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.
28 (eval-when-compile (require 'cl))
37 (defcustom gnus-kill-summary-on-exit t
38 "*If non-nil, kill the summary buffer when you exit from it.
39 If nil, the summary will become a \"*Dead Summary*\" buffer, and
40 it will be killed sometime later."
41 :group 'gnus-summary-exit
44 (defcustom gnus-fetch-old-headers nil
45 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
46 If an unread article in the group refers to an older, already read (or
47 just marked as read) article, the old article will not normally be
48 displayed in the Summary buffer. If this variable is non-nil, Gnus
49 will attempt to grab the headers to the old articles, and thereby
50 build complete threads. If it has the value `some', only enough
51 headers to connect otherwise loose threads will be displayed.
52 This variable can also be a number. In that case, no more than that
53 number of old headers will be fetched.
55 The server has to support NOV for any of this to work."
57 :type '(choice (const :tag "off" nil)
60 (sexp :menu-tag "other" t)))
62 (defcustom gnus-summary-make-false-root 'adopt
63 "*nil means that Gnus won't gather loose threads.
64 If the root of a thread has expired or been read in a previous
65 session, the information necessary to build a complete thread has been
66 lost. Instead of having many small sub-threads from this original thread
67 scattered all over the summary buffer, Gnus can gather them.
69 If non-nil, Gnus will try to gather all loose sub-threads from an
70 original thread into one large thread.
72 If this variable is non-nil, it should be one of `none', `adopt',
75 If this variable is `none', Gnus will not make a false root, but just
76 present the sub-threads after another.
77 If this variable is `dummy', Gnus will create a dummy root that will
78 have all the sub-threads as children.
79 If this variable is `adopt', Gnus will make one of the \"children\"
80 the parent and mark all the step-children as such.
81 If this variable is `empty', the \"children\" are printed with empty
82 subject fields. (Or rather, they will be printed with a string
83 given by the `gnus-summary-same-subject' variable.)"
85 :type '(choice (const :tag "off" nil)
91 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
92 "*A regexp to match subjects to be excluded from loose thread gathering.
93 As loose thread gathering is done on subjects only, that means that
94 there can be many false gatherings performed. By rooting out certain
95 common subjects, gathering might become saner."
99 (defcustom gnus-summary-gather-subject-limit nil
100 "*Maximum length of subject comparisons when gathering loose threads.
101 Use nil to compare full subjects. Setting this variable to a low
102 number will help gather threads that have been corrupted by
103 newsreaders chopping off subject lines, but it might also mean that
104 unrelated articles that have subject that happen to begin with the
105 same few characters will be incorrectly gathered.
107 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
110 :type '(choice (const :tag "off" nil)
112 (sexp :menu-tag "on" t)))
114 (defcustom gnus-simplify-ignored-prefixes nil
115 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
117 :type '(choice (const :tag "off" nil)
120 (defcustom gnus-build-sparse-threads nil
121 "*If non-nil, fill in the gaps in threads.
122 If `some', only fill in the gaps that are needed to tie loose threads
123 together. If `more', fill in all leaf nodes that Gnus can find. If
124 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
126 :type '(choice (const :tag "off" nil)
129 (sexp :menu-tag "all" t)))
131 (defcustom gnus-summary-thread-gathering-function
132 'gnus-gather-threads-by-subject
133 "Function used for gathering loose threads.
134 There are two pre-defined functions: `gnus-gather-threads-by-subject',
135 which only takes Subjects into consideration; and
136 `gnus-gather-threads-by-references', which compared the References
137 headers of the articles to find matches."
139 :type '(radio (function-item gnus-gather-threads-by-subject)
140 (function-item gnus-gather-threads-by-references)
141 (function :tag "other")))
143 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
144 (defcustom gnus-summary-same-subject ""
145 "*String indicating that the current article has the same subject as the previous.
146 This variable will only be used if the value of
147 `gnus-summary-make-false-root' is `empty'."
148 :group 'gnus-summary-format
151 (defcustom gnus-summary-goto-unread t
152 "*If t, marking commands will go to the next unread article.
153 If `never', commands that usually go to the next unread article, will
154 go to the next article, whether it is read or not.
155 If nil, only the marking commands will go to the next (un)read article."
156 :group 'gnus-summary-marks
157 :link '(custom-manual "(gnus)Setting Marks")
158 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "on" t)))
162 (defcustom gnus-summary-default-score 0
163 "*Default article score level.
164 All scores generated by the score files will be added to this score.
165 If this variable is nil, scoring will be disabled."
166 :group 'gnus-score-default
167 :type '(choice (const :tag "disable")
170 (defcustom gnus-summary-zcore-fuzz 0
171 "*Fuzziness factor for the zcore in the summary buffer.
172 Articles with scores closer than this to `gnus-summary-default-score'
174 :group 'gnus-summary-format
177 (defcustom gnus-simplify-subject-fuzzy-regexp nil
178 "*Strings to be removed when doing fuzzy matches.
179 This can either be a regular expression or list of regular expressions
180 that will be removed from subject strings if fuzzy subject
181 simplification is selected."
183 :type '(repeat regexp))
185 (defcustom gnus-show-threads t
186 "*If non-nil, display threads in summary mode."
190 (defcustom gnus-thread-hide-subtree nil
191 "*If non-nil, hide all threads initially.
192 If threads are hidden, you have to run the command
193 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
194 to expose hidden threads."
198 (defcustom gnus-thread-hide-killed t
199 "*If non-nil, hide killed threads automatically."
203 (defcustom gnus-thread-ignore-subject nil
204 "*If non-nil, ignore subjects and do all threading based on the Reference header.
205 If nil, which is the default, articles that have different subjects
206 from their parents will start separate threads."
210 (defcustom gnus-thread-operation-ignore-subject t
211 "*If non-nil, subjects will be ignored when doing thread commands.
212 This affects commands like `gnus-summary-kill-thread' and
213 `gnus-summary-lower-thread'.
215 If this variable is nil, articles in the same thread with different
216 subjects will not be included in the operation in question. If this
217 variable is `fuzzy', only articles that have subjects that are fuzzily
218 equal will be included."
220 :type '(choice (const :tag "off" nil)
224 (defcustom gnus-thread-indent-level 4
225 "*Number that says how much each sub-thread should be indented."
229 (defcustom gnus-auto-extend-newsgroup t
230 "*If non-nil, extend newsgroup forward and backward when requested."
231 :group 'gnus-summary-choose
234 (defcustom gnus-auto-select-first t
235 "*If nil, don't select the first unread article when entering a group.
236 If this variable is `best', select the highest-scored unread article
237 in the group. If neither nil nor `best', select the first unread
240 If you want to prevent automatic selection of the first unread article
241 in some newsgroups, set the variable to nil in
242 `gnus-select-group-hook'."
243 :group 'gnus-group-select
244 :type '(choice (const :tag "none" nil)
246 (sexp :menu-tag "first" t)))
248 (defcustom gnus-auto-select-next t
249 "*If non-nil, offer to go to the next group from the end of the previous.
250 If the value is t and the next newsgroup is empty, Gnus will exit
251 summary mode and go back to group mode. If the value is neither nil
252 nor t, Gnus will select the following unread newsgroup. In
253 particular, if the value is the symbol `quietly', the next unread
254 newsgroup will be selected without any confirmation, and if it is
255 `almost-quietly', the next group will be selected without any
256 confirmation if you are located on the last article in the group.
257 Finally, if this variable is `slightly-quietly', the `Z n' command
258 will go to the next group without confirmation."
259 :group 'gnus-summary-maneuvering
260 :type '(choice (const :tag "off" nil)
262 (const almost-quietly)
263 (const slightly-quietly)
264 (sexp :menu-tag "on" t)))
266 (defcustom gnus-auto-select-same nil
267 "*If non-nil, select the next article with the same subject."
268 :group 'gnus-summary-maneuvering
271 (defcustom gnus-summary-check-current nil
272 "*If non-nil, consider the current article when moving.
273 The \"unread\" movement commands will stay on the same line if the
274 current article is unread."
275 :group 'gnus-summary-maneuvering
278 (defcustom gnus-auto-center-summary t
279 "*If non-nil, always center the current summary buffer.
280 In particular, if `vertical' do only vertical recentering. If non-nil
281 and non-`vertical', do both horizontal and vertical recentering."
282 :group 'gnus-summary-maneuvering
283 :type '(choice (const :tag "none" nil)
285 (sexp :menu-tag "both" t)))
287 (defcustom gnus-show-all-headers nil
288 "*If non-nil, don't hide any headers."
289 :group 'gnus-article-hiding
290 :group 'gnus-article-headers
293 (defcustom gnus-summary-ignore-duplicates nil
294 "*If non-nil, ignore articles with identical Message-ID headers."
298 (defcustom gnus-single-article-buffer t
299 "*If non-nil, display all articles in the same buffer.
300 If nil, each group will get its own article buffer."
301 :group 'gnus-article-various
304 (defcustom gnus-break-pages t
305 "*If non-nil, do page breaking on articles.
306 The page delimiter is specified by the `gnus-page-delimiter'
308 :group 'gnus-article-various
311 (defcustom gnus-show-mime nil
312 "*If non-nil, do mime processing of articles.
313 The articles will simply be fed to the function given by
314 `gnus-show-mime-method'."
315 :group 'gnus-article-mime
318 (defcustom gnus-move-split-methods nil
319 "*Variable used to suggest where articles are to be moved to.
320 It uses the same syntax as the `gnus-split-methods' variable."
321 :group 'gnus-summary-mail
322 :type '(repeat (choice (list function)
323 (cons regexp (repeat string))
326 (defcustom gnus-unread-mark ?
327 "*Mark used for unread articles."
328 :group 'gnus-summary-marks
331 (defcustom gnus-ticked-mark ?!
332 "*Mark used for ticked articles."
333 :group 'gnus-summary-marks
336 (defcustom gnus-dormant-mark ??
337 "*Mark used for dormant articles."
338 :group 'gnus-summary-marks
341 (defcustom gnus-del-mark ?r
342 "*Mark used for del'd articles."
343 :group 'gnus-summary-marks
346 (defcustom gnus-read-mark ?R
347 "*Mark used for read articles."
348 :group 'gnus-summary-marks
351 (defcustom gnus-expirable-mark ?E
352 "*Mark used for expirable articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-killed-mark ?K
357 "*Mark used for killed articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-souped-mark ?F
362 "*Mark used for killed articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-kill-file-mark ?X
367 "*Mark used for articles killed by kill files."
368 :group 'gnus-summary-marks
371 (defcustom gnus-low-score-mark ?Y
372 "*Mark used for articles with a low score."
373 :group 'gnus-summary-marks
376 (defcustom gnus-catchup-mark ?C
377 "*Mark used for articles that are caught up."
378 :group 'gnus-summary-marks
381 (defcustom gnus-replied-mark ?A
382 "*Mark used for articles that have been replied to."
383 :group 'gnus-summary-marks
386 (defcustom gnus-cached-mark ?*
387 "*Mark used for articles that are in the cache."
388 :group 'gnus-summary-marks
391 (defcustom gnus-saved-mark ?S
392 "*Mark used for articles that have been saved to."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ancient-mark ?O
397 "*Mark used for ancient articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-sparse-mark ?Q
402 "*Mark used for sparsely reffed articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-canceled-mark ?G
407 "*Mark used for canceled articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-duplicate-mark ?M
412 "*Mark used for duplicate articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-undownloaded-mark ?@
417 "*Mark used for articles that weren't downloaded."
418 :group 'gnus-summary-marks
421 (defcustom gnus-downloadable-mark ?%
422 "*Mark used for articles that are to be downloaded."
423 :group 'gnus-summary-marks
426 (defcustom gnus-score-over-mark ?+
427 "*Score mark used for articles with high scores."
428 :group 'gnus-summary-marks
431 (defcustom gnus-score-below-mark ?-
432 "*Score mark used for articles with low scores."
433 :group 'gnus-summary-marks
436 (defcustom gnus-empty-thread-mark ?
437 "*There is no thread under the article."
438 :group 'gnus-summary-marks
441 (defcustom gnus-not-empty-thread-mark ?=
442 "*There is a thread under the article."
443 :group 'gnus-summary-marks
446 (defcustom gnus-view-pseudo-asynchronously nil
447 "*If non-nil, Gnus will view pseudo-articles asynchronously."
448 :group 'gnus-extract-view
451 (defcustom gnus-view-pseudos nil
452 "*If `automatic', pseudo-articles will be viewed automatically.
453 If `not-confirm', pseudos will be viewed automatically, and the user
454 will not be asked to confirm the command."
455 :group 'gnus-extract-view
456 :type '(choice (const :tag "off" nil)
458 (const not-confirm)))
460 (defcustom gnus-view-pseudos-separately t
461 "*If non-nil, one pseudo-article will be created for each file to be viewed.
462 If nil, all files that use the same viewing command will be given as a
463 list of parameters to that command."
464 :group 'gnus-extract-view
467 (defcustom gnus-insert-pseudo-articles t
468 "*If non-nil, insert pseudo-articles when decoding articles."
469 :group 'gnus-extract-view
472 (defcustom gnus-summary-dummy-line-format
474 "*The format specification for the dummy roots in the summary buffer.
475 It works along the same lines as a normal formatting string,
476 with some simple extensions.
479 :group 'gnus-threading
482 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
483 "*The format specification for the summary mode line.
484 It works along the same lines as a normal formatting string,
485 with some simple extensions:
488 %p Unprefixed group name
489 %A Current article number
491 %U Number of unread articles in the group
492 %e Number of unselected articles in the group
493 %Z A string with unread/unselected article counts
494 %g Shortish group name
495 %S Subject of the current article
497 %s Current score file name
498 %d Number of dormant articles
499 %r Number of articles that have been marked as read in this session
500 %E Number of articles expunged by the score files"
501 :group 'gnus-summary-format
504 (defcustom gnus-summary-mark-below 0
505 "*Mark all articles with a score below this variable as read.
506 This variable is local to each summary buffer and usually set by the
508 :group 'gnus-score-default
511 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
512 "*List of functions used for sorting articles in the summary buffer.
513 This variable is only used when not using a threaded display."
514 :group 'gnus-summary-sort
515 :type '(repeat (choice (function-item gnus-article-sort-by-number)
516 (function-item gnus-article-sort-by-author)
517 (function-item gnus-article-sort-by-subject)
518 (function-item gnus-article-sort-by-date)
519 (function-item gnus-article-sort-by-score)
520 (function :tag "other"))))
522 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
523 "*List of functions used for sorting threads in the summary buffer.
524 By default, threads are sorted by article number.
526 Each function takes two threads and return non-nil if the first thread
527 should be sorted before the other. If you use more than one function,
528 the primary sort function should be the last. You should probably
529 always include `gnus-thread-sort-by-number' in the list of sorting
530 functions -- preferably first.
532 Ready-made functions include `gnus-thread-sort-by-number',
533 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
534 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
535 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
536 :group 'gnus-summary-sort
537 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
538 (function-item gnus-thread-sort-by-author)
539 (function-item gnus-thread-sort-by-subject)
540 (function-item gnus-thread-sort-by-date)
541 (function-item gnus-thread-sort-by-score)
542 (function-item gnus-thread-sort-by-total-score)
543 (function :tag "other"))))
545 (defcustom gnus-thread-score-function '+
546 "*Function used for calculating the total score of a thread.
548 The function is called with the scores of the article and each
549 subthread and should then return the score of the thread.
551 Some functions you can use are `+', `max', or `min'."
552 :group 'gnus-summary-sort
555 (defcustom gnus-summary-expunge-below nil
556 "All articles that have a score less than this variable will be expunged."
557 :group 'gnus-score-default
558 :type '(choice (const :tag "off" nil)
561 (defcustom gnus-thread-expunge-below nil
562 "All threads that have a total score less than this variable will be expunged.
563 See `gnus-thread-score-function' for en explanation of what a
564 \"thread score\" is."
565 :group 'gnus-treading
566 :group 'gnus-score-default
567 :type '(choice (const :tag "off" nil)
570 (defcustom gnus-summary-mode-hook nil
571 "*A hook for Gnus summary mode.
572 This hook is run before any variables are set in the summary buffer."
573 :group 'gnus-summary-various
576 (defcustom gnus-summary-menu-hook nil
577 "*Hook run after the creation of the summary mode menu."
578 :group 'gnus-summary-visual
581 (defcustom gnus-summary-exit-hook nil
582 "*A hook called on exit from the summary buffer.
583 It will be called with point in the group buffer."
584 :group 'gnus-summary-exit
587 (defcustom gnus-summary-prepare-hook nil
588 "*A hook called after the summary buffer has been generated.
589 If you want to modify the summary buffer, you can use this hook."
590 :group 'gnus-summary-various
593 (defcustom gnus-summary-generate-hook nil
594 "*A hook run just before generating the summary buffer.
595 This hook is commonly used to customize threading variables and the
597 :group 'gnus-summary-various
600 (defcustom gnus-select-group-hook nil
601 "*A hook called when a newsgroup is selected.
603 If you'd like to simplify subjects like the
604 `gnus-summary-next-same-subject' command does, you can use the
607 (setq gnus-select-group-hook
610 (mapcar (lambda (header)
611 (mail-header-set-subject
613 (gnus-simplify-subject
614 (mail-header-subject header) 're-only)))
615 gnus-newsgroup-headers))))"
616 :group 'gnus-group-select
619 (defcustom gnus-select-article-hook nil
620 "*A hook called when an article is selected."
621 :group 'gnus-summary-choose
624 (defcustom gnus-visual-mark-article-hook
625 (list 'gnus-highlight-selected-summary)
626 "*Hook run after selecting an article in the summary buffer.
627 It is meant to be used for highlighting the article in some way. It
628 is not run if `gnus-visual' is nil."
629 :group 'gnus-summary-visual
632 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
633 (defcustom gnus-structured-field-decoder 'identity
634 "Function to decode non-ASCII characters in structured field for summary."
638 (defcustom gnus-unstructured-field-decoder 'identity
639 "Function to decode non-ASCII characters in unstructured field for summary."
643 (defcustom gnus-parse-headers-hook
644 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
645 "*A hook called before parsing the headers."
649 (defcustom gnus-exit-group-hook nil
650 "*A hook called when exiting (not quitting) summary mode."
654 (defcustom gnus-summary-update-hook
655 (list 'gnus-summary-highlight-line)
656 "*A hook called when a summary line is changed.
657 The hook will not be called if `gnus-visual' is nil.
659 The default function `gnus-summary-highlight-line' will
660 highlight the line according to the `gnus-summary-highlight'
662 :group 'gnus-summary-visual
665 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
666 "*A hook called when an article is selected for the first time.
667 The hook is intended to mark an article as read (or unread)
668 automatically when it is selected."
669 :group 'gnus-summary-choose
672 (defcustom gnus-group-no-more-groups-hook nil
673 "*A hook run when returning to group mode having no more (unread) groups."
674 :group 'gnus-group-select
677 (defcustom gnus-ps-print-hook nil
678 "*A hook run before ps-printing something from Gnus."
682 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
683 "Face used for highlighting the current article in the summary buffer."
684 :group 'gnus-summary-visual
687 (defcustom gnus-summary-highlight
688 '(((= mark gnus-canceled-mark)
689 . gnus-summary-cancelled-face)
690 ((and (> score default)
691 (or (= mark gnus-dormant-mark)
692 (= mark gnus-ticked-mark)))
693 . gnus-summary-high-ticked-face)
694 ((and (< score default)
695 (or (= mark gnus-dormant-mark)
696 (= mark gnus-ticked-mark)))
697 . gnus-summary-low-ticked-face)
698 ((or (= mark gnus-dormant-mark)
699 (= mark gnus-ticked-mark))
700 . gnus-summary-normal-ticked-face)
701 ((and (> score default) (= mark gnus-ancient-mark))
702 . gnus-summary-high-ancient-face)
703 ((and (< score default) (= mark gnus-ancient-mark))
704 . gnus-summary-low-ancient-face)
705 ((= mark gnus-ancient-mark)
706 . gnus-summary-normal-ancient-face)
707 ((and (> score default) (= mark gnus-unread-mark))
708 . gnus-summary-high-unread-face)
709 ((and (< score default) (= mark gnus-unread-mark))
710 . gnus-summary-low-unread-face)
711 ((and (= mark gnus-unread-mark))
712 . gnus-summary-normal-unread-face)
714 . gnus-summary-high-read-face)
716 . gnus-summary-low-read-face)
718 . gnus-summary-normal-read-face))
719 "Controls the highlighting of summary buffer lines.
721 A list of (FORM . FACE) pairs. When deciding how a a particular
722 summary line should be displayed, each form is evaluated. The content
723 of the face field after the first true form is used. You can change
724 how those summary lines are displayed, by editing the face field.
726 You can use the following variables in the FORM field.
728 score: The articles score
729 default: The default article score.
730 below: The score below which articles are automatically marked as read.
731 mark: The articles mark."
732 :group 'gnus-summary-visual
733 :type '(repeat (cons (sexp :tag "Form" nil)
737 ;;; Internal variables
739 (defvar gnus-scores-exclude-files nil)
740 (defvar gnus-page-broken nil)
742 (defvar gnus-original-article nil)
743 (defvar gnus-article-internal-prepare-hook nil)
744 (defvar gnus-newsgroup-process-stack nil)
746 (defvar gnus-thread-indent-array nil)
747 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
749 ;; Avoid highlighting in kill files.
750 (defvar gnus-summary-inhibit-highlight nil)
751 (defvar gnus-newsgroup-selected-overlay nil)
752 (defvar gnus-inhibit-limiting nil)
753 (defvar gnus-newsgroup-adaptive-score-file nil)
754 (defvar gnus-current-score-file nil)
755 (defvar gnus-current-move-group nil)
756 (defvar gnus-current-copy-group nil)
757 (defvar gnus-current-crosspost-group nil)
759 (defvar gnus-newsgroup-dependencies nil)
760 (defvar gnus-newsgroup-adaptive nil)
761 (defvar gnus-summary-display-article-function nil)
762 (defvar gnus-summary-highlight-line-function nil
763 "Function called after highlighting a summary line.")
765 (defvar gnus-summary-line-format-alist
766 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
767 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
768 (?s gnus-tmp-subject-or-nil ?s)
769 (?n gnus-tmp-name ?s)
770 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
772 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
774 (?F gnus-tmp-from ?s)
775 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
776 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
777 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
778 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
779 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
780 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
781 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
782 (?L gnus-tmp-lines ?d)
783 (?I gnus-tmp-indentation ?s)
784 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
785 (?R gnus-tmp-replied ?c)
786 (?\[ gnus-tmp-opening-bracket ?c)
787 (?\] gnus-tmp-closing-bracket ?c)
788 (?\> (make-string gnus-tmp-level ? ) ?s)
789 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
790 (?i gnus-tmp-score ?d)
791 (?z gnus-tmp-score-char ?c)
792 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
793 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
794 (?U gnus-tmp-unread ?c)
795 (?t (gnus-summary-number-of-articles-in-thread
796 (and (boundp 'thread) (car thread)) gnus-tmp-level)
798 (?e (gnus-summary-number-of-articles-in-thread
799 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
801 (?u gnus-tmp-user-defined ?s)
802 (?P (gnus-pick-line-number) ?d))
803 "An alist of format specifications that can appear in summary lines,
804 and what variables they correspond with, along with the type of the
805 variable (string, integer, character, etc).")
807 (defvar gnus-summary-dummy-line-format-alist
808 `((?S gnus-tmp-subject ?s)
809 (?N gnus-tmp-number ?d)
810 (?u gnus-tmp-user-defined ?s)))
812 (defvar gnus-summary-mode-line-format-alist
813 `((?G gnus-tmp-group-name ?s)
814 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
815 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
816 (?A gnus-tmp-article-number ?d)
817 (?Z gnus-tmp-unread-and-unselected ?s)
819 (?U gnus-tmp-unread-and-unticked ?d)
820 (?S gnus-tmp-subject ?s)
821 (?e gnus-tmp-unselected ?d)
822 (?u gnus-tmp-user-defined ?s)
823 (?d (length gnus-newsgroup-dormant) ?d)
824 (?t (length gnus-newsgroup-marked) ?d)
825 (?r (length gnus-newsgroup-reads) ?d)
826 (?E gnus-newsgroup-expunged-tally ?d)
827 (?s (gnus-current-score-file-nondirectory) ?s)))
829 (defvar gnus-last-search-regexp nil
830 "Default regexp for article search command.")
832 (defvar gnus-last-shell-command nil
833 "Default shell command on article.")
835 (defvar gnus-newsgroup-begin nil)
836 (defvar gnus-newsgroup-end nil)
837 (defvar gnus-newsgroup-last-rmail nil)
838 (defvar gnus-newsgroup-last-mail nil)
839 (defvar gnus-newsgroup-last-folder nil)
840 (defvar gnus-newsgroup-last-file nil)
841 (defvar gnus-newsgroup-auto-expire nil)
842 (defvar gnus-newsgroup-active nil)
844 (defvar gnus-newsgroup-data nil)
845 (defvar gnus-newsgroup-data-reverse nil)
846 (defvar gnus-newsgroup-limit nil)
847 (defvar gnus-newsgroup-limits nil)
849 (defvar gnus-newsgroup-unreads nil
850 "List of unread articles in the current newsgroup.")
852 (defvar gnus-newsgroup-unselected nil
853 "List of unselected unread articles in the current newsgroup.")
855 (defvar gnus-newsgroup-reads nil
856 "Alist of read articles and article marks in the current newsgroup.")
858 (defvar gnus-newsgroup-expunged-tally nil)
860 (defvar gnus-newsgroup-marked nil
861 "List of ticked articles in the current newsgroup (a subset of unread art).")
863 (defvar gnus-newsgroup-killed nil
864 "List of ranges of articles that have been through the scoring process.")
866 (defvar gnus-newsgroup-cached nil
867 "List of articles that come from the article cache.")
869 (defvar gnus-newsgroup-saved nil
870 "List of articles that have been saved.")
872 (defvar gnus-newsgroup-kill-headers nil)
874 (defvar gnus-newsgroup-replied nil
875 "List of articles that have been replied to in the current newsgroup.")
877 (defvar gnus-newsgroup-expirable nil
878 "List of articles in the current newsgroup that can be expired.")
880 (defvar gnus-newsgroup-processable nil
881 "List of articles in the current newsgroup that can be processed.")
883 (defvar gnus-newsgroup-downloadable nil
884 "List of articles in the current newsgroup that can be processed.")
886 (defvar gnus-newsgroup-undownloaded nil
887 "List of articles in the current newsgroup that haven't been downloaded..")
889 (defvar gnus-newsgroup-bookmarks nil
890 "List of articles in the current newsgroup that have bookmarks.")
892 (defvar gnus-newsgroup-dormant nil
893 "List of dormant articles in the current newsgroup.")
895 (defvar gnus-newsgroup-scored nil
896 "List of scored articles in the current newsgroup.")
898 (defvar gnus-newsgroup-headers nil
899 "List of article headers in the current newsgroup.")
901 (defvar gnus-newsgroup-threads nil)
903 (defvar gnus-newsgroup-prepared nil
904 "Whether the current group has been prepared properly.")
906 (defvar gnus-newsgroup-ancient nil
907 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
909 (defvar gnus-newsgroup-sparse nil)
911 (defvar gnus-current-article nil)
912 (defvar gnus-article-current nil)
913 (defvar gnus-current-headers nil)
914 (defvar gnus-have-all-headers nil)
915 (defvar gnus-last-article nil)
916 (defvar gnus-newsgroup-history nil)
918 (defconst gnus-summary-local-variables
919 '(gnus-newsgroup-name
920 gnus-newsgroup-begin gnus-newsgroup-end
921 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
922 gnus-newsgroup-last-folder gnus-newsgroup-last-file
923 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
924 gnus-newsgroup-unselected gnus-newsgroup-marked
925 gnus-newsgroup-reads gnus-newsgroup-saved
926 gnus-newsgroup-replied gnus-newsgroup-expirable
927 gnus-newsgroup-processable gnus-newsgroup-killed
928 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
929 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
930 gnus-newsgroup-headers gnus-newsgroup-threads
931 gnus-newsgroup-prepared gnus-summary-highlight-line-function
932 gnus-current-article gnus-current-headers gnus-have-all-headers
933 gnus-last-article gnus-article-internal-prepare-hook
934 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
935 gnus-newsgroup-scored gnus-newsgroup-kill-headers
936 gnus-thread-expunge-below
937 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
938 (gnus-summary-mark-below . global)
939 gnus-newsgroup-active gnus-scores-exclude-files
940 gnus-newsgroup-history gnus-newsgroup-ancient
941 gnus-newsgroup-sparse gnus-newsgroup-process-stack
942 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
943 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
944 (gnus-newsgroup-expunged-tally . 0)
945 gnus-cache-removable-articles gnus-newsgroup-cached
946 gnus-newsgroup-data gnus-newsgroup-data-reverse
947 gnus-newsgroup-limit gnus-newsgroup-limits)
948 "Variables that are buffer-local to the summary buffers.")
950 ;; Byte-compiler warning.
951 (defvar gnus-article-mode-map)
953 ;; Subject simplification.
955 (defsubst gnus-simplify-subject-re (subject)
956 "Remove \"Re:\" from subject lines."
957 (if (string-match "^[Rr][Ee]: *" subject)
958 (substring subject (match-end 0))
961 (defun gnus-simplify-subject (subject &optional re-only)
962 "Remove `Re:' and words in parentheses.
963 If RE-ONLY is non-nil, strip leading `Re:'s only."
964 (let ((case-fold-search t)) ;Ignore case.
965 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
966 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
967 (setq subject (substring subject (match-end 0))))
968 ;; Remove uninteresting prefixes.
969 (when (and (not re-only)
970 gnus-simplify-ignored-prefixes
971 (string-match gnus-simplify-ignored-prefixes subject))
972 (setq subject (substring subject (match-end 0))))
973 ;; Remove words in parentheses from end.
975 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
976 (setq subject (substring subject 0 (match-beginning 0)))))
977 ;; Return subject string.
980 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
982 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
983 (goto-char (point-min))
984 (while (re-search-forward regexp nil t)
985 (replace-match (or newtext ""))))
987 (defun gnus-simplify-buffer-fuzzy ()
988 "Simplify string in the buffer fuzzily.
989 The string in the accessible portion of the current buffer is simplified.
990 It is assumed to be a single-line subject.
991 Whitespace is generally cleaned up, and miscellaneous leading/trailing
992 matter is removed. Additional things can be deleted by setting
993 gnus-simplify-subject-fuzzy-regexp."
994 (let ((case-fold-search t)
996 (gnus-simplify-buffer-fuzzy-step "\t" " ")
998 (while (not (eq modified-tick (buffer-modified-tick)))
999 (setq modified-tick (buffer-modified-tick))
1001 ((listp gnus-simplify-subject-fuzzy-regexp)
1002 (mapcar 'gnus-simplify-buffer-fuzzy-step
1003 gnus-simplify-subject-fuzzy-regexp))
1004 (gnus-simplify-subject-fuzzy-regexp
1005 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1006 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1007 (gnus-simplify-buffer-fuzzy-step
1008 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1009 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1011 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1012 (gnus-simplify-buffer-fuzzy-step " +" " ")
1013 (gnus-simplify-buffer-fuzzy-step " $")
1014 (gnus-simplify-buffer-fuzzy-step "^ +")))
1016 (defun gnus-simplify-subject-fuzzy (subject)
1017 "Simplify a subject string fuzzily.
1018 See gnus-simplify-buffer-fuzzy for details."
1020 (gnus-set-work-buffer)
1021 (let ((case-fold-search t))
1023 (inline (gnus-simplify-buffer-fuzzy))
1026 (defsubst gnus-simplify-subject-fully (subject)
1027 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1029 ((null gnus-summary-gather-subject-limit)
1030 (gnus-simplify-subject-re subject))
1031 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1032 (gnus-simplify-subject-fuzzy subject))
1033 ((numberp gnus-summary-gather-subject-limit)
1034 (gnus-limit-string (gnus-simplify-subject-re subject)
1035 gnus-summary-gather-subject-limit))
1039 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1040 "Check whether two subjects are equal. If optional argument
1041 simple-first is t, first argument is already simplified."
1043 ((null simple-first)
1044 (equal (gnus-simplify-subject-fully s1)
1045 (gnus-simplify-subject-fully s2)))
1048 (gnus-simplify-subject-fully s2)))))
1050 (defun gnus-summary-bubble-group ()
1051 "Increase the score of the current group.
1052 This is a handy function to add to `gnus-summary-exit-hook' to
1053 increase the score of each group you read."
1054 (gnus-group-add-score gnus-newsgroup-name))
1058 ;;; Gnus summary mode
1061 (put 'gnus-summary-mode 'mode-class 'special)
1064 ;; Non-orthogonal keys
1066 (gnus-define-keys gnus-summary-mode-map
1067 " " gnus-summary-next-page
1068 "\177" gnus-summary-prev-page
1069 [delete] gnus-summary-prev-page
1070 "\r" gnus-summary-scroll-up
1071 "n" gnus-summary-next-unread-article
1072 "p" gnus-summary-prev-unread-article
1073 "N" gnus-summary-next-article
1074 "P" gnus-summary-prev-article
1075 "\M-\C-n" gnus-summary-next-same-subject
1076 "\M-\C-p" gnus-summary-prev-same-subject
1077 "\M-n" gnus-summary-next-unread-subject
1078 "\M-p" gnus-summary-prev-unread-subject
1079 "." gnus-summary-first-unread-article
1080 "," gnus-summary-best-unread-article
1081 "\M-s" gnus-summary-search-article-forward
1082 "\M-r" gnus-summary-search-article-backward
1083 "<" gnus-summary-beginning-of-article
1084 ">" gnus-summary-end-of-article
1085 "j" gnus-summary-goto-article
1086 "^" gnus-summary-refer-parent-article
1087 "\M-^" gnus-summary-refer-article
1088 "u" gnus-summary-tick-article-forward
1089 "!" gnus-summary-tick-article-forward
1090 "U" gnus-summary-tick-article-backward
1091 "d" gnus-summary-mark-as-read-forward
1092 "D" gnus-summary-mark-as-read-backward
1093 "E" gnus-summary-mark-as-expirable
1094 "\M-u" gnus-summary-clear-mark-forward
1095 "\M-U" gnus-summary-clear-mark-backward
1096 "k" gnus-summary-kill-same-subject-and-select
1097 "\C-k" gnus-summary-kill-same-subject
1098 "\M-\C-k" gnus-summary-kill-thread
1099 "\M-\C-l" gnus-summary-lower-thread
1100 "e" gnus-summary-edit-article
1101 "#" gnus-summary-mark-as-processable
1102 "\M-#" gnus-summary-unmark-as-processable
1103 "\M-\C-t" gnus-summary-toggle-threads
1104 "\M-\C-s" gnus-summary-show-thread
1105 "\M-\C-h" gnus-summary-hide-thread
1106 "\M-\C-f" gnus-summary-next-thread
1107 "\M-\C-b" gnus-summary-prev-thread
1108 "\M-\C-u" gnus-summary-up-thread
1109 "\M-\C-d" gnus-summary-down-thread
1110 "&" gnus-summary-execute-command
1111 "c" gnus-summary-catchup-and-exit
1112 "\C-w" gnus-summary-mark-region-as-read
1113 "\C-t" gnus-summary-toggle-truncation
1114 "?" gnus-summary-mark-as-dormant
1115 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1116 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1117 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1118 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1119 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1120 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1121 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1122 "=" gnus-summary-expand-window
1123 "\C-x\C-s" gnus-summary-reselect-current-group
1124 "\M-g" gnus-summary-rescan-group
1125 "w" gnus-summary-stop-page-breaking
1126 "\C-c\C-r" gnus-summary-caesar-message
1127 "\M-t" gnus-summary-toggle-mime
1128 "f" gnus-summary-followup
1129 "F" gnus-summary-followup-with-original
1130 "C" gnus-summary-cancel-article
1131 "r" gnus-summary-reply
1132 "R" gnus-summary-reply-with-original
1133 "\C-c\C-f" gnus-summary-mail-forward
1134 "o" gnus-summary-save-article
1135 "\C-o" gnus-summary-save-article-mail
1136 "|" gnus-summary-pipe-output
1137 "\M-k" gnus-summary-edit-local-kill
1138 "\M-K" gnus-summary-edit-global-kill
1140 "\C-c\C-d" gnus-summary-describe-group
1141 "q" gnus-summary-exit
1142 "Q" gnus-summary-exit-no-update
1143 "\C-c\C-i" gnus-info-find-node
1144 gnus-mouse-2 gnus-mouse-pick-article
1145 "m" gnus-summary-mail-other-window
1146 "a" gnus-summary-post-news
1147 "x" gnus-summary-limit-to-unread
1148 "s" gnus-summary-isearch-article
1149 "t" gnus-article-hide-headers
1150 "g" gnus-summary-show-article
1151 "l" gnus-summary-goto-last-article
1152 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1153 "\C-d" gnus-summary-enter-digest-group
1154 "\M-\C-d" gnus-summary-read-document
1156 "*" gnus-cache-enter-article
1157 "\M-*" gnus-cache-remove-article
1158 "\M-&" gnus-summary-universal-argument
1159 "\C-l" gnus-recenter
1160 "I" gnus-summary-increase-score
1161 "L" gnus-summary-lower-score
1163 "V" gnus-summary-score-map
1164 "X" gnus-uu-extract-map
1165 "S" gnus-summary-send-map)
1167 ;; Sort of orthogonal keymap
1168 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1169 "t" gnus-summary-tick-article-forward
1170 "!" gnus-summary-tick-article-forward
1171 "d" gnus-summary-mark-as-read-forward
1172 "r" gnus-summary-mark-as-read-forward
1173 "c" gnus-summary-clear-mark-forward
1174 " " gnus-summary-clear-mark-forward
1175 "e" gnus-summary-mark-as-expirable
1176 "x" gnus-summary-mark-as-expirable
1177 "?" gnus-summary-mark-as-dormant
1178 "b" gnus-summary-set-bookmark
1179 "B" gnus-summary-remove-bookmark
1180 "#" gnus-summary-mark-as-processable
1181 "\M-#" gnus-summary-unmark-as-processable
1182 "S" gnus-summary-limit-include-expunged
1183 "C" gnus-summary-catchup
1184 "H" gnus-summary-catchup-to-here
1185 "\C-c" gnus-summary-catchup-all
1186 "k" gnus-summary-kill-same-subject-and-select
1187 "K" gnus-summary-kill-same-subject
1188 "P" gnus-uu-mark-map)
1190 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1191 "c" gnus-summary-clear-above
1192 "u" gnus-summary-tick-above
1193 "m" gnus-summary-mark-above
1194 "k" gnus-summary-kill-below)
1196 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1197 "/" gnus-summary-limit-to-subject
1198 "n" gnus-summary-limit-to-articles
1199 "w" gnus-summary-pop-limit
1200 "s" gnus-summary-limit-to-subject
1201 "a" gnus-summary-limit-to-author
1202 "u" gnus-summary-limit-to-unread
1203 "m" gnus-summary-limit-to-marks
1204 "v" gnus-summary-limit-to-score
1205 "D" gnus-summary-limit-include-dormant
1206 "d" gnus-summary-limit-exclude-dormant
1207 "t" gnus-summary-limit-to-age
1208 "E" gnus-summary-limit-include-expunged
1209 "c" gnus-summary-limit-exclude-childless-dormant
1210 "C" gnus-summary-limit-mark-excluded-as-read)
1212 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1213 "n" gnus-summary-next-unread-article
1214 "p" gnus-summary-prev-unread-article
1215 "N" gnus-summary-next-article
1216 "P" gnus-summary-prev-article
1217 "\C-n" gnus-summary-next-same-subject
1218 "\C-p" gnus-summary-prev-same-subject
1219 "\M-n" gnus-summary-next-unread-subject
1220 "\M-p" gnus-summary-prev-unread-subject
1221 "f" gnus-summary-first-unread-article
1222 "b" gnus-summary-best-unread-article
1223 "j" gnus-summary-goto-article
1224 "g" gnus-summary-goto-subject
1225 "l" gnus-summary-goto-last-article
1226 "o" gnus-summary-pop-article)
1228 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1229 "k" gnus-summary-kill-thread
1230 "l" gnus-summary-lower-thread
1231 "i" gnus-summary-raise-thread
1232 "T" gnus-summary-toggle-threads
1233 "t" gnus-summary-rethread-current
1234 "^" gnus-summary-reparent-thread
1235 "s" gnus-summary-show-thread
1236 "S" gnus-summary-show-all-threads
1237 "h" gnus-summary-hide-thread
1238 "H" gnus-summary-hide-all-threads
1239 "n" gnus-summary-next-thread
1240 "p" gnus-summary-prev-thread
1241 "u" gnus-summary-up-thread
1242 "o" gnus-summary-top-thread
1243 "d" gnus-summary-down-thread
1244 "#" gnus-uu-mark-thread
1245 "\M-#" gnus-uu-unmark-thread)
1247 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1248 "g" gnus-summary-prepare
1249 "c" gnus-summary-insert-cached-articles)
1251 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1252 "c" gnus-summary-catchup-and-exit
1253 "C" gnus-summary-catchup-all-and-exit
1254 "E" gnus-summary-exit-no-update
1255 "Q" gnus-summary-exit
1256 "Z" gnus-summary-exit
1257 "n" gnus-summary-catchup-and-goto-next-group
1258 "R" gnus-summary-reselect-current-group
1259 "G" gnus-summary-rescan-group
1260 "N" gnus-summary-next-group
1261 "s" gnus-summary-save-newsrc
1262 "P" gnus-summary-prev-group)
1264 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1265 " " gnus-summary-next-page
1266 "n" gnus-summary-next-page
1267 "\177" gnus-summary-prev-page
1268 [delete] gnus-summary-prev-page
1269 "p" gnus-summary-prev-page
1270 "\r" gnus-summary-scroll-up
1271 "<" gnus-summary-beginning-of-article
1272 ">" gnus-summary-end-of-article
1273 "b" gnus-summary-beginning-of-article
1274 "e" gnus-summary-end-of-article
1275 "^" gnus-summary-refer-parent-article
1276 "r" gnus-summary-refer-parent-article
1277 "R" gnus-summary-refer-references
1278 "g" gnus-summary-show-article
1279 "s" gnus-summary-isearch-article
1280 "P" gnus-summary-print-article)
1282 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1283 "b" gnus-article-add-buttons
1284 "B" gnus-article-add-buttons-to-head
1285 "o" gnus-article-treat-overstrike
1286 "e" gnus-article-emphasize
1287 "w" gnus-article-fill-cited-article
1288 "c" gnus-article-remove-cr
1289 "q" gnus-article-de-quoted-unreadable
1290 "f" gnus-article-display-x-face
1291 "l" gnus-summary-stop-page-breaking
1292 "r" gnus-summary-caesar-message
1293 "t" gnus-article-hide-headers
1294 "v" gnus-summary-verbose-headers
1295 "m" gnus-summary-toggle-mime
1296 "h" gnus-article-treat-html)
1298 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1299 "a" gnus-article-hide
1300 "h" gnus-article-hide-headers
1301 "b" gnus-article-hide-boring-headers
1302 "s" gnus-article-hide-signature
1303 "c" gnus-article-hide-citation
1304 "p" gnus-article-hide-pgp
1305 "P" gnus-article-hide-pem
1306 "\C-c" gnus-article-hide-citation-maybe)
1308 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1309 "a" gnus-article-highlight
1310 "h" gnus-article-highlight-headers
1311 "c" gnus-article-highlight-citation
1312 "s" gnus-article-highlight-signature)
1314 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1315 "z" gnus-article-date-ut
1316 "u" gnus-article-date-ut
1317 "l" gnus-article-date-local
1318 "e" gnus-article-date-lapsed
1319 "o" gnus-article-date-original
1320 "s" gnus-article-date-user)
1322 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1323 "t" gnus-article-remove-trailing-blank-lines
1324 "l" gnus-article-strip-leading-blank-lines
1325 "m" gnus-article-strip-multiple-blank-lines
1326 "a" gnus-article-strip-blank-lines
1327 "s" gnus-article-strip-leading-space)
1329 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1331 "f" gnus-summary-fetch-faq
1332 "d" gnus-summary-describe-group
1333 "h" gnus-summary-describe-briefly
1334 "i" gnus-info-find-node)
1336 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1337 "e" gnus-summary-expire-articles
1338 "\M-\C-e" gnus-summary-expire-articles-now
1339 "\177" gnus-summary-delete-article
1340 [delete] gnus-summary-delete-article
1341 "m" gnus-summary-move-article
1342 "r" gnus-summary-respool-article
1343 "w" gnus-summary-edit-article
1344 "c" gnus-summary-copy-article
1345 "B" gnus-summary-crosspost-article
1346 "q" gnus-summary-respool-query
1347 "i" gnus-summary-import-article
1348 "p" gnus-summary-article-posted-p)
1350 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1351 "o" gnus-summary-save-article
1352 "m" gnus-summary-save-article-mail
1353 "F" gnus-summary-write-article-file
1354 "r" gnus-summary-save-article-rmail
1355 "f" gnus-summary-save-article-file
1356 "b" gnus-summary-save-article-body-file
1357 "h" gnus-summary-save-article-folder
1358 "v" gnus-summary-save-article-vm
1359 "p" gnus-summary-pipe-output
1360 "s" gnus-soup-add-article))
1362 (defun gnus-summary-make-menu-bar ()
1363 (gnus-turn-off-edit-menu 'summary)
1365 (unless (boundp 'gnus-summary-misc-menu)
1368 gnus-summary-kill-menu gnus-summary-mode-map ""
1373 ["Enter score..." gnus-summary-score-entry t]
1374 ["Customize" gnus-score-customize t])
1375 (gnus-make-score-map 'increase)
1376 (gnus-make-score-map 'lower)
1378 ["Kill below" gnus-summary-kill-below t]
1379 ["Mark above" gnus-summary-mark-above t]
1380 ["Tick above" gnus-summary-tick-above t]
1381 ["Clear above" gnus-summary-clear-above t])
1382 ["Current score" gnus-summary-current-score t]
1383 ["Set score" gnus-summary-set-score t]
1384 ["Switch current score file..." gnus-score-change-score-file t]
1385 ["Set mark below..." gnus-score-set-mark-below t]
1386 ["Set expunge below..." gnus-score-set-expunge-below t]
1387 ["Edit current score file" gnus-score-edit-current-scores t]
1388 ["Edit score file" gnus-score-edit-file t]
1389 ["Trace score" gnus-score-find-trace t]
1390 ["Find words" gnus-score-find-favourite-words t]
1391 ["Rescore buffer" gnus-summary-rescore t]
1392 ["Increase score..." gnus-summary-increase-score t]
1393 ["Lower score..." gnus-summary-lower-score t]))))
1396 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1398 :selected (null gnus-score-default-header)]
1399 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1401 :selected (eq gnus-score-default-header 'a)]
1402 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1404 :selected (eq gnus-score-default-header 's)]
1406 (gnus-score-set-default 'gnus-score-default-header 'b)
1408 :selected (eq gnus-score-default-header 'b )]
1410 (gnus-score-set-default 'gnus-score-default-header 'h)
1412 :selected (eq gnus-score-default-header 'h )]
1413 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1415 :selected (eq gnus-score-default-header 'i )]
1416 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1418 :selected (eq gnus-score-default-header 't )]
1420 (gnus-score-set-default 'gnus-score-default-header 'x)
1422 :selected (eq gnus-score-default-header 'x )]
1423 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1425 :selected (eq gnus-score-default-header 'l )]
1426 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1428 :selected (eq gnus-score-default-header 'd )]
1429 ["Followups to author"
1430 (gnus-score-set-default 'gnus-score-default-header 'f)
1432 :selected (eq gnus-score-default-header 'f )])
1434 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1436 :selected (null gnus-score-default-type)]
1437 ;; The `:active' key is commented out in the following,
1438 ;; because the GNU Emacs hack to support radio buttons use
1439 ;; active to indicate which button is selected.
1440 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1442 ;; :active (not (memq gnus-score-default-header '(l d)))
1443 :selected (eq gnus-score-default-type 's)]
1444 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1446 ;; :active (not (memq gnus-score-default-header '(l d)))
1447 :selected (eq gnus-score-default-type 'r)]
1448 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1450 ;; :active (not (memq gnus-score-default-header '(l d)))
1451 :selected (eq gnus-score-default-type 'e)]
1452 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1454 ;; :active (not (memq gnus-score-default-header '(l d)))
1455 :selected (eq gnus-score-default-type 'f)]
1456 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1458 ;; :active (eq (gnus-score-default-header 'd))
1459 :selected (eq gnus-score-default-type 'b)]
1460 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1462 ;; :active (eq (gnus-score-default-header 'd))
1463 :selected (eq gnus-score-default-type 'n)]
1464 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1466 ;; :active (eq (gnus-score-default-header 'd))
1467 :selected (eq gnus-score-default-type 'a)]
1469 (gnus-score-set-default 'gnus-score-default-type '<)
1471 ;; :active (eq (gnus-score-default-header 'l))
1472 :selected (eq gnus-score-default-type '<)]
1474 (gnus-score-set-default 'gnus-score-default-type '=)
1476 ;; :active (eq (gnus-score-default-header 'l))
1477 :selected (eq gnus-score-default-type '=)]
1478 ["Greater than number"
1479 (gnus-score-set-default 'gnus-score-default-type '>)
1481 ;; :active (eq (gnus-score-default-header 'l))
1482 :selected (eq gnus-score-default-type '>)])
1483 ["Default fold" gnus-score-default-fold-toggle
1485 :selected gnus-score-default-fold]
1487 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1489 :selected (null gnus-score-default-duration)]
1491 (gnus-score-set-default 'gnus-score-default-duration 'p)
1493 :selected (eq gnus-score-default-duration 'p)]
1495 (gnus-score-set-default 'gnus-score-default-duration 't)
1497 :selected (eq gnus-score-default-duration 't)]
1499 (gnus-score-set-default 'gnus-score-default-duration 'i)
1501 :selected (eq gnus-score-default-duration 'i)]))
1504 gnus-summary-article-menu gnus-summary-mode-map ""
1507 ["All" gnus-article-hide t]
1508 ["Headers" gnus-article-hide-headers t]
1509 ["Signature" gnus-article-hide-signature t]
1510 ["Citation" gnus-article-hide-citation t]
1511 ["PGP" gnus-article-hide-pgp t]
1512 ["Boring headers" gnus-article-hide-boring-headers t])
1514 ["All" gnus-article-highlight t]
1515 ["Headers" gnus-article-highlight-headers t]
1516 ["Signature" gnus-article-highlight-signature t]
1517 ["Citation" gnus-article-highlight-citation t])
1519 ["Local" gnus-article-date-local t]
1520 ["UT" gnus-article-date-ut t]
1521 ["Original" gnus-article-date-original t]
1522 ["Lapsed" gnus-article-date-lapsed t]
1523 ["User-defined" gnus-article-date-user t])
1526 ["Leading" gnus-article-strip-leading-blank-lines t]
1527 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1528 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1529 ["All of the above" gnus-article-strip-blank-lines t]
1530 ["Leading space" gnus-article-strip-leading-space t])
1531 ["Overstrike" gnus-article-treat-overstrike t]
1532 ["Emphasis" gnus-article-emphasize t]
1533 ["Word wrap" gnus-article-fill-cited-article t]
1534 ["CR" gnus-article-remove-cr t]
1535 ["Show X-Face" gnus-article-display-x-face t]
1536 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1537 ["UnHTMLize" gnus-article-treat-html t]
1538 ["Rot 13" gnus-summary-caesar-message t]
1539 ["Unix pipe" gnus-summary-pipe-message t]
1540 ["Add buttons" gnus-article-add-buttons t]
1541 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1542 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1543 ["Toggle MIME" gnus-summary-toggle-mime t]
1544 ["Verbose header" gnus-summary-verbose-headers t]
1545 ["Toggle header" gnus-summary-toggle-header t])
1547 ["Save in default format" gnus-summary-save-article t]
1548 ["Save in file" gnus-summary-save-article-file t]
1549 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1550 ["Write to file" gnus-summary-write-article-mail t]
1551 ["Save in MH folder" gnus-summary-save-article-folder t]
1552 ["Save in VM folder" gnus-summary-save-article-vm t]
1553 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1554 ["Save body in file" gnus-summary-save-article-body-file t]
1555 ["Pipe through a filter" gnus-summary-pipe-output t]
1556 ["Add to SOUP packet" gnus-soup-add-article t]
1557 ["Print" gnus-summary-print-article t])
1559 ["Respool article..." gnus-summary-respool-article t]
1560 ["Move article..." gnus-summary-move-article
1561 (gnus-check-backend-function
1562 'request-move-article gnus-newsgroup-name)]
1563 ["Copy article..." gnus-summary-copy-article t]
1564 ["Crosspost article..." gnus-summary-crosspost-article
1565 (gnus-check-backend-function
1566 'request-replace-article gnus-newsgroup-name)]
1567 ["Import file..." gnus-summary-import-article t]
1568 ["Check if posted" gnus-summary-article-posted-p t]
1569 ["Edit article" gnus-summary-edit-article
1570 (not (gnus-group-read-only-p))]
1571 ["Delete article" gnus-summary-delete-article
1572 (gnus-check-backend-function
1573 'request-expire-articles gnus-newsgroup-name)]
1574 ["Query respool" gnus-summary-respool-query t]
1575 ["Delete expirable articles" gnus-summary-expire-articles-now
1576 (gnus-check-backend-function
1577 'request-expire-articles gnus-newsgroup-name)])
1579 ["Uudecode" gnus-uu-decode-uu t]
1580 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1581 ["Unshar" gnus-uu-decode-unshar t]
1582 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1583 ["Save" gnus-uu-decode-save t]
1584 ["Binhex" gnus-uu-decode-binhex t]
1585 ["Postscript" gnus-uu-decode-postscript t])
1587 ["Enter article" gnus-cache-enter-article t]
1588 ["Remove article" gnus-cache-remove-article t])
1589 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1590 ["Isearch article..." gnus-summary-isearch-article t]
1591 ["Beginning of the article" gnus-summary-beginning-of-article t]
1592 ["End of the article" gnus-summary-end-of-article t]
1593 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1594 ["Fetch referenced articles" gnus-summary-refer-references t]
1595 ["Fetch article with id..." gnus-summary-refer-article t]
1596 ["Redisplay" gnus-summary-show-article t]))
1599 gnus-summary-thread-menu gnus-summary-mode-map ""
1601 ["Toggle threading" gnus-summary-toggle-threads t]
1602 ["Hide threads" gnus-summary-hide-all-threads t]
1603 ["Show threads" gnus-summary-show-all-threads t]
1604 ["Hide thread" gnus-summary-hide-thread t]
1605 ["Show thread" gnus-summary-show-thread t]
1606 ["Go to next thread" gnus-summary-next-thread t]
1607 ["Go to previous thread" gnus-summary-prev-thread t]
1608 ["Go down thread" gnus-summary-down-thread t]
1609 ["Go up thread" gnus-summary-up-thread t]
1610 ["Top of thread" gnus-summary-top-thread t]
1611 ["Mark thread as read" gnus-summary-kill-thread t]
1612 ["Lower thread score" gnus-summary-lower-thread t]
1613 ["Raise thread score" gnus-summary-raise-thread t]
1614 ["Rethread current" gnus-summary-rethread-current t]
1618 gnus-summary-post-menu gnus-summary-mode-map ""
1620 ["Post an article" gnus-summary-post-news t]
1621 ["Followup" gnus-summary-followup t]
1622 ["Followup and yank" gnus-summary-followup-with-original t]
1623 ["Supersede article" gnus-summary-supersede-article t]
1624 ["Cancel article" gnus-summary-cancel-article t]
1625 ["Reply" gnus-summary-reply t]
1626 ["Reply and yank" gnus-summary-reply-with-original t]
1627 ["Wide reply" gnus-summary-wide-reply t]
1628 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1629 ["Mail forward" gnus-summary-mail-forward t]
1630 ["Post forward" gnus-summary-post-forward t]
1631 ["Digest and mail" gnus-uu-digest-mail-forward t]
1632 ["Digest and post" gnus-uu-digest-post-forward t]
1633 ["Resend message" gnus-summary-resend-message t]
1634 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1635 ["Send a mail" gnus-summary-mail-other-window t]
1636 ["Uuencode and post" gnus-uu-post-news t]
1637 ["Followup via news" gnus-summary-followup-to-mail t]
1638 ["Followup via news and yank"
1639 gnus-summary-followup-to-mail-with-original t]
1641 ;;["Send" gnus-summary-send-draft t]
1642 ;;["Send bounced" gnus-resend-bounced-mail t])
1646 gnus-summary-misc-menu gnus-summary-mode-map ""
1649 ["Mark as read" gnus-summary-mark-as-read-forward t]
1650 ["Mark same subject and select"
1651 gnus-summary-kill-same-subject-and-select t]
1652 ["Mark same subject" gnus-summary-kill-same-subject t]
1653 ["Catchup" gnus-summary-catchup t]
1654 ["Catchup all" gnus-summary-catchup-all t]
1655 ["Catchup to here" gnus-summary-catchup-to-here t]
1656 ["Catchup region" gnus-summary-mark-region-as-read t]
1657 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1659 ["Tick" gnus-summary-tick-article-forward t]
1660 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1661 ["Remove marks" gnus-summary-clear-mark-forward t]
1662 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1663 ["Set bookmark" gnus-summary-set-bookmark t]
1664 ["Remove bookmark" gnus-summary-remove-bookmark t])
1666 ["Marks..." gnus-summary-limit-to-marks t]
1667 ["Subject..." gnus-summary-limit-to-subject t]
1668 ["Author..." gnus-summary-limit-to-author t]
1669 ["Age..." gnus-summary-limit-to-age t]
1670 ["Score" gnus-summary-limit-to-score t]
1671 ["Unread" gnus-summary-limit-to-unread t]
1672 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1673 ["Articles" gnus-summary-limit-to-articles t]
1674 ["Pop limit" gnus-summary-pop-limit t]
1675 ["Show dormant" gnus-summary-limit-include-dormant t]
1676 ["Hide childless dormant"
1677 gnus-summary-limit-exclude-childless-dormant t]
1678 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1679 ["Show expunged" gnus-summary-show-all-expunged t])
1681 ["Set mark" gnus-summary-mark-as-processable t]
1682 ["Remove mark" gnus-summary-unmark-as-processable t]
1683 ["Remove all marks" gnus-summary-unmark-all-processable t]
1684 ["Mark above" gnus-uu-mark-over t]
1685 ["Mark series" gnus-uu-mark-series t]
1686 ["Mark region" gnus-uu-mark-region t]
1687 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1688 ["Mark all" gnus-uu-mark-all t]
1689 ["Mark buffer" gnus-uu-mark-buffer t]
1690 ["Mark sparse" gnus-uu-mark-sparse t]
1691 ["Mark thread" gnus-uu-mark-thread t]
1692 ["Unmark thread" gnus-uu-unmark-thread t]
1693 ("Process Mark Sets"
1694 ["Kill" gnus-summary-kill-process-mark t]
1695 ["Yank" gnus-summary-yank-process-mark
1696 gnus-newsgroup-process-stack]
1697 ["Save" gnus-summary-save-process-mark t]))
1699 ["Page forward" gnus-summary-next-page t]
1700 ["Page backward" gnus-summary-prev-page t]
1701 ["Line forward" gnus-summary-scroll-up t])
1703 ["Next unread article" gnus-summary-next-unread-article t]
1704 ["Previous unread article" gnus-summary-prev-unread-article t]
1705 ["Next article" gnus-summary-next-article t]
1706 ["Previous article" gnus-summary-prev-article t]
1707 ["Next unread subject" gnus-summary-next-unread-subject t]
1708 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1709 ["Next article same subject" gnus-summary-next-same-subject t]
1710 ["Previous article same subject" gnus-summary-prev-same-subject t]
1711 ["First unread article" gnus-summary-first-unread-article t]
1712 ["Best unread article" gnus-summary-best-unread-article t]
1713 ["Go to subject number..." gnus-summary-goto-subject t]
1714 ["Go to article number..." gnus-summary-goto-article t]
1715 ["Go to the last article" gnus-summary-goto-last-article t]
1716 ["Pop article off history" gnus-summary-pop-article t])
1718 ["Sort by number" gnus-summary-sort-by-number t]
1719 ["Sort by author" gnus-summary-sort-by-author t]
1720 ["Sort by subject" gnus-summary-sort-by-subject t]
1721 ["Sort by date" gnus-summary-sort-by-date t]
1722 ["Sort by score" gnus-summary-sort-by-score t]
1723 ["Sort by lines" gnus-summary-sort-by-lines t])
1725 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1726 ["Describe group" gnus-summary-describe-group t]
1727 ["Read manual" gnus-info-find-node t])
1729 ["Pick and read" gnus-pick-mode t]
1730 ["Binary" gnus-binary-mode t])
1732 ["Regenerate" gnus-summary-prepare t]
1733 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1734 ["Toggle threading" gnus-summary-toggle-threads t])
1735 ["Filter articles..." gnus-summary-execute-command t]
1736 ["Run command on subjects..." gnus-summary-universal-argument t]
1737 ["Search articles forward..." gnus-summary-search-article-forward t]
1738 ["Search articles backward..." gnus-summary-search-article-backward t]
1739 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1740 ["Expand window" gnus-summary-expand-window t]
1741 ["Expire expirable articles" gnus-summary-expire-articles
1742 (gnus-check-backend-function
1743 'request-expire-articles gnus-newsgroup-name)]
1744 ["Edit local kill file" gnus-summary-edit-local-kill t]
1745 ["Edit main kill file" gnus-summary-edit-global-kill t]
1747 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1748 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1749 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1750 ["Exit group" gnus-summary-exit t]
1751 ["Exit group without updating" gnus-summary-exit-no-update t]
1752 ["Exit and goto next group" gnus-summary-next-group t]
1753 ["Exit and goto prev group" gnus-summary-prev-group t]
1754 ["Reselect group" gnus-summary-reselect-current-group t]
1755 ["Rescan group" gnus-summary-rescan-group t]
1756 ["Update dribble" gnus-summary-save-newsrc t])))
1758 (run-hooks 'gnus-summary-menu-hook)))
1760 (defun gnus-score-set-default (var value)
1761 "A version of set that updates the GNU Emacs menu-bar."
1763 ;; It is the message that forces the active status to be updated.
1766 (defun gnus-make-score-map (type)
1767 "Make a summary score map of type TYPE."
1770 (let ((headers '(("author" "from" string)
1771 ("subject" "subject" string)
1772 ("article body" "body" string)
1773 ("article head" "head" string)
1774 ("xref" "xref" string)
1775 ("lines" "lines" number)
1776 ("followups to author" "followup" string)))
1777 (types '((number ("less than" <)
1780 (string ("substring" s)
1784 (perms '(("temporary" (current-time-string))
1792 (if (eq type 'lower)
1797 (setq header (car headers))
1803 (let ((ts (cdr (assoc (nth 2 header) types)))
1819 'gnus-summary-score-entry
1821 (if (or (string= (nth 1 header)
1823 (string= (nth 1 header)
1826 (list 'gnus-summary-header
1828 (list 'quote (nth 1 (car ts)))
1829 (list 'gnus-score-default nil)
1835 (list (nreverse outp))))
1838 (list (nreverse outt))))
1840 (setq headers (cdr headers)))
1841 (list (nreverse outh))))))))
1845 (defun gnus-summary-mode (&optional group)
1846 "Major mode for reading articles.
1848 All normal editing commands are switched off.
1849 \\<gnus-summary-mode-map>
1850 Each line in this buffer represents one article. To read an
1851 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1852 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1855 You can also post articles and send mail from this buffer. To
1856 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1857 of an article, type `\\[gnus-summary-reply]'.
1859 There are approx. one gazillion commands you can execute in this
1860 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1862 The following commands are available:
1864 \\{gnus-summary-mode-map}"
1866 (when (gnus-visual-p 'summary-menu 'menu)
1867 (gnus-summary-make-menu-bar))
1868 (kill-all-local-variables)
1869 (gnus-summary-make-local-variables)
1870 (gnus-make-thread-indent-array)
1871 (gnus-simplify-mode-line)
1872 (setq major-mode 'gnus-summary-mode)
1873 (setq mode-name "Summary")
1874 (make-local-variable 'minor-mode-alist)
1875 (use-local-map gnus-summary-mode-map)
1876 (buffer-disable-undo (current-buffer))
1877 (setq buffer-read-only t) ;Disable modification
1878 (setq truncate-lines t)
1879 (setq selective-display t)
1880 (setq selective-display-ellipses t) ;Display `...'
1881 (gnus-summary-set-display-table)
1882 (gnus-set-default-directory)
1883 (setq gnus-newsgroup-name group)
1884 (make-local-variable 'gnus-summary-line-format)
1885 (make-local-variable 'gnus-summary-line-format-spec)
1886 (make-local-variable 'gnus-summary-mark-positions)
1887 (make-local-hook 'post-command-hook)
1888 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1889 (run-hooks 'gnus-summary-mode-hook)
1890 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1891 (gnus-update-summary-mark-positions))
1893 (defun gnus-summary-make-local-variables ()
1894 "Make all the local summary buffer variables."
1895 (let ((locals gnus-summary-local-variables)
1897 (while (setq local (pop locals))
1900 (if (eq (cdr local) 'global)
1901 ;; Copy the global value of the variable.
1902 (setq global (symbol-value (car local)))
1903 ;; Use the value from the list.
1904 (setq global (eval (cdr local))))
1905 (make-local-variable (car local))
1906 (set (car local) global))
1907 ;; Simple nil-valued local variable.
1908 (make-local-variable local)
1911 (defun gnus-summary-clear-local-variables ()
1912 (let ((locals gnus-summary-local-variables))
1914 (if (consp (car locals))
1915 (and (vectorp (caar locals))
1916 (set (caar locals) nil))
1917 (and (vectorp (car locals))
1918 (set (car locals) nil)))
1919 (setq locals (cdr locals)))))
1921 ;; Summary data functions.
1923 (defmacro gnus-data-number (data)
1926 (defmacro gnus-data-set-number (data number)
1927 `(setcar ,data ,number))
1929 (defmacro gnus-data-mark (data)
1932 (defmacro gnus-data-set-mark (data mark)
1933 `(setcar (nthcdr 1 ,data) ,mark))
1935 (defmacro gnus-data-pos (data)
1938 (defmacro gnus-data-set-pos (data pos)
1939 `(setcar (nthcdr 2 ,data) ,pos))
1941 (defmacro gnus-data-header (data)
1944 (defmacro gnus-data-set-header (data header)
1945 `(setf (nth 3 ,data) ,header))
1947 (defmacro gnus-data-level (data)
1950 (defmacro gnus-data-unread-p (data)
1951 `(= (nth 1 ,data) gnus-unread-mark))
1953 (defmacro gnus-data-read-p (data)
1954 `(/= (nth 1 ,data) gnus-unread-mark))
1956 (defmacro gnus-data-pseudo-p (data)
1957 `(consp (nth 3 ,data)))
1959 (defmacro gnus-data-find (number)
1960 `(assq ,number gnus-newsgroup-data))
1962 (defmacro gnus-data-find-list (number &optional data)
1963 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1964 (memq (assq ,number bdata)
1967 (defmacro gnus-data-make (number mark pos header level)
1968 `(list ,number ,mark ,pos ,header ,level))
1970 (defun gnus-data-enter (after-article number mark pos header level offset)
1971 (let ((data (gnus-data-find-list after-article)))
1973 (error "No such article: %d" after-article))
1974 (setcdr data (cons (gnus-data-make number mark pos header level)
1976 (setq gnus-newsgroup-data-reverse nil)
1977 (gnus-data-update-list (cddr data) offset)))
1979 (defun gnus-data-enter-list (after-article list &optional offset)
1981 (let ((data (and after-article (gnus-data-find-list after-article)))
1983 (or data (not after-article) (error "No such article: %d" after-article))
1984 ;; Find the last element in the list to be spliced into the main
1987 (setq list (cdr list)))
1990 (setcdr list gnus-newsgroup-data)
1991 (setq gnus-newsgroup-data ilist)
1993 (gnus-data-update-list (cdr list) offset)))
1994 (setcdr list (cdr data))
1997 (gnus-data-update-list (cdr list) offset)))
1998 (setq gnus-newsgroup-data-reverse nil))))
2000 (defun gnus-data-remove (article &optional offset)
2001 (let ((data gnus-newsgroup-data))
2002 (if (= (gnus-data-number (car data)) article)
2004 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2005 gnus-newsgroup-data-reverse nil)
2007 (gnus-data-update-list gnus-newsgroup-data offset)))
2009 (when (= (gnus-data-number (cadr data)) article)
2010 (setcdr data (cddr data))
2012 (gnus-data-update-list (cdr data) offset))
2014 gnus-newsgroup-data-reverse nil))
2015 (setq data (cdr data))))))
2017 (defmacro gnus-data-list (backward)
2019 (or gnus-newsgroup-data-reverse
2020 (setq gnus-newsgroup-data-reverse
2021 (reverse gnus-newsgroup-data)))
2022 gnus-newsgroup-data))
2024 (defun gnus-data-update-list (data offset)
2025 "Add OFFSET to the POS of all data entries in DATA."
2027 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2028 (setq data (cdr data))))
2030 (defun gnus-data-compute-positions ()
2031 "Compute the positions of all articles."
2032 (let ((data gnus-newsgroup-data)
2035 (when (setq pos (text-property-any
2036 (point-min) (point-max)
2037 'gnus-number (gnus-data-number (car data))))
2038 (gnus-data-set-pos (car data) (+ pos 3)))
2039 (setq data (cdr data)))))
2041 (defun gnus-summary-article-pseudo-p (article)
2042 "Say whether this article is a pseudo article or not."
2043 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2045 (defmacro gnus-summary-article-sparse-p (article)
2046 "Say whether this article is a sparse article or not."
2047 `(memq ,article gnus-newsgroup-sparse))
2049 (defmacro gnus-summary-article-ancient-p (article)
2050 "Say whether this article is a sparse article or not."
2051 `(memq ,article gnus-newsgroup-ancient))
2053 (defun gnus-article-parent-p (number)
2054 "Say whether this article is a parent or not."
2055 (let ((data (gnus-data-find-list number)))
2056 (and (cdr data) ; There has to be an article after...
2057 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2058 (gnus-data-level (nth 1 data))))))
2060 (defun gnus-article-children (number)
2061 "Return a list of all children to NUMBER."
2062 (let* ((data (gnus-data-find-list number))
2063 (level (gnus-data-level (car data)))
2065 (setq data (cdr data))
2067 (= (gnus-data-level (car data)) (1+ level)))
2068 (push (gnus-data-number (car data)) children)
2069 (setq data (cdr data)))
2072 (defmacro gnus-summary-skip-intangible ()
2073 "If the current article is intangible, then jump to a different article."
2074 '(let ((to (get-text-property (point) 'gnus-intangible)))
2075 (and to (gnus-summary-goto-subject to))))
2077 (defmacro gnus-summary-article-intangible-p ()
2078 "Say whether this article is intangible or not."
2079 '(get-text-property (point) 'gnus-intangible))
2081 (defun gnus-article-read-p (article)
2082 "Say whether ARTICLE is read or not."
2083 (not (or (memq article gnus-newsgroup-marked)
2084 (memq article gnus-newsgroup-unreads)
2085 (memq article gnus-newsgroup-unselected)
2086 (memq article gnus-newsgroup-dormant))))
2088 ;; Some summary mode macros.
2090 (defmacro gnus-summary-article-number ()
2091 "The article number of the article on the current line.
2092 If there isn's an article number here, then we return the current
2095 (gnus-summary-skip-intangible)
2096 (or (get-text-property (point) 'gnus-number)
2097 (gnus-summary-last-subject))))
2099 (defmacro gnus-summary-article-header (&optional number)
2100 `(gnus-data-header (gnus-data-find
2101 ,(or number '(gnus-summary-article-number)))))
2103 (defmacro gnus-summary-thread-level (&optional number)
2104 `(if (and (eq gnus-summary-make-false-root 'dummy)
2105 (get-text-property (point) 'gnus-intangible))
2107 (gnus-data-level (gnus-data-find
2108 ,(or number '(gnus-summary-article-number))))))
2110 (defmacro gnus-summary-article-mark (&optional number)
2111 `(gnus-data-mark (gnus-data-find
2112 ,(or number '(gnus-summary-article-number)))))
2114 (defmacro gnus-summary-article-pos (&optional number)
2115 `(gnus-data-pos (gnus-data-find
2116 ,(or number '(gnus-summary-article-number)))))
2118 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2119 (defmacro gnus-summary-article-subject (&optional number)
2120 "Return current subject string or nil if nothing."
2123 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2124 '(gnus-data-header (assq (gnus-summary-article-number)
2125 gnus-newsgroup-data)))))
2128 (mail-header-subject headers))))
2130 (defmacro gnus-summary-article-score (&optional number)
2131 "Return current article score."
2132 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2133 gnus-newsgroup-scored))
2134 gnus-summary-default-score 0))
2136 (defun gnus-summary-article-children (&optional number)
2137 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2138 (level (gnus-data-level (car data)))
2140 (while (and (setq data (cdr data))
2141 (> (setq l (gnus-data-level (car data))) level))
2142 (and (= (1+ level) l)
2143 (push (gnus-data-number (car data))
2145 (nreverse children)))
2147 (defun gnus-summary-article-parent (&optional number)
2148 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2149 (gnus-data-list t)))
2150 (level (gnus-data-level (car data))))
2152 () ; This is a root.
2153 ;; We search until we find an article with a level less than
2154 ;; this one. That function has to be the parent.
2155 (while (and (setq data (cdr data))
2156 (not (< (gnus-data-level (car data)) level))))
2157 (and data (gnus-data-number (car data))))))
2159 (defun gnus-unread-mark-p (mark)
2160 "Say whether MARK is the unread mark."
2161 (= mark gnus-unread-mark))
2163 (defun gnus-read-mark-p (mark)
2164 "Say whether MARK is one of the marks that mark as read.
2165 This is all marks except unread, ticked, dormant, and expirable."
2166 (not (or (= mark gnus-unread-mark)
2167 (= mark gnus-ticked-mark)
2168 (= mark gnus-dormant-mark)
2169 (= mark gnus-expirable-mark))))
2171 (defmacro gnus-article-mark (number)
2173 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2174 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2175 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2176 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2177 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2178 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2179 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2180 gnus-ancient-mark))))
2182 ;; Saving hidden threads.
2184 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2185 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2187 (defmacro gnus-save-hidden-threads (&rest forms)
2188 "Save hidden threads, eval FORMS, and restore the hidden threads."
2189 (let ((config (make-symbol "config")))
2190 `(let ((,config (gnus-hidden-threads-configuration)))
2194 (gnus-restore-hidden-threads-configuration ,config)))))
2196 (defun gnus-hidden-threads-configuration ()
2197 "Return the current hidden threads configuration."
2200 (goto-char (point-min))
2201 (while (search-forward "\r" nil t)
2202 (push (1- (point)) config))
2205 (defun gnus-restore-hidden-threads-configuration (config)
2206 "Restore hidden threads configuration from CONFIG."
2207 (let (point buffer-read-only)
2208 (while (setq point (pop config))
2209 (when (and (< point (point-max))
2211 (= (following-char) ?\n))
2212 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2214 ;; Various summary mode internalish functions.
2216 (defun gnus-mouse-pick-article (e)
2219 (gnus-summary-next-page nil t))
2221 (defun gnus-summary-set-display-table ()
2222 ;; Change the display table. Odd characters have a tendency to mess
2223 ;; up nicely formatted displays - we make all possible glyphs
2224 ;; display only a single character.
2226 ;; We start from the standard display table, if any.
2227 (let ((table (or (copy-sequence standard-display-table)
2228 (make-display-table)))
2230 ;; Nix out all the control chars...
2231 (while (>= (setq i (1- i)) 0)
2232 (aset table i [??]))
2233 ;; ... but not newline and cr, of course. (cr is necessary for the
2234 ;; selective display).
2235 (aset table ?\n nil)
2236 (aset table ?\r nil)
2237 ;; We nix out any glyphs over 126 that are not set already.
2239 (while (>= (setq i (1- i)) 127)
2240 ;; Only modify if the entry is nil.
2241 (unless (aref table i)
2242 (aset table i [??]))))
2243 (setq buffer-display-table table)))
2245 (defun gnus-summary-setup-buffer (group)
2246 "Initialize summary buffer."
2247 (let ((buffer (concat "*Summary " group "*")))
2248 (if (get-buffer buffer)
2251 (setq gnus-summary-buffer (current-buffer))
2252 (not gnus-newsgroup-prepared))
2253 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2254 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2255 (gnus-add-current-to-buffer-list)
2256 (gnus-summary-mode group)
2258 (gnus-carpal-setup-buffer 'summary))
2259 (unless gnus-single-article-buffer
2260 (make-local-variable 'gnus-article-buffer)
2261 (make-local-variable 'gnus-article-current)
2262 (make-local-variable 'gnus-original-article-buffer))
2263 (setq gnus-newsgroup-name group)
2266 (defun gnus-set-global-variables ()
2267 ;; Set the global equivalents of the summary buffer-local variables
2268 ;; to the latest values they had. These reflect the summary buffer
2269 ;; that was in action when the last article was fetched.
2270 (when (eq major-mode 'gnus-summary-mode)
2271 (setq gnus-summary-buffer (current-buffer))
2272 (let ((name gnus-newsgroup-name)
2273 (marked gnus-newsgroup-marked)
2274 (unread gnus-newsgroup-unreads)
2275 (headers gnus-current-headers)
2276 (data gnus-newsgroup-data)
2277 (summary gnus-summary-buffer)
2278 (article-buffer gnus-article-buffer)
2279 (original gnus-original-article-buffer)
2280 (gac gnus-article-current)
2281 (reffed gnus-reffed-article-number)
2282 (score-file gnus-current-score-file))
2284 (set-buffer gnus-group-buffer)
2285 (setq gnus-newsgroup-name name)
2286 (setq gnus-newsgroup-marked marked)
2287 (setq gnus-newsgroup-unreads unread)
2288 (setq gnus-current-headers headers)
2289 (setq gnus-newsgroup-data data)
2290 (setq gnus-article-current gac)
2291 (setq gnus-summary-buffer summary)
2292 (setq gnus-article-buffer article-buffer)
2293 (setq gnus-original-article-buffer original)
2294 (setq gnus-reffed-article-number reffed)
2295 (setq gnus-current-score-file score-file)
2296 ;; The article buffer also has local variables.
2297 (when (gnus-buffer-live-p gnus-article-buffer)
2298 (set-buffer gnus-article-buffer)
2299 (setq gnus-summary-buffer summary))))))
2301 (defun gnus-summary-article-unread-p (article)
2302 "Say whether ARTICLE is unread or not."
2303 (memq article gnus-newsgroup-unreads))
2305 (defun gnus-summary-first-article-p (&optional article)
2306 "Return whether ARTICLE is the first article in the buffer."
2307 (if (not (setq article (or article (gnus-summary-article-number))))
2309 (eq article (caar gnus-newsgroup-data))))
2311 (defun gnus-summary-last-article-p (&optional article)
2312 "Return whether ARTICLE is the last article in the buffer."
2313 (if (not (setq article (or article (gnus-summary-article-number))))
2314 t ; All non-existent numbers are the last article. :-)
2315 (not (cdr (gnus-data-find-list article)))))
2317 (defun gnus-make-thread-indent-array ()
2319 (unless (and gnus-thread-indent-array
2320 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2321 (setq gnus-thread-indent-array (make-vector 201 "")
2322 gnus-thread-indent-array-level gnus-thread-indent-level)
2324 (aset gnus-thread-indent-array n
2325 (make-string (* n gnus-thread-indent-level) ? ))
2328 (defun gnus-update-summary-mark-positions ()
2329 "Compute where the summary marks are to go."
2331 (when (and gnus-summary-buffer
2332 (get-buffer gnus-summary-buffer)
2333 (buffer-name (get-buffer gnus-summary-buffer)))
2334 (set-buffer gnus-summary-buffer))
2335 (let ((gnus-replied-mark 129)
2336 (gnus-score-below-mark 130)
2337 (gnus-score-over-mark 130)
2338 (gnus-download-mark 131)
2339 (spec gnus-summary-line-format-spec)
2340 thread gnus-visual pos)
2342 (gnus-set-work-buffer)
2343 (let ((gnus-summary-line-format-spec spec)
2344 (gnus-newsgroup-downloadable '((0 . t))))
2345 (gnus-summary-insert-line
2346 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2347 (goto-char (point-min))
2348 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2350 (goto-char (point-min))
2351 (push (cons 'replied (and (search-forward "\201" nil t)
2354 (goto-char (point-min))
2355 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2357 (goto-char (point-min))
2358 (push (cons 'download
2359 (and (search-forward "\203" nil t) (- (point) 2)))
2361 (setq gnus-summary-mark-positions pos))))
2363 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2364 "Insert a dummy root in the summary buffer."
2366 (gnus-add-text-properties
2367 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2368 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2370 (defun gnus-summary-insert-line (gnus-tmp-header
2371 gnus-tmp-level gnus-tmp-current
2372 gnus-tmp-unread gnus-tmp-replied
2373 gnus-tmp-expirable gnus-tmp-subject-or-nil
2374 &optional gnus-tmp-dummy gnus-tmp-score
2376 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2377 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2378 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2379 (gnus-tmp-score-char
2380 (if (or (null gnus-summary-default-score)
2381 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2382 gnus-summary-zcore-fuzz))
2384 (if (< gnus-tmp-score gnus-summary-default-score)
2385 gnus-score-below-mark gnus-score-over-mark)))
2387 (cond (gnus-tmp-process gnus-process-mark)
2388 ((memq gnus-tmp-current gnus-newsgroup-cached)
2390 (gnus-tmp-replied gnus-replied-mark)
2391 ((memq gnus-tmp-current gnus-newsgroup-saved)
2393 (t gnus-unread-mark)))
2394 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2397 ((string-match "<[^>]+> *$" gnus-tmp-from)
2398 (let ((beg (match-beginning 0)))
2399 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2400 (substring gnus-tmp-from (1+ (match-beginning 0))
2401 (1- (match-end 0))))
2402 (substring gnus-tmp-from 0 beg))))
2403 ((string-match "(.+)" gnus-tmp-from)
2404 (substring gnus-tmp-from
2405 (1+ (match-beginning 0)) (1- (match-end 0))))
2407 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2408 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2409 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2410 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2411 (buffer-read-only nil))
2412 (when (string= gnus-tmp-name "")
2413 (setq gnus-tmp-name gnus-tmp-from))
2414 (unless (numberp gnus-tmp-lines)
2415 (setq gnus-tmp-lines 0))
2416 (gnus-put-text-property
2418 (progn (eval gnus-summary-line-format-spec) (point))
2419 'gnus-number gnus-tmp-number)
2420 (when (gnus-visual-p 'summary-highlight 'highlight)
2422 (run-hooks 'gnus-summary-update-hook)
2425 (defun gnus-summary-update-line (&optional dont-update)
2426 ;; Update summary line after change.
2427 (when (and gnus-summary-default-score
2428 (not gnus-summary-inhibit-highlight))
2429 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2430 (article (gnus-summary-article-number))
2431 (score (gnus-summary-article-score article)))
2433 (if (and gnus-summary-mark-below
2434 (< (gnus-summary-article-score)
2435 gnus-summary-mark-below))
2436 ;; This article has a low score, so we mark it as read.
2437 (when (memq article gnus-newsgroup-unreads)
2438 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2439 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2440 ;; This article was previously marked as read on account
2441 ;; of a low score, but now it has risen, so we mark it as
2443 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2444 (gnus-summary-update-mark
2445 (if (or (null gnus-summary-default-score)
2446 (<= (abs (- score gnus-summary-default-score))
2447 gnus-summary-zcore-fuzz))
2449 (if (< score gnus-summary-default-score)
2450 gnus-score-below-mark gnus-score-over-mark))
2452 ;; Do visual highlighting.
2453 (when (gnus-visual-p 'summary-highlight 'highlight)
2454 (run-hooks 'gnus-summary-update-hook)))))
2456 (defvar gnus-tmp-new-adopts nil)
2458 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2459 "Return the number of articles in THREAD.
2460 This may be 0 in some cases -- if none of the articles in
2461 the thread are to be displayed."
2463 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2465 ((not (listp thread))
2467 ((and (consp thread) (cdr thread))
2470 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2473 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2476 (when (and level (zerop level) gnus-tmp-new-adopts)
2479 'gnus-summary-number-of-articles-in-thread
2480 gnus-tmp-new-adopts))))
2482 (if (> number 1) gnus-not-empty-thread-mark
2483 gnus-empty-thread-mark)
2486 (defun gnus-summary-set-local-parameters (group)
2487 "Go through the local params of GROUP and set all variable specs in that list."
2488 (let ((params (gnus-group-find-parameter group))
2491 (setq elem (car params)
2492 params (cdr params))
2493 (and (consp elem) ; Has to be a cons.
2494 (consp (cdr elem)) ; The cdr has to be a list.
2495 (symbolp (car elem)) ; Has to be a symbol in there.
2496 (not (memq (car elem)
2497 '(quit-config to-address to-list to-group)))
2498 (ignore-errors ; So we set it.
2499 (make-local-variable (car elem))
2500 (set (car elem) (eval (nth 1 elem))))))))
2502 (defun gnus-summary-read-group (group &optional show-all no-article
2503 kill-buffer no-display)
2504 "Start reading news in newsgroup GROUP.
2505 If SHOW-ALL is non-nil, already read articles are also listed.
2506 If NO-ARTICLE is non-nil, no article is selected initially.
2507 If NO-DISPLAY, don't generate a summary buffer."
2511 (let ((gnus-auto-select-next nil))
2512 (gnus-summary-read-group-1
2513 group show-all no-article
2514 kill-buffer no-display))))
2515 (eq gnus-auto-select-next 'quietly))
2516 (set-buffer gnus-group-buffer)
2517 (if (not (equal group (gnus-group-group-name)))
2518 (setq group (gnus-group-group-name))
2522 (defun gnus-summary-read-group-1 (group show-all no-article
2523 kill-buffer no-display)
2524 ;; Killed foreign groups can't be entered.
2525 (when (and (not (gnus-group-native-p group))
2526 (not (gnus-gethash group gnus-newsrc-hashtb)))
2527 (error "Dead non-native groups can't be entered"))
2528 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2529 (let* ((new-group (gnus-summary-setup-buffer group))
2530 (quit-config (gnus-group-quit-config group))
2531 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2533 ;; This summary buffer exists already, so we just select it.
2535 (gnus-set-global-variables)
2537 (gnus-kill-or-deaden-summary kill-buffer))
2538 (gnus-configure-windows 'summary 'force)
2539 (gnus-set-mode-line 'summary)
2540 (gnus-summary-position-point)
2543 ;; We couldn't select this group.
2545 (when (and (eq major-mode 'gnus-summary-mode)
2546 (not (equal (current-buffer) kill-buffer)))
2547 (kill-buffer (current-buffer))
2548 (if (not quit-config)
2550 (set-buffer gnus-group-buffer)
2551 (gnus-group-jump-to-group group)
2552 (gnus-group-next-unread-group 1))
2553 (gnus-handle-ephemeral-exit quit-config)))
2554 (gnus-message 3 "Can't select group")
2556 ;; The user did a `C-g' while prompting for number of articles,
2557 ;; so we exit this group.
2558 ((eq did-select 'quit)
2559 (and (eq major-mode 'gnus-summary-mode)
2560 (not (equal (current-buffer) kill-buffer))
2561 (kill-buffer (current-buffer)))
2563 (gnus-kill-or-deaden-summary kill-buffer))
2564 (if (not quit-config)
2566 (set-buffer gnus-group-buffer)
2567 (gnus-group-jump-to-group group)
2568 (gnus-group-next-unread-group 1)
2569 (gnus-configure-windows 'group 'force))
2570 (gnus-handle-ephemeral-exit quit-config))
2571 ;; Finally signal the quit.
2573 ;; The group was successfully selected.
2575 (gnus-set-global-variables)
2576 ;; Save the active value in effect when the group was entered.
2577 (setq gnus-newsgroup-active
2579 (gnus-active gnus-newsgroup-name)))
2580 ;; You can change the summary buffer in some way with this hook.
2581 (run-hooks 'gnus-select-group-hook)
2582 ;; Set any local variables in the group parameters.
2583 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2584 (gnus-update-format-specifications
2585 nil 'summary 'summary-mode 'summary-dummy)
2586 ;; Do score processing.
2587 (when gnus-use-scoring
2588 (gnus-possibly-score-headers))
2589 ;; Check whether to fill in the gaps in the threads.
2590 (when gnus-build-sparse-threads
2591 (gnus-build-sparse-threads))
2592 ;; Find the initial limit.
2593 (if gnus-show-threads
2595 (let ((gnus-newsgroup-dormant nil))
2596 (gnus-summary-initial-limit show-all))
2597 (gnus-summary-initial-limit show-all))
2598 (setq gnus-newsgroup-limit
2600 (lambda (header) (mail-header-number header))
2601 gnus-newsgroup-headers)))
2602 ;; Generate the summary buffer.
2604 (gnus-summary-prepare))
2605 (when gnus-use-trees
2606 (gnus-tree-open group)
2607 (setq gnus-summary-highlight-line-function
2608 'gnus-tree-highlight-article))
2609 ;; If the summary buffer is empty, but there are some low-scored
2610 ;; articles or some excluded dormants, we include these in the
2612 (when (and (zerop (buffer-size))
2614 (cond (gnus-newsgroup-dormant
2615 (gnus-summary-limit-include-dormant))
2616 ((and gnus-newsgroup-scored show-all)
2617 (gnus-summary-limit-include-expunged t))))
2618 ;; Function `gnus-apply-kill-file' must be called in this hook.
2619 (run-hooks 'gnus-apply-kill-hook)
2620 (if (and (zerop (buffer-size))
2623 ;; This newsgroup is empty.
2624 (gnus-summary-catchup-and-exit nil t)
2625 (gnus-message 6 "No unread news")
2627 (gnus-kill-or-deaden-summary kill-buffer))
2628 ;; Return nil from this function.
2630 ;; Hide conversation thread subtrees. We cannot do this in
2631 ;; gnus-summary-prepare-hook since kill processing may not
2632 ;; work with hidden articles.
2633 (and gnus-show-threads
2634 gnus-thread-hide-subtree
2635 (gnus-summary-hide-all-threads))
2636 ;; Show first unread article if requested.
2637 (if (and (not no-article)
2639 gnus-newsgroup-unreads
2640 gnus-auto-select-first)
2641 (unless (if (eq gnus-auto-select-first 'best)
2642 (gnus-summary-best-unread-article)
2643 (gnus-summary-first-unread-article))
2644 (gnus-configure-windows 'summary))
2645 ;; Don't select any articles, just move point to the first
2646 ;; article in the group.
2647 (goto-char (point-min))
2648 (gnus-summary-position-point)
2649 (gnus-set-mode-line 'summary)
2650 (gnus-configure-windows 'summary 'force))
2652 (gnus-kill-or-deaden-summary kill-buffer))
2653 (when (get-buffer-window gnus-group-buffer t)
2654 ;; Gotta use windows, because recenter does weird stuff if
2655 ;; the current buffer ain't the displayed window.
2656 (let ((owin (selected-window)))
2657 (select-window (get-buffer-window gnus-group-buffer t))
2658 (when (gnus-group-goto-group group)
2660 (select-window owin)))
2661 ;; Mark this buffer as "prepared".
2662 (setq gnus-newsgroup-prepared t)
2665 (defun gnus-summary-prepare ()
2666 "Generate the summary buffer."
2668 (let ((buffer-read-only nil))
2670 (setq gnus-newsgroup-data nil
2671 gnus-newsgroup-data-reverse nil)
2672 (run-hooks 'gnus-summary-generate-hook)
2673 ;; Generate the buffer, either with threads or without.
2674 (when gnus-newsgroup-headers
2675 (gnus-summary-prepare-threads
2676 (if gnus-show-threads
2677 (gnus-sort-gathered-threads
2678 (funcall gnus-summary-thread-gathering-function
2680 (gnus-cut-threads (gnus-make-threads)))))
2681 ;; Unthreaded display.
2682 (gnus-sort-articles gnus-newsgroup-headers))))
2683 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2684 ;; Call hooks for modifying summary buffer.
2685 (goto-char (point-min))
2686 (run-hooks 'gnus-summary-prepare-hook)))
2688 (defsubst gnus-general-simplify-subject (subject)
2689 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2692 ;; Truncate the subject.
2693 ((numberp gnus-summary-gather-subject-limit)
2694 (setq subject (gnus-simplify-subject-re subject))
2695 (if (> (length subject) gnus-summary-gather-subject-limit)
2696 (substring subject 0 gnus-summary-gather-subject-limit)
2698 ;; Fuzzily simplify it.
2699 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2700 (gnus-simplify-subject-fuzzy subject))
2701 ;; Just remove the leading "Re:".
2703 (gnus-simplify-subject-re subject))))
2705 (if (and gnus-summary-gather-exclude-subject
2706 (string-match gnus-summary-gather-exclude-subject subject))
2707 nil ; This article shouldn't be gathered
2710 (defun gnus-summary-simplify-subject-query ()
2711 "Query where the respool algorithm would put this article."
2713 (gnus-set-global-variables)
2714 (gnus-summary-select-article)
2715 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2717 (defun gnus-gather-threads-by-subject (threads)
2718 "Gather threads by looking at Subject headers."
2719 (if (not gnus-summary-make-false-root)
2721 (let ((hashtb (gnus-make-hashtable 1024))
2724 subject hthread whole-subject)
2726 (setq subject (gnus-general-simplify-subject
2727 (setq whole-subject (mail-header-subject
2730 (if (setq hthread (gnus-gethash subject hashtb))
2732 ;; We enter a dummy root into the thread, if we
2733 ;; haven't done that already.
2734 (unless (stringp (caar hthread))
2735 (setcar hthread (list whole-subject (car hthread))))
2736 ;; We add this new gathered thread to this gathered
2738 (setcdr (car hthread)
2739 (nconc (cdar hthread) (list (car threads))))
2740 ;; Remove it from the list of threads.
2741 (setcdr prev (cdr threads))
2742 (setq threads prev))
2743 ;; Enter this thread into the hash table.
2744 (gnus-sethash subject threads hashtb)))
2746 (setq threads (cdr threads)))
2749 (defun gnus-gather-threads-by-references (threads)
2750 "Gather threads by looking at References headers."
2751 (let ((idhashtb (gnus-make-hashtable 1024))
2752 (thhashtb (gnus-make-hashtable 1024))
2755 ids references id gthread gid entered ref)
2757 (when (setq references (mail-header-references (caar threads)))
2758 (setq id (mail-header-id (caar threads))
2759 ids (gnus-split-references references)
2761 (while (setq ref (pop ids))
2762 (setq ids (delete ref ids))
2763 (if (not (setq gid (gnus-gethash ref idhashtb)))
2765 (gnus-sethash ref id idhashtb)
2766 (gnus-sethash id threads thhashtb))
2767 (setq gthread (gnus-gethash gid thhashtb))
2769 ;; We enter a dummy root into the thread, if we
2770 ;; haven't done that already.
2771 (unless (stringp (caar gthread))
2772 (setcar gthread (list (mail-header-subject (caar gthread))
2774 ;; We add this new gathered thread to this gathered
2776 (setcdr (car gthread)
2777 (nconc (cdar gthread) (list (car threads)))))
2778 ;; Add it into the thread hash table.
2779 (gnus-sethash id gthread thhashtb)
2781 ;; Remove it from the list of threads.
2782 (setcdr prev (cdr threads))
2783 (setq threads prev))))
2785 (setq threads (cdr threads)))
2788 (defun gnus-sort-gathered-threads (threads)
2789 "Sort subtreads inside each gathered thread by article number."
2790 (let ((result threads))
2792 (when (stringp (caar threads))
2793 (setcdr (car threads)
2794 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2795 (setq threads (cdr threads)))
2798 (defun gnus-thread-loop-p (root thread)
2799 "Say whether ROOT is in THREAD."
2800 (let ((stack (list thread))
2803 (while (setq thread (pop stack))
2804 (setq th (cdr thread))
2806 (not (eq (caar th) root)))
2809 ;; We have found a loop.
2811 (setcdr thread (delq (car th) (cdr thread)))
2812 (if (boundp (setq ref-dep (intern "none"
2813 gnus-newsgroup-dependencies)))
2814 (setcdr (symbol-value ref-dep)
2815 (nconc (cdr (symbol-value ref-dep))
2817 (set ref-dep (list nil (car th))))
2820 ;; Push all the subthreads onto the stack.
2821 (push (cdr thread) stack)))
2824 (defun gnus-make-threads ()
2825 "Go through the dependency hashtb and find the roots. Return all threads."
2827 (while (catch 'infloop
2830 ;; Deal with self-referencing References loops.
2831 (when (and (car (symbol-value refs))
2838 (car (symbol-value refs)) thread))
2839 (cdr (symbol-value refs)))))))
2842 (unless (car (symbol-value refs))
2843 ;; These threads do not refer back to any other articles,
2844 ;; so they're roots.
2845 (setq threads (append (cdr (symbol-value refs)) threads))))
2846 gnus-newsgroup-dependencies)))
2849 (defun gnus-build-sparse-threads ()
2850 (let ((headers gnus-newsgroup-headers)
2851 (deps gnus-newsgroup-dependencies)
2852 header references generation relations
2853 cthread subject child end pthread relation)
2854 ;; First we create an alist of generations/relations, where
2855 ;; generations is how much we trust the relation, and the relation
2857 (gnus-message 7 "Making sparse threads...")
2859 (nnheader-set-temp-buffer " *gnus sparse threads*")
2860 (while (setq header (pop headers))
2861 (when (and (setq references (mail-header-references header))
2862 (not (string= references "")))
2864 (setq child (mail-header-id header)
2865 subject (mail-header-subject header))
2867 (while (search-backward ">" nil t)
2868 (setq end (1+ (point)))
2869 (when (search-backward "<" nil t)
2870 (push (list (incf generation)
2871 child (setq child (buffer-substring (point) end))
2874 (push (list (1+ generation) child nil subject) relations)
2876 (kill-buffer (current-buffer)))
2877 ;; Sort over trustworthiness.
2878 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2879 (while (setq relation (pop relations))
2880 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2881 (unless (car (symbol-value cthread))
2882 ;; Make this article the parent of these threads.
2883 (setcar (symbol-value cthread)
2884 (vector gnus-reffed-article-number
2888 (or (caddr relation) "") 0 0 "")))
2889 (set cthread (list (vector gnus-reffed-article-number
2891 "" "" (cadr relation)
2892 (or (caddr relation) "") 0 0 ""))))
2893 (push gnus-reffed-article-number gnus-newsgroup-limit)
2894 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2895 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2896 gnus-newsgroup-reads)
2897 (decf gnus-reffed-article-number)
2898 ;; Make this new thread the child of its parent.
2899 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2900 (setcdr (symbol-value pthread)
2901 (nconc (cdr (symbol-value pthread))
2902 (list (symbol-value cthread))))
2903 (set pthread (list nil (symbol-value cthread))))))
2904 (gnus-message 7 "Making sparse threads...done")))
2906 (defun gnus-build-old-threads ()
2907 ;; Look at all the articles that refer back to old articles, and
2908 ;; fetch the headers for the articles that aren't there. This will
2909 ;; build complete threads - if the roots haven't been expired by the
2914 (when (not (car (symbol-value refs)))
2915 (setq heads (cdr (symbol-value refs)))
2917 (if (memq (mail-header-number (caar heads))
2918 gnus-newsgroup-dormant)
2919 (setq heads (cdr heads))
2920 (setq id (symbol-name refs))
2921 (while (and (setq id (gnus-build-get-header id))
2922 (not (car (gnus-gethash
2923 id gnus-newsgroup-dependencies)))))
2924 (setq heads nil)))))
2925 gnus-newsgroup-dependencies)))
2927 (defun gnus-build-get-header (id)
2928 ;; Look through the buffer of NOV lines and find the header to
2929 ;; ID. Enter this line into the dependencies hash table, and return
2930 ;; the id of the parent article (if any).
2931 (let ((deps gnus-newsgroup-dependencies)
2935 (set-buffer nntp-server-buffer)
2936 (let ((case-fold-search nil))
2937 (goto-char (point-min))
2938 (while (and (not found)
2939 (search-forward id nil t))
2941 (setq found (looking-at
2942 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2943 (regexp-quote id))))
2944 (or found (beginning-of-line 2)))
2948 (setq header (gnus-nov-parse-line
2949 (read (current-buffer)) deps))
2950 (gnus-parent-id (mail-header-references header))))))
2952 (let ((number (mail-header-number header)))
2953 (push number gnus-newsgroup-limit)
2954 (push header gnus-newsgroup-headers)
2955 (if (memq number gnus-newsgroup-unselected)
2957 (push number gnus-newsgroup-unreads)
2958 (setq gnus-newsgroup-unselected
2959 (delq number gnus-newsgroup-unselected)))
2960 (push number gnus-newsgroup-ancient)))))))
2962 (defun gnus-summary-update-article-line (article header)
2963 "Update the line for ARTICLE using HEADERS."
2964 (let* ((id (mail-header-id header))
2965 (thread (gnus-id-to-thread id)))
2967 (error "Article in no thread"))
2968 ;; Update the thread.
2969 (setcar thread header)
2970 (gnus-summary-goto-subject article)
2971 (let* ((datal (gnus-data-find-list article))
2973 (length (when (cdr datal)
2974 (- (gnus-data-pos data)
2975 (gnus-data-pos (cadr datal)))))
2976 (buffer-read-only nil)
2977 (level (gnus-summary-thread-level)))
2979 (gnus-summary-insert-line
2980 header level nil (gnus-article-mark article)
2981 (memq article gnus-newsgroup-replied)
2982 (memq article gnus-newsgroup-expirable)
2983 ;; Only insert the Subject string when it's different
2984 ;; from the previous Subject string.
2985 (if (gnus-subject-equal
2987 (mail-header-subject
2990 (gnus-data-find-list
2992 (gnus-data-list t)))))
2993 ;; Error on the side of excessive subjects.
2995 (mail-header-subject header))
2997 (mail-header-subject header))
2998 nil (cdr (assq article gnus-newsgroup-scored))
2999 (memq article gnus-newsgroup-processable))
3001 (gnus-data-update-list
3002 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3004 (defun gnus-summary-update-article (article &optional iheader)
3005 "Update ARTICLE in the summary buffer."
3006 (set-buffer gnus-summary-buffer)
3007 (let* ((header (or iheader (gnus-summary-article-header article)))
3008 (id (mail-header-id header))
3009 (data (gnus-data-find article))
3010 (thread (gnus-id-to-thread id))
3011 (references (mail-header-references header))
3015 (when (and references
3016 (not (equal "" references)))
3019 (buffer-read-only nil)
3021 (number (mail-header-number header))
3024 ;; !!! Should this be in or not?
3026 (setcar thread nil))
3028 (delq thread parent))
3029 (if (gnus-summary-insert-subject id header iheader)
3030 ;; Set the (possibly) new article number in the data structure.
3031 (gnus-data-set-number data (gnus-id-to-article id))
3035 (defun gnus-rebuild-thread (id)
3036 "Rebuild the thread containing ID."
3037 (let ((buffer-read-only nil)
3038 old-pos current thread data)
3039 (if (not gnus-show-threads)
3040 (setq thread (list (car (gnus-id-to-thread id))))
3041 ;; Get the thread this article is part of.
3042 (setq thread (gnus-remove-thread id)))
3043 (setq old-pos (gnus-point-at-bol))
3044 (setq current (save-excursion
3045 (and (zerop (forward-line -1))
3046 (gnus-summary-article-number))))
3047 ;; If this is a gathered thread, we have to go some re-gathering.
3048 (when (stringp (car thread))
3049 (let ((subject (car thread))
3051 (setq thread (cdr thread))
3053 (unless (memq (setq thr (gnus-id-to-thread
3055 (mail-header-id (caar thread)))))
3058 (setq thread (cdr thread)))
3059 ;; We now have all (unique) roots.
3060 (if (= (length roots) 1)
3061 ;; All the loose roots are now one solid root.
3062 (setq thread (car roots))
3063 (setq thread (cons subject (gnus-sort-threads roots))))))
3065 ;; We then insert this thread into the summary buffer.
3066 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3067 (if gnus-show-threads
3068 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3069 (gnus-summary-prepare-unthreaded thread))
3070 (setq data (nreverse gnus-newsgroup-data))
3071 (setq threads gnus-newsgroup-threads))
3072 ;; We splice the new data into the data structure.
3073 (gnus-data-enter-list current data (- (point) old-pos))
3074 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3076 (defun gnus-number-to-header (number)
3077 "Return the header for article NUMBER."
3078 (let ((headers gnus-newsgroup-headers))
3080 (not (= number (mail-header-number (car headers)))))
3085 (defun gnus-parent-headers (headers &optional generation)
3086 "Return the headers of the GENERATIONeth parent of HEADERS."
3088 (setq generation 1))
3091 (while (and parent headers (not (zerop generation)))
3092 (setq references (mail-header-references headers))
3093 (when (and references
3094 (setq parent (gnus-parent-id references))
3095 (setq headers (car (gnus-id-to-thread parent))))
3099 (defun gnus-id-to-thread (id)
3100 "Return the (sub-)thread where ID appears."
3101 (gnus-gethash id gnus-newsgroup-dependencies))
3103 (defun gnus-id-to-article (id)
3104 "Return the article number of ID."
3105 (let ((thread (gnus-id-to-thread id)))
3108 (mail-header-number (car thread)))))
3110 (defun gnus-id-to-header (id)
3111 "Return the article headers of ID."
3112 (car (gnus-id-to-thread id)))
3114 (defun gnus-article-displayed-root-p (article)
3115 "Say whether ARTICLE is a root(ish) article."
3116 (let ((level (gnus-summary-thread-level article))
3117 (refs (mail-header-references (gnus-summary-article-header article)))
3123 ((null (gnus-parent-id refs)) t)
3125 (null (setq particle (gnus-id-to-article
3126 (gnus-parent-id refs))))
3127 (null (gnus-summary-thread-level particle)))))))
3129 (defun gnus-root-id (id)
3130 "Return the id of the root of the thread where ID appears."
3132 (while (and id (setq prev (car (gnus-gethash
3133 id gnus-newsgroup-dependencies))))
3135 id (gnus-parent-id (mail-header-references prev))))
3138 (defun gnus-remove-thread (id &optional dont-remove)
3139 "Remove the thread that has ID in it."
3140 (let ((dep gnus-newsgroup-dependencies)
3141 headers thread last-id)
3142 ;; First go up in this thread until we find the root.
3143 (setq last-id (gnus-root-id id))
3144 (setq headers (list (car (gnus-id-to-thread last-id))
3145 (caadr (gnus-id-to-thread last-id))))
3146 ;; We have now found the real root of this thread. It might have
3147 ;; been gathered into some loose thread, so we have to search
3148 ;; through the threads to find the thread we wanted.
3149 (let ((threads gnus-newsgroup-threads)
3152 (setq sub (car threads))
3153 (if (stringp (car sub))
3154 ;; This is a gathered thread, so we look at the roots
3155 ;; below it to find whether this article is in this
3158 (setq sub (cdr sub))
3160 (when (member (caar sub) headers)
3161 (setq thread (car threads)
3164 (setq sub (cdr sub))))
3165 ;; It's an ordinary thread, so we check it.
3166 (when (eq (car sub) (car headers))
3169 (setq threads (cdr threads)))
3170 ;; If this article is in no thread, then it's a root.
3173 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3174 (setq thread (gnus-gethash last-id dep)))
3177 thread ; We return this thread.
3179 (if (stringp (car thread))
3181 ;; If we use dummy roots, then we have to remove the
3182 ;; dummy root as well.
3183 (when (eq gnus-summary-make-false-root 'dummy)
3185 (gnus-data-compute-positions))
3186 (setq thread (cdr thread))
3188 (gnus-remove-thread-1 (car thread))
3189 (setq thread (cdr thread))))
3190 (gnus-remove-thread-1 thread))))))))
3192 (defun gnus-remove-thread-1 (thread)
3193 "Remove the thread THREAD recursively."
3194 (let ((number (mail-header-number (pop thread)))
3196 (setq thread (reverse thread))
3198 (gnus-remove-thread-1 (pop thread)))
3199 (when (setq d (gnus-data-find number))
3200 (goto-char (gnus-data-pos d))
3203 (- (gnus-point-at-bol)
3205 (1+ (gnus-point-at-eol))
3206 (gnus-delete-line)))))))
3208 (defun gnus-sort-threads (threads)
3210 (if (not gnus-thread-sort-functions)
3212 (gnus-message 7 "Sorting threads...")
3214 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3215 (gnus-message 7 "Sorting threads...done"))))
3217 (defun gnus-sort-articles (articles)
3219 (when gnus-article-sort-functions
3220 (gnus-message 7 "Sorting articles...")
3222 (setq gnus-newsgroup-headers
3223 (sort articles (gnus-make-sort-function
3224 gnus-article-sort-functions)))
3225 (gnus-message 7 "Sorting articles...done"))))
3227 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3228 (defmacro gnus-thread-header (thread)
3229 ;; Return header of first article in THREAD.
3230 ;; Note that THREAD must never, ever be anything else than a variable -
3231 ;; using some other form will lead to serious barfage.
3232 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3233 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3234 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3237 (defsubst gnus-article-sort-by-number (h1 h2)
3238 "Sort articles by article number."
3239 (< (mail-header-number h1)
3240 (mail-header-number h2)))
3242 (defun gnus-thread-sort-by-number (h1 h2)
3243 "Sort threads by root article number."
3244 (gnus-article-sort-by-number
3245 (gnus-thread-header h1) (gnus-thread-header h2)))
3247 (defsubst gnus-article-sort-by-lines (h1 h2)
3248 "Sort articles by article Lines header."
3249 (< (mail-header-lines h1)
3250 (mail-header-lines h2)))
3252 (defun gnus-thread-sort-by-lines (h1 h2)
3253 "Sort threads by root article Lines header."
3254 (gnus-article-sort-by-lines
3255 (gnus-thread-header h1) (gnus-thread-header h2)))
3257 (defsubst gnus-article-sort-by-author (h1 h2)
3258 "Sort articles by root author."
3260 (let ((extract (funcall
3261 gnus-extract-address-components
3262 (mail-header-from h1))))
3263 (or (car extract) (cadr extract) ""))
3264 (let ((extract (funcall
3265 gnus-extract-address-components
3266 (mail-header-from h2))))
3267 (or (car extract) (cadr extract) ""))))
3269 (defun gnus-thread-sort-by-author (h1 h2)
3270 "Sort threads by root author."
3271 (gnus-article-sort-by-author
3272 (gnus-thread-header h1) (gnus-thread-header h2)))
3274 (defsubst gnus-article-sort-by-subject (h1 h2)
3275 "Sort articles by root subject."
3277 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3278 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3280 (defun gnus-thread-sort-by-subject (h1 h2)
3281 "Sort threads by root subject."
3282 (gnus-article-sort-by-subject
3283 (gnus-thread-header h1) (gnus-thread-header h2)))
3285 (defsubst gnus-article-sort-by-date (h1 h2)
3286 "Sort articles by root article date."
3288 (gnus-date-get-time (mail-header-date h1))
3289 (gnus-date-get-time (mail-header-date h2))))
3291 (defun gnus-thread-sort-by-date (h1 h2)
3292 "Sort threads by root article date."
3293 (gnus-article-sort-by-date
3294 (gnus-thread-header h1) (gnus-thread-header h2)))
3296 (defsubst gnus-article-sort-by-score (h1 h2)
3297 "Sort articles by root article score.
3298 Unscored articles will be counted as having a score of zero."
3299 (> (or (cdr (assq (mail-header-number h1)
3300 gnus-newsgroup-scored))
3301 gnus-summary-default-score 0)
3302 (or (cdr (assq (mail-header-number h2)
3303 gnus-newsgroup-scored))
3304 gnus-summary-default-score 0)))
3306 (defun gnus-thread-sort-by-score (h1 h2)
3307 "Sort threads by root article score."
3308 (gnus-article-sort-by-score
3309 (gnus-thread-header h1) (gnus-thread-header h2)))
3311 (defun gnus-thread-sort-by-total-score (h1 h2)
3312 "Sort threads by the sum of all scores in the thread.
3313 Unscored articles will be counted as having a score of zero."
3314 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3316 (defun gnus-thread-total-score (thread)
3317 ;; This function find the total score of THREAD.
3318 (cond ((null thread)
3321 (if (stringp (car thread))
3322 (apply gnus-thread-score-function 0
3323 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3324 (gnus-thread-total-score-1 thread)))
3326 (gnus-thread-total-score-1 (list thread)))))
3328 (defun gnus-thread-total-score-1 (root)
3329 ;; This function find the total score of the thread below ROOT.
3330 (setq root (car root))
3331 (apply gnus-thread-score-function
3333 (mapcar 'gnus-thread-total-score
3334 (cdr (gnus-gethash (mail-header-id root)
3335 gnus-newsgroup-dependencies)))
3336 (when (> (mail-header-number root) 0)
3337 (list (or (cdr (assq (mail-header-number root)
3338 gnus-newsgroup-scored))
3339 gnus-summary-default-score 0))))
3340 (list gnus-summary-default-score)
3343 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3344 (defvar gnus-tmp-prev-subject nil)
3345 (defvar gnus-tmp-false-parent nil)
3346 (defvar gnus-tmp-root-expunged nil)
3347 (defvar gnus-tmp-dummy-line nil)
3349 (defun gnus-summary-prepare-threads (threads)
3350 "Prepare summary buffer from THREADS and indentation LEVEL.
3351 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3352 or a straight list of headers."
3353 (gnus-message 7 "Generating summary...")
3355 (setq gnus-newsgroup-threads threads)
3358 (let ((gnus-tmp-level 0)
3359 (default-score (or gnus-summary-default-score 0))
3360 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3361 thread number subject stack state gnus-tmp-gathered beg-match
3362 new-roots gnus-tmp-new-adopts thread-end
3363 gnus-tmp-header gnus-tmp-unread
3364 gnus-tmp-replied gnus-tmp-subject-or-nil
3365 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3366 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3367 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3369 (setq gnus-tmp-prev-subject nil)
3371 (if (vectorp (car threads))
3372 ;; If this is a straight (sic) list of headers, then a
3373 ;; threaded summary display isn't required, so we just create
3374 ;; an unthreaded one.
3375 (gnus-summary-prepare-unthreaded threads)
3377 ;; Do the threaded display.
3379 (while (or threads stack gnus-tmp-new-adopts new-roots)
3381 (if (and (= gnus-tmp-level 0)
3382 (not (setq gnus-tmp-dummy-line nil))
3385 (not gnus-tmp-false-parent)
3386 (or gnus-tmp-new-adopts new-roots))
3387 (if gnus-tmp-new-adopts
3388 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3389 thread (list (car gnus-tmp-new-adopts))
3390 gnus-tmp-header (caar thread)
3391 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3393 (setq thread (list (car new-roots))
3394 gnus-tmp-header (caar thread)
3395 new-roots (cdr new-roots))))
3398 ;; If there are some threads, we do them before the
3399 ;; threads on the stack.
3400 (setq thread threads
3401 gnus-tmp-header (caar thread))
3402 ;; There were no current threads, so we pop something off
3404 (setq state (car stack)
3405 gnus-tmp-level (car state)
3408 gnus-tmp-header (caar thread))))
3410 (setq gnus-tmp-false-parent nil)
3411 (setq gnus-tmp-root-expunged nil)
3412 (setq thread-end nil)
3414 (if (stringp gnus-tmp-header)
3415 ;; The header is a dummy root.
3417 ((eq gnus-summary-make-false-root 'adopt)
3418 ;; We let the first article adopt the rest.
3419 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3421 (setq gnus-tmp-gathered
3423 (lambda (h) (mail-header-number (car h)))
3426 (setq thread (cons (list (caar thread)
3429 (setq gnus-tmp-level -1
3430 gnus-tmp-false-parent t))
3431 ((eq gnus-summary-make-false-root 'empty)
3432 ;; We print adopted articles with empty subject fields.
3433 (setq gnus-tmp-gathered
3435 (lambda (h) (mail-header-number (car h)))
3438 (setq gnus-tmp-level -1))
3439 ((eq gnus-summary-make-false-root 'dummy)
3440 ;; We remember that we probably want to output a dummy
3442 (setq gnus-tmp-dummy-line gnus-tmp-header)
3443 (setq gnus-tmp-prev-subject gnus-tmp-header))
3445 ;; We do not make a root for the gathered
3446 ;; sub-threads at all.
3447 (setq gnus-tmp-level -1)))
3449 (setq number (mail-header-number gnus-tmp-header)
3450 subject (mail-header-subject gnus-tmp-header))
3453 ;; If the thread has changed subject, we might want to make
3454 ;; this subthread into a root.
3455 ((and (null gnus-thread-ignore-subject)
3456 (not (zerop gnus-tmp-level))
3457 gnus-tmp-prev-subject
3459 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3460 (setq new-roots (nconc new-roots (list (car thread)))
3462 gnus-tmp-header nil))
3463 ;; If the article lies outside the current limit,
3464 ;; then we do not display it.
3465 ((not (memq number gnus-newsgroup-limit))
3466 (setq gnus-tmp-gathered
3468 (lambda (h) (mail-header-number (car h)))
3471 (setq gnus-tmp-new-adopts (if (cdar thread)
3472 (append gnus-tmp-new-adopts
3474 gnus-tmp-new-adopts)
3476 gnus-tmp-header nil)
3477 (when (zerop gnus-tmp-level)
3478 (setq gnus-tmp-root-expunged t)))
3479 ;; Perhaps this article is to be marked as read?
3480 ((and gnus-summary-mark-below
3481 (< (or (cdr (assq number gnus-newsgroup-scored))
3483 gnus-summary-mark-below)
3484 ;; Don't touch sparse articles.
3485 (not (gnus-summary-article-sparse-p number))
3486 (not (gnus-summary-article-ancient-p number)))
3487 (setq gnus-newsgroup-unreads
3488 (delq number gnus-newsgroup-unreads))
3489 (if gnus-newsgroup-auto-expire
3490 (push number gnus-newsgroup-expirable)
3491 (push (cons number gnus-low-score-mark)
3492 gnus-newsgroup-reads))))
3494 (when gnus-tmp-header
3495 ;; We may have an old dummy line to output before this
3497 (when gnus-tmp-dummy-line
3498 (gnus-summary-insert-dummy-line
3499 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3500 (setq gnus-tmp-dummy-line nil))
3502 ;; Compute the mark.
3503 (setq gnus-tmp-unread (gnus-article-mark number))
3505 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3506 gnus-tmp-header gnus-tmp-level)
3507 gnus-newsgroup-data)
3509 ;; Actually insert the line.
3511 gnus-tmp-subject-or-nil
3513 ((and gnus-thread-ignore-subject
3514 gnus-tmp-prev-subject
3515 (not (inline (gnus-subject-equal
3516 gnus-tmp-prev-subject subject))))
3518 ((zerop gnus-tmp-level)
3519 (if (and (eq gnus-summary-make-false-root 'empty)
3520 (memq number gnus-tmp-gathered)
3521 gnus-tmp-prev-subject
3522 (inline (gnus-subject-equal
3523 gnus-tmp-prev-subject subject)))
3524 gnus-summary-same-subject
3526 (t gnus-summary-same-subject)))
3527 (if (and (eq gnus-summary-make-false-root 'adopt)
3528 (= gnus-tmp-level 1)
3529 (memq number gnus-tmp-gathered))
3530 (setq gnus-tmp-opening-bracket ?\<
3531 gnus-tmp-closing-bracket ?\>)
3532 (setq gnus-tmp-opening-bracket ?\[
3533 gnus-tmp-closing-bracket ?\]))
3535 gnus-tmp-indentation
3536 (aref gnus-thread-indent-array gnus-tmp-level)
3537 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3538 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3539 gnus-summary-default-score 0)
3541 (if (or (null gnus-summary-default-score)
3542 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3543 gnus-summary-zcore-fuzz))
3545 (if (< gnus-tmp-score gnus-summary-default-score)
3546 gnus-score-below-mark gnus-score-over-mark))
3548 (cond ((memq number gnus-newsgroup-processable)
3550 ((memq number gnus-newsgroup-cached)
3552 ((memq number gnus-newsgroup-replied)
3554 ((memq number gnus-newsgroup-saved)
3556 (t gnus-unread-mark))
3557 gnus-tmp-from (mail-header-from gnus-tmp-header)
3560 ((string-match "<[^>]+> *$" gnus-tmp-from)
3561 (setq beg-match (match-beginning 0))
3562 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3563 (substring gnus-tmp-from (1+ (match-beginning 0))
3564 (1- (match-end 0))))
3565 (substring gnus-tmp-from 0 beg-match)))
3566 ((string-match "(.+)" gnus-tmp-from)
3567 (substring gnus-tmp-from
3568 (1+ (match-beginning 0)) (1- (match-end 0))))
3570 (when (string= gnus-tmp-name "")
3571 (setq gnus-tmp-name gnus-tmp-from))
3572 (unless (numberp gnus-tmp-lines)
3573 (setq gnus-tmp-lines 0))
3574 (gnus-put-text-property
3576 (progn (eval gnus-summary-line-format-spec) (point))
3577 'gnus-number number)
3580 (run-hooks 'gnus-summary-update-hook)
3583 (setq gnus-tmp-prev-subject subject)))
3585 (when (nth 1 thread)
3586 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3587 (incf gnus-tmp-level)
3588 (setq threads (if thread-end nil (cdar thread)))
3590 (setq gnus-tmp-level 0)))))
3591 (gnus-message 7 "Generating summary...done"))
3593 (defun gnus-summary-prepare-unthreaded (headers)
3594 "Generate an unthreaded summary buffer based on HEADERS."
3595 (let (header number mark)
3600 ;; We may have to root out some bad articles...
3601 (when (memq (setq number (mail-header-number
3602 (setq header (pop headers))))
3603 gnus-newsgroup-limit)
3604 ;; Mark article as read when it has a low score.
3605 (when (and gnus-summary-mark-below
3606 (< (or (cdr (assq number gnus-newsgroup-scored))
3607 gnus-summary-default-score 0)
3608 gnus-summary-mark-below)
3609 (not (gnus-summary-article-ancient-p number)))
3610 (setq gnus-newsgroup-unreads
3611 (delq number gnus-newsgroup-unreads))
3612 (if gnus-newsgroup-auto-expire
3613 (push number gnus-newsgroup-expirable)
3614 (push (cons number gnus-low-score-mark)
3615 gnus-newsgroup-reads)))
3617 (setq mark (gnus-article-mark number))
3618 (push (gnus-data-make number mark (1+ (point)) header 0)
3619 gnus-newsgroup-data)
3620 (gnus-summary-insert-line
3622 mark (memq number gnus-newsgroup-replied)
3623 (memq number gnus-newsgroup-expirable)
3624 (mail-header-subject header) nil
3625 (cdr (assq number gnus-newsgroup-scored))
3626 (memq number gnus-newsgroup-processable))))))
3628 (defun gnus-select-newsgroup (group &optional read-all)
3629 "Select newsgroup GROUP.
3630 If READ-ALL is non-nil, all articles in the group are selected."
3631 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3632 ;;!!! Dirty hack; should be removed.
3633 (gnus-summary-ignore-duplicates
3634 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3636 gnus-summary-ignore-duplicates))
3637 (info (nth 2 entry))
3638 articles fetched-articles cached)
3640 (unless (gnus-check-server
3641 (setq gnus-current-select-method
3642 (gnus-find-method-for-group group)))
3643 (error "Couldn't open server"))
3645 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3646 (gnus-activate-group group) ; Or we can activate it...
3647 (progn ; Or we bug out.
3648 (when (equal major-mode 'gnus-summary-mode)
3649 (kill-buffer (current-buffer)))
3650 (error "Couldn't request group %s: %s"
3651 group (gnus-status-message group))))
3653 (unless (gnus-request-group group t)
3654 (when (equal major-mode 'gnus-summary-mode)
3655 (kill-buffer (current-buffer)))
3656 (error "Couldn't request group %s: %s"
3657 group (gnus-status-message group)))
3659 (setq gnus-newsgroup-name group)
3660 (setq gnus-newsgroup-unselected nil)
3661 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3663 ;; Adjust and set lists of article marks.
3665 (gnus-adjust-marked-articles info))
3667 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3668 (when (gnus-virtual-group-p group)
3669 (setq cached gnus-newsgroup-cached))
3671 (setq gnus-newsgroup-unreads
3672 (gnus-set-difference
3673 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3674 gnus-newsgroup-dormant))
3676 (setq gnus-newsgroup-processable nil)
3678 (gnus-update-read-articles group gnus-newsgroup-unreads)
3679 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3680 (gnus-group-update-group group))
3682 (setq articles (gnus-articles-to-read group read-all))
3686 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3688 ((eq articles 0) nil)
3690 ;; Init the dependencies hash table.
3691 (setq gnus-newsgroup-dependencies
3692 (gnus-make-hashtable (length articles)))
3693 ;; Retrieve the headers and read them in.
3694 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3695 (setq gnus-newsgroup-headers
3697 (setq gnus-headers-retrieved-by
3698 (gnus-retrieve-headers
3699 articles gnus-newsgroup-name
3700 ;; We might want to fetch old headers, but
3701 ;; not if there is only 1 article.
3702 (and gnus-fetch-old-headers
3704 (not (eq gnus-fetch-old-headers 'some))
3705 (not (numberp gnus-fetch-old-headers)))
3706 (> (length articles) 1))))))
3707 (gnus-get-newsgroup-headers-xover
3708 articles nil nil gnus-newsgroup-name t)
3709 (gnus-get-newsgroup-headers)))
3710 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3712 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3714 (setq gnus-newsgroup-cached cached))
3716 ;; Suppress duplicates?
3717 (when gnus-suppress-duplicates
3718 (gnus-dup-suppress-articles))
3720 ;; Set the initial limit.
3721 (setq gnus-newsgroup-limit (copy-sequence articles))
3722 ;; Remove canceled articles from the list of unread articles.
3723 (setq gnus-newsgroup-unreads
3724 (gnus-set-sorted-intersection
3725 gnus-newsgroup-unreads
3726 (setq fetched-articles
3727 (mapcar (lambda (headers) (mail-header-number headers))
3728 gnus-newsgroup-headers))))
3729 ;; Removed marked articles that do not exist.
3730 (gnus-update-missing-marks
3731 (gnus-sorted-complement fetched-articles articles))
3732 ;; Let the Gnus agent mark articles as read.
3734 (gnus-agent-get-undownloaded-list))
3735 ;; We might want to build some more threads first.
3736 (and gnus-fetch-old-headers
3737 (eq gnus-headers-retrieved-by 'nov)
3738 (gnus-build-old-threads))
3739 ;; Check whether auto-expire is to be done in this group.
3740 (setq gnus-newsgroup-auto-expire
3741 (gnus-group-auto-expirable-p group))
3742 ;; Set up the article buffer now, if necessary.
3743 (unless gnus-single-article-buffer
3744 (gnus-article-setup-buffer))
3745 ;; First and last article in this newsgroup.
3746 (when gnus-newsgroup-headers
3747 (setq gnus-newsgroup-begin
3748 (mail-header-number (car gnus-newsgroup-headers))
3751 (gnus-last-element gnus-newsgroup-headers))))
3752 ;; GROUP is successfully selected.
3753 (or gnus-newsgroup-headers t)))))
3755 (defun gnus-articles-to-read (group &optional read-all)
3756 ;; Find out what articles the user wants to read.
3758 ;; Select all articles if `read-all' is non-nil, or if there
3759 ;; are no unread articles.
3761 (and (zerop (length gnus-newsgroup-marked))
3762 (zerop (length gnus-newsgroup-unreads)))
3763 (eq (gnus-group-find-parameter group 'display)
3765 (gnus-uncompress-range (gnus-active group))
3766 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3767 (copy-sequence gnus-newsgroup-unreads))
3769 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3770 (scored (length scored-list))
3771 (number (length articles))
3772 (marked (+ (length gnus-newsgroup-marked)
3773 (length gnus-newsgroup-dormant)))
3781 ((and (or (<= scored marked) (= scored number))
3782 (numberp gnus-large-newsgroup)
3783 (> number gnus-large-newsgroup))
3787 "How many articles from %s (default %d): "
3788 (gnus-limit-string gnus-newsgroup-name 35)
3790 (if (string-match "^[ \t]*$" input) number input)))
3791 ((and (> scored marked) (< scored number)
3792 (> (- scored number) 20))
3795 (format "%s %s (%d scored, %d total): "
3796 "How many articles from"
3797 group scored number))))
3798 (if (string-match "^[ \t]*$" input)
3802 (setq select (if (stringp select) (string-to-number select) select))
3803 (if (or (null select) (zerop select))
3805 (if (and (not (zerop scored)) (<= (abs select) scored))
3807 (setq articles (sort scored-list '<))
3808 (setq number (length articles)))
3809 (setq articles (copy-sequence articles)))
3811 (when (< (abs select) number)
3813 ;; Select the N oldest articles.
3814 (setcdr (nthcdr (1- (abs select)) articles) nil)
3815 ;; Select the N most recent articles.
3816 (setq articles (nthcdr (- number select) articles))))
3817 (setq gnus-newsgroup-unselected
3818 (gnus-sorted-intersection
3819 gnus-newsgroup-unreads
3820 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3823 (defun gnus-killed-articles (killed articles)
3826 (when (inline (gnus-member-of-range (car articles) killed))
3827 (push (car articles) out))
3828 (setq articles (cdr articles)))
3831 (defun gnus-uncompress-marks (marks)
3832 "Uncompress the mark ranges in MARKS."
3833 (let ((uncompressed '(score bookmark))
3836 (if (memq (caar marks) uncompressed)
3837 (push (car marks) out)
3838 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3839 (setq marks (cdr marks)))
3842 (defun gnus-adjust-marked-articles (info)
3843 "Set all article lists and remove all marks that are no longer legal."
3844 (let* ((marked-lists (gnus-info-marks info))
3845 (active (gnus-active (gnus-info-group info)))
3848 (types gnus-article-mark-lists)
3849 (uncompressed '(score bookmark killed))
3850 marks var articles article mark)
3853 (setq marks (pop marked-lists))
3854 (set (setq var (intern (format "gnus-newsgroup-%s"
3855 (car (rassq (setq mark (car marks))
3857 (if (memq (car marks) uncompressed) (cdr marks)
3858 (gnus-uncompress-range (cdr marks))))
3860 (setq articles (symbol-value var))
3862 ;; All articles have to be subsets of the active articles.
3864 ;; Adjust "simple" lists.
3865 ((memq mark '(tick dormant expire reply save))
3867 (when (or (< (setq article (pop articles)) min) (> article max))
3868 (set var (delq article (symbol-value var))))))
3870 ((memq mark uncompressed)
3871 (when (not (listp (cdr (symbol-value var))))
3872 (set var (list (symbol-value var))))
3873 (when (not (listp (cdr articles)))
3874 (setq articles (list articles)))
3876 (when (or (not (consp (setq article (pop articles))))
3877 (< (car article) min)
3878 (> (car article) max))
3879 (set var (delq article (symbol-value var))))))))))
3881 (defun gnus-update-missing-marks (missing)
3882 "Go through the list of MISSING articles and remove them mark lists."
3884 (let ((types gnus-article-mark-lists)
3886 ;; Go through all types.
3888 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3889 (when (symbol-value var)
3890 ;; This list has articles. So we delete all missing articles
3894 (set var (delq (pop m) (symbol-value var)))))))))
3896 (defun gnus-update-marks ()
3897 "Enter the various lists of marked articles into the newsgroup info list."
3898 (let ((types gnus-article-mark-lists)
3899 (info (gnus-get-info gnus-newsgroup-name))
3900 (uncompressed '(score bookmark killed))
3901 type list newmarked symbol)
3903 ;; Add all marks lists that are non-nil to the list of marks lists.
3904 (while (setq type (pop types))
3905 (when (setq list (symbol-value
3907 (intern (format "gnus-newsgroup-%s"
3910 ;; Get rid of the entries of the articles that have the
3912 (when (and (eq (cdr type) 'score)
3916 (prev (cons nil list))
3919 (if (or (not (consp (car arts)))
3920 (= (cdar arts) gnus-summary-default-score))
3921 (setcdr prev (cdr arts))
3923 (setq arts (cdr arts)))
3924 (setq list (cdr all))))
3926 (push (cons (cdr type)
3927 (if (memq (cdr type) uncompressed) list
3928 (gnus-compress-sequence
3929 (set symbol (sort list '<)) t)))
3932 ;; Enter these new marks into the info of the group.
3934 (setcar (nthcdr 3 info) newmarked)
3935 ;; Add the marks lists to the end of the info.
3937 (setcdr (nthcdr 2 info) (list newmarked))))
3939 ;; Cut off the end of the info if there's nothing else there.
3943 (when (nthcdr (decf i) info)
3944 (setcdr (nthcdr i info) nil)))))))
3946 (defun gnus-set-mode-line (where)
3947 "This function sets the mode line of the article or summary buffers.
3948 If WHERE is `summary', the summary mode line format will be used."
3949 ;; Is this mode line one we keep updated?
3950 (when (memq where gnus-updated-mode-lines)
3953 ;; We evaluate this in the summary buffer since these
3954 ;; variables are buffer-local to that buffer.
3955 (set-buffer gnus-summary-buffer)
3956 ;; We bind all these variables that are used in the `eval' form
3958 (let* ((mformat (symbol-value
3960 (format "gnus-%s-mode-line-format-spec" where))))
3961 (gnus-tmp-group-name gnus-newsgroup-name)
3962 (gnus-tmp-article-number (or gnus-current-article 0))
3963 (gnus-tmp-unread gnus-newsgroup-unreads)
3964 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3965 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3966 (gnus-tmp-unread-and-unselected
3967 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3968 (zerop gnus-tmp-unselected))
3970 ((zerop gnus-tmp-unselected)
3971 (format "{%d more}" gnus-tmp-unread-and-unticked))
3972 (t (format "{%d(+%d) more}"
3973 gnus-tmp-unread-and-unticked
3974 gnus-tmp-unselected))))
3976 (if (and gnus-current-headers
3977 (vectorp gnus-current-headers))
3978 (gnus-mode-string-quote
3979 (mail-header-subject gnus-current-headers))
3981 bufname-length max-len
3982 gnus-tmp-header);; passed as argument to any user-format-funcs
3983 (setq mode-string (eval mformat))
3984 (setq bufname-length (if (string-match "%b" mode-string)
3987 (if (eq where 'summary)
3989 (get-buffer gnus-article-buffer))))
3992 (setq max-len (max 4 (if gnus-mode-non-string-length
3994 gnus-mode-non-string-length
3996 (length mode-string))))
3997 ;; We might have to chop a bit of the string off...
3998 (when (> (length mode-string) max-len)
4000 (concat (gnus-truncate-string mode-string (- max-len 3))
4002 ;; Pad the mode string a bit.
4003 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4004 ;; Update the mode line.
4005 (setq mode-line-buffer-identification
4006 (gnus-mode-line-buffer-identification (list mode-string)))
4007 (set-buffer-modified-p t))))
4009 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4010 "Go through the HEADERS list and add all Xrefs to a hash table.
4011 The resulting hash table is returned, or nil if no Xrefs were found."
4012 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4013 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4014 (xref-hashtb (gnus-make-hashtable))
4015 start group entry number xrefs header)
4017 (setq header (pop headers))
4018 (when (and (setq xrefs (mail-header-xref header))
4019 (not (memq (setq number (mail-header-number header))
4022 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4023 (setq start (match-end 0))
4024 (setq group (if prefix
4025 (concat prefix (substring xrefs (match-beginning 1)
4027 (substring xrefs (match-beginning 1) (match-end 1))))
4029 (string-to-int (substring xrefs (match-beginning 2)
4031 (if (setq entry (gnus-gethash group xref-hashtb))
4032 (setcdr entry (cons number (cdr entry)))
4033 (gnus-sethash group (cons number nil) xref-hashtb)))))
4034 (and start xref-hashtb)))
4036 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4037 "Look through all the headers and mark the Xrefs as read."
4038 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4039 name entry info xref-hashtb idlist method nth4)
4041 (set-buffer gnus-group-buffer)
4042 (when (setq xref-hashtb
4043 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4046 (unless (string= from-newsgroup (setq name (symbol-name group)))
4047 (setq idlist (symbol-value group))
4048 ;; Dead groups are not updated.
4050 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4052 (when (stringp (setq nth4 (gnus-info-method info)))
4053 (setq nth4 (gnus-server-to-method nth4))))
4054 ;; Only do the xrefs if the group has the same
4055 ;; select method as the group we have just read.
4056 (or (gnus-methods-equal-p
4057 nth4 (gnus-find-method-for-group from-newsgroup))
4059 (equal nth4 (setq method (gnus-find-method-for-group
4061 (and (equal (car nth4) (car method))
4062 (equal (nth 1 nth4) (nth 1 method))))
4063 gnus-use-cross-reference
4064 (or (not (eq gnus-use-cross-reference t))
4066 ;; Only do cross-references on subscribed
4067 ;; groups, if that is what is wanted.
4068 (<= (gnus-info-level info) gnus-level-subscribed))
4069 (gnus-group-make-articles-read name idlist))))
4072 (defun gnus-group-make-articles-read (group articles)
4073 "Update the info of GROUP to say that ARTICLES are read."
4075 (entry (gnus-gethash group gnus-newsrc-hashtb))
4076 (info (nth 2 entry))
4077 (active (gnus-active group))
4080 ;; First peel off all illegal article numbers.
4082 (let ((ids articles)
4084 (while (setq id (pop ids))
4085 (when (and first (> id (cdr active)))
4086 ;; We'll end up in this situation in one particular
4087 ;; obscure situation. If you re-scan a group and get
4088 ;; a new article that is cross-posted to a different
4089 ;; group that has not been re-scanned, you might get
4090 ;; crossposted article that has a higher number than
4091 ;; Gnus believes possible. So we re-activate this
4092 ;; group as well. This might mean doing the
4093 ;; crossposting thingy will *increase* the number
4094 ;; of articles in some groups. Tsk, tsk.
4095 (setq active (or (gnus-activate-group group) active)))
4096 (when (or (> id (cdr active))
4097 (< id (car active)))
4098 (setq articles (delq id articles))))))
4100 (set-buffer gnus-group-buffer)
4103 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4104 (gnus-info-set-read ',info ',(gnus-info-read info))
4105 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4106 (gnus-group-update-group ,group t))))
4107 ;; If the read list is nil, we init it.
4109 (null (gnus-info-read info))
4111 (gnus-info-set-read info (cons 1 (1- (car active)))))
4112 ;; Then we add the read articles to the range.
4117 (gnus-info-read info) (setq articles (sort articles '<)))))
4118 ;; Then we have to re-compute how many unread
4119 ;; articles there are in this group.
4123 (setq num (- (1+ (cdr active)) (car active))))
4124 ((not (listp (cdr range)))
4125 (setq num (- (cdr active) (- (1+ (cdr range))
4129 (if (numberp (car range))
4131 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4132 (setq range (cdr range)))
4133 (setq num (- (cdr active) num))))
4134 ;; Update the number of unread articles.
4136 ;; Update the group buffer.
4137 (gnus-group-update-group group t)))))
4139 (defun gnus-methods-equal-p (m1 m2)
4140 (let ((m1 (or m1 gnus-select-method))
4141 (m2 (or m2 gnus-select-method)))
4143 (and (eq (car m1) (car m2))
4144 (or (not (memq 'address (assoc (symbol-name (car m1))
4145 gnus-valid-select-methods)))
4146 (equal (nth 1 m1) (nth 1 m2)))))))
4148 (defvar gnus-newsgroup-none-id 0)
4150 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4151 (let ((cur nntp-server-buffer)
4154 (save-excursion (set-buffer gnus-summary-buffer)
4155 gnus-newsgroup-dependencies)))
4156 headers id id-dep ref-dep end ref)
4158 (set-buffer nntp-server-buffer)
4159 ;; Translate all TAB characters into SPACE characters.
4160 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4161 (run-hooks 'gnus-parse-headers-hook)
4162 (let ((case-fold-search t)
4163 in-reply-to header p lines)
4164 (goto-char (point-min))
4165 ;; Search to the beginning of the next header. Error messages
4166 ;; do not begin with 2 or 3.
4167 (while (re-search-forward "^[23][0-9]+ " nil t)
4170 ;; This implementation of this function, with nine
4171 ;; search-forwards instead of the one re-search-forward and
4172 ;; a case (which basically was the old function) is actually
4173 ;; about twice as fast, even though it looks messier. You
4174 ;; can't have everything, I guess. Speed and elegance
4175 ;; doesn't always go hand in hand.
4184 (narrow-to-region (point)
4185 (or (and (search-forward "\n.\n" nil t)
4191 (if (search-forward "\nsubject: " nil t)
4192 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4194 gnus-unstructured-field-decoder (nnheader-header-value))
4199 (if (search-forward "\nfrom: " nil t)
4200 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4202 gnus-structured-field-decoder (nnheader-header-value))
4207 (if (search-forward "\ndate: " nil t)
4208 (nnheader-header-value) ""))
4212 (setq id (if (search-forward "\nmessage-id:" nil t)
4214 (1- (or (search-forward "<" nil t) (point)))
4215 (or (search-forward ">" nil t) (point)))
4216 ;; If there was no message-id, we just fake one
4217 ;; to make subsequent routines simpler.
4218 (nnheader-generate-fake-message-id))))
4222 (if (search-forward "\nreferences: " nil t)
4226 (nnheader-header-value)
4231 (search-backward ">" end t)
4234 (search-backward "<" end t)
4236 ;; Get the references from the in-reply-to header if there
4237 ;; were no references and the in-reply-to header looks
4239 (if (and (search-forward "\nin-reply-to: " nil t)
4240 (setq in-reply-to (nnheader-header-value))
4241 (string-match "<[^>]+>" in-reply-to))
4242 (setq ref (substring in-reply-to (match-beginning 0)
4250 (if (search-forward "\nlines: " nil t)
4251 (if (numberp (setq lines (ignore-errors (read cur))))
4257 (and (search-forward "\nxref: " nil t)
4258 (nnheader-header-value)))))
4259 (when (equal id ref)
4261 ;; We do the threading while we read the headers. The
4262 ;; message-id and the last reference are both entered into
4263 ;; the same hash table. Some tippy-toeing around has to be
4264 ;; done in case an article has arrived before the article
4265 ;; which it refers to.
4266 (if (boundp (setq id-dep (intern id dependencies)))
4267 (if (and (car (symbol-value id-dep))
4269 ;; An article with this Message-ID has already been seen.
4270 (if gnus-summary-ignore-duplicates
4271 ;; We ignore this one, except we add
4272 ;; any additional Xrefs (in case the two articles
4273 ;; came from different servers).
4275 (mail-header-set-xref
4276 (car (symbol-value id-dep))
4277 (concat (or (mail-header-xref
4278 (car (symbol-value id-dep)))
4280 (or (mail-header-xref header) "")))
4282 ;; We rename the Message-ID.
4284 (setq id-dep (intern (setq id (nnmail-message-id))
4287 (mail-header-set-id header id))
4288 (setcar (symbol-value id-dep) header))
4289 (set id-dep (list header)))
4291 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4292 (setcdr (symbol-value ref-dep)
4293 (nconc (cdr (symbol-value ref-dep))
4294 (list (symbol-value id-dep))))
4295 (set ref-dep (list nil (symbol-value id-dep))))
4296 (push header headers))
4297 (goto-char (point-max))
4299 (nreverse headers)))))
4301 ;; The following macros and functions were written by Felix Lee
4302 ;; <flee@cse.psu.edu>.
4304 (defmacro gnus-nov-read-integer ()
4306 (if (= (following-char) ?\t)
4308 (let ((num (ignore-errors (read buffer))))
4309 (if (numberp num) num 0)))
4313 (defmacro gnus-nov-skip-field ()
4314 '(search-forward "\t" eol 'move))
4316 (defmacro gnus-nov-field ()
4317 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4319 ;; (defvar gnus-nov-none-counter 0)
4321 ;; This function has to be called with point after the article number
4322 ;; on the beginning of the line.
4323 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4324 (let ((eol (gnus-point-at-eol))
4325 (buffer (current-buffer))
4326 header ref id id-dep ref-dep)
4328 ;; overview: [num subject from date id refs chars lines misc]
4331 (narrow-to-region (point) eol)
4338 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4340 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4342 gnus-structured-field-decoder (gnus-nov-field)) ; from
4343 (gnus-nov-field) ; date
4344 (setq id (or (gnus-nov-field)
4345 (nnheader-generate-fake-message-id))) ; id
4347 (let ((beg (point)))
4348 (search-forward "\t" eol)
4349 (if (search-backward ">" beg t)
4353 (search-backward "<" beg t)))
4356 (gnus-nov-field)) ; refs
4357 (gnus-nov-read-integer) ; chars
4358 (gnus-nov-read-integer) ; lines
4359 (if (= (following-char) ?\n)
4361 (gnus-nov-field))))) ; misc
4365 ;; We build the thread tree.
4366 (when (equal id ref)
4367 ;; This article refers back to itself. Naughty, naughty.
4369 (if (boundp (setq id-dep (intern id dependencies)))
4370 (if (and (car (symbol-value id-dep))
4372 ;; An article with this Message-ID has already been seen.
4373 (if gnus-summary-ignore-duplicates
4374 ;; We ignore this one, except we add any additional
4375 ;; Xrefs (in case the two articles came from different
4378 (mail-header-set-xref
4379 (car (symbol-value id-dep))
4380 (concat (or (mail-header-xref
4381 (car (symbol-value id-dep)))
4383 (or (mail-header-xref header) "")))
4385 ;; We rename the Message-ID.
4387 (setq id-dep (intern (setq id (nnmail-message-id))
4390 (mail-header-set-id header id))
4391 (setcar (symbol-value id-dep) header))
4392 (set id-dep (list header)))
4394 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4395 (setcdr (symbol-value ref-dep)
4396 (nconc (cdr (symbol-value ref-dep))
4397 (list (symbol-value id-dep))))
4398 (set ref-dep (list nil (symbol-value id-dep)))))
4401 ;; Goes through the xover lines and returns a list of vectors
4402 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4403 force-new dependencies
4404 group also-fetch-heads)
4405 "Parse the news overview data in the server buffer, and return a
4406 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4407 ;; Get the Xref when the users reads the articles since most/some
4408 ;; NNTP servers do not include Xrefs when using XOVER.
4409 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4410 (let ((cur nntp-server-buffer)
4411 (dependencies (or dependencies gnus-newsgroup-dependencies))
4412 number headers header)
4414 (set-buffer nntp-server-buffer)
4415 ;; Allow the user to mangle the headers before parsing them.
4416 (run-hooks 'gnus-parse-headers-hook)
4417 (goto-char (point-min))
4420 (while (and sequence (not (eobp)))
4421 (setq number (read cur))
4422 (while (and sequence
4423 (< (car sequence) number))
4424 (setq sequence (cdr sequence)))
4426 (eq number (car sequence))
4428 (setq sequence (cdr sequence))
4429 (setq header (inline
4430 (gnus-nov-parse-line
4431 number dependencies force-new))))
4432 (push header headers))
4435 (gnus-error 4 "Strange nov line (%d)"
4436 (count-lines (point-min) (point)))))
4438 ;; A common bug in inn is that if you have posted an article and
4439 ;; then retrieves the active file, it will answer correctly --
4440 ;; the new article is included. However, a NOV entry for the
4441 ;; article may not have been generated yet, so this may fail.
4442 ;; We work around this problem by retrieving the last few
4443 ;; headers using HEAD.
4444 (if (or (not also-fetch-heads)
4446 ;; We (probably) got all the headers.
4448 (let ((gnus-nov-is-evil t))
4451 (when (gnus-retrieve-headers sequence group)
4452 (gnus-get-newsgroup-headers))))))))
4454 (defun gnus-article-get-xrefs ()
4455 "Fill in the Xref value in `gnus-current-headers', if necessary.
4456 This is meant to be called in `gnus-article-internal-prepare-hook'."
4457 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4458 gnus-current-headers)))
4459 (or (not gnus-use-cross-reference)
4461 (and (mail-header-xref headers)
4462 (not (string= (mail-header-xref headers) "")))
4463 (let ((case-fold-search t)
4466 (nnheader-narrow-to-headers)
4467 (goto-char (point-min))
4468 (when (or (and (eq (downcase (following-char)) ?x)
4469 (looking-at "Xref:"))
4470 (search-forward "\nXref:" nil t))
4471 (goto-char (1+ (match-end 0)))
4472 (setq xref (buffer-substring (point)
4473 (progn (end-of-line) (point))))
4474 (mail-header-set-xref headers xref)))))))
4476 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4477 "Find article ID and insert the summary line for that article."
4478 (let ((header (if (and old-header use-old-header)
4479 old-header (gnus-read-header id)))
4480 (number (and (numberp id) id))
4483 ;; Rebuild the thread that this article is part of and go to the
4484 ;; article we have fetched.
4485 (when (and (not gnus-show-threads)
4487 (when (setq d (gnus-data-find (mail-header-number old-header)))
4488 (goto-char (gnus-data-pos d))
4491 (- (gnus-point-at-bol)
4493 (1+ (gnus-point-at-eol))
4494 (gnus-delete-line))))))
4496 (mail-header-set-number header (mail-header-number old-header)))
4497 (setq gnus-newsgroup-sparse
4498 (delq (setq number (mail-header-number header))
4499 gnus-newsgroup-sparse))
4500 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4501 (gnus-rebuild-thread (mail-header-id header))
4502 (gnus-summary-goto-subject number nil t))
4503 (when (and (numberp number)
4505 ;; We have to update the boundaries even if we can't fetch the
4506 ;; article if ID is a number -- so that the next `P' or `N'
4507 ;; command will fetch the previous (or next) article even
4508 ;; if the one we tried to fetch this time has been canceled.
4509 (when (> number gnus-newsgroup-end)
4510 (setq gnus-newsgroup-end number))
4511 (when (< number gnus-newsgroup-begin)
4512 (setq gnus-newsgroup-begin number))
4513 (setq gnus-newsgroup-unselected
4514 (delq number gnus-newsgroup-unselected)))
4515 ;; Report back a success?
4516 (and header (mail-header-number header))))
4518 ;;; Process/prefix in the summary buffer
4520 (defun gnus-summary-work-articles (n)
4521 "Return a list of articles to be worked upon. The prefix argument,
4522 the list of process marked articles, and the current article will be
4523 taken into consideration."
4526 ;; A numerical prefix has been given.
4527 (setq n (prefix-numeric-value n))
4528 (let ((backward (< n 0))
4529 (n (abs (prefix-numeric-value n)))
4534 (push (setq article (gnus-summary-article-number))
4537 (gnus-summary-find-prev nil article)
4538 (gnus-summary-find-next nil article)))
4540 (nreverse articles)))
4541 ((gnus-region-active-p)
4542 ;; Work on the region between point and mark.
4543 (let ((max (max (point) (mark)))
4546 (goto-char (min (point) (mark)))
4549 (push (setq article (gnus-summary-article-number)) articles)
4550 (gnus-summary-find-next nil article)
4552 (nreverse articles))))
4553 (gnus-newsgroup-processable
4554 ;; There are process-marked articles present.
4555 ;; Save current state.
4556 (gnus-summary-save-process-mark)
4558 (reverse gnus-newsgroup-processable))
4560 ;; Just return the current article.
4561 (list (gnus-summary-article-number)))))
4563 (defun gnus-summary-save-process-mark ()
4564 "Push the current set of process marked articles on the stack."
4566 (push (copy-sequence gnus-newsgroup-processable)
4567 gnus-newsgroup-process-stack))
4569 (defun gnus-summary-kill-process-mark ()
4570 "Push the current set of process marked articles on the stack and unmark."
4572 (gnus-summary-save-process-mark)
4573 (gnus-summary-unmark-all-processable))
4575 (defun gnus-summary-yank-process-mark ()
4576 "Pop the last process mark state off the stack and restore it."
4578 (unless gnus-newsgroup-process-stack
4579 (error "Empty mark stack"))
4580 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4582 (defun gnus-summary-process-mark-set (set)
4583 "Make SET into the current process marked articles."
4584 (gnus-summary-unmark-all-processable)
4586 (gnus-summary-set-process-mark (pop set))))
4588 ;;; Searching and stuff
4590 (defun gnus-summary-search-group (&optional backward use-level)
4591 "Search for next unread newsgroup.
4592 If optional argument BACKWARD is non-nil, search backward instead."
4594 (set-buffer gnus-group-buffer)
4595 (when (gnus-group-search-forward
4596 backward nil (if use-level (gnus-group-group-level) nil))
4597 (gnus-group-group-name))))
4599 (defun gnus-summary-best-group (&optional exclude-group)
4600 "Find the name of the best unread group.
4601 If EXCLUDE-GROUP, do not go to this group."
4603 (set-buffer gnus-group-buffer)
4605 (gnus-group-best-unread-group exclude-group))))
4607 (defun gnus-summary-find-next (&optional unread article backward)
4608 (if backward (gnus-summary-find-prev)
4609 (let* ((dummy (gnus-summary-article-intangible-p))
4610 (article (or article (gnus-summary-article-number)))
4611 (arts (gnus-data-find-list article))
4613 (when (and (not dummy)
4614 (or (not gnus-summary-check-current)
4616 (not (gnus-data-unread-p (car arts)))))
4617 (setq arts (cdr arts)))
4622 (when (gnus-data-unread-p (car arts))
4623 (setq result (car arts)
4625 (setq arts (cdr arts)))
4628 (goto-char (gnus-data-pos result))
4629 (gnus-data-number result)))))
4631 (defun gnus-summary-find-prev (&optional unread article)
4632 (let* ((eobp (eobp))
4633 (article (or article (gnus-summary-article-number)))
4634 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4636 (when (and (not eobp)
4637 (or (not gnus-summary-check-current)
4639 (not (gnus-data-unread-p (car arts)))))
4640 (setq arts (cdr arts)))
4645 (when (gnus-data-unread-p (car arts))
4646 (setq result (car arts)
4648 (setq arts (cdr arts)))
4651 (goto-char (gnus-data-pos result))
4652 (gnus-data-number result))))
4654 (defun gnus-summary-find-subject (subject &optional unread backward article)
4655 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4656 (article (or article (gnus-summary-article-number)))
4657 (articles (gnus-data-list backward))
4658 (arts (gnus-data-find-list article articles))
4660 (when (or (not gnus-summary-check-current)
4662 (not (gnus-data-unread-p (car arts))))
4663 (setq arts (cdr arts)))
4665 (and (or (not unread)
4666 (gnus-data-unread-p (car arts)))
4667 (vectorp (gnus-data-header (car arts)))
4669 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4670 (setq result (car arts)
4672 (setq arts (cdr arts)))
4674 (goto-char (gnus-data-pos result))
4675 (gnus-data-number result))))
4677 (defun gnus-summary-search-forward (&optional unread subject backward)
4678 "Search forward for an article.
4679 If UNREAD, look for unread articles. If SUBJECT, look for
4680 articles with that subject. If BACKWARD, search backward instead."
4681 (cond (subject (gnus-summary-find-subject subject unread backward))
4682 (backward (gnus-summary-find-prev unread))
4683 (t (gnus-summary-find-next unread))))
4685 (defun gnus-recenter (&optional n)
4686 "Center point in window and redisplay frame.
4687 Also do horizontal recentering."
4689 (when (and gnus-auto-center-summary
4690 (not (eq gnus-auto-center-summary 'vertical)))
4691 (gnus-horizontal-recenter))
4694 (defun gnus-summary-recenter ()
4695 "Center point in the summary window.
4696 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4697 displayed, no centering will be performed."
4698 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4699 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4700 (let* ((top (cond ((< (window-height) 4) 0)
4701 ((< (window-height) 7) 1)
4703 (height (1- (window-height)))
4704 (bottom (save-excursion (goto-char (point-max))
4705 (forward-line (- height))
4707 (window (get-buffer-window (current-buffer))))
4708 ;; The user has to want it.
4709 (when gnus-auto-center-summary
4710 (when (get-buffer-window gnus-article-buffer)
4711 ;; Only do recentering when the article buffer is displayed,
4712 ;; Set the window start to either `bottom', which is the biggest
4713 ;; possible valid number, or the second line from the top,
4714 ;; whichever is the least.
4716 window (min bottom (save-excursion
4717 (forward-line (- top)) (point)))))
4718 ;; Do horizontal recentering while we're at it.
4719 (when (and (get-buffer-window (current-buffer) t)
4720 (not (eq gnus-auto-center-summary 'vertical)))
4721 (let ((selected (selected-window)))
4722 (select-window (get-buffer-window (current-buffer) t))
4723 (gnus-summary-position-point)
4724 (gnus-horizontal-recenter)
4725 (select-window selected))))))
4727 (defun gnus-summary-jump-to-group (newsgroup)
4728 "Move point to NEWSGROUP in group mode buffer."
4729 ;; Keep update point of group mode buffer if visible.
4730 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4731 (save-window-excursion
4732 ;; Take care of tree window mode.
4733 (when (get-buffer-window gnus-group-buffer)
4734 (pop-to-buffer gnus-group-buffer))
4735 (gnus-group-jump-to-group newsgroup))
4737 ;; Take care of tree window mode.
4738 (if (get-buffer-window gnus-group-buffer)
4739 (pop-to-buffer gnus-group-buffer)
4740 (set-buffer gnus-group-buffer))
4741 (gnus-group-jump-to-group newsgroup))))
4743 ;; This function returns a list of article numbers based on the
4744 ;; difference between the ranges of read articles in this group and
4745 ;; the range of active articles.
4746 (defun gnus-list-of-unread-articles (group)
4747 (let* ((read (gnus-info-read (gnus-get-info group)))
4748 (active (or (gnus-active group) (gnus-activate-group group)))
4751 ;; If none are read, then all are unread.
4753 (setq first (car active))
4754 ;; If the range of read articles is a single range, then the
4755 ;; first unread article is the article after the last read
4756 ;; article. Sounds logical, doesn't it?
4757 (if (not (listp (cdr read)))
4758 (setq first (1+ (cdr read)))
4759 ;; `read' is a list of ranges.
4760 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4766 (while (< first nlast)
4768 (setq first (1+ first))))
4769 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4770 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4771 (setq read (cdr read)))))
4772 ;; And add the last unread articles.
4773 (while (<= first last)
4775 (setq first (1+ first)))
4776 ;; Return the list of unread articles.
4777 (delq 0 (nreverse unread))))
4779 (defun gnus-list-of-read-articles (group)
4780 "Return a list of unread, unticked and non-dormant articles."
4781 (let* ((info (gnus-get-info group))
4782 (marked (gnus-info-marks info))
4783 (active (gnus-active group)))
4785 (gnus-set-difference
4786 (gnus-sorted-complement
4787 (gnus-uncompress-range active)
4788 (gnus-list-of-unread-articles group))
4790 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4791 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4793 ;; Various summary commands
4795 (defun gnus-summary-universal-argument (arg)
4796 "Perform any operation on all articles that are process/prefixed."
4798 (gnus-set-global-variables)
4799 (let ((articles (gnus-summary-work-articles arg))
4806 (substitute-command-keys
4807 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4810 (gnus-error 1 "Undefined key")
4813 (gnus-summary-goto-subject (setq article (pop articles)))
4814 (let (gnus-newsgroup-processable)
4815 (command-execute func))
4816 (gnus-summary-remove-process-mark article)))))
4817 (gnus-summary-position-point))
4819 (defun gnus-summary-toggle-truncation (&optional arg)
4820 "Toggle truncation of summary lines.
4821 With arg, turn line truncation on iff arg is positive."
4823 (setq truncate-lines
4824 (if (null arg) (not truncate-lines)
4825 (> (prefix-numeric-value arg) 0)))
4828 (defun gnus-summary-reselect-current-group (&optional all rescan)
4829 "Exit and then reselect the current newsgroup.
4830 The prefix argument ALL means to select all articles."
4832 (gnus-set-global-variables)
4833 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4834 (error "Ephemeral groups can't be reselected"))
4835 (let ((current-subject (gnus-summary-article-number))
4836 (group gnus-newsgroup-name))
4837 (setq gnus-newsgroup-begin nil)
4839 ;; We have to adjust the point of group mode buffer because
4840 ;; point was moved to the next unread newsgroup by exiting.
4841 (gnus-summary-jump-to-group group)
4844 (gnus-group-get-new-news-this-group 1)))
4845 (gnus-group-read-group all t)
4846 (gnus-summary-goto-subject current-subject nil t)))
4848 (defun gnus-summary-rescan-group (&optional all)
4849 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4851 (gnus-summary-reselect-current-group all t))
4853 (defun gnus-summary-update-info (&optional non-destructive)
4855 (let ((group gnus-newsgroup-name))
4856 (when gnus-newsgroup-kill-headers
4857 (setq gnus-newsgroup-killed
4858 (gnus-compress-sequence
4860 (gnus-set-sorted-intersection
4861 (gnus-uncompress-range gnus-newsgroup-killed)
4862 (setq gnus-newsgroup-unselected
4863 (sort gnus-newsgroup-unselected '<)))
4864 (setq gnus-newsgroup-unreads
4865 (sort gnus-newsgroup-unreads '<)))
4867 (unless (listp (cdr gnus-newsgroup-killed))
4868 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4869 (let ((headers gnus-newsgroup-headers))
4870 (when (and (not gnus-save-score)
4871 (not non-destructive))
4872 (setq gnus-newsgroup-scored nil))
4873 ;; Set the new ranges of read articles.
4875 (set-buffer gnus-group-buffer)
4876 (gnus-undo-force-boundary))
4877 (gnus-update-read-articles
4878 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4879 ;; Set the current article marks.
4881 ;; Do the cross-ref thing.
4882 (when gnus-use-cross-reference
4883 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4884 ;; Do adaptive scoring, and possibly save score files.
4885 (when gnus-newsgroup-adaptive
4886 (gnus-score-adaptive))
4887 (when gnus-use-scoring
4889 ;; Do not switch windows but change the buffer to work.
4890 (set-buffer gnus-group-buffer)
4891 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4892 (gnus-group-update-group group))))))
4894 (defun gnus-summary-save-newsrc (&optional force)
4895 "Save the current number of read/marked articles in the dribble buffer.
4896 The dribble buffer will then be saved.
4897 If FORCE (the prefix), also save the .newsrc file(s)."
4899 (gnus-summary-update-info t)
4901 (gnus-save-newsrc-file)
4902 (gnus-dribble-save)))
4904 (defun gnus-summary-exit (&optional temporary)
4905 "Exit reading current newsgroup, and then return to group selection mode.
4906 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4908 (gnus-set-global-variables)
4909 (gnus-kill-save-kill-buffer)
4910 (let* ((group gnus-newsgroup-name)
4911 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4914 (buf (current-buffer)))
4915 (run-hooks 'gnus-summary-prepare-exit-hook)
4916 ;; If we have several article buffers, we kill them at exit.
4917 (unless gnus-single-article-buffer
4918 (gnus-kill-buffer gnus-original-article-buffer)
4919 (setq gnus-article-current nil))
4920 (when gnus-use-cache
4921 (gnus-cache-possibly-remove-articles)
4922 (gnus-cache-save-buffers))
4923 (gnus-async-prefetch-remove-group group)
4924 (when gnus-suppress-duplicates
4925 (gnus-dup-enter-articles))
4926 (when gnus-use-trees
4927 (gnus-tree-close group))
4928 ;; Make all changes in this group permanent.
4930 (run-hooks 'gnus-exit-group-hook)
4931 (gnus-summary-update-info))
4932 (gnus-close-group group)
4933 ;; Make sure where we were, and go to next newsgroup.
4934 (set-buffer gnus-group-buffer)
4936 (gnus-group-jump-to-group group))
4937 (run-hooks 'gnus-summary-exit-hook)
4939 (gnus-group-next-unread-group 1))
4940 (setq group-point (point))
4943 ;; If we have several article buffers, we kill them at exit.
4944 (unless gnus-single-article-buffer
4945 (gnus-kill-buffer gnus-article-buffer)
4946 (gnus-kill-buffer gnus-original-article-buffer)
4947 (setq gnus-article-current nil))
4949 (if (not gnus-kill-summary-on-exit)
4950 (gnus-deaden-summary)
4951 ;; We set all buffer-local variables to nil. It is unclear why
4952 ;; this is needed, but if we don't, buffer-local variables are
4953 ;; not garbage-collected, it seems. This would the lead to en
4954 ;; ever-growing Emacs.
4955 (gnus-summary-clear-local-variables)
4956 (when (get-buffer gnus-article-buffer)
4957 (bury-buffer gnus-article-buffer))
4958 ;; We clear the global counterparts of the buffer-local
4959 ;; variables as well, just to be on the safe side.
4960 (set-buffer gnus-group-buffer)
4961 (gnus-summary-clear-local-variables)
4962 ;; Return to group mode buffer.
4963 (when (eq mode 'gnus-summary-mode)
4964 (gnus-kill-buffer buf)))
4965 (setq gnus-current-select-method gnus-select-method)
4966 (pop-to-buffer gnus-group-buffer)
4967 ;; Clear the current group name.
4968 (if (not quit-config)
4970 (goto-char group-point)
4971 (gnus-configure-windows 'group 'force))
4972 (gnus-handle-ephemeral-exit quit-config))
4974 (setq gnus-newsgroup-name nil)))))
4976 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4977 (defun gnus-summary-exit-no-update (&optional no-questions)
4978 "Quit reading current newsgroup without updating read article info."
4980 (gnus-set-global-variables)
4981 (let* ((group gnus-newsgroup-name)
4982 (quit-config (gnus-group-quit-config group)))
4983 (when (or no-questions
4985 (gnus-y-or-n-p "Discard changes to this group and exit? "))
4986 ;; If we have several article buffers, we kill them at exit.
4987 (unless gnus-single-article-buffer
4988 (gnus-kill-buffer gnus-article-buffer)
4989 (gnus-kill-buffer gnus-original-article-buffer)
4990 (setq gnus-article-current nil))
4991 (if (not gnus-kill-summary-on-exit)
4992 (gnus-deaden-summary)
4993 (gnus-close-group group)
4994 (gnus-summary-clear-local-variables)
4995 (set-buffer gnus-group-buffer)
4996 (gnus-summary-clear-local-variables)
4997 (when (get-buffer gnus-summary-buffer)
4998 (kill-buffer gnus-summary-buffer)))
4999 (unless gnus-single-article-buffer
5000 (setq gnus-article-current nil))
5001 (when gnus-use-trees
5002 (gnus-tree-close group))
5003 (gnus-async-prefetch-remove-group group)
5004 (when (get-buffer gnus-article-buffer)
5005 (bury-buffer gnus-article-buffer))
5006 ;; Return to the group buffer.
5007 (gnus-configure-windows 'group 'force)
5008 ;; Clear the current group name.
5009 (setq gnus-newsgroup-name nil)
5010 (when (equal (gnus-group-group-name) group)
5011 (gnus-group-next-unread-group 1))
5013 (gnus-handle-ephemeral-exit quit-config)))))
5015 (defun gnus-handle-ephemeral-exit (quit-config)
5016 "Handle movement when leaving an ephemeral group. The state
5017 which existed when entering the ephemeral is reset."
5018 (if (not (buffer-name (car quit-config)))
5019 (gnus-configure-windows 'group 'force)
5020 (set-buffer (car quit-config))
5021 (cond ((eq major-mode 'gnus-summary-mode)
5022 (gnus-set-global-variables))
5023 ((eq major-mode 'gnus-article-mode)
5025 ;; The `gnus-summary-buffer' variable may point
5026 ;; to the old summary buffer when using a single
5028 (unless (gnus-buffer-live-p gnus-summary-buffer)
5029 (set-buffer gnus-group-buffer))
5030 (set-buffer gnus-summary-buffer)
5031 (gnus-set-global-variables))))
5032 (if (or (eq (cdr quit-config) 'article)
5033 (eq (cdr quit-config) 'pick))
5035 ;; The current article may be from the ephemeral group
5036 ;; thus it is best that we reload this article
5037 (gnus-summary-show-article)
5038 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5039 (gnus-configure-windows 'pick 'force)
5040 (gnus-configure-windows (cdr quit-config) 'force)))
5041 (gnus-configure-windows (cdr quit-config) 'force))
5042 (when (eq major-mode 'gnus-summary-mode)
5043 (gnus-summary-next-subject 1 nil t)
5044 (gnus-summary-recenter)
5045 (gnus-summary-position-point))))
5049 (defvar gnus-dead-summary-mode-map nil)
5051 (unless gnus-dead-summary-mode-map
5052 (setq gnus-dead-summary-mode-map (make-keymap))
5053 (suppress-keymap gnus-dead-summary-mode-map)
5054 (substitute-key-definition
5055 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5056 (let ((keys '("\C-d" "\r" "\177" [delete])))
5058 (define-key gnus-dead-summary-mode-map
5059 (pop keys) 'gnus-summary-wake-up-the-dead))))
5061 (defvar gnus-dead-summary-mode nil
5062 "Minor mode for Gnus summary buffers.")
5064 (defun gnus-dead-summary-mode (&optional arg)
5065 "Minor mode for Gnus summary buffers."
5067 (when (eq major-mode 'gnus-summary-mode)
5068 (make-local-variable 'gnus-dead-summary-mode)
5069 (setq gnus-dead-summary-mode
5070 (if (null arg) (not gnus-dead-summary-mode)
5071 (> (prefix-numeric-value arg) 0)))
5072 (when gnus-dead-summary-mode
5073 (gnus-add-minor-mode
5074 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5076 (defun gnus-deaden-summary ()
5077 "Make the current summary buffer into a dead summary buffer."
5078 ;; Kill any previous dead summary buffer.
5079 (when (and gnus-dead-summary
5080 (buffer-name gnus-dead-summary))
5082 (set-buffer gnus-dead-summary)
5083 (when gnus-dead-summary-mode
5084 (kill-buffer (current-buffer)))))
5085 ;; Make this the current dead summary.
5086 (setq gnus-dead-summary (current-buffer))
5087 (gnus-dead-summary-mode 1)
5088 (let ((name (buffer-name)))
5089 (when (string-match "Summary" name)
5091 (concat (substring name 0 (match-beginning 0)) "Dead "
5092 (substring name (match-beginning 0)))
5095 (defun gnus-kill-or-deaden-summary (buffer)
5096 "Kill or deaden the summary BUFFER."
5097 (when (and (buffer-name buffer)
5098 (not gnus-single-article-buffer))
5101 (gnus-kill-buffer gnus-article-buffer)
5102 (gnus-kill-buffer gnus-original-article-buffer)))
5103 (cond (gnus-kill-summary-on-exit
5104 (when (and gnus-use-trees
5105 (and (get-buffer buffer)
5106 (buffer-name (get-buffer buffer))))
5108 (set-buffer (get-buffer buffer))
5109 (gnus-tree-close gnus-newsgroup-name)))
5110 (gnus-kill-buffer buffer))
5111 ((and (get-buffer buffer)
5112 (buffer-name (get-buffer buffer)))
5115 (gnus-deaden-summary)))))
5117 (defun gnus-summary-wake-up-the-dead (&rest args)
5118 "Wake up the dead summary buffer."
5120 (gnus-dead-summary-mode -1)
5121 (let ((name (buffer-name)))
5122 (when (string-match "Dead " name)
5124 (concat (substring name 0 (match-beginning 0))
5125 (substring name (match-end 0)))
5127 (gnus-message 3 "This dead summary is now alive again"))
5129 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5130 (defun gnus-summary-fetch-faq (&optional faq-dir)
5131 "Fetch the FAQ for the current group.
5132 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5136 (when current-prefix-arg
5138 "Faq dir: " (and (listp gnus-group-faq-directory)
5139 (mapcar (lambda (file) (list file))
5140 gnus-group-faq-directory))))))
5141 (let (gnus-faq-buffer)
5142 (when (setq gnus-faq-buffer
5143 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5144 (gnus-configure-windows 'summary-faq))))
5146 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5147 (defun gnus-summary-describe-group (&optional force)
5148 "Describe the current newsgroup."
5150 (gnus-group-describe-group force gnus-newsgroup-name))
5152 (defun gnus-summary-describe-briefly ()
5153 "Describe summary mode commands briefly."
5156 (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")))
5158 ;; Walking around group mode buffer from summary mode.
5160 (defun gnus-summary-next-group (&optional no-article target-group backward)
5161 "Exit current newsgroup and then select next unread newsgroup.
5162 If prefix argument NO-ARTICLE is non-nil, no article is selected
5163 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5164 previous group instead."
5166 (gnus-set-global-variables)
5167 ;; Stop pre-fetching.
5168 (gnus-async-halt-prefetch)
5169 (let ((current-group gnus-newsgroup-name)
5170 (current-buffer (current-buffer))
5172 ;; First we semi-exit this group to update Xrefs and all variables.
5173 ;; We can't do a real exit, because the window conf must remain
5174 ;; the same in case the user is prompted for info, and we don't
5175 ;; want the window conf to change before that...
5176 (gnus-summary-exit t)
5177 (while (not entered)
5178 ;; Then we find what group we are supposed to enter.
5179 (set-buffer gnus-group-buffer)
5180 (gnus-group-jump-to-group current-group)
5183 (if (eq gnus-keep-same-level 'best)
5184 (gnus-summary-best-group gnus-newsgroup-name)
5185 (gnus-summary-search-group backward gnus-keep-same-level))))
5186 (if (not target-group)
5187 ;; There are no further groups, so we return to the group
5190 (gnus-message 5 "Returning to the group buffer")
5192 (when (gnus-buffer-live-p current-buffer)
5193 (set-buffer current-buffer)
5194 (gnus-summary-exit))
5195 (run-hooks 'gnus-group-no-more-groups-hook))
5196 ;; We try to enter the target group.
5197 (gnus-group-jump-to-group target-group)
5198 (let ((unreads (gnus-group-group-unread)))
5199 (if (and (or (eq t unreads)
5200 (and unreads (not (zerop unreads))))
5201 (gnus-summary-read-group
5202 target-group nil no-article
5203 (and (buffer-name current-buffer) current-buffer)))
5205 (setq current-group target-group
5206 target-group nil)))))))
5208 (defun gnus-summary-prev-group (&optional no-article)
5209 "Exit current newsgroup and then select previous unread newsgroup.
5210 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5212 (gnus-summary-next-group no-article nil t))
5214 ;; Walking around summary lines.
5216 (defun gnus-summary-first-subject (&optional unread)
5217 "Go to the first unread subject.
5218 If UNREAD is non-nil, go to the first unread article.
5219 Returns the article selected or nil if there are no unread articles."
5224 ((null gnus-newsgroup-data)
5225 (gnus-message 3 "No articles in the group")
5227 ;; Pick the first article.
5229 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5230 (gnus-data-number (car gnus-newsgroup-data)))
5231 ;; No unread articles.
5232 ((null gnus-newsgroup-unreads)
5233 (gnus-message 3 "No more unread articles")
5235 ;; Find the first unread article.
5237 (let ((data gnus-newsgroup-data))
5239 (not (gnus-data-unread-p (car data))))
5240 (setq data (cdr data)))
5242 (goto-char (gnus-data-pos (car data)))
5243 (gnus-data-number (car data))))))
5244 (gnus-summary-position-point)))
5246 (defun gnus-summary-next-subject (n &optional unread dont-display)
5247 "Go to next N'th summary line.
5248 If N is negative, go to the previous N'th subject line.
5249 If UNREAD is non-nil, only unread articles are selected.
5250 The difference between N and the actual number of steps taken is
5253 (let ((backward (< n 0))
5257 (gnus-summary-find-prev unread)
5258 (gnus-summary-find-next unread)))
5261 (gnus-message 7 "No more%s articles"
5262 (if unread " unread" "")))
5263 (unless dont-display
5264 (gnus-summary-recenter)
5265 (gnus-summary-position-point))
5268 (defun gnus-summary-next-unread-subject (n)
5269 "Go to next N'th unread summary line."
5271 (gnus-summary-next-subject n t))
5273 (defun gnus-summary-prev-subject (n &optional unread)
5274 "Go to previous N'th summary line.
5275 If optional argument UNREAD is non-nil, only unread article is selected."
5277 (gnus-summary-next-subject (- n) unread))
5279 (defun gnus-summary-prev-unread-subject (n)
5280 "Go to previous N'th unread summary line."
5282 (gnus-summary-next-subject (- n) t))
5284 (defun gnus-summary-goto-subject (article &optional force silent)
5285 "Go the subject line of ARTICLE.
5286 If FORCE, also allow jumping to articles not currently shown."
5287 (interactive "nArticle number: ")
5289 (data (gnus-data-find article)))
5290 ;; We read in the article if we have to.
5293 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5294 (setq data (gnus-data-find article)))
5299 (gnus-message 3 "Can't find article %d" article))
5301 (goto-char (gnus-data-pos data))
5304 ;; Walking around summary lines with displaying articles.
5306 (defun gnus-summary-expand-window (&optional arg)
5307 "Make the summary buffer take up the entire Emacs frame.
5308 Given a prefix, will force an `article' buffer configuration."
5310 (gnus-set-global-variables)
5312 (gnus-configure-windows 'article 'force)
5313 (gnus-configure-windows 'summary 'force)))
5315 (defun gnus-summary-display-article (article &optional all-header)
5316 "Display ARTICLE in article buffer."
5317 (gnus-set-global-variables)
5321 (if gnus-summary-display-article-function
5322 (funcall gnus-summary-display-article-function article all-header)
5323 (gnus-article-prepare article all-header))
5324 (run-hooks 'gnus-select-article-hook)
5325 (when (and gnus-current-article
5326 (not (zerop gnus-current-article)))
5327 (gnus-summary-goto-subject gnus-current-article))
5328 (gnus-summary-recenter)
5329 (when (and gnus-use-trees gnus-show-threads)
5330 (gnus-possibly-generate-tree article)
5331 (gnus-highlight-selected-tree article))
5332 ;; Successfully display article.
5333 (gnus-article-set-window-start
5334 (cdr (assq article gnus-newsgroup-bookmarks))))))
5336 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5337 "Select the current article.
5338 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5339 non-nil, the article will be re-fetched even if it already present in
5340 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5342 ;; Make sure we are in the summary buffer to work around bbdb bug.
5343 (unless (eq major-mode 'gnus-summary-mode)
5344 (set-buffer gnus-summary-buffer))
5345 (let ((article (or article (gnus-summary-article-number)))
5346 (all-headers (not (not all-headers))) ;Must be T or NIL.
5347 gnus-summary-display-article-function
5350 (gnus-summary-article-pseudo-p article)
5351 (error "This is a pseudo-article"))
5354 (set-buffer gnus-summary-buffer)
5355 (if (or (and gnus-single-article-buffer
5356 (or (null gnus-current-article)
5357 (null gnus-article-current)
5358 (null (get-buffer gnus-article-buffer))
5359 (not (eq article (cdr gnus-article-current)))
5360 (not (equal (car gnus-article-current)
5361 gnus-newsgroup-name))))
5362 (and (not gnus-single-article-buffer)
5363 (or (null gnus-current-article)
5364 (not (eq gnus-current-article article))))
5366 ;; The requested article is different from the current article.
5368 (gnus-summary-display-article article all-headers)
5370 (when (or all-headers gnus-show-all-headers)
5371 (gnus-article-show-all-headers))
5374 (gnus-article-set-window-start
5375 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5377 (defun gnus-summary-set-current-mark (&optional current-mark)
5378 "Obsolete function."
5381 (defun gnus-summary-next-article (&optional unread subject backward push)
5382 "Select the next article.
5383 If UNREAD, only unread articles are selected.
5384 If SUBJECT, only articles with SUBJECT are selected.
5385 If BACKWARD, the previous article is selected instead of the next."
5387 (gnus-set-global-variables)
5389 ;; Is there such an article?
5390 ((and (gnus-summary-search-forward unread subject backward)
5391 (or (gnus-summary-display-article (gnus-summary-article-number))
5392 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5393 (gnus-summary-position-point))
5394 ;; If not, we try the first unread, if that is wanted.
5396 gnus-auto-select-same
5397 (gnus-summary-first-unread-article))
5398 (gnus-summary-position-point)
5399 (gnus-message 6 "Wrapped"))
5400 ;; Try to get next/previous article not displayed in this group.
5401 ((and gnus-auto-extend-newsgroup
5402 (not unread) (not subject))
5403 (gnus-summary-goto-article
5404 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5406 ;; Go to next/previous group.
5408 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5409 (gnus-summary-jump-to-group gnus-newsgroup-name))
5410 (let ((cmd last-command-char)
5413 (set-buffer gnus-group-buffer)
5416 (if (eq gnus-keep-same-level 'best)
5417 (gnus-summary-best-group gnus-newsgroup-name)
5418 (gnus-summary-search-group backward gnus-keep-same-level))))
5419 ;; For some reason, the group window gets selected. We change
5421 (select-window (get-buffer-window (current-buffer)))
5422 ;; Select next unread newsgroup automagically.
5424 ((or (not gnus-auto-select-next)
5426 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5427 ((or (eq gnus-auto-select-next 'quietly)
5428 (and (eq gnus-auto-select-next 'slightly-quietly)
5430 (and (eq gnus-auto-select-next 'almost-quietly)
5431 (gnus-summary-last-article-p)))
5433 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5435 (gnus-message 7 "No more%s articles (%s)..."
5436 (if unread " unread" "")
5437 (if group (concat "selecting " group)
5439 (gnus-summary-next-group nil group backward)))
5441 (when (gnus-key-press-event-p last-input-event)
5442 (gnus-summary-walk-group-buffer
5443 gnus-newsgroup-name cmd unread backward point))))))))
5445 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5446 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5447 (?\C-p (gnus-group-prev-unread-group 1))))
5448 (cursor-in-echo-area t)
5449 keve key group ended)
5451 (set-buffer gnus-group-buffer)
5454 (if (eq gnus-keep-same-level 'best)
5455 (gnus-summary-best-group gnus-newsgroup-name)
5456 (gnus-summary-search-group backward gnus-keep-same-level))))
5459 5 "No more%s articles%s" (if unread " unread" "")
5461 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5462 (format " (Type %s for %s [%s])"
5463 (single-key-description cmd) group
5464 (car (gnus-gethash group gnus-newsrc-hashtb)))
5465 (format " (Type %s to exit %s)"
5466 (single-key-description cmd)
5467 gnus-newsgroup-name)))
5468 ;; Confirm auto selection.
5469 (setq key (car (setq keve (gnus-read-event-char))))
5472 ((assq key keystrokes)
5473 (let ((obuf (current-buffer)))
5474 (switch-to-buffer gnus-group-buffer)
5476 (gnus-group-jump-to-group group))
5477 (eval (cadr (assq key keystrokes)))
5478 (setq group (gnus-group-group-name))
5479 (switch-to-buffer obuf))
5483 (gnus-ephemeral-group-p gnus-newsgroup-name))
5485 (gnus-summary-next-group nil group backward)))
5487 (push (cdr keve) unread-command-events))))))
5489 (defun gnus-summary-next-unread-article ()
5490 "Select unread article after current one."
5492 (gnus-summary-next-article
5493 (or (not (eq gnus-summary-goto-unread 'never))
5494 (gnus-summary-last-article-p (gnus-summary-article-number)))
5495 (and gnus-auto-select-same
5496 (gnus-summary-article-subject))))
5498 (defun gnus-summary-prev-article (&optional unread subject)
5499 "Select the article after the current one.
5500 If UNREAD is non-nil, only unread articles are selected."
5502 (gnus-summary-next-article unread subject t))
5504 (defun gnus-summary-prev-unread-article ()
5505 "Select unread article before current one."
5507 (gnus-summary-prev-article
5508 (or (not (eq gnus-summary-goto-unread 'never))
5509 (gnus-summary-first-article-p (gnus-summary-article-number)))
5510 (and gnus-auto-select-same
5511 (gnus-summary-article-subject))))
5513 (defun gnus-summary-next-page (&optional lines circular)
5514 "Show next page of the selected article.
5515 If at the end of the current article, select the next article.
5516 LINES says how many lines should be scrolled up.
5518 If CIRCULAR is non-nil, go to the start of the article instead of
5519 selecting the next article when reaching the end of the current
5522 (setq gnus-summary-buffer (current-buffer))
5523 (gnus-set-global-variables)
5524 (let ((article (gnus-summary-article-number))
5525 (article-window (get-buffer-window gnus-article-buffer t))
5527 (gnus-configure-windows 'article)
5528 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5529 (if (and (eq gnus-summary-goto-unread 'never)
5530 (not (gnus-summary-last-article-p article)))
5531 (gnus-summary-next-article)
5532 (gnus-summary-next-unread-article))
5533 (if (or (null gnus-current-article)
5534 (null gnus-article-current)
5535 (/= article (cdr gnus-article-current))
5536 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5537 ;; Selected subject is different from current article's.
5538 (gnus-summary-display-article article)
5539 (when article-window
5540 (gnus-eval-in-buffer-window gnus-article-buffer
5541 (setq endp (gnus-article-next-page lines)))
5544 (gnus-summary-beginning-of-article))
5546 (gnus-message 3 "End of message"))
5548 (if (and (eq gnus-summary-goto-unread 'never)
5549 (not (gnus-summary-last-article-p article)))
5550 (gnus-summary-next-article)
5551 (gnus-summary-next-unread-article))))))))
5552 (gnus-summary-recenter)
5553 (gnus-summary-position-point)))
5555 (defun gnus-summary-prev-page (&optional lines move)
5556 "Show previous page of selected article.
5557 Argument LINES specifies lines to be scrolled down.
5558 If MOVE, move to the previous unread article if point is at
5559 the beginning of the buffer."
5561 (gnus-set-global-variables)
5562 (let ((article (gnus-summary-article-number))
5563 (article-window (get-buffer-window gnus-article-buffer t))
5565 (gnus-configure-windows 'article)
5566 (if (or (null gnus-current-article)
5567 (null gnus-article-current)
5568 (/= article (cdr gnus-article-current))
5569 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5570 ;; Selected subject is different from current article's.
5571 (gnus-summary-display-article article)
5572 (gnus-summary-recenter)
5573 (when article-window
5574 (gnus-eval-in-buffer-window gnus-article-buffer
5575 (setq endp (gnus-article-prev-page lines)))
5576 (when (and move endp)
5578 (gnus-message 3 "Beginning of message"))
5580 (if (and (eq gnus-summary-goto-unread 'never)
5581 (not (gnus-summary-first-article-p article)))
5582 (gnus-summary-prev-article)
5583 (gnus-summary-prev-unread-article))))))))
5584 (gnus-summary-position-point))
5586 (defun gnus-summary-prev-page-or-article (&optional lines)
5587 "Show previous page of selected article.
5588 Argument LINES specifies lines to be scrolled down.
5589 If at the beginning of the article, go to the next article."
5591 (gnus-summary-prev-page lines t))
5593 (defun gnus-summary-scroll-up (lines)
5594 "Scroll up (or down) one line current article.
5595 Argument LINES specifies lines to be scrolled up (or down if negative)."
5597 (gnus-set-global-variables)
5598 (gnus-configure-windows 'article)
5599 (gnus-summary-show-thread)
5600 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5601 (gnus-eval-in-buffer-window gnus-article-buffer
5603 (when (gnus-article-next-page lines)
5604 (gnus-message 3 "End of message")))
5606 (gnus-article-prev-page (- lines))))))
5607 (gnus-summary-recenter)
5608 (gnus-summary-position-point))
5610 (defun gnus-summary-next-same-subject ()
5611 "Select next article which has the same subject as current one."
5613 (gnus-set-global-variables)
5614 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5616 (defun gnus-summary-prev-same-subject ()
5617 "Select previous article which has the same subject as current one."
5619 (gnus-set-global-variables)
5620 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5622 (defun gnus-summary-next-unread-same-subject ()
5623 "Select next unread article which has the same subject as current one."
5625 (gnus-set-global-variables)
5626 (gnus-summary-next-article t (gnus-summary-article-subject)))
5628 (defun gnus-summary-prev-unread-same-subject ()
5629 "Select previous unread article which has the same subject as current one."
5631 (gnus-set-global-variables)
5632 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5634 (defun gnus-summary-first-unread-article ()
5635 "Select the first unread article.
5636 Return nil if there are no unread articles."
5638 (gnus-set-global-variables)
5640 (when (gnus-summary-first-subject t)
5641 (gnus-summary-show-thread)
5642 (gnus-summary-first-subject t)
5643 (gnus-summary-display-article (gnus-summary-article-number)))
5644 (gnus-summary-position-point)))
5646 (defun gnus-summary-first-article ()
5647 "Select the first article.
5648 Return nil if there are no articles."
5650 (gnus-set-global-variables)
5652 (when (gnus-summary-first-subject)
5653 (gnus-summary-show-thread)
5654 (gnus-summary-first-subject)
5655 (gnus-summary-display-article (gnus-summary-article-number)))
5656 (gnus-summary-position-point)))
5658 (defun gnus-summary-best-unread-article ()
5659 "Select the unread article with the highest score."
5661 (gnus-set-global-variables)
5662 (let ((best -1000000)
5663 (data gnus-newsgroup-data)
5666 (and (gnus-data-unread-p (car data))
5668 (gnus-summary-article-score (gnus-data-number (car data))))
5671 article (gnus-data-number (car data))))
5672 (setq data (cdr data)))
5675 (gnus-summary-goto-article article)
5676 (error "No unread articles"))
5677 (gnus-summary-position-point))))
5679 (defun gnus-summary-last-subject ()
5680 "Go to the last displayed subject line in the group."
5681 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5683 (gnus-summary-goto-subject article))))
5685 (defun gnus-summary-goto-article (article &optional all-headers force)
5686 "Fetch ARTICLE and display it if it exists.
5687 If ALL-HEADERS is non-nil, no header lines are hidden."
5693 (mapcar (lambda (number) (list (int-to-string number)))
5694 gnus-newsgroup-limit)))
5698 (if (gnus-summary-goto-subject article force)
5699 (gnus-summary-display-article article all-headers)
5700 (gnus-message 4 "Couldn't go to article %s" article) nil)
5701 (gnus-summary-position-point)))
5703 (defun gnus-summary-goto-last-article ()
5704 "Go to the previously read article."
5707 (when gnus-last-article
5708 (gnus-summary-goto-article gnus-last-article))
5709 (gnus-summary-position-point)))
5711 (defun gnus-summary-pop-article (number)
5712 "Pop one article off the history and go to the previous.
5713 NUMBER articles will be popped off."
5716 (setq gnus-newsgroup-history
5717 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5719 (gnus-summary-goto-article (car to))
5720 (error "Article history empty")))
5721 (gnus-summary-position-point))
5723 ;; Summary commands and functions for limiting the summary buffer.
5725 (defun gnus-summary-limit-to-articles (n)
5726 "Limit the summary buffer to the next N articles.
5727 If not given a prefix, use the process marked articles instead."
5729 (gnus-set-global-variables)
5731 (let ((articles (gnus-summary-work-articles n)))
5732 (setq gnus-newsgroup-processable nil)
5733 (gnus-summary-limit articles))
5734 (gnus-summary-position-point)))
5736 (defun gnus-summary-pop-limit (&optional total)
5737 "Restore the previous limit.
5738 If given a prefix, remove all limits."
5740 (gnus-set-global-variables)
5742 (setq gnus-newsgroup-limits
5743 (list (mapcar (lambda (h) (mail-header-number h))
5744 gnus-newsgroup-headers))))
5745 (unless gnus-newsgroup-limits
5746 (error "No limit to pop"))
5748 (gnus-summary-limit nil 'pop)
5749 (gnus-summary-position-point)))
5751 (defun gnus-summary-limit-to-subject (subject &optional header)
5752 "Limit the summary buffer to articles that have subjects that match a regexp."
5753 (interactive "sLimit to subject (regexp): ")
5755 (setq header "subject"))
5756 (when (not (equal "" subject))
5758 (let ((articles (gnus-summary-find-matching
5759 (or header "subject") subject 'all)))
5761 (error "Found no matches for \"%s\"" subject))
5762 (gnus-summary-limit articles))
5763 (gnus-summary-position-point))))
5765 (defun gnus-summary-limit-to-author (from)
5766 "Limit the summary buffer to articles that have authors that match a regexp."
5767 (interactive "sLimit to author (regexp): ")
5768 (gnus-summary-limit-to-subject from "from"))
5770 (defun gnus-summary-limit-to-age (age &optional younger-p)
5771 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5772 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5773 articles that are younger than AGE days."
5774 (interactive "nTime in days: \nP")
5776 (let ((data gnus-newsgroup-data)
5777 (cutoff (nnmail-days-to-time age))
5778 articles d date is-younger)
5779 (while (setq d (pop data))
5780 (when (and (vectorp (gnus-data-header d))
5781 (setq date (mail-header-date (gnus-data-header d))))
5782 (setq is-younger (nnmail-time-less
5783 (nnmail-time-since (nnmail-date-to-time date))
5785 (when (if younger-p is-younger (not is-younger))
5786 (push (gnus-data-number d) articles))))
5787 (gnus-summary-limit (nreverse articles)))
5788 (gnus-summary-position-point)))
5790 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5792 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5794 (defun gnus-summary-limit-to-unread (&optional all)
5795 "Limit the summary buffer to articles that are not marked as read.
5796 If ALL is non-nil, limit strictly to unread articles."
5799 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5800 (gnus-summary-limit-to-marks
5801 ;; Concat all the marks that say that an article is read and have
5803 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5804 gnus-killed-mark gnus-kill-file-mark
5805 gnus-low-score-mark gnus-expirable-mark
5806 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5807 gnus-duplicate-mark gnus-souped-mark)
5810 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5811 (make-obsolete 'gnus-summary-delete-marked-with
5812 'gnus-summary-limit-exlude-marks)
5814 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5815 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5816 If REVERSE, limit the summary buffer to articles that are marked
5817 with MARKS. MARKS can either be a string of marks or a list of marks.
5818 Returns how many articles were removed."
5819 (interactive "sMarks: ")
5820 (gnus-summary-limit-to-marks marks t))
5822 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5823 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5824 If REVERSE (the prefix), limit the summary buffer to articles that are
5825 not marked with MARKS. MARKS can either be a string of marks or a
5827 Returns how many articles were removed."
5828 (interactive (list (read-string "Marks: ") current-prefix-arg))
5829 (gnus-set-global-variables)
5831 (let ((data gnus-newsgroup-data)
5832 (marks (if (listp marks) marks
5833 (append marks nil))) ; Transform to list.
5836 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5837 (memq (gnus-data-mark (car data)) marks))
5838 (push (gnus-data-number (car data)) articles))
5839 (setq data (cdr data)))
5840 (gnus-summary-limit articles))
5841 (gnus-summary-position-point)))
5843 (defun gnus-summary-limit-to-score (&optional score)
5844 "Limit to articles with score at or above SCORE."
5846 (gnus-set-global-variables)
5847 (setq score (if score
5848 (prefix-numeric-value score)
5849 (or gnus-summary-default-score 0)))
5850 (let ((data gnus-newsgroup-data)
5853 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5855 (push (gnus-data-number (car data)) articles))
5856 (setq data (cdr data)))
5858 (gnus-summary-limit articles)
5859 (gnus-summary-position-point))))
5861 (defun gnus-summary-limit-include-dormant ()
5862 "Display all the hidden articles that are marked as dormant."
5864 (gnus-set-global-variables)
5865 (unless gnus-newsgroup-dormant
5866 (error "There are no dormant articles in this group"))
5868 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5869 (gnus-summary-position-point)))
5871 (defun gnus-summary-limit-exclude-dormant ()
5872 "Hide all dormant articles."
5874 (gnus-set-global-variables)
5876 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5877 (gnus-summary-position-point)))
5879 (defun gnus-summary-limit-exclude-childless-dormant ()
5880 "Hide all dormant articles that have no children."
5882 (gnus-set-global-variables)
5883 (let ((data (gnus-data-list t))
5884 articles d children)
5885 ;; Find all articles that are either not dormant or have
5887 (while (setq d (pop data))
5888 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5890 (gnus-article-children (gnus-data-number d)))
5893 (when (memq (car children) articles)
5898 (push (gnus-data-number d) articles)))
5901 (gnus-summary-limit articles)
5902 (gnus-summary-position-point))))
5904 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5905 "Mark all unread excluded articles as read.
5906 If ALL, mark even excluded ticked and dormants as read."
5908 (let ((articles (gnus-sorted-complement
5910 (mapcar (lambda (h) (mail-header-number h))
5911 gnus-newsgroup-headers)
5913 (sort gnus-newsgroup-limit '<)))
5915 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
5917 (setq gnus-newsgroup-dormant nil
5918 gnus-newsgroup-marked nil
5919 gnus-newsgroup-reads
5921 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5922 gnus-newsgroup-reads))
5923 (while (setq article (pop articles))
5924 (unless (or (memq article gnus-newsgroup-dormant)
5925 (memq article gnus-newsgroup-marked))
5926 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5928 (defun gnus-summary-limit (articles &optional pop)
5930 ;; We pop the previous limit off the stack and use that.
5931 (setq articles (car gnus-newsgroup-limits)
5932 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5933 ;; We use the new limit, so we push the old limit on the stack.
5934 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5936 (setq gnus-newsgroup-limit articles)
5937 (let ((total (length gnus-newsgroup-data))
5938 (data (gnus-data-find-list (gnus-summary-article-number)))
5939 (gnus-summary-mark-below nil) ; Inhibit this.
5941 ;; This will do all the work of generating the new summary buffer
5942 ;; according to the new limit.
5943 (gnus-summary-prepare)
5944 ;; Hide any threads, possibly.
5945 (and gnus-show-threads
5946 gnus-thread-hide-subtree
5947 (gnus-summary-hide-all-threads))
5948 ;; Try to return to the article you were at, or one in the
5951 ;; We try to find some article after the current one.
5953 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5956 (setq data (cdr data))))
5958 ;; If there is no data, that means that we were after the last
5959 ;; article. The same goes when we can't find any articles
5960 ;; after the current one.
5961 (goto-char (point-max))
5962 (gnus-summary-find-prev))
5963 ;; We return how many articles were removed from the summary
5964 ;; buffer as a result of the new limit.
5965 (- total (length gnus-newsgroup-data))))
5967 (defsubst gnus-invisible-cut-children (threads)
5970 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5975 (defsubst gnus-cut-thread (thread)
5976 "Go forwards in the thread until we find an article that we want to display."
5977 (when (or (eq gnus-fetch-old-headers 'some)
5978 (eq gnus-build-sparse-threads 'some)
5979 (eq gnus-build-sparse-threads 'more))
5980 ;; Deal with old-fetched headers and sparse threads.
5984 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
5985 (gnus-summary-article-ancient-p
5986 (mail-header-number (car thread))))
5988 (if (<= (length (cdr thread)) 1)
5989 (setq gnus-newsgroup-limit
5990 (delq (mail-header-number (car thread))
5991 gnus-newsgroup-limit)
5992 thread (cadr thread))
5993 (when (gnus-invisible-cut-children (cdr thread))
5994 (let ((th (cdr thread)))
5996 (if (memq (mail-header-number (caar th))
5997 gnus-newsgroup-limit)
5998 (setq thread (car th)
6000 (setq th (cdr th)))))))))))
6003 (defun gnus-cut-threads (threads)
6004 "Cut off all uninteresting articles from the beginning of threads."
6005 (when (or (eq gnus-fetch-old-headers 'some)
6006 (eq gnus-build-sparse-threads 'some)
6007 (eq gnus-build-sparse-threads 'more))
6010 (setcar th (gnus-cut-thread (car th)))
6011 (setq th (cdr th)))))
6012 ;; Remove nixed out threads.
6015 (defun gnus-summary-initial-limit (&optional show-if-empty)
6016 "Figure out what the initial limit is supposed to be on group entry.
6017 This entails weeding out unwanted dormants, low-scored articles,
6018 fetch-old-headers verbiage, and so on."
6019 ;; Most groups have nothing to remove.
6020 (if (or gnus-inhibit-limiting
6021 (and (null gnus-newsgroup-dormant)
6022 (not (eq gnus-fetch-old-headers 'some))
6023 (null gnus-summary-expunge-below)
6024 (not (eq gnus-build-sparse-threads 'some))
6025 (not (eq gnus-build-sparse-threads 'more))
6026 (null gnus-thread-expunge-below)
6027 (not gnus-use-nocem)))
6029 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6030 (setq gnus-newsgroup-limit nil)
6033 (unless (car (symbol-value node))
6034 ;; These threads have no parents -- they are roots.
6035 (let ((nodes (cdr (symbol-value node)))
6038 (if (and gnus-thread-expunge-below
6039 (< (gnus-thread-total-score (car nodes))
6040 gnus-thread-expunge-below))
6041 (gnus-expunge-thread (pop nodes))
6042 (setq thread (pop nodes))
6043 (gnus-summary-limit-children thread))))))
6044 gnus-newsgroup-dependencies)
6045 ;; If this limitation resulted in an empty group, we might
6046 ;; pop the previous limit and use it instead.
6047 (when (and (not gnus-newsgroup-limit)
6049 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6050 gnus-newsgroup-limit))
6052 (defun gnus-summary-limit-children (thread)
6053 "Return 1 if this subthread is visible and 0 if it is not."
6054 ;; First we get the number of visible children to this thread. This
6055 ;; is done by recursing down the thread using this function, so this
6056 ;; will really go down to a leaf article first, before slowly
6057 ;; working its way up towards the root.
6061 (apply '+ (mapcar 'gnus-summary-limit-children
6064 (number (mail-header-number (car thread)))
6067 (not (memq number gnus-newsgroup-marked))
6069 ;; If this article is dormant and has absolutely no visible
6070 ;; children, then this article isn't visible.
6071 (and (memq number gnus-newsgroup-dormant)
6073 ;; If this is "fetch-old-headered" and there is no
6074 ;; visible children, then we don't want this article.
6075 (and (eq gnus-fetch-old-headers 'some)
6076 (gnus-summary-article-ancient-p number)
6078 ;; If this is a sparsely inserted article with no children,
6079 ;; we don't want it.
6080 (and (eq gnus-build-sparse-threads 'some)
6081 (gnus-summary-article-sparse-p number)
6083 ;; If we use expunging, and this article is really
6084 ;; low-scored, then we don't want this article.
6085 (when (and gnus-summary-expunge-below
6087 (or (cdr (assq number gnus-newsgroup-scored))
6088 gnus-summary-default-score))
6089 gnus-summary-expunge-below))
6090 ;; We increase the expunge-tally here, but that has
6091 ;; nothing to do with the limits, really.
6092 (incf gnus-newsgroup-expunged-tally)
6093 ;; We also mark as read here, if that's wanted.
6094 (when (and gnus-summary-mark-below
6095 (< score gnus-summary-mark-below))
6096 (setq gnus-newsgroup-unreads
6097 (delq number gnus-newsgroup-unreads))
6098 (if gnus-newsgroup-auto-expire
6099 (push number gnus-newsgroup-expirable)
6100 (push (cons number gnus-low-score-mark)
6101 gnus-newsgroup-reads)))
6103 ;; Check NoCeM things.
6104 (if (and gnus-use-nocem
6105 (gnus-nocem-unwanted-article-p
6106 (mail-header-id (car thread))))
6108 (setq gnus-newsgroup-unreads
6109 (delq number gnus-newsgroup-unreads))
6111 ;; Nope, invisible article.
6113 ;; Ok, this article is to be visible, so we add it to the limit
6115 (push number gnus-newsgroup-limit)
6118 (defun gnus-expunge-thread (thread)
6119 "Mark all articles in THREAD as read."
6120 (let* ((number (mail-header-number (car thread))))
6121 (incf gnus-newsgroup-expunged-tally)
6122 ;; We also mark as read here, if that's wanted.
6123 (setq gnus-newsgroup-unreads
6124 (delq number gnus-newsgroup-unreads))
6125 (if gnus-newsgroup-auto-expire
6126 (push number gnus-newsgroup-expirable)
6127 (push (cons number gnus-low-score-mark)
6128 gnus-newsgroup-reads)))
6129 ;; Go recursively through all subthreads.
6130 (mapcar 'gnus-expunge-thread (cdr thread)))
6132 ;; Summary article oriented commands
6134 (defun gnus-summary-refer-parent-article (n)
6135 "Refer parent article N times.
6136 If N is negative, go to ancestor -N instead.
6137 The difference between N and the number of articles fetched is returned."
6139 (gnus-set-global-variables)
6142 (when (not (natnump n))
6147 (setq header (gnus-summary-article-header))
6148 (if (and (eq (mail-header-number header)
6149 (cdr gnus-article-current))
6150 (equal gnus-newsgroup-name
6151 (car gnus-article-current)))
6152 ;; If we try to find the parent of the currently
6153 ;; displayed article, then we take a look at the actual
6154 ;; References header, since this is slightly more
6155 ;; reliable than the References field we got from the
6158 (set-buffer gnus-original-article-buffer)
6159 (nnheader-narrow-to-headers)
6160 (unless (setq ref (message-fetch-field "references"))
6161 (setq ref (message-fetch-field "in-reply-to")))
6164 ;; It's not the current article, so we take a bet on
6165 ;; the value we got from the server.
6166 (mail-header-references header)))
6168 (not (equal ref "")))
6169 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6170 (gnus-message 1 "Couldn't find parent"))
6171 (gnus-message 1 "No references in article %d"
6172 (gnus-summary-article-number))
6175 (gnus-summary-position-point)
6178 (defun gnus-summary-refer-references ()
6179 "Fetch all articles mentioned in the References header.
6180 Return how many articles were fetched."
6182 (gnus-set-global-variables)
6183 (let ((ref (mail-header-references (gnus-summary-article-header)))
6184 (current (gnus-summary-article-number))
6188 (error "No References in the current article")
6189 ;; For each Message-ID in the References header...
6190 (while (string-match "<[^>]*>" ref)
6192 ;; ... fetch that article.
6193 (gnus-summary-refer-article
6194 (prog1 (match-string 0 ref)
6195 (setq ref (substring ref (match-end 0))))))
6196 (gnus-summary-goto-subject current)
6197 (gnus-summary-position-point)
6200 (defun gnus-summary-refer-article (message-id &optional arg)
6201 "Fetch an article specified by MESSAGE-ID.
6202 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6203 or `gnus-select-method', no matter what backend the article comes from."
6204 (interactive "sMessage-ID: \nP")
6205 (when (and (stringp message-id)
6206 (not (zerop (length message-id))))
6207 ;; Construct the correct Message-ID if necessary.
6208 ;; Suggested by tale@pawl.rpi.edu.
6209 (unless (string-match "^<" message-id)
6210 (setq message-id (concat "<" message-id)))
6211 (unless (string-match ">$" message-id)
6212 (setq message-id (concat message-id ">")))
6213 (let* ((header (gnus-id-to-header message-id))
6215 (gnus-summary-article-sparse-p
6216 (mail-header-number header))
6217 (memq (mail-header-number header)
6218 gnus-newsgroup-limit))))
6220 (or (not (gnus-summary-article-sparse-p
6221 (mail-header-number header)))
6224 ;; The article is present in the buffer, so we just go to it.
6225 (gnus-summary-goto-article
6226 (mail-header-number header) nil t)
6228 (gnus-summary-update-article (mail-header-number header))))
6229 ;; We fetch the article
6230 (let ((gnus-override-method
6231 (cond ((gnus-news-group-p gnus-newsgroup-name)
6232 gnus-refer-article-method)
6234 (or gnus-refer-article-method gnus-select-method))
6237 ;; Start the special refer-article method, if necessary.
6238 (when (and gnus-refer-article-method
6239 (gnus-news-group-p gnus-newsgroup-name))
6240 (gnus-check-server gnus-refer-article-method))
6241 ;; Fetch the header, and display the article.
6242 (if (setq number (gnus-summary-insert-subject message-id))
6243 (gnus-summary-select-article nil nil nil number)
6244 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6246 (defun gnus-summary-enter-digest-group (&optional force)
6247 "Enter an nndoc group based on the current article.
6248 If FORCE, force a digest interpretation. If not, try
6249 to guess what the document format is."
6251 (gnus-set-global-variables)
6252 (let ((conf gnus-current-window-configuration))
6254 (gnus-summary-select-article))
6255 (setq gnus-current-window-configuration conf)
6256 (let* ((name (format "%s-%d"
6257 (gnus-group-prefixed-name
6258 gnus-newsgroup-name (list 'nndoc ""))
6260 (set-buffer gnus-summary-buffer)
6261 gnus-current-article)))
6262 (ogroup gnus-newsgroup-name)
6263 (params (append (gnus-info-params (gnus-get-info ogroup))
6264 (list (cons 'to-group ogroup))
6265 (list (cons 'save-article-group ogroup))))
6266 (case-fold-search t)
6267 (buf (current-buffer))
6270 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6271 (insert-buffer-substring gnus-original-article-buffer)
6272 ;; Remove lines that may lead nndoc to misinterpret the
6275 (goto-char (point-min))
6276 (or (search-forward "\n\n" nil t) (point)))
6277 (goto-char (point-min))
6278 (delete-matching-lines "^\\(Path\\):\\|^From ")
6281 (if (gnus-group-read-ephemeral-group
6282 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6284 ,(if force 'digest 'guess))) t)
6285 ;; Make all postings to this group go to the parent group.
6286 (nconc (gnus-info-params (gnus-get-info name))
6288 ;; Couldn't select this doc group.
6289 (switch-to-buffer buf)
6290 (gnus-set-global-variables)
6291 (gnus-configure-windows 'summary)
6292 (gnus-message 3 "Article couldn't be entered?"))
6293 (kill-buffer dig)))))
6295 (defun gnus-summary-read-document (n)
6296 "Open a new group based on the current article(s).
6297 This will allow you to read digests and other similar
6298 documents as newsgroups.
6299 Obeys the standard process/prefix convention."
6301 (let* ((articles (gnus-summary-work-articles n))
6302 (ogroup gnus-newsgroup-name)
6303 (params (append (gnus-info-params (gnus-get-info ogroup))
6304 (list (cons 'to-group ogroup))))
6305 article group egroup groups vgroup)
6306 (while (setq article (pop articles))
6307 (setq group (format "%s-%d" gnus-newsgroup-name article))
6308 (gnus-summary-remove-process-mark article)
6309 (when (gnus-summary-display-article article)
6311 (nnheader-temp-write nil
6312 (insert-buffer-substring gnus-original-article-buffer)
6313 ;; Remove some headers that may lead nndoc to make
6315 (message-narrow-to-head)
6316 (goto-char (point-min))
6317 (delete-matching-lines "^\\(Path\\):\\|^From ")
6320 (gnus-group-read-ephemeral-group
6321 group `(nndoc ,group (nndoc-address ,(current-buffer))
6322 (nndoc-article-type guess))
6325 ;; Make all postings to this group go to the parent group.
6326 (nconc (gnus-info-params (gnus-get-info egroup))
6328 (push egroup groups))
6329 ;; Couldn't select this doc group.
6330 (gnus-error 3 "Article couldn't be entered"))))))
6331 ;; Now we have selected all the documents.
6334 (error "None of the articles could be interpreted as documents"))
6335 ((gnus-group-read-ephemeral-group
6336 (setq vgroup (format
6337 "nnvirtual:%s-%s" gnus-newsgroup-name
6338 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6339 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6341 (cons (current-buffer) 'summary)))
6343 (error "Couldn't select virtual nndoc group")))))
6345 (defun gnus-summary-isearch-article (&optional regexp-p)
6346 "Do incremental search forward on the current article.
6347 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6349 (gnus-set-global-variables)
6350 (gnus-summary-select-article)
6351 (gnus-configure-windows 'article)
6352 (gnus-eval-in-buffer-window gnus-article-buffer
6353 ;;(goto-char (point-min))
6354 (isearch-forward regexp-p)))
6356 (defun gnus-summary-search-article-forward (regexp &optional backward)
6357 "Search for an article containing REGEXP forward.
6358 If BACKWARD, search backward instead."
6361 (format "Search article %s (regexp%s): "
6362 (if current-prefix-arg "backward" "forward")
6363 (if gnus-last-search-regexp
6364 (concat ", default " gnus-last-search-regexp)
6366 current-prefix-arg))
6367 (gnus-set-global-variables)
6368 (if (string-equal regexp "")
6369 (setq regexp (or gnus-last-search-regexp ""))
6370 (setq gnus-last-search-regexp regexp))
6371 (if (gnus-summary-search-article regexp backward)
6372 (gnus-summary-show-thread)
6373 (error "Search failed: \"%s\"" regexp)))
6375 (defun gnus-summary-search-article-backward (regexp)
6376 "Search for an article containing REGEXP backward."
6379 (format "Search article backward (regexp%s): "
6380 (if gnus-last-search-regexp
6381 (concat ", default " gnus-last-search-regexp)
6383 (gnus-summary-search-article-forward regexp 'backward))
6385 (defun gnus-summary-search-article (regexp &optional backward)
6386 "Search for an article containing REGEXP.
6387 Optional argument BACKWARD means do search for backward.
6388 `gnus-select-article-hook' is not called during the search."
6389 ;; We have to require this here to make sure that the following
6390 ;; dynamic binding isn't shadowed by autoloading.
6391 (require 'gnus-async)
6392 (let ((gnus-select-article-hook nil) ;Disable hook.
6393 (gnus-article-display-hook nil)
6394 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6395 (gnus-use-article-prefetch nil)
6396 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6397 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6398 (sum (current-buffer))
6401 (gnus-save-hidden-threads
6402 (gnus-summary-select-article)
6403 (set-buffer gnus-article-buffer)
6407 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6409 (re-search-backward regexp nil t)
6410 (re-search-forward regexp nil t))
6411 ;; We found the regexp.
6416 (get-buffer-window (current-buffer))
6420 (setq point (point)))
6421 ;; We didn't find it, so we go to the next article.
6424 (while (eq found 'not)
6425 (if (not (if backward (gnus-summary-find-prev)
6426 (gnus-summary-find-next)))
6427 ;; No more articles.
6429 ;; Select the next article and adjust point.
6430 (unless (gnus-summary-article-sparse-p
6431 (gnus-summary-article-number))
6433 (gnus-summary-select-article)
6434 (set-buffer gnus-article-buffer)
6436 (goto-char (if backward (point-max) (point-min))))))))
6437 (gnus-message 7 ""))
6438 ;; Return whether we found the regexp.
6439 (when (eq found 'found)
6441 (gnus-summary-show-thread)
6442 (gnus-summary-goto-subject gnus-current-article)
6443 (gnus-summary-position-point)
6446 (defun gnus-summary-find-matching (header regexp &optional backward unread
6448 "Return a list of all articles that match REGEXP on HEADER.
6449 The search stars on the current article and goes forwards unless
6450 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6451 If UNREAD is non-nil, only unread articles will
6452 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6453 in the comparisons."
6454 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6455 (gnus-data-find-list
6456 (gnus-summary-article-number) (gnus-data-list backward))))
6457 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6458 (case-fold-search (not not-case-fold))
6460 (unless (fboundp (intern (concat "mail-header-" header)))
6461 (error "%s is not a valid header" header))
6464 (and (or (not unread) ; We want all articles...
6465 (gnus-data-unread-p d)) ; Or just unreads.
6466 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6467 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6468 (push (gnus-data-number d) articles)) ; Success!
6469 (setq data (cdr data)))
6470 (nreverse articles)))
6472 (defun gnus-summary-execute-command (header regexp command &optional backward)
6473 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6474 If HEADER is an empty string (or nil), the match is done on the entire
6475 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6477 (list (let ((completion-ignore-case t))
6480 (mapcar (lambda (string) (list string))
6481 '("Number" "Subject" "From" "Lines" "Date"
6482 "Message-ID" "Xref" "References" "Body"))
6483 nil 'require-match))
6484 (read-string "Regexp: ")
6485 (read-key-sequence "Command: ")
6486 current-prefix-arg))
6487 (when (equal header "Body")
6489 (gnus-set-global-variables)
6490 ;; Hidden thread subtrees must be searched as well.
6491 (gnus-summary-show-all-threads)
6492 ;; We don't want to change current point nor window configuration.
6494 (save-window-excursion
6495 (gnus-message 6 "Executing %s..." (key-description command))
6496 ;; We'd like to execute COMMAND interactively so as to give arguments.
6497 (gnus-execute header regexp
6498 `(call-interactively ',(key-binding command))
6500 (gnus-message 6 "Executing %s...done" (key-description command)))))
6502 (defun gnus-summary-beginning-of-article ()
6503 "Scroll the article back to the beginning."
6505 (gnus-set-global-variables)
6506 (gnus-summary-select-article)
6507 (gnus-configure-windows 'article)
6508 (gnus-eval-in-buffer-window gnus-article-buffer
6510 (goto-char (point-min))
6511 (when gnus-page-broken
6512 (gnus-narrow-to-page))))
6514 (defun gnus-summary-end-of-article ()
6515 "Scroll to the end of the article."
6517 (gnus-set-global-variables)
6518 (gnus-summary-select-article)
6519 (gnus-configure-windows 'article)
6520 (gnus-eval-in-buffer-window gnus-article-buffer
6522 (goto-char (point-max))
6524 (when gnus-page-broken
6525 (gnus-narrow-to-page))))
6527 (defun gnus-summary-print-article (&optional filename)
6528 "Generate and print a PostScript image of the article buffer.
6530 If the optional argument FILENAME is nil, send the image to the printer.
6531 If FILENAME is a string, save the PostScript image in a file with that
6532 name. If FILENAME is a number, prompt the user for the name of the file
6534 (interactive (list (ps-print-preprint current-prefix-arg)))
6535 (gnus-summary-select-article)
6536 (gnus-eval-in-buffer-window gnus-article-buffer
6537 (let ((buffer (generate-new-buffer " *print*")))
6540 (copy-to-buffer buffer (point-min) (point-max))
6542 (gnus-article-delete-invisible-text)
6543 (run-hooks 'gnus-ps-print-hook)
6544 (ps-print-buffer-with-faces filename))
6545 (kill-buffer buffer)))))
6547 (defun gnus-summary-show-article (&optional arg)
6548 "Force re-fetching of the current article.
6549 If ARG (the prefix) is non-nil, show the raw article without any
6550 article massaging functions being run."
6552 (gnus-set-global-variables)
6554 ;; Select the article the normal way.
6555 (gnus-summary-select-article nil 'force)
6556 ;; Bind the article treatment functions to nil.
6557 (let ((gnus-have-all-headers t)
6558 gnus-article-display-hook
6559 gnus-article-prepare-hook
6563 (gnus-summary-select-article nil 'force)))
6564 (gnus-summary-goto-subject gnus-current-article)
6565 (gnus-summary-position-point))
6567 (defun gnus-summary-verbose-headers (&optional arg)
6568 "Toggle permanent full header display.
6569 If ARG is a positive number, turn header display on.
6570 If ARG is a negative number, turn header display off."
6572 (gnus-set-global-variables)
6573 (setq gnus-show-all-headers
6574 (cond ((or (not (numberp arg))
6576 (not gnus-show-all-headers))
6579 (gnus-summary-show-article))
6581 (defun gnus-summary-toggle-header (&optional arg)
6582 "Show the headers if they are hidden, or hide them if they are shown.
6583 If ARG is a positive number, show the entire header.
6584 If ARG is a negative number, hide the unwanted header lines."
6586 (gnus-set-global-variables)
6588 (set-buffer gnus-article-buffer)
6589 (let* ((buffer-read-only nil)
6590 (inhibit-point-motion-hooks t)
6591 (hidden (text-property-any
6592 (goto-char (point-min)) (search-forward "\n\n")
6595 (goto-char (point-min))
6596 (when (search-forward "\n\n" nil t)
6597 (delete-region (point-min) (1- (point))))
6598 (goto-char (point-min))
6600 (set-buffer gnus-original-article-buffer)
6601 (goto-char (point-min))
6602 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6603 (insert-buffer-substring gnus-original-article-buffer 1 e)
6604 (let ((article-inhibit-hiding t))
6605 (run-hooks 'gnus-article-display-hook))
6606 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6607 (gnus-article-hide-headers)))))
6609 (defun gnus-summary-show-all-headers ()
6610 "Make all header lines visible."
6612 (gnus-set-global-variables)
6613 (gnus-article-show-all-headers))
6615 (defun gnus-summary-toggle-mime (&optional arg)
6616 "Toggle MIME processing.
6617 If ARG is a positive number, turn MIME processing on."
6619 (gnus-set-global-variables)
6620 (setq gnus-show-mime
6621 (if (null arg) (not gnus-show-mime)
6622 (> (prefix-numeric-value arg) 0)))
6623 (gnus-summary-select-article t 'force))
6625 (defun gnus-summary-caesar-message (&optional arg)
6626 "Caesar rotate the current article by 13.
6627 The numerical prefix specifies how many places to rotate each letter
6630 (gnus-set-global-variables)
6631 (gnus-summary-select-article)
6632 (let ((mail-header-separator ""))
6633 (gnus-eval-in-buffer-window gnus-article-buffer
6636 (let ((start (window-start))
6638 (message-caesar-buffer-body arg)
6639 (set-window-start (get-buffer-window (current-buffer)) start))))))
6641 (defun gnus-summary-stop-page-breaking ()
6642 "Stop page breaking in the current article."
6644 (gnus-set-global-variables)
6645 (gnus-summary-select-article)
6646 (gnus-eval-in-buffer-window gnus-article-buffer
6648 (when (gnus-visual-p 'page-marker)
6649 (let ((buffer-read-only nil))
6650 (gnus-remove-text-with-property 'gnus-prev)
6651 (gnus-remove-text-with-property 'gnus-next)))))
6653 (defun gnus-summary-move-article (&optional n to-newsgroup
6654 select-method action)
6655 "Move the current article to a different newsgroup.
6656 If N is a positive number, move the N next articles.
6657 If N is a negative number, move the N previous articles.
6658 If N is nil and any articles have been marked with the process mark,
6659 move those articles instead.
6660 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6661 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6662 re-spool using this method.
6664 For this function to work, both the current newsgroup and the
6665 newsgroup that you want to move to have to support the `request-move'
6666 and `request-accept' functions."
6669 (setq action 'move))
6670 (gnus-set-global-variables)
6671 ;; Disable marking as read.
6672 (let (gnus-mark-article-hook)
6673 (save-window-excursion
6674 (gnus-summary-select-article)))
6675 ;; Check whether the source group supports the required functions.
6676 (cond ((and (eq action 'move)
6677 (not (gnus-check-backend-function
6678 'request-move-article gnus-newsgroup-name)))
6679 (error "The current group does not support article moving"))
6680 ((and (eq action 'crosspost)
6681 (not (gnus-check-backend-function
6682 'request-replace-article gnus-newsgroup-name)))
6683 (error "The current group does not support article editing")))
6684 (let ((articles (gnus-summary-work-articles n))
6685 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6686 (names '((move "Move" "Moving")
6687 (copy "Copy" "Copying")
6688 (crosspost "Crosspost" "Crossposting")))
6689 (copy-buf (save-excursion
6690 (nnheader-set-temp-buffer " *copy article*")))
6691 art-group to-method new-xref article to-groups)
6692 (unless (assq action names)
6693 (error "Unknown action %s" action))
6694 ;; Read the newsgroup name.
6695 (when (and (not to-newsgroup)
6696 (not select-method))
6698 (gnus-read-move-group-name
6699 (cadr (assq action names))
6700 (symbol-value (intern (format "gnus-current-%s-group" action)))
6702 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6703 (setq to-method (or select-method
6704 (gnus-group-name-to-method to-newsgroup)))
6705 ;; Check the method we are to move this article to...
6706 (unless (gnus-check-backend-function
6707 'request-accept-article (car to-method))
6708 (error "%s does not support article copying" (car to-method)))
6709 (unless (gnus-check-server to-method)
6710 (error "Can't open server %s" (car to-method)))
6711 (gnus-message 6 "%s to %s: %s..."
6712 (caddr (assq action names))
6713 (or (car select-method) to-newsgroup) articles)
6715 (setq article (pop articles))
6719 ;; Move the article.
6721 ;; Remove this article from future suppression.
6722 (gnus-dup-unsuppress-article article)
6723 (gnus-request-move-article
6724 article ; Article to move
6725 gnus-newsgroup-name ; From newsgroup
6726 (nth 1 (gnus-find-method-for-group
6727 gnus-newsgroup-name)) ; Server
6728 (list 'gnus-request-accept-article
6729 to-newsgroup (list 'quote select-method)
6730 (not articles)) ; Accept form
6731 (not articles))) ; Only save nov last time
6732 ;; Copy the article.
6735 (set-buffer copy-buf)
6736 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6737 (gnus-request-accept-article
6738 to-newsgroup select-method (not articles))))
6739 ;; Crosspost the article.
6740 ((eq action 'crosspost)
6741 (let ((xref (message-tokenize-header
6742 (mail-header-xref (gnus-summary-article-header article))
6744 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6747 (setq xref (list (system-name))))
6750 (mapconcat 'identity
6751 (delete "Xref:" (delete new-xref xref))
6755 (set-buffer copy-buf)
6756 ;; First put the article in the destination group.
6757 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6758 (when (consp (setq art-group
6759 (gnus-request-accept-article
6760 to-newsgroup select-method (not articles))))
6761 (setq new-xref (concat new-xref " " (car art-group)
6762 ":" (cdr art-group)))
6763 ;; Now we have the new Xrefs header, so we insert
6764 ;; it and replace the new article.
6765 (nnheader-replace-header "Xref" new-xref)
6766 (gnus-request-replace-article
6767 (cdr art-group) to-newsgroup (current-buffer))
6771 (gnus-message 1 "Couldn't %s article %s"
6772 (cadr (assq action names)) article))
6773 ((and (eq art-group 'junk)
6775 (gnus-summary-mark-article article gnus-canceled-mark)
6776 (gnus-message 4 "Deleted article %s" article))
6780 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6782 (gnus-group-prefixed-name
6785 (gnus-find-method-for-group to-newsgroup)))
6786 gnus-newsrc-hashtb)))
6787 (info (nth 2 entry))
6788 (to-group (gnus-info-group info)))
6789 ;; Update the group that has been moved to.
6791 (memq action '(move copy)))
6792 (unless (member to-group to-groups)
6793 (push to-group to-groups))
6795 (unless (memq article gnus-newsgroup-unreads)
6797 info (gnus-add-to-range (gnus-info-read info)
6798 (list (cdr art-group)))))
6800 ;; Copy any marks over to the new group.
6801 (let ((marks gnus-article-mark-lists)
6802 (to-article (cdr art-group)))
6804 ;; See whether the article is to be put in the cache.
6805 (when gnus-use-cache
6806 (gnus-cache-possibly-enter-article
6808 (let ((header (copy-sequence
6809 (gnus-summary-article-header article))))
6810 (mail-header-set-number header to-article)
6812 (memq article gnus-newsgroup-marked)
6813 (memq article gnus-newsgroup-dormant)
6814 (memq article gnus-newsgroup-unreads)))
6816 (when (and (equal to-group gnus-newsgroup-name)
6817 (not (memq article gnus-newsgroup-unreads)))
6818 ;; Mark this article as read in this group.
6819 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6820 (setcdr (gnus-active to-group) to-article)
6821 (setcdr gnus-newsgroup-active to-article))
6824 (when (memq article (symbol-value
6825 (intern (format "gnus-newsgroup-%s"
6827 ;; If the other group is the same as this group,
6828 ;; then we have to add the mark to the list.
6829 (when (equal to-group gnus-newsgroup-name)
6830 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6833 (intern (format "gnus-newsgroup-%s"
6835 ;; Copy the marks to other group.
6836 (gnus-add-marked-articles
6837 to-group (cdar marks) (list to-article) info))
6838 (setq marks (cdr marks)))
6841 (concat "(gnus-group-set-info '"
6842 (gnus-prin1-to-string (gnus-get-info to-group))
6845 ;; Update the Xref header in this article to point to
6846 ;; the new crossposted article we have just created.
6847 (when (eq action 'crosspost)
6849 (set-buffer copy-buf)
6850 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6851 (nnheader-replace-header "Xref" new-xref)
6852 (gnus-request-replace-article
6853 article gnus-newsgroup-name (current-buffer)))))
6855 (gnus-summary-goto-subject article)
6856 (when (eq action 'move)
6857 (gnus-summary-mark-article article gnus-canceled-mark))))
6858 (gnus-summary-remove-process-mark article))
6859 ;; Re-activate all groups that have been moved to.
6862 (set-buffer gnus-group-buffer)
6863 (when (gnus-group-goto-group (car to-groups) t)
6864 (gnus-group-get-new-news-this-group 1 t))
6867 (gnus-kill-buffer copy-buf)
6868 (gnus-summary-position-point)
6869 (gnus-set-mode-line 'summary)))
6871 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6872 "Move the current article to a different newsgroup.
6873 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6874 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6875 re-spool using this method."
6877 (gnus-summary-move-article n to-newsgroup select-method 'copy))
6879 (defun gnus-summary-crosspost-article (&optional n)
6880 "Crosspost the current article to some other group."
6882 (gnus-summary-move-article n nil nil 'crosspost))
6884 (defcustom gnus-summary-respool-default-method nil
6885 "Default method for respooling an article.
6886 If nil, use to the current newsgroup method."
6887 :type 'gnus-select-method-name
6888 :group 'gnus-summary-mail)
6890 (defun gnus-summary-respool-article (&optional n method)
6891 "Respool the current article.
6892 The article will be squeezed through the mail spooling process again,
6893 which means that it will be put in some mail newsgroup or other
6894 depending on `nnmail-split-methods'.
6895 If N is a positive number, respool the N next articles.
6896 If N is a negative number, respool the N previous articles.
6897 If N is nil and any articles have been marked with the process mark,
6898 respool those articles instead.
6900 Respooling can be done both from mail groups and \"real\" newsgroups.
6901 In the former case, the articles in question will be moved from the
6902 current group into whatever groups they are destined to. In the
6903 latter case, they will be copied into the relevant groups."
6905 (list current-prefix-arg
6906 (let* ((methods (gnus-methods-using 'respool))
6908 (symbol-name (or gnus-summary-respool-default-method
6909 (car (gnus-find-method-for-group
6910 gnus-newsgroup-name)))))
6912 (gnus-completing-read
6913 methname "What backend do you want to use when respooling?"
6914 methods nil t nil 'gnus-mail-method-history))
6917 ((zerop (length (setq ms (gnus-servers-using-backend
6919 (list (intern method) ""))
6923 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6924 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6926 (gnus-set-global-variables)
6928 (error "No method given for respooling"))
6929 (if (assoc (symbol-name
6930 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6931 (gnus-methods-using 'respool))
6932 (gnus-summary-move-article n nil method)
6933 (gnus-summary-copy-article n nil method)))
6935 (defun gnus-summary-import-article (file)
6936 "Import a random file into a mail newsgroup."
6937 (interactive "fImport file: ")
6938 (gnus-set-global-variables)
6939 (let ((group gnus-newsgroup-name)
6940 (now (current-time))
6942 (unless (gnus-check-backend-function 'request-accept-article group)
6943 (error "%s does not support article importing" group))
6944 (or (file-readable-p file)
6945 (not (file-regular-p file))
6946 (error "Can't read %s" file))
6948 (set-buffer (get-buffer-create " *import file*"))
6949 (buffer-disable-undo (current-buffer))
6951 (insert-file-contents file)
6952 (goto-char (point-min))
6953 (unless (nnheader-article-p)
6954 ;; This doesn't look like an article, so we fudge some headers.
6955 (setq atts (file-attributes file)
6956 lines (count-lines (point-min) (point-max)))
6957 (insert "From: " (read-string "From: ") "\n"
6958 "Subject: " (read-string "Subject: ") "\n"
6959 "Date: " (timezone-make-date-arpa-standard
6960 (current-time-string (nth 5 atts))
6961 (current-time-zone now)
6962 (current-time-zone now))
6964 "Message-ID: " (message-make-message-id) "\n"
6965 "Lines: " (int-to-string lines) "\n"
6966 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6967 (gnus-request-accept-article group nil t)
6968 (kill-buffer (current-buffer)))))
6970 (defun gnus-summary-article-posted-p ()
6971 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6972 This will be the case if the article has both been mailed and posted."
6974 (let ((id (mail-header-references (gnus-summary-article-header)))
6975 (gnus-override-method
6976 (or gnus-refer-article-method gnus-select-method)))
6977 (if (gnus-request-head id "")
6978 (gnus-message 2 "The current message was found on %s"
6979 gnus-override-method)
6980 (gnus-message 2 "The current message couldn't be found on %s"
6981 gnus-override-method)
6984 (defun gnus-summary-expire-articles (&optional now)
6985 "Expire all articles that are marked as expirable in the current group."
6987 (gnus-set-global-variables)
6988 (when (gnus-check-backend-function
6989 'request-expire-articles gnus-newsgroup-name)
6990 ;; This backend supports expiry.
6991 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6992 (expirable (if total
6994 ;; We need to update the info for
6995 ;; this group for `gnus-list-of-read-articles'
6996 ;; to give us the right answer.
6997 (run-hooks 'gnus-exit-group-hook)
6998 (gnus-summary-update-info)
6999 (gnus-list-of-read-articles gnus-newsgroup-name))
7000 (setq gnus-newsgroup-expirable
7001 (sort gnus-newsgroup-expirable '<))))
7002 (expiry-wait (if now 'immediate
7003 (gnus-group-find-parameter
7004 gnus-newsgroup-name 'expiry-wait)))
7007 ;; There are expirable articles in this group, so we run them
7008 ;; through the expiry process.
7009 (gnus-message 6 "Expiring articles...")
7010 ;; The list of articles that weren't expired is returned.
7012 (let ((nnmail-expiry-wait-function nil)
7013 (nnmail-expiry-wait expiry-wait))
7014 (setq es (gnus-request-expire-articles
7015 expirable gnus-newsgroup-name)))
7016 (setq es (gnus-request-expire-articles
7017 expirable gnus-newsgroup-name)))
7019 (setq gnus-newsgroup-expirable es))
7020 ;; We go through the old list of expirable, and mark all
7021 ;; really expired articles as nonexistent.
7022 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7023 (let ((gnus-use-cache nil))
7025 (unless (memq (car expirable) es)
7026 (when (gnus-data-find (car expirable))
7027 (gnus-summary-mark-article
7028 (car expirable) gnus-canceled-mark)))
7029 (setq expirable (cdr expirable)))))
7030 (gnus-message 6 "Expiring articles...done")))))
7032 (defun gnus-summary-expire-articles-now ()
7033 "Expunge all expirable articles in the current group.
7034 This means that *all* articles that are marked as expirable will be
7035 deleted forever, right now."
7037 (gnus-set-global-variables)
7038 (or gnus-expert-user
7040 "Are you really, really, really sure you want to delete all these messages? ")
7042 (gnus-summary-expire-articles t))
7044 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7045 (defun gnus-summary-delete-article (&optional n)
7046 "Delete the N next (mail) articles.
7047 This command actually deletes articles. This is not a marking
7048 command. The article will disappear forever from your life, never to
7050 If N is negative, delete backwards.
7051 If N is nil and articles have been marked with the process mark,
7052 delete these instead."
7054 (gnus-set-global-variables)
7055 (unless (gnus-check-backend-function 'request-expire-articles
7056 gnus-newsgroup-name)
7057 (error "The current newsgroup does not support article deletion"))
7058 ;; Compute the list of articles to delete.
7059 (let ((articles (gnus-summary-work-articles n))
7061 (if (and gnus-novice-user
7062 (not (gnus-yes-or-no-p
7063 (format "Do you really want to delete %s forever? "
7064 (if (> (length articles) 1)
7065 (format "these %s articles" (length articles))
7068 ;; Delete the articles.
7069 (setq not-deleted (gnus-request-expire-articles
7070 articles gnus-newsgroup-name 'force))
7072 (gnus-summary-remove-process-mark (car articles))
7073 ;; The backend might not have been able to delete the article
7075 (unless (memq (car articles) not-deleted)
7076 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7077 (setq articles (cdr articles)))
7079 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7080 (gnus-summary-position-point)
7081 (gnus-set-mode-line 'summary)
7084 (defun gnus-summary-edit-article (&optional force)
7085 "Edit the current article.
7086 This will have permanent effect only in mail groups.
7087 If FORCE is non-nil, allow editing of articles even in read-only
7091 (set-buffer gnus-summary-buffer)
7092 (gnus-set-global-variables)
7093 (when (and (not force)
7094 (gnus-group-read-only-p))
7095 (error "The current newsgroup does not support article editing"))
7096 ;; Select article if needed.
7097 (unless (eq (gnus-summary-article-number)
7098 gnus-current-article)
7099 (gnus-summary-select-article t))
7100 (gnus-article-date-original)
7101 (gnus-article-edit-article
7103 (gnus-summary-edit-article-done
7104 ,(or (mail-header-references gnus-current-headers) "")
7105 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
7107 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7109 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
7110 "Make edits to the current article permanent."
7112 ;; Replace the article.
7113 (if (and (not read-only)
7114 (not (gnus-request-replace-article
7115 (cdr gnus-article-current) (car gnus-article-current)
7117 (error "Couldn't replace article")
7118 ;; Update the summary buffer.
7120 (equal (message-tokenize-header references " ")
7121 (message-tokenize-header
7122 (or (message-fetch-field "references") "") " ")))
7123 ;; We only have to update this line.
7126 (message-narrow-to-head)
7127 (let ((head (buffer-string))
7129 (nnheader-temp-write nil
7130 (insert (format "211 %d Article retrieved.\n"
7131 (cdr gnus-article-current)))
7134 (let ((nntp-server-buffer (current-buffer)))
7135 (setq header (car (gnus-get-newsgroup-headers
7137 (set-buffer gnus-summary-buffer)
7138 gnus-newsgroup-dependencies)
7141 (set-buffer gnus-summary-buffer)
7142 (gnus-data-set-header
7143 (gnus-data-find (cdr gnus-article-current))
7145 (gnus-summary-update-article-line
7146 (cdr gnus-article-current) header))))))
7148 (set-buffer (or buffer gnus-summary-buffer))
7149 (gnus-summary-update-article (cdr gnus-article-current)))
7150 ;; Prettify the article buffer again.
7152 (set-buffer gnus-article-buffer)
7153 (run-hooks 'gnus-article-display-hook)
7154 (set-buffer gnus-original-article-buffer)
7155 (gnus-request-article
7156 (cdr gnus-article-current) (car gnus-article-current) (current-buffer)))
7157 ;; Prettify the summary buffer line.
7158 (when (gnus-visual-p 'summary-highlight 'highlight)
7159 (run-hooks 'gnus-visual-mark-article-hook))))
7161 (defun gnus-summary-edit-wash (key)
7162 "Perform editing command in the article buffer."
7166 (message "%s" (concat (this-command-keys) "- "))
7169 (gnus-summary-edit-article)
7170 (execute-kbd-macro (concat (this-command-keys) key))
7171 (gnus-article-edit-done))
7175 (defun gnus-summary-respool-query (&optional silent)
7176 "Query where the respool algorithm would put this article."
7178 (gnus-set-global-variables)
7179 (let (gnus-mark-article-hook)
7180 (gnus-summary-select-article)
7182 (set-buffer gnus-original-article-buffer)
7184 (message-narrow-to-head)
7185 (let ((groups (nnmail-article-group 'identity)))
7188 (message "This message would go to %s"
7189 (mapconcat 'car groups ", "))
7190 (message "This message would go to no groups"))
7193 ;; Summary marking commands.
7195 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7196 "Mark articles which has the same subject as read, and then select the next.
7197 If UNMARK is positive, remove any kind of mark.
7198 If UNMARK is negative, tick articles."
7200 (gnus-set-global-variables)
7202 (setq unmark (prefix-numeric-value unmark)))
7204 (gnus-summary-mark-same-subject
7205 (gnus-summary-article-subject) unmark)))
7206 ;; Select next unread article. If auto-select-same mode, should
7207 ;; select the first unread article.
7208 (gnus-summary-next-article t (and gnus-auto-select-same
7209 (gnus-summary-article-subject)))
7210 (gnus-message 7 "%d article%s marked as %s"
7211 count (if (= count 1) " is" "s are")
7212 (if unmark "unread" "read"))))
7214 (defun gnus-summary-kill-same-subject (&optional unmark)
7215 "Mark articles which has the same subject as read.
7216 If UNMARK is positive, remove any kind of mark.
7217 If UNMARK is negative, tick articles."
7219 (gnus-set-global-variables)
7221 (setq unmark (prefix-numeric-value unmark)))
7223 (gnus-summary-mark-same-subject
7224 (gnus-summary-article-subject) unmark)))
7225 ;; If marked as read, go to next unread subject.
7227 ;; Go to next unread subject.
7228 (gnus-summary-next-subject 1 t))
7229 (gnus-message 7 "%d articles are marked as %s"
7230 count (if unmark "unread" "read"))))
7232 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7233 "Mark articles with same SUBJECT as read, and return marked number.
7234 If optional argument UNMARK is positive, remove any kinds of marks.
7235 If optional argument UNMARK is negative, mark articles as unread instead."
7239 ((null unmark) ; Mark as read.
7242 (gnus-summary-mark-article-as-read gnus-killed-mark)
7243 (gnus-summary-show-thread) t)
7244 (gnus-summary-find-subject subject))
7245 (setq count (1+ count))))
7246 ((> unmark 0) ; Tick.
7249 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7250 (gnus-summary-show-thread) t)
7251 (gnus-summary-find-subject subject))
7252 (setq count (1+ count))))
7253 (t ; Mark as unread.
7256 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7257 (gnus-summary-show-thread) t)
7258 (gnus-summary-find-subject subject))
7259 (setq count (1+ count)))))
7260 (gnus-set-mode-line 'summary)
7261 ;; Return the number of marked articles.
7264 (defun gnus-summary-mark-as-processable (n &optional unmark)
7265 "Set the process mark on the next N articles.
7266 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7267 the process mark instead. The difference between N and the actual
7268 number of articles marked is returned."
7270 (gnus-set-global-variables)
7271 (let ((backward (< n 0))
7276 (gnus-summary-remove-process-mark
7277 (gnus-summary-article-number))
7278 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7279 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7282 (gnus-message 7 "No more articles"))
7283 (gnus-summary-recenter)
7284 (gnus-summary-position-point)
7287 (defun gnus-summary-unmark-as-processable (n)
7288 "Remove the process mark from the next N articles.
7289 If N is negative, unmark backward instead. The difference between N and
7290 the actual number of articles unmarked is returned."
7292 (gnus-set-global-variables)
7293 (gnus-summary-mark-as-processable n t))
7295 (defun gnus-summary-unmark-all-processable ()
7296 "Remove the process mark from all articles."
7298 (gnus-set-global-variables)
7300 (while gnus-newsgroup-processable
7301 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7302 (gnus-summary-position-point))
7304 (defun gnus-summary-mark-as-expirable (n)
7305 "Mark N articles forward as expirable.
7306 If N is negative, mark backward instead. The difference between N and
7307 the actual number of articles marked is returned."
7309 (gnus-set-global-variables)
7310 (gnus-summary-mark-forward n gnus-expirable-mark))
7312 (defun gnus-summary-mark-article-as-replied (article)
7313 "Mark ARTICLE replied and update the summary line."
7314 (push article gnus-newsgroup-replied)
7315 (let ((buffer-read-only nil))
7316 (when (gnus-summary-goto-subject article)
7317 (gnus-summary-update-secondary-mark article))))
7319 (defun gnus-summary-set-bookmark (article)
7320 "Set a bookmark in current article."
7321 (interactive (list (gnus-summary-article-number)))
7322 (gnus-set-global-variables)
7323 (when (or (not (get-buffer gnus-article-buffer))
7324 (not gnus-current-article)
7325 (not gnus-article-current)
7326 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7327 (error "No current article selected"))
7328 ;; Remove old bookmark, if one exists.
7329 (let ((old (assq article gnus-newsgroup-bookmarks)))
7331 (setq gnus-newsgroup-bookmarks
7332 (delq old gnus-newsgroup-bookmarks))))
7333 ;; Set the new bookmark, which is on the form
7334 ;; (article-number . line-number-in-body).
7338 (set-buffer gnus-article-buffer)
7342 (goto-char (point-min))
7343 (search-forward "\n\n" nil t)
7346 gnus-newsgroup-bookmarks)
7347 (gnus-message 6 "A bookmark has been added to the current article."))
7349 (defun gnus-summary-remove-bookmark (article)
7350 "Remove the bookmark from the current article."
7351 (interactive (list (gnus-summary-article-number)))
7352 (gnus-set-global-variables)
7353 ;; Remove old bookmark, if one exists.
7354 (let ((old (assq article gnus-newsgroup-bookmarks)))
7357 (setq gnus-newsgroup-bookmarks
7358 (delq old gnus-newsgroup-bookmarks))
7359 (gnus-message 6 "Removed bookmark."))
7360 (gnus-message 6 "No bookmark in current article."))))
7362 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7363 (defun gnus-summary-mark-as-dormant (n)
7364 "Mark N articles forward as dormant.
7365 If N is negative, mark backward instead. The difference between N and
7366 the actual number of articles marked is returned."
7368 (gnus-set-global-variables)
7369 (gnus-summary-mark-forward n gnus-dormant-mark))
7371 (defun gnus-summary-set-process-mark (article)
7372 "Set the process mark on ARTICLE and update the summary line."
7373 (setq gnus-newsgroup-processable
7375 (delq article gnus-newsgroup-processable)))
7376 (when (gnus-summary-goto-subject article)
7377 (gnus-summary-show-thread)
7378 (gnus-summary-update-secondary-mark article)))
7380 (defun gnus-summary-remove-process-mark (article)
7381 "Remove the process mark from ARTICLE and update the summary line."
7382 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7383 (when (gnus-summary-goto-subject article)
7384 (gnus-summary-show-thread)
7385 (gnus-summary-update-secondary-mark article)))
7387 (defun gnus-summary-set-saved-mark (article)
7388 "Set the process mark on ARTICLE and update the summary line."
7389 (push article gnus-newsgroup-saved)
7390 (when (gnus-summary-goto-subject article)
7391 (gnus-summary-update-secondary-mark article)))
7393 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7394 "Mark N articles as read forwards.
7395 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7396 The difference between N and the actual number of articles marked is
7399 (gnus-set-global-variables)
7400 (let ((backward (< n 0))
7401 (gnus-summary-goto-unread
7402 (and gnus-summary-goto-unread
7403 (not (eq gnus-summary-goto-unread 'never))
7404 (not (memq mark (list gnus-unread-mark
7405 gnus-ticked-mark gnus-dormant-mark)))))
7407 (mark (or mark gnus-del-mark)))
7409 (gnus-summary-mark-article nil mark no-expire)
7410 (zerop (gnus-summary-next-subject
7412 (and gnus-summary-goto-unread
7413 (not (eq gnus-summary-goto-unread 'never)))
7417 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7418 (gnus-summary-recenter)
7419 (gnus-summary-position-point)
7420 (gnus-set-mode-line 'summary)
7423 (defun gnus-summary-mark-article-as-read (mark)
7424 "Mark the current article quickly as read with MARK."
7425 (let ((article (gnus-summary-article-number)))
7426 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7427 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7428 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7429 (push (cons article mark) gnus-newsgroup-reads)
7430 ;; Possibly remove from cache, if that is used.
7431 (when gnus-use-cache
7432 (gnus-cache-enter-remove-article article))
7433 ;; Allow the backend to change the mark.
7434 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7435 ;; Check for auto-expiry.
7436 (when (and gnus-newsgroup-auto-expire
7437 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7438 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7439 (= mark gnus-ancient-mark)
7440 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7441 (= mark gnus-duplicate-mark)))
7442 (setq mark gnus-expirable-mark)
7443 (push article gnus-newsgroup-expirable))
7444 ;; Set the mark in the buffer.
7445 (gnus-summary-update-mark mark 'unread)
7448 (defun gnus-summary-mark-article-as-unread (mark)
7449 "Mark the current article quickly as unread with MARK."
7450 (let ((article (gnus-summary-article-number)))
7452 (gnus-error 1 "Unmarkable article")
7453 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7454 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7455 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7456 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7457 (cond ((= mark gnus-ticked-mark)
7458 (push article gnus-newsgroup-marked))
7459 ((= mark gnus-dormant-mark)
7460 (push article gnus-newsgroup-dormant))
7462 (push article gnus-newsgroup-unreads)))
7463 (setq gnus-newsgroup-reads
7464 (delq (assq article gnus-newsgroup-reads)
7465 gnus-newsgroup-reads))
7467 ;; See whether the article is to be put in the cache.
7469 (vectorp (gnus-summary-article-header article))
7471 (gnus-cache-possibly-enter-article
7472 gnus-newsgroup-name article
7473 (gnus-summary-article-header article)
7474 (= mark gnus-ticked-mark)
7475 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7478 (gnus-summary-update-mark mark 'unread))
7481 (defun gnus-summary-mark-article (&optional article mark no-expire)
7482 "Mark ARTICLE with MARK. MARK can be any character.
7483 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7484 `??' (dormant) and `?E' (expirable).
7485 If MARK is nil, then the default character `?D' is used.
7486 If ARTICLE is nil, then the article on the current line will be
7488 ;; The mark might be a string.
7489 (when (stringp mark)
7490 (setq mark (aref mark 0)))
7491 ;; If no mark is given, then we check auto-expiring.
7492 (and (not no-expire)
7493 gnus-newsgroup-auto-expire
7495 (and (gnus-characterp mark)
7496 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7497 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7498 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7499 (= mark gnus-duplicate-mark))))
7500 (setq mark gnus-expirable-mark))
7501 (let* ((mark (or mark gnus-del-mark))
7502 (article (or article (gnus-summary-article-number))))
7504 (error "No article on current line"))
7505 (if (or (= mark gnus-unread-mark)
7506 (= mark gnus-ticked-mark)
7507 (= mark gnus-dormant-mark))
7508 (gnus-mark-article-as-unread article mark)
7509 (gnus-mark-article-as-read article mark))
7511 ;; See whether the article is to be put in the cache.
7513 (not (= mark gnus-canceled-mark))
7514 (vectorp (gnus-summary-article-header article))
7516 (gnus-cache-possibly-enter-article
7517 gnus-newsgroup-name article
7518 (gnus-summary-article-header article)
7519 (= mark gnus-ticked-mark)
7520 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7522 (when (gnus-summary-goto-subject article nil t)
7523 (let ((buffer-read-only nil))
7524 (gnus-summary-show-thread)
7526 (gnus-summary-update-mark mark 'unread)
7529 (defun gnus-summary-update-secondary-mark (article)
7530 "Update the secondary (read, process, cache) mark."
7531 (gnus-summary-update-mark
7532 (cond ((memq article gnus-newsgroup-processable)
7534 ((memq article gnus-newsgroup-cached)
7536 ((memq article gnus-newsgroup-replied)
7538 ((memq article gnus-newsgroup-saved)
7540 (t gnus-unread-mark))
7542 (when (gnus-visual-p 'summary-highlight 'highlight)
7543 (run-hooks 'gnus-summary-update-hook))
7546 (defun gnus-summary-update-mark (mark type)
7547 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7548 (buffer-read-only nil))
7549 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7550 (when (looking-at "\r")
7553 (<= (+ forward (point)) (point-max)))
7554 ;; Go to the right position on the line.
7555 (goto-char (+ forward (point)))
7556 ;; Replace the old mark with the new mark.
7557 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7558 ;; Optionally update the marks by some user rule.
7559 (when (eq type 'unread)
7561 (gnus-data-find (gnus-summary-article-number)) mark)
7562 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7564 (defun gnus-mark-article-as-read (article &optional mark)
7565 "Enter ARTICLE in the pertinent lists and remove it from others."
7566 ;; Make the article expirable.
7567 (let ((mark (or mark gnus-del-mark)))
7568 (if (= mark gnus-expirable-mark)
7569 (push article gnus-newsgroup-expirable)
7570 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7571 ;; Remove from unread and marked lists.
7572 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7573 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7574 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7575 (push (cons article mark) gnus-newsgroup-reads)
7576 ;; Possibly remove from cache, if that is used.
7577 (when gnus-use-cache
7578 (gnus-cache-enter-remove-article article))))
7580 (defun gnus-mark-article-as-unread (article &optional mark)
7581 "Enter ARTICLE in the pertinent lists and remove it from others."
7582 (let ((mark (or mark gnus-ticked-mark)))
7583 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7584 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7585 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7586 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7588 ;; Unsuppress duplicates?
7589 (when gnus-suppress-duplicates
7590 (gnus-dup-unsuppress-article article))
7592 (cond ((= mark gnus-ticked-mark)
7593 (push article gnus-newsgroup-marked))
7594 ((= mark gnus-dormant-mark)
7595 (push article gnus-newsgroup-dormant))
7597 (push article gnus-newsgroup-unreads)))
7598 (setq gnus-newsgroup-reads
7599 (delq (assq article gnus-newsgroup-reads)
7600 gnus-newsgroup-reads))))
7602 (defalias 'gnus-summary-mark-as-unread-forward
7603 'gnus-summary-tick-article-forward)
7604 (make-obsolete 'gnus-summary-mark-as-unread-forward
7605 'gnus-summary-tick-article-forward)
7606 (defun gnus-summary-tick-article-forward (n)
7607 "Tick N articles forwards.
7608 If N is negative, tick backwards instead.
7609 The difference between N and the number of articles ticked is returned."
7611 (gnus-summary-mark-forward n gnus-ticked-mark))
7613 (defalias 'gnus-summary-mark-as-unread-backward
7614 'gnus-summary-tick-article-backward)
7615 (make-obsolete 'gnus-summary-mark-as-unread-backward
7616 'gnus-summary-tick-article-backward)
7617 (defun gnus-summary-tick-article-backward (n)
7618 "Tick N articles backwards.
7619 The difference between N and the number of articles ticked is returned."
7621 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7623 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7624 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7625 (defun gnus-summary-tick-article (&optional article clear-mark)
7626 "Mark current article as unread.
7627 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7628 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7630 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7633 (defun gnus-summary-mark-as-read-forward (n)
7634 "Mark N articles as read forwards.
7635 If N is negative, mark backwards instead.
7636 The difference between N and the actual number of articles marked is
7639 (gnus-summary-mark-forward n gnus-del-mark t))
7641 (defun gnus-summary-mark-as-read-backward (n)
7642 "Mark the N articles as read backwards.
7643 The difference between N and the actual number of articles marked is
7646 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7648 (defun gnus-summary-mark-as-read (&optional article mark)
7649 "Mark current article as read.
7650 ARTICLE specifies the article to be marked as read.
7651 MARK specifies a string to be inserted at the beginning of the line."
7652 (gnus-summary-mark-article article mark))
7654 (defun gnus-summary-clear-mark-forward (n)
7655 "Clear marks from N articles forward.
7656 If N is negative, clear backward instead.
7657 The difference between N and the number of marks cleared is returned."
7659 (gnus-summary-mark-forward n gnus-unread-mark))
7661 (defun gnus-summary-clear-mark-backward (n)
7662 "Clear marks from N articles backward.
7663 The difference between N and the number of marks cleared is returned."
7665 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7667 (defun gnus-summary-mark-unread-as-read ()
7668 "Intended to be used by `gnus-summary-mark-article-hook'."
7669 (when (memq gnus-current-article gnus-newsgroup-unreads)
7670 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7672 (defun gnus-summary-mark-read-and-unread-as-read ()
7673 "Intended to be used by `gnus-summary-mark-article-hook'."
7674 (let ((mark (gnus-summary-article-mark)))
7675 (when (or (gnus-unread-mark-p mark)
7676 (gnus-read-mark-p mark))
7677 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7679 (defun gnus-summary-mark-region-as-read (point mark all)
7680 "Mark all unread articles between point and mark as read.
7681 If given a prefix, mark all articles between point and mark as read,
7682 even ticked and dormant ones."
7683 (interactive "r\nP")
7692 (memq (setq article (gnus-summary-article-number))
7693 gnus-newsgroup-unreads))
7694 (gnus-summary-mark-article article gnus-del-mark))
7696 (gnus-summary-find-next))))))
7698 (defun gnus-summary-mark-below (score mark)
7699 "Mark articles with score less than SCORE with MARK."
7700 (interactive "P\ncMark: ")
7701 (gnus-set-global-variables)
7702 (setq score (if score
7703 (prefix-numeric-value score)
7704 (or gnus-summary-default-score 0)))
7706 (set-buffer gnus-summary-buffer)
7707 (goto-char (point-min))
7710 (and (< (gnus-summary-article-score) score)
7711 (gnus-summary-mark-article nil mark))
7712 (gnus-summary-find-next)))))
7714 (defun gnus-summary-kill-below (&optional score)
7715 "Mark articles with score below SCORE as read."
7717 (gnus-set-global-variables)
7718 (gnus-summary-mark-below score gnus-killed-mark))
7720 (defun gnus-summary-clear-above (&optional score)
7721 "Clear all marks from articles with score above SCORE."
7723 (gnus-set-global-variables)
7724 (gnus-summary-mark-above score gnus-unread-mark))
7726 (defun gnus-summary-tick-above (&optional score)
7727 "Tick all articles with score above SCORE."
7729 (gnus-set-global-variables)
7730 (gnus-summary-mark-above score gnus-ticked-mark))
7732 (defun gnus-summary-mark-above (score mark)
7733 "Mark articles with score over SCORE with MARK."
7734 (interactive "P\ncMark: ")
7735 (gnus-set-global-variables)
7736 (setq score (if score
7737 (prefix-numeric-value score)
7738 (or gnus-summary-default-score 0)))
7740 (set-buffer gnus-summary-buffer)
7741 (goto-char (point-min))
7743 (when (> (gnus-summary-article-score) score)
7744 (gnus-summary-mark-article nil mark))
7746 (gnus-summary-find-next)))))
7748 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7749 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7750 (defun gnus-summary-limit-include-expunged (&optional no-error)
7751 "Display all the hidden articles that were expunged for low scores."
7753 (gnus-set-global-variables)
7754 (let ((buffer-read-only nil))
7755 (let ((scored gnus-newsgroup-scored)
7758 (unless (gnus-summary-goto-subject (caar scored))
7759 (and (setq h (gnus-summary-article-header (caar scored)))
7760 (< (cdar scored) gnus-summary-expunge-below)
7762 (setq scored (cdr scored)))
7764 (when (not no-error)
7765 (error "No expunged articles hidden"))
7766 (goto-char (point-min))
7767 (gnus-summary-prepare-unthreaded (nreverse headers))
7768 (goto-char (point-min))
7769 (gnus-summary-position-point)
7772 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7773 "Mark all unread articles in this newsgroup as read.
7774 If prefix argument ALL is non-nil, ticked and dormant articles will
7775 also be marked as read.
7776 If QUIETLY is non-nil, no questions will be asked.
7777 If TO-HERE is non-nil, it should be a point in the buffer. All
7778 articles before this point will be marked as read.
7779 Note that this function will only catch up the unread article
7780 in the current summary buffer limitation.
7781 The number of articles marked as read is returned."
7783 (gnus-set-global-variables)
7787 (not gnus-interactive-catchup) ;Without confirmation?
7791 "Mark absolutely all articles as read? "
7792 "Mark all unread articles as read? ")))
7794 (not gnus-newsgroup-adaptive)
7795 (not gnus-newsgroup-auto-expire)
7796 (not gnus-suppress-duplicates)
7797 (or (not gnus-use-cache)
7798 (not (eq gnus-use-cache 'passive))))
7801 (setq gnus-newsgroup-marked nil
7802 gnus-newsgroup-dormant nil))
7803 (setq gnus-newsgroup-unreads nil))
7804 ;; We actually mark all articles as canceled, which we
7805 ;; have to do when using auto-expiry or adaptive scoring.
7806 (gnus-summary-show-all-threads)
7807 (when (gnus-summary-first-subject (not all))
7809 (if to-here (< (point) to-here) t)
7810 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7811 (gnus-summary-find-next (not all)))))
7812 (gnus-set-mode-line 'summary))
7814 (gnus-summary-position-point)))
7816 (defun gnus-summary-catchup-to-here (&optional all)
7817 "Mark all unticked articles before the current one as read.
7818 If ALL is non-nil, also mark ticked and dormant articles as read."
7820 (gnus-set-global-variables)
7822 (gnus-save-hidden-threads
7823 (let ((beg (point)))
7824 ;; We check that there are unread articles.
7825 (when (or all (gnus-summary-find-prev))
7826 (gnus-summary-catchup all t beg)))))
7827 (gnus-summary-position-point))
7829 (defun gnus-summary-catchup-all (&optional quietly)
7830 "Mark all articles in this newsgroup as read."
7832 (gnus-set-global-variables)
7833 (gnus-summary-catchup t quietly))
7835 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7836 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7837 If prefix argument ALL is non-nil, all articles are marked as read."
7839 (gnus-set-global-variables)
7840 (when (gnus-summary-catchup all quietly nil 'fast)
7841 ;; Select next newsgroup or exit.
7842 (if (eq gnus-auto-select-next 'quietly)
7843 (gnus-summary-next-group nil)
7844 (gnus-summary-exit))))
7846 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7847 "Mark all articles in this newsgroup as read, and then exit."
7849 (gnus-set-global-variables)
7850 (gnus-summary-catchup-and-exit t quietly))
7852 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7853 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7854 "Mark all articles in this group as read and select the next group.
7855 If given a prefix, mark all articles, unread as well as ticked, as
7858 (gnus-set-global-variables)
7860 (gnus-summary-catchup all))
7861 (gnus-summary-next-article t nil nil t))
7863 ;; Thread-based commands.
7865 (defun gnus-summary-articles-in-thread (&optional article)
7866 "Return a list of all articles in the current thread.
7867 If ARTICLE is non-nil, return all articles in the thread that starts
7869 (let* ((article (or article (gnus-summary-article-number)))
7870 (data (gnus-data-find-list article))
7871 (top-level (gnus-data-level (car data)))
7873 (cond ((null gnus-thread-operation-ignore-subject)
7874 (gnus-simplify-subject-re
7875 (mail-header-subject (gnus-data-header (car data)))))
7876 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7877 (gnus-simplify-subject-fuzzy
7878 (mail-header-subject (gnus-data-header (car data)))))
7880 (end-point (save-excursion
7881 (if (gnus-summary-go-to-next-thread)
7882 (point) (point-max))))
7885 (< (gnus-data-pos (car data)) end-point))
7886 (when (or (not top-subject)
7887 (string= top-subject
7888 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7889 (gnus-simplify-subject-fuzzy
7890 (mail-header-subject
7891 (gnus-data-header (car data))))
7892 (gnus-simplify-subject-re
7893 (mail-header-subject
7894 (gnus-data-header (car data)))))))
7895 (push (gnus-data-number (car data)) articles))
7896 (unless (and (setq data (cdr data))
7897 (> (gnus-data-level (car data)) top-level))
7899 ;; Return the list of articles.
7900 (nreverse articles)))
7902 (defun gnus-summary-rethread-current ()
7903 "Rethread the thread the current article is part of."
7905 (gnus-set-global-variables)
7906 (let* ((gnus-show-threads t)
7907 (article (gnus-summary-article-number))
7908 (id (mail-header-id (gnus-summary-article-header)))
7909 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7911 (error "No article on the current line"))
7912 (gnus-rebuild-thread id)
7913 (gnus-summary-goto-subject article)))
7915 (defun gnus-summary-reparent-thread ()
7916 "Make the current article child of the marked (or previous) article.
7918 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7919 is non-nil or the Subject: of both articles are the same."
7921 (unless (not (gnus-group-read-only-p))
7922 (error "The current newsgroup does not support article editing"))
7923 (unless (<= (length gnus-newsgroup-processable) 1)
7924 (error "No more than one article may be marked"))
7925 (save-window-excursion
7926 (let ((gnus-article-buffer " *reparent*")
7927 (current-article (gnus-summary-article-number))
7928 ;; First grab the marked article, otherwise one line up.
7929 (parent-article (if (not (null gnus-newsgroup-processable))
7930 (car gnus-newsgroup-processable)
7932 (if (eq (forward-line -1) 0)
7933 (gnus-summary-article-number)
7934 (error "Beginning of summary buffer"))))))
7935 (unless (not (eq current-article parent-article))
7936 (error "An article may not be self-referential"))
7937 (let ((message-id (mail-header-id
7938 (gnus-summary-article-header parent-article))))
7939 (unless (and message-id (not (equal message-id "")))
7940 (error "No message-id in desired parent"))
7941 (gnus-summary-select-article t t nil current-article)
7942 (set-buffer gnus-original-article-buffer)
7943 (let ((buf (format "%s" (buffer-string))))
7944 (nnheader-temp-write nil
7946 (goto-char (point-min))
7947 (if (search-forward-regexp "^References: " nil t)
7948 (insert message-id " " )
7949 (insert "References: " message-id "\n"))
7950 (unless (gnus-request-replace-article
7951 current-article (car gnus-article-current)
7953 (error "Couldn't replace article"))))
7954 (set-buffer gnus-summary-buffer)
7955 (gnus-summary-unmark-all-processable)
7956 (gnus-summary-rethread-current)
7957 (gnus-message 3 "Article %d is now the child of article %d"
7958 current-article parent-article)))))
7960 (defun gnus-summary-toggle-threads (&optional arg)
7961 "Toggle showing conversation threads.
7962 If ARG is positive number, turn showing conversation threads on."
7964 (gnus-set-global-variables)
7965 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7966 (setq gnus-show-threads
7967 (if (null arg) (not gnus-show-threads)
7968 (> (prefix-numeric-value arg) 0)))
7969 (gnus-summary-prepare)
7970 (gnus-summary-goto-subject current)
7971 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7972 (gnus-summary-position-point)))
7974 (defun gnus-summary-show-all-threads ()
7977 (gnus-set-global-variables)
7979 (let ((buffer-read-only nil))
7980 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7981 (gnus-summary-position-point))
7983 (defun gnus-summary-show-thread ()
7984 "Show thread subtrees.
7985 Returns nil if no thread was there to be shown."
7987 (gnus-set-global-variables)
7988 (let ((buffer-read-only nil)
7990 ;; first goto end then to beg, to have point at beg after let
7991 (end (progn (end-of-line) (point)))
7992 (beg (progn (beginning-of-line) (point))))
7994 ;; Any hidden lines here?
7995 (search-forward "\r" end t)
7996 (subst-char-in-region beg end ?\^M ?\n t)
7998 (gnus-summary-position-point))))
8000 (defun gnus-summary-hide-all-threads ()
8001 "Hide all thread subtrees."
8003 (gnus-set-global-variables)
8005 (goto-char (point-min))
8006 (gnus-summary-hide-thread)
8007 (while (zerop (gnus-summary-next-thread 1 t))
8008 (gnus-summary-hide-thread)))
8009 (gnus-summary-position-point))
8011 (defun gnus-summary-hide-thread ()
8012 "Hide thread subtrees.
8013 Returns nil if no threads were there to be hidden."
8015 (gnus-set-global-variables)
8016 (let ((buffer-read-only nil)
8018 (article (gnus-summary-article-number)))
8020 ;; Go forward until either the buffer ends or the subthread
8022 (when (and (not (eobp))
8023 (or (zerop (gnus-summary-next-thread 1 t))
8024 (goto-char (point-max))))
8026 (if (and (> (point) start)
8027 (search-backward "\n" start t))
8029 (subst-char-in-region start (point) ?\n ?\^M)
8030 (gnus-summary-goto-subject article))
8033 ;;(gnus-summary-position-point)
8036 (defun gnus-summary-go-to-next-thread (&optional previous)
8037 "Go to the same level (or less) next thread.
8038 If PREVIOUS is non-nil, go to previous thread instead.
8039 Return the article number moved to, or nil if moving was impossible."
8040 (let ((level (gnus-summary-thread-level))
8041 (way (if previous -1 1))
8044 (while (and (not (eobp))
8045 (< level (gnus-summary-thread-level)))
8053 (gnus-summary-article-number)
8056 (defun gnus-summary-next-thread (n &optional silent)
8057 "Go to the same level next N'th thread.
8058 If N is negative, search backward instead.
8059 Returns the difference between N and the number of skips actually
8062 If SILENT, don't output messages."
8064 (gnus-set-global-variables)
8065 (let ((backward (< n 0))
8068 (gnus-summary-go-to-next-thread backward))
8071 (gnus-summary-position-point))
8072 (when (and (not silent) (/= 0 n))
8073 (gnus-message 7 "No more threads"))
8076 (defun gnus-summary-prev-thread (n)
8077 "Go to the same level previous N'th thread.
8078 Returns the difference between N and the number of skips actually
8081 (gnus-set-global-variables)
8082 (gnus-summary-next-thread (- n)))
8084 (defun gnus-summary-go-down-thread ()
8085 "Go down one level in the current thread."
8086 (let ((children (gnus-summary-article-children)))
8088 (gnus-summary-goto-subject (car children)))))
8090 (defun gnus-summary-go-up-thread ()
8091 "Go up one level in the current thread."
8092 (let ((parent (gnus-summary-article-parent)))
8094 (gnus-summary-goto-subject parent))))
8096 (defun gnus-summary-down-thread (n)
8097 "Go down thread N steps.
8098 If N is negative, go up instead.
8099 Returns the difference between N and how many steps down that were
8102 (gnus-set-global-variables)
8106 (if up (gnus-summary-go-up-thread)
8107 (gnus-summary-go-down-thread)))
8109 (gnus-summary-position-point)
8111 (gnus-message 7 "Can't go further"))
8114 (defun gnus-summary-up-thread (n)
8115 "Go up thread N steps.
8116 If N is negative, go up instead.
8117 Returns the difference between N and how many steps down that were
8120 (gnus-set-global-variables)
8121 (gnus-summary-down-thread (- n)))
8123 (defun gnus-summary-top-thread ()
8124 "Go to the top of the thread."
8126 (gnus-set-global-variables)
8127 (while (gnus-summary-go-up-thread))
8128 (gnus-summary-article-number))
8130 (defun gnus-summary-kill-thread (&optional unmark)
8131 "Mark articles under current thread as read.
8132 If the prefix argument is positive, remove any kinds of marks.
8133 If the prefix argument is negative, tick articles instead."
8135 (gnus-set-global-variables)
8137 (setq unmark (prefix-numeric-value unmark)))
8138 (let ((articles (gnus-summary-articles-in-thread)))
8140 ;; Expand the thread.
8141 (gnus-summary-show-thread)
8142 ;; Mark all the articles.
8144 (gnus-summary-goto-subject (car articles))
8145 (cond ((null unmark)
8146 (gnus-summary-mark-article-as-read gnus-killed-mark))
8148 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8150 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8151 (setq articles (cdr articles))))
8152 ;; Hide killed subtrees.
8154 gnus-thread-hide-killed
8155 (gnus-summary-hide-thread))
8156 ;; If marked as read, go to next unread subject.
8158 ;; Go to next unread subject.
8159 (gnus-summary-next-subject 1 t)))
8160 (gnus-set-mode-line 'summary))
8162 ;; Summary sorting commands
8164 (defun gnus-summary-sort-by-number (&optional reverse)
8165 "Sort the summary buffer by article number.
8166 Argument REVERSE means reverse order."
8168 (gnus-summary-sort 'number reverse))
8170 (defun gnus-summary-sort-by-author (&optional reverse)
8171 "Sort the summary buffer by author name alphabetically.
8172 If case-fold-search is non-nil, case of letters is ignored.
8173 Argument REVERSE means reverse order."
8175 (gnus-summary-sort 'author reverse))
8177 (defun gnus-summary-sort-by-subject (&optional reverse)
8178 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8179 If case-fold-search is non-nil, case of letters is ignored.
8180 Argument REVERSE means reverse order."
8182 (gnus-summary-sort 'subject reverse))
8184 (defun gnus-summary-sort-by-date (&optional reverse)
8185 "Sort the summary buffer by date.
8186 Argument REVERSE means reverse order."
8188 (gnus-summary-sort 'date reverse))
8190 (defun gnus-summary-sort-by-score (&optional reverse)
8191 "Sort the summary buffer by score.
8192 Argument REVERSE means reverse order."
8194 (gnus-summary-sort 'score reverse))
8196 (defun gnus-summary-sort-by-lines (&optional reverse)
8197 "Sort the summary buffer by article length.
8198 Argument REVERSE means reverse order."
8200 (gnus-summary-sort 'lines reverse))
8202 (defun gnus-summary-sort (predicate reverse)
8203 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8204 (gnus-set-global-variables)
8205 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8206 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8207 (gnus-thread-sort-functions
8213 (gnus-article-sort-functions
8218 (,article t2 t1)))))
8220 (gnus-summary-prepare-hook nil))
8221 ;; We do the sorting by regenerating the threads.
8222 (gnus-summary-prepare)
8223 ;; Hide subthreads if needed.
8224 (when (and gnus-show-threads gnus-thread-hide-subtree)
8225 (gnus-summary-hide-all-threads))))
8227 ;; Summary saving commands.
8229 (defun gnus-summary-save-article (&optional n not-saved)
8230 "Save the current article using the default saver function.
8231 If N is a positive number, save the N next articles.
8232 If N is a negative number, save the N previous articles.
8233 If N is nil and any articles have been marked with the process mark,
8234 save those articles instead.
8235 The variable `gnus-default-article-saver' specifies the saver function."
8237 (gnus-set-global-variables)
8238 (let* ((articles (gnus-summary-work-articles n))
8239 (save-buffer (save-excursion
8240 (nnheader-set-temp-buffer " *Gnus Save*")))
8241 (num (length articles))
8242 header article file)
8244 (setq header (gnus-summary-article-header
8245 (setq article (pop articles))))
8246 (if (not (vectorp header))
8247 ;; This is a pseudo-article.
8248 (if (assq 'name header)
8249 (gnus-copy-file (cdr (assq 'name header)))
8250 (gnus-message 1 "Article %d is unsaveable" article))
8251 ;; This is a real article.
8252 (save-window-excursion
8253 (gnus-summary-select-article t nil nil article))
8255 (set-buffer save-buffer)
8257 (insert-buffer-substring gnus-original-article-buffer))
8258 (setq file (gnus-article-save save-buffer file num))
8259 (gnus-summary-remove-process-mark article)
8261 (gnus-summary-set-saved-mark article))))
8262 (gnus-kill-buffer save-buffer)
8263 (gnus-summary-position-point)
8264 (gnus-set-mode-line 'summary)
8267 (defun gnus-summary-pipe-output (&optional arg)
8268 "Pipe the current article to a subprocess.
8269 If N is a positive number, pipe the N next articles.
8270 If N is a negative number, pipe the N previous articles.
8271 If N is nil and any articles have been marked with the process mark,
8272 pipe those articles instead."
8274 (gnus-set-global-variables)
8275 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8276 (gnus-summary-save-article arg t))
8277 (gnus-configure-windows 'pipe))
8279 (defun gnus-summary-save-article-mail (&optional arg)
8280 "Append the current article to an mail file.
8281 If N is a positive number, save the N next articles.
8282 If N is a negative number, save the N previous articles.
8283 If N is nil and any articles have been marked with the process mark,
8284 save those articles instead."
8286 (gnus-set-global-variables)
8287 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8288 (gnus-summary-save-article arg)))
8290 (defun gnus-summary-save-article-rmail (&optional arg)
8291 "Append the current article to an rmail file.
8292 If N is a positive number, save the N next articles.
8293 If N is a negative number, save the N previous articles.
8294 If N is nil and any articles have been marked with the process mark,
8295 save those articles instead."
8297 (gnus-set-global-variables)
8298 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8299 (gnus-summary-save-article arg)))
8301 (defun gnus-summary-save-article-file (&optional arg)
8302 "Append the current article to a file.
8303 If N is a positive number, save the N next articles.
8304 If N is a negative number, save the N previous articles.
8305 If N is nil and any articles have been marked with the process mark,
8306 save those articles instead."
8308 (gnus-set-global-variables)
8309 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8310 (gnus-summary-save-article arg)))
8312 (defun gnus-summary-write-article-file (&optional arg)
8313 "Write the current article to a file, deleting the previous file.
8314 If N is a positive number, save the N next articles.
8315 If N is a negative number, save the N previous articles.
8316 If N is nil and any articles have been marked with the process mark,
8317 save those articles instead."
8319 (gnus-set-global-variables)
8320 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8321 (gnus-summary-save-article arg)))
8323 (defun gnus-summary-save-article-body-file (&optional arg)
8324 "Append the current article body to a file.
8325 If N is a positive number, save the N next articles.
8326 If N is a negative number, save the N previous articles.
8327 If N is nil and any articles have been marked with the process mark,
8328 save those articles instead."
8330 (gnus-set-global-variables)
8331 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8332 (gnus-summary-save-article arg)))
8334 (defun gnus-summary-pipe-message (program)
8335 "Pipe the current article through PROGRAM."
8336 (interactive "sProgram: ")
8337 (gnus-set-global-variables)
8338 (gnus-summary-select-article)
8339 (let ((mail-header-separator "")
8340 (art-buf (get-buffer gnus-article-buffer)))
8341 (gnus-eval-in-buffer-window gnus-article-buffer
8344 (let ((start (window-start))
8346 (message-pipe-buffer-body program)
8347 (set-window-start (get-buffer-window (current-buffer)) start))))))
8349 (defun gnus-get-split-value (methods)
8350 "Return a value based on the split METHODS."
8351 (let (split-name method result match)
8354 (set-buffer gnus-original-article-buffer)
8356 (nnheader-narrow-to-headers)
8358 (goto-char (point-min))
8359 (setq method (pop methods))
8360 (setq match (car method))
8363 ;; Regular expression.
8365 (re-search-forward match nil t)))
8366 ((gnus-functionp match)
8370 (setq result (funcall match gnus-newsgroup-name))))
8375 (setq result (eval match)))))
8376 (setq split-name (append (cdr method) split-name))
8377 (cond ((stringp result)
8378 (push (expand-file-name
8379 result gnus-article-save-directory)
8382 (setq split-name (append result split-name)))))))))
8385 (defun gnus-valid-move-group-p (group)
8390 (car (gnus-find-method-for-group
8391 (symbol-name group))))
8392 gnus-valid-select-methods))))
8394 (defun gnus-read-move-group-name (prompt default articles prefix)
8395 "Read a group name."
8396 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8397 (minibuffer-confirm-incomplete nil) ; XEmacs
8401 (if (> (length articles) 1)
8402 (format "these %d articles" (length articles))
8407 (gnus-completing-read default prom
8409 'gnus-valid-move-group-p
8411 'gnus-group-history))
8412 ((= 1 (length split-name))
8413 (gnus-completing-read (car split-name) prom
8415 'gnus-valid-move-group-p
8417 'gnus-group-history))
8419 (gnus-completing-read nil prom
8420 (mapcar (lambda (el) (list el))
8421 (nreverse split-name))
8423 'gnus-group-history)))))
8425 (if (or (string= to-newsgroup "")
8426 (string= to-newsgroup prefix))
8427 (setq to-newsgroup default))
8428 (unless to-newsgroup
8429 (error "No group name entered"))
8430 (or (gnus-active to-newsgroup)
8431 (gnus-activate-group to-newsgroup)
8432 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8434 (or (and (gnus-request-create-group
8435 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8436 (gnus-activate-group to-newsgroup nil nil
8437 (gnus-group-name-to-method
8439 (error "Couldn't create group %s" to-newsgroup)))
8440 (error "No such group: %s" to-newsgroup)))
8443 ;; Summary extract commands
8445 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8446 (let ((buffer-read-only nil)
8447 (article (gnus-summary-article-number))
8449 (unless (gnus-summary-goto-subject article)
8450 (error "No such article: %d" article))
8451 (gnus-summary-position-point)
8452 ;; If all commands are to be bunched up on one line, we collect
8454 (unless gnus-view-pseudos-separately
8455 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8458 (setq action (cdr (assq 'action (car ps))))
8459 (setq files (list (cdr (assq 'name (car ps)))))
8460 (while (and ps (cdr ps)
8461 (string= (or action "1")
8462 (or (cdr (assq 'action (cadr ps))) "2")))
8463 (push (cdr (assq 'name (cadr ps))) files)
8464 (setcdr ps (cddr ps)))
8466 (when (not (string-match "%s" action))
8469 (when (assq 'execute (car ps))
8470 (setcdr (assq 'execute (car ps))
8471 (funcall (if (string-match "%s" action)
8478 (gnus-quote-arg-for-sh-or-csh f)))
8480 (setq ps (cdr ps)))))
8481 (if (and gnus-view-pseudos (not not-view))
8483 (when (assq 'execute (car pslist))
8484 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8485 (eq gnus-view-pseudos 'not-confirm)))
8486 (setq pslist (cdr pslist)))
8489 (setq after-article (or (cdr (assq 'article (car pslist)))
8490 (gnus-summary-article-number)))
8491 (gnus-summary-goto-subject after-article)
8494 (insert " " (file-name-nondirectory
8495 (cdr (assq 'name (car pslist))))
8496 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8498 (forward-line -1) ; back to `b'
8499 (gnus-add-text-properties
8500 b (1- e) (list 'gnus-number gnus-reffed-article-number
8501 gnus-mouse-face-prop gnus-mouse-face))
8503 after-article gnus-reffed-article-number
8504 gnus-unread-mark b (car pslist) 0 (- e b))
8505 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8506 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8507 (setq pslist (cdr pslist)))))))
8509 (defun gnus-pseudos< (p1 p2)
8510 (let ((c1 (cdr (assq 'action p1)))
8511 (c2 (cdr (assq 'action p2))))
8512 (and c1 c2 (string< c1 c2))))
8514 (defun gnus-request-pseudo-article (props)
8515 (cond ((assq 'execute props)
8516 (gnus-execute-command (cdr (assq 'execute props)))))
8517 (let ((gnus-current-article (gnus-summary-article-number)))
8518 (run-hooks 'gnus-mark-article-hook)))
8520 (defun gnus-execute-command (command &optional automatic)
8522 (gnus-article-setup-buffer)
8523 (set-buffer gnus-article-buffer)
8524 (setq buffer-read-only nil)
8525 (let ((command (if automatic command
8526 (read-string "Command: " (cons command 0)))))
8528 (insert "$ " command "\n\n")
8529 (if gnus-view-pseudo-asynchronously
8530 (start-process "gnus-execute" (current-buffer) shell-file-name
8531 shell-command-switch command)
8532 (call-process shell-file-name nil t nil
8533 shell-command-switch command)))))
8535 ;; Summary kill commands.
8537 (defun gnus-summary-edit-global-kill (article)
8538 "Edit the \"global\" kill file."
8539 (interactive (list (gnus-summary-article-number)))
8540 (gnus-set-global-variables)
8541 (gnus-group-edit-global-kill article))
8543 (defun gnus-summary-edit-local-kill ()
8544 "Edit a local kill file applied to the current newsgroup."
8546 (gnus-set-global-variables)
8547 (setq gnus-current-headers (gnus-summary-article-header))
8548 (gnus-set-global-variables)
8549 (gnus-group-edit-local-kill
8550 (gnus-summary-article-number) gnus-newsgroup-name))
8554 (defun gnus-read-header (id &optional header)
8555 "Read the headers of article ID and enter them into the Gnus system."
8556 (let ((group gnus-newsgroup-name)
8557 (gnus-override-method
8558 (and (gnus-news-group-p gnus-newsgroup-name)
8559 gnus-refer-article-method))
8561 ;; First we check to see whether the header in question is already
8564 ;; This is a Message-ID.
8565 (setq header (or header (gnus-id-to-header id)))
8566 ;; This is an article number.
8567 (setq header (or header (gnus-summary-article-header id))))
8569 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8570 ;; We have found the header.
8572 ;; We have to really fetch the header to this article.
8574 (set-buffer nntp-server-buffer)
8575 (when (setq where (gnus-request-head id group))
8576 (nnheader-fold-continuation-lines)
8577 (goto-char (point-max))
8579 (goto-char (point-min))
8583 ((cdr where) (cdr where))
8584 (header (mail-header-number header))
8585 (t gnus-reffed-article-number))
8587 (insert " Article retrieved.\n"))
8589 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8590 () ; Malformed head.
8591 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8592 (when (and (stringp id)
8593 (not (string= (gnus-group-real-name group)
8595 ;; If we fetched by Message-ID and the article came
8596 ;; from a different group, we fudge some bogus article
8597 ;; numbers for this article.
8598 (mail-header-set-number header gnus-reffed-article-number))
8600 (set-buffer gnus-summary-buffer)
8601 (decf gnus-reffed-article-number)
8602 (gnus-remove-header (mail-header-number header))
8603 (push header gnus-newsgroup-headers)
8604 (setq gnus-current-headers header)
8605 (push (mail-header-number header) gnus-newsgroup-limit)))
8608 (defun gnus-remove-header (number)
8609 "Remove header NUMBER from `gnus-newsgroup-headers'."
8610 (if (and gnus-newsgroup-headers
8611 (= number (mail-header-number (car gnus-newsgroup-headers))))
8612 (pop gnus-newsgroup-headers)
8613 (let ((headers gnus-newsgroup-headers))
8614 (while (and (cdr headers)
8615 (not (= number (mail-header-number (cadr headers)))))
8618 (setcdr headers (cddr headers))))))
8621 ;;; summary highlights
8624 (defun gnus-highlight-selected-summary ()
8625 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8626 ;; Highlight selected article in summary buffer
8627 (when gnus-summary-selected-face
8629 (let* ((beg (progn (beginning-of-line) (point)))
8630 (end (progn (end-of-line) (point)))
8631 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8632 (from (if (get-text-property beg gnus-mouse-face-prop)
8634 (or (next-single-property-change
8635 beg gnus-mouse-face-prop nil end)
8640 (or (next-single-property-change
8641 from gnus-mouse-face-prop nil end)
8643 ;; If no mouse-face prop on line we will have to = from = end,
8644 ;; so we highlight the entire line instead.
8645 (when (= (+ to 2) from)
8648 (if gnus-newsgroup-selected-overlay
8649 ;; Move old overlay.
8651 gnus-newsgroup-selected-overlay from to (current-buffer))
8652 ;; Create new overlay.
8654 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8655 'face gnus-summary-selected-face))))))
8657 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8658 (defun gnus-summary-highlight-line ()
8659 "Highlight current line according to `gnus-summary-highlight'."
8660 (let* ((list gnus-summary-highlight)
8662 (end (progn (end-of-line) (point)))
8663 ;; now find out where the line starts and leave point there.
8664 (beg (progn (beginning-of-line) (point)))
8665 (article (gnus-summary-article-number))
8666 (score (or (cdr (assq (or article gnus-current-article)
8667 gnus-newsgroup-scored))
8668 gnus-summary-default-score 0))
8669 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8670 (inhibit-read-only t))
8671 ;; Eval the cars of the lists until we find a match.
8672 (let ((default gnus-summary-default-score))
8674 (not (eval (caar list))))
8675 (setq list (cdr list))))
8676 (let ((face (cdar list)))
8677 (unless (eq face (get-text-property beg 'face))
8678 (gnus-put-text-property
8680 (setq face (if (boundp face) (symbol-value face) face)))
8681 (when gnus-summary-highlight-line-function
8682 (funcall gnus-summary-highlight-line-function article face))))
8685 (defun gnus-update-read-articles (group unread)
8686 "Update the list of read articles in GROUP."
8687 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8688 (entry (gnus-gethash group gnus-newsrc-hashtb))
8689 (info (nth 2 entry))
8691 (unread (sort (copy-sequence unread) '<))
8693 (if (or (not info) (not active))
8694 ;; There is no info on this group if it was, in fact,
8695 ;; killed. Gnus stores no information on killed groups, so
8696 ;; there's nothing to be done.
8697 ;; One could store the information somewhere temporarily,
8698 ;; perhaps... Hmmm...
8700 ;; Remove any negative articles numbers.
8701 (while (and unread (< (car unread) 0))
8702 (setq unread (cdr unread)))
8703 ;; Remove any expired article numbers
8704 (while (and unread (< (car unread) (car active)))
8705 (setq unread (cdr unread)))
8706 ;; Compute the ranges of read articles by looking at the list of
8709 (when (/= (car unread) prev)
8710 (push (if (= prev (1- (car unread))) prev
8711 (cons prev (1- (car unread))))
8713 (setq prev (1+ (car unread)))
8714 (setq unread (cdr unread)))
8715 (when (<= prev (cdr active))
8716 (push (cons prev (cdr active)) read))
8718 (set-buffer gnus-group-buffer)
8721 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8722 (gnus-info-set-read ',info ',(gnus-info-read info))
8723 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8724 (gnus-group-update-group ,group t))))
8725 ;; Enter this list into the group info.
8727 info (if (> (length read) 1) (nreverse read) read))
8728 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8729 (gnus-get-unread-articles-in-group info (gnus-active group))
8732 (defun gnus-offer-save-summaries ()
8733 "Offer to save all active summary buffers."
8735 (let ((buflist (buffer-list))
8737 ;; Go through all buffers and find all summaries.
8739 (and (setq bufname (buffer-name (car buflist)))
8740 (string-match "Summary" bufname)
8742 (set-buffer bufname)
8743 ;; We check that this is, indeed, a summary buffer.
8744 (and (eq major-mode 'gnus-summary-mode)
8745 ;; Also make sure this isn't bogus.
8746 gnus-newsgroup-prepared
8747 ;; Also make sure that this isn't a dead summary buffer.
8748 (not gnus-dead-summary-mode)))
8749 (push bufname buffers))
8750 (setq buflist (cdr buflist)))
8751 ;; Go through all these summary buffers and offer to save them.
8754 "Update summary buffer %s? "
8755 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8762 (run-hooks 'gnus-sum-load-hook)
8764 ;;; gnus-sum.el ends here