1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
45 ;; Avoid byte-compile warnings.
46 (defvar gnus-decode-encoded-word-function)
49 (autoload 'gnus-cache-articles-in-group "gnus-cache"))
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
54 (defcustom gnus-kill-summary-on-exit t
55 "*If non-nil, kill the summary buffer when you exit from it.
56 If nil, the summary will become a \"*Dead Summary*\" buffer, and
57 it will be killed sometime later."
58 :group 'gnus-summary-exit
61 (defcustom gnus-fetch-old-headers nil
62 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
63 If an unread article in the group refers to an older, already read (or
64 just marked as read) article, the old article will not normally be
65 displayed in the Summary buffer. If this variable is non-nil, Gnus
66 will attempt to grab the headers to the old articles, and thereby
67 build complete threads. If it has the value `some', only enough
68 headers to connect otherwise loose threads will be displayed. This
69 variable can also be a number. In that case, no more than that number
70 of old headers will be fetched. If it has the value `invisible', all
71 old headers will be fetched, but none will be displayed.
73 The server has to support NOV for any of this to work."
75 :type '(choice (const :tag "off" nil)
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-refer-thread-limit 200
81 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
82 If t, fetch all the available old headers."
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-summary-make-false-root 'adopt
88 "*nil means that Gnus won't gather loose threads.
89 If the root of a thread has expired or been read in a previous
90 session, the information necessary to build a complete thread has been
91 lost. Instead of having many small sub-threads from this original thread
92 scattered all over the summary buffer, Gnus can gather them.
94 If non-nil, Gnus will try to gather all loose sub-threads from an
95 original thread into one large thread.
97 If this variable is non-nil, it should be one of `none', `adopt',
100 If this variable is `none', Gnus will not make a false root, but just
101 present the sub-threads after another.
102 If this variable is `dummy', Gnus will create a dummy root that will
103 have all the sub-threads as children.
104 If this variable is `adopt', Gnus will make one of the \"children\"
105 the parent and mark all the step-children as such.
106 If this variable is `empty', the \"children\" are printed with empty
107 subject fields. (Or rather, they will be printed with a string
108 given by the `gnus-summary-same-subject' variable.)"
110 :type '(choice (const :tag "off" nil)
116 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
117 "*A regexp to match subjects to be excluded from loose thread gathering.
118 As loose thread gathering is done on subjects only, that means that
119 there can be many false gatherings performed. By rooting out certain
120 common subjects, gathering might become saner."
124 (defcustom gnus-summary-gather-subject-limit nil
125 "*Maximum length of subject comparisons when gathering loose threads.
126 Use nil to compare full subjects. Setting this variable to a low
127 number will help gather threads that have been corrupted by
128 newsreaders chopping off subject lines, but it might also mean that
129 unrelated articles that have subject that happen to begin with the
130 same few characters will be incorrectly gathered.
132 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
135 :type '(choice (const :tag "off" nil)
137 (sexp :menu-tag "on" t)))
139 (defcustom gnus-simplify-subject-functions nil
140 "List of functions taking a string argument that simplify subjects.
141 The functions are applied recursively.
143 Useful functions to put in this list include: `gnus-simplify-subject-re',
144 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
146 :type '(repeat function))
148 (defcustom gnus-simplify-ignored-prefixes nil
149 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
151 :type '(choice (const :tag "off" nil)
154 (defcustom gnus-build-sparse-threads nil
155 "*If non-nil, fill in the gaps in threads.
156 If `some', only fill in the gaps that are needed to tie loose threads
157 together. If `more', fill in all leaf nodes that Gnus can find. If
158 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
160 :type '(choice (const :tag "off" nil)
163 (sexp :menu-tag "all" t)))
165 (defcustom gnus-summary-thread-gathering-function
166 'gnus-gather-threads-by-subject
167 "*Function used for gathering loose threads.
168 There are two pre-defined functions: `gnus-gather-threads-by-subject',
169 which only takes Subjects into consideration; and
170 `gnus-gather-threads-by-references', which compared the References
171 headers of the articles to find matches."
173 :type '(radio (function-item gnus-gather-threads-by-subject)
174 (function-item gnus-gather-threads-by-references)
175 (function :tag "other")))
177 (defcustom gnus-summary-same-subject ""
178 "*String indicating that the current article has the same subject as the previous.
179 This variable will only be used if the value of
180 `gnus-summary-make-false-root' is `empty'."
181 :group 'gnus-summary-format
184 (defcustom gnus-summary-goto-unread t
185 "*If t, marking commands will go to the next unread article.
186 If `never', commands that usually go to the next unread article, will
187 go to the next article, whether it is read or not.
188 If nil, only the marking commands will go to the next (un)read article."
189 :group 'gnus-summary-marks
190 :link '(custom-manual "(gnus)Setting Marks")
191 :type '(choice (const :tag "off" nil)
193 (sexp :menu-tag "on" t)))
195 (defcustom gnus-summary-default-score 0
196 "*Default article score level.
197 All scores generated by the score files will be added to this score.
198 If this variable is nil, scoring will be disabled."
199 :group 'gnus-score-default
200 :type '(choice (const :tag "disable")
203 (defcustom gnus-summary-zcore-fuzz 0
204 "*Fuzziness factor for the zcore in the summary buffer.
205 Articles with scores closer than this to `gnus-summary-default-score'
207 :group 'gnus-summary-format
210 (defcustom gnus-simplify-subject-fuzzy-regexp nil
211 "*Strings to be removed when doing fuzzy matches.
212 This can either be a regular expression or list of regular expressions
213 that will be removed from subject strings if fuzzy subject
214 simplification is selected."
216 :type '(repeat regexp))
218 (defcustom gnus-show-threads t
219 "*If non-nil, display threads in summary mode."
223 (defcustom gnus-thread-hide-subtree nil
224 "*If non-nil, hide all threads initially.
225 If threads are hidden, you have to run the command
226 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
227 to expose hidden threads."
231 (defcustom gnus-thread-hide-killed t
232 "*If non-nil, hide killed threads automatically."
236 (defcustom gnus-thread-ignore-subject t
237 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
238 If nil, articles that have different subjects from their parents will
239 start separate threads."
243 (defcustom gnus-thread-operation-ignore-subject t
244 "*If non-nil, subjects will be ignored when doing thread commands.
245 This affects commands like `gnus-summary-kill-thread' and
246 `gnus-summary-lower-thread'.
248 If this variable is nil, articles in the same thread with different
249 subjects will not be included in the operation in question. If this
250 variable is `fuzzy', only articles that have subjects that are fuzzily
251 equal will be included."
253 :type '(choice (const :tag "off" nil)
257 (defcustom gnus-thread-indent-level 4
258 "*Number that says how much each sub-thread should be indented."
262 (defcustom gnus-auto-extend-newsgroup t
263 "*If non-nil, extend newsgroup forward and backward when requested."
264 :group 'gnus-summary-choose
267 (defcustom gnus-auto-select-first t
268 "*If nil, don't select the first unread article when entering a group.
269 If this variable is `best', select the highest-scored unread article
270 in the group. If t, select the first unread article.
272 This variable can also be a function to place point on a likely
273 subject line. Useful values include `gnus-summary-first-unread-subject',
274 `gnus-summary-first-unread-article' and
275 `gnus-summary-best-unread-article'.
277 If you want to prevent automatic selection of the first unread article
278 in some newsgroups, set the variable to nil in
279 `gnus-select-group-hook'."
280 :group 'gnus-group-select
281 :type '(choice (const :tag "none" nil)
283 (sexp :menu-tag "first" t)
284 (function-item gnus-summary-first-unread-subject)
285 (function-item gnus-summary-first-unread-article)
286 (function-item gnus-summary-best-unread-article)))
288 (defcustom gnus-dont-select-after-jump-to-other-group nil
289 "If non-nil, don't select the first unread article after entering the
290 other group by the command `gnus-summary-jump-to-other-group'. If nil,
291 it is depend on the value of `gnus-auto-select-first' whether to select
293 :group 'gnus-group-select
296 (defcustom gnus-auto-select-next t
297 "*If non-nil, offer to go to the next group from the end of the previous.
298 If the value is t and the next newsgroup is empty, Gnus will exit
299 summary mode and go back to group mode. If the value is neither nil
300 nor t, Gnus will select the following unread newsgroup. In
301 particular, if the value is the symbol `quietly', the next unread
302 newsgroup will be selected without any confirmation, and if it is
303 `almost-quietly', the next group will be selected without any
304 confirmation if you are located on the last article in the group.
305 Finally, if this variable is `slightly-quietly', the `Z n' command
306 will go to the next group without confirmation."
307 :group 'gnus-summary-maneuvering
308 :type '(choice (const :tag "off" nil)
310 (const almost-quietly)
311 (const slightly-quietly)
312 (sexp :menu-tag "on" t)))
314 (defcustom gnus-auto-select-same nil
315 "*If non-nil, select the next article with the same subject.
316 If there are no more articles with the same subject, go to
317 the first unread article."
318 :group 'gnus-summary-maneuvering
321 (defcustom gnus-summary-check-current nil
322 "*If non-nil, consider the current article when moving.
323 The \"unread\" movement commands will stay on the same line if the
324 current article is unread."
325 :group 'gnus-summary-maneuvering
328 (defcustom gnus-auto-center-summary t
329 "*If non-nil, always center the current summary buffer.
330 In particular, if `vertical' do only vertical recentering. If non-nil
331 and non-`vertical', do both horizontal and vertical recentering."
332 :group 'gnus-summary-maneuvering
333 :type '(choice (const :tag "none" nil)
335 (integer :tag "height")
336 (sexp :menu-tag "both" t)))
338 (defcustom gnus-show-all-headers nil
339 "*If non-nil, don't hide any headers."
340 :group 'gnus-article-hiding
341 :group 'gnus-article-headers
344 (defcustom gnus-summary-ignore-duplicates nil
345 "*If non-nil, ignore articles with identical Message-ID headers."
349 (defcustom gnus-single-article-buffer t
350 "*If non-nil, display all articles in the same buffer.
351 If nil, each group will get its own article buffer."
352 :group 'gnus-article-various
355 (defcustom gnus-break-pages t
356 "*If non-nil, do page breaking on articles.
357 The page delimiter is specified by the `gnus-page-delimiter'
359 :group 'gnus-article-various
362 (defcustom gnus-show-mime t
363 "*If non-nil, do mime processing of articles.
364 The articles will simply be fed to the function given by
365 `gnus-article-display-method-for-mime'."
366 :group 'gnus-article-mime
369 (defcustom gnus-move-split-methods nil
370 "*Variable used to suggest where articles are to be moved to.
371 It uses the same syntax as the `gnus-split-methods' variable."
372 :group 'gnus-summary-mail
373 :type '(repeat (choice (list :value (fun) function)
374 (cons :value ("" "") regexp (repeat string))
377 (defcustom gnus-unread-mark ? ;Whitespace
378 "*Mark used for unread articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-ticked-mark ?!
383 "*Mark used for ticked articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-dormant-mark ??
388 "*Mark used for dormant articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-del-mark ?r
393 "*Mark used for del'd articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-read-mark ?R
398 "*Mark used for read articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-expirable-mark ?E
403 "*Mark used for expirable articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-killed-mark ?K
408 "*Mark used for killed articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-souped-mark ?F
413 "*Mark used for killed articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-kill-file-mark ?X
418 "*Mark used for articles killed by kill files."
419 :group 'gnus-summary-marks
422 (defcustom gnus-low-score-mark ?Y
423 "*Mark used for articles with a low score."
424 :group 'gnus-summary-marks
427 (defcustom gnus-catchup-mark ?C
428 "*Mark used for articles that are caught up."
429 :group 'gnus-summary-marks
432 (defcustom gnus-replied-mark ?A
433 "*Mark used for articles that have been replied to."
434 :group 'gnus-summary-marks
437 (defcustom gnus-cached-mark ?*
438 "*Mark used for articles that are in the cache."
439 :group 'gnus-summary-marks
442 (defcustom gnus-saved-mark ?S
443 "*Mark used for articles that have been saved to."
444 :group 'gnus-summary-marks
447 (defcustom gnus-ancient-mark ?O
448 "*Mark used for ancient articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-sparse-mark ?Q
453 "*Mark used for sparsely reffed articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-canceled-mark ?G
458 "*Mark used for canceled articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-duplicate-mark ?M
463 "*Mark used for duplicate articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-undownloaded-mark ?@
468 "*Mark used for articles that weren't downloaded."
469 :group 'gnus-summary-marks
472 (defcustom gnus-downloadable-mark ?%
473 "*Mark used for articles that are to be downloaded."
474 :group 'gnus-summary-marks
477 (defcustom gnus-unsendable-mark ?=
478 "*Mark used for articles that won't be sent."
479 :group 'gnus-summary-marks
482 (defcustom gnus-score-over-mark ?+
483 "*Score mark used for articles with high scores."
484 :group 'gnus-summary-marks
487 (defcustom gnus-score-below-mark ?-
488 "*Score mark used for articles with low scores."
489 :group 'gnus-summary-marks
492 (defcustom gnus-empty-thread-mark ? ;Whitespace
493 "*There is no thread under the article."
494 :group 'gnus-summary-marks
497 (defcustom gnus-not-empty-thread-mark ?=
498 "*There is a thread under the article."
499 :group 'gnus-summary-marks
502 (defcustom gnus-view-pseudo-asynchronously nil
503 "*If non-nil, Gnus will view pseudo-articles asynchronously."
504 :group 'gnus-extract-view
507 (defcustom gnus-auto-expirable-marks
508 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
509 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
510 gnus-souped-mark gnus-duplicate-mark)
511 "*The list of marks converted into expiration if a group is auto-expirable."
513 :type '(repeat character))
515 (defcustom gnus-inhibit-user-auto-expire t
516 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
520 (defcustom gnus-view-pseudos nil
521 "*If `automatic', pseudo-articles will be viewed automatically.
522 If `not-confirm', pseudos will be viewed automatically, and the user
523 will not be asked to confirm the command."
524 :group 'gnus-extract-view
525 :type '(choice (const :tag "off" nil)
527 (const not-confirm)))
529 (defcustom gnus-view-pseudos-separately t
530 "*If non-nil, one pseudo-article will be created for each file to be viewed.
531 If nil, all files that use the same viewing command will be given as a
532 list of parameters to that command."
533 :group 'gnus-extract-view
536 (defcustom gnus-insert-pseudo-articles t
537 "*If non-nil, insert pseudo-articles when decoding articles."
538 :group 'gnus-extract-view
541 (defcustom gnus-summary-dummy-line-format
543 "*The format specification for the dummy roots in the summary buffer.
544 It works along the same lines as a normal formatting string,
545 with some simple extensions.
548 :group 'gnus-threading
551 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
552 "*The format specification for the summary mode line.
553 It works along the same lines as a normal formatting string,
554 with some simple extensions:
557 %p Unprefixed group name
558 %A Current article number
559 %z Current article score
561 %U Number of unread articles in the group
562 %e Number of unselected articles in the group
563 %Z A string with unread/unselected article counts
564 %g Shortish group name
565 %S Subject of the current article
567 %s Current score file name
568 %d Number of dormant articles
569 %r Number of articles that have been marked as read in this session
570 %E Number of articles expunged by the score files"
571 :group 'gnus-summary-format
574 (defcustom gnus-summary-mark-below 0
575 "*Mark all articles with a score below this variable as read.
576 This variable is local to each summary buffer and usually set by the
578 :group 'gnus-score-default
581 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
582 "*List of functions used for sorting articles in the summary buffer.
583 This variable is only used when not using a threaded display."
584 :group 'gnus-summary-sort
585 :type '(repeat (choice (function-item gnus-article-sort-by-number)
586 (function-item gnus-article-sort-by-author)
587 (function-item gnus-article-sort-by-subject)
588 (function-item gnus-article-sort-by-date)
589 (function-item gnus-article-sort-by-score)
590 (function :tag "other"))))
592 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
593 "*List of functions used for sorting threads in the summary buffer.
594 By default, threads are sorted by article number.
596 Each function takes two threads and return non-nil if the first thread
597 should be sorted before the other. If you use more than one function,
598 the primary sort function should be the last. You should probably
599 always include `gnus-thread-sort-by-number' in the list of sorting
600 functions -- preferably first.
602 Ready-made functions include `gnus-thread-sort-by-number',
603 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
604 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
605 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
606 :group 'gnus-summary-sort
607 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
608 (function-item gnus-thread-sort-by-author)
609 (function-item gnus-thread-sort-by-subject)
610 (function-item gnus-thread-sort-by-date)
611 (function-item gnus-thread-sort-by-score)
612 (function-item gnus-thread-sort-by-total-score)
613 (function :tag "other"))))
615 (defcustom gnus-thread-score-function '+
616 "*Function used for calculating the total score of a thread.
618 The function is called with the scores of the article and each
619 subthread and should then return the score of the thread.
621 Some functions you can use are `+', `max', or `min'."
622 :group 'gnus-summary-sort
625 (defcustom gnus-summary-expunge-below nil
626 "All articles that have a score less than this variable will be expunged.
627 This variable is local to the summary buffers."
628 :group 'gnus-score-default
629 :type '(choice (const :tag "off" nil)
632 (defcustom gnus-thread-expunge-below nil
633 "All threads that have a total score less than this variable will be expunged.
634 See `gnus-thread-score-function' for en explanation of what a
637 This variable is local to the summary buffers."
638 :group 'gnus-threading
639 :group 'gnus-score-default
640 :type '(choice (const :tag "off" nil)
643 (defcustom gnus-summary-mode-hook nil
644 "*A hook for Gnus summary mode.
645 This hook is run before any variables are set in the summary buffer."
646 :group 'gnus-summary-various
649 (defcustom gnus-summary-menu-hook nil
650 "*Hook run after the creation of the summary mode menu."
651 :group 'gnus-summary-visual
654 (defcustom gnus-summary-exit-hook nil
655 "*A hook called on exit from the summary buffer.
656 It will be called with point in the group buffer."
657 :group 'gnus-summary-exit
660 (defcustom gnus-summary-prepare-hook nil
661 "*A hook called after the summary buffer has been generated.
662 If you want to modify the summary buffer, you can use this hook."
663 :group 'gnus-summary-various
666 (defcustom gnus-summary-prepared-hook nil
667 "*A hook called as the last thing after the summary buffer has been generated."
668 :group 'gnus-summary-various
671 (defcustom gnus-summary-generate-hook nil
672 "*A hook run just before generating the summary buffer.
673 This hook is commonly used to customize threading variables and the
675 :group 'gnus-summary-various
678 (defcustom gnus-select-group-hook nil
679 "*A hook called when a newsgroup is selected.
681 If you'd like to simplify subjects like the
682 `gnus-summary-next-same-subject' command does, you can use the
685 (setq gnus-select-group-hook
688 (mapcar (lambda (header)
689 (mail-header-set-subject
691 (gnus-simplify-subject
692 (mail-header-subject header) 're-only)))
693 gnus-newsgroup-headers))))"
694 :group 'gnus-group-select
697 (defcustom gnus-select-article-hook nil
698 "*A hook called when an article is selected."
699 :group 'gnus-summary-choose
702 (defcustom gnus-visual-mark-article-hook
703 (list 'gnus-highlight-selected-summary)
704 "*Hook run after selecting an article in the summary buffer.
705 It is meant to be used for highlighting the article in some way. It
706 is not run if `gnus-visual' is nil."
707 :group 'gnus-summary-visual
710 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
711 "*A hook called before parsing the headers."
715 (defcustom gnus-exit-group-hook nil
716 "*A hook called when exiting (not quitting) summary mode."
720 (defcustom gnus-summary-update-hook
721 (list 'gnus-summary-highlight-line)
722 "*A hook called when a summary line is changed.
723 The hook will not be called if `gnus-visual' is nil.
725 The default function `gnus-summary-highlight-line' will
726 highlight the line according to the `gnus-summary-highlight'
728 :group 'gnus-summary-visual
731 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
732 "*A hook called when an article is selected for the first time.
733 The hook is intended to mark an article as read (or unread)
734 automatically when it is selected."
735 :group 'gnus-summary-choose
738 (defcustom gnus-group-no-more-groups-hook nil
739 "*A hook run when returning to group mode having no more (unread) groups."
740 :group 'gnus-group-select
743 (defcustom gnus-ps-print-hook nil
744 "*A hook run before ps-printing something from Gnus."
748 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
749 "Face used for highlighting the current article in the summary buffer."
750 :group 'gnus-summary-visual
753 (defcustom gnus-summary-highlight
754 '(((= mark gnus-canceled-mark)
755 . gnus-summary-cancelled-face)
756 ((and (> score default)
757 (or (= mark gnus-dormant-mark)
758 (= mark gnus-ticked-mark)))
759 . gnus-summary-high-ticked-face)
760 ((and (< score default)
761 (or (= mark gnus-dormant-mark)
762 (= mark gnus-ticked-mark)))
763 . gnus-summary-low-ticked-face)
764 ((or (= mark gnus-dormant-mark)
765 (= mark gnus-ticked-mark))
766 . gnus-summary-normal-ticked-face)
767 ((and (> score default) (= mark gnus-ancient-mark))
768 . gnus-summary-high-ancient-face)
769 ((and (< score default) (= mark gnus-ancient-mark))
770 . gnus-summary-low-ancient-face)
771 ((= mark gnus-ancient-mark)
772 . gnus-summary-normal-ancient-face)
773 ((and (> score default) (= mark gnus-unread-mark))
774 . gnus-summary-high-unread-face)
775 ((and (< score default) (= mark gnus-unread-mark))
776 . gnus-summary-low-unread-face)
777 ((= mark gnus-unread-mark)
778 . gnus-summary-normal-unread-face)
779 ((and (> score default) (memq mark (list gnus-downloadable-mark
780 gnus-undownloaded-mark)))
781 . gnus-summary-high-unread-face)
782 ((and (< score default) (memq mark (list gnus-downloadable-mark
783 gnus-undownloaded-mark)))
784 . gnus-summary-low-unread-face)
785 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
786 . gnus-summary-normal-unread-face)
788 . gnus-summary-high-read-face)
790 . gnus-summary-low-read-face)
792 . gnus-summary-normal-read-face))
793 "*Controls the highlighting of summary buffer lines.
795 A list of (FORM . FACE) pairs. When deciding how a a particular
796 summary line should be displayed, each form is evaluated. The content
797 of the face field after the first true form is used. You can change
798 how those summary lines are displayed, by editing the face field.
800 You can use the following variables in the FORM field.
802 score: The articles score
803 default: The default article score.
804 below: The score below which articles are automatically marked as read.
805 mark: The articles mark."
806 :group 'gnus-summary-visual
807 :type '(repeat (cons (sexp :tag "Form" nil)
810 (defcustom gnus-alter-header-function nil
811 "Function called to allow alteration of article header structures.
812 The function is called with one parameter, the article header vector,
813 which it may alter in any way.")
815 (defcustom gnus-extra-headers nil
816 "*Extra headers to parse."
818 :type '(repeat symbol))
820 (defcustom gnus-ignored-from-addresses
821 (and user-mail-address (regexp-quote user-mail-address))
822 "*Regexp of From headers that may be suppressed in favor of To headers."
826 (defcustom gnus-group-charset-alist
827 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
828 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
829 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
830 ("^relcom\\>" koi8-r)
831 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
832 ("^israel\\>" iso-8859-1)
834 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
836 "Alist of regexps (to match group names) and default charsets to be used when reading."
837 :type '(repeat (list (regexp :tag "Group")
838 (symbol :tag "Charset")))
839 :group 'gnus-charset)
841 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
842 "List of charsets that should be ignored.
843 When these charsets are used in the \"charset\" parameter, the
844 default charset will be used instead."
845 :type '(repeat symbol)
846 :group 'gnus-charset)
848 (defcustom gnus-group-highlight-words-alist nil
849 "Alist of group regexps and highlight regexps.
850 This variable uses the same syntax as `gnus-emphasis-alist'."
851 :type '(repeat (cons (regexp :tag "Group")
852 (repeat (list (regexp :tag "Highlight regexp")
853 (number :tag "Group for entire word" 0)
854 (number :tag "Group for displayed part" 0)
856 gnus-emphasis-highlight-words)))))
857 :group 'gnus-summary-visual)
859 ;;; Internal variables
861 (defvar gnus-scores-exclude-files nil)
862 (defvar gnus-page-broken nil)
863 (defvar gnus-inhibit-mime-unbuttonizing nil)
865 (defvar gnus-original-article nil)
866 (defvar gnus-article-internal-prepare-hook nil)
867 (defvar gnus-newsgroup-process-stack nil)
869 (defvar gnus-thread-indent-array nil)
870 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
872 ;; Avoid highlighting in kill files.
873 (defvar gnus-summary-inhibit-highlight nil)
874 (defvar gnus-newsgroup-selected-overlay nil)
875 (defvar gnus-inhibit-limiting nil)
876 (defvar gnus-newsgroup-adaptive-score-file nil)
877 (defvar gnus-current-score-file nil)
878 (defvar gnus-current-move-group nil)
879 (defvar gnus-current-copy-group nil)
880 (defvar gnus-current-crosspost-group nil)
882 (defvar gnus-newsgroup-dependencies nil)
883 (defvar gnus-newsgroup-adaptive nil)
884 (defvar gnus-summary-display-article-function nil)
885 (defvar gnus-summary-highlight-line-function nil
886 "Function called after highlighting a summary line.")
888 (defvar gnus-summary-line-format-alist
889 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
890 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
891 (?s gnus-tmp-subject-or-nil ?s)
892 (?n gnus-tmp-name ?s)
893 (?A (std11-address-string
894 (car (mime-read-field 'From gnus-tmp-header))) ?s)
895 (?a (or (std11-full-name-string
896 (car (mime-read-field 'From gnus-tmp-header)))
898 (?F gnus-tmp-from ?s)
899 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
900 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
901 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
902 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
903 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
904 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
905 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
906 (?L gnus-tmp-lines ?d)
907 (?I gnus-tmp-indentation ?s)
908 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
909 (?R gnus-tmp-replied ?c)
910 (?\[ gnus-tmp-opening-bracket ?c)
911 (?\] gnus-tmp-closing-bracket ?c)
912 (?\> (make-string gnus-tmp-level ? ) ?s)
913 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
914 (?i gnus-tmp-score ?d)
915 (?z gnus-tmp-score-char ?c)
916 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
917 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
918 (?U gnus-tmp-unread ?c)
919 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
920 (?t (gnus-summary-number-of-articles-in-thread
921 (and (boundp 'thread) (car thread)) gnus-tmp-level)
923 (?e (gnus-summary-number-of-articles-in-thread
924 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
926 (?u gnus-tmp-user-defined ?s)
927 (?P (gnus-pick-line-number) ?d))
928 "An alist of format specifications that can appear in summary lines,
929 and what variables they correspond with, along with the type of the
930 variable (string, integer, character, etc).")
932 (defvar gnus-summary-dummy-line-format-alist
933 `((?S gnus-tmp-subject ?s)
934 (?N gnus-tmp-number ?d)
935 (?u gnus-tmp-user-defined ?s)))
937 (defvar gnus-summary-mode-line-format-alist
938 `((?G gnus-tmp-group-name ?s)
939 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
940 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
941 (?A gnus-tmp-article-number ?d)
942 (?Z gnus-tmp-unread-and-unselected ?s)
944 (?U gnus-tmp-unread-and-unticked ?d)
945 (?S gnus-tmp-subject ?s)
946 (?e gnus-tmp-unselected ?d)
947 (?u gnus-tmp-user-defined ?s)
948 (?d (length gnus-newsgroup-dormant) ?d)
949 (?t (length gnus-newsgroup-marked) ?d)
950 (?r (length gnus-newsgroup-reads) ?d)
951 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
952 (?E gnus-newsgroup-expunged-tally ?d)
953 (?s (gnus-current-score-file-nondirectory) ?s)))
955 (defvar gnus-last-search-regexp nil
956 "Default regexp for article search command.")
958 (defvar gnus-last-shell-command nil
959 "Default shell command on article.")
961 (defvar gnus-newsgroup-begin nil)
962 (defvar gnus-newsgroup-end nil)
963 (defvar gnus-newsgroup-last-rmail nil)
964 (defvar gnus-newsgroup-last-mail nil)
965 (defvar gnus-newsgroup-last-folder nil)
966 (defvar gnus-newsgroup-last-file nil)
967 (defvar gnus-newsgroup-auto-expire nil)
968 (defvar gnus-newsgroup-active nil)
970 (defvar gnus-newsgroup-data nil)
971 (defvar gnus-newsgroup-data-reverse nil)
972 (defvar gnus-newsgroup-limit nil)
973 (defvar gnus-newsgroup-limits nil)
975 (defvar gnus-newsgroup-unreads nil
976 "List of unread articles in the current newsgroup.")
978 (defvar gnus-newsgroup-unselected nil
979 "List of unselected unread articles in the current newsgroup.")
981 (defvar gnus-newsgroup-reads nil
982 "Alist of read articles and article marks in the current newsgroup.")
984 (defvar gnus-newsgroup-expunged-tally nil)
986 (defvar gnus-newsgroup-marked nil
987 "List of ticked articles in the current newsgroup (a subset of unread art).")
989 (defvar gnus-newsgroup-killed nil
990 "List of ranges of articles that have been through the scoring process.")
992 (defvar gnus-newsgroup-cached nil
993 "List of articles that come from the article cache.")
995 (defvar gnus-newsgroup-saved nil
996 "List of articles that have been saved.")
998 (defvar gnus-newsgroup-kill-headers nil)
1000 (defvar gnus-newsgroup-replied nil
1001 "List of articles that have been replied to in the current newsgroup.")
1003 (defvar gnus-newsgroup-expirable nil
1004 "List of articles in the current newsgroup that can be expired.")
1006 (defvar gnus-newsgroup-processable nil
1007 "List of articles in the current newsgroup that can be processed.")
1009 (defvar gnus-newsgroup-downloadable nil
1010 "List of articles in the current newsgroup that can be processed.")
1012 (defvar gnus-newsgroup-undownloaded nil
1013 "List of articles in the current newsgroup that haven't been downloaded..")
1015 (defvar gnus-newsgroup-unsendable nil
1016 "List of articles in the current newsgroup that won't be sent.")
1018 (defvar gnus-newsgroup-bookmarks nil
1019 "List of articles in the current newsgroup that have bookmarks.")
1021 (defvar gnus-newsgroup-dormant nil
1022 "List of dormant articles in the current newsgroup.")
1024 (defvar gnus-newsgroup-scored nil
1025 "List of scored articles in the current newsgroup.")
1027 (defvar gnus-newsgroup-headers nil
1028 "List of article headers in the current newsgroup.")
1030 (defvar gnus-newsgroup-threads nil)
1032 (defvar gnus-newsgroup-prepared nil
1033 "Whether the current group has been prepared properly.")
1035 (defvar gnus-newsgroup-ancient nil
1036 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1038 (defvar gnus-newsgroup-sparse nil)
1040 (defvar gnus-current-article nil)
1041 (defvar gnus-article-current nil)
1042 (defvar gnus-current-headers nil)
1043 (defvar gnus-have-all-headers nil)
1044 (defvar gnus-last-article nil)
1045 (defvar gnus-newsgroup-history nil)
1046 (defvar gnus-newsgroup-charset nil)
1048 (defconst gnus-summary-local-variables
1049 '(gnus-newsgroup-name
1050 gnus-newsgroup-begin gnus-newsgroup-end
1051 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1052 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1053 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1054 gnus-newsgroup-unselected gnus-newsgroup-marked
1055 gnus-newsgroup-reads gnus-newsgroup-saved
1056 gnus-newsgroup-replied gnus-newsgroup-expirable
1057 gnus-newsgroup-processable gnus-newsgroup-killed
1058 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1059 gnus-newsgroup-unsendable
1060 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1061 gnus-newsgroup-headers gnus-newsgroup-threads
1062 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1063 gnus-current-article gnus-current-headers gnus-have-all-headers
1064 gnus-last-article gnus-article-internal-prepare-hook
1065 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1066 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1067 gnus-thread-expunge-below
1068 gnus-score-alist gnus-current-score-file
1069 (gnus-summary-expunge-below . global)
1070 (gnus-summary-mark-below . global)
1071 gnus-newsgroup-active gnus-scores-exclude-files
1072 gnus-newsgroup-history gnus-newsgroup-ancient
1073 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1074 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1075 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1076 (gnus-newsgroup-expunged-tally . 0)
1077 gnus-cache-removable-articles gnus-newsgroup-cached
1078 gnus-newsgroup-data gnus-newsgroup-data-reverse
1079 gnus-newsgroup-limit gnus-newsgroup-limits
1080 gnus-newsgroup-charset)
1081 "Variables that are buffer-local to the summary buffers.")
1083 ;; Byte-compiler warning.
1084 (defvar gnus-article-mode-map)
1086 ;; Subject simplification.
1088 (defun gnus-simplify-whitespace (str)
1089 "Remove excessive whitespace."
1092 (while (string-match "[ \t][ \t]+" mystr)
1093 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1095 (substring mystr (match-end 0)))))
1097 (when (string-match "^[ \t]+" mystr)
1098 (setq mystr (substring mystr (match-end 0))))
1100 (when (string-match "[ \t]+$" mystr)
1101 (setq mystr (substring mystr 0 (match-beginning 0))))
1104 (defsubst gnus-simplify-subject-re (subject)
1105 "Remove \"Re:\" from subject lines."
1106 (if (string-match "^[Rr][Ee]: *" subject)
1107 (substring subject (match-end 0))
1110 (defun gnus-simplify-subject (subject &optional re-only)
1111 "Remove `Re:' and words in parentheses.
1112 If RE-ONLY is non-nil, strip leading `Re:'s only."
1113 (let ((case-fold-search t)) ;Ignore case.
1114 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1115 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1116 (setq subject (substring subject (match-end 0))))
1117 ;; Remove uninteresting prefixes.
1118 (when (and (not re-only)
1119 gnus-simplify-ignored-prefixes
1120 (string-match gnus-simplify-ignored-prefixes subject))
1121 (setq subject (substring subject (match-end 0))))
1122 ;; Remove words in parentheses from end.
1124 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1125 (setq subject (substring subject 0 (match-beginning 0)))))
1126 ;; Return subject string.
1129 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1131 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1132 (goto-char (point-min))
1133 (while (re-search-forward regexp nil t)
1134 (replace-match (or newtext ""))))
1136 (defun gnus-simplify-buffer-fuzzy ()
1137 "Simplify string in the buffer fuzzily.
1138 The string in the accessible portion of the current buffer is simplified.
1139 It is assumed to be a single-line subject.
1140 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1141 matter is removed. Additional things can be deleted by setting
1142 gnus-simplify-subject-fuzzy-regexp."
1143 (let ((case-fold-search t)
1145 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1147 (while (not (eq modified-tick (buffer-modified-tick)))
1148 (setq modified-tick (buffer-modified-tick))
1150 ((listp gnus-simplify-subject-fuzzy-regexp)
1151 (mapcar 'gnus-simplify-buffer-fuzzy-step
1152 gnus-simplify-subject-fuzzy-regexp))
1153 (gnus-simplify-subject-fuzzy-regexp
1154 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1155 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1156 (gnus-simplify-buffer-fuzzy-step
1157 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1158 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1160 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1161 (gnus-simplify-buffer-fuzzy-step " +" " ")
1162 (gnus-simplify-buffer-fuzzy-step " $")
1163 (gnus-simplify-buffer-fuzzy-step "^ +")))
1165 (defun gnus-simplify-subject-fuzzy (subject)
1166 "Simplify a subject string fuzzily.
1167 See `gnus-simplify-buffer-fuzzy' for details."
1169 (gnus-set-work-buffer)
1170 (let ((case-fold-search t))
1171 ;; Remove uninteresting prefixes.
1172 (when (and gnus-simplify-ignored-prefixes
1173 (string-match gnus-simplify-ignored-prefixes subject))
1174 (setq subject (substring subject (match-end 0))))
1176 (inline (gnus-simplify-buffer-fuzzy))
1179 (defsubst gnus-simplify-subject-fully (subject)
1180 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1182 (gnus-simplify-subject-functions
1183 (gnus-map-function gnus-simplify-subject-functions subject))
1184 ((null gnus-summary-gather-subject-limit)
1185 (gnus-simplify-subject-re subject))
1186 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1187 (gnus-simplify-subject-fuzzy subject))
1188 ((numberp gnus-summary-gather-subject-limit)
1189 (gnus-limit-string (gnus-simplify-subject-re subject)
1190 gnus-summary-gather-subject-limit))
1194 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1195 "Check whether two subjects are equal.
1196 If optional argument simple-first is t, first argument is already
1199 ((null simple-first)
1200 (equal (gnus-simplify-subject-fully s1)
1201 (gnus-simplify-subject-fully s2)))
1204 (gnus-simplify-subject-fully s2)))))
1206 (defun gnus-summary-bubble-group ()
1207 "Increase the score of the current group.
1208 This is a handy function to add to `gnus-summary-exit-hook' to
1209 increase the score of each group you read."
1210 (gnus-group-add-score gnus-newsgroup-name))
1214 ;;; Gnus summary mode
1217 (put 'gnus-summary-mode 'mode-class 'special)
1220 ;; Non-orthogonal keys
1222 (gnus-define-keys gnus-summary-mode-map
1223 " " gnus-summary-next-page
1224 "\177" gnus-summary-prev-page
1225 [delete] gnus-summary-prev-page
1226 [backspace] gnus-summary-prev-page
1227 "\r" gnus-summary-scroll-up
1228 "\M-\r" gnus-summary-scroll-down
1229 "n" gnus-summary-next-unread-article
1230 "p" gnus-summary-prev-unread-article
1231 "N" gnus-summary-next-article
1232 "P" gnus-summary-prev-article
1233 "\M-\C-n" gnus-summary-next-same-subject
1234 "\M-\C-p" gnus-summary-prev-same-subject
1235 "\M-n" gnus-summary-next-unread-subject
1236 "\M-p" gnus-summary-prev-unread-subject
1237 "." gnus-summary-first-unread-article
1238 "," gnus-summary-best-unread-article
1239 "\M-s" gnus-summary-search-article-forward
1240 "\M-r" gnus-summary-search-article-backward
1241 "<" gnus-summary-beginning-of-article
1242 ">" gnus-summary-end-of-article
1243 "j" gnus-summary-goto-article
1244 "^" gnus-summary-refer-parent-article
1245 "\M-^" gnus-summary-refer-article
1246 "u" gnus-summary-tick-article-forward
1247 "!" gnus-summary-tick-article-forward
1248 "U" gnus-summary-tick-article-backward
1249 "d" gnus-summary-mark-as-read-forward
1250 "D" gnus-summary-mark-as-read-backward
1251 "E" gnus-summary-mark-as-expirable
1252 "\M-u" gnus-summary-clear-mark-forward
1253 "\M-U" gnus-summary-clear-mark-backward
1254 "k" gnus-summary-kill-same-subject-and-select
1255 "\C-k" gnus-summary-kill-same-subject
1256 "\M-\C-k" gnus-summary-kill-thread
1257 "\M-\C-l" gnus-summary-lower-thread
1258 "e" gnus-summary-edit-article
1259 "#" gnus-summary-mark-as-processable
1260 "\M-#" gnus-summary-unmark-as-processable
1261 "\M-\C-t" gnus-summary-toggle-threads
1262 "\M-\C-s" gnus-summary-show-thread
1263 "\M-\C-h" gnus-summary-hide-thread
1264 "\M-\C-f" gnus-summary-next-thread
1265 "\M-\C-b" gnus-summary-prev-thread
1266 "\M-\C-u" gnus-summary-up-thread
1267 "\M-\C-d" gnus-summary-down-thread
1268 "&" gnus-summary-execute-command
1269 "c" gnus-summary-catchup-and-exit
1270 "\C-w" gnus-summary-mark-region-as-read
1271 "\C-t" gnus-summary-toggle-truncation
1272 "?" gnus-summary-mark-as-dormant
1273 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1274 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1275 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1276 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1277 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1278 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1279 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1280 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1281 "=" gnus-summary-expand-window
1282 "\C-x\C-s" gnus-summary-reselect-current-group
1283 "\M-g" gnus-summary-rescan-group
1284 "w" gnus-summary-stop-page-breaking
1285 "\C-c\C-r" gnus-summary-caesar-message
1286 "\M-t" gnus-summary-toggle-mime
1287 "f" gnus-summary-followup
1288 "F" gnus-summary-followup-with-original
1289 "C" gnus-summary-cancel-article
1290 "r" gnus-summary-reply
1291 "R" gnus-summary-reply-with-original
1292 "\C-c\C-f" gnus-summary-mail-forward
1293 "o" gnus-summary-save-article
1294 "\C-o" gnus-summary-save-article-mail
1295 "|" gnus-summary-pipe-output
1296 "\M-k" gnus-summary-edit-local-kill
1297 "\M-K" gnus-summary-edit-global-kill
1299 "\C-c\C-d" gnus-summary-describe-group
1300 "q" gnus-summary-exit
1301 "Q" gnus-summary-exit-no-update
1302 "\C-c\C-i" gnus-info-find-node
1303 gnus-mouse-2 gnus-mouse-pick-article
1304 "m" gnus-summary-mail-other-window
1305 "a" gnus-summary-post-news
1306 "x" gnus-summary-limit-to-unread
1307 "s" gnus-summary-isearch-article
1308 "t" gnus-article-toggle-headers
1309 "g" gnus-summary-show-article
1310 "l" gnus-summary-goto-last-article
1311 "v" gnus-summary-preview-mime-message
1312 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1313 "\C-d" gnus-summary-enter-digest-group
1314 "\M-\C-d" gnus-summary-read-document
1315 "\M-\C-e" gnus-summary-edit-parameters
1316 "\M-\C-g" gnus-summary-customize-parameters
1318 "*" gnus-cache-enter-article
1319 "\M-*" gnus-cache-remove-article
1320 "\M-&" gnus-summary-universal-argument
1321 "\C-l" gnus-recenter
1322 "I" gnus-summary-increase-score
1323 "L" gnus-summary-lower-score
1324 "\M-i" gnus-symbolic-argument
1325 "h" gnus-summary-select-article-buffer
1327 "V" gnus-summary-score-map
1328 "X" gnus-uu-extract-map
1329 "S" gnus-summary-send-map)
1331 ;; Sort of orthogonal keymap
1332 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1333 "t" gnus-summary-tick-article-forward
1334 "!" gnus-summary-tick-article-forward
1335 "d" gnus-summary-mark-as-read-forward
1336 "r" gnus-summary-mark-as-read-forward
1337 "c" gnus-summary-clear-mark-forward
1338 " " gnus-summary-clear-mark-forward
1339 "e" gnus-summary-mark-as-expirable
1340 "x" gnus-summary-mark-as-expirable
1341 "?" gnus-summary-mark-as-dormant
1342 "b" gnus-summary-set-bookmark
1343 "B" gnus-summary-remove-bookmark
1344 "#" gnus-summary-mark-as-processable
1345 "\M-#" gnus-summary-unmark-as-processable
1346 "S" gnus-summary-limit-include-expunged
1347 "C" gnus-summary-catchup
1348 "H" gnus-summary-catchup-to-here
1349 "\C-c" gnus-summary-catchup-all
1350 "k" gnus-summary-kill-same-subject-and-select
1351 "K" gnus-summary-kill-same-subject
1352 "P" gnus-uu-mark-map)
1354 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1355 "c" gnus-summary-clear-above
1356 "u" gnus-summary-tick-above
1357 "m" gnus-summary-mark-above
1358 "k" gnus-summary-kill-below)
1360 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1361 "/" gnus-summary-limit-to-subject
1362 "n" gnus-summary-limit-to-articles
1363 "w" gnus-summary-pop-limit
1364 "s" gnus-summary-limit-to-subject
1365 "a" gnus-summary-limit-to-author
1366 "u" gnus-summary-limit-to-unread
1367 "m" gnus-summary-limit-to-marks
1368 "M" gnus-summary-limit-exclude-marks
1369 "v" gnus-summary-limit-to-score
1370 "*" gnus-summary-limit-include-cached
1371 "D" gnus-summary-limit-include-dormant
1372 "T" gnus-summary-limit-include-thread
1373 "d" gnus-summary-limit-exclude-dormant
1374 "t" gnus-summary-limit-to-age
1375 "x" gnus-summary-limit-to-extra
1376 "E" gnus-summary-limit-include-expunged
1377 "c" gnus-summary-limit-exclude-childless-dormant
1378 "C" gnus-summary-limit-mark-excluded-as-read)
1380 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1381 "n" gnus-summary-next-unread-article
1382 "p" gnus-summary-prev-unread-article
1383 "N" gnus-summary-next-article
1384 "P" gnus-summary-prev-article
1385 "\C-n" gnus-summary-next-same-subject
1386 "\C-p" gnus-summary-prev-same-subject
1387 "\M-n" gnus-summary-next-unread-subject
1388 "\M-p" gnus-summary-prev-unread-subject
1389 "f" gnus-summary-first-unread-article
1390 "b" gnus-summary-best-unread-article
1391 "j" gnus-summary-goto-article
1392 "g" gnus-summary-goto-subject
1393 "l" gnus-summary-goto-last-article
1394 "o" gnus-summary-pop-article)
1396 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1397 "k" gnus-summary-kill-thread
1398 "l" gnus-summary-lower-thread
1399 "i" gnus-summary-raise-thread
1400 "T" gnus-summary-toggle-threads
1401 "t" gnus-summary-rethread-current
1402 "^" gnus-summary-reparent-thread
1403 "s" gnus-summary-show-thread
1404 "S" gnus-summary-show-all-threads
1405 "h" gnus-summary-hide-thread
1406 "H" gnus-summary-hide-all-threads
1407 "n" gnus-summary-next-thread
1408 "p" gnus-summary-prev-thread
1409 "u" gnus-summary-up-thread
1410 "o" gnus-summary-top-thread
1411 "d" gnus-summary-down-thread
1412 "#" gnus-uu-mark-thread
1413 "\M-#" gnus-uu-unmark-thread)
1415 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1416 "g" gnus-summary-prepare
1417 "c" gnus-summary-insert-cached-articles)
1419 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1420 "c" gnus-summary-catchup-and-exit
1421 "C" gnus-summary-catchup-all-and-exit
1422 "E" gnus-summary-exit-no-update
1423 "J" gnus-summary-jump-to-other-group
1424 "Q" gnus-summary-exit
1425 "Z" gnus-summary-exit
1426 "n" gnus-summary-catchup-and-goto-next-group
1427 "R" gnus-summary-reselect-current-group
1428 "G" gnus-summary-rescan-group
1429 "N" gnus-summary-next-group
1430 "s" gnus-summary-save-newsrc
1431 "P" gnus-summary-prev-group)
1433 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1434 " " gnus-summary-next-page
1435 "n" gnus-summary-next-page
1436 "\177" gnus-summary-prev-page
1437 [delete] gnus-summary-prev-page
1438 "p" gnus-summary-prev-page
1439 "\r" gnus-summary-scroll-up
1440 "\M-\r" gnus-summary-scroll-down
1441 "<" gnus-summary-beginning-of-article
1442 ">" gnus-summary-end-of-article
1443 "b" gnus-summary-beginning-of-article
1444 "e" gnus-summary-end-of-article
1445 "^" gnus-summary-refer-parent-article
1446 "r" gnus-summary-refer-parent-article
1447 "D" gnus-summary-enter-digest-group
1448 "R" gnus-summary-refer-references
1449 "T" gnus-summary-refer-thread
1450 "g" gnus-summary-show-article
1451 "s" gnus-summary-isearch-article
1452 "P" gnus-summary-print-article
1453 "t" gnus-article-babel)
1455 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1456 "b" gnus-article-add-buttons
1457 "B" gnus-article-add-buttons-to-head
1458 "o" gnus-article-treat-overstrike
1459 "e" gnus-article-emphasize
1460 "w" gnus-article-fill-cited-article
1461 "Q" gnus-article-fill-long-lines
1462 "C" gnus-article-capitalize-sentences
1463 "c" gnus-article-remove-cr
1464 "f" gnus-article-display-x-face
1465 "l" gnus-summary-stop-page-breaking
1466 "r" gnus-summary-caesar-message
1467 "t" gnus-article-toggle-headers
1468 "v" gnus-summary-verbose-headers
1469 "m" gnus-summary-toggle-mime
1470 "h" gnus-article-treat-html
1471 "H" gnus-article-strip-headers-in-body
1472 "d" gnus-article-treat-dumbquotes)
1474 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1475 "a" gnus-article-hide
1476 "h" gnus-article-toggle-headers
1477 "b" gnus-article-hide-boring-headers
1478 "s" gnus-article-hide-signature
1479 "c" gnus-article-hide-citation
1480 "C" gnus-article-hide-citation-in-followups
1481 "p" gnus-article-hide-pgp
1482 "B" gnus-article-strip-banner
1483 "P" gnus-article-hide-pem
1484 "\C-c" gnus-article-hide-citation-maybe)
1486 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1487 "a" gnus-article-highlight
1488 "h" gnus-article-highlight-headers
1489 "c" gnus-article-highlight-citation
1490 "s" gnus-article-highlight-signature)
1492 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1493 "z" gnus-article-date-ut
1494 "u" gnus-article-date-ut
1495 "l" gnus-article-date-local
1496 "e" gnus-article-date-lapsed
1497 "o" gnus-article-date-original
1498 "i" gnus-article-date-iso8601
1499 "s" gnus-article-date-user)
1501 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1502 "t" gnus-article-remove-trailing-blank-lines
1503 "l" gnus-article-strip-leading-blank-lines
1504 "m" gnus-article-strip-multiple-blank-lines
1505 "a" gnus-article-strip-blank-lines
1506 "A" gnus-article-strip-all-blank-lines
1507 "s" gnus-article-strip-leading-space
1508 "e" gnus-article-strip-trailing-space)
1510 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1512 "f" gnus-summary-fetch-faq
1513 "d" gnus-summary-describe-group
1514 "h" gnus-summary-describe-briefly
1515 "i" gnus-info-find-node)
1517 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1518 "e" gnus-summary-expire-articles
1519 "\M-\C-e" gnus-summary-expire-articles-now
1520 "\177" gnus-summary-delete-article
1521 [delete] gnus-summary-delete-article
1522 "m" gnus-summary-move-article
1523 "r" gnus-summary-respool-article
1524 "w" gnus-summary-edit-article
1525 "c" gnus-summary-copy-article
1526 "B" gnus-summary-crosspost-article
1527 "q" gnus-summary-respool-query
1528 "t" gnus-summary-respool-trace
1529 "i" gnus-summary-import-article
1530 "p" gnus-summary-article-posted-p)
1532 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1533 "o" gnus-summary-save-article
1534 "m" gnus-summary-save-article-mail
1535 "F" gnus-summary-write-article-file
1536 "r" gnus-summary-save-article-rmail
1537 "f" gnus-summary-save-article-file
1538 "b" gnus-summary-save-article-body-file
1539 "h" gnus-summary-save-article-folder
1540 "v" gnus-summary-save-article-vm
1541 "p" gnus-summary-pipe-output
1542 "s" gnus-soup-add-article)
1544 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1545 "b" gnus-summary-display-buttonized
1546 "m" gnus-summary-repair-multipart
1547 "v" gnus-article-view-part
1548 "o" gnus-article-save-part
1549 "c" gnus-article-copy-part
1550 "e" gnus-article-externalize-part
1551 "i" gnus-article-inline-part
1552 "|" gnus-article-pipe-part)
1555 (defun gnus-summary-make-menu-bar ()
1556 (gnus-turn-off-edit-menu 'summary)
1558 (unless (boundp 'gnus-summary-misc-menu)
1561 gnus-summary-kill-menu gnus-summary-mode-map ""
1566 ["Enter score..." gnus-summary-score-entry t]
1567 ["Customize" gnus-score-customize t])
1568 (gnus-make-score-map 'increase)
1569 (gnus-make-score-map 'lower)
1571 ["Kill below" gnus-summary-kill-below t]
1572 ["Mark above" gnus-summary-mark-above t]
1573 ["Tick above" gnus-summary-tick-above t]
1574 ["Clear above" gnus-summary-clear-above t])
1575 ["Current score" gnus-summary-current-score t]
1576 ["Set score" gnus-summary-set-score t]
1577 ["Switch current score file..." gnus-score-change-score-file t]
1578 ["Set mark below..." gnus-score-set-mark-below t]
1579 ["Set expunge below..." gnus-score-set-expunge-below t]
1580 ["Edit current score file" gnus-score-edit-current-scores t]
1581 ["Edit score file" gnus-score-edit-file t]
1582 ["Trace score" gnus-score-find-trace t]
1583 ["Find words" gnus-score-find-favourite-words t]
1584 ["Rescore buffer" gnus-summary-rescore t]
1585 ["Increase score..." gnus-summary-increase-score t]
1586 ["Lower score..." gnus-summary-lower-score t]))))
1588 ;; Define both the Article menu in the summary buffer and the equivalent
1589 ;; Commands menu in the article buffer here for consistency.
1592 ["All" gnus-article-hide t]
1593 ["Headers" gnus-article-toggle-headers t]
1594 ["Signature" gnus-article-hide-signature t]
1595 ["Citation" gnus-article-hide-citation t]
1596 ["PGP" gnus-article-hide-pgp t]
1597 ["Banner" gnus-article-strip-banner t]
1598 ["Boring headers" gnus-article-hide-boring-headers t])
1600 ["All" gnus-article-highlight t]
1601 ["Headers" gnus-article-highlight-headers t]
1602 ["Signature" gnus-article-highlight-signature t]
1603 ["Citation" gnus-article-highlight-citation t])
1605 ["Local" gnus-article-date-local t]
1606 ["ISO8601" gnus-article-date-iso8601 t]
1607 ["UT" gnus-article-date-ut t]
1608 ["Original" gnus-article-date-original t]
1609 ["Lapsed" gnus-article-date-lapsed t]
1610 ["User-defined" gnus-article-date-user t])
1613 ["Leading" gnus-article-strip-leading-blank-lines t]
1614 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1615 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1616 ["All of the above" gnus-article-strip-blank-lines t]
1617 ["All" gnus-article-strip-all-blank-lines t]
1618 ["Leading space" gnus-article-strip-leading-space t]
1619 ["Trailing space" gnus-article-strip-trailing-space t])
1620 ["Overstrike" gnus-article-treat-overstrike t]
1621 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1622 ["Emphasis" gnus-article-emphasize t]
1623 ["Word wrap" gnus-article-fill-cited-article t]
1624 ["Fill long lines" gnus-article-fill-long-lines t]
1625 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1626 ["CR" gnus-article-remove-cr t]
1627 ["Show X-Face" gnus-article-display-x-face t]
1628 ["UnHTMLize" gnus-article-treat-html t]
1629 ["Rot 13" gnus-summary-caesar-message t]
1630 ["Unix pipe" gnus-summary-pipe-message t]
1631 ["Add buttons" gnus-article-add-buttons t]
1632 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1633 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1634 ["Toggle MIME" gnus-summary-toggle-mime t]
1635 ["Verbose header" gnus-summary-verbose-headers t]
1636 ["Toggle header" gnus-summary-toggle-header t])
1638 ["Save in default format" gnus-summary-save-article t]
1639 ["Save in file" gnus-summary-save-article-file t]
1640 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1641 ["Save in MH folder" gnus-summary-save-article-folder t]
1642 ["Save in VM folder" gnus-summary-save-article-vm t]
1643 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1644 ["Save body in file" gnus-summary-save-article-body-file t]
1645 ["Pipe through a filter" gnus-summary-pipe-output t]
1646 ["Add to SOUP packet" gnus-soup-add-article t]
1647 ["Print" gnus-summary-print-article t])
1649 ["Respool article..." gnus-summary-respool-article t]
1650 ["Move article..." gnus-summary-move-article
1651 (gnus-check-backend-function
1652 'request-move-article gnus-newsgroup-name)]
1653 ["Copy article..." gnus-summary-copy-article t]
1654 ["Crosspost article..." gnus-summary-crosspost-article
1655 (gnus-check-backend-function
1656 'request-replace-article gnus-newsgroup-name)]
1657 ["Import file..." gnus-summary-import-article t]
1658 ["Check if posted" gnus-summary-article-posted-p t]
1659 ["Edit article" gnus-summary-edit-article
1660 (not (gnus-group-read-only-p))]
1661 ["Delete article" gnus-summary-delete-article
1662 (gnus-check-backend-function
1663 'request-expire-articles gnus-newsgroup-name)]
1664 ["Query respool" gnus-summary-respool-query t]
1665 ["Trace respool" gnus-summary-respool-trace t]
1666 ["Delete expirable articles" gnus-summary-expire-articles-now
1667 (gnus-check-backend-function
1668 'request-expire-articles gnus-newsgroup-name)])
1670 ["Uudecode" gnus-uu-decode-uu t]
1671 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1672 ["Unshar" gnus-uu-decode-unshar t]
1673 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1674 ["Save" gnus-uu-decode-save t]
1675 ["Binhex" gnus-uu-decode-binhex t]
1676 ["Postscript" gnus-uu-decode-postscript t])
1678 ["Enter article" gnus-cache-enter-article t]
1679 ["Remove article" gnus-cache-remove-article t])
1680 ["Translate" gnus-article-babel t]
1681 ["Select article buffer" gnus-summary-select-article-buffer t]
1682 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1683 ["Isearch article..." gnus-summary-isearch-article t]
1684 ["Beginning of the article" gnus-summary-beginning-of-article t]
1685 ["End of the article" gnus-summary-end-of-article t]
1686 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1687 ["Fetch referenced articles" gnus-summary-refer-references t]
1688 ["Fetch current thread" gnus-summary-refer-thread t]
1689 ["Fetch article with id..." gnus-summary-refer-article t]
1690 ["Redisplay" gnus-summary-show-article t])))
1692 gnus-summary-article-menu gnus-summary-mode-map ""
1693 (cons "Article" innards))
1696 gnus-article-commands-menu gnus-article-mode-map ""
1697 (cons "Commands" innards)))
1700 gnus-summary-thread-menu gnus-summary-mode-map ""
1702 ["Toggle threading" gnus-summary-toggle-threads t]
1703 ["Hide threads" gnus-summary-hide-all-threads t]
1704 ["Show threads" gnus-summary-show-all-threads t]
1705 ["Hide thread" gnus-summary-hide-thread t]
1706 ["Show thread" gnus-summary-show-thread t]
1707 ["Go to next thread" gnus-summary-next-thread t]
1708 ["Go to previous thread" gnus-summary-prev-thread t]
1709 ["Go down thread" gnus-summary-down-thread t]
1710 ["Go up thread" gnus-summary-up-thread t]
1711 ["Top of thread" gnus-summary-top-thread t]
1712 ["Mark thread as read" gnus-summary-kill-thread t]
1713 ["Lower thread score" gnus-summary-lower-thread t]
1714 ["Raise thread score" gnus-summary-raise-thread t]
1715 ["Rethread current" gnus-summary-rethread-current t]
1719 gnus-summary-post-menu gnus-summary-mode-map ""
1721 ["Post an article" gnus-summary-post-news t]
1722 ["Followup" gnus-summary-followup t]
1723 ["Followup and yank" gnus-summary-followup-with-original t]
1724 ["Supersede article" gnus-summary-supersede-article t]
1725 ["Cancel article" gnus-summary-cancel-article t]
1726 ["Reply" gnus-summary-reply t]
1727 ["Reply and yank" gnus-summary-reply-with-original t]
1728 ["Wide reply" gnus-summary-wide-reply t]
1729 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1730 ["Mail forward" gnus-summary-mail-forward t]
1731 ["Post forward" gnus-summary-post-forward t]
1732 ["Digest and mail" gnus-summary-mail-digest t]
1733 ["Digest and post" gnus-summary-post-digest t]
1734 ["Resend message" gnus-summary-resend-message t]
1735 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1736 ["Send a mail" gnus-summary-mail-other-window t]
1737 ["Uuencode and post" gnus-uu-post-news t]
1738 ["Followup via news" gnus-summary-followup-to-mail t]
1739 ["Followup via news and yank"
1740 gnus-summary-followup-to-mail-with-original t]
1742 ;;["Send" gnus-summary-send-draft t]
1743 ;;["Send bounced" gnus-resend-bounced-mail t])
1747 gnus-summary-misc-menu gnus-summary-mode-map ""
1750 ["Mark as read" gnus-summary-mark-as-read-forward t]
1751 ["Mark same subject and select"
1752 gnus-summary-kill-same-subject-and-select t]
1753 ["Mark same subject" gnus-summary-kill-same-subject t]
1754 ["Catchup" gnus-summary-catchup t]
1755 ["Catchup all" gnus-summary-catchup-all t]
1756 ["Catchup to here" gnus-summary-catchup-to-here t]
1757 ["Catchup region" gnus-summary-mark-region-as-read t]
1758 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1760 ["Tick" gnus-summary-tick-article-forward t]
1761 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1762 ["Remove marks" gnus-summary-clear-mark-forward t]
1763 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1764 ["Set bookmark" gnus-summary-set-bookmark t]
1765 ["Remove bookmark" gnus-summary-remove-bookmark t])
1767 ["Marks..." gnus-summary-limit-to-marks t]
1768 ["Subject..." gnus-summary-limit-to-subject t]
1769 ["Author..." gnus-summary-limit-to-author t]
1770 ["Age..." gnus-summary-limit-to-age t]
1771 ["Extra..." gnus-summary-limit-to-extra t]
1772 ["Score" gnus-summary-limit-to-score t]
1773 ["Unread" gnus-summary-limit-to-unread t]
1774 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1775 ["Articles" gnus-summary-limit-to-articles t]
1776 ["Pop limit" gnus-summary-pop-limit t]
1777 ["Show dormant" gnus-summary-limit-include-dormant t]
1778 ["Hide childless dormant"
1779 gnus-summary-limit-exclude-childless-dormant t]
1780 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1781 ["Hide marked" gnus-summary-limit-exclude-marks t]
1782 ["Show expunged" gnus-summary-show-all-expunged t])
1784 ["Set mark" gnus-summary-mark-as-processable t]
1785 ["Remove mark" gnus-summary-unmark-as-processable t]
1786 ["Remove all marks" gnus-summary-unmark-all-processable t]
1787 ["Mark above" gnus-uu-mark-over t]
1788 ["Mark series" gnus-uu-mark-series t]
1789 ["Mark region" gnus-uu-mark-region t]
1790 ["Unmark region" gnus-uu-unmark-region t]
1791 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1792 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1793 ["Mark all" gnus-uu-mark-all t]
1794 ["Mark buffer" gnus-uu-mark-buffer t]
1795 ["Mark sparse" gnus-uu-mark-sparse t]
1796 ["Mark thread" gnus-uu-mark-thread t]
1797 ["Unmark thread" gnus-uu-unmark-thread t]
1798 ("Process Mark Sets"
1799 ["Kill" gnus-summary-kill-process-mark t]
1800 ["Yank" gnus-summary-yank-process-mark
1801 gnus-newsgroup-process-stack]
1802 ["Save" gnus-summary-save-process-mark t]))
1804 ["Page forward" gnus-summary-next-page t]
1805 ["Page backward" gnus-summary-prev-page t]
1806 ["Line forward" gnus-summary-scroll-up t])
1808 ["Next unread article" gnus-summary-next-unread-article t]
1809 ["Previous unread article" gnus-summary-prev-unread-article t]
1810 ["Next article" gnus-summary-next-article t]
1811 ["Previous article" gnus-summary-prev-article t]
1812 ["Next unread subject" gnus-summary-next-unread-subject t]
1813 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1814 ["Next article same subject" gnus-summary-next-same-subject t]
1815 ["Previous article same subject" gnus-summary-prev-same-subject t]
1816 ["First unread article" gnus-summary-first-unread-article t]
1817 ["Best unread article" gnus-summary-best-unread-article t]
1818 ["Go to subject number..." gnus-summary-goto-subject t]
1819 ["Go to article number..." gnus-summary-goto-article t]
1820 ["Go to the last article" gnus-summary-goto-last-article t]
1821 ["Pop article off history" gnus-summary-pop-article t])
1823 ["Sort by number" gnus-summary-sort-by-number t]
1824 ["Sort by author" gnus-summary-sort-by-author t]
1825 ["Sort by subject" gnus-summary-sort-by-subject t]
1826 ["Sort by date" gnus-summary-sort-by-date t]
1827 ["Sort by score" gnus-summary-sort-by-score t]
1828 ["Sort by lines" gnus-summary-sort-by-lines t]
1829 ["Sort by characters" gnus-summary-sort-by-chars t])
1831 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1832 ["Describe group" gnus-summary-describe-group t]
1833 ["Read manual" gnus-info-find-node t])
1835 ["Pick and read" gnus-pick-mode t]
1836 ["Binary" gnus-binary-mode t])
1838 ["Regenerate" gnus-summary-prepare t]
1839 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1840 ["Toggle threading" gnus-summary-toggle-threads t])
1841 ["Filter articles..." gnus-summary-execute-command t]
1842 ["Run command on subjects..." gnus-summary-universal-argument t]
1843 ["Search articles forward..." gnus-summary-search-article-forward t]
1844 ["Search articles backward..." gnus-summary-search-article-backward t]
1845 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1846 ["Expand window" gnus-summary-expand-window t]
1847 ["Expire expirable articles" gnus-summary-expire-articles
1848 (gnus-check-backend-function
1849 'request-expire-articles gnus-newsgroup-name)]
1850 ["Edit local kill file" gnus-summary-edit-local-kill t]
1851 ["Edit main kill file" gnus-summary-edit-global-kill t]
1852 ["Edit group parameters" gnus-summary-edit-parameters t]
1853 ["Customize group parameters" gnus-summary-customize-parameters t]
1854 ["Send a bug report" gnus-bug t]
1856 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1857 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1858 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1859 ["Exit group" gnus-summary-exit t]
1860 ["Exit group without updating" gnus-summary-exit-no-update t]
1861 ["Exit and goto next group" gnus-summary-next-group t]
1862 ["Exit and goto prev group" gnus-summary-prev-group t]
1863 ["Reselect group" gnus-summary-reselect-current-group t]
1864 ["Rescan group" gnus-summary-rescan-group t]
1865 ["Update dribble" gnus-summary-save-newsrc t])))
1867 (gnus-run-hooks 'gnus-summary-menu-hook)))
1869 (defun gnus-score-set-default (var value)
1870 "A version of set that updates the GNU Emacs menu-bar."
1872 ;; It is the message that forces the active status to be updated.
1875 (defun gnus-make-score-map (type)
1876 "Make a summary score map of type TYPE."
1879 (let ((headers '(("author" "from" string)
1880 ("subject" "subject" string)
1881 ("article body" "body" string)
1882 ("article head" "head" string)
1883 ("xref" "xref" string)
1884 ("extra header" "extra" string)
1885 ("lines" "lines" number)
1886 ("followups to author" "followup" string)))
1887 (types '((number ("less than" <)
1890 (string ("substring" s)
1894 (perms '(("temporary" (current-time-string))
1902 (if (eq type 'lower)
1907 (setq header (car headers))
1913 (let ((ts (cdr (assoc (nth 2 header) types)))
1929 'gnus-summary-score-entry
1931 (if (or (string= (nth 1 header)
1933 (string= (nth 1 header)
1936 (list 'gnus-summary-header
1938 (list 'quote (nth 1 (car ts)))
1939 (list 'gnus-score-default nil)
1945 (list (nreverse outp))))
1948 (list (nreverse outt))))
1950 (setq headers (cdr headers)))
1951 (list (nreverse outh))))))))
1955 (defun gnus-summary-mode (&optional group)
1956 "Major mode for reading articles.
1958 All normal editing commands are switched off.
1959 \\<gnus-summary-mode-map>
1960 Each line in this buffer represents one article. To read an
1961 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1962 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1965 You can also post articles and send mail from this buffer. To
1966 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1967 of an article, type `\\[gnus-summary-reply]'.
1969 There are approx. one gazillion commands you can execute in this
1970 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1972 The following commands are available:
1974 \\{gnus-summary-mode-map}"
1976 (when (gnus-visual-p 'summary-menu 'menu)
1977 (gnus-summary-make-menu-bar))
1978 (kill-all-local-variables)
1979 (gnus-summary-make-local-variables)
1980 (gnus-make-thread-indent-array)
1981 (gnus-simplify-mode-line)
1982 (setq major-mode 'gnus-summary-mode)
1983 (setq mode-name "Summary")
1984 (make-local-variable 'minor-mode-alist)
1985 (use-local-map gnus-summary-mode-map)
1986 (buffer-disable-undo)
1987 (setq buffer-read-only t) ;Disable modification
1988 (setq truncate-lines t)
1989 (setq selective-display t)
1990 (setq selective-display-ellipses t) ;Display `...'
1991 (gnus-summary-set-display-table)
1992 (gnus-set-default-directory)
1993 (setq gnus-newsgroup-name group)
1994 (make-local-variable 'gnus-summary-line-format)
1995 (make-local-variable 'gnus-summary-line-format-spec)
1996 (make-local-variable 'gnus-summary-dummy-line-format)
1997 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1998 (make-local-variable 'gnus-summary-mark-positions)
1999 (make-local-hook 'pre-command-hook)
2000 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2001 (gnus-run-hooks 'gnus-summary-mode-hook)
2002 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2003 (gnus-update-summary-mark-positions))
2005 (defun gnus-summary-make-local-variables ()
2006 "Make all the local summary buffer variables."
2008 (dolist (local gnus-summary-local-variables)
2011 (if (eq (cdr local) 'global)
2012 ;; Copy the global value of the variable.
2013 (setq global (symbol-value (car local)))
2014 ;; Use the value from the list.
2015 (setq global (eval (cdr local))))
2016 (set (make-local-variable (car local)) global))
2017 ;; Simple nil-valued local variable.
2018 (set (make-local-variable local) nil)))))
2020 (defun gnus-summary-clear-local-variables ()
2021 (let ((locals gnus-summary-local-variables))
2023 (if (consp (car locals))
2024 (and (vectorp (caar locals))
2025 (set (caar locals) nil))
2026 (and (vectorp (car locals))
2027 (set (car locals) nil)))
2028 (setq locals (cdr locals)))))
2030 ;; Summary data functions.
2032 (defmacro gnus-data-number (data)
2035 (defmacro gnus-data-set-number (data number)
2036 `(setcar ,data ,number))
2038 (defmacro gnus-data-mark (data)
2041 (defmacro gnus-data-set-mark (data mark)
2042 `(setcar (nthcdr 1 ,data) ,mark))
2044 (defmacro gnus-data-pos (data)
2047 (defmacro gnus-data-set-pos (data pos)
2048 `(setcar (nthcdr 2 ,data) ,pos))
2050 (defmacro gnus-data-header (data)
2053 (defmacro gnus-data-set-header (data header)
2054 `(setf (nth 3 ,data) ,header))
2056 (defmacro gnus-data-level (data)
2059 (defmacro gnus-data-unread-p (data)
2060 `(= (nth 1 ,data) gnus-unread-mark))
2062 (defmacro gnus-data-read-p (data)
2063 `(/= (nth 1 ,data) gnus-unread-mark))
2065 (defmacro gnus-data-pseudo-p (data)
2066 `(consp (nth 3 ,data)))
2068 (defmacro gnus-data-find (number)
2069 `(assq ,number gnus-newsgroup-data))
2071 (defmacro gnus-data-find-list (number &optional data)
2072 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2073 (memq (assq ,number bdata)
2076 (defmacro gnus-data-make (number mark pos header level)
2077 `(list ,number ,mark ,pos ,header ,level))
2079 (defun gnus-data-enter (after-article number mark pos header level offset)
2080 (let ((data (gnus-data-find-list after-article)))
2082 (error "No such article: %d" after-article))
2083 (setcdr data (cons (gnus-data-make number mark pos header level)
2085 (setq gnus-newsgroup-data-reverse nil)
2086 (gnus-data-update-list (cddr data) offset)))
2088 (defun gnus-data-enter-list (after-article list &optional offset)
2090 (let ((data (and after-article (gnus-data-find-list after-article)))
2094 (let ((odata gnus-newsgroup-data))
2095 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2097 (gnus-data-update-list odata offset)))
2098 ;; Find the last element in the list to be spliced into the main
2101 (setq list (cdr list)))
2104 (setcdr list gnus-newsgroup-data)
2105 (setq gnus-newsgroup-data ilist)
2107 (gnus-data-update-list (cdr list) offset)))
2108 (setcdr list (cdr data))
2111 (gnus-data-update-list (cdr list) offset))))
2112 (setq gnus-newsgroup-data-reverse nil))))
2114 (defun gnus-data-remove (article &optional offset)
2115 (let ((data gnus-newsgroup-data))
2116 (if (= (gnus-data-number (car data)) article)
2118 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2119 gnus-newsgroup-data-reverse nil)
2121 (gnus-data-update-list gnus-newsgroup-data offset)))
2123 (when (= (gnus-data-number (cadr data)) article)
2124 (setcdr data (cddr data))
2126 (gnus-data-update-list (cdr data) offset))
2128 gnus-newsgroup-data-reverse nil))
2129 (setq data (cdr data))))))
2131 (defmacro gnus-data-list (backward)
2133 (or gnus-newsgroup-data-reverse
2134 (setq gnus-newsgroup-data-reverse
2135 (reverse gnus-newsgroup-data)))
2136 gnus-newsgroup-data))
2138 (defun gnus-data-update-list (data offset)
2139 "Add OFFSET to the POS of all data entries in DATA."
2140 (setq gnus-newsgroup-data-reverse nil)
2142 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2143 (setq data (cdr data))))
2145 (defun gnus-summary-article-pseudo-p (article)
2146 "Say whether this article is a pseudo article or not."
2147 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2149 (defmacro gnus-summary-article-sparse-p (article)
2150 "Say whether this article is a sparse article or not."
2151 `(memq ,article gnus-newsgroup-sparse))
2153 (defmacro gnus-summary-article-ancient-p (article)
2154 "Say whether this article is a sparse article or not."
2155 `(memq ,article gnus-newsgroup-ancient))
2157 (defun gnus-article-parent-p (number)
2158 "Say whether this article is a parent or not."
2159 (let ((data (gnus-data-find-list number)))
2160 (and (cdr data) ; There has to be an article after...
2161 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2162 (gnus-data-level (nth 1 data))))))
2164 (defun gnus-article-children (number)
2165 "Return a list of all children to NUMBER."
2166 (let* ((data (gnus-data-find-list number))
2167 (level (gnus-data-level (car data)))
2169 (setq data (cdr data))
2171 (= (gnus-data-level (car data)) (1+ level)))
2172 (push (gnus-data-number (car data)) children)
2173 (setq data (cdr data)))
2176 (defmacro gnus-summary-skip-intangible ()
2177 "If the current article is intangible, then jump to a different article."
2178 '(let ((to (get-text-property (point) 'gnus-intangible)))
2179 (and to (gnus-summary-goto-subject to))))
2181 (defmacro gnus-summary-article-intangible-p ()
2182 "Say whether this article is intangible or not."
2183 '(get-text-property (point) 'gnus-intangible))
2185 (defun gnus-article-read-p (article)
2186 "Say whether ARTICLE is read or not."
2187 (not (or (memq article gnus-newsgroup-marked)
2188 (memq article gnus-newsgroup-unreads)
2189 (memq article gnus-newsgroup-unselected)
2190 (memq article gnus-newsgroup-dormant))))
2192 ;; Some summary mode macros.
2194 (defmacro gnus-summary-article-number ()
2195 "The article number of the article on the current line.
2196 If there isn's an article number here, then we return the current
2199 (gnus-summary-skip-intangible)
2200 (or (get-text-property (point) 'gnus-number)
2201 (gnus-summary-last-subject))))
2203 (defmacro gnus-summary-article-header (&optional number)
2204 "Return the header of article NUMBER."
2205 `(gnus-data-header (gnus-data-find
2206 ,(or number '(gnus-summary-article-number)))))
2208 (defmacro gnus-summary-thread-level (&optional number)
2209 "Return the level of thread that starts with article NUMBER."
2210 `(if (and (eq gnus-summary-make-false-root 'dummy)
2211 (get-text-property (point) 'gnus-intangible))
2213 (gnus-data-level (gnus-data-find
2214 ,(or number '(gnus-summary-article-number))))))
2216 (defmacro gnus-summary-article-mark (&optional number)
2217 "Return the mark of article NUMBER."
2218 `(gnus-data-mark (gnus-data-find
2219 ,(or number '(gnus-summary-article-number)))))
2221 (defmacro gnus-summary-article-pos (&optional number)
2222 "Return the position of the line of article NUMBER."
2223 `(gnus-data-pos (gnus-data-find
2224 ,(or number '(gnus-summary-article-number)))))
2226 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2227 (defmacro gnus-summary-article-subject (&optional number)
2228 "Return current subject string or nil if nothing."
2231 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2232 '(gnus-data-header (assq (gnus-summary-article-number)
2233 gnus-newsgroup-data)))))
2236 (mail-header-subject headers))))
2238 (defmacro gnus-summary-article-score (&optional number)
2239 "Return current article score."
2240 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2241 gnus-newsgroup-scored))
2242 gnus-summary-default-score 0))
2244 (defun gnus-summary-article-children (&optional number)
2245 "Return a list of article numbers that are children of article NUMBER."
2246 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2247 (level (gnus-data-level (car data)))
2249 (while (and (setq data (cdr data))
2250 (> (setq l (gnus-data-level (car data))) level))
2251 (and (= (1+ level) l)
2252 (push (gnus-data-number (car data))
2254 (nreverse children)))
2256 (defun gnus-summary-article-parent (&optional number)
2257 "Return the article number of the parent of article NUMBER."
2258 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2259 (gnus-data-list t)))
2260 (level (gnus-data-level (car data))))
2262 () ; This is a root.
2263 ;; We search until we find an article with a level less than
2264 ;; this one. That function has to be the parent.
2265 (while (and (setq data (cdr data))
2266 (not (< (gnus-data-level (car data)) level))))
2267 (and data (gnus-data-number (car data))))))
2269 (defun gnus-unread-mark-p (mark)
2270 "Say whether MARK is the unread mark."
2271 (= mark gnus-unread-mark))
2273 (defun gnus-read-mark-p (mark)
2274 "Say whether MARK is one of the marks that mark as read.
2275 This is all marks except unread, ticked, dormant, and expirable."
2276 (not (or (= mark gnus-unread-mark)
2277 (= mark gnus-ticked-mark)
2278 (= mark gnus-dormant-mark)
2279 (= mark gnus-expirable-mark))))
2281 (defmacro gnus-article-mark (number)
2282 "Return the MARK of article NUMBER.
2283 This macro should only be used when computing the mark the \"first\"
2284 time; i.e., when generating the summary lines. After that,
2285 `gnus-summary-article-mark' should be used to examine the
2288 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2289 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2290 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2291 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2292 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2293 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2294 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2295 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2296 gnus-ancient-mark))))
2298 ;; Saving hidden threads.
2300 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2301 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2303 (defmacro gnus-save-hidden-threads (&rest forms)
2304 "Save hidden threads, eval FORMS, and restore the hidden threads."
2305 (let ((config (make-symbol "config")))
2306 `(let ((,config (gnus-hidden-threads-configuration)))
2310 (gnus-restore-hidden-threads-configuration ,config)))))
2312 (defun gnus-data-compute-positions ()
2313 "Compute the positions of all articles."
2314 (setq gnus-newsgroup-data-reverse nil)
2315 (let ((data gnus-newsgroup-data))
2317 (gnus-save-hidden-threads
2318 (gnus-summary-show-all-threads)
2319 (goto-char (point-min))
2321 (while (get-text-property (point) 'gnus-intangible)
2323 (gnus-data-set-pos (car data) (+ (point) 3))
2324 (setq data (cdr data))
2325 (forward-line 1))))))
2327 (defun gnus-hidden-threads-configuration ()
2328 "Return the current hidden threads configuration."
2331 (goto-char (point-min))
2332 (while (search-forward "\r" nil t)
2333 (push (1- (point)) config))
2336 (defun gnus-restore-hidden-threads-configuration (config)
2337 "Restore hidden threads configuration from CONFIG."
2338 (let (point buffer-read-only)
2339 (while (setq point (pop config))
2340 (when (and (< point (point-max))
2342 (eq (char-after) ?\n))
2343 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2345 ;; Various summary mode internalish functions.
2347 (defun gnus-mouse-pick-article (e)
2350 (gnus-summary-next-page nil t))
2352 (defun gnus-summary-set-display-table ()
2353 ;; Change the display table. Odd characters have a tendency to mess
2354 ;; up nicely formatted displays - we make all possible glyphs
2355 ;; display only a single character.
2357 ;; We start from the standard display table, if any.
2358 (let ((table (or (copy-sequence standard-display-table)
2359 (make-display-table)))
2361 ;; Nix out all the control chars...
2362 (while (>= (setq i (1- i)) 0)
2363 (aset table i [??]))
2364 ;; ... but not newline and cr, of course. (cr is necessary for the
2365 ;; selective display).
2366 (aset table ?\n nil)
2367 (aset table ?\r nil)
2368 ;; We keep TAB as well.
2369 (aset table ?\t nil)
2370 ;; We nix out any glyphs over 126 that are not set already.
2372 (while (>= (setq i (1- i)) 127)
2373 ;; Only modify if the entry is nil.
2374 (unless (aref table i)
2375 (aset table i [??]))))
2376 (setq buffer-display-table table)))
2378 (defun gnus-summary-setup-buffer (group)
2379 "Initialize summary buffer."
2380 (let ((buffer (concat "*Summary " group "*")))
2381 (if (get-buffer buffer)
2384 (setq gnus-summary-buffer (current-buffer))
2385 (not gnus-newsgroup-prepared))
2386 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2387 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2388 (gnus-summary-mode group)
2390 (gnus-carpal-setup-buffer 'summary))
2391 (unless gnus-single-article-buffer
2392 (make-local-variable 'gnus-article-buffer)
2393 (make-local-variable 'gnus-article-current)
2394 (make-local-variable 'gnus-original-article-buffer))
2395 (setq gnus-newsgroup-name group)
2398 (defun gnus-set-global-variables ()
2399 ;; Set the global equivalents of the summary buffer-local variables
2400 ;; to the latest values they had. These reflect the summary buffer
2401 ;; that was in action when the last article was fetched.
2402 (when (eq major-mode 'gnus-summary-mode)
2403 (setq gnus-summary-buffer (current-buffer))
2404 (let ((name gnus-newsgroup-name)
2405 (marked gnus-newsgroup-marked)
2406 (unread gnus-newsgroup-unreads)
2407 (headers gnus-current-headers)
2408 (data gnus-newsgroup-data)
2409 (summary gnus-summary-buffer)
2410 (article-buffer gnus-article-buffer)
2411 (original gnus-original-article-buffer)
2412 (gac gnus-article-current)
2413 (reffed gnus-reffed-article-number)
2414 (score-file gnus-current-score-file)
2415 (default-charset gnus-newsgroup-charset))
2417 (set-buffer gnus-group-buffer)
2418 (setq gnus-newsgroup-name name
2419 gnus-newsgroup-marked marked
2420 gnus-newsgroup-unreads unread
2421 gnus-current-headers headers
2422 gnus-newsgroup-data data
2423 gnus-article-current gac
2424 gnus-summary-buffer summary
2425 gnus-article-buffer article-buffer
2426 gnus-original-article-buffer original
2427 gnus-reffed-article-number reffed
2428 gnus-current-score-file score-file
2429 gnus-newsgroup-charset default-charset)
2430 ;; The article buffer also has local variables.
2431 (when (gnus-buffer-live-p gnus-article-buffer)
2432 (set-buffer gnus-article-buffer)
2433 (setq gnus-summary-buffer summary))))))
2435 (defun gnus-summary-article-unread-p (article)
2436 "Say whether ARTICLE is unread or not."
2437 (memq article gnus-newsgroup-unreads))
2439 (defun gnus-summary-first-article-p (&optional article)
2440 "Return whether ARTICLE is the first article in the buffer."
2441 (if (not (setq article (or article (gnus-summary-article-number))))
2443 (eq article (caar gnus-newsgroup-data))))
2445 (defun gnus-summary-last-article-p (&optional article)
2446 "Return whether ARTICLE is the last article in the buffer."
2447 (if (not (setq article (or article (gnus-summary-article-number))))
2448 ;; All non-existent numbers are the last article. :-)
2450 (not (cdr (gnus-data-find-list article)))))
2452 (defun gnus-make-thread-indent-array ()
2454 (unless (and gnus-thread-indent-array
2455 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2456 (setq gnus-thread-indent-array (make-vector 201 "")
2457 gnus-thread-indent-array-level gnus-thread-indent-level)
2459 (aset gnus-thread-indent-array n
2460 (make-string (* n gnus-thread-indent-level) ? ))
2463 (defun gnus-update-summary-mark-positions ()
2464 "Compute where the summary marks are to go."
2466 (when (gnus-buffer-exists-p gnus-summary-buffer)
2467 (set-buffer gnus-summary-buffer))
2468 (let ((gnus-replied-mark 129)
2469 (gnus-score-below-mark 130)
2470 (gnus-score-over-mark 130)
2471 (gnus-download-mark 131)
2472 (spec gnus-summary-line-format-spec)
2475 (gnus-set-work-buffer)
2476 (let ((gnus-summary-line-format-spec spec)
2477 (gnus-newsgroup-downloadable '((0 . t))))
2478 (gnus-summary-insert-line
2479 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2480 0 nil 128 t nil "" nil 1)
2481 (goto-char (point-min))
2482 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2484 (goto-char (point-min))
2485 (push (cons 'replied (and (search-forward "\201" nil t)
2488 (goto-char (point-min))
2489 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2491 (goto-char (point-min))
2492 (push (cons 'download
2493 (and (search-forward "\203" nil t) (- (point) 2)))
2495 (setq gnus-summary-mark-positions pos))))
2497 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2498 "Insert a dummy root in the summary buffer."
2500 (gnus-add-text-properties
2501 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2502 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2504 (defun gnus-summary-from-or-to-or-newsgroups (header)
2505 (let ((to (cdr (assq 'To (mail-header-extra header))))
2506 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2507 (mail-parse-charset gnus-newsgroup-charset))
2510 gnus-ignored-from-addresses
2511 (string-match gnus-ignored-from-addresses
2512 (mail-header-from header)))
2514 (or (car (funcall gnus-extract-address-components
2516 gnus-decode-encoded-word-function to)))
2517 (funcall gnus-decode-encoded-word-function to))))
2519 gnus-ignored-from-addresses
2520 (string-match gnus-ignored-from-addresses
2521 (mail-header-from header)))
2522 (concat "=> " newsgroups))
2524 (or (car (funcall gnus-extract-address-components
2525 (mail-header-from header)))
2526 (mail-header-from header))))))
2528 (defun gnus-summary-insert-line (gnus-tmp-header
2529 gnus-tmp-level gnus-tmp-current
2530 gnus-tmp-unread gnus-tmp-replied
2531 gnus-tmp-expirable gnus-tmp-subject-or-nil
2532 &optional gnus-tmp-dummy gnus-tmp-score
2534 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2535 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2536 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2537 (gnus-tmp-score-char
2538 (if (or (null gnus-summary-default-score)
2539 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2540 gnus-summary-zcore-fuzz))
2542 (if (< gnus-tmp-score gnus-summary-default-score)
2543 gnus-score-below-mark gnus-score-over-mark)))
2545 (cond (gnus-tmp-process gnus-process-mark)
2546 ((memq gnus-tmp-current gnus-newsgroup-cached)
2548 (gnus-tmp-replied gnus-replied-mark)
2549 ((memq gnus-tmp-current gnus-newsgroup-saved)
2551 (t gnus-unread-mark)))
2552 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2555 ((string-match "<[^>]+> *$" gnus-tmp-from)
2556 (let ((beg (match-beginning 0)))
2557 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2558 (substring gnus-tmp-from (1+ (match-beginning 0))
2559 (1- (match-end 0))))
2560 (substring gnus-tmp-from 0 beg))))
2561 ((string-match "(.+)" gnus-tmp-from)
2562 (substring gnus-tmp-from
2563 (1+ (match-beginning 0)) (1- (match-end 0))))
2565 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2566 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2567 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2568 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2569 (buffer-read-only nil))
2570 (when (string= gnus-tmp-name "")
2571 (setq gnus-tmp-name gnus-tmp-from))
2572 (unless (numberp gnus-tmp-lines)
2573 (setq gnus-tmp-lines 0))
2574 (gnus-put-text-property-excluding-characters-with-faces
2576 (progn (eval gnus-summary-line-format-spec) (point))
2577 'gnus-number gnus-tmp-number)
2578 (when (gnus-visual-p 'summary-highlight 'highlight)
2580 (gnus-run-hooks 'gnus-summary-update-hook)
2583 (defun gnus-summary-update-line (&optional dont-update)
2584 ;; Update summary line after change.
2585 (when (and gnus-summary-default-score
2586 (not gnus-summary-inhibit-highlight))
2587 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2588 (article (gnus-summary-article-number))
2589 (score (gnus-summary-article-score article)))
2591 (if (and gnus-summary-mark-below
2592 (< (gnus-summary-article-score)
2593 gnus-summary-mark-below))
2594 ;; This article has a low score, so we mark it as read.
2595 (when (memq article gnus-newsgroup-unreads)
2596 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2597 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2598 ;; This article was previously marked as read on account
2599 ;; of a low score, but now it has risen, so we mark it as
2601 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2602 (gnus-summary-update-mark
2603 (if (or (null gnus-summary-default-score)
2604 (<= (abs (- score gnus-summary-default-score))
2605 gnus-summary-zcore-fuzz))
2607 (if (< score gnus-summary-default-score)
2608 gnus-score-below-mark gnus-score-over-mark))
2610 ;; Do visual highlighting.
2611 (when (gnus-visual-p 'summary-highlight 'highlight)
2612 (gnus-run-hooks 'gnus-summary-update-hook)))))
2614 (defvar gnus-tmp-new-adopts nil)
2616 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2617 "Return the number of articles in THREAD.
2618 This may be 0 in some cases -- if none of the articles in
2619 the thread are to be displayed."
2621 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2623 ((not (listp thread))
2625 ((and (consp thread) (cdr thread))
2628 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2631 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2634 (when (and level (zerop level) gnus-tmp-new-adopts)
2637 'gnus-summary-number-of-articles-in-thread
2638 gnus-tmp-new-adopts))))
2640 (if (> number 1) gnus-not-empty-thread-mark
2641 gnus-empty-thread-mark)
2644 (defun gnus-summary-set-local-parameters (group)
2645 "Go through the local params of GROUP and set all variable specs in that list."
2646 (let ((params (gnus-group-find-parameter group))
2649 (setq elem (car params)
2650 params (cdr params))
2651 (and (consp elem) ; Has to be a cons.
2652 (consp (cdr elem)) ; The cdr has to be a list.
2653 (symbolp (car elem)) ; Has to be a symbol in there.
2654 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2655 (ignore-errors ; So we set it.
2656 (make-local-variable (car elem))
2657 (set (car elem) (eval (nth 1 elem))))))))
2659 (defun gnus-summary-read-group (group &optional show-all no-article
2660 kill-buffer no-display backward
2662 "Start reading news in newsgroup GROUP.
2663 If SHOW-ALL is non-nil, already read articles are also listed.
2664 If NO-ARTICLE is non-nil, no article is selected initially.
2665 If NO-DISPLAY, don't generate a summary buffer."
2669 (let ((gnus-auto-select-next nil))
2670 (or (gnus-summary-read-group-1
2671 group show-all no-article
2672 kill-buffer no-display
2675 select-articles nil)))))
2676 (eq gnus-auto-select-next 'quietly))
2677 (set-buffer gnus-group-buffer)
2678 ;; The entry function called above goes to the next
2679 ;; group automatically, so we go two groups back
2680 ;; if we are searching for the previous group.
2682 (gnus-group-prev-unread-group 2))
2683 (if (not (equal group (gnus-group-group-name)))
2684 (setq group (gnus-group-group-name))
2688 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2689 "Directly jump to the other GROUP from summary buffer.
2690 If SHOW-ALL is non-nil, already read articles are also listed."
2692 (if (eq gnus-summary-buffer (current-buffer))
2693 (list (completing-read
2694 "Group: " gnus-active-hashtb nil t
2695 (when (and gnus-newsgroup-name
2696 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2697 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2698 'gnus-group-history)
2700 (error "%s must be invoked from a gnus summary buffer." this-command)))
2701 (unless (or (zerop (length group))
2702 (and gnus-newsgroup-name
2703 (string-equal gnus-newsgroup-name group)))
2705 (gnus-summary-read-group group show-all
2706 gnus-dont-select-after-jump-to-other-group)))
2708 (defun gnus-summary-read-group-1 (group show-all no-article
2709 kill-buffer no-display
2710 &optional select-articles)
2711 ;; Killed foreign groups can't be entered.
2712 (when (and (not (gnus-group-native-p group))
2713 (not (gnus-gethash group gnus-newsrc-hashtb)))
2714 (error "Dead non-native groups can't be entered"))
2715 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2716 (let* ((new-group (gnus-summary-setup-buffer group))
2717 (quit-config (gnus-group-quit-config group))
2718 (did-select (and new-group (gnus-select-newsgroup
2719 group show-all select-articles))))
2721 ;; This summary buffer exists already, so we just select it.
2723 (gnus-set-global-variables)
2725 (gnus-kill-or-deaden-summary kill-buffer))
2726 (gnus-configure-windows 'summary 'force)
2727 (gnus-set-mode-line 'summary)
2728 (gnus-summary-position-point)
2731 ;; We couldn't select this group.
2733 (when (and (eq major-mode 'gnus-summary-mode)
2734 (not (equal (current-buffer) kill-buffer)))
2735 (kill-buffer (current-buffer))
2736 (if (not quit-config)
2738 ;; Update the info -- marks might need to be removed,
2740 (gnus-summary-update-info)
2741 (set-buffer gnus-group-buffer)
2742 (gnus-group-jump-to-group group)
2743 (gnus-group-next-unread-group 1))
2744 (gnus-handle-ephemeral-exit quit-config)))
2745 (gnus-message 3 "Can't select group")
2747 ;; The user did a `C-g' while prompting for number of articles,
2748 ;; so we exit this group.
2749 ((eq did-select 'quit)
2750 (and (eq major-mode 'gnus-summary-mode)
2751 (not (equal (current-buffer) kill-buffer))
2752 (kill-buffer (current-buffer)))
2754 (gnus-kill-or-deaden-summary kill-buffer))
2755 (if (not quit-config)
2757 (set-buffer gnus-group-buffer)
2758 (gnus-group-jump-to-group group)
2759 (gnus-group-next-unread-group 1)
2760 (gnus-configure-windows 'group 'force))
2761 (gnus-handle-ephemeral-exit quit-config))
2762 ;; Finally signal the quit.
2764 ;; The group was successfully selected.
2766 (gnus-set-global-variables)
2767 ;; Save the active value in effect when the group was entered.
2768 (setq gnus-newsgroup-active
2770 (gnus-active gnus-newsgroup-name)))
2771 ;; You can change the summary buffer in some way with this hook.
2772 (gnus-run-hooks 'gnus-select-group-hook)
2773 ;; Set any local variables in the group parameters.
2774 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2775 (gnus-update-format-specifications
2776 nil 'summary 'summary-mode 'summary-dummy)
2777 ;; Do score processing.
2778 (when gnus-use-scoring
2779 (gnus-possibly-score-headers))
2780 ;; Check whether to fill in the gaps in the threads.
2781 (when gnus-build-sparse-threads
2782 (gnus-build-sparse-threads))
2783 ;; Find the initial limit.
2784 (if gnus-show-threads
2786 (let ((gnus-newsgroup-dormant nil))
2787 (gnus-summary-initial-limit show-all))
2788 (gnus-summary-initial-limit show-all))
2789 (setq gnus-newsgroup-limit
2791 (lambda (header) (mail-header-number header))
2792 gnus-newsgroup-headers)))
2793 ;; Generate the summary buffer.
2795 (gnus-summary-prepare))
2796 (when gnus-use-trees
2797 (gnus-tree-open group)
2798 (setq gnus-summary-highlight-line-function
2799 'gnus-tree-highlight-article))
2800 ;; If the summary buffer is empty, but there are some low-scored
2801 ;; articles or some excluded dormants, we include these in the
2803 (when (and (zerop (buffer-size))
2805 (cond (gnus-newsgroup-dormant
2806 (gnus-summary-limit-include-dormant))
2807 ((and gnus-newsgroup-scored show-all)
2808 (gnus-summary-limit-include-expunged t))))
2809 ;; Function `gnus-apply-kill-file' must be called in this hook.
2810 (gnus-run-hooks 'gnus-apply-kill-hook)
2811 (if (and (zerop (buffer-size))
2814 ;; This newsgroup is empty.
2815 (gnus-summary-catchup-and-exit nil t)
2816 (gnus-message 6 "No unread news")
2818 (gnus-kill-or-deaden-summary kill-buffer))
2819 ;; Return nil from this function.
2821 ;; Hide conversation thread subtrees. We cannot do this in
2822 ;; gnus-summary-prepare-hook since kill processing may not
2823 ;; work with hidden articles.
2824 (and gnus-show-threads
2825 gnus-thread-hide-subtree
2826 (gnus-summary-hide-all-threads))
2828 (gnus-kill-or-deaden-summary kill-buffer))
2829 ;; Show first unread article if requested.
2830 (if (and (not no-article)
2832 gnus-newsgroup-unreads
2833 gnus-auto-select-first)
2835 (gnus-configure-windows 'summary)
2837 ((eq gnus-auto-select-first 'best)
2838 (gnus-summary-best-unread-article))
2839 ((eq gnus-auto-select-first t)
2840 (gnus-summary-first-unread-article))
2841 ((gnus-functionp gnus-auto-select-first)
2842 (funcall gnus-auto-select-first))))
2843 ;; Don't select any articles, just move point to the first
2844 ;; article in the group.
2845 (goto-char (point-min))
2846 (gnus-summary-position-point)
2847 (gnus-configure-windows 'summary 'force)
2848 (gnus-set-mode-line 'summary))
2849 (when (get-buffer-window gnus-group-buffer t)
2850 ;; Gotta use windows, because recenter does weird stuff if
2851 ;; the current buffer ain't the displayed window.
2852 (let ((owin (selected-window)))
2853 (select-window (get-buffer-window gnus-group-buffer t))
2854 (when (gnus-group-goto-group group)
2856 (select-window owin)))
2857 ;; Mark this buffer as "prepared".
2858 (setq gnus-newsgroup-prepared t)
2859 (gnus-run-hooks 'gnus-summary-prepared-hook)
2862 (defun gnus-summary-prepare ()
2863 "Generate the summary buffer."
2865 (let ((buffer-read-only nil))
2867 (setq gnus-newsgroup-data nil
2868 gnus-newsgroup-data-reverse nil)
2869 (gnus-run-hooks 'gnus-summary-generate-hook)
2870 ;; Generate the buffer, either with threads or without.
2871 (when gnus-newsgroup-headers
2872 (gnus-summary-prepare-threads
2873 (if gnus-show-threads
2874 (gnus-sort-gathered-threads
2875 (funcall gnus-summary-thread-gathering-function
2877 (gnus-cut-threads (gnus-make-threads)))))
2878 ;; Unthreaded display.
2879 (gnus-sort-articles gnus-newsgroup-headers))))
2880 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2881 ;; Call hooks for modifying summary buffer.
2882 (goto-char (point-min))
2883 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2885 (defsubst gnus-general-simplify-subject (subject)
2886 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2889 ;; Truncate the subject.
2890 (gnus-simplify-subject-functions
2891 (gnus-map-function gnus-simplify-subject-functions subject))
2892 ((numberp gnus-summary-gather-subject-limit)
2893 (setq subject (gnus-simplify-subject-re subject))
2894 (if (> (length subject) gnus-summary-gather-subject-limit)
2895 (substring subject 0 gnus-summary-gather-subject-limit)
2897 ;; Fuzzily simplify it.
2898 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2899 (gnus-simplify-subject-fuzzy subject))
2900 ;; Just remove the leading "Re:".
2902 (gnus-simplify-subject-re subject))))
2904 (if (and gnus-summary-gather-exclude-subject
2905 (string-match gnus-summary-gather-exclude-subject subject))
2906 nil ; This article shouldn't be gathered
2909 (defun gnus-summary-simplify-subject-query ()
2910 "Query where the respool algorithm would put this article."
2912 (gnus-summary-select-article)
2913 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2915 (defun gnus-gather-threads-by-subject (threads)
2916 "Gather threads by looking at Subject headers."
2917 (if (not gnus-summary-make-false-root)
2919 (let ((hashtb (gnus-make-hashtable 1024))
2922 subject hthread whole-subject)
2924 (setq subject (gnus-general-simplify-subject
2925 (setq whole-subject (mail-header-subject
2928 (if (setq hthread (gnus-gethash subject hashtb))
2930 ;; We enter a dummy root into the thread, if we
2931 ;; haven't done that already.
2932 (unless (stringp (caar hthread))
2933 (setcar hthread (list whole-subject (car hthread))))
2934 ;; We add this new gathered thread to this gathered
2936 (setcdr (car hthread)
2937 (nconc (cdar hthread) (list (car threads))))
2938 ;; Remove it from the list of threads.
2939 (setcdr prev (cdr threads))
2940 (setq threads prev))
2941 ;; Enter this thread into the hash table.
2942 (gnus-sethash subject threads hashtb)))
2944 (setq threads (cdr threads)))
2947 (defun gnus-gather-threads-by-references (threads)
2948 "Gather threads by looking at References headers."
2949 (let ((idhashtb (gnus-make-hashtable 1024))
2950 (thhashtb (gnus-make-hashtable 1024))
2953 ids references id gthread gid entered ref)
2955 (when (setq references (mail-header-references (caar threads)))
2956 (setq id (mail-header-id (caar threads))
2957 ids (gnus-split-references references)
2959 (while (setq ref (pop ids))
2960 (setq ids (delete ref ids))
2961 (if (not (setq gid (gnus-gethash ref idhashtb)))
2963 (gnus-sethash ref id idhashtb)
2964 (gnus-sethash id threads thhashtb))
2965 (setq gthread (gnus-gethash gid thhashtb))
2967 ;; We enter a dummy root into the thread, if we
2968 ;; haven't done that already.
2969 (unless (stringp (caar gthread))
2970 (setcar gthread (list (mail-header-subject (caar gthread))
2972 ;; We add this new gathered thread to this gathered
2974 (setcdr (car gthread)
2975 (nconc (cdar gthread) (list (car threads)))))
2976 ;; Add it into the thread hash table.
2977 (gnus-sethash id gthread thhashtb)
2979 ;; Remove it from the list of threads.
2980 (setcdr prev (cdr threads))
2981 (setq threads prev))))
2983 (setq threads (cdr threads)))
2986 (defun gnus-sort-gathered-threads (threads)
2987 "Sort subtreads inside each gathered thread by article number."
2988 (let ((result threads))
2990 (when (stringp (caar threads))
2991 (setcdr (car threads)
2992 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2993 (setq threads (cdr threads)))
2996 (defun gnus-thread-loop-p (root thread)
2997 "Say whether ROOT is in THREAD."
2998 (let ((stack (list thread))
3001 (while (setq thread (pop stack))
3002 (setq th (cdr thread))
3004 (not (eq (caar th) root)))
3007 ;; We have found a loop.
3009 (setcdr thread (delq (car th) (cdr thread)))
3010 (if (boundp (setq ref-dep (intern "none"
3011 gnus-newsgroup-dependencies)))
3012 (setcdr (symbol-value ref-dep)
3013 (nconc (cdr (symbol-value ref-dep))
3015 (set ref-dep (list nil (car th))))
3018 ;; Push all the subthreads onto the stack.
3019 (push (cdr thread) stack)))
3022 (defun gnus-make-threads ()
3023 "Go through the dependency hashtb and find the roots. Return all threads."
3025 (while (catch 'infloop
3028 ;; Deal with self-referencing References loops.
3029 (when (and (car (symbol-value refs))
3036 (car (symbol-value refs)) thread))
3037 (cdr (symbol-value refs)))))))
3040 (unless (car (symbol-value refs))
3041 ;; These threads do not refer back to any other articles,
3042 ;; so they're roots.
3043 (setq threads (append (cdr (symbol-value refs)) threads))))
3044 gnus-newsgroup-dependencies)))
3047 ;; Build the thread tree.
3048 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3049 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3051 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3052 if it was already present.
3054 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3055 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3056 Message-IDs will be renamed be renamed to a unique Message-ID before
3059 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3060 (let* ((id (mail-header-id header))
3061 (id-dep (and id (intern id dependencies)))
3062 ref ref-dep ref-header)
3063 ;; Enter this `header' in the `dependencies' table.
3067 ;; The first two cases do the normal part: enter a new `header'
3068 ;; in the `dependencies' table.
3069 ((not (boundp id-dep))
3070 (set id-dep (list header)))
3071 ((null (car (symbol-value id-dep)))
3072 (setcar (symbol-value id-dep) header))
3074 ;; From here the `header' was already present in the
3075 ;; `dependencies' table.
3077 ;; Overrides an existing entry;
3078 ;; just set the header part of the entry.
3079 (setcar (symbol-value id-dep) header))
3081 ;; Renames the existing `header' to a unique Message-ID.
3082 ((not gnus-summary-ignore-duplicates)
3083 ;; An article with this Message-ID has already been seen.
3084 ;; We rename the Message-ID.
3085 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3087 (mail-header-set-id header id))
3089 ;; The last case ignores an existing entry, except it adds any
3090 ;; additional Xrefs (in case the two articles came from different
3092 ;; Also sets `header' to `nil' meaning that the `dependencies'
3093 ;; table was *not* modified.
3095 (mail-header-set-xref
3096 (car (symbol-value id-dep))
3097 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3099 (or (mail-header-xref header) "")))
3103 ;; First check if that we are not creating a References loop.
3104 (setq ref (gnus-parent-id (mail-header-references header)))
3106 (setq ref-dep (intern-soft ref dependencies))
3108 (setq ref-header (car (symbol-value ref-dep))))
3109 (if (string= id ref)
3110 ;; Yuk! This is a reference loop. Make the article be a
3113 (mail-header-set-references (car (symbol-value id-dep)) "none")
3115 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3116 (setq ref (gnus-parent-id (mail-header-references header)))
3117 (setq ref-dep (intern (or ref "none") dependencies))
3118 (if (boundp ref-dep)
3119 (setcdr (symbol-value ref-dep)
3120 (nconc (cdr (symbol-value ref-dep))
3121 (list (symbol-value id-dep))))
3122 (set ref-dep (list nil (symbol-value id-dep)))))
3125 (defun gnus-build-sparse-threads ()
3126 (let ((headers gnus-newsgroup-headers)
3127 (gnus-summary-ignore-duplicates t)
3128 header references generation relations
3129 subject child end new-child date)
3130 ;; First we create an alist of generations/relations, where
3131 ;; generations is how much we trust the relation, and the relation
3133 (gnus-message 7 "Making sparse threads...")
3135 (nnheader-set-temp-buffer " *gnus sparse threads*")
3136 (while (setq header (pop headers))
3137 (when (and (setq references (mail-header-references header))
3138 (not (string= references "")))
3140 (setq child (mail-header-id header)
3141 subject (mail-header-subject header)
3142 date (mail-header-date header)
3144 (while (search-backward ">" nil t)
3145 (setq end (1+ (point)))
3146 (when (search-backward "<" nil t)
3147 (setq new-child (buffer-substring (point) end))
3148 (push (list (incf generation)
3149 child (setq child new-child)
3153 (push (list (1+ generation) child nil subject) relations))
3155 (kill-buffer (current-buffer)))
3156 ;; Sort over trustworthiness.
3159 (when (gnus-dependencies-add-header
3160 (make-full-mail-header
3161 gnus-reffed-article-number
3162 (nth 3 relation) "" (or (nth 4 relation) "")
3164 (or (nth 2 relation) "") 0 0 "")
3165 gnus-newsgroup-dependencies nil)
3166 (push gnus-reffed-article-number gnus-newsgroup-limit)
3167 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3168 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3169 gnus-newsgroup-reads)
3170 (decf gnus-reffed-article-number)))
3171 (sort relations 'car-less-than-car))
3172 (gnus-message 7 "Making sparse threads...done")))
3174 (defun gnus-build-old-threads ()
3175 ;; Look at all the articles that refer back to old articles, and
3176 ;; fetch the headers for the articles that aren't there. This will
3177 ;; build complete threads - if the roots haven't been expired by the
3182 (when (not (car (symbol-value refs)))
3183 (setq heads (cdr (symbol-value refs)))
3185 (if (memq (mail-header-number (caar heads))
3186 gnus-newsgroup-dormant)
3187 (setq heads (cdr heads))
3188 (setq id (symbol-name refs))
3189 (while (and (setq id (gnus-build-get-header id))
3190 (not (car (gnus-id-to-thread id)))))
3191 (setq heads nil)))))
3192 gnus-newsgroup-dependencies)))
3194 ;; This function has to be called with point after the article number
3195 ;; on the beginning of the line.
3196 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3197 (let ((eol (gnus-point-at-eol))
3198 (buffer (current-buffer))
3201 ;; overview: [num subject from date id refs chars lines misc]
3206 (make-full-mail-header
3208 (nnheader-nov-field) ; subject
3209 (nnheader-nov-field) ; from
3210 (nnheader-nov-field) ; date
3211 (nnheader-nov-read-message-id) ; id
3212 (nnheader-nov-field) ; refs
3213 (nnheader-nov-read-integer) ; chars
3214 (nnheader-nov-read-integer) ; lines
3216 (nnheader-nov-field)) ; misc
3217 (nnheader-nov-parse-extra))) ; extra
3219 (when gnus-alter-header-function
3220 (funcall gnus-alter-header-function header))
3221 (gnus-dependencies-add-header header dependencies force-new)))
3223 (defun gnus-build-get-header (id)
3224 ;; Look through the buffer of NOV lines and find the header to
3225 ;; ID. Enter this line into the dependencies hash table, and return
3226 ;; the id of the parent article (if any).
3227 (let ((deps gnus-newsgroup-dependencies)
3231 (set-buffer nntp-server-buffer)
3232 (let ((case-fold-search nil))
3233 (goto-char (point-min))
3234 (while (and (not found)
3235 (search-forward id nil t))
3237 (setq found (looking-at
3238 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3239 (regexp-quote id))))
3240 (or found (beginning-of-line 2)))
3244 (setq header (gnus-nov-parse-line
3245 (read (current-buffer)) deps))
3246 (gnus-parent-id (mail-header-references header))))))
3248 (let ((number (mail-header-number header)))
3249 (push number gnus-newsgroup-limit)
3250 (push header gnus-newsgroup-headers)
3251 (if (memq number gnus-newsgroup-unselected)
3253 (push number gnus-newsgroup-unreads)
3254 (setq gnus-newsgroup-unselected
3255 (delq number gnus-newsgroup-unselected)))
3256 (push number gnus-newsgroup-ancient)))))))
3258 (defun gnus-build-all-threads ()
3259 "Read all the headers."
3260 (let ((gnus-summary-ignore-duplicates t)
3261 (dependencies gnus-newsgroup-dependencies)
3264 (set-buffer nntp-server-buffer)
3265 (let ((case-fold-search nil))
3266 (goto-char (point-min))
3269 (setq article (read (current-buffer))
3270 header (gnus-nov-parse-line
3271 article dependencies)))
3274 (set-buffer gnus-summary-buffer)
3275 (push header gnus-newsgroup-headers)
3276 (if (memq (setq article (mail-header-number header))
3277 gnus-newsgroup-unselected)
3279 (push article gnus-newsgroup-unreads)
3280 (setq gnus-newsgroup-unselected
3281 (delq article gnus-newsgroup-unselected)))
3282 (push article gnus-newsgroup-ancient)))
3283 (forward-line 1)))))))
3285 (defun gnus-summary-update-article-line (article header)
3286 "Update the line for ARTICLE using HEADERS."
3287 (let* ((id (mail-header-id header))
3288 (thread (gnus-id-to-thread id)))
3290 (error "Article in no thread"))
3291 ;; Update the thread.
3292 (setcar thread header)
3293 (gnus-summary-goto-subject article)
3294 (let* ((datal (gnus-data-find-list article))
3296 (length (when (cdr datal)
3297 (- (gnus-data-pos data)
3298 (gnus-data-pos (cadr datal)))))
3299 (buffer-read-only nil)
3300 (level (gnus-summary-thread-level)))
3302 (gnus-summary-insert-line
3303 header level nil (gnus-article-mark article)
3304 (memq article gnus-newsgroup-replied)
3305 (memq article gnus-newsgroup-expirable)
3306 ;; Only insert the Subject string when it's different
3307 ;; from the previous Subject string.
3308 (if (gnus-subject-equal
3310 (mail-header-subject
3313 (gnus-data-find-list
3315 (gnus-data-list t)))))
3316 ;; Error on the side of excessive subjects.
3318 (mail-header-subject header))
3320 (mail-header-subject header))
3321 nil (cdr (assq article gnus-newsgroup-scored))
3322 (memq article gnus-newsgroup-processable))
3324 (gnus-data-update-list
3325 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3327 (defun gnus-summary-update-article (article &optional iheader)
3328 "Update ARTICLE in the summary buffer."
3329 (set-buffer gnus-summary-buffer)
3330 (let* ((header (gnus-summary-article-header article))
3331 (id (mail-header-id header))
3332 (data (gnus-data-find article))
3333 (thread (gnus-id-to-thread id))
3334 (references (mail-header-references header))
3338 (when (and references
3339 (not (equal "" references)))
3342 (buffer-read-only nil)
3348 (delq thread parent)))
3349 (if (gnus-summary-insert-subject id header)
3350 ;; Set the (possibly) new article number in the data structure.
3351 (gnus-data-set-number data (gnus-id-to-article id))
3355 (defun gnus-rebuild-thread (id &optional line)
3356 "Rebuild the thread containing ID.
3357 If LINE, insert the rebuilt thread starting on line LINE."
3358 (let ((buffer-read-only nil)
3359 old-pos current thread data)
3360 (if (not gnus-show-threads)
3361 (setq thread (list (car (gnus-id-to-thread id))))
3362 ;; Get the thread this article is part of.
3363 (setq thread (gnus-remove-thread id)))
3364 (setq old-pos (gnus-point-at-bol))
3365 (setq current (save-excursion
3366 (and (zerop (forward-line -1))
3367 (gnus-summary-article-number))))
3368 ;; If this is a gathered thread, we have to go some re-gathering.
3369 (when (stringp (car thread))
3370 (let ((subject (car thread))
3372 (setq thread (cdr thread))
3374 (unless (memq (setq thr (gnus-id-to-thread
3376 (mail-header-id (caar thread)))))
3379 (setq thread (cdr thread)))
3380 ;; We now have all (unique) roots.
3381 (if (= (length roots) 1)
3382 ;; All the loose roots are now one solid root.
3383 (setq thread (car roots))
3384 (setq thread (cons subject (gnus-sort-threads roots))))))
3386 ;; We then insert this thread into the summary buffer.
3388 (goto-char (point-min))
3389 (forward-line (1- line)))
3390 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3391 (if gnus-show-threads
3392 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3393 (gnus-summary-prepare-unthreaded thread))
3394 (setq data (nreverse gnus-newsgroup-data))
3395 (setq threads gnus-newsgroup-threads))
3396 ;; We splice the new data into the data structure.
3397 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3398 ;;!!! then we want to insert at the beginning of the buffer.
3399 ;;!!! That happens to be true with Gnus now, but that may
3400 ;;!!! change in the future. Perhaps.
3401 (gnus-data-enter-list
3402 (if line nil current) data (- (point) old-pos))
3403 (setq gnus-newsgroup-threads
3404 (nconc threads gnus-newsgroup-threads))
3405 (gnus-data-compute-positions))))
3407 (defun gnus-number-to-header (number)
3408 "Return the header for article NUMBER."
3409 (let ((headers gnus-newsgroup-headers))
3411 (not (= number (mail-header-number (car headers)))))
3416 (defun gnus-parent-headers (in-headers &optional generation)
3417 "Return the headers of the GENERATIONeth parent of HEADERS."
3419 (setq generation 1))
3421 (headers in-headers)
3424 (not (zerop generation))
3425 (setq references (mail-header-references headers)))
3426 (setq headers (if (and references
3427 (setq parent (gnus-parent-id references)))
3428 (car (gnus-id-to-thread parent))
3431 (and (not (eq headers in-headers))
3434 (defun gnus-id-to-thread (id)
3435 "Return the (sub-)thread where ID appears."
3436 (gnus-gethash id gnus-newsgroup-dependencies))
3438 (defun gnus-id-to-article (id)
3439 "Return the article number of ID."
3440 (let ((thread (gnus-id-to-thread id)))
3443 (mail-header-number (car thread)))))
3445 (defun gnus-id-to-header (id)
3446 "Return the article headers of ID."
3447 (car (gnus-id-to-thread id)))
3449 (defun gnus-article-displayed-root-p (article)
3450 "Say whether ARTICLE is a root(ish) article."
3451 (let ((level (gnus-summary-thread-level article))
3452 (refs (mail-header-references (gnus-summary-article-header article)))
3458 ((null (gnus-parent-id refs)) t)
3460 (null (setq particle (gnus-id-to-article
3461 (gnus-parent-id refs))))
3462 (null (gnus-summary-thread-level particle)))))))
3464 (defun gnus-root-id (id)
3465 "Return the id of the root of the thread where ID appears."
3467 (while (and id (setq prev (car (gnus-id-to-thread id))))
3469 id (gnus-parent-id (mail-header-references prev))))
3472 (defun gnus-articles-in-thread (thread)
3473 "Return the list of articles in THREAD."
3474 (cons (mail-header-number (car thread))
3475 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3477 (defun gnus-remove-thread (id &optional dont-remove)
3478 "Remove the thread that has ID in it."
3479 (let (headers thread last-id)
3480 ;; First go up in this thread until we find the root.
3481 (setq last-id (gnus-root-id id)
3482 headers (message-flatten-list (gnus-id-to-thread last-id)))
3483 ;; We have now found the real root of this thread. It might have
3484 ;; been gathered into some loose thread, so we have to search
3485 ;; through the threads to find the thread we wanted.
3486 (let ((threads gnus-newsgroup-threads)
3489 (setq sub (car threads))
3490 (if (stringp (car sub))
3491 ;; This is a gathered thread, so we look at the roots
3492 ;; below it to find whether this article is in this
3495 (setq sub (cdr sub))
3497 (when (member (caar sub) headers)
3498 (setq thread (car threads)
3501 (setq sub (cdr sub))))
3502 ;; It's an ordinary thread, so we check it.
3503 (when (eq (car sub) (car headers))
3506 (setq threads (cdr threads)))
3507 ;; If this article is in no thread, then it's a root.
3510 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3511 (setq thread (gnus-id-to-thread last-id)))
3514 thread ; We return this thread.
3516 (if (stringp (car thread))
3518 ;; If we use dummy roots, then we have to remove the
3519 ;; dummy root as well.
3520 (when (eq gnus-summary-make-false-root 'dummy)
3521 ;; We go to the dummy root by going to
3522 ;; the first sub-"thread", and then one line up.
3523 (gnus-summary-goto-article
3524 (mail-header-number (caadr thread)))
3527 (gnus-data-compute-positions))
3528 (setq thread (cdr thread))
3530 (gnus-remove-thread-1 (car thread))
3531 (setq thread (cdr thread))))
3532 (gnus-summary-show-all-threads)
3533 (gnus-remove-thread-1 thread))))))))
3535 (defun gnus-remove-thread-1 (thread)
3536 "Remove the thread THREAD recursively."
3537 (let ((number (mail-header-number (pop thread)))
3539 (setq thread (reverse thread))
3541 (gnus-remove-thread-1 (pop thread)))
3542 (when (setq d (gnus-data-find number))
3543 (goto-char (gnus-data-pos d))
3546 (- (gnus-point-at-bol)
3548 (1+ (gnus-point-at-eol))
3549 (gnus-delete-line)))))))
3551 (defun gnus-sort-threads (threads)
3553 (if (not gnus-thread-sort-functions)
3555 (gnus-message 8 "Sorting threads...")
3557 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3558 (gnus-message 8 "Sorting threads...done"))))
3560 (defun gnus-sort-articles (articles)
3562 (when gnus-article-sort-functions
3563 (gnus-message 7 "Sorting articles...")
3565 (setq gnus-newsgroup-headers
3566 (sort articles (gnus-make-sort-function
3567 gnus-article-sort-functions)))
3568 (gnus-message 7 "Sorting articles...done"))))
3570 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3571 (defmacro gnus-thread-header (thread)
3572 ;; Return header of first article in THREAD.
3573 ;; Note that THREAD must never, ever be anything else than a variable -
3574 ;; using some other form will lead to serious barfage.
3575 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3576 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3577 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3580 (defsubst gnus-article-sort-by-number (h1 h2)
3581 "Sort articles by article number."
3582 (< (mail-header-number h1)
3583 (mail-header-number h2)))
3585 (defun gnus-thread-sort-by-number (h1 h2)
3586 "Sort threads by root article number."
3587 (gnus-article-sort-by-number
3588 (gnus-thread-header h1) (gnus-thread-header h2)))
3590 (defsubst gnus-article-sort-by-lines (h1 h2)
3591 "Sort articles by article Lines header."
3592 (< (mail-header-lines h1)
3593 (mail-header-lines h2)))
3595 (defun gnus-thread-sort-by-lines (h1 h2)
3596 "Sort threads by root article Lines header."
3597 (gnus-article-sort-by-lines
3598 (gnus-thread-header h1) (gnus-thread-header h2)))
3600 (defsubst gnus-article-sort-by-chars (h1 h2)
3601 "Sort articles by octet length."
3602 (< (mail-header-chars h1)
3603 (mail-header-chars h2)))
3605 (defun gnus-thread-sort-by-chars (h1 h2)
3606 "Sort threads by root article octet length."
3607 (gnus-article-sort-by-chars
3608 (gnus-thread-header h1) (gnus-thread-header h2)))
3610 (defsubst gnus-article-sort-by-author (h1 h2)
3611 "Sort articles by root author."
3613 (let ((addr (car (mime-read-field 'From h1))))
3614 (or (std11-full-name-string addr)
3615 (std11-address-string addr)
3617 (let ((addr (car (mime-read-field 'From h2))))
3618 (or (std11-full-name-string addr)
3619 (std11-address-string addr)
3623 (defun gnus-thread-sort-by-author (h1 h2)
3624 "Sort threads by root author."
3625 (gnus-article-sort-by-author
3626 (gnus-thread-header h1) (gnus-thread-header h2)))
3628 (defsubst gnus-article-sort-by-subject (h1 h2)
3629 "Sort articles by root subject."
3631 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3632 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3634 (defun gnus-thread-sort-by-subject (h1 h2)
3635 "Sort threads by root subject."
3636 (gnus-article-sort-by-subject
3637 (gnus-thread-header h1) (gnus-thread-header h2)))
3639 (defsubst gnus-article-sort-by-date (h1 h2)
3640 "Sort articles by root article date."
3642 (gnus-date-get-time (mail-header-date h1))
3643 (gnus-date-get-time (mail-header-date h2))))
3645 (defun gnus-thread-sort-by-date (h1 h2)
3646 "Sort threads by root article date."
3647 (gnus-article-sort-by-date
3648 (gnus-thread-header h1) (gnus-thread-header h2)))
3650 (defsubst gnus-article-sort-by-score (h1 h2)
3651 "Sort articles by root article score.
3652 Unscored articles will be counted as having a score of zero."
3653 (> (or (cdr (assq (mail-header-number h1)
3654 gnus-newsgroup-scored))
3655 gnus-summary-default-score 0)
3656 (or (cdr (assq (mail-header-number h2)
3657 gnus-newsgroup-scored))
3658 gnus-summary-default-score 0)))
3660 (defun gnus-thread-sort-by-score (h1 h2)
3661 "Sort threads by root article score."
3662 (gnus-article-sort-by-score
3663 (gnus-thread-header h1) (gnus-thread-header h2)))
3665 (defun gnus-thread-sort-by-total-score (h1 h2)
3666 "Sort threads by the sum of all scores in the thread.
3667 Unscored articles will be counted as having a score of zero."
3668 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3670 (defun gnus-thread-total-score (thread)
3671 ;; This function find the total score of THREAD.
3672 (cond ((null thread)
3675 (if (stringp (car thread))
3676 (apply gnus-thread-score-function 0
3677 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3678 (gnus-thread-total-score-1 thread)))
3680 (gnus-thread-total-score-1 (list thread)))))
3682 (defun gnus-thread-total-score-1 (root)
3683 ;; This function find the total score of the thread below ROOT.
3684 (setq root (car root))
3685 (apply gnus-thread-score-function
3687 (mapcar 'gnus-thread-total-score
3688 (cdr (gnus-id-to-thread (mail-header-id root))))
3689 (when (> (mail-header-number root) 0)
3690 (list (or (cdr (assq (mail-header-number root)
3691 gnus-newsgroup-scored))
3692 gnus-summary-default-score 0))))
3693 (list gnus-summary-default-score)
3696 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3697 (defvar gnus-tmp-prev-subject nil)
3698 (defvar gnus-tmp-false-parent nil)
3699 (defvar gnus-tmp-root-expunged nil)
3700 (defvar gnus-tmp-dummy-line nil)
3702 (defvar gnus-tmp-header)
3703 (defun gnus-extra-header (type &optional header)
3704 "Return the extra header of TYPE."
3705 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3708 (defun gnus-summary-prepare-threads (threads)
3709 "Prepare summary buffer from THREADS and indentation LEVEL.
3710 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3711 or a straight list of headers."
3712 (gnus-message 7 "Generating summary...")
3714 (setq gnus-newsgroup-threads threads)
3717 (let ((gnus-tmp-level 0)
3718 (default-score (or gnus-summary-default-score 0))
3719 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3720 thread number subject stack state gnus-tmp-gathered beg-match
3721 new-roots gnus-tmp-new-adopts thread-end
3722 gnus-tmp-header gnus-tmp-unread
3723 gnus-tmp-replied gnus-tmp-subject-or-nil
3724 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3725 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3726 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3728 (setq gnus-tmp-prev-subject nil)
3730 (if (vectorp (car threads))
3731 ;; If this is a straight (sic) list of headers, then a
3732 ;; threaded summary display isn't required, so we just create
3733 ;; an unthreaded one.
3734 (gnus-summary-prepare-unthreaded threads)
3736 ;; Do the threaded display.
3738 (while (or threads stack gnus-tmp-new-adopts new-roots)
3740 (if (and (= gnus-tmp-level 0)
3743 (not gnus-tmp-false-parent)
3744 (or gnus-tmp-new-adopts new-roots))
3745 (if gnus-tmp-new-adopts
3746 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3747 thread (list (car gnus-tmp-new-adopts))
3748 gnus-tmp-header (caar thread)
3749 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3751 (setq thread (list (car new-roots))
3752 gnus-tmp-header (caar thread)
3753 new-roots (cdr new-roots))))
3756 ;; If there are some threads, we do them before the
3757 ;; threads on the stack.
3758 (setq thread threads
3759 gnus-tmp-header (caar thread))
3760 ;; There were no current threads, so we pop something off
3762 (setq state (car stack)
3763 gnus-tmp-level (car state)
3766 gnus-tmp-header (caar thread))))
3768 (setq gnus-tmp-false-parent nil)
3769 (setq gnus-tmp-root-expunged nil)
3770 (setq thread-end nil)
3772 (if (stringp gnus-tmp-header)
3773 ;; The header is a dummy root.
3775 ((eq gnus-summary-make-false-root 'adopt)
3776 ;; We let the first article adopt the rest.
3777 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3779 (setq gnus-tmp-gathered
3781 (lambda (h) (mail-header-number (car h)))
3784 (setq thread (cons (list (caar thread)
3787 (setq gnus-tmp-level -1
3788 gnus-tmp-false-parent t))
3789 ((eq gnus-summary-make-false-root 'empty)
3790 ;; We print adopted articles with empty subject fields.
3791 (setq gnus-tmp-gathered
3793 (lambda (h) (mail-header-number (car h)))
3796 (setq gnus-tmp-level -1))
3797 ((eq gnus-summary-make-false-root 'dummy)
3798 ;; We remember that we probably want to output a dummy
3800 (setq gnus-tmp-dummy-line gnus-tmp-header)
3801 (setq gnus-tmp-prev-subject gnus-tmp-header))
3803 ;; We do not make a root for the gathered
3804 ;; sub-threads at all.
3805 (setq gnus-tmp-level -1)))
3807 (setq number (mail-header-number gnus-tmp-header)
3808 subject (mail-header-subject gnus-tmp-header))
3811 ;; If the thread has changed subject, we might want to make
3812 ;; this subthread into a root.
3813 ((and (null gnus-thread-ignore-subject)
3814 (not (zerop gnus-tmp-level))
3815 gnus-tmp-prev-subject
3817 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3818 (setq new-roots (nconc new-roots (list (car thread)))
3820 gnus-tmp-header nil))
3821 ;; If the article lies outside the current limit,
3822 ;; then we do not display it.
3823 ((not (memq number gnus-newsgroup-limit))
3824 (setq gnus-tmp-gathered
3826 (lambda (h) (mail-header-number (car h)))
3829 (setq gnus-tmp-new-adopts (if (cdar thread)
3830 (append gnus-tmp-new-adopts
3832 gnus-tmp-new-adopts)
3834 gnus-tmp-header nil)
3835 (when (zerop gnus-tmp-level)
3836 (setq gnus-tmp-root-expunged t)))
3837 ;; Perhaps this article is to be marked as read?
3838 ((and gnus-summary-mark-below
3839 (< (or (cdr (assq number gnus-newsgroup-scored))
3841 gnus-summary-mark-below)
3842 ;; Don't touch sparse articles.
3843 (not (gnus-summary-article-sparse-p number))
3844 (not (gnus-summary-article-ancient-p number)))
3845 (setq gnus-newsgroup-unreads
3846 (delq number gnus-newsgroup-unreads))
3847 (if gnus-newsgroup-auto-expire
3848 (push number gnus-newsgroup-expirable)
3849 (push (cons number gnus-low-score-mark)
3850 gnus-newsgroup-reads))))
3852 (when gnus-tmp-header
3853 ;; We may have an old dummy line to output before this
3855 (when (and gnus-tmp-dummy-line
3858 (mail-header-subject gnus-tmp-header)))
3859 (gnus-summary-insert-dummy-line
3860 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3861 (setq gnus-tmp-dummy-line nil))
3863 ;; Compute the mark.
3864 (setq gnus-tmp-unread (gnus-article-mark number))
3866 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3867 gnus-tmp-header gnus-tmp-level)
3868 gnus-newsgroup-data)
3870 ;; Actually insert the line.
3872 gnus-tmp-subject-or-nil
3874 ((and gnus-thread-ignore-subject
3875 gnus-tmp-prev-subject
3876 (not (inline (gnus-subject-equal
3877 gnus-tmp-prev-subject subject))))
3879 ((zerop gnus-tmp-level)
3880 (if (and (eq gnus-summary-make-false-root 'empty)
3881 (memq number gnus-tmp-gathered)
3882 gnus-tmp-prev-subject
3883 (inline (gnus-subject-equal
3884 gnus-tmp-prev-subject subject)))
3885 gnus-summary-same-subject
3887 (t gnus-summary-same-subject)))
3888 (if (and (eq gnus-summary-make-false-root 'adopt)
3889 (= gnus-tmp-level 1)
3890 (memq number gnus-tmp-gathered))
3891 (setq gnus-tmp-opening-bracket ?\<
3892 gnus-tmp-closing-bracket ?\>)
3893 (setq gnus-tmp-opening-bracket ?\[
3894 gnus-tmp-closing-bracket ?\]))
3896 gnus-tmp-indentation
3897 (aref gnus-thread-indent-array gnus-tmp-level)
3898 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3899 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3900 gnus-summary-default-score 0)
3902 (if (or (null gnus-summary-default-score)
3903 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3904 gnus-summary-zcore-fuzz))
3906 (if (< gnus-tmp-score gnus-summary-default-score)
3907 gnus-score-below-mark gnus-score-over-mark))
3909 (cond ((memq number gnus-newsgroup-processable)
3911 ((memq number gnus-newsgroup-cached)
3913 ((memq number gnus-newsgroup-replied)
3915 ((memq number gnus-newsgroup-saved)
3917 (t gnus-unread-mark))
3918 gnus-tmp-from (mail-header-from gnus-tmp-header)
3921 ((string-match "<[^>]+> *$" gnus-tmp-from)
3922 (setq beg-match (match-beginning 0))
3923 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3924 (substring gnus-tmp-from (1+ (match-beginning 0))
3925 (1- (match-end 0))))
3926 (substring gnus-tmp-from 0 beg-match)))
3927 ((string-match "(.+)" gnus-tmp-from)
3928 (substring gnus-tmp-from
3929 (1+ (match-beginning 0)) (1- (match-end 0))))
3931 (when (string= gnus-tmp-name "")
3932 (setq gnus-tmp-name gnus-tmp-from))
3933 (unless (numberp gnus-tmp-lines)
3934 (setq gnus-tmp-lines 0))
3935 (gnus-put-text-property
3937 (progn (eval gnus-summary-line-format-spec) (point))
3938 'gnus-number number)
3941 (gnus-run-hooks 'gnus-summary-update-hook)
3944 (setq gnus-tmp-prev-subject subject)))
3946 (when (nth 1 thread)
3947 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3948 (incf gnus-tmp-level)
3949 (setq threads (if thread-end nil (cdar thread)))
3951 (setq gnus-tmp-level 0)))))
3952 (gnus-message 7 "Generating summary...done"))
3954 (defun gnus-summary-prepare-unthreaded (headers)
3955 "Generate an unthreaded summary buffer based on HEADERS."
3956 (let (header number mark)
3961 ;; We may have to root out some bad articles...
3962 (when (memq (setq number (mail-header-number
3963 (setq header (pop headers))))
3964 gnus-newsgroup-limit)
3965 ;; Mark article as read when it has a low score.
3966 (when (and gnus-summary-mark-below
3967 (< (or (cdr (assq number gnus-newsgroup-scored))
3968 gnus-summary-default-score 0)
3969 gnus-summary-mark-below)
3970 (not (gnus-summary-article-ancient-p number)))
3971 (setq gnus-newsgroup-unreads
3972 (delq number gnus-newsgroup-unreads))
3973 (if gnus-newsgroup-auto-expire
3974 (push number gnus-newsgroup-expirable)
3975 (push (cons number gnus-low-score-mark)
3976 gnus-newsgroup-reads)))
3978 (setq mark (gnus-article-mark number))
3979 (push (gnus-data-make number mark (1+ (point)) header 0)
3980 gnus-newsgroup-data)
3981 (gnus-summary-insert-line
3983 mark (memq number gnus-newsgroup-replied)
3984 (memq number gnus-newsgroup-expirable)
3985 (mail-header-subject header) nil
3986 (cdr (assq number gnus-newsgroup-scored))
3987 (memq number gnus-newsgroup-processable))))))
3989 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3990 "Select newsgroup GROUP.
3991 If READ-ALL is non-nil, all articles in the group are selected.
3992 If SELECT-ARTICLES, only select those articles from GROUP."
3993 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3994 ;;!!! Dirty hack; should be removed.
3995 (gnus-summary-ignore-duplicates
3996 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3998 gnus-summary-ignore-duplicates))
3999 (info (nth 2 entry))
4000 articles fetched-articles cached)
4002 (unless (gnus-check-server
4003 (setq gnus-current-select-method
4004 (gnus-find-method-for-group group)))
4005 (error "Couldn't open server"))
4007 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4008 (gnus-activate-group group) ; Or we can activate it...
4009 (progn ; Or we bug out.
4010 (when (equal major-mode 'gnus-summary-mode)
4011 (kill-buffer (current-buffer)))
4012 (error "Couldn't request group %s: %s"
4013 group (gnus-status-message group))))
4015 (unless (gnus-request-group group t)
4016 (when (equal major-mode 'gnus-summary-mode)
4017 (kill-buffer (current-buffer)))
4018 (error "Couldn't request group %s: %s"
4019 group (gnus-status-message group)))
4021 (setq gnus-newsgroup-name group)
4022 (setq gnus-newsgroup-unselected nil)
4023 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4024 (gnus-summary-setup-default-charset)
4026 ;; Adjust and set lists of article marks.
4028 (gnus-adjust-marked-articles info))
4030 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4032 (if (gnus-virtual-group-p group)
4033 gnus-newsgroup-cached
4034 (gnus-cache-articles-in-group group)))
4036 (setq gnus-newsgroup-unreads
4037 (gnus-set-difference
4038 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4039 gnus-newsgroup-dormant))
4041 (setq gnus-newsgroup-processable nil)
4043 (gnus-update-read-articles group gnus-newsgroup-unreads)
4045 (if (setq articles select-articles)
4046 (setq gnus-newsgroup-unselected
4047 (gnus-sorted-intersection
4048 gnus-newsgroup-unreads
4049 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4050 (setq articles (gnus-articles-to-read group read-all)))
4054 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4056 ((eq articles 0) nil)
4058 ;; Init the dependencies hash table.
4059 (setq gnus-newsgroup-dependencies
4060 (gnus-make-hashtable (length articles)))
4061 (gnus-set-global-variables)
4062 ;; Retrieve the headers and read them in.
4063 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4064 (setq gnus-newsgroup-headers
4065 (gnus-retrieve-parsed-headers
4066 articles gnus-newsgroup-name
4067 ;; We might want to fetch old headers, but
4068 ;; not if there is only 1 article.
4069 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4070 (not (numberp gnus-fetch-old-headers)))
4071 (> (length articles) 1))
4072 gnus-fetch-old-headers)))
4073 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4075 ;; Suppress duplicates?
4076 (when gnus-suppress-duplicates
4077 (gnus-dup-suppress-articles))
4079 ;; Set the initial limit.
4080 (setq gnus-newsgroup-limit (copy-sequence articles))
4081 ;; Remove canceled articles from the list of unread articles.
4082 (setq gnus-newsgroup-unreads
4083 (gnus-set-sorted-intersection
4084 gnus-newsgroup-unreads
4085 (setq fetched-articles
4086 (mapcar (lambda (headers) (mail-header-number headers))
4087 gnus-newsgroup-headers))))
4088 ;; Removed marked articles that do not exist.
4089 (gnus-update-missing-marks
4090 (gnus-sorted-complement fetched-articles articles))
4092 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4094 (setq gnus-newsgroup-cached cached))
4096 ;; We might want to build some more threads first.
4097 (when (and gnus-fetch-old-headers
4098 (eq gnus-headers-retrieved-by 'nov))
4099 (if (eq gnus-fetch-old-headers 'invisible)
4100 (gnus-build-all-threads)
4101 (gnus-build-old-threads)))
4102 ;; Let the Gnus agent mark articles as read.
4104 (gnus-agent-get-undownloaded-list))
4105 ;; Check whether auto-expire is to be done in this group.
4106 (setq gnus-newsgroup-auto-expire
4107 (gnus-group-auto-expirable-p group))
4108 ;; Set up the article buffer now, if necessary.
4109 (unless gnus-single-article-buffer
4110 (gnus-article-setup-buffer))
4111 ;; First and last article in this newsgroup.
4112 (when gnus-newsgroup-headers
4113 (setq gnus-newsgroup-begin
4114 (mail-header-number (car gnus-newsgroup-headers))
4117 (gnus-last-element gnus-newsgroup-headers))))
4118 ;; GROUP is successfully selected.
4119 (or gnus-newsgroup-headers t)))))
4121 (defun gnus-articles-to-read (group &optional read-all)
4122 ;; Find out what articles the user wants to read.
4124 ;; Select all articles if `read-all' is non-nil, or if there
4125 ;; are no unread articles.
4127 (and (zerop (length gnus-newsgroup-marked))
4128 (zerop (length gnus-newsgroup-unreads)))
4129 (eq (gnus-group-find-parameter group 'display)
4131 (gnus-uncompress-range (gnus-active group))
4132 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4133 (copy-sequence gnus-newsgroup-unreads))
4135 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4136 (scored (length scored-list))
4137 (number (length articles))
4138 (marked (+ (length gnus-newsgroup-marked)
4139 (length gnus-newsgroup-dormant)))
4147 ((and (or (<= scored marked) (= scored number))
4148 (natnump gnus-large-newsgroup)
4149 (> number gnus-large-newsgroup))
4150 (let ((input (read-from-minibuffer
4152 "How many articles from %s (max %d): "
4153 (gnus-limit-string gnus-newsgroup-name 35)
4155 (static-if (< emacs-major-version 20)
4156 (number-to-string gnus-large-newsgroup)
4158 (number-to-string gnus-large-newsgroup)
4160 (if (string-match "^[ \t]*$" input)
4163 ((and (> scored marked) (< scored number)
4164 (> (- scored number) 20))
4167 (format "%s %s (%d scored, %d total): "
4168 "How many articles from"
4169 group scored number))))
4170 (if (string-match "^[ \t]*$" input)
4174 (setq select (if (stringp select) (string-to-number select) select))
4175 (if (or (null select) (zerop select))
4177 (if (and (not (zerop scored)) (<= (abs select) scored))
4179 (setq articles (sort scored-list '<))
4180 (setq number (length articles)))
4181 (setq articles (copy-sequence articles)))
4183 (when (< (abs select) number)
4185 ;; Select the N oldest articles.
4186 (setcdr (nthcdr (1- (abs select)) articles) nil)
4187 ;; Select the N most recent articles.
4188 (setq articles (nthcdr (- number select) articles))))
4189 (setq gnus-newsgroup-unselected
4190 (gnus-sorted-intersection
4191 gnus-newsgroup-unreads
4192 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4195 (defun gnus-killed-articles (killed articles)
4198 (when (inline (gnus-member-of-range (car articles) killed))
4199 (push (car articles) out))
4200 (setq articles (cdr articles)))
4203 (defun gnus-uncompress-marks (marks)
4204 "Uncompress the mark ranges in MARKS."
4205 (let ((uncompressed '(score bookmark))
4208 (if (memq (caar marks) uncompressed)
4209 (push (car marks) out)
4210 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4211 (setq marks (cdr marks)))
4214 (defun gnus-adjust-marked-articles (info)
4215 "Set all article lists and remove all marks that are no longer valid."
4216 (let* ((marked-lists (gnus-info-marks info))
4217 (active (gnus-active (gnus-info-group info)))
4220 (types gnus-article-mark-lists)
4221 (uncompressed '(score bookmark killed))
4222 marks var articles article mark)
4225 (setq marks (pop marked-lists))
4226 (set (setq var (intern (format "gnus-newsgroup-%s"
4227 (car (rassq (setq mark (car marks))
4229 (if (memq (car marks) uncompressed) (cdr marks)
4230 (gnus-uncompress-range (cdr marks))))
4232 (setq articles (symbol-value var))
4234 ;; All articles have to be subsets of the active articles.
4236 ;; Adjust "simple" lists.
4237 ((memq mark '(tick dormant expire reply save))
4239 (when (or (< (setq article (pop articles)) min) (> article max))
4240 (set var (delq article (symbol-value var))))))
4242 ((memq mark uncompressed)
4243 (when (not (listp (cdr (symbol-value var))))
4244 (set var (list (symbol-value var))))
4245 (when (not (listp (cdr articles)))
4246 (setq articles (list articles)))
4248 (when (or (not (consp (setq article (pop articles))))
4249 (< (car article) min)
4250 (> (car article) max))
4251 (set var (delq article (symbol-value var))))))))))
4253 (defun gnus-update-missing-marks (missing)
4254 "Go through the list of MISSING articles and remove them from the mark lists."
4256 (let ((types gnus-article-mark-lists)
4258 ;; Go through all types.
4260 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4261 (when (symbol-value var)
4262 ;; This list has articles. So we delete all missing articles
4266 (set var (delq (pop m) (symbol-value var)))))))))
4268 (defun gnus-update-marks ()
4269 "Enter the various lists of marked articles into the newsgroup info list."
4270 (let ((types gnus-article-mark-lists)
4271 (info (gnus-get-info gnus-newsgroup-name))
4272 (uncompressed '(score bookmark killed))
4273 type list newmarked symbol delta-marks)
4275 ;; Add all marks lists to the list of marks lists.
4276 (while (setq type (pop types))
4277 (setq list (symbol-value
4279 (intern (format "gnus-newsgroup-%s"
4283 ;; Get rid of the entries of the articles that have the
4285 (when (and (eq (cdr type) 'score)
4289 (prev (cons nil list))
4292 (if (or (not (consp (car arts)))
4293 (= (cdar arts) gnus-summary-default-score))
4294 (setcdr prev (cdr arts))
4296 (setq arts (cdr arts)))
4297 (setq list (cdr all)))))
4299 (or (memq (cdr type) uncompressed)
4300 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4302 (when (gnus-check-backend-function 'request-set-mark
4303 gnus-newsgroup-name)
4304 ;; uncompressed:s are not proper flags (they are cons cells)
4305 ;; cache is a internal gnus flag
4306 (unless (memq (cdr type) (cons 'cache uncompressed))
4307 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4308 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4309 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4311 (push (list add 'add (list (cdr type))) delta-marks))
4313 (push (list del 'del (list (cdr type))) delta-marks)))))
4316 (push (cons (cdr type) list) newmarked)))
4319 (unless (gnus-check-group gnus-newsgroup-name)
4320 (error "Can't open server for %s" gnus-newsgroup-name))
4321 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4323 ;; Enter these new marks into the info of the group.
4325 (setcar (nthcdr 3 info) newmarked)
4326 ;; Add the marks lists to the end of the info.
4328 (setcdr (nthcdr 2 info) (list newmarked))))
4330 ;; Cut off the end of the info if there's nothing else there.
4334 (when (nthcdr (decf i) info)
4335 (setcdr (nthcdr i info) nil)))))))
4337 (defun gnus-set-mode-line (where)
4338 "This function sets the mode line of the article or summary buffers.
4339 If WHERE is `summary', the summary mode line format will be used."
4340 ;; Is this mode line one we keep updated?
4341 (when (and (memq where gnus-updated-mode-lines)
4343 (intern (format "gnus-%s-mode-line-format-spec" where))))
4346 ;; We evaluate this in the summary buffer since these
4347 ;; variables are buffer-local to that buffer.
4348 (set-buffer gnus-summary-buffer)
4349 ;; We bind all these variables that are used in the `eval' form
4351 (let* ((mformat (symbol-value
4353 (format "gnus-%s-mode-line-format-spec" where))))
4354 (gnus-tmp-group-name gnus-newsgroup-name)
4355 (gnus-tmp-article-number (or gnus-current-article 0))
4356 (gnus-tmp-unread gnus-newsgroup-unreads)
4357 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4358 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4359 (gnus-tmp-unread-and-unselected
4360 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4361 (zerop gnus-tmp-unselected))
4363 ((zerop gnus-tmp-unselected)
4364 (format "{%d more}" gnus-tmp-unread-and-unticked))
4365 (t (format "{%d(+%d) more}"
4366 gnus-tmp-unread-and-unticked
4367 gnus-tmp-unselected))))
4369 (if (and gnus-current-headers
4370 (vectorp gnus-current-headers))
4371 (gnus-mode-string-quote
4372 (mail-header-subject gnus-current-headers))
4374 bufname-length max-len
4375 gnus-tmp-header);; passed as argument to any user-format-funcs
4376 (setq mode-string (eval mformat))
4377 (setq bufname-length (if (string-match "%b" mode-string)
4380 (if (eq where 'summary)
4382 (get-buffer gnus-article-buffer))))
4385 (setq max-len (max 4 (if gnus-mode-non-string-length
4387 gnus-mode-non-string-length
4389 (length mode-string))))
4390 ;; We might have to chop a bit of the string off...
4391 (when (> (length mode-string) max-len)
4393 (concat (gnus-truncate-string mode-string (- max-len 3))
4395 ;; Pad the mode string a bit.
4396 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4397 ;; Update the mode line.
4398 (setq mode-line-buffer-identification
4399 (gnus-mode-line-buffer-identification (list mode-string)))
4400 (set-buffer-modified-p t))))
4402 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4403 "Go through the HEADERS list and add all Xrefs to a hash table.
4404 The resulting hash table is returned, or nil if no Xrefs were found."
4405 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4406 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4407 (xref-hashtb (gnus-make-hashtable))
4408 start group entry number xrefs header)
4410 (setq header (pop headers))
4411 (when (and (setq xrefs (mail-header-xref header))
4412 (not (memq (setq number (mail-header-number header))
4415 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4416 (setq start (match-end 0))
4417 (setq group (if prefix
4418 (concat prefix (substring xrefs (match-beginning 1)
4420 (substring xrefs (match-beginning 1) (match-end 1))))
4422 (string-to-int (substring xrefs (match-beginning 2)
4424 (if (setq entry (gnus-gethash group xref-hashtb))
4425 (setcdr entry (cons number (cdr entry)))
4426 (gnus-sethash group (cons number nil) xref-hashtb)))))
4427 (and start xref-hashtb)))
4429 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4430 "Look through all the headers and mark the Xrefs as read."
4431 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4432 name entry info xref-hashtb idlist method nth4)
4434 (set-buffer gnus-group-buffer)
4435 (when (setq xref-hashtb
4436 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4439 (unless (string= from-newsgroup (setq name (symbol-name group)))
4440 (setq idlist (symbol-value group))
4441 ;; Dead groups are not updated.
4443 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4445 (when (stringp (setq nth4 (gnus-info-method info)))
4446 (setq nth4 (gnus-server-to-method nth4))))
4447 ;; Only do the xrefs if the group has the same
4448 ;; select method as the group we have just read.
4449 (or (gnus-methods-equal-p
4450 nth4 (gnus-find-method-for-group from-newsgroup))
4452 (equal nth4 (setq method (gnus-find-method-for-group
4454 (and (equal (car nth4) (car method))
4455 (equal (nth 1 nth4) (nth 1 method))))
4456 gnus-use-cross-reference
4457 (or (not (eq gnus-use-cross-reference t))
4459 ;; Only do cross-references on subscribed
4460 ;; groups, if that is what is wanted.
4461 (<= (gnus-info-level info) gnus-level-subscribed))
4462 (gnus-group-make-articles-read name idlist))))
4465 (defun gnus-compute-read-articles (group articles)
4466 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4467 (info (nth 2 entry))
4468 (active (gnus-active group))
4471 ;; First peel off all invalid article numbers.
4473 (let ((ids articles)
4475 (while (setq id (pop ids))
4476 (when (and first (> id (cdr active)))
4477 ;; We'll end up in this situation in one particular
4478 ;; obscure situation. If you re-scan a group and get
4479 ;; a new article that is cross-posted to a different
4480 ;; group that has not been re-scanned, you might get
4481 ;; crossposted article that has a higher number than
4482 ;; Gnus believes possible. So we re-activate this
4483 ;; group as well. This might mean doing the
4484 ;; crossposting thingy will *increase* the number
4485 ;; of articles in some groups. Tsk, tsk.
4486 (setq active (or (gnus-activate-group group) active)))
4487 (when (or (> id (cdr active))
4488 (< id (car active)))
4489 (setq articles (delq id articles))))))
4490 ;; If the read list is nil, we init it.
4492 (null (gnus-info-read info))
4494 (setq ninfo (cons 1 (1- (car active))))
4495 (setq ninfo (gnus-info-read info)))
4496 ;; Then we add the read articles to the range.
4498 ninfo (setq articles (sort articles '<))))))
4500 (defun gnus-group-make-articles-read (group articles)
4501 "Update the info of GROUP to say that ARTICLES are read."
4503 (entry (gnus-gethash group gnus-newsrc-hashtb))
4504 (info (nth 2 entry))
4505 (active (gnus-active group))
4508 (setq range (gnus-compute-read-articles group articles))
4510 (set-buffer gnus-group-buffer)
4513 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4514 (gnus-info-set-read ',info ',(gnus-info-read info))
4515 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4516 (gnus-group-update-group ,group t))))
4517 ;; Add the read articles to the range.
4518 (gnus-info-set-read info range)
4519 ;; Then we have to re-compute how many unread
4520 ;; articles there are in this group.
4524 (setq num (- (1+ (cdr active)) (car active))))
4525 ((not (listp (cdr range)))
4526 (setq num (- (cdr active) (- (1+ (cdr range))
4530 (if (numberp (car range))
4532 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4533 (setq range (cdr range)))
4534 (setq num (- (cdr active) num))))
4535 ;; Update the number of unread articles.
4537 ;; Update the group buffer.
4538 (gnus-group-update-group group t)))))
4540 (defvar gnus-newsgroup-none-id 0)
4542 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4543 (let ((cur nntp-server-buffer)
4546 (save-excursion (set-buffer gnus-summary-buffer)
4547 gnus-newsgroup-dependencies)))
4549 (mail-parse-charset gnus-newsgroup-charset))
4551 (set-buffer nntp-server-buffer)
4552 ;; Translate all TAB characters into SPACE characters.
4553 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4554 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4555 (gnus-run-hooks 'gnus-parse-headers-hook)
4556 (let ((case-fold-search t)
4557 in-reply-to header p lines chars ctype)
4558 (goto-char (point-min))
4559 ;; Search to the beginning of the next header. Error messages
4560 ;; do not begin with 2 or 3.
4561 (while (re-search-forward "^[23][0-9]+ " nil t)
4564 ;; This implementation of this function, with nine
4565 ;; search-forwards instead of the one re-search-forward and
4566 ;; a case (which basically was the old function) is actually
4567 ;; about twice as fast, even though it looks messier. You
4568 ;; can't have everything, I guess. Speed and elegance
4569 ;; doesn't always go hand in hand.
4572 (make-full-mail-header
4578 (narrow-to-region (point)
4579 (or (and (search-forward "\n.\n" nil t)
4585 (if (search-forward "\nsubject: " nil t)
4586 (buffer-substring (match-end 0) (std11-field-end))
4591 (if (search-forward "\nfrom: " nil t)
4592 (buffer-substring (match-end 0) (std11-field-end))
4597 (if (search-forward "\ndate: " nil t)
4598 (buffer-substring (match-end 0) (std11-field-end))
4603 (setq id (if (re-search-forward
4604 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4605 ;; We do it this way to make sure the Message-ID
4606 ;; is (somewhat) syntactically valid.
4607 (buffer-substring (match-beginning 1)
4609 ;; If there was no message-id, we just fake one
4610 ;; to make subsequent routines simpler.
4611 (nnheader-generate-fake-message-id))))
4615 (if (search-forward "\nreferences: " nil t)
4619 (buffer-substring (match-end 0) (std11-field-end))
4624 (search-backward ">" end t)
4627 (search-backward "<" end t)
4629 ;; Get the references from the in-reply-to header if there
4630 ;; were no references and the in-reply-to header looks
4632 (if (and (search-forward "\nin-reply-to: " nil t)
4634 (buffer-substring (match-end 0)
4636 (string-match "<[^>]+>" in-reply-to))
4638 (setq ref (substring in-reply-to (match-beginning 0)
4640 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4641 (setq ref2 (substring in-reply-to (match-beginning 0)
4643 (when (> (length ref2) (length ref))
4650 (if (search-forward "\nchars: " nil t)
4651 (if (numberp (setq chars (ignore-errors (read cur))))
4657 (if (search-forward "\nlines: " nil t)
4658 (if (numberp (setq lines (ignore-errors (read cur))))
4664 (and (search-forward "\nxref: " nil t)
4665 (buffer-substring (match-end 0) (std11-field-end))))
4667 (when gnus-extra-headers
4668 (let ((extra gnus-extra-headers)
4672 (when (search-forward
4673 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4674 (push (cons (car extra)
4675 (buffer-substring (match-end 0)
4681 (if (and (search-forward "\ncontent-type: " nil t)
4683 (buffer-substring (match-end 0) (std11-field-end))))
4684 (mime-entity-set-content-type-internal
4685 header (mime-parse-Content-Type ctype)))
4686 (when (equal id ref)
4689 (when gnus-alter-header-function
4690 (funcall gnus-alter-header-function header)
4691 (setq id (mail-header-id header)
4692 ref (gnus-parent-id (mail-header-references header))))
4695 (gnus-dependencies-add-header
4696 header dependencies force-new))
4697 (push header headers))
4698 (goto-char (point-max))
4700 (nreverse headers)))))
4702 ;; Goes through the xover lines and returns a list of vectors
4703 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4704 force-new dependencies
4705 group also-fetch-heads)
4706 "Parse the news overview data in the server buffer, and return a
4707 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4708 ;; Get the Xref when the users reads the articles since most/some
4709 ;; NNTP servers do not include Xrefs when using XOVER.
4710 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4711 (let ((mail-parse-charset gnus-newsgroup-charset)
4712 (cur nntp-server-buffer)
4713 (dependencies (or dependencies gnus-newsgroup-dependencies))
4714 number headers header)
4716 (set-buffer nntp-server-buffer)
4717 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4718 ;; Allow the user to mangle the headers before parsing them.
4719 (gnus-run-hooks 'gnus-parse-headers-hook)
4720 (goto-char (point-min))
4723 (while (and sequence (not (eobp)))
4724 (setq number (read cur))
4725 (while (and sequence
4726 (< (car sequence) number))
4727 (setq sequence (cdr sequence)))
4729 (eq number (car sequence))
4731 (setq sequence (cdr sequence))
4732 (setq header (inline
4733 (gnus-nov-parse-line
4734 number dependencies force-new))))
4735 (push header headers))
4738 (gnus-error 4 "Strange nov line (%d)"
4739 (count-lines (point-min) (point)))))
4741 ;; A common bug in inn is that if you have posted an article and
4742 ;; then retrieves the active file, it will answer correctly --
4743 ;; the new article is included. However, a NOV entry for the
4744 ;; article may not have been generated yet, so this may fail.
4745 ;; We work around this problem by retrieving the last few
4746 ;; headers using HEAD.
4747 (if (or (not also-fetch-heads)
4749 ;; We (probably) got all the headers.
4751 (let ((gnus-nov-is-evil t))
4754 (gnus-retrieve-parsed-headers sequence group)
4757 (defun gnus-article-get-xrefs ()
4758 "Fill in the Xref value in `gnus-current-headers', if necessary.
4759 This is meant to be called in `gnus-article-internal-prepare-hook'."
4760 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4761 gnus-current-headers)))
4762 (or (not gnus-use-cross-reference)
4764 (and (mail-header-xref headers)
4765 (not (string= (mail-header-xref headers) "")))
4766 (let ((case-fold-search t)
4769 (nnheader-narrow-to-headers)
4770 (goto-char (point-min))
4771 (when (or (and (eq (downcase (char-after)) ?x)
4772 (looking-at "Xref:"))
4773 (search-forward "\nXref:" nil t))
4774 (goto-char (1+ (match-end 0)))
4775 (setq xref (buffer-substring (point)
4776 (progn (end-of-line) (point))))
4777 (mail-header-set-xref headers xref)))))))
4779 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4780 "Find article ID and insert the summary line for that article.
4781 OLD-HEADER can either be a header or a line number to insert
4782 the subject line on."
4783 (let* ((line (and (numberp old-header) old-header))
4784 (old-header (and (vectorp old-header) old-header))
4785 (header (cond ((and old-header use-old-header)
4788 (gnus-number-to-header id))
4789 (gnus-number-to-header id))
4791 (gnus-read-header id))))
4792 (number (and (numberp id) id))
4795 ;; Rebuild the thread that this article is part of and go to the
4796 ;; article we have fetched.
4797 (when (and (not gnus-show-threads)
4800 (setq d (gnus-data-find (mail-header-number old-header))))
4801 (goto-char (gnus-data-pos d))
4804 (- (gnus-point-at-bol)
4806 (1+ (gnus-point-at-eol))
4807 (gnus-delete-line))))))
4809 (mail-header-set-number header (mail-header-number old-header)))
4810 (setq gnus-newsgroup-sparse
4811 (delq (setq number (mail-header-number header))
4812 gnus-newsgroup-sparse))
4813 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4814 (push number gnus-newsgroup-limit)
4815 (gnus-rebuild-thread (mail-header-id header) line)
4816 (gnus-summary-goto-subject number nil t))
4817 (when (and (numberp number)
4819 ;; We have to update the boundaries even if we can't fetch the
4820 ;; article if ID is a number -- so that the next `P' or `N'
4821 ;; command will fetch the previous (or next) article even
4822 ;; if the one we tried to fetch this time has been canceled.
4823 (when (> number gnus-newsgroup-end)
4824 (setq gnus-newsgroup-end number))
4825 (when (< number gnus-newsgroup-begin)
4826 (setq gnus-newsgroup-begin number))
4827 (setq gnus-newsgroup-unselected
4828 (delq number gnus-newsgroup-unselected)))
4829 ;; Report back a success?
4830 (and header (mail-header-number header))))
4832 ;;; Process/prefix in the summary buffer
4834 (defun gnus-summary-work-articles (n)
4835 "Return a list of articles to be worked upon.
4836 The prefix argument, the list of process marked articles, and the
4837 current article will be taken into consideration."
4839 (set-buffer gnus-summary-buffer)
4842 ;; A numerical prefix has been given.
4843 (setq n (prefix-numeric-value n))
4844 (let ((backward (< n 0))
4845 (n (abs (prefix-numeric-value n)))
4850 (push (setq article (gnus-summary-article-number))
4853 (gnus-summary-find-prev nil article)
4854 (gnus-summary-find-next nil article)))
4856 (nreverse articles)))
4857 ((and (gnus-region-active-p) (mark))
4858 (message "region active")
4859 ;; Work on the region between point and mark.
4860 (let ((max (max (point) (mark)))
4863 (goto-char (min (point) (mark)))
4866 (push (setq article (gnus-summary-article-number)) articles)
4867 (gnus-summary-find-next nil article)
4869 (nreverse articles))))
4870 (gnus-newsgroup-processable
4871 ;; There are process-marked articles present.
4872 ;; Save current state.
4873 (gnus-summary-save-process-mark)
4875 (reverse gnus-newsgroup-processable))
4877 ;; Just return the current article.
4878 (list (gnus-summary-article-number))))))
4880 (defmacro gnus-summary-iterate (arg &rest forms)
4881 "Iterate over the process/prefixed articles and do FORMS.
4882 ARG is the interactive prefix given to the command. FORMS will be
4883 executed with point over the summary line of the articles."
4884 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4885 `(let ((,articles (gnus-summary-work-articles ,arg)))
4887 (gnus-summary-goto-subject (car ,articles))
4891 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4892 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4894 (defun gnus-summary-save-process-mark ()
4895 "Push the current set of process marked articles on the stack."
4897 (push (copy-sequence gnus-newsgroup-processable)
4898 gnus-newsgroup-process-stack))
4900 (defun gnus-summary-kill-process-mark ()
4901 "Push the current set of process marked articles on the stack and unmark."
4903 (gnus-summary-save-process-mark)
4904 (gnus-summary-unmark-all-processable))
4906 (defun gnus-summary-yank-process-mark ()
4907 "Pop the last process mark state off the stack and restore it."
4909 (unless gnus-newsgroup-process-stack
4910 (error "Empty mark stack"))
4911 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4913 (defun gnus-summary-process-mark-set (set)
4914 "Make SET into the current process marked articles."
4915 (gnus-summary-unmark-all-processable)
4917 (gnus-summary-set-process-mark (pop set))))
4919 ;;; Searching and stuff
4921 (defun gnus-summary-search-group (&optional backward use-level)
4922 "Search for next unread newsgroup.
4923 If optional argument BACKWARD is non-nil, search backward instead."
4925 (set-buffer gnus-group-buffer)
4926 (when (gnus-group-search-forward
4927 backward nil (if use-level (gnus-group-group-level) nil))
4928 (gnus-group-group-name))))
4930 (defun gnus-summary-best-group (&optional exclude-group)
4931 "Find the name of the best unread group.
4932 If EXCLUDE-GROUP, do not go to this group."
4934 (set-buffer gnus-group-buffer)
4936 (gnus-group-best-unread-group exclude-group))))
4938 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4939 (if backward (gnus-summary-find-prev)
4940 (let* ((dummy (gnus-summary-article-intangible-p))
4941 (article (or article (gnus-summary-article-number)))
4942 (arts (gnus-data-find-list article))
4944 (when (and (not dummy)
4945 (or (not gnus-summary-check-current)
4947 (not (gnus-data-unread-p (car arts)))))
4948 (setq arts (cdr arts)))
4953 (when (or (and undownloaded
4954 (eq gnus-undownloaded-mark
4955 (gnus-data-mark (car arts))))
4956 (gnus-data-unread-p (car arts)))
4957 (setq result (car arts)
4959 (setq arts (cdr arts)))
4962 (goto-char (gnus-data-pos result))
4963 (gnus-data-number result)))))
4965 (defun gnus-summary-find-prev (&optional unread article)
4966 (let* ((eobp (eobp))
4967 (article (or article (gnus-summary-article-number)))
4968 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4970 (when (and (not eobp)
4971 (or (not gnus-summary-check-current)
4973 (not (gnus-data-unread-p (car arts)))))
4974 (setq arts (cdr arts)))
4979 (when (gnus-data-unread-p (car arts))
4980 (setq result (car arts)
4982 (setq arts (cdr arts)))
4985 (goto-char (gnus-data-pos result))
4986 (gnus-data-number result))))
4988 (defun gnus-summary-find-subject (subject &optional unread backward article)
4989 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4990 (article (or article (gnus-summary-article-number)))
4991 (articles (gnus-data-list backward))
4992 (arts (gnus-data-find-list article articles))
4994 (when (or (not gnus-summary-check-current)
4996 (not (gnus-data-unread-p (car arts))))
4997 (setq arts (cdr arts)))
4999 (and (or (not unread)
5000 (gnus-data-unread-p (car arts)))
5001 (vectorp (gnus-data-header (car arts)))
5003 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5004 (setq result (car arts)
5006 (setq arts (cdr arts)))
5008 (goto-char (gnus-data-pos result))
5009 (gnus-data-number result))))
5011 (defun gnus-summary-search-forward (&optional unread subject backward)
5012 "Search forward for an article.
5013 If UNREAD, look for unread articles. If SUBJECT, look for
5014 articles with that subject. If BACKWARD, search backward instead."
5015 (cond (subject (gnus-summary-find-subject subject unread backward))
5016 (backward (gnus-summary-find-prev unread))
5017 (t (gnus-summary-find-next unread))))
5019 (defun gnus-recenter (&optional n)
5020 "Center point in window and redisplay frame.
5021 Also do horizontal recentering."
5023 (when (and gnus-auto-center-summary
5024 (not (eq gnus-auto-center-summary 'vertical)))
5025 (gnus-horizontal-recenter))
5028 (defun gnus-summary-recenter ()
5029 "Center point in the summary window.
5030 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5031 displayed, no centering will be performed."
5032 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5033 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5034 (let* ((top (cond ((< (window-height) 4) 0)
5035 ((< (window-height) 7) 1)
5036 (t (if (numberp gnus-auto-center-summary)
5037 gnus-auto-center-summary
5039 (height (1- (window-height)))
5040 (bottom (save-excursion (goto-char (point-max))
5041 (forward-line (- height))
5043 (window (get-buffer-window (current-buffer))))
5044 ;; The user has to want it.
5045 (when gnus-auto-center-summary
5046 (when (get-buffer-window gnus-article-buffer)
5047 ;; Only do recentering when the article buffer is displayed,
5048 ;; Set the window start to either `bottom', which is the biggest
5049 ;; possible valid number, or the second line from the top,
5050 ;; whichever is the least.
5052 window (min bottom (save-excursion
5053 (forward-line (- top)) (point)))))
5054 ;; Do horizontal recentering while we're at it.
5055 (when (and (get-buffer-window (current-buffer) t)
5056 (not (eq gnus-auto-center-summary 'vertical)))
5057 (let ((selected (selected-window)))
5058 (select-window (get-buffer-window (current-buffer) t))
5059 (gnus-summary-position-point)
5060 (gnus-horizontal-recenter)
5061 (select-window selected))))))
5063 (defun gnus-summary-jump-to-group (newsgroup)
5064 "Move point to NEWSGROUP in group mode buffer."
5065 ;; Keep update point of group mode buffer if visible.
5066 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5067 (save-window-excursion
5068 ;; Take care of tree window mode.
5069 (when (get-buffer-window gnus-group-buffer)
5070 (pop-to-buffer gnus-group-buffer))
5071 (gnus-group-jump-to-group newsgroup))
5073 ;; Take care of tree window mode.
5074 (if (get-buffer-window gnus-group-buffer)
5075 (pop-to-buffer gnus-group-buffer)
5076 (set-buffer gnus-group-buffer))
5077 (gnus-group-jump-to-group newsgroup))))
5079 ;; This function returns a list of article numbers based on the
5080 ;; difference between the ranges of read articles in this group and
5081 ;; the range of active articles.
5082 (defun gnus-list-of-unread-articles (group)
5083 (let* ((read (gnus-info-read (gnus-get-info group)))
5084 (active (or (gnus-active group) (gnus-activate-group group)))
5087 ;; If none are read, then all are unread.
5089 (setq first (car active))
5090 ;; If the range of read articles is a single range, then the
5091 ;; first unread article is the article after the last read
5092 ;; article. Sounds logical, doesn't it?
5093 (if (not (listp (cdr read)))
5094 (setq first (max (car active) (1+ (cdr read))))
5095 ;; `read' is a list of ranges.
5096 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5099 (setq first (car active)))
5102 (while (< first nlast)
5104 (setq first (1+ first))))
5105 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5106 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5107 (setq read (cdr read)))))
5108 ;; And add the last unread articles.
5109 (while (<= first last)
5111 (setq first (1+ first)))
5112 ;; Return the list of unread articles.
5113 (delq 0 (nreverse unread))))
5115 (defun gnus-list-of-read-articles (group)
5116 "Return a list of unread, unticked and non-dormant articles."
5117 (let* ((info (gnus-get-info group))
5118 (marked (gnus-info-marks info))
5119 (active (gnus-active group)))
5121 (gnus-set-difference
5122 (gnus-sorted-complement
5123 (gnus-uncompress-range active)
5124 (gnus-list-of-unread-articles group))
5126 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5127 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5129 ;; Various summary commands
5131 (defun gnus-summary-select-article-buffer ()
5132 "Reconfigure windows to show article buffer."
5134 (if (not (gnus-buffer-live-p gnus-article-buffer))
5135 (error "There is no article buffer for this summary buffer")
5136 (gnus-configure-windows 'article)
5137 (select-window (get-buffer-window gnus-article-buffer))))
5139 (defun gnus-summary-universal-argument (arg)
5140 "Perform any operation on all articles that are process/prefixed."
5142 (let ((articles (gnus-summary-work-articles arg))
5149 (substitute-command-keys
5150 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5153 (gnus-error 1 "Undefined key")
5156 (gnus-summary-goto-subject (setq article (pop articles)))
5157 (let (gnus-newsgroup-processable)
5158 (command-execute func))
5159 (gnus-summary-remove-process-mark article)))))
5160 (gnus-summary-position-point))
5162 (defun gnus-summary-toggle-truncation (&optional arg)
5163 "Toggle truncation of summary lines.
5164 With arg, turn line truncation on iff arg is positive."
5166 (setq truncate-lines
5167 (if (null arg) (not truncate-lines)
5168 (> (prefix-numeric-value arg) 0)))
5171 (defun gnus-summary-reselect-current-group (&optional all rescan)
5172 "Rescan the current newsgroup, exit and then reselect it.
5173 The prefix argument ALL means to select all articles."
5175 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5176 (error "Ephemeral groups can't be reselected"))
5177 (let ((current-subject (gnus-summary-article-number))
5178 (group gnus-newsgroup-name))
5180 (set-buffer gnus-group-buffer)
5181 ;; We have to adjust the point of group mode buffer because
5182 ;; point was moved to the next unread newsgroup by exiting.
5183 (gnus-summary-jump-to-group group)
5186 (gnus-group-get-new-news-this-group 1))))
5187 (setq gnus-newsgroup-begin nil)
5189 (gnus-group-read-group all t group)
5190 (gnus-summary-goto-subject current-subject nil t)))
5192 (defun gnus-summary-rescan-group (&optional all)
5193 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5195 (gnus-summary-reselect-current-group all t))
5197 (defun gnus-summary-update-info (&optional non-destructive)
5199 (let ((group gnus-newsgroup-name))
5201 (when gnus-newsgroup-kill-headers
5202 (setq gnus-newsgroup-killed
5203 (gnus-compress-sequence
5205 (gnus-set-sorted-intersection
5206 (gnus-uncompress-range gnus-newsgroup-killed)
5207 (setq gnus-newsgroup-unselected
5208 (sort gnus-newsgroup-unselected '<)))
5209 (setq gnus-newsgroup-unreads
5210 (sort gnus-newsgroup-unreads '<)))
5212 (unless (listp (cdr gnus-newsgroup-killed))
5213 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5214 (let ((headers gnus-newsgroup-headers))
5215 ;; Set the new ranges of read articles.
5217 (set-buffer gnus-group-buffer)
5218 (gnus-undo-force-boundary))
5219 (gnus-update-read-articles
5220 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5221 ;; Set the current article marks.
5222 (let ((gnus-newsgroup-scored
5223 (if (and (not gnus-save-score)
5224 (not non-destructive))
5226 gnus-newsgroup-scored)))
5228 (gnus-update-marks)))
5229 ;; Do the cross-ref thing.
5230 (when gnus-use-cross-reference
5231 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5232 ;; Do not switch windows but change the buffer to work.
5233 (set-buffer gnus-group-buffer)
5234 (unless (gnus-ephemeral-group-p group)
5235 (gnus-group-update-group group)))))))
5237 (defun gnus-summary-save-newsrc (&optional force)
5238 "Save the current number of read/marked articles in the dribble buffer.
5239 The dribble buffer will then be saved.
5240 If FORCE (the prefix), also save the .newsrc file(s)."
5242 (gnus-summary-update-info t)
5244 (gnus-save-newsrc-file)
5245 (gnus-dribble-save)))
5247 (defun gnus-summary-exit (&optional temporary)
5248 "Exit reading current newsgroup, and then return to group selection mode.
5249 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5251 (gnus-set-global-variables)
5252 (gnus-kill-save-kill-buffer)
5253 (gnus-async-halt-prefetch)
5254 (let* ((group gnus-newsgroup-name)
5255 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5258 (buf (current-buffer)))
5260 ;; Do adaptive scoring, and possibly save score files.
5261 (when gnus-newsgroup-adaptive
5262 (gnus-score-adaptive))
5263 (when gnus-use-scoring
5265 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5266 ;; If we have several article buffers, we kill them at exit.
5267 (unless gnus-single-article-buffer
5268 (gnus-kill-buffer gnus-original-article-buffer)
5269 (setq gnus-article-current nil))
5270 (when gnus-use-cache
5271 (gnus-cache-possibly-remove-articles)
5272 (gnus-cache-save-buffers))
5273 (gnus-async-prefetch-remove-group group)
5274 (when gnus-suppress-duplicates
5275 (gnus-dup-enter-articles))
5276 (when gnus-use-trees
5277 (gnus-tree-close group))
5278 ;; Remove entries for this group.
5279 (nnmail-purge-split-history (gnus-group-real-name group))
5280 ;; Make all changes in this group permanent.
5282 (gnus-run-hooks 'gnus-exit-group-hook)
5283 (gnus-summary-update-info))
5284 (gnus-close-group group)
5285 ;; Make sure where we were, and go to next newsgroup.
5286 (set-buffer gnus-group-buffer)
5288 (gnus-group-jump-to-group group))
5289 (gnus-run-hooks 'gnus-summary-exit-hook)
5290 (unless (or quit-config
5291 ;; If this group has disappeared from the summary
5292 ;; buffer, don't skip forwards.
5293 (not (string= group (gnus-group-group-name))))
5294 (gnus-group-next-unread-group 1))
5295 (setq group-point (point))
5298 ;; If we have several article buffers, we kill them at exit.
5299 (unless gnus-single-article-buffer
5300 (gnus-kill-buffer gnus-article-buffer)
5301 (gnus-kill-buffer gnus-original-article-buffer)
5302 (setq gnus-article-current nil))
5304 (if (not gnus-kill-summary-on-exit)
5305 (gnus-deaden-summary)
5306 ;; We set all buffer-local variables to nil. It is unclear why
5307 ;; this is needed, but if we don't, buffer-local variables are
5308 ;; not garbage-collected, it seems. This would the lead to en
5309 ;; ever-growing Emacs.
5310 (gnus-summary-clear-local-variables)
5311 (when (get-buffer gnus-article-buffer)
5312 (bury-buffer gnus-article-buffer))
5313 ;; We clear the global counterparts of the buffer-local
5314 ;; variables as well, just to be on the safe side.
5315 (set-buffer gnus-group-buffer)
5316 (gnus-summary-clear-local-variables)
5317 ;; Return to group mode buffer.
5318 (when (eq mode 'gnus-summary-mode)
5319 (gnus-kill-buffer buf)))
5320 (setq gnus-current-select-method gnus-select-method)
5321 (pop-to-buffer gnus-group-buffer)
5322 (if (not quit-config)
5324 (goto-char group-point)
5325 (gnus-configure-windows 'group 'force))
5326 (gnus-handle-ephemeral-exit quit-config))
5327 ;; Clear the current group name.
5329 (setq gnus-newsgroup-name nil)))))
5331 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5332 (defun gnus-summary-exit-no-update (&optional no-questions)
5333 "Quit reading current newsgroup without updating read article info."
5335 (let* ((group gnus-newsgroup-name)
5336 (quit-config (gnus-group-quit-config group)))
5337 (when (or no-questions
5339 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5340 (gnus-async-halt-prefetch)
5342 (delq 'gnus-summary-expire-articles
5343 (copy-list gnus-summary-prepare-exit-hook)))
5344 ;; If we have several article buffers, we kill them at exit.
5345 (unless gnus-single-article-buffer
5346 (gnus-kill-buffer gnus-article-buffer)
5347 (gnus-kill-buffer gnus-original-article-buffer)
5348 (setq gnus-article-current nil))
5349 (if (not gnus-kill-summary-on-exit)
5350 (gnus-deaden-summary)
5351 (gnus-close-group group)
5352 (gnus-summary-clear-local-variables)
5353 (set-buffer gnus-group-buffer)
5354 (gnus-summary-clear-local-variables)
5355 (when (get-buffer gnus-summary-buffer)
5356 (kill-buffer gnus-summary-buffer)))
5357 (unless gnus-single-article-buffer
5358 (setq gnus-article-current nil))
5359 (when gnus-use-trees
5360 (gnus-tree-close group))
5361 (gnus-async-prefetch-remove-group group)
5362 (when (get-buffer gnus-article-buffer)
5363 (bury-buffer gnus-article-buffer))
5364 ;; Return to the group buffer.
5365 (gnus-configure-windows 'group 'force)
5366 ;; Clear the current group name.
5367 (setq gnus-newsgroup-name nil)
5368 (when (equal (gnus-group-group-name) group)
5369 (gnus-group-next-unread-group 1))
5371 (gnus-handle-ephemeral-exit quit-config)))))
5373 (defun gnus-handle-ephemeral-exit (quit-config)
5374 "Handle movement when leaving an ephemeral group.
5375 The state which existed when entering the ephemeral is reset."
5376 (if (not (buffer-name (car quit-config)))
5377 (gnus-configure-windows 'group 'force)
5378 (set-buffer (car quit-config))
5379 (cond ((eq major-mode 'gnus-summary-mode)
5380 (gnus-set-global-variables))
5381 ((eq major-mode 'gnus-article-mode)
5383 ;; The `gnus-summary-buffer' variable may point
5384 ;; to the old summary buffer when using a single
5386 (unless (gnus-buffer-live-p gnus-summary-buffer)
5387 (set-buffer gnus-group-buffer))
5388 (set-buffer gnus-summary-buffer)
5389 (gnus-set-global-variables))))
5390 (if (or (eq (cdr quit-config) 'article)
5391 (eq (cdr quit-config) 'pick))
5393 ;; The current article may be from the ephemeral group
5394 ;; thus it is best that we reload this article
5395 (gnus-summary-show-article)
5396 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5397 (gnus-configure-windows 'pick 'force)
5398 (gnus-configure-windows (cdr quit-config) 'force)))
5399 (gnus-configure-windows (cdr quit-config) 'force))
5400 (when (eq major-mode 'gnus-summary-mode)
5401 (gnus-summary-next-subject 1 nil t)
5402 (gnus-summary-recenter)
5403 (gnus-summary-position-point))))
5405 (defun gnus-summary-preview-mime-message ()
5406 "MIME decode and play this message."
5408 (let ((gnus-break-pages nil)
5410 (gnus-summary-select-article gnus-show-all-headers t))
5411 (select-window (get-buffer-window gnus-article-buffer)))
5415 (defvar gnus-dead-summary-mode-map nil)
5417 (unless gnus-dead-summary-mode-map
5418 (setq gnus-dead-summary-mode-map (make-keymap))
5419 (suppress-keymap gnus-dead-summary-mode-map)
5420 (substitute-key-definition
5421 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5422 (let ((keys '("\C-d" "\r" "\177" [delete])))
5424 (define-key gnus-dead-summary-mode-map
5425 (pop keys) 'gnus-summary-wake-up-the-dead))))
5427 (defvar gnus-dead-summary-mode nil
5428 "Minor mode for Gnus summary buffers.")
5430 (defun gnus-dead-summary-mode (&optional arg)
5431 "Minor mode for Gnus summary buffers."
5433 (when (eq major-mode 'gnus-summary-mode)
5434 (make-local-variable 'gnus-dead-summary-mode)
5435 (setq gnus-dead-summary-mode
5436 (if (null arg) (not gnus-dead-summary-mode)
5437 (> (prefix-numeric-value arg) 0)))
5438 (when gnus-dead-summary-mode
5439 (gnus-add-minor-mode
5440 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5442 (defun gnus-deaden-summary ()
5443 "Make the current summary buffer into a dead summary buffer."
5444 ;; Kill any previous dead summary buffer.
5445 (when (and gnus-dead-summary
5446 (buffer-name gnus-dead-summary))
5448 (set-buffer gnus-dead-summary)
5449 (when gnus-dead-summary-mode
5450 (kill-buffer (current-buffer)))))
5451 ;; Make this the current dead summary.
5452 (setq gnus-dead-summary (current-buffer))
5453 (gnus-dead-summary-mode 1)
5454 (let ((name (buffer-name)))
5455 (when (string-match "Summary" name)
5457 (concat (substring name 0 (match-beginning 0)) "Dead "
5458 (substring name (match-beginning 0)))
5461 (defun gnus-kill-or-deaden-summary (buffer)
5462 "Kill or deaden the summary BUFFER."
5464 (when (and (buffer-name buffer)
5465 (not gnus-single-article-buffer))
5468 (gnus-kill-buffer gnus-article-buffer)
5469 (gnus-kill-buffer gnus-original-article-buffer)))
5470 (cond (gnus-kill-summary-on-exit
5471 (when (and gnus-use-trees
5472 (gnus-buffer-exists-p buffer))
5475 (gnus-tree-close gnus-newsgroup-name)))
5476 (gnus-kill-buffer buffer))
5477 ((gnus-buffer-exists-p buffer)
5480 (gnus-deaden-summary))))))
5482 (defun gnus-summary-wake-up-the-dead (&rest args)
5483 "Wake up the dead summary buffer."
5485 (gnus-dead-summary-mode -1)
5486 (let ((name (buffer-name)))
5487 (when (string-match "Dead " name)
5489 (concat (substring name 0 (match-beginning 0))
5490 (substring name (match-end 0)))
5492 (gnus-message 3 "This dead summary is now alive again"))
5494 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5495 (defun gnus-summary-fetch-faq (&optional faq-dir)
5496 "Fetch the FAQ for the current group.
5497 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5501 (when current-prefix-arg
5503 "Faq dir: " (and (listp gnus-group-faq-directory)
5504 (mapcar (lambda (file) (list file))
5505 gnus-group-faq-directory))))))
5506 (let (gnus-faq-buffer)
5507 (when (setq gnus-faq-buffer
5508 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5509 (gnus-configure-windows 'summary-faq))))
5511 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5512 (defun gnus-summary-describe-group (&optional force)
5513 "Describe the current newsgroup."
5515 (gnus-group-describe-group force gnus-newsgroup-name))
5517 (defun gnus-summary-describe-briefly ()
5518 "Describe summary mode commands briefly."
5520 (gnus-message 6 (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")))
5522 ;; Walking around group mode buffer from summary mode.
5524 (defun gnus-summary-next-group (&optional no-article target-group backward)
5525 "Exit current newsgroup and then select next unread newsgroup.
5526 If prefix argument NO-ARTICLE is non-nil, no article is selected
5527 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5528 previous group instead."
5530 ;; Stop pre-fetching.
5531 (gnus-async-halt-prefetch)
5532 (let ((current-group gnus-newsgroup-name)
5533 (current-buffer (current-buffer))
5535 ;; First we semi-exit this group to update Xrefs and all variables.
5536 ;; We can't do a real exit, because the window conf must remain
5537 ;; the same in case the user is prompted for info, and we don't
5538 ;; want the window conf to change before that...
5539 (gnus-summary-exit t)
5540 (while (not entered)
5541 ;; Then we find what group we are supposed to enter.
5542 (set-buffer gnus-group-buffer)
5543 (gnus-group-jump-to-group current-group)
5546 (if (eq gnus-keep-same-level 'best)
5547 (gnus-summary-best-group gnus-newsgroup-name)
5548 (gnus-summary-search-group backward gnus-keep-same-level))))
5549 (if (not target-group)
5550 ;; There are no further groups, so we return to the group
5553 (gnus-message 5 "Returning to the group buffer")
5555 (when (gnus-buffer-live-p current-buffer)
5556 (set-buffer current-buffer)
5557 (gnus-summary-exit))
5558 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5559 ;; We try to enter the target group.
5560 (gnus-group-jump-to-group target-group)
5561 (let ((unreads (gnus-group-group-unread)))
5562 (if (and (or (eq t unreads)
5563 (and unreads (not (zerop unreads))))
5564 (gnus-summary-read-group
5565 target-group nil no-article
5566 (and (buffer-name current-buffer) current-buffer)
5569 (setq current-group target-group
5570 target-group nil)))))))
5572 (defun gnus-summary-prev-group (&optional no-article)
5573 "Exit current newsgroup and then select previous unread newsgroup.
5574 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5576 (gnus-summary-next-group no-article nil t))
5578 ;; Walking around summary lines.
5580 (defun gnus-summary-first-subject (&optional unread undownloaded)
5581 "Go to the first unread subject.
5582 If UNREAD is non-nil, go to the first unread article.
5583 Returns the article selected or nil if there are no unread articles."
5588 ((null gnus-newsgroup-data)
5589 (gnus-message 3 "No articles in the group")
5591 ;; Pick the first article.
5593 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5594 (gnus-data-number (car gnus-newsgroup-data)))
5595 ;; No unread articles.
5596 ((null gnus-newsgroup-unreads)
5597 (gnus-message 3 "No more unread articles")
5599 ;; Find the first unread article.
5601 (let ((data gnus-newsgroup-data))
5603 (and (not (and undownloaded
5604 (eq gnus-undownloaded-mark
5605 (gnus-data-mark (car data)))))
5606 (not (gnus-data-unread-p (car data)))))
5607 (setq data (cdr data)))
5609 (goto-char (gnus-data-pos (car data)))
5610 (gnus-data-number (car data))))))
5611 (gnus-summary-position-point)))
5613 (defun gnus-summary-next-subject (n &optional unread dont-display)
5614 "Go to next N'th summary line.
5615 If N is negative, go to the previous N'th subject line.
5616 If UNREAD is non-nil, only unread articles are selected.
5617 The difference between N and the actual number of steps taken is
5620 (let ((backward (< n 0))
5624 (gnus-summary-find-prev unread)
5625 (gnus-summary-find-next unread)))
5626 (gnus-summary-show-thread)
5629 (gnus-message 7 "No more%s articles"
5630 (if unread " unread" "")))
5631 (unless dont-display
5632 (gnus-summary-recenter)
5633 (gnus-summary-position-point))
5636 (defun gnus-summary-next-unread-subject (n)
5637 "Go to next N'th unread summary line."
5639 (gnus-summary-next-subject n t))
5641 (defun gnus-summary-prev-subject (n &optional unread)
5642 "Go to previous N'th summary line.
5643 If optional argument UNREAD is non-nil, only unread article is selected."
5645 (gnus-summary-next-subject (- n) unread))
5647 (defun gnus-summary-prev-unread-subject (n)
5648 "Go to previous N'th unread summary line."
5650 (gnus-summary-next-subject (- n) t))
5652 (defun gnus-summary-goto-subject (article &optional force silent)
5653 "Go the subject line of ARTICLE.
5654 If FORCE, also allow jumping to articles not currently shown."
5655 (interactive "nArticle number: ")
5657 (data (gnus-data-find article)))
5658 ;; We read in the article if we have to.
5661 (gnus-summary-insert-subject
5663 (if (or (numberp force) (vectorp force)) force)
5665 (setq data (gnus-data-find article)))
5670 (gnus-message 3 "Can't find article %d" article))
5672 (goto-char (gnus-data-pos data))
5673 (gnus-summary-position-point)
5676 ;; Walking around summary lines with displaying articles.
5678 (defun gnus-summary-expand-window (&optional arg)
5679 "Make the summary buffer take up the entire Emacs frame.
5680 Given a prefix, will force an `article' buffer configuration."
5683 (gnus-configure-windows 'article 'force)
5684 (gnus-configure-windows 'summary 'force)))
5686 (defun gnus-summary-display-article (article &optional all-header)
5687 "Display ARTICLE in article buffer."
5688 (gnus-set-global-variables)
5692 (if gnus-summary-display-article-function
5693 (funcall gnus-summary-display-article-function article all-header)
5694 (gnus-article-prepare article all-header))
5695 (gnus-run-hooks 'gnus-select-article-hook)
5696 (when (and gnus-current-article
5697 (not (zerop gnus-current-article)))
5698 (gnus-summary-goto-subject gnus-current-article))
5699 (gnus-summary-recenter)
5700 (when (and gnus-use-trees gnus-show-threads)
5701 (gnus-possibly-generate-tree article)
5702 (gnus-highlight-selected-tree article))
5703 ;; Successfully display article.
5704 (gnus-article-set-window-start
5705 (cdr (assq article gnus-newsgroup-bookmarks))))))
5707 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5708 "Select the current article.
5709 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5710 non-nil, the article will be re-fetched even if it already present in
5711 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5713 ;; Make sure we are in the summary buffer to work around bbdb bug.
5714 (unless (eq major-mode 'gnus-summary-mode)
5715 (set-buffer gnus-summary-buffer))
5716 (let ((article (or article (gnus-summary-article-number)))
5717 (all-headers (not (not all-headers))) ;Must be T or NIL.
5718 gnus-summary-display-article-function
5721 (gnus-summary-article-pseudo-p article)
5722 (error "This is a pseudo-article"))
5725 (set-buffer gnus-summary-buffer)
5726 (if (or (and gnus-single-article-buffer
5727 (or (null gnus-current-article)
5728 (null gnus-article-current)
5729 (null (get-buffer gnus-article-buffer))
5730 (not (eq article (cdr gnus-article-current)))
5731 (not (equal (car gnus-article-current)
5732 gnus-newsgroup-name))))
5733 (and (not gnus-single-article-buffer)
5734 (or (null gnus-current-article)
5735 (not (eq gnus-current-article article))))
5737 ;; The requested article is different from the current article.
5739 (gnus-summary-display-article article all-headers)
5741 (when (or all-headers gnus-show-all-headers)
5742 (gnus-article-show-all-headers)))
5743 (when (or all-headers gnus-show-all-headers)
5744 (gnus-article-show-all-headers))
5747 (gnus-article-set-window-start
5748 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5750 (defun gnus-summary-set-current-mark (&optional current-mark)
5751 "Obsolete function."
5754 (defun gnus-summary-next-article (&optional unread subject backward push)
5755 "Select the next article.
5756 If UNREAD, only unread articles are selected.
5757 If SUBJECT, only articles with SUBJECT are selected.
5758 If BACKWARD, the previous article is selected instead of the next."
5761 ;; Is there such an article?
5762 ((and (gnus-summary-search-forward unread subject backward)
5763 (or (gnus-summary-display-article (gnus-summary-article-number))
5764 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5765 (gnus-summary-position-point))
5766 ;; If not, we try the first unread, if that is wanted.
5768 gnus-auto-select-same
5769 (gnus-summary-first-unread-article))
5770 (gnus-summary-position-point)
5771 (gnus-message 6 "Wrapped"))
5772 ;; Try to get next/previous article not displayed in this group.
5773 ((and gnus-auto-extend-newsgroup
5774 (not unread) (not subject))
5775 (gnus-summary-goto-article
5776 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5777 nil (count-lines (point-min) (point))))
5778 ;; Go to next/previous group.
5780 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5781 (gnus-summary-jump-to-group gnus-newsgroup-name))
5782 (let ((cmd last-command-char)
5785 (set-buffer gnus-group-buffer)
5788 (if (eq gnus-keep-same-level 'best)
5789 (gnus-summary-best-group gnus-newsgroup-name)
5790 (gnus-summary-search-group backward gnus-keep-same-level))))
5791 ;; For some reason, the group window gets selected. We change
5793 (select-window (get-buffer-window (current-buffer)))
5794 ;; Select next unread newsgroup automagically.
5796 ((or (not gnus-auto-select-next)
5798 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5799 ((or (eq gnus-auto-select-next 'quietly)
5800 (and (eq gnus-auto-select-next 'slightly-quietly)
5802 (and (eq gnus-auto-select-next 'almost-quietly)
5803 (gnus-summary-last-article-p)))
5805 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5807 (gnus-message 7 "No more%s articles (%s)..."
5808 (if unread " unread" "")
5809 (if group (concat "selecting " group)
5811 (gnus-summary-next-group nil group backward)))
5813 (when (gnus-key-press-event-p last-input-event)
5814 (gnus-summary-walk-group-buffer
5815 gnus-newsgroup-name cmd unread backward point))))))))
5817 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5818 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5819 (?\C-p (gnus-group-prev-unread-group 1))))
5820 (cursor-in-echo-area t)
5821 keve key group ended)
5823 (set-buffer gnus-group-buffer)
5826 (if (eq gnus-keep-same-level 'best)
5827 (gnus-summary-best-group gnus-newsgroup-name)
5828 (gnus-summary-search-group backward gnus-keep-same-level))))
5831 5 "No more%s articles%s" (if unread " unread" "")
5833 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5834 (format " (Type %s for %s [%s])"
5835 (single-key-description cmd) group
5836 (car (gnus-gethash group gnus-newsrc-hashtb)))
5837 (format " (Type %s to exit %s)"
5838 (single-key-description cmd)
5839 gnus-newsgroup-name)))
5840 ;; Confirm auto selection.
5841 (setq key (car (setq keve (gnus-read-event-char))))
5844 ((assq key keystrokes)
5845 (let ((obuf (current-buffer)))
5846 (switch-to-buffer gnus-group-buffer)
5848 (gnus-group-jump-to-group group))
5849 (eval (cadr (assq key keystrokes)))
5850 (setq group (gnus-group-group-name))
5851 (switch-to-buffer obuf))
5855 (gnus-ephemeral-group-p gnus-newsgroup-name))
5857 (gnus-summary-next-group nil group backward)))
5859 (push (cdr keve) unread-command-events))))))
5861 (defun gnus-summary-next-unread-article ()
5862 "Select unread article after current one."
5864 (gnus-summary-next-article
5865 (or (not (eq gnus-summary-goto-unread 'never))
5866 (gnus-summary-last-article-p (gnus-summary-article-number)))
5867 (and gnus-auto-select-same
5868 (gnus-summary-article-subject))))
5870 (defun gnus-summary-prev-article (&optional unread subject)
5871 "Select the article after the current one.
5872 If UNREAD is non-nil, only unread articles are selected."
5874 (gnus-summary-next-article unread subject t))
5876 (defun gnus-summary-prev-unread-article ()
5877 "Select unread article before current one."
5879 (gnus-summary-prev-article
5880 (or (not (eq gnus-summary-goto-unread 'never))
5881 (gnus-summary-first-article-p (gnus-summary-article-number)))
5882 (and gnus-auto-select-same
5883 (gnus-summary-article-subject))))
5885 (defun gnus-summary-next-page (&optional lines circular)
5886 "Show next page of the selected article.
5887 If at the end of the current article, select the next article.
5888 LINES says how many lines should be scrolled up.
5890 If CIRCULAR is non-nil, go to the start of the article instead of
5891 selecting the next article when reaching the end of the current
5894 (setq gnus-summary-buffer (current-buffer))
5895 (gnus-set-global-variables)
5896 (let ((article (gnus-summary-article-number))
5897 (article-window (get-buffer-window gnus-article-buffer t))
5899 ;; If the buffer is empty, we have no article.
5901 (error "No article to select"))
5902 (gnus-configure-windows 'article)
5903 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5904 (if (and (eq gnus-summary-goto-unread 'never)
5905 (not (gnus-summary-last-article-p article)))
5906 (gnus-summary-next-article)
5907 (gnus-summary-next-unread-article))
5908 (if (or (null gnus-current-article)
5909 (null gnus-article-current)
5910 (/= article (cdr gnus-article-current))
5911 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5912 ;; Selected subject is different from current article's.
5913 (gnus-summary-display-article article)
5914 (when article-window
5915 (gnus-eval-in-buffer-window gnus-article-buffer
5916 (setq endp (gnus-article-next-page lines)))
5919 (gnus-summary-beginning-of-article))
5921 (gnus-message 3 "End of message"))
5923 (if (and (eq gnus-summary-goto-unread 'never)
5924 (not (gnus-summary-last-article-p article)))
5925 (gnus-summary-next-article)
5926 (gnus-summary-next-unread-article))))))))
5927 (gnus-summary-recenter)
5928 (gnus-summary-position-point)))
5930 (defun gnus-summary-prev-page (&optional lines move)
5931 "Show previous page of selected article.
5932 Argument LINES specifies lines to be scrolled down.
5933 If MOVE, move to the previous unread article if point is at
5934 the beginning of the buffer."
5936 (let ((article (gnus-summary-article-number))
5937 (article-window (get-buffer-window gnus-article-buffer t))
5939 (gnus-configure-windows 'article)
5940 (if (or (null gnus-current-article)
5941 (null gnus-article-current)
5942 (/= article (cdr gnus-article-current))
5943 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5944 ;; Selected subject is different from current article's.
5945 (gnus-summary-display-article article)
5946 (gnus-summary-recenter)
5947 (when article-window
5948 (gnus-eval-in-buffer-window gnus-article-buffer
5949 (setq endp (gnus-article-prev-page lines)))
5950 (when (and move endp)
5952 (gnus-message 3 "Beginning of message"))
5954 (if (and (eq gnus-summary-goto-unread 'never)
5955 (not (gnus-summary-first-article-p article)))
5956 (gnus-summary-prev-article)
5957 (gnus-summary-prev-unread-article))))))))
5958 (gnus-summary-position-point))
5960 (defun gnus-summary-prev-page-or-article (&optional lines)
5961 "Show previous page of selected article.
5962 Argument LINES specifies lines to be scrolled down.
5963 If at the beginning of the article, go to the next article."
5965 (gnus-summary-prev-page lines t))
5967 (defun gnus-summary-scroll-up (lines)
5968 "Scroll up (or down) one line current article.
5969 Argument LINES specifies lines to be scrolled up (or down if negative)."
5971 (gnus-configure-windows 'article)
5972 (gnus-summary-show-thread)
5973 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5974 (gnus-eval-in-buffer-window gnus-article-buffer
5976 (when (gnus-article-next-page lines)
5977 (gnus-message 3 "End of message")))
5979 (gnus-article-prev-page (- lines))))))
5980 (gnus-summary-recenter)
5981 (gnus-summary-position-point))
5983 (defun gnus-summary-scroll-down (lines)
5984 "Scroll down (or up) one line current article.
5985 Argument LINES specifies lines to be scrolled down (or up if negative)."
5987 (gnus-summary-scroll-up (- lines)))
5989 (defun gnus-summary-next-same-subject ()
5990 "Select next article which has the same subject as current one."
5992 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5994 (defun gnus-summary-prev-same-subject ()
5995 "Select previous article which has the same subject as current one."
5997 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5999 (defun gnus-summary-next-unread-same-subject ()
6000 "Select next unread article which has the same subject as current one."
6002 (gnus-summary-next-article t (gnus-summary-article-subject)))
6004 (defun gnus-summary-prev-unread-same-subject ()
6005 "Select previous unread article which has the same subject as current one."
6007 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6009 (defun gnus-summary-first-unread-article ()
6010 "Select the first unread article.
6011 Return nil if there are no unread articles."
6014 (when (gnus-summary-first-subject t)
6015 (gnus-summary-show-thread)
6016 (gnus-summary-first-subject t)
6017 (gnus-summary-display-article (gnus-summary-article-number)))
6018 (gnus-summary-position-point)))
6020 (defun gnus-summary-first-unread-subject ()
6021 "Place the point on the subject line of the first unread article.
6022 Return nil if there are no unread articles."
6025 (when (gnus-summary-first-subject t)
6026 (gnus-summary-show-thread)
6027 (gnus-summary-first-subject t))
6028 (gnus-summary-position-point)))
6030 (defun gnus-summary-first-article ()
6031 "Select the first article.
6032 Return nil if there are no articles."
6035 (when (gnus-summary-first-subject)
6036 (gnus-summary-show-thread)
6037 (gnus-summary-first-subject)
6038 (gnus-summary-display-article (gnus-summary-article-number)))
6039 (gnus-summary-position-point)))
6041 (defun gnus-summary-best-unread-article ()
6042 "Select the unread article with the highest score."
6044 (let ((best -1000000)
6045 (data gnus-newsgroup-data)
6048 (and (gnus-data-unread-p (car data))
6050 (gnus-summary-article-score (gnus-data-number (car data))))
6053 article (gnus-data-number (car data))))
6054 (setq data (cdr data)))
6057 (gnus-summary-goto-article article)
6058 (error "No unread articles"))
6059 (gnus-summary-position-point))))
6061 (defun gnus-summary-last-subject ()
6062 "Go to the last displayed subject line in the group."
6063 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6065 (gnus-summary-goto-subject article))))
6067 (defun gnus-summary-goto-article (article &optional all-headers force)
6068 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6069 If ALL-HEADERS is non-nil, no header lines are hidden.
6070 If FORCE, go to the article even if it isn't displayed. If FORCE
6071 is a number, it is the line the article is to be displayed on."
6075 "Article number or Message-ID: "
6076 (mapcar (lambda (number) (list (int-to-string number)))
6077 gnus-newsgroup-limit))
6081 (if (and (stringp article)
6082 (string-match "@" article))
6083 (gnus-summary-refer-article article)
6084 (when (stringp article)
6085 (setq article (string-to-number article)))
6086 (if (gnus-summary-goto-subject article force)
6087 (gnus-summary-display-article article all-headers)
6088 (gnus-message 4 "Couldn't go to article %s" article) nil))
6089 (gnus-summary-position-point)))
6091 (defun gnus-summary-goto-last-article ()
6092 "Go to the previously read article."
6095 (when gnus-last-article
6096 (gnus-summary-goto-article gnus-last-article nil t))
6097 (gnus-summary-position-point)))
6099 (defun gnus-summary-pop-article (number)
6100 "Pop one article off the history and go to the previous.
6101 NUMBER articles will be popped off."
6104 (setq gnus-newsgroup-history
6105 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6107 (gnus-summary-goto-article (car to) nil t)
6108 (error "Article history empty")))
6109 (gnus-summary-position-point))
6111 ;; Summary commands and functions for limiting the summary buffer.
6113 (defun gnus-summary-limit-to-articles (n)
6114 "Limit the summary buffer to the next N articles.
6115 If not given a prefix, use the process marked articles instead."
6118 (let ((articles (gnus-summary-work-articles n)))
6119 (setq gnus-newsgroup-processable nil)
6120 (gnus-summary-limit articles))
6121 (gnus-summary-position-point)))
6123 (defun gnus-summary-pop-limit (&optional total)
6124 "Restore the previous limit.
6125 If given a prefix, remove all limits."
6128 (setq gnus-newsgroup-limits
6129 (list (mapcar (lambda (h) (mail-header-number h))
6130 gnus-newsgroup-headers))))
6131 (unless gnus-newsgroup-limits
6132 (error "No limit to pop"))
6134 (gnus-summary-limit nil 'pop)
6135 (gnus-summary-position-point)))
6137 (defun gnus-summary-limit-to-subject (subject &optional header)
6138 "Limit the summary buffer to articles that have subjects that match a regexp."
6139 (interactive "sLimit to subject (regexp): ")
6141 (setq header "subject"))
6142 (when (not (equal "" subject))
6144 (let ((articles (gnus-summary-find-matching
6145 (or header "subject") subject 'all)))
6147 (error "Found no matches for \"%s\"" subject))
6148 (gnus-summary-limit articles))
6149 (gnus-summary-position-point))))
6151 (defun gnus-summary-limit-to-author (from)
6152 "Limit the summary buffer to articles that have authors that match a regexp."
6153 (interactive "sLimit to author (regexp): ")
6154 (gnus-summary-limit-to-subject from "from"))
6156 (defun gnus-summary-limit-to-age (age &optional younger-p)
6157 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6158 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6159 articles that are younger than AGE days."
6160 (interactive "nLimit to articles older than (in days): \nP")
6162 (let ((data gnus-newsgroup-data)
6163 (cutoff (days-to-time age))
6164 articles d date is-younger)
6165 (while (setq d (pop data))
6166 (when (and (vectorp (gnus-data-header d))
6167 (setq date (mail-header-date (gnus-data-header d))))
6168 (setq is-younger (time-less-p
6169 (time-since (date-to-time date))
6174 (push (gnus-data-number d) articles))))
6175 (gnus-summary-limit (nreverse articles)))
6176 (gnus-summary-position-point)))
6178 (defun gnus-summary-limit-to-extra (header regexp)
6179 "Limit the summary buffer to articles that match an 'extra' header."
6183 (gnus-completing-read
6184 (symbol-name (car gnus-extra-headers))
6185 "Score extra header:"
6187 (cons (symbol-name x) x))
6192 (read-string (format "Limit to header %s (regexp): " header)))))
6193 (when (not (equal "" regexp))
6195 (let ((articles (gnus-summary-find-matching
6196 (cons 'extra header) regexp 'all)))
6198 (error "Found no matches for \"%s\"" regexp))
6199 (gnus-summary-limit articles))
6200 (gnus-summary-position-point))))
6202 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6204 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6206 (defun gnus-summary-limit-to-unread (&optional all)
6207 "Limit the summary buffer to articles that are not marked as read.
6208 If ALL is non-nil, limit strictly to unread articles."
6211 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6212 (gnus-summary-limit-to-marks
6213 ;; Concat all the marks that say that an article is read and have
6215 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6216 gnus-killed-mark gnus-kill-file-mark
6217 gnus-low-score-mark gnus-expirable-mark
6218 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6219 gnus-duplicate-mark gnus-souped-mark)
6222 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6223 (make-obsolete 'gnus-summary-delete-marked-with
6224 'gnus-summary-limit-exlude-marks)
6226 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6227 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6228 If REVERSE, limit the summary buffer to articles that are marked
6229 with MARKS. MARKS can either be a string of marks or a list of marks.
6230 Returns how many articles were removed."
6231 (interactive "sMarks: ")
6232 (gnus-summary-limit-to-marks marks t))
6234 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6235 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6236 If REVERSE (the prefix), limit the summary buffer to articles that are
6237 not marked with MARKS. MARKS can either be a string of marks or a
6239 Returns how many articles were removed."
6240 (interactive "sMarks: \nP")
6242 (let ((data gnus-newsgroup-data)
6243 (marks (if (listp marks) marks
6244 (append marks nil))) ; Transform to list.
6247 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6248 (memq (gnus-data-mark (car data)) marks))
6249 (push (gnus-data-number (car data)) articles))
6250 (setq data (cdr data)))
6251 (gnus-summary-limit articles))
6252 (gnus-summary-position-point)))
6254 (defun gnus-summary-limit-to-score (&optional score)
6255 "Limit to articles with score at or above SCORE."
6257 (setq score (if score
6258 (prefix-numeric-value score)
6259 (or gnus-summary-default-score 0)))
6260 (let ((data gnus-newsgroup-data)
6263 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6265 (push (gnus-data-number (car data)) articles))
6266 (setq data (cdr data)))
6268 (gnus-summary-limit articles)
6269 (gnus-summary-position-point))))
6271 (defun gnus-summary-limit-include-thread (id)
6272 "Display all the hidden articles that in the current thread."
6273 (interactive (list (mail-header-id (gnus-summary-article-header))))
6274 (let ((articles (gnus-articles-in-thread
6275 (gnus-id-to-thread (gnus-root-id id)))))
6277 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6278 (gnus-summary-position-point))))
6280 (defun gnus-summary-limit-include-dormant ()
6281 "Display all the hidden articles that are marked as dormant.
6282 Note that this command only works on a subset of the articles currently
6283 fetched for this group."
6285 (unless gnus-newsgroup-dormant
6286 (error "There are no dormant articles in this group"))
6288 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6289 (gnus-summary-position-point)))
6291 (defun gnus-summary-limit-exclude-dormant ()
6292 "Hide all dormant articles."
6295 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6296 (gnus-summary-position-point)))
6298 (defun gnus-summary-limit-exclude-childless-dormant ()
6299 "Hide all dormant articles that have no children."
6301 (let ((data (gnus-data-list t))
6302 articles d children)
6303 ;; Find all articles that are either not dormant or have
6305 (while (setq d (pop data))
6306 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6308 (gnus-article-children (gnus-data-number d)))
6311 (when (memq (car children) articles)
6316 (push (gnus-data-number d) articles)))
6319 (gnus-summary-limit articles)
6320 (gnus-summary-position-point))))
6322 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6323 "Mark all unread excluded articles as read.
6324 If ALL, mark even excluded ticked and dormants as read."
6326 (let ((articles (gnus-sorted-complement
6328 (mapcar (lambda (h) (mail-header-number h))
6329 gnus-newsgroup-headers)
6331 (sort gnus-newsgroup-limit '<)))
6333 (setq gnus-newsgroup-unreads
6334 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6336 (setq gnus-newsgroup-dormant nil
6337 gnus-newsgroup-marked nil
6338 gnus-newsgroup-reads
6340 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6341 gnus-newsgroup-reads))
6342 (while (setq article (pop articles))
6343 (unless (or (memq article gnus-newsgroup-dormant)
6344 (memq article gnus-newsgroup-marked))
6345 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6347 (defun gnus-summary-limit (articles &optional pop)
6349 ;; We pop the previous limit off the stack and use that.
6350 (setq articles (car gnus-newsgroup-limits)
6351 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6352 ;; We use the new limit, so we push the old limit on the stack.
6353 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6355 (setq gnus-newsgroup-limit articles)
6356 (let ((total (length gnus-newsgroup-data))
6357 (data (gnus-data-find-list (gnus-summary-article-number)))
6358 (gnus-summary-mark-below nil) ; Inhibit this.
6360 ;; This will do all the work of generating the new summary buffer
6361 ;; according to the new limit.
6362 (gnus-summary-prepare)
6363 ;; Hide any threads, possibly.
6364 (and gnus-show-threads
6365 gnus-thread-hide-subtree
6366 (gnus-summary-hide-all-threads))
6367 ;; Try to return to the article you were at, or one in the
6370 ;; We try to find some article after the current one.
6372 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6375 (setq data (cdr data))))
6377 ;; If there is no data, that means that we were after the last
6378 ;; article. The same goes when we can't find any articles
6379 ;; after the current one.
6380 (goto-char (point-max))
6381 (gnus-summary-find-prev))
6382 (gnus-set-mode-line 'summary)
6383 ;; We return how many articles were removed from the summary
6384 ;; buffer as a result of the new limit.
6385 (- total (length gnus-newsgroup-data))))
6387 (defsubst gnus-invisible-cut-children (threads)
6390 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6395 (defsubst gnus-cut-thread (thread)
6396 "Go forwards in the thread until we find an article that we want to display."
6397 (when (or (eq gnus-fetch-old-headers 'some)
6398 (eq gnus-fetch-old-headers 'invisible)
6399 (eq gnus-build-sparse-threads 'some)
6400 (eq gnus-build-sparse-threads 'more))
6401 ;; Deal with old-fetched headers and sparse threads.
6405 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6406 (gnus-summary-article-ancient-p
6407 (mail-header-number (car thread))))
6408 (if (or (<= (length (cdr thread)) 1)
6409 (eq gnus-fetch-old-headers 'invisible))
6410 (setq gnus-newsgroup-limit
6411 (delq (mail-header-number (car thread))
6412 gnus-newsgroup-limit)
6413 thread (cadr thread))
6414 (when (gnus-invisible-cut-children (cdr thread))
6415 (let ((th (cdr thread)))
6417 (if (memq (mail-header-number (caar th))
6418 gnus-newsgroup-limit)
6419 (setq thread (car th)
6421 (setq th (cdr th))))))))))
6424 (defun gnus-cut-threads (threads)
6425 "Cut off all uninteresting articles from the beginning of threads."
6426 (when (or (eq gnus-fetch-old-headers 'some)
6427 (eq gnus-fetch-old-headers 'invisible)
6428 (eq gnus-build-sparse-threads 'some)
6429 (eq gnus-build-sparse-threads 'more))
6432 (setcar th (gnus-cut-thread (car th)))
6433 (setq th (cdr th)))))
6434 ;; Remove nixed out threads.
6437 (defun gnus-summary-initial-limit (&optional show-if-empty)
6438 "Figure out what the initial limit is supposed to be on group entry.
6439 This entails weeding out unwanted dormants, low-scored articles,
6440 fetch-old-headers verbiage, and so on."
6441 ;; Most groups have nothing to remove.
6442 (if (or gnus-inhibit-limiting
6443 (and (null gnus-newsgroup-dormant)
6444 (not (eq gnus-fetch-old-headers 'some))
6445 (not (eq gnus-fetch-old-headers 'invisible))
6446 (null gnus-summary-expunge-below)
6447 (not (eq gnus-build-sparse-threads 'some))
6448 (not (eq gnus-build-sparse-threads 'more))
6449 (null gnus-thread-expunge-below)
6450 (not gnus-use-nocem)))
6452 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6453 (setq gnus-newsgroup-limit nil)
6456 (unless (car (symbol-value node))
6457 ;; These threads have no parents -- they are roots.
6458 (let ((nodes (cdr (symbol-value node)))
6461 (if (and gnus-thread-expunge-below
6462 (< (gnus-thread-total-score (car nodes))
6463 gnus-thread-expunge-below))
6464 (gnus-expunge-thread (pop nodes))
6465 (setq thread (pop nodes))
6466 (gnus-summary-limit-children thread))))))
6467 gnus-newsgroup-dependencies)
6468 ;; If this limitation resulted in an empty group, we might
6469 ;; pop the previous limit and use it instead.
6470 (when (and (not gnus-newsgroup-limit)
6472 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6473 gnus-newsgroup-limit))
6475 (defun gnus-summary-limit-children (thread)
6476 "Return 1 if this subthread is visible and 0 if it is not."
6477 ;; First we get the number of visible children to this thread. This
6478 ;; is done by recursing down the thread using this function, so this
6479 ;; will really go down to a leaf article first, before slowly
6480 ;; working its way up towards the root.
6484 (apply '+ (mapcar 'gnus-summary-limit-children
6487 (number (mail-header-number (car thread)))
6490 (not (memq number gnus-newsgroup-marked))
6492 ;; If this article is dormant and has absolutely no visible
6493 ;; children, then this article isn't visible.
6494 (and (memq number gnus-newsgroup-dormant)
6496 ;; If this is "fetch-old-headered" and there is no
6497 ;; visible children, then we don't want this article.
6498 (and (eq gnus-fetch-old-headers 'some)
6499 (gnus-summary-article-ancient-p number)
6501 ;; If this is "fetch-old-headered" and `invisible', then
6502 ;; we don't want this article.
6503 (and (eq gnus-fetch-old-headers 'invisible)
6504 (gnus-summary-article-ancient-p number))
6505 ;; If this is a sparsely inserted article with no children,
6506 ;; we don't want it.
6507 (and (eq gnus-build-sparse-threads 'some)
6508 (gnus-summary-article-sparse-p number)
6510 ;; If we use expunging, and this article is really
6511 ;; low-scored, then we don't want this article.
6512 (when (and gnus-summary-expunge-below
6514 (or (cdr (assq number gnus-newsgroup-scored))
6515 gnus-summary-default-score))
6516 gnus-summary-expunge-below))
6517 ;; We increase the expunge-tally here, but that has
6518 ;; nothing to do with the limits, really.
6519 (incf gnus-newsgroup-expunged-tally)
6520 ;; We also mark as read here, if that's wanted.
6521 (when (and gnus-summary-mark-below
6522 (< score gnus-summary-mark-below))
6523 (setq gnus-newsgroup-unreads
6524 (delq number gnus-newsgroup-unreads))
6525 (if gnus-newsgroup-auto-expire
6526 (push number gnus-newsgroup-expirable)
6527 (push (cons number gnus-low-score-mark)
6528 gnus-newsgroup-reads)))
6530 ;; Check NoCeM things.
6531 (if (and gnus-use-nocem
6532 (gnus-nocem-unwanted-article-p
6533 (mail-header-id (car thread))))
6535 (setq gnus-newsgroup-unreads
6536 (delq number gnus-newsgroup-unreads))
6538 ;; Nope, invisible article.
6540 ;; Ok, this article is to be visible, so we add it to the limit
6542 (push number gnus-newsgroup-limit)
6545 (defun gnus-expunge-thread (thread)
6546 "Mark all articles in THREAD as read."
6547 (let* ((number (mail-header-number (car thread))))
6548 (incf gnus-newsgroup-expunged-tally)
6549 ;; We also mark as read here, if that's wanted.
6550 (setq gnus-newsgroup-unreads
6551 (delq number gnus-newsgroup-unreads))
6552 (if gnus-newsgroup-auto-expire
6553 (push number gnus-newsgroup-expirable)
6554 (push (cons number gnus-low-score-mark)
6555 gnus-newsgroup-reads)))
6556 ;; Go recursively through all subthreads.
6557 (mapcar 'gnus-expunge-thread (cdr thread)))
6559 ;; Summary article oriented commands
6561 (defun gnus-summary-refer-parent-article (n)
6562 "Refer parent article N times.
6563 If N is negative, go to ancestor -N instead.
6564 The difference between N and the number of articles fetched is returned."
6568 (when (not (natnump n))
6573 (setq header (gnus-summary-article-header))
6574 (if (and (eq (mail-header-number header)
6575 (cdr gnus-article-current))
6576 (equal gnus-newsgroup-name
6577 (car gnus-article-current)))
6578 ;; If we try to find the parent of the currently
6579 ;; displayed article, then we take a look at the actual
6580 ;; References header, since this is slightly more
6581 ;; reliable than the References field we got from the
6584 (set-buffer gnus-original-article-buffer)
6585 (nnheader-narrow-to-headers)
6586 (unless (setq ref (message-fetch-field "references"))
6587 (setq ref (message-fetch-field "in-reply-to")))
6590 ;; It's not the current article, so we take a bet on
6591 ;; the value we got from the server.
6592 (mail-header-references header)))
6594 (not (equal ref "")))
6595 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6596 (gnus-message 1 "Couldn't find parent"))
6597 (gnus-message 1 "No references in article %d"
6598 (gnus-summary-article-number))
6601 (gnus-summary-position-point)
6604 (defun gnus-summary-refer-references ()
6605 "Fetch all articles mentioned in the References header.
6606 Return the number of articles fetched."
6608 (let ((ref (mail-header-references (gnus-summary-article-header)))
6609 (current (gnus-summary-article-number))
6613 (error "No References in the current article")
6614 ;; For each Message-ID in the References header...
6615 (while (string-match "<[^>]*>" ref)
6617 ;; ... fetch that article.
6618 (gnus-summary-refer-article
6619 (prog1 (match-string 0 ref)
6620 (setq ref (substring ref (match-end 0))))))
6621 (gnus-summary-goto-subject current)
6622 (gnus-summary-position-point)
6625 (defun gnus-summary-refer-thread (&optional limit)
6626 "Fetch all articles in the current thread.
6627 If LIMIT (the numerical prefix), fetch that many old headers instead
6628 of what's specified by the `gnus-refer-thread-limit' variable."
6630 (let ((id (mail-header-id (gnus-summary-article-header)))
6631 (limit (if limit (prefix-numeric-value limit)
6632 gnus-refer-thread-limit)))
6633 ;; We want to fetch LIMIT *old* headers, but we also have to
6634 ;; re-fetch all the headers in the current buffer, because many of
6635 ;; them may be undisplayed. So we adjust LIMIT.
6636 (when (numberp limit)
6637 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6638 (unless (eq gnus-fetch-old-headers 'invisible)
6639 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6640 ;; Retrieve the headers and read them in.
6641 (if (eq (gnus-retrieve-headers
6642 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6644 (gnus-build-all-threads)
6645 (error "Can't fetch thread from backends that don't support NOV"))
6646 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6647 (gnus-summary-limit-include-thread id)))
6649 (defun gnus-summary-refer-article (message-id &optional arg)
6650 "Fetch an article specified by MESSAGE-ID.
6651 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6652 or `gnus-select-method', no matter what backend the article comes from."
6653 (interactive "sMessage-ID: \nP")
6654 (when (and (stringp message-id)
6655 (not (zerop (length message-id))))
6656 ;; Construct the correct Message-ID if necessary.
6657 ;; Suggested by tale@pawl.rpi.edu.
6658 (unless (string-match "^<" message-id)
6659 (setq message-id (concat "<" message-id)))
6660 (unless (string-match ">$" message-id)
6661 (setq message-id (concat message-id ">")))
6662 (let* ((header (gnus-id-to-header message-id))
6664 (gnus-summary-article-sparse-p
6665 (mail-header-number header))
6666 (memq (mail-header-number header)
6667 gnus-newsgroup-limit))))
6669 ;; If the article is present in the buffer we just go to it.
6671 (or (not (gnus-summary-article-sparse-p
6672 (mail-header-number header)))
6675 (gnus-summary-goto-article
6676 (mail-header-number header) nil t)
6678 (gnus-summary-update-article (mail-header-number header)))))
6680 ;; We fetch the article
6681 (let ((gnus-override-method
6682 (cond ((gnus-news-group-p gnus-newsgroup-name)
6683 gnus-refer-article-method)
6685 (or gnus-refer-article-method gnus-select-method))
6688 ;; Start the special refer-article method, if necessary.
6689 (when (and gnus-refer-article-method
6690 (gnus-news-group-p gnus-newsgroup-name))
6691 (gnus-check-server gnus-refer-article-method))
6692 ;; Fetch the header, and display the article.
6693 (if (setq number (gnus-summary-insert-subject message-id))
6694 (gnus-summary-select-article nil nil nil number)
6695 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6697 (defun gnus-summary-edit-parameters ()
6698 "Edit the group parameters of the current group."
6700 (gnus-group-edit-group gnus-newsgroup-name 'params))
6702 (defun gnus-summary-customize-parameters ()
6703 "Customize the group parameters of the current group."
6705 (gnus-group-customize gnus-newsgroup-name))
6707 (defun gnus-summary-enter-digest-group (&optional force)
6708 "Enter an nndoc group based on the current article.
6709 If FORCE, force a digest interpretation. If not, try
6710 to guess what the document format is."
6712 (let ((conf gnus-current-window-configuration))
6714 (gnus-summary-select-article))
6715 (setq gnus-current-window-configuration conf)
6716 (let* ((name (format "%s-%d"
6717 (gnus-group-prefixed-name
6718 gnus-newsgroup-name (list 'nndoc ""))
6720 (set-buffer gnus-summary-buffer)
6721 gnus-current-article)))
6722 (ogroup gnus-newsgroup-name)
6723 (params (append (gnus-info-params (gnus-get-info ogroup))
6724 (list (cons 'to-group ogroup))
6725 (list (cons 'save-article-group ogroup))))
6726 (case-fold-search t)
6727 (buf (current-buffer))
6730 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6731 (insert-buffer-substring gnus-original-article-buffer)
6732 ;; Remove lines that may lead nndoc to misinterpret the
6735 (goto-char (point-min))
6736 (or (search-forward "\n\n" nil t) (point)))
6737 (goto-char (point-min))
6738 (delete-matching-lines "^\\(Path\\):\\|^From ")
6741 (if (gnus-group-read-ephemeral-group
6742 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6744 ,(if force 'digest 'guess))) t)
6745 ;; Make all postings to this group go to the parent group.
6746 (nconc (gnus-info-params (gnus-get-info name))
6748 ;; Couldn't select this doc group.
6749 (switch-to-buffer buf)
6750 (gnus-set-global-variables)
6751 (gnus-configure-windows 'summary)
6752 (gnus-message 3 "Article couldn't be entered?"))
6753 (kill-buffer dig)))))
6755 (defun gnus-summary-read-document (n)
6756 "Open a new group based on the current article(s).
6757 This will allow you to read digests and other similar
6758 documents as newsgroups.
6759 Obeys the standard process/prefix convention."
6761 (let* ((articles (gnus-summary-work-articles n))
6762 (ogroup gnus-newsgroup-name)
6763 (params (append (gnus-info-params (gnus-get-info ogroup))
6764 (list (cons 'to-group ogroup))))
6765 article group egroup groups vgroup)
6766 (while (setq article (pop articles))
6767 (setq group (format "%s-%d" gnus-newsgroup-name article))
6768 (gnus-summary-remove-process-mark article)
6769 (when (gnus-summary-display-article article)
6772 (insert-buffer-substring gnus-original-article-buffer)
6773 ;; Remove some headers that may lead nndoc to make
6775 (message-narrow-to-head)
6776 (goto-char (point-min))
6777 (delete-matching-lines "^\\(Path\\):\\|^From ")
6780 (gnus-group-read-ephemeral-group
6781 group `(nndoc ,group (nndoc-address ,(current-buffer))
6782 (nndoc-article-type guess))
6785 ;; Make all postings to this group go to the parent group.
6786 (nconc (gnus-info-params (gnus-get-info egroup))
6788 (push egroup groups))
6789 ;; Couldn't select this doc group.
6790 (gnus-error 3 "Article couldn't be entered"))))))
6791 ;; Now we have selected all the documents.
6794 (error "None of the articles could be interpreted as documents"))
6795 ((gnus-group-read-ephemeral-group
6796 (setq vgroup (format
6797 "nnvirtual:%s-%s" gnus-newsgroup-name
6798 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6799 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6801 (cons (current-buffer) 'summary)))
6803 (error "Couldn't select virtual nndoc group")))))
6805 (defun gnus-summary-isearch-article (&optional regexp-p)
6806 "Do incremental search forward on the current article.
6807 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6809 (gnus-summary-select-article)
6810 (gnus-configure-windows 'article)
6811 (gnus-eval-in-buffer-window gnus-article-buffer
6814 (isearch-forward regexp-p))))
6816 (defun gnus-summary-search-article-forward (regexp &optional backward)
6817 "Search for an article containing REGEXP forward.
6818 If BACKWARD, search backward instead."
6821 (format "Search article %s (regexp%s): "
6822 (if current-prefix-arg "backward" "forward")
6823 (if gnus-last-search-regexp
6824 (concat ", default " gnus-last-search-regexp)
6826 current-prefix-arg))
6827 (if (string-equal regexp "")
6828 (setq regexp (or gnus-last-search-regexp ""))
6829 (setq gnus-last-search-regexp regexp))
6830 (if (gnus-summary-search-article regexp backward)
6831 (gnus-summary-show-thread)
6832 (error "Search failed: \"%s\"" regexp)))
6834 (defun gnus-summary-search-article-backward (regexp)
6835 "Search for an article containing REGEXP backward."
6838 (format "Search article backward (regexp%s): "
6839 (if gnus-last-search-regexp
6840 (concat ", default " gnus-last-search-regexp)
6842 (gnus-summary-search-article-forward regexp 'backward))
6844 (defun gnus-summary-search-article (regexp &optional backward)
6845 "Search for an article containing REGEXP.
6846 Optional argument BACKWARD means do search for backward.
6847 `gnus-select-article-hook' is not called during the search."
6848 ;; We have to require this here to make sure that the following
6849 ;; dynamic binding isn't shadowed by autoloading.
6850 (require 'gnus-async)
6852 (let ((gnus-select-article-hook nil) ;Disable hook.
6853 (gnus-article-display-hook nil)
6854 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6855 (gnus-use-article-prefetch nil)
6856 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6857 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6858 (sum (current-buffer))
6861 (gnus-save-hidden-threads
6862 (gnus-summary-select-article)
6863 (set-buffer gnus-article-buffer)
6867 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6869 (re-search-backward regexp nil t)
6870 (re-search-forward regexp nil t))
6871 ;; We found the regexp.
6876 (get-buffer-window (current-buffer))
6880 (setq point (point)))
6881 ;; We didn't find it, so we go to the next article.
6884 (while (eq found 'not)
6885 (if (not (if backward (gnus-summary-find-prev)
6886 (gnus-summary-find-next)))
6887 ;; No more articles.
6889 ;; Select the next article and adjust point.
6890 (unless (gnus-summary-article-sparse-p
6891 (gnus-summary-article-number))
6893 (gnus-summary-select-article)
6894 (set-buffer gnus-article-buffer)
6896 (goto-char (if backward (point-max) (point-min))))))))
6897 (gnus-message 7 ""))
6898 ;; Return whether we found the regexp.
6899 (when (eq found 'found)
6901 (gnus-summary-show-thread)
6902 (gnus-summary-goto-subject gnus-current-article)
6903 (gnus-summary-position-point)
6906 (defun gnus-summary-find-matching (header regexp &optional backward unread
6908 "Return a list of all articles that match REGEXP on HEADER.
6909 The search stars on the current article and goes forwards unless
6910 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6911 If UNREAD is non-nil, only unread articles will
6912 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6913 in the comparisons."
6914 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6915 (gnus-data-find-list
6916 (gnus-summary-article-number) (gnus-data-list backward))))
6917 (case-fold-search (not not-case-fold))
6920 (if (eq (car header) 'extra)
6923 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
6925 (error "%s is an invalid header" header))
6926 (unless (fboundp (intern (concat "mail-header-" header)))
6927 (error "%s is not a valid header" header))
6928 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
6931 (and (or (not unread) ; We want all articles...
6932 (gnus-data-unread-p d)) ; Or just unreads.
6933 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6934 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6935 (push (gnus-data-number d) articles)) ; Success!
6936 (setq data (cdr data)))
6937 (nreverse articles)))
6939 (defun gnus-summary-execute-command (header regexp command &optional backward)
6940 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6941 If HEADER is an empty string (or nil), the match is done on the entire
6942 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6944 (list (let ((completion-ignore-case t))
6947 (mapcar (lambda (string) (list string))
6948 '("Number" "Subject" "From" "Lines" "Date"
6949 "Message-ID" "Xref" "References" "Body"))
6950 nil 'require-match))
6951 (read-string "Regexp: ")
6952 (read-key-sequence "Command: ")
6953 current-prefix-arg))
6954 (when (equal header "Body")
6956 ;; Hidden thread subtrees must be searched as well.
6957 (gnus-summary-show-all-threads)
6958 ;; We don't want to change current point nor window configuration.
6960 (save-window-excursion
6961 (gnus-message 6 "Executing %s..." (key-description command))
6962 ;; We'd like to execute COMMAND interactively so as to give arguments.
6963 (gnus-execute header regexp
6964 `(call-interactively ',(key-binding command))
6966 (gnus-message 6 "Executing %s...done" (key-description command)))))
6968 (defun gnus-summary-beginning-of-article ()
6969 "Scroll the article back to the beginning."
6971 (gnus-summary-select-article)
6972 (gnus-configure-windows 'article)
6973 (gnus-eval-in-buffer-window gnus-article-buffer
6975 (goto-char (point-min))
6976 (when gnus-page-broken
6977 (gnus-narrow-to-page))))
6979 (defun gnus-summary-end-of-article ()
6980 "Scroll to the end of the article."
6982 (gnus-summary-select-article)
6983 (gnus-configure-windows 'article)
6984 (gnus-eval-in-buffer-window gnus-article-buffer
6986 (goto-char (point-max))
6988 (when gnus-page-broken
6989 (gnus-narrow-to-page))))
6991 (defun gnus-summary-print-article (&optional filename n)
6992 "Generate and print a PostScript image of the N next (mail) articles.
6994 If N is negative, print the N previous articles. If N is nil and articles
6995 have been marked with the process mark, print these instead.
6997 If the optional first argument FILENAME is nil, send the image to the
6998 printer. If FILENAME is a string, save the PostScript image in a file with
6999 that name. If FILENAME is a number, prompt the user for the name of the file
7001 (interactive (list (ps-print-preprint current-prefix-arg)
7002 current-prefix-arg))
7003 (dolist (article (gnus-summary-work-articles n))
7004 (gnus-summary-select-article nil nil 'pseudo article)
7005 (gnus-eval-in-buffer-window gnus-article-buffer
7006 (let ((buffer (generate-new-buffer " *print*")))
7009 (copy-to-buffer buffer (point-min) (point-max))
7011 (gnus-article-delete-invisible-text)
7012 (let ((ps-left-header
7015 (mail-header-subject gnus-current-headers) ")")
7017 (mail-header-from gnus-current-headers) ")")))
7020 "/pagenumberstring load"
7022 (mail-header-date gnus-current-headers) ")"))))
7023 (gnus-run-hooks 'gnus-ps-print-hook)
7025 (ps-print-buffer-with-faces filename))))
7026 (kill-buffer buffer))))))
7028 (defun gnus-summary-show-article (&optional arg)
7029 "Force re-fetching of the current article.
7030 If ARG (the prefix) is non-nil, show the raw article without any
7031 article massaging functions being run."
7034 ;; Select the article the normal way.
7035 (gnus-summary-select-article nil 'force)
7036 ;; We have to require this here to make sure that the following
7037 ;; dynamic binding isn't shadowed by autoloading.
7038 (require 'gnus-async)
7040 ;; Bind the article treatment functions to nil.
7041 (let ((gnus-have-all-headers t)
7042 gnus-article-display-hook
7043 gnus-article-prepare-hook
7044 gnus-article-decode-hook
7048 (gnus-summary-select-article nil 'force)))
7049 (gnus-summary-goto-subject gnus-current-article)
7050 (gnus-summary-position-point))
7052 (defun gnus-summary-verbose-headers (&optional arg)
7053 "Toggle permanent full header display.
7054 If ARG is a positive number, turn header display on.
7055 If ARG is a negative number, turn header display off."
7057 (setq gnus-show-all-headers
7058 (cond ((or (not (numberp arg))
7060 (not gnus-show-all-headers))
7063 (gnus-summary-show-article))
7065 (defun gnus-summary-toggle-header (&optional arg)
7066 "Show the headers if they are hidden, or hide them if they are shown.
7067 If ARG is a positive number, show the entire header.
7068 If ARG is a negative number, hide the unwanted header lines."
7071 (set-buffer gnus-article-buffer)
7073 (let* ((buffer-read-only nil)
7074 (inhibit-point-motion-hooks t)
7077 (article-narrow-to-head)
7078 (setq hidden (gnus-article-hidden-text-p 'headers)))
7079 (goto-char (point-min))
7080 (when (search-forward "\n\n" nil t)
7081 (delete-region (point-min) (1- (point))))
7082 (goto-char (point-min))
7084 (set-buffer gnus-original-article-buffer)
7085 (goto-char (point-min))
7086 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7087 (insert-buffer-substring gnus-original-article-buffer 1 e)
7089 (narrow-to-region (point-min) (point))
7090 (article-decode-encoded-words)
7092 (and (numberp arg) (< arg 0)))
7093 (let ((gnus-treat-hide-headers nil)
7094 (gnus-treat-hide-boring-headers nil))
7095 (gnus-treat-article 'head))
7096 (gnus-treat-article 'head)))))))
7098 (defun gnus-summary-show-all-headers ()
7099 "Make all header lines visible."
7101 (gnus-article-show-all-headers))
7103 (defun gnus-summary-toggle-mime (&optional arg)
7104 "Toggle MIME processing.
7105 If ARG is a positive number, turn MIME processing on."
7107 (setq gnus-show-mime
7109 (not gnus-show-mime)
7110 (> (prefix-numeric-value arg) 0)))
7111 (gnus-summary-select-article t 'force))
7113 (defun gnus-summary-caesar-message (&optional arg)
7114 "Caesar rotate the current article by 13.
7115 The numerical prefix specifies how many places to rotate each letter
7118 (gnus-summary-select-article)
7119 (let ((mail-header-separator ""))
7120 (gnus-eval-in-buffer-window gnus-article-buffer
7123 (let ((start (window-start))
7125 (message-caesar-buffer-body arg)
7126 (set-window-start (get-buffer-window (current-buffer)) start))))))
7128 (defun gnus-summary-stop-page-breaking ()
7129 "Stop page breaking in the current article."
7131 (gnus-summary-select-article)
7132 (gnus-eval-in-buffer-window gnus-article-buffer
7134 (when (gnus-visual-p 'page-marker)
7135 (let ((buffer-read-only nil))
7136 (gnus-remove-text-with-property 'gnus-prev)
7137 (gnus-remove-text-with-property 'gnus-next))
7138 (setq gnus-page-broken nil))))
7140 (defun gnus-summary-move-article (&optional n to-newsgroup
7141 select-method action)
7142 "Move the current article to a different newsgroup.
7143 If N is a positive number, move the N next articles.
7144 If N is a negative number, move the N previous articles.
7145 If N is nil and any articles have been marked with the process mark,
7146 move those articles instead.
7147 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7148 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7149 re-spool using this method.
7151 For this function to work, both the current newsgroup and the
7152 newsgroup that you want to move to have to support the `request-move'
7153 and `request-accept' functions."
7156 (setq action 'move))
7157 ;; Disable marking as read.
7158 (let (gnus-mark-article-hook)
7159 (save-window-excursion
7160 (gnus-summary-select-article)))
7161 ;; Check whether the source group supports the required functions.
7162 (cond ((and (eq action 'move)
7163 (not (gnus-check-backend-function
7164 'request-move-article gnus-newsgroup-name)))
7165 (error "The current group does not support article moving"))
7166 ((and (eq action 'crosspost)
7167 (not (gnus-check-backend-function
7168 'request-replace-article gnus-newsgroup-name)))
7169 (error "The current group does not support article editing")))
7170 (let ((articles (gnus-summary-work-articles n))
7171 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7172 (names '((move "Move" "Moving")
7173 (copy "Copy" "Copying")
7174 (crosspost "Crosspost" "Crossposting")))
7175 (copy-buf (save-excursion
7176 (nnheader-set-temp-buffer " *copy article*")))
7177 (default-marks gnus-article-mark-lists)
7178 (no-expire-marks (delete '(expirable . expire)
7179 (copy-sequence gnus-article-mark-lists)))
7180 art-group to-method new-xref article to-groups)
7181 (unless (assq action names)
7182 (error "Unknown action %s" action))
7183 ;; Read the newsgroup name.
7184 (when (and (not to-newsgroup)
7185 (not select-method))
7187 (gnus-read-move-group-name
7188 (cadr (assq action names))
7189 (symbol-value (intern (format "gnus-current-%s-group" action)))
7191 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7192 (setq to-method (or select-method
7193 (gnus-group-name-to-method to-newsgroup)))
7194 ;; Check the method we are to move this article to...
7195 (unless (gnus-check-backend-function
7196 'request-accept-article (car to-method))
7197 (error "%s does not support article copying" (car to-method)))
7198 (unless (gnus-check-server to-method)
7199 (error "Can't open server %s" (car to-method)))
7200 (gnus-message 6 "%s to %s: %s..."
7201 (caddr (assq action names))
7202 (or (car select-method) to-newsgroup) articles)
7204 (setq article (pop articles))
7208 ;; Move the article.
7210 ;; Remove this article from future suppression.
7211 (gnus-dup-unsuppress-article article)
7212 (gnus-request-move-article
7213 article ; Article to move
7214 gnus-newsgroup-name ; From newsgroup
7215 (nth 1 (gnus-find-method-for-group
7216 gnus-newsgroup-name)) ; Server
7217 (list 'gnus-request-accept-article
7218 to-newsgroup (list 'quote select-method)
7219 (not articles) t) ; Accept form
7220 (not articles))) ; Only save nov last time
7221 ;; Copy the article.
7224 (set-buffer copy-buf)
7225 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7226 (gnus-request-accept-article
7227 to-newsgroup select-method (not articles) t))))
7228 ;; Crosspost the article.
7229 ((eq action 'crosspost)
7230 (let ((xref (message-tokenize-header
7231 (mail-header-xref (gnus-summary-article-header article))
7233 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7236 (setq xref (list (system-name))))
7239 (mapconcat 'identity
7240 (delete "Xref:" (delete new-xref xref))
7244 (set-buffer copy-buf)
7245 ;; First put the article in the destination group.
7246 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7247 (when (consp (setq art-group
7248 (gnus-request-accept-article
7249 to-newsgroup select-method (not articles))))
7250 (setq new-xref (concat new-xref " " (car art-group)
7251 ":" (cdr art-group)))
7252 ;; Now we have the new Xrefs header, so we insert
7253 ;; it and replace the new article.
7254 (nnheader-replace-header "Xref" new-xref)
7255 (gnus-request-replace-article
7256 (cdr art-group) to-newsgroup (current-buffer))
7260 (gnus-message 1 "Couldn't %s article %s"
7261 (cadr (assq action names)) article))
7262 ((and (eq art-group 'junk)
7264 (gnus-summary-mark-article article gnus-canceled-mark)
7265 (gnus-message 4 "Deleted article %s" article))
7267 (let* ((pto-group (gnus-group-prefixed-name
7268 (car art-group) to-method))
7270 (gnus-gethash pto-group gnus-newsrc-hashtb))
7271 (info (nth 2 entry))
7272 (to-group (gnus-info-group info)))
7273 ;; Update the group that has been moved to.
7275 (memq action '(move copy)))
7276 (unless (member to-group to-groups)
7277 (push to-group to-groups))
7279 (unless (memq article gnus-newsgroup-unreads)
7281 info (gnus-add-to-range (gnus-info-read info)
7282 (list (cdr art-group)))))
7284 ;; Copy any marks over to the new group.
7285 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7288 (to-article (cdr art-group)))
7290 ;; See whether the article is to be put in the cache.
7291 (when gnus-use-cache
7292 (gnus-cache-possibly-enter-article
7294 (let ((header (copy-sequence
7295 (gnus-summary-article-header article))))
7296 (mail-header-set-number header to-article)
7298 (memq article gnus-newsgroup-marked)
7299 (memq article gnus-newsgroup-dormant)
7300 (memq article gnus-newsgroup-unreads)))
7302 (when (and (equal to-group gnus-newsgroup-name)
7303 (not (memq article gnus-newsgroup-unreads)))
7304 ;; Mark this article as read in this group.
7305 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7306 (setcdr (gnus-active to-group) to-article)
7307 (setcdr gnus-newsgroup-active to-article))
7310 (when (memq article (symbol-value
7311 (intern (format "gnus-newsgroup-%s"
7313 ;; If the other group is the same as this group,
7314 ;; then we have to add the mark to the list.
7315 (when (equal to-group gnus-newsgroup-name)
7316 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7319 (intern (format "gnus-newsgroup-%s"
7321 ;; Copy the marks to other group.
7322 (gnus-add-marked-articles
7323 to-group (cdar marks) (list to-article) info))
7324 (setq marks (cdr marks)))
7327 (concat "(gnus-group-set-info '"
7328 (gnus-prin1-to-string (gnus-get-info to-group))
7331 ;; Update the Xref header in this article to point to
7332 ;; the new crossposted article we have just created.
7333 (when (eq action 'crosspost)
7335 (set-buffer copy-buf)
7336 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7337 (nnheader-replace-header "Xref" new-xref)
7338 (gnus-request-replace-article
7339 article gnus-newsgroup-name (current-buffer)))))
7341 ;;;!!!Why is this necessary?
7342 (set-buffer gnus-summary-buffer)
7344 (gnus-summary-goto-subject article)
7345 (when (eq action 'move)
7346 (gnus-summary-mark-article article gnus-canceled-mark))))
7347 (gnus-summary-remove-process-mark article))
7348 ;; Re-activate all groups that have been moved to.
7351 (set-buffer gnus-group-buffer)
7352 (when (gnus-group-goto-group (car to-groups) t)
7353 (gnus-group-get-new-news-this-group 1 t))
7356 (gnus-kill-buffer copy-buf)
7357 (gnus-summary-position-point)
7358 (gnus-set-mode-line 'summary)))
7360 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7361 "Move the current article to a different newsgroup.
7362 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7363 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7364 re-spool using this method."
7366 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7368 (defun gnus-summary-crosspost-article (&optional n)
7369 "Crosspost the current article to some other group."
7371 (gnus-summary-move-article n nil nil 'crosspost))
7373 (defcustom gnus-summary-respool-default-method nil
7374 "Default method for respooling an article.
7375 If nil, use to the current newsgroup method."
7376 :type '(choice (gnus-select-method :value (nnml ""))
7378 :group 'gnus-summary-mail)
7380 (defun gnus-summary-respool-article (&optional n method)
7381 "Respool the current article.
7382 The article will be squeezed through the mail spooling process again,
7383 which means that it will be put in some mail newsgroup or other
7384 depending on `nnmail-split-methods'.
7385 If N is a positive number, respool the N next articles.
7386 If N is a negative number, respool the N previous articles.
7387 If N is nil and any articles have been marked with the process mark,
7388 respool those articles instead.
7390 Respooling can be done both from mail groups and \"real\" newsgroups.
7391 In the former case, the articles in question will be moved from the
7392 current group into whatever groups they are destined to. In the
7393 latter case, they will be copied into the relevant groups."
7395 (list current-prefix-arg
7396 (let* ((methods (gnus-methods-using 'respool))
7398 (symbol-name (or gnus-summary-respool-default-method
7399 (car (gnus-find-method-for-group
7400 gnus-newsgroup-name)))))
7402 (gnus-completing-read
7403 methname "What backend do you want to use when respooling?"
7404 methods nil t nil 'gnus-mail-method-history))
7407 ((zerop (length (setq ms (gnus-servers-using-backend
7409 (list (intern method) ""))
7413 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7414 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7417 (error "No method given for respooling"))
7418 (if (assoc (symbol-name
7419 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7420 (gnus-methods-using 'respool))
7421 (gnus-summary-move-article n nil method)
7422 (gnus-summary-copy-article n nil method)))
7424 (defun gnus-summary-import-article (file)
7425 "Import an arbitrary file into a mail newsgroup."
7426 (interactive "fImport file: ")
7427 (let ((group gnus-newsgroup-name)
7428 (now (current-time))
7430 (unless (gnus-check-backend-function 'request-accept-article group)
7431 (error "%s does not support article importing" group))
7432 (or (file-readable-p file)
7433 (not (file-regular-p file))
7434 (error "Can't read %s" file))
7436 (set-buffer (gnus-get-buffer-create " *import file*"))
7438 (nnheader-insert-file-contents file)
7439 (goto-char (point-min))
7440 (unless (nnheader-article-p)
7441 ;; This doesn't look like an article, so we fudge some headers.
7442 (setq atts (file-attributes file)
7443 lines (count-lines (point-min) (point-max)))
7444 (insert "From: " (read-string "From: ") "\n"
7445 "Subject: " (read-string "Subject: ") "\n"
7446 "Date: " (message-make-date (nth 5 atts))
7448 "Message-ID: " (message-make-message-id) "\n"
7449 "Lines: " (int-to-string lines) "\n"
7450 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7451 (gnus-request-accept-article group nil t)
7452 (kill-buffer (current-buffer)))))
7454 (defun gnus-summary-article-posted-p ()
7455 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7456 This will be the case if the article has both been mailed and posted."
7458 (let ((id (mail-header-references (gnus-summary-article-header)))
7459 (gnus-override-method
7460 (or gnus-refer-article-method gnus-select-method)))
7461 (if (gnus-request-head id "")
7462 (gnus-message 2 "The current message was found on %s"
7463 gnus-override-method)
7464 (gnus-message 2 "The current message couldn't be found on %s"
7465 gnus-override-method)
7468 (defun gnus-summary-expire-articles (&optional now)
7469 "Expire all articles that are marked as expirable in the current group."
7471 (when (gnus-check-backend-function
7472 'request-expire-articles gnus-newsgroup-name)
7473 ;; This backend supports expiry.
7474 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7475 (expirable (if total
7477 ;; We need to update the info for
7478 ;; this group for `gnus-list-of-read-articles'
7479 ;; to give us the right answer.
7480 (gnus-run-hooks 'gnus-exit-group-hook)
7481 (gnus-summary-update-info)
7482 (gnus-list-of-read-articles gnus-newsgroup-name))
7483 (setq gnus-newsgroup-expirable
7484 (sort gnus-newsgroup-expirable '<))))
7485 (expiry-wait (if now 'immediate
7486 (gnus-group-find-parameter
7487 gnus-newsgroup-name 'expiry-wait)))
7490 ;; There are expirable articles in this group, so we run them
7491 ;; through the expiry process.
7492 (gnus-message 6 "Expiring articles...")
7493 (unless (gnus-check-group gnus-newsgroup-name)
7494 (error "Can't open server for %s" gnus-newsgroup-name))
7495 ;; The list of articles that weren't expired is returned.
7498 (let ((nnmail-expiry-wait-function nil)
7499 (nnmail-expiry-wait expiry-wait))
7500 (setq es (gnus-request-expire-articles
7501 expirable gnus-newsgroup-name)))
7502 (setq es (gnus-request-expire-articles
7503 expirable gnus-newsgroup-name))))
7505 (setq gnus-newsgroup-expirable es))
7506 ;; We go through the old list of expirable, and mark all
7507 ;; really expired articles as nonexistent.
7508 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7509 (let ((gnus-use-cache nil))
7511 (unless (memq (car expirable) es)
7512 (when (gnus-data-find (car expirable))
7513 (gnus-summary-mark-article
7514 (car expirable) gnus-canceled-mark)))
7515 (setq expirable (cdr expirable)))))
7516 (gnus-message 6 "Expiring articles...done")))))
7518 (defun gnus-summary-expire-articles-now ()
7519 "Expunge all expirable articles in the current group.
7520 This means that *all* articles that are marked as expirable will be
7521 deleted forever, right now."
7523 (or gnus-expert-user
7525 "Are you really, really, really sure you want to delete all these messages? ")
7527 (gnus-summary-expire-articles t))
7529 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7530 (defun gnus-summary-delete-article (&optional n)
7531 "Delete the N next (mail) articles.
7532 This command actually deletes articles. This is not a marking
7533 command. The article will disappear forever from your life, never to
7535 If N is negative, delete backwards.
7536 If N is nil and articles have been marked with the process mark,
7537 delete these instead."
7539 (unless (gnus-check-backend-function 'request-expire-articles
7540 gnus-newsgroup-name)
7541 (error "The current newsgroup does not support article deletion"))
7542 ;; Compute the list of articles to delete.
7543 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7545 (if (and gnus-novice-user
7546 (not (gnus-yes-or-no-p
7547 (format "Do you really want to delete %s forever? "
7548 (if (> (length articles) 1)
7549 (format "these %s articles" (length articles))
7552 ;; Delete the articles.
7553 (setq not-deleted (gnus-request-expire-articles
7554 articles gnus-newsgroup-name 'force))
7556 (gnus-summary-remove-process-mark (car articles))
7557 ;; The backend might not have been able to delete the article
7559 (unless (memq (car articles) not-deleted)
7560 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7561 (setq articles (cdr articles)))
7563 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7564 (gnus-summary-position-point)
7565 (gnus-set-mode-line 'summary)
7568 (defun gnus-summary-edit-article (&optional force)
7569 "Edit the current article.
7570 This will have permanent effect only in mail groups.
7571 If FORCE is non-nil, allow editing of articles even in read-only
7574 (let ((mail-parse-charset gnus-newsgroup-charset))
7576 (set-buffer gnus-summary-buffer)
7577 (gnus-set-global-variables)
7578 (when (and (not force)
7579 (gnus-group-read-only-p))
7580 (error "The current newsgroup does not support article editing"))
7581 (gnus-summary-show-article t)
7582 (gnus-article-edit-article
7584 `(lambda (no-highlight)
7585 (let ((mail-parse-charset ',gnus-newsgroup-charset))
7586 (gnus-summary-edit-article-done
7587 ,(or (mail-header-references gnus-current-headers) "")
7588 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7590 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7592 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7594 "Make edits to the current article permanent."
7596 ;; Replace the article.
7597 (let ((buf (current-buffer)))
7599 (insert-buffer-substring buf)
7600 (if (and (not read-only)
7601 (not (gnus-request-replace-article
7602 (cdr gnus-article-current) (car gnus-article-current)
7603 (current-buffer) t)))
7604 (error "Couldn't replace article")
7605 ;; Update the summary buffer.
7607 (equal (message-tokenize-header references " ")
7608 (message-tokenize-header
7609 (or (message-fetch-field "references") "") " ")))
7610 ;; We only have to update this line.
7613 (message-narrow-to-head)
7614 (let ((head (buffer-string))
7617 (insert (format "211 %d Article retrieved.\n"
7618 (cdr gnus-article-current)))
7621 (let ((nntp-server-buffer (current-buffer)))
7622 (setq header (car (gnus-get-newsgroup-headers
7624 (set-buffer gnus-summary-buffer)
7625 gnus-newsgroup-dependencies)
7628 (set-buffer gnus-summary-buffer)
7629 (gnus-data-set-header
7630 (gnus-data-find (cdr gnus-article-current))
7632 (gnus-summary-update-article-line
7633 (cdr gnus-article-current) header))))))
7635 (set-buffer (or buffer gnus-summary-buffer))
7636 (gnus-summary-update-article (cdr gnus-article-current)))
7637 ;; Prettify the article buffer again.
7638 (unless no-highlight
7640 (set-buffer gnus-article-buffer)
7641 ;;;!!! Fix this -- article should be rehighlighted.
7642 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7643 (set-buffer gnus-original-article-buffer)
7644 (gnus-request-article
7645 (cdr gnus-article-current)
7646 (car gnus-article-current) (current-buffer))))
7647 ;; Prettify the summary buffer line.
7648 (when (gnus-visual-p 'summary-highlight 'highlight)
7649 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7651 (defun gnus-summary-edit-wash (key)
7652 "Perform editing command KEY in the article buffer."
7656 (message "%s" (concat (this-command-keys) "- "))
7659 (gnus-summary-edit-article)
7660 (execute-kbd-macro (concat (this-command-keys) key))
7661 (gnus-article-edit-done))
7665 (defun gnus-summary-respool-query (&optional silent trace)
7666 "Query where the respool algorithm would put this article."
7668 (let (gnus-mark-article-hook)
7669 (gnus-summary-select-article)
7671 (set-buffer gnus-original-article-buffer)
7673 (message-narrow-to-head)
7674 (let ((groups (nnmail-article-group 'identity trace)))
7677 (message "This message would go to %s"
7678 (mapconcat 'car groups ", "))
7679 (message "This message would go to no groups"))
7682 (defun gnus-summary-respool-trace ()
7683 "Trace where the respool algorithm would put this article.
7684 Display a buffer showing all fancy splitting patterns which matched."
7686 (gnus-summary-respool-query nil t))
7688 ;; Summary marking commands.
7690 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7691 "Mark articles which has the same subject as read, and then select the next.
7692 If UNMARK is positive, remove any kind of mark.
7693 If UNMARK is negative, tick articles."
7696 (setq unmark (prefix-numeric-value unmark)))
7698 (gnus-summary-mark-same-subject
7699 (gnus-summary-article-subject) unmark)))
7700 ;; Select next unread article. If auto-select-same mode, should
7701 ;; select the first unread article.
7702 (gnus-summary-next-article t (and gnus-auto-select-same
7703 (gnus-summary-article-subject)))
7704 (gnus-message 7 "%d article%s marked as %s"
7705 count (if (= count 1) " is" "s are")
7706 (if unmark "unread" "read"))))
7708 (defun gnus-summary-kill-same-subject (&optional unmark)
7709 "Mark articles which has the same subject as read.
7710 If UNMARK is positive, remove any kind of mark.
7711 If UNMARK is negative, tick articles."
7714 (setq unmark (prefix-numeric-value unmark)))
7716 (gnus-summary-mark-same-subject
7717 (gnus-summary-article-subject) unmark)))
7718 ;; If marked as read, go to next unread subject.
7720 ;; Go to next unread subject.
7721 (gnus-summary-next-subject 1 t))
7722 (gnus-message 7 "%d articles are marked as %s"
7723 count (if unmark "unread" "read"))))
7725 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7726 "Mark articles with same SUBJECT as read, and return marked number.
7727 If optional argument UNMARK is positive, remove any kinds of marks.
7728 If optional argument UNMARK is negative, mark articles as unread instead."
7732 ((null unmark) ; Mark as read.
7735 (gnus-summary-mark-article-as-read gnus-killed-mark)
7736 (gnus-summary-show-thread) t)
7737 (gnus-summary-find-subject subject))
7738 (setq count (1+ count))))
7739 ((> unmark 0) ; Tick.
7742 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7743 (gnus-summary-show-thread) t)
7744 (gnus-summary-find-subject subject))
7745 (setq count (1+ count))))
7746 (t ; Mark as unread.
7749 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7750 (gnus-summary-show-thread) t)
7751 (gnus-summary-find-subject subject))
7752 (setq count (1+ count)))))
7753 (gnus-set-mode-line 'summary)
7754 ;; Return the number of marked articles.
7757 (defun gnus-summary-mark-as-processable (n &optional unmark)
7758 "Set the process mark on the next N articles.
7759 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7760 the process mark instead. The difference between N and the actual
7761 number of articles marked is returned."
7763 (let ((backward (< n 0))
7768 (gnus-summary-remove-process-mark
7769 (gnus-summary-article-number))
7770 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7771 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7774 (gnus-message 7 "No more articles"))
7775 (gnus-summary-recenter)
7776 (gnus-summary-position-point)
7779 (defun gnus-summary-unmark-as-processable (n)
7780 "Remove the process mark from the next N articles.
7781 If N is negative, unmark backward instead. The difference between N and
7782 the actual number of articles unmarked is returned."
7784 (gnus-summary-mark-as-processable n t))
7786 (defun gnus-summary-unmark-all-processable ()
7787 "Remove the process mark from all articles."
7790 (while gnus-newsgroup-processable
7791 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7792 (gnus-summary-position-point))
7794 (defun gnus-summary-mark-as-expirable (n)
7795 "Mark N articles forward as expirable.
7796 If N is negative, mark backward instead. The difference between N and
7797 the actual number of articles marked is returned."
7799 (gnus-summary-mark-forward n gnus-expirable-mark))
7801 (defun gnus-summary-mark-article-as-replied (article)
7802 "Mark ARTICLE replied and update the summary line."
7803 (push article gnus-newsgroup-replied)
7804 (let ((buffer-read-only nil))
7805 (when (gnus-summary-goto-subject article nil t)
7806 (gnus-summary-update-secondary-mark article))))
7808 (defun gnus-summary-set-bookmark (article)
7809 "Set a bookmark in current article."
7810 (interactive (list (gnus-summary-article-number)))
7811 (when (or (not (get-buffer gnus-article-buffer))
7812 (not gnus-current-article)
7813 (not gnus-article-current)
7814 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7815 (error "No current article selected"))
7816 ;; Remove old bookmark, if one exists.
7817 (let ((old (assq article gnus-newsgroup-bookmarks)))
7819 (setq gnus-newsgroup-bookmarks
7820 (delq old gnus-newsgroup-bookmarks))))
7821 ;; Set the new bookmark, which is on the form
7822 ;; (article-number . line-number-in-body).
7826 (set-buffer gnus-article-buffer)
7830 (goto-char (point-min))
7831 (search-forward "\n\n" nil t)
7834 gnus-newsgroup-bookmarks)
7835 (gnus-message 6 "A bookmark has been added to the current article."))
7837 (defun gnus-summary-remove-bookmark (article)
7838 "Remove the bookmark from the current article."
7839 (interactive (list (gnus-summary-article-number)))
7840 ;; Remove old bookmark, if one exists.
7841 (let ((old (assq article gnus-newsgroup-bookmarks)))
7844 (setq gnus-newsgroup-bookmarks
7845 (delq old gnus-newsgroup-bookmarks))
7846 (gnus-message 6 "Removed bookmark."))
7847 (gnus-message 6 "No bookmark in current article."))))
7849 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7850 (defun gnus-summary-mark-as-dormant (n)
7851 "Mark N articles forward as dormant.
7852 If N is negative, mark backward instead. The difference between N and
7853 the actual number of articles marked is returned."
7855 (gnus-summary-mark-forward n gnus-dormant-mark))
7857 (defun gnus-summary-set-process-mark (article)
7858 "Set the process mark on ARTICLE and update the summary line."
7859 (setq gnus-newsgroup-processable
7861 (delq article gnus-newsgroup-processable)))
7862 (when (gnus-summary-goto-subject article)
7863 (gnus-summary-show-thread)
7864 (gnus-summary-goto-subject article)
7865 (gnus-summary-update-secondary-mark article)))
7867 (defun gnus-summary-remove-process-mark (article)
7868 "Remove the process mark from ARTICLE and update the summary line."
7869 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7870 (when (gnus-summary-goto-subject article)
7871 (gnus-summary-show-thread)
7872 (gnus-summary-goto-subject article)
7873 (gnus-summary-update-secondary-mark article)))
7875 (defun gnus-summary-set-saved-mark (article)
7876 "Set the process mark on ARTICLE and update the summary line."
7877 (push article gnus-newsgroup-saved)
7878 (when (gnus-summary-goto-subject article)
7879 (gnus-summary-update-secondary-mark article)))
7881 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7882 "Mark N articles as read forwards.
7883 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7884 The difference between N and the actual number of articles marked is
7887 (gnus-summary-show-thread)
7888 (let ((backward (< n 0))
7889 (gnus-summary-goto-unread
7890 (and gnus-summary-goto-unread
7891 (not (eq gnus-summary-goto-unread 'never))
7892 (not (memq mark (list gnus-unread-mark
7893 gnus-ticked-mark gnus-dormant-mark)))))
7895 (mark (or mark gnus-del-mark)))
7897 (gnus-summary-mark-article nil mark no-expire)
7898 (zerop (gnus-summary-next-subject
7900 (and gnus-summary-goto-unread
7901 (not (eq gnus-summary-goto-unread 'never)))
7905 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7906 (gnus-summary-recenter)
7907 (gnus-summary-position-point)
7908 (gnus-set-mode-line 'summary)
7911 (defun gnus-summary-mark-article-as-read (mark)
7912 "Mark the current article quickly as read with MARK."
7913 (let ((article (gnus-summary-article-number)))
7914 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7915 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7916 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7917 (push (cons article mark) gnus-newsgroup-reads)
7918 ;; Possibly remove from cache, if that is used.
7919 (when gnus-use-cache
7920 (gnus-cache-enter-remove-article article))
7921 ;; Allow the backend to change the mark.
7922 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7923 ;; Check for auto-expiry.
7924 (when (and gnus-newsgroup-auto-expire
7925 (memq mark gnus-auto-expirable-marks))
7926 (setq mark gnus-expirable-mark)
7927 ;; Let the backend know about the mark change.
7928 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7929 (push article gnus-newsgroup-expirable))
7930 ;; Set the mark in the buffer.
7931 (gnus-summary-update-mark mark 'unread)
7934 (defun gnus-summary-mark-article-as-unread (mark)
7935 "Mark the current article quickly as unread with MARK."
7936 (let* ((article (gnus-summary-article-number))
7937 (old-mark (gnus-summary-article-mark article)))
7938 ;; Allow the backend to change the mark.
7939 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7940 (if (eq mark old-mark)
7944 (gnus-error 1 "Can't mark negative article numbers")
7946 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7947 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7948 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7949 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7950 (cond ((= mark gnus-ticked-mark)
7951 (push article gnus-newsgroup-marked))
7952 ((= mark gnus-dormant-mark)
7953 (push article gnus-newsgroup-dormant))
7955 (push article gnus-newsgroup-unreads)))
7956 (gnus-pull article gnus-newsgroup-reads)
7958 ;; See whether the article is to be put in the cache.
7960 (vectorp (gnus-summary-article-header article))
7962 (gnus-cache-possibly-enter-article
7963 gnus-newsgroup-name article
7964 (gnus-summary-article-header article)
7965 (= mark gnus-ticked-mark)
7966 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7969 (gnus-summary-update-mark mark 'unread)
7972 (defun gnus-summary-mark-article (&optional article mark no-expire)
7973 "Mark ARTICLE with MARK. MARK can be any character.
7974 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7975 `??' (dormant) and `?E' (expirable).
7976 If MARK is nil, then the default character `?r' is used.
7977 If ARTICLE is nil, then the article on the current line will be
7979 ;; The mark might be a string.
7980 (when (stringp mark)
7981 (setq mark (aref mark 0)))
7982 ;; If no mark is given, then we check auto-expiring.
7984 (setq mark gnus-del-mark))
7985 (when (and (not no-expire)
7986 gnus-newsgroup-auto-expire
7987 (memq mark gnus-auto-expirable-marks))
7988 (setq mark gnus-expirable-mark))
7989 (let ((article (or article (gnus-summary-article-number)))
7990 (old-mark (gnus-summary-article-mark article)))
7991 ;; Allow the backend to change the mark.
7992 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7993 (if (eq mark old-mark)
7996 (error "No article on current line"))
7997 (if (not (if (or (= mark gnus-unread-mark)
7998 (= mark gnus-ticked-mark)
7999 (= mark gnus-dormant-mark))
8000 (gnus-mark-article-as-unread article mark)
8001 (gnus-mark-article-as-read article mark)))
8003 ;; See whether the article is to be put in the cache.
8005 (not (= mark gnus-canceled-mark))
8006 (vectorp (gnus-summary-article-header article))
8008 (gnus-cache-possibly-enter-article
8009 gnus-newsgroup-name article
8010 (gnus-summary-article-header article)
8011 (= mark gnus-ticked-mark)
8012 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8014 (when (gnus-summary-goto-subject article nil t)
8015 (let ((buffer-read-only nil))
8016 (gnus-summary-show-thread)
8018 (gnus-summary-update-mark mark 'unread)
8021 (defun gnus-summary-update-secondary-mark (article)
8022 "Update the secondary (read, process, cache) mark."
8023 (gnus-summary-update-mark
8024 (cond ((memq article gnus-newsgroup-processable)
8026 ((memq article gnus-newsgroup-cached)
8028 ((memq article gnus-newsgroup-replied)
8030 ((memq article gnus-newsgroup-saved)
8032 (t gnus-unread-mark))
8034 (when (gnus-visual-p 'summary-highlight 'highlight)
8035 (gnus-run-hooks 'gnus-summary-update-hook))
8038 (defun gnus-summary-update-mark (mark type)
8039 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8040 (buffer-read-only nil))
8041 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8043 (when (looking-at "\r")
8045 (when (<= (+ forward (point)) (point-max))
8046 ;; Go to the right position on the line.
8047 (goto-char (+ forward (point)))
8048 ;; Replace the old mark with the new mark.
8049 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8050 ;; Optionally update the marks by some user rule.
8051 (when (eq type 'unread)
8053 (gnus-data-find (gnus-summary-article-number)) mark)
8054 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8056 (defun gnus-mark-article-as-read (article &optional mark)
8057 "Enter ARTICLE in the pertinent lists and remove it from others."
8058 ;; Make the article expirable.
8059 (let ((mark (or mark gnus-del-mark)))
8060 (if (= mark gnus-expirable-mark)
8061 (push article gnus-newsgroup-expirable)
8062 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8063 ;; Remove from unread and marked lists.
8064 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8065 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8066 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8067 (push (cons article mark) gnus-newsgroup-reads)
8068 ;; Possibly remove from cache, if that is used.
8069 (when gnus-use-cache
8070 (gnus-cache-enter-remove-article article))
8073 (defun gnus-mark-article-as-unread (article &optional mark)
8074 "Enter ARTICLE in the pertinent lists and remove it from others."
8075 (let ((mark (or mark gnus-ticked-mark)))
8078 (gnus-error 1 "Can't mark negative article numbers")
8080 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8081 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8082 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8083 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8085 ;; Unsuppress duplicates?
8086 (when gnus-suppress-duplicates
8087 (gnus-dup-unsuppress-article article))
8089 (cond ((= mark gnus-ticked-mark)
8090 (push article gnus-newsgroup-marked))
8091 ((= mark gnus-dormant-mark)
8092 (push article gnus-newsgroup-dormant))
8094 (push article gnus-newsgroup-unreads)))
8095 (gnus-pull article gnus-newsgroup-reads)
8098 (defalias 'gnus-summary-mark-as-unread-forward
8099 'gnus-summary-tick-article-forward)
8100 (make-obsolete 'gnus-summary-mark-as-unread-forward
8101 'gnus-summary-tick-article-forward)
8102 (defun gnus-summary-tick-article-forward (n)
8103 "Tick N articles forwards.
8104 If N is negative, tick backwards instead.
8105 The difference between N and the number of articles ticked is returned."
8107 (gnus-summary-mark-forward n gnus-ticked-mark))
8109 (defalias 'gnus-summary-mark-as-unread-backward
8110 'gnus-summary-tick-article-backward)
8111 (make-obsolete 'gnus-summary-mark-as-unread-backward
8112 'gnus-summary-tick-article-backward)
8113 (defun gnus-summary-tick-article-backward (n)
8114 "Tick N articles backwards.
8115 The difference between N and the number of articles ticked is returned."
8117 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8119 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8120 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8121 (defun gnus-summary-tick-article (&optional article clear-mark)
8122 "Mark current article as unread.
8123 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8124 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8126 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8129 (defun gnus-summary-mark-as-read-forward (n)
8130 "Mark N articles as read forwards.
8131 If N is negative, mark backwards instead.
8132 The difference between N and the actual number of articles marked is
8135 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8137 (defun gnus-summary-mark-as-read-backward (n)
8138 "Mark the N articles as read backwards.
8139 The difference between N and the actual number of articles marked is
8142 (gnus-summary-mark-forward
8143 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8145 (defun gnus-summary-mark-as-read (&optional article mark)
8146 "Mark current article as read.
8147 ARTICLE specifies the article to be marked as read.
8148 MARK specifies a string to be inserted at the beginning of the line."
8149 (gnus-summary-mark-article article mark))
8151 (defun gnus-summary-clear-mark-forward (n)
8152 "Clear marks from N articles forward.
8153 If N is negative, clear backward instead.
8154 The difference between N and the number of marks cleared is returned."
8156 (gnus-summary-mark-forward n gnus-unread-mark))
8158 (defun gnus-summary-clear-mark-backward (n)
8159 "Clear marks from N articles backward.
8160 The difference between N and the number of marks cleared is returned."
8162 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8164 (defun gnus-summary-mark-unread-as-read ()
8165 "Intended to be used by `gnus-summary-mark-article-hook'."
8166 (when (memq gnus-current-article gnus-newsgroup-unreads)
8167 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8169 (defun gnus-summary-mark-read-and-unread-as-read ()
8170 "Intended to be used by `gnus-summary-mark-article-hook'."
8171 (let ((mark (gnus-summary-article-mark)))
8172 (when (or (gnus-unread-mark-p mark)
8173 (gnus-read-mark-p mark))
8174 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8176 (defun gnus-summary-mark-region-as-read (point mark all)
8177 "Mark all unread articles between point and mark as read.
8178 If given a prefix, mark all articles between point and mark as read,
8179 even ticked and dormant ones."
8180 (interactive "r\nP")
8189 (memq (setq article (gnus-summary-article-number))
8190 gnus-newsgroup-unreads))
8191 (gnus-summary-mark-article article gnus-del-mark))
8193 (gnus-summary-find-next))))))
8195 (defun gnus-summary-mark-below (score mark)
8196 "Mark articles with score less than SCORE with MARK."
8197 (interactive "P\ncMark: ")
8198 (setq score (if score
8199 (prefix-numeric-value score)
8200 (or gnus-summary-default-score 0)))
8202 (set-buffer gnus-summary-buffer)
8203 (goto-char (point-min))
8206 (and (< (gnus-summary-article-score) score)
8207 (gnus-summary-mark-article nil mark))
8208 (gnus-summary-find-next)))))
8210 (defun gnus-summary-kill-below (&optional score)
8211 "Mark articles with score below SCORE as read."
8213 (gnus-summary-mark-below score gnus-killed-mark))
8215 (defun gnus-summary-clear-above (&optional score)
8216 "Clear all marks from articles with score above SCORE."
8218 (gnus-summary-mark-above score gnus-unread-mark))
8220 (defun gnus-summary-tick-above (&optional score)
8221 "Tick all articles with score above SCORE."
8223 (gnus-summary-mark-above score gnus-ticked-mark))
8225 (defun gnus-summary-mark-above (score mark)
8226 "Mark articles with score over SCORE with MARK."
8227 (interactive "P\ncMark: ")
8228 (setq score (if score
8229 (prefix-numeric-value score)
8230 (or gnus-summary-default-score 0)))
8232 (set-buffer gnus-summary-buffer)
8233 (goto-char (point-min))
8235 (when (> (gnus-summary-article-score) score)
8236 (gnus-summary-mark-article nil mark))
8238 (gnus-summary-find-next)))))
8240 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8241 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8242 (defun gnus-summary-limit-include-expunged (&optional no-error)
8243 "Display all the hidden articles that were expunged for low scores."
8245 (let ((buffer-read-only nil))
8246 (let ((scored gnus-newsgroup-scored)
8249 (unless (gnus-summary-goto-subject (caar scored))
8250 (and (setq h (gnus-summary-article-header (caar scored)))
8251 (< (cdar scored) gnus-summary-expunge-below)
8253 (setq scored (cdr scored)))
8255 (when (not no-error)
8256 (error "No expunged articles hidden"))
8257 (goto-char (point-min))
8258 (gnus-summary-prepare-unthreaded (nreverse headers))
8259 (goto-char (point-min))
8260 (gnus-summary-position-point)
8263 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8264 "Mark all unread articles in this newsgroup as read.
8265 If prefix argument ALL is non-nil, ticked and dormant articles will
8266 also be marked as read.
8267 If QUIETLY is non-nil, no questions will be asked.
8268 If TO-HERE is non-nil, it should be a point in the buffer. All
8269 articles before this point will be marked as read.
8270 Note that this function will only catch up the unread article
8271 in the current summary buffer limitation.
8272 The number of articles marked as read is returned."
8277 (not gnus-interactive-catchup) ;Without confirmation?
8281 "Mark absolutely all articles as read? "
8282 "Mark all unread articles as read? ")))
8284 (not gnus-newsgroup-adaptive)
8285 (not gnus-newsgroup-auto-expire)
8286 (not gnus-suppress-duplicates)
8287 (or (not gnus-use-cache)
8288 (eq gnus-use-cache 'passive)))
8291 (setq gnus-newsgroup-marked nil
8292 gnus-newsgroup-dormant nil))
8293 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8294 ;; We actually mark all articles as canceled, which we
8295 ;; have to do when using auto-expiry or adaptive scoring.
8296 (gnus-summary-show-all-threads)
8297 (when (gnus-summary-first-subject (not all) t)
8299 (if to-here (< (point) to-here) t)
8300 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8301 (gnus-summary-find-next (not all) nil nil t))))
8302 (gnus-set-mode-line 'summary))
8304 (gnus-summary-position-point)))
8306 (defun gnus-summary-catchup-to-here (&optional all)
8307 "Mark all unticked articles before the current one as read.
8308 If ALL is non-nil, also mark ticked and dormant articles as read."
8311 (gnus-save-hidden-threads
8312 (let ((beg (point)))
8313 ;; We check that there are unread articles.
8314 (when (or all (gnus-summary-find-prev))
8315 (gnus-summary-catchup all t beg)))))
8316 (gnus-summary-position-point))
8318 (defun gnus-summary-catchup-all (&optional quietly)
8319 "Mark all articles in this newsgroup as read."
8321 (gnus-summary-catchup t quietly))
8323 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8324 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8325 If prefix argument ALL is non-nil, all articles are marked as read."
8327 (when (gnus-summary-catchup all quietly nil 'fast)
8328 ;; Select next newsgroup or exit.
8329 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8330 (eq gnus-auto-select-next 'quietly))
8331 (gnus-summary-next-group nil)
8332 (gnus-summary-exit))))
8334 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8335 "Mark all articles in this newsgroup as read, and then exit."
8337 (gnus-summary-catchup-and-exit t quietly))
8339 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8340 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8341 "Mark all articles in this group as read and select the next group.
8342 If given a prefix, mark all articles, unread as well as ticked, as
8346 (gnus-summary-catchup all))
8347 (gnus-summary-next-article t nil nil t))
8349 ;; Thread-based commands.
8351 (defun gnus-summary-articles-in-thread (&optional article)
8352 "Return a list of all articles in the current thread.
8353 If ARTICLE is non-nil, return all articles in the thread that starts
8355 (let* ((article (or article (gnus-summary-article-number)))
8356 (data (gnus-data-find-list article))
8357 (top-level (gnus-data-level (car data)))
8359 (cond ((null gnus-thread-operation-ignore-subject)
8360 (gnus-simplify-subject-re
8361 (mail-header-subject (gnus-data-header (car data)))))
8362 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8363 (gnus-simplify-subject-fuzzy
8364 (mail-header-subject (gnus-data-header (car data)))))
8366 (end-point (save-excursion
8367 (if (gnus-summary-go-to-next-thread)
8368 (point) (point-max))))
8371 (< (gnus-data-pos (car data)) end-point))
8372 (when (or (not top-subject)
8373 (string= top-subject
8374 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8375 (gnus-simplify-subject-fuzzy
8376 (mail-header-subject
8377 (gnus-data-header (car data))))
8378 (gnus-simplify-subject-re
8379 (mail-header-subject
8380 (gnus-data-header (car data)))))))
8381 (push (gnus-data-number (car data)) articles))
8382 (unless (and (setq data (cdr data))
8383 (> (gnus-data-level (car data)) top-level))
8385 ;; Return the list of articles.
8386 (nreverse articles)))
8388 (defun gnus-summary-rethread-current ()
8389 "Rethread the thread the current article is part of."
8391 (let* ((gnus-show-threads t)
8392 (article (gnus-summary-article-number))
8393 (id (mail-header-id (gnus-summary-article-header)))
8394 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8396 (error "No article on the current line"))
8397 (gnus-rebuild-thread id)
8398 (gnus-summary-goto-subject article)))
8400 (defun gnus-summary-reparent-thread ()
8401 "Make the current article child of the marked (or previous) article.
8403 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8404 is non-nil or the Subject: of both articles are the same."
8406 (unless (not (gnus-group-read-only-p))
8407 (error "The current newsgroup does not support article editing"))
8408 (unless (<= (length gnus-newsgroup-processable) 1)
8409 (error "No more than one article may be marked"))
8410 (save-window-excursion
8411 (let ((gnus-article-buffer " *reparent*")
8412 (current-article (gnus-summary-article-number))
8413 ;; First grab the marked article, otherwise one line up.
8414 (parent-article (if (not (null gnus-newsgroup-processable))
8415 (car gnus-newsgroup-processable)
8417 (if (eq (forward-line -1) 0)
8418 (gnus-summary-article-number)
8419 (error "Beginning of summary buffer"))))))
8420 (unless (not (eq current-article parent-article))
8421 (error "An article may not be self-referential"))
8422 (let ((message-id (mail-header-id
8423 (gnus-summary-article-header parent-article))))
8424 (unless (and message-id (not (equal message-id "")))
8425 (error "No message-id in desired parent"))
8426 (gnus-with-article current-article
8427 (goto-char (point-min))
8428 (if (re-search-forward "^References: " nil t)
8430 (re-search-forward "^[^ \t]" nil t)
8433 (insert " " message-id))
8434 (insert "References: " message-id "\n")))
8435 (set-buffer gnus-summary-buffer)
8436 (gnus-summary-unmark-all-processable)
8437 (gnus-summary-update-article current-article)
8438 (gnus-summary-rethread-current)
8439 (gnus-message 3 "Article %d is now the child of article %d"
8440 current-article parent-article)))))
8442 (defun gnus-summary-toggle-threads (&optional arg)
8443 "Toggle showing conversation threads.
8444 If ARG is positive number, turn showing conversation threads on."
8446 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8447 (setq gnus-show-threads
8448 (if (null arg) (not gnus-show-threads)
8449 (> (prefix-numeric-value arg) 0)))
8450 (gnus-summary-prepare)
8451 (gnus-summary-goto-subject current)
8452 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8453 (gnus-summary-position-point)))
8455 (defun gnus-summary-show-all-threads ()
8459 (let ((buffer-read-only nil))
8460 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8461 (gnus-summary-position-point))
8463 (defun gnus-summary-show-thread ()
8464 "Show thread subtrees.
8465 Returns nil if no thread was there to be shown."
8467 (let ((buffer-read-only nil)
8469 ;; first goto end then to beg, to have point at beg after let
8470 (end (progn (end-of-line) (point)))
8471 (beg (progn (beginning-of-line) (point))))
8473 ;; Any hidden lines here?
8474 (search-forward "\r" end t)
8475 (subst-char-in-region beg end ?\^M ?\n t)
8477 (gnus-summary-position-point))))
8479 (defun gnus-summary-hide-all-threads ()
8480 "Hide all thread subtrees."
8483 (goto-char (point-min))
8484 (gnus-summary-hide-thread)
8485 (while (zerop (gnus-summary-next-thread 1 t))
8486 (gnus-summary-hide-thread)))
8487 (gnus-summary-position-point))
8489 (defun gnus-summary-hide-thread ()
8490 "Hide thread subtrees.
8491 Returns nil if no threads were there to be hidden."
8493 (let ((buffer-read-only nil)
8495 (article (gnus-summary-article-number)))
8497 ;; Go forward until either the buffer ends or the subthread
8499 (when (and (not (eobp))
8500 (or (zerop (gnus-summary-next-thread 1 t))
8501 (goto-char (point-max))))
8503 (if (and (> (point) start)
8504 (search-backward "\n" start t))
8506 (subst-char-in-region start (point) ?\n ?\^M)
8507 (gnus-summary-goto-subject article))
8510 ;;(gnus-summary-position-point)
8513 (defun gnus-summary-go-to-next-thread (&optional previous)
8514 "Go to the same level (or less) next thread.
8515 If PREVIOUS is non-nil, go to previous thread instead.
8516 Return the article number moved to, or nil if moving was impossible."
8517 (let ((level (gnus-summary-thread-level))
8518 (way (if previous -1 1))
8521 (while (and (not (eobp))
8522 (< level (gnus-summary-thread-level)))
8530 (gnus-summary-article-number)
8533 (defun gnus-summary-next-thread (n &optional silent)
8534 "Go to the same level next N'th thread.
8535 If N is negative, search backward instead.
8536 Returns the difference between N and the number of skips actually
8539 If SILENT, don't output messages."
8541 (let ((backward (< n 0))
8544 (gnus-summary-go-to-next-thread backward))
8547 (gnus-summary-position-point))
8548 (when (and (not silent) (/= 0 n))
8549 (gnus-message 7 "No more threads"))
8552 (defun gnus-summary-prev-thread (n)
8553 "Go to the same level previous N'th thread.
8554 Returns the difference between N and the number of skips actually
8557 (gnus-summary-next-thread (- n)))
8559 (defun gnus-summary-go-down-thread ()
8560 "Go down one level in the current thread."
8561 (let ((children (gnus-summary-article-children)))
8563 (gnus-summary-goto-subject (car children)))))
8565 (defun gnus-summary-go-up-thread ()
8566 "Go up one level in the current thread."
8567 (let ((parent (gnus-summary-article-parent)))
8569 (gnus-summary-goto-subject parent))))
8571 (defun gnus-summary-down-thread (n)
8572 "Go down thread N steps.
8573 If N is negative, go up instead.
8574 Returns the difference between N and how many steps down that were
8580 (if up (gnus-summary-go-up-thread)
8581 (gnus-summary-go-down-thread)))
8583 (gnus-summary-position-point)
8585 (gnus-message 7 "Can't go further"))
8588 (defun gnus-summary-up-thread (n)
8589 "Go up thread N steps.
8590 If N is negative, go up instead.
8591 Returns the difference between N and how many steps down that were
8594 (gnus-summary-down-thread (- n)))
8596 (defun gnus-summary-top-thread ()
8597 "Go to the top of the thread."
8599 (while (gnus-summary-go-up-thread))
8600 (gnus-summary-article-number))
8602 (defun gnus-summary-kill-thread (&optional unmark)
8603 "Mark articles under current thread as read.
8604 If the prefix argument is positive, remove any kinds of marks.
8605 If the prefix argument is negative, tick articles instead."
8608 (setq unmark (prefix-numeric-value unmark)))
8609 (let ((articles (gnus-summary-articles-in-thread)))
8611 ;; Expand the thread.
8612 (gnus-summary-show-thread)
8613 ;; Mark all the articles.
8615 (gnus-summary-goto-subject (car articles))
8616 (cond ((null unmark)
8617 (gnus-summary-mark-article-as-read gnus-killed-mark))
8619 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8621 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8622 (setq articles (cdr articles))))
8623 ;; Hide killed subtrees.
8625 gnus-thread-hide-killed
8626 (gnus-summary-hide-thread))
8627 ;; If marked as read, go to next unread subject.
8629 ;; Go to next unread subject.
8630 (gnus-summary-next-subject 1 t)))
8631 (gnus-set-mode-line 'summary))
8633 ;; Summary sorting commands
8635 (defun gnus-summary-sort-by-number (&optional reverse)
8636 "Sort the summary buffer by article number.
8637 Argument REVERSE means reverse order."
8639 (gnus-summary-sort 'number reverse))
8641 (defun gnus-summary-sort-by-author (&optional reverse)
8642 "Sort the summary buffer by author name alphabetically.
8643 If case-fold-search is non-nil, case of letters is ignored.
8644 Argument REVERSE means reverse order."
8646 (gnus-summary-sort 'author reverse))
8648 (defun gnus-summary-sort-by-subject (&optional reverse)
8649 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8650 If case-fold-search is non-nil, case of letters is ignored.
8651 Argument REVERSE means reverse order."
8653 (gnus-summary-sort 'subject reverse))
8655 (defun gnus-summary-sort-by-date (&optional reverse)
8656 "Sort the summary buffer by date.
8657 Argument REVERSE means reverse order."
8659 (gnus-summary-sort 'date reverse))
8661 (defun gnus-summary-sort-by-score (&optional reverse)
8662 "Sort the summary buffer by score.
8663 Argument REVERSE means reverse order."
8665 (gnus-summary-sort 'score reverse))
8667 (defun gnus-summary-sort-by-lines (&optional reverse)
8668 "Sort the summary buffer by the number of lines.
8669 Argument REVERSE means reverse order."
8671 (gnus-summary-sort 'lines reverse))
8673 (defun gnus-summary-sort-by-chars (&optional reverse)
8674 "Sort the summary buffer by article length.
8675 Argument REVERSE means reverse order."
8677 (gnus-summary-sort 'chars reverse))
8679 (defun gnus-summary-sort (predicate reverse)
8680 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8681 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8682 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8683 (gnus-thread-sort-functions
8688 (gnus-article-sort-functions
8694 (gnus-summary-prepare-hook nil))
8695 ;; We do the sorting by regenerating the threads.
8696 (gnus-summary-prepare)
8697 ;; Hide subthreads if needed.
8698 (when (and gnus-show-threads gnus-thread-hide-subtree)
8699 (gnus-summary-hide-all-threads))))
8701 ;; Summary saving commands.
8703 (defun gnus-summary-save-article (&optional n not-saved)
8704 "Save the current article using the default saver function.
8705 If N is a positive number, save the N next articles.
8706 If N is a negative number, save the N previous articles.
8707 If N is nil and any articles have been marked with the process mark,
8708 save those articles instead.
8709 The variable `gnus-default-article-saver' specifies the saver function."
8711 (let* ((articles (gnus-summary-work-articles n))
8712 (save-buffer (save-excursion
8713 (nnheader-set-temp-buffer " *Gnus Save*")))
8714 (num (length articles))
8716 (dolist (article articles)
8717 (setq header (gnus-summary-article-header article))
8718 (if (not (vectorp header))
8719 ;; This is a pseudo-article.
8720 (if (assq 'name header)
8721 (gnus-copy-file (cdr (assq 'name header)))
8722 (gnus-message 1 "Article %d is unsaveable" article))
8723 ;; This is a real article.
8724 (save-window-excursion
8725 (gnus-summary-select-article t nil nil article))
8727 (set-buffer save-buffer)
8729 (insert-buffer-substring gnus-original-article-buffer))
8730 (setq file (gnus-article-save save-buffer file num))
8731 (gnus-summary-remove-process-mark article)
8733 (gnus-summary-set-saved-mark article))))
8734 (gnus-kill-buffer save-buffer)
8735 (gnus-summary-position-point)
8736 (gnus-set-mode-line 'summary)
8739 (defun gnus-summary-pipe-output (&optional arg)
8740 "Pipe the current article to a subprocess.
8741 If N is a positive number, pipe the N next articles.
8742 If N is a negative number, pipe the N previous articles.
8743 If N is nil and any articles have been marked with the process mark,
8744 pipe those articles instead."
8746 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8747 (gnus-summary-save-article arg t))
8748 (gnus-configure-windows 'pipe))
8750 (defun gnus-summary-save-article-mail (&optional arg)
8751 "Append the current article to an mail file.
8752 If N is a positive number, save the N next articles.
8753 If N is a negative number, save the N previous articles.
8754 If N is nil and any articles have been marked with the process mark,
8755 save those articles instead."
8757 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8758 (gnus-summary-save-article arg)))
8760 (defun gnus-summary-save-article-rmail (&optional arg)
8761 "Append the current article to an rmail file.
8762 If N is a positive number, save the N next articles.
8763 If N is a negative number, save the N previous articles.
8764 If N is nil and any articles have been marked with the process mark,
8765 save those articles instead."
8767 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8768 (gnus-summary-save-article arg)))
8770 (defun gnus-summary-save-article-file (&optional arg)
8771 "Append the current article to a file.
8772 If N is a positive number, save the N next articles.
8773 If N is a negative number, save the N previous articles.
8774 If N is nil and any articles have been marked with the process mark,
8775 save those articles instead."
8777 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8778 (gnus-summary-save-article arg)))
8780 (defun gnus-summary-write-article-file (&optional arg)
8781 "Write the current article to a file, deleting the previous file.
8782 If N is a positive number, save the N next articles.
8783 If N is a negative number, save the N previous articles.
8784 If N is nil and any articles have been marked with the process mark,
8785 save those articles instead."
8787 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8788 (gnus-summary-save-article arg)))
8790 (defun gnus-summary-save-article-body-file (&optional arg)
8791 "Append the current article body to a file.
8792 If N is a positive number, save the N next articles.
8793 If N is a negative number, save the N previous articles.
8794 If N is nil and any articles have been marked with the process mark,
8795 save those articles instead."
8797 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8798 (gnus-summary-save-article arg)))
8800 (defun gnus-summary-pipe-message (program)
8801 "Pipe the current article through PROGRAM."
8802 (interactive "sProgram: ")
8803 (gnus-summary-select-article)
8804 (let ((mail-header-separator ""))
8805 (gnus-eval-in-buffer-window gnus-article-buffer
8808 (let ((start (window-start))
8810 (message-pipe-buffer-body program)
8811 (set-window-start (get-buffer-window (current-buffer)) start))))))
8813 (defun gnus-get-split-value (methods)
8814 "Return a value based on the split METHODS."
8815 (let (split-name method result match)
8818 (set-buffer gnus-original-article-buffer)
8820 (nnheader-narrow-to-headers)
8822 (goto-char (point-min))
8823 (setq method (pop methods))
8824 (setq match (car method))
8827 ;; Regular expression.
8829 (re-search-forward match nil t)))
8830 ((gnus-functionp match)
8834 (setq result (funcall match gnus-newsgroup-name))))
8839 (setq result (eval match)))))
8840 (setq split-name (append (cdr method) split-name))
8841 (cond ((stringp result)
8842 (push (expand-file-name
8843 result gnus-article-save-directory)
8846 (setq split-name (append result split-name)))))))))
8847 (nreverse split-name)))
8849 (defun gnus-valid-move-group-p (group)
8852 (symbol-value group)
8853 (gnus-get-function (gnus-find-method-for-group
8854 (symbol-name group)) 'request-accept-article t)))
8856 (defun gnus-read-move-group-name (prompt default articles prefix)
8857 "Read a group name."
8858 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8859 (minibuffer-confirm-incomplete nil) ; XEmacs
8863 (if (> (length articles) 1)
8864 (format "these %d articles" (length articles))
8869 (gnus-completing-read default prom
8871 'gnus-valid-move-group-p
8873 'gnus-group-history))
8874 ((= 1 (length split-name))
8875 (gnus-completing-read (car split-name) prom
8877 'gnus-valid-move-group-p
8879 'gnus-group-history))
8881 (gnus-completing-read nil prom
8882 (mapcar (lambda (el) (list el))
8883 (nreverse split-name))
8885 'gnus-group-history)))))
8887 (if (or (string= to-newsgroup "")
8888 (string= to-newsgroup prefix))
8889 (setq to-newsgroup default))
8890 (unless to-newsgroup
8891 (error "No group name entered"))
8892 (or (gnus-active to-newsgroup)
8893 (gnus-activate-group to-newsgroup)
8894 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8896 (or (and (gnus-request-create-group
8897 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8898 (gnus-activate-group to-newsgroup nil nil
8899 (gnus-group-name-to-method
8901 (error "Couldn't create group %s" to-newsgroup)))
8902 (error "No such group: %s" to-newsgroup)))
8905 (defun gnus-summary-save-parts (type dir n reverse)
8906 "Save parts matching TYPE to DIR.
8907 If REVERSE, save parts that do not match TYPE."
8909 (list (read-string "Save parts of type: " "image/.*")
8910 (read-file-name "Save to directory: " t nil t)
8911 current-prefix-arg))
8912 (gnus-summary-iterate n
8913 (let ((gnus-display-mime-function nil)
8914 (gnus-inhibit-treatment t))
8915 (gnus-summary-select-article))
8917 (set-buffer gnus-article-buffer)
8918 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
8920 (gnus-summary-save-parts-1 type dir handles reverse)
8921 (mm-destroy-parts handles))))))
8923 (defun gnus-summary-save-parts-1 (type dir handle reverse)
8924 (if (stringp (car handle))
8925 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
8928 (not (string-match type (car (mm-handle-type handle))))
8929 (string-match type (car (mm-handle-type handle))))
8930 (let ((file (expand-file-name
8931 (file-name-nondirectory
8933 (mail-content-type-get
8934 (mm-handle-disposition handle) 'filename)
8935 (concat gnus-newsgroup-name "." gnus-current-article)))
8937 (unless (file-exists-p file)
8938 (mm-save-part-to-file handle file))))))
8940 ;; Summary extract commands
8942 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8943 (let ((buffer-read-only nil)
8944 (article (gnus-summary-article-number))
8946 (unless (gnus-summary-goto-subject article)
8947 (error "No such article: %d" article))
8948 (gnus-summary-position-point)
8949 ;; If all commands are to be bunched up on one line, we collect
8951 (unless gnus-view-pseudos-separately
8952 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8955 (setq action (cdr (assq 'action (car ps))))
8956 (setq files (list (cdr (assq 'name (car ps)))))
8957 (while (and ps (cdr ps)
8958 (string= (or action "1")
8959 (or (cdr (assq 'action (cadr ps))) "2")))
8960 (push (cdr (assq 'name (cadr ps))) files)
8961 (setcdr ps (cddr ps)))
8963 (when (not (string-match "%s" action))
8966 (when (assq 'execute (car ps))
8967 (setcdr (assq 'execute (car ps))
8968 (funcall (if (string-match "%s" action)
8975 (gnus-quote-arg-for-sh-or-csh f)))
8977 (setq ps (cdr ps)))))
8978 (if (and gnus-view-pseudos (not not-view))
8980 (when (assq 'execute (car pslist))
8981 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8982 (eq gnus-view-pseudos 'not-confirm)))
8983 (setq pslist (cdr pslist)))
8986 (setq after-article (or (cdr (assq 'article (car pslist)))
8987 (gnus-summary-article-number)))
8988 (gnus-summary-goto-subject after-article)
8991 (insert " " (file-name-nondirectory
8992 (cdr (assq 'name (car pslist))))
8993 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8995 (forward-line -1) ; back to `b'
8996 (gnus-add-text-properties
8997 b (1- e) (list 'gnus-number gnus-reffed-article-number
8998 gnus-mouse-face-prop gnus-mouse-face))
9000 after-article gnus-reffed-article-number
9001 gnus-unread-mark b (car pslist) 0 (- e b))
9002 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9003 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9004 (setq pslist (cdr pslist)))))))
9006 (defun gnus-pseudos< (p1 p2)
9007 (let ((c1 (cdr (assq 'action p1)))
9008 (c2 (cdr (assq 'action p2))))
9009 (and c1 c2 (string< c1 c2))))
9011 (defun gnus-request-pseudo-article (props)
9012 (cond ((assq 'execute props)
9013 (gnus-execute-command (cdr (assq 'execute props)))))
9014 (let ((gnus-current-article (gnus-summary-article-number)))
9015 (gnus-run-hooks 'gnus-mark-article-hook)))
9017 (defun gnus-execute-command (command &optional automatic)
9019 (gnus-article-setup-buffer)
9020 (set-buffer gnus-article-buffer)
9021 (setq buffer-read-only nil)
9022 (let ((command (if automatic command
9023 (read-string "Command: " (cons command 0)))))
9025 (insert "$ " command "\n\n")
9026 (if gnus-view-pseudo-asynchronously
9027 (start-process "gnus-execute" (current-buffer) shell-file-name
9028 shell-command-switch command)
9029 (call-process shell-file-name nil t nil
9030 shell-command-switch command)))))
9032 ;; Summary kill commands.
9034 (defun gnus-summary-edit-global-kill (article)
9035 "Edit the \"global\" kill file."
9036 (interactive (list (gnus-summary-article-number)))
9037 (gnus-group-edit-global-kill article))
9039 (defun gnus-summary-edit-local-kill ()
9040 "Edit a local kill file applied to the current newsgroup."
9042 (setq gnus-current-headers (gnus-summary-article-header))
9043 (gnus-group-edit-local-kill
9044 (gnus-summary-article-number) gnus-newsgroup-name))
9048 (defun gnus-read-header (id &optional header)
9049 "Read the headers of article ID and enter them into the Gnus system."
9050 (let ((group gnus-newsgroup-name)
9051 (gnus-override-method
9052 (and (gnus-news-group-p gnus-newsgroup-name)
9053 gnus-refer-article-method))
9055 ;; First we check to see whether the header in question is already
9058 ;; This is a Message-ID.
9059 (setq header (or header (gnus-id-to-header id)))
9060 ;; This is an article number.
9061 (setq header (or header (gnus-summary-article-header id))))
9063 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9064 ;; We have found the header.
9066 ;; If this is a sparse article, we have to nix out its
9067 ;; previous entry in the thread hashtb.
9069 (gnus-summary-article-sparse-p (mail-header-number header)))
9070 (let* ((parent (gnus-parent-id (mail-header-references header)))
9071 (thread (and parent (gnus-id-to-thread parent))))
9073 (delq (assq header thread) thread))))
9074 ;; We have to really fetch the header to this article.
9076 (set-buffer nntp-server-buffer)
9077 (when (setq where (gnus-request-head id group))
9078 (nnheader-fold-continuation-lines)
9079 (goto-char (point-max))
9081 (goto-char (point-min))
9085 ((cdr where) (cdr where))
9086 (header (mail-header-number header))
9087 (t gnus-reffed-article-number))
9089 (insert " Article retrieved.\n"))
9091 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9092 () ; Malformed head.
9093 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9094 (when (and (stringp id)
9095 (not (string= (gnus-group-real-name group)
9097 ;; If we fetched by Message-ID and the article came
9098 ;; from a different group, we fudge some bogus article
9099 ;; numbers for this article.
9100 (mail-header-set-number header gnus-reffed-article-number))
9102 (set-buffer gnus-summary-buffer)
9103 (decf gnus-reffed-article-number)
9104 (gnus-remove-header (mail-header-number header))
9105 (push header gnus-newsgroup-headers)
9106 (setq gnus-current-headers header)
9107 (push (mail-header-number header) gnus-newsgroup-limit)))
9110 (defun gnus-remove-header (number)
9111 "Remove header NUMBER from `gnus-newsgroup-headers'."
9112 (if (and gnus-newsgroup-headers
9113 (= number (mail-header-number (car gnus-newsgroup-headers))))
9114 (pop gnus-newsgroup-headers)
9115 (let ((headers gnus-newsgroup-headers))
9116 (while (and (cdr headers)
9117 (not (= number (mail-header-number (cadr headers)))))
9120 (setcdr headers (cddr headers))))))
9123 ;;; summary highlights
9126 (defun gnus-highlight-selected-summary ()
9127 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9128 ;; Highlight selected article in summary buffer
9129 (when gnus-summary-selected-face
9131 (let* ((beg (progn (beginning-of-line) (point)))
9132 (end (progn (end-of-line) (point)))
9133 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9134 (from (if (get-text-property beg gnus-mouse-face-prop)
9136 (or (next-single-property-change
9137 beg gnus-mouse-face-prop nil end)
9142 (or (next-single-property-change
9143 from gnus-mouse-face-prop nil end)
9145 ;; If no mouse-face prop on line we will have to = from = end,
9146 ;; so we highlight the entire line instead.
9147 (when (= (+ to 2) from)
9150 (if gnus-newsgroup-selected-overlay
9151 ;; Move old overlay.
9153 gnus-newsgroup-selected-overlay from to (current-buffer))
9154 ;; Create new overlay.
9156 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9157 'face gnus-summary-selected-face))))))
9159 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9160 (defun gnus-summary-highlight-line ()
9161 "Highlight current line according to `gnus-summary-highlight'."
9162 (let* ((list gnus-summary-highlight)
9164 (end (progn (end-of-line) (point)))
9165 ;; now find out where the line starts and leave point there.
9166 (beg (progn (beginning-of-line) (point)))
9167 (article (gnus-summary-article-number))
9168 (score (or (cdr (assq (or article gnus-current-article)
9169 gnus-newsgroup-scored))
9170 gnus-summary-default-score 0))
9171 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9172 (inhibit-read-only t))
9173 ;; Eval the cars of the lists until we find a match.
9174 (let ((default gnus-summary-default-score))
9176 (not (eval (caar list))))
9177 (setq list (cdr list))))
9178 (let ((face (cdar list)))
9179 (unless (eq face (get-text-property beg 'face))
9180 (gnus-put-text-property-excluding-characters-with-faces
9182 (setq face (if (boundp face) (symbol-value face) face)))
9183 (when gnus-summary-highlight-line-function
9184 (funcall gnus-summary-highlight-line-function article face))))
9187 (defun gnus-update-read-articles (group unread &optional compute)
9188 "Update the list of read articles in GROUP."
9189 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9190 (entry (gnus-gethash group gnus-newsrc-hashtb))
9191 (info (nth 2 entry))
9193 (unread (sort (copy-sequence unread) '<))
9195 (if (or (not info) (not active))
9196 ;; There is no info on this group if it was, in fact,
9197 ;; killed. Gnus stores no information on killed groups, so
9198 ;; there's nothing to be done.
9199 ;; One could store the information somewhere temporarily,
9200 ;; perhaps... Hmmm...
9202 ;; Remove any negative articles numbers.
9203 (while (and unread (< (car unread) 0))
9204 (setq unread (cdr unread)))
9205 ;; Remove any expired article numbers
9206 (while (and unread (< (car unread) (car active)))
9207 (setq unread (cdr unread)))
9208 ;; Compute the ranges of read articles by looking at the list of
9211 (when (/= (car unread) prev)
9212 (push (if (= prev (1- (car unread))) prev
9213 (cons prev (1- (car unread))))
9215 (setq prev (1+ (car unread)))
9216 (setq unread (cdr unread)))
9217 (when (<= prev (cdr active))
9218 (push (cons prev (cdr active)) read))
9219 (setq read (if (> (length read) 1) (nreverse read) read))
9223 (set-buffer gnus-group-buffer)
9226 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9227 (gnus-info-set-read ',info ',(gnus-info-read info))
9228 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9229 (gnus-group-update-group ,group t))))
9230 ;; Propagate the read marks to the backend.
9231 (if (gnus-check-backend-function 'request-set-mark group)
9232 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9233 (add (gnus-remove-from-range read (gnus-info-read info))))
9235 (unless (gnus-check-group group)
9236 (error "Can't open server for %s" group))
9237 (gnus-request-set-mark
9238 group (delq nil (list (if add (list add 'add '(read)))
9239 (if del (list del 'del '(read)))))))))
9240 ;; Enter this list into the group info.
9241 (gnus-info-set-read info read)
9242 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9243 (gnus-get-unread-articles-in-group info (gnus-active group))
9246 (defun gnus-offer-save-summaries ()
9247 "Offer to save all active summary buffers."
9249 (let ((buflist (buffer-list))
9251 ;; Go through all buffers and find all summaries.
9253 (and (setq bufname (buffer-name (car buflist)))
9254 (string-match "Summary" bufname)
9256 (set-buffer bufname)
9257 ;; We check that this is, indeed, a summary buffer.
9258 (and (eq major-mode 'gnus-summary-mode)
9259 ;; Also make sure this isn't bogus.
9260 gnus-newsgroup-prepared
9261 ;; Also make sure that this isn't a dead summary buffer.
9262 (not gnus-dead-summary-mode)))
9263 (push bufname buffers))
9264 (setq buflist (cdr buflist)))
9265 ;; Go through all these summary buffers and offer to save them.
9268 "Update summary buffer %s? "
9270 (switch-to-buffer buf)
9271 (gnus-summary-exit))
9275 ;;; @ for mime-partial
9278 (defun gnus-request-partial-message ()
9280 (let ((number (gnus-summary-article-number))
9281 (group gnus-newsgroup-name)
9282 (mother gnus-article-buffer))
9283 (set-buffer (get-buffer-create " *Partial Article*"))
9285 (setq mime-preview-buffer mother)
9286 (gnus-request-article-this-buffer number group)
9290 (autoload 'mime-combine-message/partial-pieces-automatically
9292 "Internal method to combine message/partial messages automatically.")
9295 'action '((type . message)(subtype . partial)
9296 (major-mode . gnus-original-article-mode)
9297 (method . mime-combine-message/partial-pieces-automatically)
9298 (summary-buffer-exp . gnus-summary-buffer)
9299 (request-partial-message-method . gnus-request-partial-message)
9303 ;;; @ for message/rfc822
9306 (defun gnus-mime-extract-message/rfc822 (entity situation)
9307 (let (group article num cwin swin cur)
9308 (with-current-buffer (mime-entity-buffer entity)
9310 (narrow-to-region (mime-entity-body-start entity)
9311 (mime-entity-body-end entity))
9312 (setq group (or (cdr (assq 'group situation))
9313 (completing-read "Group: "
9316 (gnus-read-active-file-p)
9317 gnus-newsgroup-name))
9318 article (gnus-request-accept-article group)
9321 (when (and (consp article)
9322 (numberp (setq article (cdr article))))
9323 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9324 cwin (get-buffer-window (current-buffer) t)
9326 (save-window-excursion
9327 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9328 (select-window swin)
9329 (set-buffer gnus-summary-buffer)
9331 (setq cur gnus-current-article)
9333 (let (gnus-show-threads)
9334 (gnus-summary-goto-subject article t)
9336 (gnus-summary-clear-mark-forward 1)
9337 (gnus-summary-goto-subject cur)
9339 (when (and cwin (window-frame cwin))
9340 (select-frame (window-frame cwin))
9342 (when (boundp 'mime-acting-situation-to-override)
9343 (set-alist 'mime-acting-situation-to-override
9346 (set-alist 'mime-acting-situation-to-override
9349 (save-current-buffer
9350 (set-buffer gnus-group-buffer)
9351 (gnus-activate-group ,group)
9353 (gnus-summary-goto-article ,cur
9354 gnus-show-all-headers)
9356 (set-alist 'mime-acting-situation-to-override
9362 'action '((type . message)(subtype . rfc822)
9363 (major-mode . gnus-original-article-mode)
9364 (method . gnus-mime-extract-message/rfc822)
9369 'action '((type . message)(subtype . news)
9370 (major-mode . gnus-original-article-mode)
9371 (method . gnus-mime-extract-message/rfc822)
9375 (defun gnus-mime-extract-multipart (entity situation)
9376 (let ((children (mime-entity-children entity))
9377 mime-acting-situation-to-override
9380 (mime-play-entity (car children)
9381 (cons (assq 'mode situation)
9382 mime-acting-situation-to-override))
9383 (setq children (cdr children)))
9384 (if (setq f (cdr (assq 'after-method
9385 mime-acting-situation-to-override)))
9390 'action '((type . multipart)
9391 (method . gnus-mime-extract-multipart)
9400 (defun gnus-summary-setup-default-charset ()
9401 "Setup newsgroup default charset."
9402 (let ((name (and gnus-newsgroup-name
9403 (gnus-group-real-name gnus-newsgroup-name))))
9404 (setq gnus-newsgroup-charset
9405 (or (and gnus-newsgroup-name
9406 (or (gnus-group-find-parameter gnus-newsgroup-name
9408 (let ((alist gnus-group-charset-alist)
9410 (while (setq elem (pop alist))
9412 (string-match (car elem) name))
9414 charset (cadr elem))))
9416 gnus-default-charset))))
9422 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9423 "Display the current article buffer fully MIME-buttonized.
9424 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9425 treated as multipart/mixed."
9428 (let ((gnus-unbuttonized-mime-types nil)
9429 (gnus-mime-display-multipart-as-mixed show-all-parts))
9430 (gnus-summary-show-article)))
9432 (defun gnus-summary-repair-multipart (article)
9433 "Add a Content-Type header to a multipart article without one."
9434 (interactive (list (gnus-summary-article-number)))
9435 (gnus-with-article article
9436 (message-narrow-to-head)
9437 (goto-char (point-max))
9439 (when (search-forward "\n--" nil t)
9440 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9441 (message-narrow-to-head)
9442 (message-remove-header "Mime-Version")
9443 (message-remove-header "Content-Type")
9444 (goto-char (point-max))
9445 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9447 (insert "Mime-Version: 1.0\n")
9449 (let (gnus-mark-article-hook)
9450 (gnus-summary-select-article t t nil article)))
9452 (defun gnus-summary-toggle-display-buttonized ()
9453 "Toggle the buttonizing of the article buffer."
9456 (if (setq gnus-inhibit-mime-unbuttonizing
9457 (not gnus-inhibit-mime-unbuttonizing))
9458 (let ((gnus-unbuttonized-mime-types nil))
9459 (gnus-summary-show-article))
9460 (gnus-summary-show-article)))
9466 (defmacro gnus-with-article (article &rest forms)
9467 "Select ARTICLE and perform FORMS in the original article buffer.
9468 Then replace the article with the result."
9470 ;; We don't want the article to be marked as read.
9471 (let (gnus-mark-article-hook)
9472 (gnus-summary-select-article t t nil ,article))
9473 (set-buffer gnus-original-article-buffer)
9475 (if (not (gnus-check-backend-function
9476 'request-replace-article (car gnus-article-current)))
9477 (gnus-message 5 "Read-only group; not replacing")
9478 (unless (gnus-request-replace-article
9479 ,article (car gnus-article-current)
9481 (error "Couldn't replace article")))
9482 ;; The cache and backlog have to be flushed somewhat.
9483 (when gnus-keep-backlog
9484 (gnus-backlog-remove-article
9485 (car gnus-article-current) (cdr gnus-article-current)))
9486 (when gnus-use-cache
9487 (gnus-cache-update-article
9488 (car gnus-article-current) (cdr gnus-article-current)))))
9490 (put 'gnus-with-article 'lisp-indent-function 1)
9491 (put 'gnus-with-article 'edebug-form-spec '(form body))
9494 ;;; Generic summary marking commands
9497 (defvar gnus-summary-marking-alist
9498 '((read gnus-del-mark "d")
9499 (unread gnus-unread-mark "u")
9500 (ticked gnus-ticked-mark "!")
9501 (dormant gnus-dormant-mark "?")
9502 (expirable gnus-expirable-mark "e"))
9503 "An alist of names/marks/keystrokes.")
9505 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9506 (defvar gnus-summary-mark-map)
9508 (defun gnus-summary-make-all-marking-commands ()
9509 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9510 (dolist (elem gnus-summary-marking-alist)
9511 (apply 'gnus-summary-make-marking-command elem)))
9513 (defun gnus-summary-make-marking-command (name mark keystroke)
9514 (let ((map (make-sparse-keymap)))
9515 (define-key gnus-summary-generic-mark-map keystroke map)
9516 (dolist (lway `((next "next" next nil "n")
9517 (next-unread "next unread" next t "N")
9518 (prev "previous" prev nil "p")
9519 (prev-unread "previous unread" prev t "P")
9520 (nomove "" nil nil ,keystroke)))
9521 (let ((func (gnus-summary-make-marking-command-1
9522 mark (car lway) lway name)))
9523 (setq func (eval func))
9524 (define-key map (nth 4 lway) func)))))
9526 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9528 (format "gnus-summary-put-mark-as-%s%s"
9529 name (if (eq way 'nomove)
9531 (concat "-" (symbol-name way)))))
9534 "Mark the current article as %s%s.
9535 If N, the prefix, then repeat N times.
9536 If N is negative, move in reverse order.
9537 The difference between N and the actual number of articles marked is
9541 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9543 (defun gnus-summary-generic-mark (n mark move unread)
9544 "Mark N articles with MARK."
9545 (unless (eq major-mode 'gnus-summary-mode)
9546 (error "This command can only be used in the summary buffer"))
9547 (gnus-summary-show-thread)
9551 ((eq move 'prev) -1)
9557 nummove (* -1 nummove))))
9559 (gnus-summary-mark-article nil mark)
9560 (zerop (gnus-summary-next-subject nummove unread t)))
9563 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9564 (gnus-summary-recenter)
9565 (gnus-summary-position-point)
9566 (gnus-set-mode-line 'summary)
9569 (gnus-summary-make-all-marking-commands)
9575 (run-hooks 'gnus-sum-load-hook)
9577 ;;; gnus-sum.el ends here