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))
36 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
38 (defcustom gnus-kill-summary-on-exit t
39 "*If non-nil, kill the summary buffer when you exit from it.
40 If nil, the summary will become a \"*Dead Summary*\" buffer, and
41 it will be killed sometime later."
42 :group 'gnus-summary-exit
45 (defcustom gnus-fetch-old-headers nil
46 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
47 If an unread article in the group refers to an older, already read (or
48 just marked as read) article, the old article will not normally be
49 displayed in the Summary buffer. If this variable is non-nil, Gnus
50 will attempt to grab the headers to the old articles, and thereby
51 build complete threads. If it has the value `some', only enough
52 headers to connect otherwise loose threads will be displayed. This
53 variable can also be a number. In that case, no more than that number
54 of old headers will be fetched. If it has the value `invisible', all
55 old headers will be fetched, but none will be displayed.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-refer-thread-limit 200
65 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
66 If t, fetch all the available old headers."
69 (sexp :menu-tag "other" t)))
71 (defcustom gnus-summary-make-false-root 'adopt
72 "*nil means that Gnus won't gather loose threads.
73 If the root of a thread has expired or been read in a previous
74 session, the information necessary to build a complete thread has been
75 lost. Instead of having many small sub-threads from this original thread
76 scattered all over the summary buffer, Gnus can gather them.
78 If non-nil, Gnus will try to gather all loose sub-threads from an
79 original thread into one large thread.
81 If this variable is non-nil, it should be one of `none', `adopt',
84 If this variable is `none', Gnus will not make a false root, but just
85 present the sub-threads after another.
86 If this variable is `dummy', Gnus will create a dummy root that will
87 have all the sub-threads as children.
88 If this variable is `adopt', Gnus will make one of the \"children\"
89 the parent and mark all the step-children as such.
90 If this variable is `empty', the \"children\" are printed with empty
91 subject fields. (Or rather, they will be printed with a string
92 given by the `gnus-summary-same-subject' variable.)"
94 :type '(choice (const :tag "off" nil)
100 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
101 "*A regexp to match subjects to be excluded from loose thread gathering.
102 As loose thread gathering is done on subjects only, that means that
103 there can be many false gatherings performed. By rooting out certain
104 common subjects, gathering might become saner."
108 (defcustom gnus-summary-gather-subject-limit nil
109 "*Maximum length of subject comparisons when gathering loose threads.
110 Use nil to compare full subjects. Setting this variable to a low
111 number will help gather threads that have been corrupted by
112 newsreaders chopping off subject lines, but it might also mean that
113 unrelated articles that have subject that happen to begin with the
114 same few characters will be incorrectly gathered.
116 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
119 :type '(choice (const :tag "off" nil)
121 (sexp :menu-tag "on" t)))
123 (defcustom gnus-simplify-subject-functions nil
124 "List of functions taking a string argument that simplify subjects.
125 The functions are applied recursively."
127 :type '(repeat (list function)))
129 (defcustom gnus-simplify-ignored-prefixes nil
130 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
132 :type '(choice (const :tag "off" nil)
135 (defcustom gnus-build-sparse-threads nil
136 "*If non-nil, fill in the gaps in threads.
137 If `some', only fill in the gaps that are needed to tie loose threads
138 together. If `more', fill in all leaf nodes that Gnus can find. If
139 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
141 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "all" t)))
146 (defcustom gnus-summary-thread-gathering-function
147 'gnus-gather-threads-by-subject
148 "Function used for gathering loose threads.
149 There are two pre-defined functions: `gnus-gather-threads-by-subject',
150 which only takes Subjects into consideration; and
151 `gnus-gather-threads-by-references', which compared the References
152 headers of the articles to find matches."
154 :type '(radio (function-item gnus-gather-threads-by-subject)
155 (function-item gnus-gather-threads-by-references)
156 (function :tag "other")))
158 (defcustom gnus-summary-same-subject ""
159 "*String indicating that the current article has the same subject as the previous.
160 This variable will only be used if the value of
161 `gnus-summary-make-false-root' is `empty'."
162 :group 'gnus-summary-format
165 (defcustom gnus-summary-goto-unread t
166 "*If t, marking commands will go to the next unread article.
167 If `never', commands that usually go to the next unread article, will
168 go to the next article, whether it is read or not.
169 If nil, only the marking commands will go to the next (un)read article."
170 :group 'gnus-summary-marks
171 :link '(custom-manual "(gnus)Setting Marks")
172 :type '(choice (const :tag "off" nil)
174 (sexp :menu-tag "on" t)))
176 (defcustom gnus-summary-default-score 0
177 "*Default article score level.
178 All scores generated by the score files will be added to this score.
179 If this variable is nil, scoring will be disabled."
180 :group 'gnus-score-default
181 :type '(choice (const :tag "disable")
184 (defcustom gnus-summary-zcore-fuzz 0
185 "*Fuzziness factor for the zcore in the summary buffer.
186 Articles with scores closer than this to `gnus-summary-default-score'
188 :group 'gnus-summary-format
191 (defcustom gnus-simplify-subject-fuzzy-regexp nil
192 "*Strings to be removed when doing fuzzy matches.
193 This can either be a regular expression or list of regular expressions
194 that will be removed from subject strings if fuzzy subject
195 simplification is selected."
197 :type '(repeat regexp))
199 (defcustom gnus-show-threads t
200 "*If non-nil, display threads in summary mode."
204 (defcustom gnus-thread-hide-subtree nil
205 "*If non-nil, hide all threads initially.
206 If threads are hidden, you have to run the command
207 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
208 to expose hidden threads."
212 (defcustom gnus-thread-hide-killed t
213 "*If non-nil, hide killed threads automatically."
217 (defcustom gnus-thread-ignore-subject nil
218 "*If non-nil, ignore subjects and do all threading based on the Reference header.
219 If nil, which is the default, articles that have different subjects
220 from their parents will start separate threads."
224 (defcustom gnus-thread-operation-ignore-subject t
225 "*If non-nil, subjects will be ignored when doing thread commands.
226 This affects commands like `gnus-summary-kill-thread' and
227 `gnus-summary-lower-thread'.
229 If this variable is nil, articles in the same thread with different
230 subjects will not be included in the operation in question. If this
231 variable is `fuzzy', only articles that have subjects that are fuzzily
232 equal will be included."
234 :type '(choice (const :tag "off" nil)
238 (defcustom gnus-thread-indent-level 4
239 "*Number that says how much each sub-thread should be indented."
243 (defcustom gnus-auto-extend-newsgroup t
244 "*If non-nil, extend newsgroup forward and backward when requested."
245 :group 'gnus-summary-choose
248 (defcustom gnus-auto-select-first t
249 "*If nil, don't select the first unread article when entering a group.
250 If this variable is `best', select the highest-scored unread article
251 in the group. If neither nil nor `best', select the first unread
254 If you want to prevent automatic selection of the first unread article
255 in some newsgroups, set the variable to nil in
256 `gnus-select-group-hook'."
257 :group 'gnus-group-select
258 :type '(choice (const :tag "none" nil)
260 (sexp :menu-tag "first" t)))
262 (defcustom gnus-auto-select-next t
263 "*If non-nil, offer to go to the next group from the end of the previous.
264 If the value is t and the next newsgroup is empty, Gnus will exit
265 summary mode and go back to group mode. If the value is neither nil
266 nor t, Gnus will select the following unread newsgroup. In
267 particular, if the value is the symbol `quietly', the next unread
268 newsgroup will be selected without any confirmation, and if it is
269 `almost-quietly', the next group will be selected without any
270 confirmation if you are located on the last article in the group.
271 Finally, if this variable is `slightly-quietly', the `Z n' command
272 will go to the next group without confirmation."
273 :group 'gnus-summary-maneuvering
274 :type '(choice (const :tag "off" nil)
276 (const almost-quietly)
277 (const slightly-quietly)
278 (sexp :menu-tag "on" t)))
280 (defcustom gnus-auto-select-same nil
281 "*If non-nil, select the next article with the same subject."
282 :group 'gnus-summary-maneuvering
285 (defcustom gnus-summary-check-current nil
286 "*If non-nil, consider the current article when moving.
287 The \"unread\" movement commands will stay on the same line if the
288 current article is unread."
289 :group 'gnus-summary-maneuvering
292 (defcustom gnus-auto-center-summary t
293 "*If non-nil, always center the current summary buffer.
294 In particular, if `vertical' do only vertical recentering. If non-nil
295 and non-`vertical', do both horizontal and vertical recentering."
296 :group 'gnus-summary-maneuvering
297 :type '(choice (const :tag "none" nil)
299 (sexp :menu-tag "both" t)))
301 (defcustom gnus-show-all-headers nil
302 "*If non-nil, don't hide any headers."
303 :group 'gnus-article-hiding
304 :group 'gnus-article-headers
307 (defcustom gnus-summary-ignore-duplicates nil
308 "*If non-nil, ignore articles with identical Message-ID headers."
312 (defcustom gnus-single-article-buffer t
313 "*If non-nil, display all articles in the same buffer.
314 If nil, each group will get its own article buffer."
315 :group 'gnus-article-various
318 (defcustom gnus-break-pages t
319 "*If non-nil, do page breaking on articles.
320 The page delimiter is specified by the `gnus-page-delimiter'
322 :group 'gnus-article-various
325 (defcustom gnus-show-mime nil
326 "*If non-nil, do mime processing of articles.
327 The articles will simply be fed to the function given by
328 `gnus-show-mime-method'."
329 :group 'gnus-article-mime
332 (defcustom gnus-move-split-methods nil
333 "*Variable used to suggest where articles are to be moved to.
334 It uses the same syntax as the `gnus-split-methods' variable."
335 :group 'gnus-summary-mail
336 :type '(repeat (choice (list function)
337 (cons regexp (repeat string))
340 (defcustom gnus-unread-mark ?
341 "*Mark used for unread articles."
342 :group 'gnus-summary-marks
345 (defcustom gnus-ticked-mark ?!
346 "*Mark used for ticked articles."
347 :group 'gnus-summary-marks
350 (defcustom gnus-dormant-mark ??
351 "*Mark used for dormant articles."
352 :group 'gnus-summary-marks
355 (defcustom gnus-del-mark ?r
356 "*Mark used for del'd articles."
357 :group 'gnus-summary-marks
360 (defcustom gnus-read-mark ?R
361 "*Mark used for read articles."
362 :group 'gnus-summary-marks
365 (defcustom gnus-expirable-mark ?E
366 "*Mark used for expirable articles."
367 :group 'gnus-summary-marks
370 (defcustom gnus-killed-mark ?K
371 "*Mark used for killed articles."
372 :group 'gnus-summary-marks
375 (defcustom gnus-souped-mark ?F
376 "*Mark used for killed articles."
377 :group 'gnus-summary-marks
380 (defcustom gnus-kill-file-mark ?X
381 "*Mark used for articles killed by kill files."
382 :group 'gnus-summary-marks
385 (defcustom gnus-low-score-mark ?Y
386 "*Mark used for articles with a low score."
387 :group 'gnus-summary-marks
390 (defcustom gnus-catchup-mark ?C
391 "*Mark used for articles that are caught up."
392 :group 'gnus-summary-marks
395 (defcustom gnus-replied-mark ?A
396 "*Mark used for articles that have been replied to."
397 :group 'gnus-summary-marks
400 (defcustom gnus-cached-mark ?*
401 "*Mark used for articles that are in the cache."
402 :group 'gnus-summary-marks
405 (defcustom gnus-saved-mark ?S
406 "*Mark used for articles that have been saved to."
407 :group 'gnus-summary-marks
410 (defcustom gnus-ancient-mark ?O
411 "*Mark used for ancient articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-sparse-mark ?Q
416 "*Mark used for sparsely reffed articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-canceled-mark ?G
421 "*Mark used for canceled articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-duplicate-mark ?M
426 "*Mark used for duplicate articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-undownloaded-mark ?@
431 "*Mark used for articles that weren't downloaded."
432 :group 'gnus-summary-marks
435 (defcustom gnus-downloadable-mark ?%
436 "*Mark used for articles that are to be downloaded."
437 :group 'gnus-summary-marks
440 (defcustom gnus-unsendable-mark ?=
441 "*Mark used for articles that won't be sent."
442 :group 'gnus-summary-marks
445 (defcustom gnus-score-over-mark ?+
446 "*Score mark used for articles with high scores."
447 :group 'gnus-summary-marks
450 (defcustom gnus-score-below-mark ?-
451 "*Score mark used for articles with low scores."
452 :group 'gnus-summary-marks
455 (defcustom gnus-empty-thread-mark ?
456 "*There is no thread under the article."
457 :group 'gnus-summary-marks
460 (defcustom gnus-not-empty-thread-mark ?=
461 "*There is a thread under the article."
462 :group 'gnus-summary-marks
465 (defcustom gnus-view-pseudo-asynchronously nil
466 "*If non-nil, Gnus will view pseudo-articles asynchronously."
467 :group 'gnus-extract-view
470 (defcustom gnus-view-pseudos nil
471 "*If `automatic', pseudo-articles will be viewed automatically.
472 If `not-confirm', pseudos will be viewed automatically, and the user
473 will not be asked to confirm the command."
474 :group 'gnus-extract-view
475 :type '(choice (const :tag "off" nil)
477 (const not-confirm)))
479 (defcustom gnus-view-pseudos-separately t
480 "*If non-nil, one pseudo-article will be created for each file to be viewed.
481 If nil, all files that use the same viewing command will be given as a
482 list of parameters to that command."
483 :group 'gnus-extract-view
486 (defcustom gnus-insert-pseudo-articles t
487 "*If non-nil, insert pseudo-articles when decoding articles."
488 :group 'gnus-extract-view
491 (defcustom gnus-summary-dummy-line-format
493 "*The format specification for the dummy roots in the summary buffer.
494 It works along the same lines as a normal formatting string,
495 with some simple extensions.
498 :group 'gnus-threading
501 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
502 "*The format specification for the summary mode line.
503 It works along the same lines as a normal formatting string,
504 with some simple extensions:
507 %p Unprefixed group name
508 %A Current article number
510 %U Number of unread articles in the group
511 %e Number of unselected articles in the group
512 %Z A string with unread/unselected article counts
513 %g Shortish group name
514 %S Subject of the current article
516 %s Current score file name
517 %d Number of dormant articles
518 %r Number of articles that have been marked as read in this session
519 %E Number of articles expunged by the score files"
520 :group 'gnus-summary-format
523 (defcustom gnus-summary-mark-below 0
524 "*Mark all articles with a score below this variable as read.
525 This variable is local to each summary buffer and usually set by the
527 :group 'gnus-score-default
530 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
531 "*List of functions used for sorting articles in the summary buffer.
532 This variable is only used when not using a threaded display."
533 :group 'gnus-summary-sort
534 :type '(repeat (choice (function-item gnus-article-sort-by-number)
535 (function-item gnus-article-sort-by-author)
536 (function-item gnus-article-sort-by-subject)
537 (function-item gnus-article-sort-by-date)
538 (function-item gnus-article-sort-by-score)
539 (function :tag "other"))))
541 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
542 "*List of functions used for sorting threads in the summary buffer.
543 By default, threads are sorted by article number.
545 Each function takes two threads and return non-nil if the first thread
546 should be sorted before the other. If you use more than one function,
547 the primary sort function should be the last. You should probably
548 always include `gnus-thread-sort-by-number' in the list of sorting
549 functions -- preferably first.
551 Ready-made functions include `gnus-thread-sort-by-number',
552 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
553 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
554 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
555 :group 'gnus-summary-sort
556 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
557 (function-item gnus-thread-sort-by-author)
558 (function-item gnus-thread-sort-by-subject)
559 (function-item gnus-thread-sort-by-date)
560 (function-item gnus-thread-sort-by-score)
561 (function-item gnus-thread-sort-by-total-score)
562 (function :tag "other"))))
564 (defcustom gnus-thread-score-function '+
565 "*Function used for calculating the total score of a thread.
567 The function is called with the scores of the article and each
568 subthread and should then return the score of the thread.
570 Some functions you can use are `+', `max', or `min'."
571 :group 'gnus-summary-sort
574 (defcustom gnus-summary-expunge-below nil
575 "All articles that have a score less than this variable will be expunged.
576 This variable is local to the summary buffers."
577 :group 'gnus-score-default
578 :type '(choice (const :tag "off" nil)
581 (defcustom gnus-thread-expunge-below nil
582 "All threads that have a total score less than this variable will be expunged.
583 See `gnus-thread-score-function' for en explanation of what a
586 This variable is local to the summary buffers."
587 :group 'gnus-treading
588 :group 'gnus-score-default
589 :type '(choice (const :tag "off" nil)
592 (defcustom gnus-summary-mode-hook nil
593 "*A hook for Gnus summary mode.
594 This hook is run before any variables are set in the summary buffer."
595 :group 'gnus-summary-various
598 (defcustom gnus-summary-menu-hook nil
599 "*Hook run after the creation of the summary mode menu."
600 :group 'gnus-summary-visual
603 (defcustom gnus-summary-exit-hook nil
604 "*A hook called on exit from the summary buffer.
605 It will be called with point in the group buffer."
606 :group 'gnus-summary-exit
609 (defcustom gnus-summary-prepare-hook nil
610 "*A hook called after the summary buffer has been generated.
611 If you want to modify the summary buffer, you can use this hook."
612 :group 'gnus-summary-various
615 (defcustom gnus-summary-generate-hook nil
616 "*A hook run just before generating the summary buffer.
617 This hook is commonly used to customize threading variables and the
619 :group 'gnus-summary-various
622 (defcustom gnus-select-group-hook nil
623 "*A hook called when a newsgroup is selected.
625 If you'd like to simplify subjects like the
626 `gnus-summary-next-same-subject' command does, you can use the
629 (setq gnus-select-group-hook
632 (mapcar (lambda (header)
633 (mail-header-set-subject
635 (gnus-simplify-subject
636 (mail-header-subject header) 're-only)))
637 gnus-newsgroup-headers))))"
638 :group 'gnus-group-select
641 (defcustom gnus-select-article-hook nil
642 "*A hook called when an article is selected."
643 :group 'gnus-summary-choose
646 (defcustom gnus-visual-mark-article-hook
647 (list 'gnus-highlight-selected-summary)
648 "*Hook run after selecting an article in the summary buffer.
649 It is meant to be used for highlighting the article in some way. It
650 is not run if `gnus-visual' is nil."
651 :group 'gnus-summary-visual
654 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
655 (defcustom gnus-structured-field-decoder 'identity
656 "Function to decode non-ASCII characters in structured field for summary."
660 (defcustom gnus-unstructured-field-decoder 'identity
661 "Function to decode non-ASCII characters in unstructured field for summary."
665 (defcustom gnus-parse-headers-hook
666 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
667 "*A hook called before parsing the headers."
671 (defcustom gnus-exit-group-hook nil
672 "*A hook called when exiting (not quitting) summary mode."
676 (defcustom gnus-summary-update-hook
677 (list 'gnus-summary-highlight-line)
678 "*A hook called when a summary line is changed.
679 The hook will not be called if `gnus-visual' is nil.
681 The default function `gnus-summary-highlight-line' will
682 highlight the line according to the `gnus-summary-highlight'
684 :group 'gnus-summary-visual
687 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
688 "*A hook called when an article is selected for the first time.
689 The hook is intended to mark an article as read (or unread)
690 automatically when it is selected."
691 :group 'gnus-summary-choose
694 (defcustom gnus-group-no-more-groups-hook nil
695 "*A hook run when returning to group mode having no more (unread) groups."
696 :group 'gnus-group-select
699 (defcustom gnus-ps-print-hook nil
700 "*A hook run before ps-printing something from Gnus."
704 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
705 "Face used for highlighting the current article in the summary buffer."
706 :group 'gnus-summary-visual
709 (defcustom gnus-summary-highlight
710 '(((= mark gnus-canceled-mark)
711 . gnus-summary-cancelled-face)
712 ((and (> score default)
713 (or (= mark gnus-dormant-mark)
714 (= mark gnus-ticked-mark)))
715 . gnus-summary-high-ticked-face)
716 ((and (< score default)
717 (or (= mark gnus-dormant-mark)
718 (= mark gnus-ticked-mark)))
719 . gnus-summary-low-ticked-face)
720 ((or (= mark gnus-dormant-mark)
721 (= mark gnus-ticked-mark))
722 . gnus-summary-normal-ticked-face)
723 ((and (> score default) (= mark gnus-ancient-mark))
724 . gnus-summary-high-ancient-face)
725 ((and (< score default) (= mark gnus-ancient-mark))
726 . gnus-summary-low-ancient-face)
727 ((= mark gnus-ancient-mark)
728 . gnus-summary-normal-ancient-face)
729 ((and (> score default) (= mark gnus-unread-mark))
730 . gnus-summary-high-unread-face)
731 ((and (< score default) (= mark gnus-unread-mark))
732 . gnus-summary-low-unread-face)
733 ((and (= mark gnus-unread-mark))
734 . gnus-summary-normal-unread-face)
736 . gnus-summary-high-read-face)
738 . gnus-summary-low-read-face)
740 . gnus-summary-normal-read-face))
741 "Controls the highlighting of summary buffer lines.
743 A list of (FORM . FACE) pairs. When deciding how a a particular
744 summary line should be displayed, each form is evaluated. The content
745 of the face field after the first true form is used. You can change
746 how those summary lines are displayed, by editing the face field.
748 You can use the following variables in the FORM field.
750 score: The articles score
751 default: The default article score.
752 below: The score below which articles are automatically marked as read.
753 mark: The articles mark."
754 :group 'gnus-summary-visual
755 :type '(repeat (cons (sexp :tag "Form" nil)
758 (defcustom gnus-alter-header-function nil
759 "Function called to allow alteration of article header structures.
760 The function is called with one parameter, the article header vector,
761 which it may alter in any way.")
763 ;;; Internal variables
765 (defvar gnus-scores-exclude-files nil)
766 (defvar gnus-page-broken nil)
768 (defvar gnus-original-article nil)
769 (defvar gnus-article-internal-prepare-hook nil)
770 (defvar gnus-newsgroup-process-stack nil)
772 (defvar gnus-thread-indent-array nil)
773 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
775 ;; Avoid highlighting in kill files.
776 (defvar gnus-summary-inhibit-highlight nil)
777 (defvar gnus-newsgroup-selected-overlay nil)
778 (defvar gnus-inhibit-limiting nil)
779 (defvar gnus-newsgroup-adaptive-score-file nil)
780 (defvar gnus-current-score-file nil)
781 (defvar gnus-current-move-group nil)
782 (defvar gnus-current-copy-group nil)
783 (defvar gnus-current-crosspost-group nil)
785 (defvar gnus-newsgroup-dependencies nil)
786 (defvar gnus-newsgroup-adaptive nil)
787 (defvar gnus-summary-display-article-function nil)
788 (defvar gnus-summary-highlight-line-function nil
789 "Function called after highlighting a summary line.")
791 (defvar gnus-summary-line-format-alist
792 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
793 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
794 (?s gnus-tmp-subject-or-nil ?s)
795 (?n gnus-tmp-name ?s)
796 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
798 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
800 (?F gnus-tmp-from ?s)
801 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
802 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
803 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
804 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
805 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
806 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
807 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
808 (?L gnus-tmp-lines ?d)
809 (?I gnus-tmp-indentation ?s)
810 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
811 (?R gnus-tmp-replied ?c)
812 (?\[ gnus-tmp-opening-bracket ?c)
813 (?\] gnus-tmp-closing-bracket ?c)
814 (?\> (make-string gnus-tmp-level ? ) ?s)
815 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
816 (?i gnus-tmp-score ?d)
817 (?z gnus-tmp-score-char ?c)
818 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
819 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
820 (?U gnus-tmp-unread ?c)
821 (?t (gnus-summary-number-of-articles-in-thread
822 (and (boundp 'thread) (car thread)) gnus-tmp-level)
824 (?e (gnus-summary-number-of-articles-in-thread
825 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
827 (?u gnus-tmp-user-defined ?s)
828 (?P (gnus-pick-line-number) ?d))
829 "An alist of format specifications that can appear in summary lines,
830 and what variables they correspond with, along with the type of the
831 variable (string, integer, character, etc).")
833 (defvar gnus-summary-dummy-line-format-alist
834 `((?S gnus-tmp-subject ?s)
835 (?N gnus-tmp-number ?d)
836 (?u gnus-tmp-user-defined ?s)))
838 (defvar gnus-summary-mode-line-format-alist
839 `((?G gnus-tmp-group-name ?s)
840 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
841 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
842 (?A gnus-tmp-article-number ?d)
843 (?Z gnus-tmp-unread-and-unselected ?s)
845 (?U gnus-tmp-unread-and-unticked ?d)
846 (?S gnus-tmp-subject ?s)
847 (?e gnus-tmp-unselected ?d)
848 (?u gnus-tmp-user-defined ?s)
849 (?d (length gnus-newsgroup-dormant) ?d)
850 (?t (length gnus-newsgroup-marked) ?d)
851 (?r (length gnus-newsgroup-reads) ?d)
852 (?E gnus-newsgroup-expunged-tally ?d)
853 (?s (gnus-current-score-file-nondirectory) ?s)))
855 (defvar gnus-last-search-regexp nil
856 "Default regexp for article search command.")
858 (defvar gnus-last-shell-command nil
859 "Default shell command on article.")
861 (defvar gnus-newsgroup-begin nil)
862 (defvar gnus-newsgroup-end nil)
863 (defvar gnus-newsgroup-last-rmail nil)
864 (defvar gnus-newsgroup-last-mail nil)
865 (defvar gnus-newsgroup-last-folder nil)
866 (defvar gnus-newsgroup-last-file nil)
867 (defvar gnus-newsgroup-auto-expire nil)
868 (defvar gnus-newsgroup-active nil)
870 (defvar gnus-newsgroup-data nil)
871 (defvar gnus-newsgroup-data-reverse nil)
872 (defvar gnus-newsgroup-limit nil)
873 (defvar gnus-newsgroup-limits nil)
875 (defvar gnus-newsgroup-unreads nil
876 "List of unread articles in the current newsgroup.")
878 (defvar gnus-newsgroup-unselected nil
879 "List of unselected unread articles in the current newsgroup.")
881 (defvar gnus-newsgroup-reads nil
882 "Alist of read articles and article marks in the current newsgroup.")
884 (defvar gnus-newsgroup-expunged-tally nil)
886 (defvar gnus-newsgroup-marked nil
887 "List of ticked articles in the current newsgroup (a subset of unread art).")
889 (defvar gnus-newsgroup-killed nil
890 "List of ranges of articles that have been through the scoring process.")
892 (defvar gnus-newsgroup-cached nil
893 "List of articles that come from the article cache.")
895 (defvar gnus-newsgroup-saved nil
896 "List of articles that have been saved.")
898 (defvar gnus-newsgroup-kill-headers nil)
900 (defvar gnus-newsgroup-replied nil
901 "List of articles that have been replied to in the current newsgroup.")
903 (defvar gnus-newsgroup-expirable nil
904 "List of articles in the current newsgroup that can be expired.")
906 (defvar gnus-newsgroup-processable nil
907 "List of articles in the current newsgroup that can be processed.")
909 (defvar gnus-newsgroup-downloadable nil
910 "List of articles in the current newsgroup that can be processed.")
912 (defvar gnus-newsgroup-undownloaded nil
913 "List of articles in the current newsgroup that haven't been downloaded..")
915 (defvar gnus-newsgroup-unsendable nil
916 "List of articles in the current newsgroup that won't be sent.")
918 (defvar gnus-newsgroup-bookmarks nil
919 "List of articles in the current newsgroup that have bookmarks.")
921 (defvar gnus-newsgroup-dormant nil
922 "List of dormant articles in the current newsgroup.")
924 (defvar gnus-newsgroup-scored nil
925 "List of scored articles in the current newsgroup.")
927 (defvar gnus-newsgroup-headers nil
928 "List of article headers in the current newsgroup.")
930 (defvar gnus-newsgroup-threads nil)
932 (defvar gnus-newsgroup-prepared nil
933 "Whether the current group has been prepared properly.")
935 (defvar gnus-newsgroup-ancient nil
936 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
938 (defvar gnus-newsgroup-sparse nil)
940 (defvar gnus-current-article nil)
941 (defvar gnus-article-current nil)
942 (defvar gnus-current-headers nil)
943 (defvar gnus-have-all-headers nil)
944 (defvar gnus-last-article nil)
945 (defvar gnus-newsgroup-history nil)
947 (defconst gnus-summary-local-variables
948 '(gnus-newsgroup-name
949 gnus-newsgroup-begin gnus-newsgroup-end
950 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
951 gnus-newsgroup-last-folder gnus-newsgroup-last-file
952 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
953 gnus-newsgroup-unselected gnus-newsgroup-marked
954 gnus-newsgroup-reads gnus-newsgroup-saved
955 gnus-newsgroup-replied gnus-newsgroup-expirable
956 gnus-newsgroup-processable gnus-newsgroup-killed
957 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
958 gnus-newsgroup-unsendable
959 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
960 gnus-newsgroup-headers gnus-newsgroup-threads
961 gnus-newsgroup-prepared gnus-summary-highlight-line-function
962 gnus-current-article gnus-current-headers gnus-have-all-headers
963 gnus-last-article gnus-article-internal-prepare-hook
964 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
965 gnus-newsgroup-scored gnus-newsgroup-kill-headers
966 gnus-thread-expunge-below
967 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
968 (gnus-summary-mark-below . global)
969 gnus-newsgroup-active gnus-scores-exclude-files
970 gnus-newsgroup-history gnus-newsgroup-ancient
971 gnus-newsgroup-sparse gnus-newsgroup-process-stack
972 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
973 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
974 (gnus-newsgroup-expunged-tally . 0)
975 gnus-cache-removable-articles gnus-newsgroup-cached
976 gnus-newsgroup-data gnus-newsgroup-data-reverse
977 gnus-newsgroup-limit gnus-newsgroup-limits)
978 "Variables that are buffer-local to the summary buffers.")
980 ;; Byte-compiler warning.
981 (defvar gnus-article-mode-map)
983 ;; Subject simplification.
985 (defun gnus-simplify-whitespace (str)
986 "Remove excessive whitespace."
989 (while (string-match "[ \t][ \t]+" mystr)
990 (setq mystr (concat (substring mystr 0 (match-beginning 0))
992 (substring mystr (match-end 0)))))
994 (when (string-match "^[ \t]+" mystr)
995 (setq mystr (substring mystr (match-end 0))))
997 (when (string-match "[ \t]+$" mystr)
998 (setq mystr (substring mystr 0 (match-beginning 0))))
1001 (defsubst gnus-simplify-subject-re (subject)
1002 "Remove \"Re:\" from subject lines."
1003 (if (string-match "^[Rr][Ee]: *" subject)
1004 (substring subject (match-end 0))
1007 (defun gnus-simplify-subject (subject &optional re-only)
1008 "Remove `Re:' and words in parentheses.
1009 If RE-ONLY is non-nil, strip leading `Re:'s only."
1010 (let ((case-fold-search t)) ;Ignore case.
1011 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1012 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1013 (setq subject (substring subject (match-end 0))))
1014 ;; Remove uninteresting prefixes.
1015 (when (and (not re-only)
1016 gnus-simplify-ignored-prefixes
1017 (string-match gnus-simplify-ignored-prefixes subject))
1018 (setq subject (substring subject (match-end 0))))
1019 ;; Remove words in parentheses from end.
1021 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1022 (setq subject (substring subject 0 (match-beginning 0)))))
1023 ;; Return subject string.
1026 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1028 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1029 (goto-char (point-min))
1030 (while (re-search-forward regexp nil t)
1031 (replace-match (or newtext ""))))
1033 (defun gnus-simplify-buffer-fuzzy ()
1034 "Simplify string in the buffer fuzzily.
1035 The string in the accessible portion of the current buffer is simplified.
1036 It is assumed to be a single-line subject.
1037 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1038 matter is removed. Additional things can be deleted by setting
1039 gnus-simplify-subject-fuzzy-regexp."
1040 (let ((case-fold-search t)
1042 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1044 (while (not (eq modified-tick (buffer-modified-tick)))
1045 (setq modified-tick (buffer-modified-tick))
1047 ((listp gnus-simplify-subject-fuzzy-regexp)
1048 (mapcar 'gnus-simplify-buffer-fuzzy-step
1049 gnus-simplify-subject-fuzzy-regexp))
1050 (gnus-simplify-subject-fuzzy-regexp
1051 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1052 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1053 (gnus-simplify-buffer-fuzzy-step
1054 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1055 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1057 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1058 (gnus-simplify-buffer-fuzzy-step " +" " ")
1059 (gnus-simplify-buffer-fuzzy-step " $")
1060 (gnus-simplify-buffer-fuzzy-step "^ +")))
1062 (defun gnus-simplify-subject-fuzzy (subject)
1063 "Simplify a subject string fuzzily.
1064 See `gnus-simplify-buffer-fuzzy' for details."
1066 (gnus-set-work-buffer)
1067 (let ((case-fold-search t))
1069 (inline (gnus-simplify-buffer-fuzzy))
1072 (defsubst gnus-simplify-subject-fully (subject)
1073 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1075 (gnus-simplify-subject-functions
1076 (gnus-map-function gnus-simplify-subject-functions subject))
1077 ((null gnus-summary-gather-subject-limit)
1078 (gnus-simplify-subject-re subject))
1079 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1080 (gnus-simplify-subject-fuzzy subject))
1081 ((numberp gnus-summary-gather-subject-limit)
1082 (gnus-limit-string (gnus-simplify-subject-re subject)
1083 gnus-summary-gather-subject-limit))
1087 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1088 "Check whether two subjects are equal.
1089 If optional argument simple-first is t, first argument is already
1092 ((null simple-first)
1093 (equal (gnus-simplify-subject-fully s1)
1094 (gnus-simplify-subject-fully s2)))
1097 (gnus-simplify-subject-fully s2)))))
1099 (defun gnus-summary-bubble-group ()
1100 "Increase the score of the current group.
1101 This is a handy function to add to `gnus-summary-exit-hook' to
1102 increase the score of each group you read."
1103 (gnus-group-add-score gnus-newsgroup-name))
1107 ;;; Gnus summary mode
1110 (put 'gnus-summary-mode 'mode-class 'special)
1113 ;; Non-orthogonal keys
1115 (gnus-define-keys gnus-summary-mode-map
1116 " " gnus-summary-next-page
1117 "\177" gnus-summary-prev-page
1118 [delete] gnus-summary-prev-page
1119 [backspace] gnus-summary-prev-page
1120 "\r" gnus-summary-scroll-up
1121 "n" gnus-summary-next-unread-article
1122 "p" gnus-summary-prev-unread-article
1123 "N" gnus-summary-next-article
1124 "P" gnus-summary-prev-article
1125 "\M-\C-n" gnus-summary-next-same-subject
1126 "\M-\C-p" gnus-summary-prev-same-subject
1127 "\M-n" gnus-summary-next-unread-subject
1128 "\M-p" gnus-summary-prev-unread-subject
1129 "." gnus-summary-first-unread-article
1130 "," gnus-summary-best-unread-article
1131 "\M-s" gnus-summary-search-article-forward
1132 "\M-r" gnus-summary-search-article-backward
1133 "<" gnus-summary-beginning-of-article
1134 ">" gnus-summary-end-of-article
1135 "j" gnus-summary-goto-article
1136 "^" gnus-summary-refer-parent-article
1137 "\M-^" gnus-summary-refer-article
1138 "u" gnus-summary-tick-article-forward
1139 "!" gnus-summary-tick-article-forward
1140 "U" gnus-summary-tick-article-backward
1141 "d" gnus-summary-mark-as-read-forward
1142 "D" gnus-summary-mark-as-read-backward
1143 "E" gnus-summary-mark-as-expirable
1144 "\M-u" gnus-summary-clear-mark-forward
1145 "\M-U" gnus-summary-clear-mark-backward
1146 "k" gnus-summary-kill-same-subject-and-select
1147 "\C-k" gnus-summary-kill-same-subject
1148 "\M-\C-k" gnus-summary-kill-thread
1149 "\M-\C-l" gnus-summary-lower-thread
1150 "e" gnus-summary-edit-article
1151 "#" gnus-summary-mark-as-processable
1152 "\M-#" gnus-summary-unmark-as-processable
1153 "\M-\C-t" gnus-summary-toggle-threads
1154 "\M-\C-s" gnus-summary-show-thread
1155 "\M-\C-h" gnus-summary-hide-thread
1156 "\M-\C-f" gnus-summary-next-thread
1157 "\M-\C-b" gnus-summary-prev-thread
1158 "\M-\C-u" gnus-summary-up-thread
1159 "\M-\C-d" gnus-summary-down-thread
1160 "&" gnus-summary-execute-command
1161 "c" gnus-summary-catchup-and-exit
1162 "\C-w" gnus-summary-mark-region-as-read
1163 "\C-t" gnus-summary-toggle-truncation
1164 "?" gnus-summary-mark-as-dormant
1165 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1166 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1167 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1168 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1169 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1170 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1171 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1172 "=" gnus-summary-expand-window
1173 "\C-x\C-s" gnus-summary-reselect-current-group
1174 "\M-g" gnus-summary-rescan-group
1175 "w" gnus-summary-stop-page-breaking
1176 "\C-c\C-r" gnus-summary-caesar-message
1177 "\M-t" gnus-summary-toggle-mime
1178 "f" gnus-summary-followup
1179 "F" gnus-summary-followup-with-original
1180 "C" gnus-summary-cancel-article
1181 "r" gnus-summary-reply
1182 "R" gnus-summary-reply-with-original
1183 "\C-c\C-f" gnus-summary-mail-forward
1184 "o" gnus-summary-save-article
1185 "\C-o" gnus-summary-save-article-mail
1186 "|" gnus-summary-pipe-output
1187 "\M-k" gnus-summary-edit-local-kill
1188 "\M-K" gnus-summary-edit-global-kill
1190 "\C-c\C-d" gnus-summary-describe-group
1191 "q" gnus-summary-exit
1192 "Q" gnus-summary-exit-no-update
1193 "\C-c\C-i" gnus-info-find-node
1194 gnus-mouse-2 gnus-mouse-pick-article
1195 "m" gnus-summary-mail-other-window
1196 "a" gnus-summary-post-news
1197 "x" gnus-summary-limit-to-unread
1198 "s" gnus-summary-isearch-article
1199 "t" gnus-article-hide-headers
1200 "g" gnus-summary-show-article
1201 "l" gnus-summary-goto-last-article
1202 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1203 "\C-d" gnus-summary-enter-digest-group
1204 "\M-\C-d" gnus-summary-read-document
1206 "*" gnus-cache-enter-article
1207 "\M-*" gnus-cache-remove-article
1208 "\M-&" gnus-summary-universal-argument
1209 "\C-l" gnus-recenter
1210 "I" gnus-summary-increase-score
1211 "L" gnus-summary-lower-score
1212 "\M-i" gnus-symbolic-argument
1213 "h" gnus-summary-select-article-buffer
1215 "V" gnus-summary-score-map
1216 "X" gnus-uu-extract-map
1217 "S" gnus-summary-send-map)
1219 ;; Sort of orthogonal keymap
1220 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1221 "t" gnus-summary-tick-article-forward
1222 "!" gnus-summary-tick-article-forward
1223 "d" gnus-summary-mark-as-read-forward
1224 "r" gnus-summary-mark-as-read-forward
1225 "c" gnus-summary-clear-mark-forward
1226 " " gnus-summary-clear-mark-forward
1227 "e" gnus-summary-mark-as-expirable
1228 "x" gnus-summary-mark-as-expirable
1229 "?" gnus-summary-mark-as-dormant
1230 "b" gnus-summary-set-bookmark
1231 "B" gnus-summary-remove-bookmark
1232 "#" gnus-summary-mark-as-processable
1233 "\M-#" gnus-summary-unmark-as-processable
1234 "S" gnus-summary-limit-include-expunged
1235 "C" gnus-summary-catchup
1236 "H" gnus-summary-catchup-to-here
1237 "\C-c" gnus-summary-catchup-all
1238 "k" gnus-summary-kill-same-subject-and-select
1239 "K" gnus-summary-kill-same-subject
1240 "P" gnus-uu-mark-map)
1242 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1243 "c" gnus-summary-clear-above
1244 "u" gnus-summary-tick-above
1245 "m" gnus-summary-mark-above
1246 "k" gnus-summary-kill-below)
1248 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1249 "/" gnus-summary-limit-to-subject
1250 "n" gnus-summary-limit-to-articles
1251 "w" gnus-summary-pop-limit
1252 "s" gnus-summary-limit-to-subject
1253 "a" gnus-summary-limit-to-author
1254 "u" gnus-summary-limit-to-unread
1255 "m" gnus-summary-limit-to-marks
1256 "v" gnus-summary-limit-to-score
1257 "*" gnus-summary-limit-include-cached
1258 "D" gnus-summary-limit-include-dormant
1259 "T" gnus-summary-limit-include-thread
1260 "d" gnus-summary-limit-exclude-dormant
1261 "t" gnus-summary-limit-to-age
1262 "E" gnus-summary-limit-include-expunged
1263 "c" gnus-summary-limit-exclude-childless-dormant
1264 "C" gnus-summary-limit-mark-excluded-as-read)
1266 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1267 "n" gnus-summary-next-unread-article
1268 "p" gnus-summary-prev-unread-article
1269 "N" gnus-summary-next-article
1270 "P" gnus-summary-prev-article
1271 "\C-n" gnus-summary-next-same-subject
1272 "\C-p" gnus-summary-prev-same-subject
1273 "\M-n" gnus-summary-next-unread-subject
1274 "\M-p" gnus-summary-prev-unread-subject
1275 "f" gnus-summary-first-unread-article
1276 "b" gnus-summary-best-unread-article
1277 "j" gnus-summary-goto-article
1278 "g" gnus-summary-goto-subject
1279 "l" gnus-summary-goto-last-article
1280 "o" gnus-summary-pop-article)
1282 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1283 "k" gnus-summary-kill-thread
1284 "l" gnus-summary-lower-thread
1285 "i" gnus-summary-raise-thread
1286 "T" gnus-summary-toggle-threads
1287 "t" gnus-summary-rethread-current
1288 "^" gnus-summary-reparent-thread
1289 "s" gnus-summary-show-thread
1290 "S" gnus-summary-show-all-threads
1291 "h" gnus-summary-hide-thread
1292 "H" gnus-summary-hide-all-threads
1293 "n" gnus-summary-next-thread
1294 "p" gnus-summary-prev-thread
1295 "u" gnus-summary-up-thread
1296 "o" gnus-summary-top-thread
1297 "d" gnus-summary-down-thread
1298 "#" gnus-uu-mark-thread
1299 "\M-#" gnus-uu-unmark-thread)
1301 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1302 "g" gnus-summary-prepare
1303 "c" gnus-summary-insert-cached-articles)
1305 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1306 "c" gnus-summary-catchup-and-exit
1307 "C" gnus-summary-catchup-all-and-exit
1308 "E" gnus-summary-exit-no-update
1309 "Q" gnus-summary-exit
1310 "Z" gnus-summary-exit
1311 "n" gnus-summary-catchup-and-goto-next-group
1312 "R" gnus-summary-reselect-current-group
1313 "G" gnus-summary-rescan-group
1314 "N" gnus-summary-next-group
1315 "s" gnus-summary-save-newsrc
1316 "P" gnus-summary-prev-group)
1318 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1319 " " gnus-summary-next-page
1320 "n" gnus-summary-next-page
1321 "\177" gnus-summary-prev-page
1322 [delete] gnus-summary-prev-page
1323 "p" gnus-summary-prev-page
1324 "\r" gnus-summary-scroll-up
1325 "<" gnus-summary-beginning-of-article
1326 ">" gnus-summary-end-of-article
1327 "b" gnus-summary-beginning-of-article
1328 "e" gnus-summary-end-of-article
1329 "^" gnus-summary-refer-parent-article
1330 "r" gnus-summary-refer-parent-article
1331 "R" gnus-summary-refer-references
1332 "T" gnus-summary-refer-thread
1333 "g" gnus-summary-show-article
1334 "s" gnus-summary-isearch-article
1335 "P" gnus-summary-print-article)
1337 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1338 "b" gnus-article-add-buttons
1339 "B" gnus-article-add-buttons-to-head
1340 "o" gnus-article-treat-overstrike
1341 "e" gnus-article-emphasize
1342 "w" gnus-article-fill-cited-article
1343 "c" gnus-article-remove-cr
1344 "q" gnus-article-de-quoted-unreadable
1345 "f" gnus-article-display-x-face
1346 "l" gnus-summary-stop-page-breaking
1347 "r" gnus-summary-caesar-message
1348 "t" gnus-article-hide-headers
1349 "v" gnus-summary-verbose-headers
1350 "m" gnus-summary-toggle-mime
1351 "h" gnus-article-treat-html
1352 "d" gnus-article-treat-dumbquotes)
1354 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1355 "a" gnus-article-hide
1356 "h" gnus-article-hide-headers
1357 "b" gnus-article-hide-boring-headers
1358 "s" gnus-article-hide-signature
1359 "c" gnus-article-hide-citation
1360 "p" gnus-article-hide-pgp
1361 "P" gnus-article-hide-pem
1362 "\C-c" gnus-article-hide-citation-maybe)
1364 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1365 "a" gnus-article-highlight
1366 "h" gnus-article-highlight-headers
1367 "c" gnus-article-highlight-citation
1368 "s" gnus-article-highlight-signature)
1370 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1371 "z" gnus-article-date-ut
1372 "u" gnus-article-date-ut
1373 "l" gnus-article-date-local
1374 "e" gnus-article-date-lapsed
1375 "o" gnus-article-date-original
1376 "s" gnus-article-date-user)
1378 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1379 "t" gnus-article-remove-trailing-blank-lines
1380 "l" gnus-article-strip-leading-blank-lines
1381 "m" gnus-article-strip-multiple-blank-lines
1382 "a" gnus-article-strip-blank-lines
1383 "s" gnus-article-strip-leading-space)
1385 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1387 "f" gnus-summary-fetch-faq
1388 "d" gnus-summary-describe-group
1389 "h" gnus-summary-describe-briefly
1390 "i" gnus-info-find-node)
1392 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1393 "e" gnus-summary-expire-articles
1394 "\M-\C-e" gnus-summary-expire-articles-now
1395 "\177" gnus-summary-delete-article
1396 [delete] gnus-summary-delete-article
1397 "m" gnus-summary-move-article
1398 "r" gnus-summary-respool-article
1399 "w" gnus-summary-edit-article
1400 "c" gnus-summary-copy-article
1401 "B" gnus-summary-crosspost-article
1402 "q" gnus-summary-respool-query
1403 "i" gnus-summary-import-article
1404 "p" gnus-summary-article-posted-p)
1406 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1407 "o" gnus-summary-save-article
1408 "m" gnus-summary-save-article-mail
1409 "F" gnus-summary-write-article-file
1410 "r" gnus-summary-save-article-rmail
1411 "f" gnus-summary-save-article-file
1412 "b" gnus-summary-save-article-body-file
1413 "h" gnus-summary-save-article-folder
1414 "v" gnus-summary-save-article-vm
1415 "p" gnus-summary-pipe-output
1416 "s" gnus-soup-add-article))
1418 (defun gnus-summary-make-menu-bar ()
1419 (gnus-turn-off-edit-menu 'summary)
1421 (unless (boundp 'gnus-summary-misc-menu)
1424 gnus-summary-kill-menu gnus-summary-mode-map ""
1429 ["Enter score..." gnus-summary-score-entry t]
1430 ["Customize" gnus-score-customize t])
1431 (gnus-make-score-map 'increase)
1432 (gnus-make-score-map 'lower)
1434 ["Kill below" gnus-summary-kill-below t]
1435 ["Mark above" gnus-summary-mark-above t]
1436 ["Tick above" gnus-summary-tick-above t]
1437 ["Clear above" gnus-summary-clear-above t])
1438 ["Current score" gnus-summary-current-score t]
1439 ["Set score" gnus-summary-set-score t]
1440 ["Switch current score file..." gnus-score-change-score-file t]
1441 ["Set mark below..." gnus-score-set-mark-below t]
1442 ["Set expunge below..." gnus-score-set-expunge-below t]
1443 ["Edit current score file" gnus-score-edit-current-scores t]
1444 ["Edit score file" gnus-score-edit-file t]
1445 ["Trace score" gnus-score-find-trace t]
1446 ["Find words" gnus-score-find-favourite-words t]
1447 ["Rescore buffer" gnus-summary-rescore t]
1448 ["Increase score..." gnus-summary-increase-score t]
1449 ["Lower score..." gnus-summary-lower-score t]))))
1452 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1454 :selected (null gnus-score-default-header)]
1455 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1457 :selected (eq gnus-score-default-header 'a)]
1458 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1460 :selected (eq gnus-score-default-header 's)]
1462 (gnus-score-set-default 'gnus-score-default-header 'b)
1464 :selected (eq gnus-score-default-header 'b )]
1466 (gnus-score-set-default 'gnus-score-default-header 'h)
1468 :selected (eq gnus-score-default-header 'h )]
1469 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1471 :selected (eq gnus-score-default-header 'i )]
1472 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1474 :selected (eq gnus-score-default-header 't )]
1476 (gnus-score-set-default 'gnus-score-default-header 'x)
1478 :selected (eq gnus-score-default-header 'x )]
1479 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1481 :selected (eq gnus-score-default-header 'l )]
1482 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1484 :selected (eq gnus-score-default-header 'd )]
1485 ["Followups to author"
1486 (gnus-score-set-default 'gnus-score-default-header 'f)
1488 :selected (eq gnus-score-default-header 'f )])
1490 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1492 :selected (null gnus-score-default-type)]
1493 ;; The `:active' key is commented out in the following,
1494 ;; because the GNU Emacs hack to support radio buttons use
1495 ;; active to indicate which button is selected.
1496 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1498 ;; :active (not (memq gnus-score-default-header '(l d)))
1499 :selected (eq gnus-score-default-type 's)]
1500 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1502 ;; :active (not (memq gnus-score-default-header '(l d)))
1503 :selected (eq gnus-score-default-type 'r)]
1504 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1506 ;; :active (not (memq gnus-score-default-header '(l d)))
1507 :selected (eq gnus-score-default-type 'e)]
1508 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1510 ;; :active (not (memq gnus-score-default-header '(l d)))
1511 :selected (eq gnus-score-default-type 'f)]
1512 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1514 ;; :active (eq (gnus-score-default-header 'd))
1515 :selected (eq gnus-score-default-type 'b)]
1516 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1518 ;; :active (eq (gnus-score-default-header 'd))
1519 :selected (eq gnus-score-default-type 'n)]
1520 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1522 ;; :active (eq (gnus-score-default-header 'd))
1523 :selected (eq gnus-score-default-type 'a)]
1525 (gnus-score-set-default 'gnus-score-default-type '<)
1527 ;; :active (eq (gnus-score-default-header 'l))
1528 :selected (eq gnus-score-default-type '<)]
1530 (gnus-score-set-default 'gnus-score-default-type '=)
1532 ;; :active (eq (gnus-score-default-header 'l))
1533 :selected (eq gnus-score-default-type '=)]
1534 ["Greater than number"
1535 (gnus-score-set-default 'gnus-score-default-type '>)
1537 ;; :active (eq (gnus-score-default-header 'l))
1538 :selected (eq gnus-score-default-type '>)])
1539 ["Default fold" gnus-score-default-fold-toggle
1541 :selected gnus-score-default-fold]
1543 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1545 :selected (null gnus-score-default-duration)]
1547 (gnus-score-set-default 'gnus-score-default-duration 'p)
1549 :selected (eq gnus-score-default-duration 'p)]
1551 (gnus-score-set-default 'gnus-score-default-duration 't)
1553 :selected (eq gnus-score-default-duration 't)]
1555 (gnus-score-set-default 'gnus-score-default-duration 'i)
1557 :selected (eq gnus-score-default-duration 'i)]))
1560 gnus-summary-article-menu gnus-summary-mode-map ""
1563 ["All" gnus-article-hide t]
1564 ["Headers" gnus-article-hide-headers t]
1565 ["Signature" gnus-article-hide-signature t]
1566 ["Citation" gnus-article-hide-citation t]
1567 ["PGP" gnus-article-hide-pgp t]
1568 ["Boring headers" gnus-article-hide-boring-headers t])
1570 ["All" gnus-article-highlight t]
1571 ["Headers" gnus-article-highlight-headers t]
1572 ["Signature" gnus-article-highlight-signature t]
1573 ["Citation" gnus-article-highlight-citation t])
1575 ["Local" gnus-article-date-local t]
1576 ["UT" gnus-article-date-ut t]
1577 ["Original" gnus-article-date-original t]
1578 ["Lapsed" gnus-article-date-lapsed t]
1579 ["User-defined" gnus-article-date-user t])
1582 ["Leading" gnus-article-strip-leading-blank-lines t]
1583 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1584 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1585 ["All of the above" gnus-article-strip-blank-lines t]
1586 ["Leading space" gnus-article-strip-leading-space t])
1587 ["Overstrike" gnus-article-treat-overstrike t]
1588 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1589 ["Emphasis" gnus-article-emphasize t]
1590 ["Word wrap" gnus-article-fill-cited-article t]
1591 ["CR" gnus-article-remove-cr t]
1592 ["Show X-Face" gnus-article-display-x-face t]
1593 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1594 ["UnHTMLize" gnus-article-treat-html t]
1595 ["Rot 13" gnus-summary-caesar-message t]
1596 ["Unix pipe" gnus-summary-pipe-message t]
1597 ["Add buttons" gnus-article-add-buttons t]
1598 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1599 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1600 ["Toggle MIME" gnus-summary-toggle-mime t]
1601 ["Verbose header" gnus-summary-verbose-headers t]
1602 ["Toggle header" gnus-summary-toggle-header t])
1604 ["Save in default format" gnus-summary-save-article t]
1605 ["Save in file" gnus-summary-save-article-file t]
1606 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1607 ["Save in MH folder" gnus-summary-save-article-folder t]
1608 ["Save in VM folder" gnus-summary-save-article-vm t]
1609 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1610 ["Save body in file" gnus-summary-save-article-body-file t]
1611 ["Pipe through a filter" gnus-summary-pipe-output t]
1612 ["Add to SOUP packet" gnus-soup-add-article t]
1613 ["Print" gnus-summary-print-article t])
1615 ["Respool article..." gnus-summary-respool-article t]
1616 ["Move article..." gnus-summary-move-article
1617 (gnus-check-backend-function
1618 'request-move-article gnus-newsgroup-name)]
1619 ["Copy article..." gnus-summary-copy-article t]
1620 ["Crosspost article..." gnus-summary-crosspost-article
1621 (gnus-check-backend-function
1622 'request-replace-article gnus-newsgroup-name)]
1623 ["Import file..." gnus-summary-import-article t]
1624 ["Check if posted" gnus-summary-article-posted-p t]
1625 ["Edit article" gnus-summary-edit-article
1626 (not (gnus-group-read-only-p))]
1627 ["Delete article" gnus-summary-delete-article
1628 (gnus-check-backend-function
1629 'request-expire-articles gnus-newsgroup-name)]
1630 ["Query respool" gnus-summary-respool-query t]
1631 ["Delete expirable articles" gnus-summary-expire-articles-now
1632 (gnus-check-backend-function
1633 'request-expire-articles gnus-newsgroup-name)])
1635 ["Uudecode" gnus-uu-decode-uu t]
1636 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1637 ["Unshar" gnus-uu-decode-unshar t]
1638 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1639 ["Save" gnus-uu-decode-save t]
1640 ["Binhex" gnus-uu-decode-binhex t]
1641 ["Postscript" gnus-uu-decode-postscript t])
1643 ["Enter article" gnus-cache-enter-article t]
1644 ["Remove article" gnus-cache-remove-article t])
1645 ["Select article buffer" gnus-summary-select-article-buffer t]
1646 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1647 ["Isearch article..." gnus-summary-isearch-article t]
1648 ["Beginning of the article" gnus-summary-beginning-of-article t]
1649 ["End of the article" gnus-summary-end-of-article t]
1650 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1651 ["Fetch referenced articles" gnus-summary-refer-references t]
1652 ["Fetch current thread" gnus-summary-refer-thread t]
1653 ["Fetch article with id..." gnus-summary-refer-article t]
1654 ["Redisplay" gnus-summary-show-article t]))
1657 gnus-summary-thread-menu gnus-summary-mode-map ""
1659 ["Toggle threading" gnus-summary-toggle-threads t]
1660 ["Hide threads" gnus-summary-hide-all-threads t]
1661 ["Show threads" gnus-summary-show-all-threads t]
1662 ["Hide thread" gnus-summary-hide-thread t]
1663 ["Show thread" gnus-summary-show-thread t]
1664 ["Go to next thread" gnus-summary-next-thread t]
1665 ["Go to previous thread" gnus-summary-prev-thread t]
1666 ["Go down thread" gnus-summary-down-thread t]
1667 ["Go up thread" gnus-summary-up-thread t]
1668 ["Top of thread" gnus-summary-top-thread t]
1669 ["Mark thread as read" gnus-summary-kill-thread t]
1670 ["Lower thread score" gnus-summary-lower-thread t]
1671 ["Raise thread score" gnus-summary-raise-thread t]
1672 ["Rethread current" gnus-summary-rethread-current t]
1676 gnus-summary-post-menu gnus-summary-mode-map ""
1678 ["Post an article" gnus-summary-post-news t]
1679 ["Followup" gnus-summary-followup t]
1680 ["Followup and yank" gnus-summary-followup-with-original t]
1681 ["Supersede article" gnus-summary-supersede-article t]
1682 ["Cancel article" gnus-summary-cancel-article t]
1683 ["Reply" gnus-summary-reply t]
1684 ["Reply and yank" gnus-summary-reply-with-original t]
1685 ["Wide reply" gnus-summary-wide-reply t]
1686 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1687 ["Mail forward" gnus-summary-mail-forward t]
1688 ["Post forward" gnus-summary-post-forward t]
1689 ["Digest and mail" gnus-uu-digest-mail-forward t]
1690 ["Digest and post" gnus-uu-digest-post-forward t]
1691 ["Resend message" gnus-summary-resend-message t]
1692 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1693 ["Send a mail" gnus-summary-mail-other-window t]
1694 ["Uuencode and post" gnus-uu-post-news t]
1695 ["Followup via news" gnus-summary-followup-to-mail t]
1696 ["Followup via news and yank"
1697 gnus-summary-followup-to-mail-with-original t]
1699 ;;["Send" gnus-summary-send-draft t]
1700 ;;["Send bounced" gnus-resend-bounced-mail t])
1704 gnus-summary-misc-menu gnus-summary-mode-map ""
1707 ["Mark as read" gnus-summary-mark-as-read-forward t]
1708 ["Mark same subject and select"
1709 gnus-summary-kill-same-subject-and-select t]
1710 ["Mark same subject" gnus-summary-kill-same-subject t]
1711 ["Catchup" gnus-summary-catchup t]
1712 ["Catchup all" gnus-summary-catchup-all t]
1713 ["Catchup to here" gnus-summary-catchup-to-here t]
1714 ["Catchup region" gnus-summary-mark-region-as-read t]
1715 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1717 ["Tick" gnus-summary-tick-article-forward t]
1718 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1719 ["Remove marks" gnus-summary-clear-mark-forward t]
1720 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1721 ["Set bookmark" gnus-summary-set-bookmark t]
1722 ["Remove bookmark" gnus-summary-remove-bookmark t])
1724 ["Marks..." gnus-summary-limit-to-marks t]
1725 ["Subject..." gnus-summary-limit-to-subject t]
1726 ["Author..." gnus-summary-limit-to-author t]
1727 ["Age..." gnus-summary-limit-to-age t]
1728 ["Score" gnus-summary-limit-to-score t]
1729 ["Unread" gnus-summary-limit-to-unread t]
1730 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1731 ["Articles" gnus-summary-limit-to-articles t]
1732 ["Pop limit" gnus-summary-pop-limit t]
1733 ["Show dormant" gnus-summary-limit-include-dormant t]
1734 ["Hide childless dormant"
1735 gnus-summary-limit-exclude-childless-dormant t]
1736 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1737 ["Show expunged" gnus-summary-show-all-expunged t])
1739 ["Set mark" gnus-summary-mark-as-processable t]
1740 ["Remove mark" gnus-summary-unmark-as-processable t]
1741 ["Remove all marks" gnus-summary-unmark-all-processable t]
1742 ["Mark above" gnus-uu-mark-over t]
1743 ["Mark series" gnus-uu-mark-series t]
1744 ["Mark region" gnus-uu-mark-region t]
1745 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1746 ["Mark all" gnus-uu-mark-all t]
1747 ["Mark buffer" gnus-uu-mark-buffer t]
1748 ["Mark sparse" gnus-uu-mark-sparse t]
1749 ["Mark thread" gnus-uu-mark-thread t]
1750 ["Unmark thread" gnus-uu-unmark-thread t]
1751 ("Process Mark Sets"
1752 ["Kill" gnus-summary-kill-process-mark t]
1753 ["Yank" gnus-summary-yank-process-mark
1754 gnus-newsgroup-process-stack]
1755 ["Save" gnus-summary-save-process-mark t]))
1757 ["Page forward" gnus-summary-next-page t]
1758 ["Page backward" gnus-summary-prev-page t]
1759 ["Line forward" gnus-summary-scroll-up t])
1761 ["Next unread article" gnus-summary-next-unread-article t]
1762 ["Previous unread article" gnus-summary-prev-unread-article t]
1763 ["Next article" gnus-summary-next-article t]
1764 ["Previous article" gnus-summary-prev-article t]
1765 ["Next unread subject" gnus-summary-next-unread-subject t]
1766 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1767 ["Next article same subject" gnus-summary-next-same-subject t]
1768 ["Previous article same subject" gnus-summary-prev-same-subject t]
1769 ["First unread article" gnus-summary-first-unread-article t]
1770 ["Best unread article" gnus-summary-best-unread-article t]
1771 ["Go to subject number..." gnus-summary-goto-subject t]
1772 ["Go to article number..." gnus-summary-goto-article t]
1773 ["Go to the last article" gnus-summary-goto-last-article t]
1774 ["Pop article off history" gnus-summary-pop-article t])
1776 ["Sort by number" gnus-summary-sort-by-number t]
1777 ["Sort by author" gnus-summary-sort-by-author t]
1778 ["Sort by subject" gnus-summary-sort-by-subject t]
1779 ["Sort by date" gnus-summary-sort-by-date t]
1780 ["Sort by score" gnus-summary-sort-by-score t]
1781 ["Sort by lines" gnus-summary-sort-by-lines t])
1783 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1784 ["Describe group" gnus-summary-describe-group t]
1785 ["Read manual" gnus-info-find-node t])
1787 ["Pick and read" gnus-pick-mode t]
1788 ["Binary" gnus-binary-mode t])
1790 ["Regenerate" gnus-summary-prepare t]
1791 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1792 ["Toggle threading" gnus-summary-toggle-threads t])
1793 ["Filter articles..." gnus-summary-execute-command t]
1794 ["Run command on subjects..." gnus-summary-universal-argument t]
1795 ["Search articles forward..." gnus-summary-search-article-forward t]
1796 ["Search articles backward..." gnus-summary-search-article-backward t]
1797 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1798 ["Expand window" gnus-summary-expand-window t]
1799 ["Expire expirable articles" gnus-summary-expire-articles
1800 (gnus-check-backend-function
1801 'request-expire-articles gnus-newsgroup-name)]
1802 ["Edit local kill file" gnus-summary-edit-local-kill t]
1803 ["Edit main kill file" gnus-summary-edit-global-kill t]
1805 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1806 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1807 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1808 ["Exit group" gnus-summary-exit t]
1809 ["Exit group without updating" gnus-summary-exit-no-update t]
1810 ["Exit and goto next group" gnus-summary-next-group t]
1811 ["Exit and goto prev group" gnus-summary-prev-group t]
1812 ["Reselect group" gnus-summary-reselect-current-group t]
1813 ["Rescan group" gnus-summary-rescan-group t]
1814 ["Update dribble" gnus-summary-save-newsrc t])))
1816 (run-hooks 'gnus-summary-menu-hook)))
1818 (defun gnus-score-set-default (var value)
1819 "A version of set that updates the GNU Emacs menu-bar."
1821 ;; It is the message that forces the active status to be updated.
1824 (defun gnus-make-score-map (type)
1825 "Make a summary score map of type TYPE."
1828 (let ((headers '(("author" "from" string)
1829 ("subject" "subject" string)
1830 ("article body" "body" string)
1831 ("article head" "head" string)
1832 ("xref" "xref" string)
1833 ("lines" "lines" number)
1834 ("followups to author" "followup" string)))
1835 (types '((number ("less than" <)
1838 (string ("substring" s)
1842 (perms '(("temporary" (current-time-string))
1850 (if (eq type 'lower)
1855 (setq header (car headers))
1861 (let ((ts (cdr (assoc (nth 2 header) types)))
1877 'gnus-summary-score-entry
1879 (if (or (string= (nth 1 header)
1881 (string= (nth 1 header)
1884 (list 'gnus-summary-header
1886 (list 'quote (nth 1 (car ts)))
1887 (list 'gnus-score-default nil)
1893 (list (nreverse outp))))
1896 (list (nreverse outt))))
1898 (setq headers (cdr headers)))
1899 (list (nreverse outh))))))))
1903 (defun gnus-summary-mode (&optional group)
1904 "Major mode for reading articles.
1906 All normal editing commands are switched off.
1907 \\<gnus-summary-mode-map>
1908 Each line in this buffer represents one article. To read an
1909 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1910 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1913 You can also post articles and send mail from this buffer. To
1914 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1915 of an article, type `\\[gnus-summary-reply]'.
1917 There are approx. one gazillion commands you can execute in this
1918 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1920 The following commands are available:
1922 \\{gnus-summary-mode-map}"
1924 (when (gnus-visual-p 'summary-menu 'menu)
1925 (gnus-summary-make-menu-bar))
1926 (kill-all-local-variables)
1927 (gnus-summary-make-local-variables)
1928 (gnus-make-thread-indent-array)
1929 (gnus-simplify-mode-line)
1930 (setq major-mode 'gnus-summary-mode)
1931 (setq mode-name "Summary")
1932 (make-local-variable 'minor-mode-alist)
1933 (use-local-map gnus-summary-mode-map)
1934 (buffer-disable-undo (current-buffer))
1935 (setq buffer-read-only t) ;Disable modification
1936 (setq truncate-lines t)
1937 (setq selective-display t)
1938 (setq selective-display-ellipses t) ;Display `...'
1939 (gnus-summary-set-display-table)
1940 (gnus-set-default-directory)
1941 (setq gnus-newsgroup-name group)
1942 (make-local-variable 'gnus-summary-line-format)
1943 (make-local-variable 'gnus-summary-line-format-spec)
1944 (make-local-variable 'gnus-summary-dummy-line-format)
1945 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1946 (make-local-variable 'gnus-summary-mark-positions)
1947 (make-local-hook 'post-command-hook)
1948 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1949 (make-local-hook 'pre-command-hook)
1950 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1951 (run-hooks 'gnus-summary-mode-hook)
1952 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1953 (gnus-update-summary-mark-positions))
1955 (defun gnus-summary-make-local-variables ()
1956 "Make all the local summary buffer variables."
1957 (let ((locals gnus-summary-local-variables)
1959 (while (setq local (pop locals))
1962 (if (eq (cdr local) 'global)
1963 ;; Copy the global value of the variable.
1964 (setq global (symbol-value (car local)))
1965 ;; Use the value from the list.
1966 (setq global (eval (cdr local))))
1967 (make-local-variable (car local))
1968 (set (car local) global))
1969 ;; Simple nil-valued local variable.
1970 (make-local-variable local)
1973 (defun gnus-summary-clear-local-variables ()
1974 (let ((locals gnus-summary-local-variables))
1976 (if (consp (car locals))
1977 (and (vectorp (caar locals))
1978 (set (caar locals) nil))
1979 (and (vectorp (car locals))
1980 (set (car locals) nil)))
1981 (setq locals (cdr locals)))))
1983 ;; Summary data functions.
1985 (defmacro gnus-data-number (data)
1988 (defmacro gnus-data-set-number (data number)
1989 `(setcar ,data ,number))
1991 (defmacro gnus-data-mark (data)
1994 (defmacro gnus-data-set-mark (data mark)
1995 `(setcar (nthcdr 1 ,data) ,mark))
1997 (defmacro gnus-data-pos (data)
2000 (defmacro gnus-data-set-pos (data pos)
2001 `(setcar (nthcdr 2 ,data) ,pos))
2003 (defmacro gnus-data-header (data)
2006 (defmacro gnus-data-set-header (data header)
2007 `(setf (nth 3 ,data) ,header))
2009 (defmacro gnus-data-level (data)
2012 (defmacro gnus-data-unread-p (data)
2013 `(= (nth 1 ,data) gnus-unread-mark))
2015 (defmacro gnus-data-read-p (data)
2016 `(/= (nth 1 ,data) gnus-unread-mark))
2018 (defmacro gnus-data-pseudo-p (data)
2019 `(consp (nth 3 ,data)))
2021 (defmacro gnus-data-find (number)
2022 `(assq ,number gnus-newsgroup-data))
2024 (defmacro gnus-data-find-list (number &optional data)
2025 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2026 (memq (assq ,number bdata)
2029 (defmacro gnus-data-make (number mark pos header level)
2030 `(list ,number ,mark ,pos ,header ,level))
2032 (defun gnus-data-enter (after-article number mark pos header level offset)
2033 (let ((data (gnus-data-find-list after-article)))
2035 (error "No such article: %d" after-article))
2036 (setcdr data (cons (gnus-data-make number mark pos header level)
2038 (setq gnus-newsgroup-data-reverse nil)
2039 (gnus-data-update-list (cddr data) offset)))
2041 (defun gnus-data-enter-list (after-article list &optional offset)
2043 (let ((data (and after-article (gnus-data-find-list after-article)))
2045 (or data (not after-article) (error "No such article: %d" after-article))
2046 ;; Find the last element in the list to be spliced into the main
2049 (setq list (cdr list)))
2052 (setcdr list gnus-newsgroup-data)
2053 (setq gnus-newsgroup-data ilist)
2055 (gnus-data-update-list (cdr list) offset)))
2056 (setcdr list (cdr data))
2059 (gnus-data-update-list (cdr list) offset)))
2060 (setq gnus-newsgroup-data-reverse nil))))
2062 (defun gnus-data-remove (article &optional offset)
2063 (let ((data gnus-newsgroup-data))
2064 (if (= (gnus-data-number (car data)) article)
2066 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2067 gnus-newsgroup-data-reverse nil)
2069 (gnus-data-update-list gnus-newsgroup-data offset)))
2071 (when (= (gnus-data-number (cadr data)) article)
2072 (setcdr data (cddr data))
2074 (gnus-data-update-list (cdr data) offset))
2076 gnus-newsgroup-data-reverse nil))
2077 (setq data (cdr data))))))
2079 (defmacro gnus-data-list (backward)
2081 (or gnus-newsgroup-data-reverse
2082 (setq gnus-newsgroup-data-reverse
2083 (reverse gnus-newsgroup-data)))
2084 gnus-newsgroup-data))
2086 (defun gnus-data-update-list (data offset)
2087 "Add OFFSET to the POS of all data entries in DATA."
2089 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2090 (setq data (cdr data))))
2092 (defun gnus-data-compute-positions ()
2093 "Compute the positions of all articles."
2094 (let ((data gnus-newsgroup-data)
2097 (when (setq pos (text-property-any
2098 (point-min) (point-max)
2099 'gnus-number (gnus-data-number (car data))))
2100 (gnus-data-set-pos (car data) (+ pos 3)))
2101 (setq data (cdr data)))))
2103 (defun gnus-summary-article-pseudo-p (article)
2104 "Say whether this article is a pseudo article or not."
2105 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2107 (defmacro gnus-summary-article-sparse-p (article)
2108 "Say whether this article is a sparse article or not."
2109 `(memq ,article gnus-newsgroup-sparse))
2111 (defmacro gnus-summary-article-ancient-p (article)
2112 "Say whether this article is a sparse article or not."
2113 `(memq ,article gnus-newsgroup-ancient))
2115 (defun gnus-article-parent-p (number)
2116 "Say whether this article is a parent or not."
2117 (let ((data (gnus-data-find-list number)))
2118 (and (cdr data) ; There has to be an article after...
2119 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2120 (gnus-data-level (nth 1 data))))))
2122 (defun gnus-article-children (number)
2123 "Return a list of all children to NUMBER."
2124 (let* ((data (gnus-data-find-list number))
2125 (level (gnus-data-level (car data)))
2127 (setq data (cdr data))
2129 (= (gnus-data-level (car data)) (1+ level)))
2130 (push (gnus-data-number (car data)) children)
2131 (setq data (cdr data)))
2134 (defmacro gnus-summary-skip-intangible ()
2135 "If the current article is intangible, then jump to a different article."
2136 '(let ((to (get-text-property (point) 'gnus-intangible)))
2137 (and to (gnus-summary-goto-subject to))))
2139 (defmacro gnus-summary-article-intangible-p ()
2140 "Say whether this article is intangible or not."
2141 '(get-text-property (point) 'gnus-intangible))
2143 (defun gnus-article-read-p (article)
2144 "Say whether ARTICLE is read or not."
2145 (not (or (memq article gnus-newsgroup-marked)
2146 (memq article gnus-newsgroup-unreads)
2147 (memq article gnus-newsgroup-unselected)
2148 (memq article gnus-newsgroup-dormant))))
2150 ;; Some summary mode macros.
2152 (defmacro gnus-summary-article-number ()
2153 "The article number of the article on the current line.
2154 If there isn's an article number here, then we return the current
2157 (gnus-summary-skip-intangible)
2158 (or (get-text-property (point) 'gnus-number)
2159 (gnus-summary-last-subject))))
2161 (defmacro gnus-summary-article-header (&optional number)
2162 `(gnus-data-header (gnus-data-find
2163 ,(or number '(gnus-summary-article-number)))))
2165 (defmacro gnus-summary-thread-level (&optional number)
2166 `(if (and (eq gnus-summary-make-false-root 'dummy)
2167 (get-text-property (point) 'gnus-intangible))
2169 (gnus-data-level (gnus-data-find
2170 ,(or number '(gnus-summary-article-number))))))
2172 (defmacro gnus-summary-article-mark (&optional number)
2173 `(gnus-data-mark (gnus-data-find
2174 ,(or number '(gnus-summary-article-number)))))
2176 (defmacro gnus-summary-article-pos (&optional number)
2177 `(gnus-data-pos (gnus-data-find
2178 ,(or number '(gnus-summary-article-number)))))
2180 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2181 (defmacro gnus-summary-article-subject (&optional number)
2182 "Return current subject string or nil if nothing."
2185 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2186 '(gnus-data-header (assq (gnus-summary-article-number)
2187 gnus-newsgroup-data)))))
2190 (mail-header-subject headers))))
2192 (defmacro gnus-summary-article-score (&optional number)
2193 "Return current article score."
2194 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2195 gnus-newsgroup-scored))
2196 gnus-summary-default-score 0))
2198 (defun gnus-summary-article-children (&optional number)
2199 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2200 (level (gnus-data-level (car data)))
2202 (while (and (setq data (cdr data))
2203 (> (setq l (gnus-data-level (car data))) level))
2204 (and (= (1+ level) l)
2205 (push (gnus-data-number (car data))
2207 (nreverse children)))
2209 (defun gnus-summary-article-parent (&optional number)
2210 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2211 (gnus-data-list t)))
2212 (level (gnus-data-level (car data))))
2214 () ; This is a root.
2215 ;; We search until we find an article with a level less than
2216 ;; this one. That function has to be the parent.
2217 (while (and (setq data (cdr data))
2218 (not (< (gnus-data-level (car data)) level))))
2219 (and data (gnus-data-number (car data))))))
2221 (defun gnus-unread-mark-p (mark)
2222 "Say whether MARK is the unread mark."
2223 (= mark gnus-unread-mark))
2225 (defun gnus-read-mark-p (mark)
2226 "Say whether MARK is one of the marks that mark as read.
2227 This is all marks except unread, ticked, dormant, and expirable."
2228 (not (or (= mark gnus-unread-mark)
2229 (= mark gnus-ticked-mark)
2230 (= mark gnus-dormant-mark)
2231 (= mark gnus-expirable-mark))))
2233 (defmacro gnus-article-mark (number)
2235 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2236 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2237 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2238 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2239 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2240 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2241 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2242 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2243 gnus-ancient-mark))))
2245 ;; Saving hidden threads.
2247 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2248 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2250 (defmacro gnus-save-hidden-threads (&rest forms)
2251 "Save hidden threads, eval FORMS, and restore the hidden threads."
2252 (let ((config (make-symbol "config")))
2253 `(let ((,config (gnus-hidden-threads-configuration)))
2257 (gnus-restore-hidden-threads-configuration ,config)))))
2259 (defun gnus-hidden-threads-configuration ()
2260 "Return the current hidden threads configuration."
2263 (goto-char (point-min))
2264 (while (search-forward "\r" nil t)
2265 (push (1- (point)) config))
2268 (defun gnus-restore-hidden-threads-configuration (config)
2269 "Restore hidden threads configuration from CONFIG."
2270 (let (point buffer-read-only)
2271 (while (setq point (pop config))
2272 (when (and (< point (point-max))
2274 (= (following-char) ?\n))
2275 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2277 ;; Various summary mode internalish functions.
2279 (defun gnus-mouse-pick-article (e)
2282 (gnus-summary-next-page nil t))
2284 (defun gnus-summary-set-display-table ()
2285 ;; Change the display table. Odd characters have a tendency to mess
2286 ;; up nicely formatted displays - we make all possible glyphs
2287 ;; display only a single character.
2289 ;; We start from the standard display table, if any.
2290 (let ((table (or (copy-sequence standard-display-table)
2291 (make-display-table)))
2293 ;; Nix out all the control chars...
2294 (while (>= (setq i (1- i)) 0)
2295 (aset table i [??]))
2296 ;; ... but not newline and cr, of course. (cr is necessary for the
2297 ;; selective display).
2298 (aset table ?\n nil)
2299 (aset table ?\r nil)
2300 ;; We nix out any glyphs over 126 that are not set already.
2302 (while (>= (setq i (1- i)) 127)
2303 ;; Only modify if the entry is nil.
2304 (unless (aref table i)
2305 (aset table i [??]))))
2306 (setq buffer-display-table table)))
2308 (defun gnus-summary-setup-buffer (group)
2309 "Initialize summary buffer."
2310 (let ((buffer (concat "*Summary " group "*")))
2311 (if (get-buffer buffer)
2314 (setq gnus-summary-buffer (current-buffer))
2315 (not gnus-newsgroup-prepared))
2316 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2317 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2318 (gnus-add-current-to-buffer-list)
2319 (gnus-summary-mode group)
2321 (gnus-carpal-setup-buffer 'summary))
2322 (unless gnus-single-article-buffer
2323 (make-local-variable 'gnus-article-buffer)
2324 (make-local-variable 'gnus-article-current)
2325 (make-local-variable 'gnus-original-article-buffer))
2326 (setq gnus-newsgroup-name group)
2329 (defun gnus-set-global-variables ()
2330 ;; Set the global equivalents of the summary buffer-local variables
2331 ;; to the latest values they had. These reflect the summary buffer
2332 ;; that was in action when the last article was fetched.
2333 (when (eq major-mode 'gnus-summary-mode)
2334 (setq gnus-summary-buffer (current-buffer))
2335 (let ((name gnus-newsgroup-name)
2336 (marked gnus-newsgroup-marked)
2337 (unread gnus-newsgroup-unreads)
2338 (headers gnus-current-headers)
2339 (data gnus-newsgroup-data)
2340 (summary gnus-summary-buffer)
2341 (article-buffer gnus-article-buffer)
2342 (original gnus-original-article-buffer)
2343 (gac gnus-article-current)
2344 (reffed gnus-reffed-article-number)
2345 (score-file gnus-current-score-file))
2347 (set-buffer gnus-group-buffer)
2348 (setq gnus-newsgroup-name name
2349 gnus-newsgroup-marked marked
2350 gnus-newsgroup-unreads unread
2351 gnus-current-headers headers
2352 gnus-newsgroup-data data
2353 gnus-article-current gac
2354 gnus-summary-buffer summary
2355 gnus-article-buffer article-buffer
2356 gnus-original-article-buffer original
2357 gnus-reffed-article-number reffed
2358 gnus-current-score-file score-file)
2359 ;; The article buffer also has local variables.
2360 (when (gnus-buffer-live-p gnus-article-buffer)
2361 (set-buffer gnus-article-buffer)
2362 (setq gnus-summary-buffer summary))))))
2364 (defun gnus-summary-article-unread-p (article)
2365 "Say whether ARTICLE is unread or not."
2366 (memq article gnus-newsgroup-unreads))
2368 (defun gnus-summary-first-article-p (&optional article)
2369 "Return whether ARTICLE is the first article in the buffer."
2370 (if (not (setq article (or article (gnus-summary-article-number))))
2372 (eq article (caar gnus-newsgroup-data))))
2374 (defun gnus-summary-last-article-p (&optional article)
2375 "Return whether ARTICLE is the last article in the buffer."
2376 (if (not (setq article (or article (gnus-summary-article-number))))
2377 t ; All non-existent numbers are the last article. :-)
2378 (not (cdr (gnus-data-find-list article)))))
2380 (defun gnus-make-thread-indent-array ()
2382 (unless (and gnus-thread-indent-array
2383 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2384 (setq gnus-thread-indent-array (make-vector 201 "")
2385 gnus-thread-indent-array-level gnus-thread-indent-level)
2387 (aset gnus-thread-indent-array n
2388 (make-string (* n gnus-thread-indent-level) ? ))
2391 (defun gnus-update-summary-mark-positions ()
2392 "Compute where the summary marks are to go."
2394 (when (and gnus-summary-buffer
2395 (get-buffer gnus-summary-buffer)
2396 (buffer-name (get-buffer gnus-summary-buffer)))
2397 (set-buffer gnus-summary-buffer))
2398 (let ((gnus-replied-mark 129)
2399 (gnus-score-below-mark 130)
2400 (gnus-score-over-mark 130)
2401 (gnus-download-mark 131)
2402 (spec gnus-summary-line-format-spec)
2403 thread gnus-visual pos)
2405 (gnus-set-work-buffer)
2406 (let ((gnus-summary-line-format-spec spec)
2407 (gnus-newsgroup-downloadable '((0 . t))))
2408 (gnus-summary-insert-line
2409 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2410 (goto-char (point-min))
2411 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2413 (goto-char (point-min))
2414 (push (cons 'replied (and (search-forward "\201" nil t)
2417 (goto-char (point-min))
2418 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2420 (goto-char (point-min))
2421 (push (cons 'download
2422 (and (search-forward "\203" nil t) (- (point) 2)))
2424 (setq gnus-summary-mark-positions pos))))
2426 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2427 "Insert a dummy root in the summary buffer."
2429 (gnus-add-text-properties
2430 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2431 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2433 (defun gnus-summary-insert-line (gnus-tmp-header
2434 gnus-tmp-level gnus-tmp-current
2435 gnus-tmp-unread gnus-tmp-replied
2436 gnus-tmp-expirable gnus-tmp-subject-or-nil
2437 &optional gnus-tmp-dummy gnus-tmp-score
2439 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2440 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2441 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2442 (gnus-tmp-score-char
2443 (if (or (null gnus-summary-default-score)
2444 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2445 gnus-summary-zcore-fuzz))
2447 (if (< gnus-tmp-score gnus-summary-default-score)
2448 gnus-score-below-mark gnus-score-over-mark)))
2450 (cond (gnus-tmp-process gnus-process-mark)
2451 ((memq gnus-tmp-current gnus-newsgroup-cached)
2453 (gnus-tmp-replied gnus-replied-mark)
2454 ((memq gnus-tmp-current gnus-newsgroup-saved)
2456 (t gnus-unread-mark)))
2457 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2460 ((string-match "<[^>]+> *$" gnus-tmp-from)
2461 (let ((beg (match-beginning 0)))
2462 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2463 (substring gnus-tmp-from (1+ (match-beginning 0))
2464 (1- (match-end 0))))
2465 (substring gnus-tmp-from 0 beg))))
2466 ((string-match "(.+)" gnus-tmp-from)
2467 (substring gnus-tmp-from
2468 (1+ (match-beginning 0)) (1- (match-end 0))))
2470 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2471 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2472 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2473 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2474 (buffer-read-only nil))
2475 (when (string= gnus-tmp-name "")
2476 (setq gnus-tmp-name gnus-tmp-from))
2477 (unless (numberp gnus-tmp-lines)
2478 (setq gnus-tmp-lines 0))
2479 (gnus-put-text-property
2481 (progn (eval gnus-summary-line-format-spec) (point))
2482 'gnus-number gnus-tmp-number)
2483 (when (gnus-visual-p 'summary-highlight 'highlight)
2485 (run-hooks 'gnus-summary-update-hook)
2488 (defun gnus-summary-update-line (&optional dont-update)
2489 ;; Update summary line after change.
2490 (when (and gnus-summary-default-score
2491 (not gnus-summary-inhibit-highlight))
2492 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2493 (article (gnus-summary-article-number))
2494 (score (gnus-summary-article-score article)))
2496 (if (and gnus-summary-mark-below
2497 (< (gnus-summary-article-score)
2498 gnus-summary-mark-below))
2499 ;; This article has a low score, so we mark it as read.
2500 (when (memq article gnus-newsgroup-unreads)
2501 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2502 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2503 ;; This article was previously marked as read on account
2504 ;; of a low score, but now it has risen, so we mark it as
2506 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2507 (gnus-summary-update-mark
2508 (if (or (null gnus-summary-default-score)
2509 (<= (abs (- score gnus-summary-default-score))
2510 gnus-summary-zcore-fuzz))
2512 (if (< score gnus-summary-default-score)
2513 gnus-score-below-mark gnus-score-over-mark))
2515 ;; Do visual highlighting.
2516 (when (gnus-visual-p 'summary-highlight 'highlight)
2517 (run-hooks 'gnus-summary-update-hook)))))
2519 (defvar gnus-tmp-new-adopts nil)
2521 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2522 "Return the number of articles in THREAD.
2523 This may be 0 in some cases -- if none of the articles in
2524 the thread are to be displayed."
2526 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2528 ((not (listp thread))
2530 ((and (consp thread) (cdr thread))
2533 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2536 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2539 (when (and level (zerop level) gnus-tmp-new-adopts)
2542 'gnus-summary-number-of-articles-in-thread
2543 gnus-tmp-new-adopts))))
2545 (if (> number 1) gnus-not-empty-thread-mark
2546 gnus-empty-thread-mark)
2549 (defun gnus-summary-set-local-parameters (group)
2550 "Go through the local params of GROUP and set all variable specs in that list."
2551 (let ((params (gnus-group-find-parameter group))
2554 (setq elem (car params)
2555 params (cdr params))
2556 (and (consp elem) ; Has to be a cons.
2557 (consp (cdr elem)) ; The cdr has to be a list.
2558 (symbolp (car elem)) ; Has to be a symbol in there.
2559 (not (memq (car elem)
2560 '(quit-config to-address to-list to-group)))
2561 (ignore-errors ; So we set it.
2562 (make-local-variable (car elem))
2563 (set (car elem) (eval (nth 1 elem))))))))
2565 (defun gnus-summary-read-group (group &optional show-all no-article
2566 kill-buffer no-display)
2567 "Start reading news in newsgroup GROUP.
2568 If SHOW-ALL is non-nil, already read articles are also listed.
2569 If NO-ARTICLE is non-nil, no article is selected initially.
2570 If NO-DISPLAY, don't generate a summary buffer."
2574 (let ((gnus-auto-select-next nil))
2575 (or (gnus-summary-read-group-1
2576 group show-all no-article
2577 kill-buffer no-display)
2578 (setq show-all nil)))))
2579 (eq gnus-auto-select-next 'quietly))
2580 (set-buffer gnus-group-buffer)
2581 (if (not (equal group (gnus-group-group-name)))
2582 (setq group (gnus-group-group-name))
2586 (defun gnus-summary-read-group-1 (group show-all no-article
2587 kill-buffer no-display)
2588 ;; Killed foreign groups can't be entered.
2589 (when (and (not (gnus-group-native-p group))
2590 (not (gnus-gethash group gnus-newsrc-hashtb)))
2591 (error "Dead non-native groups can't be entered"))
2592 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2593 (let* ((new-group (gnus-summary-setup-buffer group))
2594 (quit-config (gnus-group-quit-config group))
2595 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2597 ;; This summary buffer exists already, so we just select it.
2599 (gnus-set-global-variables)
2601 (gnus-kill-or-deaden-summary kill-buffer))
2602 (gnus-configure-windows 'summary 'force)
2603 (gnus-set-mode-line 'summary)
2604 (gnus-summary-position-point)
2607 ;; We couldn't select this group.
2609 (when (and (eq major-mode 'gnus-summary-mode)
2610 (not (equal (current-buffer) kill-buffer)))
2611 (kill-buffer (current-buffer))
2612 (if (not quit-config)
2614 ;; Update the info -- marks might need to be removed,
2616 (gnus-summary-update-info)
2617 (set-buffer gnus-group-buffer)
2618 (gnus-group-jump-to-group group)
2619 (gnus-group-next-unread-group 1))
2620 (gnus-handle-ephemeral-exit quit-config)))
2621 (gnus-message 3 "Can't select group")
2623 ;; The user did a `C-g' while prompting for number of articles,
2624 ;; so we exit this group.
2625 ((eq did-select 'quit)
2626 (and (eq major-mode 'gnus-summary-mode)
2627 (not (equal (current-buffer) kill-buffer))
2628 (kill-buffer (current-buffer)))
2630 (gnus-kill-or-deaden-summary kill-buffer))
2631 (if (not quit-config)
2633 (set-buffer gnus-group-buffer)
2634 (gnus-group-jump-to-group group)
2635 (gnus-group-next-unread-group 1)
2636 (gnus-configure-windows 'group 'force))
2637 (gnus-handle-ephemeral-exit quit-config))
2638 ;; Finally signal the quit.
2640 ;; The group was successfully selected.
2642 (gnus-set-global-variables)
2643 ;; Save the active value in effect when the group was entered.
2644 (setq gnus-newsgroup-active
2646 (gnus-active gnus-newsgroup-name)))
2647 ;; You can change the summary buffer in some way with this hook.
2648 (run-hooks 'gnus-select-group-hook)
2649 ;; Set any local variables in the group parameters.
2650 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2651 (gnus-update-format-specifications
2652 nil 'summary 'summary-mode 'summary-dummy)
2653 ;; Do score processing.
2654 (when gnus-use-scoring
2655 (gnus-possibly-score-headers))
2656 ;; Check whether to fill in the gaps in the threads.
2657 (when gnus-build-sparse-threads
2658 (gnus-build-sparse-threads))
2659 ;; Find the initial limit.
2660 (if gnus-show-threads
2662 (let ((gnus-newsgroup-dormant nil))
2663 (gnus-summary-initial-limit show-all))
2664 (gnus-summary-initial-limit show-all))
2665 (setq gnus-newsgroup-limit
2667 (lambda (header) (mail-header-number header))
2668 gnus-newsgroup-headers)))
2669 ;; Generate the summary buffer.
2671 (gnus-summary-prepare))
2672 (when gnus-use-trees
2673 (gnus-tree-open group)
2674 (setq gnus-summary-highlight-line-function
2675 'gnus-tree-highlight-article))
2676 ;; If the summary buffer is empty, but there are some low-scored
2677 ;; articles or some excluded dormants, we include these in the
2679 (when (and (zerop (buffer-size))
2681 (cond (gnus-newsgroup-dormant
2682 (gnus-summary-limit-include-dormant))
2683 ((and gnus-newsgroup-scored show-all)
2684 (gnus-summary-limit-include-expunged t))))
2685 ;; Function `gnus-apply-kill-file' must be called in this hook.
2686 (run-hooks 'gnus-apply-kill-hook)
2687 (if (and (zerop (buffer-size))
2690 ;; This newsgroup is empty.
2691 (gnus-summary-catchup-and-exit nil t)
2692 (gnus-message 6 "No unread news")
2694 (gnus-kill-or-deaden-summary kill-buffer))
2695 ;; Return nil from this function.
2697 ;; Hide conversation thread subtrees. We cannot do this in
2698 ;; gnus-summary-prepare-hook since kill processing may not
2699 ;; work with hidden articles.
2700 (and gnus-show-threads
2701 gnus-thread-hide-subtree
2702 (gnus-summary-hide-all-threads))
2704 (gnus-kill-or-deaden-summary kill-buffer))
2705 ;; Show first unread article if requested.
2706 (if (and (not no-article)
2708 gnus-newsgroup-unreads
2709 gnus-auto-select-first)
2710 (unless (if (eq gnus-auto-select-first 'best)
2711 (gnus-summary-best-unread-article)
2712 (gnus-summary-first-unread-article))
2713 (gnus-configure-windows 'summary))
2714 ;; Don't select any articles, just move point to the first
2715 ;; article in the group.
2716 (goto-char (point-min))
2717 (gnus-summary-position-point)
2718 (gnus-set-mode-line 'summary)
2719 (gnus-configure-windows 'summary 'force))
2720 (when (get-buffer-window gnus-group-buffer t)
2721 ;; Gotta use windows, because recenter does weird stuff if
2722 ;; the current buffer ain't the displayed window.
2723 (let ((owin (selected-window)))
2724 (select-window (get-buffer-window gnus-group-buffer t))
2725 (when (gnus-group-goto-group group)
2727 (select-window owin)))
2728 ;; Mark this buffer as "prepared".
2729 (setq gnus-newsgroup-prepared t)
2732 (defun gnus-summary-prepare ()
2733 "Generate the summary buffer."
2735 (let ((buffer-read-only nil))
2737 (setq gnus-newsgroup-data nil
2738 gnus-newsgroup-data-reverse nil)
2739 (run-hooks 'gnus-summary-generate-hook)
2740 ;; Generate the buffer, either with threads or without.
2741 (when gnus-newsgroup-headers
2742 (gnus-summary-prepare-threads
2743 (if gnus-show-threads
2744 (gnus-sort-gathered-threads
2745 (funcall gnus-summary-thread-gathering-function
2747 (gnus-cut-threads (gnus-make-threads)))))
2748 ;; Unthreaded display.
2749 (gnus-sort-articles gnus-newsgroup-headers))))
2750 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2751 ;; Call hooks for modifying summary buffer.
2752 (goto-char (point-min))
2753 (run-hooks 'gnus-summary-prepare-hook)))
2755 (defsubst gnus-general-simplify-subject (subject)
2756 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2759 ;; Truncate the subject.
2760 (gnus-simplify-subject-functions
2761 (gnus-map-function gnus-simplify-subject-functions subject))
2762 ((numberp gnus-summary-gather-subject-limit)
2763 (setq subject (gnus-simplify-subject-re subject))
2764 (if (> (length subject) gnus-summary-gather-subject-limit)
2765 (substring subject 0 gnus-summary-gather-subject-limit)
2767 ;; Fuzzily simplify it.
2768 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2769 (gnus-simplify-subject-fuzzy subject))
2770 ;; Just remove the leading "Re:".
2772 (gnus-simplify-subject-re subject))))
2774 (if (and gnus-summary-gather-exclude-subject
2775 (string-match gnus-summary-gather-exclude-subject subject))
2776 nil ; This article shouldn't be gathered
2779 (defun gnus-summary-simplify-subject-query ()
2780 "Query where the respool algorithm would put this article."
2782 (gnus-summary-select-article)
2783 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2785 (defun gnus-gather-threads-by-subject (threads)
2786 "Gather threads by looking at Subject headers."
2787 (if (not gnus-summary-make-false-root)
2789 (let ((hashtb (gnus-make-hashtable 1024))
2792 subject hthread whole-subject)
2794 (setq subject (gnus-general-simplify-subject
2795 (setq whole-subject (mail-header-subject
2798 (if (setq hthread (gnus-gethash subject hashtb))
2800 ;; We enter a dummy root into the thread, if we
2801 ;; haven't done that already.
2802 (unless (stringp (caar hthread))
2803 (setcar hthread (list whole-subject (car hthread))))
2804 ;; We add this new gathered thread to this gathered
2806 (setcdr (car hthread)
2807 (nconc (cdar hthread) (list (car threads))))
2808 ;; Remove it from the list of threads.
2809 (setcdr prev (cdr threads))
2810 (setq threads prev))
2811 ;; Enter this thread into the hash table.
2812 (gnus-sethash subject threads hashtb)))
2814 (setq threads (cdr threads)))
2817 (defun gnus-gather-threads-by-references (threads)
2818 "Gather threads by looking at References headers."
2819 (let ((idhashtb (gnus-make-hashtable 1024))
2820 (thhashtb (gnus-make-hashtable 1024))
2823 ids references id gthread gid entered ref)
2825 (when (setq references (mail-header-references (caar threads)))
2826 (setq id (mail-header-id (caar threads))
2827 ids (gnus-split-references references)
2829 (while (setq ref (pop ids))
2830 (setq ids (delete ref ids))
2831 (if (not (setq gid (gnus-gethash ref idhashtb)))
2833 (gnus-sethash ref id idhashtb)
2834 (gnus-sethash id threads thhashtb))
2835 (setq gthread (gnus-gethash gid thhashtb))
2837 ;; We enter a dummy root into the thread, if we
2838 ;; haven't done that already.
2839 (unless (stringp (caar gthread))
2840 (setcar gthread (list (mail-header-subject (caar gthread))
2842 ;; We add this new gathered thread to this gathered
2844 (setcdr (car gthread)
2845 (nconc (cdar gthread) (list (car threads)))))
2846 ;; Add it into the thread hash table.
2847 (gnus-sethash id gthread thhashtb)
2849 ;; Remove it from the list of threads.
2850 (setcdr prev (cdr threads))
2851 (setq threads prev))))
2853 (setq threads (cdr threads)))
2856 (defun gnus-sort-gathered-threads (threads)
2857 "Sort subtreads inside each gathered thread by article number."
2858 (let ((result threads))
2860 (when (stringp (caar threads))
2861 (setcdr (car threads)
2862 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2863 (setq threads (cdr threads)))
2866 (defun gnus-thread-loop-p (root thread)
2867 "Say whether ROOT is in THREAD."
2868 (let ((stack (list thread))
2871 (while (setq thread (pop stack))
2872 (setq th (cdr thread))
2874 (not (eq (caar th) root)))
2877 ;; We have found a loop.
2879 (setcdr thread (delq (car th) (cdr thread)))
2880 (if (boundp (setq ref-dep (intern "none"
2881 gnus-newsgroup-dependencies)))
2882 (setcdr (symbol-value ref-dep)
2883 (nconc (cdr (symbol-value ref-dep))
2885 (set ref-dep (list nil (car th))))
2888 ;; Push all the subthreads onto the stack.
2889 (push (cdr thread) stack)))
2892 (defun gnus-make-threads ()
2893 "Go through the dependency hashtb and find the roots. Return all threads."
2895 (while (catch 'infloop
2898 ;; Deal with self-referencing References loops.
2899 (when (and (car (symbol-value refs))
2906 (car (symbol-value refs)) thread))
2907 (cdr (symbol-value refs)))))))
2910 (unless (car (symbol-value refs))
2911 ;; These threads do not refer back to any other articles,
2912 ;; so they're roots.
2913 (setq threads (append (cdr (symbol-value refs)) threads))))
2914 gnus-newsgroup-dependencies)))
2917 (defun gnus-build-sparse-threads ()
2918 (let ((headers gnus-newsgroup-headers)
2919 (deps gnus-newsgroup-dependencies)
2920 header references generation relations
2921 cthread subject child end pthread relation new-child)
2922 ;; First we create an alist of generations/relations, where
2923 ;; generations is how much we trust the relation, and the relation
2925 (gnus-message 7 "Making sparse threads...")
2927 (nnheader-set-temp-buffer " *gnus sparse threads*")
2928 (while (setq header (pop headers))
2929 (when (and (setq references (mail-header-references header))
2930 (not (string= references "")))
2932 (setq child (mail-header-id header)
2933 subject (mail-header-subject header))
2935 (while (search-backward ">" nil t)
2936 (setq end (1+ (point)))
2937 (when (search-backward "<" nil t)
2938 (unless (string= (setq new-child (buffer-substring (point) end))
2940 (push (list (incf generation)
2941 child (setq child new-child)
2944 (push (list (1+ generation) child nil subject) relations)
2946 (kill-buffer (current-buffer)))
2947 ;; Sort over trustworthiness.
2948 (setq relations (sort relations 'car-less-than-car))
2949 (while (setq relation (pop relations))
2950 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2951 (unless (car (symbol-value cthread))
2952 ;; Make this article the parent of these threads.
2953 (setcar (symbol-value cthread)
2954 (vector gnus-reffed-article-number
2958 (or (caddr relation) "") 0 0 "")))
2959 (set cthread (list (vector gnus-reffed-article-number
2961 "" "" (cadr relation)
2962 (or (caddr relation) "") 0 0 ""))))
2963 (push gnus-reffed-article-number gnus-newsgroup-limit)
2964 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2965 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2966 gnus-newsgroup-reads)
2967 (decf gnus-reffed-article-number)
2968 ;; Make this new thread the child of its parent.
2969 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2970 (setcdr (symbol-value pthread)
2971 (nconc (cdr (symbol-value pthread))
2972 (list (symbol-value cthread))))
2973 (set pthread (list nil (symbol-value cthread))))))
2974 (gnus-message 7 "Making sparse threads...done")))
2976 (defun gnus-build-old-threads ()
2977 ;; Look at all the articles that refer back to old articles, and
2978 ;; fetch the headers for the articles that aren't there. This will
2979 ;; build complete threads - if the roots haven't been expired by the
2984 (when (not (car (symbol-value refs)))
2985 (setq heads (cdr (symbol-value refs)))
2987 (if (memq (mail-header-number (caar heads))
2988 gnus-newsgroup-dormant)
2989 (setq heads (cdr heads))
2990 (setq id (symbol-name refs))
2991 (while (and (setq id (gnus-build-get-header id))
2992 (not (car (gnus-gethash
2993 id gnus-newsgroup-dependencies)))))
2994 (setq heads nil)))))
2995 gnus-newsgroup-dependencies)))
2997 (defun gnus-build-get-header (id)
2998 ;; Look through the buffer of NOV lines and find the header to
2999 ;; ID. Enter this line into the dependencies hash table, and return
3000 ;; the id of the parent article (if any).
3001 (let ((deps gnus-newsgroup-dependencies)
3005 (set-buffer nntp-server-buffer)
3006 (let ((case-fold-search nil))
3007 (goto-char (point-min))
3008 (while (and (not found)
3009 (search-forward id nil t))
3011 (setq found (looking-at
3012 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3013 (regexp-quote id))))
3014 (or found (beginning-of-line 2)))
3018 (setq header (gnus-nov-parse-line
3019 (read (current-buffer)) deps))
3020 (gnus-parent-id (mail-header-references header))))))
3022 (let ((number (mail-header-number header)))
3023 (push number gnus-newsgroup-limit)
3024 (push header gnus-newsgroup-headers)
3025 (if (memq number gnus-newsgroup-unselected)
3027 (push number gnus-newsgroup-unreads)
3028 (setq gnus-newsgroup-unselected
3029 (delq number gnus-newsgroup-unselected)))
3030 (push number gnus-newsgroup-ancient)))))))
3032 (defun gnus-build-all-threads ()
3033 "Read all the headers."
3034 (let ((deps gnus-newsgroup-dependencies)
3035 (gnus-summary-ignore-duplicates t)
3036 found header article)
3038 (set-buffer nntp-server-buffer)
3039 (let ((case-fold-search nil))
3040 (goto-char (point-min))
3043 (setq article (read (current-buffer)))
3044 (setq header (gnus-nov-parse-line article deps)))
3046 (push header gnus-newsgroup-headers)
3047 (if (memq (setq article (mail-header-number header))
3048 gnus-newsgroup-unselected)
3050 (push article gnus-newsgroup-unreads)
3051 (setq gnus-newsgroup-unselected
3052 (delq article gnus-newsgroup-unselected)))
3053 (push article gnus-newsgroup-ancient))
3054 (forward-line 1)))))))
3056 (defun gnus-summary-update-article-line (article header)
3057 "Update the line for ARTICLE using HEADERS."
3058 (let* ((id (mail-header-id header))
3059 (thread (gnus-id-to-thread id)))
3061 (error "Article in no thread"))
3062 ;; Update the thread.
3063 (setcar thread header)
3064 (gnus-summary-goto-subject article)
3065 (let* ((datal (gnus-data-find-list article))
3067 (length (when (cdr datal)
3068 (- (gnus-data-pos data)
3069 (gnus-data-pos (cadr datal)))))
3070 (buffer-read-only nil)
3071 (level (gnus-summary-thread-level)))
3073 (gnus-summary-insert-line
3074 header level nil (gnus-article-mark article)
3075 (memq article gnus-newsgroup-replied)
3076 (memq article gnus-newsgroup-expirable)
3077 ;; Only insert the Subject string when it's different
3078 ;; from the previous Subject string.
3079 (if (gnus-subject-equal
3081 (mail-header-subject
3084 (gnus-data-find-list
3086 (gnus-data-list t)))))
3087 ;; Error on the side of excessive subjects.
3089 (mail-header-subject header))
3091 (mail-header-subject header))
3092 nil (cdr (assq article gnus-newsgroup-scored))
3093 (memq article gnus-newsgroup-processable))
3095 (gnus-data-update-list
3096 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3098 (defun gnus-summary-update-article (article &optional iheader)
3099 "Update ARTICLE in the summary buffer."
3100 (set-buffer gnus-summary-buffer)
3101 (let* ((header (or iheader (gnus-summary-article-header article)))
3102 (id (mail-header-id header))
3103 (data (gnus-data-find article))
3104 (thread (gnus-id-to-thread id))
3105 (references (mail-header-references header))
3109 (when (and references
3110 (not (equal "" references)))
3113 (buffer-read-only nil)
3115 (number (mail-header-number header))
3118 ;; !!! Should this be in or not?
3120 (setcar thread nil))
3122 (delq thread parent))
3123 (if (gnus-summary-insert-subject id header iheader)
3124 ;; Set the (possibly) new article number in the data structure.
3125 (gnus-data-set-number data (gnus-id-to-article id))
3129 (defun gnus-rebuild-thread (id)
3130 "Rebuild the thread containing ID."
3131 (let ((buffer-read-only nil)
3132 old-pos current thread data)
3133 (if (not gnus-show-threads)
3134 (setq thread (list (car (gnus-id-to-thread id))))
3135 ;; Get the thread this article is part of.
3136 (setq thread (gnus-remove-thread id)))
3137 (setq old-pos (gnus-point-at-bol))
3138 (setq current (save-excursion
3139 (and (zerop (forward-line -1))
3140 (gnus-summary-article-number))))
3141 ;; If this is a gathered thread, we have to go some re-gathering.
3142 (when (stringp (car thread))
3143 (let ((subject (car thread))
3145 (setq thread (cdr thread))
3147 (unless (memq (setq thr (gnus-id-to-thread
3149 (mail-header-id (caar thread)))))
3152 (setq thread (cdr thread)))
3153 ;; We now have all (unique) roots.
3154 (if (= (length roots) 1)
3155 ;; All the loose roots are now one solid root.
3156 (setq thread (car roots))
3157 (setq thread (cons subject (gnus-sort-threads roots))))))
3159 ;; We then insert this thread into the summary buffer.
3160 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3161 (if gnus-show-threads
3162 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3163 (gnus-summary-prepare-unthreaded thread))
3164 (setq data (nreverse gnus-newsgroup-data))
3165 (setq threads gnus-newsgroup-threads))
3166 ;; We splice the new data into the data structure.
3167 (gnus-data-enter-list current data (- (point) old-pos))
3168 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3170 (defun gnus-number-to-header (number)
3171 "Return the header for article NUMBER."
3172 (let ((headers gnus-newsgroup-headers))
3174 (not (= number (mail-header-number (car headers)))))
3179 (defun gnus-parent-headers (headers &optional generation)
3180 "Return the headers of the GENERATIONeth parent of HEADERS."
3182 (setq generation 1))
3185 (while (and parent headers (not (zerop generation)))
3186 (setq references (mail-header-references headers))
3187 (when (and references
3188 (setq parent (gnus-parent-id references))
3189 (setq headers (car (gnus-id-to-thread parent))))
3193 (defun gnus-id-to-thread (id)
3194 "Return the (sub-)thread where ID appears."
3195 (gnus-gethash id gnus-newsgroup-dependencies))
3197 (defun gnus-id-to-article (id)
3198 "Return the article number of ID."
3199 (let ((thread (gnus-id-to-thread id)))
3202 (mail-header-number (car thread)))))
3204 (defun gnus-id-to-header (id)
3205 "Return the article headers of ID."
3206 (car (gnus-id-to-thread id)))
3208 (defun gnus-article-displayed-root-p (article)
3209 "Say whether ARTICLE is a root(ish) article."
3210 (let ((level (gnus-summary-thread-level article))
3211 (refs (mail-header-references (gnus-summary-article-header article)))
3217 ((null (gnus-parent-id refs)) t)
3219 (null (setq particle (gnus-id-to-article
3220 (gnus-parent-id refs))))
3221 (null (gnus-summary-thread-level particle)))))))
3223 (defun gnus-root-id (id)
3224 "Return the id of the root of the thread where ID appears."
3226 (while (and id (setq prev (car (gnus-gethash
3227 id gnus-newsgroup-dependencies))))
3229 id (gnus-parent-id (mail-header-references prev))))
3232 (defun gnus-articles-in-thread (thread)
3233 "Return the list of articles in THREAD."
3234 (cons (mail-header-number (car thread))
3235 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3237 (defun gnus-remove-thread (id &optional dont-remove)
3238 "Remove the thread that has ID in it."
3239 (let ((dep gnus-newsgroup-dependencies)
3240 headers thread last-id)
3241 ;; First go up in this thread until we find the root.
3242 (setq last-id (gnus-root-id id))
3243 (setq headers (list (car (gnus-id-to-thread last-id))
3244 (caadr (gnus-id-to-thread last-id))))
3245 ;; We have now found the real root of this thread. It might have
3246 ;; been gathered into some loose thread, so we have to search
3247 ;; through the threads to find the thread we wanted.
3248 (let ((threads gnus-newsgroup-threads)
3251 (setq sub (car threads))
3252 (if (stringp (car sub))
3253 ;; This is a gathered thread, so we look at the roots
3254 ;; below it to find whether this article is in this
3257 (setq sub (cdr sub))
3259 (when (member (caar sub) headers)
3260 (setq thread (car threads)
3263 (setq sub (cdr sub))))
3264 ;; It's an ordinary thread, so we check it.
3265 (when (eq (car sub) (car headers))
3268 (setq threads (cdr threads)))
3269 ;; If this article is in no thread, then it's a root.
3272 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3273 (setq thread (gnus-gethash last-id dep)))
3276 thread ; We return this thread.
3278 (if (stringp (car thread))
3280 ;; If we use dummy roots, then we have to remove the
3281 ;; dummy root as well.
3282 (when (eq gnus-summary-make-false-root 'dummy)
3284 (gnus-data-compute-positions))
3285 (setq thread (cdr thread))
3287 (gnus-remove-thread-1 (car thread))
3288 (setq thread (cdr thread))))
3289 (gnus-remove-thread-1 thread))))))))
3291 (defun gnus-remove-thread-1 (thread)
3292 "Remove the thread THREAD recursively."
3293 (let ((number (mail-header-number (pop thread)))
3295 (setq thread (reverse thread))
3297 (gnus-remove-thread-1 (pop thread)))
3298 (when (setq d (gnus-data-find number))
3299 (goto-char (gnus-data-pos d))
3302 (- (gnus-point-at-bol)
3304 (1+ (gnus-point-at-eol))
3305 (gnus-delete-line)))))))
3307 (defun gnus-sort-threads (threads)
3309 (if (not gnus-thread-sort-functions)
3311 (gnus-message 7 "Sorting threads...")
3313 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3314 (gnus-message 7 "Sorting threads...done"))))
3316 (defun gnus-sort-articles (articles)
3318 (when gnus-article-sort-functions
3319 (gnus-message 7 "Sorting articles...")
3321 (setq gnus-newsgroup-headers
3322 (sort articles (gnus-make-sort-function
3323 gnus-article-sort-functions)))
3324 (gnus-message 7 "Sorting articles...done"))))
3326 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3327 (defmacro gnus-thread-header (thread)
3328 ;; Return header of first article in THREAD.
3329 ;; Note that THREAD must never, ever be anything else than a variable -
3330 ;; using some other form will lead to serious barfage.
3331 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3332 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3333 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3336 (defsubst gnus-article-sort-by-number (h1 h2)
3337 "Sort articles by article number."
3338 (< (mail-header-number h1)
3339 (mail-header-number h2)))
3341 (defun gnus-thread-sort-by-number (h1 h2)
3342 "Sort threads by root article number."
3343 (gnus-article-sort-by-number
3344 (gnus-thread-header h1) (gnus-thread-header h2)))
3346 (defsubst gnus-article-sort-by-lines (h1 h2)
3347 "Sort articles by article Lines header."
3348 (< (mail-header-lines h1)
3349 (mail-header-lines h2)))
3351 (defun gnus-thread-sort-by-lines (h1 h2)
3352 "Sort threads by root article Lines header."
3353 (gnus-article-sort-by-lines
3354 (gnus-thread-header h1) (gnus-thread-header h2)))
3356 (defsubst gnus-article-sort-by-author (h1 h2)
3357 "Sort articles by root author."
3359 (let ((extract (funcall
3360 gnus-extract-address-components
3361 (mail-header-from h1))))
3362 (or (car extract) (cadr extract) ""))
3363 (let ((extract (funcall
3364 gnus-extract-address-components
3365 (mail-header-from h2))))
3366 (or (car extract) (cadr extract) ""))))
3368 (defun gnus-thread-sort-by-author (h1 h2)
3369 "Sort threads by root author."
3370 (gnus-article-sort-by-author
3371 (gnus-thread-header h1) (gnus-thread-header h2)))
3373 (defsubst gnus-article-sort-by-subject (h1 h2)
3374 "Sort articles by root subject."
3376 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3377 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3379 (defun gnus-thread-sort-by-subject (h1 h2)
3380 "Sort threads by root subject."
3381 (gnus-article-sort-by-subject
3382 (gnus-thread-header h1) (gnus-thread-header h2)))
3384 (defsubst gnus-article-sort-by-date (h1 h2)
3385 "Sort articles by root article date."
3387 (gnus-date-get-time (mail-header-date h1))
3388 (gnus-date-get-time (mail-header-date h2))))
3390 (defun gnus-thread-sort-by-date (h1 h2)
3391 "Sort threads by root article date."
3392 (gnus-article-sort-by-date
3393 (gnus-thread-header h1) (gnus-thread-header h2)))
3395 (defsubst gnus-article-sort-by-score (h1 h2)
3396 "Sort articles by root article score.
3397 Unscored articles will be counted as having a score of zero."
3398 (> (or (cdr (assq (mail-header-number h1)
3399 gnus-newsgroup-scored))
3400 gnus-summary-default-score 0)
3401 (or (cdr (assq (mail-header-number h2)
3402 gnus-newsgroup-scored))
3403 gnus-summary-default-score 0)))
3405 (defun gnus-thread-sort-by-score (h1 h2)
3406 "Sort threads by root article score."
3407 (gnus-article-sort-by-score
3408 (gnus-thread-header h1) (gnus-thread-header h2)))
3410 (defun gnus-thread-sort-by-total-score (h1 h2)
3411 "Sort threads by the sum of all scores in the thread.
3412 Unscored articles will be counted as having a score of zero."
3413 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3415 (defun gnus-thread-total-score (thread)
3416 ;; This function find the total score of THREAD.
3417 (cond ((null thread)
3420 (if (stringp (car thread))
3421 (apply gnus-thread-score-function 0
3422 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3423 (gnus-thread-total-score-1 thread)))
3425 (gnus-thread-total-score-1 (list thread)))))
3427 (defun gnus-thread-total-score-1 (root)
3428 ;; This function find the total score of the thread below ROOT.
3429 (setq root (car root))
3430 (apply gnus-thread-score-function
3432 (mapcar 'gnus-thread-total-score
3433 (cdr (gnus-gethash (mail-header-id root)
3434 gnus-newsgroup-dependencies)))
3435 (when (> (mail-header-number root) 0)
3436 (list (or (cdr (assq (mail-header-number root)
3437 gnus-newsgroup-scored))
3438 gnus-summary-default-score 0))))
3439 (list gnus-summary-default-score)
3442 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3443 (defvar gnus-tmp-prev-subject nil)
3444 (defvar gnus-tmp-false-parent nil)
3445 (defvar gnus-tmp-root-expunged nil)
3446 (defvar gnus-tmp-dummy-line nil)
3448 (defun gnus-summary-prepare-threads (threads)
3449 "Prepare summary buffer from THREADS and indentation LEVEL.
3450 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3451 or a straight list of headers."
3452 (gnus-message 7 "Generating summary...")
3454 (setq gnus-newsgroup-threads threads)
3457 (let ((gnus-tmp-level 0)
3458 (default-score (or gnus-summary-default-score 0))
3459 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3460 thread number subject stack state gnus-tmp-gathered beg-match
3461 new-roots gnus-tmp-new-adopts thread-end
3462 gnus-tmp-header gnus-tmp-unread
3463 gnus-tmp-replied gnus-tmp-subject-or-nil
3464 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3465 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3466 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3468 (setq gnus-tmp-prev-subject nil)
3470 (if (vectorp (car threads))
3471 ;; If this is a straight (sic) list of headers, then a
3472 ;; threaded summary display isn't required, so we just create
3473 ;; an unthreaded one.
3474 (gnus-summary-prepare-unthreaded threads)
3476 ;; Do the threaded display.
3478 (while (or threads stack gnus-tmp-new-adopts new-roots)
3480 (if (and (= gnus-tmp-level 0)
3481 (not (setq gnus-tmp-dummy-line nil))
3484 (not gnus-tmp-false-parent)
3485 (or gnus-tmp-new-adopts new-roots))
3486 (if gnus-tmp-new-adopts
3487 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3488 thread (list (car gnus-tmp-new-adopts))
3489 gnus-tmp-header (caar thread)
3490 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3492 (setq thread (list (car new-roots))
3493 gnus-tmp-header (caar thread)
3494 new-roots (cdr new-roots))))
3497 ;; If there are some threads, we do them before the
3498 ;; threads on the stack.
3499 (setq thread threads
3500 gnus-tmp-header (caar thread))
3501 ;; There were no current threads, so we pop something off
3503 (setq state (car stack)
3504 gnus-tmp-level (car state)
3507 gnus-tmp-header (caar thread))))
3509 (setq gnus-tmp-false-parent nil)
3510 (setq gnus-tmp-root-expunged nil)
3511 (setq thread-end nil)
3513 (if (stringp gnus-tmp-header)
3514 ;; The header is a dummy root.
3516 ((eq gnus-summary-make-false-root 'adopt)
3517 ;; We let the first article adopt the rest.
3518 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3520 (setq gnus-tmp-gathered
3522 (lambda (h) (mail-header-number (car h)))
3525 (setq thread (cons (list (caar thread)
3528 (setq gnus-tmp-level -1
3529 gnus-tmp-false-parent t))
3530 ((eq gnus-summary-make-false-root 'empty)
3531 ;; We print adopted articles with empty subject fields.
3532 (setq gnus-tmp-gathered
3534 (lambda (h) (mail-header-number (car h)))
3537 (setq gnus-tmp-level -1))
3538 ((eq gnus-summary-make-false-root 'dummy)
3539 ;; We remember that we probably want to output a dummy
3541 (setq gnus-tmp-dummy-line gnus-tmp-header)
3542 (setq gnus-tmp-prev-subject gnus-tmp-header))
3544 ;; We do not make a root for the gathered
3545 ;; sub-threads at all.
3546 (setq gnus-tmp-level -1)))
3548 (setq number (mail-header-number gnus-tmp-header)
3549 subject (mail-header-subject gnus-tmp-header))
3552 ;; If the thread has changed subject, we might want to make
3553 ;; this subthread into a root.
3554 ((and (null gnus-thread-ignore-subject)
3555 (not (zerop gnus-tmp-level))
3556 gnus-tmp-prev-subject
3558 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3559 (setq new-roots (nconc new-roots (list (car thread)))
3561 gnus-tmp-header nil))
3562 ;; If the article lies outside the current limit,
3563 ;; then we do not display it.
3564 ((not (memq number gnus-newsgroup-limit))
3565 (setq gnus-tmp-gathered
3567 (lambda (h) (mail-header-number (car h)))
3570 (setq gnus-tmp-new-adopts (if (cdar thread)
3571 (append gnus-tmp-new-adopts
3573 gnus-tmp-new-adopts)
3575 gnus-tmp-header nil)
3576 (when (zerop gnus-tmp-level)
3577 (setq gnus-tmp-root-expunged t)))
3578 ;; Perhaps this article is to be marked as read?
3579 ((and gnus-summary-mark-below
3580 (< (or (cdr (assq number gnus-newsgroup-scored))
3582 gnus-summary-mark-below)
3583 ;; Don't touch sparse articles.
3584 (not (gnus-summary-article-sparse-p number))
3585 (not (gnus-summary-article-ancient-p number)))
3586 (setq gnus-newsgroup-unreads
3587 (delq number gnus-newsgroup-unreads))
3588 (if gnus-newsgroup-auto-expire
3589 (push number gnus-newsgroup-expirable)
3590 (push (cons number gnus-low-score-mark)
3591 gnus-newsgroup-reads))))
3593 (when gnus-tmp-header
3594 ;; We may have an old dummy line to output before this
3596 (when gnus-tmp-dummy-line
3597 (gnus-summary-insert-dummy-line
3598 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3599 (setq gnus-tmp-dummy-line nil))
3601 ;; Compute the mark.
3602 (setq gnus-tmp-unread (gnus-article-mark number))
3604 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3605 gnus-tmp-header gnus-tmp-level)
3606 gnus-newsgroup-data)
3608 ;; Actually insert the line.
3610 gnus-tmp-subject-or-nil
3612 ((and gnus-thread-ignore-subject
3613 gnus-tmp-prev-subject
3614 (not (inline (gnus-subject-equal
3615 gnus-tmp-prev-subject subject))))
3617 ((zerop gnus-tmp-level)
3618 (if (and (eq gnus-summary-make-false-root 'empty)
3619 (memq number gnus-tmp-gathered)
3620 gnus-tmp-prev-subject
3621 (inline (gnus-subject-equal
3622 gnus-tmp-prev-subject subject)))
3623 gnus-summary-same-subject
3625 (t gnus-summary-same-subject)))
3626 (if (and (eq gnus-summary-make-false-root 'adopt)
3627 (= gnus-tmp-level 1)
3628 (memq number gnus-tmp-gathered))
3629 (setq gnus-tmp-opening-bracket ?\<
3630 gnus-tmp-closing-bracket ?\>)
3631 (setq gnus-tmp-opening-bracket ?\[
3632 gnus-tmp-closing-bracket ?\]))
3634 gnus-tmp-indentation
3635 (aref gnus-thread-indent-array gnus-tmp-level)
3636 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3637 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3638 gnus-summary-default-score 0)
3640 (if (or (null gnus-summary-default-score)
3641 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3642 gnus-summary-zcore-fuzz))
3644 (if (< gnus-tmp-score gnus-summary-default-score)
3645 gnus-score-below-mark gnus-score-over-mark))
3647 (cond ((memq number gnus-newsgroup-processable)
3649 ((memq number gnus-newsgroup-cached)
3651 ((memq number gnus-newsgroup-replied)
3653 ((memq number gnus-newsgroup-saved)
3655 (t gnus-unread-mark))
3656 gnus-tmp-from (mail-header-from gnus-tmp-header)
3659 ((string-match "<[^>]+> *$" gnus-tmp-from)
3660 (setq beg-match (match-beginning 0))
3661 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3662 (substring gnus-tmp-from (1+ (match-beginning 0))
3663 (1- (match-end 0))))
3664 (substring gnus-tmp-from 0 beg-match)))
3665 ((string-match "(.+)" gnus-tmp-from)
3666 (substring gnus-tmp-from
3667 (1+ (match-beginning 0)) (1- (match-end 0))))
3669 (when (string= gnus-tmp-name "")
3670 (setq gnus-tmp-name gnus-tmp-from))
3671 (unless (numberp gnus-tmp-lines)
3672 (setq gnus-tmp-lines 0))
3673 (gnus-put-text-property
3675 (progn (eval gnus-summary-line-format-spec) (point))
3676 'gnus-number number)
3679 (run-hooks 'gnus-summary-update-hook)
3682 (setq gnus-tmp-prev-subject subject)))
3684 (when (nth 1 thread)
3685 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3686 (incf gnus-tmp-level)
3687 (setq threads (if thread-end nil (cdar thread)))
3689 (setq gnus-tmp-level 0)))))
3690 (gnus-message 7 "Generating summary...done"))
3692 (defun gnus-summary-prepare-unthreaded (headers)
3693 "Generate an unthreaded summary buffer based on HEADERS."
3694 (let (header number mark)
3699 ;; We may have to root out some bad articles...
3700 (when (memq (setq number (mail-header-number
3701 (setq header (pop headers))))
3702 gnus-newsgroup-limit)
3703 ;; Mark article as read when it has a low score.
3704 (when (and gnus-summary-mark-below
3705 (< (or (cdr (assq number gnus-newsgroup-scored))
3706 gnus-summary-default-score 0)
3707 gnus-summary-mark-below)
3708 (not (gnus-summary-article-ancient-p number)))
3709 (setq gnus-newsgroup-unreads
3710 (delq number gnus-newsgroup-unreads))
3711 (if gnus-newsgroup-auto-expire
3712 (push number gnus-newsgroup-expirable)
3713 (push (cons number gnus-low-score-mark)
3714 gnus-newsgroup-reads)))
3716 (setq mark (gnus-article-mark number))
3717 (push (gnus-data-make number mark (1+ (point)) header 0)
3718 gnus-newsgroup-data)
3719 (gnus-summary-insert-line
3721 mark (memq number gnus-newsgroup-replied)
3722 (memq number gnus-newsgroup-expirable)
3723 (mail-header-subject header) nil
3724 (cdr (assq number gnus-newsgroup-scored))
3725 (memq number gnus-newsgroup-processable))))))
3727 (defun gnus-select-newsgroup (group &optional read-all)
3728 "Select newsgroup GROUP.
3729 If READ-ALL is non-nil, all articles in the group are selected."
3730 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3731 ;;!!! Dirty hack; should be removed.
3732 (gnus-summary-ignore-duplicates
3733 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3735 gnus-summary-ignore-duplicates))
3736 (info (nth 2 entry))
3737 articles fetched-articles cached)
3739 (unless (gnus-check-server
3740 (setq gnus-current-select-method
3741 (gnus-find-method-for-group group)))
3742 (error "Couldn't open server"))
3744 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3745 (gnus-activate-group group) ; Or we can activate it...
3746 (progn ; Or we bug out.
3747 (when (equal major-mode 'gnus-summary-mode)
3748 (kill-buffer (current-buffer)))
3749 (error "Couldn't request group %s: %s"
3750 group (gnus-status-message group))))
3752 (unless (gnus-request-group group t)
3753 (when (equal major-mode 'gnus-summary-mode)
3754 (kill-buffer (current-buffer)))
3755 (error "Couldn't request group %s: %s"
3756 group (gnus-status-message group)))
3758 (setq gnus-newsgroup-name group)
3759 (setq gnus-newsgroup-unselected nil)
3760 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3762 ;; Adjust and set lists of article marks.
3764 (gnus-adjust-marked-articles info))
3766 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3767 (when (gnus-virtual-group-p group)
3768 (setq cached gnus-newsgroup-cached))
3770 (setq gnus-newsgroup-unreads
3771 (gnus-set-difference
3772 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3773 gnus-newsgroup-dormant))
3775 (setq gnus-newsgroup-processable nil)
3777 (gnus-update-read-articles group gnus-newsgroup-unreads)
3778 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3779 (gnus-group-update-group group))
3781 (setq articles (gnus-articles-to-read group read-all))
3785 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3787 ((eq articles 0) nil)
3789 ;; Init the dependencies hash table.
3790 (setq gnus-newsgroup-dependencies
3791 (gnus-make-hashtable (length articles)))
3792 ;; Retrieve the headers and read them in.
3793 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3794 (setq gnus-newsgroup-headers
3796 (setq gnus-headers-retrieved-by
3797 (gnus-retrieve-headers
3798 articles gnus-newsgroup-name
3799 ;; We might want to fetch old headers, but
3800 ;; not if there is only 1 article.
3801 (and gnus-fetch-old-headers
3803 (not (eq gnus-fetch-old-headers 'some))
3804 (not (numberp gnus-fetch-old-headers)))
3805 (> (length articles) 1))))))
3806 (gnus-get-newsgroup-headers-xover
3807 articles nil nil gnus-newsgroup-name t)
3808 (gnus-get-newsgroup-headers)))
3809 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3811 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3813 (setq gnus-newsgroup-cached cached))
3815 ;; Suppress duplicates?
3816 (when gnus-suppress-duplicates
3817 (gnus-dup-suppress-articles))
3819 ;; Set the initial limit.
3820 (setq gnus-newsgroup-limit (copy-sequence articles))
3821 ;; Remove canceled articles from the list of unread articles.
3822 (setq gnus-newsgroup-unreads
3823 (gnus-set-sorted-intersection
3824 gnus-newsgroup-unreads
3825 (setq fetched-articles
3826 (mapcar (lambda (headers) (mail-header-number headers))
3827 gnus-newsgroup-headers))))
3828 ;; Removed marked articles that do not exist.
3829 (gnus-update-missing-marks
3830 (gnus-sorted-complement fetched-articles articles))
3831 ;; Let the Gnus agent mark articles as read.
3833 (gnus-agent-get-undownloaded-list))
3834 ;; We might want to build some more threads first.
3835 (when (and gnus-fetch-old-headers
3836 (eq gnus-headers-retrieved-by 'nov))
3837 (if (eq gnus-fetch-old-headers 'invisible)
3838 (gnus-build-all-threads)
3839 (gnus-build-old-threads)))
3840 ;; Check whether auto-expire is to be done in this group.
3841 (setq gnus-newsgroup-auto-expire
3842 (gnus-group-auto-expirable-p group))
3843 ;; Set up the article buffer now, if necessary.
3844 (unless gnus-single-article-buffer
3845 (gnus-article-setup-buffer))
3846 ;; First and last article in this newsgroup.
3847 (when gnus-newsgroup-headers
3848 (setq gnus-newsgroup-begin
3849 (mail-header-number (car gnus-newsgroup-headers))
3852 (gnus-last-element gnus-newsgroup-headers))))
3853 ;; GROUP is successfully selected.
3854 (or gnus-newsgroup-headers t)))))
3856 (defun gnus-articles-to-read (group &optional read-all)
3857 ;; Find out what articles the user wants to read.
3859 ;; Select all articles if `read-all' is non-nil, or if there
3860 ;; are no unread articles.
3862 (and (zerop (length gnus-newsgroup-marked))
3863 (zerop (length gnus-newsgroup-unreads)))
3864 (eq (gnus-group-find-parameter group 'display)
3866 (gnus-uncompress-range (gnus-active group))
3867 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3868 (copy-sequence gnus-newsgroup-unreads))
3870 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3871 (scored (length scored-list))
3872 (number (length articles))
3873 (marked (+ (length gnus-newsgroup-marked)
3874 (length gnus-newsgroup-dormant)))
3882 ((and (or (<= scored marked) (= scored number))
3883 (numberp gnus-large-newsgroup)
3884 (> number gnus-large-newsgroup))
3888 "How many articles from %s (default %d): "
3889 (gnus-limit-string gnus-newsgroup-name 35)
3891 (if (string-match "^[ \t]*$" input) number input)))
3892 ((and (> scored marked) (< scored number)
3893 (> (- scored number) 20))
3896 (format "%s %s (%d scored, %d total): "
3897 "How many articles from"
3898 group scored number))))
3899 (if (string-match "^[ \t]*$" input)
3903 (setq select (if (stringp select) (string-to-number select) select))
3904 (if (or (null select) (zerop select))
3906 (if (and (not (zerop scored)) (<= (abs select) scored))
3908 (setq articles (sort scored-list '<))
3909 (setq number (length articles)))
3910 (setq articles (copy-sequence articles)))
3912 (when (< (abs select) number)
3914 ;; Select the N oldest articles.
3915 (setcdr (nthcdr (1- (abs select)) articles) nil)
3916 ;; Select the N most recent articles.
3917 (setq articles (nthcdr (- number select) articles))))
3918 (setq gnus-newsgroup-unselected
3919 (gnus-sorted-intersection
3920 gnus-newsgroup-unreads
3921 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3924 (defun gnus-killed-articles (killed articles)
3927 (when (inline (gnus-member-of-range (car articles) killed))
3928 (push (car articles) out))
3929 (setq articles (cdr articles)))
3932 (defun gnus-uncompress-marks (marks)
3933 "Uncompress the mark ranges in MARKS."
3934 (let ((uncompressed '(score bookmark))
3937 (if (memq (caar marks) uncompressed)
3938 (push (car marks) out)
3939 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3940 (setq marks (cdr marks)))
3943 (defun gnus-adjust-marked-articles (info)
3944 "Set all article lists and remove all marks that are no longer legal."
3945 (let* ((marked-lists (gnus-info-marks info))
3946 (active (gnus-active (gnus-info-group info)))
3949 (types gnus-article-mark-lists)
3950 (uncompressed '(score bookmark killed))
3951 marks var articles article mark)
3954 (setq marks (pop marked-lists))
3955 (set (setq var (intern (format "gnus-newsgroup-%s"
3956 (car (rassq (setq mark (car marks))
3958 (if (memq (car marks) uncompressed) (cdr marks)
3959 (gnus-uncompress-range (cdr marks))))
3961 (setq articles (symbol-value var))
3963 ;; All articles have to be subsets of the active articles.
3965 ;; Adjust "simple" lists.
3966 ((memq mark '(tick dormant expire reply save))
3968 (when (or (< (setq article (pop articles)) min) (> article max))
3969 (set var (delq article (symbol-value var))))))
3971 ((memq mark uncompressed)
3972 (when (not (listp (cdr (symbol-value var))))
3973 (set var (list (symbol-value var))))
3974 (when (not (listp (cdr articles)))
3975 (setq articles (list articles)))
3977 (when (or (not (consp (setq article (pop articles))))
3978 (< (car article) min)
3979 (> (car article) max))
3980 (set var (delq article (symbol-value var))))))))))
3982 (defun gnus-update-missing-marks (missing)
3983 "Go through the list of MISSING articles and remove them from the mark lists."
3985 (let ((types gnus-article-mark-lists)
3987 ;; Go through all types.
3989 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3990 (when (symbol-value var)
3991 ;; This list has articles. So we delete all missing articles
3995 (set var (delq (pop m) (symbol-value var)))))))))
3997 (defun gnus-update-marks ()
3998 "Enter the various lists of marked articles into the newsgroup info list."
3999 (let ((types gnus-article-mark-lists)
4000 (info (gnus-get-info gnus-newsgroup-name))
4001 (uncompressed '(score bookmark killed))
4002 type list newmarked symbol)
4004 ;; Add all marks lists that are non-nil to the list of marks lists.
4005 (while (setq type (pop types))
4006 (when (setq list (symbol-value
4008 (intern (format "gnus-newsgroup-%s"
4011 ;; Get rid of the entries of the articles that have the
4013 (when (and (eq (cdr type) 'score)
4017 (prev (cons nil list))
4020 (if (or (not (consp (car arts)))
4021 (= (cdar arts) gnus-summary-default-score))
4022 (setcdr prev (cdr arts))
4024 (setq arts (cdr arts)))
4025 (setq list (cdr all))))
4027 (push (cons (cdr type)
4028 (if (memq (cdr type) uncompressed) list
4029 (gnus-compress-sequence
4030 (set symbol (sort list '<)) t)))
4033 ;; Enter these new marks into the info of the group.
4035 (setcar (nthcdr 3 info) newmarked)
4036 ;; Add the marks lists to the end of the info.
4038 (setcdr (nthcdr 2 info) (list newmarked))))
4040 ;; Cut off the end of the info if there's nothing else there.
4044 (when (nthcdr (decf i) info)
4045 (setcdr (nthcdr i info) nil)))))))
4047 (defun gnus-set-mode-line (where)
4048 "This function sets the mode line of the article or summary buffers.
4049 If WHERE is `summary', the summary mode line format will be used."
4050 ;; Is this mode line one we keep updated?
4051 (when (memq where gnus-updated-mode-lines)
4054 ;; We evaluate this in the summary buffer since these
4055 ;; variables are buffer-local to that buffer.
4056 (set-buffer gnus-summary-buffer)
4057 ;; We bind all these variables that are used in the `eval' form
4059 (let* ((mformat (symbol-value
4061 (format "gnus-%s-mode-line-format-spec" where))))
4062 (gnus-tmp-group-name gnus-newsgroup-name)
4063 (gnus-tmp-article-number (or gnus-current-article 0))
4064 (gnus-tmp-unread gnus-newsgroup-unreads)
4065 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4066 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4067 (gnus-tmp-unread-and-unselected
4068 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4069 (zerop gnus-tmp-unselected))
4071 ((zerop gnus-tmp-unselected)
4072 (format "{%d more}" gnus-tmp-unread-and-unticked))
4073 (t (format "{%d(+%d) more}"
4074 gnus-tmp-unread-and-unticked
4075 gnus-tmp-unselected))))
4077 (if (and gnus-current-headers
4078 (vectorp gnus-current-headers))
4079 (gnus-mode-string-quote
4080 (mail-header-subject gnus-current-headers))
4082 bufname-length max-len
4083 gnus-tmp-header);; passed as argument to any user-format-funcs
4084 (setq mode-string (eval mformat))
4085 (setq bufname-length (if (string-match "%b" mode-string)
4088 (if (eq where 'summary)
4090 (get-buffer gnus-article-buffer))))
4093 (setq max-len (max 4 (if gnus-mode-non-string-length
4095 gnus-mode-non-string-length
4097 (length mode-string))))
4098 ;; We might have to chop a bit of the string off...
4099 (when (> (length mode-string) max-len)
4101 (concat (gnus-truncate-string mode-string (- max-len 3))
4103 ;; Pad the mode string a bit.
4104 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4105 ;; Update the mode line.
4106 (setq mode-line-buffer-identification
4107 (gnus-mode-line-buffer-identification (list mode-string)))
4108 (set-buffer-modified-p t))))
4110 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4111 "Go through the HEADERS list and add all Xrefs to a hash table.
4112 The resulting hash table is returned, or nil if no Xrefs were found."
4113 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4114 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4115 (xref-hashtb (gnus-make-hashtable))
4116 start group entry number xrefs header)
4118 (setq header (pop headers))
4119 (when (and (setq xrefs (mail-header-xref header))
4120 (not (memq (setq number (mail-header-number header))
4123 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4124 (setq start (match-end 0))
4125 (setq group (if prefix
4126 (concat prefix (substring xrefs (match-beginning 1)
4128 (substring xrefs (match-beginning 1) (match-end 1))))
4130 (string-to-int (substring xrefs (match-beginning 2)
4132 (if (setq entry (gnus-gethash group xref-hashtb))
4133 (setcdr entry (cons number (cdr entry)))
4134 (gnus-sethash group (cons number nil) xref-hashtb)))))
4135 (and start xref-hashtb)))
4137 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4138 "Look through all the headers and mark the Xrefs as read."
4139 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4140 name entry info xref-hashtb idlist method nth4)
4142 (set-buffer gnus-group-buffer)
4143 (when (setq xref-hashtb
4144 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4147 (unless (string= from-newsgroup (setq name (symbol-name group)))
4148 (setq idlist (symbol-value group))
4149 ;; Dead groups are not updated.
4151 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4153 (when (stringp (setq nth4 (gnus-info-method info)))
4154 (setq nth4 (gnus-server-to-method nth4))))
4155 ;; Only do the xrefs if the group has the same
4156 ;; select method as the group we have just read.
4157 (or (gnus-methods-equal-p
4158 nth4 (gnus-find-method-for-group from-newsgroup))
4160 (equal nth4 (setq method (gnus-find-method-for-group
4162 (and (equal (car nth4) (car method))
4163 (equal (nth 1 nth4) (nth 1 method))))
4164 gnus-use-cross-reference
4165 (or (not (eq gnus-use-cross-reference t))
4167 ;; Only do cross-references on subscribed
4168 ;; groups, if that is what is wanted.
4169 (<= (gnus-info-level info) gnus-level-subscribed))
4170 (gnus-group-make-articles-read name idlist))))
4173 (defun gnus-compute-read-articles (group articles)
4174 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4175 (info (nth 2 entry))
4176 (active (gnus-active group))
4179 ;; First peel off all illegal article numbers.
4181 (let ((ids articles)
4183 (while (setq id (pop ids))
4184 (when (and first (> id (cdr active)))
4185 ;; We'll end up in this situation in one particular
4186 ;; obscure situation. If you re-scan a group and get
4187 ;; a new article that is cross-posted to a different
4188 ;; group that has not been re-scanned, you might get
4189 ;; crossposted article that has a higher number than
4190 ;; Gnus believes possible. So we re-activate this
4191 ;; group as well. This might mean doing the
4192 ;; crossposting thingy will *increase* the number
4193 ;; of articles in some groups. Tsk, tsk.
4194 (setq active (or (gnus-activate-group group) active)))
4195 (when (or (> id (cdr active))
4196 (< id (car active)))
4197 (setq articles (delq id articles))))))
4198 ;; If the read list is nil, we init it.
4200 (null (gnus-info-read info))
4202 (setq ninfo (cons 1 (1- (car active))))
4203 (setq ninfo (gnus-info-read info)))
4204 ;; Then we add the read articles to the range.
4206 ninfo (setq articles (sort articles '<))))))
4208 (defun gnus-group-make-articles-read (group articles)
4209 "Update the info of GROUP to say that ARTICLES are read."
4211 (entry (gnus-gethash group gnus-newsrc-hashtb))
4212 (info (nth 2 entry))
4213 (active (gnus-active group))
4216 (setq range (gnus-compute-read-articles group articles))
4218 (set-buffer gnus-group-buffer)
4221 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4222 (gnus-info-set-read ',info ',(gnus-info-read info))
4223 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4224 (gnus-group-update-group ,group t))))
4225 ;; Add the read articles to the range.
4226 (gnus-info-set-read info range)
4227 ;; Then we have to re-compute how many unread
4228 ;; articles there are in this group.
4232 (setq num (- (1+ (cdr active)) (car active))))
4233 ((not (listp (cdr range)))
4234 (setq num (- (cdr active) (- (1+ (cdr range))
4238 (if (numberp (car range))
4240 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4241 (setq range (cdr range)))
4242 (setq num (- (cdr active) num))))
4243 ;; Update the number of unread articles.
4245 ;; Update the group buffer.
4246 (gnus-group-update-group group t)))))
4248 (defun gnus-methods-equal-p (m1 m2)
4249 (let ((m1 (or m1 gnus-select-method))
4250 (m2 (or m2 gnus-select-method)))
4252 (and (eq (car m1) (car m2))
4253 (or (not (memq 'address (assoc (symbol-name (car m1))
4254 gnus-valid-select-methods)))
4255 (equal (nth 1 m1) (nth 1 m2)))))))
4257 (defvar gnus-newsgroup-none-id 0)
4259 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4260 (let ((cur nntp-server-buffer)
4263 (save-excursion (set-buffer gnus-summary-buffer)
4264 gnus-newsgroup-dependencies)))
4265 headers id id-dep ref-dep end ref)
4267 (set-buffer nntp-server-buffer)
4268 ;; Translate all TAB characters into SPACE characters.
4269 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4270 (run-hooks 'gnus-parse-headers-hook)
4271 (let ((case-fold-search t)
4272 in-reply-to header p lines)
4273 (goto-char (point-min))
4274 ;; Search to the beginning of the next header. Error messages
4275 ;; do not begin with 2 or 3.
4276 (while (re-search-forward "^[23][0-9]+ " nil t)
4279 ;; This implementation of this function, with nine
4280 ;; search-forwards instead of the one re-search-forward and
4281 ;; a case (which basically was the old function) is actually
4282 ;; about twice as fast, even though it looks messier. You
4283 ;; can't have everything, I guess. Speed and elegance
4284 ;; doesn't always go hand in hand.
4293 (narrow-to-region (point)
4294 (or (and (search-forward "\n.\n" nil t)
4300 (if (search-forward "\nsubject: " nil t)
4301 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4303 gnus-unstructured-field-decoder (nnheader-header-value))
4308 (if (search-forward "\nfrom: " nil t)
4309 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4311 gnus-structured-field-decoder (nnheader-header-value))
4316 (if (search-forward "\ndate: " nil t)
4317 (nnheader-header-value) ""))
4321 (setq id (if (search-forward "\nmessage-id:" nil t)
4323 (1- (or (search-forward "<" nil t) (point)))
4324 (or (search-forward ">" nil t) (point)))
4325 ;; If there was no message-id, we just fake one
4326 ;; to make subsequent routines simpler.
4327 (nnheader-generate-fake-message-id))))
4331 (if (search-forward "\nreferences: " nil t)
4335 (nnheader-header-value)
4340 (search-backward ">" end t)
4343 (search-backward "<" end t)
4345 ;; Get the references from the in-reply-to header if there
4346 ;; were no references and the in-reply-to header looks
4348 (if (and (search-forward "\nin-reply-to: " nil t)
4349 (setq in-reply-to (nnheader-header-value))
4350 (string-match "<[^>]+>" in-reply-to))
4351 (setq ref (substring in-reply-to (match-beginning 0)
4359 (if (search-forward "\nlines: " nil t)
4360 (if (numberp (setq lines (ignore-errors (read cur))))
4366 (and (search-forward "\nxref: " nil t)
4367 (nnheader-header-value)))))
4368 (when (equal id ref)
4371 (when gnus-alter-header-function
4372 (funcall gnus-alter-header-function header)
4373 (setq id (mail-header-id header)
4374 ref (gnus-parent-id (mail-header-references header))))
4376 ;; We do the threading while we read the headers. The
4377 ;; message-id and the last reference are both entered into
4378 ;; the same hash table. Some tippy-toeing around has to be
4379 ;; done in case an article has arrived before the article
4380 ;; which it refers to.
4381 (if (boundp (setq id-dep (intern id dependencies)))
4382 (if (and (car (symbol-value id-dep))
4384 ;; An article with this Message-ID has already been seen.
4385 (if gnus-summary-ignore-duplicates
4386 ;; We ignore this one, except we add
4387 ;; any additional Xrefs (in case the two articles
4388 ;; came from different servers).
4390 (mail-header-set-xref
4391 (car (symbol-value id-dep))
4392 (concat (or (mail-header-xref
4393 (car (symbol-value id-dep)))
4395 (or (mail-header-xref header) "")))
4397 ;; We rename the Message-ID.
4399 (setq id-dep (intern (setq id (nnmail-message-id))
4402 (mail-header-set-id header id))
4403 (setcar (symbol-value id-dep) header))
4404 (set id-dep (list header)))
4406 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4407 (setcdr (symbol-value ref-dep)
4408 (nconc (cdr (symbol-value ref-dep))
4409 (list (symbol-value id-dep))))
4410 (set ref-dep (list nil (symbol-value id-dep))))
4411 (push header headers))
4412 (goto-char (point-max))
4414 (nreverse headers)))))
4416 ;; The following macros and functions were written by Felix Lee
4417 ;; <flee@cse.psu.edu>.
4419 (defmacro gnus-nov-read-integer ()
4421 (if (= (following-char) ?\t)
4423 (let ((num (ignore-errors (read buffer))))
4424 (if (numberp num) num 0)))
4426 (search-forward "\t" eol 'move))))
4428 (defmacro gnus-nov-skip-field ()
4429 '(search-forward "\t" eol 'move))
4431 (defmacro gnus-nov-field ()
4432 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4434 ;; (defvar gnus-nov-none-counter 0)
4436 ;; This function has to be called with point after the article number
4437 ;; on the beginning of the line.
4438 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4439 (let ((eol (gnus-point-at-eol))
4440 (buffer (current-buffer))
4441 header ref id id-dep ref-dep)
4443 ;; overview: [num subject from date id refs chars lines misc]
4446 (narrow-to-region (point) eol)
4454 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4456 gnus-structured-field-decoder (gnus-nov-field)) ; from
4457 (gnus-nov-field) ; date
4458 (setq id (or (gnus-nov-field)
4459 (nnheader-generate-fake-message-id))) ; id
4461 (let ((beg (point)))
4462 (search-forward "\t" eol)
4463 (if (search-backward ">" beg t)
4467 (search-backward "<" beg t)))
4470 (gnus-nov-field)) ; refs
4471 (gnus-nov-read-integer) ; chars
4472 (gnus-nov-read-integer) ; lines
4473 (if (= (following-char) ?\n)
4475 (gnus-nov-field))))) ; misc
4479 (when gnus-alter-header-function
4480 (funcall gnus-alter-header-function header)
4481 (setq id (mail-header-id header)
4482 ref (gnus-parent-id (mail-header-references header))))
4484 ;; We build the thread tree.
4485 (when (equal id ref)
4486 ;; This article refers back to itself. Naughty, naughty.
4488 (if (boundp (setq id-dep (intern id dependencies)))
4489 (if (and (car (symbol-value id-dep))
4491 ;; An article with this Message-ID has already been seen.
4492 (if gnus-summary-ignore-duplicates
4493 ;; We ignore this one, except we add any additional
4494 ;; Xrefs (in case the two articles came from different
4497 (mail-header-set-xref
4498 (car (symbol-value id-dep))
4499 (concat (or (mail-header-xref
4500 (car (symbol-value id-dep)))
4502 (or (mail-header-xref header) "")))
4504 ;; We rename the Message-ID.
4506 (setq id-dep (intern (setq id (nnmail-message-id))
4509 (mail-header-set-id header id))
4510 (setcar (symbol-value id-dep) header))
4511 (set id-dep (list header)))
4513 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4514 (setcdr (symbol-value ref-dep)
4515 (nconc (cdr (symbol-value ref-dep))
4516 (list (symbol-value id-dep))))
4517 (set ref-dep (list nil (symbol-value id-dep)))))
4520 ;; Goes through the xover lines and returns a list of vectors
4521 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4522 force-new dependencies
4523 group also-fetch-heads)
4524 "Parse the news overview data in the server buffer, and return a
4525 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4526 ;; Get the Xref when the users reads the articles since most/some
4527 ;; NNTP servers do not include Xrefs when using XOVER.
4528 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4529 (let ((cur nntp-server-buffer)
4530 (dependencies (or dependencies gnus-newsgroup-dependencies))
4531 number headers header)
4533 (set-buffer nntp-server-buffer)
4534 ;; Allow the user to mangle the headers before parsing them.
4535 (run-hooks 'gnus-parse-headers-hook)
4536 (goto-char (point-min))
4539 (while (and sequence (not (eobp)))
4540 (setq number (read cur))
4541 (while (and sequence
4542 (< (car sequence) number))
4543 (setq sequence (cdr sequence)))
4545 (eq number (car sequence))
4547 (setq sequence (cdr sequence))
4548 (setq header (inline
4549 (gnus-nov-parse-line
4550 number dependencies force-new))))
4551 (push header headers))
4554 (gnus-error 4 "Strange nov line (%d)"
4555 (count-lines (point-min) (point)))))
4557 ;; A common bug in inn is that if you have posted an article and
4558 ;; then retrieves the active file, it will answer correctly --
4559 ;; the new article is included. However, a NOV entry for the
4560 ;; article may not have been generated yet, so this may fail.
4561 ;; We work around this problem by retrieving the last few
4562 ;; headers using HEAD.
4563 (if (or (not also-fetch-heads)
4565 ;; We (probably) got all the headers.
4567 (let ((gnus-nov-is-evil t))
4570 (when (gnus-retrieve-headers sequence group)
4571 (gnus-get-newsgroup-headers))))))))
4573 (defun gnus-article-get-xrefs ()
4574 "Fill in the Xref value in `gnus-current-headers', if necessary.
4575 This is meant to be called in `gnus-article-internal-prepare-hook'."
4576 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4577 gnus-current-headers)))
4578 (or (not gnus-use-cross-reference)
4580 (and (mail-header-xref headers)
4581 (not (string= (mail-header-xref headers) "")))
4582 (let ((case-fold-search t)
4585 (nnheader-narrow-to-headers)
4586 (goto-char (point-min))
4587 (when (or (and (eq (downcase (following-char)) ?x)
4588 (looking-at "Xref:"))
4589 (search-forward "\nXref:" nil t))
4590 (goto-char (1+ (match-end 0)))
4591 (setq xref (buffer-substring (point)
4592 (progn (end-of-line) (point))))
4593 (mail-header-set-xref headers xref)))))))
4595 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4596 "Find article ID and insert the summary line for that article."
4597 (let ((header (if (and old-header use-old-header)
4598 old-header (gnus-read-header id)))
4599 (number (and (numberp id) id))
4602 ;; Rebuild the thread that this article is part of and go to the
4603 ;; article we have fetched.
4604 (when (and (not gnus-show-threads)
4606 (when (setq d (gnus-data-find (mail-header-number old-header)))
4607 (goto-char (gnus-data-pos d))
4610 (- (gnus-point-at-bol)
4612 (1+ (gnus-point-at-eol))
4613 (gnus-delete-line))))))
4615 (mail-header-set-number header (mail-header-number old-header)))
4616 (setq gnus-newsgroup-sparse
4617 (delq (setq number (mail-header-number header))
4618 gnus-newsgroup-sparse))
4619 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4620 (gnus-rebuild-thread (mail-header-id header))
4621 (gnus-summary-goto-subject number nil t))
4622 (when (and (numberp number)
4624 ;; We have to update the boundaries even if we can't fetch the
4625 ;; article if ID is a number -- so that the next `P' or `N'
4626 ;; command will fetch the previous (or next) article even
4627 ;; if the one we tried to fetch this time has been canceled.
4628 (when (> number gnus-newsgroup-end)
4629 (setq gnus-newsgroup-end number))
4630 (when (< number gnus-newsgroup-begin)
4631 (setq gnus-newsgroup-begin number))
4632 (setq gnus-newsgroup-unselected
4633 (delq number gnus-newsgroup-unselected)))
4634 ;; Report back a success?
4635 (and header (mail-header-number header))))
4637 ;;; Process/prefix in the summary buffer
4639 (defun gnus-summary-work-articles (n)
4640 "Return a list of articles to be worked upon. The prefix argument,
4641 the list of process marked articles, and the current article will be
4642 taken into consideration."
4645 ;; A numerical prefix has been given.
4646 (setq n (prefix-numeric-value n))
4647 (let ((backward (< n 0))
4648 (n (abs (prefix-numeric-value n)))
4653 (push (setq article (gnus-summary-article-number))
4656 (gnus-summary-find-prev nil article)
4657 (gnus-summary-find-next nil article)))
4659 (nreverse articles)))
4660 ((gnus-region-active-p)
4661 ;; Work on the region between point and mark.
4662 (let ((max (max (point) (mark)))
4665 (goto-char (min (point) (mark)))
4668 (push (setq article (gnus-summary-article-number)) articles)
4669 (gnus-summary-find-next nil article)
4671 (nreverse articles))))
4672 (gnus-newsgroup-processable
4673 ;; There are process-marked articles present.
4674 ;; Save current state.
4675 (gnus-summary-save-process-mark)
4677 (reverse gnus-newsgroup-processable))
4679 ;; Just return the current article.
4680 (list (gnus-summary-article-number)))))
4682 (defun gnus-summary-save-process-mark ()
4683 "Push the current set of process marked articles on the stack."
4685 (push (copy-sequence gnus-newsgroup-processable)
4686 gnus-newsgroup-process-stack))
4688 (defun gnus-summary-kill-process-mark ()
4689 "Push the current set of process marked articles on the stack and unmark."
4691 (gnus-summary-save-process-mark)
4692 (gnus-summary-unmark-all-processable))
4694 (defun gnus-summary-yank-process-mark ()
4695 "Pop the last process mark state off the stack and restore it."
4697 (unless gnus-newsgroup-process-stack
4698 (error "Empty mark stack"))
4699 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4701 (defun gnus-summary-process-mark-set (set)
4702 "Make SET into the current process marked articles."
4703 (gnus-summary-unmark-all-processable)
4705 (gnus-summary-set-process-mark (pop set))))
4707 ;;; Searching and stuff
4709 (defun gnus-summary-search-group (&optional backward use-level)
4710 "Search for next unread newsgroup.
4711 If optional argument BACKWARD is non-nil, search backward instead."
4713 (set-buffer gnus-group-buffer)
4714 (when (gnus-group-search-forward
4715 backward nil (if use-level (gnus-group-group-level) nil))
4716 (gnus-group-group-name))))
4718 (defun gnus-summary-best-group (&optional exclude-group)
4719 "Find the name of the best unread group.
4720 If EXCLUDE-GROUP, do not go to this group."
4722 (set-buffer gnus-group-buffer)
4724 (gnus-group-best-unread-group exclude-group))))
4726 (defun gnus-summary-find-next (&optional unread article backward)
4727 (if backward (gnus-summary-find-prev)
4728 (let* ((dummy (gnus-summary-article-intangible-p))
4729 (article (or article (gnus-summary-article-number)))
4730 (arts (gnus-data-find-list article))
4732 (when (and (not dummy)
4733 (or (not gnus-summary-check-current)
4735 (not (gnus-data-unread-p (car arts)))))
4736 (setq arts (cdr arts)))
4741 (when (gnus-data-unread-p (car arts))
4742 (setq result (car arts)
4744 (setq arts (cdr arts)))
4747 (goto-char (gnus-data-pos result))
4748 (gnus-data-number result)))))
4750 (defun gnus-summary-find-prev (&optional unread article)
4751 (let* ((eobp (eobp))
4752 (article (or article (gnus-summary-article-number)))
4753 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4755 (when (and (not eobp)
4756 (or (not gnus-summary-check-current)
4758 (not (gnus-data-unread-p (car arts)))))
4759 (setq arts (cdr arts)))
4764 (when (gnus-data-unread-p (car arts))
4765 (setq result (car arts)
4767 (setq arts (cdr arts)))
4770 (goto-char (gnus-data-pos result))
4771 (gnus-data-number result))))
4773 (defun gnus-summary-find-subject (subject &optional unread backward article)
4774 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4775 (article (or article (gnus-summary-article-number)))
4776 (articles (gnus-data-list backward))
4777 (arts (gnus-data-find-list article articles))
4779 (when (or (not gnus-summary-check-current)
4781 (not (gnus-data-unread-p (car arts))))
4782 (setq arts (cdr arts)))
4784 (and (or (not unread)
4785 (gnus-data-unread-p (car arts)))
4786 (vectorp (gnus-data-header (car arts)))
4788 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4789 (setq result (car arts)
4791 (setq arts (cdr arts)))
4793 (goto-char (gnus-data-pos result))
4794 (gnus-data-number result))))
4796 (defun gnus-summary-search-forward (&optional unread subject backward)
4797 "Search forward for an article.
4798 If UNREAD, look for unread articles. If SUBJECT, look for
4799 articles with that subject. If BACKWARD, search backward instead."
4800 (cond (subject (gnus-summary-find-subject subject unread backward))
4801 (backward (gnus-summary-find-prev unread))
4802 (t (gnus-summary-find-next unread))))
4804 (defun gnus-recenter (&optional n)
4805 "Center point in window and redisplay frame.
4806 Also do horizontal recentering."
4808 (when (and gnus-auto-center-summary
4809 (not (eq gnus-auto-center-summary 'vertical)))
4810 (gnus-horizontal-recenter))
4813 (defun gnus-summary-recenter ()
4814 "Center point in the summary window.
4815 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4816 displayed, no centering will be performed."
4817 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4818 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4819 (let* ((top (cond ((< (window-height) 4) 0)
4820 ((< (window-height) 7) 1)
4822 (height (1- (window-height)))
4823 (bottom (save-excursion (goto-char (point-max))
4824 (forward-line (- height))
4826 (window (get-buffer-window (current-buffer))))
4827 ;; The user has to want it.
4828 (when gnus-auto-center-summary
4829 (when (get-buffer-window gnus-article-buffer)
4830 ;; Only do recentering when the article buffer is displayed,
4831 ;; Set the window start to either `bottom', which is the biggest
4832 ;; possible valid number, or the second line from the top,
4833 ;; whichever is the least.
4835 window (min bottom (save-excursion
4836 (forward-line (- top)) (point)))))
4837 ;; Do horizontal recentering while we're at it.
4838 (when (and (get-buffer-window (current-buffer) t)
4839 (not (eq gnus-auto-center-summary 'vertical)))
4840 (let ((selected (selected-window)))
4841 (select-window (get-buffer-window (current-buffer) t))
4842 (gnus-summary-position-point)
4843 (gnus-horizontal-recenter)
4844 (select-window selected))))))
4846 (defun gnus-summary-jump-to-group (newsgroup)
4847 "Move point to NEWSGROUP in group mode buffer."
4848 ;; Keep update point of group mode buffer if visible.
4849 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4850 (save-window-excursion
4851 ;; Take care of tree window mode.
4852 (when (get-buffer-window gnus-group-buffer)
4853 (pop-to-buffer gnus-group-buffer))
4854 (gnus-group-jump-to-group newsgroup))
4856 ;; Take care of tree window mode.
4857 (if (get-buffer-window gnus-group-buffer)
4858 (pop-to-buffer gnus-group-buffer)
4859 (set-buffer gnus-group-buffer))
4860 (gnus-group-jump-to-group newsgroup))))
4862 ;; This function returns a list of article numbers based on the
4863 ;; difference between the ranges of read articles in this group and
4864 ;; the range of active articles.
4865 (defun gnus-list-of-unread-articles (group)
4866 (let* ((read (gnus-info-read (gnus-get-info group)))
4867 (active (or (gnus-active group) (gnus-activate-group group)))
4870 ;; If none are read, then all are unread.
4872 (setq first (car active))
4873 ;; If the range of read articles is a single range, then the
4874 ;; first unread article is the article after the last read
4875 ;; article. Sounds logical, doesn't it?
4876 (if (not (listp (cdr read)))
4877 (setq first (1+ (cdr read)))
4878 ;; `read' is a list of ranges.
4879 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4885 (while (< first nlast)
4887 (setq first (1+ first))))
4888 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4889 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4890 (setq read (cdr read)))))
4891 ;; And add the last unread articles.
4892 (while (<= first last)
4894 (setq first (1+ first)))
4895 ;; Return the list of unread articles.
4896 (delq 0 (nreverse unread))))
4898 (defun gnus-list-of-read-articles (group)
4899 "Return a list of unread, unticked and non-dormant articles."
4900 (let* ((info (gnus-get-info group))
4901 (marked (gnus-info-marks info))
4902 (active (gnus-active group)))
4904 (gnus-set-difference
4905 (gnus-sorted-complement
4906 (gnus-uncompress-range active)
4907 (gnus-list-of-unread-articles group))
4909 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4910 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4912 ;; Various summary commands
4914 (defun gnus-summary-select-article-buffer ()
4915 "Reconfigure windows to show article buffer."
4917 (if (not (gnus-buffer-live-p gnus-article-buffer))
4918 (error "There is no article buffer for this summary buffer")
4919 (gnus-configure-windows 'article)
4920 (select-window (get-buffer-window gnus-article-buffer))))
4922 (defun gnus-summary-universal-argument (arg)
4923 "Perform any operation on all articles that are process/prefixed."
4925 (let ((articles (gnus-summary-work-articles arg))
4932 (substitute-command-keys
4933 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4936 (gnus-error 1 "Undefined key")
4939 (gnus-summary-goto-subject (setq article (pop articles)))
4940 (let (gnus-newsgroup-processable)
4941 (command-execute func))
4942 (gnus-summary-remove-process-mark article)))))
4943 (gnus-summary-position-point))
4945 (defun gnus-summary-toggle-truncation (&optional arg)
4946 "Toggle truncation of summary lines.
4947 With arg, turn line truncation on iff arg is positive."
4949 (setq truncate-lines
4950 (if (null arg) (not truncate-lines)
4951 (> (prefix-numeric-value arg) 0)))
4954 (defun gnus-summary-reselect-current-group (&optional all rescan)
4955 "Exit and then reselect the current newsgroup.
4956 The prefix argument ALL means to select all articles."
4958 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4959 (error "Ephemeral groups can't be reselected"))
4960 (let ((current-subject (gnus-summary-article-number))
4961 (group gnus-newsgroup-name))
4962 (setq gnus-newsgroup-begin nil)
4964 ;; We have to adjust the point of group mode buffer because
4965 ;; point was moved to the next unread newsgroup by exiting.
4966 (gnus-summary-jump-to-group group)
4969 (gnus-group-get-new-news-this-group 1)))
4970 (gnus-group-read-group all t)
4971 (gnus-summary-goto-subject current-subject nil t)))
4973 (defun gnus-summary-rescan-group (&optional all)
4974 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4976 (gnus-summary-reselect-current-group all t))
4978 (defun gnus-summary-update-info (&optional non-destructive)
4980 (let ((group gnus-newsgroup-name))
4982 (when gnus-newsgroup-kill-headers
4983 (setq gnus-newsgroup-killed
4984 (gnus-compress-sequence
4986 (gnus-set-sorted-intersection
4987 (gnus-uncompress-range gnus-newsgroup-killed)
4988 (setq gnus-newsgroup-unselected
4989 (sort gnus-newsgroup-unselected '<)))
4990 (setq gnus-newsgroup-unreads
4991 (sort gnus-newsgroup-unreads '<)))
4993 (unless (listp (cdr gnus-newsgroup-killed))
4994 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4995 (let ((headers gnus-newsgroup-headers))
4996 (when (and (not gnus-save-score)
4997 (not non-destructive))
4998 (setq gnus-newsgroup-scored nil))
4999 ;; Set the new ranges of read articles.
5001 (set-buffer gnus-group-buffer)
5002 (gnus-undo-force-boundary))
5003 (gnus-update-read-articles
5004 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5005 ;; Set the current article marks.
5007 ;; Do the cross-ref thing.
5008 (when gnus-use-cross-reference
5009 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5010 ;; Do not switch windows but change the buffer to work.
5011 (set-buffer gnus-group-buffer)
5012 (unless (gnus-ephemeral-group-p group)
5013 (gnus-group-update-group group)))))))
5015 (defun gnus-summary-save-newsrc (&optional force)
5016 "Save the current number of read/marked articles in the dribble buffer.
5017 The dribble buffer will then be saved.
5018 If FORCE (the prefix), also save the .newsrc file(s)."
5020 (gnus-summary-update-info t)
5022 (gnus-save-newsrc-file)
5023 (gnus-dribble-save)))
5025 (defun gnus-summary-exit (&optional temporary)
5026 "Exit reading current newsgroup, and then return to group selection mode.
5027 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5029 (gnus-kill-save-kill-buffer)
5030 (let* ((group gnus-newsgroup-name)
5031 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5034 (buf (current-buffer)))
5035 (run-hooks 'gnus-summary-prepare-exit-hook)
5036 ;; If we have several article buffers, we kill them at exit.
5037 (unless gnus-single-article-buffer
5038 (gnus-kill-buffer gnus-original-article-buffer)
5039 (setq gnus-article-current nil))
5040 (when gnus-use-cache
5041 (gnus-cache-possibly-remove-articles)
5042 (gnus-cache-save-buffers))
5043 (gnus-async-prefetch-remove-group group)
5044 (when gnus-suppress-duplicates
5045 (gnus-dup-enter-articles))
5046 (when gnus-use-trees
5047 (gnus-tree-close group))
5048 ;; Make all changes in this group permanent.
5050 (run-hooks 'gnus-exit-group-hook)
5051 (gnus-summary-update-info)
5052 ;; Do adaptive scoring, and possibly save score files.
5053 (when gnus-newsgroup-adaptive
5054 (gnus-score-adaptive))
5055 (when gnus-use-scoring
5057 (gnus-close-group group)
5058 ;; Make sure where we were, and go to next newsgroup.
5059 (set-buffer gnus-group-buffer)
5061 (gnus-group-jump-to-group group))
5062 (run-hooks 'gnus-summary-exit-hook)
5063 (unless (or quit-config
5064 ;; If this group has disappeared from the summary
5065 ;; buffer, don't skip forwards.
5066 (not (string= group (gnus-group-group-name))))
5067 (gnus-group-next-unread-group 1))
5068 (setq group-point (point))
5071 ;; If we have several article buffers, we kill them at exit.
5072 (unless gnus-single-article-buffer
5073 (gnus-kill-buffer gnus-article-buffer)
5074 (gnus-kill-buffer gnus-original-article-buffer)
5075 (setq gnus-article-current nil))
5077 (if (not gnus-kill-summary-on-exit)
5078 (gnus-deaden-summary)
5079 ;; We set all buffer-local variables to nil. It is unclear why
5080 ;; this is needed, but if we don't, buffer-local variables are
5081 ;; not garbage-collected, it seems. This would the lead to en
5082 ;; ever-growing Emacs.
5083 (gnus-summary-clear-local-variables)
5084 (when (get-buffer gnus-article-buffer)
5085 (bury-buffer gnus-article-buffer))
5086 ;; We clear the global counterparts of the buffer-local
5087 ;; variables as well, just to be on the safe side.
5088 (set-buffer gnus-group-buffer)
5089 (gnus-summary-clear-local-variables)
5090 ;; Return to group mode buffer.
5091 (when (eq mode 'gnus-summary-mode)
5092 (gnus-kill-buffer buf)))
5093 (setq gnus-current-select-method gnus-select-method)
5094 (pop-to-buffer gnus-group-buffer)
5095 ;; Clear the current group name.
5096 (if (not quit-config)
5098 (goto-char group-point)
5099 (gnus-configure-windows 'group 'force))
5100 (gnus-handle-ephemeral-exit quit-config))
5102 (setq gnus-newsgroup-name nil)))))
5104 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5105 (defun gnus-summary-exit-no-update (&optional no-questions)
5106 "Quit reading current newsgroup without updating read article info."
5108 (let* ((group gnus-newsgroup-name)
5109 (quit-config (gnus-group-quit-config group)))
5110 (when (or no-questions
5112 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5113 ;; If we have several article buffers, we kill them at exit.
5114 (unless gnus-single-article-buffer
5115 (gnus-kill-buffer gnus-article-buffer)
5116 (gnus-kill-buffer gnus-original-article-buffer)
5117 (setq gnus-article-current nil))
5118 (if (not gnus-kill-summary-on-exit)
5119 (gnus-deaden-summary)
5120 (gnus-close-group group)
5121 (gnus-summary-clear-local-variables)
5122 (set-buffer gnus-group-buffer)
5123 (gnus-summary-clear-local-variables)
5124 (when (get-buffer gnus-summary-buffer)
5125 (kill-buffer gnus-summary-buffer)))
5126 (unless gnus-single-article-buffer
5127 (setq gnus-article-current nil))
5128 (when gnus-use-trees
5129 (gnus-tree-close group))
5130 (gnus-async-prefetch-remove-group group)
5131 (when (get-buffer gnus-article-buffer)
5132 (bury-buffer gnus-article-buffer))
5133 ;; Return to the group buffer.
5134 (gnus-configure-windows 'group 'force)
5135 ;; Clear the current group name.
5136 (setq gnus-newsgroup-name nil)
5137 (when (equal (gnus-group-group-name) group)
5138 (gnus-group-next-unread-group 1))
5140 (gnus-handle-ephemeral-exit quit-config)))))
5142 (defun gnus-handle-ephemeral-exit (quit-config)
5143 "Handle movement when leaving an ephemeral group. The state
5144 which existed when entering the ephemeral is reset."
5145 (if (not (buffer-name (car quit-config)))
5146 (gnus-configure-windows 'group 'force)
5147 (set-buffer (car quit-config))
5148 (cond ((eq major-mode 'gnus-summary-mode)
5149 (gnus-set-global-variables))
5150 ((eq major-mode 'gnus-article-mode)
5152 ;; The `gnus-summary-buffer' variable may point
5153 ;; to the old summary buffer when using a single
5155 (unless (gnus-buffer-live-p gnus-summary-buffer)
5156 (set-buffer gnus-group-buffer))
5157 (set-buffer gnus-summary-buffer)
5158 (gnus-set-global-variables))))
5159 (if (or (eq (cdr quit-config) 'article)
5160 (eq (cdr quit-config) 'pick))
5162 ;; The current article may be from the ephemeral group
5163 ;; thus it is best that we reload this article
5164 (gnus-summary-show-article)
5165 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5166 (gnus-configure-windows 'pick 'force)
5167 (gnus-configure-windows (cdr quit-config) 'force)))
5168 (gnus-configure-windows (cdr quit-config) 'force))
5169 (when (eq major-mode 'gnus-summary-mode)
5170 (gnus-summary-next-subject 1 nil t)
5171 (gnus-summary-recenter)
5172 (gnus-summary-position-point))))
5176 (defvar gnus-dead-summary-mode-map nil)
5178 (unless gnus-dead-summary-mode-map
5179 (setq gnus-dead-summary-mode-map (make-keymap))
5180 (suppress-keymap gnus-dead-summary-mode-map)
5181 (substitute-key-definition
5182 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5183 (let ((keys '("\C-d" "\r" "\177" [delete])))
5185 (define-key gnus-dead-summary-mode-map
5186 (pop keys) 'gnus-summary-wake-up-the-dead))))
5188 (defvar gnus-dead-summary-mode nil
5189 "Minor mode for Gnus summary buffers.")
5191 (defun gnus-dead-summary-mode (&optional arg)
5192 "Minor mode for Gnus summary buffers."
5194 (when (eq major-mode 'gnus-summary-mode)
5195 (make-local-variable 'gnus-dead-summary-mode)
5196 (setq gnus-dead-summary-mode
5197 (if (null arg) (not gnus-dead-summary-mode)
5198 (> (prefix-numeric-value arg) 0)))
5199 (when gnus-dead-summary-mode
5200 (gnus-add-minor-mode
5201 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5203 (defun gnus-deaden-summary ()
5204 "Make the current summary buffer into a dead summary buffer."
5205 ;; Kill any previous dead summary buffer.
5206 (when (and gnus-dead-summary
5207 (buffer-name gnus-dead-summary))
5209 (set-buffer gnus-dead-summary)
5210 (when gnus-dead-summary-mode
5211 (kill-buffer (current-buffer)))))
5212 ;; Make this the current dead summary.
5213 (setq gnus-dead-summary (current-buffer))
5214 (gnus-dead-summary-mode 1)
5215 (let ((name (buffer-name)))
5216 (when (string-match "Summary" name)
5218 (concat (substring name 0 (match-beginning 0)) "Dead "
5219 (substring name (match-beginning 0)))
5222 (defun gnus-kill-or-deaden-summary (buffer)
5223 "Kill or deaden the summary BUFFER."
5225 (when (and (buffer-name buffer)
5226 (not gnus-single-article-buffer))
5229 (gnus-kill-buffer gnus-article-buffer)
5230 (gnus-kill-buffer gnus-original-article-buffer)))
5231 (cond (gnus-kill-summary-on-exit
5232 (when (and gnus-use-trees
5233 (and (get-buffer buffer)
5234 (buffer-name (get-buffer buffer))))
5236 (set-buffer (get-buffer buffer))
5237 (gnus-tree-close gnus-newsgroup-name)))
5238 (gnus-kill-buffer buffer))
5239 ((and (get-buffer buffer)
5240 (buffer-name (get-buffer buffer)))
5243 (gnus-deaden-summary))))))
5245 (defun gnus-summary-wake-up-the-dead (&rest args)
5246 "Wake up the dead summary buffer."
5248 (gnus-dead-summary-mode -1)
5249 (let ((name (buffer-name)))
5250 (when (string-match "Dead " name)
5252 (concat (substring name 0 (match-beginning 0))
5253 (substring name (match-end 0)))
5255 (gnus-message 3 "This dead summary is now alive again"))
5257 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5258 (defun gnus-summary-fetch-faq (&optional faq-dir)
5259 "Fetch the FAQ for the current group.
5260 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5264 (when current-prefix-arg
5266 "Faq dir: " (and (listp gnus-group-faq-directory)
5267 (mapcar (lambda (file) (list file))
5268 gnus-group-faq-directory))))))
5269 (let (gnus-faq-buffer)
5270 (when (setq gnus-faq-buffer
5271 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5272 (gnus-configure-windows 'summary-faq))))
5274 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5275 (defun gnus-summary-describe-group (&optional force)
5276 "Describe the current newsgroup."
5278 (gnus-group-describe-group force gnus-newsgroup-name))
5280 (defun gnus-summary-describe-briefly ()
5281 "Describe summary mode commands briefly."
5284 (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")))
5286 ;; Walking around group mode buffer from summary mode.
5288 (defun gnus-summary-next-group (&optional no-article target-group backward)
5289 "Exit current newsgroup and then select next unread newsgroup.
5290 If prefix argument NO-ARTICLE is non-nil, no article is selected
5291 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5292 previous group instead."
5294 ;; Stop pre-fetching.
5295 (gnus-async-halt-prefetch)
5296 (let ((current-group gnus-newsgroup-name)
5297 (current-buffer (current-buffer))
5299 ;; First we semi-exit this group to update Xrefs and all variables.
5300 ;; We can't do a real exit, because the window conf must remain
5301 ;; the same in case the user is prompted for info, and we don't
5302 ;; want the window conf to change before that...
5303 (gnus-summary-exit t)
5304 (while (not entered)
5305 ;; Then we find what group we are supposed to enter.
5306 (set-buffer gnus-group-buffer)
5307 (gnus-group-jump-to-group current-group)
5310 (if (eq gnus-keep-same-level 'best)
5311 (gnus-summary-best-group gnus-newsgroup-name)
5312 (gnus-summary-search-group backward gnus-keep-same-level))))
5313 (if (not target-group)
5314 ;; There are no further groups, so we return to the group
5317 (gnus-message 5 "Returning to the group buffer")
5319 (when (gnus-buffer-live-p current-buffer)
5320 (set-buffer current-buffer)
5321 (gnus-summary-exit))
5322 (run-hooks 'gnus-group-no-more-groups-hook))
5323 ;; We try to enter the target group.
5324 (gnus-group-jump-to-group target-group)
5325 (let ((unreads (gnus-group-group-unread)))
5326 (if (and (or (eq t unreads)
5327 (and unreads (not (zerop unreads))))
5328 (gnus-summary-read-group
5329 target-group nil no-article
5330 (and (buffer-name current-buffer) current-buffer)))
5332 (setq current-group target-group
5333 target-group nil)))))))
5335 (defun gnus-summary-prev-group (&optional no-article)
5336 "Exit current newsgroup and then select previous unread newsgroup.
5337 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5339 (gnus-summary-next-group no-article nil t))
5341 ;; Walking around summary lines.
5343 (defun gnus-summary-first-subject (&optional unread)
5344 "Go to the first unread subject.
5345 If UNREAD is non-nil, go to the first unread article.
5346 Returns the article selected or nil if there are no unread articles."
5351 ((null gnus-newsgroup-data)
5352 (gnus-message 3 "No articles in the group")
5354 ;; Pick the first article.
5356 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5357 (gnus-data-number (car gnus-newsgroup-data)))
5358 ;; No unread articles.
5359 ((null gnus-newsgroup-unreads)
5360 (gnus-message 3 "No more unread articles")
5362 ;; Find the first unread article.
5364 (let ((data gnus-newsgroup-data))
5366 (not (gnus-data-unread-p (car data))))
5367 (setq data (cdr data)))
5369 (goto-char (gnus-data-pos (car data)))
5370 (gnus-data-number (car data))))))
5371 (gnus-summary-position-point)))
5373 (defun gnus-summary-next-subject (n &optional unread dont-display)
5374 "Go to next N'th summary line.
5375 If N is negative, go to the previous N'th subject line.
5376 If UNREAD is non-nil, only unread articles are selected.
5377 The difference between N and the actual number of steps taken is
5380 (let ((backward (< n 0))
5384 (gnus-summary-find-prev unread)
5385 (gnus-summary-find-next unread)))
5388 (gnus-message 7 "No more%s articles"
5389 (if unread " unread" "")))
5390 (unless dont-display
5391 (gnus-summary-recenter)
5392 (gnus-summary-position-point))
5395 (defun gnus-summary-next-unread-subject (n)
5396 "Go to next N'th unread summary line."
5398 (gnus-summary-next-subject n t))
5400 (defun gnus-summary-prev-subject (n &optional unread)
5401 "Go to previous N'th summary line.
5402 If optional argument UNREAD is non-nil, only unread article is selected."
5404 (gnus-summary-next-subject (- n) unread))
5406 (defun gnus-summary-prev-unread-subject (n)
5407 "Go to previous N'th unread summary line."
5409 (gnus-summary-next-subject (- n) t))
5411 (defun gnus-summary-goto-subject (article &optional force silent)
5412 "Go the subject line of ARTICLE.
5413 If FORCE, also allow jumping to articles not currently shown."
5414 (interactive "nArticle number: ")
5416 (data (gnus-data-find article)))
5417 ;; We read in the article if we have to.
5420 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5421 (setq data (gnus-data-find article)))
5426 (gnus-message 3 "Can't find article %d" article))
5428 (goto-char (gnus-data-pos data))
5431 ;; Walking around summary lines with displaying articles.
5433 (defun gnus-summary-expand-window (&optional arg)
5434 "Make the summary buffer take up the entire Emacs frame.
5435 Given a prefix, will force an `article' buffer configuration."
5438 (gnus-configure-windows 'article 'force)
5439 (gnus-configure-windows 'summary 'force)))
5441 (defun gnus-summary-display-article (article &optional all-header)
5442 "Display ARTICLE in article buffer."
5443 (gnus-set-global-variables)
5447 (if gnus-summary-display-article-function
5448 (funcall gnus-summary-display-article-function article all-header)
5449 (gnus-article-prepare article all-header))
5450 (run-hooks 'gnus-select-article-hook)
5451 (when (and gnus-current-article
5452 (not (zerop gnus-current-article)))
5453 (gnus-summary-goto-subject gnus-current-article))
5454 (gnus-summary-recenter)
5455 (when (and gnus-use-trees gnus-show-threads)
5456 (gnus-possibly-generate-tree article)
5457 (gnus-highlight-selected-tree article))
5458 ;; Successfully display article.
5459 (gnus-article-set-window-start
5460 (cdr (assq article gnus-newsgroup-bookmarks))))))
5462 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5463 "Select the current article.
5464 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5465 non-nil, the article will be re-fetched even if it already present in
5466 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5468 ;; Make sure we are in the summary buffer to work around bbdb bug.
5469 (unless (eq major-mode 'gnus-summary-mode)
5470 (set-buffer gnus-summary-buffer))
5471 (let ((article (or article (gnus-summary-article-number)))
5472 (all-headers (not (not all-headers))) ;Must be T or NIL.
5473 gnus-summary-display-article-function
5476 (gnus-summary-article-pseudo-p article)
5477 (error "This is a pseudo-article"))
5480 (set-buffer gnus-summary-buffer)
5481 (if (or (and gnus-single-article-buffer
5482 (or (null gnus-current-article)
5483 (null gnus-article-current)
5484 (null (get-buffer gnus-article-buffer))
5485 (not (eq article (cdr gnus-article-current)))
5486 (not (equal (car gnus-article-current)
5487 gnus-newsgroup-name))))
5488 (and (not gnus-single-article-buffer)
5489 (or (null gnus-current-article)
5490 (not (eq gnus-current-article article))))
5492 ;; The requested article is different from the current article.
5494 (gnus-summary-display-article article all-headers)
5496 (when (or all-headers gnus-show-all-headers)
5497 (gnus-article-show-all-headers))
5500 (gnus-article-set-window-start
5501 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5503 (defun gnus-summary-set-current-mark (&optional current-mark)
5504 "Obsolete function."
5507 (defun gnus-summary-next-article (&optional unread subject backward push)
5508 "Select the next article.
5509 If UNREAD, only unread articles are selected.
5510 If SUBJECT, only articles with SUBJECT are selected.
5511 If BACKWARD, the previous article is selected instead of the next."
5514 ;; Is there such an article?
5515 ((and (gnus-summary-search-forward unread subject backward)
5516 (or (gnus-summary-display-article (gnus-summary-article-number))
5517 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5518 (gnus-summary-position-point))
5519 ;; If not, we try the first unread, if that is wanted.
5521 gnus-auto-select-same
5522 (gnus-summary-first-unread-article))
5523 (gnus-summary-position-point)
5524 (gnus-message 6 "Wrapped"))
5525 ;; Try to get next/previous article not displayed in this group.
5526 ((and gnus-auto-extend-newsgroup
5527 (not unread) (not subject))
5528 (gnus-summary-goto-article
5529 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5531 ;; Go to next/previous group.
5533 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5534 (gnus-summary-jump-to-group gnus-newsgroup-name))
5535 (let ((cmd last-command-char)
5538 (set-buffer gnus-group-buffer)
5541 (if (eq gnus-keep-same-level 'best)
5542 (gnus-summary-best-group gnus-newsgroup-name)
5543 (gnus-summary-search-group backward gnus-keep-same-level))))
5544 ;; For some reason, the group window gets selected. We change
5546 (select-window (get-buffer-window (current-buffer)))
5547 ;; Select next unread newsgroup automagically.
5549 ((or (not gnus-auto-select-next)
5551 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5552 ((or (eq gnus-auto-select-next 'quietly)
5553 (and (eq gnus-auto-select-next 'slightly-quietly)
5555 (and (eq gnus-auto-select-next 'almost-quietly)
5556 (gnus-summary-last-article-p)))
5558 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5560 (gnus-message 7 "No more%s articles (%s)..."
5561 (if unread " unread" "")
5562 (if group (concat "selecting " group)
5564 (gnus-summary-next-group nil group backward)))
5566 (when (gnus-key-press-event-p last-input-event)
5567 (gnus-summary-walk-group-buffer
5568 gnus-newsgroup-name cmd unread backward point))))))))
5570 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5571 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5572 (?\C-p (gnus-group-prev-unread-group 1))))
5573 (cursor-in-echo-area t)
5574 keve key group ended)
5576 (set-buffer gnus-group-buffer)
5579 (if (eq gnus-keep-same-level 'best)
5580 (gnus-summary-best-group gnus-newsgroup-name)
5581 (gnus-summary-search-group backward gnus-keep-same-level))))
5584 5 "No more%s articles%s" (if unread " unread" "")
5586 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5587 (format " (Type %s for %s [%s])"
5588 (single-key-description cmd) group
5589 (car (gnus-gethash group gnus-newsrc-hashtb)))
5590 (format " (Type %s to exit %s)"
5591 (single-key-description cmd)
5592 gnus-newsgroup-name)))
5593 ;; Confirm auto selection.
5594 (setq key (car (setq keve (gnus-read-event-char))))
5597 ((assq key keystrokes)
5598 (let ((obuf (current-buffer)))
5599 (switch-to-buffer gnus-group-buffer)
5601 (gnus-group-jump-to-group group))
5602 (eval (cadr (assq key keystrokes)))
5603 (setq group (gnus-group-group-name))
5604 (switch-to-buffer obuf))
5608 (gnus-ephemeral-group-p gnus-newsgroup-name))
5610 (gnus-summary-next-group nil group backward)))
5612 (push (cdr keve) unread-command-events))))))
5614 (defun gnus-summary-next-unread-article ()
5615 "Select unread article after current one."
5617 (gnus-summary-next-article
5618 (or (not (eq gnus-summary-goto-unread 'never))
5619 (gnus-summary-last-article-p (gnus-summary-article-number)))
5620 (and gnus-auto-select-same
5621 (gnus-summary-article-subject))))
5623 (defun gnus-summary-prev-article (&optional unread subject)
5624 "Select the article after the current one.
5625 If UNREAD is non-nil, only unread articles are selected."
5627 (gnus-summary-next-article unread subject t))
5629 (defun gnus-summary-prev-unread-article ()
5630 "Select unread article before current one."
5632 (gnus-summary-prev-article
5633 (or (not (eq gnus-summary-goto-unread 'never))
5634 (gnus-summary-first-article-p (gnus-summary-article-number)))
5635 (and gnus-auto-select-same
5636 (gnus-summary-article-subject))))
5638 (defun gnus-summary-next-page (&optional lines circular)
5639 "Show next page of the selected article.
5640 If at the end of the current article, select the next article.
5641 LINES says how many lines should be scrolled up.
5643 If CIRCULAR is non-nil, go to the start of the article instead of
5644 selecting the next article when reaching the end of the current
5647 (setq gnus-summary-buffer (current-buffer))
5648 (gnus-set-global-variables)
5649 (let ((article (gnus-summary-article-number))
5650 (article-window (get-buffer-window gnus-article-buffer t))
5652 (gnus-configure-windows 'article)
5653 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5654 (if (and (eq gnus-summary-goto-unread 'never)
5655 (not (gnus-summary-last-article-p article)))
5656 (gnus-summary-next-article)
5657 (gnus-summary-next-unread-article))
5658 (if (or (null gnus-current-article)
5659 (null gnus-article-current)
5660 (/= article (cdr gnus-article-current))
5661 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5662 ;; Selected subject is different from current article's.
5663 (gnus-summary-display-article article)
5664 (when article-window
5665 (gnus-eval-in-buffer-window gnus-article-buffer
5666 (setq endp (gnus-article-next-page lines)))
5669 (gnus-summary-beginning-of-article))
5671 (gnus-message 3 "End of message"))
5673 (if (and (eq gnus-summary-goto-unread 'never)
5674 (not (gnus-summary-last-article-p article)))
5675 (gnus-summary-next-article)
5676 (gnus-summary-next-unread-article))))))))
5677 (gnus-summary-recenter)
5678 (gnus-summary-position-point)))
5680 (defun gnus-summary-prev-page (&optional lines move)
5681 "Show previous page of selected article.
5682 Argument LINES specifies lines to be scrolled down.
5683 If MOVE, move to the previous unread article if point is at
5684 the beginning of the buffer."
5686 (let ((article (gnus-summary-article-number))
5687 (article-window (get-buffer-window gnus-article-buffer t))
5689 (gnus-configure-windows 'article)
5690 (if (or (null gnus-current-article)
5691 (null gnus-article-current)
5692 (/= article (cdr gnus-article-current))
5693 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5694 ;; Selected subject is different from current article's.
5695 (gnus-summary-display-article article)
5696 (gnus-summary-recenter)
5697 (when article-window
5698 (gnus-eval-in-buffer-window gnus-article-buffer
5699 (setq endp (gnus-article-prev-page lines)))
5700 (when (and move endp)
5702 (gnus-message 3 "Beginning of message"))
5704 (if (and (eq gnus-summary-goto-unread 'never)
5705 (not (gnus-summary-first-article-p article)))
5706 (gnus-summary-prev-article)
5707 (gnus-summary-prev-unread-article))))))))
5708 (gnus-summary-position-point))
5710 (defun gnus-summary-prev-page-or-article (&optional lines)
5711 "Show previous page of selected article.
5712 Argument LINES specifies lines to be scrolled down.
5713 If at the beginning of the article, go to the next article."
5715 (gnus-summary-prev-page lines t))
5717 (defun gnus-summary-scroll-up (lines)
5718 "Scroll up (or down) one line current article.
5719 Argument LINES specifies lines to be scrolled up (or down if negative)."
5721 (gnus-configure-windows 'article)
5722 (gnus-summary-show-thread)
5723 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5724 (gnus-eval-in-buffer-window gnus-article-buffer
5726 (when (gnus-article-next-page lines)
5727 (gnus-message 3 "End of message")))
5729 (gnus-article-prev-page (- lines))))))
5730 (gnus-summary-recenter)
5731 (gnus-summary-position-point))
5733 (defun gnus-summary-next-same-subject ()
5734 "Select next article which has the same subject as current one."
5736 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5738 (defun gnus-summary-prev-same-subject ()
5739 "Select previous article which has the same subject as current one."
5741 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5743 (defun gnus-summary-next-unread-same-subject ()
5744 "Select next unread article which has the same subject as current one."
5746 (gnus-summary-next-article t (gnus-summary-article-subject)))
5748 (defun gnus-summary-prev-unread-same-subject ()
5749 "Select previous unread article which has the same subject as current one."
5751 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5753 (defun gnus-summary-first-unread-article ()
5754 "Select the first unread article.
5755 Return nil if there are no unread articles."
5758 (when (gnus-summary-first-subject t)
5759 (gnus-summary-show-thread)
5760 (gnus-summary-first-subject t)
5761 (gnus-summary-display-article (gnus-summary-article-number)))
5762 (gnus-summary-position-point)))
5764 (defun gnus-summary-first-article ()
5765 "Select the first article.
5766 Return nil if there are no articles."
5769 (when (gnus-summary-first-subject)
5770 (gnus-summary-show-thread)
5771 (gnus-summary-first-subject)
5772 (gnus-summary-display-article (gnus-summary-article-number)))
5773 (gnus-summary-position-point)))
5775 (defun gnus-summary-best-unread-article ()
5776 "Select the unread article with the highest score."
5778 (let ((best -1000000)
5779 (data gnus-newsgroup-data)
5782 (and (gnus-data-unread-p (car data))
5784 (gnus-summary-article-score (gnus-data-number (car data))))
5787 article (gnus-data-number (car data))))
5788 (setq data (cdr data)))
5791 (gnus-summary-goto-article article)
5792 (error "No unread articles"))
5793 (gnus-summary-position-point))))
5795 (defun gnus-summary-last-subject ()
5796 "Go to the last displayed subject line in the group."
5797 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5799 (gnus-summary-goto-subject article))))
5801 (defun gnus-summary-goto-article (article &optional all-headers force)
5802 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5803 If ALL-HEADERS is non-nil, no header lines are hidden."
5807 "Article number or Message-ID: "
5808 (mapcar (lambda (number) (list (int-to-string number)))
5809 gnus-newsgroup-limit))
5813 (if (and (stringp article)
5814 (string-match "@" article))
5815 (gnus-summary-refer-article article)
5816 (when (stringp article)
5817 (setq article (string-to-number article)))
5818 (if (gnus-summary-goto-subject article force)
5819 (gnus-summary-display-article article all-headers)
5820 (gnus-message 4 "Couldn't go to article %s" article) nil))
5821 (gnus-summary-position-point)))
5823 (defun gnus-summary-goto-last-article ()
5824 "Go to the previously read article."
5827 (when gnus-last-article
5828 (gnus-summary-goto-article gnus-last-article))
5829 (gnus-summary-position-point)))
5831 (defun gnus-summary-pop-article (number)
5832 "Pop one article off the history and go to the previous.
5833 NUMBER articles will be popped off."
5836 (setq gnus-newsgroup-history
5837 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5839 (gnus-summary-goto-article (car to) nil t)
5840 (error "Article history empty")))
5841 (gnus-summary-position-point))
5843 ;; Summary commands and functions for limiting the summary buffer.
5845 (defun gnus-summary-limit-to-articles (n)
5846 "Limit the summary buffer to the next N articles.
5847 If not given a prefix, use the process marked articles instead."
5850 (let ((articles (gnus-summary-work-articles n)))
5851 (setq gnus-newsgroup-processable nil)
5852 (gnus-summary-limit articles))
5853 (gnus-summary-position-point)))
5855 (defun gnus-summary-pop-limit (&optional total)
5856 "Restore the previous limit.
5857 If given a prefix, remove all limits."
5860 (setq gnus-newsgroup-limits
5861 (list (mapcar (lambda (h) (mail-header-number h))
5862 gnus-newsgroup-headers))))
5863 (unless gnus-newsgroup-limits
5864 (error "No limit to pop"))
5866 (gnus-summary-limit nil 'pop)
5867 (gnus-summary-position-point)))
5869 (defun gnus-summary-limit-to-subject (subject &optional header)
5870 "Limit the summary buffer to articles that have subjects that match a regexp."
5871 (interactive "sLimit to subject (regexp): ")
5873 (setq header "subject"))
5874 (when (not (equal "" subject))
5876 (let ((articles (gnus-summary-find-matching
5877 (or header "subject") subject 'all)))
5879 (error "Found no matches for \"%s\"" subject))
5880 (gnus-summary-limit articles))
5881 (gnus-summary-position-point))))
5883 (defun gnus-summary-limit-to-author (from)
5884 "Limit the summary buffer to articles that have authors that match a regexp."
5885 (interactive "sLimit to author (regexp): ")
5886 (gnus-summary-limit-to-subject from "from"))
5888 (defun gnus-summary-limit-to-age (age &optional younger-p)
5889 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5890 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5891 articles that are younger than AGE days."
5892 (interactive "nTime in days: \nP")
5894 (let ((data gnus-newsgroup-data)
5895 (cutoff (nnmail-days-to-time age))
5896 articles d date is-younger)
5897 (while (setq d (pop data))
5898 (when (and (vectorp (gnus-data-header d))
5899 (setq date (mail-header-date (gnus-data-header d))))
5900 (setq is-younger (nnmail-time-less
5901 (nnmail-time-since (nnmail-date-to-time date))
5903 (when (if younger-p is-younger (not is-younger))
5904 (push (gnus-data-number d) articles))))
5905 (gnus-summary-limit (nreverse articles)))
5906 (gnus-summary-position-point)))
5908 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5910 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5912 (defun gnus-summary-limit-to-unread (&optional all)
5913 "Limit the summary buffer to articles that are not marked as read.
5914 If ALL is non-nil, limit strictly to unread articles."
5917 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5918 (gnus-summary-limit-to-marks
5919 ;; Concat all the marks that say that an article is read and have
5921 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5922 gnus-killed-mark gnus-kill-file-mark
5923 gnus-low-score-mark gnus-expirable-mark
5924 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5925 gnus-duplicate-mark gnus-souped-mark)
5928 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5929 (make-obsolete 'gnus-summary-delete-marked-with
5930 'gnus-summary-limit-exlude-marks)
5932 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5933 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5934 If REVERSE, limit the summary buffer to articles that are marked
5935 with MARKS. MARKS can either be a string of marks or a list of marks.
5936 Returns how many articles were removed."
5937 (interactive "sMarks: ")
5938 (gnus-summary-limit-to-marks marks t))
5940 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5941 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5942 If REVERSE (the prefix), limit the summary buffer to articles that are
5943 not marked with MARKS. MARKS can either be a string of marks or a
5945 Returns how many articles were removed."
5946 (interactive "sMarks: \nP")
5948 (let ((data gnus-newsgroup-data)
5949 (marks (if (listp marks) marks
5950 (append marks nil))) ; Transform to list.
5953 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5954 (memq (gnus-data-mark (car data)) marks))
5955 (push (gnus-data-number (car data)) articles))
5956 (setq data (cdr data)))
5957 (gnus-summary-limit articles))
5958 (gnus-summary-position-point)))
5960 (defun gnus-summary-limit-to-score (&optional score)
5961 "Limit to articles with score at or above SCORE."
5963 (setq score (if score
5964 (prefix-numeric-value score)
5965 (or gnus-summary-default-score 0)))
5966 (let ((data gnus-newsgroup-data)
5969 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5971 (push (gnus-data-number (car data)) articles))
5972 (setq data (cdr data)))
5974 (gnus-summary-limit articles)
5975 (gnus-summary-position-point))))
5977 (defun gnus-summary-limit-include-thread (id)
5978 "Display all the hidden articles that in the current thread."
5979 (interactive (list (mail-header-id (gnus-summary-article-header))))
5980 (let ((articles (gnus-articles-in-thread
5981 (gnus-id-to-thread (gnus-root-id id)))))
5983 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
5984 (gnus-summary-position-point))))
5986 (defun gnus-summary-limit-include-dormant ()
5987 "Display all the hidden articles that are marked as dormant.
5988 Note that this command only works on a subset of the articles currently
5989 fetched for this group."
5991 (unless gnus-newsgroup-dormant
5992 (error "There are no dormant articles in this group"))
5994 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5995 (gnus-summary-position-point)))
5997 (defun gnus-summary-limit-exclude-dormant ()
5998 "Hide all dormant articles."
6001 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6002 (gnus-summary-position-point)))
6004 (defun gnus-summary-limit-exclude-childless-dormant ()
6005 "Hide all dormant articles that have no children."
6007 (let ((data (gnus-data-list t))
6008 articles d children)
6009 ;; Find all articles that are either not dormant or have
6011 (while (setq d (pop data))
6012 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6014 (gnus-article-children (gnus-data-number d)))
6017 (when (memq (car children) articles)
6022 (push (gnus-data-number d) articles)))
6025 (gnus-summary-limit articles)
6026 (gnus-summary-position-point))))
6028 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6029 "Mark all unread excluded articles as read.
6030 If ALL, mark even excluded ticked and dormants as read."
6032 (let ((articles (gnus-sorted-complement
6034 (mapcar (lambda (h) (mail-header-number h))
6035 gnus-newsgroup-headers)
6037 (sort gnus-newsgroup-limit '<)))
6039 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6041 (setq gnus-newsgroup-dormant nil
6042 gnus-newsgroup-marked nil
6043 gnus-newsgroup-reads
6045 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6046 gnus-newsgroup-reads))
6047 (while (setq article (pop articles))
6048 (unless (or (memq article gnus-newsgroup-dormant)
6049 (memq article gnus-newsgroup-marked))
6050 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6052 (defun gnus-summary-limit (articles &optional pop)
6054 ;; We pop the previous limit off the stack and use that.
6055 (setq articles (car gnus-newsgroup-limits)
6056 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6057 ;; We use the new limit, so we push the old limit on the stack.
6058 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6060 (setq gnus-newsgroup-limit articles)
6061 (let ((total (length gnus-newsgroup-data))
6062 (data (gnus-data-find-list (gnus-summary-article-number)))
6063 (gnus-summary-mark-below nil) ; Inhibit this.
6065 ;; This will do all the work of generating the new summary buffer
6066 ;; according to the new limit.
6067 (gnus-summary-prepare)
6068 ;; Hide any threads, possibly.
6069 (and gnus-show-threads
6070 gnus-thread-hide-subtree
6071 (gnus-summary-hide-all-threads))
6072 ;; Try to return to the article you were at, or one in the
6075 ;; We try to find some article after the current one.
6077 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6080 (setq data (cdr data))))
6082 ;; If there is no data, that means that we were after the last
6083 ;; article. The same goes when we can't find any articles
6084 ;; after the current one.
6085 (goto-char (point-max))
6086 (gnus-summary-find-prev))
6087 ;; We return how many articles were removed from the summary
6088 ;; buffer as a result of the new limit.
6089 (- total (length gnus-newsgroup-data))))
6091 (defsubst gnus-invisible-cut-children (threads)
6094 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6099 (defsubst gnus-cut-thread (thread)
6100 "Go forwards in the thread until we find an article that we want to display."
6101 (when (or (eq gnus-fetch-old-headers 'some)
6102 (eq gnus-fetch-old-headers 'invisible)
6103 (eq gnus-build-sparse-threads 'some)
6104 (eq gnus-build-sparse-threads 'more))
6105 ;; Deal with old-fetched headers and sparse threads.
6109 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6110 (gnus-summary-article-ancient-p
6111 (mail-header-number (car thread))))
6112 (if (or (<= (length (cdr thread)) 1)
6113 (eq gnus-fetch-old-headers 'invisible))
6114 (setq gnus-newsgroup-limit
6115 (delq (mail-header-number (car thread))
6116 gnus-newsgroup-limit)
6117 thread (cadr thread))
6118 (when (gnus-invisible-cut-children (cdr thread))
6119 (let ((th (cdr thread)))
6121 (if (memq (mail-header-number (caar th))
6122 gnus-newsgroup-limit)
6123 (setq thread (car th)
6125 (setq th (cdr th))))))))))
6128 (defun gnus-cut-threads (threads)
6129 "Cut off all uninteresting articles from the beginning of threads."
6130 (when (or (eq gnus-fetch-old-headers 'some)
6131 (eq gnus-fetch-old-headers 'invisible)
6132 (eq gnus-build-sparse-threads 'some)
6133 (eq gnus-build-sparse-threads 'more))
6136 (setcar th (gnus-cut-thread (car th)))
6137 (setq th (cdr th)))))
6138 ;; Remove nixed out threads.
6141 (defun gnus-summary-initial-limit (&optional show-if-empty)
6142 "Figure out what the initial limit is supposed to be on group entry.
6143 This entails weeding out unwanted dormants, low-scored articles,
6144 fetch-old-headers verbiage, and so on."
6145 ;; Most groups have nothing to remove.
6146 (if (or gnus-inhibit-limiting
6147 (and (null gnus-newsgroup-dormant)
6148 (not (eq gnus-fetch-old-headers 'some))
6149 (not (eq gnus-fetch-old-headers 'invisible))
6150 (null gnus-summary-expunge-below)
6151 (not (eq gnus-build-sparse-threads 'some))
6152 (not (eq gnus-build-sparse-threads 'more))
6153 (null gnus-thread-expunge-below)
6154 (not gnus-use-nocem)))
6156 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6157 (setq gnus-newsgroup-limit nil)
6160 (unless (car (symbol-value node))
6161 ;; These threads have no parents -- they are roots.
6162 (let ((nodes (cdr (symbol-value node)))
6165 (if (and gnus-thread-expunge-below
6166 (< (gnus-thread-total-score (car nodes))
6167 gnus-thread-expunge-below))
6168 (gnus-expunge-thread (pop nodes))
6169 (setq thread (pop nodes))
6170 (gnus-summary-limit-children thread))))))
6171 gnus-newsgroup-dependencies)
6172 ;; If this limitation resulted in an empty group, we might
6173 ;; pop the previous limit and use it instead.
6174 (when (and (not gnus-newsgroup-limit)
6176 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6177 gnus-newsgroup-limit))
6179 (defun gnus-summary-limit-children (thread)
6180 "Return 1 if this subthread is visible and 0 if it is not."
6181 ;; First we get the number of visible children to this thread. This
6182 ;; is done by recursing down the thread using this function, so this
6183 ;; will really go down to a leaf article first, before slowly
6184 ;; working its way up towards the root.
6188 (apply '+ (mapcar 'gnus-summary-limit-children
6191 (number (mail-header-number (car thread)))
6194 (not (memq number gnus-newsgroup-marked))
6196 ;; If this article is dormant and has absolutely no visible
6197 ;; children, then this article isn't visible.
6198 (and (memq number gnus-newsgroup-dormant)
6200 ;; If this is "fetch-old-headered" and there is no
6201 ;; visible children, then we don't want this article.
6202 (and (eq gnus-fetch-old-headers 'some)
6203 (gnus-summary-article-ancient-p number)
6205 ;; If this is "fetch-old-headered" and `invisible', then
6206 ;; we don't want this article.
6207 (and (eq gnus-fetch-old-headers 'invisible)
6208 (gnus-summary-article-ancient-p number))
6209 ;; If this is a sparsely inserted article with no children,
6210 ;; we don't want it.
6211 (and (eq gnus-build-sparse-threads 'some)
6212 (gnus-summary-article-sparse-p number)
6214 ;; If we use expunging, and this article is really
6215 ;; low-scored, then we don't want this article.
6216 (when (and gnus-summary-expunge-below
6218 (or (cdr (assq number gnus-newsgroup-scored))
6219 gnus-summary-default-score))
6220 gnus-summary-expunge-below))
6221 ;; We increase the expunge-tally here, but that has
6222 ;; nothing to do with the limits, really.
6223 (incf gnus-newsgroup-expunged-tally)
6224 ;; We also mark as read here, if that's wanted.
6225 (when (and gnus-summary-mark-below
6226 (< score gnus-summary-mark-below))
6227 (setq gnus-newsgroup-unreads
6228 (delq number gnus-newsgroup-unreads))
6229 (if gnus-newsgroup-auto-expire
6230 (push number gnus-newsgroup-expirable)
6231 (push (cons number gnus-low-score-mark)
6232 gnus-newsgroup-reads)))
6234 ;; Check NoCeM things.
6235 (if (and gnus-use-nocem
6236 (gnus-nocem-unwanted-article-p
6237 (mail-header-id (car thread))))
6239 (setq gnus-newsgroup-unreads
6240 (delq number gnus-newsgroup-unreads))
6242 ;; Nope, invisible article.
6244 ;; Ok, this article is to be visible, so we add it to the limit
6246 (push number gnus-newsgroup-limit)
6249 (defun gnus-expunge-thread (thread)
6250 "Mark all articles in THREAD as read."
6251 (let* ((number (mail-header-number (car thread))))
6252 (incf gnus-newsgroup-expunged-tally)
6253 ;; We also mark as read here, if that's wanted.
6254 (setq gnus-newsgroup-unreads
6255 (delq number gnus-newsgroup-unreads))
6256 (if gnus-newsgroup-auto-expire
6257 (push number gnus-newsgroup-expirable)
6258 (push (cons number gnus-low-score-mark)
6259 gnus-newsgroup-reads)))
6260 ;; Go recursively through all subthreads.
6261 (mapcar 'gnus-expunge-thread (cdr thread)))
6263 ;; Summary article oriented commands
6265 (defun gnus-summary-refer-parent-article (n)
6266 "Refer parent article N times.
6267 If N is negative, go to ancestor -N instead.
6268 The difference between N and the number of articles fetched is returned."
6272 (when (not (natnump n))
6277 (setq header (gnus-summary-article-header))
6278 (if (and (eq (mail-header-number header)
6279 (cdr gnus-article-current))
6280 (equal gnus-newsgroup-name
6281 (car gnus-article-current)))
6282 ;; If we try to find the parent of the currently
6283 ;; displayed article, then we take a look at the actual
6284 ;; References header, since this is slightly more
6285 ;; reliable than the References field we got from the
6288 (set-buffer gnus-original-article-buffer)
6289 (nnheader-narrow-to-headers)
6290 (unless (setq ref (message-fetch-field "references"))
6291 (setq ref (message-fetch-field "in-reply-to")))
6294 ;; It's not the current article, so we take a bet on
6295 ;; the value we got from the server.
6296 (mail-header-references header)))
6298 (not (equal ref "")))
6299 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6300 (gnus-message 1 "Couldn't find parent"))
6301 (gnus-message 1 "No references in article %d"
6302 (gnus-summary-article-number))
6305 (gnus-summary-position-point)
6308 (defun gnus-summary-refer-references ()
6309 "Fetch all articles mentioned in the References header.
6310 Return the number of articles fetched."
6312 (let ((ref (mail-header-references (gnus-summary-article-header)))
6313 (current (gnus-summary-article-number))
6317 (error "No References in the current article")
6318 ;; For each Message-ID in the References header...
6319 (while (string-match "<[^>]*>" ref)
6321 ;; ... fetch that article.
6322 (gnus-summary-refer-article
6323 (prog1 (match-string 0 ref)
6324 (setq ref (substring ref (match-end 0))))))
6325 (gnus-summary-goto-subject current)
6326 (gnus-summary-position-point)
6329 (defun gnus-summary-refer-thread (&optional limit)
6330 "Fetch all articles in the current thread.
6331 If LIMIT (the numerical prefix), fetch that many old headers instead
6332 of what's specified by the `gnus-refer-thread-limit' variable."
6334 (let ((id (mail-header-id (gnus-summary-article-header)))
6335 (limit (if limit (prefix-numeric-value limit)
6336 gnus-refer-thread-limit))
6338 ;; We want to fetch LIMIT *old* headers, but we also have to
6339 ;; re-fetch all the headers in the current buffer, because many of
6340 ;; them may be undisplayed. So we adjust LIMIT.
6341 (when (numberp limit)
6342 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6343 (unless (eq gnus-fetch-old-headers 'invisible)
6344 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6345 ;; Retrieve the headers and read them in.
6346 (if (eq (gnus-retrieve-headers
6347 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6349 (gnus-build-all-threads)
6350 (error "Can't fetch thread from backends that don't support NOV"))
6351 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6352 (gnus-summary-limit-include-thread id)))
6354 (defun gnus-summary-refer-article (message-id &optional arg)
6355 "Fetch an article specified by MESSAGE-ID.
6356 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6357 or `gnus-select-method', no matter what backend the article comes from."
6358 (interactive "sMessage-ID: \nP")
6359 (when (and (stringp message-id)
6360 (not (zerop (length message-id))))
6361 ;; Construct the correct Message-ID if necessary.
6362 ;; Suggested by tale@pawl.rpi.edu.
6363 (unless (string-match "^<" message-id)
6364 (setq message-id (concat "<" message-id)))
6365 (unless (string-match ">$" message-id)
6366 (setq message-id (concat message-id ">")))
6367 (let* ((header (gnus-id-to-header message-id))
6369 (gnus-summary-article-sparse-p
6370 (mail-header-number header))
6371 (memq (mail-header-number header)
6372 gnus-newsgroup-limit)))
6375 ;; If the article is present in the buffer we just go to it.
6377 (or (not (gnus-summary-article-sparse-p
6378 (mail-header-number header)))
6381 (gnus-summary-goto-article
6382 (mail-header-number header) nil t)
6384 (gnus-summary-update-article (mail-header-number header)))))
6386 ;; We fetch the article
6387 (let ((gnus-override-method
6388 (cond ((gnus-news-group-p gnus-newsgroup-name)
6389 gnus-refer-article-method)
6391 (or gnus-refer-article-method gnus-select-method))
6394 ;; Start the special refer-article method, if necessary.
6395 (when (and gnus-refer-article-method
6396 (gnus-news-group-p gnus-newsgroup-name))
6397 (gnus-check-server gnus-refer-article-method))
6398 ;; Fetch the header, and display the article.
6399 (if (setq number (gnus-summary-insert-subject message-id))
6400 (gnus-summary-select-article nil nil nil number)
6401 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6403 (defun gnus-summary-enter-digest-group (&optional force)
6404 "Enter an nndoc group based on the current article.
6405 If FORCE, force a digest interpretation. If not, try
6406 to guess what the document format is."
6408 (let ((conf gnus-current-window-configuration))
6410 (gnus-summary-select-article))
6411 (setq gnus-current-window-configuration conf)
6412 (let* ((name (format "%s-%d"
6413 (gnus-group-prefixed-name
6414 gnus-newsgroup-name (list 'nndoc ""))
6416 (set-buffer gnus-summary-buffer)
6417 gnus-current-article)))
6418 (ogroup gnus-newsgroup-name)
6419 (params (append (gnus-info-params (gnus-get-info ogroup))
6420 (list (cons 'to-group ogroup))
6421 (list (cons 'save-article-group ogroup))))
6422 (case-fold-search t)
6423 (buf (current-buffer))
6426 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6427 (insert-buffer-substring gnus-original-article-buffer)
6428 ;; Remove lines that may lead nndoc to misinterpret the
6431 (goto-char (point-min))
6432 (or (search-forward "\n\n" nil t) (point)))
6433 (goto-char (point-min))
6434 (delete-matching-lines "^\\(Path\\):\\|^From ")
6437 (if (gnus-group-read-ephemeral-group
6438 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6440 ,(if force 'digest 'guess))) t)
6441 ;; Make all postings to this group go to the parent group.
6442 (nconc (gnus-info-params (gnus-get-info name))
6444 ;; Couldn't select this doc group.
6445 (switch-to-buffer buf)
6446 (gnus-set-global-variables)
6447 (gnus-configure-windows 'summary)
6448 (gnus-message 3 "Article couldn't be entered?"))
6449 (kill-buffer dig)))))
6451 (defun gnus-summary-read-document (n)
6452 "Open a new group based on the current article(s).
6453 This will allow you to read digests and other similar
6454 documents as newsgroups.
6455 Obeys the standard process/prefix convention."
6457 (let* ((articles (gnus-summary-work-articles n))
6458 (ogroup gnus-newsgroup-name)
6459 (params (append (gnus-info-params (gnus-get-info ogroup))
6460 (list (cons 'to-group ogroup))))
6461 article group egroup groups vgroup)
6462 (while (setq article (pop articles))
6463 (setq group (format "%s-%d" gnus-newsgroup-name article))
6464 (gnus-summary-remove-process-mark article)
6465 (when (gnus-summary-display-article article)
6467 (nnheader-temp-write nil
6468 (insert-buffer-substring gnus-original-article-buffer)
6469 ;; Remove some headers that may lead nndoc to make
6471 (message-narrow-to-head)
6472 (goto-char (point-min))
6473 (delete-matching-lines "^\\(Path\\):\\|^From ")
6476 (gnus-group-read-ephemeral-group
6477 group `(nndoc ,group (nndoc-address ,(current-buffer))
6478 (nndoc-article-type guess))
6481 ;; Make all postings to this group go to the parent group.
6482 (nconc (gnus-info-params (gnus-get-info egroup))
6484 (push egroup groups))
6485 ;; Couldn't select this doc group.
6486 (gnus-error 3 "Article couldn't be entered"))))))
6487 ;; Now we have selected all the documents.
6490 (error "None of the articles could be interpreted as documents"))
6491 ((gnus-group-read-ephemeral-group
6492 (setq vgroup (format
6493 "nnvirtual:%s-%s" gnus-newsgroup-name
6494 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6495 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6497 (cons (current-buffer) 'summary)))
6499 (error "Couldn't select virtual nndoc group")))))
6501 (defun gnus-summary-isearch-article (&optional regexp-p)
6502 "Do incremental search forward on the current article.
6503 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6505 (gnus-summary-select-article)
6506 (gnus-configure-windows 'article)
6507 (gnus-eval-in-buffer-window gnus-article-buffer
6510 (isearch-forward regexp-p))))
6512 (defun gnus-summary-search-article-forward (regexp &optional backward)
6513 "Search for an article containing REGEXP forward.
6514 If BACKWARD, search backward instead."
6517 (format "Search article %s (regexp%s): "
6518 (if current-prefix-arg "backward" "forward")
6519 (if gnus-last-search-regexp
6520 (concat ", default " gnus-last-search-regexp)
6522 current-prefix-arg))
6523 (if (string-equal regexp "")
6524 (setq regexp (or gnus-last-search-regexp ""))
6525 (setq gnus-last-search-regexp regexp))
6526 (if (gnus-summary-search-article regexp backward)
6527 (gnus-summary-show-thread)
6528 (error "Search failed: \"%s\"" regexp)))
6530 (defun gnus-summary-search-article-backward (regexp)
6531 "Search for an article containing REGEXP backward."
6534 (format "Search article backward (regexp%s): "
6535 (if gnus-last-search-regexp
6536 (concat ", default " gnus-last-search-regexp)
6538 (gnus-summary-search-article-forward regexp 'backward))
6540 (defun gnus-summary-search-article (regexp &optional backward)
6541 "Search for an article containing REGEXP.
6542 Optional argument BACKWARD means do search for backward.
6543 `gnus-select-article-hook' is not called during the search."
6544 ;; We have to require this here to make sure that the following
6545 ;; dynamic binding isn't shadowed by autoloading.
6546 (require 'gnus-async)
6547 (let ((gnus-select-article-hook nil) ;Disable hook.
6548 (gnus-article-display-hook nil)
6549 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6550 (gnus-use-article-prefetch nil)
6551 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6552 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6553 (sum (current-buffer))
6556 (gnus-save-hidden-threads
6557 (gnus-summary-select-article)
6558 (set-buffer gnus-article-buffer)
6562 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6564 (re-search-backward regexp nil t)
6565 (re-search-forward regexp nil t))
6566 ;; We found the regexp.
6571 (get-buffer-window (current-buffer))
6575 (setq point (point)))
6576 ;; We didn't find it, so we go to the next article.
6579 (while (eq found 'not)
6580 (if (not (if backward (gnus-summary-find-prev)
6581 (gnus-summary-find-next)))
6582 ;; No more articles.
6584 ;; Select the next article and adjust point.
6585 (unless (gnus-summary-article-sparse-p
6586 (gnus-summary-article-number))
6588 (gnus-summary-select-article)
6589 (set-buffer gnus-article-buffer)
6591 (goto-char (if backward (point-max) (point-min))))))))
6592 (gnus-message 7 ""))
6593 ;; Return whether we found the regexp.
6594 (when (eq found 'found)
6596 (gnus-summary-show-thread)
6597 (gnus-summary-goto-subject gnus-current-article)
6598 (gnus-summary-position-point)
6601 (defun gnus-summary-find-matching (header regexp &optional backward unread
6603 "Return a list of all articles that match REGEXP on HEADER.
6604 The search stars on the current article and goes forwards unless
6605 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6606 If UNREAD is non-nil, only unread articles will
6607 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6608 in the comparisons."
6609 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6610 (gnus-data-find-list
6611 (gnus-summary-article-number) (gnus-data-list backward))))
6612 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6613 (case-fold-search (not not-case-fold))
6615 (unless (fboundp (intern (concat "mail-header-" header)))
6616 (error "%s is not a valid header" header))
6619 (and (or (not unread) ; We want all articles...
6620 (gnus-data-unread-p d)) ; Or just unreads.
6621 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6622 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6623 (push (gnus-data-number d) articles)) ; Success!
6624 (setq data (cdr data)))
6625 (nreverse articles)))
6627 (defun gnus-summary-execute-command (header regexp command &optional backward)
6628 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6629 If HEADER is an empty string (or nil), the match is done on the entire
6630 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6632 (list (let ((completion-ignore-case t))
6635 (mapcar (lambda (string) (list string))
6636 '("Number" "Subject" "From" "Lines" "Date"
6637 "Message-ID" "Xref" "References" "Body"))
6638 nil 'require-match))
6639 (read-string "Regexp: ")
6640 (read-key-sequence "Command: ")
6641 current-prefix-arg))
6642 (when (equal header "Body")
6644 ;; Hidden thread subtrees must be searched as well.
6645 (gnus-summary-show-all-threads)
6646 ;; We don't want to change current point nor window configuration.
6648 (save-window-excursion
6649 (gnus-message 6 "Executing %s..." (key-description command))
6650 ;; We'd like to execute COMMAND interactively so as to give arguments.
6651 (gnus-execute header regexp
6652 `(call-interactively ',(key-binding command))
6654 (gnus-message 6 "Executing %s...done" (key-description command)))))
6656 (defun gnus-summary-beginning-of-article ()
6657 "Scroll the article back to the beginning."
6659 (gnus-summary-select-article)
6660 (gnus-configure-windows 'article)
6661 (gnus-eval-in-buffer-window gnus-article-buffer
6663 (goto-char (point-min))
6664 (when gnus-page-broken
6665 (gnus-narrow-to-page))))
6667 (defun gnus-summary-end-of-article ()
6668 "Scroll to the end of the article."
6670 (gnus-summary-select-article)
6671 (gnus-configure-windows 'article)
6672 (gnus-eval-in-buffer-window gnus-article-buffer
6674 (goto-char (point-max))
6676 (when gnus-page-broken
6677 (gnus-narrow-to-page))))
6679 (defun gnus-summary-print-article (&optional filename)
6680 "Generate and print a PostScript image of the article buffer.
6682 If the optional argument FILENAME is nil, send the image to the printer.
6683 If FILENAME is a string, save the PostScript image in a file with that
6684 name. If FILENAME is a number, prompt the user for the name of the file
6686 (interactive (list (ps-print-preprint current-prefix-arg)))
6687 (gnus-summary-select-article)
6688 (gnus-eval-in-buffer-window gnus-article-buffer
6689 (let ((buffer (generate-new-buffer " *print*")))
6692 (copy-to-buffer buffer (point-min) (point-max))
6694 (gnus-article-delete-invisible-text)
6695 (run-hooks 'gnus-ps-print-hook)
6696 (ps-print-buffer-with-faces filename))
6697 (kill-buffer buffer)))))
6699 (defun gnus-summary-show-article (&optional arg)
6700 "Force re-fetching of the current article.
6701 If ARG (the prefix) is non-nil, show the raw article without any
6702 article massaging functions being run."
6705 ;; Select the article the normal way.
6706 (gnus-summary-select-article nil 'force)
6707 ;; Bind the article treatment functions to nil.
6708 (let ((gnus-have-all-headers t)
6709 gnus-article-display-hook
6710 gnus-article-prepare-hook
6714 (gnus-summary-select-article nil 'force)))
6715 (gnus-summary-goto-subject gnus-current-article)
6716 (gnus-summary-position-point))
6718 (defun gnus-summary-verbose-headers (&optional arg)
6719 "Toggle permanent full header display.
6720 If ARG is a positive number, turn header display on.
6721 If ARG is a negative number, turn header display off."
6723 (setq gnus-show-all-headers
6724 (cond ((or (not (numberp arg))
6726 (not gnus-show-all-headers))
6729 (gnus-summary-show-article))
6731 (defun gnus-summary-toggle-header (&optional arg)
6732 "Show the headers if they are hidden, or hide them if they are shown.
6733 If ARG is a positive number, show the entire header.
6734 If ARG is a negative number, hide the unwanted header lines."
6737 (set-buffer gnus-article-buffer)
6738 (let* ((buffer-read-only nil)
6739 (inhibit-point-motion-hooks t)
6740 (hidden (text-property-any
6741 (goto-char (point-min)) (search-forward "\n\n")
6744 (goto-char (point-min))
6745 (when (search-forward "\n\n" nil t)
6746 (delete-region (point-min) (1- (point))))
6747 (goto-char (point-min))
6749 (set-buffer gnus-original-article-buffer)
6750 (goto-char (point-min))
6751 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6752 (insert-buffer-substring gnus-original-article-buffer 1 e)
6753 (let ((article-inhibit-hiding t))
6754 (run-hooks 'gnus-article-display-hook))
6755 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6756 (gnus-article-hide-headers)))))
6758 (defun gnus-summary-show-all-headers ()
6759 "Make all header lines visible."
6761 (gnus-article-show-all-headers))
6763 (defun gnus-summary-toggle-mime (&optional arg)
6764 "Toggle MIME processing.
6765 If ARG is a positive number, turn MIME processing on."
6767 (setq gnus-show-mime
6768 (if (null arg) (not gnus-show-mime)
6769 (> (prefix-numeric-value arg) 0)))
6770 (gnus-summary-select-article t 'force))
6772 (defun gnus-summary-caesar-message (&optional arg)
6773 "Caesar rotate the current article by 13.
6774 The numerical prefix specifies how many places to rotate each letter
6777 (gnus-summary-select-article)
6778 (let ((mail-header-separator ""))
6779 (gnus-eval-in-buffer-window gnus-article-buffer
6782 (let ((start (window-start))
6784 (message-caesar-buffer-body arg)
6785 (set-window-start (get-buffer-window (current-buffer)) start))))))
6787 (defun gnus-summary-stop-page-breaking ()
6788 "Stop page breaking in the current article."
6790 (gnus-summary-select-article)
6791 (gnus-eval-in-buffer-window gnus-article-buffer
6793 (when (gnus-visual-p 'page-marker)
6794 (let ((buffer-read-only nil))
6795 (gnus-remove-text-with-property 'gnus-prev)
6796 (gnus-remove-text-with-property 'gnus-next)))))
6798 (defun gnus-summary-move-article (&optional n to-newsgroup
6799 select-method action)
6800 "Move the current article to a different newsgroup.
6801 If N is a positive number, move the N next articles.
6802 If N is a negative number, move the N previous articles.
6803 If N is nil and any articles have been marked with the process mark,
6804 move those articles instead.
6805 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6806 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6807 re-spool using this method.
6809 For this function to work, both the current newsgroup and the
6810 newsgroup that you want to move to have to support the `request-move'
6811 and `request-accept' functions."
6814 (setq action 'move))
6815 ;; Disable marking as read.
6816 (let (gnus-mark-article-hook)
6817 (save-window-excursion
6818 (gnus-summary-select-article)))
6819 ;; Check whether the source group supports the required functions.
6820 (cond ((and (eq action 'move)
6821 (not (gnus-check-backend-function
6822 'request-move-article gnus-newsgroup-name)))
6823 (error "The current group does not support article moving"))
6824 ((and (eq action 'crosspost)
6825 (not (gnus-check-backend-function
6826 'request-replace-article gnus-newsgroup-name)))
6827 (error "The current group does not support article editing")))
6828 (let ((articles (gnus-summary-work-articles n))
6829 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6830 (names '((move "Move" "Moving")
6831 (copy "Copy" "Copying")
6832 (crosspost "Crosspost" "Crossposting")))
6833 (copy-buf (save-excursion
6834 (nnheader-set-temp-buffer " *copy article*")))
6835 art-group to-method new-xref article to-groups)
6836 (unless (assq action names)
6837 (error "Unknown action %s" action))
6838 ;; Read the newsgroup name.
6839 (when (and (not to-newsgroup)
6840 (not select-method))
6842 (gnus-read-move-group-name
6843 (cadr (assq action names))
6844 (symbol-value (intern (format "gnus-current-%s-group" action)))
6846 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6847 (setq to-method (or select-method
6848 (gnus-group-name-to-method to-newsgroup)))
6849 ;; Check the method we are to move this article to...
6850 (unless (gnus-check-backend-function
6851 'request-accept-article (car to-method))
6852 (error "%s does not support article copying" (car to-method)))
6853 (unless (gnus-check-server to-method)
6854 (error "Can't open server %s" (car to-method)))
6855 (gnus-message 6 "%s to %s: %s..."
6856 (caddr (assq action names))
6857 (or (car select-method) to-newsgroup) articles)
6859 (setq article (pop articles))
6863 ;; Move the article.
6865 ;; Remove this article from future suppression.
6866 (gnus-dup-unsuppress-article article)
6867 (gnus-request-move-article
6868 article ; Article to move
6869 gnus-newsgroup-name ; From newsgroup
6870 (nth 1 (gnus-find-method-for-group
6871 gnus-newsgroup-name)) ; Server
6872 (list 'gnus-request-accept-article
6873 to-newsgroup (list 'quote select-method)
6874 (not articles)) ; Accept form
6875 (not articles))) ; Only save nov last time
6876 ;; Copy the article.
6879 (set-buffer copy-buf)
6880 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6881 (gnus-request-accept-article
6882 to-newsgroup select-method (not articles)))))
6883 ;; Crosspost the article.
6884 ((eq action 'crosspost)
6885 (let ((xref (message-tokenize-header
6886 (mail-header-xref (gnus-summary-article-header article))
6888 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6891 (setq xref (list (system-name))))
6894 (mapconcat 'identity
6895 (delete "Xref:" (delete new-xref xref))
6899 (set-buffer copy-buf)
6900 ;; First put the article in the destination group.
6901 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6902 (when (consp (setq art-group
6903 (gnus-request-accept-article
6904 to-newsgroup select-method (not articles))))
6905 (setq new-xref (concat new-xref " " (car art-group)
6906 ":" (cdr art-group)))
6907 ;; Now we have the new Xrefs header, so we insert
6908 ;; it and replace the new article.
6909 (nnheader-replace-header "Xref" new-xref)
6910 (gnus-request-replace-article
6911 (cdr art-group) to-newsgroup (current-buffer))
6915 (gnus-message 1 "Couldn't %s article %s"
6916 (cadr (assq action names)) article))
6917 ((and (eq art-group 'junk)
6919 (gnus-summary-mark-article article gnus-canceled-mark)
6920 (gnus-message 4 "Deleted article %s" article))
6924 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6926 (gnus-group-prefixed-name
6929 (gnus-find-method-for-group to-newsgroup)))
6930 gnus-newsrc-hashtb)))
6931 (info (nth 2 entry))
6932 (to-group (gnus-info-group info)))
6933 ;; Update the group that has been moved to.
6935 (memq action '(move copy)))
6936 (unless (member to-group to-groups)
6937 (push to-group to-groups))
6939 (unless (memq article gnus-newsgroup-unreads)
6941 info (gnus-add-to-range (gnus-info-read info)
6942 (list (cdr art-group)))))
6944 ;; Copy any marks over to the new group.
6945 (let ((marks gnus-article-mark-lists)
6946 (to-article (cdr art-group)))
6948 ;; See whether the article is to be put in the cache.
6949 (when gnus-use-cache
6950 (gnus-cache-possibly-enter-article
6952 (let ((header (copy-sequence
6953 (gnus-summary-article-header article))))
6954 (mail-header-set-number header to-article)
6956 (memq article gnus-newsgroup-marked)
6957 (memq article gnus-newsgroup-dormant)
6958 (memq article gnus-newsgroup-unreads)))
6960 (when (and (equal to-group gnus-newsgroup-name)
6961 (not (memq article gnus-newsgroup-unreads)))
6962 ;; Mark this article as read in this group.
6963 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6964 (setcdr (gnus-active to-group) to-article)
6965 (setcdr gnus-newsgroup-active to-article))
6968 (when (memq article (symbol-value
6969 (intern (format "gnus-newsgroup-%s"
6971 ;; If the other group is the same as this group,
6972 ;; then we have to add the mark to the list.
6973 (when (equal to-group gnus-newsgroup-name)
6974 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6977 (intern (format "gnus-newsgroup-%s"
6979 ;; Copy the marks to other group.
6980 (gnus-add-marked-articles
6981 to-group (cdar marks) (list to-article) info))
6982 (setq marks (cdr marks)))
6985 (concat "(gnus-group-set-info '"
6986 (gnus-prin1-to-string (gnus-get-info to-group))
6989 ;; Update the Xref header in this article to point to
6990 ;; the new crossposted article we have just created.
6991 (when (eq action 'crosspost)
6993 (set-buffer copy-buf)
6994 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6995 (nnheader-replace-header "Xref" new-xref)
6996 (gnus-request-replace-article
6997 article gnus-newsgroup-name (current-buffer)))))
6999 (gnus-summary-goto-subject article)
7000 (when (eq action 'move)
7001 (gnus-summary-mark-article article gnus-canceled-mark))))
7002 (gnus-summary-remove-process-mark article))
7003 ;; Re-activate all groups that have been moved to.
7006 (set-buffer gnus-group-buffer)
7007 (when (gnus-group-goto-group (car to-groups) t)
7008 (gnus-group-get-new-news-this-group 1 t))
7011 (gnus-kill-buffer copy-buf)
7012 (gnus-summary-position-point)
7013 (gnus-set-mode-line 'summary)))
7015 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7016 "Move the current article to a different newsgroup.
7017 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7018 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7019 re-spool using this method."
7021 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7023 (defun gnus-summary-crosspost-article (&optional n)
7024 "Crosspost the current article to some other group."
7026 (gnus-summary-move-article n nil nil 'crosspost))
7028 (defcustom gnus-summary-respool-default-method nil
7029 "Default method for respooling an article.
7030 If nil, use to the current newsgroup method."
7031 :type `(choice (gnus-select-method :value (nnml ""))
7033 :group 'gnus-summary-mail)
7035 (defun gnus-summary-respool-article (&optional n method)
7036 "Respool the current article.
7037 The article will be squeezed through the mail spooling process again,
7038 which means that it will be put in some mail newsgroup or other
7039 depending on `nnmail-split-methods'.
7040 If N is a positive number, respool the N next articles.
7041 If N is a negative number, respool the N previous articles.
7042 If N is nil and any articles have been marked with the process mark,
7043 respool those articles instead.
7045 Respooling can be done both from mail groups and \"real\" newsgroups.
7046 In the former case, the articles in question will be moved from the
7047 current group into whatever groups they are destined to. In the
7048 latter case, they will be copied into the relevant groups."
7050 (list current-prefix-arg
7051 (let* ((methods (gnus-methods-using 'respool))
7053 (symbol-name (or gnus-summary-respool-default-method
7054 (car (gnus-find-method-for-group
7055 gnus-newsgroup-name)))))
7057 (gnus-completing-read
7058 methname "What backend do you want to use when respooling?"
7059 methods nil t nil 'gnus-mail-method-history))
7062 ((zerop (length (setq ms (gnus-servers-using-backend
7064 (list (intern method) ""))
7068 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7069 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7072 (error "No method given for respooling"))
7073 (if (assoc (symbol-name
7074 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7075 (gnus-methods-using 'respool))
7076 (gnus-summary-move-article n nil method)
7077 (gnus-summary-copy-article n nil method)))
7079 (defun gnus-summary-import-article (file)
7080 "Import a random file into a mail newsgroup."
7081 (interactive "fImport file: ")
7082 (let ((group gnus-newsgroup-name)
7083 (now (current-time))
7085 (unless (gnus-check-backend-function 'request-accept-article group)
7086 (error "%s does not support article importing" group))
7087 (or (file-readable-p file)
7088 (not (file-regular-p file))
7089 (error "Can't read %s" file))
7091 (set-buffer (get-buffer-create " *import file*"))
7092 (buffer-disable-undo (current-buffer))
7094 (insert-file-contents file)
7095 (goto-char (point-min))
7096 (unless (nnheader-article-p)
7097 ;; This doesn't look like an article, so we fudge some headers.
7098 (setq atts (file-attributes file)
7099 lines (count-lines (point-min) (point-max)))
7100 (insert "From: " (read-string "From: ") "\n"
7101 "Subject: " (read-string "Subject: ") "\n"
7102 "Date: " (timezone-make-date-arpa-standard
7103 (current-time-string (nth 5 atts))
7104 (current-time-zone now)
7105 (current-time-zone now))
7107 "Message-ID: " (message-make-message-id) "\n"
7108 "Lines: " (int-to-string lines) "\n"
7109 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7110 (gnus-request-accept-article group nil t)
7111 (kill-buffer (current-buffer)))))
7113 (defun gnus-summary-article-posted-p ()
7114 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7115 This will be the case if the article has both been mailed and posted."
7117 (let ((id (mail-header-references (gnus-summary-article-header)))
7118 (gnus-override-method
7119 (or gnus-refer-article-method gnus-select-method)))
7120 (if (gnus-request-head id "")
7121 (gnus-message 2 "The current message was found on %s"
7122 gnus-override-method)
7123 (gnus-message 2 "The current message couldn't be found on %s"
7124 gnus-override-method)
7127 (defun gnus-summary-expire-articles (&optional now)
7128 "Expire all articles that are marked as expirable in the current group."
7130 (when (gnus-check-backend-function
7131 'request-expire-articles gnus-newsgroup-name)
7132 ;; This backend supports expiry.
7133 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7134 (expirable (if total
7136 ;; We need to update the info for
7137 ;; this group for `gnus-list-of-read-articles'
7138 ;; to give us the right answer.
7139 (run-hooks 'gnus-exit-group-hook)
7140 (gnus-summary-update-info)
7141 (gnus-list-of-read-articles gnus-newsgroup-name))
7142 (setq gnus-newsgroup-expirable
7143 (sort gnus-newsgroup-expirable '<))))
7144 (expiry-wait (if now 'immediate
7145 (gnus-group-find-parameter
7146 gnus-newsgroup-name 'expiry-wait)))
7149 ;; There are expirable articles in this group, so we run them
7150 ;; through the expiry process.
7151 (gnus-message 6 "Expiring articles...")
7152 ;; The list of articles that weren't expired is returned.
7154 (let ((nnmail-expiry-wait-function nil)
7155 (nnmail-expiry-wait expiry-wait))
7156 (setq es (gnus-request-expire-articles
7157 expirable gnus-newsgroup-name)))
7158 (setq es (gnus-request-expire-articles
7159 expirable gnus-newsgroup-name)))
7161 (setq gnus-newsgroup-expirable es))
7162 ;; We go through the old list of expirable, and mark all
7163 ;; really expired articles as nonexistent.
7164 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7165 (let ((gnus-use-cache nil))
7167 (unless (memq (car expirable) es)
7168 (when (gnus-data-find (car expirable))
7169 (gnus-summary-mark-article
7170 (car expirable) gnus-canceled-mark)))
7171 (setq expirable (cdr expirable)))))
7172 (gnus-message 6 "Expiring articles...done")))))
7174 (defun gnus-summary-expire-articles-now ()
7175 "Expunge all expirable articles in the current group.
7176 This means that *all* articles that are marked as expirable will be
7177 deleted forever, right now."
7179 (or gnus-expert-user
7181 "Are you really, really, really sure you want to delete all these messages? ")
7183 (gnus-summary-expire-articles t))
7185 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7186 (defun gnus-summary-delete-article (&optional n)
7187 "Delete the N next (mail) articles.
7188 This command actually deletes articles. This is not a marking
7189 command. The article will disappear forever from your life, never to
7191 If N is negative, delete backwards.
7192 If N is nil and articles have been marked with the process mark,
7193 delete these instead."
7195 (unless (gnus-check-backend-function 'request-expire-articles
7196 gnus-newsgroup-name)
7197 (error "The current newsgroup does not support article deletion"))
7198 ;; Compute the list of articles to delete.
7199 (let ((articles (gnus-summary-work-articles n))
7201 (if (and gnus-novice-user
7202 (not (gnus-yes-or-no-p
7203 (format "Do you really want to delete %s forever? "
7204 (if (> (length articles) 1)
7205 (format "these %s articles" (length articles))
7208 ;; Delete the articles.
7209 (setq not-deleted (gnus-request-expire-articles
7210 articles gnus-newsgroup-name 'force))
7212 (gnus-summary-remove-process-mark (car articles))
7213 ;; The backend might not have been able to delete the article
7215 (unless (memq (car articles) not-deleted)
7216 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7217 (setq articles (cdr articles)))
7219 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7220 (gnus-summary-position-point)
7221 (gnus-set-mode-line 'summary)
7224 (defun gnus-summary-edit-article (&optional force)
7225 "Edit the current article.
7226 This will have permanent effect only in mail groups.
7227 If FORCE is non-nil, allow editing of articles even in read-only
7231 (set-buffer gnus-summary-buffer)
7232 (gnus-set-global-variables)
7233 (when (and (not force)
7234 (gnus-group-read-only-p))
7235 (error "The current newsgroup does not support article editing"))
7236 ;; Select article if needed.
7237 (unless (eq (gnus-summary-article-number)
7238 gnus-current-article)
7239 (gnus-summary-select-article t))
7240 (gnus-article-date-original)
7241 (gnus-article-edit-article
7242 `(lambda (no-highlight)
7243 (gnus-summary-edit-article-done
7244 ,(or (mail-header-references gnus-current-headers) "")
7245 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7247 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7249 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7251 "Make edits to the current article permanent."
7253 ;; Replace the article.
7254 (if (and (not read-only)
7255 (not (gnus-request-replace-article
7256 (cdr gnus-article-current) (car gnus-article-current)
7258 (error "Couldn't replace article")
7259 ;; Update the summary buffer.
7261 (equal (message-tokenize-header references " ")
7262 (message-tokenize-header
7263 (or (message-fetch-field "references") "") " ")))
7264 ;; We only have to update this line.
7267 (message-narrow-to-head)
7268 (let ((head (buffer-string))
7270 (nnheader-temp-write nil
7271 (insert (format "211 %d Article retrieved.\n"
7272 (cdr gnus-article-current)))
7275 (let ((nntp-server-buffer (current-buffer)))
7276 (setq header (car (gnus-get-newsgroup-headers
7278 (set-buffer gnus-summary-buffer)
7279 gnus-newsgroup-dependencies)
7282 (set-buffer gnus-summary-buffer)
7283 (gnus-data-set-header
7284 (gnus-data-find (cdr gnus-article-current))
7286 (gnus-summary-update-article-line
7287 (cdr gnus-article-current) header))))))
7289 (set-buffer (or buffer gnus-summary-buffer))
7290 (gnus-summary-update-article (cdr gnus-article-current)))
7291 ;; Prettify the article buffer again.
7292 (unless no-highlight
7294 (set-buffer gnus-article-buffer)
7295 (run-hooks 'gnus-article-display-hook)
7296 (set-buffer gnus-original-article-buffer)
7297 (gnus-request-article
7298 (cdr gnus-article-current)
7299 (car gnus-article-current) (current-buffer))))
7300 ;; Prettify the summary buffer line.
7301 (when (gnus-visual-p 'summary-highlight 'highlight)
7302 (run-hooks 'gnus-visual-mark-article-hook))))
7304 (defun gnus-summary-edit-wash (key)
7305 "Perform editing command in the article buffer."
7309 (message "%s" (concat (this-command-keys) "- "))
7312 (gnus-summary-edit-article)
7313 (execute-kbd-macro (concat (this-command-keys) key))
7314 (gnus-article-edit-done))
7318 (defun gnus-summary-respool-query (&optional silent)
7319 "Query where the respool algorithm would put this article."
7321 (let (gnus-mark-article-hook)
7322 (gnus-summary-select-article)
7324 (set-buffer gnus-original-article-buffer)
7326 (message-narrow-to-head)
7327 (let ((groups (nnmail-article-group 'identity)))
7330 (message "This message would go to %s"
7331 (mapconcat 'car groups ", "))
7332 (message "This message would go to no groups"))
7335 ;; Summary marking commands.
7337 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7338 "Mark articles which has the same subject as read, and then select the next.
7339 If UNMARK is positive, remove any kind of mark.
7340 If UNMARK is negative, tick articles."
7343 (setq unmark (prefix-numeric-value unmark)))
7345 (gnus-summary-mark-same-subject
7346 (gnus-summary-article-subject) unmark)))
7347 ;; Select next unread article. If auto-select-same mode, should
7348 ;; select the first unread article.
7349 (gnus-summary-next-article t (and gnus-auto-select-same
7350 (gnus-summary-article-subject)))
7351 (gnus-message 7 "%d article%s marked as %s"
7352 count (if (= count 1) " is" "s are")
7353 (if unmark "unread" "read"))))
7355 (defun gnus-summary-kill-same-subject (&optional unmark)
7356 "Mark articles which has the same subject as read.
7357 If UNMARK is positive, remove any kind of mark.
7358 If UNMARK is negative, tick articles."
7361 (setq unmark (prefix-numeric-value unmark)))
7363 (gnus-summary-mark-same-subject
7364 (gnus-summary-article-subject) unmark)))
7365 ;; If marked as read, go to next unread subject.
7367 ;; Go to next unread subject.
7368 (gnus-summary-next-subject 1 t))
7369 (gnus-message 7 "%d articles are marked as %s"
7370 count (if unmark "unread" "read"))))
7372 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7373 "Mark articles with same SUBJECT as read, and return marked number.
7374 If optional argument UNMARK is positive, remove any kinds of marks.
7375 If optional argument UNMARK is negative, mark articles as unread instead."
7379 ((null unmark) ; Mark as read.
7382 (gnus-summary-mark-article-as-read gnus-killed-mark)
7383 (gnus-summary-show-thread) t)
7384 (gnus-summary-find-subject subject))
7385 (setq count (1+ count))))
7386 ((> unmark 0) ; Tick.
7389 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7390 (gnus-summary-show-thread) t)
7391 (gnus-summary-find-subject subject))
7392 (setq count (1+ count))))
7393 (t ; Mark as unread.
7396 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7397 (gnus-summary-show-thread) t)
7398 (gnus-summary-find-subject subject))
7399 (setq count (1+ count)))))
7400 (gnus-set-mode-line 'summary)
7401 ;; Return the number of marked articles.
7404 (defun gnus-summary-mark-as-processable (n &optional unmark)
7405 "Set the process mark on the next N articles.
7406 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7407 the process mark instead. The difference between N and the actual
7408 number of articles marked is returned."
7410 (let ((backward (< n 0))
7415 (gnus-summary-remove-process-mark
7416 (gnus-summary-article-number))
7417 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7418 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7421 (gnus-message 7 "No more articles"))
7422 (gnus-summary-recenter)
7423 (gnus-summary-position-point)
7426 (defun gnus-summary-unmark-as-processable (n)
7427 "Remove the process mark from the next N articles.
7428 If N is negative, unmark backward instead. The difference between N and
7429 the actual number of articles unmarked is returned."
7431 (gnus-summary-mark-as-processable n t))
7433 (defun gnus-summary-unmark-all-processable ()
7434 "Remove the process mark from all articles."
7437 (while gnus-newsgroup-processable
7438 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7439 (gnus-summary-position-point))
7441 (defun gnus-summary-mark-as-expirable (n)
7442 "Mark N articles forward as expirable.
7443 If N is negative, mark backward instead. The difference between N and
7444 the actual number of articles marked is returned."
7446 (gnus-summary-mark-forward n gnus-expirable-mark))
7448 (defun gnus-summary-mark-article-as-replied (article)
7449 "Mark ARTICLE replied and update the summary line."
7450 (push article gnus-newsgroup-replied)
7451 (let ((buffer-read-only nil))
7452 (when (gnus-summary-goto-subject article)
7453 (gnus-summary-update-secondary-mark article))))
7455 (defun gnus-summary-set-bookmark (article)
7456 "Set a bookmark in current article."
7457 (interactive (list (gnus-summary-article-number)))
7458 (when (or (not (get-buffer gnus-article-buffer))
7459 (not gnus-current-article)
7460 (not gnus-article-current)
7461 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7462 (error "No current article selected"))
7463 ;; Remove old bookmark, if one exists.
7464 (let ((old (assq article gnus-newsgroup-bookmarks)))
7466 (setq gnus-newsgroup-bookmarks
7467 (delq old gnus-newsgroup-bookmarks))))
7468 ;; Set the new bookmark, which is on the form
7469 ;; (article-number . line-number-in-body).
7473 (set-buffer gnus-article-buffer)
7477 (goto-char (point-min))
7478 (search-forward "\n\n" nil t)
7481 gnus-newsgroup-bookmarks)
7482 (gnus-message 6 "A bookmark has been added to the current article."))
7484 (defun gnus-summary-remove-bookmark (article)
7485 "Remove the bookmark from the current article."
7486 (interactive (list (gnus-summary-article-number)))
7487 ;; Remove old bookmark, if one exists.
7488 (let ((old (assq article gnus-newsgroup-bookmarks)))
7491 (setq gnus-newsgroup-bookmarks
7492 (delq old gnus-newsgroup-bookmarks))
7493 (gnus-message 6 "Removed bookmark."))
7494 (gnus-message 6 "No bookmark in current article."))))
7496 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7497 (defun gnus-summary-mark-as-dormant (n)
7498 "Mark N articles forward as dormant.
7499 If N is negative, mark backward instead. The difference between N and
7500 the actual number of articles marked is returned."
7502 (gnus-summary-mark-forward n gnus-dormant-mark))
7504 (defun gnus-summary-set-process-mark (article)
7505 "Set the process mark on ARTICLE and update the summary line."
7506 (setq gnus-newsgroup-processable
7508 (delq article gnus-newsgroup-processable)))
7509 (when (gnus-summary-goto-subject article)
7510 (gnus-summary-show-thread)
7511 (gnus-summary-update-secondary-mark article)))
7513 (defun gnus-summary-remove-process-mark (article)
7514 "Remove the process mark from ARTICLE and update the summary line."
7515 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7516 (when (gnus-summary-goto-subject article)
7517 (gnus-summary-show-thread)
7518 (gnus-summary-update-secondary-mark article)))
7520 (defun gnus-summary-set-saved-mark (article)
7521 "Set the process mark on ARTICLE and update the summary line."
7522 (push article gnus-newsgroup-saved)
7523 (when (gnus-summary-goto-subject article)
7524 (gnus-summary-update-secondary-mark article)))
7526 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7527 "Mark N articles as read forwards.
7528 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7529 The difference between N and the actual number of articles marked is
7532 (let ((backward (< n 0))
7533 (gnus-summary-goto-unread
7534 (and gnus-summary-goto-unread
7535 (not (eq gnus-summary-goto-unread 'never))
7536 (not (memq mark (list gnus-unread-mark
7537 gnus-ticked-mark gnus-dormant-mark)))))
7539 (mark (or mark gnus-del-mark)))
7541 (gnus-summary-mark-article nil mark no-expire)
7542 (zerop (gnus-summary-next-subject
7544 (and gnus-summary-goto-unread
7545 (not (eq gnus-summary-goto-unread 'never)))
7549 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7550 (gnus-summary-recenter)
7551 (gnus-summary-position-point)
7552 (gnus-set-mode-line 'summary)
7555 (defun gnus-summary-mark-article-as-read (mark)
7556 "Mark the current article quickly as read with MARK."
7557 (let ((article (gnus-summary-article-number)))
7558 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7559 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7560 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7561 (push (cons article mark) gnus-newsgroup-reads)
7562 ;; Possibly remove from cache, if that is used.
7563 (when gnus-use-cache
7564 (gnus-cache-enter-remove-article article))
7565 ;; Allow the backend to change the mark.
7566 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7567 ;; Check for auto-expiry.
7568 (when (and gnus-newsgroup-auto-expire
7569 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7570 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7571 (= mark gnus-ancient-mark)
7572 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7573 (= mark gnus-duplicate-mark)))
7574 (setq mark gnus-expirable-mark)
7575 (push article gnus-newsgroup-expirable))
7576 ;; Set the mark in the buffer.
7577 (gnus-summary-update-mark mark 'unread)
7580 (defun gnus-summary-mark-article-as-unread (mark)
7581 "Mark the current article quickly as unread with MARK."
7582 (let ((article (gnus-summary-article-number)))
7585 (gnus-error 1 "Can't mark negative article numbers")
7587 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7588 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7589 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7590 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7591 (cond ((= mark gnus-ticked-mark)
7592 (push article gnus-newsgroup-marked))
7593 ((= mark gnus-dormant-mark)
7594 (push article gnus-newsgroup-dormant))
7596 (push article gnus-newsgroup-unreads)))
7597 (setq gnus-newsgroup-reads
7598 (delq (assq article gnus-newsgroup-reads)
7599 gnus-newsgroup-reads))
7601 ;; See whether the article is to be put in the cache.
7603 (vectorp (gnus-summary-article-header article))
7605 (gnus-cache-possibly-enter-article
7606 gnus-newsgroup-name article
7607 (gnus-summary-article-header article)
7608 (= mark gnus-ticked-mark)
7609 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7612 (gnus-summary-update-mark mark 'unread)
7615 (defun gnus-summary-mark-article (&optional article mark no-expire)
7616 "Mark ARTICLE with MARK. MARK can be any character.
7617 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7618 `??' (dormant) and `?E' (expirable).
7619 If MARK is nil, then the default character `?D' is used.
7620 If ARTICLE is nil, then the article on the current line will be
7622 ;; The mark might be a string.
7623 (when (stringp mark)
7624 (setq mark (aref mark 0)))
7625 ;; If no mark is given, then we check auto-expiring.
7626 (and (not no-expire)
7627 gnus-newsgroup-auto-expire
7629 (and (gnus-characterp mark)
7630 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7631 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7632 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7633 (= mark gnus-duplicate-mark))))
7634 (setq mark gnus-expirable-mark))
7635 (let* ((mark (or mark gnus-del-mark))
7636 (article (or article (gnus-summary-article-number))))
7638 (error "No article on current line"))
7639 (if (not (if (or (= mark gnus-unread-mark)
7640 (= mark gnus-ticked-mark)
7641 (= mark gnus-dormant-mark))
7642 (gnus-mark-article-as-unread article mark)
7643 (gnus-mark-article-as-read article mark)))
7645 ;; See whether the article is to be put in the cache.
7647 (not (= mark gnus-canceled-mark))
7648 (vectorp (gnus-summary-article-header article))
7650 (gnus-cache-possibly-enter-article
7651 gnus-newsgroup-name article
7652 (gnus-summary-article-header article)
7653 (= mark gnus-ticked-mark)
7654 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7656 (when (gnus-summary-goto-subject article nil t)
7657 (let ((buffer-read-only nil))
7658 (gnus-summary-show-thread)
7660 (gnus-summary-update-mark mark 'unread)
7663 (defun gnus-summary-update-secondary-mark (article)
7664 "Update the secondary (read, process, cache) mark."
7665 (gnus-summary-update-mark
7666 (cond ((memq article gnus-newsgroup-processable)
7668 ((memq article gnus-newsgroup-cached)
7670 ((memq article gnus-newsgroup-replied)
7672 ((memq article gnus-newsgroup-saved)
7674 (t gnus-unread-mark))
7676 (when (gnus-visual-p 'summary-highlight 'highlight)
7677 (run-hooks 'gnus-summary-update-hook))
7680 (defun gnus-summary-update-mark (mark type)
7681 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7682 (buffer-read-only nil))
7683 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7684 (when (looking-at "\r")
7687 (<= (+ forward (point)) (point-max)))
7688 ;; Go to the right position on the line.
7689 (goto-char (+ forward (point)))
7690 ;; Replace the old mark with the new mark.
7691 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7692 ;; Optionally update the marks by some user rule.
7693 (when (eq type 'unread)
7695 (gnus-data-find (gnus-summary-article-number)) mark)
7696 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7698 (defun gnus-mark-article-as-read (article &optional mark)
7699 "Enter ARTICLE in the pertinent lists and remove it from others."
7700 ;; Make the article expirable.
7701 (let ((mark (or mark gnus-del-mark)))
7702 (if (= mark gnus-expirable-mark)
7703 (push article gnus-newsgroup-expirable)
7704 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7705 ;; Remove from unread and marked lists.
7706 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7707 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7708 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7709 (push (cons article mark) gnus-newsgroup-reads)
7710 ;; Possibly remove from cache, if that is used.
7711 (when gnus-use-cache
7712 (gnus-cache-enter-remove-article article))))
7714 (defun gnus-mark-article-as-unread (article &optional mark)
7715 "Enter ARTICLE in the pertinent lists and remove it from others."
7716 (let ((mark (or mark gnus-ticked-mark)))
7719 (gnus-error 1 "Can't mark negative article numbers")
7721 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7722 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7723 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7724 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7726 ;; Unsuppress duplicates?
7727 (when gnus-suppress-duplicates
7728 (gnus-dup-unsuppress-article article))
7730 (cond ((= mark gnus-ticked-mark)
7731 (push article gnus-newsgroup-marked))
7732 ((= mark gnus-dormant-mark)
7733 (push article gnus-newsgroup-dormant))
7735 (push article gnus-newsgroup-unreads)))
7736 (setq gnus-newsgroup-reads
7737 (delq (assq article gnus-newsgroup-reads)
7738 gnus-newsgroup-reads))
7741 (defalias 'gnus-summary-mark-as-unread-forward
7742 'gnus-summary-tick-article-forward)
7743 (make-obsolete 'gnus-summary-mark-as-unread-forward
7744 'gnus-summary-tick-article-forward)
7745 (defun gnus-summary-tick-article-forward (n)
7746 "Tick N articles forwards.
7747 If N is negative, tick backwards instead.
7748 The difference between N and the number of articles ticked is returned."
7750 (gnus-summary-mark-forward n gnus-ticked-mark))
7752 (defalias 'gnus-summary-mark-as-unread-backward
7753 'gnus-summary-tick-article-backward)
7754 (make-obsolete 'gnus-summary-mark-as-unread-backward
7755 'gnus-summary-tick-article-backward)
7756 (defun gnus-summary-tick-article-backward (n)
7757 "Tick N articles backwards.
7758 The difference between N and the number of articles ticked is returned."
7760 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7762 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7763 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7764 (defun gnus-summary-tick-article (&optional article clear-mark)
7765 "Mark current article as unread.
7766 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7767 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7769 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7772 (defun gnus-summary-mark-as-read-forward (n)
7773 "Mark N articles as read forwards.
7774 If N is negative, mark backwards instead.
7775 The difference between N and the actual number of articles marked is
7778 (gnus-summary-mark-forward n gnus-del-mark t))
7780 (defun gnus-summary-mark-as-read-backward (n)
7781 "Mark the N articles as read backwards.
7782 The difference between N and the actual number of articles marked is
7785 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7787 (defun gnus-summary-mark-as-read (&optional article mark)
7788 "Mark current article as read.
7789 ARTICLE specifies the article to be marked as read.
7790 MARK specifies a string to be inserted at the beginning of the line."
7791 (gnus-summary-mark-article article mark))
7793 (defun gnus-summary-clear-mark-forward (n)
7794 "Clear marks from N articles forward.
7795 If N is negative, clear backward instead.
7796 The difference between N and the number of marks cleared is returned."
7798 (gnus-summary-mark-forward n gnus-unread-mark))
7800 (defun gnus-summary-clear-mark-backward (n)
7801 "Clear marks from N articles backward.
7802 The difference between N and the number of marks cleared is returned."
7804 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7806 (defun gnus-summary-mark-unread-as-read ()
7807 "Intended to be used by `gnus-summary-mark-article-hook'."
7808 (when (memq gnus-current-article gnus-newsgroup-unreads)
7809 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7811 (defun gnus-summary-mark-read-and-unread-as-read ()
7812 "Intended to be used by `gnus-summary-mark-article-hook'."
7813 (let ((mark (gnus-summary-article-mark)))
7814 (when (or (gnus-unread-mark-p mark)
7815 (gnus-read-mark-p mark))
7816 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7818 (defun gnus-summary-mark-region-as-read (point mark all)
7819 "Mark all unread articles between point and mark as read.
7820 If given a prefix, mark all articles between point and mark as read,
7821 even ticked and dormant ones."
7822 (interactive "r\nP")
7831 (memq (setq article (gnus-summary-article-number))
7832 gnus-newsgroup-unreads))
7833 (gnus-summary-mark-article article gnus-del-mark))
7835 (gnus-summary-find-next))))))
7837 (defun gnus-summary-mark-below (score mark)
7838 "Mark articles with score less than SCORE with MARK."
7839 (interactive "P\ncMark: ")
7840 (setq score (if score
7841 (prefix-numeric-value score)
7842 (or gnus-summary-default-score 0)))
7844 (set-buffer gnus-summary-buffer)
7845 (goto-char (point-min))
7848 (and (< (gnus-summary-article-score) score)
7849 (gnus-summary-mark-article nil mark))
7850 (gnus-summary-find-next)))))
7852 (defun gnus-summary-kill-below (&optional score)
7853 "Mark articles with score below SCORE as read."
7855 (gnus-summary-mark-below score gnus-killed-mark))
7857 (defun gnus-summary-clear-above (&optional score)
7858 "Clear all marks from articles with score above SCORE."
7860 (gnus-summary-mark-above score gnus-unread-mark))
7862 (defun gnus-summary-tick-above (&optional score)
7863 "Tick all articles with score above SCORE."
7865 (gnus-summary-mark-above score gnus-ticked-mark))
7867 (defun gnus-summary-mark-above (score mark)
7868 "Mark articles with score over SCORE with MARK."
7869 (interactive "P\ncMark: ")
7870 (setq score (if score
7871 (prefix-numeric-value score)
7872 (or gnus-summary-default-score 0)))
7874 (set-buffer gnus-summary-buffer)
7875 (goto-char (point-min))
7877 (when (> (gnus-summary-article-score) score)
7878 (gnus-summary-mark-article nil mark))
7880 (gnus-summary-find-next)))))
7882 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7883 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7884 (defun gnus-summary-limit-include-expunged (&optional no-error)
7885 "Display all the hidden articles that were expunged for low scores."
7887 (let ((buffer-read-only nil))
7888 (let ((scored gnus-newsgroup-scored)
7891 (unless (gnus-summary-goto-subject (caar scored))
7892 (and (setq h (gnus-summary-article-header (caar scored)))
7893 (< (cdar scored) gnus-summary-expunge-below)
7895 (setq scored (cdr scored)))
7897 (when (not no-error)
7898 (error "No expunged articles hidden"))
7899 (goto-char (point-min))
7900 (gnus-summary-prepare-unthreaded (nreverse headers))
7901 (goto-char (point-min))
7902 (gnus-summary-position-point)
7905 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7906 "Mark all unread articles in this newsgroup as read.
7907 If prefix argument ALL is non-nil, ticked and dormant articles will
7908 also be marked as read.
7909 If QUIETLY is non-nil, no questions will be asked.
7910 If TO-HERE is non-nil, it should be a point in the buffer. All
7911 articles before this point will be marked as read.
7912 Note that this function will only catch up the unread article
7913 in the current summary buffer limitation.
7914 The number of articles marked as read is returned."
7919 (not gnus-interactive-catchup) ;Without confirmation?
7923 "Mark absolutely all articles as read? "
7924 "Mark all unread articles as read? ")))
7926 (not gnus-newsgroup-adaptive)
7927 (not gnus-newsgroup-auto-expire)
7928 (not gnus-suppress-duplicates)
7929 (or (not gnus-use-cache)
7930 (eq gnus-use-cache 'passive)))
7933 (setq gnus-newsgroup-marked nil
7934 gnus-newsgroup-dormant nil))
7935 (setq gnus-newsgroup-unreads nil))
7936 ;; We actually mark all articles as canceled, which we
7937 ;; have to do when using auto-expiry or adaptive scoring.
7938 (gnus-summary-show-all-threads)
7939 (when (gnus-summary-first-subject (not all))
7941 (if to-here (< (point) to-here) t)
7942 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7943 (gnus-summary-find-next (not all)))))
7944 (gnus-set-mode-line 'summary))
7946 (gnus-summary-position-point)))
7948 (defun gnus-summary-catchup-to-here (&optional all)
7949 "Mark all unticked articles before the current one as read.
7950 If ALL is non-nil, also mark ticked and dormant articles as read."
7953 (gnus-save-hidden-threads
7954 (let ((beg (point)))
7955 ;; We check that there are unread articles.
7956 (when (or all (gnus-summary-find-prev))
7957 (gnus-summary-catchup all t beg)))))
7958 (gnus-summary-position-point))
7960 (defun gnus-summary-catchup-all (&optional quietly)
7961 "Mark all articles in this newsgroup as read."
7963 (gnus-summary-catchup t quietly))
7965 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7966 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7967 If prefix argument ALL is non-nil, all articles are marked as read."
7969 (when (gnus-summary-catchup all quietly nil 'fast)
7970 ;; Select next newsgroup or exit.
7971 (if (eq gnus-auto-select-next 'quietly)
7972 (gnus-summary-next-group nil)
7973 (gnus-summary-exit))))
7975 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7976 "Mark all articles in this newsgroup as read, and then exit."
7978 (gnus-summary-catchup-and-exit t quietly))
7980 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7981 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7982 "Mark all articles in this group as read and select the next group.
7983 If given a prefix, mark all articles, unread as well as ticked, as
7987 (gnus-summary-catchup all))
7988 (gnus-summary-next-article t nil nil t))
7990 ;; Thread-based commands.
7992 (defun gnus-summary-articles-in-thread (&optional article)
7993 "Return a list of all articles in the current thread.
7994 If ARTICLE is non-nil, return all articles in the thread that starts
7996 (let* ((article (or article (gnus-summary-article-number)))
7997 (data (gnus-data-find-list article))
7998 (top-level (gnus-data-level (car data)))
8000 (cond ((null gnus-thread-operation-ignore-subject)
8001 (gnus-simplify-subject-re
8002 (mail-header-subject (gnus-data-header (car data)))))
8003 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8004 (gnus-simplify-subject-fuzzy
8005 (mail-header-subject (gnus-data-header (car data)))))
8007 (end-point (save-excursion
8008 (if (gnus-summary-go-to-next-thread)
8009 (point) (point-max))))
8012 (< (gnus-data-pos (car data)) end-point))
8013 (when (or (not top-subject)
8014 (string= top-subject
8015 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8016 (gnus-simplify-subject-fuzzy
8017 (mail-header-subject
8018 (gnus-data-header (car data))))
8019 (gnus-simplify-subject-re
8020 (mail-header-subject
8021 (gnus-data-header (car data)))))))
8022 (push (gnus-data-number (car data)) articles))
8023 (unless (and (setq data (cdr data))
8024 (> (gnus-data-level (car data)) top-level))
8026 ;; Return the list of articles.
8027 (nreverse articles)))
8029 (defun gnus-summary-rethread-current ()
8030 "Rethread the thread the current article is part of."
8032 (let* ((gnus-show-threads t)
8033 (article (gnus-summary-article-number))
8034 (id (mail-header-id (gnus-summary-article-header)))
8035 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8037 (error "No article on the current line"))
8038 (gnus-rebuild-thread id)
8039 (gnus-summary-goto-subject article)))
8041 (defun gnus-summary-reparent-thread ()
8042 "Make the current article child of the marked (or previous) article.
8044 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8045 is non-nil or the Subject: of both articles are the same."
8047 (unless (not (gnus-group-read-only-p))
8048 (error "The current newsgroup does not support article editing"))
8049 (unless (<= (length gnus-newsgroup-processable) 1)
8050 (error "No more than one article may be marked"))
8051 (save-window-excursion
8052 (let ((gnus-article-buffer " *reparent*")
8053 (current-article (gnus-summary-article-number))
8054 ;; First grab the marked article, otherwise one line up.
8055 (parent-article (if (not (null gnus-newsgroup-processable))
8056 (car gnus-newsgroup-processable)
8058 (if (eq (forward-line -1) 0)
8059 (gnus-summary-article-number)
8060 (error "Beginning of summary buffer"))))))
8061 (unless (not (eq current-article parent-article))
8062 (error "An article may not be self-referential"))
8063 (let ((message-id (mail-header-id
8064 (gnus-summary-article-header parent-article))))
8065 (unless (and message-id (not (equal message-id "")))
8066 (error "No message-id in desired parent"))
8067 (gnus-summary-select-article t t nil current-article)
8068 (set-buffer gnus-original-article-buffer)
8069 (let ((buf (format "%s" (buffer-string))))
8070 (nnheader-temp-write nil
8072 (goto-char (point-min))
8073 (if (re-search-forward "^References: " nil t)
8075 (re-search-forward "^[^ \t]" nil t)
8078 (insert " " message-id))
8079 (insert "References: " message-id "\n"))
8080 (unless (gnus-request-replace-article
8081 current-article (car gnus-article-current)
8083 (error "Couldn't replace article"))))
8084 (set-buffer gnus-summary-buffer)
8085 (gnus-summary-unmark-all-processable)
8086 (gnus-summary-update-article current-article)
8087 (gnus-summary-rethread-current)
8088 (gnus-message 3 "Article %d is now the child of article %d"
8089 current-article parent-article)))))
8091 (defun gnus-summary-toggle-threads (&optional arg)
8092 "Toggle showing conversation threads.
8093 If ARG is positive number, turn showing conversation threads on."
8095 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8096 (setq gnus-show-threads
8097 (if (null arg) (not gnus-show-threads)
8098 (> (prefix-numeric-value arg) 0)))
8099 (gnus-summary-prepare)
8100 (gnus-summary-goto-subject current)
8101 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8102 (gnus-summary-position-point)))
8104 (defun gnus-summary-show-all-threads ()
8108 (let ((buffer-read-only nil))
8109 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8110 (gnus-summary-position-point))
8112 (defun gnus-summary-show-thread ()
8113 "Show thread subtrees.
8114 Returns nil if no thread was there to be shown."
8116 (let ((buffer-read-only nil)
8118 ;; first goto end then to beg, to have point at beg after let
8119 (end (progn (end-of-line) (point)))
8120 (beg (progn (beginning-of-line) (point))))
8122 ;; Any hidden lines here?
8123 (search-forward "\r" end t)
8124 (subst-char-in-region beg end ?\^M ?\n t)
8126 (gnus-summary-position-point))))
8128 (defun gnus-summary-hide-all-threads ()
8129 "Hide all thread subtrees."
8132 (goto-char (point-min))
8133 (gnus-summary-hide-thread)
8134 (while (zerop (gnus-summary-next-thread 1 t))
8135 (gnus-summary-hide-thread)))
8136 (gnus-summary-position-point))
8138 (defun gnus-summary-hide-thread ()
8139 "Hide thread subtrees.
8140 Returns nil if no threads were there to be hidden."
8142 (let ((buffer-read-only nil)
8144 (article (gnus-summary-article-number)))
8146 ;; Go forward until either the buffer ends or the subthread
8148 (when (and (not (eobp))
8149 (or (zerop (gnus-summary-next-thread 1 t))
8150 (goto-char (point-max))))
8152 (if (and (> (point) start)
8153 (search-backward "\n" start t))
8155 (subst-char-in-region start (point) ?\n ?\^M)
8156 (gnus-summary-goto-subject article))
8159 ;;(gnus-summary-position-point)
8162 (defun gnus-summary-go-to-next-thread (&optional previous)
8163 "Go to the same level (or less) next thread.
8164 If PREVIOUS is non-nil, go to previous thread instead.
8165 Return the article number moved to, or nil if moving was impossible."
8166 (let ((level (gnus-summary-thread-level))
8167 (way (if previous -1 1))
8170 (while (and (not (eobp))
8171 (< level (gnus-summary-thread-level)))
8179 (gnus-summary-article-number)
8182 (defun gnus-summary-next-thread (n &optional silent)
8183 "Go to the same level next N'th thread.
8184 If N is negative, search backward instead.
8185 Returns the difference between N and the number of skips actually
8188 If SILENT, don't output messages."
8190 (let ((backward (< n 0))
8193 (gnus-summary-go-to-next-thread backward))
8196 (gnus-summary-position-point))
8197 (when (and (not silent) (/= 0 n))
8198 (gnus-message 7 "No more threads"))
8201 (defun gnus-summary-prev-thread (n)
8202 "Go to the same level previous N'th thread.
8203 Returns the difference between N and the number of skips actually
8206 (gnus-summary-next-thread (- n)))
8208 (defun gnus-summary-go-down-thread ()
8209 "Go down one level in the current thread."
8210 (let ((children (gnus-summary-article-children)))
8212 (gnus-summary-goto-subject (car children)))))
8214 (defun gnus-summary-go-up-thread ()
8215 "Go up one level in the current thread."
8216 (let ((parent (gnus-summary-article-parent)))
8218 (gnus-summary-goto-subject parent))))
8220 (defun gnus-summary-down-thread (n)
8221 "Go down thread N steps.
8222 If N is negative, go up instead.
8223 Returns the difference between N and how many steps down that were
8229 (if up (gnus-summary-go-up-thread)
8230 (gnus-summary-go-down-thread)))
8232 (gnus-summary-position-point)
8234 (gnus-message 7 "Can't go further"))
8237 (defun gnus-summary-up-thread (n)
8238 "Go up thread N steps.
8239 If N is negative, go up instead.
8240 Returns the difference between N and how many steps down that were
8243 (gnus-summary-down-thread (- n)))
8245 (defun gnus-summary-top-thread ()
8246 "Go to the top of the thread."
8248 (while (gnus-summary-go-up-thread))
8249 (gnus-summary-article-number))
8251 (defun gnus-summary-kill-thread (&optional unmark)
8252 "Mark articles under current thread as read.
8253 If the prefix argument is positive, remove any kinds of marks.
8254 If the prefix argument is negative, tick articles instead."
8257 (setq unmark (prefix-numeric-value unmark)))
8258 (let ((articles (gnus-summary-articles-in-thread)))
8260 ;; Expand the thread.
8261 (gnus-summary-show-thread)
8262 ;; Mark all the articles.
8264 (gnus-summary-goto-subject (car articles))
8265 (cond ((null unmark)
8266 (gnus-summary-mark-article-as-read gnus-killed-mark))
8268 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8270 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8271 (setq articles (cdr articles))))
8272 ;; Hide killed subtrees.
8274 gnus-thread-hide-killed
8275 (gnus-summary-hide-thread))
8276 ;; If marked as read, go to next unread subject.
8278 ;; Go to next unread subject.
8279 (gnus-summary-next-subject 1 t)))
8280 (gnus-set-mode-line 'summary))
8282 ;; Summary sorting commands
8284 (defun gnus-summary-sort-by-number (&optional reverse)
8285 "Sort the summary buffer by article number.
8286 Argument REVERSE means reverse order."
8288 (gnus-summary-sort 'number reverse))
8290 (defun gnus-summary-sort-by-author (&optional reverse)
8291 "Sort the summary buffer by author name alphabetically.
8292 If case-fold-search is non-nil, case of letters is ignored.
8293 Argument REVERSE means reverse order."
8295 (gnus-summary-sort 'author reverse))
8297 (defun gnus-summary-sort-by-subject (&optional reverse)
8298 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8299 If case-fold-search is non-nil, case of letters is ignored.
8300 Argument REVERSE means reverse order."
8302 (gnus-summary-sort 'subject reverse))
8304 (defun gnus-summary-sort-by-date (&optional reverse)
8305 "Sort the summary buffer by date.
8306 Argument REVERSE means reverse order."
8308 (gnus-summary-sort 'date reverse))
8310 (defun gnus-summary-sort-by-score (&optional reverse)
8311 "Sort the summary buffer by score.
8312 Argument REVERSE means reverse order."
8314 (gnus-summary-sort 'score reverse))
8316 (defun gnus-summary-sort-by-lines (&optional reverse)
8317 "Sort the summary buffer by article length.
8318 Argument REVERSE means reverse order."
8320 (gnus-summary-sort 'lines reverse))
8322 (defun gnus-summary-sort (predicate reverse)
8323 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8324 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8325 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8326 (gnus-thread-sort-functions
8332 (gnus-article-sort-functions
8337 (,article t2 t1)))))
8339 (gnus-summary-prepare-hook nil))
8340 ;; We do the sorting by regenerating the threads.
8341 (gnus-summary-prepare)
8342 ;; Hide subthreads if needed.
8343 (when (and gnus-show-threads gnus-thread-hide-subtree)
8344 (gnus-summary-hide-all-threads))))
8346 ;; Summary saving commands.
8348 (defun gnus-summary-save-article (&optional n not-saved)
8349 "Save the current article using the default saver function.
8350 If N is a positive number, save the N next articles.
8351 If N is a negative number, save the N previous articles.
8352 If N is nil and any articles have been marked with the process mark,
8353 save those articles instead.
8354 The variable `gnus-default-article-saver' specifies the saver function."
8356 (let* ((articles (gnus-summary-work-articles n))
8357 (save-buffer (save-excursion
8358 (nnheader-set-temp-buffer " *Gnus Save*")))
8359 (num (length articles))
8360 header article file)
8362 (setq header (gnus-summary-article-header
8363 (setq article (pop articles))))
8364 (if (not (vectorp header))
8365 ;; This is a pseudo-article.
8366 (if (assq 'name header)
8367 (gnus-copy-file (cdr (assq 'name header)))
8368 (gnus-message 1 "Article %d is unsaveable" article))
8369 ;; This is a real article.
8370 (save-window-excursion
8371 (gnus-summary-select-article t nil nil article))
8373 (set-buffer save-buffer)
8375 (insert-buffer-substring gnus-original-article-buffer))
8376 (setq file (gnus-article-save save-buffer file num))
8377 (gnus-summary-remove-process-mark article)
8379 (gnus-summary-set-saved-mark article))))
8380 (gnus-kill-buffer save-buffer)
8381 (gnus-summary-position-point)
8382 (gnus-set-mode-line 'summary)
8385 (defun gnus-summary-pipe-output (&optional arg)
8386 "Pipe the current article to a subprocess.
8387 If N is a positive number, pipe the N next articles.
8388 If N is a negative number, pipe the N previous articles.
8389 If N is nil and any articles have been marked with the process mark,
8390 pipe those articles instead."
8392 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8393 (gnus-summary-save-article arg t))
8394 (gnus-configure-windows 'pipe))
8396 (defun gnus-summary-save-article-mail (&optional arg)
8397 "Append the current article to an mail file.
8398 If N is a positive number, save the N next articles.
8399 If N is a negative number, save the N previous articles.
8400 If N is nil and any articles have been marked with the process mark,
8401 save those articles instead."
8403 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8404 (gnus-summary-save-article arg)))
8406 (defun gnus-summary-save-article-rmail (&optional arg)
8407 "Append the current article to an rmail file.
8408 If N is a positive number, save the N next articles.
8409 If N is a negative number, save the N previous articles.
8410 If N is nil and any articles have been marked with the process mark,
8411 save those articles instead."
8413 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8414 (gnus-summary-save-article arg)))
8416 (defun gnus-summary-save-article-file (&optional arg)
8417 "Append the current article to a file.
8418 If N is a positive number, save the N next articles.
8419 If N is a negative number, save the N previous articles.
8420 If N is nil and any articles have been marked with the process mark,
8421 save those articles instead."
8423 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8424 (gnus-summary-save-article arg)))
8426 (defun gnus-summary-write-article-file (&optional arg)
8427 "Write the current article to a file, deleting the previous file.
8428 If N is a positive number, save the N next articles.
8429 If N is a negative number, save the N previous articles.
8430 If N is nil and any articles have been marked with the process mark,
8431 save those articles instead."
8433 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8434 (gnus-summary-save-article arg)))
8436 (defun gnus-summary-save-article-body-file (&optional arg)
8437 "Append the current article body to a file.
8438 If N is a positive number, save the N next articles.
8439 If N is a negative number, save the N previous articles.
8440 If N is nil and any articles have been marked with the process mark,
8441 save those articles instead."
8443 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8444 (gnus-summary-save-article arg)))
8446 (defun gnus-summary-pipe-message (program)
8447 "Pipe the current article through PROGRAM."
8448 (interactive "sProgram: ")
8449 (gnus-summary-select-article)
8450 (let ((mail-header-separator "")
8451 (art-buf (get-buffer gnus-article-buffer)))
8452 (gnus-eval-in-buffer-window gnus-article-buffer
8455 (let ((start (window-start))
8457 (message-pipe-buffer-body program)
8458 (set-window-start (get-buffer-window (current-buffer)) start))))))
8460 (defun gnus-get-split-value (methods)
8461 "Return a value based on the split METHODS."
8462 (let (split-name method result match)
8465 (set-buffer gnus-original-article-buffer)
8467 (nnheader-narrow-to-headers)
8469 (goto-char (point-min))
8470 (setq method (pop methods))
8471 (setq match (car method))
8474 ;; Regular expression.
8476 (re-search-forward match nil t)))
8477 ((gnus-functionp match)
8481 (setq result (funcall match gnus-newsgroup-name))))
8486 (setq result (eval match)))))
8487 (setq split-name (append (cdr method) split-name))
8488 (cond ((stringp result)
8489 (push (expand-file-name
8490 result gnus-article-save-directory)
8493 (setq split-name (append result split-name)))))))))
8496 (defun gnus-valid-move-group-p (group)
8501 (car (gnus-find-method-for-group
8502 (symbol-name group))))
8503 gnus-valid-select-methods))))
8505 (defun gnus-read-move-group-name (prompt default articles prefix)
8506 "Read a group name."
8507 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8508 (minibuffer-confirm-incomplete nil) ; XEmacs
8512 (if (> (length articles) 1)
8513 (format "these %d articles" (length articles))
8518 (gnus-completing-read default prom
8520 'gnus-valid-move-group-p
8522 'gnus-group-history))
8523 ((= 1 (length split-name))
8524 (gnus-completing-read (car split-name) prom
8526 'gnus-valid-move-group-p
8528 'gnus-group-history))
8530 (gnus-completing-read nil prom
8531 (mapcar (lambda (el) (list el))
8532 (nreverse split-name))
8534 'gnus-group-history)))))
8536 (if (or (string= to-newsgroup "")
8537 (string= to-newsgroup prefix))
8538 (setq to-newsgroup default))
8539 (unless to-newsgroup
8540 (error "No group name entered"))
8541 (or (gnus-active to-newsgroup)
8542 (gnus-activate-group to-newsgroup)
8543 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8545 (or (and (gnus-request-create-group
8546 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8547 (gnus-activate-group to-newsgroup nil nil
8548 (gnus-group-name-to-method
8550 (error "Couldn't create group %s" to-newsgroup)))
8551 (error "No such group: %s" to-newsgroup)))
8554 ;; Summary extract commands
8556 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8557 (let ((buffer-read-only nil)
8558 (article (gnus-summary-article-number))
8560 (unless (gnus-summary-goto-subject article)
8561 (error "No such article: %d" article))
8562 (gnus-summary-position-point)
8563 ;; If all commands are to be bunched up on one line, we collect
8565 (unless gnus-view-pseudos-separately
8566 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8569 (setq action (cdr (assq 'action (car ps))))
8570 (setq files (list (cdr (assq 'name (car ps)))))
8571 (while (and ps (cdr ps)
8572 (string= (or action "1")
8573 (or (cdr (assq 'action (cadr ps))) "2")))
8574 (push (cdr (assq 'name (cadr ps))) files)
8575 (setcdr ps (cddr ps)))
8577 (when (not (string-match "%s" action))
8580 (when (assq 'execute (car ps))
8581 (setcdr (assq 'execute (car ps))
8582 (funcall (if (string-match "%s" action)
8589 (gnus-quote-arg-for-sh-or-csh f)))
8591 (setq ps (cdr ps)))))
8592 (if (and gnus-view-pseudos (not not-view))
8594 (when (assq 'execute (car pslist))
8595 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8596 (eq gnus-view-pseudos 'not-confirm)))
8597 (setq pslist (cdr pslist)))
8600 (setq after-article (or (cdr (assq 'article (car pslist)))
8601 (gnus-summary-article-number)))
8602 (gnus-summary-goto-subject after-article)
8605 (insert " " (file-name-nondirectory
8606 (cdr (assq 'name (car pslist))))
8607 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8609 (forward-line -1) ; back to `b'
8610 (gnus-add-text-properties
8611 b (1- e) (list 'gnus-number gnus-reffed-article-number
8612 gnus-mouse-face-prop gnus-mouse-face))
8614 after-article gnus-reffed-article-number
8615 gnus-unread-mark b (car pslist) 0 (- e b))
8616 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8617 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8618 (setq pslist (cdr pslist)))))))
8620 (defun gnus-pseudos< (p1 p2)
8621 (let ((c1 (cdr (assq 'action p1)))
8622 (c2 (cdr (assq 'action p2))))
8623 (and c1 c2 (string< c1 c2))))
8625 (defun gnus-request-pseudo-article (props)
8626 (cond ((assq 'execute props)
8627 (gnus-execute-command (cdr (assq 'execute props)))))
8628 (let ((gnus-current-article (gnus-summary-article-number)))
8629 (run-hooks 'gnus-mark-article-hook)))
8631 (defun gnus-execute-command (command &optional automatic)
8633 (gnus-article-setup-buffer)
8634 (set-buffer gnus-article-buffer)
8635 (setq buffer-read-only nil)
8636 (let ((command (if automatic command
8637 (read-string "Command: " (cons command 0)))))
8639 (insert "$ " command "\n\n")
8640 (if gnus-view-pseudo-asynchronously
8641 (start-process "gnus-execute" (current-buffer) shell-file-name
8642 shell-command-switch command)
8643 (call-process shell-file-name nil t nil
8644 shell-command-switch command)))))
8646 ;; Summary kill commands.
8648 (defun gnus-summary-edit-global-kill (article)
8649 "Edit the \"global\" kill file."
8650 (interactive (list (gnus-summary-article-number)))
8651 (gnus-group-edit-global-kill article))
8653 (defun gnus-summary-edit-local-kill ()
8654 "Edit a local kill file applied to the current newsgroup."
8656 (setq gnus-current-headers (gnus-summary-article-header))
8657 (gnus-group-edit-local-kill
8658 (gnus-summary-article-number) gnus-newsgroup-name))
8662 (defun gnus-read-header (id &optional header)
8663 "Read the headers of article ID and enter them into the Gnus system."
8664 (let ((group gnus-newsgroup-name)
8665 (gnus-override-method
8666 (and (gnus-news-group-p gnus-newsgroup-name)
8667 gnus-refer-article-method))
8669 ;; First we check to see whether the header in question is already
8672 ;; This is a Message-ID.
8673 (setq header (or header (gnus-id-to-header id)))
8674 ;; This is an article number.
8675 (setq header (or header (gnus-summary-article-header id))))
8677 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8678 ;; We have found the header.
8680 ;; If this is a sparse article, we have to nix out its
8681 ;; previous entry in the thread hashtb.
8683 (gnus-summary-article-sparse-p (mail-header-number header)))
8684 (let* ((parent (gnus-parent-id (mail-header-references header)))
8687 (gnus-gethash parent gnus-newsgroup-dependencies))))
8689 (delq (assq header thread) thread))))
8690 ;; We have to really fetch the header to this article.
8692 (set-buffer nntp-server-buffer)
8693 (when (setq where (gnus-request-head id group))
8694 (nnheader-fold-continuation-lines)
8695 (goto-char (point-max))
8697 (goto-char (point-min))
8701 ((cdr where) (cdr where))
8702 (header (mail-header-number header))
8703 (t gnus-reffed-article-number))
8705 (insert " Article retrieved.\n"))
8707 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8708 () ; Malformed head.
8709 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8710 (when (and (stringp id)
8711 (not (string= (gnus-group-real-name group)
8713 ;; If we fetched by Message-ID and the article came
8714 ;; from a different group, we fudge some bogus article
8715 ;; numbers for this article.
8716 (mail-header-set-number header gnus-reffed-article-number))
8718 (set-buffer gnus-summary-buffer)
8719 (decf gnus-reffed-article-number)
8720 (gnus-remove-header (mail-header-number header))
8721 (push header gnus-newsgroup-headers)
8722 (setq gnus-current-headers header)
8723 (push (mail-header-number header) gnus-newsgroup-limit)))
8726 (defun gnus-remove-header (number)
8727 "Remove header NUMBER from `gnus-newsgroup-headers'."
8728 (if (and gnus-newsgroup-headers
8729 (= number (mail-header-number (car gnus-newsgroup-headers))))
8730 (pop gnus-newsgroup-headers)
8731 (let ((headers gnus-newsgroup-headers))
8732 (while (and (cdr headers)
8733 (not (= number (mail-header-number (cadr headers)))))
8736 (setcdr headers (cddr headers))))))
8739 ;;; summary highlights
8742 (defun gnus-highlight-selected-summary ()
8743 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8744 ;; Highlight selected article in summary buffer
8745 (when gnus-summary-selected-face
8747 (let* ((beg (progn (beginning-of-line) (point)))
8748 (end (progn (end-of-line) (point)))
8749 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8750 (from (if (get-text-property beg gnus-mouse-face-prop)
8752 (or (next-single-property-change
8753 beg gnus-mouse-face-prop nil end)
8758 (or (next-single-property-change
8759 from gnus-mouse-face-prop nil end)
8761 ;; If no mouse-face prop on line we will have to = from = end,
8762 ;; so we highlight the entire line instead.
8763 (when (= (+ to 2) from)
8766 (if gnus-newsgroup-selected-overlay
8767 ;; Move old overlay.
8769 gnus-newsgroup-selected-overlay from to (current-buffer))
8770 ;; Create new overlay.
8772 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8773 'face gnus-summary-selected-face))))))
8775 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8776 (defun gnus-summary-highlight-line ()
8777 "Highlight current line according to `gnus-summary-highlight'."
8778 (let* ((list gnus-summary-highlight)
8780 (end (progn (end-of-line) (point)))
8781 ;; now find out where the line starts and leave point there.
8782 (beg (progn (beginning-of-line) (point)))
8783 (article (gnus-summary-article-number))
8784 (score (or (cdr (assq (or article gnus-current-article)
8785 gnus-newsgroup-scored))
8786 gnus-summary-default-score 0))
8787 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8788 (inhibit-read-only t))
8789 ;; Eval the cars of the lists until we find a match.
8790 (let ((default gnus-summary-default-score))
8792 (not (eval (caar list))))
8793 (setq list (cdr list))))
8794 (let ((face (cdar list)))
8795 (unless (eq face (get-text-property beg 'face))
8796 (gnus-put-text-property
8798 (setq face (if (boundp face) (symbol-value face) face)))
8799 (when gnus-summary-highlight-line-function
8800 (funcall gnus-summary-highlight-line-function article face))))
8803 (defun gnus-update-read-articles (group unread &optional compute)
8804 "Update the list of read articles in GROUP."
8805 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8806 (entry (gnus-gethash group gnus-newsrc-hashtb))
8807 (info (nth 2 entry))
8809 (unread (sort (copy-sequence unread) '<))
8811 (if (or (not info) (not active))
8812 ;; There is no info on this group if it was, in fact,
8813 ;; killed. Gnus stores no information on killed groups, so
8814 ;; there's nothing to be done.
8815 ;; One could store the information somewhere temporarily,
8816 ;; perhaps... Hmmm...
8818 ;; Remove any negative articles numbers.
8819 (while (and unread (< (car unread) 0))
8820 (setq unread (cdr unread)))
8821 ;; Remove any expired article numbers
8822 (while (and unread (< (car unread) (car active)))
8823 (setq unread (cdr unread)))
8824 ;; Compute the ranges of read articles by looking at the list of
8827 (when (/= (car unread) prev)
8828 (push (if (= prev (1- (car unread))) prev
8829 (cons prev (1- (car unread))))
8831 (setq prev (1+ (car unread)))
8832 (setq unread (cdr unread)))
8833 (when (<= prev (cdr active))
8834 (push (cons prev (cdr active)) read))
8836 (if (> (length read) 1) (nreverse read) read)
8838 (set-buffer gnus-group-buffer)
8841 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8842 (gnus-info-set-read ',info ',(gnus-info-read info))
8843 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8844 (gnus-group-update-group ,group t))))
8845 ;; Enter this list into the group info.
8847 info (if (> (length read) 1) (nreverse read) read))
8848 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8849 (gnus-get-unread-articles-in-group info (gnus-active group))
8852 (defun gnus-offer-save-summaries ()
8853 "Offer to save all active summary buffers."
8855 (let ((buflist (buffer-list))
8857 ;; Go through all buffers and find all summaries.
8859 (and (setq bufname (buffer-name (car buflist)))
8860 (string-match "Summary" bufname)
8862 (set-buffer bufname)
8863 ;; We check that this is, indeed, a summary buffer.
8864 (and (eq major-mode 'gnus-summary-mode)
8865 ;; Also make sure this isn't bogus.
8866 gnus-newsgroup-prepared
8867 ;; Also make sure that this isn't a dead summary buffer.
8868 (not gnus-dead-summary-mode)))
8869 (push bufname buffers))
8870 (setq buflist (cdr buflist)))
8871 ;; Go through all these summary buffers and offer to save them.
8874 "Update summary buffer %s? "
8875 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8882 (run-hooks 'gnus-sum-load-hook)
8884 ;;; gnus-sum.el ends here