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 :value (fun) function)
337 (cons :value ("" "") 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 ((memq mark (list gnus-unread-mark gnus-downloadable-mark
734 gnus-undownloaded-mark))
735 . gnus-summary-normal-unread-face)
737 . gnus-summary-high-read-face)
739 . gnus-summary-low-read-face)
741 . gnus-summary-normal-read-face))
742 "Controls the highlighting of summary buffer lines.
744 A list of (FORM . FACE) pairs. When deciding how a a particular
745 summary line should be displayed, each form is evaluated. The content
746 of the face field after the first true form is used. You can change
747 how those summary lines are displayed, by editing the face field.
749 You can use the following variables in the FORM field.
751 score: The articles score
752 default: The default article score.
753 below: The score below which articles are automatically marked as read.
754 mark: The articles mark."
755 :group 'gnus-summary-visual
756 :type '(repeat (cons (sexp :tag "Form" nil)
759 (defcustom gnus-alter-header-function nil
760 "Function called to allow alteration of article header structures.
761 The function is called with one parameter, the article header vector,
762 which it may alter in any way.")
764 ;;; Internal variables
766 (defvar gnus-scores-exclude-files nil)
767 (defvar gnus-page-broken nil)
769 (defvar gnus-original-article nil)
770 (defvar gnus-article-internal-prepare-hook nil)
771 (defvar gnus-newsgroup-process-stack nil)
773 (defvar gnus-thread-indent-array nil)
774 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
776 ;; Avoid highlighting in kill files.
777 (defvar gnus-summary-inhibit-highlight nil)
778 (defvar gnus-newsgroup-selected-overlay nil)
779 (defvar gnus-inhibit-limiting nil)
780 (defvar gnus-newsgroup-adaptive-score-file nil)
781 (defvar gnus-current-score-file nil)
782 (defvar gnus-current-move-group nil)
783 (defvar gnus-current-copy-group nil)
784 (defvar gnus-current-crosspost-group nil)
786 (defvar gnus-newsgroup-dependencies nil)
787 (defvar gnus-newsgroup-adaptive nil)
788 (defvar gnus-summary-display-article-function nil)
789 (defvar gnus-summary-highlight-line-function nil
790 "Function called after highlighting a summary line.")
792 (defvar gnus-summary-line-format-alist
793 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
794 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
795 (?s gnus-tmp-subject-or-nil ?s)
796 (?n gnus-tmp-name ?s)
797 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
799 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
801 (?F gnus-tmp-from ?s)
802 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
803 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
804 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
805 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
806 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
807 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
808 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
809 (?L gnus-tmp-lines ?d)
810 (?I gnus-tmp-indentation ?s)
811 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
812 (?R gnus-tmp-replied ?c)
813 (?\[ gnus-tmp-opening-bracket ?c)
814 (?\] gnus-tmp-closing-bracket ?c)
815 (?\> (make-string gnus-tmp-level ? ) ?s)
816 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
817 (?i gnus-tmp-score ?d)
818 (?z gnus-tmp-score-char ?c)
819 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
820 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
821 (?U gnus-tmp-unread ?c)
822 (?t (gnus-summary-number-of-articles-in-thread
823 (and (boundp 'thread) (car thread)) gnus-tmp-level)
825 (?e (gnus-summary-number-of-articles-in-thread
826 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
828 (?u gnus-tmp-user-defined ?s)
829 (?P (gnus-pick-line-number) ?d))
830 "An alist of format specifications that can appear in summary lines,
831 and what variables they correspond with, along with the type of the
832 variable (string, integer, character, etc).")
834 (defvar gnus-summary-dummy-line-format-alist
835 `((?S gnus-tmp-subject ?s)
836 (?N gnus-tmp-number ?d)
837 (?u gnus-tmp-user-defined ?s)))
839 (defvar gnus-summary-mode-line-format-alist
840 `((?G gnus-tmp-group-name ?s)
841 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
842 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
843 (?A gnus-tmp-article-number ?d)
844 (?Z gnus-tmp-unread-and-unselected ?s)
846 (?U gnus-tmp-unread-and-unticked ?d)
847 (?S gnus-tmp-subject ?s)
848 (?e gnus-tmp-unselected ?d)
849 (?u gnus-tmp-user-defined ?s)
850 (?d (length gnus-newsgroup-dormant) ?d)
851 (?t (length gnus-newsgroup-marked) ?d)
852 (?r (length gnus-newsgroup-reads) ?d)
853 (?E gnus-newsgroup-expunged-tally ?d)
854 (?s (gnus-current-score-file-nondirectory) ?s)))
856 (defvar gnus-last-search-regexp nil
857 "Default regexp for article search command.")
859 (defvar gnus-last-shell-command nil
860 "Default shell command on article.")
862 (defvar gnus-newsgroup-begin nil)
863 (defvar gnus-newsgroup-end nil)
864 (defvar gnus-newsgroup-last-rmail nil)
865 (defvar gnus-newsgroup-last-mail nil)
866 (defvar gnus-newsgroup-last-folder nil)
867 (defvar gnus-newsgroup-last-file nil)
868 (defvar gnus-newsgroup-auto-expire nil)
869 (defvar gnus-newsgroup-active nil)
871 (defvar gnus-newsgroup-data nil)
872 (defvar gnus-newsgroup-data-reverse nil)
873 (defvar gnus-newsgroup-limit nil)
874 (defvar gnus-newsgroup-limits nil)
876 (defvar gnus-newsgroup-unreads nil
877 "List of unread articles in the current newsgroup.")
879 (defvar gnus-newsgroup-unselected nil
880 "List of unselected unread articles in the current newsgroup.")
882 (defvar gnus-newsgroup-reads nil
883 "Alist of read articles and article marks in the current newsgroup.")
885 (defvar gnus-newsgroup-expunged-tally nil)
887 (defvar gnus-newsgroup-marked nil
888 "List of ticked articles in the current newsgroup (a subset of unread art).")
890 (defvar gnus-newsgroup-killed nil
891 "List of ranges of articles that have been through the scoring process.")
893 (defvar gnus-newsgroup-cached nil
894 "List of articles that come from the article cache.")
896 (defvar gnus-newsgroup-saved nil
897 "List of articles that have been saved.")
899 (defvar gnus-newsgroup-kill-headers nil)
901 (defvar gnus-newsgroup-replied nil
902 "List of articles that have been replied to in the current newsgroup.")
904 (defvar gnus-newsgroup-expirable nil
905 "List of articles in the current newsgroup that can be expired.")
907 (defvar gnus-newsgroup-processable nil
908 "List of articles in the current newsgroup that can be processed.")
910 (defvar gnus-newsgroup-downloadable nil
911 "List of articles in the current newsgroup that can be processed.")
913 (defvar gnus-newsgroup-undownloaded nil
914 "List of articles in the current newsgroup that haven't been downloaded..")
916 (defvar gnus-newsgroup-unsendable nil
917 "List of articles in the current newsgroup that won't be sent.")
919 (defvar gnus-newsgroup-bookmarks nil
920 "List of articles in the current newsgroup that have bookmarks.")
922 (defvar gnus-newsgroup-dormant nil
923 "List of dormant articles in the current newsgroup.")
925 (defvar gnus-newsgroup-scored nil
926 "List of scored articles in the current newsgroup.")
928 (defvar gnus-newsgroup-headers nil
929 "List of article headers in the current newsgroup.")
931 (defvar gnus-newsgroup-threads nil)
933 (defvar gnus-newsgroup-prepared nil
934 "Whether the current group has been prepared properly.")
936 (defvar gnus-newsgroup-ancient nil
937 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
939 (defvar gnus-newsgroup-sparse nil)
941 (defvar gnus-current-article nil)
942 (defvar gnus-article-current nil)
943 (defvar gnus-current-headers nil)
944 (defvar gnus-have-all-headers nil)
945 (defvar gnus-last-article nil)
946 (defvar gnus-newsgroup-history nil)
948 (defconst gnus-summary-local-variables
949 '(gnus-newsgroup-name
950 gnus-newsgroup-begin gnus-newsgroup-end
951 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
952 gnus-newsgroup-last-folder gnus-newsgroup-last-file
953 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
954 gnus-newsgroup-unselected gnus-newsgroup-marked
955 gnus-newsgroup-reads gnus-newsgroup-saved
956 gnus-newsgroup-replied gnus-newsgroup-expirable
957 gnus-newsgroup-processable gnus-newsgroup-killed
958 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
959 gnus-newsgroup-unsendable
960 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
961 gnus-newsgroup-headers gnus-newsgroup-threads
962 gnus-newsgroup-prepared gnus-summary-highlight-line-function
963 gnus-current-article gnus-current-headers gnus-have-all-headers
964 gnus-last-article gnus-article-internal-prepare-hook
965 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
966 gnus-newsgroup-scored gnus-newsgroup-kill-headers
967 gnus-thread-expunge-below
968 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
969 (gnus-summary-mark-below . global)
970 gnus-newsgroup-active gnus-scores-exclude-files
971 gnus-newsgroup-history gnus-newsgroup-ancient
972 gnus-newsgroup-sparse gnus-newsgroup-process-stack
973 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
974 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
975 (gnus-newsgroup-expunged-tally . 0)
976 gnus-cache-removable-articles gnus-newsgroup-cached
977 gnus-newsgroup-data gnus-newsgroup-data-reverse
978 gnus-newsgroup-limit gnus-newsgroup-limits)
979 "Variables that are buffer-local to the summary buffers.")
981 ;; Byte-compiler warning.
982 (defvar gnus-article-mode-map)
984 ;; Subject simplification.
986 (defun gnus-simplify-whitespace (str)
987 "Remove excessive whitespace."
990 (while (string-match "[ \t][ \t]+" mystr)
991 (setq mystr (concat (substring mystr 0 (match-beginning 0))
993 (substring mystr (match-end 0)))))
995 (when (string-match "^[ \t]+" mystr)
996 (setq mystr (substring mystr (match-end 0))))
998 (when (string-match "[ \t]+$" mystr)
999 (setq mystr (substring mystr 0 (match-beginning 0))))
1002 (defsubst gnus-simplify-subject-re (subject)
1003 "Remove \"Re:\" from subject lines."
1004 (if (string-match "^[Rr][Ee]: *" subject)
1005 (substring subject (match-end 0))
1008 (defun gnus-simplify-subject (subject &optional re-only)
1009 "Remove `Re:' and words in parentheses.
1010 If RE-ONLY is non-nil, strip leading `Re:'s only."
1011 (let ((case-fold-search t)) ;Ignore case.
1012 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1013 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1014 (setq subject (substring subject (match-end 0))))
1015 ;; Remove uninteresting prefixes.
1016 (when (and (not re-only)
1017 gnus-simplify-ignored-prefixes
1018 (string-match gnus-simplify-ignored-prefixes subject))
1019 (setq subject (substring subject (match-end 0))))
1020 ;; Remove words in parentheses from end.
1022 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1023 (setq subject (substring subject 0 (match-beginning 0)))))
1024 ;; Return subject string.
1027 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1029 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1030 (goto-char (point-min))
1031 (while (re-search-forward regexp nil t)
1032 (replace-match (or newtext ""))))
1034 (defun gnus-simplify-buffer-fuzzy ()
1035 "Simplify string in the buffer fuzzily.
1036 The string in the accessible portion of the current buffer is simplified.
1037 It is assumed to be a single-line subject.
1038 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1039 matter is removed. Additional things can be deleted by setting
1040 gnus-simplify-subject-fuzzy-regexp."
1041 (let ((case-fold-search t)
1043 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1045 (while (not (eq modified-tick (buffer-modified-tick)))
1046 (setq modified-tick (buffer-modified-tick))
1048 ((listp gnus-simplify-subject-fuzzy-regexp)
1049 (mapcar 'gnus-simplify-buffer-fuzzy-step
1050 gnus-simplify-subject-fuzzy-regexp))
1051 (gnus-simplify-subject-fuzzy-regexp
1052 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1053 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1054 (gnus-simplify-buffer-fuzzy-step
1055 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1056 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1058 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1059 (gnus-simplify-buffer-fuzzy-step " +" " ")
1060 (gnus-simplify-buffer-fuzzy-step " $")
1061 (gnus-simplify-buffer-fuzzy-step "^ +")))
1063 (defun gnus-simplify-subject-fuzzy (subject)
1064 "Simplify a subject string fuzzily.
1065 See `gnus-simplify-buffer-fuzzy' for details."
1067 (gnus-set-work-buffer)
1068 (let ((case-fold-search t))
1070 (inline (gnus-simplify-buffer-fuzzy))
1073 (defsubst gnus-simplify-subject-fully (subject)
1074 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1076 (gnus-simplify-subject-functions
1077 (gnus-map-function gnus-simplify-subject-functions subject))
1078 ((null gnus-summary-gather-subject-limit)
1079 (gnus-simplify-subject-re subject))
1080 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1081 (gnus-simplify-subject-fuzzy subject))
1082 ((numberp gnus-summary-gather-subject-limit)
1083 (gnus-limit-string (gnus-simplify-subject-re subject)
1084 gnus-summary-gather-subject-limit))
1088 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1089 "Check whether two subjects are equal.
1090 If optional argument simple-first is t, first argument is already
1093 ((null simple-first)
1094 (equal (gnus-simplify-subject-fully s1)
1095 (gnus-simplify-subject-fully s2)))
1098 (gnus-simplify-subject-fully s2)))))
1100 (defun gnus-summary-bubble-group ()
1101 "Increase the score of the current group.
1102 This is a handy function to add to `gnus-summary-exit-hook' to
1103 increase the score of each group you read."
1104 (gnus-group-add-score gnus-newsgroup-name))
1108 ;;; Gnus summary mode
1111 (put 'gnus-summary-mode 'mode-class 'special)
1114 ;; Non-orthogonal keys
1116 (gnus-define-keys gnus-summary-mode-map
1117 " " gnus-summary-next-page
1118 "\177" gnus-summary-prev-page
1119 [delete] gnus-summary-prev-page
1120 [backspace] gnus-summary-prev-page
1121 "\r" gnus-summary-scroll-up
1122 "n" gnus-summary-next-unread-article
1123 "p" gnus-summary-prev-unread-article
1124 "N" gnus-summary-next-article
1125 "P" gnus-summary-prev-article
1126 "\M-\C-n" gnus-summary-next-same-subject
1127 "\M-\C-p" gnus-summary-prev-same-subject
1128 "\M-n" gnus-summary-next-unread-subject
1129 "\M-p" gnus-summary-prev-unread-subject
1130 "." gnus-summary-first-unread-article
1131 "," gnus-summary-best-unread-article
1132 "\M-s" gnus-summary-search-article-forward
1133 "\M-r" gnus-summary-search-article-backward
1134 "<" gnus-summary-beginning-of-article
1135 ">" gnus-summary-end-of-article
1136 "j" gnus-summary-goto-article
1137 "^" gnus-summary-refer-parent-article
1138 "\M-^" gnus-summary-refer-article
1139 "u" gnus-summary-tick-article-forward
1140 "!" gnus-summary-tick-article-forward
1141 "U" gnus-summary-tick-article-backward
1142 "d" gnus-summary-mark-as-read-forward
1143 "D" gnus-summary-mark-as-read-backward
1144 "E" gnus-summary-mark-as-expirable
1145 "\M-u" gnus-summary-clear-mark-forward
1146 "\M-U" gnus-summary-clear-mark-backward
1147 "k" gnus-summary-kill-same-subject-and-select
1148 "\C-k" gnus-summary-kill-same-subject
1149 "\M-\C-k" gnus-summary-kill-thread
1150 "\M-\C-l" gnus-summary-lower-thread
1151 "e" gnus-summary-edit-article
1152 "#" gnus-summary-mark-as-processable
1153 "\M-#" gnus-summary-unmark-as-processable
1154 "\M-\C-t" gnus-summary-toggle-threads
1155 "\M-\C-s" gnus-summary-show-thread
1156 "\M-\C-h" gnus-summary-hide-thread
1157 "\M-\C-f" gnus-summary-next-thread
1158 "\M-\C-b" gnus-summary-prev-thread
1159 "\M-\C-u" gnus-summary-up-thread
1160 "\M-\C-d" gnus-summary-down-thread
1161 "&" gnus-summary-execute-command
1162 "c" gnus-summary-catchup-and-exit
1163 "\C-w" gnus-summary-mark-region-as-read
1164 "\C-t" gnus-summary-toggle-truncation
1165 "?" gnus-summary-mark-as-dormant
1166 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1167 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1168 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1169 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1170 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1171 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1172 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1173 "=" gnus-summary-expand-window
1174 "\C-x\C-s" gnus-summary-reselect-current-group
1175 "\M-g" gnus-summary-rescan-group
1176 "w" gnus-summary-stop-page-breaking
1177 "\C-c\C-r" gnus-summary-caesar-message
1178 "\M-t" gnus-summary-toggle-mime
1179 "f" gnus-summary-followup
1180 "F" gnus-summary-followup-with-original
1181 "C" gnus-summary-cancel-article
1182 "r" gnus-summary-reply
1183 "R" gnus-summary-reply-with-original
1184 "\C-c\C-f" gnus-summary-mail-forward
1185 "o" gnus-summary-save-article
1186 "\C-o" gnus-summary-save-article-mail
1187 "|" gnus-summary-pipe-output
1188 "\M-k" gnus-summary-edit-local-kill
1189 "\M-K" gnus-summary-edit-global-kill
1191 "\C-c\C-d" gnus-summary-describe-group
1192 "q" gnus-summary-exit
1193 "Q" gnus-summary-exit-no-update
1194 "\C-c\C-i" gnus-info-find-node
1195 gnus-mouse-2 gnus-mouse-pick-article
1196 "m" gnus-summary-mail-other-window
1197 "a" gnus-summary-post-news
1198 "x" gnus-summary-limit-to-unread
1199 "s" gnus-summary-isearch-article
1200 "t" gnus-article-hide-headers
1201 "g" gnus-summary-show-article
1202 "l" gnus-summary-goto-last-article
1203 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1204 "\C-d" gnus-summary-enter-digest-group
1205 "\M-\C-d" gnus-summary-read-document
1207 "*" gnus-cache-enter-article
1208 "\M-*" gnus-cache-remove-article
1209 "\M-&" gnus-summary-universal-argument
1210 "\C-l" gnus-recenter
1211 "I" gnus-summary-increase-score
1212 "L" gnus-summary-lower-score
1213 "\M-i" gnus-symbolic-argument
1214 "h" gnus-summary-select-article-buffer
1216 "V" gnus-summary-score-map
1217 "X" gnus-uu-extract-map
1218 "S" gnus-summary-send-map)
1220 ;; Sort of orthogonal keymap
1221 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1222 "t" gnus-summary-tick-article-forward
1223 "!" gnus-summary-tick-article-forward
1224 "d" gnus-summary-mark-as-read-forward
1225 "r" gnus-summary-mark-as-read-forward
1226 "c" gnus-summary-clear-mark-forward
1227 " " gnus-summary-clear-mark-forward
1228 "e" gnus-summary-mark-as-expirable
1229 "x" gnus-summary-mark-as-expirable
1230 "?" gnus-summary-mark-as-dormant
1231 "b" gnus-summary-set-bookmark
1232 "B" gnus-summary-remove-bookmark
1233 "#" gnus-summary-mark-as-processable
1234 "\M-#" gnus-summary-unmark-as-processable
1235 "S" gnus-summary-limit-include-expunged
1236 "C" gnus-summary-catchup
1237 "H" gnus-summary-catchup-to-here
1238 "\C-c" gnus-summary-catchup-all
1239 "k" gnus-summary-kill-same-subject-and-select
1240 "K" gnus-summary-kill-same-subject
1241 "P" gnus-uu-mark-map)
1243 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1244 "c" gnus-summary-clear-above
1245 "u" gnus-summary-tick-above
1246 "m" gnus-summary-mark-above
1247 "k" gnus-summary-kill-below)
1249 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1250 "/" gnus-summary-limit-to-subject
1251 "n" gnus-summary-limit-to-articles
1252 "w" gnus-summary-pop-limit
1253 "s" gnus-summary-limit-to-subject
1254 "a" gnus-summary-limit-to-author
1255 "u" gnus-summary-limit-to-unread
1256 "m" gnus-summary-limit-to-marks
1257 "v" gnus-summary-limit-to-score
1258 "*" gnus-summary-limit-include-cached
1259 "D" gnus-summary-limit-include-dormant
1260 "T" gnus-summary-limit-include-thread
1261 "d" gnus-summary-limit-exclude-dormant
1262 "t" gnus-summary-limit-to-age
1263 "E" gnus-summary-limit-include-expunged
1264 "c" gnus-summary-limit-exclude-childless-dormant
1265 "C" gnus-summary-limit-mark-excluded-as-read)
1267 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1268 "n" gnus-summary-next-unread-article
1269 "p" gnus-summary-prev-unread-article
1270 "N" gnus-summary-next-article
1271 "P" gnus-summary-prev-article
1272 "\C-n" gnus-summary-next-same-subject
1273 "\C-p" gnus-summary-prev-same-subject
1274 "\M-n" gnus-summary-next-unread-subject
1275 "\M-p" gnus-summary-prev-unread-subject
1276 "f" gnus-summary-first-unread-article
1277 "b" gnus-summary-best-unread-article
1278 "j" gnus-summary-goto-article
1279 "g" gnus-summary-goto-subject
1280 "l" gnus-summary-goto-last-article
1281 "o" gnus-summary-pop-article)
1283 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1284 "k" gnus-summary-kill-thread
1285 "l" gnus-summary-lower-thread
1286 "i" gnus-summary-raise-thread
1287 "T" gnus-summary-toggle-threads
1288 "t" gnus-summary-rethread-current
1289 "^" gnus-summary-reparent-thread
1290 "s" gnus-summary-show-thread
1291 "S" gnus-summary-show-all-threads
1292 "h" gnus-summary-hide-thread
1293 "H" gnus-summary-hide-all-threads
1294 "n" gnus-summary-next-thread
1295 "p" gnus-summary-prev-thread
1296 "u" gnus-summary-up-thread
1297 "o" gnus-summary-top-thread
1298 "d" gnus-summary-down-thread
1299 "#" gnus-uu-mark-thread
1300 "\M-#" gnus-uu-unmark-thread)
1302 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1303 "g" gnus-summary-prepare
1304 "c" gnus-summary-insert-cached-articles)
1306 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1307 "c" gnus-summary-catchup-and-exit
1308 "C" gnus-summary-catchup-all-and-exit
1309 "E" gnus-summary-exit-no-update
1310 "Q" gnus-summary-exit
1311 "Z" gnus-summary-exit
1312 "n" gnus-summary-catchup-and-goto-next-group
1313 "R" gnus-summary-reselect-current-group
1314 "G" gnus-summary-rescan-group
1315 "N" gnus-summary-next-group
1316 "s" gnus-summary-save-newsrc
1317 "P" gnus-summary-prev-group)
1319 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1320 " " gnus-summary-next-page
1321 "n" gnus-summary-next-page
1322 "\177" gnus-summary-prev-page
1323 [delete] gnus-summary-prev-page
1324 "p" gnus-summary-prev-page
1325 "\r" gnus-summary-scroll-up
1326 "<" gnus-summary-beginning-of-article
1327 ">" gnus-summary-end-of-article
1328 "b" gnus-summary-beginning-of-article
1329 "e" gnus-summary-end-of-article
1330 "^" gnus-summary-refer-parent-article
1331 "r" gnus-summary-refer-parent-article
1332 "R" gnus-summary-refer-references
1333 "T" gnus-summary-refer-thread
1334 "g" gnus-summary-show-article
1335 "s" gnus-summary-isearch-article
1336 "P" gnus-summary-print-article)
1338 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1339 "b" gnus-article-add-buttons
1340 "B" gnus-article-add-buttons-to-head
1341 "o" gnus-article-treat-overstrike
1342 "e" gnus-article-emphasize
1343 "w" gnus-article-fill-cited-article
1344 "c" gnus-article-remove-cr
1345 "q" gnus-article-de-quoted-unreadable
1346 "f" gnus-article-display-x-face
1347 "l" gnus-summary-stop-page-breaking
1348 "r" gnus-summary-caesar-message
1349 "t" gnus-article-hide-headers
1350 "v" gnus-summary-verbose-headers
1351 "m" gnus-summary-toggle-mime
1352 "h" gnus-article-treat-html
1353 "d" gnus-article-treat-dumbquotes)
1355 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1356 "a" gnus-article-hide
1357 "h" gnus-article-hide-headers
1358 "b" gnus-article-hide-boring-headers
1359 "s" gnus-article-hide-signature
1360 "c" gnus-article-hide-citation
1361 "p" gnus-article-hide-pgp
1362 "P" gnus-article-hide-pem
1363 "\C-c" gnus-article-hide-citation-maybe)
1365 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1366 "a" gnus-article-highlight
1367 "h" gnus-article-highlight-headers
1368 "c" gnus-article-highlight-citation
1369 "s" gnus-article-highlight-signature)
1371 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1372 "z" gnus-article-date-ut
1373 "u" gnus-article-date-ut
1374 "l" gnus-article-date-local
1375 "e" gnus-article-date-lapsed
1376 "o" gnus-article-date-original
1377 "s" gnus-article-date-user)
1379 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1380 "t" gnus-article-remove-trailing-blank-lines
1381 "l" gnus-article-strip-leading-blank-lines
1382 "m" gnus-article-strip-multiple-blank-lines
1383 "a" gnus-article-strip-blank-lines
1384 "s" gnus-article-strip-leading-space)
1386 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1388 "f" gnus-summary-fetch-faq
1389 "d" gnus-summary-describe-group
1390 "h" gnus-summary-describe-briefly
1391 "i" gnus-info-find-node)
1393 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1394 "e" gnus-summary-expire-articles
1395 "\M-\C-e" gnus-summary-expire-articles-now
1396 "\177" gnus-summary-delete-article
1397 [delete] gnus-summary-delete-article
1398 "m" gnus-summary-move-article
1399 "r" gnus-summary-respool-article
1400 "w" gnus-summary-edit-article
1401 "c" gnus-summary-copy-article
1402 "B" gnus-summary-crosspost-article
1403 "q" gnus-summary-respool-query
1404 "i" gnus-summary-import-article
1405 "p" gnus-summary-article-posted-p)
1407 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1408 "o" gnus-summary-save-article
1409 "m" gnus-summary-save-article-mail
1410 "F" gnus-summary-write-article-file
1411 "r" gnus-summary-save-article-rmail
1412 "f" gnus-summary-save-article-file
1413 "b" gnus-summary-save-article-body-file
1414 "h" gnus-summary-save-article-folder
1415 "v" gnus-summary-save-article-vm
1416 "p" gnus-summary-pipe-output
1417 "s" gnus-soup-add-article))
1419 (defun gnus-summary-make-menu-bar ()
1420 (gnus-turn-off-edit-menu 'summary)
1422 (unless (boundp 'gnus-summary-misc-menu)
1425 gnus-summary-kill-menu gnus-summary-mode-map ""
1430 ["Enter score..." gnus-summary-score-entry t]
1431 ["Customize" gnus-score-customize t])
1432 (gnus-make-score-map 'increase)
1433 (gnus-make-score-map 'lower)
1435 ["Kill below" gnus-summary-kill-below t]
1436 ["Mark above" gnus-summary-mark-above t]
1437 ["Tick above" gnus-summary-tick-above t]
1438 ["Clear above" gnus-summary-clear-above t])
1439 ["Current score" gnus-summary-current-score t]
1440 ["Set score" gnus-summary-set-score t]
1441 ["Switch current score file..." gnus-score-change-score-file t]
1442 ["Set mark below..." gnus-score-set-mark-below t]
1443 ["Set expunge below..." gnus-score-set-expunge-below t]
1444 ["Edit current score file" gnus-score-edit-current-scores t]
1445 ["Edit score file" gnus-score-edit-file t]
1446 ["Trace score" gnus-score-find-trace t]
1447 ["Find words" gnus-score-find-favourite-words t]
1448 ["Rescore buffer" gnus-summary-rescore t]
1449 ["Increase score..." gnus-summary-increase-score t]
1450 ["Lower score..." gnus-summary-lower-score t]))))
1453 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1455 :selected (null gnus-score-default-header)]
1456 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1458 :selected (eq gnus-score-default-header 'a)]
1459 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1461 :selected (eq gnus-score-default-header 's)]
1463 (gnus-score-set-default 'gnus-score-default-header 'b)
1465 :selected (eq gnus-score-default-header 'b )]
1467 (gnus-score-set-default 'gnus-score-default-header 'h)
1469 :selected (eq gnus-score-default-header 'h )]
1470 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1472 :selected (eq gnus-score-default-header 'i )]
1473 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1475 :selected (eq gnus-score-default-header 't )]
1477 (gnus-score-set-default 'gnus-score-default-header 'x)
1479 :selected (eq gnus-score-default-header 'x )]
1480 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1482 :selected (eq gnus-score-default-header 'l )]
1483 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1485 :selected (eq gnus-score-default-header 'd )]
1486 ["Followups to author"
1487 (gnus-score-set-default 'gnus-score-default-header 'f)
1489 :selected (eq gnus-score-default-header 'f )])
1491 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1493 :selected (null gnus-score-default-type)]
1494 ;; The `:active' key is commented out in the following,
1495 ;; because the GNU Emacs hack to support radio buttons use
1496 ;; active to indicate which button is selected.
1497 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1499 ;; :active (not (memq gnus-score-default-header '(l d)))
1500 :selected (eq gnus-score-default-type 's)]
1501 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1503 ;; :active (not (memq gnus-score-default-header '(l d)))
1504 :selected (eq gnus-score-default-type 'r)]
1505 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1507 ;; :active (not (memq gnus-score-default-header '(l d)))
1508 :selected (eq gnus-score-default-type 'e)]
1509 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1511 ;; :active (not (memq gnus-score-default-header '(l d)))
1512 :selected (eq gnus-score-default-type 'f)]
1513 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1515 ;; :active (eq (gnus-score-default-header 'd))
1516 :selected (eq gnus-score-default-type 'b)]
1517 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1519 ;; :active (eq (gnus-score-default-header 'd))
1520 :selected (eq gnus-score-default-type 'n)]
1521 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1523 ;; :active (eq (gnus-score-default-header 'd))
1524 :selected (eq gnus-score-default-type 'a)]
1526 (gnus-score-set-default 'gnus-score-default-type '<)
1528 ;; :active (eq (gnus-score-default-header 'l))
1529 :selected (eq gnus-score-default-type '<)]
1531 (gnus-score-set-default 'gnus-score-default-type '=)
1533 ;; :active (eq (gnus-score-default-header 'l))
1534 :selected (eq gnus-score-default-type '=)]
1535 ["Greater than number"
1536 (gnus-score-set-default 'gnus-score-default-type '>)
1538 ;; :active (eq (gnus-score-default-header 'l))
1539 :selected (eq gnus-score-default-type '>)])
1540 ["Default fold" gnus-score-default-fold-toggle
1542 :selected gnus-score-default-fold]
1544 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1546 :selected (null gnus-score-default-duration)]
1548 (gnus-score-set-default 'gnus-score-default-duration 'p)
1550 :selected (eq gnus-score-default-duration 'p)]
1552 (gnus-score-set-default 'gnus-score-default-duration 't)
1554 :selected (eq gnus-score-default-duration 't)]
1556 (gnus-score-set-default 'gnus-score-default-duration 'i)
1558 :selected (eq gnus-score-default-duration 'i)]))
1561 gnus-summary-article-menu gnus-summary-mode-map ""
1564 ["All" gnus-article-hide t]
1565 ["Headers" gnus-article-hide-headers t]
1566 ["Signature" gnus-article-hide-signature t]
1567 ["Citation" gnus-article-hide-citation t]
1568 ["PGP" gnus-article-hide-pgp t]
1569 ["Boring headers" gnus-article-hide-boring-headers t])
1571 ["All" gnus-article-highlight t]
1572 ["Headers" gnus-article-highlight-headers t]
1573 ["Signature" gnus-article-highlight-signature t]
1574 ["Citation" gnus-article-highlight-citation t])
1576 ["Local" gnus-article-date-local t]
1577 ["UT" gnus-article-date-ut t]
1578 ["Original" gnus-article-date-original t]
1579 ["Lapsed" gnus-article-date-lapsed t]
1580 ["User-defined" gnus-article-date-user t])
1583 ["Leading" gnus-article-strip-leading-blank-lines t]
1584 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1585 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1586 ["All of the above" gnus-article-strip-blank-lines t]
1587 ["Leading space" gnus-article-strip-leading-space t])
1588 ["Overstrike" gnus-article-treat-overstrike t]
1589 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1590 ["Emphasis" gnus-article-emphasize t]
1591 ["Word wrap" gnus-article-fill-cited-article t]
1592 ["CR" gnus-article-remove-cr t]
1593 ["Show X-Face" gnus-article-display-x-face t]
1594 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1595 ["UnHTMLize" gnus-article-treat-html t]
1596 ["Rot 13" gnus-summary-caesar-message t]
1597 ["Unix pipe" gnus-summary-pipe-message t]
1598 ["Add buttons" gnus-article-add-buttons t]
1599 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1600 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1601 ["Toggle MIME" gnus-summary-toggle-mime t]
1602 ["Verbose header" gnus-summary-verbose-headers t]
1603 ["Toggle header" gnus-summary-toggle-header t])
1605 ["Save in default format" gnus-summary-save-article t]
1606 ["Save in file" gnus-summary-save-article-file t]
1607 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1608 ["Save in MH folder" gnus-summary-save-article-folder t]
1609 ["Save in VM folder" gnus-summary-save-article-vm t]
1610 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1611 ["Save body in file" gnus-summary-save-article-body-file t]
1612 ["Pipe through a filter" gnus-summary-pipe-output t]
1613 ["Add to SOUP packet" gnus-soup-add-article t]
1614 ["Print" gnus-summary-print-article t])
1616 ["Respool article..." gnus-summary-respool-article t]
1617 ["Move article..." gnus-summary-move-article
1618 (gnus-check-backend-function
1619 'request-move-article gnus-newsgroup-name)]
1620 ["Copy article..." gnus-summary-copy-article t]
1621 ["Crosspost article..." gnus-summary-crosspost-article
1622 (gnus-check-backend-function
1623 'request-replace-article gnus-newsgroup-name)]
1624 ["Import file..." gnus-summary-import-article t]
1625 ["Check if posted" gnus-summary-article-posted-p t]
1626 ["Edit article" gnus-summary-edit-article
1627 (not (gnus-group-read-only-p))]
1628 ["Delete article" gnus-summary-delete-article
1629 (gnus-check-backend-function
1630 'request-expire-articles gnus-newsgroup-name)]
1631 ["Query respool" gnus-summary-respool-query t]
1632 ["Delete expirable articles" gnus-summary-expire-articles-now
1633 (gnus-check-backend-function
1634 'request-expire-articles gnus-newsgroup-name)])
1636 ["Uudecode" gnus-uu-decode-uu t]
1637 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1638 ["Unshar" gnus-uu-decode-unshar t]
1639 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1640 ["Save" gnus-uu-decode-save t]
1641 ["Binhex" gnus-uu-decode-binhex t]
1642 ["Postscript" gnus-uu-decode-postscript t])
1644 ["Enter article" gnus-cache-enter-article t]
1645 ["Remove article" gnus-cache-remove-article t])
1646 ["Select article buffer" gnus-summary-select-article-buffer t]
1647 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1648 ["Isearch article..." gnus-summary-isearch-article t]
1649 ["Beginning of the article" gnus-summary-beginning-of-article t]
1650 ["End of the article" gnus-summary-end-of-article t]
1651 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1652 ["Fetch referenced articles" gnus-summary-refer-references t]
1653 ["Fetch current thread" gnus-summary-refer-thread t]
1654 ["Fetch article with id..." gnus-summary-refer-article t]
1655 ["Redisplay" gnus-summary-show-article t]))
1658 gnus-summary-thread-menu gnus-summary-mode-map ""
1660 ["Toggle threading" gnus-summary-toggle-threads t]
1661 ["Hide threads" gnus-summary-hide-all-threads t]
1662 ["Show threads" gnus-summary-show-all-threads t]
1663 ["Hide thread" gnus-summary-hide-thread t]
1664 ["Show thread" gnus-summary-show-thread t]
1665 ["Go to next thread" gnus-summary-next-thread t]
1666 ["Go to previous thread" gnus-summary-prev-thread t]
1667 ["Go down thread" gnus-summary-down-thread t]
1668 ["Go up thread" gnus-summary-up-thread t]
1669 ["Top of thread" gnus-summary-top-thread t]
1670 ["Mark thread as read" gnus-summary-kill-thread t]
1671 ["Lower thread score" gnus-summary-lower-thread t]
1672 ["Raise thread score" gnus-summary-raise-thread t]
1673 ["Rethread current" gnus-summary-rethread-current t]
1677 gnus-summary-post-menu gnus-summary-mode-map ""
1679 ["Post an article" gnus-summary-post-news t]
1680 ["Followup" gnus-summary-followup t]
1681 ["Followup and yank" gnus-summary-followup-with-original t]
1682 ["Supersede article" gnus-summary-supersede-article t]
1683 ["Cancel article" gnus-summary-cancel-article t]
1684 ["Reply" gnus-summary-reply t]
1685 ["Reply and yank" gnus-summary-reply-with-original t]
1686 ["Wide reply" gnus-summary-wide-reply t]
1687 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1688 ["Mail forward" gnus-summary-mail-forward t]
1689 ["Post forward" gnus-summary-post-forward t]
1690 ["Digest and mail" gnus-uu-digest-mail-forward t]
1691 ["Digest and post" gnus-uu-digest-post-forward t]
1692 ["Resend message" gnus-summary-resend-message t]
1693 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1694 ["Send a mail" gnus-summary-mail-other-window t]
1695 ["Uuencode and post" gnus-uu-post-news t]
1696 ["Followup via news" gnus-summary-followup-to-mail t]
1697 ["Followup via news and yank"
1698 gnus-summary-followup-to-mail-with-original t]
1700 ;;["Send" gnus-summary-send-draft t]
1701 ;;["Send bounced" gnus-resend-bounced-mail t])
1705 gnus-summary-misc-menu gnus-summary-mode-map ""
1708 ["Mark as read" gnus-summary-mark-as-read-forward t]
1709 ["Mark same subject and select"
1710 gnus-summary-kill-same-subject-and-select t]
1711 ["Mark same subject" gnus-summary-kill-same-subject t]
1712 ["Catchup" gnus-summary-catchup t]
1713 ["Catchup all" gnus-summary-catchup-all t]
1714 ["Catchup to here" gnus-summary-catchup-to-here t]
1715 ["Catchup region" gnus-summary-mark-region-as-read t]
1716 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1718 ["Tick" gnus-summary-tick-article-forward t]
1719 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1720 ["Remove marks" gnus-summary-clear-mark-forward t]
1721 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1722 ["Set bookmark" gnus-summary-set-bookmark t]
1723 ["Remove bookmark" gnus-summary-remove-bookmark t])
1725 ["Marks..." gnus-summary-limit-to-marks t]
1726 ["Subject..." gnus-summary-limit-to-subject t]
1727 ["Author..." gnus-summary-limit-to-author t]
1728 ["Age..." gnus-summary-limit-to-age t]
1729 ["Score" gnus-summary-limit-to-score t]
1730 ["Unread" gnus-summary-limit-to-unread t]
1731 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1732 ["Articles" gnus-summary-limit-to-articles t]
1733 ["Pop limit" gnus-summary-pop-limit t]
1734 ["Show dormant" gnus-summary-limit-include-dormant t]
1735 ["Hide childless dormant"
1736 gnus-summary-limit-exclude-childless-dormant t]
1737 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1738 ["Show expunged" gnus-summary-show-all-expunged t])
1740 ["Set mark" gnus-summary-mark-as-processable t]
1741 ["Remove mark" gnus-summary-unmark-as-processable t]
1742 ["Remove all marks" gnus-summary-unmark-all-processable t]
1743 ["Mark above" gnus-uu-mark-over t]
1744 ["Mark series" gnus-uu-mark-series t]
1745 ["Mark region" gnus-uu-mark-region t]
1746 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1747 ["Mark all" gnus-uu-mark-all t]
1748 ["Mark buffer" gnus-uu-mark-buffer t]
1749 ["Mark sparse" gnus-uu-mark-sparse t]
1750 ["Mark thread" gnus-uu-mark-thread t]
1751 ["Unmark thread" gnus-uu-unmark-thread t]
1752 ("Process Mark Sets"
1753 ["Kill" gnus-summary-kill-process-mark t]
1754 ["Yank" gnus-summary-yank-process-mark
1755 gnus-newsgroup-process-stack]
1756 ["Save" gnus-summary-save-process-mark t]))
1758 ["Page forward" gnus-summary-next-page t]
1759 ["Page backward" gnus-summary-prev-page t]
1760 ["Line forward" gnus-summary-scroll-up t])
1762 ["Next unread article" gnus-summary-next-unread-article t]
1763 ["Previous unread article" gnus-summary-prev-unread-article t]
1764 ["Next article" gnus-summary-next-article t]
1765 ["Previous article" gnus-summary-prev-article t]
1766 ["Next unread subject" gnus-summary-next-unread-subject t]
1767 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1768 ["Next article same subject" gnus-summary-next-same-subject t]
1769 ["Previous article same subject" gnus-summary-prev-same-subject t]
1770 ["First unread article" gnus-summary-first-unread-article t]
1771 ["Best unread article" gnus-summary-best-unread-article t]
1772 ["Go to subject number..." gnus-summary-goto-subject t]
1773 ["Go to article number..." gnus-summary-goto-article t]
1774 ["Go to the last article" gnus-summary-goto-last-article t]
1775 ["Pop article off history" gnus-summary-pop-article t])
1777 ["Sort by number" gnus-summary-sort-by-number t]
1778 ["Sort by author" gnus-summary-sort-by-author t]
1779 ["Sort by subject" gnus-summary-sort-by-subject t]
1780 ["Sort by date" gnus-summary-sort-by-date t]
1781 ["Sort by score" gnus-summary-sort-by-score t]
1782 ["Sort by lines" gnus-summary-sort-by-lines t])
1784 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1785 ["Describe group" gnus-summary-describe-group t]
1786 ["Read manual" gnus-info-find-node t])
1788 ["Pick and read" gnus-pick-mode t]
1789 ["Binary" gnus-binary-mode t])
1791 ["Regenerate" gnus-summary-prepare t]
1792 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1793 ["Toggle threading" gnus-summary-toggle-threads t])
1794 ["Filter articles..." gnus-summary-execute-command t]
1795 ["Run command on subjects..." gnus-summary-universal-argument t]
1796 ["Search articles forward..." gnus-summary-search-article-forward t]
1797 ["Search articles backward..." gnus-summary-search-article-backward t]
1798 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1799 ["Expand window" gnus-summary-expand-window t]
1800 ["Expire expirable articles" gnus-summary-expire-articles
1801 (gnus-check-backend-function
1802 'request-expire-articles gnus-newsgroup-name)]
1803 ["Edit local kill file" gnus-summary-edit-local-kill t]
1804 ["Edit main kill file" gnus-summary-edit-global-kill t]
1806 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1807 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1808 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1809 ["Exit group" gnus-summary-exit t]
1810 ["Exit group without updating" gnus-summary-exit-no-update t]
1811 ["Exit and goto next group" gnus-summary-next-group t]
1812 ["Exit and goto prev group" gnus-summary-prev-group t]
1813 ["Reselect group" gnus-summary-reselect-current-group t]
1814 ["Rescan group" gnus-summary-rescan-group t]
1815 ["Update dribble" gnus-summary-save-newsrc t])))
1817 (run-hooks 'gnus-summary-menu-hook)))
1819 (defun gnus-score-set-default (var value)
1820 "A version of set that updates the GNU Emacs menu-bar."
1822 ;; It is the message that forces the active status to be updated.
1825 (defun gnus-make-score-map (type)
1826 "Make a summary score map of type TYPE."
1829 (let ((headers '(("author" "from" string)
1830 ("subject" "subject" string)
1831 ("article body" "body" string)
1832 ("article head" "head" string)
1833 ("xref" "xref" string)
1834 ("lines" "lines" number)
1835 ("followups to author" "followup" string)))
1836 (types '((number ("less than" <)
1839 (string ("substring" s)
1843 (perms '(("temporary" (current-time-string))
1851 (if (eq type 'lower)
1856 (setq header (car headers))
1862 (let ((ts (cdr (assoc (nth 2 header) types)))
1878 'gnus-summary-score-entry
1880 (if (or (string= (nth 1 header)
1882 (string= (nth 1 header)
1885 (list 'gnus-summary-header
1887 (list 'quote (nth 1 (car ts)))
1888 (list 'gnus-score-default nil)
1894 (list (nreverse outp))))
1897 (list (nreverse outt))))
1899 (setq headers (cdr headers)))
1900 (list (nreverse outh))))))))
1904 (defun gnus-summary-mode (&optional group)
1905 "Major mode for reading articles.
1907 All normal editing commands are switched off.
1908 \\<gnus-summary-mode-map>
1909 Each line in this buffer represents one article. To read an
1910 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1911 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1914 You can also post articles and send mail from this buffer. To
1915 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1916 of an article, type `\\[gnus-summary-reply]'.
1918 There are approx. one gazillion commands you can execute in this
1919 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1921 The following commands are available:
1923 \\{gnus-summary-mode-map}"
1925 (when (gnus-visual-p 'summary-menu 'menu)
1926 (gnus-summary-make-menu-bar))
1927 (kill-all-local-variables)
1928 (gnus-summary-make-local-variables)
1929 (gnus-make-thread-indent-array)
1930 (gnus-simplify-mode-line)
1931 (setq major-mode 'gnus-summary-mode)
1932 (setq mode-name "Summary")
1933 (make-local-variable 'minor-mode-alist)
1934 (use-local-map gnus-summary-mode-map)
1935 (buffer-disable-undo (current-buffer))
1936 (setq buffer-read-only t) ;Disable modification
1937 (setq truncate-lines t)
1938 (setq selective-display t)
1939 (setq selective-display-ellipses t) ;Display `...'
1940 (gnus-summary-set-display-table)
1941 (gnus-set-default-directory)
1942 (setq gnus-newsgroup-name group)
1943 (make-local-variable 'gnus-summary-line-format)
1944 (make-local-variable 'gnus-summary-line-format-spec)
1945 (make-local-variable 'gnus-summary-dummy-line-format)
1946 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1947 (make-local-variable 'gnus-summary-mark-positions)
1948 (make-local-hook 'post-command-hook)
1949 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1950 (make-local-hook 'pre-command-hook)
1951 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1952 (run-hooks 'gnus-summary-mode-hook)
1953 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1954 (gnus-update-summary-mark-positions))
1956 (defun gnus-summary-make-local-variables ()
1957 "Make all the local summary buffer variables."
1958 (let ((locals gnus-summary-local-variables)
1960 (while (setq local (pop locals))
1963 (if (eq (cdr local) 'global)
1964 ;; Copy the global value of the variable.
1965 (setq global (symbol-value (car local)))
1966 ;; Use the value from the list.
1967 (setq global (eval (cdr local))))
1968 (make-local-variable (car local))
1969 (set (car local) global))
1970 ;; Simple nil-valued local variable.
1971 (make-local-variable local)
1974 (defun gnus-summary-clear-local-variables ()
1975 (let ((locals gnus-summary-local-variables))
1977 (if (consp (car locals))
1978 (and (vectorp (caar locals))
1979 (set (caar locals) nil))
1980 (and (vectorp (car locals))
1981 (set (car locals) nil)))
1982 (setq locals (cdr locals)))))
1984 ;; Summary data functions.
1986 (defmacro gnus-data-number (data)
1989 (defmacro gnus-data-set-number (data number)
1990 `(setcar ,data ,number))
1992 (defmacro gnus-data-mark (data)
1995 (defmacro gnus-data-set-mark (data mark)
1996 `(setcar (nthcdr 1 ,data) ,mark))
1998 (defmacro gnus-data-pos (data)
2001 (defmacro gnus-data-set-pos (data pos)
2002 `(setcar (nthcdr 2 ,data) ,pos))
2004 (defmacro gnus-data-header (data)
2007 (defmacro gnus-data-set-header (data header)
2008 `(setf (nth 3 ,data) ,header))
2010 (defmacro gnus-data-level (data)
2013 (defmacro gnus-data-unread-p (data)
2014 `(= (nth 1 ,data) gnus-unread-mark))
2016 (defmacro gnus-data-read-p (data)
2017 `(/= (nth 1 ,data) gnus-unread-mark))
2019 (defmacro gnus-data-pseudo-p (data)
2020 `(consp (nth 3 ,data)))
2022 (defmacro gnus-data-find (number)
2023 `(assq ,number gnus-newsgroup-data))
2025 (defmacro gnus-data-find-list (number &optional data)
2026 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2027 (memq (assq ,number bdata)
2030 (defmacro gnus-data-make (number mark pos header level)
2031 `(list ,number ,mark ,pos ,header ,level))
2033 (defun gnus-data-enter (after-article number mark pos header level offset)
2034 (let ((data (gnus-data-find-list after-article)))
2036 (error "No such article: %d" after-article))
2037 (setcdr data (cons (gnus-data-make number mark pos header level)
2039 (setq gnus-newsgroup-data-reverse nil)
2040 (gnus-data-update-list (cddr data) offset)))
2042 (defun gnus-data-enter-list (after-article list &optional offset)
2044 (let ((data (and after-article (gnus-data-find-list after-article)))
2046 (or data (not after-article) (error "No such article: %d" after-article))
2047 ;; Find the last element in the list to be spliced into the main
2050 (setq list (cdr list)))
2053 (setcdr list gnus-newsgroup-data)
2054 (setq gnus-newsgroup-data ilist)
2056 (gnus-data-update-list (cdr list) offset)))
2057 (setcdr list (cdr data))
2060 (gnus-data-update-list (cdr list) offset)))
2061 (setq gnus-newsgroup-data-reverse nil))))
2063 (defun gnus-data-remove (article &optional offset)
2064 (let ((data gnus-newsgroup-data))
2065 (if (= (gnus-data-number (car data)) article)
2067 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2068 gnus-newsgroup-data-reverse nil)
2070 (gnus-data-update-list gnus-newsgroup-data offset)))
2072 (when (= (gnus-data-number (cadr data)) article)
2073 (setcdr data (cddr data))
2075 (gnus-data-update-list (cdr data) offset))
2077 gnus-newsgroup-data-reverse nil))
2078 (setq data (cdr data))))))
2080 (defmacro gnus-data-list (backward)
2082 (or gnus-newsgroup-data-reverse
2083 (setq gnus-newsgroup-data-reverse
2084 (reverse gnus-newsgroup-data)))
2085 gnus-newsgroup-data))
2087 (defun gnus-data-update-list (data offset)
2088 "Add OFFSET to the POS of all data entries in DATA."
2090 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2091 (setq data (cdr data))))
2093 (defun gnus-data-compute-positions ()
2094 "Compute the positions of all articles."
2095 (let ((data gnus-newsgroup-data)
2098 (when (setq pos (text-property-any
2099 (point-min) (point-max)
2100 'gnus-number (gnus-data-number (car data))))
2101 (gnus-data-set-pos (car data) (+ pos 3)))
2102 (setq data (cdr data)))))
2104 (defun gnus-summary-article-pseudo-p (article)
2105 "Say whether this article is a pseudo article or not."
2106 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2108 (defmacro gnus-summary-article-sparse-p (article)
2109 "Say whether this article is a sparse article or not."
2110 `(memq ,article gnus-newsgroup-sparse))
2112 (defmacro gnus-summary-article-ancient-p (article)
2113 "Say whether this article is a sparse article or not."
2114 `(memq ,article gnus-newsgroup-ancient))
2116 (defun gnus-article-parent-p (number)
2117 "Say whether this article is a parent or not."
2118 (let ((data (gnus-data-find-list number)))
2119 (and (cdr data) ; There has to be an article after...
2120 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2121 (gnus-data-level (nth 1 data))))))
2123 (defun gnus-article-children (number)
2124 "Return a list of all children to NUMBER."
2125 (let* ((data (gnus-data-find-list number))
2126 (level (gnus-data-level (car data)))
2128 (setq data (cdr data))
2130 (= (gnus-data-level (car data)) (1+ level)))
2131 (push (gnus-data-number (car data)) children)
2132 (setq data (cdr data)))
2135 (defmacro gnus-summary-skip-intangible ()
2136 "If the current article is intangible, then jump to a different article."
2137 '(let ((to (get-text-property (point) 'gnus-intangible)))
2138 (and to (gnus-summary-goto-subject to))))
2140 (defmacro gnus-summary-article-intangible-p ()
2141 "Say whether this article is intangible or not."
2142 '(get-text-property (point) 'gnus-intangible))
2144 (defun gnus-article-read-p (article)
2145 "Say whether ARTICLE is read or not."
2146 (not (or (memq article gnus-newsgroup-marked)
2147 (memq article gnus-newsgroup-unreads)
2148 (memq article gnus-newsgroup-unselected)
2149 (memq article gnus-newsgroup-dormant))))
2151 ;; Some summary mode macros.
2153 (defmacro gnus-summary-article-number ()
2154 "The article number of the article on the current line.
2155 If there isn's an article number here, then we return the current
2158 (gnus-summary-skip-intangible)
2159 (or (get-text-property (point) 'gnus-number)
2160 (gnus-summary-last-subject))))
2162 (defmacro gnus-summary-article-header (&optional number)
2163 `(gnus-data-header (gnus-data-find
2164 ,(or number '(gnus-summary-article-number)))))
2166 (defmacro gnus-summary-thread-level (&optional number)
2167 `(if (and (eq gnus-summary-make-false-root 'dummy)
2168 (get-text-property (point) 'gnus-intangible))
2170 (gnus-data-level (gnus-data-find
2171 ,(or number '(gnus-summary-article-number))))))
2173 (defmacro gnus-summary-article-mark (&optional number)
2174 `(gnus-data-mark (gnus-data-find
2175 ,(or number '(gnus-summary-article-number)))))
2177 (defmacro gnus-summary-article-pos (&optional number)
2178 `(gnus-data-pos (gnus-data-find
2179 ,(or number '(gnus-summary-article-number)))))
2181 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2182 (defmacro gnus-summary-article-subject (&optional number)
2183 "Return current subject string or nil if nothing."
2186 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2187 '(gnus-data-header (assq (gnus-summary-article-number)
2188 gnus-newsgroup-data)))))
2191 (mail-header-subject headers))))
2193 (defmacro gnus-summary-article-score (&optional number)
2194 "Return current article score."
2195 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2196 gnus-newsgroup-scored))
2197 gnus-summary-default-score 0))
2199 (defun gnus-summary-article-children (&optional number)
2200 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2201 (level (gnus-data-level (car data)))
2203 (while (and (setq data (cdr data))
2204 (> (setq l (gnus-data-level (car data))) level))
2205 (and (= (1+ level) l)
2206 (push (gnus-data-number (car data))
2208 (nreverse children)))
2210 (defun gnus-summary-article-parent (&optional number)
2211 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2212 (gnus-data-list t)))
2213 (level (gnus-data-level (car data))))
2215 () ; This is a root.
2216 ;; We search until we find an article with a level less than
2217 ;; this one. That function has to be the parent.
2218 (while (and (setq data (cdr data))
2219 (not (< (gnus-data-level (car data)) level))))
2220 (and data (gnus-data-number (car data))))))
2222 (defun gnus-unread-mark-p (mark)
2223 "Say whether MARK is the unread mark."
2224 (= mark gnus-unread-mark))
2226 (defun gnus-read-mark-p (mark)
2227 "Say whether MARK is one of the marks that mark as read.
2228 This is all marks except unread, ticked, dormant, and expirable."
2229 (not (or (= mark gnus-unread-mark)
2230 (= mark gnus-ticked-mark)
2231 (= mark gnus-dormant-mark)
2232 (= mark gnus-expirable-mark))))
2234 (defmacro gnus-article-mark (number)
2236 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2237 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2238 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2239 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2240 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2241 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2242 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2243 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2244 gnus-ancient-mark))))
2246 ;; Saving hidden threads.
2248 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2249 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2251 (defmacro gnus-save-hidden-threads (&rest forms)
2252 "Save hidden threads, eval FORMS, and restore the hidden threads."
2253 (let ((config (make-symbol "config")))
2254 `(let ((,config (gnus-hidden-threads-configuration)))
2258 (gnus-restore-hidden-threads-configuration ,config)))))
2260 (defun gnus-hidden-threads-configuration ()
2261 "Return the current hidden threads configuration."
2264 (goto-char (point-min))
2265 (while (search-forward "\r" nil t)
2266 (push (1- (point)) config))
2269 (defun gnus-restore-hidden-threads-configuration (config)
2270 "Restore hidden threads configuration from CONFIG."
2271 (let (point buffer-read-only)
2272 (while (setq point (pop config))
2273 (when (and (< point (point-max))
2275 (= (following-char) ?\n))
2276 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2278 ;; Various summary mode internalish functions.
2280 (defun gnus-mouse-pick-article (e)
2283 (gnus-summary-next-page nil t))
2285 (defun gnus-summary-set-display-table ()
2286 ;; Change the display table. Odd characters have a tendency to mess
2287 ;; up nicely formatted displays - we make all possible glyphs
2288 ;; display only a single character.
2290 ;; We start from the standard display table, if any.
2291 (let ((table (or (copy-sequence standard-display-table)
2292 (make-display-table)))
2294 ;; Nix out all the control chars...
2295 (while (>= (setq i (1- i)) 0)
2296 (aset table i [??]))
2297 ;; ... but not newline and cr, of course. (cr is necessary for the
2298 ;; selective display).
2299 (aset table ?\n nil)
2300 (aset table ?\r nil)
2301 ;; We nix out any glyphs over 126 that are not set already.
2303 (while (>= (setq i (1- i)) 127)
2304 ;; Only modify if the entry is nil.
2305 (unless (aref table i)
2306 (aset table i [??]))))
2307 (setq buffer-display-table table)))
2309 (defun gnus-summary-setup-buffer (group)
2310 "Initialize summary buffer."
2311 (let ((buffer (concat "*Summary " group "*")))
2312 (if (get-buffer buffer)
2315 (setq gnus-summary-buffer (current-buffer))
2316 (not gnus-newsgroup-prepared))
2317 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2318 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2319 (gnus-add-current-to-buffer-list)
2320 (gnus-summary-mode group)
2322 (gnus-carpal-setup-buffer 'summary))
2323 (unless gnus-single-article-buffer
2324 (make-local-variable 'gnus-article-buffer)
2325 (make-local-variable 'gnus-article-current)
2326 (make-local-variable 'gnus-original-article-buffer))
2327 (setq gnus-newsgroup-name group)
2330 (defun gnus-set-global-variables ()
2331 ;; Set the global equivalents of the summary buffer-local variables
2332 ;; to the latest values they had. These reflect the summary buffer
2333 ;; that was in action when the last article was fetched.
2334 (when (eq major-mode 'gnus-summary-mode)
2335 (setq gnus-summary-buffer (current-buffer))
2336 (let ((name gnus-newsgroup-name)
2337 (marked gnus-newsgroup-marked)
2338 (unread gnus-newsgroup-unreads)
2339 (headers gnus-current-headers)
2340 (data gnus-newsgroup-data)
2341 (summary gnus-summary-buffer)
2342 (article-buffer gnus-article-buffer)
2343 (original gnus-original-article-buffer)
2344 (gac gnus-article-current)
2345 (reffed gnus-reffed-article-number)
2346 (score-file gnus-current-score-file))
2348 (set-buffer gnus-group-buffer)
2349 (setq gnus-newsgroup-name name
2350 gnus-newsgroup-marked marked
2351 gnus-newsgroup-unreads unread
2352 gnus-current-headers headers
2353 gnus-newsgroup-data data
2354 gnus-article-current gac
2355 gnus-summary-buffer summary
2356 gnus-article-buffer article-buffer
2357 gnus-original-article-buffer original
2358 gnus-reffed-article-number reffed
2359 gnus-current-score-file score-file)
2360 ;; The article buffer also has local variables.
2361 (when (gnus-buffer-live-p gnus-article-buffer)
2362 (set-buffer gnus-article-buffer)
2363 (setq gnus-summary-buffer summary))))))
2365 (defun gnus-summary-article-unread-p (article)
2366 "Say whether ARTICLE is unread or not."
2367 (memq article gnus-newsgroup-unreads))
2369 (defun gnus-summary-first-article-p (&optional article)
2370 "Return whether ARTICLE is the first article in the buffer."
2371 (if (not (setq article (or article (gnus-summary-article-number))))
2373 (eq article (caar gnus-newsgroup-data))))
2375 (defun gnus-summary-last-article-p (&optional article)
2376 "Return whether ARTICLE is the last article in the buffer."
2377 (if (not (setq article (or article (gnus-summary-article-number))))
2378 t ; All non-existent numbers are the last article. :-)
2379 (not (cdr (gnus-data-find-list article)))))
2381 (defun gnus-make-thread-indent-array ()
2383 (unless (and gnus-thread-indent-array
2384 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2385 (setq gnus-thread-indent-array (make-vector 201 "")
2386 gnus-thread-indent-array-level gnus-thread-indent-level)
2388 (aset gnus-thread-indent-array n
2389 (make-string (* n gnus-thread-indent-level) ? ))
2392 (defun gnus-update-summary-mark-positions ()
2393 "Compute where the summary marks are to go."
2395 (when (and gnus-summary-buffer
2396 (get-buffer gnus-summary-buffer)
2397 (buffer-name (get-buffer gnus-summary-buffer)))
2398 (set-buffer gnus-summary-buffer))
2399 (let ((gnus-replied-mark 129)
2400 (gnus-score-below-mark 130)
2401 (gnus-score-over-mark 130)
2402 (gnus-download-mark 131)
2403 (spec gnus-summary-line-format-spec)
2404 thread gnus-visual pos)
2406 (gnus-set-work-buffer)
2407 (let ((gnus-summary-line-format-spec spec)
2408 (gnus-newsgroup-downloadable '((0 . t))))
2409 (gnus-summary-insert-line
2410 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2411 (goto-char (point-min))
2412 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2414 (goto-char (point-min))
2415 (push (cons 'replied (and (search-forward "\201" nil t)
2418 (goto-char (point-min))
2419 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2421 (goto-char (point-min))
2422 (push (cons 'download
2423 (and (search-forward "\203" nil t) (- (point) 2)))
2425 (setq gnus-summary-mark-positions pos))))
2427 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2428 "Insert a dummy root in the summary buffer."
2430 (gnus-add-text-properties
2431 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2432 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2434 (defun gnus-summary-insert-line (gnus-tmp-header
2435 gnus-tmp-level gnus-tmp-current
2436 gnus-tmp-unread gnus-tmp-replied
2437 gnus-tmp-expirable gnus-tmp-subject-or-nil
2438 &optional gnus-tmp-dummy gnus-tmp-score
2440 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2441 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2442 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2443 (gnus-tmp-score-char
2444 (if (or (null gnus-summary-default-score)
2445 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2446 gnus-summary-zcore-fuzz))
2448 (if (< gnus-tmp-score gnus-summary-default-score)
2449 gnus-score-below-mark gnus-score-over-mark)))
2451 (cond (gnus-tmp-process gnus-process-mark)
2452 ((memq gnus-tmp-current gnus-newsgroup-cached)
2454 (gnus-tmp-replied gnus-replied-mark)
2455 ((memq gnus-tmp-current gnus-newsgroup-saved)
2457 (t gnus-unread-mark)))
2458 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2461 ((string-match "<[^>]+> *$" gnus-tmp-from)
2462 (let ((beg (match-beginning 0)))
2463 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2464 (substring gnus-tmp-from (1+ (match-beginning 0))
2465 (1- (match-end 0))))
2466 (substring gnus-tmp-from 0 beg))))
2467 ((string-match "(.+)" gnus-tmp-from)
2468 (substring gnus-tmp-from
2469 (1+ (match-beginning 0)) (1- (match-end 0))))
2471 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2472 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2473 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2474 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2475 (buffer-read-only nil))
2476 (when (string= gnus-tmp-name "")
2477 (setq gnus-tmp-name gnus-tmp-from))
2478 (unless (numberp gnus-tmp-lines)
2479 (setq gnus-tmp-lines 0))
2480 (gnus-put-text-property
2482 (progn (eval gnus-summary-line-format-spec) (point))
2483 'gnus-number gnus-tmp-number)
2484 (when (gnus-visual-p 'summary-highlight 'highlight)
2486 (run-hooks 'gnus-summary-update-hook)
2489 (defun gnus-summary-update-line (&optional dont-update)
2490 ;; Update summary line after change.
2491 (when (and gnus-summary-default-score
2492 (not gnus-summary-inhibit-highlight))
2493 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2494 (article (gnus-summary-article-number))
2495 (score (gnus-summary-article-score article)))
2497 (if (and gnus-summary-mark-below
2498 (< (gnus-summary-article-score)
2499 gnus-summary-mark-below))
2500 ;; This article has a low score, so we mark it as read.
2501 (when (memq article gnus-newsgroup-unreads)
2502 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2503 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2504 ;; This article was previously marked as read on account
2505 ;; of a low score, but now it has risen, so we mark it as
2507 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2508 (gnus-summary-update-mark
2509 (if (or (null gnus-summary-default-score)
2510 (<= (abs (- score gnus-summary-default-score))
2511 gnus-summary-zcore-fuzz))
2513 (if (< score gnus-summary-default-score)
2514 gnus-score-below-mark gnus-score-over-mark))
2516 ;; Do visual highlighting.
2517 (when (gnus-visual-p 'summary-highlight 'highlight)
2518 (run-hooks 'gnus-summary-update-hook)))))
2520 (defvar gnus-tmp-new-adopts nil)
2522 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2523 "Return the number of articles in THREAD.
2524 This may be 0 in some cases -- if none of the articles in
2525 the thread are to be displayed."
2527 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2529 ((not (listp thread))
2531 ((and (consp thread) (cdr thread))
2534 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2537 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2540 (when (and level (zerop level) gnus-tmp-new-adopts)
2543 'gnus-summary-number-of-articles-in-thread
2544 gnus-tmp-new-adopts))))
2546 (if (> number 1) gnus-not-empty-thread-mark
2547 gnus-empty-thread-mark)
2550 (defun gnus-summary-set-local-parameters (group)
2551 "Go through the local params of GROUP and set all variable specs in that list."
2552 (let ((params (gnus-group-find-parameter group))
2555 (setq elem (car params)
2556 params (cdr params))
2557 (and (consp elem) ; Has to be a cons.
2558 (consp (cdr elem)) ; The cdr has to be a list.
2559 (symbolp (car elem)) ; Has to be a symbol in there.
2560 (not (memq (car elem)
2561 '(quit-config to-address to-list to-group)))
2562 (ignore-errors ; So we set it.
2563 (make-local-variable (car elem))
2564 (set (car elem) (eval (nth 1 elem))))))))
2566 (defun gnus-summary-read-group (group &optional show-all no-article
2567 kill-buffer no-display)
2568 "Start reading news in newsgroup GROUP.
2569 If SHOW-ALL is non-nil, already read articles are also listed.
2570 If NO-ARTICLE is non-nil, no article is selected initially.
2571 If NO-DISPLAY, don't generate a summary buffer."
2575 (let ((gnus-auto-select-next nil))
2576 (or (gnus-summary-read-group-1
2577 group show-all no-article
2578 kill-buffer no-display)
2579 (setq show-all nil)))))
2580 (eq gnus-auto-select-next 'quietly))
2581 (set-buffer gnus-group-buffer)
2582 (if (not (equal group (gnus-group-group-name)))
2583 (setq group (gnus-group-group-name))
2587 (defun gnus-summary-read-group-1 (group show-all no-article
2588 kill-buffer no-display)
2589 ;; Killed foreign groups can't be entered.
2590 (when (and (not (gnus-group-native-p group))
2591 (not (gnus-gethash group gnus-newsrc-hashtb)))
2592 (error "Dead non-native groups can't be entered"))
2593 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2594 (let* ((new-group (gnus-summary-setup-buffer group))
2595 (quit-config (gnus-group-quit-config group))
2596 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2598 ;; This summary buffer exists already, so we just select it.
2600 (gnus-set-global-variables)
2602 (gnus-kill-or-deaden-summary kill-buffer))
2603 (gnus-configure-windows 'summary 'force)
2604 (gnus-set-mode-line 'summary)
2605 (gnus-summary-position-point)
2608 ;; We couldn't select this group.
2610 (when (and (eq major-mode 'gnus-summary-mode)
2611 (not (equal (current-buffer) kill-buffer)))
2612 (kill-buffer (current-buffer))
2613 (if (not quit-config)
2615 ;; Update the info -- marks might need to be removed,
2617 (gnus-summary-update-info)
2618 (set-buffer gnus-group-buffer)
2619 (gnus-group-jump-to-group group)
2620 (gnus-group-next-unread-group 1))
2621 (gnus-handle-ephemeral-exit quit-config)))
2622 (gnus-message 3 "Can't select group")
2624 ;; The user did a `C-g' while prompting for number of articles,
2625 ;; so we exit this group.
2626 ((eq did-select 'quit)
2627 (and (eq major-mode 'gnus-summary-mode)
2628 (not (equal (current-buffer) kill-buffer))
2629 (kill-buffer (current-buffer)))
2631 (gnus-kill-or-deaden-summary kill-buffer))
2632 (if (not quit-config)
2634 (set-buffer gnus-group-buffer)
2635 (gnus-group-jump-to-group group)
2636 (gnus-group-next-unread-group 1)
2637 (gnus-configure-windows 'group 'force))
2638 (gnus-handle-ephemeral-exit quit-config))
2639 ;; Finally signal the quit.
2641 ;; The group was successfully selected.
2643 (gnus-set-global-variables)
2644 ;; Save the active value in effect when the group was entered.
2645 (setq gnus-newsgroup-active
2647 (gnus-active gnus-newsgroup-name)))
2648 ;; You can change the summary buffer in some way with this hook.
2649 (run-hooks 'gnus-select-group-hook)
2650 ;; Set any local variables in the group parameters.
2651 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2652 (gnus-update-format-specifications
2653 nil 'summary 'summary-mode 'summary-dummy)
2654 ;; Do score processing.
2655 (when gnus-use-scoring
2656 (gnus-possibly-score-headers))
2657 ;; Check whether to fill in the gaps in the threads.
2658 (when gnus-build-sparse-threads
2659 (gnus-build-sparse-threads))
2660 ;; Find the initial limit.
2661 (if gnus-show-threads
2663 (let ((gnus-newsgroup-dormant nil))
2664 (gnus-summary-initial-limit show-all))
2665 (gnus-summary-initial-limit show-all))
2666 (setq gnus-newsgroup-limit
2668 (lambda (header) (mail-header-number header))
2669 gnus-newsgroup-headers)))
2670 ;; Generate the summary buffer.
2672 (gnus-summary-prepare))
2673 (when gnus-use-trees
2674 (gnus-tree-open group)
2675 (setq gnus-summary-highlight-line-function
2676 'gnus-tree-highlight-article))
2677 ;; If the summary buffer is empty, but there are some low-scored
2678 ;; articles or some excluded dormants, we include these in the
2680 (when (and (zerop (buffer-size))
2682 (cond (gnus-newsgroup-dormant
2683 (gnus-summary-limit-include-dormant))
2684 ((and gnus-newsgroup-scored show-all)
2685 (gnus-summary-limit-include-expunged t))))
2686 ;; Function `gnus-apply-kill-file' must be called in this hook.
2687 (run-hooks 'gnus-apply-kill-hook)
2688 (if (and (zerop (buffer-size))
2691 ;; This newsgroup is empty.
2692 (gnus-summary-catchup-and-exit nil t)
2693 (gnus-message 6 "No unread news")
2695 (gnus-kill-or-deaden-summary kill-buffer))
2696 ;; Return nil from this function.
2698 ;; Hide conversation thread subtrees. We cannot do this in
2699 ;; gnus-summary-prepare-hook since kill processing may not
2700 ;; work with hidden articles.
2701 (and gnus-show-threads
2702 gnus-thread-hide-subtree
2703 (gnus-summary-hide-all-threads))
2705 (gnus-kill-or-deaden-summary kill-buffer))
2706 ;; Show first unread article if requested.
2707 (if (and (not no-article)
2709 gnus-newsgroup-unreads
2710 gnus-auto-select-first)
2711 (unless (if (eq gnus-auto-select-first 'best)
2712 (gnus-summary-best-unread-article)
2713 (gnus-summary-first-unread-article))
2714 (gnus-configure-windows 'summary))
2715 ;; Don't select any articles, just move point to the first
2716 ;; article in the group.
2717 (goto-char (point-min))
2718 (gnus-summary-position-point)
2719 (gnus-configure-windows 'summary 'force)
2720 (gnus-set-mode-line 'summary))
2721 (when (get-buffer-window gnus-group-buffer t)
2722 ;; Gotta use windows, because recenter does weird stuff if
2723 ;; the current buffer ain't the displayed window.
2724 (let ((owin (selected-window)))
2725 (select-window (get-buffer-window gnus-group-buffer t))
2726 (when (gnus-group-goto-group group)
2728 (select-window owin)))
2729 ;; Mark this buffer as "prepared".
2730 (setq gnus-newsgroup-prepared t)
2733 (defun gnus-summary-prepare ()
2734 "Generate the summary buffer."
2736 (let ((buffer-read-only nil))
2738 (setq gnus-newsgroup-data nil
2739 gnus-newsgroup-data-reverse nil)
2740 (run-hooks 'gnus-summary-generate-hook)
2741 ;; Generate the buffer, either with threads or without.
2742 (when gnus-newsgroup-headers
2743 (gnus-summary-prepare-threads
2744 (if gnus-show-threads
2745 (gnus-sort-gathered-threads
2746 (funcall gnus-summary-thread-gathering-function
2748 (gnus-cut-threads (gnus-make-threads)))))
2749 ;; Unthreaded display.
2750 (gnus-sort-articles gnus-newsgroup-headers))))
2751 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2752 ;; Call hooks for modifying summary buffer.
2753 (goto-char (point-min))
2754 (run-hooks 'gnus-summary-prepare-hook)))
2756 (defsubst gnus-general-simplify-subject (subject)
2757 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2760 ;; Truncate the subject.
2761 (gnus-simplify-subject-functions
2762 (gnus-map-function gnus-simplify-subject-functions subject))
2763 ((numberp gnus-summary-gather-subject-limit)
2764 (setq subject (gnus-simplify-subject-re subject))
2765 (if (> (length subject) gnus-summary-gather-subject-limit)
2766 (substring subject 0 gnus-summary-gather-subject-limit)
2768 ;; Fuzzily simplify it.
2769 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2770 (gnus-simplify-subject-fuzzy subject))
2771 ;; Just remove the leading "Re:".
2773 (gnus-simplify-subject-re subject))))
2775 (if (and gnus-summary-gather-exclude-subject
2776 (string-match gnus-summary-gather-exclude-subject subject))
2777 nil ; This article shouldn't be gathered
2780 (defun gnus-summary-simplify-subject-query ()
2781 "Query where the respool algorithm would put this article."
2783 (gnus-summary-select-article)
2784 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2786 (defun gnus-gather-threads-by-subject (threads)
2787 "Gather threads by looking at Subject headers."
2788 (if (not gnus-summary-make-false-root)
2790 (let ((hashtb (gnus-make-hashtable 1024))
2793 subject hthread whole-subject)
2795 (setq subject (gnus-general-simplify-subject
2796 (setq whole-subject (mail-header-subject
2799 (if (setq hthread (gnus-gethash subject hashtb))
2801 ;; We enter a dummy root into the thread, if we
2802 ;; haven't done that already.
2803 (unless (stringp (caar hthread))
2804 (setcar hthread (list whole-subject (car hthread))))
2805 ;; We add this new gathered thread to this gathered
2807 (setcdr (car hthread)
2808 (nconc (cdar hthread) (list (car threads))))
2809 ;; Remove it from the list of threads.
2810 (setcdr prev (cdr threads))
2811 (setq threads prev))
2812 ;; Enter this thread into the hash table.
2813 (gnus-sethash subject threads hashtb)))
2815 (setq threads (cdr threads)))
2818 (defun gnus-gather-threads-by-references (threads)
2819 "Gather threads by looking at References headers."
2820 (let ((idhashtb (gnus-make-hashtable 1024))
2821 (thhashtb (gnus-make-hashtable 1024))
2824 ids references id gthread gid entered ref)
2826 (when (setq references (mail-header-references (caar threads)))
2827 (setq id (mail-header-id (caar threads))
2828 ids (gnus-split-references references)
2830 (while (setq ref (pop ids))
2831 (setq ids (delete ref ids))
2832 (if (not (setq gid (gnus-gethash ref idhashtb)))
2834 (gnus-sethash ref id idhashtb)
2835 (gnus-sethash id threads thhashtb))
2836 (setq gthread (gnus-gethash gid thhashtb))
2838 ;; We enter a dummy root into the thread, if we
2839 ;; haven't done that already.
2840 (unless (stringp (caar gthread))
2841 (setcar gthread (list (mail-header-subject (caar gthread))
2843 ;; We add this new gathered thread to this gathered
2845 (setcdr (car gthread)
2846 (nconc (cdar gthread) (list (car threads)))))
2847 ;; Add it into the thread hash table.
2848 (gnus-sethash id gthread thhashtb)
2850 ;; Remove it from the list of threads.
2851 (setcdr prev (cdr threads))
2852 (setq threads prev))))
2854 (setq threads (cdr threads)))
2857 (defun gnus-sort-gathered-threads (threads)
2858 "Sort subtreads inside each gathered thread by article number."
2859 (let ((result threads))
2861 (when (stringp (caar threads))
2862 (setcdr (car threads)
2863 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2864 (setq threads (cdr threads)))
2867 (defun gnus-thread-loop-p (root thread)
2868 "Say whether ROOT is in THREAD."
2869 (let ((stack (list thread))
2872 (while (setq thread (pop stack))
2873 (setq th (cdr thread))
2875 (not (eq (caar th) root)))
2878 ;; We have found a loop.
2880 (setcdr thread (delq (car th) (cdr thread)))
2881 (if (boundp (setq ref-dep (intern "none"
2882 gnus-newsgroup-dependencies)))
2883 (setcdr (symbol-value ref-dep)
2884 (nconc (cdr (symbol-value ref-dep))
2886 (set ref-dep (list nil (car th))))
2889 ;; Push all the subthreads onto the stack.
2890 (push (cdr thread) stack)))
2893 (defun gnus-make-threads ()
2894 "Go through the dependency hashtb and find the roots. Return all threads."
2896 (while (catch 'infloop
2899 ;; Deal with self-referencing References loops.
2900 (when (and (car (symbol-value refs))
2907 (car (symbol-value refs)) thread))
2908 (cdr (symbol-value refs)))))))
2911 (unless (car (symbol-value refs))
2912 ;; These threads do not refer back to any other articles,
2913 ;; so they're roots.
2914 (setq threads (append (cdr (symbol-value refs)) threads))))
2915 gnus-newsgroup-dependencies)))
2918 (defun gnus-build-sparse-threads ()
2919 (let ((headers gnus-newsgroup-headers)
2920 (deps gnus-newsgroup-dependencies)
2921 header references generation relations
2922 cthread subject child end pthread relation new-child)
2923 ;; First we create an alist of generations/relations, where
2924 ;; generations is how much we trust the relation, and the relation
2926 (gnus-message 7 "Making sparse threads...")
2928 (nnheader-set-temp-buffer " *gnus sparse threads*")
2929 (while (setq header (pop headers))
2930 (when (and (setq references (mail-header-references header))
2931 (not (string= references "")))
2933 (setq child (mail-header-id header)
2934 subject (mail-header-subject header))
2936 (while (search-backward ">" nil t)
2937 (setq end (1+ (point)))
2938 (when (search-backward "<" nil t)
2939 (unless (string= (setq new-child (buffer-substring (point) end))
2941 (push (list (incf generation)
2942 child (setq child new-child)
2945 (push (list (1+ generation) child nil subject) relations)
2947 (kill-buffer (current-buffer)))
2948 ;; Sort over trustworthiness.
2949 (setq relations (sort relations 'car-less-than-car))
2950 (while (setq relation (pop relations))
2951 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2952 (unless (car (symbol-value cthread))
2953 ;; Make this article the parent of these threads.
2954 (setcar (symbol-value cthread)
2955 (vector gnus-reffed-article-number
2959 (or (caddr relation) "") 0 0 "")))
2960 (set cthread (list (vector gnus-reffed-article-number
2962 "" "" (cadr relation)
2963 (or (caddr relation) "") 0 0 ""))))
2964 (push gnus-reffed-article-number gnus-newsgroup-limit)
2965 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2966 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2967 gnus-newsgroup-reads)
2968 (decf gnus-reffed-article-number)
2969 ;; Make this new thread the child of its parent.
2970 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2971 (setcdr (symbol-value pthread)
2972 (nconc (cdr (symbol-value pthread))
2973 (list (symbol-value cthread))))
2974 (set pthread (list nil (symbol-value cthread))))))
2975 (gnus-message 7 "Making sparse threads...done")))
2977 (defun gnus-build-old-threads ()
2978 ;; Look at all the articles that refer back to old articles, and
2979 ;; fetch the headers for the articles that aren't there. This will
2980 ;; build complete threads - if the roots haven't been expired by the
2985 (when (not (car (symbol-value refs)))
2986 (setq heads (cdr (symbol-value refs)))
2988 (if (memq (mail-header-number (caar heads))
2989 gnus-newsgroup-dormant)
2990 (setq heads (cdr heads))
2991 (setq id (symbol-name refs))
2992 (while (and (setq id (gnus-build-get-header id))
2993 (not (car (gnus-gethash
2994 id gnus-newsgroup-dependencies)))))
2995 (setq heads nil)))))
2996 gnus-newsgroup-dependencies)))
2998 (defun gnus-build-get-header (id)
2999 ;; Look through the buffer of NOV lines and find the header to
3000 ;; ID. Enter this line into the dependencies hash table, and return
3001 ;; the id of the parent article (if any).
3002 (let ((deps gnus-newsgroup-dependencies)
3006 (set-buffer nntp-server-buffer)
3007 (let ((case-fold-search nil))
3008 (goto-char (point-min))
3009 (while (and (not found)
3010 (search-forward id nil t))
3012 (setq found (looking-at
3013 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3014 (regexp-quote id))))
3015 (or found (beginning-of-line 2)))
3019 (setq header (gnus-nov-parse-line
3020 (read (current-buffer)) deps))
3021 (gnus-parent-id (mail-header-references header))))))
3023 (let ((number (mail-header-number header)))
3024 (push number gnus-newsgroup-limit)
3025 (push header gnus-newsgroup-headers)
3026 (if (memq number gnus-newsgroup-unselected)
3028 (push number gnus-newsgroup-unreads)
3029 (setq gnus-newsgroup-unselected
3030 (delq number gnus-newsgroup-unselected)))
3031 (push number gnus-newsgroup-ancient)))))))
3033 (defun gnus-build-all-threads ()
3034 "Read all the headers."
3035 (let ((deps gnus-newsgroup-dependencies)
3036 (gnus-summary-ignore-duplicates t)
3037 found header article)
3039 (set-buffer nntp-server-buffer)
3040 (let ((case-fold-search nil))
3041 (goto-char (point-min))
3044 (setq article (read (current-buffer)))
3045 (setq header (gnus-nov-parse-line article deps)))
3047 (push header gnus-newsgroup-headers)
3048 (if (memq (setq article (mail-header-number header))
3049 gnus-newsgroup-unselected)
3051 (push article gnus-newsgroup-unreads)
3052 (setq gnus-newsgroup-unselected
3053 (delq article gnus-newsgroup-unselected)))
3054 (push article gnus-newsgroup-ancient))
3055 (forward-line 1)))))))
3057 (defun gnus-summary-update-article-line (article header)
3058 "Update the line for ARTICLE using HEADERS."
3059 (let* ((id (mail-header-id header))
3060 (thread (gnus-id-to-thread id)))
3062 (error "Article in no thread"))
3063 ;; Update the thread.
3064 (setcar thread header)
3065 (gnus-summary-goto-subject article)
3066 (let* ((datal (gnus-data-find-list article))
3068 (length (when (cdr datal)
3069 (- (gnus-data-pos data)
3070 (gnus-data-pos (cadr datal)))))
3071 (buffer-read-only nil)
3072 (level (gnus-summary-thread-level)))
3074 (gnus-summary-insert-line
3075 header level nil (gnus-article-mark article)
3076 (memq article gnus-newsgroup-replied)
3077 (memq article gnus-newsgroup-expirable)
3078 ;; Only insert the Subject string when it's different
3079 ;; from the previous Subject string.
3080 (if (gnus-subject-equal
3082 (mail-header-subject
3085 (gnus-data-find-list
3087 (gnus-data-list t)))))
3088 ;; Error on the side of excessive subjects.
3090 (mail-header-subject header))
3092 (mail-header-subject header))
3093 nil (cdr (assq article gnus-newsgroup-scored))
3094 (memq article gnus-newsgroup-processable))
3096 (gnus-data-update-list
3097 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3099 (defun gnus-summary-update-article (article &optional iheader)
3100 "Update ARTICLE in the summary buffer."
3101 (set-buffer gnus-summary-buffer)
3102 (let* ((header (or iheader (gnus-summary-article-header article)))
3103 (id (mail-header-id header))
3104 (data (gnus-data-find article))
3105 (thread (gnus-id-to-thread id))
3106 (references (mail-header-references header))
3110 (when (and references
3111 (not (equal "" references)))
3114 (buffer-read-only nil)
3116 (number (mail-header-number header))
3119 ;; !!! Should this be in or not?
3121 (setcar thread nil))
3123 (delq thread parent))
3124 (if (gnus-summary-insert-subject id header iheader)
3125 ;; Set the (possibly) new article number in the data structure.
3126 (gnus-data-set-number data (gnus-id-to-article id))
3130 (defun gnus-rebuild-thread (id)
3131 "Rebuild the thread containing ID."
3132 (let ((buffer-read-only nil)
3133 old-pos current thread data)
3134 (if (not gnus-show-threads)
3135 (setq thread (list (car (gnus-id-to-thread id))))
3136 ;; Get the thread this article is part of.
3137 (setq thread (gnus-remove-thread id)))
3138 (setq old-pos (gnus-point-at-bol))
3139 (setq current (save-excursion
3140 (and (zerop (forward-line -1))
3141 (gnus-summary-article-number))))
3142 ;; If this is a gathered thread, we have to go some re-gathering.
3143 (when (stringp (car thread))
3144 (let ((subject (car thread))
3146 (setq thread (cdr thread))
3148 (unless (memq (setq thr (gnus-id-to-thread
3150 (mail-header-id (caar thread)))))
3153 (setq thread (cdr thread)))
3154 ;; We now have all (unique) roots.
3155 (if (= (length roots) 1)
3156 ;; All the loose roots are now one solid root.
3157 (setq thread (car roots))
3158 (setq thread (cons subject (gnus-sort-threads roots))))))
3160 ;; We then insert this thread into the summary buffer.
3161 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3162 (if gnus-show-threads
3163 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3164 (gnus-summary-prepare-unthreaded thread))
3165 (setq data (nreverse gnus-newsgroup-data))
3166 (setq threads gnus-newsgroup-threads))
3167 ;; We splice the new data into the data structure.
3168 (gnus-data-enter-list current data (- (point) old-pos))
3169 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3171 (defun gnus-number-to-header (number)
3172 "Return the header for article NUMBER."
3173 (let ((headers gnus-newsgroup-headers))
3175 (not (= number (mail-header-number (car headers)))))
3180 (defun gnus-parent-headers (headers &optional generation)
3181 "Return the headers of the GENERATIONeth parent of HEADERS."
3183 (setq generation 1))
3186 (while (and parent headers (not (zerop generation)))
3187 (setq references (mail-header-references headers))
3188 (when (and references
3189 (setq parent (gnus-parent-id references))
3190 (setq headers (car (gnus-id-to-thread parent))))
3194 (defun gnus-id-to-thread (id)
3195 "Return the (sub-)thread where ID appears."
3196 (gnus-gethash id gnus-newsgroup-dependencies))
3198 (defun gnus-id-to-article (id)
3199 "Return the article number of ID."
3200 (let ((thread (gnus-id-to-thread id)))
3203 (mail-header-number (car thread)))))
3205 (defun gnus-id-to-header (id)
3206 "Return the article headers of ID."
3207 (car (gnus-id-to-thread id)))
3209 (defun gnus-article-displayed-root-p (article)
3210 "Say whether ARTICLE is a root(ish) article."
3211 (let ((level (gnus-summary-thread-level article))
3212 (refs (mail-header-references (gnus-summary-article-header article)))
3218 ((null (gnus-parent-id refs)) t)
3220 (null (setq particle (gnus-id-to-article
3221 (gnus-parent-id refs))))
3222 (null (gnus-summary-thread-level particle)))))))
3224 (defun gnus-root-id (id)
3225 "Return the id of the root of the thread where ID appears."
3227 (while (and id (setq prev (car (gnus-gethash
3228 id gnus-newsgroup-dependencies))))
3230 id (gnus-parent-id (mail-header-references prev))))
3233 (defun gnus-articles-in-thread (thread)
3234 "Return the list of articles in THREAD."
3235 (cons (mail-header-number (car thread))
3236 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3238 (defun gnus-remove-thread (id &optional dont-remove)
3239 "Remove the thread that has ID in it."
3240 (let ((dep gnus-newsgroup-dependencies)
3241 headers thread last-id)
3242 ;; First go up in this thread until we find the root.
3243 (setq last-id (gnus-root-id id))
3244 (setq headers (list (car (gnus-id-to-thread last-id))
3245 (caadr (gnus-id-to-thread last-id))))
3246 ;; We have now found the real root of this thread. It might have
3247 ;; been gathered into some loose thread, so we have to search
3248 ;; through the threads to find the thread we wanted.
3249 (let ((threads gnus-newsgroup-threads)
3252 (setq sub (car threads))
3253 (if (stringp (car sub))
3254 ;; This is a gathered thread, so we look at the roots
3255 ;; below it to find whether this article is in this
3258 (setq sub (cdr sub))
3260 (when (member (caar sub) headers)
3261 (setq thread (car threads)
3264 (setq sub (cdr sub))))
3265 ;; It's an ordinary thread, so we check it.
3266 (when (eq (car sub) (car headers))
3269 (setq threads (cdr threads)))
3270 ;; If this article is in no thread, then it's a root.
3273 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3274 (setq thread (gnus-gethash last-id dep)))
3277 thread ; We return this thread.
3279 (if (stringp (car thread))
3281 ;; If we use dummy roots, then we have to remove the
3282 ;; dummy root as well.
3283 (when (eq gnus-summary-make-false-root 'dummy)
3285 (gnus-data-compute-positions))
3286 (setq thread (cdr thread))
3288 (gnus-remove-thread-1 (car thread))
3289 (setq thread (cdr thread))))
3290 (gnus-remove-thread-1 thread))))))))
3292 (defun gnus-remove-thread-1 (thread)
3293 "Remove the thread THREAD recursively."
3294 (let ((number (mail-header-number (pop thread)))
3296 (setq thread (reverse thread))
3298 (gnus-remove-thread-1 (pop thread)))
3299 (when (setq d (gnus-data-find number))
3300 (goto-char (gnus-data-pos d))
3303 (- (gnus-point-at-bol)
3305 (1+ (gnus-point-at-eol))
3306 (gnus-delete-line)))))))
3308 (defun gnus-sort-threads (threads)
3310 (if (not gnus-thread-sort-functions)
3312 (gnus-message 7 "Sorting threads...")
3314 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3315 (gnus-message 7 "Sorting threads...done"))))
3317 (defun gnus-sort-articles (articles)
3319 (when gnus-article-sort-functions
3320 (gnus-message 7 "Sorting articles...")
3322 (setq gnus-newsgroup-headers
3323 (sort articles (gnus-make-sort-function
3324 gnus-article-sort-functions)))
3325 (gnus-message 7 "Sorting articles...done"))))
3327 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3328 (defmacro gnus-thread-header (thread)
3329 ;; Return header of first article in THREAD.
3330 ;; Note that THREAD must never, ever be anything else than a variable -
3331 ;; using some other form will lead to serious barfage.
3332 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3333 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3334 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3337 (defsubst gnus-article-sort-by-number (h1 h2)
3338 "Sort articles by article number."
3339 (< (mail-header-number h1)
3340 (mail-header-number h2)))
3342 (defun gnus-thread-sort-by-number (h1 h2)
3343 "Sort threads by root article number."
3344 (gnus-article-sort-by-number
3345 (gnus-thread-header h1) (gnus-thread-header h2)))
3347 (defsubst gnus-article-sort-by-lines (h1 h2)
3348 "Sort articles by article Lines header."
3349 (< (mail-header-lines h1)
3350 (mail-header-lines h2)))
3352 (defun gnus-thread-sort-by-lines (h1 h2)
3353 "Sort threads by root article Lines header."
3354 (gnus-article-sort-by-lines
3355 (gnus-thread-header h1) (gnus-thread-header h2)))
3357 (defsubst gnus-article-sort-by-author (h1 h2)
3358 "Sort articles by root author."
3360 (let ((extract (funcall
3361 gnus-extract-address-components
3362 (mail-header-from h1))))
3363 (or (car extract) (cadr extract) ""))
3364 (let ((extract (funcall
3365 gnus-extract-address-components
3366 (mail-header-from h2))))
3367 (or (car extract) (cadr extract) ""))))
3369 (defun gnus-thread-sort-by-author (h1 h2)
3370 "Sort threads by root author."
3371 (gnus-article-sort-by-author
3372 (gnus-thread-header h1) (gnus-thread-header h2)))
3374 (defsubst gnus-article-sort-by-subject (h1 h2)
3375 "Sort articles by root subject."
3377 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3378 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3380 (defun gnus-thread-sort-by-subject (h1 h2)
3381 "Sort threads by root subject."
3382 (gnus-article-sort-by-subject
3383 (gnus-thread-header h1) (gnus-thread-header h2)))
3385 (defsubst gnus-article-sort-by-date (h1 h2)
3386 "Sort articles by root article date."
3388 (gnus-date-get-time (mail-header-date h1))
3389 (gnus-date-get-time (mail-header-date h2))))
3391 (defun gnus-thread-sort-by-date (h1 h2)
3392 "Sort threads by root article date."
3393 (gnus-article-sort-by-date
3394 (gnus-thread-header h1) (gnus-thread-header h2)))
3396 (defsubst gnus-article-sort-by-score (h1 h2)
3397 "Sort articles by root article score.
3398 Unscored articles will be counted as having a score of zero."
3399 (> (or (cdr (assq (mail-header-number h1)
3400 gnus-newsgroup-scored))
3401 gnus-summary-default-score 0)
3402 (or (cdr (assq (mail-header-number h2)
3403 gnus-newsgroup-scored))
3404 gnus-summary-default-score 0)))
3406 (defun gnus-thread-sort-by-score (h1 h2)
3407 "Sort threads by root article score."
3408 (gnus-article-sort-by-score
3409 (gnus-thread-header h1) (gnus-thread-header h2)))
3411 (defun gnus-thread-sort-by-total-score (h1 h2)
3412 "Sort threads by the sum of all scores in the thread.
3413 Unscored articles will be counted as having a score of zero."
3414 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3416 (defun gnus-thread-total-score (thread)
3417 ;; This function find the total score of THREAD.
3418 (cond ((null thread)
3421 (if (stringp (car thread))
3422 (apply gnus-thread-score-function 0
3423 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3424 (gnus-thread-total-score-1 thread)))
3426 (gnus-thread-total-score-1 (list thread)))))
3428 (defun gnus-thread-total-score-1 (root)
3429 ;; This function find the total score of the thread below ROOT.
3430 (setq root (car root))
3431 (apply gnus-thread-score-function
3433 (mapcar 'gnus-thread-total-score
3434 (cdr (gnus-gethash (mail-header-id root)
3435 gnus-newsgroup-dependencies)))
3436 (when (> (mail-header-number root) 0)
3437 (list (or (cdr (assq (mail-header-number root)
3438 gnus-newsgroup-scored))
3439 gnus-summary-default-score 0))))
3440 (list gnus-summary-default-score)
3443 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3444 (defvar gnus-tmp-prev-subject nil)
3445 (defvar gnus-tmp-false-parent nil)
3446 (defvar gnus-tmp-root-expunged nil)
3447 (defvar gnus-tmp-dummy-line nil)
3449 (defun gnus-summary-prepare-threads (threads)
3450 "Prepare summary buffer from THREADS and indentation LEVEL.
3451 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3452 or a straight list of headers."
3453 (gnus-message 7 "Generating summary...")
3455 (setq gnus-newsgroup-threads threads)
3458 (let ((gnus-tmp-level 0)
3459 (default-score (or gnus-summary-default-score 0))
3460 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3461 thread number subject stack state gnus-tmp-gathered beg-match
3462 new-roots gnus-tmp-new-adopts thread-end
3463 gnus-tmp-header gnus-tmp-unread
3464 gnus-tmp-replied gnus-tmp-subject-or-nil
3465 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3466 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3467 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3469 (setq gnus-tmp-prev-subject nil)
3471 (if (vectorp (car threads))
3472 ;; If this is a straight (sic) list of headers, then a
3473 ;; threaded summary display isn't required, so we just create
3474 ;; an unthreaded one.
3475 (gnus-summary-prepare-unthreaded threads)
3477 ;; Do the threaded display.
3479 (while (or threads stack gnus-tmp-new-adopts new-roots)
3481 (if (and (= gnus-tmp-level 0)
3482 (not (setq gnus-tmp-dummy-line nil))
3485 (not gnus-tmp-false-parent)
3486 (or gnus-tmp-new-adopts new-roots))
3487 (if gnus-tmp-new-adopts
3488 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3489 thread (list (car gnus-tmp-new-adopts))
3490 gnus-tmp-header (caar thread)
3491 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3493 (setq thread (list (car new-roots))
3494 gnus-tmp-header (caar thread)
3495 new-roots (cdr new-roots))))
3498 ;; If there are some threads, we do them before the
3499 ;; threads on the stack.
3500 (setq thread threads
3501 gnus-tmp-header (caar thread))
3502 ;; There were no current threads, so we pop something off
3504 (setq state (car stack)
3505 gnus-tmp-level (car state)
3508 gnus-tmp-header (caar thread))))
3510 (setq gnus-tmp-false-parent nil)
3511 (setq gnus-tmp-root-expunged nil)
3512 (setq thread-end nil)
3514 (if (stringp gnus-tmp-header)
3515 ;; The header is a dummy root.
3517 ((eq gnus-summary-make-false-root 'adopt)
3518 ;; We let the first article adopt the rest.
3519 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3521 (setq gnus-tmp-gathered
3523 (lambda (h) (mail-header-number (car h)))
3526 (setq thread (cons (list (caar thread)
3529 (setq gnus-tmp-level -1
3530 gnus-tmp-false-parent t))
3531 ((eq gnus-summary-make-false-root 'empty)
3532 ;; We print adopted articles with empty subject fields.
3533 (setq gnus-tmp-gathered
3535 (lambda (h) (mail-header-number (car h)))
3538 (setq gnus-tmp-level -1))
3539 ((eq gnus-summary-make-false-root 'dummy)
3540 ;; We remember that we probably want to output a dummy
3542 (setq gnus-tmp-dummy-line gnus-tmp-header)
3543 (setq gnus-tmp-prev-subject gnus-tmp-header))
3545 ;; We do not make a root for the gathered
3546 ;; sub-threads at all.
3547 (setq gnus-tmp-level -1)))
3549 (setq number (mail-header-number gnus-tmp-header)
3550 subject (mail-header-subject gnus-tmp-header))
3553 ;; If the thread has changed subject, we might want to make
3554 ;; this subthread into a root.
3555 ((and (null gnus-thread-ignore-subject)
3556 (not (zerop gnus-tmp-level))
3557 gnus-tmp-prev-subject
3559 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3560 (setq new-roots (nconc new-roots (list (car thread)))
3562 gnus-tmp-header nil))
3563 ;; If the article lies outside the current limit,
3564 ;; then we do not display it.
3565 ((not (memq number gnus-newsgroup-limit))
3566 (setq gnus-tmp-gathered
3568 (lambda (h) (mail-header-number (car h)))
3571 (setq gnus-tmp-new-adopts (if (cdar thread)
3572 (append gnus-tmp-new-adopts
3574 gnus-tmp-new-adopts)
3576 gnus-tmp-header nil)
3577 (when (zerop gnus-tmp-level)
3578 (setq gnus-tmp-root-expunged t)))
3579 ;; Perhaps this article is to be marked as read?
3580 ((and gnus-summary-mark-below
3581 (< (or (cdr (assq number gnus-newsgroup-scored))
3583 gnus-summary-mark-below)
3584 ;; Don't touch sparse articles.
3585 (not (gnus-summary-article-sparse-p number))
3586 (not (gnus-summary-article-ancient-p number)))
3587 (setq gnus-newsgroup-unreads
3588 (delq number gnus-newsgroup-unreads))
3589 (if gnus-newsgroup-auto-expire
3590 (push number gnus-newsgroup-expirable)
3591 (push (cons number gnus-low-score-mark)
3592 gnus-newsgroup-reads))))
3594 (when gnus-tmp-header
3595 ;; We may have an old dummy line to output before this
3597 (when gnus-tmp-dummy-line
3598 (gnus-summary-insert-dummy-line
3599 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3600 (setq gnus-tmp-dummy-line nil))
3602 ;; Compute the mark.
3603 (setq gnus-tmp-unread (gnus-article-mark number))
3605 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3606 gnus-tmp-header gnus-tmp-level)
3607 gnus-newsgroup-data)
3609 ;; Actually insert the line.
3611 gnus-tmp-subject-or-nil
3613 ((and gnus-thread-ignore-subject
3614 gnus-tmp-prev-subject
3615 (not (inline (gnus-subject-equal
3616 gnus-tmp-prev-subject subject))))
3618 ((zerop gnus-tmp-level)
3619 (if (and (eq gnus-summary-make-false-root 'empty)
3620 (memq number gnus-tmp-gathered)
3621 gnus-tmp-prev-subject
3622 (inline (gnus-subject-equal
3623 gnus-tmp-prev-subject subject)))
3624 gnus-summary-same-subject
3626 (t gnus-summary-same-subject)))
3627 (if (and (eq gnus-summary-make-false-root 'adopt)
3628 (= gnus-tmp-level 1)
3629 (memq number gnus-tmp-gathered))
3630 (setq gnus-tmp-opening-bracket ?\<
3631 gnus-tmp-closing-bracket ?\>)
3632 (setq gnus-tmp-opening-bracket ?\[
3633 gnus-tmp-closing-bracket ?\]))
3635 gnus-tmp-indentation
3636 (aref gnus-thread-indent-array gnus-tmp-level)
3637 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3638 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3639 gnus-summary-default-score 0)
3641 (if (or (null gnus-summary-default-score)
3642 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3643 gnus-summary-zcore-fuzz))
3645 (if (< gnus-tmp-score gnus-summary-default-score)
3646 gnus-score-below-mark gnus-score-over-mark))
3648 (cond ((memq number gnus-newsgroup-processable)
3650 ((memq number gnus-newsgroup-cached)
3652 ((memq number gnus-newsgroup-replied)
3654 ((memq number gnus-newsgroup-saved)
3656 (t gnus-unread-mark))
3657 gnus-tmp-from (mail-header-from gnus-tmp-header)
3660 ((string-match "<[^>]+> *$" gnus-tmp-from)
3661 (setq beg-match (match-beginning 0))
3662 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3663 (substring gnus-tmp-from (1+ (match-beginning 0))
3664 (1- (match-end 0))))
3665 (substring gnus-tmp-from 0 beg-match)))
3666 ((string-match "(.+)" gnus-tmp-from)
3667 (substring gnus-tmp-from
3668 (1+ (match-beginning 0)) (1- (match-end 0))))
3670 (when (string= gnus-tmp-name "")
3671 (setq gnus-tmp-name gnus-tmp-from))
3672 (unless (numberp gnus-tmp-lines)
3673 (setq gnus-tmp-lines 0))
3674 (gnus-put-text-property
3676 (progn (eval gnus-summary-line-format-spec) (point))
3677 'gnus-number number)
3680 (run-hooks 'gnus-summary-update-hook)
3683 (setq gnus-tmp-prev-subject subject)))
3685 (when (nth 1 thread)
3686 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3687 (incf gnus-tmp-level)
3688 (setq threads (if thread-end nil (cdar thread)))
3690 (setq gnus-tmp-level 0)))))
3691 (gnus-message 7 "Generating summary...done"))
3693 (defun gnus-summary-prepare-unthreaded (headers)
3694 "Generate an unthreaded summary buffer based on HEADERS."
3695 (let (header number mark)
3700 ;; We may have to root out some bad articles...
3701 (when (memq (setq number (mail-header-number
3702 (setq header (pop headers))))
3703 gnus-newsgroup-limit)
3704 ;; Mark article as read when it has a low score.
3705 (when (and gnus-summary-mark-below
3706 (< (or (cdr (assq number gnus-newsgroup-scored))
3707 gnus-summary-default-score 0)
3708 gnus-summary-mark-below)
3709 (not (gnus-summary-article-ancient-p number)))
3710 (setq gnus-newsgroup-unreads
3711 (delq number gnus-newsgroup-unreads))
3712 (if gnus-newsgroup-auto-expire
3713 (push number gnus-newsgroup-expirable)
3714 (push (cons number gnus-low-score-mark)
3715 gnus-newsgroup-reads)))
3717 (setq mark (gnus-article-mark number))
3718 (push (gnus-data-make number mark (1+ (point)) header 0)
3719 gnus-newsgroup-data)
3720 (gnus-summary-insert-line
3722 mark (memq number gnus-newsgroup-replied)
3723 (memq number gnus-newsgroup-expirable)
3724 (mail-header-subject header) nil
3725 (cdr (assq number gnus-newsgroup-scored))
3726 (memq number gnus-newsgroup-processable))))))
3728 (defun gnus-select-newsgroup (group &optional read-all)
3729 "Select newsgroup GROUP.
3730 If READ-ALL is non-nil, all articles in the group are selected."
3731 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3732 ;;!!! Dirty hack; should be removed.
3733 (gnus-summary-ignore-duplicates
3734 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3736 gnus-summary-ignore-duplicates))
3737 (info (nth 2 entry))
3738 articles fetched-articles cached)
3740 (unless (gnus-check-server
3741 (setq gnus-current-select-method
3742 (gnus-find-method-for-group group)))
3743 (error "Couldn't open server"))
3745 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3746 (gnus-activate-group group) ; Or we can activate it...
3747 (progn ; Or we bug out.
3748 (when (equal major-mode 'gnus-summary-mode)
3749 (kill-buffer (current-buffer)))
3750 (error "Couldn't request group %s: %s"
3751 group (gnus-status-message group))))
3753 (unless (gnus-request-group group t)
3754 (when (equal major-mode 'gnus-summary-mode)
3755 (kill-buffer (current-buffer)))
3756 (error "Couldn't request group %s: %s"
3757 group (gnus-status-message group)))
3759 (setq gnus-newsgroup-name group)
3760 (setq gnus-newsgroup-unselected nil)
3761 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3763 ;; Adjust and set lists of article marks.
3765 (gnus-adjust-marked-articles info))
3767 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3768 (when (gnus-virtual-group-p group)
3769 (setq cached gnus-newsgroup-cached))
3771 (setq gnus-newsgroup-unreads
3772 (gnus-set-difference
3773 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3774 gnus-newsgroup-dormant))
3776 (setq gnus-newsgroup-processable nil)
3778 (gnus-update-read-articles group gnus-newsgroup-unreads)
3779 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3780 (gnus-group-update-group group))
3782 (setq articles (gnus-articles-to-read group read-all))
3786 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3788 ((eq articles 0) nil)
3790 ;; Init the dependencies hash table.
3791 (setq gnus-newsgroup-dependencies
3792 (gnus-make-hashtable (length articles)))
3793 ;; Retrieve the headers and read them in.
3794 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3795 (setq gnus-newsgroup-headers
3797 (setq gnus-headers-retrieved-by
3798 (gnus-retrieve-headers
3799 articles gnus-newsgroup-name
3800 ;; We might want to fetch old headers, but
3801 ;; not if there is only 1 article.
3802 (and gnus-fetch-old-headers
3804 (not (eq gnus-fetch-old-headers 'some))
3805 (not (numberp gnus-fetch-old-headers)))
3806 (> (length articles) 1))))))
3807 (gnus-get-newsgroup-headers-xover
3808 articles nil nil gnus-newsgroup-name t)
3809 (gnus-get-newsgroup-headers)))
3810 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3812 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3814 (setq gnus-newsgroup-cached cached))
3816 ;; Suppress duplicates?
3817 (when gnus-suppress-duplicates
3818 (gnus-dup-suppress-articles))
3820 ;; Set the initial limit.
3821 (setq gnus-newsgroup-limit (copy-sequence articles))
3822 ;; Remove canceled articles from the list of unread articles.
3823 (setq gnus-newsgroup-unreads
3824 (gnus-set-sorted-intersection
3825 gnus-newsgroup-unreads
3826 (setq fetched-articles
3827 (mapcar (lambda (headers) (mail-header-number headers))
3828 gnus-newsgroup-headers))))
3829 ;; Removed marked articles that do not exist.
3830 (gnus-update-missing-marks
3831 (gnus-sorted-complement fetched-articles articles))
3832 ;; Let the Gnus agent mark articles as read.
3834 (gnus-agent-get-undownloaded-list))
3835 ;; We might want to build some more threads first.
3836 (when (and gnus-fetch-old-headers
3837 (eq gnus-headers-retrieved-by 'nov))
3838 (if (eq gnus-fetch-old-headers 'invisible)
3839 (gnus-build-all-threads)
3840 (gnus-build-old-threads)))
3841 ;; Check whether auto-expire is to be done in this group.
3842 (setq gnus-newsgroup-auto-expire
3843 (gnus-group-auto-expirable-p group))
3844 ;; Set up the article buffer now, if necessary.
3845 (unless gnus-single-article-buffer
3846 (gnus-article-setup-buffer))
3847 ;; First and last article in this newsgroup.
3848 (when gnus-newsgroup-headers
3849 (setq gnus-newsgroup-begin
3850 (mail-header-number (car gnus-newsgroup-headers))
3853 (gnus-last-element gnus-newsgroup-headers))))
3854 ;; GROUP is successfully selected.
3855 (or gnus-newsgroup-headers t)))))
3857 (defun gnus-articles-to-read (group &optional read-all)
3858 ;; Find out what articles the user wants to read.
3860 ;; Select all articles if `read-all' is non-nil, or if there
3861 ;; are no unread articles.
3863 (and (zerop (length gnus-newsgroup-marked))
3864 (zerop (length gnus-newsgroup-unreads)))
3865 (eq (gnus-group-find-parameter group 'display)
3867 (gnus-uncompress-range (gnus-active group))
3868 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3869 (copy-sequence gnus-newsgroup-unreads))
3871 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3872 (scored (length scored-list))
3873 (number (length articles))
3874 (marked (+ (length gnus-newsgroup-marked)
3875 (length gnus-newsgroup-dormant)))
3883 ((and (or (<= scored marked) (= scored number))
3884 (numberp gnus-large-newsgroup)
3885 (> number gnus-large-newsgroup))
3889 "How many articles from %s (default %d): "
3890 (gnus-limit-string gnus-newsgroup-name 35)
3892 (if (string-match "^[ \t]*$" input) number input)))
3893 ((and (> scored marked) (< scored number)
3894 (> (- scored number) 20))
3897 (format "%s %s (%d scored, %d total): "
3898 "How many articles from"
3899 group scored number))))
3900 (if (string-match "^[ \t]*$" input)
3904 (setq select (if (stringp select) (string-to-number select) select))
3905 (if (or (null select) (zerop select))
3907 (if (and (not (zerop scored)) (<= (abs select) scored))
3909 (setq articles (sort scored-list '<))
3910 (setq number (length articles)))
3911 (setq articles (copy-sequence articles)))
3913 (when (< (abs select) number)
3915 ;; Select the N oldest articles.
3916 (setcdr (nthcdr (1- (abs select)) articles) nil)
3917 ;; Select the N most recent articles.
3918 (setq articles (nthcdr (- number select) articles))))
3919 (setq gnus-newsgroup-unselected
3920 (gnus-sorted-intersection
3921 gnus-newsgroup-unreads
3922 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3925 (defun gnus-killed-articles (killed articles)
3928 (when (inline (gnus-member-of-range (car articles) killed))
3929 (push (car articles) out))
3930 (setq articles (cdr articles)))
3933 (defun gnus-uncompress-marks (marks)
3934 "Uncompress the mark ranges in MARKS."
3935 (let ((uncompressed '(score bookmark))
3938 (if (memq (caar marks) uncompressed)
3939 (push (car marks) out)
3940 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3941 (setq marks (cdr marks)))
3944 (defun gnus-adjust-marked-articles (info)
3945 "Set all article lists and remove all marks that are no longer legal."
3946 (let* ((marked-lists (gnus-info-marks info))
3947 (active (gnus-active (gnus-info-group info)))
3950 (types gnus-article-mark-lists)
3951 (uncompressed '(score bookmark killed))
3952 marks var articles article mark)
3955 (setq marks (pop marked-lists))
3956 (set (setq var (intern (format "gnus-newsgroup-%s"
3957 (car (rassq (setq mark (car marks))
3959 (if (memq (car marks) uncompressed) (cdr marks)
3960 (gnus-uncompress-range (cdr marks))))
3962 (setq articles (symbol-value var))
3964 ;; All articles have to be subsets of the active articles.
3966 ;; Adjust "simple" lists.
3967 ((memq mark '(tick dormant expire reply save))
3969 (when (or (< (setq article (pop articles)) min) (> article max))
3970 (set var (delq article (symbol-value var))))))
3972 ((memq mark uncompressed)
3973 (when (not (listp (cdr (symbol-value var))))
3974 (set var (list (symbol-value var))))
3975 (when (not (listp (cdr articles)))
3976 (setq articles (list articles)))
3978 (when (or (not (consp (setq article (pop articles))))
3979 (< (car article) min)
3980 (> (car article) max))
3981 (set var (delq article (symbol-value var))))))))))
3983 (defun gnus-update-missing-marks (missing)
3984 "Go through the list of MISSING articles and remove them from the mark lists."
3986 (let ((types gnus-article-mark-lists)
3988 ;; Go through all types.
3990 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3991 (when (symbol-value var)
3992 ;; This list has articles. So we delete all missing articles
3996 (set var (delq (pop m) (symbol-value var)))))))))
3998 (defun gnus-update-marks ()
3999 "Enter the various lists of marked articles into the newsgroup info list."
4000 (let ((types gnus-article-mark-lists)
4001 (info (gnus-get-info gnus-newsgroup-name))
4002 (uncompressed '(score bookmark killed))
4003 type list newmarked symbol)
4005 ;; Add all marks lists that are non-nil to the list of marks lists.
4006 (while (setq type (pop types))
4007 (when (setq list (symbol-value
4009 (intern (format "gnus-newsgroup-%s"
4012 ;; Get rid of the entries of the articles that have the
4014 (when (and (eq (cdr type) 'score)
4018 (prev (cons nil list))
4021 (if (or (not (consp (car arts)))
4022 (= (cdar arts) gnus-summary-default-score))
4023 (setcdr prev (cdr arts))
4025 (setq arts (cdr arts)))
4026 (setq list (cdr all))))
4028 (push (cons (cdr type)
4029 (if (memq (cdr type) uncompressed) list
4030 (gnus-compress-sequence
4031 (set symbol (sort list '<)) t)))
4034 ;; Enter these new marks into the info of the group.
4036 (setcar (nthcdr 3 info) newmarked)
4037 ;; Add the marks lists to the end of the info.
4039 (setcdr (nthcdr 2 info) (list newmarked))))
4041 ;; Cut off the end of the info if there's nothing else there.
4045 (when (nthcdr (decf i) info)
4046 (setcdr (nthcdr i info) nil)))))))
4048 (defun gnus-set-mode-line (where)
4049 "This function sets the mode line of the article or summary buffers.
4050 If WHERE is `summary', the summary mode line format will be used."
4051 ;; Is this mode line one we keep updated?
4052 (when (memq where gnus-updated-mode-lines)
4055 ;; We evaluate this in the summary buffer since these
4056 ;; variables are buffer-local to that buffer.
4057 (set-buffer gnus-summary-buffer)
4058 ;; We bind all these variables that are used in the `eval' form
4060 (let* ((mformat (symbol-value
4062 (format "gnus-%s-mode-line-format-spec" where))))
4063 (gnus-tmp-group-name gnus-newsgroup-name)
4064 (gnus-tmp-article-number (or gnus-current-article 0))
4065 (gnus-tmp-unread gnus-newsgroup-unreads)
4066 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4067 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4068 (gnus-tmp-unread-and-unselected
4069 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4070 (zerop gnus-tmp-unselected))
4072 ((zerop gnus-tmp-unselected)
4073 (format "{%d more}" gnus-tmp-unread-and-unticked))
4074 (t (format "{%d(+%d) more}"
4075 gnus-tmp-unread-and-unticked
4076 gnus-tmp-unselected))))
4078 (if (and gnus-current-headers
4079 (vectorp gnus-current-headers))
4080 (gnus-mode-string-quote
4081 (mail-header-subject gnus-current-headers))
4083 bufname-length max-len
4084 gnus-tmp-header);; passed as argument to any user-format-funcs
4085 (setq mode-string (eval mformat))
4086 (setq bufname-length (if (string-match "%b" mode-string)
4089 (if (eq where 'summary)
4091 (get-buffer gnus-article-buffer))))
4094 (setq max-len (max 4 (if gnus-mode-non-string-length
4096 gnus-mode-non-string-length
4098 (length mode-string))))
4099 ;; We might have to chop a bit of the string off...
4100 (when (> (length mode-string) max-len)
4102 (concat (gnus-truncate-string mode-string (- max-len 3))
4104 ;; Pad the mode string a bit.
4105 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4106 ;; Update the mode line.
4107 (setq mode-line-buffer-identification
4108 (gnus-mode-line-buffer-identification (list mode-string)))
4109 (set-buffer-modified-p t))))
4111 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4112 "Go through the HEADERS list and add all Xrefs to a hash table.
4113 The resulting hash table is returned, or nil if no Xrefs were found."
4114 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4115 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4116 (xref-hashtb (gnus-make-hashtable))
4117 start group entry number xrefs header)
4119 (setq header (pop headers))
4120 (when (and (setq xrefs (mail-header-xref header))
4121 (not (memq (setq number (mail-header-number header))
4124 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4125 (setq start (match-end 0))
4126 (setq group (if prefix
4127 (concat prefix (substring xrefs (match-beginning 1)
4129 (substring xrefs (match-beginning 1) (match-end 1))))
4131 (string-to-int (substring xrefs (match-beginning 2)
4133 (if (setq entry (gnus-gethash group xref-hashtb))
4134 (setcdr entry (cons number (cdr entry)))
4135 (gnus-sethash group (cons number nil) xref-hashtb)))))
4136 (and start xref-hashtb)))
4138 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4139 "Look through all the headers and mark the Xrefs as read."
4140 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4141 name entry info xref-hashtb idlist method nth4)
4143 (set-buffer gnus-group-buffer)
4144 (when (setq xref-hashtb
4145 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4148 (unless (string= from-newsgroup (setq name (symbol-name group)))
4149 (setq idlist (symbol-value group))
4150 ;; Dead groups are not updated.
4152 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4154 (when (stringp (setq nth4 (gnus-info-method info)))
4155 (setq nth4 (gnus-server-to-method nth4))))
4156 ;; Only do the xrefs if the group has the same
4157 ;; select method as the group we have just read.
4158 (or (gnus-methods-equal-p
4159 nth4 (gnus-find-method-for-group from-newsgroup))
4161 (equal nth4 (setq method (gnus-find-method-for-group
4163 (and (equal (car nth4) (car method))
4164 (equal (nth 1 nth4) (nth 1 method))))
4165 gnus-use-cross-reference
4166 (or (not (eq gnus-use-cross-reference t))
4168 ;; Only do cross-references on subscribed
4169 ;; groups, if that is what is wanted.
4170 (<= (gnus-info-level info) gnus-level-subscribed))
4171 (gnus-group-make-articles-read name idlist))))
4174 (defun gnus-compute-read-articles (group articles)
4175 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4176 (info (nth 2 entry))
4177 (active (gnus-active group))
4180 ;; First peel off all illegal article numbers.
4182 (let ((ids articles)
4184 (while (setq id (pop ids))
4185 (when (and first (> id (cdr active)))
4186 ;; We'll end up in this situation in one particular
4187 ;; obscure situation. If you re-scan a group and get
4188 ;; a new article that is cross-posted to a different
4189 ;; group that has not been re-scanned, you might get
4190 ;; crossposted article that has a higher number than
4191 ;; Gnus believes possible. So we re-activate this
4192 ;; group as well. This might mean doing the
4193 ;; crossposting thingy will *increase* the number
4194 ;; of articles in some groups. Tsk, tsk.
4195 (setq active (or (gnus-activate-group group) active)))
4196 (when (or (> id (cdr active))
4197 (< id (car active)))
4198 (setq articles (delq id articles))))))
4199 ;; If the read list is nil, we init it.
4201 (null (gnus-info-read info))
4203 (setq ninfo (cons 1 (1- (car active))))
4204 (setq ninfo (gnus-info-read info)))
4205 ;; Then we add the read articles to the range.
4207 ninfo (setq articles (sort articles '<))))))
4209 (defun gnus-group-make-articles-read (group articles)
4210 "Update the info of GROUP to say that ARTICLES are read."
4212 (entry (gnus-gethash group gnus-newsrc-hashtb))
4213 (info (nth 2 entry))
4214 (active (gnus-active group))
4217 (setq range (gnus-compute-read-articles group articles))
4219 (set-buffer gnus-group-buffer)
4222 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4223 (gnus-info-set-read ',info ',(gnus-info-read info))
4224 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4225 (gnus-group-update-group ,group t))))
4226 ;; Add the read articles to the range.
4227 (gnus-info-set-read info range)
4228 ;; Then we have to re-compute how many unread
4229 ;; articles there are in this group.
4233 (setq num (- (1+ (cdr active)) (car active))))
4234 ((not (listp (cdr range)))
4235 (setq num (- (cdr active) (- (1+ (cdr range))
4239 (if (numberp (car range))
4241 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4242 (setq range (cdr range)))
4243 (setq num (- (cdr active) num))))
4244 ;; Update the number of unread articles.
4246 ;; Update the group buffer.
4247 (gnus-group-update-group group t)))))
4249 (defun gnus-methods-equal-p (m1 m2)
4250 (let ((m1 (or m1 gnus-select-method))
4251 (m2 (or m2 gnus-select-method)))
4253 (and (eq (car m1) (car m2))
4254 (or (not (memq 'address (assoc (symbol-name (car m1))
4255 gnus-valid-select-methods)))
4256 (equal (nth 1 m1) (nth 1 m2)))))))
4258 (defvar gnus-newsgroup-none-id 0)
4260 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4261 (let ((cur nntp-server-buffer)
4264 (save-excursion (set-buffer gnus-summary-buffer)
4265 gnus-newsgroup-dependencies)))
4266 headers id id-dep ref-dep end ref)
4268 (set-buffer nntp-server-buffer)
4269 ;; Translate all TAB characters into SPACE characters.
4270 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4271 (run-hooks 'gnus-parse-headers-hook)
4272 (let ((case-fold-search t)
4273 in-reply-to header p lines)
4274 (goto-char (point-min))
4275 ;; Search to the beginning of the next header. Error messages
4276 ;; do not begin with 2 or 3.
4277 (while (re-search-forward "^[23][0-9]+ " nil t)
4280 ;; This implementation of this function, with nine
4281 ;; search-forwards instead of the one re-search-forward and
4282 ;; a case (which basically was the old function) is actually
4283 ;; about twice as fast, even though it looks messier. You
4284 ;; can't have everything, I guess. Speed and elegance
4285 ;; doesn't always go hand in hand.
4294 (narrow-to-region (point)
4295 (or (and (search-forward "\n.\n" nil t)
4301 (if (search-forward "\nsubject: " nil t)
4302 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4304 gnus-unstructured-field-decoder (nnheader-header-value))
4309 (if (search-forward "\nfrom: " nil t)
4310 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4312 gnus-structured-field-decoder (nnheader-header-value))
4317 (if (search-forward "\ndate: " nil t)
4318 (nnheader-header-value) ""))
4322 (setq id (if (search-forward "\nmessage-id:" nil t)
4324 (1- (or (search-forward "<" nil t) (point)))
4325 (or (search-forward ">" nil t) (point)))
4326 ;; If there was no message-id, we just fake one
4327 ;; to make subsequent routines simpler.
4328 (nnheader-generate-fake-message-id))))
4332 (if (search-forward "\nreferences: " nil t)
4336 (nnheader-header-value)
4341 (search-backward ">" end t)
4344 (search-backward "<" end t)
4346 ;; Get the references from the in-reply-to header if there
4347 ;; were no references and the in-reply-to header looks
4349 (if (and (search-forward "\nin-reply-to: " nil t)
4350 (setq in-reply-to (nnheader-header-value))
4351 (string-match "<[^>]+>" in-reply-to))
4352 (setq ref (substring in-reply-to (match-beginning 0)
4360 (if (search-forward "\nlines: " nil t)
4361 (if (numberp (setq lines (ignore-errors (read cur))))
4367 (and (search-forward "\nxref: " nil t)
4368 (nnheader-header-value)))))
4369 (when (equal id ref)
4372 (when gnus-alter-header-function
4373 (funcall gnus-alter-header-function header)
4374 (setq id (mail-header-id header)
4375 ref (gnus-parent-id (mail-header-references header))))
4377 ;; We do the threading while we read the headers. The
4378 ;; message-id and the last reference are both entered into
4379 ;; the same hash table. Some tippy-toeing around has to be
4380 ;; done in case an article has arrived before the article
4381 ;; which it refers to.
4382 (if (boundp (setq id-dep (intern id dependencies)))
4383 (if (and (car (symbol-value id-dep))
4385 ;; An article with this Message-ID has already been seen.
4386 (if gnus-summary-ignore-duplicates
4387 ;; We ignore this one, except we add
4388 ;; any additional Xrefs (in case the two articles
4389 ;; came from different servers).
4391 (mail-header-set-xref
4392 (car (symbol-value id-dep))
4393 (concat (or (mail-header-xref
4394 (car (symbol-value id-dep)))
4396 (or (mail-header-xref header) "")))
4398 ;; We rename the Message-ID.
4400 (setq id-dep (intern (setq id (nnmail-message-id))
4403 (mail-header-set-id header id))
4404 (setcar (symbol-value id-dep) header))
4405 (set id-dep (list header)))
4407 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4408 (setcdr (symbol-value ref-dep)
4409 (nconc (cdr (symbol-value ref-dep))
4410 (list (symbol-value id-dep))))
4411 (set ref-dep (list nil (symbol-value id-dep))))
4412 (push header headers))
4413 (goto-char (point-max))
4415 (nreverse headers)))))
4417 ;; The following macros and functions were written by Felix Lee
4418 ;; <flee@cse.psu.edu>.
4420 (defmacro gnus-nov-read-integer ()
4422 (if (= (following-char) ?\t)
4424 (let ((num (ignore-errors (read buffer))))
4425 (if (numberp num) num 0)))
4427 (search-forward "\t" eol 'move))))
4429 (defmacro gnus-nov-skip-field ()
4430 '(search-forward "\t" eol 'move))
4432 (defmacro gnus-nov-field ()
4433 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4435 ;; (defvar gnus-nov-none-counter 0)
4437 ;; This function has to be called with point after the article number
4438 ;; on the beginning of the line.
4439 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4440 (let ((eol (gnus-point-at-eol))
4441 (buffer (current-buffer))
4442 header ref id id-dep ref-dep)
4444 ;; overview: [num subject from date id refs chars lines misc]
4447 (narrow-to-region (point) eol)
4455 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4457 gnus-structured-field-decoder (gnus-nov-field)) ; from
4458 (gnus-nov-field) ; date
4459 (setq id (or (gnus-nov-field)
4460 (nnheader-generate-fake-message-id))) ; id
4462 (let ((beg (point)))
4463 (search-forward "\t" eol)
4464 (if (search-backward ">" beg t)
4468 (search-backward "<" beg t)))
4471 (gnus-nov-field)) ; refs
4472 (gnus-nov-read-integer) ; chars
4473 (gnus-nov-read-integer) ; lines
4474 (if (= (following-char) ?\n)
4476 (gnus-nov-field))))) ; misc
4480 (when gnus-alter-header-function
4481 (funcall gnus-alter-header-function header)
4482 (setq id (mail-header-id header)
4483 ref (gnus-parent-id (mail-header-references header))))
4485 ;; We build the thread tree.
4486 (when (equal id ref)
4487 ;; This article refers back to itself. Naughty, naughty.
4489 (if (boundp (setq id-dep (intern id dependencies)))
4490 (if (and (car (symbol-value id-dep))
4492 ;; An article with this Message-ID has already been seen.
4493 (if gnus-summary-ignore-duplicates
4494 ;; We ignore this one, except we add any additional
4495 ;; Xrefs (in case the two articles came from different
4498 (mail-header-set-xref
4499 (car (symbol-value id-dep))
4500 (concat (or (mail-header-xref
4501 (car (symbol-value id-dep)))
4503 (or (mail-header-xref header) "")))
4505 ;; We rename the Message-ID.
4507 (setq id-dep (intern (setq id (nnmail-message-id))
4510 (mail-header-set-id header id))
4511 (setcar (symbol-value id-dep) header))
4512 (set id-dep (list header)))
4514 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4515 (setcdr (symbol-value ref-dep)
4516 (nconc (cdr (symbol-value ref-dep))
4517 (list (symbol-value id-dep))))
4518 (set ref-dep (list nil (symbol-value id-dep)))))
4521 ;; Goes through the xover lines and returns a list of vectors
4522 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4523 force-new dependencies
4524 group also-fetch-heads)
4525 "Parse the news overview data in the server buffer, and return a
4526 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4527 ;; Get the Xref when the users reads the articles since most/some
4528 ;; NNTP servers do not include Xrefs when using XOVER.
4529 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4530 (let ((cur nntp-server-buffer)
4531 (dependencies (or dependencies gnus-newsgroup-dependencies))
4532 number headers header)
4534 (set-buffer nntp-server-buffer)
4535 ;; Allow the user to mangle the headers before parsing them.
4536 (run-hooks 'gnus-parse-headers-hook)
4537 (goto-char (point-min))
4540 (while (and sequence (not (eobp)))
4541 (setq number (read cur))
4542 (while (and sequence
4543 (< (car sequence) number))
4544 (setq sequence (cdr sequence)))
4546 (eq number (car sequence))
4548 (setq sequence (cdr sequence))
4549 (setq header (inline
4550 (gnus-nov-parse-line
4551 number dependencies force-new))))
4552 (push header headers))
4555 (gnus-error 4 "Strange nov line (%d)"
4556 (count-lines (point-min) (point)))))
4558 ;; A common bug in inn is that if you have posted an article and
4559 ;; then retrieves the active file, it will answer correctly --
4560 ;; the new article is included. However, a NOV entry for the
4561 ;; article may not have been generated yet, so this may fail.
4562 ;; We work around this problem by retrieving the last few
4563 ;; headers using HEAD.
4564 (if (or (not also-fetch-heads)
4566 ;; We (probably) got all the headers.
4568 (let ((gnus-nov-is-evil t))
4571 (when (gnus-retrieve-headers sequence group)
4572 (gnus-get-newsgroup-headers))))))))
4574 (defun gnus-article-get-xrefs ()
4575 "Fill in the Xref value in `gnus-current-headers', if necessary.
4576 This is meant to be called in `gnus-article-internal-prepare-hook'."
4577 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4578 gnus-current-headers)))
4579 (or (not gnus-use-cross-reference)
4581 (and (mail-header-xref headers)
4582 (not (string= (mail-header-xref headers) "")))
4583 (let ((case-fold-search t)
4586 (nnheader-narrow-to-headers)
4587 (goto-char (point-min))
4588 (when (or (and (eq (downcase (following-char)) ?x)
4589 (looking-at "Xref:"))
4590 (search-forward "\nXref:" nil t))
4591 (goto-char (1+ (match-end 0)))
4592 (setq xref (buffer-substring (point)
4593 (progn (end-of-line) (point))))
4594 (mail-header-set-xref headers xref)))))))
4596 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4597 "Find article ID and insert the summary line for that article."
4598 (let ((header (if (and old-header use-old-header)
4599 old-header (gnus-read-header id)))
4600 (number (and (numberp id) id))
4603 ;; Rebuild the thread that this article is part of and go to the
4604 ;; article we have fetched.
4605 (when (and (not gnus-show-threads)
4607 (when (setq d (gnus-data-find (mail-header-number old-header)))
4608 (goto-char (gnus-data-pos d))
4611 (- (gnus-point-at-bol)
4613 (1+ (gnus-point-at-eol))
4614 (gnus-delete-line))))))
4616 (mail-header-set-number header (mail-header-number old-header)))
4617 (setq gnus-newsgroup-sparse
4618 (delq (setq number (mail-header-number header))
4619 gnus-newsgroup-sparse))
4620 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4621 (gnus-rebuild-thread (mail-header-id header))
4622 (gnus-summary-goto-subject number nil t))
4623 (when (and (numberp number)
4625 ;; We have to update the boundaries even if we can't fetch the
4626 ;; article if ID is a number -- so that the next `P' or `N'
4627 ;; command will fetch the previous (or next) article even
4628 ;; if the one we tried to fetch this time has been canceled.
4629 (when (> number gnus-newsgroup-end)
4630 (setq gnus-newsgroup-end number))
4631 (when (< number gnus-newsgroup-begin)
4632 (setq gnus-newsgroup-begin number))
4633 (setq gnus-newsgroup-unselected
4634 (delq number gnus-newsgroup-unselected)))
4635 ;; Report back a success?
4636 (and header (mail-header-number header))))
4638 ;;; Process/prefix in the summary buffer
4640 (defun gnus-summary-work-articles (n)
4641 "Return a list of articles to be worked upon. The prefix argument,
4642 the list of process marked articles, and the current article will be
4643 taken into consideration."
4646 ;; A numerical prefix has been given.
4647 (setq n (prefix-numeric-value n))
4648 (let ((backward (< n 0))
4649 (n (abs (prefix-numeric-value n)))
4654 (push (setq article (gnus-summary-article-number))
4657 (gnus-summary-find-prev nil article)
4658 (gnus-summary-find-next nil article)))
4660 (nreverse articles)))
4661 ((gnus-region-active-p)
4662 ;; Work on the region between point and mark.
4663 (let ((max (max (point) (mark)))
4666 (goto-char (min (point) (mark)))
4669 (push (setq article (gnus-summary-article-number)) articles)
4670 (gnus-summary-find-next nil article)
4672 (nreverse articles))))
4673 (gnus-newsgroup-processable
4674 ;; There are process-marked articles present.
4675 ;; Save current state.
4676 (gnus-summary-save-process-mark)
4678 (reverse gnus-newsgroup-processable))
4680 ;; Just return the current article.
4681 (list (gnus-summary-article-number)))))
4683 (defun gnus-summary-save-process-mark ()
4684 "Push the current set of process marked articles on the stack."
4686 (push (copy-sequence gnus-newsgroup-processable)
4687 gnus-newsgroup-process-stack))
4689 (defun gnus-summary-kill-process-mark ()
4690 "Push the current set of process marked articles on the stack and unmark."
4692 (gnus-summary-save-process-mark)
4693 (gnus-summary-unmark-all-processable))
4695 (defun gnus-summary-yank-process-mark ()
4696 "Pop the last process mark state off the stack and restore it."
4698 (unless gnus-newsgroup-process-stack
4699 (error "Empty mark stack"))
4700 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4702 (defun gnus-summary-process-mark-set (set)
4703 "Make SET into the current process marked articles."
4704 (gnus-summary-unmark-all-processable)
4706 (gnus-summary-set-process-mark (pop set))))
4708 ;;; Searching and stuff
4710 (defun gnus-summary-search-group (&optional backward use-level)
4711 "Search for next unread newsgroup.
4712 If optional argument BACKWARD is non-nil, search backward instead."
4714 (set-buffer gnus-group-buffer)
4715 (when (gnus-group-search-forward
4716 backward nil (if use-level (gnus-group-group-level) nil))
4717 (gnus-group-group-name))))
4719 (defun gnus-summary-best-group (&optional exclude-group)
4720 "Find the name of the best unread group.
4721 If EXCLUDE-GROUP, do not go to this group."
4723 (set-buffer gnus-group-buffer)
4725 (gnus-group-best-unread-group exclude-group))))
4727 (defun gnus-summary-find-next (&optional unread article backward)
4728 (if backward (gnus-summary-find-prev)
4729 (let* ((dummy (gnus-summary-article-intangible-p))
4730 (article (or article (gnus-summary-article-number)))
4731 (arts (gnus-data-find-list article))
4733 (when (and (not dummy)
4734 (or (not gnus-summary-check-current)
4736 (not (gnus-data-unread-p (car arts)))))
4737 (setq arts (cdr arts)))
4742 (when (gnus-data-unread-p (car arts))
4743 (setq result (car arts)
4745 (setq arts (cdr arts)))
4748 (goto-char (gnus-data-pos result))
4749 (gnus-data-number result)))))
4751 (defun gnus-summary-find-prev (&optional unread article)
4752 (let* ((eobp (eobp))
4753 (article (or article (gnus-summary-article-number)))
4754 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4756 (when (and (not eobp)
4757 (or (not gnus-summary-check-current)
4759 (not (gnus-data-unread-p (car arts)))))
4760 (setq arts (cdr arts)))
4765 (when (gnus-data-unread-p (car arts))
4766 (setq result (car arts)
4768 (setq arts (cdr arts)))
4771 (goto-char (gnus-data-pos result))
4772 (gnus-data-number result))))
4774 (defun gnus-summary-find-subject (subject &optional unread backward article)
4775 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4776 (article (or article (gnus-summary-article-number)))
4777 (articles (gnus-data-list backward))
4778 (arts (gnus-data-find-list article articles))
4780 (when (or (not gnus-summary-check-current)
4782 (not (gnus-data-unread-p (car arts))))
4783 (setq arts (cdr arts)))
4785 (and (or (not unread)
4786 (gnus-data-unread-p (car arts)))
4787 (vectorp (gnus-data-header (car arts)))
4789 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4790 (setq result (car arts)
4792 (setq arts (cdr arts)))
4794 (goto-char (gnus-data-pos result))
4795 (gnus-data-number result))))
4797 (defun gnus-summary-search-forward (&optional unread subject backward)
4798 "Search forward for an article.
4799 If UNREAD, look for unread articles. If SUBJECT, look for
4800 articles with that subject. If BACKWARD, search backward instead."
4801 (cond (subject (gnus-summary-find-subject subject unread backward))
4802 (backward (gnus-summary-find-prev unread))
4803 (t (gnus-summary-find-next unread))))
4805 (defun gnus-recenter (&optional n)
4806 "Center point in window and redisplay frame.
4807 Also do horizontal recentering."
4809 (when (and gnus-auto-center-summary
4810 (not (eq gnus-auto-center-summary 'vertical)))
4811 (gnus-horizontal-recenter))
4814 (defun gnus-summary-recenter ()
4815 "Center point in the summary window.
4816 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4817 displayed, no centering will be performed."
4818 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4819 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4820 (let* ((top (cond ((< (window-height) 4) 0)
4821 ((< (window-height) 7) 1)
4823 (height (1- (window-height)))
4824 (bottom (save-excursion (goto-char (point-max))
4825 (forward-line (- height))
4827 (window (get-buffer-window (current-buffer))))
4828 ;; The user has to want it.
4829 (when gnus-auto-center-summary
4830 (when (get-buffer-window gnus-article-buffer)
4831 ;; Only do recentering when the article buffer is displayed,
4832 ;; Set the window start to either `bottom', which is the biggest
4833 ;; possible valid number, or the second line from the top,
4834 ;; whichever is the least.
4836 window (min bottom (save-excursion
4837 (forward-line (- top)) (point)))))
4838 ;; Do horizontal recentering while we're at it.
4839 (when (and (get-buffer-window (current-buffer) t)
4840 (not (eq gnus-auto-center-summary 'vertical)))
4841 (let ((selected (selected-window)))
4842 (select-window (get-buffer-window (current-buffer) t))
4843 (gnus-summary-position-point)
4844 (gnus-horizontal-recenter)
4845 (select-window selected))))))
4847 (defun gnus-summary-jump-to-group (newsgroup)
4848 "Move point to NEWSGROUP in group mode buffer."
4849 ;; Keep update point of group mode buffer if visible.
4850 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4851 (save-window-excursion
4852 ;; Take care of tree window mode.
4853 (when (get-buffer-window gnus-group-buffer)
4854 (pop-to-buffer gnus-group-buffer))
4855 (gnus-group-jump-to-group newsgroup))
4857 ;; Take care of tree window mode.
4858 (if (get-buffer-window gnus-group-buffer)
4859 (pop-to-buffer gnus-group-buffer)
4860 (set-buffer gnus-group-buffer))
4861 (gnus-group-jump-to-group newsgroup))))
4863 ;; This function returns a list of article numbers based on the
4864 ;; difference between the ranges of read articles in this group and
4865 ;; the range of active articles.
4866 (defun gnus-list-of-unread-articles (group)
4867 (let* ((read (gnus-info-read (gnus-get-info group)))
4868 (active (or (gnus-active group) (gnus-activate-group group)))
4871 ;; If none are read, then all are unread.
4873 (setq first (car active))
4874 ;; If the range of read articles is a single range, then the
4875 ;; first unread article is the article after the last read
4876 ;; article. Sounds logical, doesn't it?
4877 (if (not (listp (cdr read)))
4878 (setq first (1+ (cdr read)))
4879 ;; `read' is a list of ranges.
4880 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4886 (while (< first nlast)
4888 (setq first (1+ first))))
4889 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4890 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4891 (setq read (cdr read)))))
4892 ;; And add the last unread articles.
4893 (while (<= first last)
4895 (setq first (1+ first)))
4896 ;; Return the list of unread articles.
4897 (delq 0 (nreverse unread))))
4899 (defun gnus-list-of-read-articles (group)
4900 "Return a list of unread, unticked and non-dormant articles."
4901 (let* ((info (gnus-get-info group))
4902 (marked (gnus-info-marks info))
4903 (active (gnus-active group)))
4905 (gnus-set-difference
4906 (gnus-sorted-complement
4907 (gnus-uncompress-range active)
4908 (gnus-list-of-unread-articles group))
4910 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4911 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4913 ;; Various summary commands
4915 (defun gnus-summary-select-article-buffer ()
4916 "Reconfigure windows to show article buffer."
4918 (if (not (gnus-buffer-live-p gnus-article-buffer))
4919 (error "There is no article buffer for this summary buffer")
4920 (gnus-configure-windows 'article)
4921 (select-window (get-buffer-window gnus-article-buffer))))
4923 (defun gnus-summary-universal-argument (arg)
4924 "Perform any operation on all articles that are process/prefixed."
4926 (let ((articles (gnus-summary-work-articles arg))
4933 (substitute-command-keys
4934 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4937 (gnus-error 1 "Undefined key")
4940 (gnus-summary-goto-subject (setq article (pop articles)))
4941 (let (gnus-newsgroup-processable)
4942 (command-execute func))
4943 (gnus-summary-remove-process-mark article)))))
4944 (gnus-summary-position-point))
4946 (defun gnus-summary-toggle-truncation (&optional arg)
4947 "Toggle truncation of summary lines.
4948 With arg, turn line truncation on iff arg is positive."
4950 (setq truncate-lines
4951 (if (null arg) (not truncate-lines)
4952 (> (prefix-numeric-value arg) 0)))
4955 (defun gnus-summary-reselect-current-group (&optional all rescan)
4956 "Exit and then reselect the current newsgroup.
4957 The prefix argument ALL means to select all articles."
4959 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4960 (error "Ephemeral groups can't be reselected"))
4961 (let ((current-subject (gnus-summary-article-number))
4962 (group gnus-newsgroup-name))
4963 (setq gnus-newsgroup-begin nil)
4965 ;; We have to adjust the point of group mode buffer because
4966 ;; point was moved to the next unread newsgroup by exiting.
4967 (gnus-summary-jump-to-group group)
4970 (gnus-group-get-new-news-this-group 1)))
4971 (gnus-group-read-group all t)
4972 (gnus-summary-goto-subject current-subject nil t)))
4974 (defun gnus-summary-rescan-group (&optional all)
4975 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4977 (gnus-summary-reselect-current-group all t))
4979 (defun gnus-summary-update-info (&optional non-destructive)
4981 (let ((group gnus-newsgroup-name))
4983 (when gnus-newsgroup-kill-headers
4984 (setq gnus-newsgroup-killed
4985 (gnus-compress-sequence
4987 (gnus-set-sorted-intersection
4988 (gnus-uncompress-range gnus-newsgroup-killed)
4989 (setq gnus-newsgroup-unselected
4990 (sort gnus-newsgroup-unselected '<)))
4991 (setq gnus-newsgroup-unreads
4992 (sort gnus-newsgroup-unreads '<)))
4994 (unless (listp (cdr gnus-newsgroup-killed))
4995 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4996 (let ((headers gnus-newsgroup-headers))
4997 (when (and (not gnus-save-score)
4998 (not non-destructive))
4999 (setq gnus-newsgroup-scored nil))
5000 ;; Set the new ranges of read articles.
5002 (set-buffer gnus-group-buffer)
5003 (gnus-undo-force-boundary))
5004 (gnus-update-read-articles
5005 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5006 ;; Set the current article marks.
5008 ;; Do the cross-ref thing.
5009 (when gnus-use-cross-reference
5010 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5011 ;; Do not switch windows but change the buffer to work.
5012 (set-buffer gnus-group-buffer)
5013 (unless (gnus-ephemeral-group-p group)
5014 (gnus-group-update-group group)))))))
5016 (defun gnus-summary-save-newsrc (&optional force)
5017 "Save the current number of read/marked articles in the dribble buffer.
5018 The dribble buffer will then be saved.
5019 If FORCE (the prefix), also save the .newsrc file(s)."
5021 (gnus-summary-update-info t)
5023 (gnus-save-newsrc-file)
5024 (gnus-dribble-save)))
5026 (defun gnus-summary-exit (&optional temporary)
5027 "Exit reading current newsgroup, and then return to group selection mode.
5028 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5030 (gnus-kill-save-kill-buffer)
5031 (let* ((group gnus-newsgroup-name)
5032 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5035 (buf (current-buffer)))
5036 (run-hooks 'gnus-summary-prepare-exit-hook)
5037 ;; If we have several article buffers, we kill them at exit.
5038 (unless gnus-single-article-buffer
5039 (gnus-kill-buffer gnus-original-article-buffer)
5040 (setq gnus-article-current nil))
5041 (when gnus-use-cache
5042 (gnus-cache-possibly-remove-articles)
5043 (gnus-cache-save-buffers))
5044 (gnus-async-prefetch-remove-group group)
5045 (when gnus-suppress-duplicates
5046 (gnus-dup-enter-articles))
5047 (when gnus-use-trees
5048 (gnus-tree-close group))
5049 ;; Make all changes in this group permanent.
5051 (run-hooks 'gnus-exit-group-hook)
5052 (gnus-summary-update-info)
5053 ;; Do adaptive scoring, and possibly save score files.
5054 (when gnus-newsgroup-adaptive
5055 (gnus-score-adaptive))
5056 (when gnus-use-scoring
5058 (gnus-close-group group)
5059 ;; Make sure where we were, and go to next newsgroup.
5060 (set-buffer gnus-group-buffer)
5062 (gnus-group-jump-to-group group))
5063 (run-hooks 'gnus-summary-exit-hook)
5064 (unless (or quit-config
5065 ;; If this group has disappeared from the summary
5066 ;; buffer, don't skip forwards.
5067 (not (string= group (gnus-group-group-name))))
5068 (gnus-group-next-unread-group 1))
5069 (setq group-point (point))
5072 ;; If we have several article buffers, we kill them at exit.
5073 (unless gnus-single-article-buffer
5074 (gnus-kill-buffer gnus-article-buffer)
5075 (gnus-kill-buffer gnus-original-article-buffer)
5076 (setq gnus-article-current nil))
5078 (if (not gnus-kill-summary-on-exit)
5079 (gnus-deaden-summary)
5080 ;; We set all buffer-local variables to nil. It is unclear why
5081 ;; this is needed, but if we don't, buffer-local variables are
5082 ;; not garbage-collected, it seems. This would the lead to en
5083 ;; ever-growing Emacs.
5084 (gnus-summary-clear-local-variables)
5085 (when (get-buffer gnus-article-buffer)
5086 (bury-buffer gnus-article-buffer))
5087 ;; We clear the global counterparts of the buffer-local
5088 ;; variables as well, just to be on the safe side.
5089 (set-buffer gnus-group-buffer)
5090 (gnus-summary-clear-local-variables)
5091 ;; Return to group mode buffer.
5092 (when (eq mode 'gnus-summary-mode)
5093 (gnus-kill-buffer buf)))
5094 (setq gnus-current-select-method gnus-select-method)
5095 (pop-to-buffer gnus-group-buffer)
5096 ;; Clear the current group name.
5097 (if (not quit-config)
5099 (goto-char group-point)
5100 (gnus-configure-windows 'group 'force))
5101 (gnus-handle-ephemeral-exit quit-config))
5103 (setq gnus-newsgroup-name nil)))))
5105 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5106 (defun gnus-summary-exit-no-update (&optional no-questions)
5107 "Quit reading current newsgroup without updating read article info."
5109 (let* ((group gnus-newsgroup-name)
5110 (quit-config (gnus-group-quit-config group)))
5111 (when (or no-questions
5113 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5114 ;; If we have several article buffers, we kill them at exit.
5115 (unless gnus-single-article-buffer
5116 (gnus-kill-buffer gnus-article-buffer)
5117 (gnus-kill-buffer gnus-original-article-buffer)
5118 (setq gnus-article-current nil))
5119 (if (not gnus-kill-summary-on-exit)
5120 (gnus-deaden-summary)
5121 (gnus-close-group group)
5122 (gnus-summary-clear-local-variables)
5123 (set-buffer gnus-group-buffer)
5124 (gnus-summary-clear-local-variables)
5125 (when (get-buffer gnus-summary-buffer)
5126 (kill-buffer gnus-summary-buffer)))
5127 (unless gnus-single-article-buffer
5128 (setq gnus-article-current nil))
5129 (when gnus-use-trees
5130 (gnus-tree-close group))
5131 (gnus-async-prefetch-remove-group group)
5132 (when (get-buffer gnus-article-buffer)
5133 (bury-buffer gnus-article-buffer))
5134 ;; Return to the group buffer.
5135 (gnus-configure-windows 'group 'force)
5136 ;; Clear the current group name.
5137 (setq gnus-newsgroup-name nil)
5138 (when (equal (gnus-group-group-name) group)
5139 (gnus-group-next-unread-group 1))
5141 (gnus-handle-ephemeral-exit quit-config)))))
5143 (defun gnus-handle-ephemeral-exit (quit-config)
5144 "Handle movement when leaving an ephemeral group. The state
5145 which existed when entering the ephemeral is reset."
5146 (if (not (buffer-name (car quit-config)))
5147 (gnus-configure-windows 'group 'force)
5148 (set-buffer (car quit-config))
5149 (cond ((eq major-mode 'gnus-summary-mode)
5150 (gnus-set-global-variables))
5151 ((eq major-mode 'gnus-article-mode)
5153 ;; The `gnus-summary-buffer' variable may point
5154 ;; to the old summary buffer when using a single
5156 (unless (gnus-buffer-live-p gnus-summary-buffer)
5157 (set-buffer gnus-group-buffer))
5158 (set-buffer gnus-summary-buffer)
5159 (gnus-set-global-variables))))
5160 (if (or (eq (cdr quit-config) 'article)
5161 (eq (cdr quit-config) 'pick))
5163 ;; The current article may be from the ephemeral group
5164 ;; thus it is best that we reload this article
5165 (gnus-summary-show-article)
5166 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5167 (gnus-configure-windows 'pick 'force)
5168 (gnus-configure-windows (cdr quit-config) 'force)))
5169 (gnus-configure-windows (cdr quit-config) 'force))
5170 (when (eq major-mode 'gnus-summary-mode)
5171 (gnus-summary-next-subject 1 nil t)
5172 (gnus-summary-recenter)
5173 (gnus-summary-position-point))))
5177 (defvar gnus-dead-summary-mode-map nil)
5179 (unless gnus-dead-summary-mode-map
5180 (setq gnus-dead-summary-mode-map (make-keymap))
5181 (suppress-keymap gnus-dead-summary-mode-map)
5182 (substitute-key-definition
5183 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5184 (let ((keys '("\C-d" "\r" "\177" [delete])))
5186 (define-key gnus-dead-summary-mode-map
5187 (pop keys) 'gnus-summary-wake-up-the-dead))))
5189 (defvar gnus-dead-summary-mode nil
5190 "Minor mode for Gnus summary buffers.")
5192 (defun gnus-dead-summary-mode (&optional arg)
5193 "Minor mode for Gnus summary buffers."
5195 (when (eq major-mode 'gnus-summary-mode)
5196 (make-local-variable 'gnus-dead-summary-mode)
5197 (setq gnus-dead-summary-mode
5198 (if (null arg) (not gnus-dead-summary-mode)
5199 (> (prefix-numeric-value arg) 0)))
5200 (when gnus-dead-summary-mode
5201 (gnus-add-minor-mode
5202 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5204 (defun gnus-deaden-summary ()
5205 "Make the current summary buffer into a dead summary buffer."
5206 ;; Kill any previous dead summary buffer.
5207 (when (and gnus-dead-summary
5208 (buffer-name gnus-dead-summary))
5210 (set-buffer gnus-dead-summary)
5211 (when gnus-dead-summary-mode
5212 (kill-buffer (current-buffer)))))
5213 ;; Make this the current dead summary.
5214 (setq gnus-dead-summary (current-buffer))
5215 (gnus-dead-summary-mode 1)
5216 (let ((name (buffer-name)))
5217 (when (string-match "Summary" name)
5219 (concat (substring name 0 (match-beginning 0)) "Dead "
5220 (substring name (match-beginning 0)))
5223 (defun gnus-kill-or-deaden-summary (buffer)
5224 "Kill or deaden the summary BUFFER."
5226 (when (and (buffer-name buffer)
5227 (not gnus-single-article-buffer))
5230 (gnus-kill-buffer gnus-article-buffer)
5231 (gnus-kill-buffer gnus-original-article-buffer)))
5232 (cond (gnus-kill-summary-on-exit
5233 (when (and gnus-use-trees
5234 (and (get-buffer buffer)
5235 (buffer-name (get-buffer buffer))))
5237 (set-buffer (get-buffer buffer))
5238 (gnus-tree-close gnus-newsgroup-name)))
5239 (gnus-kill-buffer buffer))
5240 ((and (get-buffer buffer)
5241 (buffer-name (get-buffer buffer)))
5244 (gnus-deaden-summary))))))
5246 (defun gnus-summary-wake-up-the-dead (&rest args)
5247 "Wake up the dead summary buffer."
5249 (gnus-dead-summary-mode -1)
5250 (let ((name (buffer-name)))
5251 (when (string-match "Dead " name)
5253 (concat (substring name 0 (match-beginning 0))
5254 (substring name (match-end 0)))
5256 (gnus-message 3 "This dead summary is now alive again"))
5258 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5259 (defun gnus-summary-fetch-faq (&optional faq-dir)
5260 "Fetch the FAQ for the current group.
5261 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5265 (when current-prefix-arg
5267 "Faq dir: " (and (listp gnus-group-faq-directory)
5268 (mapcar (lambda (file) (list file))
5269 gnus-group-faq-directory))))))
5270 (let (gnus-faq-buffer)
5271 (when (setq gnus-faq-buffer
5272 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5273 (gnus-configure-windows 'summary-faq))))
5275 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5276 (defun gnus-summary-describe-group (&optional force)
5277 "Describe the current newsgroup."
5279 (gnus-group-describe-group force gnus-newsgroup-name))
5281 (defun gnus-summary-describe-briefly ()
5282 "Describe summary mode commands briefly."
5285 (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")))
5287 ;; Walking around group mode buffer from summary mode.
5289 (defun gnus-summary-next-group (&optional no-article target-group backward)
5290 "Exit current newsgroup and then select next unread newsgroup.
5291 If prefix argument NO-ARTICLE is non-nil, no article is selected
5292 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5293 previous group instead."
5295 ;; Stop pre-fetching.
5296 (gnus-async-halt-prefetch)
5297 (let ((current-group gnus-newsgroup-name)
5298 (current-buffer (current-buffer))
5300 ;; First we semi-exit this group to update Xrefs and all variables.
5301 ;; We can't do a real exit, because the window conf must remain
5302 ;; the same in case the user is prompted for info, and we don't
5303 ;; want the window conf to change before that...
5304 (gnus-summary-exit t)
5305 (while (not entered)
5306 ;; Then we find what group we are supposed to enter.
5307 (set-buffer gnus-group-buffer)
5308 (gnus-group-jump-to-group current-group)
5311 (if (eq gnus-keep-same-level 'best)
5312 (gnus-summary-best-group gnus-newsgroup-name)
5313 (gnus-summary-search-group backward gnus-keep-same-level))))
5314 (if (not target-group)
5315 ;; There are no further groups, so we return to the group
5318 (gnus-message 5 "Returning to the group buffer")
5320 (when (gnus-buffer-live-p current-buffer)
5321 (set-buffer current-buffer)
5322 (gnus-summary-exit))
5323 (run-hooks 'gnus-group-no-more-groups-hook))
5324 ;; We try to enter the target group.
5325 (gnus-group-jump-to-group target-group)
5326 (let ((unreads (gnus-group-group-unread)))
5327 (if (and (or (eq t unreads)
5328 (and unreads (not (zerop unreads))))
5329 (gnus-summary-read-group
5330 target-group nil no-article
5331 (and (buffer-name current-buffer) current-buffer)))
5333 (setq current-group target-group
5334 target-group nil)))))))
5336 (defun gnus-summary-prev-group (&optional no-article)
5337 "Exit current newsgroup and then select previous unread newsgroup.
5338 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5340 (gnus-summary-next-group no-article nil t))
5342 ;; Walking around summary lines.
5344 (defun gnus-summary-first-subject (&optional unread)
5345 "Go to the first unread subject.
5346 If UNREAD is non-nil, go to the first unread article.
5347 Returns the article selected or nil if there are no unread articles."
5352 ((null gnus-newsgroup-data)
5353 (gnus-message 3 "No articles in the group")
5355 ;; Pick the first article.
5357 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5358 (gnus-data-number (car gnus-newsgroup-data)))
5359 ;; No unread articles.
5360 ((null gnus-newsgroup-unreads)
5361 (gnus-message 3 "No more unread articles")
5363 ;; Find the first unread article.
5365 (let ((data gnus-newsgroup-data))
5367 (not (gnus-data-unread-p (car data))))
5368 (setq data (cdr data)))
5370 (goto-char (gnus-data-pos (car data)))
5371 (gnus-data-number (car data))))))
5372 (gnus-summary-position-point)))
5374 (defun gnus-summary-next-subject (n &optional unread dont-display)
5375 "Go to next N'th summary line.
5376 If N is negative, go to the previous N'th subject line.
5377 If UNREAD is non-nil, only unread articles are selected.
5378 The difference between N and the actual number of steps taken is
5381 (let ((backward (< n 0))
5385 (gnus-summary-find-prev unread)
5386 (gnus-summary-find-next unread)))
5389 (gnus-message 7 "No more%s articles"
5390 (if unread " unread" "")))
5391 (unless dont-display
5392 (gnus-summary-recenter)
5393 (gnus-summary-position-point))
5396 (defun gnus-summary-next-unread-subject (n)
5397 "Go to next N'th unread summary line."
5399 (gnus-summary-next-subject n t))
5401 (defun gnus-summary-prev-subject (n &optional unread)
5402 "Go to previous N'th summary line.
5403 If optional argument UNREAD is non-nil, only unread article is selected."
5405 (gnus-summary-next-subject (- n) unread))
5407 (defun gnus-summary-prev-unread-subject (n)
5408 "Go to previous N'th unread summary line."
5410 (gnus-summary-next-subject (- n) t))
5412 (defun gnus-summary-goto-subject (article &optional force silent)
5413 "Go the subject line of ARTICLE.
5414 If FORCE, also allow jumping to articles not currently shown."
5415 (interactive "nArticle number: ")
5417 (data (gnus-data-find article)))
5418 ;; We read in the article if we have to.
5421 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5422 (setq data (gnus-data-find article)))
5427 (gnus-message 3 "Can't find article %d" article))
5429 (goto-char (gnus-data-pos data))
5432 ;; Walking around summary lines with displaying articles.
5434 (defun gnus-summary-expand-window (&optional arg)
5435 "Make the summary buffer take up the entire Emacs frame.
5436 Given a prefix, will force an `article' buffer configuration."
5439 (gnus-configure-windows 'article 'force)
5440 (gnus-configure-windows 'summary 'force)))
5442 (defun gnus-summary-display-article (article &optional all-header)
5443 "Display ARTICLE in article buffer."
5444 (gnus-set-global-variables)
5448 (if gnus-summary-display-article-function
5449 (funcall gnus-summary-display-article-function article all-header)
5450 (gnus-article-prepare article all-header))
5451 (run-hooks 'gnus-select-article-hook)
5452 (when (and gnus-current-article
5453 (not (zerop gnus-current-article)))
5454 (gnus-summary-goto-subject gnus-current-article))
5455 (gnus-summary-recenter)
5456 (when (and gnus-use-trees gnus-show-threads)
5457 (gnus-possibly-generate-tree article)
5458 (gnus-highlight-selected-tree article))
5459 ;; Successfully display article.
5460 (gnus-article-set-window-start
5461 (cdr (assq article gnus-newsgroup-bookmarks))))))
5463 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5464 "Select the current article.
5465 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5466 non-nil, the article will be re-fetched even if it already present in
5467 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5469 ;; Make sure we are in the summary buffer to work around bbdb bug.
5470 (unless (eq major-mode 'gnus-summary-mode)
5471 (set-buffer gnus-summary-buffer))
5472 (let ((article (or article (gnus-summary-article-number)))
5473 (all-headers (not (not all-headers))) ;Must be T or NIL.
5474 gnus-summary-display-article-function
5477 (gnus-summary-article-pseudo-p article)
5478 (error "This is a pseudo-article"))
5481 (set-buffer gnus-summary-buffer)
5482 (if (or (and gnus-single-article-buffer
5483 (or (null gnus-current-article)
5484 (null gnus-article-current)
5485 (null (get-buffer gnus-article-buffer))
5486 (not (eq article (cdr gnus-article-current)))
5487 (not (equal (car gnus-article-current)
5488 gnus-newsgroup-name))))
5489 (and (not gnus-single-article-buffer)
5490 (or (null gnus-current-article)
5491 (not (eq gnus-current-article article))))
5493 ;; The requested article is different from the current article.
5495 (gnus-summary-display-article article all-headers)
5497 (when (or all-headers gnus-show-all-headers)
5498 (gnus-article-show-all-headers))
5501 (gnus-article-set-window-start
5502 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5504 (defun gnus-summary-set-current-mark (&optional current-mark)
5505 "Obsolete function."
5508 (defun gnus-summary-next-article (&optional unread subject backward push)
5509 "Select the next article.
5510 If UNREAD, only unread articles are selected.
5511 If SUBJECT, only articles with SUBJECT are selected.
5512 If BACKWARD, the previous article is selected instead of the next."
5515 ;; Is there such an article?
5516 ((and (gnus-summary-search-forward unread subject backward)
5517 (or (gnus-summary-display-article (gnus-summary-article-number))
5518 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5519 (gnus-summary-position-point))
5520 ;; If not, we try the first unread, if that is wanted.
5522 gnus-auto-select-same
5523 (gnus-summary-first-unread-article))
5524 (gnus-summary-position-point)
5525 (gnus-message 6 "Wrapped"))
5526 ;; Try to get next/previous article not displayed in this group.
5527 ((and gnus-auto-extend-newsgroup
5528 (not unread) (not subject))
5529 (gnus-summary-goto-article
5530 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5532 ;; Go to next/previous group.
5534 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5535 (gnus-summary-jump-to-group gnus-newsgroup-name))
5536 (let ((cmd last-command-char)
5539 (set-buffer gnus-group-buffer)
5542 (if (eq gnus-keep-same-level 'best)
5543 (gnus-summary-best-group gnus-newsgroup-name)
5544 (gnus-summary-search-group backward gnus-keep-same-level))))
5545 ;; For some reason, the group window gets selected. We change
5547 (select-window (get-buffer-window (current-buffer)))
5548 ;; Select next unread newsgroup automagically.
5550 ((or (not gnus-auto-select-next)
5552 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5553 ((or (eq gnus-auto-select-next 'quietly)
5554 (and (eq gnus-auto-select-next 'slightly-quietly)
5556 (and (eq gnus-auto-select-next 'almost-quietly)
5557 (gnus-summary-last-article-p)))
5559 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5561 (gnus-message 7 "No more%s articles (%s)..."
5562 (if unread " unread" "")
5563 (if group (concat "selecting " group)
5565 (gnus-summary-next-group nil group backward)))
5567 (when (gnus-key-press-event-p last-input-event)
5568 (gnus-summary-walk-group-buffer
5569 gnus-newsgroup-name cmd unread backward point))))))))
5571 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5572 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5573 (?\C-p (gnus-group-prev-unread-group 1))))
5574 (cursor-in-echo-area t)
5575 keve key group ended)
5577 (set-buffer gnus-group-buffer)
5580 (if (eq gnus-keep-same-level 'best)
5581 (gnus-summary-best-group gnus-newsgroup-name)
5582 (gnus-summary-search-group backward gnus-keep-same-level))))
5585 5 "No more%s articles%s" (if unread " unread" "")
5587 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5588 (format " (Type %s for %s [%s])"
5589 (single-key-description cmd) group
5590 (car (gnus-gethash group gnus-newsrc-hashtb)))
5591 (format " (Type %s to exit %s)"
5592 (single-key-description cmd)
5593 gnus-newsgroup-name)))
5594 ;; Confirm auto selection.
5595 (setq key (car (setq keve (gnus-read-event-char))))
5598 ((assq key keystrokes)
5599 (let ((obuf (current-buffer)))
5600 (switch-to-buffer gnus-group-buffer)
5602 (gnus-group-jump-to-group group))
5603 (eval (cadr (assq key keystrokes)))
5604 (setq group (gnus-group-group-name))
5605 (switch-to-buffer obuf))
5609 (gnus-ephemeral-group-p gnus-newsgroup-name))
5611 (gnus-summary-next-group nil group backward)))
5613 (push (cdr keve) unread-command-events))))))
5615 (defun gnus-summary-next-unread-article ()
5616 "Select unread article after current one."
5618 (gnus-summary-next-article
5619 (or (not (eq gnus-summary-goto-unread 'never))
5620 (gnus-summary-last-article-p (gnus-summary-article-number)))
5621 (and gnus-auto-select-same
5622 (gnus-summary-article-subject))))
5624 (defun gnus-summary-prev-article (&optional unread subject)
5625 "Select the article after the current one.
5626 If UNREAD is non-nil, only unread articles are selected."
5628 (gnus-summary-next-article unread subject t))
5630 (defun gnus-summary-prev-unread-article ()
5631 "Select unread article before current one."
5633 (gnus-summary-prev-article
5634 (or (not (eq gnus-summary-goto-unread 'never))
5635 (gnus-summary-first-article-p (gnus-summary-article-number)))
5636 (and gnus-auto-select-same
5637 (gnus-summary-article-subject))))
5639 (defun gnus-summary-next-page (&optional lines circular)
5640 "Show next page of the selected article.
5641 If at the end of the current article, select the next article.
5642 LINES says how many lines should be scrolled up.
5644 If CIRCULAR is non-nil, go to the start of the article instead of
5645 selecting the next article when reaching the end of the current
5648 (setq gnus-summary-buffer (current-buffer))
5649 (gnus-set-global-variables)
5650 (let ((article (gnus-summary-article-number))
5651 (article-window (get-buffer-window gnus-article-buffer t))
5653 (gnus-configure-windows 'article)
5654 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5655 (if (and (eq gnus-summary-goto-unread 'never)
5656 (not (gnus-summary-last-article-p article)))
5657 (gnus-summary-next-article)
5658 (gnus-summary-next-unread-article))
5659 (if (or (null gnus-current-article)
5660 (null gnus-article-current)
5661 (/= article (cdr gnus-article-current))
5662 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5663 ;; Selected subject is different from current article's.
5664 (gnus-summary-display-article article)
5665 (when article-window
5666 (gnus-eval-in-buffer-window gnus-article-buffer
5667 (setq endp (gnus-article-next-page lines)))
5670 (gnus-summary-beginning-of-article))
5672 (gnus-message 3 "End of message"))
5674 (if (and (eq gnus-summary-goto-unread 'never)
5675 (not (gnus-summary-last-article-p article)))
5676 (gnus-summary-next-article)
5677 (gnus-summary-next-unread-article))))))))
5678 (gnus-summary-recenter)
5679 (gnus-summary-position-point)))
5681 (defun gnus-summary-prev-page (&optional lines move)
5682 "Show previous page of selected article.
5683 Argument LINES specifies lines to be scrolled down.
5684 If MOVE, move to the previous unread article if point is at
5685 the beginning of the buffer."
5687 (let ((article (gnus-summary-article-number))
5688 (article-window (get-buffer-window gnus-article-buffer t))
5690 (gnus-configure-windows 'article)
5691 (if (or (null gnus-current-article)
5692 (null gnus-article-current)
5693 (/= article (cdr gnus-article-current))
5694 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5695 ;; Selected subject is different from current article's.
5696 (gnus-summary-display-article article)
5697 (gnus-summary-recenter)
5698 (when article-window
5699 (gnus-eval-in-buffer-window gnus-article-buffer
5700 (setq endp (gnus-article-prev-page lines)))
5701 (when (and move endp)
5703 (gnus-message 3 "Beginning of message"))
5705 (if (and (eq gnus-summary-goto-unread 'never)
5706 (not (gnus-summary-first-article-p article)))
5707 (gnus-summary-prev-article)
5708 (gnus-summary-prev-unread-article))))))))
5709 (gnus-summary-position-point))
5711 (defun gnus-summary-prev-page-or-article (&optional lines)
5712 "Show previous page of selected article.
5713 Argument LINES specifies lines to be scrolled down.
5714 If at the beginning of the article, go to the next article."
5716 (gnus-summary-prev-page lines t))
5718 (defun gnus-summary-scroll-up (lines)
5719 "Scroll up (or down) one line current article.
5720 Argument LINES specifies lines to be scrolled up (or down if negative)."
5722 (gnus-configure-windows 'article)
5723 (gnus-summary-show-thread)
5724 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5725 (gnus-eval-in-buffer-window gnus-article-buffer
5727 (when (gnus-article-next-page lines)
5728 (gnus-message 3 "End of message")))
5730 (gnus-article-prev-page (- lines))))))
5731 (gnus-summary-recenter)
5732 (gnus-summary-position-point))
5734 (defun gnus-summary-next-same-subject ()
5735 "Select next article which has the same subject as current one."
5737 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5739 (defun gnus-summary-prev-same-subject ()
5740 "Select previous article which has the same subject as current one."
5742 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5744 (defun gnus-summary-next-unread-same-subject ()
5745 "Select next unread article which has the same subject as current one."
5747 (gnus-summary-next-article t (gnus-summary-article-subject)))
5749 (defun gnus-summary-prev-unread-same-subject ()
5750 "Select previous unread article which has the same subject as current one."
5752 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5754 (defun gnus-summary-first-unread-article ()
5755 "Select the first unread article.
5756 Return nil if there are no unread articles."
5759 (when (gnus-summary-first-subject t)
5760 (gnus-summary-show-thread)
5761 (gnus-summary-first-subject t)
5762 (gnus-summary-display-article (gnus-summary-article-number)))
5763 (gnus-summary-position-point)))
5765 (defun gnus-summary-first-article ()
5766 "Select the first article.
5767 Return nil if there are no articles."
5770 (when (gnus-summary-first-subject)
5771 (gnus-summary-show-thread)
5772 (gnus-summary-first-subject)
5773 (gnus-summary-display-article (gnus-summary-article-number)))
5774 (gnus-summary-position-point)))
5776 (defun gnus-summary-best-unread-article ()
5777 "Select the unread article with the highest score."
5779 (let ((best -1000000)
5780 (data gnus-newsgroup-data)
5783 (and (gnus-data-unread-p (car data))
5785 (gnus-summary-article-score (gnus-data-number (car data))))
5788 article (gnus-data-number (car data))))
5789 (setq data (cdr data)))
5792 (gnus-summary-goto-article article)
5793 (error "No unread articles"))
5794 (gnus-summary-position-point))))
5796 (defun gnus-summary-last-subject ()
5797 "Go to the last displayed subject line in the group."
5798 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5800 (gnus-summary-goto-subject article))))
5802 (defun gnus-summary-goto-article (article &optional all-headers force)
5803 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5804 If ALL-HEADERS is non-nil, no header lines are hidden."
5808 "Article number or Message-ID: "
5809 (mapcar (lambda (number) (list (int-to-string number)))
5810 gnus-newsgroup-limit))
5814 (if (and (stringp article)
5815 (string-match "@" article))
5816 (gnus-summary-refer-article article)
5817 (when (stringp article)
5818 (setq article (string-to-number article)))
5819 (if (gnus-summary-goto-subject article force)
5820 (gnus-summary-display-article article all-headers)
5821 (gnus-message 4 "Couldn't go to article %s" article) nil))
5822 (gnus-summary-position-point)))
5824 (defun gnus-summary-goto-last-article ()
5825 "Go to the previously read article."
5828 (when gnus-last-article
5829 (gnus-summary-goto-article gnus-last-article))
5830 (gnus-summary-position-point)))
5832 (defun gnus-summary-pop-article (number)
5833 "Pop one article off the history and go to the previous.
5834 NUMBER articles will be popped off."
5837 (setq gnus-newsgroup-history
5838 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5840 (gnus-summary-goto-article (car to) nil t)
5841 (error "Article history empty")))
5842 (gnus-summary-position-point))
5844 ;; Summary commands and functions for limiting the summary buffer.
5846 (defun gnus-summary-limit-to-articles (n)
5847 "Limit the summary buffer to the next N articles.
5848 If not given a prefix, use the process marked articles instead."
5851 (let ((articles (gnus-summary-work-articles n)))
5852 (setq gnus-newsgroup-processable nil)
5853 (gnus-summary-limit articles))
5854 (gnus-summary-position-point)))
5856 (defun gnus-summary-pop-limit (&optional total)
5857 "Restore the previous limit.
5858 If given a prefix, remove all limits."
5861 (setq gnus-newsgroup-limits
5862 (list (mapcar (lambda (h) (mail-header-number h))
5863 gnus-newsgroup-headers))))
5864 (unless gnus-newsgroup-limits
5865 (error "No limit to pop"))
5867 (gnus-summary-limit nil 'pop)
5868 (gnus-summary-position-point)))
5870 (defun gnus-summary-limit-to-subject (subject &optional header)
5871 "Limit the summary buffer to articles that have subjects that match a regexp."
5872 (interactive "sLimit to subject (regexp): ")
5874 (setq header "subject"))
5875 (when (not (equal "" subject))
5877 (let ((articles (gnus-summary-find-matching
5878 (or header "subject") subject 'all)))
5880 (error "Found no matches for \"%s\"" subject))
5881 (gnus-summary-limit articles))
5882 (gnus-summary-position-point))))
5884 (defun gnus-summary-limit-to-author (from)
5885 "Limit the summary buffer to articles that have authors that match a regexp."
5886 (interactive "sLimit to author (regexp): ")
5887 (gnus-summary-limit-to-subject from "from"))
5889 (defun gnus-summary-limit-to-age (age &optional younger-p)
5890 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5891 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5892 articles that are younger than AGE days."
5893 (interactive "nTime in days: \nP")
5895 (let ((data gnus-newsgroup-data)
5896 (cutoff (nnmail-days-to-time age))
5897 articles d date is-younger)
5898 (while (setq d (pop data))
5899 (when (and (vectorp (gnus-data-header d))
5900 (setq date (mail-header-date (gnus-data-header d))))
5901 (setq is-younger (nnmail-time-less
5902 (nnmail-time-since (nnmail-date-to-time date))
5904 (when (if younger-p is-younger (not is-younger))
5905 (push (gnus-data-number d) articles))))
5906 (gnus-summary-limit (nreverse articles)))
5907 (gnus-summary-position-point)))
5909 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5911 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5913 (defun gnus-summary-limit-to-unread (&optional all)
5914 "Limit the summary buffer to articles that are not marked as read.
5915 If ALL is non-nil, limit strictly to unread articles."
5918 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5919 (gnus-summary-limit-to-marks
5920 ;; Concat all the marks that say that an article is read and have
5922 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5923 gnus-killed-mark gnus-kill-file-mark
5924 gnus-low-score-mark gnus-expirable-mark
5925 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5926 gnus-duplicate-mark gnus-souped-mark)
5929 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5930 (make-obsolete 'gnus-summary-delete-marked-with
5931 'gnus-summary-limit-exlude-marks)
5933 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5934 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5935 If REVERSE, limit the summary buffer to articles that are marked
5936 with MARKS. MARKS can either be a string of marks or a list of marks.
5937 Returns how many articles were removed."
5938 (interactive "sMarks: ")
5939 (gnus-summary-limit-to-marks marks t))
5941 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5942 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5943 If REVERSE (the prefix), limit the summary buffer to articles that are
5944 not marked with MARKS. MARKS can either be a string of marks or a
5946 Returns how many articles were removed."
5947 (interactive "sMarks: \nP")
5949 (let ((data gnus-newsgroup-data)
5950 (marks (if (listp marks) marks
5951 (append marks nil))) ; Transform to list.
5954 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5955 (memq (gnus-data-mark (car data)) marks))
5956 (push (gnus-data-number (car data)) articles))
5957 (setq data (cdr data)))
5958 (gnus-summary-limit articles))
5959 (gnus-summary-position-point)))
5961 (defun gnus-summary-limit-to-score (&optional score)
5962 "Limit to articles with score at or above SCORE."
5964 (setq score (if score
5965 (prefix-numeric-value score)
5966 (or gnus-summary-default-score 0)))
5967 (let ((data gnus-newsgroup-data)
5970 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5972 (push (gnus-data-number (car data)) articles))
5973 (setq data (cdr data)))
5975 (gnus-summary-limit articles)
5976 (gnus-summary-position-point))))
5978 (defun gnus-summary-limit-include-thread (id)
5979 "Display all the hidden articles that in the current thread."
5980 (interactive (list (mail-header-id (gnus-summary-article-header))))
5981 (let ((articles (gnus-articles-in-thread
5982 (gnus-id-to-thread (gnus-root-id id)))))
5984 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
5985 (gnus-summary-position-point))))
5987 (defun gnus-summary-limit-include-dormant ()
5988 "Display all the hidden articles that are marked as dormant.
5989 Note that this command only works on a subset of the articles currently
5990 fetched for this group."
5992 (unless gnus-newsgroup-dormant
5993 (error "There are no dormant articles in this group"))
5995 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5996 (gnus-summary-position-point)))
5998 (defun gnus-summary-limit-exclude-dormant ()
5999 "Hide all dormant articles."
6002 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6003 (gnus-summary-position-point)))
6005 (defun gnus-summary-limit-exclude-childless-dormant ()
6006 "Hide all dormant articles that have no children."
6008 (let ((data (gnus-data-list t))
6009 articles d children)
6010 ;; Find all articles that are either not dormant or have
6012 (while (setq d (pop data))
6013 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6015 (gnus-article-children (gnus-data-number d)))
6018 (when (memq (car children) articles)
6023 (push (gnus-data-number d) articles)))
6026 (gnus-summary-limit articles)
6027 (gnus-summary-position-point))))
6029 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6030 "Mark all unread excluded articles as read.
6031 If ALL, mark even excluded ticked and dormants as read."
6033 (let ((articles (gnus-sorted-complement
6035 (mapcar (lambda (h) (mail-header-number h))
6036 gnus-newsgroup-headers)
6038 (sort gnus-newsgroup-limit '<)))
6040 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6042 (setq gnus-newsgroup-dormant nil
6043 gnus-newsgroup-marked nil
6044 gnus-newsgroup-reads
6046 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6047 gnus-newsgroup-reads))
6048 (while (setq article (pop articles))
6049 (unless (or (memq article gnus-newsgroup-dormant)
6050 (memq article gnus-newsgroup-marked))
6051 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6053 (defun gnus-summary-limit (articles &optional pop)
6055 ;; We pop the previous limit off the stack and use that.
6056 (setq articles (car gnus-newsgroup-limits)
6057 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6058 ;; We use the new limit, so we push the old limit on the stack.
6059 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6061 (setq gnus-newsgroup-limit articles)
6062 (let ((total (length gnus-newsgroup-data))
6063 (data (gnus-data-find-list (gnus-summary-article-number)))
6064 (gnus-summary-mark-below nil) ; Inhibit this.
6066 ;; This will do all the work of generating the new summary buffer
6067 ;; according to the new limit.
6068 (gnus-summary-prepare)
6069 ;; Hide any threads, possibly.
6070 (and gnus-show-threads
6071 gnus-thread-hide-subtree
6072 (gnus-summary-hide-all-threads))
6073 ;; Try to return to the article you were at, or one in the
6076 ;; We try to find some article after the current one.
6078 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6081 (setq data (cdr data))))
6083 ;; If there is no data, that means that we were after the last
6084 ;; article. The same goes when we can't find any articles
6085 ;; after the current one.
6086 (goto-char (point-max))
6087 (gnus-summary-find-prev))
6088 ;; We return how many articles were removed from the summary
6089 ;; buffer as a result of the new limit.
6090 (- total (length gnus-newsgroup-data))))
6092 (defsubst gnus-invisible-cut-children (threads)
6095 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6100 (defsubst gnus-cut-thread (thread)
6101 "Go forwards in the thread until we find an article that we want to display."
6102 (when (or (eq gnus-fetch-old-headers 'some)
6103 (eq gnus-fetch-old-headers 'invisible)
6104 (eq gnus-build-sparse-threads 'some)
6105 (eq gnus-build-sparse-threads 'more))
6106 ;; Deal with old-fetched headers and sparse threads.
6110 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6111 (gnus-summary-article-ancient-p
6112 (mail-header-number (car thread))))
6113 (if (or (<= (length (cdr thread)) 1)
6114 (eq gnus-fetch-old-headers 'invisible))
6115 (setq gnus-newsgroup-limit
6116 (delq (mail-header-number (car thread))
6117 gnus-newsgroup-limit)
6118 thread (cadr thread))
6119 (when (gnus-invisible-cut-children (cdr thread))
6120 (let ((th (cdr thread)))
6122 (if (memq (mail-header-number (caar th))
6123 gnus-newsgroup-limit)
6124 (setq thread (car th)
6126 (setq th (cdr th))))))))))
6129 (defun gnus-cut-threads (threads)
6130 "Cut off all uninteresting articles from the beginning of threads."
6131 (when (or (eq gnus-fetch-old-headers 'some)
6132 (eq gnus-fetch-old-headers 'invisible)
6133 (eq gnus-build-sparse-threads 'some)
6134 (eq gnus-build-sparse-threads 'more))
6137 (setcar th (gnus-cut-thread (car th)))
6138 (setq th (cdr th)))))
6139 ;; Remove nixed out threads.
6142 (defun gnus-summary-initial-limit (&optional show-if-empty)
6143 "Figure out what the initial limit is supposed to be on group entry.
6144 This entails weeding out unwanted dormants, low-scored articles,
6145 fetch-old-headers verbiage, and so on."
6146 ;; Most groups have nothing to remove.
6147 (if (or gnus-inhibit-limiting
6148 (and (null gnus-newsgroup-dormant)
6149 (not (eq gnus-fetch-old-headers 'some))
6150 (not (eq gnus-fetch-old-headers 'invisible))
6151 (null gnus-summary-expunge-below)
6152 (not (eq gnus-build-sparse-threads 'some))
6153 (not (eq gnus-build-sparse-threads 'more))
6154 (null gnus-thread-expunge-below)
6155 (not gnus-use-nocem)))
6157 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6158 (setq gnus-newsgroup-limit nil)
6161 (unless (car (symbol-value node))
6162 ;; These threads have no parents -- they are roots.
6163 (let ((nodes (cdr (symbol-value node)))
6166 (if (and gnus-thread-expunge-below
6167 (< (gnus-thread-total-score (car nodes))
6168 gnus-thread-expunge-below))
6169 (gnus-expunge-thread (pop nodes))
6170 (setq thread (pop nodes))
6171 (gnus-summary-limit-children thread))))))
6172 gnus-newsgroup-dependencies)
6173 ;; If this limitation resulted in an empty group, we might
6174 ;; pop the previous limit and use it instead.
6175 (when (and (not gnus-newsgroup-limit)
6177 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6178 gnus-newsgroup-limit))
6180 (defun gnus-summary-limit-children (thread)
6181 "Return 1 if this subthread is visible and 0 if it is not."
6182 ;; First we get the number of visible children to this thread. This
6183 ;; is done by recursing down the thread using this function, so this
6184 ;; will really go down to a leaf article first, before slowly
6185 ;; working its way up towards the root.
6189 (apply '+ (mapcar 'gnus-summary-limit-children
6192 (number (mail-header-number (car thread)))
6195 (not (memq number gnus-newsgroup-marked))
6197 ;; If this article is dormant and has absolutely no visible
6198 ;; children, then this article isn't visible.
6199 (and (memq number gnus-newsgroup-dormant)
6201 ;; If this is "fetch-old-headered" and there is no
6202 ;; visible children, then we don't want this article.
6203 (and (eq gnus-fetch-old-headers 'some)
6204 (gnus-summary-article-ancient-p number)
6206 ;; If this is "fetch-old-headered" and `invisible', then
6207 ;; we don't want this article.
6208 (and (eq gnus-fetch-old-headers 'invisible)
6209 (gnus-summary-article-ancient-p number))
6210 ;; If this is a sparsely inserted article with no children,
6211 ;; we don't want it.
6212 (and (eq gnus-build-sparse-threads 'some)
6213 (gnus-summary-article-sparse-p number)
6215 ;; If we use expunging, and this article is really
6216 ;; low-scored, then we don't want this article.
6217 (when (and gnus-summary-expunge-below
6219 (or (cdr (assq number gnus-newsgroup-scored))
6220 gnus-summary-default-score))
6221 gnus-summary-expunge-below))
6222 ;; We increase the expunge-tally here, but that has
6223 ;; nothing to do with the limits, really.
6224 (incf gnus-newsgroup-expunged-tally)
6225 ;; We also mark as read here, if that's wanted.
6226 (when (and gnus-summary-mark-below
6227 (< score gnus-summary-mark-below))
6228 (setq gnus-newsgroup-unreads
6229 (delq number gnus-newsgroup-unreads))
6230 (if gnus-newsgroup-auto-expire
6231 (push number gnus-newsgroup-expirable)
6232 (push (cons number gnus-low-score-mark)
6233 gnus-newsgroup-reads)))
6235 ;; Check NoCeM things.
6236 (if (and gnus-use-nocem
6237 (gnus-nocem-unwanted-article-p
6238 (mail-header-id (car thread))))
6240 (setq gnus-newsgroup-unreads
6241 (delq number gnus-newsgroup-unreads))
6243 ;; Nope, invisible article.
6245 ;; Ok, this article is to be visible, so we add it to the limit
6247 (push number gnus-newsgroup-limit)
6250 (defun gnus-expunge-thread (thread)
6251 "Mark all articles in THREAD as read."
6252 (let* ((number (mail-header-number (car thread))))
6253 (incf gnus-newsgroup-expunged-tally)
6254 ;; We also mark as read here, if that's wanted.
6255 (setq gnus-newsgroup-unreads
6256 (delq number gnus-newsgroup-unreads))
6257 (if gnus-newsgroup-auto-expire
6258 (push number gnus-newsgroup-expirable)
6259 (push (cons number gnus-low-score-mark)
6260 gnus-newsgroup-reads)))
6261 ;; Go recursively through all subthreads.
6262 (mapcar 'gnus-expunge-thread (cdr thread)))
6264 ;; Summary article oriented commands
6266 (defun gnus-summary-refer-parent-article (n)
6267 "Refer parent article N times.
6268 If N is negative, go to ancestor -N instead.
6269 The difference between N and the number of articles fetched is returned."
6273 (when (not (natnump n))
6278 (setq header (gnus-summary-article-header))
6279 (if (and (eq (mail-header-number header)
6280 (cdr gnus-article-current))
6281 (equal gnus-newsgroup-name
6282 (car gnus-article-current)))
6283 ;; If we try to find the parent of the currently
6284 ;; displayed article, then we take a look at the actual
6285 ;; References header, since this is slightly more
6286 ;; reliable than the References field we got from the
6289 (set-buffer gnus-original-article-buffer)
6290 (nnheader-narrow-to-headers)
6291 (unless (setq ref (message-fetch-field "references"))
6292 (setq ref (message-fetch-field "in-reply-to")))
6295 ;; It's not the current article, so we take a bet on
6296 ;; the value we got from the server.
6297 (mail-header-references header)))
6299 (not (equal ref "")))
6300 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6301 (gnus-message 1 "Couldn't find parent"))
6302 (gnus-message 1 "No references in article %d"
6303 (gnus-summary-article-number))
6306 (gnus-summary-position-point)
6309 (defun gnus-summary-refer-references ()
6310 "Fetch all articles mentioned in the References header.
6311 Return the number of articles fetched."
6313 (let ((ref (mail-header-references (gnus-summary-article-header)))
6314 (current (gnus-summary-article-number))
6318 (error "No References in the current article")
6319 ;; For each Message-ID in the References header...
6320 (while (string-match "<[^>]*>" ref)
6322 ;; ... fetch that article.
6323 (gnus-summary-refer-article
6324 (prog1 (match-string 0 ref)
6325 (setq ref (substring ref (match-end 0))))))
6326 (gnus-summary-goto-subject current)
6327 (gnus-summary-position-point)
6330 (defun gnus-summary-refer-thread (&optional limit)
6331 "Fetch all articles in the current thread.
6332 If LIMIT (the numerical prefix), fetch that many old headers instead
6333 of what's specified by the `gnus-refer-thread-limit' variable."
6335 (let ((id (mail-header-id (gnus-summary-article-header)))
6336 (limit (if limit (prefix-numeric-value limit)
6337 gnus-refer-thread-limit))
6339 ;; We want to fetch LIMIT *old* headers, but we also have to
6340 ;; re-fetch all the headers in the current buffer, because many of
6341 ;; them may be undisplayed. So we adjust LIMIT.
6342 (when (numberp limit)
6343 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6344 (unless (eq gnus-fetch-old-headers 'invisible)
6345 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6346 ;; Retrieve the headers and read them in.
6347 (if (eq (gnus-retrieve-headers
6348 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6350 (gnus-build-all-threads)
6351 (error "Can't fetch thread from backends that don't support NOV"))
6352 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6353 (gnus-summary-limit-include-thread id)))
6355 (defun gnus-summary-refer-article (message-id &optional arg)
6356 "Fetch an article specified by MESSAGE-ID.
6357 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6358 or `gnus-select-method', no matter what backend the article comes from."
6359 (interactive "sMessage-ID: \nP")
6360 (when (and (stringp message-id)
6361 (not (zerop (length message-id))))
6362 ;; Construct the correct Message-ID if necessary.
6363 ;; Suggested by tale@pawl.rpi.edu.
6364 (unless (string-match "^<" message-id)
6365 (setq message-id (concat "<" message-id)))
6366 (unless (string-match ">$" message-id)
6367 (setq message-id (concat message-id ">")))
6368 (let* ((header (gnus-id-to-header message-id))
6370 (gnus-summary-article-sparse-p
6371 (mail-header-number header))
6372 (memq (mail-header-number header)
6373 gnus-newsgroup-limit)))
6376 ;; If the article is present in the buffer we just go to it.
6378 (or (not (gnus-summary-article-sparse-p
6379 (mail-header-number header)))
6382 (gnus-summary-goto-article
6383 (mail-header-number header) nil t)
6385 (gnus-summary-update-article (mail-header-number header)))))
6387 ;; We fetch the article
6388 (let ((gnus-override-method
6389 (cond ((gnus-news-group-p gnus-newsgroup-name)
6390 gnus-refer-article-method)
6392 (or gnus-refer-article-method gnus-select-method))
6395 ;; Start the special refer-article method, if necessary.
6396 (when (and gnus-refer-article-method
6397 (gnus-news-group-p gnus-newsgroup-name))
6398 (gnus-check-server gnus-refer-article-method))
6399 ;; Fetch the header, and display the article.
6400 (if (setq number (gnus-summary-insert-subject message-id))
6401 (gnus-summary-select-article nil nil nil number)
6402 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6404 (defun gnus-summary-enter-digest-group (&optional force)
6405 "Enter an nndoc group based on the current article.
6406 If FORCE, force a digest interpretation. If not, try
6407 to guess what the document format is."
6409 (let ((conf gnus-current-window-configuration))
6411 (gnus-summary-select-article))
6412 (setq gnus-current-window-configuration conf)
6413 (let* ((name (format "%s-%d"
6414 (gnus-group-prefixed-name
6415 gnus-newsgroup-name (list 'nndoc ""))
6417 (set-buffer gnus-summary-buffer)
6418 gnus-current-article)))
6419 (ogroup gnus-newsgroup-name)
6420 (params (append (gnus-info-params (gnus-get-info ogroup))
6421 (list (cons 'to-group ogroup))
6422 (list (cons 'save-article-group ogroup))))
6423 (case-fold-search t)
6424 (buf (current-buffer))
6427 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6428 (insert-buffer-substring gnus-original-article-buffer)
6429 ;; Remove lines that may lead nndoc to misinterpret the
6432 (goto-char (point-min))
6433 (or (search-forward "\n\n" nil t) (point)))
6434 (goto-char (point-min))
6435 (delete-matching-lines "^\\(Path\\):\\|^From ")
6438 (if (gnus-group-read-ephemeral-group
6439 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6441 ,(if force 'digest 'guess))) t)
6442 ;; Make all postings to this group go to the parent group.
6443 (nconc (gnus-info-params (gnus-get-info name))
6445 ;; Couldn't select this doc group.
6446 (switch-to-buffer buf)
6447 (gnus-set-global-variables)
6448 (gnus-configure-windows 'summary)
6449 (gnus-message 3 "Article couldn't be entered?"))
6450 (kill-buffer dig)))))
6452 (defun gnus-summary-read-document (n)
6453 "Open a new group based on the current article(s).
6454 This will allow you to read digests and other similar
6455 documents as newsgroups.
6456 Obeys the standard process/prefix convention."
6458 (let* ((articles (gnus-summary-work-articles n))
6459 (ogroup gnus-newsgroup-name)
6460 (params (append (gnus-info-params (gnus-get-info ogroup))
6461 (list (cons 'to-group ogroup))))
6462 article group egroup groups vgroup)
6463 (while (setq article (pop articles))
6464 (setq group (format "%s-%d" gnus-newsgroup-name article))
6465 (gnus-summary-remove-process-mark article)
6466 (when (gnus-summary-display-article article)
6468 (nnheader-temp-write nil
6469 (insert-buffer-substring gnus-original-article-buffer)
6470 ;; Remove some headers that may lead nndoc to make
6472 (message-narrow-to-head)
6473 (goto-char (point-min))
6474 (delete-matching-lines "^\\(Path\\):\\|^From ")
6477 (gnus-group-read-ephemeral-group
6478 group `(nndoc ,group (nndoc-address ,(current-buffer))
6479 (nndoc-article-type guess))
6482 ;; Make all postings to this group go to the parent group.
6483 (nconc (gnus-info-params (gnus-get-info egroup))
6485 (push egroup groups))
6486 ;; Couldn't select this doc group.
6487 (gnus-error 3 "Article couldn't be entered"))))))
6488 ;; Now we have selected all the documents.
6491 (error "None of the articles could be interpreted as documents"))
6492 ((gnus-group-read-ephemeral-group
6493 (setq vgroup (format
6494 "nnvirtual:%s-%s" gnus-newsgroup-name
6495 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6496 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6498 (cons (current-buffer) 'summary)))
6500 (error "Couldn't select virtual nndoc group")))))
6502 (defun gnus-summary-isearch-article (&optional regexp-p)
6503 "Do incremental search forward on the current article.
6504 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6506 (gnus-summary-select-article)
6507 (gnus-configure-windows 'article)
6508 (gnus-eval-in-buffer-window gnus-article-buffer
6511 (isearch-forward regexp-p))))
6513 (defun gnus-summary-search-article-forward (regexp &optional backward)
6514 "Search for an article containing REGEXP forward.
6515 If BACKWARD, search backward instead."
6518 (format "Search article %s (regexp%s): "
6519 (if current-prefix-arg "backward" "forward")
6520 (if gnus-last-search-regexp
6521 (concat ", default " gnus-last-search-regexp)
6523 current-prefix-arg))
6524 (if (string-equal regexp "")
6525 (setq regexp (or gnus-last-search-regexp ""))
6526 (setq gnus-last-search-regexp regexp))
6527 (if (gnus-summary-search-article regexp backward)
6528 (gnus-summary-show-thread)
6529 (error "Search failed: \"%s\"" regexp)))
6531 (defun gnus-summary-search-article-backward (regexp)
6532 "Search for an article containing REGEXP backward."
6535 (format "Search article backward (regexp%s): "
6536 (if gnus-last-search-regexp
6537 (concat ", default " gnus-last-search-regexp)
6539 (gnus-summary-search-article-forward regexp 'backward))
6541 (defun gnus-summary-search-article (regexp &optional backward)
6542 "Search for an article containing REGEXP.
6543 Optional argument BACKWARD means do search for backward.
6544 `gnus-select-article-hook' is not called during the search."
6545 ;; We have to require this here to make sure that the following
6546 ;; dynamic binding isn't shadowed by autoloading.
6547 (require 'gnus-async)
6548 (let ((gnus-select-article-hook nil) ;Disable hook.
6549 (gnus-article-display-hook nil)
6550 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6551 (gnus-use-article-prefetch nil)
6552 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6553 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6554 (sum (current-buffer))
6557 (gnus-save-hidden-threads
6558 (gnus-summary-select-article)
6559 (set-buffer gnus-article-buffer)
6563 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6565 (re-search-backward regexp nil t)
6566 (re-search-forward regexp nil t))
6567 ;; We found the regexp.
6572 (get-buffer-window (current-buffer))
6576 (setq point (point)))
6577 ;; We didn't find it, so we go to the next article.
6580 (while (eq found 'not)
6581 (if (not (if backward (gnus-summary-find-prev)
6582 (gnus-summary-find-next)))
6583 ;; No more articles.
6585 ;; Select the next article and adjust point.
6586 (unless (gnus-summary-article-sparse-p
6587 (gnus-summary-article-number))
6589 (gnus-summary-select-article)
6590 (set-buffer gnus-article-buffer)
6592 (goto-char (if backward (point-max) (point-min))))))))
6593 (gnus-message 7 ""))
6594 ;; Return whether we found the regexp.
6595 (when (eq found 'found)
6597 (gnus-summary-show-thread)
6598 (gnus-summary-goto-subject gnus-current-article)
6599 (gnus-summary-position-point)
6602 (defun gnus-summary-find-matching (header regexp &optional backward unread
6604 "Return a list of all articles that match REGEXP on HEADER.
6605 The search stars on the current article and goes forwards unless
6606 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6607 If UNREAD is non-nil, only unread articles will
6608 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6609 in the comparisons."
6610 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6611 (gnus-data-find-list
6612 (gnus-summary-article-number) (gnus-data-list backward))))
6613 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6614 (case-fold-search (not not-case-fold))
6616 (unless (fboundp (intern (concat "mail-header-" header)))
6617 (error "%s is not a valid header" header))
6620 (and (or (not unread) ; We want all articles...
6621 (gnus-data-unread-p d)) ; Or just unreads.
6622 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6623 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6624 (push (gnus-data-number d) articles)) ; Success!
6625 (setq data (cdr data)))
6626 (nreverse articles)))
6628 (defun gnus-summary-execute-command (header regexp command &optional backward)
6629 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6630 If HEADER is an empty string (or nil), the match is done on the entire
6631 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6633 (list (let ((completion-ignore-case t))
6636 (mapcar (lambda (string) (list string))
6637 '("Number" "Subject" "From" "Lines" "Date"
6638 "Message-ID" "Xref" "References" "Body"))
6639 nil 'require-match))
6640 (read-string "Regexp: ")
6641 (read-key-sequence "Command: ")
6642 current-prefix-arg))
6643 (when (equal header "Body")
6645 ;; Hidden thread subtrees must be searched as well.
6646 (gnus-summary-show-all-threads)
6647 ;; We don't want to change current point nor window configuration.
6649 (save-window-excursion
6650 (gnus-message 6 "Executing %s..." (key-description command))
6651 ;; We'd like to execute COMMAND interactively so as to give arguments.
6652 (gnus-execute header regexp
6653 `(call-interactively ',(key-binding command))
6655 (gnus-message 6 "Executing %s...done" (key-description command)))))
6657 (defun gnus-summary-beginning-of-article ()
6658 "Scroll the article back to the beginning."
6660 (gnus-summary-select-article)
6661 (gnus-configure-windows 'article)
6662 (gnus-eval-in-buffer-window gnus-article-buffer
6664 (goto-char (point-min))
6665 (when gnus-page-broken
6666 (gnus-narrow-to-page))))
6668 (defun gnus-summary-end-of-article ()
6669 "Scroll to the end of the article."
6671 (gnus-summary-select-article)
6672 (gnus-configure-windows 'article)
6673 (gnus-eval-in-buffer-window gnus-article-buffer
6675 (goto-char (point-max))
6677 (when gnus-page-broken
6678 (gnus-narrow-to-page))))
6680 (defun gnus-summary-print-article (&optional filename n)
6681 "Generate and print a PostScript image of the N next (mail) articles.
6683 If N is negative, print the N previous articles. If N is nil and articles
6684 have been marked with the process mark, print these instead.
6686 If the optional second argument FILENAME is nil, send the image to the
6687 printer. If FILENAME is a string, save the PostScript image in a file with
6688 that name. If FILENAME is a number, prompt the user for the name of the file
6690 (interactive (list (ps-print-preprint current-prefix-arg)
6691 current-prefix-arg))
6692 (dolist (nbr (gnus-summary-work-articles n))
6693 (gnus-summary-select-article 'all nil 'pseudo nbr)
6694 (gnus-eval-in-buffer-window gnus-article-buffer
6695 (let ((buffer (generate-new-buffer " *print*")))
6698 (copy-to-buffer buffer (point-min) (point-max))
6700 (gnus-article-delete-invisible-text)
6701 (let ((ps-left-header
6704 (mail-header-subject gnus-current-headers) ")")
6706 (mail-header-from gnus-current-headers) ")")))
6709 "/pagenumberstring load"
6711 (mail-header-date gnus-current-headers) ")"))))
6712 (run-hooks 'gnus-ps-print-hook)
6713 (ps-print-buffer-with-faces filename)))
6714 (kill-buffer buffer))))))
6716 (defun gnus-summary-show-article (&optional arg)
6717 "Force re-fetching of the current article.
6718 If ARG (the prefix) is non-nil, show the raw article without any
6719 article massaging functions being run."
6722 ;; Select the article the normal way.
6723 (gnus-summary-select-article nil 'force)
6724 ;; Bind the article treatment functions to nil.
6725 (let ((gnus-have-all-headers t)
6726 gnus-article-display-hook
6727 gnus-article-prepare-hook
6731 (gnus-summary-select-article nil 'force)))
6732 (gnus-summary-goto-subject gnus-current-article)
6733 (gnus-summary-position-point))
6735 (defun gnus-summary-verbose-headers (&optional arg)
6736 "Toggle permanent full header display.
6737 If ARG is a positive number, turn header display on.
6738 If ARG is a negative number, turn header display off."
6740 (setq gnus-show-all-headers
6741 (cond ((or (not (numberp arg))
6743 (not gnus-show-all-headers))
6746 (gnus-summary-show-article))
6748 (defun gnus-summary-toggle-header (&optional arg)
6749 "Show the headers if they are hidden, or hide them if they are shown.
6750 If ARG is a positive number, show the entire header.
6751 If ARG is a negative number, hide the unwanted header lines."
6754 (set-buffer gnus-article-buffer)
6755 (let* ((buffer-read-only nil)
6756 (inhibit-point-motion-hooks t)
6757 (hidden (text-property-any
6758 (goto-char (point-min)) (search-forward "\n\n")
6761 (goto-char (point-min))
6762 (when (search-forward "\n\n" nil t)
6763 (delete-region (point-min) (1- (point))))
6764 (goto-char (point-min))
6766 (set-buffer gnus-original-article-buffer)
6767 (goto-char (point-min))
6768 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6769 (insert-buffer-substring gnus-original-article-buffer 1 e)
6770 (let ((article-inhibit-hiding t))
6771 (run-hooks 'gnus-article-display-hook))
6772 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6773 (gnus-article-hide-headers)))))
6775 (defun gnus-summary-show-all-headers ()
6776 "Make all header lines visible."
6778 (gnus-article-show-all-headers))
6780 (defun gnus-summary-toggle-mime (&optional arg)
6781 "Toggle MIME processing.
6782 If ARG is a positive number, turn MIME processing on."
6784 (setq gnus-show-mime
6785 (if (null arg) (not gnus-show-mime)
6786 (> (prefix-numeric-value arg) 0)))
6787 (gnus-summary-select-article t 'force))
6789 (defun gnus-summary-caesar-message (&optional arg)
6790 "Caesar rotate the current article by 13.
6791 The numerical prefix specifies how many places to rotate each letter
6794 (gnus-summary-select-article)
6795 (let ((mail-header-separator ""))
6796 (gnus-eval-in-buffer-window gnus-article-buffer
6799 (let ((start (window-start))
6801 (message-caesar-buffer-body arg)
6802 (set-window-start (get-buffer-window (current-buffer)) start))))))
6804 (defun gnus-summary-stop-page-breaking ()
6805 "Stop page breaking in the current article."
6807 (gnus-summary-select-article)
6808 (gnus-eval-in-buffer-window gnus-article-buffer
6810 (when (gnus-visual-p 'page-marker)
6811 (let ((buffer-read-only nil))
6812 (gnus-remove-text-with-property 'gnus-prev)
6813 (gnus-remove-text-with-property 'gnus-next)))))
6815 (defun gnus-summary-move-article (&optional n to-newsgroup
6816 select-method action)
6817 "Move the current article to a different newsgroup.
6818 If N is a positive number, move the N next articles.
6819 If N is a negative number, move the N previous articles.
6820 If N is nil and any articles have been marked with the process mark,
6821 move those articles instead.
6822 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6823 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6824 re-spool using this method.
6826 For this function to work, both the current newsgroup and the
6827 newsgroup that you want to move to have to support the `request-move'
6828 and `request-accept' functions."
6831 (setq action 'move))
6832 ;; Disable marking as read.
6833 (let (gnus-mark-article-hook)
6834 (save-window-excursion
6835 (gnus-summary-select-article)))
6836 ;; Check whether the source group supports the required functions.
6837 (cond ((and (eq action 'move)
6838 (not (gnus-check-backend-function
6839 'request-move-article gnus-newsgroup-name)))
6840 (error "The current group does not support article moving"))
6841 ((and (eq action 'crosspost)
6842 (not (gnus-check-backend-function
6843 'request-replace-article gnus-newsgroup-name)))
6844 (error "The current group does not support article editing")))
6845 (let ((articles (gnus-summary-work-articles n))
6846 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6847 (names '((move "Move" "Moving")
6848 (copy "Copy" "Copying")
6849 (crosspost "Crosspost" "Crossposting")))
6850 (copy-buf (save-excursion
6851 (nnheader-set-temp-buffer " *copy article*")))
6852 art-group to-method new-xref article to-groups)
6853 (unless (assq action names)
6854 (error "Unknown action %s" action))
6855 ;; Read the newsgroup name.
6856 (when (and (not to-newsgroup)
6857 (not select-method))
6859 (gnus-read-move-group-name
6860 (cadr (assq action names))
6861 (symbol-value (intern (format "gnus-current-%s-group" action)))
6863 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6864 (setq to-method (or select-method
6865 (gnus-group-name-to-method to-newsgroup)))
6866 ;; Check the method we are to move this article to...
6867 (unless (gnus-check-backend-function
6868 'request-accept-article (car to-method))
6869 (error "%s does not support article copying" (car to-method)))
6870 (unless (gnus-check-server to-method)
6871 (error "Can't open server %s" (car to-method)))
6872 (gnus-message 6 "%s to %s: %s..."
6873 (caddr (assq action names))
6874 (or (car select-method) to-newsgroup) articles)
6876 (setq article (pop articles))
6880 ;; Move the article.
6882 ;; Remove this article from future suppression.
6883 (gnus-dup-unsuppress-article article)
6884 (gnus-request-move-article
6885 article ; Article to move
6886 gnus-newsgroup-name ; From newsgroup
6887 (nth 1 (gnus-find-method-for-group
6888 gnus-newsgroup-name)) ; Server
6889 (list 'gnus-request-accept-article
6890 to-newsgroup (list 'quote select-method)
6891 (not articles)) ; Accept form
6892 (not articles))) ; Only save nov last time
6893 ;; Copy the article.
6896 (set-buffer copy-buf)
6897 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6898 (gnus-request-accept-article
6899 to-newsgroup select-method (not articles)))))
6900 ;; Crosspost the article.
6901 ((eq action 'crosspost)
6902 (let ((xref (message-tokenize-header
6903 (mail-header-xref (gnus-summary-article-header article))
6905 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6908 (setq xref (list (system-name))))
6911 (mapconcat 'identity
6912 (delete "Xref:" (delete new-xref xref))
6916 (set-buffer copy-buf)
6917 ;; First put the article in the destination group.
6918 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6919 (when (consp (setq art-group
6920 (gnus-request-accept-article
6921 to-newsgroup select-method (not articles))))
6922 (setq new-xref (concat new-xref " " (car art-group)
6923 ":" (cdr art-group)))
6924 ;; Now we have the new Xrefs header, so we insert
6925 ;; it and replace the new article.
6926 (nnheader-replace-header "Xref" new-xref)
6927 (gnus-request-replace-article
6928 (cdr art-group) to-newsgroup (current-buffer))
6932 (gnus-message 1 "Couldn't %s article %s"
6933 (cadr (assq action names)) article))
6934 ((and (eq art-group 'junk)
6936 (gnus-summary-mark-article article gnus-canceled-mark)
6937 (gnus-message 4 "Deleted article %s" article))
6941 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6943 (gnus-group-prefixed-name
6946 (gnus-find-method-for-group to-newsgroup)))
6947 gnus-newsrc-hashtb)))
6948 (info (nth 2 entry))
6949 (to-group (gnus-info-group info)))
6950 ;; Update the group that has been moved to.
6952 (memq action '(move copy)))
6953 (unless (member to-group to-groups)
6954 (push to-group to-groups))
6956 (unless (memq article gnus-newsgroup-unreads)
6958 info (gnus-add-to-range (gnus-info-read info)
6959 (list (cdr art-group)))))
6961 ;; Copy any marks over to the new group.
6962 (let ((marks gnus-article-mark-lists)
6963 (to-article (cdr art-group)))
6965 ;; See whether the article is to be put in the cache.
6966 (when gnus-use-cache
6967 (gnus-cache-possibly-enter-article
6969 (let ((header (copy-sequence
6970 (gnus-summary-article-header article))))
6971 (mail-header-set-number header to-article)
6973 (memq article gnus-newsgroup-marked)
6974 (memq article gnus-newsgroup-dormant)
6975 (memq article gnus-newsgroup-unreads)))
6977 (when (and (equal to-group gnus-newsgroup-name)
6978 (not (memq article gnus-newsgroup-unreads)))
6979 ;; Mark this article as read in this group.
6980 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6981 (setcdr (gnus-active to-group) to-article)
6982 (setcdr gnus-newsgroup-active to-article))
6985 (when (memq article (symbol-value
6986 (intern (format "gnus-newsgroup-%s"
6988 ;; If the other group is the same as this group,
6989 ;; then we have to add the mark to the list.
6990 (when (equal to-group gnus-newsgroup-name)
6991 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6994 (intern (format "gnus-newsgroup-%s"
6996 ;; Copy the marks to other group.
6997 (gnus-add-marked-articles
6998 to-group (cdar marks) (list to-article) info))
6999 (setq marks (cdr marks)))
7002 (concat "(gnus-group-set-info '"
7003 (gnus-prin1-to-string (gnus-get-info to-group))
7006 ;; Update the Xref header in this article to point to
7007 ;; the new crossposted article we have just created.
7008 (when (eq action 'crosspost)
7010 (set-buffer copy-buf)
7011 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7012 (nnheader-replace-header "Xref" new-xref)
7013 (gnus-request-replace-article
7014 article gnus-newsgroup-name (current-buffer)))))
7016 (gnus-summary-goto-subject article)
7017 (when (eq action 'move)
7018 (gnus-summary-mark-article article gnus-canceled-mark))))
7019 (gnus-summary-remove-process-mark article))
7020 ;; Re-activate all groups that have been moved to.
7023 (set-buffer gnus-group-buffer)
7024 (when (gnus-group-goto-group (car to-groups) t)
7025 (gnus-group-get-new-news-this-group 1 t))
7028 (gnus-kill-buffer copy-buf)
7029 (gnus-summary-position-point)
7030 (gnus-set-mode-line 'summary)))
7032 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7033 "Move the current article to a different newsgroup.
7034 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7035 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7036 re-spool using this method."
7038 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7040 (defun gnus-summary-crosspost-article (&optional n)
7041 "Crosspost the current article to some other group."
7043 (gnus-summary-move-article n nil nil 'crosspost))
7045 (defcustom gnus-summary-respool-default-method nil
7046 "Default method for respooling an article.
7047 If nil, use to the current newsgroup method."
7048 :type `(choice (gnus-select-method :value (nnml ""))
7050 :group 'gnus-summary-mail)
7052 (defun gnus-summary-respool-article (&optional n method)
7053 "Respool the current article.
7054 The article will be squeezed through the mail spooling process again,
7055 which means that it will be put in some mail newsgroup or other
7056 depending on `nnmail-split-methods'.
7057 If N is a positive number, respool the N next articles.
7058 If N is a negative number, respool the N previous articles.
7059 If N is nil and any articles have been marked with the process mark,
7060 respool those articles instead.
7062 Respooling can be done both from mail groups and \"real\" newsgroups.
7063 In the former case, the articles in question will be moved from the
7064 current group into whatever groups they are destined to. In the
7065 latter case, they will be copied into the relevant groups."
7067 (list current-prefix-arg
7068 (let* ((methods (gnus-methods-using 'respool))
7070 (symbol-name (or gnus-summary-respool-default-method
7071 (car (gnus-find-method-for-group
7072 gnus-newsgroup-name)))))
7074 (gnus-completing-read
7075 methname "What backend do you want to use when respooling?"
7076 methods nil t nil 'gnus-mail-method-history))
7079 ((zerop (length (setq ms (gnus-servers-using-backend
7081 (list (intern method) ""))
7085 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7086 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7089 (error "No method given for respooling"))
7090 (if (assoc (symbol-name
7091 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7092 (gnus-methods-using 'respool))
7093 (gnus-summary-move-article n nil method)
7094 (gnus-summary-copy-article n nil method)))
7096 (defun gnus-summary-import-article (file)
7097 "Import a random file into a mail newsgroup."
7098 (interactive "fImport file: ")
7099 (let ((group gnus-newsgroup-name)
7100 (now (current-time))
7102 (unless (gnus-check-backend-function 'request-accept-article group)
7103 (error "%s does not support article importing" group))
7104 (or (file-readable-p file)
7105 (not (file-regular-p file))
7106 (error "Can't read %s" file))
7108 (set-buffer (get-buffer-create " *import file*"))
7109 (buffer-disable-undo (current-buffer))
7111 (insert-file-contents file)
7112 (goto-char (point-min))
7113 (unless (nnheader-article-p)
7114 ;; This doesn't look like an article, so we fudge some headers.
7115 (setq atts (file-attributes file)
7116 lines (count-lines (point-min) (point-max)))
7117 (insert "From: " (read-string "From: ") "\n"
7118 "Subject: " (read-string "Subject: ") "\n"
7119 "Date: " (timezone-make-date-arpa-standard
7120 (current-time-string (nth 5 atts))
7121 (current-time-zone now)
7122 (current-time-zone now))
7124 "Message-ID: " (message-make-message-id) "\n"
7125 "Lines: " (int-to-string lines) "\n"
7126 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7127 (gnus-request-accept-article group nil t)
7128 (kill-buffer (current-buffer)))))
7130 (defun gnus-summary-article-posted-p ()
7131 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7132 This will be the case if the article has both been mailed and posted."
7134 (let ((id (mail-header-references (gnus-summary-article-header)))
7135 (gnus-override-method
7136 (or gnus-refer-article-method gnus-select-method)))
7137 (if (gnus-request-head id "")
7138 (gnus-message 2 "The current message was found on %s"
7139 gnus-override-method)
7140 (gnus-message 2 "The current message couldn't be found on %s"
7141 gnus-override-method)
7144 (defun gnus-summary-expire-articles (&optional now)
7145 "Expire all articles that are marked as expirable in the current group."
7147 (when (gnus-check-backend-function
7148 'request-expire-articles gnus-newsgroup-name)
7149 ;; This backend supports expiry.
7150 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7151 (expirable (if total
7153 ;; We need to update the info for
7154 ;; this group for `gnus-list-of-read-articles'
7155 ;; to give us the right answer.
7156 (run-hooks 'gnus-exit-group-hook)
7157 (gnus-summary-update-info)
7158 (gnus-list-of-read-articles gnus-newsgroup-name))
7159 (setq gnus-newsgroup-expirable
7160 (sort gnus-newsgroup-expirable '<))))
7161 (expiry-wait (if now 'immediate
7162 (gnus-group-find-parameter
7163 gnus-newsgroup-name 'expiry-wait)))
7166 ;; There are expirable articles in this group, so we run them
7167 ;; through the expiry process.
7168 (gnus-message 6 "Expiring articles...")
7169 ;; The list of articles that weren't expired is returned.
7171 (let ((nnmail-expiry-wait-function nil)
7172 (nnmail-expiry-wait expiry-wait))
7173 (setq es (gnus-request-expire-articles
7174 expirable gnus-newsgroup-name)))
7175 (setq es (gnus-request-expire-articles
7176 expirable gnus-newsgroup-name)))
7178 (setq gnus-newsgroup-expirable es))
7179 ;; We go through the old list of expirable, and mark all
7180 ;; really expired articles as nonexistent.
7181 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7182 (let ((gnus-use-cache nil))
7184 (unless (memq (car expirable) es)
7185 (when (gnus-data-find (car expirable))
7186 (gnus-summary-mark-article
7187 (car expirable) gnus-canceled-mark)))
7188 (setq expirable (cdr expirable)))))
7189 (gnus-message 6 "Expiring articles...done")))))
7191 (defun gnus-summary-expire-articles-now ()
7192 "Expunge all expirable articles in the current group.
7193 This means that *all* articles that are marked as expirable will be
7194 deleted forever, right now."
7196 (or gnus-expert-user
7198 "Are you really, really, really sure you want to delete all these messages? ")
7200 (gnus-summary-expire-articles t))
7202 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7203 (defun gnus-summary-delete-article (&optional n)
7204 "Delete the N next (mail) articles.
7205 This command actually deletes articles. This is not a marking
7206 command. The article will disappear forever from your life, never to
7208 If N is negative, delete backwards.
7209 If N is nil and articles have been marked with the process mark,
7210 delete these instead."
7212 (unless (gnus-check-backend-function 'request-expire-articles
7213 gnus-newsgroup-name)
7214 (error "The current newsgroup does not support article deletion"))
7215 ;; Compute the list of articles to delete.
7216 (let ((articles (gnus-summary-work-articles n))
7218 (if (and gnus-novice-user
7219 (not (gnus-yes-or-no-p
7220 (format "Do you really want to delete %s forever? "
7221 (if (> (length articles) 1)
7222 (format "these %s articles" (length articles))
7225 ;; Delete the articles.
7226 (setq not-deleted (gnus-request-expire-articles
7227 articles gnus-newsgroup-name 'force))
7229 (gnus-summary-remove-process-mark (car articles))
7230 ;; The backend might not have been able to delete the article
7232 (unless (memq (car articles) not-deleted)
7233 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7234 (setq articles (cdr articles)))
7236 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7237 (gnus-summary-position-point)
7238 (gnus-set-mode-line 'summary)
7241 (defun gnus-summary-edit-article (&optional force)
7242 "Edit the current article.
7243 This will have permanent effect only in mail groups.
7244 If FORCE is non-nil, allow editing of articles even in read-only
7248 (set-buffer gnus-summary-buffer)
7249 (gnus-set-global-variables)
7250 (when (and (not force)
7251 (gnus-group-read-only-p))
7252 (error "The current newsgroup does not support article editing"))
7253 ;; Select article if needed.
7254 (unless (eq (gnus-summary-article-number)
7255 gnus-current-article)
7256 (gnus-summary-select-article t))
7257 (gnus-article-date-original)
7258 (gnus-article-edit-article
7259 `(lambda (no-highlight)
7260 (gnus-summary-edit-article-done
7261 ,(or (mail-header-references gnus-current-headers) "")
7262 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7264 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7266 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7268 "Make edits to the current article permanent."
7270 ;; Replace the article.
7271 (if (and (not read-only)
7272 (not (gnus-request-replace-article
7273 (cdr gnus-article-current) (car gnus-article-current)
7275 (error "Couldn't replace article")
7276 ;; Update the summary buffer.
7278 (equal (message-tokenize-header references " ")
7279 (message-tokenize-header
7280 (or (message-fetch-field "references") "") " ")))
7281 ;; We only have to update this line.
7284 (message-narrow-to-head)
7285 (let ((head (buffer-string))
7287 (nnheader-temp-write nil
7288 (insert (format "211 %d Article retrieved.\n"
7289 (cdr gnus-article-current)))
7292 (let ((nntp-server-buffer (current-buffer)))
7293 (setq header (car (gnus-get-newsgroup-headers
7295 (set-buffer gnus-summary-buffer)
7296 gnus-newsgroup-dependencies)
7299 (set-buffer gnus-summary-buffer)
7300 (gnus-data-set-header
7301 (gnus-data-find (cdr gnus-article-current))
7303 (gnus-summary-update-article-line
7304 (cdr gnus-article-current) header))))))
7306 (set-buffer (or buffer gnus-summary-buffer))
7307 (gnus-summary-update-article (cdr gnus-article-current)))
7308 ;; Prettify the article buffer again.
7309 (unless no-highlight
7311 (set-buffer gnus-article-buffer)
7312 (run-hooks 'gnus-article-display-hook)
7313 (set-buffer gnus-original-article-buffer)
7314 (gnus-request-article
7315 (cdr gnus-article-current)
7316 (car gnus-article-current) (current-buffer))))
7317 ;; Prettify the summary buffer line.
7318 (when (gnus-visual-p 'summary-highlight 'highlight)
7319 (run-hooks 'gnus-visual-mark-article-hook))))
7321 (defun gnus-summary-edit-wash (key)
7322 "Perform editing command in the article buffer."
7326 (message "%s" (concat (this-command-keys) "- "))
7329 (gnus-summary-edit-article)
7330 (execute-kbd-macro (concat (this-command-keys) key))
7331 (gnus-article-edit-done))
7335 (defun gnus-summary-respool-query (&optional silent)
7336 "Query where the respool algorithm would put this article."
7338 (let (gnus-mark-article-hook)
7339 (gnus-summary-select-article)
7341 (set-buffer gnus-original-article-buffer)
7343 (message-narrow-to-head)
7344 (let ((groups (nnmail-article-group 'identity)))
7347 (message "This message would go to %s"
7348 (mapconcat 'car groups ", "))
7349 (message "This message would go to no groups"))
7352 ;; Summary marking commands.
7354 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7355 "Mark articles which has the same subject as read, and then select the next.
7356 If UNMARK is positive, remove any kind of mark.
7357 If UNMARK is negative, tick articles."
7360 (setq unmark (prefix-numeric-value unmark)))
7362 (gnus-summary-mark-same-subject
7363 (gnus-summary-article-subject) unmark)))
7364 ;; Select next unread article. If auto-select-same mode, should
7365 ;; select the first unread article.
7366 (gnus-summary-next-article t (and gnus-auto-select-same
7367 (gnus-summary-article-subject)))
7368 (gnus-message 7 "%d article%s marked as %s"
7369 count (if (= count 1) " is" "s are")
7370 (if unmark "unread" "read"))))
7372 (defun gnus-summary-kill-same-subject (&optional unmark)
7373 "Mark articles which has the same subject as read.
7374 If UNMARK is positive, remove any kind of mark.
7375 If UNMARK is negative, tick articles."
7378 (setq unmark (prefix-numeric-value unmark)))
7380 (gnus-summary-mark-same-subject
7381 (gnus-summary-article-subject) unmark)))
7382 ;; If marked as read, go to next unread subject.
7384 ;; Go to next unread subject.
7385 (gnus-summary-next-subject 1 t))
7386 (gnus-message 7 "%d articles are marked as %s"
7387 count (if unmark "unread" "read"))))
7389 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7390 "Mark articles with same SUBJECT as read, and return marked number.
7391 If optional argument UNMARK is positive, remove any kinds of marks.
7392 If optional argument UNMARK is negative, mark articles as unread instead."
7396 ((null unmark) ; Mark as read.
7399 (gnus-summary-mark-article-as-read gnus-killed-mark)
7400 (gnus-summary-show-thread) t)
7401 (gnus-summary-find-subject subject))
7402 (setq count (1+ count))))
7403 ((> unmark 0) ; Tick.
7406 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7407 (gnus-summary-show-thread) t)
7408 (gnus-summary-find-subject subject))
7409 (setq count (1+ count))))
7410 (t ; Mark as unread.
7413 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7414 (gnus-summary-show-thread) t)
7415 (gnus-summary-find-subject subject))
7416 (setq count (1+ count)))))
7417 (gnus-set-mode-line 'summary)
7418 ;; Return the number of marked articles.
7421 (defun gnus-summary-mark-as-processable (n &optional unmark)
7422 "Set the process mark on the next N articles.
7423 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7424 the process mark instead. The difference between N and the actual
7425 number of articles marked is returned."
7427 (let ((backward (< n 0))
7432 (gnus-summary-remove-process-mark
7433 (gnus-summary-article-number))
7434 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7435 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7438 (gnus-message 7 "No more articles"))
7439 (gnus-summary-recenter)
7440 (gnus-summary-position-point)
7443 (defun gnus-summary-unmark-as-processable (n)
7444 "Remove the process mark from the next N articles.
7445 If N is negative, unmark backward instead. The difference between N and
7446 the actual number of articles unmarked is returned."
7448 (gnus-summary-mark-as-processable n t))
7450 (defun gnus-summary-unmark-all-processable ()
7451 "Remove the process mark from all articles."
7454 (while gnus-newsgroup-processable
7455 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7456 (gnus-summary-position-point))
7458 (defun gnus-summary-mark-as-expirable (n)
7459 "Mark N articles forward as expirable.
7460 If N is negative, mark backward instead. The difference between N and
7461 the actual number of articles marked is returned."
7463 (gnus-summary-mark-forward n gnus-expirable-mark))
7465 (defun gnus-summary-mark-article-as-replied (article)
7466 "Mark ARTICLE replied and update the summary line."
7467 (push article gnus-newsgroup-replied)
7468 (let ((buffer-read-only nil))
7469 (when (gnus-summary-goto-subject article)
7470 (gnus-summary-update-secondary-mark article))))
7472 (defun gnus-summary-set-bookmark (article)
7473 "Set a bookmark in current article."
7474 (interactive (list (gnus-summary-article-number)))
7475 (when (or (not (get-buffer gnus-article-buffer))
7476 (not gnus-current-article)
7477 (not gnus-article-current)
7478 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7479 (error "No current article selected"))
7480 ;; Remove old bookmark, if one exists.
7481 (let ((old (assq article gnus-newsgroup-bookmarks)))
7483 (setq gnus-newsgroup-bookmarks
7484 (delq old gnus-newsgroup-bookmarks))))
7485 ;; Set the new bookmark, which is on the form
7486 ;; (article-number . line-number-in-body).
7490 (set-buffer gnus-article-buffer)
7494 (goto-char (point-min))
7495 (search-forward "\n\n" nil t)
7498 gnus-newsgroup-bookmarks)
7499 (gnus-message 6 "A bookmark has been added to the current article."))
7501 (defun gnus-summary-remove-bookmark (article)
7502 "Remove the bookmark from the current article."
7503 (interactive (list (gnus-summary-article-number)))
7504 ;; Remove old bookmark, if one exists.
7505 (let ((old (assq article gnus-newsgroup-bookmarks)))
7508 (setq gnus-newsgroup-bookmarks
7509 (delq old gnus-newsgroup-bookmarks))
7510 (gnus-message 6 "Removed bookmark."))
7511 (gnus-message 6 "No bookmark in current article."))))
7513 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7514 (defun gnus-summary-mark-as-dormant (n)
7515 "Mark N articles forward as dormant.
7516 If N is negative, mark backward instead. The difference between N and
7517 the actual number of articles marked is returned."
7519 (gnus-summary-mark-forward n gnus-dormant-mark))
7521 (defun gnus-summary-set-process-mark (article)
7522 "Set the process mark on ARTICLE and update the summary line."
7523 (setq gnus-newsgroup-processable
7525 (delq article gnus-newsgroup-processable)))
7526 (when (gnus-summary-goto-subject article)
7527 (gnus-summary-show-thread)
7528 (gnus-summary-update-secondary-mark article)))
7530 (defun gnus-summary-remove-process-mark (article)
7531 "Remove the process mark from ARTICLE and update the summary line."
7532 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7533 (when (gnus-summary-goto-subject article)
7534 (gnus-summary-show-thread)
7535 (gnus-summary-update-secondary-mark article)))
7537 (defun gnus-summary-set-saved-mark (article)
7538 "Set the process mark on ARTICLE and update the summary line."
7539 (push article gnus-newsgroup-saved)
7540 (when (gnus-summary-goto-subject article)
7541 (gnus-summary-update-secondary-mark article)))
7543 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7544 "Mark N articles as read forwards.
7545 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7546 The difference between N and the actual number of articles marked is
7549 (let ((backward (< n 0))
7550 (gnus-summary-goto-unread
7551 (and gnus-summary-goto-unread
7552 (not (eq gnus-summary-goto-unread 'never))
7553 (not (memq mark (list gnus-unread-mark
7554 gnus-ticked-mark gnus-dormant-mark)))))
7556 (mark (or mark gnus-del-mark)))
7558 (gnus-summary-mark-article nil mark no-expire)
7559 (zerop (gnus-summary-next-subject
7561 (and gnus-summary-goto-unread
7562 (not (eq gnus-summary-goto-unread 'never)))
7566 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7567 (gnus-summary-recenter)
7568 (gnus-summary-position-point)
7569 (gnus-set-mode-line 'summary)
7572 (defun gnus-summary-mark-article-as-read (mark)
7573 "Mark the current article quickly as read with MARK."
7574 (let ((article (gnus-summary-article-number)))
7575 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7576 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7577 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7578 (push (cons article mark) gnus-newsgroup-reads)
7579 ;; Possibly remove from cache, if that is used.
7580 (when gnus-use-cache
7581 (gnus-cache-enter-remove-article article))
7582 ;; Allow the backend to change the mark.
7583 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7584 ;; Check for auto-expiry.
7585 (when (and gnus-newsgroup-auto-expire
7586 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7587 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7588 (= mark gnus-ancient-mark)
7589 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7590 (= mark gnus-duplicate-mark)))
7591 (setq mark gnus-expirable-mark)
7592 (push article gnus-newsgroup-expirable))
7593 ;; Set the mark in the buffer.
7594 (gnus-summary-update-mark mark 'unread)
7597 (defun gnus-summary-mark-article-as-unread (mark)
7598 "Mark the current article quickly as unread with MARK."
7599 (let ((article (gnus-summary-article-number)))
7602 (gnus-error 1 "Can't mark negative article numbers")
7604 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7605 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7606 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7607 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7608 (cond ((= mark gnus-ticked-mark)
7609 (push article gnus-newsgroup-marked))
7610 ((= mark gnus-dormant-mark)
7611 (push article gnus-newsgroup-dormant))
7613 (push article gnus-newsgroup-unreads)))
7614 (setq gnus-newsgroup-reads
7615 (delq (assq article gnus-newsgroup-reads)
7616 gnus-newsgroup-reads))
7618 ;; See whether the article is to be put in the cache.
7620 (vectorp (gnus-summary-article-header article))
7622 (gnus-cache-possibly-enter-article
7623 gnus-newsgroup-name article
7624 (gnus-summary-article-header article)
7625 (= mark gnus-ticked-mark)
7626 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7629 (gnus-summary-update-mark mark 'unread)
7632 (defun gnus-summary-mark-article (&optional article mark no-expire)
7633 "Mark ARTICLE with MARK. MARK can be any character.
7634 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7635 `??' (dormant) and `?E' (expirable).
7636 If MARK is nil, then the default character `?D' is used.
7637 If ARTICLE is nil, then the article on the current line will be
7639 ;; The mark might be a string.
7640 (when (stringp mark)
7641 (setq mark (aref mark 0)))
7642 ;; If no mark is given, then we check auto-expiring.
7643 (and (not no-expire)
7644 gnus-newsgroup-auto-expire
7646 (and (gnus-characterp mark)
7647 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7648 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7649 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7650 (= mark gnus-duplicate-mark))))
7651 (setq mark gnus-expirable-mark))
7652 (let* ((mark (or mark gnus-del-mark))
7653 (article (or article (gnus-summary-article-number))))
7655 (error "No article on current line"))
7656 (if (not (if (or (= mark gnus-unread-mark)
7657 (= mark gnus-ticked-mark)
7658 (= mark gnus-dormant-mark))
7659 (gnus-mark-article-as-unread article mark)
7660 (gnus-mark-article-as-read article mark)))
7662 ;; See whether the article is to be put in the cache.
7664 (not (= mark gnus-canceled-mark))
7665 (vectorp (gnus-summary-article-header article))
7667 (gnus-cache-possibly-enter-article
7668 gnus-newsgroup-name article
7669 (gnus-summary-article-header article)
7670 (= mark gnus-ticked-mark)
7671 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7673 (when (gnus-summary-goto-subject article nil t)
7674 (let ((buffer-read-only nil))
7675 (gnus-summary-show-thread)
7677 (gnus-summary-update-mark mark 'unread)
7680 (defun gnus-summary-update-secondary-mark (article)
7681 "Update the secondary (read, process, cache) mark."
7682 (gnus-summary-update-mark
7683 (cond ((memq article gnus-newsgroup-processable)
7685 ((memq article gnus-newsgroup-cached)
7687 ((memq article gnus-newsgroup-replied)
7689 ((memq article gnus-newsgroup-saved)
7691 (t gnus-unread-mark))
7693 (when (gnus-visual-p 'summary-highlight 'highlight)
7694 (run-hooks 'gnus-summary-update-hook))
7697 (defun gnus-summary-update-mark (mark type)
7698 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7699 (buffer-read-only nil))
7700 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7701 (when (looking-at "\r")
7704 (<= (+ forward (point)) (point-max)))
7705 ;; Go to the right position on the line.
7706 (goto-char (+ forward (point)))
7707 ;; Replace the old mark with the new mark.
7708 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7709 ;; Optionally update the marks by some user rule.
7710 (when (eq type 'unread)
7712 (gnus-data-find (gnus-summary-article-number)) mark)
7713 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7715 (defun gnus-mark-article-as-read (article &optional mark)
7716 "Enter ARTICLE in the pertinent lists and remove it from others."
7717 ;; Make the article expirable.
7718 (let ((mark (or mark gnus-del-mark)))
7719 (if (= mark gnus-expirable-mark)
7720 (push article gnus-newsgroup-expirable)
7721 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7722 ;; Remove from unread and marked lists.
7723 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7724 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7725 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7726 (push (cons article mark) gnus-newsgroup-reads)
7727 ;; Possibly remove from cache, if that is used.
7728 (when gnus-use-cache
7729 (gnus-cache-enter-remove-article article))))
7731 (defun gnus-mark-article-as-unread (article &optional mark)
7732 "Enter ARTICLE in the pertinent lists and remove it from others."
7733 (let ((mark (or mark gnus-ticked-mark)))
7736 (gnus-error 1 "Can't mark negative article numbers")
7738 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7739 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7740 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7741 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7743 ;; Unsuppress duplicates?
7744 (when gnus-suppress-duplicates
7745 (gnus-dup-unsuppress-article article))
7747 (cond ((= mark gnus-ticked-mark)
7748 (push article gnus-newsgroup-marked))
7749 ((= mark gnus-dormant-mark)
7750 (push article gnus-newsgroup-dormant))
7752 (push article gnus-newsgroup-unreads)))
7753 (setq gnus-newsgroup-reads
7754 (delq (assq article gnus-newsgroup-reads)
7755 gnus-newsgroup-reads))
7758 (defalias 'gnus-summary-mark-as-unread-forward
7759 'gnus-summary-tick-article-forward)
7760 (make-obsolete 'gnus-summary-mark-as-unread-forward
7761 'gnus-summary-tick-article-forward)
7762 (defun gnus-summary-tick-article-forward (n)
7763 "Tick N articles forwards.
7764 If N is negative, tick backwards instead.
7765 The difference between N and the number of articles ticked is returned."
7767 (gnus-summary-mark-forward n gnus-ticked-mark))
7769 (defalias 'gnus-summary-mark-as-unread-backward
7770 'gnus-summary-tick-article-backward)
7771 (make-obsolete 'gnus-summary-mark-as-unread-backward
7772 'gnus-summary-tick-article-backward)
7773 (defun gnus-summary-tick-article-backward (n)
7774 "Tick N articles backwards.
7775 The difference between N and the number of articles ticked is returned."
7777 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7779 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7780 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7781 (defun gnus-summary-tick-article (&optional article clear-mark)
7782 "Mark current article as unread.
7783 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7784 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7786 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7789 (defun gnus-summary-mark-as-read-forward (n)
7790 "Mark N articles as read forwards.
7791 If N is negative, mark backwards instead.
7792 The difference between N and the actual number of articles marked is
7795 (gnus-summary-mark-forward n gnus-del-mark t))
7797 (defun gnus-summary-mark-as-read-backward (n)
7798 "Mark the N articles as read backwards.
7799 The difference between N and the actual number of articles marked is
7802 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7804 (defun gnus-summary-mark-as-read (&optional article mark)
7805 "Mark current article as read.
7806 ARTICLE specifies the article to be marked as read.
7807 MARK specifies a string to be inserted at the beginning of the line."
7808 (gnus-summary-mark-article article mark))
7810 (defun gnus-summary-clear-mark-forward (n)
7811 "Clear marks from N articles forward.
7812 If N is negative, clear backward instead.
7813 The difference between N and the number of marks cleared is returned."
7815 (gnus-summary-mark-forward n gnus-unread-mark))
7817 (defun gnus-summary-clear-mark-backward (n)
7818 "Clear marks from N articles backward.
7819 The difference between N and the number of marks cleared is returned."
7821 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7823 (defun gnus-summary-mark-unread-as-read ()
7824 "Intended to be used by `gnus-summary-mark-article-hook'."
7825 (when (memq gnus-current-article gnus-newsgroup-unreads)
7826 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7828 (defun gnus-summary-mark-read-and-unread-as-read ()
7829 "Intended to be used by `gnus-summary-mark-article-hook'."
7830 (let ((mark (gnus-summary-article-mark)))
7831 (when (or (gnus-unread-mark-p mark)
7832 (gnus-read-mark-p mark))
7833 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7835 (defun gnus-summary-mark-region-as-read (point mark all)
7836 "Mark all unread articles between point and mark as read.
7837 If given a prefix, mark all articles between point and mark as read,
7838 even ticked and dormant ones."
7839 (interactive "r\nP")
7848 (memq (setq article (gnus-summary-article-number))
7849 gnus-newsgroup-unreads))
7850 (gnus-summary-mark-article article gnus-del-mark))
7852 (gnus-summary-find-next))))))
7854 (defun gnus-summary-mark-below (score mark)
7855 "Mark articles with score less than SCORE with MARK."
7856 (interactive "P\ncMark: ")
7857 (setq score (if score
7858 (prefix-numeric-value score)
7859 (or gnus-summary-default-score 0)))
7861 (set-buffer gnus-summary-buffer)
7862 (goto-char (point-min))
7865 (and (< (gnus-summary-article-score) score)
7866 (gnus-summary-mark-article nil mark))
7867 (gnus-summary-find-next)))))
7869 (defun gnus-summary-kill-below (&optional score)
7870 "Mark articles with score below SCORE as read."
7872 (gnus-summary-mark-below score gnus-killed-mark))
7874 (defun gnus-summary-clear-above (&optional score)
7875 "Clear all marks from articles with score above SCORE."
7877 (gnus-summary-mark-above score gnus-unread-mark))
7879 (defun gnus-summary-tick-above (&optional score)
7880 "Tick all articles with score above SCORE."
7882 (gnus-summary-mark-above score gnus-ticked-mark))
7884 (defun gnus-summary-mark-above (score mark)
7885 "Mark articles with score over SCORE with MARK."
7886 (interactive "P\ncMark: ")
7887 (setq score (if score
7888 (prefix-numeric-value score)
7889 (or gnus-summary-default-score 0)))
7891 (set-buffer gnus-summary-buffer)
7892 (goto-char (point-min))
7894 (when (> (gnus-summary-article-score) score)
7895 (gnus-summary-mark-article nil mark))
7897 (gnus-summary-find-next)))))
7899 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7900 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7901 (defun gnus-summary-limit-include-expunged (&optional no-error)
7902 "Display all the hidden articles that were expunged for low scores."
7904 (let ((buffer-read-only nil))
7905 (let ((scored gnus-newsgroup-scored)
7908 (unless (gnus-summary-goto-subject (caar scored))
7909 (and (setq h (gnus-summary-article-header (caar scored)))
7910 (< (cdar scored) gnus-summary-expunge-below)
7912 (setq scored (cdr scored)))
7914 (when (not no-error)
7915 (error "No expunged articles hidden"))
7916 (goto-char (point-min))
7917 (gnus-summary-prepare-unthreaded (nreverse headers))
7918 (goto-char (point-min))
7919 (gnus-summary-position-point)
7922 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7923 "Mark all unread articles in this newsgroup as read.
7924 If prefix argument ALL is non-nil, ticked and dormant articles will
7925 also be marked as read.
7926 If QUIETLY is non-nil, no questions will be asked.
7927 If TO-HERE is non-nil, it should be a point in the buffer. All
7928 articles before this point will be marked as read.
7929 Note that this function will only catch up the unread article
7930 in the current summary buffer limitation.
7931 The number of articles marked as read is returned."
7936 (not gnus-interactive-catchup) ;Without confirmation?
7940 "Mark absolutely all articles as read? "
7941 "Mark all unread articles as read? ")))
7943 (not gnus-newsgroup-adaptive)
7944 (not gnus-newsgroup-auto-expire)
7945 (not gnus-suppress-duplicates)
7946 (or (not gnus-use-cache)
7947 (eq gnus-use-cache 'passive)))
7950 (setq gnus-newsgroup-marked nil
7951 gnus-newsgroup-dormant nil))
7952 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
7953 ;; We actually mark all articles as canceled, which we
7954 ;; have to do when using auto-expiry or adaptive scoring.
7955 (gnus-summary-show-all-threads)
7956 (when (gnus-summary-first-subject (not all))
7958 (if to-here (< (point) to-here) t)
7959 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7960 (gnus-summary-find-next (not all)))))
7961 (gnus-set-mode-line 'summary))
7963 (gnus-summary-position-point)))
7965 (defun gnus-summary-catchup-to-here (&optional all)
7966 "Mark all unticked articles before the current one as read.
7967 If ALL is non-nil, also mark ticked and dormant articles as read."
7970 (gnus-save-hidden-threads
7971 (let ((beg (point)))
7972 ;; We check that there are unread articles.
7973 (when (or all (gnus-summary-find-prev))
7974 (gnus-summary-catchup all t beg)))))
7975 (gnus-summary-position-point))
7977 (defun gnus-summary-catchup-all (&optional quietly)
7978 "Mark all articles in this newsgroup as read."
7980 (gnus-summary-catchup t quietly))
7982 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7983 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7984 If prefix argument ALL is non-nil, all articles are marked as read."
7986 (when (gnus-summary-catchup all quietly nil 'fast)
7987 ;; Select next newsgroup or exit.
7988 (if (eq gnus-auto-select-next 'quietly)
7989 (gnus-summary-next-group nil)
7990 (gnus-summary-exit))))
7992 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7993 "Mark all articles in this newsgroup as read, and then exit."
7995 (gnus-summary-catchup-and-exit t quietly))
7997 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7998 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7999 "Mark all articles in this group as read and select the next group.
8000 If given a prefix, mark all articles, unread as well as ticked, as
8004 (gnus-summary-catchup all))
8005 (gnus-summary-next-article t nil nil t))
8007 ;; Thread-based commands.
8009 (defun gnus-summary-articles-in-thread (&optional article)
8010 "Return a list of all articles in the current thread.
8011 If ARTICLE is non-nil, return all articles in the thread that starts
8013 (let* ((article (or article (gnus-summary-article-number)))
8014 (data (gnus-data-find-list article))
8015 (top-level (gnus-data-level (car data)))
8017 (cond ((null gnus-thread-operation-ignore-subject)
8018 (gnus-simplify-subject-re
8019 (mail-header-subject (gnus-data-header (car data)))))
8020 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8021 (gnus-simplify-subject-fuzzy
8022 (mail-header-subject (gnus-data-header (car data)))))
8024 (end-point (save-excursion
8025 (if (gnus-summary-go-to-next-thread)
8026 (point) (point-max))))
8029 (< (gnus-data-pos (car data)) end-point))
8030 (when (or (not top-subject)
8031 (string= top-subject
8032 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8033 (gnus-simplify-subject-fuzzy
8034 (mail-header-subject
8035 (gnus-data-header (car data))))
8036 (gnus-simplify-subject-re
8037 (mail-header-subject
8038 (gnus-data-header (car data)))))))
8039 (push (gnus-data-number (car data)) articles))
8040 (unless (and (setq data (cdr data))
8041 (> (gnus-data-level (car data)) top-level))
8043 ;; Return the list of articles.
8044 (nreverse articles)))
8046 (defun gnus-summary-rethread-current ()
8047 "Rethread the thread the current article is part of."
8049 (let* ((gnus-show-threads t)
8050 (article (gnus-summary-article-number))
8051 (id (mail-header-id (gnus-summary-article-header)))
8052 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8054 (error "No article on the current line"))
8055 (gnus-rebuild-thread id)
8056 (gnus-summary-goto-subject article)))
8058 (defun gnus-summary-reparent-thread ()
8059 "Make the current article child of the marked (or previous) article.
8061 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8062 is non-nil or the Subject: of both articles are the same."
8064 (unless (not (gnus-group-read-only-p))
8065 (error "The current newsgroup does not support article editing"))
8066 (unless (<= (length gnus-newsgroup-processable) 1)
8067 (error "No more than one article may be marked"))
8068 (save-window-excursion
8069 (let ((gnus-article-buffer " *reparent*")
8070 (current-article (gnus-summary-article-number))
8071 ;; First grab the marked article, otherwise one line up.
8072 (parent-article (if (not (null gnus-newsgroup-processable))
8073 (car gnus-newsgroup-processable)
8075 (if (eq (forward-line -1) 0)
8076 (gnus-summary-article-number)
8077 (error "Beginning of summary buffer"))))))
8078 (unless (not (eq current-article parent-article))
8079 (error "An article may not be self-referential"))
8080 (let ((message-id (mail-header-id
8081 (gnus-summary-article-header parent-article))))
8082 (unless (and message-id (not (equal message-id "")))
8083 (error "No message-id in desired parent"))
8084 (gnus-summary-select-article t t nil current-article)
8085 (set-buffer gnus-original-article-buffer)
8086 (let ((buf (format "%s" (buffer-string))))
8087 (nnheader-temp-write nil
8089 (goto-char (point-min))
8090 (if (re-search-forward "^References: " nil t)
8092 (re-search-forward "^[^ \t]" nil t)
8095 (insert " " message-id))
8096 (insert "References: " message-id "\n"))
8097 (unless (gnus-request-replace-article
8098 current-article (car gnus-article-current)
8100 (error "Couldn't replace article"))))
8101 (set-buffer gnus-summary-buffer)
8102 (gnus-summary-unmark-all-processable)
8103 (gnus-summary-update-article current-article)
8104 (gnus-summary-rethread-current)
8105 (gnus-message 3 "Article %d is now the child of article %d"
8106 current-article parent-article)))))
8108 (defun gnus-summary-toggle-threads (&optional arg)
8109 "Toggle showing conversation threads.
8110 If ARG is positive number, turn showing conversation threads on."
8112 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8113 (setq gnus-show-threads
8114 (if (null arg) (not gnus-show-threads)
8115 (> (prefix-numeric-value arg) 0)))
8116 (gnus-summary-prepare)
8117 (gnus-summary-goto-subject current)
8118 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8119 (gnus-summary-position-point)))
8121 (defun gnus-summary-show-all-threads ()
8125 (let ((buffer-read-only nil))
8126 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8127 (gnus-summary-position-point))
8129 (defun gnus-summary-show-thread ()
8130 "Show thread subtrees.
8131 Returns nil if no thread was there to be shown."
8133 (let ((buffer-read-only nil)
8135 ;; first goto end then to beg, to have point at beg after let
8136 (end (progn (end-of-line) (point)))
8137 (beg (progn (beginning-of-line) (point))))
8139 ;; Any hidden lines here?
8140 (search-forward "\r" end t)
8141 (subst-char-in-region beg end ?\^M ?\n t)
8143 (gnus-summary-position-point))))
8145 (defun gnus-summary-hide-all-threads ()
8146 "Hide all thread subtrees."
8149 (goto-char (point-min))
8150 (gnus-summary-hide-thread)
8151 (while (zerop (gnus-summary-next-thread 1 t))
8152 (gnus-summary-hide-thread)))
8153 (gnus-summary-position-point))
8155 (defun gnus-summary-hide-thread ()
8156 "Hide thread subtrees.
8157 Returns nil if no threads were there to be hidden."
8159 (let ((buffer-read-only nil)
8161 (article (gnus-summary-article-number)))
8163 ;; Go forward until either the buffer ends or the subthread
8165 (when (and (not (eobp))
8166 (or (zerop (gnus-summary-next-thread 1 t))
8167 (goto-char (point-max))))
8169 (if (and (> (point) start)
8170 (search-backward "\n" start t))
8172 (subst-char-in-region start (point) ?\n ?\^M)
8173 (gnus-summary-goto-subject article))
8176 ;;(gnus-summary-position-point)
8179 (defun gnus-summary-go-to-next-thread (&optional previous)
8180 "Go to the same level (or less) next thread.
8181 If PREVIOUS is non-nil, go to previous thread instead.
8182 Return the article number moved to, or nil if moving was impossible."
8183 (let ((level (gnus-summary-thread-level))
8184 (way (if previous -1 1))
8187 (while (and (not (eobp))
8188 (< level (gnus-summary-thread-level)))
8196 (gnus-summary-article-number)
8199 (defun gnus-summary-next-thread (n &optional silent)
8200 "Go to the same level next N'th thread.
8201 If N is negative, search backward instead.
8202 Returns the difference between N and the number of skips actually
8205 If SILENT, don't output messages."
8207 (let ((backward (< n 0))
8210 (gnus-summary-go-to-next-thread backward))
8213 (gnus-summary-position-point))
8214 (when (and (not silent) (/= 0 n))
8215 (gnus-message 7 "No more threads"))
8218 (defun gnus-summary-prev-thread (n)
8219 "Go to the same level previous N'th thread.
8220 Returns the difference between N and the number of skips actually
8223 (gnus-summary-next-thread (- n)))
8225 (defun gnus-summary-go-down-thread ()
8226 "Go down one level in the current thread."
8227 (let ((children (gnus-summary-article-children)))
8229 (gnus-summary-goto-subject (car children)))))
8231 (defun gnus-summary-go-up-thread ()
8232 "Go up one level in the current thread."
8233 (let ((parent (gnus-summary-article-parent)))
8235 (gnus-summary-goto-subject parent))))
8237 (defun gnus-summary-down-thread (n)
8238 "Go down thread N steps.
8239 If N is negative, go up instead.
8240 Returns the difference between N and how many steps down that were
8246 (if up (gnus-summary-go-up-thread)
8247 (gnus-summary-go-down-thread)))
8249 (gnus-summary-position-point)
8251 (gnus-message 7 "Can't go further"))
8254 (defun gnus-summary-up-thread (n)
8255 "Go up thread N steps.
8256 If N is negative, go up instead.
8257 Returns the difference between N and how many steps down that were
8260 (gnus-summary-down-thread (- n)))
8262 (defun gnus-summary-top-thread ()
8263 "Go to the top of the thread."
8265 (while (gnus-summary-go-up-thread))
8266 (gnus-summary-article-number))
8268 (defun gnus-summary-kill-thread (&optional unmark)
8269 "Mark articles under current thread as read.
8270 If the prefix argument is positive, remove any kinds of marks.
8271 If the prefix argument is negative, tick articles instead."
8274 (setq unmark (prefix-numeric-value unmark)))
8275 (let ((articles (gnus-summary-articles-in-thread)))
8277 ;; Expand the thread.
8278 (gnus-summary-show-thread)
8279 ;; Mark all the articles.
8281 (gnus-summary-goto-subject (car articles))
8282 (cond ((null unmark)
8283 (gnus-summary-mark-article-as-read gnus-killed-mark))
8285 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8287 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8288 (setq articles (cdr articles))))
8289 ;; Hide killed subtrees.
8291 gnus-thread-hide-killed
8292 (gnus-summary-hide-thread))
8293 ;; If marked as read, go to next unread subject.
8295 ;; Go to next unread subject.
8296 (gnus-summary-next-subject 1 t)))
8297 (gnus-set-mode-line 'summary))
8299 ;; Summary sorting commands
8301 (defun gnus-summary-sort-by-number (&optional reverse)
8302 "Sort the summary buffer by article number.
8303 Argument REVERSE means reverse order."
8305 (gnus-summary-sort 'number reverse))
8307 (defun gnus-summary-sort-by-author (&optional reverse)
8308 "Sort the summary buffer by author name alphabetically.
8309 If case-fold-search is non-nil, case of letters is ignored.
8310 Argument REVERSE means reverse order."
8312 (gnus-summary-sort 'author reverse))
8314 (defun gnus-summary-sort-by-subject (&optional reverse)
8315 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8316 If case-fold-search is non-nil, case of letters is ignored.
8317 Argument REVERSE means reverse order."
8319 (gnus-summary-sort 'subject reverse))
8321 (defun gnus-summary-sort-by-date (&optional reverse)
8322 "Sort the summary buffer by date.
8323 Argument REVERSE means reverse order."
8325 (gnus-summary-sort 'date reverse))
8327 (defun gnus-summary-sort-by-score (&optional reverse)
8328 "Sort the summary buffer by score.
8329 Argument REVERSE means reverse order."
8331 (gnus-summary-sort 'score reverse))
8333 (defun gnus-summary-sort-by-lines (&optional reverse)
8334 "Sort the summary buffer by article length.
8335 Argument REVERSE means reverse order."
8337 (gnus-summary-sort 'lines reverse))
8339 (defun gnus-summary-sort (predicate reverse)
8340 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8341 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8342 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8343 (gnus-thread-sort-functions
8349 (gnus-article-sort-functions
8354 (,article t2 t1)))))
8356 (gnus-summary-prepare-hook nil))
8357 ;; We do the sorting by regenerating the threads.
8358 (gnus-summary-prepare)
8359 ;; Hide subthreads if needed.
8360 (when (and gnus-show-threads gnus-thread-hide-subtree)
8361 (gnus-summary-hide-all-threads))))
8363 ;; Summary saving commands.
8365 (defun gnus-summary-save-article (&optional n not-saved)
8366 "Save the current article using the default saver function.
8367 If N is a positive number, save the N next articles.
8368 If N is a negative number, save the N previous articles.
8369 If N is nil and any articles have been marked with the process mark,
8370 save those articles instead.
8371 The variable `gnus-default-article-saver' specifies the saver function."
8373 (let* ((articles (gnus-summary-work-articles n))
8374 (save-buffer (save-excursion
8375 (nnheader-set-temp-buffer " *Gnus Save*")))
8376 (num (length articles))
8377 header article file)
8379 (setq header (gnus-summary-article-header
8380 (setq article (pop articles))))
8381 (if (not (vectorp header))
8382 ;; This is a pseudo-article.
8383 (if (assq 'name header)
8384 (gnus-copy-file (cdr (assq 'name header)))
8385 (gnus-message 1 "Article %d is unsaveable" article))
8386 ;; This is a real article.
8387 (save-window-excursion
8388 (gnus-summary-select-article t nil nil article))
8390 (set-buffer save-buffer)
8392 (insert-buffer-substring gnus-original-article-buffer))
8393 (setq file (gnus-article-save save-buffer file num))
8394 (gnus-summary-remove-process-mark article)
8396 (gnus-summary-set-saved-mark article))))
8397 (gnus-kill-buffer save-buffer)
8398 (gnus-summary-position-point)
8399 (gnus-set-mode-line 'summary)
8402 (defun gnus-summary-pipe-output (&optional arg)
8403 "Pipe the current article to a subprocess.
8404 If N is a positive number, pipe the N next articles.
8405 If N is a negative number, pipe the N previous articles.
8406 If N is nil and any articles have been marked with the process mark,
8407 pipe those articles instead."
8409 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8410 (gnus-summary-save-article arg t))
8411 (gnus-configure-windows 'pipe))
8413 (defun gnus-summary-save-article-mail (&optional arg)
8414 "Append the current article to an mail file.
8415 If N is a positive number, save the N next articles.
8416 If N is a negative number, save the N previous articles.
8417 If N is nil and any articles have been marked with the process mark,
8418 save those articles instead."
8420 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8421 (gnus-summary-save-article arg)))
8423 (defun gnus-summary-save-article-rmail (&optional arg)
8424 "Append the current article to an rmail file.
8425 If N is a positive number, save the N next articles.
8426 If N is a negative number, save the N previous articles.
8427 If N is nil and any articles have been marked with the process mark,
8428 save those articles instead."
8430 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8431 (gnus-summary-save-article arg)))
8433 (defun gnus-summary-save-article-file (&optional arg)
8434 "Append the current article to a file.
8435 If N is a positive number, save the N next articles.
8436 If N is a negative number, save the N previous articles.
8437 If N is nil and any articles have been marked with the process mark,
8438 save those articles instead."
8440 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8441 (gnus-summary-save-article arg)))
8443 (defun gnus-summary-write-article-file (&optional arg)
8444 "Write the current article to a file, deleting the previous file.
8445 If N is a positive number, save the N next articles.
8446 If N is a negative number, save the N previous articles.
8447 If N is nil and any articles have been marked with the process mark,
8448 save those articles instead."
8450 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8451 (gnus-summary-save-article arg)))
8453 (defun gnus-summary-save-article-body-file (&optional arg)
8454 "Append the current article body to a file.
8455 If N is a positive number, save the N next articles.
8456 If N is a negative number, save the N previous articles.
8457 If N is nil and any articles have been marked with the process mark,
8458 save those articles instead."
8460 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8461 (gnus-summary-save-article arg)))
8463 (defun gnus-summary-pipe-message (program)
8464 "Pipe the current article through PROGRAM."
8465 (interactive "sProgram: ")
8466 (gnus-summary-select-article)
8467 (let ((mail-header-separator "")
8468 (art-buf (get-buffer gnus-article-buffer)))
8469 (gnus-eval-in-buffer-window gnus-article-buffer
8472 (let ((start (window-start))
8474 (message-pipe-buffer-body program)
8475 (set-window-start (get-buffer-window (current-buffer)) start))))))
8477 (defun gnus-get-split-value (methods)
8478 "Return a value based on the split METHODS."
8479 (let (split-name method result match)
8482 (set-buffer gnus-original-article-buffer)
8484 (nnheader-narrow-to-headers)
8486 (goto-char (point-min))
8487 (setq method (pop methods))
8488 (setq match (car method))
8491 ;; Regular expression.
8493 (re-search-forward match nil t)))
8494 ((gnus-functionp match)
8498 (setq result (funcall match gnus-newsgroup-name))))
8503 (setq result (eval match)))))
8504 (setq split-name (append (cdr method) split-name))
8505 (cond ((stringp result)
8506 (push (expand-file-name
8507 result gnus-article-save-directory)
8510 (setq split-name (append result split-name)))))))))
8513 (defun gnus-valid-move-group-p (group)
8518 (car (gnus-find-method-for-group
8519 (symbol-name group))))
8520 gnus-valid-select-methods))))
8522 (defun gnus-read-move-group-name (prompt default articles prefix)
8523 "Read a group name."
8524 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8525 (minibuffer-confirm-incomplete nil) ; XEmacs
8529 (if (> (length articles) 1)
8530 (format "these %d articles" (length articles))
8535 (gnus-completing-read default prom
8537 'gnus-valid-move-group-p
8539 'gnus-group-history))
8540 ((= 1 (length split-name))
8541 (gnus-completing-read (car split-name) prom
8543 'gnus-valid-move-group-p
8545 'gnus-group-history))
8547 (gnus-completing-read nil prom
8548 (mapcar (lambda (el) (list el))
8549 (nreverse split-name))
8551 'gnus-group-history)))))
8553 (if (or (string= to-newsgroup "")
8554 (string= to-newsgroup prefix))
8555 (setq to-newsgroup default))
8556 (unless to-newsgroup
8557 (error "No group name entered"))
8558 (or (gnus-active to-newsgroup)
8559 (gnus-activate-group to-newsgroup)
8560 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8562 (or (and (gnus-request-create-group
8563 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8564 (gnus-activate-group to-newsgroup nil nil
8565 (gnus-group-name-to-method
8567 (error "Couldn't create group %s" to-newsgroup)))
8568 (error "No such group: %s" to-newsgroup)))
8571 ;; Summary extract commands
8573 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8574 (let ((buffer-read-only nil)
8575 (article (gnus-summary-article-number))
8577 (unless (gnus-summary-goto-subject article)
8578 (error "No such article: %d" article))
8579 (gnus-summary-position-point)
8580 ;; If all commands are to be bunched up on one line, we collect
8582 (unless gnus-view-pseudos-separately
8583 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8586 (setq action (cdr (assq 'action (car ps))))
8587 (setq files (list (cdr (assq 'name (car ps)))))
8588 (while (and ps (cdr ps)
8589 (string= (or action "1")
8590 (or (cdr (assq 'action (cadr ps))) "2")))
8591 (push (cdr (assq 'name (cadr ps))) files)
8592 (setcdr ps (cddr ps)))
8594 (when (not (string-match "%s" action))
8597 (when (assq 'execute (car ps))
8598 (setcdr (assq 'execute (car ps))
8599 (funcall (if (string-match "%s" action)
8606 (gnus-quote-arg-for-sh-or-csh f)))
8608 (setq ps (cdr ps)))))
8609 (if (and gnus-view-pseudos (not not-view))
8611 (when (assq 'execute (car pslist))
8612 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8613 (eq gnus-view-pseudos 'not-confirm)))
8614 (setq pslist (cdr pslist)))
8617 (setq after-article (or (cdr (assq 'article (car pslist)))
8618 (gnus-summary-article-number)))
8619 (gnus-summary-goto-subject after-article)
8622 (insert " " (file-name-nondirectory
8623 (cdr (assq 'name (car pslist))))
8624 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8626 (forward-line -1) ; back to `b'
8627 (gnus-add-text-properties
8628 b (1- e) (list 'gnus-number gnus-reffed-article-number
8629 gnus-mouse-face-prop gnus-mouse-face))
8631 after-article gnus-reffed-article-number
8632 gnus-unread-mark b (car pslist) 0 (- e b))
8633 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8634 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8635 (setq pslist (cdr pslist)))))))
8637 (defun gnus-pseudos< (p1 p2)
8638 (let ((c1 (cdr (assq 'action p1)))
8639 (c2 (cdr (assq 'action p2))))
8640 (and c1 c2 (string< c1 c2))))
8642 (defun gnus-request-pseudo-article (props)
8643 (cond ((assq 'execute props)
8644 (gnus-execute-command (cdr (assq 'execute props)))))
8645 (let ((gnus-current-article (gnus-summary-article-number)))
8646 (run-hooks 'gnus-mark-article-hook)))
8648 (defun gnus-execute-command (command &optional automatic)
8650 (gnus-article-setup-buffer)
8651 (set-buffer gnus-article-buffer)
8652 (setq buffer-read-only nil)
8653 (let ((command (if automatic command
8654 (read-string "Command: " (cons command 0)))))
8656 (insert "$ " command "\n\n")
8657 (if gnus-view-pseudo-asynchronously
8658 (start-process "gnus-execute" (current-buffer) shell-file-name
8659 shell-command-switch command)
8660 (call-process shell-file-name nil t nil
8661 shell-command-switch command)))))
8663 ;; Summary kill commands.
8665 (defun gnus-summary-edit-global-kill (article)
8666 "Edit the \"global\" kill file."
8667 (interactive (list (gnus-summary-article-number)))
8668 (gnus-group-edit-global-kill article))
8670 (defun gnus-summary-edit-local-kill ()
8671 "Edit a local kill file applied to the current newsgroup."
8673 (setq gnus-current-headers (gnus-summary-article-header))
8674 (gnus-group-edit-local-kill
8675 (gnus-summary-article-number) gnus-newsgroup-name))
8679 (defun gnus-read-header (id &optional header)
8680 "Read the headers of article ID and enter them into the Gnus system."
8681 (let ((group gnus-newsgroup-name)
8682 (gnus-override-method
8683 (and (gnus-news-group-p gnus-newsgroup-name)
8684 gnus-refer-article-method))
8686 ;; First we check to see whether the header in question is already
8689 ;; This is a Message-ID.
8690 (setq header (or header (gnus-id-to-header id)))
8691 ;; This is an article number.
8692 (setq header (or header (gnus-summary-article-header id))))
8694 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8695 ;; We have found the header.
8697 ;; If this is a sparse article, we have to nix out its
8698 ;; previous entry in the thread hashtb.
8700 (gnus-summary-article-sparse-p (mail-header-number header)))
8701 (let* ((parent (gnus-parent-id (mail-header-references header)))
8704 (gnus-gethash parent gnus-newsgroup-dependencies))))
8706 (delq (assq header thread) thread))))
8707 ;; We have to really fetch the header to this article.
8709 (set-buffer nntp-server-buffer)
8710 (when (setq where (gnus-request-head id group))
8711 (nnheader-fold-continuation-lines)
8712 (goto-char (point-max))
8714 (goto-char (point-min))
8718 ((cdr where) (cdr where))
8719 (header (mail-header-number header))
8720 (t gnus-reffed-article-number))
8722 (insert " Article retrieved.\n"))
8724 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8725 () ; Malformed head.
8726 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8727 (when (and (stringp id)
8728 (not (string= (gnus-group-real-name group)
8730 ;; If we fetched by Message-ID and the article came
8731 ;; from a different group, we fudge some bogus article
8732 ;; numbers for this article.
8733 (mail-header-set-number header gnus-reffed-article-number))
8735 (set-buffer gnus-summary-buffer)
8736 (decf gnus-reffed-article-number)
8737 (gnus-remove-header (mail-header-number header))
8738 (push header gnus-newsgroup-headers)
8739 (setq gnus-current-headers header)
8740 (push (mail-header-number header) gnus-newsgroup-limit)))
8743 (defun gnus-remove-header (number)
8744 "Remove header NUMBER from `gnus-newsgroup-headers'."
8745 (if (and gnus-newsgroup-headers
8746 (= number (mail-header-number (car gnus-newsgroup-headers))))
8747 (pop gnus-newsgroup-headers)
8748 (let ((headers gnus-newsgroup-headers))
8749 (while (and (cdr headers)
8750 (not (= number (mail-header-number (cadr headers)))))
8753 (setcdr headers (cddr headers))))))
8756 ;;; summary highlights
8759 (defun gnus-highlight-selected-summary ()
8760 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8761 ;; Highlight selected article in summary buffer
8762 (when gnus-summary-selected-face
8764 (let* ((beg (progn (beginning-of-line) (point)))
8765 (end (progn (end-of-line) (point)))
8766 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8767 (from (if (get-text-property beg gnus-mouse-face-prop)
8769 (or (next-single-property-change
8770 beg gnus-mouse-face-prop nil end)
8775 (or (next-single-property-change
8776 from gnus-mouse-face-prop nil end)
8778 ;; If no mouse-face prop on line we will have to = from = end,
8779 ;; so we highlight the entire line instead.
8780 (when (= (+ to 2) from)
8783 (if gnus-newsgroup-selected-overlay
8784 ;; Move old overlay.
8786 gnus-newsgroup-selected-overlay from to (current-buffer))
8787 ;; Create new overlay.
8789 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8790 'face gnus-summary-selected-face))))))
8792 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8793 (defun gnus-summary-highlight-line ()
8794 "Highlight current line according to `gnus-summary-highlight'."
8795 (let* ((list gnus-summary-highlight)
8797 (end (progn (end-of-line) (point)))
8798 ;; now find out where the line starts and leave point there.
8799 (beg (progn (beginning-of-line) (point)))
8800 (article (gnus-summary-article-number))
8801 (score (or (cdr (assq (or article gnus-current-article)
8802 gnus-newsgroup-scored))
8803 gnus-summary-default-score 0))
8804 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8805 (inhibit-read-only t))
8806 ;; Eval the cars of the lists until we find a match.
8807 (let ((default gnus-summary-default-score))
8809 (not (eval (caar list))))
8810 (setq list (cdr list))))
8811 (let ((face (cdar list)))
8812 (unless (eq face (get-text-property beg 'face))
8813 (gnus-put-text-property
8815 (setq face (if (boundp face) (symbol-value face) face)))
8816 (when gnus-summary-highlight-line-function
8817 (funcall gnus-summary-highlight-line-function article face))))
8820 (defun gnus-update-read-articles (group unread &optional compute)
8821 "Update the list of read articles in GROUP."
8822 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8823 (entry (gnus-gethash group gnus-newsrc-hashtb))
8824 (info (nth 2 entry))
8826 (unread (sort (copy-sequence unread) '<))
8828 (if (or (not info) (not active))
8829 ;; There is no info on this group if it was, in fact,
8830 ;; killed. Gnus stores no information on killed groups, so
8831 ;; there's nothing to be done.
8832 ;; One could store the information somewhere temporarily,
8833 ;; perhaps... Hmmm...
8835 ;; Remove any negative articles numbers.
8836 (while (and unread (< (car unread) 0))
8837 (setq unread (cdr unread)))
8838 ;; Remove any expired article numbers
8839 (while (and unread (< (car unread) (car active)))
8840 (setq unread (cdr unread)))
8841 ;; Compute the ranges of read articles by looking at the list of
8844 (when (/= (car unread) prev)
8845 (push (if (= prev (1- (car unread))) prev
8846 (cons prev (1- (car unread))))
8848 (setq prev (1+ (car unread)))
8849 (setq unread (cdr unread)))
8850 (when (<= prev (cdr active))
8851 (push (cons prev (cdr active)) read))
8853 (if (> (length read) 1) (nreverse read) read)
8855 (set-buffer gnus-group-buffer)
8858 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8859 (gnus-info-set-read ',info ',(gnus-info-read info))
8860 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8861 (gnus-group-update-group ,group t))))
8862 ;; Enter this list into the group info.
8864 info (if (> (length read) 1) (nreverse read) read))
8865 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8866 (gnus-get-unread-articles-in-group info (gnus-active group))
8869 (defun gnus-offer-save-summaries ()
8870 "Offer to save all active summary buffers."
8872 (let ((buflist (buffer-list))
8874 ;; Go through all buffers and find all summaries.
8876 (and (setq bufname (buffer-name (car buflist)))
8877 (string-match "Summary" bufname)
8879 (set-buffer bufname)
8880 ;; We check that this is, indeed, a summary buffer.
8881 (and (eq major-mode 'gnus-summary-mode)
8882 ;; Also make sure this isn't bogus.
8883 gnus-newsgroup-prepared
8884 ;; Also make sure that this isn't a dead summary buffer.
8885 (not gnus-dead-summary-mode)))
8886 (push bufname buffers))
8887 (setq buflist (cdr buflist)))
8888 ;; Go through all these summary buffers and offer to save them.
8891 "Update summary buffer %s? "
8892 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8899 (run-hooks 'gnus-sum-load-hook)
8901 ;;; gnus-sum.el ends here