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 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
765 "Variable that says which function should be used to decode a string with encoded words.")
767 ;;; Internal variables
769 (defvar gnus-article-mime-handles nil)
770 (defvar gnus-article-decoded-p nil)
771 (defvar gnus-scores-exclude-files nil)
772 (defvar gnus-page-broken nil)
774 (defvar gnus-original-article nil)
775 (defvar gnus-article-internal-prepare-hook nil)
776 (defvar gnus-newsgroup-process-stack nil)
778 (defvar gnus-thread-indent-array nil)
779 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
781 ;; Avoid highlighting in kill files.
782 (defvar gnus-summary-inhibit-highlight nil)
783 (defvar gnus-newsgroup-selected-overlay nil)
784 (defvar gnus-inhibit-limiting nil)
785 (defvar gnus-newsgroup-adaptive-score-file nil)
786 (defvar gnus-current-score-file nil)
787 (defvar gnus-current-move-group nil)
788 (defvar gnus-current-copy-group nil)
789 (defvar gnus-current-crosspost-group nil)
791 (defvar gnus-newsgroup-dependencies nil)
792 (defvar gnus-newsgroup-adaptive nil)
793 (defvar gnus-summary-display-article-function nil)
794 (defvar gnus-summary-highlight-line-function nil
795 "Function called after highlighting a summary line.")
797 (defvar gnus-summary-line-format-alist
798 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
799 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
800 (?s gnus-tmp-subject-or-nil ?s)
801 (?n gnus-tmp-name ?s)
802 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
804 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
806 (?F gnus-tmp-from ?s)
807 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
808 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
809 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
810 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
811 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
812 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
813 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
814 (?L gnus-tmp-lines ?d)
815 (?I gnus-tmp-indentation ?s)
816 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
817 (?R gnus-tmp-replied ?c)
818 (?\[ gnus-tmp-opening-bracket ?c)
819 (?\] gnus-tmp-closing-bracket ?c)
820 (?\> (make-string gnus-tmp-level ? ) ?s)
821 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
822 (?i gnus-tmp-score ?d)
823 (?z gnus-tmp-score-char ?c)
824 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
825 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
826 (?U gnus-tmp-unread ?c)
827 (?t (gnus-summary-number-of-articles-in-thread
828 (and (boundp 'thread) (car thread)) gnus-tmp-level)
830 (?e (gnus-summary-number-of-articles-in-thread
831 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
833 (?u gnus-tmp-user-defined ?s)
834 (?P (gnus-pick-line-number) ?d))
835 "An alist of format specifications that can appear in summary lines,
836 and what variables they correspond with, along with the type of the
837 variable (string, integer, character, etc).")
839 (defvar gnus-summary-dummy-line-format-alist
840 `((?S gnus-tmp-subject ?s)
841 (?N gnus-tmp-number ?d)
842 (?u gnus-tmp-user-defined ?s)))
844 (defvar gnus-summary-mode-line-format-alist
845 `((?G gnus-tmp-group-name ?s)
846 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
847 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
848 (?A gnus-tmp-article-number ?d)
849 (?Z gnus-tmp-unread-and-unselected ?s)
851 (?U gnus-tmp-unread-and-unticked ?d)
852 (?S gnus-tmp-subject ?s)
853 (?e gnus-tmp-unselected ?d)
854 (?u gnus-tmp-user-defined ?s)
855 (?d (length gnus-newsgroup-dormant) ?d)
856 (?t (length gnus-newsgroup-marked) ?d)
857 (?r (length gnus-newsgroup-reads) ?d)
858 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
859 (?E gnus-newsgroup-expunged-tally ?d)
860 (?s (gnus-current-score-file-nondirectory) ?s)))
862 (defvar gnus-last-search-regexp nil
863 "Default regexp for article search command.")
865 (defvar gnus-last-shell-command nil
866 "Default shell command on article.")
868 (defvar gnus-newsgroup-begin nil)
869 (defvar gnus-newsgroup-end nil)
870 (defvar gnus-newsgroup-last-rmail nil)
871 (defvar gnus-newsgroup-last-mail nil)
872 (defvar gnus-newsgroup-last-folder nil)
873 (defvar gnus-newsgroup-last-file nil)
874 (defvar gnus-newsgroup-auto-expire nil)
875 (defvar gnus-newsgroup-active nil)
877 (defvar gnus-newsgroup-data nil)
878 (defvar gnus-newsgroup-data-reverse nil)
879 (defvar gnus-newsgroup-limit nil)
880 (defvar gnus-newsgroup-limits nil)
882 (defvar gnus-newsgroup-unreads nil
883 "List of unread articles in the current newsgroup.")
885 (defvar gnus-newsgroup-unselected nil
886 "List of unselected unread articles in the current newsgroup.")
888 (defvar gnus-newsgroup-reads nil
889 "Alist of read articles and article marks in the current newsgroup.")
891 (defvar gnus-newsgroup-expunged-tally nil)
893 (defvar gnus-newsgroup-marked nil
894 "List of ticked articles in the current newsgroup (a subset of unread art).")
896 (defvar gnus-newsgroup-killed nil
897 "List of ranges of articles that have been through the scoring process.")
899 (defvar gnus-newsgroup-cached nil
900 "List of articles that come from the article cache.")
902 (defvar gnus-newsgroup-saved nil
903 "List of articles that have been saved.")
905 (defvar gnus-newsgroup-kill-headers nil)
907 (defvar gnus-newsgroup-replied nil
908 "List of articles that have been replied to in the current newsgroup.")
910 (defvar gnus-newsgroup-expirable nil
911 "List of articles in the current newsgroup that can be expired.")
913 (defvar gnus-newsgroup-processable nil
914 "List of articles in the current newsgroup that can be processed.")
916 (defvar gnus-newsgroup-downloadable nil
917 "List of articles in the current newsgroup that can be processed.")
919 (defvar gnus-newsgroup-undownloaded nil
920 "List of articles in the current newsgroup that haven't been downloaded..")
922 (defvar gnus-newsgroup-unsendable nil
923 "List of articles in the current newsgroup that won't be sent.")
925 (defvar gnus-newsgroup-bookmarks nil
926 "List of articles in the current newsgroup that have bookmarks.")
928 (defvar gnus-newsgroup-dormant nil
929 "List of dormant articles in the current newsgroup.")
931 (defvar gnus-newsgroup-scored nil
932 "List of scored articles in the current newsgroup.")
934 (defvar gnus-newsgroup-headers nil
935 "List of article headers in the current newsgroup.")
937 (defvar gnus-newsgroup-threads nil)
939 (defvar gnus-newsgroup-prepared nil
940 "Whether the current group has been prepared properly.")
942 (defvar gnus-newsgroup-ancient nil
943 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
945 (defvar gnus-newsgroup-sparse nil)
947 (defvar gnus-current-article nil)
948 (defvar gnus-article-current nil)
949 (defvar gnus-current-headers nil)
950 (defvar gnus-have-all-headers nil)
951 (defvar gnus-last-article nil)
952 (defvar gnus-newsgroup-history nil)
954 (defconst gnus-summary-local-variables
955 '(gnus-newsgroup-name
956 gnus-newsgroup-begin gnus-newsgroup-end
957 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
958 gnus-newsgroup-last-folder gnus-newsgroup-last-file
959 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
960 gnus-newsgroup-unselected gnus-newsgroup-marked
961 gnus-newsgroup-reads gnus-newsgroup-saved
962 gnus-newsgroup-replied gnus-newsgroup-expirable
963 gnus-newsgroup-processable gnus-newsgroup-killed
964 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
965 gnus-newsgroup-unsendable
966 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
967 gnus-newsgroup-headers gnus-newsgroup-threads
968 gnus-newsgroup-prepared gnus-summary-highlight-line-function
969 gnus-current-article gnus-current-headers gnus-have-all-headers
970 gnus-last-article gnus-article-internal-prepare-hook
971 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
972 gnus-newsgroup-scored gnus-newsgroup-kill-headers
973 gnus-thread-expunge-below
974 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
975 (gnus-summary-mark-below . global)
976 gnus-newsgroup-active gnus-scores-exclude-files
977 gnus-newsgroup-history gnus-newsgroup-ancient
978 gnus-newsgroup-sparse gnus-newsgroup-process-stack
979 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
980 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
981 (gnus-newsgroup-expunged-tally . 0)
982 gnus-cache-removable-articles gnus-newsgroup-cached
983 gnus-newsgroup-data gnus-newsgroup-data-reverse
984 gnus-newsgroup-limit gnus-newsgroup-limits)
985 "Variables that are buffer-local to the summary buffers.")
987 ;; Byte-compiler warning.
988 (defvar gnus-article-mode-map)
992 (defvar gnus-encoded-word-method-alist
993 '(("chinese" mail-decode-encoded-word-string rfc1843-decode-string)
994 (".*" mail-decode-encoded-word-string))
995 "Alist of regexps (to match group names) and lists of functions to be applied.")
997 (defun gnus-multi-decode-encoded-word-string (string)
998 "Apply the functions from `gnus-encoded-word-method-alist' that match."
999 (let ((alist gnus-encoded-word-method-alist)
1001 (while (setq elem (pop alist))
1002 (when (string-match (car elem) gnus-newsgroup-name)
1005 (setq string (funcall (pop elem) string)))
1009 ;; Subject simplification.
1011 (defun gnus-simplify-whitespace (str)
1012 "Remove excessive whitespace."
1015 (while (string-match "[ \t][ \t]+" mystr)
1016 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1018 (substring mystr (match-end 0)))))
1020 (when (string-match "^[ \t]+" mystr)
1021 (setq mystr (substring mystr (match-end 0))))
1023 (when (string-match "[ \t]+$" mystr)
1024 (setq mystr (substring mystr 0 (match-beginning 0))))
1027 (defsubst gnus-simplify-subject-re (subject)
1028 "Remove \"Re:\" from subject lines."
1029 (if (string-match "^[Rr][Ee]: *" subject)
1030 (substring subject (match-end 0))
1033 (defun gnus-simplify-subject (subject &optional re-only)
1034 "Remove `Re:' and words in parentheses.
1035 If RE-ONLY is non-nil, strip leading `Re:'s only."
1036 (let ((case-fold-search t)) ;Ignore case.
1037 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1038 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1039 (setq subject (substring subject (match-end 0))))
1040 ;; Remove uninteresting prefixes.
1041 (when (and (not re-only)
1042 gnus-simplify-ignored-prefixes
1043 (string-match gnus-simplify-ignored-prefixes subject))
1044 (setq subject (substring subject (match-end 0))))
1045 ;; Remove words in parentheses from end.
1047 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1048 (setq subject (substring subject 0 (match-beginning 0)))))
1049 ;; Return subject string.
1052 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1054 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1055 (goto-char (point-min))
1056 (while (re-search-forward regexp nil t)
1057 (replace-match (or newtext ""))))
1059 (defun gnus-simplify-buffer-fuzzy ()
1060 "Simplify string in the buffer fuzzily.
1061 The string in the accessible portion of the current buffer is simplified.
1062 It is assumed to be a single-line subject.
1063 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1064 matter is removed. Additional things can be deleted by setting
1065 gnus-simplify-subject-fuzzy-regexp."
1066 (let ((case-fold-search t)
1068 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1070 (while (not (eq modified-tick (buffer-modified-tick)))
1071 (setq modified-tick (buffer-modified-tick))
1073 ((listp gnus-simplify-subject-fuzzy-regexp)
1074 (mapcar 'gnus-simplify-buffer-fuzzy-step
1075 gnus-simplify-subject-fuzzy-regexp))
1076 (gnus-simplify-subject-fuzzy-regexp
1077 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1078 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1079 (gnus-simplify-buffer-fuzzy-step
1080 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1081 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1083 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1084 (gnus-simplify-buffer-fuzzy-step " +" " ")
1085 (gnus-simplify-buffer-fuzzy-step " $")
1086 (gnus-simplify-buffer-fuzzy-step "^ +")))
1088 (defun gnus-simplify-subject-fuzzy (subject)
1089 "Simplify a subject string fuzzily.
1090 See `gnus-simplify-buffer-fuzzy' for details."
1092 (gnus-set-work-buffer)
1093 (let ((case-fold-search t))
1094 ;; Remove uninteresting prefixes.
1095 (when (and gnus-simplify-ignored-prefixes
1096 (string-match gnus-simplify-ignored-prefixes subject))
1097 (setq subject (substring subject (match-end 0))))
1099 (inline (gnus-simplify-buffer-fuzzy))
1102 (defsubst gnus-simplify-subject-fully (subject)
1103 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1105 (gnus-simplify-subject-functions
1106 (gnus-map-function gnus-simplify-subject-functions subject))
1107 ((null gnus-summary-gather-subject-limit)
1108 (gnus-simplify-subject-re subject))
1109 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1110 (gnus-simplify-subject-fuzzy subject))
1111 ((numberp gnus-summary-gather-subject-limit)
1112 (gnus-limit-string (gnus-simplify-subject-re subject)
1113 gnus-summary-gather-subject-limit))
1117 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1118 "Check whether two subjects are equal.
1119 If optional argument simple-first is t, first argument is already
1122 ((null simple-first)
1123 (equal (gnus-simplify-subject-fully s1)
1124 (gnus-simplify-subject-fully s2)))
1127 (gnus-simplify-subject-fully s2)))))
1129 (defun gnus-summary-bubble-group ()
1130 "Increase the score of the current group.
1131 This is a handy function to add to `gnus-summary-exit-hook' to
1132 increase the score of each group you read."
1133 (gnus-group-add-score gnus-newsgroup-name))
1137 ;;; Gnus summary mode
1140 (put 'gnus-summary-mode 'mode-class 'special)
1143 ;; Non-orthogonal keys
1145 (gnus-define-keys gnus-summary-mode-map
1146 " " gnus-summary-next-page
1147 "\177" gnus-summary-prev-page
1148 [delete] gnus-summary-prev-page
1149 [backspace] gnus-summary-prev-page
1150 "\r" gnus-summary-scroll-up
1151 "\M-\r" gnus-summary-scroll-down
1152 "n" gnus-summary-next-unread-article
1153 "p" gnus-summary-prev-unread-article
1154 "N" gnus-summary-next-article
1155 "P" gnus-summary-prev-article
1156 "\M-\C-n" gnus-summary-next-same-subject
1157 "\M-\C-p" gnus-summary-prev-same-subject
1158 "\M-n" gnus-summary-next-unread-subject
1159 "\M-p" gnus-summary-prev-unread-subject
1160 "." gnus-summary-first-unread-article
1161 "," gnus-summary-best-unread-article
1162 "\M-s" gnus-summary-search-article-forward
1163 "\M-r" gnus-summary-search-article-backward
1164 "<" gnus-summary-beginning-of-article
1165 ">" gnus-summary-end-of-article
1166 "j" gnus-summary-goto-article
1167 "^" gnus-summary-refer-parent-article
1168 "\M-^" gnus-summary-refer-article
1169 "u" gnus-summary-tick-article-forward
1170 "!" gnus-summary-tick-article-forward
1171 "U" gnus-summary-tick-article-backward
1172 "d" gnus-summary-mark-as-read-forward
1173 "D" gnus-summary-mark-as-read-backward
1174 "E" gnus-summary-mark-as-expirable
1175 "\M-u" gnus-summary-clear-mark-forward
1176 "\M-U" gnus-summary-clear-mark-backward
1177 "k" gnus-summary-kill-same-subject-and-select
1178 "\C-k" gnus-summary-kill-same-subject
1179 "\M-\C-k" gnus-summary-kill-thread
1180 "\M-\C-l" gnus-summary-lower-thread
1181 "e" gnus-summary-edit-article
1182 "#" gnus-summary-mark-as-processable
1183 "\M-#" gnus-summary-unmark-as-processable
1184 "\M-\C-t" gnus-summary-toggle-threads
1185 "\M-\C-s" gnus-summary-show-thread
1186 "\M-\C-h" gnus-summary-hide-thread
1187 "\M-\C-f" gnus-summary-next-thread
1188 "\M-\C-b" gnus-summary-prev-thread
1189 "\M-\C-u" gnus-summary-up-thread
1190 "\M-\C-d" gnus-summary-down-thread
1191 "&" gnus-summary-execute-command
1192 "c" gnus-summary-catchup-and-exit
1193 "\C-w" gnus-summary-mark-region-as-read
1194 "\C-t" gnus-summary-toggle-truncation
1195 "?" gnus-summary-mark-as-dormant
1196 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1197 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1198 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1199 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1200 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1201 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1202 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1203 "=" gnus-summary-expand-window
1204 "\C-x\C-s" gnus-summary-reselect-current-group
1205 "\M-g" gnus-summary-rescan-group
1206 "w" gnus-summary-stop-page-breaking
1207 "\C-c\C-r" gnus-summary-caesar-message
1208 "f" gnus-summary-followup
1209 "F" gnus-summary-followup-with-original
1210 "C" gnus-summary-cancel-article
1211 "r" gnus-summary-reply
1212 "R" gnus-summary-reply-with-original
1213 "\C-c\C-f" gnus-summary-mail-forward
1214 "o" gnus-summary-save-article
1215 "\C-o" gnus-summary-save-article-mail
1216 "|" gnus-summary-pipe-output
1217 "\M-k" gnus-summary-edit-local-kill
1218 "\M-K" gnus-summary-edit-global-kill
1220 "\C-c\C-d" gnus-summary-describe-group
1221 "q" gnus-summary-exit
1222 "Q" gnus-summary-exit-no-update
1223 "\C-c\C-i" gnus-info-find-node
1224 gnus-mouse-2 gnus-mouse-pick-article
1225 "m" gnus-summary-mail-other-window
1226 "a" gnus-summary-post-news
1227 "x" gnus-summary-limit-to-unread
1228 "s" gnus-summary-isearch-article
1229 "t" gnus-article-hide-headers
1230 "g" gnus-summary-show-article
1231 "l" gnus-summary-goto-last-article
1232 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1233 "\C-d" gnus-summary-enter-digest-group
1234 "\M-\C-d" gnus-summary-read-document
1235 "\M-\C-e" gnus-summary-edit-parameters
1237 "*" gnus-cache-enter-article
1238 "\M-*" gnus-cache-remove-article
1239 "\M-&" gnus-summary-universal-argument
1240 "\C-l" gnus-recenter
1241 "I" gnus-summary-increase-score
1242 "L" gnus-summary-lower-score
1243 "\M-i" gnus-symbolic-argument
1244 "h" gnus-summary-select-article-buffer
1246 "V" gnus-summary-score-map
1247 "X" gnus-uu-extract-map
1248 "S" gnus-summary-send-map)
1250 ;; Sort of orthogonal keymap
1251 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1252 "t" gnus-summary-tick-article-forward
1253 "!" gnus-summary-tick-article-forward
1254 "d" gnus-summary-mark-as-read-forward
1255 "r" gnus-summary-mark-as-read-forward
1256 "c" gnus-summary-clear-mark-forward
1257 " " gnus-summary-clear-mark-forward
1258 "e" gnus-summary-mark-as-expirable
1259 "x" gnus-summary-mark-as-expirable
1260 "?" gnus-summary-mark-as-dormant
1261 "b" gnus-summary-set-bookmark
1262 "B" gnus-summary-remove-bookmark
1263 "#" gnus-summary-mark-as-processable
1264 "\M-#" gnus-summary-unmark-as-processable
1265 "S" gnus-summary-limit-include-expunged
1266 "C" gnus-summary-catchup
1267 "H" gnus-summary-catchup-to-here
1268 "\C-c" gnus-summary-catchup-all
1269 "k" gnus-summary-kill-same-subject-and-select
1270 "K" gnus-summary-kill-same-subject
1271 "P" gnus-uu-mark-map)
1273 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1274 "c" gnus-summary-clear-above
1275 "u" gnus-summary-tick-above
1276 "m" gnus-summary-mark-above
1277 "k" gnus-summary-kill-below)
1279 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1280 "/" gnus-summary-limit-to-subject
1281 "n" gnus-summary-limit-to-articles
1282 "w" gnus-summary-pop-limit
1283 "s" gnus-summary-limit-to-subject
1284 "a" gnus-summary-limit-to-author
1285 "u" gnus-summary-limit-to-unread
1286 "m" gnus-summary-limit-to-marks
1287 "v" gnus-summary-limit-to-score
1288 "*" gnus-summary-limit-include-cached
1289 "D" gnus-summary-limit-include-dormant
1290 "T" gnus-summary-limit-include-thread
1291 "d" gnus-summary-limit-exclude-dormant
1292 "t" gnus-summary-limit-to-age
1293 "E" gnus-summary-limit-include-expunged
1294 "c" gnus-summary-limit-exclude-childless-dormant
1295 "C" gnus-summary-limit-mark-excluded-as-read)
1297 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1298 "n" gnus-summary-next-unread-article
1299 "p" gnus-summary-prev-unread-article
1300 "N" gnus-summary-next-article
1301 "P" gnus-summary-prev-article
1302 "\C-n" gnus-summary-next-same-subject
1303 "\C-p" gnus-summary-prev-same-subject
1304 "\M-n" gnus-summary-next-unread-subject
1305 "\M-p" gnus-summary-prev-unread-subject
1306 "f" gnus-summary-first-unread-article
1307 "b" gnus-summary-best-unread-article
1308 "j" gnus-summary-goto-article
1309 "g" gnus-summary-goto-subject
1310 "l" gnus-summary-goto-last-article
1311 "o" gnus-summary-pop-article)
1313 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1314 "k" gnus-summary-kill-thread
1315 "l" gnus-summary-lower-thread
1316 "i" gnus-summary-raise-thread
1317 "T" gnus-summary-toggle-threads
1318 "t" gnus-summary-rethread-current
1319 "^" gnus-summary-reparent-thread
1320 "s" gnus-summary-show-thread
1321 "S" gnus-summary-show-all-threads
1322 "h" gnus-summary-hide-thread
1323 "H" gnus-summary-hide-all-threads
1324 "n" gnus-summary-next-thread
1325 "p" gnus-summary-prev-thread
1326 "u" gnus-summary-up-thread
1327 "o" gnus-summary-top-thread
1328 "d" gnus-summary-down-thread
1329 "#" gnus-uu-mark-thread
1330 "\M-#" gnus-uu-unmark-thread)
1332 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1333 "g" gnus-summary-prepare
1334 "c" gnus-summary-insert-cached-articles)
1336 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1337 "c" gnus-summary-catchup-and-exit
1338 "C" gnus-summary-catchup-all-and-exit
1339 "E" gnus-summary-exit-no-update
1340 "Q" gnus-summary-exit
1341 "Z" gnus-summary-exit
1342 "n" gnus-summary-catchup-and-goto-next-group
1343 "R" gnus-summary-reselect-current-group
1344 "G" gnus-summary-rescan-group
1345 "N" gnus-summary-next-group
1346 "s" gnus-summary-save-newsrc
1347 "P" gnus-summary-prev-group)
1349 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1350 " " gnus-summary-next-page
1351 "n" gnus-summary-next-page
1352 "\177" gnus-summary-prev-page
1353 [delete] gnus-summary-prev-page
1354 "p" gnus-summary-prev-page
1355 "\r" gnus-summary-scroll-up
1356 "\M-\r" gnus-summary-scroll-down
1357 "<" gnus-summary-beginning-of-article
1358 ">" gnus-summary-end-of-article
1359 "b" gnus-summary-beginning-of-article
1360 "e" gnus-summary-end-of-article
1361 "^" gnus-summary-refer-parent-article
1362 "r" gnus-summary-refer-parent-article
1363 "R" gnus-summary-refer-references
1364 "T" gnus-summary-refer-thread
1365 "g" gnus-summary-show-article
1366 "s" gnus-summary-isearch-article
1367 "P" gnus-summary-print-article)
1369 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1370 "b" gnus-article-add-buttons
1371 "B" gnus-article-add-buttons-to-head
1372 "o" gnus-article-treat-overstrike
1373 "e" gnus-article-emphasize
1374 "w" gnus-article-fill-cited-article
1375 "c" gnus-article-remove-cr
1376 "q" gnus-article-de-quoted-unreadable
1377 "f" gnus-article-display-x-face
1378 "l" gnus-summary-stop-page-breaking
1379 "r" gnus-summary-caesar-message
1380 "t" gnus-article-hide-headers
1381 "v" gnus-summary-verbose-headers
1382 "h" gnus-article-treat-html
1383 "d" gnus-article-treat-dumbquotes)
1385 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1386 "a" gnus-article-hide
1387 "h" gnus-article-hide-headers
1388 "b" gnus-article-hide-boring-headers
1389 "s" gnus-article-hide-signature
1390 "c" gnus-article-hide-citation
1391 "C" gnus-article-hide-citation-in-followups
1392 "p" gnus-article-hide-pgp
1393 "P" gnus-article-hide-pem
1394 "\C-c" gnus-article-hide-citation-maybe)
1396 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1397 "a" gnus-article-highlight
1398 "h" gnus-article-highlight-headers
1399 "c" gnus-article-highlight-citation
1400 "s" gnus-article-highlight-signature)
1402 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1403 "w" gnus-article-decode-mime-words
1404 "c" gnus-article-decode-charset)
1406 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1407 "z" gnus-article-date-ut
1408 "u" gnus-article-date-ut
1409 "l" gnus-article-date-local
1410 "e" gnus-article-date-lapsed
1411 "o" gnus-article-date-original
1412 "i" gnus-article-date-iso8601
1413 "s" gnus-article-date-user)
1415 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1416 "t" gnus-article-remove-trailing-blank-lines
1417 "l" gnus-article-strip-leading-blank-lines
1418 "m" gnus-article-strip-multiple-blank-lines
1419 "a" gnus-article-strip-blank-lines
1420 "A" gnus-article-strip-all-blank-lines
1421 "s" gnus-article-strip-leading-space)
1423 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1425 "f" gnus-summary-fetch-faq
1426 "d" gnus-summary-describe-group
1427 "h" gnus-summary-describe-briefly
1428 "i" gnus-info-find-node)
1430 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1431 "e" gnus-summary-expire-articles
1432 "\M-\C-e" gnus-summary-expire-articles-now
1433 "\177" gnus-summary-delete-article
1434 [delete] gnus-summary-delete-article
1435 "m" gnus-summary-move-article
1436 "r" gnus-summary-respool-article
1437 "w" gnus-summary-edit-article
1438 "c" gnus-summary-copy-article
1439 "B" gnus-summary-crosspost-article
1440 "q" gnus-summary-respool-query
1441 "t" gnus-summary-respool-trace
1442 "i" gnus-summary-import-article
1443 "p" gnus-summary-article-posted-p)
1445 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1446 "o" gnus-summary-save-article
1447 "m" gnus-summary-save-article-mail
1448 "F" gnus-summary-write-article-file
1449 "r" gnus-summary-save-article-rmail
1450 "f" gnus-summary-save-article-file
1451 "b" gnus-summary-save-article-body-file
1452 "h" gnus-summary-save-article-folder
1453 "v" gnus-summary-save-article-vm
1454 "p" gnus-summary-pipe-output
1455 "s" gnus-soup-add-article))
1457 (defun gnus-summary-make-menu-bar ()
1458 (gnus-turn-off-edit-menu 'summary)
1460 (unless (boundp 'gnus-summary-misc-menu)
1463 gnus-summary-kill-menu gnus-summary-mode-map ""
1468 ["Enter score..." gnus-summary-score-entry t]
1469 ["Customize" gnus-score-customize t])
1470 (gnus-make-score-map 'increase)
1471 (gnus-make-score-map 'lower)
1473 ["Kill below" gnus-summary-kill-below t]
1474 ["Mark above" gnus-summary-mark-above t]
1475 ["Tick above" gnus-summary-tick-above t]
1476 ["Clear above" gnus-summary-clear-above t])
1477 ["Current score" gnus-summary-current-score t]
1478 ["Set score" gnus-summary-set-score t]
1479 ["Switch current score file..." gnus-score-change-score-file t]
1480 ["Set mark below..." gnus-score-set-mark-below t]
1481 ["Set expunge below..." gnus-score-set-expunge-below t]
1482 ["Edit current score file" gnus-score-edit-current-scores t]
1483 ["Edit score file" gnus-score-edit-file t]
1484 ["Trace score" gnus-score-find-trace t]
1485 ["Find words" gnus-score-find-favourite-words t]
1486 ["Rescore buffer" gnus-summary-rescore t]
1487 ["Increase score..." gnus-summary-increase-score t]
1488 ["Lower score..." gnus-summary-lower-score t]))))
1490 ;; Define both the Article menu in the summary buffer and the equivalent
1491 ;; Commands menu in the article buffer here for consistency.
1494 ["All" gnus-article-hide t]
1495 ["Headers" gnus-article-hide-headers t]
1496 ["Signature" gnus-article-hide-signature t]
1497 ["Citation" gnus-article-hide-citation t]
1498 ["PGP" gnus-article-hide-pgp t]
1499 ["Boring headers" gnus-article-hide-boring-headers t])
1501 ["All" gnus-article-highlight t]
1502 ["Headers" gnus-article-highlight-headers t]
1503 ["Signature" gnus-article-highlight-signature t]
1504 ["Citation" gnus-article-highlight-citation t])
1506 ["Words" gnus-article-decode-mime-words t]
1507 ["Charset" gnus-article-decode-charset t]
1508 ["QP" gnus-article-de-quoted-unreadable t])
1510 ["Local" gnus-article-date-local t]
1511 ["ISO8601" gnus-article-date-iso8601 t]
1512 ["UT" gnus-article-date-ut t]
1513 ["Original" gnus-article-date-original t]
1514 ["Lapsed" gnus-article-date-lapsed t]
1515 ["User-defined" gnus-article-date-user t])
1518 ["Leading" gnus-article-strip-leading-blank-lines t]
1519 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1520 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1521 ["All of the above" gnus-article-strip-blank-lines t]
1522 ["All" gnus-article-strip-all-blank-lines t]
1523 ["Leading space" gnus-article-strip-leading-space t])
1524 ["Overstrike" gnus-article-treat-overstrike t]
1525 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1526 ["Emphasis" gnus-article-emphasize t]
1527 ["Word wrap" gnus-article-fill-cited-article t]
1528 ["CR" gnus-article-remove-cr t]
1529 ["Show X-Face" gnus-article-display-x-face t]
1530 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1531 ["UnHTMLize" gnus-article-treat-html t]
1532 ["Rot 13" gnus-summary-caesar-message t]
1533 ["Unix pipe" gnus-summary-pipe-message t]
1534 ["Add buttons" gnus-article-add-buttons t]
1535 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1536 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1537 ["Verbose header" gnus-summary-verbose-headers t]
1538 ["Toggle header" gnus-summary-toggle-header t])
1540 ["Save in default format" gnus-summary-save-article t]
1541 ["Save in file" gnus-summary-save-article-file t]
1542 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1543 ["Save in MH folder" gnus-summary-save-article-folder t]
1544 ["Save in VM folder" gnus-summary-save-article-vm t]
1545 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1546 ["Save body in file" gnus-summary-save-article-body-file t]
1547 ["Pipe through a filter" gnus-summary-pipe-output t]
1548 ["Add to SOUP packet" gnus-soup-add-article t]
1549 ["Print" gnus-summary-print-article t])
1551 ["Respool article..." gnus-summary-respool-article t]
1552 ["Move article..." gnus-summary-move-article
1553 (gnus-check-backend-function
1554 'request-move-article gnus-newsgroup-name)]
1555 ["Copy article..." gnus-summary-copy-article t]
1556 ["Crosspost article..." gnus-summary-crosspost-article
1557 (gnus-check-backend-function
1558 'request-replace-article gnus-newsgroup-name)]
1559 ["Import file..." gnus-summary-import-article t]
1560 ["Check if posted" gnus-summary-article-posted-p t]
1561 ["Edit article" gnus-summary-edit-article
1562 (not (gnus-group-read-only-p))]
1563 ["Delete article" gnus-summary-delete-article
1564 (gnus-check-backend-function
1565 'request-expire-articles gnus-newsgroup-name)]
1566 ["Query respool" gnus-summary-respool-query t]
1567 ["Trace respool" gnus-summary-respool-trace t]
1568 ["Delete expirable articles" gnus-summary-expire-articles-now
1569 (gnus-check-backend-function
1570 'request-expire-articles gnus-newsgroup-name)])
1572 ["Uudecode" gnus-uu-decode-uu t]
1573 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1574 ["Unshar" gnus-uu-decode-unshar t]
1575 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1576 ["Save" gnus-uu-decode-save t]
1577 ["Binhex" gnus-uu-decode-binhex t]
1578 ["Postscript" gnus-uu-decode-postscript t])
1580 ["Enter article" gnus-cache-enter-article t]
1581 ["Remove article" gnus-cache-remove-article t])
1582 ["Select article buffer" gnus-summary-select-article-buffer t]
1583 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1584 ["Isearch article..." gnus-summary-isearch-article t]
1585 ["Beginning of the article" gnus-summary-beginning-of-article t]
1586 ["End of the article" gnus-summary-end-of-article t]
1587 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1588 ["Fetch referenced articles" gnus-summary-refer-references t]
1589 ["Fetch current thread" gnus-summary-refer-thread t]
1590 ["Fetch article with id..." gnus-summary-refer-article t]
1591 ["Redisplay" gnus-summary-show-article t])))
1593 gnus-summary-article-menu gnus-summary-mode-map ""
1594 (cons "Article" innards))
1597 gnus-article-commands-menu gnus-article-mode-map ""
1598 (cons "Commands" innards)))
1601 gnus-summary-thread-menu gnus-summary-mode-map ""
1603 ["Toggle threading" gnus-summary-toggle-threads t]
1604 ["Hide threads" gnus-summary-hide-all-threads t]
1605 ["Show threads" gnus-summary-show-all-threads t]
1606 ["Hide thread" gnus-summary-hide-thread t]
1607 ["Show thread" gnus-summary-show-thread t]
1608 ["Go to next thread" gnus-summary-next-thread t]
1609 ["Go to previous thread" gnus-summary-prev-thread t]
1610 ["Go down thread" gnus-summary-down-thread t]
1611 ["Go up thread" gnus-summary-up-thread t]
1612 ["Top of thread" gnus-summary-top-thread t]
1613 ["Mark thread as read" gnus-summary-kill-thread t]
1614 ["Lower thread score" gnus-summary-lower-thread t]
1615 ["Raise thread score" gnus-summary-raise-thread t]
1616 ["Rethread current" gnus-summary-rethread-current t]
1620 gnus-summary-post-menu gnus-summary-mode-map ""
1622 ["Post an article" gnus-summary-post-news t]
1623 ["Followup" gnus-summary-followup t]
1624 ["Followup and yank" gnus-summary-followup-with-original t]
1625 ["Supersede article" gnus-summary-supersede-article t]
1626 ["Cancel article" gnus-summary-cancel-article t]
1627 ["Reply" gnus-summary-reply t]
1628 ["Reply and yank" gnus-summary-reply-with-original t]
1629 ["Wide reply" gnus-summary-wide-reply t]
1630 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1631 ["Mail forward" gnus-summary-mail-forward t]
1632 ["Post forward" gnus-summary-post-forward t]
1633 ["Digest and mail" gnus-uu-digest-mail-forward t]
1634 ["Digest and post" gnus-uu-digest-post-forward t]
1635 ["Resend message" gnus-summary-resend-message t]
1636 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1637 ["Send a mail" gnus-summary-mail-other-window t]
1638 ["Uuencode and post" gnus-uu-post-news t]
1639 ["Followup via news" gnus-summary-followup-to-mail t]
1640 ["Followup via news and yank"
1641 gnus-summary-followup-to-mail-with-original t]
1643 ;;["Send" gnus-summary-send-draft t]
1644 ;;["Send bounced" gnus-resend-bounced-mail t])
1648 gnus-summary-misc-menu gnus-summary-mode-map ""
1651 ["Mark as read" gnus-summary-mark-as-read-forward t]
1652 ["Mark same subject and select"
1653 gnus-summary-kill-same-subject-and-select t]
1654 ["Mark same subject" gnus-summary-kill-same-subject t]
1655 ["Catchup" gnus-summary-catchup t]
1656 ["Catchup all" gnus-summary-catchup-all t]
1657 ["Catchup to here" gnus-summary-catchup-to-here t]
1658 ["Catchup region" gnus-summary-mark-region-as-read t]
1659 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1661 ["Tick" gnus-summary-tick-article-forward t]
1662 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1663 ["Remove marks" gnus-summary-clear-mark-forward t]
1664 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1665 ["Set bookmark" gnus-summary-set-bookmark t]
1666 ["Remove bookmark" gnus-summary-remove-bookmark t])
1668 ["Marks..." gnus-summary-limit-to-marks t]
1669 ["Subject..." gnus-summary-limit-to-subject t]
1670 ["Author..." gnus-summary-limit-to-author t]
1671 ["Age..." gnus-summary-limit-to-age t]
1672 ["Score" gnus-summary-limit-to-score t]
1673 ["Unread" gnus-summary-limit-to-unread t]
1674 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1675 ["Articles" gnus-summary-limit-to-articles t]
1676 ["Pop limit" gnus-summary-pop-limit t]
1677 ["Show dormant" gnus-summary-limit-include-dormant t]
1678 ["Hide childless dormant"
1679 gnus-summary-limit-exclude-childless-dormant t]
1680 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1681 ["Show expunged" gnus-summary-show-all-expunged t])
1683 ["Set mark" gnus-summary-mark-as-processable t]
1684 ["Remove mark" gnus-summary-unmark-as-processable t]
1685 ["Remove all marks" gnus-summary-unmark-all-processable t]
1686 ["Mark above" gnus-uu-mark-over t]
1687 ["Mark series" gnus-uu-mark-series t]
1688 ["Mark region" gnus-uu-mark-region t]
1689 ["Unmark region" gnus-uu-unmark-region t]
1690 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1691 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1692 ["Mark all" gnus-uu-mark-all t]
1693 ["Mark buffer" gnus-uu-mark-buffer t]
1694 ["Mark sparse" gnus-uu-mark-sparse t]
1695 ["Mark thread" gnus-uu-mark-thread t]
1696 ["Unmark thread" gnus-uu-unmark-thread t]
1697 ("Process Mark Sets"
1698 ["Kill" gnus-summary-kill-process-mark t]
1699 ["Yank" gnus-summary-yank-process-mark
1700 gnus-newsgroup-process-stack]
1701 ["Save" gnus-summary-save-process-mark t]))
1703 ["Page forward" gnus-summary-next-page t]
1704 ["Page backward" gnus-summary-prev-page t]
1705 ["Line forward" gnus-summary-scroll-up t])
1707 ["Next unread article" gnus-summary-next-unread-article t]
1708 ["Previous unread article" gnus-summary-prev-unread-article t]
1709 ["Next article" gnus-summary-next-article t]
1710 ["Previous article" gnus-summary-prev-article t]
1711 ["Next unread subject" gnus-summary-next-unread-subject t]
1712 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1713 ["Next article same subject" gnus-summary-next-same-subject t]
1714 ["Previous article same subject" gnus-summary-prev-same-subject t]
1715 ["First unread article" gnus-summary-first-unread-article t]
1716 ["Best unread article" gnus-summary-best-unread-article t]
1717 ["Go to subject number..." gnus-summary-goto-subject t]
1718 ["Go to article number..." gnus-summary-goto-article t]
1719 ["Go to the last article" gnus-summary-goto-last-article t]
1720 ["Pop article off history" gnus-summary-pop-article t])
1722 ["Sort by number" gnus-summary-sort-by-number t]
1723 ["Sort by author" gnus-summary-sort-by-author t]
1724 ["Sort by subject" gnus-summary-sort-by-subject t]
1725 ["Sort by date" gnus-summary-sort-by-date t]
1726 ["Sort by score" gnus-summary-sort-by-score t]
1727 ["Sort by lines" gnus-summary-sort-by-lines t])
1729 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1730 ["Describe group" gnus-summary-describe-group t]
1731 ["Read manual" gnus-info-find-node t])
1733 ["Pick and read" gnus-pick-mode t]
1734 ["Binary" gnus-binary-mode t])
1736 ["Regenerate" gnus-summary-prepare t]
1737 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1738 ["Toggle threading" gnus-summary-toggle-threads t])
1739 ["Filter articles..." gnus-summary-execute-command t]
1740 ["Run command on subjects..." gnus-summary-universal-argument t]
1741 ["Search articles forward..." gnus-summary-search-article-forward t]
1742 ["Search articles backward..." gnus-summary-search-article-backward t]
1743 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1744 ["Expand window" gnus-summary-expand-window t]
1745 ["Expire expirable articles" gnus-summary-expire-articles
1746 (gnus-check-backend-function
1747 'request-expire-articles gnus-newsgroup-name)]
1748 ["Edit local kill file" gnus-summary-edit-local-kill t]
1749 ["Edit main kill file" gnus-summary-edit-global-kill t]
1750 ["Edit group parameters" gnus-summary-edit-parameters t]
1751 ["Send a bug report" gnus-bug t]
1753 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1754 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1755 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1756 ["Exit group" gnus-summary-exit t]
1757 ["Exit group without updating" gnus-summary-exit-no-update t]
1758 ["Exit and goto next group" gnus-summary-next-group t]
1759 ["Exit and goto prev group" gnus-summary-prev-group t]
1760 ["Reselect group" gnus-summary-reselect-current-group t]
1761 ["Rescan group" gnus-summary-rescan-group t]
1762 ["Update dribble" gnus-summary-save-newsrc t])))
1764 (gnus-run-hooks 'gnus-summary-menu-hook)))
1766 (defun gnus-score-set-default (var value)
1767 "A version of set that updates the GNU Emacs menu-bar."
1769 ;; It is the message that forces the active status to be updated.
1772 (defun gnus-make-score-map (type)
1773 "Make a summary score map of type TYPE."
1776 (let ((headers '(("author" "from" string)
1777 ("subject" "subject" string)
1778 ("article body" "body" string)
1779 ("article head" "head" string)
1780 ("xref" "xref" string)
1781 ("lines" "lines" number)
1782 ("followups to author" "followup" string)))
1783 (types '((number ("less than" <)
1786 (string ("substring" s)
1790 (perms '(("temporary" (current-time-string))
1798 (if (eq type 'lower)
1803 (setq header (car headers))
1809 (let ((ts (cdr (assoc (nth 2 header) types)))
1825 'gnus-summary-score-entry
1827 (if (or (string= (nth 1 header)
1829 (string= (nth 1 header)
1832 (list 'gnus-summary-header
1834 (list 'quote (nth 1 (car ts)))
1835 (list 'gnus-score-default nil)
1841 (list (nreverse outp))))
1844 (list (nreverse outt))))
1846 (setq headers (cdr headers)))
1847 (list (nreverse outh))))))))
1851 (defun gnus-summary-mode (&optional group)
1852 "Major mode for reading articles.
1854 All normal editing commands are switched off.
1855 \\<gnus-summary-mode-map>
1856 Each line in this buffer represents one article. To read an
1857 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1858 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1861 You can also post articles and send mail from this buffer. To
1862 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1863 of an article, type `\\[gnus-summary-reply]'.
1865 There are approx. one gazillion commands you can execute in this
1866 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1868 The following commands are available:
1870 \\{gnus-summary-mode-map}"
1872 (when (gnus-visual-p 'summary-menu 'menu)
1873 (gnus-summary-make-menu-bar))
1874 (kill-all-local-variables)
1875 (gnus-summary-make-local-variables)
1876 (gnus-make-thread-indent-array)
1877 (gnus-simplify-mode-line)
1878 (setq major-mode 'gnus-summary-mode)
1879 (setq mode-name "Summary")
1880 (make-local-variable 'minor-mode-alist)
1881 (use-local-map gnus-summary-mode-map)
1882 (buffer-disable-undo)
1883 (setq buffer-read-only t) ;Disable modification
1884 (setq truncate-lines t)
1885 (setq selective-display t)
1886 (setq selective-display-ellipses t) ;Display `...'
1887 (gnus-summary-set-display-table)
1888 (gnus-set-default-directory)
1889 (setq gnus-newsgroup-name group)
1890 (make-local-variable 'gnus-summary-line-format)
1891 (make-local-variable 'gnus-summary-line-format-spec)
1892 (make-local-variable 'gnus-summary-dummy-line-format)
1893 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1894 (make-local-variable 'gnus-summary-mark-positions)
1895 (make-local-hook 'post-command-hook)
1896 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1897 (make-local-hook 'pre-command-hook)
1898 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1899 (gnus-run-hooks 'gnus-summary-mode-hook)
1900 (mm-enable-multibyte)
1901 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1902 (gnus-update-summary-mark-positions))
1904 (defun gnus-summary-make-local-variables ()
1905 "Make all the local summary buffer variables."
1906 (let ((locals gnus-summary-local-variables)
1908 (while (setq local (pop locals))
1911 (if (eq (cdr local) 'global)
1912 ;; Copy the global value of the variable.
1913 (setq global (symbol-value (car local)))
1914 ;; Use the value from the list.
1915 (setq global (eval (cdr local))))
1916 (make-local-variable (car local))
1917 (set (car local) global))
1918 ;; Simple nil-valued local variable.
1919 (make-local-variable local)
1922 (defun gnus-summary-clear-local-variables ()
1923 (let ((locals gnus-summary-local-variables))
1925 (if (consp (car locals))
1926 (and (vectorp (caar locals))
1927 (set (caar locals) nil))
1928 (and (vectorp (car locals))
1929 (set (car locals) nil)))
1930 (setq locals (cdr locals)))))
1932 ;; Summary data functions.
1934 (defmacro gnus-data-number (data)
1937 (defmacro gnus-data-set-number (data number)
1938 `(setcar ,data ,number))
1940 (defmacro gnus-data-mark (data)
1943 (defmacro gnus-data-set-mark (data mark)
1944 `(setcar (nthcdr 1 ,data) ,mark))
1946 (defmacro gnus-data-pos (data)
1949 (defmacro gnus-data-set-pos (data pos)
1950 `(setcar (nthcdr 2 ,data) ,pos))
1952 (defmacro gnus-data-header (data)
1955 (defmacro gnus-data-set-header (data header)
1956 `(setf (nth 3 ,data) ,header))
1958 (defmacro gnus-data-level (data)
1961 (defmacro gnus-data-unread-p (data)
1962 `(= (nth 1 ,data) gnus-unread-mark))
1964 (defmacro gnus-data-read-p (data)
1965 `(/= (nth 1 ,data) gnus-unread-mark))
1967 (defmacro gnus-data-pseudo-p (data)
1968 `(consp (nth 3 ,data)))
1970 (defmacro gnus-data-find (number)
1971 `(assq ,number gnus-newsgroup-data))
1973 (defmacro gnus-data-find-list (number &optional data)
1974 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1975 (memq (assq ,number bdata)
1978 (defmacro gnus-data-make (number mark pos header level)
1979 `(list ,number ,mark ,pos ,header ,level))
1981 (defun gnus-data-enter (after-article number mark pos header level offset)
1982 (let ((data (gnus-data-find-list after-article)))
1984 (error "No such article: %d" after-article))
1985 (setcdr data (cons (gnus-data-make number mark pos header level)
1987 (setq gnus-newsgroup-data-reverse nil)
1988 (gnus-data-update-list (cddr data) offset)))
1990 (defun gnus-data-enter-list (after-article list &optional offset)
1992 (let ((data (and after-article (gnus-data-find-list after-article)))
1996 (let ((odata gnus-newsgroup-data))
1997 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
1999 (gnus-data-update-list odata offset)))
2000 ;; Find the last element in the list to be spliced into the main
2003 (setq list (cdr list)))
2006 (setcdr list gnus-newsgroup-data)
2007 (setq gnus-newsgroup-data ilist)
2009 (gnus-data-update-list (cdr list) offset)))
2010 (setcdr list (cdr data))
2013 (gnus-data-update-list (cdr list) offset))))
2014 (setq gnus-newsgroup-data-reverse nil))))
2016 (defun gnus-data-remove (article &optional offset)
2017 (let ((data gnus-newsgroup-data))
2018 (if (= (gnus-data-number (car data)) article)
2020 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2021 gnus-newsgroup-data-reverse nil)
2023 (gnus-data-update-list gnus-newsgroup-data offset)))
2025 (when (= (gnus-data-number (cadr data)) article)
2026 (setcdr data (cddr data))
2028 (gnus-data-update-list (cdr data) offset))
2030 gnus-newsgroup-data-reverse nil))
2031 (setq data (cdr data))))))
2033 (defmacro gnus-data-list (backward)
2035 (or gnus-newsgroup-data-reverse
2036 (setq gnus-newsgroup-data-reverse
2037 (reverse gnus-newsgroup-data)))
2038 gnus-newsgroup-data))
2040 (defun gnus-data-update-list (data offset)
2041 "Add OFFSET to the POS of all data entries in DATA."
2042 (setq gnus-newsgroup-data-reverse nil)
2044 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2045 (setq data (cdr data))))
2047 (defun gnus-summary-article-pseudo-p (article)
2048 "Say whether this article is a pseudo article or not."
2049 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2051 (defmacro gnus-summary-article-sparse-p (article)
2052 "Say whether this article is a sparse article or not."
2053 `(memq ,article gnus-newsgroup-sparse))
2055 (defmacro gnus-summary-article-ancient-p (article)
2056 "Say whether this article is a sparse article or not."
2057 `(memq ,article gnus-newsgroup-ancient))
2059 (defun gnus-article-parent-p (number)
2060 "Say whether this article is a parent or not."
2061 (let ((data (gnus-data-find-list number)))
2062 (and (cdr data) ; There has to be an article after...
2063 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2064 (gnus-data-level (nth 1 data))))))
2066 (defun gnus-article-children (number)
2067 "Return a list of all children to NUMBER."
2068 (let* ((data (gnus-data-find-list number))
2069 (level (gnus-data-level (car data)))
2071 (setq data (cdr data))
2073 (= (gnus-data-level (car data)) (1+ level)))
2074 (push (gnus-data-number (car data)) children)
2075 (setq data (cdr data)))
2078 (defmacro gnus-summary-skip-intangible ()
2079 "If the current article is intangible, then jump to a different article."
2080 '(let ((to (get-text-property (point) 'gnus-intangible)))
2081 (and to (gnus-summary-goto-subject to))))
2083 (defmacro gnus-summary-article-intangible-p ()
2084 "Say whether this article is intangible or not."
2085 '(get-text-property (point) 'gnus-intangible))
2087 (defun gnus-article-read-p (article)
2088 "Say whether ARTICLE is read or not."
2089 (not (or (memq article gnus-newsgroup-marked)
2090 (memq article gnus-newsgroup-unreads)
2091 (memq article gnus-newsgroup-unselected)
2092 (memq article gnus-newsgroup-dormant))))
2094 ;; Some summary mode macros.
2096 (defmacro gnus-summary-article-number ()
2097 "The article number of the article on the current line.
2098 If there isn's an article number here, then we return the current
2101 (gnus-summary-skip-intangible)
2102 (or (get-text-property (point) 'gnus-number)
2103 (gnus-summary-last-subject))))
2105 (defmacro gnus-summary-article-header (&optional number)
2106 "Return the header of article NUMBER."
2107 `(gnus-data-header (gnus-data-find
2108 ,(or number '(gnus-summary-article-number)))))
2110 (defmacro gnus-summary-thread-level (&optional number)
2111 "Return the level of thread that starts with article NUMBER."
2112 `(if (and (eq gnus-summary-make-false-root 'dummy)
2113 (get-text-property (point) 'gnus-intangible))
2115 (gnus-data-level (gnus-data-find
2116 ,(or number '(gnus-summary-article-number))))))
2118 (defmacro gnus-summary-article-mark (&optional number)
2119 "Return the mark of article NUMBER."
2120 `(gnus-data-mark (gnus-data-find
2121 ,(or number '(gnus-summary-article-number)))))
2123 (defmacro gnus-summary-article-pos (&optional number)
2124 "Return the position of the line of article NUMBER."
2125 `(gnus-data-pos (gnus-data-find
2126 ,(or number '(gnus-summary-article-number)))))
2128 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2129 (defmacro gnus-summary-article-subject (&optional number)
2130 "Return current subject string or nil if nothing."
2133 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2134 '(gnus-data-header (assq (gnus-summary-article-number)
2135 gnus-newsgroup-data)))))
2138 (mail-header-subject headers))))
2140 (defmacro gnus-summary-article-score (&optional number)
2141 "Return current article score."
2142 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2143 gnus-newsgroup-scored))
2144 gnus-summary-default-score 0))
2146 (defun gnus-summary-article-children (&optional number)
2147 "Return a list of article numbers that are children of article NUMBER."
2148 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2149 (level (gnus-data-level (car data)))
2151 (while (and (setq data (cdr data))
2152 (> (setq l (gnus-data-level (car data))) level))
2153 (and (= (1+ level) l)
2154 (push (gnus-data-number (car data))
2156 (nreverse children)))
2158 (defun gnus-summary-article-parent (&optional number)
2159 "Return the article number of the parent of article NUMBER."
2160 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2161 (gnus-data-list t)))
2162 (level (gnus-data-level (car data))))
2164 () ; This is a root.
2165 ;; We search until we find an article with a level less than
2166 ;; this one. That function has to be the parent.
2167 (while (and (setq data (cdr data))
2168 (not (< (gnus-data-level (car data)) level))))
2169 (and data (gnus-data-number (car data))))))
2171 (defun gnus-unread-mark-p (mark)
2172 "Say whether MARK is the unread mark."
2173 (= mark gnus-unread-mark))
2175 (defun gnus-read-mark-p (mark)
2176 "Say whether MARK is one of the marks that mark as read.
2177 This is all marks except unread, ticked, dormant, and expirable."
2178 (not (or (= mark gnus-unread-mark)
2179 (= mark gnus-ticked-mark)
2180 (= mark gnus-dormant-mark)
2181 (= mark gnus-expirable-mark))))
2183 (defmacro gnus-article-mark (number)
2184 "Return the MARK of article NUMBER.
2185 This macro should only be used when computing the mark the \"first\"
2186 time; i.e., when generating the summary lines. After that,
2187 `gnus-summary-article-mark' should be used to examine the
2190 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2191 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2192 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2193 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2194 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2195 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2196 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2197 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2198 gnus-ancient-mark))))
2200 ;; Saving hidden threads.
2202 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2203 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2205 (defmacro gnus-save-hidden-threads (&rest forms)
2206 "Save hidden threads, eval FORMS, and restore the hidden threads."
2207 (let ((config (make-symbol "config")))
2208 `(let ((,config (gnus-hidden-threads-configuration)))
2212 (gnus-restore-hidden-threads-configuration ,config)))))
2214 (defun gnus-data-compute-positions ()
2215 "Compute the positions of all articles."
2216 (setq gnus-newsgroup-data-reverse nil)
2217 (let ((data gnus-newsgroup-data))
2219 (gnus-save-hidden-threads
2220 (gnus-summary-show-all-threads)
2221 (goto-char (point-min))
2223 (while (get-text-property (point) 'gnus-intangible)
2225 (gnus-data-set-pos (car data) (+ (point) 3))
2226 (setq data (cdr data))
2227 (forward-line 1))))))
2229 (defun gnus-hidden-threads-configuration ()
2230 "Return the current hidden threads configuration."
2233 (goto-char (point-min))
2234 (while (search-forward "\r" nil t)
2235 (push (1- (point)) config))
2238 (defun gnus-restore-hidden-threads-configuration (config)
2239 "Restore hidden threads configuration from CONFIG."
2240 (let (point buffer-read-only)
2241 (while (setq point (pop config))
2242 (when (and (< point (point-max))
2244 (= (following-char) ?\n))
2245 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2247 ;; Various summary mode internalish functions.
2249 (defun gnus-mouse-pick-article (e)
2252 (gnus-summary-next-page nil t))
2254 (defun gnus-summary-set-display-table ()
2255 ;; Change the display table. Odd characters have a tendency to mess
2256 ;; up nicely formatted displays - we make all possible glyphs
2257 ;; display only a single character.
2259 ;; We start from the standard display table, if any.
2260 (let ((table (or (copy-sequence standard-display-table)
2261 (make-display-table)))
2263 ;; Nix out all the control chars...
2264 (while (>= (setq i (1- i)) 0)
2265 (aset table i [??]))
2266 ;; ... but not newline and cr, of course. (cr is necessary for the
2267 ;; selective display).
2268 (aset table ?\n nil)
2269 (aset table ?\r nil)
2270 ;; We keep TAB as well.
2271 (aset table ?\t nil)
2272 ;; We nix out any glyphs over 126 that are not set already.
2274 (while (>= (setq i (1- i)) 127)
2275 ;; Only modify if the entry is nil.
2276 (unless (aref table i)
2277 (aset table i [??]))))
2278 (setq buffer-display-table table)))
2280 (defun gnus-summary-setup-buffer (group)
2281 "Initialize summary buffer."
2282 (let ((buffer (concat "*Summary " group "*")))
2283 (if (get-buffer buffer)
2286 (setq gnus-summary-buffer (current-buffer))
2287 (not gnus-newsgroup-prepared))
2288 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2289 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2290 (gnus-summary-mode group)
2292 (gnus-carpal-setup-buffer 'summary))
2293 (unless gnus-single-article-buffer
2294 (make-local-variable 'gnus-article-buffer)
2295 (make-local-variable 'gnus-article-current)
2296 (make-local-variable 'gnus-original-article-buffer))
2297 (setq gnus-newsgroup-name group)
2300 (defun gnus-set-global-variables ()
2301 ;; Set the global equivalents of the summary buffer-local variables
2302 ;; to the latest values they had. These reflect the summary buffer
2303 ;; that was in action when the last article was fetched.
2304 (when (eq major-mode 'gnus-summary-mode)
2305 (setq gnus-summary-buffer (current-buffer))
2306 (let ((name gnus-newsgroup-name)
2307 (marked gnus-newsgroup-marked)
2308 (unread gnus-newsgroup-unreads)
2309 (headers gnus-current-headers)
2310 (data gnus-newsgroup-data)
2311 (summary gnus-summary-buffer)
2312 (article-buffer gnus-article-buffer)
2313 (original gnus-original-article-buffer)
2314 (gac gnus-article-current)
2315 (reffed gnus-reffed-article-number)
2316 (score-file gnus-current-score-file))
2318 (set-buffer gnus-group-buffer)
2319 (setq gnus-newsgroup-name name
2320 gnus-newsgroup-marked marked
2321 gnus-newsgroup-unreads unread
2322 gnus-current-headers headers
2323 gnus-newsgroup-data data
2324 gnus-article-current gac
2325 gnus-summary-buffer summary
2326 gnus-article-buffer article-buffer
2327 gnus-original-article-buffer original
2328 gnus-reffed-article-number reffed
2329 gnus-current-score-file score-file)
2330 ;; The article buffer also has local variables.
2331 (when (gnus-buffer-live-p gnus-article-buffer)
2332 (set-buffer gnus-article-buffer)
2333 (setq gnus-summary-buffer summary))))))
2335 (defun gnus-summary-article-unread-p (article)
2336 "Say whether ARTICLE is unread or not."
2337 (memq article gnus-newsgroup-unreads))
2339 (defun gnus-summary-first-article-p (&optional article)
2340 "Return whether ARTICLE is the first article in the buffer."
2341 (if (not (setq article (or article (gnus-summary-article-number))))
2343 (eq article (caar gnus-newsgroup-data))))
2345 (defun gnus-summary-last-article-p (&optional article)
2346 "Return whether ARTICLE is the last article in the buffer."
2347 (if (not (setq article (or article (gnus-summary-article-number))))
2348 t ; All non-existent numbers are the last article. :-)
2349 (not (cdr (gnus-data-find-list article)))))
2351 (defun gnus-make-thread-indent-array ()
2353 (unless (and gnus-thread-indent-array
2354 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2355 (setq gnus-thread-indent-array (make-vector 201 "")
2356 gnus-thread-indent-array-level gnus-thread-indent-level)
2358 (aset gnus-thread-indent-array n
2359 (make-string (* n gnus-thread-indent-level) ? ))
2362 (defun gnus-update-summary-mark-positions ()
2363 "Compute where the summary marks are to go."
2365 (when (gnus-buffer-exists-p gnus-summary-buffer)
2366 (set-buffer gnus-summary-buffer))
2367 (let ((gnus-replied-mark 129)
2368 (gnus-score-below-mark 130)
2369 (gnus-score-over-mark 130)
2370 (gnus-download-mark 131)
2371 (spec gnus-summary-line-format-spec)
2374 (gnus-set-work-buffer)
2375 (let ((gnus-summary-line-format-spec spec)
2376 (gnus-newsgroup-downloadable '((0 . t))))
2377 (gnus-summary-insert-line
2378 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2379 (goto-char (point-min))
2380 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2382 (goto-char (point-min))
2383 (push (cons 'replied (and (search-forward "\201" nil t)
2386 (goto-char (point-min))
2387 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2389 (goto-char (point-min))
2390 (push (cons 'download
2391 (and (search-forward "\203" nil t) (- (point) 2)))
2393 (setq gnus-summary-mark-positions pos))))
2395 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2396 "Insert a dummy root in the summary buffer."
2398 (gnus-add-text-properties
2399 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2400 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2402 (defun gnus-summary-insert-line (gnus-tmp-header
2403 gnus-tmp-level gnus-tmp-current
2404 gnus-tmp-unread gnus-tmp-replied
2405 gnus-tmp-expirable gnus-tmp-subject-or-nil
2406 &optional gnus-tmp-dummy gnus-tmp-score
2408 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2409 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2410 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2411 (gnus-tmp-score-char
2412 (if (or (null gnus-summary-default-score)
2413 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2414 gnus-summary-zcore-fuzz))
2416 (if (< gnus-tmp-score gnus-summary-default-score)
2417 gnus-score-below-mark gnus-score-over-mark)))
2419 (cond (gnus-tmp-process gnus-process-mark)
2420 ((memq gnus-tmp-current gnus-newsgroup-cached)
2422 (gnus-tmp-replied gnus-replied-mark)
2423 ((memq gnus-tmp-current gnus-newsgroup-saved)
2425 (t gnus-unread-mark)))
2426 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2429 ((string-match "<[^>]+> *$" gnus-tmp-from)
2430 (let ((beg (match-beginning 0)))
2431 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2432 (substring gnus-tmp-from (1+ (match-beginning 0))
2433 (1- (match-end 0))))
2434 (substring gnus-tmp-from 0 beg))))
2435 ((string-match "(.+)" gnus-tmp-from)
2436 (substring gnus-tmp-from
2437 (1+ (match-beginning 0)) (1- (match-end 0))))
2439 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2440 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2441 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2442 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2443 (buffer-read-only nil))
2444 (when (string= gnus-tmp-name "")
2445 (setq gnus-tmp-name gnus-tmp-from))
2446 (unless (numberp gnus-tmp-lines)
2447 (setq gnus-tmp-lines 0))
2448 (gnus-put-text-property
2450 (progn (eval gnus-summary-line-format-spec) (point))
2451 'gnus-number gnus-tmp-number)
2452 (when (gnus-visual-p 'summary-highlight 'highlight)
2454 (gnus-run-hooks 'gnus-summary-update-hook)
2457 (defun gnus-summary-update-line (&optional dont-update)
2458 ;; Update summary line after change.
2459 (when (and gnus-summary-default-score
2460 (not gnus-summary-inhibit-highlight))
2461 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2462 (article (gnus-summary-article-number))
2463 (score (gnus-summary-article-score article)))
2465 (if (and gnus-summary-mark-below
2466 (< (gnus-summary-article-score)
2467 gnus-summary-mark-below))
2468 ;; This article has a low score, so we mark it as read.
2469 (when (memq article gnus-newsgroup-unreads)
2470 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2471 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2472 ;; This article was previously marked as read on account
2473 ;; of a low score, but now it has risen, so we mark it as
2475 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2476 (gnus-summary-update-mark
2477 (if (or (null gnus-summary-default-score)
2478 (<= (abs (- score gnus-summary-default-score))
2479 gnus-summary-zcore-fuzz))
2481 (if (< score gnus-summary-default-score)
2482 gnus-score-below-mark gnus-score-over-mark))
2484 ;; Do visual highlighting.
2485 (when (gnus-visual-p 'summary-highlight 'highlight)
2486 (gnus-run-hooks 'gnus-summary-update-hook)))))
2488 (defvar gnus-tmp-new-adopts nil)
2490 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2491 "Return the number of articles in THREAD.
2492 This may be 0 in some cases -- if none of the articles in
2493 the thread are to be displayed."
2495 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2497 ((not (listp thread))
2499 ((and (consp thread) (cdr thread))
2502 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2505 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2508 (when (and level (zerop level) gnus-tmp-new-adopts)
2511 'gnus-summary-number-of-articles-in-thread
2512 gnus-tmp-new-adopts))))
2514 (if (> number 1) gnus-not-empty-thread-mark
2515 gnus-empty-thread-mark)
2518 (defun gnus-summary-set-local-parameters (group)
2519 "Go through the local params of GROUP and set all variable specs in that list."
2520 (let ((params (gnus-group-find-parameter group))
2523 (setq elem (car params)
2524 params (cdr params))
2525 (and (consp elem) ; Has to be a cons.
2526 (consp (cdr elem)) ; The cdr has to be a list.
2527 (symbolp (car elem)) ; Has to be a symbol in there.
2528 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2529 (ignore-errors ; So we set it.
2530 (make-local-variable (car elem))
2531 (set (car elem) (eval (nth 1 elem))))))))
2533 (defun gnus-summary-read-group (group &optional show-all no-article
2534 kill-buffer no-display backward
2536 "Start reading news in newsgroup GROUP.
2537 If SHOW-ALL is non-nil, already read articles are also listed.
2538 If NO-ARTICLE is non-nil, no article is selected initially.
2539 If NO-DISPLAY, don't generate a summary buffer."
2543 (let ((gnus-auto-select-next nil))
2544 (or (gnus-summary-read-group-1
2545 group show-all no-article
2546 kill-buffer no-display
2549 select-articles nil)))))
2550 (eq gnus-auto-select-next 'quietly))
2551 (set-buffer gnus-group-buffer)
2552 ;; The entry function called above goes to the next
2553 ;; group automatically, so we go two groups back
2554 ;; if we are searching for the previous group.
2556 (gnus-group-prev-unread-group 2))
2557 (if (not (equal group (gnus-group-group-name)))
2558 (setq group (gnus-group-group-name))
2562 (defun gnus-summary-read-group-1 (group show-all no-article
2563 kill-buffer no-display
2564 &optional select-articles)
2565 ;; Killed foreign groups can't be entered.
2566 (when (and (not (gnus-group-native-p group))
2567 (not (gnus-gethash group gnus-newsrc-hashtb)))
2568 (error "Dead non-native groups can't be entered"))
2569 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2570 (let* ((new-group (gnus-summary-setup-buffer group))
2571 (quit-config (gnus-group-quit-config group))
2572 (did-select (and new-group (gnus-select-newsgroup
2573 group show-all select-articles))))
2575 ;; This summary buffer exists already, so we just select it.
2577 (gnus-set-global-variables)
2579 (gnus-kill-or-deaden-summary kill-buffer))
2580 (gnus-configure-windows 'summary 'force)
2581 (gnus-set-mode-line 'summary)
2582 (gnus-summary-position-point)
2585 ;; We couldn't select this group.
2587 (when (and (eq major-mode 'gnus-summary-mode)
2588 (not (equal (current-buffer) kill-buffer)))
2589 (kill-buffer (current-buffer))
2590 (if (not quit-config)
2592 ;; Update the info -- marks might need to be removed,
2594 (gnus-summary-update-info)
2595 (set-buffer gnus-group-buffer)
2596 (gnus-group-jump-to-group group)
2597 (gnus-group-next-unread-group 1))
2598 (gnus-handle-ephemeral-exit quit-config)))
2599 (gnus-message 3 "Can't select group")
2601 ;; The user did a `C-g' while prompting for number of articles,
2602 ;; so we exit this group.
2603 ((eq did-select 'quit)
2604 (and (eq major-mode 'gnus-summary-mode)
2605 (not (equal (current-buffer) kill-buffer))
2606 (kill-buffer (current-buffer)))
2608 (gnus-kill-or-deaden-summary kill-buffer))
2609 (if (not quit-config)
2611 (set-buffer gnus-group-buffer)
2612 (gnus-group-jump-to-group group)
2613 (gnus-group-next-unread-group 1)
2614 (gnus-configure-windows 'group 'force))
2615 (gnus-handle-ephemeral-exit quit-config))
2616 ;; Finally signal the quit.
2618 ;; The group was successfully selected.
2620 (gnus-set-global-variables)
2621 ;; Save the active value in effect when the group was entered.
2622 (setq gnus-newsgroup-active
2624 (gnus-active gnus-newsgroup-name)))
2625 ;; You can change the summary buffer in some way with this hook.
2626 (gnus-run-hooks 'gnus-select-group-hook)
2627 ;; Set any local variables in the group parameters.
2628 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2629 (gnus-update-format-specifications
2630 nil 'summary 'summary-mode 'summary-dummy)
2631 ;; Do score processing.
2632 (when gnus-use-scoring
2633 (gnus-possibly-score-headers))
2634 ;; Check whether to fill in the gaps in the threads.
2635 (when gnus-build-sparse-threads
2636 (gnus-build-sparse-threads))
2637 ;; Find the initial limit.
2638 (if gnus-show-threads
2640 (let ((gnus-newsgroup-dormant nil))
2641 (gnus-summary-initial-limit show-all))
2642 (gnus-summary-initial-limit show-all))
2643 (setq gnus-newsgroup-limit
2645 (lambda (header) (mail-header-number header))
2646 gnus-newsgroup-headers)))
2647 ;; Generate the summary buffer.
2649 (gnus-summary-prepare))
2650 (when gnus-use-trees
2651 (gnus-tree-open group)
2652 (setq gnus-summary-highlight-line-function
2653 'gnus-tree-highlight-article))
2654 ;; If the summary buffer is empty, but there are some low-scored
2655 ;; articles or some excluded dormants, we include these in the
2657 (when (and (zerop (buffer-size))
2659 (cond (gnus-newsgroup-dormant
2660 (gnus-summary-limit-include-dormant))
2661 ((and gnus-newsgroup-scored show-all)
2662 (gnus-summary-limit-include-expunged t))))
2663 ;; Function `gnus-apply-kill-file' must be called in this hook.
2664 (gnus-run-hooks 'gnus-apply-kill-hook)
2665 (if (and (zerop (buffer-size))
2668 ;; This newsgroup is empty.
2669 (gnus-summary-catchup-and-exit nil t)
2670 (gnus-message 6 "No unread news")
2672 (gnus-kill-or-deaden-summary kill-buffer))
2673 ;; Return nil from this function.
2675 ;; Hide conversation thread subtrees. We cannot do this in
2676 ;; gnus-summary-prepare-hook since kill processing may not
2677 ;; work with hidden articles.
2678 (and gnus-show-threads
2679 gnus-thread-hide-subtree
2680 (gnus-summary-hide-all-threads))
2682 (gnus-kill-or-deaden-summary kill-buffer))
2683 ;; Show first unread article if requested.
2684 (if (and (not no-article)
2686 gnus-newsgroup-unreads
2687 gnus-auto-select-first)
2688 (unless (if (eq gnus-auto-select-first 'best)
2689 (gnus-summary-best-unread-article)
2690 (gnus-summary-first-unread-article))
2691 (gnus-configure-windows 'summary))
2692 ;; Don't select any articles, just move point to the first
2693 ;; article in the group.
2694 (goto-char (point-min))
2695 (gnus-summary-position-point)
2696 (gnus-configure-windows 'summary 'force)
2697 (gnus-set-mode-line 'summary))
2698 (when (get-buffer-window gnus-group-buffer t)
2699 ;; Gotta use windows, because recenter does weird stuff if
2700 ;; the current buffer ain't the displayed window.
2701 (let ((owin (selected-window)))
2702 (select-window (get-buffer-window gnus-group-buffer t))
2703 (when (gnus-group-goto-group group)
2705 (select-window owin)))
2706 ;; Mark this buffer as "prepared".
2707 (setq gnus-newsgroup-prepared t)
2708 (gnus-run-hooks 'gnus-summary-prepared-hook)
2711 (defun gnus-summary-prepare ()
2712 "Generate the summary buffer."
2714 (let ((buffer-read-only nil))
2716 (setq gnus-newsgroup-data nil
2717 gnus-newsgroup-data-reverse nil)
2718 (gnus-run-hooks 'gnus-summary-generate-hook)
2719 ;; Generate the buffer, either with threads or without.
2720 (when gnus-newsgroup-headers
2721 (gnus-summary-prepare-threads
2722 (if gnus-show-threads
2723 (gnus-sort-gathered-threads
2724 (funcall gnus-summary-thread-gathering-function
2726 (gnus-cut-threads (gnus-make-threads)))))
2727 ;; Unthreaded display.
2728 (gnus-sort-articles gnus-newsgroup-headers))))
2729 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2730 ;; Call hooks for modifying summary buffer.
2731 (goto-char (point-min))
2732 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2734 (defsubst gnus-general-simplify-subject (subject)
2735 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2738 ;; Truncate the subject.
2739 (gnus-simplify-subject-functions
2740 (gnus-map-function gnus-simplify-subject-functions subject))
2741 ((numberp gnus-summary-gather-subject-limit)
2742 (setq subject (gnus-simplify-subject-re subject))
2743 (if (> (length subject) gnus-summary-gather-subject-limit)
2744 (substring subject 0 gnus-summary-gather-subject-limit)
2746 ;; Fuzzily simplify it.
2747 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2748 (gnus-simplify-subject-fuzzy subject))
2749 ;; Just remove the leading "Re:".
2751 (gnus-simplify-subject-re subject))))
2753 (if (and gnus-summary-gather-exclude-subject
2754 (string-match gnus-summary-gather-exclude-subject subject))
2755 nil ; This article shouldn't be gathered
2758 (defun gnus-summary-simplify-subject-query ()
2759 "Query where the respool algorithm would put this article."
2761 (gnus-summary-select-article)
2762 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2764 (defun gnus-gather-threads-by-subject (threads)
2765 "Gather threads by looking at Subject headers."
2766 (if (not gnus-summary-make-false-root)
2768 (let ((hashtb (gnus-make-hashtable 1024))
2771 subject hthread whole-subject)
2773 (setq subject (gnus-general-simplify-subject
2774 (setq whole-subject (mail-header-subject
2777 (if (setq hthread (gnus-gethash subject hashtb))
2779 ;; We enter a dummy root into the thread, if we
2780 ;; haven't done that already.
2781 (unless (stringp (caar hthread))
2782 (setcar hthread (list whole-subject (car hthread))))
2783 ;; We add this new gathered thread to this gathered
2785 (setcdr (car hthread)
2786 (nconc (cdar hthread) (list (car threads))))
2787 ;; Remove it from the list of threads.
2788 (setcdr prev (cdr threads))
2789 (setq threads prev))
2790 ;; Enter this thread into the hash table.
2791 (gnus-sethash subject threads hashtb)))
2793 (setq threads (cdr threads)))
2796 (defun gnus-gather-threads-by-references (threads)
2797 "Gather threads by looking at References headers."
2798 (let ((idhashtb (gnus-make-hashtable 1024))
2799 (thhashtb (gnus-make-hashtable 1024))
2802 ids references id gthread gid entered ref)
2804 (when (setq references (mail-header-references (caar threads)))
2805 (setq id (mail-header-id (caar threads))
2806 ids (gnus-split-references references)
2808 (while (setq ref (pop ids))
2809 (setq ids (delete ref ids))
2810 (if (not (setq gid (gnus-gethash ref idhashtb)))
2812 (gnus-sethash ref id idhashtb)
2813 (gnus-sethash id threads thhashtb))
2814 (setq gthread (gnus-gethash gid thhashtb))
2816 ;; We enter a dummy root into the thread, if we
2817 ;; haven't done that already.
2818 (unless (stringp (caar gthread))
2819 (setcar gthread (list (mail-header-subject (caar gthread))
2821 ;; We add this new gathered thread to this gathered
2823 (setcdr (car gthread)
2824 (nconc (cdar gthread) (list (car threads)))))
2825 ;; Add it into the thread hash table.
2826 (gnus-sethash id gthread thhashtb)
2828 ;; Remove it from the list of threads.
2829 (setcdr prev (cdr threads))
2830 (setq threads prev))))
2832 (setq threads (cdr threads)))
2835 (defun gnus-sort-gathered-threads (threads)
2836 "Sort subtreads inside each gathered thread by article number."
2837 (let ((result threads))
2839 (when (stringp (caar threads))
2840 (setcdr (car threads)
2841 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2842 (setq threads (cdr threads)))
2845 (defun gnus-thread-loop-p (root thread)
2846 "Say whether ROOT is in THREAD."
2847 (let ((stack (list thread))
2850 (while (setq thread (pop stack))
2851 (setq th (cdr thread))
2853 (not (eq (caar th) root)))
2856 ;; We have found a loop.
2858 (setcdr thread (delq (car th) (cdr thread)))
2859 (if (boundp (setq ref-dep (intern "none"
2860 gnus-newsgroup-dependencies)))
2861 (setcdr (symbol-value ref-dep)
2862 (nconc (cdr (symbol-value ref-dep))
2864 (set ref-dep (list nil (car th))))
2867 ;; Push all the subthreads onto the stack.
2868 (push (cdr thread) stack)))
2871 (defun gnus-make-threads ()
2872 "Go through the dependency hashtb and find the roots. Return all threads."
2874 (while (catch 'infloop
2877 ;; Deal with self-referencing References loops.
2878 (when (and (car (symbol-value refs))
2885 (car (symbol-value refs)) thread))
2886 (cdr (symbol-value refs)))))))
2889 (unless (car (symbol-value refs))
2890 ;; These threads do not refer back to any other articles,
2891 ;; so they're roots.
2892 (setq threads (append (cdr (symbol-value refs)) threads))))
2893 gnus-newsgroup-dependencies)))
2896 ;; Build the thread tree.
2897 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2898 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2900 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2901 if it was already present.
2903 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2904 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2905 Message-IDs will be renamed be renamed to a unique Message-ID before
2908 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2909 (let* ((id (mail-header-id header))
2910 (id-dep (and id (intern id dependencies)))
2911 ref ref-dep ref-header)
2912 ;; Enter this `header' in the `dependencies' table.
2916 ;; The first two cases do the normal part: enter a new `header'
2917 ;; in the `dependencies' table.
2918 ((not (boundp id-dep))
2919 (set id-dep (list header)))
2920 ((null (car (symbol-value id-dep)))
2921 (setcar (symbol-value id-dep) header))
2923 ;; From here the `header' was already present in the
2924 ;; `dependencies' table.
2926 ;; Overrides an existing entry;
2927 ;; just set the header part of the entry.
2928 (setcar (symbol-value id-dep) header))
2930 ;; Renames the existing `header' to a unique Message-ID.
2931 ((not gnus-summary-ignore-duplicates)
2932 ;; An article with this Message-ID has already been seen.
2933 ;; We rename the Message-ID.
2934 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2936 (mail-header-set-id header id))
2938 ;; The last case ignores an existing entry, except it adds any
2939 ;; additional Xrefs (in case the two articles came from different
2941 ;; Also sets `header' to `nil' meaning that the `dependencies'
2942 ;; table was *not* modified.
2944 (mail-header-set-xref
2945 (car (symbol-value id-dep))
2946 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2948 (or (mail-header-xref header) "")))
2952 ;; First check if that we are not creating a References loop.
2953 (setq ref (gnus-parent-id (mail-header-references header)))
2955 (setq ref-dep (intern-soft ref dependencies))
2957 (setq ref-header (car (symbol-value ref-dep))))
2958 (if (string= id ref)
2959 ;; Yuk! This is a reference loop. Make the article be a
2962 (mail-header-set-references (car (symbol-value id-dep)) "none")
2964 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2965 (setq ref (gnus-parent-id (mail-header-references header)))
2966 (setq ref-dep (intern (or ref "none") dependencies))
2967 (if (boundp ref-dep)
2968 (setcdr (symbol-value ref-dep)
2969 (nconc (cdr (symbol-value ref-dep))
2970 (list (symbol-value id-dep))))
2971 (set ref-dep (list nil (symbol-value id-dep)))))
2974 (defun gnus-build-sparse-threads ()
2975 (let ((headers gnus-newsgroup-headers)
2976 (gnus-summary-ignore-duplicates t)
2977 header references generation relations
2978 subject child end new-child date)
2979 ;; First we create an alist of generations/relations, where
2980 ;; generations is how much we trust the relation, and the relation
2982 (gnus-message 7 "Making sparse threads...")
2984 (nnheader-set-temp-buffer " *gnus sparse threads*")
2985 (while (setq header (pop headers))
2986 (when (and (setq references (mail-header-references header))
2987 (not (string= references "")))
2989 (setq child (mail-header-id header)
2990 subject (mail-header-subject header)
2991 date (mail-header-date header)
2993 (while (search-backward ">" nil t)
2994 (setq end (1+ (point)))
2995 (when (search-backward "<" nil t)
2996 (setq new-child (buffer-substring (point) end))
2997 (push (list (incf generation)
2998 child (setq child new-child)
3002 (push (list (1+ generation) child nil subject) relations))
3004 (kill-buffer (current-buffer)))
3005 ;; Sort over trustworthiness.
3008 (when (gnus-dependencies-add-header
3009 (make-full-mail-header
3010 gnus-reffed-article-number
3011 (nth 3 relation) "" (or (nth 4 relation) "")
3013 (or (nth 2 relation) "") 0 0 "")
3014 gnus-newsgroup-dependencies nil)
3015 (push gnus-reffed-article-number gnus-newsgroup-limit)
3016 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3017 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3018 gnus-newsgroup-reads)
3019 (decf gnus-reffed-article-number)))
3020 (sort relations 'car-less-than-car))
3021 (gnus-message 7 "Making sparse threads...done")))
3023 (defun gnus-build-old-threads ()
3024 ;; Look at all the articles that refer back to old articles, and
3025 ;; fetch the headers for the articles that aren't there. This will
3026 ;; build complete threads - if the roots haven't been expired by the
3031 (when (not (car (symbol-value refs)))
3032 (setq heads (cdr (symbol-value refs)))
3034 (if (memq (mail-header-number (caar heads))
3035 gnus-newsgroup-dormant)
3036 (setq heads (cdr heads))
3037 (setq id (symbol-name refs))
3038 (while (and (setq id (gnus-build-get-header id))
3039 (not (car (gnus-id-to-thread id)))))
3040 (setq heads nil)))))
3041 gnus-newsgroup-dependencies)))
3043 ;; The following macros and functions were written by Felix Lee
3044 ;; <flee@cse.psu.edu>.
3046 (defmacro gnus-nov-read-integer ()
3048 (if (= (following-char) ?\t)
3050 (let ((num (ignore-errors (read buffer))))
3051 (if (numberp num) num 0)))
3053 (search-forward "\t" eol 'move))))
3055 (defmacro gnus-nov-skip-field ()
3056 '(search-forward "\t" eol 'move))
3058 (defmacro gnus-nov-field ()
3059 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3061 ;; This function has to be called with point after the article number
3062 ;; on the beginning of the line.
3063 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3064 (let ((eol (gnus-point-at-eol))
3065 (buffer (current-buffer))
3068 ;; overview: [num subject from date id refs chars lines misc]
3071 (narrow-to-region (point) eol)
3076 (make-full-mail-header
3078 (funcall gnus-decode-encoded-word-function
3079 (gnus-nov-field)) ; subject
3080 (funcall gnus-decode-encoded-word-function
3081 (gnus-nov-field)) ; from
3082 (gnus-nov-field) ; date
3083 (or (gnus-nov-field)
3084 (nnheader-generate-fake-message-id)) ; id
3085 (gnus-nov-field) ; refs
3086 (gnus-nov-read-integer) ; chars
3087 (gnus-nov-read-integer) ; lines
3088 (unless (= (following-char) ?\n)
3089 (gnus-nov-field))))) ; misc
3093 (when gnus-alter-header-function
3094 (funcall gnus-alter-header-function header))
3095 (gnus-dependencies-add-header header dependencies force-new)))
3097 (defun gnus-build-get-header (id)
3098 ;; Look through the buffer of NOV lines and find the header to
3099 ;; ID. Enter this line into the dependencies hash table, and return
3100 ;; the id of the parent article (if any).
3101 (let ((deps gnus-newsgroup-dependencies)
3105 (set-buffer nntp-server-buffer)
3106 (let ((case-fold-search nil))
3107 (goto-char (point-min))
3108 (while (and (not found)
3109 (search-forward id nil t))
3111 (setq found (looking-at
3112 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3113 (regexp-quote id))))
3114 (or found (beginning-of-line 2)))
3118 (setq header (gnus-nov-parse-line
3119 (read (current-buffer)) deps))
3120 (gnus-parent-id (mail-header-references header))))))
3122 (let ((number (mail-header-number header)))
3123 (push number gnus-newsgroup-limit)
3124 (push header gnus-newsgroup-headers)
3125 (if (memq number gnus-newsgroup-unselected)
3127 (push number gnus-newsgroup-unreads)
3128 (setq gnus-newsgroup-unselected
3129 (delq number gnus-newsgroup-unselected)))
3130 (push number gnus-newsgroup-ancient)))))))
3132 (defun gnus-build-all-threads ()
3133 "Read all the headers."
3134 (let ((gnus-summary-ignore-duplicates t)
3135 (dependencies gnus-newsgroup-dependencies)
3138 (set-buffer nntp-server-buffer)
3139 (let ((case-fold-search nil))
3140 (goto-char (point-min))
3143 (setq article (read (current-buffer))
3144 header (gnus-nov-parse-line
3145 article dependencies)))
3148 (set-buffer gnus-summary-buffer)
3149 (push header gnus-newsgroup-headers)
3150 (if (memq (setq article (mail-header-number header))
3151 gnus-newsgroup-unselected)
3153 (push article gnus-newsgroup-unreads)
3154 (setq gnus-newsgroup-unselected
3155 (delq article gnus-newsgroup-unselected)))
3156 (push article gnus-newsgroup-ancient)))
3157 (forward-line 1)))))))
3159 (defun gnus-summary-update-article-line (article header)
3160 "Update the line for ARTICLE using HEADERS."
3161 (let* ((id (mail-header-id header))
3162 (thread (gnus-id-to-thread id)))
3164 (error "Article in no thread"))
3165 ;; Update the thread.
3166 (setcar thread header)
3167 (gnus-summary-goto-subject article)
3168 (let* ((datal (gnus-data-find-list article))
3170 (length (when (cdr datal)
3171 (- (gnus-data-pos data)
3172 (gnus-data-pos (cadr datal)))))
3173 (buffer-read-only nil)
3174 (level (gnus-summary-thread-level)))
3176 (gnus-summary-insert-line
3177 header level nil (gnus-article-mark article)
3178 (memq article gnus-newsgroup-replied)
3179 (memq article gnus-newsgroup-expirable)
3180 ;; Only insert the Subject string when it's different
3181 ;; from the previous Subject string.
3182 (if (gnus-subject-equal
3184 (mail-header-subject
3187 (gnus-data-find-list
3189 (gnus-data-list t)))))
3190 ;; Error on the side of excessive subjects.
3192 (mail-header-subject header))
3194 (mail-header-subject header))
3195 nil (cdr (assq article gnus-newsgroup-scored))
3196 (memq article gnus-newsgroup-processable))
3198 (gnus-data-update-list
3199 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3201 (defun gnus-summary-update-article (article &optional iheader)
3202 "Update ARTICLE in the summary buffer."
3203 (set-buffer gnus-summary-buffer)
3204 (let* ((header (gnus-summary-article-header article))
3205 (id (mail-header-id header))
3206 (data (gnus-data-find article))
3207 (thread (gnus-id-to-thread id))
3208 (references (mail-header-references header))
3212 (when (and references
3213 (not (equal "" references)))
3216 (buffer-read-only nil)
3222 (delq thread parent)))
3223 (if (gnus-summary-insert-subject id header)
3224 ;; Set the (possibly) new article number in the data structure.
3225 (gnus-data-set-number data (gnus-id-to-article id))
3229 (defun gnus-rebuild-thread (id &optional line)
3230 "Rebuild the thread containing ID.
3231 If LINE, insert the rebuilt thread starting on line LINE."
3232 (let ((buffer-read-only nil)
3233 old-pos current thread data)
3234 (if (not gnus-show-threads)
3235 (setq thread (list (car (gnus-id-to-thread id))))
3236 ;; Get the thread this article is part of.
3237 (setq thread (gnus-remove-thread id)))
3238 (setq old-pos (gnus-point-at-bol))
3239 (setq current (save-excursion
3240 (and (zerop (forward-line -1))
3241 (gnus-summary-article-number))))
3242 ;; If this is a gathered thread, we have to go some re-gathering.
3243 (when (stringp (car thread))
3244 (let ((subject (car thread))
3246 (setq thread (cdr thread))
3248 (unless (memq (setq thr (gnus-id-to-thread
3250 (mail-header-id (caar thread)))))
3253 (setq thread (cdr thread)))
3254 ;; We now have all (unique) roots.
3255 (if (= (length roots) 1)
3256 ;; All the loose roots are now one solid root.
3257 (setq thread (car roots))
3258 (setq thread (cons subject (gnus-sort-threads roots))))))
3260 ;; We then insert this thread into the summary buffer.
3262 (goto-char (point-min))
3263 (forward-line (1- line)))
3264 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3265 (if gnus-show-threads
3266 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3267 (gnus-summary-prepare-unthreaded thread))
3268 (setq data (nreverse gnus-newsgroup-data))
3269 (setq threads gnus-newsgroup-threads))
3270 ;; We splice the new data into the data structure.
3271 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3272 ;;!!! then we want to insert at the beginning of the buffer.
3273 ;;!!! That happens to be true with Gnus now, but that may
3274 ;;!!! change in the future. Perhaps.
3275 (gnus-data-enter-list
3276 (if line nil current) data (- (point) old-pos))
3277 (setq gnus-newsgroup-threads
3278 (nconc threads gnus-newsgroup-threads))
3279 (gnus-data-compute-positions))))
3281 (defun gnus-number-to-header (number)
3282 "Return the header for article NUMBER."
3283 (let ((headers gnus-newsgroup-headers))
3285 (not (= number (mail-header-number (car headers)))))
3290 (defun gnus-parent-headers (in-headers &optional generation)
3291 "Return the headers of the GENERATIONeth parent of HEADERS."
3293 (setq generation 1))
3295 (headers in-headers)
3298 (not (zerop generation))
3299 (setq references (mail-header-references headers)))
3300 (setq headers (if (and references
3301 (setq parent (gnus-parent-id references)))
3302 (car (gnus-id-to-thread parent))
3305 (and (not (eq headers in-headers))
3308 (defun gnus-id-to-thread (id)
3309 "Return the (sub-)thread where ID appears."
3310 (gnus-gethash id gnus-newsgroup-dependencies))
3312 (defun gnus-id-to-article (id)
3313 "Return the article number of ID."
3314 (let ((thread (gnus-id-to-thread id)))
3317 (mail-header-number (car thread)))))
3319 (defun gnus-id-to-header (id)
3320 "Return the article headers of ID."
3321 (car (gnus-id-to-thread id)))
3323 (defun gnus-article-displayed-root-p (article)
3324 "Say whether ARTICLE is a root(ish) article."
3325 (let ((level (gnus-summary-thread-level article))
3326 (refs (mail-header-references (gnus-summary-article-header article)))
3332 ((null (gnus-parent-id refs)) t)
3334 (null (setq particle (gnus-id-to-article
3335 (gnus-parent-id refs))))
3336 (null (gnus-summary-thread-level particle)))))))
3338 (defun gnus-root-id (id)
3339 "Return the id of the root of the thread where ID appears."
3341 (while (and id (setq prev (car (gnus-id-to-thread id))))
3343 id (gnus-parent-id (mail-header-references prev))))
3346 (defun gnus-articles-in-thread (thread)
3347 "Return the list of articles in THREAD."
3348 (cons (mail-header-number (car thread))
3349 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3351 (defun gnus-remove-thread (id &optional dont-remove)
3352 "Remove the thread that has ID in it."
3353 (let (headers thread last-id)
3354 ;; First go up in this thread until we find the root.
3355 (setq last-id (gnus-root-id id)
3356 headers (message-flatten-list (gnus-id-to-thread last-id)))
3357 ;; We have now found the real root of this thread. It might have
3358 ;; been gathered into some loose thread, so we have to search
3359 ;; through the threads to find the thread we wanted.
3360 (let ((threads gnus-newsgroup-threads)
3363 (setq sub (car threads))
3364 (if (stringp (car sub))
3365 ;; This is a gathered thread, so we look at the roots
3366 ;; below it to find whether this article is in this
3369 (setq sub (cdr sub))
3371 (when (member (caar sub) headers)
3372 (setq thread (car threads)
3375 (setq sub (cdr sub))))
3376 ;; It's an ordinary thread, so we check it.
3377 (when (eq (car sub) (car headers))
3380 (setq threads (cdr threads)))
3381 ;; If this article is in no thread, then it's a root.
3384 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3385 (setq thread (gnus-id-to-thread last-id)))
3388 thread ; We return this thread.
3390 (if (stringp (car thread))
3392 ;; If we use dummy roots, then we have to remove the
3393 ;; dummy root as well.
3394 (when (eq gnus-summary-make-false-root 'dummy)
3395 ;; We go to the dummy root by going to
3396 ;; the first sub-"thread", and then one line up.
3397 (gnus-summary-goto-article
3398 (mail-header-number (caadr thread)))
3401 (gnus-data-compute-positions))
3402 (setq thread (cdr thread))
3404 (gnus-remove-thread-1 (car thread))
3405 (setq thread (cdr thread))))
3406 (gnus-summary-show-all-threads)
3407 (gnus-remove-thread-1 thread))))))))
3409 (defun gnus-remove-thread-1 (thread)
3410 "Remove the thread THREAD recursively."
3411 (let ((number (mail-header-number (pop thread)))
3413 (setq thread (reverse thread))
3415 (gnus-remove-thread-1 (pop thread)))
3416 (when (setq d (gnus-data-find number))
3417 (goto-char (gnus-data-pos d))
3420 (- (gnus-point-at-bol)
3422 (1+ (gnus-point-at-eol))
3423 (gnus-delete-line)))))))
3425 (defun gnus-sort-threads (threads)
3427 (if (not gnus-thread-sort-functions)
3429 (gnus-message 8 "Sorting threads...")
3431 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3432 (gnus-message 8 "Sorting threads...done"))))
3434 (defun gnus-sort-articles (articles)
3436 (when gnus-article-sort-functions
3437 (gnus-message 7 "Sorting articles...")
3439 (setq gnus-newsgroup-headers
3440 (sort articles (gnus-make-sort-function
3441 gnus-article-sort-functions)))
3442 (gnus-message 7 "Sorting articles...done"))))
3444 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3445 (defmacro gnus-thread-header (thread)
3446 ;; Return header of first article in THREAD.
3447 ;; Note that THREAD must never, ever be anything else than a variable -
3448 ;; using some other form will lead to serious barfage.
3449 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3450 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3451 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3454 (defsubst gnus-article-sort-by-number (h1 h2)
3455 "Sort articles by article number."
3456 (< (mail-header-number h1)
3457 (mail-header-number h2)))
3459 (defun gnus-thread-sort-by-number (h1 h2)
3460 "Sort threads by root article number."
3461 (gnus-article-sort-by-number
3462 (gnus-thread-header h1) (gnus-thread-header h2)))
3464 (defsubst gnus-article-sort-by-lines (h1 h2)
3465 "Sort articles by article Lines header."
3466 (< (mail-header-lines h1)
3467 (mail-header-lines h2)))
3469 (defun gnus-thread-sort-by-lines (h1 h2)
3470 "Sort threads by root article Lines header."
3471 (gnus-article-sort-by-lines
3472 (gnus-thread-header h1) (gnus-thread-header h2)))
3474 (defsubst gnus-article-sort-by-author (h1 h2)
3475 "Sort articles by root author."
3477 (let ((extract (funcall
3478 gnus-extract-address-components
3479 (mail-header-from h1))))
3480 (or (car extract) (cadr extract) ""))
3481 (let ((extract (funcall
3482 gnus-extract-address-components
3483 (mail-header-from h2))))
3484 (or (car extract) (cadr extract) ""))))
3486 (defun gnus-thread-sort-by-author (h1 h2)
3487 "Sort threads by root author."
3488 (gnus-article-sort-by-author
3489 (gnus-thread-header h1) (gnus-thread-header h2)))
3491 (defsubst gnus-article-sort-by-subject (h1 h2)
3492 "Sort articles by root subject."
3494 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3495 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3497 (defun gnus-thread-sort-by-subject (h1 h2)
3498 "Sort threads by root subject."
3499 (gnus-article-sort-by-subject
3500 (gnus-thread-header h1) (gnus-thread-header h2)))
3502 (defsubst gnus-article-sort-by-date (h1 h2)
3503 "Sort articles by root article date."
3505 (gnus-date-get-time (mail-header-date h1))
3506 (gnus-date-get-time (mail-header-date h2))))
3508 (defun gnus-thread-sort-by-date (h1 h2)
3509 "Sort threads by root article date."
3510 (gnus-article-sort-by-date
3511 (gnus-thread-header h1) (gnus-thread-header h2)))
3513 (defsubst gnus-article-sort-by-score (h1 h2)
3514 "Sort articles by root article score.
3515 Unscored articles will be counted as having a score of zero."
3516 (> (or (cdr (assq (mail-header-number h1)
3517 gnus-newsgroup-scored))
3518 gnus-summary-default-score 0)
3519 (or (cdr (assq (mail-header-number h2)
3520 gnus-newsgroup-scored))
3521 gnus-summary-default-score 0)))
3523 (defun gnus-thread-sort-by-score (h1 h2)
3524 "Sort threads by root article score."
3525 (gnus-article-sort-by-score
3526 (gnus-thread-header h1) (gnus-thread-header h2)))
3528 (defun gnus-thread-sort-by-total-score (h1 h2)
3529 "Sort threads by the sum of all scores in the thread.
3530 Unscored articles will be counted as having a score of zero."
3531 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3533 (defun gnus-thread-total-score (thread)
3534 ;; This function find the total score of THREAD.
3535 (cond ((null thread)
3538 (if (stringp (car thread))
3539 (apply gnus-thread-score-function 0
3540 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3541 (gnus-thread-total-score-1 thread)))
3543 (gnus-thread-total-score-1 (list thread)))))
3545 (defun gnus-thread-total-score-1 (root)
3546 ;; This function find the total score of the thread below ROOT.
3547 (setq root (car root))
3548 (apply gnus-thread-score-function
3550 (mapcar 'gnus-thread-total-score
3551 (cdr (gnus-id-to-thread (mail-header-id root))))
3552 (when (> (mail-header-number root) 0)
3553 (list (or (cdr (assq (mail-header-number root)
3554 gnus-newsgroup-scored))
3555 gnus-summary-default-score 0))))
3556 (list gnus-summary-default-score)
3559 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3560 (defvar gnus-tmp-prev-subject nil)
3561 (defvar gnus-tmp-false-parent nil)
3562 (defvar gnus-tmp-root-expunged nil)
3563 (defvar gnus-tmp-dummy-line nil)
3565 (defun gnus-summary-prepare-threads (threads)
3566 "Prepare summary buffer from THREADS and indentation LEVEL.
3567 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3568 or a straight list of headers."
3569 (gnus-message 7 "Generating summary...")
3571 (setq gnus-newsgroup-threads threads)
3574 (let ((gnus-tmp-level 0)
3575 (default-score (or gnus-summary-default-score 0))
3576 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3577 thread number subject stack state gnus-tmp-gathered beg-match
3578 new-roots gnus-tmp-new-adopts thread-end
3579 gnus-tmp-header gnus-tmp-unread
3580 gnus-tmp-replied gnus-tmp-subject-or-nil
3581 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3582 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3583 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3585 (setq gnus-tmp-prev-subject nil)
3587 (if (vectorp (car threads))
3588 ;; If this is a straight (sic) list of headers, then a
3589 ;; threaded summary display isn't required, so we just create
3590 ;; an unthreaded one.
3591 (gnus-summary-prepare-unthreaded threads)
3593 ;; Do the threaded display.
3595 (while (or threads stack gnus-tmp-new-adopts new-roots)
3597 (if (and (= gnus-tmp-level 0)
3600 (not gnus-tmp-false-parent)
3601 (or gnus-tmp-new-adopts new-roots))
3602 (if gnus-tmp-new-adopts
3603 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3604 thread (list (car gnus-tmp-new-adopts))
3605 gnus-tmp-header (caar thread)
3606 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3608 (setq thread (list (car new-roots))
3609 gnus-tmp-header (caar thread)
3610 new-roots (cdr new-roots))))
3613 ;; If there are some threads, we do them before the
3614 ;; threads on the stack.
3615 (setq thread threads
3616 gnus-tmp-header (caar thread))
3617 ;; There were no current threads, so we pop something off
3619 (setq state (car stack)
3620 gnus-tmp-level (car state)
3623 gnus-tmp-header (caar thread))))
3625 (setq gnus-tmp-false-parent nil)
3626 (setq gnus-tmp-root-expunged nil)
3627 (setq thread-end nil)
3629 (if (stringp gnus-tmp-header)
3630 ;; The header is a dummy root.
3632 ((eq gnus-summary-make-false-root 'adopt)
3633 ;; We let the first article adopt the rest.
3634 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3636 (setq gnus-tmp-gathered
3638 (lambda (h) (mail-header-number (car h)))
3641 (setq thread (cons (list (caar thread)
3644 (setq gnus-tmp-level -1
3645 gnus-tmp-false-parent t))
3646 ((eq gnus-summary-make-false-root 'empty)
3647 ;; We print adopted articles with empty subject fields.
3648 (setq gnus-tmp-gathered
3650 (lambda (h) (mail-header-number (car h)))
3653 (setq gnus-tmp-level -1))
3654 ((eq gnus-summary-make-false-root 'dummy)
3655 ;; We remember that we probably want to output a dummy
3657 (setq gnus-tmp-dummy-line gnus-tmp-header)
3658 (setq gnus-tmp-prev-subject gnus-tmp-header))
3660 ;; We do not make a root for the gathered
3661 ;; sub-threads at all.
3662 (setq gnus-tmp-level -1)))
3664 (setq number (mail-header-number gnus-tmp-header)
3665 subject (mail-header-subject gnus-tmp-header))
3668 ;; If the thread has changed subject, we might want to make
3669 ;; this subthread into a root.
3670 ((and (null gnus-thread-ignore-subject)
3671 (not (zerop gnus-tmp-level))
3672 gnus-tmp-prev-subject
3674 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3675 (setq new-roots (nconc new-roots (list (car thread)))
3677 gnus-tmp-header nil))
3678 ;; If the article lies outside the current limit,
3679 ;; then we do not display it.
3680 ((not (memq number gnus-newsgroup-limit))
3681 (setq gnus-tmp-gathered
3683 (lambda (h) (mail-header-number (car h)))
3686 (setq gnus-tmp-new-adopts (if (cdar thread)
3687 (append gnus-tmp-new-adopts
3689 gnus-tmp-new-adopts)
3691 gnus-tmp-header nil)
3692 (when (zerop gnus-tmp-level)
3693 (setq gnus-tmp-root-expunged t)))
3694 ;; Perhaps this article is to be marked as read?
3695 ((and gnus-summary-mark-below
3696 (< (or (cdr (assq number gnus-newsgroup-scored))
3698 gnus-summary-mark-below)
3699 ;; Don't touch sparse articles.
3700 (not (gnus-summary-article-sparse-p number))
3701 (not (gnus-summary-article-ancient-p number)))
3702 (setq gnus-newsgroup-unreads
3703 (delq number gnus-newsgroup-unreads))
3704 (if gnus-newsgroup-auto-expire
3705 (push number gnus-newsgroup-expirable)
3706 (push (cons number gnus-low-score-mark)
3707 gnus-newsgroup-reads))))
3709 (when gnus-tmp-header
3710 ;; We may have an old dummy line to output before this
3712 (when (and gnus-tmp-dummy-line
3715 (mail-header-subject gnus-tmp-header)))
3716 (gnus-summary-insert-dummy-line
3717 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3718 (setq gnus-tmp-dummy-line nil))
3720 ;; Compute the mark.
3721 (setq gnus-tmp-unread (gnus-article-mark number))
3723 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3724 gnus-tmp-header gnus-tmp-level)
3725 gnus-newsgroup-data)
3727 ;; Actually insert the line.
3729 gnus-tmp-subject-or-nil
3731 ((and gnus-thread-ignore-subject
3732 gnus-tmp-prev-subject
3733 (not (inline (gnus-subject-equal
3734 gnus-tmp-prev-subject subject))))
3736 ((zerop gnus-tmp-level)
3737 (if (and (eq gnus-summary-make-false-root 'empty)
3738 (memq number gnus-tmp-gathered)
3739 gnus-tmp-prev-subject
3740 (inline (gnus-subject-equal
3741 gnus-tmp-prev-subject subject)))
3742 gnus-summary-same-subject
3744 (t gnus-summary-same-subject)))
3745 (if (and (eq gnus-summary-make-false-root 'adopt)
3746 (= gnus-tmp-level 1)
3747 (memq number gnus-tmp-gathered))
3748 (setq gnus-tmp-opening-bracket ?\<
3749 gnus-tmp-closing-bracket ?\>)
3750 (setq gnus-tmp-opening-bracket ?\[
3751 gnus-tmp-closing-bracket ?\]))
3753 gnus-tmp-indentation
3754 (aref gnus-thread-indent-array gnus-tmp-level)
3755 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3756 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3757 gnus-summary-default-score 0)
3759 (if (or (null gnus-summary-default-score)
3760 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3761 gnus-summary-zcore-fuzz))
3763 (if (< gnus-tmp-score gnus-summary-default-score)
3764 gnus-score-below-mark gnus-score-over-mark))
3766 (cond ((memq number gnus-newsgroup-processable)
3768 ((memq number gnus-newsgroup-cached)
3770 ((memq number gnus-newsgroup-replied)
3772 ((memq number gnus-newsgroup-saved)
3774 (t gnus-unread-mark))
3775 gnus-tmp-from (mail-header-from gnus-tmp-header)
3778 ((string-match "<[^>]+> *$" gnus-tmp-from)
3779 (setq beg-match (match-beginning 0))
3780 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3781 (substring gnus-tmp-from (1+ (match-beginning 0))
3782 (1- (match-end 0))))
3783 (substring gnus-tmp-from 0 beg-match)))
3784 ((string-match "(.+)" gnus-tmp-from)
3785 (substring gnus-tmp-from
3786 (1+ (match-beginning 0)) (1- (match-end 0))))
3788 (when (string= gnus-tmp-name "")
3789 (setq gnus-tmp-name gnus-tmp-from))
3790 (unless (numberp gnus-tmp-lines)
3791 (setq gnus-tmp-lines 0))
3792 (gnus-put-text-property
3794 (progn (eval gnus-summary-line-format-spec) (point))
3795 'gnus-number number)
3798 (gnus-run-hooks 'gnus-summary-update-hook)
3801 (setq gnus-tmp-prev-subject subject)))
3803 (when (nth 1 thread)
3804 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3805 (incf gnus-tmp-level)
3806 (setq threads (if thread-end nil (cdar thread)))
3808 (setq gnus-tmp-level 0)))))
3809 (gnus-message 7 "Generating summary...done"))
3811 (defun gnus-summary-prepare-unthreaded (headers)
3812 "Generate an unthreaded summary buffer based on HEADERS."
3813 (let (header number mark)
3818 ;; We may have to root out some bad articles...
3819 (when (memq (setq number (mail-header-number
3820 (setq header (pop headers))))
3821 gnus-newsgroup-limit)
3822 ;; Mark article as read when it has a low score.
3823 (when (and gnus-summary-mark-below
3824 (< (or (cdr (assq number gnus-newsgroup-scored))
3825 gnus-summary-default-score 0)
3826 gnus-summary-mark-below)
3827 (not (gnus-summary-article-ancient-p number)))
3828 (setq gnus-newsgroup-unreads
3829 (delq number gnus-newsgroup-unreads))
3830 (if gnus-newsgroup-auto-expire
3831 (push number gnus-newsgroup-expirable)
3832 (push (cons number gnus-low-score-mark)
3833 gnus-newsgroup-reads)))
3835 (setq mark (gnus-article-mark number))
3836 (push (gnus-data-make number mark (1+ (point)) header 0)
3837 gnus-newsgroup-data)
3838 (gnus-summary-insert-line
3840 mark (memq number gnus-newsgroup-replied)
3841 (memq number gnus-newsgroup-expirable)
3842 (mail-header-subject header) nil
3843 (cdr (assq number gnus-newsgroup-scored))
3844 (memq number gnus-newsgroup-processable))))))
3846 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3847 "Select newsgroup GROUP.
3848 If READ-ALL is non-nil, all articles in the group are selected.
3849 If SELECT-ARTICLES, only select those articles from GROUP."
3850 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3851 ;;!!! Dirty hack; should be removed.
3852 (gnus-summary-ignore-duplicates
3853 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3855 gnus-summary-ignore-duplicates))
3856 (info (nth 2 entry))
3857 articles fetched-articles cached)
3859 (unless (gnus-check-server
3860 (setq gnus-current-select-method
3861 (gnus-find-method-for-group group)))
3862 (error "Couldn't open server"))
3864 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3865 (gnus-activate-group group) ; Or we can activate it...
3866 (progn ; Or we bug out.
3867 (when (equal major-mode 'gnus-summary-mode)
3868 (kill-buffer (current-buffer)))
3869 (error "Couldn't request group %s: %s"
3870 group (gnus-status-message group))))
3872 (unless (gnus-request-group group t)
3873 (when (equal major-mode 'gnus-summary-mode)
3874 (kill-buffer (current-buffer)))
3875 (error "Couldn't request group %s: %s"
3876 group (gnus-status-message group)))
3878 (setq gnus-newsgroup-name group)
3879 (setq gnus-newsgroup-unselected nil)
3880 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3882 ;; Adjust and set lists of article marks.
3884 (gnus-adjust-marked-articles info))
3886 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3887 (when (gnus-virtual-group-p group)
3888 (setq cached gnus-newsgroup-cached))
3890 (setq gnus-newsgroup-unreads
3891 (gnus-set-difference
3892 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3893 gnus-newsgroup-dormant))
3895 (setq gnus-newsgroup-processable nil)
3897 (gnus-update-read-articles group gnus-newsgroup-unreads)
3899 (if (setq articles select-articles)
3900 (setq gnus-newsgroup-unselected
3901 (gnus-sorted-intersection
3902 gnus-newsgroup-unreads
3903 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3904 (setq articles (gnus-articles-to-read group read-all)))
3908 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3910 ((eq articles 0) nil)
3912 ;; Init the dependencies hash table.
3913 (setq gnus-newsgroup-dependencies
3914 (gnus-make-hashtable (length articles)))
3915 (gnus-set-global-variables)
3916 ;; Retrieve the headers and read them in.
3917 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3918 (setq gnus-newsgroup-headers
3920 (setq gnus-headers-retrieved-by
3921 (gnus-retrieve-headers
3922 articles gnus-newsgroup-name
3923 ;; We might want to fetch old headers, but
3924 ;; not if there is only 1 article.
3926 (not (eq gnus-fetch-old-headers 'some))
3927 (not (numberp gnus-fetch-old-headers)))
3928 (> (length articles) 1))
3929 gnus-fetch-old-headers))))
3930 (gnus-get-newsgroup-headers-xover
3931 articles nil nil gnus-newsgroup-name t)
3932 (gnus-get-newsgroup-headers)))
3933 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3935 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3937 (setq gnus-newsgroup-cached cached))
3939 ;; Suppress duplicates?
3940 (when gnus-suppress-duplicates
3941 (gnus-dup-suppress-articles))
3943 ;; Set the initial limit.
3944 (setq gnus-newsgroup-limit (copy-sequence articles))
3945 ;; Remove canceled articles from the list of unread articles.
3946 (setq gnus-newsgroup-unreads
3947 (gnus-set-sorted-intersection
3948 gnus-newsgroup-unreads
3949 (setq fetched-articles
3950 (mapcar (lambda (headers) (mail-header-number headers))
3951 gnus-newsgroup-headers))))
3952 ;; Removed marked articles that do not exist.
3953 (gnus-update-missing-marks
3954 (gnus-sorted-complement fetched-articles articles))
3955 ;; We might want to build some more threads first.
3956 (when (and gnus-fetch-old-headers
3957 (eq gnus-headers-retrieved-by 'nov))
3958 (if (eq gnus-fetch-old-headers 'invisible)
3959 (gnus-build-all-threads)
3960 (gnus-build-old-threads)))
3961 ;; Let the Gnus agent mark articles as read.
3963 (gnus-agent-get-undownloaded-list))
3964 ;; Check whether auto-expire is to be done in this group.
3965 (setq gnus-newsgroup-auto-expire
3966 (gnus-group-auto-expirable-p group))
3967 ;; Set up the article buffer now, if necessary.
3968 (unless gnus-single-article-buffer
3969 (gnus-article-setup-buffer))
3970 ;; First and last article in this newsgroup.
3971 (when gnus-newsgroup-headers
3972 (setq gnus-newsgroup-begin
3973 (mail-header-number (car gnus-newsgroup-headers))
3976 (gnus-last-element gnus-newsgroup-headers))))
3977 ;; GROUP is successfully selected.
3978 (or gnus-newsgroup-headers t)))))
3980 (defun gnus-articles-to-read (group &optional read-all)
3981 ;; Find out what articles the user wants to read.
3983 ;; Select all articles if `read-all' is non-nil, or if there
3984 ;; are no unread articles.
3986 (and (zerop (length gnus-newsgroup-marked))
3987 (zerop (length gnus-newsgroup-unreads)))
3988 (eq (gnus-group-find-parameter group 'display)
3990 (gnus-uncompress-range (gnus-active group))
3991 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3992 (copy-sequence gnus-newsgroup-unreads))
3994 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3995 (scored (length scored-list))
3996 (number (length articles))
3997 (marked (+ (length gnus-newsgroup-marked)
3998 (length gnus-newsgroup-dormant)))
4006 ((and (or (<= scored marked) (= scored number))
4007 (numberp gnus-large-newsgroup)
4008 (> number gnus-large-newsgroup))
4012 "How many articles from %s (default %d): "
4013 (gnus-limit-string gnus-newsgroup-name 35)
4015 (if (string-match "^[ \t]*$" input) number input)))
4016 ((and (> scored marked) (< scored number)
4017 (> (- scored number) 20))
4020 (format "%s %s (%d scored, %d total): "
4021 "How many articles from"
4022 group scored number))))
4023 (if (string-match "^[ \t]*$" input)
4027 (setq select (if (stringp select) (string-to-number select) select))
4028 (if (or (null select) (zerop select))
4030 (if (and (not (zerop scored)) (<= (abs select) scored))
4032 (setq articles (sort scored-list '<))
4033 (setq number (length articles)))
4034 (setq articles (copy-sequence articles)))
4036 (when (< (abs select) number)
4038 ;; Select the N oldest articles.
4039 (setcdr (nthcdr (1- (abs select)) articles) nil)
4040 ;; Select the N most recent articles.
4041 (setq articles (nthcdr (- number select) articles))))
4042 (setq gnus-newsgroup-unselected
4043 (gnus-sorted-intersection
4044 gnus-newsgroup-unreads
4045 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4048 (defun gnus-killed-articles (killed articles)
4051 (when (inline (gnus-member-of-range (car articles) killed))
4052 (push (car articles) out))
4053 (setq articles (cdr articles)))
4056 (defun gnus-uncompress-marks (marks)
4057 "Uncompress the mark ranges in MARKS."
4058 (let ((uncompressed '(score bookmark))
4061 (if (memq (caar marks) uncompressed)
4062 (push (car marks) out)
4063 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4064 (setq marks (cdr marks)))
4067 (defun gnus-adjust-marked-articles (info)
4068 "Set all article lists and remove all marks that are no longer legal."
4069 (let* ((marked-lists (gnus-info-marks info))
4070 (active (gnus-active (gnus-info-group info)))
4073 (types gnus-article-mark-lists)
4074 (uncompressed '(score bookmark killed))
4075 marks var articles article mark)
4078 (setq marks (pop marked-lists))
4079 (set (setq var (intern (format "gnus-newsgroup-%s"
4080 (car (rassq (setq mark (car marks))
4082 (if (memq (car marks) uncompressed) (cdr marks)
4083 (gnus-uncompress-range (cdr marks))))
4085 (setq articles (symbol-value var))
4087 ;; All articles have to be subsets of the active articles.
4089 ;; Adjust "simple" lists.
4090 ((memq mark '(tick dormant expire reply save))
4092 (when (or (< (setq article (pop articles)) min) (> article max))
4093 (set var (delq article (symbol-value var))))))
4095 ((memq mark uncompressed)
4096 (when (not (listp (cdr (symbol-value var))))
4097 (set var (list (symbol-value var))))
4098 (when (not (listp (cdr articles)))
4099 (setq articles (list articles)))
4101 (when (or (not (consp (setq article (pop articles))))
4102 (< (car article) min)
4103 (> (car article) max))
4104 (set var (delq article (symbol-value var))))))))))
4106 (defun gnus-update-missing-marks (missing)
4107 "Go through the list of MISSING articles and remove them from the mark lists."
4109 (let ((types gnus-article-mark-lists)
4111 ;; Go through all types.
4113 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4114 (when (symbol-value var)
4115 ;; This list has articles. So we delete all missing articles
4119 (set var (delq (pop m) (symbol-value var)))))))))
4121 (defun gnus-update-marks ()
4122 "Enter the various lists of marked articles into the newsgroup info list."
4123 (let ((types gnus-article-mark-lists)
4124 (info (gnus-get-info gnus-newsgroup-name))
4125 (uncompressed '(score bookmark killed))
4126 type list newmarked symbol)
4128 ;; Add all marks lists that are non-nil to the list of marks lists.
4129 (while (setq type (pop types))
4130 (when (setq list (symbol-value
4132 (intern (format "gnus-newsgroup-%s"
4135 ;; Get rid of the entries of the articles that have the
4137 (when (and (eq (cdr type) 'score)
4141 (prev (cons nil list))
4144 (if (or (not (consp (car arts)))
4145 (= (cdar arts) gnus-summary-default-score))
4146 (setcdr prev (cdr arts))
4148 (setq arts (cdr arts)))
4149 (setq list (cdr all))))
4151 (push (cons (cdr type)
4152 (if (memq (cdr type) uncompressed) list
4153 (gnus-compress-sequence
4154 (set symbol (sort list '<)) t)))
4157 ;; Enter these new marks into the info of the group.
4159 (setcar (nthcdr 3 info) newmarked)
4160 ;; Add the marks lists to the end of the info.
4162 (setcdr (nthcdr 2 info) (list newmarked))))
4164 ;; Cut off the end of the info if there's nothing else there.
4168 (when (nthcdr (decf i) info)
4169 (setcdr (nthcdr i info) nil)))))))
4171 (defun gnus-set-mode-line (where)
4172 "This function sets the mode line of the article or summary buffers.
4173 If WHERE is `summary', the summary mode line format will be used."
4174 ;; Is this mode line one we keep updated?
4175 (when (memq where gnus-updated-mode-lines)
4178 ;; We evaluate this in the summary buffer since these
4179 ;; variables are buffer-local to that buffer.
4180 (set-buffer gnus-summary-buffer)
4181 ;; We bind all these variables that are used in the `eval' form
4183 (let* ((mformat (symbol-value
4185 (format "gnus-%s-mode-line-format-spec" where))))
4186 (gnus-tmp-group-name gnus-newsgroup-name)
4187 (gnus-tmp-article-number (or gnus-current-article 0))
4188 (gnus-tmp-unread gnus-newsgroup-unreads)
4189 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4190 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4191 (gnus-tmp-unread-and-unselected
4192 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4193 (zerop gnus-tmp-unselected))
4195 ((zerop gnus-tmp-unselected)
4196 (format "{%d more}" gnus-tmp-unread-and-unticked))
4197 (t (format "{%d(+%d) more}"
4198 gnus-tmp-unread-and-unticked
4199 gnus-tmp-unselected))))
4201 (if (and gnus-current-headers
4202 (vectorp gnus-current-headers))
4203 (gnus-mode-string-quote
4204 (mail-header-subject gnus-current-headers))
4206 bufname-length max-len
4207 gnus-tmp-header);; passed as argument to any user-format-funcs
4208 (setq mode-string (eval mformat))
4209 (setq bufname-length (if (string-match "%b" mode-string)
4212 (if (eq where 'summary)
4214 (get-buffer gnus-article-buffer))))
4217 (setq max-len (max 4 (if gnus-mode-non-string-length
4219 gnus-mode-non-string-length
4221 (length mode-string))))
4222 ;; We might have to chop a bit of the string off...
4223 (when (> (length mode-string) max-len)
4225 (concat (truncate-string mode-string (- max-len 3))
4227 ;; Pad the mode string a bit.
4228 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4229 ;; Update the mode line.
4230 (setq mode-line-buffer-identification
4231 (gnus-mode-line-buffer-identification (list mode-string)))
4232 (set-buffer-modified-p t))))
4234 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4235 "Go through the HEADERS list and add all Xrefs to a hash table.
4236 The resulting hash table is returned, or nil if no Xrefs were found."
4237 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4238 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4239 (xref-hashtb (gnus-make-hashtable))
4240 start group entry number xrefs header)
4242 (setq header (pop headers))
4243 (when (and (setq xrefs (mail-header-xref header))
4244 (not (memq (setq number (mail-header-number header))
4247 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4248 (setq start (match-end 0))
4249 (setq group (if prefix
4250 (concat prefix (substring xrefs (match-beginning 1)
4252 (substring xrefs (match-beginning 1) (match-end 1))))
4254 (string-to-int (substring xrefs (match-beginning 2)
4256 (if (setq entry (gnus-gethash group xref-hashtb))
4257 (setcdr entry (cons number (cdr entry)))
4258 (gnus-sethash group (cons number nil) xref-hashtb)))))
4259 (and start xref-hashtb)))
4261 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4262 "Look through all the headers and mark the Xrefs as read."
4263 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4264 name entry info xref-hashtb idlist method nth4)
4266 (set-buffer gnus-group-buffer)
4267 (when (setq xref-hashtb
4268 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4271 (unless (string= from-newsgroup (setq name (symbol-name group)))
4272 (setq idlist (symbol-value group))
4273 ;; Dead groups are not updated.
4275 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4277 (when (stringp (setq nth4 (gnus-info-method info)))
4278 (setq nth4 (gnus-server-to-method nth4))))
4279 ;; Only do the xrefs if the group has the same
4280 ;; select method as the group we have just read.
4281 (or (gnus-methods-equal-p
4282 nth4 (gnus-find-method-for-group from-newsgroup))
4284 (equal nth4 (setq method (gnus-find-method-for-group
4286 (and (equal (car nth4) (car method))
4287 (equal (nth 1 nth4) (nth 1 method))))
4288 gnus-use-cross-reference
4289 (or (not (eq gnus-use-cross-reference t))
4291 ;; Only do cross-references on subscribed
4292 ;; groups, if that is what is wanted.
4293 (<= (gnus-info-level info) gnus-level-subscribed))
4294 (gnus-group-make-articles-read name idlist))))
4297 (defun gnus-compute-read-articles (group articles)
4298 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4299 (info (nth 2 entry))
4300 (active (gnus-active group))
4303 ;; First peel off all illegal article numbers.
4305 (let ((ids articles)
4307 (while (setq id (pop ids))
4308 (when (and first (> id (cdr active)))
4309 ;; We'll end up in this situation in one particular
4310 ;; obscure situation. If you re-scan a group and get
4311 ;; a new article that is cross-posted to a different
4312 ;; group that has not been re-scanned, you might get
4313 ;; crossposted article that has a higher number than
4314 ;; Gnus believes possible. So we re-activate this
4315 ;; group as well. This might mean doing the
4316 ;; crossposting thingy will *increase* the number
4317 ;; of articles in some groups. Tsk, tsk.
4318 (setq active (or (gnus-activate-group group) active)))
4319 (when (or (> id (cdr active))
4320 (< id (car active)))
4321 (setq articles (delq id articles))))))
4322 ;; If the read list is nil, we init it.
4324 (null (gnus-info-read info))
4326 (setq ninfo (cons 1 (1- (car active))))
4327 (setq ninfo (gnus-info-read info)))
4328 ;; Then we add the read articles to the range.
4330 ninfo (setq articles (sort articles '<))))))
4332 (defun gnus-group-make-articles-read (group articles)
4333 "Update the info of GROUP to say that ARTICLES are read."
4335 (entry (gnus-gethash group gnus-newsrc-hashtb))
4336 (info (nth 2 entry))
4337 (active (gnus-active group))
4340 (setq range (gnus-compute-read-articles group articles))
4342 (set-buffer gnus-group-buffer)
4345 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4346 (gnus-info-set-read ',info ',(gnus-info-read info))
4347 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4348 (gnus-group-update-group ,group t))))
4349 ;; Add the read articles to the range.
4350 (gnus-info-set-read info range)
4351 ;; Then we have to re-compute how many unread
4352 ;; articles there are in this group.
4356 (setq num (- (1+ (cdr active)) (car active))))
4357 ((not (listp (cdr range)))
4358 (setq num (- (cdr active) (- (1+ (cdr range))
4362 (if (numberp (car range))
4364 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4365 (setq range (cdr range)))
4366 (setq num (- (cdr active) num))))
4367 ;; Update the number of unread articles.
4369 ;; Update the group buffer.
4370 (gnus-group-update-group group t)))))
4372 (defun gnus-methods-equal-p (m1 m2)
4373 (let ((m1 (or m1 gnus-select-method))
4374 (m2 (or m2 gnus-select-method)))
4376 (and (eq (car m1) (car m2))
4377 (or (not (memq 'address (assoc (symbol-name (car m1))
4378 gnus-valid-select-methods)))
4379 (equal (nth 1 m1) (nth 1 m2)))))))
4381 (defvar gnus-newsgroup-none-id 0)
4383 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4384 (let ((cur nntp-server-buffer)
4387 (save-excursion (set-buffer gnus-summary-buffer)
4388 gnus-newsgroup-dependencies)))
4391 (set-buffer nntp-server-buffer)
4392 ;; Translate all TAB characters into SPACE characters.
4393 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4394 (gnus-run-hooks 'gnus-parse-headers-hook)
4395 (let ((case-fold-search t)
4396 in-reply-to header p lines chars)
4397 (goto-char (point-min))
4398 ;; Search to the beginning of the next header. Error messages
4399 ;; do not begin with 2 or 3.
4400 (while (re-search-forward "^[23][0-9]+ " nil t)
4403 ;; This implementation of this function, with nine
4404 ;; search-forwards instead of the one re-search-forward and
4405 ;; a case (which basically was the old function) is actually
4406 ;; about twice as fast, even though it looks messier. You
4407 ;; can't have everything, I guess. Speed and elegance
4408 ;; doesn't always go hand in hand.
4417 (narrow-to-region (point)
4418 (or (and (search-forward "\n.\n" nil t)
4424 (if (search-forward "\nsubject: " nil t)
4425 (funcall gnus-decode-encoded-word-function
4426 (nnheader-header-value))
4431 (if (search-forward "\nfrom: " nil t)
4432 (funcall gnus-decode-encoded-word-function
4433 (nnheader-header-value))
4438 (if (search-forward "\ndate: " nil t)
4439 (nnheader-header-value) ""))
4443 (setq id (if (re-search-forward
4444 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4445 ;; We do it this way to make sure the Message-ID
4446 ;; is (somewhat) syntactically valid.
4447 (buffer-substring (match-beginning 1)
4449 ;; If there was no message-id, we just fake one
4450 ;; to make subsequent routines simpler.
4451 (nnheader-generate-fake-message-id))))
4455 (if (search-forward "\nreferences: " nil t)
4459 (nnheader-header-value)
4464 (search-backward ">" end t)
4467 (search-backward "<" end t)
4469 ;; Get the references from the in-reply-to header if there
4470 ;; were no references and the in-reply-to header looks
4472 (if (and (search-forward "\nin-reply-to: " nil t)
4473 (setq in-reply-to (nnheader-header-value))
4474 (string-match "<[^>]+>" in-reply-to))
4476 (setq ref (substring in-reply-to (match-beginning 0)
4478 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4479 (setq ref2 (substring in-reply-to (match-beginning 0)
4481 (when (> (length ref2) (length ref))
4488 (if (search-forward "\nchars: " nil t)
4489 (if (numberp (setq chars (ignore-errors (read cur))))
4495 (if (search-forward "\nlines: " nil t)
4496 (if (numberp (setq lines (ignore-errors (read cur))))
4502 (and (search-forward "\nxref: " nil t)
4503 (nnheader-header-value)))))
4504 (when (equal id ref)
4507 (when gnus-alter-header-function
4508 (funcall gnus-alter-header-function header)
4509 (setq id (mail-header-id header)
4510 ref (gnus-parent-id (mail-header-references header))))
4513 (gnus-dependencies-add-header
4514 header dependencies force-new))
4515 (push header headers))
4516 (goto-char (point-max))
4518 (nreverse headers)))))
4520 ;; Goes through the xover lines and returns a list of vectors
4521 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4522 force-new dependencies
4523 group also-fetch-heads)
4524 "Parse the news overview data in the server buffer, and return a
4525 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4526 ;; Get the Xref when the users reads the articles since most/some
4527 ;; NNTP servers do not include Xrefs when using XOVER.
4528 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4529 (let ((cur nntp-server-buffer)
4530 (dependencies (or dependencies gnus-newsgroup-dependencies))
4531 number headers header)
4533 (set-buffer nntp-server-buffer)
4534 ;; Allow the user to mangle the headers before parsing them.
4535 (gnus-run-hooks 'gnus-parse-headers-hook)
4536 (goto-char (point-min))
4539 (while (and sequence (not (eobp)))
4540 (setq number (read cur))
4541 (while (and sequence
4542 (< (car sequence) number))
4543 (setq sequence (cdr sequence)))
4545 (eq number (car sequence))
4547 (setq sequence (cdr sequence))
4548 (setq header (inline
4549 (gnus-nov-parse-line
4550 number dependencies force-new))))
4551 (push header headers))
4554 (gnus-error 4 "Strange nov line (%d)"
4555 (count-lines (point-min) (point)))))
4557 ;; A common bug in inn is that if you have posted an article and
4558 ;; then retrieves the active file, it will answer correctly --
4559 ;; the new article is included. However, a NOV entry for the
4560 ;; article may not have been generated yet, so this may fail.
4561 ;; We work around this problem by retrieving the last few
4562 ;; headers using HEAD.
4563 (if (or (not also-fetch-heads)
4565 ;; We (probably) got all the headers.
4567 (let ((gnus-nov-is-evil t))
4570 (when (gnus-retrieve-headers sequence group)
4571 (gnus-get-newsgroup-headers))))))))
4573 (defun gnus-article-get-xrefs ()
4574 "Fill in the Xref value in `gnus-current-headers', if necessary.
4575 This is meant to be called in `gnus-article-internal-prepare-hook'."
4576 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4577 gnus-current-headers)))
4578 (or (not gnus-use-cross-reference)
4580 (and (mail-header-xref headers)
4581 (not (string= (mail-header-xref headers) "")))
4582 (let ((case-fold-search t)
4585 (nnheader-narrow-to-headers)
4586 (goto-char (point-min))
4587 (when (or (and (eq (downcase (following-char)) ?x)
4588 (looking-at "Xref:"))
4589 (search-forward "\nXref:" nil t))
4590 (goto-char (1+ (match-end 0)))
4591 (setq xref (buffer-substring (point)
4592 (progn (end-of-line) (point))))
4593 (mail-header-set-xref headers xref)))))))
4595 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4596 "Find article ID and insert the summary line for that article.
4597 OLD-HEADER can either be a header or a line number to insert
4598 the subject line on."
4599 (let* ((line (and (numberp old-header) old-header))
4600 (old-header (and (vectorp old-header) old-header))
4601 (header (cond ((and old-header use-old-header)
4604 (gnus-number-to-header id))
4605 (gnus-number-to-header id))
4607 (gnus-read-header id))))
4608 (number (and (numberp id) id))
4611 ;; Rebuild the thread that this article is part of and go to the
4612 ;; article we have fetched.
4613 (when (and (not gnus-show-threads)
4616 (setq d (gnus-data-find (mail-header-number old-header))))
4617 (goto-char (gnus-data-pos d))
4620 (- (gnus-point-at-bol)
4622 (1+ (gnus-point-at-eol))
4623 (gnus-delete-line))))))
4625 (mail-header-set-number header (mail-header-number old-header)))
4626 (setq gnus-newsgroup-sparse
4627 (delq (setq number (mail-header-number header))
4628 gnus-newsgroup-sparse))
4629 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4630 (push number gnus-newsgroup-limit)
4631 (gnus-rebuild-thread (mail-header-id header) line)
4632 (gnus-summary-goto-subject number nil t))
4633 (when (and (numberp number)
4635 ;; We have to update the boundaries even if we can't fetch the
4636 ;; article if ID is a number -- so that the next `P' or `N'
4637 ;; command will fetch the previous (or next) article even
4638 ;; if the one we tried to fetch this time has been canceled.
4639 (when (> number gnus-newsgroup-end)
4640 (setq gnus-newsgroup-end number))
4641 (when (< number gnus-newsgroup-begin)
4642 (setq gnus-newsgroup-begin number))
4643 (setq gnus-newsgroup-unselected
4644 (delq number gnus-newsgroup-unselected)))
4645 ;; Report back a success?
4646 (and header (mail-header-number header))))
4648 ;;; Process/prefix in the summary buffer
4650 (defun gnus-summary-work-articles (n)
4651 "Return a list of articles to be worked upon.
4652 The prefix argument, the list of process marked articles, and the
4653 current article will be taken into consideration."
4655 (set-buffer gnus-summary-buffer)
4658 ;; A numerical prefix has been given.
4659 (setq n (prefix-numeric-value n))
4660 (let ((backward (< n 0))
4661 (n (abs (prefix-numeric-value n)))
4666 (push (setq article (gnus-summary-article-number))
4669 (gnus-summary-find-prev nil article)
4670 (gnus-summary-find-next nil article)))
4672 (nreverse articles)))
4673 ((and (gnus-region-active-p) (mark))
4674 (message "region active")
4675 ;; Work on the region between point and mark.
4676 (let ((max (max (point) (mark)))
4679 (goto-char (min (min (point) (mark))))
4682 (push (setq article (gnus-summary-article-number)) articles)
4683 (gnus-summary-find-next nil article)
4685 (nreverse articles))))
4686 (gnus-newsgroup-processable
4687 ;; There are process-marked articles present.
4688 ;; Save current state.
4689 (gnus-summary-save-process-mark)
4691 (reverse gnus-newsgroup-processable))
4693 ;; Just return the current article.
4694 (list (gnus-summary-article-number))))))
4696 (defmacro gnus-summary-iterate (arg &rest forms)
4697 "Iterate over the process/prefixed articles and do FORMS.
4698 ARG is the interactive prefix given to the command. FORMS will be
4699 executed with point over the summary line of the articles."
4700 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4701 `(let ((,articles (gnus-summary-work-articles ,arg)))
4703 (gnus-summary-goto-subject (car ,articles))
4706 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4707 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4709 (defun gnus-summary-save-process-mark ()
4710 "Push the current set of process marked articles on the stack."
4712 (push (copy-sequence gnus-newsgroup-processable)
4713 gnus-newsgroup-process-stack))
4715 (defun gnus-summary-kill-process-mark ()
4716 "Push the current set of process marked articles on the stack and unmark."
4718 (gnus-summary-save-process-mark)
4719 (gnus-summary-unmark-all-processable))
4721 (defun gnus-summary-yank-process-mark ()
4722 "Pop the last process mark state off the stack and restore it."
4724 (unless gnus-newsgroup-process-stack
4725 (error "Empty mark stack"))
4726 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4728 (defun gnus-summary-process-mark-set (set)
4729 "Make SET into the current process marked articles."
4730 (gnus-summary-unmark-all-processable)
4732 (gnus-summary-set-process-mark (pop set))))
4734 ;;; Searching and stuff
4736 (defun gnus-summary-search-group (&optional backward use-level)
4737 "Search for next unread newsgroup.
4738 If optional argument BACKWARD is non-nil, search backward instead."
4740 (set-buffer gnus-group-buffer)
4741 (when (gnus-group-search-forward
4742 backward nil (if use-level (gnus-group-group-level) nil))
4743 (gnus-group-group-name))))
4745 (defun gnus-summary-best-group (&optional exclude-group)
4746 "Find the name of the best unread group.
4747 If EXCLUDE-GROUP, do not go to this group."
4749 (set-buffer gnus-group-buffer)
4751 (gnus-group-best-unread-group exclude-group))))
4753 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4754 (if backward (gnus-summary-find-prev)
4755 (let* ((dummy (gnus-summary-article-intangible-p))
4756 (article (or article (gnus-summary-article-number)))
4757 (arts (gnus-data-find-list article))
4759 (when (and (not dummy)
4760 (or (not gnus-summary-check-current)
4762 (not (gnus-data-unread-p (car arts)))))
4763 (setq arts (cdr arts)))
4768 (when (or (and undownloaded
4769 (eq gnus-undownloaded-mark
4770 (gnus-data-mark (car arts))))
4771 (gnus-data-unread-p (car arts)))
4772 (setq result (car arts)
4774 (setq arts (cdr arts)))
4777 (goto-char (gnus-data-pos result))
4778 (gnus-data-number result)))))
4780 (defun gnus-summary-find-prev (&optional unread article)
4781 (let* ((eobp (eobp))
4782 (article (or article (gnus-summary-article-number)))
4783 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4785 (when (and (not eobp)
4786 (or (not gnus-summary-check-current)
4788 (not (gnus-data-unread-p (car arts)))))
4789 (setq arts (cdr arts)))
4794 (when (gnus-data-unread-p (car arts))
4795 (setq result (car arts)
4797 (setq arts (cdr arts)))
4800 (goto-char (gnus-data-pos result))
4801 (gnus-data-number result))))
4803 (defun gnus-summary-find-subject (subject &optional unread backward article)
4804 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4805 (article (or article (gnus-summary-article-number)))
4806 (articles (gnus-data-list backward))
4807 (arts (gnus-data-find-list article articles))
4809 (when (or (not gnus-summary-check-current)
4811 (not (gnus-data-unread-p (car arts))))
4812 (setq arts (cdr arts)))
4814 (and (or (not unread)
4815 (gnus-data-unread-p (car arts)))
4816 (vectorp (gnus-data-header (car arts)))
4818 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4819 (setq result (car arts)
4821 (setq arts (cdr arts)))
4823 (goto-char (gnus-data-pos result))
4824 (gnus-data-number result))))
4826 (defun gnus-summary-search-forward (&optional unread subject backward)
4827 "Search forward for an article.
4828 If UNREAD, look for unread articles. If SUBJECT, look for
4829 articles with that subject. If BACKWARD, search backward instead."
4830 (cond (subject (gnus-summary-find-subject subject unread backward))
4831 (backward (gnus-summary-find-prev unread))
4832 (t (gnus-summary-find-next unread))))
4834 (defun gnus-recenter (&optional n)
4835 "Center point in window and redisplay frame.
4836 Also do horizontal recentering."
4838 (when (and gnus-auto-center-summary
4839 (not (eq gnus-auto-center-summary 'vertical)))
4840 (gnus-horizontal-recenter))
4843 (defun gnus-summary-recenter ()
4844 "Center point in the summary window.
4845 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4846 displayed, no centering will be performed."
4847 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4848 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4849 (let* ((top (cond ((< (window-height) 4) 0)
4850 ((< (window-height) 7) 1)
4852 (height (1- (window-height)))
4853 (bottom (save-excursion (goto-char (point-max))
4854 (forward-line (- height))
4856 (window (get-buffer-window (current-buffer))))
4857 ;; The user has to want it.
4858 (when gnus-auto-center-summary
4859 (when (get-buffer-window gnus-article-buffer)
4860 ;; Only do recentering when the article buffer is displayed,
4861 ;; Set the window start to either `bottom', which is the biggest
4862 ;; possible valid number, or the second line from the top,
4863 ;; whichever is the least.
4865 window (min bottom (save-excursion
4866 (forward-line (- top)) (point)))))
4867 ;; Do horizontal recentering while we're at it.
4868 (when (and (get-buffer-window (current-buffer) t)
4869 (not (eq gnus-auto-center-summary 'vertical)))
4870 (let ((selected (selected-window)))
4871 (select-window (get-buffer-window (current-buffer) t))
4872 (gnus-summary-position-point)
4873 (gnus-horizontal-recenter)
4874 (select-window selected))))))
4876 (defun gnus-summary-jump-to-group (newsgroup)
4877 "Move point to NEWSGROUP in group mode buffer."
4878 ;; Keep update point of group mode buffer if visible.
4879 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4880 (save-window-excursion
4881 ;; Take care of tree window mode.
4882 (when (get-buffer-window gnus-group-buffer)
4883 (pop-to-buffer gnus-group-buffer))
4884 (gnus-group-jump-to-group newsgroup))
4886 ;; Take care of tree window mode.
4887 (if (get-buffer-window gnus-group-buffer)
4888 (pop-to-buffer gnus-group-buffer)
4889 (set-buffer gnus-group-buffer))
4890 (gnus-group-jump-to-group newsgroup))))
4892 ;; This function returns a list of article numbers based on the
4893 ;; difference between the ranges of read articles in this group and
4894 ;; the range of active articles.
4895 (defun gnus-list-of-unread-articles (group)
4896 (let* ((read (gnus-info-read (gnus-get-info group)))
4897 (active (or (gnus-active group) (gnus-activate-group group)))
4900 ;; If none are read, then all are unread.
4902 (setq first (car active))
4903 ;; If the range of read articles is a single range, then the
4904 ;; first unread article is the article after the last read
4905 ;; article. Sounds logical, doesn't it?
4906 (if (not (listp (cdr read)))
4907 (setq first (max (car active) (1+ (cdr read))))
4908 ;; `read' is a list of ranges.
4909 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4912 (setq first (car active)))
4915 (while (< first nlast)
4917 (setq first (1+ first))))
4918 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4919 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4920 (setq read (cdr read)))))
4921 ;; And add the last unread articles.
4922 (while (<= first last)
4924 (setq first (1+ first)))
4925 ;; Return the list of unread articles.
4926 (delq 0 (nreverse unread))))
4928 (defun gnus-list-of-read-articles (group)
4929 "Return a list of unread, unticked and non-dormant articles."
4930 (let* ((info (gnus-get-info group))
4931 (marked (gnus-info-marks info))
4932 (active (gnus-active group)))
4934 (gnus-set-difference
4935 (gnus-sorted-complement
4936 (gnus-uncompress-range active)
4937 (gnus-list-of-unread-articles group))
4939 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4940 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4942 ;; Various summary commands
4944 (defun gnus-summary-select-article-buffer ()
4945 "Reconfigure windows to show article buffer."
4947 (if (not (gnus-buffer-live-p gnus-article-buffer))
4948 (error "There is no article buffer for this summary buffer")
4949 (gnus-configure-windows 'article)
4950 (select-window (get-buffer-window gnus-article-buffer))))
4952 (defun gnus-summary-universal-argument (arg)
4953 "Perform any operation on all articles that are process/prefixed."
4955 (let ((articles (gnus-summary-work-articles arg))
4962 (substitute-command-keys
4963 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4966 (gnus-error 1 "Undefined key")
4969 (gnus-summary-goto-subject (setq article (pop articles)))
4970 (let (gnus-newsgroup-processable)
4971 (command-execute func))
4972 (gnus-summary-remove-process-mark article)))))
4973 (gnus-summary-position-point))
4975 (defun gnus-summary-toggle-truncation (&optional arg)
4976 "Toggle truncation of summary lines.
4977 With arg, turn line truncation on iff arg is positive."
4979 (setq truncate-lines
4980 (if (null arg) (not truncate-lines)
4981 (> (prefix-numeric-value arg) 0)))
4984 (defun gnus-summary-reselect-current-group (&optional all rescan)
4985 "Exit and then reselect the current newsgroup.
4986 The prefix argument ALL means to select all articles."
4988 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4989 (error "Ephemeral groups can't be reselected"))
4990 (let ((current-subject (gnus-summary-article-number))
4991 (group gnus-newsgroup-name))
4992 (setq gnus-newsgroup-begin nil)
4994 ;; We have to adjust the point of group mode buffer because
4995 ;; point was moved to the next unread newsgroup by exiting.
4996 (gnus-summary-jump-to-group group)
4999 (gnus-group-get-new-news-this-group 1)))
5000 (gnus-group-read-group all t)
5001 (gnus-summary-goto-subject current-subject nil t)))
5003 (defun gnus-summary-rescan-group (&optional all)
5004 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5006 (gnus-summary-reselect-current-group all t))
5008 (defun gnus-summary-update-info (&optional non-destructive)
5010 (let ((group gnus-newsgroup-name))
5012 (when gnus-newsgroup-kill-headers
5013 (setq gnus-newsgroup-killed
5014 (gnus-compress-sequence
5016 (gnus-set-sorted-intersection
5017 (gnus-uncompress-range gnus-newsgroup-killed)
5018 (setq gnus-newsgroup-unselected
5019 (sort gnus-newsgroup-unselected '<)))
5020 (setq gnus-newsgroup-unreads
5021 (sort gnus-newsgroup-unreads '<)))
5023 (unless (listp (cdr gnus-newsgroup-killed))
5024 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5025 (let ((headers gnus-newsgroup-headers))
5026 ;; Set the new ranges of read articles.
5028 (set-buffer gnus-group-buffer)
5029 (gnus-undo-force-boundary))
5030 (gnus-update-read-articles
5031 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5032 ;; Set the current article marks.
5033 (let ((gnus-newsgroup-scored
5034 (if (and (not gnus-save-score)
5035 (not non-destructive))
5037 gnus-newsgroup-scored)))
5039 (gnus-update-marks)))
5040 ;; Do the cross-ref thing.
5041 (when gnus-use-cross-reference
5042 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5043 ;; Do not switch windows but change the buffer to work.
5044 (set-buffer gnus-group-buffer)
5045 (unless (gnus-ephemeral-group-p group)
5046 (gnus-group-update-group group)))))))
5048 (defun gnus-summary-save-newsrc (&optional force)
5049 "Save the current number of read/marked articles in the dribble buffer.
5050 The dribble buffer will then be saved.
5051 If FORCE (the prefix), also save the .newsrc file(s)."
5053 (gnus-summary-update-info t)
5055 (gnus-save-newsrc-file)
5056 (gnus-dribble-save)))
5058 (defun gnus-summary-exit (&optional temporary)
5059 "Exit reading current newsgroup, and then return to group selection mode.
5060 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5062 (gnus-set-global-variables)
5063 (gnus-kill-save-kill-buffer)
5064 (gnus-async-halt-prefetch)
5065 (let* ((group gnus-newsgroup-name)
5066 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5069 (buf (current-buffer)))
5070 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5071 ;; If we have several article buffers, we kill them at exit.
5072 (unless gnus-single-article-buffer
5073 (gnus-kill-buffer gnus-original-article-buffer)
5074 (setq gnus-article-current nil))
5075 (when gnus-use-cache
5076 (gnus-cache-possibly-remove-articles)
5077 (gnus-cache-save-buffers))
5078 (gnus-async-prefetch-remove-group group)
5079 (when gnus-suppress-duplicates
5080 (gnus-dup-enter-articles))
5081 (when gnus-use-trees
5082 (gnus-tree-close group))
5083 ;; Remove entries for this group.
5084 (nnmail-purge-split-history (gnus-group-real-name group))
5085 ;; Make all changes in this group permanent.
5087 (gnus-run-hooks 'gnus-exit-group-hook)
5088 (gnus-summary-update-info)
5089 ;; Do adaptive scoring, and possibly save score files.
5090 (when gnus-newsgroup-adaptive
5091 (gnus-score-adaptive))
5092 (when gnus-use-scoring
5094 (gnus-close-group group)
5095 ;; Make sure where we were, and go to next newsgroup.
5096 (set-buffer gnus-group-buffer)
5098 (gnus-group-jump-to-group group))
5099 (gnus-run-hooks 'gnus-summary-exit-hook)
5100 (unless (or quit-config
5101 ;; If this group has disappeared from the summary
5102 ;; buffer, don't skip forwards.
5103 (not (string= group (gnus-group-group-name))))
5104 (gnus-group-next-unread-group 1))
5105 (setq group-point (point))
5108 (when (gnus-buffer-live-p gnus-article-buffer)
5110 (set-buffer gnus-article-buffer)
5111 (mapcar 'mm-destroy-part gnus-article-mime-handles)))
5112 ;; If we have several article buffers, we kill them at exit.
5113 (unless gnus-single-article-buffer
5114 (gnus-kill-buffer gnus-article-buffer)
5115 (gnus-kill-buffer gnus-original-article-buffer)
5116 (setq gnus-article-current nil))
5118 (if (not gnus-kill-summary-on-exit)
5119 (gnus-deaden-summary)
5120 ;; We set all buffer-local variables to nil. It is unclear why
5121 ;; this is needed, but if we don't, buffer-local variables are
5122 ;; not garbage-collected, it seems. This would the lead to en
5123 ;; ever-growing Emacs.
5124 (gnus-summary-clear-local-variables)
5125 (when (get-buffer gnus-article-buffer)
5126 (bury-buffer gnus-article-buffer))
5127 ;; We clear the global counterparts of the buffer-local
5128 ;; variables as well, just to be on the safe side.
5129 (set-buffer gnus-group-buffer)
5130 (gnus-summary-clear-local-variables)
5131 ;; Return to group mode buffer.
5132 (when (eq mode 'gnus-summary-mode)
5133 (gnus-kill-buffer buf)))
5134 (setq gnus-current-select-method gnus-select-method)
5135 (pop-to-buffer gnus-group-buffer)
5136 (if (not quit-config)
5138 (goto-char group-point)
5139 (gnus-configure-windows 'group 'force))
5140 (gnus-handle-ephemeral-exit quit-config))
5141 ;; Clear the current group name.
5143 (setq gnus-newsgroup-name nil)))))
5145 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5146 (defun gnus-summary-exit-no-update (&optional no-questions)
5147 "Quit reading current newsgroup without updating read article info."
5149 (let* ((group gnus-newsgroup-name)
5150 (quit-config (gnus-group-quit-config group)))
5151 (when (or no-questions
5153 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5154 (gnus-async-halt-prefetch)
5155 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5156 (when (gnus-buffer-live-p gnus-article-buffer)
5158 (set-buffer gnus-article-buffer)
5159 (mapcar 'mm-destroy-part gnus-article-mime-handles)))
5160 ;; If we have several article buffers, we kill them at exit.
5161 (unless gnus-single-article-buffer
5162 (gnus-kill-buffer gnus-article-buffer)
5163 (gnus-kill-buffer gnus-original-article-buffer)
5164 (setq gnus-article-current nil))
5165 (if (not gnus-kill-summary-on-exit)
5166 (gnus-deaden-summary)
5167 (gnus-close-group group)
5168 (gnus-summary-clear-local-variables)
5169 (set-buffer gnus-group-buffer)
5170 (gnus-summary-clear-local-variables)
5171 (when (get-buffer gnus-summary-buffer)
5172 (kill-buffer gnus-summary-buffer)))
5173 (unless gnus-single-article-buffer
5174 (setq gnus-article-current nil))
5175 (when gnus-use-trees
5176 (gnus-tree-close group))
5177 (gnus-async-prefetch-remove-group group)
5178 (when (get-buffer gnus-article-buffer)
5179 (bury-buffer gnus-article-buffer))
5180 ;; Return to the group buffer.
5181 (gnus-configure-windows 'group 'force)
5182 ;; Clear the current group name.
5183 (setq gnus-newsgroup-name nil)
5184 (when (equal (gnus-group-group-name) group)
5185 (gnus-group-next-unread-group 1))
5187 (gnus-handle-ephemeral-exit quit-config)))))
5189 (defun gnus-handle-ephemeral-exit (quit-config)
5190 "Handle movement when leaving an ephemeral group.
5191 The state which existed when entering the ephemeral is reset."
5192 (if (not (buffer-name (car quit-config)))
5193 (gnus-configure-windows 'group 'force)
5194 (set-buffer (car quit-config))
5195 (cond ((eq major-mode 'gnus-summary-mode)
5196 (gnus-set-global-variables))
5197 ((eq major-mode 'gnus-article-mode)
5199 ;; The `gnus-summary-buffer' variable may point
5200 ;; to the old summary buffer when using a single
5202 (unless (gnus-buffer-live-p gnus-summary-buffer)
5203 (set-buffer gnus-group-buffer))
5204 (set-buffer gnus-summary-buffer)
5205 (gnus-set-global-variables))))
5206 (if (or (eq (cdr quit-config) 'article)
5207 (eq (cdr quit-config) 'pick))
5209 ;; The current article may be from the ephemeral group
5210 ;; thus it is best that we reload this article
5211 (gnus-summary-show-article)
5212 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5213 (gnus-configure-windows 'pick 'force)
5214 (gnus-configure-windows (cdr quit-config) 'force)))
5215 (gnus-configure-windows (cdr quit-config) 'force))
5216 (when (eq major-mode 'gnus-summary-mode)
5217 (gnus-summary-next-subject 1 nil t)
5218 (gnus-summary-recenter)
5219 (gnus-summary-position-point))))
5223 (defvar gnus-dead-summary-mode-map nil)
5225 (unless gnus-dead-summary-mode-map
5226 (setq gnus-dead-summary-mode-map (make-keymap))
5227 (suppress-keymap gnus-dead-summary-mode-map)
5228 (substitute-key-definition
5229 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5230 (let ((keys '("\C-d" "\r" "\177" [delete])))
5232 (define-key gnus-dead-summary-mode-map
5233 (pop keys) 'gnus-summary-wake-up-the-dead))))
5235 (defvar gnus-dead-summary-mode nil
5236 "Minor mode for Gnus summary buffers.")
5238 (defun gnus-dead-summary-mode (&optional arg)
5239 "Minor mode for Gnus summary buffers."
5241 (when (eq major-mode 'gnus-summary-mode)
5242 (make-local-variable 'gnus-dead-summary-mode)
5243 (setq gnus-dead-summary-mode
5244 (if (null arg) (not gnus-dead-summary-mode)
5245 (> (prefix-numeric-value arg) 0)))
5246 (when gnus-dead-summary-mode
5247 (gnus-add-minor-mode
5248 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5250 (defun gnus-deaden-summary ()
5251 "Make the current summary buffer into a dead summary buffer."
5252 ;; Kill any previous dead summary buffer.
5253 (when (and gnus-dead-summary
5254 (buffer-name gnus-dead-summary))
5256 (set-buffer gnus-dead-summary)
5257 (when gnus-dead-summary-mode
5258 (kill-buffer (current-buffer)))))
5259 ;; Make this the current dead summary.
5260 (setq gnus-dead-summary (current-buffer))
5261 (gnus-dead-summary-mode 1)
5262 (let ((name (buffer-name)))
5263 (when (string-match "Summary" name)
5265 (concat (substring name 0 (match-beginning 0)) "Dead "
5266 (substring name (match-beginning 0)))
5269 (defun gnus-kill-or-deaden-summary (buffer)
5270 "Kill or deaden the summary BUFFER."
5272 (when (and (buffer-name buffer)
5273 (not gnus-single-article-buffer))
5276 (gnus-kill-buffer gnus-article-buffer)
5277 (gnus-kill-buffer gnus-original-article-buffer)))
5278 (cond (gnus-kill-summary-on-exit
5279 (when (and gnus-use-trees
5280 (gnus-buffer-exists-p buffer))
5283 (gnus-tree-close gnus-newsgroup-name)))
5284 (gnus-kill-buffer buffer))
5285 ((gnus-buffer-exists-p buffer)
5288 (gnus-deaden-summary))))))
5290 (defun gnus-summary-wake-up-the-dead (&rest args)
5291 "Wake up the dead summary buffer."
5293 (gnus-dead-summary-mode -1)
5294 (let ((name (buffer-name)))
5295 (when (string-match "Dead " name)
5297 (concat (substring name 0 (match-beginning 0))
5298 (substring name (match-end 0)))
5300 (gnus-message 3 "This dead summary is now alive again"))
5302 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5303 (defun gnus-summary-fetch-faq (&optional faq-dir)
5304 "Fetch the FAQ for the current group.
5305 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5309 (when current-prefix-arg
5311 "Faq dir: " (and (listp gnus-group-faq-directory)
5312 (mapcar (lambda (file) (list file))
5313 gnus-group-faq-directory))))))
5314 (let (gnus-faq-buffer)
5315 (when (setq gnus-faq-buffer
5316 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5317 (gnus-configure-windows 'summary-faq))))
5319 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5320 (defun gnus-summary-describe-group (&optional force)
5321 "Describe the current newsgroup."
5323 (gnus-group-describe-group force gnus-newsgroup-name))
5325 (defun gnus-summary-describe-briefly ()
5326 "Describe summary mode commands briefly."
5329 (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")))
5331 ;; Walking around group mode buffer from summary mode.
5333 (defun gnus-summary-next-group (&optional no-article target-group backward)
5334 "Exit current newsgroup and then select next unread newsgroup.
5335 If prefix argument NO-ARTICLE is non-nil, no article is selected
5336 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5337 previous group instead."
5339 ;; Stop pre-fetching.
5340 (gnus-async-halt-prefetch)
5341 (let ((current-group gnus-newsgroup-name)
5342 (current-buffer (current-buffer))
5344 ;; First we semi-exit this group to update Xrefs and all variables.
5345 ;; We can't do a real exit, because the window conf must remain
5346 ;; the same in case the user is prompted for info, and we don't
5347 ;; want the window conf to change before that...
5348 (gnus-summary-exit t)
5349 (while (not entered)
5350 ;; Then we find what group we are supposed to enter.
5351 (set-buffer gnus-group-buffer)
5352 (gnus-group-jump-to-group current-group)
5355 (if (eq gnus-keep-same-level 'best)
5356 (gnus-summary-best-group gnus-newsgroup-name)
5357 (gnus-summary-search-group backward gnus-keep-same-level))))
5358 (if (not target-group)
5359 ;; There are no further groups, so we return to the group
5362 (gnus-message 5 "Returning to the group buffer")
5364 (when (gnus-buffer-live-p current-buffer)
5365 (set-buffer current-buffer)
5366 (gnus-summary-exit))
5367 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5368 ;; We try to enter the target group.
5369 (gnus-group-jump-to-group target-group)
5370 (let ((unreads (gnus-group-group-unread)))
5371 (if (and (or (eq t unreads)
5372 (and unreads (not (zerop unreads))))
5373 (gnus-summary-read-group
5374 target-group nil no-article
5375 (and (buffer-name current-buffer) current-buffer)
5378 (setq current-group target-group
5379 target-group nil)))))))
5381 (defun gnus-summary-prev-group (&optional no-article)
5382 "Exit current newsgroup and then select previous unread newsgroup.
5383 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5385 (gnus-summary-next-group no-article nil t))
5387 ;; Walking around summary lines.
5389 (defun gnus-summary-first-subject (&optional unread undownloaded)
5390 "Go to the first unread subject.
5391 If UNREAD is non-nil, go to the first unread article.
5392 Returns the article selected or nil if there are no unread articles."
5397 ((null gnus-newsgroup-data)
5398 (gnus-message 3 "No articles in the group")
5400 ;; Pick the first article.
5402 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5403 (gnus-data-number (car gnus-newsgroup-data)))
5404 ;; No unread articles.
5405 ((null gnus-newsgroup-unreads)
5406 (gnus-message 3 "No more unread articles")
5408 ;; Find the first unread article.
5410 (let ((data gnus-newsgroup-data))
5412 (and (not (and undownloaded
5413 (eq gnus-undownloaded-mark
5414 (gnus-data-mark (car data)))))
5415 (not (gnus-data-unread-p (car data)))))
5416 (setq data (cdr data)))
5418 (goto-char (gnus-data-pos (car data)))
5419 (gnus-data-number (car data))))))
5420 (gnus-summary-position-point)))
5422 (defun gnus-summary-next-subject (n &optional unread dont-display)
5423 "Go to next N'th summary line.
5424 If N is negative, go to the previous N'th subject line.
5425 If UNREAD is non-nil, only unread articles are selected.
5426 The difference between N and the actual number of steps taken is
5429 (let ((backward (< n 0))
5433 (gnus-summary-find-prev unread)
5434 (gnus-summary-find-next unread)))
5435 (gnus-summary-show-thread)
5438 (gnus-message 7 "No more%s articles"
5439 (if unread " unread" "")))
5440 (unless dont-display
5441 (gnus-summary-recenter)
5442 (gnus-summary-position-point))
5445 (defun gnus-summary-next-unread-subject (n)
5446 "Go to next N'th unread summary line."
5448 (gnus-summary-next-subject n t))
5450 (defun gnus-summary-prev-subject (n &optional unread)
5451 "Go to previous N'th summary line.
5452 If optional argument UNREAD is non-nil, only unread article is selected."
5454 (gnus-summary-next-subject (- n) unread))
5456 (defun gnus-summary-prev-unread-subject (n)
5457 "Go to previous N'th unread summary line."
5459 (gnus-summary-next-subject (- n) t))
5461 (defun gnus-summary-goto-subject (article &optional force silent)
5462 "Go the subject line of ARTICLE.
5463 If FORCE, also allow jumping to articles not currently shown."
5464 (interactive "nArticle number: ")
5466 (data (gnus-data-find article)))
5467 ;; We read in the article if we have to.
5470 (gnus-summary-insert-subject
5472 (if (or (numberp force) (vectorp force)) force)
5474 (setq data (gnus-data-find article)))
5479 (gnus-message 3 "Can't find article %d" article))
5481 (goto-char (gnus-data-pos data))
5482 (gnus-summary-position-point)
5485 ;; Walking around summary lines with displaying articles.
5487 (defun gnus-summary-expand-window (&optional arg)
5488 "Make the summary buffer take up the entire Emacs frame.
5489 Given a prefix, will force an `article' buffer configuration."
5492 (gnus-configure-windows 'article 'force)
5493 (gnus-configure-windows 'summary 'force)))
5495 (defun gnus-summary-display-article (article &optional all-header)
5496 "Display ARTICLE in article buffer."
5497 (gnus-set-global-variables)
5501 (if gnus-summary-display-article-function
5502 (funcall gnus-summary-display-article-function article all-header)
5503 (gnus-article-prepare article all-header))
5504 (gnus-run-hooks 'gnus-select-article-hook)
5505 (when (and gnus-current-article
5506 (not (zerop gnus-current-article)))
5507 (gnus-summary-goto-subject gnus-current-article))
5508 (gnus-summary-recenter)
5509 (when (and gnus-use-trees gnus-show-threads)
5510 (gnus-possibly-generate-tree article)
5511 (gnus-highlight-selected-tree article))
5512 ;; Successfully display article.
5513 (gnus-article-set-window-start
5514 (cdr (assq article gnus-newsgroup-bookmarks))))))
5516 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5517 "Select the current article.
5518 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5519 non-nil, the article will be re-fetched even if it already present in
5520 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5522 ;; Make sure we are in the summary buffer to work around bbdb bug.
5523 (unless (eq major-mode 'gnus-summary-mode)
5524 (set-buffer gnus-summary-buffer))
5525 (let ((article (or article (gnus-summary-article-number)))
5526 (all-headers (not (not all-headers))) ;Must be T or NIL.
5527 gnus-summary-display-article-function
5530 (gnus-summary-article-pseudo-p article)
5531 (error "This is a pseudo-article"))
5534 (set-buffer gnus-summary-buffer)
5535 (if (or (and gnus-single-article-buffer
5536 (or (null gnus-current-article)
5537 (null gnus-article-current)
5538 (null (get-buffer gnus-article-buffer))
5539 (not (eq article (cdr gnus-article-current)))
5540 (not (equal (car gnus-article-current)
5541 gnus-newsgroup-name))))
5542 (and (not gnus-single-article-buffer)
5543 (or (null gnus-current-article)
5544 (not (eq gnus-current-article article))))
5546 ;; The requested article is different from the current article.
5548 (gnus-summary-display-article article all-headers)
5550 (when (or all-headers gnus-show-all-headers)
5551 (gnus-article-show-all-headers))
5554 (gnus-article-set-window-start
5555 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5557 (defun gnus-summary-set-current-mark (&optional current-mark)
5558 "Obsolete function."
5561 (defun gnus-summary-next-article (&optional unread subject backward push)
5562 "Select the next article.
5563 If UNREAD, only unread articles are selected.
5564 If SUBJECT, only articles with SUBJECT are selected.
5565 If BACKWARD, the previous article is selected instead of the next."
5568 ;; Is there such an article?
5569 ((and (gnus-summary-search-forward unread subject backward)
5570 (or (gnus-summary-display-article (gnus-summary-article-number))
5571 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5572 (gnus-summary-position-point))
5573 ;; If not, we try the first unread, if that is wanted.
5575 gnus-auto-select-same
5576 (gnus-summary-first-unread-article))
5577 (gnus-summary-position-point)
5578 (gnus-message 6 "Wrapped"))
5579 ;; Try to get next/previous article not displayed in this group.
5580 ((and gnus-auto-extend-newsgroup
5581 (not unread) (not subject))
5582 (gnus-summary-goto-article
5583 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5584 nil (count-lines (point-min) (point))))
5585 ;; Go to next/previous group.
5587 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5588 (gnus-summary-jump-to-group gnus-newsgroup-name))
5589 (let ((cmd last-command-char)
5592 (set-buffer gnus-group-buffer)
5595 (if (eq gnus-keep-same-level 'best)
5596 (gnus-summary-best-group gnus-newsgroup-name)
5597 (gnus-summary-search-group backward gnus-keep-same-level))))
5598 ;; For some reason, the group window gets selected. We change
5600 (select-window (get-buffer-window (current-buffer)))
5601 ;; Select next unread newsgroup automagically.
5603 ((or (not gnus-auto-select-next)
5605 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5606 ((or (eq gnus-auto-select-next 'quietly)
5607 (and (eq gnus-auto-select-next 'slightly-quietly)
5609 (and (eq gnus-auto-select-next 'almost-quietly)
5610 (gnus-summary-last-article-p)))
5612 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5614 (gnus-message 7 "No more%s articles (%s)..."
5615 (if unread " unread" "")
5616 (if group (concat "selecting " group)
5618 (gnus-summary-next-group nil group backward)))
5620 (when (gnus-key-press-event-p last-input-event)
5621 (gnus-summary-walk-group-buffer
5622 gnus-newsgroup-name cmd unread backward point))))))))
5624 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5625 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5626 (?\C-p (gnus-group-prev-unread-group 1))))
5627 (cursor-in-echo-area t)
5628 keve key group ended)
5630 (set-buffer gnus-group-buffer)
5633 (if (eq gnus-keep-same-level 'best)
5634 (gnus-summary-best-group gnus-newsgroup-name)
5635 (gnus-summary-search-group backward gnus-keep-same-level))))
5638 5 "No more%s articles%s" (if unread " unread" "")
5640 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5641 (format " (Type %s for %s [%s])"
5642 (single-key-description cmd) group
5643 (car (gnus-gethash group gnus-newsrc-hashtb)))
5644 (format " (Type %s to exit %s)"
5645 (single-key-description cmd)
5646 gnus-newsgroup-name)))
5647 ;; Confirm auto selection.
5648 (setq key (car (setq keve (gnus-read-event-char))))
5651 ((assq key keystrokes)
5652 (let ((obuf (current-buffer)))
5653 (switch-to-buffer gnus-group-buffer)
5655 (gnus-group-jump-to-group group))
5656 (eval (cadr (assq key keystrokes)))
5657 (setq group (gnus-group-group-name))
5658 (switch-to-buffer obuf))
5662 (gnus-ephemeral-group-p gnus-newsgroup-name))
5664 (gnus-summary-next-group nil group backward)))
5666 (push (cdr keve) unread-command-events))))))
5668 (defun gnus-summary-next-unread-article ()
5669 "Select unread article after current one."
5671 (gnus-summary-next-article
5672 (or (not (eq gnus-summary-goto-unread 'never))
5673 (gnus-summary-last-article-p (gnus-summary-article-number)))
5674 (and gnus-auto-select-same
5675 (gnus-summary-article-subject))))
5677 (defun gnus-summary-prev-article (&optional unread subject)
5678 "Select the article after the current one.
5679 If UNREAD is non-nil, only unread articles are selected."
5681 (gnus-summary-next-article unread subject t))
5683 (defun gnus-summary-prev-unread-article ()
5684 "Select unread article before current one."
5686 (gnus-summary-prev-article
5687 (or (not (eq gnus-summary-goto-unread 'never))
5688 (gnus-summary-first-article-p (gnus-summary-article-number)))
5689 (and gnus-auto-select-same
5690 (gnus-summary-article-subject))))
5692 (defun gnus-summary-next-page (&optional lines circular)
5693 "Show next page of the selected article.
5694 If at the end of the current article, select the next article.
5695 LINES says how many lines should be scrolled up.
5697 If CIRCULAR is non-nil, go to the start of the article instead of
5698 selecting the next article when reaching the end of the current
5701 (setq gnus-summary-buffer (current-buffer))
5702 (gnus-set-global-variables)
5703 (let ((article (gnus-summary-article-number))
5704 (article-window (get-buffer-window gnus-article-buffer t))
5706 ;; If the buffer is empty, we have no article.
5708 (error "No article to select"))
5709 (gnus-configure-windows 'article)
5710 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5711 (if (and (eq gnus-summary-goto-unread 'never)
5712 (not (gnus-summary-last-article-p article)))
5713 (gnus-summary-next-article)
5714 (gnus-summary-next-unread-article))
5715 (if (or (null gnus-current-article)
5716 (null gnus-article-current)
5717 (/= article (cdr gnus-article-current))
5718 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5719 ;; Selected subject is different from current article's.
5720 (gnus-summary-display-article article)
5721 (when article-window
5722 (gnus-eval-in-buffer-window gnus-article-buffer
5723 (setq endp (gnus-article-next-page lines)))
5726 (gnus-summary-beginning-of-article))
5728 (gnus-message 3 "End of message"))
5730 (if (and (eq gnus-summary-goto-unread 'never)
5731 (not (gnus-summary-last-article-p article)))
5732 (gnus-summary-next-article)
5733 (gnus-summary-next-unread-article))))))))
5734 (gnus-summary-recenter)
5735 (gnus-summary-position-point)))
5737 (defun gnus-summary-prev-page (&optional lines move)
5738 "Show previous page of selected article.
5739 Argument LINES specifies lines to be scrolled down.
5740 If MOVE, move to the previous unread article if point is at
5741 the beginning of the buffer."
5743 (let ((article (gnus-summary-article-number))
5744 (article-window (get-buffer-window gnus-article-buffer t))
5746 (gnus-configure-windows 'article)
5747 (if (or (null gnus-current-article)
5748 (null gnus-article-current)
5749 (/= article (cdr gnus-article-current))
5750 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5751 ;; Selected subject is different from current article's.
5752 (gnus-summary-display-article article)
5753 (gnus-summary-recenter)
5754 (when article-window
5755 (gnus-eval-in-buffer-window gnus-article-buffer
5756 (setq endp (gnus-article-prev-page lines)))
5757 (when (and move endp)
5759 (gnus-message 3 "Beginning of message"))
5761 (if (and (eq gnus-summary-goto-unread 'never)
5762 (not (gnus-summary-first-article-p article)))
5763 (gnus-summary-prev-article)
5764 (gnus-summary-prev-unread-article))))))))
5765 (gnus-summary-position-point))
5767 (defun gnus-summary-prev-page-or-article (&optional lines)
5768 "Show previous page of selected article.
5769 Argument LINES specifies lines to be scrolled down.
5770 If at the beginning of the article, go to the next article."
5772 (gnus-summary-prev-page lines t))
5774 (defun gnus-summary-scroll-up (lines)
5775 "Scroll up (or down) one line current article.
5776 Argument LINES specifies lines to be scrolled up (or down if negative)."
5778 (gnus-configure-windows 'article)
5779 (gnus-summary-show-thread)
5780 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5781 (gnus-eval-in-buffer-window gnus-article-buffer
5783 (when (gnus-article-next-page lines)
5784 (gnus-message 3 "End of message")))
5786 (gnus-article-prev-page (- lines))))))
5787 (gnus-summary-recenter)
5788 (gnus-summary-position-point))
5790 (defun gnus-summary-scroll-down (lines)
5791 "Scroll down (or up) one line current article.
5792 Argument LINES specifies lines to be scrolled down (or up if negative)."
5794 (gnus-summary-scroll-up (- lines)))
5796 (defun gnus-summary-next-same-subject ()
5797 "Select next article which has the same subject as current one."
5799 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5801 (defun gnus-summary-prev-same-subject ()
5802 "Select previous article which has the same subject as current one."
5804 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5806 (defun gnus-summary-next-unread-same-subject ()
5807 "Select next unread article which has the same subject as current one."
5809 (gnus-summary-next-article t (gnus-summary-article-subject)))
5811 (defun gnus-summary-prev-unread-same-subject ()
5812 "Select previous unread article which has the same subject as current one."
5814 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5816 (defun gnus-summary-first-unread-article ()
5817 "Select the first unread article.
5818 Return nil if there are no unread articles."
5821 (when (gnus-summary-first-subject t)
5822 (gnus-summary-show-thread)
5823 (gnus-summary-first-subject t)
5824 (gnus-summary-display-article (gnus-summary-article-number)))
5825 (gnus-summary-position-point)))
5827 (defun gnus-summary-first-article ()
5828 "Select the first article.
5829 Return nil if there are no articles."
5832 (when (gnus-summary-first-subject)
5833 (gnus-summary-show-thread)
5834 (gnus-summary-first-subject)
5835 (gnus-summary-display-article (gnus-summary-article-number)))
5836 (gnus-summary-position-point)))
5838 (defun gnus-summary-best-unread-article ()
5839 "Select the unread article with the highest score."
5841 (let ((best -1000000)
5842 (data gnus-newsgroup-data)
5845 (and (gnus-data-unread-p (car data))
5847 (gnus-summary-article-score (gnus-data-number (car data))))
5850 article (gnus-data-number (car data))))
5851 (setq data (cdr data)))
5854 (gnus-summary-goto-article article)
5855 (error "No unread articles"))
5856 (gnus-summary-position-point))))
5858 (defun gnus-summary-last-subject ()
5859 "Go to the last displayed subject line in the group."
5860 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5862 (gnus-summary-goto-subject article))))
5864 (defun gnus-summary-goto-article (article &optional all-headers force)
5865 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5866 If ALL-HEADERS is non-nil, no header lines are hidden.
5867 If FORCE, go to the article even if it isn't displayed. If FORCE
5868 is a number, it is the line the article is to be displayed on."
5872 "Article number or Message-ID: "
5873 (mapcar (lambda (number) (list (int-to-string number)))
5874 gnus-newsgroup-limit))
5878 (if (and (stringp article)
5879 (string-match "@" article))
5880 (gnus-summary-refer-article article)
5881 (when (stringp article)
5882 (setq article (string-to-number article)))
5883 (if (gnus-summary-goto-subject article force)
5884 (gnus-summary-display-article article all-headers)
5885 (gnus-message 4 "Couldn't go to article %s" article) nil))
5886 (gnus-summary-position-point)))
5888 (defun gnus-summary-goto-last-article ()
5889 "Go to the previously read article."
5892 (when gnus-last-article
5893 (gnus-summary-goto-article gnus-last-article nil t))
5894 (gnus-summary-position-point)))
5896 (defun gnus-summary-pop-article (number)
5897 "Pop one article off the history and go to the previous.
5898 NUMBER articles will be popped off."
5901 (setq gnus-newsgroup-history
5902 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5904 (gnus-summary-goto-article (car to) nil t)
5905 (error "Article history empty")))
5906 (gnus-summary-position-point))
5908 ;; Summary commands and functions for limiting the summary buffer.
5910 (defun gnus-summary-limit-to-articles (n)
5911 "Limit the summary buffer to the next N articles.
5912 If not given a prefix, use the process marked articles instead."
5915 (let ((articles (gnus-summary-work-articles n)))
5916 (setq gnus-newsgroup-processable nil)
5917 (gnus-summary-limit articles))
5918 (gnus-summary-position-point)))
5920 (defun gnus-summary-pop-limit (&optional total)
5921 "Restore the previous limit.
5922 If given a prefix, remove all limits."
5925 (setq gnus-newsgroup-limits
5926 (list (mapcar (lambda (h) (mail-header-number h))
5927 gnus-newsgroup-headers))))
5928 (unless gnus-newsgroup-limits
5929 (error "No limit to pop"))
5931 (gnus-summary-limit nil 'pop)
5932 (gnus-summary-position-point)))
5934 (defun gnus-summary-limit-to-subject (subject &optional header)
5935 "Limit the summary buffer to articles that have subjects that match a regexp."
5936 (interactive "sLimit to subject (regexp): ")
5938 (setq header "subject"))
5939 (when (not (equal "" subject))
5941 (let ((articles (gnus-summary-find-matching
5942 (or header "subject") subject 'all)))
5944 (error "Found no matches for \"%s\"" subject))
5945 (gnus-summary-limit articles))
5946 (gnus-summary-position-point))))
5948 (defun gnus-summary-limit-to-author (from)
5949 "Limit the summary buffer to articles that have authors that match a regexp."
5950 (interactive "sLimit to author (regexp): ")
5951 (gnus-summary-limit-to-subject from "from"))
5953 (defun gnus-summary-limit-to-age (age &optional younger-p)
5954 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5955 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5956 articles that are younger than AGE days."
5957 (interactive "nTime in days: \nP")
5959 (let ((data gnus-newsgroup-data)
5960 (cutoff (days-to-time age))
5961 articles d date is-younger)
5962 (while (setq d (pop data))
5963 (when (and (vectorp (gnus-data-header d))
5964 (setq date (mail-header-date (gnus-data-header d))))
5965 (setq is-younger (time-less-p
5966 (time-since (date-to-time date))
5971 (push (gnus-data-number d) articles))))
5972 (gnus-summary-limit (nreverse articles)))
5973 (gnus-summary-position-point)))
5975 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5977 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5979 (defun gnus-summary-limit-to-unread (&optional all)
5980 "Limit the summary buffer to articles that are not marked as read.
5981 If ALL is non-nil, limit strictly to unread articles."
5984 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5985 (gnus-summary-limit-to-marks
5986 ;; Concat all the marks that say that an article is read and have
5988 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5989 gnus-killed-mark gnus-kill-file-mark
5990 gnus-low-score-mark gnus-expirable-mark
5991 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5992 gnus-duplicate-mark gnus-souped-mark)
5995 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5996 (make-obsolete 'gnus-summary-delete-marked-with
5997 'gnus-summary-limit-exlude-marks)
5999 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6000 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6001 If REVERSE, limit the summary buffer to articles that are marked
6002 with MARKS. MARKS can either be a string of marks or a list of marks.
6003 Returns how many articles were removed."
6004 (interactive "sMarks: ")
6005 (gnus-summary-limit-to-marks marks t))
6007 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6008 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6009 If REVERSE (the prefix), limit the summary buffer to articles that are
6010 not marked with MARKS. MARKS can either be a string of marks or a
6012 Returns how many articles were removed."
6013 (interactive "sMarks: \nP")
6015 (let ((data gnus-newsgroup-data)
6016 (marks (if (listp marks) marks
6017 (append marks nil))) ; Transform to list.
6020 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6021 (memq (gnus-data-mark (car data)) marks))
6022 (push (gnus-data-number (car data)) articles))
6023 (setq data (cdr data)))
6024 (gnus-summary-limit articles))
6025 (gnus-summary-position-point)))
6027 (defun gnus-summary-limit-to-score (&optional score)
6028 "Limit to articles with score at or above SCORE."
6030 (setq score (if score
6031 (prefix-numeric-value score)
6032 (or gnus-summary-default-score 0)))
6033 (let ((data gnus-newsgroup-data)
6036 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6038 (push (gnus-data-number (car data)) articles))
6039 (setq data (cdr data)))
6041 (gnus-summary-limit articles)
6042 (gnus-summary-position-point))))
6044 (defun gnus-summary-limit-include-thread (id)
6045 "Display all the hidden articles that in the current thread."
6046 (interactive (list (mail-header-id (gnus-summary-article-header))))
6047 (let ((articles (gnus-articles-in-thread
6048 (gnus-id-to-thread (gnus-root-id id)))))
6050 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6051 (gnus-summary-position-point))))
6053 (defun gnus-summary-limit-include-dormant ()
6054 "Display all the hidden articles that are marked as dormant.
6055 Note that this command only works on a subset of the articles currently
6056 fetched for this group."
6058 (unless gnus-newsgroup-dormant
6059 (error "There are no dormant articles in this group"))
6061 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6062 (gnus-summary-position-point)))
6064 (defun gnus-summary-limit-exclude-dormant ()
6065 "Hide all dormant articles."
6068 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6069 (gnus-summary-position-point)))
6071 (defun gnus-summary-limit-exclude-childless-dormant ()
6072 "Hide all dormant articles that have no children."
6074 (let ((data (gnus-data-list t))
6075 articles d children)
6076 ;; Find all articles that are either not dormant or have
6078 (while (setq d (pop data))
6079 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6081 (gnus-article-children (gnus-data-number d)))
6084 (when (memq (car children) articles)
6089 (push (gnus-data-number d) articles)))
6092 (gnus-summary-limit articles)
6093 (gnus-summary-position-point))))
6095 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6096 "Mark all unread excluded articles as read.
6097 If ALL, mark even excluded ticked and dormants as read."
6099 (let ((articles (gnus-sorted-complement
6101 (mapcar (lambda (h) (mail-header-number h))
6102 gnus-newsgroup-headers)
6104 (sort gnus-newsgroup-limit '<)))
6106 (setq gnus-newsgroup-unreads
6107 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6109 (setq gnus-newsgroup-dormant nil
6110 gnus-newsgroup-marked nil
6111 gnus-newsgroup-reads
6113 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6114 gnus-newsgroup-reads))
6115 (while (setq article (pop articles))
6116 (unless (or (memq article gnus-newsgroup-dormant)
6117 (memq article gnus-newsgroup-marked))
6118 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6120 (defun gnus-summary-limit (articles &optional pop)
6122 ;; We pop the previous limit off the stack and use that.
6123 (setq articles (car gnus-newsgroup-limits)
6124 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6125 ;; We use the new limit, so we push the old limit on the stack.
6126 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6128 (setq gnus-newsgroup-limit articles)
6129 (let ((total (length gnus-newsgroup-data))
6130 (data (gnus-data-find-list (gnus-summary-article-number)))
6131 (gnus-summary-mark-below nil) ; Inhibit this.
6133 ;; This will do all the work of generating the new summary buffer
6134 ;; according to the new limit.
6135 (gnus-summary-prepare)
6136 ;; Hide any threads, possibly.
6137 (and gnus-show-threads
6138 gnus-thread-hide-subtree
6139 (gnus-summary-hide-all-threads))
6140 ;; Try to return to the article you were at, or one in the
6143 ;; We try to find some article after the current one.
6145 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6148 (setq data (cdr data))))
6150 ;; If there is no data, that means that we were after the last
6151 ;; article. The same goes when we can't find any articles
6152 ;; after the current one.
6153 (goto-char (point-max))
6154 (gnus-summary-find-prev))
6155 (gnus-set-mode-line 'summary)
6156 ;; We return how many articles were removed from the summary
6157 ;; buffer as a result of the new limit.
6158 (- total (length gnus-newsgroup-data))))
6160 (defsubst gnus-invisible-cut-children (threads)
6163 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6168 (defsubst gnus-cut-thread (thread)
6169 "Go forwards in the thread until we find an article that we want to display."
6170 (when (or (eq gnus-fetch-old-headers 'some)
6171 (eq gnus-fetch-old-headers 'invisible)
6172 (eq gnus-build-sparse-threads 'some)
6173 (eq gnus-build-sparse-threads 'more))
6174 ;; Deal with old-fetched headers and sparse threads.
6178 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6179 (gnus-summary-article-ancient-p
6180 (mail-header-number (car thread))))
6181 (if (or (<= (length (cdr thread)) 1)
6182 (eq gnus-fetch-old-headers 'invisible))
6183 (setq gnus-newsgroup-limit
6184 (delq (mail-header-number (car thread))
6185 gnus-newsgroup-limit)
6186 thread (cadr thread))
6187 (when (gnus-invisible-cut-children (cdr thread))
6188 (let ((th (cdr thread)))
6190 (if (memq (mail-header-number (caar th))
6191 gnus-newsgroup-limit)
6192 (setq thread (car th)
6194 (setq th (cdr th))))))))))
6197 (defun gnus-cut-threads (threads)
6198 "Cut off all uninteresting articles from the beginning of threads."
6199 (when (or (eq gnus-fetch-old-headers 'some)
6200 (eq gnus-fetch-old-headers 'invisible)
6201 (eq gnus-build-sparse-threads 'some)
6202 (eq gnus-build-sparse-threads 'more))
6205 (setcar th (gnus-cut-thread (car th)))
6206 (setq th (cdr th)))))
6207 ;; Remove nixed out threads.
6210 (defun gnus-summary-initial-limit (&optional show-if-empty)
6211 "Figure out what the initial limit is supposed to be on group entry.
6212 This entails weeding out unwanted dormants, low-scored articles,
6213 fetch-old-headers verbiage, and so on."
6214 ;; Most groups have nothing to remove.
6215 (if (or gnus-inhibit-limiting
6216 (and (null gnus-newsgroup-dormant)
6217 (not (eq gnus-fetch-old-headers 'some))
6218 (not (eq gnus-fetch-old-headers 'invisible))
6219 (null gnus-summary-expunge-below)
6220 (not (eq gnus-build-sparse-threads 'some))
6221 (not (eq gnus-build-sparse-threads 'more))
6222 (null gnus-thread-expunge-below)
6223 (not gnus-use-nocem)))
6225 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6226 (setq gnus-newsgroup-limit nil)
6229 (unless (car (symbol-value node))
6230 ;; These threads have no parents -- they are roots.
6231 (let ((nodes (cdr (symbol-value node)))
6234 (if (and gnus-thread-expunge-below
6235 (< (gnus-thread-total-score (car nodes))
6236 gnus-thread-expunge-below))
6237 (gnus-expunge-thread (pop nodes))
6238 (setq thread (pop nodes))
6239 (gnus-summary-limit-children thread))))))
6240 gnus-newsgroup-dependencies)
6241 ;; If this limitation resulted in an empty group, we might
6242 ;; pop the previous limit and use it instead.
6243 (when (and (not gnus-newsgroup-limit)
6245 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6246 gnus-newsgroup-limit))
6248 (defun gnus-summary-limit-children (thread)
6249 "Return 1 if this subthread is visible and 0 if it is not."
6250 ;; First we get the number of visible children to this thread. This
6251 ;; is done by recursing down the thread using this function, so this
6252 ;; will really go down to a leaf article first, before slowly
6253 ;; working its way up towards the root.
6257 (apply '+ (mapcar 'gnus-summary-limit-children
6260 (number (mail-header-number (car thread)))
6263 (not (memq number gnus-newsgroup-marked))
6265 ;; If this article is dormant and has absolutely no visible
6266 ;; children, then this article isn't visible.
6267 (and (memq number gnus-newsgroup-dormant)
6269 ;; If this is "fetch-old-headered" and there is no
6270 ;; visible children, then we don't want this article.
6271 (and (eq gnus-fetch-old-headers 'some)
6272 (gnus-summary-article-ancient-p number)
6274 ;; If this is "fetch-old-headered" and `invisible', then
6275 ;; we don't want this article.
6276 (and (eq gnus-fetch-old-headers 'invisible)
6277 (gnus-summary-article-ancient-p number))
6278 ;; If this is a sparsely inserted article with no children,
6279 ;; we don't want it.
6280 (and (eq gnus-build-sparse-threads 'some)
6281 (gnus-summary-article-sparse-p number)
6283 ;; If we use expunging, and this article is really
6284 ;; low-scored, then we don't want this article.
6285 (when (and gnus-summary-expunge-below
6287 (or (cdr (assq number gnus-newsgroup-scored))
6288 gnus-summary-default-score))
6289 gnus-summary-expunge-below))
6290 ;; We increase the expunge-tally here, but that has
6291 ;; nothing to do with the limits, really.
6292 (incf gnus-newsgroup-expunged-tally)
6293 ;; We also mark as read here, if that's wanted.
6294 (when (and gnus-summary-mark-below
6295 (< score gnus-summary-mark-below))
6296 (setq gnus-newsgroup-unreads
6297 (delq number gnus-newsgroup-unreads))
6298 (if gnus-newsgroup-auto-expire
6299 (push number gnus-newsgroup-expirable)
6300 (push (cons number gnus-low-score-mark)
6301 gnus-newsgroup-reads)))
6303 ;; Check NoCeM things.
6304 (if (and gnus-use-nocem
6305 (gnus-nocem-unwanted-article-p
6306 (mail-header-id (car thread))))
6308 (setq gnus-newsgroup-unreads
6309 (delq number gnus-newsgroup-unreads))
6311 ;; Nope, invisible article.
6313 ;; Ok, this article is to be visible, so we add it to the limit
6315 (push number gnus-newsgroup-limit)
6318 (defun gnus-expunge-thread (thread)
6319 "Mark all articles in THREAD as read."
6320 (let* ((number (mail-header-number (car thread))))
6321 (incf gnus-newsgroup-expunged-tally)
6322 ;; We also mark as read here, if that's wanted.
6323 (setq gnus-newsgroup-unreads
6324 (delq number gnus-newsgroup-unreads))
6325 (if gnus-newsgroup-auto-expire
6326 (push number gnus-newsgroup-expirable)
6327 (push (cons number gnus-low-score-mark)
6328 gnus-newsgroup-reads)))
6329 ;; Go recursively through all subthreads.
6330 (mapcar 'gnus-expunge-thread (cdr thread)))
6332 ;; Summary article oriented commands
6334 (defun gnus-summary-refer-parent-article (n)
6335 "Refer parent article N times.
6336 If N is negative, go to ancestor -N instead.
6337 The difference between N and the number of articles fetched is returned."
6341 (when (not (natnump n))
6346 (setq header (gnus-summary-article-header))
6347 (if (and (eq (mail-header-number header)
6348 (cdr gnus-article-current))
6349 (equal gnus-newsgroup-name
6350 (car gnus-article-current)))
6351 ;; If we try to find the parent of the currently
6352 ;; displayed article, then we take a look at the actual
6353 ;; References header, since this is slightly more
6354 ;; reliable than the References field we got from the
6357 (set-buffer gnus-original-article-buffer)
6358 (nnheader-narrow-to-headers)
6359 (unless (setq ref (message-fetch-field "references"))
6360 (setq ref (message-fetch-field "in-reply-to")))
6363 ;; It's not the current article, so we take a bet on
6364 ;; the value we got from the server.
6365 (mail-header-references header)))
6367 (not (equal ref "")))
6368 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6369 (gnus-message 1 "Couldn't find parent"))
6370 (gnus-message 1 "No references in article %d"
6371 (gnus-summary-article-number))
6374 (gnus-summary-position-point)
6377 (defun gnus-summary-refer-references ()
6378 "Fetch all articles mentioned in the References header.
6379 Return the number of articles fetched."
6381 (let ((ref (mail-header-references (gnus-summary-article-header)))
6382 (current (gnus-summary-article-number))
6386 (error "No References in the current article")
6387 ;; For each Message-ID in the References header...
6388 (while (string-match "<[^>]*>" ref)
6390 ;; ... fetch that article.
6391 (gnus-summary-refer-article
6392 (prog1 (match-string 0 ref)
6393 (setq ref (substring ref (match-end 0))))))
6394 (gnus-summary-goto-subject current)
6395 (gnus-summary-position-point)
6398 (defun gnus-summary-refer-thread (&optional limit)
6399 "Fetch all articles in the current thread.
6400 If LIMIT (the numerical prefix), fetch that many old headers instead
6401 of what's specified by the `gnus-refer-thread-limit' variable."
6403 (let ((id (mail-header-id (gnus-summary-article-header)))
6404 (limit (if limit (prefix-numeric-value limit)
6405 gnus-refer-thread-limit)))
6406 ;; We want to fetch LIMIT *old* headers, but we also have to
6407 ;; re-fetch all the headers in the current buffer, because many of
6408 ;; them may be undisplayed. So we adjust LIMIT.
6409 (when (numberp limit)
6410 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6411 (unless (eq gnus-fetch-old-headers 'invisible)
6412 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6413 ;; Retrieve the headers and read them in.
6414 (if (eq (gnus-retrieve-headers
6415 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6417 (gnus-build-all-threads)
6418 (error "Can't fetch thread from backends that don't support NOV"))
6419 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6420 (gnus-summary-limit-include-thread id)))
6422 (defun gnus-summary-refer-article (message-id &optional arg)
6423 "Fetch an article specified by MESSAGE-ID.
6424 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6425 or `gnus-select-method', no matter what backend the article comes from."
6426 (interactive "sMessage-ID: \nP")
6427 (when (and (stringp message-id)
6428 (not (zerop (length message-id))))
6429 ;; Construct the correct Message-ID if necessary.
6430 ;; Suggested by tale@pawl.rpi.edu.
6431 (unless (string-match "^<" message-id)
6432 (setq message-id (concat "<" message-id)))
6433 (unless (string-match ">$" message-id)
6434 (setq message-id (concat message-id ">")))
6435 (let* ((header (gnus-id-to-header message-id))
6437 (gnus-summary-article-sparse-p
6438 (mail-header-number header))
6439 (memq (mail-header-number header)
6440 gnus-newsgroup-limit))))
6442 ;; If the article is present in the buffer we just go to it.
6444 (or (not (gnus-summary-article-sparse-p
6445 (mail-header-number header)))
6448 (gnus-summary-goto-article
6449 (mail-header-number header) nil t)
6451 (gnus-summary-update-article (mail-header-number header)))))
6453 ;; We fetch the article
6454 (let ((gnus-override-method
6455 (cond ((gnus-news-group-p gnus-newsgroup-name)
6456 gnus-refer-article-method)
6458 (or gnus-refer-article-method gnus-select-method))
6461 ;; Start the special refer-article method, if necessary.
6462 (when (and gnus-refer-article-method
6463 (gnus-news-group-p gnus-newsgroup-name))
6464 (gnus-check-server gnus-refer-article-method))
6465 ;; Fetch the header, and display the article.
6466 (if (setq number (gnus-summary-insert-subject message-id))
6467 (gnus-summary-select-article nil nil nil number)
6468 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6470 (defun gnus-summary-edit-parameters ()
6471 "Edit the group parameters of the current group."
6473 (gnus-group-edit-group gnus-newsgroup-name 'params))
6475 (defun gnus-summary-enter-digest-group (&optional force)
6476 "Enter an nndoc group based on the current article.
6477 If FORCE, force a digest interpretation. If not, try
6478 to guess what the document format is."
6480 (let ((conf gnus-current-window-configuration))
6482 (gnus-summary-select-article))
6483 (setq gnus-current-window-configuration conf)
6484 (let* ((name (format "%s-%d"
6485 (gnus-group-prefixed-name
6486 gnus-newsgroup-name (list 'nndoc ""))
6488 (set-buffer gnus-summary-buffer)
6489 gnus-current-article)))
6490 (ogroup gnus-newsgroup-name)
6491 (params (append (gnus-info-params (gnus-get-info ogroup))
6492 (list (cons 'to-group ogroup))
6493 (list (cons 'save-article-group ogroup))))
6494 (case-fold-search t)
6495 (buf (current-buffer))
6498 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6499 (insert-buffer-substring gnus-original-article-buffer)
6500 ;; Remove lines that may lead nndoc to misinterpret the
6503 (goto-char (point-min))
6504 (or (search-forward "\n\n" nil t) (point)))
6505 (goto-char (point-min))
6506 (delete-matching-lines "^\\(Path\\):\\|^From ")
6509 (if (gnus-group-read-ephemeral-group
6510 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6512 ,(if force 'digest 'guess))) t)
6513 ;; Make all postings to this group go to the parent group.
6514 (nconc (gnus-info-params (gnus-get-info name))
6516 ;; Couldn't select this doc group.
6517 (switch-to-buffer buf)
6518 (gnus-set-global-variables)
6519 (gnus-configure-windows 'summary)
6520 (gnus-message 3 "Article couldn't be entered?"))
6521 (kill-buffer dig)))))
6523 (defun gnus-summary-read-document (n)
6524 "Open a new group based on the current article(s).
6525 This will allow you to read digests and other similar
6526 documents as newsgroups.
6527 Obeys the standard process/prefix convention."
6529 (let* ((articles (gnus-summary-work-articles n))
6530 (ogroup gnus-newsgroup-name)
6531 (params (append (gnus-info-params (gnus-get-info ogroup))
6532 (list (cons 'to-group ogroup))))
6533 article group egroup groups vgroup)
6534 (while (setq article (pop articles))
6535 (setq group (format "%s-%d" gnus-newsgroup-name article))
6536 (gnus-summary-remove-process-mark article)
6537 (when (gnus-summary-display-article article)
6540 (insert-buffer-substring gnus-original-article-buffer)
6541 ;; Remove some headers that may lead nndoc to make
6543 (message-narrow-to-head)
6544 (goto-char (point-min))
6545 (delete-matching-lines "^\\(Path\\):\\|^From ")
6548 (gnus-group-read-ephemeral-group
6549 group `(nndoc ,group (nndoc-address ,(current-buffer))
6550 (nndoc-article-type guess))
6553 ;; Make all postings to this group go to the parent group.
6554 (nconc (gnus-info-params (gnus-get-info egroup))
6556 (push egroup groups))
6557 ;; Couldn't select this doc group.
6558 (gnus-error 3 "Article couldn't be entered"))))))
6559 ;; Now we have selected all the documents.
6562 (error "None of the articles could be interpreted as documents"))
6563 ((gnus-group-read-ephemeral-group
6564 (setq vgroup (format
6565 "nnvirtual:%s-%s" gnus-newsgroup-name
6566 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6567 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6569 (cons (current-buffer) 'summary)))
6571 (error "Couldn't select virtual nndoc group")))))
6573 (defun gnus-summary-isearch-article (&optional regexp-p)
6574 "Do incremental search forward on the current article.
6575 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6577 (gnus-summary-select-article)
6578 (gnus-configure-windows 'article)
6579 (gnus-eval-in-buffer-window gnus-article-buffer
6582 (isearch-forward regexp-p))))
6584 (defun gnus-summary-search-article-forward (regexp &optional backward)
6585 "Search for an article containing REGEXP forward.
6586 If BACKWARD, search backward instead."
6589 (format "Search article %s (regexp%s): "
6590 (if current-prefix-arg "backward" "forward")
6591 (if gnus-last-search-regexp
6592 (concat ", default " gnus-last-search-regexp)
6594 current-prefix-arg))
6595 (if (string-equal regexp "")
6596 (setq regexp (or gnus-last-search-regexp ""))
6597 (setq gnus-last-search-regexp regexp))
6598 (if (gnus-summary-search-article regexp backward)
6599 (gnus-summary-show-thread)
6600 (error "Search failed: \"%s\"" regexp)))
6602 (defun gnus-summary-search-article-backward (regexp)
6603 "Search for an article containing REGEXP backward."
6606 (format "Search article backward (regexp%s): "
6607 (if gnus-last-search-regexp
6608 (concat ", default " gnus-last-search-regexp)
6610 (gnus-summary-search-article-forward regexp 'backward))
6612 (defun gnus-summary-search-article (regexp &optional backward)
6613 "Search for an article containing REGEXP.
6614 Optional argument BACKWARD means do search for backward.
6615 `gnus-select-article-hook' is not called during the search."
6616 ;; We have to require this here to make sure that the following
6617 ;; dynamic binding isn't shadowed by autoloading.
6618 (require 'gnus-async)
6619 (let ((gnus-select-article-hook nil) ;Disable hook.
6620 (gnus-article-display-hook nil)
6621 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6622 (gnus-use-article-prefetch nil)
6623 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6624 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6625 (sum (current-buffer))
6627 point gnus-display-mime-function)
6628 (gnus-save-hidden-threads
6629 (gnus-summary-select-article)
6630 (set-buffer gnus-article-buffer)
6634 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6636 (re-search-backward regexp nil t)
6637 (re-search-forward regexp nil t))
6638 ;; We found the regexp.
6643 (get-buffer-window (current-buffer))
6647 (setq point (point)))
6648 ;; We didn't find it, so we go to the next article.
6651 (while (eq found 'not)
6652 (if (not (if backward (gnus-summary-find-prev)
6653 (gnus-summary-find-next)))
6654 ;; No more articles.
6656 ;; Select the next article and adjust point.
6657 (unless (gnus-summary-article-sparse-p
6658 (gnus-summary-article-number))
6660 (gnus-summary-select-article)
6661 (set-buffer gnus-article-buffer)
6663 (goto-char (if backward (point-max) (point-min))))))))
6664 (gnus-message 7 ""))
6665 ;; Return whether we found the regexp.
6666 (when (eq found 'found)
6668 (gnus-summary-show-thread)
6669 (gnus-summary-goto-subject gnus-current-article)
6670 (gnus-summary-position-point)
6673 (defun gnus-summary-find-matching (header regexp &optional backward unread
6675 "Return a list of all articles that match REGEXP on HEADER.
6676 The search stars on the current article and goes forwards unless
6677 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6678 If UNREAD is non-nil, only unread articles will
6679 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6680 in the comparisons."
6681 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6682 (gnus-data-find-list
6683 (gnus-summary-article-number) (gnus-data-list backward))))
6684 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6685 (case-fold-search (not not-case-fold))
6687 (unless (fboundp (intern (concat "mail-header-" header)))
6688 (error "%s is not a valid header" header))
6691 (and (or (not unread) ; We want all articles...
6692 (gnus-data-unread-p d)) ; Or just unreads.
6693 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6694 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6695 (push (gnus-data-number d) articles)) ; Success!
6696 (setq data (cdr data)))
6697 (nreverse articles)))
6699 (defun gnus-summary-execute-command (header regexp command &optional backward)
6700 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6701 If HEADER is an empty string (or nil), the match is done on the entire
6702 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6704 (list (let ((completion-ignore-case t))
6707 (mapcar (lambda (string) (list string))
6708 '("Number" "Subject" "From" "Lines" "Date"
6709 "Message-ID" "Xref" "References" "Body"))
6710 nil 'require-match))
6711 (read-string "Regexp: ")
6712 (read-key-sequence "Command: ")
6713 current-prefix-arg))
6714 (when (equal header "Body")
6716 ;; Hidden thread subtrees must be searched as well.
6717 (gnus-summary-show-all-threads)
6718 ;; We don't want to change current point nor window configuration.
6720 (save-window-excursion
6721 (gnus-message 6 "Executing %s..." (key-description command))
6722 ;; We'd like to execute COMMAND interactively so as to give arguments.
6723 (gnus-execute header regexp
6724 `(call-interactively ',(key-binding command))
6726 (gnus-message 6 "Executing %s...done" (key-description command)))))
6728 (defun gnus-summary-beginning-of-article ()
6729 "Scroll the article back to the beginning."
6731 (gnus-summary-select-article)
6732 (gnus-configure-windows 'article)
6733 (gnus-eval-in-buffer-window gnus-article-buffer
6735 (goto-char (point-min))
6736 (when gnus-page-broken
6737 (gnus-narrow-to-page))))
6739 (defun gnus-summary-end-of-article ()
6740 "Scroll to the end of the article."
6742 (gnus-summary-select-article)
6743 (gnus-configure-windows 'article)
6744 (gnus-eval-in-buffer-window gnus-article-buffer
6746 (goto-char (point-max))
6748 (when gnus-page-broken
6749 (gnus-narrow-to-page))))
6751 (defun gnus-summary-print-article (&optional filename n)
6752 "Generate and print a PostScript image of the N next (mail) articles.
6754 If N is negative, print the N previous articles. If N is nil and articles
6755 have been marked with the process mark, print these instead.
6757 If the optional second argument FILENAME is nil, send the image to the
6758 printer. If FILENAME is a string, save the PostScript image in a file with
6759 that name. If FILENAME is a number, prompt the user for the name of the file
6761 (interactive (list (ps-print-preprint current-prefix-arg)
6762 current-prefix-arg))
6763 (dolist (article (gnus-summary-work-articles n))
6764 (gnus-summary-select-article nil nil 'pseudo article)
6765 (gnus-eval-in-buffer-window gnus-article-buffer
6766 (let ((buffer (generate-new-buffer " *print*")))
6769 (copy-to-buffer buffer (point-min) (point-max))
6771 (gnus-article-delete-invisible-text)
6772 (let ((ps-left-header
6775 (mail-header-subject gnus-current-headers) ")")
6777 (mail-header-from gnus-current-headers) ")")))
6780 "/pagenumberstring load"
6782 (mail-header-date gnus-current-headers) ")"))))
6783 (gnus-run-hooks 'gnus-ps-print-hook)
6785 (ps-print-buffer-with-faces filename))))
6786 (kill-buffer buffer))))))
6788 (defun gnus-summary-show-article (&optional arg)
6789 "Force re-fetching of the current article.
6790 If ARG (the prefix) is non-nil, show the raw article without any
6791 article massaging functions being run."
6794 ;; Select the article the normal way.
6795 (gnus-summary-select-article nil 'force)
6796 ;; Bind the article treatment functions to nil.
6797 (let ((gnus-have-all-headers t)
6798 gnus-article-display-hook
6799 gnus-article-prepare-hook
6800 gnus-article-decode-hook
6801 gnus-display-mime-function
6804 (gnus-summary-select-article nil 'force)))
6805 (gnus-summary-goto-subject gnus-current-article)
6806 (gnus-summary-position-point))
6808 (defun gnus-summary-verbose-headers (&optional arg)
6809 "Toggle permanent full header display.
6810 If ARG is a positive number, turn header display on.
6811 If ARG is a negative number, turn header display off."
6813 (setq gnus-show-all-headers
6814 (cond ((or (not (numberp arg))
6816 (not gnus-show-all-headers))
6819 (gnus-summary-show-article))
6821 (defun gnus-summary-toggle-header (&optional arg)
6822 "Show the headers if they are hidden, or hide them if they are shown.
6823 If ARG is a positive number, show the entire header.
6824 If ARG is a negative number, hide the unwanted header lines."
6827 (set-buffer gnus-article-buffer)
6828 (let* ((buffer-read-only nil)
6829 (inhibit-point-motion-hooks t)
6830 (hidden (text-property-any
6831 (goto-char (point-min)) (search-forward "\n\n")
6834 (goto-char (point-min))
6835 (when (search-forward "\n\n" nil t)
6836 (delete-region (point-min) (1- (point))))
6837 (goto-char (point-min))
6839 (set-buffer gnus-original-article-buffer)
6840 (goto-char (point-min))
6841 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6842 (insert-buffer-substring gnus-original-article-buffer 1 e)
6843 (let ((article-inhibit-hiding t))
6844 (gnus-run-hooks 'gnus-article-display-hook))
6845 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6846 (gnus-article-hide-headers)))))
6848 (defun gnus-summary-show-all-headers ()
6849 "Make all header lines visible."
6851 (gnus-article-show-all-headers))
6853 (defun gnus-summary-caesar-message (&optional arg)
6854 "Caesar rotate the current article by 13.
6855 The numerical prefix specifies how many places to rotate each letter
6858 (gnus-summary-select-article)
6859 (let ((mail-header-separator ""))
6860 (gnus-eval-in-buffer-window gnus-article-buffer
6863 (let ((start (window-start))
6865 (message-caesar-buffer-body arg)
6866 (set-window-start (get-buffer-window (current-buffer)) start))))))
6868 (defun gnus-summary-stop-page-breaking ()
6869 "Stop page breaking in the current article."
6871 (gnus-summary-select-article)
6872 (gnus-eval-in-buffer-window gnus-article-buffer
6874 (when (gnus-visual-p 'page-marker)
6875 (let ((buffer-read-only nil))
6876 (gnus-remove-text-with-property 'gnus-prev)
6877 (gnus-remove-text-with-property 'gnus-next))
6878 (setq gnus-page-broken nil))))
6880 (defun gnus-summary-move-article (&optional n to-newsgroup
6881 select-method action)
6882 "Move the current article to a different newsgroup.
6883 If N is a positive number, move the N next articles.
6884 If N is a negative number, move the N previous articles.
6885 If N is nil and any articles have been marked with the process mark,
6886 move those articles instead.
6887 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6888 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6889 re-spool using this method.
6891 For this function to work, both the current newsgroup and the
6892 newsgroup that you want to move to have to support the `request-move'
6893 and `request-accept' functions."
6896 (setq action 'move))
6897 ;; Disable marking as read.
6898 (let (gnus-mark-article-hook)
6899 (save-window-excursion
6900 (gnus-summary-select-article)))
6901 ;; Check whether the source group supports the required functions.
6902 (cond ((and (eq action 'move)
6903 (not (gnus-check-backend-function
6904 'request-move-article gnus-newsgroup-name)))
6905 (error "The current group does not support article moving"))
6906 ((and (eq action 'crosspost)
6907 (not (gnus-check-backend-function
6908 'request-replace-article gnus-newsgroup-name)))
6909 (error "The current group does not support article editing")))
6910 (let ((articles (gnus-summary-work-articles n))
6911 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6912 (names '((move "Move" "Moving")
6913 (copy "Copy" "Copying")
6914 (crosspost "Crosspost" "Crossposting")))
6915 (copy-buf (save-excursion
6916 (nnheader-set-temp-buffer " *copy article*")))
6917 art-group to-method new-xref article to-groups)
6918 (unless (assq action names)
6919 (error "Unknown action %s" action))
6920 ;; Read the newsgroup name.
6921 (when (and (not to-newsgroup)
6922 (not select-method))
6924 (gnus-read-move-group-name
6925 (cadr (assq action names))
6926 (symbol-value (intern (format "gnus-current-%s-group" action)))
6928 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6929 (setq to-method (or select-method
6930 (gnus-group-name-to-method to-newsgroup)))
6931 ;; Check the method we are to move this article to...
6932 (unless (gnus-check-backend-function
6933 'request-accept-article (car to-method))
6934 (error "%s does not support article copying" (car to-method)))
6935 (unless (gnus-check-server to-method)
6936 (error "Can't open server %s" (car to-method)))
6937 (gnus-message 6 "%s to %s: %s..."
6938 (caddr (assq action names))
6939 (or (car select-method) to-newsgroup) articles)
6941 (setq article (pop articles))
6945 ;; Move the article.
6947 ;; Remove this article from future suppression.
6948 (gnus-dup-unsuppress-article article)
6949 (gnus-request-move-article
6950 article ; Article to move
6951 gnus-newsgroup-name ; From newsgroup
6952 (nth 1 (gnus-find-method-for-group
6953 gnus-newsgroup-name)) ; Server
6954 (list 'gnus-request-accept-article
6955 to-newsgroup (list 'quote select-method)
6956 (not articles)) ; Accept form
6957 (not articles))) ; Only save nov last time
6958 ;; Copy the article.
6961 (set-buffer copy-buf)
6962 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6963 (gnus-request-accept-article
6964 to-newsgroup select-method (not articles) t))))
6965 ;; Crosspost the article.
6966 ((eq action 'crosspost)
6967 (let ((xref (message-tokenize-header
6968 (mail-header-xref (gnus-summary-article-header article))
6970 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6973 (setq xref (list (system-name))))
6976 (mapconcat 'identity
6977 (delete "Xref:" (delete new-xref xref))
6981 (set-buffer copy-buf)
6982 ;; First put the article in the destination group.
6983 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6984 (when (consp (setq art-group
6985 (gnus-request-accept-article
6986 to-newsgroup select-method (not articles))))
6987 (setq new-xref (concat new-xref " " (car art-group)
6988 ":" (cdr art-group)))
6989 ;; Now we have the new Xrefs header, so we insert
6990 ;; it and replace the new article.
6991 (nnheader-replace-header "Xref" new-xref)
6992 (gnus-request-replace-article
6993 (cdr art-group) to-newsgroup (current-buffer))
6997 (gnus-message 1 "Couldn't %s article %s"
6998 (cadr (assq action names)) article))
6999 ((and (eq art-group 'junk)
7001 (gnus-summary-mark-article article gnus-canceled-mark)
7002 (gnus-message 4 "Deleted article %s" article))
7004 (let* ((pto-group (gnus-group-prefixed-name
7005 (car art-group) to-method))
7007 (gnus-gethash pto-group gnus-newsrc-hashtb))
7008 (info (nth 2 entry))
7009 (to-group (gnus-info-group info)))
7010 ;; Update the group that has been moved to.
7012 (memq action '(move copy)))
7013 (unless (member to-group to-groups)
7014 (push to-group to-groups))
7016 (unless (memq article gnus-newsgroup-unreads)
7018 info (gnus-add-to-range (gnus-info-read info)
7019 (list (cdr art-group)))))
7021 ;; Copy any marks over to the new group.
7022 (let ((marks gnus-article-mark-lists)
7023 (to-article (cdr art-group)))
7025 ;; See whether the article is to be put in the cache.
7026 (when gnus-use-cache
7027 (gnus-cache-possibly-enter-article
7029 (let ((header (copy-sequence
7030 (gnus-summary-article-header article))))
7031 (mail-header-set-number header to-article)
7033 (memq article gnus-newsgroup-marked)
7034 (memq article gnus-newsgroup-dormant)
7035 (memq article gnus-newsgroup-unreads)))
7037 (when (and (equal to-group gnus-newsgroup-name)
7038 (not (memq article gnus-newsgroup-unreads)))
7039 ;; Mark this article as read in this group.
7040 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7041 (setcdr (gnus-active to-group) to-article)
7042 (setcdr gnus-newsgroup-active to-article))
7045 (when (memq article (symbol-value
7046 (intern (format "gnus-newsgroup-%s"
7048 ;; If the other group is the same as this group,
7049 ;; then we have to add the mark to the list.
7050 (when (equal to-group gnus-newsgroup-name)
7051 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7054 (intern (format "gnus-newsgroup-%s"
7056 ;; Copy the marks to other group.
7057 (gnus-add-marked-articles
7058 to-group (cdar marks) (list to-article) info))
7059 (setq marks (cdr marks)))
7062 (concat "(gnus-group-set-info '"
7063 (gnus-prin1-to-string (gnus-get-info to-group))
7066 ;; Update the Xref header in this article to point to
7067 ;; the new crossposted article we have just created.
7068 (when (eq action 'crosspost)
7070 (set-buffer copy-buf)
7071 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7072 (nnheader-replace-header "Xref" new-xref)
7073 (gnus-request-replace-article
7074 article gnus-newsgroup-name (current-buffer)))))
7076 ;;;!!!Why is this necessary?
7077 (set-buffer gnus-summary-buffer)
7079 (gnus-summary-goto-subject article)
7080 (when (eq action 'move)
7081 (gnus-summary-mark-article article gnus-canceled-mark))))
7082 (gnus-summary-remove-process-mark article))
7083 ;; Re-activate all groups that have been moved to.
7086 (set-buffer gnus-group-buffer)
7087 (when (gnus-group-goto-group (car to-groups) t)
7088 (gnus-group-get-new-news-this-group 1 t))
7091 (gnus-kill-buffer copy-buf)
7092 (gnus-summary-position-point)
7093 (gnus-set-mode-line 'summary)))
7095 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7096 "Move the current article to a different newsgroup.
7097 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7098 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7099 re-spool using this method."
7101 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7103 (defun gnus-summary-crosspost-article (&optional n)
7104 "Crosspost the current article to some other group."
7106 (gnus-summary-move-article n nil nil 'crosspost))
7108 (defcustom gnus-summary-respool-default-method nil
7109 "Default method for respooling an article.
7110 If nil, use to the current newsgroup method."
7111 :type '(choice (gnus-select-method :value (nnml ""))
7113 :group 'gnus-summary-mail)
7115 (defun gnus-summary-respool-article (&optional n method)
7116 "Respool the current article.
7117 The article will be squeezed through the mail spooling process again,
7118 which means that it will be put in some mail newsgroup or other
7119 depending on `nnmail-split-methods'.
7120 If N is a positive number, respool the N next articles.
7121 If N is a negative number, respool the N previous articles.
7122 If N is nil and any articles have been marked with the process mark,
7123 respool those articles instead.
7125 Respooling can be done both from mail groups and \"real\" newsgroups.
7126 In the former case, the articles in question will be moved from the
7127 current group into whatever groups they are destined to. In the
7128 latter case, they will be copied into the relevant groups."
7130 (list current-prefix-arg
7131 (let* ((methods (gnus-methods-using 'respool))
7133 (symbol-name (or gnus-summary-respool-default-method
7134 (car (gnus-find-method-for-group
7135 gnus-newsgroup-name)))))
7137 (gnus-completing-read
7138 methname "What backend do you want to use when respooling?"
7139 methods nil t nil 'gnus-mail-method-history))
7142 ((zerop (length (setq ms (gnus-servers-using-backend
7144 (list (intern method) ""))
7148 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7149 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7152 (error "No method given for respooling"))
7153 (if (assoc (symbol-name
7154 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7155 (gnus-methods-using 'respool))
7156 (gnus-summary-move-article n nil method)
7157 (gnus-summary-copy-article n nil method)))
7159 (defun gnus-summary-import-article (file)
7160 "Import an arbitrary file into a mail newsgroup."
7161 (interactive "fImport file: ")
7162 (let ((group gnus-newsgroup-name)
7163 (now (current-time))
7165 (unless (gnus-check-backend-function 'request-accept-article group)
7166 (error "%s does not support article importing" group))
7167 (or (file-readable-p file)
7168 (not (file-regular-p file))
7169 (error "Can't read %s" file))
7171 (set-buffer (gnus-get-buffer-create " *import file*"))
7173 (insert-file-contents file)
7174 (goto-char (point-min))
7175 (unless (nnheader-article-p)
7176 ;; This doesn't look like an article, so we fudge some headers.
7177 (setq atts (file-attributes file)
7178 lines (count-lines (point-min) (point-max)))
7179 (insert "From: " (read-string "From: ") "\n"
7180 "Subject: " (read-string "Subject: ") "\n"
7181 "Date: " (message-make-date (nth 5 atts))
7183 "Message-ID: " (message-make-message-id) "\n"
7184 "Lines: " (int-to-string lines) "\n"
7185 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7186 (gnus-request-accept-article group nil t)
7187 (kill-buffer (current-buffer)))))
7189 (defun gnus-summary-article-posted-p ()
7190 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7191 This will be the case if the article has both been mailed and posted."
7193 (let ((id (mail-header-references (gnus-summary-article-header)))
7194 (gnus-override-method
7195 (or gnus-refer-article-method gnus-select-method)))
7196 (if (gnus-request-head id "")
7197 (gnus-message 2 "The current message was found on %s"
7198 gnus-override-method)
7199 (gnus-message 2 "The current message couldn't be found on %s"
7200 gnus-override-method)
7203 (defun gnus-summary-expire-articles (&optional now)
7204 "Expire all articles that are marked as expirable in the current group."
7206 (when (gnus-check-backend-function
7207 'request-expire-articles gnus-newsgroup-name)
7208 ;; This backend supports expiry.
7209 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7210 (expirable (if total
7212 ;; We need to update the info for
7213 ;; this group for `gnus-list-of-read-articles'
7214 ;; to give us the right answer.
7215 (gnus-run-hooks 'gnus-exit-group-hook)
7216 (gnus-summary-update-info)
7217 (gnus-list-of-read-articles gnus-newsgroup-name))
7218 (setq gnus-newsgroup-expirable
7219 (sort gnus-newsgroup-expirable '<))))
7220 (expiry-wait (if now 'immediate
7221 (gnus-group-find-parameter
7222 gnus-newsgroup-name 'expiry-wait)))
7225 ;; There are expirable articles in this group, so we run them
7226 ;; through the expiry process.
7227 (gnus-message 6 "Expiring articles...")
7228 ;; The list of articles that weren't expired is returned.
7231 (let ((nnmail-expiry-wait-function nil)
7232 (nnmail-expiry-wait expiry-wait))
7233 (setq es (gnus-request-expire-articles
7234 expirable gnus-newsgroup-name)))
7235 (setq es (gnus-request-expire-articles
7236 expirable gnus-newsgroup-name))))
7238 (setq gnus-newsgroup-expirable es))
7239 ;; We go through the old list of expirable, and mark all
7240 ;; really expired articles as nonexistent.
7241 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7242 (let ((gnus-use-cache nil))
7244 (unless (memq (car expirable) es)
7245 (when (gnus-data-find (car expirable))
7246 (gnus-summary-mark-article
7247 (car expirable) gnus-canceled-mark)))
7248 (setq expirable (cdr expirable)))))
7249 (gnus-message 6 "Expiring articles...done")))))
7251 (defun gnus-summary-expire-articles-now ()
7252 "Expunge all expirable articles in the current group.
7253 This means that *all* articles that are marked as expirable will be
7254 deleted forever, right now."
7256 (or gnus-expert-user
7258 "Are you really, really, really sure you want to delete all these messages? ")
7260 (gnus-summary-expire-articles t))
7262 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7263 (defun gnus-summary-delete-article (&optional n)
7264 "Delete the N next (mail) articles.
7265 This command actually deletes articles. This is not a marking
7266 command. The article will disappear forever from your life, never to
7268 If N is negative, delete backwards.
7269 If N is nil and articles have been marked with the process mark,
7270 delete these instead."
7272 (unless (gnus-check-backend-function 'request-expire-articles
7273 gnus-newsgroup-name)
7274 (error "The current newsgroup does not support article deletion"))
7275 ;; Compute the list of articles to delete.
7276 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7278 (if (and gnus-novice-user
7279 (not (gnus-yes-or-no-p
7280 (format "Do you really want to delete %s forever? "
7281 (if (> (length articles) 1)
7282 (format "these %s articles" (length articles))
7285 ;; Delete the articles.
7286 (setq not-deleted (gnus-request-expire-articles
7287 articles gnus-newsgroup-name 'force))
7289 (gnus-summary-remove-process-mark (car articles))
7290 ;; The backend might not have been able to delete the article
7292 (unless (memq (car articles) not-deleted)
7293 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7294 (setq articles (cdr articles)))
7296 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7297 (gnus-summary-position-point)
7298 (gnus-set-mode-line 'summary)
7301 (defun gnus-summary-edit-article (&optional force)
7302 "Edit the current article.
7303 This will have permanent effect only in mail groups.
7304 If FORCE is non-nil, allow editing of articles even in read-only
7308 (set-buffer gnus-summary-buffer)
7309 (gnus-set-global-variables)
7310 (when (and (not force)
7311 (gnus-group-read-only-p))
7312 (error "The current newsgroup does not support article editing"))
7313 ;; Select article if needed.
7314 (unless (eq (gnus-summary-article-number)
7315 gnus-current-article)
7316 (gnus-summary-select-article t))
7317 (gnus-article-date-original)
7318 (gnus-article-edit-article
7319 `(lambda (no-highlight)
7320 (gnus-summary-edit-article-done
7321 ,(or (mail-header-references gnus-current-headers) "")
7322 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7324 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7326 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7328 "Make edits to the current article permanent."
7330 ;; Replace the article.
7331 (let ((buf (current-buffer)))
7334 (if (and (not read-only)
7335 (not (gnus-request-replace-article
7336 (cdr gnus-article-current) (car gnus-article-current)
7338 (not gnus-article-decoded-p))))
7339 (error "Couldn't replace article")
7340 ;; Update the summary buffer.
7342 (equal (message-tokenize-header references " ")
7343 (message-tokenize-header
7344 (or (message-fetch-field "references") "") " ")))
7345 ;; We only have to update this line.
7348 (message-narrow-to-head)
7349 (let ((head (buffer-string))
7352 (insert (format "211 %d Article retrieved.\n"
7353 (cdr gnus-article-current)))
7356 (let ((nntp-server-buffer (current-buffer)))
7357 (setq header (car (gnus-get-newsgroup-headers
7359 (set-buffer gnus-summary-buffer)
7360 gnus-newsgroup-dependencies)
7363 (set-buffer gnus-summary-buffer)
7364 (gnus-data-set-header
7365 (gnus-data-find (cdr gnus-article-current))
7367 (gnus-summary-update-article-line
7368 (cdr gnus-article-current) header))))))
7370 (set-buffer (or buffer gnus-summary-buffer))
7371 (gnus-summary-update-article (cdr gnus-article-current)))
7372 ;; Prettify the article buffer again.
7373 (unless no-highlight
7375 (set-buffer gnus-article-buffer)
7376 (gnus-run-hooks 'gnus-article-display-hook)
7377 (set-buffer gnus-original-article-buffer)
7378 (gnus-request-article
7379 (cdr gnus-article-current)
7380 (car gnus-article-current) (current-buffer))))
7381 ;; Prettify the summary buffer line.
7382 (when (gnus-visual-p 'summary-highlight 'highlight)
7383 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7385 (defun gnus-summary-edit-wash (key)
7386 "Perform editing command KEY in the article buffer."
7390 (message "%s" (concat (this-command-keys) "- "))
7393 (gnus-summary-edit-article)
7394 (execute-kbd-macro (concat (this-command-keys) key))
7395 (gnus-article-edit-done))
7399 (defun gnus-summary-respool-query (&optional silent trace)
7400 "Query where the respool algorithm would put this article."
7402 (let (gnus-mark-article-hook)
7403 (gnus-summary-select-article)
7405 (set-buffer gnus-original-article-buffer)
7407 (message-narrow-to-head)
7408 (let ((groups (nnmail-article-group 'identity trace)))
7411 (message "This message would go to %s"
7412 (mapconcat 'car groups ", "))
7413 (message "This message would go to no groups"))
7416 (defun gnus-summary-respool-trace ()
7417 "Trace where the respool algorithm would put this article.
7418 Display a buffer showing all fancy splitting patterns which matched."
7420 (gnus-summary-respool-query nil t))
7422 ;; Summary marking commands.
7424 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7425 "Mark articles which has the same subject as read, and then select the next.
7426 If UNMARK is positive, remove any kind of mark.
7427 If UNMARK is negative, tick articles."
7430 (setq unmark (prefix-numeric-value unmark)))
7432 (gnus-summary-mark-same-subject
7433 (gnus-summary-article-subject) unmark)))
7434 ;; Select next unread article. If auto-select-same mode, should
7435 ;; select the first unread article.
7436 (gnus-summary-next-article t (and gnus-auto-select-same
7437 (gnus-summary-article-subject)))
7438 (gnus-message 7 "%d article%s marked as %s"
7439 count (if (= count 1) " is" "s are")
7440 (if unmark "unread" "read"))))
7442 (defun gnus-summary-kill-same-subject (&optional unmark)
7443 "Mark articles which has the same subject as read.
7444 If UNMARK is positive, remove any kind of mark.
7445 If UNMARK is negative, tick articles."
7448 (setq unmark (prefix-numeric-value unmark)))
7450 (gnus-summary-mark-same-subject
7451 (gnus-summary-article-subject) unmark)))
7452 ;; If marked as read, go to next unread subject.
7454 ;; Go to next unread subject.
7455 (gnus-summary-next-subject 1 t))
7456 (gnus-message 7 "%d articles are marked as %s"
7457 count (if unmark "unread" "read"))))
7459 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7460 "Mark articles with same SUBJECT as read, and return marked number.
7461 If optional argument UNMARK is positive, remove any kinds of marks.
7462 If optional argument UNMARK is negative, mark articles as unread instead."
7466 ((null unmark) ; Mark as read.
7469 (gnus-summary-mark-article-as-read gnus-killed-mark)
7470 (gnus-summary-show-thread) t)
7471 (gnus-summary-find-subject subject))
7472 (setq count (1+ count))))
7473 ((> unmark 0) ; Tick.
7476 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7477 (gnus-summary-show-thread) t)
7478 (gnus-summary-find-subject subject))
7479 (setq count (1+ count))))
7480 (t ; Mark as unread.
7483 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7484 (gnus-summary-show-thread) t)
7485 (gnus-summary-find-subject subject))
7486 (setq count (1+ count)))))
7487 (gnus-set-mode-line 'summary)
7488 ;; Return the number of marked articles.
7491 (defun gnus-summary-mark-as-processable (n &optional unmark)
7492 "Set the process mark on the next N articles.
7493 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7494 the process mark instead. The difference between N and the actual
7495 number of articles marked is returned."
7497 (let ((backward (< n 0))
7502 (gnus-summary-remove-process-mark
7503 (gnus-summary-article-number))
7504 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7505 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7508 (gnus-message 7 "No more articles"))
7509 (gnus-summary-recenter)
7510 (gnus-summary-position-point)
7513 (defun gnus-summary-unmark-as-processable (n)
7514 "Remove the process mark from the next N articles.
7515 If N is negative, unmark backward instead. The difference between N and
7516 the actual number of articles unmarked is returned."
7518 (gnus-summary-mark-as-processable n t))
7520 (defun gnus-summary-unmark-all-processable ()
7521 "Remove the process mark from all articles."
7524 (while gnus-newsgroup-processable
7525 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7526 (gnus-summary-position-point))
7528 (defun gnus-summary-mark-as-expirable (n)
7529 "Mark N articles forward as expirable.
7530 If N is negative, mark backward instead. The difference between N and
7531 the actual number of articles marked is returned."
7533 (gnus-summary-mark-forward n gnus-expirable-mark))
7535 (defun gnus-summary-mark-article-as-replied (article)
7536 "Mark ARTICLE replied and update the summary line."
7537 (push article gnus-newsgroup-replied)
7538 (let ((buffer-read-only nil))
7539 (when (gnus-summary-goto-subject article nil t)
7540 (gnus-summary-update-secondary-mark article))))
7542 (defun gnus-summary-set-bookmark (article)
7543 "Set a bookmark in current article."
7544 (interactive (list (gnus-summary-article-number)))
7545 (when (or (not (get-buffer gnus-article-buffer))
7546 (not gnus-current-article)
7547 (not gnus-article-current)
7548 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7549 (error "No current article selected"))
7550 ;; Remove old bookmark, if one exists.
7551 (let ((old (assq article gnus-newsgroup-bookmarks)))
7553 (setq gnus-newsgroup-bookmarks
7554 (delq old gnus-newsgroup-bookmarks))))
7555 ;; Set the new bookmark, which is on the form
7556 ;; (article-number . line-number-in-body).
7560 (set-buffer gnus-article-buffer)
7564 (goto-char (point-min))
7565 (search-forward "\n\n" nil t)
7568 gnus-newsgroup-bookmarks)
7569 (gnus-message 6 "A bookmark has been added to the current article."))
7571 (defun gnus-summary-remove-bookmark (article)
7572 "Remove the bookmark from the current article."
7573 (interactive (list (gnus-summary-article-number)))
7574 ;; Remove old bookmark, if one exists.
7575 (let ((old (assq article gnus-newsgroup-bookmarks)))
7578 (setq gnus-newsgroup-bookmarks
7579 (delq old gnus-newsgroup-bookmarks))
7580 (gnus-message 6 "Removed bookmark."))
7581 (gnus-message 6 "No bookmark in current article."))))
7583 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7584 (defun gnus-summary-mark-as-dormant (n)
7585 "Mark N articles forward as dormant.
7586 If N is negative, mark backward instead. The difference between N and
7587 the actual number of articles marked is returned."
7589 (gnus-summary-mark-forward n gnus-dormant-mark))
7591 (defun gnus-summary-set-process-mark (article)
7592 "Set the process mark on ARTICLE and update the summary line."
7593 (setq gnus-newsgroup-processable
7595 (delq article gnus-newsgroup-processable)))
7596 (when (gnus-summary-goto-subject article)
7597 (gnus-summary-show-thread)
7598 (gnus-summary-goto-subject article)
7599 (gnus-summary-update-secondary-mark article)))
7601 (defun gnus-summary-remove-process-mark (article)
7602 "Remove the process mark from ARTICLE and update the summary line."
7603 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7604 (when (gnus-summary-goto-subject article)
7605 (gnus-summary-show-thread)
7606 (gnus-summary-goto-subject article)
7607 (gnus-summary-update-secondary-mark article)))
7609 (defun gnus-summary-set-saved-mark (article)
7610 "Set the process mark on ARTICLE and update the summary line."
7611 (push article gnus-newsgroup-saved)
7612 (when (gnus-summary-goto-subject article)
7613 (gnus-summary-update-secondary-mark article)))
7615 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7616 "Mark N articles as read forwards.
7617 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7618 The difference between N and the actual number of articles marked is
7621 (let ((backward (< n 0))
7622 (gnus-summary-goto-unread
7623 (and gnus-summary-goto-unread
7624 (not (eq gnus-summary-goto-unread 'never))
7625 (not (memq mark (list gnus-unread-mark
7626 gnus-ticked-mark gnus-dormant-mark)))))
7628 (mark (or mark gnus-del-mark)))
7630 (gnus-summary-mark-article nil mark no-expire)
7631 (zerop (gnus-summary-next-subject
7633 (and gnus-summary-goto-unread
7634 (not (eq gnus-summary-goto-unread 'never)))
7638 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7639 (gnus-summary-recenter)
7640 (gnus-summary-position-point)
7641 (gnus-set-mode-line 'summary)
7644 (defun gnus-summary-mark-article-as-read (mark)
7645 "Mark the current article quickly as read with MARK."
7646 (let ((article (gnus-summary-article-number)))
7647 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7648 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7649 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7650 (push (cons article mark) gnus-newsgroup-reads)
7651 ;; Possibly remove from cache, if that is used.
7652 (when gnus-use-cache
7653 (gnus-cache-enter-remove-article article))
7654 ;; Allow the backend to change the mark.
7655 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7656 ;; Check for auto-expiry.
7657 (when (and gnus-newsgroup-auto-expire
7658 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7659 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7660 (= mark gnus-ancient-mark)
7661 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7662 (= mark gnus-duplicate-mark)))
7663 (setq mark gnus-expirable-mark)
7664 ;; Let the backend know about the mark change.
7665 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7666 (push article gnus-newsgroup-expirable))
7667 ;; Set the mark in the buffer.
7668 (gnus-summary-update-mark mark 'unread)
7671 (defun gnus-summary-mark-article-as-unread (mark)
7672 "Mark the current article quickly as unread with MARK."
7673 (let* ((article (gnus-summary-article-number))
7674 (old-mark (gnus-summary-article-mark article)))
7675 ;; Allow the backend to change the mark.
7676 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7677 (if (eq mark old-mark)
7681 (gnus-error 1 "Can't mark negative article numbers")
7683 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7684 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7685 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7686 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7687 (cond ((= mark gnus-ticked-mark)
7688 (push article gnus-newsgroup-marked))
7689 ((= mark gnus-dormant-mark)
7690 (push article gnus-newsgroup-dormant))
7692 (push article gnus-newsgroup-unreads)))
7693 (gnus-pull article gnus-newsgroup-reads)
7695 ;; See whether the article is to be put in the cache.
7697 (vectorp (gnus-summary-article-header article))
7699 (gnus-cache-possibly-enter-article
7700 gnus-newsgroup-name article
7701 (gnus-summary-article-header article)
7702 (= mark gnus-ticked-mark)
7703 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7706 (gnus-summary-update-mark mark 'unread)
7709 (defun gnus-summary-mark-article (&optional article mark no-expire)
7710 "Mark ARTICLE with MARK. MARK can be any character.
7711 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7712 `??' (dormant) and `?E' (expirable).
7713 If MARK is nil, then the default character `?D' is used.
7714 If ARTICLE is nil, then the article on the current line will be
7716 ;; The mark might be a string.
7717 (when (stringp mark)
7718 (setq mark (aref mark 0)))
7719 ;; If no mark is given, then we check auto-expiring.
7720 (and (not no-expire)
7721 gnus-newsgroup-auto-expire
7723 (and (gnus-characterp mark)
7724 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7725 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7726 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7727 (= mark gnus-duplicate-mark))))
7728 (setq mark gnus-expirable-mark))
7729 (let* ((mark (or mark gnus-del-mark))
7730 (article (or article (gnus-summary-article-number)))
7731 (old-mark (gnus-summary-article-mark article)))
7732 ;; Allow the backend to change the mark.
7733 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7734 (if (eq mark old-mark)
7737 (error "No article on current line"))
7738 (if (not (if (or (= mark gnus-unread-mark)
7739 (= mark gnus-ticked-mark)
7740 (= mark gnus-dormant-mark))
7741 (gnus-mark-article-as-unread article mark)
7742 (gnus-mark-article-as-read article mark)))
7744 ;; See whether the article is to be put in the cache.
7746 (not (= mark gnus-canceled-mark))
7747 (vectorp (gnus-summary-article-header article))
7749 (gnus-cache-possibly-enter-article
7750 gnus-newsgroup-name article
7751 (gnus-summary-article-header article)
7752 (= mark gnus-ticked-mark)
7753 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7755 (when (gnus-summary-goto-subject article nil t)
7756 (let ((buffer-read-only nil))
7757 (gnus-summary-show-thread)
7759 (gnus-summary-update-mark mark 'unread)
7762 (defun gnus-summary-update-secondary-mark (article)
7763 "Update the secondary (read, process, cache) mark."
7764 (gnus-summary-update-mark
7765 (cond ((memq article gnus-newsgroup-processable)
7767 ((memq article gnus-newsgroup-cached)
7769 ((memq article gnus-newsgroup-replied)
7771 ((memq article gnus-newsgroup-saved)
7773 (t gnus-unread-mark))
7775 (when (gnus-visual-p 'summary-highlight 'highlight)
7776 (gnus-run-hooks 'gnus-summary-update-hook))
7779 (defun gnus-summary-update-mark (mark type)
7780 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7781 (buffer-read-only nil))
7782 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7783 (when (looking-at "\r")
7786 (<= (+ forward (point)) (point-max)))
7787 ;; Go to the right position on the line.
7788 (goto-char (+ forward (point)))
7789 ;; Replace the old mark with the new mark.
7790 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7791 ;; Optionally update the marks by some user rule.
7792 (when (eq type 'unread)
7794 (gnus-data-find (gnus-summary-article-number)) mark)
7795 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7797 (defun gnus-mark-article-as-read (article &optional mark)
7798 "Enter ARTICLE in the pertinent lists and remove it from others."
7799 ;; Make the article expirable.
7800 (let ((mark (or mark gnus-del-mark)))
7801 (if (= mark gnus-expirable-mark)
7802 (push article gnus-newsgroup-expirable)
7803 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7804 ;; Remove from unread and marked lists.
7805 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7806 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7807 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7808 (push (cons article mark) gnus-newsgroup-reads)
7809 ;; Possibly remove from cache, if that is used.
7810 (when gnus-use-cache
7811 (gnus-cache-enter-remove-article article))
7814 (defun gnus-mark-article-as-unread (article &optional mark)
7815 "Enter ARTICLE in the pertinent lists and remove it from others."
7816 (let ((mark (or mark gnus-ticked-mark)))
7819 (gnus-error 1 "Can't mark negative article numbers")
7821 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7822 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7823 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7824 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7826 ;; Unsuppress duplicates?
7827 (when gnus-suppress-duplicates
7828 (gnus-dup-unsuppress-article article))
7830 (cond ((= mark gnus-ticked-mark)
7831 (push article gnus-newsgroup-marked))
7832 ((= mark gnus-dormant-mark)
7833 (push article gnus-newsgroup-dormant))
7835 (push article gnus-newsgroup-unreads)))
7836 (gnus-pull article gnus-newsgroup-reads)
7839 (defalias 'gnus-summary-mark-as-unread-forward
7840 'gnus-summary-tick-article-forward)
7841 (make-obsolete 'gnus-summary-mark-as-unread-forward
7842 'gnus-summary-tick-article-forward)
7843 (defun gnus-summary-tick-article-forward (n)
7844 "Tick N articles forwards.
7845 If N is negative, tick backwards instead.
7846 The difference between N and the number of articles ticked is returned."
7848 (gnus-summary-mark-forward n gnus-ticked-mark))
7850 (defalias 'gnus-summary-mark-as-unread-backward
7851 'gnus-summary-tick-article-backward)
7852 (make-obsolete 'gnus-summary-mark-as-unread-backward
7853 'gnus-summary-tick-article-backward)
7854 (defun gnus-summary-tick-article-backward (n)
7855 "Tick N articles backwards.
7856 The difference between N and the number of articles ticked is returned."
7858 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7860 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7861 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7862 (defun gnus-summary-tick-article (&optional article clear-mark)
7863 "Mark current article as unread.
7864 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7865 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7867 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7870 (defun gnus-summary-mark-as-read-forward (n)
7871 "Mark N articles as read forwards.
7872 If N is negative, mark backwards instead.
7873 The difference between N and the actual number of articles marked is
7876 (gnus-summary-mark-forward n gnus-del-mark t))
7878 (defun gnus-summary-mark-as-read-backward (n)
7879 "Mark the N articles as read backwards.
7880 The difference between N and the actual number of articles marked is
7883 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7885 (defun gnus-summary-mark-as-read (&optional article mark)
7886 "Mark current article as read.
7887 ARTICLE specifies the article to be marked as read.
7888 MARK specifies a string to be inserted at the beginning of the line."
7889 (gnus-summary-mark-article article mark))
7891 (defun gnus-summary-clear-mark-forward (n)
7892 "Clear marks from N articles forward.
7893 If N is negative, clear backward instead.
7894 The difference between N and the number of marks cleared is returned."
7896 (gnus-summary-mark-forward n gnus-unread-mark))
7898 (defun gnus-summary-clear-mark-backward (n)
7899 "Clear marks from N articles backward.
7900 The difference between N and the number of marks cleared is returned."
7902 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7904 (defun gnus-summary-mark-unread-as-read ()
7905 "Intended to be used by `gnus-summary-mark-article-hook'."
7906 (when (memq gnus-current-article gnus-newsgroup-unreads)
7907 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7909 (defun gnus-summary-mark-read-and-unread-as-read ()
7910 "Intended to be used by `gnus-summary-mark-article-hook'."
7911 (let ((mark (gnus-summary-article-mark)))
7912 (when (or (gnus-unread-mark-p mark)
7913 (gnus-read-mark-p mark))
7914 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7916 (defun gnus-summary-mark-region-as-read (point mark all)
7917 "Mark all unread articles between point and mark as read.
7918 If given a prefix, mark all articles between point and mark as read,
7919 even ticked and dormant ones."
7920 (interactive "r\nP")
7929 (memq (setq article (gnus-summary-article-number))
7930 gnus-newsgroup-unreads))
7931 (gnus-summary-mark-article article gnus-del-mark))
7933 (gnus-summary-find-next))))))
7935 (defun gnus-summary-mark-below (score mark)
7936 "Mark articles with score less than SCORE with MARK."
7937 (interactive "P\ncMark: ")
7938 (setq score (if score
7939 (prefix-numeric-value score)
7940 (or gnus-summary-default-score 0)))
7942 (set-buffer gnus-summary-buffer)
7943 (goto-char (point-min))
7946 (and (< (gnus-summary-article-score) score)
7947 (gnus-summary-mark-article nil mark))
7948 (gnus-summary-find-next)))))
7950 (defun gnus-summary-kill-below (&optional score)
7951 "Mark articles with score below SCORE as read."
7953 (gnus-summary-mark-below score gnus-killed-mark))
7955 (defun gnus-summary-clear-above (&optional score)
7956 "Clear all marks from articles with score above SCORE."
7958 (gnus-summary-mark-above score gnus-unread-mark))
7960 (defun gnus-summary-tick-above (&optional score)
7961 "Tick all articles with score above SCORE."
7963 (gnus-summary-mark-above score gnus-ticked-mark))
7965 (defun gnus-summary-mark-above (score mark)
7966 "Mark articles with score over SCORE with MARK."
7967 (interactive "P\ncMark: ")
7968 (setq score (if score
7969 (prefix-numeric-value score)
7970 (or gnus-summary-default-score 0)))
7972 (set-buffer gnus-summary-buffer)
7973 (goto-char (point-min))
7975 (when (> (gnus-summary-article-score) score)
7976 (gnus-summary-mark-article nil mark))
7978 (gnus-summary-find-next)))))
7980 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7981 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7982 (defun gnus-summary-limit-include-expunged (&optional no-error)
7983 "Display all the hidden articles that were expunged for low scores."
7985 (let ((buffer-read-only nil))
7986 (let ((scored gnus-newsgroup-scored)
7989 (unless (gnus-summary-goto-subject (caar scored))
7990 (and (setq h (gnus-summary-article-header (caar scored)))
7991 (< (cdar scored) gnus-summary-expunge-below)
7993 (setq scored (cdr scored)))
7995 (when (not no-error)
7996 (error "No expunged articles hidden"))
7997 (goto-char (point-min))
7998 (gnus-summary-prepare-unthreaded (nreverse headers))
7999 (goto-char (point-min))
8000 (gnus-summary-position-point)
8003 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8004 "Mark all unread articles in this newsgroup as read.
8005 If prefix argument ALL is non-nil, ticked and dormant articles will
8006 also be marked as read.
8007 If QUIETLY is non-nil, no questions will be asked.
8008 If TO-HERE is non-nil, it should be a point in the buffer. All
8009 articles before this point will be marked as read.
8010 Note that this function will only catch up the unread article
8011 in the current summary buffer limitation.
8012 The number of articles marked as read is returned."
8017 (not gnus-interactive-catchup) ;Without confirmation?
8021 "Mark absolutely all articles as read? "
8022 "Mark all unread articles as read? ")))
8024 (not gnus-newsgroup-adaptive)
8025 (not gnus-newsgroup-auto-expire)
8026 (not gnus-suppress-duplicates)
8027 (or (not gnus-use-cache)
8028 (eq gnus-use-cache 'passive)))
8031 (setq gnus-newsgroup-marked nil
8032 gnus-newsgroup-dormant nil))
8033 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8034 ;; We actually mark all articles as canceled, which we
8035 ;; have to do when using auto-expiry or adaptive scoring.
8036 (gnus-summary-show-all-threads)
8037 (when (gnus-summary-first-subject (not all) t)
8039 (if to-here (< (point) to-here) t)
8040 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8041 (gnus-summary-find-next (not all) nil nil t))))
8042 (gnus-set-mode-line 'summary))
8044 (gnus-summary-position-point)))
8046 (defun gnus-summary-catchup-to-here (&optional all)
8047 "Mark all unticked articles before the current one as read.
8048 If ALL is non-nil, also mark ticked and dormant articles as read."
8051 (gnus-save-hidden-threads
8052 (let ((beg (point)))
8053 ;; We check that there are unread articles.
8054 (when (or all (gnus-summary-find-prev))
8055 (gnus-summary-catchup all t beg)))))
8056 (gnus-summary-position-point))
8058 (defun gnus-summary-catchup-all (&optional quietly)
8059 "Mark all articles in this newsgroup as read."
8061 (gnus-summary-catchup t quietly))
8063 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8064 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8065 If prefix argument ALL is non-nil, all articles are marked as read."
8067 (when (gnus-summary-catchup all quietly nil 'fast)
8068 ;; Select next newsgroup or exit.
8069 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8070 (eq gnus-auto-select-next 'quietly))
8071 (gnus-summary-next-group nil)
8072 (gnus-summary-exit))))
8074 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8075 "Mark all articles in this newsgroup as read, and then exit."
8077 (gnus-summary-catchup-and-exit t quietly))
8079 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8080 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8081 "Mark all articles in this group as read and select the next group.
8082 If given a prefix, mark all articles, unread as well as ticked, as
8086 (gnus-summary-catchup all))
8087 (gnus-summary-next-article t nil nil t))
8089 ;; Thread-based commands.
8091 (defun gnus-summary-articles-in-thread (&optional article)
8092 "Return a list of all articles in the current thread.
8093 If ARTICLE is non-nil, return all articles in the thread that starts
8095 (let* ((article (or article (gnus-summary-article-number)))
8096 (data (gnus-data-find-list article))
8097 (top-level (gnus-data-level (car data)))
8099 (cond ((null gnus-thread-operation-ignore-subject)
8100 (gnus-simplify-subject-re
8101 (mail-header-subject (gnus-data-header (car data)))))
8102 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8103 (gnus-simplify-subject-fuzzy
8104 (mail-header-subject (gnus-data-header (car data)))))
8106 (end-point (save-excursion
8107 (if (gnus-summary-go-to-next-thread)
8108 (point) (point-max))))
8111 (< (gnus-data-pos (car data)) end-point))
8112 (when (or (not top-subject)
8113 (string= top-subject
8114 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8115 (gnus-simplify-subject-fuzzy
8116 (mail-header-subject
8117 (gnus-data-header (car data))))
8118 (gnus-simplify-subject-re
8119 (mail-header-subject
8120 (gnus-data-header (car data)))))))
8121 (push (gnus-data-number (car data)) articles))
8122 (unless (and (setq data (cdr data))
8123 (> (gnus-data-level (car data)) top-level))
8125 ;; Return the list of articles.
8126 (nreverse articles)))
8128 (defun gnus-summary-rethread-current ()
8129 "Rethread the thread the current article is part of."
8131 (let* ((gnus-show-threads t)
8132 (article (gnus-summary-article-number))
8133 (id (mail-header-id (gnus-summary-article-header)))
8134 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8136 (error "No article on the current line"))
8137 (gnus-rebuild-thread id)
8138 (gnus-summary-goto-subject article)))
8140 (defun gnus-summary-reparent-thread ()
8141 "Make the current article child of the marked (or previous) article.
8143 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8144 is non-nil or the Subject: of both articles are the same."
8146 (unless (not (gnus-group-read-only-p))
8147 (error "The current newsgroup does not support article editing"))
8148 (unless (<= (length gnus-newsgroup-processable) 1)
8149 (error "No more than one article may be marked"))
8150 (save-window-excursion
8151 (let ((gnus-article-buffer " *reparent*")
8152 (current-article (gnus-summary-article-number))
8153 ;; First grab the marked article, otherwise one line up.
8154 (parent-article (if (not (null gnus-newsgroup-processable))
8155 (car gnus-newsgroup-processable)
8157 (if (eq (forward-line -1) 0)
8158 (gnus-summary-article-number)
8159 (error "Beginning of summary buffer"))))))
8160 (unless (not (eq current-article parent-article))
8161 (error "An article may not be self-referential"))
8162 (let ((message-id (mail-header-id
8163 (gnus-summary-article-header parent-article))))
8164 (unless (and message-id (not (equal message-id "")))
8165 (error "No message-id in desired parent"))
8166 ;; We don't want the article to be marked as read.
8167 (let (gnus-mark-article-hook)
8168 (gnus-summary-select-article t t nil current-article))
8169 (set-buffer gnus-original-article-buffer)
8170 (let ((buf (format "%s" (buffer-string))))
8173 (goto-char (point-min))
8174 (if (re-search-forward "^References: " nil t)
8176 (re-search-forward "^[^ \t]" nil t)
8179 (insert " " message-id))
8180 (insert "References: " message-id "\n"))
8181 (unless (gnus-request-replace-article
8182 current-article (car gnus-article-current)
8184 (error "Couldn't replace article"))))
8185 (set-buffer gnus-summary-buffer)
8186 (gnus-summary-unmark-all-processable)
8187 (gnus-summary-update-article current-article)
8188 (gnus-summary-rethread-current)
8189 (gnus-message 3 "Article %d is now the child of article %d"
8190 current-article parent-article)))))
8192 (defun gnus-summary-toggle-threads (&optional arg)
8193 "Toggle showing conversation threads.
8194 If ARG is positive number, turn showing conversation threads on."
8196 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8197 (setq gnus-show-threads
8198 (if (null arg) (not gnus-show-threads)
8199 (> (prefix-numeric-value arg) 0)))
8200 (gnus-summary-prepare)
8201 (gnus-summary-goto-subject current)
8202 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8203 (gnus-summary-position-point)))
8205 (defun gnus-summary-show-all-threads ()
8209 (let ((buffer-read-only nil))
8210 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8211 (gnus-summary-position-point))
8213 (defun gnus-summary-show-thread ()
8214 "Show thread subtrees.
8215 Returns nil if no thread was there to be shown."
8217 (let ((buffer-read-only nil)
8219 ;; first goto end then to beg, to have point at beg after let
8220 (end (progn (end-of-line) (point)))
8221 (beg (progn (beginning-of-line) (point))))
8223 ;; Any hidden lines here?
8224 (search-forward "\r" end t)
8225 (subst-char-in-region beg end ?\^M ?\n t)
8227 (gnus-summary-position-point))))
8229 (defun gnus-summary-hide-all-threads ()
8230 "Hide all thread subtrees."
8233 (goto-char (point-min))
8234 (gnus-summary-hide-thread)
8235 (while (zerop (gnus-summary-next-thread 1 t))
8236 (gnus-summary-hide-thread)))
8237 (gnus-summary-position-point))
8239 (defun gnus-summary-hide-thread ()
8240 "Hide thread subtrees.
8241 Returns nil if no threads were there to be hidden."
8243 (let ((buffer-read-only nil)
8245 (article (gnus-summary-article-number)))
8247 ;; Go forward until either the buffer ends or the subthread
8249 (when (and (not (eobp))
8250 (or (zerop (gnus-summary-next-thread 1 t))
8251 (goto-char (point-max))))
8253 (if (and (> (point) start)
8254 (search-backward "\n" start t))
8256 (subst-char-in-region start (point) ?\n ?\^M)
8257 (gnus-summary-goto-subject article))
8260 ;;(gnus-summary-position-point)
8263 (defun gnus-summary-go-to-next-thread (&optional previous)
8264 "Go to the same level (or less) next thread.
8265 If PREVIOUS is non-nil, go to previous thread instead.
8266 Return the article number moved to, or nil if moving was impossible."
8267 (let ((level (gnus-summary-thread-level))
8268 (way (if previous -1 1))
8271 (while (and (not (eobp))
8272 (< level (gnus-summary-thread-level)))
8280 (gnus-summary-article-number)
8283 (defun gnus-summary-next-thread (n &optional silent)
8284 "Go to the same level next N'th thread.
8285 If N is negative, search backward instead.
8286 Returns the difference between N and the number of skips actually
8289 If SILENT, don't output messages."
8291 (let ((backward (< n 0))
8294 (gnus-summary-go-to-next-thread backward))
8297 (gnus-summary-position-point))
8298 (when (and (not silent) (/= 0 n))
8299 (gnus-message 7 "No more threads"))
8302 (defun gnus-summary-prev-thread (n)
8303 "Go to the same level previous N'th thread.
8304 Returns the difference between N and the number of skips actually
8307 (gnus-summary-next-thread (- n)))
8309 (defun gnus-summary-go-down-thread ()
8310 "Go down one level in the current thread."
8311 (let ((children (gnus-summary-article-children)))
8313 (gnus-summary-goto-subject (car children)))))
8315 (defun gnus-summary-go-up-thread ()
8316 "Go up one level in the current thread."
8317 (let ((parent (gnus-summary-article-parent)))
8319 (gnus-summary-goto-subject parent))))
8321 (defun gnus-summary-down-thread (n)
8322 "Go down thread N steps.
8323 If N is negative, go up instead.
8324 Returns the difference between N and how many steps down that were
8330 (if up (gnus-summary-go-up-thread)
8331 (gnus-summary-go-down-thread)))
8333 (gnus-summary-position-point)
8335 (gnus-message 7 "Can't go further"))
8338 (defun gnus-summary-up-thread (n)
8339 "Go up thread N steps.
8340 If N is negative, go up instead.
8341 Returns the difference between N and how many steps down that were
8344 (gnus-summary-down-thread (- n)))
8346 (defun gnus-summary-top-thread ()
8347 "Go to the top of the thread."
8349 (while (gnus-summary-go-up-thread))
8350 (gnus-summary-article-number))
8352 (defun gnus-summary-kill-thread (&optional unmark)
8353 "Mark articles under current thread as read.
8354 If the prefix argument is positive, remove any kinds of marks.
8355 If the prefix argument is negative, tick articles instead."
8358 (setq unmark (prefix-numeric-value unmark)))
8359 (let ((articles (gnus-summary-articles-in-thread)))
8361 ;; Expand the thread.
8362 (gnus-summary-show-thread)
8363 ;; Mark all the articles.
8365 (gnus-summary-goto-subject (car articles))
8366 (cond ((null unmark)
8367 (gnus-summary-mark-article-as-read gnus-killed-mark))
8369 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8371 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8372 (setq articles (cdr articles))))
8373 ;; Hide killed subtrees.
8375 gnus-thread-hide-killed
8376 (gnus-summary-hide-thread))
8377 ;; If marked as read, go to next unread subject.
8379 ;; Go to next unread subject.
8380 (gnus-summary-next-subject 1 t)))
8381 (gnus-set-mode-line 'summary))
8383 ;; Summary sorting commands
8385 (defun gnus-summary-sort-by-number (&optional reverse)
8386 "Sort the summary buffer by article number.
8387 Argument REVERSE means reverse order."
8389 (gnus-summary-sort 'number reverse))
8391 (defun gnus-summary-sort-by-author (&optional reverse)
8392 "Sort the summary buffer by author name alphabetically.
8393 If case-fold-search is non-nil, case of letters is ignored.
8394 Argument REVERSE means reverse order."
8396 (gnus-summary-sort 'author reverse))
8398 (defun gnus-summary-sort-by-subject (&optional reverse)
8399 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8400 If case-fold-search is non-nil, case of letters is ignored.
8401 Argument REVERSE means reverse order."
8403 (gnus-summary-sort 'subject reverse))
8405 (defun gnus-summary-sort-by-date (&optional reverse)
8406 "Sort the summary buffer by date.
8407 Argument REVERSE means reverse order."
8409 (gnus-summary-sort 'date reverse))
8411 (defun gnus-summary-sort-by-score (&optional reverse)
8412 "Sort the summary buffer by score.
8413 Argument REVERSE means reverse order."
8415 (gnus-summary-sort 'score reverse))
8417 (defun gnus-summary-sort-by-lines (&optional reverse)
8418 "Sort the summary buffer by article length.
8419 Argument REVERSE means reverse order."
8421 (gnus-summary-sort 'lines reverse))
8423 (defun gnus-summary-sort (predicate reverse)
8424 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8425 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8426 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8427 (gnus-thread-sort-functions
8433 (gnus-article-sort-functions
8438 (,article t2 t1)))))
8440 (gnus-summary-prepare-hook nil))
8441 ;; We do the sorting by regenerating the threads.
8442 (gnus-summary-prepare)
8443 ;; Hide subthreads if needed.
8444 (when (and gnus-show-threads gnus-thread-hide-subtree)
8445 (gnus-summary-hide-all-threads))))
8447 ;; Summary saving commands.
8449 (defun gnus-summary-save-article (&optional n not-saved)
8450 "Save the current article using the default saver function.
8451 If N is a positive number, save the N next articles.
8452 If N is a negative number, save the N previous articles.
8453 If N is nil and any articles have been marked with the process mark,
8454 save those articles instead.
8455 The variable `gnus-default-article-saver' specifies the saver function."
8457 (let* ((articles (gnus-summary-work-articles n))
8458 (save-buffer (save-excursion
8459 (nnheader-set-temp-buffer " *Gnus Save*")))
8460 (num (length articles))
8461 header article file)
8463 (setq header (gnus-summary-article-header
8464 (setq article (pop articles))))
8465 (if (not (vectorp header))
8466 ;; This is a pseudo-article.
8467 (if (assq 'name header)
8468 (gnus-copy-file (cdr (assq 'name header)))
8469 (gnus-message 1 "Article %d is unsaveable" article))
8470 ;; This is a real article.
8471 (save-window-excursion
8472 (gnus-summary-select-article t nil nil article))
8474 (set-buffer save-buffer)
8476 (insert-buffer-substring gnus-original-article-buffer))
8477 (setq file (gnus-article-save save-buffer file num))
8478 (gnus-summary-remove-process-mark article)
8480 (gnus-summary-set-saved-mark article))))
8481 (gnus-kill-buffer save-buffer)
8482 (gnus-summary-position-point)
8483 (gnus-set-mode-line 'summary)
8486 (defun gnus-summary-pipe-output (&optional arg)
8487 "Pipe the current article to a subprocess.
8488 If N is a positive number, pipe the N next articles.
8489 If N is a negative number, pipe the N previous articles.
8490 If N is nil and any articles have been marked with the process mark,
8491 pipe those articles instead."
8493 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8494 (gnus-summary-save-article arg t))
8495 (gnus-configure-windows 'pipe))
8497 (defun gnus-summary-save-article-mail (&optional arg)
8498 "Append the current article to an mail file.
8499 If N is a positive number, save the N next articles.
8500 If N is a negative number, save the N previous articles.
8501 If N is nil and any articles have been marked with the process mark,
8502 save those articles instead."
8504 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8505 (gnus-summary-save-article arg)))
8507 (defun gnus-summary-save-article-rmail (&optional arg)
8508 "Append the current article to an rmail file.
8509 If N is a positive number, save the N next articles.
8510 If N is a negative number, save the N previous articles.
8511 If N is nil and any articles have been marked with the process mark,
8512 save those articles instead."
8514 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8515 (gnus-summary-save-article arg)))
8517 (defun gnus-summary-save-article-file (&optional arg)
8518 "Append the current article to a file.
8519 If N is a positive number, save the N next articles.
8520 If N is a negative number, save the N previous articles.
8521 If N is nil and any articles have been marked with the process mark,
8522 save those articles instead."
8524 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8525 (gnus-summary-save-article arg)))
8527 (defun gnus-summary-write-article-file (&optional arg)
8528 "Write the current article to a file, deleting the previous file.
8529 If N is a positive number, save the N next articles.
8530 If N is a negative number, save the N previous articles.
8531 If N is nil and any articles have been marked with the process mark,
8532 save those articles instead."
8534 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8535 (gnus-summary-save-article arg)))
8537 (defun gnus-summary-save-article-body-file (&optional arg)
8538 "Append the current article body to a file.
8539 If N is a positive number, save the N next articles.
8540 If N is a negative number, save the N previous articles.
8541 If N is nil and any articles have been marked with the process mark,
8542 save those articles instead."
8544 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8545 (gnus-summary-save-article arg)))
8547 (defun gnus-summary-pipe-message (program)
8548 "Pipe the current article through PROGRAM."
8549 (interactive "sProgram: ")
8550 (gnus-summary-select-article)
8551 (let ((mail-header-separator ""))
8552 (gnus-eval-in-buffer-window gnus-article-buffer
8555 (let ((start (window-start))
8557 (message-pipe-buffer-body program)
8558 (set-window-start (get-buffer-window (current-buffer)) start))))))
8560 (defun gnus-get-split-value (methods)
8561 "Return a value based on the split METHODS."
8562 (let (split-name method result match)
8565 (set-buffer gnus-original-article-buffer)
8567 (nnheader-narrow-to-headers)
8569 (goto-char (point-min))
8570 (setq method (pop methods))
8571 (setq match (car method))
8574 ;; Regular expression.
8576 (re-search-forward match nil t)))
8577 ((gnus-functionp match)
8581 (setq result (funcall match gnus-newsgroup-name))))
8586 (setq result (eval match)))))
8587 (setq split-name (append (cdr method) split-name))
8588 (cond ((stringp result)
8589 (push (expand-file-name
8590 result gnus-article-save-directory)
8593 (setq split-name (append result split-name)))))))))
8596 (defun gnus-valid-move-group-p (group)
8601 (car (gnus-find-method-for-group
8602 (symbol-name group))))
8603 gnus-valid-select-methods))))
8605 (defun gnus-read-move-group-name (prompt default articles prefix)
8606 "Read a group name."
8607 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8608 (minibuffer-confirm-incomplete nil) ; XEmacs
8612 (if (> (length articles) 1)
8613 (format "these %d articles" (length articles))
8618 (gnus-completing-read default prom
8620 'gnus-valid-move-group-p
8622 'gnus-group-history))
8623 ((= 1 (length split-name))
8624 (gnus-completing-read (car split-name) prom
8626 'gnus-valid-move-group-p
8628 'gnus-group-history))
8630 (gnus-completing-read nil prom
8631 (mapcar (lambda (el) (list el))
8632 (nreverse split-name))
8634 'gnus-group-history)))))
8636 (if (or (string= to-newsgroup "")
8637 (string= to-newsgroup prefix))
8638 (setq to-newsgroup default))
8639 (unless to-newsgroup
8640 (error "No group name entered"))
8641 (or (gnus-active to-newsgroup)
8642 (gnus-activate-group to-newsgroup)
8643 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8645 (or (and (gnus-request-create-group
8646 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8647 (gnus-activate-group to-newsgroup nil nil
8648 (gnus-group-name-to-method
8650 (error "Couldn't create group %s" to-newsgroup)))
8651 (error "No such group: %s" to-newsgroup)))
8654 ;; Summary extract commands
8656 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8657 (let ((buffer-read-only nil)
8658 (article (gnus-summary-article-number))
8660 (unless (gnus-summary-goto-subject article)
8661 (error "No such article: %d" article))
8662 (gnus-summary-position-point)
8663 ;; If all commands are to be bunched up on one line, we collect
8665 (unless gnus-view-pseudos-separately
8666 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8669 (setq action (cdr (assq 'action (car ps))))
8670 (setq files (list (cdr (assq 'name (car ps)))))
8671 (while (and ps (cdr ps)
8672 (string= (or action "1")
8673 (or (cdr (assq 'action (cadr ps))) "2")))
8674 (push (cdr (assq 'name (cadr ps))) files)
8675 (setcdr ps (cddr ps)))
8677 (when (not (string-match "%s" action))
8680 (when (assq 'execute (car ps))
8681 (setcdr (assq 'execute (car ps))
8682 (funcall (if (string-match "%s" action)
8691 (setq ps (cdr ps)))))
8692 (if (and gnus-view-pseudos (not not-view))
8694 (when (assq 'execute (car pslist))
8695 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8696 (eq gnus-view-pseudos 'not-confirm)))
8697 (setq pslist (cdr pslist)))
8700 (setq after-article (or (cdr (assq 'article (car pslist)))
8701 (gnus-summary-article-number)))
8702 (gnus-summary-goto-subject after-article)
8705 (insert " " (file-name-nondirectory
8706 (cdr (assq 'name (car pslist))))
8707 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8709 (forward-line -1) ; back to `b'
8710 (gnus-add-text-properties
8711 b (1- e) (list 'gnus-number gnus-reffed-article-number
8712 gnus-mouse-face-prop gnus-mouse-face))
8714 after-article gnus-reffed-article-number
8715 gnus-unread-mark b (car pslist) 0 (- e b))
8716 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8717 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8718 (setq pslist (cdr pslist)))))))
8720 (defun gnus-pseudos< (p1 p2)
8721 (let ((c1 (cdr (assq 'action p1)))
8722 (c2 (cdr (assq 'action p2))))
8723 (and c1 c2 (string< c1 c2))))
8725 (defun gnus-request-pseudo-article (props)
8726 (cond ((assq 'execute props)
8727 (gnus-execute-command (cdr (assq 'execute props)))))
8728 (let ((gnus-current-article (gnus-summary-article-number)))
8729 (gnus-run-hooks 'gnus-mark-article-hook)))
8731 (defun gnus-execute-command (command &optional automatic)
8733 (gnus-article-setup-buffer)
8734 (set-buffer gnus-article-buffer)
8735 (setq buffer-read-only nil)
8736 (let ((command (if automatic command
8737 (read-string "Command: " (cons command 0)))))
8739 (insert "$ " command "\n\n")
8740 (if gnus-view-pseudo-asynchronously
8741 (start-process "gnus-execute" (current-buffer) shell-file-name
8742 shell-command-switch command)
8743 (call-process shell-file-name nil t nil
8744 shell-command-switch command)))))
8746 ;; Summary kill commands.
8748 (defun gnus-summary-edit-global-kill (article)
8749 "Edit the \"global\" kill file."
8750 (interactive (list (gnus-summary-article-number)))
8751 (gnus-group-edit-global-kill article))
8753 (defun gnus-summary-edit-local-kill ()
8754 "Edit a local kill file applied to the current newsgroup."
8756 (setq gnus-current-headers (gnus-summary-article-header))
8757 (gnus-group-edit-local-kill
8758 (gnus-summary-article-number) gnus-newsgroup-name))
8762 (defun gnus-read-header (id &optional header)
8763 "Read the headers of article ID and enter them into the Gnus system."
8764 (let ((group gnus-newsgroup-name)
8765 (gnus-override-method
8766 (and (gnus-news-group-p gnus-newsgroup-name)
8767 gnus-refer-article-method))
8769 ;; First we check to see whether the header in question is already
8772 ;; This is a Message-ID.
8773 (setq header (or header (gnus-id-to-header id)))
8774 ;; This is an article number.
8775 (setq header (or header (gnus-summary-article-header id))))
8777 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8778 ;; We have found the header.
8780 ;; If this is a sparse article, we have to nix out its
8781 ;; previous entry in the thread hashtb.
8783 (gnus-summary-article-sparse-p (mail-header-number header)))
8784 (let* ((parent (gnus-parent-id (mail-header-references header)))
8785 (thread (and parent (gnus-id-to-thread parent))))
8787 (delq (assq header thread) thread))))
8788 ;; We have to really fetch the header to this article.
8790 (set-buffer nntp-server-buffer)
8791 (when (setq where (gnus-request-head id group))
8792 (nnheader-fold-continuation-lines)
8793 (goto-char (point-max))
8795 (goto-char (point-min))
8799 ((cdr where) (cdr where))
8800 (header (mail-header-number header))
8801 (t gnus-reffed-article-number))
8803 (insert " Article retrieved.\n"))
8805 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8806 () ; Malformed head.
8807 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8808 (when (and (stringp id)
8809 (not (string= (gnus-group-real-name group)
8811 ;; If we fetched by Message-ID and the article came
8812 ;; from a different group, we fudge some bogus article
8813 ;; numbers for this article.
8814 (mail-header-set-number header gnus-reffed-article-number))
8816 (set-buffer gnus-summary-buffer)
8817 (decf gnus-reffed-article-number)
8818 (gnus-remove-header (mail-header-number header))
8819 (push header gnus-newsgroup-headers)
8820 (setq gnus-current-headers header)
8821 (push (mail-header-number header) gnus-newsgroup-limit)))
8824 (defun gnus-remove-header (number)
8825 "Remove header NUMBER from `gnus-newsgroup-headers'."
8826 (if (and gnus-newsgroup-headers
8827 (= number (mail-header-number (car gnus-newsgroup-headers))))
8828 (pop gnus-newsgroup-headers)
8829 (let ((headers gnus-newsgroup-headers))
8830 (while (and (cdr headers)
8831 (not (= number (mail-header-number (cadr headers)))))
8834 (setcdr headers (cddr headers))))))
8837 ;;; summary highlights
8840 (defun gnus-highlight-selected-summary ()
8841 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8842 ;; Highlight selected article in summary buffer
8843 (when gnus-summary-selected-face
8845 (let* ((beg (progn (beginning-of-line) (point)))
8846 (end (progn (end-of-line) (point)))
8847 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8848 (from (if (get-text-property beg gnus-mouse-face-prop)
8850 (or (next-single-property-change
8851 beg gnus-mouse-face-prop nil end)
8856 (or (next-single-property-change
8857 from gnus-mouse-face-prop nil end)
8859 ;; If no mouse-face prop on line we will have to = from = end,
8860 ;; so we highlight the entire line instead.
8861 (when (= (+ to 2) from)
8864 (if gnus-newsgroup-selected-overlay
8865 ;; Move old overlay.
8867 gnus-newsgroup-selected-overlay from to (current-buffer))
8868 ;; Create new overlay.
8870 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8871 'face gnus-summary-selected-face))))))
8873 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8874 (defun gnus-summary-highlight-line ()
8875 "Highlight current line according to `gnus-summary-highlight'."
8876 (let* ((list gnus-summary-highlight)
8878 (end (progn (end-of-line) (point)))
8879 ;; now find out where the line starts and leave point there.
8880 (beg (progn (beginning-of-line) (point)))
8881 (article (gnus-summary-article-number))
8882 (score (or (cdr (assq (or article gnus-current-article)
8883 gnus-newsgroup-scored))
8884 gnus-summary-default-score 0))
8885 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8886 (inhibit-read-only t))
8887 ;; Eval the cars of the lists until we find a match.
8888 (let ((default gnus-summary-default-score))
8890 (not (eval (caar list))))
8891 (setq list (cdr list))))
8892 (let ((face (cdar list)))
8893 (unless (eq face (get-text-property beg 'face))
8894 (gnus-put-text-property-excluding-characters-with-faces
8896 (setq face (if (boundp face) (symbol-value face) face)))
8897 (when gnus-summary-highlight-line-function
8898 (funcall gnus-summary-highlight-line-function article face))))
8901 (defun gnus-update-read-articles (group unread &optional compute)
8902 "Update the list of read articles in GROUP."
8903 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8904 (entry (gnus-gethash group gnus-newsrc-hashtb))
8905 (info (nth 2 entry))
8907 (unread (sort (copy-sequence unread) '<))
8909 (if (or (not info) (not active))
8910 ;; There is no info on this group if it was, in fact,
8911 ;; killed. Gnus stores no information on killed groups, so
8912 ;; there's nothing to be done.
8913 ;; One could store the information somewhere temporarily,
8914 ;; perhaps... Hmmm...
8916 ;; Remove any negative articles numbers.
8917 (while (and unread (< (car unread) 0))
8918 (setq unread (cdr unread)))
8919 ;; Remove any expired article numbers
8920 (while (and unread (< (car unread) (car active)))
8921 (setq unread (cdr unread)))
8922 ;; Compute the ranges of read articles by looking at the list of
8925 (when (/= (car unread) prev)
8926 (push (if (= prev (1- (car unread))) prev
8927 (cons prev (1- (car unread))))
8929 (setq prev (1+ (car unread)))
8930 (setq unread (cdr unread)))
8931 (when (<= prev (cdr active))
8932 (push (cons prev (cdr active)) read))
8934 (if (> (length read) 1) (nreverse read) read)
8936 (set-buffer gnus-group-buffer)
8939 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8940 (gnus-info-set-read ',info ',(gnus-info-read info))
8941 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8942 (gnus-group-update-group ,group t))))
8943 ;; Enter this list into the group info.
8945 info (if (> (length read) 1) (nreverse read) read))
8946 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8947 (gnus-get-unread-articles-in-group info (gnus-active group))
8950 (defun gnus-offer-save-summaries ()
8951 "Offer to save all active summary buffers."
8953 (let ((buflist (buffer-list))
8955 ;; Go through all buffers and find all summaries.
8957 (and (setq bufname (buffer-name (car buflist)))
8958 (string-match "Summary" bufname)
8960 (set-buffer bufname)
8961 ;; We check that this is, indeed, a summary buffer.
8962 (and (eq major-mode 'gnus-summary-mode)
8963 ;; Also make sure this isn't bogus.
8964 gnus-newsgroup-prepared
8965 ;; Also make sure that this isn't a dead summary buffer.
8966 (not gnus-dead-summary-mode)))
8967 (push bufname buffers))
8968 (setq buflist (cdr buflist)))
8969 ;; Go through all these summary buffers and offer to save them.
8972 "Update summary buffer %s? "
8974 (switch-to-buffer buf)
8975 (gnus-summary-exit))
8982 (run-hooks 'gnus-sum-load-hook)
8984 ;;; gnus-sum.el ends here