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-unsendable-mark ?=
427 "*Mark used for articles that won't be sent."
428 :group 'gnus-summary-marks
431 (defcustom gnus-score-over-mark ?+
432 "*Score mark used for articles with high scores."
433 :group 'gnus-summary-marks
436 (defcustom gnus-score-below-mark ?-
437 "*Score mark used for articles with low scores."
438 :group 'gnus-summary-marks
441 (defcustom gnus-empty-thread-mark ?
442 "*There is no thread under the article."
443 :group 'gnus-summary-marks
446 (defcustom gnus-not-empty-thread-mark ?=
447 "*There is a thread under the article."
448 :group 'gnus-summary-marks
451 (defcustom gnus-view-pseudo-asynchronously nil
452 "*If non-nil, Gnus will view pseudo-articles asynchronously."
453 :group 'gnus-extract-view
456 (defcustom gnus-view-pseudos nil
457 "*If `automatic', pseudo-articles will be viewed automatically.
458 If `not-confirm', pseudos will be viewed automatically, and the user
459 will not be asked to confirm the command."
460 :group 'gnus-extract-view
461 :type '(choice (const :tag "off" nil)
463 (const not-confirm)))
465 (defcustom gnus-view-pseudos-separately t
466 "*If non-nil, one pseudo-article will be created for each file to be viewed.
467 If nil, all files that use the same viewing command will be given as a
468 list of parameters to that command."
469 :group 'gnus-extract-view
472 (defcustom gnus-insert-pseudo-articles t
473 "*If non-nil, insert pseudo-articles when decoding articles."
474 :group 'gnus-extract-view
477 (defcustom gnus-summary-dummy-line-format
479 "*The format specification for the dummy roots in the summary buffer.
480 It works along the same lines as a normal formatting string,
481 with some simple extensions.
484 :group 'gnus-threading
487 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
488 "*The format specification for the summary mode line.
489 It works along the same lines as a normal formatting string,
490 with some simple extensions:
493 %p Unprefixed group name
494 %A Current article number
496 %U Number of unread articles in the group
497 %e Number of unselected articles in the group
498 %Z A string with unread/unselected article counts
499 %g Shortish group name
500 %S Subject of the current article
502 %s Current score file name
503 %d Number of dormant articles
504 %r Number of articles that have been marked as read in this session
505 %E Number of articles expunged by the score files"
506 :group 'gnus-summary-format
509 (defcustom gnus-summary-mark-below 0
510 "*Mark all articles with a score below this variable as read.
511 This variable is local to each summary buffer and usually set by the
513 :group 'gnus-score-default
516 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
517 "*List of functions used for sorting articles in the summary buffer.
518 This variable is only used when not using a threaded display."
519 :group 'gnus-summary-sort
520 :type '(repeat (choice (function-item gnus-article-sort-by-number)
521 (function-item gnus-article-sort-by-author)
522 (function-item gnus-article-sort-by-subject)
523 (function-item gnus-article-sort-by-date)
524 (function-item gnus-article-sort-by-score)
525 (function :tag "other"))))
527 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
528 "*List of functions used for sorting threads in the summary buffer.
529 By default, threads are sorted by article number.
531 Each function takes two threads and return non-nil if the first thread
532 should be sorted before the other. If you use more than one function,
533 the primary sort function should be the last. You should probably
534 always include `gnus-thread-sort-by-number' in the list of sorting
535 functions -- preferably first.
537 Ready-made functions include `gnus-thread-sort-by-number',
538 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
539 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
540 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
541 :group 'gnus-summary-sort
542 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
543 (function-item gnus-thread-sort-by-author)
544 (function-item gnus-thread-sort-by-subject)
545 (function-item gnus-thread-sort-by-date)
546 (function-item gnus-thread-sort-by-score)
547 (function-item gnus-thread-sort-by-total-score)
548 (function :tag "other"))))
550 (defcustom gnus-thread-score-function '+
551 "*Function used for calculating the total score of a thread.
553 The function is called with the scores of the article and each
554 subthread and should then return the score of the thread.
556 Some functions you can use are `+', `max', or `min'."
557 :group 'gnus-summary-sort
560 (defcustom gnus-summary-expunge-below nil
561 "All articles that have a score less than this variable will be expunged."
562 :group 'gnus-score-default
563 :type '(choice (const :tag "off" nil)
566 (defcustom gnus-thread-expunge-below nil
567 "All threads that have a total score less than this variable will be expunged.
568 See `gnus-thread-score-function' for en explanation of what a
569 \"thread score\" is."
570 :group 'gnus-treading
571 :group 'gnus-score-default
572 :type '(choice (const :tag "off" nil)
575 (defcustom gnus-summary-mode-hook nil
576 "*A hook for Gnus summary mode.
577 This hook is run before any variables are set in the summary buffer."
578 :group 'gnus-summary-various
581 (defcustom gnus-summary-menu-hook nil
582 "*Hook run after the creation of the summary mode menu."
583 :group 'gnus-summary-visual
586 (defcustom gnus-summary-exit-hook nil
587 "*A hook called on exit from the summary buffer.
588 It will be called with point in the group buffer."
589 :group 'gnus-summary-exit
592 (defcustom gnus-summary-prepare-hook nil
593 "*A hook called after the summary buffer has been generated.
594 If you want to modify the summary buffer, you can use this hook."
595 :group 'gnus-summary-various
598 (defcustom gnus-summary-generate-hook nil
599 "*A hook run just before generating the summary buffer.
600 This hook is commonly used to customize threading variables and the
602 :group 'gnus-summary-various
605 (defcustom gnus-select-group-hook nil
606 "*A hook called when a newsgroup is selected.
608 If you'd like to simplify subjects like the
609 `gnus-summary-next-same-subject' command does, you can use the
612 (setq gnus-select-group-hook
615 (mapcar (lambda (header)
616 (mail-header-set-subject
618 (gnus-simplify-subject
619 (mail-header-subject header) 're-only)))
620 gnus-newsgroup-headers))))"
621 :group 'gnus-group-select
624 (defcustom gnus-select-article-hook nil
625 "*A hook called when an article is selected."
626 :group 'gnus-summary-choose
629 (defcustom gnus-visual-mark-article-hook
630 (list 'gnus-highlight-selected-summary)
631 "*Hook run after selecting an article in the summary buffer.
632 It is meant to be used for highlighting the article in some way. It
633 is not run if `gnus-visual' is nil."
634 :group 'gnus-summary-visual
637 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
638 (defcustom gnus-structured-field-decoder 'identity
639 "Function to decode non-ASCII characters in structured field for summary."
643 (defcustom gnus-unstructured-field-decoder 'identity
644 "Function to decode non-ASCII characters in unstructured field for summary."
648 (defcustom gnus-parse-headers-hook
649 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
650 "*A hook called before parsing the headers."
654 (defcustom gnus-exit-group-hook nil
655 "*A hook called when exiting (not quitting) summary mode."
659 (defcustom gnus-summary-update-hook
660 (list 'gnus-summary-highlight-line)
661 "*A hook called when a summary line is changed.
662 The hook will not be called if `gnus-visual' is nil.
664 The default function `gnus-summary-highlight-line' will
665 highlight the line according to the `gnus-summary-highlight'
667 :group 'gnus-summary-visual
670 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
671 "*A hook called when an article is selected for the first time.
672 The hook is intended to mark an article as read (or unread)
673 automatically when it is selected."
674 :group 'gnus-summary-choose
677 (defcustom gnus-group-no-more-groups-hook nil
678 "*A hook run when returning to group mode having no more (unread) groups."
679 :group 'gnus-group-select
682 (defcustom gnus-ps-print-hook nil
683 "*A hook run before ps-printing something from Gnus."
687 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
688 "Face used for highlighting the current article in the summary buffer."
689 :group 'gnus-summary-visual
692 (defcustom gnus-summary-highlight
693 '(((= mark gnus-canceled-mark)
694 . gnus-summary-cancelled-face)
695 ((and (> score default)
696 (or (= mark gnus-dormant-mark)
697 (= mark gnus-ticked-mark)))
698 . gnus-summary-high-ticked-face)
699 ((and (< score default)
700 (or (= mark gnus-dormant-mark)
701 (= mark gnus-ticked-mark)))
702 . gnus-summary-low-ticked-face)
703 ((or (= mark gnus-dormant-mark)
704 (= mark gnus-ticked-mark))
705 . gnus-summary-normal-ticked-face)
706 ((and (> score default) (= mark gnus-ancient-mark))
707 . gnus-summary-high-ancient-face)
708 ((and (< score default) (= mark gnus-ancient-mark))
709 . gnus-summary-low-ancient-face)
710 ((= mark gnus-ancient-mark)
711 . gnus-summary-normal-ancient-face)
712 ((and (> score default) (= mark gnus-unread-mark))
713 . gnus-summary-high-unread-face)
714 ((and (< score default) (= mark gnus-unread-mark))
715 . gnus-summary-low-unread-face)
716 ((and (= mark gnus-unread-mark))
717 . gnus-summary-normal-unread-face)
719 . gnus-summary-high-read-face)
721 . gnus-summary-low-read-face)
723 . gnus-summary-normal-read-face))
724 "Controls the highlighting of summary buffer lines.
726 A list of (FORM . FACE) pairs. When deciding how a a particular
727 summary line should be displayed, each form is evaluated. The content
728 of the face field after the first true form is used. You can change
729 how those summary lines are displayed, by editing the face field.
731 You can use the following variables in the FORM field.
733 score: The articles score
734 default: The default article score.
735 below: The score below which articles are automatically marked as read.
736 mark: The articles mark."
737 :group 'gnus-summary-visual
738 :type '(repeat (cons (sexp :tag "Form" nil)
742 ;;; Internal variables
744 (defvar gnus-scores-exclude-files nil)
745 (defvar gnus-page-broken nil)
747 (defvar gnus-original-article nil)
748 (defvar gnus-article-internal-prepare-hook nil)
749 (defvar gnus-newsgroup-process-stack nil)
751 (defvar gnus-thread-indent-array nil)
752 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
754 ;; Avoid highlighting in kill files.
755 (defvar gnus-summary-inhibit-highlight nil)
756 (defvar gnus-newsgroup-selected-overlay nil)
757 (defvar gnus-inhibit-limiting nil)
758 (defvar gnus-newsgroup-adaptive-score-file nil)
759 (defvar gnus-current-score-file nil)
760 (defvar gnus-current-move-group nil)
761 (defvar gnus-current-copy-group nil)
762 (defvar gnus-current-crosspost-group nil)
764 (defvar gnus-newsgroup-dependencies nil)
765 (defvar gnus-newsgroup-adaptive nil)
766 (defvar gnus-summary-display-article-function nil)
767 (defvar gnus-summary-highlight-line-function nil
768 "Function called after highlighting a summary line.")
770 (defvar gnus-summary-line-format-alist
771 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
772 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
773 (?s gnus-tmp-subject-or-nil ?s)
774 (?n gnus-tmp-name ?s)
775 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
777 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
779 (?F gnus-tmp-from ?s)
780 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
781 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
782 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
783 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
784 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
785 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
786 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
787 (?L gnus-tmp-lines ?d)
788 (?I gnus-tmp-indentation ?s)
789 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
790 (?R gnus-tmp-replied ?c)
791 (?\[ gnus-tmp-opening-bracket ?c)
792 (?\] gnus-tmp-closing-bracket ?c)
793 (?\> (make-string gnus-tmp-level ? ) ?s)
794 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
795 (?i gnus-tmp-score ?d)
796 (?z gnus-tmp-score-char ?c)
797 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
798 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
799 (?U gnus-tmp-unread ?c)
800 (?t (gnus-summary-number-of-articles-in-thread
801 (and (boundp 'thread) (car thread)) gnus-tmp-level)
803 (?e (gnus-summary-number-of-articles-in-thread
804 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
806 (?u gnus-tmp-user-defined ?s)
807 (?P (gnus-pick-line-number) ?d))
808 "An alist of format specifications that can appear in summary lines,
809 and what variables they correspond with, along with the type of the
810 variable (string, integer, character, etc).")
812 (defvar gnus-summary-dummy-line-format-alist
813 `((?S gnus-tmp-subject ?s)
814 (?N gnus-tmp-number ?d)
815 (?u gnus-tmp-user-defined ?s)))
817 (defvar gnus-summary-mode-line-format-alist
818 `((?G gnus-tmp-group-name ?s)
819 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
820 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
821 (?A gnus-tmp-article-number ?d)
822 (?Z gnus-tmp-unread-and-unselected ?s)
824 (?U gnus-tmp-unread-and-unticked ?d)
825 (?S gnus-tmp-subject ?s)
826 (?e gnus-tmp-unselected ?d)
827 (?u gnus-tmp-user-defined ?s)
828 (?d (length gnus-newsgroup-dormant) ?d)
829 (?t (length gnus-newsgroup-marked) ?d)
830 (?r (length gnus-newsgroup-reads) ?d)
831 (?E gnus-newsgroup-expunged-tally ?d)
832 (?s (gnus-current-score-file-nondirectory) ?s)))
834 (defvar gnus-last-search-regexp nil
835 "Default regexp for article search command.")
837 (defvar gnus-last-shell-command nil
838 "Default shell command on article.")
840 (defvar gnus-newsgroup-begin nil)
841 (defvar gnus-newsgroup-end nil)
842 (defvar gnus-newsgroup-last-rmail nil)
843 (defvar gnus-newsgroup-last-mail nil)
844 (defvar gnus-newsgroup-last-folder nil)
845 (defvar gnus-newsgroup-last-file nil)
846 (defvar gnus-newsgroup-auto-expire nil)
847 (defvar gnus-newsgroup-active nil)
849 (defvar gnus-newsgroup-data nil)
850 (defvar gnus-newsgroup-data-reverse nil)
851 (defvar gnus-newsgroup-limit nil)
852 (defvar gnus-newsgroup-limits nil)
854 (defvar gnus-newsgroup-unreads nil
855 "List of unread articles in the current newsgroup.")
857 (defvar gnus-newsgroup-unselected nil
858 "List of unselected unread articles in the current newsgroup.")
860 (defvar gnus-newsgroup-reads nil
861 "Alist of read articles and article marks in the current newsgroup.")
863 (defvar gnus-newsgroup-expunged-tally nil)
865 (defvar gnus-newsgroup-marked nil
866 "List of ticked articles in the current newsgroup (a subset of unread art).")
868 (defvar gnus-newsgroup-killed nil
869 "List of ranges of articles that have been through the scoring process.")
871 (defvar gnus-newsgroup-cached nil
872 "List of articles that come from the article cache.")
874 (defvar gnus-newsgroup-saved nil
875 "List of articles that have been saved.")
877 (defvar gnus-newsgroup-kill-headers nil)
879 (defvar gnus-newsgroup-replied nil
880 "List of articles that have been replied to in the current newsgroup.")
882 (defvar gnus-newsgroup-expirable nil
883 "List of articles in the current newsgroup that can be expired.")
885 (defvar gnus-newsgroup-processable nil
886 "List of articles in the current newsgroup that can be processed.")
888 (defvar gnus-newsgroup-downloadable nil
889 "List of articles in the current newsgroup that can be processed.")
891 (defvar gnus-newsgroup-undownloaded nil
892 "List of articles in the current newsgroup that haven't been downloaded..")
894 (defvar gnus-newsgroup-unsendable nil
895 "List of articles in the current newsgroup that won't be sent.")
897 (defvar gnus-newsgroup-bookmarks nil
898 "List of articles in the current newsgroup that have bookmarks.")
900 (defvar gnus-newsgroup-dormant nil
901 "List of dormant articles in the current newsgroup.")
903 (defvar gnus-newsgroup-scored nil
904 "List of scored articles in the current newsgroup.")
906 (defvar gnus-newsgroup-headers nil
907 "List of article headers in the current newsgroup.")
909 (defvar gnus-newsgroup-threads nil)
911 (defvar gnus-newsgroup-prepared nil
912 "Whether the current group has been prepared properly.")
914 (defvar gnus-newsgroup-ancient nil
915 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
917 (defvar gnus-newsgroup-sparse nil)
919 (defvar gnus-current-article nil)
920 (defvar gnus-article-current nil)
921 (defvar gnus-current-headers nil)
922 (defvar gnus-have-all-headers nil)
923 (defvar gnus-last-article nil)
924 (defvar gnus-newsgroup-history nil)
926 (defconst gnus-summary-local-variables
927 '(gnus-newsgroup-name
928 gnus-newsgroup-begin gnus-newsgroup-end
929 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
930 gnus-newsgroup-last-folder gnus-newsgroup-last-file
931 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
932 gnus-newsgroup-unselected gnus-newsgroup-marked
933 gnus-newsgroup-reads gnus-newsgroup-saved
934 gnus-newsgroup-replied gnus-newsgroup-expirable
935 gnus-newsgroup-processable gnus-newsgroup-killed
936 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
937 gnus-newsgroup-unsendable
938 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
939 gnus-newsgroup-headers gnus-newsgroup-threads
940 gnus-newsgroup-prepared gnus-summary-highlight-line-function
941 gnus-current-article gnus-current-headers gnus-have-all-headers
942 gnus-last-article gnus-article-internal-prepare-hook
943 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
944 gnus-newsgroup-scored gnus-newsgroup-kill-headers
945 gnus-thread-expunge-below
946 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
947 (gnus-summary-mark-below . global)
948 gnus-newsgroup-active gnus-scores-exclude-files
949 gnus-newsgroup-history gnus-newsgroup-ancient
950 gnus-newsgroup-sparse gnus-newsgroup-process-stack
951 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
952 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
953 (gnus-newsgroup-expunged-tally . 0)
954 gnus-cache-removable-articles gnus-newsgroup-cached
955 gnus-newsgroup-data gnus-newsgroup-data-reverse
956 gnus-newsgroup-limit gnus-newsgroup-limits)
957 "Variables that are buffer-local to the summary buffers.")
959 ;; Byte-compiler warning.
960 (defvar gnus-article-mode-map)
962 ;; Subject simplification.
964 (defsubst gnus-simplify-subject-re (subject)
965 "Remove \"Re:\" from subject lines."
966 (if (string-match "^[Rr][Ee]: *" subject)
967 (substring subject (match-end 0))
970 (defun gnus-simplify-subject (subject &optional re-only)
971 "Remove `Re:' and words in parentheses.
972 If RE-ONLY is non-nil, strip leading `Re:'s only."
973 (let ((case-fold-search t)) ;Ignore case.
974 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
975 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
976 (setq subject (substring subject (match-end 0))))
977 ;; Remove uninteresting prefixes.
978 (when (and (not re-only)
979 gnus-simplify-ignored-prefixes
980 (string-match gnus-simplify-ignored-prefixes subject))
981 (setq subject (substring subject (match-end 0))))
982 ;; Remove words in parentheses from end.
984 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
985 (setq subject (substring subject 0 (match-beginning 0)))))
986 ;; Return subject string.
989 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
991 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
992 (goto-char (point-min))
993 (while (re-search-forward regexp nil t)
994 (replace-match (or newtext ""))))
996 (defun gnus-simplify-buffer-fuzzy ()
997 "Simplify string in the buffer fuzzily.
998 The string in the accessible portion of the current buffer is simplified.
999 It is assumed to be a single-line subject.
1000 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1001 matter is removed. Additional things can be deleted by setting
1002 gnus-simplify-subject-fuzzy-regexp."
1003 (let ((case-fold-search t)
1005 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1007 (while (not (eq modified-tick (buffer-modified-tick)))
1008 (setq modified-tick (buffer-modified-tick))
1010 ((listp gnus-simplify-subject-fuzzy-regexp)
1011 (mapcar 'gnus-simplify-buffer-fuzzy-step
1012 gnus-simplify-subject-fuzzy-regexp))
1013 (gnus-simplify-subject-fuzzy-regexp
1014 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1015 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1016 (gnus-simplify-buffer-fuzzy-step
1017 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1018 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1020 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1021 (gnus-simplify-buffer-fuzzy-step " +" " ")
1022 (gnus-simplify-buffer-fuzzy-step " $")
1023 (gnus-simplify-buffer-fuzzy-step "^ +")))
1025 (defun gnus-simplify-subject-fuzzy (subject)
1026 "Simplify a subject string fuzzily.
1027 See gnus-simplify-buffer-fuzzy for details."
1029 (gnus-set-work-buffer)
1030 (let ((case-fold-search t))
1032 (inline (gnus-simplify-buffer-fuzzy))
1035 (defsubst gnus-simplify-subject-fully (subject)
1036 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1038 ((null gnus-summary-gather-subject-limit)
1039 (gnus-simplify-subject-re subject))
1040 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1041 (gnus-simplify-subject-fuzzy subject))
1042 ((numberp gnus-summary-gather-subject-limit)
1043 (gnus-limit-string (gnus-simplify-subject-re subject)
1044 gnus-summary-gather-subject-limit))
1048 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1049 "Check whether two subjects are equal. If optional argument
1050 simple-first is t, first argument is already simplified."
1052 ((null simple-first)
1053 (equal (gnus-simplify-subject-fully s1)
1054 (gnus-simplify-subject-fully s2)))
1057 (gnus-simplify-subject-fully s2)))))
1059 (defun gnus-summary-bubble-group ()
1060 "Increase the score of the current group.
1061 This is a handy function to add to `gnus-summary-exit-hook' to
1062 increase the score of each group you read."
1063 (gnus-group-add-score gnus-newsgroup-name))
1067 ;;; Gnus summary mode
1070 (put 'gnus-summary-mode 'mode-class 'special)
1073 ;; Non-orthogonal keys
1075 (gnus-define-keys gnus-summary-mode-map
1076 " " gnus-summary-next-page
1077 "\177" gnus-summary-prev-page
1078 [delete] gnus-summary-prev-page
1079 "\r" gnus-summary-scroll-up
1080 "n" gnus-summary-next-unread-article
1081 "p" gnus-summary-prev-unread-article
1082 "N" gnus-summary-next-article
1083 "P" gnus-summary-prev-article
1084 "\M-\C-n" gnus-summary-next-same-subject
1085 "\M-\C-p" gnus-summary-prev-same-subject
1086 "\M-n" gnus-summary-next-unread-subject
1087 "\M-p" gnus-summary-prev-unread-subject
1088 "." gnus-summary-first-unread-article
1089 "," gnus-summary-best-unread-article
1090 "\M-s" gnus-summary-search-article-forward
1091 "\M-r" gnus-summary-search-article-backward
1092 "<" gnus-summary-beginning-of-article
1093 ">" gnus-summary-end-of-article
1094 "j" gnus-summary-goto-article
1095 "^" gnus-summary-refer-parent-article
1096 "\M-^" gnus-summary-refer-article
1097 "u" gnus-summary-tick-article-forward
1098 "!" gnus-summary-tick-article-forward
1099 "U" gnus-summary-tick-article-backward
1100 "d" gnus-summary-mark-as-read-forward
1101 "D" gnus-summary-mark-as-read-backward
1102 "E" gnus-summary-mark-as-expirable
1103 "\M-u" gnus-summary-clear-mark-forward
1104 "\M-U" gnus-summary-clear-mark-backward
1105 "k" gnus-summary-kill-same-subject-and-select
1106 "\C-k" gnus-summary-kill-same-subject
1107 "\M-\C-k" gnus-summary-kill-thread
1108 "\M-\C-l" gnus-summary-lower-thread
1109 "e" gnus-summary-edit-article
1110 "#" gnus-summary-mark-as-processable
1111 "\M-#" gnus-summary-unmark-as-processable
1112 "\M-\C-t" gnus-summary-toggle-threads
1113 "\M-\C-s" gnus-summary-show-thread
1114 "\M-\C-h" gnus-summary-hide-thread
1115 "\M-\C-f" gnus-summary-next-thread
1116 "\M-\C-b" gnus-summary-prev-thread
1117 "\M-\C-u" gnus-summary-up-thread
1118 "\M-\C-d" gnus-summary-down-thread
1119 "&" gnus-summary-execute-command
1120 "c" gnus-summary-catchup-and-exit
1121 "\C-w" gnus-summary-mark-region-as-read
1122 "\C-t" gnus-summary-toggle-truncation
1123 "?" gnus-summary-mark-as-dormant
1124 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1125 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1126 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1127 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1128 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1129 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1130 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1131 "=" gnus-summary-expand-window
1132 "\C-x\C-s" gnus-summary-reselect-current-group
1133 "\M-g" gnus-summary-rescan-group
1134 "w" gnus-summary-stop-page-breaking
1135 "\C-c\C-r" gnus-summary-caesar-message
1136 "\M-t" gnus-summary-toggle-mime
1137 "f" gnus-summary-followup
1138 "F" gnus-summary-followup-with-original
1139 "C" gnus-summary-cancel-article
1140 "r" gnus-summary-reply
1141 "R" gnus-summary-reply-with-original
1142 "\C-c\C-f" gnus-summary-mail-forward
1143 "o" gnus-summary-save-article
1144 "\C-o" gnus-summary-save-article-mail
1145 "|" gnus-summary-pipe-output
1146 "\M-k" gnus-summary-edit-local-kill
1147 "\M-K" gnus-summary-edit-global-kill
1149 "\C-c\C-d" gnus-summary-describe-group
1150 "q" gnus-summary-exit
1151 "Q" gnus-summary-exit-no-update
1152 "\C-c\C-i" gnus-info-find-node
1153 gnus-mouse-2 gnus-mouse-pick-article
1154 "m" gnus-summary-mail-other-window
1155 "a" gnus-summary-post-news
1156 "x" gnus-summary-limit-to-unread
1157 "s" gnus-summary-isearch-article
1158 "t" gnus-article-hide-headers
1159 "g" gnus-summary-show-article
1160 "l" gnus-summary-goto-last-article
1161 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1162 "\C-d" gnus-summary-enter-digest-group
1163 "\M-\C-d" gnus-summary-read-document
1165 "*" gnus-cache-enter-article
1166 "\M-*" gnus-cache-remove-article
1167 "\M-&" gnus-summary-universal-argument
1168 "\C-l" gnus-recenter
1169 "I" gnus-summary-increase-score
1170 "L" gnus-summary-lower-score
1172 "V" gnus-summary-score-map
1173 "X" gnus-uu-extract-map
1174 "S" gnus-summary-send-map)
1176 ;; Sort of orthogonal keymap
1177 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1178 "t" gnus-summary-tick-article-forward
1179 "!" gnus-summary-tick-article-forward
1180 "d" gnus-summary-mark-as-read-forward
1181 "r" gnus-summary-mark-as-read-forward
1182 "c" gnus-summary-clear-mark-forward
1183 " " gnus-summary-clear-mark-forward
1184 "e" gnus-summary-mark-as-expirable
1185 "x" gnus-summary-mark-as-expirable
1186 "?" gnus-summary-mark-as-dormant
1187 "b" gnus-summary-set-bookmark
1188 "B" gnus-summary-remove-bookmark
1189 "#" gnus-summary-mark-as-processable
1190 "\M-#" gnus-summary-unmark-as-processable
1191 "S" gnus-summary-limit-include-expunged
1192 "C" gnus-summary-catchup
1193 "H" gnus-summary-catchup-to-here
1194 "\C-c" gnus-summary-catchup-all
1195 "k" gnus-summary-kill-same-subject-and-select
1196 "K" gnus-summary-kill-same-subject
1197 "P" gnus-uu-mark-map)
1199 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1200 "c" gnus-summary-clear-above
1201 "u" gnus-summary-tick-above
1202 "m" gnus-summary-mark-above
1203 "k" gnus-summary-kill-below)
1205 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1206 "/" gnus-summary-limit-to-subject
1207 "n" gnus-summary-limit-to-articles
1208 "w" gnus-summary-pop-limit
1209 "s" gnus-summary-limit-to-subject
1210 "a" gnus-summary-limit-to-author
1211 "u" gnus-summary-limit-to-unread
1212 "m" gnus-summary-limit-to-marks
1213 "v" gnus-summary-limit-to-score
1214 "D" gnus-summary-limit-include-dormant
1215 "d" gnus-summary-limit-exclude-dormant
1216 "t" gnus-summary-limit-to-age
1217 "E" gnus-summary-limit-include-expunged
1218 "c" gnus-summary-limit-exclude-childless-dormant
1219 "C" gnus-summary-limit-mark-excluded-as-read)
1221 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1222 "n" gnus-summary-next-unread-article
1223 "p" gnus-summary-prev-unread-article
1224 "N" gnus-summary-next-article
1225 "P" gnus-summary-prev-article
1226 "\C-n" gnus-summary-next-same-subject
1227 "\C-p" gnus-summary-prev-same-subject
1228 "\M-n" gnus-summary-next-unread-subject
1229 "\M-p" gnus-summary-prev-unread-subject
1230 "f" gnus-summary-first-unread-article
1231 "b" gnus-summary-best-unread-article
1232 "j" gnus-summary-goto-article
1233 "g" gnus-summary-goto-subject
1234 "l" gnus-summary-goto-last-article
1235 "o" gnus-summary-pop-article)
1237 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1238 "k" gnus-summary-kill-thread
1239 "l" gnus-summary-lower-thread
1240 "i" gnus-summary-raise-thread
1241 "T" gnus-summary-toggle-threads
1242 "t" gnus-summary-rethread-current
1243 "^" gnus-summary-reparent-thread
1244 "s" gnus-summary-show-thread
1245 "S" gnus-summary-show-all-threads
1246 "h" gnus-summary-hide-thread
1247 "H" gnus-summary-hide-all-threads
1248 "n" gnus-summary-next-thread
1249 "p" gnus-summary-prev-thread
1250 "u" gnus-summary-up-thread
1251 "o" gnus-summary-top-thread
1252 "d" gnus-summary-down-thread
1253 "#" gnus-uu-mark-thread
1254 "\M-#" gnus-uu-unmark-thread)
1256 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1257 "g" gnus-summary-prepare
1258 "c" gnus-summary-insert-cached-articles)
1260 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1261 "c" gnus-summary-catchup-and-exit
1262 "C" gnus-summary-catchup-all-and-exit
1263 "E" gnus-summary-exit-no-update
1264 "Q" gnus-summary-exit
1265 "Z" gnus-summary-exit
1266 "n" gnus-summary-catchup-and-goto-next-group
1267 "R" gnus-summary-reselect-current-group
1268 "G" gnus-summary-rescan-group
1269 "N" gnus-summary-next-group
1270 "s" gnus-summary-save-newsrc
1271 "P" gnus-summary-prev-group)
1273 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1274 " " gnus-summary-next-page
1275 "n" gnus-summary-next-page
1276 "\177" gnus-summary-prev-page
1277 [delete] gnus-summary-prev-page
1278 "p" gnus-summary-prev-page
1279 "\r" gnus-summary-scroll-up
1280 "<" gnus-summary-beginning-of-article
1281 ">" gnus-summary-end-of-article
1282 "b" gnus-summary-beginning-of-article
1283 "e" gnus-summary-end-of-article
1284 "^" gnus-summary-refer-parent-article
1285 "r" gnus-summary-refer-parent-article
1286 "R" gnus-summary-refer-references
1287 "g" gnus-summary-show-article
1288 "s" gnus-summary-isearch-article
1289 "P" gnus-summary-print-article)
1291 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1292 "b" gnus-article-add-buttons
1293 "B" gnus-article-add-buttons-to-head
1294 "o" gnus-article-treat-overstrike
1295 "e" gnus-article-emphasize
1296 "w" gnus-article-fill-cited-article
1297 "c" gnus-article-remove-cr
1298 "q" gnus-article-de-quoted-unreadable
1299 "f" gnus-article-display-x-face
1300 "l" gnus-summary-stop-page-breaking
1301 "r" gnus-summary-caesar-message
1302 "t" gnus-article-hide-headers
1303 "v" gnus-summary-verbose-headers
1304 "m" gnus-summary-toggle-mime
1305 "h" gnus-article-treat-html)
1307 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1308 "a" gnus-article-hide
1309 "h" gnus-article-hide-headers
1310 "b" gnus-article-hide-boring-headers
1311 "s" gnus-article-hide-signature
1312 "c" gnus-article-hide-citation
1313 "p" gnus-article-hide-pgp
1314 "P" gnus-article-hide-pem
1315 "\C-c" gnus-article-hide-citation-maybe)
1317 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1318 "a" gnus-article-highlight
1319 "h" gnus-article-highlight-headers
1320 "c" gnus-article-highlight-citation
1321 "s" gnus-article-highlight-signature)
1323 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1324 "z" gnus-article-date-ut
1325 "u" gnus-article-date-ut
1326 "l" gnus-article-date-local
1327 "e" gnus-article-date-lapsed
1328 "o" gnus-article-date-original
1329 "s" gnus-article-date-user)
1331 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1332 "t" gnus-article-remove-trailing-blank-lines
1333 "l" gnus-article-strip-leading-blank-lines
1334 "m" gnus-article-strip-multiple-blank-lines
1335 "a" gnus-article-strip-blank-lines
1336 "s" gnus-article-strip-leading-space)
1338 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1340 "f" gnus-summary-fetch-faq
1341 "d" gnus-summary-describe-group
1342 "h" gnus-summary-describe-briefly
1343 "i" gnus-info-find-node)
1345 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1346 "e" gnus-summary-expire-articles
1347 "\M-\C-e" gnus-summary-expire-articles-now
1348 "\177" gnus-summary-delete-article
1349 [delete] gnus-summary-delete-article
1350 "m" gnus-summary-move-article
1351 "r" gnus-summary-respool-article
1352 "w" gnus-summary-edit-article
1353 "c" gnus-summary-copy-article
1354 "B" gnus-summary-crosspost-article
1355 "q" gnus-summary-respool-query
1356 "i" gnus-summary-import-article
1357 "p" gnus-summary-article-posted-p)
1359 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1360 "o" gnus-summary-save-article
1361 "m" gnus-summary-save-article-mail
1362 "F" gnus-summary-write-article-file
1363 "r" gnus-summary-save-article-rmail
1364 "f" gnus-summary-save-article-file
1365 "b" gnus-summary-save-article-body-file
1366 "h" gnus-summary-save-article-folder
1367 "v" gnus-summary-save-article-vm
1368 "p" gnus-summary-pipe-output
1369 "s" gnus-soup-add-article))
1371 (defun gnus-summary-make-menu-bar ()
1372 (gnus-turn-off-edit-menu 'summary)
1374 (unless (boundp 'gnus-summary-misc-menu)
1377 gnus-summary-kill-menu gnus-summary-mode-map ""
1382 ["Enter score..." gnus-summary-score-entry t]
1383 ["Customize" gnus-score-customize t])
1384 (gnus-make-score-map 'increase)
1385 (gnus-make-score-map 'lower)
1387 ["Kill below" gnus-summary-kill-below t]
1388 ["Mark above" gnus-summary-mark-above t]
1389 ["Tick above" gnus-summary-tick-above t]
1390 ["Clear above" gnus-summary-clear-above t])
1391 ["Current score" gnus-summary-current-score t]
1392 ["Set score" gnus-summary-set-score t]
1393 ["Switch current score file..." gnus-score-change-score-file t]
1394 ["Set mark below..." gnus-score-set-mark-below t]
1395 ["Set expunge below..." gnus-score-set-expunge-below t]
1396 ["Edit current score file" gnus-score-edit-current-scores t]
1397 ["Edit score file" gnus-score-edit-file t]
1398 ["Trace score" gnus-score-find-trace t]
1399 ["Find words" gnus-score-find-favourite-words t]
1400 ["Rescore buffer" gnus-summary-rescore t]
1401 ["Increase score..." gnus-summary-increase-score t]
1402 ["Lower score..." gnus-summary-lower-score t]))))
1405 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1407 :selected (null gnus-score-default-header)]
1408 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1410 :selected (eq gnus-score-default-header 'a)]
1411 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1413 :selected (eq gnus-score-default-header 's)]
1415 (gnus-score-set-default 'gnus-score-default-header 'b)
1417 :selected (eq gnus-score-default-header 'b )]
1419 (gnus-score-set-default 'gnus-score-default-header 'h)
1421 :selected (eq gnus-score-default-header 'h )]
1422 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1424 :selected (eq gnus-score-default-header 'i )]
1425 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1427 :selected (eq gnus-score-default-header 't )]
1429 (gnus-score-set-default 'gnus-score-default-header 'x)
1431 :selected (eq gnus-score-default-header 'x )]
1432 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1434 :selected (eq gnus-score-default-header 'l )]
1435 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1437 :selected (eq gnus-score-default-header 'd )]
1438 ["Followups to author"
1439 (gnus-score-set-default 'gnus-score-default-header 'f)
1441 :selected (eq gnus-score-default-header 'f )])
1443 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1445 :selected (null gnus-score-default-type)]
1446 ;; The `:active' key is commented out in the following,
1447 ;; because the GNU Emacs hack to support radio buttons use
1448 ;; active to indicate which button is selected.
1449 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1451 ;; :active (not (memq gnus-score-default-header '(l d)))
1452 :selected (eq gnus-score-default-type 's)]
1453 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1455 ;; :active (not (memq gnus-score-default-header '(l d)))
1456 :selected (eq gnus-score-default-type 'r)]
1457 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1459 ;; :active (not (memq gnus-score-default-header '(l d)))
1460 :selected (eq gnus-score-default-type 'e)]
1461 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1463 ;; :active (not (memq gnus-score-default-header '(l d)))
1464 :selected (eq gnus-score-default-type 'f)]
1465 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1467 ;; :active (eq (gnus-score-default-header 'd))
1468 :selected (eq gnus-score-default-type 'b)]
1469 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1471 ;; :active (eq (gnus-score-default-header 'd))
1472 :selected (eq gnus-score-default-type 'n)]
1473 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1475 ;; :active (eq (gnus-score-default-header 'd))
1476 :selected (eq gnus-score-default-type 'a)]
1478 (gnus-score-set-default 'gnus-score-default-type '<)
1480 ;; :active (eq (gnus-score-default-header 'l))
1481 :selected (eq gnus-score-default-type '<)]
1483 (gnus-score-set-default 'gnus-score-default-type '=)
1485 ;; :active (eq (gnus-score-default-header 'l))
1486 :selected (eq gnus-score-default-type '=)]
1487 ["Greater than number"
1488 (gnus-score-set-default 'gnus-score-default-type '>)
1490 ;; :active (eq (gnus-score-default-header 'l))
1491 :selected (eq gnus-score-default-type '>)])
1492 ["Default fold" gnus-score-default-fold-toggle
1494 :selected gnus-score-default-fold]
1496 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1498 :selected (null gnus-score-default-duration)]
1500 (gnus-score-set-default 'gnus-score-default-duration 'p)
1502 :selected (eq gnus-score-default-duration 'p)]
1504 (gnus-score-set-default 'gnus-score-default-duration 't)
1506 :selected (eq gnus-score-default-duration 't)]
1508 (gnus-score-set-default 'gnus-score-default-duration 'i)
1510 :selected (eq gnus-score-default-duration 'i)]))
1513 gnus-summary-article-menu gnus-summary-mode-map ""
1516 ["All" gnus-article-hide t]
1517 ["Headers" gnus-article-hide-headers t]
1518 ["Signature" gnus-article-hide-signature t]
1519 ["Citation" gnus-article-hide-citation t]
1520 ["PGP" gnus-article-hide-pgp t]
1521 ["Boring headers" gnus-article-hide-boring-headers t])
1523 ["All" gnus-article-highlight t]
1524 ["Headers" gnus-article-highlight-headers t]
1525 ["Signature" gnus-article-highlight-signature t]
1526 ["Citation" gnus-article-highlight-citation t])
1528 ["Local" gnus-article-date-local t]
1529 ["UT" gnus-article-date-ut t]
1530 ["Original" gnus-article-date-original t]
1531 ["Lapsed" gnus-article-date-lapsed t]
1532 ["User-defined" gnus-article-date-user t])
1535 ["Leading" gnus-article-strip-leading-blank-lines t]
1536 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1537 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1538 ["All of the above" gnus-article-strip-blank-lines t]
1539 ["Leading space" gnus-article-strip-leading-space t])
1540 ["Overstrike" gnus-article-treat-overstrike t]
1541 ["Emphasis" gnus-article-emphasize t]
1542 ["Word wrap" gnus-article-fill-cited-article t]
1543 ["CR" gnus-article-remove-cr t]
1544 ["Show X-Face" gnus-article-display-x-face t]
1545 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1546 ["UnHTMLize" gnus-article-treat-html t]
1547 ["Rot 13" gnus-summary-caesar-message t]
1548 ["Unix pipe" gnus-summary-pipe-message t]
1549 ["Add buttons" gnus-article-add-buttons t]
1550 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1551 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1552 ["Toggle MIME" gnus-summary-toggle-mime t]
1553 ["Verbose header" gnus-summary-verbose-headers t]
1554 ["Toggle header" gnus-summary-toggle-header t])
1556 ["Save in default format" gnus-summary-save-article t]
1557 ["Save in file" gnus-summary-save-article-file t]
1558 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1559 ["Write to file" gnus-summary-write-article-mail t]
1560 ["Save in MH folder" gnus-summary-save-article-folder t]
1561 ["Save in VM folder" gnus-summary-save-article-vm t]
1562 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1563 ["Save body in file" gnus-summary-save-article-body-file t]
1564 ["Pipe through a filter" gnus-summary-pipe-output t]
1565 ["Add to SOUP packet" gnus-soup-add-article t]
1566 ["Print" gnus-summary-print-article t])
1568 ["Respool article..." gnus-summary-respool-article t]
1569 ["Move article..." gnus-summary-move-article
1570 (gnus-check-backend-function
1571 'request-move-article gnus-newsgroup-name)]
1572 ["Copy article..." gnus-summary-copy-article t]
1573 ["Crosspost article..." gnus-summary-crosspost-article
1574 (gnus-check-backend-function
1575 'request-replace-article gnus-newsgroup-name)]
1576 ["Import file..." gnus-summary-import-article t]
1577 ["Check if posted" gnus-summary-article-posted-p t]
1578 ["Edit article" gnus-summary-edit-article
1579 (not (gnus-group-read-only-p))]
1580 ["Delete article" gnus-summary-delete-article
1581 (gnus-check-backend-function
1582 'request-expire-articles gnus-newsgroup-name)]
1583 ["Query respool" gnus-summary-respool-query t]
1584 ["Delete expirable articles" gnus-summary-expire-articles-now
1585 (gnus-check-backend-function
1586 'request-expire-articles gnus-newsgroup-name)])
1588 ["Uudecode" gnus-uu-decode-uu t]
1589 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1590 ["Unshar" gnus-uu-decode-unshar t]
1591 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1592 ["Save" gnus-uu-decode-save t]
1593 ["Binhex" gnus-uu-decode-binhex t]
1594 ["Postscript" gnus-uu-decode-postscript t])
1596 ["Enter article" gnus-cache-enter-article t]
1597 ["Remove article" gnus-cache-remove-article t])
1598 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1599 ["Isearch article..." gnus-summary-isearch-article t]
1600 ["Beginning of the article" gnus-summary-beginning-of-article t]
1601 ["End of the article" gnus-summary-end-of-article t]
1602 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1603 ["Fetch referenced articles" gnus-summary-refer-references t]
1604 ["Fetch article with id..." gnus-summary-refer-article t]
1605 ["Redisplay" gnus-summary-show-article t]))
1608 gnus-summary-thread-menu gnus-summary-mode-map ""
1610 ["Toggle threading" gnus-summary-toggle-threads t]
1611 ["Hide threads" gnus-summary-hide-all-threads t]
1612 ["Show threads" gnus-summary-show-all-threads t]
1613 ["Hide thread" gnus-summary-hide-thread t]
1614 ["Show thread" gnus-summary-show-thread t]
1615 ["Go to next thread" gnus-summary-next-thread t]
1616 ["Go to previous thread" gnus-summary-prev-thread t]
1617 ["Go down thread" gnus-summary-down-thread t]
1618 ["Go up thread" gnus-summary-up-thread t]
1619 ["Top of thread" gnus-summary-top-thread t]
1620 ["Mark thread as read" gnus-summary-kill-thread t]
1621 ["Lower thread score" gnus-summary-lower-thread t]
1622 ["Raise thread score" gnus-summary-raise-thread t]
1623 ["Rethread current" gnus-summary-rethread-current t]
1627 gnus-summary-post-menu gnus-summary-mode-map ""
1629 ["Post an article" gnus-summary-post-news t]
1630 ["Followup" gnus-summary-followup t]
1631 ["Followup and yank" gnus-summary-followup-with-original t]
1632 ["Supersede article" gnus-summary-supersede-article t]
1633 ["Cancel article" gnus-summary-cancel-article t]
1634 ["Reply" gnus-summary-reply t]
1635 ["Reply and yank" gnus-summary-reply-with-original t]
1636 ["Wide reply" gnus-summary-wide-reply t]
1637 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1638 ["Mail forward" gnus-summary-mail-forward t]
1639 ["Post forward" gnus-summary-post-forward t]
1640 ["Digest and mail" gnus-uu-digest-mail-forward t]
1641 ["Digest and post" gnus-uu-digest-post-forward t]
1642 ["Resend message" gnus-summary-resend-message t]
1643 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1644 ["Send a mail" gnus-summary-mail-other-window t]
1645 ["Uuencode and post" gnus-uu-post-news t]
1646 ["Followup via news" gnus-summary-followup-to-mail t]
1647 ["Followup via news and yank"
1648 gnus-summary-followup-to-mail-with-original t]
1650 ;;["Send" gnus-summary-send-draft t]
1651 ;;["Send bounced" gnus-resend-bounced-mail t])
1655 gnus-summary-misc-menu gnus-summary-mode-map ""
1658 ["Mark as read" gnus-summary-mark-as-read-forward t]
1659 ["Mark same subject and select"
1660 gnus-summary-kill-same-subject-and-select t]
1661 ["Mark same subject" gnus-summary-kill-same-subject t]
1662 ["Catchup" gnus-summary-catchup t]
1663 ["Catchup all" gnus-summary-catchup-all t]
1664 ["Catchup to here" gnus-summary-catchup-to-here t]
1665 ["Catchup region" gnus-summary-mark-region-as-read t]
1666 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1668 ["Tick" gnus-summary-tick-article-forward t]
1669 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1670 ["Remove marks" gnus-summary-clear-mark-forward t]
1671 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1672 ["Set bookmark" gnus-summary-set-bookmark t]
1673 ["Remove bookmark" gnus-summary-remove-bookmark t])
1675 ["Marks..." gnus-summary-limit-to-marks t]
1676 ["Subject..." gnus-summary-limit-to-subject t]
1677 ["Author..." gnus-summary-limit-to-author t]
1678 ["Age..." gnus-summary-limit-to-age t]
1679 ["Score" gnus-summary-limit-to-score t]
1680 ["Unread" gnus-summary-limit-to-unread t]
1681 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1682 ["Articles" gnus-summary-limit-to-articles t]
1683 ["Pop limit" gnus-summary-pop-limit t]
1684 ["Show dormant" gnus-summary-limit-include-dormant t]
1685 ["Hide childless dormant"
1686 gnus-summary-limit-exclude-childless-dormant t]
1687 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1688 ["Show expunged" gnus-summary-show-all-expunged t])
1690 ["Set mark" gnus-summary-mark-as-processable t]
1691 ["Remove mark" gnus-summary-unmark-as-processable t]
1692 ["Remove all marks" gnus-summary-unmark-all-processable t]
1693 ["Mark above" gnus-uu-mark-over t]
1694 ["Mark series" gnus-uu-mark-series t]
1695 ["Mark region" gnus-uu-mark-region t]
1696 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1697 ["Mark all" gnus-uu-mark-all t]
1698 ["Mark buffer" gnus-uu-mark-buffer t]
1699 ["Mark sparse" gnus-uu-mark-sparse t]
1700 ["Mark thread" gnus-uu-mark-thread t]
1701 ["Unmark thread" gnus-uu-unmark-thread t]
1702 ("Process Mark Sets"
1703 ["Kill" gnus-summary-kill-process-mark t]
1704 ["Yank" gnus-summary-yank-process-mark
1705 gnus-newsgroup-process-stack]
1706 ["Save" gnus-summary-save-process-mark t]))
1708 ["Page forward" gnus-summary-next-page t]
1709 ["Page backward" gnus-summary-prev-page t]
1710 ["Line forward" gnus-summary-scroll-up t])
1712 ["Next unread article" gnus-summary-next-unread-article t]
1713 ["Previous unread article" gnus-summary-prev-unread-article t]
1714 ["Next article" gnus-summary-next-article t]
1715 ["Previous article" gnus-summary-prev-article t]
1716 ["Next unread subject" gnus-summary-next-unread-subject t]
1717 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1718 ["Next article same subject" gnus-summary-next-same-subject t]
1719 ["Previous article same subject" gnus-summary-prev-same-subject t]
1720 ["First unread article" gnus-summary-first-unread-article t]
1721 ["Best unread article" gnus-summary-best-unread-article t]
1722 ["Go to subject number..." gnus-summary-goto-subject t]
1723 ["Go to article number..." gnus-summary-goto-article t]
1724 ["Go to the last article" gnus-summary-goto-last-article t]
1725 ["Pop article off history" gnus-summary-pop-article t])
1727 ["Sort by number" gnus-summary-sort-by-number t]
1728 ["Sort by author" gnus-summary-sort-by-author t]
1729 ["Sort by subject" gnus-summary-sort-by-subject t]
1730 ["Sort by date" gnus-summary-sort-by-date t]
1731 ["Sort by score" gnus-summary-sort-by-score t]
1732 ["Sort by lines" gnus-summary-sort-by-lines t])
1734 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1735 ["Describe group" gnus-summary-describe-group t]
1736 ["Read manual" gnus-info-find-node t])
1738 ["Pick and read" gnus-pick-mode t]
1739 ["Binary" gnus-binary-mode t])
1741 ["Regenerate" gnus-summary-prepare t]
1742 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1743 ["Toggle threading" gnus-summary-toggle-threads t])
1744 ["Filter articles..." gnus-summary-execute-command t]
1745 ["Run command on subjects..." gnus-summary-universal-argument t]
1746 ["Search articles forward..." gnus-summary-search-article-forward t]
1747 ["Search articles backward..." gnus-summary-search-article-backward t]
1748 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1749 ["Expand window" gnus-summary-expand-window t]
1750 ["Expire expirable articles" gnus-summary-expire-articles
1751 (gnus-check-backend-function
1752 'request-expire-articles gnus-newsgroup-name)]
1753 ["Edit local kill file" gnus-summary-edit-local-kill t]
1754 ["Edit main kill file" gnus-summary-edit-global-kill t]
1756 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1757 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1758 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1759 ["Exit group" gnus-summary-exit t]
1760 ["Exit group without updating" gnus-summary-exit-no-update t]
1761 ["Exit and goto next group" gnus-summary-next-group t]
1762 ["Exit and goto prev group" gnus-summary-prev-group t]
1763 ["Reselect group" gnus-summary-reselect-current-group t]
1764 ["Rescan group" gnus-summary-rescan-group t]
1765 ["Update dribble" gnus-summary-save-newsrc t])))
1767 (run-hooks 'gnus-summary-menu-hook)))
1769 (defun gnus-score-set-default (var value)
1770 "A version of set that updates the GNU Emacs menu-bar."
1772 ;; It is the message that forces the active status to be updated.
1775 (defun gnus-make-score-map (type)
1776 "Make a summary score map of type TYPE."
1779 (let ((headers '(("author" "from" string)
1780 ("subject" "subject" string)
1781 ("article body" "body" string)
1782 ("article head" "head" string)
1783 ("xref" "xref" string)
1784 ("lines" "lines" number)
1785 ("followups to author" "followup" string)))
1786 (types '((number ("less than" <)
1789 (string ("substring" s)
1793 (perms '(("temporary" (current-time-string))
1801 (if (eq type 'lower)
1806 (setq header (car headers))
1812 (let ((ts (cdr (assoc (nth 2 header) types)))
1828 'gnus-summary-score-entry
1830 (if (or (string= (nth 1 header)
1832 (string= (nth 1 header)
1835 (list 'gnus-summary-header
1837 (list 'quote (nth 1 (car ts)))
1838 (list 'gnus-score-default nil)
1844 (list (nreverse outp))))
1847 (list (nreverse outt))))
1849 (setq headers (cdr headers)))
1850 (list (nreverse outh))))))))
1854 (defun gnus-summary-mode (&optional group)
1855 "Major mode for reading articles.
1857 All normal editing commands are switched off.
1858 \\<gnus-summary-mode-map>
1859 Each line in this buffer represents one article. To read an
1860 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1861 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1864 You can also post articles and send mail from this buffer. To
1865 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1866 of an article, type `\\[gnus-summary-reply]'.
1868 There are approx. one gazillion commands you can execute in this
1869 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1871 The following commands are available:
1873 \\{gnus-summary-mode-map}"
1875 (when (gnus-visual-p 'summary-menu 'menu)
1876 (gnus-summary-make-menu-bar))
1877 (kill-all-local-variables)
1878 (gnus-summary-make-local-variables)
1879 (gnus-make-thread-indent-array)
1880 (gnus-simplify-mode-line)
1881 (setq major-mode 'gnus-summary-mode)
1882 (setq mode-name "Summary")
1883 (make-local-variable 'minor-mode-alist)
1884 (use-local-map gnus-summary-mode-map)
1885 (buffer-disable-undo (current-buffer))
1886 (setq buffer-read-only t) ;Disable modification
1887 (setq truncate-lines t)
1888 (setq selective-display t)
1889 (setq selective-display-ellipses t) ;Display `...'
1890 (gnus-summary-set-display-table)
1891 (gnus-set-default-directory)
1892 (setq gnus-newsgroup-name group)
1893 (make-local-variable 'gnus-summary-line-format)
1894 (make-local-variable 'gnus-summary-line-format-spec)
1895 (make-local-variable 'gnus-summary-mark-positions)
1896 (make-local-hook 'post-command-hook)
1897 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1898 (run-hooks 'gnus-summary-mode-hook)
1899 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1900 (gnus-update-summary-mark-positions))
1902 (defun gnus-summary-make-local-variables ()
1903 "Make all the local summary buffer variables."
1904 (let ((locals gnus-summary-local-variables)
1906 (while (setq local (pop locals))
1909 (if (eq (cdr local) 'global)
1910 ;; Copy the global value of the variable.
1911 (setq global (symbol-value (car local)))
1912 ;; Use the value from the list.
1913 (setq global (eval (cdr local))))
1914 (make-local-variable (car local))
1915 (set (car local) global))
1916 ;; Simple nil-valued local variable.
1917 (make-local-variable local)
1920 (defun gnus-summary-clear-local-variables ()
1921 (let ((locals gnus-summary-local-variables))
1923 (if (consp (car locals))
1924 (and (vectorp (caar locals))
1925 (set (caar locals) nil))
1926 (and (vectorp (car locals))
1927 (set (car locals) nil)))
1928 (setq locals (cdr locals)))))
1930 ;; Summary data functions.
1932 (defmacro gnus-data-number (data)
1935 (defmacro gnus-data-set-number (data number)
1936 `(setcar ,data ,number))
1938 (defmacro gnus-data-mark (data)
1941 (defmacro gnus-data-set-mark (data mark)
1942 `(setcar (nthcdr 1 ,data) ,mark))
1944 (defmacro gnus-data-pos (data)
1947 (defmacro gnus-data-set-pos (data pos)
1948 `(setcar (nthcdr 2 ,data) ,pos))
1950 (defmacro gnus-data-header (data)
1953 (defmacro gnus-data-set-header (data header)
1954 `(setf (nth 3 ,data) ,header))
1956 (defmacro gnus-data-level (data)
1959 (defmacro gnus-data-unread-p (data)
1960 `(= (nth 1 ,data) gnus-unread-mark))
1962 (defmacro gnus-data-read-p (data)
1963 `(/= (nth 1 ,data) gnus-unread-mark))
1965 (defmacro gnus-data-pseudo-p (data)
1966 `(consp (nth 3 ,data)))
1968 (defmacro gnus-data-find (number)
1969 `(assq ,number gnus-newsgroup-data))
1971 (defmacro gnus-data-find-list (number &optional data)
1972 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1973 (memq (assq ,number bdata)
1976 (defmacro gnus-data-make (number mark pos header level)
1977 `(list ,number ,mark ,pos ,header ,level))
1979 (defun gnus-data-enter (after-article number mark pos header level offset)
1980 (let ((data (gnus-data-find-list after-article)))
1982 (error "No such article: %d" after-article))
1983 (setcdr data (cons (gnus-data-make number mark pos header level)
1985 (setq gnus-newsgroup-data-reverse nil)
1986 (gnus-data-update-list (cddr data) offset)))
1988 (defun gnus-data-enter-list (after-article list &optional offset)
1990 (let ((data (and after-article (gnus-data-find-list after-article)))
1992 (or data (not after-article) (error "No such article: %d" after-article))
1993 ;; Find the last element in the list to be spliced into the main
1996 (setq list (cdr list)))
1999 (setcdr list gnus-newsgroup-data)
2000 (setq gnus-newsgroup-data ilist)
2002 (gnus-data-update-list (cdr list) offset)))
2003 (setcdr list (cdr data))
2006 (gnus-data-update-list (cdr list) offset)))
2007 (setq gnus-newsgroup-data-reverse nil))))
2009 (defun gnus-data-remove (article &optional offset)
2010 (let ((data gnus-newsgroup-data))
2011 (if (= (gnus-data-number (car data)) article)
2013 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2014 gnus-newsgroup-data-reverse nil)
2016 (gnus-data-update-list gnus-newsgroup-data offset)))
2018 (when (= (gnus-data-number (cadr data)) article)
2019 (setcdr data (cddr data))
2021 (gnus-data-update-list (cdr data) offset))
2023 gnus-newsgroup-data-reverse nil))
2024 (setq data (cdr data))))))
2026 (defmacro gnus-data-list (backward)
2028 (or gnus-newsgroup-data-reverse
2029 (setq gnus-newsgroup-data-reverse
2030 (reverse gnus-newsgroup-data)))
2031 gnus-newsgroup-data))
2033 (defun gnus-data-update-list (data offset)
2034 "Add OFFSET to the POS of all data entries in DATA."
2036 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2037 (setq data (cdr data))))
2039 (defun gnus-data-compute-positions ()
2040 "Compute the positions of all articles."
2041 (let ((data gnus-newsgroup-data)
2044 (when (setq pos (text-property-any
2045 (point-min) (point-max)
2046 'gnus-number (gnus-data-number (car data))))
2047 (gnus-data-set-pos (car data) (+ pos 3)))
2048 (setq data (cdr data)))))
2050 (defun gnus-summary-article-pseudo-p (article)
2051 "Say whether this article is a pseudo article or not."
2052 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2054 (defmacro gnus-summary-article-sparse-p (article)
2055 "Say whether this article is a sparse article or not."
2056 `(memq ,article gnus-newsgroup-sparse))
2058 (defmacro gnus-summary-article-ancient-p (article)
2059 "Say whether this article is a sparse article or not."
2060 `(memq ,article gnus-newsgroup-ancient))
2062 (defun gnus-article-parent-p (number)
2063 "Say whether this article is a parent or not."
2064 (let ((data (gnus-data-find-list number)))
2065 (and (cdr data) ; There has to be an article after...
2066 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2067 (gnus-data-level (nth 1 data))))))
2069 (defun gnus-article-children (number)
2070 "Return a list of all children to NUMBER."
2071 (let* ((data (gnus-data-find-list number))
2072 (level (gnus-data-level (car data)))
2074 (setq data (cdr data))
2076 (= (gnus-data-level (car data)) (1+ level)))
2077 (push (gnus-data-number (car data)) children)
2078 (setq data (cdr data)))
2081 (defmacro gnus-summary-skip-intangible ()
2082 "If the current article is intangible, then jump to a different article."
2083 '(let ((to (get-text-property (point) 'gnus-intangible)))
2084 (and to (gnus-summary-goto-subject to))))
2086 (defmacro gnus-summary-article-intangible-p ()
2087 "Say whether this article is intangible or not."
2088 '(get-text-property (point) 'gnus-intangible))
2090 (defun gnus-article-read-p (article)
2091 "Say whether ARTICLE is read or not."
2092 (not (or (memq article gnus-newsgroup-marked)
2093 (memq article gnus-newsgroup-unreads)
2094 (memq article gnus-newsgroup-unselected)
2095 (memq article gnus-newsgroup-dormant))))
2097 ;; Some summary mode macros.
2099 (defmacro gnus-summary-article-number ()
2100 "The article number of the article on the current line.
2101 If there isn's an article number here, then we return the current
2104 (gnus-summary-skip-intangible)
2105 (or (get-text-property (point) 'gnus-number)
2106 (gnus-summary-last-subject))))
2108 (defmacro gnus-summary-article-header (&optional number)
2109 `(gnus-data-header (gnus-data-find
2110 ,(or number '(gnus-summary-article-number)))))
2112 (defmacro gnus-summary-thread-level (&optional number)
2113 `(if (and (eq gnus-summary-make-false-root 'dummy)
2114 (get-text-property (point) 'gnus-intangible))
2116 (gnus-data-level (gnus-data-find
2117 ,(or number '(gnus-summary-article-number))))))
2119 (defmacro gnus-summary-article-mark (&optional number)
2120 `(gnus-data-mark (gnus-data-find
2121 ,(or number '(gnus-summary-article-number)))))
2123 (defmacro gnus-summary-article-pos (&optional number)
2124 `(gnus-data-pos (gnus-data-find
2125 ,(or number '(gnus-summary-article-number)))))
2127 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2128 (defmacro gnus-summary-article-subject (&optional number)
2129 "Return current subject string or nil if nothing."
2132 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2133 '(gnus-data-header (assq (gnus-summary-article-number)
2134 gnus-newsgroup-data)))))
2137 (mail-header-subject headers))))
2139 (defmacro gnus-summary-article-score (&optional number)
2140 "Return current article score."
2141 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2142 gnus-newsgroup-scored))
2143 gnus-summary-default-score 0))
2145 (defun gnus-summary-article-children (&optional number)
2146 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2147 (level (gnus-data-level (car data)))
2149 (while (and (setq data (cdr data))
2150 (> (setq l (gnus-data-level (car data))) level))
2151 (and (= (1+ level) l)
2152 (push (gnus-data-number (car data))
2154 (nreverse children)))
2156 (defun gnus-summary-article-parent (&optional number)
2157 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2158 (gnus-data-list t)))
2159 (level (gnus-data-level (car data))))
2161 () ; This is a root.
2162 ;; We search until we find an article with a level less than
2163 ;; this one. That function has to be the parent.
2164 (while (and (setq data (cdr data))
2165 (not (< (gnus-data-level (car data)) level))))
2166 (and data (gnus-data-number (car data))))))
2168 (defun gnus-unread-mark-p (mark)
2169 "Say whether MARK is the unread mark."
2170 (= mark gnus-unread-mark))
2172 (defun gnus-read-mark-p (mark)
2173 "Say whether MARK is one of the marks that mark as read.
2174 This is all marks except unread, ticked, dormant, and expirable."
2175 (not (or (= mark gnus-unread-mark)
2176 (= mark gnus-ticked-mark)
2177 (= mark gnus-dormant-mark)
2178 (= mark gnus-expirable-mark))))
2180 (defmacro gnus-article-mark (number)
2182 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2183 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2184 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2185 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2186 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2187 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2188 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2189 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2190 gnus-ancient-mark))))
2192 ;; Saving hidden threads.
2194 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2195 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2197 (defmacro gnus-save-hidden-threads (&rest forms)
2198 "Save hidden threads, eval FORMS, and restore the hidden threads."
2199 (let ((config (make-symbol "config")))
2200 `(let ((,config (gnus-hidden-threads-configuration)))
2204 (gnus-restore-hidden-threads-configuration ,config)))))
2206 (defun gnus-hidden-threads-configuration ()
2207 "Return the current hidden threads configuration."
2210 (goto-char (point-min))
2211 (while (search-forward "\r" nil t)
2212 (push (1- (point)) config))
2215 (defun gnus-restore-hidden-threads-configuration (config)
2216 "Restore hidden threads configuration from CONFIG."
2217 (let (point buffer-read-only)
2218 (while (setq point (pop config))
2219 (when (and (< point (point-max))
2221 (= (following-char) ?\n))
2222 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2224 ;; Various summary mode internalish functions.
2226 (defun gnus-mouse-pick-article (e)
2229 (gnus-summary-next-page nil t))
2231 (defun gnus-summary-set-display-table ()
2232 ;; Change the display table. Odd characters have a tendency to mess
2233 ;; up nicely formatted displays - we make all possible glyphs
2234 ;; display only a single character.
2236 ;; We start from the standard display table, if any.
2237 (let ((table (or (copy-sequence standard-display-table)
2238 (make-display-table)))
2240 ;; Nix out all the control chars...
2241 (while (>= (setq i (1- i)) 0)
2242 (aset table i [??]))
2243 ;; ... but not newline and cr, of course. (cr is necessary for the
2244 ;; selective display).
2245 (aset table ?\n nil)
2246 (aset table ?\r nil)
2247 ;; We nix out any glyphs over 126 that are not set already.
2249 (while (>= (setq i (1- i)) 127)
2250 ;; Only modify if the entry is nil.
2251 (unless (aref table i)
2252 (aset table i [??]))))
2253 (setq buffer-display-table table)))
2255 (defun gnus-summary-setup-buffer (group)
2256 "Initialize summary buffer."
2257 (let ((buffer (concat "*Summary " group "*")))
2258 (if (get-buffer buffer)
2261 (setq gnus-summary-buffer (current-buffer))
2262 (not gnus-newsgroup-prepared))
2263 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2264 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2265 (gnus-add-current-to-buffer-list)
2266 (gnus-summary-mode group)
2268 (gnus-carpal-setup-buffer 'summary))
2269 (unless gnus-single-article-buffer
2270 (make-local-variable 'gnus-article-buffer)
2271 (make-local-variable 'gnus-article-current)
2272 (make-local-variable 'gnus-original-article-buffer))
2273 (setq gnus-newsgroup-name group)
2276 (defun gnus-set-global-variables ()
2277 ;; Set the global equivalents of the summary buffer-local variables
2278 ;; to the latest values they had. These reflect the summary buffer
2279 ;; that was in action when the last article was fetched.
2280 (when (eq major-mode 'gnus-summary-mode)
2281 (setq gnus-summary-buffer (current-buffer))
2282 (let ((name gnus-newsgroup-name)
2283 (marked gnus-newsgroup-marked)
2284 (unread gnus-newsgroup-unreads)
2285 (headers gnus-current-headers)
2286 (data gnus-newsgroup-data)
2287 (summary gnus-summary-buffer)
2288 (article-buffer gnus-article-buffer)
2289 (original gnus-original-article-buffer)
2290 (gac gnus-article-current)
2291 (reffed gnus-reffed-article-number)
2292 (score-file gnus-current-score-file))
2294 (set-buffer gnus-group-buffer)
2295 (setq gnus-newsgroup-name name)
2296 (setq gnus-newsgroup-marked marked)
2297 (setq gnus-newsgroup-unreads unread)
2298 (setq gnus-current-headers headers)
2299 (setq gnus-newsgroup-data data)
2300 (setq gnus-article-current gac)
2301 (setq gnus-summary-buffer summary)
2302 (setq gnus-article-buffer article-buffer)
2303 (setq gnus-original-article-buffer original)
2304 (setq gnus-reffed-article-number reffed)
2305 (setq gnus-current-score-file score-file)
2306 ;; The article buffer also has local variables.
2307 (when (gnus-buffer-live-p gnus-article-buffer)
2308 (set-buffer gnus-article-buffer)
2309 (setq gnus-summary-buffer summary))))))
2311 (defun gnus-summary-article-unread-p (article)
2312 "Say whether ARTICLE is unread or not."
2313 (memq article gnus-newsgroup-unreads))
2315 (defun gnus-summary-first-article-p (&optional article)
2316 "Return whether ARTICLE is the first article in the buffer."
2317 (if (not (setq article (or article (gnus-summary-article-number))))
2319 (eq article (caar gnus-newsgroup-data))))
2321 (defun gnus-summary-last-article-p (&optional article)
2322 "Return whether ARTICLE is the last article in the buffer."
2323 (if (not (setq article (or article (gnus-summary-article-number))))
2324 t ; All non-existent numbers are the last article. :-)
2325 (not (cdr (gnus-data-find-list article)))))
2327 (defun gnus-make-thread-indent-array ()
2329 (unless (and gnus-thread-indent-array
2330 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2331 (setq gnus-thread-indent-array (make-vector 201 "")
2332 gnus-thread-indent-array-level gnus-thread-indent-level)
2334 (aset gnus-thread-indent-array n
2335 (make-string (* n gnus-thread-indent-level) ? ))
2338 (defun gnus-update-summary-mark-positions ()
2339 "Compute where the summary marks are to go."
2341 (when (and gnus-summary-buffer
2342 (get-buffer gnus-summary-buffer)
2343 (buffer-name (get-buffer gnus-summary-buffer)))
2344 (set-buffer gnus-summary-buffer))
2345 (let ((gnus-replied-mark 129)
2346 (gnus-score-below-mark 130)
2347 (gnus-score-over-mark 130)
2348 (gnus-download-mark 131)
2349 (spec gnus-summary-line-format-spec)
2350 thread gnus-visual pos)
2352 (gnus-set-work-buffer)
2353 (let ((gnus-summary-line-format-spec spec)
2354 (gnus-newsgroup-downloadable '((0 . t))))
2355 (gnus-summary-insert-line
2356 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2357 (goto-char (point-min))
2358 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2360 (goto-char (point-min))
2361 (push (cons 'replied (and (search-forward "\201" nil t)
2364 (goto-char (point-min))
2365 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2367 (goto-char (point-min))
2368 (push (cons 'download
2369 (and (search-forward "\203" nil t) (- (point) 2)))
2371 (setq gnus-summary-mark-positions pos))))
2373 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2374 "Insert a dummy root in the summary buffer."
2376 (gnus-add-text-properties
2377 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2378 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2380 (defun gnus-summary-insert-line (gnus-tmp-header
2381 gnus-tmp-level gnus-tmp-current
2382 gnus-tmp-unread gnus-tmp-replied
2383 gnus-tmp-expirable gnus-tmp-subject-or-nil
2384 &optional gnus-tmp-dummy gnus-tmp-score
2386 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2387 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2388 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2389 (gnus-tmp-score-char
2390 (if (or (null gnus-summary-default-score)
2391 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2392 gnus-summary-zcore-fuzz))
2394 (if (< gnus-tmp-score gnus-summary-default-score)
2395 gnus-score-below-mark gnus-score-over-mark)))
2397 (cond (gnus-tmp-process gnus-process-mark)
2398 ((memq gnus-tmp-current gnus-newsgroup-cached)
2400 (gnus-tmp-replied gnus-replied-mark)
2401 ((memq gnus-tmp-current gnus-newsgroup-saved)
2403 (t gnus-unread-mark)))
2404 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2407 ((string-match "<[^>]+> *$" gnus-tmp-from)
2408 (let ((beg (match-beginning 0)))
2409 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2410 (substring gnus-tmp-from (1+ (match-beginning 0))
2411 (1- (match-end 0))))
2412 (substring gnus-tmp-from 0 beg))))
2413 ((string-match "(.+)" gnus-tmp-from)
2414 (substring gnus-tmp-from
2415 (1+ (match-beginning 0)) (1- (match-end 0))))
2417 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2418 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2419 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2420 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2421 (buffer-read-only nil))
2422 (when (string= gnus-tmp-name "")
2423 (setq gnus-tmp-name gnus-tmp-from))
2424 (unless (numberp gnus-tmp-lines)
2425 (setq gnus-tmp-lines 0))
2426 (gnus-put-text-property
2428 (progn (eval gnus-summary-line-format-spec) (point))
2429 'gnus-number gnus-tmp-number)
2430 (when (gnus-visual-p 'summary-highlight 'highlight)
2432 (run-hooks 'gnus-summary-update-hook)
2435 (defun gnus-summary-update-line (&optional dont-update)
2436 ;; Update summary line after change.
2437 (when (and gnus-summary-default-score
2438 (not gnus-summary-inhibit-highlight))
2439 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2440 (article (gnus-summary-article-number))
2441 (score (gnus-summary-article-score article)))
2443 (if (and gnus-summary-mark-below
2444 (< (gnus-summary-article-score)
2445 gnus-summary-mark-below))
2446 ;; This article has a low score, so we mark it as read.
2447 (when (memq article gnus-newsgroup-unreads)
2448 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2449 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2450 ;; This article was previously marked as read on account
2451 ;; of a low score, but now it has risen, so we mark it as
2453 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2454 (gnus-summary-update-mark
2455 (if (or (null gnus-summary-default-score)
2456 (<= (abs (- score gnus-summary-default-score))
2457 gnus-summary-zcore-fuzz))
2459 (if (< score gnus-summary-default-score)
2460 gnus-score-below-mark gnus-score-over-mark))
2462 ;; Do visual highlighting.
2463 (when (gnus-visual-p 'summary-highlight 'highlight)
2464 (run-hooks 'gnus-summary-update-hook)))))
2466 (defvar gnus-tmp-new-adopts nil)
2468 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2469 "Return the number of articles in THREAD.
2470 This may be 0 in some cases -- if none of the articles in
2471 the thread are to be displayed."
2473 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2475 ((not (listp thread))
2477 ((and (consp thread) (cdr thread))
2480 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2483 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2486 (when (and level (zerop level) gnus-tmp-new-adopts)
2489 'gnus-summary-number-of-articles-in-thread
2490 gnus-tmp-new-adopts))))
2492 (if (> number 1) gnus-not-empty-thread-mark
2493 gnus-empty-thread-mark)
2496 (defun gnus-summary-set-local-parameters (group)
2497 "Go through the local params of GROUP and set all variable specs in that list."
2498 (let ((params (gnus-group-find-parameter group))
2501 (setq elem (car params)
2502 params (cdr params))
2503 (and (consp elem) ; Has to be a cons.
2504 (consp (cdr elem)) ; The cdr has to be a list.
2505 (symbolp (car elem)) ; Has to be a symbol in there.
2506 (not (memq (car elem)
2507 '(quit-config to-address to-list to-group)))
2508 (ignore-errors ; So we set it.
2509 (make-local-variable (car elem))
2510 (set (car elem) (eval (nth 1 elem))))))))
2512 (defun gnus-summary-read-group (group &optional show-all no-article
2513 kill-buffer no-display)
2514 "Start reading news in newsgroup GROUP.
2515 If SHOW-ALL is non-nil, already read articles are also listed.
2516 If NO-ARTICLE is non-nil, no article is selected initially.
2517 If NO-DISPLAY, don't generate a summary buffer."
2521 (let ((gnus-auto-select-next nil))
2522 (gnus-summary-read-group-1
2523 group show-all no-article
2524 kill-buffer no-display))))
2525 (eq gnus-auto-select-next 'quietly))
2526 (set-buffer gnus-group-buffer)
2527 (if (not (equal group (gnus-group-group-name)))
2528 (setq group (gnus-group-group-name))
2532 (defun gnus-summary-read-group-1 (group show-all no-article
2533 kill-buffer no-display)
2534 ;; Killed foreign groups can't be entered.
2535 (when (and (not (gnus-group-native-p group))
2536 (not (gnus-gethash group gnus-newsrc-hashtb)))
2537 (error "Dead non-native groups can't be entered"))
2538 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2539 (let* ((new-group (gnus-summary-setup-buffer group))
2540 (quit-config (gnus-group-quit-config group))
2541 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2543 ;; This summary buffer exists already, so we just select it.
2545 (gnus-set-global-variables)
2547 (gnus-kill-or-deaden-summary kill-buffer))
2548 (gnus-configure-windows 'summary 'force)
2549 (gnus-set-mode-line 'summary)
2550 (gnus-summary-position-point)
2553 ;; We couldn't select this group.
2555 (when (and (eq major-mode 'gnus-summary-mode)
2556 (not (equal (current-buffer) kill-buffer)))
2557 (kill-buffer (current-buffer))
2558 (if (not quit-config)
2560 (set-buffer gnus-group-buffer)
2561 (gnus-group-jump-to-group group)
2562 (gnus-group-next-unread-group 1))
2563 (gnus-handle-ephemeral-exit quit-config)))
2564 (gnus-message 3 "Can't select group")
2566 ;; The user did a `C-g' while prompting for number of articles,
2567 ;; so we exit this group.
2568 ((eq did-select 'quit)
2569 (and (eq major-mode 'gnus-summary-mode)
2570 (not (equal (current-buffer) kill-buffer))
2571 (kill-buffer (current-buffer)))
2573 (gnus-kill-or-deaden-summary kill-buffer))
2574 (if (not quit-config)
2576 (set-buffer gnus-group-buffer)
2577 (gnus-group-jump-to-group group)
2578 (gnus-group-next-unread-group 1)
2579 (gnus-configure-windows 'group 'force))
2580 (gnus-handle-ephemeral-exit quit-config))
2581 ;; Finally signal the quit.
2583 ;; The group was successfully selected.
2585 (gnus-set-global-variables)
2586 ;; Save the active value in effect when the group was entered.
2587 (setq gnus-newsgroup-active
2589 (gnus-active gnus-newsgroup-name)))
2590 ;; You can change the summary buffer in some way with this hook.
2591 (run-hooks 'gnus-select-group-hook)
2592 ;; Set any local variables in the group parameters.
2593 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2594 (gnus-update-format-specifications
2595 nil 'summary 'summary-mode 'summary-dummy)
2596 ;; Do score processing.
2597 (when gnus-use-scoring
2598 (gnus-possibly-score-headers))
2599 ;; Check whether to fill in the gaps in the threads.
2600 (when gnus-build-sparse-threads
2601 (gnus-build-sparse-threads))
2602 ;; Find the initial limit.
2603 (if gnus-show-threads
2605 (let ((gnus-newsgroup-dormant nil))
2606 (gnus-summary-initial-limit show-all))
2607 (gnus-summary-initial-limit show-all))
2608 (setq gnus-newsgroup-limit
2610 (lambda (header) (mail-header-number header))
2611 gnus-newsgroup-headers)))
2612 ;; Generate the summary buffer.
2614 (gnus-summary-prepare))
2615 (when gnus-use-trees
2616 (gnus-tree-open group)
2617 (setq gnus-summary-highlight-line-function
2618 'gnus-tree-highlight-article))
2619 ;; If the summary buffer is empty, but there are some low-scored
2620 ;; articles or some excluded dormants, we include these in the
2622 (when (and (zerop (buffer-size))
2624 (cond (gnus-newsgroup-dormant
2625 (gnus-summary-limit-include-dormant))
2626 ((and gnus-newsgroup-scored show-all)
2627 (gnus-summary-limit-include-expunged t))))
2628 ;; Function `gnus-apply-kill-file' must be called in this hook.
2629 (run-hooks 'gnus-apply-kill-hook)
2630 (if (and (zerop (buffer-size))
2633 ;; This newsgroup is empty.
2634 (gnus-summary-catchup-and-exit nil t)
2635 (gnus-message 6 "No unread news")
2637 (gnus-kill-or-deaden-summary kill-buffer))
2638 ;; Return nil from this function.
2640 ;; Hide conversation thread subtrees. We cannot do this in
2641 ;; gnus-summary-prepare-hook since kill processing may not
2642 ;; work with hidden articles.
2643 (and gnus-show-threads
2644 gnus-thread-hide-subtree
2645 (gnus-summary-hide-all-threads))
2646 ;; Show first unread article if requested.
2647 (if (and (not no-article)
2649 gnus-newsgroup-unreads
2650 gnus-auto-select-first)
2651 (unless (if (eq gnus-auto-select-first 'best)
2652 (gnus-summary-best-unread-article)
2653 (gnus-summary-first-unread-article))
2654 (gnus-configure-windows 'summary))
2655 ;; Don't select any articles, just move point to the first
2656 ;; article in the group.
2657 (goto-char (point-min))
2658 (gnus-summary-position-point)
2659 (gnus-set-mode-line 'summary)
2660 (gnus-configure-windows 'summary 'force))
2662 (gnus-kill-or-deaden-summary kill-buffer))
2663 (when (get-buffer-window gnus-group-buffer t)
2664 ;; Gotta use windows, because recenter does weird stuff if
2665 ;; the current buffer ain't the displayed window.
2666 (let ((owin (selected-window)))
2667 (select-window (get-buffer-window gnus-group-buffer t))
2668 (when (gnus-group-goto-group group)
2670 (select-window owin)))
2671 ;; Mark this buffer as "prepared".
2672 (setq gnus-newsgroup-prepared t)
2675 (defun gnus-summary-prepare ()
2676 "Generate the summary buffer."
2678 (let ((buffer-read-only nil))
2680 (setq gnus-newsgroup-data nil
2681 gnus-newsgroup-data-reverse nil)
2682 (run-hooks 'gnus-summary-generate-hook)
2683 ;; Generate the buffer, either with threads or without.
2684 (when gnus-newsgroup-headers
2685 (gnus-summary-prepare-threads
2686 (if gnus-show-threads
2687 (gnus-sort-gathered-threads
2688 (funcall gnus-summary-thread-gathering-function
2690 (gnus-cut-threads (gnus-make-threads)))))
2691 ;; Unthreaded display.
2692 (gnus-sort-articles gnus-newsgroup-headers))))
2693 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2694 ;; Call hooks for modifying summary buffer.
2695 (goto-char (point-min))
2696 (run-hooks 'gnus-summary-prepare-hook)))
2698 (defsubst gnus-general-simplify-subject (subject)
2699 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2702 ;; Truncate the subject.
2703 ((numberp gnus-summary-gather-subject-limit)
2704 (setq subject (gnus-simplify-subject-re subject))
2705 (if (> (length subject) gnus-summary-gather-subject-limit)
2706 (substring subject 0 gnus-summary-gather-subject-limit)
2708 ;; Fuzzily simplify it.
2709 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2710 (gnus-simplify-subject-fuzzy subject))
2711 ;; Just remove the leading "Re:".
2713 (gnus-simplify-subject-re subject))))
2715 (if (and gnus-summary-gather-exclude-subject
2716 (string-match gnus-summary-gather-exclude-subject subject))
2717 nil ; This article shouldn't be gathered
2720 (defun gnus-summary-simplify-subject-query ()
2721 "Query where the respool algorithm would put this article."
2723 (gnus-set-global-variables)
2724 (gnus-summary-select-article)
2725 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2727 (defun gnus-gather-threads-by-subject (threads)
2728 "Gather threads by looking at Subject headers."
2729 (if (not gnus-summary-make-false-root)
2731 (let ((hashtb (gnus-make-hashtable 1024))
2734 subject hthread whole-subject)
2736 (setq subject (gnus-general-simplify-subject
2737 (setq whole-subject (mail-header-subject
2740 (if (setq hthread (gnus-gethash subject hashtb))
2742 ;; We enter a dummy root into the thread, if we
2743 ;; haven't done that already.
2744 (unless (stringp (caar hthread))
2745 (setcar hthread (list whole-subject (car hthread))))
2746 ;; We add this new gathered thread to this gathered
2748 (setcdr (car hthread)
2749 (nconc (cdar hthread) (list (car threads))))
2750 ;; Remove it from the list of threads.
2751 (setcdr prev (cdr threads))
2752 (setq threads prev))
2753 ;; Enter this thread into the hash table.
2754 (gnus-sethash subject threads hashtb)))
2756 (setq threads (cdr threads)))
2759 (defun gnus-gather-threads-by-references (threads)
2760 "Gather threads by looking at References headers."
2761 (let ((idhashtb (gnus-make-hashtable 1024))
2762 (thhashtb (gnus-make-hashtable 1024))
2765 ids references id gthread gid entered ref)
2767 (when (setq references (mail-header-references (caar threads)))
2768 (setq id (mail-header-id (caar threads))
2769 ids (gnus-split-references references)
2771 (while (setq ref (pop ids))
2772 (setq ids (delete ref ids))
2773 (if (not (setq gid (gnus-gethash ref idhashtb)))
2775 (gnus-sethash ref id idhashtb)
2776 (gnus-sethash id threads thhashtb))
2777 (setq gthread (gnus-gethash gid thhashtb))
2779 ;; We enter a dummy root into the thread, if we
2780 ;; haven't done that already.
2781 (unless (stringp (caar gthread))
2782 (setcar gthread (list (mail-header-subject (caar gthread))
2784 ;; We add this new gathered thread to this gathered
2786 (setcdr (car gthread)
2787 (nconc (cdar gthread) (list (car threads)))))
2788 ;; Add it into the thread hash table.
2789 (gnus-sethash id gthread thhashtb)
2791 ;; Remove it from the list of threads.
2792 (setcdr prev (cdr threads))
2793 (setq threads prev))))
2795 (setq threads (cdr threads)))
2798 (defun gnus-sort-gathered-threads (threads)
2799 "Sort subtreads inside each gathered thread by article number."
2800 (let ((result threads))
2802 (when (stringp (caar threads))
2803 (setcdr (car threads)
2804 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2805 (setq threads (cdr threads)))
2808 (defun gnus-thread-loop-p (root thread)
2809 "Say whether ROOT is in THREAD."
2810 (let ((stack (list thread))
2813 (while (setq thread (pop stack))
2814 (setq th (cdr thread))
2816 (not (eq (caar th) root)))
2819 ;; We have found a loop.
2821 (setcdr thread (delq (car th) (cdr thread)))
2822 (if (boundp (setq ref-dep (intern "none"
2823 gnus-newsgroup-dependencies)))
2824 (setcdr (symbol-value ref-dep)
2825 (nconc (cdr (symbol-value ref-dep))
2827 (set ref-dep (list nil (car th))))
2830 ;; Push all the subthreads onto the stack.
2831 (push (cdr thread) stack)))
2834 (defun gnus-make-threads ()
2835 "Go through the dependency hashtb and find the roots. Return all threads."
2837 (while (catch 'infloop
2840 ;; Deal with self-referencing References loops.
2841 (when (and (car (symbol-value refs))
2848 (car (symbol-value refs)) thread))
2849 (cdr (symbol-value refs)))))))
2852 (unless (car (symbol-value refs))
2853 ;; These threads do not refer back to any other articles,
2854 ;; so they're roots.
2855 (setq threads (append (cdr (symbol-value refs)) threads))))
2856 gnus-newsgroup-dependencies)))
2859 (defun gnus-build-sparse-threads ()
2860 (let ((headers gnus-newsgroup-headers)
2861 (deps gnus-newsgroup-dependencies)
2862 header references generation relations
2863 cthread subject child end pthread relation)
2864 ;; First we create an alist of generations/relations, where
2865 ;; generations is how much we trust the relation, and the relation
2867 (gnus-message 7 "Making sparse threads...")
2869 (nnheader-set-temp-buffer " *gnus sparse threads*")
2870 (while (setq header (pop headers))
2871 (when (and (setq references (mail-header-references header))
2872 (not (string= references "")))
2874 (setq child (mail-header-id header)
2875 subject (mail-header-subject header))
2877 (while (search-backward ">" nil t)
2878 (setq end (1+ (point)))
2879 (when (search-backward "<" nil t)
2880 (push (list (incf generation)
2881 child (setq child (buffer-substring (point) end))
2884 (push (list (1+ generation) child nil subject) relations)
2886 (kill-buffer (current-buffer)))
2887 ;; Sort over trustworthiness.
2888 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2889 (while (setq relation (pop relations))
2890 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2891 (unless (car (symbol-value cthread))
2892 ;; Make this article the parent of these threads.
2893 (setcar (symbol-value cthread)
2894 (vector gnus-reffed-article-number
2898 (or (caddr relation) "") 0 0 "")))
2899 (set cthread (list (vector gnus-reffed-article-number
2901 "" "" (cadr relation)
2902 (or (caddr relation) "") 0 0 ""))))
2903 (push gnus-reffed-article-number gnus-newsgroup-limit)
2904 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2905 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2906 gnus-newsgroup-reads)
2907 (decf gnus-reffed-article-number)
2908 ;; Make this new thread the child of its parent.
2909 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2910 (setcdr (symbol-value pthread)
2911 (nconc (cdr (symbol-value pthread))
2912 (list (symbol-value cthread))))
2913 (set pthread (list nil (symbol-value cthread))))))
2914 (gnus-message 7 "Making sparse threads...done")))
2916 (defun gnus-build-old-threads ()
2917 ;; Look at all the articles that refer back to old articles, and
2918 ;; fetch the headers for the articles that aren't there. This will
2919 ;; build complete threads - if the roots haven't been expired by the
2924 (when (not (car (symbol-value refs)))
2925 (setq heads (cdr (symbol-value refs)))
2927 (if (memq (mail-header-number (caar heads))
2928 gnus-newsgroup-dormant)
2929 (setq heads (cdr heads))
2930 (setq id (symbol-name refs))
2931 (while (and (setq id (gnus-build-get-header id))
2932 (not (car (gnus-gethash
2933 id gnus-newsgroup-dependencies)))))
2934 (setq heads nil)))))
2935 gnus-newsgroup-dependencies)))
2937 (defun gnus-build-get-header (id)
2938 ;; Look through the buffer of NOV lines and find the header to
2939 ;; ID. Enter this line into the dependencies hash table, and return
2940 ;; the id of the parent article (if any).
2941 (let ((deps gnus-newsgroup-dependencies)
2945 (set-buffer nntp-server-buffer)
2946 (let ((case-fold-search nil))
2947 (goto-char (point-min))
2948 (while (and (not found)
2949 (search-forward id nil t))
2951 (setq found (looking-at
2952 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2953 (regexp-quote id))))
2954 (or found (beginning-of-line 2)))
2958 (setq header (gnus-nov-parse-line
2959 (read (current-buffer)) deps))
2960 (gnus-parent-id (mail-header-references header))))))
2962 (let ((number (mail-header-number header)))
2963 (push number gnus-newsgroup-limit)
2964 (push header gnus-newsgroup-headers)
2965 (if (memq number gnus-newsgroup-unselected)
2967 (push number gnus-newsgroup-unreads)
2968 (setq gnus-newsgroup-unselected
2969 (delq number gnus-newsgroup-unselected)))
2970 (push number gnus-newsgroup-ancient)))))))
2972 (defun gnus-summary-update-article-line (article header)
2973 "Update the line for ARTICLE using HEADERS."
2974 (let* ((id (mail-header-id header))
2975 (thread (gnus-id-to-thread id)))
2977 (error "Article in no thread"))
2978 ;; Update the thread.
2979 (setcar thread header)
2980 (gnus-summary-goto-subject article)
2981 (let* ((datal (gnus-data-find-list article))
2983 (length (when (cdr datal)
2984 (- (gnus-data-pos data)
2985 (gnus-data-pos (cadr datal)))))
2986 (buffer-read-only nil)
2987 (level (gnus-summary-thread-level)))
2989 (gnus-summary-insert-line
2990 header level nil (gnus-article-mark article)
2991 (memq article gnus-newsgroup-replied)
2992 (memq article gnus-newsgroup-expirable)
2993 ;; Only insert the Subject string when it's different
2994 ;; from the previous Subject string.
2995 (if (gnus-subject-equal
2997 (mail-header-subject
3000 (gnus-data-find-list
3002 (gnus-data-list t)))))
3003 ;; Error on the side of excessive subjects.
3005 (mail-header-subject header))
3007 (mail-header-subject header))
3008 nil (cdr (assq article gnus-newsgroup-scored))
3009 (memq article gnus-newsgroup-processable))
3011 (gnus-data-update-list
3012 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3014 (defun gnus-summary-update-article (article &optional iheader)
3015 "Update ARTICLE in the summary buffer."
3016 (set-buffer gnus-summary-buffer)
3017 (let* ((header (or iheader (gnus-summary-article-header article)))
3018 (id (mail-header-id header))
3019 (data (gnus-data-find article))
3020 (thread (gnus-id-to-thread id))
3021 (references (mail-header-references header))
3025 (when (and references
3026 (not (equal "" references)))
3029 (buffer-read-only nil)
3031 (number (mail-header-number header))
3034 ;; !!! Should this be in or not?
3036 (setcar thread nil))
3038 (delq thread parent))
3039 (if (gnus-summary-insert-subject id header iheader)
3040 ;; Set the (possibly) new article number in the data structure.
3041 (gnus-data-set-number data (gnus-id-to-article id))
3045 (defun gnus-rebuild-thread (id)
3046 "Rebuild the thread containing ID."
3047 (let ((buffer-read-only nil)
3048 old-pos current thread data)
3049 (if (not gnus-show-threads)
3050 (setq thread (list (car (gnus-id-to-thread id))))
3051 ;; Get the thread this article is part of.
3052 (setq thread (gnus-remove-thread id)))
3053 (setq old-pos (gnus-point-at-bol))
3054 (setq current (save-excursion
3055 (and (zerop (forward-line -1))
3056 (gnus-summary-article-number))))
3057 ;; If this is a gathered thread, we have to go some re-gathering.
3058 (when (stringp (car thread))
3059 (let ((subject (car thread))
3061 (setq thread (cdr thread))
3063 (unless (memq (setq thr (gnus-id-to-thread
3065 (mail-header-id (caar thread)))))
3068 (setq thread (cdr thread)))
3069 ;; We now have all (unique) roots.
3070 (if (= (length roots) 1)
3071 ;; All the loose roots are now one solid root.
3072 (setq thread (car roots))
3073 (setq thread (cons subject (gnus-sort-threads roots))))))
3075 ;; We then insert this thread into the summary buffer.
3076 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3077 (if gnus-show-threads
3078 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3079 (gnus-summary-prepare-unthreaded thread))
3080 (setq data (nreverse gnus-newsgroup-data))
3081 (setq threads gnus-newsgroup-threads))
3082 ;; We splice the new data into the data structure.
3083 (gnus-data-enter-list current data (- (point) old-pos))
3084 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3086 (defun gnus-number-to-header (number)
3087 "Return the header for article NUMBER."
3088 (let ((headers gnus-newsgroup-headers))
3090 (not (= number (mail-header-number (car headers)))))
3095 (defun gnus-parent-headers (headers &optional generation)
3096 "Return the headers of the GENERATIONeth parent of HEADERS."
3098 (setq generation 1))
3101 (while (and parent headers (not (zerop generation)))
3102 (setq references (mail-header-references headers))
3103 (when (and references
3104 (setq parent (gnus-parent-id references))
3105 (setq headers (car (gnus-id-to-thread parent))))
3109 (defun gnus-id-to-thread (id)
3110 "Return the (sub-)thread where ID appears."
3111 (gnus-gethash id gnus-newsgroup-dependencies))
3113 (defun gnus-id-to-article (id)
3114 "Return the article number of ID."
3115 (let ((thread (gnus-id-to-thread id)))
3118 (mail-header-number (car thread)))))
3120 (defun gnus-id-to-header (id)
3121 "Return the article headers of ID."
3122 (car (gnus-id-to-thread id)))
3124 (defun gnus-article-displayed-root-p (article)
3125 "Say whether ARTICLE is a root(ish) article."
3126 (let ((level (gnus-summary-thread-level article))
3127 (refs (mail-header-references (gnus-summary-article-header article)))
3133 ((null (gnus-parent-id refs)) t)
3135 (null (setq particle (gnus-id-to-article
3136 (gnus-parent-id refs))))
3137 (null (gnus-summary-thread-level particle)))))))
3139 (defun gnus-root-id (id)
3140 "Return the id of the root of the thread where ID appears."
3142 (while (and id (setq prev (car (gnus-gethash
3143 id gnus-newsgroup-dependencies))))
3145 id (gnus-parent-id (mail-header-references prev))))
3148 (defun gnus-remove-thread (id &optional dont-remove)
3149 "Remove the thread that has ID in it."
3150 (let ((dep gnus-newsgroup-dependencies)
3151 headers thread last-id)
3152 ;; First go up in this thread until we find the root.
3153 (setq last-id (gnus-root-id id))
3154 (setq headers (list (car (gnus-id-to-thread last-id))
3155 (caadr (gnus-id-to-thread last-id))))
3156 ;; We have now found the real root of this thread. It might have
3157 ;; been gathered into some loose thread, so we have to search
3158 ;; through the threads to find the thread we wanted.
3159 (let ((threads gnus-newsgroup-threads)
3162 (setq sub (car threads))
3163 (if (stringp (car sub))
3164 ;; This is a gathered thread, so we look at the roots
3165 ;; below it to find whether this article is in this
3168 (setq sub (cdr sub))
3170 (when (member (caar sub) headers)
3171 (setq thread (car threads)
3174 (setq sub (cdr sub))))
3175 ;; It's an ordinary thread, so we check it.
3176 (when (eq (car sub) (car headers))
3179 (setq threads (cdr threads)))
3180 ;; If this article is in no thread, then it's a root.
3183 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3184 (setq thread (gnus-gethash last-id dep)))
3187 thread ; We return this thread.
3189 (if (stringp (car thread))
3191 ;; If we use dummy roots, then we have to remove the
3192 ;; dummy root as well.
3193 (when (eq gnus-summary-make-false-root 'dummy)
3195 (gnus-data-compute-positions))
3196 (setq thread (cdr thread))
3198 (gnus-remove-thread-1 (car thread))
3199 (setq thread (cdr thread))))
3200 (gnus-remove-thread-1 thread))))))))
3202 (defun gnus-remove-thread-1 (thread)
3203 "Remove the thread THREAD recursively."
3204 (let ((number (mail-header-number (pop thread)))
3206 (setq thread (reverse thread))
3208 (gnus-remove-thread-1 (pop thread)))
3209 (when (setq d (gnus-data-find number))
3210 (goto-char (gnus-data-pos d))
3213 (- (gnus-point-at-bol)
3215 (1+ (gnus-point-at-eol))
3216 (gnus-delete-line)))))))
3218 (defun gnus-sort-threads (threads)
3220 (if (not gnus-thread-sort-functions)
3222 (gnus-message 7 "Sorting threads...")
3224 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3225 (gnus-message 7 "Sorting threads...done"))))
3227 (defun gnus-sort-articles (articles)
3229 (when gnus-article-sort-functions
3230 (gnus-message 7 "Sorting articles...")
3232 (setq gnus-newsgroup-headers
3233 (sort articles (gnus-make-sort-function
3234 gnus-article-sort-functions)))
3235 (gnus-message 7 "Sorting articles...done"))))
3237 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3238 (defmacro gnus-thread-header (thread)
3239 ;; Return header of first article in THREAD.
3240 ;; Note that THREAD must never, ever be anything else than a variable -
3241 ;; using some other form will lead to serious barfage.
3242 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3243 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3244 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3247 (defsubst gnus-article-sort-by-number (h1 h2)
3248 "Sort articles by article number."
3249 (< (mail-header-number h1)
3250 (mail-header-number h2)))
3252 (defun gnus-thread-sort-by-number (h1 h2)
3253 "Sort threads by root article number."
3254 (gnus-article-sort-by-number
3255 (gnus-thread-header h1) (gnus-thread-header h2)))
3257 (defsubst gnus-article-sort-by-lines (h1 h2)
3258 "Sort articles by article Lines header."
3259 (< (mail-header-lines h1)
3260 (mail-header-lines h2)))
3262 (defun gnus-thread-sort-by-lines (h1 h2)
3263 "Sort threads by root article Lines header."
3264 (gnus-article-sort-by-lines
3265 (gnus-thread-header h1) (gnus-thread-header h2)))
3267 (defsubst gnus-article-sort-by-author (h1 h2)
3268 "Sort articles by root author."
3270 (let ((extract (funcall
3271 gnus-extract-address-components
3272 (mail-header-from h1))))
3273 (or (car extract) (cadr extract) ""))
3274 (let ((extract (funcall
3275 gnus-extract-address-components
3276 (mail-header-from h2))))
3277 (or (car extract) (cadr extract) ""))))
3279 (defun gnus-thread-sort-by-author (h1 h2)
3280 "Sort threads by root author."
3281 (gnus-article-sort-by-author
3282 (gnus-thread-header h1) (gnus-thread-header h2)))
3284 (defsubst gnus-article-sort-by-subject (h1 h2)
3285 "Sort articles by root subject."
3287 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3288 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3290 (defun gnus-thread-sort-by-subject (h1 h2)
3291 "Sort threads by root subject."
3292 (gnus-article-sort-by-subject
3293 (gnus-thread-header h1) (gnus-thread-header h2)))
3295 (defsubst gnus-article-sort-by-date (h1 h2)
3296 "Sort articles by root article date."
3298 (gnus-date-get-time (mail-header-date h1))
3299 (gnus-date-get-time (mail-header-date h2))))
3301 (defun gnus-thread-sort-by-date (h1 h2)
3302 "Sort threads by root article date."
3303 (gnus-article-sort-by-date
3304 (gnus-thread-header h1) (gnus-thread-header h2)))
3306 (defsubst gnus-article-sort-by-score (h1 h2)
3307 "Sort articles by root article score.
3308 Unscored articles will be counted as having a score of zero."
3309 (> (or (cdr (assq (mail-header-number h1)
3310 gnus-newsgroup-scored))
3311 gnus-summary-default-score 0)
3312 (or (cdr (assq (mail-header-number h2)
3313 gnus-newsgroup-scored))
3314 gnus-summary-default-score 0)))
3316 (defun gnus-thread-sort-by-score (h1 h2)
3317 "Sort threads by root article score."
3318 (gnus-article-sort-by-score
3319 (gnus-thread-header h1) (gnus-thread-header h2)))
3321 (defun gnus-thread-sort-by-total-score (h1 h2)
3322 "Sort threads by the sum of all scores in the thread.
3323 Unscored articles will be counted as having a score of zero."
3324 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3326 (defun gnus-thread-total-score (thread)
3327 ;; This function find the total score of THREAD.
3328 (cond ((null thread)
3331 (if (stringp (car thread))
3332 (apply gnus-thread-score-function 0
3333 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3334 (gnus-thread-total-score-1 thread)))
3336 (gnus-thread-total-score-1 (list thread)))))
3338 (defun gnus-thread-total-score-1 (root)
3339 ;; This function find the total score of the thread below ROOT.
3340 (setq root (car root))
3341 (apply gnus-thread-score-function
3343 (mapcar 'gnus-thread-total-score
3344 (cdr (gnus-gethash (mail-header-id root)
3345 gnus-newsgroup-dependencies)))
3346 (when (> (mail-header-number root) 0)
3347 (list (or (cdr (assq (mail-header-number root)
3348 gnus-newsgroup-scored))
3349 gnus-summary-default-score 0))))
3350 (list gnus-summary-default-score)
3353 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3354 (defvar gnus-tmp-prev-subject nil)
3355 (defvar gnus-tmp-false-parent nil)
3356 (defvar gnus-tmp-root-expunged nil)
3357 (defvar gnus-tmp-dummy-line nil)
3359 (defun gnus-summary-prepare-threads (threads)
3360 "Prepare summary buffer from THREADS and indentation LEVEL.
3361 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3362 or a straight list of headers."
3363 (gnus-message 7 "Generating summary...")
3365 (setq gnus-newsgroup-threads threads)
3368 (let ((gnus-tmp-level 0)
3369 (default-score (or gnus-summary-default-score 0))
3370 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3371 thread number subject stack state gnus-tmp-gathered beg-match
3372 new-roots gnus-tmp-new-adopts thread-end
3373 gnus-tmp-header gnus-tmp-unread
3374 gnus-tmp-replied gnus-tmp-subject-or-nil
3375 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3376 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3377 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3379 (setq gnus-tmp-prev-subject nil)
3381 (if (vectorp (car threads))
3382 ;; If this is a straight (sic) list of headers, then a
3383 ;; threaded summary display isn't required, so we just create
3384 ;; an unthreaded one.
3385 (gnus-summary-prepare-unthreaded threads)
3387 ;; Do the threaded display.
3389 (while (or threads stack gnus-tmp-new-adopts new-roots)
3391 (if (and (= gnus-tmp-level 0)
3392 (not (setq gnus-tmp-dummy-line nil))
3395 (not gnus-tmp-false-parent)
3396 (or gnus-tmp-new-adopts new-roots))
3397 (if gnus-tmp-new-adopts
3398 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3399 thread (list (car gnus-tmp-new-adopts))
3400 gnus-tmp-header (caar thread)
3401 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3403 (setq thread (list (car new-roots))
3404 gnus-tmp-header (caar thread)
3405 new-roots (cdr new-roots))))
3408 ;; If there are some threads, we do them before the
3409 ;; threads on the stack.
3410 (setq thread threads
3411 gnus-tmp-header (caar thread))
3412 ;; There were no current threads, so we pop something off
3414 (setq state (car stack)
3415 gnus-tmp-level (car state)
3418 gnus-tmp-header (caar thread))))
3420 (setq gnus-tmp-false-parent nil)
3421 (setq gnus-tmp-root-expunged nil)
3422 (setq thread-end nil)
3424 (if (stringp gnus-tmp-header)
3425 ;; The header is a dummy root.
3427 ((eq gnus-summary-make-false-root 'adopt)
3428 ;; We let the first article adopt the rest.
3429 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3431 (setq gnus-tmp-gathered
3433 (lambda (h) (mail-header-number (car h)))
3436 (setq thread (cons (list (caar thread)
3439 (setq gnus-tmp-level -1
3440 gnus-tmp-false-parent t))
3441 ((eq gnus-summary-make-false-root 'empty)
3442 ;; We print adopted articles with empty subject fields.
3443 (setq gnus-tmp-gathered
3445 (lambda (h) (mail-header-number (car h)))
3448 (setq gnus-tmp-level -1))
3449 ((eq gnus-summary-make-false-root 'dummy)
3450 ;; We remember that we probably want to output a dummy
3452 (setq gnus-tmp-dummy-line gnus-tmp-header)
3453 (setq gnus-tmp-prev-subject gnus-tmp-header))
3455 ;; We do not make a root for the gathered
3456 ;; sub-threads at all.
3457 (setq gnus-tmp-level -1)))
3459 (setq number (mail-header-number gnus-tmp-header)
3460 subject (mail-header-subject gnus-tmp-header))
3463 ;; If the thread has changed subject, we might want to make
3464 ;; this subthread into a root.
3465 ((and (null gnus-thread-ignore-subject)
3466 (not (zerop gnus-tmp-level))
3467 gnus-tmp-prev-subject
3469 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3470 (setq new-roots (nconc new-roots (list (car thread)))
3472 gnus-tmp-header nil))
3473 ;; If the article lies outside the current limit,
3474 ;; then we do not display it.
3475 ((not (memq number gnus-newsgroup-limit))
3476 (setq gnus-tmp-gathered
3478 (lambda (h) (mail-header-number (car h)))
3481 (setq gnus-tmp-new-adopts (if (cdar thread)
3482 (append gnus-tmp-new-adopts
3484 gnus-tmp-new-adopts)
3486 gnus-tmp-header nil)
3487 (when (zerop gnus-tmp-level)
3488 (setq gnus-tmp-root-expunged t)))
3489 ;; Perhaps this article is to be marked as read?
3490 ((and gnus-summary-mark-below
3491 (< (or (cdr (assq number gnus-newsgroup-scored))
3493 gnus-summary-mark-below)
3494 ;; Don't touch sparse articles.
3495 (not (gnus-summary-article-sparse-p number))
3496 (not (gnus-summary-article-ancient-p number)))
3497 (setq gnus-newsgroup-unreads
3498 (delq number gnus-newsgroup-unreads))
3499 (if gnus-newsgroup-auto-expire
3500 (push number gnus-newsgroup-expirable)
3501 (push (cons number gnus-low-score-mark)
3502 gnus-newsgroup-reads))))
3504 (when gnus-tmp-header
3505 ;; We may have an old dummy line to output before this
3507 (when gnus-tmp-dummy-line
3508 (gnus-summary-insert-dummy-line
3509 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3510 (setq gnus-tmp-dummy-line nil))
3512 ;; Compute the mark.
3513 (setq gnus-tmp-unread (gnus-article-mark number))
3515 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3516 gnus-tmp-header gnus-tmp-level)
3517 gnus-newsgroup-data)
3519 ;; Actually insert the line.
3521 gnus-tmp-subject-or-nil
3523 ((and gnus-thread-ignore-subject
3524 gnus-tmp-prev-subject
3525 (not (inline (gnus-subject-equal
3526 gnus-tmp-prev-subject subject))))
3528 ((zerop gnus-tmp-level)
3529 (if (and (eq gnus-summary-make-false-root 'empty)
3530 (memq number gnus-tmp-gathered)
3531 gnus-tmp-prev-subject
3532 (inline (gnus-subject-equal
3533 gnus-tmp-prev-subject subject)))
3534 gnus-summary-same-subject
3536 (t gnus-summary-same-subject)))
3537 (if (and (eq gnus-summary-make-false-root 'adopt)
3538 (= gnus-tmp-level 1)
3539 (memq number gnus-tmp-gathered))
3540 (setq gnus-tmp-opening-bracket ?\<
3541 gnus-tmp-closing-bracket ?\>)
3542 (setq gnus-tmp-opening-bracket ?\[
3543 gnus-tmp-closing-bracket ?\]))
3545 gnus-tmp-indentation
3546 (aref gnus-thread-indent-array gnus-tmp-level)
3547 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3548 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3549 gnus-summary-default-score 0)
3551 (if (or (null gnus-summary-default-score)
3552 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3553 gnus-summary-zcore-fuzz))
3555 (if (< gnus-tmp-score gnus-summary-default-score)
3556 gnus-score-below-mark gnus-score-over-mark))
3558 (cond ((memq number gnus-newsgroup-processable)
3560 ((memq number gnus-newsgroup-cached)
3562 ((memq number gnus-newsgroup-replied)
3564 ((memq number gnus-newsgroup-saved)
3566 (t gnus-unread-mark))
3567 gnus-tmp-from (mail-header-from gnus-tmp-header)
3570 ((string-match "<[^>]+> *$" gnus-tmp-from)
3571 (setq beg-match (match-beginning 0))
3572 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3573 (substring gnus-tmp-from (1+ (match-beginning 0))
3574 (1- (match-end 0))))
3575 (substring gnus-tmp-from 0 beg-match)))
3576 ((string-match "(.+)" gnus-tmp-from)
3577 (substring gnus-tmp-from
3578 (1+ (match-beginning 0)) (1- (match-end 0))))
3580 (when (string= gnus-tmp-name "")
3581 (setq gnus-tmp-name gnus-tmp-from))
3582 (unless (numberp gnus-tmp-lines)
3583 (setq gnus-tmp-lines 0))
3584 (gnus-put-text-property
3586 (progn (eval gnus-summary-line-format-spec) (point))
3587 'gnus-number number)
3590 (run-hooks 'gnus-summary-update-hook)
3593 (setq gnus-tmp-prev-subject subject)))
3595 (when (nth 1 thread)
3596 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3597 (incf gnus-tmp-level)
3598 (setq threads (if thread-end nil (cdar thread)))
3600 (setq gnus-tmp-level 0)))))
3601 (gnus-message 7 "Generating summary...done"))
3603 (defun gnus-summary-prepare-unthreaded (headers)
3604 "Generate an unthreaded summary buffer based on HEADERS."
3605 (let (header number mark)
3610 ;; We may have to root out some bad articles...
3611 (when (memq (setq number (mail-header-number
3612 (setq header (pop headers))))
3613 gnus-newsgroup-limit)
3614 ;; Mark article as read when it has a low score.
3615 (when (and gnus-summary-mark-below
3616 (< (or (cdr (assq number gnus-newsgroup-scored))
3617 gnus-summary-default-score 0)
3618 gnus-summary-mark-below)
3619 (not (gnus-summary-article-ancient-p number)))
3620 (setq gnus-newsgroup-unreads
3621 (delq number gnus-newsgroup-unreads))
3622 (if gnus-newsgroup-auto-expire
3623 (push number gnus-newsgroup-expirable)
3624 (push (cons number gnus-low-score-mark)
3625 gnus-newsgroup-reads)))
3627 (setq mark (gnus-article-mark number))
3628 (push (gnus-data-make number mark (1+ (point)) header 0)
3629 gnus-newsgroup-data)
3630 (gnus-summary-insert-line
3632 mark (memq number gnus-newsgroup-replied)
3633 (memq number gnus-newsgroup-expirable)
3634 (mail-header-subject header) nil
3635 (cdr (assq number gnus-newsgroup-scored))
3636 (memq number gnus-newsgroup-processable))))))
3638 (defun gnus-select-newsgroup (group &optional read-all)
3639 "Select newsgroup GROUP.
3640 If READ-ALL is non-nil, all articles in the group are selected."
3641 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3642 ;;!!! Dirty hack; should be removed.
3643 (gnus-summary-ignore-duplicates
3644 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3646 gnus-summary-ignore-duplicates))
3647 (info (nth 2 entry))
3648 articles fetched-articles cached)
3650 (unless (gnus-check-server
3651 (setq gnus-current-select-method
3652 (gnus-find-method-for-group group)))
3653 (error "Couldn't open server"))
3655 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3656 (gnus-activate-group group) ; Or we can activate it...
3657 (progn ; Or we bug out.
3658 (when (equal major-mode 'gnus-summary-mode)
3659 (kill-buffer (current-buffer)))
3660 (error "Couldn't request group %s: %s"
3661 group (gnus-status-message group))))
3663 (unless (gnus-request-group group t)
3664 (when (equal major-mode 'gnus-summary-mode)
3665 (kill-buffer (current-buffer)))
3666 (error "Couldn't request group %s: %s"
3667 group (gnus-status-message group)))
3669 (setq gnus-newsgroup-name group)
3670 (setq gnus-newsgroup-unselected nil)
3671 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3673 ;; Adjust and set lists of article marks.
3675 (gnus-adjust-marked-articles info))
3677 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3678 (when (gnus-virtual-group-p group)
3679 (setq cached gnus-newsgroup-cached))
3681 (setq gnus-newsgroup-unreads
3682 (gnus-set-difference
3683 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3684 gnus-newsgroup-dormant))
3686 (setq gnus-newsgroup-processable nil)
3688 (gnus-update-read-articles group gnus-newsgroup-unreads)
3689 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3690 (gnus-group-update-group group))
3692 (setq articles (gnus-articles-to-read group read-all))
3696 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3698 ((eq articles 0) nil)
3700 ;; Init the dependencies hash table.
3701 (setq gnus-newsgroup-dependencies
3702 (gnus-make-hashtable (length articles)))
3703 ;; Retrieve the headers and read them in.
3704 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3705 (setq gnus-newsgroup-headers
3707 (setq gnus-headers-retrieved-by
3708 (gnus-retrieve-headers
3709 articles gnus-newsgroup-name
3710 ;; We might want to fetch old headers, but
3711 ;; not if there is only 1 article.
3712 (and gnus-fetch-old-headers
3714 (not (eq gnus-fetch-old-headers 'some))
3715 (not (numberp gnus-fetch-old-headers)))
3716 (> (length articles) 1))))))
3717 (gnus-get-newsgroup-headers-xover
3718 articles nil nil gnus-newsgroup-name t)
3719 (gnus-get-newsgroup-headers)))
3720 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3722 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3724 (setq gnus-newsgroup-cached cached))
3726 ;; Suppress duplicates?
3727 (when gnus-suppress-duplicates
3728 (gnus-dup-suppress-articles))
3730 ;; Set the initial limit.
3731 (setq gnus-newsgroup-limit (copy-sequence articles))
3732 ;; Remove canceled articles from the list of unread articles.
3733 (setq gnus-newsgroup-unreads
3734 (gnus-set-sorted-intersection
3735 gnus-newsgroup-unreads
3736 (setq fetched-articles
3737 (mapcar (lambda (headers) (mail-header-number headers))
3738 gnus-newsgroup-headers))))
3739 ;; Removed marked articles that do not exist.
3740 (gnus-update-missing-marks
3741 (gnus-sorted-complement fetched-articles articles))
3742 ;; Let the Gnus agent mark articles as read.
3744 (gnus-agent-get-undownloaded-list))
3745 ;; We might want to build some more threads first.
3746 (and gnus-fetch-old-headers
3747 (eq gnus-headers-retrieved-by 'nov)
3748 (gnus-build-old-threads))
3749 ;; Check whether auto-expire is to be done in this group.
3750 (setq gnus-newsgroup-auto-expire
3751 (gnus-group-auto-expirable-p group))
3752 ;; Set up the article buffer now, if necessary.
3753 (unless gnus-single-article-buffer
3754 (gnus-article-setup-buffer))
3755 ;; First and last article in this newsgroup.
3756 (when gnus-newsgroup-headers
3757 (setq gnus-newsgroup-begin
3758 (mail-header-number (car gnus-newsgroup-headers))
3761 (gnus-last-element gnus-newsgroup-headers))))
3762 ;; GROUP is successfully selected.
3763 (or gnus-newsgroup-headers t)))))
3765 (defun gnus-articles-to-read (group &optional read-all)
3766 ;; Find out what articles the user wants to read.
3768 ;; Select all articles if `read-all' is non-nil, or if there
3769 ;; are no unread articles.
3771 (and (zerop (length gnus-newsgroup-marked))
3772 (zerop (length gnus-newsgroup-unreads)))
3773 (eq (gnus-group-find-parameter group 'display)
3775 (gnus-uncompress-range (gnus-active group))
3776 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3777 (copy-sequence gnus-newsgroup-unreads))
3779 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3780 (scored (length scored-list))
3781 (number (length articles))
3782 (marked (+ (length gnus-newsgroup-marked)
3783 (length gnus-newsgroup-dormant)))
3791 ((and (or (<= scored marked) (= scored number))
3792 (numberp gnus-large-newsgroup)
3793 (> number gnus-large-newsgroup))
3797 "How many articles from %s (default %d): "
3798 (gnus-limit-string gnus-newsgroup-name 35)
3800 (if (string-match "^[ \t]*$" input) number input)))
3801 ((and (> scored marked) (< scored number)
3802 (> (- scored number) 20))
3805 (format "%s %s (%d scored, %d total): "
3806 "How many articles from"
3807 group scored number))))
3808 (if (string-match "^[ \t]*$" input)
3812 (setq select (if (stringp select) (string-to-number select) select))
3813 (if (or (null select) (zerop select))
3815 (if (and (not (zerop scored)) (<= (abs select) scored))
3817 (setq articles (sort scored-list '<))
3818 (setq number (length articles)))
3819 (setq articles (copy-sequence articles)))
3821 (when (< (abs select) number)
3823 ;; Select the N oldest articles.
3824 (setcdr (nthcdr (1- (abs select)) articles) nil)
3825 ;; Select the N most recent articles.
3826 (setq articles (nthcdr (- number select) articles))))
3827 (setq gnus-newsgroup-unselected
3828 (gnus-sorted-intersection
3829 gnus-newsgroup-unreads
3830 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3833 (defun gnus-killed-articles (killed articles)
3836 (when (inline (gnus-member-of-range (car articles) killed))
3837 (push (car articles) out))
3838 (setq articles (cdr articles)))
3841 (defun gnus-uncompress-marks (marks)
3842 "Uncompress the mark ranges in MARKS."
3843 (let ((uncompressed '(score bookmark))
3846 (if (memq (caar marks) uncompressed)
3847 (push (car marks) out)
3848 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3849 (setq marks (cdr marks)))
3852 (defun gnus-adjust-marked-articles (info)
3853 "Set all article lists and remove all marks that are no longer legal."
3854 (let* ((marked-lists (gnus-info-marks info))
3855 (active (gnus-active (gnus-info-group info)))
3858 (types gnus-article-mark-lists)
3859 (uncompressed '(score bookmark killed))
3860 marks var articles article mark)
3863 (setq marks (pop marked-lists))
3864 (set (setq var (intern (format "gnus-newsgroup-%s"
3865 (car (rassq (setq mark (car marks))
3867 (if (memq (car marks) uncompressed) (cdr marks)
3868 (gnus-uncompress-range (cdr marks))))
3870 (setq articles (symbol-value var))
3872 ;; All articles have to be subsets of the active articles.
3874 ;; Adjust "simple" lists.
3875 ((memq mark '(tick dormant expire reply save))
3877 (when (or (< (setq article (pop articles)) min) (> article max))
3878 (set var (delq article (symbol-value var))))))
3880 ((memq mark uncompressed)
3881 (when (not (listp (cdr (symbol-value var))))
3882 (set var (list (symbol-value var))))
3883 (when (not (listp (cdr articles)))
3884 (setq articles (list articles)))
3886 (when (or (not (consp (setq article (pop articles))))
3887 (< (car article) min)
3888 (> (car article) max))
3889 (set var (delq article (symbol-value var))))))))))
3891 (defun gnus-update-missing-marks (missing)
3892 "Go through the list of MISSING articles and remove them mark lists."
3894 (let ((types gnus-article-mark-lists)
3896 ;; Go through all types.
3898 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3899 (when (symbol-value var)
3900 ;; This list has articles. So we delete all missing articles
3904 (set var (delq (pop m) (symbol-value var)))))))))
3906 (defun gnus-update-marks ()
3907 "Enter the various lists of marked articles into the newsgroup info list."
3908 (let ((types gnus-article-mark-lists)
3909 (info (gnus-get-info gnus-newsgroup-name))
3910 (uncompressed '(score bookmark killed))
3911 type list newmarked symbol)
3913 ;; Add all marks lists that are non-nil to the list of marks lists.
3914 (while (setq type (pop types))
3915 (when (setq list (symbol-value
3917 (intern (format "gnus-newsgroup-%s"
3920 ;; Get rid of the entries of the articles that have the
3922 (when (and (eq (cdr type) 'score)
3926 (prev (cons nil list))
3929 (if (or (not (consp (car arts)))
3930 (= (cdar arts) gnus-summary-default-score))
3931 (setcdr prev (cdr arts))
3933 (setq arts (cdr arts)))
3934 (setq list (cdr all))))
3936 (push (cons (cdr type)
3937 (if (memq (cdr type) uncompressed) list
3938 (gnus-compress-sequence
3939 (set symbol (sort list '<)) t)))
3942 ;; Enter these new marks into the info of the group.
3944 (setcar (nthcdr 3 info) newmarked)
3945 ;; Add the marks lists to the end of the info.
3947 (setcdr (nthcdr 2 info) (list newmarked))))
3949 ;; Cut off the end of the info if there's nothing else there.
3953 (when (nthcdr (decf i) info)
3954 (setcdr (nthcdr i info) nil)))))))
3956 (defun gnus-set-mode-line (where)
3957 "This function sets the mode line of the article or summary buffers.
3958 If WHERE is `summary', the summary mode line format will be used."
3959 ;; Is this mode line one we keep updated?
3960 (when (memq where gnus-updated-mode-lines)
3963 ;; We evaluate this in the summary buffer since these
3964 ;; variables are buffer-local to that buffer.
3965 (set-buffer gnus-summary-buffer)
3966 ;; We bind all these variables that are used in the `eval' form
3968 (let* ((mformat (symbol-value
3970 (format "gnus-%s-mode-line-format-spec" where))))
3971 (gnus-tmp-group-name gnus-newsgroup-name)
3972 (gnus-tmp-article-number (or gnus-current-article 0))
3973 (gnus-tmp-unread gnus-newsgroup-unreads)
3974 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3975 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3976 (gnus-tmp-unread-and-unselected
3977 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3978 (zerop gnus-tmp-unselected))
3980 ((zerop gnus-tmp-unselected)
3981 (format "{%d more}" gnus-tmp-unread-and-unticked))
3982 (t (format "{%d(+%d) more}"
3983 gnus-tmp-unread-and-unticked
3984 gnus-tmp-unselected))))
3986 (if (and gnus-current-headers
3987 (vectorp gnus-current-headers))
3988 (gnus-mode-string-quote
3989 (mail-header-subject gnus-current-headers))
3991 bufname-length max-len
3992 gnus-tmp-header);; passed as argument to any user-format-funcs
3993 (setq mode-string (eval mformat))
3994 (setq bufname-length (if (string-match "%b" mode-string)
3997 (if (eq where 'summary)
3999 (get-buffer gnus-article-buffer))))
4002 (setq max-len (max 4 (if gnus-mode-non-string-length
4004 gnus-mode-non-string-length
4006 (length mode-string))))
4007 ;; We might have to chop a bit of the string off...
4008 (when (> (length mode-string) max-len)
4010 (concat (gnus-truncate-string mode-string (- max-len 3))
4012 ;; Pad the mode string a bit.
4013 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4014 ;; Update the mode line.
4015 (setq mode-line-buffer-identification
4016 (gnus-mode-line-buffer-identification (list mode-string)))
4017 (set-buffer-modified-p t))))
4019 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4020 "Go through the HEADERS list and add all Xrefs to a hash table.
4021 The resulting hash table is returned, or nil if no Xrefs were found."
4022 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4023 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4024 (xref-hashtb (gnus-make-hashtable))
4025 start group entry number xrefs header)
4027 (setq header (pop headers))
4028 (when (and (setq xrefs (mail-header-xref header))
4029 (not (memq (setq number (mail-header-number header))
4032 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4033 (setq start (match-end 0))
4034 (setq group (if prefix
4035 (concat prefix (substring xrefs (match-beginning 1)
4037 (substring xrefs (match-beginning 1) (match-end 1))))
4039 (string-to-int (substring xrefs (match-beginning 2)
4041 (if (setq entry (gnus-gethash group xref-hashtb))
4042 (setcdr entry (cons number (cdr entry)))
4043 (gnus-sethash group (cons number nil) xref-hashtb)))))
4044 (and start xref-hashtb)))
4046 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4047 "Look through all the headers and mark the Xrefs as read."
4048 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4049 name entry info xref-hashtb idlist method nth4)
4051 (set-buffer gnus-group-buffer)
4052 (when (setq xref-hashtb
4053 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4056 (unless (string= from-newsgroup (setq name (symbol-name group)))
4057 (setq idlist (symbol-value group))
4058 ;; Dead groups are not updated.
4060 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4062 (when (stringp (setq nth4 (gnus-info-method info)))
4063 (setq nth4 (gnus-server-to-method nth4))))
4064 ;; Only do the xrefs if the group has the same
4065 ;; select method as the group we have just read.
4066 (or (gnus-methods-equal-p
4067 nth4 (gnus-find-method-for-group from-newsgroup))
4069 (equal nth4 (setq method (gnus-find-method-for-group
4071 (and (equal (car nth4) (car method))
4072 (equal (nth 1 nth4) (nth 1 method))))
4073 gnus-use-cross-reference
4074 (or (not (eq gnus-use-cross-reference t))
4076 ;; Only do cross-references on subscribed
4077 ;; groups, if that is what is wanted.
4078 (<= (gnus-info-level info) gnus-level-subscribed))
4079 (gnus-group-make-articles-read name idlist))))
4082 (defun gnus-group-make-articles-read (group articles)
4083 "Update the info of GROUP to say that ARTICLES are read."
4085 (entry (gnus-gethash group gnus-newsrc-hashtb))
4086 (info (nth 2 entry))
4087 (active (gnus-active group))
4090 ;; First peel off all illegal article numbers.
4092 (let ((ids articles)
4094 (while (setq id (pop ids))
4095 (when (and first (> id (cdr active)))
4096 ;; We'll end up in this situation in one particular
4097 ;; obscure situation. If you re-scan a group and get
4098 ;; a new article that is cross-posted to a different
4099 ;; group that has not been re-scanned, you might get
4100 ;; crossposted article that has a higher number than
4101 ;; Gnus believes possible. So we re-activate this
4102 ;; group as well. This might mean doing the
4103 ;; crossposting thingy will *increase* the number
4104 ;; of articles in some groups. Tsk, tsk.
4105 (setq active (or (gnus-activate-group group) active)))
4106 (when (or (> id (cdr active))
4107 (< id (car active)))
4108 (setq articles (delq id articles))))))
4110 (set-buffer gnus-group-buffer)
4113 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4114 (gnus-info-set-read ',info ',(gnus-info-read info))
4115 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4116 (gnus-group-update-group ,group t))))
4117 ;; If the read list is nil, we init it.
4119 (null (gnus-info-read info))
4121 (gnus-info-set-read info (cons 1 (1- (car active)))))
4122 ;; Then we add the read articles to the range.
4127 (gnus-info-read info) (setq articles (sort articles '<)))))
4128 ;; Then we have to re-compute how many unread
4129 ;; articles there are in this group.
4133 (setq num (- (1+ (cdr active)) (car active))))
4134 ((not (listp (cdr range)))
4135 (setq num (- (cdr active) (- (1+ (cdr range))
4139 (if (numberp (car range))
4141 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4142 (setq range (cdr range)))
4143 (setq num (- (cdr active) num))))
4144 ;; Update the number of unread articles.
4146 ;; Update the group buffer.
4147 (gnus-group-update-group group t)))))
4149 (defun gnus-methods-equal-p (m1 m2)
4150 (let ((m1 (or m1 gnus-select-method))
4151 (m2 (or m2 gnus-select-method)))
4153 (and (eq (car m1) (car m2))
4154 (or (not (memq 'address (assoc (symbol-name (car m1))
4155 gnus-valid-select-methods)))
4156 (equal (nth 1 m1) (nth 1 m2)))))))
4158 (defvar gnus-newsgroup-none-id 0)
4160 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4161 (let ((cur nntp-server-buffer)
4164 (save-excursion (set-buffer gnus-summary-buffer)
4165 gnus-newsgroup-dependencies)))
4166 headers id id-dep ref-dep end ref)
4168 (set-buffer nntp-server-buffer)
4169 ;; Translate all TAB characters into SPACE characters.
4170 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4171 (run-hooks 'gnus-parse-headers-hook)
4172 (let ((case-fold-search t)
4173 in-reply-to header p lines)
4174 (goto-char (point-min))
4175 ;; Search to the beginning of the next header. Error messages
4176 ;; do not begin with 2 or 3.
4177 (while (re-search-forward "^[23][0-9]+ " nil t)
4180 ;; This implementation of this function, with nine
4181 ;; search-forwards instead of the one re-search-forward and
4182 ;; a case (which basically was the old function) is actually
4183 ;; about twice as fast, even though it looks messier. You
4184 ;; can't have everything, I guess. Speed and elegance
4185 ;; doesn't always go hand in hand.
4194 (narrow-to-region (point)
4195 (or (and (search-forward "\n.\n" nil t)
4201 (if (search-forward "\nsubject: " nil t)
4202 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4204 gnus-unstructured-field-decoder (nnheader-header-value))
4209 (if (search-forward "\nfrom: " nil t)
4210 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4212 gnus-structured-field-decoder (nnheader-header-value))
4217 (if (search-forward "\ndate: " nil t)
4218 (nnheader-header-value) ""))
4222 (setq id (if (search-forward "\nmessage-id:" nil t)
4224 (1- (or (search-forward "<" nil t) (point)))
4225 (or (search-forward ">" nil t) (point)))
4226 ;; If there was no message-id, we just fake one
4227 ;; to make subsequent routines simpler.
4228 (nnheader-generate-fake-message-id))))
4232 (if (search-forward "\nreferences: " nil t)
4236 (nnheader-header-value)
4241 (search-backward ">" end t)
4244 (search-backward "<" end t)
4246 ;; Get the references from the in-reply-to header if there
4247 ;; were no references and the in-reply-to header looks
4249 (if (and (search-forward "\nin-reply-to: " nil t)
4250 (setq in-reply-to (nnheader-header-value))
4251 (string-match "<[^>]+>" in-reply-to))
4252 (setq ref (substring in-reply-to (match-beginning 0)
4260 (if (search-forward "\nlines: " nil t)
4261 (if (numberp (setq lines (ignore-errors (read cur))))
4267 (and (search-forward "\nxref: " nil t)
4268 (nnheader-header-value)))))
4269 (when (equal id ref)
4271 ;; We do the threading while we read the headers. The
4272 ;; message-id and the last reference are both entered into
4273 ;; the same hash table. Some tippy-toeing around has to be
4274 ;; done in case an article has arrived before the article
4275 ;; which it refers to.
4276 (if (boundp (setq id-dep (intern id dependencies)))
4277 (if (and (car (symbol-value id-dep))
4279 ;; An article with this Message-ID has already been seen.
4280 (if gnus-summary-ignore-duplicates
4281 ;; We ignore this one, except we add
4282 ;; any additional Xrefs (in case the two articles
4283 ;; came from different servers).
4285 (mail-header-set-xref
4286 (car (symbol-value id-dep))
4287 (concat (or (mail-header-xref
4288 (car (symbol-value id-dep)))
4290 (or (mail-header-xref header) "")))
4292 ;; We rename the Message-ID.
4294 (setq id-dep (intern (setq id (nnmail-message-id))
4297 (mail-header-set-id header id))
4298 (setcar (symbol-value id-dep) header))
4299 (set id-dep (list header)))
4301 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4302 (setcdr (symbol-value ref-dep)
4303 (nconc (cdr (symbol-value ref-dep))
4304 (list (symbol-value id-dep))))
4305 (set ref-dep (list nil (symbol-value id-dep))))
4306 (push header headers))
4307 (goto-char (point-max))
4309 (nreverse headers)))))
4311 ;; The following macros and functions were written by Felix Lee
4312 ;; <flee@cse.psu.edu>.
4314 (defmacro gnus-nov-read-integer ()
4316 (if (= (following-char) ?\t)
4318 (let ((num (ignore-errors (read buffer))))
4319 (if (numberp num) num 0)))
4323 (defmacro gnus-nov-skip-field ()
4324 '(search-forward "\t" eol 'move))
4326 (defmacro gnus-nov-field ()
4327 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4329 ;; (defvar gnus-nov-none-counter 0)
4331 ;; This function has to be called with point after the article number
4332 ;; on the beginning of the line.
4333 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4334 (let ((eol (gnus-point-at-eol))
4335 (buffer (current-buffer))
4336 header ref id id-dep ref-dep)
4338 ;; overview: [num subject from date id refs chars lines misc]
4341 (narrow-to-region (point) eol)
4348 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4350 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4352 gnus-structured-field-decoder (gnus-nov-field)) ; from
4353 (gnus-nov-field) ; date
4354 (setq id (or (gnus-nov-field)
4355 (nnheader-generate-fake-message-id))) ; id
4357 (let ((beg (point)))
4358 (search-forward "\t" eol)
4359 (if (search-backward ">" beg t)
4363 (search-backward "<" beg t)))
4366 (gnus-nov-field)) ; refs
4367 (gnus-nov-read-integer) ; chars
4368 (gnus-nov-read-integer) ; lines
4369 (if (= (following-char) ?\n)
4371 (gnus-nov-field))))) ; misc
4375 ;; We build the thread tree.
4376 (when (equal id ref)
4377 ;; This article refers back to itself. Naughty, naughty.
4379 (if (boundp (setq id-dep (intern id dependencies)))
4380 (if (and (car (symbol-value id-dep))
4382 ;; An article with this Message-ID has already been seen.
4383 (if gnus-summary-ignore-duplicates
4384 ;; We ignore this one, except we add any additional
4385 ;; Xrefs (in case the two articles came from different
4388 (mail-header-set-xref
4389 (car (symbol-value id-dep))
4390 (concat (or (mail-header-xref
4391 (car (symbol-value id-dep)))
4393 (or (mail-header-xref header) "")))
4395 ;; We rename the Message-ID.
4397 (setq id-dep (intern (setq id (nnmail-message-id))
4400 (mail-header-set-id header id))
4401 (setcar (symbol-value id-dep) header))
4402 (set id-dep (list header)))
4404 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4405 (setcdr (symbol-value ref-dep)
4406 (nconc (cdr (symbol-value ref-dep))
4407 (list (symbol-value id-dep))))
4408 (set ref-dep (list nil (symbol-value id-dep)))))
4411 ;; Goes through the xover lines and returns a list of vectors
4412 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4413 force-new dependencies
4414 group also-fetch-heads)
4415 "Parse the news overview data in the server buffer, and return a
4416 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4417 ;; Get the Xref when the users reads the articles since most/some
4418 ;; NNTP servers do not include Xrefs when using XOVER.
4419 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4420 (let ((cur nntp-server-buffer)
4421 (dependencies (or dependencies gnus-newsgroup-dependencies))
4422 number headers header)
4424 (set-buffer nntp-server-buffer)
4425 ;; Allow the user to mangle the headers before parsing them.
4426 (run-hooks 'gnus-parse-headers-hook)
4427 (goto-char (point-min))
4430 (while (and sequence (not (eobp)))
4431 (setq number (read cur))
4432 (while (and sequence
4433 (< (car sequence) number))
4434 (setq sequence (cdr sequence)))
4436 (eq number (car sequence))
4438 (setq sequence (cdr sequence))
4439 (setq header (inline
4440 (gnus-nov-parse-line
4441 number dependencies force-new))))
4442 (push header headers))
4445 (gnus-error 4 "Strange nov line (%d)"
4446 (count-lines (point-min) (point)))))
4448 ;; A common bug in inn is that if you have posted an article and
4449 ;; then retrieves the active file, it will answer correctly --
4450 ;; the new article is included. However, a NOV entry for the
4451 ;; article may not have been generated yet, so this may fail.
4452 ;; We work around this problem by retrieving the last few
4453 ;; headers using HEAD.
4454 (if (or (not also-fetch-heads)
4456 ;; We (probably) got all the headers.
4458 (let ((gnus-nov-is-evil t))
4461 (when (gnus-retrieve-headers sequence group)
4462 (gnus-get-newsgroup-headers))))))))
4464 (defun gnus-article-get-xrefs ()
4465 "Fill in the Xref value in `gnus-current-headers', if necessary.
4466 This is meant to be called in `gnus-article-internal-prepare-hook'."
4467 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4468 gnus-current-headers)))
4469 (or (not gnus-use-cross-reference)
4471 (and (mail-header-xref headers)
4472 (not (string= (mail-header-xref headers) "")))
4473 (let ((case-fold-search t)
4476 (nnheader-narrow-to-headers)
4477 (goto-char (point-min))
4478 (when (or (and (eq (downcase (following-char)) ?x)
4479 (looking-at "Xref:"))
4480 (search-forward "\nXref:" nil t))
4481 (goto-char (1+ (match-end 0)))
4482 (setq xref (buffer-substring (point)
4483 (progn (end-of-line) (point))))
4484 (mail-header-set-xref headers xref)))))))
4486 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4487 "Find article ID and insert the summary line for that article."
4488 (let ((header (if (and old-header use-old-header)
4489 old-header (gnus-read-header id)))
4490 (number (and (numberp id) id))
4493 ;; Rebuild the thread that this article is part of and go to the
4494 ;; article we have fetched.
4495 (when (and (not gnus-show-threads)
4497 (when (setq d (gnus-data-find (mail-header-number old-header)))
4498 (goto-char (gnus-data-pos d))
4501 (- (gnus-point-at-bol)
4503 (1+ (gnus-point-at-eol))
4504 (gnus-delete-line))))))
4506 (mail-header-set-number header (mail-header-number old-header)))
4507 (setq gnus-newsgroup-sparse
4508 (delq (setq number (mail-header-number header))
4509 gnus-newsgroup-sparse))
4510 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4511 (gnus-rebuild-thread (mail-header-id header))
4512 (gnus-summary-goto-subject number nil t))
4513 (when (and (numberp number)
4515 ;; We have to update the boundaries even if we can't fetch the
4516 ;; article if ID is a number -- so that the next `P' or `N'
4517 ;; command will fetch the previous (or next) article even
4518 ;; if the one we tried to fetch this time has been canceled.
4519 (when (> number gnus-newsgroup-end)
4520 (setq gnus-newsgroup-end number))
4521 (when (< number gnus-newsgroup-begin)
4522 (setq gnus-newsgroup-begin number))
4523 (setq gnus-newsgroup-unselected
4524 (delq number gnus-newsgroup-unselected)))
4525 ;; Report back a success?
4526 (and header (mail-header-number header))))
4528 ;;; Process/prefix in the summary buffer
4530 (defun gnus-summary-work-articles (n)
4531 "Return a list of articles to be worked upon. The prefix argument,
4532 the list of process marked articles, and the current article will be
4533 taken into consideration."
4536 ;; A numerical prefix has been given.
4537 (setq n (prefix-numeric-value n))
4538 (let ((backward (< n 0))
4539 (n (abs (prefix-numeric-value n)))
4544 (push (setq article (gnus-summary-article-number))
4547 (gnus-summary-find-prev nil article)
4548 (gnus-summary-find-next nil article)))
4550 (nreverse articles)))
4551 ((gnus-region-active-p)
4552 ;; Work on the region between point and mark.
4553 (let ((max (max (point) (mark)))
4556 (goto-char (min (point) (mark)))
4559 (push (setq article (gnus-summary-article-number)) articles)
4560 (gnus-summary-find-next nil article)
4562 (nreverse articles))))
4563 (gnus-newsgroup-processable
4564 ;; There are process-marked articles present.
4565 ;; Save current state.
4566 (gnus-summary-save-process-mark)
4568 (reverse gnus-newsgroup-processable))
4570 ;; Just return the current article.
4571 (list (gnus-summary-article-number)))))
4573 (defun gnus-summary-save-process-mark ()
4574 "Push the current set of process marked articles on the stack."
4576 (push (copy-sequence gnus-newsgroup-processable)
4577 gnus-newsgroup-process-stack))
4579 (defun gnus-summary-kill-process-mark ()
4580 "Push the current set of process marked articles on the stack and unmark."
4582 (gnus-summary-save-process-mark)
4583 (gnus-summary-unmark-all-processable))
4585 (defun gnus-summary-yank-process-mark ()
4586 "Pop the last process mark state off the stack and restore it."
4588 (unless gnus-newsgroup-process-stack
4589 (error "Empty mark stack"))
4590 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4592 (defun gnus-summary-process-mark-set (set)
4593 "Make SET into the current process marked articles."
4594 (gnus-summary-unmark-all-processable)
4596 (gnus-summary-set-process-mark (pop set))))
4598 ;;; Searching and stuff
4600 (defun gnus-summary-search-group (&optional backward use-level)
4601 "Search for next unread newsgroup.
4602 If optional argument BACKWARD is non-nil, search backward instead."
4604 (set-buffer gnus-group-buffer)
4605 (when (gnus-group-search-forward
4606 backward nil (if use-level (gnus-group-group-level) nil))
4607 (gnus-group-group-name))))
4609 (defun gnus-summary-best-group (&optional exclude-group)
4610 "Find the name of the best unread group.
4611 If EXCLUDE-GROUP, do not go to this group."
4613 (set-buffer gnus-group-buffer)
4615 (gnus-group-best-unread-group exclude-group))))
4617 (defun gnus-summary-find-next (&optional unread article backward)
4618 (if backward (gnus-summary-find-prev)
4619 (let* ((dummy (gnus-summary-article-intangible-p))
4620 (article (or article (gnus-summary-article-number)))
4621 (arts (gnus-data-find-list article))
4623 (when (and (not dummy)
4624 (or (not gnus-summary-check-current)
4626 (not (gnus-data-unread-p (car arts)))))
4627 (setq arts (cdr arts)))
4632 (when (gnus-data-unread-p (car arts))
4633 (setq result (car arts)
4635 (setq arts (cdr arts)))
4638 (goto-char (gnus-data-pos result))
4639 (gnus-data-number result)))))
4641 (defun gnus-summary-find-prev (&optional unread article)
4642 (let* ((eobp (eobp))
4643 (article (or article (gnus-summary-article-number)))
4644 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4646 (when (and (not eobp)
4647 (or (not gnus-summary-check-current)
4649 (not (gnus-data-unread-p (car arts)))))
4650 (setq arts (cdr arts)))
4655 (when (gnus-data-unread-p (car arts))
4656 (setq result (car arts)
4658 (setq arts (cdr arts)))
4661 (goto-char (gnus-data-pos result))
4662 (gnus-data-number result))))
4664 (defun gnus-summary-find-subject (subject &optional unread backward article)
4665 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4666 (article (or article (gnus-summary-article-number)))
4667 (articles (gnus-data-list backward))
4668 (arts (gnus-data-find-list article articles))
4670 (when (or (not gnus-summary-check-current)
4672 (not (gnus-data-unread-p (car arts))))
4673 (setq arts (cdr arts)))
4675 (and (or (not unread)
4676 (gnus-data-unread-p (car arts)))
4677 (vectorp (gnus-data-header (car arts)))
4679 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4680 (setq result (car arts)
4682 (setq arts (cdr arts)))
4684 (goto-char (gnus-data-pos result))
4685 (gnus-data-number result))))
4687 (defun gnus-summary-search-forward (&optional unread subject backward)
4688 "Search forward for an article.
4689 If UNREAD, look for unread articles. If SUBJECT, look for
4690 articles with that subject. If BACKWARD, search backward instead."
4691 (cond (subject (gnus-summary-find-subject subject unread backward))
4692 (backward (gnus-summary-find-prev unread))
4693 (t (gnus-summary-find-next unread))))
4695 (defun gnus-recenter (&optional n)
4696 "Center point in window and redisplay frame.
4697 Also do horizontal recentering."
4699 (when (and gnus-auto-center-summary
4700 (not (eq gnus-auto-center-summary 'vertical)))
4701 (gnus-horizontal-recenter))
4704 (defun gnus-summary-recenter ()
4705 "Center point in the summary window.
4706 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4707 displayed, no centering will be performed."
4708 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4709 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4710 (let* ((top (cond ((< (window-height) 4) 0)
4711 ((< (window-height) 7) 1)
4713 (height (1- (window-height)))
4714 (bottom (save-excursion (goto-char (point-max))
4715 (forward-line (- height))
4717 (window (get-buffer-window (current-buffer))))
4718 ;; The user has to want it.
4719 (when gnus-auto-center-summary
4720 (when (get-buffer-window gnus-article-buffer)
4721 ;; Only do recentering when the article buffer is displayed,
4722 ;; Set the window start to either `bottom', which is the biggest
4723 ;; possible valid number, or the second line from the top,
4724 ;; whichever is the least.
4726 window (min bottom (save-excursion
4727 (forward-line (- top)) (point)))))
4728 ;; Do horizontal recentering while we're at it.
4729 (when (and (get-buffer-window (current-buffer) t)
4730 (not (eq gnus-auto-center-summary 'vertical)))
4731 (let ((selected (selected-window)))
4732 (select-window (get-buffer-window (current-buffer) t))
4733 (gnus-summary-position-point)
4734 (gnus-horizontal-recenter)
4735 (select-window selected))))))
4737 (defun gnus-summary-jump-to-group (newsgroup)
4738 "Move point to NEWSGROUP in group mode buffer."
4739 ;; Keep update point of group mode buffer if visible.
4740 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4741 (save-window-excursion
4742 ;; Take care of tree window mode.
4743 (when (get-buffer-window gnus-group-buffer)
4744 (pop-to-buffer gnus-group-buffer))
4745 (gnus-group-jump-to-group newsgroup))
4747 ;; Take care of tree window mode.
4748 (if (get-buffer-window gnus-group-buffer)
4749 (pop-to-buffer gnus-group-buffer)
4750 (set-buffer gnus-group-buffer))
4751 (gnus-group-jump-to-group newsgroup))))
4753 ;; This function returns a list of article numbers based on the
4754 ;; difference between the ranges of read articles in this group and
4755 ;; the range of active articles.
4756 (defun gnus-list-of-unread-articles (group)
4757 (let* ((read (gnus-info-read (gnus-get-info group)))
4758 (active (or (gnus-active group) (gnus-activate-group group)))
4761 ;; If none are read, then all are unread.
4763 (setq first (car active))
4764 ;; If the range of read articles is a single range, then the
4765 ;; first unread article is the article after the last read
4766 ;; article. Sounds logical, doesn't it?
4767 (if (not (listp (cdr read)))
4768 (setq first (1+ (cdr read)))
4769 ;; `read' is a list of ranges.
4770 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4776 (while (< first nlast)
4778 (setq first (1+ first))))
4779 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4780 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4781 (setq read (cdr read)))))
4782 ;; And add the last unread articles.
4783 (while (<= first last)
4785 (setq first (1+ first)))
4786 ;; Return the list of unread articles.
4787 (delq 0 (nreverse unread))))
4789 (defun gnus-list-of-read-articles (group)
4790 "Return a list of unread, unticked and non-dormant articles."
4791 (let* ((info (gnus-get-info group))
4792 (marked (gnus-info-marks info))
4793 (active (gnus-active group)))
4795 (gnus-set-difference
4796 (gnus-sorted-complement
4797 (gnus-uncompress-range active)
4798 (gnus-list-of-unread-articles group))
4800 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4801 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4803 ;; Various summary commands
4805 (defun gnus-summary-universal-argument (arg)
4806 "Perform any operation on all articles that are process/prefixed."
4808 (gnus-set-global-variables)
4809 (let ((articles (gnus-summary-work-articles arg))
4816 (substitute-command-keys
4817 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4820 (gnus-error 1 "Undefined key")
4823 (gnus-summary-goto-subject (setq article (pop articles)))
4824 (let (gnus-newsgroup-processable)
4825 (command-execute func))
4826 (gnus-summary-remove-process-mark article)))))
4827 (gnus-summary-position-point))
4829 (defun gnus-summary-toggle-truncation (&optional arg)
4830 "Toggle truncation of summary lines.
4831 With arg, turn line truncation on iff arg is positive."
4833 (setq truncate-lines
4834 (if (null arg) (not truncate-lines)
4835 (> (prefix-numeric-value arg) 0)))
4838 (defun gnus-summary-reselect-current-group (&optional all rescan)
4839 "Exit and then reselect the current newsgroup.
4840 The prefix argument ALL means to select all articles."
4842 (gnus-set-global-variables)
4843 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4844 (error "Ephemeral groups can't be reselected"))
4845 (let ((current-subject (gnus-summary-article-number))
4846 (group gnus-newsgroup-name))
4847 (setq gnus-newsgroup-begin nil)
4849 ;; We have to adjust the point of group mode buffer because
4850 ;; point was moved to the next unread newsgroup by exiting.
4851 (gnus-summary-jump-to-group group)
4854 (gnus-group-get-new-news-this-group 1)))
4855 (gnus-group-read-group all t)
4856 (gnus-summary-goto-subject current-subject nil t)))
4858 (defun gnus-summary-rescan-group (&optional all)
4859 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4861 (gnus-summary-reselect-current-group all t))
4863 (defun gnus-summary-update-info (&optional non-destructive)
4865 (let ((group gnus-newsgroup-name))
4866 (when gnus-newsgroup-kill-headers
4867 (setq gnus-newsgroup-killed
4868 (gnus-compress-sequence
4870 (gnus-set-sorted-intersection
4871 (gnus-uncompress-range gnus-newsgroup-killed)
4872 (setq gnus-newsgroup-unselected
4873 (sort gnus-newsgroup-unselected '<)))
4874 (setq gnus-newsgroup-unreads
4875 (sort gnus-newsgroup-unreads '<)))
4877 (unless (listp (cdr gnus-newsgroup-killed))
4878 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4879 (let ((headers gnus-newsgroup-headers))
4880 (when (and (not gnus-save-score)
4881 (not non-destructive))
4882 (setq gnus-newsgroup-scored nil))
4883 ;; Set the new ranges of read articles.
4885 (set-buffer gnus-group-buffer)
4886 (gnus-undo-force-boundary))
4887 (gnus-update-read-articles
4888 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4889 ;; Set the current article marks.
4891 ;; Do the cross-ref thing.
4892 (when gnus-use-cross-reference
4893 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4894 ;; Do adaptive scoring, and possibly save score files.
4895 (when gnus-newsgroup-adaptive
4896 (gnus-score-adaptive))
4897 (when gnus-use-scoring
4899 ;; Do not switch windows but change the buffer to work.
4900 (set-buffer gnus-group-buffer)
4901 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4902 (gnus-group-update-group group))))))
4904 (defun gnus-summary-save-newsrc (&optional force)
4905 "Save the current number of read/marked articles in the dribble buffer.
4906 The dribble buffer will then be saved.
4907 If FORCE (the prefix), also save the .newsrc file(s)."
4909 (gnus-summary-update-info t)
4911 (gnus-save-newsrc-file)
4912 (gnus-dribble-save)))
4914 (defun gnus-summary-exit (&optional temporary)
4915 "Exit reading current newsgroup, and then return to group selection mode.
4916 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4918 (gnus-set-global-variables)
4919 (gnus-kill-save-kill-buffer)
4920 (let* ((group gnus-newsgroup-name)
4921 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4924 (buf (current-buffer)))
4925 (run-hooks 'gnus-summary-prepare-exit-hook)
4926 ;; If we have several article buffers, we kill them at exit.
4927 (unless gnus-single-article-buffer
4928 (gnus-kill-buffer gnus-original-article-buffer)
4929 (setq gnus-article-current nil))
4930 (when gnus-use-cache
4931 (gnus-cache-possibly-remove-articles)
4932 (gnus-cache-save-buffers))
4933 (gnus-async-prefetch-remove-group group)
4934 (when gnus-suppress-duplicates
4935 (gnus-dup-enter-articles))
4936 (when gnus-use-trees
4937 (gnus-tree-close group))
4938 ;; Make all changes in this group permanent.
4940 (run-hooks 'gnus-exit-group-hook)
4941 (gnus-summary-update-info))
4942 (gnus-close-group group)
4943 ;; Make sure where we were, and go to next newsgroup.
4944 (set-buffer gnus-group-buffer)
4946 (gnus-group-jump-to-group group))
4947 (run-hooks 'gnus-summary-exit-hook)
4949 (gnus-group-next-unread-group 1))
4950 (setq group-point (point))
4953 ;; If we have several article buffers, we kill them at exit.
4954 (unless gnus-single-article-buffer
4955 (gnus-kill-buffer gnus-article-buffer)
4956 (gnus-kill-buffer gnus-original-article-buffer)
4957 (setq gnus-article-current nil))
4959 (if (not gnus-kill-summary-on-exit)
4960 (gnus-deaden-summary)
4961 ;; We set all buffer-local variables to nil. It is unclear why
4962 ;; this is needed, but if we don't, buffer-local variables are
4963 ;; not garbage-collected, it seems. This would the lead to en
4964 ;; ever-growing Emacs.
4965 (gnus-summary-clear-local-variables)
4966 (when (get-buffer gnus-article-buffer)
4967 (bury-buffer gnus-article-buffer))
4968 ;; We clear the global counterparts of the buffer-local
4969 ;; variables as well, just to be on the safe side.
4970 (set-buffer gnus-group-buffer)
4971 (gnus-summary-clear-local-variables)
4972 ;; Return to group mode buffer.
4973 (when (eq mode 'gnus-summary-mode)
4974 (gnus-kill-buffer buf)))
4975 (setq gnus-current-select-method gnus-select-method)
4976 (pop-to-buffer gnus-group-buffer)
4977 ;; Clear the current group name.
4978 (if (not quit-config)
4980 (goto-char group-point)
4981 (gnus-configure-windows 'group 'force))
4982 (gnus-handle-ephemeral-exit quit-config))
4984 (setq gnus-newsgroup-name nil)))))
4986 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4987 (defun gnus-summary-exit-no-update (&optional no-questions)
4988 "Quit reading current newsgroup without updating read article info."
4990 (gnus-set-global-variables)
4991 (let* ((group gnus-newsgroup-name)
4992 (quit-config (gnus-group-quit-config group)))
4993 (when (or no-questions
4995 (gnus-y-or-n-p "Discard changes to this group and exit? "))
4996 ;; If we have several article buffers, we kill them at exit.
4997 (unless gnus-single-article-buffer
4998 (gnus-kill-buffer gnus-article-buffer)
4999 (gnus-kill-buffer gnus-original-article-buffer)
5000 (setq gnus-article-current nil))
5001 (if (not gnus-kill-summary-on-exit)
5002 (gnus-deaden-summary)
5003 (gnus-close-group group)
5004 (gnus-summary-clear-local-variables)
5005 (set-buffer gnus-group-buffer)
5006 (gnus-summary-clear-local-variables)
5007 (when (get-buffer gnus-summary-buffer)
5008 (kill-buffer gnus-summary-buffer)))
5009 (unless gnus-single-article-buffer
5010 (setq gnus-article-current nil))
5011 (when gnus-use-trees
5012 (gnus-tree-close group))
5013 (gnus-async-prefetch-remove-group group)
5014 (when (get-buffer gnus-article-buffer)
5015 (bury-buffer gnus-article-buffer))
5016 ;; Return to the group buffer.
5017 (gnus-configure-windows 'group 'force)
5018 ;; Clear the current group name.
5019 (setq gnus-newsgroup-name nil)
5020 (when (equal (gnus-group-group-name) group)
5021 (gnus-group-next-unread-group 1))
5023 (gnus-handle-ephemeral-exit quit-config)))))
5025 (defun gnus-handle-ephemeral-exit (quit-config)
5026 "Handle movement when leaving an ephemeral group. The state
5027 which existed when entering the ephemeral is reset."
5028 (if (not (buffer-name (car quit-config)))
5029 (gnus-configure-windows 'group 'force)
5030 (set-buffer (car quit-config))
5031 (cond ((eq major-mode 'gnus-summary-mode)
5032 (gnus-set-global-variables))
5033 ((eq major-mode 'gnus-article-mode)
5035 ;; The `gnus-summary-buffer' variable may point
5036 ;; to the old summary buffer when using a single
5038 (unless (gnus-buffer-live-p gnus-summary-buffer)
5039 (set-buffer gnus-group-buffer))
5040 (set-buffer gnus-summary-buffer)
5041 (gnus-set-global-variables))))
5042 (if (or (eq (cdr quit-config) 'article)
5043 (eq (cdr quit-config) 'pick))
5045 ;; The current article may be from the ephemeral group
5046 ;; thus it is best that we reload this article
5047 (gnus-summary-show-article)
5048 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5049 (gnus-configure-windows 'pick 'force)
5050 (gnus-configure-windows (cdr quit-config) 'force)))
5051 (gnus-configure-windows (cdr quit-config) 'force))
5052 (when (eq major-mode 'gnus-summary-mode)
5053 (gnus-summary-next-subject 1 nil t)
5054 (gnus-summary-recenter)
5055 (gnus-summary-position-point))))
5059 (defvar gnus-dead-summary-mode-map nil)
5061 (unless gnus-dead-summary-mode-map
5062 (setq gnus-dead-summary-mode-map (make-keymap))
5063 (suppress-keymap gnus-dead-summary-mode-map)
5064 (substitute-key-definition
5065 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5066 (let ((keys '("\C-d" "\r" "\177" [delete])))
5068 (define-key gnus-dead-summary-mode-map
5069 (pop keys) 'gnus-summary-wake-up-the-dead))))
5071 (defvar gnus-dead-summary-mode nil
5072 "Minor mode for Gnus summary buffers.")
5074 (defun gnus-dead-summary-mode (&optional arg)
5075 "Minor mode for Gnus summary buffers."
5077 (when (eq major-mode 'gnus-summary-mode)
5078 (make-local-variable 'gnus-dead-summary-mode)
5079 (setq gnus-dead-summary-mode
5080 (if (null arg) (not gnus-dead-summary-mode)
5081 (> (prefix-numeric-value arg) 0)))
5082 (when gnus-dead-summary-mode
5083 (gnus-add-minor-mode
5084 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5086 (defun gnus-deaden-summary ()
5087 "Make the current summary buffer into a dead summary buffer."
5088 ;; Kill any previous dead summary buffer.
5089 (when (and gnus-dead-summary
5090 (buffer-name gnus-dead-summary))
5092 (set-buffer gnus-dead-summary)
5093 (when gnus-dead-summary-mode
5094 (kill-buffer (current-buffer)))))
5095 ;; Make this the current dead summary.
5096 (setq gnus-dead-summary (current-buffer))
5097 (gnus-dead-summary-mode 1)
5098 (let ((name (buffer-name)))
5099 (when (string-match "Summary" name)
5101 (concat (substring name 0 (match-beginning 0)) "Dead "
5102 (substring name (match-beginning 0)))
5105 (defun gnus-kill-or-deaden-summary (buffer)
5106 "Kill or deaden the summary BUFFER."
5107 (when (and (buffer-name buffer)
5108 (not gnus-single-article-buffer))
5111 (gnus-kill-buffer gnus-article-buffer)
5112 (gnus-kill-buffer gnus-original-article-buffer)))
5113 (cond (gnus-kill-summary-on-exit
5114 (when (and gnus-use-trees
5115 (and (get-buffer buffer)
5116 (buffer-name (get-buffer buffer))))
5118 (set-buffer (get-buffer buffer))
5119 (gnus-tree-close gnus-newsgroup-name)))
5120 (gnus-kill-buffer buffer))
5121 ((and (get-buffer buffer)
5122 (buffer-name (get-buffer buffer)))
5125 (gnus-deaden-summary)))))
5127 (defun gnus-summary-wake-up-the-dead (&rest args)
5128 "Wake up the dead summary buffer."
5130 (gnus-dead-summary-mode -1)
5131 (let ((name (buffer-name)))
5132 (when (string-match "Dead " name)
5134 (concat (substring name 0 (match-beginning 0))
5135 (substring name (match-end 0)))
5137 (gnus-message 3 "This dead summary is now alive again"))
5139 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5140 (defun gnus-summary-fetch-faq (&optional faq-dir)
5141 "Fetch the FAQ for the current group.
5142 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5146 (when current-prefix-arg
5148 "Faq dir: " (and (listp gnus-group-faq-directory)
5149 (mapcar (lambda (file) (list file))
5150 gnus-group-faq-directory))))))
5151 (let (gnus-faq-buffer)
5152 (when (setq gnus-faq-buffer
5153 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5154 (gnus-configure-windows 'summary-faq))))
5156 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5157 (defun gnus-summary-describe-group (&optional force)
5158 "Describe the current newsgroup."
5160 (gnus-group-describe-group force gnus-newsgroup-name))
5162 (defun gnus-summary-describe-briefly ()
5163 "Describe summary mode commands briefly."
5166 (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")))
5168 ;; Walking around group mode buffer from summary mode.
5170 (defun gnus-summary-next-group (&optional no-article target-group backward)
5171 "Exit current newsgroup and then select next unread newsgroup.
5172 If prefix argument NO-ARTICLE is non-nil, no article is selected
5173 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5174 previous group instead."
5176 (gnus-set-global-variables)
5177 ;; Stop pre-fetching.
5178 (gnus-async-halt-prefetch)
5179 (let ((current-group gnus-newsgroup-name)
5180 (current-buffer (current-buffer))
5182 ;; First we semi-exit this group to update Xrefs and all variables.
5183 ;; We can't do a real exit, because the window conf must remain
5184 ;; the same in case the user is prompted for info, and we don't
5185 ;; want the window conf to change before that...
5186 (gnus-summary-exit t)
5187 (while (not entered)
5188 ;; Then we find what group we are supposed to enter.
5189 (set-buffer gnus-group-buffer)
5190 (gnus-group-jump-to-group current-group)
5193 (if (eq gnus-keep-same-level 'best)
5194 (gnus-summary-best-group gnus-newsgroup-name)
5195 (gnus-summary-search-group backward gnus-keep-same-level))))
5196 (if (not target-group)
5197 ;; There are no further groups, so we return to the group
5200 (gnus-message 5 "Returning to the group buffer")
5202 (when (gnus-buffer-live-p current-buffer)
5203 (set-buffer current-buffer)
5204 (gnus-summary-exit))
5205 (run-hooks 'gnus-group-no-more-groups-hook))
5206 ;; We try to enter the target group.
5207 (gnus-group-jump-to-group target-group)
5208 (let ((unreads (gnus-group-group-unread)))
5209 (if (and (or (eq t unreads)
5210 (and unreads (not (zerop unreads))))
5211 (gnus-summary-read-group
5212 target-group nil no-article
5213 (and (buffer-name current-buffer) current-buffer)))
5215 (setq current-group target-group
5216 target-group nil)))))))
5218 (defun gnus-summary-prev-group (&optional no-article)
5219 "Exit current newsgroup and then select previous unread newsgroup.
5220 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5222 (gnus-summary-next-group no-article nil t))
5224 ;; Walking around summary lines.
5226 (defun gnus-summary-first-subject (&optional unread)
5227 "Go to the first unread subject.
5228 If UNREAD is non-nil, go to the first unread article.
5229 Returns the article selected or nil if there are no unread articles."
5234 ((null gnus-newsgroup-data)
5235 (gnus-message 3 "No articles in the group")
5237 ;; Pick the first article.
5239 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5240 (gnus-data-number (car gnus-newsgroup-data)))
5241 ;; No unread articles.
5242 ((null gnus-newsgroup-unreads)
5243 (gnus-message 3 "No more unread articles")
5245 ;; Find the first unread article.
5247 (let ((data gnus-newsgroup-data))
5249 (not (gnus-data-unread-p (car data))))
5250 (setq data (cdr data)))
5252 (goto-char (gnus-data-pos (car data)))
5253 (gnus-data-number (car data))))))
5254 (gnus-summary-position-point)))
5256 (defun gnus-summary-next-subject (n &optional unread dont-display)
5257 "Go to next N'th summary line.
5258 If N is negative, go to the previous N'th subject line.
5259 If UNREAD is non-nil, only unread articles are selected.
5260 The difference between N and the actual number of steps taken is
5263 (let ((backward (< n 0))
5267 (gnus-summary-find-prev unread)
5268 (gnus-summary-find-next unread)))
5271 (gnus-message 7 "No more%s articles"
5272 (if unread " unread" "")))
5273 (unless dont-display
5274 (gnus-summary-recenter)
5275 (gnus-summary-position-point))
5278 (defun gnus-summary-next-unread-subject (n)
5279 "Go to next N'th unread summary line."
5281 (gnus-summary-next-subject n t))
5283 (defun gnus-summary-prev-subject (n &optional unread)
5284 "Go to previous N'th summary line.
5285 If optional argument UNREAD is non-nil, only unread article is selected."
5287 (gnus-summary-next-subject (- n) unread))
5289 (defun gnus-summary-prev-unread-subject (n)
5290 "Go to previous N'th unread summary line."
5292 (gnus-summary-next-subject (- n) t))
5294 (defun gnus-summary-goto-subject (article &optional force silent)
5295 "Go the subject line of ARTICLE.
5296 If FORCE, also allow jumping to articles not currently shown."
5297 (interactive "nArticle number: ")
5299 (data (gnus-data-find article)))
5300 ;; We read in the article if we have to.
5303 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5304 (setq data (gnus-data-find article)))
5309 (gnus-message 3 "Can't find article %d" article))
5311 (goto-char (gnus-data-pos data))
5314 ;; Walking around summary lines with displaying articles.
5316 (defun gnus-summary-expand-window (&optional arg)
5317 "Make the summary buffer take up the entire Emacs frame.
5318 Given a prefix, will force an `article' buffer configuration."
5320 (gnus-set-global-variables)
5322 (gnus-configure-windows 'article 'force)
5323 (gnus-configure-windows 'summary 'force)))
5325 (defun gnus-summary-display-article (article &optional all-header)
5326 "Display ARTICLE in article buffer."
5327 (gnus-set-global-variables)
5331 (if gnus-summary-display-article-function
5332 (funcall gnus-summary-display-article-function article all-header)
5333 (gnus-article-prepare article all-header))
5334 (run-hooks 'gnus-select-article-hook)
5335 (when (and gnus-current-article
5336 (not (zerop gnus-current-article)))
5337 (gnus-summary-goto-subject gnus-current-article))
5338 (gnus-summary-recenter)
5339 (when (and gnus-use-trees gnus-show-threads)
5340 (gnus-possibly-generate-tree article)
5341 (gnus-highlight-selected-tree article))
5342 ;; Successfully display article.
5343 (gnus-article-set-window-start
5344 (cdr (assq article gnus-newsgroup-bookmarks))))))
5346 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5347 "Select the current article.
5348 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5349 non-nil, the article will be re-fetched even if it already present in
5350 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5352 ;; Make sure we are in the summary buffer to work around bbdb bug.
5353 (unless (eq major-mode 'gnus-summary-mode)
5354 (set-buffer gnus-summary-buffer))
5355 (let ((article (or article (gnus-summary-article-number)))
5356 (all-headers (not (not all-headers))) ;Must be T or NIL.
5357 gnus-summary-display-article-function
5360 (gnus-summary-article-pseudo-p article)
5361 (error "This is a pseudo-article"))
5364 (set-buffer gnus-summary-buffer)
5365 (if (or (and gnus-single-article-buffer
5366 (or (null gnus-current-article)
5367 (null gnus-article-current)
5368 (null (get-buffer gnus-article-buffer))
5369 (not (eq article (cdr gnus-article-current)))
5370 (not (equal (car gnus-article-current)
5371 gnus-newsgroup-name))))
5372 (and (not gnus-single-article-buffer)
5373 (or (null gnus-current-article)
5374 (not (eq gnus-current-article article))))
5376 ;; The requested article is different from the current article.
5378 (gnus-summary-display-article article all-headers)
5380 (when (or all-headers gnus-show-all-headers)
5381 (gnus-article-show-all-headers))
5384 (gnus-article-set-window-start
5385 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5387 (defun gnus-summary-set-current-mark (&optional current-mark)
5388 "Obsolete function."
5391 (defun gnus-summary-next-article (&optional unread subject backward push)
5392 "Select the next article.
5393 If UNREAD, only unread articles are selected.
5394 If SUBJECT, only articles with SUBJECT are selected.
5395 If BACKWARD, the previous article is selected instead of the next."
5397 (gnus-set-global-variables)
5399 ;; Is there such an article?
5400 ((and (gnus-summary-search-forward unread subject backward)
5401 (or (gnus-summary-display-article (gnus-summary-article-number))
5402 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5403 (gnus-summary-position-point))
5404 ;; If not, we try the first unread, if that is wanted.
5406 gnus-auto-select-same
5407 (gnus-summary-first-unread-article))
5408 (gnus-summary-position-point)
5409 (gnus-message 6 "Wrapped"))
5410 ;; Try to get next/previous article not displayed in this group.
5411 ((and gnus-auto-extend-newsgroup
5412 (not unread) (not subject))
5413 (gnus-summary-goto-article
5414 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5416 ;; Go to next/previous group.
5418 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5419 (gnus-summary-jump-to-group gnus-newsgroup-name))
5420 (let ((cmd last-command-char)
5423 (set-buffer gnus-group-buffer)
5426 (if (eq gnus-keep-same-level 'best)
5427 (gnus-summary-best-group gnus-newsgroup-name)
5428 (gnus-summary-search-group backward gnus-keep-same-level))))
5429 ;; For some reason, the group window gets selected. We change
5431 (select-window (get-buffer-window (current-buffer)))
5432 ;; Select next unread newsgroup automagically.
5434 ((or (not gnus-auto-select-next)
5436 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5437 ((or (eq gnus-auto-select-next 'quietly)
5438 (and (eq gnus-auto-select-next 'slightly-quietly)
5440 (and (eq gnus-auto-select-next 'almost-quietly)
5441 (gnus-summary-last-article-p)))
5443 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5445 (gnus-message 7 "No more%s articles (%s)..."
5446 (if unread " unread" "")
5447 (if group (concat "selecting " group)
5449 (gnus-summary-next-group nil group backward)))
5451 (when (gnus-key-press-event-p last-input-event)
5452 (gnus-summary-walk-group-buffer
5453 gnus-newsgroup-name cmd unread backward point))))))))
5455 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5456 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5457 (?\C-p (gnus-group-prev-unread-group 1))))
5458 (cursor-in-echo-area t)
5459 keve key group ended)
5461 (set-buffer gnus-group-buffer)
5464 (if (eq gnus-keep-same-level 'best)
5465 (gnus-summary-best-group gnus-newsgroup-name)
5466 (gnus-summary-search-group backward gnus-keep-same-level))))
5469 5 "No more%s articles%s" (if unread " unread" "")
5471 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5472 (format " (Type %s for %s [%s])"
5473 (single-key-description cmd) group
5474 (car (gnus-gethash group gnus-newsrc-hashtb)))
5475 (format " (Type %s to exit %s)"
5476 (single-key-description cmd)
5477 gnus-newsgroup-name)))
5478 ;; Confirm auto selection.
5479 (setq key (car (setq keve (gnus-read-event-char))))
5482 ((assq key keystrokes)
5483 (let ((obuf (current-buffer)))
5484 (switch-to-buffer gnus-group-buffer)
5486 (gnus-group-jump-to-group group))
5487 (eval (cadr (assq key keystrokes)))
5488 (setq group (gnus-group-group-name))
5489 (switch-to-buffer obuf))
5493 (gnus-ephemeral-group-p gnus-newsgroup-name))
5495 (gnus-summary-next-group nil group backward)))
5497 (push (cdr keve) unread-command-events))))))
5499 (defun gnus-summary-next-unread-article ()
5500 "Select unread article after current one."
5502 (gnus-summary-next-article
5503 (or (not (eq gnus-summary-goto-unread 'never))
5504 (gnus-summary-last-article-p (gnus-summary-article-number)))
5505 (and gnus-auto-select-same
5506 (gnus-summary-article-subject))))
5508 (defun gnus-summary-prev-article (&optional unread subject)
5509 "Select the article after the current one.
5510 If UNREAD is non-nil, only unread articles are selected."
5512 (gnus-summary-next-article unread subject t))
5514 (defun gnus-summary-prev-unread-article ()
5515 "Select unread article before current one."
5517 (gnus-summary-prev-article
5518 (or (not (eq gnus-summary-goto-unread 'never))
5519 (gnus-summary-first-article-p (gnus-summary-article-number)))
5520 (and gnus-auto-select-same
5521 (gnus-summary-article-subject))))
5523 (defun gnus-summary-next-page (&optional lines circular)
5524 "Show next page of the selected article.
5525 If at the end of the current article, select the next article.
5526 LINES says how many lines should be scrolled up.
5528 If CIRCULAR is non-nil, go to the start of the article instead of
5529 selecting the next article when reaching the end of the current
5532 (setq gnus-summary-buffer (current-buffer))
5533 (gnus-set-global-variables)
5534 (let ((article (gnus-summary-article-number))
5535 (article-window (get-buffer-window gnus-article-buffer t))
5537 (gnus-configure-windows 'article)
5538 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5539 (if (and (eq gnus-summary-goto-unread 'never)
5540 (not (gnus-summary-last-article-p article)))
5541 (gnus-summary-next-article)
5542 (gnus-summary-next-unread-article))
5543 (if (or (null gnus-current-article)
5544 (null gnus-article-current)
5545 (/= article (cdr gnus-article-current))
5546 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5547 ;; Selected subject is different from current article's.
5548 (gnus-summary-display-article article)
5549 (when article-window
5550 (gnus-eval-in-buffer-window gnus-article-buffer
5551 (setq endp (gnus-article-next-page lines)))
5554 (gnus-summary-beginning-of-article))
5556 (gnus-message 3 "End of message"))
5558 (if (and (eq gnus-summary-goto-unread 'never)
5559 (not (gnus-summary-last-article-p article)))
5560 (gnus-summary-next-article)
5561 (gnus-summary-next-unread-article))))))))
5562 (gnus-summary-recenter)
5563 (gnus-summary-position-point)))
5565 (defun gnus-summary-prev-page (&optional lines move)
5566 "Show previous page of selected article.
5567 Argument LINES specifies lines to be scrolled down.
5568 If MOVE, move to the previous unread article if point is at
5569 the beginning of the buffer."
5571 (gnus-set-global-variables)
5572 (let ((article (gnus-summary-article-number))
5573 (article-window (get-buffer-window gnus-article-buffer t))
5575 (gnus-configure-windows 'article)
5576 (if (or (null gnus-current-article)
5577 (null gnus-article-current)
5578 (/= article (cdr gnus-article-current))
5579 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5580 ;; Selected subject is different from current article's.
5581 (gnus-summary-display-article article)
5582 (gnus-summary-recenter)
5583 (when article-window
5584 (gnus-eval-in-buffer-window gnus-article-buffer
5585 (setq endp (gnus-article-prev-page lines)))
5586 (when (and move endp)
5588 (gnus-message 3 "Beginning of message"))
5590 (if (and (eq gnus-summary-goto-unread 'never)
5591 (not (gnus-summary-first-article-p article)))
5592 (gnus-summary-prev-article)
5593 (gnus-summary-prev-unread-article))))))))
5594 (gnus-summary-position-point))
5596 (defun gnus-summary-prev-page-or-article (&optional lines)
5597 "Show previous page of selected article.
5598 Argument LINES specifies lines to be scrolled down.
5599 If at the beginning of the article, go to the next article."
5601 (gnus-summary-prev-page lines t))
5603 (defun gnus-summary-scroll-up (lines)
5604 "Scroll up (or down) one line current article.
5605 Argument LINES specifies lines to be scrolled up (or down if negative)."
5607 (gnus-set-global-variables)
5608 (gnus-configure-windows 'article)
5609 (gnus-summary-show-thread)
5610 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5611 (gnus-eval-in-buffer-window gnus-article-buffer
5613 (when (gnus-article-next-page lines)
5614 (gnus-message 3 "End of message")))
5616 (gnus-article-prev-page (- lines))))))
5617 (gnus-summary-recenter)
5618 (gnus-summary-position-point))
5620 (defun gnus-summary-next-same-subject ()
5621 "Select next article which has the same subject as current one."
5623 (gnus-set-global-variables)
5624 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5626 (defun gnus-summary-prev-same-subject ()
5627 "Select previous article which has the same subject as current one."
5629 (gnus-set-global-variables)
5630 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5632 (defun gnus-summary-next-unread-same-subject ()
5633 "Select next unread article which has the same subject as current one."
5635 (gnus-set-global-variables)
5636 (gnus-summary-next-article t (gnus-summary-article-subject)))
5638 (defun gnus-summary-prev-unread-same-subject ()
5639 "Select previous unread article which has the same subject as current one."
5641 (gnus-set-global-variables)
5642 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5644 (defun gnus-summary-first-unread-article ()
5645 "Select the first unread article.
5646 Return nil if there are no unread articles."
5648 (gnus-set-global-variables)
5650 (when (gnus-summary-first-subject t)
5651 (gnus-summary-show-thread)
5652 (gnus-summary-first-subject t)
5653 (gnus-summary-display-article (gnus-summary-article-number)))
5654 (gnus-summary-position-point)))
5656 (defun gnus-summary-first-article ()
5657 "Select the first article.
5658 Return nil if there are no articles."
5660 (gnus-set-global-variables)
5662 (when (gnus-summary-first-subject)
5663 (gnus-summary-show-thread)
5664 (gnus-summary-first-subject)
5665 (gnus-summary-display-article (gnus-summary-article-number)))
5666 (gnus-summary-position-point)))
5668 (defun gnus-summary-best-unread-article ()
5669 "Select the unread article with the highest score."
5671 (gnus-set-global-variables)
5672 (let ((best -1000000)
5673 (data gnus-newsgroup-data)
5676 (and (gnus-data-unread-p (car data))
5678 (gnus-summary-article-score (gnus-data-number (car data))))
5681 article (gnus-data-number (car data))))
5682 (setq data (cdr data)))
5685 (gnus-summary-goto-article article)
5686 (error "No unread articles"))
5687 (gnus-summary-position-point))))
5689 (defun gnus-summary-last-subject ()
5690 "Go to the last displayed subject line in the group."
5691 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5693 (gnus-summary-goto-subject article))))
5695 (defun gnus-summary-goto-article (article &optional all-headers force)
5696 "Fetch ARTICLE and display it if it exists.
5697 If ALL-HEADERS is non-nil, no header lines are hidden."
5703 (mapcar (lambda (number) (list (int-to-string number)))
5704 gnus-newsgroup-limit)))
5708 (if (gnus-summary-goto-subject article force)
5709 (gnus-summary-display-article article all-headers)
5710 (gnus-message 4 "Couldn't go to article %s" article) nil)
5711 (gnus-summary-position-point)))
5713 (defun gnus-summary-goto-last-article ()
5714 "Go to the previously read article."
5717 (when gnus-last-article
5718 (gnus-summary-goto-article gnus-last-article))
5719 (gnus-summary-position-point)))
5721 (defun gnus-summary-pop-article (number)
5722 "Pop one article off the history and go to the previous.
5723 NUMBER articles will be popped off."
5726 (setq gnus-newsgroup-history
5727 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5729 (gnus-summary-goto-article (car to))
5730 (error "Article history empty")))
5731 (gnus-summary-position-point))
5733 ;; Summary commands and functions for limiting the summary buffer.
5735 (defun gnus-summary-limit-to-articles (n)
5736 "Limit the summary buffer to the next N articles.
5737 If not given a prefix, use the process marked articles instead."
5739 (gnus-set-global-variables)
5741 (let ((articles (gnus-summary-work-articles n)))
5742 (setq gnus-newsgroup-processable nil)
5743 (gnus-summary-limit articles))
5744 (gnus-summary-position-point)))
5746 (defun gnus-summary-pop-limit (&optional total)
5747 "Restore the previous limit.
5748 If given a prefix, remove all limits."
5750 (gnus-set-global-variables)
5752 (setq gnus-newsgroup-limits
5753 (list (mapcar (lambda (h) (mail-header-number h))
5754 gnus-newsgroup-headers))))
5755 (unless gnus-newsgroup-limits
5756 (error "No limit to pop"))
5758 (gnus-summary-limit nil 'pop)
5759 (gnus-summary-position-point)))
5761 (defun gnus-summary-limit-to-subject (subject &optional header)
5762 "Limit the summary buffer to articles that have subjects that match a regexp."
5763 (interactive "sLimit to subject (regexp): ")
5765 (setq header "subject"))
5766 (when (not (equal "" subject))
5768 (let ((articles (gnus-summary-find-matching
5769 (or header "subject") subject 'all)))
5771 (error "Found no matches for \"%s\"" subject))
5772 (gnus-summary-limit articles))
5773 (gnus-summary-position-point))))
5775 (defun gnus-summary-limit-to-author (from)
5776 "Limit the summary buffer to articles that have authors that match a regexp."
5777 (interactive "sLimit to author (regexp): ")
5778 (gnus-summary-limit-to-subject from "from"))
5780 (defun gnus-summary-limit-to-age (age &optional younger-p)
5781 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5782 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5783 articles that are younger than AGE days."
5784 (interactive "nTime in days: \nP")
5786 (let ((data gnus-newsgroup-data)
5787 (cutoff (nnmail-days-to-time age))
5788 articles d date is-younger)
5789 (while (setq d (pop data))
5790 (when (and (vectorp (gnus-data-header d))
5791 (setq date (mail-header-date (gnus-data-header d))))
5792 (setq is-younger (nnmail-time-less
5793 (nnmail-time-since (nnmail-date-to-time date))
5795 (when (if younger-p is-younger (not is-younger))
5796 (push (gnus-data-number d) articles))))
5797 (gnus-summary-limit (nreverse articles)))
5798 (gnus-summary-position-point)))
5800 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5802 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5804 (defun gnus-summary-limit-to-unread (&optional all)
5805 "Limit the summary buffer to articles that are not marked as read.
5806 If ALL is non-nil, limit strictly to unread articles."
5809 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5810 (gnus-summary-limit-to-marks
5811 ;; Concat all the marks that say that an article is read and have
5813 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5814 gnus-killed-mark gnus-kill-file-mark
5815 gnus-low-score-mark gnus-expirable-mark
5816 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5817 gnus-duplicate-mark gnus-souped-mark)
5820 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5821 (make-obsolete 'gnus-summary-delete-marked-with
5822 'gnus-summary-limit-exlude-marks)
5824 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5825 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5826 If REVERSE, limit the summary buffer to articles that are marked
5827 with MARKS. MARKS can either be a string of marks or a list of marks.
5828 Returns how many articles were removed."
5829 (interactive "sMarks: ")
5830 (gnus-summary-limit-to-marks marks t))
5832 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5833 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5834 If REVERSE (the prefix), limit the summary buffer to articles that are
5835 not marked with MARKS. MARKS can either be a string of marks or a
5837 Returns how many articles were removed."
5838 (interactive (list (read-string "Marks: ") current-prefix-arg))
5839 (gnus-set-global-variables)
5841 (let ((data gnus-newsgroup-data)
5842 (marks (if (listp marks) marks
5843 (append marks nil))) ; Transform to list.
5846 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5847 (memq (gnus-data-mark (car data)) marks))
5848 (push (gnus-data-number (car data)) articles))
5849 (setq data (cdr data)))
5850 (gnus-summary-limit articles))
5851 (gnus-summary-position-point)))
5853 (defun gnus-summary-limit-to-score (&optional score)
5854 "Limit to articles with score at or above SCORE."
5856 (gnus-set-global-variables)
5857 (setq score (if score
5858 (prefix-numeric-value score)
5859 (or gnus-summary-default-score 0)))
5860 (let ((data gnus-newsgroup-data)
5863 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5865 (push (gnus-data-number (car data)) articles))
5866 (setq data (cdr data)))
5868 (gnus-summary-limit articles)
5869 (gnus-summary-position-point))))
5871 (defun gnus-summary-limit-include-dormant ()
5872 "Display all the hidden articles that are marked as dormant."
5874 (gnus-set-global-variables)
5875 (unless gnus-newsgroup-dormant
5876 (error "There are no dormant articles in this group"))
5878 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5879 (gnus-summary-position-point)))
5881 (defun gnus-summary-limit-exclude-dormant ()
5882 "Hide all dormant articles."
5884 (gnus-set-global-variables)
5886 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5887 (gnus-summary-position-point)))
5889 (defun gnus-summary-limit-exclude-childless-dormant ()
5890 "Hide all dormant articles that have no children."
5892 (gnus-set-global-variables)
5893 (let ((data (gnus-data-list t))
5894 articles d children)
5895 ;; Find all articles that are either not dormant or have
5897 (while (setq d (pop data))
5898 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5900 (gnus-article-children (gnus-data-number d)))
5903 (when (memq (car children) articles)
5908 (push (gnus-data-number d) articles)))
5911 (gnus-summary-limit articles)
5912 (gnus-summary-position-point))))
5914 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5915 "Mark all unread excluded articles as read.
5916 If ALL, mark even excluded ticked and dormants as read."
5918 (let ((articles (gnus-sorted-complement
5920 (mapcar (lambda (h) (mail-header-number h))
5921 gnus-newsgroup-headers)
5923 (sort gnus-newsgroup-limit '<)))
5925 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
5927 (setq gnus-newsgroup-dormant nil
5928 gnus-newsgroup-marked nil
5929 gnus-newsgroup-reads
5931 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5932 gnus-newsgroup-reads))
5933 (while (setq article (pop articles))
5934 (unless (or (memq article gnus-newsgroup-dormant)
5935 (memq article gnus-newsgroup-marked))
5936 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5938 (defun gnus-summary-limit (articles &optional pop)
5940 ;; We pop the previous limit off the stack and use that.
5941 (setq articles (car gnus-newsgroup-limits)
5942 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5943 ;; We use the new limit, so we push the old limit on the stack.
5944 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5946 (setq gnus-newsgroup-limit articles)
5947 (let ((total (length gnus-newsgroup-data))
5948 (data (gnus-data-find-list (gnus-summary-article-number)))
5949 (gnus-summary-mark-below nil) ; Inhibit this.
5951 ;; This will do all the work of generating the new summary buffer
5952 ;; according to the new limit.
5953 (gnus-summary-prepare)
5954 ;; Hide any threads, possibly.
5955 (and gnus-show-threads
5956 gnus-thread-hide-subtree
5957 (gnus-summary-hide-all-threads))
5958 ;; Try to return to the article you were at, or one in the
5961 ;; We try to find some article after the current one.
5963 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5966 (setq data (cdr data))))
5968 ;; If there is no data, that means that we were after the last
5969 ;; article. The same goes when we can't find any articles
5970 ;; after the current one.
5971 (goto-char (point-max))
5972 (gnus-summary-find-prev))
5973 ;; We return how many articles were removed from the summary
5974 ;; buffer as a result of the new limit.
5975 (- total (length gnus-newsgroup-data))))
5977 (defsubst gnus-invisible-cut-children (threads)
5980 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5985 (defsubst gnus-cut-thread (thread)
5986 "Go forwards in the thread until we find an article that we want to display."
5987 (when (or (eq gnus-fetch-old-headers 'some)
5988 (eq gnus-build-sparse-threads 'some)
5989 (eq gnus-build-sparse-threads 'more))
5990 ;; Deal with old-fetched headers and sparse threads.
5994 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
5995 (gnus-summary-article-ancient-p
5996 (mail-header-number (car thread))))
5998 (if (<= (length (cdr thread)) 1)
5999 (setq gnus-newsgroup-limit
6000 (delq (mail-header-number (car thread))
6001 gnus-newsgroup-limit)
6002 thread (cadr thread))
6003 (when (gnus-invisible-cut-children (cdr thread))
6004 (let ((th (cdr thread)))
6006 (if (memq (mail-header-number (caar th))
6007 gnus-newsgroup-limit)
6008 (setq thread (car th)
6010 (setq th (cdr th)))))))))))
6013 (defun gnus-cut-threads (threads)
6014 "Cut off all uninteresting articles from the beginning of threads."
6015 (when (or (eq gnus-fetch-old-headers 'some)
6016 (eq gnus-build-sparse-threads 'some)
6017 (eq gnus-build-sparse-threads 'more))
6020 (setcar th (gnus-cut-thread (car th)))
6021 (setq th (cdr th)))))
6022 ;; Remove nixed out threads.
6025 (defun gnus-summary-initial-limit (&optional show-if-empty)
6026 "Figure out what the initial limit is supposed to be on group entry.
6027 This entails weeding out unwanted dormants, low-scored articles,
6028 fetch-old-headers verbiage, and so on."
6029 ;; Most groups have nothing to remove.
6030 (if (or gnus-inhibit-limiting
6031 (and (null gnus-newsgroup-dormant)
6032 (not (eq gnus-fetch-old-headers 'some))
6033 (null gnus-summary-expunge-below)
6034 (not (eq gnus-build-sparse-threads 'some))
6035 (not (eq gnus-build-sparse-threads 'more))
6036 (null gnus-thread-expunge-below)
6037 (not gnus-use-nocem)))
6039 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6040 (setq gnus-newsgroup-limit nil)
6043 (unless (car (symbol-value node))
6044 ;; These threads have no parents -- they are roots.
6045 (let ((nodes (cdr (symbol-value node)))
6048 (if (and gnus-thread-expunge-below
6049 (< (gnus-thread-total-score (car nodes))
6050 gnus-thread-expunge-below))
6051 (gnus-expunge-thread (pop nodes))
6052 (setq thread (pop nodes))
6053 (gnus-summary-limit-children thread))))))
6054 gnus-newsgroup-dependencies)
6055 ;; If this limitation resulted in an empty group, we might
6056 ;; pop the previous limit and use it instead.
6057 (when (and (not gnus-newsgroup-limit)
6059 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6060 gnus-newsgroup-limit))
6062 (defun gnus-summary-limit-children (thread)
6063 "Return 1 if this subthread is visible and 0 if it is not."
6064 ;; First we get the number of visible children to this thread. This
6065 ;; is done by recursing down the thread using this function, so this
6066 ;; will really go down to a leaf article first, before slowly
6067 ;; working its way up towards the root.
6071 (apply '+ (mapcar 'gnus-summary-limit-children
6074 (number (mail-header-number (car thread)))
6077 (not (memq number gnus-newsgroup-marked))
6079 ;; If this article is dormant and has absolutely no visible
6080 ;; children, then this article isn't visible.
6081 (and (memq number gnus-newsgroup-dormant)
6083 ;; If this is "fetch-old-headered" and there is no
6084 ;; visible children, then we don't want this article.
6085 (and (eq gnus-fetch-old-headers 'some)
6086 (gnus-summary-article-ancient-p number)
6088 ;; If this is a sparsely inserted article with no children,
6089 ;; we don't want it.
6090 (and (eq gnus-build-sparse-threads 'some)
6091 (gnus-summary-article-sparse-p number)
6093 ;; If we use expunging, and this article is really
6094 ;; low-scored, then we don't want this article.
6095 (when (and gnus-summary-expunge-below
6097 (or (cdr (assq number gnus-newsgroup-scored))
6098 gnus-summary-default-score))
6099 gnus-summary-expunge-below))
6100 ;; We increase the expunge-tally here, but that has
6101 ;; nothing to do with the limits, really.
6102 (incf gnus-newsgroup-expunged-tally)
6103 ;; We also mark as read here, if that's wanted.
6104 (when (and gnus-summary-mark-below
6105 (< score gnus-summary-mark-below))
6106 (setq gnus-newsgroup-unreads
6107 (delq number gnus-newsgroup-unreads))
6108 (if gnus-newsgroup-auto-expire
6109 (push number gnus-newsgroup-expirable)
6110 (push (cons number gnus-low-score-mark)
6111 gnus-newsgroup-reads)))
6113 ;; Check NoCeM things.
6114 (if (and gnus-use-nocem
6115 (gnus-nocem-unwanted-article-p
6116 (mail-header-id (car thread))))
6118 (setq gnus-newsgroup-unreads
6119 (delq number gnus-newsgroup-unreads))
6121 ;; Nope, invisible article.
6123 ;; Ok, this article is to be visible, so we add it to the limit
6125 (push number gnus-newsgroup-limit)
6128 (defun gnus-expunge-thread (thread)
6129 "Mark all articles in THREAD as read."
6130 (let* ((number (mail-header-number (car thread))))
6131 (incf gnus-newsgroup-expunged-tally)
6132 ;; We also mark as read here, if that's wanted.
6133 (setq gnus-newsgroup-unreads
6134 (delq number gnus-newsgroup-unreads))
6135 (if gnus-newsgroup-auto-expire
6136 (push number gnus-newsgroup-expirable)
6137 (push (cons number gnus-low-score-mark)
6138 gnus-newsgroup-reads)))
6139 ;; Go recursively through all subthreads.
6140 (mapcar 'gnus-expunge-thread (cdr thread)))
6142 ;; Summary article oriented commands
6144 (defun gnus-summary-refer-parent-article (n)
6145 "Refer parent article N times.
6146 If N is negative, go to ancestor -N instead.
6147 The difference between N and the number of articles fetched is returned."
6149 (gnus-set-global-variables)
6152 (when (not (natnump n))
6157 (setq header (gnus-summary-article-header))
6158 (if (and (eq (mail-header-number header)
6159 (cdr gnus-article-current))
6160 (equal gnus-newsgroup-name
6161 (car gnus-article-current)))
6162 ;; If we try to find the parent of the currently
6163 ;; displayed article, then we take a look at the actual
6164 ;; References header, since this is slightly more
6165 ;; reliable than the References field we got from the
6168 (set-buffer gnus-original-article-buffer)
6169 (nnheader-narrow-to-headers)
6170 (unless (setq ref (message-fetch-field "references"))
6171 (setq ref (message-fetch-field "in-reply-to")))
6174 ;; It's not the current article, so we take a bet on
6175 ;; the value we got from the server.
6176 (mail-header-references header)))
6178 (not (equal ref "")))
6179 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6180 (gnus-message 1 "Couldn't find parent"))
6181 (gnus-message 1 "No references in article %d"
6182 (gnus-summary-article-number))
6185 (gnus-summary-position-point)
6188 (defun gnus-summary-refer-references ()
6189 "Fetch all articles mentioned in the References header.
6190 Return how many articles were fetched."
6192 (gnus-set-global-variables)
6193 (let ((ref (mail-header-references (gnus-summary-article-header)))
6194 (current (gnus-summary-article-number))
6198 (error "No References in the current article")
6199 ;; For each Message-ID in the References header...
6200 (while (string-match "<[^>]*>" ref)
6202 ;; ... fetch that article.
6203 (gnus-summary-refer-article
6204 (prog1 (match-string 0 ref)
6205 (setq ref (substring ref (match-end 0))))))
6206 (gnus-summary-goto-subject current)
6207 (gnus-summary-position-point)
6210 (defun gnus-summary-refer-article (message-id &optional arg)
6211 "Fetch an article specified by MESSAGE-ID.
6212 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6213 or `gnus-select-method', no matter what backend the article comes from."
6214 (interactive "sMessage-ID: \nP")
6215 (when (and (stringp message-id)
6216 (not (zerop (length message-id))))
6217 ;; Construct the correct Message-ID if necessary.
6218 ;; Suggested by tale@pawl.rpi.edu.
6219 (unless (string-match "^<" message-id)
6220 (setq message-id (concat "<" message-id)))
6221 (unless (string-match ">$" message-id)
6222 (setq message-id (concat message-id ">")))
6223 (let* ((header (gnus-id-to-header message-id))
6225 (gnus-summary-article-sparse-p
6226 (mail-header-number header))
6227 (memq (mail-header-number header)
6228 gnus-newsgroup-limit))))
6230 (or (not (gnus-summary-article-sparse-p
6231 (mail-header-number header)))
6234 ;; The article is present in the buffer, so we just go to it.
6235 (gnus-summary-goto-article
6236 (mail-header-number header) nil t)
6238 (gnus-summary-update-article (mail-header-number header))))
6239 ;; We fetch the article
6240 (let ((gnus-override-method
6241 (cond ((gnus-news-group-p gnus-newsgroup-name)
6242 gnus-refer-article-method)
6244 (or gnus-refer-article-method gnus-select-method))
6247 ;; Start the special refer-article method, if necessary.
6248 (when (and gnus-refer-article-method
6249 (gnus-news-group-p gnus-newsgroup-name))
6250 (gnus-check-server gnus-refer-article-method))
6251 ;; Fetch the header, and display the article.
6252 (if (setq number (gnus-summary-insert-subject message-id))
6253 (gnus-summary-select-article nil nil nil number)
6254 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6256 (defun gnus-summary-enter-digest-group (&optional force)
6257 "Enter an nndoc group based on the current article.
6258 If FORCE, force a digest interpretation. If not, try
6259 to guess what the document format is."
6261 (gnus-set-global-variables)
6262 (let ((conf gnus-current-window-configuration))
6264 (gnus-summary-select-article))
6265 (setq gnus-current-window-configuration conf)
6266 (let* ((name (format "%s-%d"
6267 (gnus-group-prefixed-name
6268 gnus-newsgroup-name (list 'nndoc ""))
6270 (set-buffer gnus-summary-buffer)
6271 gnus-current-article)))
6272 (ogroup gnus-newsgroup-name)
6273 (params (append (gnus-info-params (gnus-get-info ogroup))
6274 (list (cons 'to-group ogroup))
6275 (list (cons 'save-article-group ogroup))))
6276 (case-fold-search t)
6277 (buf (current-buffer))
6280 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6281 (insert-buffer-substring gnus-original-article-buffer)
6282 ;; Remove lines that may lead nndoc to misinterpret the
6285 (goto-char (point-min))
6286 (or (search-forward "\n\n" nil t) (point)))
6287 (goto-char (point-min))
6288 (delete-matching-lines "^\\(Path\\):\\|^From ")
6291 (if (gnus-group-read-ephemeral-group
6292 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6294 ,(if force 'digest 'guess))) t)
6295 ;; Make all postings to this group go to the parent group.
6296 (nconc (gnus-info-params (gnus-get-info name))
6298 ;; Couldn't select this doc group.
6299 (switch-to-buffer buf)
6300 (gnus-set-global-variables)
6301 (gnus-configure-windows 'summary)
6302 (gnus-message 3 "Article couldn't be entered?"))
6303 (kill-buffer dig)))))
6305 (defun gnus-summary-read-document (n)
6306 "Open a new group based on the current article(s).
6307 This will allow you to read digests and other similar
6308 documents as newsgroups.
6309 Obeys the standard process/prefix convention."
6311 (let* ((articles (gnus-summary-work-articles n))
6312 (ogroup gnus-newsgroup-name)
6313 (params (append (gnus-info-params (gnus-get-info ogroup))
6314 (list (cons 'to-group ogroup))))
6315 article group egroup groups vgroup)
6316 (while (setq article (pop articles))
6317 (setq group (format "%s-%d" gnus-newsgroup-name article))
6318 (gnus-summary-remove-process-mark article)
6319 (when (gnus-summary-display-article article)
6321 (nnheader-temp-write nil
6322 (insert-buffer-substring gnus-original-article-buffer)
6323 ;; Remove some headers that may lead nndoc to make
6325 (message-narrow-to-head)
6326 (goto-char (point-min))
6327 (delete-matching-lines "^\\(Path\\):\\|^From ")
6330 (gnus-group-read-ephemeral-group
6331 group `(nndoc ,group (nndoc-address ,(current-buffer))
6332 (nndoc-article-type guess))
6335 ;; Make all postings to this group go to the parent group.
6336 (nconc (gnus-info-params (gnus-get-info egroup))
6338 (push egroup groups))
6339 ;; Couldn't select this doc group.
6340 (gnus-error 3 "Article couldn't be entered"))))))
6341 ;; Now we have selected all the documents.
6344 (error "None of the articles could be interpreted as documents"))
6345 ((gnus-group-read-ephemeral-group
6346 (setq vgroup (format
6347 "nnvirtual:%s-%s" gnus-newsgroup-name
6348 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6349 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6351 (cons (current-buffer) 'summary)))
6353 (error "Couldn't select virtual nndoc group")))))
6355 (defun gnus-summary-isearch-article (&optional regexp-p)
6356 "Do incremental search forward on the current article.
6357 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6359 (gnus-set-global-variables)
6360 (gnus-summary-select-article)
6361 (gnus-configure-windows 'article)
6362 (gnus-eval-in-buffer-window gnus-article-buffer
6363 ;;(goto-char (point-min))
6364 (isearch-forward regexp-p)))
6366 (defun gnus-summary-search-article-forward (regexp &optional backward)
6367 "Search for an article containing REGEXP forward.
6368 If BACKWARD, search backward instead."
6371 (format "Search article %s (regexp%s): "
6372 (if current-prefix-arg "backward" "forward")
6373 (if gnus-last-search-regexp
6374 (concat ", default " gnus-last-search-regexp)
6376 current-prefix-arg))
6377 (gnus-set-global-variables)
6378 (if (string-equal regexp "")
6379 (setq regexp (or gnus-last-search-regexp ""))
6380 (setq gnus-last-search-regexp regexp))
6381 (if (gnus-summary-search-article regexp backward)
6382 (gnus-summary-show-thread)
6383 (error "Search failed: \"%s\"" regexp)))
6385 (defun gnus-summary-search-article-backward (regexp)
6386 "Search for an article containing REGEXP backward."
6389 (format "Search article backward (regexp%s): "
6390 (if gnus-last-search-regexp
6391 (concat ", default " gnus-last-search-regexp)
6393 (gnus-summary-search-article-forward regexp 'backward))
6395 (defun gnus-summary-search-article (regexp &optional backward)
6396 "Search for an article containing REGEXP.
6397 Optional argument BACKWARD means do search for backward.
6398 `gnus-select-article-hook' is not called during the search."
6399 ;; We have to require this here to make sure that the following
6400 ;; dynamic binding isn't shadowed by autoloading.
6401 (require 'gnus-async)
6402 (let ((gnus-select-article-hook nil) ;Disable hook.
6403 (gnus-article-display-hook nil)
6404 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6405 (gnus-use-article-prefetch nil)
6406 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6407 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6408 (sum (current-buffer))
6411 (gnus-save-hidden-threads
6412 (gnus-summary-select-article)
6413 (set-buffer gnus-article-buffer)
6417 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6419 (re-search-backward regexp nil t)
6420 (re-search-forward regexp nil t))
6421 ;; We found the regexp.
6426 (get-buffer-window (current-buffer))
6430 (setq point (point)))
6431 ;; We didn't find it, so we go to the next article.
6434 (while (eq found 'not)
6435 (if (not (if backward (gnus-summary-find-prev)
6436 (gnus-summary-find-next)))
6437 ;; No more articles.
6439 ;; Select the next article and adjust point.
6440 (unless (gnus-summary-article-sparse-p
6441 (gnus-summary-article-number))
6443 (gnus-summary-select-article)
6444 (set-buffer gnus-article-buffer)
6446 (goto-char (if backward (point-max) (point-min))))))))
6447 (gnus-message 7 ""))
6448 ;; Return whether we found the regexp.
6449 (when (eq found 'found)
6451 (gnus-summary-show-thread)
6452 (gnus-summary-goto-subject gnus-current-article)
6453 (gnus-summary-position-point)
6456 (defun gnus-summary-find-matching (header regexp &optional backward unread
6458 "Return a list of all articles that match REGEXP on HEADER.
6459 The search stars on the current article and goes forwards unless
6460 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6461 If UNREAD is non-nil, only unread articles will
6462 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6463 in the comparisons."
6464 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6465 (gnus-data-find-list
6466 (gnus-summary-article-number) (gnus-data-list backward))))
6467 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6468 (case-fold-search (not not-case-fold))
6470 (unless (fboundp (intern (concat "mail-header-" header)))
6471 (error "%s is not a valid header" header))
6474 (and (or (not unread) ; We want all articles...
6475 (gnus-data-unread-p d)) ; Or just unreads.
6476 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6477 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6478 (push (gnus-data-number d) articles)) ; Success!
6479 (setq data (cdr data)))
6480 (nreverse articles)))
6482 (defun gnus-summary-execute-command (header regexp command &optional backward)
6483 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6484 If HEADER is an empty string (or nil), the match is done on the entire
6485 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6487 (list (let ((completion-ignore-case t))
6490 (mapcar (lambda (string) (list string))
6491 '("Number" "Subject" "From" "Lines" "Date"
6492 "Message-ID" "Xref" "References" "Body"))
6493 nil 'require-match))
6494 (read-string "Regexp: ")
6495 (read-key-sequence "Command: ")
6496 current-prefix-arg))
6497 (when (equal header "Body")
6499 (gnus-set-global-variables)
6500 ;; Hidden thread subtrees must be searched as well.
6501 (gnus-summary-show-all-threads)
6502 ;; We don't want to change current point nor window configuration.
6504 (save-window-excursion
6505 (gnus-message 6 "Executing %s..." (key-description command))
6506 ;; We'd like to execute COMMAND interactively so as to give arguments.
6507 (gnus-execute header regexp
6508 `(call-interactively ',(key-binding command))
6510 (gnus-message 6 "Executing %s...done" (key-description command)))))
6512 (defun gnus-summary-beginning-of-article ()
6513 "Scroll the article back to the beginning."
6515 (gnus-set-global-variables)
6516 (gnus-summary-select-article)
6517 (gnus-configure-windows 'article)
6518 (gnus-eval-in-buffer-window gnus-article-buffer
6520 (goto-char (point-min))
6521 (when gnus-page-broken
6522 (gnus-narrow-to-page))))
6524 (defun gnus-summary-end-of-article ()
6525 "Scroll to the end of the article."
6527 (gnus-set-global-variables)
6528 (gnus-summary-select-article)
6529 (gnus-configure-windows 'article)
6530 (gnus-eval-in-buffer-window gnus-article-buffer
6532 (goto-char (point-max))
6534 (when gnus-page-broken
6535 (gnus-narrow-to-page))))
6537 (defun gnus-summary-print-article (&optional filename)
6538 "Generate and print a PostScript image of the article buffer.
6540 If the optional argument FILENAME is nil, send the image to the printer.
6541 If FILENAME is a string, save the PostScript image in a file with that
6542 name. If FILENAME is a number, prompt the user for the name of the file
6544 (interactive (list (ps-print-preprint current-prefix-arg)))
6545 (gnus-summary-select-article)
6546 (gnus-eval-in-buffer-window gnus-article-buffer
6547 (let ((buffer (generate-new-buffer " *print*")))
6550 (copy-to-buffer buffer (point-min) (point-max))
6552 (gnus-article-delete-invisible-text)
6553 (run-hooks 'gnus-ps-print-hook)
6554 (ps-print-buffer-with-faces filename))
6555 (kill-buffer buffer)))))
6557 (defun gnus-summary-show-article (&optional arg)
6558 "Force re-fetching of the current article.
6559 If ARG (the prefix) is non-nil, show the raw article without any
6560 article massaging functions being run."
6562 (gnus-set-global-variables)
6564 ;; Select the article the normal way.
6565 (gnus-summary-select-article nil 'force)
6566 ;; Bind the article treatment functions to nil.
6567 (let ((gnus-have-all-headers t)
6568 gnus-article-display-hook
6569 gnus-article-prepare-hook
6573 (gnus-summary-select-article nil 'force)))
6574 (gnus-summary-goto-subject gnus-current-article)
6575 (gnus-summary-position-point))
6577 (defun gnus-summary-verbose-headers (&optional arg)
6578 "Toggle permanent full header display.
6579 If ARG is a positive number, turn header display on.
6580 If ARG is a negative number, turn header display off."
6582 (gnus-set-global-variables)
6583 (setq gnus-show-all-headers
6584 (cond ((or (not (numberp arg))
6586 (not gnus-show-all-headers))
6589 (gnus-summary-show-article))
6591 (defun gnus-summary-toggle-header (&optional arg)
6592 "Show the headers if they are hidden, or hide them if they are shown.
6593 If ARG is a positive number, show the entire header.
6594 If ARG is a negative number, hide the unwanted header lines."
6596 (gnus-set-global-variables)
6598 (set-buffer gnus-article-buffer)
6599 (let* ((buffer-read-only nil)
6600 (inhibit-point-motion-hooks t)
6601 (hidden (text-property-any
6602 (goto-char (point-min)) (search-forward "\n\n")
6605 (goto-char (point-min))
6606 (when (search-forward "\n\n" nil t)
6607 (delete-region (point-min) (1- (point))))
6608 (goto-char (point-min))
6610 (set-buffer gnus-original-article-buffer)
6611 (goto-char (point-min))
6612 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6613 (insert-buffer-substring gnus-original-article-buffer 1 e)
6614 (let ((article-inhibit-hiding t))
6615 (run-hooks 'gnus-article-display-hook))
6616 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6617 (gnus-article-hide-headers)))))
6619 (defun gnus-summary-show-all-headers ()
6620 "Make all header lines visible."
6622 (gnus-set-global-variables)
6623 (gnus-article-show-all-headers))
6625 (defun gnus-summary-toggle-mime (&optional arg)
6626 "Toggle MIME processing.
6627 If ARG is a positive number, turn MIME processing on."
6629 (gnus-set-global-variables)
6630 (setq gnus-show-mime
6631 (if (null arg) (not gnus-show-mime)
6632 (> (prefix-numeric-value arg) 0)))
6633 (gnus-summary-select-article t 'force))
6635 (defun gnus-summary-caesar-message (&optional arg)
6636 "Caesar rotate the current article by 13.
6637 The numerical prefix specifies how many places to rotate each letter
6640 (gnus-set-global-variables)
6641 (gnus-summary-select-article)
6642 (let ((mail-header-separator ""))
6643 (gnus-eval-in-buffer-window gnus-article-buffer
6646 (let ((start (window-start))
6648 (message-caesar-buffer-body arg)
6649 (set-window-start (get-buffer-window (current-buffer)) start))))))
6651 (defun gnus-summary-stop-page-breaking ()
6652 "Stop page breaking in the current article."
6654 (gnus-set-global-variables)
6655 (gnus-summary-select-article)
6656 (gnus-eval-in-buffer-window gnus-article-buffer
6658 (when (gnus-visual-p 'page-marker)
6659 (let ((buffer-read-only nil))
6660 (gnus-remove-text-with-property 'gnus-prev)
6661 (gnus-remove-text-with-property 'gnus-next)))))
6663 (defun gnus-summary-move-article (&optional n to-newsgroup
6664 select-method action)
6665 "Move the current article to a different newsgroup.
6666 If N is a positive number, move the N next articles.
6667 If N is a negative number, move the N previous articles.
6668 If N is nil and any articles have been marked with the process mark,
6669 move those articles instead.
6670 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6671 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6672 re-spool using this method.
6674 For this function to work, both the current newsgroup and the
6675 newsgroup that you want to move to have to support the `request-move'
6676 and `request-accept' functions."
6679 (setq action 'move))
6680 (gnus-set-global-variables)
6681 ;; Disable marking as read.
6682 (let (gnus-mark-article-hook)
6683 (save-window-excursion
6684 (gnus-summary-select-article)))
6685 ;; Check whether the source group supports the required functions.
6686 (cond ((and (eq action 'move)
6687 (not (gnus-check-backend-function
6688 'request-move-article gnus-newsgroup-name)))
6689 (error "The current group does not support article moving"))
6690 ((and (eq action 'crosspost)
6691 (not (gnus-check-backend-function
6692 'request-replace-article gnus-newsgroup-name)))
6693 (error "The current group does not support article editing")))
6694 (let ((articles (gnus-summary-work-articles n))
6695 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6696 (names '((move "Move" "Moving")
6697 (copy "Copy" "Copying")
6698 (crosspost "Crosspost" "Crossposting")))
6699 (copy-buf (save-excursion
6700 (nnheader-set-temp-buffer " *copy article*")))
6701 art-group to-method new-xref article to-groups)
6702 (unless (assq action names)
6703 (error "Unknown action %s" action))
6704 ;; Read the newsgroup name.
6705 (when (and (not to-newsgroup)
6706 (not select-method))
6708 (gnus-read-move-group-name
6709 (cadr (assq action names))
6710 (symbol-value (intern (format "gnus-current-%s-group" action)))
6712 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6713 (setq to-method (or select-method
6714 (gnus-group-name-to-method to-newsgroup)))
6715 ;; Check the method we are to move this article to...
6716 (unless (gnus-check-backend-function
6717 'request-accept-article (car to-method))
6718 (error "%s does not support article copying" (car to-method)))
6719 (unless (gnus-check-server to-method)
6720 (error "Can't open server %s" (car to-method)))
6721 (gnus-message 6 "%s to %s: %s..."
6722 (caddr (assq action names))
6723 (or (car select-method) to-newsgroup) articles)
6725 (setq article (pop articles))
6729 ;; Move the article.
6731 ;; Remove this article from future suppression.
6732 (gnus-dup-unsuppress-article article)
6733 (gnus-request-move-article
6734 article ; Article to move
6735 gnus-newsgroup-name ; From newsgroup
6736 (nth 1 (gnus-find-method-for-group
6737 gnus-newsgroup-name)) ; Server
6738 (list 'gnus-request-accept-article
6739 to-newsgroup (list 'quote select-method)
6740 (not articles)) ; Accept form
6741 (not articles))) ; Only save nov last time
6742 ;; Copy the article.
6745 (set-buffer copy-buf)
6746 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6747 (gnus-request-accept-article
6748 to-newsgroup select-method (not articles))))
6749 ;; Crosspost the article.
6750 ((eq action 'crosspost)
6751 (let ((xref (message-tokenize-header
6752 (mail-header-xref (gnus-summary-article-header article))
6754 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6757 (setq xref (list (system-name))))
6760 (mapconcat 'identity
6761 (delete "Xref:" (delete new-xref xref))
6765 (set-buffer copy-buf)
6766 ;; First put the article in the destination group.
6767 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6768 (when (consp (setq art-group
6769 (gnus-request-accept-article
6770 to-newsgroup select-method (not articles))))
6771 (setq new-xref (concat new-xref " " (car art-group)
6772 ":" (cdr art-group)))
6773 ;; Now we have the new Xrefs header, so we insert
6774 ;; it and replace the new article.
6775 (nnheader-replace-header "Xref" new-xref)
6776 (gnus-request-replace-article
6777 (cdr art-group) to-newsgroup (current-buffer))
6781 (gnus-message 1 "Couldn't %s article %s"
6782 (cadr (assq action names)) article))
6783 ((and (eq art-group 'junk)
6785 (gnus-summary-mark-article article gnus-canceled-mark)
6786 (gnus-message 4 "Deleted article %s" article))
6790 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6792 (gnus-group-prefixed-name
6795 (gnus-find-method-for-group to-newsgroup)))
6796 gnus-newsrc-hashtb)))
6797 (info (nth 2 entry))
6798 (to-group (gnus-info-group info)))
6799 ;; Update the group that has been moved to.
6801 (memq action '(move copy)))
6802 (unless (member to-group to-groups)
6803 (push to-group to-groups))
6805 (unless (memq article gnus-newsgroup-unreads)
6807 info (gnus-add-to-range (gnus-info-read info)
6808 (list (cdr art-group)))))
6810 ;; Copy any marks over to the new group.
6811 (let ((marks gnus-article-mark-lists)
6812 (to-article (cdr art-group)))
6814 ;; See whether the article is to be put in the cache.
6815 (when gnus-use-cache
6816 (gnus-cache-possibly-enter-article
6818 (let ((header (copy-sequence
6819 (gnus-summary-article-header article))))
6820 (mail-header-set-number header to-article)
6822 (memq article gnus-newsgroup-marked)
6823 (memq article gnus-newsgroup-dormant)
6824 (memq article gnus-newsgroup-unreads)))
6826 (when (and (equal to-group gnus-newsgroup-name)
6827 (not (memq article gnus-newsgroup-unreads)))
6828 ;; Mark this article as read in this group.
6829 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6830 (setcdr (gnus-active to-group) to-article)
6831 (setcdr gnus-newsgroup-active to-article))
6834 (when (memq article (symbol-value
6835 (intern (format "gnus-newsgroup-%s"
6837 ;; If the other group is the same as this group,
6838 ;; then we have to add the mark to the list.
6839 (when (equal to-group gnus-newsgroup-name)
6840 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6843 (intern (format "gnus-newsgroup-%s"
6845 ;; Copy the marks to other group.
6846 (gnus-add-marked-articles
6847 to-group (cdar marks) (list to-article) info))
6848 (setq marks (cdr marks)))
6851 (concat "(gnus-group-set-info '"
6852 (gnus-prin1-to-string (gnus-get-info to-group))
6855 ;; Update the Xref header in this article to point to
6856 ;; the new crossposted article we have just created.
6857 (when (eq action 'crosspost)
6859 (set-buffer copy-buf)
6860 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6861 (nnheader-replace-header "Xref" new-xref)
6862 (gnus-request-replace-article
6863 article gnus-newsgroup-name (current-buffer)))))
6865 (gnus-summary-goto-subject article)
6866 (when (eq action 'move)
6867 (gnus-summary-mark-article article gnus-canceled-mark))))
6868 (gnus-summary-remove-process-mark article))
6869 ;; Re-activate all groups that have been moved to.
6872 (set-buffer gnus-group-buffer)
6873 (when (gnus-group-goto-group (car to-groups) t)
6874 (gnus-group-get-new-news-this-group 1 t))
6877 (gnus-kill-buffer copy-buf)
6878 (gnus-summary-position-point)
6879 (gnus-set-mode-line 'summary)))
6881 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6882 "Move the current article to a different newsgroup.
6883 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6884 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6885 re-spool using this method."
6887 (gnus-summary-move-article n to-newsgroup select-method 'copy))
6889 (defun gnus-summary-crosspost-article (&optional n)
6890 "Crosspost the current article to some other group."
6892 (gnus-summary-move-article n nil nil 'crosspost))
6894 (defcustom gnus-summary-respool-default-method nil
6895 "Default method for respooling an article.
6896 If nil, use to the current newsgroup method."
6897 :type 'gnus-select-method-name
6898 :group 'gnus-summary-mail)
6900 (defun gnus-summary-respool-article (&optional n method)
6901 "Respool the current article.
6902 The article will be squeezed through the mail spooling process again,
6903 which means that it will be put in some mail newsgroup or other
6904 depending on `nnmail-split-methods'.
6905 If N is a positive number, respool the N next articles.
6906 If N is a negative number, respool the N previous articles.
6907 If N is nil and any articles have been marked with the process mark,
6908 respool those articles instead.
6910 Respooling can be done both from mail groups and \"real\" newsgroups.
6911 In the former case, the articles in question will be moved from the
6912 current group into whatever groups they are destined to. In the
6913 latter case, they will be copied into the relevant groups."
6915 (list current-prefix-arg
6916 (let* ((methods (gnus-methods-using 'respool))
6918 (symbol-name (or gnus-summary-respool-default-method
6919 (car (gnus-find-method-for-group
6920 gnus-newsgroup-name)))))
6922 (gnus-completing-read
6923 methname "What backend do you want to use when respooling?"
6924 methods nil t nil 'gnus-mail-method-history))
6927 ((zerop (length (setq ms (gnus-servers-using-backend
6929 (list (intern method) ""))
6933 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6934 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6936 (gnus-set-global-variables)
6938 (error "No method given for respooling"))
6939 (if (assoc (symbol-name
6940 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6941 (gnus-methods-using 'respool))
6942 (gnus-summary-move-article n nil method)
6943 (gnus-summary-copy-article n nil method)))
6945 (defun gnus-summary-import-article (file)
6946 "Import a random file into a mail newsgroup."
6947 (interactive "fImport file: ")
6948 (gnus-set-global-variables)
6949 (let ((group gnus-newsgroup-name)
6950 (now (current-time))
6952 (unless (gnus-check-backend-function 'request-accept-article group)
6953 (error "%s does not support article importing" group))
6954 (or (file-readable-p file)
6955 (not (file-regular-p file))
6956 (error "Can't read %s" file))
6958 (set-buffer (get-buffer-create " *import file*"))
6959 (buffer-disable-undo (current-buffer))
6961 (insert-file-contents file)
6962 (goto-char (point-min))
6963 (unless (nnheader-article-p)
6964 ;; This doesn't look like an article, so we fudge some headers.
6965 (setq atts (file-attributes file)
6966 lines (count-lines (point-min) (point-max)))
6967 (insert "From: " (read-string "From: ") "\n"
6968 "Subject: " (read-string "Subject: ") "\n"
6969 "Date: " (timezone-make-date-arpa-standard
6970 (current-time-string (nth 5 atts))
6971 (current-time-zone now)
6972 (current-time-zone now))
6974 "Message-ID: " (message-make-message-id) "\n"
6975 "Lines: " (int-to-string lines) "\n"
6976 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6977 (gnus-request-accept-article group nil t)
6978 (kill-buffer (current-buffer)))))
6980 (defun gnus-summary-article-posted-p ()
6981 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6982 This will be the case if the article has both been mailed and posted."
6984 (let ((id (mail-header-references (gnus-summary-article-header)))
6985 (gnus-override-method
6986 (or gnus-refer-article-method gnus-select-method)))
6987 (if (gnus-request-head id "")
6988 (gnus-message 2 "The current message was found on %s"
6989 gnus-override-method)
6990 (gnus-message 2 "The current message couldn't be found on %s"
6991 gnus-override-method)
6994 (defun gnus-summary-expire-articles (&optional now)
6995 "Expire all articles that are marked as expirable in the current group."
6997 (gnus-set-global-variables)
6998 (when (gnus-check-backend-function
6999 'request-expire-articles gnus-newsgroup-name)
7000 ;; This backend supports expiry.
7001 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7002 (expirable (if total
7004 ;; We need to update the info for
7005 ;; this group for `gnus-list-of-read-articles'
7006 ;; to give us the right answer.
7007 (run-hooks 'gnus-exit-group-hook)
7008 (gnus-summary-update-info)
7009 (gnus-list-of-read-articles gnus-newsgroup-name))
7010 (setq gnus-newsgroup-expirable
7011 (sort gnus-newsgroup-expirable '<))))
7012 (expiry-wait (if now 'immediate
7013 (gnus-group-find-parameter
7014 gnus-newsgroup-name 'expiry-wait)))
7017 ;; There are expirable articles in this group, so we run them
7018 ;; through the expiry process.
7019 (gnus-message 6 "Expiring articles...")
7020 ;; The list of articles that weren't expired is returned.
7022 (let ((nnmail-expiry-wait-function nil)
7023 (nnmail-expiry-wait expiry-wait))
7024 (setq es (gnus-request-expire-articles
7025 expirable gnus-newsgroup-name)))
7026 (setq es (gnus-request-expire-articles
7027 expirable gnus-newsgroup-name)))
7029 (setq gnus-newsgroup-expirable es))
7030 ;; We go through the old list of expirable, and mark all
7031 ;; really expired articles as nonexistent.
7032 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7033 (let ((gnus-use-cache nil))
7035 (unless (memq (car expirable) es)
7036 (when (gnus-data-find (car expirable))
7037 (gnus-summary-mark-article
7038 (car expirable) gnus-canceled-mark)))
7039 (setq expirable (cdr expirable)))))
7040 (gnus-message 6 "Expiring articles...done")))))
7042 (defun gnus-summary-expire-articles-now ()
7043 "Expunge all expirable articles in the current group.
7044 This means that *all* articles that are marked as expirable will be
7045 deleted forever, right now."
7047 (gnus-set-global-variables)
7048 (or gnus-expert-user
7050 "Are you really, really, really sure you want to delete all these messages? ")
7052 (gnus-summary-expire-articles t))
7054 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7055 (defun gnus-summary-delete-article (&optional n)
7056 "Delete the N next (mail) articles.
7057 This command actually deletes articles. This is not a marking
7058 command. The article will disappear forever from your life, never to
7060 If N is negative, delete backwards.
7061 If N is nil and articles have been marked with the process mark,
7062 delete these instead."
7064 (gnus-set-global-variables)
7065 (unless (gnus-check-backend-function 'request-expire-articles
7066 gnus-newsgroup-name)
7067 (error "The current newsgroup does not support article deletion"))
7068 ;; Compute the list of articles to delete.
7069 (let ((articles (gnus-summary-work-articles n))
7071 (if (and gnus-novice-user
7072 (not (gnus-yes-or-no-p
7073 (format "Do you really want to delete %s forever? "
7074 (if (> (length articles) 1)
7075 (format "these %s articles" (length articles))
7078 ;; Delete the articles.
7079 (setq not-deleted (gnus-request-expire-articles
7080 articles gnus-newsgroup-name 'force))
7082 (gnus-summary-remove-process-mark (car articles))
7083 ;; The backend might not have been able to delete the article
7085 (unless (memq (car articles) not-deleted)
7086 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7087 (setq articles (cdr articles)))
7089 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7090 (gnus-summary-position-point)
7091 (gnus-set-mode-line 'summary)
7094 (defun gnus-summary-edit-article (&optional force)
7095 "Edit the current article.
7096 This will have permanent effect only in mail groups.
7097 If FORCE is non-nil, allow editing of articles even in read-only
7101 (set-buffer gnus-summary-buffer)
7102 (gnus-set-global-variables)
7103 (when (and (not force)
7104 (gnus-group-read-only-p))
7105 (error "The current newsgroup does not support article editing"))
7106 ;; Select article if needed.
7107 (unless (eq (gnus-summary-article-number)
7108 gnus-current-article)
7109 (gnus-summary-select-article t))
7110 (gnus-article-date-original)
7111 (gnus-article-edit-article
7113 (gnus-summary-edit-article-done
7114 ,(or (mail-header-references gnus-current-headers) "")
7115 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
7117 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7119 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
7120 "Make edits to the current article permanent."
7122 ;; Replace the article.
7123 (if (and (not read-only)
7124 (not (gnus-request-replace-article
7125 (cdr gnus-article-current) (car gnus-article-current)
7127 (error "Couldn't replace article")
7128 ;; Update the summary buffer.
7130 (equal (message-tokenize-header references " ")
7131 (message-tokenize-header
7132 (or (message-fetch-field "references") "") " ")))
7133 ;; We only have to update this line.
7136 (message-narrow-to-head)
7137 (let ((head (buffer-string))
7139 (nnheader-temp-write nil
7140 (insert (format "211 %d Article retrieved.\n"
7141 (cdr gnus-article-current)))
7144 (let ((nntp-server-buffer (current-buffer)))
7145 (setq header (car (gnus-get-newsgroup-headers
7147 (set-buffer gnus-summary-buffer)
7148 gnus-newsgroup-dependencies)
7151 (set-buffer gnus-summary-buffer)
7152 (gnus-data-set-header
7153 (gnus-data-find (cdr gnus-article-current))
7155 (gnus-summary-update-article-line
7156 (cdr gnus-article-current) header))))))
7158 (set-buffer (or buffer gnus-summary-buffer))
7159 (gnus-summary-update-article (cdr gnus-article-current)))
7160 ;; Prettify the article buffer again.
7162 (set-buffer gnus-article-buffer)
7163 (run-hooks 'gnus-article-display-hook)
7164 (set-buffer gnus-original-article-buffer)
7165 (gnus-request-article
7166 (cdr gnus-article-current) (car gnus-article-current) (current-buffer)))
7167 ;; Prettify the summary buffer line.
7168 (when (gnus-visual-p 'summary-highlight 'highlight)
7169 (run-hooks 'gnus-visual-mark-article-hook))))
7171 (defun gnus-summary-edit-wash (key)
7172 "Perform editing command in the article buffer."
7176 (message "%s" (concat (this-command-keys) "- "))
7179 (gnus-summary-edit-article)
7180 (execute-kbd-macro (concat (this-command-keys) key))
7181 (gnus-article-edit-done))
7185 (defun gnus-summary-respool-query (&optional silent)
7186 "Query where the respool algorithm would put this article."
7188 (gnus-set-global-variables)
7189 (let (gnus-mark-article-hook)
7190 (gnus-summary-select-article)
7192 (set-buffer gnus-original-article-buffer)
7194 (message-narrow-to-head)
7195 (let ((groups (nnmail-article-group 'identity)))
7198 (message "This message would go to %s"
7199 (mapconcat 'car groups ", "))
7200 (message "This message would go to no groups"))
7203 ;; Summary marking commands.
7205 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7206 "Mark articles which has the same subject as read, and then select the next.
7207 If UNMARK is positive, remove any kind of mark.
7208 If UNMARK is negative, tick articles."
7210 (gnus-set-global-variables)
7212 (setq unmark (prefix-numeric-value unmark)))
7214 (gnus-summary-mark-same-subject
7215 (gnus-summary-article-subject) unmark)))
7216 ;; Select next unread article. If auto-select-same mode, should
7217 ;; select the first unread article.
7218 (gnus-summary-next-article t (and gnus-auto-select-same
7219 (gnus-summary-article-subject)))
7220 (gnus-message 7 "%d article%s marked as %s"
7221 count (if (= count 1) " is" "s are")
7222 (if unmark "unread" "read"))))
7224 (defun gnus-summary-kill-same-subject (&optional unmark)
7225 "Mark articles which has the same subject as read.
7226 If UNMARK is positive, remove any kind of mark.
7227 If UNMARK is negative, tick articles."
7229 (gnus-set-global-variables)
7231 (setq unmark (prefix-numeric-value unmark)))
7233 (gnus-summary-mark-same-subject
7234 (gnus-summary-article-subject) unmark)))
7235 ;; If marked as read, go to next unread subject.
7237 ;; Go to next unread subject.
7238 (gnus-summary-next-subject 1 t))
7239 (gnus-message 7 "%d articles are marked as %s"
7240 count (if unmark "unread" "read"))))
7242 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7243 "Mark articles with same SUBJECT as read, and return marked number.
7244 If optional argument UNMARK is positive, remove any kinds of marks.
7245 If optional argument UNMARK is negative, mark articles as unread instead."
7249 ((null unmark) ; Mark as read.
7252 (gnus-summary-mark-article-as-read gnus-killed-mark)
7253 (gnus-summary-show-thread) t)
7254 (gnus-summary-find-subject subject))
7255 (setq count (1+ count))))
7256 ((> unmark 0) ; Tick.
7259 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7260 (gnus-summary-show-thread) t)
7261 (gnus-summary-find-subject subject))
7262 (setq count (1+ count))))
7263 (t ; Mark as unread.
7266 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7267 (gnus-summary-show-thread) t)
7268 (gnus-summary-find-subject subject))
7269 (setq count (1+ count)))))
7270 (gnus-set-mode-line 'summary)
7271 ;; Return the number of marked articles.
7274 (defun gnus-summary-mark-as-processable (n &optional unmark)
7275 "Set the process mark on the next N articles.
7276 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7277 the process mark instead. The difference between N and the actual
7278 number of articles marked is returned."
7280 (gnus-set-global-variables)
7281 (let ((backward (< n 0))
7286 (gnus-summary-remove-process-mark
7287 (gnus-summary-article-number))
7288 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7289 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7292 (gnus-message 7 "No more articles"))
7293 (gnus-summary-recenter)
7294 (gnus-summary-position-point)
7297 (defun gnus-summary-unmark-as-processable (n)
7298 "Remove the process mark from the next N articles.
7299 If N is negative, unmark backward instead. The difference between N and
7300 the actual number of articles unmarked is returned."
7302 (gnus-set-global-variables)
7303 (gnus-summary-mark-as-processable n t))
7305 (defun gnus-summary-unmark-all-processable ()
7306 "Remove the process mark from all articles."
7308 (gnus-set-global-variables)
7310 (while gnus-newsgroup-processable
7311 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7312 (gnus-summary-position-point))
7314 (defun gnus-summary-mark-as-expirable (n)
7315 "Mark N articles forward as expirable.
7316 If N is negative, mark backward instead. The difference between N and
7317 the actual number of articles marked is returned."
7319 (gnus-set-global-variables)
7320 (gnus-summary-mark-forward n gnus-expirable-mark))
7322 (defun gnus-summary-mark-article-as-replied (article)
7323 "Mark ARTICLE replied and update the summary line."
7324 (push article gnus-newsgroup-replied)
7325 (let ((buffer-read-only nil))
7326 (when (gnus-summary-goto-subject article)
7327 (gnus-summary-update-secondary-mark article))))
7329 (defun gnus-summary-set-bookmark (article)
7330 "Set a bookmark in current article."
7331 (interactive (list (gnus-summary-article-number)))
7332 (gnus-set-global-variables)
7333 (when (or (not (get-buffer gnus-article-buffer))
7334 (not gnus-current-article)
7335 (not gnus-article-current)
7336 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7337 (error "No current article selected"))
7338 ;; Remove old bookmark, if one exists.
7339 (let ((old (assq article gnus-newsgroup-bookmarks)))
7341 (setq gnus-newsgroup-bookmarks
7342 (delq old gnus-newsgroup-bookmarks))))
7343 ;; Set the new bookmark, which is on the form
7344 ;; (article-number . line-number-in-body).
7348 (set-buffer gnus-article-buffer)
7352 (goto-char (point-min))
7353 (search-forward "\n\n" nil t)
7356 gnus-newsgroup-bookmarks)
7357 (gnus-message 6 "A bookmark has been added to the current article."))
7359 (defun gnus-summary-remove-bookmark (article)
7360 "Remove the bookmark from the current article."
7361 (interactive (list (gnus-summary-article-number)))
7362 (gnus-set-global-variables)
7363 ;; Remove old bookmark, if one exists.
7364 (let ((old (assq article gnus-newsgroup-bookmarks)))
7367 (setq gnus-newsgroup-bookmarks
7368 (delq old gnus-newsgroup-bookmarks))
7369 (gnus-message 6 "Removed bookmark."))
7370 (gnus-message 6 "No bookmark in current article."))))
7372 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7373 (defun gnus-summary-mark-as-dormant (n)
7374 "Mark N articles forward as dormant.
7375 If N is negative, mark backward instead. The difference between N and
7376 the actual number of articles marked is returned."
7378 (gnus-set-global-variables)
7379 (gnus-summary-mark-forward n gnus-dormant-mark))
7381 (defun gnus-summary-set-process-mark (article)
7382 "Set the process mark on ARTICLE and update the summary line."
7383 (setq gnus-newsgroup-processable
7385 (delq article gnus-newsgroup-processable)))
7386 (when (gnus-summary-goto-subject article)
7387 (gnus-summary-show-thread)
7388 (gnus-summary-update-secondary-mark article)))
7390 (defun gnus-summary-remove-process-mark (article)
7391 "Remove the process mark from ARTICLE and update the summary line."
7392 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7393 (when (gnus-summary-goto-subject article)
7394 (gnus-summary-show-thread)
7395 (gnus-summary-update-secondary-mark article)))
7397 (defun gnus-summary-set-saved-mark (article)
7398 "Set the process mark on ARTICLE and update the summary line."
7399 (push article gnus-newsgroup-saved)
7400 (when (gnus-summary-goto-subject article)
7401 (gnus-summary-update-secondary-mark article)))
7403 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7404 "Mark N articles as read forwards.
7405 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7406 The difference between N and the actual number of articles marked is
7409 (gnus-set-global-variables)
7410 (let ((backward (< n 0))
7411 (gnus-summary-goto-unread
7412 (and gnus-summary-goto-unread
7413 (not (eq gnus-summary-goto-unread 'never))
7414 (not (memq mark (list gnus-unread-mark
7415 gnus-ticked-mark gnus-dormant-mark)))))
7417 (mark (or mark gnus-del-mark)))
7419 (gnus-summary-mark-article nil mark no-expire)
7420 (zerop (gnus-summary-next-subject
7422 (and gnus-summary-goto-unread
7423 (not (eq gnus-summary-goto-unread 'never)))
7427 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7428 (gnus-summary-recenter)
7429 (gnus-summary-position-point)
7430 (gnus-set-mode-line 'summary)
7433 (defun gnus-summary-mark-article-as-read (mark)
7434 "Mark the current article quickly as read with MARK."
7435 (let ((article (gnus-summary-article-number)))
7436 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7437 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7438 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7439 (push (cons article mark) gnus-newsgroup-reads)
7440 ;; Possibly remove from cache, if that is used.
7441 (when gnus-use-cache
7442 (gnus-cache-enter-remove-article article))
7443 ;; Allow the backend to change the mark.
7444 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7445 ;; Check for auto-expiry.
7446 (when (and gnus-newsgroup-auto-expire
7447 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7448 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7449 (= mark gnus-ancient-mark)
7450 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7451 (= mark gnus-duplicate-mark)))
7452 (setq mark gnus-expirable-mark)
7453 (push article gnus-newsgroup-expirable))
7454 ;; Set the mark in the buffer.
7455 (gnus-summary-update-mark mark 'unread)
7458 (defun gnus-summary-mark-article-as-unread (mark)
7459 "Mark the current article quickly as unread with MARK."
7460 (let ((article (gnus-summary-article-number)))
7462 (gnus-error 1 "Unmarkable article")
7463 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7464 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7465 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7466 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7467 (cond ((= mark gnus-ticked-mark)
7468 (push article gnus-newsgroup-marked))
7469 ((= mark gnus-dormant-mark)
7470 (push article gnus-newsgroup-dormant))
7472 (push article gnus-newsgroup-unreads)))
7473 (setq gnus-newsgroup-reads
7474 (delq (assq article gnus-newsgroup-reads)
7475 gnus-newsgroup-reads))
7477 ;; See whether the article is to be put in the cache.
7479 (vectorp (gnus-summary-article-header article))
7481 (gnus-cache-possibly-enter-article
7482 gnus-newsgroup-name article
7483 (gnus-summary-article-header article)
7484 (= mark gnus-ticked-mark)
7485 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7488 (gnus-summary-update-mark mark 'unread))
7491 (defun gnus-summary-mark-article (&optional article mark no-expire)
7492 "Mark ARTICLE with MARK. MARK can be any character.
7493 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7494 `??' (dormant) and `?E' (expirable).
7495 If MARK is nil, then the default character `?D' is used.
7496 If ARTICLE is nil, then the article on the current line will be
7498 ;; The mark might be a string.
7499 (when (stringp mark)
7500 (setq mark (aref mark 0)))
7501 ;; If no mark is given, then we check auto-expiring.
7502 (and (not no-expire)
7503 gnus-newsgroup-auto-expire
7505 (and (gnus-characterp mark)
7506 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7507 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7508 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7509 (= mark gnus-duplicate-mark))))
7510 (setq mark gnus-expirable-mark))
7511 (let* ((mark (or mark gnus-del-mark))
7512 (article (or article (gnus-summary-article-number))))
7514 (error "No article on current line"))
7515 (if (or (= mark gnus-unread-mark)
7516 (= mark gnus-ticked-mark)
7517 (= mark gnus-dormant-mark))
7518 (gnus-mark-article-as-unread article mark)
7519 (gnus-mark-article-as-read article mark))
7521 ;; See whether the article is to be put in the cache.
7523 (not (= mark gnus-canceled-mark))
7524 (vectorp (gnus-summary-article-header article))
7526 (gnus-cache-possibly-enter-article
7527 gnus-newsgroup-name article
7528 (gnus-summary-article-header article)
7529 (= mark gnus-ticked-mark)
7530 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7532 (when (gnus-summary-goto-subject article nil t)
7533 (let ((buffer-read-only nil))
7534 (gnus-summary-show-thread)
7536 (gnus-summary-update-mark mark 'unread)
7539 (defun gnus-summary-update-secondary-mark (article)
7540 "Update the secondary (read, process, cache) mark."
7541 (gnus-summary-update-mark
7542 (cond ((memq article gnus-newsgroup-processable)
7544 ((memq article gnus-newsgroup-cached)
7546 ((memq article gnus-newsgroup-replied)
7548 ((memq article gnus-newsgroup-saved)
7550 (t gnus-unread-mark))
7552 (when (gnus-visual-p 'summary-highlight 'highlight)
7553 (run-hooks 'gnus-summary-update-hook))
7556 (defun gnus-summary-update-mark (mark type)
7557 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7558 (buffer-read-only nil))
7559 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7560 (when (looking-at "\r")
7563 (<= (+ forward (point)) (point-max)))
7564 ;; Go to the right position on the line.
7565 (goto-char (+ forward (point)))
7566 ;; Replace the old mark with the new mark.
7567 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7568 ;; Optionally update the marks by some user rule.
7569 (when (eq type 'unread)
7571 (gnus-data-find (gnus-summary-article-number)) mark)
7572 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7574 (defun gnus-mark-article-as-read (article &optional mark)
7575 "Enter ARTICLE in the pertinent lists and remove it from others."
7576 ;; Make the article expirable.
7577 (let ((mark (or mark gnus-del-mark)))
7578 (if (= mark gnus-expirable-mark)
7579 (push article gnus-newsgroup-expirable)
7580 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7581 ;; Remove from unread and marked lists.
7582 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7583 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7584 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7585 (push (cons article mark) gnus-newsgroup-reads)
7586 ;; Possibly remove from cache, if that is used.
7587 (when gnus-use-cache
7588 (gnus-cache-enter-remove-article article))))
7590 (defun gnus-mark-article-as-unread (article &optional mark)
7591 "Enter ARTICLE in the pertinent lists and remove it from others."
7592 (let ((mark (or mark gnus-ticked-mark)))
7593 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7594 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7595 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7596 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7598 ;; Unsuppress duplicates?
7599 (when gnus-suppress-duplicates
7600 (gnus-dup-unsuppress-article article))
7602 (cond ((= mark gnus-ticked-mark)
7603 (push article gnus-newsgroup-marked))
7604 ((= mark gnus-dormant-mark)
7605 (push article gnus-newsgroup-dormant))
7607 (push article gnus-newsgroup-unreads)))
7608 (setq gnus-newsgroup-reads
7609 (delq (assq article gnus-newsgroup-reads)
7610 gnus-newsgroup-reads))))
7612 (defalias 'gnus-summary-mark-as-unread-forward
7613 'gnus-summary-tick-article-forward)
7614 (make-obsolete 'gnus-summary-mark-as-unread-forward
7615 'gnus-summary-tick-article-forward)
7616 (defun gnus-summary-tick-article-forward (n)
7617 "Tick N articles forwards.
7618 If N is negative, tick backwards instead.
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-backward
7624 'gnus-summary-tick-article-backward)
7625 (make-obsolete 'gnus-summary-mark-as-unread-backward
7626 'gnus-summary-tick-article-backward)
7627 (defun gnus-summary-tick-article-backward (n)
7628 "Tick N articles backwards.
7629 The difference between N and the number of articles ticked is returned."
7631 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7633 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7634 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7635 (defun gnus-summary-tick-article (&optional article clear-mark)
7636 "Mark current article as unread.
7637 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7638 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7640 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7643 (defun gnus-summary-mark-as-read-forward (n)
7644 "Mark N articles as read forwards.
7645 If N is negative, mark backwards instead.
7646 The difference between N and the actual number of articles marked is
7649 (gnus-summary-mark-forward n gnus-del-mark t))
7651 (defun gnus-summary-mark-as-read-backward (n)
7652 "Mark the N articles as read backwards.
7653 The difference between N and the actual number of articles marked is
7656 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7658 (defun gnus-summary-mark-as-read (&optional article mark)
7659 "Mark current article as read.
7660 ARTICLE specifies the article to be marked as read.
7661 MARK specifies a string to be inserted at the beginning of the line."
7662 (gnus-summary-mark-article article mark))
7664 (defun gnus-summary-clear-mark-forward (n)
7665 "Clear marks from N articles forward.
7666 If N is negative, clear backward instead.
7667 The difference between N and the number of marks cleared is returned."
7669 (gnus-summary-mark-forward n gnus-unread-mark))
7671 (defun gnus-summary-clear-mark-backward (n)
7672 "Clear marks from N articles backward.
7673 The difference between N and the number of marks cleared is returned."
7675 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7677 (defun gnus-summary-mark-unread-as-read ()
7678 "Intended to be used by `gnus-summary-mark-article-hook'."
7679 (when (memq gnus-current-article gnus-newsgroup-unreads)
7680 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7682 (defun gnus-summary-mark-read-and-unread-as-read ()
7683 "Intended to be used by `gnus-summary-mark-article-hook'."
7684 (let ((mark (gnus-summary-article-mark)))
7685 (when (or (gnus-unread-mark-p mark)
7686 (gnus-read-mark-p mark))
7687 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7689 (defun gnus-summary-mark-region-as-read (point mark all)
7690 "Mark all unread articles between point and mark as read.
7691 If given a prefix, mark all articles between point and mark as read,
7692 even ticked and dormant ones."
7693 (interactive "r\nP")
7702 (memq (setq article (gnus-summary-article-number))
7703 gnus-newsgroup-unreads))
7704 (gnus-summary-mark-article article gnus-del-mark))
7706 (gnus-summary-find-next))))))
7708 (defun gnus-summary-mark-below (score mark)
7709 "Mark articles with score less than SCORE with MARK."
7710 (interactive "P\ncMark: ")
7711 (gnus-set-global-variables)
7712 (setq score (if score
7713 (prefix-numeric-value score)
7714 (or gnus-summary-default-score 0)))
7716 (set-buffer gnus-summary-buffer)
7717 (goto-char (point-min))
7720 (and (< (gnus-summary-article-score) score)
7721 (gnus-summary-mark-article nil mark))
7722 (gnus-summary-find-next)))))
7724 (defun gnus-summary-kill-below (&optional score)
7725 "Mark articles with score below SCORE as read."
7727 (gnus-set-global-variables)
7728 (gnus-summary-mark-below score gnus-killed-mark))
7730 (defun gnus-summary-clear-above (&optional score)
7731 "Clear all marks from articles with score above SCORE."
7733 (gnus-set-global-variables)
7734 (gnus-summary-mark-above score gnus-unread-mark))
7736 (defun gnus-summary-tick-above (&optional score)
7737 "Tick all articles with score above SCORE."
7739 (gnus-set-global-variables)
7740 (gnus-summary-mark-above score gnus-ticked-mark))
7742 (defun gnus-summary-mark-above (score mark)
7743 "Mark articles with score over SCORE with MARK."
7744 (interactive "P\ncMark: ")
7745 (gnus-set-global-variables)
7746 (setq score (if score
7747 (prefix-numeric-value score)
7748 (or gnus-summary-default-score 0)))
7750 (set-buffer gnus-summary-buffer)
7751 (goto-char (point-min))
7753 (when (> (gnus-summary-article-score) score)
7754 (gnus-summary-mark-article nil mark))
7756 (gnus-summary-find-next)))))
7758 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7759 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7760 (defun gnus-summary-limit-include-expunged (&optional no-error)
7761 "Display all the hidden articles that were expunged for low scores."
7763 (gnus-set-global-variables)
7764 (let ((buffer-read-only nil))
7765 (let ((scored gnus-newsgroup-scored)
7768 (unless (gnus-summary-goto-subject (caar scored))
7769 (and (setq h (gnus-summary-article-header (caar scored)))
7770 (< (cdar scored) gnus-summary-expunge-below)
7772 (setq scored (cdr scored)))
7774 (when (not no-error)
7775 (error "No expunged articles hidden"))
7776 (goto-char (point-min))
7777 (gnus-summary-prepare-unthreaded (nreverse headers))
7778 (goto-char (point-min))
7779 (gnus-summary-position-point)
7782 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7783 "Mark all unread articles in this newsgroup as read.
7784 If prefix argument ALL is non-nil, ticked and dormant articles will
7785 also be marked as read.
7786 If QUIETLY is non-nil, no questions will be asked.
7787 If TO-HERE is non-nil, it should be a point in the buffer. All
7788 articles before this point will be marked as read.
7789 Note that this function will only catch up the unread article
7790 in the current summary buffer limitation.
7791 The number of articles marked as read is returned."
7793 (gnus-set-global-variables)
7797 (not gnus-interactive-catchup) ;Without confirmation?
7801 "Mark absolutely all articles as read? "
7802 "Mark all unread articles as read? ")))
7804 (not gnus-newsgroup-adaptive)
7805 (not gnus-newsgroup-auto-expire)
7806 (not gnus-suppress-duplicates)
7807 (or (not gnus-use-cache)
7808 (eq gnus-use-cache 'passive)))
7811 (setq gnus-newsgroup-marked nil
7812 gnus-newsgroup-dormant nil))
7813 (setq gnus-newsgroup-unreads nil))
7814 ;; We actually mark all articles as canceled, which we
7815 ;; have to do when using auto-expiry or adaptive scoring.
7816 (gnus-summary-show-all-threads)
7817 (when (gnus-summary-first-subject (not all))
7819 (if to-here (< (point) to-here) t)
7820 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7821 (gnus-summary-find-next (not all)))))
7822 (gnus-set-mode-line 'summary))
7824 (gnus-summary-position-point)))
7826 (defun gnus-summary-catchup-to-here (&optional all)
7827 "Mark all unticked articles before the current one as read.
7828 If ALL is non-nil, also mark ticked and dormant articles as read."
7830 (gnus-set-global-variables)
7832 (gnus-save-hidden-threads
7833 (let ((beg (point)))
7834 ;; We check that there are unread articles.
7835 (when (or all (gnus-summary-find-prev))
7836 (gnus-summary-catchup all t beg)))))
7837 (gnus-summary-position-point))
7839 (defun gnus-summary-catchup-all (&optional quietly)
7840 "Mark all articles in this newsgroup as read."
7842 (gnus-set-global-variables)
7843 (gnus-summary-catchup t quietly))
7845 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7846 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7847 If prefix argument ALL is non-nil, all articles are marked as read."
7849 (gnus-set-global-variables)
7850 (when (gnus-summary-catchup all quietly nil 'fast)
7851 ;; Select next newsgroup or exit.
7852 (if (eq gnus-auto-select-next 'quietly)
7853 (gnus-summary-next-group nil)
7854 (gnus-summary-exit))))
7856 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7857 "Mark all articles in this newsgroup as read, and then exit."
7859 (gnus-set-global-variables)
7860 (gnus-summary-catchup-and-exit t quietly))
7862 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7863 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7864 "Mark all articles in this group as read and select the next group.
7865 If given a prefix, mark all articles, unread as well as ticked, as
7868 (gnus-set-global-variables)
7870 (gnus-summary-catchup all))
7871 (gnus-summary-next-article t nil nil t))
7873 ;; Thread-based commands.
7875 (defun gnus-summary-articles-in-thread (&optional article)
7876 "Return a list of all articles in the current thread.
7877 If ARTICLE is non-nil, return all articles in the thread that starts
7879 (let* ((article (or article (gnus-summary-article-number)))
7880 (data (gnus-data-find-list article))
7881 (top-level (gnus-data-level (car data)))
7883 (cond ((null gnus-thread-operation-ignore-subject)
7884 (gnus-simplify-subject-re
7885 (mail-header-subject (gnus-data-header (car data)))))
7886 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7887 (gnus-simplify-subject-fuzzy
7888 (mail-header-subject (gnus-data-header (car data)))))
7890 (end-point (save-excursion
7891 (if (gnus-summary-go-to-next-thread)
7892 (point) (point-max))))
7895 (< (gnus-data-pos (car data)) end-point))
7896 (when (or (not top-subject)
7897 (string= top-subject
7898 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7899 (gnus-simplify-subject-fuzzy
7900 (mail-header-subject
7901 (gnus-data-header (car data))))
7902 (gnus-simplify-subject-re
7903 (mail-header-subject
7904 (gnus-data-header (car data)))))))
7905 (push (gnus-data-number (car data)) articles))
7906 (unless (and (setq data (cdr data))
7907 (> (gnus-data-level (car data)) top-level))
7909 ;; Return the list of articles.
7910 (nreverse articles)))
7912 (defun gnus-summary-rethread-current ()
7913 "Rethread the thread the current article is part of."
7915 (gnus-set-global-variables)
7916 (let* ((gnus-show-threads t)
7917 (article (gnus-summary-article-number))
7918 (id (mail-header-id (gnus-summary-article-header)))
7919 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7921 (error "No article on the current line"))
7922 (gnus-rebuild-thread id)
7923 (gnus-summary-goto-subject article)))
7925 (defun gnus-summary-reparent-thread ()
7926 "Make the current article child of the marked (or previous) article.
7928 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7929 is non-nil or the Subject: of both articles are the same."
7931 (unless (not (gnus-group-read-only-p))
7932 (error "The current newsgroup does not support article editing"))
7933 (unless (<= (length gnus-newsgroup-processable) 1)
7934 (error "No more than one article may be marked"))
7935 (save-window-excursion
7936 (let ((gnus-article-buffer " *reparent*")
7937 (current-article (gnus-summary-article-number))
7938 ;; First grab the marked article, otherwise one line up.
7939 (parent-article (if (not (null gnus-newsgroup-processable))
7940 (car gnus-newsgroup-processable)
7942 (if (eq (forward-line -1) 0)
7943 (gnus-summary-article-number)
7944 (error "Beginning of summary buffer"))))))
7945 (unless (not (eq current-article parent-article))
7946 (error "An article may not be self-referential"))
7947 (let ((message-id (mail-header-id
7948 (gnus-summary-article-header parent-article))))
7949 (unless (and message-id (not (equal message-id "")))
7950 (error "No message-id in desired parent"))
7951 (gnus-summary-select-article t t nil current-article)
7952 (set-buffer gnus-original-article-buffer)
7953 (let ((buf (format "%s" (buffer-string))))
7954 (nnheader-temp-write nil
7956 (goto-char (point-min))
7957 (if (search-forward-regexp "^References: " nil t)
7958 (insert message-id " " )
7959 (insert "References: " message-id "\n"))
7960 (unless (gnus-request-replace-article
7961 current-article (car gnus-article-current)
7963 (error "Couldn't replace article"))))
7964 (set-buffer gnus-summary-buffer)
7965 (gnus-summary-unmark-all-processable)
7966 (gnus-summary-rethread-current)
7967 (gnus-message 3 "Article %d is now the child of article %d"
7968 current-article parent-article)))))
7970 (defun gnus-summary-toggle-threads (&optional arg)
7971 "Toggle showing conversation threads.
7972 If ARG is positive number, turn showing conversation threads on."
7974 (gnus-set-global-variables)
7975 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7976 (setq gnus-show-threads
7977 (if (null arg) (not gnus-show-threads)
7978 (> (prefix-numeric-value arg) 0)))
7979 (gnus-summary-prepare)
7980 (gnus-summary-goto-subject current)
7981 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7982 (gnus-summary-position-point)))
7984 (defun gnus-summary-show-all-threads ()
7987 (gnus-set-global-variables)
7989 (let ((buffer-read-only nil))
7990 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7991 (gnus-summary-position-point))
7993 (defun gnus-summary-show-thread ()
7994 "Show thread subtrees.
7995 Returns nil if no thread was there to be shown."
7997 (gnus-set-global-variables)
7998 (let ((buffer-read-only nil)
8000 ;; first goto end then to beg, to have point at beg after let
8001 (end (progn (end-of-line) (point)))
8002 (beg (progn (beginning-of-line) (point))))
8004 ;; Any hidden lines here?
8005 (search-forward "\r" end t)
8006 (subst-char-in-region beg end ?\^M ?\n t)
8008 (gnus-summary-position-point))))
8010 (defun gnus-summary-hide-all-threads ()
8011 "Hide all thread subtrees."
8013 (gnus-set-global-variables)
8015 (goto-char (point-min))
8016 (gnus-summary-hide-thread)
8017 (while (zerop (gnus-summary-next-thread 1 t))
8018 (gnus-summary-hide-thread)))
8019 (gnus-summary-position-point))
8021 (defun gnus-summary-hide-thread ()
8022 "Hide thread subtrees.
8023 Returns nil if no threads were there to be hidden."
8025 (gnus-set-global-variables)
8026 (let ((buffer-read-only nil)
8028 (article (gnus-summary-article-number)))
8030 ;; Go forward until either the buffer ends or the subthread
8032 (when (and (not (eobp))
8033 (or (zerop (gnus-summary-next-thread 1 t))
8034 (goto-char (point-max))))
8036 (if (and (> (point) start)
8037 (search-backward "\n" start t))
8039 (subst-char-in-region start (point) ?\n ?\^M)
8040 (gnus-summary-goto-subject article))
8043 ;;(gnus-summary-position-point)
8046 (defun gnus-summary-go-to-next-thread (&optional previous)
8047 "Go to the same level (or less) next thread.
8048 If PREVIOUS is non-nil, go to previous thread instead.
8049 Return the article number moved to, or nil if moving was impossible."
8050 (let ((level (gnus-summary-thread-level))
8051 (way (if previous -1 1))
8054 (while (and (not (eobp))
8055 (< level (gnus-summary-thread-level)))
8063 (gnus-summary-article-number)
8066 (defun gnus-summary-next-thread (n &optional silent)
8067 "Go to the same level next N'th thread.
8068 If N is negative, search backward instead.
8069 Returns the difference between N and the number of skips actually
8072 If SILENT, don't output messages."
8074 (gnus-set-global-variables)
8075 (let ((backward (< n 0))
8078 (gnus-summary-go-to-next-thread backward))
8081 (gnus-summary-position-point))
8082 (when (and (not silent) (/= 0 n))
8083 (gnus-message 7 "No more threads"))
8086 (defun gnus-summary-prev-thread (n)
8087 "Go to the same level previous N'th thread.
8088 Returns the difference between N and the number of skips actually
8091 (gnus-set-global-variables)
8092 (gnus-summary-next-thread (- n)))
8094 (defun gnus-summary-go-down-thread ()
8095 "Go down one level in the current thread."
8096 (let ((children (gnus-summary-article-children)))
8098 (gnus-summary-goto-subject (car children)))))
8100 (defun gnus-summary-go-up-thread ()
8101 "Go up one level in the current thread."
8102 (let ((parent (gnus-summary-article-parent)))
8104 (gnus-summary-goto-subject parent))))
8106 (defun gnus-summary-down-thread (n)
8107 "Go down thread N steps.
8108 If N is negative, go up instead.
8109 Returns the difference between N and how many steps down that were
8112 (gnus-set-global-variables)
8116 (if up (gnus-summary-go-up-thread)
8117 (gnus-summary-go-down-thread)))
8119 (gnus-summary-position-point)
8121 (gnus-message 7 "Can't go further"))
8124 (defun gnus-summary-up-thread (n)
8125 "Go up thread N steps.
8126 If N is negative, go up instead.
8127 Returns the difference between N and how many steps down that were
8130 (gnus-set-global-variables)
8131 (gnus-summary-down-thread (- n)))
8133 (defun gnus-summary-top-thread ()
8134 "Go to the top of the thread."
8136 (gnus-set-global-variables)
8137 (while (gnus-summary-go-up-thread))
8138 (gnus-summary-article-number))
8140 (defun gnus-summary-kill-thread (&optional unmark)
8141 "Mark articles under current thread as read.
8142 If the prefix argument is positive, remove any kinds of marks.
8143 If the prefix argument is negative, tick articles instead."
8145 (gnus-set-global-variables)
8147 (setq unmark (prefix-numeric-value unmark)))
8148 (let ((articles (gnus-summary-articles-in-thread)))
8150 ;; Expand the thread.
8151 (gnus-summary-show-thread)
8152 ;; Mark all the articles.
8154 (gnus-summary-goto-subject (car articles))
8155 (cond ((null unmark)
8156 (gnus-summary-mark-article-as-read gnus-killed-mark))
8158 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8160 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8161 (setq articles (cdr articles))))
8162 ;; Hide killed subtrees.
8164 gnus-thread-hide-killed
8165 (gnus-summary-hide-thread))
8166 ;; If marked as read, go to next unread subject.
8168 ;; Go to next unread subject.
8169 (gnus-summary-next-subject 1 t)))
8170 (gnus-set-mode-line 'summary))
8172 ;; Summary sorting commands
8174 (defun gnus-summary-sort-by-number (&optional reverse)
8175 "Sort the summary buffer by article number.
8176 Argument REVERSE means reverse order."
8178 (gnus-summary-sort 'number reverse))
8180 (defun gnus-summary-sort-by-author (&optional reverse)
8181 "Sort the summary buffer by author name alphabetically.
8182 If case-fold-search is non-nil, case of letters is ignored.
8183 Argument REVERSE means reverse order."
8185 (gnus-summary-sort 'author reverse))
8187 (defun gnus-summary-sort-by-subject (&optional reverse)
8188 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8189 If case-fold-search is non-nil, case of letters is ignored.
8190 Argument REVERSE means reverse order."
8192 (gnus-summary-sort 'subject reverse))
8194 (defun gnus-summary-sort-by-date (&optional reverse)
8195 "Sort the summary buffer by date.
8196 Argument REVERSE means reverse order."
8198 (gnus-summary-sort 'date reverse))
8200 (defun gnus-summary-sort-by-score (&optional reverse)
8201 "Sort the summary buffer by score.
8202 Argument REVERSE means reverse order."
8204 (gnus-summary-sort 'score reverse))
8206 (defun gnus-summary-sort-by-lines (&optional reverse)
8207 "Sort the summary buffer by article length.
8208 Argument REVERSE means reverse order."
8210 (gnus-summary-sort 'lines reverse))
8212 (defun gnus-summary-sort (predicate reverse)
8213 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8214 (gnus-set-global-variables)
8215 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8216 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8217 (gnus-thread-sort-functions
8223 (gnus-article-sort-functions
8228 (,article t2 t1)))))
8230 (gnus-summary-prepare-hook nil))
8231 ;; We do the sorting by regenerating the threads.
8232 (gnus-summary-prepare)
8233 ;; Hide subthreads if needed.
8234 (when (and gnus-show-threads gnus-thread-hide-subtree)
8235 (gnus-summary-hide-all-threads))))
8237 ;; Summary saving commands.
8239 (defun gnus-summary-save-article (&optional n not-saved)
8240 "Save the current article using the default saver function.
8241 If N is a positive number, save the N next articles.
8242 If N is a negative number, save the N previous articles.
8243 If N is nil and any articles have been marked with the process mark,
8244 save those articles instead.
8245 The variable `gnus-default-article-saver' specifies the saver function."
8247 (gnus-set-global-variables)
8248 (let* ((articles (gnus-summary-work-articles n))
8249 (save-buffer (save-excursion
8250 (nnheader-set-temp-buffer " *Gnus Save*")))
8251 (num (length articles))
8252 header article file)
8254 (setq header (gnus-summary-article-header
8255 (setq article (pop articles))))
8256 (if (not (vectorp header))
8257 ;; This is a pseudo-article.
8258 (if (assq 'name header)
8259 (gnus-copy-file (cdr (assq 'name header)))
8260 (gnus-message 1 "Article %d is unsaveable" article))
8261 ;; This is a real article.
8262 (save-window-excursion
8263 (gnus-summary-select-article t nil nil article))
8265 (set-buffer save-buffer)
8267 (insert-buffer-substring gnus-original-article-buffer))
8268 (setq file (gnus-article-save save-buffer file num))
8269 (gnus-summary-remove-process-mark article)
8271 (gnus-summary-set-saved-mark article))))
8272 (gnus-kill-buffer save-buffer)
8273 (gnus-summary-position-point)
8274 (gnus-set-mode-line 'summary)
8277 (defun gnus-summary-pipe-output (&optional arg)
8278 "Pipe the current article to a subprocess.
8279 If N is a positive number, pipe the N next articles.
8280 If N is a negative number, pipe the N previous articles.
8281 If N is nil and any articles have been marked with the process mark,
8282 pipe those articles instead."
8284 (gnus-set-global-variables)
8285 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8286 (gnus-summary-save-article arg t))
8287 (gnus-configure-windows 'pipe))
8289 (defun gnus-summary-save-article-mail (&optional arg)
8290 "Append the current article to an mail file.
8291 If N is a positive number, save the N next articles.
8292 If N is a negative number, save the N previous articles.
8293 If N is nil and any articles have been marked with the process mark,
8294 save those articles instead."
8296 (gnus-set-global-variables)
8297 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8298 (gnus-summary-save-article arg)))
8300 (defun gnus-summary-save-article-rmail (&optional arg)
8301 "Append the current article to an rmail file.
8302 If N is a positive number, save the N next articles.
8303 If N is a negative number, save the N previous articles.
8304 If N is nil and any articles have been marked with the process mark,
8305 save those articles instead."
8307 (gnus-set-global-variables)
8308 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8309 (gnus-summary-save-article arg)))
8311 (defun gnus-summary-save-article-file (&optional arg)
8312 "Append the current article to a file.
8313 If N is a positive number, save the N next articles.
8314 If N is a negative number, save the N previous articles.
8315 If N is nil and any articles have been marked with the process mark,
8316 save those articles instead."
8318 (gnus-set-global-variables)
8319 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8320 (gnus-summary-save-article arg)))
8322 (defun gnus-summary-write-article-file (&optional arg)
8323 "Write the current article to a file, deleting the previous file.
8324 If N is a positive number, save the N next articles.
8325 If N is a negative number, save the N previous articles.
8326 If N is nil and any articles have been marked with the process mark,
8327 save those articles instead."
8329 (gnus-set-global-variables)
8330 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8331 (gnus-summary-save-article arg)))
8333 (defun gnus-summary-save-article-body-file (&optional arg)
8334 "Append the current article body to a file.
8335 If N is a positive number, save the N next articles.
8336 If N is a negative number, save the N previous articles.
8337 If N is nil and any articles have been marked with the process mark,
8338 save those articles instead."
8340 (gnus-set-global-variables)
8341 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8342 (gnus-summary-save-article arg)))
8344 (defun gnus-summary-pipe-message (program)
8345 "Pipe the current article through PROGRAM."
8346 (interactive "sProgram: ")
8347 (gnus-set-global-variables)
8348 (gnus-summary-select-article)
8349 (let ((mail-header-separator "")
8350 (art-buf (get-buffer gnus-article-buffer)))
8351 (gnus-eval-in-buffer-window gnus-article-buffer
8354 (let ((start (window-start))
8356 (message-pipe-buffer-body program)
8357 (set-window-start (get-buffer-window (current-buffer)) start))))))
8359 (defun gnus-get-split-value (methods)
8360 "Return a value based on the split METHODS."
8361 (let (split-name method result match)
8364 (set-buffer gnus-original-article-buffer)
8366 (nnheader-narrow-to-headers)
8368 (goto-char (point-min))
8369 (setq method (pop methods))
8370 (setq match (car method))
8373 ;; Regular expression.
8375 (re-search-forward match nil t)))
8376 ((gnus-functionp match)
8380 (setq result (funcall match gnus-newsgroup-name))))
8385 (setq result (eval match)))))
8386 (setq split-name (append (cdr method) split-name))
8387 (cond ((stringp result)
8388 (push (expand-file-name
8389 result gnus-article-save-directory)
8392 (setq split-name (append result split-name)))))))))
8395 (defun gnus-valid-move-group-p (group)
8400 (car (gnus-find-method-for-group
8401 (symbol-name group))))
8402 gnus-valid-select-methods))))
8404 (defun gnus-read-move-group-name (prompt default articles prefix)
8405 "Read a group name."
8406 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8407 (minibuffer-confirm-incomplete nil) ; XEmacs
8411 (if (> (length articles) 1)
8412 (format "these %d articles" (length articles))
8417 (gnus-completing-read default prom
8419 'gnus-valid-move-group-p
8421 'gnus-group-history))
8422 ((= 1 (length split-name))
8423 (gnus-completing-read (car split-name) prom
8425 'gnus-valid-move-group-p
8427 'gnus-group-history))
8429 (gnus-completing-read nil prom
8430 (mapcar (lambda (el) (list el))
8431 (nreverse split-name))
8433 'gnus-group-history)))))
8435 (if (or (string= to-newsgroup "")
8436 (string= to-newsgroup prefix))
8437 (setq to-newsgroup default))
8438 (unless to-newsgroup
8439 (error "No group name entered"))
8440 (or (gnus-active to-newsgroup)
8441 (gnus-activate-group to-newsgroup)
8442 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8444 (or (and (gnus-request-create-group
8445 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8446 (gnus-activate-group to-newsgroup nil nil
8447 (gnus-group-name-to-method
8449 (error "Couldn't create group %s" to-newsgroup)))
8450 (error "No such group: %s" to-newsgroup)))
8453 ;; Summary extract commands
8455 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8456 (let ((buffer-read-only nil)
8457 (article (gnus-summary-article-number))
8459 (unless (gnus-summary-goto-subject article)
8460 (error "No such article: %d" article))
8461 (gnus-summary-position-point)
8462 ;; If all commands are to be bunched up on one line, we collect
8464 (unless gnus-view-pseudos-separately
8465 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8468 (setq action (cdr (assq 'action (car ps))))
8469 (setq files (list (cdr (assq 'name (car ps)))))
8470 (while (and ps (cdr ps)
8471 (string= (or action "1")
8472 (or (cdr (assq 'action (cadr ps))) "2")))
8473 (push (cdr (assq 'name (cadr ps))) files)
8474 (setcdr ps (cddr ps)))
8476 (when (not (string-match "%s" action))
8479 (when (assq 'execute (car ps))
8480 (setcdr (assq 'execute (car ps))
8481 (funcall (if (string-match "%s" action)
8488 (gnus-quote-arg-for-sh-or-csh f)))
8490 (setq ps (cdr ps)))))
8491 (if (and gnus-view-pseudos (not not-view))
8493 (when (assq 'execute (car pslist))
8494 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8495 (eq gnus-view-pseudos 'not-confirm)))
8496 (setq pslist (cdr pslist)))
8499 (setq after-article (or (cdr (assq 'article (car pslist)))
8500 (gnus-summary-article-number)))
8501 (gnus-summary-goto-subject after-article)
8504 (insert " " (file-name-nondirectory
8505 (cdr (assq 'name (car pslist))))
8506 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8508 (forward-line -1) ; back to `b'
8509 (gnus-add-text-properties
8510 b (1- e) (list 'gnus-number gnus-reffed-article-number
8511 gnus-mouse-face-prop gnus-mouse-face))
8513 after-article gnus-reffed-article-number
8514 gnus-unread-mark b (car pslist) 0 (- e b))
8515 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8516 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8517 (setq pslist (cdr pslist)))))))
8519 (defun gnus-pseudos< (p1 p2)
8520 (let ((c1 (cdr (assq 'action p1)))
8521 (c2 (cdr (assq 'action p2))))
8522 (and c1 c2 (string< c1 c2))))
8524 (defun gnus-request-pseudo-article (props)
8525 (cond ((assq 'execute props)
8526 (gnus-execute-command (cdr (assq 'execute props)))))
8527 (let ((gnus-current-article (gnus-summary-article-number)))
8528 (run-hooks 'gnus-mark-article-hook)))
8530 (defun gnus-execute-command (command &optional automatic)
8532 (gnus-article-setup-buffer)
8533 (set-buffer gnus-article-buffer)
8534 (setq buffer-read-only nil)
8535 (let ((command (if automatic command
8536 (read-string "Command: " (cons command 0)))))
8538 (insert "$ " command "\n\n")
8539 (if gnus-view-pseudo-asynchronously
8540 (start-process "gnus-execute" (current-buffer) shell-file-name
8541 shell-command-switch command)
8542 (call-process shell-file-name nil t nil
8543 shell-command-switch command)))))
8545 ;; Summary kill commands.
8547 (defun gnus-summary-edit-global-kill (article)
8548 "Edit the \"global\" kill file."
8549 (interactive (list (gnus-summary-article-number)))
8550 (gnus-set-global-variables)
8551 (gnus-group-edit-global-kill article))
8553 (defun gnus-summary-edit-local-kill ()
8554 "Edit a local kill file applied to the current newsgroup."
8556 (gnus-set-global-variables)
8557 (setq gnus-current-headers (gnus-summary-article-header))
8558 (gnus-set-global-variables)
8559 (gnus-group-edit-local-kill
8560 (gnus-summary-article-number) gnus-newsgroup-name))
8564 (defun gnus-read-header (id &optional header)
8565 "Read the headers of article ID and enter them into the Gnus system."
8566 (let ((group gnus-newsgroup-name)
8567 (gnus-override-method
8568 (and (gnus-news-group-p gnus-newsgroup-name)
8569 gnus-refer-article-method))
8571 ;; First we check to see whether the header in question is already
8574 ;; This is a Message-ID.
8575 (setq header (or header (gnus-id-to-header id)))
8576 ;; This is an article number.
8577 (setq header (or header (gnus-summary-article-header id))))
8579 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8580 ;; We have found the header.
8582 ;; We have to really fetch the header to this article.
8584 (set-buffer nntp-server-buffer)
8585 (when (setq where (gnus-request-head id group))
8586 (nnheader-fold-continuation-lines)
8587 (goto-char (point-max))
8589 (goto-char (point-min))
8593 ((cdr where) (cdr where))
8594 (header (mail-header-number header))
8595 (t gnus-reffed-article-number))
8597 (insert " Article retrieved.\n"))
8599 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8600 () ; Malformed head.
8601 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8602 (when (and (stringp id)
8603 (not (string= (gnus-group-real-name group)
8605 ;; If we fetched by Message-ID and the article came
8606 ;; from a different group, we fudge some bogus article
8607 ;; numbers for this article.
8608 (mail-header-set-number header gnus-reffed-article-number))
8610 (set-buffer gnus-summary-buffer)
8611 (decf gnus-reffed-article-number)
8612 (gnus-remove-header (mail-header-number header))
8613 (push header gnus-newsgroup-headers)
8614 (setq gnus-current-headers header)
8615 (push (mail-header-number header) gnus-newsgroup-limit)))
8618 (defun gnus-remove-header (number)
8619 "Remove header NUMBER from `gnus-newsgroup-headers'."
8620 (if (and gnus-newsgroup-headers
8621 (= number (mail-header-number (car gnus-newsgroup-headers))))
8622 (pop gnus-newsgroup-headers)
8623 (let ((headers gnus-newsgroup-headers))
8624 (while (and (cdr headers)
8625 (not (= number (mail-header-number (cadr headers)))))
8628 (setcdr headers (cddr headers))))))
8631 ;;; summary highlights
8634 (defun gnus-highlight-selected-summary ()
8635 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8636 ;; Highlight selected article in summary buffer
8637 (when gnus-summary-selected-face
8639 (let* ((beg (progn (beginning-of-line) (point)))
8640 (end (progn (end-of-line) (point)))
8641 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8642 (from (if (get-text-property beg gnus-mouse-face-prop)
8644 (or (next-single-property-change
8645 beg gnus-mouse-face-prop nil end)
8650 (or (next-single-property-change
8651 from gnus-mouse-face-prop nil end)
8653 ;; If no mouse-face prop on line we will have to = from = end,
8654 ;; so we highlight the entire line instead.
8655 (when (= (+ to 2) from)
8658 (if gnus-newsgroup-selected-overlay
8659 ;; Move old overlay.
8661 gnus-newsgroup-selected-overlay from to (current-buffer))
8662 ;; Create new overlay.
8664 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8665 'face gnus-summary-selected-face))))))
8667 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8668 (defun gnus-summary-highlight-line ()
8669 "Highlight current line according to `gnus-summary-highlight'."
8670 (let* ((list gnus-summary-highlight)
8672 (end (progn (end-of-line) (point)))
8673 ;; now find out where the line starts and leave point there.
8674 (beg (progn (beginning-of-line) (point)))
8675 (article (gnus-summary-article-number))
8676 (score (or (cdr (assq (or article gnus-current-article)
8677 gnus-newsgroup-scored))
8678 gnus-summary-default-score 0))
8679 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8680 (inhibit-read-only t))
8681 ;; Eval the cars of the lists until we find a match.
8682 (let ((default gnus-summary-default-score))
8684 (not (eval (caar list))))
8685 (setq list (cdr list))))
8686 (let ((face (cdar list)))
8687 (unless (eq face (get-text-property beg 'face))
8688 (gnus-put-text-property
8690 (setq face (if (boundp face) (symbol-value face) face)))
8691 (when gnus-summary-highlight-line-function
8692 (funcall gnus-summary-highlight-line-function article face))))
8695 (defun gnus-update-read-articles (group unread)
8696 "Update the list of read articles in GROUP."
8697 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8698 (entry (gnus-gethash group gnus-newsrc-hashtb))
8699 (info (nth 2 entry))
8701 (unread (sort (copy-sequence unread) '<))
8703 (if (or (not info) (not active))
8704 ;; There is no info on this group if it was, in fact,
8705 ;; killed. Gnus stores no information on killed groups, so
8706 ;; there's nothing to be done.
8707 ;; One could store the information somewhere temporarily,
8708 ;; perhaps... Hmmm...
8710 ;; Remove any negative articles numbers.
8711 (while (and unread (< (car unread) 0))
8712 (setq unread (cdr unread)))
8713 ;; Remove any expired article numbers
8714 (while (and unread (< (car unread) (car active)))
8715 (setq unread (cdr unread)))
8716 ;; Compute the ranges of read articles by looking at the list of
8719 (when (/= (car unread) prev)
8720 (push (if (= prev (1- (car unread))) prev
8721 (cons prev (1- (car unread))))
8723 (setq prev (1+ (car unread)))
8724 (setq unread (cdr unread)))
8725 (when (<= prev (cdr active))
8726 (push (cons prev (cdr active)) read))
8728 (set-buffer gnus-group-buffer)
8731 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8732 (gnus-info-set-read ',info ',(gnus-info-read info))
8733 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8734 (gnus-group-update-group ,group t))))
8735 ;; Enter this list into the group info.
8737 info (if (> (length read) 1) (nreverse read) read))
8738 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8739 (gnus-get-unread-articles-in-group info (gnus-active group))
8742 (defun gnus-offer-save-summaries ()
8743 "Offer to save all active summary buffers."
8745 (let ((buflist (buffer-list))
8747 ;; Go through all buffers and find all summaries.
8749 (and (setq bufname (buffer-name (car buflist)))
8750 (string-match "Summary" bufname)
8752 (set-buffer bufname)
8753 ;; We check that this is, indeed, a summary buffer.
8754 (and (eq major-mode 'gnus-summary-mode)
8755 ;; Also make sure this isn't bogus.
8756 gnus-newsgroup-prepared
8757 ;; Also make sure that this isn't a dead summary buffer.
8758 (not gnus-dead-summary-mode)))
8759 (push bufname buffers))
8760 (setq buflist (cdr buflist)))
8761 ;; Go through all these summary buffers and offer to save them.
8764 "Update summary buffer %s? "
8765 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8772 (run-hooks 'gnus-sum-load-hook)
8774 ;;; gnus-sum.el ends here