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
130 'gnus-gather-threads-by-subject
131 "Function used for gathering loose threads.
132 There are two pre-defined functions: `gnus-gather-threads-by-subject',
133 which only takes Subjects into consideration; and
134 `gnus-gather-threads-by-references', which compared the References
135 headers of the articles to find matches."
137 :type '(set (function-item gnus-gather-threads-by-subject)
138 (function-item gnus-gather-threads-by-references)
139 (function :tag "other")))
141 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
142 (defcustom gnus-summary-same-subject ""
143 "*String indicating that the current article has the same subject as the previous.
144 This variable will only be used if the value of
145 `gnus-summary-make-false-root' is `empty'."
146 :group 'gnus-summary-format
149 (defcustom gnus-summary-goto-unread t
150 "*If t, marking commands will go to the next unread article.
151 If `never', commands that usually go to the next unread article, will
152 go to the next article, whether it is read or not.
153 If nil, only the marking commands will go to the next (un)read article."
154 :group 'gnus-summary-marks
155 :link '(custom-manual "(gnus)Setting Marks")
156 :type '(choice (const :tag "off" nil)
158 (sexp :menu-tag "on" t)))
160 (defcustom gnus-summary-default-score 0
161 "*Default article score level.
162 All scores generated by the score files will be added to this score.
163 If this variable is nil, scoring will be disabled."
164 :group 'gnus-score-default
165 :type '(choice (const :tag "disable")
168 (defcustom gnus-summary-zcore-fuzz 0
169 "*Fuzziness factor for the zcore in the summary buffer.
170 Articles with scores closer than this to `gnus-summary-default-score'
172 :group 'gnus-summary-format
175 (defcustom gnus-simplify-subject-fuzzy-regexp nil
176 "*Strings to be removed when doing fuzzy matches.
177 This can either be a regular expression or list of regular expressions
178 that will be removed from subject strings if fuzzy subject
179 simplification is selected."
181 :type '(repeat regexp))
183 (defcustom gnus-show-threads t
184 "*If non-nil, display threads in summary mode."
188 (defcustom gnus-thread-hide-subtree nil
189 "*If non-nil, hide all threads initially.
190 If threads are hidden, you have to run the command
191 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
192 to expose hidden threads."
196 (defcustom gnus-thread-hide-killed t
197 "*If non-nil, hide killed threads automatically."
201 (defcustom gnus-thread-ignore-subject nil
202 "*If non-nil, ignore subjects and do all threading based on the Reference header.
203 If nil, which is the default, articles that have different subjects
204 from their parents will start separate threads."
208 (defcustom gnus-thread-operation-ignore-subject t
209 "*If non-nil, subjects will be ignored when doing thread commands.
210 This affects commands like `gnus-summary-kill-thread' and
211 `gnus-summary-lower-thread'.
213 If this variable is nil, articles in the same thread with different
214 subjects will not be included in the operation in question. If this
215 variable is `fuzzy', only articles that have subjects that are fuzzily
216 equal will be included."
218 :type '(choice (const :tag "off" nil)
222 (defcustom gnus-thread-indent-level 4
223 "*Number that says how much each sub-thread should be indented."
227 (defcustom gnus-auto-extend-newsgroup t
228 "*If non-nil, extend newsgroup forward and backward when requested."
229 :group 'gnus-summary-choose
232 (defcustom gnus-auto-select-first t
233 "*If nil, don't select the first unread article when entering a group.
234 If this variable is `best', select the highest-scored unread article
235 in the group. If neither nil nor `best', select the first unread
238 If you want to prevent automatic selection of the first unread article
239 in some newsgroups, set the variable to nil in
240 `gnus-select-group-hook'."
241 :group 'gnus-group-select
242 :type '(choice (const :tag "none" nil)
244 (sexp :menu-tag "first" t)))
246 (defcustom gnus-auto-select-next t
247 "*If non-nil, offer to go to the next group from the end of the previous.
248 If the value is t and the next newsgroup is empty, Gnus will exit
249 summary mode and go back to group mode. If the value is neither nil
250 nor t, Gnus will select the following unread newsgroup. In
251 particular, if the value is the symbol `quietly', the next unread
252 newsgroup will be selected without any confirmation, and if it is
253 `almost-quietly', the next group will be selected without any
254 confirmation if you are located on the last article in the group.
255 Finally, if this variable is `slightly-quietly', the `Z n' command
256 will go to the next group without confirmation."
257 :group 'gnus-summary-maneuvering
258 :type '(choice (const :tag "off" nil)
260 (const almost-quietly)
261 (const slightly-quietly)
262 (sexp :menu-tag "on" t)))
264 (defcustom gnus-auto-select-same nil
265 "*If non-nil, select the next article with the same subject."
266 :group 'gnus-summary-maneuvering
269 (defcustom gnus-summary-check-current nil
270 "*If non-nil, consider the current article when moving.
271 The \"unread\" movement commands will stay on the same line if the
272 current article is unread."
273 :group 'gnus-summary-maneuvering
276 (defcustom gnus-auto-center-summary t
277 "*If non-nil, always center the current summary buffer.
278 In particular, if `vertical' do only vertical recentering. If non-nil
279 and non-`vertical', do both horizontal and vertical recentering."
280 :group 'gnus-summary-maneuvering
281 :type '(choice (const :tag "none" nil)
283 (sexp :menu-tag "both" t)))
285 (defcustom gnus-show-all-headers nil
286 "*If non-nil, don't hide any headers."
287 :group 'gnus-article-hiding
288 :group 'gnus-article-headers
291 (defcustom gnus-single-article-buffer t
292 "*If non-nil, display all articles in the same buffer.
293 If nil, each group will get its own article buffer."
294 :group 'gnus-article-various
297 (defcustom gnus-break-pages t
298 "*If non-nil, do page breaking on articles.
299 The page delimiter is specified by the `gnus-page-delimiter'
301 :group 'gnus-article-various
304 (defcustom gnus-show-mime nil
305 "*If non-nil, do mime processing of articles.
306 The articles will simply be fed to the function given by
307 `gnus-show-mime-method'."
308 :group 'gnus-article-mime
311 (defcustom gnus-move-split-methods nil
312 "*Variable used to suggest where articles are to be moved to.
313 It uses the same syntax as the `gnus-split-methods' variable."
314 :group 'gnus-summary-mail
315 :type '(repeat (choice (list function)
316 (cons regexp (repeat string))
319 (defcustom gnus-unread-mark ?
320 "*Mark used for unread articles."
321 :group 'gnus-summary-marks
324 (defcustom gnus-ticked-mark ?!
325 "*Mark used for ticked articles."
326 :group 'gnus-summary-marks
329 (defcustom gnus-dormant-mark ??
330 "*Mark used for dormant articles."
331 :group 'gnus-summary-marks
334 (defcustom gnus-del-mark ?r
335 "*Mark used for del'd articles."
336 :group 'gnus-summary-marks
339 (defcustom gnus-read-mark ?R
340 "*Mark used for read articles."
341 :group 'gnus-summary-marks
344 (defcustom gnus-expirable-mark ?E
345 "*Mark used for expirable articles."
346 :group 'gnus-summary-marks
349 (defcustom gnus-killed-mark ?K
350 "*Mark used for killed articles."
351 :group 'gnus-summary-marks
354 (defcustom gnus-souped-mark ?F
355 "*Mark used for killed articles."
356 :group 'gnus-summary-marks
359 (defcustom gnus-kill-file-mark ?X
360 "*Mark used for articles killed by kill files."
361 :group 'gnus-summary-marks
364 (defcustom gnus-low-score-mark ?Y
365 "*Mark used for articles with a low score."
366 :group 'gnus-summary-marks
369 (defcustom gnus-catchup-mark ?C
370 "*Mark used for articles that are caught up."
371 :group 'gnus-summary-marks
374 (defcustom gnus-replied-mark ?A
375 "*Mark used for articles that have been replied to."
376 :group 'gnus-summary-marks
379 (defcustom gnus-cached-mark ?*
380 "*Mark used for articles that are in the cache."
381 :group 'gnus-summary-marks
384 (defcustom gnus-saved-mark ?S
385 "*Mark used for articles that have been saved to."
386 :group 'gnus-summary-marks
389 (defcustom gnus-ancient-mark ?O
390 "*Mark used for ancient articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-sparse-mark ?Q
395 "*Mark used for sparsely reffed articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-canceled-mark ?G
400 "*Mark used for canceled articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-duplicate-mark ?M
405 "*Mark used for duplicate articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-score-over-mark ?+
410 "*Score mark used for articles with high scores."
411 :group 'gnus-summary-marks
414 (defcustom gnus-score-below-mark ?-
415 "*Score mark used for articles with low scores."
416 :group 'gnus-summary-marks
419 (defcustom gnus-empty-thread-mark ?
420 "*There is no thread under the article."
421 :group 'gnus-summary-marks
424 (defcustom gnus-not-empty-thread-mark ?=
425 "*There is a thread under the article."
426 :group 'gnus-summary-marks
429 (defcustom gnus-view-pseudo-asynchronously nil
430 "*If non-nil, Gnus will view pseudo-articles asynchronously."
431 :group 'gnus-extract-view
434 (defcustom gnus-view-pseudos nil
435 "*If `automatic', pseudo-articles will be viewed automatically.
436 If `not-confirm', pseudos will be viewed automatically, and the user
437 will not be asked to confirm the command."
438 :group 'gnus-extract-view
439 :type '(choice (const :tag "off" nil)
441 (const not-confirm)))
443 (defcustom gnus-view-pseudos-separately t
444 "*If non-nil, one pseudo-article will be created for each file to be viewed.
445 If nil, all files that use the same viewing command will be given as a
446 list of parameters to that command."
447 :group 'gnus-extract-view
450 (defcustom gnus-insert-pseudo-articles t
451 "*If non-nil, insert pseudo-articles when decoding articles."
452 :group 'gnus-extract-view
455 (defcustom gnus-summary-dummy-line-format
457 "*The format specification for the dummy roots in the summary buffer.
458 It works along the same lines as a normal formatting string,
459 with some simple extensions.
462 :group 'gnus-threading
465 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
466 "*The format specification for the summary mode line.
467 It works along the same lines as a normal formatting string,
468 with some simple extensions:
471 %p Unprefixed group name
472 %A Current article number
474 %U Number of unread articles in the group
475 %e Number of unselected articles in the group
476 %Z A string with unread/unselected article counts
477 %g Shortish group name
478 %S Subject of the current article
480 %s Current score file name
481 %d Number of dormant articles
482 %r Number of articles that have been marked as read in this session
483 %E Number of articles expunged by the score files"
484 :group 'gnus-summary-format
487 (defcustom gnus-summary-mark-below 0
488 "*Mark all articles with a score below this variable as read.
489 This variable is local to each summary buffer and usually set by the
491 :group 'gnus-score-default
494 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
495 "*List of functions used for sorting articles in the summary buffer.
496 This variable is only used when not using a threaded display."
497 :group 'gnus-summary-sort
498 :type '(repeat (choice (function-item gnus-article-sort-by-number)
499 (function-item gnus-article-sort-by-author)
500 (function-item gnus-article-sort-by-subject)
501 (function-item gnus-article-sort-by-date)
502 (function-item gnus-article-sort-by-score)
503 (function :tag "other"))))
505 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
506 "*List of functions used for sorting threads in the summary buffer.
507 By default, threads are sorted by article number.
509 Each function takes two threads and return non-nil if the first thread
510 should be sorted before the other. If you use more than one function,
511 the primary sort function should be the last. You should probably
512 always include `gnus-thread-sort-by-number' in the list of sorting
513 functions -- preferably first.
515 Ready-made functions include `gnus-thread-sort-by-number',
516 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
517 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
518 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
519 :group 'gnus-summary-sort
520 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
521 (function-item gnus-thread-sort-by-author)
522 (function-item gnus-thread-sort-by-subject)
523 (function-item gnus-thread-sort-by-date)
524 (function-item gnus-thread-sort-by-score)
525 (function-item gnus-thread-sort-by-total-score)
526 (function :tag "other"))))
528 (defcustom gnus-thread-score-function '+
529 "*Function used for calculating the total score of a thread.
531 The function is called with the scores of the article and each
532 subthread and should then return the score of the thread.
534 Some functions you can use are `+', `max', or `min'."
535 :group 'gnus-summary-sort
538 (defcustom gnus-summary-expunge-below nil
539 "All articles that have a score less than this variable will be expunged."
540 :group 'gnus-score-default
541 :type '(choice (const :tag "off" nil)
544 (defcustom gnus-thread-expunge-below nil
545 "All threads that have a total score less than this variable will be expunged.
546 See `gnus-thread-score-function' for en explanation of what a
547 \"thread score\" is."
548 :group 'gnus-treading
549 :group 'gnus-score-default
550 :type '(choice (const :tag "off" nil)
553 (defcustom gnus-summary-mode-hook nil
554 "*A hook for Gnus summary mode.
555 This hook is run before any variables are set in the summary buffer."
556 :group 'gnus-summary-various
559 (defcustom gnus-summary-menu-hook nil
560 "*Hook run after the creation of the summary mode menu."
561 :group 'gnus-summary-visual
564 (defcustom gnus-summary-exit-hook nil
565 "*A hook called on exit from the summary buffer.
566 It will be called with point in the group buffer."
567 :group 'gnus-summary-exit
570 (defcustom gnus-summary-prepare-hook nil
571 "*A hook called after the summary buffer has been generated.
572 If you want to modify the summary buffer, you can use this hook."
573 :group 'gnus-summary-various
576 (defcustom gnus-summary-generate-hook nil
577 "*A hook run just before generating the summary buffer.
578 This hook is commonly used to customize threading variables and the
580 :group 'gnus-summary-various
583 (defcustom gnus-select-group-hook nil
584 "*A hook called when a newsgroup is selected.
586 If you'd like to simplify subjects like the
587 `gnus-summary-next-same-subject' command does, you can use the
590 (setq gnus-select-group-hook
593 (mapcar (lambda (header)
594 (mail-header-set-subject
596 (gnus-simplify-subject
597 (mail-header-subject header) 're-only)))
598 gnus-newsgroup-headers))))"
599 :group 'gnus-group-select
602 (defcustom gnus-select-article-hook nil
603 "*A hook called when an article is selected."
604 :group 'gnus-summary-choose
607 (defcustom gnus-visual-mark-article-hook
608 (list 'gnus-highlight-selected-summary)
609 "*Hook run after selecting an article in the summary buffer.
610 It is meant to be used for highlighting the article in some way. It
611 is not run if `gnus-visual' is nil."
612 :group 'gnus-summary-visual
615 (defcustom gnus-parse-headers-hook
616 (list 'gnus-decode-rfc1522)
617 "*A hook called before parsing the headers."
621 (defcustom gnus-exit-group-hook nil
622 "*A hook called when exiting (not quitting) summary mode."
626 (defcustom gnus-summary-update-hook
627 (list 'gnus-summary-highlight-line)
628 "*A hook called when a summary line is changed.
629 The hook will not be called if `gnus-visual' is nil.
631 The default function `gnus-summary-highlight-line' will
632 highlight the line according to the `gnus-summary-highlight'
634 :group 'gnus-summary-visual
637 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
638 "*A hook called when an article is selected for the first time.
639 The hook is intended to mark an article as read (or unread)
640 automatically when it is selected."
641 :group 'gnus-summary-choose
644 (defcustom gnus-group-no-more-groups-hook nil
645 "*A hook run when returning to group mode having no more (unread) groups."
646 :group 'gnus-group-select
649 (defcustom gnus-ps-print-hook nil
650 "*A hook run before ps-printing something from Gnus."
654 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
655 "Face used for highlighting the current article in the summary buffer."
656 :group 'gnus-summary-visual
659 (defcustom gnus-summary-highlight
660 '(((= mark gnus-canceled-mark)
661 . gnus-summary-cancelled-face)
662 ((and (> score default)
663 (or (= mark gnus-dormant-mark)
664 (= mark gnus-ticked-mark)))
665 . gnus-summary-high-ticked-face)
666 ((and (< score default)
667 (or (= mark gnus-dormant-mark)
668 (= mark gnus-ticked-mark)))
669 . gnus-summary-low-ticked-face)
670 ((or (= mark gnus-dormant-mark)
671 (= mark gnus-ticked-mark))
672 . gnus-summary-normal-ticked-face)
673 ((and (> score default) (= mark gnus-ancient-mark))
674 . gnus-summary-high-ancient-face)
675 ((and (< score default) (= mark gnus-ancient-mark))
676 . gnus-summary-low-ancient-face)
677 ((= mark gnus-ancient-mark)
678 . gnus-summary-normal-ancient-face)
679 ((and (> score default) (= mark gnus-unread-mark))
680 . gnus-summary-high-unread-face)
681 ((and (< score default) (= mark gnus-unread-mark))
682 . gnus-summary-low-unread-face)
683 ((and (= mark gnus-unread-mark))
684 . gnus-summary-normal-unread-face)
686 . gnus-summary-high-read-face)
688 . gnus-summary-low-read-face)
690 . gnus-summary-normal-read-face))
691 "Controls the highlighting of summary buffer lines.
693 A list of (FORM . FACE) pairs. When deciding how a a particular
694 summary line should be displayed, each form is evaluated. The content
695 of the face field after the first true form is used. You can change
696 how those summary lines are displayed, by editing the face field.
698 You can use the following variables in the FORM field.
700 score: The articles score
701 default: The default article score.
702 below: The score below which articles are automatically marked as read.
703 mark: The articles mark."
704 :group 'gnus-summary-visual
705 :type '(repeat (cons (sexp :tag "Form" nil)
709 ;;; Internal variables
711 (defvar gnus-scores-exclude-files nil)
713 (defvar gnus-summary-display-table
714 ;; Change the display table. Odd characters have a tendency to mess
715 ;; up nicely formatted displays - we make all possible glyphs
716 ;; display only a single character.
718 ;; We start from the standard display table, if any.
719 (let ((table (or (copy-sequence standard-display-table)
720 (make-display-table)))
721 ;; Nix out all the control chars...
723 (while (>= (setq i (1- i)) 0)
725 ;; ... but not newline and cr, of course. (cr is necessary for the
726 ;; selective display).
729 ;; We nix out any glyphs over 126 that are not set already.
731 (while (>= (setq i (1- i)) 127)
732 ;; Only modify if the entry is nil.
734 (aset table i [??]))))
736 "Display table used in summary mode buffers.")
738 (defvar gnus-original-article nil)
739 (defvar gnus-article-internal-prepare-hook nil)
740 (defvar gnus-newsgroup-process-stack nil)
742 (defvar gnus-thread-indent-array nil)
743 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
745 ;; Avoid highlighting in kill files.
746 (defvar gnus-summary-inhibit-highlight nil)
747 (defvar gnus-newsgroup-selected-overlay nil)
748 (defvar gnus-inhibit-limiting nil)
749 (defvar gnus-newsgroup-adaptive-score-file nil)
750 (defvar gnus-current-score-file nil)
751 (defvar gnus-current-move-group nil)
752 (defvar gnus-current-copy-group nil)
753 (defvar gnus-current-crosspost-group nil)
755 (defvar gnus-newsgroup-dependencies nil)
756 (defvar gnus-newsgroup-adaptive nil)
757 (defvar gnus-summary-display-article-function nil)
758 (defvar gnus-summary-highlight-line-function nil
759 "Function called after highlighting a summary line.")
761 (defvar gnus-summary-line-format-alist
762 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
763 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
764 (?s gnus-tmp-subject-or-nil ?s)
765 (?n gnus-tmp-name ?s)
766 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
768 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
770 (?F gnus-tmp-from ?s)
771 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
772 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
773 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
774 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
775 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
776 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
777 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
778 (?L gnus-tmp-lines ?d)
779 (?I gnus-tmp-indentation ?s)
780 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
781 (?R gnus-tmp-replied ?c)
782 (?\[ gnus-tmp-opening-bracket ?c)
783 (?\] gnus-tmp-closing-bracket ?c)
784 (?\> (make-string gnus-tmp-level ? ) ?s)
785 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
786 (?i gnus-tmp-score ?d)
787 (?z gnus-tmp-score-char ?c)
788 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
789 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
790 (?U gnus-tmp-unread ?c)
791 (?t (gnus-summary-number-of-articles-in-thread
792 (and (boundp 'thread) (car thread)) gnus-tmp-level)
794 (?e (gnus-summary-number-of-articles-in-thread
795 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
797 (?u gnus-tmp-user-defined ?s)
798 (?P (gnus-pick-line-number) ?d))
799 "An alist of format specifications that can appear in summary lines,
800 and what variables they correspond with, along with the type of the
801 variable (string, integer, character, etc).")
803 (defvar gnus-summary-dummy-line-format-alist
804 `((?S gnus-tmp-subject ?s)
805 (?N gnus-tmp-number ?d)
806 (?u gnus-tmp-user-defined ?s)))
808 (defvar gnus-summary-mode-line-format-alist
809 `((?G gnus-tmp-group-name ?s)
810 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
811 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
812 (?A gnus-tmp-article-number ?d)
813 (?Z gnus-tmp-unread-and-unselected ?s)
815 (?U gnus-tmp-unread-and-unticked ?d)
816 (?S gnus-tmp-subject ?s)
817 (?e gnus-tmp-unselected ?d)
818 (?u gnus-tmp-user-defined ?s)
819 (?d (length gnus-newsgroup-dormant) ?d)
820 (?t (length gnus-newsgroup-marked) ?d)
821 (?r (length gnus-newsgroup-reads) ?d)
822 (?E gnus-newsgroup-expunged-tally ?d)
823 (?s (gnus-current-score-file-nondirectory) ?s)))
825 (defvar gnus-last-search-regexp nil
826 "Default regexp for article search command.")
828 (defvar gnus-last-shell-command nil
829 "Default shell command on article.")
831 (defvar gnus-newsgroup-begin nil)
832 (defvar gnus-newsgroup-end nil)
833 (defvar gnus-newsgroup-last-rmail nil)
834 (defvar gnus-newsgroup-last-mail nil)
835 (defvar gnus-newsgroup-last-folder nil)
836 (defvar gnus-newsgroup-last-file nil)
837 (defvar gnus-newsgroup-auto-expire nil)
838 (defvar gnus-newsgroup-active nil)
840 (defvar gnus-newsgroup-data nil)
841 (defvar gnus-newsgroup-data-reverse nil)
842 (defvar gnus-newsgroup-limit nil)
843 (defvar gnus-newsgroup-limits nil)
845 (defvar gnus-newsgroup-unreads nil
846 "List of unread articles in the current newsgroup.")
848 (defvar gnus-newsgroup-unselected nil
849 "List of unselected unread articles in the current newsgroup.")
851 (defvar gnus-newsgroup-reads nil
852 "Alist of read articles and article marks in the current newsgroup.")
854 (defvar gnus-newsgroup-expunged-tally nil)
856 (defvar gnus-newsgroup-marked nil
857 "List of ticked articles in the current newsgroup (a subset of unread art).")
859 (defvar gnus-newsgroup-killed nil
860 "List of ranges of articles that have been through the scoring process.")
862 (defvar gnus-newsgroup-cached nil
863 "List of articles that come from the article cache.")
865 (defvar gnus-newsgroup-saved nil
866 "List of articles that have been saved.")
868 (defvar gnus-newsgroup-kill-headers nil)
870 (defvar gnus-newsgroup-replied nil
871 "List of articles that have been replied to in the current newsgroup.")
873 (defvar gnus-newsgroup-expirable nil
874 "List of articles in the current newsgroup that can be expired.")
876 (defvar gnus-newsgroup-processable nil
877 "List of articles in the current newsgroup that can be processed.")
879 (defvar gnus-newsgroup-bookmarks nil
880 "List of articles in the current newsgroup that have bookmarks.")
882 (defvar gnus-newsgroup-dormant nil
883 "List of dormant articles in the current newsgroup.")
885 (defvar gnus-newsgroup-scored nil
886 "List of scored articles in the current newsgroup.")
888 (defvar gnus-newsgroup-headers nil
889 "List of article headers in the current newsgroup.")
891 (defvar gnus-newsgroup-threads nil)
893 (defvar gnus-newsgroup-prepared nil
894 "Whether the current group has been prepared properly.")
896 (defvar gnus-newsgroup-ancient nil
897 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
899 (defvar gnus-newsgroup-sparse nil)
901 (defvar gnus-current-article nil)
902 (defvar gnus-article-current nil)
903 (defvar gnus-current-headers nil)
904 (defvar gnus-have-all-headers nil)
905 (defvar gnus-last-article nil)
906 (defvar gnus-newsgroup-history nil)
908 (defconst gnus-summary-local-variables
909 '(gnus-newsgroup-name
910 gnus-newsgroup-begin gnus-newsgroup-end
911 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
912 gnus-newsgroup-last-folder gnus-newsgroup-last-file
913 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
914 gnus-newsgroup-unselected gnus-newsgroup-marked
915 gnus-newsgroup-reads gnus-newsgroup-saved
916 gnus-newsgroup-replied gnus-newsgroup-expirable
917 gnus-newsgroup-processable gnus-newsgroup-killed
918 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
919 gnus-newsgroup-headers gnus-newsgroup-threads
920 gnus-newsgroup-prepared gnus-summary-highlight-line-function
921 gnus-current-article gnus-current-headers gnus-have-all-headers
922 gnus-last-article gnus-article-internal-prepare-hook
923 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
924 gnus-newsgroup-scored gnus-newsgroup-kill-headers
925 gnus-thread-expunge-below
926 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
927 (gnus-summary-mark-below . global)
928 gnus-newsgroup-active gnus-scores-exclude-files
929 gnus-newsgroup-history gnus-newsgroup-ancient
930 gnus-newsgroup-sparse gnus-newsgroup-process-stack
931 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
932 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
933 (gnus-newsgroup-expunged-tally . 0)
934 gnus-cache-removable-articles gnus-newsgroup-cached
935 gnus-newsgroup-data gnus-newsgroup-data-reverse
936 gnus-newsgroup-limit gnus-newsgroup-limits)
937 "Variables that are buffer-local to the summary buffers.")
939 ;; Byte-compiler warning.
940 (defvar gnus-article-mode-map)
942 ;; Subject simplification.
944 (defsubst gnus-simplify-subject-re (subject)
945 "Remove \"Re:\" from subject lines."
946 (if (string-match "^[Rr][Ee]: *" subject)
947 (substring subject (match-end 0))
950 (defun gnus-simplify-subject (subject &optional re-only)
951 "Remove `Re:' and words in parentheses.
952 If RE-ONLY is non-nil, strip leading `Re:'s only."
953 (let ((case-fold-search t)) ;Ignore case.
954 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
955 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
956 (setq subject (substring subject (match-end 0))))
957 ;; Remove uninteresting prefixes.
958 (when (and (not re-only)
959 gnus-simplify-ignored-prefixes
960 (string-match gnus-simplify-ignored-prefixes subject))
961 (setq subject (substring subject (match-end 0))))
962 ;; Remove words in parentheses from end.
964 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
965 (setq subject (substring subject 0 (match-beginning 0)))))
966 ;; Return subject string.
969 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
971 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
972 (goto-char (point-min))
973 (while (re-search-forward regexp nil t)
974 (replace-match (or newtext ""))))
976 (defun gnus-simplify-buffer-fuzzy ()
977 "Simplify string in the buffer fuzzily.
978 The string in the accessible portion of the current buffer is simplified.
979 It is assumed to be a single-line subject.
980 Whitespace is generally cleaned up, and miscellaneous leading/trailing
981 matter is removed. Additional things can be deleted by setting
982 gnus-simplify-subject-fuzzy-regexp."
983 (let ((case-fold-search t)
985 (gnus-simplify-buffer-fuzzy-step "\t" " ")
987 (while (not (eq modified-tick (buffer-modified-tick)))
988 (setq modified-tick (buffer-modified-tick))
990 ((listp gnus-simplify-subject-fuzzy-regexp)
991 (mapcar 'gnus-simplify-buffer-fuzzy-step
992 gnus-simplify-subject-fuzzy-regexp))
993 (gnus-simplify-subject-fuzzy-regexp
994 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
995 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
996 (gnus-simplify-buffer-fuzzy-step
997 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
998 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1000 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1001 (gnus-simplify-buffer-fuzzy-step " +" " ")
1002 (gnus-simplify-buffer-fuzzy-step " $")
1003 (gnus-simplify-buffer-fuzzy-step "^ +")))
1005 (defun gnus-simplify-subject-fuzzy (subject)
1006 "Simplify a subject string fuzzily.
1007 See gnus-simplify-buffer-fuzzy for details."
1009 (gnus-set-work-buffer)
1010 (let ((case-fold-search t))
1012 (inline (gnus-simplify-buffer-fuzzy))
1015 (defsubst gnus-simplify-subject-fully (subject)
1016 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1018 ((null gnus-summary-gather-subject-limit)
1019 (gnus-simplify-subject-re subject))
1020 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1021 (gnus-simplify-subject-fuzzy subject))
1022 ((numberp gnus-summary-gather-subject-limit)
1023 (gnus-limit-string (gnus-simplify-subject-re subject)
1024 gnus-summary-gather-subject-limit))
1028 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1029 "Check whether two subjects are equal. If optional argument
1030 simple-first is t, first argument is already simplified."
1032 ((null simple-first)
1033 (equal (gnus-simplify-subject-fully s1)
1034 (gnus-simplify-subject-fully s2)))
1037 (gnus-simplify-subject-fully s2)))))
1039 (defun gnus-summary-bubble-group ()
1040 "Increase the score of the current group.
1041 This is a handy function to add to `gnus-summary-exit-hook' to
1042 increase the score of each group you read."
1043 (gnus-group-add-score gnus-newsgroup-name))
1047 ;;; Gnus summary mode
1050 (put 'gnus-summary-mode 'mode-class 'special)
1053 ;; Non-orthogonal keys
1055 (gnus-define-keys gnus-summary-mode-map
1056 " " gnus-summary-next-page
1057 "\177" gnus-summary-prev-page
1058 [delete] gnus-summary-prev-page
1059 "\r" gnus-summary-scroll-up
1060 "n" gnus-summary-next-unread-article
1061 "p" gnus-summary-prev-unread-article
1062 "N" gnus-summary-next-article
1063 "P" gnus-summary-prev-article
1064 "\M-\C-n" gnus-summary-next-same-subject
1065 "\M-\C-p" gnus-summary-prev-same-subject
1066 "\M-n" gnus-summary-next-unread-subject
1067 "\M-p" gnus-summary-prev-unread-subject
1068 "." gnus-summary-first-unread-article
1069 "," gnus-summary-best-unread-article
1070 "\M-s" gnus-summary-search-article-forward
1071 "\M-r" gnus-summary-search-article-backward
1072 "<" gnus-summary-beginning-of-article
1073 ">" gnus-summary-end-of-article
1074 "j" gnus-summary-goto-article
1075 "^" gnus-summary-refer-parent-article
1076 "\M-^" gnus-summary-refer-article
1077 "u" gnus-summary-tick-article-forward
1078 "!" gnus-summary-tick-article-forward
1079 "U" gnus-summary-tick-article-backward
1080 "d" gnus-summary-mark-as-read-forward
1081 "D" gnus-summary-mark-as-read-backward
1082 "E" gnus-summary-mark-as-expirable
1083 "\M-u" gnus-summary-clear-mark-forward
1084 "\M-U" gnus-summary-clear-mark-backward
1085 "k" gnus-summary-kill-same-subject-and-select
1086 "\C-k" gnus-summary-kill-same-subject
1087 "\M-\C-k" gnus-summary-kill-thread
1088 "\M-\C-l" gnus-summary-lower-thread
1089 "e" gnus-summary-edit-article
1090 "#" gnus-summary-mark-as-processable
1091 "\M-#" gnus-summary-unmark-as-processable
1092 "\M-\C-t" gnus-summary-toggle-threads
1093 "\M-\C-s" gnus-summary-show-thread
1094 "\M-\C-h" gnus-summary-hide-thread
1095 "\M-\C-f" gnus-summary-next-thread
1096 "\M-\C-b" gnus-summary-prev-thread
1097 "\M-\C-u" gnus-summary-up-thread
1098 "\M-\C-d" gnus-summary-down-thread
1099 "&" gnus-summary-execute-command
1100 "c" gnus-summary-catchup-and-exit
1101 "\C-w" gnus-summary-mark-region-as-read
1102 "\C-t" gnus-summary-toggle-truncation
1103 "?" gnus-summary-mark-as-dormant
1104 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1105 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1106 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1107 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1108 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1109 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1110 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1111 "=" gnus-summary-expand-window
1112 "\C-x\C-s" gnus-summary-reselect-current-group
1113 "\M-g" gnus-summary-rescan-group
1114 "w" gnus-summary-stop-page-breaking
1115 "\C-c\C-r" gnus-summary-caesar-message
1116 "\M-t" gnus-summary-toggle-mime
1117 "f" gnus-summary-followup
1118 "F" gnus-summary-followup-with-original
1119 "C" gnus-summary-cancel-article
1120 "r" gnus-summary-reply
1121 "R" gnus-summary-reply-with-original
1122 "\C-c\C-f" gnus-summary-mail-forward
1123 "o" gnus-summary-save-article
1124 "\C-o" gnus-summary-save-article-mail
1125 "|" gnus-summary-pipe-output
1126 "\M-k" gnus-summary-edit-local-kill
1127 "\M-K" gnus-summary-edit-global-kill
1129 "\C-c\C-d" gnus-summary-describe-group
1130 "q" gnus-summary-exit
1131 "Q" gnus-summary-exit-no-update
1132 "\C-c\C-i" gnus-info-find-node
1133 gnus-mouse-2 gnus-mouse-pick-article
1134 "m" gnus-summary-mail-other-window
1135 "a" gnus-summary-post-news
1136 "x" gnus-summary-limit-to-unread
1137 "s" gnus-summary-isearch-article
1138 "t" gnus-article-hide-headers
1139 "g" gnus-summary-show-article
1140 "l" gnus-summary-goto-last-article
1141 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1142 "\C-d" gnus-summary-enter-digest-group
1143 "\M-\C-d" gnus-summary-read-document
1145 "*" gnus-cache-enter-article
1146 "\M-*" gnus-cache-remove-article
1147 "\M-&" gnus-summary-universal-argument
1148 "\C-l" gnus-recenter
1149 "I" gnus-summary-increase-score
1150 "L" gnus-summary-lower-score
1152 "V" gnus-summary-score-map
1153 "X" gnus-uu-extract-map
1154 "S" gnus-summary-send-map)
1156 ;; Sort of orthogonal keymap
1157 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1158 "t" gnus-summary-tick-article-forward
1159 "!" gnus-summary-tick-article-forward
1160 "d" gnus-summary-mark-as-read-forward
1161 "r" gnus-summary-mark-as-read-forward
1162 "c" gnus-summary-clear-mark-forward
1163 " " gnus-summary-clear-mark-forward
1164 "e" gnus-summary-mark-as-expirable
1165 "x" gnus-summary-mark-as-expirable
1166 "?" gnus-summary-mark-as-dormant
1167 "b" gnus-summary-set-bookmark
1168 "B" gnus-summary-remove-bookmark
1169 "#" gnus-summary-mark-as-processable
1170 "\M-#" gnus-summary-unmark-as-processable
1171 "S" gnus-summary-limit-include-expunged
1172 "C" gnus-summary-catchup
1173 "H" gnus-summary-catchup-to-here
1174 "\C-c" gnus-summary-catchup-all
1175 "k" gnus-summary-kill-same-subject-and-select
1176 "K" gnus-summary-kill-same-subject
1177 "P" gnus-uu-mark-map)
1179 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1180 "c" gnus-summary-clear-above
1181 "u" gnus-summary-tick-above
1182 "m" gnus-summary-mark-above
1183 "k" gnus-summary-kill-below)
1185 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1186 "/" gnus-summary-limit-to-subject
1187 "n" gnus-summary-limit-to-articles
1188 "w" gnus-summary-pop-limit
1189 "s" gnus-summary-limit-to-subject
1190 "a" gnus-summary-limit-to-author
1191 "u" gnus-summary-limit-to-unread
1192 "m" gnus-summary-limit-to-marks
1193 "v" gnus-summary-limit-to-score
1194 "D" gnus-summary-limit-include-dormant
1195 "d" gnus-summary-limit-exclude-dormant
1196 "t" gnus-summary-limit-to-age
1197 "E" gnus-summary-limit-include-expunged
1198 "c" gnus-summary-limit-exclude-childless-dormant
1199 "C" gnus-summary-limit-mark-excluded-as-read)
1201 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1202 "n" gnus-summary-next-unread-article
1203 "p" gnus-summary-prev-unread-article
1204 "N" gnus-summary-next-article
1205 "P" gnus-summary-prev-article
1206 "\C-n" gnus-summary-next-same-subject
1207 "\C-p" gnus-summary-prev-same-subject
1208 "\M-n" gnus-summary-next-unread-subject
1209 "\M-p" gnus-summary-prev-unread-subject
1210 "f" gnus-summary-first-unread-article
1211 "b" gnus-summary-best-unread-article
1212 "j" gnus-summary-goto-article
1213 "g" gnus-summary-goto-subject
1214 "l" gnus-summary-goto-last-article
1215 "p" gnus-summary-pop-article)
1217 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1218 "k" gnus-summary-kill-thread
1219 "l" gnus-summary-lower-thread
1220 "i" gnus-summary-raise-thread
1221 "T" gnus-summary-toggle-threads
1222 "t" gnus-summary-rethread-current
1223 "^" gnus-summary-reparent-thread
1224 "s" gnus-summary-show-thread
1225 "S" gnus-summary-show-all-threads
1226 "h" gnus-summary-hide-thread
1227 "H" gnus-summary-hide-all-threads
1228 "n" gnus-summary-next-thread
1229 "p" gnus-summary-prev-thread
1230 "u" gnus-summary-up-thread
1231 "o" gnus-summary-top-thread
1232 "d" gnus-summary-down-thread
1233 "#" gnus-uu-mark-thread
1234 "\M-#" gnus-uu-unmark-thread)
1236 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1237 "g" gnus-summary-prepare
1238 "c" gnus-summary-insert-cached-articles)
1240 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1241 "c" gnus-summary-catchup-and-exit
1242 "C" gnus-summary-catchup-all-and-exit
1243 "E" gnus-summary-exit-no-update
1244 "Q" gnus-summary-exit
1245 "Z" gnus-summary-exit
1246 "n" gnus-summary-catchup-and-goto-next-group
1247 "R" gnus-summary-reselect-current-group
1248 "G" gnus-summary-rescan-group
1249 "N" gnus-summary-next-group
1250 "s" gnus-summary-save-newsrc
1251 "P" gnus-summary-prev-group)
1253 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1254 " " gnus-summary-next-page
1255 "n" gnus-summary-next-page
1256 "\177" gnus-summary-prev-page
1257 [delete] gnus-summary-prev-page
1258 "p" gnus-summary-prev-page
1259 "\r" gnus-summary-scroll-up
1260 "<" gnus-summary-beginning-of-article
1261 ">" gnus-summary-end-of-article
1262 "b" gnus-summary-beginning-of-article
1263 "e" gnus-summary-end-of-article
1264 "^" gnus-summary-refer-parent-article
1265 "r" gnus-summary-refer-parent-article
1266 "R" gnus-summary-refer-references
1267 "g" gnus-summary-show-article
1268 "s" gnus-summary-isearch-article
1269 "P" gnus-summary-print-article)
1271 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1272 "b" gnus-article-add-buttons
1273 "B" gnus-article-add-buttons-to-head
1274 "o" gnus-article-treat-overstrike
1275 "e" gnus-article-emphasize
1276 "w" gnus-article-fill-cited-article
1277 "c" gnus-article-remove-cr
1278 "q" gnus-article-de-quoted-unreadable
1279 "f" gnus-article-display-x-face
1280 "l" gnus-summary-stop-page-breaking
1281 "r" gnus-summary-caesar-message
1282 "t" gnus-article-hide-headers
1283 "v" gnus-summary-verbose-headers
1284 "m" gnus-summary-toggle-mime
1285 "h" gnus-article-treat-html)
1287 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1288 "a" gnus-article-hide
1289 "h" gnus-article-hide-headers
1290 "b" gnus-article-hide-boring-headers
1291 "s" gnus-article-hide-signature
1292 "c" gnus-article-hide-citation
1293 "p" gnus-article-hide-pgp
1294 "P" gnus-article-hide-pem
1295 "\C-c" gnus-article-hide-citation-maybe)
1297 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1298 "a" gnus-article-highlight
1299 "h" gnus-article-highlight-headers
1300 "c" gnus-article-highlight-citation
1301 "s" gnus-article-highlight-signature)
1303 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1304 "z" gnus-article-date-ut
1305 "u" gnus-article-date-ut
1306 "l" gnus-article-date-local
1307 "e" gnus-article-date-lapsed
1308 "o" gnus-article-date-original
1309 "s" gnus-article-date-user)
1311 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1312 "t" gnus-article-remove-trailing-blank-lines
1313 "l" gnus-article-strip-leading-blank-lines
1314 "m" gnus-article-strip-multiple-blank-lines
1315 "a" gnus-article-strip-blank-lines)
1317 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1319 "f" gnus-summary-fetch-faq
1320 "d" gnus-summary-describe-group
1321 "h" gnus-summary-describe-briefly
1322 "i" gnus-info-find-node)
1324 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1325 "e" gnus-summary-expire-articles
1326 "\M-\C-e" gnus-summary-expire-articles-now
1327 "\177" gnus-summary-delete-article
1328 [delete] gnus-summary-delete-article
1329 "m" gnus-summary-move-article
1330 "r" gnus-summary-respool-article
1331 "w" gnus-summary-edit-article
1332 "c" gnus-summary-copy-article
1333 "B" gnus-summary-crosspost-article
1334 "q" gnus-summary-respool-query
1335 "i" gnus-summary-import-article
1336 "p" gnus-summary-article-posted-p)
1338 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1339 "o" gnus-summary-save-article
1340 "m" gnus-summary-save-article-mail
1341 "F" gnus-summary-write-article-file
1342 "r" gnus-summary-save-article-rmail
1343 "f" gnus-summary-save-article-file
1344 "b" gnus-summary-save-article-body-file
1345 "h" gnus-summary-save-article-folder
1346 "v" gnus-summary-save-article-vm
1347 "p" gnus-summary-pipe-output
1348 "s" gnus-soup-add-article))
1350 (defun gnus-summary-make-menu-bar ()
1351 (gnus-turn-off-edit-menu 'summary)
1353 (unless (boundp 'gnus-summary-misc-menu)
1356 gnus-summary-kill-menu gnus-summary-mode-map ""
1361 ["Enter score..." gnus-summary-score-entry t]
1362 ["Customize" gnus-score-customize t])
1363 (gnus-make-score-map 'increase)
1364 (gnus-make-score-map 'lower)
1366 ["Kill below" gnus-summary-kill-below t]
1367 ["Mark above" gnus-summary-mark-above t]
1368 ["Tick above" gnus-summary-tick-above t]
1369 ["Clear above" gnus-summary-clear-above t])
1370 ["Current score" gnus-summary-current-score t]
1371 ["Set score" gnus-summary-set-score t]
1372 ["Switch current score file..." gnus-score-change-score-file t]
1373 ["Set mark below..." gnus-score-set-mark-below t]
1374 ["Set expunge below..." gnus-score-set-expunge-below t]
1375 ["Edit current score file" gnus-score-edit-current-scores t]
1376 ["Edit score file" gnus-score-edit-file t]
1377 ["Trace score" gnus-score-find-trace t]
1378 ["Find words" gnus-score-find-favourite-words t]
1379 ["Rescore buffer" gnus-summary-rescore t]
1380 ["Increase score..." gnus-summary-increase-score t]
1381 ["Lower score..." gnus-summary-lower-score t]))))
1384 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1386 :selected (null gnus-score-default-header)]
1387 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1389 :selected (eq gnus-score-default-header 'a)]
1390 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1392 :selected (eq gnus-score-default-header 's)]
1394 (gnus-score-set-default 'gnus-score-default-header 'b)
1396 :selected (eq gnus-score-default-header 'b )]
1398 (gnus-score-set-default 'gnus-score-default-header 'h)
1400 :selected (eq gnus-score-default-header 'h )]
1401 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1403 :selected (eq gnus-score-default-header 'i )]
1404 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1406 :selected (eq gnus-score-default-header 't )]
1408 (gnus-score-set-default 'gnus-score-default-header 'x)
1410 :selected (eq gnus-score-default-header 'x )]
1411 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1413 :selected (eq gnus-score-default-header 'l )]
1414 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1416 :selected (eq gnus-score-default-header 'd )]
1417 ["Followups to author"
1418 (gnus-score-set-default 'gnus-score-default-header 'f)
1420 :selected (eq gnus-score-default-header 'f )])
1422 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1424 :selected (null gnus-score-default-type)]
1425 ;; The `:active' key is commented out in the following,
1426 ;; because the GNU Emacs hack to support radio buttons use
1427 ;; active to indicate which button is selected.
1428 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1430 ;; :active (not (memq gnus-score-default-header '(l d)))
1431 :selected (eq gnus-score-default-type 's)]
1432 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1434 ;; :active (not (memq gnus-score-default-header '(l d)))
1435 :selected (eq gnus-score-default-type 'r)]
1436 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1438 ;; :active (not (memq gnus-score-default-header '(l d)))
1439 :selected (eq gnus-score-default-type 'e)]
1440 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1442 ;; :active (not (memq gnus-score-default-header '(l d)))
1443 :selected (eq gnus-score-default-type 'f)]
1444 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1446 ;; :active (eq (gnus-score-default-header 'd))
1447 :selected (eq gnus-score-default-type 'b)]
1448 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1450 ;; :active (eq (gnus-score-default-header 'd))
1451 :selected (eq gnus-score-default-type 'n)]
1452 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1454 ;; :active (eq (gnus-score-default-header 'd))
1455 :selected (eq gnus-score-default-type 'a)]
1457 (gnus-score-set-default 'gnus-score-default-type '<)
1459 ;; :active (eq (gnus-score-default-header 'l))
1460 :selected (eq gnus-score-default-type '<)]
1462 (gnus-score-set-default 'gnus-score-default-type '=)
1464 ;; :active (eq (gnus-score-default-header 'l))
1465 :selected (eq gnus-score-default-type '=)]
1466 ["Greater than number"
1467 (gnus-score-set-default 'gnus-score-default-type '>)
1469 ;; :active (eq (gnus-score-default-header 'l))
1470 :selected (eq gnus-score-default-type '>)])
1471 ["Default fold" gnus-score-default-fold-toggle
1473 :selected gnus-score-default-fold]
1475 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1477 :selected (null gnus-score-default-duration)]
1479 (gnus-score-set-default 'gnus-score-default-duration 'p)
1481 :selected (eq gnus-score-default-duration 'p)]
1483 (gnus-score-set-default 'gnus-score-default-duration 't)
1485 :selected (eq gnus-score-default-duration 't)]
1487 (gnus-score-set-default 'gnus-score-default-duration 'i)
1489 :selected (eq gnus-score-default-duration 'i)]))
1492 gnus-summary-article-menu gnus-summary-mode-map ""
1495 ["All" gnus-article-hide t]
1496 ["Headers" gnus-article-hide-headers t]
1497 ["Signature" gnus-article-hide-signature t]
1498 ["Citation" gnus-article-hide-citation t]
1499 ["PGP" gnus-article-hide-pgp t]
1500 ["Boring headers" gnus-article-hide-boring-headers t])
1502 ["All" gnus-article-highlight t]
1503 ["Headers" gnus-article-highlight-headers t]
1504 ["Signature" gnus-article-highlight-signature t]
1505 ["Citation" gnus-article-highlight-citation t])
1507 ["Local" gnus-article-date-local t]
1508 ["UT" gnus-article-date-ut t]
1509 ["Original" gnus-article-date-original t]
1510 ["Lapsed" gnus-article-date-lapsed t]
1511 ["User-defined" gnus-article-date-user t])
1514 ["Leading" gnus-article-strip-leading-blank-lines t]
1515 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1516 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1517 ["All of the above" gnus-article-strip-blank-lines t])
1518 ["Overstrike" gnus-article-treat-overstrike t]
1519 ["Emphasis" gnus-article-emphasize t]
1520 ["Word wrap" gnus-article-fill-cited-article t]
1521 ["CR" gnus-article-remove-cr t]
1522 ["Show X-Face" gnus-article-display-x-face t]
1523 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1524 ["UnHTMLize" gnus-article-treat-html t]
1525 ["Rot 13" gnus-summary-caesar-message t]
1526 ["Unix pipe" gnus-summary-pipe-message t]
1527 ["Add buttons" gnus-article-add-buttons t]
1528 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1529 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1530 ["Toggle MIME" gnus-summary-toggle-mime t]
1531 ["Verbose header" gnus-summary-verbose-headers t]
1532 ["Toggle header" gnus-summary-toggle-header t])
1534 ["Save in default format" gnus-summary-save-article t]
1535 ["Save in file" gnus-summary-save-article-file t]
1536 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1537 ["Write to file" gnus-summary-write-article-mail t]
1538 ["Save in MH folder" gnus-summary-save-article-folder t]
1539 ["Save in VM folder" gnus-summary-save-article-vm t]
1540 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1541 ["Save body in file" gnus-summary-save-article-body-file t]
1542 ["Pipe through a filter" gnus-summary-pipe-output t]
1543 ["Add to SOUP packet" gnus-soup-add-article t]
1544 ["Print" gnus-summary-print-article t])
1546 ["Respool article..." gnus-summary-respool-article t]
1547 ["Move article..." gnus-summary-move-article
1548 (gnus-check-backend-function
1549 'request-move-article gnus-newsgroup-name)]
1550 ["Copy article..." gnus-summary-copy-article t]
1551 ["Crosspost article..." gnus-summary-crosspost-article
1552 (gnus-check-backend-function
1553 'request-replace-article gnus-newsgroup-name)]
1554 ["Import file..." gnus-summary-import-article t]
1555 ["Check if posted" gnus-summary-article-posted-p t]
1556 ["Edit article" gnus-summary-edit-article
1557 (not (gnus-group-read-only-p))]
1558 ["Delete article" gnus-summary-delete-article
1559 (gnus-check-backend-function
1560 'request-expire-articles gnus-newsgroup-name)]
1561 ["Query respool" gnus-summary-respool-query t]
1562 ["Delete expirable articles" gnus-summary-expire-articles-now
1563 (gnus-check-backend-function
1564 'request-expire-articles gnus-newsgroup-name)])
1566 ["Uudecode" gnus-uu-decode-uu t]
1567 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1568 ["Unshar" gnus-uu-decode-unshar t]
1569 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1570 ["Save" gnus-uu-decode-save t]
1571 ["Binhex" gnus-uu-decode-binhex t]
1572 ["Postscript" gnus-uu-decode-postscript t])
1574 ["Enter article" gnus-cache-enter-article t]
1575 ["Remove article" gnus-cache-remove-article t])
1576 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1577 ["Isearch article..." gnus-summary-isearch-article t]
1578 ["Beginning of the article" gnus-summary-beginning-of-article t]
1579 ["End of the article" gnus-summary-end-of-article t]
1580 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1581 ["Fetch referenced articles" gnus-summary-refer-references t]
1582 ["Fetch article with id..." gnus-summary-refer-article t]
1583 ["Redisplay" gnus-summary-show-article t]))
1586 gnus-summary-thread-menu gnus-summary-mode-map ""
1588 ["Toggle threading" gnus-summary-toggle-threads t]
1589 ["Hide threads" gnus-summary-hide-all-threads t]
1590 ["Show threads" gnus-summary-show-all-threads t]
1591 ["Hide thread" gnus-summary-hide-thread t]
1592 ["Show thread" gnus-summary-show-thread t]
1593 ["Go to next thread" gnus-summary-next-thread t]
1594 ["Go to previous thread" gnus-summary-prev-thread t]
1595 ["Go down thread" gnus-summary-down-thread t]
1596 ["Go up thread" gnus-summary-up-thread t]
1597 ["Top of thread" gnus-summary-top-thread t]
1598 ["Mark thread as read" gnus-summary-kill-thread t]
1599 ["Lower thread score" gnus-summary-lower-thread t]
1600 ["Raise thread score" gnus-summary-raise-thread t]
1601 ["Rethread current" gnus-summary-rethread-current t]
1605 gnus-summary-post-menu gnus-summary-mode-map ""
1607 ["Post an article" gnus-summary-post-news t]
1608 ["Followup" gnus-summary-followup t]
1609 ["Followup and yank" gnus-summary-followup-with-original t]
1610 ["Supersede article" gnus-summary-supersede-article t]
1611 ["Cancel article" gnus-summary-cancel-article t]
1612 ["Reply" gnus-summary-reply t]
1613 ["Reply and yank" gnus-summary-reply-with-original t]
1614 ["Wide reply" gnus-summary-wide-reply t]
1615 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1616 ["Mail forward" gnus-summary-mail-forward t]
1617 ["Post forward" gnus-summary-post-forward t]
1618 ["Digest and mail" gnus-uu-digest-mail-forward t]
1619 ["Digest and post" gnus-uu-digest-post-forward t]
1620 ["Resend message" gnus-summary-resend-message t]
1621 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1622 ["Send a mail" gnus-summary-mail-other-window t]
1623 ["Uuencode and post" gnus-uu-post-news t]
1624 ["Followup via news" gnus-summary-followup-to-mail t]
1625 ["Followup via news and yank"
1626 gnus-summary-followup-to-mail-with-original t]
1628 ;;["Send" gnus-summary-send-draft t]
1629 ;;["Send bounced" gnus-resend-bounced-mail t])
1633 gnus-summary-misc-menu gnus-summary-mode-map ""
1636 ["Mark as read" gnus-summary-mark-as-read-forward t]
1637 ["Mark same subject and select"
1638 gnus-summary-kill-same-subject-and-select t]
1639 ["Mark same subject" gnus-summary-kill-same-subject t]
1640 ["Catchup" gnus-summary-catchup t]
1641 ["Catchup all" gnus-summary-catchup-all t]
1642 ["Catchup to here" gnus-summary-catchup-to-here t]
1643 ["Catchup region" gnus-summary-mark-region-as-read t]
1644 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1646 ["Tick" gnus-summary-tick-article-forward t]
1647 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1648 ["Remove marks" gnus-summary-clear-mark-forward t]
1649 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1650 ["Set bookmark" gnus-summary-set-bookmark t]
1651 ["Remove bookmark" gnus-summary-remove-bookmark t])
1653 ["Marks..." gnus-summary-limit-to-marks t]
1654 ["Subject..." gnus-summary-limit-to-subject t]
1655 ["Author..." gnus-summary-limit-to-author t]
1656 ["Age..." gnus-summary-limit-to-age t]
1657 ["Score" gnus-summary-limit-to-score t]
1658 ["Unread" gnus-summary-limit-to-unread t]
1659 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1660 ["Articles" gnus-summary-limit-to-articles t]
1661 ["Pop limit" gnus-summary-pop-limit t]
1662 ["Show dormant" gnus-summary-limit-include-dormant t]
1663 ["Hide childless dormant"
1664 gnus-summary-limit-exclude-childless-dormant t]
1665 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1666 ["Show expunged" gnus-summary-show-all-expunged t])
1668 ["Set mark" gnus-summary-mark-as-processable t]
1669 ["Remove mark" gnus-summary-unmark-as-processable t]
1670 ["Remove all marks" gnus-summary-unmark-all-processable t]
1671 ["Mark above" gnus-uu-mark-over t]
1672 ["Mark series" gnus-uu-mark-series t]
1673 ["Mark region" gnus-uu-mark-region t]
1674 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1675 ["Mark all" gnus-uu-mark-all t]
1676 ["Mark buffer" gnus-uu-mark-buffer t]
1677 ["Mark sparse" gnus-uu-mark-sparse t]
1678 ["Mark thread" gnus-uu-mark-thread t]
1679 ["Unmark thread" gnus-uu-unmark-thread t]
1680 ("Process Mark Sets"
1681 ["Kill" gnus-summary-kill-process-mark t]
1682 ["Yank" gnus-summary-yank-process-mark
1683 gnus-newsgroup-process-stack]
1684 ["Save" gnus-summary-save-process-mark t]))
1686 ["Page forward" gnus-summary-next-page t]
1687 ["Page backward" gnus-summary-prev-page t]
1688 ["Line forward" gnus-summary-scroll-up t])
1690 ["Next unread article" gnus-summary-next-unread-article t]
1691 ["Previous unread article" gnus-summary-prev-unread-article t]
1692 ["Next article" gnus-summary-next-article t]
1693 ["Previous article" gnus-summary-prev-article t]
1694 ["Next unread subject" gnus-summary-next-unread-subject t]
1695 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1696 ["Next article same subject" gnus-summary-next-same-subject t]
1697 ["Previous article same subject" gnus-summary-prev-same-subject t]
1698 ["First unread article" gnus-summary-first-unread-article t]
1699 ["Best unread article" gnus-summary-best-unread-article t]
1700 ["Go to subject number..." gnus-summary-goto-subject t]
1701 ["Go to article number..." gnus-summary-goto-article t]
1702 ["Go to the last article" gnus-summary-goto-last-article t]
1703 ["Pop article off history" gnus-summary-pop-article t])
1705 ["Sort by number" gnus-summary-sort-by-number t]
1706 ["Sort by author" gnus-summary-sort-by-author t]
1707 ["Sort by subject" gnus-summary-sort-by-subject t]
1708 ["Sort by date" gnus-summary-sort-by-date t]
1709 ["Sort by score" gnus-summary-sort-by-score t]
1710 ["Sort by lines" gnus-summary-sort-by-lines t])
1712 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1713 ["Describe group" gnus-summary-describe-group t]
1714 ["Read manual" gnus-info-find-node t])
1716 ["Pick and read" gnus-pick-mode t]
1717 ["Binary" gnus-binary-mode t])
1719 ["Regenerate" gnus-summary-prepare t]
1720 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1721 ["Toggle threading" gnus-summary-toggle-threads t])
1722 ["Filter articles..." gnus-summary-execute-command t]
1723 ["Run command on subjects..." gnus-summary-universal-argument t]
1724 ["Search articles forward..." gnus-summary-search-article-forward t]
1725 ["Search articles backward..." gnus-summary-search-article-backward t]
1726 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1727 ["Expand window" gnus-summary-expand-window t]
1728 ["Expire expirable articles" gnus-summary-expire-articles
1729 (gnus-check-backend-function
1730 'request-expire-articles gnus-newsgroup-name)]
1731 ["Edit local kill file" gnus-summary-edit-local-kill t]
1732 ["Edit main kill file" gnus-summary-edit-global-kill t]
1734 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1735 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1736 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1737 ["Exit group" gnus-summary-exit t]
1738 ["Exit group without updating" gnus-summary-exit-no-update t]
1739 ["Exit and goto next group" gnus-summary-next-group t]
1740 ["Exit and goto prev group" gnus-summary-prev-group t]
1741 ["Reselect group" gnus-summary-reselect-current-group t]
1742 ["Rescan group" gnus-summary-rescan-group t]
1743 ["Update dribble" gnus-summary-save-newsrc t])))
1745 (run-hooks 'gnus-summary-menu-hook)))
1747 (defun gnus-score-set-default (var value)
1748 "A version of set that updates the GNU Emacs menu-bar."
1750 ;; It is the message that forces the active status to be updated.
1753 (defun gnus-make-score-map (type)
1754 "Make a summary score map of type TYPE."
1757 (let ((headers '(("author" "from" string)
1758 ("subject" "subject" string)
1759 ("article body" "body" string)
1760 ("article head" "head" string)
1761 ("xref" "xref" string)
1762 ("lines" "lines" number)
1763 ("followups to author" "followup" string)))
1764 (types '((number ("less than" <)
1767 (string ("substring" s)
1771 (perms '(("temporary" (current-time-string))
1779 (if (eq type 'lower)
1784 (setq header (car headers))
1790 (let ((ts (cdr (assoc (nth 2 header) types)))
1806 'gnus-summary-score-entry
1808 (if (or (string= (nth 1 header)
1810 (string= (nth 1 header)
1813 (list 'gnus-summary-header
1815 (list 'quote (nth 1 (car ts)))
1816 (list 'gnus-score-default nil)
1822 (list (nreverse outp))))
1825 (list (nreverse outt))))
1827 (setq headers (cdr headers)))
1828 (list (nreverse outh))))))))
1832 (defun gnus-summary-mode (&optional group)
1833 "Major mode for reading articles.
1835 All normal editing commands are switched off.
1836 \\<gnus-summary-mode-map>
1837 Each line in this buffer represents one article. To read an
1838 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1839 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1842 You can also post articles and send mail from this buffer. To
1843 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1844 of an article, type `\\[gnus-summary-reply]'.
1846 There are approx. one gazillion commands you can execute in this
1847 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1849 The following commands are available:
1851 \\{gnus-summary-mode-map}"
1853 (when (gnus-visual-p 'summary-menu 'menu)
1854 (gnus-summary-make-menu-bar))
1855 (kill-all-local-variables)
1856 (gnus-summary-make-local-variables)
1857 (gnus-make-thread-indent-array)
1858 (gnus-simplify-mode-line)
1859 (setq major-mode 'gnus-summary-mode)
1860 (setq mode-name "Summary")
1861 (make-local-variable 'minor-mode-alist)
1862 (use-local-map gnus-summary-mode-map)
1863 (buffer-disable-undo (current-buffer))
1864 (setq buffer-read-only t) ;Disable modification
1865 (setq truncate-lines t)
1866 (setq selective-display t)
1867 (setq selective-display-ellipses t) ;Display `...'
1868 (setq buffer-display-table gnus-summary-display-table)
1869 (gnus-set-default-directory)
1870 (setq gnus-newsgroup-name group)
1871 (make-local-variable 'gnus-summary-line-format)
1872 (make-local-variable 'gnus-summary-line-format-spec)
1873 (make-local-variable 'gnus-summary-mark-positions)
1874 (make-local-hook 'post-command-hook)
1875 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1876 (run-hooks 'gnus-summary-mode-hook)
1877 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1878 (gnus-update-summary-mark-positions))
1880 (defun gnus-summary-make-local-variables ()
1881 "Make all the local summary buffer variables."
1882 (let ((locals gnus-summary-local-variables)
1884 (while (setq local (pop locals))
1887 (if (eq (cdr local) 'global)
1888 ;; Copy the global value of the variable.
1889 (setq global (symbol-value (car local)))
1890 ;; Use the value from the list.
1891 (setq global (eval (cdr local))))
1892 (make-local-variable (car local))
1893 (set (car local) global))
1894 ;; Simple nil-valued local variable.
1895 (make-local-variable local)
1898 (defun gnus-summary-clear-local-variables ()
1899 (let ((locals gnus-summary-local-variables))
1901 (if (consp (car locals))
1902 (and (vectorp (caar locals))
1903 (set (caar locals) nil))
1904 (and (vectorp (car locals))
1905 (set (car locals) nil)))
1906 (setq locals (cdr locals)))))
1908 ;; Summary data functions.
1910 (defmacro gnus-data-number (data)
1913 (defmacro gnus-data-set-number (data number)
1914 `(setcar ,data ,number))
1916 (defmacro gnus-data-mark (data)
1919 (defmacro gnus-data-set-mark (data mark)
1920 `(setcar (nthcdr 1 ,data) ,mark))
1922 (defmacro gnus-data-pos (data)
1925 (defmacro gnus-data-set-pos (data pos)
1926 `(setcar (nthcdr 2 ,data) ,pos))
1928 (defmacro gnus-data-header (data)
1931 (defmacro gnus-data-set-header (data header)
1932 `(setf (nth 3 ,data) ,header))
1934 (defmacro gnus-data-level (data)
1937 (defmacro gnus-data-unread-p (data)
1938 `(= (nth 1 ,data) gnus-unread-mark))
1940 (defmacro gnus-data-read-p (data)
1941 `(/= (nth 1 ,data) gnus-unread-mark))
1943 (defmacro gnus-data-pseudo-p (data)
1944 `(consp (nth 3 ,data)))
1946 (defmacro gnus-data-find (number)
1947 `(assq ,number gnus-newsgroup-data))
1949 (defmacro gnus-data-find-list (number &optional data)
1950 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1951 (memq (assq ,number bdata)
1954 (defmacro gnus-data-make (number mark pos header level)
1955 `(list ,number ,mark ,pos ,header ,level))
1957 (defun gnus-data-enter (after-article number mark pos header level offset)
1958 (let ((data (gnus-data-find-list after-article)))
1960 (error "No such article: %d" after-article))
1961 (setcdr data (cons (gnus-data-make number mark pos header level)
1963 (setq gnus-newsgroup-data-reverse nil)
1964 (gnus-data-update-list (cddr data) offset)))
1966 (defun gnus-data-enter-list (after-article list &optional offset)
1968 (let ((data (and after-article (gnus-data-find-list after-article)))
1970 (or data (not after-article) (error "No such article: %d" after-article))
1971 ;; Find the last element in the list to be spliced into the main
1974 (setq list (cdr list)))
1977 (setcdr list gnus-newsgroup-data)
1978 (setq gnus-newsgroup-data ilist)
1980 (gnus-data-update-list (cdr list) offset)))
1981 (setcdr list (cdr data))
1984 (gnus-data-update-list (cdr list) offset)))
1985 (setq gnus-newsgroup-data-reverse nil))))
1987 (defun gnus-data-remove (article &optional offset)
1988 (let ((data gnus-newsgroup-data))
1989 (if (= (gnus-data-number (car data)) article)
1991 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1992 gnus-newsgroup-data-reverse nil)
1994 (gnus-data-update-list gnus-newsgroup-data offset)))
1996 (when (= (gnus-data-number (cadr data)) article)
1997 (setcdr data (cddr data))
1999 (gnus-data-update-list (cdr data) offset))
2001 gnus-newsgroup-data-reverse nil))
2002 (setq data (cdr data))))))
2004 (defmacro gnus-data-list (backward)
2006 (or gnus-newsgroup-data-reverse
2007 (setq gnus-newsgroup-data-reverse
2008 (reverse gnus-newsgroup-data)))
2009 gnus-newsgroup-data))
2011 (defun gnus-data-update-list (data offset)
2012 "Add OFFSET to the POS of all data entries in DATA."
2014 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2015 (setq data (cdr data))))
2017 (defun gnus-data-compute-positions ()
2018 "Compute the positions of all articles."
2019 (let ((data gnus-newsgroup-data)
2022 (when (setq pos (text-property-any
2023 (point-min) (point-max)
2024 'gnus-number (gnus-data-number (car data))))
2025 (gnus-data-set-pos (car data) (+ pos 3)))
2026 (setq data (cdr data)))))
2028 (defun gnus-summary-article-pseudo-p (article)
2029 "Say whether this article is a pseudo article or not."
2030 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2032 (defmacro gnus-summary-article-sparse-p (article)
2033 "Say whether this article is a sparse article or not."
2034 ` (memq ,article gnus-newsgroup-sparse))
2036 (defmacro gnus-summary-article-ancient-p (article)
2037 "Say whether this article is a sparse article or not."
2038 `(memq ,article gnus-newsgroup-ancient))
2040 (defun gnus-article-parent-p (number)
2041 "Say whether this article is a parent or not."
2042 (let ((data (gnus-data-find-list number)))
2043 (and (cdr data) ; There has to be an article after...
2044 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2045 (gnus-data-level (nth 1 data))))))
2047 (defun gnus-article-children (number)
2048 "Return a list of all children to NUMBER."
2049 (let* ((data (gnus-data-find-list number))
2050 (level (gnus-data-level (car data)))
2052 (setq data (cdr data))
2054 (= (gnus-data-level (car data)) (1+ level)))
2055 (push (gnus-data-number (car data)) children)
2056 (setq data (cdr data)))
2059 (defmacro gnus-summary-skip-intangible ()
2060 "If the current article is intangible, then jump to a different article."
2061 '(let ((to (get-text-property (point) 'gnus-intangible)))
2062 (and to (gnus-summary-goto-subject to))))
2064 (defmacro gnus-summary-article-intangible-p ()
2065 "Say whether this article is intangible or not."
2066 '(get-text-property (point) 'gnus-intangible))
2068 (defun gnus-article-read-p (article)
2069 "Say whether ARTICLE is read or not."
2070 (not (or (memq article gnus-newsgroup-marked)
2071 (memq article gnus-newsgroup-unreads)
2072 (memq article gnus-newsgroup-unselected)
2073 (memq article gnus-newsgroup-dormant))))
2075 ;; Some summary mode macros.
2077 (defmacro gnus-summary-article-number ()
2078 "The article number of the article on the current line.
2079 If there isn's an article number here, then we return the current
2082 (gnus-summary-skip-intangible)
2083 (or (get-text-property (point) 'gnus-number)
2084 (gnus-summary-last-subject))))
2086 (defmacro gnus-summary-article-header (&optional number)
2087 `(gnus-data-header (gnus-data-find
2088 ,(or number '(gnus-summary-article-number)))))
2090 (defmacro gnus-summary-thread-level (&optional number)
2091 `(if (and (eq gnus-summary-make-false-root 'dummy)
2092 (get-text-property (point) 'gnus-intangible))
2094 (gnus-data-level (gnus-data-find
2095 ,(or number '(gnus-summary-article-number))))))
2097 (defmacro gnus-summary-article-mark (&optional number)
2098 `(gnus-data-mark (gnus-data-find
2099 ,(or number '(gnus-summary-article-number)))))
2101 (defmacro gnus-summary-article-pos (&optional number)
2102 `(gnus-data-pos (gnus-data-find
2103 ,(or number '(gnus-summary-article-number)))))
2105 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2106 (defmacro gnus-summary-article-subject (&optional number)
2107 "Return current subject string or nil if nothing."
2110 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2111 '(gnus-data-header (assq (gnus-summary-article-number)
2112 gnus-newsgroup-data)))))
2115 (mail-header-subject headers))))
2117 (defmacro gnus-summary-article-score (&optional number)
2118 "Return current article score."
2119 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2120 gnus-newsgroup-scored))
2121 gnus-summary-default-score 0))
2123 (defun gnus-summary-article-children (&optional number)
2124 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2125 (level (gnus-data-level (car data)))
2127 (while (and (setq data (cdr data))
2128 (> (setq l (gnus-data-level (car data))) level))
2129 (and (= (1+ level) l)
2130 (push (gnus-data-number (car data))
2132 (nreverse children)))
2134 (defun gnus-summary-article-parent (&optional number)
2135 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2136 (gnus-data-list t)))
2137 (level (gnus-data-level (car data))))
2139 () ; This is a root.
2140 ;; We search until we find an article with a level less than
2141 ;; this one. That function has to be the parent.
2142 (while (and (setq data (cdr data))
2143 (not (< (gnus-data-level (car data)) level))))
2144 (and data (gnus-data-number (car data))))))
2146 (defun gnus-unread-mark-p (mark)
2147 "Say whether MARK is the unread mark."
2148 (= mark gnus-unread-mark))
2150 (defun gnus-read-mark-p (mark)
2151 "Say whether MARK is one of the marks that mark as read.
2152 This is all marks except unread, ticked, dormant, and expirable."
2153 (not (or (= mark gnus-unread-mark)
2154 (= mark gnus-ticked-mark)
2155 (= mark gnus-dormant-mark)
2156 (= mark gnus-expirable-mark))))
2158 (defmacro gnus-article-mark (number)
2160 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2161 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2162 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2163 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2164 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2165 gnus-ancient-mark))))
2167 ;; Saving hidden threads.
2169 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2170 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2172 (defmacro gnus-save-hidden-threads (&rest forms)
2173 "Save hidden threads, eval FORMS, and restore the hidden threads."
2174 (let ((config (make-symbol "config")))
2175 `(let ((,config (gnus-hidden-threads-configuration)))
2179 (gnus-restore-hidden-threads-configuration ,config)))))
2181 (defun gnus-hidden-threads-configuration ()
2182 "Return the current hidden threads configuration."
2185 (goto-char (point-min))
2186 (while (search-forward "\r" nil t)
2187 (push (1- (point)) config))
2190 (defun gnus-restore-hidden-threads-configuration (config)
2191 "Restore hidden threads configuration from CONFIG."
2192 (let (point buffer-read-only)
2193 (while (setq point (pop config))
2194 (when (and (< point (point-max))
2196 (= (following-char) ?\n))
2197 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2199 ;; Various summary mode internalish functions.
2201 (defun gnus-mouse-pick-article (e)
2204 (gnus-summary-next-page nil t))
2206 (defun gnus-summary-setup-buffer (group)
2207 "Initialize summary buffer."
2208 (let ((buffer (concat "*Summary " group "*")))
2209 (if (get-buffer buffer)
2212 (setq gnus-summary-buffer (current-buffer))
2213 (not gnus-newsgroup-prepared))
2214 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2215 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2216 (gnus-add-current-to-buffer-list)
2217 (gnus-summary-mode group)
2219 (gnus-carpal-setup-buffer 'summary))
2220 (unless gnus-single-article-buffer
2221 (make-local-variable 'gnus-article-buffer)
2222 (make-local-variable 'gnus-article-current)
2223 (make-local-variable 'gnus-original-article-buffer))
2224 (setq gnus-newsgroup-name group)
2227 (defun gnus-set-global-variables ()
2228 ;; Set the global equivalents of the summary buffer-local variables
2229 ;; to the latest values they had. These reflect the summary buffer
2230 ;; that was in action when the last article was fetched.
2231 (when (eq major-mode 'gnus-summary-mode)
2232 (setq gnus-summary-buffer (current-buffer))
2233 (let ((name gnus-newsgroup-name)
2234 (marked gnus-newsgroup-marked)
2235 (unread gnus-newsgroup-unreads)
2236 (headers gnus-current-headers)
2237 (data gnus-newsgroup-data)
2238 (summary gnus-summary-buffer)
2239 (article-buffer gnus-article-buffer)
2240 (original gnus-original-article-buffer)
2241 (gac gnus-article-current)
2242 (reffed gnus-reffed-article-number)
2243 (score-file gnus-current-score-file))
2245 (set-buffer gnus-group-buffer)
2246 (setq gnus-newsgroup-name name)
2247 (setq gnus-newsgroup-marked marked)
2248 (setq gnus-newsgroup-unreads unread)
2249 (setq gnus-current-headers headers)
2250 (setq gnus-newsgroup-data data)
2251 (setq gnus-article-current gac)
2252 (setq gnus-summary-buffer summary)
2253 (setq gnus-article-buffer article-buffer)
2254 (setq gnus-original-article-buffer original)
2255 (setq gnus-reffed-article-number reffed)
2256 (setq gnus-current-score-file score-file)
2257 ;; The article buffer also has local variables.
2258 (when (gnus-buffer-live-p gnus-article-buffer)
2259 (set-buffer gnus-article-buffer)
2260 (setq gnus-summary-buffer summary))))))
2262 (defun gnus-summary-article-unread-p (article)
2263 "Say whether ARTICLE is unread or not."
2264 (memq article gnus-newsgroup-unreads))
2266 (defun gnus-summary-first-article-p (&optional article)
2267 "Return whether ARTICLE is the first article in the buffer."
2268 (if (not (setq article (or article (gnus-summary-article-number))))
2270 (eq article (caar gnus-newsgroup-data))))
2272 (defun gnus-summary-last-article-p (&optional article)
2273 "Return whether ARTICLE is the last article in the buffer."
2274 (if (not (setq article (or article (gnus-summary-article-number))))
2275 t ; All non-existent numbers are the last article. :-)
2276 (not (cdr (gnus-data-find-list article)))))
2278 (defun gnus-make-thread-indent-array ()
2280 (unless (and gnus-thread-indent-array
2281 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2282 (setq gnus-thread-indent-array (make-vector 201 "")
2283 gnus-thread-indent-array-level gnus-thread-indent-level)
2285 (aset gnus-thread-indent-array n
2286 (make-string (* n gnus-thread-indent-level) ? ))
2289 (defun gnus-update-summary-mark-positions ()
2290 "Compute where the summary marks are to go."
2292 (when (and gnus-summary-buffer
2293 (get-buffer gnus-summary-buffer)
2294 (buffer-name (get-buffer gnus-summary-buffer)))
2295 (set-buffer gnus-summary-buffer))
2296 (let ((gnus-replied-mark 129)
2297 (gnus-score-below-mark 130)
2298 (gnus-score-over-mark 130)
2299 (spec gnus-summary-line-format-spec)
2300 thread gnus-visual pos)
2302 (gnus-set-work-buffer)
2303 (let ((gnus-summary-line-format-spec spec))
2304 (gnus-summary-insert-line
2305 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2306 (goto-char (point-min))
2307 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2309 (goto-char (point-min))
2310 (push (cons 'replied (and (search-forward "\201" nil t)
2313 (goto-char (point-min))
2314 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2316 (setq gnus-summary-mark-positions pos))))
2318 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2319 "Insert a dummy root in the summary buffer."
2321 (gnus-add-text-properties
2322 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2323 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2325 (defun gnus-summary-insert-line (gnus-tmp-header
2326 gnus-tmp-level gnus-tmp-current
2327 gnus-tmp-unread gnus-tmp-replied
2328 gnus-tmp-expirable gnus-tmp-subject-or-nil
2329 &optional gnus-tmp-dummy gnus-tmp-score
2331 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2332 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2333 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2334 (gnus-tmp-score-char
2335 (if (or (null gnus-summary-default-score)
2336 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2337 gnus-summary-zcore-fuzz))
2339 (if (< gnus-tmp-score gnus-summary-default-score)
2340 gnus-score-below-mark gnus-score-over-mark)))
2342 (cond (gnus-tmp-process gnus-process-mark)
2343 ((memq gnus-tmp-current gnus-newsgroup-cached)
2345 (gnus-tmp-replied gnus-replied-mark)
2346 ((memq gnus-tmp-current gnus-newsgroup-saved)
2348 (t gnus-unread-mark)))
2349 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2352 ((string-match "<[^>]+> *$" gnus-tmp-from)
2353 (let ((beg (match-beginning 0)))
2354 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2355 (substring gnus-tmp-from (1+ (match-beginning 0))
2356 (1- (match-end 0))))
2357 (substring gnus-tmp-from 0 beg))))
2358 ((string-match "(.+)" gnus-tmp-from)
2359 (substring gnus-tmp-from
2360 (1+ (match-beginning 0)) (1- (match-end 0))))
2362 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2363 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2364 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2365 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2366 (buffer-read-only nil))
2367 (when (string= gnus-tmp-name "")
2368 (setq gnus-tmp-name gnus-tmp-from))
2369 (unless (numberp gnus-tmp-lines)
2370 (setq gnus-tmp-lines 0))
2371 (gnus-put-text-property
2373 (progn (eval gnus-summary-line-format-spec) (point))
2374 'gnus-number gnus-tmp-number)
2375 (when (gnus-visual-p 'summary-highlight 'highlight)
2377 (run-hooks 'gnus-summary-update-hook)
2380 (defun gnus-summary-update-line (&optional dont-update)
2381 ;; Update summary line after change.
2382 (when (and gnus-summary-default-score
2383 (not gnus-summary-inhibit-highlight))
2384 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2385 (article (gnus-summary-article-number))
2386 (score (gnus-summary-article-score article)))
2388 (if (and gnus-summary-mark-below
2389 (< (gnus-summary-article-score)
2390 gnus-summary-mark-below))
2391 ;; This article has a low score, so we mark it as read.
2392 (when (memq article gnus-newsgroup-unreads)
2393 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2394 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2395 ;; This article was previously marked as read on account
2396 ;; of a low score, but now it has risen, so we mark it as
2398 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2399 (gnus-summary-update-mark
2400 (if (or (null gnus-summary-default-score)
2401 (<= (abs (- score gnus-summary-default-score))
2402 gnus-summary-zcore-fuzz))
2404 (if (< score gnus-summary-default-score)
2405 gnus-score-below-mark gnus-score-over-mark))
2407 ;; Do visual highlighting.
2408 (when (gnus-visual-p 'summary-highlight 'highlight)
2409 (run-hooks 'gnus-summary-update-hook)))))
2411 (defvar gnus-tmp-new-adopts nil)
2413 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2414 "Return the number of articles in THREAD.
2415 This may be 0 in some cases -- if none of the articles in
2416 the thread are to be displayed."
2418 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2420 ((not (listp thread))
2422 ((and (consp thread) (cdr thread))
2425 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2428 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2431 (when (and level (zerop level) gnus-tmp-new-adopts)
2434 'gnus-summary-number-of-articles-in-thread
2435 gnus-tmp-new-adopts))))
2437 (if (> number 1) gnus-not-empty-thread-mark
2438 gnus-empty-thread-mark)
2441 (defun gnus-summary-set-local-parameters (group)
2442 "Go through the local params of GROUP and set all variable specs in that list."
2443 (let ((params (gnus-group-find-parameter group))
2446 (setq elem (car params)
2447 params (cdr params))
2448 (and (consp elem) ; Has to be a cons.
2449 (consp (cdr elem)) ; The cdr has to be a list.
2450 (symbolp (car elem)) ; Has to be a symbol in there.
2451 (not (memq (car elem)
2452 '(quit-config to-address to-list to-group)))
2453 (ignore-errors ; So we set it.
2454 (make-local-variable (car elem))
2455 (set (car elem) (eval (nth 1 elem))))))))
2457 (defun gnus-summary-read-group (group &optional show-all no-article
2458 kill-buffer no-display)
2459 "Start reading news in newsgroup GROUP.
2460 If SHOW-ALL is non-nil, already read articles are also listed.
2461 If NO-ARTICLE is non-nil, no article is selected initially.
2462 If NO-DISPLAY, don't generate a summary buffer."
2463 ;; Killed foreign groups can't be entered.
2464 (when (and (not (gnus-group-native-p group))
2465 (not (gnus-gethash group gnus-newsrc-hashtb)))
2466 (error "Dead non-native groups can't be entered"))
2467 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2468 (let* ((new-group (gnus-summary-setup-buffer group))
2469 (quit-config (gnus-group-quit-config group))
2470 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2472 ;; This summary buffer exists already, so we just select it.
2474 (gnus-set-global-variables)
2476 (gnus-kill-or-deaden-summary kill-buffer))
2477 (gnus-configure-windows 'summary 'force)
2478 (gnus-set-mode-line 'summary)
2479 (gnus-summary-position-point)
2482 ;; We couldn't select this group.
2484 (when (and (eq major-mode 'gnus-summary-mode)
2485 (not (equal (current-buffer) kill-buffer)))
2486 (kill-buffer (current-buffer))
2487 (if (not quit-config)
2489 (set-buffer gnus-group-buffer)
2490 (gnus-group-jump-to-group group)
2491 (gnus-group-next-unread-group 1))
2492 (gnus-handle-ephemeral-exit quit-config)))
2493 (gnus-message 3 "Can't select group")
2495 ;; The user did a `C-g' while prompting for number of articles,
2496 ;; so we exit this group.
2497 ((eq did-select 'quit)
2498 (and (eq major-mode 'gnus-summary-mode)
2499 (not (equal (current-buffer) kill-buffer))
2500 (kill-buffer (current-buffer)))
2502 (gnus-kill-or-deaden-summary kill-buffer))
2503 (if (not quit-config)
2505 (set-buffer gnus-group-buffer)
2506 (gnus-group-jump-to-group group)
2507 (gnus-group-next-unread-group 1)
2508 (gnus-configure-windows 'group 'force))
2509 (gnus-handle-ephemeral-exit quit-config))
2510 ;; Finally signal the quit.
2512 ;; The group was successfully selected.
2514 (gnus-set-global-variables)
2515 ;; Save the active value in effect when the group was entered.
2516 (setq gnus-newsgroup-active
2518 (gnus-active gnus-newsgroup-name)))
2519 ;; You can change the summary buffer in some way with this hook.
2520 (run-hooks 'gnus-select-group-hook)
2521 ;; Set any local variables in the group parameters.
2522 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2523 (gnus-update-format-specifications
2524 nil 'summary 'summary-mode 'summary-dummy)
2525 ;; Do score processing.
2526 (when gnus-use-scoring
2527 (gnus-possibly-score-headers))
2528 ;; Check whether to fill in the gaps in the threads.
2529 (when gnus-build-sparse-threads
2530 (gnus-build-sparse-threads))
2531 ;; Find the initial limit.
2532 (if gnus-show-threads
2534 (let ((gnus-newsgroup-dormant nil))
2535 (gnus-summary-initial-limit show-all))
2536 (gnus-summary-initial-limit show-all))
2537 (setq gnus-newsgroup-limit
2539 (lambda (header) (mail-header-number header))
2540 gnus-newsgroup-headers)))
2541 ;; Generate the summary buffer.
2543 (gnus-summary-prepare))
2544 (when gnus-use-trees
2545 (gnus-tree-open group)
2546 (setq gnus-summary-highlight-line-function
2547 'gnus-tree-highlight-article))
2548 ;; If the summary buffer is empty, but there are some low-scored
2549 ;; articles or some excluded dormants, we include these in the
2551 (when (and (zerop (buffer-size))
2553 (cond (gnus-newsgroup-dormant
2554 (gnus-summary-limit-include-dormant))
2555 ((and gnus-newsgroup-scored show-all)
2556 (gnus-summary-limit-include-expunged t))))
2557 ;; Function `gnus-apply-kill-file' must be called in this hook.
2558 (run-hooks 'gnus-apply-kill-hook)
2559 (if (and (zerop (buffer-size))
2562 ;; This newsgroup is empty.
2563 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2564 (gnus-message 6 "No unread news")
2566 (gnus-kill-or-deaden-summary kill-buffer))
2567 ;; Return nil from this function.
2569 ;; Hide conversation thread subtrees. We cannot do this in
2570 ;; gnus-summary-prepare-hook since kill processing may not
2571 ;; work with hidden articles.
2572 (and gnus-show-threads
2573 gnus-thread-hide-subtree
2574 (gnus-summary-hide-all-threads))
2575 ;; Show first unread article if requested.
2576 (if (and (not no-article)
2578 gnus-newsgroup-unreads
2579 gnus-auto-select-first)
2580 (unless (if (eq gnus-auto-select-first 'best)
2581 (gnus-summary-best-unread-article)
2582 (gnus-summary-first-unread-article))
2583 (gnus-configure-windows 'summary))
2584 ;; Don't select any articles, just move point to the first
2585 ;; article in the group.
2586 (goto-char (point-min))
2587 (gnus-summary-position-point)
2588 (gnus-set-mode-line 'summary)
2589 (gnus-configure-windows 'summary 'force))
2591 (gnus-kill-or-deaden-summary kill-buffer))
2592 (when (get-buffer-window gnus-group-buffer t)
2593 ;; Gotta use windows, because recenter does weird stuff if
2594 ;; the current buffer ain't the displayed window.
2595 (let ((owin (selected-window)))
2596 (select-window (get-buffer-window gnus-group-buffer t))
2597 (when (gnus-group-goto-group group)
2599 (select-window owin))))
2600 ;; Mark this buffer as "prepared".
2601 (setq gnus-newsgroup-prepared t)
2604 (defun gnus-summary-prepare ()
2605 "Generate the summary buffer."
2607 (let ((buffer-read-only nil))
2609 (setq gnus-newsgroup-data nil
2610 gnus-newsgroup-data-reverse nil)
2611 (run-hooks 'gnus-summary-generate-hook)
2612 ;; Generate the buffer, either with threads or without.
2613 (when gnus-newsgroup-headers
2614 (gnus-summary-prepare-threads
2615 (if gnus-show-threads
2616 (gnus-sort-gathered-threads
2617 (funcall gnus-summary-thread-gathering-function
2619 (gnus-cut-threads (gnus-make-threads)))))
2620 ;; Unthreaded display.
2621 (gnus-sort-articles gnus-newsgroup-headers))))
2622 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2623 ;; Call hooks for modifying summary buffer.
2624 (goto-char (point-min))
2625 (run-hooks 'gnus-summary-prepare-hook)))
2627 (defsubst gnus-general-simplify-subject (subject)
2628 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2631 ;; Truncate the subject.
2632 ((numberp gnus-summary-gather-subject-limit)
2633 (setq subject (gnus-simplify-subject-re subject))
2634 (if (> (length subject) gnus-summary-gather-subject-limit)
2635 (substring subject 0 gnus-summary-gather-subject-limit)
2637 ;; Fuzzily simplify it.
2638 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2639 (gnus-simplify-subject-fuzzy subject))
2640 ;; Just remove the leading "Re:".
2642 (gnus-simplify-subject-re subject))))
2644 (if (and gnus-summary-gather-exclude-subject
2645 (string-match gnus-summary-gather-exclude-subject subject))
2646 nil ; This article shouldn't be gathered
2649 (defun gnus-summary-simplify-subject-query ()
2650 "Query where the respool algorithm would put this article."
2652 (gnus-set-global-variables)
2653 (gnus-summary-select-article)
2654 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2656 (defun gnus-gather-threads-by-subject (threads)
2657 "Gather threads by looking at Subject headers."
2658 (if (not gnus-summary-make-false-root)
2660 (let ((hashtb (gnus-make-hashtable 1024))
2663 subject hthread whole-subject)
2665 (setq subject (gnus-general-simplify-subject
2666 (setq whole-subject (mail-header-subject
2669 (if (setq hthread (gnus-gethash subject hashtb))
2671 ;; We enter a dummy root into the thread, if we
2672 ;; haven't done that already.
2673 (unless (stringp (caar hthread))
2674 (setcar hthread (list whole-subject (car hthread))))
2675 ;; We add this new gathered thread to this gathered
2677 (setcdr (car hthread)
2678 (nconc (cdar hthread) (list (car threads))))
2679 ;; Remove it from the list of threads.
2680 (setcdr prev (cdr threads))
2681 (setq threads prev))
2682 ;; Enter this thread into the hash table.
2683 (gnus-sethash subject threads hashtb)))
2685 (setq threads (cdr threads)))
2688 (defun gnus-gather-threads-by-references (threads)
2689 "Gather threads by looking at References headers."
2690 (let ((idhashtb (gnus-make-hashtable 1024))
2691 (thhashtb (gnus-make-hashtable 1024))
2694 ids references id gthread gid entered ref)
2696 (when (setq references (mail-header-references (caar threads)))
2697 (setq id (mail-header-id (caar threads))
2698 ids (gnus-split-references references)
2700 (while (setq ref (pop ids))
2701 (setq ids (delete ref ids))
2702 (if (not (setq gid (gnus-gethash ref idhashtb)))
2704 (gnus-sethash ref id idhashtb)
2705 (gnus-sethash id threads thhashtb))
2706 (setq gthread (gnus-gethash gid thhashtb))
2708 ;; We enter a dummy root into the thread, if we
2709 ;; haven't done that already.
2710 (unless (stringp (caar gthread))
2711 (setcar gthread (list (mail-header-subject (caar gthread))
2713 ;; We add this new gathered thread to this gathered
2715 (setcdr (car gthread)
2716 (nconc (cdar gthread) (list (car threads)))))
2717 ;; Add it into the thread hash table.
2718 (gnus-sethash id gthread thhashtb)
2720 ;; Remove it from the list of threads.
2721 (setcdr prev (cdr threads))
2722 (setq threads prev))))
2724 (setq threads (cdr threads)))
2727 (defun gnus-sort-gathered-threads (threads)
2728 "Sort subtreads inside each gathered thread by article number."
2729 (let ((result threads))
2731 (when (stringp (caar threads))
2732 (setcdr (car threads)
2733 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2734 (setq threads (cdr threads)))
2737 (defun gnus-thread-loop-p (root thread)
2738 "Say whether ROOT is in THREAD."
2739 (let ((th (cdr thread)))
2741 (not (eq (caar th) root)))
2744 ;; We have found a loop.
2746 (setcdr thread (delq (car th) (cdr thread)))
2747 (if (boundp (setq ref-dep (intern "none"
2748 gnus-newsgroup-dependencies)))
2749 (setcdr (symbol-value ref-dep)
2750 (nconc (cdr (symbol-value ref-dep))
2752 (set ref-dep (list nil (car th))))
2754 ;; Recurse down into the sub-threads and look for loops.
2757 (lambda (thread) (gnus-thread-loop-p root thread))
2760 (defun gnus-make-threads ()
2761 "Go through the dependency hashtb and find the roots. Return all threads."
2763 (while (catch 'infloop
2766 ;; Deal with self-referencing References loops.
2767 (when (and (car (symbol-value refs))
2774 (car (symbol-value refs)) thread))
2775 (cdr (symbol-value refs)))))))
2778 (unless (car (symbol-value refs))
2779 ;; These threads do not refer back to any other articles,
2780 ;; so they're roots.
2781 (setq threads (append (cdr (symbol-value refs)) threads))))
2782 gnus-newsgroup-dependencies)))
2785 (defun gnus-build-sparse-threads ()
2786 (let ((headers gnus-newsgroup-headers)
2787 (deps gnus-newsgroup-dependencies)
2788 header references generation relations
2789 cthread subject child end pthread relation)
2790 ;; First we create an alist of generations/relations, where
2791 ;; generations is how much we trust the relation, and the relation
2793 (gnus-message 7 "Making sparse threads...")
2795 (nnheader-set-temp-buffer " *gnus sparse threads*")
2796 (while (setq header (pop headers))
2797 (when (and (setq references (mail-header-references header))
2798 (not (string= references "")))
2800 (setq child (mail-header-id header)
2801 subject (mail-header-subject header))
2803 (while (search-backward ">" nil t)
2804 (setq end (1+ (point)))
2805 (when (search-backward "<" nil t)
2806 (push (list (incf generation)
2807 child (setq child (buffer-substring (point) end))
2810 (push (list (1+ generation) child nil subject) relations)
2812 (kill-buffer (current-buffer)))
2813 ;; Sort over trustworthiness.
2814 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2815 (while (setq relation (pop relations))
2816 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2817 (unless (car (symbol-value cthread))
2818 ;; Make this article the parent of these threads.
2819 (setcar (symbol-value cthread)
2820 (vector gnus-reffed-article-number
2824 (or (caddr relation) "") 0 0 "")))
2825 (set cthread (list (vector gnus-reffed-article-number
2827 "" "" (cadr relation)
2828 (or (caddr relation) "") 0 0 ""))))
2829 (push gnus-reffed-article-number gnus-newsgroup-limit)
2830 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2831 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2832 gnus-newsgroup-reads)
2833 (decf gnus-reffed-article-number)
2834 ;; Make this new thread the child of its parent.
2835 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2836 (setcdr (symbol-value pthread)
2837 (nconc (cdr (symbol-value pthread))
2838 (list (symbol-value cthread))))
2839 (set pthread (list nil (symbol-value cthread))))))
2840 (gnus-message 7 "Making sparse threads...done")))
2842 (defun gnus-build-old-threads ()
2843 ;; Look at all the articles that refer back to old articles, and
2844 ;; fetch the headers for the articles that aren't there. This will
2845 ;; build complete threads - if the roots haven't been expired by the
2850 (when (not (car (symbol-value refs)))
2851 (setq heads (cdr (symbol-value refs)))
2853 (if (memq (mail-header-number (caar heads))
2854 gnus-newsgroup-dormant)
2855 (setq heads (cdr heads))
2856 (setq id (symbol-name refs))
2857 (while (and (setq id (gnus-build-get-header id))
2858 (not (car (gnus-gethash
2859 id gnus-newsgroup-dependencies)))))
2860 (setq heads nil)))))
2861 gnus-newsgroup-dependencies)))
2863 (defun gnus-build-get-header (id)
2864 ;; Look through the buffer of NOV lines and find the header to
2865 ;; ID. Enter this line into the dependencies hash table, and return
2866 ;; the id of the parent article (if any).
2867 (let ((deps gnus-newsgroup-dependencies)
2871 (set-buffer nntp-server-buffer)
2872 (goto-char (point-min))
2873 (while (and (not found) (search-forward id nil t))
2875 (setq found (looking-at
2876 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2877 (regexp-quote id))))
2878 (or found (beginning-of-line 2)))
2882 (setq header (gnus-nov-parse-line
2883 (read (current-buffer)) deps))
2884 (gnus-parent-id (mail-header-references header)))))
2886 (let ((number (mail-header-number header)))
2887 (push number gnus-newsgroup-limit)
2888 (push header gnus-newsgroup-headers)
2889 (if (memq number gnus-newsgroup-unselected)
2891 (push number gnus-newsgroup-unreads)
2892 (setq gnus-newsgroup-unselected
2893 (delq number gnus-newsgroup-unselected)))
2894 (push number gnus-newsgroup-ancient)))))))
2896 (defun gnus-summary-update-article-line (article header)
2897 "Update the line for ARTICLE using HEADERS."
2898 (let* ((id (mail-header-id header))
2899 (thread (gnus-id-to-thread id)))
2901 (error "Article in no thread"))
2902 ;; Update the thread.
2903 (setcar thread header)
2904 (gnus-summary-goto-subject article)
2905 (let* ((datal (gnus-data-find-list article))
2907 (length (when (cdr datal)
2908 (- (gnus-data-pos data)
2909 (gnus-data-pos (cadr datal)))))
2910 (buffer-read-only nil)
2911 (level (gnus-summary-thread-level)))
2913 (gnus-summary-insert-line
2914 header level nil (gnus-article-mark article)
2915 (memq article gnus-newsgroup-replied)
2916 (memq article gnus-newsgroup-expirable)
2917 ;; Only insert the Subject string when it's different
2918 ;; from the previous Subject string.
2919 (unless (gnus-subject-equal
2921 (mail-header-subject
2924 (gnus-data-find-list
2926 (gnus-data-list t)))))
2928 (mail-header-subject header))
2929 (mail-header-subject header))
2930 nil (cdr (assq article gnus-newsgroup-scored))
2931 (memq article gnus-newsgroup-processable))
2933 (gnus-data-update-list
2934 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2936 (defun gnus-summary-update-article (article &optional iheader)
2937 "Update ARTICLE in the summary buffer."
2938 (set-buffer gnus-summary-buffer)
2939 (let* ((header (or iheader (gnus-summary-article-header article)))
2940 (id (mail-header-id header))
2941 (data (gnus-data-find article))
2942 (thread (gnus-id-to-thread id))
2943 (references (mail-header-references header))
2947 (when (and references
2948 (not (equal "" references)))
2951 (buffer-read-only nil)
2953 (number (mail-header-number header))
2956 ;; !!! Should this be in or not?
2958 (setcar thread nil))
2960 (delq thread parent))
2961 (if (gnus-summary-insert-subject id header iheader)
2962 ;; Set the (possibly) new article number in the data structure.
2963 (gnus-data-set-number data (gnus-id-to-article id))
2967 (defun gnus-rebuild-thread (id)
2968 "Rebuild the thread containing ID."
2969 (let ((buffer-read-only nil)
2970 old-pos current thread data)
2971 (if (not gnus-show-threads)
2972 (setq thread (list (car (gnus-id-to-thread id))))
2973 ;; Get the thread this article is part of.
2974 (setq thread (gnus-remove-thread id)))
2975 (setq old-pos (gnus-point-at-bol))
2976 (setq current (save-excursion
2977 (and (zerop (forward-line -1))
2978 (gnus-summary-article-number))))
2979 ;; If this is a gathered thread, we have to go some re-gathering.
2980 (when (stringp (car thread))
2981 (let ((subject (car thread))
2983 (setq thread (cdr thread))
2985 (unless (memq (setq thr (gnus-id-to-thread
2987 (mail-header-id (caar thread)))))
2990 (setq thread (cdr thread)))
2991 ;; We now have all (unique) roots.
2992 (if (= (length roots) 1)
2993 ;; All the loose roots are now one solid root.
2994 (setq thread (car roots))
2995 (setq thread (cons subject (gnus-sort-threads roots))))))
2997 ;; We then insert this thread into the summary buffer.
2998 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2999 (if gnus-show-threads
3000 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3001 (gnus-summary-prepare-unthreaded thread))
3002 (setq data (nreverse gnus-newsgroup-data))
3003 (setq threads gnus-newsgroup-threads))
3004 ;; We splice the new data into the data structure.
3005 (gnus-data-enter-list current data (- (point) old-pos))
3006 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3008 (defun gnus-number-to-header (number)
3009 "Return the header for article NUMBER."
3010 (let ((headers gnus-newsgroup-headers))
3012 (not (= number (mail-header-number (car headers)))))
3017 (defun gnus-parent-headers (headers &optional generation)
3018 "Return the headers of the GENERATIONeth parent of HEADERS."
3020 (setq generation 1))
3021 (let (references parent)
3022 (while (and headers (not (zerop generation)))
3023 (setq references (mail-header-references headers))
3024 (when (and references
3025 (setq parent (gnus-parent-id references))
3026 (setq headers (car (gnus-id-to-thread parent))))
3030 (defun gnus-id-to-thread (id)
3031 "Return the (sub-)thread where ID appears."
3032 (gnus-gethash id gnus-newsgroup-dependencies))
3034 (defun gnus-id-to-article (id)
3035 "Return the article number of ID."
3036 (let ((thread (gnus-id-to-thread id)))
3039 (mail-header-number (car thread)))))
3041 (defun gnus-id-to-header (id)
3042 "Return the article headers of ID."
3043 (car (gnus-id-to-thread id)))
3045 (defun gnus-article-displayed-root-p (article)
3046 "Say whether ARTICLE is a root(ish) article."
3047 (let ((level (gnus-summary-thread-level article))
3048 (refs (mail-header-references (gnus-summary-article-header article)))
3054 ((null (gnus-parent-id refs)) t)
3056 (null (setq particle (gnus-id-to-article
3057 (gnus-parent-id refs))))
3058 (null (gnus-summary-thread-level particle)))))))
3060 (defun gnus-root-id (id)
3061 "Return the id of the root of the thread where ID appears."
3063 (while (and id (setq prev (car (gnus-gethash
3064 id gnus-newsgroup-dependencies))))
3066 id (gnus-parent-id (mail-header-references prev))))
3069 (defun gnus-remove-thread (id &optional dont-remove)
3070 "Remove the thread that has ID in it."
3071 (let ((dep gnus-newsgroup-dependencies)
3072 headers thread last-id)
3073 ;; First go up in this thread until we find the root.
3074 (setq last-id (gnus-root-id id))
3075 (setq headers (list (car (gnus-id-to-thread last-id))
3076 (caadr (gnus-id-to-thread last-id))))
3077 ;; We have now found the real root of this thread. It might have
3078 ;; been gathered into some loose thread, so we have to search
3079 ;; through the threads to find the thread we wanted.
3080 (let ((threads gnus-newsgroup-threads)
3083 (setq sub (car threads))
3084 (if (stringp (car sub))
3085 ;; This is a gathered thread, so we look at the roots
3086 ;; below it to find whether this article is in this
3089 (setq sub (cdr sub))
3091 (when (member (caar sub) headers)
3092 (setq thread (car threads)
3095 (setq sub (cdr sub))))
3096 ;; It's an ordinary thread, so we check it.
3097 (when (eq (car sub) (car headers))
3100 (setq threads (cdr threads)))
3101 ;; If this article is in no thread, then it's a root.
3104 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3105 (setq thread (gnus-gethash last-id dep)))
3108 thread ; We return this thread.
3110 (if (stringp (car thread))
3112 ;; If we use dummy roots, then we have to remove the
3113 ;; dummy root as well.
3114 (when (eq gnus-summary-make-false-root 'dummy)
3116 (gnus-data-compute-positions))
3117 (setq thread (cdr thread))
3119 (gnus-remove-thread-1 (car thread))
3120 (setq thread (cdr thread))))
3121 (gnus-remove-thread-1 thread))))))))
3123 (defun gnus-remove-thread-1 (thread)
3124 "Remove the thread THREAD recursively."
3125 (let ((number (mail-header-number (pop thread)))
3127 (setq thread (reverse thread))
3129 (gnus-remove-thread-1 (pop thread)))
3130 (when (setq d (gnus-data-find number))
3131 (goto-char (gnus-data-pos d))
3134 (- (gnus-point-at-bol)
3136 (1+ (gnus-point-at-eol))
3137 (gnus-delete-line)))))))
3139 (defun gnus-sort-threads (threads)
3141 (if (not gnus-thread-sort-functions)
3143 (gnus-message 7 "Sorting threads...")
3145 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3146 (gnus-message 7 "Sorting threads...done"))))
3148 (defun gnus-sort-articles (articles)
3150 (when gnus-article-sort-functions
3151 (gnus-message 7 "Sorting articles...")
3153 (setq gnus-newsgroup-headers
3154 (sort articles (gnus-make-sort-function
3155 gnus-article-sort-functions)))
3156 (gnus-message 7 "Sorting articles...done"))))
3158 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3159 (defmacro gnus-thread-header (thread)
3160 ;; Return header of first article in THREAD.
3161 ;; Note that THREAD must never, ever be anything else than a variable -
3162 ;; using some other form will lead to serious barfage.
3163 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3164 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3165 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3168 (defsubst gnus-article-sort-by-number (h1 h2)
3169 "Sort articles by article number."
3170 (< (mail-header-number h1)
3171 (mail-header-number h2)))
3173 (defun gnus-thread-sort-by-number (h1 h2)
3174 "Sort threads by root article number."
3175 (gnus-article-sort-by-number
3176 (gnus-thread-header h1) (gnus-thread-header h2)))
3178 (defsubst gnus-article-sort-by-lines (h1 h2)
3179 "Sort articles by article Lines header."
3180 (< (mail-header-lines h1)
3181 (mail-header-lines h2)))
3183 (defun gnus-thread-sort-by-lines (h1 h2)
3184 "Sort threads by root article Lines header."
3185 (gnus-article-sort-by-lines
3186 (gnus-thread-header h1) (gnus-thread-header h2)))
3188 (defsubst gnus-article-sort-by-author (h1 h2)
3189 "Sort articles by root author."
3191 (let ((extract (funcall
3192 gnus-extract-address-components
3193 (mail-header-from h1))))
3194 (or (car extract) (cadr extract) ""))
3195 (let ((extract (funcall
3196 gnus-extract-address-components
3197 (mail-header-from h2))))
3198 (or (car extract) (cadr extract) ""))))
3200 (defun gnus-thread-sort-by-author (h1 h2)
3201 "Sort threads by root author."
3202 (gnus-article-sort-by-author
3203 (gnus-thread-header h1) (gnus-thread-header h2)))
3205 (defsubst gnus-article-sort-by-subject (h1 h2)
3206 "Sort articles by root subject."
3208 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3209 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3211 (defun gnus-thread-sort-by-subject (h1 h2)
3212 "Sort threads by root subject."
3213 (gnus-article-sort-by-subject
3214 (gnus-thread-header h1) (gnus-thread-header h2)))
3216 (defsubst gnus-article-sort-by-date (h1 h2)
3217 "Sort articles by root article date."
3219 (gnus-date-get-time (mail-header-date h1))
3220 (gnus-date-get-time (mail-header-date h2))))
3222 (defun gnus-thread-sort-by-date (h1 h2)
3223 "Sort threads by root article date."
3224 (gnus-article-sort-by-date
3225 (gnus-thread-header h1) (gnus-thread-header h2)))
3227 (defsubst gnus-article-sort-by-score (h1 h2)
3228 "Sort articles by root article score.
3229 Unscored articles will be counted as having a score of zero."
3230 (> (or (cdr (assq (mail-header-number h1)
3231 gnus-newsgroup-scored))
3232 gnus-summary-default-score 0)
3233 (or (cdr (assq (mail-header-number h2)
3234 gnus-newsgroup-scored))
3235 gnus-summary-default-score 0)))
3237 (defun gnus-thread-sort-by-score (h1 h2)
3238 "Sort threads by root article score."
3239 (gnus-article-sort-by-score
3240 (gnus-thread-header h1) (gnus-thread-header h2)))
3242 (defun gnus-thread-sort-by-total-score (h1 h2)
3243 "Sort threads by the sum of all scores in the thread.
3244 Unscored articles will be counted as having a score of zero."
3245 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3247 (defun gnus-thread-total-score (thread)
3248 ;; This function find the total score of THREAD.
3249 (cond ((null thread)
3252 (if (stringp (car thread))
3253 (apply gnus-thread-score-function 0
3254 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3255 (gnus-thread-total-score-1 thread)))
3257 (gnus-thread-total-score-1 (list thread)))))
3259 (defun gnus-thread-total-score-1 (root)
3260 ;; This function find the total score of the thread below ROOT.
3261 (setq root (car root))
3262 (apply gnus-thread-score-function
3264 (mapcar 'gnus-thread-total-score
3265 (cdr (gnus-gethash (mail-header-id root)
3266 gnus-newsgroup-dependencies)))
3267 (when (> (mail-header-number root) 0)
3268 (list (or (cdr (assq (mail-header-number root)
3269 gnus-newsgroup-scored))
3270 gnus-summary-default-score 0))))
3271 (list gnus-summary-default-score)
3274 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3275 (defvar gnus-tmp-prev-subject nil)
3276 (defvar gnus-tmp-false-parent nil)
3277 (defvar gnus-tmp-root-expunged nil)
3278 (defvar gnus-tmp-dummy-line nil)
3280 (defun gnus-summary-prepare-threads (threads)
3281 "Prepare summary buffer from THREADS and indentation LEVEL.
3282 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3283 or a straight list of headers."
3284 (gnus-message 7 "Generating summary...")
3286 (setq gnus-newsgroup-threads threads)
3289 (let ((gnus-tmp-level 0)
3290 (default-score (or gnus-summary-default-score 0))
3291 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3292 thread number subject stack state gnus-tmp-gathered beg-match
3293 new-roots gnus-tmp-new-adopts thread-end
3294 gnus-tmp-header gnus-tmp-unread
3295 gnus-tmp-replied gnus-tmp-subject-or-nil
3296 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3297 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3298 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3300 (setq gnus-tmp-prev-subject nil)
3302 (if (vectorp (car threads))
3303 ;; If this is a straight (sic) list of headers, then a
3304 ;; threaded summary display isn't required, so we just create
3305 ;; an unthreaded one.
3306 (gnus-summary-prepare-unthreaded threads)
3308 ;; Do the threaded display.
3310 (while (or threads stack gnus-tmp-new-adopts new-roots)
3312 (if (and (= gnus-tmp-level 0)
3313 (not (setq gnus-tmp-dummy-line nil))
3316 (not gnus-tmp-false-parent)
3317 (or gnus-tmp-new-adopts new-roots))
3318 (if gnus-tmp-new-adopts
3319 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3320 thread (list (car gnus-tmp-new-adopts))
3321 gnus-tmp-header (caar thread)
3322 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3324 (setq thread (list (car new-roots))
3325 gnus-tmp-header (caar thread)
3326 new-roots (cdr new-roots))))
3329 ;; If there are some threads, we do them before the
3330 ;; threads on the stack.
3331 (setq thread threads
3332 gnus-tmp-header (caar thread))
3333 ;; There were no current threads, so we pop something off
3335 (setq state (car stack)
3336 gnus-tmp-level (car state)
3339 gnus-tmp-header (caar thread))))
3341 (setq gnus-tmp-false-parent nil)
3342 (setq gnus-tmp-root-expunged nil)
3343 (setq thread-end nil)
3345 (if (stringp gnus-tmp-header)
3346 ;; The header is a dummy root.
3348 ((eq gnus-summary-make-false-root 'adopt)
3349 ;; We let the first article adopt the rest.
3350 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3352 (setq gnus-tmp-gathered
3354 (lambda (h) (mail-header-number (car h)))
3357 (setq thread (cons (list (caar thread)
3360 (setq gnus-tmp-level -1
3361 gnus-tmp-false-parent t))
3362 ((eq gnus-summary-make-false-root 'empty)
3363 ;; We print adopted articles with empty subject fields.
3364 (setq gnus-tmp-gathered
3366 (lambda (h) (mail-header-number (car h)))
3369 (setq gnus-tmp-level -1))
3370 ((eq gnus-summary-make-false-root 'dummy)
3371 ;; We remember that we probably want to output a dummy
3373 (setq gnus-tmp-dummy-line gnus-tmp-header)
3374 (setq gnus-tmp-prev-subject gnus-tmp-header))
3376 ;; We do not make a root for the gathered
3377 ;; sub-threads at all.
3378 (setq gnus-tmp-level -1)))
3380 (setq number (mail-header-number gnus-tmp-header)
3381 subject (mail-header-subject gnus-tmp-header))
3384 ;; If the thread has changed subject, we might want to make
3385 ;; this subthread into a root.
3386 ((and (null gnus-thread-ignore-subject)
3387 (not (zerop gnus-tmp-level))
3388 gnus-tmp-prev-subject
3390 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3391 (setq new-roots (nconc new-roots (list (car thread)))
3393 gnus-tmp-header nil))
3394 ;; If the article lies outside the current limit,
3395 ;; then we do not display it.
3396 ((not (memq number gnus-newsgroup-limit))
3397 (setq gnus-tmp-gathered
3399 (lambda (h) (mail-header-number (car h)))
3402 (setq gnus-tmp-new-adopts (if (cdar thread)
3403 (append gnus-tmp-new-adopts
3405 gnus-tmp-new-adopts)
3407 gnus-tmp-header nil)
3408 (when (zerop gnus-tmp-level)
3409 (setq gnus-tmp-root-expunged t)))
3410 ;; Perhaps this article is to be marked as read?
3411 ((and gnus-summary-mark-below
3412 (< (or (cdr (assq number gnus-newsgroup-scored))
3414 gnus-summary-mark-below)
3415 ;; Don't touch sparse articles.
3416 (not (gnus-summary-article-sparse-p number))
3417 (not (gnus-summary-article-ancient-p number)))
3418 (setq gnus-newsgroup-unreads
3419 (delq number gnus-newsgroup-unreads))
3420 (if gnus-newsgroup-auto-expire
3421 (push number gnus-newsgroup-expirable)
3422 (push (cons number gnus-low-score-mark)
3423 gnus-newsgroup-reads))))
3425 (when gnus-tmp-header
3426 ;; We may have an old dummy line to output before this
3428 (when gnus-tmp-dummy-line
3429 (gnus-summary-insert-dummy-line
3430 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3431 (setq gnus-tmp-dummy-line nil))
3433 ;; Compute the mark.
3434 (setq gnus-tmp-unread (gnus-article-mark number))
3436 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3437 gnus-tmp-header gnus-tmp-level)
3438 gnus-newsgroup-data)
3440 ;; Actually insert the line.
3442 gnus-tmp-subject-or-nil
3444 ((and gnus-thread-ignore-subject
3445 gnus-tmp-prev-subject
3446 (not (inline (gnus-subject-equal
3447 gnus-tmp-prev-subject subject))))
3449 ((zerop gnus-tmp-level)
3450 (if (and (eq gnus-summary-make-false-root 'empty)
3451 (memq number gnus-tmp-gathered)
3452 gnus-tmp-prev-subject
3453 (inline (gnus-subject-equal
3454 gnus-tmp-prev-subject subject)))
3455 gnus-summary-same-subject
3457 (t gnus-summary-same-subject)))
3458 (if (and (eq gnus-summary-make-false-root 'adopt)
3459 (= gnus-tmp-level 1)
3460 (memq number gnus-tmp-gathered))
3461 (setq gnus-tmp-opening-bracket ?\<
3462 gnus-tmp-closing-bracket ?\>)
3463 (setq gnus-tmp-opening-bracket ?\[
3464 gnus-tmp-closing-bracket ?\]))
3466 gnus-tmp-indentation
3467 (aref gnus-thread-indent-array gnus-tmp-level)
3468 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3469 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3470 gnus-summary-default-score 0)
3472 (if (or (null gnus-summary-default-score)
3473 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3474 gnus-summary-zcore-fuzz))
3476 (if (< gnus-tmp-score gnus-summary-default-score)
3477 gnus-score-below-mark gnus-score-over-mark))
3479 (cond ((memq number gnus-newsgroup-processable)
3481 ((memq number gnus-newsgroup-cached)
3483 ((memq number gnus-newsgroup-replied)
3485 ((memq number gnus-newsgroup-saved)
3487 (t gnus-unread-mark))
3488 gnus-tmp-from (mail-header-from gnus-tmp-header)
3491 ((string-match "<[^>]+> *$" gnus-tmp-from)
3492 (setq beg-match (match-beginning 0))
3493 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3494 (substring gnus-tmp-from (1+ (match-beginning 0))
3495 (1- (match-end 0))))
3496 (substring gnus-tmp-from 0 beg-match)))
3497 ((string-match "(.+)" gnus-tmp-from)
3498 (substring gnus-tmp-from
3499 (1+ (match-beginning 0)) (1- (match-end 0))))
3501 (when (string= gnus-tmp-name "")
3502 (setq gnus-tmp-name gnus-tmp-from))
3503 (unless (numberp gnus-tmp-lines)
3504 (setq gnus-tmp-lines 0))
3505 (gnus-put-text-property
3507 (progn (eval gnus-summary-line-format-spec) (point))
3508 'gnus-number number)
3511 (run-hooks 'gnus-summary-update-hook)
3514 (setq gnus-tmp-prev-subject subject)))
3516 (when (nth 1 thread)
3517 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3518 (incf gnus-tmp-level)
3519 (setq threads (if thread-end nil (cdar thread)))
3521 (setq gnus-tmp-level 0)))))
3522 (gnus-message 7 "Generating summary...done"))
3524 (defun gnus-summary-prepare-unthreaded (headers)
3525 "Generate an unthreaded summary buffer based on HEADERS."
3526 (let (header number mark)
3531 ;; We may have to root out some bad articles...
3532 (when (memq (setq number (mail-header-number
3533 (setq header (pop headers))))
3534 gnus-newsgroup-limit)
3535 ;; Mark article as read when it has a low score.
3536 (when (and gnus-summary-mark-below
3537 (< (or (cdr (assq number gnus-newsgroup-scored))
3538 gnus-summary-default-score 0)
3539 gnus-summary-mark-below)
3540 (not (gnus-summary-article-ancient-p number)))
3541 (setq gnus-newsgroup-unreads
3542 (delq number gnus-newsgroup-unreads))
3543 (if gnus-newsgroup-auto-expire
3544 (push number gnus-newsgroup-expirable)
3545 (push (cons number gnus-low-score-mark)
3546 gnus-newsgroup-reads)))
3548 (setq mark (gnus-article-mark number))
3549 (push (gnus-data-make number mark (1+ (point)) header 0)
3550 gnus-newsgroup-data)
3551 (gnus-summary-insert-line
3553 mark (memq number gnus-newsgroup-replied)
3554 (memq number gnus-newsgroup-expirable)
3555 (mail-header-subject header) nil
3556 (cdr (assq number gnus-newsgroup-scored))
3557 (memq number gnus-newsgroup-processable))))))
3559 (defun gnus-select-newsgroup (group &optional read-all)
3560 "Select newsgroup GROUP.
3561 If READ-ALL is non-nil, all articles in the group are selected."
3562 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3563 (info (nth 2 entry))
3564 articles fetched-articles cached)
3566 (unless (gnus-check-server
3567 (setq gnus-current-select-method
3568 (gnus-find-method-for-group group)))
3569 (error "Couldn't open server"))
3571 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3572 (gnus-activate-group group) ; Or we can activate it...
3573 (progn ; Or we bug out.
3574 (when (equal major-mode 'gnus-summary-mode)
3575 (kill-buffer (current-buffer)))
3576 (error "Couldn't request group %s: %s"
3577 group (gnus-status-message group))))
3579 (unless (gnus-request-group group t)
3580 (when (equal major-mode 'gnus-summary-mode)
3581 (kill-buffer (current-buffer)))
3582 (error "Couldn't request group %s: %s"
3583 group (gnus-status-message group)))
3585 (setq gnus-newsgroup-name group)
3586 (setq gnus-newsgroup-unselected nil)
3587 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3589 ;; Adjust and set lists of article marks.
3591 (gnus-adjust-marked-articles info))
3593 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3594 (when (gnus-virtual-group-p group)
3595 (setq cached gnus-newsgroup-cached))
3597 (setq gnus-newsgroup-unreads
3598 (gnus-set-difference
3599 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3600 gnus-newsgroup-dormant))
3602 (setq gnus-newsgroup-processable nil)
3604 (gnus-update-read-articles group gnus-newsgroup-unreads)
3605 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3606 (gnus-group-update-group group))
3608 (setq articles (gnus-articles-to-read group read-all))
3612 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3614 ((eq articles 0) nil)
3616 ;; Init the dependencies hash table.
3617 (setq gnus-newsgroup-dependencies
3618 (gnus-make-hashtable (length articles)))
3619 ;; Retrieve the headers and read them in.
3620 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3621 (setq gnus-newsgroup-headers
3623 (setq gnus-headers-retrieved-by
3624 (gnus-retrieve-headers
3625 articles gnus-newsgroup-name
3626 ;; We might want to fetch old headers, but
3627 ;; not if there is only 1 article.
3628 (and gnus-fetch-old-headers
3630 (not (eq gnus-fetch-old-headers 'some))
3631 (not (numberp gnus-fetch-old-headers)))
3632 (> (length articles) 1))))))
3633 (gnus-get-newsgroup-headers-xover
3634 articles nil nil gnus-newsgroup-name t)
3635 (gnus-get-newsgroup-headers)))
3636 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3638 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3640 (setq gnus-newsgroup-cached cached))
3642 ;; Suppress duplicates?
3643 (when gnus-suppress-duplicates
3644 (gnus-dup-suppress-articles))
3646 ;; Set the initial limit.
3647 (setq gnus-newsgroup-limit (copy-sequence articles))
3648 ;; Remove canceled articles from the list of unread articles.
3649 (setq gnus-newsgroup-unreads
3650 (gnus-set-sorted-intersection
3651 gnus-newsgroup-unreads
3652 (setq fetched-articles
3653 (mapcar (lambda (headers) (mail-header-number headers))
3654 gnus-newsgroup-headers))))
3655 ;; Removed marked articles that do not exist.
3656 (gnus-update-missing-marks
3657 (gnus-sorted-complement fetched-articles articles))
3658 ;; We might want to build some more threads first.
3659 (and gnus-fetch-old-headers
3660 (eq gnus-headers-retrieved-by 'nov)
3661 (gnus-build-old-threads))
3662 ;; Check whether auto-expire is to be done in this group.
3663 (setq gnus-newsgroup-auto-expire
3664 (gnus-group-auto-expirable-p group))
3665 ;; Set up the article buffer now, if necessary.
3666 (unless gnus-single-article-buffer
3667 (gnus-article-setup-buffer))
3668 ;; First and last article in this newsgroup.
3669 (when gnus-newsgroup-headers
3670 (setq gnus-newsgroup-begin
3671 (mail-header-number (car gnus-newsgroup-headers))
3674 (gnus-last-element gnus-newsgroup-headers))))
3675 ;; GROUP is successfully selected.
3676 (or gnus-newsgroup-headers t)))))
3678 (defun gnus-articles-to-read (group &optional read-all)
3679 ;; Find out what articles the user wants to read.
3681 ;; Select all articles if `read-all' is non-nil, or if there
3682 ;; are no unread articles.
3684 (and (zerop (length gnus-newsgroup-marked))
3685 (zerop (length gnus-newsgroup-unreads)))
3686 (eq (gnus-group-find-parameter group 'display)
3688 (gnus-uncompress-range (gnus-active group))
3689 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3690 (copy-sequence gnus-newsgroup-unreads))
3692 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3693 (scored (length scored-list))
3694 (number (length articles))
3695 (marked (+ (length gnus-newsgroup-marked)
3696 (length gnus-newsgroup-dormant)))
3704 ((and (or (<= scored marked) (= scored number))
3705 (numberp gnus-large-newsgroup)
3706 (> number gnus-large-newsgroup))
3710 "How many articles from %s (default %d): "
3711 (gnus-limit-string gnus-newsgroup-name 35)
3713 (if (string-match "^[ \t]*$" input) number input)))
3714 ((and (> scored marked) (< scored number)
3715 (> (- scored number) 20))
3718 (format "%s %s (%d scored, %d total): "
3719 "How many articles from"
3720 group scored number))))
3721 (if (string-match "^[ \t]*$" input)
3725 (setq select (if (stringp select) (string-to-number select) select))
3726 (if (or (null select) (zerop select))
3728 (if (and (not (zerop scored)) (<= (abs select) scored))
3730 (setq articles (sort scored-list '<))
3731 (setq number (length articles)))
3732 (setq articles (copy-sequence articles)))
3734 (when (< (abs select) number)
3736 ;; Select the N oldest articles.
3737 (setcdr (nthcdr (1- (abs select)) articles) nil)
3738 ;; Select the N most recent articles.
3739 (setq articles (nthcdr (- number select) articles))))
3740 (setq gnus-newsgroup-unselected
3741 (gnus-sorted-intersection
3742 gnus-newsgroup-unreads
3743 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3746 (defun gnus-killed-articles (killed articles)
3749 (when (inline (gnus-member-of-range (car articles) killed))
3750 (push (car articles) out))
3751 (setq articles (cdr articles)))
3754 (defun gnus-uncompress-marks (marks)
3755 "Uncompress the mark ranges in MARKS."
3756 (let ((uncompressed '(score bookmark))
3759 (if (memq (caar marks) uncompressed)
3760 (push (car marks) out)
3761 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3762 (setq marks (cdr marks)))
3765 (defun gnus-adjust-marked-articles (info)
3766 "Set all article lists and remove all marks that are no longer legal."
3767 (let* ((marked-lists (gnus-info-marks info))
3768 (active (gnus-active (gnus-info-group info)))
3771 (types gnus-article-mark-lists)
3772 (uncompressed '(score bookmark killed))
3773 marks var articles article mark)
3776 (setq marks (pop marked-lists))
3777 (set (setq var (intern (format "gnus-newsgroup-%s"
3778 (car (rassq (setq mark (car marks))
3780 (if (memq (car marks) uncompressed) (cdr marks)
3781 (gnus-uncompress-range (cdr marks))))
3783 (setq articles (symbol-value var))
3785 ;; All articles have to be subsets of the active articles.
3787 ;; Adjust "simple" lists.
3788 ((memq mark '(tick dormant expirable reply save))
3790 (when (or (< (setq article (pop articles)) min) (> article max))
3791 (set var (delq article (symbol-value var))))))
3793 ((memq mark uncompressed)
3795 (when (or (not (consp (setq article (pop articles))))
3796 (< (car article) min)
3797 (> (car article) max))
3798 (set var (delq article (symbol-value var))))))))))
3800 (defun gnus-update-missing-marks (missing)
3801 "Go through the list of MISSING articles and remove them mark lists."
3803 (let ((types gnus-article-mark-lists)
3805 ;; Go through all types.
3807 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3808 (when (symbol-value var)
3809 ;; This list has articles. So we delete all missing articles
3813 (set var (delq (pop m) (symbol-value var)))))))))
3815 (defun gnus-update-marks ()
3816 "Enter the various lists of marked articles into the newsgroup info list."
3817 (let ((types gnus-article-mark-lists)
3818 (info (gnus-get-info gnus-newsgroup-name))
3819 (uncompressed '(score bookmark killed))
3820 type list newmarked symbol)
3822 ;; Add all marks lists that are non-nil to the list of marks lists.
3823 (while (setq type (pop types))
3824 (when (setq list (symbol-value
3826 (intern (format "gnus-newsgroup-%s"
3829 ;; Get rid of the entries of the articles that have the
3831 (when (and (eq (cdr type) 'score)
3834 (let* ((arts articles)
3835 (prev (cons nil articles))
3838 (if (or (not (consp (car arts)))
3839 (= (cdar arts) gnus-summary-default-score))
3840 (setcdr prev (cdr arts))
3842 (setq arts (cdr arts)))
3843 (setq articles (cdr all))))
3845 (push (cons (cdr type)
3846 (if (memq (cdr type) uncompressed) list
3847 (gnus-compress-sequence
3848 (set symbol (sort list '<)) t)))
3851 ;; Enter these new marks into the info of the group.
3853 (setcar (nthcdr 3 info) newmarked)
3854 ;; Add the marks lists to the end of the info.
3856 (setcdr (nthcdr 2 info) (list newmarked))))
3858 ;; Cut off the end of the info if there's nothing else there.
3862 (when (nthcdr (decf i) info)
3863 (setcdr (nthcdr i info) nil)))))))
3865 (defun gnus-set-mode-line (where)
3866 "This function sets the mode line of the article or summary buffers.
3867 If WHERE is `summary', the summary mode line format will be used."
3868 ;; Is this mode line one we keep updated?
3869 (when (memq where gnus-updated-mode-lines)
3872 ;; We evaluate this in the summary buffer since these
3873 ;; variables are buffer-local to that buffer.
3874 (set-buffer gnus-summary-buffer)
3875 ;; We bind all these variables that are used in the `eval' form
3877 (let* ((mformat (symbol-value
3879 (format "gnus-%s-mode-line-format-spec" where))))
3880 (gnus-tmp-group-name gnus-newsgroup-name)
3881 (gnus-tmp-article-number (or gnus-current-article 0))
3882 (gnus-tmp-unread gnus-newsgroup-unreads)
3883 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3884 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3885 (gnus-tmp-unread-and-unselected
3886 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3887 (zerop gnus-tmp-unselected))
3889 ((zerop gnus-tmp-unselected)
3890 (format "{%d more}" gnus-tmp-unread-and-unticked))
3891 (t (format "{%d(+%d) more}"
3892 gnus-tmp-unread-and-unticked
3893 gnus-tmp-unselected))))
3895 (if (and gnus-current-headers
3896 (vectorp gnus-current-headers))
3897 (gnus-mode-string-quote
3898 (mail-header-subject gnus-current-headers))
3900 bufname-length max-len
3901 gnus-tmp-header);; passed as argument to any user-format-funcs
3902 (setq mode-string (eval mformat))
3903 (setq bufname-length (if (string-match "%b" mode-string)
3906 (if (eq where 'summary)
3908 (get-buffer gnus-article-buffer))))
3911 (setq max-len (max 4 (if gnus-mode-non-string-length
3913 gnus-mode-non-string-length
3915 (length mode-string))))
3916 ;; We might have to chop a bit of the string off...
3917 (when (> (length mode-string) max-len)
3919 (concat (gnus-truncate-string mode-string (- max-len 3))
3921 ;; Pad the mode string a bit.
3922 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3923 ;; Update the mode line.
3924 (setq mode-line-buffer-identification
3925 (gnus-mode-line-buffer-identification (list mode-string)))
3926 (set-buffer-modified-p t))))
3928 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3929 "Go through the HEADERS list and add all Xrefs to a hash table.
3930 The resulting hash table is returned, or nil if no Xrefs were found."
3931 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3932 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3933 (xref-hashtb (gnus-make-hashtable))
3934 start group entry number xrefs header)
3936 (setq header (pop headers))
3937 (when (and (setq xrefs (mail-header-xref header))
3938 (not (memq (setq number (mail-header-number header))
3941 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3942 (setq start (match-end 0))
3943 (setq group (if prefix
3944 (concat prefix (substring xrefs (match-beginning 1)
3946 (substring xrefs (match-beginning 1) (match-end 1))))
3948 (string-to-int (substring xrefs (match-beginning 2)
3950 (if (setq entry (gnus-gethash group xref-hashtb))
3951 (setcdr entry (cons number (cdr entry)))
3952 (gnus-sethash group (cons number nil) xref-hashtb)))))
3953 (and start xref-hashtb)))
3955 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3956 "Look through all the headers and mark the Xrefs as read."
3957 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3958 name entry info xref-hashtb idlist method nth4)
3960 (set-buffer gnus-group-buffer)
3961 (when (setq xref-hashtb
3962 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3965 (unless (string= from-newsgroup (setq name (symbol-name group)))
3966 (setq idlist (symbol-value group))
3967 ;; Dead groups are not updated.
3969 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3971 (when (stringp (setq nth4 (gnus-info-method info)))
3972 (setq nth4 (gnus-server-to-method nth4))))
3973 ;; Only do the xrefs if the group has the same
3974 ;; select method as the group we have just read.
3975 (or (gnus-methods-equal-p
3976 nth4 (gnus-find-method-for-group from-newsgroup))
3978 (equal nth4 (setq method (gnus-find-method-for-group
3980 (and (equal (car nth4) (car method))
3981 (equal (nth 1 nth4) (nth 1 method))))
3982 gnus-use-cross-reference
3983 (or (not (eq gnus-use-cross-reference t))
3985 ;; Only do cross-references on subscribed
3986 ;; groups, if that is what is wanted.
3987 (<= (gnus-info-level info) gnus-level-subscribed))
3988 (gnus-group-make-articles-read name idlist))))
3991 (defun gnus-group-make-articles-read (group articles)
3992 "Update the info of GROUP to say that ARTICLES are read."
3994 (entry (gnus-gethash group gnus-newsrc-hashtb))
3995 (info (nth 2 entry))
3996 (active (gnus-active group))
3998 ;; First peel off all illegal article numbers.
4000 (let ((ids articles)
4002 (while (setq id (pop ids))
4003 (when (and first (> id (cdr active)))
4004 ;; We'll end up in this situation in one particular
4005 ;; obscure situation. If you re-scan a group and get
4006 ;; a new article that is cross-posted to a different
4007 ;; group that has not been re-scanned, you might get
4008 ;; crossposted article that has a higher number than
4009 ;; Gnus believes possible. So we re-activate this
4010 ;; group as well. This might mean doing the
4011 ;; crossposting thingy will *increase* the number
4012 ;; of articles in some groups. Tsk, tsk.
4013 (setq active (or (gnus-activate-group group) active)))
4014 (when (or (> id (cdr active))
4015 (< id (car active)))
4016 (setq articles (delq id articles))))))
4018 (set-buffer gnus-group-buffer)
4021 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4022 (gnus-info-set-read ',info ',(gnus-info-read info))
4023 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4024 (gnus-group-update-group ,group t))))
4025 ;; If the read list is nil, we init it.
4027 (null (gnus-info-read info))
4029 (gnus-info-set-read info (cons 1 (1- (car active)))))
4030 ;; Then we add the read articles to the range.
4035 (gnus-info-read info) (setq articles (sort articles '<)))))
4036 ;; Then we have to re-compute how many unread
4037 ;; articles there are in this group.
4041 (setq num (- (1+ (cdr active)) (car active))))
4042 ((not (listp (cdr range)))
4043 (setq num (- (cdr active) (- (1+ (cdr range))
4047 (if (numberp (car range))
4049 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4050 (setq range (cdr range)))
4051 (setq num (- (cdr active) num))))
4052 ;; Update the number of unread articles.
4054 ;; Update the group buffer.
4055 (gnus-group-update-group group t))))
4057 (defun gnus-methods-equal-p (m1 m2)
4058 (let ((m1 (or m1 gnus-select-method))
4059 (m2 (or m2 gnus-select-method)))
4061 (and (eq (car m1) (car m2))
4062 (or (not (memq 'address (assoc (symbol-name (car m1))
4063 gnus-valid-select-methods)))
4064 (equal (nth 1 m1) (nth 1 m2)))))))
4066 (defvar gnus-newsgroup-none-id 0)
4068 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4069 (let ((cur nntp-server-buffer)
4072 (save-excursion (set-buffer gnus-summary-buffer)
4073 gnus-newsgroup-dependencies)))
4074 headers id id-dep ref-dep end ref)
4076 (set-buffer nntp-server-buffer)
4077 ;; Translate all TAB characters into SPACE characters.
4078 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4079 (run-hooks 'gnus-parse-headers-hook)
4080 (let ((case-fold-search t)
4081 in-reply-to header p lines)
4082 (goto-char (point-min))
4083 ;; Search to the beginning of the next header. Error messages
4084 ;; do not begin with 2 or 3.
4085 (while (re-search-forward "^[23][0-9]+ " nil t)
4088 ;; This implementation of this function, with nine
4089 ;; search-forwards instead of the one re-search-forward and
4090 ;; a case (which basically was the old function) is actually
4091 ;; about twice as fast, even though it looks messier. You
4092 ;; can't have everything, I guess. Speed and elegance
4093 ;; doesn't always go hand in hand.
4102 (narrow-to-region (point)
4103 (or (and (search-forward "\n.\n" nil t)
4109 (if (search-forward "\nsubject: " nil t)
4110 (nnheader-header-value) "(none)"))
4114 (if (search-forward "\nfrom: " nil t)
4115 (nnheader-header-value) "(nobody)"))
4119 (if (search-forward "\ndate: " nil t)
4120 (nnheader-header-value) ""))
4124 (setq id (if (search-forward "\nmessage-id:" nil t)
4126 (1- (or (search-forward "<" nil t) (point)))
4127 (or (search-forward ">" nil t) (point)))
4128 ;; If there was no message-id, we just fake one
4129 ;; to make subsequent routines simpler.
4130 (nnheader-generate-fake-message-id))))
4134 (if (search-forward "\nreferences: " nil t)
4138 (nnheader-header-value)
4143 (search-backward ">" end t)
4146 (search-backward "<" end t)
4148 ;; Get the references from the in-reply-to header if there
4149 ;; were no references and the in-reply-to header looks
4151 (if (and (search-forward "\nin-reply-to: " nil t)
4152 (setq in-reply-to (nnheader-header-value))
4153 (string-match "<[^>]+>" in-reply-to))
4154 (setq ref (substring in-reply-to (match-beginning 0)
4162 (if (search-forward "\nlines: " nil t)
4163 (if (numberp (setq lines (read cur)))
4169 (and (search-forward "\nxref: " nil t)
4170 (nnheader-header-value)))))
4171 (when (equal id ref)
4173 ;; We do the threading while we read the headers. The
4174 ;; message-id and the last reference are both entered into
4175 ;; the same hash table. Some tippy-toeing around has to be
4176 ;; done in case an article has arrived before the article
4177 ;; which it refers to.
4178 (if (boundp (setq id-dep (intern id dependencies)))
4179 (if (and (car (symbol-value id-dep))
4181 ;; An article with this Message-ID has already been seen,
4182 ;; so we rename the Message-ID.
4185 (setq id-dep (intern (setq id (nnmail-message-id))
4188 (mail-header-set-id header id))
4189 (setcar (symbol-value id-dep) header))
4190 (set id-dep (list header)))
4192 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4193 (setcdr (symbol-value ref-dep)
4194 (nconc (cdr (symbol-value ref-dep))
4195 (list (symbol-value id-dep))))
4196 (set ref-dep (list nil (symbol-value id-dep))))
4197 (push header headers))
4198 (goto-char (point-max))
4200 (nreverse headers)))))
4202 ;; The following macros and functions were written by Felix Lee
4203 ;; <flee@cse.psu.edu>.
4205 (defmacro gnus-nov-read-integer ()
4207 (if (= (following-char) ?\t)
4209 (let ((num (ignore-errors (read buffer))))
4210 (if (numberp num) num 0)))
4214 (defmacro gnus-nov-skip-field ()
4215 '(search-forward "\t" eol 'move))
4217 (defmacro gnus-nov-field ()
4218 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4220 ;; (defvar gnus-nov-none-counter 0)
4222 ;; This function has to be called with point after the article number
4223 ;; on the beginning of the line.
4224 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4225 (let ((eol (gnus-point-at-eol))
4226 (buffer (current-buffer))
4227 header ref id id-dep ref-dep)
4229 ;; overview: [num subject from date id refs chars lines misc]
4232 (narrow-to-region (point) eol)
4239 (gnus-nov-field) ; subject
4240 (gnus-nov-field) ; from
4241 (gnus-nov-field) ; date
4242 (setq id (or (gnus-nov-field)
4243 (nnheader-generate-fake-message-id))) ; id
4245 (let ((beg (point)))
4246 (search-forward "\t" eol)
4247 (if (search-backward ">" beg t)
4251 (search-backward "<" beg t)))
4254 (gnus-nov-field)) ; refs
4255 (gnus-nov-read-integer) ; chars
4256 (gnus-nov-read-integer) ; lines
4257 (if (= (following-char) ?\n)
4259 (gnus-nov-field))))) ; misc
4263 ;; We build the thread tree.
4264 (when (equal id ref)
4265 ;; This article refers back to itself. Naughty, naughty.
4267 (if (boundp (setq id-dep (intern id dependencies)))
4268 (if (and (car (symbol-value id-dep))
4270 ;; An article with this Message-ID has already been seen,
4271 ;; so we rename the Message-ID.
4274 (setq id-dep (intern (setq id (nnmail-message-id))
4277 (mail-header-set-id header id))
4278 (setcar (symbol-value id-dep) header))
4279 (set id-dep (list header)))
4281 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4282 (setcdr (symbol-value ref-dep)
4283 (nconc (cdr (symbol-value ref-dep))
4284 (list (symbol-value id-dep))))
4285 (set ref-dep (list nil (symbol-value id-dep)))))
4288 ;; Goes through the xover lines and returns a list of vectors
4289 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4290 force-new dependencies
4291 group also-fetch-heads)
4292 "Parse the news overview data in the server buffer, and return a
4293 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4294 ;; Get the Xref when the users reads the articles since most/some
4295 ;; NNTP servers do not include Xrefs when using XOVER.
4296 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4297 (let ((cur nntp-server-buffer)
4298 (dependencies (or dependencies gnus-newsgroup-dependencies))
4299 number headers header)
4301 (set-buffer nntp-server-buffer)
4302 ;; Allow the user to mangle the headers before parsing them.
4303 (run-hooks 'gnus-parse-headers-hook)
4304 (goto-char (point-min))
4307 (while (and sequence (not (eobp)))
4308 (setq number (read cur))
4309 (while (and sequence
4310 (< (car sequence) number))
4311 (setq sequence (cdr sequence)))
4313 (eq number (car sequence))
4315 (setq sequence (cdr sequence))
4316 (setq header (inline
4317 (gnus-nov-parse-line
4318 number dependencies force-new))))
4319 (push header headers))
4322 (gnus-error 4 "Strange nov line (%d)"
4323 (count-lines (point-min) (point)))))
4325 ;; A common bug in inn is that if you have posted an article and
4326 ;; then retrieves the active file, it will answer correctly --
4327 ;; the new article is included. However, a NOV entry for the
4328 ;; article may not have been generated yet, so this may fail.
4329 ;; We work around this problem by retrieving the last few
4330 ;; headers using HEAD.
4331 (if (or (not also-fetch-heads)
4333 ;; We (probably) got all the headers.
4335 (let ((gnus-nov-is-evil t))
4338 (when (gnus-retrieve-headers sequence group)
4339 (gnus-get-newsgroup-headers))))))))
4341 (defun gnus-article-get-xrefs ()
4342 "Fill in the Xref value in `gnus-current-headers', if necessary.
4343 This is meant to be called in `gnus-article-internal-prepare-hook'."
4344 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4345 gnus-current-headers)))
4346 (or (not gnus-use-cross-reference)
4348 (and (mail-header-xref headers)
4349 (not (string= (mail-header-xref headers) "")))
4350 (let ((case-fold-search t)
4353 (nnheader-narrow-to-headers)
4354 (goto-char (point-min))
4355 (when (or (and (eq (downcase (following-char)) ?x)
4356 (looking-at "Xref:"))
4357 (search-forward "\nXref:" nil t))
4358 (goto-char (1+ (match-end 0)))
4359 (setq xref (buffer-substring (point)
4360 (progn (end-of-line) (point))))
4361 (mail-header-set-xref headers xref)))))))
4363 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4364 "Find article ID and insert the summary line for that article."
4365 (let ((header (if (and old-header use-old-header)
4366 old-header (gnus-read-header id)))
4367 (number (and (numberp id) id))
4370 ;; Rebuild the thread that this article is part of and go to the
4371 ;; article we have fetched.
4372 (when (and (not gnus-show-threads)
4374 (when (setq d (gnus-data-find (mail-header-number old-header)))
4375 (goto-char (gnus-data-pos d))
4378 (- (gnus-point-at-bol)
4380 (1+ (gnus-point-at-eol))
4381 (gnus-delete-line))))))
4383 (mail-header-set-number header (mail-header-number old-header)))
4384 (setq gnus-newsgroup-sparse
4385 (delq (setq number (mail-header-number header))
4386 gnus-newsgroup-sparse))
4387 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4388 (gnus-rebuild-thread (mail-header-id header))
4389 (gnus-summary-goto-subject number nil t))
4390 (when (and (numberp number)
4392 ;; We have to update the boundaries even if we can't fetch the
4393 ;; article if ID is a number -- so that the next `P' or `N'
4394 ;; command will fetch the previous (or next) article even
4395 ;; if the one we tried to fetch this time has been canceled.
4396 (when (> number gnus-newsgroup-end)
4397 (setq gnus-newsgroup-end number))
4398 (when (< number gnus-newsgroup-begin)
4399 (setq gnus-newsgroup-begin number))
4400 (setq gnus-newsgroup-unselected
4401 (delq number gnus-newsgroup-unselected)))
4402 ;; Report back a success?
4403 (and header (mail-header-number header))))
4405 ;;; Process/prefix in the summary buffer
4407 (defun gnus-summary-work-articles (n)
4408 "Return a list of articles to be worked upon. The prefix argument,
4409 the list of process marked articles, and the current article will be
4410 taken into consideration."
4413 ;; A numerical prefix has been given.
4414 (setq n (prefix-numeric-value n))
4415 (let ((backward (< n 0))
4416 (n (abs (prefix-numeric-value n)))
4421 (push (setq article (gnus-summary-article-number))
4424 (gnus-summary-find-prev nil article)
4425 (gnus-summary-find-next nil article)))
4427 (nreverse articles)))
4428 ((gnus-region-active-p)
4429 ;; Work on the region between point and mark.
4430 (let ((max (max (point) (mark)))
4433 (goto-char (min (point) (mark)))
4436 (push (setq article (gnus-summary-article-number)) articles)
4437 (gnus-summary-find-next nil article)
4439 (nreverse articles))))
4440 (gnus-newsgroup-processable
4441 ;; There are process-marked articles present.
4442 ;; Save current state.
4443 (gnus-summary-save-process-mark)
4445 (reverse gnus-newsgroup-processable))
4447 ;; Just return the current article.
4448 (list (gnus-summary-article-number)))))
4450 (defun gnus-summary-save-process-mark ()
4451 "Push the current set of process marked articles on the stack."
4453 (push (copy-sequence gnus-newsgroup-processable)
4454 gnus-newsgroup-process-stack))
4456 (defun gnus-summary-kill-process-mark ()
4457 "Push the current set of process marked articles on the stack and unmark."
4459 (gnus-summary-save-process-mark)
4460 (gnus-summary-unmark-all-processable))
4462 (defun gnus-summary-yank-process-mark ()
4463 "Pop the last process mark state off the stack and restore it."
4465 (unless gnus-newsgroup-process-stack
4466 (error "Empty mark stack"))
4467 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4469 (defun gnus-summary-process-mark-set (set)
4470 "Make SET into the current process marked articles."
4471 (gnus-summary-unmark-all-processable)
4473 (gnus-summary-set-process-mark (pop set))))
4475 ;;; Searching and stuff
4477 (defun gnus-summary-search-group (&optional backward use-level)
4478 "Search for next unread newsgroup.
4479 If optional argument BACKWARD is non-nil, search backward instead."
4481 (set-buffer gnus-group-buffer)
4482 (when (gnus-group-search-forward
4483 backward nil (if use-level (gnus-group-group-level) nil))
4484 (gnus-group-group-name))))
4486 (defun gnus-summary-best-group (&optional exclude-group)
4487 "Find the name of the best unread group.
4488 If EXCLUDE-GROUP, do not go to this group."
4490 (set-buffer gnus-group-buffer)
4492 (gnus-group-best-unread-group exclude-group))))
4494 (defun gnus-summary-find-next (&optional unread article backward)
4495 (if backward (gnus-summary-find-prev)
4496 (let* ((dummy (gnus-summary-article-intangible-p))
4497 (article (or article (gnus-summary-article-number)))
4498 (arts (gnus-data-find-list article))
4500 (when (and (not dummy)
4501 (or (not gnus-summary-check-current)
4503 (not (gnus-data-unread-p (car arts)))))
4504 (setq arts (cdr arts)))
4509 (when (gnus-data-unread-p (car arts))
4510 (setq result (car arts)
4512 (setq arts (cdr arts)))
4515 (goto-char (gnus-data-pos result))
4516 (gnus-data-number result)))))
4518 (defun gnus-summary-find-prev (&optional unread article)
4519 (let* ((eobp (eobp))
4520 (article (or article (gnus-summary-article-number)))
4521 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4523 (when (and (not eobp)
4524 (or (not gnus-summary-check-current)
4526 (not (gnus-data-unread-p (car arts)))))
4527 (setq arts (cdr arts)))
4532 (when (gnus-data-unread-p (car arts))
4533 (setq result (car arts)
4535 (setq arts (cdr arts)))
4538 (goto-char (gnus-data-pos result))
4539 (gnus-data-number result))))
4541 (defun gnus-summary-find-subject (subject &optional unread backward article)
4542 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4543 (article (or article (gnus-summary-article-number)))
4544 (articles (gnus-data-list backward))
4545 (arts (gnus-data-find-list article articles))
4547 (when (or (not gnus-summary-check-current)
4549 (not (gnus-data-unread-p (car arts))))
4550 (setq arts (cdr arts)))
4552 (and (or (not unread)
4553 (gnus-data-unread-p (car arts)))
4554 (vectorp (gnus-data-header (car arts)))
4556 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4557 (setq result (car arts)
4559 (setq arts (cdr arts)))
4561 (goto-char (gnus-data-pos result))
4562 (gnus-data-number result))))
4564 (defun gnus-summary-search-forward (&optional unread subject backward)
4565 "Search forward for an article.
4566 If UNREAD, look for unread articles. If SUBJECT, look for
4567 articles with that subject. If BACKWARD, search backward instead."
4568 (cond (subject (gnus-summary-find-subject subject unread backward))
4569 (backward (gnus-summary-find-prev unread))
4570 (t (gnus-summary-find-next unread))))
4572 (defun gnus-recenter (&optional n)
4573 "Center point in window and redisplay frame.
4574 Also do horizontal recentering."
4576 (when (and gnus-auto-center-summary
4577 (not (eq gnus-auto-center-summary 'vertical)))
4578 (gnus-horizontal-recenter))
4581 (defun gnus-summary-recenter ()
4582 "Center point in the summary window.
4583 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4584 displayed, no centering will be performed."
4585 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4586 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4587 (let* ((top (cond ((< (window-height) 4) 0)
4588 ((< (window-height) 7) 1)
4590 (height (1- (window-height)))
4591 (bottom (save-excursion (goto-char (point-max))
4592 (forward-line (- height))
4594 (window (get-buffer-window (current-buffer))))
4595 ;; The user has to want it.
4596 (when gnus-auto-center-summary
4597 (when (get-buffer-window gnus-article-buffer)
4598 ;; Only do recentering when the article buffer is displayed,
4599 ;; Set the window start to either `bottom', which is the biggest
4600 ;; possible valid number, or the second line from the top,
4601 ;; whichever is the least.
4603 window (min bottom (save-excursion
4604 (forward-line (- top)) (point)))))
4605 ;; Do horizontal recentering while we're at it.
4606 (when (and (get-buffer-window (current-buffer) t)
4607 (not (eq gnus-auto-center-summary 'vertical)))
4608 (let ((selected (selected-window)))
4609 (select-window (get-buffer-window (current-buffer) t))
4610 (gnus-summary-position-point)
4611 (gnus-horizontal-recenter)
4612 (select-window selected))))))
4614 (defun gnus-summary-jump-to-group (newsgroup)
4615 "Move point to NEWSGROUP in group mode buffer."
4616 ;; Keep update point of group mode buffer if visible.
4617 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4618 (save-window-excursion
4619 ;; Take care of tree window mode.
4620 (when (get-buffer-window gnus-group-buffer)
4621 (pop-to-buffer gnus-group-buffer))
4622 (gnus-group-jump-to-group newsgroup))
4624 ;; Take care of tree window mode.
4625 (if (get-buffer-window gnus-group-buffer)
4626 (pop-to-buffer gnus-group-buffer)
4627 (set-buffer gnus-group-buffer))
4628 (gnus-group-jump-to-group newsgroup))))
4630 ;; This function returns a list of article numbers based on the
4631 ;; difference between the ranges of read articles in this group and
4632 ;; the range of active articles.
4633 (defun gnus-list-of-unread-articles (group)
4634 (let* ((read (gnus-info-read (gnus-get-info group)))
4635 (active (or (gnus-active group) (gnus-activate-group group)))
4638 ;; If none are read, then all are unread.
4640 (setq first (car active))
4641 ;; If the range of read articles is a single range, then the
4642 ;; first unread article is the article after the last read
4643 ;; article. Sounds logical, doesn't it?
4644 (if (not (listp (cdr read)))
4645 (setq first (1+ (cdr read)))
4646 ;; `read' is a list of ranges.
4647 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4653 (while (< first nlast)
4655 (setq first (1+ first))))
4656 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4657 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4658 (setq read (cdr read)))))
4659 ;; And add the last unread articles.
4660 (while (<= first last)
4662 (setq first (1+ first)))
4663 ;; Return the list of unread articles.
4666 (defun gnus-list-of-read-articles (group)
4667 "Return a list of unread, unticked and non-dormant articles."
4668 (let* ((info (gnus-get-info group))
4669 (marked (gnus-info-marks info))
4670 (active (gnus-active group)))
4672 (gnus-set-difference
4673 (gnus-sorted-complement
4674 (gnus-uncompress-range active)
4675 (gnus-list-of-unread-articles group))
4677 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4678 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4680 ;; Various summary commands
4682 (defun gnus-summary-universal-argument (arg)
4683 "Perform any operation on all articles that are process/prefixed."
4685 (gnus-set-global-variables)
4686 (let ((articles (gnus-summary-work-articles arg))
4693 (substitute-command-keys
4694 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4697 (gnus-error 1 "Undefined key")
4700 (gnus-summary-goto-subject (setq article (pop articles)))
4701 (let (gnus-newsgroup-processable)
4702 (command-execute func))
4703 (gnus-summary-remove-process-mark article)))))
4704 (gnus-summary-position-point))
4706 (defun gnus-summary-toggle-truncation (&optional arg)
4707 "Toggle truncation of summary lines.
4708 With arg, turn line truncation on iff arg is positive."
4710 (setq truncate-lines
4711 (if (null arg) (not truncate-lines)
4712 (> (prefix-numeric-value arg) 0)))
4715 (defun gnus-summary-reselect-current-group (&optional all rescan)
4716 "Exit and then reselect the current newsgroup.
4717 The prefix argument ALL means to select all articles."
4719 (gnus-set-global-variables)
4720 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4721 (error "Ephemeral groups can't be reselected"))
4722 (let ((current-subject (gnus-summary-article-number))
4723 (group gnus-newsgroup-name))
4724 (setq gnus-newsgroup-begin nil)
4726 ;; We have to adjust the point of group mode buffer because
4727 ;; point was moved to the next unread newsgroup by exiting.
4728 (gnus-summary-jump-to-group group)
4731 (gnus-group-get-new-news-this-group 1)))
4732 (gnus-group-read-group all t)
4733 (gnus-summary-goto-subject current-subject nil t)))
4735 (defun gnus-summary-rescan-group (&optional all)
4736 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4738 (gnus-summary-reselect-current-group all t))
4740 (defun gnus-summary-update-info (&optional non-destructive)
4742 (let ((group gnus-newsgroup-name))
4743 (when gnus-newsgroup-kill-headers
4744 (setq gnus-newsgroup-killed
4745 (gnus-compress-sequence
4747 (gnus-set-sorted-intersection
4748 (gnus-uncompress-range gnus-newsgroup-killed)
4749 (setq gnus-newsgroup-unselected
4750 (sort gnus-newsgroup-unselected '<)))
4751 (setq gnus-newsgroup-unreads
4752 (sort gnus-newsgroup-unreads '<)))
4754 (unless (listp (cdr gnus-newsgroup-killed))
4755 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4756 (let ((headers gnus-newsgroup-headers))
4757 (when (and (not gnus-save-score)
4758 (not non-destructive))
4759 (setq gnus-newsgroup-scored nil))
4760 ;; Set the new ranges of read articles.
4761 (gnus-update-read-articles
4762 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4763 ;; Set the current article marks.
4765 ;; Do the cross-ref thing.
4766 (when gnus-use-cross-reference
4767 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4768 ;; Do adaptive scoring, and possibly save score files.
4769 (when gnus-newsgroup-adaptive
4770 (gnus-score-adaptive))
4771 (when gnus-use-scoring
4773 ;; Do not switch windows but change the buffer to work.
4774 (set-buffer gnus-group-buffer)
4775 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4776 (gnus-group-update-group group))))))
4778 (defun gnus-summary-save-newsrc (&optional force)
4779 "Save the current number of read/marked articles in the dribble buffer.
4780 The dribble buffer will then be saved.
4781 If FORCE (the prefix), also save the .newsrc file(s)."
4783 (gnus-summary-update-info t)
4785 (gnus-save-newsrc-file)
4786 (gnus-dribble-save)))
4788 (defun gnus-summary-exit (&optional temporary)
4789 "Exit reading current newsgroup, and then return to group selection mode.
4790 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4792 (gnus-set-global-variables)
4793 (gnus-kill-save-kill-buffer)
4794 (let* ((group gnus-newsgroup-name)
4795 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4797 (buf (current-buffer)))
4798 (run-hooks 'gnus-summary-prepare-exit-hook)
4799 ;; If we have several article buffers, we kill them at exit.
4800 (unless gnus-single-article-buffer
4801 (gnus-kill-buffer gnus-original-article-buffer)
4802 (setq gnus-article-current nil))
4803 (when gnus-use-cache
4804 (gnus-cache-possibly-remove-articles)
4805 (gnus-cache-save-buffers))
4806 (gnus-async-prefetch-remove-group group)
4807 (when gnus-suppress-duplicates
4808 (gnus-dup-enter-articles))
4809 (when gnus-use-trees
4810 (gnus-tree-close group))
4811 ;; Make all changes in this group permanent.
4813 (run-hooks 'gnus-exit-group-hook)
4814 (gnus-summary-update-info))
4815 (gnus-close-group group)
4816 ;; Make sure where I was, and go to next newsgroup.
4817 (set-buffer gnus-group-buffer)
4819 (gnus-group-jump-to-group group))
4820 (run-hooks 'gnus-summary-exit-hook)
4822 (gnus-group-next-unread-group 1))
4825 ;; If we have several article buffers, we kill them at exit.
4826 (unless gnus-single-article-buffer
4827 (gnus-kill-buffer gnus-article-buffer)
4828 (gnus-kill-buffer gnus-original-article-buffer)
4829 (setq gnus-article-current nil))
4831 (if (not gnus-kill-summary-on-exit)
4832 (gnus-deaden-summary)
4833 ;; We set all buffer-local variables to nil. It is unclear why
4834 ;; this is needed, but if we don't, buffer-local variables are
4835 ;; not garbage-collected, it seems. This would the lead to en
4836 ;; ever-growing Emacs.
4837 (gnus-summary-clear-local-variables)
4838 (when (get-buffer gnus-article-buffer)
4839 (bury-buffer gnus-article-buffer))
4840 ;; We clear the global counterparts of the buffer-local
4841 ;; variables as well, just to be on the safe side.
4842 (set-buffer gnus-group-buffer)
4843 (gnus-summary-clear-local-variables)
4844 ;; Return to group mode buffer.
4845 (when (eq mode 'gnus-summary-mode)
4846 (gnus-kill-buffer buf)))
4847 (setq gnus-current-select-method gnus-select-method)
4848 (pop-to-buffer gnus-group-buffer)
4849 ;; Clear the current group name.
4850 (if (not quit-config)
4852 (gnus-group-jump-to-group group)
4853 (gnus-group-next-unread-group 1)
4854 (gnus-configure-windows 'group 'force))
4855 (gnus-handle-ephemeral-exit quit-config))
4857 (setq gnus-newsgroup-name nil)))))
4859 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4860 (defun gnus-summary-exit-no-update (&optional no-questions)
4861 "Quit reading current newsgroup without updating read article info."
4863 (gnus-set-global-variables)
4864 (let* ((group gnus-newsgroup-name)
4865 (quit-config (gnus-group-quit-config group)))
4866 (when (or no-questions
4868 (gnus-y-or-n-p "Discard changes to this group and exit? "))
4869 ;; If we have several article buffers, we kill them at exit.
4870 (unless gnus-single-article-buffer
4871 (gnus-kill-buffer gnus-article-buffer)
4872 (gnus-kill-buffer gnus-original-article-buffer)
4873 (setq gnus-article-current nil))
4874 (if (not gnus-kill-summary-on-exit)
4875 (gnus-deaden-summary)
4876 (gnus-close-group group)
4877 (gnus-summary-clear-local-variables)
4878 (set-buffer gnus-group-buffer)
4879 (gnus-summary-clear-local-variables)
4880 (when (get-buffer gnus-summary-buffer)
4881 (kill-buffer gnus-summary-buffer)))
4882 (unless gnus-single-article-buffer
4883 (setq gnus-article-current nil))
4884 (when gnus-use-trees
4885 (gnus-tree-close group))
4886 (gnus-async-prefetch-remove-group group)
4887 (when (get-buffer gnus-article-buffer)
4888 (bury-buffer gnus-article-buffer))
4889 ;; Return to the group buffer.
4890 (gnus-configure-windows 'group 'force)
4891 ;; Clear the current group name.
4892 (setq gnus-newsgroup-name nil)
4893 (when (equal (gnus-group-group-name) group)
4894 (gnus-group-next-unread-group 1))
4896 (gnus-handle-ephemeral-exit quit-config)))))
4898 (defun gnus-handle-ephemeral-exit (quit-config)
4899 "Handle movement when leaving an ephemeral group. The state
4900 which existed when entering the ephemeral is reset."
4901 (if (not (buffer-name (car quit-config)))
4902 (gnus-configure-windows 'group 'force)
4903 (set-buffer (car quit-config))
4904 (cond ((eq major-mode 'gnus-summary-mode)
4905 (gnus-set-global-variables))
4906 ((eq major-mode 'gnus-article-mode)
4908 ;; The `gnus-summary-buffer' variable may point
4909 ;; to the old summary buffer when using a single
4911 (unless (gnus-buffer-live-p gnus-summary-buffer)
4912 (set-buffer gnus-group-buffer))
4913 (set-buffer gnus-summary-buffer)
4914 (gnus-set-global-variables))))
4915 (if (or (eq (cdr quit-config) 'article)
4916 (eq (cdr quit-config) 'pick))
4918 ;; The current article may be from the ephemeral group
4919 ;; thus it is best that we reload this article
4920 (gnus-summary-show-article)
4921 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4922 (gnus-configure-windows 'pick 'force)
4923 (gnus-configure-windows (cdr quit-config) 'force)))
4924 (gnus-configure-windows (cdr quit-config) 'force))
4925 (when (eq major-mode 'gnus-summary-mode)
4926 (gnus-summary-next-subject 1 nil t)
4927 (gnus-summary-recenter)
4928 (gnus-summary-position-point))))
4932 (defvar gnus-dead-summary-mode-map nil)
4934 (unless gnus-dead-summary-mode-map
4935 (setq gnus-dead-summary-mode-map (make-keymap))
4936 (suppress-keymap gnus-dead-summary-mode-map)
4937 (substitute-key-definition
4938 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4939 (let ((keys '("\C-d" "\r" "\177")))
4941 (define-key gnus-dead-summary-mode-map
4942 (pop keys) 'gnus-summary-wake-up-the-dead))))
4944 (defvar gnus-dead-summary-mode nil
4945 "Minor mode for Gnus summary buffers.")
4947 (defun gnus-dead-summary-mode (&optional arg)
4948 "Minor mode for Gnus summary buffers."
4950 (when (eq major-mode 'gnus-summary-mode)
4951 (make-local-variable 'gnus-dead-summary-mode)
4952 (setq gnus-dead-summary-mode
4953 (if (null arg) (not gnus-dead-summary-mode)
4954 (> (prefix-numeric-value arg) 0)))
4955 (when gnus-dead-summary-mode
4956 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4957 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4958 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4959 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4960 minor-mode-map-alist)))))
4962 (defun gnus-deaden-summary ()
4963 "Make the current summary buffer into a dead summary buffer."
4964 ;; Kill any previous dead summary buffer.
4965 (when (and gnus-dead-summary
4966 (buffer-name gnus-dead-summary))
4968 (set-buffer gnus-dead-summary)
4969 (when gnus-dead-summary-mode
4970 (kill-buffer (current-buffer)))))
4971 ;; Make this the current dead summary.
4972 (setq gnus-dead-summary (current-buffer))
4973 (gnus-dead-summary-mode 1)
4974 (let ((name (buffer-name)))
4975 (when (string-match "Summary" name)
4977 (concat (substring name 0 (match-beginning 0)) "Dead "
4978 (substring name (match-beginning 0)))
4981 (defun gnus-kill-or-deaden-summary (buffer)
4982 "Kill or deaden the summary BUFFER."
4983 (when (and (buffer-name buffer)
4984 (not gnus-single-article-buffer))
4987 (gnus-kill-buffer gnus-article-buffer)
4988 (gnus-kill-buffer gnus-original-article-buffer)))
4989 (cond (gnus-kill-summary-on-exit
4990 (when (and gnus-use-trees
4991 (and (get-buffer buffer)
4992 (buffer-name (get-buffer buffer))))
4994 (set-buffer (get-buffer buffer))
4995 (gnus-tree-close gnus-newsgroup-name)))
4996 (gnus-kill-buffer buffer))
4997 ((and (get-buffer buffer)
4998 (buffer-name (get-buffer buffer)))
5001 (gnus-deaden-summary)))))
5003 (defun gnus-summary-wake-up-the-dead (&rest args)
5004 "Wake up the dead summary buffer."
5006 (gnus-dead-summary-mode -1)
5007 (let ((name (buffer-name)))
5008 (when (string-match "Dead " name)
5010 (concat (substring name 0 (match-beginning 0))
5011 (substring name (match-end 0)))
5013 (gnus-message 3 "This dead summary is now alive again"))
5015 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5016 (defun gnus-summary-fetch-faq (&optional faq-dir)
5017 "Fetch the FAQ for the current group.
5018 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5022 (when current-prefix-arg
5024 "Faq dir: " (and (listp gnus-group-faq-directory)
5025 gnus-group-faq-directory)))))
5026 (let (gnus-faq-buffer)
5027 (when (setq gnus-faq-buffer
5028 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5029 (gnus-configure-windows 'summary-faq))))
5031 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5032 (defun gnus-summary-describe-group (&optional force)
5033 "Describe the current newsgroup."
5035 (gnus-group-describe-group force gnus-newsgroup-name))
5037 (defun gnus-summary-describe-briefly ()
5038 "Describe summary mode commands briefly."
5041 (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")))
5043 ;; Walking around group mode buffer from summary mode.
5045 (defun gnus-summary-next-group (&optional no-article target-group backward)
5046 "Exit current newsgroup and then select next unread newsgroup.
5047 If prefix argument NO-ARTICLE is non-nil, no article is selected
5048 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5049 previous group instead."
5051 (gnus-set-global-variables)
5052 ;; Stop pre-fetching.
5053 (gnus-async-halt-prefetch)
5054 (let ((current-group gnus-newsgroup-name)
5055 (current-buffer (current-buffer))
5057 ;; First we semi-exit this group to update Xrefs and all variables.
5058 ;; We can't do a real exit, because the window conf must remain
5059 ;; the same in case the user is prompted for info, and we don't
5060 ;; want the window conf to change before that...
5061 (gnus-summary-exit t)
5062 (while (not entered)
5063 ;; Then we find what group we are supposed to enter.
5064 (set-buffer gnus-group-buffer)
5065 (gnus-group-jump-to-group current-group)
5068 (if (eq gnus-keep-same-level 'best)
5069 (gnus-summary-best-group gnus-newsgroup-name)
5070 (gnus-summary-search-group backward gnus-keep-same-level))))
5071 (if (not target-group)
5072 ;; There are no further groups, so we return to the group
5075 (gnus-message 5 "Returning to the group buffer")
5077 (set-buffer current-buffer)
5079 (run-hooks 'gnus-group-no-more-groups-hook))
5080 ;; We try to enter the target group.
5081 (gnus-group-jump-to-group target-group)
5082 (let ((unreads (gnus-group-group-unread)))
5083 (if (and (or (eq t unreads)
5084 (and unreads (not (zerop unreads))))
5085 (gnus-summary-read-group
5086 target-group nil no-article current-buffer))
5088 (setq current-group target-group
5089 target-group nil)))))))
5091 (defun gnus-summary-prev-group (&optional no-article)
5092 "Exit current newsgroup and then select previous unread newsgroup.
5093 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5095 (gnus-summary-next-group no-article nil t))
5097 ;; Walking around summary lines.
5099 (defun gnus-summary-first-subject (&optional unread)
5100 "Go to the first unread subject.
5101 If UNREAD is non-nil, go to the first unread article.
5102 Returns the article selected or nil if there are no unread articles."
5107 ((null gnus-newsgroup-data)
5108 (gnus-message 3 "No articles in the group")
5110 ;; Pick the first article.
5112 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5113 (gnus-data-number (car gnus-newsgroup-data)))
5114 ;; No unread articles.
5115 ((null gnus-newsgroup-unreads)
5116 (gnus-message 3 "No more unread articles")
5118 ;; Find the first unread article.
5120 (let ((data gnus-newsgroup-data))
5122 (not (gnus-data-unread-p (car data))))
5123 (setq data (cdr data)))
5125 (goto-char (gnus-data-pos (car data)))
5126 (gnus-data-number (car data))))))
5127 (gnus-summary-position-point)))
5129 (defun gnus-summary-next-subject (n &optional unread dont-display)
5130 "Go to next N'th summary line.
5131 If N is negative, go to the previous N'th subject line.
5132 If UNREAD is non-nil, only unread articles are selected.
5133 The difference between N and the actual number of steps taken is
5136 (let ((backward (< n 0))
5140 (gnus-summary-find-prev unread)
5141 (gnus-summary-find-next unread)))
5144 (gnus-message 7 "No more%s articles"
5145 (if unread " unread" "")))
5146 (unless dont-display
5147 (gnus-summary-recenter)
5148 (gnus-summary-position-point))
5151 (defun gnus-summary-next-unread-subject (n)
5152 "Go to next N'th unread summary line."
5154 (gnus-summary-next-subject n t))
5156 (defun gnus-summary-prev-subject (n &optional unread)
5157 "Go to previous N'th summary line.
5158 If optional argument UNREAD is non-nil, only unread article is selected."
5160 (gnus-summary-next-subject (- n) unread))
5162 (defun gnus-summary-prev-unread-subject (n)
5163 "Go to previous N'th unread summary line."
5165 (gnus-summary-next-subject (- n) t))
5167 (defun gnus-summary-goto-subject (article &optional force silent)
5168 "Go the subject line of ARTICLE.
5169 If FORCE, also allow jumping to articles not currently shown."
5170 (interactive "nArticle number: ")
5172 (data (gnus-data-find article)))
5173 ;; We read in the article if we have to.
5176 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5177 (setq data (gnus-data-find article)))
5182 (gnus-message 3 "Can't find article %d" article))
5184 (goto-char (gnus-data-pos data))
5187 ;; Walking around summary lines with displaying articles.
5189 (defun gnus-summary-expand-window (&optional arg)
5190 "Make the summary buffer take up the entire Emacs frame.
5191 Given a prefix, will force an `article' buffer configuration."
5193 (gnus-set-global-variables)
5195 (gnus-configure-windows 'article 'force)
5196 (gnus-configure-windows 'summary 'force)))
5198 (defun gnus-summary-display-article (article &optional all-header)
5199 "Display ARTICLE in article buffer."
5200 (gnus-set-global-variables)
5204 (if gnus-summary-display-article-function
5205 (funcall gnus-summary-display-article-function article all-header)
5206 (gnus-article-prepare article all-header))
5207 (run-hooks 'gnus-select-article-hook)
5208 (when (and gnus-current-article
5209 (not (zerop gnus-current-article)))
5210 (gnus-summary-goto-subject gnus-current-article))
5211 (gnus-summary-recenter)
5212 (when (and gnus-use-trees gnus-show-threads)
5213 (gnus-possibly-generate-tree article)
5214 (gnus-highlight-selected-tree article))
5215 ;; Successfully display article.
5216 (gnus-article-set-window-start
5217 (cdr (assq article gnus-newsgroup-bookmarks))))))
5219 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5220 "Select the current article.
5221 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5222 non-nil, the article will be re-fetched even if it already present in
5223 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5225 ;; Make sure we are in the summary buffer to work around bbdb bug.
5226 (unless (eq major-mode 'gnus-summary-mode)
5227 (set-buffer gnus-summary-buffer))
5228 (let ((article (or article (gnus-summary-article-number)))
5229 (all-headers (not (not all-headers))) ;Must be T or NIL.
5230 gnus-summary-display-article-function
5233 (gnus-summary-article-pseudo-p article)
5234 (error "This is a pseudo-article."))
5237 (set-buffer gnus-summary-buffer)
5238 (if (or (and gnus-single-article-buffer
5239 (or (null gnus-current-article)
5240 (null gnus-article-current)
5241 (null (get-buffer gnus-article-buffer))
5242 (not (eq article (cdr gnus-article-current)))
5243 (not (equal (car gnus-article-current)
5244 gnus-newsgroup-name))))
5245 (and (not gnus-single-article-buffer)
5246 (or (null gnus-current-article)
5247 (not (eq gnus-current-article article))))
5249 ;; The requested article is different from the current article.
5251 (gnus-summary-display-article article all-headers)
5253 (when (or all-headers gnus-show-all-headers)
5254 (gnus-article-show-all-headers))
5257 (gnus-article-set-window-start
5258 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5260 (defun gnus-summary-set-current-mark (&optional current-mark)
5261 "Obsolete function."
5264 (defun gnus-summary-next-article (&optional unread subject backward push)
5265 "Select the next article.
5266 If UNREAD, only unread articles are selected.
5267 If SUBJECT, only articles with SUBJECT are selected.
5268 If BACKWARD, the previous article is selected instead of the next."
5270 (gnus-set-global-variables)
5272 ;; Is there such an article?
5273 ((and (gnus-summary-search-forward unread subject backward)
5274 (or (gnus-summary-display-article (gnus-summary-article-number))
5275 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5276 (gnus-summary-position-point))
5277 ;; If not, we try the first unread, if that is wanted.
5279 gnus-auto-select-same
5280 (gnus-summary-first-unread-article))
5281 (gnus-summary-position-point)
5282 (gnus-message 6 "Wrapped"))
5283 ;; Try to get next/previous article not displayed in this group.
5284 ((and gnus-auto-extend-newsgroup
5285 (not unread) (not subject))
5286 (gnus-summary-goto-article
5287 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5289 ;; Go to next/previous group.
5291 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5292 (gnus-summary-jump-to-group gnus-newsgroup-name))
5293 (let ((cmd last-command-char)
5296 (set-buffer gnus-group-buffer)
5299 (if (eq gnus-keep-same-level 'best)
5300 (gnus-summary-best-group gnus-newsgroup-name)
5301 (gnus-summary-search-group backward gnus-keep-same-level))))
5302 ;; For some reason, the group window gets selected. We change
5304 (select-window (get-buffer-window (current-buffer)))
5305 ;; Select next unread newsgroup automagically.
5307 ((or (not gnus-auto-select-next)
5309 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5310 ((or (eq gnus-auto-select-next 'quietly)
5311 (and (eq gnus-auto-select-next 'slightly-quietly)
5313 (and (eq gnus-auto-select-next 'almost-quietly)
5314 (gnus-summary-last-article-p)))
5316 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5318 (gnus-message 7 "No more%s articles (%s)..."
5319 (if unread " unread" "")
5320 (if group (concat "selecting " group)
5322 (gnus-summary-next-group nil group backward)))
5324 (when (gnus-key-press-event-p last-input-event)
5325 (gnus-summary-walk-group-buffer
5326 gnus-newsgroup-name cmd unread backward point))))))))
5328 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5329 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5330 (?\C-p (gnus-group-prev-unread-group 1))))
5331 (cursor-in-echo-area t)
5332 keve key group ended)
5334 (set-buffer gnus-group-buffer)
5337 (if (eq gnus-keep-same-level 'best)
5338 (gnus-summary-best-group gnus-newsgroup-name)
5339 (gnus-summary-search-group backward gnus-keep-same-level))))
5342 5 "No more%s articles%s" (if unread " unread" "")
5344 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5345 (format " (Type %s for %s [%s])"
5346 (single-key-description cmd) group
5347 (car (gnus-gethash group gnus-newsrc-hashtb)))
5348 (format " (Type %s to exit %s)"
5349 (single-key-description cmd)
5350 gnus-newsgroup-name)))
5351 ;; Confirm auto selection.
5352 (setq key (car (setq keve (gnus-read-event-char))))
5355 ((assq key keystrokes)
5356 (let ((obuf (current-buffer)))
5357 (switch-to-buffer gnus-group-buffer)
5359 (gnus-group-jump-to-group group))
5360 (eval (cadr (assq key keystrokes)))
5361 (setq group (gnus-group-group-name))
5362 (switch-to-buffer obuf))
5366 (gnus-ephemeral-group-p gnus-newsgroup-name))
5368 (gnus-summary-next-group nil group backward)))
5370 (push (cdr keve) unread-command-events))))))
5372 (defun gnus-summary-next-unread-article ()
5373 "Select unread article after current one."
5375 (gnus-summary-next-article
5376 (or (not (eq gnus-summary-goto-unread 'never))
5377 (gnus-summary-last-article-p (gnus-summary-article-number)))
5378 (and gnus-auto-select-same
5379 (gnus-summary-article-subject))))
5381 (defun gnus-summary-prev-article (&optional unread subject)
5382 "Select the article after the current one.
5383 If UNREAD is non-nil, only unread articles are selected."
5385 (gnus-summary-next-article unread subject t))
5387 (defun gnus-summary-prev-unread-article ()
5388 "Select unread article before current one."
5390 (gnus-summary-prev-article
5391 (or (not (eq gnus-summary-goto-unread 'never))
5392 (gnus-summary-first-article-p (gnus-summary-article-number)))
5393 (and gnus-auto-select-same
5394 (gnus-summary-article-subject))))
5396 (defun gnus-summary-next-page (&optional lines circular)
5397 "Show next page of the selected article.
5398 If at the end of the current article, select the next article.
5399 LINES says how many lines should be scrolled up.
5401 If CIRCULAR is non-nil, go to the start of the article instead of
5402 selecting the next article when reaching the end of the current
5405 (setq gnus-summary-buffer (current-buffer))
5406 (gnus-set-global-variables)
5407 (let ((article (gnus-summary-article-number))
5408 (article-window (get-buffer-window gnus-article-buffer t))
5410 (gnus-configure-windows 'article)
5411 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
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 (if (or (null gnus-current-article)
5417 (null gnus-article-current)
5418 (/= article (cdr gnus-article-current))
5419 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5420 ;; Selected subject is different from current article's.
5421 (gnus-summary-display-article article)
5422 (when article-window
5423 (gnus-eval-in-buffer-window gnus-article-buffer
5424 (setq endp (gnus-article-next-page lines)))
5427 (gnus-summary-beginning-of-article))
5429 (gnus-message 3 "End of message"))
5431 (if (and (eq gnus-summary-goto-unread 'never)
5432 (not (gnus-summary-last-article-p article)))
5433 (gnus-summary-next-article)
5434 (gnus-summary-next-unread-article))))))))
5435 (gnus-summary-recenter)
5436 (gnus-summary-position-point)))
5438 (defun gnus-summary-prev-page (&optional lines move)
5439 "Show previous page of selected article.
5440 Argument LINES specifies lines to be scrolled down.
5441 If MOVE, move to the previous unread article if point is at
5442 the beginning of the buffer."
5444 (gnus-set-global-variables)
5445 (let ((article (gnus-summary-article-number))
5446 (article-window (get-buffer-window gnus-article-buffer t))
5448 (gnus-configure-windows 'article)
5449 (if (or (null gnus-current-article)
5450 (null gnus-article-current)
5451 (/= article (cdr gnus-article-current))
5452 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5453 ;; Selected subject is different from current article's.
5454 (gnus-summary-display-article article)
5455 (gnus-summary-recenter)
5456 (when article-window
5457 (gnus-eval-in-buffer-window gnus-article-buffer
5458 (setq endp (gnus-article-prev-page lines)))
5459 (when (and move endp)
5461 (gnus-message 3 "Beginning of message"))
5463 (if (and (eq gnus-summary-goto-unread 'never)
5464 (not (gnus-summary-first-article-p article)))
5465 (gnus-summary-prev-article)
5466 (gnus-summary-prev-unread-article))))))))
5467 (gnus-summary-position-point))
5469 (defun gnus-summary-prev-page-or-article (&optional lines)
5470 "Show previous page of selected article.
5471 Argument LINES specifies lines to be scrolled down.
5472 If at the beginning of the article, go to the next article."
5474 (gnus-summary-prev-page lines t))
5476 (defun gnus-summary-scroll-up (lines)
5477 "Scroll up (or down) one line current article.
5478 Argument LINES specifies lines to be scrolled up (or down if negative)."
5480 (gnus-set-global-variables)
5481 (gnus-configure-windows 'article)
5482 (gnus-summary-show-thread)
5483 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5484 (gnus-eval-in-buffer-window gnus-article-buffer
5486 (when (gnus-article-next-page lines)
5487 (gnus-message 3 "End of message")))
5489 (gnus-article-prev-page (- lines))))))
5490 (gnus-summary-recenter)
5491 (gnus-summary-position-point))
5493 (defun gnus-summary-next-same-subject ()
5494 "Select next article which has the same subject as current one."
5496 (gnus-set-global-variables)
5497 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5499 (defun gnus-summary-prev-same-subject ()
5500 "Select previous article which has the same subject as current one."
5502 (gnus-set-global-variables)
5503 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5505 (defun gnus-summary-next-unread-same-subject ()
5506 "Select next unread article which has the same subject as current one."
5508 (gnus-set-global-variables)
5509 (gnus-summary-next-article t (gnus-summary-article-subject)))
5511 (defun gnus-summary-prev-unread-same-subject ()
5512 "Select previous unread article which has the same subject as current one."
5514 (gnus-set-global-variables)
5515 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5517 (defun gnus-summary-first-unread-article ()
5518 "Select the first unread article.
5519 Return nil if there are no unread articles."
5521 (gnus-set-global-variables)
5523 (when (gnus-summary-first-subject t)
5524 (gnus-summary-show-thread)
5525 (gnus-summary-first-subject t)
5526 (gnus-summary-display-article (gnus-summary-article-number)))
5527 (gnus-summary-position-point)))
5529 (defun gnus-summary-first-article ()
5530 "Select the first article.
5531 Return nil if there are no articles."
5533 (gnus-set-global-variables)
5535 (when (gnus-summary-first-subject)
5536 (gnus-summary-show-thread)
5537 (gnus-summary-first-subject)
5538 (gnus-summary-display-article (gnus-summary-article-number)))
5539 (gnus-summary-position-point)))
5541 (defun gnus-summary-best-unread-article ()
5542 "Select the unread article with the highest score."
5544 (gnus-set-global-variables)
5545 (let ((best -1000000)
5546 (data gnus-newsgroup-data)
5549 (and (gnus-data-unread-p (car data))
5551 (gnus-summary-article-score (gnus-data-number (car data))))
5554 article (gnus-data-number (car data))))
5555 (setq data (cdr data)))
5558 (gnus-summary-goto-article article)
5559 (error "No unread articles"))
5560 (gnus-summary-position-point))))
5562 (defun gnus-summary-last-subject ()
5563 "Go to the last displayed subject line in the group."
5564 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5566 (gnus-summary-goto-subject article))))
5568 (defun gnus-summary-goto-article (article &optional all-headers force)
5569 "Fetch ARTICLE and display it if it exists.
5570 If ALL-HEADERS is non-nil, no header lines are hidden."
5576 (mapcar (lambda (number) (list (int-to-string number)))
5577 gnus-newsgroup-limit)))
5581 (if (gnus-summary-goto-subject article force)
5582 (gnus-summary-display-article article all-headers)
5583 (gnus-message 4 "Couldn't go to article %s" article) nil)
5584 (gnus-summary-position-point)))
5586 (defun gnus-summary-goto-last-article ()
5587 "Go to the previously read article."
5590 (when gnus-last-article
5591 (gnus-summary-goto-article gnus-last-article))
5592 (gnus-summary-position-point)))
5594 (defun gnus-summary-pop-article (number)
5595 "Pop one article off the history and go to the previous.
5596 NUMBER articles will be popped off."
5599 (setq gnus-newsgroup-history
5600 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5602 (gnus-summary-goto-article (car to))
5603 (error "Article history empty")))
5604 (gnus-summary-position-point))
5606 ;; Summary commands and functions for limiting the summary buffer.
5608 (defun gnus-summary-limit-to-articles (n)
5609 "Limit the summary buffer to the next N articles.
5610 If not given a prefix, use the process marked articles instead."
5612 (gnus-set-global-variables)
5614 (let ((articles (gnus-summary-work-articles n)))
5615 (setq gnus-newsgroup-processable nil)
5616 (gnus-summary-limit articles))
5617 (gnus-summary-position-point)))
5619 (defun gnus-summary-pop-limit (&optional total)
5620 "Restore the previous limit.
5621 If given a prefix, remove all limits."
5623 (gnus-set-global-variables)
5625 (setq gnus-newsgroup-limits
5626 (list (mapcar (lambda (h) (mail-header-number h))
5627 gnus-newsgroup-headers))))
5628 (unless gnus-newsgroup-limits
5629 (error "No limit to pop"))
5631 (gnus-summary-limit nil 'pop)
5632 (gnus-summary-position-point)))
5634 (defun gnus-summary-limit-to-subject (subject &optional header)
5635 "Limit the summary buffer to articles that have subjects that match a regexp."
5636 (interactive "sLimit to subject (regexp): ")
5638 (setq header "subject"))
5639 (when (not (equal "" subject))
5641 (let ((articles (gnus-summary-find-matching
5642 (or header "subject") subject 'all)))
5644 (error "Found no matches for \"%s\"" subject))
5645 (gnus-summary-limit articles))
5646 (gnus-summary-position-point))))
5648 (defun gnus-summary-limit-to-author (from)
5649 "Limit the summary buffer to articles that have authors that match a regexp."
5650 (interactive "sLimit to author (regexp): ")
5651 (gnus-summary-limit-to-subject from "from"))
5653 (defun gnus-summary-limit-to-age (age &optional younger-p)
5654 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5655 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5656 articles that are younger than AGE days."
5657 (interactive "nTime in days: \nP")
5659 (let ((data gnus-newsgroup-data)
5660 (cutoff (nnmail-days-to-time age))
5661 articles d date is-younger)
5662 (while (setq d (pop data))
5663 (when (and (vectorp (gnus-data-header d))
5664 (setq date (mail-header-date (gnus-data-header d))))
5665 (setq is-younger (nnmail-time-less
5666 (nnmail-time-since (nnmail-date-to-time date))
5668 (when (if younger-p is-younger (not is-younger))
5669 (push (gnus-data-number d) articles))))
5670 (gnus-summary-limit (nreverse articles)))
5671 (gnus-summary-position-point)))
5673 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5675 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5677 (defun gnus-summary-limit-to-unread (&optional all)
5678 "Limit the summary buffer to articles that are not marked as read.
5679 If ALL is non-nil, limit strictly to unread articles."
5682 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5683 (gnus-summary-limit-to-marks
5684 ;; Concat all the marks that say that an article is read and have
5686 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5687 gnus-killed-mark gnus-kill-file-mark
5688 gnus-low-score-mark gnus-expirable-mark
5689 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5690 gnus-duplicate-mark gnus-souped-mark)
5693 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5694 (make-obsolete 'gnus-summary-delete-marked-with
5695 'gnus-summary-limit-exlude-marks)
5697 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5698 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5699 If REVERSE, limit the summary buffer to articles that are marked
5700 with MARKS. MARKS can either be a string of marks or a list of marks.
5701 Returns how many articles were removed."
5702 (interactive "sMarks: ")
5703 (gnus-summary-limit-to-marks marks t))
5705 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5706 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5707 If REVERSE (the prefix), limit the summary buffer to articles that are
5708 not marked with MARKS. MARKS can either be a string of marks or a
5710 Returns how many articles were removed."
5711 (interactive (list (read-string "Marks: ") current-prefix-arg))
5712 (gnus-set-global-variables)
5714 (let ((data gnus-newsgroup-data)
5715 (marks (if (listp marks) marks
5716 (append marks nil))) ; Transform to list.
5719 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5720 (memq (gnus-data-mark (car data)) marks))
5721 (push (gnus-data-number (car data)) articles))
5722 (setq data (cdr data)))
5723 (gnus-summary-limit articles))
5724 (gnus-summary-position-point)))
5726 (defun gnus-summary-limit-to-score (&optional score)
5727 "Limit to articles with score at or above SCORE."
5729 (gnus-set-global-variables)
5730 (setq score (if score
5731 (prefix-numeric-value score)
5732 (or gnus-summary-default-score 0)))
5733 (let ((data gnus-newsgroup-data)
5736 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5738 (push (gnus-data-number (car data)) articles))
5739 (setq data (cdr data)))
5741 (gnus-summary-limit articles)
5742 (gnus-summary-position-point))))
5744 (defun gnus-summary-limit-include-dormant ()
5745 "Display all the hidden articles that are marked as dormant."
5747 (gnus-set-global-variables)
5748 (unless gnus-newsgroup-dormant
5749 (error "There are no dormant articles in this group"))
5751 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5752 (gnus-summary-position-point)))
5754 (defun gnus-summary-limit-exclude-dormant ()
5755 "Hide all dormant articles."
5757 (gnus-set-global-variables)
5759 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5760 (gnus-summary-position-point)))
5762 (defun gnus-summary-limit-exclude-childless-dormant ()
5763 "Hide all dormant articles that have no children."
5765 (gnus-set-global-variables)
5766 (let ((data (gnus-data-list t))
5767 articles d children)
5768 ;; Find all articles that are either not dormant or have
5770 (while (setq d (pop data))
5771 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5773 (gnus-article-children (gnus-data-number d)))
5776 (when (memq (car children) articles)
5781 (push (gnus-data-number d) articles)))
5784 (gnus-summary-limit articles)
5785 (gnus-summary-position-point))))
5787 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5788 "Mark all unread excluded articles as read.
5789 If ALL, mark even excluded ticked and dormants as read."
5791 (let ((articles (gnus-sorted-complement
5793 (mapcar (lambda (h) (mail-header-number h))
5794 gnus-newsgroup-headers)
5796 (sort gnus-newsgroup-limit '<)))
5798 (setq gnus-newsgroup-unreads nil)
5800 (setq gnus-newsgroup-dormant nil
5801 gnus-newsgroup-marked nil
5802 gnus-newsgroup-reads
5804 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5805 gnus-newsgroup-reads))
5806 (while (setq article (pop articles))
5807 (unless (or (memq article gnus-newsgroup-dormant)
5808 (memq article gnus-newsgroup-marked))
5809 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5811 (defun gnus-summary-limit (articles &optional pop)
5813 ;; We pop the previous limit off the stack and use that.
5814 (setq articles (car gnus-newsgroup-limits)
5815 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5816 ;; We use the new limit, so we push the old limit on the stack.
5817 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5819 (setq gnus-newsgroup-limit articles)
5820 (let ((total (length gnus-newsgroup-data))
5821 (data (gnus-data-find-list (gnus-summary-article-number)))
5822 (gnus-summary-mark-below nil) ; Inhibit this.
5824 ;; This will do all the work of generating the new summary buffer
5825 ;; according to the new limit.
5826 (gnus-summary-prepare)
5827 ;; Hide any threads, possibly.
5828 (and gnus-show-threads
5829 gnus-thread-hide-subtree
5830 (gnus-summary-hide-all-threads))
5831 ;; Try to return to the article you were at, or one in the
5834 ;; We try to find some article after the current one.
5836 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5839 (setq data (cdr data))))
5841 ;; If there is no data, that means that we were after the last
5842 ;; article. The same goes when we can't find any articles
5843 ;; after the current one.
5844 (goto-char (point-max))
5845 (gnus-summary-find-prev))
5846 ;; We return how many articles were removed from the summary
5847 ;; buffer as a result of the new limit.
5848 (- total (length gnus-newsgroup-data))))
5850 (defsubst gnus-invisible-cut-children (threads)
5853 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5858 (defsubst gnus-cut-thread (thread)
5859 "Go forwards in the thread until we find an article that we want to display."
5860 (when (or (eq gnus-fetch-old-headers 'some)
5861 (eq gnus-build-sparse-threads 'some)
5862 (eq gnus-build-sparse-threads 'more))
5863 ;; Deal with old-fetched headers and sparse threads.
5867 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
5868 (gnus-summary-article-ancient-p
5869 (mail-header-number (car thread))))
5871 (if (<= (length (cdr thread)) 1)
5872 (setq thread (cadr thread))
5873 (when (gnus-invisible-cut-children (cdr thread))
5874 (let ((th (cdr thread)))
5876 (if (memq (mail-header-number (caar th))
5877 gnus-newsgroup-limit)
5878 (setq thread (car th)
5880 (setq th (cdr th)))))))))
5884 (defun gnus-cut-threads (threads)
5885 "Cut off all uninteresting articles from the beginning of threads."
5886 (when (or (eq gnus-fetch-old-headers 'some)
5887 (eq gnus-build-sparse-threads 'some)
5888 (eq gnus-build-sparse-threads 'more))
5891 (setcar th (gnus-cut-thread (car th)))
5892 (setq th (cdr th)))))
5893 ;; Remove nixed out threads.
5896 (defun gnus-summary-initial-limit (&optional show-if-empty)
5897 "Figure out what the initial limit is supposed to be on group entry.
5898 This entails weeding out unwanted dormants, low-scored articles,
5899 fetch-old-headers verbiage, and so on."
5900 ;; Most groups have nothing to remove.
5901 (if (or gnus-inhibit-limiting
5902 (and (null gnus-newsgroup-dormant)
5903 (not (eq gnus-fetch-old-headers 'some))
5904 (null gnus-summary-expunge-below)
5905 (not (eq gnus-build-sparse-threads 'some))
5906 (not (eq gnus-build-sparse-threads 'more))
5907 (null gnus-thread-expunge-below)
5908 (not gnus-use-nocem)))
5910 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5911 (setq gnus-newsgroup-limit nil)
5914 (unless (car (symbol-value node))
5915 ;; These threads have no parents -- they are roots.
5916 (let ((nodes (cdr (symbol-value node)))
5919 (if (and gnus-thread-expunge-below
5920 (< (gnus-thread-total-score (car nodes))
5921 gnus-thread-expunge-below))
5922 (gnus-expunge-thread (pop nodes))
5923 (setq thread (pop nodes))
5924 (gnus-summary-limit-children thread))))))
5925 gnus-newsgroup-dependencies)
5926 ;; If this limitation resulted in an empty group, we might
5927 ;; pop the previous limit and use it instead.
5928 (when (and (not gnus-newsgroup-limit)
5930 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5931 gnus-newsgroup-limit))
5933 (defun gnus-summary-limit-children (thread)
5934 "Return 1 if this subthread is visible and 0 if it is not."
5935 ;; First we get the number of visible children to this thread. This
5936 ;; is done by recursing down the thread using this function, so this
5937 ;; will really go down to a leaf article first, before slowly
5938 ;; working its way up towards the root.
5942 (apply '+ (mapcar 'gnus-summary-limit-children
5945 (number (mail-header-number (car thread)))
5948 (not (memq number gnus-newsgroup-marked))
5950 ;; If this article is dormant and has absolutely no visible
5951 ;; children, then this article isn't visible.
5952 (and (memq number gnus-newsgroup-dormant)
5954 ;; If this is "fetch-old-headered" and there is no
5955 ;; visible children, then we don't want this article.
5956 (and (eq gnus-fetch-old-headers 'some)
5957 (gnus-summary-article-ancient-p number)
5959 ;; If this is a sparsely inserted article with no children,
5960 ;; we don't want it.
5961 (and (eq gnus-build-sparse-threads 'some)
5962 (gnus-summary-article-sparse-p number)
5964 ;; If we use expunging, and this article is really
5965 ;; low-scored, then we don't want this article.
5966 (when (and gnus-summary-expunge-below
5968 (or (cdr (assq number gnus-newsgroup-scored))
5969 gnus-summary-default-score))
5970 gnus-summary-expunge-below))
5971 ;; We increase the expunge-tally here, but that has
5972 ;; nothing to do with the limits, really.
5973 (incf gnus-newsgroup-expunged-tally)
5974 ;; We also mark as read here, if that's wanted.
5975 (when (and gnus-summary-mark-below
5976 (< score gnus-summary-mark-below))
5977 (setq gnus-newsgroup-unreads
5978 (delq number gnus-newsgroup-unreads))
5979 (if gnus-newsgroup-auto-expire
5980 (push number gnus-newsgroup-expirable)
5981 (push (cons number gnus-low-score-mark)
5982 gnus-newsgroup-reads)))
5984 ;; Check NoCeM things.
5985 (if (and gnus-use-nocem
5986 (gnus-nocem-unwanted-article-p
5987 (mail-header-id (car thread))))
5989 (setq gnus-newsgroup-reads
5990 (delq number gnus-newsgroup-unreads))
5992 ;; Nope, invisible article.
5994 ;; Ok, this article is to be visible, so we add it to the limit
5996 (push number gnus-newsgroup-limit)
5999 (defun gnus-expunge-thread (thread)
6000 "Mark all articles in THREAD as read."
6001 (let* ((number (mail-header-number (car thread))))
6002 (incf gnus-newsgroup-expunged-tally)
6003 ;; We also mark as read here, if that's wanted.
6004 (setq gnus-newsgroup-unreads
6005 (delq number gnus-newsgroup-unreads))
6006 (if gnus-newsgroup-auto-expire
6007 (push number gnus-newsgroup-expirable)
6008 (push (cons number gnus-low-score-mark)
6009 gnus-newsgroup-reads)))
6010 ;; Go recursively through all subthreads.
6011 (mapcar 'gnus-expunge-thread (cdr thread)))
6013 ;; Summary article oriented commands
6015 (defun gnus-summary-refer-parent-article (n)
6016 "Refer parent article N times.
6017 If N is negative, go to ancestor -N instead.
6018 The difference between N and the number of articles fetched is returned."
6020 (gnus-set-global-variables)
6023 (when (not (natnump n))
6028 (setq header (gnus-summary-article-header))
6029 (if (and (eq (mail-header-number header)
6030 (cdr gnus-article-current))
6031 (equal gnus-newsgroup-name
6032 (car gnus-article-current)))
6033 ;; If we try to find the parent of the currently
6034 ;; displayed article, then we take a look at the actual
6035 ;; References header, since this is slightly more
6036 ;; reliable than the References field we got from the
6039 (set-buffer gnus-original-article-buffer)
6040 (nnheader-narrow-to-headers)
6041 (unless (setq ref (message-fetch-field "references"))
6042 (setq ref (message-fetch-field "in-reply-to")))
6045 ;; It's not the current article, so we take a bet on
6046 ;; the value we got from the server.
6047 (mail-header-references header)))
6049 (not (equal ref "")))
6050 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6051 (gnus-message 1 "Couldn't find parent"))
6052 (gnus-message 1 "No references in article %d"
6053 (gnus-summary-article-number))
6056 (gnus-summary-position-point)
6059 (defun gnus-summary-refer-references ()
6060 "Fetch all articles mentioned in the References header.
6061 Return how many articles were fetched."
6063 (gnus-set-global-variables)
6064 (let ((ref (mail-header-references (gnus-summary-article-header)))
6065 (current (gnus-summary-article-number))
6069 (error "No References in the current article")
6070 ;; For each Message-ID in the References header...
6071 (while (string-match "<[^>]*>" ref)
6073 ;; ... fetch that article.
6074 (gnus-summary-refer-article
6075 (prog1 (match-string 0 ref)
6076 (setq ref (substring ref (match-end 0))))))
6077 (gnus-summary-goto-subject current)
6078 (gnus-summary-position-point)
6081 (defun gnus-summary-refer-article (message-id)
6082 "Fetch an article specified by MESSAGE-ID."
6083 (interactive "sMessage-ID: ")
6084 (when (and (stringp message-id)
6085 (not (zerop (length message-id))))
6086 ;; Construct the correct Message-ID if necessary.
6087 ;; Suggested by tale@pawl.rpi.edu.
6088 (unless (string-match "^<" message-id)
6089 (setq message-id (concat "<" message-id)))
6090 (unless (string-match ">$" message-id)
6091 (setq message-id (concat message-id ">")))
6092 (let* ((header (gnus-id-to-header message-id))
6094 (gnus-summary-article-sparse-p
6095 (mail-header-number header)))))
6098 ;; The article is present in the buffer, to we just go to it.
6099 (gnus-summary-goto-article
6100 (mail-header-number header) nil header)
6102 (gnus-summary-update-article (mail-header-number header))))
6103 ;; We fetch the article
6104 (let ((gnus-override-method
6105 (and (gnus-news-group-p gnus-newsgroup-name)
6106 gnus-refer-article-method))
6108 ;; Start the special refer-article method, if necessary.
6109 (when (and gnus-refer-article-method
6110 (gnus-news-group-p gnus-newsgroup-name))
6111 (gnus-check-server gnus-refer-article-method))
6112 ;; Fetch the header, and display the article.
6113 (if (setq number (gnus-summary-insert-subject message-id))
6114 (gnus-summary-select-article nil nil nil number)
6115 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6117 (defun gnus-summary-enter-digest-group (&optional force)
6118 "Enter an nndoc group based on the current article.
6119 If FORCE, force a digest interpretation. If not, try
6120 to guess what the document format is."
6122 (gnus-set-global-variables)
6123 (let ((conf gnus-current-window-configuration))
6125 (gnus-summary-select-article))
6126 (setq gnus-current-window-configuration conf)
6127 (let* ((name (format "%s-%d"
6128 (gnus-group-prefixed-name
6129 gnus-newsgroup-name (list 'nndoc ""))
6131 (set-buffer gnus-summary-buffer)
6132 gnus-current-article)))
6133 (ogroup gnus-newsgroup-name)
6134 (params (append (gnus-info-params (gnus-get-info ogroup))
6135 (list (cons 'to-group ogroup))))
6136 (case-fold-search t)
6137 (buf (current-buffer))
6140 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6141 (insert-buffer-substring gnus-original-article-buffer)
6142 ;; Remove lines that may lead nndoc to misinterpret the
6145 (goto-char (point-min))
6146 (or (search-forward "\n\n" nil t) (point)))
6147 (goto-char (point-min))
6148 (delete-matching-lines "^\\(Path\\):\\|^From ")
6151 (if (gnus-group-read-ephemeral-group
6152 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6154 ,(if force 'digest 'guess))) t)
6155 ;; Make all postings to this group go to the parent group.
6156 (nconc (gnus-info-params (gnus-get-info name))
6158 ;; Couldn't select this doc group.
6159 (switch-to-buffer buf)
6160 (gnus-set-global-variables)
6161 (gnus-configure-windows 'summary)
6162 (gnus-message 3 "Article couldn't be entered?"))
6163 (kill-buffer dig)))))
6165 (defun gnus-summary-read-document (n)
6166 "Open a new group based on the current article(s).
6167 This will allow you to read digests and other similar
6168 documents as newsgroups.
6169 Obeys the standard process/prefix convention."
6171 (let* ((articles (gnus-summary-work-articles n))
6172 (ogroup gnus-newsgroup-name)
6173 (params (append (gnus-info-params (gnus-get-info ogroup))
6174 (list (cons 'to-group ogroup))))
6175 article group egroup groups vgroup)
6176 (while (setq article (pop articles))
6177 (setq group (format "%s-%d" gnus-newsgroup-name article))
6178 (gnus-summary-remove-process-mark article)
6179 (when (gnus-summary-display-article article)
6181 (nnheader-temp-write nil
6182 (insert-buffer-substring gnus-original-article-buffer)
6183 ;; Remove some headers that may lead nndoc to make
6185 (message-narrow-to-head)
6186 (goto-char (point-min))
6187 (delete-matching-lines "^\\(Path\\):\\|^From ")
6190 (gnus-group-read-ephemeral-group
6191 group `(nndoc ,group (nndoc-address ,(current-buffer))
6192 (nndoc-article-type guess))
6195 ;; Make all postings to this group go to the parent group.
6196 (nconc (gnus-info-params (gnus-get-info egroup))
6198 (push egroup groups))
6199 ;; Couldn't select this doc group.
6200 (gnus-error 3 "Article couldn't be entered"))))))
6201 ;; Now we have selected all the documents.
6204 (error "None of the articles could be interpreted as documents"))
6205 ((gnus-group-read-ephemeral-group
6206 (setq vgroup (format
6207 "nnvirtual:%s-%s" gnus-newsgroup-name
6208 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6209 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6211 (cons (current-buffer) 'summary)))
6213 (error "Couldn't select virtual nndoc group")))))
6215 (defun gnus-summary-isearch-article (&optional regexp-p)
6216 "Do incremental search forward on the current article.
6217 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6219 (gnus-set-global-variables)
6220 (gnus-summary-select-article)
6221 (gnus-configure-windows 'article)
6222 (gnus-eval-in-buffer-window gnus-article-buffer
6223 ;;(goto-char (point-min))
6224 (isearch-forward regexp-p)))
6226 (defun gnus-summary-search-article-forward (regexp &optional backward)
6227 "Search for an article containing REGEXP forward.
6228 If BACKWARD, search backward instead."
6231 (format "Search article %s (regexp%s): "
6232 (if current-prefix-arg "backward" "forward")
6233 (if gnus-last-search-regexp
6234 (concat ", default " gnus-last-search-regexp)
6236 current-prefix-arg))
6237 (gnus-set-global-variables)
6238 (if (string-equal regexp "")
6239 (setq regexp (or gnus-last-search-regexp ""))
6240 (setq gnus-last-search-regexp regexp))
6241 (if (gnus-summary-search-article regexp backward)
6242 (gnus-summary-show-thread)
6243 (error "Search failed: \"%s\"" regexp)))
6245 (defun gnus-summary-search-article-backward (regexp)
6246 "Search for an article containing REGEXP backward."
6249 (format "Search article backward (regexp%s): "
6250 (if gnus-last-search-regexp
6251 (concat ", default " gnus-last-search-regexp)
6253 (gnus-summary-search-article-forward regexp 'backward))
6255 (defun gnus-summary-search-article (regexp &optional backward)
6256 "Search for an article containing REGEXP.
6257 Optional argument BACKWARD means do search for backward.
6258 `gnus-select-article-hook' is not called during the search."
6259 (let ((gnus-select-article-hook nil) ;Disable hook.
6260 (gnus-article-display-hook nil)
6261 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6262 (gnus-use-article-prefetch nil)
6263 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6264 (sum (current-buffer))
6267 (gnus-save-hidden-threads
6268 (gnus-summary-select-article)
6269 (set-buffer gnus-article-buffer)
6273 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6275 (re-search-backward regexp nil t)
6276 (re-search-forward regexp nil t))
6277 ;; We found the regexp.
6282 (get-buffer-window (current-buffer))
6286 (setq point (point)))
6287 ;; We didn't find it, so we go to the next article.
6290 (while (eq found 'not)
6291 (if (not (if backward (gnus-summary-find-prev)
6292 (gnus-summary-find-next)))
6293 ;; No more articles.
6295 ;; Select the next article and adjust point.
6296 (unless (gnus-summary-article-sparse-p
6297 (gnus-summary-article-number))
6299 (gnus-summary-select-article)
6300 (set-buffer gnus-article-buffer)
6302 (goto-char (if backward (point-max) (point-min))))))))
6303 (gnus-message 7 ""))
6304 ;; Return whether we found the regexp.
6305 (when (eq found 'found)
6307 (gnus-summary-show-thread)
6308 (gnus-summary-goto-subject gnus-current-article)
6309 (gnus-summary-position-point)
6312 (defun gnus-summary-find-matching (header regexp &optional backward unread
6314 "Return a list of all articles that match REGEXP on HEADER.
6315 The search stars on the current article and goes forwards unless
6316 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6317 If UNREAD is non-nil, only unread articles will
6318 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6319 in the comparisons."
6320 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6321 (gnus-data-find-list
6322 (gnus-summary-article-number) (gnus-data-list backward))))
6323 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6324 (case-fold-search (not not-case-fold))
6326 (unless (fboundp (intern (concat "mail-header-" header)))
6327 (error "%s is not a valid header" header))
6330 (and (or (not unread) ; We want all articles...
6331 (gnus-data-unread-p d)) ; Or just unreads.
6332 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6333 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6334 (push (gnus-data-number d) articles)) ; Success!
6335 (setq data (cdr data)))
6336 (nreverse articles)))
6338 (defun gnus-summary-execute-command (header regexp command &optional backward)
6339 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6340 If HEADER is an empty string (or nil), the match is done on the entire
6341 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6343 (list (let ((completion-ignore-case t))
6346 (mapcar (lambda (string) (list string))
6347 '("Number" "Subject" "From" "Lines" "Date"
6348 "Message-ID" "Xref" "References" "Body"))
6349 nil 'require-match))
6350 (read-string "Regexp: ")
6351 (read-key-sequence "Command: ")
6352 current-prefix-arg))
6353 (when (equal header "Body")
6355 (gnus-set-global-variables)
6356 ;; Hidden thread subtrees must be searched as well.
6357 (gnus-summary-show-all-threads)
6358 ;; We don't want to change current point nor window configuration.
6360 (save-window-excursion
6361 (gnus-message 6 "Executing %s..." (key-description command))
6362 ;; We'd like to execute COMMAND interactively so as to give arguments.
6363 (gnus-execute header regexp
6364 `(call-interactively ',(key-binding command))
6366 (gnus-message 6 "Executing %s...done" (key-description command)))))
6368 (defun gnus-summary-beginning-of-article ()
6369 "Scroll the article back to the beginning."
6371 (gnus-set-global-variables)
6372 (gnus-summary-select-article)
6373 (gnus-configure-windows 'article)
6374 (gnus-eval-in-buffer-window gnus-article-buffer
6376 (goto-char (point-min))
6377 (when gnus-break-pages
6378 (gnus-narrow-to-page))))
6380 (defun gnus-summary-end-of-article ()
6381 "Scroll to the end of the article."
6383 (gnus-set-global-variables)
6384 (gnus-summary-select-article)
6385 (gnus-configure-windows 'article)
6386 (gnus-eval-in-buffer-window gnus-article-buffer
6388 (goto-char (point-max))
6390 (when gnus-break-pages
6391 (gnus-narrow-to-page))))
6393 (defun gnus-summary-print-article (&optional filename)
6394 "Generate and print a PostScript image of the article buffer.
6396 If the optional argument FILENAME is nil, send the image to the printer.
6397 If FILENAME is a string, save the PostScript image in a file with that
6398 name. If FILENAME is a number, prompt the user for the name of the file
6400 (interactive (list (ps-print-preprint current-prefix-arg)))
6401 (gnus-summary-select-article)
6402 (gnus-eval-in-buffer-window gnus-article-buffer
6403 (let ((buffer (generate-new-buffer " *print*")))
6406 (copy-to-buffer buffer (point-min) (point-max))
6408 (gnus-article-delete-invisible-text)
6409 (run-hooks 'gnus-ps-print-hook)
6410 (ps-print-buffer-with-faces filename))
6411 (kill-buffer buffer)))))
6413 (defun gnus-summary-show-article (&optional arg)
6414 "Force re-fetching of the current article.
6415 If ARG (the prefix) is non-nil, show the raw article without any
6416 article massaging functions being run."
6418 (gnus-set-global-variables)
6420 ;; Select the article the normal way.
6421 (gnus-summary-select-article nil 'force)
6422 ;; Bind the article treatment functions to nil.
6423 (let ((gnus-have-all-headers t)
6424 gnus-article-display-hook
6425 gnus-article-prepare-hook
6428 (gnus-summary-select-article nil 'force)))
6429 (gnus-summary-goto-subject gnus-current-article)
6430 ; (gnus-configure-windows 'article)
6431 (gnus-summary-position-point))
6433 (defun gnus-summary-verbose-headers (&optional arg)
6434 "Toggle permanent full header display.
6435 If ARG is a positive number, turn header display on.
6436 If ARG is a negative number, turn header display off."
6438 (gnus-set-global-variables)
6439 (setq gnus-show-all-headers
6440 (cond ((or (not (numberp arg))
6442 (not gnus-show-all-headers))
6445 (gnus-summary-show-article))
6447 (defun gnus-summary-toggle-header (&optional arg)
6448 "Show the headers if they are hidden, or hide them if they are shown.
6449 If ARG is a positive number, show the entire header.
6450 If ARG is a negative number, hide the unwanted header lines."
6452 (gnus-set-global-variables)
6454 (set-buffer gnus-article-buffer)
6455 (let* ((buffer-read-only nil)
6456 (inhibit-point-motion-hooks t)
6457 (hidden (text-property-any
6458 (goto-char (point-min)) (search-forward "\n\n")
6461 (goto-char (point-min))
6462 (when (search-forward "\n\n" nil t)
6463 (delete-region (point-min) (1- (point))))
6464 (goto-char (point-min))
6466 (set-buffer gnus-original-article-buffer)
6467 (goto-char (point-min))
6468 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6469 (insert-buffer-substring gnus-original-article-buffer 1 e)
6470 (let ((article-inhibit-hiding t))
6471 (run-hooks 'gnus-article-display-hook))
6472 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6473 (gnus-article-hide-headers)))))
6475 (defun gnus-summary-show-all-headers ()
6476 "Make all header lines visible."
6478 (gnus-set-global-variables)
6479 (gnus-article-show-all-headers))
6481 (defun gnus-summary-toggle-mime (&optional arg)
6482 "Toggle MIME processing.
6483 If ARG is a positive number, turn MIME processing on."
6485 (gnus-set-global-variables)
6486 (setq gnus-show-mime
6487 (if (null arg) (not gnus-show-mime)
6488 (> (prefix-numeric-value arg) 0)))
6489 (gnus-summary-select-article t 'force))
6491 (defun gnus-summary-caesar-message (&optional arg)
6492 "Caesar rotate the current article by 13.
6493 The numerical prefix specifies how many places to rotate each letter
6496 (gnus-set-global-variables)
6497 (gnus-summary-select-article)
6498 (let ((mail-header-separator ""))
6499 (gnus-eval-in-buffer-window gnus-article-buffer
6502 (let ((start (window-start))
6504 (message-caesar-buffer-body arg)
6505 (set-window-start (get-buffer-window (current-buffer)) start))))))
6507 (defun gnus-summary-stop-page-breaking ()
6508 "Stop page breaking in the current article."
6510 (gnus-set-global-variables)
6511 (gnus-summary-select-article)
6512 (gnus-eval-in-buffer-window gnus-article-buffer
6514 (when (gnus-visual-p 'page-marker)
6515 (let ((buffer-read-only nil))
6516 (gnus-remove-text-with-property 'gnus-prev)
6517 (gnus-remove-text-with-property 'gnus-next)))))
6519 (defun gnus-summary-move-article (&optional n to-newsgroup
6520 select-method action)
6521 "Move the current article to a different newsgroup.
6522 If N is a positive number, move the N next articles.
6523 If N is a negative number, move the N previous articles.
6524 If N is nil and any articles have been marked with the process mark,
6525 move those articles instead.
6526 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6527 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6528 re-spool using this method.
6530 For this function to work, both the current newsgroup and the
6531 newsgroup that you want to move to have to support the `request-move'
6532 and `request-accept' functions."
6535 (setq action 'move))
6536 (gnus-set-global-variables)
6537 ;; Disable marking as read.
6538 (let (gnus-mark-article-hook)
6539 (save-window-excursion
6540 (gnus-summary-select-article)))
6541 ;; Check whether the source group supports the required functions.
6542 (cond ((and (eq action 'move)
6543 (not (gnus-check-backend-function
6544 'request-move-article gnus-newsgroup-name)))
6545 (error "The current group does not support article moving"))
6546 ((and (eq action 'crosspost)
6547 (not (gnus-check-backend-function
6548 'request-replace-article gnus-newsgroup-name)))
6549 (error "The current group does not support article editing")))
6550 (let ((articles (gnus-summary-work-articles n))
6551 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6552 (names '((move "Move" "Moving")
6553 (copy "Copy" "Copying")
6554 (crosspost "Crosspost" "Crossposting")))
6555 (copy-buf (save-excursion
6556 (nnheader-set-temp-buffer " *copy article*")))
6557 art-group to-method new-xref article to-groups)
6558 (unless (assq action names)
6559 (error "Unknown action %s" action))
6560 ;; Read the newsgroup name.
6561 (when (and (not to-newsgroup)
6562 (not select-method))
6564 (gnus-read-move-group-name
6565 (cadr (assq action names))
6566 (symbol-value (intern (format "gnus-current-%s-group" action)))
6568 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6569 (setq to-method (or select-method
6570 (gnus-group-name-to-method to-newsgroup)))
6571 ;; Check the method we are to move this article to...
6572 (unless (gnus-check-backend-function
6573 'request-accept-article (car to-method))
6574 (error "%s does not support article copying" (car to-method)))
6575 (unless (gnus-check-server to-method)
6576 (error "Can't open server %s" (car to-method)))
6577 (gnus-message 6 "%s to %s: %s..."
6578 (caddr (assq action names))
6579 (or (car select-method) to-newsgroup) articles)
6581 (setq article (pop articles))
6585 ;; Move the article.
6587 (gnus-request-move-article
6588 article ; Article to move
6589 gnus-newsgroup-name ; From newsgroup
6590 (nth 1 (gnus-find-method-for-group
6591 gnus-newsgroup-name)) ; Server
6592 (list 'gnus-request-accept-article
6593 to-newsgroup (list 'quote select-method)
6594 (not articles)) ; Accept form
6595 (not articles))) ; Only save nov last time
6596 ;; Copy the article.
6599 (set-buffer copy-buf)
6600 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6601 (gnus-request-accept-article
6602 to-newsgroup select-method (not articles))))
6603 ;; Crosspost the article.
6604 ((eq action 'crosspost)
6605 (let ((xref (message-tokenize-header
6606 (mail-header-xref (gnus-summary-article-header article))
6608 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6611 (setq xref (list (system-name))))
6614 (mapconcat 'identity
6615 (delete "Xref:" (delete new-xref xref))
6619 (set-buffer copy-buf)
6620 ;; First put the article in the destination group.
6621 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6623 (gnus-request-accept-article
6624 to-newsgroup select-method (not articles)))
6625 (setq new-xref (concat new-xref " " (car art-group)
6626 ":" (cdr art-group)))
6627 ;; Now we have the new Xrefs header, so we insert
6628 ;; it and replace the new article.
6629 (nnheader-replace-header "Xref" new-xref)
6630 (gnus-request-replace-article
6631 (cdr art-group) to-newsgroup (current-buffer))
6634 (gnus-message 1 "Couldn't %s article %s"
6635 (cadr (assq action names)) article)
6638 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6640 (gnus-group-prefixed-name
6643 (gnus-find-method-for-group to-newsgroup)))
6644 gnus-newsrc-hashtb)))
6645 (info (nth 2 entry))
6646 (to-group (gnus-info-group info)))
6647 ;; Update the group that has been moved to.
6649 (memq action '(move copy)))
6650 (unless (member to-group to-groups)
6651 (push to-group to-groups))
6653 (unless (memq article gnus-newsgroup-unreads)
6655 info (gnus-add-to-range (gnus-info-read info)
6656 (list (cdr art-group)))))
6658 ;; Copy any marks over to the new group.
6659 (let ((marks gnus-article-mark-lists)
6660 (to-article (cdr art-group)))
6662 ;; See whether the article is to be put in the cache.
6663 (when gnus-use-cache
6664 (gnus-cache-possibly-enter-article
6666 (let ((header (copy-sequence
6667 (gnus-summary-article-header article))))
6668 (mail-header-set-number header to-article)
6670 (memq article gnus-newsgroup-marked)
6671 (memq article gnus-newsgroup-dormant)
6672 (memq article gnus-newsgroup-unreads)))
6674 (when (and (equal to-group gnus-newsgroup-name)
6675 (not (memq article gnus-newsgroup-unreads)))
6676 ;; Mark this article as read in this group.
6677 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6678 (setcdr (gnus-active to-group) to-article)
6679 (setcdr gnus-newsgroup-active to-article))
6682 (when (memq article (symbol-value
6683 (intern (format "gnus-newsgroup-%s"
6685 ;; If the other group is the same as this group,
6686 ;; then we have to add the mark to the list.
6687 (when (equal to-group gnus-newsgroup-name)
6688 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6691 (intern (format "gnus-newsgroup-%s"
6693 ;; Copy the marks to other group.
6694 (gnus-add-marked-articles
6695 to-group (cdar marks) (list to-article) info))
6696 (setq marks (cdr marks)))))
6698 ;; Update the Xref header in this article to point to
6699 ;; the new crossposted article we have just created.
6700 (when (eq action 'crosspost)
6702 (set-buffer copy-buf)
6703 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6704 (nnheader-replace-header "Xref" new-xref)
6705 (gnus-request-replace-article
6706 article gnus-newsgroup-name (current-buffer)))))
6708 (gnus-summary-goto-subject article)
6709 (when (eq action 'move)
6710 (gnus-summary-mark-article article gnus-canceled-mark)))
6711 (gnus-summary-remove-process-mark article))
6712 ;; Re-activate all groups that have been moved to.
6714 (gnus-activate-group (pop to-groups)))
6716 (gnus-kill-buffer copy-buf)
6717 (gnus-summary-position-point)
6718 (gnus-set-mode-line 'summary)))
6720 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6721 "Move the current article to a different newsgroup.
6722 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6723 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6724 re-spool using this method."
6726 (gnus-summary-move-article n to-newsgroup select-method 'copy))
6728 (defun gnus-summary-crosspost-article (&optional n)
6729 "Crosspost the current article to some other group."
6731 (gnus-summary-move-article n nil nil 'crosspost))
6733 (defcustom gnus-summary-respool-default-method nil
6734 "Default method for respooling an article.
6735 If nil, use to the current newsgroup method."
6736 :type 'gnus-select-method-name
6737 :group 'gnus-summary-mail)
6739 (defun gnus-summary-respool-article (&optional n method)
6740 "Respool the current article.
6741 The article will be squeezed through the mail spooling process again,
6742 which means that it will be put in some mail newsgroup or other
6743 depending on `nnmail-split-methods'.
6744 If N is a positive number, respool the N next articles.
6745 If N is a negative number, respool the N previous articles.
6746 If N is nil and any articles have been marked with the process mark,
6747 respool those articles instead.
6749 Respooling can be done both from mail groups and \"real\" newsgroups.
6750 In the former case, the articles in question will be moved from the
6751 current group into whatever groups they are destined to. In the
6752 latter case, they will be copied into the relevant groups."
6754 (list current-prefix-arg
6755 (let* ((methods (gnus-methods-using 'respool))
6757 (symbol-name (or gnus-summary-respool-default-method
6758 (car (gnus-find-method-for-group
6759 gnus-newsgroup-name)))))
6761 (gnus-completing-read
6762 methname "What backend do you want to use when respooling?"
6763 methods nil t nil 'gnus-mail-method-history))
6766 ((zerop (length (setq ms (gnus-servers-using-backend
6768 (list (intern method) ""))
6772 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6773 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6775 (gnus-set-global-variables)
6777 (error "No method given for respooling"))
6778 (if (assoc (symbol-name
6779 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6780 (gnus-methods-using 'respool))
6781 (gnus-summary-move-article n nil method)
6782 (gnus-summary-copy-article n nil method)))
6784 (defun gnus-summary-import-article (file)
6785 "Import a random file into a mail newsgroup."
6786 (interactive "fImport file: ")
6787 (gnus-set-global-variables)
6788 (let ((group gnus-newsgroup-name)
6789 (now (current-time))
6791 (unless (gnus-check-backend-function 'request-accept-article group)
6792 (error "%s does not support article importing" group))
6793 (or (file-readable-p file)
6794 (not (file-regular-p file))
6795 (error "Can't read %s" file))
6797 (set-buffer (get-buffer-create " *import file*"))
6798 (buffer-disable-undo (current-buffer))
6800 (insert-file-contents file)
6801 (goto-char (point-min))
6802 (unless (nnheader-article-p)
6803 ;; This doesn't look like an article, so we fudge some headers.
6804 (setq atts (file-attributes file)
6805 lines (count-lines (point-min) (point-max)))
6806 (insert "From: " (read-string "From: ") "\n"
6807 "Subject: " (read-string "Subject: ") "\n"
6808 "Date: " (timezone-make-date-arpa-standard
6809 (current-time-string (nth 5 atts))
6810 (current-time-zone now)
6811 (current-time-zone now))
6813 "Message-ID: " (message-make-message-id) "\n"
6814 "Lines: " (int-to-string lines) "\n"
6815 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6816 (gnus-request-accept-article group nil t)
6817 (kill-buffer (current-buffer)))))
6819 (defun gnus-summary-article-posted-p ()
6820 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6821 This will be the case if the article has both been mailed and posted."
6823 (let ((id (mail-header-references (gnus-summary-article-header)))
6824 (gnus-override-method
6825 (or gnus-refer-article-method gnus-select-method)))
6826 (if (gnus-request-head id "")
6827 (gnus-message 2 "The current message was found on %s"
6828 gnus-override-method)
6829 (gnus-message 2 "The current message couldn't be found on %s"
6830 gnus-override-method)
6833 (defun gnus-summary-expire-articles (&optional now)
6834 "Expire all articles that are marked as expirable in the current group."
6836 (gnus-set-global-variables)
6837 (when (gnus-check-backend-function
6838 'request-expire-articles gnus-newsgroup-name)
6839 ;; This backend supports expiry.
6840 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6841 (expirable (if total
6843 ;; We need to update the info for
6844 ;; this group for `gnus-list-of-read-articles'
6845 ;; to give us the right answer.
6846 (run-hooks 'gnus-exit-group-hook)
6847 (gnus-summary-update-info)
6848 (gnus-list-of-read-articles gnus-newsgroup-name))
6849 (setq gnus-newsgroup-expirable
6850 (sort gnus-newsgroup-expirable '<))))
6851 (expiry-wait (if now 'immediate
6852 (gnus-group-find-parameter
6853 gnus-newsgroup-name 'expiry-wait)))
6856 ;; There are expirable articles in this group, so we run them
6857 ;; through the expiry process.
6858 (gnus-message 6 "Expiring articles...")
6859 ;; The list of articles that weren't expired is returned.
6861 (let ((nnmail-expiry-wait-function nil)
6862 (nnmail-expiry-wait expiry-wait))
6863 (setq es (gnus-request-expire-articles
6864 expirable gnus-newsgroup-name)))
6865 (setq es (gnus-request-expire-articles
6866 expirable gnus-newsgroup-name)))
6868 (setq gnus-newsgroup-expirable es))
6869 ;; We go through the old list of expirable, and mark all
6870 ;; really expired articles as nonexistent.
6871 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6872 (let ((gnus-use-cache nil))
6874 (unless (memq (car expirable) es)
6875 (when (gnus-data-find (car expirable))
6876 (gnus-summary-mark-article
6877 (car expirable) gnus-canceled-mark)))
6878 (setq expirable (cdr expirable)))))
6879 (gnus-message 6 "Expiring articles...done")))))
6881 (defun gnus-summary-expire-articles-now ()
6882 "Expunge all expirable articles in the current group.
6883 This means that *all* articles that are marked as expirable will be
6884 deleted forever, right now."
6886 (gnus-set-global-variables)
6887 (or gnus-expert-user
6889 "Are you really, really, really sure you want to delete all these messages? ")
6891 (gnus-summary-expire-articles t))
6893 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6894 (defun gnus-summary-delete-article (&optional n)
6895 "Delete the N next (mail) articles.
6896 This command actually deletes articles. This is not a marking
6897 command. The article will disappear forever from your life, never to
6899 If N is negative, delete backwards.
6900 If N is nil and articles have been marked with the process mark,
6901 delete these instead."
6903 (gnus-set-global-variables)
6904 (unless (gnus-check-backend-function 'request-expire-articles
6905 gnus-newsgroup-name)
6906 (error "The current newsgroup does not support article deletion."))
6907 ;; Compute the list of articles to delete.
6908 (let ((articles (gnus-summary-work-articles n))
6910 (if (and gnus-novice-user
6911 (not (gnus-yes-or-no-p
6912 (format "Do you really want to delete %s forever? "
6913 (if (> (length articles) 1)
6914 (format "these %s articles" (length articles))
6917 ;; Delete the articles.
6918 (setq not-deleted (gnus-request-expire-articles
6919 articles gnus-newsgroup-name 'force))
6921 (gnus-summary-remove-process-mark (car articles))
6922 ;; The backend might not have been able to delete the article
6924 (unless (memq (car articles) not-deleted)
6925 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6926 (setq articles (cdr articles)))
6928 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
6929 (gnus-summary-position-point)
6930 (gnus-set-mode-line 'summary)
6933 (defun gnus-summary-edit-article (&optional force)
6934 "Edit the current article.
6935 This will have permanent effect only in mail groups.
6936 If FORCE is non-nil, allow editing of articles even in read-only
6940 (set-buffer gnus-summary-buffer)
6941 (gnus-set-global-variables)
6942 (when (and (not force)
6943 (gnus-group-read-only-p))
6944 (error "The current newsgroup does not support article editing."))
6945 ;; Select article if needed.
6946 (unless (eq (gnus-summary-article-number)
6947 gnus-current-article)
6948 (gnus-summary-select-article t))
6949 (gnus-article-edit-article
6951 (gnus-summary-edit-article-done
6952 ,(or (mail-header-references gnus-current-headers) "")
6953 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6955 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6957 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6958 "Make edits to the current article permanent."
6960 ;; Replace the article.
6961 (if (and (not read-only)
6962 (not (gnus-request-replace-article
6963 (cdr gnus-article-current) (car gnus-article-current)
6965 (error "Couldn't replace article.")
6966 ;; Update the summary buffer.
6968 (equal (message-tokenize-header references " ")
6969 (message-tokenize-header
6970 (or (message-fetch-field "references") "") " ")))
6971 ;; We only have to update this line.
6974 (message-narrow-to-head)
6975 (let ((head (buffer-string))
6977 (nnheader-temp-write nil
6978 (insert (format "211 %d Article retrieved.\n"
6979 (cdr gnus-article-current)))
6982 (let ((nntp-server-buffer (current-buffer)))
6983 (setq header (car (gnus-get-newsgroup-headers
6985 (set-buffer gnus-summary-buffer)
6986 gnus-newsgroup-dependencies)
6989 (set-buffer gnus-summary-buffer)
6990 (gnus-data-set-header
6991 (gnus-data-find (cdr gnus-article-current))
6993 (gnus-summary-update-article-line
6994 (cdr gnus-article-current) header))))))
6996 (set-buffer (or buffer gnus-summary-buffer))
6997 (gnus-summary-update-article (cdr gnus-article-current)))
6998 ;; Prettify the article buffer again.
7000 (set-buffer gnus-article-buffer)
7001 (run-hooks 'gnus-article-display-hook)
7002 (set-buffer gnus-original-article-buffer)
7003 (gnus-request-article
7004 (cdr gnus-article-current) (car gnus-article-current) (current-buffer)))
7005 ;; Prettify the summary buffer line.
7006 (when (gnus-visual-p 'summary-highlight 'highlight)
7007 (run-hooks 'gnus-visual-mark-article-hook))))
7009 (defun gnus-summary-edit-wash (key)
7010 "Perform editing command in the article buffer."
7014 (message "%s" (concat (this-command-keys) "- "))
7017 (gnus-summary-edit-article)
7018 (execute-kbd-macro (concat (this-command-keys) key))
7019 (gnus-article-edit-done))
7023 (defun gnus-summary-respool-query ()
7024 "Query where the respool algorithm would put this article."
7026 (gnus-set-global-variables)
7027 (let (gnus-mark-article-hook)
7028 (gnus-summary-select-article)
7030 (set-buffer gnus-original-article-buffer)
7032 (message-narrow-to-head)
7033 (message "This message would go to %s"
7034 (mapconcat 'car (nnmail-article-group 'identity) ", "))))))
7036 ;; Summary marking commands.
7038 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7039 "Mark articles which has the same subject as read, and then select the next.
7040 If UNMARK is positive, remove any kind of mark.
7041 If UNMARK is negative, tick articles."
7043 (gnus-set-global-variables)
7045 (setq unmark (prefix-numeric-value unmark)))
7047 (gnus-summary-mark-same-subject
7048 (gnus-summary-article-subject) unmark)))
7049 ;; Select next unread article. If auto-select-same mode, should
7050 ;; select the first unread article.
7051 (gnus-summary-next-article t (and gnus-auto-select-same
7052 (gnus-summary-article-subject)))
7053 (gnus-message 7 "%d article%s marked as %s"
7054 count (if (= count 1) " is" "s are")
7055 (if unmark "unread" "read"))))
7057 (defun gnus-summary-kill-same-subject (&optional unmark)
7058 "Mark articles which has the same subject as read.
7059 If UNMARK is positive, remove any kind of mark.
7060 If UNMARK is negative, tick articles."
7062 (gnus-set-global-variables)
7064 (setq unmark (prefix-numeric-value unmark)))
7066 (gnus-summary-mark-same-subject
7067 (gnus-summary-article-subject) unmark)))
7068 ;; If marked as read, go to next unread subject.
7070 ;; Go to next unread subject.
7071 (gnus-summary-next-subject 1 t))
7072 (gnus-message 7 "%d articles are marked as %s"
7073 count (if unmark "unread" "read"))))
7075 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7076 "Mark articles with same SUBJECT as read, and return marked number.
7077 If optional argument UNMARK is positive, remove any kinds of marks.
7078 If optional argument UNMARK is negative, mark articles as unread instead."
7082 ((null unmark) ; Mark as read.
7085 (gnus-summary-mark-article-as-read gnus-killed-mark)
7086 (gnus-summary-show-thread) t)
7087 (gnus-summary-find-subject subject))
7088 (setq count (1+ count))))
7089 ((> unmark 0) ; Tick.
7092 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7093 (gnus-summary-show-thread) t)
7094 (gnus-summary-find-subject subject))
7095 (setq count (1+ count))))
7096 (t ; Mark as unread.
7099 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7100 (gnus-summary-show-thread) t)
7101 (gnus-summary-find-subject subject))
7102 (setq count (1+ count)))))
7103 (gnus-set-mode-line 'summary)
7104 ;; Return the number of marked articles.
7107 (defun gnus-summary-mark-as-processable (n &optional unmark)
7108 "Set the process mark on the next N articles.
7109 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7110 the process mark instead. The difference between N and the actual
7111 number of articles marked is returned."
7113 (gnus-set-global-variables)
7114 (let ((backward (< n 0))
7119 (gnus-summary-remove-process-mark
7120 (gnus-summary-article-number))
7121 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7122 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7125 (gnus-message 7 "No more articles"))
7126 (gnus-summary-recenter)
7127 (gnus-summary-position-point)
7130 (defun gnus-summary-unmark-as-processable (n)
7131 "Remove the process mark from the next N articles.
7132 If N is negative, mark backward instead. The difference between N and
7133 the actual number of articles marked is returned."
7135 (gnus-set-global-variables)
7136 (gnus-summary-mark-as-processable n t))
7138 (defun gnus-summary-unmark-all-processable ()
7139 "Remove the process mark from all articles."
7141 (gnus-set-global-variables)
7143 (while gnus-newsgroup-processable
7144 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7145 (gnus-summary-position-point))
7147 (defun gnus-summary-mark-as-expirable (n)
7148 "Mark N articles forward as expirable.
7149 If N is negative, mark backward instead. The difference between N and
7150 the actual number of articles marked is returned."
7152 (gnus-set-global-variables)
7153 (gnus-summary-mark-forward n gnus-expirable-mark))
7155 (defun gnus-summary-mark-article-as-replied (article)
7156 "Mark ARTICLE replied and update the summary line."
7157 (push article gnus-newsgroup-replied)
7158 (let ((buffer-read-only nil))
7159 (when (gnus-summary-goto-subject article)
7160 (gnus-summary-update-secondary-mark article))))
7162 (defun gnus-summary-set-bookmark (article)
7163 "Set a bookmark in current article."
7164 (interactive (list (gnus-summary-article-number)))
7165 (gnus-set-global-variables)
7166 (when (or (not (get-buffer gnus-article-buffer))
7167 (not gnus-current-article)
7168 (not gnus-article-current)
7169 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7170 (error "No current article selected"))
7171 ;; Remove old bookmark, if one exists.
7172 (let ((old (assq article gnus-newsgroup-bookmarks)))
7174 (setq gnus-newsgroup-bookmarks
7175 (delq old gnus-newsgroup-bookmarks))))
7176 ;; Set the new bookmark, which is on the form
7177 ;; (article-number . line-number-in-body).
7181 (set-buffer gnus-article-buffer)
7185 (goto-char (point-min))
7186 (search-forward "\n\n" nil t)
7189 gnus-newsgroup-bookmarks)
7190 (gnus-message 6 "A bookmark has been added to the current article."))
7192 (defun gnus-summary-remove-bookmark (article)
7193 "Remove the bookmark from the current article."
7194 (interactive (list (gnus-summary-article-number)))
7195 (gnus-set-global-variables)
7196 ;; Remove old bookmark, if one exists.
7197 (let ((old (assq article gnus-newsgroup-bookmarks)))
7200 (setq gnus-newsgroup-bookmarks
7201 (delq old gnus-newsgroup-bookmarks))
7202 (gnus-message 6 "Removed bookmark."))
7203 (gnus-message 6 "No bookmark in current article."))))
7205 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7206 (defun gnus-summary-mark-as-dormant (n)
7207 "Mark N articles forward as dormant.
7208 If N is negative, mark backward instead. The difference between N and
7209 the actual number of articles marked is returned."
7211 (gnus-set-global-variables)
7212 (gnus-summary-mark-forward n gnus-dormant-mark))
7214 (defun gnus-summary-set-process-mark (article)
7215 "Set the process mark on ARTICLE and update the summary line."
7216 (setq gnus-newsgroup-processable
7218 (delq article gnus-newsgroup-processable)))
7219 (when (gnus-summary-goto-subject article)
7220 (gnus-summary-show-thread)
7221 (gnus-summary-update-secondary-mark article)))
7223 (defun gnus-summary-remove-process-mark (article)
7224 "Remove the process mark from ARTICLE and update the summary line."
7225 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7226 (when (gnus-summary-goto-subject article)
7227 (gnus-summary-show-thread)
7228 (gnus-summary-update-secondary-mark article)))
7230 (defun gnus-summary-set-saved-mark (article)
7231 "Set the process mark on ARTICLE and update the summary line."
7232 (push article gnus-newsgroup-saved)
7233 (when (gnus-summary-goto-subject article)
7234 (gnus-summary-update-secondary-mark article)))
7236 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7237 "Mark N articles as read forwards.
7238 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7239 The difference between N and the actual number of articles marked is
7242 (gnus-set-global-variables)
7243 (let ((backward (< n 0))
7244 (gnus-summary-goto-unread
7245 (and gnus-summary-goto-unread
7246 (not (eq gnus-summary-goto-unread 'never))
7247 (not (memq mark (list gnus-unread-mark
7248 gnus-ticked-mark gnus-dormant-mark)))))
7250 (mark (or mark gnus-del-mark)))
7252 (gnus-summary-mark-article nil mark no-expire)
7253 (zerop (gnus-summary-next-subject
7255 (and gnus-summary-goto-unread
7256 (not (eq gnus-summary-goto-unread 'never)))
7260 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7261 (gnus-summary-recenter)
7262 (gnus-summary-position-point)
7263 (gnus-set-mode-line 'summary)
7266 (defun gnus-summary-mark-article-as-read (mark)
7267 "Mark the current article quickly as read with MARK."
7268 (let ((article (gnus-summary-article-number)))
7269 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7270 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7271 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7272 (push (cons article mark) gnus-newsgroup-reads)
7273 ;; Possibly remove from cache, if that is used.
7274 (when gnus-use-cache
7275 (gnus-cache-enter-remove-article article))
7276 ;; Allow the backend to change the mark.
7277 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7278 ;; Check for auto-expiry.
7279 (when (and gnus-newsgroup-auto-expire
7280 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7281 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7282 (= mark gnus-ancient-mark)
7283 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7284 (= mark gnus-duplicate-mark)))
7285 (setq mark gnus-expirable-mark)
7286 (push article gnus-newsgroup-expirable))
7287 ;; Set the mark in the buffer.
7288 (gnus-summary-update-mark mark 'unread)
7291 (defun gnus-summary-mark-article-as-unread (mark)
7292 "Mark the current article quickly as unread with MARK."
7293 (let ((article (gnus-summary-article-number)))
7295 (gnus-error 1 "Unmarkable article")
7296 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7297 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7298 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7299 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7300 (cond ((= mark gnus-ticked-mark)
7301 (push article gnus-newsgroup-marked))
7302 ((= mark gnus-dormant-mark)
7303 (push article gnus-newsgroup-dormant))
7305 (push article gnus-newsgroup-unreads)))
7306 (setq gnus-newsgroup-reads
7307 (delq (assq article gnus-newsgroup-reads)
7308 gnus-newsgroup-reads))
7310 ;; See whether the article is to be put in the cache.
7312 (vectorp (gnus-summary-article-header article))
7314 (gnus-cache-possibly-enter-article
7315 gnus-newsgroup-name article
7316 (gnus-summary-article-header article)
7317 (= mark gnus-ticked-mark)
7318 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7321 (gnus-summary-update-mark mark 'unread))
7324 (defun gnus-summary-mark-article (&optional article mark no-expire)
7325 "Mark ARTICLE with MARK. MARK can be any character.
7326 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7327 `??' (dormant) and `?E' (expirable).
7328 If MARK is nil, then the default character `?D' is used.
7329 If ARTICLE is nil, then the article on the current line will be
7331 ;; The mark might be a string.
7332 (when (stringp mark)
7333 (setq mark (aref mark 0)))
7334 ;; If no mark is given, then we check auto-expiring.
7335 (and (not no-expire)
7336 gnus-newsgroup-auto-expire
7338 (and (gnus-characterp mark)
7339 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7340 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7341 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7342 (= mark gnus-duplicate-mark))))
7343 (setq mark gnus-expirable-mark))
7344 (let* ((mark (or mark gnus-del-mark))
7345 (article (or article (gnus-summary-article-number))))
7347 (error "No article on current line"))
7348 (if (or (= mark gnus-unread-mark)
7349 (= mark gnus-ticked-mark)
7350 (= mark gnus-dormant-mark))
7351 (gnus-mark-article-as-unread article mark)
7352 (gnus-mark-article-as-read article mark))
7354 ;; See whether the article is to be put in the cache.
7356 (not (= mark gnus-canceled-mark))
7357 (vectorp (gnus-summary-article-header article))
7359 (gnus-cache-possibly-enter-article
7360 gnus-newsgroup-name article
7361 (gnus-summary-article-header article)
7362 (= mark gnus-ticked-mark)
7363 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7365 (when (gnus-summary-goto-subject article nil t)
7366 (let ((buffer-read-only nil))
7367 (gnus-summary-show-thread)
7369 (gnus-summary-update-mark mark 'unread)
7372 (defun gnus-summary-update-secondary-mark (article)
7373 "Update the secondary (read, process, cache) mark."
7374 (gnus-summary-update-mark
7375 (cond ((memq article gnus-newsgroup-processable)
7377 ((memq article gnus-newsgroup-cached)
7379 ((memq article gnus-newsgroup-replied)
7381 ((memq article gnus-newsgroup-saved)
7383 (t gnus-unread-mark))
7385 (when (gnus-visual-p 'summary-highlight 'highlight)
7386 (run-hooks 'gnus-summary-update-hook))
7389 (defun gnus-summary-update-mark (mark type)
7390 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7391 (buffer-read-only nil))
7392 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7393 (when (looking-at "\r")
7396 (<= (+ forward (point)) (point-max)))
7397 ;; Go to the right position on the line.
7398 (goto-char (+ forward (point)))
7399 ;; Replace the old mark with the new mark.
7400 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7401 ;; Optionally update the marks by some user rule.
7402 (when (eq type 'unread)
7404 (gnus-data-find (gnus-summary-article-number)) mark)
7405 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7407 (defun gnus-mark-article-as-read (article &optional mark)
7408 "Enter ARTICLE in the pertinent lists and remove it from others."
7409 ;; Make the article expirable.
7410 (let ((mark (or mark gnus-del-mark)))
7411 (if (= mark gnus-expirable-mark)
7412 (push article gnus-newsgroup-expirable)
7413 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7414 ;; Remove from unread and marked lists.
7415 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7416 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7417 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7418 (push (cons article mark) gnus-newsgroup-reads)
7419 ;; Possibly remove from cache, if that is used.
7420 (when gnus-use-cache
7421 (gnus-cache-enter-remove-article article))))
7423 (defun gnus-mark-article-as-unread (article &optional mark)
7424 "Enter ARTICLE in the pertinent lists and remove it from others."
7425 (let ((mark (or mark gnus-ticked-mark)))
7426 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7427 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7428 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7429 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7431 ;; Unsuppress duplicates?
7432 (when gnus-suppress-duplicates
7433 (gnus-dup-unsuppress-article article))
7435 (cond ((= mark gnus-ticked-mark)
7436 (push article gnus-newsgroup-marked))
7437 ((= mark gnus-dormant-mark)
7438 (push article gnus-newsgroup-dormant))
7440 (push article gnus-newsgroup-unreads)))
7441 (setq gnus-newsgroup-reads
7442 (delq (assq article gnus-newsgroup-reads)
7443 gnus-newsgroup-reads))))
7445 (defalias 'gnus-summary-mark-as-unread-forward
7446 'gnus-summary-tick-article-forward)
7447 (make-obsolete 'gnus-summary-mark-as-unread-forward
7448 'gnus-summary-tick-article-forward)
7449 (defun gnus-summary-tick-article-forward (n)
7450 "Tick N articles forwards.
7451 If N is negative, tick backwards instead.
7452 The difference between N and the number of articles ticked is returned."
7454 (gnus-summary-mark-forward n gnus-ticked-mark))
7456 (defalias 'gnus-summary-mark-as-unread-backward
7457 'gnus-summary-tick-article-backward)
7458 (make-obsolete 'gnus-summary-mark-as-unread-backward
7459 'gnus-summary-tick-article-backward)
7460 (defun gnus-summary-tick-article-backward (n)
7461 "Tick N articles backwards.
7462 The difference between N and the number of articles ticked is returned."
7464 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7466 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7467 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7468 (defun gnus-summary-tick-article (&optional article clear-mark)
7469 "Mark current article as unread.
7470 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7471 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7473 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7476 (defun gnus-summary-mark-as-read-forward (n)
7477 "Mark N articles as read forwards.
7478 If N is negative, mark backwards instead.
7479 The difference between N and the actual number of articles marked is
7482 (gnus-summary-mark-forward n gnus-del-mark t))
7484 (defun gnus-summary-mark-as-read-backward (n)
7485 "Mark the N articles as read backwards.
7486 The difference between N and the actual number of articles marked is
7489 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7491 (defun gnus-summary-mark-as-read (&optional article mark)
7492 "Mark current article as read.
7493 ARTICLE specifies the article to be marked as read.
7494 MARK specifies a string to be inserted at the beginning of the line."
7495 (gnus-summary-mark-article article mark))
7497 (defun gnus-summary-clear-mark-forward (n)
7498 "Clear marks from N articles forward.
7499 If N is negative, clear backward instead.
7500 The difference between N and the number of marks cleared is returned."
7502 (gnus-summary-mark-forward n gnus-unread-mark))
7504 (defun gnus-summary-clear-mark-backward (n)
7505 "Clear marks from N articles backward.
7506 The difference between N and the number of marks cleared is returned."
7508 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7510 (defun gnus-summary-mark-unread-as-read ()
7511 "Intended to be used by `gnus-summary-mark-article-hook'."
7512 (when (memq gnus-current-article gnus-newsgroup-unreads)
7513 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7515 (defun gnus-summary-mark-read-and-unread-as-read ()
7516 "Intended to be used by `gnus-summary-mark-article-hook'."
7517 (let ((mark (gnus-summary-article-mark)))
7518 (when (or (gnus-unread-mark-p mark)
7519 (gnus-read-mark-p mark))
7520 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7522 (defun gnus-summary-mark-region-as-read (point mark all)
7523 "Mark all unread articles between point and mark as read.
7524 If given a prefix, mark all articles between point and mark as read,
7525 even ticked and dormant ones."
7526 (interactive "r\nP")
7535 (memq (setq article (gnus-summary-article-number))
7536 gnus-newsgroup-unreads))
7537 (gnus-summary-mark-article article gnus-del-mark))
7539 (gnus-summary-find-next))))))
7541 (defun gnus-summary-mark-below (score mark)
7542 "Mark articles with score less than SCORE with MARK."
7543 (interactive "P\ncMark: ")
7544 (gnus-set-global-variables)
7545 (setq score (if score
7546 (prefix-numeric-value score)
7547 (or gnus-summary-default-score 0)))
7549 (set-buffer gnus-summary-buffer)
7550 (goto-char (point-min))
7553 (and (< (gnus-summary-article-score) score)
7554 (gnus-summary-mark-article nil mark))
7555 (gnus-summary-find-next)))))
7557 (defun gnus-summary-kill-below (&optional score)
7558 "Mark articles with score below SCORE as read."
7560 (gnus-set-global-variables)
7561 (gnus-summary-mark-below score gnus-killed-mark))
7563 (defun gnus-summary-clear-above (&optional score)
7564 "Clear all marks from articles with score above SCORE."
7566 (gnus-set-global-variables)
7567 (gnus-summary-mark-above score gnus-unread-mark))
7569 (defun gnus-summary-tick-above (&optional score)
7570 "Tick all articles with score above SCORE."
7572 (gnus-set-global-variables)
7573 (gnus-summary-mark-above score gnus-ticked-mark))
7575 (defun gnus-summary-mark-above (score mark)
7576 "Mark articles with score over SCORE with MARK."
7577 (interactive "P\ncMark: ")
7578 (gnus-set-global-variables)
7579 (setq score (if score
7580 (prefix-numeric-value score)
7581 (or gnus-summary-default-score 0)))
7583 (set-buffer gnus-summary-buffer)
7584 (goto-char (point-min))
7586 (when (> (gnus-summary-article-score) score)
7587 (gnus-summary-mark-article nil mark))
7589 (gnus-summary-find-next)))))
7591 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7592 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7593 (defun gnus-summary-limit-include-expunged (&optional no-error)
7594 "Display all the hidden articles that were expunged for low scores."
7596 (gnus-set-global-variables)
7597 (let ((buffer-read-only nil))
7598 (let ((scored gnus-newsgroup-scored)
7601 (unless (gnus-summary-goto-subject (caar scored))
7602 (and (setq h (gnus-summary-article-header (caar scored)))
7603 (< (cdar scored) gnus-summary-expunge-below)
7605 (setq scored (cdr scored)))
7607 (when (not no-error)
7608 (error "No expunged articles hidden."))
7609 (goto-char (point-min))
7610 (gnus-summary-prepare-unthreaded (nreverse headers))
7611 (goto-char (point-min))
7612 (gnus-summary-position-point)
7615 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7616 "Mark all unread articles in this newsgroup as read.
7617 If prefix argument ALL is non-nil, ticked and dormant articles will
7618 also be marked as read.
7619 If QUIETLY is non-nil, no questions will be asked.
7620 If TO-HERE is non-nil, it should be a point in the buffer. All
7621 articles before this point will be marked as read.
7622 Note that this function will only catch up the unread article
7623 in the current summary buffer limitation.
7624 The number of articles marked as read is returned."
7626 (gnus-set-global-variables)
7630 (not gnus-interactive-catchup) ;Without confirmation?
7634 "Mark absolutely all articles as read? "
7635 "Mark all unread articles as read? ")))
7637 (not gnus-newsgroup-adaptive)
7638 (not gnus-newsgroup-auto-expire)
7639 (not gnus-suppress-duplicates))
7642 (setq gnus-newsgroup-marked nil
7643 gnus-newsgroup-dormant nil))
7644 (setq gnus-newsgroup-unreads nil))
7645 ;; We actually mark all articles as canceled, which we
7646 ;; have to do when using auto-expiry or adaptive scoring.
7647 (gnus-summary-show-all-threads)
7648 (when (gnus-summary-first-subject (not all))
7650 (if to-here (< (point) to-here) t)
7651 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7652 (gnus-summary-find-next (not all)))))
7653 (gnus-set-mode-line 'summary))
7655 (gnus-summary-position-point)))
7657 (defun gnus-summary-catchup-to-here (&optional all)
7658 "Mark all unticked articles before the current one as read.
7659 If ALL is non-nil, also mark ticked and dormant articles as read."
7661 (gnus-set-global-variables)
7663 (gnus-save-hidden-threads
7664 (let ((beg (point)))
7665 ;; We check that there are unread articles.
7666 (when (or all (gnus-summary-find-prev))
7667 (gnus-summary-catchup all t beg)))))
7668 (gnus-summary-position-point))
7670 (defun gnus-summary-catchup-all (&optional quietly)
7671 "Mark all articles in this newsgroup as read."
7673 (gnus-set-global-variables)
7674 (gnus-summary-catchup t quietly))
7676 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7677 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7678 If prefix argument ALL is non-nil, all articles are marked as read."
7680 (gnus-set-global-variables)
7681 (when (gnus-summary-catchup all quietly nil 'fast)
7682 ;; Select next newsgroup or exit.
7683 (if (eq gnus-auto-select-next 'quietly)
7684 (gnus-summary-next-group nil)
7685 (gnus-summary-exit))))
7687 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7688 "Mark all articles in this newsgroup as read, and then exit."
7690 (gnus-set-global-variables)
7691 (gnus-summary-catchup-and-exit t quietly))
7693 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7694 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7695 "Mark all articles in this group as read and select the next group.
7696 If given a prefix, mark all articles, unread as well as ticked, as
7699 (gnus-set-global-variables)
7701 (gnus-summary-catchup all))
7702 (gnus-summary-next-article t nil nil t))
7704 ;; Thread-based commands.
7706 (defun gnus-summary-articles-in-thread (&optional article)
7707 "Return a list of all articles in the current thread.
7708 If ARTICLE is non-nil, return all articles in the thread that starts
7710 (let* ((article (or article (gnus-summary-article-number)))
7711 (data (gnus-data-find-list article))
7712 (top-level (gnus-data-level (car data)))
7714 (cond ((null gnus-thread-operation-ignore-subject)
7715 (gnus-simplify-subject-re
7716 (mail-header-subject (gnus-data-header (car data)))))
7717 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7718 (gnus-simplify-subject-fuzzy
7719 (mail-header-subject (gnus-data-header (car data)))))
7721 (end-point (save-excursion
7722 (if (gnus-summary-go-to-next-thread)
7723 (point) (point-max))))
7726 (< (gnus-data-pos (car data)) end-point))
7727 (when (or (not top-subject)
7728 (string= top-subject
7729 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7730 (gnus-simplify-subject-fuzzy
7731 (mail-header-subject
7732 (gnus-data-header (car data))))
7733 (gnus-simplify-subject-re
7734 (mail-header-subject
7735 (gnus-data-header (car data)))))))
7736 (push (gnus-data-number (car data)) articles))
7737 (unless (and (setq data (cdr data))
7738 (> (gnus-data-level (car data)) top-level))
7740 ;; Return the list of articles.
7741 (nreverse articles)))
7743 (defun gnus-summary-rethread-current ()
7744 "Rethread the thread the current article is part of."
7746 (gnus-set-global-variables)
7747 (let* ((gnus-show-threads t)
7748 (article (gnus-summary-article-number))
7749 (id (mail-header-id (gnus-summary-article-header)))
7750 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7752 (error "No article on the current line"))
7753 (gnus-rebuild-thread id)
7754 (gnus-summary-goto-subject article)))
7756 (defun gnus-summary-reparent-thread ()
7757 "Make the current article child of the marked (or previous) article.
7759 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7760 is non-nil or the Subject: of both articles are the same."
7762 (unless (not (gnus-group-read-only-p))
7763 (error "The current newsgroup does not support article editing."))
7764 (unless (<= (length gnus-newsgroup-processable) 1)
7765 (error "No more than one article may be marked."))
7766 (save-window-excursion
7767 (let ((gnus-article-buffer " *reparent*")
7768 (current-article (gnus-summary-article-number))
7769 ;; First grab the marked article, otherwise one line up.
7770 (parent-article (if (not (null gnus-newsgroup-processable))
7771 (car gnus-newsgroup-processable)
7773 (if (eq (forward-line -1) 0)
7774 (gnus-summary-article-number)
7775 (error "Beginning of summary buffer."))))))
7776 (unless (not (eq current-article parent-article))
7777 (error "An article may not be self-referential."))
7778 (let ((message-id (mail-header-id
7779 (gnus-summary-article-header parent-article))))
7780 (unless (and message-id (not (equal message-id "")))
7781 (error "No message-id in desired parent."))
7782 (gnus-summary-select-article t t nil current-article)
7783 (set-buffer gnus-original-article-buffer)
7784 (let ((buf (format "%s" (buffer-string))))
7785 (nnheader-temp-write nil
7787 (goto-char (point-min))
7788 (if (search-forward-regexp "^References: " nil t)
7789 (insert message-id " " )
7790 (insert "References: " message-id "\n"))
7791 (unless (gnus-request-replace-article
7792 current-article (car gnus-article-current)
7794 (error "Couldn't replace article."))))
7795 (set-buffer gnus-summary-buffer)
7796 (gnus-summary-unmark-all-processable)
7797 (gnus-summary-rethread-current)
7798 (gnus-message 3 "Article %d is now the child of article %d."
7799 current-article parent-article)))))
7801 (defun gnus-summary-toggle-threads (&optional arg)
7802 "Toggle showing conversation threads.
7803 If ARG is positive number, turn showing conversation threads on."
7805 (gnus-set-global-variables)
7806 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7807 (setq gnus-show-threads
7808 (if (null arg) (not gnus-show-threads)
7809 (> (prefix-numeric-value arg) 0)))
7810 (gnus-summary-prepare)
7811 (gnus-summary-goto-subject current)
7812 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7813 (gnus-summary-position-point)))
7815 (defun gnus-summary-show-all-threads ()
7818 (gnus-set-global-variables)
7820 (let ((buffer-read-only nil))
7821 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7822 (gnus-summary-position-point))
7824 (defun gnus-summary-show-thread ()
7825 "Show thread subtrees.
7826 Returns nil if no thread was there to be shown."
7828 (gnus-set-global-variables)
7829 (let ((buffer-read-only nil)
7831 ;; first goto end then to beg, to have point at beg after let
7832 (end (progn (end-of-line) (point)))
7833 (beg (progn (beginning-of-line) (point))))
7835 ;; Any hidden lines here?
7836 (search-forward "\r" end t)
7837 (subst-char-in-region beg end ?\^M ?\n t)
7839 (gnus-summary-position-point))))
7841 (defun gnus-summary-hide-all-threads ()
7842 "Hide all thread subtrees."
7844 (gnus-set-global-variables)
7846 (goto-char (point-min))
7847 (gnus-summary-hide-thread)
7848 (while (zerop (gnus-summary-next-thread 1 t))
7849 (gnus-summary-hide-thread)))
7850 (gnus-summary-position-point))
7852 (defun gnus-summary-hide-thread ()
7853 "Hide thread subtrees.
7854 Returns nil if no threads were there to be hidden."
7856 (gnus-set-global-variables)
7857 (let ((buffer-read-only nil)
7859 (article (gnus-summary-article-number)))
7861 ;; Go forward until either the buffer ends or the subthread
7863 (when (and (not (eobp))
7864 (or (zerop (gnus-summary-next-thread 1 t))
7865 (goto-char (point-max))))
7867 (if (and (> (point) start)
7868 (search-backward "\n" start t))
7870 (subst-char-in-region start (point) ?\n ?\^M)
7871 (gnus-summary-goto-subject article))
7874 ;;(gnus-summary-position-point)
7877 (defun gnus-summary-go-to-next-thread (&optional previous)
7878 "Go to the same level (or less) next thread.
7879 If PREVIOUS is non-nil, go to previous thread instead.
7880 Return the article number moved to, or nil if moving was impossible."
7881 (let ((level (gnus-summary-thread-level))
7882 (way (if previous -1 1))
7885 (while (and (not (eobp))
7886 (< level (gnus-summary-thread-level)))
7894 (gnus-summary-article-number)
7897 (defun gnus-summary-next-thread (n &optional silent)
7898 "Go to the same level next N'th thread.
7899 If N is negative, search backward instead.
7900 Returns the difference between N and the number of skips actually
7903 If SILENT, don't output messages."
7905 (gnus-set-global-variables)
7906 (let ((backward (< n 0))
7909 (gnus-summary-go-to-next-thread backward))
7912 (gnus-summary-position-point))
7913 (when (and (not silent) (/= 0 n))
7914 (gnus-message 7 "No more threads"))
7917 (defun gnus-summary-prev-thread (n)
7918 "Go to the same level previous N'th thread.
7919 Returns the difference between N and the number of skips actually
7922 (gnus-set-global-variables)
7923 (gnus-summary-next-thread (- n)))
7925 (defun gnus-summary-go-down-thread ()
7926 "Go down one level in the current thread."
7927 (let ((children (gnus-summary-article-children)))
7929 (gnus-summary-goto-subject (car children)))))
7931 (defun gnus-summary-go-up-thread ()
7932 "Go up one level in the current thread."
7933 (let ((parent (gnus-summary-article-parent)))
7935 (gnus-summary-goto-subject parent))))
7937 (defun gnus-summary-down-thread (n)
7938 "Go down thread N steps.
7939 If N is negative, go up instead.
7940 Returns the difference between N and how many steps down that were
7943 (gnus-set-global-variables)
7947 (if up (gnus-summary-go-up-thread)
7948 (gnus-summary-go-down-thread)))
7950 (gnus-summary-position-point)
7952 (gnus-message 7 "Can't go further"))
7955 (defun gnus-summary-up-thread (n)
7956 "Go up thread N steps.
7957 If N is negative, go up instead.
7958 Returns the difference between N and how many steps down that were
7961 (gnus-set-global-variables)
7962 (gnus-summary-down-thread (- n)))
7964 (defun gnus-summary-top-thread ()
7965 "Go to the top of the thread."
7967 (gnus-set-global-variables)
7968 (while (gnus-summary-go-up-thread))
7969 (gnus-summary-article-number))
7971 (defun gnus-summary-kill-thread (&optional unmark)
7972 "Mark articles under current thread as read.
7973 If the prefix argument is positive, remove any kinds of marks.
7974 If the prefix argument is negative, tick articles instead."
7976 (gnus-set-global-variables)
7978 (setq unmark (prefix-numeric-value unmark)))
7979 (let ((articles (gnus-summary-articles-in-thread)))
7981 ;; Expand the thread.
7982 (gnus-summary-show-thread)
7983 ;; Mark all the articles.
7985 (gnus-summary-goto-subject (car articles))
7986 (cond ((null unmark)
7987 (gnus-summary-mark-article-as-read gnus-killed-mark))
7989 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7991 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7992 (setq articles (cdr articles))))
7993 ;; Hide killed subtrees.
7995 gnus-thread-hide-killed
7996 (gnus-summary-hide-thread))
7997 ;; If marked as read, go to next unread subject.
7999 ;; Go to next unread subject.
8000 (gnus-summary-next-subject 1 t)))
8001 (gnus-set-mode-line 'summary))
8003 ;; Summary sorting commands
8005 (defun gnus-summary-sort-by-number (&optional reverse)
8006 "Sort the summary buffer by article number.
8007 Argument REVERSE means reverse order."
8009 (gnus-summary-sort 'number reverse))
8011 (defun gnus-summary-sort-by-author (&optional reverse)
8012 "Sort the summary buffer by author name alphabetically.
8013 If case-fold-search is non-nil, case of letters is ignored.
8014 Argument REVERSE means reverse order."
8016 (gnus-summary-sort 'author reverse))
8018 (defun gnus-summary-sort-by-subject (&optional reverse)
8019 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8020 If case-fold-search is non-nil, case of letters is ignored.
8021 Argument REVERSE means reverse order."
8023 (gnus-summary-sort 'subject reverse))
8025 (defun gnus-summary-sort-by-date (&optional reverse)
8026 "Sort the summary buffer by date.
8027 Argument REVERSE means reverse order."
8029 (gnus-summary-sort 'date reverse))
8031 (defun gnus-summary-sort-by-score (&optional reverse)
8032 "Sort the summary buffer by score.
8033 Argument REVERSE means reverse order."
8035 (gnus-summary-sort 'score reverse))
8037 (defun gnus-summary-sort-by-lines (&optional reverse)
8038 "Sort the summary buffer by article length.
8039 Argument REVERSE means reverse order."
8041 (gnus-summary-sort 'lines reverse))
8043 (defun gnus-summary-sort (predicate reverse)
8044 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8045 (gnus-set-global-variables)
8046 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8047 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8048 (gnus-thread-sort-functions
8054 (gnus-article-sort-functions
8059 (,article t2 t1)))))
8061 (gnus-summary-prepare-hook nil))
8062 ;; We do the sorting by regenerating the threads.
8063 (gnus-summary-prepare)
8064 ;; Hide subthreads if needed.
8065 (when (and gnus-show-threads gnus-thread-hide-subtree)
8066 (gnus-summary-hide-all-threads))))
8068 ;; Summary saving commands.
8070 (defun gnus-summary-save-article (&optional n not-saved)
8071 "Save the current article using the default saver function.
8072 If N is a positive number, save the N next articles.
8073 If N is a negative number, save the N previous articles.
8074 If N is nil and any articles have been marked with the process mark,
8075 save those articles instead.
8076 The variable `gnus-default-article-saver' specifies the saver function."
8078 (gnus-set-global-variables)
8079 (let* ((articles (gnus-summary-work-articles n))
8080 (save-buffer (save-excursion
8081 (nnheader-set-temp-buffer " *Gnus Save*")))
8082 (num (length articles))
8083 header article file)
8085 (setq header (gnus-summary-article-header
8086 (setq article (pop articles))))
8087 (if (not (vectorp header))
8088 ;; This is a pseudo-article.
8089 (if (assq 'name header)
8090 (gnus-copy-file (cdr (assq 'name header)))
8091 (gnus-message 1 "Article %d is unsaveable" article))
8092 ;; This is a real article.
8093 (save-window-excursion
8094 (gnus-summary-select-article t nil nil article))
8096 (set-buffer save-buffer)
8098 (insert-buffer-substring gnus-original-article-buffer))
8099 (setq file (gnus-article-save save-buffer file num))
8100 (gnus-summary-remove-process-mark article)
8102 (gnus-summary-set-saved-mark article))))
8103 (gnus-kill-buffer save-buffer)
8104 (gnus-summary-position-point)
8105 (gnus-set-mode-line 'summary)
8108 (defun gnus-summary-pipe-output (&optional arg)
8109 "Pipe the current article to a subprocess.
8110 If N is a positive number, pipe the N next articles.
8111 If N is a negative number, pipe the N previous articles.
8112 If N is nil and any articles have been marked with the process mark,
8113 pipe those articles instead."
8115 (gnus-set-global-variables)
8116 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8117 (gnus-summary-save-article arg t))
8118 (gnus-configure-windows 'pipe))
8120 (defun gnus-summary-save-article-mail (&optional arg)
8121 "Append the current article to an mail file.
8122 If N is a positive number, save the N next articles.
8123 If N is a negative number, save the N previous articles.
8124 If N is nil and any articles have been marked with the process mark,
8125 save those articles instead."
8127 (gnus-set-global-variables)
8128 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8129 (gnus-summary-save-article arg)))
8131 (defun gnus-summary-save-article-rmail (&optional arg)
8132 "Append the current article to an rmail file.
8133 If N is a positive number, save the N next articles.
8134 If N is a negative number, save the N previous articles.
8135 If N is nil and any articles have been marked with the process mark,
8136 save those articles instead."
8138 (gnus-set-global-variables)
8139 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8140 (gnus-summary-save-article arg)))
8142 (defun gnus-summary-save-article-file (&optional arg)
8143 "Append the current article to a file.
8144 If N is a positive number, save the N next articles.
8145 If N is a negative number, save the N previous articles.
8146 If N is nil and any articles have been marked with the process mark,
8147 save those articles instead."
8149 (gnus-set-global-variables)
8150 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8151 (gnus-summary-save-article arg)))
8153 (defun gnus-summary-write-article-file (&optional arg)
8154 "Write the current article to a file, deleting the previous file.
8155 If N is a positive number, save the N next articles.
8156 If N is a negative number, save the N previous articles.
8157 If N is nil and any articles have been marked with the process mark,
8158 save those articles instead."
8160 (gnus-set-global-variables)
8161 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8162 (gnus-summary-save-article arg)))
8164 (defun gnus-summary-save-article-body-file (&optional arg)
8165 "Append the current article body to a file.
8166 If N is a positive number, save the N next articles.
8167 If N is a negative number, save the N previous articles.
8168 If N is nil and any articles have been marked with the process mark,
8169 save those articles instead."
8171 (gnus-set-global-variables)
8172 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8173 (gnus-summary-save-article arg)))
8175 (defun gnus-summary-pipe-message (program)
8176 "Pipe the current article through PROGRAM."
8177 (interactive "sProgram: ")
8178 (gnus-set-global-variables)
8179 (gnus-summary-select-article)
8180 (let ((mail-header-separator "")
8181 (art-buf (get-buffer gnus-article-buffer)))
8182 (gnus-eval-in-buffer-window gnus-article-buffer
8185 (let ((start (window-start))
8187 (message-pipe-buffer-body program)
8188 (set-window-start (get-buffer-window (current-buffer)) start))))))
8190 (defun gnus-get-split-value (methods)
8191 "Return a value based on the split METHODS."
8192 (let (split-name method result match)
8195 (set-buffer gnus-original-article-buffer)
8197 (nnheader-narrow-to-headers)
8199 (goto-char (point-min))
8200 (setq method (pop methods))
8201 (setq match (car method))
8204 ;; Regular expression.
8206 (re-search-forward match nil t)))
8207 ((gnus-functionp match)
8211 (setq result (funcall match gnus-newsgroup-name))))
8216 (setq result (eval match)))))
8217 (setq split-name (append (cdr method) split-name))
8218 (cond ((stringp result)
8219 (push (expand-file-name
8220 result gnus-article-save-directory)
8223 (setq split-name (append result split-name)))))))))
8226 (defun gnus-valid-move-group-p (group)
8231 (car (gnus-find-method-for-group
8232 (symbol-name group))))
8233 gnus-valid-select-methods))))
8235 (defun gnus-read-move-group-name (prompt default articles prefix)
8236 "Read a group name."
8237 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8238 (minibuffer-confirm-incomplete nil) ; XEmacs
8242 (if (> (length articles) 1)
8243 (format "these %d articles" (length articles))
8248 (gnus-completing-read default prom
8250 'gnus-valid-move-group-p
8252 'gnus-group-history))
8253 ((= 1 (length split-name))
8254 (gnus-completing-read (car split-name) prom
8256 'gnus-valid-move-group-p
8258 'gnus-group-history))
8260 (gnus-completing-read nil prom
8261 (mapcar (lambda (el) (list el))
8262 (nreverse split-name))
8264 'gnus-group-history)))))
8266 (if (or (string= to-newsgroup "")
8267 (string= to-newsgroup prefix))
8268 (setq to-newsgroup default))
8269 (unless to-newsgroup
8270 (error "No group name entered"))
8271 (or (gnus-active to-newsgroup)
8272 (gnus-activate-group to-newsgroup)
8273 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8275 (or (and (gnus-request-create-group
8276 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8277 (gnus-activate-group to-newsgroup nil nil
8278 (gnus-group-name-to-method
8280 (error "Couldn't create group %s" to-newsgroup)))
8281 (error "No such group: %s" to-newsgroup)))
8284 ;; Summary extract commands
8286 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8287 (let ((buffer-read-only nil)
8288 (article (gnus-summary-article-number))
8290 (unless (gnus-summary-goto-subject article)
8291 (error "No such article: %d" article))
8292 (gnus-summary-position-point)
8293 ;; If all commands are to be bunched up on one line, we collect
8295 (unless gnus-view-pseudos-separately
8296 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8299 (setq action (cdr (assq 'action (car ps))))
8300 (setq files (list (cdr (assq 'name (car ps)))))
8301 (while (and ps (cdr ps)
8302 (string= (or action "1")
8303 (or (cdr (assq 'action (cadr ps))) "2")))
8304 (push (cdr (assq 'name (cadr ps))) files)
8305 (setcdr ps (cddr ps)))
8307 (when (not (string-match "%s" action))
8310 (when (assq 'execute (car ps))
8311 (setcdr (assq 'execute (car ps))
8312 (funcall (if (string-match "%s" action)
8319 (gnus-quote-arg-for-sh-or-csh f)))
8321 (setq ps (cdr ps)))))
8322 (if (and gnus-view-pseudos (not not-view))
8324 (when (assq 'execute (car pslist))
8325 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8326 (eq gnus-view-pseudos 'not-confirm)))
8327 (setq pslist (cdr pslist)))
8330 (setq after-article (or (cdr (assq 'article (car pslist)))
8331 (gnus-summary-article-number)))
8332 (gnus-summary-goto-subject after-article)
8335 (insert " " (file-name-nondirectory
8336 (cdr (assq 'name (car pslist))))
8337 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8339 (forward-line -1) ; back to `b'
8340 (gnus-add-text-properties
8341 b (1- e) (list 'gnus-number gnus-reffed-article-number
8342 gnus-mouse-face-prop gnus-mouse-face))
8344 after-article gnus-reffed-article-number
8345 gnus-unread-mark b (car pslist) 0 (- e b))
8346 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8347 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8348 (setq pslist (cdr pslist)))))))
8350 (defun gnus-pseudos< (p1 p2)
8351 (let ((c1 (cdr (assq 'action p1)))
8352 (c2 (cdr (assq 'action p2))))
8353 (and c1 c2 (string< c1 c2))))
8355 (defun gnus-request-pseudo-article (props)
8356 (cond ((assq 'execute props)
8357 (gnus-execute-command (cdr (assq 'execute props)))))
8358 (let ((gnus-current-article (gnus-summary-article-number)))
8359 (run-hooks 'gnus-mark-article-hook)))
8361 (defun gnus-execute-command (command &optional automatic)
8363 (gnus-article-setup-buffer)
8364 (set-buffer gnus-article-buffer)
8365 (setq buffer-read-only nil)
8366 (let ((command (if automatic command (read-string "Command: " command))))
8368 (insert "$ " command "\n\n")
8369 (if gnus-view-pseudo-asynchronously
8370 (start-process "gnus-execute" (current-buffer) shell-file-name
8371 shell-command-switch command)
8372 (call-process shell-file-name nil t nil
8373 shell-command-switch command)))))
8375 ;; Summary kill commands.
8377 (defun gnus-summary-edit-global-kill (article)
8378 "Edit the \"global\" kill file."
8379 (interactive (list (gnus-summary-article-number)))
8380 (gnus-set-global-variables)
8381 (gnus-group-edit-global-kill article))
8383 (defun gnus-summary-edit-local-kill ()
8384 "Edit a local kill file applied to the current newsgroup."
8386 (gnus-set-global-variables)
8387 (setq gnus-current-headers (gnus-summary-article-header))
8388 (gnus-set-global-variables)
8389 (gnus-group-edit-local-kill
8390 (gnus-summary-article-number) gnus-newsgroup-name))
8394 (defun gnus-read-header (id &optional header)
8395 "Read the headers of article ID and enter them into the Gnus system."
8396 (let ((group gnus-newsgroup-name)
8397 (gnus-override-method
8398 (and (gnus-news-group-p gnus-newsgroup-name)
8399 gnus-refer-article-method))
8401 ;; First we check to see whether the header in question is already
8404 ;; This is a Message-ID.
8405 (setq header (or header (gnus-id-to-header id)))
8406 ;; This is an article number.
8407 (setq header (or header (gnus-summary-article-header id))))
8409 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8410 ;; We have found the header.
8412 ;; We have to really fetch the header to this article.
8414 (set-buffer nntp-server-buffer)
8415 (when (setq where (gnus-request-head id group))
8416 (nnheader-fold-continuation-lines)
8417 (goto-char (point-max))
8419 (goto-char (point-min))
8423 ((cdr where) (cdr where))
8424 (header (mail-header-number header))
8425 (t gnus-reffed-article-number))
8427 (insert " Article retrieved.\n"))
8429 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8430 () ; Malformed head.
8431 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8432 (when (and (stringp id)
8433 (not (string= (gnus-group-real-name group)
8435 ;; If we fetched by Message-ID and the article came
8436 ;; from a different group, we fudge some bogus article
8437 ;; numbers for this article.
8438 (mail-header-set-number header gnus-reffed-article-number))
8440 (set-buffer gnus-summary-buffer)
8441 (decf gnus-reffed-article-number)
8442 (gnus-remove-header (mail-header-number header))
8443 (push header gnus-newsgroup-headers)
8444 (setq gnus-current-headers header)
8445 (push (mail-header-number header) gnus-newsgroup-limit)))
8448 (defun gnus-remove-header (number)
8449 "Remove header NUMBER from `gnus-newsgroup-headers'."
8450 (if (and gnus-newsgroup-headers
8451 (= number (mail-header-number (car gnus-newsgroup-headers))))
8452 (pop gnus-newsgroup-headers)
8453 (let ((headers gnus-newsgroup-headers))
8454 (while (and (cdr headers)
8455 (not (= number (mail-header-number (cadr headers)))))
8458 (setcdr headers (cddr headers))))))
8461 ;;; summary highlights
8464 (defun gnus-highlight-selected-summary ()
8465 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8466 ;; Highlight selected article in summary buffer
8467 (when gnus-summary-selected-face
8469 (let* ((beg (progn (beginning-of-line) (point)))
8470 (end (progn (end-of-line) (point)))
8471 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8472 (from (if (get-text-property beg gnus-mouse-face-prop)
8474 (or (next-single-property-change
8475 beg gnus-mouse-face-prop nil end)
8480 (or (next-single-property-change
8481 from gnus-mouse-face-prop nil end)
8483 ;; If no mouse-face prop on line we will have to = from = end,
8484 ;; so we highlight the entire line instead.
8485 (when (= (+ to 2) from)
8488 (if gnus-newsgroup-selected-overlay
8489 ;; Move old overlay.
8491 gnus-newsgroup-selected-overlay from to (current-buffer))
8492 ;; Create new overlay.
8494 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8495 'face gnus-summary-selected-face))))))
8497 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8498 (defun gnus-summary-highlight-line ()
8499 "Highlight current line according to `gnus-summary-highlight'."
8500 (let* ((list gnus-summary-highlight)
8502 (end (progn (end-of-line) (point)))
8503 ;; now find out where the line starts and leave point there.
8504 (beg (progn (beginning-of-line) (point)))
8505 (article (gnus-summary-article-number))
8506 (score (or (cdr (assq (or article gnus-current-article)
8507 gnus-newsgroup-scored))
8508 gnus-summary-default-score 0))
8509 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8510 (inhibit-read-only t))
8511 ;; Eval the cars of the lists until we find a match.
8512 (let ((default gnus-summary-default-score))
8514 (not (eval (caar list))))
8515 (setq list (cdr list))))
8516 (let ((face (cdar list)))
8517 (unless (eq face (get-text-property beg 'face))
8518 (gnus-put-text-property
8520 (setq face (if (boundp face) (symbol-value face) face)))
8521 (when gnus-summary-highlight-line-function
8522 (funcall gnus-summary-highlight-line-function article face))))
8525 (defun gnus-update-read-articles (group unread)
8526 "Update the list of read articles in GROUP."
8527 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8528 (entry (gnus-gethash group gnus-newsrc-hashtb))
8529 (info (nth 2 entry))
8531 (unread (sort (copy-sequence unread) '<))
8533 (if (or (not info) (not active))
8534 ;; There is no info on this group if it was, in fact,
8535 ;; killed. Gnus stores no information on killed groups, so
8536 ;; there's nothing to be done.
8537 ;; One could store the information somewhere temporarily,
8538 ;; perhaps... Hmmm...
8540 ;; Remove any negative articles numbers.
8541 (while (and unread (< (car unread) 0))
8542 (setq unread (cdr unread)))
8543 ;; Remove any expired article numbers
8544 (while (and unread (< (car unread) (car active)))
8545 (setq unread (cdr unread)))
8546 ;; Compute the ranges of read articles by looking at the list of
8549 (when (/= (car unread) prev)
8550 (push (if (= prev (1- (car unread))) prev
8551 (cons prev (1- (car unread))))
8553 (setq prev (1+ (car unread)))
8554 (setq unread (cdr unread)))
8555 (when (<= prev (cdr active))
8556 (push (cons prev (cdr active)) read))
8558 (set-buffer gnus-group-buffer)
8561 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8562 (gnus-info-set-read ',info ',(gnus-info-read info))
8563 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8564 (gnus-group-update-group ,group t))))
8565 ;; Enter this list into the group info.
8567 info (if (> (length read) 1) (nreverse read) read))
8568 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8569 (gnus-get-unread-articles-in-group info (gnus-active group))
8572 (defun gnus-offer-save-summaries ()
8573 "Offer to save all active summary buffers."
8575 (let ((buflist (buffer-list))
8577 ;; Go through all buffers and find all summaries.
8579 (and (setq bufname (buffer-name (car buflist)))
8580 (string-match "Summary" bufname)
8582 (set-buffer bufname)
8583 ;; We check that this is, indeed, a summary buffer.
8584 (and (eq major-mode 'gnus-summary-mode)
8585 ;; Also make sure this isn't bogus.
8586 gnus-newsgroup-prepared
8587 ;; Also make sure that this isn't a dead summary buffer.
8588 (not gnus-dead-summary-mode)))
8589 (push bufname buffers))
8590 (setq buflist (cdr buflist)))
8591 ;; Go through all these summary buffers and offer to save them.
8594 "Update summary buffer %s? "
8595 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8600 (run-hooks 'gnus-sum-load-hook)
8602 ;;; gnus-sum.el ends here