1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
37 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
39 (defcustom gnus-kill-summary-on-exit t
40 "*If non-nil, kill the summary buffer when you exit from it.
41 If nil, the summary will become a \"*Dead Summary*\" buffer, and
42 it will be killed sometime later."
43 :group 'gnus-summary-exit
46 (defcustom gnus-fetch-old-headers nil
47 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
48 If an unread article in the group refers to an older, already read (or
49 just marked as read) article, the old article will not normally be
50 displayed in the Summary buffer. If this variable is non-nil, Gnus
51 will attempt to grab the headers to the old articles, and thereby
52 build complete threads. If it has the value `some', only enough
53 headers to connect otherwise loose threads will be displayed. This
54 variable can also be a number. In that case, no more than that number
55 of old headers will be fetched. If it has the value `invisible', all
56 old headers will be fetched, but none will be displayed.
58 The server has to support NOV for any of this to work."
60 :type '(choice (const :tag "off" nil)
63 (sexp :menu-tag "other" t)))
65 (defcustom gnus-refer-thread-limit 200
66 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
67 If t, fetch all the available old headers."
70 (sexp :menu-tag "other" t)))
72 (defcustom gnus-summary-make-false-root 'adopt
73 "*nil means that Gnus won't gather loose threads.
74 If the root of a thread has expired or been read in a previous
75 session, the information necessary to build a complete thread has been
76 lost. Instead of having many small sub-threads from this original thread
77 scattered all over the summary buffer, Gnus can gather them.
79 If non-nil, Gnus will try to gather all loose sub-threads from an
80 original thread into one large thread.
82 If this variable is non-nil, it should be one of `none', `adopt',
85 If this variable is `none', Gnus will not make a false root, but just
86 present the sub-threads after another.
87 If this variable is `dummy', Gnus will create a dummy root that will
88 have all the sub-threads as children.
89 If this variable is `adopt', Gnus will make one of the \"children\"
90 the parent and mark all the step-children as such.
91 If this variable is `empty', the \"children\" are printed with empty
92 subject fields. (Or rather, they will be printed with a string
93 given by the `gnus-summary-same-subject' variable.)"
95 :type '(choice (const :tag "off" nil)
101 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
102 "*A regexp to match subjects to be excluded from loose thread gathering.
103 As loose thread gathering is done on subjects only, that means that
104 there can be many false gatherings performed. By rooting out certain
105 common subjects, gathering might become saner."
109 (defcustom gnus-summary-gather-subject-limit nil
110 "*Maximum length of subject comparisons when gathering loose threads.
111 Use nil to compare full subjects. Setting this variable to a low
112 number will help gather threads that have been corrupted by
113 newsreaders chopping off subject lines, but it might also mean that
114 unrelated articles that have subject that happen to begin with the
115 same few characters will be incorrectly gathered.
117 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
120 :type '(choice (const :tag "off" nil)
122 (sexp :menu-tag "on" t)))
124 (defcustom gnus-simplify-subject-functions nil
125 "List of functions taking a string argument that simplify subjects.
126 The functions are applied recursively.
128 Useful functions to put in this list include: `gnus-simplify-subject-re',
129 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
131 :type '(repeat function))
133 (defcustom gnus-simplify-ignored-prefixes nil
134 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
136 :type '(choice (const :tag "off" nil)
139 (defcustom gnus-build-sparse-threads nil
140 "*If non-nil, fill in the gaps in threads.
141 If `some', only fill in the gaps that are needed to tie loose threads
142 together. If `more', fill in all leaf nodes that Gnus can find. If
143 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
145 :type '(choice (const :tag "off" nil)
148 (sexp :menu-tag "all" t)))
150 (defcustom gnus-summary-thread-gathering-function
151 'gnus-gather-threads-by-subject
152 "*Function used for gathering loose threads.
153 There are two pre-defined functions: `gnus-gather-threads-by-subject',
154 which only takes Subjects into consideration; and
155 `gnus-gather-threads-by-references', which compared the References
156 headers of the articles to find matches."
158 :type '(radio (function-item gnus-gather-threads-by-subject)
159 (function-item gnus-gather-threads-by-references)
160 (function :tag "other")))
162 (defcustom gnus-summary-same-subject ""
163 "*String indicating that the current article has the same subject as the previous.
164 This variable will only be used if the value of
165 `gnus-summary-make-false-root' is `empty'."
166 :group 'gnus-summary-format
169 (defcustom gnus-summary-goto-unread t
170 "*If t, marking commands will go to the next unread article.
171 If `never', commands that usually go to the next unread article, will
172 go to the next article, whether it is read or not.
173 If nil, only the marking commands will go to the next (un)read article."
174 :group 'gnus-summary-marks
175 :link '(custom-manual "(gnus)Setting Marks")
176 :type '(choice (const :tag "off" nil)
178 (sexp :menu-tag "on" t)))
180 (defcustom gnus-summary-default-score 0
181 "*Default article score level.
182 All scores generated by the score files will be added to this score.
183 If this variable is nil, scoring will be disabled."
184 :group 'gnus-score-default
185 :type '(choice (const :tag "disable")
188 (defcustom gnus-summary-zcore-fuzz 0
189 "*Fuzziness factor for the zcore in the summary buffer.
190 Articles with scores closer than this to `gnus-summary-default-score'
192 :group 'gnus-summary-format
195 (defcustom gnus-simplify-subject-fuzzy-regexp nil
196 "*Strings to be removed when doing fuzzy matches.
197 This can either be a regular expression or list of regular expressions
198 that will be removed from subject strings if fuzzy subject
199 simplification is selected."
201 :type '(repeat regexp))
203 (defcustom gnus-show-threads t
204 "*If non-nil, display threads in summary mode."
208 (defcustom gnus-thread-hide-subtree nil
209 "*If non-nil, hide all threads initially.
210 If threads are hidden, you have to run the command
211 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
212 to expose hidden threads."
216 (defcustom gnus-thread-hide-killed t
217 "*If non-nil, hide killed threads automatically."
221 (defcustom gnus-thread-ignore-subject t
222 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
223 If nil, articles that have different subjects from their parents will
224 start separate threads."
228 (defcustom gnus-thread-operation-ignore-subject t
229 "*If non-nil, subjects will be ignored when doing thread commands.
230 This affects commands like `gnus-summary-kill-thread' and
231 `gnus-summary-lower-thread'.
233 If this variable is nil, articles in the same thread with different
234 subjects will not be included in the operation in question. If this
235 variable is `fuzzy', only articles that have subjects that are fuzzily
236 equal will be included."
238 :type '(choice (const :tag "off" nil)
242 (defcustom gnus-thread-indent-level 4
243 "*Number that says how much each sub-thread should be indented."
247 (defcustom gnus-auto-extend-newsgroup t
248 "*If non-nil, extend newsgroup forward and backward when requested."
249 :group 'gnus-summary-choose
252 (defcustom gnus-auto-select-first t
253 "*If nil, don't select the first unread article when entering a group.
254 If this variable is `best', select the highest-scored unread article
255 in the group. If neither nil nor `best', select the first unread
258 If you want to prevent automatic selection of the first unread article
259 in some newsgroups, set the variable to nil in
260 `gnus-select-group-hook'."
261 :group 'gnus-group-select
262 :type '(choice (const :tag "none" nil)
264 (sexp :menu-tag "first" t)))
266 (defcustom gnus-auto-select-next t
267 "*If non-nil, offer to go to the next group from the end of the previous.
268 If the value is t and the next newsgroup is empty, Gnus will exit
269 summary mode and go back to group mode. If the value is neither nil
270 nor t, Gnus will select the following unread newsgroup. In
271 particular, if the value is the symbol `quietly', the next unread
272 newsgroup will be selected without any confirmation, and if it is
273 `almost-quietly', the next group will be selected without any
274 confirmation if you are located on the last article in the group.
275 Finally, if this variable is `slightly-quietly', the `Z n' command
276 will go to the next group without confirmation."
277 :group 'gnus-summary-maneuvering
278 :type '(choice (const :tag "off" nil)
280 (const almost-quietly)
281 (const slightly-quietly)
282 (sexp :menu-tag "on" t)))
284 (defcustom gnus-auto-select-same nil
285 "*If non-nil, select the next article with the same subject.
286 If there are no more articles with the same subject, go to
287 the first unread article."
288 :group 'gnus-summary-maneuvering
291 (defcustom gnus-summary-check-current nil
292 "*If non-nil, consider the current article when moving.
293 The \"unread\" movement commands will stay on the same line if the
294 current article is unread."
295 :group 'gnus-summary-maneuvering
298 (defcustom gnus-auto-center-summary t
299 "*If non-nil, always center the current summary buffer.
300 In particular, if `vertical' do only vertical recentering. If non-nil
301 and non-`vertical', do both horizontal and vertical recentering."
302 :group 'gnus-summary-maneuvering
303 :type '(choice (const :tag "none" nil)
305 (sexp :menu-tag "both" t)))
307 (defcustom gnus-show-all-headers nil
308 "*If non-nil, don't hide any headers."
309 :group 'gnus-article-hiding
310 :group 'gnus-article-headers
313 (defcustom gnus-summary-ignore-duplicates nil
314 "*If non-nil, ignore articles with identical Message-ID headers."
318 (defcustom gnus-single-article-buffer t
319 "*If non-nil, display all articles in the same buffer.
320 If nil, each group will get its own article buffer."
321 :group 'gnus-article-various
324 (defcustom gnus-break-pages t
325 "*If non-nil, do page breaking on articles.
326 The page delimiter is specified by the `gnus-page-delimiter'
328 :group 'gnus-article-various
331 (defcustom gnus-move-split-methods nil
332 "*Variable used to suggest where articles are to be moved to.
333 It uses the same syntax as the `gnus-split-methods' variable."
334 :group 'gnus-summary-mail
335 :type '(repeat (choice (list :value (fun) function)
336 (cons :value ("" "") regexp (repeat string))
339 (defcustom gnus-unread-mark ?
340 "*Mark used for unread articles."
341 :group 'gnus-summary-marks
344 (defcustom gnus-ticked-mark ?!
345 "*Mark used for ticked articles."
346 :group 'gnus-summary-marks
349 (defcustom gnus-dormant-mark ??
350 "*Mark used for dormant articles."
351 :group 'gnus-summary-marks
354 (defcustom gnus-del-mark ?r
355 "*Mark used for del'd articles."
356 :group 'gnus-summary-marks
359 (defcustom gnus-read-mark ?R
360 "*Mark used for read articles."
361 :group 'gnus-summary-marks
364 (defcustom gnus-expirable-mark ?E
365 "*Mark used for expirable articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-killed-mark ?K
370 "*Mark used for killed articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-souped-mark ?F
375 "*Mark used for killed articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-kill-file-mark ?X
380 "*Mark used for articles killed by kill files."
381 :group 'gnus-summary-marks
384 (defcustom gnus-low-score-mark ?Y
385 "*Mark used for articles with a low score."
386 :group 'gnus-summary-marks
389 (defcustom gnus-catchup-mark ?C
390 "*Mark used for articles that are caught up."
391 :group 'gnus-summary-marks
394 (defcustom gnus-replied-mark ?A
395 "*Mark used for articles that have been replied to."
396 :group 'gnus-summary-marks
399 (defcustom gnus-cached-mark ?*
400 "*Mark used for articles that are in the cache."
401 :group 'gnus-summary-marks
404 (defcustom gnus-saved-mark ?S
405 "*Mark used for articles that have been saved to."
406 :group 'gnus-summary-marks
409 (defcustom gnus-ancient-mark ?O
410 "*Mark used for ancient articles."
411 :group 'gnus-summary-marks
414 (defcustom gnus-sparse-mark ?Q
415 "*Mark used for sparsely reffed articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-canceled-mark ?G
420 "*Mark used for canceled articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-duplicate-mark ?M
425 "*Mark used for duplicate articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-undownloaded-mark ?@
430 "*Mark used for articles that weren't downloaded."
431 :group 'gnus-summary-marks
434 (defcustom gnus-downloadable-mark ?%
435 "*Mark used for articles that are to be downloaded."
436 :group 'gnus-summary-marks
439 (defcustom gnus-unsendable-mark ?=
440 "*Mark used for articles that won't be sent."
441 :group 'gnus-summary-marks
444 (defcustom gnus-score-over-mark ?+
445 "*Score mark used for articles with high scores."
446 :group 'gnus-summary-marks
449 (defcustom gnus-score-below-mark ?-
450 "*Score mark used for articles with low scores."
451 :group 'gnus-summary-marks
454 (defcustom gnus-empty-thread-mark ?
455 "*There is no thread under the article."
456 :group 'gnus-summary-marks
459 (defcustom gnus-not-empty-thread-mark ?=
460 "*There is a thread under the article."
461 :group 'gnus-summary-marks
464 (defcustom gnus-view-pseudo-asynchronously nil
465 "*If non-nil, Gnus will view pseudo-articles asynchronously."
466 :group 'gnus-extract-view
469 (defcustom gnus-view-pseudos nil
470 "*If `automatic', pseudo-articles will be viewed automatically.
471 If `not-confirm', pseudos will be viewed automatically, and the user
472 will not be asked to confirm the command."
473 :group 'gnus-extract-view
474 :type '(choice (const :tag "off" nil)
476 (const not-confirm)))
478 (defcustom gnus-view-pseudos-separately t
479 "*If non-nil, one pseudo-article will be created for each file to be viewed.
480 If nil, all files that use the same viewing command will be given as a
481 list of parameters to that command."
482 :group 'gnus-extract-view
485 (defcustom gnus-insert-pseudo-articles t
486 "*If non-nil, insert pseudo-articles when decoding articles."
487 :group 'gnus-extract-view
490 (defcustom gnus-summary-dummy-line-format
492 "*The format specification for the dummy roots in the summary buffer.
493 It works along the same lines as a normal formatting string,
494 with some simple extensions.
497 :group 'gnus-threading
500 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
501 "*The format specification for the summary mode line.
502 It works along the same lines as a normal formatting string,
503 with some simple extensions:
506 %p Unprefixed group name
507 %A Current article number
508 %z Current article score
510 %U Number of unread articles in the group
511 %e Number of unselected articles in the group
512 %Z A string with unread/unselected article counts
513 %g Shortish group name
514 %S Subject of the current article
516 %s Current score file name
517 %d Number of dormant articles
518 %r Number of articles that have been marked as read in this session
519 %E Number of articles expunged by the score files"
520 :group 'gnus-summary-format
523 (defcustom gnus-summary-mark-below 0
524 "*Mark all articles with a score below this variable as read.
525 This variable is local to each summary buffer and usually set by the
527 :group 'gnus-score-default
530 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
531 "*List of functions used for sorting articles in the summary buffer.
532 This variable is only used when not using a threaded display."
533 :group 'gnus-summary-sort
534 :type '(repeat (choice (function-item gnus-article-sort-by-number)
535 (function-item gnus-article-sort-by-author)
536 (function-item gnus-article-sort-by-subject)
537 (function-item gnus-article-sort-by-date)
538 (function-item gnus-article-sort-by-score)
539 (function :tag "other"))))
541 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
542 "*List of functions used for sorting threads in the summary buffer.
543 By default, threads are sorted by article number.
545 Each function takes two threads and return non-nil if the first thread
546 should be sorted before the other. If you use more than one function,
547 the primary sort function should be the last. You should probably
548 always include `gnus-thread-sort-by-number' in the list of sorting
549 functions -- preferably first.
551 Ready-made functions include `gnus-thread-sort-by-number',
552 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
553 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
554 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
555 :group 'gnus-summary-sort
556 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
557 (function-item gnus-thread-sort-by-author)
558 (function-item gnus-thread-sort-by-subject)
559 (function-item gnus-thread-sort-by-date)
560 (function-item gnus-thread-sort-by-score)
561 (function-item gnus-thread-sort-by-total-score)
562 (function :tag "other"))))
564 (defcustom gnus-thread-score-function '+
565 "*Function used for calculating the total score of a thread.
567 The function is called with the scores of the article and each
568 subthread and should then return the score of the thread.
570 Some functions you can use are `+', `max', or `min'."
571 :group 'gnus-summary-sort
574 (defcustom gnus-summary-expunge-below nil
575 "All articles that have a score less than this variable will be expunged.
576 This variable is local to the summary buffers."
577 :group 'gnus-score-default
578 :type '(choice (const :tag "off" nil)
581 (defcustom gnus-thread-expunge-below nil
582 "All threads that have a total score less than this variable will be expunged.
583 See `gnus-thread-score-function' for en explanation of what a
586 This variable is local to the summary buffers."
587 :group 'gnus-treading
588 :group 'gnus-score-default
589 :type '(choice (const :tag "off" nil)
592 (defcustom gnus-summary-mode-hook nil
593 "*A hook for Gnus summary mode.
594 This hook is run before any variables are set in the summary buffer."
595 :group 'gnus-summary-various
598 (defcustom gnus-summary-menu-hook nil
599 "*Hook run after the creation of the summary mode menu."
600 :group 'gnus-summary-visual
603 (defcustom gnus-summary-exit-hook nil
604 "*A hook called on exit from the summary buffer.
605 It will be called with point in the group buffer."
606 :group 'gnus-summary-exit
609 (defcustom gnus-summary-prepare-hook nil
610 "*A hook called after the summary buffer has been generated.
611 If you want to modify the summary buffer, you can use this hook."
612 :group 'gnus-summary-various
615 (defcustom gnus-summary-prepared-hook nil
616 "*A hook called as the last thing after the summary buffer has been generated."
617 :group 'gnus-summary-various
620 (defcustom gnus-summary-generate-hook nil
621 "*A hook run just before generating the summary buffer.
622 This hook is commonly used to customize threading variables and the
624 :group 'gnus-summary-various
627 (defcustom gnus-select-group-hook nil
628 "*A hook called when a newsgroup is selected.
630 If you'd like to simplify subjects like the
631 `gnus-summary-next-same-subject' command does, you can use the
634 (setq gnus-select-group-hook
637 (mapcar (lambda (header)
638 (mail-header-set-subject
640 (gnus-simplify-subject
641 (mail-header-subject header) 're-only)))
642 gnus-newsgroup-headers))))"
643 :group 'gnus-group-select
646 (defcustom gnus-select-article-hook nil
647 "*A hook called when an article is selected."
648 :group 'gnus-summary-choose
651 (defcustom gnus-visual-mark-article-hook
652 (list 'gnus-highlight-selected-summary)
653 "*Hook run after selecting an article in the summary buffer.
654 It is meant to be used for highlighting the article in some way. It
655 is not run if `gnus-visual' is nil."
656 :group 'gnus-summary-visual
659 (defcustom gnus-parse-headers-hook nil
660 "*A hook called before parsing the headers."
664 (defcustom gnus-exit-group-hook nil
665 "*A hook called when exiting (not quitting) summary mode."
669 (defcustom gnus-summary-update-hook
670 (list 'gnus-summary-highlight-line)
671 "*A hook called when a summary line is changed.
672 The hook will not be called if `gnus-visual' is nil.
674 The default function `gnus-summary-highlight-line' will
675 highlight the line according to the `gnus-summary-highlight'
677 :group 'gnus-summary-visual
680 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
681 "*A hook called when an article is selected for the first time.
682 The hook is intended to mark an article as read (or unread)
683 automatically when it is selected."
684 :group 'gnus-summary-choose
687 (defcustom gnus-group-no-more-groups-hook nil
688 "*A hook run when returning to group mode having no more (unread) groups."
689 :group 'gnus-group-select
692 (defcustom gnus-ps-print-hook nil
693 "*A hook run before ps-printing something from Gnus."
697 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
698 "Face used for highlighting the current article in the summary buffer."
699 :group 'gnus-summary-visual
702 (defcustom gnus-summary-highlight
703 '(((= mark gnus-canceled-mark)
704 . gnus-summary-cancelled-face)
705 ((and (> score default)
706 (or (= mark gnus-dormant-mark)
707 (= mark gnus-ticked-mark)))
708 . gnus-summary-high-ticked-face)
709 ((and (< score default)
710 (or (= mark gnus-dormant-mark)
711 (= mark gnus-ticked-mark)))
712 . gnus-summary-low-ticked-face)
713 ((or (= mark gnus-dormant-mark)
714 (= mark gnus-ticked-mark))
715 . gnus-summary-normal-ticked-face)
716 ((and (> score default) (= mark gnus-ancient-mark))
717 . gnus-summary-high-ancient-face)
718 ((and (< score default) (= mark gnus-ancient-mark))
719 . gnus-summary-low-ancient-face)
720 ((= mark gnus-ancient-mark)
721 . gnus-summary-normal-ancient-face)
722 ((and (> score default) (= mark gnus-unread-mark))
723 . gnus-summary-high-unread-face)
724 ((and (< score default) (= mark gnus-unread-mark))
725 . gnus-summary-low-unread-face)
726 ((= mark gnus-unread-mark)
727 . gnus-summary-normal-unread-face)
728 ((and (> score default) (memq mark (list gnus-downloadable-mark
729 gnus-undownloaded-mark)))
730 . gnus-summary-high-unread-face)
731 ((and (< score default) (memq mark (list gnus-downloadable-mark
732 gnus-undownloaded-mark)))
733 . gnus-summary-low-unread-face)
734 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
735 . gnus-summary-normal-unread-face)
737 . gnus-summary-high-read-face)
739 . gnus-summary-low-read-face)
741 . gnus-summary-normal-read-face))
742 "*Controls the highlighting of summary buffer lines.
744 A list of (FORM . FACE) pairs. When deciding how a a particular
745 summary line should be displayed, each form is evaluated. The content
746 of the face field after the first true form is used. You can change
747 how those summary lines are displayed, by editing the face field.
749 You can use the following variables in the FORM field.
751 score: The articles score
752 default: The default article score.
753 below: The score below which articles are automatically marked as read.
754 mark: The articles mark."
755 :group 'gnus-summary-visual
756 :type '(repeat (cons (sexp :tag "Form" nil)
759 (defcustom gnus-alter-header-function nil
760 "Function called to allow alteration of article header structures.
761 The function is called with one parameter, the article header vector,
762 which it may alter in any way.")
764 ;;; Internal variables
766 (defvar gnus-scores-exclude-files nil)
767 (defvar gnus-page-broken nil)
769 (defvar gnus-original-article nil)
770 (defvar gnus-article-internal-prepare-hook nil)
771 (defvar gnus-newsgroup-process-stack nil)
773 (defvar gnus-thread-indent-array nil)
774 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
776 ;; Avoid highlighting in kill files.
777 (defvar gnus-summary-inhibit-highlight nil)
778 (defvar gnus-newsgroup-selected-overlay nil)
779 (defvar gnus-inhibit-limiting nil)
780 (defvar gnus-newsgroup-adaptive-score-file nil)
781 (defvar gnus-current-score-file nil)
782 (defvar gnus-current-move-group nil)
783 (defvar gnus-current-copy-group nil)
784 (defvar gnus-current-crosspost-group nil)
786 (defvar gnus-newsgroup-dependencies nil)
787 (defvar gnus-newsgroup-adaptive nil)
788 (defvar gnus-summary-display-article-function nil)
789 (defvar gnus-summary-highlight-line-function nil
790 "Function called after highlighting a summary line.")
792 (defvar gnus-summary-line-format-alist
793 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
794 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
795 (?s gnus-tmp-subject-or-nil ?s)
796 (?n gnus-tmp-name ?s)
797 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
799 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
801 (?F gnus-tmp-from ?s)
802 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
803 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
804 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
805 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
806 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
807 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
808 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
809 (?L gnus-tmp-lines ?d)
810 (?I gnus-tmp-indentation ?s)
811 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
812 (?R gnus-tmp-replied ?c)
813 (?\[ gnus-tmp-opening-bracket ?c)
814 (?\] gnus-tmp-closing-bracket ?c)
815 (?\> (make-string gnus-tmp-level ? ) ?s)
816 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
817 (?i gnus-tmp-score ?d)
818 (?z gnus-tmp-score-char ?c)
819 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
820 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
821 (?U gnus-tmp-unread ?c)
822 (?t (gnus-summary-number-of-articles-in-thread
823 (and (boundp 'thread) (car thread)) gnus-tmp-level)
825 (?e (gnus-summary-number-of-articles-in-thread
826 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
828 (?u gnus-tmp-user-defined ?s)
829 (?P (gnus-pick-line-number) ?d))
830 "An alist of format specifications that can appear in summary lines,
831 and what variables they correspond with, along with the type of the
832 variable (string, integer, character, etc).")
834 (defvar gnus-summary-dummy-line-format-alist
835 `((?S gnus-tmp-subject ?s)
836 (?N gnus-tmp-number ?d)
837 (?u gnus-tmp-user-defined ?s)))
839 (defvar gnus-summary-mode-line-format-alist
840 `((?G gnus-tmp-group-name ?s)
841 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
842 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
843 (?A gnus-tmp-article-number ?d)
844 (?Z gnus-tmp-unread-and-unselected ?s)
846 (?U gnus-tmp-unread-and-unticked ?d)
847 (?S gnus-tmp-subject ?s)
848 (?e gnus-tmp-unselected ?d)
849 (?u gnus-tmp-user-defined ?s)
850 (?d (length gnus-newsgroup-dormant) ?d)
851 (?t (length gnus-newsgroup-marked) ?d)
852 (?r (length gnus-newsgroup-reads) ?d)
853 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
854 (?E gnus-newsgroup-expunged-tally ?d)
855 (?s (gnus-current-score-file-nondirectory) ?s)))
857 (defvar gnus-last-search-regexp nil
858 "Default regexp for article search command.")
860 (defvar gnus-last-shell-command nil
861 "Default shell command on article.")
863 (defvar gnus-newsgroup-begin nil)
864 (defvar gnus-newsgroup-end nil)
865 (defvar gnus-newsgroup-last-rmail nil)
866 (defvar gnus-newsgroup-last-mail nil)
867 (defvar gnus-newsgroup-last-folder nil)
868 (defvar gnus-newsgroup-last-file nil)
869 (defvar gnus-newsgroup-auto-expire nil)
870 (defvar gnus-newsgroup-active nil)
872 (defvar gnus-newsgroup-data nil)
873 (defvar gnus-newsgroup-data-reverse nil)
874 (defvar gnus-newsgroup-limit nil)
875 (defvar gnus-newsgroup-limits nil)
877 (defvar gnus-newsgroup-unreads nil
878 "List of unread articles in the current newsgroup.")
880 (defvar gnus-newsgroup-unselected nil
881 "List of unselected unread articles in the current newsgroup.")
883 (defvar gnus-newsgroup-reads nil
884 "Alist of read articles and article marks in the current newsgroup.")
886 (defvar gnus-newsgroup-expunged-tally nil)
888 (defvar gnus-newsgroup-marked nil
889 "List of ticked articles in the current newsgroup (a subset of unread art).")
891 (defvar gnus-newsgroup-killed nil
892 "List of ranges of articles that have been through the scoring process.")
894 (defvar gnus-newsgroup-cached nil
895 "List of articles that come from the article cache.")
897 (defvar gnus-newsgroup-saved nil
898 "List of articles that have been saved.")
900 (defvar gnus-newsgroup-kill-headers nil)
902 (defvar gnus-newsgroup-replied nil
903 "List of articles that have been replied to in the current newsgroup.")
905 (defvar gnus-newsgroup-expirable nil
906 "List of articles in the current newsgroup that can be expired.")
908 (defvar gnus-newsgroup-processable nil
909 "List of articles in the current newsgroup that can be processed.")
911 (defvar gnus-newsgroup-downloadable nil
912 "List of articles in the current newsgroup that can be processed.")
914 (defvar gnus-newsgroup-undownloaded nil
915 "List of articles in the current newsgroup that haven't been downloaded..")
917 (defvar gnus-newsgroup-unsendable nil
918 "List of articles in the current newsgroup that won't be sent.")
920 (defvar gnus-newsgroup-bookmarks nil
921 "List of articles in the current newsgroup that have bookmarks.")
923 (defvar gnus-newsgroup-dormant nil
924 "List of dormant articles in the current newsgroup.")
926 (defvar gnus-newsgroup-scored nil
927 "List of scored articles in the current newsgroup.")
929 (defvar gnus-newsgroup-headers nil
930 "List of article headers in the current newsgroup.")
932 (defvar gnus-newsgroup-threads nil)
934 (defvar gnus-newsgroup-prepared nil
935 "Whether the current group has been prepared properly.")
937 (defvar gnus-newsgroup-ancient nil
938 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
940 (defvar gnus-newsgroup-sparse nil)
942 (defvar gnus-current-article nil)
943 (defvar gnus-article-current nil)
944 (defvar gnus-current-headers nil)
945 (defvar gnus-have-all-headers nil)
946 (defvar gnus-last-article nil)
947 (defvar gnus-newsgroup-history nil)
949 (defconst gnus-summary-local-variables
950 '(gnus-newsgroup-name
951 gnus-newsgroup-begin gnus-newsgroup-end
952 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
953 gnus-newsgroup-last-folder gnus-newsgroup-last-file
954 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
955 gnus-newsgroup-unselected gnus-newsgroup-marked
956 gnus-newsgroup-reads gnus-newsgroup-saved
957 gnus-newsgroup-replied gnus-newsgroup-expirable
958 gnus-newsgroup-processable gnus-newsgroup-killed
959 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
960 gnus-newsgroup-unsendable
961 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
962 gnus-newsgroup-headers gnus-newsgroup-threads
963 gnus-newsgroup-prepared gnus-summary-highlight-line-function
964 gnus-current-article gnus-current-headers gnus-have-all-headers
965 gnus-last-article gnus-article-internal-prepare-hook
966 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
967 gnus-newsgroup-scored gnus-newsgroup-kill-headers
968 gnus-thread-expunge-below
969 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
970 (gnus-summary-mark-below . global)
971 gnus-newsgroup-active gnus-scores-exclude-files
972 gnus-newsgroup-history gnus-newsgroup-ancient
973 gnus-newsgroup-sparse gnus-newsgroup-process-stack
974 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
975 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
976 (gnus-newsgroup-expunged-tally . 0)
977 gnus-cache-removable-articles gnus-newsgroup-cached
978 gnus-newsgroup-data gnus-newsgroup-data-reverse
979 gnus-newsgroup-limit gnus-newsgroup-limits)
980 "Variables that are buffer-local to the summary buffers.")
982 ;; Byte-compiler warning.
983 (defvar gnus-article-mode-map)
985 ;; Subject simplification.
987 (defun gnus-simplify-whitespace (str)
988 "Remove excessive whitespace."
991 (while (string-match "[ \t][ \t]+" mystr)
992 (setq mystr (concat (substring mystr 0 (match-beginning 0))
994 (substring mystr (match-end 0)))))
996 (when (string-match "^[ \t]+" mystr)
997 (setq mystr (substring mystr (match-end 0))))
999 (when (string-match "[ \t]+$" mystr)
1000 (setq mystr (substring mystr 0 (match-beginning 0))))
1003 (defsubst gnus-simplify-subject-re (subject)
1004 "Remove \"Re:\" from subject lines."
1005 (if (string-match "^[Rr][Ee]: *" subject)
1006 (substring subject (match-end 0))
1009 (defun gnus-simplify-subject (subject &optional re-only)
1010 "Remove `Re:' and words in parentheses.
1011 If RE-ONLY is non-nil, strip leading `Re:'s only."
1012 (let ((case-fold-search t)) ;Ignore case.
1013 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1014 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1015 (setq subject (substring subject (match-end 0))))
1016 ;; Remove uninteresting prefixes.
1017 (when (and (not re-only)
1018 gnus-simplify-ignored-prefixes
1019 (string-match gnus-simplify-ignored-prefixes subject))
1020 (setq subject (substring subject (match-end 0))))
1021 ;; Remove words in parentheses from end.
1023 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1024 (setq subject (substring subject 0 (match-beginning 0)))))
1025 ;; Return subject string.
1028 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1030 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1031 (goto-char (point-min))
1032 (while (re-search-forward regexp nil t)
1033 (replace-match (or newtext ""))))
1035 (defun gnus-simplify-buffer-fuzzy ()
1036 "Simplify string in the buffer fuzzily.
1037 The string in the accessible portion of the current buffer is simplified.
1038 It is assumed to be a single-line subject.
1039 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1040 matter is removed. Additional things can be deleted by setting
1041 gnus-simplify-subject-fuzzy-regexp."
1042 (let ((case-fold-search t)
1044 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1046 (while (not (eq modified-tick (buffer-modified-tick)))
1047 (setq modified-tick (buffer-modified-tick))
1049 ((listp gnus-simplify-subject-fuzzy-regexp)
1050 (mapcar 'gnus-simplify-buffer-fuzzy-step
1051 gnus-simplify-subject-fuzzy-regexp))
1052 (gnus-simplify-subject-fuzzy-regexp
1053 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1054 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1055 (gnus-simplify-buffer-fuzzy-step
1056 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1057 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1059 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1060 (gnus-simplify-buffer-fuzzy-step " +" " ")
1061 (gnus-simplify-buffer-fuzzy-step " $")
1062 (gnus-simplify-buffer-fuzzy-step "^ +")))
1064 (defun gnus-simplify-subject-fuzzy (subject)
1065 "Simplify a subject string fuzzily.
1066 See `gnus-simplify-buffer-fuzzy' for details."
1068 (gnus-set-work-buffer)
1069 (let ((case-fold-search t))
1070 ;; Remove uninteresting prefixes.
1071 (when (and gnus-simplify-ignored-prefixes
1072 (string-match gnus-simplify-ignored-prefixes subject))
1073 (setq subject (substring subject (match-end 0))))
1075 (inline (gnus-simplify-buffer-fuzzy))
1078 (defsubst gnus-simplify-subject-fully (subject)
1079 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1081 (gnus-simplify-subject-functions
1082 (gnus-map-function gnus-simplify-subject-functions subject))
1083 ((null gnus-summary-gather-subject-limit)
1084 (gnus-simplify-subject-re subject))
1085 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1086 (gnus-simplify-subject-fuzzy subject))
1087 ((numberp gnus-summary-gather-subject-limit)
1088 (gnus-limit-string (gnus-simplify-subject-re subject)
1089 gnus-summary-gather-subject-limit))
1093 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1094 "Check whether two subjects are equal.
1095 If optional argument simple-first is t, first argument is already
1098 ((null simple-first)
1099 (equal (gnus-simplify-subject-fully s1)
1100 (gnus-simplify-subject-fully s2)))
1103 (gnus-simplify-subject-fully s2)))))
1105 (defun gnus-summary-bubble-group ()
1106 "Increase the score of the current group.
1107 This is a handy function to add to `gnus-summary-exit-hook' to
1108 increase the score of each group you read."
1109 (gnus-group-add-score gnus-newsgroup-name))
1113 ;;; Gnus summary mode
1116 (put 'gnus-summary-mode 'mode-class 'special)
1119 ;; Non-orthogonal keys
1121 (gnus-define-keys gnus-summary-mode-map
1122 " " gnus-summary-next-page
1123 "\177" gnus-summary-prev-page
1124 [delete] gnus-summary-prev-page
1125 [backspace] gnus-summary-prev-page
1126 "\r" gnus-summary-scroll-up
1127 "\M-\r" gnus-summary-scroll-down
1128 "n" gnus-summary-next-unread-article
1129 "p" gnus-summary-prev-unread-article
1130 "N" gnus-summary-next-article
1131 "P" gnus-summary-prev-article
1132 "\M-\C-n" gnus-summary-next-same-subject
1133 "\M-\C-p" gnus-summary-prev-same-subject
1134 "\M-n" gnus-summary-next-unread-subject
1135 "\M-p" gnus-summary-prev-unread-subject
1136 "." gnus-summary-first-unread-article
1137 "," gnus-summary-best-unread-article
1138 "\M-s" gnus-summary-search-article-forward
1139 "\M-r" gnus-summary-search-article-backward
1140 "<" gnus-summary-beginning-of-article
1141 ">" gnus-summary-end-of-article
1142 "j" gnus-summary-goto-article
1143 "^" gnus-summary-refer-parent-article
1144 "\M-^" gnus-summary-refer-article
1145 "u" gnus-summary-tick-article-forward
1146 "!" gnus-summary-tick-article-forward
1147 "U" gnus-summary-tick-article-backward
1148 "d" gnus-summary-mark-as-read-forward
1149 "D" gnus-summary-mark-as-read-backward
1150 "E" gnus-summary-mark-as-expirable
1151 "\M-u" gnus-summary-clear-mark-forward
1152 "\M-U" gnus-summary-clear-mark-backward
1153 "k" gnus-summary-kill-same-subject-and-select
1154 "\C-k" gnus-summary-kill-same-subject
1155 "\M-\C-k" gnus-summary-kill-thread
1156 "\M-\C-l" gnus-summary-lower-thread
1157 "e" gnus-summary-edit-article
1158 "#" gnus-summary-mark-as-processable
1159 "\M-#" gnus-summary-unmark-as-processable
1160 "\M-\C-t" gnus-summary-toggle-threads
1161 "\M-\C-s" gnus-summary-show-thread
1162 "\M-\C-h" gnus-summary-hide-thread
1163 "\M-\C-f" gnus-summary-next-thread
1164 "\M-\C-b" gnus-summary-prev-thread
1165 "\M-\C-u" gnus-summary-up-thread
1166 "\M-\C-d" gnus-summary-down-thread
1167 "&" gnus-summary-execute-command
1168 "c" gnus-summary-catchup-and-exit
1169 "\C-w" gnus-summary-mark-region-as-read
1170 "\C-t" gnus-summary-toggle-truncation
1171 "?" gnus-summary-mark-as-dormant
1172 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1173 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1174 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1175 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1176 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1177 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1178 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1179 "=" gnus-summary-expand-window
1180 "\C-x\C-s" gnus-summary-reselect-current-group
1181 "\M-g" gnus-summary-rescan-group
1182 "w" gnus-summary-stop-page-breaking
1183 "\C-c\C-r" gnus-summary-caesar-message
1184 "f" gnus-summary-followup
1185 "F" gnus-summary-followup-with-original
1186 "C" gnus-summary-cancel-article
1187 "r" gnus-summary-reply
1188 "R" gnus-summary-reply-with-original
1189 "\C-c\C-f" gnus-summary-mail-forward
1190 "o" gnus-summary-save-article
1191 "\C-o" gnus-summary-save-article-mail
1192 "|" gnus-summary-pipe-output
1193 "\M-k" gnus-summary-edit-local-kill
1194 "\M-K" gnus-summary-edit-global-kill
1196 "\C-c\C-d" gnus-summary-describe-group
1197 "q" gnus-summary-exit
1198 "Q" gnus-summary-exit-no-update
1199 "\C-c\C-i" gnus-info-find-node
1200 gnus-mouse-2 gnus-mouse-pick-article
1201 "m" gnus-summary-mail-other-window
1202 "a" gnus-summary-post-news
1203 "x" gnus-summary-limit-to-unread
1204 "s" gnus-summary-isearch-article
1205 "t" gnus-article-hide-headers
1206 "g" gnus-summary-show-article
1207 "l" gnus-summary-goto-last-article
1208 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1209 "\C-d" gnus-summary-enter-digest-group
1210 "\M-\C-d" gnus-summary-read-document
1211 "\M-\C-e" gnus-summary-edit-parameters
1213 "*" gnus-cache-enter-article
1214 "\M-*" gnus-cache-remove-article
1215 "\M-&" gnus-summary-universal-argument
1216 "\C-l" gnus-recenter
1217 "I" gnus-summary-increase-score
1218 "L" gnus-summary-lower-score
1219 "\M-i" gnus-symbolic-argument
1220 "h" gnus-summary-select-article-buffer
1222 "V" gnus-summary-score-map
1223 "X" gnus-uu-extract-map
1224 "S" gnus-summary-send-map)
1226 ;; Sort of orthogonal keymap
1227 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1228 "t" gnus-summary-tick-article-forward
1229 "!" gnus-summary-tick-article-forward
1230 "d" gnus-summary-mark-as-read-forward
1231 "r" gnus-summary-mark-as-read-forward
1232 "c" gnus-summary-clear-mark-forward
1233 " " gnus-summary-clear-mark-forward
1234 "e" gnus-summary-mark-as-expirable
1235 "x" gnus-summary-mark-as-expirable
1236 "?" gnus-summary-mark-as-dormant
1237 "b" gnus-summary-set-bookmark
1238 "B" gnus-summary-remove-bookmark
1239 "#" gnus-summary-mark-as-processable
1240 "\M-#" gnus-summary-unmark-as-processable
1241 "S" gnus-summary-limit-include-expunged
1242 "C" gnus-summary-catchup
1243 "H" gnus-summary-catchup-to-here
1244 "\C-c" gnus-summary-catchup-all
1245 "k" gnus-summary-kill-same-subject-and-select
1246 "K" gnus-summary-kill-same-subject
1247 "P" gnus-uu-mark-map)
1249 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1250 "c" gnus-summary-clear-above
1251 "u" gnus-summary-tick-above
1252 "m" gnus-summary-mark-above
1253 "k" gnus-summary-kill-below)
1255 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1256 "/" gnus-summary-limit-to-subject
1257 "n" gnus-summary-limit-to-articles
1258 "w" gnus-summary-pop-limit
1259 "s" gnus-summary-limit-to-subject
1260 "a" gnus-summary-limit-to-author
1261 "u" gnus-summary-limit-to-unread
1262 "m" gnus-summary-limit-to-marks
1263 "v" gnus-summary-limit-to-score
1264 "*" gnus-summary-limit-include-cached
1265 "D" gnus-summary-limit-include-dormant
1266 "T" gnus-summary-limit-include-thread
1267 "d" gnus-summary-limit-exclude-dormant
1268 "t" gnus-summary-limit-to-age
1269 "E" gnus-summary-limit-include-expunged
1270 "c" gnus-summary-limit-exclude-childless-dormant
1271 "C" gnus-summary-limit-mark-excluded-as-read)
1273 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1274 "n" gnus-summary-next-unread-article
1275 "p" gnus-summary-prev-unread-article
1276 "N" gnus-summary-next-article
1277 "P" gnus-summary-prev-article
1278 "\C-n" gnus-summary-next-same-subject
1279 "\C-p" gnus-summary-prev-same-subject
1280 "\M-n" gnus-summary-next-unread-subject
1281 "\M-p" gnus-summary-prev-unread-subject
1282 "f" gnus-summary-first-unread-article
1283 "b" gnus-summary-best-unread-article
1284 "j" gnus-summary-goto-article
1285 "g" gnus-summary-goto-subject
1286 "l" gnus-summary-goto-last-article
1287 "o" gnus-summary-pop-article)
1289 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1290 "k" gnus-summary-kill-thread
1291 "l" gnus-summary-lower-thread
1292 "i" gnus-summary-raise-thread
1293 "T" gnus-summary-toggle-threads
1294 "t" gnus-summary-rethread-current
1295 "^" gnus-summary-reparent-thread
1296 "s" gnus-summary-show-thread
1297 "S" gnus-summary-show-all-threads
1298 "h" gnus-summary-hide-thread
1299 "H" gnus-summary-hide-all-threads
1300 "n" gnus-summary-next-thread
1301 "p" gnus-summary-prev-thread
1302 "u" gnus-summary-up-thread
1303 "o" gnus-summary-top-thread
1304 "d" gnus-summary-down-thread
1305 "#" gnus-uu-mark-thread
1306 "\M-#" gnus-uu-unmark-thread)
1308 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1309 "g" gnus-summary-prepare
1310 "c" gnus-summary-insert-cached-articles)
1312 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1313 "c" gnus-summary-catchup-and-exit
1314 "C" gnus-summary-catchup-all-and-exit
1315 "E" gnus-summary-exit-no-update
1316 "Q" gnus-summary-exit
1317 "Z" gnus-summary-exit
1318 "n" gnus-summary-catchup-and-goto-next-group
1319 "R" gnus-summary-reselect-current-group
1320 "G" gnus-summary-rescan-group
1321 "N" gnus-summary-next-group
1322 "s" gnus-summary-save-newsrc
1323 "P" gnus-summary-prev-group)
1325 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1326 " " gnus-summary-next-page
1327 "n" gnus-summary-next-page
1328 "\177" gnus-summary-prev-page
1329 [delete] gnus-summary-prev-page
1330 "p" gnus-summary-prev-page
1331 "\r" gnus-summary-scroll-up
1332 "\M-\r" gnus-summary-scroll-down
1333 "<" gnus-summary-beginning-of-article
1334 ">" gnus-summary-end-of-article
1335 "b" gnus-summary-beginning-of-article
1336 "e" gnus-summary-end-of-article
1337 "^" gnus-summary-refer-parent-article
1338 "r" gnus-summary-refer-parent-article
1339 "R" gnus-summary-refer-references
1340 "T" gnus-summary-refer-thread
1341 "g" gnus-summary-show-article
1342 "s" gnus-summary-isearch-article
1343 "P" gnus-summary-print-article)
1345 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1346 "b" gnus-article-add-buttons
1347 "B" gnus-article-add-buttons-to-head
1348 "o" gnus-article-treat-overstrike
1349 "e" gnus-article-emphasize
1350 "w" gnus-article-fill-cited-article
1351 "c" gnus-article-remove-cr
1352 "q" gnus-article-de-quoted-unreadable
1353 "f" gnus-article-display-x-face
1354 "l" gnus-summary-stop-page-breaking
1355 "r" gnus-summary-caesar-message
1356 "t" gnus-article-hide-headers
1357 "v" gnus-summary-verbose-headers
1358 "h" gnus-article-treat-html
1359 "d" gnus-article-treat-dumbquotes)
1361 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1362 "a" gnus-article-hide
1363 "h" gnus-article-hide-headers
1364 "b" gnus-article-hide-boring-headers
1365 "s" gnus-article-hide-signature
1366 "c" gnus-article-hide-citation
1367 "C" gnus-article-hide-citation-in-followups
1368 "p" gnus-article-hide-pgp
1369 "P" gnus-article-hide-pem
1370 "\C-c" gnus-article-hide-citation-maybe)
1372 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1373 "a" gnus-article-highlight
1374 "h" gnus-article-highlight-headers
1375 "c" gnus-article-highlight-citation
1376 "s" gnus-article-highlight-signature)
1378 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1379 "w" gnus-article-decode-mime-words
1380 "c" gnus-article-decode-charset)
1382 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1383 "z" gnus-article-date-ut
1384 "u" gnus-article-date-ut
1385 "l" gnus-article-date-local
1386 "e" gnus-article-date-lapsed
1387 "o" gnus-article-date-original
1388 "i" gnus-article-date-iso8601
1389 "s" gnus-article-date-user)
1391 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1392 "t" gnus-article-remove-trailing-blank-lines
1393 "l" gnus-article-strip-leading-blank-lines
1394 "m" gnus-article-strip-multiple-blank-lines
1395 "a" gnus-article-strip-blank-lines
1396 "A" gnus-article-strip-all-blank-lines
1397 "s" gnus-article-strip-leading-space)
1399 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1401 "f" gnus-summary-fetch-faq
1402 "d" gnus-summary-describe-group
1403 "h" gnus-summary-describe-briefly
1404 "i" gnus-info-find-node)
1406 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1407 "e" gnus-summary-expire-articles
1408 "\M-\C-e" gnus-summary-expire-articles-now
1409 "\177" gnus-summary-delete-article
1410 [delete] gnus-summary-delete-article
1411 "m" gnus-summary-move-article
1412 "r" gnus-summary-respool-article
1413 "w" gnus-summary-edit-article
1414 "c" gnus-summary-copy-article
1415 "B" gnus-summary-crosspost-article
1416 "q" gnus-summary-respool-query
1417 "t" gnus-summary-respool-trace
1418 "i" gnus-summary-import-article
1419 "p" gnus-summary-article-posted-p)
1421 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1422 "o" gnus-summary-save-article
1423 "m" gnus-summary-save-article-mail
1424 "F" gnus-summary-write-article-file
1425 "r" gnus-summary-save-article-rmail
1426 "f" gnus-summary-save-article-file
1427 "b" gnus-summary-save-article-body-file
1428 "h" gnus-summary-save-article-folder
1429 "v" gnus-summary-save-article-vm
1430 "p" gnus-summary-pipe-output
1431 "s" gnus-soup-add-article))
1433 (defun gnus-summary-make-menu-bar ()
1434 (gnus-turn-off-edit-menu 'summary)
1436 (unless (boundp 'gnus-summary-misc-menu)
1439 gnus-summary-kill-menu gnus-summary-mode-map ""
1444 ["Enter score..." gnus-summary-score-entry t]
1445 ["Customize" gnus-score-customize t])
1446 (gnus-make-score-map 'increase)
1447 (gnus-make-score-map 'lower)
1449 ["Kill below" gnus-summary-kill-below t]
1450 ["Mark above" gnus-summary-mark-above t]
1451 ["Tick above" gnus-summary-tick-above t]
1452 ["Clear above" gnus-summary-clear-above t])
1453 ["Current score" gnus-summary-current-score t]
1454 ["Set score" gnus-summary-set-score t]
1455 ["Switch current score file..." gnus-score-change-score-file t]
1456 ["Set mark below..." gnus-score-set-mark-below t]
1457 ["Set expunge below..." gnus-score-set-expunge-below t]
1458 ["Edit current score file" gnus-score-edit-current-scores t]
1459 ["Edit score file" gnus-score-edit-file t]
1460 ["Trace score" gnus-score-find-trace t]
1461 ["Find words" gnus-score-find-favourite-words t]
1462 ["Rescore buffer" gnus-summary-rescore t]
1463 ["Increase score..." gnus-summary-increase-score t]
1464 ["Lower score..." gnus-summary-lower-score t]))))
1466 ;; Define both the Article menu in the summary buffer and the equivalent
1467 ;; Commands menu in the article buffer here for consistency.
1470 ["All" gnus-article-hide t]
1471 ["Headers" gnus-article-hide-headers t]
1472 ["Signature" gnus-article-hide-signature t]
1473 ["Citation" gnus-article-hide-citation t]
1474 ["PGP" gnus-article-hide-pgp t]
1475 ["Boring headers" gnus-article-hide-boring-headers t])
1477 ["All" gnus-article-highlight t]
1478 ["Headers" gnus-article-highlight-headers t]
1479 ["Signature" gnus-article-highlight-signature t]
1480 ["Citation" gnus-article-highlight-citation t])
1482 ["Words" gnus-article-decode-mime-words t]
1483 ["Charset" gnus-article-decode-charset t]
1484 ["QP" gnus-article-de-quoted-unreadable t])
1486 ["Local" gnus-article-date-local t]
1487 ["ISO8601" gnus-article-date-iso8601 t]
1488 ["UT" gnus-article-date-ut t]
1489 ["Original" gnus-article-date-original t]
1490 ["Lapsed" gnus-article-date-lapsed t]
1491 ["User-defined" gnus-article-date-user t])
1494 ["Leading" gnus-article-strip-leading-blank-lines t]
1495 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1496 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1497 ["All of the above" gnus-article-strip-blank-lines t]
1498 ["All" gnus-article-strip-all-blank-lines t]
1499 ["Leading space" gnus-article-strip-leading-space t])
1500 ["Overstrike" gnus-article-treat-overstrike t]
1501 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1502 ["Emphasis" gnus-article-emphasize t]
1503 ["Word wrap" gnus-article-fill-cited-article t]
1504 ["CR" gnus-article-remove-cr t]
1505 ["Show X-Face" gnus-article-display-x-face t]
1506 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1507 ["UnHTMLize" gnus-article-treat-html t]
1508 ["Rot 13" gnus-summary-caesar-message t]
1509 ["Unix pipe" gnus-summary-pipe-message t]
1510 ["Add buttons" gnus-article-add-buttons t]
1511 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1512 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1513 ["Verbose header" gnus-summary-verbose-headers t]
1514 ["Toggle header" gnus-summary-toggle-header t])
1516 ["Save in default format" gnus-summary-save-article t]
1517 ["Save in file" gnus-summary-save-article-file t]
1518 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1519 ["Save in MH folder" gnus-summary-save-article-folder t]
1520 ["Save in VM folder" gnus-summary-save-article-vm t]
1521 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1522 ["Save body in file" gnus-summary-save-article-body-file t]
1523 ["Pipe through a filter" gnus-summary-pipe-output t]
1524 ["Add to SOUP packet" gnus-soup-add-article t]
1525 ["Print" gnus-summary-print-article t])
1527 ["Respool article..." gnus-summary-respool-article t]
1528 ["Move article..." gnus-summary-move-article
1529 (gnus-check-backend-function
1530 'request-move-article gnus-newsgroup-name)]
1531 ["Copy article..." gnus-summary-copy-article t]
1532 ["Crosspost article..." gnus-summary-crosspost-article
1533 (gnus-check-backend-function
1534 'request-replace-article gnus-newsgroup-name)]
1535 ["Import file..." gnus-summary-import-article t]
1536 ["Check if posted" gnus-summary-article-posted-p t]
1537 ["Edit article" gnus-summary-edit-article
1538 (not (gnus-group-read-only-p))]
1539 ["Delete article" gnus-summary-delete-article
1540 (gnus-check-backend-function
1541 'request-expire-articles gnus-newsgroup-name)]
1542 ["Query respool" gnus-summary-respool-query t]
1543 ["Trace respool" gnus-summary-respool-trace t]
1544 ["Delete expirable articles" gnus-summary-expire-articles-now
1545 (gnus-check-backend-function
1546 'request-expire-articles gnus-newsgroup-name)])
1548 ["Uudecode" gnus-uu-decode-uu t]
1549 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1550 ["Unshar" gnus-uu-decode-unshar t]
1551 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1552 ["Save" gnus-uu-decode-save t]
1553 ["Binhex" gnus-uu-decode-binhex t]
1554 ["Postscript" gnus-uu-decode-postscript t])
1556 ["Enter article" gnus-cache-enter-article t]
1557 ["Remove article" gnus-cache-remove-article t])
1558 ["Select article buffer" gnus-summary-select-article-buffer t]
1559 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1560 ["Isearch article..." gnus-summary-isearch-article t]
1561 ["Beginning of the article" gnus-summary-beginning-of-article t]
1562 ["End of the article" gnus-summary-end-of-article t]
1563 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1564 ["Fetch referenced articles" gnus-summary-refer-references t]
1565 ["Fetch current thread" gnus-summary-refer-thread t]
1566 ["Fetch article with id..." gnus-summary-refer-article t]
1567 ["Redisplay" gnus-summary-show-article t])))
1569 gnus-summary-article-menu gnus-summary-mode-map ""
1570 (cons "Article" innards))
1573 gnus-article-commands-menu gnus-article-mode-map ""
1574 (cons "Commands" innards)))
1577 gnus-summary-thread-menu gnus-summary-mode-map ""
1579 ["Toggle threading" gnus-summary-toggle-threads t]
1580 ["Hide threads" gnus-summary-hide-all-threads t]
1581 ["Show threads" gnus-summary-show-all-threads t]
1582 ["Hide thread" gnus-summary-hide-thread t]
1583 ["Show thread" gnus-summary-show-thread t]
1584 ["Go to next thread" gnus-summary-next-thread t]
1585 ["Go to previous thread" gnus-summary-prev-thread t]
1586 ["Go down thread" gnus-summary-down-thread t]
1587 ["Go up thread" gnus-summary-up-thread t]
1588 ["Top of thread" gnus-summary-top-thread t]
1589 ["Mark thread as read" gnus-summary-kill-thread t]
1590 ["Lower thread score" gnus-summary-lower-thread t]
1591 ["Raise thread score" gnus-summary-raise-thread t]
1592 ["Rethread current" gnus-summary-rethread-current t]
1596 gnus-summary-post-menu gnus-summary-mode-map ""
1598 ["Post an article" gnus-summary-post-news t]
1599 ["Followup" gnus-summary-followup t]
1600 ["Followup and yank" gnus-summary-followup-with-original t]
1601 ["Supersede article" gnus-summary-supersede-article t]
1602 ["Cancel article" gnus-summary-cancel-article t]
1603 ["Reply" gnus-summary-reply t]
1604 ["Reply and yank" gnus-summary-reply-with-original t]
1605 ["Wide reply" gnus-summary-wide-reply t]
1606 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1607 ["Mail forward" gnus-summary-mail-forward t]
1608 ["Post forward" gnus-summary-post-forward t]
1609 ["Digest and mail" gnus-uu-digest-mail-forward t]
1610 ["Digest and post" gnus-uu-digest-post-forward t]
1611 ["Resend message" gnus-summary-resend-message t]
1612 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1613 ["Send a mail" gnus-summary-mail-other-window t]
1614 ["Uuencode and post" gnus-uu-post-news t]
1615 ["Followup via news" gnus-summary-followup-to-mail t]
1616 ["Followup via news and yank"
1617 gnus-summary-followup-to-mail-with-original t]
1619 ;;["Send" gnus-summary-send-draft t]
1620 ;;["Send bounced" gnus-resend-bounced-mail t])
1624 gnus-summary-misc-menu gnus-summary-mode-map ""
1627 ["Mark as read" gnus-summary-mark-as-read-forward t]
1628 ["Mark same subject and select"
1629 gnus-summary-kill-same-subject-and-select t]
1630 ["Mark same subject" gnus-summary-kill-same-subject t]
1631 ["Catchup" gnus-summary-catchup t]
1632 ["Catchup all" gnus-summary-catchup-all t]
1633 ["Catchup to here" gnus-summary-catchup-to-here t]
1634 ["Catchup region" gnus-summary-mark-region-as-read t]
1635 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1637 ["Tick" gnus-summary-tick-article-forward t]
1638 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1639 ["Remove marks" gnus-summary-clear-mark-forward t]
1640 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1641 ["Set bookmark" gnus-summary-set-bookmark t]
1642 ["Remove bookmark" gnus-summary-remove-bookmark t])
1644 ["Marks..." gnus-summary-limit-to-marks t]
1645 ["Subject..." gnus-summary-limit-to-subject t]
1646 ["Author..." gnus-summary-limit-to-author t]
1647 ["Age..." gnus-summary-limit-to-age t]
1648 ["Score" gnus-summary-limit-to-score t]
1649 ["Unread" gnus-summary-limit-to-unread t]
1650 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1651 ["Articles" gnus-summary-limit-to-articles t]
1652 ["Pop limit" gnus-summary-pop-limit t]
1653 ["Show dormant" gnus-summary-limit-include-dormant t]
1654 ["Hide childless dormant"
1655 gnus-summary-limit-exclude-childless-dormant t]
1656 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1657 ["Show expunged" gnus-summary-show-all-expunged t])
1659 ["Set mark" gnus-summary-mark-as-processable t]
1660 ["Remove mark" gnus-summary-unmark-as-processable t]
1661 ["Remove all marks" gnus-summary-unmark-all-processable t]
1662 ["Mark above" gnus-uu-mark-over t]
1663 ["Mark series" gnus-uu-mark-series t]
1664 ["Mark region" gnus-uu-mark-region t]
1665 ["Unmark region" gnus-uu-unmark-region t]
1666 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1667 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1668 ["Mark all" gnus-uu-mark-all t]
1669 ["Mark buffer" gnus-uu-mark-buffer t]
1670 ["Mark sparse" gnus-uu-mark-sparse t]
1671 ["Mark thread" gnus-uu-mark-thread t]
1672 ["Unmark thread" gnus-uu-unmark-thread t]
1673 ("Process Mark Sets"
1674 ["Kill" gnus-summary-kill-process-mark t]
1675 ["Yank" gnus-summary-yank-process-mark
1676 gnus-newsgroup-process-stack]
1677 ["Save" gnus-summary-save-process-mark t]))
1679 ["Page forward" gnus-summary-next-page t]
1680 ["Page backward" gnus-summary-prev-page t]
1681 ["Line forward" gnus-summary-scroll-up t])
1683 ["Next unread article" gnus-summary-next-unread-article t]
1684 ["Previous unread article" gnus-summary-prev-unread-article t]
1685 ["Next article" gnus-summary-next-article t]
1686 ["Previous article" gnus-summary-prev-article t]
1687 ["Next unread subject" gnus-summary-next-unread-subject t]
1688 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1689 ["Next article same subject" gnus-summary-next-same-subject t]
1690 ["Previous article same subject" gnus-summary-prev-same-subject t]
1691 ["First unread article" gnus-summary-first-unread-article t]
1692 ["Best unread article" gnus-summary-best-unread-article t]
1693 ["Go to subject number..." gnus-summary-goto-subject t]
1694 ["Go to article number..." gnus-summary-goto-article t]
1695 ["Go to the last article" gnus-summary-goto-last-article t]
1696 ["Pop article off history" gnus-summary-pop-article t])
1698 ["Sort by number" gnus-summary-sort-by-number t]
1699 ["Sort by author" gnus-summary-sort-by-author t]
1700 ["Sort by subject" gnus-summary-sort-by-subject t]
1701 ["Sort by date" gnus-summary-sort-by-date t]
1702 ["Sort by score" gnus-summary-sort-by-score t]
1703 ["Sort by lines" gnus-summary-sort-by-lines t])
1705 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1706 ["Describe group" gnus-summary-describe-group t]
1707 ["Read manual" gnus-info-find-node t])
1709 ["Pick and read" gnus-pick-mode t]
1710 ["Binary" gnus-binary-mode t])
1712 ["Regenerate" gnus-summary-prepare t]
1713 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1714 ["Toggle threading" gnus-summary-toggle-threads t])
1715 ["Filter articles..." gnus-summary-execute-command t]
1716 ["Run command on subjects..." gnus-summary-universal-argument t]
1717 ["Search articles forward..." gnus-summary-search-article-forward t]
1718 ["Search articles backward..." gnus-summary-search-article-backward t]
1719 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1720 ["Expand window" gnus-summary-expand-window t]
1721 ["Expire expirable articles" gnus-summary-expire-articles
1722 (gnus-check-backend-function
1723 'request-expire-articles gnus-newsgroup-name)]
1724 ["Edit local kill file" gnus-summary-edit-local-kill t]
1725 ["Edit main kill file" gnus-summary-edit-global-kill t]
1726 ["Edit group parameters" gnus-summary-edit-parameters t]
1727 ["Send a bug report" gnus-bug t]
1729 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1730 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1731 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1732 ["Exit group" gnus-summary-exit t]
1733 ["Exit group without updating" gnus-summary-exit-no-update t]
1734 ["Exit and goto next group" gnus-summary-next-group t]
1735 ["Exit and goto prev group" gnus-summary-prev-group t]
1736 ["Reselect group" gnus-summary-reselect-current-group t]
1737 ["Rescan group" gnus-summary-rescan-group t]
1738 ["Update dribble" gnus-summary-save-newsrc t])))
1740 (gnus-run-hooks 'gnus-summary-menu-hook)))
1742 (defun gnus-score-set-default (var value)
1743 "A version of set that updates the GNU Emacs menu-bar."
1745 ;; It is the message that forces the active status to be updated.
1748 (defun gnus-make-score-map (type)
1749 "Make a summary score map of type TYPE."
1752 (let ((headers '(("author" "from" string)
1753 ("subject" "subject" string)
1754 ("article body" "body" string)
1755 ("article head" "head" string)
1756 ("xref" "xref" string)
1757 ("lines" "lines" number)
1758 ("followups to author" "followup" string)))
1759 (types '((number ("less than" <)
1762 (string ("substring" s)
1766 (perms '(("temporary" (current-time-string))
1774 (if (eq type 'lower)
1779 (setq header (car headers))
1785 (let ((ts (cdr (assoc (nth 2 header) types)))
1801 'gnus-summary-score-entry
1803 (if (or (string= (nth 1 header)
1805 (string= (nth 1 header)
1808 (list 'gnus-summary-header
1810 (list 'quote (nth 1 (car ts)))
1811 (list 'gnus-score-default nil)
1817 (list (nreverse outp))))
1820 (list (nreverse outt))))
1822 (setq headers (cdr headers)))
1823 (list (nreverse outh))))))))
1827 (defun gnus-summary-mode (&optional group)
1828 "Major mode for reading articles.
1830 All normal editing commands are switched off.
1831 \\<gnus-summary-mode-map>
1832 Each line in this buffer represents one article. To read an
1833 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1834 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1837 You can also post articles and send mail from this buffer. To
1838 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1839 of an article, type `\\[gnus-summary-reply]'.
1841 There are approx. one gazillion commands you can execute in this
1842 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1844 The following commands are available:
1846 \\{gnus-summary-mode-map}"
1848 (when (gnus-visual-p 'summary-menu 'menu)
1849 (gnus-summary-make-menu-bar))
1850 (kill-all-local-variables)
1851 (gnus-summary-make-local-variables)
1852 (gnus-make-thread-indent-array)
1853 (gnus-simplify-mode-line)
1854 (setq major-mode 'gnus-summary-mode)
1855 (setq mode-name "Summary")
1856 (make-local-variable 'minor-mode-alist)
1857 (use-local-map gnus-summary-mode-map)
1858 (buffer-disable-undo (current-buffer))
1859 (setq buffer-read-only t) ;Disable modification
1860 (setq truncate-lines t)
1861 (setq selective-display t)
1862 (setq selective-display-ellipses t) ;Display `...'
1863 (gnus-summary-set-display-table)
1864 (gnus-set-default-directory)
1865 (setq gnus-newsgroup-name group)
1866 (make-local-variable 'gnus-summary-line-format)
1867 (make-local-variable 'gnus-summary-line-format-spec)
1868 (make-local-variable 'gnus-summary-dummy-line-format)
1869 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1870 (make-local-variable 'gnus-summary-mark-positions)
1871 (make-local-hook 'post-command-hook)
1872 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1873 (make-local-hook 'pre-command-hook)
1874 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1875 (gnus-run-hooks 'gnus-summary-mode-hook)
1876 (mm-enable-multibyte)
1877 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1878 (gnus-update-summary-mark-positions))
1880 (defun gnus-summary-make-local-variables ()
1881 "Make all the local summary buffer variables."
1882 (let ((locals gnus-summary-local-variables)
1884 (while (setq local (pop locals))
1887 (if (eq (cdr local) 'global)
1888 ;; Copy the global value of the variable.
1889 (setq global (symbol-value (car local)))
1890 ;; Use the value from the list.
1891 (setq global (eval (cdr local))))
1892 (make-local-variable (car local))
1893 (set (car local) global))
1894 ;; Simple nil-valued local variable.
1895 (make-local-variable local)
1898 (defun gnus-summary-clear-local-variables ()
1899 (let ((locals gnus-summary-local-variables))
1901 (if (consp (car locals))
1902 (and (vectorp (caar locals))
1903 (set (caar locals) nil))
1904 (and (vectorp (car locals))
1905 (set (car locals) nil)))
1906 (setq locals (cdr locals)))))
1908 ;; Summary data functions.
1910 (defmacro gnus-data-number (data)
1913 (defmacro gnus-data-set-number (data number)
1914 `(setcar ,data ,number))
1916 (defmacro gnus-data-mark (data)
1919 (defmacro gnus-data-set-mark (data mark)
1920 `(setcar (nthcdr 1 ,data) ,mark))
1922 (defmacro gnus-data-pos (data)
1925 (defmacro gnus-data-set-pos (data pos)
1926 `(setcar (nthcdr 2 ,data) ,pos))
1928 (defmacro gnus-data-header (data)
1931 (defmacro gnus-data-set-header (data header)
1932 `(setf (nth 3 ,data) ,header))
1934 (defmacro gnus-data-level (data)
1937 (defmacro gnus-data-unread-p (data)
1938 `(= (nth 1 ,data) gnus-unread-mark))
1940 (defmacro gnus-data-read-p (data)
1941 `(/= (nth 1 ,data) gnus-unread-mark))
1943 (defmacro gnus-data-pseudo-p (data)
1944 `(consp (nth 3 ,data)))
1946 (defmacro gnus-data-find (number)
1947 `(assq ,number gnus-newsgroup-data))
1949 (defmacro gnus-data-find-list (number &optional data)
1950 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1951 (memq (assq ,number bdata)
1954 (defmacro gnus-data-make (number mark pos header level)
1955 `(list ,number ,mark ,pos ,header ,level))
1957 (defun gnus-data-enter (after-article number mark pos header level offset)
1958 (let ((data (gnus-data-find-list after-article)))
1960 (error "No such article: %d" after-article))
1961 (setcdr data (cons (gnus-data-make number mark pos header level)
1963 (setq gnus-newsgroup-data-reverse nil)
1964 (gnus-data-update-list (cddr data) offset)))
1966 (defun gnus-data-enter-list (after-article list &optional offset)
1968 (let ((data (and after-article (gnus-data-find-list after-article)))
1972 (let ((odata gnus-newsgroup-data))
1973 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
1975 (gnus-data-update-list odata offset)))
1976 ;; Find the last element in the list to be spliced into the main
1979 (setq list (cdr list)))
1982 (setcdr list gnus-newsgroup-data)
1983 (setq gnus-newsgroup-data ilist)
1985 (gnus-data-update-list (cdr list) offset)))
1986 (setcdr list (cdr data))
1989 (gnus-data-update-list (cdr list) offset))))
1990 (setq gnus-newsgroup-data-reverse nil))))
1992 (defun gnus-data-remove (article &optional offset)
1993 (let ((data gnus-newsgroup-data))
1994 (if (= (gnus-data-number (car data)) article)
1996 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1997 gnus-newsgroup-data-reverse nil)
1999 (gnus-data-update-list gnus-newsgroup-data offset)))
2001 (when (= (gnus-data-number (cadr data)) article)
2002 (setcdr data (cddr data))
2004 (gnus-data-update-list (cdr data) offset))
2006 gnus-newsgroup-data-reverse nil))
2007 (setq data (cdr data))))))
2009 (defmacro gnus-data-list (backward)
2011 (or gnus-newsgroup-data-reverse
2012 (setq gnus-newsgroup-data-reverse
2013 (reverse gnus-newsgroup-data)))
2014 gnus-newsgroup-data))
2016 (defun gnus-data-update-list (data offset)
2017 "Add OFFSET to the POS of all data entries in DATA."
2018 (setq gnus-newsgroup-data-reverse nil)
2020 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2021 (setq data (cdr data))))
2023 (defun gnus-summary-article-pseudo-p (article)
2024 "Say whether this article is a pseudo article or not."
2025 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2027 (defmacro gnus-summary-article-sparse-p (article)
2028 "Say whether this article is a sparse article or not."
2029 `(memq ,article gnus-newsgroup-sparse))
2031 (defmacro gnus-summary-article-ancient-p (article)
2032 "Say whether this article is a sparse article or not."
2033 `(memq ,article gnus-newsgroup-ancient))
2035 (defun gnus-article-parent-p (number)
2036 "Say whether this article is a parent or not."
2037 (let ((data (gnus-data-find-list number)))
2038 (and (cdr data) ; There has to be an article after...
2039 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2040 (gnus-data-level (nth 1 data))))))
2042 (defun gnus-article-children (number)
2043 "Return a list of all children to NUMBER."
2044 (let* ((data (gnus-data-find-list number))
2045 (level (gnus-data-level (car data)))
2047 (setq data (cdr data))
2049 (= (gnus-data-level (car data)) (1+ level)))
2050 (push (gnus-data-number (car data)) children)
2051 (setq data (cdr data)))
2054 (defmacro gnus-summary-skip-intangible ()
2055 "If the current article is intangible, then jump to a different article."
2056 '(let ((to (get-text-property (point) 'gnus-intangible)))
2057 (and to (gnus-summary-goto-subject to))))
2059 (defmacro gnus-summary-article-intangible-p ()
2060 "Say whether this article is intangible or not."
2061 '(get-text-property (point) 'gnus-intangible))
2063 (defun gnus-article-read-p (article)
2064 "Say whether ARTICLE is read or not."
2065 (not (or (memq article gnus-newsgroup-marked)
2066 (memq article gnus-newsgroup-unreads)
2067 (memq article gnus-newsgroup-unselected)
2068 (memq article gnus-newsgroup-dormant))))
2070 ;; Some summary mode macros.
2072 (defmacro gnus-summary-article-number ()
2073 "The article number of the article on the current line.
2074 If there isn's an article number here, then we return the current
2077 (gnus-summary-skip-intangible)
2078 (or (get-text-property (point) 'gnus-number)
2079 (gnus-summary-last-subject))))
2081 (defmacro gnus-summary-article-header (&optional number)
2082 "Return the header of article NUMBER."
2083 `(gnus-data-header (gnus-data-find
2084 ,(or number '(gnus-summary-article-number)))))
2086 (defmacro gnus-summary-thread-level (&optional number)
2087 "Return the level of thread that starts with article NUMBER."
2088 `(if (and (eq gnus-summary-make-false-root 'dummy)
2089 (get-text-property (point) 'gnus-intangible))
2091 (gnus-data-level (gnus-data-find
2092 ,(or number '(gnus-summary-article-number))))))
2094 (defmacro gnus-summary-article-mark (&optional number)
2095 "Return the mark of article NUMBER."
2096 `(gnus-data-mark (gnus-data-find
2097 ,(or number '(gnus-summary-article-number)))))
2099 (defmacro gnus-summary-article-pos (&optional number)
2100 "Return the position of the line of article NUMBER."
2101 `(gnus-data-pos (gnus-data-find
2102 ,(or number '(gnus-summary-article-number)))))
2104 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2105 (defmacro gnus-summary-article-subject (&optional number)
2106 "Return current subject string or nil if nothing."
2109 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2110 '(gnus-data-header (assq (gnus-summary-article-number)
2111 gnus-newsgroup-data)))))
2114 (mail-header-subject headers))))
2116 (defmacro gnus-summary-article-score (&optional number)
2117 "Return current article score."
2118 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2119 gnus-newsgroup-scored))
2120 gnus-summary-default-score 0))
2122 (defun gnus-summary-article-children (&optional number)
2123 "Return a list of article numbers that are children of article NUMBER."
2124 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2125 (level (gnus-data-level (car data)))
2127 (while (and (setq data (cdr data))
2128 (> (setq l (gnus-data-level (car data))) level))
2129 (and (= (1+ level) l)
2130 (push (gnus-data-number (car data))
2132 (nreverse children)))
2134 (defun gnus-summary-article-parent (&optional number)
2135 "Return the article number of the parent of article NUMBER."
2136 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2137 (gnus-data-list t)))
2138 (level (gnus-data-level (car data))))
2140 () ; This is a root.
2141 ;; We search until we find an article with a level less than
2142 ;; this one. That function has to be the parent.
2143 (while (and (setq data (cdr data))
2144 (not (< (gnus-data-level (car data)) level))))
2145 (and data (gnus-data-number (car data))))))
2147 (defun gnus-unread-mark-p (mark)
2148 "Say whether MARK is the unread mark."
2149 (= mark gnus-unread-mark))
2151 (defun gnus-read-mark-p (mark)
2152 "Say whether MARK is one of the marks that mark as read.
2153 This is all marks except unread, ticked, dormant, and expirable."
2154 (not (or (= mark gnus-unread-mark)
2155 (= mark gnus-ticked-mark)
2156 (= mark gnus-dormant-mark)
2157 (= mark gnus-expirable-mark))))
2159 (defmacro gnus-article-mark (number)
2160 "Return the MARK of article NUMBER.
2161 This macro should only be used when computing the mark the \"first\"
2162 time; i.e., when generating the summary lines. After that,
2163 `gnus-summary-article-mark' should be used to examine the
2166 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2167 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2168 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2169 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2170 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2171 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2172 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2173 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2174 gnus-ancient-mark))))
2176 ;; Saving hidden threads.
2178 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2179 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2181 (defmacro gnus-save-hidden-threads (&rest forms)
2182 "Save hidden threads, eval FORMS, and restore the hidden threads."
2183 (let ((config (make-symbol "config")))
2184 `(let ((,config (gnus-hidden-threads-configuration)))
2188 (gnus-restore-hidden-threads-configuration ,config)))))
2190 (defun gnus-data-compute-positions ()
2191 "Compute the positions of all articles."
2192 (setq gnus-newsgroup-data-reverse nil)
2193 (let ((data gnus-newsgroup-data))
2195 (gnus-save-hidden-threads
2196 (gnus-summary-show-all-threads)
2197 (goto-char (point-min))
2199 (while (get-text-property (point) 'gnus-intangible)
2201 (gnus-data-set-pos (car data) (+ (point) 3))
2202 (setq data (cdr data))
2203 (forward-line 1))))))
2205 (defun gnus-hidden-threads-configuration ()
2206 "Return the current hidden threads configuration."
2209 (goto-char (point-min))
2210 (while (search-forward "\r" nil t)
2211 (push (1- (point)) config))
2214 (defun gnus-restore-hidden-threads-configuration (config)
2215 "Restore hidden threads configuration from CONFIG."
2216 (let (point buffer-read-only)
2217 (while (setq point (pop config))
2218 (when (and (< point (point-max))
2220 (= (following-char) ?\n))
2221 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2223 ;; Various summary mode internalish functions.
2225 (defun gnus-mouse-pick-article (e)
2228 (gnus-summary-next-page nil t))
2230 (defun gnus-summary-set-display-table ()
2231 ;; Change the display table. Odd characters have a tendency to mess
2232 ;; up nicely formatted displays - we make all possible glyphs
2233 ;; display only a single character.
2235 ;; We start from the standard display table, if any.
2236 (let ((table (or (copy-sequence standard-display-table)
2237 (make-display-table)))
2239 ;; Nix out all the control chars...
2240 (while (>= (setq i (1- i)) 0)
2241 (aset table i [??]))
2242 ;; ... but not newline and cr, of course. (cr is necessary for the
2243 ;; selective display).
2244 (aset table ?\n nil)
2245 (aset table ?\r nil)
2246 ;; We keep TAB as well.
2247 (aset table ?\t nil)
2248 ;; We nix out any glyphs over 126 that are not set already.
2250 (while (>= (setq i (1- i)) 127)
2251 ;; Only modify if the entry is nil.
2252 (unless (aref table i)
2253 (aset table i [??]))))
2254 (setq buffer-display-table table)))
2256 (defun gnus-summary-setup-buffer (group)
2257 "Initialize summary buffer."
2258 (let ((buffer (concat "*Summary " group "*")))
2259 (if (get-buffer buffer)
2262 (setq gnus-summary-buffer (current-buffer))
2263 (not gnus-newsgroup-prepared))
2264 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2265 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2266 (gnus-summary-mode group)
2268 (gnus-carpal-setup-buffer 'summary))
2269 (unless gnus-single-article-buffer
2270 (make-local-variable 'gnus-article-buffer)
2271 (make-local-variable 'gnus-article-current)
2272 (make-local-variable 'gnus-original-article-buffer))
2273 (setq gnus-newsgroup-name group)
2276 (defun gnus-set-global-variables ()
2277 ;; Set the global equivalents of the summary buffer-local variables
2278 ;; to the latest values they had. These reflect the summary buffer
2279 ;; that was in action when the last article was fetched.
2280 (when (eq major-mode 'gnus-summary-mode)
2281 (setq gnus-summary-buffer (current-buffer))
2282 (let ((name gnus-newsgroup-name)
2283 (marked gnus-newsgroup-marked)
2284 (unread gnus-newsgroup-unreads)
2285 (headers gnus-current-headers)
2286 (data gnus-newsgroup-data)
2287 (summary gnus-summary-buffer)
2288 (article-buffer gnus-article-buffer)
2289 (original gnus-original-article-buffer)
2290 (gac gnus-article-current)
2291 (reffed gnus-reffed-article-number)
2292 (score-file gnus-current-score-file))
2294 (set-buffer gnus-group-buffer)
2295 (setq gnus-newsgroup-name name
2296 gnus-newsgroup-marked marked
2297 gnus-newsgroup-unreads unread
2298 gnus-current-headers headers
2299 gnus-newsgroup-data data
2300 gnus-article-current gac
2301 gnus-summary-buffer summary
2302 gnus-article-buffer article-buffer
2303 gnus-original-article-buffer original
2304 gnus-reffed-article-number reffed
2305 gnus-current-score-file score-file)
2306 ;; The article buffer also has local variables.
2307 (when (gnus-buffer-live-p gnus-article-buffer)
2308 (set-buffer gnus-article-buffer)
2309 (setq gnus-summary-buffer summary))))))
2311 (defun gnus-summary-article-unread-p (article)
2312 "Say whether ARTICLE is unread or not."
2313 (memq article gnus-newsgroup-unreads))
2315 (defun gnus-summary-first-article-p (&optional article)
2316 "Return whether ARTICLE is the first article in the buffer."
2317 (if (not (setq article (or article (gnus-summary-article-number))))
2319 (eq article (caar gnus-newsgroup-data))))
2321 (defun gnus-summary-last-article-p (&optional article)
2322 "Return whether ARTICLE is the last article in the buffer."
2323 (if (not (setq article (or article (gnus-summary-article-number))))
2324 t ; All non-existent numbers are the last article. :-)
2325 (not (cdr (gnus-data-find-list article)))))
2327 (defun gnus-make-thread-indent-array ()
2329 (unless (and gnus-thread-indent-array
2330 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2331 (setq gnus-thread-indent-array (make-vector 201 "")
2332 gnus-thread-indent-array-level gnus-thread-indent-level)
2334 (aset gnus-thread-indent-array n
2335 (make-string (* n gnus-thread-indent-level) ? ))
2338 (defun gnus-update-summary-mark-positions ()
2339 "Compute where the summary marks are to go."
2341 (when (gnus-buffer-exists-p gnus-summary-buffer)
2342 (set-buffer gnus-summary-buffer))
2343 (let ((gnus-replied-mark 129)
2344 (gnus-score-below-mark 130)
2345 (gnus-score-over-mark 130)
2346 (gnus-download-mark 131)
2347 (spec gnus-summary-line-format-spec)
2350 (gnus-set-work-buffer)
2351 (let ((gnus-summary-line-format-spec spec)
2352 (gnus-newsgroup-downloadable '((0 . t))))
2353 (gnus-summary-insert-line
2354 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2355 (goto-char (point-min))
2356 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2358 (goto-char (point-min))
2359 (push (cons 'replied (and (search-forward "\201" nil t)
2362 (goto-char (point-min))
2363 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2365 (goto-char (point-min))
2366 (push (cons 'download
2367 (and (search-forward "\203" nil t) (- (point) 2)))
2369 (setq gnus-summary-mark-positions pos))))
2371 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2372 "Insert a dummy root in the summary buffer."
2374 (gnus-add-text-properties
2375 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2376 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2378 (defun gnus-summary-insert-line (gnus-tmp-header
2379 gnus-tmp-level gnus-tmp-current
2380 gnus-tmp-unread gnus-tmp-replied
2381 gnus-tmp-expirable gnus-tmp-subject-or-nil
2382 &optional gnus-tmp-dummy gnus-tmp-score
2384 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2385 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2386 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2387 (gnus-tmp-score-char
2388 (if (or (null gnus-summary-default-score)
2389 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2390 gnus-summary-zcore-fuzz))
2392 (if (< gnus-tmp-score gnus-summary-default-score)
2393 gnus-score-below-mark gnus-score-over-mark)))
2395 (cond (gnus-tmp-process gnus-process-mark)
2396 ((memq gnus-tmp-current gnus-newsgroup-cached)
2398 (gnus-tmp-replied gnus-replied-mark)
2399 ((memq gnus-tmp-current gnus-newsgroup-saved)
2401 (t gnus-unread-mark)))
2402 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2405 ((string-match "<[^>]+> *$" gnus-tmp-from)
2406 (let ((beg (match-beginning 0)))
2407 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2408 (substring gnus-tmp-from (1+ (match-beginning 0))
2409 (1- (match-end 0))))
2410 (substring gnus-tmp-from 0 beg))))
2411 ((string-match "(.+)" gnus-tmp-from)
2412 (substring gnus-tmp-from
2413 (1+ (match-beginning 0)) (1- (match-end 0))))
2415 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2416 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2417 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2418 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2419 (buffer-read-only nil))
2420 (when (string= gnus-tmp-name "")
2421 (setq gnus-tmp-name gnus-tmp-from))
2422 (unless (numberp gnus-tmp-lines)
2423 (setq gnus-tmp-lines 0))
2424 (gnus-put-text-property-excluding-characters-with-faces
2426 (progn (eval gnus-summary-line-format-spec) (point))
2427 'gnus-number gnus-tmp-number)
2428 (when (gnus-visual-p 'summary-highlight 'highlight)
2430 (gnus-run-hooks 'gnus-summary-update-hook)
2433 (defun gnus-summary-update-line (&optional dont-update)
2434 ;; Update summary line after change.
2435 (when (and gnus-summary-default-score
2436 (not gnus-summary-inhibit-highlight))
2437 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2438 (article (gnus-summary-article-number))
2439 (score (gnus-summary-article-score article)))
2441 (if (and gnus-summary-mark-below
2442 (< (gnus-summary-article-score)
2443 gnus-summary-mark-below))
2444 ;; This article has a low score, so we mark it as read.
2445 (when (memq article gnus-newsgroup-unreads)
2446 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2447 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2448 ;; This article was previously marked as read on account
2449 ;; of a low score, but now it has risen, so we mark it as
2451 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2452 (gnus-summary-update-mark
2453 (if (or (null gnus-summary-default-score)
2454 (<= (abs (- score gnus-summary-default-score))
2455 gnus-summary-zcore-fuzz))
2457 (if (< score gnus-summary-default-score)
2458 gnus-score-below-mark gnus-score-over-mark))
2460 ;; Do visual highlighting.
2461 (when (gnus-visual-p 'summary-highlight 'highlight)
2462 (gnus-run-hooks 'gnus-summary-update-hook)))))
2464 (defvar gnus-tmp-new-adopts nil)
2466 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2467 "Return the number of articles in THREAD.
2468 This may be 0 in some cases -- if none of the articles in
2469 the thread are to be displayed."
2471 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2473 ((not (listp thread))
2475 ((and (consp thread) (cdr thread))
2478 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2481 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2484 (when (and level (zerop level) gnus-tmp-new-adopts)
2487 'gnus-summary-number-of-articles-in-thread
2488 gnus-tmp-new-adopts))))
2490 (if (> number 1) gnus-not-empty-thread-mark
2491 gnus-empty-thread-mark)
2494 (defun gnus-summary-set-local-parameters (group)
2495 "Go through the local params of GROUP and set all variable specs in that list."
2496 (let ((params (gnus-group-find-parameter group))
2499 (setq elem (car params)
2500 params (cdr params))
2501 (and (consp elem) ; Has to be a cons.
2502 (consp (cdr elem)) ; The cdr has to be a list.
2503 (symbolp (car elem)) ; Has to be a symbol in there.
2504 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2505 (ignore-errors ; So we set it.
2506 (make-local-variable (car elem))
2507 (set (car elem) (eval (nth 1 elem))))))))
2509 (defun gnus-summary-read-group (group &optional show-all no-article
2510 kill-buffer no-display backward
2512 "Start reading news in newsgroup GROUP.
2513 If SHOW-ALL is non-nil, already read articles are also listed.
2514 If NO-ARTICLE is non-nil, no article is selected initially.
2515 If NO-DISPLAY, don't generate a summary buffer."
2519 (let ((gnus-auto-select-next nil))
2520 (or (gnus-summary-read-group-1
2521 group show-all no-article
2522 kill-buffer no-display
2525 select-articles nil)))))
2526 (eq gnus-auto-select-next 'quietly))
2527 (set-buffer gnus-group-buffer)
2528 ;; The entry function called above goes to the next
2529 ;; group automatically, so we go two groups back
2530 ;; if we are searching for the previous group.
2532 (gnus-group-prev-unread-group 2))
2533 (if (not (equal group (gnus-group-group-name)))
2534 (setq group (gnus-group-group-name))
2538 (defun gnus-summary-read-group-1 (group show-all no-article
2539 kill-buffer no-display
2540 &optional select-articles)
2541 ;; Killed foreign groups can't be entered.
2542 (when (and (not (gnus-group-native-p group))
2543 (not (gnus-gethash group gnus-newsrc-hashtb)))
2544 (error "Dead non-native groups can't be entered"))
2545 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2546 (let* ((new-group (gnus-summary-setup-buffer group))
2547 (quit-config (gnus-group-quit-config group))
2548 (did-select (and new-group (gnus-select-newsgroup
2549 group show-all select-articles))))
2551 ;; This summary buffer exists already, so we just select it.
2553 (gnus-set-global-variables)
2555 (gnus-kill-or-deaden-summary kill-buffer))
2556 (gnus-configure-windows 'summary 'force)
2557 (gnus-set-mode-line 'summary)
2558 (gnus-summary-position-point)
2561 ;; We couldn't select this group.
2563 (when (and (eq major-mode 'gnus-summary-mode)
2564 (not (equal (current-buffer) kill-buffer)))
2565 (kill-buffer (current-buffer))
2566 (if (not quit-config)
2568 ;; Update the info -- marks might need to be removed,
2570 (gnus-summary-update-info)
2571 (set-buffer gnus-group-buffer)
2572 (gnus-group-jump-to-group group)
2573 (gnus-group-next-unread-group 1))
2574 (gnus-handle-ephemeral-exit quit-config)))
2575 (gnus-message 3 "Can't select group")
2577 ;; The user did a `C-g' while prompting for number of articles,
2578 ;; so we exit this group.
2579 ((eq did-select 'quit)
2580 (and (eq major-mode 'gnus-summary-mode)
2581 (not (equal (current-buffer) kill-buffer))
2582 (kill-buffer (current-buffer)))
2584 (gnus-kill-or-deaden-summary kill-buffer))
2585 (if (not quit-config)
2587 (set-buffer gnus-group-buffer)
2588 (gnus-group-jump-to-group group)
2589 (gnus-group-next-unread-group 1)
2590 (gnus-configure-windows 'group 'force))
2591 (gnus-handle-ephemeral-exit quit-config))
2592 ;; Finally signal the quit.
2594 ;; The group was successfully selected.
2596 (gnus-set-global-variables)
2597 ;; Save the active value in effect when the group was entered.
2598 (setq gnus-newsgroup-active
2600 (gnus-active gnus-newsgroup-name)))
2601 ;; You can change the summary buffer in some way with this hook.
2602 (gnus-run-hooks 'gnus-select-group-hook)
2603 ;; Set any local variables in the group parameters.
2604 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2605 (gnus-update-format-specifications
2606 nil 'summary 'summary-mode 'summary-dummy)
2607 ;; Do score processing.
2608 (when gnus-use-scoring
2609 (gnus-possibly-score-headers))
2610 ;; Check whether to fill in the gaps in the threads.
2611 (when gnus-build-sparse-threads
2612 (gnus-build-sparse-threads))
2613 ;; Find the initial limit.
2614 (if gnus-show-threads
2616 (let ((gnus-newsgroup-dormant nil))
2617 (gnus-summary-initial-limit show-all))
2618 (gnus-summary-initial-limit show-all))
2619 (setq gnus-newsgroup-limit
2621 (lambda (header) (mail-header-number header))
2622 gnus-newsgroup-headers)))
2623 ;; Generate the summary buffer.
2625 (gnus-summary-prepare))
2626 (when gnus-use-trees
2627 (gnus-tree-open group)
2628 (setq gnus-summary-highlight-line-function
2629 'gnus-tree-highlight-article))
2630 ;; If the summary buffer is empty, but there are some low-scored
2631 ;; articles or some excluded dormants, we include these in the
2633 (when (and (zerop (buffer-size))
2635 (cond (gnus-newsgroup-dormant
2636 (gnus-summary-limit-include-dormant))
2637 ((and gnus-newsgroup-scored show-all)
2638 (gnus-summary-limit-include-expunged t))))
2639 ;; Function `gnus-apply-kill-file' must be called in this hook.
2640 (gnus-run-hooks 'gnus-apply-kill-hook)
2641 (if (and (zerop (buffer-size))
2644 ;; This newsgroup is empty.
2645 (gnus-summary-catchup-and-exit nil t)
2646 (gnus-message 6 "No unread news")
2648 (gnus-kill-or-deaden-summary kill-buffer))
2649 ;; Return nil from this function.
2651 ;; Hide conversation thread subtrees. We cannot do this in
2652 ;; gnus-summary-prepare-hook since kill processing may not
2653 ;; work with hidden articles.
2654 (and gnus-show-threads
2655 gnus-thread-hide-subtree
2656 (gnus-summary-hide-all-threads))
2658 (gnus-kill-or-deaden-summary kill-buffer))
2659 ;; Show first unread article if requested.
2660 (if (and (not no-article)
2662 gnus-newsgroup-unreads
2663 gnus-auto-select-first)
2664 (unless (if (eq gnus-auto-select-first 'best)
2665 (gnus-summary-best-unread-article)
2666 (gnus-summary-first-unread-article))
2667 (gnus-configure-windows 'summary))
2668 ;; Don't select any articles, just move point to the first
2669 ;; article in the group.
2670 (goto-char (point-min))
2671 (gnus-summary-position-point)
2672 (gnus-configure-windows 'summary 'force)
2673 (gnus-set-mode-line 'summary))
2674 (when (get-buffer-window gnus-group-buffer t)
2675 ;; Gotta use windows, because recenter does weird stuff if
2676 ;; the current buffer ain't the displayed window.
2677 (let ((owin (selected-window)))
2678 (select-window (get-buffer-window gnus-group-buffer t))
2679 (when (gnus-group-goto-group group)
2681 (select-window owin)))
2682 ;; Mark this buffer as "prepared".
2683 (setq gnus-newsgroup-prepared t)
2684 (gnus-run-hooks 'gnus-summary-prepared-hook)
2687 (defun gnus-summary-prepare ()
2688 "Generate the summary buffer."
2690 (let ((buffer-read-only nil))
2692 (setq gnus-newsgroup-data nil
2693 gnus-newsgroup-data-reverse nil)
2694 (gnus-run-hooks 'gnus-summary-generate-hook)
2695 ;; Generate the buffer, either with threads or without.
2696 (when gnus-newsgroup-headers
2697 (gnus-summary-prepare-threads
2698 (if gnus-show-threads
2699 (gnus-sort-gathered-threads
2700 (funcall gnus-summary-thread-gathering-function
2702 (gnus-cut-threads (gnus-make-threads)))))
2703 ;; Unthreaded display.
2704 (gnus-sort-articles gnus-newsgroup-headers))))
2705 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2706 ;; Call hooks for modifying summary buffer.
2707 (goto-char (point-min))
2708 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2710 (defsubst gnus-general-simplify-subject (subject)
2711 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2714 ;; Truncate the subject.
2715 (gnus-simplify-subject-functions
2716 (gnus-map-function gnus-simplify-subject-functions subject))
2717 ((numberp gnus-summary-gather-subject-limit)
2718 (setq subject (gnus-simplify-subject-re subject))
2719 (if (> (length subject) gnus-summary-gather-subject-limit)
2720 (substring subject 0 gnus-summary-gather-subject-limit)
2722 ;; Fuzzily simplify it.
2723 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2724 (gnus-simplify-subject-fuzzy subject))
2725 ;; Just remove the leading "Re:".
2727 (gnus-simplify-subject-re subject))))
2729 (if (and gnus-summary-gather-exclude-subject
2730 (string-match gnus-summary-gather-exclude-subject subject))
2731 nil ; This article shouldn't be gathered
2734 (defun gnus-summary-simplify-subject-query ()
2735 "Query where the respool algorithm would put this article."
2737 (gnus-summary-select-article)
2738 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2740 (defun gnus-gather-threads-by-subject (threads)
2741 "Gather threads by looking at Subject headers."
2742 (if (not gnus-summary-make-false-root)
2744 (let ((hashtb (gnus-make-hashtable 1024))
2747 subject hthread whole-subject)
2749 (setq subject (gnus-general-simplify-subject
2750 (setq whole-subject (mail-header-subject
2753 (if (setq hthread (gnus-gethash subject hashtb))
2755 ;; We enter a dummy root into the thread, if we
2756 ;; haven't done that already.
2757 (unless (stringp (caar hthread))
2758 (setcar hthread (list whole-subject (car hthread))))
2759 ;; We add this new gathered thread to this gathered
2761 (setcdr (car hthread)
2762 (nconc (cdar hthread) (list (car threads))))
2763 ;; Remove it from the list of threads.
2764 (setcdr prev (cdr threads))
2765 (setq threads prev))
2766 ;; Enter this thread into the hash table.
2767 (gnus-sethash subject threads hashtb)))
2769 (setq threads (cdr threads)))
2772 (defun gnus-gather-threads-by-references (threads)
2773 "Gather threads by looking at References headers."
2774 (let ((idhashtb (gnus-make-hashtable 1024))
2775 (thhashtb (gnus-make-hashtable 1024))
2778 ids references id gthread gid entered ref)
2780 (when (setq references (mail-header-references (caar threads)))
2781 (setq id (mail-header-id (caar threads))
2782 ids (gnus-split-references references)
2784 (while (setq ref (pop ids))
2785 (setq ids (delete ref ids))
2786 (if (not (setq gid (gnus-gethash ref idhashtb)))
2788 (gnus-sethash ref id idhashtb)
2789 (gnus-sethash id threads thhashtb))
2790 (setq gthread (gnus-gethash gid thhashtb))
2792 ;; We enter a dummy root into the thread, if we
2793 ;; haven't done that already.
2794 (unless (stringp (caar gthread))
2795 (setcar gthread (list (mail-header-subject (caar gthread))
2797 ;; We add this new gathered thread to this gathered
2799 (setcdr (car gthread)
2800 (nconc (cdar gthread) (list (car threads)))))
2801 ;; Add it into the thread hash table.
2802 (gnus-sethash id gthread thhashtb)
2804 ;; Remove it from the list of threads.
2805 (setcdr prev (cdr threads))
2806 (setq threads prev))))
2808 (setq threads (cdr threads)))
2811 (defun gnus-sort-gathered-threads (threads)
2812 "Sort subtreads inside each gathered thread by article number."
2813 (let ((result threads))
2815 (when (stringp (caar threads))
2816 (setcdr (car threads)
2817 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2818 (setq threads (cdr threads)))
2821 (defun gnus-thread-loop-p (root thread)
2822 "Say whether ROOT is in THREAD."
2823 (let ((stack (list thread))
2826 (while (setq thread (pop stack))
2827 (setq th (cdr thread))
2829 (not (eq (caar th) root)))
2832 ;; We have found a loop.
2834 (setcdr thread (delq (car th) (cdr thread)))
2835 (if (boundp (setq ref-dep (intern "none"
2836 gnus-newsgroup-dependencies)))
2837 (setcdr (symbol-value ref-dep)
2838 (nconc (cdr (symbol-value ref-dep))
2840 (set ref-dep (list nil (car th))))
2843 ;; Push all the subthreads onto the stack.
2844 (push (cdr thread) stack)))
2847 (defun gnus-make-threads ()
2848 "Go through the dependency hashtb and find the roots. Return all threads."
2850 (while (catch 'infloop
2853 ;; Deal with self-referencing References loops.
2854 (when (and (car (symbol-value refs))
2861 (car (symbol-value refs)) thread))
2862 (cdr (symbol-value refs)))))))
2865 (unless (car (symbol-value refs))
2866 ;; These threads do not refer back to any other articles,
2867 ;; so they're roots.
2868 (setq threads (append (cdr (symbol-value refs)) threads))))
2869 gnus-newsgroup-dependencies)))
2872 ;; Build the thread tree.
2873 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2874 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2876 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2877 if it was already present.
2879 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2880 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2881 Message-IDs will be renamed be renamed to a unique Message-ID before
2884 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2885 (let* ((id (mail-header-id header))
2886 (id-dep (and id (intern id dependencies)))
2887 ref ref-dep ref-header)
2888 ;; Enter this `header' in the `dependencies' table.
2892 ;; The first two cases do the normal part: enter a new `header'
2893 ;; in the `dependencies' table.
2894 ((not (boundp id-dep))
2895 (set id-dep (list header)))
2896 ((null (car (symbol-value id-dep)))
2897 (setcar (symbol-value id-dep) header))
2899 ;; From here the `header' was already present in the
2900 ;; `dependencies' table.
2902 ;; Overrides an existing entry;
2903 ;; just set the header part of the entry.
2904 (setcar (symbol-value id-dep) header))
2906 ;; Renames the existing `header' to a unique Message-ID.
2907 ((not gnus-summary-ignore-duplicates)
2908 ;; An article with this Message-ID has already been seen.
2909 ;; We rename the Message-ID.
2910 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2912 (mail-header-set-id header id))
2914 ;; The last case ignores an existing entry, except it adds any
2915 ;; additional Xrefs (in case the two articles came from different
2917 ;; Also sets `header' to `nil' meaning that the `dependencies'
2918 ;; table was *not* modified.
2920 (mail-header-set-xref
2921 (car (symbol-value id-dep))
2922 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2924 (or (mail-header-xref header) "")))
2928 ;; First check if that we are not creating a References loop.
2929 (setq ref (gnus-parent-id (mail-header-references header)))
2931 (setq ref-dep (intern-soft ref dependencies))
2933 (setq ref-header (car (symbol-value ref-dep))))
2934 (if (string= id ref)
2935 ;; Yuk! This is a reference loop. Make the article be a
2938 (mail-header-set-references (car (symbol-value id-dep)) "none")
2940 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2941 (setq ref (gnus-parent-id (mail-header-references header)))
2942 (setq ref-dep (intern (or ref "none") dependencies))
2943 (if (boundp ref-dep)
2944 (setcdr (symbol-value ref-dep)
2945 (nconc (cdr (symbol-value ref-dep))
2946 (list (symbol-value id-dep))))
2947 (set ref-dep (list nil (symbol-value id-dep)))))
2950 (defun gnus-build-sparse-threads ()
2951 (let ((headers gnus-newsgroup-headers)
2952 (gnus-summary-ignore-duplicates t)
2953 header references generation relations
2954 subject child end new-child date)
2955 ;; First we create an alist of generations/relations, where
2956 ;; generations is how much we trust the relation, and the relation
2958 (gnus-message 7 "Making sparse threads...")
2960 (nnheader-set-temp-buffer " *gnus sparse threads*")
2961 (while (setq header (pop headers))
2962 (when (and (setq references (mail-header-references header))
2963 (not (string= references "")))
2965 (setq child (mail-header-id header)
2966 subject (mail-header-subject header)
2967 date (mail-header-date header)
2969 (while (search-backward ">" nil t)
2970 (setq end (1+ (point)))
2971 (when (search-backward "<" nil t)
2972 (setq new-child (buffer-substring (point) end))
2973 (push (list (incf generation)
2974 child (setq child new-child)
2978 (push (list (1+ generation) child nil subject) relations))
2980 (kill-buffer (current-buffer)))
2981 ;; Sort over trustworthiness.
2984 (when (gnus-dependencies-add-header
2985 (make-full-mail-header
2986 gnus-reffed-article-number
2987 (nth 3 relation) "" (or (nth 4 relation) "")
2989 (or (nth 2 relation) "") 0 0 "")
2990 gnus-newsgroup-dependencies nil)
2991 (push gnus-reffed-article-number gnus-newsgroup-limit)
2992 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2993 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2994 gnus-newsgroup-reads)
2995 (decf gnus-reffed-article-number)))
2996 (sort relations 'car-less-than-car))
2997 (gnus-message 7 "Making sparse threads...done")))
2999 (defun gnus-build-old-threads ()
3000 ;; Look at all the articles that refer back to old articles, and
3001 ;; fetch the headers for the articles that aren't there. This will
3002 ;; build complete threads - if the roots haven't been expired by the
3007 (when (not (car (symbol-value refs)))
3008 (setq heads (cdr (symbol-value refs)))
3010 (if (memq (mail-header-number (caar heads))
3011 gnus-newsgroup-dormant)
3012 (setq heads (cdr heads))
3013 (setq id (symbol-name refs))
3014 (while (and (setq id (gnus-build-get-header id))
3015 (not (car (gnus-id-to-thread id)))))
3016 (setq heads nil)))))
3017 gnus-newsgroup-dependencies)))
3019 ;; The following macros and functions were written by Felix Lee
3020 ;; <flee@cse.psu.edu>.
3022 (defmacro gnus-nov-read-integer ()
3024 (if (= (following-char) ?\t)
3026 (let ((num (ignore-errors (read buffer))))
3027 (if (numberp num) num 0)))
3029 (search-forward "\t" eol 'move))))
3031 (defmacro gnus-nov-skip-field ()
3032 '(search-forward "\t" eol 'move))
3034 (defmacro gnus-nov-field ()
3035 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3037 ;; This function has to be called with point after the article number
3038 ;; on the beginning of the line.
3039 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3040 (let ((eol (gnus-point-at-eol))
3041 (buffer (current-buffer))
3044 ;; overview: [num subject from date id refs chars lines misc]
3047 (narrow-to-region (point) eol)
3052 (make-full-mail-header
3054 (rfc2047-decode-string (gnus-nov-field)) ; subject
3055 (rfc2047-decode-string (gnus-nov-field)) ; from
3056 (gnus-nov-field) ; date
3057 (or (gnus-nov-field)
3058 (nnheader-generate-fake-message-id)) ; id
3059 (gnus-nov-field) ; refs
3060 (gnus-nov-read-integer) ; chars
3061 (gnus-nov-read-integer) ; lines
3062 (unless (= (following-char) ?\n)
3063 (gnus-nov-field))))) ; misc
3067 (when gnus-alter-header-function
3068 (funcall gnus-alter-header-function header))
3069 (gnus-dependencies-add-header header dependencies force-new)))
3071 (defun gnus-build-get-header (id)
3072 ;; Look through the buffer of NOV lines and find the header to
3073 ;; ID. Enter this line into the dependencies hash table, and return
3074 ;; the id of the parent article (if any).
3075 (let ((deps gnus-newsgroup-dependencies)
3079 (set-buffer nntp-server-buffer)
3080 (let ((case-fold-search nil))
3081 (goto-char (point-min))
3082 (while (and (not found)
3083 (search-forward id nil t))
3085 (setq found (looking-at
3086 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3087 (regexp-quote id))))
3088 (or found (beginning-of-line 2)))
3092 (setq header (gnus-nov-parse-line
3093 (read (current-buffer)) deps))
3094 (gnus-parent-id (mail-header-references header))))))
3096 (let ((number (mail-header-number header)))
3097 (push number gnus-newsgroup-limit)
3098 (push header gnus-newsgroup-headers)
3099 (if (memq number gnus-newsgroup-unselected)
3101 (push number gnus-newsgroup-unreads)
3102 (setq gnus-newsgroup-unselected
3103 (delq number gnus-newsgroup-unselected)))
3104 (push number gnus-newsgroup-ancient)))))))
3106 (defun gnus-build-all-threads ()
3107 "Read all the headers."
3108 (let ((gnus-summary-ignore-duplicates t)
3109 (dependencies gnus-newsgroup-dependencies)
3112 (set-buffer nntp-server-buffer)
3113 (let ((case-fold-search nil))
3114 (goto-char (point-min))
3117 (setq article (read (current-buffer))
3118 header (gnus-nov-parse-line
3119 article dependencies)))
3122 (set-buffer gnus-summary-buffer)
3123 (push header gnus-newsgroup-headers)
3124 (if (memq (setq article (mail-header-number header))
3125 gnus-newsgroup-unselected)
3127 (push article gnus-newsgroup-unreads)
3128 (setq gnus-newsgroup-unselected
3129 (delq article gnus-newsgroup-unselected)))
3130 (push article gnus-newsgroup-ancient)))
3131 (forward-line 1)))))))
3133 (defun gnus-summary-update-article-line (article header)
3134 "Update the line for ARTICLE using HEADERS."
3135 (let* ((id (mail-header-id header))
3136 (thread (gnus-id-to-thread id)))
3138 (error "Article in no thread"))
3139 ;; Update the thread.
3140 (setcar thread header)
3141 (gnus-summary-goto-subject article)
3142 (let* ((datal (gnus-data-find-list article))
3144 (length (when (cdr datal)
3145 (- (gnus-data-pos data)
3146 (gnus-data-pos (cadr datal)))))
3147 (buffer-read-only nil)
3148 (level (gnus-summary-thread-level)))
3150 (gnus-summary-insert-line
3151 header level nil (gnus-article-mark article)
3152 (memq article gnus-newsgroup-replied)
3153 (memq article gnus-newsgroup-expirable)
3154 ;; Only insert the Subject string when it's different
3155 ;; from the previous Subject string.
3156 (if (gnus-subject-equal
3158 (mail-header-subject
3161 (gnus-data-find-list
3163 (gnus-data-list t)))))
3164 ;; Error on the side of excessive subjects.
3166 (mail-header-subject header))
3168 (mail-header-subject header))
3169 nil (cdr (assq article gnus-newsgroup-scored))
3170 (memq article gnus-newsgroup-processable))
3172 (gnus-data-update-list
3173 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3175 (defun gnus-summary-update-article (article &optional iheader)
3176 "Update ARTICLE in the summary buffer."
3177 (set-buffer gnus-summary-buffer)
3178 (let* ((header (gnus-summary-article-header article))
3179 (id (mail-header-id header))
3180 (data (gnus-data-find article))
3181 (thread (gnus-id-to-thread id))
3182 (references (mail-header-references header))
3186 (when (and references
3187 (not (equal "" references)))
3190 (buffer-read-only nil)
3196 (delq thread parent)))
3197 (if (gnus-summary-insert-subject id header)
3198 ;; Set the (possibly) new article number in the data structure.
3199 (gnus-data-set-number data (gnus-id-to-article id))
3203 (defun gnus-rebuild-thread (id &optional line)
3204 "Rebuild the thread containing ID.
3205 If LINE, insert the rebuilt thread starting on line LINE."
3206 (let ((buffer-read-only nil)
3207 old-pos current thread data)
3208 (if (not gnus-show-threads)
3209 (setq thread (list (car (gnus-id-to-thread id))))
3210 ;; Get the thread this article is part of.
3211 (setq thread (gnus-remove-thread id)))
3212 (setq old-pos (gnus-point-at-bol))
3213 (setq current (save-excursion
3214 (and (zerop (forward-line -1))
3215 (gnus-summary-article-number))))
3216 ;; If this is a gathered thread, we have to go some re-gathering.
3217 (when (stringp (car thread))
3218 (let ((subject (car thread))
3220 (setq thread (cdr thread))
3222 (unless (memq (setq thr (gnus-id-to-thread
3224 (mail-header-id (caar thread)))))
3227 (setq thread (cdr thread)))
3228 ;; We now have all (unique) roots.
3229 (if (= (length roots) 1)
3230 ;; All the loose roots are now one solid root.
3231 (setq thread (car roots))
3232 (setq thread (cons subject (gnus-sort-threads roots))))))
3234 ;; We then insert this thread into the summary buffer.
3236 (goto-char (point-min))
3237 (forward-line (1- line)))
3238 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3239 (if gnus-show-threads
3240 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3241 (gnus-summary-prepare-unthreaded thread))
3242 (setq data (nreverse gnus-newsgroup-data))
3243 (setq threads gnus-newsgroup-threads))
3244 ;; We splice the new data into the data structure.
3245 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3246 ;;!!! then we want to insert at the beginning of the buffer.
3247 ;;!!! That happens to be true with Gnus now, but that may
3248 ;;!!! change in the future. Perhaps.
3249 (gnus-data-enter-list
3250 (if line nil current) data (- (point) old-pos))
3251 (setq gnus-newsgroup-threads
3252 (nconc threads gnus-newsgroup-threads))
3253 (gnus-data-compute-positions))))
3255 (defun gnus-number-to-header (number)
3256 "Return the header for article NUMBER."
3257 (let ((headers gnus-newsgroup-headers))
3259 (not (= number (mail-header-number (car headers)))))
3264 (defun gnus-parent-headers (in-headers &optional generation)
3265 "Return the headers of the GENERATIONeth parent of HEADERS."
3267 (setq generation 1))
3269 (headers in-headers)
3272 (not (zerop generation))
3273 (setq references (mail-header-references headers)))
3274 (setq headers (if (and references
3275 (setq parent (gnus-parent-id references)))
3276 (car (gnus-id-to-thread parent))
3279 (and (not (eq headers in-headers))
3282 (defun gnus-id-to-thread (id)
3283 "Return the (sub-)thread where ID appears."
3284 (gnus-gethash id gnus-newsgroup-dependencies))
3286 (defun gnus-id-to-article (id)
3287 "Return the article number of ID."
3288 (let ((thread (gnus-id-to-thread id)))
3291 (mail-header-number (car thread)))))
3293 (defun gnus-id-to-header (id)
3294 "Return the article headers of ID."
3295 (car (gnus-id-to-thread id)))
3297 (defun gnus-article-displayed-root-p (article)
3298 "Say whether ARTICLE is a root(ish) article."
3299 (let ((level (gnus-summary-thread-level article))
3300 (refs (mail-header-references (gnus-summary-article-header article)))
3306 ((null (gnus-parent-id refs)) t)
3308 (null (setq particle (gnus-id-to-article
3309 (gnus-parent-id refs))))
3310 (null (gnus-summary-thread-level particle)))))))
3312 (defun gnus-root-id (id)
3313 "Return the id of the root of the thread where ID appears."
3315 (while (and id (setq prev (car (gnus-id-to-thread id))))
3317 id (gnus-parent-id (mail-header-references prev))))
3320 (defun gnus-articles-in-thread (thread)
3321 "Return the list of articles in THREAD."
3322 (cons (mail-header-number (car thread))
3323 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3325 (defun gnus-remove-thread (id &optional dont-remove)
3326 "Remove the thread that has ID in it."
3327 (let (headers thread last-id)
3328 ;; First go up in this thread until we find the root.
3329 (setq last-id (gnus-root-id id)
3330 headers (message-flatten-list (gnus-id-to-thread last-id)))
3331 ;; We have now found the real root of this thread. It might have
3332 ;; been gathered into some loose thread, so we have to search
3333 ;; through the threads to find the thread we wanted.
3334 (let ((threads gnus-newsgroup-threads)
3337 (setq sub (car threads))
3338 (if (stringp (car sub))
3339 ;; This is a gathered thread, so we look at the roots
3340 ;; below it to find whether this article is in this
3343 (setq sub (cdr sub))
3345 (when (member (caar sub) headers)
3346 (setq thread (car threads)
3349 (setq sub (cdr sub))))
3350 ;; It's an ordinary thread, so we check it.
3351 (when (eq (car sub) (car headers))
3354 (setq threads (cdr threads)))
3355 ;; If this article is in no thread, then it's a root.
3358 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3359 (setq thread (gnus-id-to-thread last-id)))
3362 thread ; We return this thread.
3364 (if (stringp (car thread))
3366 ;; If we use dummy roots, then we have to remove the
3367 ;; dummy root as well.
3368 (when (eq gnus-summary-make-false-root 'dummy)
3369 ;; We go to the dummy root by going to
3370 ;; the first sub-"thread", and then one line up.
3371 (gnus-summary-goto-article
3372 (mail-header-number (caadr thread)))
3375 (gnus-data-compute-positions))
3376 (setq thread (cdr thread))
3378 (gnus-remove-thread-1 (car thread))
3379 (setq thread (cdr thread))))
3380 (gnus-summary-show-all-threads)
3381 (gnus-remove-thread-1 thread))))))))
3383 (defun gnus-remove-thread-1 (thread)
3384 "Remove the thread THREAD recursively."
3385 (let ((number (mail-header-number (pop thread)))
3387 (setq thread (reverse thread))
3389 (gnus-remove-thread-1 (pop thread)))
3390 (when (setq d (gnus-data-find number))
3391 (goto-char (gnus-data-pos d))
3394 (- (gnus-point-at-bol)
3396 (1+ (gnus-point-at-eol))
3397 (gnus-delete-line)))))))
3399 (defun gnus-sort-threads (threads)
3401 (if (not gnus-thread-sort-functions)
3403 (gnus-message 8 "Sorting threads...")
3405 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3406 (gnus-message 8 "Sorting threads...done"))))
3408 (defun gnus-sort-articles (articles)
3410 (when gnus-article-sort-functions
3411 (gnus-message 7 "Sorting articles...")
3413 (setq gnus-newsgroup-headers
3414 (sort articles (gnus-make-sort-function
3415 gnus-article-sort-functions)))
3416 (gnus-message 7 "Sorting articles...done"))))
3418 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3419 (defmacro gnus-thread-header (thread)
3420 ;; Return header of first article in THREAD.
3421 ;; Note that THREAD must never, ever be anything else than a variable -
3422 ;; using some other form will lead to serious barfage.
3423 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3424 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3425 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3428 (defsubst gnus-article-sort-by-number (h1 h2)
3429 "Sort articles by article number."
3430 (< (mail-header-number h1)
3431 (mail-header-number h2)))
3433 (defun gnus-thread-sort-by-number (h1 h2)
3434 "Sort threads by root article number."
3435 (gnus-article-sort-by-number
3436 (gnus-thread-header h1) (gnus-thread-header h2)))
3438 (defsubst gnus-article-sort-by-lines (h1 h2)
3439 "Sort articles by article Lines header."
3440 (< (mail-header-lines h1)
3441 (mail-header-lines h2)))
3443 (defun gnus-thread-sort-by-lines (h1 h2)
3444 "Sort threads by root article Lines header."
3445 (gnus-article-sort-by-lines
3446 (gnus-thread-header h1) (gnus-thread-header h2)))
3448 (defsubst gnus-article-sort-by-author (h1 h2)
3449 "Sort articles by root author."
3451 (let ((extract (funcall
3452 gnus-extract-address-components
3453 (mail-header-from h1))))
3454 (or (car extract) (cadr extract) ""))
3455 (let ((extract (funcall
3456 gnus-extract-address-components
3457 (mail-header-from h2))))
3458 (or (car extract) (cadr extract) ""))))
3460 (defun gnus-thread-sort-by-author (h1 h2)
3461 "Sort threads by root author."
3462 (gnus-article-sort-by-author
3463 (gnus-thread-header h1) (gnus-thread-header h2)))
3465 (defsubst gnus-article-sort-by-subject (h1 h2)
3466 "Sort articles by root subject."
3468 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3469 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3471 (defun gnus-thread-sort-by-subject (h1 h2)
3472 "Sort threads by root subject."
3473 (gnus-article-sort-by-subject
3474 (gnus-thread-header h1) (gnus-thread-header h2)))
3476 (defsubst gnus-article-sort-by-date (h1 h2)
3477 "Sort articles by root article date."
3479 (gnus-date-get-time (mail-header-date h1))
3480 (gnus-date-get-time (mail-header-date h2))))
3482 (defun gnus-thread-sort-by-date (h1 h2)
3483 "Sort threads by root article date."
3484 (gnus-article-sort-by-date
3485 (gnus-thread-header h1) (gnus-thread-header h2)))
3487 (defsubst gnus-article-sort-by-score (h1 h2)
3488 "Sort articles by root article score.
3489 Unscored articles will be counted as having a score of zero."
3490 (> (or (cdr (assq (mail-header-number h1)
3491 gnus-newsgroup-scored))
3492 gnus-summary-default-score 0)
3493 (or (cdr (assq (mail-header-number h2)
3494 gnus-newsgroup-scored))
3495 gnus-summary-default-score 0)))
3497 (defun gnus-thread-sort-by-score (h1 h2)
3498 "Sort threads by root article score."
3499 (gnus-article-sort-by-score
3500 (gnus-thread-header h1) (gnus-thread-header h2)))
3502 (defun gnus-thread-sort-by-total-score (h1 h2)
3503 "Sort threads by the sum of all scores in the thread.
3504 Unscored articles will be counted as having a score of zero."
3505 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3507 (defun gnus-thread-total-score (thread)
3508 ;; This function find the total score of THREAD.
3509 (cond ((null thread)
3512 (if (stringp (car thread))
3513 (apply gnus-thread-score-function 0
3514 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3515 (gnus-thread-total-score-1 thread)))
3517 (gnus-thread-total-score-1 (list thread)))))
3519 (defun gnus-thread-total-score-1 (root)
3520 ;; This function find the total score of the thread below ROOT.
3521 (setq root (car root))
3522 (apply gnus-thread-score-function
3524 (mapcar 'gnus-thread-total-score
3525 (cdr (gnus-id-to-thread (mail-header-id root))))
3526 (when (> (mail-header-number root) 0)
3527 (list (or (cdr (assq (mail-header-number root)
3528 gnus-newsgroup-scored))
3529 gnus-summary-default-score 0))))
3530 (list gnus-summary-default-score)
3533 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3534 (defvar gnus-tmp-prev-subject nil)
3535 (defvar gnus-tmp-false-parent nil)
3536 (defvar gnus-tmp-root-expunged nil)
3537 (defvar gnus-tmp-dummy-line nil)
3539 (defun gnus-summary-prepare-threads (threads)
3540 "Prepare summary buffer from THREADS and indentation LEVEL.
3541 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3542 or a straight list of headers."
3543 (gnus-message 7 "Generating summary...")
3545 (setq gnus-newsgroup-threads threads)
3548 (let ((gnus-tmp-level 0)
3549 (default-score (or gnus-summary-default-score 0))
3550 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3551 thread number subject stack state gnus-tmp-gathered beg-match
3552 new-roots gnus-tmp-new-adopts thread-end
3553 gnus-tmp-header gnus-tmp-unread
3554 gnus-tmp-replied gnus-tmp-subject-or-nil
3555 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3556 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3557 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3559 (setq gnus-tmp-prev-subject nil)
3561 (if (vectorp (car threads))
3562 ;; If this is a straight (sic) list of headers, then a
3563 ;; threaded summary display isn't required, so we just create
3564 ;; an unthreaded one.
3565 (gnus-summary-prepare-unthreaded threads)
3567 ;; Do the threaded display.
3569 (while (or threads stack gnus-tmp-new-adopts new-roots)
3571 (if (and (= gnus-tmp-level 0)
3574 (not gnus-tmp-false-parent)
3575 (or gnus-tmp-new-adopts new-roots))
3576 (if gnus-tmp-new-adopts
3577 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3578 thread (list (car gnus-tmp-new-adopts))
3579 gnus-tmp-header (caar thread)
3580 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3582 (setq thread (list (car new-roots))
3583 gnus-tmp-header (caar thread)
3584 new-roots (cdr new-roots))))
3587 ;; If there are some threads, we do them before the
3588 ;; threads on the stack.
3589 (setq thread threads
3590 gnus-tmp-header (caar thread))
3591 ;; There were no current threads, so we pop something off
3593 (setq state (car stack)
3594 gnus-tmp-level (car state)
3597 gnus-tmp-header (caar thread))))
3599 (setq gnus-tmp-false-parent nil)
3600 (setq gnus-tmp-root-expunged nil)
3601 (setq thread-end nil)
3603 (if (stringp gnus-tmp-header)
3604 ;; The header is a dummy root.
3606 ((eq gnus-summary-make-false-root 'adopt)
3607 ;; We let the first article adopt the rest.
3608 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3610 (setq gnus-tmp-gathered
3612 (lambda (h) (mail-header-number (car h)))
3615 (setq thread (cons (list (caar thread)
3618 (setq gnus-tmp-level -1
3619 gnus-tmp-false-parent t))
3620 ((eq gnus-summary-make-false-root 'empty)
3621 ;; We print adopted articles with empty subject fields.
3622 (setq gnus-tmp-gathered
3624 (lambda (h) (mail-header-number (car h)))
3627 (setq gnus-tmp-level -1))
3628 ((eq gnus-summary-make-false-root 'dummy)
3629 ;; We remember that we probably want to output a dummy
3631 (setq gnus-tmp-dummy-line gnus-tmp-header)
3632 (setq gnus-tmp-prev-subject gnus-tmp-header))
3634 ;; We do not make a root for the gathered
3635 ;; sub-threads at all.
3636 (setq gnus-tmp-level -1)))
3638 (setq number (mail-header-number gnus-tmp-header)
3639 subject (mail-header-subject gnus-tmp-header))
3642 ;; If the thread has changed subject, we might want to make
3643 ;; this subthread into a root.
3644 ((and (null gnus-thread-ignore-subject)
3645 (not (zerop gnus-tmp-level))
3646 gnus-tmp-prev-subject
3648 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3649 (setq new-roots (nconc new-roots (list (car thread)))
3651 gnus-tmp-header nil))
3652 ;; If the article lies outside the current limit,
3653 ;; then we do not display it.
3654 ((not (memq number gnus-newsgroup-limit))
3655 (setq gnus-tmp-gathered
3657 (lambda (h) (mail-header-number (car h)))
3660 (setq gnus-tmp-new-adopts (if (cdar thread)
3661 (append gnus-tmp-new-adopts
3663 gnus-tmp-new-adopts)
3665 gnus-tmp-header nil)
3666 (when (zerop gnus-tmp-level)
3667 (setq gnus-tmp-root-expunged t)))
3668 ;; Perhaps this article is to be marked as read?
3669 ((and gnus-summary-mark-below
3670 (< (or (cdr (assq number gnus-newsgroup-scored))
3672 gnus-summary-mark-below)
3673 ;; Don't touch sparse articles.
3674 (not (gnus-summary-article-sparse-p number))
3675 (not (gnus-summary-article-ancient-p number)))
3676 (setq gnus-newsgroup-unreads
3677 (delq number gnus-newsgroup-unreads))
3678 (if gnus-newsgroup-auto-expire
3679 (push number gnus-newsgroup-expirable)
3680 (push (cons number gnus-low-score-mark)
3681 gnus-newsgroup-reads))))
3683 (when gnus-tmp-header
3684 ;; We may have an old dummy line to output before this
3686 (when (and gnus-tmp-dummy-line
3689 (mail-header-subject gnus-tmp-header)))
3690 (gnus-summary-insert-dummy-line
3691 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3692 (setq gnus-tmp-dummy-line nil))
3694 ;; Compute the mark.
3695 (setq gnus-tmp-unread (gnus-article-mark number))
3697 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3698 gnus-tmp-header gnus-tmp-level)
3699 gnus-newsgroup-data)
3701 ;; Actually insert the line.
3703 gnus-tmp-subject-or-nil
3705 ((and gnus-thread-ignore-subject
3706 gnus-tmp-prev-subject
3707 (not (inline (gnus-subject-equal
3708 gnus-tmp-prev-subject subject))))
3710 ((zerop gnus-tmp-level)
3711 (if (and (eq gnus-summary-make-false-root 'empty)
3712 (memq number gnus-tmp-gathered)
3713 gnus-tmp-prev-subject
3714 (inline (gnus-subject-equal
3715 gnus-tmp-prev-subject subject)))
3716 gnus-summary-same-subject
3718 (t gnus-summary-same-subject)))
3719 (if (and (eq gnus-summary-make-false-root 'adopt)
3720 (= gnus-tmp-level 1)
3721 (memq number gnus-tmp-gathered))
3722 (setq gnus-tmp-opening-bracket ?\<
3723 gnus-tmp-closing-bracket ?\>)
3724 (setq gnus-tmp-opening-bracket ?\[
3725 gnus-tmp-closing-bracket ?\]))
3727 gnus-tmp-indentation
3728 (aref gnus-thread-indent-array gnus-tmp-level)
3729 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3730 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3731 gnus-summary-default-score 0)
3733 (if (or (null gnus-summary-default-score)
3734 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3735 gnus-summary-zcore-fuzz))
3737 (if (< gnus-tmp-score gnus-summary-default-score)
3738 gnus-score-below-mark gnus-score-over-mark))
3740 (cond ((memq number gnus-newsgroup-processable)
3742 ((memq number gnus-newsgroup-cached)
3744 ((memq number gnus-newsgroup-replied)
3746 ((memq number gnus-newsgroup-saved)
3748 (t gnus-unread-mark))
3749 gnus-tmp-from (mail-header-from gnus-tmp-header)
3752 ((string-match "<[^>]+> *$" gnus-tmp-from)
3753 (setq beg-match (match-beginning 0))
3754 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3755 (substring gnus-tmp-from (1+ (match-beginning 0))
3756 (1- (match-end 0))))
3757 (substring gnus-tmp-from 0 beg-match)))
3758 ((string-match "(.+)" gnus-tmp-from)
3759 (substring gnus-tmp-from
3760 (1+ (match-beginning 0)) (1- (match-end 0))))
3762 (when (string= gnus-tmp-name "")
3763 (setq gnus-tmp-name gnus-tmp-from))
3764 (unless (numberp gnus-tmp-lines)
3765 (setq gnus-tmp-lines 0))
3766 (gnus-put-text-property-excluding-characters-with-faces
3768 (progn (eval gnus-summary-line-format-spec) (point))
3769 'gnus-number number)
3772 (gnus-run-hooks 'gnus-summary-update-hook)
3775 (setq gnus-tmp-prev-subject subject)))
3777 (when (nth 1 thread)
3778 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3779 (incf gnus-tmp-level)
3780 (setq threads (if thread-end nil (cdar thread)))
3782 (setq gnus-tmp-level 0)))))
3783 (gnus-message 7 "Generating summary...done"))
3785 (defun gnus-summary-prepare-unthreaded (headers)
3786 "Generate an unthreaded summary buffer based on HEADERS."
3787 (let (header number mark)
3792 ;; We may have to root out some bad articles...
3793 (when (memq (setq number (mail-header-number
3794 (setq header (pop headers))))
3795 gnus-newsgroup-limit)
3796 ;; Mark article as read when it has a low score.
3797 (when (and gnus-summary-mark-below
3798 (< (or (cdr (assq number gnus-newsgroup-scored))
3799 gnus-summary-default-score 0)
3800 gnus-summary-mark-below)
3801 (not (gnus-summary-article-ancient-p number)))
3802 (setq gnus-newsgroup-unreads
3803 (delq number gnus-newsgroup-unreads))
3804 (if gnus-newsgroup-auto-expire
3805 (push number gnus-newsgroup-expirable)
3806 (push (cons number gnus-low-score-mark)
3807 gnus-newsgroup-reads)))
3809 (setq mark (gnus-article-mark number))
3810 (push (gnus-data-make number mark (1+ (point)) header 0)
3811 gnus-newsgroup-data)
3812 (gnus-summary-insert-line
3814 mark (memq number gnus-newsgroup-replied)
3815 (memq number gnus-newsgroup-expirable)
3816 (mail-header-subject header) nil
3817 (cdr (assq number gnus-newsgroup-scored))
3818 (memq number gnus-newsgroup-processable))))))
3820 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3821 "Select newsgroup GROUP.
3822 If READ-ALL is non-nil, all articles in the group are selected.
3823 If SELECT-ARTICLES, only select those articles from GROUP."
3824 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3825 ;;!!! Dirty hack; should be removed.
3826 (gnus-summary-ignore-duplicates
3827 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3829 gnus-summary-ignore-duplicates))
3830 (info (nth 2 entry))
3831 articles fetched-articles cached)
3833 (unless (gnus-check-server
3834 (setq gnus-current-select-method
3835 (gnus-find-method-for-group group)))
3836 (error "Couldn't open server"))
3838 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3839 (gnus-activate-group group) ; Or we can activate it...
3840 (progn ; Or we bug out.
3841 (when (equal major-mode 'gnus-summary-mode)
3842 (kill-buffer (current-buffer)))
3843 (error "Couldn't request group %s: %s"
3844 group (gnus-status-message group))))
3846 (unless (gnus-request-group group t)
3847 (when (equal major-mode 'gnus-summary-mode)
3848 (kill-buffer (current-buffer)))
3849 (error "Couldn't request group %s: %s"
3850 group (gnus-status-message group)))
3852 (setq gnus-newsgroup-name group)
3853 (setq gnus-newsgroup-unselected nil)
3854 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3856 ;; Adjust and set lists of article marks.
3858 (gnus-adjust-marked-articles info))
3860 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3861 (when (gnus-virtual-group-p group)
3862 (setq cached gnus-newsgroup-cached))
3864 (setq gnus-newsgroup-unreads
3865 (gnus-set-difference
3866 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3867 gnus-newsgroup-dormant))
3869 (setq gnus-newsgroup-processable nil)
3871 (gnus-update-read-articles group gnus-newsgroup-unreads)
3873 (if (setq articles select-articles)
3874 (setq gnus-newsgroup-unselected
3875 (gnus-sorted-intersection
3876 gnus-newsgroup-unreads
3877 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3878 (setq articles (gnus-articles-to-read group read-all)))
3882 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3884 ((eq articles 0) nil)
3886 ;; Init the dependencies hash table.
3887 (setq gnus-newsgroup-dependencies
3888 (gnus-make-hashtable (length articles)))
3889 ;; Retrieve the headers and read them in.
3890 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3891 (setq gnus-newsgroup-headers
3893 (setq gnus-headers-retrieved-by
3894 (gnus-retrieve-headers
3895 articles gnus-newsgroup-name
3896 ;; We might want to fetch old headers, but
3897 ;; not if there is only 1 article.
3899 (not (eq gnus-fetch-old-headers 'some))
3900 (not (numberp gnus-fetch-old-headers)))
3901 (> (length articles) 1))
3902 gnus-fetch-old-headers))))
3903 (gnus-get-newsgroup-headers-xover
3904 articles nil nil gnus-newsgroup-name t)
3905 (gnus-get-newsgroup-headers)))
3906 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3908 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3910 (setq gnus-newsgroup-cached cached))
3912 ;; Suppress duplicates?
3913 (when gnus-suppress-duplicates
3914 (gnus-dup-suppress-articles))
3916 ;; Set the initial limit.
3917 (setq gnus-newsgroup-limit (copy-sequence articles))
3918 ;; Remove canceled articles from the list of unread articles.
3919 (setq gnus-newsgroup-unreads
3920 (gnus-set-sorted-intersection
3921 gnus-newsgroup-unreads
3922 (setq fetched-articles
3923 (mapcar (lambda (headers) (mail-header-number headers))
3924 gnus-newsgroup-headers))))
3925 ;; Removed marked articles that do not exist.
3926 (gnus-update-missing-marks
3927 (gnus-sorted-complement fetched-articles articles))
3928 ;; We might want to build some more threads first.
3929 (when (and gnus-fetch-old-headers
3930 (eq gnus-headers-retrieved-by 'nov))
3931 (if (eq gnus-fetch-old-headers 'invisible)
3932 (gnus-build-all-threads)
3933 (gnus-build-old-threads)))
3934 ;; Let the Gnus agent mark articles as read.
3936 (gnus-agent-get-undownloaded-list))
3937 ;; Check whether auto-expire is to be done in this group.
3938 (setq gnus-newsgroup-auto-expire
3939 (gnus-group-auto-expirable-p group))
3940 ;; Set up the article buffer now, if necessary.
3941 (unless gnus-single-article-buffer
3942 (gnus-article-setup-buffer))
3943 ;; First and last article in this newsgroup.
3944 (when gnus-newsgroup-headers
3945 (setq gnus-newsgroup-begin
3946 (mail-header-number (car gnus-newsgroup-headers))
3949 (gnus-last-element gnus-newsgroup-headers))))
3950 ;; GROUP is successfully selected.
3951 (or gnus-newsgroup-headers t)))))
3953 (defun gnus-articles-to-read (group &optional read-all)
3954 ;; Find out what articles the user wants to read.
3956 ;; Select all articles if `read-all' is non-nil, or if there
3957 ;; are no unread articles.
3959 (and (zerop (length gnus-newsgroup-marked))
3960 (zerop (length gnus-newsgroup-unreads)))
3961 (eq (gnus-group-find-parameter group 'display)
3963 (gnus-uncompress-range (gnus-active group))
3964 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3965 (copy-sequence gnus-newsgroup-unreads))
3967 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3968 (scored (length scored-list))
3969 (number (length articles))
3970 (marked (+ (length gnus-newsgroup-marked)
3971 (length gnus-newsgroup-dormant)))
3979 ((and (or (<= scored marked) (= scored number))
3980 (numberp gnus-large-newsgroup)
3981 (> number gnus-large-newsgroup))
3985 "How many articles from %s (default %d): "
3986 (gnus-limit-string gnus-newsgroup-name 35)
3988 (if (string-match "^[ \t]*$" input) number input)))
3989 ((and (> scored marked) (< scored number)
3990 (> (- scored number) 20))
3993 (format "%s %s (%d scored, %d total): "
3994 "How many articles from"
3995 group scored number))))
3996 (if (string-match "^[ \t]*$" input)
4000 (setq select (if (stringp select) (string-to-number select) select))
4001 (if (or (null select) (zerop select))
4003 (if (and (not (zerop scored)) (<= (abs select) scored))
4005 (setq articles (sort scored-list '<))
4006 (setq number (length articles)))
4007 (setq articles (copy-sequence articles)))
4009 (when (< (abs select) number)
4011 ;; Select the N oldest articles.
4012 (setcdr (nthcdr (1- (abs select)) articles) nil)
4013 ;; Select the N most recent articles.
4014 (setq articles (nthcdr (- number select) articles))))
4015 (setq gnus-newsgroup-unselected
4016 (gnus-sorted-intersection
4017 gnus-newsgroup-unreads
4018 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4021 (defun gnus-killed-articles (killed articles)
4024 (when (inline (gnus-member-of-range (car articles) killed))
4025 (push (car articles) out))
4026 (setq articles (cdr articles)))
4029 (defun gnus-uncompress-marks (marks)
4030 "Uncompress the mark ranges in MARKS."
4031 (let ((uncompressed '(score bookmark))
4034 (if (memq (caar marks) uncompressed)
4035 (push (car marks) out)
4036 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4037 (setq marks (cdr marks)))
4040 (defun gnus-adjust-marked-articles (info)
4041 "Set all article lists and remove all marks that are no longer legal."
4042 (let* ((marked-lists (gnus-info-marks info))
4043 (active (gnus-active (gnus-info-group info)))
4046 (types gnus-article-mark-lists)
4047 (uncompressed '(score bookmark killed))
4048 marks var articles article mark)
4051 (setq marks (pop marked-lists))
4052 (set (setq var (intern (format "gnus-newsgroup-%s"
4053 (car (rassq (setq mark (car marks))
4055 (if (memq (car marks) uncompressed) (cdr marks)
4056 (gnus-uncompress-range (cdr marks))))
4058 (setq articles (symbol-value var))
4060 ;; All articles have to be subsets of the active articles.
4062 ;; Adjust "simple" lists.
4063 ((memq mark '(tick dormant expire reply save))
4065 (when (or (< (setq article (pop articles)) min) (> article max))
4066 (set var (delq article (symbol-value var))))))
4068 ((memq mark uncompressed)
4069 (when (not (listp (cdr (symbol-value var))))
4070 (set var (list (symbol-value var))))
4071 (when (not (listp (cdr articles)))
4072 (setq articles (list articles)))
4074 (when (or (not (consp (setq article (pop articles))))
4075 (< (car article) min)
4076 (> (car article) max))
4077 (set var (delq article (symbol-value var))))))))))
4079 (defun gnus-update-missing-marks (missing)
4080 "Go through the list of MISSING articles and remove them from the mark lists."
4082 (let ((types gnus-article-mark-lists)
4084 ;; Go through all types.
4086 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4087 (when (symbol-value var)
4088 ;; This list has articles. So we delete all missing articles
4092 (set var (delq (pop m) (symbol-value var)))))))))
4094 (defun gnus-update-marks ()
4095 "Enter the various lists of marked articles into the newsgroup info list."
4096 (let ((types gnus-article-mark-lists)
4097 (info (gnus-get-info gnus-newsgroup-name))
4098 (uncompressed '(score bookmark killed))
4099 type list newmarked symbol)
4101 ;; Add all marks lists that are non-nil to the list of marks lists.
4102 (while (setq type (pop types))
4103 (when (setq list (symbol-value
4105 (intern (format "gnus-newsgroup-%s"
4108 ;; Get rid of the entries of the articles that have the
4110 (when (and (eq (cdr type) 'score)
4114 (prev (cons nil list))
4117 (if (or (not (consp (car arts)))
4118 (= (cdar arts) gnus-summary-default-score))
4119 (setcdr prev (cdr arts))
4121 (setq arts (cdr arts)))
4122 (setq list (cdr all))))
4124 (push (cons (cdr type)
4125 (if (memq (cdr type) uncompressed) list
4126 (gnus-compress-sequence
4127 (set symbol (sort list '<)) t)))
4130 ;; Enter these new marks into the info of the group.
4132 (setcar (nthcdr 3 info) newmarked)
4133 ;; Add the marks lists to the end of the info.
4135 (setcdr (nthcdr 2 info) (list newmarked))))
4137 ;; Cut off the end of the info if there's nothing else there.
4141 (when (nthcdr (decf i) info)
4142 (setcdr (nthcdr i info) nil)))))))
4144 (defun gnus-set-mode-line (where)
4145 "This function sets the mode line of the article or summary buffers.
4146 If WHERE is `summary', the summary mode line format will be used."
4147 ;; Is this mode line one we keep updated?
4148 (when (memq where gnus-updated-mode-lines)
4151 ;; We evaluate this in the summary buffer since these
4152 ;; variables are buffer-local to that buffer.
4153 (set-buffer gnus-summary-buffer)
4154 ;; We bind all these variables that are used in the `eval' form
4156 (let* ((mformat (symbol-value
4158 (format "gnus-%s-mode-line-format-spec" where))))
4159 (gnus-tmp-group-name gnus-newsgroup-name)
4160 (gnus-tmp-article-number (or gnus-current-article 0))
4161 (gnus-tmp-unread gnus-newsgroup-unreads)
4162 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4163 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4164 (gnus-tmp-unread-and-unselected
4165 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4166 (zerop gnus-tmp-unselected))
4168 ((zerop gnus-tmp-unselected)
4169 (format "{%d more}" gnus-tmp-unread-and-unticked))
4170 (t (format "{%d(+%d) more}"
4171 gnus-tmp-unread-and-unticked
4172 gnus-tmp-unselected))))
4174 (if (and gnus-current-headers
4175 (vectorp gnus-current-headers))
4176 (gnus-mode-string-quote
4177 (mail-header-subject gnus-current-headers))
4179 bufname-length max-len
4180 gnus-tmp-header);; passed as argument to any user-format-funcs
4181 (setq mode-string (eval mformat))
4182 (setq bufname-length (if (string-match "%b" mode-string)
4185 (if (eq where 'summary)
4187 (get-buffer gnus-article-buffer))))
4190 (setq max-len (max 4 (if gnus-mode-non-string-length
4192 gnus-mode-non-string-length
4194 (length mode-string))))
4195 ;; We might have to chop a bit of the string off...
4196 (when (> (length mode-string) max-len)
4198 (concat (truncate-string mode-string (- max-len 3))
4200 ;; Pad the mode string a bit.
4201 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4202 ;; Update the mode line.
4203 (setq mode-line-buffer-identification
4204 (gnus-mode-line-buffer-identification (list mode-string)))
4205 (set-buffer-modified-p t))))
4207 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4208 "Go through the HEADERS list and add all Xrefs to a hash table.
4209 The resulting hash table is returned, or nil if no Xrefs were found."
4210 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4211 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4212 (xref-hashtb (gnus-make-hashtable))
4213 start group entry number xrefs header)
4215 (setq header (pop headers))
4216 (when (and (setq xrefs (mail-header-xref header))
4217 (not (memq (setq number (mail-header-number header))
4220 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4221 (setq start (match-end 0))
4222 (setq group (if prefix
4223 (concat prefix (substring xrefs (match-beginning 1)
4225 (substring xrefs (match-beginning 1) (match-end 1))))
4227 (string-to-int (substring xrefs (match-beginning 2)
4229 (if (setq entry (gnus-gethash group xref-hashtb))
4230 (setcdr entry (cons number (cdr entry)))
4231 (gnus-sethash group (cons number nil) xref-hashtb)))))
4232 (and start xref-hashtb)))
4234 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4235 "Look through all the headers and mark the Xrefs as read."
4236 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4237 name entry info xref-hashtb idlist method nth4)
4239 (set-buffer gnus-group-buffer)
4240 (when (setq xref-hashtb
4241 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4244 (unless (string= from-newsgroup (setq name (symbol-name group)))
4245 (setq idlist (symbol-value group))
4246 ;; Dead groups are not updated.
4248 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4250 (when (stringp (setq nth4 (gnus-info-method info)))
4251 (setq nth4 (gnus-server-to-method nth4))))
4252 ;; Only do the xrefs if the group has the same
4253 ;; select method as the group we have just read.
4254 (or (gnus-methods-equal-p
4255 nth4 (gnus-find-method-for-group from-newsgroup))
4257 (equal nth4 (setq method (gnus-find-method-for-group
4259 (and (equal (car nth4) (car method))
4260 (equal (nth 1 nth4) (nth 1 method))))
4261 gnus-use-cross-reference
4262 (or (not (eq gnus-use-cross-reference t))
4264 ;; Only do cross-references on subscribed
4265 ;; groups, if that is what is wanted.
4266 (<= (gnus-info-level info) gnus-level-subscribed))
4267 (gnus-group-make-articles-read name idlist))))
4270 (defun gnus-compute-read-articles (group articles)
4271 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4272 (info (nth 2 entry))
4273 (active (gnus-active group))
4276 ;; First peel off all illegal article numbers.
4278 (let ((ids articles)
4280 (while (setq id (pop ids))
4281 (when (and first (> id (cdr active)))
4282 ;; We'll end up in this situation in one particular
4283 ;; obscure situation. If you re-scan a group and get
4284 ;; a new article that is cross-posted to a different
4285 ;; group that has not been re-scanned, you might get
4286 ;; crossposted article that has a higher number than
4287 ;; Gnus believes possible. So we re-activate this
4288 ;; group as well. This might mean doing the
4289 ;; crossposting thingy will *increase* the number
4290 ;; of articles in some groups. Tsk, tsk.
4291 (setq active (or (gnus-activate-group group) active)))
4292 (when (or (> id (cdr active))
4293 (< id (car active)))
4294 (setq articles (delq id articles))))))
4295 ;; If the read list is nil, we init it.
4297 (null (gnus-info-read info))
4299 (setq ninfo (cons 1 (1- (car active))))
4300 (setq ninfo (gnus-info-read info)))
4301 ;; Then we add the read articles to the range.
4303 ninfo (setq articles (sort articles '<))))))
4305 (defun gnus-group-make-articles-read (group articles)
4306 "Update the info of GROUP to say that ARTICLES are read."
4308 (entry (gnus-gethash group gnus-newsrc-hashtb))
4309 (info (nth 2 entry))
4310 (active (gnus-active group))
4313 (setq range (gnus-compute-read-articles group articles))
4315 (set-buffer gnus-group-buffer)
4318 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4319 (gnus-info-set-read ',info ',(gnus-info-read info))
4320 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4321 (gnus-group-update-group ,group t))))
4322 ;; Add the read articles to the range.
4323 (gnus-info-set-read info range)
4324 ;; Then we have to re-compute how many unread
4325 ;; articles there are in this group.
4329 (setq num (- (1+ (cdr active)) (car active))))
4330 ((not (listp (cdr range)))
4331 (setq num (- (cdr active) (- (1+ (cdr range))
4335 (if (numberp (car range))
4337 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4338 (setq range (cdr range)))
4339 (setq num (- (cdr active) num))))
4340 ;; Update the number of unread articles.
4342 ;; Update the group buffer.
4343 (gnus-group-update-group group t)))))
4345 (defun gnus-methods-equal-p (m1 m2)
4346 (let ((m1 (or m1 gnus-select-method))
4347 (m2 (or m2 gnus-select-method)))
4349 (and (eq (car m1) (car m2))
4350 (or (not (memq 'address (assoc (symbol-name (car m1))
4351 gnus-valid-select-methods)))
4352 (equal (nth 1 m1) (nth 1 m2)))))))
4354 (defvar gnus-newsgroup-none-id 0)
4356 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4357 (let ((cur nntp-server-buffer)
4360 (save-excursion (set-buffer gnus-summary-buffer)
4361 gnus-newsgroup-dependencies)))
4364 (set-buffer nntp-server-buffer)
4365 ;; Translate all TAB characters into SPACE characters.
4366 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4367 (gnus-run-hooks 'gnus-parse-headers-hook)
4368 (let ((case-fold-search t)
4369 in-reply-to header p lines chars)
4370 (goto-char (point-min))
4371 ;; Search to the beginning of the next header. Error messages
4372 ;; do not begin with 2 or 3.
4373 (while (re-search-forward "^[23][0-9]+ " nil t)
4376 ;; This implementation of this function, with nine
4377 ;; search-forwards instead of the one re-search-forward and
4378 ;; a case (which basically was the old function) is actually
4379 ;; about twice as fast, even though it looks messier. You
4380 ;; can't have everything, I guess. Speed and elegance
4381 ;; doesn't always go hand in hand.
4390 (narrow-to-region (point)
4391 (or (and (search-forward "\n.\n" nil t)
4397 (if (search-forward "\nsubject: " nil t)
4398 (rfc2047-decode-string (nnheader-header-value))
4403 (if (search-forward "\nfrom: " nil t)
4404 (rfc2047-decode-string (nnheader-header-value))
4409 (if (search-forward "\ndate: " nil t)
4410 (nnheader-header-value) ""))
4414 (setq id (if (re-search-forward
4415 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4416 ;; We do it this way to make sure the Message-ID
4417 ;; is (somewhat) syntactically valid.
4418 (buffer-substring (match-beginning 1)
4420 ;; If there was no message-id, we just fake one
4421 ;; to make subsequent routines simpler.
4422 (nnheader-generate-fake-message-id))))
4426 (if (search-forward "\nreferences: " nil t)
4430 (nnheader-header-value)
4435 (search-backward ">" end t)
4438 (search-backward "<" end t)
4440 ;; Get the references from the in-reply-to header if there
4441 ;; were no references and the in-reply-to header looks
4443 (if (and (search-forward "\nin-reply-to: " nil t)
4444 (setq in-reply-to (nnheader-header-value))
4445 (string-match "<[^>]+>" in-reply-to))
4447 (setq ref (substring in-reply-to (match-beginning 0)
4449 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4450 (setq ref2 (substring in-reply-to (match-beginning 0)
4452 (when (> (length ref2) (length ref))
4459 (if (search-forward "\nchars: " nil t)
4460 (if (numberp (setq chars (ignore-errors (read cur))))
4466 (if (search-forward "\nlines: " nil t)
4467 (if (numberp (setq lines (ignore-errors (read cur))))
4473 (and (search-forward "\nxref: " nil t)
4474 (nnheader-header-value)))))
4475 (when (equal id ref)
4478 (when gnus-alter-header-function
4479 (funcall gnus-alter-header-function header)
4480 (setq id (mail-header-id header)
4481 ref (gnus-parent-id (mail-header-references header))))
4484 (gnus-dependencies-add-header
4485 header dependencies force-new))
4486 (push header headers))
4487 (goto-char (point-max))
4489 (nreverse headers)))))
4491 ;; Goes through the xover lines and returns a list of vectors
4492 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4493 force-new dependencies
4494 group also-fetch-heads)
4495 "Parse the news overview data in the server buffer, and return a
4496 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4497 ;; Get the Xref when the users reads the articles since most/some
4498 ;; NNTP servers do not include Xrefs when using XOVER.
4499 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4500 (let ((cur nntp-server-buffer)
4501 (dependencies (or dependencies gnus-newsgroup-dependencies))
4502 number headers header)
4504 (set-buffer nntp-server-buffer)
4505 ;; Allow the user to mangle the headers before parsing them.
4506 (gnus-run-hooks 'gnus-parse-headers-hook)
4507 (goto-char (point-min))
4510 (while (and sequence (not (eobp)))
4511 (setq number (read cur))
4512 (while (and sequence
4513 (< (car sequence) number))
4514 (setq sequence (cdr sequence)))
4516 (eq number (car sequence))
4518 (setq sequence (cdr sequence))
4519 (setq header (inline
4520 (gnus-nov-parse-line
4521 number dependencies force-new))))
4522 (push header headers))
4525 ; (gnus-error 4 "Strange nov line (%d)"
4526 ; (count-lines (point-min) (point))))
4529 ;; A common bug in inn is that if you have posted an article and
4530 ;; then retrieves the active file, it will answer correctly --
4531 ;; the new article is included. However, a NOV entry for the
4532 ;; article may not have been generated yet, so this may fail.
4533 ;; We work around this problem by retrieving the last few
4534 ;; headers using HEAD.
4535 (if (or (not also-fetch-heads)
4537 ;; We (probably) got all the headers.
4539 (let ((gnus-nov-is-evil t))
4542 (when (gnus-retrieve-headers sequence group)
4543 (gnus-get-newsgroup-headers))))))))
4545 (defun gnus-article-get-xrefs ()
4546 "Fill in the Xref value in `gnus-current-headers', if necessary.
4547 This is meant to be called in `gnus-article-internal-prepare-hook'."
4548 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4549 gnus-current-headers)))
4550 (or (not gnus-use-cross-reference)
4552 (and (mail-header-xref headers)
4553 (not (string= (mail-header-xref headers) "")))
4554 (let ((case-fold-search t)
4557 (nnheader-narrow-to-headers)
4558 (goto-char (point-min))
4559 (when (or (and (eq (downcase (following-char)) ?x)
4560 (looking-at "Xref:"))
4561 (search-forward "\nXref:" nil t))
4562 (goto-char (1+ (match-end 0)))
4563 (setq xref (buffer-substring (point)
4564 (progn (end-of-line) (point))))
4565 (mail-header-set-xref headers xref)))))))
4567 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4568 "Find article ID and insert the summary line for that article.
4569 OLD-HEADER can either be a header or a line number to insert
4570 the subject line on."
4571 (let* ((line (and (numberp old-header) old-header))
4572 (old-header (and (vectorp old-header) old-header))
4573 (header (cond ((and old-header use-old-header)
4576 (gnus-number-to-header id))
4577 (gnus-number-to-header id))
4579 (gnus-read-header id))))
4580 (number (and (numberp id) id))
4583 ;; Rebuild the thread that this article is part of and go to the
4584 ;; article we have fetched.
4585 (when (and (not gnus-show-threads)
4588 (setq d (gnus-data-find (mail-header-number old-header))))
4589 (goto-char (gnus-data-pos d))
4592 (- (gnus-point-at-bol)
4594 (1+ (gnus-point-at-eol))
4595 (gnus-delete-line))))))
4597 (mail-header-set-number header (mail-header-number old-header)))
4598 (setq gnus-newsgroup-sparse
4599 (delq (setq number (mail-header-number header))
4600 gnus-newsgroup-sparse))
4601 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4602 (push number gnus-newsgroup-limit)
4603 (gnus-rebuild-thread (mail-header-id header) line)
4604 (gnus-summary-goto-subject number nil t))
4605 (when (and (numberp number)
4607 ;; We have to update the boundaries even if we can't fetch the
4608 ;; article if ID is a number -- so that the next `P' or `N'
4609 ;; command will fetch the previous (or next) article even
4610 ;; if the one we tried to fetch this time has been canceled.
4611 (when (> number gnus-newsgroup-end)
4612 (setq gnus-newsgroup-end number))
4613 (when (< number gnus-newsgroup-begin)
4614 (setq gnus-newsgroup-begin number))
4615 (setq gnus-newsgroup-unselected
4616 (delq number gnus-newsgroup-unselected)))
4617 ;; Report back a success?
4618 (and header (mail-header-number header))))
4620 ;;; Process/prefix in the summary buffer
4622 (defun gnus-summary-work-articles (n)
4623 "Return a list of articles to be worked upon.
4624 The prefix argument, the list of process marked articles, and the
4625 current article will be taken into consideration."
4627 (set-buffer gnus-summary-buffer)
4630 ;; A numerical prefix has been given.
4631 (setq n (prefix-numeric-value n))
4632 (let ((backward (< n 0))
4633 (n (abs (prefix-numeric-value n)))
4638 (push (setq article (gnus-summary-article-number))
4641 (gnus-summary-find-prev nil article)
4642 (gnus-summary-find-next nil article)))
4644 (nreverse articles)))
4645 ((and (gnus-region-active-p) (mark))
4646 (message "region active")
4647 ;; Work on the region between point and mark.
4648 (let ((max (max (point) (mark)))
4651 (goto-char (min (min (point) (mark))))
4654 (push (setq article (gnus-summary-article-number)) articles)
4655 (gnus-summary-find-next nil article)
4657 (nreverse articles))))
4658 (gnus-newsgroup-processable
4659 ;; There are process-marked articles present.
4660 ;; Save current state.
4661 (gnus-summary-save-process-mark)
4663 (reverse gnus-newsgroup-processable))
4665 ;; Just return the current article.
4666 (list (gnus-summary-article-number))))))
4668 (defmacro gnus-summary-iterate (arg &rest forms)
4669 "Iterate over the process/prefixed articles and do FORMS.
4670 ARG is the interactive prefix given to the command. FORMS will be
4671 executed with point over the summary line of the articles."
4672 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4673 `(let ((,articles (gnus-summary-work-articles ,arg)))
4675 (gnus-summary-goto-subject (car ,articles))
4678 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4679 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4681 (defun gnus-summary-save-process-mark ()
4682 "Push the current set of process marked articles on the stack."
4684 (push (copy-sequence gnus-newsgroup-processable)
4685 gnus-newsgroup-process-stack))
4687 (defun gnus-summary-kill-process-mark ()
4688 "Push the current set of process marked articles on the stack and unmark."
4690 (gnus-summary-save-process-mark)
4691 (gnus-summary-unmark-all-processable))
4693 (defun gnus-summary-yank-process-mark ()
4694 "Pop the last process mark state off the stack and restore it."
4696 (unless gnus-newsgroup-process-stack
4697 (error "Empty mark stack"))
4698 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4700 (defun gnus-summary-process-mark-set (set)
4701 "Make SET into the current process marked articles."
4702 (gnus-summary-unmark-all-processable)
4704 (gnus-summary-set-process-mark (pop set))))
4706 ;;; Searching and stuff
4708 (defun gnus-summary-search-group (&optional backward use-level)
4709 "Search for next unread newsgroup.
4710 If optional argument BACKWARD is non-nil, search backward instead."
4712 (set-buffer gnus-group-buffer)
4713 (when (gnus-group-search-forward
4714 backward nil (if use-level (gnus-group-group-level) nil))
4715 (gnus-group-group-name))))
4717 (defun gnus-summary-best-group (&optional exclude-group)
4718 "Find the name of the best unread group.
4719 If EXCLUDE-GROUP, do not go to this group."
4721 (set-buffer gnus-group-buffer)
4723 (gnus-group-best-unread-group exclude-group))))
4725 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4726 (if backward (gnus-summary-find-prev)
4727 (let* ((dummy (gnus-summary-article-intangible-p))
4728 (article (or article (gnus-summary-article-number)))
4729 (arts (gnus-data-find-list article))
4731 (when (and (not dummy)
4732 (or (not gnus-summary-check-current)
4734 (not (gnus-data-unread-p (car arts)))))
4735 (setq arts (cdr arts)))
4740 (when (or (and undownloaded
4741 (eq gnus-undownloaded-mark
4742 (gnus-data-mark (car arts))))
4743 (gnus-data-unread-p (car arts)))
4744 (setq result (car arts)
4746 (setq arts (cdr arts)))
4749 (goto-char (gnus-data-pos result))
4750 (gnus-data-number result)))))
4752 (defun gnus-summary-find-prev (&optional unread article)
4753 (let* ((eobp (eobp))
4754 (article (or article (gnus-summary-article-number)))
4755 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4757 (when (and (not eobp)
4758 (or (not gnus-summary-check-current)
4760 (not (gnus-data-unread-p (car arts)))))
4761 (setq arts (cdr arts)))
4766 (when (gnus-data-unread-p (car arts))
4767 (setq result (car arts)
4769 (setq arts (cdr arts)))
4772 (goto-char (gnus-data-pos result))
4773 (gnus-data-number result))))
4775 (defun gnus-summary-find-subject (subject &optional unread backward article)
4776 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4777 (article (or article (gnus-summary-article-number)))
4778 (articles (gnus-data-list backward))
4779 (arts (gnus-data-find-list article articles))
4781 (when (or (not gnus-summary-check-current)
4783 (not (gnus-data-unread-p (car arts))))
4784 (setq arts (cdr arts)))
4786 (and (or (not unread)
4787 (gnus-data-unread-p (car arts)))
4788 (vectorp (gnus-data-header (car arts)))
4790 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4791 (setq result (car arts)
4793 (setq arts (cdr arts)))
4795 (goto-char (gnus-data-pos result))
4796 (gnus-data-number result))))
4798 (defun gnus-summary-search-forward (&optional unread subject backward)
4799 "Search forward for an article.
4800 If UNREAD, look for unread articles. If SUBJECT, look for
4801 articles with that subject. If BACKWARD, search backward instead."
4802 (cond (subject (gnus-summary-find-subject subject unread backward))
4803 (backward (gnus-summary-find-prev unread))
4804 (t (gnus-summary-find-next unread))))
4806 (defun gnus-recenter (&optional n)
4807 "Center point in window and redisplay frame.
4808 Also do horizontal recentering."
4810 (when (and gnus-auto-center-summary
4811 (not (eq gnus-auto-center-summary 'vertical)))
4812 (gnus-horizontal-recenter))
4815 (defun gnus-summary-recenter ()
4816 "Center point in the summary window.
4817 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4818 displayed, no centering will be performed."
4819 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4820 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4821 (let* ((top (cond ((< (window-height) 4) 0)
4822 ((< (window-height) 7) 1)
4824 (height (1- (window-height)))
4825 (bottom (save-excursion (goto-char (point-max))
4826 (forward-line (- height))
4828 (window (get-buffer-window (current-buffer))))
4829 ;; The user has to want it.
4830 (when gnus-auto-center-summary
4831 (when (get-buffer-window gnus-article-buffer)
4832 ;; Only do recentering when the article buffer is displayed,
4833 ;; Set the window start to either `bottom', which is the biggest
4834 ;; possible valid number, or the second line from the top,
4835 ;; whichever is the least.
4837 window (min bottom (save-excursion
4838 (forward-line (- top)) (point)))))
4839 ;; Do horizontal recentering while we're at it.
4840 (when (and (get-buffer-window (current-buffer) t)
4841 (not (eq gnus-auto-center-summary 'vertical)))
4842 (let ((selected (selected-window)))
4843 (select-window (get-buffer-window (current-buffer) t))
4844 (gnus-summary-position-point)
4845 (gnus-horizontal-recenter)
4846 (select-window selected))))))
4848 (defun gnus-summary-jump-to-group (newsgroup)
4849 "Move point to NEWSGROUP in group mode buffer."
4850 ;; Keep update point of group mode buffer if visible.
4851 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4852 (save-window-excursion
4853 ;; Take care of tree window mode.
4854 (when (get-buffer-window gnus-group-buffer)
4855 (pop-to-buffer gnus-group-buffer))
4856 (gnus-group-jump-to-group newsgroup))
4858 ;; Take care of tree window mode.
4859 (if (get-buffer-window gnus-group-buffer)
4860 (pop-to-buffer gnus-group-buffer)
4861 (set-buffer gnus-group-buffer))
4862 (gnus-group-jump-to-group newsgroup))))
4864 ;; This function returns a list of article numbers based on the
4865 ;; difference between the ranges of read articles in this group and
4866 ;; the range of active articles.
4867 (defun gnus-list-of-unread-articles (group)
4868 (let* ((read (gnus-info-read (gnus-get-info group)))
4869 (active (or (gnus-active group) (gnus-activate-group group)))
4872 ;; If none are read, then all are unread.
4874 (setq first (car active))
4875 ;; If the range of read articles is a single range, then the
4876 ;; first unread article is the article after the last read
4877 ;; article. Sounds logical, doesn't it?
4878 (if (not (listp (cdr read)))
4879 (setq first (max (car active) (1+ (cdr read))))
4880 ;; `read' is a list of ranges.
4881 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4884 (setq first (car active)))
4887 (while (< first nlast)
4889 (setq first (1+ first))))
4890 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4891 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4892 (setq read (cdr read)))))
4893 ;; And add the last unread articles.
4894 (while (<= first last)
4896 (setq first (1+ first)))
4897 ;; Return the list of unread articles.
4898 (delq 0 (nreverse unread))))
4900 (defun gnus-list-of-read-articles (group)
4901 "Return a list of unread, unticked and non-dormant articles."
4902 (let* ((info (gnus-get-info group))
4903 (marked (gnus-info-marks info))
4904 (active (gnus-active group)))
4906 (gnus-set-difference
4907 (gnus-sorted-complement
4908 (gnus-uncompress-range active)
4909 (gnus-list-of-unread-articles group))
4911 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4912 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4914 ;; Various summary commands
4916 (defun gnus-summary-select-article-buffer ()
4917 "Reconfigure windows to show article buffer."
4919 (if (not (gnus-buffer-live-p gnus-article-buffer))
4920 (error "There is no article buffer for this summary buffer")
4921 (gnus-configure-windows 'article)
4922 (select-window (get-buffer-window gnus-article-buffer))))
4924 (defun gnus-summary-universal-argument (arg)
4925 "Perform any operation on all articles that are process/prefixed."
4927 (let ((articles (gnus-summary-work-articles arg))
4934 (substitute-command-keys
4935 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4938 (gnus-error 1 "Undefined key")
4941 (gnus-summary-goto-subject (setq article (pop articles)))
4942 (let (gnus-newsgroup-processable)
4943 (command-execute func))
4944 (gnus-summary-remove-process-mark article)))))
4945 (gnus-summary-position-point))
4947 (defun gnus-summary-toggle-truncation (&optional arg)
4948 "Toggle truncation of summary lines.
4949 With arg, turn line truncation on iff arg is positive."
4951 (setq truncate-lines
4952 (if (null arg) (not truncate-lines)
4953 (> (prefix-numeric-value arg) 0)))
4956 (defun gnus-summary-reselect-current-group (&optional all rescan)
4957 "Exit and then reselect the current newsgroup.
4958 The prefix argument ALL means to select all articles."
4960 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4961 (error "Ephemeral groups can't be reselected"))
4962 (let ((current-subject (gnus-summary-article-number))
4963 (group gnus-newsgroup-name))
4964 (setq gnus-newsgroup-begin nil)
4966 ;; We have to adjust the point of group mode buffer because
4967 ;; point was moved to the next unread newsgroup by exiting.
4968 (gnus-summary-jump-to-group group)
4971 (gnus-group-get-new-news-this-group 1)))
4972 (gnus-group-read-group all t)
4973 (gnus-summary-goto-subject current-subject nil t)))
4975 (defun gnus-summary-rescan-group (&optional all)
4976 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4978 (gnus-summary-reselect-current-group all t))
4980 (defun gnus-summary-update-info (&optional non-destructive)
4982 (let ((group gnus-newsgroup-name))
4984 (when gnus-newsgroup-kill-headers
4985 (setq gnus-newsgroup-killed
4986 (gnus-compress-sequence
4988 (gnus-set-sorted-intersection
4989 (gnus-uncompress-range gnus-newsgroup-killed)
4990 (setq gnus-newsgroup-unselected
4991 (sort gnus-newsgroup-unselected '<)))
4992 (setq gnus-newsgroup-unreads
4993 (sort gnus-newsgroup-unreads '<)))
4995 (unless (listp (cdr gnus-newsgroup-killed))
4996 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4997 (let ((headers gnus-newsgroup-headers))
4998 ;; Set the new ranges of read articles.
5000 (set-buffer gnus-group-buffer)
5001 (gnus-undo-force-boundary))
5002 (gnus-update-read-articles
5003 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5004 ;; Set the current article marks.
5005 (let ((gnus-newsgroup-scored
5006 (if (and (not gnus-save-score)
5007 (not non-destructive))
5009 gnus-newsgroup-scored)))
5011 (gnus-update-marks)))
5012 ;; Do the cross-ref thing.
5013 (when gnus-use-cross-reference
5014 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5015 ;; Do not switch windows but change the buffer to work.
5016 (set-buffer gnus-group-buffer)
5017 (unless (gnus-ephemeral-group-p group)
5018 (gnus-group-update-group group)))))))
5020 (defun gnus-summary-save-newsrc (&optional force)
5021 "Save the current number of read/marked articles in the dribble buffer.
5022 The dribble buffer will then be saved.
5023 If FORCE (the prefix), also save the .newsrc file(s)."
5025 (gnus-summary-update-info t)
5027 (gnus-save-newsrc-file)
5028 (gnus-dribble-save)))
5030 (defun gnus-summary-exit (&optional temporary)
5031 "Exit reading current newsgroup, and then return to group selection mode.
5032 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5034 (gnus-set-global-variables)
5035 (gnus-kill-save-kill-buffer)
5036 (gnus-async-halt-prefetch)
5037 (let* ((group gnus-newsgroup-name)
5038 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5041 (buf (current-buffer)))
5042 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5043 ;; If we have several article buffers, we kill them at exit.
5044 (unless gnus-single-article-buffer
5045 (gnus-kill-buffer gnus-original-article-buffer)
5046 (setq gnus-article-current nil))
5047 (when gnus-use-cache
5048 (gnus-cache-possibly-remove-articles)
5049 (gnus-cache-save-buffers))
5050 (gnus-async-prefetch-remove-group group)
5051 (when gnus-suppress-duplicates
5052 (gnus-dup-enter-articles))
5053 (when gnus-use-trees
5054 (gnus-tree-close group))
5055 ;; Remove entries for this group.
5056 (nnmail-purge-split-history (gnus-group-real-name group))
5057 ;; Make all changes in this group permanent.
5059 (gnus-run-hooks 'gnus-exit-group-hook)
5060 (gnus-summary-update-info)
5061 ;; Do adaptive scoring, and possibly save score files.
5062 (when gnus-newsgroup-adaptive
5063 (gnus-score-adaptive))
5064 (when gnus-use-scoring
5066 (gnus-close-group group)
5067 ;; Make sure where we were, and go to next newsgroup.
5068 (set-buffer gnus-group-buffer)
5070 (gnus-group-jump-to-group group))
5071 (gnus-run-hooks 'gnus-summary-exit-hook)
5072 (unless (or quit-config
5073 ;; If this group has disappeared from the summary
5074 ;; buffer, don't skip forwards.
5075 (not (string= group (gnus-group-group-name))))
5076 (gnus-group-next-unread-group 1))
5077 (setq group-point (point))
5080 ;; If we have several article buffers, we kill them at exit.
5081 (unless gnus-single-article-buffer
5083 (set-buffer gnus-article-buffer)
5084 (mapcar 'mm-destroy-part gnus-article-mime-handles))
5085 (gnus-kill-buffer gnus-article-buffer)
5086 (gnus-kill-buffer gnus-original-article-buffer)
5087 (setq gnus-article-current nil))
5089 (if (not gnus-kill-summary-on-exit)
5090 (gnus-deaden-summary)
5091 ;; We set all buffer-local variables to nil. It is unclear why
5092 ;; this is needed, but if we don't, buffer-local variables are
5093 ;; not garbage-collected, it seems. This would the lead to en
5094 ;; ever-growing Emacs.
5095 (gnus-summary-clear-local-variables)
5096 (when (get-buffer gnus-article-buffer)
5097 (bury-buffer gnus-article-buffer))
5098 ;; We clear the global counterparts of the buffer-local
5099 ;; variables as well, just to be on the safe side.
5100 (set-buffer gnus-group-buffer)
5101 (gnus-summary-clear-local-variables)
5102 ;; Return to group mode buffer.
5103 (when (eq mode 'gnus-summary-mode)
5104 (gnus-kill-buffer buf)))
5105 (setq gnus-current-select-method gnus-select-method)
5106 (pop-to-buffer gnus-group-buffer)
5107 (if (not quit-config)
5109 (goto-char group-point)
5110 (gnus-configure-windows 'group 'force))
5111 (gnus-handle-ephemeral-exit quit-config))
5112 ;; Clear the current group name.
5114 (setq gnus-newsgroup-name nil)))))
5116 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5117 (defun gnus-summary-exit-no-update (&optional no-questions)
5118 "Quit reading current newsgroup without updating read article info."
5120 (let* ((group gnus-newsgroup-name)
5121 (quit-config (gnus-group-quit-config group)))
5122 (when (or no-questions
5124 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5125 (gnus-async-halt-prefetch)
5126 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5127 ;; If we have several article buffers, we kill them at exit.
5128 (unless gnus-single-article-buffer
5129 (gnus-kill-buffer gnus-article-buffer)
5130 (gnus-kill-buffer gnus-original-article-buffer)
5131 (setq gnus-article-current nil))
5132 (if (not gnus-kill-summary-on-exit)
5133 (gnus-deaden-summary)
5134 (gnus-close-group group)
5135 (gnus-summary-clear-local-variables)
5136 (set-buffer gnus-group-buffer)
5137 (gnus-summary-clear-local-variables)
5138 (when (get-buffer gnus-summary-buffer)
5139 (kill-buffer gnus-summary-buffer)))
5140 (unless gnus-single-article-buffer
5141 (setq gnus-article-current nil))
5142 (when gnus-use-trees
5143 (gnus-tree-close group))
5144 (gnus-async-prefetch-remove-group group)
5145 (when (get-buffer gnus-article-buffer)
5146 (bury-buffer gnus-article-buffer))
5147 ;; Return to the group buffer.
5148 (gnus-configure-windows 'group 'force)
5149 ;; Clear the current group name.
5150 (setq gnus-newsgroup-name nil)
5151 (when (equal (gnus-group-group-name) group)
5152 (gnus-group-next-unread-group 1))
5154 (gnus-handle-ephemeral-exit quit-config)))))
5156 (defun gnus-handle-ephemeral-exit (quit-config)
5157 "Handle movement when leaving an ephemeral group.
5158 The state which existed when entering the ephemeral is reset."
5159 (if (not (buffer-name (car quit-config)))
5160 (gnus-configure-windows 'group 'force)
5161 (set-buffer (car quit-config))
5162 (cond ((eq major-mode 'gnus-summary-mode)
5163 (gnus-set-global-variables))
5164 ((eq major-mode 'gnus-article-mode)
5166 ;; The `gnus-summary-buffer' variable may point
5167 ;; to the old summary buffer when using a single
5169 (unless (gnus-buffer-live-p gnus-summary-buffer)
5170 (set-buffer gnus-group-buffer))
5171 (set-buffer gnus-summary-buffer)
5172 (gnus-set-global-variables))))
5173 (if (or (eq (cdr quit-config) 'article)
5174 (eq (cdr quit-config) 'pick))
5176 ;; The current article may be from the ephemeral group
5177 ;; thus it is best that we reload this article
5178 (gnus-summary-show-article)
5179 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5180 (gnus-configure-windows 'pick 'force)
5181 (gnus-configure-windows (cdr quit-config) 'force)))
5182 (gnus-configure-windows (cdr quit-config) 'force))
5183 (when (eq major-mode 'gnus-summary-mode)
5184 (gnus-summary-next-subject 1 nil t)
5185 (gnus-summary-recenter)
5186 (gnus-summary-position-point))))
5190 (defvar gnus-dead-summary-mode-map nil)
5192 (unless gnus-dead-summary-mode-map
5193 (setq gnus-dead-summary-mode-map (make-keymap))
5194 (suppress-keymap gnus-dead-summary-mode-map)
5195 (substitute-key-definition
5196 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5197 (let ((keys '("\C-d" "\r" "\177" [delete])))
5199 (define-key gnus-dead-summary-mode-map
5200 (pop keys) 'gnus-summary-wake-up-the-dead))))
5202 (defvar gnus-dead-summary-mode nil
5203 "Minor mode for Gnus summary buffers.")
5205 (defun gnus-dead-summary-mode (&optional arg)
5206 "Minor mode for Gnus summary buffers."
5208 (when (eq major-mode 'gnus-summary-mode)
5209 (make-local-variable 'gnus-dead-summary-mode)
5210 (setq gnus-dead-summary-mode
5211 (if (null arg) (not gnus-dead-summary-mode)
5212 (> (prefix-numeric-value arg) 0)))
5213 (when gnus-dead-summary-mode
5214 (gnus-add-minor-mode
5215 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5217 (defun gnus-deaden-summary ()
5218 "Make the current summary buffer into a dead summary buffer."
5219 ;; Kill any previous dead summary buffer.
5220 (when (and gnus-dead-summary
5221 (buffer-name gnus-dead-summary))
5223 (set-buffer gnus-dead-summary)
5224 (when gnus-dead-summary-mode
5225 (kill-buffer (current-buffer)))))
5226 ;; Make this the current dead summary.
5227 (setq gnus-dead-summary (current-buffer))
5228 (gnus-dead-summary-mode 1)
5229 (let ((name (buffer-name)))
5230 (when (string-match "Summary" name)
5232 (concat (substring name 0 (match-beginning 0)) "Dead "
5233 (substring name (match-beginning 0)))
5236 (defun gnus-kill-or-deaden-summary (buffer)
5237 "Kill or deaden the summary BUFFER."
5239 (when (and (buffer-name buffer)
5240 (not gnus-single-article-buffer))
5243 (gnus-kill-buffer gnus-article-buffer)
5244 (gnus-kill-buffer gnus-original-article-buffer)))
5245 (cond (gnus-kill-summary-on-exit
5246 (when (and gnus-use-trees
5247 (gnus-buffer-exists-p buffer))
5250 (gnus-tree-close gnus-newsgroup-name)))
5251 (gnus-kill-buffer buffer))
5252 ((gnus-buffer-exists-p buffer)
5255 (gnus-deaden-summary))))))
5257 (defun gnus-summary-wake-up-the-dead (&rest args)
5258 "Wake up the dead summary buffer."
5260 (gnus-dead-summary-mode -1)
5261 (let ((name (buffer-name)))
5262 (when (string-match "Dead " name)
5264 (concat (substring name 0 (match-beginning 0))
5265 (substring name (match-end 0)))
5267 (gnus-message 3 "This dead summary is now alive again"))
5269 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5270 (defun gnus-summary-fetch-faq (&optional faq-dir)
5271 "Fetch the FAQ for the current group.
5272 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5276 (when current-prefix-arg
5278 "Faq dir: " (and (listp gnus-group-faq-directory)
5279 (mapcar (lambda (file) (list file))
5280 gnus-group-faq-directory))))))
5281 (let (gnus-faq-buffer)
5282 (when (setq gnus-faq-buffer
5283 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5284 (gnus-configure-windows 'summary-faq))))
5286 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5287 (defun gnus-summary-describe-group (&optional force)
5288 "Describe the current newsgroup."
5290 (gnus-group-describe-group force gnus-newsgroup-name))
5292 (defun gnus-summary-describe-briefly ()
5293 "Describe summary mode commands briefly."
5296 (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")))
5298 ;; Walking around group mode buffer from summary mode.
5300 (defun gnus-summary-next-group (&optional no-article target-group backward)
5301 "Exit current newsgroup and then select next unread newsgroup.
5302 If prefix argument NO-ARTICLE is non-nil, no article is selected
5303 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5304 previous group instead."
5306 ;; Stop pre-fetching.
5307 (gnus-async-halt-prefetch)
5308 (let ((current-group gnus-newsgroup-name)
5309 (current-buffer (current-buffer))
5311 ;; First we semi-exit this group to update Xrefs and all variables.
5312 ;; We can't do a real exit, because the window conf must remain
5313 ;; the same in case the user is prompted for info, and we don't
5314 ;; want the window conf to change before that...
5315 (gnus-summary-exit t)
5316 (while (not entered)
5317 ;; Then we find what group we are supposed to enter.
5318 (set-buffer gnus-group-buffer)
5319 (gnus-group-jump-to-group current-group)
5322 (if (eq gnus-keep-same-level 'best)
5323 (gnus-summary-best-group gnus-newsgroup-name)
5324 (gnus-summary-search-group backward gnus-keep-same-level))))
5325 (if (not target-group)
5326 ;; There are no further groups, so we return to the group
5329 (gnus-message 5 "Returning to the group buffer")
5331 (when (gnus-buffer-live-p current-buffer)
5332 (set-buffer current-buffer)
5333 (gnus-summary-exit))
5334 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5335 ;; We try to enter the target group.
5336 (gnus-group-jump-to-group target-group)
5337 (let ((unreads (gnus-group-group-unread)))
5338 (if (and (or (eq t unreads)
5339 (and unreads (not (zerop unreads))))
5340 (gnus-summary-read-group
5341 target-group nil no-article
5342 (and (buffer-name current-buffer) current-buffer)
5345 (setq current-group target-group
5346 target-group nil)))))))
5348 (defun gnus-summary-prev-group (&optional no-article)
5349 "Exit current newsgroup and then select previous unread newsgroup.
5350 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5352 (gnus-summary-next-group no-article nil t))
5354 ;; Walking around summary lines.
5356 (defun gnus-summary-first-subject (&optional unread undownloaded)
5357 "Go to the first unread subject.
5358 If UNREAD is non-nil, go to the first unread article.
5359 Returns the article selected or nil if there are no unread articles."
5364 ((null gnus-newsgroup-data)
5365 (gnus-message 3 "No articles in the group")
5367 ;; Pick the first article.
5369 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5370 (gnus-data-number (car gnus-newsgroup-data)))
5371 ;; No unread articles.
5372 ((null gnus-newsgroup-unreads)
5373 (gnus-message 3 "No more unread articles")
5375 ;; Find the first unread article.
5377 (let ((data gnus-newsgroup-data))
5379 (and (not (and undownloaded
5380 (eq gnus-undownloaded-mark
5381 (gnus-data-mark (car data)))))
5382 (not (gnus-data-unread-p (car data)))))
5383 (setq data (cdr data)))
5385 (goto-char (gnus-data-pos (car data)))
5386 (gnus-data-number (car data))))))
5387 (gnus-summary-position-point)))
5389 (defun gnus-summary-next-subject (n &optional unread dont-display)
5390 "Go to next N'th summary line.
5391 If N is negative, go to the previous N'th subject line.
5392 If UNREAD is non-nil, only unread articles are selected.
5393 The difference between N and the actual number of steps taken is
5396 (let ((backward (< n 0))
5400 (gnus-summary-find-prev unread)
5401 (gnus-summary-find-next unread)))
5402 (gnus-summary-show-thread)
5405 (gnus-message 7 "No more%s articles"
5406 (if unread " unread" "")))
5407 (unless dont-display
5408 (gnus-summary-recenter)
5409 (gnus-summary-position-point))
5412 (defun gnus-summary-next-unread-subject (n)
5413 "Go to next N'th unread summary line."
5415 (gnus-summary-next-subject n t))
5417 (defun gnus-summary-prev-subject (n &optional unread)
5418 "Go to previous N'th summary line.
5419 If optional argument UNREAD is non-nil, only unread article is selected."
5421 (gnus-summary-next-subject (- n) unread))
5423 (defun gnus-summary-prev-unread-subject (n)
5424 "Go to previous N'th unread summary line."
5426 (gnus-summary-next-subject (- n) t))
5428 (defun gnus-summary-goto-subject (article &optional force silent)
5429 "Go the subject line of ARTICLE.
5430 If FORCE, also allow jumping to articles not currently shown."
5431 (interactive "nArticle number: ")
5433 (data (gnus-data-find article)))
5434 ;; We read in the article if we have to.
5437 (gnus-summary-insert-subject
5439 (if (or (numberp force) (vectorp force)) force)
5441 (setq data (gnus-data-find article)))
5446 (gnus-message 3 "Can't find article %d" article))
5448 (goto-char (gnus-data-pos data))
5449 (gnus-summary-position-point)
5452 ;; Walking around summary lines with displaying articles.
5454 (defun gnus-summary-expand-window (&optional arg)
5455 "Make the summary buffer take up the entire Emacs frame.
5456 Given a prefix, will force an `article' buffer configuration."
5459 (gnus-configure-windows 'article 'force)
5460 (gnus-configure-windows 'summary 'force)))
5462 (defun gnus-summary-display-article (article &optional all-header)
5463 "Display ARTICLE in article buffer."
5464 (gnus-set-global-variables)
5468 (if gnus-summary-display-article-function
5469 (funcall gnus-summary-display-article-function article all-header)
5470 (gnus-article-prepare article all-header))
5471 (gnus-run-hooks 'gnus-select-article-hook)
5472 (when (and gnus-current-article
5473 (not (zerop gnus-current-article)))
5474 (gnus-summary-goto-subject gnus-current-article))
5475 (gnus-summary-recenter)
5476 (when (and gnus-use-trees gnus-show-threads)
5477 (gnus-possibly-generate-tree article)
5478 (gnus-highlight-selected-tree article))
5479 ;; Successfully display article.
5480 (gnus-article-set-window-start
5481 (cdr (assq article gnus-newsgroup-bookmarks))))))
5483 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5484 "Select the current article.
5485 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5486 non-nil, the article will be re-fetched even if it already present in
5487 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5489 ;; Make sure we are in the summary buffer to work around bbdb bug.
5490 (unless (eq major-mode 'gnus-summary-mode)
5491 (set-buffer gnus-summary-buffer))
5492 (let ((article (or article (gnus-summary-article-number)))
5493 (all-headers (not (not all-headers))) ;Must be T or NIL.
5494 gnus-summary-display-article-function
5497 (gnus-summary-article-pseudo-p article)
5498 (error "This is a pseudo-article"))
5501 (set-buffer gnus-summary-buffer)
5502 (if (or (and gnus-single-article-buffer
5503 (or (null gnus-current-article)
5504 (null gnus-article-current)
5505 (null (get-buffer gnus-article-buffer))
5506 (not (eq article (cdr gnus-article-current)))
5507 (not (equal (car gnus-article-current)
5508 gnus-newsgroup-name))))
5509 (and (not gnus-single-article-buffer)
5510 (or (null gnus-current-article)
5511 (not (eq gnus-current-article article))))
5513 ;; The requested article is different from the current article.
5515 (gnus-summary-display-article article all-headers)
5517 (when (or all-headers gnus-show-all-headers)
5518 (gnus-article-show-all-headers))
5521 (gnus-article-set-window-start
5522 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5524 (defun gnus-summary-set-current-mark (&optional current-mark)
5525 "Obsolete function."
5528 (defun gnus-summary-next-article (&optional unread subject backward push)
5529 "Select the next article.
5530 If UNREAD, only unread articles are selected.
5531 If SUBJECT, only articles with SUBJECT are selected.
5532 If BACKWARD, the previous article is selected instead of the next."
5535 ;; Is there such an article?
5536 ((and (gnus-summary-search-forward unread subject backward)
5537 (or (gnus-summary-display-article (gnus-summary-article-number))
5538 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5539 (gnus-summary-position-point))
5540 ;; If not, we try the first unread, if that is wanted.
5542 gnus-auto-select-same
5543 (gnus-summary-first-unread-article))
5544 (gnus-summary-position-point)
5545 (gnus-message 6 "Wrapped"))
5546 ;; Try to get next/previous article not displayed in this group.
5547 ((and gnus-auto-extend-newsgroup
5548 (not unread) (not subject))
5549 (gnus-summary-goto-article
5550 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5551 nil (count-lines (point-min) (point))))
5552 ;; Go to next/previous group.
5554 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5555 (gnus-summary-jump-to-group gnus-newsgroup-name))
5556 (let ((cmd last-command-char)
5559 (set-buffer gnus-group-buffer)
5562 (if (eq gnus-keep-same-level 'best)
5563 (gnus-summary-best-group gnus-newsgroup-name)
5564 (gnus-summary-search-group backward gnus-keep-same-level))))
5565 ;; For some reason, the group window gets selected. We change
5567 (select-window (get-buffer-window (current-buffer)))
5568 ;; Select next unread newsgroup automagically.
5570 ((or (not gnus-auto-select-next)
5572 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5573 ((or (eq gnus-auto-select-next 'quietly)
5574 (and (eq gnus-auto-select-next 'slightly-quietly)
5576 (and (eq gnus-auto-select-next 'almost-quietly)
5577 (gnus-summary-last-article-p)))
5579 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5581 (gnus-message 7 "No more%s articles (%s)..."
5582 (if unread " unread" "")
5583 (if group (concat "selecting " group)
5585 (gnus-summary-next-group nil group backward)))
5587 (when (gnus-key-press-event-p last-input-event)
5588 (gnus-summary-walk-group-buffer
5589 gnus-newsgroup-name cmd unread backward point))))))))
5591 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5592 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5593 (?\C-p (gnus-group-prev-unread-group 1))))
5594 (cursor-in-echo-area t)
5595 keve key group ended)
5597 (set-buffer gnus-group-buffer)
5600 (if (eq gnus-keep-same-level 'best)
5601 (gnus-summary-best-group gnus-newsgroup-name)
5602 (gnus-summary-search-group backward gnus-keep-same-level))))
5605 5 "No more%s articles%s" (if unread " unread" "")
5607 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5608 (format " (Type %s for %s [%s])"
5609 (single-key-description cmd) group
5610 (car (gnus-gethash group gnus-newsrc-hashtb)))
5611 (format " (Type %s to exit %s)"
5612 (single-key-description cmd)
5613 gnus-newsgroup-name)))
5614 ;; Confirm auto selection.
5615 (setq key (car (setq keve (gnus-read-event-char))))
5618 ((assq key keystrokes)
5619 (let ((obuf (current-buffer)))
5620 (switch-to-buffer gnus-group-buffer)
5622 (gnus-group-jump-to-group group))
5623 (eval (cadr (assq key keystrokes)))
5624 (setq group (gnus-group-group-name))
5625 (switch-to-buffer obuf))
5629 (gnus-ephemeral-group-p gnus-newsgroup-name))
5631 (gnus-summary-next-group nil group backward)))
5633 (push (cdr keve) unread-command-events))))))
5635 (defun gnus-summary-next-unread-article ()
5636 "Select unread article after current one."
5638 (gnus-summary-next-article
5639 (or (not (eq gnus-summary-goto-unread 'never))
5640 (gnus-summary-last-article-p (gnus-summary-article-number)))
5641 (and gnus-auto-select-same
5642 (gnus-summary-article-subject))))
5644 (defun gnus-summary-prev-article (&optional unread subject)
5645 "Select the article after the current one.
5646 If UNREAD is non-nil, only unread articles are selected."
5648 (gnus-summary-next-article unread subject t))
5650 (defun gnus-summary-prev-unread-article ()
5651 "Select unread article before current one."
5653 (gnus-summary-prev-article
5654 (or (not (eq gnus-summary-goto-unread 'never))
5655 (gnus-summary-first-article-p (gnus-summary-article-number)))
5656 (and gnus-auto-select-same
5657 (gnus-summary-article-subject))))
5659 (defun gnus-summary-next-page (&optional lines circular)
5660 "Show next page of the selected article.
5661 If at the end of the current article, select the next article.
5662 LINES says how many lines should be scrolled up.
5664 If CIRCULAR is non-nil, go to the start of the article instead of
5665 selecting the next article when reaching the end of the current
5668 (setq gnus-summary-buffer (current-buffer))
5669 (gnus-set-global-variables)
5670 (let ((article (gnus-summary-article-number))
5671 (article-window (get-buffer-window gnus-article-buffer t))
5673 ;; If the buffer is empty, we have no article.
5675 (error "No article to select"))
5676 (gnus-configure-windows 'article)
5677 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5678 (if (and (eq gnus-summary-goto-unread 'never)
5679 (not (gnus-summary-last-article-p article)))
5680 (gnus-summary-next-article)
5681 (gnus-summary-next-unread-article))
5682 (if (or (null gnus-current-article)
5683 (null gnus-article-current)
5684 (/= article (cdr gnus-article-current))
5685 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5686 ;; Selected subject is different from current article's.
5687 (gnus-summary-display-article article)
5688 (when article-window
5689 (gnus-eval-in-buffer-window gnus-article-buffer
5690 (setq endp (gnus-article-next-page lines)))
5693 (gnus-summary-beginning-of-article))
5695 (gnus-message 3 "End of message"))
5697 (if (and (eq gnus-summary-goto-unread 'never)
5698 (not (gnus-summary-last-article-p article)))
5699 (gnus-summary-next-article)
5700 (gnus-summary-next-unread-article))))))))
5701 (gnus-summary-recenter)
5702 (gnus-summary-position-point)))
5704 (defun gnus-summary-prev-page (&optional lines move)
5705 "Show previous page of selected article.
5706 Argument LINES specifies lines to be scrolled down.
5707 If MOVE, move to the previous unread article if point is at
5708 the beginning of the buffer."
5710 (let ((article (gnus-summary-article-number))
5711 (article-window (get-buffer-window gnus-article-buffer t))
5713 (gnus-configure-windows 'article)
5714 (if (or (null gnus-current-article)
5715 (null gnus-article-current)
5716 (/= article (cdr gnus-article-current))
5717 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5718 ;; Selected subject is different from current article's.
5719 (gnus-summary-display-article article)
5720 (gnus-summary-recenter)
5721 (when article-window
5722 (gnus-eval-in-buffer-window gnus-article-buffer
5723 (setq endp (gnus-article-prev-page lines)))
5724 (when (and move endp)
5726 (gnus-message 3 "Beginning of message"))
5728 (if (and (eq gnus-summary-goto-unread 'never)
5729 (not (gnus-summary-first-article-p article)))
5730 (gnus-summary-prev-article)
5731 (gnus-summary-prev-unread-article))))))))
5732 (gnus-summary-position-point))
5734 (defun gnus-summary-prev-page-or-article (&optional lines)
5735 "Show previous page of selected article.
5736 Argument LINES specifies lines to be scrolled down.
5737 If at the beginning of the article, go to the next article."
5739 (gnus-summary-prev-page lines t))
5741 (defun gnus-summary-scroll-up (lines)
5742 "Scroll up (or down) one line current article.
5743 Argument LINES specifies lines to be scrolled up (or down if negative)."
5745 (gnus-configure-windows 'article)
5746 (gnus-summary-show-thread)
5747 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5748 (gnus-eval-in-buffer-window gnus-article-buffer
5750 (when (gnus-article-next-page lines)
5751 (gnus-message 3 "End of message")))
5753 (gnus-article-prev-page (- lines))))))
5754 (gnus-summary-recenter)
5755 (gnus-summary-position-point))
5757 (defun gnus-summary-scroll-down (lines)
5758 "Scroll down (or up) one line current article.
5759 Argument LINES specifies lines to be scrolled down (or up if negative)."
5761 (gnus-summary-scroll-up (- lines)))
5763 (defun gnus-summary-next-same-subject ()
5764 "Select next article which has the same subject as current one."
5766 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5768 (defun gnus-summary-prev-same-subject ()
5769 "Select previous article which has the same subject as current one."
5771 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5773 (defun gnus-summary-next-unread-same-subject ()
5774 "Select next unread article which has the same subject as current one."
5776 (gnus-summary-next-article t (gnus-summary-article-subject)))
5778 (defun gnus-summary-prev-unread-same-subject ()
5779 "Select previous unread article which has the same subject as current one."
5781 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5783 (defun gnus-summary-first-unread-article ()
5784 "Select the first unread article.
5785 Return nil if there are no unread articles."
5788 (when (gnus-summary-first-subject t)
5789 (gnus-summary-show-thread)
5790 (gnus-summary-first-subject t)
5791 (gnus-summary-display-article (gnus-summary-article-number)))
5792 (gnus-summary-position-point)))
5794 (defun gnus-summary-first-article ()
5795 "Select the first article.
5796 Return nil if there are no articles."
5799 (when (gnus-summary-first-subject)
5800 (gnus-summary-show-thread)
5801 (gnus-summary-first-subject)
5802 (gnus-summary-display-article (gnus-summary-article-number)))
5803 (gnus-summary-position-point)))
5805 (defun gnus-summary-best-unread-article ()
5806 "Select the unread article with the highest score."
5808 (let ((best -1000000)
5809 (data gnus-newsgroup-data)
5812 (and (gnus-data-unread-p (car data))
5814 (gnus-summary-article-score (gnus-data-number (car data))))
5817 article (gnus-data-number (car data))))
5818 (setq data (cdr data)))
5821 (gnus-summary-goto-article article)
5822 (error "No unread articles"))
5823 (gnus-summary-position-point))))
5825 (defun gnus-summary-last-subject ()
5826 "Go to the last displayed subject line in the group."
5827 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5829 (gnus-summary-goto-subject article))))
5831 (defun gnus-summary-goto-article (article &optional all-headers force)
5832 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5833 If ALL-HEADERS is non-nil, no header lines are hidden.
5834 If FORCE, go to the article even if it isn't displayed. If FORCE
5835 is a number, it is the line the article is to be displayed on."
5839 "Article number or Message-ID: "
5840 (mapcar (lambda (number) (list (int-to-string number)))
5841 gnus-newsgroup-limit))
5845 (if (and (stringp article)
5846 (string-match "@" article))
5847 (gnus-summary-refer-article article)
5848 (when (stringp article)
5849 (setq article (string-to-number article)))
5850 (if (gnus-summary-goto-subject article force)
5851 (gnus-summary-display-article article all-headers)
5852 (gnus-message 4 "Couldn't go to article %s" article) nil))
5853 (gnus-summary-position-point)))
5855 (defun gnus-summary-goto-last-article ()
5856 "Go to the previously read article."
5859 (when gnus-last-article
5860 (gnus-summary-goto-article gnus-last-article nil t))
5861 (gnus-summary-position-point)))
5863 (defun gnus-summary-pop-article (number)
5864 "Pop one article off the history and go to the previous.
5865 NUMBER articles will be popped off."
5868 (setq gnus-newsgroup-history
5869 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5871 (gnus-summary-goto-article (car to) nil t)
5872 (error "Article history empty")))
5873 (gnus-summary-position-point))
5875 ;; Summary commands and functions for limiting the summary buffer.
5877 (defun gnus-summary-limit-to-articles (n)
5878 "Limit the summary buffer to the next N articles.
5879 If not given a prefix, use the process marked articles instead."
5882 (let ((articles (gnus-summary-work-articles n)))
5883 (setq gnus-newsgroup-processable nil)
5884 (gnus-summary-limit articles))
5885 (gnus-summary-position-point)))
5887 (defun gnus-summary-pop-limit (&optional total)
5888 "Restore the previous limit.
5889 If given a prefix, remove all limits."
5892 (setq gnus-newsgroup-limits
5893 (list (mapcar (lambda (h) (mail-header-number h))
5894 gnus-newsgroup-headers))))
5895 (unless gnus-newsgroup-limits
5896 (error "No limit to pop"))
5898 (gnus-summary-limit nil 'pop)
5899 (gnus-summary-position-point)))
5901 (defun gnus-summary-limit-to-subject (subject &optional header)
5902 "Limit the summary buffer to articles that have subjects that match a regexp."
5903 (interactive "sLimit to subject (regexp): ")
5905 (setq header "subject"))
5906 (when (not (equal "" subject))
5908 (let ((articles (gnus-summary-find-matching
5909 (or header "subject") subject 'all)))
5911 (error "Found no matches for \"%s\"" subject))
5912 (gnus-summary-limit articles))
5913 (gnus-summary-position-point))))
5915 (defun gnus-summary-limit-to-author (from)
5916 "Limit the summary buffer to articles that have authors that match a regexp."
5917 (interactive "sLimit to author (regexp): ")
5918 (gnus-summary-limit-to-subject from "from"))
5920 (defun gnus-summary-limit-to-age (age &optional younger-p)
5921 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5922 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5923 articles that are younger than AGE days."
5924 (interactive "nTime in days: \nP")
5926 (let ((data gnus-newsgroup-data)
5927 (cutoff (days-to-time age))
5928 articles d date is-younger)
5929 (while (setq d (pop data))
5930 (when (and (vectorp (gnus-data-header d))
5931 (setq date (mail-header-date (gnus-data-header d))))
5932 (setq is-younger (time-less-p
5933 (time-since (date-to-time date))
5938 (push (gnus-data-number d) articles))))
5939 (gnus-summary-limit (nreverse articles)))
5940 (gnus-summary-position-point)))
5942 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5944 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5946 (defun gnus-summary-limit-to-unread (&optional all)
5947 "Limit the summary buffer to articles that are not marked as read.
5948 If ALL is non-nil, limit strictly to unread articles."
5951 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5952 (gnus-summary-limit-to-marks
5953 ;; Concat all the marks that say that an article is read and have
5955 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5956 gnus-killed-mark gnus-kill-file-mark
5957 gnus-low-score-mark gnus-expirable-mark
5958 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5959 gnus-duplicate-mark gnus-souped-mark)
5962 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5963 (make-obsolete 'gnus-summary-delete-marked-with
5964 'gnus-summary-limit-exlude-marks)
5966 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5967 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5968 If REVERSE, limit the summary buffer to articles that are marked
5969 with MARKS. MARKS can either be a string of marks or a list of marks.
5970 Returns how many articles were removed."
5971 (interactive "sMarks: ")
5972 (gnus-summary-limit-to-marks marks t))
5974 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5975 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5976 If REVERSE (the prefix), limit the summary buffer to articles that are
5977 not marked with MARKS. MARKS can either be a string of marks or a
5979 Returns how many articles were removed."
5980 (interactive "sMarks: \nP")
5982 (let ((data gnus-newsgroup-data)
5983 (marks (if (listp marks) marks
5984 (append marks nil))) ; Transform to list.
5987 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5988 (memq (gnus-data-mark (car data)) marks))
5989 (push (gnus-data-number (car data)) articles))
5990 (setq data (cdr data)))
5991 (gnus-summary-limit articles))
5992 (gnus-summary-position-point)))
5994 (defun gnus-summary-limit-to-score (&optional score)
5995 "Limit to articles with score at or above SCORE."
5997 (setq score (if score
5998 (prefix-numeric-value score)
5999 (or gnus-summary-default-score 0)))
6000 (let ((data gnus-newsgroup-data)
6003 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6005 (push (gnus-data-number (car data)) articles))
6006 (setq data (cdr data)))
6008 (gnus-summary-limit articles)
6009 (gnus-summary-position-point))))
6011 (defun gnus-summary-limit-include-thread (id)
6012 "Display all the hidden articles that in the current thread."
6013 (interactive (list (mail-header-id (gnus-summary-article-header))))
6014 (let ((articles (gnus-articles-in-thread
6015 (gnus-id-to-thread (gnus-root-id id)))))
6017 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6018 (gnus-summary-position-point))))
6020 (defun gnus-summary-limit-include-dormant ()
6021 "Display all the hidden articles that are marked as dormant.
6022 Note that this command only works on a subset of the articles currently
6023 fetched for this group."
6025 (unless gnus-newsgroup-dormant
6026 (error "There are no dormant articles in this group"))
6028 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6029 (gnus-summary-position-point)))
6031 (defun gnus-summary-limit-exclude-dormant ()
6032 "Hide all dormant articles."
6035 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6036 (gnus-summary-position-point)))
6038 (defun gnus-summary-limit-exclude-childless-dormant ()
6039 "Hide all dormant articles that have no children."
6041 (let ((data (gnus-data-list t))
6042 articles d children)
6043 ;; Find all articles that are either not dormant or have
6045 (while (setq d (pop data))
6046 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6048 (gnus-article-children (gnus-data-number d)))
6051 (when (memq (car children) articles)
6056 (push (gnus-data-number d) articles)))
6059 (gnus-summary-limit articles)
6060 (gnus-summary-position-point))))
6062 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6063 "Mark all unread excluded articles as read.
6064 If ALL, mark even excluded ticked and dormants as read."
6066 (let ((articles (gnus-sorted-complement
6068 (mapcar (lambda (h) (mail-header-number h))
6069 gnus-newsgroup-headers)
6071 (sort gnus-newsgroup-limit '<)))
6073 (setq gnus-newsgroup-unreads
6074 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6076 (setq gnus-newsgroup-dormant nil
6077 gnus-newsgroup-marked nil
6078 gnus-newsgroup-reads
6080 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6081 gnus-newsgroup-reads))
6082 (while (setq article (pop articles))
6083 (unless (or (memq article gnus-newsgroup-dormant)
6084 (memq article gnus-newsgroup-marked))
6085 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6087 (defun gnus-summary-limit (articles &optional pop)
6089 ;; We pop the previous limit off the stack and use that.
6090 (setq articles (car gnus-newsgroup-limits)
6091 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6092 ;; We use the new limit, so we push the old limit on the stack.
6093 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6095 (setq gnus-newsgroup-limit articles)
6096 (let ((total (length gnus-newsgroup-data))
6097 (data (gnus-data-find-list (gnus-summary-article-number)))
6098 (gnus-summary-mark-below nil) ; Inhibit this.
6100 ;; This will do all the work of generating the new summary buffer
6101 ;; according to the new limit.
6102 (gnus-summary-prepare)
6103 ;; Hide any threads, possibly.
6104 (and gnus-show-threads
6105 gnus-thread-hide-subtree
6106 (gnus-summary-hide-all-threads))
6107 ;; Try to return to the article you were at, or one in the
6110 ;; We try to find some article after the current one.
6112 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6115 (setq data (cdr data))))
6117 ;; If there is no data, that means that we were after the last
6118 ;; article. The same goes when we can't find any articles
6119 ;; after the current one.
6120 (goto-char (point-max))
6121 (gnus-summary-find-prev))
6122 (gnus-set-mode-line 'summary)
6123 ;; We return how many articles were removed from the summary
6124 ;; buffer as a result of the new limit.
6125 (- total (length gnus-newsgroup-data))))
6127 (defsubst gnus-invisible-cut-children (threads)
6130 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6135 (defsubst gnus-cut-thread (thread)
6136 "Go forwards in the thread until we find an article that we want to display."
6137 (when (or (eq gnus-fetch-old-headers 'some)
6138 (eq gnus-fetch-old-headers 'invisible)
6139 (eq gnus-build-sparse-threads 'some)
6140 (eq gnus-build-sparse-threads 'more))
6141 ;; Deal with old-fetched headers and sparse threads.
6145 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6146 (gnus-summary-article-ancient-p
6147 (mail-header-number (car thread))))
6148 (if (or (<= (length (cdr thread)) 1)
6149 (eq gnus-fetch-old-headers 'invisible))
6150 (setq gnus-newsgroup-limit
6151 (delq (mail-header-number (car thread))
6152 gnus-newsgroup-limit)
6153 thread (cadr thread))
6154 (when (gnus-invisible-cut-children (cdr thread))
6155 (let ((th (cdr thread)))
6157 (if (memq (mail-header-number (caar th))
6158 gnus-newsgroup-limit)
6159 (setq thread (car th)
6161 (setq th (cdr th))))))))))
6164 (defun gnus-cut-threads (threads)
6165 "Cut off all uninteresting articles from the beginning of threads."
6166 (when (or (eq gnus-fetch-old-headers 'some)
6167 (eq gnus-fetch-old-headers 'invisible)
6168 (eq gnus-build-sparse-threads 'some)
6169 (eq gnus-build-sparse-threads 'more))
6172 (setcar th (gnus-cut-thread (car th)))
6173 (setq th (cdr th)))))
6174 ;; Remove nixed out threads.
6177 (defun gnus-summary-initial-limit (&optional show-if-empty)
6178 "Figure out what the initial limit is supposed to be on group entry.
6179 This entails weeding out unwanted dormants, low-scored articles,
6180 fetch-old-headers verbiage, and so on."
6181 ;; Most groups have nothing to remove.
6182 (if (or gnus-inhibit-limiting
6183 (and (null gnus-newsgroup-dormant)
6184 (not (eq gnus-fetch-old-headers 'some))
6185 (not (eq gnus-fetch-old-headers 'invisible))
6186 (null gnus-summary-expunge-below)
6187 (not (eq gnus-build-sparse-threads 'some))
6188 (not (eq gnus-build-sparse-threads 'more))
6189 (null gnus-thread-expunge-below)
6190 (not gnus-use-nocem)))
6192 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6193 (setq gnus-newsgroup-limit nil)
6196 (unless (car (symbol-value node))
6197 ;; These threads have no parents -- they are roots.
6198 (let ((nodes (cdr (symbol-value node)))
6201 (if (and gnus-thread-expunge-below
6202 (< (gnus-thread-total-score (car nodes))
6203 gnus-thread-expunge-below))
6204 (gnus-expunge-thread (pop nodes))
6205 (setq thread (pop nodes))
6206 (gnus-summary-limit-children thread))))))
6207 gnus-newsgroup-dependencies)
6208 ;; If this limitation resulted in an empty group, we might
6209 ;; pop the previous limit and use it instead.
6210 (when (and (not gnus-newsgroup-limit)
6212 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6213 gnus-newsgroup-limit))
6215 (defun gnus-summary-limit-children (thread)
6216 "Return 1 if this subthread is visible and 0 if it is not."
6217 ;; First we get the number of visible children to this thread. This
6218 ;; is done by recursing down the thread using this function, so this
6219 ;; will really go down to a leaf article first, before slowly
6220 ;; working its way up towards the root.
6224 (apply '+ (mapcar 'gnus-summary-limit-children
6227 (number (mail-header-number (car thread)))
6230 (not (memq number gnus-newsgroup-marked))
6232 ;; If this article is dormant and has absolutely no visible
6233 ;; children, then this article isn't visible.
6234 (and (memq number gnus-newsgroup-dormant)
6236 ;; If this is "fetch-old-headered" and there is no
6237 ;; visible children, then we don't want this article.
6238 (and (eq gnus-fetch-old-headers 'some)
6239 (gnus-summary-article-ancient-p number)
6241 ;; If this is "fetch-old-headered" and `invisible', then
6242 ;; we don't want this article.
6243 (and (eq gnus-fetch-old-headers 'invisible)
6244 (gnus-summary-article-ancient-p number))
6245 ;; If this is a sparsely inserted article with no children,
6246 ;; we don't want it.
6247 (and (eq gnus-build-sparse-threads 'some)
6248 (gnus-summary-article-sparse-p number)
6250 ;; If we use expunging, and this article is really
6251 ;; low-scored, then we don't want this article.
6252 (when (and gnus-summary-expunge-below
6254 (or (cdr (assq number gnus-newsgroup-scored))
6255 gnus-summary-default-score))
6256 gnus-summary-expunge-below))
6257 ;; We increase the expunge-tally here, but that has
6258 ;; nothing to do with the limits, really.
6259 (incf gnus-newsgroup-expunged-tally)
6260 ;; We also mark as read here, if that's wanted.
6261 (when (and gnus-summary-mark-below
6262 (< score gnus-summary-mark-below))
6263 (setq gnus-newsgroup-unreads
6264 (delq number gnus-newsgroup-unreads))
6265 (if gnus-newsgroup-auto-expire
6266 (push number gnus-newsgroup-expirable)
6267 (push (cons number gnus-low-score-mark)
6268 gnus-newsgroup-reads)))
6270 ;; Check NoCeM things.
6271 (if (and gnus-use-nocem
6272 (gnus-nocem-unwanted-article-p
6273 (mail-header-id (car thread))))
6275 (setq gnus-newsgroup-unreads
6276 (delq number gnus-newsgroup-unreads))
6278 ;; Nope, invisible article.
6280 ;; Ok, this article is to be visible, so we add it to the limit
6282 (push number gnus-newsgroup-limit)
6285 (defun gnus-expunge-thread (thread)
6286 "Mark all articles in THREAD as read."
6287 (let* ((number (mail-header-number (car thread))))
6288 (incf gnus-newsgroup-expunged-tally)
6289 ;; We also mark as read here, if that's wanted.
6290 (setq gnus-newsgroup-unreads
6291 (delq number gnus-newsgroup-unreads))
6292 (if gnus-newsgroup-auto-expire
6293 (push number gnus-newsgroup-expirable)
6294 (push (cons number gnus-low-score-mark)
6295 gnus-newsgroup-reads)))
6296 ;; Go recursively through all subthreads.
6297 (mapcar 'gnus-expunge-thread (cdr thread)))
6299 ;; Summary article oriented commands
6301 (defun gnus-summary-refer-parent-article (n)
6302 "Refer parent article N times.
6303 If N is negative, go to ancestor -N instead.
6304 The difference between N and the number of articles fetched is returned."
6308 (when (not (natnump n))
6313 (setq header (gnus-summary-article-header))
6314 (if (and (eq (mail-header-number header)
6315 (cdr gnus-article-current))
6316 (equal gnus-newsgroup-name
6317 (car gnus-article-current)))
6318 ;; If we try to find the parent of the currently
6319 ;; displayed article, then we take a look at the actual
6320 ;; References header, since this is slightly more
6321 ;; reliable than the References field we got from the
6324 (set-buffer gnus-original-article-buffer)
6325 (nnheader-narrow-to-headers)
6326 (unless (setq ref (message-fetch-field "references"))
6327 (setq ref (message-fetch-field "in-reply-to")))
6330 ;; It's not the current article, so we take a bet on
6331 ;; the value we got from the server.
6332 (mail-header-references header)))
6334 (not (equal ref "")))
6335 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6336 (gnus-message 1 "Couldn't find parent"))
6337 (gnus-message 1 "No references in article %d"
6338 (gnus-summary-article-number))
6341 (gnus-summary-position-point)
6344 (defun gnus-summary-refer-references ()
6345 "Fetch all articles mentioned in the References header.
6346 Return the number of articles fetched."
6348 (let ((ref (mail-header-references (gnus-summary-article-header)))
6349 (current (gnus-summary-article-number))
6353 (error "No References in the current article")
6354 ;; For each Message-ID in the References header...
6355 (while (string-match "<[^>]*>" ref)
6357 ;; ... fetch that article.
6358 (gnus-summary-refer-article
6359 (prog1 (match-string 0 ref)
6360 (setq ref (substring ref (match-end 0))))))
6361 (gnus-summary-goto-subject current)
6362 (gnus-summary-position-point)
6365 (defun gnus-summary-refer-thread (&optional limit)
6366 "Fetch all articles in the current thread.
6367 If LIMIT (the numerical prefix), fetch that many old headers instead
6368 of what's specified by the `gnus-refer-thread-limit' variable."
6370 (let ((id (mail-header-id (gnus-summary-article-header)))
6371 (limit (if limit (prefix-numeric-value limit)
6372 gnus-refer-thread-limit)))
6373 ;; We want to fetch LIMIT *old* headers, but we also have to
6374 ;; re-fetch all the headers in the current buffer, because many of
6375 ;; them may be undisplayed. So we adjust LIMIT.
6376 (when (numberp limit)
6377 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6378 (unless (eq gnus-fetch-old-headers 'invisible)
6379 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6380 ;; Retrieve the headers and read them in.
6381 (if (eq (gnus-retrieve-headers
6382 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6384 (gnus-build-all-threads)
6385 (error "Can't fetch thread from backends that don't support NOV"))
6386 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6387 (gnus-summary-limit-include-thread id)))
6389 (defun gnus-summary-refer-article (message-id &optional arg)
6390 "Fetch an article specified by MESSAGE-ID.
6391 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6392 or `gnus-select-method', no matter what backend the article comes from."
6393 (interactive "sMessage-ID: \nP")
6394 (when (and (stringp message-id)
6395 (not (zerop (length message-id))))
6396 ;; Construct the correct Message-ID if necessary.
6397 ;; Suggested by tale@pawl.rpi.edu.
6398 (unless (string-match "^<" message-id)
6399 (setq message-id (concat "<" message-id)))
6400 (unless (string-match ">$" message-id)
6401 (setq message-id (concat message-id ">")))
6402 (let* ((header (gnus-id-to-header message-id))
6404 (gnus-summary-article-sparse-p
6405 (mail-header-number header))
6406 (memq (mail-header-number header)
6407 gnus-newsgroup-limit))))
6409 ;; If the article is present in the buffer we just go to it.
6411 (or (not (gnus-summary-article-sparse-p
6412 (mail-header-number header)))
6415 (gnus-summary-goto-article
6416 (mail-header-number header) nil t)
6418 (gnus-summary-update-article (mail-header-number header)))))
6420 ;; We fetch the article
6421 (let ((gnus-override-method
6422 (cond ((gnus-news-group-p gnus-newsgroup-name)
6423 gnus-refer-article-method)
6425 (or gnus-refer-article-method gnus-select-method))
6428 ;; Start the special refer-article method, if necessary.
6429 (when (and gnus-refer-article-method
6430 (gnus-news-group-p gnus-newsgroup-name))
6431 (gnus-check-server gnus-refer-article-method))
6432 ;; Fetch the header, and display the article.
6433 (if (setq number (gnus-summary-insert-subject message-id))
6434 (gnus-summary-select-article nil nil nil number)
6435 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6437 (defun gnus-summary-edit-parameters ()
6438 "Edit the group parameters of the current group."
6440 (gnus-group-edit-group gnus-newsgroup-name 'params))
6442 (defun gnus-summary-enter-digest-group (&optional force)
6443 "Enter an nndoc group based on the current article.
6444 If FORCE, force a digest interpretation. If not, try
6445 to guess what the document format is."
6447 (let ((conf gnus-current-window-configuration))
6449 (gnus-summary-select-article))
6450 (setq gnus-current-window-configuration conf)
6451 (let* ((name (format "%s-%d"
6452 (gnus-group-prefixed-name
6453 gnus-newsgroup-name (list 'nndoc ""))
6455 (set-buffer gnus-summary-buffer)
6456 gnus-current-article)))
6457 (ogroup gnus-newsgroup-name)
6458 (params (append (gnus-info-params (gnus-get-info ogroup))
6459 (list (cons 'to-group ogroup))
6460 (list (cons 'save-article-group ogroup))))
6461 (case-fold-search t)
6462 (buf (current-buffer))
6465 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6466 (insert-buffer-substring gnus-original-article-buffer)
6467 ;; Remove lines that may lead nndoc to misinterpret the
6470 (goto-char (point-min))
6471 (or (search-forward "\n\n" nil t) (point)))
6472 (goto-char (point-min))
6473 (delete-matching-lines "^\\(Path\\):\\|^From ")
6476 (if (gnus-group-read-ephemeral-group
6477 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6479 ,(if force 'digest 'guess))) t)
6480 ;; Make all postings to this group go to the parent group.
6481 (nconc (gnus-info-params (gnus-get-info name))
6483 ;; Couldn't select this doc group.
6484 (switch-to-buffer buf)
6485 (gnus-set-global-variables)
6486 (gnus-configure-windows 'summary)
6487 (gnus-message 3 "Article couldn't be entered?"))
6488 (kill-buffer dig)))))
6490 (defun gnus-summary-read-document (n)
6491 "Open a new group based on the current article(s).
6492 This will allow you to read digests and other similar
6493 documents as newsgroups.
6494 Obeys the standard process/prefix convention."
6496 (let* ((articles (gnus-summary-work-articles n))
6497 (ogroup gnus-newsgroup-name)
6498 (params (append (gnus-info-params (gnus-get-info ogroup))
6499 (list (cons 'to-group ogroup))))
6500 article group egroup groups vgroup)
6501 (while (setq article (pop articles))
6502 (setq group (format "%s-%d" gnus-newsgroup-name article))
6503 (gnus-summary-remove-process-mark article)
6504 (when (gnus-summary-display-article article)
6507 (insert-buffer-substring gnus-original-article-buffer)
6508 ;; Remove some headers that may lead nndoc to make
6510 (message-narrow-to-head)
6511 (goto-char (point-min))
6512 (delete-matching-lines "^\\(Path\\):\\|^From ")
6515 (gnus-group-read-ephemeral-group
6516 group `(nndoc ,group (nndoc-address ,(current-buffer))
6517 (nndoc-article-type guess))
6520 ;; Make all postings to this group go to the parent group.
6521 (nconc (gnus-info-params (gnus-get-info egroup))
6523 (push egroup groups))
6524 ;; Couldn't select this doc group.
6525 (gnus-error 3 "Article couldn't be entered"))))))
6526 ;; Now we have selected all the documents.
6529 (error "None of the articles could be interpreted as documents"))
6530 ((gnus-group-read-ephemeral-group
6531 (setq vgroup (format
6532 "nnvirtual:%s-%s" gnus-newsgroup-name
6533 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6534 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6536 (cons (current-buffer) 'summary)))
6538 (error "Couldn't select virtual nndoc group")))))
6540 (defun gnus-summary-isearch-article (&optional regexp-p)
6541 "Do incremental search forward on the current article.
6542 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6544 (gnus-summary-select-article)
6545 (gnus-configure-windows 'article)
6546 (gnus-eval-in-buffer-window gnus-article-buffer
6549 (isearch-forward regexp-p))))
6551 (defun gnus-summary-search-article-forward (regexp &optional backward)
6552 "Search for an article containing REGEXP forward.
6553 If BACKWARD, search backward instead."
6556 (format "Search article %s (regexp%s): "
6557 (if current-prefix-arg "backward" "forward")
6558 (if gnus-last-search-regexp
6559 (concat ", default " gnus-last-search-regexp)
6561 current-prefix-arg))
6562 (if (string-equal regexp "")
6563 (setq regexp (or gnus-last-search-regexp ""))
6564 (setq gnus-last-search-regexp regexp))
6565 (if (gnus-summary-search-article regexp backward)
6566 (gnus-summary-show-thread)
6567 (error "Search failed: \"%s\"" regexp)))
6569 (defun gnus-summary-search-article-backward (regexp)
6570 "Search for an article containing REGEXP backward."
6573 (format "Search article backward (regexp%s): "
6574 (if gnus-last-search-regexp
6575 (concat ", default " gnus-last-search-regexp)
6577 (gnus-summary-search-article-forward regexp 'backward))
6579 (defun gnus-summary-search-article (regexp &optional backward)
6580 "Search for an article containing REGEXP.
6581 Optional argument BACKWARD means do search for backward.
6582 `gnus-select-article-hook' is not called during the search."
6583 ;; We have to require this here to make sure that the following
6584 ;; dynamic binding isn't shadowed by autoloading.
6585 (require 'gnus-async)
6586 (let ((gnus-select-article-hook nil) ;Disable hook.
6587 (gnus-article-display-hook nil)
6588 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6589 (gnus-use-article-prefetch nil)
6590 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6591 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6592 (sum (current-buffer))
6594 point gnus-display-mime-function)
6595 (gnus-save-hidden-threads
6596 (gnus-summary-select-article)
6597 (set-buffer gnus-article-buffer)
6601 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6603 (re-search-backward regexp nil t)
6604 (re-search-forward regexp nil t))
6605 ;; We found the regexp.
6610 (get-buffer-window (current-buffer))
6614 (setq point (point)))
6615 ;; We didn't find it, so we go to the next article.
6618 (while (eq found 'not)
6619 (if (not (if backward (gnus-summary-find-prev)
6620 (gnus-summary-find-next)))
6621 ;; No more articles.
6623 ;; Select the next article and adjust point.
6624 (unless (gnus-summary-article-sparse-p
6625 (gnus-summary-article-number))
6627 (gnus-summary-select-article)
6628 (set-buffer gnus-article-buffer)
6630 (goto-char (if backward (point-max) (point-min))))))))
6631 (gnus-message 7 ""))
6632 ;; Return whether we found the regexp.
6633 (when (eq found 'found)
6635 (gnus-summary-show-thread)
6636 (gnus-summary-goto-subject gnus-current-article)
6637 (gnus-summary-position-point)
6640 (defun gnus-summary-find-matching (header regexp &optional backward unread
6642 "Return a list of all articles that match REGEXP on HEADER.
6643 The search stars on the current article and goes forwards unless
6644 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6645 If UNREAD is non-nil, only unread articles will
6646 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6647 in the comparisons."
6648 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6649 (gnus-data-find-list
6650 (gnus-summary-article-number) (gnus-data-list backward))))
6651 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6652 (case-fold-search (not not-case-fold))
6654 (unless (fboundp (intern (concat "mail-header-" header)))
6655 (error "%s is not a valid header" header))
6658 (and (or (not unread) ; We want all articles...
6659 (gnus-data-unread-p d)) ; Or just unreads.
6660 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6661 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6662 (push (gnus-data-number d) articles)) ; Success!
6663 (setq data (cdr data)))
6664 (nreverse articles)))
6666 (defun gnus-summary-execute-command (header regexp command &optional backward)
6667 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6668 If HEADER is an empty string (or nil), the match is done on the entire
6669 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6671 (list (let ((completion-ignore-case t))
6674 (mapcar (lambda (string) (list string))
6675 '("Number" "Subject" "From" "Lines" "Date"
6676 "Message-ID" "Xref" "References" "Body"))
6677 nil 'require-match))
6678 (read-string "Regexp: ")
6679 (read-key-sequence "Command: ")
6680 current-prefix-arg))
6681 (when (equal header "Body")
6683 ;; Hidden thread subtrees must be searched as well.
6684 (gnus-summary-show-all-threads)
6685 ;; We don't want to change current point nor window configuration.
6687 (save-window-excursion
6688 (gnus-message 6 "Executing %s..." (key-description command))
6689 ;; We'd like to execute COMMAND interactively so as to give arguments.
6690 (gnus-execute header regexp
6691 `(call-interactively ',(key-binding command))
6693 (gnus-message 6 "Executing %s...done" (key-description command)))))
6695 (defun gnus-summary-beginning-of-article ()
6696 "Scroll the article back to the beginning."
6698 (gnus-summary-select-article)
6699 (gnus-configure-windows 'article)
6700 (gnus-eval-in-buffer-window gnus-article-buffer
6702 (goto-char (point-min))
6703 (when gnus-page-broken
6704 (gnus-narrow-to-page))))
6706 (defun gnus-summary-end-of-article ()
6707 "Scroll to the end of the article."
6709 (gnus-summary-select-article)
6710 (gnus-configure-windows 'article)
6711 (gnus-eval-in-buffer-window gnus-article-buffer
6713 (goto-char (point-max))
6715 (when gnus-page-broken
6716 (gnus-narrow-to-page))))
6718 (defun gnus-summary-print-article (&optional filename n)
6719 "Generate and print a PostScript image of the N next (mail) articles.
6721 If N is negative, print the N previous articles. If N is nil and articles
6722 have been marked with the process mark, print these instead.
6724 If the optional second argument FILENAME is nil, send the image to the
6725 printer. If FILENAME is a string, save the PostScript image in a file with
6726 that name. If FILENAME is a number, prompt the user for the name of the file
6728 (interactive (list (ps-print-preprint current-prefix-arg)
6729 current-prefix-arg))
6730 (dolist (article (gnus-summary-work-articles n))
6731 (gnus-summary-select-article nil nil 'pseudo article)
6732 (gnus-eval-in-buffer-window gnus-article-buffer
6733 (let ((buffer (generate-new-buffer " *print*")))
6736 (copy-to-buffer buffer (point-min) (point-max))
6738 (gnus-article-delete-invisible-text)
6739 (let ((ps-left-header
6742 (mail-header-subject gnus-current-headers) ")")
6744 (mail-header-from gnus-current-headers) ")")))
6747 "/pagenumberstring load"
6749 (mail-header-date gnus-current-headers) ")"))))
6750 (gnus-run-hooks 'gnus-ps-print-hook)
6752 (ps-print-buffer-with-faces filename))))
6753 (kill-buffer buffer))))))
6755 (defun gnus-summary-show-article (&optional arg)
6756 "Force re-fetching of the current article.
6757 If ARG (the prefix) is non-nil, show the raw article without any
6758 article massaging functions being run."
6761 ;; Select the article the normal way.
6762 (gnus-summary-select-article nil 'force)
6763 ;; Bind the article treatment functions to nil.
6764 (let ((gnus-have-all-headers t)
6765 gnus-article-display-hook
6766 gnus-article-prepare-hook
6767 gnus-article-decode-hook
6768 gnus-display-mime-function
6771 (gnus-summary-select-article nil 'force)))
6772 (gnus-summary-goto-subject gnus-current-article)
6773 (gnus-summary-position-point))
6775 (defun gnus-summary-verbose-headers (&optional arg)
6776 "Toggle permanent full header display.
6777 If ARG is a positive number, turn header display on.
6778 If ARG is a negative number, turn header display off."
6780 (setq gnus-show-all-headers
6781 (cond ((or (not (numberp arg))
6783 (not gnus-show-all-headers))
6786 (gnus-summary-show-article))
6788 (defun gnus-summary-toggle-header (&optional arg)
6789 "Show the headers if they are hidden, or hide them if they are shown.
6790 If ARG is a positive number, show the entire header.
6791 If ARG is a negative number, hide the unwanted header lines."
6794 (set-buffer gnus-article-buffer)
6795 (let* ((buffer-read-only nil)
6796 (inhibit-point-motion-hooks t)
6797 (hidden (text-property-any
6798 (goto-char (point-min)) (search-forward "\n\n")
6801 (goto-char (point-min))
6802 (when (search-forward "\n\n" nil t)
6803 (delete-region (point-min) (1- (point))))
6804 (goto-char (point-min))
6806 (set-buffer gnus-original-article-buffer)
6807 (goto-char (point-min))
6808 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6809 (insert-buffer-substring gnus-original-article-buffer 1 e)
6810 (let ((article-inhibit-hiding t))
6811 (gnus-run-hooks 'gnus-article-display-hook))
6812 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6813 (gnus-article-hide-headers)))))
6815 (defun gnus-summary-show-all-headers ()
6816 "Make all header lines visible."
6818 (gnus-article-show-all-headers))
6820 (defun gnus-summary-caesar-message (&optional arg)
6821 "Caesar rotate the current article by 13.
6822 The numerical prefix specifies how many places to rotate each letter
6825 (gnus-summary-select-article)
6826 (let ((mail-header-separator ""))
6827 (gnus-eval-in-buffer-window gnus-article-buffer
6830 (let ((start (window-start))
6832 (message-caesar-buffer-body arg)
6833 (set-window-start (get-buffer-window (current-buffer)) start))))))
6835 (defun gnus-summary-stop-page-breaking ()
6836 "Stop page breaking in the current article."
6838 (gnus-summary-select-article)
6839 (gnus-eval-in-buffer-window gnus-article-buffer
6841 (when (gnus-visual-p 'page-marker)
6842 (let ((buffer-read-only nil))
6843 (gnus-remove-text-with-property 'gnus-prev)
6844 (gnus-remove-text-with-property 'gnus-next))
6845 (setq gnus-page-broken nil))))
6847 (defun gnus-summary-move-article (&optional n to-newsgroup
6848 select-method action)
6849 "Move the current article to a different newsgroup.
6850 If N is a positive number, move the N next articles.
6851 If N is a negative number, move the N previous articles.
6852 If N is nil and any articles have been marked with the process mark,
6853 move those articles instead.
6854 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6855 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6856 re-spool using this method.
6858 For this function to work, both the current newsgroup and the
6859 newsgroup that you want to move to have to support the `request-move'
6860 and `request-accept' functions."
6863 (setq action 'move))
6864 ;; Disable marking as read.
6865 (let (gnus-mark-article-hook)
6866 (save-window-excursion
6867 (gnus-summary-select-article)))
6868 ;; Check whether the source group supports the required functions.
6869 (cond ((and (eq action 'move)
6870 (not (gnus-check-backend-function
6871 'request-move-article gnus-newsgroup-name)))
6872 (error "The current group does not support article moving"))
6873 ((and (eq action 'crosspost)
6874 (not (gnus-check-backend-function
6875 'request-replace-article gnus-newsgroup-name)))
6876 (error "The current group does not support article editing")))
6877 (let ((articles (gnus-summary-work-articles n))
6878 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6879 (names '((move "Move" "Moving")
6880 (copy "Copy" "Copying")
6881 (crosspost "Crosspost" "Crossposting")))
6882 (copy-buf (save-excursion
6883 (nnheader-set-temp-buffer " *copy article*")))
6884 art-group to-method new-xref article to-groups)
6885 (unless (assq action names)
6886 (error "Unknown action %s" action))
6887 ;; Read the newsgroup name.
6888 (when (and (not to-newsgroup)
6889 (not select-method))
6891 (gnus-read-move-group-name
6892 (cadr (assq action names))
6893 (symbol-value (intern (format "gnus-current-%s-group" action)))
6895 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6896 (setq to-method (or select-method
6897 (gnus-group-name-to-method to-newsgroup)))
6898 ;; Check the method we are to move this article to...
6899 (unless (gnus-check-backend-function
6900 'request-accept-article (car to-method))
6901 (error "%s does not support article copying" (car to-method)))
6902 (unless (gnus-check-server to-method)
6903 (error "Can't open server %s" (car to-method)))
6904 (gnus-message 6 "%s to %s: %s..."
6905 (caddr (assq action names))
6906 (or (car select-method) to-newsgroup) articles)
6908 (setq article (pop articles))
6912 ;; Move the article.
6914 ;; Remove this article from future suppression.
6915 (gnus-dup-unsuppress-article article)
6916 (gnus-request-move-article
6917 article ; Article to move
6918 gnus-newsgroup-name ; From newsgroup
6919 (nth 1 (gnus-find-method-for-group
6920 gnus-newsgroup-name)) ; Server
6921 (list 'gnus-request-accept-article
6922 to-newsgroup (list 'quote select-method)
6923 (not articles)) ; Accept form
6924 (not articles))) ; Only save nov last time
6925 ;; Copy the article.
6928 (set-buffer copy-buf)
6929 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6930 (gnus-request-accept-article
6931 to-newsgroup select-method (not articles)))))
6932 ;; Crosspost the article.
6933 ((eq action 'crosspost)
6934 (let ((xref (message-tokenize-header
6935 (mail-header-xref (gnus-summary-article-header article))
6937 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6940 (setq xref (list (system-name))))
6943 (mapconcat 'identity
6944 (delete "Xref:" (delete new-xref xref))
6948 (set-buffer copy-buf)
6949 ;; First put the article in the destination group.
6950 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6951 (when (consp (setq art-group
6952 (gnus-request-accept-article
6953 to-newsgroup select-method (not articles))))
6954 (setq new-xref (concat new-xref " " (car art-group)
6955 ":" (cdr art-group)))
6956 ;; Now we have the new Xrefs header, so we insert
6957 ;; it and replace the new article.
6958 (nnheader-replace-header "Xref" new-xref)
6959 (gnus-request-replace-article
6960 (cdr art-group) to-newsgroup (current-buffer))
6964 (gnus-message 1 "Couldn't %s article %s"
6965 (cadr (assq action names)) article))
6966 ((and (eq art-group 'junk)
6968 (gnus-summary-mark-article article gnus-canceled-mark)
6969 (gnus-message 4 "Deleted article %s" article))
6971 (let* ((pto-group (gnus-group-prefixed-name
6972 (car art-group) to-method))
6974 (gnus-gethash pto-group gnus-newsrc-hashtb))
6975 (info (nth 2 entry))
6976 (to-group (gnus-info-group info)))
6977 ;; Update the group that has been moved to.
6979 (memq action '(move copy)))
6980 (unless (member to-group to-groups)
6981 (push to-group to-groups))
6983 (unless (memq article gnus-newsgroup-unreads)
6985 info (gnus-add-to-range (gnus-info-read info)
6986 (list (cdr art-group)))))
6988 ;; Copy any marks over to the new group.
6989 (let ((marks gnus-article-mark-lists)
6990 (to-article (cdr art-group)))
6992 ;; See whether the article is to be put in the cache.
6993 (when gnus-use-cache
6994 (gnus-cache-possibly-enter-article
6996 (let ((header (copy-sequence
6997 (gnus-summary-article-header article))))
6998 (mail-header-set-number header to-article)
7000 (memq article gnus-newsgroup-marked)
7001 (memq article gnus-newsgroup-dormant)
7002 (memq article gnus-newsgroup-unreads)))
7004 (when (and (equal to-group gnus-newsgroup-name)
7005 (not (memq article gnus-newsgroup-unreads)))
7006 ;; Mark this article as read in this group.
7007 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7008 (setcdr (gnus-active to-group) to-article)
7009 (setcdr gnus-newsgroup-active to-article))
7012 (when (memq article (symbol-value
7013 (intern (format "gnus-newsgroup-%s"
7015 ;; If the other group is the same as this group,
7016 ;; then we have to add the mark to the list.
7017 (when (equal to-group gnus-newsgroup-name)
7018 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7021 (intern (format "gnus-newsgroup-%s"
7023 ;; Copy the marks to other group.
7024 (gnus-add-marked-articles
7025 to-group (cdar marks) (list to-article) info))
7026 (setq marks (cdr marks)))
7029 (concat "(gnus-group-set-info '"
7030 (gnus-prin1-to-string (gnus-get-info to-group))
7033 ;; Update the Xref header in this article to point to
7034 ;; the new crossposted article we have just created.
7035 (when (eq action 'crosspost)
7037 (set-buffer copy-buf)
7038 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7039 (nnheader-replace-header "Xref" new-xref)
7040 (gnus-request-replace-article
7041 article gnus-newsgroup-name (current-buffer)))))
7043 ;;;!!!Why is this necessary?
7044 (set-buffer gnus-summary-buffer)
7046 (gnus-summary-goto-subject article)
7047 (when (eq action 'move)
7048 (gnus-summary-mark-article article gnus-canceled-mark))))
7049 (gnus-summary-remove-process-mark article))
7050 ;; Re-activate all groups that have been moved to.
7053 (set-buffer gnus-group-buffer)
7054 (when (gnus-group-goto-group (car to-groups) t)
7055 (gnus-group-get-new-news-this-group 1 t))
7058 (gnus-kill-buffer copy-buf)
7059 (gnus-summary-position-point)
7060 (gnus-set-mode-line 'summary)))
7062 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7063 "Move the current article to a different newsgroup.
7064 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7065 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7066 re-spool using this method."
7068 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7070 (defun gnus-summary-crosspost-article (&optional n)
7071 "Crosspost the current article to some other group."
7073 (gnus-summary-move-article n nil nil 'crosspost))
7075 (defcustom gnus-summary-respool-default-method nil
7076 "Default method for respooling an article.
7077 If nil, use to the current newsgroup method."
7078 :type `(choice (gnus-select-method :value (nnml ""))
7080 :group 'gnus-summary-mail)
7082 (defun gnus-summary-respool-article (&optional n method)
7083 "Respool the current article.
7084 The article will be squeezed through the mail spooling process again,
7085 which means that it will be put in some mail newsgroup or other
7086 depending on `nnmail-split-methods'.
7087 If N is a positive number, respool the N next articles.
7088 If N is a negative number, respool the N previous articles.
7089 If N is nil and any articles have been marked with the process mark,
7090 respool those articles instead.
7092 Respooling can be done both from mail groups and \"real\" newsgroups.
7093 In the former case, the articles in question will be moved from the
7094 current group into whatever groups they are destined to. In the
7095 latter case, they will be copied into the relevant groups."
7097 (list current-prefix-arg
7098 (let* ((methods (gnus-methods-using 'respool))
7100 (symbol-name (or gnus-summary-respool-default-method
7101 (car (gnus-find-method-for-group
7102 gnus-newsgroup-name)))))
7104 (gnus-completing-read
7105 methname "What backend do you want to use when respooling?"
7106 methods nil t nil 'gnus-mail-method-history))
7109 ((zerop (length (setq ms (gnus-servers-using-backend
7111 (list (intern method) ""))
7115 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7116 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7119 (error "No method given for respooling"))
7120 (if (assoc (symbol-name
7121 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7122 (gnus-methods-using 'respool))
7123 (gnus-summary-move-article n nil method)
7124 (gnus-summary-copy-article n nil method)))
7126 (defun gnus-summary-import-article (file)
7127 "Import an arbitrary file into a mail newsgroup."
7128 (interactive "fImport file: ")
7129 (let ((group gnus-newsgroup-name)
7130 (now (current-time))
7132 (unless (gnus-check-backend-function 'request-accept-article group)
7133 (error "%s does not support article importing" group))
7134 (or (file-readable-p file)
7135 (not (file-regular-p file))
7136 (error "Can't read %s" file))
7138 (set-buffer (gnus-get-buffer-create " *import file*"))
7139 (buffer-disable-undo (current-buffer))
7141 (insert-file-contents file)
7142 (goto-char (point-min))
7143 (unless (nnheader-article-p)
7144 ;; This doesn't look like an article, so we fudge some headers.
7145 (setq atts (file-attributes file)
7146 lines (count-lines (point-min) (point-max)))
7147 (insert "From: " (read-string "From: ") "\n"
7148 "Subject: " (read-string "Subject: ") "\n"
7149 "Date: " (message-make-date (nth 5 atts))
7151 "Message-ID: " (message-make-message-id) "\n"
7152 "Lines: " (int-to-string lines) "\n"
7153 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7154 (gnus-request-accept-article group nil t)
7155 (kill-buffer (current-buffer)))))
7157 (defun gnus-summary-article-posted-p ()
7158 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7159 This will be the case if the article has both been mailed and posted."
7161 (let ((id (mail-header-references (gnus-summary-article-header)))
7162 (gnus-override-method
7163 (or gnus-refer-article-method gnus-select-method)))
7164 (if (gnus-request-head id "")
7165 (gnus-message 2 "The current message was found on %s"
7166 gnus-override-method)
7167 (gnus-message 2 "The current message couldn't be found on %s"
7168 gnus-override-method)
7171 (defun gnus-summary-expire-articles (&optional now)
7172 "Expire all articles that are marked as expirable in the current group."
7174 (when (gnus-check-backend-function
7175 'request-expire-articles gnus-newsgroup-name)
7176 ;; This backend supports expiry.
7177 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7178 (expirable (if total
7180 ;; We need to update the info for
7181 ;; this group for `gnus-list-of-read-articles'
7182 ;; to give us the right answer.
7183 (gnus-run-hooks 'gnus-exit-group-hook)
7184 (gnus-summary-update-info)
7185 (gnus-list-of-read-articles gnus-newsgroup-name))
7186 (setq gnus-newsgroup-expirable
7187 (sort gnus-newsgroup-expirable '<))))
7188 (expiry-wait (if now 'immediate
7189 (gnus-group-find-parameter
7190 gnus-newsgroup-name 'expiry-wait)))
7193 ;; There are expirable articles in this group, so we run them
7194 ;; through the expiry process.
7195 (gnus-message 6 "Expiring articles...")
7196 ;; The list of articles that weren't expired is returned.
7199 (let ((nnmail-expiry-wait-function nil)
7200 (nnmail-expiry-wait expiry-wait))
7201 (setq es (gnus-request-expire-articles
7202 expirable gnus-newsgroup-name)))
7203 (setq es (gnus-request-expire-articles
7204 expirable gnus-newsgroup-name))))
7206 (setq gnus-newsgroup-expirable es))
7207 ;; We go through the old list of expirable, and mark all
7208 ;; really expired articles as nonexistent.
7209 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7210 (let ((gnus-use-cache nil))
7212 (unless (memq (car expirable) es)
7213 (when (gnus-data-find (car expirable))
7214 (gnus-summary-mark-article
7215 (car expirable) gnus-canceled-mark)))
7216 (setq expirable (cdr expirable)))))
7217 (gnus-message 6 "Expiring articles...done")))))
7219 (defun gnus-summary-expire-articles-now ()
7220 "Expunge all expirable articles in the current group.
7221 This means that *all* articles that are marked as expirable will be
7222 deleted forever, right now."
7224 (or gnus-expert-user
7226 "Are you really, really, really sure you want to delete all these messages? ")
7228 (gnus-summary-expire-articles t))
7230 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7231 (defun gnus-summary-delete-article (&optional n)
7232 "Delete the N next (mail) articles.
7233 This command actually deletes articles. This is not a marking
7234 command. The article will disappear forever from your life, never to
7236 If N is negative, delete backwards.
7237 If N is nil and articles have been marked with the process mark,
7238 delete these instead."
7240 (unless (gnus-check-backend-function 'request-expire-articles
7241 gnus-newsgroup-name)
7242 (error "The current newsgroup does not support article deletion"))
7243 ;; Compute the list of articles to delete.
7244 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7246 (if (and gnus-novice-user
7247 (not (gnus-yes-or-no-p
7248 (format "Do you really want to delete %s forever? "
7249 (if (> (length articles) 1)
7250 (format "these %s articles" (length articles))
7253 ;; Delete the articles.
7254 (setq not-deleted (gnus-request-expire-articles
7255 articles gnus-newsgroup-name 'force))
7257 (gnus-summary-remove-process-mark (car articles))
7258 ;; The backend might not have been able to delete the article
7260 (unless (memq (car articles) not-deleted)
7261 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7262 (setq articles (cdr articles)))
7264 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7265 (gnus-summary-position-point)
7266 (gnus-set-mode-line 'summary)
7269 (defun gnus-summary-edit-article (&optional force)
7270 "Edit the current article.
7271 This will have permanent effect only in mail groups.
7272 If FORCE is non-nil, allow editing of articles even in read-only
7276 (set-buffer gnus-summary-buffer)
7277 (gnus-set-global-variables)
7278 (when (and (not force)
7279 (gnus-group-read-only-p))
7280 (error "The current newsgroup does not support article editing"))
7281 ;; Select article if needed.
7282 (unless (eq (gnus-summary-article-number)
7283 gnus-current-article)
7284 (gnus-summary-select-article t))
7285 (gnus-article-date-original)
7286 (gnus-article-edit-article
7287 `(lambda (no-highlight)
7288 (gnus-summary-edit-article-done
7289 ,(or (mail-header-references gnus-current-headers) "")
7290 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7292 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7294 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7296 "Make edits to the current article permanent."
7298 ;; Replace the article.
7299 (let ((buf (current-buffer)))
7302 (if (and (not read-only)
7303 (not (gnus-request-replace-article
7304 (cdr gnus-article-current) (car gnus-article-current)
7306 (error "Couldn't replace article")
7307 ;; Update the summary buffer.
7309 (equal (message-tokenize-header references " ")
7310 (message-tokenize-header
7311 (or (message-fetch-field "references") "") " ")))
7312 ;; We only have to update this line.
7315 (message-narrow-to-head)
7316 (let ((head (buffer-string))
7319 (insert (format "211 %d Article retrieved.\n"
7320 (cdr gnus-article-current)))
7323 (let ((nntp-server-buffer (current-buffer)))
7324 (setq header (car (gnus-get-newsgroup-headers
7326 (set-buffer gnus-summary-buffer)
7327 gnus-newsgroup-dependencies)
7330 (set-buffer gnus-summary-buffer)
7331 (gnus-data-set-header
7332 (gnus-data-find (cdr gnus-article-current))
7334 (gnus-summary-update-article-line
7335 (cdr gnus-article-current) header))))))
7337 (set-buffer (or buffer gnus-summary-buffer))
7338 (gnus-summary-update-article (cdr gnus-article-current)))
7339 ;; Prettify the article buffer again.
7340 (unless no-highlight
7342 (set-buffer gnus-article-buffer)
7343 (gnus-run-hooks 'gnus-article-display-hook)
7344 (set-buffer gnus-original-article-buffer)
7345 (gnus-request-article
7346 (cdr gnus-article-current)
7347 (car gnus-article-current) (current-buffer))))
7348 ;; Prettify the summary buffer line.
7349 (when (gnus-visual-p 'summary-highlight 'highlight)
7350 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7352 (defun gnus-summary-edit-wash (key)
7353 "Perform editing command KEY in the article buffer."
7357 (message "%s" (concat (this-command-keys) "- "))
7360 (gnus-summary-edit-article)
7361 (execute-kbd-macro (concat (this-command-keys) key))
7362 (gnus-article-edit-done))
7366 (defun gnus-summary-respool-query (&optional silent trace)
7367 "Query where the respool algorithm would put this article."
7369 (let (gnus-mark-article-hook)
7370 (gnus-summary-select-article)
7372 (set-buffer gnus-original-article-buffer)
7374 (message-narrow-to-head)
7375 (let ((groups (nnmail-article-group 'identity trace)))
7378 (message "This message would go to %s"
7379 (mapconcat 'car groups ", "))
7380 (message "This message would go to no groups"))
7383 (defun gnus-summary-respool-trace ()
7384 "Trace where the respool algorithm would put this article.
7385 Display a buffer showing all fancy splitting patterns which matched."
7387 (gnus-summary-respool-query nil t))
7389 ;; Summary marking commands.
7391 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7392 "Mark articles which has the same subject as read, and then select the next.
7393 If UNMARK is positive, remove any kind of mark.
7394 If UNMARK is negative, tick articles."
7397 (setq unmark (prefix-numeric-value unmark)))
7399 (gnus-summary-mark-same-subject
7400 (gnus-summary-article-subject) unmark)))
7401 ;; Select next unread article. If auto-select-same mode, should
7402 ;; select the first unread article.
7403 (gnus-summary-next-article t (and gnus-auto-select-same
7404 (gnus-summary-article-subject)))
7405 (gnus-message 7 "%d article%s marked as %s"
7406 count (if (= count 1) " is" "s are")
7407 (if unmark "unread" "read"))))
7409 (defun gnus-summary-kill-same-subject (&optional unmark)
7410 "Mark articles which has the same subject as read.
7411 If UNMARK is positive, remove any kind of mark.
7412 If UNMARK is negative, tick articles."
7415 (setq unmark (prefix-numeric-value unmark)))
7417 (gnus-summary-mark-same-subject
7418 (gnus-summary-article-subject) unmark)))
7419 ;; If marked as read, go to next unread subject.
7421 ;; Go to next unread subject.
7422 (gnus-summary-next-subject 1 t))
7423 (gnus-message 7 "%d articles are marked as %s"
7424 count (if unmark "unread" "read"))))
7426 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7427 "Mark articles with same SUBJECT as read, and return marked number.
7428 If optional argument UNMARK is positive, remove any kinds of marks.
7429 If optional argument UNMARK is negative, mark articles as unread instead."
7433 ((null unmark) ; Mark as read.
7436 (gnus-summary-mark-article-as-read gnus-killed-mark)
7437 (gnus-summary-show-thread) t)
7438 (gnus-summary-find-subject subject))
7439 (setq count (1+ count))))
7440 ((> unmark 0) ; Tick.
7443 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7444 (gnus-summary-show-thread) t)
7445 (gnus-summary-find-subject subject))
7446 (setq count (1+ count))))
7447 (t ; Mark as unread.
7450 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7451 (gnus-summary-show-thread) t)
7452 (gnus-summary-find-subject subject))
7453 (setq count (1+ count)))))
7454 (gnus-set-mode-line 'summary)
7455 ;; Return the number of marked articles.
7458 (defun gnus-summary-mark-as-processable (n &optional unmark)
7459 "Set the process mark on the next N articles.
7460 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7461 the process mark instead. The difference between N and the actual
7462 number of articles marked is returned."
7464 (let ((backward (< n 0))
7469 (gnus-summary-remove-process-mark
7470 (gnus-summary-article-number))
7471 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7472 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7475 (gnus-message 7 "No more articles"))
7476 (gnus-summary-recenter)
7477 (gnus-summary-position-point)
7480 (defun gnus-summary-unmark-as-processable (n)
7481 "Remove the process mark from the next N articles.
7482 If N is negative, unmark backward instead. The difference between N and
7483 the actual number of articles unmarked is returned."
7485 (gnus-summary-mark-as-processable n t))
7487 (defun gnus-summary-unmark-all-processable ()
7488 "Remove the process mark from all articles."
7491 (while gnus-newsgroup-processable
7492 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7493 (gnus-summary-position-point))
7495 (defun gnus-summary-mark-as-expirable (n)
7496 "Mark N articles forward as expirable.
7497 If N is negative, mark backward instead. The difference between N and
7498 the actual number of articles marked is returned."
7500 (gnus-summary-mark-forward n gnus-expirable-mark))
7502 (defun gnus-summary-mark-article-as-replied (article)
7503 "Mark ARTICLE replied and update the summary line."
7504 (push article gnus-newsgroup-replied)
7505 (let ((buffer-read-only nil))
7506 (when (gnus-summary-goto-subject article)
7507 (gnus-summary-update-secondary-mark article))))
7509 (defun gnus-summary-set-bookmark (article)
7510 "Set a bookmark in current article."
7511 (interactive (list (gnus-summary-article-number)))
7512 (when (or (not (get-buffer gnus-article-buffer))
7513 (not gnus-current-article)
7514 (not gnus-article-current)
7515 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7516 (error "No current article selected"))
7517 ;; Remove old bookmark, if one exists.
7518 (let ((old (assq article gnus-newsgroup-bookmarks)))
7520 (setq gnus-newsgroup-bookmarks
7521 (delq old gnus-newsgroup-bookmarks))))
7522 ;; Set the new bookmark, which is on the form
7523 ;; (article-number . line-number-in-body).
7527 (set-buffer gnus-article-buffer)
7531 (goto-char (point-min))
7532 (search-forward "\n\n" nil t)
7535 gnus-newsgroup-bookmarks)
7536 (gnus-message 6 "A bookmark has been added to the current article."))
7538 (defun gnus-summary-remove-bookmark (article)
7539 "Remove the bookmark from the current article."
7540 (interactive (list (gnus-summary-article-number)))
7541 ;; Remove old bookmark, if one exists.
7542 (let ((old (assq article gnus-newsgroup-bookmarks)))
7545 (setq gnus-newsgroup-bookmarks
7546 (delq old gnus-newsgroup-bookmarks))
7547 (gnus-message 6 "Removed bookmark."))
7548 (gnus-message 6 "No bookmark in current article."))))
7550 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7551 (defun gnus-summary-mark-as-dormant (n)
7552 "Mark N articles forward as dormant.
7553 If N is negative, mark backward instead. The difference between N and
7554 the actual number of articles marked is returned."
7556 (gnus-summary-mark-forward n gnus-dormant-mark))
7558 (defun gnus-summary-set-process-mark (article)
7559 "Set the process mark on ARTICLE and update the summary line."
7560 (setq gnus-newsgroup-processable
7562 (delq article gnus-newsgroup-processable)))
7563 (when (gnus-summary-goto-subject article)
7564 (gnus-summary-show-thread)
7565 (gnus-summary-goto-subject article)
7566 (gnus-summary-update-secondary-mark article)))
7568 (defun gnus-summary-remove-process-mark (article)
7569 "Remove the process mark from ARTICLE and update the summary line."
7570 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7571 (when (gnus-summary-goto-subject article)
7572 (gnus-summary-show-thread)
7573 (gnus-summary-goto-subject article)
7574 (gnus-summary-update-secondary-mark article)))
7576 (defun gnus-summary-set-saved-mark (article)
7577 "Set the process mark on ARTICLE and update the summary line."
7578 (push article gnus-newsgroup-saved)
7579 (when (gnus-summary-goto-subject article)
7580 (gnus-summary-update-secondary-mark article)))
7582 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7583 "Mark N articles as read forwards.
7584 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7585 The difference between N and the actual number of articles marked is
7588 (let ((backward (< n 0))
7589 (gnus-summary-goto-unread
7590 (and gnus-summary-goto-unread
7591 (not (eq gnus-summary-goto-unread 'never))
7592 (not (memq mark (list gnus-unread-mark
7593 gnus-ticked-mark gnus-dormant-mark)))))
7595 (mark (or mark gnus-del-mark)))
7597 (gnus-summary-mark-article nil mark no-expire)
7598 (zerop (gnus-summary-next-subject
7600 (and gnus-summary-goto-unread
7601 (not (eq gnus-summary-goto-unread 'never)))
7605 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7606 (gnus-summary-recenter)
7607 (gnus-summary-position-point)
7608 (gnus-set-mode-line 'summary)
7611 (defun gnus-summary-mark-article-as-read (mark)
7612 "Mark the current article quickly as read with MARK."
7613 (let ((article (gnus-summary-article-number)))
7614 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7615 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7616 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7617 (push (cons article mark) gnus-newsgroup-reads)
7618 ;; Possibly remove from cache, if that is used.
7619 (when gnus-use-cache
7620 (gnus-cache-enter-remove-article article))
7621 ;; Allow the backend to change the mark.
7622 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7623 ;; Check for auto-expiry.
7624 (when (and gnus-newsgroup-auto-expire
7625 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7626 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7627 (= mark gnus-ancient-mark)
7628 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7629 (= mark gnus-duplicate-mark)))
7630 (setq mark gnus-expirable-mark)
7631 ;; Let the backend know about the mark change.
7632 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7633 (push article gnus-newsgroup-expirable))
7634 ;; Set the mark in the buffer.
7635 (gnus-summary-update-mark mark 'unread)
7638 (defun gnus-summary-mark-article-as-unread (mark)
7639 "Mark the current article quickly as unread with MARK."
7640 (let* ((article (gnus-summary-article-number))
7641 (old-mark (gnus-summary-article-mark article)))
7642 ;; Allow the backend to change the mark.
7643 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7644 (if (eq mark old-mark)
7648 (gnus-error 1 "Can't mark negative article numbers")
7650 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7651 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7652 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7653 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7654 (cond ((= mark gnus-ticked-mark)
7655 (push article gnus-newsgroup-marked))
7656 ((= mark gnus-dormant-mark)
7657 (push article gnus-newsgroup-dormant))
7659 (push article gnus-newsgroup-unreads)))
7660 (gnus-pull article gnus-newsgroup-reads)
7662 ;; See whether the article is to be put in the cache.
7664 (vectorp (gnus-summary-article-header article))
7666 (gnus-cache-possibly-enter-article
7667 gnus-newsgroup-name article
7668 (gnus-summary-article-header article)
7669 (= mark gnus-ticked-mark)
7670 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7673 (gnus-summary-update-mark mark 'unread)
7676 (defun gnus-summary-mark-article (&optional article mark no-expire)
7677 "Mark ARTICLE with MARK. MARK can be any character.
7678 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7679 `??' (dormant) and `?E' (expirable).
7680 If MARK is nil, then the default character `?D' is used.
7681 If ARTICLE is nil, then the article on the current line will be
7683 ;; The mark might be a string.
7684 (when (stringp mark)
7685 (setq mark (aref mark 0)))
7686 ;; If no mark is given, then we check auto-expiring.
7687 (and (not no-expire)
7688 gnus-newsgroup-auto-expire
7690 (and (gnus-characterp mark)
7691 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7692 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7693 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7694 (= mark gnus-duplicate-mark))))
7695 (setq mark gnus-expirable-mark))
7696 (let* ((mark (or mark gnus-del-mark))
7697 (article (or article (gnus-summary-article-number)))
7698 (old-mark (gnus-summary-article-mark article)))
7699 ;; Allow the backend to change the mark.
7700 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7701 (if (eq mark old-mark)
7704 (error "No article on current line"))
7705 (if (not (if (or (= mark gnus-unread-mark)
7706 (= mark gnus-ticked-mark)
7707 (= mark gnus-dormant-mark))
7708 (gnus-mark-article-as-unread article mark)
7709 (gnus-mark-article-as-read article mark)))
7711 ;; See whether the article is to be put in the cache.
7713 (not (= mark gnus-canceled-mark))
7714 (vectorp (gnus-summary-article-header article))
7716 (gnus-cache-possibly-enter-article
7717 gnus-newsgroup-name article
7718 (gnus-summary-article-header article)
7719 (= mark gnus-ticked-mark)
7720 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7722 (when (gnus-summary-goto-subject article nil t)
7723 (let ((buffer-read-only nil))
7724 (gnus-summary-show-thread)
7726 (gnus-summary-update-mark mark 'unread)
7729 (defun gnus-summary-update-secondary-mark (article)
7730 "Update the secondary (read, process, cache) mark."
7731 (gnus-summary-update-mark
7732 (cond ((memq article gnus-newsgroup-processable)
7734 ((memq article gnus-newsgroup-cached)
7736 ((memq article gnus-newsgroup-replied)
7738 ((memq article gnus-newsgroup-saved)
7740 (t gnus-unread-mark))
7742 (when (gnus-visual-p 'summary-highlight 'highlight)
7743 (gnus-run-hooks 'gnus-summary-update-hook))
7746 (defun gnus-summary-update-mark (mark type)
7747 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7748 (buffer-read-only nil))
7749 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7750 (when (looking-at "\r")
7753 (<= (+ forward (point)) (point-max)))
7754 ;; Go to the right position on the line.
7755 (goto-char (+ forward (point)))
7756 ;; Replace the old mark with the new mark.
7757 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7758 ;; Optionally update the marks by some user rule.
7759 (when (eq type 'unread)
7761 (gnus-data-find (gnus-summary-article-number)) mark)
7762 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7764 (defun gnus-mark-article-as-read (article &optional mark)
7765 "Enter ARTICLE in the pertinent lists and remove it from others."
7766 ;; Make the article expirable.
7767 (let ((mark (or mark gnus-del-mark)))
7768 (if (= mark gnus-expirable-mark)
7769 (push article gnus-newsgroup-expirable)
7770 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7771 ;; Remove from unread and marked lists.
7772 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7773 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7774 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7775 (push (cons article mark) gnus-newsgroup-reads)
7776 ;; Possibly remove from cache, if that is used.
7777 (when gnus-use-cache
7778 (gnus-cache-enter-remove-article article))
7781 (defun gnus-mark-article-as-unread (article &optional mark)
7782 "Enter ARTICLE in the pertinent lists and remove it from others."
7783 (let ((mark (or mark gnus-ticked-mark)))
7786 (gnus-error 1 "Can't mark negative article numbers")
7788 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7789 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7790 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7791 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7793 ;; Unsuppress duplicates?
7794 (when gnus-suppress-duplicates
7795 (gnus-dup-unsuppress-article article))
7797 (cond ((= mark gnus-ticked-mark)
7798 (push article gnus-newsgroup-marked))
7799 ((= mark gnus-dormant-mark)
7800 (push article gnus-newsgroup-dormant))
7802 (push article gnus-newsgroup-unreads)))
7803 (gnus-pull article gnus-newsgroup-reads)
7806 (defalias 'gnus-summary-mark-as-unread-forward
7807 'gnus-summary-tick-article-forward)
7808 (make-obsolete 'gnus-summary-mark-as-unread-forward
7809 'gnus-summary-tick-article-forward)
7810 (defun gnus-summary-tick-article-forward (n)
7811 "Tick N articles forwards.
7812 If N is negative, tick backwards instead.
7813 The difference between N and the number of articles ticked is returned."
7815 (gnus-summary-mark-forward n gnus-ticked-mark))
7817 (defalias 'gnus-summary-mark-as-unread-backward
7818 'gnus-summary-tick-article-backward)
7819 (make-obsolete 'gnus-summary-mark-as-unread-backward
7820 'gnus-summary-tick-article-backward)
7821 (defun gnus-summary-tick-article-backward (n)
7822 "Tick N articles backwards.
7823 The difference between N and the number of articles ticked is returned."
7825 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7827 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7828 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7829 (defun gnus-summary-tick-article (&optional article clear-mark)
7830 "Mark current article as unread.
7831 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7832 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7834 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7837 (defun gnus-summary-mark-as-read-forward (n)
7838 "Mark N articles as read forwards.
7839 If N is negative, mark backwards instead.
7840 The difference between N and the actual number of articles marked is
7843 (gnus-summary-mark-forward n gnus-del-mark t))
7845 (defun gnus-summary-mark-as-read-backward (n)
7846 "Mark the N articles as read backwards.
7847 The difference between N and the actual number of articles marked is
7850 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7852 (defun gnus-summary-mark-as-read (&optional article mark)
7853 "Mark current article as read.
7854 ARTICLE specifies the article to be marked as read.
7855 MARK specifies a string to be inserted at the beginning of the line."
7856 (gnus-summary-mark-article article mark))
7858 (defun gnus-summary-clear-mark-forward (n)
7859 "Clear marks from N articles forward.
7860 If N is negative, clear backward instead.
7861 The difference between N and the number of marks cleared is returned."
7863 (gnus-summary-mark-forward n gnus-unread-mark))
7865 (defun gnus-summary-clear-mark-backward (n)
7866 "Clear marks from N articles backward.
7867 The difference between N and the number of marks cleared is returned."
7869 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7871 (defun gnus-summary-mark-unread-as-read ()
7872 "Intended to be used by `gnus-summary-mark-article-hook'."
7873 (when (memq gnus-current-article gnus-newsgroup-unreads)
7874 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7876 (defun gnus-summary-mark-read-and-unread-as-read ()
7877 "Intended to be used by `gnus-summary-mark-article-hook'."
7878 (let ((mark (gnus-summary-article-mark)))
7879 (when (or (gnus-unread-mark-p mark)
7880 (gnus-read-mark-p mark))
7881 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7883 (defun gnus-summary-mark-region-as-read (point mark all)
7884 "Mark all unread articles between point and mark as read.
7885 If given a prefix, mark all articles between point and mark as read,
7886 even ticked and dormant ones."
7887 (interactive "r\nP")
7896 (memq (setq article (gnus-summary-article-number))
7897 gnus-newsgroup-unreads))
7898 (gnus-summary-mark-article article gnus-del-mark))
7900 (gnus-summary-find-next))))))
7902 (defun gnus-summary-mark-below (score mark)
7903 "Mark articles with score less than SCORE with MARK."
7904 (interactive "P\ncMark: ")
7905 (setq score (if score
7906 (prefix-numeric-value score)
7907 (or gnus-summary-default-score 0)))
7909 (set-buffer gnus-summary-buffer)
7910 (goto-char (point-min))
7913 (and (< (gnus-summary-article-score) score)
7914 (gnus-summary-mark-article nil mark))
7915 (gnus-summary-find-next)))))
7917 (defun gnus-summary-kill-below (&optional score)
7918 "Mark articles with score below SCORE as read."
7920 (gnus-summary-mark-below score gnus-killed-mark))
7922 (defun gnus-summary-clear-above (&optional score)
7923 "Clear all marks from articles with score above SCORE."
7925 (gnus-summary-mark-above score gnus-unread-mark))
7927 (defun gnus-summary-tick-above (&optional score)
7928 "Tick all articles with score above SCORE."
7930 (gnus-summary-mark-above score gnus-ticked-mark))
7932 (defun gnus-summary-mark-above (score mark)
7933 "Mark articles with score over SCORE with MARK."
7934 (interactive "P\ncMark: ")
7935 (setq score (if score
7936 (prefix-numeric-value score)
7937 (or gnus-summary-default-score 0)))
7939 (set-buffer gnus-summary-buffer)
7940 (goto-char (point-min))
7942 (when (> (gnus-summary-article-score) score)
7943 (gnus-summary-mark-article nil mark))
7945 (gnus-summary-find-next)))))
7947 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7948 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7949 (defun gnus-summary-limit-include-expunged (&optional no-error)
7950 "Display all the hidden articles that were expunged for low scores."
7952 (let ((buffer-read-only nil))
7953 (let ((scored gnus-newsgroup-scored)
7956 (unless (gnus-summary-goto-subject (caar scored))
7957 (and (setq h (gnus-summary-article-header (caar scored)))
7958 (< (cdar scored) gnus-summary-expunge-below)
7960 (setq scored (cdr scored)))
7962 (when (not no-error)
7963 (error "No expunged articles hidden"))
7964 (goto-char (point-min))
7965 (gnus-summary-prepare-unthreaded (nreverse headers))
7966 (goto-char (point-min))
7967 (gnus-summary-position-point)
7970 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7971 "Mark all unread articles in this newsgroup as read.
7972 If prefix argument ALL is non-nil, ticked and dormant articles will
7973 also be marked as read.
7974 If QUIETLY is non-nil, no questions will be asked.
7975 If TO-HERE is non-nil, it should be a point in the buffer. All
7976 articles before this point will be marked as read.
7977 Note that this function will only catch up the unread article
7978 in the current summary buffer limitation.
7979 The number of articles marked as read is returned."
7984 (not gnus-interactive-catchup) ;Without confirmation?
7988 "Mark absolutely all articles as read? "
7989 "Mark all unread articles as read? ")))
7991 (not gnus-newsgroup-adaptive)
7992 (not gnus-newsgroup-auto-expire)
7993 (not gnus-suppress-duplicates)
7994 (or (not gnus-use-cache)
7995 (eq gnus-use-cache 'passive)))
7998 (setq gnus-newsgroup-marked nil
7999 gnus-newsgroup-dormant nil))
8000 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8001 ;; We actually mark all articles as canceled, which we
8002 ;; have to do when using auto-expiry or adaptive scoring.
8003 (gnus-summary-show-all-threads)
8004 (when (gnus-summary-first-subject (not all) t)
8006 (if to-here (< (point) to-here) t)
8007 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8008 (gnus-summary-find-next (not all) nil nil t))))
8009 (gnus-set-mode-line 'summary))
8011 (gnus-summary-position-point)))
8013 (defun gnus-summary-catchup-to-here (&optional all)
8014 "Mark all unticked articles before the current one as read.
8015 If ALL is non-nil, also mark ticked and dormant articles as read."
8018 (gnus-save-hidden-threads
8019 (let ((beg (point)))
8020 ;; We check that there are unread articles.
8021 (when (or all (gnus-summary-find-prev))
8022 (gnus-summary-catchup all t beg)))))
8023 (gnus-summary-position-point))
8025 (defun gnus-summary-catchup-all (&optional quietly)
8026 "Mark all articles in this newsgroup as read."
8028 (gnus-summary-catchup t quietly))
8030 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8031 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8032 If prefix argument ALL is non-nil, all articles are marked as read."
8034 (when (gnus-summary-catchup all quietly nil 'fast)
8035 ;; Select next newsgroup or exit.
8036 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8037 (eq gnus-auto-select-next 'quietly))
8038 (gnus-summary-next-group nil)
8039 (gnus-summary-exit))))
8041 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8042 "Mark all articles in this newsgroup as read, and then exit."
8044 (gnus-summary-catchup-and-exit t quietly))
8046 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8047 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8048 "Mark all articles in this group as read and select the next group.
8049 If given a prefix, mark all articles, unread as well as ticked, as
8053 (gnus-summary-catchup all))
8054 (gnus-summary-next-article t nil nil t))
8056 ;; Thread-based commands.
8058 (defun gnus-summary-articles-in-thread (&optional article)
8059 "Return a list of all articles in the current thread.
8060 If ARTICLE is non-nil, return all articles in the thread that starts
8062 (let* ((article (or article (gnus-summary-article-number)))
8063 (data (gnus-data-find-list article))
8064 (top-level (gnus-data-level (car data)))
8066 (cond ((null gnus-thread-operation-ignore-subject)
8067 (gnus-simplify-subject-re
8068 (mail-header-subject (gnus-data-header (car data)))))
8069 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8070 (gnus-simplify-subject-fuzzy
8071 (mail-header-subject (gnus-data-header (car data)))))
8073 (end-point (save-excursion
8074 (if (gnus-summary-go-to-next-thread)
8075 (point) (point-max))))
8078 (< (gnus-data-pos (car data)) end-point))
8079 (when (or (not top-subject)
8080 (string= top-subject
8081 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8082 (gnus-simplify-subject-fuzzy
8083 (mail-header-subject
8084 (gnus-data-header (car data))))
8085 (gnus-simplify-subject-re
8086 (mail-header-subject
8087 (gnus-data-header (car data)))))))
8088 (push (gnus-data-number (car data)) articles))
8089 (unless (and (setq data (cdr data))
8090 (> (gnus-data-level (car data)) top-level))
8092 ;; Return the list of articles.
8093 (nreverse articles)))
8095 (defun gnus-summary-rethread-current ()
8096 "Rethread the thread the current article is part of."
8098 (let* ((gnus-show-threads t)
8099 (article (gnus-summary-article-number))
8100 (id (mail-header-id (gnus-summary-article-header)))
8101 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8103 (error "No article on the current line"))
8104 (gnus-rebuild-thread id)
8105 (gnus-summary-goto-subject article)))
8107 (defun gnus-summary-reparent-thread ()
8108 "Make the current article child of the marked (or previous) article.
8110 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8111 is non-nil or the Subject: of both articles are the same."
8113 (unless (not (gnus-group-read-only-p))
8114 (error "The current newsgroup does not support article editing"))
8115 (unless (<= (length gnus-newsgroup-processable) 1)
8116 (error "No more than one article may be marked"))
8117 (save-window-excursion
8118 (let ((gnus-article-buffer " *reparent*")
8119 (current-article (gnus-summary-article-number))
8120 ;; First grab the marked article, otherwise one line up.
8121 (parent-article (if (not (null gnus-newsgroup-processable))
8122 (car gnus-newsgroup-processable)
8124 (if (eq (forward-line -1) 0)
8125 (gnus-summary-article-number)
8126 (error "Beginning of summary buffer"))))))
8127 (unless (not (eq current-article parent-article))
8128 (error "An article may not be self-referential"))
8129 (let ((message-id (mail-header-id
8130 (gnus-summary-article-header parent-article))))
8131 (unless (and message-id (not (equal message-id "")))
8132 (error "No message-id in desired parent"))
8133 ;; We don't want the article to be marked as read.
8134 (let (gnus-mark-article-hook)
8135 (gnus-summary-select-article t t nil current-article))
8136 (set-buffer gnus-original-article-buffer)
8137 (let ((buf (format "%s" (buffer-string))))
8140 (goto-char (point-min))
8141 (if (re-search-forward "^References: " nil t)
8143 (re-search-forward "^[^ \t]" nil t)
8146 (insert " " message-id))
8147 (insert "References: " message-id "\n"))
8148 (unless (gnus-request-replace-article
8149 current-article (car gnus-article-current)
8151 (error "Couldn't replace article"))))
8152 (set-buffer gnus-summary-buffer)
8153 (gnus-summary-unmark-all-processable)
8154 (gnus-summary-update-article current-article)
8155 (gnus-summary-rethread-current)
8156 (gnus-message 3 "Article %d is now the child of article %d"
8157 current-article parent-article)))))
8159 (defun gnus-summary-toggle-threads (&optional arg)
8160 "Toggle showing conversation threads.
8161 If ARG is positive number, turn showing conversation threads on."
8163 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8164 (setq gnus-show-threads
8165 (if (null arg) (not gnus-show-threads)
8166 (> (prefix-numeric-value arg) 0)))
8167 (gnus-summary-prepare)
8168 (gnus-summary-goto-subject current)
8169 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8170 (gnus-summary-position-point)))
8172 (defun gnus-summary-show-all-threads ()
8176 (let ((buffer-read-only nil))
8177 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8178 (gnus-summary-position-point))
8180 (defun gnus-summary-show-thread ()
8181 "Show thread subtrees.
8182 Returns nil if no thread was there to be shown."
8184 (let ((buffer-read-only nil)
8186 ;; first goto end then to beg, to have point at beg after let
8187 (end (progn (end-of-line) (point)))
8188 (beg (progn (beginning-of-line) (point))))
8190 ;; Any hidden lines here?
8191 (search-forward "\r" end t)
8192 (subst-char-in-region beg end ?\^M ?\n t)
8194 (gnus-summary-position-point))))
8196 (defun gnus-summary-hide-all-threads ()
8197 "Hide all thread subtrees."
8200 (goto-char (point-min))
8201 (gnus-summary-hide-thread)
8202 (while (zerop (gnus-summary-next-thread 1 t))
8203 (gnus-summary-hide-thread)))
8204 (gnus-summary-position-point))
8206 (defun gnus-summary-hide-thread ()
8207 "Hide thread subtrees.
8208 Returns nil if no threads were there to be hidden."
8210 (let ((buffer-read-only nil)
8212 (article (gnus-summary-article-number)))
8214 ;; Go forward until either the buffer ends or the subthread
8216 (when (and (not (eobp))
8217 (or (zerop (gnus-summary-next-thread 1 t))
8218 (goto-char (point-max))))
8220 (if (and (> (point) start)
8221 (search-backward "\n" start t))
8223 (subst-char-in-region start (point) ?\n ?\^M)
8224 (gnus-summary-goto-subject article))
8227 ;;(gnus-summary-position-point)
8230 (defun gnus-summary-go-to-next-thread (&optional previous)
8231 "Go to the same level (or less) next thread.
8232 If PREVIOUS is non-nil, go to previous thread instead.
8233 Return the article number moved to, or nil if moving was impossible."
8234 (let ((level (gnus-summary-thread-level))
8235 (way (if previous -1 1))
8238 (while (and (not (eobp))
8239 (< level (gnus-summary-thread-level)))
8247 (gnus-summary-article-number)
8250 (defun gnus-summary-next-thread (n &optional silent)
8251 "Go to the same level next N'th thread.
8252 If N is negative, search backward instead.
8253 Returns the difference between N and the number of skips actually
8256 If SILENT, don't output messages."
8258 (let ((backward (< n 0))
8261 (gnus-summary-go-to-next-thread backward))
8264 (gnus-summary-position-point))
8265 (when (and (not silent) (/= 0 n))
8266 (gnus-message 7 "No more threads"))
8269 (defun gnus-summary-prev-thread (n)
8270 "Go to the same level previous N'th thread.
8271 Returns the difference between N and the number of skips actually
8274 (gnus-summary-next-thread (- n)))
8276 (defun gnus-summary-go-down-thread ()
8277 "Go down one level in the current thread."
8278 (let ((children (gnus-summary-article-children)))
8280 (gnus-summary-goto-subject (car children)))))
8282 (defun gnus-summary-go-up-thread ()
8283 "Go up one level in the current thread."
8284 (let ((parent (gnus-summary-article-parent)))
8286 (gnus-summary-goto-subject parent))))
8288 (defun gnus-summary-down-thread (n)
8289 "Go down thread N steps.
8290 If N is negative, go up instead.
8291 Returns the difference between N and how many steps down that were
8297 (if up (gnus-summary-go-up-thread)
8298 (gnus-summary-go-down-thread)))
8300 (gnus-summary-position-point)
8302 (gnus-message 7 "Can't go further"))
8305 (defun gnus-summary-up-thread (n)
8306 "Go up thread N steps.
8307 If N is negative, go up instead.
8308 Returns the difference between N and how many steps down that were
8311 (gnus-summary-down-thread (- n)))
8313 (defun gnus-summary-top-thread ()
8314 "Go to the top of the thread."
8316 (while (gnus-summary-go-up-thread))
8317 (gnus-summary-article-number))
8319 (defun gnus-summary-kill-thread (&optional unmark)
8320 "Mark articles under current thread as read.
8321 If the prefix argument is positive, remove any kinds of marks.
8322 If the prefix argument is negative, tick articles instead."
8325 (setq unmark (prefix-numeric-value unmark)))
8326 (let ((articles (gnus-summary-articles-in-thread)))
8328 ;; Expand the thread.
8329 (gnus-summary-show-thread)
8330 ;; Mark all the articles.
8332 (gnus-summary-goto-subject (car articles))
8333 (cond ((null unmark)
8334 (gnus-summary-mark-article-as-read gnus-killed-mark))
8336 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8338 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8339 (setq articles (cdr articles))))
8340 ;; Hide killed subtrees.
8342 gnus-thread-hide-killed
8343 (gnus-summary-hide-thread))
8344 ;; If marked as read, go to next unread subject.
8346 ;; Go to next unread subject.
8347 (gnus-summary-next-subject 1 t)))
8348 (gnus-set-mode-line 'summary))
8350 ;; Summary sorting commands
8352 (defun gnus-summary-sort-by-number (&optional reverse)
8353 "Sort the summary buffer by article number.
8354 Argument REVERSE means reverse order."
8356 (gnus-summary-sort 'number reverse))
8358 (defun gnus-summary-sort-by-author (&optional reverse)
8359 "Sort the summary buffer by author name alphabetically.
8360 If case-fold-search is non-nil, case of letters is ignored.
8361 Argument REVERSE means reverse order."
8363 (gnus-summary-sort 'author reverse))
8365 (defun gnus-summary-sort-by-subject (&optional reverse)
8366 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8367 If case-fold-search is non-nil, case of letters is ignored.
8368 Argument REVERSE means reverse order."
8370 (gnus-summary-sort 'subject reverse))
8372 (defun gnus-summary-sort-by-date (&optional reverse)
8373 "Sort the summary buffer by date.
8374 Argument REVERSE means reverse order."
8376 (gnus-summary-sort 'date reverse))
8378 (defun gnus-summary-sort-by-score (&optional reverse)
8379 "Sort the summary buffer by score.
8380 Argument REVERSE means reverse order."
8382 (gnus-summary-sort 'score reverse))
8384 (defun gnus-summary-sort-by-lines (&optional reverse)
8385 "Sort the summary buffer by article length.
8386 Argument REVERSE means reverse order."
8388 (gnus-summary-sort 'lines reverse))
8390 (defun gnus-summary-sort (predicate reverse)
8391 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8392 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8393 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8394 (gnus-thread-sort-functions
8400 (gnus-article-sort-functions
8405 (,article t2 t1)))))
8407 (gnus-summary-prepare-hook nil))
8408 ;; We do the sorting by regenerating the threads.
8409 (gnus-summary-prepare)
8410 ;; Hide subthreads if needed.
8411 (when (and gnus-show-threads gnus-thread-hide-subtree)
8412 (gnus-summary-hide-all-threads))))
8414 ;; Summary saving commands.
8416 (defun gnus-summary-save-article (&optional n not-saved)
8417 "Save the current article using the default saver function.
8418 If N is a positive number, save the N next articles.
8419 If N is a negative number, save the N previous articles.
8420 If N is nil and any articles have been marked with the process mark,
8421 save those articles instead.
8422 The variable `gnus-default-article-saver' specifies the saver function."
8424 (let* ((articles (gnus-summary-work-articles n))
8425 (save-buffer (save-excursion
8426 (nnheader-set-temp-buffer " *Gnus Save*")))
8427 (num (length articles))
8428 header article file)
8430 (setq header (gnus-summary-article-header
8431 (setq article (pop articles))))
8432 (if (not (vectorp header))
8433 ;; This is a pseudo-article.
8434 (if (assq 'name header)
8435 (gnus-copy-file (cdr (assq 'name header)))
8436 (gnus-message 1 "Article %d is unsaveable" article))
8437 ;; This is a real article.
8438 (save-window-excursion
8439 (gnus-summary-select-article t nil nil article))
8441 (set-buffer save-buffer)
8443 (insert-buffer-substring gnus-original-article-buffer))
8444 (setq file (gnus-article-save save-buffer file num))
8445 (gnus-summary-remove-process-mark article)
8447 (gnus-summary-set-saved-mark article))))
8448 (gnus-kill-buffer save-buffer)
8449 (gnus-summary-position-point)
8450 (gnus-set-mode-line 'summary)
8453 (defun gnus-summary-pipe-output (&optional arg)
8454 "Pipe the current article to a subprocess.
8455 If N is a positive number, pipe the N next articles.
8456 If N is a negative number, pipe the N previous articles.
8457 If N is nil and any articles have been marked with the process mark,
8458 pipe those articles instead."
8460 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8461 (gnus-summary-save-article arg t))
8462 (gnus-configure-windows 'pipe))
8464 (defun gnus-summary-save-article-mail (&optional arg)
8465 "Append the current article to an mail 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 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8472 (gnus-summary-save-article arg)))
8474 (defun gnus-summary-save-article-rmail (&optional arg)
8475 "Append the current article to an rmail file.
8476 If N is a positive number, save the N next articles.
8477 If N is a negative number, save the N previous articles.
8478 If N is nil and any articles have been marked with the process mark,
8479 save those articles instead."
8481 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8482 (gnus-summary-save-article arg)))
8484 (defun gnus-summary-save-article-file (&optional arg)
8485 "Append the current article to a file.
8486 If N is a positive number, save the N next articles.
8487 If N is a negative number, save the N previous articles.
8488 If N is nil and any articles have been marked with the process mark,
8489 save those articles instead."
8491 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8492 (gnus-summary-save-article arg)))
8494 (defun gnus-summary-write-article-file (&optional arg)
8495 "Write the current article to a file, deleting the previous file.
8496 If N is a positive number, save the N next articles.
8497 If N is a negative number, save the N previous articles.
8498 If N is nil and any articles have been marked with the process mark,
8499 save those articles instead."
8501 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8502 (gnus-summary-save-article arg)))
8504 (defun gnus-summary-save-article-body-file (&optional arg)
8505 "Append the current article body to a file.
8506 If N is a positive number, save the N next articles.
8507 If N is a negative number, save the N previous articles.
8508 If N is nil and any articles have been marked with the process mark,
8509 save those articles instead."
8511 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8512 (gnus-summary-save-article arg)))
8514 (defun gnus-summary-pipe-message (program)
8515 "Pipe the current article through PROGRAM."
8516 (interactive "sProgram: ")
8517 (gnus-summary-select-article)
8518 (let ((mail-header-separator ""))
8519 (gnus-eval-in-buffer-window gnus-article-buffer
8522 (let ((start (window-start))
8524 (message-pipe-buffer-body program)
8525 (set-window-start (get-buffer-window (current-buffer)) start))))))
8527 (defun gnus-get-split-value (methods)
8528 "Return a value based on the split METHODS."
8529 (let (split-name method result match)
8532 (set-buffer gnus-original-article-buffer)
8534 (nnheader-narrow-to-headers)
8536 (goto-char (point-min))
8537 (setq method (pop methods))
8538 (setq match (car method))
8541 ;; Regular expression.
8543 (re-search-forward match nil t)))
8544 ((gnus-functionp match)
8548 (setq result (funcall match gnus-newsgroup-name))))
8553 (setq result (eval match)))))
8554 (setq split-name (append (cdr method) split-name))
8555 (cond ((stringp result)
8556 (push (expand-file-name
8557 result gnus-article-save-directory)
8560 (setq split-name (append result split-name)))))))))
8563 (defun gnus-valid-move-group-p (group)
8568 (car (gnus-find-method-for-group
8569 (symbol-name group))))
8570 gnus-valid-select-methods))))
8572 (defun gnus-read-move-group-name (prompt default articles prefix)
8573 "Read a group name."
8574 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8575 (minibuffer-confirm-incomplete nil) ; XEmacs
8579 (if (> (length articles) 1)
8580 (format "these %d articles" (length articles))
8585 (gnus-completing-read default prom
8587 'gnus-valid-move-group-p
8589 'gnus-group-history))
8590 ((= 1 (length split-name))
8591 (gnus-completing-read (car split-name) prom
8593 'gnus-valid-move-group-p
8595 'gnus-group-history))
8597 (gnus-completing-read nil prom
8598 (mapcar (lambda (el) (list el))
8599 (nreverse split-name))
8601 'gnus-group-history)))))
8603 (if (or (string= to-newsgroup "")
8604 (string= to-newsgroup prefix))
8605 (setq to-newsgroup default))
8606 (unless to-newsgroup
8607 (error "No group name entered"))
8608 (or (gnus-active to-newsgroup)
8609 (gnus-activate-group to-newsgroup)
8610 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8612 (or (and (gnus-request-create-group
8613 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8614 (gnus-activate-group to-newsgroup nil nil
8615 (gnus-group-name-to-method
8617 (error "Couldn't create group %s" to-newsgroup)))
8618 (error "No such group: %s" to-newsgroup)))
8621 ;; Summary extract commands
8623 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8624 (let ((buffer-read-only nil)
8625 (article (gnus-summary-article-number))
8627 (unless (gnus-summary-goto-subject article)
8628 (error "No such article: %d" article))
8629 (gnus-summary-position-point)
8630 ;; If all commands are to be bunched up on one line, we collect
8632 (unless gnus-view-pseudos-separately
8633 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8636 (setq action (cdr (assq 'action (car ps))))
8637 (setq files (list (cdr (assq 'name (car ps)))))
8638 (while (and ps (cdr ps)
8639 (string= (or action "1")
8640 (or (cdr (assq 'action (cadr ps))) "2")))
8641 (push (cdr (assq 'name (cadr ps))) files)
8642 (setcdr ps (cddr ps)))
8644 (when (not (string-match "%s" action))
8647 (when (assq 'execute (car ps))
8648 (setcdr (assq 'execute (car ps))
8649 (funcall (if (string-match "%s" action)
8656 (gnus-quote-arg-for-sh-or-csh f)))
8658 (setq ps (cdr ps)))))
8659 (if (and gnus-view-pseudos (not not-view))
8661 (when (assq 'execute (car pslist))
8662 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8663 (eq gnus-view-pseudos 'not-confirm)))
8664 (setq pslist (cdr pslist)))
8667 (setq after-article (or (cdr (assq 'article (car pslist)))
8668 (gnus-summary-article-number)))
8669 (gnus-summary-goto-subject after-article)
8672 (insert " " (file-name-nondirectory
8673 (cdr (assq 'name (car pslist))))
8674 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8676 (forward-line -1) ; back to `b'
8677 (gnus-add-text-properties
8678 b (1- e) (list 'gnus-number gnus-reffed-article-number
8679 gnus-mouse-face-prop gnus-mouse-face))
8681 after-article gnus-reffed-article-number
8682 gnus-unread-mark b (car pslist) 0 (- e b))
8683 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8684 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8685 (setq pslist (cdr pslist)))))))
8687 (defun gnus-pseudos< (p1 p2)
8688 (let ((c1 (cdr (assq 'action p1)))
8689 (c2 (cdr (assq 'action p2))))
8690 (and c1 c2 (string< c1 c2))))
8692 (defun gnus-request-pseudo-article (props)
8693 (cond ((assq 'execute props)
8694 (gnus-execute-command (cdr (assq 'execute props)))))
8695 (let ((gnus-current-article (gnus-summary-article-number)))
8696 (gnus-run-hooks 'gnus-mark-article-hook)))
8698 (defun gnus-execute-command (command &optional automatic)
8700 (gnus-article-setup-buffer)
8701 (set-buffer gnus-article-buffer)
8702 (setq buffer-read-only nil)
8703 (let ((command (if automatic command
8704 (read-string "Command: " (cons command 0)))))
8706 (insert "$ " command "\n\n")
8707 (if gnus-view-pseudo-asynchronously
8708 (start-process "gnus-execute" (current-buffer) shell-file-name
8709 shell-command-switch command)
8710 (call-process shell-file-name nil t nil
8711 shell-command-switch command)))))
8713 ;; Summary kill commands.
8715 (defun gnus-summary-edit-global-kill (article)
8716 "Edit the \"global\" kill file."
8717 (interactive (list (gnus-summary-article-number)))
8718 (gnus-group-edit-global-kill article))
8720 (defun gnus-summary-edit-local-kill ()
8721 "Edit a local kill file applied to the current newsgroup."
8723 (setq gnus-current-headers (gnus-summary-article-header))
8724 (gnus-group-edit-local-kill
8725 (gnus-summary-article-number) gnus-newsgroup-name))
8729 (defun gnus-read-header (id &optional header)
8730 "Read the headers of article ID and enter them into the Gnus system."
8731 (let ((group gnus-newsgroup-name)
8732 (gnus-override-method
8733 (and (gnus-news-group-p gnus-newsgroup-name)
8734 gnus-refer-article-method))
8736 ;; First we check to see whether the header in question is already
8739 ;; This is a Message-ID.
8740 (setq header (or header (gnus-id-to-header id)))
8741 ;; This is an article number.
8742 (setq header (or header (gnus-summary-article-header id))))
8744 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8745 ;; We have found the header.
8747 ;; If this is a sparse article, we have to nix out its
8748 ;; previous entry in the thread hashtb.
8750 (gnus-summary-article-sparse-p (mail-header-number header)))
8751 (let* ((parent (gnus-parent-id (mail-header-references header)))
8752 (thread (and parent (gnus-id-to-thread parent))))
8754 (delq (assq header thread) thread))))
8755 ;; We have to really fetch the header to this article.
8757 (set-buffer nntp-server-buffer)
8758 (when (setq where (gnus-request-head id group))
8759 (nnheader-fold-continuation-lines)
8760 (goto-char (point-max))
8762 (goto-char (point-min))
8766 ((cdr where) (cdr where))
8767 (header (mail-header-number header))
8768 (t gnus-reffed-article-number))
8770 (insert " Article retrieved.\n"))
8772 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8773 () ; Malformed head.
8774 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8775 (when (and (stringp id)
8776 (not (string= (gnus-group-real-name group)
8778 ;; If we fetched by Message-ID and the article came
8779 ;; from a different group, we fudge some bogus article
8780 ;; numbers for this article.
8781 (mail-header-set-number header gnus-reffed-article-number))
8783 (set-buffer gnus-summary-buffer)
8784 (decf gnus-reffed-article-number)
8785 (gnus-remove-header (mail-header-number header))
8786 (push header gnus-newsgroup-headers)
8787 (setq gnus-current-headers header)
8788 (push (mail-header-number header) gnus-newsgroup-limit)))
8791 (defun gnus-remove-header (number)
8792 "Remove header NUMBER from `gnus-newsgroup-headers'."
8793 (if (and gnus-newsgroup-headers
8794 (= number (mail-header-number (car gnus-newsgroup-headers))))
8795 (pop gnus-newsgroup-headers)
8796 (let ((headers gnus-newsgroup-headers))
8797 (while (and (cdr headers)
8798 (not (= number (mail-header-number (cadr headers)))))
8801 (setcdr headers (cddr headers))))))
8804 ;;; summary highlights
8807 (defun gnus-highlight-selected-summary ()
8808 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8809 ;; Highlight selected article in summary buffer
8810 (when gnus-summary-selected-face
8812 (let* ((beg (progn (beginning-of-line) (point)))
8813 (end (progn (end-of-line) (point)))
8814 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8815 (from (if (get-text-property beg gnus-mouse-face-prop)
8817 (or (next-single-property-change
8818 beg gnus-mouse-face-prop nil end)
8823 (or (next-single-property-change
8824 from gnus-mouse-face-prop nil end)
8826 ;; If no mouse-face prop on line we will have to = from = end,
8827 ;; so we highlight the entire line instead.
8828 (when (= (+ to 2) from)
8831 (if gnus-newsgroup-selected-overlay
8832 ;; Move old overlay.
8834 gnus-newsgroup-selected-overlay from to (current-buffer))
8835 ;; Create new overlay.
8837 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8838 'face gnus-summary-selected-face))))))
8840 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8841 (defun gnus-summary-highlight-line ()
8842 "Highlight current line according to `gnus-summary-highlight'."
8843 (let* ((list gnus-summary-highlight)
8845 (end (progn (end-of-line) (point)))
8846 ;; now find out where the line starts and leave point there.
8847 (beg (progn (beginning-of-line) (point)))
8848 (article (gnus-summary-article-number))
8849 (score (or (cdr (assq (or article gnus-current-article)
8850 gnus-newsgroup-scored))
8851 gnus-summary-default-score 0))
8852 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8853 (inhibit-read-only t))
8854 ;; Eval the cars of the lists until we find a match.
8855 (let ((default gnus-summary-default-score))
8857 (not (eval (caar list))))
8858 (setq list (cdr list))))
8859 (let ((face (cdar list)))
8860 (unless (eq face (get-text-property beg 'face))
8861 (gnus-put-text-property-excluding-characters-with-faces
8863 (setq face (if (boundp face) (symbol-value face) face)))
8864 (when gnus-summary-highlight-line-function
8865 (funcall gnus-summary-highlight-line-function article face))))
8868 (defun gnus-update-read-articles (group unread &optional compute)
8869 "Update the list of read articles in GROUP."
8870 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8871 (entry (gnus-gethash group gnus-newsrc-hashtb))
8872 (info (nth 2 entry))
8874 (unread (sort (copy-sequence unread) '<))
8876 (if (or (not info) (not active))
8877 ;; There is no info on this group if it was, in fact,
8878 ;; killed. Gnus stores no information on killed groups, so
8879 ;; there's nothing to be done.
8880 ;; One could store the information somewhere temporarily,
8881 ;; perhaps... Hmmm...
8883 ;; Remove any negative articles numbers.
8884 (while (and unread (< (car unread) 0))
8885 (setq unread (cdr unread)))
8886 ;; Remove any expired article numbers
8887 (while (and unread (< (car unread) (car active)))
8888 (setq unread (cdr unread)))
8889 ;; Compute the ranges of read articles by looking at the list of
8892 (when (/= (car unread) prev)
8893 (push (if (= prev (1- (car unread))) prev
8894 (cons prev (1- (car unread))))
8896 (setq prev (1+ (car unread)))
8897 (setq unread (cdr unread)))
8898 (when (<= prev (cdr active))
8899 (push (cons prev (cdr active)) read))
8901 (if (> (length read) 1) (nreverse read) read)
8903 (set-buffer gnus-group-buffer)
8906 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8907 (gnus-info-set-read ',info ',(gnus-info-read info))
8908 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8909 (gnus-group-update-group ,group t))))
8910 ;; Enter this list into the group info.
8912 info (if (> (length read) 1) (nreverse read) read))
8913 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8914 (gnus-get-unread-articles-in-group info (gnus-active group))
8917 (defun gnus-offer-save-summaries ()
8918 "Offer to save all active summary buffers."
8920 (let ((buflist (buffer-list))
8922 ;; Go through all buffers and find all summaries.
8924 (and (setq bufname (buffer-name (car buflist)))
8925 (string-match "Summary" bufname)
8927 (set-buffer bufname)
8928 ;; We check that this is, indeed, a summary buffer.
8929 (and (eq major-mode 'gnus-summary-mode)
8930 ;; Also make sure this isn't bogus.
8931 gnus-newsgroup-prepared
8932 ;; Also make sure that this isn't a dead summary buffer.
8933 (not gnus-dead-summary-mode)))
8934 (push bufname buffers))
8935 (setq buflist (cdr buflist)))
8936 ;; Go through all these summary buffers and offer to save them.
8939 "Update summary buffer %s? "
8941 (switch-to-buffer buf)
8942 (gnus-summary-exit))
8949 (run-hooks 'gnus-sum-load-hook)
8951 ;;; gnus-sum.el ends here