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-ignored-charsets-alist
849 '(("alt\\.chinese\\.text" iso-8859-1))
850 "Alist of regexps (to match group names) and charsets that should be ignored.
851 When these charsets are used in the \"charset\" parameter, the
852 default charset will be used instead."
853 :type '(repeat (cons (regexp :tag "Group")
855 :group 'gnus-charset)
857 (defcustom gnus-group-highlight-words-alist nil
858 "Alist of group regexps and highlight regexps.
859 This variable uses the same syntax as `gnus-emphasis-alist'."
860 :type '(repeat (cons (regexp :tag "Group")
861 (repeat (list (regexp :tag "Highlight regexp")
862 (number :tag "Group for entire word" 0)
863 (number :tag "Group for displayed part" 0)
865 gnus-emphasis-highlight-words)))))
866 :group 'gnus-summary-visual)
868 ;;; Internal variables
870 (defvar gnus-scores-exclude-files nil)
871 (defvar gnus-page-broken nil)
872 (defvar gnus-inhibit-mime-unbuttonizing nil)
874 (defvar gnus-original-article nil)
875 (defvar gnus-article-internal-prepare-hook nil)
876 (defvar gnus-newsgroup-process-stack nil)
878 (defvar gnus-thread-indent-array nil)
879 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
881 ;; Avoid highlighting in kill files.
882 (defvar gnus-summary-inhibit-highlight nil)
883 (defvar gnus-newsgroup-selected-overlay nil)
884 (defvar gnus-inhibit-limiting nil)
885 (defvar gnus-newsgroup-adaptive-score-file nil)
886 (defvar gnus-current-score-file nil)
887 (defvar gnus-current-move-group nil)
888 (defvar gnus-current-copy-group nil)
889 (defvar gnus-current-crosspost-group nil)
891 (defvar gnus-newsgroup-dependencies nil)
892 (defvar gnus-newsgroup-adaptive nil)
893 (defvar gnus-summary-display-article-function nil)
894 (defvar gnus-summary-highlight-line-function nil
895 "Function called after highlighting a summary line.")
897 (defvar gnus-summary-line-format-alist
898 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
899 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
900 (?s gnus-tmp-subject-or-nil ?s)
901 (?n gnus-tmp-name ?s)
902 (?A (std11-address-string
903 (car (mime-read-field 'From gnus-tmp-header))) ?s)
904 (?a (or (std11-full-name-string
905 (car (mime-read-field 'From gnus-tmp-header)))
907 (?F gnus-tmp-from ?s)
908 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
909 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
910 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
911 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
912 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
913 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
914 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
915 (?L gnus-tmp-lines ?d)
916 (?I gnus-tmp-indentation ?s)
917 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
918 (?R gnus-tmp-replied ?c)
919 (?\[ gnus-tmp-opening-bracket ?c)
920 (?\] gnus-tmp-closing-bracket ?c)
921 (?\> (make-string gnus-tmp-level ? ) ?s)
922 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
923 (?i gnus-tmp-score ?d)
924 (?z gnus-tmp-score-char ?c)
925 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
926 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
927 (?U gnus-tmp-unread ?c)
928 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
929 (?t (gnus-summary-number-of-articles-in-thread
930 (and (boundp 'thread) (car thread)) gnus-tmp-level)
932 (?e (gnus-summary-number-of-articles-in-thread
933 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
935 (?u gnus-tmp-user-defined ?s)
936 (?P (gnus-pick-line-number) ?d))
937 "An alist of format specifications that can appear in summary lines,
938 and what variables they correspond with, along with the type of the
939 variable (string, integer, character, etc).")
941 (defvar gnus-summary-dummy-line-format-alist
942 `((?S gnus-tmp-subject ?s)
943 (?N gnus-tmp-number ?d)
944 (?u gnus-tmp-user-defined ?s)))
946 (defvar gnus-summary-mode-line-format-alist
947 `((?G gnus-tmp-group-name ?s)
948 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
949 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
950 (?A gnus-tmp-article-number ?d)
951 (?Z gnus-tmp-unread-and-unselected ?s)
953 (?U gnus-tmp-unread-and-unticked ?d)
954 (?S gnus-tmp-subject ?s)
955 (?e gnus-tmp-unselected ?d)
956 (?u gnus-tmp-user-defined ?s)
957 (?d (length gnus-newsgroup-dormant) ?d)
958 (?t (length gnus-newsgroup-marked) ?d)
959 (?r (length gnus-newsgroup-reads) ?d)
960 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
961 (?E gnus-newsgroup-expunged-tally ?d)
962 (?s (gnus-current-score-file-nondirectory) ?s)))
964 (defvar gnus-last-search-regexp nil
965 "Default regexp for article search command.")
967 (defvar gnus-last-shell-command nil
968 "Default shell command on article.")
970 (defvar gnus-newsgroup-begin nil)
971 (defvar gnus-newsgroup-end nil)
972 (defvar gnus-newsgroup-last-rmail nil)
973 (defvar gnus-newsgroup-last-mail nil)
974 (defvar gnus-newsgroup-last-folder nil)
975 (defvar gnus-newsgroup-last-file nil)
976 (defvar gnus-newsgroup-auto-expire nil)
977 (defvar gnus-newsgroup-active nil)
979 (defvar gnus-newsgroup-data nil)
980 (defvar gnus-newsgroup-data-reverse nil)
981 (defvar gnus-newsgroup-limit nil)
982 (defvar gnus-newsgroup-limits nil)
984 (defvar gnus-newsgroup-unreads nil
985 "List of unread articles in the current newsgroup.")
987 (defvar gnus-newsgroup-unselected nil
988 "List of unselected unread articles in the current newsgroup.")
990 (defvar gnus-newsgroup-reads nil
991 "Alist of read articles and article marks in the current newsgroup.")
993 (defvar gnus-newsgroup-expunged-tally nil)
995 (defvar gnus-newsgroup-marked nil
996 "List of ticked articles in the current newsgroup (a subset of unread art).")
998 (defvar gnus-newsgroup-killed nil
999 "List of ranges of articles that have been through the scoring process.")
1001 (defvar gnus-newsgroup-cached nil
1002 "List of articles that come from the article cache.")
1004 (defvar gnus-newsgroup-saved nil
1005 "List of articles that have been saved.")
1007 (defvar gnus-newsgroup-kill-headers nil)
1009 (defvar gnus-newsgroup-replied nil
1010 "List of articles that have been replied to in the current newsgroup.")
1012 (defvar gnus-newsgroup-expirable nil
1013 "List of articles in the current newsgroup that can be expired.")
1015 (defvar gnus-newsgroup-processable nil
1016 "List of articles in the current newsgroup that can be processed.")
1018 (defvar gnus-newsgroup-downloadable nil
1019 "List of articles in the current newsgroup that can be processed.")
1021 (defvar gnus-newsgroup-undownloaded nil
1022 "List of articles in the current newsgroup that haven't been downloaded..")
1024 (defvar gnus-newsgroup-unsendable nil
1025 "List of articles in the current newsgroup that won't be sent.")
1027 (defvar gnus-newsgroup-bookmarks nil
1028 "List of articles in the current newsgroup that have bookmarks.")
1030 (defvar gnus-newsgroup-dormant nil
1031 "List of dormant articles in the current newsgroup.")
1033 (defvar gnus-newsgroup-scored nil
1034 "List of scored articles in the current newsgroup.")
1036 (defvar gnus-newsgroup-headers nil
1037 "List of article headers in the current newsgroup.")
1039 (defvar gnus-newsgroup-threads nil)
1041 (defvar gnus-newsgroup-prepared nil
1042 "Whether the current group has been prepared properly.")
1044 (defvar gnus-newsgroup-ancient nil
1045 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1047 (defvar gnus-newsgroup-sparse nil)
1049 (defvar gnus-current-article nil)
1050 (defvar gnus-article-current nil)
1051 (defvar gnus-current-headers nil)
1052 (defvar gnus-have-all-headers nil)
1053 (defvar gnus-last-article nil)
1054 (defvar gnus-newsgroup-history nil)
1055 (defvar gnus-newsgroup-charset nil)
1056 (defvar gnus-newsgroup-ephemeral-charset nil)
1057 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1059 (defconst gnus-summary-local-variables
1060 '(gnus-newsgroup-name
1061 gnus-newsgroup-begin gnus-newsgroup-end
1062 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1063 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1064 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1065 gnus-newsgroup-unselected gnus-newsgroup-marked
1066 gnus-newsgroup-reads gnus-newsgroup-saved
1067 gnus-newsgroup-replied gnus-newsgroup-expirable
1068 gnus-newsgroup-processable gnus-newsgroup-killed
1069 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1070 gnus-newsgroup-unsendable
1071 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1072 gnus-newsgroup-headers gnus-newsgroup-threads
1073 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1074 gnus-current-article gnus-current-headers gnus-have-all-headers
1075 gnus-last-article gnus-article-internal-prepare-hook
1076 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1077 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1078 gnus-thread-expunge-below
1079 gnus-score-alist gnus-current-score-file
1080 (gnus-summary-expunge-below . global)
1081 (gnus-summary-mark-below . global)
1082 gnus-newsgroup-active gnus-scores-exclude-files
1083 gnus-newsgroup-history gnus-newsgroup-ancient
1084 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1085 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1086 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1087 (gnus-newsgroup-expunged-tally . 0)
1088 gnus-cache-removable-articles gnus-newsgroup-cached
1089 gnus-newsgroup-data gnus-newsgroup-data-reverse
1090 gnus-newsgroup-limit gnus-newsgroup-limits
1091 gnus-newsgroup-charset)
1092 "Variables that are buffer-local to the summary buffers.")
1094 ;; Byte-compiler warning.
1095 (defvar gnus-article-mode-map)
1097 ;; Subject simplification.
1099 (defun gnus-simplify-whitespace (str)
1100 "Remove excessive whitespace."
1103 (while (string-match "[ \t][ \t]+" mystr)
1104 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1106 (substring mystr (match-end 0)))))
1108 (when (string-match "^[ \t]+" mystr)
1109 (setq mystr (substring mystr (match-end 0))))
1111 (when (string-match "[ \t]+$" mystr)
1112 (setq mystr (substring mystr 0 (match-beginning 0))))
1115 (defsubst gnus-simplify-subject-re (subject)
1116 "Remove \"Re:\" from subject lines."
1117 (if (string-match "^[Rr][Ee]: *" subject)
1118 (substring subject (match-end 0))
1121 (defun gnus-simplify-subject (subject &optional re-only)
1122 "Remove `Re:' and words in parentheses.
1123 If RE-ONLY is non-nil, strip leading `Re:'s only."
1124 (let ((case-fold-search t)) ;Ignore case.
1125 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1126 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1127 (setq subject (substring subject (match-end 0))))
1128 ;; Remove uninteresting prefixes.
1129 (when (and (not re-only)
1130 gnus-simplify-ignored-prefixes
1131 (string-match gnus-simplify-ignored-prefixes subject))
1132 (setq subject (substring subject (match-end 0))))
1133 ;; Remove words in parentheses from end.
1135 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1136 (setq subject (substring subject 0 (match-beginning 0)))))
1137 ;; Return subject string.
1140 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1142 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1143 (goto-char (point-min))
1144 (while (re-search-forward regexp nil t)
1145 (replace-match (or newtext ""))))
1147 (defun gnus-simplify-buffer-fuzzy ()
1148 "Simplify string in the buffer fuzzily.
1149 The string in the accessible portion of the current buffer is simplified.
1150 It is assumed to be a single-line subject.
1151 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1152 matter is removed. Additional things can be deleted by setting
1153 gnus-simplify-subject-fuzzy-regexp."
1154 (let ((case-fold-search t)
1156 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1158 (while (not (eq modified-tick (buffer-modified-tick)))
1159 (setq modified-tick (buffer-modified-tick))
1161 ((listp gnus-simplify-subject-fuzzy-regexp)
1162 (mapcar 'gnus-simplify-buffer-fuzzy-step
1163 gnus-simplify-subject-fuzzy-regexp))
1164 (gnus-simplify-subject-fuzzy-regexp
1165 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1166 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1167 (gnus-simplify-buffer-fuzzy-step
1168 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1169 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1171 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1172 (gnus-simplify-buffer-fuzzy-step " +" " ")
1173 (gnus-simplify-buffer-fuzzy-step " $")
1174 (gnus-simplify-buffer-fuzzy-step "^ +")))
1176 (defun gnus-simplify-subject-fuzzy (subject)
1177 "Simplify a subject string fuzzily.
1178 See `gnus-simplify-buffer-fuzzy' for details."
1180 (gnus-set-work-buffer)
1181 (let ((case-fold-search t))
1182 ;; Remove uninteresting prefixes.
1183 (when (and gnus-simplify-ignored-prefixes
1184 (string-match gnus-simplify-ignored-prefixes subject))
1185 (setq subject (substring subject (match-end 0))))
1187 (inline (gnus-simplify-buffer-fuzzy))
1190 (defsubst gnus-simplify-subject-fully (subject)
1191 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1193 (gnus-simplify-subject-functions
1194 (gnus-map-function gnus-simplify-subject-functions subject))
1195 ((null gnus-summary-gather-subject-limit)
1196 (gnus-simplify-subject-re subject))
1197 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1198 (gnus-simplify-subject-fuzzy subject))
1199 ((numberp gnus-summary-gather-subject-limit)
1200 (gnus-limit-string (gnus-simplify-subject-re subject)
1201 gnus-summary-gather-subject-limit))
1205 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1206 "Check whether two subjects are equal.
1207 If optional argument simple-first is t, first argument is already
1210 ((null simple-first)
1211 (equal (gnus-simplify-subject-fully s1)
1212 (gnus-simplify-subject-fully s2)))
1215 (gnus-simplify-subject-fully s2)))))
1217 (defun gnus-summary-bubble-group ()
1218 "Increase the score of the current group.
1219 This is a handy function to add to `gnus-summary-exit-hook' to
1220 increase the score of each group you read."
1221 (gnus-group-add-score gnus-newsgroup-name))
1225 ;;; Gnus summary mode
1228 (put 'gnus-summary-mode 'mode-class 'special)
1231 ;; Non-orthogonal keys
1233 (gnus-define-keys gnus-summary-mode-map
1234 " " gnus-summary-next-page
1235 "\177" gnus-summary-prev-page
1236 [delete] gnus-summary-prev-page
1237 [backspace] gnus-summary-prev-page
1238 "\r" gnus-summary-scroll-up
1239 "\M-\r" gnus-summary-scroll-down
1240 "n" gnus-summary-next-unread-article
1241 "p" gnus-summary-prev-unread-article
1242 "N" gnus-summary-next-article
1243 "P" gnus-summary-prev-article
1244 "\M-\C-n" gnus-summary-next-same-subject
1245 "\M-\C-p" gnus-summary-prev-same-subject
1246 "\M-n" gnus-summary-next-unread-subject
1247 "\M-p" gnus-summary-prev-unread-subject
1248 "." gnus-summary-first-unread-article
1249 "," gnus-summary-best-unread-article
1250 "\M-s" gnus-summary-search-article-forward
1251 "\M-r" gnus-summary-search-article-backward
1252 "<" gnus-summary-beginning-of-article
1253 ">" gnus-summary-end-of-article
1254 "j" gnus-summary-goto-article
1255 "^" gnus-summary-refer-parent-article
1256 "\M-^" gnus-summary-refer-article
1257 "u" gnus-summary-tick-article-forward
1258 "!" gnus-summary-tick-article-forward
1259 "U" gnus-summary-tick-article-backward
1260 "d" gnus-summary-mark-as-read-forward
1261 "D" gnus-summary-mark-as-read-backward
1262 "E" gnus-summary-mark-as-expirable
1263 "\M-u" gnus-summary-clear-mark-forward
1264 "\M-U" gnus-summary-clear-mark-backward
1265 "k" gnus-summary-kill-same-subject-and-select
1266 "\C-k" gnus-summary-kill-same-subject
1267 "\M-\C-k" gnus-summary-kill-thread
1268 "\M-\C-l" gnus-summary-lower-thread
1269 "e" gnus-summary-edit-article
1270 "#" gnus-summary-mark-as-processable
1271 "\M-#" gnus-summary-unmark-as-processable
1272 "\M-\C-t" gnus-summary-toggle-threads
1273 "\M-\C-s" gnus-summary-show-thread
1274 "\M-\C-h" gnus-summary-hide-thread
1275 "\M-\C-f" gnus-summary-next-thread
1276 "\M-\C-b" gnus-summary-prev-thread
1277 "\M-\C-u" gnus-summary-up-thread
1278 "\M-\C-d" gnus-summary-down-thread
1279 "&" gnus-summary-execute-command
1280 "c" gnus-summary-catchup-and-exit
1281 "\C-w" gnus-summary-mark-region-as-read
1282 "\C-t" gnus-summary-toggle-truncation
1283 "?" gnus-summary-mark-as-dormant
1284 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1285 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1286 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1287 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1288 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1289 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1290 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1291 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1292 "=" gnus-summary-expand-window
1293 "\C-x\C-s" gnus-summary-reselect-current-group
1294 "\M-g" gnus-summary-rescan-group
1295 "w" gnus-summary-stop-page-breaking
1296 "\C-c\C-r" gnus-summary-caesar-message
1297 "\M-t" gnus-summary-toggle-mime
1298 "f" gnus-summary-followup
1299 "F" gnus-summary-followup-with-original
1300 "C" gnus-summary-cancel-article
1301 "r" gnus-summary-reply
1302 "R" gnus-summary-reply-with-original
1303 "\C-c\C-f" gnus-summary-mail-forward
1304 "o" gnus-summary-save-article
1305 "\C-o" gnus-summary-save-article-mail
1306 "|" gnus-summary-pipe-output
1307 "\M-k" gnus-summary-edit-local-kill
1308 "\M-K" gnus-summary-edit-global-kill
1310 "\C-c\C-d" gnus-summary-describe-group
1311 "q" gnus-summary-exit
1312 "Q" gnus-summary-exit-no-update
1313 "\C-c\C-i" gnus-info-find-node
1314 gnus-mouse-2 gnus-mouse-pick-article
1315 "m" gnus-summary-mail-other-window
1316 "a" gnus-summary-post-news
1317 "x" gnus-summary-limit-to-unread
1318 "s" gnus-summary-isearch-article
1319 "t" gnus-article-toggle-headers
1320 "g" gnus-summary-show-article
1321 "l" gnus-summary-goto-last-article
1322 "v" gnus-summary-preview-mime-message
1323 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1324 "\C-d" gnus-summary-enter-digest-group
1325 "\M-\C-d" gnus-summary-read-document
1326 "\M-\C-e" gnus-summary-edit-parameters
1327 "\M-\C-g" gnus-summary-customize-parameters
1329 "*" gnus-cache-enter-article
1330 "\M-*" gnus-cache-remove-article
1331 "\M-&" gnus-summary-universal-argument
1332 "\C-l" gnus-recenter
1333 "I" gnus-summary-increase-score
1334 "L" gnus-summary-lower-score
1335 "\M-i" gnus-symbolic-argument
1336 "h" gnus-summary-select-article-buffer
1338 "V" gnus-summary-score-map
1339 "X" gnus-uu-extract-map
1340 "S" gnus-summary-send-map)
1342 ;; Sort of orthogonal keymap
1343 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1344 "t" gnus-summary-tick-article-forward
1345 "!" gnus-summary-tick-article-forward
1346 "d" gnus-summary-mark-as-read-forward
1347 "r" gnus-summary-mark-as-read-forward
1348 "c" gnus-summary-clear-mark-forward
1349 " " gnus-summary-clear-mark-forward
1350 "e" gnus-summary-mark-as-expirable
1351 "x" gnus-summary-mark-as-expirable
1352 "?" gnus-summary-mark-as-dormant
1353 "b" gnus-summary-set-bookmark
1354 "B" gnus-summary-remove-bookmark
1355 "#" gnus-summary-mark-as-processable
1356 "\M-#" gnus-summary-unmark-as-processable
1357 "S" gnus-summary-limit-include-expunged
1358 "C" gnus-summary-catchup
1359 "H" gnus-summary-catchup-to-here
1360 "\C-c" gnus-summary-catchup-all
1361 "k" gnus-summary-kill-same-subject-and-select
1362 "K" gnus-summary-kill-same-subject
1363 "P" gnus-uu-mark-map)
1365 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1366 "c" gnus-summary-clear-above
1367 "u" gnus-summary-tick-above
1368 "m" gnus-summary-mark-above
1369 "k" gnus-summary-kill-below)
1371 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1372 "/" gnus-summary-limit-to-subject
1373 "n" gnus-summary-limit-to-articles
1374 "w" gnus-summary-pop-limit
1375 "s" gnus-summary-limit-to-subject
1376 "a" gnus-summary-limit-to-author
1377 "u" gnus-summary-limit-to-unread
1378 "m" gnus-summary-limit-to-marks
1379 "M" gnus-summary-limit-exclude-marks
1380 "v" gnus-summary-limit-to-score
1381 "*" gnus-summary-limit-include-cached
1382 "D" gnus-summary-limit-include-dormant
1383 "T" gnus-summary-limit-include-thread
1384 "d" gnus-summary-limit-exclude-dormant
1385 "t" gnus-summary-limit-to-age
1386 "x" gnus-summary-limit-to-extra
1387 "E" gnus-summary-limit-include-expunged
1388 "c" gnus-summary-limit-exclude-childless-dormant
1389 "C" gnus-summary-limit-mark-excluded-as-read)
1391 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1392 "n" gnus-summary-next-unread-article
1393 "p" gnus-summary-prev-unread-article
1394 "N" gnus-summary-next-article
1395 "P" gnus-summary-prev-article
1396 "\C-n" gnus-summary-next-same-subject
1397 "\C-p" gnus-summary-prev-same-subject
1398 "\M-n" gnus-summary-next-unread-subject
1399 "\M-p" gnus-summary-prev-unread-subject
1400 "f" gnus-summary-first-unread-article
1401 "b" gnus-summary-best-unread-article
1402 "j" gnus-summary-goto-article
1403 "g" gnus-summary-goto-subject
1404 "l" gnus-summary-goto-last-article
1405 "o" gnus-summary-pop-article)
1407 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1408 "k" gnus-summary-kill-thread
1409 "l" gnus-summary-lower-thread
1410 "i" gnus-summary-raise-thread
1411 "T" gnus-summary-toggle-threads
1412 "t" gnus-summary-rethread-current
1413 "^" gnus-summary-reparent-thread
1414 "s" gnus-summary-show-thread
1415 "S" gnus-summary-show-all-threads
1416 "h" gnus-summary-hide-thread
1417 "H" gnus-summary-hide-all-threads
1418 "n" gnus-summary-next-thread
1419 "p" gnus-summary-prev-thread
1420 "u" gnus-summary-up-thread
1421 "o" gnus-summary-top-thread
1422 "d" gnus-summary-down-thread
1423 "#" gnus-uu-mark-thread
1424 "\M-#" gnus-uu-unmark-thread)
1426 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1427 "g" gnus-summary-prepare
1428 "c" gnus-summary-insert-cached-articles)
1430 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1431 "c" gnus-summary-catchup-and-exit
1432 "C" gnus-summary-catchup-all-and-exit
1433 "E" gnus-summary-exit-no-update
1434 "J" gnus-summary-jump-to-other-group
1435 "Q" gnus-summary-exit
1436 "Z" gnus-summary-exit
1437 "n" gnus-summary-catchup-and-goto-next-group
1438 "R" gnus-summary-reselect-current-group
1439 "G" gnus-summary-rescan-group
1440 "N" gnus-summary-next-group
1441 "s" gnus-summary-save-newsrc
1442 "P" gnus-summary-prev-group)
1444 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1445 " " gnus-summary-next-page
1446 "n" gnus-summary-next-page
1447 "\177" gnus-summary-prev-page
1448 [delete] gnus-summary-prev-page
1449 "p" gnus-summary-prev-page
1450 "\r" gnus-summary-scroll-up
1451 "\M-\r" gnus-summary-scroll-down
1452 "<" gnus-summary-beginning-of-article
1453 ">" gnus-summary-end-of-article
1454 "b" gnus-summary-beginning-of-article
1455 "e" gnus-summary-end-of-article
1456 "^" gnus-summary-refer-parent-article
1457 "r" gnus-summary-refer-parent-article
1458 "D" gnus-summary-enter-digest-group
1459 "R" gnus-summary-refer-references
1460 "T" gnus-summary-refer-thread
1461 "g" gnus-summary-show-article
1462 "s" gnus-summary-isearch-article
1463 "P" gnus-summary-print-article
1464 "t" gnus-article-babel)
1466 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1467 "b" gnus-article-add-buttons
1468 "B" gnus-article-add-buttons-to-head
1469 "o" gnus-article-treat-overstrike
1470 "e" gnus-article-emphasize
1471 "w" gnus-article-fill-cited-article
1472 "Q" gnus-article-fill-long-lines
1473 "C" gnus-article-capitalize-sentences
1474 "c" gnus-article-remove-cr
1475 "f" gnus-article-display-x-face
1476 "l" gnus-summary-stop-page-breaking
1477 "r" gnus-summary-caesar-message
1478 "t" gnus-article-toggle-headers
1479 "v" gnus-summary-verbose-headers
1480 "m" gnus-summary-toggle-mime
1481 "h" gnus-article-treat-html
1482 "H" gnus-article-strip-headers-in-body
1483 "d" gnus-article-treat-dumbquotes)
1485 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1486 "a" gnus-article-hide
1487 "h" gnus-article-toggle-headers
1488 "b" gnus-article-hide-boring-headers
1489 "s" gnus-article-hide-signature
1490 "c" gnus-article-hide-citation
1491 "C" gnus-article-hide-citation-in-followups
1492 "p" gnus-article-hide-pgp
1493 "B" gnus-article-strip-banner
1494 "P" gnus-article-hide-pem
1495 "\C-c" gnus-article-hide-citation-maybe)
1497 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1498 "a" gnus-article-highlight
1499 "h" gnus-article-highlight-headers
1500 "c" gnus-article-highlight-citation
1501 "s" gnus-article-highlight-signature)
1503 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1504 "z" gnus-article-date-ut
1505 "u" gnus-article-date-ut
1506 "l" gnus-article-date-local
1507 "e" gnus-article-date-lapsed
1508 "o" gnus-article-date-original
1509 "i" gnus-article-date-iso8601
1510 "s" gnus-article-date-user)
1512 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1513 "t" gnus-article-remove-trailing-blank-lines
1514 "l" gnus-article-strip-leading-blank-lines
1515 "m" gnus-article-strip-multiple-blank-lines
1516 "a" gnus-article-strip-blank-lines
1517 "A" gnus-article-strip-all-blank-lines
1518 "s" gnus-article-strip-leading-space
1519 "e" gnus-article-strip-trailing-space)
1521 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1523 "f" gnus-summary-fetch-faq
1524 "d" gnus-summary-describe-group
1525 "h" gnus-summary-describe-briefly
1526 "i" gnus-info-find-node)
1528 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1529 "e" gnus-summary-expire-articles
1530 "\M-\C-e" gnus-summary-expire-articles-now
1531 "\177" gnus-summary-delete-article
1532 [delete] gnus-summary-delete-article
1533 [backspace] gnus-summary-delete-article
1534 "m" gnus-summary-move-article
1535 "r" gnus-summary-respool-article
1536 "w" gnus-summary-edit-article
1537 "c" gnus-summary-copy-article
1538 "B" gnus-summary-crosspost-article
1539 "q" gnus-summary-respool-query
1540 "t" gnus-summary-respool-trace
1541 "i" gnus-summary-import-article
1542 "p" gnus-summary-article-posted-p)
1544 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1545 "o" gnus-summary-save-article
1546 "m" gnus-summary-save-article-mail
1547 "F" gnus-summary-write-article-file
1548 "r" gnus-summary-save-article-rmail
1549 "f" gnus-summary-save-article-file
1550 "b" gnus-summary-save-article-body-file
1551 "h" gnus-summary-save-article-folder
1552 "v" gnus-summary-save-article-vm
1553 "p" gnus-summary-pipe-output
1554 "s" gnus-soup-add-article)
1556 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1557 "b" gnus-summary-display-buttonized
1558 "m" gnus-summary-repair-multipart
1559 "v" gnus-article-view-part
1560 "o" gnus-article-save-part
1561 "c" gnus-article-copy-part
1562 "e" gnus-article-externalize-part
1563 "i" gnus-article-inline-part
1564 "|" gnus-article-pipe-part)
1567 (defun gnus-summary-make-menu-bar ()
1568 (gnus-turn-off-edit-menu 'summary)
1570 (unless (boundp 'gnus-summary-misc-menu)
1573 gnus-summary-kill-menu gnus-summary-mode-map ""
1578 ["Enter score..." gnus-summary-score-entry t]
1579 ["Customize" gnus-score-customize t])
1580 (gnus-make-score-map 'increase)
1581 (gnus-make-score-map 'lower)
1583 ["Kill below" gnus-summary-kill-below t]
1584 ["Mark above" gnus-summary-mark-above t]
1585 ["Tick above" gnus-summary-tick-above t]
1586 ["Clear above" gnus-summary-clear-above t])
1587 ["Current score" gnus-summary-current-score t]
1588 ["Set score" gnus-summary-set-score t]
1589 ["Switch current score file..." gnus-score-change-score-file t]
1590 ["Set mark below..." gnus-score-set-mark-below t]
1591 ["Set expunge below..." gnus-score-set-expunge-below t]
1592 ["Edit current score file" gnus-score-edit-current-scores t]
1593 ["Edit score file" gnus-score-edit-file t]
1594 ["Trace score" gnus-score-find-trace t]
1595 ["Find words" gnus-score-find-favourite-words t]
1596 ["Rescore buffer" gnus-summary-rescore t]
1597 ["Increase score..." gnus-summary-increase-score t]
1598 ["Lower score..." gnus-summary-lower-score t]))))
1600 ;; Define both the Article menu in the summary buffer and the equivalent
1601 ;; Commands menu in the article buffer here for consistency.
1604 ["All" gnus-article-hide t]
1605 ["Headers" gnus-article-toggle-headers t]
1606 ["Signature" gnus-article-hide-signature t]
1607 ["Citation" gnus-article-hide-citation t]
1608 ["PGP" gnus-article-hide-pgp t]
1609 ["Banner" gnus-article-strip-banner t]
1610 ["Boring headers" gnus-article-hide-boring-headers t])
1612 ["All" gnus-article-highlight t]
1613 ["Headers" gnus-article-highlight-headers t]
1614 ["Signature" gnus-article-highlight-signature t]
1615 ["Citation" gnus-article-highlight-citation t])
1617 ["Local" gnus-article-date-local t]
1618 ["ISO8601" gnus-article-date-iso8601 t]
1619 ["UT" gnus-article-date-ut t]
1620 ["Original" gnus-article-date-original t]
1621 ["Lapsed" gnus-article-date-lapsed t]
1622 ["User-defined" gnus-article-date-user t])
1625 ["Leading" gnus-article-strip-leading-blank-lines t]
1626 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1627 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1628 ["All of the above" gnus-article-strip-blank-lines t]
1629 ["All" gnus-article-strip-all-blank-lines t]
1630 ["Leading space" gnus-article-strip-leading-space t]
1631 ["Trailing space" gnus-article-strip-trailing-space t])
1632 ["Overstrike" gnus-article-treat-overstrike t]
1633 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1634 ["Emphasis" gnus-article-emphasize t]
1635 ["Word wrap" gnus-article-fill-cited-article t]
1636 ["Fill long lines" gnus-article-fill-long-lines t]
1637 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1638 ["CR" gnus-article-remove-cr t]
1639 ["Show X-Face" gnus-article-display-x-face t]
1640 ["UnHTMLize" gnus-article-treat-html t]
1641 ["Rot 13" gnus-summary-caesar-message t]
1642 ["Unix pipe" gnus-summary-pipe-message t]
1643 ["Add buttons" gnus-article-add-buttons t]
1644 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1645 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1646 ["Toggle MIME" gnus-summary-toggle-mime t]
1647 ["Verbose header" gnus-summary-verbose-headers t]
1648 ["Toggle header" gnus-summary-toggle-header t])
1650 ["Save in default format" gnus-summary-save-article t]
1651 ["Save in file" gnus-summary-save-article-file t]
1652 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1653 ["Save in MH folder" gnus-summary-save-article-folder t]
1654 ["Save in VM folder" gnus-summary-save-article-vm t]
1655 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1656 ["Save body in file" gnus-summary-save-article-body-file t]
1657 ["Pipe through a filter" gnus-summary-pipe-output t]
1658 ["Add to SOUP packet" gnus-soup-add-article t]
1659 ["Print" gnus-summary-print-article t])
1661 ["Respool article..." gnus-summary-respool-article t]
1662 ["Move article..." gnus-summary-move-article
1663 (gnus-check-backend-function
1664 'request-move-article gnus-newsgroup-name)]
1665 ["Copy article..." gnus-summary-copy-article t]
1666 ["Crosspost article..." gnus-summary-crosspost-article
1667 (gnus-check-backend-function
1668 'request-replace-article gnus-newsgroup-name)]
1669 ["Import file..." gnus-summary-import-article t]
1670 ["Check if posted" gnus-summary-article-posted-p t]
1671 ["Edit article" gnus-summary-edit-article
1672 (not (gnus-group-read-only-p))]
1673 ["Delete article" gnus-summary-delete-article
1674 (gnus-check-backend-function
1675 'request-expire-articles gnus-newsgroup-name)]
1676 ["Query respool" gnus-summary-respool-query t]
1677 ["Trace respool" gnus-summary-respool-trace t]
1678 ["Delete expirable articles" gnus-summary-expire-articles-now
1679 (gnus-check-backend-function
1680 'request-expire-articles gnus-newsgroup-name)])
1682 ["Uudecode" gnus-uu-decode-uu t]
1683 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1684 ["Unshar" gnus-uu-decode-unshar t]
1685 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1686 ["Save" gnus-uu-decode-save t]
1687 ["Binhex" gnus-uu-decode-binhex t]
1688 ["Postscript" gnus-uu-decode-postscript t])
1690 ["Enter article" gnus-cache-enter-article t]
1691 ["Remove article" gnus-cache-remove-article t])
1692 ["Translate" gnus-article-babel t]
1693 ["Select article buffer" gnus-summary-select-article-buffer t]
1694 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1695 ["Isearch article..." gnus-summary-isearch-article t]
1696 ["Beginning of the article" gnus-summary-beginning-of-article t]
1697 ["End of the article" gnus-summary-end-of-article t]
1698 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1699 ["Fetch referenced articles" gnus-summary-refer-references t]
1700 ["Fetch current thread" gnus-summary-refer-thread t]
1701 ["Fetch article with id..." gnus-summary-refer-article t]
1702 ["Redisplay" gnus-summary-show-article t])))
1704 gnus-summary-article-menu gnus-summary-mode-map ""
1705 (cons "Article" innards))
1708 gnus-article-commands-menu gnus-article-mode-map ""
1709 (cons "Commands" innards)))
1712 gnus-summary-thread-menu gnus-summary-mode-map ""
1714 ["Toggle threading" gnus-summary-toggle-threads t]
1715 ["Hide threads" gnus-summary-hide-all-threads t]
1716 ["Show threads" gnus-summary-show-all-threads t]
1717 ["Hide thread" gnus-summary-hide-thread t]
1718 ["Show thread" gnus-summary-show-thread t]
1719 ["Go to next thread" gnus-summary-next-thread t]
1720 ["Go to previous thread" gnus-summary-prev-thread t]
1721 ["Go down thread" gnus-summary-down-thread t]
1722 ["Go up thread" gnus-summary-up-thread t]
1723 ["Top of thread" gnus-summary-top-thread t]
1724 ["Mark thread as read" gnus-summary-kill-thread t]
1725 ["Lower thread score" gnus-summary-lower-thread t]
1726 ["Raise thread score" gnus-summary-raise-thread t]
1727 ["Rethread current" gnus-summary-rethread-current t]
1731 gnus-summary-post-menu gnus-summary-mode-map ""
1733 ["Post an article" gnus-summary-post-news t]
1734 ["Followup" gnus-summary-followup t]
1735 ["Followup and yank" gnus-summary-followup-with-original t]
1736 ["Supersede article" gnus-summary-supersede-article t]
1737 ["Cancel article" gnus-summary-cancel-article t]
1738 ["Reply" gnus-summary-reply t]
1739 ["Reply and yank" gnus-summary-reply-with-original t]
1740 ["Wide reply" gnus-summary-wide-reply t]
1741 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1742 ["Mail forward" gnus-summary-mail-forward t]
1743 ["Post forward" gnus-summary-post-forward t]
1744 ["Digest and mail" gnus-summary-mail-digest t]
1745 ["Digest and post" gnus-summary-post-digest t]
1746 ["Resend message" gnus-summary-resend-message t]
1747 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1748 ["Send a mail" gnus-summary-mail-other-window t]
1749 ["Uuencode and post" gnus-uu-post-news t]
1750 ["Followup via news" gnus-summary-followup-to-mail t]
1751 ["Followup via news and yank"
1752 gnus-summary-followup-to-mail-with-original t]
1754 ;;["Send" gnus-summary-send-draft t]
1755 ;;["Send bounced" gnus-resend-bounced-mail t])
1759 gnus-summary-misc-menu gnus-summary-mode-map ""
1762 ["Mark as read" gnus-summary-mark-as-read-forward t]
1763 ["Mark same subject and select"
1764 gnus-summary-kill-same-subject-and-select t]
1765 ["Mark same subject" gnus-summary-kill-same-subject t]
1766 ["Catchup" gnus-summary-catchup t]
1767 ["Catchup all" gnus-summary-catchup-all t]
1768 ["Catchup to here" gnus-summary-catchup-to-here t]
1769 ["Catchup region" gnus-summary-mark-region-as-read t]
1770 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1772 ["Tick" gnus-summary-tick-article-forward t]
1773 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1774 ["Remove marks" gnus-summary-clear-mark-forward t]
1775 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1776 ["Set bookmark" gnus-summary-set-bookmark t]
1777 ["Remove bookmark" gnus-summary-remove-bookmark t])
1779 ["Marks..." gnus-summary-limit-to-marks t]
1780 ["Subject..." gnus-summary-limit-to-subject t]
1781 ["Author..." gnus-summary-limit-to-author t]
1782 ["Age..." gnus-summary-limit-to-age t]
1783 ["Extra..." gnus-summary-limit-to-extra t]
1784 ["Score" gnus-summary-limit-to-score t]
1785 ["Unread" gnus-summary-limit-to-unread t]
1786 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1787 ["Articles" gnus-summary-limit-to-articles t]
1788 ["Pop limit" gnus-summary-pop-limit t]
1789 ["Show dormant" gnus-summary-limit-include-dormant t]
1790 ["Hide childless dormant"
1791 gnus-summary-limit-exclude-childless-dormant t]
1792 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1793 ["Hide marked" gnus-summary-limit-exclude-marks t]
1794 ["Show expunged" gnus-summary-show-all-expunged t])
1796 ["Set mark" gnus-summary-mark-as-processable t]
1797 ["Remove mark" gnus-summary-unmark-as-processable t]
1798 ["Remove all marks" gnus-summary-unmark-all-processable t]
1799 ["Mark above" gnus-uu-mark-over t]
1800 ["Mark series" gnus-uu-mark-series t]
1801 ["Mark region" gnus-uu-mark-region t]
1802 ["Unmark region" gnus-uu-unmark-region t]
1803 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1804 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1805 ["Mark all" gnus-uu-mark-all t]
1806 ["Mark buffer" gnus-uu-mark-buffer t]
1807 ["Mark sparse" gnus-uu-mark-sparse t]
1808 ["Mark thread" gnus-uu-mark-thread t]
1809 ["Unmark thread" gnus-uu-unmark-thread t]
1810 ("Process Mark Sets"
1811 ["Kill" gnus-summary-kill-process-mark t]
1812 ["Yank" gnus-summary-yank-process-mark
1813 gnus-newsgroup-process-stack]
1814 ["Save" gnus-summary-save-process-mark t]))
1816 ["Page forward" gnus-summary-next-page t]
1817 ["Page backward" gnus-summary-prev-page t]
1818 ["Line forward" gnus-summary-scroll-up t])
1820 ["Next unread article" gnus-summary-next-unread-article t]
1821 ["Previous unread article" gnus-summary-prev-unread-article t]
1822 ["Next article" gnus-summary-next-article t]
1823 ["Previous article" gnus-summary-prev-article t]
1824 ["Next unread subject" gnus-summary-next-unread-subject t]
1825 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1826 ["Next article same subject" gnus-summary-next-same-subject t]
1827 ["Previous article same subject" gnus-summary-prev-same-subject t]
1828 ["First unread article" gnus-summary-first-unread-article t]
1829 ["Best unread article" gnus-summary-best-unread-article t]
1830 ["Go to subject number..." gnus-summary-goto-subject t]
1831 ["Go to article number..." gnus-summary-goto-article t]
1832 ["Go to the last article" gnus-summary-goto-last-article t]
1833 ["Pop article off history" gnus-summary-pop-article t])
1835 ["Sort by number" gnus-summary-sort-by-number t]
1836 ["Sort by author" gnus-summary-sort-by-author t]
1837 ["Sort by subject" gnus-summary-sort-by-subject t]
1838 ["Sort by date" gnus-summary-sort-by-date t]
1839 ["Sort by score" gnus-summary-sort-by-score t]
1840 ["Sort by lines" gnus-summary-sort-by-lines t]
1841 ["Sort by characters" gnus-summary-sort-by-chars t])
1843 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1844 ["Describe group" gnus-summary-describe-group t]
1845 ["Read manual" gnus-info-find-node t])
1847 ["Pick and read" gnus-pick-mode t]
1848 ["Binary" gnus-binary-mode t])
1850 ["Regenerate" gnus-summary-prepare t]
1851 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1852 ["Toggle threading" gnus-summary-toggle-threads t])
1853 ["Filter articles..." gnus-summary-execute-command t]
1854 ["Run command on subjects..." gnus-summary-universal-argument t]
1855 ["Search articles forward..." gnus-summary-search-article-forward t]
1856 ["Search articles backward..." gnus-summary-search-article-backward t]
1857 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1858 ["Expand window" gnus-summary-expand-window t]
1859 ["Expire expirable articles" gnus-summary-expire-articles
1860 (gnus-check-backend-function
1861 'request-expire-articles gnus-newsgroup-name)]
1862 ["Edit local kill file" gnus-summary-edit-local-kill t]
1863 ["Edit main kill file" gnus-summary-edit-global-kill t]
1864 ["Edit group parameters" gnus-summary-edit-parameters t]
1865 ["Customize group parameters" gnus-summary-customize-parameters t]
1866 ["Send a bug report" gnus-bug t]
1868 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1869 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1870 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1871 ["Exit group" gnus-summary-exit t]
1872 ["Exit group without updating" gnus-summary-exit-no-update t]
1873 ["Exit and goto next group" gnus-summary-next-group t]
1874 ["Exit and goto prev group" gnus-summary-prev-group t]
1875 ["Reselect group" gnus-summary-reselect-current-group t]
1876 ["Rescan group" gnus-summary-rescan-group t]
1877 ["Update dribble" gnus-summary-save-newsrc t])))
1879 (gnus-run-hooks 'gnus-summary-menu-hook)))
1881 (defun gnus-score-set-default (var value)
1882 "A version of set that updates the GNU Emacs menu-bar."
1884 ;; It is the message that forces the active status to be updated.
1887 (defun gnus-make-score-map (type)
1888 "Make a summary score map of type TYPE."
1891 (let ((headers '(("author" "from" string)
1892 ("subject" "subject" string)
1893 ("article body" "body" string)
1894 ("article head" "head" string)
1895 ("xref" "xref" string)
1896 ("extra header" "extra" string)
1897 ("lines" "lines" number)
1898 ("followups to author" "followup" string)))
1899 (types '((number ("less than" <)
1902 (string ("substring" s)
1906 (perms '(("temporary" (current-time-string))
1914 (if (eq type 'lower)
1919 (setq header (car headers))
1925 (let ((ts (cdr (assoc (nth 2 header) types)))
1941 'gnus-summary-score-entry
1943 (if (or (string= (nth 1 header)
1945 (string= (nth 1 header)
1948 (list 'gnus-summary-header
1950 (list 'quote (nth 1 (car ts)))
1951 (list 'gnus-score-default nil)
1957 (list (nreverse outp))))
1960 (list (nreverse outt))))
1962 (setq headers (cdr headers)))
1963 (list (nreverse outh))))))))
1967 (defun gnus-summary-mode (&optional group)
1968 "Major mode for reading articles.
1970 All normal editing commands are switched off.
1971 \\<gnus-summary-mode-map>
1972 Each line in this buffer represents one article. To read an
1973 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1974 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1977 You can also post articles and send mail from this buffer. To
1978 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1979 of an article, type `\\[gnus-summary-reply]'.
1981 There are approx. one gazillion commands you can execute in this
1982 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1984 The following commands are available:
1986 \\{gnus-summary-mode-map}"
1988 (when (gnus-visual-p 'summary-menu 'menu)
1989 (gnus-summary-make-menu-bar))
1990 (kill-all-local-variables)
1991 (gnus-summary-make-local-variables)
1992 (gnus-make-thread-indent-array)
1993 (gnus-simplify-mode-line)
1994 (setq major-mode 'gnus-summary-mode)
1995 (setq mode-name "Summary")
1996 (make-local-variable 'minor-mode-alist)
1997 (use-local-map gnus-summary-mode-map)
1998 (buffer-disable-undo)
1999 (setq buffer-read-only t) ;Disable modification
2000 (setq truncate-lines t)
2001 (setq selective-display t)
2002 (setq selective-display-ellipses t) ;Display `...'
2003 (gnus-summary-set-display-table)
2004 (gnus-set-default-directory)
2005 (setq gnus-newsgroup-name group)
2006 (make-local-variable 'gnus-summary-line-format)
2007 (make-local-variable 'gnus-summary-line-format-spec)
2008 (make-local-variable 'gnus-summary-dummy-line-format)
2009 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2010 (make-local-variable 'gnus-summary-mark-positions)
2011 (make-local-hook 'pre-command-hook)
2012 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2013 (gnus-run-hooks 'gnus-summary-mode-hook)
2014 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2015 (gnus-update-summary-mark-positions))
2017 (defun gnus-summary-make-local-variables ()
2018 "Make all the local summary buffer variables."
2020 (dolist (local gnus-summary-local-variables)
2023 (if (eq (cdr local) 'global)
2024 ;; Copy the global value of the variable.
2025 (setq global (symbol-value (car local)))
2026 ;; Use the value from the list.
2027 (setq global (eval (cdr local))))
2028 (set (make-local-variable (car local)) global))
2029 ;; Simple nil-valued local variable.
2030 (set (make-local-variable local) nil)))))
2032 (defun gnus-summary-clear-local-variables ()
2033 (let ((locals gnus-summary-local-variables))
2035 (if (consp (car locals))
2036 (and (vectorp (caar locals))
2037 (set (caar locals) nil))
2038 (and (vectorp (car locals))
2039 (set (car locals) nil)))
2040 (setq locals (cdr locals)))))
2042 ;; Summary data functions.
2044 (defmacro gnus-data-number (data)
2047 (defmacro gnus-data-set-number (data number)
2048 `(setcar ,data ,number))
2050 (defmacro gnus-data-mark (data)
2053 (defmacro gnus-data-set-mark (data mark)
2054 `(setcar (nthcdr 1 ,data) ,mark))
2056 (defmacro gnus-data-pos (data)
2059 (defmacro gnus-data-set-pos (data pos)
2060 `(setcar (nthcdr 2 ,data) ,pos))
2062 (defmacro gnus-data-header (data)
2065 (defmacro gnus-data-set-header (data header)
2066 `(setf (nth 3 ,data) ,header))
2068 (defmacro gnus-data-level (data)
2071 (defmacro gnus-data-unread-p (data)
2072 `(= (nth 1 ,data) gnus-unread-mark))
2074 (defmacro gnus-data-read-p (data)
2075 `(/= (nth 1 ,data) gnus-unread-mark))
2077 (defmacro gnus-data-pseudo-p (data)
2078 `(consp (nth 3 ,data)))
2080 (defmacro gnus-data-find (number)
2081 `(assq ,number gnus-newsgroup-data))
2083 (defmacro gnus-data-find-list (number &optional data)
2084 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2085 (memq (assq ,number bdata)
2088 (defmacro gnus-data-make (number mark pos header level)
2089 `(list ,number ,mark ,pos ,header ,level))
2091 (defun gnus-data-enter (after-article number mark pos header level offset)
2092 (let ((data (gnus-data-find-list after-article)))
2094 (error "No such article: %d" after-article))
2095 (setcdr data (cons (gnus-data-make number mark pos header level)
2097 (setq gnus-newsgroup-data-reverse nil)
2098 (gnus-data-update-list (cddr data) offset)))
2100 (defun gnus-data-enter-list (after-article list &optional offset)
2102 (let ((data (and after-article (gnus-data-find-list after-article)))
2106 (let ((odata gnus-newsgroup-data))
2107 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2109 (gnus-data-update-list odata offset)))
2110 ;; Find the last element in the list to be spliced into the main
2113 (setq list (cdr list)))
2116 (setcdr list gnus-newsgroup-data)
2117 (setq gnus-newsgroup-data ilist)
2119 (gnus-data-update-list (cdr list) offset)))
2120 (setcdr list (cdr data))
2123 (gnus-data-update-list (cdr list) offset))))
2124 (setq gnus-newsgroup-data-reverse nil))))
2126 (defun gnus-data-remove (article &optional offset)
2127 (let ((data gnus-newsgroup-data))
2128 (if (= (gnus-data-number (car data)) article)
2130 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2131 gnus-newsgroup-data-reverse nil)
2133 (gnus-data-update-list gnus-newsgroup-data offset)))
2135 (when (= (gnus-data-number (cadr data)) article)
2136 (setcdr data (cddr data))
2138 (gnus-data-update-list (cdr data) offset))
2140 gnus-newsgroup-data-reverse nil))
2141 (setq data (cdr data))))))
2143 (defmacro gnus-data-list (backward)
2145 (or gnus-newsgroup-data-reverse
2146 (setq gnus-newsgroup-data-reverse
2147 (reverse gnus-newsgroup-data)))
2148 gnus-newsgroup-data))
2150 (defun gnus-data-update-list (data offset)
2151 "Add OFFSET to the POS of all data entries in DATA."
2152 (setq gnus-newsgroup-data-reverse nil)
2154 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2155 (setq data (cdr data))))
2157 (defun gnus-summary-article-pseudo-p (article)
2158 "Say whether this article is a pseudo article or not."
2159 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2161 (defmacro gnus-summary-article-sparse-p (article)
2162 "Say whether this article is a sparse article or not."
2163 `(memq ,article gnus-newsgroup-sparse))
2165 (defmacro gnus-summary-article-ancient-p (article)
2166 "Say whether this article is a sparse article or not."
2167 `(memq ,article gnus-newsgroup-ancient))
2169 (defun gnus-article-parent-p (number)
2170 "Say whether this article is a parent or not."
2171 (let ((data (gnus-data-find-list number)))
2172 (and (cdr data) ; There has to be an article after...
2173 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2174 (gnus-data-level (nth 1 data))))))
2176 (defun gnus-article-children (number)
2177 "Return a list of all children to NUMBER."
2178 (let* ((data (gnus-data-find-list number))
2179 (level (gnus-data-level (car data)))
2181 (setq data (cdr data))
2183 (= (gnus-data-level (car data)) (1+ level)))
2184 (push (gnus-data-number (car data)) children)
2185 (setq data (cdr data)))
2188 (defmacro gnus-summary-skip-intangible ()
2189 "If the current article is intangible, then jump to a different article."
2190 '(let ((to (get-text-property (point) 'gnus-intangible)))
2191 (and to (gnus-summary-goto-subject to))))
2193 (defmacro gnus-summary-article-intangible-p ()
2194 "Say whether this article is intangible or not."
2195 '(get-text-property (point) 'gnus-intangible))
2197 (defun gnus-article-read-p (article)
2198 "Say whether ARTICLE is read or not."
2199 (not (or (memq article gnus-newsgroup-marked)
2200 (memq article gnus-newsgroup-unreads)
2201 (memq article gnus-newsgroup-unselected)
2202 (memq article gnus-newsgroup-dormant))))
2204 ;; Some summary mode macros.
2206 (defmacro gnus-summary-article-number ()
2207 "The article number of the article on the current line.
2208 If there isn's an article number here, then we return the current
2211 (gnus-summary-skip-intangible)
2212 (or (get-text-property (point) 'gnus-number)
2213 (gnus-summary-last-subject))))
2215 (defmacro gnus-summary-article-header (&optional number)
2216 "Return the header of article NUMBER."
2217 `(gnus-data-header (gnus-data-find
2218 ,(or number '(gnus-summary-article-number)))))
2220 (defmacro gnus-summary-thread-level (&optional number)
2221 "Return the level of thread that starts with article NUMBER."
2222 `(if (and (eq gnus-summary-make-false-root 'dummy)
2223 (get-text-property (point) 'gnus-intangible))
2225 (gnus-data-level (gnus-data-find
2226 ,(or number '(gnus-summary-article-number))))))
2228 (defmacro gnus-summary-article-mark (&optional number)
2229 "Return the mark of article NUMBER."
2230 `(gnus-data-mark (gnus-data-find
2231 ,(or number '(gnus-summary-article-number)))))
2233 (defmacro gnus-summary-article-pos (&optional number)
2234 "Return the position of the line of article NUMBER."
2235 `(gnus-data-pos (gnus-data-find
2236 ,(or number '(gnus-summary-article-number)))))
2238 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2239 (defmacro gnus-summary-article-subject (&optional number)
2240 "Return current subject string or nil if nothing."
2243 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2244 '(gnus-data-header (assq (gnus-summary-article-number)
2245 gnus-newsgroup-data)))))
2248 (mail-header-subject headers))))
2250 (defmacro gnus-summary-article-score (&optional number)
2251 "Return current article score."
2252 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2253 gnus-newsgroup-scored))
2254 gnus-summary-default-score 0))
2256 (defun gnus-summary-article-children (&optional number)
2257 "Return a list of article numbers that are children of article NUMBER."
2258 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2259 (level (gnus-data-level (car data)))
2261 (while (and (setq data (cdr data))
2262 (> (setq l (gnus-data-level (car data))) level))
2263 (and (= (1+ level) l)
2264 (push (gnus-data-number (car data))
2266 (nreverse children)))
2268 (defun gnus-summary-article-parent (&optional number)
2269 "Return the article number of the parent of article NUMBER."
2270 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2271 (gnus-data-list t)))
2272 (level (gnus-data-level (car data))))
2274 () ; This is a root.
2275 ;; We search until we find an article with a level less than
2276 ;; this one. That function has to be the parent.
2277 (while (and (setq data (cdr data))
2278 (not (< (gnus-data-level (car data)) level))))
2279 (and data (gnus-data-number (car data))))))
2281 (defun gnus-unread-mark-p (mark)
2282 "Say whether MARK is the unread mark."
2283 (= mark gnus-unread-mark))
2285 (defun gnus-read-mark-p (mark)
2286 "Say whether MARK is one of the marks that mark as read.
2287 This is all marks except unread, ticked, dormant, and expirable."
2288 (not (or (= mark gnus-unread-mark)
2289 (= mark gnus-ticked-mark)
2290 (= mark gnus-dormant-mark)
2291 (= mark gnus-expirable-mark))))
2293 (defmacro gnus-article-mark (number)
2294 "Return the MARK of article NUMBER.
2295 This macro should only be used when computing the mark the \"first\"
2296 time; i.e., when generating the summary lines. After that,
2297 `gnus-summary-article-mark' should be used to examine the
2300 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2301 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2302 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2303 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2304 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2305 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2306 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2307 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2308 gnus-ancient-mark))))
2310 ;; Saving hidden threads.
2312 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2313 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2315 (defmacro gnus-save-hidden-threads (&rest forms)
2316 "Save hidden threads, eval FORMS, and restore the hidden threads."
2317 (let ((config (make-symbol "config")))
2318 `(let ((,config (gnus-hidden-threads-configuration)))
2322 (gnus-restore-hidden-threads-configuration ,config)))))
2324 (defun gnus-data-compute-positions ()
2325 "Compute the positions of all articles."
2326 (setq gnus-newsgroup-data-reverse nil)
2327 (let ((data gnus-newsgroup-data))
2329 (gnus-save-hidden-threads
2330 (gnus-summary-show-all-threads)
2331 (goto-char (point-min))
2333 (while (get-text-property (point) 'gnus-intangible)
2335 (gnus-data-set-pos (car data) (+ (point) 3))
2336 (setq data (cdr data))
2337 (forward-line 1))))))
2339 (defun gnus-hidden-threads-configuration ()
2340 "Return the current hidden threads configuration."
2343 (goto-char (point-min))
2344 (while (search-forward "\r" nil t)
2345 (push (1- (point)) config))
2348 (defun gnus-restore-hidden-threads-configuration (config)
2349 "Restore hidden threads configuration from CONFIG."
2350 (let (point buffer-read-only)
2351 (while (setq point (pop config))
2352 (when (and (< point (point-max))
2354 (eq (char-after) ?\n))
2355 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2357 ;; Various summary mode internalish functions.
2359 (defun gnus-mouse-pick-article (e)
2362 (gnus-summary-next-page nil t))
2364 (defun gnus-summary-set-display-table ()
2365 ;; Change the display table. Odd characters have a tendency to mess
2366 ;; up nicely formatted displays - we make all possible glyphs
2367 ;; display only a single character.
2369 ;; We start from the standard display table, if any.
2370 (let ((table (or (copy-sequence standard-display-table)
2371 (make-display-table)))
2373 ;; Nix out all the control chars...
2374 (while (>= (setq i (1- i)) 0)
2375 (aset table i [??]))
2376 ;; ... but not newline and cr, of course. (cr is necessary for the
2377 ;; selective display).
2378 (aset table ?\n nil)
2379 (aset table ?\r nil)
2380 ;; We keep TAB as well.
2381 (aset table ?\t nil)
2382 ;; We nix out any glyphs over 126 that are not set already.
2384 (while (>= (setq i (1- i)) 127)
2385 ;; Only modify if the entry is nil.
2386 (unless (aref table i)
2387 (aset table i [??]))))
2388 (setq buffer-display-table table)))
2390 (defun gnus-summary-setup-buffer (group)
2391 "Initialize summary buffer."
2392 (let ((buffer (concat "*Summary " group "*")))
2393 (if (get-buffer buffer)
2396 (setq gnus-summary-buffer (current-buffer))
2397 (not gnus-newsgroup-prepared))
2398 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2399 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2400 (gnus-summary-mode group)
2402 (gnus-carpal-setup-buffer 'summary))
2403 (unless gnus-single-article-buffer
2404 (make-local-variable 'gnus-article-buffer)
2405 (make-local-variable 'gnus-article-current)
2406 (make-local-variable 'gnus-original-article-buffer))
2407 (setq gnus-newsgroup-name group)
2410 (defun gnus-set-global-variables ()
2411 ;; Set the global equivalents of the summary buffer-local variables
2412 ;; to the latest values they had. These reflect the summary buffer
2413 ;; that was in action when the last article was fetched.
2414 (when (eq major-mode 'gnus-summary-mode)
2415 (setq gnus-summary-buffer (current-buffer))
2416 (let ((name gnus-newsgroup-name)
2417 (marked gnus-newsgroup-marked)
2418 (unread gnus-newsgroup-unreads)
2419 (headers gnus-current-headers)
2420 (data gnus-newsgroup-data)
2421 (summary gnus-summary-buffer)
2422 (article-buffer gnus-article-buffer)
2423 (original gnus-original-article-buffer)
2424 (gac gnus-article-current)
2425 (reffed gnus-reffed-article-number)
2426 (score-file gnus-current-score-file)
2427 (default-charset gnus-newsgroup-charset))
2429 (set-buffer gnus-group-buffer)
2430 (setq gnus-newsgroup-name name
2431 gnus-newsgroup-marked marked
2432 gnus-newsgroup-unreads unread
2433 gnus-current-headers headers
2434 gnus-newsgroup-data data
2435 gnus-article-current gac
2436 gnus-summary-buffer summary
2437 gnus-article-buffer article-buffer
2438 gnus-original-article-buffer original
2439 gnus-reffed-article-number reffed
2440 gnus-current-score-file score-file
2441 gnus-newsgroup-charset default-charset)
2442 ;; The article buffer also has local variables.
2443 (when (gnus-buffer-live-p gnus-article-buffer)
2444 (set-buffer gnus-article-buffer)
2445 (setq gnus-summary-buffer summary))))))
2447 (defun gnus-summary-article-unread-p (article)
2448 "Say whether ARTICLE is unread or not."
2449 (memq article gnus-newsgroup-unreads))
2451 (defun gnus-summary-first-article-p (&optional article)
2452 "Return whether ARTICLE is the first article in the buffer."
2453 (if (not (setq article (or article (gnus-summary-article-number))))
2455 (eq article (caar gnus-newsgroup-data))))
2457 (defun gnus-summary-last-article-p (&optional article)
2458 "Return whether ARTICLE is the last article in the buffer."
2459 (if (not (setq article (or article (gnus-summary-article-number))))
2460 ;; All non-existent numbers are the last article. :-)
2462 (not (cdr (gnus-data-find-list article)))))
2464 (defun gnus-make-thread-indent-array ()
2466 (unless (and gnus-thread-indent-array
2467 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2468 (setq gnus-thread-indent-array (make-vector 201 "")
2469 gnus-thread-indent-array-level gnus-thread-indent-level)
2471 (aset gnus-thread-indent-array n
2472 (make-string (* n gnus-thread-indent-level) ? ))
2475 (defun gnus-update-summary-mark-positions ()
2476 "Compute where the summary marks are to go."
2478 (when (gnus-buffer-exists-p gnus-summary-buffer)
2479 (set-buffer gnus-summary-buffer))
2480 (let ((gnus-replied-mark 129)
2481 (gnus-score-below-mark 130)
2482 (gnus-score-over-mark 130)
2483 (gnus-download-mark 131)
2484 (spec gnus-summary-line-format-spec)
2487 (gnus-set-work-buffer)
2488 (let ((gnus-summary-line-format-spec spec)
2489 (gnus-newsgroup-downloadable '((0 . t))))
2490 (gnus-summary-insert-line
2491 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2492 0 nil 128 t nil "" nil 1)
2493 (goto-char (point-min))
2494 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2496 (goto-char (point-min))
2497 (push (cons 'replied (and (search-forward "\201" nil t)
2500 (goto-char (point-min))
2501 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2503 (goto-char (point-min))
2504 (push (cons 'download
2505 (and (search-forward "\203" nil t) (- (point) 2)))
2507 (setq gnus-summary-mark-positions pos))))
2509 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2510 "Insert a dummy root in the summary buffer."
2512 (gnus-add-text-properties
2513 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2514 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2516 (defun gnus-summary-from-or-to-or-newsgroups (header)
2517 (let ((to (cdr (assq 'To (mail-header-extra header))))
2518 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2519 (mail-parse-charset gnus-newsgroup-charset)
2520 (mail-parse-ignored-charsets
2521 (save-excursion (set-buffer gnus-summary-buffer)
2522 gnus-newsgroup-ignored-charsets)))
2525 gnus-ignored-from-addresses
2526 (string-match gnus-ignored-from-addresses
2527 (mail-header-from header)))
2529 (or (car (funcall gnus-extract-address-components
2531 gnus-decode-encoded-word-function to)))
2532 (funcall gnus-decode-encoded-word-function to))))
2534 gnus-ignored-from-addresses
2535 (string-match gnus-ignored-from-addresses
2536 (mail-header-from header)))
2537 (concat "=> " newsgroups))
2539 (or (car (funcall gnus-extract-address-components
2540 (mail-header-from header)))
2541 (mail-header-from header))))))
2543 (defun gnus-summary-insert-line (gnus-tmp-header
2544 gnus-tmp-level gnus-tmp-current
2545 gnus-tmp-unread gnus-tmp-replied
2546 gnus-tmp-expirable gnus-tmp-subject-or-nil
2547 &optional gnus-tmp-dummy gnus-tmp-score
2549 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2550 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2551 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2552 (gnus-tmp-score-char
2553 (if (or (null gnus-summary-default-score)
2554 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2555 gnus-summary-zcore-fuzz))
2557 (if (< gnus-tmp-score gnus-summary-default-score)
2558 gnus-score-below-mark gnus-score-over-mark)))
2560 (cond (gnus-tmp-process gnus-process-mark)
2561 ((memq gnus-tmp-current gnus-newsgroup-cached)
2563 (gnus-tmp-replied gnus-replied-mark)
2564 ((memq gnus-tmp-current gnus-newsgroup-saved)
2566 (t gnus-unread-mark)))
2567 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2570 ((string-match "<[^>]+> *$" gnus-tmp-from)
2571 (let ((beg (match-beginning 0)))
2572 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2573 (substring gnus-tmp-from (1+ (match-beginning 0))
2574 (1- (match-end 0))))
2575 (substring gnus-tmp-from 0 beg))))
2576 ((string-match "(.+)" gnus-tmp-from)
2577 (substring gnus-tmp-from
2578 (1+ (match-beginning 0)) (1- (match-end 0))))
2580 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2581 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2582 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2583 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2584 (buffer-read-only nil))
2585 (when (string= gnus-tmp-name "")
2586 (setq gnus-tmp-name gnus-tmp-from))
2587 (unless (numberp gnus-tmp-lines)
2588 (setq gnus-tmp-lines 0))
2589 (gnus-put-text-property-excluding-characters-with-faces
2591 (progn (eval gnus-summary-line-format-spec) (point))
2592 'gnus-number gnus-tmp-number)
2593 (when (gnus-visual-p 'summary-highlight 'highlight)
2595 (gnus-run-hooks 'gnus-summary-update-hook)
2598 (defun gnus-summary-update-line (&optional dont-update)
2599 ;; Update summary line after change.
2600 (when (and gnus-summary-default-score
2601 (not gnus-summary-inhibit-highlight))
2602 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2603 (article (gnus-summary-article-number))
2604 (score (gnus-summary-article-score article)))
2606 (if (and gnus-summary-mark-below
2607 (< (gnus-summary-article-score)
2608 gnus-summary-mark-below))
2609 ;; This article has a low score, so we mark it as read.
2610 (when (memq article gnus-newsgroup-unreads)
2611 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2612 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2613 ;; This article was previously marked as read on account
2614 ;; of a low score, but now it has risen, so we mark it as
2616 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2617 (gnus-summary-update-mark
2618 (if (or (null gnus-summary-default-score)
2619 (<= (abs (- score gnus-summary-default-score))
2620 gnus-summary-zcore-fuzz))
2622 (if (< score gnus-summary-default-score)
2623 gnus-score-below-mark gnus-score-over-mark))
2625 ;; Do visual highlighting.
2626 (when (gnus-visual-p 'summary-highlight 'highlight)
2627 (gnus-run-hooks 'gnus-summary-update-hook)))))
2629 (defvar gnus-tmp-new-adopts nil)
2631 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2632 "Return the number of articles in THREAD.
2633 This may be 0 in some cases -- if none of the articles in
2634 the thread are to be displayed."
2636 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2638 ((not (listp thread))
2640 ((and (consp thread) (cdr thread))
2643 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2646 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2649 (when (and level (zerop level) gnus-tmp-new-adopts)
2652 'gnus-summary-number-of-articles-in-thread
2653 gnus-tmp-new-adopts))))
2655 (if (> number 1) gnus-not-empty-thread-mark
2656 gnus-empty-thread-mark)
2659 (defun gnus-summary-set-local-parameters (group)
2660 "Go through the local params of GROUP and set all variable specs in that list."
2661 (let ((params (gnus-group-find-parameter group))
2664 (setq elem (car params)
2665 params (cdr params))
2666 (and (consp elem) ; Has to be a cons.
2667 (consp (cdr elem)) ; The cdr has to be a list.
2668 (symbolp (car elem)) ; Has to be a symbol in there.
2669 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2670 (ignore-errors ; So we set it.
2671 (make-local-variable (car elem))
2672 (set (car elem) (eval (nth 1 elem))))))))
2674 (defun gnus-summary-read-group (group &optional show-all no-article
2675 kill-buffer no-display backward
2677 "Start reading news in newsgroup GROUP.
2678 If SHOW-ALL is non-nil, already read articles are also listed.
2679 If NO-ARTICLE is non-nil, no article is selected initially.
2680 If NO-DISPLAY, don't generate a summary buffer."
2684 (let ((gnus-auto-select-next nil))
2685 (or (gnus-summary-read-group-1
2686 group show-all no-article
2687 kill-buffer no-display
2690 select-articles nil)))))
2691 (eq gnus-auto-select-next 'quietly))
2692 (set-buffer gnus-group-buffer)
2693 ;; The entry function called above goes to the next
2694 ;; group automatically, so we go two groups back
2695 ;; if we are searching for the previous group.
2697 (gnus-group-prev-unread-group 2))
2698 (if (not (equal group (gnus-group-group-name)))
2699 (setq group (gnus-group-group-name))
2703 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2704 "Directly jump to the other GROUP from summary buffer.
2705 If SHOW-ALL is non-nil, already read articles are also listed."
2707 (if (eq gnus-summary-buffer (current-buffer))
2708 (list (completing-read
2709 "Group: " gnus-active-hashtb nil t
2710 (when (and gnus-newsgroup-name
2711 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2712 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2713 'gnus-group-history)
2715 (error "%s must be invoked from a gnus summary buffer." this-command)))
2716 (unless (or (zerop (length group))
2717 (and gnus-newsgroup-name
2718 (string-equal gnus-newsgroup-name group)))
2720 (gnus-summary-read-group group show-all
2721 gnus-dont-select-after-jump-to-other-group)))
2723 (defun gnus-summary-read-group-1 (group show-all no-article
2724 kill-buffer no-display
2725 &optional select-articles)
2726 ;; Killed foreign groups can't be entered.
2727 (when (and (not (gnus-group-native-p group))
2728 (not (gnus-gethash group gnus-newsrc-hashtb)))
2729 (error "Dead non-native groups can't be entered"))
2730 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2731 (let* ((new-group (gnus-summary-setup-buffer group))
2732 (quit-config (gnus-group-quit-config group))
2733 (did-select (and new-group (gnus-select-newsgroup
2734 group show-all select-articles))))
2736 ;; This summary buffer exists already, so we just select it.
2738 (gnus-set-global-variables)
2740 (gnus-kill-or-deaden-summary kill-buffer))
2741 (gnus-configure-windows 'summary 'force)
2742 (gnus-set-mode-line 'summary)
2743 (gnus-summary-position-point)
2746 ;; We couldn't select this group.
2748 (when (and (eq major-mode 'gnus-summary-mode)
2749 (not (equal (current-buffer) kill-buffer)))
2750 (kill-buffer (current-buffer))
2751 (if (not quit-config)
2753 ;; Update the info -- marks might need to be removed,
2755 (gnus-summary-update-info)
2756 (set-buffer gnus-group-buffer)
2757 (gnus-group-jump-to-group group)
2758 (gnus-group-next-unread-group 1))
2759 (gnus-handle-ephemeral-exit quit-config)))
2760 (gnus-message 3 "Can't select group")
2762 ;; The user did a `C-g' while prompting for number of articles,
2763 ;; so we exit this group.
2764 ((eq did-select 'quit)
2765 (and (eq major-mode 'gnus-summary-mode)
2766 (not (equal (current-buffer) kill-buffer))
2767 (kill-buffer (current-buffer)))
2769 (gnus-kill-or-deaden-summary kill-buffer))
2770 (if (not quit-config)
2772 (set-buffer gnus-group-buffer)
2773 (gnus-group-jump-to-group group)
2774 (gnus-group-next-unread-group 1)
2775 (gnus-configure-windows 'group 'force))
2776 (gnus-handle-ephemeral-exit quit-config))
2777 ;; Finally signal the quit.
2779 ;; The group was successfully selected.
2781 (gnus-set-global-variables)
2782 ;; Save the active value in effect when the group was entered.
2783 (setq gnus-newsgroup-active
2785 (gnus-active gnus-newsgroup-name)))
2786 ;; You can change the summary buffer in some way with this hook.
2787 (gnus-run-hooks 'gnus-select-group-hook)
2788 ;; Set any local variables in the group parameters.
2789 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2790 (gnus-update-format-specifications
2791 nil 'summary 'summary-mode 'summary-dummy)
2792 ;; Do score processing.
2793 (when gnus-use-scoring
2794 (gnus-possibly-score-headers))
2795 ;; Check whether to fill in the gaps in the threads.
2796 (when gnus-build-sparse-threads
2797 (gnus-build-sparse-threads))
2798 ;; Find the initial limit.
2799 (if gnus-show-threads
2801 (let ((gnus-newsgroup-dormant nil))
2802 (gnus-summary-initial-limit show-all))
2803 (gnus-summary-initial-limit show-all))
2804 (setq gnus-newsgroup-limit
2806 (lambda (header) (mail-header-number header))
2807 gnus-newsgroup-headers)))
2808 ;; Generate the summary buffer.
2810 (gnus-summary-prepare))
2811 (when gnus-use-trees
2812 (gnus-tree-open group)
2813 (setq gnus-summary-highlight-line-function
2814 'gnus-tree-highlight-article))
2815 ;; If the summary buffer is empty, but there are some low-scored
2816 ;; articles or some excluded dormants, we include these in the
2818 (when (and (zerop (buffer-size))
2820 (cond (gnus-newsgroup-dormant
2821 (gnus-summary-limit-include-dormant))
2822 ((and gnus-newsgroup-scored show-all)
2823 (gnus-summary-limit-include-expunged t))))
2824 ;; Function `gnus-apply-kill-file' must be called in this hook.
2825 (gnus-run-hooks 'gnus-apply-kill-hook)
2826 (if (and (zerop (buffer-size))
2829 ;; This newsgroup is empty.
2830 (gnus-summary-catchup-and-exit nil t)
2831 (gnus-message 6 "No unread news")
2833 (gnus-kill-or-deaden-summary kill-buffer))
2834 ;; Return nil from this function.
2836 ;; Hide conversation thread subtrees. We cannot do this in
2837 ;; gnus-summary-prepare-hook since kill processing may not
2838 ;; work with hidden articles.
2839 (and gnus-show-threads
2840 gnus-thread-hide-subtree
2841 (gnus-summary-hide-all-threads))
2843 (gnus-kill-or-deaden-summary kill-buffer))
2844 ;; Show first unread article if requested.
2845 (if (and (not no-article)
2847 gnus-newsgroup-unreads
2848 gnus-auto-select-first)
2850 (gnus-configure-windows 'summary)
2852 ((eq gnus-auto-select-first 'best)
2853 (gnus-summary-best-unread-article))
2854 ((eq gnus-auto-select-first t)
2855 (gnus-summary-first-unread-article))
2856 ((gnus-functionp gnus-auto-select-first)
2857 (funcall gnus-auto-select-first))))
2858 ;; Don't select any articles, just move point to the first
2859 ;; article in the group.
2860 (goto-char (point-min))
2861 (gnus-summary-position-point)
2862 (gnus-configure-windows 'summary 'force)
2863 (gnus-set-mode-line 'summary))
2864 (when (get-buffer-window gnus-group-buffer t)
2865 ;; Gotta use windows, because recenter does weird stuff if
2866 ;; the current buffer ain't the displayed window.
2867 (let ((owin (selected-window)))
2868 (select-window (get-buffer-window gnus-group-buffer t))
2869 (when (gnus-group-goto-group group)
2871 (select-window owin)))
2872 ;; Mark this buffer as "prepared".
2873 (setq gnus-newsgroup-prepared t)
2874 (gnus-run-hooks 'gnus-summary-prepared-hook)
2877 (defun gnus-summary-prepare ()
2878 "Generate the summary buffer."
2880 (let ((buffer-read-only nil))
2882 (setq gnus-newsgroup-data nil
2883 gnus-newsgroup-data-reverse nil)
2884 (gnus-run-hooks 'gnus-summary-generate-hook)
2885 ;; Generate the buffer, either with threads or without.
2886 (when gnus-newsgroup-headers
2887 (gnus-summary-prepare-threads
2888 (if gnus-show-threads
2889 (gnus-sort-gathered-threads
2890 (funcall gnus-summary-thread-gathering-function
2892 (gnus-cut-threads (gnus-make-threads)))))
2893 ;; Unthreaded display.
2894 (gnus-sort-articles gnus-newsgroup-headers))))
2895 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2896 ;; Call hooks for modifying summary buffer.
2897 (goto-char (point-min))
2898 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2900 (defsubst gnus-general-simplify-subject (subject)
2901 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2904 ;; Truncate the subject.
2905 (gnus-simplify-subject-functions
2906 (gnus-map-function gnus-simplify-subject-functions subject))
2907 ((numberp gnus-summary-gather-subject-limit)
2908 (setq subject (gnus-simplify-subject-re subject))
2909 (if (> (length subject) gnus-summary-gather-subject-limit)
2910 (substring subject 0 gnus-summary-gather-subject-limit)
2912 ;; Fuzzily simplify it.
2913 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2914 (gnus-simplify-subject-fuzzy subject))
2915 ;; Just remove the leading "Re:".
2917 (gnus-simplify-subject-re subject))))
2919 (if (and gnus-summary-gather-exclude-subject
2920 (string-match gnus-summary-gather-exclude-subject subject))
2921 nil ; This article shouldn't be gathered
2924 (defun gnus-summary-simplify-subject-query ()
2925 "Query where the respool algorithm would put this article."
2927 (gnus-summary-select-article)
2928 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2930 (defun gnus-gather-threads-by-subject (threads)
2931 "Gather threads by looking at Subject headers."
2932 (if (not gnus-summary-make-false-root)
2934 (let ((hashtb (gnus-make-hashtable 1024))
2937 subject hthread whole-subject)
2939 (setq subject (gnus-general-simplify-subject
2940 (setq whole-subject (mail-header-subject
2943 (if (setq hthread (gnus-gethash subject hashtb))
2945 ;; We enter a dummy root into the thread, if we
2946 ;; haven't done that already.
2947 (unless (stringp (caar hthread))
2948 (setcar hthread (list whole-subject (car hthread))))
2949 ;; We add this new gathered thread to this gathered
2951 (setcdr (car hthread)
2952 (nconc (cdar hthread) (list (car threads))))
2953 ;; Remove it from the list of threads.
2954 (setcdr prev (cdr threads))
2955 (setq threads prev))
2956 ;; Enter this thread into the hash table.
2957 (gnus-sethash subject threads hashtb)))
2959 (setq threads (cdr threads)))
2962 (defun gnus-gather-threads-by-references (threads)
2963 "Gather threads by looking at References headers."
2964 (let ((idhashtb (gnus-make-hashtable 1024))
2965 (thhashtb (gnus-make-hashtable 1024))
2968 ids references id gthread gid entered ref)
2970 (when (setq references (mail-header-references (caar threads)))
2971 (setq id (mail-header-id (caar threads))
2972 ids (gnus-split-references references)
2974 (while (setq ref (pop ids))
2975 (setq ids (delete ref ids))
2976 (if (not (setq gid (gnus-gethash ref idhashtb)))
2978 (gnus-sethash ref id idhashtb)
2979 (gnus-sethash id threads thhashtb))
2980 (setq gthread (gnus-gethash gid thhashtb))
2982 ;; We enter a dummy root into the thread, if we
2983 ;; haven't done that already.
2984 (unless (stringp (caar gthread))
2985 (setcar gthread (list (mail-header-subject (caar gthread))
2987 ;; We add this new gathered thread to this gathered
2989 (setcdr (car gthread)
2990 (nconc (cdar gthread) (list (car threads)))))
2991 ;; Add it into the thread hash table.
2992 (gnus-sethash id gthread thhashtb)
2994 ;; Remove it from the list of threads.
2995 (setcdr prev (cdr threads))
2996 (setq threads prev))))
2998 (setq threads (cdr threads)))
3001 (defun gnus-sort-gathered-threads (threads)
3002 "Sort subtreads inside each gathered thread by article number."
3003 (let ((result threads))
3005 (when (stringp (caar threads))
3006 (setcdr (car threads)
3007 (sort (cdar threads) 'gnus-thread-sort-by-number)))
3008 (setq threads (cdr threads)))
3011 (defun gnus-thread-loop-p (root thread)
3012 "Say whether ROOT is in THREAD."
3013 (let ((stack (list thread))
3016 (while (setq thread (pop stack))
3017 (setq th (cdr thread))
3019 (not (eq (caar th) root)))
3022 ;; We have found a loop.
3024 (setcdr thread (delq (car th) (cdr thread)))
3025 (if (boundp (setq ref-dep (intern "none"
3026 gnus-newsgroup-dependencies)))
3027 (setcdr (symbol-value ref-dep)
3028 (nconc (cdr (symbol-value ref-dep))
3030 (set ref-dep (list nil (car th))))
3033 ;; Push all the subthreads onto the stack.
3034 (push (cdr thread) stack)))
3037 (defun gnus-make-threads ()
3038 "Go through the dependency hashtb and find the roots. Return all threads."
3040 (while (catch 'infloop
3043 ;; Deal with self-referencing References loops.
3044 (when (and (car (symbol-value refs))
3051 (car (symbol-value refs)) thread))
3052 (cdr (symbol-value refs)))))))
3055 (unless (car (symbol-value refs))
3056 ;; These threads do not refer back to any other articles,
3057 ;; so they're roots.
3058 (setq threads (append (cdr (symbol-value refs)) threads))))
3059 gnus-newsgroup-dependencies)))
3062 ;; Build the thread tree.
3063 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3064 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3066 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3067 if it was already present.
3069 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3070 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3071 Message-IDs will be renamed be renamed to a unique Message-ID before
3074 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3075 (let* ((id (mail-header-id header))
3076 (id-dep (and id (intern id dependencies)))
3077 ref ref-dep ref-header)
3078 ;; Enter this `header' in the `dependencies' table.
3082 ;; The first two cases do the normal part: enter a new `header'
3083 ;; in the `dependencies' table.
3084 ((not (boundp id-dep))
3085 (set id-dep (list header)))
3086 ((null (car (symbol-value id-dep)))
3087 (setcar (symbol-value id-dep) header))
3089 ;; From here the `header' was already present in the
3090 ;; `dependencies' table.
3092 ;; Overrides an existing entry;
3093 ;; just set the header part of the entry.
3094 (setcar (symbol-value id-dep) header))
3096 ;; Renames the existing `header' to a unique Message-ID.
3097 ((not gnus-summary-ignore-duplicates)
3098 ;; An article with this Message-ID has already been seen.
3099 ;; We rename the Message-ID.
3100 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3102 (mail-header-set-id header id))
3104 ;; The last case ignores an existing entry, except it adds any
3105 ;; additional Xrefs (in case the two articles came from different
3107 ;; Also sets `header' to `nil' meaning that the `dependencies'
3108 ;; table was *not* modified.
3110 (mail-header-set-xref
3111 (car (symbol-value id-dep))
3112 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3114 (or (mail-header-xref header) "")))
3118 ;; First check if that we are not creating a References loop.
3119 (setq ref (gnus-parent-id (mail-header-references header)))
3121 (setq ref-dep (intern-soft ref dependencies))
3123 (setq ref-header (car (symbol-value ref-dep))))
3124 (if (string= id ref)
3125 ;; Yuk! This is a reference loop. Make the article be a
3128 (mail-header-set-references (car (symbol-value id-dep)) "none")
3130 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3131 (setq ref (gnus-parent-id (mail-header-references header)))
3132 (setq ref-dep (intern (or ref "none") dependencies))
3133 (if (boundp ref-dep)
3134 (setcdr (symbol-value ref-dep)
3135 (nconc (cdr (symbol-value ref-dep))
3136 (list (symbol-value id-dep))))
3137 (set ref-dep (list nil (symbol-value id-dep)))))
3140 (defun gnus-build-sparse-threads ()
3141 (let ((headers gnus-newsgroup-headers)
3142 (gnus-summary-ignore-duplicates t)
3143 header references generation relations
3144 subject child end new-child date)
3145 ;; First we create an alist of generations/relations, where
3146 ;; generations is how much we trust the relation, and the relation
3148 (gnus-message 7 "Making sparse threads...")
3150 (nnheader-set-temp-buffer " *gnus sparse threads*")
3151 (while (setq header (pop headers))
3152 (when (and (setq references (mail-header-references header))
3153 (not (string= references "")))
3155 (setq child (mail-header-id header)
3156 subject (mail-header-subject header)
3157 date (mail-header-date header)
3159 (while (search-backward ">" nil t)
3160 (setq end (1+ (point)))
3161 (when (search-backward "<" nil t)
3162 (setq new-child (buffer-substring (point) end))
3163 (push (list (incf generation)
3164 child (setq child new-child)
3168 (push (list (1+ generation) child nil subject) relations))
3170 (kill-buffer (current-buffer)))
3171 ;; Sort over trustworthiness.
3174 (when (gnus-dependencies-add-header
3175 (make-full-mail-header
3176 gnus-reffed-article-number
3177 (nth 3 relation) "" (or (nth 4 relation) "")
3179 (or (nth 2 relation) "") 0 0 "")
3180 gnus-newsgroup-dependencies nil)
3181 (push gnus-reffed-article-number gnus-newsgroup-limit)
3182 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3183 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3184 gnus-newsgroup-reads)
3185 (decf gnus-reffed-article-number)))
3186 (sort relations 'car-less-than-car))
3187 (gnus-message 7 "Making sparse threads...done")))
3189 (defun gnus-build-old-threads ()
3190 ;; Look at all the articles that refer back to old articles, and
3191 ;; fetch the headers for the articles that aren't there. This will
3192 ;; build complete threads - if the roots haven't been expired by the
3197 (when (not (car (symbol-value refs)))
3198 (setq heads (cdr (symbol-value refs)))
3200 (if (memq (mail-header-number (caar heads))
3201 gnus-newsgroup-dormant)
3202 (setq heads (cdr heads))
3203 (setq id (symbol-name refs))
3204 (while (and (setq id (gnus-build-get-header id))
3205 (not (car (gnus-id-to-thread id)))))
3206 (setq heads nil)))))
3207 gnus-newsgroup-dependencies)))
3209 ;; This function has to be called with point after the article number
3210 ;; on the beginning of the line.
3211 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3212 (let ((eol (gnus-point-at-eol))
3213 (buffer (current-buffer))
3216 ;; overview: [num subject from date id refs chars lines misc]
3221 (make-full-mail-header
3223 (nnheader-nov-field) ; subject
3224 (nnheader-nov-field) ; from
3225 (nnheader-nov-field) ; date
3226 (nnheader-nov-read-message-id) ; id
3227 (nnheader-nov-field) ; refs
3228 (nnheader-nov-read-integer) ; chars
3229 (nnheader-nov-read-integer) ; lines
3231 (nnheader-nov-field)) ; misc
3232 (nnheader-nov-parse-extra))) ; extra
3234 (when gnus-alter-header-function
3235 (funcall gnus-alter-header-function header))
3236 (gnus-dependencies-add-header header dependencies force-new)))
3238 (defun gnus-build-get-header (id)
3239 ;; Look through the buffer of NOV lines and find the header to
3240 ;; ID. Enter this line into the dependencies hash table, and return
3241 ;; the id of the parent article (if any).
3242 (let ((deps gnus-newsgroup-dependencies)
3246 (set-buffer nntp-server-buffer)
3247 (let ((case-fold-search nil))
3248 (goto-char (point-min))
3249 (while (and (not found)
3250 (search-forward id nil t))
3252 (setq found (looking-at
3253 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3254 (regexp-quote id))))
3255 (or found (beginning-of-line 2)))
3259 (setq header (gnus-nov-parse-line
3260 (read (current-buffer)) deps))
3261 (gnus-parent-id (mail-header-references header))))))
3263 (let ((number (mail-header-number header)))
3264 (push number gnus-newsgroup-limit)
3265 (push header gnus-newsgroup-headers)
3266 (if (memq number gnus-newsgroup-unselected)
3268 (push number gnus-newsgroup-unreads)
3269 (setq gnus-newsgroup-unselected
3270 (delq number gnus-newsgroup-unselected)))
3271 (push number gnus-newsgroup-ancient)))))))
3273 (defun gnus-build-all-threads ()
3274 "Read all the headers."
3275 (let ((gnus-summary-ignore-duplicates t)
3276 (dependencies gnus-newsgroup-dependencies)
3279 (set-buffer nntp-server-buffer)
3280 (let ((case-fold-search nil))
3281 (goto-char (point-min))
3284 (setq article (read (current-buffer))
3285 header (gnus-nov-parse-line
3286 article dependencies)))
3289 (set-buffer gnus-summary-buffer)
3290 (push header gnus-newsgroup-headers)
3291 (if (memq (setq article (mail-header-number header))
3292 gnus-newsgroup-unselected)
3294 (push article gnus-newsgroup-unreads)
3295 (setq gnus-newsgroup-unselected
3296 (delq article gnus-newsgroup-unselected)))
3297 (push article gnus-newsgroup-ancient)))
3298 (forward-line 1)))))))
3300 (defun gnus-summary-update-article-line (article header)
3301 "Update the line for ARTICLE using HEADERS."
3302 (let* ((id (mail-header-id header))
3303 (thread (gnus-id-to-thread id)))
3305 (error "Article in no thread"))
3306 ;; Update the thread.
3307 (setcar thread header)
3308 (gnus-summary-goto-subject article)
3309 (let* ((datal (gnus-data-find-list article))
3311 (length (when (cdr datal)
3312 (- (gnus-data-pos data)
3313 (gnus-data-pos (cadr datal)))))
3314 (buffer-read-only nil)
3315 (level (gnus-summary-thread-level)))
3317 (gnus-summary-insert-line
3318 header level nil (gnus-article-mark article)
3319 (memq article gnus-newsgroup-replied)
3320 (memq article gnus-newsgroup-expirable)
3321 ;; Only insert the Subject string when it's different
3322 ;; from the previous Subject string.
3323 (if (gnus-subject-equal
3325 (mail-header-subject
3328 (gnus-data-find-list
3330 (gnus-data-list t)))))
3331 ;; Error on the side of excessive subjects.
3333 (mail-header-subject header))
3335 (mail-header-subject header))
3336 nil (cdr (assq article gnus-newsgroup-scored))
3337 (memq article gnus-newsgroup-processable))
3339 (gnus-data-update-list
3340 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3342 (defun gnus-summary-update-article (article &optional iheader)
3343 "Update ARTICLE in the summary buffer."
3344 (set-buffer gnus-summary-buffer)
3345 (let* ((header (gnus-summary-article-header article))
3346 (id (mail-header-id header))
3347 (data (gnus-data-find article))
3348 (thread (gnus-id-to-thread id))
3349 (references (mail-header-references header))
3353 (when (and references
3354 (not (equal "" references)))
3357 (buffer-read-only nil)
3363 (delq thread parent)))
3364 (if (gnus-summary-insert-subject id header)
3365 ;; Set the (possibly) new article number in the data structure.
3366 (gnus-data-set-number data (gnus-id-to-article id))
3370 (defun gnus-rebuild-thread (id &optional line)
3371 "Rebuild the thread containing ID.
3372 If LINE, insert the rebuilt thread starting on line LINE."
3373 (let ((buffer-read-only nil)
3374 old-pos current thread data)
3375 (if (not gnus-show-threads)
3376 (setq thread (list (car (gnus-id-to-thread id))))
3377 ;; Get the thread this article is part of.
3378 (setq thread (gnus-remove-thread id)))
3379 (setq old-pos (gnus-point-at-bol))
3380 (setq current (save-excursion
3381 (and (zerop (forward-line -1))
3382 (gnus-summary-article-number))))
3383 ;; If this is a gathered thread, we have to go some re-gathering.
3384 (when (stringp (car thread))
3385 (let ((subject (car thread))
3387 (setq thread (cdr thread))
3389 (unless (memq (setq thr (gnus-id-to-thread
3391 (mail-header-id (caar thread)))))
3394 (setq thread (cdr thread)))
3395 ;; We now have all (unique) roots.
3396 (if (= (length roots) 1)
3397 ;; All the loose roots are now one solid root.
3398 (setq thread (car roots))
3399 (setq thread (cons subject (gnus-sort-threads roots))))))
3401 ;; We then insert this thread into the summary buffer.
3403 (goto-char (point-min))
3404 (forward-line (1- line)))
3405 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3406 (if gnus-show-threads
3407 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3408 (gnus-summary-prepare-unthreaded thread))
3409 (setq data (nreverse gnus-newsgroup-data))
3410 (setq threads gnus-newsgroup-threads))
3411 ;; We splice the new data into the data structure.
3412 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3413 ;;!!! then we want to insert at the beginning of the buffer.
3414 ;;!!! That happens to be true with Gnus now, but that may
3415 ;;!!! change in the future. Perhaps.
3416 (gnus-data-enter-list
3417 (if line nil current) data (- (point) old-pos))
3418 (setq gnus-newsgroup-threads
3419 (nconc threads gnus-newsgroup-threads))
3420 (gnus-data-compute-positions))))
3422 (defun gnus-number-to-header (number)
3423 "Return the header for article NUMBER."
3424 (let ((headers gnus-newsgroup-headers))
3426 (not (= number (mail-header-number (car headers)))))
3431 (defun gnus-parent-headers (in-headers &optional generation)
3432 "Return the headers of the GENERATIONeth parent of HEADERS."
3434 (setq generation 1))
3436 (headers in-headers)
3439 (not (zerop generation))
3440 (setq references (mail-header-references headers)))
3441 (setq headers (if (and references
3442 (setq parent (gnus-parent-id references)))
3443 (car (gnus-id-to-thread parent))
3446 (and (not (eq headers in-headers))
3449 (defun gnus-id-to-thread (id)
3450 "Return the (sub-)thread where ID appears."
3451 (gnus-gethash id gnus-newsgroup-dependencies))
3453 (defun gnus-id-to-article (id)
3454 "Return the article number of ID."
3455 (let ((thread (gnus-id-to-thread id)))
3458 (mail-header-number (car thread)))))
3460 (defun gnus-id-to-header (id)
3461 "Return the article headers of ID."
3462 (car (gnus-id-to-thread id)))
3464 (defun gnus-article-displayed-root-p (article)
3465 "Say whether ARTICLE is a root(ish) article."
3466 (let ((level (gnus-summary-thread-level article))
3467 (refs (mail-header-references (gnus-summary-article-header article)))
3473 ((null (gnus-parent-id refs)) t)
3475 (null (setq particle (gnus-id-to-article
3476 (gnus-parent-id refs))))
3477 (null (gnus-summary-thread-level particle)))))))
3479 (defun gnus-root-id (id)
3480 "Return the id of the root of the thread where ID appears."
3482 (while (and id (setq prev (car (gnus-id-to-thread id))))
3484 id (gnus-parent-id (mail-header-references prev))))
3487 (defun gnus-articles-in-thread (thread)
3488 "Return the list of articles in THREAD."
3489 (cons (mail-header-number (car thread))
3490 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3492 (defun gnus-remove-thread (id &optional dont-remove)
3493 "Remove the thread that has ID in it."
3494 (let (headers thread last-id)
3495 ;; First go up in this thread until we find the root.
3496 (setq last-id (gnus-root-id id)
3497 headers (message-flatten-list (gnus-id-to-thread last-id)))
3498 ;; We have now found the real root of this thread. It might have
3499 ;; been gathered into some loose thread, so we have to search
3500 ;; through the threads to find the thread we wanted.
3501 (let ((threads gnus-newsgroup-threads)
3504 (setq sub (car threads))
3505 (if (stringp (car sub))
3506 ;; This is a gathered thread, so we look at the roots
3507 ;; below it to find whether this article is in this
3510 (setq sub (cdr sub))
3512 (when (member (caar sub) headers)
3513 (setq thread (car threads)
3516 (setq sub (cdr sub))))
3517 ;; It's an ordinary thread, so we check it.
3518 (when (eq (car sub) (car headers))
3521 (setq threads (cdr threads)))
3522 ;; If this article is in no thread, then it's a root.
3525 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3526 (setq thread (gnus-id-to-thread last-id)))
3529 thread ; We return this thread.
3531 (if (stringp (car thread))
3533 ;; If we use dummy roots, then we have to remove the
3534 ;; dummy root as well.
3535 (when (eq gnus-summary-make-false-root 'dummy)
3536 ;; We go to the dummy root by going to
3537 ;; the first sub-"thread", and then one line up.
3538 (gnus-summary-goto-article
3539 (mail-header-number (caadr thread)))
3542 (gnus-data-compute-positions))
3543 (setq thread (cdr thread))
3545 (gnus-remove-thread-1 (car thread))
3546 (setq thread (cdr thread))))
3547 (gnus-summary-show-all-threads)
3548 (gnus-remove-thread-1 thread))))))))
3550 (defun gnus-remove-thread-1 (thread)
3551 "Remove the thread THREAD recursively."
3552 (let ((number (mail-header-number (pop thread)))
3554 (setq thread (reverse thread))
3556 (gnus-remove-thread-1 (pop thread)))
3557 (when (setq d (gnus-data-find number))
3558 (goto-char (gnus-data-pos d))
3561 (- (gnus-point-at-bol)
3563 (1+ (gnus-point-at-eol))
3564 (gnus-delete-line)))))))
3566 (defun gnus-sort-threads (threads)
3568 (if (not gnus-thread-sort-functions)
3570 (gnus-message 8 "Sorting threads...")
3572 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3573 (gnus-message 8 "Sorting threads...done"))))
3575 (defun gnus-sort-articles (articles)
3577 (when gnus-article-sort-functions
3578 (gnus-message 7 "Sorting articles...")
3580 (setq gnus-newsgroup-headers
3581 (sort articles (gnus-make-sort-function
3582 gnus-article-sort-functions)))
3583 (gnus-message 7 "Sorting articles...done"))))
3585 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3586 (defmacro gnus-thread-header (thread)
3587 ;; Return header of first article in THREAD.
3588 ;; Note that THREAD must never, ever be anything else than a variable -
3589 ;; using some other form will lead to serious barfage.
3590 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3591 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3592 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3595 (defsubst gnus-article-sort-by-number (h1 h2)
3596 "Sort articles by article number."
3597 (< (mail-header-number h1)
3598 (mail-header-number h2)))
3600 (defun gnus-thread-sort-by-number (h1 h2)
3601 "Sort threads by root article number."
3602 (gnus-article-sort-by-number
3603 (gnus-thread-header h1) (gnus-thread-header h2)))
3605 (defsubst gnus-article-sort-by-lines (h1 h2)
3606 "Sort articles by article Lines header."
3607 (< (mail-header-lines h1)
3608 (mail-header-lines h2)))
3610 (defun gnus-thread-sort-by-lines (h1 h2)
3611 "Sort threads by root article Lines header."
3612 (gnus-article-sort-by-lines
3613 (gnus-thread-header h1) (gnus-thread-header h2)))
3615 (defsubst gnus-article-sort-by-chars (h1 h2)
3616 "Sort articles by octet length."
3617 (< (mail-header-chars h1)
3618 (mail-header-chars h2)))
3620 (defun gnus-thread-sort-by-chars (h1 h2)
3621 "Sort threads by root article octet length."
3622 (gnus-article-sort-by-chars
3623 (gnus-thread-header h1) (gnus-thread-header h2)))
3625 (defsubst gnus-article-sort-by-author (h1 h2)
3626 "Sort articles by root author."
3628 (let ((addr (car (mime-read-field 'From h1))))
3629 (or (std11-full-name-string addr)
3630 (std11-address-string addr)
3632 (let ((addr (car (mime-read-field 'From h2))))
3633 (or (std11-full-name-string addr)
3634 (std11-address-string addr)
3638 (defun gnus-thread-sort-by-author (h1 h2)
3639 "Sort threads by root author."
3640 (gnus-article-sort-by-author
3641 (gnus-thread-header h1) (gnus-thread-header h2)))
3643 (defsubst gnus-article-sort-by-subject (h1 h2)
3644 "Sort articles by root subject."
3646 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3647 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3649 (defun gnus-thread-sort-by-subject (h1 h2)
3650 "Sort threads by root subject."
3651 (gnus-article-sort-by-subject
3652 (gnus-thread-header h1) (gnus-thread-header h2)))
3654 (defsubst gnus-article-sort-by-date (h1 h2)
3655 "Sort articles by root article date."
3657 (gnus-date-get-time (mail-header-date h1))
3658 (gnus-date-get-time (mail-header-date h2))))
3660 (defun gnus-thread-sort-by-date (h1 h2)
3661 "Sort threads by root article date."
3662 (gnus-article-sort-by-date
3663 (gnus-thread-header h1) (gnus-thread-header h2)))
3665 (defsubst gnus-article-sort-by-score (h1 h2)
3666 "Sort articles by root article score.
3667 Unscored articles will be counted as having a score of zero."
3668 (> (or (cdr (assq (mail-header-number h1)
3669 gnus-newsgroup-scored))
3670 gnus-summary-default-score 0)
3671 (or (cdr (assq (mail-header-number h2)
3672 gnus-newsgroup-scored))
3673 gnus-summary-default-score 0)))
3675 (defun gnus-thread-sort-by-score (h1 h2)
3676 "Sort threads by root article score."
3677 (gnus-article-sort-by-score
3678 (gnus-thread-header h1) (gnus-thread-header h2)))
3680 (defun gnus-thread-sort-by-total-score (h1 h2)
3681 "Sort threads by the sum of all scores in the thread.
3682 Unscored articles will be counted as having a score of zero."
3683 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3685 (defun gnus-thread-total-score (thread)
3686 ;; This function find the total score of THREAD.
3687 (cond ((null thread)
3690 (if (stringp (car thread))
3691 (apply gnus-thread-score-function 0
3692 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3693 (gnus-thread-total-score-1 thread)))
3695 (gnus-thread-total-score-1 (list thread)))))
3697 (defun gnus-thread-total-score-1 (root)
3698 ;; This function find the total score of the thread below ROOT.
3699 (setq root (car root))
3700 (apply gnus-thread-score-function
3702 (mapcar 'gnus-thread-total-score
3703 (cdr (gnus-id-to-thread (mail-header-id root))))
3704 (when (> (mail-header-number root) 0)
3705 (list (or (cdr (assq (mail-header-number root)
3706 gnus-newsgroup-scored))
3707 gnus-summary-default-score 0))))
3708 (list gnus-summary-default-score)
3711 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3712 (defvar gnus-tmp-prev-subject nil)
3713 (defvar gnus-tmp-false-parent nil)
3714 (defvar gnus-tmp-root-expunged nil)
3715 (defvar gnus-tmp-dummy-line nil)
3717 (defvar gnus-tmp-header)
3718 (defun gnus-extra-header (type &optional header)
3719 "Return the extra header of TYPE."
3720 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3723 (defun gnus-summary-prepare-threads (threads)
3724 "Prepare summary buffer from THREADS and indentation LEVEL.
3725 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3726 or a straight list of headers."
3727 (gnus-message 7 "Generating summary...")
3729 (setq gnus-newsgroup-threads threads)
3732 (let ((gnus-tmp-level 0)
3733 (default-score (or gnus-summary-default-score 0))
3734 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3735 thread number subject stack state gnus-tmp-gathered beg-match
3736 new-roots gnus-tmp-new-adopts thread-end
3737 gnus-tmp-header gnus-tmp-unread
3738 gnus-tmp-replied gnus-tmp-subject-or-nil
3739 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3740 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3741 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3743 (setq gnus-tmp-prev-subject nil)
3745 (if (vectorp (car threads))
3746 ;; If this is a straight (sic) list of headers, then a
3747 ;; threaded summary display isn't required, so we just create
3748 ;; an unthreaded one.
3749 (gnus-summary-prepare-unthreaded threads)
3751 ;; Do the threaded display.
3753 (while (or threads stack gnus-tmp-new-adopts new-roots)
3755 (if (and (= gnus-tmp-level 0)
3758 (not gnus-tmp-false-parent)
3759 (or gnus-tmp-new-adopts new-roots))
3760 (if gnus-tmp-new-adopts
3761 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3762 thread (list (car gnus-tmp-new-adopts))
3763 gnus-tmp-header (caar thread)
3764 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3766 (setq thread (list (car new-roots))
3767 gnus-tmp-header (caar thread)
3768 new-roots (cdr new-roots))))
3771 ;; If there are some threads, we do them before the
3772 ;; threads on the stack.
3773 (setq thread threads
3774 gnus-tmp-header (caar thread))
3775 ;; There were no current threads, so we pop something off
3777 (setq state (car stack)
3778 gnus-tmp-level (car state)
3781 gnus-tmp-header (caar thread))))
3783 (setq gnus-tmp-false-parent nil)
3784 (setq gnus-tmp-root-expunged nil)
3785 (setq thread-end nil)
3787 (if (stringp gnus-tmp-header)
3788 ;; The header is a dummy root.
3790 ((eq gnus-summary-make-false-root 'adopt)
3791 ;; We let the first article adopt the rest.
3792 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3794 (setq gnus-tmp-gathered
3796 (lambda (h) (mail-header-number (car h)))
3799 (setq thread (cons (list (caar thread)
3802 (setq gnus-tmp-level -1
3803 gnus-tmp-false-parent t))
3804 ((eq gnus-summary-make-false-root 'empty)
3805 ;; We print adopted articles with empty subject fields.
3806 (setq gnus-tmp-gathered
3808 (lambda (h) (mail-header-number (car h)))
3811 (setq gnus-tmp-level -1))
3812 ((eq gnus-summary-make-false-root 'dummy)
3813 ;; We remember that we probably want to output a dummy
3815 (setq gnus-tmp-dummy-line gnus-tmp-header)
3816 (setq gnus-tmp-prev-subject gnus-tmp-header))
3818 ;; We do not make a root for the gathered
3819 ;; sub-threads at all.
3820 (setq gnus-tmp-level -1)))
3822 (setq number (mail-header-number gnus-tmp-header)
3823 subject (mail-header-subject gnus-tmp-header))
3826 ;; If the thread has changed subject, we might want to make
3827 ;; this subthread into a root.
3828 ((and (null gnus-thread-ignore-subject)
3829 (not (zerop gnus-tmp-level))
3830 gnus-tmp-prev-subject
3832 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3833 (setq new-roots (nconc new-roots (list (car thread)))
3835 gnus-tmp-header nil))
3836 ;; If the article lies outside the current limit,
3837 ;; then we do not display it.
3838 ((not (memq number gnus-newsgroup-limit))
3839 (setq gnus-tmp-gathered
3841 (lambda (h) (mail-header-number (car h)))
3844 (setq gnus-tmp-new-adopts (if (cdar thread)
3845 (append gnus-tmp-new-adopts
3847 gnus-tmp-new-adopts)
3849 gnus-tmp-header nil)
3850 (when (zerop gnus-tmp-level)
3851 (setq gnus-tmp-root-expunged t)))
3852 ;; Perhaps this article is to be marked as read?
3853 ((and gnus-summary-mark-below
3854 (< (or (cdr (assq number gnus-newsgroup-scored))
3856 gnus-summary-mark-below)
3857 ;; Don't touch sparse articles.
3858 (not (gnus-summary-article-sparse-p number))
3859 (not (gnus-summary-article-ancient-p number)))
3860 (setq gnus-newsgroup-unreads
3861 (delq number gnus-newsgroup-unreads))
3862 (if gnus-newsgroup-auto-expire
3863 (push number gnus-newsgroup-expirable)
3864 (push (cons number gnus-low-score-mark)
3865 gnus-newsgroup-reads))))
3867 (when gnus-tmp-header
3868 ;; We may have an old dummy line to output before this
3870 (when (and gnus-tmp-dummy-line
3873 (mail-header-subject gnus-tmp-header)))
3874 (gnus-summary-insert-dummy-line
3875 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3876 (setq gnus-tmp-dummy-line nil))
3878 ;; Compute the mark.
3879 (setq gnus-tmp-unread (gnus-article-mark number))
3881 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3882 gnus-tmp-header gnus-tmp-level)
3883 gnus-newsgroup-data)
3885 ;; Actually insert the line.
3887 gnus-tmp-subject-or-nil
3889 ((and gnus-thread-ignore-subject
3890 gnus-tmp-prev-subject
3891 (not (inline (gnus-subject-equal
3892 gnus-tmp-prev-subject subject))))
3894 ((zerop gnus-tmp-level)
3895 (if (and (eq gnus-summary-make-false-root 'empty)
3896 (memq number gnus-tmp-gathered)
3897 gnus-tmp-prev-subject
3898 (inline (gnus-subject-equal
3899 gnus-tmp-prev-subject subject)))
3900 gnus-summary-same-subject
3902 (t gnus-summary-same-subject)))
3903 (if (and (eq gnus-summary-make-false-root 'adopt)
3904 (= gnus-tmp-level 1)
3905 (memq number gnus-tmp-gathered))
3906 (setq gnus-tmp-opening-bracket ?\<
3907 gnus-tmp-closing-bracket ?\>)
3908 (setq gnus-tmp-opening-bracket ?\[
3909 gnus-tmp-closing-bracket ?\]))
3911 gnus-tmp-indentation
3912 (aref gnus-thread-indent-array gnus-tmp-level)
3913 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3914 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3915 gnus-summary-default-score 0)
3917 (if (or (null gnus-summary-default-score)
3918 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3919 gnus-summary-zcore-fuzz))
3921 (if (< gnus-tmp-score gnus-summary-default-score)
3922 gnus-score-below-mark gnus-score-over-mark))
3924 (cond ((memq number gnus-newsgroup-processable)
3926 ((memq number gnus-newsgroup-cached)
3928 ((memq number gnus-newsgroup-replied)
3930 ((memq number gnus-newsgroup-saved)
3932 (t gnus-unread-mark))
3933 gnus-tmp-from (mail-header-from gnus-tmp-header)
3936 ((string-match "<[^>]+> *$" gnus-tmp-from)
3937 (setq beg-match (match-beginning 0))
3938 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3939 (substring gnus-tmp-from (1+ (match-beginning 0))
3940 (1- (match-end 0))))
3941 (substring gnus-tmp-from 0 beg-match)))
3942 ((string-match "(.+)" gnus-tmp-from)
3943 (substring gnus-tmp-from
3944 (1+ (match-beginning 0)) (1- (match-end 0))))
3946 (when (string= gnus-tmp-name "")
3947 (setq gnus-tmp-name gnus-tmp-from))
3948 (unless (numberp gnus-tmp-lines)
3949 (setq gnus-tmp-lines 0))
3950 (gnus-put-text-property
3952 (progn (eval gnus-summary-line-format-spec) (point))
3953 'gnus-number number)
3956 (gnus-run-hooks 'gnus-summary-update-hook)
3959 (setq gnus-tmp-prev-subject subject)))
3961 (when (nth 1 thread)
3962 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3963 (incf gnus-tmp-level)
3964 (setq threads (if thread-end nil (cdar thread)))
3966 (setq gnus-tmp-level 0)))))
3967 (gnus-message 7 "Generating summary...done"))
3969 (defun gnus-summary-prepare-unthreaded (headers)
3970 "Generate an unthreaded summary buffer based on HEADERS."
3971 (let (header number mark)
3976 ;; We may have to root out some bad articles...
3977 (when (memq (setq number (mail-header-number
3978 (setq header (pop headers))))
3979 gnus-newsgroup-limit)
3980 ;; Mark article as read when it has a low score.
3981 (when (and gnus-summary-mark-below
3982 (< (or (cdr (assq number gnus-newsgroup-scored))
3983 gnus-summary-default-score 0)
3984 gnus-summary-mark-below)
3985 (not (gnus-summary-article-ancient-p number)))
3986 (setq gnus-newsgroup-unreads
3987 (delq number gnus-newsgroup-unreads))
3988 (if gnus-newsgroup-auto-expire
3989 (push number gnus-newsgroup-expirable)
3990 (push (cons number gnus-low-score-mark)
3991 gnus-newsgroup-reads)))
3993 (setq mark (gnus-article-mark number))
3994 (push (gnus-data-make number mark (1+ (point)) header 0)
3995 gnus-newsgroup-data)
3996 (gnus-summary-insert-line
3998 mark (memq number gnus-newsgroup-replied)
3999 (memq number gnus-newsgroup-expirable)
4000 (mail-header-subject header) nil
4001 (cdr (assq number gnus-newsgroup-scored))
4002 (memq number gnus-newsgroup-processable))))))
4004 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4005 "Select newsgroup GROUP.
4006 If READ-ALL is non-nil, all articles in the group are selected.
4007 If SELECT-ARTICLES, only select those articles from GROUP."
4008 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4009 ;;!!! Dirty hack; should be removed.
4010 (gnus-summary-ignore-duplicates
4011 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4013 gnus-summary-ignore-duplicates))
4014 (info (nth 2 entry))
4015 articles fetched-articles cached)
4017 (unless (gnus-check-server
4018 (setq gnus-current-select-method
4019 (gnus-find-method-for-group group)))
4020 (error "Couldn't open server"))
4022 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4023 (gnus-activate-group group) ; Or we can activate it...
4024 (progn ; Or we bug out.
4025 (when (equal major-mode 'gnus-summary-mode)
4026 (kill-buffer (current-buffer)))
4027 (error "Couldn't request group %s: %s"
4028 group (gnus-status-message group))))
4030 (unless (gnus-request-group group t)
4031 (when (equal major-mode 'gnus-summary-mode)
4032 (kill-buffer (current-buffer)))
4033 (error "Couldn't request group %s: %s"
4034 group (gnus-status-message group)))
4036 (setq gnus-newsgroup-name group)
4037 (setq gnus-newsgroup-unselected nil)
4038 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4039 (gnus-summary-setup-default-charset)
4041 ;; Adjust and set lists of article marks.
4043 (gnus-adjust-marked-articles info))
4045 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4047 (if (gnus-virtual-group-p group)
4048 gnus-newsgroup-cached
4049 (gnus-cache-articles-in-group group)))
4051 (setq gnus-newsgroup-unreads
4052 (gnus-set-difference
4053 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4054 gnus-newsgroup-dormant))
4056 (setq gnus-newsgroup-processable nil)
4058 (gnus-update-read-articles group gnus-newsgroup-unreads)
4060 (if (setq articles select-articles)
4061 (setq gnus-newsgroup-unselected
4062 (gnus-sorted-intersection
4063 gnus-newsgroup-unreads
4064 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4065 (setq articles (gnus-articles-to-read group read-all)))
4069 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4071 ((eq articles 0) nil)
4073 ;; Init the dependencies hash table.
4074 (setq gnus-newsgroup-dependencies
4075 (gnus-make-hashtable (length articles)))
4076 (gnus-set-global-variables)
4077 ;; Retrieve the headers and read them in.
4078 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4079 (setq gnus-newsgroup-headers
4080 (gnus-retrieve-parsed-headers
4081 articles gnus-newsgroup-name
4082 ;; We might want to fetch old headers, but
4083 ;; not if there is only 1 article.
4084 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4085 (not (numberp gnus-fetch-old-headers)))
4086 (> (length articles) 1))
4087 gnus-fetch-old-headers)))
4088 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4090 ;; Suppress duplicates?
4091 (when gnus-suppress-duplicates
4092 (gnus-dup-suppress-articles))
4094 ;; Set the initial limit.
4095 (setq gnus-newsgroup-limit (copy-sequence articles))
4096 ;; Remove canceled articles from the list of unread articles.
4097 (setq gnus-newsgroup-unreads
4098 (gnus-set-sorted-intersection
4099 gnus-newsgroup-unreads
4100 (setq fetched-articles
4101 (mapcar (lambda (headers) (mail-header-number headers))
4102 gnus-newsgroup-headers))))
4103 ;; Removed marked articles that do not exist.
4104 (gnus-update-missing-marks
4105 (gnus-sorted-complement fetched-articles articles))
4107 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4109 (setq gnus-newsgroup-cached cached))
4111 ;; We might want to build some more threads first.
4112 (when (and gnus-fetch-old-headers
4113 (eq gnus-headers-retrieved-by 'nov))
4114 (if (eq gnus-fetch-old-headers 'invisible)
4115 (gnus-build-all-threads)
4116 (gnus-build-old-threads)))
4117 ;; Let the Gnus agent mark articles as read.
4119 (gnus-agent-get-undownloaded-list))
4120 ;; Check whether auto-expire is to be done in this group.
4121 (setq gnus-newsgroup-auto-expire
4122 (gnus-group-auto-expirable-p group))
4123 ;; Set up the article buffer now, if necessary.
4124 (unless gnus-single-article-buffer
4125 (gnus-article-setup-buffer))
4126 ;; First and last article in this newsgroup.
4127 (when gnus-newsgroup-headers
4128 (setq gnus-newsgroup-begin
4129 (mail-header-number (car gnus-newsgroup-headers))
4132 (gnus-last-element gnus-newsgroup-headers))))
4133 ;; GROUP is successfully selected.
4134 (or gnus-newsgroup-headers t)))))
4136 (defun gnus-articles-to-read (group &optional read-all)
4137 ;; Find out what articles the user wants to read.
4139 ;; Select all articles if `read-all' is non-nil, or if there
4140 ;; are no unread articles.
4142 (and (zerop (length gnus-newsgroup-marked))
4143 (zerop (length gnus-newsgroup-unreads)))
4144 (eq (gnus-group-find-parameter group 'display)
4146 (gnus-uncompress-range (gnus-active group))
4147 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4148 (copy-sequence gnus-newsgroup-unreads))
4150 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4151 (scored (length scored-list))
4152 (number (length articles))
4153 (marked (+ (length gnus-newsgroup-marked)
4154 (length gnus-newsgroup-dormant)))
4162 ((and (or (<= scored marked) (= scored number))
4163 (natnump gnus-large-newsgroup)
4164 (> number gnus-large-newsgroup))
4165 (let ((input (read-from-minibuffer
4167 "How many articles from %s (max %d): "
4168 (gnus-limit-string gnus-newsgroup-name 35)
4170 (static-if (< emacs-major-version 20)
4171 (number-to-string gnus-large-newsgroup)
4173 (number-to-string gnus-large-newsgroup)
4175 (if (string-match "^[ \t]*$" input)
4178 ((and (> scored marked) (< scored number)
4179 (> (- scored number) 20))
4182 (format "%s %s (%d scored, %d total): "
4183 "How many articles from"
4184 group scored number))))
4185 (if (string-match "^[ \t]*$" input)
4189 (setq select (if (stringp select) (string-to-number select) select))
4190 (if (or (null select) (zerop select))
4192 (if (and (not (zerop scored)) (<= (abs select) scored))
4194 (setq articles (sort scored-list '<))
4195 (setq number (length articles)))
4196 (setq articles (copy-sequence articles)))
4198 (when (< (abs select) number)
4200 ;; Select the N oldest articles.
4201 (setcdr (nthcdr (1- (abs select)) articles) nil)
4202 ;; Select the N most recent articles.
4203 (setq articles (nthcdr (- number select) articles))))
4204 (setq gnus-newsgroup-unselected
4205 (gnus-sorted-intersection
4206 gnus-newsgroup-unreads
4207 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4210 (defun gnus-killed-articles (killed articles)
4213 (when (inline (gnus-member-of-range (car articles) killed))
4214 (push (car articles) out))
4215 (setq articles (cdr articles)))
4218 (defun gnus-uncompress-marks (marks)
4219 "Uncompress the mark ranges in MARKS."
4220 (let ((uncompressed '(score bookmark))
4223 (if (memq (caar marks) uncompressed)
4224 (push (car marks) out)
4225 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4226 (setq marks (cdr marks)))
4229 (defun gnus-adjust-marked-articles (info)
4230 "Set all article lists and remove all marks that are no longer valid."
4231 (let* ((marked-lists (gnus-info-marks info))
4232 (active (gnus-active (gnus-info-group info)))
4235 (types gnus-article-mark-lists)
4236 (uncompressed '(score bookmark killed))
4237 marks var articles article mark)
4240 (setq marks (pop marked-lists))
4241 (set (setq var (intern (format "gnus-newsgroup-%s"
4242 (car (rassq (setq mark (car marks))
4244 (if (memq (car marks) uncompressed) (cdr marks)
4245 (gnus-uncompress-range (cdr marks))))
4247 (setq articles (symbol-value var))
4249 ;; All articles have to be subsets of the active articles.
4251 ;; Adjust "simple" lists.
4252 ((memq mark '(tick dormant expire reply save))
4254 (when (or (< (setq article (pop articles)) min) (> article max))
4255 (set var (delq article (symbol-value var))))))
4257 ((memq mark uncompressed)
4258 (when (not (listp (cdr (symbol-value var))))
4259 (set var (list (symbol-value var))))
4260 (when (not (listp (cdr articles)))
4261 (setq articles (list articles)))
4263 (when (or (not (consp (setq article (pop articles))))
4264 (< (car article) min)
4265 (> (car article) max))
4266 (set var (delq article (symbol-value var))))))))))
4268 (defun gnus-update-missing-marks (missing)
4269 "Go through the list of MISSING articles and remove them from the mark lists."
4271 (let ((types gnus-article-mark-lists)
4273 ;; Go through all types.
4275 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4276 (when (symbol-value var)
4277 ;; This list has articles. So we delete all missing articles
4281 (set var (delq (pop m) (symbol-value var)))))))))
4283 (defun gnus-update-marks ()
4284 "Enter the various lists of marked articles into the newsgroup info list."
4285 (let ((types gnus-article-mark-lists)
4286 (info (gnus-get-info gnus-newsgroup-name))
4287 (uncompressed '(score bookmark killed))
4288 type list newmarked symbol delta-marks)
4290 ;; Add all marks lists to the list of marks lists.
4291 (while (setq type (pop types))
4292 (setq list (symbol-value
4294 (intern (format "gnus-newsgroup-%s"
4298 ;; Get rid of the entries of the articles that have the
4300 (when (and (eq (cdr type) 'score)
4304 (prev (cons nil list))
4307 (if (or (not (consp (car arts)))
4308 (= (cdar arts) gnus-summary-default-score))
4309 (setcdr prev (cdr arts))
4311 (setq arts (cdr arts)))
4312 (setq list (cdr all)))))
4314 (or (memq (cdr type) uncompressed)
4315 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4317 (when (gnus-check-backend-function 'request-set-mark
4318 gnus-newsgroup-name)
4319 ;; uncompressed:s are not proper flags (they are cons cells)
4320 ;; cache is a internal gnus flag
4321 (unless (memq (cdr type) (cons 'cache uncompressed))
4322 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4323 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4324 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4326 (push (list add 'add (list (cdr type))) delta-marks))
4328 (push (list del 'del (list (cdr type))) delta-marks)))))
4331 (push (cons (cdr type) list) newmarked)))
4334 (unless (gnus-check-group gnus-newsgroup-name)
4335 (error "Can't open server for %s" gnus-newsgroup-name))
4336 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4338 ;; Enter these new marks into the info of the group.
4340 (setcar (nthcdr 3 info) newmarked)
4341 ;; Add the marks lists to the end of the info.
4343 (setcdr (nthcdr 2 info) (list newmarked))))
4345 ;; Cut off the end of the info if there's nothing else there.
4349 (when (nthcdr (decf i) info)
4350 (setcdr (nthcdr i info) nil)))))))
4352 (defun gnus-set-mode-line (where)
4353 "This function sets the mode line of the article or summary buffers.
4354 If WHERE is `summary', the summary mode line format will be used."
4355 ;; Is this mode line one we keep updated?
4356 (when (and (memq where gnus-updated-mode-lines)
4358 (intern (format "gnus-%s-mode-line-format-spec" where))))
4361 ;; We evaluate this in the summary buffer since these
4362 ;; variables are buffer-local to that buffer.
4363 (set-buffer gnus-summary-buffer)
4364 ;; We bind all these variables that are used in the `eval' form
4366 (let* ((mformat (symbol-value
4368 (format "gnus-%s-mode-line-format-spec" where))))
4369 (gnus-tmp-group-name gnus-newsgroup-name)
4370 (gnus-tmp-article-number (or gnus-current-article 0))
4371 (gnus-tmp-unread gnus-newsgroup-unreads)
4372 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4373 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4374 (gnus-tmp-unread-and-unselected
4375 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4376 (zerop gnus-tmp-unselected))
4378 ((zerop gnus-tmp-unselected)
4379 (format "{%d more}" gnus-tmp-unread-and-unticked))
4380 (t (format "{%d(+%d) more}"
4381 gnus-tmp-unread-and-unticked
4382 gnus-tmp-unselected))))
4384 (if (and gnus-current-headers
4385 (vectorp gnus-current-headers))
4386 (gnus-mode-string-quote
4387 (mail-header-subject gnus-current-headers))
4389 bufname-length max-len
4390 gnus-tmp-header);; passed as argument to any user-format-funcs
4391 (setq mode-string (eval mformat))
4392 (setq bufname-length (if (string-match "%b" mode-string)
4395 (if (eq where 'summary)
4397 (get-buffer gnus-article-buffer))))
4400 (setq max-len (max 4 (if gnus-mode-non-string-length
4402 gnus-mode-non-string-length
4404 (length mode-string))))
4405 ;; We might have to chop a bit of the string off...
4406 (when (> (length mode-string) max-len)
4408 (concat (gnus-truncate-string mode-string (- max-len 3))
4410 ;; Pad the mode string a bit.
4411 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4412 ;; Update the mode line.
4413 (setq mode-line-buffer-identification
4414 (gnus-mode-line-buffer-identification (list mode-string)))
4415 (set-buffer-modified-p t))))
4417 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4418 "Go through the HEADERS list and add all Xrefs to a hash table.
4419 The resulting hash table is returned, or nil if no Xrefs were found."
4420 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4421 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4422 (xref-hashtb (gnus-make-hashtable))
4423 start group entry number xrefs header)
4425 (setq header (pop headers))
4426 (when (and (setq xrefs (mail-header-xref header))
4427 (not (memq (setq number (mail-header-number header))
4430 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4431 (setq start (match-end 0))
4432 (setq group (if prefix
4433 (concat prefix (substring xrefs (match-beginning 1)
4435 (substring xrefs (match-beginning 1) (match-end 1))))
4437 (string-to-int (substring xrefs (match-beginning 2)
4439 (if (setq entry (gnus-gethash group xref-hashtb))
4440 (setcdr entry (cons number (cdr entry)))
4441 (gnus-sethash group (cons number nil) xref-hashtb)))))
4442 (and start xref-hashtb)))
4444 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4445 "Look through all the headers and mark the Xrefs as read."
4446 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4447 name entry info xref-hashtb idlist method nth4)
4449 (set-buffer gnus-group-buffer)
4450 (when (setq xref-hashtb
4451 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4454 (unless (string= from-newsgroup (setq name (symbol-name group)))
4455 (setq idlist (symbol-value group))
4456 ;; Dead groups are not updated.
4458 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4460 (when (stringp (setq nth4 (gnus-info-method info)))
4461 (setq nth4 (gnus-server-to-method nth4))))
4462 ;; Only do the xrefs if the group has the same
4463 ;; select method as the group we have just read.
4464 (or (gnus-methods-equal-p
4465 nth4 (gnus-find-method-for-group from-newsgroup))
4467 (equal nth4 (setq method (gnus-find-method-for-group
4469 (and (equal (car nth4) (car method))
4470 (equal (nth 1 nth4) (nth 1 method))))
4471 gnus-use-cross-reference
4472 (or (not (eq gnus-use-cross-reference t))
4474 ;; Only do cross-references on subscribed
4475 ;; groups, if that is what is wanted.
4476 (<= (gnus-info-level info) gnus-level-subscribed))
4477 (gnus-group-make-articles-read name idlist))))
4480 (defun gnus-compute-read-articles (group articles)
4481 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4482 (info (nth 2 entry))
4483 (active (gnus-active group))
4486 ;; First peel off all invalid article numbers.
4488 (let ((ids articles)
4490 (while (setq id (pop ids))
4491 (when (and first (> id (cdr active)))
4492 ;; We'll end up in this situation in one particular
4493 ;; obscure situation. If you re-scan a group and get
4494 ;; a new article that is cross-posted to a different
4495 ;; group that has not been re-scanned, you might get
4496 ;; crossposted article that has a higher number than
4497 ;; Gnus believes possible. So we re-activate this
4498 ;; group as well. This might mean doing the
4499 ;; crossposting thingy will *increase* the number
4500 ;; of articles in some groups. Tsk, tsk.
4501 (setq active (or (gnus-activate-group group) active)))
4502 (when (or (> id (cdr active))
4503 (< id (car active)))
4504 (setq articles (delq id articles))))))
4505 ;; If the read list is nil, we init it.
4507 (null (gnus-info-read info))
4509 (setq ninfo (cons 1 (1- (car active))))
4510 (setq ninfo (gnus-info-read info)))
4511 ;; Then we add the read articles to the range.
4513 ninfo (setq articles (sort articles '<))))))
4515 (defun gnus-group-make-articles-read (group articles)
4516 "Update the info of GROUP to say that ARTICLES are read."
4518 (entry (gnus-gethash group gnus-newsrc-hashtb))
4519 (info (nth 2 entry))
4520 (active (gnus-active group))
4523 (setq range (gnus-compute-read-articles group articles))
4525 (set-buffer gnus-group-buffer)
4528 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4529 (gnus-info-set-read ',info ',(gnus-info-read info))
4530 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4531 (gnus-group-update-group ,group t))))
4532 ;; Add the read articles to the range.
4533 (gnus-info-set-read info range)
4534 ;; Then we have to re-compute how many unread
4535 ;; articles there are in this group.
4539 (setq num (- (1+ (cdr active)) (car active))))
4540 ((not (listp (cdr range)))
4541 (setq num (- (cdr active) (- (1+ (cdr range))
4545 (if (numberp (car range))
4547 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4548 (setq range (cdr range)))
4549 (setq num (- (cdr active) num))))
4550 ;; Update the number of unread articles.
4552 ;; Update the group buffer.
4553 (gnus-group-update-group group t)))))
4555 (defvar gnus-newsgroup-none-id 0)
4557 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4558 (let ((cur nntp-server-buffer)
4561 (save-excursion (set-buffer gnus-summary-buffer)
4562 gnus-newsgroup-dependencies)))
4564 (mail-parse-charset gnus-newsgroup-charset)
4565 (mail-parse-ignored-charsets
4566 (or (and (gnus-buffer-live-p gnus-summary-buffer)
4567 (save-excursion (set-buffer gnus-summary-buffer)
4568 gnus-newsgroup-ignored-charsets))
4569 gnus-newsgroup-ignored-charsets)))
4571 (set-buffer nntp-server-buffer)
4572 ;; Translate all TAB characters into SPACE characters.
4573 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4574 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4575 (gnus-run-hooks 'gnus-parse-headers-hook)
4576 (let ((case-fold-search t)
4577 in-reply-to header p lines chars ctype)
4578 (goto-char (point-min))
4579 ;; Search to the beginning of the next header. Error messages
4580 ;; do not begin with 2 or 3.
4581 (while (re-search-forward "^[23][0-9]+ " nil t)
4584 ;; This implementation of this function, with nine
4585 ;; search-forwards instead of the one re-search-forward and
4586 ;; a case (which basically was the old function) is actually
4587 ;; about twice as fast, even though it looks messier. You
4588 ;; can't have everything, I guess. Speed and elegance
4589 ;; doesn't always go hand in hand.
4592 (make-full-mail-header
4598 (narrow-to-region (point)
4599 (or (and (search-forward "\n.\n" nil t)
4605 (if (search-forward "\nsubject: " nil t)
4606 (buffer-substring (match-end 0) (std11-field-end))
4611 (if (search-forward "\nfrom: " nil t)
4612 (buffer-substring (match-end 0) (std11-field-end))
4617 (if (search-forward "\ndate: " nil t)
4618 (buffer-substring (match-end 0) (std11-field-end))
4623 (setq id (if (re-search-forward
4624 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4625 ;; We do it this way to make sure the Message-ID
4626 ;; is (somewhat) syntactically valid.
4627 (buffer-substring (match-beginning 1)
4629 ;; If there was no message-id, we just fake one
4630 ;; to make subsequent routines simpler.
4631 (nnheader-generate-fake-message-id))))
4635 (if (search-forward "\nreferences: " nil t)
4639 (buffer-substring (match-end 0) (std11-field-end))
4644 (search-backward ">" end t)
4647 (search-backward "<" end t)
4649 ;; Get the references from the in-reply-to header if there
4650 ;; were no references and the in-reply-to header looks
4652 (if (and (search-forward "\nin-reply-to: " nil t)
4654 (buffer-substring (match-end 0)
4656 (string-match "<[^>]+>" in-reply-to))
4658 (setq ref (substring in-reply-to (match-beginning 0)
4660 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4661 (setq ref2 (substring in-reply-to (match-beginning 0)
4663 (when (> (length ref2) (length ref))
4670 (if (search-forward "\nchars: " nil t)
4671 (if (numberp (setq chars (ignore-errors (read cur))))
4677 (if (search-forward "\nlines: " nil t)
4678 (if (numberp (setq lines (ignore-errors (read cur))))
4684 (and (search-forward "\nxref: " nil t)
4685 (buffer-substring (match-end 0) (std11-field-end))))
4687 (when gnus-extra-headers
4688 (let ((extra gnus-extra-headers)
4692 (when (search-forward
4693 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4694 (push (cons (car extra)
4695 (buffer-substring (match-end 0)
4701 (if (and (search-forward "\ncontent-type: " nil t)
4703 (buffer-substring (match-end 0) (std11-field-end))))
4704 (mime-entity-set-content-type-internal
4705 header (mime-parse-Content-Type ctype)))
4706 (when (equal id ref)
4709 (when gnus-alter-header-function
4710 (funcall gnus-alter-header-function header)
4711 (setq id (mail-header-id header)
4712 ref (gnus-parent-id (mail-header-references header))))
4715 (gnus-dependencies-add-header
4716 header dependencies force-new))
4717 (push header headers))
4718 (goto-char (point-max))
4720 (nreverse headers)))))
4722 ;; Goes through the xover lines and returns a list of vectors
4723 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4724 force-new dependencies
4725 group also-fetch-heads)
4726 "Parse the news overview data in the server buffer, and return a
4727 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4728 ;; Get the Xref when the users reads the articles since most/some
4729 ;; NNTP servers do not include Xrefs when using XOVER.
4730 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4731 (let ((mail-parse-charset gnus-newsgroup-charset)
4732 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4733 (cur nntp-server-buffer)
4734 (dependencies (or dependencies gnus-newsgroup-dependencies))
4735 number headers header)
4737 (set-buffer nntp-server-buffer)
4738 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4739 ;; Allow the user to mangle the headers before parsing them.
4740 (gnus-run-hooks 'gnus-parse-headers-hook)
4741 (goto-char (point-min))
4744 (while (and sequence (not (eobp)))
4745 (setq number (read cur))
4746 (while (and sequence
4747 (< (car sequence) number))
4748 (setq sequence (cdr sequence)))
4750 (eq number (car sequence))
4752 (setq sequence (cdr sequence))
4753 (setq header (inline
4754 (gnus-nov-parse-line
4755 number dependencies force-new))))
4756 (push header headers))
4759 (gnus-error 4 "Strange nov line (%d)"
4760 (count-lines (point-min) (point)))))
4762 ;; A common bug in inn is that if you have posted an article and
4763 ;; then retrieves the active file, it will answer correctly --
4764 ;; the new article is included. However, a NOV entry for the
4765 ;; article may not have been generated yet, so this may fail.
4766 ;; We work around this problem by retrieving the last few
4767 ;; headers using HEAD.
4768 (if (or (not also-fetch-heads)
4770 ;; We (probably) got all the headers.
4772 (let ((gnus-nov-is-evil t))
4775 (gnus-retrieve-parsed-headers sequence group)
4778 (defun gnus-article-get-xrefs ()
4779 "Fill in the Xref value in `gnus-current-headers', if necessary.
4780 This is meant to be called in `gnus-article-internal-prepare-hook'."
4781 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4782 gnus-current-headers)))
4783 (or (not gnus-use-cross-reference)
4785 (and (mail-header-xref headers)
4786 (not (string= (mail-header-xref headers) "")))
4787 (let ((case-fold-search t)
4790 (nnheader-narrow-to-headers)
4791 (goto-char (point-min))
4792 (when (or (and (eq (downcase (char-after)) ?x)
4793 (looking-at "Xref:"))
4794 (search-forward "\nXref:" nil t))
4795 (goto-char (1+ (match-end 0)))
4796 (setq xref (buffer-substring (point)
4797 (progn (end-of-line) (point))))
4798 (mail-header-set-xref headers xref)))))))
4800 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4801 "Find article ID and insert the summary line for that article.
4802 OLD-HEADER can either be a header or a line number to insert
4803 the subject line on."
4804 (let* ((line (and (numberp old-header) old-header))
4805 (old-header (and (vectorp old-header) old-header))
4806 (header (cond ((and old-header use-old-header)
4809 (gnus-number-to-header id))
4810 (gnus-number-to-header id))
4812 (gnus-read-header id))))
4813 (number (and (numberp id) id))
4816 ;; Rebuild the thread that this article is part of and go to the
4817 ;; article we have fetched.
4818 (when (and (not gnus-show-threads)
4821 (setq d (gnus-data-find (mail-header-number old-header))))
4822 (goto-char (gnus-data-pos d))
4825 (- (gnus-point-at-bol)
4827 (1+ (gnus-point-at-eol))
4828 (gnus-delete-line))))))
4830 (mail-header-set-number header (mail-header-number old-header)))
4831 (setq gnus-newsgroup-sparse
4832 (delq (setq number (mail-header-number header))
4833 gnus-newsgroup-sparse))
4834 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4835 (push number gnus-newsgroup-limit)
4836 (gnus-rebuild-thread (mail-header-id header) line)
4837 (gnus-summary-goto-subject number nil t))
4838 (when (and (numberp number)
4840 ;; We have to update the boundaries even if we can't fetch the
4841 ;; article if ID is a number -- so that the next `P' or `N'
4842 ;; command will fetch the previous (or next) article even
4843 ;; if the one we tried to fetch this time has been canceled.
4844 (when (> number gnus-newsgroup-end)
4845 (setq gnus-newsgroup-end number))
4846 (when (< number gnus-newsgroup-begin)
4847 (setq gnus-newsgroup-begin number))
4848 (setq gnus-newsgroup-unselected
4849 (delq number gnus-newsgroup-unselected)))
4850 ;; Report back a success?
4851 (and header (mail-header-number header))))
4853 ;;; Process/prefix in the summary buffer
4855 (defun gnus-summary-work-articles (n)
4856 "Return a list of articles to be worked upon.
4857 The prefix argument, the list of process marked articles, and the
4858 current article will be taken into consideration."
4860 (set-buffer gnus-summary-buffer)
4863 ;; A numerical prefix has been given.
4864 (setq n (prefix-numeric-value n))
4865 (let ((backward (< n 0))
4866 (n (abs (prefix-numeric-value n)))
4871 (push (setq article (gnus-summary-article-number))
4874 (gnus-summary-find-prev nil article)
4875 (gnus-summary-find-next nil article)))
4877 (nreverse articles)))
4878 ((and (gnus-region-active-p) (mark))
4879 (message "region active")
4880 ;; Work on the region between point and mark.
4881 (let ((max (max (point) (mark)))
4884 (goto-char (min (point) (mark)))
4887 (push (setq article (gnus-summary-article-number)) articles)
4888 (gnus-summary-find-next nil article)
4890 (nreverse articles))))
4891 (gnus-newsgroup-processable
4892 ;; There are process-marked articles present.
4893 ;; Save current state.
4894 (gnus-summary-save-process-mark)
4896 (reverse gnus-newsgroup-processable))
4898 ;; Just return the current article.
4899 (list (gnus-summary-article-number))))))
4901 (defmacro gnus-summary-iterate (arg &rest forms)
4902 "Iterate over the process/prefixed articles and do FORMS.
4903 ARG is the interactive prefix given to the command. FORMS will be
4904 executed with point over the summary line of the articles."
4905 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4906 `(let ((,articles (gnus-summary-work-articles ,arg)))
4908 (gnus-summary-goto-subject (car ,articles))
4912 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4913 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4915 (defun gnus-summary-save-process-mark ()
4916 "Push the current set of process marked articles on the stack."
4918 (push (copy-sequence gnus-newsgroup-processable)
4919 gnus-newsgroup-process-stack))
4921 (defun gnus-summary-kill-process-mark ()
4922 "Push the current set of process marked articles on the stack and unmark."
4924 (gnus-summary-save-process-mark)
4925 (gnus-summary-unmark-all-processable))
4927 (defun gnus-summary-yank-process-mark ()
4928 "Pop the last process mark state off the stack and restore it."
4930 (unless gnus-newsgroup-process-stack
4931 (error "Empty mark stack"))
4932 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4934 (defun gnus-summary-process-mark-set (set)
4935 "Make SET into the current process marked articles."
4936 (gnus-summary-unmark-all-processable)
4938 (gnus-summary-set-process-mark (pop set))))
4940 ;;; Searching and stuff
4942 (defun gnus-summary-search-group (&optional backward use-level)
4943 "Search for next unread newsgroup.
4944 If optional argument BACKWARD is non-nil, search backward instead."
4946 (set-buffer gnus-group-buffer)
4947 (when (gnus-group-search-forward
4948 backward nil (if use-level (gnus-group-group-level) nil))
4949 (gnus-group-group-name))))
4951 (defun gnus-summary-best-group (&optional exclude-group)
4952 "Find the name of the best unread group.
4953 If EXCLUDE-GROUP, do not go to this group."
4955 (set-buffer gnus-group-buffer)
4957 (gnus-group-best-unread-group exclude-group))))
4959 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4960 (if backward (gnus-summary-find-prev)
4961 (let* ((dummy (gnus-summary-article-intangible-p))
4962 (article (or article (gnus-summary-article-number)))
4963 (arts (gnus-data-find-list article))
4965 (when (and (not dummy)
4966 (or (not gnus-summary-check-current)
4968 (not (gnus-data-unread-p (car arts)))))
4969 (setq arts (cdr arts)))
4974 (when (or (and undownloaded
4975 (eq gnus-undownloaded-mark
4976 (gnus-data-mark (car arts))))
4977 (gnus-data-unread-p (car arts)))
4978 (setq result (car arts)
4980 (setq arts (cdr arts)))
4983 (goto-char (gnus-data-pos result))
4984 (gnus-data-number result)))))
4986 (defun gnus-summary-find-prev (&optional unread article)
4987 (let* ((eobp (eobp))
4988 (article (or article (gnus-summary-article-number)))
4989 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4991 (when (and (not eobp)
4992 (or (not gnus-summary-check-current)
4994 (not (gnus-data-unread-p (car arts)))))
4995 (setq arts (cdr arts)))
5000 (when (gnus-data-unread-p (car arts))
5001 (setq result (car arts)
5003 (setq arts (cdr arts)))
5006 (goto-char (gnus-data-pos result))
5007 (gnus-data-number result))))
5009 (defun gnus-summary-find-subject (subject &optional unread backward article)
5010 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5011 (article (or article (gnus-summary-article-number)))
5012 (articles (gnus-data-list backward))
5013 (arts (gnus-data-find-list article articles))
5015 (when (or (not gnus-summary-check-current)
5017 (not (gnus-data-unread-p (car arts))))
5018 (setq arts (cdr arts)))
5020 (and (or (not unread)
5021 (gnus-data-unread-p (car arts)))
5022 (vectorp (gnus-data-header (car arts)))
5024 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5025 (setq result (car arts)
5027 (setq arts (cdr arts)))
5029 (goto-char (gnus-data-pos result))
5030 (gnus-data-number result))))
5032 (defun gnus-summary-search-forward (&optional unread subject backward)
5033 "Search forward for an article.
5034 If UNREAD, look for unread articles. If SUBJECT, look for
5035 articles with that subject. If BACKWARD, search backward instead."
5036 (cond (subject (gnus-summary-find-subject subject unread backward))
5037 (backward (gnus-summary-find-prev unread))
5038 (t (gnus-summary-find-next unread))))
5040 (defun gnus-recenter (&optional n)
5041 "Center point in window and redisplay frame.
5042 Also do horizontal recentering."
5044 (when (and gnus-auto-center-summary
5045 (not (eq gnus-auto-center-summary 'vertical)))
5046 (gnus-horizontal-recenter))
5049 (defun gnus-summary-recenter ()
5050 "Center point in the summary window.
5051 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5052 displayed, no centering will be performed."
5053 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5054 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5055 (let* ((top (cond ((< (window-height) 4) 0)
5056 ((< (window-height) 7) 1)
5057 (t (if (numberp gnus-auto-center-summary)
5058 gnus-auto-center-summary
5060 (height (1- (window-height)))
5061 (bottom (save-excursion (goto-char (point-max))
5062 (forward-line (- height))
5064 (window (get-buffer-window (current-buffer))))
5065 ;; The user has to want it.
5066 (when gnus-auto-center-summary
5067 (when (get-buffer-window gnus-article-buffer)
5068 ;; Only do recentering when the article buffer is displayed,
5069 ;; Set the window start to either `bottom', which is the biggest
5070 ;; possible valid number, or the second line from the top,
5071 ;; whichever is the least.
5073 window (min bottom (save-excursion
5074 (forward-line (- top)) (point)))))
5075 ;; Do horizontal recentering while we're at it.
5076 (when (and (get-buffer-window (current-buffer) t)
5077 (not (eq gnus-auto-center-summary 'vertical)))
5078 (let ((selected (selected-window)))
5079 (select-window (get-buffer-window (current-buffer) t))
5080 (gnus-summary-position-point)
5081 (gnus-horizontal-recenter)
5082 (select-window selected))))))
5084 (defun gnus-summary-jump-to-group (newsgroup)
5085 "Move point to NEWSGROUP in group mode buffer."
5086 ;; Keep update point of group mode buffer if visible.
5087 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5088 (save-window-excursion
5089 ;; Take care of tree window mode.
5090 (when (get-buffer-window gnus-group-buffer)
5091 (pop-to-buffer gnus-group-buffer))
5092 (gnus-group-jump-to-group newsgroup))
5094 ;; Take care of tree window mode.
5095 (if (get-buffer-window gnus-group-buffer)
5096 (pop-to-buffer gnus-group-buffer)
5097 (set-buffer gnus-group-buffer))
5098 (gnus-group-jump-to-group newsgroup))))
5100 ;; This function returns a list of article numbers based on the
5101 ;; difference between the ranges of read articles in this group and
5102 ;; the range of active articles.
5103 (defun gnus-list-of-unread-articles (group)
5104 (let* ((read (gnus-info-read (gnus-get-info group)))
5105 (active (or (gnus-active group) (gnus-activate-group group)))
5108 ;; If none are read, then all are unread.
5110 (setq first (car active))
5111 ;; If the range of read articles is a single range, then the
5112 ;; first unread article is the article after the last read
5113 ;; article. Sounds logical, doesn't it?
5114 (if (not (listp (cdr read)))
5115 (setq first (max (car active) (1+ (cdr read))))
5116 ;; `read' is a list of ranges.
5117 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5120 (setq first (car active)))
5123 (while (< first nlast)
5125 (setq first (1+ first))))
5126 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5127 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5128 (setq read (cdr read)))))
5129 ;; And add the last unread articles.
5130 (while (<= first last)
5132 (setq first (1+ first)))
5133 ;; Return the list of unread articles.
5134 (delq 0 (nreverse unread))))
5136 (defun gnus-list-of-read-articles (group)
5137 "Return a list of unread, unticked and non-dormant articles."
5138 (let* ((info (gnus-get-info group))
5139 (marked (gnus-info-marks info))
5140 (active (gnus-active group)))
5142 (gnus-set-difference
5143 (gnus-sorted-complement
5144 (gnus-uncompress-range active)
5145 (gnus-list-of-unread-articles group))
5147 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5148 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5150 ;; Various summary commands
5152 (defun gnus-summary-select-article-buffer ()
5153 "Reconfigure windows to show article buffer."
5155 (if (not (gnus-buffer-live-p gnus-article-buffer))
5156 (error "There is no article buffer for this summary buffer")
5157 (gnus-configure-windows 'article)
5158 (select-window (get-buffer-window gnus-article-buffer))))
5160 (defun gnus-summary-universal-argument (arg)
5161 "Perform any operation on all articles that are process/prefixed."
5163 (let ((articles (gnus-summary-work-articles arg))
5170 (substitute-command-keys
5171 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5174 (gnus-error 1 "Undefined key")
5177 (gnus-summary-goto-subject (setq article (pop articles)))
5178 (let (gnus-newsgroup-processable)
5179 (command-execute func))
5180 (gnus-summary-remove-process-mark article)))))
5181 (gnus-summary-position-point))
5183 (defun gnus-summary-toggle-truncation (&optional arg)
5184 "Toggle truncation of summary lines.
5185 With arg, turn line truncation on iff arg is positive."
5187 (setq truncate-lines
5188 (if (null arg) (not truncate-lines)
5189 (> (prefix-numeric-value arg) 0)))
5192 (defun gnus-summary-reselect-current-group (&optional all rescan)
5193 "Rescan the current newsgroup, exit and then reselect it.
5194 The prefix argument ALL means to select all articles."
5196 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5197 (error "Ephemeral groups can't be reselected"))
5198 (let ((current-subject (gnus-summary-article-number))
5199 (group gnus-newsgroup-name))
5201 (set-buffer gnus-group-buffer)
5202 ;; We have to adjust the point of group mode buffer because
5203 ;; point was moved to the next unread newsgroup by exiting.
5204 (gnus-summary-jump-to-group group)
5207 (gnus-group-get-new-news-this-group 1))))
5208 (setq gnus-newsgroup-begin nil)
5210 (gnus-group-read-group all t group)
5211 (gnus-summary-goto-subject current-subject nil t)))
5213 (defun gnus-summary-rescan-group (&optional all)
5214 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5216 (gnus-summary-reselect-current-group all t))
5218 (defun gnus-summary-update-info (&optional non-destructive)
5220 (let ((group gnus-newsgroup-name))
5222 (when gnus-newsgroup-kill-headers
5223 (setq gnus-newsgroup-killed
5224 (gnus-compress-sequence
5226 (gnus-set-sorted-intersection
5227 (gnus-uncompress-range gnus-newsgroup-killed)
5228 (setq gnus-newsgroup-unselected
5229 (sort gnus-newsgroup-unselected '<)))
5230 (setq gnus-newsgroup-unreads
5231 (sort gnus-newsgroup-unreads '<)))
5233 (unless (listp (cdr gnus-newsgroup-killed))
5234 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5235 (let ((headers gnus-newsgroup-headers))
5236 ;; Set the new ranges of read articles.
5238 (set-buffer gnus-group-buffer)
5239 (gnus-undo-force-boundary))
5240 (gnus-update-read-articles
5241 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5242 ;; Set the current article marks.
5243 (let ((gnus-newsgroup-scored
5244 (if (and (not gnus-save-score)
5245 (not non-destructive))
5247 gnus-newsgroup-scored)))
5249 (gnus-update-marks)))
5250 ;; Do the cross-ref thing.
5251 (when gnus-use-cross-reference
5252 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5253 ;; Do not switch windows but change the buffer to work.
5254 (set-buffer gnus-group-buffer)
5255 (unless (gnus-ephemeral-group-p group)
5256 (gnus-group-update-group group)))))))
5258 (defun gnus-summary-save-newsrc (&optional force)
5259 "Save the current number of read/marked articles in the dribble buffer.
5260 The dribble buffer will then be saved.
5261 If FORCE (the prefix), also save the .newsrc file(s)."
5263 (gnus-summary-update-info t)
5265 (gnus-save-newsrc-file)
5266 (gnus-dribble-save)))
5268 (defun gnus-summary-exit (&optional temporary)
5269 "Exit reading current newsgroup, and then return to group selection mode.
5270 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5272 (gnus-set-global-variables)
5273 (gnus-kill-save-kill-buffer)
5274 (gnus-async-halt-prefetch)
5275 (let* ((group gnus-newsgroup-name)
5276 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5279 (buf (current-buffer)))
5281 ;; Do adaptive scoring, and possibly save score files.
5282 (when gnus-newsgroup-adaptive
5283 (gnus-score-adaptive))
5284 (when gnus-use-scoring
5286 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5287 ;; If we have several article buffers, we kill them at exit.
5288 (unless gnus-single-article-buffer
5289 (gnus-kill-buffer gnus-original-article-buffer)
5290 (setq gnus-article-current nil))
5291 (when gnus-use-cache
5292 (gnus-cache-possibly-remove-articles)
5293 (gnus-cache-save-buffers))
5294 (gnus-async-prefetch-remove-group group)
5295 (when gnus-suppress-duplicates
5296 (gnus-dup-enter-articles))
5297 (when gnus-use-trees
5298 (gnus-tree-close group))
5299 ;; Remove entries for this group.
5300 (nnmail-purge-split-history (gnus-group-real-name group))
5301 ;; Make all changes in this group permanent.
5303 (gnus-run-hooks 'gnus-exit-group-hook)
5304 (gnus-summary-update-info))
5305 (gnus-close-group group)
5306 ;; Make sure where we were, and go to next newsgroup.
5307 (set-buffer gnus-group-buffer)
5309 (gnus-group-jump-to-group group))
5310 (gnus-run-hooks 'gnus-summary-exit-hook)
5311 (unless (or quit-config
5312 ;; If this group has disappeared from the summary
5313 ;; buffer, don't skip forwards.
5314 (not (string= group (gnus-group-group-name))))
5315 (gnus-group-next-unread-group 1))
5316 (setq group-point (point))
5319 ;; If we have several article buffers, we kill them at exit.
5320 (unless gnus-single-article-buffer
5321 (gnus-kill-buffer gnus-article-buffer)
5322 (gnus-kill-buffer gnus-original-article-buffer)
5323 (setq gnus-article-current nil))
5325 (if (not gnus-kill-summary-on-exit)
5326 (gnus-deaden-summary)
5327 ;; We set all buffer-local variables to nil. It is unclear why
5328 ;; this is needed, but if we don't, buffer-local variables are
5329 ;; not garbage-collected, it seems. This would the lead to en
5330 ;; ever-growing Emacs.
5331 (gnus-summary-clear-local-variables)
5332 (when (get-buffer gnus-article-buffer)
5333 (bury-buffer gnus-article-buffer))
5334 ;; We clear the global counterparts of the buffer-local
5335 ;; variables as well, just to be on the safe side.
5336 (set-buffer gnus-group-buffer)
5337 (gnus-summary-clear-local-variables)
5338 ;; Return to group mode buffer.
5339 (when (eq mode 'gnus-summary-mode)
5340 (gnus-kill-buffer buf)))
5341 (setq gnus-current-select-method gnus-select-method)
5342 (pop-to-buffer gnus-group-buffer)
5343 (if (not quit-config)
5345 (goto-char group-point)
5346 (gnus-configure-windows 'group 'force))
5347 (gnus-handle-ephemeral-exit quit-config))
5348 ;; Clear the current group name.
5350 (setq gnus-newsgroup-name nil)))))
5352 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5353 (defun gnus-summary-exit-no-update (&optional no-questions)
5354 "Quit reading current newsgroup without updating read article info."
5356 (let* ((group gnus-newsgroup-name)
5357 (quit-config (gnus-group-quit-config group)))
5358 (when (or no-questions
5360 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5361 (gnus-async-halt-prefetch)
5363 (delq 'gnus-summary-expire-articles
5364 (copy-list gnus-summary-prepare-exit-hook)))
5365 ;; If we have several article buffers, we kill them at exit.
5366 (unless gnus-single-article-buffer
5367 (gnus-kill-buffer gnus-article-buffer)
5368 (gnus-kill-buffer gnus-original-article-buffer)
5369 (setq gnus-article-current nil))
5370 (if (not gnus-kill-summary-on-exit)
5371 (gnus-deaden-summary)
5372 (gnus-close-group group)
5373 (gnus-summary-clear-local-variables)
5374 (set-buffer gnus-group-buffer)
5375 (gnus-summary-clear-local-variables)
5376 (when (get-buffer gnus-summary-buffer)
5377 (kill-buffer gnus-summary-buffer)))
5378 (unless gnus-single-article-buffer
5379 (setq gnus-article-current nil))
5380 (when gnus-use-trees
5381 (gnus-tree-close group))
5382 (gnus-async-prefetch-remove-group group)
5383 (when (get-buffer gnus-article-buffer)
5384 (bury-buffer gnus-article-buffer))
5385 ;; Return to the group buffer.
5386 (gnus-configure-windows 'group 'force)
5387 ;; Clear the current group name.
5388 (setq gnus-newsgroup-name nil)
5389 (when (equal (gnus-group-group-name) group)
5390 (gnus-group-next-unread-group 1))
5392 (gnus-handle-ephemeral-exit quit-config)))))
5394 (defun gnus-handle-ephemeral-exit (quit-config)
5395 "Handle movement when leaving an ephemeral group.
5396 The state which existed when entering the ephemeral is reset."
5397 (if (not (buffer-name (car quit-config)))
5398 (gnus-configure-windows 'group 'force)
5399 (set-buffer (car quit-config))
5400 (cond ((eq major-mode 'gnus-summary-mode)
5401 (gnus-set-global-variables))
5402 ((eq major-mode 'gnus-article-mode)
5404 ;; The `gnus-summary-buffer' variable may point
5405 ;; to the old summary buffer when using a single
5407 (unless (gnus-buffer-live-p gnus-summary-buffer)
5408 (set-buffer gnus-group-buffer))
5409 (set-buffer gnus-summary-buffer)
5410 (gnus-set-global-variables))))
5411 (if (or (eq (cdr quit-config) 'article)
5412 (eq (cdr quit-config) 'pick))
5414 ;; The current article may be from the ephemeral group
5415 ;; thus it is best that we reload this article
5416 (gnus-summary-show-article)
5417 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5418 (gnus-configure-windows 'pick 'force)
5419 (gnus-configure-windows (cdr quit-config) 'force)))
5420 (gnus-configure-windows (cdr quit-config) 'force))
5421 (when (eq major-mode 'gnus-summary-mode)
5422 (gnus-summary-next-subject 1 nil t)
5423 (gnus-summary-recenter)
5424 (gnus-summary-position-point))))
5426 (defun gnus-summary-preview-mime-message ()
5427 "MIME decode and play this message."
5429 (let ((gnus-break-pages nil)
5431 (gnus-summary-select-article gnus-show-all-headers t))
5432 (select-window (get-buffer-window gnus-article-buffer)))
5436 (defvar gnus-dead-summary-mode-map nil)
5438 (unless gnus-dead-summary-mode-map
5439 (setq gnus-dead-summary-mode-map (make-keymap))
5440 (suppress-keymap gnus-dead-summary-mode-map)
5441 (substitute-key-definition
5442 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5443 (let ((keys '("\C-d" "\r" "\177" [delete])))
5445 (define-key gnus-dead-summary-mode-map
5446 (pop keys) 'gnus-summary-wake-up-the-dead))))
5448 (defvar gnus-dead-summary-mode nil
5449 "Minor mode for Gnus summary buffers.")
5451 (defun gnus-dead-summary-mode (&optional arg)
5452 "Minor mode for Gnus summary buffers."
5454 (when (eq major-mode 'gnus-summary-mode)
5455 (make-local-variable 'gnus-dead-summary-mode)
5456 (setq gnus-dead-summary-mode
5457 (if (null arg) (not gnus-dead-summary-mode)
5458 (> (prefix-numeric-value arg) 0)))
5459 (when gnus-dead-summary-mode
5460 (gnus-add-minor-mode
5461 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5463 (defun gnus-deaden-summary ()
5464 "Make the current summary buffer into a dead summary buffer."
5465 ;; Kill any previous dead summary buffer.
5466 (when (and gnus-dead-summary
5467 (buffer-name gnus-dead-summary))
5469 (set-buffer gnus-dead-summary)
5470 (when gnus-dead-summary-mode
5471 (kill-buffer (current-buffer)))))
5472 ;; Make this the current dead summary.
5473 (setq gnus-dead-summary (current-buffer))
5474 (gnus-dead-summary-mode 1)
5475 (let ((name (buffer-name)))
5476 (when (string-match "Summary" name)
5478 (concat (substring name 0 (match-beginning 0)) "Dead "
5479 (substring name (match-beginning 0)))
5482 (defun gnus-kill-or-deaden-summary (buffer)
5483 "Kill or deaden the summary BUFFER."
5485 (when (and (buffer-name buffer)
5486 (not gnus-single-article-buffer))
5489 (gnus-kill-buffer gnus-article-buffer)
5490 (gnus-kill-buffer gnus-original-article-buffer)))
5491 (cond (gnus-kill-summary-on-exit
5492 (when (and gnus-use-trees
5493 (gnus-buffer-exists-p buffer))
5496 (gnus-tree-close gnus-newsgroup-name)))
5497 (gnus-kill-buffer buffer))
5498 ((gnus-buffer-exists-p buffer)
5501 (gnus-deaden-summary))))))
5503 (defun gnus-summary-wake-up-the-dead (&rest args)
5504 "Wake up the dead summary buffer."
5506 (gnus-dead-summary-mode -1)
5507 (let ((name (buffer-name)))
5508 (when (string-match "Dead " name)
5510 (concat (substring name 0 (match-beginning 0))
5511 (substring name (match-end 0)))
5513 (gnus-message 3 "This dead summary is now alive again"))
5515 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5516 (defun gnus-summary-fetch-faq (&optional faq-dir)
5517 "Fetch the FAQ for the current group.
5518 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5522 (when current-prefix-arg
5524 "Faq dir: " (and (listp gnus-group-faq-directory)
5525 (mapcar (lambda (file) (list file))
5526 gnus-group-faq-directory))))))
5527 (let (gnus-faq-buffer)
5528 (when (setq gnus-faq-buffer
5529 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5530 (gnus-configure-windows 'summary-faq))))
5532 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5533 (defun gnus-summary-describe-group (&optional force)
5534 "Describe the current newsgroup."
5536 (gnus-group-describe-group force gnus-newsgroup-name))
5538 (defun gnus-summary-describe-briefly ()
5539 "Describe summary mode commands briefly."
5541 (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")))
5543 ;; Walking around group mode buffer from summary mode.
5545 (defun gnus-summary-next-group (&optional no-article target-group backward)
5546 "Exit current newsgroup and then select next unread newsgroup.
5547 If prefix argument NO-ARTICLE is non-nil, no article is selected
5548 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5549 previous group instead."
5551 ;; Stop pre-fetching.
5552 (gnus-async-halt-prefetch)
5553 (let ((current-group gnus-newsgroup-name)
5554 (current-buffer (current-buffer))
5556 ;; First we semi-exit this group to update Xrefs and all variables.
5557 ;; We can't do a real exit, because the window conf must remain
5558 ;; the same in case the user is prompted for info, and we don't
5559 ;; want the window conf to change before that...
5560 (gnus-summary-exit t)
5561 (while (not entered)
5562 ;; Then we find what group we are supposed to enter.
5563 (set-buffer gnus-group-buffer)
5564 (gnus-group-jump-to-group current-group)
5567 (if (eq gnus-keep-same-level 'best)
5568 (gnus-summary-best-group gnus-newsgroup-name)
5569 (gnus-summary-search-group backward gnus-keep-same-level))))
5570 (if (not target-group)
5571 ;; There are no further groups, so we return to the group
5574 (gnus-message 5 "Returning to the group buffer")
5576 (when (gnus-buffer-live-p current-buffer)
5577 (set-buffer current-buffer)
5578 (gnus-summary-exit))
5579 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5580 ;; We try to enter the target group.
5581 (gnus-group-jump-to-group target-group)
5582 (let ((unreads (gnus-group-group-unread)))
5583 (if (and (or (eq t unreads)
5584 (and unreads (not (zerop unreads))))
5585 (gnus-summary-read-group
5586 target-group nil no-article
5587 (and (buffer-name current-buffer) current-buffer)
5590 (setq current-group target-group
5591 target-group nil)))))))
5593 (defun gnus-summary-prev-group (&optional no-article)
5594 "Exit current newsgroup and then select previous unread newsgroup.
5595 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5597 (gnus-summary-next-group no-article nil t))
5599 ;; Walking around summary lines.
5601 (defun gnus-summary-first-subject (&optional unread undownloaded)
5602 "Go to the first unread subject.
5603 If UNREAD is non-nil, go to the first unread article.
5604 Returns the article selected or nil if there are no unread articles."
5609 ((null gnus-newsgroup-data)
5610 (gnus-message 3 "No articles in the group")
5612 ;; Pick the first article.
5614 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5615 (gnus-data-number (car gnus-newsgroup-data)))
5616 ;; No unread articles.
5617 ((null gnus-newsgroup-unreads)
5618 (gnus-message 3 "No more unread articles")
5620 ;; Find the first unread article.
5622 (let ((data gnus-newsgroup-data))
5624 (and (not (and undownloaded
5625 (eq gnus-undownloaded-mark
5626 (gnus-data-mark (car data)))))
5627 (not (gnus-data-unread-p (car data)))))
5628 (setq data (cdr data)))
5630 (goto-char (gnus-data-pos (car data)))
5631 (gnus-data-number (car data))))))
5632 (gnus-summary-position-point)))
5634 (defun gnus-summary-next-subject (n &optional unread dont-display)
5635 "Go to next N'th summary line.
5636 If N is negative, go to the previous N'th subject line.
5637 If UNREAD is non-nil, only unread articles are selected.
5638 The difference between N and the actual number of steps taken is
5641 (let ((backward (< n 0))
5645 (gnus-summary-find-prev unread)
5646 (gnus-summary-find-next unread)))
5647 (gnus-summary-show-thread)
5650 (gnus-message 7 "No more%s articles"
5651 (if unread " unread" "")))
5652 (unless dont-display
5653 (gnus-summary-recenter)
5654 (gnus-summary-position-point))
5657 (defun gnus-summary-next-unread-subject (n)
5658 "Go to next N'th unread summary line."
5660 (gnus-summary-next-subject n t))
5662 (defun gnus-summary-prev-subject (n &optional unread)
5663 "Go to previous N'th summary line.
5664 If optional argument UNREAD is non-nil, only unread article is selected."
5666 (gnus-summary-next-subject (- n) unread))
5668 (defun gnus-summary-prev-unread-subject (n)
5669 "Go to previous N'th unread summary line."
5671 (gnus-summary-next-subject (- n) t))
5673 (defun gnus-summary-goto-subject (article &optional force silent)
5674 "Go the subject line of ARTICLE.
5675 If FORCE, also allow jumping to articles not currently shown."
5676 (interactive "nArticle number: ")
5678 (data (gnus-data-find article)))
5679 ;; We read in the article if we have to.
5682 (gnus-summary-insert-subject
5684 (if (or (numberp force) (vectorp force)) force)
5686 (setq data (gnus-data-find article)))
5691 (gnus-message 3 "Can't find article %d" article))
5693 (goto-char (gnus-data-pos data))
5694 (gnus-summary-position-point)
5697 ;; Walking around summary lines with displaying articles.
5699 (defun gnus-summary-expand-window (&optional arg)
5700 "Make the summary buffer take up the entire Emacs frame.
5701 Given a prefix, will force an `article' buffer configuration."
5704 (gnus-configure-windows 'article 'force)
5705 (gnus-configure-windows 'summary 'force)))
5707 (defun gnus-summary-display-article (article &optional all-header)
5708 "Display ARTICLE in article buffer."
5709 (gnus-set-global-variables)
5713 (if gnus-summary-display-article-function
5714 (funcall gnus-summary-display-article-function article all-header)
5715 (gnus-article-prepare article all-header))
5716 (gnus-run-hooks 'gnus-select-article-hook)
5717 (when (and gnus-current-article
5718 (not (zerop gnus-current-article)))
5719 (gnus-summary-goto-subject gnus-current-article))
5720 (gnus-summary-recenter)
5721 (when (and gnus-use-trees gnus-show-threads)
5722 (gnus-possibly-generate-tree article)
5723 (gnus-highlight-selected-tree article))
5724 ;; Successfully display article.
5725 (gnus-article-set-window-start
5726 (cdr (assq article gnus-newsgroup-bookmarks))))))
5728 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5729 "Select the current article.
5730 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5731 non-nil, the article will be re-fetched even if it already present in
5732 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5734 ;; Make sure we are in the summary buffer to work around bbdb bug.
5735 (unless (eq major-mode 'gnus-summary-mode)
5736 (set-buffer gnus-summary-buffer))
5737 (let ((article (or article (gnus-summary-article-number)))
5738 (all-headers (not (not all-headers))) ;Must be T or NIL.
5739 gnus-summary-display-article-function
5742 (gnus-summary-article-pseudo-p article)
5743 (error "This is a pseudo-article"))
5746 (set-buffer gnus-summary-buffer)
5747 (if (or (and gnus-single-article-buffer
5748 (or (null gnus-current-article)
5749 (null gnus-article-current)
5750 (null (get-buffer gnus-article-buffer))
5751 (not (eq article (cdr gnus-article-current)))
5752 (not (equal (car gnus-article-current)
5753 gnus-newsgroup-name))))
5754 (and (not gnus-single-article-buffer)
5755 (or (null gnus-current-article)
5756 (not (eq gnus-current-article article))))
5758 ;; The requested article is different from the current article.
5760 (gnus-summary-display-article article all-headers)
5762 (when (or all-headers gnus-show-all-headers)
5763 (gnus-article-show-all-headers)))
5764 (when (or all-headers gnus-show-all-headers)
5765 (gnus-article-show-all-headers))
5768 (gnus-article-set-window-start
5769 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5771 (defun gnus-summary-set-current-mark (&optional current-mark)
5772 "Obsolete function."
5775 (defun gnus-summary-next-article (&optional unread subject backward push)
5776 "Select the next article.
5777 If UNREAD, only unread articles are selected.
5778 If SUBJECT, only articles with SUBJECT are selected.
5779 If BACKWARD, the previous article is selected instead of the next."
5782 ;; Is there such an article?
5783 ((and (gnus-summary-search-forward unread subject backward)
5784 (or (gnus-summary-display-article (gnus-summary-article-number))
5785 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5786 (gnus-summary-position-point))
5787 ;; If not, we try the first unread, if that is wanted.
5789 gnus-auto-select-same
5790 (gnus-summary-first-unread-article))
5791 (gnus-summary-position-point)
5792 (gnus-message 6 "Wrapped"))
5793 ;; Try to get next/previous article not displayed in this group.
5794 ((and gnus-auto-extend-newsgroup
5795 (not unread) (not subject))
5796 (gnus-summary-goto-article
5797 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5798 nil (count-lines (point-min) (point))))
5799 ;; Go to next/previous group.
5801 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5802 (gnus-summary-jump-to-group gnus-newsgroup-name))
5803 (let ((cmd last-command-char)
5806 (set-buffer gnus-group-buffer)
5809 (if (eq gnus-keep-same-level 'best)
5810 (gnus-summary-best-group gnus-newsgroup-name)
5811 (gnus-summary-search-group backward gnus-keep-same-level))))
5812 ;; For some reason, the group window gets selected. We change
5814 (select-window (get-buffer-window (current-buffer)))
5815 ;; Select next unread newsgroup automagically.
5817 ((or (not gnus-auto-select-next)
5819 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5820 ((or (eq gnus-auto-select-next 'quietly)
5821 (and (eq gnus-auto-select-next 'slightly-quietly)
5823 (and (eq gnus-auto-select-next 'almost-quietly)
5824 (gnus-summary-last-article-p)))
5826 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5828 (gnus-message 7 "No more%s articles (%s)..."
5829 (if unread " unread" "")
5830 (if group (concat "selecting " group)
5832 (gnus-summary-next-group nil group backward)))
5834 (when (gnus-key-press-event-p last-input-event)
5835 (gnus-summary-walk-group-buffer
5836 gnus-newsgroup-name cmd unread backward point))))))))
5838 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5839 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5840 (?\C-p (gnus-group-prev-unread-group 1))))
5841 (cursor-in-echo-area t)
5842 keve key group ended)
5844 (set-buffer gnus-group-buffer)
5847 (if (eq gnus-keep-same-level 'best)
5848 (gnus-summary-best-group gnus-newsgroup-name)
5849 (gnus-summary-search-group backward gnus-keep-same-level))))
5852 5 "No more%s articles%s" (if unread " unread" "")
5854 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5855 (format " (Type %s for %s [%s])"
5856 (single-key-description cmd) group
5857 (car (gnus-gethash group gnus-newsrc-hashtb)))
5858 (format " (Type %s to exit %s)"
5859 (single-key-description cmd)
5860 gnus-newsgroup-name)))
5861 ;; Confirm auto selection.
5862 (setq key (car (setq keve (gnus-read-event-char))))
5865 ((assq key keystrokes)
5866 (let ((obuf (current-buffer)))
5867 (switch-to-buffer gnus-group-buffer)
5869 (gnus-group-jump-to-group group))
5870 (eval (cadr (assq key keystrokes)))
5871 (setq group (gnus-group-group-name))
5872 (switch-to-buffer obuf))
5876 (gnus-ephemeral-group-p gnus-newsgroup-name))
5878 (gnus-summary-next-group nil group backward)))
5880 (push (cdr keve) unread-command-events))))))
5882 (defun gnus-summary-next-unread-article ()
5883 "Select unread article after current one."
5885 (gnus-summary-next-article
5886 (or (not (eq gnus-summary-goto-unread 'never))
5887 (gnus-summary-last-article-p (gnus-summary-article-number)))
5888 (and gnus-auto-select-same
5889 (gnus-summary-article-subject))))
5891 (defun gnus-summary-prev-article (&optional unread subject)
5892 "Select the article after the current one.
5893 If UNREAD is non-nil, only unread articles are selected."
5895 (gnus-summary-next-article unread subject t))
5897 (defun gnus-summary-prev-unread-article ()
5898 "Select unread article before current one."
5900 (gnus-summary-prev-article
5901 (or (not (eq gnus-summary-goto-unread 'never))
5902 (gnus-summary-first-article-p (gnus-summary-article-number)))
5903 (and gnus-auto-select-same
5904 (gnus-summary-article-subject))))
5906 (defun gnus-summary-next-page (&optional lines circular)
5907 "Show next page of the selected article.
5908 If at the end of the current article, select the next article.
5909 LINES says how many lines should be scrolled up.
5911 If CIRCULAR is non-nil, go to the start of the article instead of
5912 selecting the next article when reaching the end of the current
5915 (setq gnus-summary-buffer (current-buffer))
5916 (gnus-set-global-variables)
5917 (let ((article (gnus-summary-article-number))
5918 (article-window (get-buffer-window gnus-article-buffer t))
5920 ;; If the buffer is empty, we have no article.
5922 (error "No article to select"))
5923 (gnus-configure-windows 'article)
5924 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5925 (if (and (eq gnus-summary-goto-unread 'never)
5926 (not (gnus-summary-last-article-p article)))
5927 (gnus-summary-next-article)
5928 (gnus-summary-next-unread-article))
5929 (if (or (null gnus-current-article)
5930 (null gnus-article-current)
5931 (/= article (cdr gnus-article-current))
5932 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5933 ;; Selected subject is different from current article's.
5934 (gnus-summary-display-article article)
5935 (when article-window
5936 (gnus-eval-in-buffer-window gnus-article-buffer
5937 (setq endp (gnus-article-next-page lines)))
5940 (gnus-summary-beginning-of-article))
5942 (gnus-message 3 "End of message"))
5944 (if (and (eq gnus-summary-goto-unread 'never)
5945 (not (gnus-summary-last-article-p article)))
5946 (gnus-summary-next-article)
5947 (gnus-summary-next-unread-article))))))))
5948 (gnus-summary-recenter)
5949 (gnus-summary-position-point)))
5951 (defun gnus-summary-prev-page (&optional lines move)
5952 "Show previous page of selected article.
5953 Argument LINES specifies lines to be scrolled down.
5954 If MOVE, move to the previous unread article if point is at
5955 the beginning of the buffer."
5957 (let ((article (gnus-summary-article-number))
5958 (article-window (get-buffer-window gnus-article-buffer t))
5960 (gnus-configure-windows 'article)
5961 (if (or (null gnus-current-article)
5962 (null gnus-article-current)
5963 (/= article (cdr gnus-article-current))
5964 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5965 ;; Selected subject is different from current article's.
5966 (gnus-summary-display-article article)
5967 (gnus-summary-recenter)
5968 (when article-window
5969 (gnus-eval-in-buffer-window gnus-article-buffer
5970 (setq endp (gnus-article-prev-page lines)))
5971 (when (and move endp)
5973 (gnus-message 3 "Beginning of message"))
5975 (if (and (eq gnus-summary-goto-unread 'never)
5976 (not (gnus-summary-first-article-p article)))
5977 (gnus-summary-prev-article)
5978 (gnus-summary-prev-unread-article))))))))
5979 (gnus-summary-position-point))
5981 (defun gnus-summary-prev-page-or-article (&optional lines)
5982 "Show previous page of selected article.
5983 Argument LINES specifies lines to be scrolled down.
5984 If at the beginning of the article, go to the next article."
5986 (gnus-summary-prev-page lines t))
5988 (defun gnus-summary-scroll-up (lines)
5989 "Scroll up (or down) one line current article.
5990 Argument LINES specifies lines to be scrolled up (or down if negative)."
5992 (gnus-configure-windows 'article)
5993 (gnus-summary-show-thread)
5994 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5995 (gnus-eval-in-buffer-window gnus-article-buffer
5997 (when (gnus-article-next-page lines)
5998 (gnus-message 3 "End of message")))
6000 (gnus-article-prev-page (- lines))))))
6001 (gnus-summary-recenter)
6002 (gnus-summary-position-point))
6004 (defun gnus-summary-scroll-down (lines)
6005 "Scroll down (or up) one line current article.
6006 Argument LINES specifies lines to be scrolled down (or up if negative)."
6008 (gnus-summary-scroll-up (- lines)))
6010 (defun gnus-summary-next-same-subject ()
6011 "Select next article which has the same subject as current one."
6013 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6015 (defun gnus-summary-prev-same-subject ()
6016 "Select previous article which has the same subject as current one."
6018 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6020 (defun gnus-summary-next-unread-same-subject ()
6021 "Select next unread article which has the same subject as current one."
6023 (gnus-summary-next-article t (gnus-summary-article-subject)))
6025 (defun gnus-summary-prev-unread-same-subject ()
6026 "Select previous unread article which has the same subject as current one."
6028 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6030 (defun gnus-summary-first-unread-article ()
6031 "Select the first unread article.
6032 Return nil if there are no unread articles."
6035 (when (gnus-summary-first-subject t)
6036 (gnus-summary-show-thread)
6037 (gnus-summary-first-subject t)
6038 (gnus-summary-display-article (gnus-summary-article-number)))
6039 (gnus-summary-position-point)))
6041 (defun gnus-summary-first-unread-subject ()
6042 "Place the point on the subject line of the first unread article.
6043 Return nil if there are no unread articles."
6046 (when (gnus-summary-first-subject t)
6047 (gnus-summary-show-thread)
6048 (gnus-summary-first-subject t))
6049 (gnus-summary-position-point)))
6051 (defun gnus-summary-first-article ()
6052 "Select the first article.
6053 Return nil if there are no articles."
6056 (when (gnus-summary-first-subject)
6057 (gnus-summary-show-thread)
6058 (gnus-summary-first-subject)
6059 (gnus-summary-display-article (gnus-summary-article-number)))
6060 (gnus-summary-position-point)))
6062 (defun gnus-summary-best-unread-article ()
6063 "Select the unread article with the highest score."
6065 (let ((best -1000000)
6066 (data gnus-newsgroup-data)
6069 (and (gnus-data-unread-p (car data))
6071 (gnus-summary-article-score (gnus-data-number (car data))))
6074 article (gnus-data-number (car data))))
6075 (setq data (cdr data)))
6078 (gnus-summary-goto-article article)
6079 (error "No unread articles"))
6080 (gnus-summary-position-point))))
6082 (defun gnus-summary-last-subject ()
6083 "Go to the last displayed subject line in the group."
6084 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6086 (gnus-summary-goto-subject article))))
6088 (defun gnus-summary-goto-article (article &optional all-headers force)
6089 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6090 If ALL-HEADERS is non-nil, no header lines are hidden.
6091 If FORCE, go to the article even if it isn't displayed. If FORCE
6092 is a number, it is the line the article is to be displayed on."
6096 "Article number or Message-ID: "
6097 (mapcar (lambda (number) (list (int-to-string number)))
6098 gnus-newsgroup-limit))
6102 (if (and (stringp article)
6103 (string-match "@" article))
6104 (gnus-summary-refer-article article)
6105 (when (stringp article)
6106 (setq article (string-to-number article)))
6107 (if (gnus-summary-goto-subject article force)
6108 (gnus-summary-display-article article all-headers)
6109 (gnus-message 4 "Couldn't go to article %s" article) nil))
6110 (gnus-summary-position-point)))
6112 (defun gnus-summary-goto-last-article ()
6113 "Go to the previously read article."
6116 (when gnus-last-article
6117 (gnus-summary-goto-article gnus-last-article nil t))
6118 (gnus-summary-position-point)))
6120 (defun gnus-summary-pop-article (number)
6121 "Pop one article off the history and go to the previous.
6122 NUMBER articles will be popped off."
6125 (setq gnus-newsgroup-history
6126 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6128 (gnus-summary-goto-article (car to) nil t)
6129 (error "Article history empty")))
6130 (gnus-summary-position-point))
6132 ;; Summary commands and functions for limiting the summary buffer.
6134 (defun gnus-summary-limit-to-articles (n)
6135 "Limit the summary buffer to the next N articles.
6136 If not given a prefix, use the process marked articles instead."
6139 (let ((articles (gnus-summary-work-articles n)))
6140 (setq gnus-newsgroup-processable nil)
6141 (gnus-summary-limit articles))
6142 (gnus-summary-position-point)))
6144 (defun gnus-summary-pop-limit (&optional total)
6145 "Restore the previous limit.
6146 If given a prefix, remove all limits."
6149 (setq gnus-newsgroup-limits
6150 (list (mapcar (lambda (h) (mail-header-number h))
6151 gnus-newsgroup-headers))))
6152 (unless gnus-newsgroup-limits
6153 (error "No limit to pop"))
6155 (gnus-summary-limit nil 'pop)
6156 (gnus-summary-position-point)))
6158 (defun gnus-summary-limit-to-subject (subject &optional header)
6159 "Limit the summary buffer to articles that have subjects that match a regexp."
6160 (interactive "sLimit to subject (regexp): ")
6162 (setq header "subject"))
6163 (when (not (equal "" subject))
6165 (let ((articles (gnus-summary-find-matching
6166 (or header "subject") subject 'all)))
6168 (error "Found no matches for \"%s\"" subject))
6169 (gnus-summary-limit articles))
6170 (gnus-summary-position-point))))
6172 (defun gnus-summary-limit-to-author (from)
6173 "Limit the summary buffer to articles that have authors that match a regexp."
6174 (interactive "sLimit to author (regexp): ")
6175 (gnus-summary-limit-to-subject from "from"))
6177 (defun gnus-summary-limit-to-age (age &optional younger-p)
6178 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6179 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6180 articles that are younger than AGE days."
6181 (interactive "nLimit to articles older than (in days): \nP")
6183 (let ((data gnus-newsgroup-data)
6184 (cutoff (days-to-time age))
6185 articles d date is-younger)
6186 (while (setq d (pop data))
6187 (when (and (vectorp (gnus-data-header d))
6188 (setq date (mail-header-date (gnus-data-header d))))
6189 (setq is-younger (time-less-p
6190 (time-since (date-to-time date))
6195 (push (gnus-data-number d) articles))))
6196 (gnus-summary-limit (nreverse articles)))
6197 (gnus-summary-position-point)))
6199 (defun gnus-summary-limit-to-extra (header regexp)
6200 "Limit the summary buffer to articles that match an 'extra' header."
6204 (gnus-completing-read
6205 (symbol-name (car gnus-extra-headers))
6206 "Score extra header:"
6208 (cons (symbol-name x) x))
6213 (read-string (format "Limit to header %s (regexp): " header)))))
6214 (when (not (equal "" regexp))
6216 (let ((articles (gnus-summary-find-matching
6217 (cons 'extra header) regexp 'all)))
6219 (error "Found no matches for \"%s\"" regexp))
6220 (gnus-summary-limit articles))
6221 (gnus-summary-position-point))))
6223 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6225 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6227 (defun gnus-summary-limit-to-unread (&optional all)
6228 "Limit the summary buffer to articles that are not marked as read.
6229 If ALL is non-nil, limit strictly to unread articles."
6232 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6233 (gnus-summary-limit-to-marks
6234 ;; Concat all the marks that say that an article is read and have
6236 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6237 gnus-killed-mark gnus-kill-file-mark
6238 gnus-low-score-mark gnus-expirable-mark
6239 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6240 gnus-duplicate-mark gnus-souped-mark)
6243 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6244 (make-obsolete 'gnus-summary-delete-marked-with
6245 'gnus-summary-limit-exlude-marks)
6247 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6248 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6249 If REVERSE, limit the summary buffer to articles that are marked
6250 with MARKS. MARKS can either be a string of marks or a list of marks.
6251 Returns how many articles were removed."
6252 (interactive "sMarks: ")
6253 (gnus-summary-limit-to-marks marks t))
6255 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6256 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6257 If REVERSE (the prefix), limit the summary buffer to articles that are
6258 not marked with MARKS. MARKS can either be a string of marks or a
6260 Returns how many articles were removed."
6261 (interactive "sMarks: \nP")
6263 (let ((data gnus-newsgroup-data)
6264 (marks (if (listp marks) marks
6265 (append marks nil))) ; Transform to list.
6268 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6269 (memq (gnus-data-mark (car data)) marks))
6270 (push (gnus-data-number (car data)) articles))
6271 (setq data (cdr data)))
6272 (gnus-summary-limit articles))
6273 (gnus-summary-position-point)))
6275 (defun gnus-summary-limit-to-score (&optional score)
6276 "Limit to articles with score at or above SCORE."
6278 (setq score (if score
6279 (prefix-numeric-value score)
6280 (or gnus-summary-default-score 0)))
6281 (let ((data gnus-newsgroup-data)
6284 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6286 (push (gnus-data-number (car data)) articles))
6287 (setq data (cdr data)))
6289 (gnus-summary-limit articles)
6290 (gnus-summary-position-point))))
6292 (defun gnus-summary-limit-include-thread (id)
6293 "Display all the hidden articles that in the current thread."
6294 (interactive (list (mail-header-id (gnus-summary-article-header))))
6295 (let ((articles (gnus-articles-in-thread
6296 (gnus-id-to-thread (gnus-root-id id)))))
6298 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6299 (gnus-summary-position-point))))
6301 (defun gnus-summary-limit-include-dormant ()
6302 "Display all the hidden articles that are marked as dormant.
6303 Note that this command only works on a subset of the articles currently
6304 fetched for this group."
6306 (unless gnus-newsgroup-dormant
6307 (error "There are no dormant articles in this group"))
6309 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6310 (gnus-summary-position-point)))
6312 (defun gnus-summary-limit-exclude-dormant ()
6313 "Hide all dormant articles."
6316 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6317 (gnus-summary-position-point)))
6319 (defun gnus-summary-limit-exclude-childless-dormant ()
6320 "Hide all dormant articles that have no children."
6322 (let ((data (gnus-data-list t))
6323 articles d children)
6324 ;; Find all articles that are either not dormant or have
6326 (while (setq d (pop data))
6327 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6329 (gnus-article-children (gnus-data-number d)))
6332 (when (memq (car children) articles)
6337 (push (gnus-data-number d) articles)))
6340 (gnus-summary-limit articles)
6341 (gnus-summary-position-point))))
6343 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6344 "Mark all unread excluded articles as read.
6345 If ALL, mark even excluded ticked and dormants as read."
6347 (let ((articles (gnus-sorted-complement
6349 (mapcar (lambda (h) (mail-header-number h))
6350 gnus-newsgroup-headers)
6352 (sort gnus-newsgroup-limit '<)))
6354 (setq gnus-newsgroup-unreads
6355 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6357 (setq gnus-newsgroup-dormant nil
6358 gnus-newsgroup-marked nil
6359 gnus-newsgroup-reads
6361 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6362 gnus-newsgroup-reads))
6363 (while (setq article (pop articles))
6364 (unless (or (memq article gnus-newsgroup-dormant)
6365 (memq article gnus-newsgroup-marked))
6366 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6368 (defun gnus-summary-limit (articles &optional pop)
6370 ;; We pop the previous limit off the stack and use that.
6371 (setq articles (car gnus-newsgroup-limits)
6372 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6373 ;; We use the new limit, so we push the old limit on the stack.
6374 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6376 (setq gnus-newsgroup-limit articles)
6377 (let ((total (length gnus-newsgroup-data))
6378 (data (gnus-data-find-list (gnus-summary-article-number)))
6379 (gnus-summary-mark-below nil) ; Inhibit this.
6381 ;; This will do all the work of generating the new summary buffer
6382 ;; according to the new limit.
6383 (gnus-summary-prepare)
6384 ;; Hide any threads, possibly.
6385 (and gnus-show-threads
6386 gnus-thread-hide-subtree
6387 (gnus-summary-hide-all-threads))
6388 ;; Try to return to the article you were at, or one in the
6391 ;; We try to find some article after the current one.
6393 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6396 (setq data (cdr data))))
6398 ;; If there is no data, that means that we were after the last
6399 ;; article. The same goes when we can't find any articles
6400 ;; after the current one.
6401 (goto-char (point-max))
6402 (gnus-summary-find-prev))
6403 (gnus-set-mode-line 'summary)
6404 ;; We return how many articles were removed from the summary
6405 ;; buffer as a result of the new limit.
6406 (- total (length gnus-newsgroup-data))))
6408 (defsubst gnus-invisible-cut-children (threads)
6411 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6416 (defsubst gnus-cut-thread (thread)
6417 "Go forwards in the thread until we find an article that we want to display."
6418 (when (or (eq gnus-fetch-old-headers 'some)
6419 (eq gnus-fetch-old-headers 'invisible)
6420 (eq gnus-build-sparse-threads 'some)
6421 (eq gnus-build-sparse-threads 'more))
6422 ;; Deal with old-fetched headers and sparse threads.
6426 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6427 (gnus-summary-article-ancient-p
6428 (mail-header-number (car thread))))
6429 (if (or (<= (length (cdr thread)) 1)
6430 (eq gnus-fetch-old-headers 'invisible))
6431 (setq gnus-newsgroup-limit
6432 (delq (mail-header-number (car thread))
6433 gnus-newsgroup-limit)
6434 thread (cadr thread))
6435 (when (gnus-invisible-cut-children (cdr thread))
6436 (let ((th (cdr thread)))
6438 (if (memq (mail-header-number (caar th))
6439 gnus-newsgroup-limit)
6440 (setq thread (car th)
6442 (setq th (cdr th))))))))))
6445 (defun gnus-cut-threads (threads)
6446 "Cut off all uninteresting articles from the beginning of threads."
6447 (when (or (eq gnus-fetch-old-headers 'some)
6448 (eq gnus-fetch-old-headers 'invisible)
6449 (eq gnus-build-sparse-threads 'some)
6450 (eq gnus-build-sparse-threads 'more))
6453 (setcar th (gnus-cut-thread (car th)))
6454 (setq th (cdr th)))))
6455 ;; Remove nixed out threads.
6458 (defun gnus-summary-initial-limit (&optional show-if-empty)
6459 "Figure out what the initial limit is supposed to be on group entry.
6460 This entails weeding out unwanted dormants, low-scored articles,
6461 fetch-old-headers verbiage, and so on."
6462 ;; Most groups have nothing to remove.
6463 (if (or gnus-inhibit-limiting
6464 (and (null gnus-newsgroup-dormant)
6465 (not (eq gnus-fetch-old-headers 'some))
6466 (not (eq gnus-fetch-old-headers 'invisible))
6467 (null gnus-summary-expunge-below)
6468 (not (eq gnus-build-sparse-threads 'some))
6469 (not (eq gnus-build-sparse-threads 'more))
6470 (null gnus-thread-expunge-below)
6471 (not gnus-use-nocem)))
6473 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6474 (setq gnus-newsgroup-limit nil)
6477 (unless (car (symbol-value node))
6478 ;; These threads have no parents -- they are roots.
6479 (let ((nodes (cdr (symbol-value node)))
6482 (if (and gnus-thread-expunge-below
6483 (< (gnus-thread-total-score (car nodes))
6484 gnus-thread-expunge-below))
6485 (gnus-expunge-thread (pop nodes))
6486 (setq thread (pop nodes))
6487 (gnus-summary-limit-children thread))))))
6488 gnus-newsgroup-dependencies)
6489 ;; If this limitation resulted in an empty group, we might
6490 ;; pop the previous limit and use it instead.
6491 (when (and (not gnus-newsgroup-limit)
6493 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6494 gnus-newsgroup-limit))
6496 (defun gnus-summary-limit-children (thread)
6497 "Return 1 if this subthread is visible and 0 if it is not."
6498 ;; First we get the number of visible children to this thread. This
6499 ;; is done by recursing down the thread using this function, so this
6500 ;; will really go down to a leaf article first, before slowly
6501 ;; working its way up towards the root.
6505 (apply '+ (mapcar 'gnus-summary-limit-children
6508 (number (mail-header-number (car thread)))
6511 (not (memq number gnus-newsgroup-marked))
6513 ;; If this article is dormant and has absolutely no visible
6514 ;; children, then this article isn't visible.
6515 (and (memq number gnus-newsgroup-dormant)
6517 ;; If this is "fetch-old-headered" and there is no
6518 ;; visible children, then we don't want this article.
6519 (and (eq gnus-fetch-old-headers 'some)
6520 (gnus-summary-article-ancient-p number)
6522 ;; If this is "fetch-old-headered" and `invisible', then
6523 ;; we don't want this article.
6524 (and (eq gnus-fetch-old-headers 'invisible)
6525 (gnus-summary-article-ancient-p number))
6526 ;; If this is a sparsely inserted article with no children,
6527 ;; we don't want it.
6528 (and (eq gnus-build-sparse-threads 'some)
6529 (gnus-summary-article-sparse-p number)
6531 ;; If we use expunging, and this article is really
6532 ;; low-scored, then we don't want this article.
6533 (when (and gnus-summary-expunge-below
6535 (or (cdr (assq number gnus-newsgroup-scored))
6536 gnus-summary-default-score))
6537 gnus-summary-expunge-below))
6538 ;; We increase the expunge-tally here, but that has
6539 ;; nothing to do with the limits, really.
6540 (incf gnus-newsgroup-expunged-tally)
6541 ;; We also mark as read here, if that's wanted.
6542 (when (and gnus-summary-mark-below
6543 (< score gnus-summary-mark-below))
6544 (setq gnus-newsgroup-unreads
6545 (delq number gnus-newsgroup-unreads))
6546 (if gnus-newsgroup-auto-expire
6547 (push number gnus-newsgroup-expirable)
6548 (push (cons number gnus-low-score-mark)
6549 gnus-newsgroup-reads)))
6551 ;; Check NoCeM things.
6552 (if (and gnus-use-nocem
6553 (gnus-nocem-unwanted-article-p
6554 (mail-header-id (car thread))))
6556 (setq gnus-newsgroup-unreads
6557 (delq number gnus-newsgroup-unreads))
6559 ;; Nope, invisible article.
6561 ;; Ok, this article is to be visible, so we add it to the limit
6563 (push number gnus-newsgroup-limit)
6566 (defun gnus-expunge-thread (thread)
6567 "Mark all articles in THREAD as read."
6568 (let* ((number (mail-header-number (car thread))))
6569 (incf gnus-newsgroup-expunged-tally)
6570 ;; We also mark as read here, if that's wanted.
6571 (setq gnus-newsgroup-unreads
6572 (delq number gnus-newsgroup-unreads))
6573 (if gnus-newsgroup-auto-expire
6574 (push number gnus-newsgroup-expirable)
6575 (push (cons number gnus-low-score-mark)
6576 gnus-newsgroup-reads)))
6577 ;; Go recursively through all subthreads.
6578 (mapcar 'gnus-expunge-thread (cdr thread)))
6580 ;; Summary article oriented commands
6582 (defun gnus-summary-refer-parent-article (n)
6583 "Refer parent article N times.
6584 If N is negative, go to ancestor -N instead.
6585 The difference between N and the number of articles fetched is returned."
6589 (when (not (natnump n))
6594 (setq header (gnus-summary-article-header))
6595 (if (and (eq (mail-header-number header)
6596 (cdr gnus-article-current))
6597 (equal gnus-newsgroup-name
6598 (car gnus-article-current)))
6599 ;; If we try to find the parent of the currently
6600 ;; displayed article, then we take a look at the actual
6601 ;; References header, since this is slightly more
6602 ;; reliable than the References field we got from the
6605 (set-buffer gnus-original-article-buffer)
6606 (nnheader-narrow-to-headers)
6607 (unless (setq ref (message-fetch-field "references"))
6608 (setq ref (message-fetch-field "in-reply-to")))
6611 ;; It's not the current article, so we take a bet on
6612 ;; the value we got from the server.
6613 (mail-header-references header)))
6615 (not (equal ref "")))
6616 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6617 (gnus-message 1 "Couldn't find parent"))
6618 (gnus-message 1 "No references in article %d"
6619 (gnus-summary-article-number))
6622 (gnus-summary-position-point)
6625 (defun gnus-summary-refer-references ()
6626 "Fetch all articles mentioned in the References header.
6627 Return the number of articles fetched."
6629 (let ((ref (mail-header-references (gnus-summary-article-header)))
6630 (current (gnus-summary-article-number))
6634 (error "No References in the current article")
6635 ;; For each Message-ID in the References header...
6636 (while (string-match "<[^>]*>" ref)
6638 ;; ... fetch that article.
6639 (gnus-summary-refer-article
6640 (prog1 (match-string 0 ref)
6641 (setq ref (substring ref (match-end 0))))))
6642 (gnus-summary-goto-subject current)
6643 (gnus-summary-position-point)
6646 (defun gnus-summary-refer-thread (&optional limit)
6647 "Fetch all articles in the current thread.
6648 If LIMIT (the numerical prefix), fetch that many old headers instead
6649 of what's specified by the `gnus-refer-thread-limit' variable."
6651 (let ((id (mail-header-id (gnus-summary-article-header)))
6652 (limit (if limit (prefix-numeric-value limit)
6653 gnus-refer-thread-limit)))
6654 ;; We want to fetch LIMIT *old* headers, but we also have to
6655 ;; re-fetch all the headers in the current buffer, because many of
6656 ;; them may be undisplayed. So we adjust LIMIT.
6657 (when (numberp limit)
6658 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6659 (unless (eq gnus-fetch-old-headers 'invisible)
6660 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6661 ;; Retrieve the headers and read them in.
6662 (if (eq (gnus-retrieve-headers
6663 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6665 (gnus-build-all-threads)
6666 (error "Can't fetch thread from backends that don't support NOV"))
6667 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6668 (gnus-summary-limit-include-thread id)))
6670 (defun gnus-summary-refer-article (message-id &optional arg)
6671 "Fetch an article specified by MESSAGE-ID.
6672 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6673 or `gnus-select-method', no matter what backend the article comes from."
6674 (interactive "sMessage-ID: \nP")
6675 (when (and (stringp message-id)
6676 (not (zerop (length message-id))))
6677 ;; Construct the correct Message-ID if necessary.
6678 ;; Suggested by tale@pawl.rpi.edu.
6679 (unless (string-match "^<" message-id)
6680 (setq message-id (concat "<" message-id)))
6681 (unless (string-match ">$" message-id)
6682 (setq message-id (concat message-id ">")))
6683 (let* ((header (gnus-id-to-header message-id))
6685 (gnus-summary-article-sparse-p
6686 (mail-header-number header))
6687 (memq (mail-header-number header)
6688 gnus-newsgroup-limit))))
6690 ;; If the article is present in the buffer we just go to it.
6692 (or (not (gnus-summary-article-sparse-p
6693 (mail-header-number header)))
6696 (gnus-summary-goto-article
6697 (mail-header-number header) nil t)
6699 (gnus-summary-update-article (mail-header-number header)))))
6701 ;; We fetch the article
6702 (let ((gnus-override-method
6703 (cond ((gnus-news-group-p gnus-newsgroup-name)
6704 gnus-refer-article-method)
6706 (or gnus-refer-article-method gnus-select-method))
6709 ;; Start the special refer-article method, if necessary.
6710 (when (and gnus-refer-article-method
6711 (gnus-news-group-p gnus-newsgroup-name))
6712 (gnus-check-server gnus-refer-article-method))
6713 ;; Fetch the header, and display the article.
6714 (if (setq number (gnus-summary-insert-subject message-id))
6715 (gnus-summary-select-article nil nil nil number)
6716 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6718 (defun gnus-summary-edit-parameters ()
6719 "Edit the group parameters of the current group."
6721 (gnus-group-edit-group gnus-newsgroup-name 'params))
6723 (defun gnus-summary-customize-parameters ()
6724 "Customize the group parameters of the current group."
6726 (gnus-group-customize gnus-newsgroup-name))
6728 (defun gnus-summary-enter-digest-group (&optional force)
6729 "Enter an nndoc group based on the current article.
6730 If FORCE, force a digest interpretation. If not, try
6731 to guess what the document format is."
6733 (let ((conf gnus-current-window-configuration))
6735 (gnus-summary-select-article))
6736 (setq gnus-current-window-configuration conf)
6737 (let* ((name (format "%s-%d"
6738 (gnus-group-prefixed-name
6739 gnus-newsgroup-name (list 'nndoc ""))
6741 (set-buffer gnus-summary-buffer)
6742 gnus-current-article)))
6743 (ogroup gnus-newsgroup-name)
6744 (params (append (gnus-info-params (gnus-get-info ogroup))
6745 (list (cons 'to-group ogroup))
6746 (list (cons 'save-article-group ogroup))))
6747 (case-fold-search t)
6748 (buf (current-buffer))
6751 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6752 (insert-buffer-substring gnus-original-article-buffer)
6753 ;; Remove lines that may lead nndoc to misinterpret the
6756 (goto-char (point-min))
6757 (or (search-forward "\n\n" nil t) (point)))
6758 (goto-char (point-min))
6759 (delete-matching-lines "^\\(Path\\):\\|^From ")
6762 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6763 (gnus-newsgroup-ephemeral-ignored-charsets
6764 gnus-newsgroup-ignored-charsets))
6765 (gnus-group-read-ephemeral-group
6766 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6768 ,(if force 'digest 'guess))) t))
6769 ;; Make all postings to this group go to the parent group.
6770 (nconc (gnus-info-params (gnus-get-info name))
6772 ;; Couldn't select this doc group.
6773 (switch-to-buffer buf)
6774 (gnus-set-global-variables)
6775 (gnus-configure-windows 'summary)
6776 (gnus-message 3 "Article couldn't be entered?"))
6777 (kill-buffer dig)))))
6779 (defun gnus-summary-read-document (n)
6780 "Open a new group based on the current article(s).
6781 This will allow you to read digests and other similar
6782 documents as newsgroups.
6783 Obeys the standard process/prefix convention."
6785 (let* ((articles (gnus-summary-work-articles n))
6786 (ogroup gnus-newsgroup-name)
6787 (params (append (gnus-info-params (gnus-get-info ogroup))
6788 (list (cons 'to-group ogroup))))
6789 article group egroup groups vgroup)
6790 (while (setq article (pop articles))
6791 (setq group (format "%s-%d" gnus-newsgroup-name article))
6792 (gnus-summary-remove-process-mark article)
6793 (when (gnus-summary-display-article article)
6796 (insert-buffer-substring gnus-original-article-buffer)
6797 ;; Remove some headers that may lead nndoc to make
6799 (message-narrow-to-head)
6800 (goto-char (point-min))
6801 (delete-matching-lines "^\\(Path\\):\\|^From ")
6804 (gnus-group-read-ephemeral-group
6805 group `(nndoc ,group (nndoc-address ,(current-buffer))
6806 (nndoc-article-type guess))
6809 ;; Make all postings to this group go to the parent group.
6810 (nconc (gnus-info-params (gnus-get-info egroup))
6812 (push egroup groups))
6813 ;; Couldn't select this doc group.
6814 (gnus-error 3 "Article couldn't be entered"))))))
6815 ;; Now we have selected all the documents.
6818 (error "None of the articles could be interpreted as documents"))
6819 ((gnus-group-read-ephemeral-group
6820 (setq vgroup (format
6821 "nnvirtual:%s-%s" gnus-newsgroup-name
6822 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6823 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6825 (cons (current-buffer) 'summary)))
6827 (error "Couldn't select virtual nndoc group")))))
6829 (defun gnus-summary-isearch-article (&optional regexp-p)
6830 "Do incremental search forward on the current article.
6831 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6833 (gnus-summary-select-article)
6834 (gnus-configure-windows 'article)
6835 (gnus-eval-in-buffer-window gnus-article-buffer
6838 (isearch-forward regexp-p))))
6840 (defun gnus-summary-search-article-forward (regexp &optional backward)
6841 "Search for an article containing REGEXP forward.
6842 If BACKWARD, search backward instead."
6845 (format "Search article %s (regexp%s): "
6846 (if current-prefix-arg "backward" "forward")
6847 (if gnus-last-search-regexp
6848 (concat ", default " gnus-last-search-regexp)
6850 current-prefix-arg))
6851 (if (string-equal regexp "")
6852 (setq regexp (or gnus-last-search-regexp ""))
6853 (setq gnus-last-search-regexp regexp))
6854 (if (gnus-summary-search-article regexp backward)
6855 (gnus-summary-show-thread)
6856 (error "Search failed: \"%s\"" regexp)))
6858 (defun gnus-summary-search-article-backward (regexp)
6859 "Search for an article containing REGEXP backward."
6862 (format "Search article backward (regexp%s): "
6863 (if gnus-last-search-regexp
6864 (concat ", default " gnus-last-search-regexp)
6866 (gnus-summary-search-article-forward regexp 'backward))
6868 (defun gnus-summary-search-article (regexp &optional backward)
6869 "Search for an article containing REGEXP.
6870 Optional argument BACKWARD means do search for backward.
6871 `gnus-select-article-hook' is not called during the search."
6872 ;; We have to require this here to make sure that the following
6873 ;; dynamic binding isn't shadowed by autoloading.
6874 (require 'gnus-async)
6876 (let ((gnus-select-article-hook nil) ;Disable hook.
6877 (gnus-article-display-hook nil)
6878 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6879 (gnus-use-article-prefetch nil)
6880 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6881 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6882 (sum (current-buffer))
6885 (gnus-save-hidden-threads
6886 (gnus-summary-select-article)
6887 (set-buffer gnus-article-buffer)
6891 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6893 (re-search-backward regexp nil t)
6894 (re-search-forward regexp nil t))
6895 ;; We found the regexp.
6900 (get-buffer-window (current-buffer))
6904 (setq point (point)))
6905 ;; We didn't find it, so we go to the next article.
6908 (while (eq found 'not)
6909 (if (not (if backward (gnus-summary-find-prev)
6910 (gnus-summary-find-next)))
6911 ;; No more articles.
6913 ;; Select the next article and adjust point.
6914 (unless (gnus-summary-article-sparse-p
6915 (gnus-summary-article-number))
6917 (gnus-summary-select-article)
6918 (set-buffer gnus-article-buffer)
6920 (goto-char (if backward (point-max) (point-min))))))))
6921 (gnus-message 7 ""))
6922 ;; Return whether we found the regexp.
6923 (when (eq found 'found)
6925 (gnus-summary-show-thread)
6926 (gnus-summary-goto-subject gnus-current-article)
6927 (gnus-summary-position-point)
6930 (defun gnus-summary-find-matching (header regexp &optional backward unread
6932 "Return a list of all articles that match REGEXP on HEADER.
6933 The search stars on the current article and goes forwards unless
6934 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6935 If UNREAD is non-nil, only unread articles will
6936 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6937 in the comparisons."
6938 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6939 (gnus-data-find-list
6940 (gnus-summary-article-number) (gnus-data-list backward))))
6941 (case-fold-search (not not-case-fold))
6944 (if (eq (car header) 'extra)
6947 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
6949 (error "%s is an invalid header" header))
6950 (unless (fboundp (intern (concat "mail-header-" header)))
6951 (error "%s is not a valid header" header))
6952 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
6955 (and (or (not unread) ; We want all articles...
6956 (gnus-data-unread-p d)) ; Or just unreads.
6957 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6958 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6959 (push (gnus-data-number d) articles)) ; Success!
6960 (setq data (cdr data)))
6961 (nreverse articles)))
6963 (defun gnus-summary-execute-command (header regexp command &optional backward)
6964 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6965 If HEADER is an empty string (or nil), the match is done on the entire
6966 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6968 (list (let ((completion-ignore-case t))
6971 (mapcar (lambda (string) (list string))
6972 '("Number" "Subject" "From" "Lines" "Date"
6973 "Message-ID" "Xref" "References" "Body"))
6974 nil 'require-match))
6975 (read-string "Regexp: ")
6976 (read-key-sequence "Command: ")
6977 current-prefix-arg))
6978 (when (equal header "Body")
6980 ;; Hidden thread subtrees must be searched as well.
6981 (gnus-summary-show-all-threads)
6982 ;; We don't want to change current point nor window configuration.
6984 (save-window-excursion
6985 (gnus-message 6 "Executing %s..." (key-description command))
6986 ;; We'd like to execute COMMAND interactively so as to give arguments.
6987 (gnus-execute header regexp
6988 `(call-interactively ',(key-binding command))
6990 (gnus-message 6 "Executing %s...done" (key-description command)))))
6992 (defun gnus-summary-beginning-of-article ()
6993 "Scroll the article back to the beginning."
6995 (gnus-summary-select-article)
6996 (gnus-configure-windows 'article)
6997 (gnus-eval-in-buffer-window gnus-article-buffer
6999 (goto-char (point-min))
7000 (when gnus-page-broken
7001 (gnus-narrow-to-page))))
7003 (defun gnus-summary-end-of-article ()
7004 "Scroll to the end of the article."
7006 (gnus-summary-select-article)
7007 (gnus-configure-windows 'article)
7008 (gnus-eval-in-buffer-window gnus-article-buffer
7010 (goto-char (point-max))
7012 (when gnus-page-broken
7013 (gnus-narrow-to-page))))
7015 (defun gnus-summary-print-article (&optional filename n)
7016 "Generate and print a PostScript image of the N next (mail) articles.
7018 If N is negative, print the N previous articles. If N is nil and articles
7019 have been marked with the process mark, print these instead.
7021 If the optional first argument FILENAME is nil, send the image to the
7022 printer. If FILENAME is a string, save the PostScript image in a file with
7023 that name. If FILENAME is a number, prompt the user for the name of the file
7025 (interactive (list (ps-print-preprint current-prefix-arg)
7026 current-prefix-arg))
7027 (dolist (article (gnus-summary-work-articles n))
7028 (gnus-summary-select-article nil nil 'pseudo article)
7029 (gnus-eval-in-buffer-window gnus-article-buffer
7030 (let ((buffer (generate-new-buffer " *print*")))
7033 (copy-to-buffer buffer (point-min) (point-max))
7035 (gnus-article-delete-invisible-text)
7036 (let ((ps-left-header
7039 (mail-header-subject gnus-current-headers) ")")
7041 (mail-header-from gnus-current-headers) ")")))
7044 "/pagenumberstring load"
7046 (mail-header-date gnus-current-headers) ")"))))
7047 (gnus-run-hooks 'gnus-ps-print-hook)
7049 (ps-print-buffer-with-faces filename))))
7050 (kill-buffer buffer))))))
7052 (defun gnus-summary-show-article (&optional arg)
7053 "Force re-fetching of the current article.
7054 If ARG (the prefix) is non-nil, show the raw article without any
7055 article massaging functions being run."
7058 ;; Select the article the normal way.
7059 (gnus-summary-select-article nil 'force)
7060 ;; We have to require this here to make sure that the following
7061 ;; dynamic binding isn't shadowed by autoloading.
7062 (require 'gnus-async)
7064 ;; Bind the article treatment functions to nil.
7065 (let ((gnus-have-all-headers t)
7066 gnus-article-display-hook
7067 gnus-article-prepare-hook
7068 gnus-article-decode-hook
7072 (gnus-summary-select-article nil 'force)))
7073 (gnus-summary-goto-subject gnus-current-article)
7074 (gnus-summary-position-point))
7076 (defun gnus-summary-verbose-headers (&optional arg)
7077 "Toggle permanent full header display.
7078 If ARG is a positive number, turn header display on.
7079 If ARG is a negative number, turn header display off."
7081 (setq gnus-show-all-headers
7082 (cond ((or (not (numberp arg))
7084 (not gnus-show-all-headers))
7087 (gnus-summary-show-article))
7089 (defun gnus-summary-toggle-header (&optional arg)
7090 "Show the headers if they are hidden, or hide them if they are shown.
7091 If ARG is a positive number, show the entire header.
7092 If ARG is a negative number, hide the unwanted header lines."
7095 (set-buffer gnus-article-buffer)
7097 (let* ((buffer-read-only nil)
7098 (inhibit-point-motion-hooks t)
7101 (article-narrow-to-head)
7102 (setq hidden (gnus-article-hidden-text-p 'headers)))
7103 (goto-char (point-min))
7104 (when (search-forward "\n\n" nil t)
7105 (delete-region (point-min) (1- (point))))
7106 (goto-char (point-min))
7108 (set-buffer gnus-original-article-buffer)
7109 (goto-char (point-min))
7110 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7111 (insert-buffer-substring gnus-original-article-buffer 1 e)
7113 (narrow-to-region (point-min) (point))
7114 (article-decode-encoded-words)
7116 (and (numberp arg) (< arg 0)))
7117 (let ((gnus-treat-hide-headers nil)
7118 (gnus-treat-hide-boring-headers nil))
7119 (gnus-treat-article 'head))
7120 (gnus-treat-article 'head)))))))
7122 (defun gnus-summary-show-all-headers ()
7123 "Make all header lines visible."
7125 (gnus-article-show-all-headers))
7127 (defun gnus-summary-toggle-mime (&optional arg)
7128 "Toggle MIME processing.
7129 If ARG is a positive number, turn MIME processing on."
7131 (setq gnus-show-mime
7133 (not gnus-show-mime)
7134 (> (prefix-numeric-value arg) 0)))
7135 (gnus-summary-select-article t 'force))
7137 (defun gnus-summary-caesar-message (&optional arg)
7138 "Caesar rotate the current article by 13.
7139 The numerical prefix specifies how many places to rotate each letter
7142 (gnus-summary-select-article)
7143 (let ((mail-header-separator ""))
7144 (gnus-eval-in-buffer-window gnus-article-buffer
7147 (let ((start (window-start))
7149 (message-caesar-buffer-body arg)
7150 (set-window-start (get-buffer-window (current-buffer)) start))))))
7152 (defun gnus-summary-stop-page-breaking ()
7153 "Stop page breaking in the current article."
7155 (gnus-summary-select-article)
7156 (gnus-eval-in-buffer-window gnus-article-buffer
7158 (when (gnus-visual-p 'page-marker)
7159 (let ((buffer-read-only nil))
7160 (gnus-remove-text-with-property 'gnus-prev)
7161 (gnus-remove-text-with-property 'gnus-next))
7162 (setq gnus-page-broken nil))))
7164 (defun gnus-summary-move-article (&optional n to-newsgroup
7165 select-method action)
7166 "Move the current article to a different newsgroup.
7167 If N is a positive number, move the N next articles.
7168 If N is a negative number, move the N previous articles.
7169 If N is nil and any articles have been marked with the process mark,
7170 move those articles instead.
7171 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7172 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7173 re-spool using this method.
7175 For this function to work, both the current newsgroup and the
7176 newsgroup that you want to move to have to support the `request-move'
7177 and `request-accept' functions."
7180 (setq action 'move))
7181 ;; Disable marking as read.
7182 (let (gnus-mark-article-hook)
7183 (save-window-excursion
7184 (gnus-summary-select-article)))
7185 ;; Check whether the source group supports the required functions.
7186 (cond ((and (eq action 'move)
7187 (not (gnus-check-backend-function
7188 'request-move-article gnus-newsgroup-name)))
7189 (error "The current group does not support article moving"))
7190 ((and (eq action 'crosspost)
7191 (not (gnus-check-backend-function
7192 'request-replace-article gnus-newsgroup-name)))
7193 (error "The current group does not support article editing")))
7194 (let ((articles (gnus-summary-work-articles n))
7195 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7196 (names '((move "Move" "Moving")
7197 (copy "Copy" "Copying")
7198 (crosspost "Crosspost" "Crossposting")))
7199 (copy-buf (save-excursion
7200 (nnheader-set-temp-buffer " *copy article*")))
7201 (default-marks gnus-article-mark-lists)
7202 (no-expire-marks (delete '(expirable . expire)
7203 (copy-sequence gnus-article-mark-lists)))
7204 art-group to-method new-xref article to-groups)
7205 (unless (assq action names)
7206 (error "Unknown action %s" action))
7207 ;; Read the newsgroup name.
7208 (when (and (not to-newsgroup)
7209 (not select-method))
7211 (gnus-read-move-group-name
7212 (cadr (assq action names))
7213 (symbol-value (intern (format "gnus-current-%s-group" action)))
7215 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7216 (setq to-method (or select-method
7217 (gnus-group-name-to-method to-newsgroup)))
7218 ;; Check the method we are to move this article to...
7219 (unless (gnus-check-backend-function
7220 'request-accept-article (car to-method))
7221 (error "%s does not support article copying" (car to-method)))
7222 (unless (gnus-check-server to-method)
7223 (error "Can't open server %s" (car to-method)))
7224 (gnus-message 6 "%s to %s: %s..."
7225 (caddr (assq action names))
7226 (or (car select-method) to-newsgroup) articles)
7228 (setq article (pop articles))
7232 ;; Move the article.
7234 ;; Remove this article from future suppression.
7235 (gnus-dup-unsuppress-article article)
7236 (gnus-request-move-article
7237 article ; Article to move
7238 gnus-newsgroup-name ; From newsgroup
7239 (nth 1 (gnus-find-method-for-group
7240 gnus-newsgroup-name)) ; Server
7241 (list 'gnus-request-accept-article
7242 to-newsgroup (list 'quote select-method)
7243 (not articles) t) ; Accept form
7244 (not articles))) ; Only save nov last time
7245 ;; Copy the article.
7248 (set-buffer copy-buf)
7249 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7250 (gnus-request-accept-article
7251 to-newsgroup select-method (not articles) t))))
7252 ;; Crosspost the article.
7253 ((eq action 'crosspost)
7254 (let ((xref (message-tokenize-header
7255 (mail-header-xref (gnus-summary-article-header article))
7257 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7260 (setq xref (list (system-name))))
7263 (mapconcat 'identity
7264 (delete "Xref:" (delete new-xref xref))
7268 (set-buffer copy-buf)
7269 ;; First put the article in the destination group.
7270 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7271 (when (consp (setq art-group
7272 (gnus-request-accept-article
7273 to-newsgroup select-method (not articles))))
7274 (setq new-xref (concat new-xref " " (car art-group)
7275 ":" (cdr art-group)))
7276 ;; Now we have the new Xrefs header, so we insert
7277 ;; it and replace the new article.
7278 (nnheader-replace-header "Xref" new-xref)
7279 (gnus-request-replace-article
7280 (cdr art-group) to-newsgroup (current-buffer))
7284 (gnus-message 1 "Couldn't %s article %s"
7285 (cadr (assq action names)) article))
7286 ((and (eq art-group 'junk)
7288 (gnus-summary-mark-article article gnus-canceled-mark)
7289 (gnus-message 4 "Deleted article %s" article))
7291 (let* ((pto-group (gnus-group-prefixed-name
7292 (car art-group) to-method))
7294 (gnus-gethash pto-group gnus-newsrc-hashtb))
7295 (info (nth 2 entry))
7296 (to-group (gnus-info-group info))
7298 ;; Update the group that has been moved to.
7300 (memq action '(move copy)))
7301 (unless (member to-group to-groups)
7302 (push to-group to-groups))
7304 (unless (memq article gnus-newsgroup-unreads)
7305 (push 'read to-marks)
7307 info (gnus-add-to-range (gnus-info-read info)
7308 (list (cdr art-group)))))
7310 ;; Copy any marks over to the new group.
7311 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7314 (to-article (cdr art-group)))
7316 ;; See whether the article is to be put in the cache.
7317 (when gnus-use-cache
7318 (gnus-cache-possibly-enter-article
7320 (let ((header (copy-sequence
7321 (gnus-summary-article-header article))))
7322 (mail-header-set-number header to-article)
7324 (memq article gnus-newsgroup-marked)
7325 (memq article gnus-newsgroup-dormant)
7326 (memq article gnus-newsgroup-unreads)))
7328 (when (and (equal to-group gnus-newsgroup-name)
7329 (not (memq article gnus-newsgroup-unreads)))
7330 ;; Mark this article as read in this group.
7331 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7332 (setcdr (gnus-active to-group) to-article)
7333 (setcdr gnus-newsgroup-active to-article))
7336 (when (memq article (symbol-value
7337 (intern (format "gnus-newsgroup-%s"
7339 (push (cdar marks) to-marks)
7340 ;; If the other group is the same as this group,
7341 ;; then we have to add the mark to the list.
7342 (when (equal to-group gnus-newsgroup-name)
7343 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7346 (intern (format "gnus-newsgroup-%s"
7348 ;; Copy the marks to other group.
7349 (gnus-add-marked-articles
7350 to-group (cdar marks) (list to-article) info))
7351 (setq marks (cdr marks)))
7353 (gnus-request-set-mark to-group (list (list (list to-article)
7358 (concat "(gnus-group-set-info '"
7359 (gnus-prin1-to-string (gnus-get-info to-group))
7362 ;; Update the Xref header in this article to point to
7363 ;; the new crossposted article we have just created.
7364 (when (eq action 'crosspost)
7366 (set-buffer copy-buf)
7367 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7368 (nnheader-replace-header "Xref" new-xref)
7369 (gnus-request-replace-article
7370 article gnus-newsgroup-name (current-buffer)))))
7372 ;;;!!!Why is this necessary?
7373 (set-buffer gnus-summary-buffer)
7375 (gnus-summary-goto-subject article)
7376 (when (eq action 'move)
7377 (gnus-summary-mark-article article gnus-canceled-mark))))
7378 (gnus-summary-remove-process-mark article))
7379 ;; Re-activate all groups that have been moved to.
7382 (set-buffer gnus-group-buffer)
7383 (when (gnus-group-goto-group (car to-groups) t)
7384 (gnus-group-get-new-news-this-group 1 t))
7387 (gnus-kill-buffer copy-buf)
7388 (gnus-summary-position-point)
7389 (gnus-set-mode-line 'summary)))
7391 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7392 "Move the current article to a different newsgroup.
7393 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7394 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7395 re-spool using this method."
7397 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7399 (defun gnus-summary-crosspost-article (&optional n)
7400 "Crosspost the current article to some other group."
7402 (gnus-summary-move-article n nil nil 'crosspost))
7404 (defcustom gnus-summary-respool-default-method nil
7405 "Default method for respooling an article.
7406 If nil, use to the current newsgroup method."
7407 :type '(choice (gnus-select-method :value (nnml ""))
7409 :group 'gnus-summary-mail)
7411 (defun gnus-summary-respool-article (&optional n method)
7412 "Respool the current article.
7413 The article will be squeezed through the mail spooling process again,
7414 which means that it will be put in some mail newsgroup or other
7415 depending on `nnmail-split-methods'.
7416 If N is a positive number, respool the N next articles.
7417 If N is a negative number, respool the N previous articles.
7418 If N is nil and any articles have been marked with the process mark,
7419 respool those articles instead.
7421 Respooling can be done both from mail groups and \"real\" newsgroups.
7422 In the former case, the articles in question will be moved from the
7423 current group into whatever groups they are destined to. In the
7424 latter case, they will be copied into the relevant groups."
7426 (list current-prefix-arg
7427 (let* ((methods (gnus-methods-using 'respool))
7429 (symbol-name (or gnus-summary-respool-default-method
7430 (car (gnus-find-method-for-group
7431 gnus-newsgroup-name)))))
7433 (gnus-completing-read
7434 methname "What backend do you want to use when respooling?"
7435 methods nil t nil 'gnus-mail-method-history))
7438 ((zerop (length (setq ms (gnus-servers-using-backend
7440 (list (intern method) ""))
7444 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7445 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7448 (error "No method given for respooling"))
7449 (if (assoc (symbol-name
7450 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7451 (gnus-methods-using 'respool))
7452 (gnus-summary-move-article n nil method)
7453 (gnus-summary-copy-article n nil method)))
7455 (defun gnus-summary-import-article (file)
7456 "Import an arbitrary file into a mail newsgroup."
7457 (interactive "fImport file: ")
7458 (let ((group gnus-newsgroup-name)
7459 (now (current-time))
7461 (unless (gnus-check-backend-function 'request-accept-article group)
7462 (error "%s does not support article importing" group))
7463 (or (file-readable-p file)
7464 (not (file-regular-p file))
7465 (error "Can't read %s" file))
7467 (set-buffer (gnus-get-buffer-create " *import file*"))
7469 (nnheader-insert-file-contents file)
7470 (goto-char (point-min))
7471 (unless (nnheader-article-p)
7472 ;; This doesn't look like an article, so we fudge some headers.
7473 (setq atts (file-attributes file)
7474 lines (count-lines (point-min) (point-max)))
7475 (insert "From: " (read-string "From: ") "\n"
7476 "Subject: " (read-string "Subject: ") "\n"
7477 "Date: " (message-make-date (nth 5 atts))
7479 "Message-ID: " (message-make-message-id) "\n"
7480 "Lines: " (int-to-string lines) "\n"
7481 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7482 (gnus-request-accept-article group nil t)
7483 (kill-buffer (current-buffer)))))
7485 (defun gnus-summary-article-posted-p ()
7486 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7487 This will be the case if the article has both been mailed and posted."
7489 (let ((id (mail-header-references (gnus-summary-article-header)))
7490 (gnus-override-method
7491 (or gnus-refer-article-method gnus-select-method)))
7492 (if (gnus-request-head id "")
7493 (gnus-message 2 "The current message was found on %s"
7494 gnus-override-method)
7495 (gnus-message 2 "The current message couldn't be found on %s"
7496 gnus-override-method)
7499 (defun gnus-summary-expire-articles (&optional now)
7500 "Expire all articles that are marked as expirable in the current group."
7502 (when (gnus-check-backend-function
7503 'request-expire-articles gnus-newsgroup-name)
7504 ;; This backend supports expiry.
7505 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7506 (expirable (if total
7508 ;; We need to update the info for
7509 ;; this group for `gnus-list-of-read-articles'
7510 ;; to give us the right answer.
7511 (gnus-run-hooks 'gnus-exit-group-hook)
7512 (gnus-summary-update-info)
7513 (gnus-list-of-read-articles gnus-newsgroup-name))
7514 (setq gnus-newsgroup-expirable
7515 (sort gnus-newsgroup-expirable '<))))
7516 (expiry-wait (if now 'immediate
7517 (gnus-group-find-parameter
7518 gnus-newsgroup-name 'expiry-wait)))
7521 ;; There are expirable articles in this group, so we run them
7522 ;; through the expiry process.
7523 (gnus-message 6 "Expiring articles...")
7524 (unless (gnus-check-group gnus-newsgroup-name)
7525 (error "Can't open server for %s" gnus-newsgroup-name))
7526 ;; The list of articles that weren't expired is returned.
7529 (let ((nnmail-expiry-wait-function nil)
7530 (nnmail-expiry-wait expiry-wait))
7531 (setq es (gnus-request-expire-articles
7532 expirable gnus-newsgroup-name)))
7533 (setq es (gnus-request-expire-articles
7534 expirable gnus-newsgroup-name))))
7536 (setq gnus-newsgroup-expirable es))
7537 ;; We go through the old list of expirable, and mark all
7538 ;; really expired articles as nonexistent.
7539 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7540 (let ((gnus-use-cache nil))
7542 (unless (memq (car expirable) es)
7543 (when (gnus-data-find (car expirable))
7544 (gnus-summary-mark-article
7545 (car expirable) gnus-canceled-mark)))
7546 (setq expirable (cdr expirable)))))
7547 (gnus-message 6 "Expiring articles...done")))))
7549 (defun gnus-summary-expire-articles-now ()
7550 "Expunge all expirable articles in the current group.
7551 This means that *all* articles that are marked as expirable will be
7552 deleted forever, right now."
7554 (or gnus-expert-user
7556 "Are you really, really, really sure you want to delete all these messages? ")
7558 (gnus-summary-expire-articles t))
7560 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7561 (defun gnus-summary-delete-article (&optional n)
7562 "Delete the N next (mail) articles.
7563 This command actually deletes articles. This is not a marking
7564 command. The article will disappear forever from your life, never to
7566 If N is negative, delete backwards.
7567 If N is nil and articles have been marked with the process mark,
7568 delete these instead."
7570 (unless (gnus-check-backend-function 'request-expire-articles
7571 gnus-newsgroup-name)
7572 (error "The current newsgroup does not support article deletion"))
7573 ;; Compute the list of articles to delete.
7574 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7576 (if (and gnus-novice-user
7577 (not (gnus-yes-or-no-p
7578 (format "Do you really want to delete %s forever? "
7579 (if (> (length articles) 1)
7580 (format "these %s articles" (length articles))
7583 ;; Delete the articles.
7584 (setq not-deleted (gnus-request-expire-articles
7585 articles gnus-newsgroup-name 'force))
7587 (gnus-summary-remove-process-mark (car articles))
7588 ;; The backend might not have been able to delete the article
7590 (unless (memq (car articles) not-deleted)
7591 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7592 (setq articles (cdr articles)))
7594 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7595 (gnus-summary-position-point)
7596 (gnus-set-mode-line 'summary)
7599 (defun gnus-summary-edit-article (&optional force)
7600 "Edit the current article.
7601 This will have permanent effect only in mail groups.
7602 If FORCE is non-nil, allow editing of articles even in read-only
7606 (set-buffer gnus-summary-buffer)
7607 (let ((mail-parse-charset gnus-newsgroup-charset)
7608 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7609 (gnus-set-global-variables)
7610 (when (and (not force)
7611 (gnus-group-read-only-p))
7612 (error "The current newsgroup does not support article editing"))
7613 (gnus-summary-show-article t)
7614 (gnus-article-edit-article
7616 `(lambda (no-highlight)
7617 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7618 (mail-parse-ignored-charsets
7619 ',gnus-newsgroup-ignored-charsets))
7620 (gnus-summary-edit-article-done
7621 ,(or (mail-header-references gnus-current-headers) "")
7622 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7624 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7626 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7628 "Make edits to the current article permanent."
7630 ;; Replace the article.
7631 (let ((buf (current-buffer)))
7633 (insert-buffer-substring buf)
7634 (if (and (not read-only)
7635 (not (gnus-request-replace-article
7636 (cdr gnus-article-current) (car gnus-article-current)
7637 (current-buffer) t)))
7638 (error "Couldn't replace article")
7639 ;; Update the summary buffer.
7641 (equal (message-tokenize-header references " ")
7642 (message-tokenize-header
7643 (or (message-fetch-field "references") "") " ")))
7644 ;; We only have to update this line.
7647 (message-narrow-to-head)
7648 (let ((head (buffer-string))
7651 (insert (format "211 %d Article retrieved.\n"
7652 (cdr gnus-article-current)))
7655 (let ((nntp-server-buffer (current-buffer)))
7656 (setq header (car (gnus-get-newsgroup-headers
7658 (set-buffer gnus-summary-buffer)
7659 gnus-newsgroup-dependencies)
7662 (set-buffer gnus-summary-buffer)
7663 (gnus-data-set-header
7664 (gnus-data-find (cdr gnus-article-current))
7666 (gnus-summary-update-article-line
7667 (cdr gnus-article-current) header))))))
7669 (set-buffer (or buffer gnus-summary-buffer))
7670 (gnus-summary-update-article (cdr gnus-article-current)))
7671 ;; Prettify the article buffer again.
7672 (unless no-highlight
7674 (set-buffer gnus-article-buffer)
7675 ;;;!!! Fix this -- article should be rehighlighted.
7676 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7677 (set-buffer gnus-original-article-buffer)
7678 (gnus-request-article
7679 (cdr gnus-article-current)
7680 (car gnus-article-current) (current-buffer))))
7681 ;; Prettify the summary buffer line.
7682 (when (gnus-visual-p 'summary-highlight 'highlight)
7683 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7685 (defun gnus-summary-edit-wash (key)
7686 "Perform editing command KEY in the article buffer."
7690 (message "%s" (concat (this-command-keys) "- "))
7693 (gnus-summary-edit-article)
7694 (execute-kbd-macro (concat (this-command-keys) key))
7695 (gnus-article-edit-done))
7699 (defun gnus-summary-respool-query (&optional silent trace)
7700 "Query where the respool algorithm would put this article."
7702 (let (gnus-mark-article-hook)
7703 (gnus-summary-select-article)
7705 (set-buffer gnus-original-article-buffer)
7707 (message-narrow-to-head)
7708 (let ((groups (nnmail-article-group 'identity trace)))
7711 (message "This message would go to %s"
7712 (mapconcat 'car groups ", "))
7713 (message "This message would go to no groups"))
7716 (defun gnus-summary-respool-trace ()
7717 "Trace where the respool algorithm would put this article.
7718 Display a buffer showing all fancy splitting patterns which matched."
7720 (gnus-summary-respool-query nil t))
7722 ;; Summary marking commands.
7724 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7725 "Mark articles which has the same subject as read, and then select the next.
7726 If UNMARK is positive, remove any kind of mark.
7727 If UNMARK is negative, tick articles."
7730 (setq unmark (prefix-numeric-value unmark)))
7732 (gnus-summary-mark-same-subject
7733 (gnus-summary-article-subject) unmark)))
7734 ;; Select next unread article. If auto-select-same mode, should
7735 ;; select the first unread article.
7736 (gnus-summary-next-article t (and gnus-auto-select-same
7737 (gnus-summary-article-subject)))
7738 (gnus-message 7 "%d article%s marked as %s"
7739 count (if (= count 1) " is" "s are")
7740 (if unmark "unread" "read"))))
7742 (defun gnus-summary-kill-same-subject (&optional unmark)
7743 "Mark articles which has the same subject as read.
7744 If UNMARK is positive, remove any kind of mark.
7745 If UNMARK is negative, tick articles."
7748 (setq unmark (prefix-numeric-value unmark)))
7750 (gnus-summary-mark-same-subject
7751 (gnus-summary-article-subject) unmark)))
7752 ;; If marked as read, go to next unread subject.
7754 ;; Go to next unread subject.
7755 (gnus-summary-next-subject 1 t))
7756 (gnus-message 7 "%d articles are marked as %s"
7757 count (if unmark "unread" "read"))))
7759 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7760 "Mark articles with same SUBJECT as read, and return marked number.
7761 If optional argument UNMARK is positive, remove any kinds of marks.
7762 If optional argument UNMARK is negative, mark articles as unread instead."
7766 ((null unmark) ; Mark as read.
7769 (gnus-summary-mark-article-as-read gnus-killed-mark)
7770 (gnus-summary-show-thread) t)
7771 (gnus-summary-find-subject subject))
7772 (setq count (1+ count))))
7773 ((> unmark 0) ; Tick.
7776 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7777 (gnus-summary-show-thread) t)
7778 (gnus-summary-find-subject subject))
7779 (setq count (1+ count))))
7780 (t ; Mark as unread.
7783 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7784 (gnus-summary-show-thread) t)
7785 (gnus-summary-find-subject subject))
7786 (setq count (1+ count)))))
7787 (gnus-set-mode-line 'summary)
7788 ;; Return the number of marked articles.
7791 (defun gnus-summary-mark-as-processable (n &optional unmark)
7792 "Set the process mark on the next N articles.
7793 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7794 the process mark instead. The difference between N and the actual
7795 number of articles marked is returned."
7797 (let ((backward (< n 0))
7802 (gnus-summary-remove-process-mark
7803 (gnus-summary-article-number))
7804 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7805 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7808 (gnus-message 7 "No more articles"))
7809 (gnus-summary-recenter)
7810 (gnus-summary-position-point)
7813 (defun gnus-summary-unmark-as-processable (n)
7814 "Remove the process mark from the next N articles.
7815 If N is negative, unmark backward instead. The difference between N and
7816 the actual number of articles unmarked is returned."
7818 (gnus-summary-mark-as-processable n t))
7820 (defun gnus-summary-unmark-all-processable ()
7821 "Remove the process mark from all articles."
7824 (while gnus-newsgroup-processable
7825 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7826 (gnus-summary-position-point))
7828 (defun gnus-summary-mark-as-expirable (n)
7829 "Mark N articles forward as expirable.
7830 If N is negative, mark backward instead. The difference between N and
7831 the actual number of articles marked is returned."
7833 (gnus-summary-mark-forward n gnus-expirable-mark))
7835 (defun gnus-summary-mark-article-as-replied (article)
7836 "Mark ARTICLE replied and update the summary line."
7837 (push article gnus-newsgroup-replied)
7838 (let ((buffer-read-only nil))
7839 (when (gnus-summary-goto-subject article nil t)
7840 (gnus-summary-update-secondary-mark article))))
7842 (defun gnus-summary-set-bookmark (article)
7843 "Set a bookmark in current article."
7844 (interactive (list (gnus-summary-article-number)))
7845 (when (or (not (get-buffer gnus-article-buffer))
7846 (not gnus-current-article)
7847 (not gnus-article-current)
7848 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7849 (error "No current article selected"))
7850 ;; Remove old bookmark, if one exists.
7851 (let ((old (assq article gnus-newsgroup-bookmarks)))
7853 (setq gnus-newsgroup-bookmarks
7854 (delq old gnus-newsgroup-bookmarks))))
7855 ;; Set the new bookmark, which is on the form
7856 ;; (article-number . line-number-in-body).
7860 (set-buffer gnus-article-buffer)
7864 (goto-char (point-min))
7865 (search-forward "\n\n" nil t)
7868 gnus-newsgroup-bookmarks)
7869 (gnus-message 6 "A bookmark has been added to the current article."))
7871 (defun gnus-summary-remove-bookmark (article)
7872 "Remove the bookmark from the current article."
7873 (interactive (list (gnus-summary-article-number)))
7874 ;; Remove old bookmark, if one exists.
7875 (let ((old (assq article gnus-newsgroup-bookmarks)))
7878 (setq gnus-newsgroup-bookmarks
7879 (delq old gnus-newsgroup-bookmarks))
7880 (gnus-message 6 "Removed bookmark."))
7881 (gnus-message 6 "No bookmark in current article."))))
7883 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7884 (defun gnus-summary-mark-as-dormant (n)
7885 "Mark N articles forward as dormant.
7886 If N is negative, mark backward instead. The difference between N and
7887 the actual number of articles marked is returned."
7889 (gnus-summary-mark-forward n gnus-dormant-mark))
7891 (defun gnus-summary-set-process-mark (article)
7892 "Set the process mark on ARTICLE and update the summary line."
7893 (setq gnus-newsgroup-processable
7895 (delq article gnus-newsgroup-processable)))
7896 (when (gnus-summary-goto-subject article)
7897 (gnus-summary-show-thread)
7898 (gnus-summary-goto-subject article)
7899 (gnus-summary-update-secondary-mark article)))
7901 (defun gnus-summary-remove-process-mark (article)
7902 "Remove the process mark from ARTICLE and update the summary line."
7903 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7904 (when (gnus-summary-goto-subject article)
7905 (gnus-summary-show-thread)
7906 (gnus-summary-goto-subject article)
7907 (gnus-summary-update-secondary-mark article)))
7909 (defun gnus-summary-set-saved-mark (article)
7910 "Set the process mark on ARTICLE and update the summary line."
7911 (push article gnus-newsgroup-saved)
7912 (when (gnus-summary-goto-subject article)
7913 (gnus-summary-update-secondary-mark article)))
7915 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7916 "Mark N articles as read forwards.
7917 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7918 The difference between N and the actual number of articles marked is
7921 (gnus-summary-show-thread)
7922 (let ((backward (< n 0))
7923 (gnus-summary-goto-unread
7924 (and gnus-summary-goto-unread
7925 (not (eq gnus-summary-goto-unread 'never))
7926 (not (memq mark (list gnus-unread-mark
7927 gnus-ticked-mark gnus-dormant-mark)))))
7929 (mark (or mark gnus-del-mark)))
7931 (gnus-summary-mark-article nil mark no-expire)
7932 (zerop (gnus-summary-next-subject
7934 (and gnus-summary-goto-unread
7935 (not (eq gnus-summary-goto-unread 'never)))
7939 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7940 (gnus-summary-recenter)
7941 (gnus-summary-position-point)
7942 (gnus-set-mode-line 'summary)
7945 (defun gnus-summary-mark-article-as-read (mark)
7946 "Mark the current article quickly as read with MARK."
7947 (let ((article (gnus-summary-article-number)))
7948 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7949 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7950 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7951 (push (cons article mark) gnus-newsgroup-reads)
7952 ;; Possibly remove from cache, if that is used.
7953 (when gnus-use-cache
7954 (gnus-cache-enter-remove-article article))
7955 ;; Allow the backend to change the mark.
7956 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7957 ;; Check for auto-expiry.
7958 (when (and gnus-newsgroup-auto-expire
7959 (memq mark gnus-auto-expirable-marks))
7960 (setq mark gnus-expirable-mark)
7961 ;; Let the backend know about the mark change.
7962 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7963 (push article gnus-newsgroup-expirable))
7964 ;; Set the mark in the buffer.
7965 (gnus-summary-update-mark mark 'unread)
7968 (defun gnus-summary-mark-article-as-unread (mark)
7969 "Mark the current article quickly as unread with MARK."
7970 (let* ((article (gnus-summary-article-number))
7971 (old-mark (gnus-summary-article-mark article)))
7972 ;; Allow the backend to change the mark.
7973 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7974 (if (eq mark old-mark)
7978 (gnus-error 1 "Can't mark negative article numbers")
7980 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7981 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7982 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7983 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7984 (cond ((= mark gnus-ticked-mark)
7985 (push article gnus-newsgroup-marked))
7986 ((= mark gnus-dormant-mark)
7987 (push article gnus-newsgroup-dormant))
7989 (push article gnus-newsgroup-unreads)))
7990 (gnus-pull article gnus-newsgroup-reads)
7992 ;; See whether the article is to be put in the cache.
7994 (vectorp (gnus-summary-article-header article))
7996 (gnus-cache-possibly-enter-article
7997 gnus-newsgroup-name article
7998 (gnus-summary-article-header article)
7999 (= mark gnus-ticked-mark)
8000 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8003 (gnus-summary-update-mark mark 'unread)
8006 (defun gnus-summary-mark-article (&optional article mark no-expire)
8007 "Mark ARTICLE with MARK. MARK can be any character.
8008 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8009 `??' (dormant) and `?E' (expirable).
8010 If MARK is nil, then the default character `?r' is used.
8011 If ARTICLE is nil, then the article on the current line will be
8013 ;; The mark might be a string.
8014 (when (stringp mark)
8015 (setq mark (aref mark 0)))
8016 ;; If no mark is given, then we check auto-expiring.
8018 (setq mark gnus-del-mark))
8019 (when (and (not no-expire)
8020 gnus-newsgroup-auto-expire
8021 (memq mark gnus-auto-expirable-marks))
8022 (setq mark gnus-expirable-mark))
8023 (let ((article (or article (gnus-summary-article-number)))
8024 (old-mark (gnus-summary-article-mark article)))
8025 ;; Allow the backend to change the mark.
8026 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8027 (if (eq mark old-mark)
8030 (error "No article on current line"))
8031 (if (not (if (or (= mark gnus-unread-mark)
8032 (= mark gnus-ticked-mark)
8033 (= mark gnus-dormant-mark))
8034 (gnus-mark-article-as-unread article mark)
8035 (gnus-mark-article-as-read article mark)))
8037 ;; See whether the article is to be put in the cache.
8039 (not (= mark gnus-canceled-mark))
8040 (vectorp (gnus-summary-article-header article))
8042 (gnus-cache-possibly-enter-article
8043 gnus-newsgroup-name article
8044 (gnus-summary-article-header article)
8045 (= mark gnus-ticked-mark)
8046 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8048 (when (gnus-summary-goto-subject article nil t)
8049 (let ((buffer-read-only nil))
8050 (gnus-summary-show-thread)
8052 (gnus-summary-update-mark mark 'unread)
8055 (defun gnus-summary-update-secondary-mark (article)
8056 "Update the secondary (read, process, cache) mark."
8057 (gnus-summary-update-mark
8058 (cond ((memq article gnus-newsgroup-processable)
8060 ((memq article gnus-newsgroup-cached)
8062 ((memq article gnus-newsgroup-replied)
8064 ((memq article gnus-newsgroup-saved)
8066 (t gnus-unread-mark))
8068 (when (gnus-visual-p 'summary-highlight 'highlight)
8069 (gnus-run-hooks 'gnus-summary-update-hook))
8072 (defun gnus-summary-update-mark (mark type)
8073 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8074 (buffer-read-only nil))
8075 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8077 (when (looking-at "\r")
8079 (when (<= (+ forward (point)) (point-max))
8080 ;; Go to the right position on the line.
8081 (goto-char (+ forward (point)))
8082 ;; Replace the old mark with the new mark.
8083 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8084 ;; Optionally update the marks by some user rule.
8085 (when (eq type 'unread)
8087 (gnus-data-find (gnus-summary-article-number)) mark)
8088 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8090 (defun gnus-mark-article-as-read (article &optional mark)
8091 "Enter ARTICLE in the pertinent lists and remove it from others."
8092 ;; Make the article expirable.
8093 (let ((mark (or mark gnus-del-mark)))
8094 (if (= mark gnus-expirable-mark)
8095 (push article gnus-newsgroup-expirable)
8096 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8097 ;; Remove from unread and marked lists.
8098 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8099 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8100 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8101 (push (cons article mark) gnus-newsgroup-reads)
8102 ;; Possibly remove from cache, if that is used.
8103 (when gnus-use-cache
8104 (gnus-cache-enter-remove-article article))
8107 (defun gnus-mark-article-as-unread (article &optional mark)
8108 "Enter ARTICLE in the pertinent lists and remove it from others."
8109 (let ((mark (or mark gnus-ticked-mark)))
8112 (gnus-error 1 "Can't mark negative article numbers")
8114 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8115 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8116 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8117 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8119 ;; Unsuppress duplicates?
8120 (when gnus-suppress-duplicates
8121 (gnus-dup-unsuppress-article article))
8123 (cond ((= mark gnus-ticked-mark)
8124 (push article gnus-newsgroup-marked))
8125 ((= mark gnus-dormant-mark)
8126 (push article gnus-newsgroup-dormant))
8128 (push article gnus-newsgroup-unreads)))
8129 (gnus-pull article gnus-newsgroup-reads)
8132 (defalias 'gnus-summary-mark-as-unread-forward
8133 'gnus-summary-tick-article-forward)
8134 (make-obsolete 'gnus-summary-mark-as-unread-forward
8135 'gnus-summary-tick-article-forward)
8136 (defun gnus-summary-tick-article-forward (n)
8137 "Tick N articles forwards.
8138 If N is negative, tick backwards instead.
8139 The difference between N and the number of articles ticked is returned."
8141 (gnus-summary-mark-forward n gnus-ticked-mark))
8143 (defalias 'gnus-summary-mark-as-unread-backward
8144 'gnus-summary-tick-article-backward)
8145 (make-obsolete 'gnus-summary-mark-as-unread-backward
8146 'gnus-summary-tick-article-backward)
8147 (defun gnus-summary-tick-article-backward (n)
8148 "Tick N articles backwards.
8149 The difference between N and the number of articles ticked is returned."
8151 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8153 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8154 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8155 (defun gnus-summary-tick-article (&optional article clear-mark)
8156 "Mark current article as unread.
8157 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8158 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8160 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8163 (defun gnus-summary-mark-as-read-forward (n)
8164 "Mark N articles as read forwards.
8165 If N is negative, mark backwards instead.
8166 The difference between N and the actual number of articles marked is
8169 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8171 (defun gnus-summary-mark-as-read-backward (n)
8172 "Mark the N articles as read backwards.
8173 The difference between N and the actual number of articles marked is
8176 (gnus-summary-mark-forward
8177 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8179 (defun gnus-summary-mark-as-read (&optional article mark)
8180 "Mark current article as read.
8181 ARTICLE specifies the article to be marked as read.
8182 MARK specifies a string to be inserted at the beginning of the line."
8183 (gnus-summary-mark-article article mark))
8185 (defun gnus-summary-clear-mark-forward (n)
8186 "Clear marks from N articles forward.
8187 If N is negative, clear backward instead.
8188 The difference between N and the number of marks cleared is returned."
8190 (gnus-summary-mark-forward n gnus-unread-mark))
8192 (defun gnus-summary-clear-mark-backward (n)
8193 "Clear marks from N articles backward.
8194 The difference between N and the number of marks cleared is returned."
8196 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8198 (defun gnus-summary-mark-unread-as-read ()
8199 "Intended to be used by `gnus-summary-mark-article-hook'."
8200 (when (memq gnus-current-article gnus-newsgroup-unreads)
8201 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8203 (defun gnus-summary-mark-read-and-unread-as-read ()
8204 "Intended to be used by `gnus-summary-mark-article-hook'."
8205 (let ((mark (gnus-summary-article-mark)))
8206 (when (or (gnus-unread-mark-p mark)
8207 (gnus-read-mark-p mark))
8208 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8210 (defun gnus-summary-mark-region-as-read (point mark all)
8211 "Mark all unread articles between point and mark as read.
8212 If given a prefix, mark all articles between point and mark as read,
8213 even ticked and dormant ones."
8214 (interactive "r\nP")
8223 (memq (setq article (gnus-summary-article-number))
8224 gnus-newsgroup-unreads))
8225 (gnus-summary-mark-article article gnus-del-mark))
8227 (gnus-summary-find-next))))))
8229 (defun gnus-summary-mark-below (score mark)
8230 "Mark articles with score less than SCORE with MARK."
8231 (interactive "P\ncMark: ")
8232 (setq score (if score
8233 (prefix-numeric-value score)
8234 (or gnus-summary-default-score 0)))
8236 (set-buffer gnus-summary-buffer)
8237 (goto-char (point-min))
8240 (and (< (gnus-summary-article-score) score)
8241 (gnus-summary-mark-article nil mark))
8242 (gnus-summary-find-next)))))
8244 (defun gnus-summary-kill-below (&optional score)
8245 "Mark articles with score below SCORE as read."
8247 (gnus-summary-mark-below score gnus-killed-mark))
8249 (defun gnus-summary-clear-above (&optional score)
8250 "Clear all marks from articles with score above SCORE."
8252 (gnus-summary-mark-above score gnus-unread-mark))
8254 (defun gnus-summary-tick-above (&optional score)
8255 "Tick all articles with score above SCORE."
8257 (gnus-summary-mark-above score gnus-ticked-mark))
8259 (defun gnus-summary-mark-above (score mark)
8260 "Mark articles with score over SCORE with MARK."
8261 (interactive "P\ncMark: ")
8262 (setq score (if score
8263 (prefix-numeric-value score)
8264 (or gnus-summary-default-score 0)))
8266 (set-buffer gnus-summary-buffer)
8267 (goto-char (point-min))
8269 (when (> (gnus-summary-article-score) score)
8270 (gnus-summary-mark-article nil mark))
8272 (gnus-summary-find-next)))))
8274 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8275 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8276 (defun gnus-summary-limit-include-expunged (&optional no-error)
8277 "Display all the hidden articles that were expunged for low scores."
8279 (let ((buffer-read-only nil))
8280 (let ((scored gnus-newsgroup-scored)
8283 (unless (gnus-summary-goto-subject (caar scored))
8284 (and (setq h (gnus-summary-article-header (caar scored)))
8285 (< (cdar scored) gnus-summary-expunge-below)
8287 (setq scored (cdr scored)))
8289 (when (not no-error)
8290 (error "No expunged articles hidden"))
8291 (goto-char (point-min))
8292 (gnus-summary-prepare-unthreaded (nreverse headers))
8293 (goto-char (point-min))
8294 (gnus-summary-position-point)
8297 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8298 "Mark all unread articles in this newsgroup as read.
8299 If prefix argument ALL is non-nil, ticked and dormant articles will
8300 also be marked as read.
8301 If QUIETLY is non-nil, no questions will be asked.
8302 If TO-HERE is non-nil, it should be a point in the buffer. All
8303 articles before this point will be marked as read.
8304 Note that this function will only catch up the unread article
8305 in the current summary buffer limitation.
8306 The number of articles marked as read is returned."
8311 (not gnus-interactive-catchup) ;Without confirmation?
8315 "Mark absolutely all articles as read? "
8316 "Mark all unread articles as read? ")))
8318 (not gnus-newsgroup-adaptive)
8319 (not gnus-newsgroup-auto-expire)
8320 (not gnus-suppress-duplicates)
8321 (or (not gnus-use-cache)
8322 (eq gnus-use-cache 'passive)))
8325 (setq gnus-newsgroup-marked nil
8326 gnus-newsgroup-dormant nil))
8327 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8328 ;; We actually mark all articles as canceled, which we
8329 ;; have to do when using auto-expiry or adaptive scoring.
8330 (gnus-summary-show-all-threads)
8331 (when (gnus-summary-first-subject (not all) t)
8333 (if to-here (< (point) to-here) t)
8334 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8335 (gnus-summary-find-next (not all) nil nil t))))
8336 (gnus-set-mode-line 'summary))
8338 (gnus-summary-position-point)))
8340 (defun gnus-summary-catchup-to-here (&optional all)
8341 "Mark all unticked articles before the current one as read.
8342 If ALL is non-nil, also mark ticked and dormant articles as read."
8345 (gnus-save-hidden-threads
8346 (let ((beg (point)))
8347 ;; We check that there are unread articles.
8348 (when (or all (gnus-summary-find-prev))
8349 (gnus-summary-catchup all t beg)))))
8350 (gnus-summary-position-point))
8352 (defun gnus-summary-catchup-all (&optional quietly)
8353 "Mark all articles in this newsgroup as read."
8355 (gnus-summary-catchup t quietly))
8357 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8358 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8359 If prefix argument ALL is non-nil, all articles are marked as read."
8361 (when (gnus-summary-catchup all quietly nil 'fast)
8362 ;; Select next newsgroup or exit.
8363 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8364 (eq gnus-auto-select-next 'quietly))
8365 (gnus-summary-next-group nil)
8366 (gnus-summary-exit))))
8368 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8369 "Mark all articles in this newsgroup as read, and then exit."
8371 (gnus-summary-catchup-and-exit t quietly))
8373 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8374 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8375 "Mark all articles in this group as read and select the next group.
8376 If given a prefix, mark all articles, unread as well as ticked, as
8380 (gnus-summary-catchup all))
8381 (gnus-summary-next-article t nil nil t))
8383 ;; Thread-based commands.
8385 (defun gnus-summary-articles-in-thread (&optional article)
8386 "Return a list of all articles in the current thread.
8387 If ARTICLE is non-nil, return all articles in the thread that starts
8389 (let* ((article (or article (gnus-summary-article-number)))
8390 (data (gnus-data-find-list article))
8391 (top-level (gnus-data-level (car data)))
8393 (cond ((null gnus-thread-operation-ignore-subject)
8394 (gnus-simplify-subject-re
8395 (mail-header-subject (gnus-data-header (car data)))))
8396 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8397 (gnus-simplify-subject-fuzzy
8398 (mail-header-subject (gnus-data-header (car data)))))
8400 (end-point (save-excursion
8401 (if (gnus-summary-go-to-next-thread)
8402 (point) (point-max))))
8405 (< (gnus-data-pos (car data)) end-point))
8406 (when (or (not top-subject)
8407 (string= top-subject
8408 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8409 (gnus-simplify-subject-fuzzy
8410 (mail-header-subject
8411 (gnus-data-header (car data))))
8412 (gnus-simplify-subject-re
8413 (mail-header-subject
8414 (gnus-data-header (car data)))))))
8415 (push (gnus-data-number (car data)) articles))
8416 (unless (and (setq data (cdr data))
8417 (> (gnus-data-level (car data)) top-level))
8419 ;; Return the list of articles.
8420 (nreverse articles)))
8422 (defun gnus-summary-rethread-current ()
8423 "Rethread the thread the current article is part of."
8425 (let* ((gnus-show-threads t)
8426 (article (gnus-summary-article-number))
8427 (id (mail-header-id (gnus-summary-article-header)))
8428 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8430 (error "No article on the current line"))
8431 (gnus-rebuild-thread id)
8432 (gnus-summary-goto-subject article)))
8434 (defun gnus-summary-reparent-thread ()
8435 "Make the current article child of the marked (or previous) article.
8437 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8438 is non-nil or the Subject: of both articles are the same."
8440 (unless (not (gnus-group-read-only-p))
8441 (error "The current newsgroup does not support article editing"))
8442 (unless (<= (length gnus-newsgroup-processable) 1)
8443 (error "No more than one article may be marked"))
8444 (save-window-excursion
8445 (let ((gnus-article-buffer " *reparent*")
8446 (current-article (gnus-summary-article-number))
8447 ;; First grab the marked article, otherwise one line up.
8448 (parent-article (if (not (null gnus-newsgroup-processable))
8449 (car gnus-newsgroup-processable)
8451 (if (eq (forward-line -1) 0)
8452 (gnus-summary-article-number)
8453 (error "Beginning of summary buffer"))))))
8454 (unless (not (eq current-article parent-article))
8455 (error "An article may not be self-referential"))
8456 (let ((message-id (mail-header-id
8457 (gnus-summary-article-header parent-article))))
8458 (unless (and message-id (not (equal message-id "")))
8459 (error "No message-id in desired parent"))
8460 (gnus-with-article current-article
8461 (goto-char (point-min))
8462 (if (re-search-forward "^References: " nil t)
8464 (re-search-forward "^[^ \t]" nil t)
8467 (insert " " message-id))
8468 (insert "References: " message-id "\n")))
8469 (set-buffer gnus-summary-buffer)
8470 (gnus-summary-unmark-all-processable)
8471 (gnus-summary-update-article current-article)
8472 (gnus-summary-rethread-current)
8473 (gnus-message 3 "Article %d is now the child of article %d"
8474 current-article parent-article)))))
8476 (defun gnus-summary-toggle-threads (&optional arg)
8477 "Toggle showing conversation threads.
8478 If ARG is positive number, turn showing conversation threads on."
8480 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8481 (setq gnus-show-threads
8482 (if (null arg) (not gnus-show-threads)
8483 (> (prefix-numeric-value arg) 0)))
8484 (gnus-summary-prepare)
8485 (gnus-summary-goto-subject current)
8486 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8487 (gnus-summary-position-point)))
8489 (defun gnus-summary-show-all-threads ()
8493 (let ((buffer-read-only nil))
8494 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8495 (gnus-summary-position-point))
8497 (defun gnus-summary-show-thread ()
8498 "Show thread subtrees.
8499 Returns nil if no thread was there to be shown."
8501 (let ((buffer-read-only nil)
8503 ;; first goto end then to beg, to have point at beg after let
8504 (end (progn (end-of-line) (point)))
8505 (beg (progn (beginning-of-line) (point))))
8507 ;; Any hidden lines here?
8508 (search-forward "\r" end t)
8509 (subst-char-in-region beg end ?\^M ?\n t)
8511 (gnus-summary-position-point))))
8513 (defun gnus-summary-hide-all-threads ()
8514 "Hide all thread subtrees."
8517 (goto-char (point-min))
8518 (gnus-summary-hide-thread)
8519 (while (zerop (gnus-summary-next-thread 1 t))
8520 (gnus-summary-hide-thread)))
8521 (gnus-summary-position-point))
8523 (defun gnus-summary-hide-thread ()
8524 "Hide thread subtrees.
8525 Returns nil if no threads were there to be hidden."
8527 (let ((buffer-read-only nil)
8529 (article (gnus-summary-article-number)))
8531 ;; Go forward until either the buffer ends or the subthread
8533 (when (and (not (eobp))
8534 (or (zerop (gnus-summary-next-thread 1 t))
8535 (goto-char (point-max))))
8537 (if (and (> (point) start)
8538 (search-backward "\n" start t))
8540 (subst-char-in-region start (point) ?\n ?\^M)
8541 (gnus-summary-goto-subject article))
8544 ;;(gnus-summary-position-point)
8547 (defun gnus-summary-go-to-next-thread (&optional previous)
8548 "Go to the same level (or less) next thread.
8549 If PREVIOUS is non-nil, go to previous thread instead.
8550 Return the article number moved to, or nil if moving was impossible."
8551 (let ((level (gnus-summary-thread-level))
8552 (way (if previous -1 1))
8555 (while (and (not (eobp))
8556 (< level (gnus-summary-thread-level)))
8564 (gnus-summary-article-number)
8567 (defun gnus-summary-next-thread (n &optional silent)
8568 "Go to the same level next N'th thread.
8569 If N is negative, search backward instead.
8570 Returns the difference between N and the number of skips actually
8573 If SILENT, don't output messages."
8575 (let ((backward (< n 0))
8578 (gnus-summary-go-to-next-thread backward))
8581 (gnus-summary-position-point))
8582 (when (and (not silent) (/= 0 n))
8583 (gnus-message 7 "No more threads"))
8586 (defun gnus-summary-prev-thread (n)
8587 "Go to the same level previous N'th thread.
8588 Returns the difference between N and the number of skips actually
8591 (gnus-summary-next-thread (- n)))
8593 (defun gnus-summary-go-down-thread ()
8594 "Go down one level in the current thread."
8595 (let ((children (gnus-summary-article-children)))
8597 (gnus-summary-goto-subject (car children)))))
8599 (defun gnus-summary-go-up-thread ()
8600 "Go up one level in the current thread."
8601 (let ((parent (gnus-summary-article-parent)))
8603 (gnus-summary-goto-subject parent))))
8605 (defun gnus-summary-down-thread (n)
8606 "Go down thread N steps.
8607 If N is negative, go up instead.
8608 Returns the difference between N and how many steps down that were
8614 (if up (gnus-summary-go-up-thread)
8615 (gnus-summary-go-down-thread)))
8617 (gnus-summary-position-point)
8619 (gnus-message 7 "Can't go further"))
8622 (defun gnus-summary-up-thread (n)
8623 "Go up thread N steps.
8624 If N is negative, go up instead.
8625 Returns the difference between N and how many steps down that were
8628 (gnus-summary-down-thread (- n)))
8630 (defun gnus-summary-top-thread ()
8631 "Go to the top of the thread."
8633 (while (gnus-summary-go-up-thread))
8634 (gnus-summary-article-number))
8636 (defun gnus-summary-kill-thread (&optional unmark)
8637 "Mark articles under current thread as read.
8638 If the prefix argument is positive, remove any kinds of marks.
8639 If the prefix argument is negative, tick articles instead."
8642 (setq unmark (prefix-numeric-value unmark)))
8643 (let ((articles (gnus-summary-articles-in-thread)))
8645 ;; Expand the thread.
8646 (gnus-summary-show-thread)
8647 ;; Mark all the articles.
8649 (gnus-summary-goto-subject (car articles))
8650 (cond ((null unmark)
8651 (gnus-summary-mark-article-as-read gnus-killed-mark))
8653 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8655 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8656 (setq articles (cdr articles))))
8657 ;; Hide killed subtrees.
8659 gnus-thread-hide-killed
8660 (gnus-summary-hide-thread))
8661 ;; If marked as read, go to next unread subject.
8663 ;; Go to next unread subject.
8664 (gnus-summary-next-subject 1 t)))
8665 (gnus-set-mode-line 'summary))
8667 ;; Summary sorting commands
8669 (defun gnus-summary-sort-by-number (&optional reverse)
8670 "Sort the summary buffer by article number.
8671 Argument REVERSE means reverse order."
8673 (gnus-summary-sort 'number reverse))
8675 (defun gnus-summary-sort-by-author (&optional reverse)
8676 "Sort the summary buffer by author name alphabetically.
8677 If case-fold-search is non-nil, case of letters is ignored.
8678 Argument REVERSE means reverse order."
8680 (gnus-summary-sort 'author reverse))
8682 (defun gnus-summary-sort-by-subject (&optional reverse)
8683 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8684 If case-fold-search is non-nil, case of letters is ignored.
8685 Argument REVERSE means reverse order."
8687 (gnus-summary-sort 'subject reverse))
8689 (defun gnus-summary-sort-by-date (&optional reverse)
8690 "Sort the summary buffer by date.
8691 Argument REVERSE means reverse order."
8693 (gnus-summary-sort 'date reverse))
8695 (defun gnus-summary-sort-by-score (&optional reverse)
8696 "Sort the summary buffer by score.
8697 Argument REVERSE means reverse order."
8699 (gnus-summary-sort 'score reverse))
8701 (defun gnus-summary-sort-by-lines (&optional reverse)
8702 "Sort the summary buffer by the number of lines.
8703 Argument REVERSE means reverse order."
8705 (gnus-summary-sort 'lines reverse))
8707 (defun gnus-summary-sort-by-chars (&optional reverse)
8708 "Sort the summary buffer by article length.
8709 Argument REVERSE means reverse order."
8711 (gnus-summary-sort 'chars reverse))
8713 (defun gnus-summary-sort (predicate reverse)
8714 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8715 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8716 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8717 (gnus-thread-sort-functions
8722 (gnus-article-sort-functions
8728 (gnus-summary-prepare-hook nil))
8729 ;; We do the sorting by regenerating the threads.
8730 (gnus-summary-prepare)
8731 ;; Hide subthreads if needed.
8732 (when (and gnus-show-threads gnus-thread-hide-subtree)
8733 (gnus-summary-hide-all-threads))))
8735 ;; Summary saving commands.
8737 (defun gnus-summary-save-article (&optional n not-saved)
8738 "Save the current article using the default saver function.
8739 If N is a positive number, save the N next articles.
8740 If N is a negative number, save the N previous articles.
8741 If N is nil and any articles have been marked with the process mark,
8742 save those articles instead.
8743 The variable `gnus-default-article-saver' specifies the saver function."
8745 (let* ((articles (gnus-summary-work-articles n))
8746 (save-buffer (save-excursion
8747 (nnheader-set-temp-buffer " *Gnus Save*")))
8748 (num (length articles))
8750 (dolist (article articles)
8751 (setq header (gnus-summary-article-header article))
8752 (if (not (vectorp header))
8753 ;; This is a pseudo-article.
8754 (if (assq 'name header)
8755 (gnus-copy-file (cdr (assq 'name header)))
8756 (gnus-message 1 "Article %d is unsaveable" article))
8757 ;; This is a real article.
8758 (save-window-excursion
8759 (gnus-summary-select-article t nil nil article))
8761 (set-buffer save-buffer)
8763 (insert-buffer-substring gnus-original-article-buffer))
8764 (setq file (gnus-article-save save-buffer file num))
8765 (gnus-summary-remove-process-mark article)
8767 (gnus-summary-set-saved-mark article))))
8768 (gnus-kill-buffer save-buffer)
8769 (gnus-summary-position-point)
8770 (gnus-set-mode-line 'summary)
8773 (defun gnus-summary-pipe-output (&optional arg)
8774 "Pipe the current article to a subprocess.
8775 If N is a positive number, pipe the N next articles.
8776 If N is a negative number, pipe the N previous articles.
8777 If N is nil and any articles have been marked with the process mark,
8778 pipe those articles instead."
8780 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8781 (gnus-summary-save-article arg t))
8782 (gnus-configure-windows 'pipe))
8784 (defun gnus-summary-save-article-mail (&optional arg)
8785 "Append the current article to an mail file.
8786 If N is a positive number, save the N next articles.
8787 If N is a negative number, save the N previous articles.
8788 If N is nil and any articles have been marked with the process mark,
8789 save those articles instead."
8791 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8792 (gnus-summary-save-article arg)))
8794 (defun gnus-summary-save-article-rmail (&optional arg)
8795 "Append the current article to an rmail file.
8796 If N is a positive number, save the N next articles.
8797 If N is a negative number, save the N previous articles.
8798 If N is nil and any articles have been marked with the process mark,
8799 save those articles instead."
8801 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8802 (gnus-summary-save-article arg)))
8804 (defun gnus-summary-save-article-file (&optional arg)
8805 "Append the current article to a file.
8806 If N is a positive number, save the N next articles.
8807 If N is a negative number, save the N previous articles.
8808 If N is nil and any articles have been marked with the process mark,
8809 save those articles instead."
8811 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8812 (gnus-summary-save-article arg)))
8814 (defun gnus-summary-write-article-file (&optional arg)
8815 "Write the current article to a file, deleting the previous file.
8816 If N is a positive number, save the N next articles.
8817 If N is a negative number, save the N previous articles.
8818 If N is nil and any articles have been marked with the process mark,
8819 save those articles instead."
8821 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8822 (gnus-summary-save-article arg)))
8824 (defun gnus-summary-save-article-body-file (&optional arg)
8825 "Append the current article body to a file.
8826 If N is a positive number, save the N next articles.
8827 If N is a negative number, save the N previous articles.
8828 If N is nil and any articles have been marked with the process mark,
8829 save those articles instead."
8831 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8832 (gnus-summary-save-article arg)))
8834 (defun gnus-summary-pipe-message (program)
8835 "Pipe the current article through PROGRAM."
8836 (interactive "sProgram: ")
8837 (gnus-summary-select-article)
8838 (let ((mail-header-separator ""))
8839 (gnus-eval-in-buffer-window gnus-article-buffer
8842 (let ((start (window-start))
8844 (message-pipe-buffer-body program)
8845 (set-window-start (get-buffer-window (current-buffer)) start))))))
8847 (defun gnus-get-split-value (methods)
8848 "Return a value based on the split METHODS."
8849 (let (split-name method result match)
8852 (set-buffer gnus-original-article-buffer)
8854 (nnheader-narrow-to-headers)
8856 (goto-char (point-min))
8857 (setq method (pop methods))
8858 (setq match (car method))
8861 ;; Regular expression.
8863 (re-search-forward match nil t)))
8864 ((gnus-functionp match)
8868 (setq result (funcall match gnus-newsgroup-name))))
8873 (setq result (eval match)))))
8874 (setq split-name (append (cdr method) split-name))
8875 (cond ((stringp result)
8876 (push (expand-file-name
8877 result gnus-article-save-directory)
8880 (setq split-name (append result split-name)))))))))
8881 (nreverse split-name)))
8883 (defun gnus-valid-move-group-p (group)
8886 (symbol-value group)
8887 (gnus-get-function (gnus-find-method-for-group
8888 (symbol-name group)) 'request-accept-article t)))
8890 (defun gnus-read-move-group-name (prompt default articles prefix)
8891 "Read a group name."
8892 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8893 (minibuffer-confirm-incomplete nil) ; XEmacs
8897 (if (> (length articles) 1)
8898 (format "these %d articles" (length articles))
8903 (gnus-completing-read default prom
8905 'gnus-valid-move-group-p
8907 'gnus-group-history))
8908 ((= 1 (length split-name))
8909 (gnus-completing-read (car split-name) prom
8911 'gnus-valid-move-group-p
8913 'gnus-group-history))
8915 (gnus-completing-read nil prom
8916 (mapcar (lambda (el) (list el))
8917 (nreverse split-name))
8919 'gnus-group-history)))))
8921 (if (or (string= to-newsgroup "")
8922 (string= to-newsgroup prefix))
8923 (setq to-newsgroup default))
8924 (unless to-newsgroup
8925 (error "No group name entered"))
8926 (or (gnus-active to-newsgroup)
8927 (gnus-activate-group to-newsgroup)
8928 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8930 (or (and (gnus-request-create-group
8931 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8932 (gnus-activate-group to-newsgroup nil nil
8933 (gnus-group-name-to-method
8935 (error "Couldn't create group %s" to-newsgroup)))
8936 (error "No such group: %s" to-newsgroup)))
8939 (defun gnus-summary-save-parts (type dir n reverse)
8940 "Save parts matching TYPE to DIR.
8941 If REVERSE, save parts that do not match TYPE."
8943 (list (read-string "Save parts of type: " "image/.*")
8944 (read-file-name "Save to directory: " t nil t)
8945 current-prefix-arg))
8946 (gnus-summary-iterate n
8947 (let ((gnus-display-mime-function nil)
8948 (gnus-inhibit-treatment t))
8949 (gnus-summary-select-article))
8951 (set-buffer gnus-article-buffer)
8952 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
8954 (gnus-summary-save-parts-1 type dir handles reverse)
8955 (mm-destroy-parts handles))))))
8957 (defun gnus-summary-save-parts-1 (type dir handle reverse)
8958 (if (stringp (car handle))
8959 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
8962 (not (string-match type (car (mm-handle-type handle))))
8963 (string-match type (car (mm-handle-type handle))))
8964 (let ((file (expand-file-name
8965 (file-name-nondirectory
8967 (mail-content-type-get
8968 (mm-handle-disposition handle) 'filename)
8969 (concat gnus-newsgroup-name "." gnus-current-article)))
8971 (unless (file-exists-p file)
8972 (mm-save-part-to-file handle file))))))
8974 ;; Summary extract commands
8976 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8977 (let ((buffer-read-only nil)
8978 (article (gnus-summary-article-number))
8980 (unless (gnus-summary-goto-subject article)
8981 (error "No such article: %d" article))
8982 (gnus-summary-position-point)
8983 ;; If all commands are to be bunched up on one line, we collect
8985 (unless gnus-view-pseudos-separately
8986 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8989 (setq action (cdr (assq 'action (car ps))))
8990 (setq files (list (cdr (assq 'name (car ps)))))
8991 (while (and ps (cdr ps)
8992 (string= (or action "1")
8993 (or (cdr (assq 'action (cadr ps))) "2")))
8994 (push (cdr (assq 'name (cadr ps))) files)
8995 (setcdr ps (cddr ps)))
8997 (when (not (string-match "%s" action))
9000 (when (assq 'execute (car ps))
9001 (setcdr (assq 'execute (car ps))
9002 (funcall (if (string-match "%s" action)
9009 (gnus-quote-arg-for-sh-or-csh f)))
9011 (setq ps (cdr ps)))))
9012 (if (and gnus-view-pseudos (not not-view))
9014 (when (assq 'execute (car pslist))
9015 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9016 (eq gnus-view-pseudos 'not-confirm)))
9017 (setq pslist (cdr pslist)))
9020 (setq after-article (or (cdr (assq 'article (car pslist)))
9021 (gnus-summary-article-number)))
9022 (gnus-summary-goto-subject after-article)
9025 (insert " " (file-name-nondirectory
9026 (cdr (assq 'name (car pslist))))
9027 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9029 (forward-line -1) ; back to `b'
9030 (gnus-add-text-properties
9031 b (1- e) (list 'gnus-number gnus-reffed-article-number
9032 gnus-mouse-face-prop gnus-mouse-face))
9034 after-article gnus-reffed-article-number
9035 gnus-unread-mark b (car pslist) 0 (- e b))
9036 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9037 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9038 (setq pslist (cdr pslist)))))))
9040 (defun gnus-pseudos< (p1 p2)
9041 (let ((c1 (cdr (assq 'action p1)))
9042 (c2 (cdr (assq 'action p2))))
9043 (and c1 c2 (string< c1 c2))))
9045 (defun gnus-request-pseudo-article (props)
9046 (cond ((assq 'execute props)
9047 (gnus-execute-command (cdr (assq 'execute props)))))
9048 (let ((gnus-current-article (gnus-summary-article-number)))
9049 (gnus-run-hooks 'gnus-mark-article-hook)))
9051 (defun gnus-execute-command (command &optional automatic)
9053 (gnus-article-setup-buffer)
9054 (set-buffer gnus-article-buffer)
9055 (setq buffer-read-only nil)
9056 (let ((command (if automatic command
9057 (read-string "Command: " (cons command 0)))))
9059 (insert "$ " command "\n\n")
9060 (if gnus-view-pseudo-asynchronously
9061 (start-process "gnus-execute" (current-buffer) shell-file-name
9062 shell-command-switch command)
9063 (call-process shell-file-name nil t nil
9064 shell-command-switch command)))))
9066 ;; Summary kill commands.
9068 (defun gnus-summary-edit-global-kill (article)
9069 "Edit the \"global\" kill file."
9070 (interactive (list (gnus-summary-article-number)))
9071 (gnus-group-edit-global-kill article))
9073 (defun gnus-summary-edit-local-kill ()
9074 "Edit a local kill file applied to the current newsgroup."
9076 (setq gnus-current-headers (gnus-summary-article-header))
9077 (gnus-group-edit-local-kill
9078 (gnus-summary-article-number) gnus-newsgroup-name))
9082 (defun gnus-read-header (id &optional header)
9083 "Read the headers of article ID and enter them into the Gnus system."
9084 (let ((group gnus-newsgroup-name)
9085 (gnus-override-method
9086 (and (gnus-news-group-p gnus-newsgroup-name)
9087 gnus-refer-article-method))
9089 ;; First we check to see whether the header in question is already
9092 ;; This is a Message-ID.
9093 (setq header (or header (gnus-id-to-header id)))
9094 ;; This is an article number.
9095 (setq header (or header (gnus-summary-article-header id))))
9097 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9098 ;; We have found the header.
9100 ;; If this is a sparse article, we have to nix out its
9101 ;; previous entry in the thread hashtb.
9103 (gnus-summary-article-sparse-p (mail-header-number header)))
9104 (let* ((parent (gnus-parent-id (mail-header-references header)))
9105 (thread (and parent (gnus-id-to-thread parent))))
9107 (delq (assq header thread) thread))))
9108 ;; We have to really fetch the header to this article.
9110 (set-buffer nntp-server-buffer)
9111 (when (setq where (gnus-request-head id group))
9112 (nnheader-fold-continuation-lines)
9113 (goto-char (point-max))
9115 (goto-char (point-min))
9119 ((cdr where) (cdr where))
9120 (header (mail-header-number header))
9121 (t gnus-reffed-article-number))
9123 (insert " Article retrieved.\n"))
9125 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9126 () ; Malformed head.
9127 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9128 (when (and (stringp id)
9129 (not (string= (gnus-group-real-name group)
9131 ;; If we fetched by Message-ID and the article came
9132 ;; from a different group, we fudge some bogus article
9133 ;; numbers for this article.
9134 (mail-header-set-number header gnus-reffed-article-number))
9136 (set-buffer gnus-summary-buffer)
9137 (decf gnus-reffed-article-number)
9138 (gnus-remove-header (mail-header-number header))
9139 (push header gnus-newsgroup-headers)
9140 (setq gnus-current-headers header)
9141 (push (mail-header-number header) gnus-newsgroup-limit)))
9144 (defun gnus-remove-header (number)
9145 "Remove header NUMBER from `gnus-newsgroup-headers'."
9146 (if (and gnus-newsgroup-headers
9147 (= number (mail-header-number (car gnus-newsgroup-headers))))
9148 (pop gnus-newsgroup-headers)
9149 (let ((headers gnus-newsgroup-headers))
9150 (while (and (cdr headers)
9151 (not (= number (mail-header-number (cadr headers)))))
9154 (setcdr headers (cddr headers))))))
9157 ;;; summary highlights
9160 (defun gnus-highlight-selected-summary ()
9161 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9162 ;; Highlight selected article in summary buffer
9163 (when gnus-summary-selected-face
9165 (let* ((beg (progn (beginning-of-line) (point)))
9166 (end (progn (end-of-line) (point)))
9167 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9168 (from (if (get-text-property beg gnus-mouse-face-prop)
9170 (or (next-single-property-change
9171 beg gnus-mouse-face-prop nil end)
9176 (or (next-single-property-change
9177 from gnus-mouse-face-prop nil end)
9179 ;; If no mouse-face prop on line we will have to = from = end,
9180 ;; so we highlight the entire line instead.
9181 (when (= (+ to 2) from)
9184 (if gnus-newsgroup-selected-overlay
9185 ;; Move old overlay.
9187 gnus-newsgroup-selected-overlay from to (current-buffer))
9188 ;; Create new overlay.
9190 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9191 'face gnus-summary-selected-face))))))
9193 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9194 (defun gnus-summary-highlight-line ()
9195 "Highlight current line according to `gnus-summary-highlight'."
9196 (let* ((list gnus-summary-highlight)
9198 (end (progn (end-of-line) (point)))
9199 ;; now find out where the line starts and leave point there.
9200 (beg (progn (beginning-of-line) (point)))
9201 (article (gnus-summary-article-number))
9202 (score (or (cdr (assq (or article gnus-current-article)
9203 gnus-newsgroup-scored))
9204 gnus-summary-default-score 0))
9205 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9206 (inhibit-read-only t))
9207 ;; Eval the cars of the lists until we find a match.
9208 (let ((default gnus-summary-default-score))
9210 (not (eval (caar list))))
9211 (setq list (cdr list))))
9212 (let ((face (cdar list)))
9213 (unless (eq face (get-text-property beg 'face))
9214 (gnus-put-text-property-excluding-characters-with-faces
9216 (setq face (if (boundp face) (symbol-value face) face)))
9217 (when gnus-summary-highlight-line-function
9218 (funcall gnus-summary-highlight-line-function article face))))
9221 (defun gnus-update-read-articles (group unread &optional compute)
9222 "Update the list of read articles in GROUP."
9223 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9224 (entry (gnus-gethash group gnus-newsrc-hashtb))
9225 (info (nth 2 entry))
9227 (unread (sort (copy-sequence unread) '<))
9229 (if (or (not info) (not active))
9230 ;; There is no info on this group if it was, in fact,
9231 ;; killed. Gnus stores no information on killed groups, so
9232 ;; there's nothing to be done.
9233 ;; One could store the information somewhere temporarily,
9234 ;; perhaps... Hmmm...
9236 ;; Remove any negative articles numbers.
9237 (while (and unread (< (car unread) 0))
9238 (setq unread (cdr unread)))
9239 ;; Remove any expired article numbers
9240 (while (and unread (< (car unread) (car active)))
9241 (setq unread (cdr unread)))
9242 ;; Compute the ranges of read articles by looking at the list of
9245 (when (/= (car unread) prev)
9246 (push (if (= prev (1- (car unread))) prev
9247 (cons prev (1- (car unread))))
9249 (setq prev (1+ (car unread)))
9250 (setq unread (cdr unread)))
9251 (when (<= prev (cdr active))
9252 (push (cons prev (cdr active)) read))
9253 (setq read (if (> (length read) 1) (nreverse read) read))
9257 (set-buffer gnus-group-buffer)
9260 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9261 (gnus-info-set-read ',info ',(gnus-info-read info))
9262 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9263 (gnus-group-update-group ,group t))))
9264 ;; Propagate the read marks to the backend.
9265 (if (gnus-check-backend-function 'request-set-mark group)
9266 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9267 (add (gnus-remove-from-range read (gnus-info-read info))))
9269 (unless (gnus-check-group group)
9270 (error "Can't open server for %s" group))
9271 (gnus-request-set-mark
9272 group (delq nil (list (if add (list add 'add '(read)))
9273 (if del (list del 'del '(read)))))))))
9274 ;; Enter this list into the group info.
9275 (gnus-info-set-read info read)
9276 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9277 (gnus-get-unread-articles-in-group info (gnus-active group))
9280 (defun gnus-offer-save-summaries ()
9281 "Offer to save all active summary buffers."
9283 (let ((buflist (buffer-list))
9285 ;; Go through all buffers and find all summaries.
9287 (and (setq bufname (buffer-name (car buflist)))
9288 (string-match "Summary" bufname)
9290 (set-buffer bufname)
9291 ;; We check that this is, indeed, a summary buffer.
9292 (and (eq major-mode 'gnus-summary-mode)
9293 ;; Also make sure this isn't bogus.
9294 gnus-newsgroup-prepared
9295 ;; Also make sure that this isn't a dead summary buffer.
9296 (not gnus-dead-summary-mode)))
9297 (push bufname buffers))
9298 (setq buflist (cdr buflist)))
9299 ;; Go through all these summary buffers and offer to save them.
9302 "Update summary buffer %s? "
9304 (switch-to-buffer buf)
9305 (gnus-summary-exit))
9309 ;;; @ for mime-partial
9312 (defun gnus-request-partial-message ()
9314 (let ((number (gnus-summary-article-number))
9315 (group gnus-newsgroup-name)
9316 (mother gnus-article-buffer))
9317 (set-buffer (get-buffer-create " *Partial Article*"))
9319 (setq mime-preview-buffer mother)
9320 (gnus-request-article-this-buffer number group)
9324 (autoload 'mime-combine-message/partial-pieces-automatically
9326 "Internal method to combine message/partial messages automatically.")
9329 'action '((type . message)(subtype . partial)
9330 (major-mode . gnus-original-article-mode)
9331 (method . mime-combine-message/partial-pieces-automatically)
9332 (summary-buffer-exp . gnus-summary-buffer)
9333 (request-partial-message-method . gnus-request-partial-message)
9337 ;;; @ for message/rfc822
9340 (defun gnus-mime-extract-message/rfc822 (entity situation)
9341 (let (group article num cwin swin cur)
9342 (with-current-buffer (mime-entity-buffer entity)
9344 (narrow-to-region (mime-entity-body-start entity)
9345 (mime-entity-body-end entity))
9346 (setq group (or (cdr (assq 'group situation))
9347 (completing-read "Group: "
9350 (gnus-read-active-file-p)
9351 gnus-newsgroup-name))
9352 article (gnus-request-accept-article group)
9355 (when (and (consp article)
9356 (numberp (setq article (cdr article))))
9357 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9358 cwin (get-buffer-window (current-buffer) t)
9360 (save-window-excursion
9361 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9362 (select-window swin)
9363 (set-buffer gnus-summary-buffer)
9365 (setq cur gnus-current-article)
9367 (let (gnus-show-threads)
9368 (gnus-summary-goto-subject article t)
9370 (gnus-summary-clear-mark-forward 1)
9371 (gnus-summary-goto-subject cur)
9373 (when (and cwin (window-frame cwin))
9374 (select-frame (window-frame cwin))
9376 (when (boundp 'mime-acting-situation-to-override)
9377 (set-alist 'mime-acting-situation-to-override
9380 (set-alist 'mime-acting-situation-to-override
9383 (save-current-buffer
9384 (set-buffer gnus-group-buffer)
9385 (gnus-activate-group ,group)
9387 (gnus-summary-goto-article ,cur
9388 gnus-show-all-headers)
9390 (set-alist 'mime-acting-situation-to-override
9396 'action '((type . message)(subtype . rfc822)
9397 (major-mode . gnus-original-article-mode)
9398 (method . gnus-mime-extract-message/rfc822)
9403 'action '((type . message)(subtype . news)
9404 (major-mode . gnus-original-article-mode)
9405 (method . gnus-mime-extract-message/rfc822)
9409 (defun gnus-mime-extract-multipart (entity situation)
9410 (let ((children (mime-entity-children entity))
9411 mime-acting-situation-to-override
9414 (mime-play-entity (car children)
9415 (cons (assq 'mode situation)
9416 mime-acting-situation-to-override))
9417 (setq children (cdr children)))
9418 (if (setq f (cdr (assq 'after-method
9419 mime-acting-situation-to-override)))
9424 'action '((type . multipart)
9425 (method . gnus-mime-extract-multipart)
9434 (defun gnus-summary-setup-default-charset ()
9435 "Setup newsgroup default charset."
9436 (let* ((name (and gnus-newsgroup-name
9437 (gnus-group-real-name gnus-newsgroup-name)))
9439 (or gnus-newsgroup-ephemeral-ignored-charsets
9441 (and gnus-newsgroup-name
9442 (or (gnus-group-find-parameter gnus-newsgroup-name
9443 'ignored-charsets t)
9444 (let ((alist gnus-group-ignored-charsets-alist)
9445 elem (charsets nil))
9446 (while (setq elem (pop alist))
9448 (string-match (car elem) name))
9450 charsets (cdr elem))))
9452 gnus-newsgroup-ignored-charsets)))
9453 (setq gnus-newsgroup-charset
9454 (or gnus-newsgroup-ephemeral-charset
9455 (and gnus-newsgroup-name
9456 (or (gnus-group-find-parameter gnus-newsgroup-name
9458 (let ((alist gnus-group-charset-alist)
9460 (while (setq elem (pop alist))
9462 (string-match (car elem) name))
9464 charset (cadr elem))))
9466 gnus-default-charset))
9467 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9474 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9475 "Display the current article buffer fully MIME-buttonized.
9476 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9477 treated as multipart/mixed."
9480 (let ((gnus-unbuttonized-mime-types nil)
9481 (gnus-mime-display-multipart-as-mixed show-all-parts))
9482 (gnus-summary-show-article)))
9484 (defun gnus-summary-repair-multipart (article)
9485 "Add a Content-Type header to a multipart article without one."
9486 (interactive (list (gnus-summary-article-number)))
9487 (gnus-with-article article
9488 (message-narrow-to-head)
9489 (goto-char (point-max))
9491 (when (search-forward "\n--" nil t)
9492 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9493 (message-narrow-to-head)
9494 (message-remove-header "Mime-Version")
9495 (message-remove-header "Content-Type")
9496 (goto-char (point-max))
9497 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9499 (insert "Mime-Version: 1.0\n")
9501 (let (gnus-mark-article-hook)
9502 (gnus-summary-select-article t t nil article)))
9504 (defun gnus-summary-toggle-display-buttonized ()
9505 "Toggle the buttonizing of the article buffer."
9508 (if (setq gnus-inhibit-mime-unbuttonizing
9509 (not gnus-inhibit-mime-unbuttonizing))
9510 (let ((gnus-unbuttonized-mime-types nil))
9511 (gnus-summary-show-article))
9512 (gnus-summary-show-article)))
9518 (defmacro gnus-with-article (article &rest forms)
9519 "Select ARTICLE and perform FORMS in the original article buffer.
9520 Then replace the article with the result."
9522 ;; We don't want the article to be marked as read.
9523 (let (gnus-mark-article-hook)
9524 (gnus-summary-select-article t t nil ,article))
9525 (set-buffer gnus-original-article-buffer)
9527 (if (not (gnus-check-backend-function
9528 'request-replace-article (car gnus-article-current)))
9529 (gnus-message 5 "Read-only group; not replacing")
9530 (unless (gnus-request-replace-article
9531 ,article (car gnus-article-current)
9533 (error "Couldn't replace article")))
9534 ;; The cache and backlog have to be flushed somewhat.
9535 (when gnus-keep-backlog
9536 (gnus-backlog-remove-article
9537 (car gnus-article-current) (cdr gnus-article-current)))
9538 (when gnus-use-cache
9539 (gnus-cache-update-article
9540 (car gnus-article-current) (cdr gnus-article-current)))))
9542 (put 'gnus-with-article 'lisp-indent-function 1)
9543 (put 'gnus-with-article 'edebug-form-spec '(form body))
9546 ;;; Generic summary marking commands
9549 (defvar gnus-summary-marking-alist
9550 '((read gnus-del-mark "d")
9551 (unread gnus-unread-mark "u")
9552 (ticked gnus-ticked-mark "!")
9553 (dormant gnus-dormant-mark "?")
9554 (expirable gnus-expirable-mark "e"))
9555 "An alist of names/marks/keystrokes.")
9557 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9558 (defvar gnus-summary-mark-map)
9560 (defun gnus-summary-make-all-marking-commands ()
9561 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9562 (dolist (elem gnus-summary-marking-alist)
9563 (apply 'gnus-summary-make-marking-command elem)))
9565 (defun gnus-summary-make-marking-command (name mark keystroke)
9566 (let ((map (make-sparse-keymap)))
9567 (define-key gnus-summary-generic-mark-map keystroke map)
9568 (dolist (lway `((next "next" next nil "n")
9569 (next-unread "next unread" next t "N")
9570 (prev "previous" prev nil "p")
9571 (prev-unread "previous unread" prev t "P")
9572 (nomove "" nil nil ,keystroke)))
9573 (let ((func (gnus-summary-make-marking-command-1
9574 mark (car lway) lway name)))
9575 (setq func (eval func))
9576 (define-key map (nth 4 lway) func)))))
9578 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9580 (format "gnus-summary-put-mark-as-%s%s"
9581 name (if (eq way 'nomove)
9583 (concat "-" (symbol-name way)))))
9586 "Mark the current article as %s%s.
9587 If N, the prefix, then repeat N times.
9588 If N is negative, move in reverse order.
9589 The difference between N and the actual number of articles marked is
9593 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9595 (defun gnus-summary-generic-mark (n mark move unread)
9596 "Mark N articles with MARK."
9597 (unless (eq major-mode 'gnus-summary-mode)
9598 (error "This command can only be used in the summary buffer"))
9599 (gnus-summary-show-thread)
9603 ((eq move 'prev) -1)
9609 nummove (* -1 nummove))))
9611 (gnus-summary-mark-article nil mark)
9612 (zerop (gnus-summary-next-subject nummove unread t)))
9615 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9616 (gnus-summary-recenter)
9617 (gnus-summary-position-point)
9618 (gnus-set-mode-line 'summary)
9621 (gnus-summary-make-all-marking-commands)
9627 (run-hooks 'gnus-sum-load-hook)
9629 ;;; gnus-sum.el ends here