1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
36 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
38 (defcustom gnus-kill-summary-on-exit t
39 "*If non-nil, kill the summary buffer when you exit from it.
40 If nil, the summary will become a \"*Dead Summary*\" buffer, and
41 it will be killed sometime later."
42 :group 'gnus-summary-exit
45 (defcustom gnus-fetch-old-headers nil
46 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
47 If an unread article in the group refers to an older, already read (or
48 just marked as read) article, the old article will not normally be
49 displayed in the Summary buffer. If this variable is non-nil, Gnus
50 will attempt to grab the headers to the old articles, and thereby
51 build complete threads. If it has the value `some', only enough
52 headers to connect otherwise loose threads will be displayed. This
53 variable can also be a number. In that case, no more than that number
54 of old headers will be fetched. If it has the value `invisible', all
55 old headers will be fetched, but none will be displayed.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-refer-thread-limit 200
65 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
66 If t, fetch all the available old headers."
69 (sexp :menu-tag "other" t)))
71 (defcustom gnus-summary-make-false-root 'adopt
72 "*nil means that Gnus won't gather loose threads.
73 If the root of a thread has expired or been read in a previous
74 session, the information necessary to build a complete thread has been
75 lost. Instead of having many small sub-threads from this original thread
76 scattered all over the summary buffer, Gnus can gather them.
78 If non-nil, Gnus will try to gather all loose sub-threads from an
79 original thread into one large thread.
81 If this variable is non-nil, it should be one of `none', `adopt',
84 If this variable is `none', Gnus will not make a false root, but just
85 present the sub-threads after another.
86 If this variable is `dummy', Gnus will create a dummy root that will
87 have all the sub-threads as children.
88 If this variable is `adopt', Gnus will make one of the \"children\"
89 the parent and mark all the step-children as such.
90 If this variable is `empty', the \"children\" are printed with empty
91 subject fields. (Or rather, they will be printed with a string
92 given by the `gnus-summary-same-subject' variable.)"
94 :type '(choice (const :tag "off" nil)
100 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
101 "*A regexp to match subjects to be excluded from loose thread gathering.
102 As loose thread gathering is done on subjects only, that means that
103 there can be many false gatherings performed. By rooting out certain
104 common subjects, gathering might become saner."
108 (defcustom gnus-summary-gather-subject-limit nil
109 "*Maximum length of subject comparisons when gathering loose threads.
110 Use nil to compare full subjects. Setting this variable to a low
111 number will help gather threads that have been corrupted by
112 newsreaders chopping off subject lines, but it might also mean that
113 unrelated articles that have subject that happen to begin with the
114 same few characters will be incorrectly gathered.
116 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
119 :type '(choice (const :tag "off" nil)
121 (sexp :menu-tag "on" t)))
123 (defcustom gnus-simplify-subject-functions nil
124 "List of functions taking a string argument that simplify subjects.
125 The functions are applied recursively."
127 :type '(repeat (list function)))
129 (defcustom gnus-simplify-ignored-prefixes nil
130 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
132 :type '(choice (const :tag "off" nil)
135 (defcustom gnus-build-sparse-threads nil
136 "*If non-nil, fill in the gaps in threads.
137 If `some', only fill in the gaps that are needed to tie loose threads
138 together. If `more', fill in all leaf nodes that Gnus can find. If
139 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
141 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "all" t)))
146 (defcustom gnus-summary-thread-gathering-function
147 'gnus-gather-threads-by-subject
148 "Function used for gathering loose threads.
149 There are two pre-defined functions: `gnus-gather-threads-by-subject',
150 which only takes Subjects into consideration; and
151 `gnus-gather-threads-by-references', which compared the References
152 headers of the articles to find matches."
154 :type '(radio (function-item gnus-gather-threads-by-subject)
155 (function-item gnus-gather-threads-by-references)
156 (function :tag "other")))
158 (defcustom gnus-summary-same-subject ""
159 "*String indicating that the current article has the same subject as the previous.
160 This variable will only be used if the value of
161 `gnus-summary-make-false-root' is `empty'."
162 :group 'gnus-summary-format
165 (defcustom gnus-summary-goto-unread t
166 "*If t, marking commands will go to the next unread article.
167 If `never', commands that usually go to the next unread article, will
168 go to the next article, whether it is read or not.
169 If nil, only the marking commands will go to the next (un)read article."
170 :group 'gnus-summary-marks
171 :link '(custom-manual "(gnus)Setting Marks")
172 :type '(choice (const :tag "off" nil)
174 (sexp :menu-tag "on" t)))
176 (defcustom gnus-summary-default-score 0
177 "*Default article score level.
178 All scores generated by the score files will be added to this score.
179 If this variable is nil, scoring will be disabled."
180 :group 'gnus-score-default
181 :type '(choice (const :tag "disable")
184 (defcustom gnus-summary-zcore-fuzz 0
185 "*Fuzziness factor for the zcore in the summary buffer.
186 Articles with scores closer than this to `gnus-summary-default-score'
188 :group 'gnus-summary-format
191 (defcustom gnus-simplify-subject-fuzzy-regexp nil
192 "*Strings to be removed when doing fuzzy matches.
193 This can either be a regular expression or list of regular expressions
194 that will be removed from subject strings if fuzzy subject
195 simplification is selected."
197 :type '(repeat regexp))
199 (defcustom gnus-show-threads t
200 "*If non-nil, display threads in summary mode."
204 (defcustom gnus-thread-hide-subtree nil
205 "*If non-nil, hide all threads initially.
206 If threads are hidden, you have to run the command
207 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
208 to expose hidden threads."
212 (defcustom gnus-thread-hide-killed t
213 "*If non-nil, hide killed threads automatically."
217 (defcustom gnus-thread-ignore-subject nil
218 "*If non-nil, ignore subjects and do all threading based on the Reference header.
219 If nil, which is the default, articles that have different subjects
220 from their parents will start separate threads."
224 (defcustom gnus-thread-operation-ignore-subject t
225 "*If non-nil, subjects will be ignored when doing thread commands.
226 This affects commands like `gnus-summary-kill-thread' and
227 `gnus-summary-lower-thread'.
229 If this variable is nil, articles in the same thread with different
230 subjects will not be included in the operation in question. If this
231 variable is `fuzzy', only articles that have subjects that are fuzzily
232 equal will be included."
234 :type '(choice (const :tag "off" nil)
238 (defcustom gnus-thread-indent-level 4
239 "*Number that says how much each sub-thread should be indented."
243 (defcustom gnus-auto-extend-newsgroup t
244 "*If non-nil, extend newsgroup forward and backward when requested."
245 :group 'gnus-summary-choose
248 (defcustom gnus-auto-select-first t
249 "*If nil, don't select the first unread article when entering a group.
250 If this variable is `best', select the highest-scored unread article
251 in the group. If neither nil nor `best', select the first unread
254 If you want to prevent automatic selection of the first unread article
255 in some newsgroups, set the variable to nil in
256 `gnus-select-group-hook'."
257 :group 'gnus-group-select
258 :type '(choice (const :tag "none" nil)
260 (sexp :menu-tag "first" t)))
262 (defcustom gnus-auto-select-next t
263 "*If non-nil, offer to go to the next group from the end of the previous.
264 If the value is t and the next newsgroup is empty, Gnus will exit
265 summary mode and go back to group mode. If the value is neither nil
266 nor t, Gnus will select the following unread newsgroup. In
267 particular, if the value is the symbol `quietly', the next unread
268 newsgroup will be selected without any confirmation, and if it is
269 `almost-quietly', the next group will be selected without any
270 confirmation if you are located on the last article in the group.
271 Finally, if this variable is `slightly-quietly', the `Z n' command
272 will go to the next group without confirmation."
273 :group 'gnus-summary-maneuvering
274 :type '(choice (const :tag "off" nil)
276 (const almost-quietly)
277 (const slightly-quietly)
278 (sexp :menu-tag "on" t)))
280 (defcustom gnus-auto-select-same nil
281 "*If non-nil, select the next article with the same subject."
282 :group 'gnus-summary-maneuvering
285 (defcustom gnus-summary-check-current nil
286 "*If non-nil, consider the current article when moving.
287 The \"unread\" movement commands will stay on the same line if the
288 current article is unread."
289 :group 'gnus-summary-maneuvering
292 (defcustom gnus-auto-center-summary t
293 "*If non-nil, always center the current summary buffer.
294 In particular, if `vertical' do only vertical recentering. If non-nil
295 and non-`vertical', do both horizontal and vertical recentering."
296 :group 'gnus-summary-maneuvering
297 :type '(choice (const :tag "none" nil)
299 (sexp :menu-tag "both" t)))
301 (defcustom gnus-show-all-headers nil
302 "*If non-nil, don't hide any headers."
303 :group 'gnus-article-hiding
304 :group 'gnus-article-headers
307 (defcustom gnus-summary-ignore-duplicates nil
308 "*If non-nil, ignore articles with identical Message-ID headers."
312 (defcustom gnus-single-article-buffer t
313 "*If non-nil, display all articles in the same buffer.
314 If nil, each group will get its own article buffer."
315 :group 'gnus-article-various
318 (defcustom gnus-break-pages t
319 "*If non-nil, do page breaking on articles.
320 The page delimiter is specified by the `gnus-page-delimiter'
322 :group 'gnus-article-various
325 (defcustom gnus-show-mime nil
326 "*If non-nil, do mime processing of articles.
327 The articles will simply be fed to the function given by
328 `gnus-show-mime-method'."
329 :group 'gnus-article-mime
332 (defcustom gnus-move-split-methods nil
333 "*Variable used to suggest where articles are to be moved to.
334 It uses the same syntax as the `gnus-split-methods' variable."
335 :group 'gnus-summary-mail
336 :type '(repeat (choice (list function)
337 (cons regexp (repeat string))
340 (defcustom gnus-unread-mark ?
341 "*Mark used for unread articles."
342 :group 'gnus-summary-marks
345 (defcustom gnus-ticked-mark ?!
346 "*Mark used for ticked articles."
347 :group 'gnus-summary-marks
350 (defcustom gnus-dormant-mark ??
351 "*Mark used for dormant articles."
352 :group 'gnus-summary-marks
355 (defcustom gnus-del-mark ?r
356 "*Mark used for del'd articles."
357 :group 'gnus-summary-marks
360 (defcustom gnus-read-mark ?R
361 "*Mark used for read articles."
362 :group 'gnus-summary-marks
365 (defcustom gnus-expirable-mark ?E
366 "*Mark used for expirable articles."
367 :group 'gnus-summary-marks
370 (defcustom gnus-killed-mark ?K
371 "*Mark used for killed articles."
372 :group 'gnus-summary-marks
375 (defcustom gnus-souped-mark ?F
376 "*Mark used for killed articles."
377 :group 'gnus-summary-marks
380 (defcustom gnus-kill-file-mark ?X
381 "*Mark used for articles killed by kill files."
382 :group 'gnus-summary-marks
385 (defcustom gnus-low-score-mark ?Y
386 "*Mark used for articles with a low score."
387 :group 'gnus-summary-marks
390 (defcustom gnus-catchup-mark ?C
391 "*Mark used for articles that are caught up."
392 :group 'gnus-summary-marks
395 (defcustom gnus-replied-mark ?A
396 "*Mark used for articles that have been replied to."
397 :group 'gnus-summary-marks
400 (defcustom gnus-cached-mark ?*
401 "*Mark used for articles that are in the cache."
402 :group 'gnus-summary-marks
405 (defcustom gnus-saved-mark ?S
406 "*Mark used for articles that have been saved to."
407 :group 'gnus-summary-marks
410 (defcustom gnus-ancient-mark ?O
411 "*Mark used for ancient articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-sparse-mark ?Q
416 "*Mark used for sparsely reffed articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-canceled-mark ?G
421 "*Mark used for canceled articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-duplicate-mark ?M
426 "*Mark used for duplicate articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-undownloaded-mark ?@
431 "*Mark used for articles that weren't downloaded."
432 :group 'gnus-summary-marks
435 (defcustom gnus-downloadable-mark ?%
436 "*Mark used for articles that are to be downloaded."
437 :group 'gnus-summary-marks
440 (defcustom gnus-unsendable-mark ?=
441 "*Mark used for articles that won't be sent."
442 :group 'gnus-summary-marks
445 (defcustom gnus-score-over-mark ?+
446 "*Score mark used for articles with high scores."
447 :group 'gnus-summary-marks
450 (defcustom gnus-score-below-mark ?-
451 "*Score mark used for articles with low scores."
452 :group 'gnus-summary-marks
455 (defcustom gnus-empty-thread-mark ?
456 "*There is no thread under the article."
457 :group 'gnus-summary-marks
460 (defcustom gnus-not-empty-thread-mark ?=
461 "*There is a thread under the article."
462 :group 'gnus-summary-marks
465 (defcustom gnus-view-pseudo-asynchronously nil
466 "*If non-nil, Gnus will view pseudo-articles asynchronously."
467 :group 'gnus-extract-view
470 (defcustom gnus-view-pseudos nil
471 "*If `automatic', pseudo-articles will be viewed automatically.
472 If `not-confirm', pseudos will be viewed automatically, and the user
473 will not be asked to confirm the command."
474 :group 'gnus-extract-view
475 :type '(choice (const :tag "off" nil)
477 (const not-confirm)))
479 (defcustom gnus-view-pseudos-separately t
480 "*If non-nil, one pseudo-article will be created for each file to be viewed.
481 If nil, all files that use the same viewing command will be given as a
482 list of parameters to that command."
483 :group 'gnus-extract-view
486 (defcustom gnus-insert-pseudo-articles t
487 "*If non-nil, insert pseudo-articles when decoding articles."
488 :group 'gnus-extract-view
491 (defcustom gnus-summary-dummy-line-format
493 "*The format specification for the dummy roots in the summary buffer.
494 It works along the same lines as a normal formatting string,
495 with some simple extensions.
498 :group 'gnus-threading
501 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
502 "*The format specification for the summary mode line.
503 It works along the same lines as a normal formatting string,
504 with some simple extensions:
507 %p Unprefixed group name
508 %A Current article number
510 %U Number of unread articles in the group
511 %e Number of unselected articles in the group
512 %Z A string with unread/unselected article counts
513 %g Shortish group name
514 %S Subject of the current article
516 %s Current score file name
517 %d Number of dormant articles
518 %r Number of articles that have been marked as read in this session
519 %E Number of articles expunged by the score files"
520 :group 'gnus-summary-format
523 (defcustom gnus-summary-mark-below 0
524 "*Mark all articles with a score below this variable as read.
525 This variable is local to each summary buffer and usually set by the
527 :group 'gnus-score-default
530 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
531 "*List of functions used for sorting articles in the summary buffer.
532 This variable is only used when not using a threaded display."
533 :group 'gnus-summary-sort
534 :type '(repeat (choice (function-item gnus-article-sort-by-number)
535 (function-item gnus-article-sort-by-author)
536 (function-item gnus-article-sort-by-subject)
537 (function-item gnus-article-sort-by-date)
538 (function-item gnus-article-sort-by-score)
539 (function :tag "other"))))
541 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
542 "*List of functions used for sorting threads in the summary buffer.
543 By default, threads are sorted by article number.
545 Each function takes two threads and return non-nil if the first thread
546 should be sorted before the other. If you use more than one function,
547 the primary sort function should be the last. You should probably
548 always include `gnus-thread-sort-by-number' in the list of sorting
549 functions -- preferably first.
551 Ready-made functions include `gnus-thread-sort-by-number',
552 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
553 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
554 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
555 :group 'gnus-summary-sort
556 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
557 (function-item gnus-thread-sort-by-author)
558 (function-item gnus-thread-sort-by-subject)
559 (function-item gnus-thread-sort-by-date)
560 (function-item gnus-thread-sort-by-score)
561 (function-item gnus-thread-sort-by-total-score)
562 (function :tag "other"))))
564 (defcustom gnus-thread-score-function '+
565 "*Function used for calculating the total score of a thread.
567 The function is called with the scores of the article and each
568 subthread and should then return the score of the thread.
570 Some functions you can use are `+', `max', or `min'."
571 :group 'gnus-summary-sort
574 (defcustom gnus-summary-expunge-below nil
575 "All articles that have a score less than this variable will be expunged."
576 :group 'gnus-score-default
577 :type '(choice (const :tag "off" nil)
580 (defcustom gnus-thread-expunge-below nil
581 "All threads that have a total score less than this variable will be expunged.
582 See `gnus-thread-score-function' for en explanation of what a
583 \"thread score\" is."
584 :group 'gnus-treading
585 :group 'gnus-score-default
586 :type '(choice (const :tag "off" nil)
589 (defcustom gnus-summary-mode-hook nil
590 "*A hook for Gnus summary mode.
591 This hook is run before any variables are set in the summary buffer."
592 :group 'gnus-summary-various
595 (defcustom gnus-summary-menu-hook nil
596 "*Hook run after the creation of the summary mode menu."
597 :group 'gnus-summary-visual
600 (defcustom gnus-summary-exit-hook nil
601 "*A hook called on exit from the summary buffer.
602 It will be called with point in the group buffer."
603 :group 'gnus-summary-exit
606 (defcustom gnus-summary-prepare-hook nil
607 "*A hook called after the summary buffer has been generated.
608 If you want to modify the summary buffer, you can use this hook."
609 :group 'gnus-summary-various
612 (defcustom gnus-summary-generate-hook nil
613 "*A hook run just before generating the summary buffer.
614 This hook is commonly used to customize threading variables and the
616 :group 'gnus-summary-various
619 (defcustom gnus-select-group-hook nil
620 "*A hook called when a newsgroup is selected.
622 If you'd like to simplify subjects like the
623 `gnus-summary-next-same-subject' command does, you can use the
626 (setq gnus-select-group-hook
629 (mapcar (lambda (header)
630 (mail-header-set-subject
632 (gnus-simplify-subject
633 (mail-header-subject header) 're-only)))
634 gnus-newsgroup-headers))))"
635 :group 'gnus-group-select
638 (defcustom gnus-select-article-hook nil
639 "*A hook called when an article is selected."
640 :group 'gnus-summary-choose
643 (defcustom gnus-visual-mark-article-hook
644 (list 'gnus-highlight-selected-summary)
645 "*Hook run after selecting an article in the summary buffer.
646 It is meant to be used for highlighting the article in some way. It
647 is not run if `gnus-visual' is nil."
648 :group 'gnus-summary-visual
651 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
652 (defcustom gnus-structured-field-decoder 'identity
653 "Function to decode non-ASCII characters in structured field for summary."
657 (defcustom gnus-unstructured-field-decoder 'identity
658 "Function to decode non-ASCII characters in unstructured field for summary."
662 (defcustom gnus-parse-headers-hook
663 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
664 "*A hook called before parsing the headers."
668 (defcustom gnus-exit-group-hook nil
669 "*A hook called when exiting (not quitting) summary mode."
673 (defcustom gnus-summary-update-hook
674 (list 'gnus-summary-highlight-line)
675 "*A hook called when a summary line is changed.
676 The hook will not be called if `gnus-visual' is nil.
678 The default function `gnus-summary-highlight-line' will
679 highlight the line according to the `gnus-summary-highlight'
681 :group 'gnus-summary-visual
684 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
685 "*A hook called when an article is selected for the first time.
686 The hook is intended to mark an article as read (or unread)
687 automatically when it is selected."
688 :group 'gnus-summary-choose
691 (defcustom gnus-group-no-more-groups-hook nil
692 "*A hook run when returning to group mode having no more (unread) groups."
693 :group 'gnus-group-select
696 (defcustom gnus-ps-print-hook nil
697 "*A hook run before ps-printing something from Gnus."
701 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
702 "Face used for highlighting the current article in the summary buffer."
703 :group 'gnus-summary-visual
706 (defcustom gnus-summary-highlight
707 '(((= mark gnus-canceled-mark)
708 . gnus-summary-cancelled-face)
709 ((and (> score default)
710 (or (= mark gnus-dormant-mark)
711 (= mark gnus-ticked-mark)))
712 . gnus-summary-high-ticked-face)
713 ((and (< score default)
714 (or (= mark gnus-dormant-mark)
715 (= mark gnus-ticked-mark)))
716 . gnus-summary-low-ticked-face)
717 ((or (= mark gnus-dormant-mark)
718 (= mark gnus-ticked-mark))
719 . gnus-summary-normal-ticked-face)
720 ((and (> score default) (= mark gnus-ancient-mark))
721 . gnus-summary-high-ancient-face)
722 ((and (< score default) (= mark gnus-ancient-mark))
723 . gnus-summary-low-ancient-face)
724 ((= mark gnus-ancient-mark)
725 . gnus-summary-normal-ancient-face)
726 ((and (> score default) (= mark gnus-unread-mark))
727 . gnus-summary-high-unread-face)
728 ((and (< score default) (= mark gnus-unread-mark))
729 . gnus-summary-low-unread-face)
730 ((and (= mark gnus-unread-mark))
731 . gnus-summary-normal-unread-face)
733 . gnus-summary-high-read-face)
735 . gnus-summary-low-read-face)
737 . gnus-summary-normal-read-face))
738 "Controls the highlighting of summary buffer lines.
740 A list of (FORM . FACE) pairs. When deciding how a a particular
741 summary line should be displayed, each form is evaluated. The content
742 of the face field after the first true form is used. You can change
743 how those summary lines are displayed, by editing the face field.
745 You can use the following variables in the FORM field.
747 score: The articles score
748 default: The default article score.
749 below: The score below which articles are automatically marked as read.
750 mark: The articles mark."
751 :group 'gnus-summary-visual
752 :type '(repeat (cons (sexp :tag "Form" nil)
755 (defcustom gnus-alter-header-function nil
756 "Function called to allow alteration of article header structures.
757 The function is called with one parameter, the article header vector,
758 which it may alter in any way.")
760 ;;; Internal variables
762 (defvar gnus-scores-exclude-files nil)
763 (defvar gnus-page-broken nil)
765 (defvar gnus-original-article nil)
766 (defvar gnus-article-internal-prepare-hook nil)
767 (defvar gnus-newsgroup-process-stack nil)
769 (defvar gnus-thread-indent-array nil)
770 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
772 ;; Avoid highlighting in kill files.
773 (defvar gnus-summary-inhibit-highlight nil)
774 (defvar gnus-newsgroup-selected-overlay nil)
775 (defvar gnus-inhibit-limiting nil)
776 (defvar gnus-newsgroup-adaptive-score-file nil)
777 (defvar gnus-current-score-file nil)
778 (defvar gnus-current-move-group nil)
779 (defvar gnus-current-copy-group nil)
780 (defvar gnus-current-crosspost-group nil)
782 (defvar gnus-newsgroup-dependencies nil)
783 (defvar gnus-newsgroup-adaptive nil)
784 (defvar gnus-summary-display-article-function nil)
785 (defvar gnus-summary-highlight-line-function nil
786 "Function called after highlighting a summary line.")
788 (defvar gnus-summary-line-format-alist
789 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
790 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
791 (?s gnus-tmp-subject-or-nil ?s)
792 (?n gnus-tmp-name ?s)
793 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
795 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
797 (?F gnus-tmp-from ?s)
798 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
799 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
800 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
801 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
802 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
803 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
804 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
805 (?L gnus-tmp-lines ?d)
806 (?I gnus-tmp-indentation ?s)
807 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
808 (?R gnus-tmp-replied ?c)
809 (?\[ gnus-tmp-opening-bracket ?c)
810 (?\] gnus-tmp-closing-bracket ?c)
811 (?\> (make-string gnus-tmp-level ? ) ?s)
812 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
813 (?i gnus-tmp-score ?d)
814 (?z gnus-tmp-score-char ?c)
815 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
816 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
817 (?U gnus-tmp-unread ?c)
818 (?t (gnus-summary-number-of-articles-in-thread
819 (and (boundp 'thread) (car thread)) gnus-tmp-level)
821 (?e (gnus-summary-number-of-articles-in-thread
822 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
824 (?u gnus-tmp-user-defined ?s)
825 (?P (gnus-pick-line-number) ?d))
826 "An alist of format specifications that can appear in summary lines,
827 and what variables they correspond with, along with the type of the
828 variable (string, integer, character, etc).")
830 (defvar gnus-summary-dummy-line-format-alist
831 `((?S gnus-tmp-subject ?s)
832 (?N gnus-tmp-number ?d)
833 (?u gnus-tmp-user-defined ?s)))
835 (defvar gnus-summary-mode-line-format-alist
836 `((?G gnus-tmp-group-name ?s)
837 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
838 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
839 (?A gnus-tmp-article-number ?d)
840 (?Z gnus-tmp-unread-and-unselected ?s)
842 (?U gnus-tmp-unread-and-unticked ?d)
843 (?S gnus-tmp-subject ?s)
844 (?e gnus-tmp-unselected ?d)
845 (?u gnus-tmp-user-defined ?s)
846 (?d (length gnus-newsgroup-dormant) ?d)
847 (?t (length gnus-newsgroup-marked) ?d)
848 (?r (length gnus-newsgroup-reads) ?d)
849 (?E gnus-newsgroup-expunged-tally ?d)
850 (?s (gnus-current-score-file-nondirectory) ?s)))
852 (defvar gnus-last-search-regexp nil
853 "Default regexp for article search command.")
855 (defvar gnus-last-shell-command nil
856 "Default shell command on article.")
858 (defvar gnus-newsgroup-begin nil)
859 (defvar gnus-newsgroup-end nil)
860 (defvar gnus-newsgroup-last-rmail nil)
861 (defvar gnus-newsgroup-last-mail nil)
862 (defvar gnus-newsgroup-last-folder nil)
863 (defvar gnus-newsgroup-last-file nil)
864 (defvar gnus-newsgroup-auto-expire nil)
865 (defvar gnus-newsgroup-active nil)
867 (defvar gnus-newsgroup-data nil)
868 (defvar gnus-newsgroup-data-reverse nil)
869 (defvar gnus-newsgroup-limit nil)
870 (defvar gnus-newsgroup-limits nil)
872 (defvar gnus-newsgroup-unreads nil
873 "List of unread articles in the current newsgroup.")
875 (defvar gnus-newsgroup-unselected nil
876 "List of unselected unread articles in the current newsgroup.")
878 (defvar gnus-newsgroup-reads nil
879 "Alist of read articles and article marks in the current newsgroup.")
881 (defvar gnus-newsgroup-expunged-tally nil)
883 (defvar gnus-newsgroup-marked nil
884 "List of ticked articles in the current newsgroup (a subset of unread art).")
886 (defvar gnus-newsgroup-killed nil
887 "List of ranges of articles that have been through the scoring process.")
889 (defvar gnus-newsgroup-cached nil
890 "List of articles that come from the article cache.")
892 (defvar gnus-newsgroup-saved nil
893 "List of articles that have been saved.")
895 (defvar gnus-newsgroup-kill-headers nil)
897 (defvar gnus-newsgroup-replied nil
898 "List of articles that have been replied to in the current newsgroup.")
900 (defvar gnus-newsgroup-expirable nil
901 "List of articles in the current newsgroup that can be expired.")
903 (defvar gnus-newsgroup-processable nil
904 "List of articles in the current newsgroup that can be processed.")
906 (defvar gnus-newsgroup-downloadable nil
907 "List of articles in the current newsgroup that can be processed.")
909 (defvar gnus-newsgroup-undownloaded nil
910 "List of articles in the current newsgroup that haven't been downloaded..")
912 (defvar gnus-newsgroup-unsendable nil
913 "List of articles in the current newsgroup that won't be sent.")
915 (defvar gnus-newsgroup-bookmarks nil
916 "List of articles in the current newsgroup that have bookmarks.")
918 (defvar gnus-newsgroup-dormant nil
919 "List of dormant articles in the current newsgroup.")
921 (defvar gnus-newsgroup-scored nil
922 "List of scored articles in the current newsgroup.")
924 (defvar gnus-newsgroup-headers nil
925 "List of article headers in the current newsgroup.")
927 (defvar gnus-newsgroup-threads nil)
929 (defvar gnus-newsgroup-prepared nil
930 "Whether the current group has been prepared properly.")
932 (defvar gnus-newsgroup-ancient nil
933 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
935 (defvar gnus-newsgroup-sparse nil)
937 (defvar gnus-current-article nil)
938 (defvar gnus-article-current nil)
939 (defvar gnus-current-headers nil)
940 (defvar gnus-have-all-headers nil)
941 (defvar gnus-last-article nil)
942 (defvar gnus-newsgroup-history nil)
944 (defconst gnus-summary-local-variables
945 '(gnus-newsgroup-name
946 gnus-newsgroup-begin gnus-newsgroup-end
947 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
948 gnus-newsgroup-last-folder gnus-newsgroup-last-file
949 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
950 gnus-newsgroup-unselected gnus-newsgroup-marked
951 gnus-newsgroup-reads gnus-newsgroup-saved
952 gnus-newsgroup-replied gnus-newsgroup-expirable
953 gnus-newsgroup-processable gnus-newsgroup-killed
954 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
955 gnus-newsgroup-unsendable
956 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
957 gnus-newsgroup-headers gnus-newsgroup-threads
958 gnus-newsgroup-prepared gnus-summary-highlight-line-function
959 gnus-current-article gnus-current-headers gnus-have-all-headers
960 gnus-last-article gnus-article-internal-prepare-hook
961 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
962 gnus-newsgroup-scored gnus-newsgroup-kill-headers
963 gnus-thread-expunge-below
964 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
965 (gnus-summary-mark-below . global)
966 gnus-newsgroup-active gnus-scores-exclude-files
967 gnus-newsgroup-history gnus-newsgroup-ancient
968 gnus-newsgroup-sparse gnus-newsgroup-process-stack
969 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
970 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
971 (gnus-newsgroup-expunged-tally . 0)
972 gnus-cache-removable-articles gnus-newsgroup-cached
973 gnus-newsgroup-data gnus-newsgroup-data-reverse
974 gnus-newsgroup-limit gnus-newsgroup-limits)
975 "Variables that are buffer-local to the summary buffers.")
977 ;; Byte-compiler warning.
978 (defvar gnus-article-mode-map)
980 ;; Subject simplification.
982 (defun gnus-simplify-whitespace (str)
983 "Remove excessive whitespace."
986 (while (string-match "[ \t][ \t]+" mystr)
987 (setq mystr (concat (substring mystr 0 (match-beginning 0))
989 (substring mystr (match-end 0)))))
991 (when (string-match "^[ \t]+" mystr)
992 (setq mystr (substring mystr (match-end 0))))
994 (when (string-match "[ \t]+$" mystr)
995 (setq mystr (substring mystr 0 (match-beginning 0))))
998 (defsubst gnus-simplify-subject-re (subject)
999 "Remove \"Re:\" from subject lines."
1000 (if (string-match "^[Rr][Ee]: *" subject)
1001 (substring subject (match-end 0))
1004 (defun gnus-simplify-subject (subject &optional re-only)
1005 "Remove `Re:' and words in parentheses.
1006 If RE-ONLY is non-nil, strip leading `Re:'s only."
1007 (let ((case-fold-search t)) ;Ignore case.
1008 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1009 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1010 (setq subject (substring subject (match-end 0))))
1011 ;; Remove uninteresting prefixes.
1012 (when (and (not re-only)
1013 gnus-simplify-ignored-prefixes
1014 (string-match gnus-simplify-ignored-prefixes subject))
1015 (setq subject (substring subject (match-end 0))))
1016 ;; Remove words in parentheses from end.
1018 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1019 (setq subject (substring subject 0 (match-beginning 0)))))
1020 ;; Return subject string.
1023 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1025 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1026 (goto-char (point-min))
1027 (while (re-search-forward regexp nil t)
1028 (replace-match (or newtext ""))))
1030 (defun gnus-simplify-buffer-fuzzy ()
1031 "Simplify string in the buffer fuzzily.
1032 The string in the accessible portion of the current buffer is simplified.
1033 It is assumed to be a single-line subject.
1034 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1035 matter is removed. Additional things can be deleted by setting
1036 gnus-simplify-subject-fuzzy-regexp."
1037 (let ((case-fold-search t)
1039 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1041 (while (not (eq modified-tick (buffer-modified-tick)))
1042 (setq modified-tick (buffer-modified-tick))
1044 ((listp gnus-simplify-subject-fuzzy-regexp)
1045 (mapcar 'gnus-simplify-buffer-fuzzy-step
1046 gnus-simplify-subject-fuzzy-regexp))
1047 (gnus-simplify-subject-fuzzy-regexp
1048 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1049 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1050 (gnus-simplify-buffer-fuzzy-step
1051 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1052 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1054 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1055 (gnus-simplify-buffer-fuzzy-step " +" " ")
1056 (gnus-simplify-buffer-fuzzy-step " $")
1057 (gnus-simplify-buffer-fuzzy-step "^ +")))
1059 (defun gnus-simplify-subject-fuzzy (subject)
1060 "Simplify a subject string fuzzily.
1061 See `gnus-simplify-buffer-fuzzy' for details."
1063 (gnus-set-work-buffer)
1064 (let ((case-fold-search t))
1066 (inline (gnus-simplify-buffer-fuzzy))
1069 (defsubst gnus-simplify-subject-fully (subject)
1070 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1072 (gnus-simplify-subject-functions
1073 (gnus-map-function gnus-simplify-subject-functions subject))
1074 ((null gnus-summary-gather-subject-limit)
1075 (gnus-simplify-subject-re subject))
1076 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1077 (gnus-simplify-subject-fuzzy subject))
1078 ((numberp gnus-summary-gather-subject-limit)
1079 (gnus-limit-string (gnus-simplify-subject-re subject)
1080 gnus-summary-gather-subject-limit))
1084 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1085 "Check whether two subjects are equal.
1086 If optional argument simple-first is t, first argument is already
1089 ((null simple-first)
1090 (equal (gnus-simplify-subject-fully s1)
1091 (gnus-simplify-subject-fully s2)))
1094 (gnus-simplify-subject-fully s2)))))
1096 (defun gnus-summary-bubble-group ()
1097 "Increase the score of the current group.
1098 This is a handy function to add to `gnus-summary-exit-hook' to
1099 increase the score of each group you read."
1100 (gnus-group-add-score gnus-newsgroup-name))
1104 ;;; Gnus summary mode
1107 (put 'gnus-summary-mode 'mode-class 'special)
1110 ;; Non-orthogonal keys
1112 (gnus-define-keys gnus-summary-mode-map
1113 " " gnus-summary-next-page
1114 "\177" gnus-summary-prev-page
1115 [delete] gnus-summary-prev-page
1116 "\r" gnus-summary-scroll-up
1117 "n" gnus-summary-next-unread-article
1118 "p" gnus-summary-prev-unread-article
1119 "N" gnus-summary-next-article
1120 "P" gnus-summary-prev-article
1121 "\M-\C-n" gnus-summary-next-same-subject
1122 "\M-\C-p" gnus-summary-prev-same-subject
1123 "\M-n" gnus-summary-next-unread-subject
1124 "\M-p" gnus-summary-prev-unread-subject
1125 "." gnus-summary-first-unread-article
1126 "," gnus-summary-best-unread-article
1127 "\M-s" gnus-summary-search-article-forward
1128 "\M-r" gnus-summary-search-article-backward
1129 "<" gnus-summary-beginning-of-article
1130 ">" gnus-summary-end-of-article
1131 "j" gnus-summary-goto-article
1132 "^" gnus-summary-refer-parent-article
1133 "\M-^" gnus-summary-refer-article
1134 "u" gnus-summary-tick-article-forward
1135 "!" gnus-summary-tick-article-forward
1136 "U" gnus-summary-tick-article-backward
1137 "d" gnus-summary-mark-as-read-forward
1138 "D" gnus-summary-mark-as-read-backward
1139 "E" gnus-summary-mark-as-expirable
1140 "\M-u" gnus-summary-clear-mark-forward
1141 "\M-U" gnus-summary-clear-mark-backward
1142 "k" gnus-summary-kill-same-subject-and-select
1143 "\C-k" gnus-summary-kill-same-subject
1144 "\M-\C-k" gnus-summary-kill-thread
1145 "\M-\C-l" gnus-summary-lower-thread
1146 "e" gnus-summary-edit-article
1147 "#" gnus-summary-mark-as-processable
1148 "\M-#" gnus-summary-unmark-as-processable
1149 "\M-\C-t" gnus-summary-toggle-threads
1150 "\M-\C-s" gnus-summary-show-thread
1151 "\M-\C-h" gnus-summary-hide-thread
1152 "\M-\C-f" gnus-summary-next-thread
1153 "\M-\C-b" gnus-summary-prev-thread
1154 "\M-\C-u" gnus-summary-up-thread
1155 "\M-\C-d" gnus-summary-down-thread
1156 "&" gnus-summary-execute-command
1157 "c" gnus-summary-catchup-and-exit
1158 "\C-w" gnus-summary-mark-region-as-read
1159 "\C-t" gnus-summary-toggle-truncation
1160 "?" gnus-summary-mark-as-dormant
1161 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1162 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1163 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1164 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1165 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1166 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1167 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1168 "=" gnus-summary-expand-window
1169 "\C-x\C-s" gnus-summary-reselect-current-group
1170 "\M-g" gnus-summary-rescan-group
1171 "w" gnus-summary-stop-page-breaking
1172 "\C-c\C-r" gnus-summary-caesar-message
1173 "\M-t" gnus-summary-toggle-mime
1174 "f" gnus-summary-followup
1175 "F" gnus-summary-followup-with-original
1176 "C" gnus-summary-cancel-article
1177 "r" gnus-summary-reply
1178 "R" gnus-summary-reply-with-original
1179 "\C-c\C-f" gnus-summary-mail-forward
1180 "o" gnus-summary-save-article
1181 "\C-o" gnus-summary-save-article-mail
1182 "|" gnus-summary-pipe-output
1183 "\M-k" gnus-summary-edit-local-kill
1184 "\M-K" gnus-summary-edit-global-kill
1186 "\C-c\C-d" gnus-summary-describe-group
1187 "q" gnus-summary-exit
1188 "Q" gnus-summary-exit-no-update
1189 "\C-c\C-i" gnus-info-find-node
1190 gnus-mouse-2 gnus-mouse-pick-article
1191 "m" gnus-summary-mail-other-window
1192 "a" gnus-summary-post-news
1193 "x" gnus-summary-limit-to-unread
1194 "s" gnus-summary-isearch-article
1195 "t" gnus-article-hide-headers
1196 "g" gnus-summary-show-article
1197 "l" gnus-summary-goto-last-article
1198 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1199 "\C-d" gnus-summary-enter-digest-group
1200 "\M-\C-d" gnus-summary-read-document
1202 "*" gnus-cache-enter-article
1203 "\M-*" gnus-cache-remove-article
1204 "\M-&" gnus-summary-universal-argument
1205 "\C-l" gnus-recenter
1206 "I" gnus-summary-increase-score
1207 "L" gnus-summary-lower-score
1208 "\M-i" gnus-symbolic-argument
1209 "h" gnus-summary-select-article-buffer
1211 "V" gnus-summary-score-map
1212 "X" gnus-uu-extract-map
1213 "S" gnus-summary-send-map)
1215 ;; Sort of orthogonal keymap
1216 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1217 "t" gnus-summary-tick-article-forward
1218 "!" gnus-summary-tick-article-forward
1219 "d" gnus-summary-mark-as-read-forward
1220 "r" gnus-summary-mark-as-read-forward
1221 "c" gnus-summary-clear-mark-forward
1222 " " gnus-summary-clear-mark-forward
1223 "e" gnus-summary-mark-as-expirable
1224 "x" gnus-summary-mark-as-expirable
1225 "?" gnus-summary-mark-as-dormant
1226 "b" gnus-summary-set-bookmark
1227 "B" gnus-summary-remove-bookmark
1228 "#" gnus-summary-mark-as-processable
1229 "\M-#" gnus-summary-unmark-as-processable
1230 "S" gnus-summary-limit-include-expunged
1231 "C" gnus-summary-catchup
1232 "H" gnus-summary-catchup-to-here
1233 "\C-c" gnus-summary-catchup-all
1234 "k" gnus-summary-kill-same-subject-and-select
1235 "K" gnus-summary-kill-same-subject
1236 "P" gnus-uu-mark-map)
1238 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1239 "c" gnus-summary-clear-above
1240 "u" gnus-summary-tick-above
1241 "m" gnus-summary-mark-above
1242 "k" gnus-summary-kill-below)
1244 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1245 "/" gnus-summary-limit-to-subject
1246 "n" gnus-summary-limit-to-articles
1247 "w" gnus-summary-pop-limit
1248 "s" gnus-summary-limit-to-subject
1249 "a" gnus-summary-limit-to-author
1250 "u" gnus-summary-limit-to-unread
1251 "m" gnus-summary-limit-to-marks
1252 "v" gnus-summary-limit-to-score
1253 "*" gnus-summary-limit-include-cached
1254 "D" gnus-summary-limit-include-dormant
1255 "T" gnus-summary-limit-include-thread
1256 "d" gnus-summary-limit-exclude-dormant
1257 "t" gnus-summary-limit-to-age
1258 "E" gnus-summary-limit-include-expunged
1259 "c" gnus-summary-limit-exclude-childless-dormant
1260 "C" gnus-summary-limit-mark-excluded-as-read)
1262 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1263 "n" gnus-summary-next-unread-article
1264 "p" gnus-summary-prev-unread-article
1265 "N" gnus-summary-next-article
1266 "P" gnus-summary-prev-article
1267 "\C-n" gnus-summary-next-same-subject
1268 "\C-p" gnus-summary-prev-same-subject
1269 "\M-n" gnus-summary-next-unread-subject
1270 "\M-p" gnus-summary-prev-unread-subject
1271 "f" gnus-summary-first-unread-article
1272 "b" gnus-summary-best-unread-article
1273 "j" gnus-summary-goto-article
1274 "g" gnus-summary-goto-subject
1275 "l" gnus-summary-goto-last-article
1276 "o" gnus-summary-pop-article)
1278 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1279 "k" gnus-summary-kill-thread
1280 "l" gnus-summary-lower-thread
1281 "i" gnus-summary-raise-thread
1282 "T" gnus-summary-toggle-threads
1283 "t" gnus-summary-rethread-current
1284 "^" gnus-summary-reparent-thread
1285 "s" gnus-summary-show-thread
1286 "S" gnus-summary-show-all-threads
1287 "h" gnus-summary-hide-thread
1288 "H" gnus-summary-hide-all-threads
1289 "n" gnus-summary-next-thread
1290 "p" gnus-summary-prev-thread
1291 "u" gnus-summary-up-thread
1292 "o" gnus-summary-top-thread
1293 "d" gnus-summary-down-thread
1294 "#" gnus-uu-mark-thread
1295 "\M-#" gnus-uu-unmark-thread)
1297 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1298 "g" gnus-summary-prepare
1299 "c" gnus-summary-insert-cached-articles)
1301 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1302 "c" gnus-summary-catchup-and-exit
1303 "C" gnus-summary-catchup-all-and-exit
1304 "E" gnus-summary-exit-no-update
1305 "Q" gnus-summary-exit
1306 "Z" gnus-summary-exit
1307 "n" gnus-summary-catchup-and-goto-next-group
1308 "R" gnus-summary-reselect-current-group
1309 "G" gnus-summary-rescan-group
1310 "N" gnus-summary-next-group
1311 "s" gnus-summary-save-newsrc
1312 "P" gnus-summary-prev-group)
1314 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1315 " " gnus-summary-next-page
1316 "n" gnus-summary-next-page
1317 "\177" gnus-summary-prev-page
1318 [delete] gnus-summary-prev-page
1319 "p" gnus-summary-prev-page
1320 "\r" gnus-summary-scroll-up
1321 "<" gnus-summary-beginning-of-article
1322 ">" gnus-summary-end-of-article
1323 "b" gnus-summary-beginning-of-article
1324 "e" gnus-summary-end-of-article
1325 "^" gnus-summary-refer-parent-article
1326 "r" gnus-summary-refer-parent-article
1327 "R" gnus-summary-refer-references
1328 "T" gnus-summary-refer-thread
1329 "g" gnus-summary-show-article
1330 "s" gnus-summary-isearch-article
1331 "P" gnus-summary-print-article)
1333 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1334 "b" gnus-article-add-buttons
1335 "B" gnus-article-add-buttons-to-head
1336 "o" gnus-article-treat-overstrike
1337 "e" gnus-article-emphasize
1338 "w" gnus-article-fill-cited-article
1339 "c" gnus-article-remove-cr
1340 "q" gnus-article-de-quoted-unreadable
1341 "f" gnus-article-display-x-face
1342 "l" gnus-summary-stop-page-breaking
1343 "r" gnus-summary-caesar-message
1344 "t" gnus-article-hide-headers
1345 "v" gnus-summary-verbose-headers
1346 "m" gnus-summary-toggle-mime
1347 "h" gnus-article-treat-html
1348 "d" gnus-article-treat-dumbquotes)
1350 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1351 "a" gnus-article-hide
1352 "h" gnus-article-hide-headers
1353 "b" gnus-article-hide-boring-headers
1354 "s" gnus-article-hide-signature
1355 "c" gnus-article-hide-citation
1356 "p" gnus-article-hide-pgp
1357 "P" gnus-article-hide-pem
1358 "\C-c" gnus-article-hide-citation-maybe)
1360 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1361 "a" gnus-article-highlight
1362 "h" gnus-article-highlight-headers
1363 "c" gnus-article-highlight-citation
1364 "s" gnus-article-highlight-signature)
1366 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1367 "z" gnus-article-date-ut
1368 "u" gnus-article-date-ut
1369 "l" gnus-article-date-local
1370 "e" gnus-article-date-lapsed
1371 "o" gnus-article-date-original
1372 "s" gnus-article-date-user)
1374 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1375 "t" gnus-article-remove-trailing-blank-lines
1376 "l" gnus-article-strip-leading-blank-lines
1377 "m" gnus-article-strip-multiple-blank-lines
1378 "a" gnus-article-strip-blank-lines
1379 "s" gnus-article-strip-leading-space)
1381 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1383 "f" gnus-summary-fetch-faq
1384 "d" gnus-summary-describe-group
1385 "h" gnus-summary-describe-briefly
1386 "i" gnus-info-find-node)
1388 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1389 "e" gnus-summary-expire-articles
1390 "\M-\C-e" gnus-summary-expire-articles-now
1391 "\177" gnus-summary-delete-article
1392 [delete] gnus-summary-delete-article
1393 "m" gnus-summary-move-article
1394 "r" gnus-summary-respool-article
1395 "w" gnus-summary-edit-article
1396 "c" gnus-summary-copy-article
1397 "B" gnus-summary-crosspost-article
1398 "q" gnus-summary-respool-query
1399 "i" gnus-summary-import-article
1400 "p" gnus-summary-article-posted-p)
1402 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1403 "o" gnus-summary-save-article
1404 "m" gnus-summary-save-article-mail
1405 "F" gnus-summary-write-article-file
1406 "r" gnus-summary-save-article-rmail
1407 "f" gnus-summary-save-article-file
1408 "b" gnus-summary-save-article-body-file
1409 "h" gnus-summary-save-article-folder
1410 "v" gnus-summary-save-article-vm
1411 "p" gnus-summary-pipe-output
1412 "s" gnus-soup-add-article))
1414 (defun gnus-summary-make-menu-bar ()
1415 (gnus-turn-off-edit-menu 'summary)
1417 (unless (boundp 'gnus-summary-misc-menu)
1420 gnus-summary-kill-menu gnus-summary-mode-map ""
1425 ["Enter score..." gnus-summary-score-entry t]
1426 ["Customize" gnus-score-customize t])
1427 (gnus-make-score-map 'increase)
1428 (gnus-make-score-map 'lower)
1430 ["Kill below" gnus-summary-kill-below t]
1431 ["Mark above" gnus-summary-mark-above t]
1432 ["Tick above" gnus-summary-tick-above t]
1433 ["Clear above" gnus-summary-clear-above t])
1434 ["Current score" gnus-summary-current-score t]
1435 ["Set score" gnus-summary-set-score t]
1436 ["Switch current score file..." gnus-score-change-score-file t]
1437 ["Set mark below..." gnus-score-set-mark-below t]
1438 ["Set expunge below..." gnus-score-set-expunge-below t]
1439 ["Edit current score file" gnus-score-edit-current-scores t]
1440 ["Edit score file" gnus-score-edit-file t]
1441 ["Trace score" gnus-score-find-trace t]
1442 ["Find words" gnus-score-find-favourite-words t]
1443 ["Rescore buffer" gnus-summary-rescore t]
1444 ["Increase score..." gnus-summary-increase-score t]
1445 ["Lower score..." gnus-summary-lower-score t]))))
1448 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1450 :selected (null gnus-score-default-header)]
1451 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1453 :selected (eq gnus-score-default-header 'a)]
1454 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1456 :selected (eq gnus-score-default-header 's)]
1458 (gnus-score-set-default 'gnus-score-default-header 'b)
1460 :selected (eq gnus-score-default-header 'b )]
1462 (gnus-score-set-default 'gnus-score-default-header 'h)
1464 :selected (eq gnus-score-default-header 'h )]
1465 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1467 :selected (eq gnus-score-default-header 'i )]
1468 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1470 :selected (eq gnus-score-default-header 't )]
1472 (gnus-score-set-default 'gnus-score-default-header 'x)
1474 :selected (eq gnus-score-default-header 'x )]
1475 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1477 :selected (eq gnus-score-default-header 'l )]
1478 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1480 :selected (eq gnus-score-default-header 'd )]
1481 ["Followups to author"
1482 (gnus-score-set-default 'gnus-score-default-header 'f)
1484 :selected (eq gnus-score-default-header 'f )])
1486 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1488 :selected (null gnus-score-default-type)]
1489 ;; The `:active' key is commented out in the following,
1490 ;; because the GNU Emacs hack to support radio buttons use
1491 ;; active to indicate which button is selected.
1492 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1494 ;; :active (not (memq gnus-score-default-header '(l d)))
1495 :selected (eq gnus-score-default-type 's)]
1496 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1498 ;; :active (not (memq gnus-score-default-header '(l d)))
1499 :selected (eq gnus-score-default-type 'r)]
1500 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1502 ;; :active (not (memq gnus-score-default-header '(l d)))
1503 :selected (eq gnus-score-default-type 'e)]
1504 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1506 ;; :active (not (memq gnus-score-default-header '(l d)))
1507 :selected (eq gnus-score-default-type 'f)]
1508 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1510 ;; :active (eq (gnus-score-default-header 'd))
1511 :selected (eq gnus-score-default-type 'b)]
1512 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1514 ;; :active (eq (gnus-score-default-header 'd))
1515 :selected (eq gnus-score-default-type 'n)]
1516 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1518 ;; :active (eq (gnus-score-default-header 'd))
1519 :selected (eq gnus-score-default-type 'a)]
1521 (gnus-score-set-default 'gnus-score-default-type '<)
1523 ;; :active (eq (gnus-score-default-header 'l))
1524 :selected (eq gnus-score-default-type '<)]
1526 (gnus-score-set-default 'gnus-score-default-type '=)
1528 ;; :active (eq (gnus-score-default-header 'l))
1529 :selected (eq gnus-score-default-type '=)]
1530 ["Greater than number"
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 ["Default fold" gnus-score-default-fold-toggle
1537 :selected gnus-score-default-fold]
1539 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1541 :selected (null gnus-score-default-duration)]
1543 (gnus-score-set-default 'gnus-score-default-duration 'p)
1545 :selected (eq gnus-score-default-duration 'p)]
1547 (gnus-score-set-default 'gnus-score-default-duration 't)
1549 :selected (eq gnus-score-default-duration 't)]
1551 (gnus-score-set-default 'gnus-score-default-duration 'i)
1553 :selected (eq gnus-score-default-duration 'i)]))
1556 gnus-summary-article-menu gnus-summary-mode-map ""
1559 ["All" gnus-article-hide t]
1560 ["Headers" gnus-article-hide-headers t]
1561 ["Signature" gnus-article-hide-signature t]
1562 ["Citation" gnus-article-hide-citation t]
1563 ["PGP" gnus-article-hide-pgp t]
1564 ["Boring headers" gnus-article-hide-boring-headers t])
1566 ["All" gnus-article-highlight t]
1567 ["Headers" gnus-article-highlight-headers t]
1568 ["Signature" gnus-article-highlight-signature t]
1569 ["Citation" gnus-article-highlight-citation t])
1571 ["Local" gnus-article-date-local t]
1572 ["UT" gnus-article-date-ut t]
1573 ["Original" gnus-article-date-original t]
1574 ["Lapsed" gnus-article-date-lapsed t]
1575 ["User-defined" gnus-article-date-user t])
1578 ["Leading" gnus-article-strip-leading-blank-lines t]
1579 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1580 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1581 ["All of the above" gnus-article-strip-blank-lines t]
1582 ["Leading space" gnus-article-strip-leading-space t])
1583 ["Overstrike" gnus-article-treat-overstrike t]
1584 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1585 ["Emphasis" gnus-article-emphasize t]
1586 ["Word wrap" gnus-article-fill-cited-article t]
1587 ["CR" gnus-article-remove-cr t]
1588 ["Show X-Face" gnus-article-display-x-face t]
1589 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1590 ["UnHTMLize" gnus-article-treat-html t]
1591 ["Rot 13" gnus-summary-caesar-message t]
1592 ["Unix pipe" gnus-summary-pipe-message t]
1593 ["Add buttons" gnus-article-add-buttons t]
1594 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1595 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1596 ["Toggle MIME" gnus-summary-toggle-mime t]
1597 ["Verbose header" gnus-summary-verbose-headers t]
1598 ["Toggle header" gnus-summary-toggle-header t])
1600 ["Save in default format" gnus-summary-save-article t]
1601 ["Save in file" gnus-summary-save-article-file t]
1602 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1603 ["Write to file" gnus-summary-write-article-mail t]
1604 ["Save in MH folder" gnus-summary-save-article-folder t]
1605 ["Save in VM folder" gnus-summary-save-article-vm t]
1606 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1607 ["Save body in file" gnus-summary-save-article-body-file t]
1608 ["Pipe through a filter" gnus-summary-pipe-output t]
1609 ["Add to SOUP packet" gnus-soup-add-article t]
1610 ["Print" gnus-summary-print-article t])
1612 ["Respool article..." gnus-summary-respool-article t]
1613 ["Move article..." gnus-summary-move-article
1614 (gnus-check-backend-function
1615 'request-move-article gnus-newsgroup-name)]
1616 ["Copy article..." gnus-summary-copy-article t]
1617 ["Crosspost article..." gnus-summary-crosspost-article
1618 (gnus-check-backend-function
1619 'request-replace-article gnus-newsgroup-name)]
1620 ["Import file..." gnus-summary-import-article t]
1621 ["Check if posted" gnus-summary-article-posted-p t]
1622 ["Edit article" gnus-summary-edit-article
1623 (not (gnus-group-read-only-p))]
1624 ["Delete article" gnus-summary-delete-article
1625 (gnus-check-backend-function
1626 'request-expire-articles gnus-newsgroup-name)]
1627 ["Query respool" gnus-summary-respool-query t]
1628 ["Delete expirable articles" gnus-summary-expire-articles-now
1629 (gnus-check-backend-function
1630 'request-expire-articles gnus-newsgroup-name)])
1632 ["Uudecode" gnus-uu-decode-uu t]
1633 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1634 ["Unshar" gnus-uu-decode-unshar t]
1635 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1636 ["Save" gnus-uu-decode-save t]
1637 ["Binhex" gnus-uu-decode-binhex t]
1638 ["Postscript" gnus-uu-decode-postscript t])
1640 ["Enter article" gnus-cache-enter-article t]
1641 ["Remove article" gnus-cache-remove-article t])
1642 ["Select article buffer" gnus-summary-select-article-buffer t]
1643 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1644 ["Isearch article..." gnus-summary-isearch-article t]
1645 ["Beginning of the article" gnus-summary-beginning-of-article t]
1646 ["End of the article" gnus-summary-end-of-article t]
1647 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1648 ["Fetch referenced articles" gnus-summary-refer-references t]
1649 ["Fetch current thread" gnus-summary-refer-thread t]
1650 ["Fetch article with id..." gnus-summary-refer-article t]
1651 ["Redisplay" gnus-summary-show-article t]))
1654 gnus-summary-thread-menu gnus-summary-mode-map ""
1656 ["Toggle threading" gnus-summary-toggle-threads t]
1657 ["Hide threads" gnus-summary-hide-all-threads t]
1658 ["Show threads" gnus-summary-show-all-threads t]
1659 ["Hide thread" gnus-summary-hide-thread t]
1660 ["Show thread" gnus-summary-show-thread t]
1661 ["Go to next thread" gnus-summary-next-thread t]
1662 ["Go to previous thread" gnus-summary-prev-thread t]
1663 ["Go down thread" gnus-summary-down-thread t]
1664 ["Go up thread" gnus-summary-up-thread t]
1665 ["Top of thread" gnus-summary-top-thread t]
1666 ["Mark thread as read" gnus-summary-kill-thread t]
1667 ["Lower thread score" gnus-summary-lower-thread t]
1668 ["Raise thread score" gnus-summary-raise-thread t]
1669 ["Rethread current" gnus-summary-rethread-current t]
1673 gnus-summary-post-menu gnus-summary-mode-map ""
1675 ["Post an article" gnus-summary-post-news t]
1676 ["Followup" gnus-summary-followup t]
1677 ["Followup and yank" gnus-summary-followup-with-original t]
1678 ["Supersede article" gnus-summary-supersede-article t]
1679 ["Cancel article" gnus-summary-cancel-article t]
1680 ["Reply" gnus-summary-reply t]
1681 ["Reply and yank" gnus-summary-reply-with-original t]
1682 ["Wide reply" gnus-summary-wide-reply t]
1683 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1684 ["Mail forward" gnus-summary-mail-forward t]
1685 ["Post forward" gnus-summary-post-forward t]
1686 ["Digest and mail" gnus-uu-digest-mail-forward t]
1687 ["Digest and post" gnus-uu-digest-post-forward t]
1688 ["Resend message" gnus-summary-resend-message t]
1689 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1690 ["Send a mail" gnus-summary-mail-other-window t]
1691 ["Uuencode and post" gnus-uu-post-news t]
1692 ["Followup via news" gnus-summary-followup-to-mail t]
1693 ["Followup via news and yank"
1694 gnus-summary-followup-to-mail-with-original t]
1696 ;;["Send" gnus-summary-send-draft t]
1697 ;;["Send bounced" gnus-resend-bounced-mail t])
1701 gnus-summary-misc-menu gnus-summary-mode-map ""
1704 ["Mark as read" gnus-summary-mark-as-read-forward t]
1705 ["Mark same subject and select"
1706 gnus-summary-kill-same-subject-and-select t]
1707 ["Mark same subject" gnus-summary-kill-same-subject t]
1708 ["Catchup" gnus-summary-catchup t]
1709 ["Catchup all" gnus-summary-catchup-all t]
1710 ["Catchup to here" gnus-summary-catchup-to-here t]
1711 ["Catchup region" gnus-summary-mark-region-as-read t]
1712 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1714 ["Tick" gnus-summary-tick-article-forward t]
1715 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1716 ["Remove marks" gnus-summary-clear-mark-forward t]
1717 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1718 ["Set bookmark" gnus-summary-set-bookmark t]
1719 ["Remove bookmark" gnus-summary-remove-bookmark t])
1721 ["Marks..." gnus-summary-limit-to-marks t]
1722 ["Subject..." gnus-summary-limit-to-subject t]
1723 ["Author..." gnus-summary-limit-to-author t]
1724 ["Age..." gnus-summary-limit-to-age t]
1725 ["Score" gnus-summary-limit-to-score t]
1726 ["Unread" gnus-summary-limit-to-unread t]
1727 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1728 ["Articles" gnus-summary-limit-to-articles t]
1729 ["Pop limit" gnus-summary-pop-limit t]
1730 ["Show dormant" gnus-summary-limit-include-dormant t]
1731 ["Hide childless dormant"
1732 gnus-summary-limit-exclude-childless-dormant t]
1733 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1734 ["Show expunged" gnus-summary-show-all-expunged t])
1736 ["Set mark" gnus-summary-mark-as-processable t]
1737 ["Remove mark" gnus-summary-unmark-as-processable t]
1738 ["Remove all marks" gnus-summary-unmark-all-processable t]
1739 ["Mark above" gnus-uu-mark-over t]
1740 ["Mark series" gnus-uu-mark-series t]
1741 ["Mark region" gnus-uu-mark-region t]
1742 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1743 ["Mark all" gnus-uu-mark-all t]
1744 ["Mark buffer" gnus-uu-mark-buffer t]
1745 ["Mark sparse" gnus-uu-mark-sparse t]
1746 ["Mark thread" gnus-uu-mark-thread t]
1747 ["Unmark thread" gnus-uu-unmark-thread t]
1748 ("Process Mark Sets"
1749 ["Kill" gnus-summary-kill-process-mark t]
1750 ["Yank" gnus-summary-yank-process-mark
1751 gnus-newsgroup-process-stack]
1752 ["Save" gnus-summary-save-process-mark t]))
1754 ["Page forward" gnus-summary-next-page t]
1755 ["Page backward" gnus-summary-prev-page t]
1756 ["Line forward" gnus-summary-scroll-up t])
1758 ["Next unread article" gnus-summary-next-unread-article t]
1759 ["Previous unread article" gnus-summary-prev-unread-article t]
1760 ["Next article" gnus-summary-next-article t]
1761 ["Previous article" gnus-summary-prev-article t]
1762 ["Next unread subject" gnus-summary-next-unread-subject t]
1763 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1764 ["Next article same subject" gnus-summary-next-same-subject t]
1765 ["Previous article same subject" gnus-summary-prev-same-subject t]
1766 ["First unread article" gnus-summary-first-unread-article t]
1767 ["Best unread article" gnus-summary-best-unread-article t]
1768 ["Go to subject number..." gnus-summary-goto-subject t]
1769 ["Go to article number..." gnus-summary-goto-article t]
1770 ["Go to the last article" gnus-summary-goto-last-article t]
1771 ["Pop article off history" gnus-summary-pop-article t])
1773 ["Sort by number" gnus-summary-sort-by-number t]
1774 ["Sort by author" gnus-summary-sort-by-author t]
1775 ["Sort by subject" gnus-summary-sort-by-subject t]
1776 ["Sort by date" gnus-summary-sort-by-date t]
1777 ["Sort by score" gnus-summary-sort-by-score t]
1778 ["Sort by lines" gnus-summary-sort-by-lines t])
1780 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1781 ["Describe group" gnus-summary-describe-group t]
1782 ["Read manual" gnus-info-find-node t])
1784 ["Pick and read" gnus-pick-mode t]
1785 ["Binary" gnus-binary-mode t])
1787 ["Regenerate" gnus-summary-prepare t]
1788 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1789 ["Toggle threading" gnus-summary-toggle-threads t])
1790 ["Filter articles..." gnus-summary-execute-command t]
1791 ["Run command on subjects..." gnus-summary-universal-argument t]
1792 ["Search articles forward..." gnus-summary-search-article-forward t]
1793 ["Search articles backward..." gnus-summary-search-article-backward t]
1794 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1795 ["Expand window" gnus-summary-expand-window t]
1796 ["Expire expirable articles" gnus-summary-expire-articles
1797 (gnus-check-backend-function
1798 'request-expire-articles gnus-newsgroup-name)]
1799 ["Edit local kill file" gnus-summary-edit-local-kill t]
1800 ["Edit main kill file" gnus-summary-edit-global-kill t]
1802 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1803 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1804 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1805 ["Exit group" gnus-summary-exit t]
1806 ["Exit group without updating" gnus-summary-exit-no-update t]
1807 ["Exit and goto next group" gnus-summary-next-group t]
1808 ["Exit and goto prev group" gnus-summary-prev-group t]
1809 ["Reselect group" gnus-summary-reselect-current-group t]
1810 ["Rescan group" gnus-summary-rescan-group t]
1811 ["Update dribble" gnus-summary-save-newsrc t])))
1813 (run-hooks 'gnus-summary-menu-hook)))
1815 (defun gnus-score-set-default (var value)
1816 "A version of set that updates the GNU Emacs menu-bar."
1818 ;; It is the message that forces the active status to be updated.
1821 (defun gnus-make-score-map (type)
1822 "Make a summary score map of type TYPE."
1825 (let ((headers '(("author" "from" string)
1826 ("subject" "subject" string)
1827 ("article body" "body" string)
1828 ("article head" "head" string)
1829 ("xref" "xref" string)
1830 ("lines" "lines" number)
1831 ("followups to author" "followup" string)))
1832 (types '((number ("less than" <)
1835 (string ("substring" s)
1839 (perms '(("temporary" (current-time-string))
1847 (if (eq type 'lower)
1852 (setq header (car headers))
1858 (let ((ts (cdr (assoc (nth 2 header) types)))
1874 'gnus-summary-score-entry
1876 (if (or (string= (nth 1 header)
1878 (string= (nth 1 header)
1881 (list 'gnus-summary-header
1883 (list 'quote (nth 1 (car ts)))
1884 (list 'gnus-score-default nil)
1890 (list (nreverse outp))))
1893 (list (nreverse outt))))
1895 (setq headers (cdr headers)))
1896 (list (nreverse outh))))))))
1900 (defun gnus-summary-mode (&optional group)
1901 "Major mode for reading articles.
1903 All normal editing commands are switched off.
1904 \\<gnus-summary-mode-map>
1905 Each line in this buffer represents one article. To read an
1906 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1907 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1910 You can also post articles and send mail from this buffer. To
1911 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1912 of an article, type `\\[gnus-summary-reply]'.
1914 There are approx. one gazillion commands you can execute in this
1915 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1917 The following commands are available:
1919 \\{gnus-summary-mode-map}"
1921 (when (gnus-visual-p 'summary-menu 'menu)
1922 (gnus-summary-make-menu-bar))
1923 (kill-all-local-variables)
1924 (gnus-summary-make-local-variables)
1925 (gnus-make-thread-indent-array)
1926 (gnus-simplify-mode-line)
1927 (setq major-mode 'gnus-summary-mode)
1928 (setq mode-name "Summary")
1929 (make-local-variable 'minor-mode-alist)
1930 (use-local-map gnus-summary-mode-map)
1931 (buffer-disable-undo (current-buffer))
1932 (setq buffer-read-only t) ;Disable modification
1933 (setq truncate-lines t)
1934 (setq selective-display t)
1935 (setq selective-display-ellipses t) ;Display `...'
1936 (gnus-summary-set-display-table)
1937 (gnus-set-default-directory)
1938 (setq gnus-newsgroup-name group)
1939 (make-local-variable 'gnus-summary-line-format)
1940 (make-local-variable 'gnus-summary-line-format-spec)
1941 (make-local-variable 'gnus-summary-mark-positions)
1942 (make-local-hook 'post-command-hook)
1943 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1944 (run-hooks 'gnus-summary-mode-hook)
1945 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1946 (gnus-update-summary-mark-positions))
1948 (defun gnus-summary-make-local-variables ()
1949 "Make all the local summary buffer variables."
1950 (let ((locals gnus-summary-local-variables)
1952 (while (setq local (pop locals))
1955 (if (eq (cdr local) 'global)
1956 ;; Copy the global value of the variable.
1957 (setq global (symbol-value (car local)))
1958 ;; Use the value from the list.
1959 (setq global (eval (cdr local))))
1960 (make-local-variable (car local))
1961 (set (car local) global))
1962 ;; Simple nil-valued local variable.
1963 (make-local-variable local)
1966 (defun gnus-summary-clear-local-variables ()
1967 (let ((locals gnus-summary-local-variables))
1969 (if (consp (car locals))
1970 (and (vectorp (caar locals))
1971 (set (caar locals) nil))
1972 (and (vectorp (car locals))
1973 (set (car locals) nil)))
1974 (setq locals (cdr locals)))))
1976 ;; Summary data functions.
1978 (defmacro gnus-data-number (data)
1981 (defmacro gnus-data-set-number (data number)
1982 `(setcar ,data ,number))
1984 (defmacro gnus-data-mark (data)
1987 (defmacro gnus-data-set-mark (data mark)
1988 `(setcar (nthcdr 1 ,data) ,mark))
1990 (defmacro gnus-data-pos (data)
1993 (defmacro gnus-data-set-pos (data pos)
1994 `(setcar (nthcdr 2 ,data) ,pos))
1996 (defmacro gnus-data-header (data)
1999 (defmacro gnus-data-set-header (data header)
2000 `(setf (nth 3 ,data) ,header))
2002 (defmacro gnus-data-level (data)
2005 (defmacro gnus-data-unread-p (data)
2006 `(= (nth 1 ,data) gnus-unread-mark))
2008 (defmacro gnus-data-read-p (data)
2009 `(/= (nth 1 ,data) gnus-unread-mark))
2011 (defmacro gnus-data-pseudo-p (data)
2012 `(consp (nth 3 ,data)))
2014 (defmacro gnus-data-find (number)
2015 `(assq ,number gnus-newsgroup-data))
2017 (defmacro gnus-data-find-list (number &optional data)
2018 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2019 (memq (assq ,number bdata)
2022 (defmacro gnus-data-make (number mark pos header level)
2023 `(list ,number ,mark ,pos ,header ,level))
2025 (defun gnus-data-enter (after-article number mark pos header level offset)
2026 (let ((data (gnus-data-find-list after-article)))
2028 (error "No such article: %d" after-article))
2029 (setcdr data (cons (gnus-data-make number mark pos header level)
2031 (setq gnus-newsgroup-data-reverse nil)
2032 (gnus-data-update-list (cddr data) offset)))
2034 (defun gnus-data-enter-list (after-article list &optional offset)
2036 (let ((data (and after-article (gnus-data-find-list after-article)))
2038 (or data (not after-article) (error "No such article: %d" after-article))
2039 ;; Find the last element in the list to be spliced into the main
2042 (setq list (cdr list)))
2045 (setcdr list gnus-newsgroup-data)
2046 (setq gnus-newsgroup-data ilist)
2048 (gnus-data-update-list (cdr list) offset)))
2049 (setcdr list (cdr data))
2052 (gnus-data-update-list (cdr list) offset)))
2053 (setq gnus-newsgroup-data-reverse nil))))
2055 (defun gnus-data-remove (article &optional offset)
2056 (let ((data gnus-newsgroup-data))
2057 (if (= (gnus-data-number (car data)) article)
2059 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2060 gnus-newsgroup-data-reverse nil)
2062 (gnus-data-update-list gnus-newsgroup-data offset)))
2064 (when (= (gnus-data-number (cadr data)) article)
2065 (setcdr data (cddr data))
2067 (gnus-data-update-list (cdr data) offset))
2069 gnus-newsgroup-data-reverse nil))
2070 (setq data (cdr data))))))
2072 (defmacro gnus-data-list (backward)
2074 (or gnus-newsgroup-data-reverse
2075 (setq gnus-newsgroup-data-reverse
2076 (reverse gnus-newsgroup-data)))
2077 gnus-newsgroup-data))
2079 (defun gnus-data-update-list (data offset)
2080 "Add OFFSET to the POS of all data entries in DATA."
2082 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2083 (setq data (cdr data))))
2085 (defun gnus-data-compute-positions ()
2086 "Compute the positions of all articles."
2087 (let ((data gnus-newsgroup-data)
2090 (when (setq pos (text-property-any
2091 (point-min) (point-max)
2092 'gnus-number (gnus-data-number (car data))))
2093 (gnus-data-set-pos (car data) (+ pos 3)))
2094 (setq data (cdr data)))))
2096 (defun gnus-summary-article-pseudo-p (article)
2097 "Say whether this article is a pseudo article or not."
2098 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2100 (defmacro gnus-summary-article-sparse-p (article)
2101 "Say whether this article is a sparse article or not."
2102 `(memq ,article gnus-newsgroup-sparse))
2104 (defmacro gnus-summary-article-ancient-p (article)
2105 "Say whether this article is a sparse article or not."
2106 `(memq ,article gnus-newsgroup-ancient))
2108 (defun gnus-article-parent-p (number)
2109 "Say whether this article is a parent or not."
2110 (let ((data (gnus-data-find-list number)))
2111 (and (cdr data) ; There has to be an article after...
2112 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2113 (gnus-data-level (nth 1 data))))))
2115 (defun gnus-article-children (number)
2116 "Return a list of all children to NUMBER."
2117 (let* ((data (gnus-data-find-list number))
2118 (level (gnus-data-level (car data)))
2120 (setq data (cdr data))
2122 (= (gnus-data-level (car data)) (1+ level)))
2123 (push (gnus-data-number (car data)) children)
2124 (setq data (cdr data)))
2127 (defmacro gnus-summary-skip-intangible ()
2128 "If the current article is intangible, then jump to a different article."
2129 '(let ((to (get-text-property (point) 'gnus-intangible)))
2130 (and to (gnus-summary-goto-subject to))))
2132 (defmacro gnus-summary-article-intangible-p ()
2133 "Say whether this article is intangible or not."
2134 '(get-text-property (point) 'gnus-intangible))
2136 (defun gnus-article-read-p (article)
2137 "Say whether ARTICLE is read or not."
2138 (not (or (memq article gnus-newsgroup-marked)
2139 (memq article gnus-newsgroup-unreads)
2140 (memq article gnus-newsgroup-unselected)
2141 (memq article gnus-newsgroup-dormant))))
2143 ;; Some summary mode macros.
2145 (defmacro gnus-summary-article-number ()
2146 "The article number of the article on the current line.
2147 If there isn's an article number here, then we return the current
2150 (gnus-summary-skip-intangible)
2151 (or (get-text-property (point) 'gnus-number)
2152 (gnus-summary-last-subject))))
2154 (defmacro gnus-summary-article-header (&optional number)
2155 `(gnus-data-header (gnus-data-find
2156 ,(or number '(gnus-summary-article-number)))))
2158 (defmacro gnus-summary-thread-level (&optional number)
2159 `(if (and (eq gnus-summary-make-false-root 'dummy)
2160 (get-text-property (point) 'gnus-intangible))
2162 (gnus-data-level (gnus-data-find
2163 ,(or number '(gnus-summary-article-number))))))
2165 (defmacro gnus-summary-article-mark (&optional number)
2166 `(gnus-data-mark (gnus-data-find
2167 ,(or number '(gnus-summary-article-number)))))
2169 (defmacro gnus-summary-article-pos (&optional number)
2170 `(gnus-data-pos (gnus-data-find
2171 ,(or number '(gnus-summary-article-number)))))
2173 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2174 (defmacro gnus-summary-article-subject (&optional number)
2175 "Return current subject string or nil if nothing."
2178 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2179 '(gnus-data-header (assq (gnus-summary-article-number)
2180 gnus-newsgroup-data)))))
2183 (mail-header-subject headers))))
2185 (defmacro gnus-summary-article-score (&optional number)
2186 "Return current article score."
2187 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2188 gnus-newsgroup-scored))
2189 gnus-summary-default-score 0))
2191 (defun gnus-summary-article-children (&optional number)
2192 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2193 (level (gnus-data-level (car data)))
2195 (while (and (setq data (cdr data))
2196 (> (setq l (gnus-data-level (car data))) level))
2197 (and (= (1+ level) l)
2198 (push (gnus-data-number (car data))
2200 (nreverse children)))
2202 (defun gnus-summary-article-parent (&optional number)
2203 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2204 (gnus-data-list t)))
2205 (level (gnus-data-level (car data))))
2207 () ; This is a root.
2208 ;; We search until we find an article with a level less than
2209 ;; this one. That function has to be the parent.
2210 (while (and (setq data (cdr data))
2211 (not (< (gnus-data-level (car data)) level))))
2212 (and data (gnus-data-number (car data))))))
2214 (defun gnus-unread-mark-p (mark)
2215 "Say whether MARK is the unread mark."
2216 (= mark gnus-unread-mark))
2218 (defun gnus-read-mark-p (mark)
2219 "Say whether MARK is one of the marks that mark as read.
2220 This is all marks except unread, ticked, dormant, and expirable."
2221 (not (or (= mark gnus-unread-mark)
2222 (= mark gnus-ticked-mark)
2223 (= mark gnus-dormant-mark)
2224 (= mark gnus-expirable-mark))))
2226 (defmacro gnus-article-mark (number)
2228 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2229 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2230 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2231 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2232 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2233 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2234 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2235 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2236 gnus-ancient-mark))))
2238 ;; Saving hidden threads.
2240 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2241 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2243 (defmacro gnus-save-hidden-threads (&rest forms)
2244 "Save hidden threads, eval FORMS, and restore the hidden threads."
2245 (let ((config (make-symbol "config")))
2246 `(let ((,config (gnus-hidden-threads-configuration)))
2250 (gnus-restore-hidden-threads-configuration ,config)))))
2252 (defun gnus-hidden-threads-configuration ()
2253 "Return the current hidden threads configuration."
2256 (goto-char (point-min))
2257 (while (search-forward "\r" nil t)
2258 (push (1- (point)) config))
2261 (defun gnus-restore-hidden-threads-configuration (config)
2262 "Restore hidden threads configuration from CONFIG."
2263 (let (point buffer-read-only)
2264 (while (setq point (pop config))
2265 (when (and (< point (point-max))
2267 (= (following-char) ?\n))
2268 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2270 ;; Various summary mode internalish functions.
2272 (defun gnus-mouse-pick-article (e)
2275 (gnus-summary-next-page nil t))
2277 (defun gnus-summary-set-display-table ()
2278 ;; Change the display table. Odd characters have a tendency to mess
2279 ;; up nicely formatted displays - we make all possible glyphs
2280 ;; display only a single character.
2282 ;; We start from the standard display table, if any.
2283 (let ((table (or (copy-sequence standard-display-table)
2284 (make-display-table)))
2286 ;; Nix out all the control chars...
2287 (while (>= (setq i (1- i)) 0)
2288 (aset table i [??]))
2289 ;; ... but not newline and cr, of course. (cr is necessary for the
2290 ;; selective display).
2291 (aset table ?\n nil)
2292 (aset table ?\r nil)
2293 ;; We nix out any glyphs over 126 that are not set already.
2295 (while (>= (setq i (1- i)) 127)
2296 ;; Only modify if the entry is nil.
2297 (unless (aref table i)
2298 (aset table i [??]))))
2299 (setq buffer-display-table table)))
2301 (defun gnus-summary-setup-buffer (group)
2302 "Initialize summary buffer."
2303 (let ((buffer (concat "*Summary " group "*")))
2304 (if (get-buffer buffer)
2307 (setq gnus-summary-buffer (current-buffer))
2308 (not gnus-newsgroup-prepared))
2309 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2310 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2311 (gnus-add-current-to-buffer-list)
2312 (gnus-summary-mode group)
2314 (gnus-carpal-setup-buffer 'summary))
2315 (unless gnus-single-article-buffer
2316 (make-local-variable 'gnus-article-buffer)
2317 (make-local-variable 'gnus-article-current)
2318 (make-local-variable 'gnus-original-article-buffer))
2319 (setq gnus-newsgroup-name group)
2322 (defun gnus-set-global-variables ()
2323 ;; Set the global equivalents of the summary buffer-local variables
2324 ;; to the latest values they had. These reflect the summary buffer
2325 ;; that was in action when the last article was fetched.
2326 (when (eq major-mode 'gnus-summary-mode)
2327 (setq gnus-summary-buffer (current-buffer))
2328 (let ((name gnus-newsgroup-name)
2329 (marked gnus-newsgroup-marked)
2330 (unread gnus-newsgroup-unreads)
2331 (headers gnus-current-headers)
2332 (data gnus-newsgroup-data)
2333 (summary gnus-summary-buffer)
2334 (article-buffer gnus-article-buffer)
2335 (original gnus-original-article-buffer)
2336 (gac gnus-article-current)
2337 (reffed gnus-reffed-article-number)
2338 (score-file gnus-current-score-file))
2340 (set-buffer gnus-group-buffer)
2341 (setq gnus-newsgroup-name name)
2342 (setq gnus-newsgroup-marked marked)
2343 (setq gnus-newsgroup-unreads unread)
2344 (setq gnus-current-headers headers)
2345 (setq gnus-newsgroup-data data)
2346 (setq gnus-article-current gac)
2347 (setq gnus-summary-buffer summary)
2348 (setq gnus-article-buffer article-buffer)
2349 (setq gnus-original-article-buffer original)
2350 (setq gnus-reffed-article-number reffed)
2351 (setq gnus-current-score-file score-file)
2352 ;; The article buffer also has local variables.
2353 (when (gnus-buffer-live-p gnus-article-buffer)
2354 (set-buffer gnus-article-buffer)
2355 (setq gnus-summary-buffer summary))))))
2357 (defun gnus-summary-article-unread-p (article)
2358 "Say whether ARTICLE is unread or not."
2359 (memq article gnus-newsgroup-unreads))
2361 (defun gnus-summary-first-article-p (&optional article)
2362 "Return whether ARTICLE is the first article in the buffer."
2363 (if (not (setq article (or article (gnus-summary-article-number))))
2365 (eq article (caar gnus-newsgroup-data))))
2367 (defun gnus-summary-last-article-p (&optional article)
2368 "Return whether ARTICLE is the last article in the buffer."
2369 (if (not (setq article (or article (gnus-summary-article-number))))
2370 t ; All non-existent numbers are the last article. :-)
2371 (not (cdr (gnus-data-find-list article)))))
2373 (defun gnus-make-thread-indent-array ()
2375 (unless (and gnus-thread-indent-array
2376 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2377 (setq gnus-thread-indent-array (make-vector 201 "")
2378 gnus-thread-indent-array-level gnus-thread-indent-level)
2380 (aset gnus-thread-indent-array n
2381 (make-string (* n gnus-thread-indent-level) ? ))
2384 (defun gnus-update-summary-mark-positions ()
2385 "Compute where the summary marks are to go."
2387 (when (and gnus-summary-buffer
2388 (get-buffer gnus-summary-buffer)
2389 (buffer-name (get-buffer gnus-summary-buffer)))
2390 (set-buffer gnus-summary-buffer))
2391 (let ((gnus-replied-mark 129)
2392 (gnus-score-below-mark 130)
2393 (gnus-score-over-mark 130)
2394 (gnus-download-mark 131)
2395 (spec gnus-summary-line-format-spec)
2396 thread gnus-visual pos)
2398 (gnus-set-work-buffer)
2399 (let ((gnus-summary-line-format-spec spec)
2400 (gnus-newsgroup-downloadable '((0 . t))))
2401 (gnus-summary-insert-line
2402 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2403 (goto-char (point-min))
2404 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2406 (goto-char (point-min))
2407 (push (cons 'replied (and (search-forward "\201" nil t)
2410 (goto-char (point-min))
2411 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2413 (goto-char (point-min))
2414 (push (cons 'download
2415 (and (search-forward "\203" nil t) (- (point) 2)))
2417 (setq gnus-summary-mark-positions pos))))
2419 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2420 "Insert a dummy root in the summary buffer."
2422 (gnus-add-text-properties
2423 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2424 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2426 (defun gnus-summary-insert-line (gnus-tmp-header
2427 gnus-tmp-level gnus-tmp-current
2428 gnus-tmp-unread gnus-tmp-replied
2429 gnus-tmp-expirable gnus-tmp-subject-or-nil
2430 &optional gnus-tmp-dummy gnus-tmp-score
2432 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2433 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2434 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2435 (gnus-tmp-score-char
2436 (if (or (null gnus-summary-default-score)
2437 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2438 gnus-summary-zcore-fuzz))
2440 (if (< gnus-tmp-score gnus-summary-default-score)
2441 gnus-score-below-mark gnus-score-over-mark)))
2443 (cond (gnus-tmp-process gnus-process-mark)
2444 ((memq gnus-tmp-current gnus-newsgroup-cached)
2446 (gnus-tmp-replied gnus-replied-mark)
2447 ((memq gnus-tmp-current gnus-newsgroup-saved)
2449 (t gnus-unread-mark)))
2450 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2453 ((string-match "<[^>]+> *$" gnus-tmp-from)
2454 (let ((beg (match-beginning 0)))
2455 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2456 (substring gnus-tmp-from (1+ (match-beginning 0))
2457 (1- (match-end 0))))
2458 (substring gnus-tmp-from 0 beg))))
2459 ((string-match "(.+)" gnus-tmp-from)
2460 (substring gnus-tmp-from
2461 (1+ (match-beginning 0)) (1- (match-end 0))))
2463 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2464 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2465 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2466 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2467 (buffer-read-only nil))
2468 (when (string= gnus-tmp-name "")
2469 (setq gnus-tmp-name gnus-tmp-from))
2470 (unless (numberp gnus-tmp-lines)
2471 (setq gnus-tmp-lines 0))
2472 (gnus-put-text-property
2474 (progn (eval gnus-summary-line-format-spec) (point))
2475 'gnus-number gnus-tmp-number)
2476 (when (gnus-visual-p 'summary-highlight 'highlight)
2478 (run-hooks 'gnus-summary-update-hook)
2481 (defun gnus-summary-update-line (&optional dont-update)
2482 ;; Update summary line after change.
2483 (when (and gnus-summary-default-score
2484 (not gnus-summary-inhibit-highlight))
2485 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2486 (article (gnus-summary-article-number))
2487 (score (gnus-summary-article-score article)))
2489 (if (and gnus-summary-mark-below
2490 (< (gnus-summary-article-score)
2491 gnus-summary-mark-below))
2492 ;; This article has a low score, so we mark it as read.
2493 (when (memq article gnus-newsgroup-unreads)
2494 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2495 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2496 ;; This article was previously marked as read on account
2497 ;; of a low score, but now it has risen, so we mark it as
2499 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2500 (gnus-summary-update-mark
2501 (if (or (null gnus-summary-default-score)
2502 (<= (abs (- score gnus-summary-default-score))
2503 gnus-summary-zcore-fuzz))
2505 (if (< score gnus-summary-default-score)
2506 gnus-score-below-mark gnus-score-over-mark))
2508 ;; Do visual highlighting.
2509 (when (gnus-visual-p 'summary-highlight 'highlight)
2510 (run-hooks 'gnus-summary-update-hook)))))
2512 (defvar gnus-tmp-new-adopts nil)
2514 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2515 "Return the number of articles in THREAD.
2516 This may be 0 in some cases -- if none of the articles in
2517 the thread are to be displayed."
2519 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2521 ((not (listp thread))
2523 ((and (consp thread) (cdr thread))
2526 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2529 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2532 (when (and level (zerop level) gnus-tmp-new-adopts)
2535 'gnus-summary-number-of-articles-in-thread
2536 gnus-tmp-new-adopts))))
2538 (if (> number 1) gnus-not-empty-thread-mark
2539 gnus-empty-thread-mark)
2542 (defun gnus-summary-set-local-parameters (group)
2543 "Go through the local params of GROUP and set all variable specs in that list."
2544 (let ((params (gnus-group-find-parameter group))
2547 (setq elem (car params)
2548 params (cdr params))
2549 (and (consp elem) ; Has to be a cons.
2550 (consp (cdr elem)) ; The cdr has to be a list.
2551 (symbolp (car elem)) ; Has to be a symbol in there.
2552 (not (memq (car elem)
2553 '(quit-config to-address to-list to-group)))
2554 (ignore-errors ; So we set it.
2555 (make-local-variable (car elem))
2556 (set (car elem) (eval (nth 1 elem))))))))
2558 (defun gnus-summary-read-group (group &optional show-all no-article
2559 kill-buffer no-display)
2560 "Start reading news in newsgroup GROUP.
2561 If SHOW-ALL is non-nil, already read articles are also listed.
2562 If NO-ARTICLE is non-nil, no article is selected initially.
2563 If NO-DISPLAY, don't generate a summary buffer."
2567 (let ((gnus-auto-select-next nil))
2568 (or (gnus-summary-read-group-1
2569 group show-all no-article
2570 kill-buffer no-display)
2571 (setq show-all nil)))))
2572 (eq gnus-auto-select-next 'quietly))
2573 (set-buffer gnus-group-buffer)
2574 (if (not (equal group (gnus-group-group-name)))
2575 (setq group (gnus-group-group-name))
2579 (defun gnus-summary-read-group-1 (group show-all no-article
2580 kill-buffer no-display)
2581 ;; Killed foreign groups can't be entered.
2582 (when (and (not (gnus-group-native-p group))
2583 (not (gnus-gethash group gnus-newsrc-hashtb)))
2584 (error "Dead non-native groups can't be entered"))
2585 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2586 (let* ((new-group (gnus-summary-setup-buffer group))
2587 (quit-config (gnus-group-quit-config group))
2588 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2590 ;; This summary buffer exists already, so we just select it.
2592 (gnus-set-global-variables)
2594 (gnus-kill-or-deaden-summary kill-buffer))
2595 (gnus-configure-windows 'summary 'force)
2596 (gnus-set-mode-line 'summary)
2597 (gnus-summary-position-point)
2600 ;; We couldn't select this group.
2602 (when (and (eq major-mode 'gnus-summary-mode)
2603 (not (equal (current-buffer) kill-buffer)))
2604 (kill-buffer (current-buffer))
2605 (if (not quit-config)
2607 (set-buffer gnus-group-buffer)
2608 (gnus-group-jump-to-group group)
2609 (gnus-group-next-unread-group 1))
2610 (gnus-handle-ephemeral-exit quit-config)))
2611 (gnus-message 3 "Can't select group")
2613 ;; The user did a `C-g' while prompting for number of articles,
2614 ;; so we exit this group.
2615 ((eq did-select 'quit)
2616 (and (eq major-mode 'gnus-summary-mode)
2617 (not (equal (current-buffer) kill-buffer))
2618 (kill-buffer (current-buffer)))
2620 (gnus-kill-or-deaden-summary kill-buffer))
2621 (if (not quit-config)
2623 (set-buffer gnus-group-buffer)
2624 (gnus-group-jump-to-group group)
2625 (gnus-group-next-unread-group 1)
2626 (gnus-configure-windows 'group 'force))
2627 (gnus-handle-ephemeral-exit quit-config))
2628 ;; Finally signal the quit.
2630 ;; The group was successfully selected.
2632 (gnus-set-global-variables)
2633 ;; Save the active value in effect when the group was entered.
2634 (setq gnus-newsgroup-active
2636 (gnus-active gnus-newsgroup-name)))
2637 ;; You can change the summary buffer in some way with this hook.
2638 (run-hooks 'gnus-select-group-hook)
2639 ;; Set any local variables in the group parameters.
2640 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2641 (gnus-update-format-specifications
2642 nil 'summary 'summary-mode 'summary-dummy)
2643 ;; Do score processing.
2644 (when gnus-use-scoring
2645 (gnus-possibly-score-headers))
2646 ;; Check whether to fill in the gaps in the threads.
2647 (when gnus-build-sparse-threads
2648 (gnus-build-sparse-threads))
2649 ;; Find the initial limit.
2650 (if gnus-show-threads
2652 (let ((gnus-newsgroup-dormant nil))
2653 (gnus-summary-initial-limit show-all))
2654 (gnus-summary-initial-limit show-all))
2655 (setq gnus-newsgroup-limit
2657 (lambda (header) (mail-header-number header))
2658 gnus-newsgroup-headers)))
2659 ;; Generate the summary buffer.
2661 (gnus-summary-prepare))
2662 (when gnus-use-trees
2663 (gnus-tree-open group)
2664 (setq gnus-summary-highlight-line-function
2665 'gnus-tree-highlight-article))
2666 ;; If the summary buffer is empty, but there are some low-scored
2667 ;; articles or some excluded dormants, we include these in the
2669 (when (and (zerop (buffer-size))
2671 (cond (gnus-newsgroup-dormant
2672 (gnus-summary-limit-include-dormant))
2673 ((and gnus-newsgroup-scored show-all)
2674 (gnus-summary-limit-include-expunged t))))
2675 ;; Function `gnus-apply-kill-file' must be called in this hook.
2676 (run-hooks 'gnus-apply-kill-hook)
2677 (if (and (zerop (buffer-size))
2680 ;; This newsgroup is empty.
2681 (gnus-summary-catchup-and-exit nil t)
2682 (gnus-message 6 "No unread news")
2684 (gnus-kill-or-deaden-summary kill-buffer))
2685 ;; Return nil from this function.
2687 ;; Hide conversation thread subtrees. We cannot do this in
2688 ;; gnus-summary-prepare-hook since kill processing may not
2689 ;; work with hidden articles.
2690 (and gnus-show-threads
2691 gnus-thread-hide-subtree
2692 (gnus-summary-hide-all-threads))
2693 ;; Show first unread article if requested.
2694 (if (and (not no-article)
2696 gnus-newsgroup-unreads
2697 gnus-auto-select-first)
2698 (unless (if (eq gnus-auto-select-first 'best)
2699 (gnus-summary-best-unread-article)
2700 (gnus-summary-first-unread-article))
2701 (gnus-configure-windows 'summary))
2702 ;; Don't select any articles, just move point to the first
2703 ;; article in the group.
2704 (goto-char (point-min))
2705 (gnus-summary-position-point)
2706 (gnus-set-mode-line 'summary)
2707 (gnus-configure-windows 'summary 'force))
2709 (gnus-kill-or-deaden-summary kill-buffer))
2710 (when (get-buffer-window gnus-group-buffer t)
2711 ;; Gotta use windows, because recenter does weird stuff if
2712 ;; the current buffer ain't the displayed window.
2713 (let ((owin (selected-window)))
2714 (select-window (get-buffer-window gnus-group-buffer t))
2715 (when (gnus-group-goto-group group)
2717 (select-window owin)))
2718 ;; Mark this buffer as "prepared".
2719 (setq gnus-newsgroup-prepared t)
2722 (defun gnus-summary-prepare ()
2723 "Generate the summary buffer."
2725 (let ((buffer-read-only nil))
2727 (setq gnus-newsgroup-data nil
2728 gnus-newsgroup-data-reverse nil)
2729 (run-hooks 'gnus-summary-generate-hook)
2730 ;; Generate the buffer, either with threads or without.
2731 (when gnus-newsgroup-headers
2732 (gnus-summary-prepare-threads
2733 (if gnus-show-threads
2734 (gnus-sort-gathered-threads
2735 (funcall gnus-summary-thread-gathering-function
2737 (gnus-cut-threads (gnus-make-threads)))))
2738 ;; Unthreaded display.
2739 (gnus-sort-articles gnus-newsgroup-headers))))
2740 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2741 ;; Call hooks for modifying summary buffer.
2742 (goto-char (point-min))
2743 (run-hooks 'gnus-summary-prepare-hook)))
2745 (defsubst gnus-general-simplify-subject (subject)
2746 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2749 ;; Truncate the subject.
2750 (gnus-simplify-subject-functions
2751 (gnus-map-function gnus-simplify-subject-functions subject))
2752 ((numberp gnus-summary-gather-subject-limit)
2753 (setq subject (gnus-simplify-subject-re subject))
2754 (if (> (length subject) gnus-summary-gather-subject-limit)
2755 (substring subject 0 gnus-summary-gather-subject-limit)
2757 ;; Fuzzily simplify it.
2758 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2759 (gnus-simplify-subject-fuzzy subject))
2760 ;; Just remove the leading "Re:".
2762 (gnus-simplify-subject-re subject))))
2764 (if (and gnus-summary-gather-exclude-subject
2765 (string-match gnus-summary-gather-exclude-subject subject))
2766 nil ; This article shouldn't be gathered
2769 (defun gnus-summary-simplify-subject-query ()
2770 "Query where the respool algorithm would put this article."
2772 (gnus-set-global-variables)
2773 (gnus-summary-select-article)
2774 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2776 (defun gnus-gather-threads-by-subject (threads)
2777 "Gather threads by looking at Subject headers."
2778 (if (not gnus-summary-make-false-root)
2780 (let ((hashtb (gnus-make-hashtable 1024))
2783 subject hthread whole-subject)
2785 (setq subject (gnus-general-simplify-subject
2786 (setq whole-subject (mail-header-subject
2789 (if (setq hthread (gnus-gethash subject hashtb))
2791 ;; We enter a dummy root into the thread, if we
2792 ;; haven't done that already.
2793 (unless (stringp (caar hthread))
2794 (setcar hthread (list whole-subject (car hthread))))
2795 ;; We add this new gathered thread to this gathered
2797 (setcdr (car hthread)
2798 (nconc (cdar hthread) (list (car threads))))
2799 ;; Remove it from the list of threads.
2800 (setcdr prev (cdr threads))
2801 (setq threads prev))
2802 ;; Enter this thread into the hash table.
2803 (gnus-sethash subject threads hashtb)))
2805 (setq threads (cdr threads)))
2808 (defun gnus-gather-threads-by-references (threads)
2809 "Gather threads by looking at References headers."
2810 (let ((idhashtb (gnus-make-hashtable 1024))
2811 (thhashtb (gnus-make-hashtable 1024))
2814 ids references id gthread gid entered ref)
2816 (when (setq references (mail-header-references (caar threads)))
2817 (setq id (mail-header-id (caar threads))
2818 ids (gnus-split-references references)
2820 (while (setq ref (pop ids))
2821 (setq ids (delete ref ids))
2822 (if (not (setq gid (gnus-gethash ref idhashtb)))
2824 (gnus-sethash ref id idhashtb)
2825 (gnus-sethash id threads thhashtb))
2826 (setq gthread (gnus-gethash gid thhashtb))
2828 ;; We enter a dummy root into the thread, if we
2829 ;; haven't done that already.
2830 (unless (stringp (caar gthread))
2831 (setcar gthread (list (mail-header-subject (caar gthread))
2833 ;; We add this new gathered thread to this gathered
2835 (setcdr (car gthread)
2836 (nconc (cdar gthread) (list (car threads)))))
2837 ;; Add it into the thread hash table.
2838 (gnus-sethash id gthread thhashtb)
2840 ;; Remove it from the list of threads.
2841 (setcdr prev (cdr threads))
2842 (setq threads prev))))
2844 (setq threads (cdr threads)))
2847 (defun gnus-sort-gathered-threads (threads)
2848 "Sort subtreads inside each gathered thread by article number."
2849 (let ((result threads))
2851 (when (stringp (caar threads))
2852 (setcdr (car threads)
2853 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2854 (setq threads (cdr threads)))
2857 (defun gnus-thread-loop-p (root thread)
2858 "Say whether ROOT is in THREAD."
2859 (let ((stack (list thread))
2862 (while (setq thread (pop stack))
2863 (setq th (cdr thread))
2865 (not (eq (caar th) root)))
2868 ;; We have found a loop.
2870 (setcdr thread (delq (car th) (cdr thread)))
2871 (if (boundp (setq ref-dep (intern "none"
2872 gnus-newsgroup-dependencies)))
2873 (setcdr (symbol-value ref-dep)
2874 (nconc (cdr (symbol-value ref-dep))
2876 (set ref-dep (list nil (car th))))
2879 ;; Push all the subthreads onto the stack.
2880 (push (cdr thread) stack)))
2883 (defun gnus-make-threads ()
2884 "Go through the dependency hashtb and find the roots. Return all threads."
2886 (while (catch 'infloop
2889 ;; Deal with self-referencing References loops.
2890 (when (and (car (symbol-value refs))
2897 (car (symbol-value refs)) thread))
2898 (cdr (symbol-value refs)))))))
2901 (unless (car (symbol-value refs))
2902 ;; These threads do not refer back to any other articles,
2903 ;; so they're roots.
2904 (setq threads (append (cdr (symbol-value refs)) threads))))
2905 gnus-newsgroup-dependencies)))
2908 (defun gnus-build-sparse-threads ()
2909 (let ((headers gnus-newsgroup-headers)
2910 (deps gnus-newsgroup-dependencies)
2911 header references generation relations
2912 cthread subject child end pthread relation new-child)
2913 ;; First we create an alist of generations/relations, where
2914 ;; generations is how much we trust the relation, and the relation
2916 (gnus-message 7 "Making sparse threads...")
2918 (nnheader-set-temp-buffer " *gnus sparse threads*")
2919 (while (setq header (pop headers))
2920 (when (and (setq references (mail-header-references header))
2921 (not (string= references "")))
2923 (setq child (mail-header-id header)
2924 subject (mail-header-subject header))
2926 (while (search-backward ">" nil t)
2927 (setq end (1+ (point)))
2928 (when (search-backward "<" nil t)
2929 (unless (string= (setq new-child (buffer-substring (point) end))
2931 (push (list (incf generation)
2932 child (setq child new-child)
2935 (push (list (1+ generation) child nil subject) relations)
2937 (kill-buffer (current-buffer)))
2938 ;; Sort over trustworthiness.
2939 (setq relations (sort relations 'car-less-than-car))
2940 (while (setq relation (pop relations))
2941 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2942 (unless (car (symbol-value cthread))
2943 ;; Make this article the parent of these threads.
2944 (setcar (symbol-value cthread)
2945 (vector gnus-reffed-article-number
2949 (or (caddr relation) "") 0 0 "")))
2950 (set cthread (list (vector gnus-reffed-article-number
2952 "" "" (cadr relation)
2953 (or (caddr relation) "") 0 0 ""))))
2954 (push gnus-reffed-article-number gnus-newsgroup-limit)
2955 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2956 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2957 gnus-newsgroup-reads)
2958 (decf gnus-reffed-article-number)
2959 ;; Make this new thread the child of its parent.
2960 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2961 (setcdr (symbol-value pthread)
2962 (nconc (cdr (symbol-value pthread))
2963 (list (symbol-value cthread))))
2964 (set pthread (list nil (symbol-value cthread))))))
2965 (gnus-message 7 "Making sparse threads...done")))
2967 (defun gnus-build-old-threads ()
2968 ;; Look at all the articles that refer back to old articles, and
2969 ;; fetch the headers for the articles that aren't there. This will
2970 ;; build complete threads - if the roots haven't been expired by the
2975 (when (not (car (symbol-value refs)))
2976 (setq heads (cdr (symbol-value refs)))
2978 (if (memq (mail-header-number (caar heads))
2979 gnus-newsgroup-dormant)
2980 (setq heads (cdr heads))
2981 (setq id (symbol-name refs))
2982 (while (and (setq id (gnus-build-get-header id))
2983 (not (car (gnus-gethash
2984 id gnus-newsgroup-dependencies)))))
2985 (setq heads nil)))))
2986 gnus-newsgroup-dependencies)))
2988 (defun gnus-build-get-header (id)
2989 ;; Look through the buffer of NOV lines and find the header to
2990 ;; ID. Enter this line into the dependencies hash table, and return
2991 ;; the id of the parent article (if any).
2992 (let ((deps gnus-newsgroup-dependencies)
2996 (set-buffer nntp-server-buffer)
2997 (let ((case-fold-search nil))
2998 (goto-char (point-min))
2999 (while (and (not found)
3000 (search-forward id nil t))
3002 (setq found (looking-at
3003 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3004 (regexp-quote id))))
3005 (or found (beginning-of-line 2)))
3009 (setq header (gnus-nov-parse-line
3010 (read (current-buffer)) deps))
3011 (gnus-parent-id (mail-header-references header))))))
3013 (let ((number (mail-header-number header)))
3014 (push number gnus-newsgroup-limit)
3015 (push header gnus-newsgroup-headers)
3016 (if (memq number gnus-newsgroup-unselected)
3018 (push number gnus-newsgroup-unreads)
3019 (setq gnus-newsgroup-unselected
3020 (delq number gnus-newsgroup-unselected)))
3021 (push number gnus-newsgroup-ancient)))))))
3023 (defun gnus-build-all-threads ()
3024 "Read all the headers."
3025 (let ((deps gnus-newsgroup-dependencies)
3026 (gnus-summary-ignore-duplicates t)
3027 found header article)
3029 (set-buffer nntp-server-buffer)
3030 (let ((case-fold-search nil))
3031 (goto-char (point-min))
3034 (setq article (read (current-buffer)))
3035 (setq header (gnus-nov-parse-line article deps)))
3037 (push header gnus-newsgroup-headers)
3038 (if (memq (setq article (mail-header-number header))
3039 gnus-newsgroup-unselected)
3041 (push article gnus-newsgroup-unreads)
3042 (setq gnus-newsgroup-unselected
3043 (delq article gnus-newsgroup-unselected)))
3044 (push article gnus-newsgroup-ancient))
3045 (forward-line 1)))))))
3047 (defun gnus-summary-update-article-line (article header)
3048 "Update the line for ARTICLE using HEADERS."
3049 (let* ((id (mail-header-id header))
3050 (thread (gnus-id-to-thread id)))
3052 (error "Article in no thread"))
3053 ;; Update the thread.
3054 (setcar thread header)
3055 (gnus-summary-goto-subject article)
3056 (let* ((datal (gnus-data-find-list article))
3058 (length (when (cdr datal)
3059 (- (gnus-data-pos data)
3060 (gnus-data-pos (cadr datal)))))
3061 (buffer-read-only nil)
3062 (level (gnus-summary-thread-level)))
3064 (gnus-summary-insert-line
3065 header level nil (gnus-article-mark article)
3066 (memq article gnus-newsgroup-replied)
3067 (memq article gnus-newsgroup-expirable)
3068 ;; Only insert the Subject string when it's different
3069 ;; from the previous Subject string.
3070 (if (gnus-subject-equal
3072 (mail-header-subject
3075 (gnus-data-find-list
3077 (gnus-data-list t)))))
3078 ;; Error on the side of excessive subjects.
3080 (mail-header-subject header))
3082 (mail-header-subject header))
3083 nil (cdr (assq article gnus-newsgroup-scored))
3084 (memq article gnus-newsgroup-processable))
3086 (gnus-data-update-list
3087 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3089 (defun gnus-summary-update-article (article &optional iheader)
3090 "Update ARTICLE in the summary buffer."
3091 (set-buffer gnus-summary-buffer)
3092 (let* ((header (or iheader (gnus-summary-article-header article)))
3093 (id (mail-header-id header))
3094 (data (gnus-data-find article))
3095 (thread (gnus-id-to-thread id))
3096 (references (mail-header-references header))
3100 (when (and references
3101 (not (equal "" references)))
3104 (buffer-read-only nil)
3106 (number (mail-header-number header))
3109 ;; !!! Should this be in or not?
3111 (setcar thread nil))
3113 (delq thread parent))
3114 (if (gnus-summary-insert-subject id header iheader)
3115 ;; Set the (possibly) new article number in the data structure.
3116 (gnus-data-set-number data (gnus-id-to-article id))
3120 (defun gnus-rebuild-thread (id)
3121 "Rebuild the thread containing ID."
3122 (let ((buffer-read-only nil)
3123 old-pos current thread data)
3124 (if (not gnus-show-threads)
3125 (setq thread (list (car (gnus-id-to-thread id))))
3126 ;; Get the thread this article is part of.
3127 (setq thread (gnus-remove-thread id)))
3128 (setq old-pos (gnus-point-at-bol))
3129 (setq current (save-excursion
3130 (and (zerop (forward-line -1))
3131 (gnus-summary-article-number))))
3132 ;; If this is a gathered thread, we have to go some re-gathering.
3133 (when (stringp (car thread))
3134 (let ((subject (car thread))
3136 (setq thread (cdr thread))
3138 (unless (memq (setq thr (gnus-id-to-thread
3140 (mail-header-id (caar thread)))))
3143 (setq thread (cdr thread)))
3144 ;; We now have all (unique) roots.
3145 (if (= (length roots) 1)
3146 ;; All the loose roots are now one solid root.
3147 (setq thread (car roots))
3148 (setq thread (cons subject (gnus-sort-threads roots))))))
3150 ;; We then insert this thread into the summary buffer.
3151 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3152 (if gnus-show-threads
3153 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3154 (gnus-summary-prepare-unthreaded thread))
3155 (setq data (nreverse gnus-newsgroup-data))
3156 (setq threads gnus-newsgroup-threads))
3157 ;; We splice the new data into the data structure.
3158 (gnus-data-enter-list current data (- (point) old-pos))
3159 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3161 (defun gnus-number-to-header (number)
3162 "Return the header for article NUMBER."
3163 (let ((headers gnus-newsgroup-headers))
3165 (not (= number (mail-header-number (car headers)))))
3170 (defun gnus-parent-headers (headers &optional generation)
3171 "Return the headers of the GENERATIONeth parent of HEADERS."
3173 (setq generation 1))
3176 (while (and parent headers (not (zerop generation)))
3177 (setq references (mail-header-references headers))
3178 (when (and references
3179 (setq parent (gnus-parent-id references))
3180 (setq headers (car (gnus-id-to-thread parent))))
3184 (defun gnus-id-to-thread (id)
3185 "Return the (sub-)thread where ID appears."
3186 (gnus-gethash id gnus-newsgroup-dependencies))
3188 (defun gnus-id-to-article (id)
3189 "Return the article number of ID."
3190 (let ((thread (gnus-id-to-thread id)))
3193 (mail-header-number (car thread)))))
3195 (defun gnus-id-to-header (id)
3196 "Return the article headers of ID."
3197 (car (gnus-id-to-thread id)))
3199 (defun gnus-article-displayed-root-p (article)
3200 "Say whether ARTICLE is a root(ish) article."
3201 (let ((level (gnus-summary-thread-level article))
3202 (refs (mail-header-references (gnus-summary-article-header article)))
3208 ((null (gnus-parent-id refs)) t)
3210 (null (setq particle (gnus-id-to-article
3211 (gnus-parent-id refs))))
3212 (null (gnus-summary-thread-level particle)))))))
3214 (defun gnus-root-id (id)
3215 "Return the id of the root of the thread where ID appears."
3217 (while (and id (setq prev (car (gnus-gethash
3218 id gnus-newsgroup-dependencies))))
3220 id (gnus-parent-id (mail-header-references prev))))
3223 (defun gnus-articles-in-thread (thread)
3224 "Return the list of articles in THREAD."
3225 (cons (mail-header-number (car thread))
3226 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3228 (defun gnus-remove-thread (id &optional dont-remove)
3229 "Remove the thread that has ID in it."
3230 (let ((dep gnus-newsgroup-dependencies)
3231 headers thread last-id)
3232 ;; First go up in this thread until we find the root.
3233 (setq last-id (gnus-root-id id))
3234 (setq headers (list (car (gnus-id-to-thread last-id))
3235 (caadr (gnus-id-to-thread last-id))))
3236 ;; We have now found the real root of this thread. It might have
3237 ;; been gathered into some loose thread, so we have to search
3238 ;; through the threads to find the thread we wanted.
3239 (let ((threads gnus-newsgroup-threads)
3242 (setq sub (car threads))
3243 (if (stringp (car sub))
3244 ;; This is a gathered thread, so we look at the roots
3245 ;; below it to find whether this article is in this
3248 (setq sub (cdr sub))
3250 (when (member (caar sub) headers)
3251 (setq thread (car threads)
3254 (setq sub (cdr sub))))
3255 ;; It's an ordinary thread, so we check it.
3256 (when (eq (car sub) (car headers))
3259 (setq threads (cdr threads)))
3260 ;; If this article is in no thread, then it's a root.
3263 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3264 (setq thread (gnus-gethash last-id dep)))
3267 thread ; We return this thread.
3269 (if (stringp (car thread))
3271 ;; If we use dummy roots, then we have to remove the
3272 ;; dummy root as well.
3273 (when (eq gnus-summary-make-false-root 'dummy)
3275 (gnus-data-compute-positions))
3276 (setq thread (cdr thread))
3278 (gnus-remove-thread-1 (car thread))
3279 (setq thread (cdr thread))))
3280 (gnus-remove-thread-1 thread))))))))
3282 (defun gnus-remove-thread-1 (thread)
3283 "Remove the thread THREAD recursively."
3284 (let ((number (mail-header-number (pop thread)))
3286 (setq thread (reverse thread))
3288 (gnus-remove-thread-1 (pop thread)))
3289 (when (setq d (gnus-data-find number))
3290 (goto-char (gnus-data-pos d))
3293 (- (gnus-point-at-bol)
3295 (1+ (gnus-point-at-eol))
3296 (gnus-delete-line)))))))
3298 (defun gnus-sort-threads (threads)
3300 (if (not gnus-thread-sort-functions)
3302 (gnus-message 7 "Sorting threads...")
3304 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3305 (gnus-message 7 "Sorting threads...done"))))
3307 (defun gnus-sort-articles (articles)
3309 (when gnus-article-sort-functions
3310 (gnus-message 7 "Sorting articles...")
3312 (setq gnus-newsgroup-headers
3313 (sort articles (gnus-make-sort-function
3314 gnus-article-sort-functions)))
3315 (gnus-message 7 "Sorting articles...done"))))
3317 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3318 (defmacro gnus-thread-header (thread)
3319 ;; Return header of first article in THREAD.
3320 ;; Note that THREAD must never, ever be anything else than a variable -
3321 ;; using some other form will lead to serious barfage.
3322 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3323 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3324 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3327 (defsubst gnus-article-sort-by-number (h1 h2)
3328 "Sort articles by article number."
3329 (< (mail-header-number h1)
3330 (mail-header-number h2)))
3332 (defun gnus-thread-sort-by-number (h1 h2)
3333 "Sort threads by root article number."
3334 (gnus-article-sort-by-number
3335 (gnus-thread-header h1) (gnus-thread-header h2)))
3337 (defsubst gnus-article-sort-by-lines (h1 h2)
3338 "Sort articles by article Lines header."
3339 (< (mail-header-lines h1)
3340 (mail-header-lines h2)))
3342 (defun gnus-thread-sort-by-lines (h1 h2)
3343 "Sort threads by root article Lines header."
3344 (gnus-article-sort-by-lines
3345 (gnus-thread-header h1) (gnus-thread-header h2)))
3347 (defsubst gnus-article-sort-by-author (h1 h2)
3348 "Sort articles by root author."
3350 (let ((extract (funcall
3351 gnus-extract-address-components
3352 (mail-header-from h1))))
3353 (or (car extract) (cadr extract) ""))
3354 (let ((extract (funcall
3355 gnus-extract-address-components
3356 (mail-header-from h2))))
3357 (or (car extract) (cadr extract) ""))))
3359 (defun gnus-thread-sort-by-author (h1 h2)
3360 "Sort threads by root author."
3361 (gnus-article-sort-by-author
3362 (gnus-thread-header h1) (gnus-thread-header h2)))
3364 (defsubst gnus-article-sort-by-subject (h1 h2)
3365 "Sort articles by root subject."
3367 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3368 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3370 (defun gnus-thread-sort-by-subject (h1 h2)
3371 "Sort threads by root subject."
3372 (gnus-article-sort-by-subject
3373 (gnus-thread-header h1) (gnus-thread-header h2)))
3375 (defsubst gnus-article-sort-by-date (h1 h2)
3376 "Sort articles by root article date."
3378 (gnus-date-get-time (mail-header-date h1))
3379 (gnus-date-get-time (mail-header-date h2))))
3381 (defun gnus-thread-sort-by-date (h1 h2)
3382 "Sort threads by root article date."
3383 (gnus-article-sort-by-date
3384 (gnus-thread-header h1) (gnus-thread-header h2)))
3386 (defsubst gnus-article-sort-by-score (h1 h2)
3387 "Sort articles by root article score.
3388 Unscored articles will be counted as having a score of zero."
3389 (> (or (cdr (assq (mail-header-number h1)
3390 gnus-newsgroup-scored))
3391 gnus-summary-default-score 0)
3392 (or (cdr (assq (mail-header-number h2)
3393 gnus-newsgroup-scored))
3394 gnus-summary-default-score 0)))
3396 (defun gnus-thread-sort-by-score (h1 h2)
3397 "Sort threads by root article score."
3398 (gnus-article-sort-by-score
3399 (gnus-thread-header h1) (gnus-thread-header h2)))
3401 (defun gnus-thread-sort-by-total-score (h1 h2)
3402 "Sort threads by the sum of all scores in the thread.
3403 Unscored articles will be counted as having a score of zero."
3404 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3406 (defun gnus-thread-total-score (thread)
3407 ;; This function find the total score of THREAD.
3408 (cond ((null thread)
3411 (if (stringp (car thread))
3412 (apply gnus-thread-score-function 0
3413 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3414 (gnus-thread-total-score-1 thread)))
3416 (gnus-thread-total-score-1 (list thread)))))
3418 (defun gnus-thread-total-score-1 (root)
3419 ;; This function find the total score of the thread below ROOT.
3420 (setq root (car root))
3421 (apply gnus-thread-score-function
3423 (mapcar 'gnus-thread-total-score
3424 (cdr (gnus-gethash (mail-header-id root)
3425 gnus-newsgroup-dependencies)))
3426 (when (> (mail-header-number root) 0)
3427 (list (or (cdr (assq (mail-header-number root)
3428 gnus-newsgroup-scored))
3429 gnus-summary-default-score 0))))
3430 (list gnus-summary-default-score)
3433 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3434 (defvar gnus-tmp-prev-subject nil)
3435 (defvar gnus-tmp-false-parent nil)
3436 (defvar gnus-tmp-root-expunged nil)
3437 (defvar gnus-tmp-dummy-line nil)
3439 (defun gnus-summary-prepare-threads (threads)
3440 "Prepare summary buffer from THREADS and indentation LEVEL.
3441 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3442 or a straight list of headers."
3443 (gnus-message 7 "Generating summary...")
3445 (setq gnus-newsgroup-threads threads)
3448 (let ((gnus-tmp-level 0)
3449 (default-score (or gnus-summary-default-score 0))
3450 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3451 thread number subject stack state gnus-tmp-gathered beg-match
3452 new-roots gnus-tmp-new-adopts thread-end
3453 gnus-tmp-header gnus-tmp-unread
3454 gnus-tmp-replied gnus-tmp-subject-or-nil
3455 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3456 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3457 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3459 (setq gnus-tmp-prev-subject nil)
3461 (if (vectorp (car threads))
3462 ;; If this is a straight (sic) list of headers, then a
3463 ;; threaded summary display isn't required, so we just create
3464 ;; an unthreaded one.
3465 (gnus-summary-prepare-unthreaded threads)
3467 ;; Do the threaded display.
3469 (while (or threads stack gnus-tmp-new-adopts new-roots)
3471 (if (and (= gnus-tmp-level 0)
3472 (not (setq gnus-tmp-dummy-line nil))
3475 (not gnus-tmp-false-parent)
3476 (or gnus-tmp-new-adopts new-roots))
3477 (if gnus-tmp-new-adopts
3478 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3479 thread (list (car gnus-tmp-new-adopts))
3480 gnus-tmp-header (caar thread)
3481 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3483 (setq thread (list (car new-roots))
3484 gnus-tmp-header (caar thread)
3485 new-roots (cdr new-roots))))
3488 ;; If there are some threads, we do them before the
3489 ;; threads on the stack.
3490 (setq thread threads
3491 gnus-tmp-header (caar thread))
3492 ;; There were no current threads, so we pop something off
3494 (setq state (car stack)
3495 gnus-tmp-level (car state)
3498 gnus-tmp-header (caar thread))))
3500 (setq gnus-tmp-false-parent nil)
3501 (setq gnus-tmp-root-expunged nil)
3502 (setq thread-end nil)
3504 (if (stringp gnus-tmp-header)
3505 ;; The header is a dummy root.
3507 ((eq gnus-summary-make-false-root 'adopt)
3508 ;; We let the first article adopt the rest.
3509 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3511 (setq gnus-tmp-gathered
3513 (lambda (h) (mail-header-number (car h)))
3516 (setq thread (cons (list (caar thread)
3519 (setq gnus-tmp-level -1
3520 gnus-tmp-false-parent t))
3521 ((eq gnus-summary-make-false-root 'empty)
3522 ;; We print adopted articles with empty subject fields.
3523 (setq gnus-tmp-gathered
3525 (lambda (h) (mail-header-number (car h)))
3528 (setq gnus-tmp-level -1))
3529 ((eq gnus-summary-make-false-root 'dummy)
3530 ;; We remember that we probably want to output a dummy
3532 (setq gnus-tmp-dummy-line gnus-tmp-header)
3533 (setq gnus-tmp-prev-subject gnus-tmp-header))
3535 ;; We do not make a root for the gathered
3536 ;; sub-threads at all.
3537 (setq gnus-tmp-level -1)))
3539 (setq number (mail-header-number gnus-tmp-header)
3540 subject (mail-header-subject gnus-tmp-header))
3543 ;; If the thread has changed subject, we might want to make
3544 ;; this subthread into a root.
3545 ((and (null gnus-thread-ignore-subject)
3546 (not (zerop gnus-tmp-level))
3547 gnus-tmp-prev-subject
3549 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3550 (setq new-roots (nconc new-roots (list (car thread)))
3552 gnus-tmp-header nil))
3553 ;; If the article lies outside the current limit,
3554 ;; then we do not display it.
3555 ((not (memq number gnus-newsgroup-limit))
3556 (setq gnus-tmp-gathered
3558 (lambda (h) (mail-header-number (car h)))
3561 (setq gnus-tmp-new-adopts (if (cdar thread)
3562 (append gnus-tmp-new-adopts
3564 gnus-tmp-new-adopts)
3566 gnus-tmp-header nil)
3567 (when (zerop gnus-tmp-level)
3568 (setq gnus-tmp-root-expunged t)))
3569 ;; Perhaps this article is to be marked as read?
3570 ((and gnus-summary-mark-below
3571 (< (or (cdr (assq number gnus-newsgroup-scored))
3573 gnus-summary-mark-below)
3574 ;; Don't touch sparse articles.
3575 (not (gnus-summary-article-sparse-p number))
3576 (not (gnus-summary-article-ancient-p number)))
3577 (setq gnus-newsgroup-unreads
3578 (delq number gnus-newsgroup-unreads))
3579 (if gnus-newsgroup-auto-expire
3580 (push number gnus-newsgroup-expirable)
3581 (push (cons number gnus-low-score-mark)
3582 gnus-newsgroup-reads))))
3584 (when gnus-tmp-header
3585 ;; We may have an old dummy line to output before this
3587 (when gnus-tmp-dummy-line
3588 (gnus-summary-insert-dummy-line
3589 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3590 (setq gnus-tmp-dummy-line nil))
3592 ;; Compute the mark.
3593 (setq gnus-tmp-unread (gnus-article-mark number))
3595 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3596 gnus-tmp-header gnus-tmp-level)
3597 gnus-newsgroup-data)
3599 ;; Actually insert the line.
3601 gnus-tmp-subject-or-nil
3603 ((and gnus-thread-ignore-subject
3604 gnus-tmp-prev-subject
3605 (not (inline (gnus-subject-equal
3606 gnus-tmp-prev-subject subject))))
3608 ((zerop gnus-tmp-level)
3609 (if (and (eq gnus-summary-make-false-root 'empty)
3610 (memq number gnus-tmp-gathered)
3611 gnus-tmp-prev-subject
3612 (inline (gnus-subject-equal
3613 gnus-tmp-prev-subject subject)))
3614 gnus-summary-same-subject
3616 (t gnus-summary-same-subject)))
3617 (if (and (eq gnus-summary-make-false-root 'adopt)
3618 (= gnus-tmp-level 1)
3619 (memq number gnus-tmp-gathered))
3620 (setq gnus-tmp-opening-bracket ?\<
3621 gnus-tmp-closing-bracket ?\>)
3622 (setq gnus-tmp-opening-bracket ?\[
3623 gnus-tmp-closing-bracket ?\]))
3625 gnus-tmp-indentation
3626 (aref gnus-thread-indent-array gnus-tmp-level)
3627 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3628 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3629 gnus-summary-default-score 0)
3631 (if (or (null gnus-summary-default-score)
3632 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3633 gnus-summary-zcore-fuzz))
3635 (if (< gnus-tmp-score gnus-summary-default-score)
3636 gnus-score-below-mark gnus-score-over-mark))
3638 (cond ((memq number gnus-newsgroup-processable)
3640 ((memq number gnus-newsgroup-cached)
3642 ((memq number gnus-newsgroup-replied)
3644 ((memq number gnus-newsgroup-saved)
3646 (t gnus-unread-mark))
3647 gnus-tmp-from (mail-header-from gnus-tmp-header)
3650 ((string-match "<[^>]+> *$" gnus-tmp-from)
3651 (setq beg-match (match-beginning 0))
3652 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3653 (substring gnus-tmp-from (1+ (match-beginning 0))
3654 (1- (match-end 0))))
3655 (substring gnus-tmp-from 0 beg-match)))
3656 ((string-match "(.+)" gnus-tmp-from)
3657 (substring gnus-tmp-from
3658 (1+ (match-beginning 0)) (1- (match-end 0))))
3660 (when (string= gnus-tmp-name "")
3661 (setq gnus-tmp-name gnus-tmp-from))
3662 (unless (numberp gnus-tmp-lines)
3663 (setq gnus-tmp-lines 0))
3664 (gnus-put-text-property
3666 (progn (eval gnus-summary-line-format-spec) (point))
3667 'gnus-number number)
3670 (run-hooks 'gnus-summary-update-hook)
3673 (setq gnus-tmp-prev-subject subject)))
3675 (when (nth 1 thread)
3676 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3677 (incf gnus-tmp-level)
3678 (setq threads (if thread-end nil (cdar thread)))
3680 (setq gnus-tmp-level 0)))))
3681 (gnus-message 7 "Generating summary...done"))
3683 (defun gnus-summary-prepare-unthreaded (headers)
3684 "Generate an unthreaded summary buffer based on HEADERS."
3685 (let (header number mark)
3690 ;; We may have to root out some bad articles...
3691 (when (memq (setq number (mail-header-number
3692 (setq header (pop headers))))
3693 gnus-newsgroup-limit)
3694 ;; Mark article as read when it has a low score.
3695 (when (and gnus-summary-mark-below
3696 (< (or (cdr (assq number gnus-newsgroup-scored))
3697 gnus-summary-default-score 0)
3698 gnus-summary-mark-below)
3699 (not (gnus-summary-article-ancient-p number)))
3700 (setq gnus-newsgroup-unreads
3701 (delq number gnus-newsgroup-unreads))
3702 (if gnus-newsgroup-auto-expire
3703 (push number gnus-newsgroup-expirable)
3704 (push (cons number gnus-low-score-mark)
3705 gnus-newsgroup-reads)))
3707 (setq mark (gnus-article-mark number))
3708 (push (gnus-data-make number mark (1+ (point)) header 0)
3709 gnus-newsgroup-data)
3710 (gnus-summary-insert-line
3712 mark (memq number gnus-newsgroup-replied)
3713 (memq number gnus-newsgroup-expirable)
3714 (mail-header-subject header) nil
3715 (cdr (assq number gnus-newsgroup-scored))
3716 (memq number gnus-newsgroup-processable))))))
3718 (defun gnus-select-newsgroup (group &optional read-all)
3719 "Select newsgroup GROUP.
3720 If READ-ALL is non-nil, all articles in the group are selected."
3721 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3722 ;;!!! Dirty hack; should be removed.
3723 (gnus-summary-ignore-duplicates
3724 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3726 gnus-summary-ignore-duplicates))
3727 (info (nth 2 entry))
3728 articles fetched-articles cached)
3730 (unless (gnus-check-server
3731 (setq gnus-current-select-method
3732 (gnus-find-method-for-group group)))
3733 (error "Couldn't open server"))
3735 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3736 (gnus-activate-group group) ; Or we can activate it...
3737 (progn ; Or we bug out.
3738 (when (equal major-mode 'gnus-summary-mode)
3739 (kill-buffer (current-buffer)))
3740 (error "Couldn't request group %s: %s"
3741 group (gnus-status-message group))))
3743 (unless (gnus-request-group group t)
3744 (when (equal major-mode 'gnus-summary-mode)
3745 (kill-buffer (current-buffer)))
3746 (error "Couldn't request group %s: %s"
3747 group (gnus-status-message group)))
3749 (setq gnus-newsgroup-name group)
3750 (setq gnus-newsgroup-unselected nil)
3751 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3753 ;; Adjust and set lists of article marks.
3755 (gnus-adjust-marked-articles info))
3757 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3758 (when (gnus-virtual-group-p group)
3759 (setq cached gnus-newsgroup-cached))
3761 (setq gnus-newsgroup-unreads
3762 (gnus-set-difference
3763 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3764 gnus-newsgroup-dormant))
3766 (setq gnus-newsgroup-processable nil)
3768 (gnus-update-read-articles group gnus-newsgroup-unreads)
3769 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3770 (gnus-group-update-group group))
3772 (setq articles (gnus-articles-to-read group read-all))
3776 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3778 ((eq articles 0) nil)
3780 ;; Init the dependencies hash table.
3781 (setq gnus-newsgroup-dependencies
3782 (gnus-make-hashtable (length articles)))
3783 ;; Retrieve the headers and read them in.
3784 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3785 (setq gnus-newsgroup-headers
3787 (setq gnus-headers-retrieved-by
3788 (gnus-retrieve-headers
3789 articles gnus-newsgroup-name
3790 ;; We might want to fetch old headers, but
3791 ;; not if there is only 1 article.
3792 (and gnus-fetch-old-headers
3794 (not (eq gnus-fetch-old-headers 'some))
3795 (not (numberp gnus-fetch-old-headers)))
3796 (> (length articles) 1))))))
3797 (gnus-get-newsgroup-headers-xover
3798 articles nil nil gnus-newsgroup-name t)
3799 (gnus-get-newsgroup-headers)))
3800 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3802 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3804 (setq gnus-newsgroup-cached cached))
3806 ;; Suppress duplicates?
3807 (when gnus-suppress-duplicates
3808 (gnus-dup-suppress-articles))
3810 ;; Set the initial limit.
3811 (setq gnus-newsgroup-limit (copy-sequence articles))
3812 ;; Remove canceled articles from the list of unread articles.
3813 (setq gnus-newsgroup-unreads
3814 (gnus-set-sorted-intersection
3815 gnus-newsgroup-unreads
3816 (setq fetched-articles
3817 (mapcar (lambda (headers) (mail-header-number headers))
3818 gnus-newsgroup-headers))))
3819 ;; Removed marked articles that do not exist.
3820 (gnus-update-missing-marks
3821 (gnus-sorted-complement fetched-articles articles))
3822 ;; Let the Gnus agent mark articles as read.
3824 (gnus-agent-get-undownloaded-list))
3825 ;; We might want to build some more threads first.
3826 (when (and gnus-fetch-old-headers
3827 (eq gnus-headers-retrieved-by 'nov))
3828 (if (eq gnus-fetch-old-headers 'invisible)
3829 (gnus-build-all-threads)
3830 (gnus-build-old-threads)))
3831 ;; Check whether auto-expire is to be done in this group.
3832 (setq gnus-newsgroup-auto-expire
3833 (gnus-group-auto-expirable-p group))
3834 ;; Set up the article buffer now, if necessary.
3835 (unless gnus-single-article-buffer
3836 (gnus-article-setup-buffer))
3837 ;; First and last article in this newsgroup.
3838 (when gnus-newsgroup-headers
3839 (setq gnus-newsgroup-begin
3840 (mail-header-number (car gnus-newsgroup-headers))
3843 (gnus-last-element gnus-newsgroup-headers))))
3844 ;; GROUP is successfully selected.
3845 (or gnus-newsgroup-headers t)))))
3847 (defun gnus-articles-to-read (group &optional read-all)
3848 ;; Find out what articles the user wants to read.
3850 ;; Select all articles if `read-all' is non-nil, or if there
3851 ;; are no unread articles.
3853 (and (zerop (length gnus-newsgroup-marked))
3854 (zerop (length gnus-newsgroup-unreads)))
3855 (eq (gnus-group-find-parameter group 'display)
3857 (gnus-uncompress-range (gnus-active group))
3858 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3859 (copy-sequence gnus-newsgroup-unreads))
3861 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3862 (scored (length scored-list))
3863 (number (length articles))
3864 (marked (+ (length gnus-newsgroup-marked)
3865 (length gnus-newsgroup-dormant)))
3873 ((and (or (<= scored marked) (= scored number))
3874 (numberp gnus-large-newsgroup)
3875 (> number gnus-large-newsgroup))
3879 "How many articles from %s (default %d): "
3880 (gnus-limit-string gnus-newsgroup-name 35)
3882 (if (string-match "^[ \t]*$" input) number input)))
3883 ((and (> scored marked) (< scored number)
3884 (> (- scored number) 20))
3887 (format "%s %s (%d scored, %d total): "
3888 "How many articles from"
3889 group scored number))))
3890 (if (string-match "^[ \t]*$" input)
3894 (setq select (if (stringp select) (string-to-number select) select))
3895 (if (or (null select) (zerop select))
3897 (if (and (not (zerop scored)) (<= (abs select) scored))
3899 (setq articles (sort scored-list '<))
3900 (setq number (length articles)))
3901 (setq articles (copy-sequence articles)))
3903 (when (< (abs select) number)
3905 ;; Select the N oldest articles.
3906 (setcdr (nthcdr (1- (abs select)) articles) nil)
3907 ;; Select the N most recent articles.
3908 (setq articles (nthcdr (- number select) articles))))
3909 (setq gnus-newsgroup-unselected
3910 (gnus-sorted-intersection
3911 gnus-newsgroup-unreads
3912 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3915 (defun gnus-killed-articles (killed articles)
3918 (when (inline (gnus-member-of-range (car articles) killed))
3919 (push (car articles) out))
3920 (setq articles (cdr articles)))
3923 (defun gnus-uncompress-marks (marks)
3924 "Uncompress the mark ranges in MARKS."
3925 (let ((uncompressed '(score bookmark))
3928 (if (memq (caar marks) uncompressed)
3929 (push (car marks) out)
3930 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3931 (setq marks (cdr marks)))
3934 (defun gnus-adjust-marked-articles (info)
3935 "Set all article lists and remove all marks that are no longer legal."
3936 (let* ((marked-lists (gnus-info-marks info))
3937 (active (gnus-active (gnus-info-group info)))
3940 (types gnus-article-mark-lists)
3941 (uncompressed '(score bookmark killed))
3942 marks var articles article mark)
3945 (setq marks (pop marked-lists))
3946 (set (setq var (intern (format "gnus-newsgroup-%s"
3947 (car (rassq (setq mark (car marks))
3949 (if (memq (car marks) uncompressed) (cdr marks)
3950 (gnus-uncompress-range (cdr marks))))
3952 (setq articles (symbol-value var))
3954 ;; All articles have to be subsets of the active articles.
3956 ;; Adjust "simple" lists.
3957 ((memq mark '(tick dormant expire reply save))
3959 (when (or (< (setq article (pop articles)) min) (> article max))
3960 (set var (delq article (symbol-value var))))))
3962 ((memq mark uncompressed)
3963 (when (not (listp (cdr (symbol-value var))))
3964 (set var (list (symbol-value var))))
3965 (when (not (listp (cdr articles)))
3966 (setq articles (list articles)))
3968 (when (or (not (consp (setq article (pop articles))))
3969 (< (car article) min)
3970 (> (car article) max))
3971 (set var (delq article (symbol-value var))))))))))
3973 (defun gnus-update-missing-marks (missing)
3974 "Go through the list of MISSING articles and remove them mark lists."
3976 (let ((types gnus-article-mark-lists)
3978 ;; Go through all types.
3980 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3981 (when (symbol-value var)
3982 ;; This list has articles. So we delete all missing articles
3986 (set var (delq (pop m) (symbol-value var)))))))))
3988 (defun gnus-update-marks ()
3989 "Enter the various lists of marked articles into the newsgroup info list."
3990 (let ((types gnus-article-mark-lists)
3991 (info (gnus-get-info gnus-newsgroup-name))
3992 (uncompressed '(score bookmark killed))
3993 type list newmarked symbol)
3995 ;; Add all marks lists that are non-nil to the list of marks lists.
3996 (while (setq type (pop types))
3997 (when (setq list (symbol-value
3999 (intern (format "gnus-newsgroup-%s"
4002 ;; Get rid of the entries of the articles that have the
4004 (when (and (eq (cdr type) 'score)
4008 (prev (cons nil list))
4011 (if (or (not (consp (car arts)))
4012 (= (cdar arts) gnus-summary-default-score))
4013 (setcdr prev (cdr arts))
4015 (setq arts (cdr arts)))
4016 (setq list (cdr all))))
4018 (push (cons (cdr type)
4019 (if (memq (cdr type) uncompressed) list
4020 (gnus-compress-sequence
4021 (set symbol (sort list '<)) t)))
4024 ;; Enter these new marks into the info of the group.
4026 (setcar (nthcdr 3 info) newmarked)
4027 ;; Add the marks lists to the end of the info.
4029 (setcdr (nthcdr 2 info) (list newmarked))))
4031 ;; Cut off the end of the info if there's nothing else there.
4035 (when (nthcdr (decf i) info)
4036 (setcdr (nthcdr i info) nil)))))))
4038 (defun gnus-set-mode-line (where)
4039 "This function sets the mode line of the article or summary buffers.
4040 If WHERE is `summary', the summary mode line format will be used."
4041 ;; Is this mode line one we keep updated?
4042 (when (memq where gnus-updated-mode-lines)
4045 ;; We evaluate this in the summary buffer since these
4046 ;; variables are buffer-local to that buffer.
4047 (set-buffer gnus-summary-buffer)
4048 ;; We bind all these variables that are used in the `eval' form
4050 (let* ((mformat (symbol-value
4052 (format "gnus-%s-mode-line-format-spec" where))))
4053 (gnus-tmp-group-name gnus-newsgroup-name)
4054 (gnus-tmp-article-number (or gnus-current-article 0))
4055 (gnus-tmp-unread gnus-newsgroup-unreads)
4056 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4057 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4058 (gnus-tmp-unread-and-unselected
4059 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4060 (zerop gnus-tmp-unselected))
4062 ((zerop gnus-tmp-unselected)
4063 (format "{%d more}" gnus-tmp-unread-and-unticked))
4064 (t (format "{%d(+%d) more}"
4065 gnus-tmp-unread-and-unticked
4066 gnus-tmp-unselected))))
4068 (if (and gnus-current-headers
4069 (vectorp gnus-current-headers))
4070 (gnus-mode-string-quote
4071 (mail-header-subject gnus-current-headers))
4073 bufname-length max-len
4074 gnus-tmp-header);; passed as argument to any user-format-funcs
4075 (setq mode-string (eval mformat))
4076 (setq bufname-length (if (string-match "%b" mode-string)
4079 (if (eq where 'summary)
4081 (get-buffer gnus-article-buffer))))
4084 (setq max-len (max 4 (if gnus-mode-non-string-length
4086 gnus-mode-non-string-length
4088 (length mode-string))))
4089 ;; We might have to chop a bit of the string off...
4090 (when (> (length mode-string) max-len)
4092 (concat (gnus-truncate-string mode-string (- max-len 3))
4094 ;; Pad the mode string a bit.
4095 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4096 ;; Update the mode line.
4097 (setq mode-line-buffer-identification
4098 (gnus-mode-line-buffer-identification (list mode-string)))
4099 (set-buffer-modified-p t))))
4101 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4102 "Go through the HEADERS list and add all Xrefs to a hash table.
4103 The resulting hash table is returned, or nil if no Xrefs were found."
4104 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4105 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4106 (xref-hashtb (gnus-make-hashtable))
4107 start group entry number xrefs header)
4109 (setq header (pop headers))
4110 (when (and (setq xrefs (mail-header-xref header))
4111 (not (memq (setq number (mail-header-number header))
4114 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4115 (setq start (match-end 0))
4116 (setq group (if prefix
4117 (concat prefix (substring xrefs (match-beginning 1)
4119 (substring xrefs (match-beginning 1) (match-end 1))))
4121 (string-to-int (substring xrefs (match-beginning 2)
4123 (if (setq entry (gnus-gethash group xref-hashtb))
4124 (setcdr entry (cons number (cdr entry)))
4125 (gnus-sethash group (cons number nil) xref-hashtb)))))
4126 (and start xref-hashtb)))
4128 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4129 "Look through all the headers and mark the Xrefs as read."
4130 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4131 name entry info xref-hashtb idlist method nth4)
4133 (set-buffer gnus-group-buffer)
4134 (when (setq xref-hashtb
4135 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4138 (unless (string= from-newsgroup (setq name (symbol-name group)))
4139 (setq idlist (symbol-value group))
4140 ;; Dead groups are not updated.
4142 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4144 (when (stringp (setq nth4 (gnus-info-method info)))
4145 (setq nth4 (gnus-server-to-method nth4))))
4146 ;; Only do the xrefs if the group has the same
4147 ;; select method as the group we have just read.
4148 (or (gnus-methods-equal-p
4149 nth4 (gnus-find-method-for-group from-newsgroup))
4151 (equal nth4 (setq method (gnus-find-method-for-group
4153 (and (equal (car nth4) (car method))
4154 (equal (nth 1 nth4) (nth 1 method))))
4155 gnus-use-cross-reference
4156 (or (not (eq gnus-use-cross-reference t))
4158 ;; Only do cross-references on subscribed
4159 ;; groups, if that is what is wanted.
4160 (<= (gnus-info-level info) gnus-level-subscribed))
4161 (gnus-group-make-articles-read name idlist))))
4164 (defun gnus-compute-read-articles (group articles)
4165 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4166 (info (nth 2 entry))
4167 (active (gnus-active group))
4170 ;; First peel off all illegal article numbers.
4172 (let ((ids articles)
4174 (while (setq id (pop ids))
4175 (when (and first (> id (cdr active)))
4176 ;; We'll end up in this situation in one particular
4177 ;; obscure situation. If you re-scan a group and get
4178 ;; a new article that is cross-posted to a different
4179 ;; group that has not been re-scanned, you might get
4180 ;; crossposted article that has a higher number than
4181 ;; Gnus believes possible. So we re-activate this
4182 ;; group as well. This might mean doing the
4183 ;; crossposting thingy will *increase* the number
4184 ;; of articles in some groups. Tsk, tsk.
4185 (setq active (or (gnus-activate-group group) active)))
4186 (when (or (> id (cdr active))
4187 (< id (car active)))
4188 (setq articles (delq id articles))))))
4189 ;; If the read list is nil, we init it.
4191 (null (gnus-info-read info))
4193 (setq ninfo (cons 1 (1- (car active))))
4194 (setq ninfo (gnus-info-read info)))
4195 ;; Then we add the read articles to the range.
4197 ninfo (setq articles (sort articles '<))))))
4199 (defun gnus-group-make-articles-read (group articles)
4200 "Update the info of GROUP to say that ARTICLES are read."
4202 (entry (gnus-gethash group gnus-newsrc-hashtb))
4203 (info (nth 2 entry))
4204 (active (gnus-active group))
4207 (setq range (gnus-compute-read-articles group articles))
4209 (set-buffer gnus-group-buffer)
4212 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4213 (gnus-info-set-read ',info ',(gnus-info-read info))
4214 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4215 (gnus-group-update-group ,group t))))
4216 ;; Add the read articles to the range.
4217 (gnus-info-set-read info range)
4218 ;; Then we have to re-compute how many unread
4219 ;; articles there are in this group.
4223 (setq num (- (1+ (cdr active)) (car active))))
4224 ((not (listp (cdr range)))
4225 (setq num (- (cdr active) (- (1+ (cdr range))
4229 (if (numberp (car range))
4231 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4232 (setq range (cdr range)))
4233 (setq num (- (cdr active) num))))
4234 ;; Update the number of unread articles.
4236 ;; Update the group buffer.
4237 (gnus-group-update-group group t)))))
4239 (defun gnus-methods-equal-p (m1 m2)
4240 (let ((m1 (or m1 gnus-select-method))
4241 (m2 (or m2 gnus-select-method)))
4243 (and (eq (car m1) (car m2))
4244 (or (not (memq 'address (assoc (symbol-name (car m1))
4245 gnus-valid-select-methods)))
4246 (equal (nth 1 m1) (nth 1 m2)))))))
4248 (defvar gnus-newsgroup-none-id 0)
4250 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4251 (let ((cur nntp-server-buffer)
4254 (save-excursion (set-buffer gnus-summary-buffer)
4255 gnus-newsgroup-dependencies)))
4256 headers id id-dep ref-dep end ref)
4258 (set-buffer nntp-server-buffer)
4259 ;; Translate all TAB characters into SPACE characters.
4260 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4261 (run-hooks 'gnus-parse-headers-hook)
4262 (let ((case-fold-search t)
4263 in-reply-to header p lines)
4264 (goto-char (point-min))
4265 ;; Search to the beginning of the next header. Error messages
4266 ;; do not begin with 2 or 3.
4267 (while (re-search-forward "^[23][0-9]+ " nil t)
4270 ;; This implementation of this function, with nine
4271 ;; search-forwards instead of the one re-search-forward and
4272 ;; a case (which basically was the old function) is actually
4273 ;; about twice as fast, even though it looks messier. You
4274 ;; can't have everything, I guess. Speed and elegance
4275 ;; doesn't always go hand in hand.
4284 (narrow-to-region (point)
4285 (or (and (search-forward "\n.\n" nil t)
4291 (if (search-forward "\nsubject: " nil t)
4292 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4294 gnus-unstructured-field-decoder (nnheader-header-value))
4299 (if (search-forward "\nfrom: " nil t)
4300 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4302 gnus-structured-field-decoder (nnheader-header-value))
4307 (if (search-forward "\ndate: " nil t)
4308 (nnheader-header-value) ""))
4312 (setq id (if (search-forward "\nmessage-id:" nil t)
4314 (1- (or (search-forward "<" nil t) (point)))
4315 (or (search-forward ">" nil t) (point)))
4316 ;; If there was no message-id, we just fake one
4317 ;; to make subsequent routines simpler.
4318 (nnheader-generate-fake-message-id))))
4322 (if (search-forward "\nreferences: " nil t)
4326 (nnheader-header-value)
4331 (search-backward ">" end t)
4334 (search-backward "<" end t)
4336 ;; Get the references from the in-reply-to header if there
4337 ;; were no references and the in-reply-to header looks
4339 (if (and (search-forward "\nin-reply-to: " nil t)
4340 (setq in-reply-to (nnheader-header-value))
4341 (string-match "<[^>]+>" in-reply-to))
4342 (setq ref (substring in-reply-to (match-beginning 0)
4350 (if (search-forward "\nlines: " nil t)
4351 (if (numberp (setq lines (ignore-errors (read cur))))
4357 (and (search-forward "\nxref: " nil t)
4358 (nnheader-header-value)))))
4359 (when (equal id ref)
4362 (when gnus-alter-header-function
4363 (funcall gnus-alter-header-function header)
4364 (setq id (mail-header-id header)
4365 ref (gnus-parent-id (mail-header-references header))))
4367 ;; We do the threading while we read the headers. The
4368 ;; message-id and the last reference are both entered into
4369 ;; the same hash table. Some tippy-toeing around has to be
4370 ;; done in case an article has arrived before the article
4371 ;; which it refers to.
4372 (if (boundp (setq id-dep (intern id dependencies)))
4373 (if (and (car (symbol-value id-dep))
4375 ;; An article with this Message-ID has already been seen.
4376 (if gnus-summary-ignore-duplicates
4377 ;; We ignore this one, except we add
4378 ;; any additional Xrefs (in case the two articles
4379 ;; came from different servers).
4381 (mail-header-set-xref
4382 (car (symbol-value id-dep))
4383 (concat (or (mail-header-xref
4384 (car (symbol-value id-dep)))
4386 (or (mail-header-xref header) "")))
4388 ;; We rename the Message-ID.
4390 (setq id-dep (intern (setq id (nnmail-message-id))
4393 (mail-header-set-id header id))
4394 (setcar (symbol-value id-dep) header))
4395 (set id-dep (list header)))
4397 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4398 (setcdr (symbol-value ref-dep)
4399 (nconc (cdr (symbol-value ref-dep))
4400 (list (symbol-value id-dep))))
4401 (set ref-dep (list nil (symbol-value id-dep))))
4402 (push header headers))
4403 (goto-char (point-max))
4405 (nreverse headers)))))
4407 ;; The following macros and functions were written by Felix Lee
4408 ;; <flee@cse.psu.edu>.
4410 (defmacro gnus-nov-read-integer ()
4412 (if (= (following-char) ?\t)
4414 (let ((num (ignore-errors (read buffer))))
4415 (if (numberp num) num 0)))
4417 (search-forward "\t" eol 'move))))
4419 (defmacro gnus-nov-skip-field ()
4420 '(search-forward "\t" eol 'move))
4422 (defmacro gnus-nov-field ()
4423 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4425 ;; (defvar gnus-nov-none-counter 0)
4427 ;; This function has to be called with point after the article number
4428 ;; on the beginning of the line.
4429 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4430 (let ((eol (gnus-point-at-eol))
4431 (buffer (current-buffer))
4432 header ref id id-dep ref-dep)
4434 ;; overview: [num subject from date id refs chars lines misc]
4437 (narrow-to-region (point) eol)
4445 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4447 gnus-structured-field-decoder (gnus-nov-field)) ; from
4448 (gnus-nov-field) ; date
4449 (setq id (or (gnus-nov-field)
4450 (nnheader-generate-fake-message-id))) ; id
4452 (let ((beg (point)))
4453 (search-forward "\t" eol)
4454 (if (search-backward ">" beg t)
4458 (search-backward "<" beg t)))
4461 (gnus-nov-field)) ; refs
4462 (gnus-nov-read-integer) ; chars
4463 (gnus-nov-read-integer) ; lines
4464 (if (= (following-char) ?\n)
4466 (gnus-nov-field))))) ; misc
4470 (when gnus-alter-header-function
4471 (funcall gnus-alter-header-function header)
4472 (setq id (mail-header-id header)
4473 ref (gnus-parent-id (mail-header-references header))))
4475 ;; We build the thread tree.
4476 (when (equal id ref)
4477 ;; This article refers back to itself. Naughty, naughty.
4479 (if (boundp (setq id-dep (intern id dependencies)))
4480 (if (and (car (symbol-value id-dep))
4482 ;; An article with this Message-ID has already been seen.
4483 (if gnus-summary-ignore-duplicates
4484 ;; We ignore this one, except we add any additional
4485 ;; Xrefs (in case the two articles came from different
4488 (mail-header-set-xref
4489 (car (symbol-value id-dep))
4490 (concat (or (mail-header-xref
4491 (car (symbol-value id-dep)))
4493 (or (mail-header-xref header) "")))
4495 ;; We rename the Message-ID.
4497 (setq id-dep (intern (setq id (nnmail-message-id))
4500 (mail-header-set-id header id))
4501 (setcar (symbol-value id-dep) header))
4502 (set id-dep (list header)))
4504 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4505 (setcdr (symbol-value ref-dep)
4506 (nconc (cdr (symbol-value ref-dep))
4507 (list (symbol-value id-dep))))
4508 (set ref-dep (list nil (symbol-value id-dep)))))
4511 ;; Goes through the xover lines and returns a list of vectors
4512 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4513 force-new dependencies
4514 group also-fetch-heads)
4515 "Parse the news overview data in the server buffer, and return a
4516 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4517 ;; Get the Xref when the users reads the articles since most/some
4518 ;; NNTP servers do not include Xrefs when using XOVER.
4519 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4520 (let ((cur nntp-server-buffer)
4521 (dependencies (or dependencies gnus-newsgroup-dependencies))
4522 number headers header)
4524 (set-buffer nntp-server-buffer)
4525 ;; Allow the user to mangle the headers before parsing them.
4526 (run-hooks 'gnus-parse-headers-hook)
4527 (goto-char (point-min))
4530 (while (and sequence (not (eobp)))
4531 (setq number (read cur))
4532 (while (and sequence
4533 (< (car sequence) number))
4534 (setq sequence (cdr sequence)))
4536 (eq number (car sequence))
4538 (setq sequence (cdr sequence))
4539 (setq header (inline
4540 (gnus-nov-parse-line
4541 number dependencies force-new))))
4542 (push header headers))
4545 (gnus-error 4 "Strange nov line (%d)"
4546 (count-lines (point-min) (point)))))
4548 ;; A common bug in inn is that if you have posted an article and
4549 ;; then retrieves the active file, it will answer correctly --
4550 ;; the new article is included. However, a NOV entry for the
4551 ;; article may not have been generated yet, so this may fail.
4552 ;; We work around this problem by retrieving the last few
4553 ;; headers using HEAD.
4554 (if (or (not also-fetch-heads)
4556 ;; We (probably) got all the headers.
4558 (let ((gnus-nov-is-evil t))
4561 (when (gnus-retrieve-headers sequence group)
4562 (gnus-get-newsgroup-headers))))))))
4564 (defun gnus-article-get-xrefs ()
4565 "Fill in the Xref value in `gnus-current-headers', if necessary.
4566 This is meant to be called in `gnus-article-internal-prepare-hook'."
4567 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4568 gnus-current-headers)))
4569 (or (not gnus-use-cross-reference)
4571 (and (mail-header-xref headers)
4572 (not (string= (mail-header-xref headers) "")))
4573 (let ((case-fold-search t)
4576 (nnheader-narrow-to-headers)
4577 (goto-char (point-min))
4578 (when (or (and (eq (downcase (following-char)) ?x)
4579 (looking-at "Xref:"))
4580 (search-forward "\nXref:" nil t))
4581 (goto-char (1+ (match-end 0)))
4582 (setq xref (buffer-substring (point)
4583 (progn (end-of-line) (point))))
4584 (mail-header-set-xref headers xref)))))))
4586 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4587 "Find article ID and insert the summary line for that article."
4588 (let ((header (if (and old-header use-old-header)
4589 old-header (gnus-read-header id)))
4590 (number (and (numberp id) id))
4593 ;; Rebuild the thread that this article is part of and go to the
4594 ;; article we have fetched.
4595 (when (and (not gnus-show-threads)
4597 (when (setq d (gnus-data-find (mail-header-number old-header)))
4598 (goto-char (gnus-data-pos d))
4601 (- (gnus-point-at-bol)
4603 (1+ (gnus-point-at-eol))
4604 (gnus-delete-line))))))
4606 (mail-header-set-number header (mail-header-number old-header)))
4607 (setq gnus-newsgroup-sparse
4608 (delq (setq number (mail-header-number header))
4609 gnus-newsgroup-sparse))
4610 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4611 (gnus-rebuild-thread (mail-header-id header))
4612 (gnus-summary-goto-subject number nil t))
4613 (when (and (numberp number)
4615 ;; We have to update the boundaries even if we can't fetch the
4616 ;; article if ID is a number -- so that the next `P' or `N'
4617 ;; command will fetch the previous (or next) article even
4618 ;; if the one we tried to fetch this time has been canceled.
4619 (when (> number gnus-newsgroup-end)
4620 (setq gnus-newsgroup-end number))
4621 (when (< number gnus-newsgroup-begin)
4622 (setq gnus-newsgroup-begin number))
4623 (setq gnus-newsgroup-unselected
4624 (delq number gnus-newsgroup-unselected)))
4625 ;; Report back a success?
4626 (and header (mail-header-number header))))
4628 ;;; Process/prefix in the summary buffer
4630 (defun gnus-summary-work-articles (n)
4631 "Return a list of articles to be worked upon. The prefix argument,
4632 the list of process marked articles, and the current article will be
4633 taken into consideration."
4636 ;; A numerical prefix has been given.
4637 (setq n (prefix-numeric-value n))
4638 (let ((backward (< n 0))
4639 (n (abs (prefix-numeric-value n)))
4644 (push (setq article (gnus-summary-article-number))
4647 (gnus-summary-find-prev nil article)
4648 (gnus-summary-find-next nil article)))
4650 (nreverse articles)))
4651 ((gnus-region-active-p)
4652 ;; Work on the region between point and mark.
4653 (let ((max (max (point) (mark)))
4656 (goto-char (min (point) (mark)))
4659 (push (setq article (gnus-summary-article-number)) articles)
4660 (gnus-summary-find-next nil article)
4662 (nreverse articles))))
4663 (gnus-newsgroup-processable
4664 ;; There are process-marked articles present.
4665 ;; Save current state.
4666 (gnus-summary-save-process-mark)
4668 (reverse gnus-newsgroup-processable))
4670 ;; Just return the current article.
4671 (list (gnus-summary-article-number)))))
4673 (defun gnus-summary-save-process-mark ()
4674 "Push the current set of process marked articles on the stack."
4676 (push (copy-sequence gnus-newsgroup-processable)
4677 gnus-newsgroup-process-stack))
4679 (defun gnus-summary-kill-process-mark ()
4680 "Push the current set of process marked articles on the stack and unmark."
4682 (gnus-summary-save-process-mark)
4683 (gnus-summary-unmark-all-processable))
4685 (defun gnus-summary-yank-process-mark ()
4686 "Pop the last process mark state off the stack and restore it."
4688 (unless gnus-newsgroup-process-stack
4689 (error "Empty mark stack"))
4690 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4692 (defun gnus-summary-process-mark-set (set)
4693 "Make SET into the current process marked articles."
4694 (gnus-summary-unmark-all-processable)
4696 (gnus-summary-set-process-mark (pop set))))
4698 ;;; Searching and stuff
4700 (defun gnus-summary-search-group (&optional backward use-level)
4701 "Search for next unread newsgroup.
4702 If optional argument BACKWARD is non-nil, search backward instead."
4704 (set-buffer gnus-group-buffer)
4705 (when (gnus-group-search-forward
4706 backward nil (if use-level (gnus-group-group-level) nil))
4707 (gnus-group-group-name))))
4709 (defun gnus-summary-best-group (&optional exclude-group)
4710 "Find the name of the best unread group.
4711 If EXCLUDE-GROUP, do not go to this group."
4713 (set-buffer gnus-group-buffer)
4715 (gnus-group-best-unread-group exclude-group))))
4717 (defun gnus-summary-find-next (&optional unread article backward)
4718 (if backward (gnus-summary-find-prev)
4719 (let* ((dummy (gnus-summary-article-intangible-p))
4720 (article (or article (gnus-summary-article-number)))
4721 (arts (gnus-data-find-list article))
4723 (when (and (not dummy)
4724 (or (not gnus-summary-check-current)
4726 (not (gnus-data-unread-p (car arts)))))
4727 (setq arts (cdr arts)))
4732 (when (gnus-data-unread-p (car arts))
4733 (setq result (car arts)
4735 (setq arts (cdr arts)))
4738 (goto-char (gnus-data-pos result))
4739 (gnus-data-number result)))))
4741 (defun gnus-summary-find-prev (&optional unread article)
4742 (let* ((eobp (eobp))
4743 (article (or article (gnus-summary-article-number)))
4744 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4746 (when (and (not eobp)
4747 (or (not gnus-summary-check-current)
4749 (not (gnus-data-unread-p (car arts)))))
4750 (setq arts (cdr arts)))
4755 (when (gnus-data-unread-p (car arts))
4756 (setq result (car arts)
4758 (setq arts (cdr arts)))
4761 (goto-char (gnus-data-pos result))
4762 (gnus-data-number result))))
4764 (defun gnus-summary-find-subject (subject &optional unread backward article)
4765 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4766 (article (or article (gnus-summary-article-number)))
4767 (articles (gnus-data-list backward))
4768 (arts (gnus-data-find-list article articles))
4770 (when (or (not gnus-summary-check-current)
4772 (not (gnus-data-unread-p (car arts))))
4773 (setq arts (cdr arts)))
4775 (and (or (not unread)
4776 (gnus-data-unread-p (car arts)))
4777 (vectorp (gnus-data-header (car arts)))
4779 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4780 (setq result (car arts)
4782 (setq arts (cdr arts)))
4784 (goto-char (gnus-data-pos result))
4785 (gnus-data-number result))))
4787 (defun gnus-summary-search-forward (&optional unread subject backward)
4788 "Search forward for an article.
4789 If UNREAD, look for unread articles. If SUBJECT, look for
4790 articles with that subject. If BACKWARD, search backward instead."
4791 (cond (subject (gnus-summary-find-subject subject unread backward))
4792 (backward (gnus-summary-find-prev unread))
4793 (t (gnus-summary-find-next unread))))
4795 (defun gnus-recenter (&optional n)
4796 "Center point in window and redisplay frame.
4797 Also do horizontal recentering."
4799 (when (and gnus-auto-center-summary
4800 (not (eq gnus-auto-center-summary 'vertical)))
4801 (gnus-horizontal-recenter))
4804 (defun gnus-summary-recenter ()
4805 "Center point in the summary window.
4806 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4807 displayed, no centering will be performed."
4808 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4809 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4810 (let* ((top (cond ((< (window-height) 4) 0)
4811 ((< (window-height) 7) 1)
4813 (height (1- (window-height)))
4814 (bottom (save-excursion (goto-char (point-max))
4815 (forward-line (- height))
4817 (window (get-buffer-window (current-buffer))))
4818 ;; The user has to want it.
4819 (when gnus-auto-center-summary
4820 (when (get-buffer-window gnus-article-buffer)
4821 ;; Only do recentering when the article buffer is displayed,
4822 ;; Set the window start to either `bottom', which is the biggest
4823 ;; possible valid number, or the second line from the top,
4824 ;; whichever is the least.
4826 window (min bottom (save-excursion
4827 (forward-line (- top)) (point)))))
4828 ;; Do horizontal recentering while we're at it.
4829 (when (and (get-buffer-window (current-buffer) t)
4830 (not (eq gnus-auto-center-summary 'vertical)))
4831 (let ((selected (selected-window)))
4832 (select-window (get-buffer-window (current-buffer) t))
4833 (gnus-summary-position-point)
4834 (gnus-horizontal-recenter)
4835 (select-window selected))))))
4837 (defun gnus-summary-jump-to-group (newsgroup)
4838 "Move point to NEWSGROUP in group mode buffer."
4839 ;; Keep update point of group mode buffer if visible.
4840 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4841 (save-window-excursion
4842 ;; Take care of tree window mode.
4843 (when (get-buffer-window gnus-group-buffer)
4844 (pop-to-buffer gnus-group-buffer))
4845 (gnus-group-jump-to-group newsgroup))
4847 ;; Take care of tree window mode.
4848 (if (get-buffer-window gnus-group-buffer)
4849 (pop-to-buffer gnus-group-buffer)
4850 (set-buffer gnus-group-buffer))
4851 (gnus-group-jump-to-group newsgroup))))
4853 ;; This function returns a list of article numbers based on the
4854 ;; difference between the ranges of read articles in this group and
4855 ;; the range of active articles.
4856 (defun gnus-list-of-unread-articles (group)
4857 (let* ((read (gnus-info-read (gnus-get-info group)))
4858 (active (or (gnus-active group) (gnus-activate-group group)))
4861 ;; If none are read, then all are unread.
4863 (setq first (car active))
4864 ;; If the range of read articles is a single range, then the
4865 ;; first unread article is the article after the last read
4866 ;; article. Sounds logical, doesn't it?
4867 (if (not (listp (cdr read)))
4868 (setq first (1+ (cdr read)))
4869 ;; `read' is a list of ranges.
4870 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4876 (while (< first nlast)
4878 (setq first (1+ first))))
4879 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4880 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4881 (setq read (cdr read)))))
4882 ;; And add the last unread articles.
4883 (while (<= first last)
4885 (setq first (1+ first)))
4886 ;; Return the list of unread articles.
4887 (delq 0 (nreverse unread))))
4889 (defun gnus-list-of-read-articles (group)
4890 "Return a list of unread, unticked and non-dormant articles."
4891 (let* ((info (gnus-get-info group))
4892 (marked (gnus-info-marks info))
4893 (active (gnus-active group)))
4895 (gnus-set-difference
4896 (gnus-sorted-complement
4897 (gnus-uncompress-range active)
4898 (gnus-list-of-unread-articles group))
4900 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4901 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4903 ;; Various summary commands
4905 (defun gnus-summary-select-article-buffer ()
4906 "Reconfigure windows to show article buffer."
4908 (if (not (gnus-buffer-live-p gnus-article-buffer))
4909 (error "There is no article buffer for this summary buffer")
4910 (gnus-configure-windows 'article)
4911 (select-window (get-buffer-window gnus-article-buffer))))
4913 (defun gnus-summary-universal-argument (arg)
4914 "Perform any operation on all articles that are process/prefixed."
4916 (gnus-set-global-variables)
4917 (let ((articles (gnus-summary-work-articles arg))
4924 (substitute-command-keys
4925 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4928 (gnus-error 1 "Undefined key")
4931 (gnus-summary-goto-subject (setq article (pop articles)))
4932 (let (gnus-newsgroup-processable)
4933 (command-execute func))
4934 (gnus-summary-remove-process-mark article)))))
4935 (gnus-summary-position-point))
4937 (defun gnus-summary-toggle-truncation (&optional arg)
4938 "Toggle truncation of summary lines.
4939 With arg, turn line truncation on iff arg is positive."
4941 (setq truncate-lines
4942 (if (null arg) (not truncate-lines)
4943 (> (prefix-numeric-value arg) 0)))
4946 (defun gnus-summary-reselect-current-group (&optional all rescan)
4947 "Exit and then reselect the current newsgroup.
4948 The prefix argument ALL means to select all articles."
4950 (gnus-set-global-variables)
4951 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4952 (error "Ephemeral groups can't be reselected"))
4953 (let ((current-subject (gnus-summary-article-number))
4954 (group gnus-newsgroup-name))
4955 (setq gnus-newsgroup-begin nil)
4957 ;; We have to adjust the point of group mode buffer because
4958 ;; point was moved to the next unread newsgroup by exiting.
4959 (gnus-summary-jump-to-group group)
4962 (gnus-group-get-new-news-this-group 1)))
4963 (gnus-group-read-group all t)
4964 (gnus-summary-goto-subject current-subject nil t)))
4966 (defun gnus-summary-rescan-group (&optional all)
4967 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4969 (gnus-summary-reselect-current-group all t))
4971 (defun gnus-summary-update-info (&optional non-destructive)
4973 (let ((group gnus-newsgroup-name))
4974 (when gnus-newsgroup-kill-headers
4975 (setq gnus-newsgroup-killed
4976 (gnus-compress-sequence
4978 (gnus-set-sorted-intersection
4979 (gnus-uncompress-range gnus-newsgroup-killed)
4980 (setq gnus-newsgroup-unselected
4981 (sort gnus-newsgroup-unselected '<)))
4982 (setq gnus-newsgroup-unreads
4983 (sort gnus-newsgroup-unreads '<)))
4985 (unless (listp (cdr gnus-newsgroup-killed))
4986 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4987 (let ((headers gnus-newsgroup-headers))
4988 (when (and (not gnus-save-score)
4989 (not non-destructive))
4990 (setq gnus-newsgroup-scored nil))
4991 ;; Set the new ranges of read articles.
4993 (set-buffer gnus-group-buffer)
4994 (gnus-undo-force-boundary))
4995 (gnus-update-read-articles
4996 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4997 ;; Set the current article marks.
4999 ;; Do the cross-ref thing.
5000 (when gnus-use-cross-reference
5001 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5002 ;; Do adaptive scoring, and possibly save score files.
5003 (when gnus-newsgroup-adaptive
5004 (gnus-score-adaptive))
5005 (when gnus-use-scoring
5007 ;; Do not switch windows but change the buffer to work.
5008 (set-buffer gnus-group-buffer)
5009 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5010 (gnus-group-update-group group))))))
5012 (defun gnus-summary-save-newsrc (&optional force)
5013 "Save the current number of read/marked articles in the dribble buffer.
5014 The dribble buffer will then be saved.
5015 If FORCE (the prefix), also save the .newsrc file(s)."
5017 (gnus-summary-update-info t)
5019 (gnus-save-newsrc-file)
5020 (gnus-dribble-save)))
5022 (defun gnus-summary-exit (&optional temporary)
5023 "Exit reading current newsgroup, and then return to group selection mode.
5024 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5026 (gnus-set-global-variables)
5027 (gnus-kill-save-kill-buffer)
5028 (let* ((group gnus-newsgroup-name)
5029 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5032 (buf (current-buffer)))
5033 (run-hooks 'gnus-summary-prepare-exit-hook)
5034 ;; If we have several article buffers, we kill them at exit.
5035 (unless gnus-single-article-buffer
5036 (gnus-kill-buffer gnus-original-article-buffer)
5037 (setq gnus-article-current nil))
5038 (when gnus-use-cache
5039 (gnus-cache-possibly-remove-articles)
5040 (gnus-cache-save-buffers))
5041 (gnus-async-prefetch-remove-group group)
5042 (when gnus-suppress-duplicates
5043 (gnus-dup-enter-articles))
5044 (when gnus-use-trees
5045 (gnus-tree-close group))
5046 ;; Make all changes in this group permanent.
5048 (run-hooks 'gnus-exit-group-hook)
5049 (gnus-summary-update-info))
5050 (gnus-close-group group)
5051 ;; Make sure where we were, and go to next newsgroup.
5052 (set-buffer gnus-group-buffer)
5054 (gnus-group-jump-to-group group))
5055 (run-hooks 'gnus-summary-exit-hook)
5057 (gnus-group-next-unread-group 1))
5058 (setq group-point (point))
5061 ;; If we have several article buffers, we kill them at exit.
5062 (unless gnus-single-article-buffer
5063 (gnus-kill-buffer gnus-article-buffer)
5064 (gnus-kill-buffer gnus-original-article-buffer)
5065 (setq gnus-article-current nil))
5067 (if (not gnus-kill-summary-on-exit)
5068 (gnus-deaden-summary)
5069 ;; We set all buffer-local variables to nil. It is unclear why
5070 ;; this is needed, but if we don't, buffer-local variables are
5071 ;; not garbage-collected, it seems. This would the lead to en
5072 ;; ever-growing Emacs.
5073 (gnus-summary-clear-local-variables)
5074 (when (get-buffer gnus-article-buffer)
5075 (bury-buffer gnus-article-buffer))
5076 ;; We clear the global counterparts of the buffer-local
5077 ;; variables as well, just to be on the safe side.
5078 (set-buffer gnus-group-buffer)
5079 (gnus-summary-clear-local-variables)
5080 ;; Return to group mode buffer.
5081 (when (eq mode 'gnus-summary-mode)
5082 (gnus-kill-buffer buf)))
5083 (setq gnus-current-select-method gnus-select-method)
5084 (pop-to-buffer gnus-group-buffer)
5085 ;; Clear the current group name.
5086 (if (not quit-config)
5088 (goto-char group-point)
5089 (gnus-configure-windows 'group 'force))
5090 (gnus-handle-ephemeral-exit quit-config))
5092 (setq gnus-newsgroup-name nil)))))
5094 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5095 (defun gnus-summary-exit-no-update (&optional no-questions)
5096 "Quit reading current newsgroup without updating read article info."
5098 (gnus-set-global-variables)
5099 (let* ((group gnus-newsgroup-name)
5100 (quit-config (gnus-group-quit-config group)))
5101 (when (or no-questions
5103 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5104 ;; If we have several article buffers, we kill them at exit.
5105 (unless gnus-single-article-buffer
5106 (gnus-kill-buffer gnus-article-buffer)
5107 (gnus-kill-buffer gnus-original-article-buffer)
5108 (setq gnus-article-current nil))
5109 (if (not gnus-kill-summary-on-exit)
5110 (gnus-deaden-summary)
5111 (gnus-close-group group)
5112 (gnus-summary-clear-local-variables)
5113 (set-buffer gnus-group-buffer)
5114 (gnus-summary-clear-local-variables)
5115 (when (get-buffer gnus-summary-buffer)
5116 (kill-buffer gnus-summary-buffer)))
5117 (unless gnus-single-article-buffer
5118 (setq gnus-article-current nil))
5119 (when gnus-use-trees
5120 (gnus-tree-close group))
5121 (gnus-async-prefetch-remove-group group)
5122 (when (get-buffer gnus-article-buffer)
5123 (bury-buffer gnus-article-buffer))
5124 ;; Return to the group buffer.
5125 (gnus-configure-windows 'group 'force)
5126 ;; Clear the current group name.
5127 (setq gnus-newsgroup-name nil)
5128 (when (equal (gnus-group-group-name) group)
5129 (gnus-group-next-unread-group 1))
5131 (gnus-handle-ephemeral-exit quit-config)))))
5133 (defun gnus-handle-ephemeral-exit (quit-config)
5134 "Handle movement when leaving an ephemeral group. The state
5135 which existed when entering the ephemeral is reset."
5136 (if (not (buffer-name (car quit-config)))
5137 (gnus-configure-windows 'group 'force)
5138 (set-buffer (car quit-config))
5139 (cond ((eq major-mode 'gnus-summary-mode)
5140 (gnus-set-global-variables))
5141 ((eq major-mode 'gnus-article-mode)
5143 ;; The `gnus-summary-buffer' variable may point
5144 ;; to the old summary buffer when using a single
5146 (unless (gnus-buffer-live-p gnus-summary-buffer)
5147 (set-buffer gnus-group-buffer))
5148 (set-buffer gnus-summary-buffer)
5149 (gnus-set-global-variables))))
5150 (if (or (eq (cdr quit-config) 'article)
5151 (eq (cdr quit-config) 'pick))
5153 ;; The current article may be from the ephemeral group
5154 ;; thus it is best that we reload this article
5155 (gnus-summary-show-article)
5156 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5157 (gnus-configure-windows 'pick 'force)
5158 (gnus-configure-windows (cdr quit-config) 'force)))
5159 (gnus-configure-windows (cdr quit-config) 'force))
5160 (when (eq major-mode 'gnus-summary-mode)
5161 (gnus-summary-next-subject 1 nil t)
5162 (gnus-summary-recenter)
5163 (gnus-summary-position-point))))
5167 (defvar gnus-dead-summary-mode-map nil)
5169 (unless gnus-dead-summary-mode-map
5170 (setq gnus-dead-summary-mode-map (make-keymap))
5171 (suppress-keymap gnus-dead-summary-mode-map)
5172 (substitute-key-definition
5173 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5174 (let ((keys '("\C-d" "\r" "\177" [delete])))
5176 (define-key gnus-dead-summary-mode-map
5177 (pop keys) 'gnus-summary-wake-up-the-dead))))
5179 (defvar gnus-dead-summary-mode nil
5180 "Minor mode for Gnus summary buffers.")
5182 (defun gnus-dead-summary-mode (&optional arg)
5183 "Minor mode for Gnus summary buffers."
5185 (when (eq major-mode 'gnus-summary-mode)
5186 (make-local-variable 'gnus-dead-summary-mode)
5187 (setq gnus-dead-summary-mode
5188 (if (null arg) (not gnus-dead-summary-mode)
5189 (> (prefix-numeric-value arg) 0)))
5190 (when gnus-dead-summary-mode
5191 (gnus-add-minor-mode
5192 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5194 (defun gnus-deaden-summary ()
5195 "Make the current summary buffer into a dead summary buffer."
5196 ;; Kill any previous dead summary buffer.
5197 (when (and gnus-dead-summary
5198 (buffer-name gnus-dead-summary))
5200 (set-buffer gnus-dead-summary)
5201 (when gnus-dead-summary-mode
5202 (kill-buffer (current-buffer)))))
5203 ;; Make this the current dead summary.
5204 (setq gnus-dead-summary (current-buffer))
5205 (gnus-dead-summary-mode 1)
5206 (let ((name (buffer-name)))
5207 (when (string-match "Summary" name)
5209 (concat (substring name 0 (match-beginning 0)) "Dead "
5210 (substring name (match-beginning 0)))
5213 (defun gnus-kill-or-deaden-summary (buffer)
5214 "Kill or deaden the summary BUFFER."
5215 (when (and (buffer-name buffer)
5216 (not gnus-single-article-buffer))
5219 (gnus-kill-buffer gnus-article-buffer)
5220 (gnus-kill-buffer gnus-original-article-buffer)))
5221 (cond (gnus-kill-summary-on-exit
5222 (when (and gnus-use-trees
5223 (and (get-buffer buffer)
5224 (buffer-name (get-buffer buffer))))
5226 (set-buffer (get-buffer buffer))
5227 (gnus-tree-close gnus-newsgroup-name)))
5228 (gnus-kill-buffer buffer))
5229 ((and (get-buffer buffer)
5230 (buffer-name (get-buffer buffer)))
5233 (gnus-deaden-summary)))))
5235 (defun gnus-summary-wake-up-the-dead (&rest args)
5236 "Wake up the dead summary buffer."
5238 (gnus-dead-summary-mode -1)
5239 (let ((name (buffer-name)))
5240 (when (string-match "Dead " name)
5242 (concat (substring name 0 (match-beginning 0))
5243 (substring name (match-end 0)))
5245 (gnus-message 3 "This dead summary is now alive again"))
5247 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5248 (defun gnus-summary-fetch-faq (&optional faq-dir)
5249 "Fetch the FAQ for the current group.
5250 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5254 (when current-prefix-arg
5256 "Faq dir: " (and (listp gnus-group-faq-directory)
5257 (mapcar (lambda (file) (list file))
5258 gnus-group-faq-directory))))))
5259 (let (gnus-faq-buffer)
5260 (when (setq gnus-faq-buffer
5261 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5262 (gnus-configure-windows 'summary-faq))))
5264 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5265 (defun gnus-summary-describe-group (&optional force)
5266 "Describe the current newsgroup."
5268 (gnus-group-describe-group force gnus-newsgroup-name))
5270 (defun gnus-summary-describe-briefly ()
5271 "Describe summary mode commands briefly."
5274 (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")))
5276 ;; Walking around group mode buffer from summary mode.
5278 (defun gnus-summary-next-group (&optional no-article target-group backward)
5279 "Exit current newsgroup and then select next unread newsgroup.
5280 If prefix argument NO-ARTICLE is non-nil, no article is selected
5281 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5282 previous group instead."
5284 (gnus-set-global-variables)
5285 ;; Stop pre-fetching.
5286 (gnus-async-halt-prefetch)
5287 (let ((current-group gnus-newsgroup-name)
5288 (current-buffer (current-buffer))
5290 ;; First we semi-exit this group to update Xrefs and all variables.
5291 ;; We can't do a real exit, because the window conf must remain
5292 ;; the same in case the user is prompted for info, and we don't
5293 ;; want the window conf to change before that...
5294 (gnus-summary-exit t)
5295 (while (not entered)
5296 ;; Then we find what group we are supposed to enter.
5297 (set-buffer gnus-group-buffer)
5298 (gnus-group-jump-to-group current-group)
5301 (if (eq gnus-keep-same-level 'best)
5302 (gnus-summary-best-group gnus-newsgroup-name)
5303 (gnus-summary-search-group backward gnus-keep-same-level))))
5304 (if (not target-group)
5305 ;; There are no further groups, so we return to the group
5308 (gnus-message 5 "Returning to the group buffer")
5310 (when (gnus-buffer-live-p current-buffer)
5311 (set-buffer current-buffer)
5312 (gnus-summary-exit))
5313 (run-hooks 'gnus-group-no-more-groups-hook))
5314 ;; We try to enter the target group.
5315 (gnus-group-jump-to-group target-group)
5316 (let ((unreads (gnus-group-group-unread)))
5317 (if (and (or (eq t unreads)
5318 (and unreads (not (zerop unreads))))
5319 (gnus-summary-read-group
5320 target-group nil no-article
5321 (and (buffer-name current-buffer) current-buffer)))
5323 (setq current-group target-group
5324 target-group nil)))))))
5326 (defun gnus-summary-prev-group (&optional no-article)
5327 "Exit current newsgroup and then select previous unread newsgroup.
5328 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5330 (gnus-summary-next-group no-article nil t))
5332 ;; Walking around summary lines.
5334 (defun gnus-summary-first-subject (&optional unread)
5335 "Go to the first unread subject.
5336 If UNREAD is non-nil, go to the first unread article.
5337 Returns the article selected or nil if there are no unread articles."
5342 ((null gnus-newsgroup-data)
5343 (gnus-message 3 "No articles in the group")
5345 ;; Pick the first article.
5347 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5348 (gnus-data-number (car gnus-newsgroup-data)))
5349 ;; No unread articles.
5350 ((null gnus-newsgroup-unreads)
5351 (gnus-message 3 "No more unread articles")
5353 ;; Find the first unread article.
5355 (let ((data gnus-newsgroup-data))
5357 (not (gnus-data-unread-p (car data))))
5358 (setq data (cdr data)))
5360 (goto-char (gnus-data-pos (car data)))
5361 (gnus-data-number (car data))))))
5362 (gnus-summary-position-point)))
5364 (defun gnus-summary-next-subject (n &optional unread dont-display)
5365 "Go to next N'th summary line.
5366 If N is negative, go to the previous N'th subject line.
5367 If UNREAD is non-nil, only unread articles are selected.
5368 The difference between N and the actual number of steps taken is
5371 (let ((backward (< n 0))
5375 (gnus-summary-find-prev unread)
5376 (gnus-summary-find-next unread)))
5379 (gnus-message 7 "No more%s articles"
5380 (if unread " unread" "")))
5381 (unless dont-display
5382 (gnus-summary-recenter)
5383 (gnus-summary-position-point))
5386 (defun gnus-summary-next-unread-subject (n)
5387 "Go to next N'th unread summary line."
5389 (gnus-summary-next-subject n t))
5391 (defun gnus-summary-prev-subject (n &optional unread)
5392 "Go to previous N'th summary line.
5393 If optional argument UNREAD is non-nil, only unread article is selected."
5395 (gnus-summary-next-subject (- n) unread))
5397 (defun gnus-summary-prev-unread-subject (n)
5398 "Go to previous N'th unread summary line."
5400 (gnus-summary-next-subject (- n) t))
5402 (defun gnus-summary-goto-subject (article &optional force silent)
5403 "Go the subject line of ARTICLE.
5404 If FORCE, also allow jumping to articles not currently shown."
5405 (interactive "nArticle number: ")
5407 (data (gnus-data-find article)))
5408 ;; We read in the article if we have to.
5411 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5412 (setq data (gnus-data-find article)))
5417 (gnus-message 3 "Can't find article %d" article))
5419 (goto-char (gnus-data-pos data))
5422 ;; Walking around summary lines with displaying articles.
5424 (defun gnus-summary-expand-window (&optional arg)
5425 "Make the summary buffer take up the entire Emacs frame.
5426 Given a prefix, will force an `article' buffer configuration."
5428 (gnus-set-global-variables)
5430 (gnus-configure-windows 'article 'force)
5431 (gnus-configure-windows 'summary 'force)))
5433 (defun gnus-summary-display-article (article &optional all-header)
5434 "Display ARTICLE in article buffer."
5435 (gnus-set-global-variables)
5439 (if gnus-summary-display-article-function
5440 (funcall gnus-summary-display-article-function article all-header)
5441 (gnus-article-prepare article all-header))
5442 (run-hooks 'gnus-select-article-hook)
5443 (when (and gnus-current-article
5444 (not (zerop gnus-current-article)))
5445 (gnus-summary-goto-subject gnus-current-article))
5446 (gnus-summary-recenter)
5447 (when (and gnus-use-trees gnus-show-threads)
5448 (gnus-possibly-generate-tree article)
5449 (gnus-highlight-selected-tree article))
5450 ;; Successfully display article.
5451 (gnus-article-set-window-start
5452 (cdr (assq article gnus-newsgroup-bookmarks))))))
5454 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5455 "Select the current article.
5456 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5457 non-nil, the article will be re-fetched even if it already present in
5458 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5460 ;; Make sure we are in the summary buffer to work around bbdb bug.
5461 (unless (eq major-mode 'gnus-summary-mode)
5462 (set-buffer gnus-summary-buffer))
5463 (let ((article (or article (gnus-summary-article-number)))
5464 (all-headers (not (not all-headers))) ;Must be T or NIL.
5465 gnus-summary-display-article-function
5468 (gnus-summary-article-pseudo-p article)
5469 (error "This is a pseudo-article"))
5472 (set-buffer gnus-summary-buffer)
5473 (if (or (and gnus-single-article-buffer
5474 (or (null gnus-current-article)
5475 (null gnus-article-current)
5476 (null (get-buffer gnus-article-buffer))
5477 (not (eq article (cdr gnus-article-current)))
5478 (not (equal (car gnus-article-current)
5479 gnus-newsgroup-name))))
5480 (and (not gnus-single-article-buffer)
5481 (or (null gnus-current-article)
5482 (not (eq gnus-current-article article))))
5484 ;; The requested article is different from the current article.
5486 (gnus-summary-display-article article all-headers)
5488 (when (or all-headers gnus-show-all-headers)
5489 (gnus-article-show-all-headers))
5492 (gnus-article-set-window-start
5493 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5495 (defun gnus-summary-set-current-mark (&optional current-mark)
5496 "Obsolete function."
5499 (defun gnus-summary-next-article (&optional unread subject backward push)
5500 "Select the next article.
5501 If UNREAD, only unread articles are selected.
5502 If SUBJECT, only articles with SUBJECT are selected.
5503 If BACKWARD, the previous article is selected instead of the next."
5505 (gnus-set-global-variables)
5507 ;; Is there such an article?
5508 ((and (gnus-summary-search-forward unread subject backward)
5509 (or (gnus-summary-display-article (gnus-summary-article-number))
5510 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5511 (gnus-summary-position-point))
5512 ;; If not, we try the first unread, if that is wanted.
5514 gnus-auto-select-same
5515 (gnus-summary-first-unread-article))
5516 (gnus-summary-position-point)
5517 (gnus-message 6 "Wrapped"))
5518 ;; Try to get next/previous article not displayed in this group.
5519 ((and gnus-auto-extend-newsgroup
5520 (not unread) (not subject))
5521 (gnus-summary-goto-article
5522 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5524 ;; Go to next/previous group.
5526 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5527 (gnus-summary-jump-to-group gnus-newsgroup-name))
5528 (let ((cmd last-command-char)
5531 (set-buffer gnus-group-buffer)
5534 (if (eq gnus-keep-same-level 'best)
5535 (gnus-summary-best-group gnus-newsgroup-name)
5536 (gnus-summary-search-group backward gnus-keep-same-level))))
5537 ;; For some reason, the group window gets selected. We change
5539 (select-window (get-buffer-window (current-buffer)))
5540 ;; Select next unread newsgroup automagically.
5542 ((or (not gnus-auto-select-next)
5544 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5545 ((or (eq gnus-auto-select-next 'quietly)
5546 (and (eq gnus-auto-select-next 'slightly-quietly)
5548 (and (eq gnus-auto-select-next 'almost-quietly)
5549 (gnus-summary-last-article-p)))
5551 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5553 (gnus-message 7 "No more%s articles (%s)..."
5554 (if unread " unread" "")
5555 (if group (concat "selecting " group)
5557 (gnus-summary-next-group nil group backward)))
5559 (when (gnus-key-press-event-p last-input-event)
5560 (gnus-summary-walk-group-buffer
5561 gnus-newsgroup-name cmd unread backward point))))))))
5563 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5564 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5565 (?\C-p (gnus-group-prev-unread-group 1))))
5566 (cursor-in-echo-area t)
5567 keve key group ended)
5569 (set-buffer gnus-group-buffer)
5572 (if (eq gnus-keep-same-level 'best)
5573 (gnus-summary-best-group gnus-newsgroup-name)
5574 (gnus-summary-search-group backward gnus-keep-same-level))))
5577 5 "No more%s articles%s" (if unread " unread" "")
5579 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5580 (format " (Type %s for %s [%s])"
5581 (single-key-description cmd) group
5582 (car (gnus-gethash group gnus-newsrc-hashtb)))
5583 (format " (Type %s to exit %s)"
5584 (single-key-description cmd)
5585 gnus-newsgroup-name)))
5586 ;; Confirm auto selection.
5587 (setq key (car (setq keve (gnus-read-event-char))))
5590 ((assq key keystrokes)
5591 (let ((obuf (current-buffer)))
5592 (switch-to-buffer gnus-group-buffer)
5594 (gnus-group-jump-to-group group))
5595 (eval (cadr (assq key keystrokes)))
5596 (setq group (gnus-group-group-name))
5597 (switch-to-buffer obuf))
5601 (gnus-ephemeral-group-p gnus-newsgroup-name))
5603 (gnus-summary-next-group nil group backward)))
5605 (push (cdr keve) unread-command-events))))))
5607 (defun gnus-summary-next-unread-article ()
5608 "Select unread article after current one."
5610 (gnus-summary-next-article
5611 (or (not (eq gnus-summary-goto-unread 'never))
5612 (gnus-summary-last-article-p (gnus-summary-article-number)))
5613 (and gnus-auto-select-same
5614 (gnus-summary-article-subject))))
5616 (defun gnus-summary-prev-article (&optional unread subject)
5617 "Select the article after the current one.
5618 If UNREAD is non-nil, only unread articles are selected."
5620 (gnus-summary-next-article unread subject t))
5622 (defun gnus-summary-prev-unread-article ()
5623 "Select unread article before current one."
5625 (gnus-summary-prev-article
5626 (or (not (eq gnus-summary-goto-unread 'never))
5627 (gnus-summary-first-article-p (gnus-summary-article-number)))
5628 (and gnus-auto-select-same
5629 (gnus-summary-article-subject))))
5631 (defun gnus-summary-next-page (&optional lines circular)
5632 "Show next page of the selected article.
5633 If at the end of the current article, select the next article.
5634 LINES says how many lines should be scrolled up.
5636 If CIRCULAR is non-nil, go to the start of the article instead of
5637 selecting the next article when reaching the end of the current
5640 (setq gnus-summary-buffer (current-buffer))
5641 (gnus-set-global-variables)
5642 (let ((article (gnus-summary-article-number))
5643 (article-window (get-buffer-window gnus-article-buffer t))
5645 (gnus-configure-windows 'article)
5646 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5647 (if (and (eq gnus-summary-goto-unread 'never)
5648 (not (gnus-summary-last-article-p article)))
5649 (gnus-summary-next-article)
5650 (gnus-summary-next-unread-article))
5651 (if (or (null gnus-current-article)
5652 (null gnus-article-current)
5653 (/= article (cdr gnus-article-current))
5654 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5655 ;; Selected subject is different from current article's.
5656 (gnus-summary-display-article article)
5657 (when article-window
5658 (gnus-eval-in-buffer-window gnus-article-buffer
5659 (setq endp (gnus-article-next-page lines)))
5662 (gnus-summary-beginning-of-article))
5664 (gnus-message 3 "End of message"))
5666 (if (and (eq gnus-summary-goto-unread 'never)
5667 (not (gnus-summary-last-article-p article)))
5668 (gnus-summary-next-article)
5669 (gnus-summary-next-unread-article))))))))
5670 (gnus-summary-recenter)
5671 (gnus-summary-position-point)))
5673 (defun gnus-summary-prev-page (&optional lines move)
5674 "Show previous page of selected article.
5675 Argument LINES specifies lines to be scrolled down.
5676 If MOVE, move to the previous unread article if point is at
5677 the beginning of the buffer."
5679 (gnus-set-global-variables)
5680 (let ((article (gnus-summary-article-number))
5681 (article-window (get-buffer-window gnus-article-buffer t))
5683 (gnus-configure-windows 'article)
5684 (if (or (null gnus-current-article)
5685 (null gnus-article-current)
5686 (/= article (cdr gnus-article-current))
5687 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5688 ;; Selected subject is different from current article's.
5689 (gnus-summary-display-article article)
5690 (gnus-summary-recenter)
5691 (when article-window
5692 (gnus-eval-in-buffer-window gnus-article-buffer
5693 (setq endp (gnus-article-prev-page lines)))
5694 (when (and move endp)
5696 (gnus-message 3 "Beginning of message"))
5698 (if (and (eq gnus-summary-goto-unread 'never)
5699 (not (gnus-summary-first-article-p article)))
5700 (gnus-summary-prev-article)
5701 (gnus-summary-prev-unread-article))))))))
5702 (gnus-summary-position-point))
5704 (defun gnus-summary-prev-page-or-article (&optional lines)
5705 "Show previous page of selected article.
5706 Argument LINES specifies lines to be scrolled down.
5707 If at the beginning of the article, go to the next article."
5709 (gnus-summary-prev-page lines t))
5711 (defun gnus-summary-scroll-up (lines)
5712 "Scroll up (or down) one line current article.
5713 Argument LINES specifies lines to be scrolled up (or down if negative)."
5715 (gnus-set-global-variables)
5716 (gnus-configure-windows 'article)
5717 (gnus-summary-show-thread)
5718 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5719 (gnus-eval-in-buffer-window gnus-article-buffer
5721 (when (gnus-article-next-page lines)
5722 (gnus-message 3 "End of message")))
5724 (gnus-article-prev-page (- lines))))))
5725 (gnus-summary-recenter)
5726 (gnus-summary-position-point))
5728 (defun gnus-summary-next-same-subject ()
5729 "Select next article which has the same subject as current one."
5731 (gnus-set-global-variables)
5732 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5734 (defun gnus-summary-prev-same-subject ()
5735 "Select previous article which has the same subject as current one."
5737 (gnus-set-global-variables)
5738 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5740 (defun gnus-summary-next-unread-same-subject ()
5741 "Select next unread article which has the same subject as current one."
5743 (gnus-set-global-variables)
5744 (gnus-summary-next-article t (gnus-summary-article-subject)))
5746 (defun gnus-summary-prev-unread-same-subject ()
5747 "Select previous unread article which has the same subject as current one."
5749 (gnus-set-global-variables)
5750 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5752 (defun gnus-summary-first-unread-article ()
5753 "Select the first unread article.
5754 Return nil if there are no unread articles."
5756 (gnus-set-global-variables)
5758 (when (gnus-summary-first-subject t)
5759 (gnus-summary-show-thread)
5760 (gnus-summary-first-subject t)
5761 (gnus-summary-display-article (gnus-summary-article-number)))
5762 (gnus-summary-position-point)))
5764 (defun gnus-summary-first-article ()
5765 "Select the first article.
5766 Return nil if there are no articles."
5768 (gnus-set-global-variables)
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 (gnus-set-global-variables)
5780 (let ((best -1000000)
5781 (data gnus-newsgroup-data)
5784 (and (gnus-data-unread-p (car data))
5786 (gnus-summary-article-score (gnus-data-number (car data))))
5789 article (gnus-data-number (car data))))
5790 (setq data (cdr data)))
5793 (gnus-summary-goto-article article)
5794 (error "No unread articles"))
5795 (gnus-summary-position-point))))
5797 (defun gnus-summary-last-subject ()
5798 "Go to the last displayed subject line in the group."
5799 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5801 (gnus-summary-goto-subject article))))
5803 (defun gnus-summary-goto-article (article &optional all-headers force)
5804 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5805 If ALL-HEADERS is non-nil, no header lines are hidden."
5809 "Article number or Message-ID: "
5810 (mapcar (lambda (number) (list (int-to-string number)))
5811 gnus-newsgroup-limit))
5815 (if (and (stringp article)
5816 (string-match "@" article))
5817 (gnus-summary-refer-article article)
5818 (when (stringp article)
5819 (setq article (string-to-number article)))
5820 (if (gnus-summary-goto-subject article force)
5821 (gnus-summary-display-article article all-headers)
5822 (gnus-message 4 "Couldn't go to article %s" article) nil))
5823 (gnus-summary-position-point)))
5825 (defun gnus-summary-goto-last-article ()
5826 "Go to the previously read article."
5829 (when gnus-last-article
5830 (gnus-summary-goto-article gnus-last-article))
5831 (gnus-summary-position-point)))
5833 (defun gnus-summary-pop-article (number)
5834 "Pop one article off the history and go to the previous.
5835 NUMBER articles will be popped off."
5838 (setq gnus-newsgroup-history
5839 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5841 (gnus-summary-goto-article (car to) nil t)
5842 (error "Article history empty")))
5843 (gnus-summary-position-point))
5845 ;; Summary commands and functions for limiting the summary buffer.
5847 (defun gnus-summary-limit-to-articles (n)
5848 "Limit the summary buffer to the next N articles.
5849 If not given a prefix, use the process marked articles instead."
5851 (gnus-set-global-variables)
5853 (let ((articles (gnus-summary-work-articles n)))
5854 (setq gnus-newsgroup-processable nil)
5855 (gnus-summary-limit articles))
5856 (gnus-summary-position-point)))
5858 (defun gnus-summary-pop-limit (&optional total)
5859 "Restore the previous limit.
5860 If given a prefix, remove all limits."
5862 (gnus-set-global-variables)
5864 (setq gnus-newsgroup-limits
5865 (list (mapcar (lambda (h) (mail-header-number h))
5866 gnus-newsgroup-headers))))
5867 (unless gnus-newsgroup-limits
5868 (error "No limit to pop"))
5870 (gnus-summary-limit nil 'pop)
5871 (gnus-summary-position-point)))
5873 (defun gnus-summary-limit-to-subject (subject &optional header)
5874 "Limit the summary buffer to articles that have subjects that match a regexp."
5875 (interactive "sLimit to subject (regexp): ")
5877 (setq header "subject"))
5878 (when (not (equal "" subject))
5880 (let ((articles (gnus-summary-find-matching
5881 (or header "subject") subject 'all)))
5883 (error "Found no matches for \"%s\"" subject))
5884 (gnus-summary-limit articles))
5885 (gnus-summary-position-point))))
5887 (defun gnus-summary-limit-to-author (from)
5888 "Limit the summary buffer to articles that have authors that match a regexp."
5889 (interactive "sLimit to author (regexp): ")
5890 (gnus-summary-limit-to-subject from "from"))
5892 (defun gnus-summary-limit-to-age (age &optional younger-p)
5893 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5894 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5895 articles that are younger than AGE days."
5896 (interactive "nTime in days: \nP")
5898 (let ((data gnus-newsgroup-data)
5899 (cutoff (nnmail-days-to-time age))
5900 articles d date is-younger)
5901 (while (setq d (pop data))
5902 (when (and (vectorp (gnus-data-header d))
5903 (setq date (mail-header-date (gnus-data-header d))))
5904 (setq is-younger (nnmail-time-less
5905 (nnmail-time-since (nnmail-date-to-time date))
5907 (when (if younger-p is-younger (not is-younger))
5908 (push (gnus-data-number d) articles))))
5909 (gnus-summary-limit (nreverse articles)))
5910 (gnus-summary-position-point)))
5912 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5914 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5916 (defun gnus-summary-limit-to-unread (&optional all)
5917 "Limit the summary buffer to articles that are not marked as read.
5918 If ALL is non-nil, limit strictly to unread articles."
5921 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5922 (gnus-summary-limit-to-marks
5923 ;; Concat all the marks that say that an article is read and have
5925 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5926 gnus-killed-mark gnus-kill-file-mark
5927 gnus-low-score-mark gnus-expirable-mark
5928 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5929 gnus-duplicate-mark gnus-souped-mark)
5932 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5933 (make-obsolete 'gnus-summary-delete-marked-with
5934 'gnus-summary-limit-exlude-marks)
5936 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5937 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5938 If REVERSE, limit the summary buffer to articles that are marked
5939 with MARKS. MARKS can either be a string of marks or a list of marks.
5940 Returns how many articles were removed."
5941 (interactive "sMarks: ")
5942 (gnus-summary-limit-to-marks marks t))
5944 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5945 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5946 If REVERSE (the prefix), limit the summary buffer to articles that are
5947 not marked with MARKS. MARKS can either be a string of marks or a
5949 Returns how many articles were removed."
5950 (interactive "sMarks: \nP")
5951 (gnus-set-global-variables)
5953 (let ((data gnus-newsgroup-data)
5954 (marks (if (listp marks) marks
5955 (append marks nil))) ; Transform to list.
5958 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5959 (memq (gnus-data-mark (car data)) marks))
5960 (push (gnus-data-number (car data)) articles))
5961 (setq data (cdr data)))
5962 (gnus-summary-limit articles))
5963 (gnus-summary-position-point)))
5965 (defun gnus-summary-limit-to-score (&optional score)
5966 "Limit to articles with score at or above SCORE."
5968 (gnus-set-global-variables)
5969 (setq score (if score
5970 (prefix-numeric-value score)
5971 (or gnus-summary-default-score 0)))
5972 (let ((data gnus-newsgroup-data)
5975 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5977 (push (gnus-data-number (car data)) articles))
5978 (setq data (cdr data)))
5980 (gnus-summary-limit articles)
5981 (gnus-summary-position-point))))
5983 (defun gnus-summary-limit-include-thread (id)
5984 "Display all the hidden articles that in the current thread."
5985 (interactive (mail-header-id (gnus-summary-article-header)))
5986 (gnus-set-global-variables)
5987 (let ((articles (gnus-articles-in-thread
5988 (gnus-id-to-thread (gnus-root-id id)))))
5990 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
5991 (gnus-summary-position-point))))
5993 (defun gnus-summary-limit-include-dormant ()
5994 "Display all the hidden articles that are marked as dormant."
5996 (gnus-set-global-variables)
5997 (unless gnus-newsgroup-dormant
5998 (error "There are no dormant articles in this group"))
6000 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6001 (gnus-summary-position-point)))
6003 (defun gnus-summary-limit-exclude-dormant ()
6004 "Hide all dormant articles."
6006 (gnus-set-global-variables)
6008 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6009 (gnus-summary-position-point)))
6011 (defun gnus-summary-limit-exclude-childless-dormant ()
6012 "Hide all dormant articles that have no children."
6014 (gnus-set-global-variables)
6015 (let ((data (gnus-data-list t))
6016 articles d children)
6017 ;; Find all articles that are either not dormant or have
6019 (while (setq d (pop data))
6020 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6022 (gnus-article-children (gnus-data-number d)))
6025 (when (memq (car children) articles)
6030 (push (gnus-data-number d) articles)))
6033 (gnus-summary-limit articles)
6034 (gnus-summary-position-point))))
6036 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6037 "Mark all unread excluded articles as read.
6038 If ALL, mark even excluded ticked and dormants as read."
6040 (let ((articles (gnus-sorted-complement
6042 (mapcar (lambda (h) (mail-header-number h))
6043 gnus-newsgroup-headers)
6045 (sort gnus-newsgroup-limit '<)))
6047 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6049 (setq gnus-newsgroup-dormant nil
6050 gnus-newsgroup-marked nil
6051 gnus-newsgroup-reads
6053 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6054 gnus-newsgroup-reads))
6055 (while (setq article (pop articles))
6056 (unless (or (memq article gnus-newsgroup-dormant)
6057 (memq article gnus-newsgroup-marked))
6058 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6060 (defun gnus-summary-limit (articles &optional pop)
6062 ;; We pop the previous limit off the stack and use that.
6063 (setq articles (car gnus-newsgroup-limits)
6064 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6065 ;; We use the new limit, so we push the old limit on the stack.
6066 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6068 (setq gnus-newsgroup-limit articles)
6069 (let ((total (length gnus-newsgroup-data))
6070 (data (gnus-data-find-list (gnus-summary-article-number)))
6071 (gnus-summary-mark-below nil) ; Inhibit this.
6073 ;; This will do all the work of generating the new summary buffer
6074 ;; according to the new limit.
6075 (gnus-summary-prepare)
6076 ;; Hide any threads, possibly.
6077 (and gnus-show-threads
6078 gnus-thread-hide-subtree
6079 (gnus-summary-hide-all-threads))
6080 ;; Try to return to the article you were at, or one in the
6083 ;; We try to find some article after the current one.
6085 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6088 (setq data (cdr data))))
6090 ;; If there is no data, that means that we were after the last
6091 ;; article. The same goes when we can't find any articles
6092 ;; after the current one.
6093 (goto-char (point-max))
6094 (gnus-summary-find-prev))
6095 ;; We return how many articles were removed from the summary
6096 ;; buffer as a result of the new limit.
6097 (- total (length gnus-newsgroup-data))))
6099 (defsubst gnus-invisible-cut-children (threads)
6102 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6107 (defsubst gnus-cut-thread (thread)
6108 "Go forwards in the thread until we find an article that we want to display."
6109 (when (or (eq gnus-fetch-old-headers 'some)
6110 (eq gnus-fetch-old-headers 'invisible)
6111 (eq gnus-build-sparse-threads 'some)
6112 (eq gnus-build-sparse-threads 'more))
6113 ;; Deal with old-fetched headers and sparse threads.
6117 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6118 (gnus-summary-article-ancient-p
6119 (mail-header-number (car thread))))
6120 (if (or (<= (length (cdr thread)) 1)
6121 (eq gnus-fetch-old-headers 'invisible))
6122 (setq gnus-newsgroup-limit
6123 (delq (mail-header-number (car thread))
6124 gnus-newsgroup-limit)
6125 thread (cadr thread))
6126 (when (gnus-invisible-cut-children (cdr thread))
6127 (let ((th (cdr thread)))
6129 (if (memq (mail-header-number (caar th))
6130 gnus-newsgroup-limit)
6131 (setq thread (car th)
6133 (setq th (cdr th))))))))))
6136 (defun gnus-cut-threads (threads)
6137 "Cut off all uninteresting articles from the beginning of threads."
6138 (when (or (eq gnus-fetch-old-headers 'some)
6139 (eq gnus-fetch-old-headers 'invisible)
6140 (eq gnus-build-sparse-threads 'some)
6141 (eq gnus-build-sparse-threads 'more))
6144 (setcar th (gnus-cut-thread (car th)))
6145 (setq th (cdr th)))))
6146 ;; Remove nixed out threads.
6149 (defun gnus-summary-initial-limit (&optional show-if-empty)
6150 "Figure out what the initial limit is supposed to be on group entry.
6151 This entails weeding out unwanted dormants, low-scored articles,
6152 fetch-old-headers verbiage, and so on."
6153 ;; Most groups have nothing to remove.
6154 (if (or gnus-inhibit-limiting
6155 (and (null gnus-newsgroup-dormant)
6156 (not (eq gnus-fetch-old-headers 'some))
6157 (not (eq gnus-fetch-old-headers 'invisible))
6158 (null gnus-summary-expunge-below)
6159 (not (eq gnus-build-sparse-threads 'some))
6160 (not (eq gnus-build-sparse-threads 'more))
6161 (null gnus-thread-expunge-below)
6162 (not gnus-use-nocem)))
6164 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6165 (setq gnus-newsgroup-limit nil)
6168 (unless (car (symbol-value node))
6169 ;; These threads have no parents -- they are roots.
6170 (let ((nodes (cdr (symbol-value node)))
6173 (if (and gnus-thread-expunge-below
6174 (< (gnus-thread-total-score (car nodes))
6175 gnus-thread-expunge-below))
6176 (gnus-expunge-thread (pop nodes))
6177 (setq thread (pop nodes))
6178 (gnus-summary-limit-children thread))))))
6179 gnus-newsgroup-dependencies)
6180 ;; If this limitation resulted in an empty group, we might
6181 ;; pop the previous limit and use it instead.
6182 (when (and (not gnus-newsgroup-limit)
6184 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6185 gnus-newsgroup-limit))
6187 (defun gnus-summary-limit-children (thread)
6188 "Return 1 if this subthread is visible and 0 if it is not."
6189 ;; First we get the number of visible children to this thread. This
6190 ;; is done by recursing down the thread using this function, so this
6191 ;; will really go down to a leaf article first, before slowly
6192 ;; working its way up towards the root.
6196 (apply '+ (mapcar 'gnus-summary-limit-children
6199 (number (mail-header-number (car thread)))
6202 (not (memq number gnus-newsgroup-marked))
6204 ;; If this article is dormant and has absolutely no visible
6205 ;; children, then this article isn't visible.
6206 (and (memq number gnus-newsgroup-dormant)
6208 ;; If this is "fetch-old-headered" and there is no
6209 ;; visible children, then we don't want this article.
6210 (and (eq gnus-fetch-old-headers 'some)
6211 (gnus-summary-article-ancient-p number)
6213 ;; If this is "fetch-old-headered" and `invisible', then
6214 ;; we don't want this article.
6215 (and (eq gnus-fetch-old-headers 'invisible)
6216 (gnus-summary-article-ancient-p number))
6217 ;; If this is a sparsely inserted article with no children,
6218 ;; we don't want it.
6219 (and (eq gnus-build-sparse-threads 'some)
6220 (gnus-summary-article-sparse-p number)
6222 ;; If we use expunging, and this article is really
6223 ;; low-scored, then we don't want this article.
6224 (when (and gnus-summary-expunge-below
6226 (or (cdr (assq number gnus-newsgroup-scored))
6227 gnus-summary-default-score))
6228 gnus-summary-expunge-below))
6229 ;; We increase the expunge-tally here, but that has
6230 ;; nothing to do with the limits, really.
6231 (incf gnus-newsgroup-expunged-tally)
6232 ;; We also mark as read here, if that's wanted.
6233 (when (and gnus-summary-mark-below
6234 (< score gnus-summary-mark-below))
6235 (setq gnus-newsgroup-unreads
6236 (delq number gnus-newsgroup-unreads))
6237 (if gnus-newsgroup-auto-expire
6238 (push number gnus-newsgroup-expirable)
6239 (push (cons number gnus-low-score-mark)
6240 gnus-newsgroup-reads)))
6242 ;; Check NoCeM things.
6243 (if (and gnus-use-nocem
6244 (gnus-nocem-unwanted-article-p
6245 (mail-header-id (car thread))))
6247 (setq gnus-newsgroup-unreads
6248 (delq number gnus-newsgroup-unreads))
6250 ;; Nope, invisible article.
6252 ;; Ok, this article is to be visible, so we add it to the limit
6254 (push number gnus-newsgroup-limit)
6257 (defun gnus-expunge-thread (thread)
6258 "Mark all articles in THREAD as read."
6259 (let* ((number (mail-header-number (car thread))))
6260 (incf gnus-newsgroup-expunged-tally)
6261 ;; We also mark as read here, if that's wanted.
6262 (setq gnus-newsgroup-unreads
6263 (delq number gnus-newsgroup-unreads))
6264 (if gnus-newsgroup-auto-expire
6265 (push number gnus-newsgroup-expirable)
6266 (push (cons number gnus-low-score-mark)
6267 gnus-newsgroup-reads)))
6268 ;; Go recursively through all subthreads.
6269 (mapcar 'gnus-expunge-thread (cdr thread)))
6271 ;; Summary article oriented commands
6273 (defun gnus-summary-refer-parent-article (n)
6274 "Refer parent article N times.
6275 If N is negative, go to ancestor -N instead.
6276 The difference between N and the number of articles fetched is returned."
6278 (gnus-set-global-variables)
6281 (when (not (natnump n))
6286 (setq header (gnus-summary-article-header))
6287 (if (and (eq (mail-header-number header)
6288 (cdr gnus-article-current))
6289 (equal gnus-newsgroup-name
6290 (car gnus-article-current)))
6291 ;; If we try to find the parent of the currently
6292 ;; displayed article, then we take a look at the actual
6293 ;; References header, since this is slightly more
6294 ;; reliable than the References field we got from the
6297 (set-buffer gnus-original-article-buffer)
6298 (nnheader-narrow-to-headers)
6299 (unless (setq ref (message-fetch-field "references"))
6300 (setq ref (message-fetch-field "in-reply-to")))
6303 ;; It's not the current article, so we take a bet on
6304 ;; the value we got from the server.
6305 (mail-header-references header)))
6307 (not (equal ref "")))
6308 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6309 (gnus-message 1 "Couldn't find parent"))
6310 (gnus-message 1 "No references in article %d"
6311 (gnus-summary-article-number))
6314 (gnus-summary-position-point)
6317 (defun gnus-summary-refer-references ()
6318 "Fetch all articles mentioned in the References header.
6319 Return the number of articles fetched."
6321 (gnus-set-global-variables)
6322 (let ((ref (mail-header-references (gnus-summary-article-header)))
6323 (current (gnus-summary-article-number))
6327 (error "No References in the current article")
6328 ;; For each Message-ID in the References header...
6329 (while (string-match "<[^>]*>" ref)
6331 ;; ... fetch that article.
6332 (gnus-summary-refer-article
6333 (prog1 (match-string 0 ref)
6334 (setq ref (substring ref (match-end 0))))))
6335 (gnus-summary-goto-subject current)
6336 (gnus-summary-position-point)
6339 (defun gnus-summary-refer-thread (&optional limit)
6340 "Fetch all articles in the current thread.
6341 If LIMIT (the numerical prefix), fetch that many old headers instead
6342 of what's specified by the `gnus-refer-thread-limit' variable."
6344 (gnus-set-global-variables)
6345 (let ((id (mail-header-id (gnus-summary-article-header)))
6346 (limit (if limit (prefix-numeric-value limit)
6347 gnus-refer-thread-limit))
6349 ;; We want to fetch LIMIT *old* headers, but we also have to
6350 ;; re-fetch all the headers in the current buffer, because many of
6351 ;; them may be undisplayed. So we adjust LIMIT.
6352 (when (numberp limit)
6353 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6354 (unless (eq gnus-fetch-old-headers 'invisible)
6355 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6356 ;; Retrieve the headers and read them in.
6357 (if (eq (gnus-retrieve-headers
6358 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6360 (gnus-build-all-threads)
6361 (error "Can't fetch thread from backends that don't support NOV"))
6362 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6363 (gnus-summary-limit-include-thread id)))
6365 (defun gnus-summary-refer-article (message-id &optional arg)
6366 "Fetch an article specified by MESSAGE-ID.
6367 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6368 or `gnus-select-method', no matter what backend the article comes from."
6369 (interactive "sMessage-ID: \nP")
6370 (when (and (stringp message-id)
6371 (not (zerop (length message-id))))
6372 ;; Construct the correct Message-ID if necessary.
6373 ;; Suggested by tale@pawl.rpi.edu.
6374 (unless (string-match "^<" message-id)
6375 (setq message-id (concat "<" message-id)))
6376 (unless (string-match ">$" message-id)
6377 (setq message-id (concat message-id ">")))
6378 (let* ((header (gnus-id-to-header message-id))
6380 (gnus-summary-article-sparse-p
6381 (mail-header-number header))
6382 (memq (mail-header-number header)
6383 gnus-newsgroup-limit))))
6385 (or (not (gnus-summary-article-sparse-p
6386 (mail-header-number header)))
6389 ;; The article is present in the buffer, so we just go to it.
6390 (gnus-summary-goto-article
6391 (mail-header-number header) nil t)
6393 (gnus-summary-update-article (mail-header-number header))))
6394 ;; We fetch the article
6395 (let ((gnus-override-method
6396 (cond ((gnus-news-group-p gnus-newsgroup-name)
6397 gnus-refer-article-method)
6399 (or gnus-refer-article-method gnus-select-method))
6402 ;; Start the special refer-article method, if necessary.
6403 (when (and gnus-refer-article-method
6404 (gnus-news-group-p gnus-newsgroup-name))
6405 (gnus-check-server gnus-refer-article-method))
6406 ;; Fetch the header, and display the article.
6407 (if (setq number (gnus-summary-insert-subject message-id))
6408 (gnus-summary-select-article nil nil nil number)
6409 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6411 (defun gnus-summary-enter-digest-group (&optional force)
6412 "Enter an nndoc group based on the current article.
6413 If FORCE, force a digest interpretation. If not, try
6414 to guess what the document format is."
6416 (gnus-set-global-variables)
6417 (let ((conf gnus-current-window-configuration))
6419 (gnus-summary-select-article))
6420 (setq gnus-current-window-configuration conf)
6421 (let* ((name (format "%s-%d"
6422 (gnus-group-prefixed-name
6423 gnus-newsgroup-name (list 'nndoc ""))
6425 (set-buffer gnus-summary-buffer)
6426 gnus-current-article)))
6427 (ogroup gnus-newsgroup-name)
6428 (params (append (gnus-info-params (gnus-get-info ogroup))
6429 (list (cons 'to-group ogroup))
6430 (list (cons 'save-article-group ogroup))))
6431 (case-fold-search t)
6432 (buf (current-buffer))
6435 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6436 (insert-buffer-substring gnus-original-article-buffer)
6437 ;; Remove lines that may lead nndoc to misinterpret the
6440 (goto-char (point-min))
6441 (or (search-forward "\n\n" nil t) (point)))
6442 (goto-char (point-min))
6443 (delete-matching-lines "^\\(Path\\):\\|^From ")
6446 (if (gnus-group-read-ephemeral-group
6447 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6449 ,(if force 'digest 'guess))) t)
6450 ;; Make all postings to this group go to the parent group.
6451 (nconc (gnus-info-params (gnus-get-info name))
6453 ;; Couldn't select this doc group.
6454 (switch-to-buffer buf)
6455 (gnus-set-global-variables)
6456 (gnus-configure-windows 'summary)
6457 (gnus-message 3 "Article couldn't be entered?"))
6458 (kill-buffer dig)))))
6460 (defun gnus-summary-read-document (n)
6461 "Open a new group based on the current article(s).
6462 This will allow you to read digests and other similar
6463 documents as newsgroups.
6464 Obeys the standard process/prefix convention."
6466 (let* ((articles (gnus-summary-work-articles n))
6467 (ogroup gnus-newsgroup-name)
6468 (params (append (gnus-info-params (gnus-get-info ogroup))
6469 (list (cons 'to-group ogroup))))
6470 article group egroup groups vgroup)
6471 (while (setq article (pop articles))
6472 (setq group (format "%s-%d" gnus-newsgroup-name article))
6473 (gnus-summary-remove-process-mark article)
6474 (when (gnus-summary-display-article article)
6476 (nnheader-temp-write nil
6477 (insert-buffer-substring gnus-original-article-buffer)
6478 ;; Remove some headers that may lead nndoc to make
6480 (message-narrow-to-head)
6481 (goto-char (point-min))
6482 (delete-matching-lines "^\\(Path\\):\\|^From ")
6485 (gnus-group-read-ephemeral-group
6486 group `(nndoc ,group (nndoc-address ,(current-buffer))
6487 (nndoc-article-type guess))
6490 ;; Make all postings to this group go to the parent group.
6491 (nconc (gnus-info-params (gnus-get-info egroup))
6493 (push egroup groups))
6494 ;; Couldn't select this doc group.
6495 (gnus-error 3 "Article couldn't be entered"))))))
6496 ;; Now we have selected all the documents.
6499 (error "None of the articles could be interpreted as documents"))
6500 ((gnus-group-read-ephemeral-group
6501 (setq vgroup (format
6502 "nnvirtual:%s-%s" gnus-newsgroup-name
6503 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6504 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6506 (cons (current-buffer) 'summary)))
6508 (error "Couldn't select virtual nndoc group")))))
6510 (defun gnus-summary-isearch-article (&optional regexp-p)
6511 "Do incremental search forward on the current article.
6512 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6514 (gnus-set-global-variables)
6515 (gnus-summary-select-article)
6516 (gnus-configure-windows 'article)
6517 (gnus-eval-in-buffer-window gnus-article-buffer
6518 ;;(goto-char (point-min))
6519 (isearch-forward regexp-p)))
6521 (defun gnus-summary-search-article-forward (regexp &optional backward)
6522 "Search for an article containing REGEXP forward.
6523 If BACKWARD, search backward instead."
6526 (format "Search article %s (regexp%s): "
6527 (if current-prefix-arg "backward" "forward")
6528 (if gnus-last-search-regexp
6529 (concat ", default " gnus-last-search-regexp)
6531 current-prefix-arg))
6532 (gnus-set-global-variables)
6533 (if (string-equal regexp "")
6534 (setq regexp (or gnus-last-search-regexp ""))
6535 (setq gnus-last-search-regexp regexp))
6536 (if (gnus-summary-search-article regexp backward)
6537 (gnus-summary-show-thread)
6538 (error "Search failed: \"%s\"" regexp)))
6540 (defun gnus-summary-search-article-backward (regexp)
6541 "Search for an article containing REGEXP backward."
6544 (format "Search article backward (regexp%s): "
6545 (if gnus-last-search-regexp
6546 (concat ", default " gnus-last-search-regexp)
6548 (gnus-summary-search-article-forward regexp 'backward))
6550 (defun gnus-summary-search-article (regexp &optional backward)
6551 "Search for an article containing REGEXP.
6552 Optional argument BACKWARD means do search for backward.
6553 `gnus-select-article-hook' is not called during the search."
6554 ;; We have to require this here to make sure that the following
6555 ;; dynamic binding isn't shadowed by autoloading.
6556 (require 'gnus-async)
6557 (let ((gnus-select-article-hook nil) ;Disable hook.
6558 (gnus-article-display-hook nil)
6559 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6560 (gnus-use-article-prefetch nil)
6561 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6562 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6563 (sum (current-buffer))
6566 (gnus-save-hidden-threads
6567 (gnus-summary-select-article)
6568 (set-buffer gnus-article-buffer)
6572 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6574 (re-search-backward regexp nil t)
6575 (re-search-forward regexp nil t))
6576 ;; We found the regexp.
6581 (get-buffer-window (current-buffer))
6585 (setq point (point)))
6586 ;; We didn't find it, so we go to the next article.
6589 (while (eq found 'not)
6590 (if (not (if backward (gnus-summary-find-prev)
6591 (gnus-summary-find-next)))
6592 ;; No more articles.
6594 ;; Select the next article and adjust point.
6595 (unless (gnus-summary-article-sparse-p
6596 (gnus-summary-article-number))
6598 (gnus-summary-select-article)
6599 (set-buffer gnus-article-buffer)
6601 (goto-char (if backward (point-max) (point-min))))))))
6602 (gnus-message 7 ""))
6603 ;; Return whether we found the regexp.
6604 (when (eq found 'found)
6606 (gnus-summary-show-thread)
6607 (gnus-summary-goto-subject gnus-current-article)
6608 (gnus-summary-position-point)
6611 (defun gnus-summary-find-matching (header regexp &optional backward unread
6613 "Return a list of all articles that match REGEXP on HEADER.
6614 The search stars on the current article and goes forwards unless
6615 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6616 If UNREAD is non-nil, only unread articles will
6617 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6618 in the comparisons."
6619 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6620 (gnus-data-find-list
6621 (gnus-summary-article-number) (gnus-data-list backward))))
6622 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6623 (case-fold-search (not not-case-fold))
6625 (unless (fboundp (intern (concat "mail-header-" header)))
6626 (error "%s is not a valid header" header))
6629 (and (or (not unread) ; We want all articles...
6630 (gnus-data-unread-p d)) ; Or just unreads.
6631 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6632 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6633 (push (gnus-data-number d) articles)) ; Success!
6634 (setq data (cdr data)))
6635 (nreverse articles)))
6637 (defun gnus-summary-execute-command (header regexp command &optional backward)
6638 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6639 If HEADER is an empty string (or nil), the match is done on the entire
6640 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6642 (list (let ((completion-ignore-case t))
6645 (mapcar (lambda (string) (list string))
6646 '("Number" "Subject" "From" "Lines" "Date"
6647 "Message-ID" "Xref" "References" "Body"))
6648 nil 'require-match))
6649 (read-string "Regexp: ")
6650 (read-key-sequence "Command: ")
6651 current-prefix-arg))
6652 (when (equal header "Body")
6654 (gnus-set-global-variables)
6655 ;; Hidden thread subtrees must be searched as well.
6656 (gnus-summary-show-all-threads)
6657 ;; We don't want to change current point nor window configuration.
6659 (save-window-excursion
6660 (gnus-message 6 "Executing %s..." (key-description command))
6661 ;; We'd like to execute COMMAND interactively so as to give arguments.
6662 (gnus-execute header regexp
6663 `(call-interactively ',(key-binding command))
6665 (gnus-message 6 "Executing %s...done" (key-description command)))))
6667 (defun gnus-summary-beginning-of-article ()
6668 "Scroll the article back to the beginning."
6670 (gnus-set-global-variables)
6671 (gnus-summary-select-article)
6672 (gnus-configure-windows 'article)
6673 (gnus-eval-in-buffer-window gnus-article-buffer
6675 (goto-char (point-min))
6676 (when gnus-page-broken
6677 (gnus-narrow-to-page))))
6679 (defun gnus-summary-end-of-article ()
6680 "Scroll to the end of the article."
6682 (gnus-set-global-variables)
6683 (gnus-summary-select-article)
6684 (gnus-configure-windows 'article)
6685 (gnus-eval-in-buffer-window gnus-article-buffer
6687 (goto-char (point-max))
6689 (when gnus-page-broken
6690 (gnus-narrow-to-page))))
6692 (defun gnus-summary-print-article (&optional filename)
6693 "Generate and print a PostScript image of the article buffer.
6695 If the optional argument FILENAME is nil, send the image to the printer.
6696 If FILENAME is a string, save the PostScript image in a file with that
6697 name. If FILENAME is a number, prompt the user for the name of the file
6699 (interactive (list (ps-print-preprint current-prefix-arg)))
6700 (gnus-summary-select-article)
6701 (gnus-eval-in-buffer-window gnus-article-buffer
6702 (let ((buffer (generate-new-buffer " *print*")))
6705 (copy-to-buffer buffer (point-min) (point-max))
6707 (gnus-article-delete-invisible-text)
6708 (run-hooks 'gnus-ps-print-hook)
6709 (ps-print-buffer-with-faces filename))
6710 (kill-buffer buffer)))))
6712 (defun gnus-summary-show-article (&optional arg)
6713 "Force re-fetching of the current article.
6714 If ARG (the prefix) is non-nil, show the raw article without any
6715 article massaging functions being run."
6717 (gnus-set-global-variables)
6719 ;; Select the article the normal way.
6720 (gnus-summary-select-article nil 'force)
6721 ;; Bind the article treatment functions to nil.
6722 (let ((gnus-have-all-headers t)
6723 gnus-article-display-hook
6724 gnus-article-prepare-hook
6728 (gnus-summary-select-article nil 'force)))
6729 (gnus-summary-goto-subject gnus-current-article)
6730 (gnus-summary-position-point))
6732 (defun gnus-summary-verbose-headers (&optional arg)
6733 "Toggle permanent full header display.
6734 If ARG is a positive number, turn header display on.
6735 If ARG is a negative number, turn header display off."
6737 (gnus-set-global-variables)
6738 (setq gnus-show-all-headers
6739 (cond ((or (not (numberp arg))
6741 (not gnus-show-all-headers))
6744 (gnus-summary-show-article))
6746 (defun gnus-summary-toggle-header (&optional arg)
6747 "Show the headers if they are hidden, or hide them if they are shown.
6748 If ARG is a positive number, show the entire header.
6749 If ARG is a negative number, hide the unwanted header lines."
6751 (gnus-set-global-variables)
6753 (set-buffer gnus-article-buffer)
6754 (let* ((buffer-read-only nil)
6755 (inhibit-point-motion-hooks t)
6756 (hidden (text-property-any
6757 (goto-char (point-min)) (search-forward "\n\n")
6760 (goto-char (point-min))
6761 (when (search-forward "\n\n" nil t)
6762 (delete-region (point-min) (1- (point))))
6763 (goto-char (point-min))
6765 (set-buffer gnus-original-article-buffer)
6766 (goto-char (point-min))
6767 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6768 (insert-buffer-substring gnus-original-article-buffer 1 e)
6769 (let ((article-inhibit-hiding t))
6770 (run-hooks 'gnus-article-display-hook))
6771 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6772 (gnus-article-hide-headers)))))
6774 (defun gnus-summary-show-all-headers ()
6775 "Make all header lines visible."
6777 (gnus-set-global-variables)
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 (gnus-set-global-variables)
6785 (setq gnus-show-mime
6786 (if (null arg) (not gnus-show-mime)
6787 (> (prefix-numeric-value arg) 0)))
6788 (gnus-summary-select-article t 'force))
6790 (defun gnus-summary-caesar-message (&optional arg)
6791 "Caesar rotate the current article by 13.
6792 The numerical prefix specifies how many places to rotate each letter
6795 (gnus-set-global-variables)
6796 (gnus-summary-select-article)
6797 (let ((mail-header-separator ""))
6798 (gnus-eval-in-buffer-window gnus-article-buffer
6801 (let ((start (window-start))
6803 (message-caesar-buffer-body arg)
6804 (set-window-start (get-buffer-window (current-buffer)) start))))))
6806 (defun gnus-summary-stop-page-breaking ()
6807 "Stop page breaking in the current article."
6809 (gnus-set-global-variables)
6810 (gnus-summary-select-article)
6811 (gnus-eval-in-buffer-window gnus-article-buffer
6813 (when (gnus-visual-p 'page-marker)
6814 (let ((buffer-read-only nil))
6815 (gnus-remove-text-with-property 'gnus-prev)
6816 (gnus-remove-text-with-property 'gnus-next)))))
6818 (defun gnus-summary-move-article (&optional n to-newsgroup
6819 select-method action)
6820 "Move the current article to a different newsgroup.
6821 If N is a positive number, move the N next articles.
6822 If N is a negative number, move the N previous articles.
6823 If N is nil and any articles have been marked with the process mark,
6824 move those articles instead.
6825 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6826 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6827 re-spool using this method.
6829 For this function to work, both the current newsgroup and the
6830 newsgroup that you want to move to have to support the `request-move'
6831 and `request-accept' functions."
6834 (setq action 'move))
6835 (gnus-set-global-variables)
6836 ;; Disable marking as read.
6837 (let (gnus-mark-article-hook)
6838 (save-window-excursion
6839 (gnus-summary-select-article)))
6840 ;; Check whether the source group supports the required functions.
6841 (cond ((and (eq action 'move)
6842 (not (gnus-check-backend-function
6843 'request-move-article gnus-newsgroup-name)))
6844 (error "The current group does not support article moving"))
6845 ((and (eq action 'crosspost)
6846 (not (gnus-check-backend-function
6847 'request-replace-article gnus-newsgroup-name)))
6848 (error "The current group does not support article editing")))
6849 (let ((articles (gnus-summary-work-articles n))
6850 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6851 (names '((move "Move" "Moving")
6852 (copy "Copy" "Copying")
6853 (crosspost "Crosspost" "Crossposting")))
6854 (copy-buf (save-excursion
6855 (nnheader-set-temp-buffer " *copy article*")))
6856 art-group to-method new-xref article to-groups)
6857 (unless (assq action names)
6858 (error "Unknown action %s" action))
6859 ;; Read the newsgroup name.
6860 (when (and (not to-newsgroup)
6861 (not select-method))
6863 (gnus-read-move-group-name
6864 (cadr (assq action names))
6865 (symbol-value (intern (format "gnus-current-%s-group" action)))
6867 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6868 (setq to-method (or select-method
6869 (gnus-group-name-to-method to-newsgroup)))
6870 ;; Check the method we are to move this article to...
6871 (unless (gnus-check-backend-function
6872 'request-accept-article (car to-method))
6873 (error "%s does not support article copying" (car to-method)))
6874 (unless (gnus-check-server to-method)
6875 (error "Can't open server %s" (car to-method)))
6876 (gnus-message 6 "%s to %s: %s..."
6877 (caddr (assq action names))
6878 (or (car select-method) to-newsgroup) articles)
6880 (setq article (pop articles))
6884 ;; Move the article.
6886 ;; Remove this article from future suppression.
6887 (gnus-dup-unsuppress-article article)
6888 (gnus-request-move-article
6889 article ; Article to move
6890 gnus-newsgroup-name ; From newsgroup
6891 (nth 1 (gnus-find-method-for-group
6892 gnus-newsgroup-name)) ; Server
6893 (list 'gnus-request-accept-article
6894 to-newsgroup (list 'quote select-method)
6895 (not articles)) ; Accept form
6896 (not articles))) ; Only save nov last time
6897 ;; Copy the article.
6900 (set-buffer copy-buf)
6901 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6902 (gnus-request-accept-article
6903 to-newsgroup select-method (not articles))))
6904 ;; Crosspost the article.
6905 ((eq action 'crosspost)
6906 (let ((xref (message-tokenize-header
6907 (mail-header-xref (gnus-summary-article-header article))
6909 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6912 (setq xref (list (system-name))))
6915 (mapconcat 'identity
6916 (delete "Xref:" (delete new-xref xref))
6920 (set-buffer copy-buf)
6921 ;; First put the article in the destination group.
6922 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6923 (when (consp (setq art-group
6924 (gnus-request-accept-article
6925 to-newsgroup select-method (not articles))))
6926 (setq new-xref (concat new-xref " " (car art-group)
6927 ":" (cdr art-group)))
6928 ;; Now we have the new Xrefs header, so we insert
6929 ;; it and replace the new article.
6930 (nnheader-replace-header "Xref" new-xref)
6931 (gnus-request-replace-article
6932 (cdr art-group) to-newsgroup (current-buffer))
6936 (gnus-message 1 "Couldn't %s article %s"
6937 (cadr (assq action names)) article))
6938 ((and (eq art-group 'junk)
6940 (gnus-summary-mark-article article gnus-canceled-mark)
6941 (gnus-message 4 "Deleted article %s" article))
6945 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6947 (gnus-group-prefixed-name
6950 (gnus-find-method-for-group to-newsgroup)))
6951 gnus-newsrc-hashtb)))
6952 (info (nth 2 entry))
6953 (to-group (gnus-info-group info)))
6954 ;; Update the group that has been moved to.
6956 (memq action '(move copy)))
6957 (unless (member to-group to-groups)
6958 (push to-group to-groups))
6960 (unless (memq article gnus-newsgroup-unreads)
6962 info (gnus-add-to-range (gnus-info-read info)
6963 (list (cdr art-group)))))
6965 ;; Copy any marks over to the new group.
6966 (let ((marks gnus-article-mark-lists)
6967 (to-article (cdr art-group)))
6969 ;; See whether the article is to be put in the cache.
6970 (when gnus-use-cache
6971 (gnus-cache-possibly-enter-article
6973 (let ((header (copy-sequence
6974 (gnus-summary-article-header article))))
6975 (mail-header-set-number header to-article)
6977 (memq article gnus-newsgroup-marked)
6978 (memq article gnus-newsgroup-dormant)
6979 (memq article gnus-newsgroup-unreads)))
6981 (when (and (equal to-group gnus-newsgroup-name)
6982 (not (memq article gnus-newsgroup-unreads)))
6983 ;; Mark this article as read in this group.
6984 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6985 (setcdr (gnus-active to-group) to-article)
6986 (setcdr gnus-newsgroup-active to-article))
6989 (when (memq article (symbol-value
6990 (intern (format "gnus-newsgroup-%s"
6992 ;; If the other group is the same as this group,
6993 ;; then we have to add the mark to the list.
6994 (when (equal to-group gnus-newsgroup-name)
6995 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6998 (intern (format "gnus-newsgroup-%s"
7000 ;; Copy the marks to other group.
7001 (gnus-add-marked-articles
7002 to-group (cdar marks) (list to-article) info))
7003 (setq marks (cdr marks)))
7006 (concat "(gnus-group-set-info '"
7007 (gnus-prin1-to-string (gnus-get-info to-group))
7010 ;; Update the Xref header in this article to point to
7011 ;; the new crossposted article we have just created.
7012 (when (eq action 'crosspost)
7014 (set-buffer copy-buf)
7015 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7016 (nnheader-replace-header "Xref" new-xref)
7017 (gnus-request-replace-article
7018 article gnus-newsgroup-name (current-buffer)))))
7020 (gnus-summary-goto-subject article)
7021 (when (eq action 'move)
7022 (gnus-summary-mark-article article gnus-canceled-mark))))
7023 (gnus-summary-remove-process-mark article))
7024 ;; Re-activate all groups that have been moved to.
7027 (set-buffer gnus-group-buffer)
7028 (when (gnus-group-goto-group (car to-groups) t)
7029 (gnus-group-get-new-news-this-group 1 t))
7032 (gnus-kill-buffer copy-buf)
7033 (gnus-summary-position-point)
7034 (gnus-set-mode-line 'summary)))
7036 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7037 "Move the current article to a different newsgroup.
7038 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7039 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7040 re-spool using this method."
7042 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7044 (defun gnus-summary-crosspost-article (&optional n)
7045 "Crosspost the current article to some other group."
7047 (gnus-summary-move-article n nil nil 'crosspost))
7049 (defcustom gnus-summary-respool-default-method nil
7050 "Default method for respooling an article.
7051 If nil, use to the current newsgroup method."
7052 :type `(choice (gnus-select-method :value (nnml ""))
7054 :group 'gnus-summary-mail)
7056 (defun gnus-summary-respool-article (&optional n method)
7057 "Respool the current article.
7058 The article will be squeezed through the mail spooling process again,
7059 which means that it will be put in some mail newsgroup or other
7060 depending on `nnmail-split-methods'.
7061 If N is a positive number, respool the N next articles.
7062 If N is a negative number, respool the N previous articles.
7063 If N is nil and any articles have been marked with the process mark,
7064 respool those articles instead.
7066 Respooling can be done both from mail groups and \"real\" newsgroups.
7067 In the former case, the articles in question will be moved from the
7068 current group into whatever groups they are destined to. In the
7069 latter case, they will be copied into the relevant groups."
7071 (list current-prefix-arg
7072 (let* ((methods (gnus-methods-using 'respool))
7074 (symbol-name (or gnus-summary-respool-default-method
7075 (car (gnus-find-method-for-group
7076 gnus-newsgroup-name)))))
7078 (gnus-completing-read
7079 methname "What backend do you want to use when respooling?"
7080 methods nil t nil 'gnus-mail-method-history))
7083 ((zerop (length (setq ms (gnus-servers-using-backend
7085 (list (intern method) ""))
7089 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7090 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7092 (gnus-set-global-variables)
7094 (error "No method given for respooling"))
7095 (if (assoc (symbol-name
7096 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7097 (gnus-methods-using 'respool))
7098 (gnus-summary-move-article n nil method)
7099 (gnus-summary-copy-article n nil method)))
7101 (defun gnus-summary-import-article (file)
7102 "Import a random file into a mail newsgroup."
7103 (interactive "fImport file: ")
7104 (gnus-set-global-variables)
7105 (let ((group gnus-newsgroup-name)
7106 (now (current-time))
7108 (unless (gnus-check-backend-function 'request-accept-article group)
7109 (error "%s does not support article importing" group))
7110 (or (file-readable-p file)
7111 (not (file-regular-p file))
7112 (error "Can't read %s" file))
7114 (set-buffer (get-buffer-create " *import file*"))
7115 (buffer-disable-undo (current-buffer))
7117 (insert-file-contents file)
7118 (goto-char (point-min))
7119 (unless (nnheader-article-p)
7120 ;; This doesn't look like an article, so we fudge some headers.
7121 (setq atts (file-attributes file)
7122 lines (count-lines (point-min) (point-max)))
7123 (insert "From: " (read-string "From: ") "\n"
7124 "Subject: " (read-string "Subject: ") "\n"
7125 "Date: " (timezone-make-date-arpa-standard
7126 (current-time-string (nth 5 atts))
7127 (current-time-zone now)
7128 (current-time-zone now))
7130 "Message-ID: " (message-make-message-id) "\n"
7131 "Lines: " (int-to-string lines) "\n"
7132 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7133 (gnus-request-accept-article group nil t)
7134 (kill-buffer (current-buffer)))))
7136 (defun gnus-summary-article-posted-p ()
7137 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7138 This will be the case if the article has both been mailed and posted."
7140 (let ((id (mail-header-references (gnus-summary-article-header)))
7141 (gnus-override-method
7142 (or gnus-refer-article-method gnus-select-method)))
7143 (if (gnus-request-head id "")
7144 (gnus-message 2 "The current message was found on %s"
7145 gnus-override-method)
7146 (gnus-message 2 "The current message couldn't be found on %s"
7147 gnus-override-method)
7150 (defun gnus-summary-expire-articles (&optional now)
7151 "Expire all articles that are marked as expirable in the current group."
7153 (gnus-set-global-variables)
7154 (when (gnus-check-backend-function
7155 'request-expire-articles gnus-newsgroup-name)
7156 ;; This backend supports expiry.
7157 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7158 (expirable (if total
7160 ;; We need to update the info for
7161 ;; this group for `gnus-list-of-read-articles'
7162 ;; to give us the right answer.
7163 (run-hooks 'gnus-exit-group-hook)
7164 (gnus-summary-update-info)
7165 (gnus-list-of-read-articles gnus-newsgroup-name))
7166 (setq gnus-newsgroup-expirable
7167 (sort gnus-newsgroup-expirable '<))))
7168 (expiry-wait (if now 'immediate
7169 (gnus-group-find-parameter
7170 gnus-newsgroup-name 'expiry-wait)))
7173 ;; There are expirable articles in this group, so we run them
7174 ;; through the expiry process.
7175 (gnus-message 6 "Expiring articles...")
7176 ;; The list of articles that weren't expired is returned.
7178 (let ((nnmail-expiry-wait-function nil)
7179 (nnmail-expiry-wait expiry-wait))
7180 (setq es (gnus-request-expire-articles
7181 expirable gnus-newsgroup-name)))
7182 (setq es (gnus-request-expire-articles
7183 expirable gnus-newsgroup-name)))
7185 (setq gnus-newsgroup-expirable es))
7186 ;; We go through the old list of expirable, and mark all
7187 ;; really expired articles as nonexistent.
7188 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7189 (let ((gnus-use-cache nil))
7191 (unless (memq (car expirable) es)
7192 (when (gnus-data-find (car expirable))
7193 (gnus-summary-mark-article
7194 (car expirable) gnus-canceled-mark)))
7195 (setq expirable (cdr expirable)))))
7196 (gnus-message 6 "Expiring articles...done")))))
7198 (defun gnus-summary-expire-articles-now ()
7199 "Expunge all expirable articles in the current group.
7200 This means that *all* articles that are marked as expirable will be
7201 deleted forever, right now."
7203 (gnus-set-global-variables)
7204 (or gnus-expert-user
7206 "Are you really, really, really sure you want to delete all these messages? ")
7208 (gnus-summary-expire-articles t))
7210 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7211 (defun gnus-summary-delete-article (&optional n)
7212 "Delete the N next (mail) articles.
7213 This command actually deletes articles. This is not a marking
7214 command. The article will disappear forever from your life, never to
7216 If N is negative, delete backwards.
7217 If N is nil and articles have been marked with the process mark,
7218 delete these instead."
7220 (gnus-set-global-variables)
7221 (unless (gnus-check-backend-function 'request-expire-articles
7222 gnus-newsgroup-name)
7223 (error "The current newsgroup does not support article deletion"))
7224 ;; Compute the list of articles to delete.
7225 (let ((articles (gnus-summary-work-articles n))
7227 (if (and gnus-novice-user
7228 (not (gnus-yes-or-no-p
7229 (format "Do you really want to delete %s forever? "
7230 (if (> (length articles) 1)
7231 (format "these %s articles" (length articles))
7234 ;; Delete the articles.
7235 (setq not-deleted (gnus-request-expire-articles
7236 articles gnus-newsgroup-name 'force))
7238 (gnus-summary-remove-process-mark (car articles))
7239 ;; The backend might not have been able to delete the article
7241 (unless (memq (car articles) not-deleted)
7242 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7243 (setq articles (cdr articles)))
7245 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7246 (gnus-summary-position-point)
7247 (gnus-set-mode-line 'summary)
7250 (defun gnus-summary-edit-article (&optional force)
7251 "Edit the current article.
7252 This will have permanent effect only in mail groups.
7253 If FORCE is non-nil, allow editing of articles even in read-only
7257 (set-buffer gnus-summary-buffer)
7258 (gnus-set-global-variables)
7259 (when (and (not force)
7260 (gnus-group-read-only-p))
7261 (error "The current newsgroup does not support article editing"))
7262 ;; Select article if needed.
7263 (unless (eq (gnus-summary-article-number)
7264 gnus-current-article)
7265 (gnus-summary-select-article t))
7266 (gnus-article-date-original)
7267 (gnus-article-edit-article
7268 `(lambda (no-highlight)
7269 (gnus-summary-edit-article-done
7270 ,(or (mail-header-references gnus-current-headers) "")
7271 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7273 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7275 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7277 "Make edits to the current article permanent."
7279 ;; Replace the article.
7280 (if (and (not read-only)
7281 (not (gnus-request-replace-article
7282 (cdr gnus-article-current) (car gnus-article-current)
7284 (error "Couldn't replace article")
7285 ;; Update the summary buffer.
7287 (equal (message-tokenize-header references " ")
7288 (message-tokenize-header
7289 (or (message-fetch-field "references") "") " ")))
7290 ;; We only have to update this line.
7293 (message-narrow-to-head)
7294 (let ((head (buffer-string))
7296 (nnheader-temp-write nil
7297 (insert (format "211 %d Article retrieved.\n"
7298 (cdr gnus-article-current)))
7301 (let ((nntp-server-buffer (current-buffer)))
7302 (setq header (car (gnus-get-newsgroup-headers
7304 (set-buffer gnus-summary-buffer)
7305 gnus-newsgroup-dependencies)
7308 (set-buffer gnus-summary-buffer)
7309 (gnus-data-set-header
7310 (gnus-data-find (cdr gnus-article-current))
7312 (gnus-summary-update-article-line
7313 (cdr gnus-article-current) header))))))
7315 (set-buffer (or buffer gnus-summary-buffer))
7316 (gnus-summary-update-article (cdr gnus-article-current)))
7317 ;; Prettify the article buffer again.
7318 (unless no-highlight
7320 (set-buffer gnus-article-buffer)
7321 (run-hooks 'gnus-article-display-hook)
7322 (set-buffer gnus-original-article-buffer)
7323 (gnus-request-article
7324 (cdr gnus-article-current)
7325 (car gnus-article-current) (current-buffer))))
7326 ;; Prettify the summary buffer line.
7327 (when (gnus-visual-p 'summary-highlight 'highlight)
7328 (run-hooks 'gnus-visual-mark-article-hook))))
7330 (defun gnus-summary-edit-wash (key)
7331 "Perform editing command in the article buffer."
7335 (message "%s" (concat (this-command-keys) "- "))
7338 (gnus-summary-edit-article)
7339 (execute-kbd-macro (concat (this-command-keys) key))
7340 (gnus-article-edit-done))
7344 (defun gnus-summary-respool-query (&optional silent)
7345 "Query where the respool algorithm would put this article."
7347 (gnus-set-global-variables)
7348 (let (gnus-mark-article-hook)
7349 (gnus-summary-select-article)
7351 (set-buffer gnus-original-article-buffer)
7353 (message-narrow-to-head)
7354 (let ((groups (nnmail-article-group 'identity)))
7357 (message "This message would go to %s"
7358 (mapconcat 'car groups ", "))
7359 (message "This message would go to no groups"))
7362 ;; Summary marking commands.
7364 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7365 "Mark articles which has the same subject as read, and then select the next.
7366 If UNMARK is positive, remove any kind of mark.
7367 If UNMARK is negative, tick articles."
7369 (gnus-set-global-variables)
7371 (setq unmark (prefix-numeric-value unmark)))
7373 (gnus-summary-mark-same-subject
7374 (gnus-summary-article-subject) unmark)))
7375 ;; Select next unread article. If auto-select-same mode, should
7376 ;; select the first unread article.
7377 (gnus-summary-next-article t (and gnus-auto-select-same
7378 (gnus-summary-article-subject)))
7379 (gnus-message 7 "%d article%s marked as %s"
7380 count (if (= count 1) " is" "s are")
7381 (if unmark "unread" "read"))))
7383 (defun gnus-summary-kill-same-subject (&optional unmark)
7384 "Mark articles which has the same subject as read.
7385 If UNMARK is positive, remove any kind of mark.
7386 If UNMARK is negative, tick articles."
7388 (gnus-set-global-variables)
7390 (setq unmark (prefix-numeric-value unmark)))
7392 (gnus-summary-mark-same-subject
7393 (gnus-summary-article-subject) unmark)))
7394 ;; If marked as read, go to next unread subject.
7396 ;; Go to next unread subject.
7397 (gnus-summary-next-subject 1 t))
7398 (gnus-message 7 "%d articles are marked as %s"
7399 count (if unmark "unread" "read"))))
7401 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7402 "Mark articles with same SUBJECT as read, and return marked number.
7403 If optional argument UNMARK is positive, remove any kinds of marks.
7404 If optional argument UNMARK is negative, mark articles as unread instead."
7408 ((null unmark) ; Mark as read.
7411 (gnus-summary-mark-article-as-read gnus-killed-mark)
7412 (gnus-summary-show-thread) t)
7413 (gnus-summary-find-subject subject))
7414 (setq count (1+ count))))
7415 ((> unmark 0) ; Tick.
7418 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7419 (gnus-summary-show-thread) t)
7420 (gnus-summary-find-subject subject))
7421 (setq count (1+ count))))
7422 (t ; Mark as unread.
7425 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7426 (gnus-summary-show-thread) t)
7427 (gnus-summary-find-subject subject))
7428 (setq count (1+ count)))))
7429 (gnus-set-mode-line 'summary)
7430 ;; Return the number of marked articles.
7433 (defun gnus-summary-mark-as-processable (n &optional unmark)
7434 "Set the process mark on the next N articles.
7435 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7436 the process mark instead. The difference between N and the actual
7437 number of articles marked is returned."
7439 (gnus-set-global-variables)
7440 (let ((backward (< n 0))
7445 (gnus-summary-remove-process-mark
7446 (gnus-summary-article-number))
7447 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7448 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7451 (gnus-message 7 "No more articles"))
7452 (gnus-summary-recenter)
7453 (gnus-summary-position-point)
7456 (defun gnus-summary-unmark-as-processable (n)
7457 "Remove the process mark from the next N articles.
7458 If N is negative, unmark backward instead. The difference between N and
7459 the actual number of articles unmarked is returned."
7461 (gnus-set-global-variables)
7462 (gnus-summary-mark-as-processable n t))
7464 (defun gnus-summary-unmark-all-processable ()
7465 "Remove the process mark from all articles."
7467 (gnus-set-global-variables)
7469 (while gnus-newsgroup-processable
7470 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7471 (gnus-summary-position-point))
7473 (defun gnus-summary-mark-as-expirable (n)
7474 "Mark N articles forward as expirable.
7475 If N is negative, mark backward instead. The difference between N and
7476 the actual number of articles marked is returned."
7478 (gnus-set-global-variables)
7479 (gnus-summary-mark-forward n gnus-expirable-mark))
7481 (defun gnus-summary-mark-article-as-replied (article)
7482 "Mark ARTICLE replied and update the summary line."
7483 (push article gnus-newsgroup-replied)
7484 (let ((buffer-read-only nil))
7485 (when (gnus-summary-goto-subject article)
7486 (gnus-summary-update-secondary-mark article))))
7488 (defun gnus-summary-set-bookmark (article)
7489 "Set a bookmark in current article."
7490 (interactive (gnus-summary-article-number))
7491 (gnus-set-global-variables)
7492 (when (or (not (get-buffer gnus-article-buffer))
7493 (not gnus-current-article)
7494 (not gnus-article-current)
7495 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7496 (error "No current article selected"))
7497 ;; Remove old bookmark, if one exists.
7498 (let ((old (assq article gnus-newsgroup-bookmarks)))
7500 (setq gnus-newsgroup-bookmarks
7501 (delq old gnus-newsgroup-bookmarks))))
7502 ;; Set the new bookmark, which is on the form
7503 ;; (article-number . line-number-in-body).
7507 (set-buffer gnus-article-buffer)
7511 (goto-char (point-min))
7512 (search-forward "\n\n" nil t)
7515 gnus-newsgroup-bookmarks)
7516 (gnus-message 6 "A bookmark has been added to the current article."))
7518 (defun gnus-summary-remove-bookmark (article)
7519 "Remove the bookmark from the current article."
7520 (interactive (gnus-summary-article-number))
7521 (gnus-set-global-variables)
7522 ;; Remove old bookmark, if one exists.
7523 (let ((old (assq article gnus-newsgroup-bookmarks)))
7526 (setq gnus-newsgroup-bookmarks
7527 (delq old gnus-newsgroup-bookmarks))
7528 (gnus-message 6 "Removed bookmark."))
7529 (gnus-message 6 "No bookmark in current article."))))
7531 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7532 (defun gnus-summary-mark-as-dormant (n)
7533 "Mark N articles forward as dormant.
7534 If N is negative, mark backward instead. The difference between N and
7535 the actual number of articles marked is returned."
7537 (gnus-set-global-variables)
7538 (gnus-summary-mark-forward n gnus-dormant-mark))
7540 (defun gnus-summary-set-process-mark (article)
7541 "Set the process mark on ARTICLE and update the summary line."
7542 (setq gnus-newsgroup-processable
7544 (delq article gnus-newsgroup-processable)))
7545 (when (gnus-summary-goto-subject article)
7546 (gnus-summary-show-thread)
7547 (gnus-summary-update-secondary-mark article)))
7549 (defun gnus-summary-remove-process-mark (article)
7550 "Remove the process mark from ARTICLE and update the summary line."
7551 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7552 (when (gnus-summary-goto-subject article)
7553 (gnus-summary-show-thread)
7554 (gnus-summary-update-secondary-mark article)))
7556 (defun gnus-summary-set-saved-mark (article)
7557 "Set the process mark on ARTICLE and update the summary line."
7558 (push article gnus-newsgroup-saved)
7559 (when (gnus-summary-goto-subject article)
7560 (gnus-summary-update-secondary-mark article)))
7562 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7563 "Mark N articles as read forwards.
7564 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7565 The difference between N and the actual number of articles marked is
7568 (gnus-set-global-variables)
7569 (let ((backward (< n 0))
7570 (gnus-summary-goto-unread
7571 (and gnus-summary-goto-unread
7572 (not (eq gnus-summary-goto-unread 'never))
7573 (not (memq mark (list gnus-unread-mark
7574 gnus-ticked-mark gnus-dormant-mark)))))
7576 (mark (or mark gnus-del-mark)))
7578 (gnus-summary-mark-article nil mark no-expire)
7579 (zerop (gnus-summary-next-subject
7581 (and gnus-summary-goto-unread
7582 (not (eq gnus-summary-goto-unread 'never)))
7586 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7587 (gnus-summary-recenter)
7588 (gnus-summary-position-point)
7589 (gnus-set-mode-line 'summary)
7592 (defun gnus-summary-mark-article-as-read (mark)
7593 "Mark the current article quickly as read with MARK."
7594 (let ((article (gnus-summary-article-number)))
7595 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7596 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7597 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7598 (push (cons article mark) gnus-newsgroup-reads)
7599 ;; Possibly remove from cache, if that is used.
7600 (when gnus-use-cache
7601 (gnus-cache-enter-remove-article article))
7602 ;; Allow the backend to change the mark.
7603 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7604 ;; Check for auto-expiry.
7605 (when (and gnus-newsgroup-auto-expire
7606 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7607 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7608 (= mark gnus-ancient-mark)
7609 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7610 (= mark gnus-duplicate-mark)))
7611 (setq mark gnus-expirable-mark)
7612 (push article gnus-newsgroup-expirable))
7613 ;; Set the mark in the buffer.
7614 (gnus-summary-update-mark mark 'unread)
7617 (defun gnus-summary-mark-article-as-unread (mark)
7618 "Mark the current article quickly as unread with MARK."
7619 (let ((article (gnus-summary-article-number)))
7621 (gnus-error 1 "Can't mark negative article numbers")
7622 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7623 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7624 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7625 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7626 (cond ((= mark gnus-ticked-mark)
7627 (push article gnus-newsgroup-marked))
7628 ((= mark gnus-dormant-mark)
7629 (push article gnus-newsgroup-dormant))
7631 (push article gnus-newsgroup-unreads)))
7632 (setq gnus-newsgroup-reads
7633 (delq (assq article gnus-newsgroup-reads)
7634 gnus-newsgroup-reads))
7636 ;; See whether the article is to be put in the cache.
7638 (vectorp (gnus-summary-article-header article))
7640 (gnus-cache-possibly-enter-article
7641 gnus-newsgroup-name article
7642 (gnus-summary-article-header article)
7643 (= mark gnus-ticked-mark)
7644 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7647 (gnus-summary-update-mark mark 'unread))
7650 (defun gnus-summary-mark-article (&optional article mark no-expire)
7651 "Mark ARTICLE with MARK. MARK can be any character.
7652 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7653 `??' (dormant) and `?E' (expirable).
7654 If MARK is nil, then the default character `?D' is used.
7655 If ARTICLE is nil, then the article on the current line will be
7657 ;; The mark might be a string.
7658 (when (stringp mark)
7659 (setq mark (aref mark 0)))
7660 ;; If no mark is given, then we check auto-expiring.
7661 (and (not no-expire)
7662 gnus-newsgroup-auto-expire
7664 (and (gnus-characterp mark)
7665 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7666 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7667 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7668 (= mark gnus-duplicate-mark))))
7669 (setq mark gnus-expirable-mark))
7670 (let* ((mark (or mark gnus-del-mark))
7671 (article (or article (gnus-summary-article-number))))
7673 (error "No article on current line"))
7674 (if (or (= mark gnus-unread-mark)
7675 (= mark gnus-ticked-mark)
7676 (= mark gnus-dormant-mark))
7677 (gnus-mark-article-as-unread article mark)
7678 (gnus-mark-article-as-read article mark))
7680 ;; See whether the article is to be put in the cache.
7682 (not (= mark gnus-canceled-mark))
7683 (vectorp (gnus-summary-article-header article))
7685 (gnus-cache-possibly-enter-article
7686 gnus-newsgroup-name article
7687 (gnus-summary-article-header article)
7688 (= mark gnus-ticked-mark)
7689 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7691 (when (gnus-summary-goto-subject article nil t)
7692 (let ((buffer-read-only nil))
7693 (gnus-summary-show-thread)
7695 (gnus-summary-update-mark mark 'unread)
7698 (defun gnus-summary-update-secondary-mark (article)
7699 "Update the secondary (read, process, cache) mark."
7700 (gnus-summary-update-mark
7701 (cond ((memq article gnus-newsgroup-processable)
7703 ((memq article gnus-newsgroup-cached)
7705 ((memq article gnus-newsgroup-replied)
7707 ((memq article gnus-newsgroup-saved)
7709 (t gnus-unread-mark))
7711 (when (gnus-visual-p 'summary-highlight 'highlight)
7712 (run-hooks 'gnus-summary-update-hook))
7715 (defun gnus-summary-update-mark (mark type)
7716 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7717 (buffer-read-only nil))
7718 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7719 (when (looking-at "\r")
7722 (<= (+ forward (point)) (point-max)))
7723 ;; Go to the right position on the line.
7724 (goto-char (+ forward (point)))
7725 ;; Replace the old mark with the new mark.
7726 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7727 ;; Optionally update the marks by some user rule.
7728 (when (eq type 'unread)
7730 (gnus-data-find (gnus-summary-article-number)) mark)
7731 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7733 (defun gnus-mark-article-as-read (article &optional mark)
7734 "Enter ARTICLE in the pertinent lists and remove it from others."
7735 ;; Make the article expirable.
7736 (let ((mark (or mark gnus-del-mark)))
7737 (if (= mark gnus-expirable-mark)
7738 (push article gnus-newsgroup-expirable)
7739 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7740 ;; Remove from unread and marked lists.
7741 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7742 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7743 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7744 (push (cons article mark) gnus-newsgroup-reads)
7745 ;; Possibly remove from cache, if that is used.
7746 (when gnus-use-cache
7747 (gnus-cache-enter-remove-article article))))
7749 (defun gnus-mark-article-as-unread (article &optional mark)
7750 "Enter ARTICLE in the pertinent lists and remove it from others."
7751 (let ((mark (or mark gnus-ticked-mark)))
7752 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7753 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7754 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7755 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7759 (gnus-error 1 "Can't mark negative article numbers")
7761 ;; Unsuppress duplicates?
7762 (when gnus-suppress-duplicates
7763 (gnus-dup-unsuppress-article article))
7765 (cond ((= mark gnus-ticked-mark)
7766 (push article gnus-newsgroup-marked))
7767 ((= mark gnus-dormant-mark)
7768 (push article gnus-newsgroup-dormant))
7770 (push article gnus-newsgroup-unreads)))
7771 (setq gnus-newsgroup-reads
7772 (delq (assq article gnus-newsgroup-reads)
7773 gnus-newsgroup-reads))
7776 (defalias 'gnus-summary-mark-as-unread-forward
7777 'gnus-summary-tick-article-forward)
7778 (make-obsolete 'gnus-summary-mark-as-unread-forward
7779 'gnus-summary-tick-article-forward)
7780 (defun gnus-summary-tick-article-forward (n)
7781 "Tick N articles forwards.
7782 If N is negative, tick backwards instead.
7783 The difference between N and the number of articles ticked is returned."
7785 (gnus-summary-mark-forward n gnus-ticked-mark))
7787 (defalias 'gnus-summary-mark-as-unread-backward
7788 'gnus-summary-tick-article-backward)
7789 (make-obsolete 'gnus-summary-mark-as-unread-backward
7790 'gnus-summary-tick-article-backward)
7791 (defun gnus-summary-tick-article-backward (n)
7792 "Tick N articles backwards.
7793 The difference between N and the number of articles ticked is returned."
7795 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7797 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7798 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7799 (defun gnus-summary-tick-article (&optional article clear-mark)
7800 "Mark current article as unread.
7801 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7802 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7804 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7807 (defun gnus-summary-mark-as-read-forward (n)
7808 "Mark N articles as read forwards.
7809 If N is negative, mark backwards instead.
7810 The difference between N and the actual number of articles marked is
7813 (gnus-summary-mark-forward n gnus-del-mark t))
7815 (defun gnus-summary-mark-as-read-backward (n)
7816 "Mark the N articles as read backwards.
7817 The difference between N and the actual number of articles marked is
7820 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7822 (defun gnus-summary-mark-as-read (&optional article mark)
7823 "Mark current article as read.
7824 ARTICLE specifies the article to be marked as read.
7825 MARK specifies a string to be inserted at the beginning of the line."
7826 (gnus-summary-mark-article article mark))
7828 (defun gnus-summary-clear-mark-forward (n)
7829 "Clear marks from N articles forward.
7830 If N is negative, clear backward instead.
7831 The difference between N and the number of marks cleared is returned."
7833 (gnus-summary-mark-forward n gnus-unread-mark))
7835 (defun gnus-summary-clear-mark-backward (n)
7836 "Clear marks from N articles backward.
7837 The difference between N and the number of marks cleared is returned."
7839 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7841 (defun gnus-summary-mark-unread-as-read ()
7842 "Intended to be used by `gnus-summary-mark-article-hook'."
7843 (when (memq gnus-current-article gnus-newsgroup-unreads)
7844 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7846 (defun gnus-summary-mark-read-and-unread-as-read ()
7847 "Intended to be used by `gnus-summary-mark-article-hook'."
7848 (let ((mark (gnus-summary-article-mark)))
7849 (when (or (gnus-unread-mark-p mark)
7850 (gnus-read-mark-p mark))
7851 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7853 (defun gnus-summary-mark-region-as-read (point mark all)
7854 "Mark all unread articles between point and mark as read.
7855 If given a prefix, mark all articles between point and mark as read,
7856 even ticked and dormant ones."
7857 (interactive "r\nP")
7866 (memq (setq article (gnus-summary-article-number))
7867 gnus-newsgroup-unreads))
7868 (gnus-summary-mark-article article gnus-del-mark))
7870 (gnus-summary-find-next))))))
7872 (defun gnus-summary-mark-below (score mark)
7873 "Mark articles with score less than SCORE with MARK."
7874 (interactive "P\ncMark: ")
7875 (gnus-set-global-variables)
7876 (setq score (if score
7877 (prefix-numeric-value score)
7878 (or gnus-summary-default-score 0)))
7880 (set-buffer gnus-summary-buffer)
7881 (goto-char (point-min))
7884 (and (< (gnus-summary-article-score) score)
7885 (gnus-summary-mark-article nil mark))
7886 (gnus-summary-find-next)))))
7888 (defun gnus-summary-kill-below (&optional score)
7889 "Mark articles with score below SCORE as read."
7891 (gnus-set-global-variables)
7892 (gnus-summary-mark-below score gnus-killed-mark))
7894 (defun gnus-summary-clear-above (&optional score)
7895 "Clear all marks from articles with score above SCORE."
7897 (gnus-set-global-variables)
7898 (gnus-summary-mark-above score gnus-unread-mark))
7900 (defun gnus-summary-tick-above (&optional score)
7901 "Tick all articles with score above SCORE."
7903 (gnus-set-global-variables)
7904 (gnus-summary-mark-above score gnus-ticked-mark))
7906 (defun gnus-summary-mark-above (score mark)
7907 "Mark articles with score over SCORE with MARK."
7908 (interactive "P\ncMark: ")
7909 (gnus-set-global-variables)
7910 (setq score (if score
7911 (prefix-numeric-value score)
7912 (or gnus-summary-default-score 0)))
7914 (set-buffer gnus-summary-buffer)
7915 (goto-char (point-min))
7917 (when (> (gnus-summary-article-score) score)
7918 (gnus-summary-mark-article nil mark))
7920 (gnus-summary-find-next)))))
7922 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7923 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7924 (defun gnus-summary-limit-include-expunged (&optional no-error)
7925 "Display all the hidden articles that were expunged for low scores."
7927 (gnus-set-global-variables)
7928 (let ((buffer-read-only nil))
7929 (let ((scored gnus-newsgroup-scored)
7932 (unless (gnus-summary-goto-subject (caar scored))
7933 (and (setq h (gnus-summary-article-header (caar scored)))
7934 (< (cdar scored) gnus-summary-expunge-below)
7936 (setq scored (cdr scored)))
7938 (when (not no-error)
7939 (error "No expunged articles hidden"))
7940 (goto-char (point-min))
7941 (gnus-summary-prepare-unthreaded (nreverse headers))
7942 (goto-char (point-min))
7943 (gnus-summary-position-point)
7946 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7947 "Mark all unread articles in this newsgroup as read.
7948 If prefix argument ALL is non-nil, ticked and dormant articles will
7949 also be marked as read.
7950 If QUIETLY is non-nil, no questions will be asked.
7951 If TO-HERE is non-nil, it should be a point in the buffer. All
7952 articles before this point will be marked as read.
7953 Note that this function will only catch up the unread article
7954 in the current summary buffer limitation.
7955 The number of articles marked as read is returned."
7957 (gnus-set-global-variables)
7961 (not gnus-interactive-catchup) ;Without confirmation?
7965 "Mark absolutely all articles as read? "
7966 "Mark all unread articles as read? ")))
7968 (not gnus-newsgroup-adaptive)
7969 (not gnus-newsgroup-auto-expire)
7970 (not gnus-suppress-duplicates)
7971 (or (not gnus-use-cache)
7972 (eq gnus-use-cache 'passive)))
7975 (setq gnus-newsgroup-marked nil
7976 gnus-newsgroup-dormant nil))
7977 (setq gnus-newsgroup-unreads nil))
7978 ;; We actually mark all articles as canceled, which we
7979 ;; have to do when using auto-expiry or adaptive scoring.
7980 (gnus-summary-show-all-threads)
7981 (when (gnus-summary-first-subject (not all))
7983 (if to-here (< (point) to-here) t)
7984 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7985 (gnus-summary-find-next (not all)))))
7986 (gnus-set-mode-line 'summary))
7988 (gnus-summary-position-point)))
7990 (defun gnus-summary-catchup-to-here (&optional all)
7991 "Mark all unticked articles before the current one as read.
7992 If ALL is non-nil, also mark ticked and dormant articles as read."
7994 (gnus-set-global-variables)
7996 (gnus-save-hidden-threads
7997 (let ((beg (point)))
7998 ;; We check that there are unread articles.
7999 (when (or all (gnus-summary-find-prev))
8000 (gnus-summary-catchup all t beg)))))
8001 (gnus-summary-position-point))
8003 (defun gnus-summary-catchup-all (&optional quietly)
8004 "Mark all articles in this newsgroup as read."
8006 (gnus-set-global-variables)
8007 (gnus-summary-catchup t quietly))
8009 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8010 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8011 If prefix argument ALL is non-nil, all articles are marked as read."
8013 (gnus-set-global-variables)
8014 (when (gnus-summary-catchup all quietly nil 'fast)
8015 ;; Select next newsgroup or exit.
8016 (if (eq gnus-auto-select-next 'quietly)
8017 (gnus-summary-next-group nil)
8018 (gnus-summary-exit))))
8020 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8021 "Mark all articles in this newsgroup as read, and then exit."
8023 (gnus-set-global-variables)
8024 (gnus-summary-catchup-and-exit t quietly))
8026 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8027 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8028 "Mark all articles in this group as read and select the next group.
8029 If given a prefix, mark all articles, unread as well as ticked, as
8032 (gnus-set-global-variables)
8034 (gnus-summary-catchup all))
8035 (gnus-summary-next-article t nil nil t))
8037 ;; Thread-based commands.
8039 (defun gnus-summary-articles-in-thread (&optional article)
8040 "Return a list of all articles in the current thread.
8041 If ARTICLE is non-nil, return all articles in the thread that starts
8043 (let* ((article (or article (gnus-summary-article-number)))
8044 (data (gnus-data-find-list article))
8045 (top-level (gnus-data-level (car data)))
8047 (cond ((null gnus-thread-operation-ignore-subject)
8048 (gnus-simplify-subject-re
8049 (mail-header-subject (gnus-data-header (car data)))))
8050 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8051 (gnus-simplify-subject-fuzzy
8052 (mail-header-subject (gnus-data-header (car data)))))
8054 (end-point (save-excursion
8055 (if (gnus-summary-go-to-next-thread)
8056 (point) (point-max))))
8059 (< (gnus-data-pos (car data)) end-point))
8060 (when (or (not top-subject)
8061 (string= top-subject
8062 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8063 (gnus-simplify-subject-fuzzy
8064 (mail-header-subject
8065 (gnus-data-header (car data))))
8066 (gnus-simplify-subject-re
8067 (mail-header-subject
8068 (gnus-data-header (car data)))))))
8069 (push (gnus-data-number (car data)) articles))
8070 (unless (and (setq data (cdr data))
8071 (> (gnus-data-level (car data)) top-level))
8073 ;; Return the list of articles.
8074 (nreverse articles)))
8076 (defun gnus-summary-rethread-current ()
8077 "Rethread the thread the current article is part of."
8079 (gnus-set-global-variables)
8080 (let* ((gnus-show-threads t)
8081 (article (gnus-summary-article-number))
8082 (id (mail-header-id (gnus-summary-article-header)))
8083 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8085 (error "No article on the current line"))
8086 (gnus-rebuild-thread id)
8087 (gnus-summary-goto-subject article)))
8089 (defun gnus-summary-reparent-thread ()
8090 "Make the current article child of the marked (or previous) article.
8092 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8093 is non-nil or the Subject: of both articles are the same."
8095 (unless (not (gnus-group-read-only-p))
8096 (error "The current newsgroup does not support article editing"))
8097 (unless (<= (length gnus-newsgroup-processable) 1)
8098 (error "No more than one article may be marked"))
8099 (save-window-excursion
8100 (let ((gnus-article-buffer " *reparent*")
8101 (current-article (gnus-summary-article-number))
8102 ;; First grab the marked article, otherwise one line up.
8103 (parent-article (if (not (null gnus-newsgroup-processable))
8104 (car gnus-newsgroup-processable)
8106 (if (eq (forward-line -1) 0)
8107 (gnus-summary-article-number)
8108 (error "Beginning of summary buffer"))))))
8109 (unless (not (eq current-article parent-article))
8110 (error "An article may not be self-referential"))
8111 (let ((message-id (mail-header-id
8112 (gnus-summary-article-header parent-article))))
8113 (unless (and message-id (not (equal message-id "")))
8114 (error "No message-id in desired parent"))
8115 (gnus-summary-select-article t t nil current-article)
8116 (set-buffer gnus-original-article-buffer)
8117 (let ((buf (format "%s" (buffer-string))))
8118 (nnheader-temp-write nil
8120 (goto-char (point-min))
8121 (if (search-forward-regexp "^References: " nil t)
8122 (insert message-id " " )
8123 (insert "References: " message-id "\n"))
8124 (unless (gnus-request-replace-article
8125 current-article (car gnus-article-current)
8127 (error "Couldn't replace article"))))
8128 (set-buffer gnus-summary-buffer)
8129 (gnus-summary-unmark-all-processable)
8130 (gnus-summary-rethread-current)
8131 (gnus-message 3 "Article %d is now the child of article %d"
8132 current-article parent-article)))))
8134 (defun gnus-summary-toggle-threads (&optional arg)
8135 "Toggle showing conversation threads.
8136 If ARG is positive number, turn showing conversation threads on."
8138 (gnus-set-global-variables)
8139 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8140 (setq gnus-show-threads
8141 (if (null arg) (not gnus-show-threads)
8142 (> (prefix-numeric-value arg) 0)))
8143 (gnus-summary-prepare)
8144 (gnus-summary-goto-subject current)
8145 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8146 (gnus-summary-position-point)))
8148 (defun gnus-summary-show-all-threads ()
8151 (gnus-set-global-variables)
8153 (let ((buffer-read-only nil))
8154 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8155 (gnus-summary-position-point))
8157 (defun gnus-summary-show-thread ()
8158 "Show thread subtrees.
8159 Returns nil if no thread was there to be shown."
8161 (gnus-set-global-variables)
8162 (let ((buffer-read-only nil)
8164 ;; first goto end then to beg, to have point at beg after let
8165 (end (progn (end-of-line) (point)))
8166 (beg (progn (beginning-of-line) (point))))
8168 ;; Any hidden lines here?
8169 (search-forward "\r" end t)
8170 (subst-char-in-region beg end ?\^M ?\n t)
8172 (gnus-summary-position-point))))
8174 (defun gnus-summary-hide-all-threads ()
8175 "Hide all thread subtrees."
8177 (gnus-set-global-variables)
8179 (goto-char (point-min))
8180 (gnus-summary-hide-thread)
8181 (while (zerop (gnus-summary-next-thread 1 t))
8182 (gnus-summary-hide-thread)))
8183 (gnus-summary-position-point))
8185 (defun gnus-summary-hide-thread ()
8186 "Hide thread subtrees.
8187 Returns nil if no threads were there to be hidden."
8189 (gnus-set-global-variables)
8190 (let ((buffer-read-only nil)
8192 (article (gnus-summary-article-number)))
8194 ;; Go forward until either the buffer ends or the subthread
8196 (when (and (not (eobp))
8197 (or (zerop (gnus-summary-next-thread 1 t))
8198 (goto-char (point-max))))
8200 (if (and (> (point) start)
8201 (search-backward "\n" start t))
8203 (subst-char-in-region start (point) ?\n ?\^M)
8204 (gnus-summary-goto-subject article))
8207 ;;(gnus-summary-position-point)
8210 (defun gnus-summary-go-to-next-thread (&optional previous)
8211 "Go to the same level (or less) next thread.
8212 If PREVIOUS is non-nil, go to previous thread instead.
8213 Return the article number moved to, or nil if moving was impossible."
8214 (let ((level (gnus-summary-thread-level))
8215 (way (if previous -1 1))
8218 (while (and (not (eobp))
8219 (< level (gnus-summary-thread-level)))
8227 (gnus-summary-article-number)
8230 (defun gnus-summary-next-thread (n &optional silent)
8231 "Go to the same level next N'th thread.
8232 If N is negative, search backward instead.
8233 Returns the difference between N and the number of skips actually
8236 If SILENT, don't output messages."
8238 (gnus-set-global-variables)
8239 (let ((backward (< n 0))
8242 (gnus-summary-go-to-next-thread backward))
8245 (gnus-summary-position-point))
8246 (when (and (not silent) (/= 0 n))
8247 (gnus-message 7 "No more threads"))
8250 (defun gnus-summary-prev-thread (n)
8251 "Go to the same level previous N'th thread.
8252 Returns the difference between N and the number of skips actually
8255 (gnus-set-global-variables)
8256 (gnus-summary-next-thread (- n)))
8258 (defun gnus-summary-go-down-thread ()
8259 "Go down one level in the current thread."
8260 (let ((children (gnus-summary-article-children)))
8262 (gnus-summary-goto-subject (car children)))))
8264 (defun gnus-summary-go-up-thread ()
8265 "Go up one level in the current thread."
8266 (let ((parent (gnus-summary-article-parent)))
8268 (gnus-summary-goto-subject parent))))
8270 (defun gnus-summary-down-thread (n)
8271 "Go down thread N steps.
8272 If N is negative, go up instead.
8273 Returns the difference between N and how many steps down that were
8276 (gnus-set-global-variables)
8280 (if up (gnus-summary-go-up-thread)
8281 (gnus-summary-go-down-thread)))
8283 (gnus-summary-position-point)
8285 (gnus-message 7 "Can't go further"))
8288 (defun gnus-summary-up-thread (n)
8289 "Go up thread N steps.
8290 If N is negative, go up instead.
8291 Returns the difference between N and how many steps down that were
8294 (gnus-set-global-variables)
8295 (gnus-summary-down-thread (- n)))
8297 (defun gnus-summary-top-thread ()
8298 "Go to the top of the thread."
8300 (gnus-set-global-variables)
8301 (while (gnus-summary-go-up-thread))
8302 (gnus-summary-article-number))
8304 (defun gnus-summary-kill-thread (&optional unmark)
8305 "Mark articles under current thread as read.
8306 If the prefix argument is positive, remove any kinds of marks.
8307 If the prefix argument is negative, tick articles instead."
8309 (gnus-set-global-variables)
8311 (setq unmark (prefix-numeric-value unmark)))
8312 (let ((articles (gnus-summary-articles-in-thread)))
8314 ;; Expand the thread.
8315 (gnus-summary-show-thread)
8316 ;; Mark all the articles.
8318 (gnus-summary-goto-subject (car articles))
8319 (cond ((null unmark)
8320 (gnus-summary-mark-article-as-read gnus-killed-mark))
8322 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8324 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8325 (setq articles (cdr articles))))
8326 ;; Hide killed subtrees.
8328 gnus-thread-hide-killed
8329 (gnus-summary-hide-thread))
8330 ;; If marked as read, go to next unread subject.
8332 ;; Go to next unread subject.
8333 (gnus-summary-next-subject 1 t)))
8334 (gnus-set-mode-line 'summary))
8336 ;; Summary sorting commands
8338 (defun gnus-summary-sort-by-number (&optional reverse)
8339 "Sort the summary buffer by article number.
8340 Argument REVERSE means reverse order."
8342 (gnus-summary-sort 'number reverse))
8344 (defun gnus-summary-sort-by-author (&optional reverse)
8345 "Sort the summary buffer by author name alphabetically.
8346 If case-fold-search is non-nil, case of letters is ignored.
8347 Argument REVERSE means reverse order."
8349 (gnus-summary-sort 'author reverse))
8351 (defun gnus-summary-sort-by-subject (&optional reverse)
8352 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8353 If case-fold-search is non-nil, case of letters is ignored.
8354 Argument REVERSE means reverse order."
8356 (gnus-summary-sort 'subject reverse))
8358 (defun gnus-summary-sort-by-date (&optional reverse)
8359 "Sort the summary buffer by date.
8360 Argument REVERSE means reverse order."
8362 (gnus-summary-sort 'date reverse))
8364 (defun gnus-summary-sort-by-score (&optional reverse)
8365 "Sort the summary buffer by score.
8366 Argument REVERSE means reverse order."
8368 (gnus-summary-sort 'score reverse))
8370 (defun gnus-summary-sort-by-lines (&optional reverse)
8371 "Sort the summary buffer by article length.
8372 Argument REVERSE means reverse order."
8374 (gnus-summary-sort 'lines reverse))
8376 (defun gnus-summary-sort (predicate reverse)
8377 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8378 (gnus-set-global-variables)
8379 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8380 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8381 (gnus-thread-sort-functions
8387 (gnus-article-sort-functions
8392 (,article t2 t1)))))
8394 (gnus-summary-prepare-hook nil))
8395 ;; We do the sorting by regenerating the threads.
8396 (gnus-summary-prepare)
8397 ;; Hide subthreads if needed.
8398 (when (and gnus-show-threads gnus-thread-hide-subtree)
8399 (gnus-summary-hide-all-threads))))
8401 ;; Summary saving commands.
8403 (defun gnus-summary-save-article (&optional n not-saved)
8404 "Save the current article using the default saver function.
8405 If N is a positive number, save the N next articles.
8406 If N is a negative number, save the N previous articles.
8407 If N is nil and any articles have been marked with the process mark,
8408 save those articles instead.
8409 The variable `gnus-default-article-saver' specifies the saver function."
8411 (gnus-set-global-variables)
8412 (let* ((articles (gnus-summary-work-articles n))
8413 (save-buffer (save-excursion
8414 (nnheader-set-temp-buffer " *Gnus Save*")))
8415 (num (length articles))
8416 header article file)
8418 (setq header (gnus-summary-article-header
8419 (setq article (pop articles))))
8420 (if (not (vectorp header))
8421 ;; This is a pseudo-article.
8422 (if (assq 'name header)
8423 (gnus-copy-file (cdr (assq 'name header)))
8424 (gnus-message 1 "Article %d is unsaveable" article))
8425 ;; This is a real article.
8426 (save-window-excursion
8427 (gnus-summary-select-article t nil nil article))
8429 (set-buffer save-buffer)
8431 (insert-buffer-substring gnus-original-article-buffer))
8432 (setq file (gnus-article-save save-buffer file num))
8433 (gnus-summary-remove-process-mark article)
8435 (gnus-summary-set-saved-mark article))))
8436 (gnus-kill-buffer save-buffer)
8437 (gnus-summary-position-point)
8438 (gnus-set-mode-line 'summary)
8441 (defun gnus-summary-pipe-output (&optional arg)
8442 "Pipe the current article to a subprocess.
8443 If N is a positive number, pipe the N next articles.
8444 If N is a negative number, pipe the N previous articles.
8445 If N is nil and any articles have been marked with the process mark,
8446 pipe those articles instead."
8448 (gnus-set-global-variables)
8449 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8450 (gnus-summary-save-article arg t))
8451 (gnus-configure-windows 'pipe))
8453 (defun gnus-summary-save-article-mail (&optional arg)
8454 "Append the current article to an mail 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 (gnus-set-global-variables)
8461 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8462 (gnus-summary-save-article arg)))
8464 (defun gnus-summary-save-article-rmail (&optional arg)
8465 "Append the current article to an rmail file.
8466 If N is a positive number, save the N next articles.
8467 If N is a negative number, save the N previous articles.
8468 If N is nil and any articles have been marked with the process mark,
8469 save those articles instead."
8471 (gnus-set-global-variables)
8472 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8473 (gnus-summary-save-article arg)))
8475 (defun gnus-summary-save-article-file (&optional arg)
8476 "Append the current article to a file.
8477 If N is a positive number, save the N next articles.
8478 If N is a negative number, save the N previous articles.
8479 If N is nil and any articles have been marked with the process mark,
8480 save those articles instead."
8482 (gnus-set-global-variables)
8483 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8484 (gnus-summary-save-article arg)))
8486 (defun gnus-summary-write-article-file (&optional arg)
8487 "Write the current article to a file, deleting the previous file.
8488 If N is a positive number, save the N next articles.
8489 If N is a negative number, save the N previous articles.
8490 If N is nil and any articles have been marked with the process mark,
8491 save those articles instead."
8493 (gnus-set-global-variables)
8494 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8495 (gnus-summary-save-article arg)))
8497 (defun gnus-summary-save-article-body-file (&optional arg)
8498 "Append the current article body to a file.
8499 If N is a positive number, save the N next articles.
8500 If N is a negative number, save the N previous articles.
8501 If N is nil and any articles have been marked with the process mark,
8502 save those articles instead."
8504 (gnus-set-global-variables)
8505 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8506 (gnus-summary-save-article arg)))
8508 (defun gnus-summary-pipe-message (program)
8509 "Pipe the current article through PROGRAM."
8510 (interactive "sProgram: ")
8511 (gnus-set-global-variables)
8512 (gnus-summary-select-article)
8513 (let ((mail-header-separator "")
8514 (art-buf (get-buffer gnus-article-buffer)))
8515 (gnus-eval-in-buffer-window gnus-article-buffer
8518 (let ((start (window-start))
8520 (message-pipe-buffer-body program)
8521 (set-window-start (get-buffer-window (current-buffer)) start))))))
8523 (defun gnus-get-split-value (methods)
8524 "Return a value based on the split METHODS."
8525 (let (split-name method result match)
8528 (set-buffer gnus-original-article-buffer)
8530 (nnheader-narrow-to-headers)
8532 (goto-char (point-min))
8533 (setq method (pop methods))
8534 (setq match (car method))
8537 ;; Regular expression.
8539 (re-search-forward match nil t)))
8540 ((gnus-functionp match)
8544 (setq result (funcall match gnus-newsgroup-name))))
8549 (setq result (eval match)))))
8550 (setq split-name (append (cdr method) split-name))
8551 (cond ((stringp result)
8552 (push (expand-file-name
8553 result gnus-article-save-directory)
8556 (setq split-name (append result split-name)))))))))
8559 (defun gnus-valid-move-group-p (group)
8564 (car (gnus-find-method-for-group
8565 (symbol-name group))))
8566 gnus-valid-select-methods))))
8568 (defun gnus-read-move-group-name (prompt default articles prefix)
8569 "Read a group name."
8570 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8571 (minibuffer-confirm-incomplete nil) ; XEmacs
8575 (if (> (length articles) 1)
8576 (format "these %d articles" (length articles))
8581 (gnus-completing-read default prom
8583 'gnus-valid-move-group-p
8585 'gnus-group-history))
8586 ((= 1 (length split-name))
8587 (gnus-completing-read (car split-name) prom
8589 'gnus-valid-move-group-p
8591 'gnus-group-history))
8593 (gnus-completing-read nil prom
8594 (mapcar (lambda (el) (list el))
8595 (nreverse split-name))
8597 'gnus-group-history)))))
8599 (if (or (string= to-newsgroup "")
8600 (string= to-newsgroup prefix))
8601 (setq to-newsgroup default))
8602 (unless to-newsgroup
8603 (error "No group name entered"))
8604 (or (gnus-active to-newsgroup)
8605 (gnus-activate-group to-newsgroup)
8606 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8608 (or (and (gnus-request-create-group
8609 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8610 (gnus-activate-group to-newsgroup nil nil
8611 (gnus-group-name-to-method
8613 (error "Couldn't create group %s" to-newsgroup)))
8614 (error "No such group: %s" to-newsgroup)))
8617 ;; Summary extract commands
8619 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8620 (let ((buffer-read-only nil)
8621 (article (gnus-summary-article-number))
8623 (unless (gnus-summary-goto-subject article)
8624 (error "No such article: %d" article))
8625 (gnus-summary-position-point)
8626 ;; If all commands are to be bunched up on one line, we collect
8628 (unless gnus-view-pseudos-separately
8629 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8632 (setq action (cdr (assq 'action (car ps))))
8633 (setq files (list (cdr (assq 'name (car ps)))))
8634 (while (and ps (cdr ps)
8635 (string= (or action "1")
8636 (or (cdr (assq 'action (cadr ps))) "2")))
8637 (push (cdr (assq 'name (cadr ps))) files)
8638 (setcdr ps (cddr ps)))
8640 (when (not (string-match "%s" action))
8643 (when (assq 'execute (car ps))
8644 (setcdr (assq 'execute (car ps))
8645 (funcall (if (string-match "%s" action)
8652 (gnus-quote-arg-for-sh-or-csh f)))
8654 (setq ps (cdr ps)))))
8655 (if (and gnus-view-pseudos (not not-view))
8657 (when (assq 'execute (car pslist))
8658 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8659 (eq gnus-view-pseudos 'not-confirm)))
8660 (setq pslist (cdr pslist)))
8663 (setq after-article (or (cdr (assq 'article (car pslist)))
8664 (gnus-summary-article-number)))
8665 (gnus-summary-goto-subject after-article)
8668 (insert " " (file-name-nondirectory
8669 (cdr (assq 'name (car pslist))))
8670 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8672 (forward-line -1) ; back to `b'
8673 (gnus-add-text-properties
8674 b (1- e) (list 'gnus-number gnus-reffed-article-number
8675 gnus-mouse-face-prop gnus-mouse-face))
8677 after-article gnus-reffed-article-number
8678 gnus-unread-mark b (car pslist) 0 (- e b))
8679 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8680 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8681 (setq pslist (cdr pslist)))))))
8683 (defun gnus-pseudos< (p1 p2)
8684 (let ((c1 (cdr (assq 'action p1)))
8685 (c2 (cdr (assq 'action p2))))
8686 (and c1 c2 (string< c1 c2))))
8688 (defun gnus-request-pseudo-article (props)
8689 (cond ((assq 'execute props)
8690 (gnus-execute-command (cdr (assq 'execute props)))))
8691 (let ((gnus-current-article (gnus-summary-article-number)))
8692 (run-hooks 'gnus-mark-article-hook)))
8694 (defun gnus-execute-command (command &optional automatic)
8696 (gnus-article-setup-buffer)
8697 (set-buffer gnus-article-buffer)
8698 (setq buffer-read-only nil)
8699 (let ((command (if automatic command
8700 (read-string "Command: " (cons command 0)))))
8702 (insert "$ " command "\n\n")
8703 (if gnus-view-pseudo-asynchronously
8704 (start-process "gnus-execute" (current-buffer) shell-file-name
8705 shell-command-switch command)
8706 (call-process shell-file-name nil t nil
8707 shell-command-switch command)))))
8709 ;; Summary kill commands.
8711 (defun gnus-summary-edit-global-kill (article)
8712 "Edit the \"global\" kill file."
8713 (interactive (gnus-summary-article-number))
8714 (gnus-set-global-variables)
8715 (gnus-group-edit-global-kill article))
8717 (defun gnus-summary-edit-local-kill ()
8718 "Edit a local kill file applied to the current newsgroup."
8720 (gnus-set-global-variables)
8721 (setq gnus-current-headers (gnus-summary-article-header))
8722 (gnus-set-global-variables)
8723 (gnus-group-edit-local-kill
8724 (gnus-summary-article-number) gnus-newsgroup-name))
8728 (defun gnus-read-header (id &optional header)
8729 "Read the headers of article ID and enter them into the Gnus system."
8730 (let ((group gnus-newsgroup-name)
8731 (gnus-override-method
8732 (and (gnus-news-group-p gnus-newsgroup-name)
8733 gnus-refer-article-method))
8735 ;; First we check to see whether the header in question is already
8738 ;; This is a Message-ID.
8739 (setq header (or header (gnus-id-to-header id)))
8740 ;; This is an article number.
8741 (setq header (or header (gnus-summary-article-header id))))
8743 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8744 ;; We have found the header.
8746 ;; We have to really fetch the header to this article.
8748 (set-buffer nntp-server-buffer)
8749 (when (setq where (gnus-request-head id group))
8750 (nnheader-fold-continuation-lines)
8751 (goto-char (point-max))
8753 (goto-char (point-min))
8757 ((cdr where) (cdr where))
8758 (header (mail-header-number header))
8759 (t gnus-reffed-article-number))
8761 (insert " Article retrieved.\n"))
8763 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8764 () ; Malformed head.
8765 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8766 (when (and (stringp id)
8767 (not (string= (gnus-group-real-name group)
8769 ;; If we fetched by Message-ID and the article came
8770 ;; from a different group, we fudge some bogus article
8771 ;; numbers for this article.
8772 (mail-header-set-number header gnus-reffed-article-number))
8774 (set-buffer gnus-summary-buffer)
8775 (decf gnus-reffed-article-number)
8776 (gnus-remove-header (mail-header-number header))
8777 (push header gnus-newsgroup-headers)
8778 (setq gnus-current-headers header)
8779 (push (mail-header-number header) gnus-newsgroup-limit)))
8782 (defun gnus-remove-header (number)
8783 "Remove header NUMBER from `gnus-newsgroup-headers'."
8784 (if (and gnus-newsgroup-headers
8785 (= number (mail-header-number (car gnus-newsgroup-headers))))
8786 (pop gnus-newsgroup-headers)
8787 (let ((headers gnus-newsgroup-headers))
8788 (while (and (cdr headers)
8789 (not (= number (mail-header-number (cadr headers)))))
8792 (setcdr headers (cddr headers))))))
8795 ;;; summary highlights
8798 (defun gnus-highlight-selected-summary ()
8799 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8800 ;; Highlight selected article in summary buffer
8801 (when gnus-summary-selected-face
8803 (let* ((beg (progn (beginning-of-line) (point)))
8804 (end (progn (end-of-line) (point)))
8805 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8806 (from (if (get-text-property beg gnus-mouse-face-prop)
8808 (or (next-single-property-change
8809 beg gnus-mouse-face-prop nil end)
8814 (or (next-single-property-change
8815 from gnus-mouse-face-prop nil end)
8817 ;; If no mouse-face prop on line we will have to = from = end,
8818 ;; so we highlight the entire line instead.
8819 (when (= (+ to 2) from)
8822 (if gnus-newsgroup-selected-overlay
8823 ;; Move old overlay.
8825 gnus-newsgroup-selected-overlay from to (current-buffer))
8826 ;; Create new overlay.
8828 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8829 'face gnus-summary-selected-face))))))
8831 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8832 (defun gnus-summary-highlight-line ()
8833 "Highlight current line according to `gnus-summary-highlight'."
8834 (let* ((list gnus-summary-highlight)
8836 (end (progn (end-of-line) (point)))
8837 ;; now find out where the line starts and leave point there.
8838 (beg (progn (beginning-of-line) (point)))
8839 (article (gnus-summary-article-number))
8840 (score (or (cdr (assq (or article gnus-current-article)
8841 gnus-newsgroup-scored))
8842 gnus-summary-default-score 0))
8843 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8844 (inhibit-read-only t))
8845 ;; Eval the cars of the lists until we find a match.
8846 (let ((default gnus-summary-default-score))
8848 (not (eval (caar list))))
8849 (setq list (cdr list))))
8850 (let ((face (cdar list)))
8851 (unless (eq face (get-text-property beg 'face))
8852 (gnus-put-text-property
8854 (setq face (if (boundp face) (symbol-value face) face)))
8855 (when gnus-summary-highlight-line-function
8856 (funcall gnus-summary-highlight-line-function article face))))
8859 (defun gnus-update-read-articles (group unread &optional compute)
8860 "Update the list of read articles in GROUP."
8861 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8862 (entry (gnus-gethash group gnus-newsrc-hashtb))
8863 (info (nth 2 entry))
8865 (unread (sort (copy-sequence unread) '<))
8867 (if (or (not info) (not active))
8868 ;; There is no info on this group if it was, in fact,
8869 ;; killed. Gnus stores no information on killed groups, so
8870 ;; there's nothing to be done.
8871 ;; One could store the information somewhere temporarily,
8872 ;; perhaps... Hmmm...
8874 ;; Remove any negative articles numbers.
8875 (while (and unread (< (car unread) 0))
8876 (setq unread (cdr unread)))
8877 ;; Remove any expired article numbers
8878 (while (and unread (< (car unread) (car active)))
8879 (setq unread (cdr unread)))
8880 ;; Compute the ranges of read articles by looking at the list of
8883 (when (/= (car unread) prev)
8884 (push (if (= prev (1- (car unread))) prev
8885 (cons prev (1- (car unread))))
8887 (setq prev (1+ (car unread)))
8888 (setq unread (cdr unread)))
8889 (when (<= prev (cdr active))
8890 (push (cons prev (cdr active)) read))
8892 (if (> (length read) 1) (nreverse read) read)
8894 (set-buffer gnus-group-buffer)
8897 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8898 (gnus-info-set-read ',info ',(gnus-info-read info))
8899 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8900 (gnus-group-update-group ,group t))))
8901 ;; Enter this list into the group info.
8903 info (if (> (length read) 1) (nreverse read) read))
8904 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8905 (gnus-get-unread-articles-in-group info (gnus-active group))
8908 (defun gnus-offer-save-summaries ()
8909 "Offer to save all active summary buffers."
8911 (let ((buflist (buffer-list))
8913 ;; Go through all buffers and find all summaries.
8915 (and (setq bufname (buffer-name (car buflist)))
8916 (string-match "Summary" bufname)
8918 (set-buffer bufname)
8919 ;; We check that this is, indeed, a summary buffer.
8920 (and (eq major-mode 'gnus-summary-mode)
8921 ;; Also make sure this isn't bogus.
8922 gnus-newsgroup-prepared
8923 ;; Also make sure that this isn't a dead summary buffer.
8924 (not gnus-dead-summary-mode)))
8925 (push bufname buffers))
8926 (setq buflist (cdr buflist)))
8927 ;; Go through all these summary buffers and offer to save them.
8930 "Update summary buffer %s? "
8931 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8938 (run-hooks 'gnus-sum-load-hook)
8940 ;;; gnus-sum.el ends here