1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
38 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (defcustom gnus-kill-summary-on-exit t
41 "*If non-nil, kill the summary buffer when you exit from it.
42 If nil, the summary will become a \"*Dead Summary*\" buffer, and
43 it will be killed sometime later."
44 :group 'gnus-summary-exit
47 (defcustom gnus-fetch-old-headers nil
48 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
49 If an unread article in the group refers to an older, already read (or
50 just marked as read) article, the old article will not normally be
51 displayed in the Summary buffer. If this variable is non-nil, Gnus
52 will attempt to grab the headers to the old articles, and thereby
53 build complete threads. If it has the value `some', only enough
54 headers to connect otherwise loose threads will be displayed. This
55 variable can also be a number. In that case, no more than that number
56 of old headers will be fetched. If it has the value `invisible', all
57 old headers will be fetched, but none will be displayed.
59 The server has to support NOV for any of this to work."
61 :type '(choice (const :tag "off" nil)
64 (sexp :menu-tag "other" t)))
66 (defcustom gnus-refer-thread-limit 200
67 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
68 If t, fetch all the available old headers."
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-summary-make-false-root 'adopt
74 "*nil means that Gnus won't gather loose threads.
75 If the root of a thread has expired or been read in a previous
76 session, the information necessary to build a complete thread has been
77 lost. Instead of having many small sub-threads from this original thread
78 scattered all over the summary buffer, Gnus can gather them.
80 If non-nil, Gnus will try to gather all loose sub-threads from an
81 original thread into one large thread.
83 If this variable is non-nil, it should be one of `none', `adopt',
86 If this variable is `none', Gnus will not make a false root, but just
87 present the sub-threads after another.
88 If this variable is `dummy', Gnus will create a dummy root that will
89 have all the sub-threads as children.
90 If this variable is `adopt', Gnus will make one of the \"children\"
91 the parent and mark all the step-children as such.
92 If this variable is `empty', the \"children\" are printed with empty
93 subject fields. (Or rather, they will be printed with a string
94 given by the `gnus-summary-same-subject' variable.)"
96 :type '(choice (const :tag "off" nil)
102 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
103 "*A regexp to match subjects to be excluded from loose thread gathering.
104 As loose thread gathering is done on subjects only, that means that
105 there can be many false gatherings performed. By rooting out certain
106 common subjects, gathering might become saner."
110 (defcustom gnus-summary-gather-subject-limit nil
111 "*Maximum length of subject comparisons when gathering loose threads.
112 Use nil to compare full subjects. Setting this variable to a low
113 number will help gather threads that have been corrupted by
114 newsreaders chopping off subject lines, but it might also mean that
115 unrelated articles that have subject that happen to begin with the
116 same few characters will be incorrectly gathered.
118 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
121 :type '(choice (const :tag "off" nil)
123 (sexp :menu-tag "on" t)))
125 (defcustom gnus-simplify-subject-functions nil
126 "List of functions taking a string argument that simplify subjects.
127 The functions are applied recursively.
129 Useful functions to put in this list include: `gnus-simplify-subject-re',
130 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
132 :type '(repeat function))
134 (defcustom gnus-simplify-ignored-prefixes nil
135 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
137 :type '(choice (const :tag "off" nil)
140 (defcustom gnus-build-sparse-threads nil
141 "*If non-nil, fill in the gaps in threads.
142 If `some', only fill in the gaps that are needed to tie loose threads
143 together. If `more', fill in all leaf nodes that Gnus can find. If
144 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
146 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "all" t)))
151 (defcustom gnus-summary-thread-gathering-function
152 'gnus-gather-threads-by-subject
153 "*Function used for gathering loose threads.
154 There are two pre-defined functions: `gnus-gather-threads-by-subject',
155 which only takes Subjects into consideration; and
156 `gnus-gather-threads-by-references', which compared the References
157 headers of the articles to find matches."
159 :type '(radio (function-item gnus-gather-threads-by-subject)
160 (function-item gnus-gather-threads-by-references)
161 (function :tag "other")))
163 (defcustom gnus-summary-same-subject ""
164 "*String indicating that the current article has the same subject as the previous.
165 This variable will only be used if the value of
166 `gnus-summary-make-false-root' is `empty'."
167 :group 'gnus-summary-format
170 (defcustom gnus-summary-goto-unread t
171 "*If t, marking commands will go to the next unread article.
172 If `never', commands that usually go to the next unread article, will
173 go to the next article, whether it is read or not.
174 If nil, only the marking commands will go to the next (un)read article."
175 :group 'gnus-summary-marks
176 :link '(custom-manual "(gnus)Setting Marks")
177 :type '(choice (const :tag "off" nil)
179 (sexp :menu-tag "on" t)))
181 (defcustom gnus-summary-default-score 0
182 "*Default article score level.
183 All scores generated by the score files will be added to this score.
184 If this variable is nil, scoring will be disabled."
185 :group 'gnus-score-default
186 :type '(choice (const :tag "disable")
189 (defcustom gnus-summary-zcore-fuzz 0
190 "*Fuzziness factor for the zcore in the summary buffer.
191 Articles with scores closer than this to `gnus-summary-default-score'
193 :group 'gnus-summary-format
196 (defcustom gnus-simplify-subject-fuzzy-regexp nil
197 "*Strings to be removed when doing fuzzy matches.
198 This can either be a regular expression or list of regular expressions
199 that will be removed from subject strings if fuzzy subject
200 simplification is selected."
202 :type '(repeat regexp))
204 (defcustom gnus-show-threads t
205 "*If non-nil, display threads in summary mode."
209 (defcustom gnus-thread-hide-subtree nil
210 "*If non-nil, hide all threads initially.
211 If threads are hidden, you have to run the command
212 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
213 to expose hidden threads."
217 (defcustom gnus-thread-hide-killed t
218 "*If non-nil, hide killed threads automatically."
222 (defcustom gnus-thread-ignore-subject t
223 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
224 If nil, articles that have different subjects from their parents will
225 start separate threads."
229 (defcustom gnus-thread-operation-ignore-subject t
230 "*If non-nil, subjects will be ignored when doing thread commands.
231 This affects commands like `gnus-summary-kill-thread' and
232 `gnus-summary-lower-thread'.
234 If this variable is nil, articles in the same thread with different
235 subjects will not be included in the operation in question. If this
236 variable is `fuzzy', only articles that have subjects that are fuzzily
237 equal will be included."
239 :type '(choice (const :tag "off" nil)
243 (defcustom gnus-thread-indent-level 4
244 "*Number that says how much each sub-thread should be indented."
248 (defcustom gnus-auto-extend-newsgroup t
249 "*If non-nil, extend newsgroup forward and backward when requested."
250 :group 'gnus-summary-choose
253 (defcustom gnus-auto-select-first t
254 "*If nil, don't select the first unread article when entering a group.
255 If this variable is `best', select the highest-scored unread article
256 in the group. If t, select the first unread article.
258 This variable can also be a function to place point on a likely
259 subject line. Useful values include `gnus-summary-first-unread-subject',
260 `gnus-summary-first-unread-article' and
261 `gnus-summary-best-unread-article'.
263 If you want to prevent automatic selection of the first unread article
264 in some newsgroups, set the variable to nil in
265 `gnus-select-group-hook'."
266 :group 'gnus-group-select
267 :type '(choice (const :tag "none" nil)
269 (sexp :menu-tag "first" t)
270 (function-item gnus-summary-first-unread-subject)
271 (function-item gnus-summary-first-unread-article)
272 (function-item gnus-summary-best-unread-article)))
274 (defcustom gnus-auto-select-next t
275 "*If non-nil, offer to go to the next group from the end of the previous.
276 If the value is t and the next newsgroup is empty, Gnus will exit
277 summary mode and go back to group mode. If the value is neither nil
278 nor t, Gnus will select the following unread newsgroup. In
279 particular, if the value is the symbol `quietly', the next unread
280 newsgroup will be selected without any confirmation, and if it is
281 `almost-quietly', the next group will be selected without any
282 confirmation if you are located on the last article in the group.
283 Finally, if this variable is `slightly-quietly', the `Z n' command
284 will go to the next group without confirmation."
285 :group 'gnus-summary-maneuvering
286 :type '(choice (const :tag "off" nil)
288 (const almost-quietly)
289 (const slightly-quietly)
290 (sexp :menu-tag "on" t)))
292 (defcustom gnus-auto-select-same nil
293 "*If non-nil, select the next article with the same subject.
294 If there are no more articles with the same subject, go to
295 the first unread article."
296 :group 'gnus-summary-maneuvering
299 (defcustom gnus-summary-check-current nil
300 "*If non-nil, consider the current article when moving.
301 The \"unread\" movement commands will stay on the same line if the
302 current article is unread."
303 :group 'gnus-summary-maneuvering
306 (defcustom gnus-auto-center-summary t
307 "*If non-nil, always center the current summary buffer.
308 In particular, if `vertical' do only vertical recentering. If non-nil
309 and non-`vertical', do both horizontal and vertical recentering."
310 :group 'gnus-summary-maneuvering
311 :type '(choice (const :tag "none" nil)
313 (integer :tag "height")
314 (sexp :menu-tag "both" t)))
316 (defcustom gnus-show-all-headers nil
317 "*If non-nil, don't hide any headers."
318 :group 'gnus-article-hiding
319 :group 'gnus-article-headers
322 (defcustom gnus-summary-ignore-duplicates nil
323 "*If non-nil, ignore articles with identical Message-ID headers."
327 (defcustom gnus-single-article-buffer t
328 "*If non-nil, display all articles in the same buffer.
329 If nil, each group will get its own article buffer."
330 :group 'gnus-article-various
333 (defcustom gnus-break-pages t
334 "*If non-nil, do page breaking on articles.
335 The page delimiter is specified by the `gnus-page-delimiter'
337 :group 'gnus-article-various
340 (defcustom gnus-move-split-methods nil
341 "*Variable used to suggest where articles are to be moved to.
342 It uses the same syntax as the `gnus-split-methods' variable."
343 :group 'gnus-summary-mail
344 :type '(repeat (choice (list :value (fun) function)
345 (cons :value ("" "") regexp (repeat string))
348 (defcustom gnus-unread-mark ? ;Whitespace
349 "*Mark used for unread articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-ticked-mark ?!
354 "*Mark used for ticked articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-dormant-mark ??
359 "*Mark used for dormant articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-del-mark ?r
364 "*Mark used for del'd articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-read-mark ?R
369 "*Mark used for read articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-expirable-mark ?E
374 "*Mark used for expirable articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-killed-mark ?K
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-souped-mark ?F
384 "*Mark used for killed articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-kill-file-mark ?X
389 "*Mark used for articles killed by kill files."
390 :group 'gnus-summary-marks
393 (defcustom gnus-low-score-mark ?Y
394 "*Mark used for articles with a low score."
395 :group 'gnus-summary-marks
398 (defcustom gnus-catchup-mark ?C
399 "*Mark used for articles that are caught up."
400 :group 'gnus-summary-marks
403 (defcustom gnus-replied-mark ?A
404 "*Mark used for articles that have been replied to."
405 :group 'gnus-summary-marks
408 (defcustom gnus-cached-mark ?*
409 "*Mark used for articles that are in the cache."
410 :group 'gnus-summary-marks
413 (defcustom gnus-saved-mark ?S
414 "*Mark used for articles that have been saved to."
415 :group 'gnus-summary-marks
418 (defcustom gnus-ancient-mark ?O
419 "*Mark used for ancient articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-sparse-mark ?Q
424 "*Mark used for sparsely reffed articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-canceled-mark ?G
429 "*Mark used for canceled articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-duplicate-mark ?M
434 "*Mark used for duplicate articles."
435 :group 'gnus-summary-marks
438 (defcustom gnus-undownloaded-mark ?@
439 "*Mark used for articles that weren't downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-downloadable-mark ?%
444 "*Mark used for articles that are to be downloaded."
445 :group 'gnus-summary-marks
448 (defcustom gnus-unsendable-mark ?=
449 "*Mark used for articles that won't be sent."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-over-mark ?+
454 "*Score mark used for articles with high scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-score-below-mark ?-
459 "*Score mark used for articles with low scores."
460 :group 'gnus-summary-marks
463 (defcustom gnus-empty-thread-mark ? ;Whitespace
464 "*There is no thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-not-empty-thread-mark ?=
469 "*There is a thread under the article."
470 :group 'gnus-summary-marks
473 (defcustom gnus-view-pseudo-asynchronously nil
474 "*If non-nil, Gnus will view pseudo-articles asynchronously."
475 :group 'gnus-extract-view
478 (defcustom gnus-auto-expirable-marks
479 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
480 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
481 gnus-souped-mark gnus-duplicate-mark)
482 "*The list of marks converted into expiration if a group is auto-expirable."
484 :type '(repeat character))
486 (defcustom gnus-inhibit-user-auto-expire t
487 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
491 (defcustom gnus-view-pseudos nil
492 "*If `automatic', pseudo-articles will be viewed automatically.
493 If `not-confirm', pseudos will be viewed automatically, and the user
494 will not be asked to confirm the command."
495 :group 'gnus-extract-view
496 :type '(choice (const :tag "off" nil)
498 (const not-confirm)))
500 (defcustom gnus-view-pseudos-separately t
501 "*If non-nil, one pseudo-article will be created for each file to be viewed.
502 If nil, all files that use the same viewing command will be given as a
503 list of parameters to that command."
504 :group 'gnus-extract-view
507 (defcustom gnus-insert-pseudo-articles t
508 "*If non-nil, insert pseudo-articles when decoding articles."
509 :group 'gnus-extract-view
512 (defcustom gnus-summary-dummy-line-format
514 "*The format specification for the dummy roots in the summary buffer.
515 It works along the same lines as a normal formatting string,
516 with some simple extensions.
519 :group 'gnus-threading
522 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
523 "*The format specification for the summary mode line.
524 It works along the same lines as a normal formatting string,
525 with some simple extensions:
528 %p Unprefixed group name
529 %A Current article number
530 %z Current article score
532 %U Number of unread articles in the group
533 %e Number of unselected articles in the group
534 %Z A string with unread/unselected article counts
535 %g Shortish group name
536 %S Subject of the current article
538 %s Current score file name
539 %d Number of dormant articles
540 %r Number of articles that have been marked as read in this session
541 %E Number of articles expunged by the score files"
542 :group 'gnus-summary-format
545 (defcustom gnus-summary-mark-below 0
546 "*Mark all articles with a score below this variable as read.
547 This variable is local to each summary buffer and usually set by the
549 :group 'gnus-score-default
552 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
553 "*List of functions used for sorting articles in the summary buffer.
554 This variable is only used when not using a threaded display."
555 :group 'gnus-summary-sort
556 :type '(repeat (choice (function-item gnus-article-sort-by-number)
557 (function-item gnus-article-sort-by-author)
558 (function-item gnus-article-sort-by-subject)
559 (function-item gnus-article-sort-by-date)
560 (function-item gnus-article-sort-by-score)
561 (function :tag "other"))))
563 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
564 "*List of functions used for sorting threads in the summary buffer.
565 By default, threads are sorted by article number.
567 Each function takes two threads and return non-nil if the first thread
568 should be sorted before the other. If you use more than one function,
569 the primary sort function should be the last. You should probably
570 always include `gnus-thread-sort-by-number' in the list of sorting
571 functions -- preferably first.
573 Ready-made functions include `gnus-thread-sort-by-number',
574 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
575 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
576 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
577 :group 'gnus-summary-sort
578 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
579 (function-item gnus-thread-sort-by-author)
580 (function-item gnus-thread-sort-by-subject)
581 (function-item gnus-thread-sort-by-date)
582 (function-item gnus-thread-sort-by-score)
583 (function-item gnus-thread-sort-by-total-score)
584 (function :tag "other"))))
586 (defcustom gnus-thread-score-function '+
587 "*Function used for calculating the total score of a thread.
589 The function is called with the scores of the article and each
590 subthread and should then return the score of the thread.
592 Some functions you can use are `+', `max', or `min'."
593 :group 'gnus-summary-sort
596 (defcustom gnus-summary-expunge-below nil
597 "All articles that have a score less than this variable will be expunged.
598 This variable is local to the summary buffers."
599 :group 'gnus-score-default
600 :type '(choice (const :tag "off" nil)
603 (defcustom gnus-thread-expunge-below nil
604 "All threads that have a total score less than this variable will be expunged.
605 See `gnus-thread-score-function' for en explanation of what a
608 This variable is local to the summary buffers."
609 :group 'gnus-threading
610 :group 'gnus-score-default
611 :type '(choice (const :tag "off" nil)
614 (defcustom gnus-summary-mode-hook nil
615 "*A hook for Gnus summary mode.
616 This hook is run before any variables are set in the summary buffer."
617 :group 'gnus-summary-various
620 (defcustom gnus-summary-menu-hook nil
621 "*Hook run after the creation of the summary mode menu."
622 :group 'gnus-summary-visual
625 (defcustom gnus-summary-exit-hook nil
626 "*A hook called on exit from the summary buffer.
627 It will be called with point in the group buffer."
628 :group 'gnus-summary-exit
631 (defcustom gnus-summary-prepare-hook nil
632 "*A hook called after the summary buffer has been generated.
633 If you want to modify the summary buffer, you can use this hook."
634 :group 'gnus-summary-various
637 (defcustom gnus-summary-prepared-hook nil
638 "*A hook called as the last thing after the summary buffer has been generated."
639 :group 'gnus-summary-various
642 (defcustom gnus-summary-generate-hook nil
643 "*A hook run just before generating the summary buffer.
644 This hook is commonly used to customize threading variables and the
646 :group 'gnus-summary-various
649 (defcustom gnus-select-group-hook nil
650 "*A hook called when a newsgroup is selected.
652 If you'd like to simplify subjects like the
653 `gnus-summary-next-same-subject' command does, you can use the
656 (setq gnus-select-group-hook
659 (mapcar (lambda (header)
660 (mail-header-set-subject
662 (gnus-simplify-subject
663 (mail-header-subject header) 're-only)))
664 gnus-newsgroup-headers))))"
665 :group 'gnus-group-select
668 (defcustom gnus-select-article-hook nil
669 "*A hook called when an article is selected."
670 :group 'gnus-summary-choose
673 (defcustom gnus-visual-mark-article-hook
674 (list 'gnus-highlight-selected-summary)
675 "*Hook run after selecting an article in the summary buffer.
676 It is meant to be used for highlighting the article in some way. It
677 is not run if `gnus-visual' is nil."
678 :group 'gnus-summary-visual
681 (defcustom gnus-parse-headers-hook nil
682 "*A hook called before parsing the headers."
686 (defcustom gnus-exit-group-hook nil
687 "*A hook called when exiting (not quitting) summary mode."
691 (defcustom gnus-summary-update-hook
692 (list 'gnus-summary-highlight-line)
693 "*A hook called when a summary line is changed.
694 The hook will not be called if `gnus-visual' is nil.
696 The default function `gnus-summary-highlight-line' will
697 highlight the line according to the `gnus-summary-highlight'
699 :group 'gnus-summary-visual
702 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
703 "*A hook called when an article is selected for the first time.
704 The hook is intended to mark an article as read (or unread)
705 automatically when it is selected."
706 :group 'gnus-summary-choose
709 (defcustom gnus-group-no-more-groups-hook nil
710 "*A hook run when returning to group mode having no more (unread) groups."
711 :group 'gnus-group-select
714 (defcustom gnus-ps-print-hook nil
715 "*A hook run before ps-printing something from Gnus."
719 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
720 "Face used for highlighting the current article in the summary buffer."
721 :group 'gnus-summary-visual
724 (defcustom gnus-summary-highlight
725 '(((= mark gnus-canceled-mark)
726 . gnus-summary-cancelled-face)
727 ((and (> score default)
728 (or (= mark gnus-dormant-mark)
729 (= mark gnus-ticked-mark)))
730 . gnus-summary-high-ticked-face)
731 ((and (< score default)
732 (or (= mark gnus-dormant-mark)
733 (= mark gnus-ticked-mark)))
734 . gnus-summary-low-ticked-face)
735 ((or (= mark gnus-dormant-mark)
736 (= mark gnus-ticked-mark))
737 . gnus-summary-normal-ticked-face)
738 ((and (> score default) (= mark gnus-ancient-mark))
739 . gnus-summary-high-ancient-face)
740 ((and (< score default) (= mark gnus-ancient-mark))
741 . gnus-summary-low-ancient-face)
742 ((= mark gnus-ancient-mark)
743 . gnus-summary-normal-ancient-face)
744 ((and (> score default) (= mark gnus-unread-mark))
745 . gnus-summary-high-unread-face)
746 ((and (< score default) (= mark gnus-unread-mark))
747 . gnus-summary-low-unread-face)
748 ((= mark gnus-unread-mark)
749 . gnus-summary-normal-unread-face)
750 ((and (> score default) (memq mark (list gnus-downloadable-mark
751 gnus-undownloaded-mark)))
752 . gnus-summary-high-unread-face)
753 ((and (< score default) (memq mark (list gnus-downloadable-mark
754 gnus-undownloaded-mark)))
755 . gnus-summary-low-unread-face)
756 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
757 . gnus-summary-normal-unread-face)
759 . gnus-summary-high-read-face)
761 . gnus-summary-low-read-face)
763 . gnus-summary-normal-read-face))
764 "*Controls the highlighting of summary buffer lines.
766 A list of (FORM . FACE) pairs. When deciding how a a particular
767 summary line should be displayed, each form is evaluated. The content
768 of the face field after the first true form is used. You can change
769 how those summary lines are displayed, by editing the face field.
771 You can use the following variables in the FORM field.
773 score: The articles score
774 default: The default article score.
775 below: The score below which articles are automatically marked as read.
776 mark: The articles mark."
777 :group 'gnus-summary-visual
778 :type '(repeat (cons (sexp :tag "Form" nil)
781 (defcustom gnus-alter-header-function nil
782 "Function called to allow alteration of article header structures.
783 The function is called with one parameter, the article header vector,
784 which it may alter in any way.")
786 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
787 "Variable that says which function should be used to decode a string with encoded words.")
789 (defcustom gnus-extra-headers nil
790 "*Extra headers to parse."
792 :type '(repeat symbol))
794 (defcustom gnus-ignored-from-addresses
795 (and user-mail-address (regexp-quote user-mail-address))
796 "*Regexp of From headers that may be suppressed in favor of To headers."
800 (defcustom gnus-group-charset-alist
801 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
802 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
803 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
804 ("^relcom\\>" koi8-r)
805 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
806 ("^israel\\>" iso-8859-1)
808 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
810 "Alist of regexps (to match group names) and default charsets to be used when reading."
811 :type '(repeat (list (regexp :tag "Group")
812 (symbol :tag "Charset")))
813 :group 'gnus-charset)
815 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
816 "List of charsets that should be ignored.
817 When these charsets are used in the \"charset\" parameter, the
818 default charset will be used instead."
819 :type '(repeat symbol)
820 :group 'gnus-charset)
822 ;;; Internal variables
824 (defvar gnus-article-mime-handles nil)
825 (defvar gnus-article-decoded-p nil)
826 (defvar gnus-scores-exclude-files nil)
827 (defvar gnus-page-broken nil)
828 (defvar gnus-inhibit-mime-unbuttonizing nil)
830 (defvar gnus-original-article nil)
831 (defvar gnus-article-internal-prepare-hook nil)
832 (defvar gnus-newsgroup-process-stack nil)
834 (defvar gnus-thread-indent-array nil)
835 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
837 ;; Avoid highlighting in kill files.
838 (defvar gnus-summary-inhibit-highlight nil)
839 (defvar gnus-newsgroup-selected-overlay nil)
840 (defvar gnus-inhibit-limiting nil)
841 (defvar gnus-newsgroup-adaptive-score-file nil)
842 (defvar gnus-current-score-file nil)
843 (defvar gnus-current-move-group nil)
844 (defvar gnus-current-copy-group nil)
845 (defvar gnus-current-crosspost-group nil)
847 (defvar gnus-newsgroup-dependencies nil)
848 (defvar gnus-newsgroup-adaptive nil)
849 (defvar gnus-summary-display-article-function nil)
850 (defvar gnus-summary-highlight-line-function nil
851 "Function called after highlighting a summary line.")
853 (defvar gnus-summary-line-format-alist
854 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
855 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
856 (?s gnus-tmp-subject-or-nil ?s)
857 (?n gnus-tmp-name ?s)
858 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
860 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
862 (?F gnus-tmp-from ?s)
863 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
864 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
865 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
866 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
867 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
868 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
869 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
870 (?L gnus-tmp-lines ?d)
871 (?I gnus-tmp-indentation ?s)
872 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
873 (?R gnus-tmp-replied ?c)
874 (?\[ gnus-tmp-opening-bracket ?c)
875 (?\] gnus-tmp-closing-bracket ?c)
876 (?\> (make-string gnus-tmp-level ? ) ?s)
877 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
878 (?i gnus-tmp-score ?d)
879 (?z gnus-tmp-score-char ?c)
880 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
881 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
882 (?U gnus-tmp-unread ?c)
883 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
884 (?t (gnus-summary-number-of-articles-in-thread
885 (and (boundp 'thread) (car thread)) gnus-tmp-level)
887 (?e (gnus-summary-number-of-articles-in-thread
888 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
890 (?u gnus-tmp-user-defined ?s)
891 (?P (gnus-pick-line-number) ?d))
892 "An alist of format specifications that can appear in summary lines,
893 and what variables they correspond with, along with the type of the
894 variable (string, integer, character, etc).")
896 (defvar gnus-summary-dummy-line-format-alist
897 `((?S gnus-tmp-subject ?s)
898 (?N gnus-tmp-number ?d)
899 (?u gnus-tmp-user-defined ?s)))
901 (defvar gnus-summary-mode-line-format-alist
902 `((?G gnus-tmp-group-name ?s)
903 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
904 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
905 (?A gnus-tmp-article-number ?d)
906 (?Z gnus-tmp-unread-and-unselected ?s)
908 (?U gnus-tmp-unread-and-unticked ?d)
909 (?S gnus-tmp-subject ?s)
910 (?e gnus-tmp-unselected ?d)
911 (?u gnus-tmp-user-defined ?s)
912 (?d (length gnus-newsgroup-dormant) ?d)
913 (?t (length gnus-newsgroup-marked) ?d)
914 (?r (length gnus-newsgroup-reads) ?d)
915 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
916 (?E gnus-newsgroup-expunged-tally ?d)
917 (?s (gnus-current-score-file-nondirectory) ?s)))
919 (defvar gnus-last-search-regexp nil
920 "Default regexp for article search command.")
922 (defvar gnus-last-shell-command nil
923 "Default shell command on article.")
925 (defvar gnus-newsgroup-begin nil)
926 (defvar gnus-newsgroup-end nil)
927 (defvar gnus-newsgroup-last-rmail nil)
928 (defvar gnus-newsgroup-last-mail nil)
929 (defvar gnus-newsgroup-last-folder nil)
930 (defvar gnus-newsgroup-last-file nil)
931 (defvar gnus-newsgroup-auto-expire nil)
932 (defvar gnus-newsgroup-active nil)
934 (defvar gnus-newsgroup-data nil)
935 (defvar gnus-newsgroup-data-reverse nil)
936 (defvar gnus-newsgroup-limit nil)
937 (defvar gnus-newsgroup-limits nil)
939 (defvar gnus-newsgroup-unreads nil
940 "List of unread articles in the current newsgroup.")
942 (defvar gnus-newsgroup-unselected nil
943 "List of unselected unread articles in the current newsgroup.")
945 (defvar gnus-newsgroup-reads nil
946 "Alist of read articles and article marks in the current newsgroup.")
948 (defvar gnus-newsgroup-expunged-tally nil)
950 (defvar gnus-newsgroup-marked nil
951 "List of ticked articles in the current newsgroup (a subset of unread art).")
953 (defvar gnus-newsgroup-killed nil
954 "List of ranges of articles that have been through the scoring process.")
956 (defvar gnus-newsgroup-cached nil
957 "List of articles that come from the article cache.")
959 (defvar gnus-newsgroup-saved nil
960 "List of articles that have been saved.")
962 (defvar gnus-newsgroup-kill-headers nil)
964 (defvar gnus-newsgroup-replied nil
965 "List of articles that have been replied to in the current newsgroup.")
967 (defvar gnus-newsgroup-expirable nil
968 "List of articles in the current newsgroup that can be expired.")
970 (defvar gnus-newsgroup-processable nil
971 "List of articles in the current newsgroup that can be processed.")
973 (defvar gnus-newsgroup-downloadable nil
974 "List of articles in the current newsgroup that can be processed.")
976 (defvar gnus-newsgroup-undownloaded nil
977 "List of articles in the current newsgroup that haven't been downloaded..")
979 (defvar gnus-newsgroup-unsendable nil
980 "List of articles in the current newsgroup that won't be sent.")
982 (defvar gnus-newsgroup-bookmarks nil
983 "List of articles in the current newsgroup that have bookmarks.")
985 (defvar gnus-newsgroup-dormant nil
986 "List of dormant articles in the current newsgroup.")
988 (defvar gnus-newsgroup-scored nil
989 "List of scored articles in the current newsgroup.")
991 (defvar gnus-newsgroup-headers nil
992 "List of article headers in the current newsgroup.")
994 (defvar gnus-newsgroup-threads nil)
996 (defvar gnus-newsgroup-prepared nil
997 "Whether the current group has been prepared properly.")
999 (defvar gnus-newsgroup-ancient nil
1000 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1002 (defvar gnus-newsgroup-sparse nil)
1004 (defvar gnus-current-article nil)
1005 (defvar gnus-article-current nil)
1006 (defvar gnus-current-headers nil)
1007 (defvar gnus-have-all-headers nil)
1008 (defvar gnus-last-article nil)
1009 (defvar gnus-newsgroup-history nil)
1010 (defvar gnus-newsgroup-charset nil)
1012 (defconst gnus-summary-local-variables
1013 '(gnus-newsgroup-name
1014 gnus-newsgroup-begin gnus-newsgroup-end
1015 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1016 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1017 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1018 gnus-newsgroup-unselected gnus-newsgroup-marked
1019 gnus-newsgroup-reads gnus-newsgroup-saved
1020 gnus-newsgroup-replied gnus-newsgroup-expirable
1021 gnus-newsgroup-processable gnus-newsgroup-killed
1022 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1023 gnus-newsgroup-unsendable
1024 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1025 gnus-newsgroup-headers gnus-newsgroup-threads
1026 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1027 gnus-current-article gnus-current-headers gnus-have-all-headers
1028 gnus-last-article gnus-article-internal-prepare-hook
1029 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1030 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1031 gnus-thread-expunge-below
1032 gnus-score-alist gnus-current-score-file
1033 (gnus-summary-expunge-below . global)
1034 (gnus-summary-mark-below . global)
1035 gnus-newsgroup-active gnus-scores-exclude-files
1036 gnus-newsgroup-history gnus-newsgroup-ancient
1037 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1038 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1039 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1040 (gnus-newsgroup-expunged-tally . 0)
1041 gnus-cache-removable-articles gnus-newsgroup-cached
1042 gnus-newsgroup-data gnus-newsgroup-data-reverse
1043 gnus-newsgroup-limit gnus-newsgroup-limits
1044 gnus-newsgroup-charset)
1045 "Variables that are buffer-local to the summary buffers.")
1047 ;; Byte-compiler warning.
1048 (defvar gnus-article-mode-map)
1052 (defvar gnus-decode-encoded-word-methods
1053 '(mail-decode-encoded-word-string)
1054 "List of methods used to decode encoded words.
1056 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1057 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1058 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1059 whose names match REGEXP.
1062 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1063 mail-decode-encoded-word-string
1064 (\"chinese\" . rfc1843-decode-string))
1067 (defvar gnus-decode-encoded-word-methods-cache nil)
1069 (defun gnus-multi-decode-encoded-word-string (string)
1070 "Apply the functions from `gnus-encoded-word-methods' that match."
1071 (unless (and gnus-decode-encoded-word-methods-cache
1072 (eq gnus-newsgroup-name
1073 (car gnus-decode-encoded-word-methods-cache)))
1074 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1077 (nconc gnus-decode-encoded-word-methods-cache (list x))
1078 (if (and gnus-newsgroup-name
1079 (string-match (car x) gnus-newsgroup-name))
1080 (nconc gnus-decode-encoded-word-methods-cache
1082 gnus-decode-encoded-word-methods))
1083 (let ((xlist gnus-decode-encoded-word-methods-cache))
1086 (setq string (funcall (pop xlist) string))))
1089 ;; Subject simplification.
1091 (defun gnus-simplify-whitespace (str)
1092 "Remove excessive whitespace."
1095 (while (string-match "[ \t][ \t]+" mystr)
1096 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1098 (substring mystr (match-end 0)))))
1100 (when (string-match "^[ \t]+" mystr)
1101 (setq mystr (substring mystr (match-end 0))))
1103 (when (string-match "[ \t]+$" mystr)
1104 (setq mystr (substring mystr 0 (match-beginning 0))))
1107 (defsubst gnus-simplify-subject-re (subject)
1108 "Remove \"Re:\" from subject lines."
1109 (if (string-match "^[Rr][Ee]: *" subject)
1110 (substring subject (match-end 0))
1113 (defun gnus-simplify-subject (subject &optional re-only)
1114 "Remove `Re:' and words in parentheses.
1115 If RE-ONLY is non-nil, strip leading `Re:'s only."
1116 (let ((case-fold-search t)) ;Ignore case.
1117 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1118 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1119 (setq subject (substring subject (match-end 0))))
1120 ;; Remove uninteresting prefixes.
1121 (when (and (not re-only)
1122 gnus-simplify-ignored-prefixes
1123 (string-match gnus-simplify-ignored-prefixes subject))
1124 (setq subject (substring subject (match-end 0))))
1125 ;; Remove words in parentheses from end.
1127 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1128 (setq subject (substring subject 0 (match-beginning 0)))))
1129 ;; Return subject string.
1132 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1134 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1135 (goto-char (point-min))
1136 (while (re-search-forward regexp nil t)
1137 (replace-match (or newtext ""))))
1139 (defun gnus-simplify-buffer-fuzzy ()
1140 "Simplify string in the buffer fuzzily.
1141 The string in the accessible portion of the current buffer is simplified.
1142 It is assumed to be a single-line subject.
1143 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1144 matter is removed. Additional things can be deleted by setting
1145 gnus-simplify-subject-fuzzy-regexp."
1146 (let ((case-fold-search t)
1148 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1150 (while (not (eq modified-tick (buffer-modified-tick)))
1151 (setq modified-tick (buffer-modified-tick))
1153 ((listp gnus-simplify-subject-fuzzy-regexp)
1154 (mapcar 'gnus-simplify-buffer-fuzzy-step
1155 gnus-simplify-subject-fuzzy-regexp))
1156 (gnus-simplify-subject-fuzzy-regexp
1157 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1158 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1159 (gnus-simplify-buffer-fuzzy-step
1160 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1161 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1163 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1164 (gnus-simplify-buffer-fuzzy-step " +" " ")
1165 (gnus-simplify-buffer-fuzzy-step " $")
1166 (gnus-simplify-buffer-fuzzy-step "^ +")))
1168 (defun gnus-simplify-subject-fuzzy (subject)
1169 "Simplify a subject string fuzzily.
1170 See `gnus-simplify-buffer-fuzzy' for details."
1172 (gnus-set-work-buffer)
1173 (let ((case-fold-search t))
1174 ;; Remove uninteresting prefixes.
1175 (when (and gnus-simplify-ignored-prefixes
1176 (string-match gnus-simplify-ignored-prefixes subject))
1177 (setq subject (substring subject (match-end 0))))
1179 (inline (gnus-simplify-buffer-fuzzy))
1182 (defsubst gnus-simplify-subject-fully (subject)
1183 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1185 (gnus-simplify-subject-functions
1186 (gnus-map-function gnus-simplify-subject-functions subject))
1187 ((null gnus-summary-gather-subject-limit)
1188 (gnus-simplify-subject-re subject))
1189 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1190 (gnus-simplify-subject-fuzzy subject))
1191 ((numberp gnus-summary-gather-subject-limit)
1192 (gnus-limit-string (gnus-simplify-subject-re subject)
1193 gnus-summary-gather-subject-limit))
1197 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1198 "Check whether two subjects are equal.
1199 If optional argument simple-first is t, first argument is already
1202 ((null simple-first)
1203 (equal (gnus-simplify-subject-fully s1)
1204 (gnus-simplify-subject-fully s2)))
1207 (gnus-simplify-subject-fully s2)))))
1209 (defun gnus-summary-bubble-group ()
1210 "Increase the score of the current group.
1211 This is a handy function to add to `gnus-summary-exit-hook' to
1212 increase the score of each group you read."
1213 (gnus-group-add-score gnus-newsgroup-name))
1217 ;;; Gnus summary mode
1220 (put 'gnus-summary-mode 'mode-class 'special)
1223 ;; Non-orthogonal keys
1225 (gnus-define-keys gnus-summary-mode-map
1226 " " gnus-summary-next-page
1227 "\177" gnus-summary-prev-page
1228 [delete] gnus-summary-prev-page
1229 [backspace] gnus-summary-prev-page
1230 "\r" gnus-summary-scroll-up
1231 "\M-\r" gnus-summary-scroll-down
1232 "n" gnus-summary-next-unread-article
1233 "p" gnus-summary-prev-unread-article
1234 "N" gnus-summary-next-article
1235 "P" gnus-summary-prev-article
1236 "\M-\C-n" gnus-summary-next-same-subject
1237 "\M-\C-p" gnus-summary-prev-same-subject
1238 "\M-n" gnus-summary-next-unread-subject
1239 "\M-p" gnus-summary-prev-unread-subject
1240 "." gnus-summary-first-unread-article
1241 "," gnus-summary-best-unread-article
1242 "\M-s" gnus-summary-search-article-forward
1243 "\M-r" gnus-summary-search-article-backward
1244 "<" gnus-summary-beginning-of-article
1245 ">" gnus-summary-end-of-article
1246 "j" gnus-summary-goto-article
1247 "^" gnus-summary-refer-parent-article
1248 "\M-^" gnus-summary-refer-article
1249 "u" gnus-summary-tick-article-forward
1250 "!" gnus-summary-tick-article-forward
1251 "U" gnus-summary-tick-article-backward
1252 "d" gnus-summary-mark-as-read-forward
1253 "D" gnus-summary-mark-as-read-backward
1254 "E" gnus-summary-mark-as-expirable
1255 "\M-u" gnus-summary-clear-mark-forward
1256 "\M-U" gnus-summary-clear-mark-backward
1257 "k" gnus-summary-kill-same-subject-and-select
1258 "\C-k" gnus-summary-kill-same-subject
1259 "\M-\C-k" gnus-summary-kill-thread
1260 "\M-\C-l" gnus-summary-lower-thread
1261 "e" gnus-summary-edit-article
1262 "#" gnus-summary-mark-as-processable
1263 "\M-#" gnus-summary-unmark-as-processable
1264 "\M-\C-t" gnus-summary-toggle-threads
1265 "\M-\C-s" gnus-summary-show-thread
1266 "\M-\C-h" gnus-summary-hide-thread
1267 "\M-\C-f" gnus-summary-next-thread
1268 "\M-\C-b" gnus-summary-prev-thread
1269 "\M-\C-u" gnus-summary-up-thread
1270 "\M-\C-d" gnus-summary-down-thread
1271 "&" gnus-summary-execute-command
1272 "c" gnus-summary-catchup-and-exit
1273 "\C-w" gnus-summary-mark-region-as-read
1274 "\C-t" gnus-summary-toggle-truncation
1275 "?" gnus-summary-mark-as-dormant
1276 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1277 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1278 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1279 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1280 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1281 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1282 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1283 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1284 "=" gnus-summary-expand-window
1285 "\C-x\C-s" gnus-summary-reselect-current-group
1286 "\M-g" gnus-summary-rescan-group
1287 "w" gnus-summary-stop-page-breaking
1288 "\C-c\C-r" gnus-summary-caesar-message
1289 "f" gnus-summary-followup
1290 "F" gnus-summary-followup-with-original
1291 "C" gnus-summary-cancel-article
1292 "r" gnus-summary-reply
1293 "R" gnus-summary-reply-with-original
1294 "\C-c\C-f" gnus-summary-mail-forward
1295 "o" gnus-summary-save-article
1296 "\C-o" gnus-summary-save-article-mail
1297 "|" gnus-summary-pipe-output
1298 "\M-k" gnus-summary-edit-local-kill
1299 "\M-K" gnus-summary-edit-global-kill
1301 "\C-c\C-d" gnus-summary-describe-group
1302 "q" gnus-summary-exit
1303 "Q" gnus-summary-exit-no-update
1304 "\C-c\C-i" gnus-info-find-node
1305 gnus-mouse-2 gnus-mouse-pick-article
1306 "m" gnus-summary-mail-other-window
1307 "a" gnus-summary-post-news
1308 "x" gnus-summary-limit-to-unread
1309 "s" gnus-summary-isearch-article
1310 "t" gnus-summary-toggle-header
1311 "g" gnus-summary-show-article
1312 "l" gnus-summary-goto-last-article
1313 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1314 "\C-d" gnus-summary-enter-digest-group
1315 "\M-\C-d" gnus-summary-read-document
1316 "\M-\C-e" gnus-summary-edit-parameters
1317 "\M-\C-g" gnus-summary-customize-parameters
1319 "*" gnus-cache-enter-article
1320 "\M-*" gnus-cache-remove-article
1321 "\M-&" gnus-summary-universal-argument
1322 "\C-l" gnus-recenter
1323 "I" gnus-summary-increase-score
1324 "L" gnus-summary-lower-score
1325 "\M-i" gnus-symbolic-argument
1326 "h" gnus-summary-select-article-buffer
1328 "b" gnus-article-view-part
1329 "\M-t" gnus-summary-toggle-display-buttonized
1331 "V" gnus-summary-score-map
1332 "X" gnus-uu-extract-map
1333 "S" gnus-summary-send-map)
1335 ;; Sort of orthogonal keymap
1336 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1337 "t" gnus-summary-tick-article-forward
1338 "!" gnus-summary-tick-article-forward
1339 "d" gnus-summary-mark-as-read-forward
1340 "r" gnus-summary-mark-as-read-forward
1341 "c" gnus-summary-clear-mark-forward
1342 " " gnus-summary-clear-mark-forward
1343 "e" gnus-summary-mark-as-expirable
1344 "x" gnus-summary-mark-as-expirable
1345 "?" gnus-summary-mark-as-dormant
1346 "b" gnus-summary-set-bookmark
1347 "B" gnus-summary-remove-bookmark
1348 "#" gnus-summary-mark-as-processable
1349 "\M-#" gnus-summary-unmark-as-processable
1350 "S" gnus-summary-limit-include-expunged
1351 "C" gnus-summary-catchup
1352 "H" gnus-summary-catchup-to-here
1353 "\C-c" gnus-summary-catchup-all
1354 "k" gnus-summary-kill-same-subject-and-select
1355 "K" gnus-summary-kill-same-subject
1356 "P" gnus-uu-mark-map)
1358 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1359 "c" gnus-summary-clear-above
1360 "u" gnus-summary-tick-above
1361 "m" gnus-summary-mark-above
1362 "k" gnus-summary-kill-below)
1364 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1365 "/" gnus-summary-limit-to-subject
1366 "n" gnus-summary-limit-to-articles
1367 "w" gnus-summary-pop-limit
1368 "s" gnus-summary-limit-to-subject
1369 "a" gnus-summary-limit-to-author
1370 "u" gnus-summary-limit-to-unread
1371 "m" gnus-summary-limit-to-marks
1372 "M" gnus-summary-limit-exclude-marks
1373 "v" gnus-summary-limit-to-score
1374 "*" gnus-summary-limit-include-cached
1375 "D" gnus-summary-limit-include-dormant
1376 "T" gnus-summary-limit-include-thread
1377 "d" gnus-summary-limit-exclude-dormant
1378 "t" gnus-summary-limit-to-age
1379 "E" gnus-summary-limit-include-expunged
1380 "c" gnus-summary-limit-exclude-childless-dormant
1381 "C" gnus-summary-limit-mark-excluded-as-read)
1383 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1384 "n" gnus-summary-next-unread-article
1385 "p" gnus-summary-prev-unread-article
1386 "N" gnus-summary-next-article
1387 "P" gnus-summary-prev-article
1388 "\C-n" gnus-summary-next-same-subject
1389 "\C-p" gnus-summary-prev-same-subject
1390 "\M-n" gnus-summary-next-unread-subject
1391 "\M-p" gnus-summary-prev-unread-subject
1392 "f" gnus-summary-first-unread-article
1393 "b" gnus-summary-best-unread-article
1394 "j" gnus-summary-goto-article
1395 "g" gnus-summary-goto-subject
1396 "l" gnus-summary-goto-last-article
1397 "o" gnus-summary-pop-article)
1399 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1400 "k" gnus-summary-kill-thread
1401 "l" gnus-summary-lower-thread
1402 "i" gnus-summary-raise-thread
1403 "T" gnus-summary-toggle-threads
1404 "t" gnus-summary-rethread-current
1405 "^" gnus-summary-reparent-thread
1406 "s" gnus-summary-show-thread
1407 "S" gnus-summary-show-all-threads
1408 "h" gnus-summary-hide-thread
1409 "H" gnus-summary-hide-all-threads
1410 "n" gnus-summary-next-thread
1411 "p" gnus-summary-prev-thread
1412 "u" gnus-summary-up-thread
1413 "o" gnus-summary-top-thread
1414 "d" gnus-summary-down-thread
1415 "#" gnus-uu-mark-thread
1416 "\M-#" gnus-uu-unmark-thread)
1418 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1419 "g" gnus-summary-prepare
1420 "c" gnus-summary-insert-cached-articles)
1422 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1423 "c" gnus-summary-catchup-and-exit
1424 "C" gnus-summary-catchup-all-and-exit
1425 "E" gnus-summary-exit-no-update
1426 "Q" gnus-summary-exit
1427 "Z" gnus-summary-exit
1428 "n" gnus-summary-catchup-and-goto-next-group
1429 "R" gnus-summary-reselect-current-group
1430 "G" gnus-summary-rescan-group
1431 "N" gnus-summary-next-group
1432 "s" gnus-summary-save-newsrc
1433 "P" gnus-summary-prev-group)
1435 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1436 " " gnus-summary-next-page
1437 "n" gnus-summary-next-page
1438 "\177" gnus-summary-prev-page
1439 [delete] gnus-summary-prev-page
1440 "p" gnus-summary-prev-page
1441 "\r" gnus-summary-scroll-up
1442 "\M-\r" gnus-summary-scroll-down
1443 "<" gnus-summary-beginning-of-article
1444 ">" gnus-summary-end-of-article
1445 "b" gnus-summary-beginning-of-article
1446 "e" gnus-summary-end-of-article
1447 "^" gnus-summary-refer-parent-article
1448 "r" gnus-summary-refer-parent-article
1449 "R" gnus-summary-refer-references
1450 "T" gnus-summary-refer-thread
1451 "g" gnus-summary-show-article
1452 "s" gnus-summary-isearch-article
1453 "P" gnus-summary-print-article)
1455 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1456 "b" gnus-article-add-buttons
1457 "B" gnus-article-add-buttons-to-head
1458 "o" gnus-article-treat-overstrike
1459 "e" gnus-article-emphasize
1460 "w" gnus-article-fill-cited-article
1461 "Q" gnus-article-fill-long-lines
1462 "C" gnus-article-capitalize-sentences
1463 "c" gnus-article-remove-cr
1464 "q" gnus-article-de-quoted-unreadable
1465 "f" gnus-article-display-x-face
1466 "l" gnus-summary-stop-page-breaking
1467 "r" gnus-summary-caesar-message
1468 "t" gnus-article-hide-headers
1469 "v" gnus-summary-verbose-headers
1470 "h" gnus-article-treat-html
1471 "H" gnus-article-strip-headers-in-body
1472 "d" gnus-article-treat-dumbquotes)
1474 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1475 "a" gnus-article-hide
1476 "h" gnus-article-hide-headers
1477 "b" gnus-article-hide-boring-headers
1478 "s" gnus-article-hide-signature
1479 "c" gnus-article-hide-citation
1480 "C" gnus-article-hide-citation-in-followups
1481 "p" gnus-article-hide-pgp
1482 "B" gnus-article-strip-banner
1483 "P" gnus-article-hide-pem
1484 "\C-c" gnus-article-hide-citation-maybe)
1486 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1487 "a" gnus-article-highlight
1488 "h" gnus-article-highlight-headers
1489 "c" gnus-article-highlight-citation
1490 "s" gnus-article-highlight-signature)
1492 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1493 "w" gnus-article-decode-mime-words
1494 "c" gnus-article-decode-charset
1495 "v" gnus-mime-view-all-parts
1496 "b" gnus-article-view-part)
1498 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1499 "z" gnus-article-date-ut
1500 "u" gnus-article-date-ut
1501 "l" gnus-article-date-local
1502 "e" gnus-article-date-lapsed
1503 "o" gnus-article-date-original
1504 "i" gnus-article-date-iso8601
1505 "s" gnus-article-date-user)
1507 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1508 "t" gnus-article-remove-trailing-blank-lines
1509 "l" gnus-article-strip-leading-blank-lines
1510 "m" gnus-article-strip-multiple-blank-lines
1511 "a" gnus-article-strip-blank-lines
1512 "A" gnus-article-strip-all-blank-lines
1513 "s" gnus-article-strip-leading-space
1514 "e" gnus-article-strip-trailing-space)
1516 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1518 "f" gnus-summary-fetch-faq
1519 "d" gnus-summary-describe-group
1520 "h" gnus-summary-describe-briefly
1521 "i" gnus-info-find-node)
1523 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1524 "e" gnus-summary-expire-articles
1525 "\M-\C-e" gnus-summary-expire-articles-now
1526 "\177" gnus-summary-delete-article
1527 [delete] gnus-summary-delete-article
1528 "m" gnus-summary-move-article
1529 "r" gnus-summary-respool-article
1530 "w" gnus-summary-edit-article
1531 "c" gnus-summary-copy-article
1532 "B" gnus-summary-crosspost-article
1533 "q" gnus-summary-respool-query
1534 "t" gnus-summary-respool-trace
1535 "i" gnus-summary-import-article
1536 "p" gnus-summary-article-posted-p)
1538 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1539 "o" gnus-summary-save-article
1540 "m" gnus-summary-save-article-mail
1541 "F" gnus-summary-write-article-file
1542 "r" gnus-summary-save-article-rmail
1543 "f" gnus-summary-save-article-file
1544 "b" gnus-summary-save-article-body-file
1545 "h" gnus-summary-save-article-folder
1546 "v" gnus-summary-save-article-vm
1547 "p" gnus-summary-pipe-output
1548 "s" gnus-soup-add-article)
1550 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1551 "b" gnus-summary-display-buttonized
1552 "m" gnus-summary-repair-multipart
1553 "v" gnus-article-view-part
1554 "o" gnus-article-save-part
1555 "c" gnus-article-copy-part
1556 "e" gnus-article-externalize-part
1557 "i" gnus-article-inline-part
1558 "|" gnus-article-pipe-part)
1561 (defun gnus-summary-make-menu-bar ()
1562 (gnus-turn-off-edit-menu 'summary)
1564 (unless (boundp 'gnus-summary-misc-menu)
1567 gnus-summary-kill-menu gnus-summary-mode-map ""
1572 ["Enter score..." gnus-summary-score-entry t]
1573 ["Customize" gnus-score-customize t])
1574 (gnus-make-score-map 'increase)
1575 (gnus-make-score-map 'lower)
1577 ["Kill below" gnus-summary-kill-below t]
1578 ["Mark above" gnus-summary-mark-above t]
1579 ["Tick above" gnus-summary-tick-above t]
1580 ["Clear above" gnus-summary-clear-above t])
1581 ["Current score" gnus-summary-current-score t]
1582 ["Set score" gnus-summary-set-score t]
1583 ["Switch current score file..." gnus-score-change-score-file t]
1584 ["Set mark below..." gnus-score-set-mark-below t]
1585 ["Set expunge below..." gnus-score-set-expunge-below t]
1586 ["Edit current score file" gnus-score-edit-current-scores t]
1587 ["Edit score file" gnus-score-edit-file t]
1588 ["Trace score" gnus-score-find-trace t]
1589 ["Find words" gnus-score-find-favourite-words t]
1590 ["Rescore buffer" gnus-summary-rescore t]
1591 ["Increase score..." gnus-summary-increase-score t]
1592 ["Lower score..." gnus-summary-lower-score t]))))
1594 ;; Define both the Article menu in the summary buffer and the equivalent
1595 ;; Commands menu in the article buffer here for consistency.
1598 ["All" gnus-article-hide t]
1599 ["Headers" gnus-article-hide-headers t]
1600 ["Signature" gnus-article-hide-signature t]
1601 ["Citation" gnus-article-hide-citation t]
1602 ["PGP" gnus-article-hide-pgp t]
1603 ["Banner" gnus-article-strip-banner t]
1604 ["Boring headers" gnus-article-hide-boring-headers t])
1606 ["All" gnus-article-highlight t]
1607 ["Headers" gnus-article-highlight-headers t]
1608 ["Signature" gnus-article-highlight-signature t]
1609 ["Citation" gnus-article-highlight-citation t])
1611 ["Words" gnus-article-decode-mime-words t]
1612 ["Charset" gnus-article-decode-charset t]
1613 ["QP" gnus-article-de-quoted-unreadable t]
1614 ["View all" gnus-mime-view-all-parts t])
1616 ["Local" gnus-article-date-local t]
1617 ["ISO8601" gnus-article-date-iso8601 t]
1618 ["UT" gnus-article-date-ut t]
1619 ["Original" gnus-article-date-original t]
1620 ["Lapsed" gnus-article-date-lapsed t]
1621 ["User-defined" gnus-article-date-user t])
1624 ["Leading" gnus-article-strip-leading-blank-lines t]
1625 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1626 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1627 ["All of the above" gnus-article-strip-blank-lines t]
1628 ["All" gnus-article-strip-all-blank-lines t]
1629 ["Leading space" gnus-article-strip-leading-space t]
1630 ["Trailing space" gnus-article-strip-trailing-space t])
1631 ["Overstrike" gnus-article-treat-overstrike t]
1632 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1633 ["Emphasis" gnus-article-emphasize t]
1634 ["Word wrap" gnus-article-fill-cited-article t]
1635 ["Fill long lines" gnus-article-fill-long-lines t]
1636 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1637 ["CR" gnus-article-remove-cr t]
1638 ["Show X-Face" gnus-article-display-x-face t]
1639 ["Quoted-Printable" gnus-article-de-quoted-unreadable 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 ["Verbose header" gnus-summary-verbose-headers t]
1647 ["Toggle header" gnus-summary-toggle-header t])
1649 ["Save in default format" gnus-summary-save-article t]
1650 ["Save in file" gnus-summary-save-article-file t]
1651 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1652 ["Save in MH folder" gnus-summary-save-article-folder t]
1653 ["Save in VM folder" gnus-summary-save-article-vm t]
1654 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1655 ["Save body in file" gnus-summary-save-article-body-file t]
1656 ["Pipe through a filter" gnus-summary-pipe-output t]
1657 ["Add to SOUP packet" gnus-soup-add-article t]
1658 ["Print" gnus-summary-print-article t])
1660 ["Respool article..." gnus-summary-respool-article t]
1661 ["Move article..." gnus-summary-move-article
1662 (gnus-check-backend-function
1663 'request-move-article gnus-newsgroup-name)]
1664 ["Copy article..." gnus-summary-copy-article t]
1665 ["Crosspost article..." gnus-summary-crosspost-article
1666 (gnus-check-backend-function
1667 'request-replace-article gnus-newsgroup-name)]
1668 ["Import file..." gnus-summary-import-article t]
1669 ["Check if posted" gnus-summary-article-posted-p t]
1670 ["Edit article" gnus-summary-edit-article
1671 (not (gnus-group-read-only-p))]
1672 ["Delete article" gnus-summary-delete-article
1673 (gnus-check-backend-function
1674 'request-expire-articles gnus-newsgroup-name)]
1675 ["Query respool" gnus-summary-respool-query t]
1676 ["Trace respool" gnus-summary-respool-trace t]
1677 ["Delete expirable articles" gnus-summary-expire-articles-now
1678 (gnus-check-backend-function
1679 'request-expire-articles gnus-newsgroup-name)])
1681 ["Uudecode" gnus-uu-decode-uu t]
1682 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1683 ["Unshar" gnus-uu-decode-unshar t]
1684 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1685 ["Save" gnus-uu-decode-save t]
1686 ["Binhex" gnus-uu-decode-binhex t]
1687 ["Postscript" gnus-uu-decode-postscript t])
1689 ["Enter article" gnus-cache-enter-article t]
1690 ["Remove article" gnus-cache-remove-article t])
1691 ["Select article buffer" gnus-summary-select-article-buffer t]
1692 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1693 ["Isearch article..." gnus-summary-isearch-article t]
1694 ["Beginning of the article" gnus-summary-beginning-of-article t]
1695 ["End of the article" gnus-summary-end-of-article t]
1696 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1697 ["Fetch referenced articles" gnus-summary-refer-references t]
1698 ["Fetch current thread" gnus-summary-refer-thread t]
1699 ["Fetch article with id..." gnus-summary-refer-article t]
1700 ["Redisplay" gnus-summary-show-article t])))
1702 gnus-summary-article-menu gnus-summary-mode-map ""
1703 (cons "Article" innards))
1706 gnus-article-commands-menu gnus-article-mode-map ""
1707 (cons "Commands" innards)))
1710 gnus-summary-thread-menu gnus-summary-mode-map ""
1712 ["Toggle threading" gnus-summary-toggle-threads t]
1713 ["Hide threads" gnus-summary-hide-all-threads t]
1714 ["Show threads" gnus-summary-show-all-threads t]
1715 ["Hide thread" gnus-summary-hide-thread t]
1716 ["Show thread" gnus-summary-show-thread t]
1717 ["Go to next thread" gnus-summary-next-thread t]
1718 ["Go to previous thread" gnus-summary-prev-thread t]
1719 ["Go down thread" gnus-summary-down-thread t]
1720 ["Go up thread" gnus-summary-up-thread t]
1721 ["Top of thread" gnus-summary-top-thread t]
1722 ["Mark thread as read" gnus-summary-kill-thread t]
1723 ["Lower thread score" gnus-summary-lower-thread t]
1724 ["Raise thread score" gnus-summary-raise-thread t]
1725 ["Rethread current" gnus-summary-rethread-current t]
1729 gnus-summary-post-menu gnus-summary-mode-map ""
1731 ["Post an article" gnus-summary-post-news t]
1732 ["Followup" gnus-summary-followup t]
1733 ["Followup and yank" gnus-summary-followup-with-original t]
1734 ["Supersede article" gnus-summary-supersede-article t]
1735 ["Cancel article" gnus-summary-cancel-article t]
1736 ["Reply" gnus-summary-reply t]
1737 ["Reply and yank" gnus-summary-reply-with-original t]
1738 ["Wide reply" gnus-summary-wide-reply t]
1739 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1740 ["Mail forward" gnus-summary-mail-forward t]
1741 ["Post forward" gnus-summary-post-forward t]
1742 ["Digest and mail" gnus-uu-digest-mail-forward t]
1743 ["Digest and post" gnus-uu-digest-post-forward t]
1744 ["Resend message" gnus-summary-resend-message t]
1745 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1746 ["Send a mail" gnus-summary-mail-other-window t]
1747 ["Uuencode and post" gnus-uu-post-news t]
1748 ["Followup via news" gnus-summary-followup-to-mail t]
1749 ["Followup via news and yank"
1750 gnus-summary-followup-to-mail-with-original t]
1752 ;;["Send" gnus-summary-send-draft t]
1753 ;;["Send bounced" gnus-resend-bounced-mail t])
1757 gnus-summary-misc-menu gnus-summary-mode-map ""
1760 ["Mark as read" gnus-summary-mark-as-read-forward t]
1761 ["Mark same subject and select"
1762 gnus-summary-kill-same-subject-and-select t]
1763 ["Mark same subject" gnus-summary-kill-same-subject t]
1764 ["Catchup" gnus-summary-catchup t]
1765 ["Catchup all" gnus-summary-catchup-all t]
1766 ["Catchup to here" gnus-summary-catchup-to-here t]
1767 ["Catchup region" gnus-summary-mark-region-as-read t]
1768 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1770 ["Tick" gnus-summary-tick-article-forward t]
1771 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1772 ["Remove marks" gnus-summary-clear-mark-forward t]
1773 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1774 ["Set bookmark" gnus-summary-set-bookmark t]
1775 ["Remove bookmark" gnus-summary-remove-bookmark t])
1777 ["Marks..." gnus-summary-limit-to-marks t]
1778 ["Subject..." gnus-summary-limit-to-subject t]
1779 ["Author..." gnus-summary-limit-to-author t]
1780 ["Age..." gnus-summary-limit-to-age t]
1781 ["Score" gnus-summary-limit-to-score t]
1782 ["Unread" gnus-summary-limit-to-unread t]
1783 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1784 ["Articles" gnus-summary-limit-to-articles t]
1785 ["Pop limit" gnus-summary-pop-limit t]
1786 ["Show dormant" gnus-summary-limit-include-dormant t]
1787 ["Hide childless dormant"
1788 gnus-summary-limit-exclude-childless-dormant t]
1789 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1790 ["Hide marked" gnus-summary-limit-exclude-marks t]
1791 ["Show expunged" gnus-summary-show-all-expunged t])
1793 ["Set mark" gnus-summary-mark-as-processable t]
1794 ["Remove mark" gnus-summary-unmark-as-processable t]
1795 ["Remove all marks" gnus-summary-unmark-all-processable t]
1796 ["Mark above" gnus-uu-mark-over t]
1797 ["Mark series" gnus-uu-mark-series t]
1798 ["Mark region" gnus-uu-mark-region t]
1799 ["Unmark region" gnus-uu-unmark-region t]
1800 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1801 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1802 ["Mark all" gnus-uu-mark-all t]
1803 ["Mark buffer" gnus-uu-mark-buffer t]
1804 ["Mark sparse" gnus-uu-mark-sparse t]
1805 ["Mark thread" gnus-uu-mark-thread t]
1806 ["Unmark thread" gnus-uu-unmark-thread t]
1807 ("Process Mark Sets"
1808 ["Kill" gnus-summary-kill-process-mark t]
1809 ["Yank" gnus-summary-yank-process-mark
1810 gnus-newsgroup-process-stack]
1811 ["Save" gnus-summary-save-process-mark t]))
1813 ["Page forward" gnus-summary-next-page t]
1814 ["Page backward" gnus-summary-prev-page t]
1815 ["Line forward" gnus-summary-scroll-up t])
1817 ["Next unread article" gnus-summary-next-unread-article t]
1818 ["Previous unread article" gnus-summary-prev-unread-article t]
1819 ["Next article" gnus-summary-next-article t]
1820 ["Previous article" gnus-summary-prev-article t]
1821 ["Next unread subject" gnus-summary-next-unread-subject t]
1822 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1823 ["Next article same subject" gnus-summary-next-same-subject t]
1824 ["Previous article same subject" gnus-summary-prev-same-subject t]
1825 ["First unread article" gnus-summary-first-unread-article t]
1826 ["Best unread article" gnus-summary-best-unread-article t]
1827 ["Go to subject number..." gnus-summary-goto-subject t]
1828 ["Go to article number..." gnus-summary-goto-article t]
1829 ["Go to the last article" gnus-summary-goto-last-article t]
1830 ["Pop article off history" gnus-summary-pop-article t])
1832 ["Sort by number" gnus-summary-sort-by-number t]
1833 ["Sort by author" gnus-summary-sort-by-author t]
1834 ["Sort by subject" gnus-summary-sort-by-subject t]
1835 ["Sort by date" gnus-summary-sort-by-date t]
1836 ["Sort by score" gnus-summary-sort-by-score t]
1837 ["Sort by lines" gnus-summary-sort-by-lines t]
1838 ["Sort by characters" gnus-summary-sort-by-chars t])
1840 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1841 ["Describe group" gnus-summary-describe-group t]
1842 ["Read manual" gnus-info-find-node t])
1844 ["Pick and read" gnus-pick-mode t]
1845 ["Binary" gnus-binary-mode t])
1847 ["Regenerate" gnus-summary-prepare t]
1848 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1849 ["Toggle threading" gnus-summary-toggle-threads t])
1850 ["Filter articles..." gnus-summary-execute-command t]
1851 ["Run command on subjects..." gnus-summary-universal-argument t]
1852 ["Search articles forward..." gnus-summary-search-article-forward t]
1853 ["Search articles backward..." gnus-summary-search-article-backward t]
1854 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1855 ["Expand window" gnus-summary-expand-window t]
1856 ["Expire expirable articles" gnus-summary-expire-articles
1857 (gnus-check-backend-function
1858 'request-expire-articles gnus-newsgroup-name)]
1859 ["Edit local kill file" gnus-summary-edit-local-kill t]
1860 ["Edit main kill file" gnus-summary-edit-global-kill t]
1861 ["Edit group parameters" gnus-summary-edit-parameters t]
1862 ["Customize group parameters" gnus-summary-customize-parameters t]
1863 ["Send a bug report" gnus-bug t]
1865 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1866 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1867 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1868 ["Exit group" gnus-summary-exit t]
1869 ["Exit group without updating" gnus-summary-exit-no-update t]
1870 ["Exit and goto next group" gnus-summary-next-group t]
1871 ["Exit and goto prev group" gnus-summary-prev-group t]
1872 ["Reselect group" gnus-summary-reselect-current-group t]
1873 ["Rescan group" gnus-summary-rescan-group t]
1874 ["Update dribble" gnus-summary-save-newsrc t])))
1876 (gnus-run-hooks 'gnus-summary-menu-hook)))
1878 (defun gnus-score-set-default (var value)
1879 "A version of set that updates the GNU Emacs menu-bar."
1881 ;; It is the message that forces the active status to be updated.
1884 (defun gnus-make-score-map (type)
1885 "Make a summary score map of type TYPE."
1888 (let ((headers '(("author" "from" string)
1889 ("subject" "subject" string)
1890 ("article body" "body" string)
1891 ("article head" "head" string)
1892 ("xref" "xref" string)
1893 ("extra header" "extra" string)
1894 ("lines" "lines" number)
1895 ("followups to author" "followup" string)))
1896 (types '((number ("less than" <)
1899 (string ("substring" s)
1903 (perms '(("temporary" (current-time-string))
1911 (if (eq type 'lower)
1916 (setq header (car headers))
1922 (let ((ts (cdr (assoc (nth 2 header) types)))
1938 'gnus-summary-score-entry
1940 (if (or (string= (nth 1 header)
1942 (string= (nth 1 header)
1945 (list 'gnus-summary-header
1947 (list 'quote (nth 1 (car ts)))
1948 (list 'gnus-score-default nil)
1954 (list (nreverse outp))))
1957 (list (nreverse outt))))
1959 (setq headers (cdr headers)))
1960 (list (nreverse outh))))))))
1964 (defun gnus-summary-mode (&optional group)
1965 "Major mode for reading articles.
1967 All normal editing commands are switched off.
1968 \\<gnus-summary-mode-map>
1969 Each line in this buffer represents one article. To read an
1970 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1971 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1974 You can also post articles and send mail from this buffer. To
1975 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1976 of an article, type `\\[gnus-summary-reply]'.
1978 There are approx. one gazillion commands you can execute in this
1979 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1981 The following commands are available:
1983 \\{gnus-summary-mode-map}"
1985 (when (gnus-visual-p 'summary-menu 'menu)
1986 (gnus-summary-make-menu-bar))
1987 (kill-all-local-variables)
1988 (gnus-summary-make-local-variables)
1989 (gnus-make-thread-indent-array)
1990 (gnus-simplify-mode-line)
1991 (setq major-mode 'gnus-summary-mode)
1992 (setq mode-name "Summary")
1993 (make-local-variable 'minor-mode-alist)
1994 (use-local-map gnus-summary-mode-map)
1995 (buffer-disable-undo)
1996 (setq buffer-read-only t) ;Disable modification
1997 (setq truncate-lines t)
1998 (setq selective-display t)
1999 (setq selective-display-ellipses t) ;Display `...'
2000 (gnus-summary-set-display-table)
2001 (gnus-set-default-directory)
2002 (setq gnus-newsgroup-name group)
2003 (make-local-variable 'gnus-summary-line-format)
2004 (make-local-variable 'gnus-summary-line-format-spec)
2005 (make-local-variable 'gnus-summary-dummy-line-format)
2006 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2007 (make-local-variable 'gnus-summary-mark-positions)
2008 (make-local-hook 'pre-command-hook)
2009 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2010 (gnus-run-hooks 'gnus-summary-mode-hook)
2011 (mm-enable-multibyte)
2012 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2013 (gnus-update-summary-mark-positions))
2015 (defun gnus-summary-make-local-variables ()
2016 "Make all the local summary buffer variables."
2018 (dolist (local gnus-summary-local-variables)
2021 (if (eq (cdr local) 'global)
2022 ;; Copy the global value of the variable.
2023 (setq global (symbol-value (car local)))
2024 ;; Use the value from the list.
2025 (setq global (eval (cdr local))))
2026 (set (make-local-variable (car local)) global))
2027 ;; Simple nil-valued local variable.
2028 (set (make-local-variable local) nil)))))
2030 (defun gnus-summary-clear-local-variables ()
2031 (let ((locals gnus-summary-local-variables))
2033 (if (consp (car locals))
2034 (and (vectorp (caar locals))
2035 (set (caar locals) nil))
2036 (and (vectorp (car locals))
2037 (set (car locals) nil)))
2038 (setq locals (cdr locals)))))
2040 ;; Summary data functions.
2042 (defmacro gnus-data-number (data)
2045 (defmacro gnus-data-set-number (data number)
2046 `(setcar ,data ,number))
2048 (defmacro gnus-data-mark (data)
2051 (defmacro gnus-data-set-mark (data mark)
2052 `(setcar (nthcdr 1 ,data) ,mark))
2054 (defmacro gnus-data-pos (data)
2057 (defmacro gnus-data-set-pos (data pos)
2058 `(setcar (nthcdr 2 ,data) ,pos))
2060 (defmacro gnus-data-header (data)
2063 (defmacro gnus-data-set-header (data header)
2064 `(setf (nth 3 ,data) ,header))
2066 (defmacro gnus-data-level (data)
2069 (defmacro gnus-data-unread-p (data)
2070 `(= (nth 1 ,data) gnus-unread-mark))
2072 (defmacro gnus-data-read-p (data)
2073 `(/= (nth 1 ,data) gnus-unread-mark))
2075 (defmacro gnus-data-pseudo-p (data)
2076 `(consp (nth 3 ,data)))
2078 (defmacro gnus-data-find (number)
2079 `(assq ,number gnus-newsgroup-data))
2081 (defmacro gnus-data-find-list (number &optional data)
2082 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2083 (memq (assq ,number bdata)
2086 (defmacro gnus-data-make (number mark pos header level)
2087 `(list ,number ,mark ,pos ,header ,level))
2089 (defun gnus-data-enter (after-article number mark pos header level offset)
2090 (let ((data (gnus-data-find-list after-article)))
2092 (error "No such article: %d" after-article))
2093 (setcdr data (cons (gnus-data-make number mark pos header level)
2095 (setq gnus-newsgroup-data-reverse nil)
2096 (gnus-data-update-list (cddr data) offset)))
2098 (defun gnus-data-enter-list (after-article list &optional offset)
2100 (let ((data (and after-article (gnus-data-find-list after-article)))
2104 (let ((odata gnus-newsgroup-data))
2105 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2107 (gnus-data-update-list odata offset)))
2108 ;; Find the last element in the list to be spliced into the main
2111 (setq list (cdr list)))
2114 (setcdr list gnus-newsgroup-data)
2115 (setq gnus-newsgroup-data ilist)
2117 (gnus-data-update-list (cdr list) offset)))
2118 (setcdr list (cdr data))
2121 (gnus-data-update-list (cdr list) offset))))
2122 (setq gnus-newsgroup-data-reverse nil))))
2124 (defun gnus-data-remove (article &optional offset)
2125 (let ((data gnus-newsgroup-data))
2126 (if (= (gnus-data-number (car data)) article)
2128 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2129 gnus-newsgroup-data-reverse nil)
2131 (gnus-data-update-list gnus-newsgroup-data offset)))
2133 (when (= (gnus-data-number (cadr data)) article)
2134 (setcdr data (cddr data))
2136 (gnus-data-update-list (cdr data) offset))
2138 gnus-newsgroup-data-reverse nil))
2139 (setq data (cdr data))))))
2141 (defmacro gnus-data-list (backward)
2143 (or gnus-newsgroup-data-reverse
2144 (setq gnus-newsgroup-data-reverse
2145 (reverse gnus-newsgroup-data)))
2146 gnus-newsgroup-data))
2148 (defun gnus-data-update-list (data offset)
2149 "Add OFFSET to the POS of all data entries in DATA."
2150 (setq gnus-newsgroup-data-reverse nil)
2152 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2153 (setq data (cdr data))))
2155 (defun gnus-summary-article-pseudo-p (article)
2156 "Say whether this article is a pseudo article or not."
2157 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2159 (defmacro gnus-summary-article-sparse-p (article)
2160 "Say whether this article is a sparse article or not."
2161 `(memq ,article gnus-newsgroup-sparse))
2163 (defmacro gnus-summary-article-ancient-p (article)
2164 "Say whether this article is a sparse article or not."
2165 `(memq ,article gnus-newsgroup-ancient))
2167 (defun gnus-article-parent-p (number)
2168 "Say whether this article is a parent or not."
2169 (let ((data (gnus-data-find-list number)))
2170 (and (cdr data) ; There has to be an article after...
2171 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2172 (gnus-data-level (nth 1 data))))))
2174 (defun gnus-article-children (number)
2175 "Return a list of all children to NUMBER."
2176 (let* ((data (gnus-data-find-list number))
2177 (level (gnus-data-level (car data)))
2179 (setq data (cdr data))
2181 (= (gnus-data-level (car data)) (1+ level)))
2182 (push (gnus-data-number (car data)) children)
2183 (setq data (cdr data)))
2186 (defmacro gnus-summary-skip-intangible ()
2187 "If the current article is intangible, then jump to a different article."
2188 '(let ((to (get-text-property (point) 'gnus-intangible)))
2189 (and to (gnus-summary-goto-subject to))))
2191 (defmacro gnus-summary-article-intangible-p ()
2192 "Say whether this article is intangible or not."
2193 '(get-text-property (point) 'gnus-intangible))
2195 (defun gnus-article-read-p (article)
2196 "Say whether ARTICLE is read or not."
2197 (not (or (memq article gnus-newsgroup-marked)
2198 (memq article gnus-newsgroup-unreads)
2199 (memq article gnus-newsgroup-unselected)
2200 (memq article gnus-newsgroup-dormant))))
2202 ;; Some summary mode macros.
2204 (defmacro gnus-summary-article-number ()
2205 "The article number of the article on the current line.
2206 If there isn's an article number here, then we return the current
2209 (gnus-summary-skip-intangible)
2210 (or (get-text-property (point) 'gnus-number)
2211 (gnus-summary-last-subject))))
2213 (defmacro gnus-summary-article-header (&optional number)
2214 "Return the header of article NUMBER."
2215 `(gnus-data-header (gnus-data-find
2216 ,(or number '(gnus-summary-article-number)))))
2218 (defmacro gnus-summary-thread-level (&optional number)
2219 "Return the level of thread that starts with article NUMBER."
2220 `(if (and (eq gnus-summary-make-false-root 'dummy)
2221 (get-text-property (point) 'gnus-intangible))
2223 (gnus-data-level (gnus-data-find
2224 ,(or number '(gnus-summary-article-number))))))
2226 (defmacro gnus-summary-article-mark (&optional number)
2227 "Return the mark of article NUMBER."
2228 `(gnus-data-mark (gnus-data-find
2229 ,(or number '(gnus-summary-article-number)))))
2231 (defmacro gnus-summary-article-pos (&optional number)
2232 "Return the position of the line of article NUMBER."
2233 `(gnus-data-pos (gnus-data-find
2234 ,(or number '(gnus-summary-article-number)))))
2236 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2237 (defmacro gnus-summary-article-subject (&optional number)
2238 "Return current subject string or nil if nothing."
2241 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2242 '(gnus-data-header (assq (gnus-summary-article-number)
2243 gnus-newsgroup-data)))))
2246 (mail-header-subject headers))))
2248 (defmacro gnus-summary-article-score (&optional number)
2249 "Return current article score."
2250 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2251 gnus-newsgroup-scored))
2252 gnus-summary-default-score 0))
2254 (defun gnus-summary-article-children (&optional number)
2255 "Return a list of article numbers that are children of article NUMBER."
2256 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2257 (level (gnus-data-level (car data)))
2259 (while (and (setq data (cdr data))
2260 (> (setq l (gnus-data-level (car data))) level))
2261 (and (= (1+ level) l)
2262 (push (gnus-data-number (car data))
2264 (nreverse children)))
2266 (defun gnus-summary-article-parent (&optional number)
2267 "Return the article number of the parent of article NUMBER."
2268 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2269 (gnus-data-list t)))
2270 (level (gnus-data-level (car data))))
2272 () ; This is a root.
2273 ;; We search until we find an article with a level less than
2274 ;; this one. That function has to be the parent.
2275 (while (and (setq data (cdr data))
2276 (not (< (gnus-data-level (car data)) level))))
2277 (and data (gnus-data-number (car data))))))
2279 (defun gnus-unread-mark-p (mark)
2280 "Say whether MARK is the unread mark."
2281 (= mark gnus-unread-mark))
2283 (defun gnus-read-mark-p (mark)
2284 "Say whether MARK is one of the marks that mark as read.
2285 This is all marks except unread, ticked, dormant, and expirable."
2286 (not (or (= mark gnus-unread-mark)
2287 (= mark gnus-ticked-mark)
2288 (= mark gnus-dormant-mark)
2289 (= mark gnus-expirable-mark))))
2291 (defmacro gnus-article-mark (number)
2292 "Return the MARK of article NUMBER.
2293 This macro should only be used when computing the mark the \"first\"
2294 time; i.e., when generating the summary lines. After that,
2295 `gnus-summary-article-mark' should be used to examine the
2298 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2299 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2300 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2301 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2302 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2303 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2304 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2305 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2306 gnus-ancient-mark))))
2308 ;; Saving hidden threads.
2310 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2311 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2313 (defmacro gnus-save-hidden-threads (&rest forms)
2314 "Save hidden threads, eval FORMS, and restore the hidden threads."
2315 (let ((config (make-symbol "config")))
2316 `(let ((,config (gnus-hidden-threads-configuration)))
2320 (gnus-restore-hidden-threads-configuration ,config)))))
2322 (defun gnus-data-compute-positions ()
2323 "Compute the positions of all articles."
2324 (setq gnus-newsgroup-data-reverse nil)
2325 (let ((data gnus-newsgroup-data))
2327 (gnus-save-hidden-threads
2328 (gnus-summary-show-all-threads)
2329 (goto-char (point-min))
2331 (while (get-text-property (point) 'gnus-intangible)
2333 (gnus-data-set-pos (car data) (+ (point) 3))
2334 (setq data (cdr data))
2335 (forward-line 1))))))
2337 (defun gnus-hidden-threads-configuration ()
2338 "Return the current hidden threads configuration."
2341 (goto-char (point-min))
2342 (while (search-forward "\r" nil t)
2343 (push (1- (point)) config))
2346 (defun gnus-restore-hidden-threads-configuration (config)
2347 "Restore hidden threads configuration from CONFIG."
2348 (let (point buffer-read-only)
2349 (while (setq point (pop config))
2350 (when (and (< point (point-max))
2352 (eq (char-after) ?\n))
2353 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2355 ;; Various summary mode internalish functions.
2357 (defun gnus-mouse-pick-article (e)
2360 (gnus-summary-next-page nil t))
2362 (defun gnus-summary-set-display-table ()
2363 ;; Change the display table. Odd characters have a tendency to mess
2364 ;; up nicely formatted displays - we make all possible glyphs
2365 ;; display only a single character.
2367 ;; We start from the standard display table, if any.
2368 (let ((table (or (copy-sequence standard-display-table)
2369 (make-display-table)))
2371 ;; Nix out all the control chars...
2372 (while (>= (setq i (1- i)) 0)
2373 (aset table i [??]))
2374 ;; ... but not newline and cr, of course. (cr is necessary for the
2375 ;; selective display).
2376 (aset table ?\n nil)
2377 (aset table ?\r nil)
2378 ;; We keep TAB as well.
2379 (aset table ?\t nil)
2380 ;; We nix out any glyphs over 126 that are not set already.
2382 (while (>= (setq i (1- i)) 127)
2383 ;; Only modify if the entry is nil.
2384 (unless (aref table i)
2385 (aset table i [??]))))
2386 (setq buffer-display-table table)))
2388 (defun gnus-summary-setup-buffer (group)
2389 "Initialize summary buffer."
2390 (let ((buffer (concat "*Summary " group "*")))
2391 (if (get-buffer buffer)
2394 (setq gnus-summary-buffer (current-buffer))
2395 (not gnus-newsgroup-prepared))
2396 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2397 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2398 (gnus-summary-mode group)
2400 (gnus-carpal-setup-buffer 'summary))
2401 (unless gnus-single-article-buffer
2402 (make-local-variable 'gnus-article-buffer)
2403 (make-local-variable 'gnus-article-current)
2404 (make-local-variable 'gnus-original-article-buffer))
2405 (setq gnus-newsgroup-name group)
2408 (defun gnus-set-global-variables ()
2409 ;; Set the global equivalents of the summary buffer-local variables
2410 ;; to the latest values they had. These reflect the summary buffer
2411 ;; that was in action when the last article was fetched.
2412 (when (eq major-mode 'gnus-summary-mode)
2413 (setq gnus-summary-buffer (current-buffer))
2414 (let ((name gnus-newsgroup-name)
2415 (marked gnus-newsgroup-marked)
2416 (unread gnus-newsgroup-unreads)
2417 (headers gnus-current-headers)
2418 (data gnus-newsgroup-data)
2419 (summary gnus-summary-buffer)
2420 (article-buffer gnus-article-buffer)
2421 (original gnus-original-article-buffer)
2422 (gac gnus-article-current)
2423 (reffed gnus-reffed-article-number)
2424 (score-file gnus-current-score-file)
2425 (default-charset gnus-newsgroup-charset))
2427 (set-buffer gnus-group-buffer)
2428 (setq gnus-newsgroup-name name
2429 gnus-newsgroup-marked marked
2430 gnus-newsgroup-unreads unread
2431 gnus-current-headers headers
2432 gnus-newsgroup-data data
2433 gnus-article-current gac
2434 gnus-summary-buffer summary
2435 gnus-article-buffer article-buffer
2436 gnus-original-article-buffer original
2437 gnus-reffed-article-number reffed
2438 gnus-current-score-file score-file
2439 gnus-newsgroup-charset default-charset)
2440 ;; The article buffer also has local variables.
2441 (when (gnus-buffer-live-p gnus-article-buffer)
2442 (set-buffer gnus-article-buffer)
2443 (setq gnus-summary-buffer summary))))))
2445 (defun gnus-summary-article-unread-p (article)
2446 "Say whether ARTICLE is unread or not."
2447 (memq article gnus-newsgroup-unreads))
2449 (defun gnus-summary-first-article-p (&optional article)
2450 "Return whether ARTICLE is the first article in the buffer."
2451 (if (not (setq article (or article (gnus-summary-article-number))))
2453 (eq article (caar gnus-newsgroup-data))))
2455 (defun gnus-summary-last-article-p (&optional article)
2456 "Return whether ARTICLE is the last article in the buffer."
2457 (if (not (setq article (or article (gnus-summary-article-number))))
2458 ;; All non-existent numbers are the last article. :-)
2460 (not (cdr (gnus-data-find-list article)))))
2462 (defun gnus-make-thread-indent-array ()
2464 (unless (and gnus-thread-indent-array
2465 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2466 (setq gnus-thread-indent-array (make-vector 201 "")
2467 gnus-thread-indent-array-level gnus-thread-indent-level)
2469 (aset gnus-thread-indent-array n
2470 (make-string (* n gnus-thread-indent-level) ? ))
2473 (defun gnus-update-summary-mark-positions ()
2474 "Compute where the summary marks are to go."
2476 (when (gnus-buffer-exists-p gnus-summary-buffer)
2477 (set-buffer gnus-summary-buffer))
2478 (let ((gnus-replied-mark 129)
2479 (gnus-score-below-mark 130)
2480 (gnus-score-over-mark 130)
2481 (gnus-download-mark 131)
2482 (spec gnus-summary-line-format-spec)
2485 (gnus-set-work-buffer)
2486 (let ((gnus-summary-line-format-spec spec)
2487 (gnus-newsgroup-downloadable '((0 . t))))
2488 (gnus-summary-insert-line
2489 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2490 (goto-char (point-min))
2491 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2493 (goto-char (point-min))
2494 (push (cons 'replied (and (search-forward "\201" nil t)
2497 (goto-char (point-min))
2498 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2500 (goto-char (point-min))
2501 (push (cons 'download
2502 (and (search-forward "\203" nil t) (- (point) 2)))
2504 (setq gnus-summary-mark-positions pos))))
2506 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2507 "Insert a dummy root in the summary buffer."
2509 (gnus-add-text-properties
2510 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2511 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2513 (defun gnus-summary-from-or-to-or-newsgroups (header)
2514 (let ((to (cdr (assq 'To (mail-header-extra header))))
2515 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2516 (mail-parse-charset gnus-newsgroup-charset))
2519 gnus-ignored-from-addresses
2520 (string-match gnus-ignored-from-addresses
2521 (mail-header-from header)))
2523 (or (car (funcall gnus-extract-address-components
2525 gnus-decode-encoded-word-function to)))
2526 (funcall gnus-decode-encoded-word-function to))))
2528 gnus-ignored-from-addresses
2529 (string-match gnus-ignored-from-addresses
2530 (mail-header-from header)))
2531 (concat "=> " newsgroups))
2533 (or (car (funcall gnus-extract-address-components
2534 (mail-header-from header)))
2535 (mail-header-from header))))))
2537 (defun gnus-summary-insert-line (gnus-tmp-header
2538 gnus-tmp-level gnus-tmp-current
2539 gnus-tmp-unread gnus-tmp-replied
2540 gnus-tmp-expirable gnus-tmp-subject-or-nil
2541 &optional gnus-tmp-dummy gnus-tmp-score
2543 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2544 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2545 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2546 (gnus-tmp-score-char
2547 (if (or (null gnus-summary-default-score)
2548 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2549 gnus-summary-zcore-fuzz))
2551 (if (< gnus-tmp-score gnus-summary-default-score)
2552 gnus-score-below-mark gnus-score-over-mark)))
2554 (cond (gnus-tmp-process gnus-process-mark)
2555 ((memq gnus-tmp-current gnus-newsgroup-cached)
2557 (gnus-tmp-replied gnus-replied-mark)
2558 ((memq gnus-tmp-current gnus-newsgroup-saved)
2560 (t gnus-unread-mark)))
2561 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2564 ((string-match "<[^>]+> *$" gnus-tmp-from)
2565 (let ((beg (match-beginning 0)))
2566 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2567 (substring gnus-tmp-from (1+ (match-beginning 0))
2568 (1- (match-end 0))))
2569 (substring gnus-tmp-from 0 beg))))
2570 ((string-match "(.+)" gnus-tmp-from)
2571 (substring gnus-tmp-from
2572 (1+ (match-beginning 0)) (1- (match-end 0))))
2574 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2575 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2576 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2577 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2578 (buffer-read-only nil))
2579 (when (string= gnus-tmp-name "")
2580 (setq gnus-tmp-name gnus-tmp-from))
2581 (unless (numberp gnus-tmp-lines)
2582 (setq gnus-tmp-lines 0))
2583 (gnus-put-text-property
2585 (progn (eval gnus-summary-line-format-spec) (point))
2586 'gnus-number gnus-tmp-number)
2587 (when (gnus-visual-p 'summary-highlight 'highlight)
2589 (gnus-run-hooks 'gnus-summary-update-hook)
2592 (defun gnus-summary-update-line (&optional dont-update)
2593 ;; Update summary line after change.
2594 (when (and gnus-summary-default-score
2595 (not gnus-summary-inhibit-highlight))
2596 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2597 (article (gnus-summary-article-number))
2598 (score (gnus-summary-article-score article)))
2600 (if (and gnus-summary-mark-below
2601 (< (gnus-summary-article-score)
2602 gnus-summary-mark-below))
2603 ;; This article has a low score, so we mark it as read.
2604 (when (memq article gnus-newsgroup-unreads)
2605 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2606 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2607 ;; This article was previously marked as read on account
2608 ;; of a low score, but now it has risen, so we mark it as
2610 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2611 (gnus-summary-update-mark
2612 (if (or (null gnus-summary-default-score)
2613 (<= (abs (- score gnus-summary-default-score))
2614 gnus-summary-zcore-fuzz))
2616 (if (< score gnus-summary-default-score)
2617 gnus-score-below-mark gnus-score-over-mark))
2619 ;; Do visual highlighting.
2620 (when (gnus-visual-p 'summary-highlight 'highlight)
2621 (gnus-run-hooks 'gnus-summary-update-hook)))))
2623 (defvar gnus-tmp-new-adopts nil)
2625 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2626 "Return the number of articles in THREAD.
2627 This may be 0 in some cases -- if none of the articles in
2628 the thread are to be displayed."
2630 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2632 ((not (listp thread))
2634 ((and (consp thread) (cdr thread))
2637 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2640 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2643 (when (and level (zerop level) gnus-tmp-new-adopts)
2646 'gnus-summary-number-of-articles-in-thread
2647 gnus-tmp-new-adopts))))
2649 (if (> number 1) gnus-not-empty-thread-mark
2650 gnus-empty-thread-mark)
2653 (defun gnus-summary-set-local-parameters (group)
2654 "Go through the local params of GROUP and set all variable specs in that list."
2655 (let ((params (gnus-group-find-parameter group))
2658 (setq elem (car params)
2659 params (cdr params))
2660 (and (consp elem) ; Has to be a cons.
2661 (consp (cdr elem)) ; The cdr has to be a list.
2662 (symbolp (car elem)) ; Has to be a symbol in there.
2663 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2664 (ignore-errors ; So we set it.
2665 (make-local-variable (car elem))
2666 (set (car elem) (eval (nth 1 elem))))))))
2668 (defun gnus-summary-read-group (group &optional show-all no-article
2669 kill-buffer no-display backward
2671 "Start reading news in newsgroup GROUP.
2672 If SHOW-ALL is non-nil, already read articles are also listed.
2673 If NO-ARTICLE is non-nil, no article is selected initially.
2674 If NO-DISPLAY, don't generate a summary buffer."
2678 (let ((gnus-auto-select-next nil))
2679 (or (gnus-summary-read-group-1
2680 group show-all no-article
2681 kill-buffer no-display
2684 select-articles nil)))))
2685 (eq gnus-auto-select-next 'quietly))
2686 (set-buffer gnus-group-buffer)
2687 ;; The entry function called above goes to the next
2688 ;; group automatically, so we go two groups back
2689 ;; if we are searching for the previous group.
2691 (gnus-group-prev-unread-group 2))
2692 (if (not (equal group (gnus-group-group-name)))
2693 (setq group (gnus-group-group-name))
2697 (defun gnus-summary-read-group-1 (group show-all no-article
2698 kill-buffer no-display
2699 &optional select-articles)
2700 ;; Killed foreign groups can't be entered.
2701 (when (and (not (gnus-group-native-p group))
2702 (not (gnus-gethash group gnus-newsrc-hashtb)))
2703 (error "Dead non-native groups can't be entered"))
2704 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2705 (let* ((new-group (gnus-summary-setup-buffer group))
2706 (quit-config (gnus-group-quit-config group))
2707 (did-select (and new-group (gnus-select-newsgroup
2708 group show-all select-articles))))
2710 ;; This summary buffer exists already, so we just select it.
2712 (gnus-set-global-variables)
2714 (gnus-kill-or-deaden-summary kill-buffer))
2715 (gnus-configure-windows 'summary 'force)
2716 (gnus-set-mode-line 'summary)
2717 (gnus-summary-position-point)
2720 ;; We couldn't select this group.
2722 (when (and (eq major-mode 'gnus-summary-mode)
2723 (not (equal (current-buffer) kill-buffer)))
2724 (kill-buffer (current-buffer))
2725 (if (not quit-config)
2727 ;; Update the info -- marks might need to be removed,
2729 (gnus-summary-update-info)
2730 (set-buffer gnus-group-buffer)
2731 (gnus-group-jump-to-group group)
2732 (gnus-group-next-unread-group 1))
2733 (gnus-handle-ephemeral-exit quit-config)))
2734 (gnus-message 3 "Can't select group")
2736 ;; The user did a `C-g' while prompting for number of articles,
2737 ;; so we exit this group.
2738 ((eq did-select 'quit)
2739 (and (eq major-mode 'gnus-summary-mode)
2740 (not (equal (current-buffer) kill-buffer))
2741 (kill-buffer (current-buffer)))
2743 (gnus-kill-or-deaden-summary kill-buffer))
2744 (if (not quit-config)
2746 (set-buffer gnus-group-buffer)
2747 (gnus-group-jump-to-group group)
2748 (gnus-group-next-unread-group 1)
2749 (gnus-configure-windows 'group 'force))
2750 (gnus-handle-ephemeral-exit quit-config))
2751 ;; Finally signal the quit.
2753 ;; The group was successfully selected.
2755 (gnus-set-global-variables)
2756 ;; Save the active value in effect when the group was entered.
2757 (setq gnus-newsgroup-active
2759 (gnus-active gnus-newsgroup-name)))
2760 ;; You can change the summary buffer in some way with this hook.
2761 (gnus-run-hooks 'gnus-select-group-hook)
2762 ;; Set any local variables in the group parameters.
2763 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2764 (gnus-update-format-specifications
2765 nil 'summary 'summary-mode 'summary-dummy)
2766 ;; Do score processing.
2767 (when gnus-use-scoring
2768 (gnus-possibly-score-headers))
2769 ;; Check whether to fill in the gaps in the threads.
2770 (when gnus-build-sparse-threads
2771 (gnus-build-sparse-threads))
2772 ;; Find the initial limit.
2773 (if gnus-show-threads
2775 (let ((gnus-newsgroup-dormant nil))
2776 (gnus-summary-initial-limit show-all))
2777 (gnus-summary-initial-limit show-all))
2778 (setq gnus-newsgroup-limit
2780 (lambda (header) (mail-header-number header))
2781 gnus-newsgroup-headers)))
2782 ;; Generate the summary buffer.
2784 (gnus-summary-prepare))
2785 (when gnus-use-trees
2786 (gnus-tree-open group)
2787 (setq gnus-summary-highlight-line-function
2788 'gnus-tree-highlight-article))
2789 ;; If the summary buffer is empty, but there are some low-scored
2790 ;; articles or some excluded dormants, we include these in the
2792 (when (and (zerop (buffer-size))
2794 (cond (gnus-newsgroup-dormant
2795 (gnus-summary-limit-include-dormant))
2796 ((and gnus-newsgroup-scored show-all)
2797 (gnus-summary-limit-include-expunged t))))
2798 ;; Function `gnus-apply-kill-file' must be called in this hook.
2799 (gnus-run-hooks 'gnus-apply-kill-hook)
2800 (if (and (zerop (buffer-size))
2803 ;; This newsgroup is empty.
2804 (gnus-summary-catchup-and-exit nil t)
2805 (gnus-message 6 "No unread news")
2807 (gnus-kill-or-deaden-summary kill-buffer))
2808 ;; Return nil from this function.
2810 ;; Hide conversation thread subtrees. We cannot do this in
2811 ;; gnus-summary-prepare-hook since kill processing may not
2812 ;; work with hidden articles.
2813 (and gnus-show-threads
2814 gnus-thread-hide-subtree
2815 (gnus-summary-hide-all-threads))
2817 (gnus-kill-or-deaden-summary kill-buffer))
2818 ;; Show first unread article if requested.
2819 (if (and (not no-article)
2821 gnus-newsgroup-unreads
2822 gnus-auto-select-first)
2824 (gnus-configure-windows 'summary)
2826 ((eq gnus-auto-select-first 'best)
2827 (gnus-summary-best-unread-article))
2828 ((eq gnus-auto-select-first t)
2829 (gnus-summary-first-unread-article))
2830 ((gnus-functionp gnus-auto-select-first)
2831 (funcall gnus-auto-select-first))))
2832 ;; Don't select any articles, just move point to the first
2833 ;; article in the group.
2834 (goto-char (point-min))
2835 (gnus-summary-position-point)
2836 (gnus-configure-windows 'summary 'force)
2837 (gnus-set-mode-line 'summary))
2838 (when (get-buffer-window gnus-group-buffer t)
2839 ;; Gotta use windows, because recenter does weird stuff if
2840 ;; the current buffer ain't the displayed window.
2841 (let ((owin (selected-window)))
2842 (select-window (get-buffer-window gnus-group-buffer t))
2843 (when (gnus-group-goto-group group)
2845 (select-window owin)))
2846 ;; Mark this buffer as "prepared".
2847 (setq gnus-newsgroup-prepared t)
2848 (gnus-run-hooks 'gnus-summary-prepared-hook)
2851 (defun gnus-summary-prepare ()
2852 "Generate the summary buffer."
2854 (let ((buffer-read-only nil))
2856 (setq gnus-newsgroup-data nil
2857 gnus-newsgroup-data-reverse nil)
2858 (gnus-run-hooks 'gnus-summary-generate-hook)
2859 ;; Generate the buffer, either with threads or without.
2860 (when gnus-newsgroup-headers
2861 (gnus-summary-prepare-threads
2862 (if gnus-show-threads
2863 (gnus-sort-gathered-threads
2864 (funcall gnus-summary-thread-gathering-function
2866 (gnus-cut-threads (gnus-make-threads)))))
2867 ;; Unthreaded display.
2868 (gnus-sort-articles gnus-newsgroup-headers))))
2869 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2870 ;; Call hooks for modifying summary buffer.
2871 (goto-char (point-min))
2872 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2874 (defsubst gnus-general-simplify-subject (subject)
2875 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2878 ;; Truncate the subject.
2879 (gnus-simplify-subject-functions
2880 (gnus-map-function gnus-simplify-subject-functions subject))
2881 ((numberp gnus-summary-gather-subject-limit)
2882 (setq subject (gnus-simplify-subject-re subject))
2883 (if (> (length subject) gnus-summary-gather-subject-limit)
2884 (substring subject 0 gnus-summary-gather-subject-limit)
2886 ;; Fuzzily simplify it.
2887 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2888 (gnus-simplify-subject-fuzzy subject))
2889 ;; Just remove the leading "Re:".
2891 (gnus-simplify-subject-re subject))))
2893 (if (and gnus-summary-gather-exclude-subject
2894 (string-match gnus-summary-gather-exclude-subject subject))
2895 nil ; This article shouldn't be gathered
2898 (defun gnus-summary-simplify-subject-query ()
2899 "Query where the respool algorithm would put this article."
2901 (gnus-summary-select-article)
2902 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2904 (defun gnus-gather-threads-by-subject (threads)
2905 "Gather threads by looking at Subject headers."
2906 (if (not gnus-summary-make-false-root)
2908 (let ((hashtb (gnus-make-hashtable 1024))
2911 subject hthread whole-subject)
2913 (setq subject (gnus-general-simplify-subject
2914 (setq whole-subject (mail-header-subject
2917 (if (setq hthread (gnus-gethash subject hashtb))
2919 ;; We enter a dummy root into the thread, if we
2920 ;; haven't done that already.
2921 (unless (stringp (caar hthread))
2922 (setcar hthread (list whole-subject (car hthread))))
2923 ;; We add this new gathered thread to this gathered
2925 (setcdr (car hthread)
2926 (nconc (cdar hthread) (list (car threads))))
2927 ;; Remove it from the list of threads.
2928 (setcdr prev (cdr threads))
2929 (setq threads prev))
2930 ;; Enter this thread into the hash table.
2931 (gnus-sethash subject threads hashtb)))
2933 (setq threads (cdr threads)))
2936 (defun gnus-gather-threads-by-references (threads)
2937 "Gather threads by looking at References headers."
2938 (let ((idhashtb (gnus-make-hashtable 1024))
2939 (thhashtb (gnus-make-hashtable 1024))
2942 ids references id gthread gid entered ref)
2944 (when (setq references (mail-header-references (caar threads)))
2945 (setq id (mail-header-id (caar threads))
2946 ids (gnus-split-references references)
2948 (while (setq ref (pop ids))
2949 (setq ids (delete ref ids))
2950 (if (not (setq gid (gnus-gethash ref idhashtb)))
2952 (gnus-sethash ref id idhashtb)
2953 (gnus-sethash id threads thhashtb))
2954 (setq gthread (gnus-gethash gid thhashtb))
2956 ;; We enter a dummy root into the thread, if we
2957 ;; haven't done that already.
2958 (unless (stringp (caar gthread))
2959 (setcar gthread (list (mail-header-subject (caar gthread))
2961 ;; We add this new gathered thread to this gathered
2963 (setcdr (car gthread)
2964 (nconc (cdar gthread) (list (car threads)))))
2965 ;; Add it into the thread hash table.
2966 (gnus-sethash id gthread thhashtb)
2968 ;; Remove it from the list of threads.
2969 (setcdr prev (cdr threads))
2970 (setq threads prev))))
2972 (setq threads (cdr threads)))
2975 (defun gnus-sort-gathered-threads (threads)
2976 "Sort subtreads inside each gathered thread by article number."
2977 (let ((result threads))
2979 (when (stringp (caar threads))
2980 (setcdr (car threads)
2981 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2982 (setq threads (cdr threads)))
2985 (defun gnus-thread-loop-p (root thread)
2986 "Say whether ROOT is in THREAD."
2987 (let ((stack (list thread))
2990 (while (setq thread (pop stack))
2991 (setq th (cdr thread))
2993 (not (eq (caar th) root)))
2996 ;; We have found a loop.
2998 (setcdr thread (delq (car th) (cdr thread)))
2999 (if (boundp (setq ref-dep (intern "none"
3000 gnus-newsgroup-dependencies)))
3001 (setcdr (symbol-value ref-dep)
3002 (nconc (cdr (symbol-value ref-dep))
3004 (set ref-dep (list nil (car th))))
3007 ;; Push all the subthreads onto the stack.
3008 (push (cdr thread) stack)))
3011 (defun gnus-make-threads ()
3012 "Go through the dependency hashtb and find the roots. Return all threads."
3014 (while (catch 'infloop
3017 ;; Deal with self-referencing References loops.
3018 (when (and (car (symbol-value refs))
3025 (car (symbol-value refs)) thread))
3026 (cdr (symbol-value refs)))))))
3029 (unless (car (symbol-value refs))
3030 ;; These threads do not refer back to any other articles,
3031 ;; so they're roots.
3032 (setq threads (append (cdr (symbol-value refs)) threads))))
3033 gnus-newsgroup-dependencies)))
3036 ;; Build the thread tree.
3037 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3038 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3040 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3041 if it was already present.
3043 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3044 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3045 Message-IDs will be renamed be renamed to a unique Message-ID before
3048 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3049 (let* ((id (mail-header-id header))
3050 (id-dep (and id (intern id dependencies)))
3051 ref ref-dep ref-header)
3052 ;; Enter this `header' in the `dependencies' table.
3056 ;; The first two cases do the normal part: enter a new `header'
3057 ;; in the `dependencies' table.
3058 ((not (boundp id-dep))
3059 (set id-dep (list header)))
3060 ((null (car (symbol-value id-dep)))
3061 (setcar (symbol-value id-dep) header))
3063 ;; From here the `header' was already present in the
3064 ;; `dependencies' table.
3066 ;; Overrides an existing entry;
3067 ;; just set the header part of the entry.
3068 (setcar (symbol-value id-dep) header))
3070 ;; Renames the existing `header' to a unique Message-ID.
3071 ((not gnus-summary-ignore-duplicates)
3072 ;; An article with this Message-ID has already been seen.
3073 ;; We rename the Message-ID.
3074 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3076 (mail-header-set-id header id))
3078 ;; The last case ignores an existing entry, except it adds any
3079 ;; additional Xrefs (in case the two articles came from different
3081 ;; Also sets `header' to `nil' meaning that the `dependencies'
3082 ;; table was *not* modified.
3084 (mail-header-set-xref
3085 (car (symbol-value id-dep))
3086 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3088 (or (mail-header-xref header) "")))
3092 ;; First check if that we are not creating a References loop.
3093 (setq ref (gnus-parent-id (mail-header-references header)))
3095 (setq ref-dep (intern-soft ref dependencies))
3097 (setq ref-header (car (symbol-value ref-dep))))
3098 (if (string= id ref)
3099 ;; Yuk! This is a reference loop. Make the article be a
3102 (mail-header-set-references (car (symbol-value id-dep)) "none")
3104 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3105 (setq ref (gnus-parent-id (mail-header-references header)))
3106 (setq ref-dep (intern (or ref "none") dependencies))
3107 (if (boundp ref-dep)
3108 (setcdr (symbol-value ref-dep)
3109 (nconc (cdr (symbol-value ref-dep))
3110 (list (symbol-value id-dep))))
3111 (set ref-dep (list nil (symbol-value id-dep)))))
3114 (defun gnus-build-sparse-threads ()
3115 (let ((headers gnus-newsgroup-headers)
3116 (gnus-summary-ignore-duplicates t)
3117 header references generation relations
3118 subject child end new-child date)
3119 ;; First we create an alist of generations/relations, where
3120 ;; generations is how much we trust the relation, and the relation
3122 (gnus-message 7 "Making sparse threads...")
3124 (nnheader-set-temp-buffer " *gnus sparse threads*")
3125 (while (setq header (pop headers))
3126 (when (and (setq references (mail-header-references header))
3127 (not (string= references "")))
3129 (setq child (mail-header-id header)
3130 subject (mail-header-subject header)
3131 date (mail-header-date header)
3133 (while (search-backward ">" nil t)
3134 (setq end (1+ (point)))
3135 (when (search-backward "<" nil t)
3136 (setq new-child (buffer-substring (point) end))
3137 (push (list (incf generation)
3138 child (setq child new-child)
3142 (push (list (1+ generation) child nil subject) relations))
3144 (kill-buffer (current-buffer)))
3145 ;; Sort over trustworthiness.
3148 (when (gnus-dependencies-add-header
3149 (make-full-mail-header
3150 gnus-reffed-article-number
3151 (nth 3 relation) "" (or (nth 4 relation) "")
3153 (or (nth 2 relation) "") 0 0 "")
3154 gnus-newsgroup-dependencies nil)
3155 (push gnus-reffed-article-number gnus-newsgroup-limit)
3156 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3157 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3158 gnus-newsgroup-reads)
3159 (decf gnus-reffed-article-number)))
3160 (sort relations 'car-less-than-car))
3161 (gnus-message 7 "Making sparse threads...done")))
3163 (defun gnus-build-old-threads ()
3164 ;; Look at all the articles that refer back to old articles, and
3165 ;; fetch the headers for the articles that aren't there. This will
3166 ;; build complete threads - if the roots haven't been expired by the
3171 (when (not (car (symbol-value refs)))
3172 (setq heads (cdr (symbol-value refs)))
3174 (if (memq (mail-header-number (caar heads))
3175 gnus-newsgroup-dormant)
3176 (setq heads (cdr heads))
3177 (setq id (symbol-name refs))
3178 (while (and (setq id (gnus-build-get-header id))
3179 (not (car (gnus-id-to-thread id)))))
3180 (setq heads nil)))))
3181 gnus-newsgroup-dependencies)))
3183 ;; This function has to be called with point after the article number
3184 ;; on the beginning of the line.
3185 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3186 (let ((eol (gnus-point-at-eol))
3187 (buffer (current-buffer))
3190 ;; overview: [num subject from date id refs chars lines misc]
3193 (narrow-to-region (point) eol)
3198 (make-full-mail-header
3200 (funcall gnus-decode-encoded-word-function
3201 (nnheader-nov-field)) ; subject
3202 (funcall gnus-decode-encoded-word-function
3203 (nnheader-nov-field)) ; from
3204 (nnheader-nov-field) ; date
3205 (nnheader-nov-read-message-id) ; id
3206 (nnheader-nov-field) ; refs
3207 (nnheader-nov-read-integer) ; chars
3208 (nnheader-nov-read-integer) ; lines
3210 (nnheader-nov-field)) ; misc
3211 (nnheader-nov-parse-extra)))) ; extra
3215 (when gnus-alter-header-function
3216 (funcall gnus-alter-header-function header))
3217 (gnus-dependencies-add-header header dependencies force-new)))
3219 (defun gnus-build-get-header (id)
3220 ;; Look through the buffer of NOV lines and find the header to
3221 ;; ID. Enter this line into the dependencies hash table, and return
3222 ;; the id of the parent article (if any).
3223 (let ((deps gnus-newsgroup-dependencies)
3227 (set-buffer nntp-server-buffer)
3228 (let ((case-fold-search nil))
3229 (goto-char (point-min))
3230 (while (and (not found)
3231 (search-forward id nil t))
3233 (setq found (looking-at
3234 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3235 (regexp-quote id))))
3236 (or found (beginning-of-line 2)))
3240 (setq header (gnus-nov-parse-line
3241 (read (current-buffer)) deps))
3242 (gnus-parent-id (mail-header-references header))))))
3244 (let ((number (mail-header-number header)))
3245 (push number gnus-newsgroup-limit)
3246 (push header gnus-newsgroup-headers)
3247 (if (memq number gnus-newsgroup-unselected)
3249 (push number gnus-newsgroup-unreads)
3250 (setq gnus-newsgroup-unselected
3251 (delq number gnus-newsgroup-unselected)))
3252 (push number gnus-newsgroup-ancient)))))))
3254 (defun gnus-build-all-threads ()
3255 "Read all the headers."
3256 (let ((gnus-summary-ignore-duplicates t)
3257 (dependencies gnus-newsgroup-dependencies)
3260 (set-buffer nntp-server-buffer)
3261 (let ((case-fold-search nil))
3262 (goto-char (point-min))
3265 (setq article (read (current-buffer))
3266 header (gnus-nov-parse-line
3267 article dependencies)))
3270 (set-buffer gnus-summary-buffer)
3271 (push header gnus-newsgroup-headers)
3272 (if (memq (setq article (mail-header-number header))
3273 gnus-newsgroup-unselected)
3275 (push article gnus-newsgroup-unreads)
3276 (setq gnus-newsgroup-unselected
3277 (delq article gnus-newsgroup-unselected)))
3278 (push article gnus-newsgroup-ancient)))
3279 (forward-line 1)))))))
3281 (defun gnus-summary-update-article-line (article header)
3282 "Update the line for ARTICLE using HEADERS."
3283 (let* ((id (mail-header-id header))
3284 (thread (gnus-id-to-thread id)))
3286 (error "Article in no thread"))
3287 ;; Update the thread.
3288 (setcar thread header)
3289 (gnus-summary-goto-subject article)
3290 (let* ((datal (gnus-data-find-list article))
3292 (length (when (cdr datal)
3293 (- (gnus-data-pos data)
3294 (gnus-data-pos (cadr datal)))))
3295 (buffer-read-only nil)
3296 (level (gnus-summary-thread-level)))
3298 (gnus-summary-insert-line
3299 header level nil (gnus-article-mark article)
3300 (memq article gnus-newsgroup-replied)
3301 (memq article gnus-newsgroup-expirable)
3302 ;; Only insert the Subject string when it's different
3303 ;; from the previous Subject string.
3304 (if (gnus-subject-equal
3306 (mail-header-subject
3309 (gnus-data-find-list
3311 (gnus-data-list t)))))
3312 ;; Error on the side of excessive subjects.
3314 (mail-header-subject header))
3316 (mail-header-subject header))
3317 nil (cdr (assq article gnus-newsgroup-scored))
3318 (memq article gnus-newsgroup-processable))
3320 (gnus-data-update-list
3321 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3323 (defun gnus-summary-update-article (article &optional iheader)
3324 "Update ARTICLE in the summary buffer."
3325 (set-buffer gnus-summary-buffer)
3326 (let* ((header (gnus-summary-article-header article))
3327 (id (mail-header-id header))
3328 (data (gnus-data-find article))
3329 (thread (gnus-id-to-thread id))
3330 (references (mail-header-references header))
3334 (when (and references
3335 (not (equal "" references)))
3338 (buffer-read-only nil)
3344 (delq thread parent)))
3345 (if (gnus-summary-insert-subject id header)
3346 ;; Set the (possibly) new article number in the data structure.
3347 (gnus-data-set-number data (gnus-id-to-article id))
3351 (defun gnus-rebuild-thread (id &optional line)
3352 "Rebuild the thread containing ID.
3353 If LINE, insert the rebuilt thread starting on line LINE."
3354 (let ((buffer-read-only nil)
3355 old-pos current thread data)
3356 (if (not gnus-show-threads)
3357 (setq thread (list (car (gnus-id-to-thread id))))
3358 ;; Get the thread this article is part of.
3359 (setq thread (gnus-remove-thread id)))
3360 (setq old-pos (gnus-point-at-bol))
3361 (setq current (save-excursion
3362 (and (zerop (forward-line -1))
3363 (gnus-summary-article-number))))
3364 ;; If this is a gathered thread, we have to go some re-gathering.
3365 (when (stringp (car thread))
3366 (let ((subject (car thread))
3368 (setq thread (cdr thread))
3370 (unless (memq (setq thr (gnus-id-to-thread
3372 (mail-header-id (caar thread)))))
3375 (setq thread (cdr thread)))
3376 ;; We now have all (unique) roots.
3377 (if (= (length roots) 1)
3378 ;; All the loose roots are now one solid root.
3379 (setq thread (car roots))
3380 (setq thread (cons subject (gnus-sort-threads roots))))))
3382 ;; We then insert this thread into the summary buffer.
3384 (goto-char (point-min))
3385 (forward-line (1- line)))
3386 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3387 (if gnus-show-threads
3388 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3389 (gnus-summary-prepare-unthreaded thread))
3390 (setq data (nreverse gnus-newsgroup-data))
3391 (setq threads gnus-newsgroup-threads))
3392 ;; We splice the new data into the data structure.
3393 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3394 ;;!!! then we want to insert at the beginning of the buffer.
3395 ;;!!! That happens to be true with Gnus now, but that may
3396 ;;!!! change in the future. Perhaps.
3397 (gnus-data-enter-list
3398 (if line nil current) data (- (point) old-pos))
3399 (setq gnus-newsgroup-threads
3400 (nconc threads gnus-newsgroup-threads))
3401 (gnus-data-compute-positions))))
3403 (defun gnus-number-to-header (number)
3404 "Return the header for article NUMBER."
3405 (let ((headers gnus-newsgroup-headers))
3407 (not (= number (mail-header-number (car headers)))))
3412 (defun gnus-parent-headers (in-headers &optional generation)
3413 "Return the headers of the GENERATIONeth parent of HEADERS."
3415 (setq generation 1))
3417 (headers in-headers)
3420 (not (zerop generation))
3421 (setq references (mail-header-references headers)))
3422 (setq headers (if (and references
3423 (setq parent (gnus-parent-id references)))
3424 (car (gnus-id-to-thread parent))
3427 (and (not (eq headers in-headers))
3430 (defun gnus-id-to-thread (id)
3431 "Return the (sub-)thread where ID appears."
3432 (gnus-gethash id gnus-newsgroup-dependencies))
3434 (defun gnus-id-to-article (id)
3435 "Return the article number of ID."
3436 (let ((thread (gnus-id-to-thread id)))
3439 (mail-header-number (car thread)))))
3441 (defun gnus-id-to-header (id)
3442 "Return the article headers of ID."
3443 (car (gnus-id-to-thread id)))
3445 (defun gnus-article-displayed-root-p (article)
3446 "Say whether ARTICLE is a root(ish) article."
3447 (let ((level (gnus-summary-thread-level article))
3448 (refs (mail-header-references (gnus-summary-article-header article)))
3454 ((null (gnus-parent-id refs)) t)
3456 (null (setq particle (gnus-id-to-article
3457 (gnus-parent-id refs))))
3458 (null (gnus-summary-thread-level particle)))))))
3460 (defun gnus-root-id (id)
3461 "Return the id of the root of the thread where ID appears."
3463 (while (and id (setq prev (car (gnus-id-to-thread id))))
3465 id (gnus-parent-id (mail-header-references prev))))
3468 (defun gnus-articles-in-thread (thread)
3469 "Return the list of articles in THREAD."
3470 (cons (mail-header-number (car thread))
3471 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3473 (defun gnus-remove-thread (id &optional dont-remove)
3474 "Remove the thread that has ID in it."
3475 (let (headers thread last-id)
3476 ;; First go up in this thread until we find the root.
3477 (setq last-id (gnus-root-id id)
3478 headers (message-flatten-list (gnus-id-to-thread last-id)))
3479 ;; We have now found the real root of this thread. It might have
3480 ;; been gathered into some loose thread, so we have to search
3481 ;; through the threads to find the thread we wanted.
3482 (let ((threads gnus-newsgroup-threads)
3485 (setq sub (car threads))
3486 (if (stringp (car sub))
3487 ;; This is a gathered thread, so we look at the roots
3488 ;; below it to find whether this article is in this
3491 (setq sub (cdr sub))
3493 (when (member (caar sub) headers)
3494 (setq thread (car threads)
3497 (setq sub (cdr sub))))
3498 ;; It's an ordinary thread, so we check it.
3499 (when (eq (car sub) (car headers))
3502 (setq threads (cdr threads)))
3503 ;; If this article is in no thread, then it's a root.
3506 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3507 (setq thread (gnus-id-to-thread last-id)))
3510 thread ; We return this thread.
3512 (if (stringp (car thread))
3514 ;; If we use dummy roots, then we have to remove the
3515 ;; dummy root as well.
3516 (when (eq gnus-summary-make-false-root 'dummy)
3517 ;; We go to the dummy root by going to
3518 ;; the first sub-"thread", and then one line up.
3519 (gnus-summary-goto-article
3520 (mail-header-number (caadr thread)))
3523 (gnus-data-compute-positions))
3524 (setq thread (cdr thread))
3526 (gnus-remove-thread-1 (car thread))
3527 (setq thread (cdr thread))))
3528 (gnus-summary-show-all-threads)
3529 (gnus-remove-thread-1 thread))))))))
3531 (defun gnus-remove-thread-1 (thread)
3532 "Remove the thread THREAD recursively."
3533 (let ((number (mail-header-number (pop thread)))
3535 (setq thread (reverse thread))
3537 (gnus-remove-thread-1 (pop thread)))
3538 (when (setq d (gnus-data-find number))
3539 (goto-char (gnus-data-pos d))
3542 (- (gnus-point-at-bol)
3544 (1+ (gnus-point-at-eol))
3545 (gnus-delete-line)))))))
3547 (defun gnus-sort-threads (threads)
3549 (if (not gnus-thread-sort-functions)
3551 (gnus-message 8 "Sorting threads...")
3553 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3554 (gnus-message 8 "Sorting threads...done"))))
3556 (defun gnus-sort-articles (articles)
3558 (when gnus-article-sort-functions
3559 (gnus-message 7 "Sorting articles...")
3561 (setq gnus-newsgroup-headers
3562 (sort articles (gnus-make-sort-function
3563 gnus-article-sort-functions)))
3564 (gnus-message 7 "Sorting articles...done"))))
3566 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3567 (defmacro gnus-thread-header (thread)
3568 ;; Return header of first article in THREAD.
3569 ;; Note that THREAD must never, ever be anything else than a variable -
3570 ;; using some other form will lead to serious barfage.
3571 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3572 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3573 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3576 (defsubst gnus-article-sort-by-number (h1 h2)
3577 "Sort articles by article number."
3578 (< (mail-header-number h1)
3579 (mail-header-number h2)))
3581 (defun gnus-thread-sort-by-number (h1 h2)
3582 "Sort threads by root article number."
3583 (gnus-article-sort-by-number
3584 (gnus-thread-header h1) (gnus-thread-header h2)))
3586 (defsubst gnus-article-sort-by-lines (h1 h2)
3587 "Sort articles by article Lines header."
3588 (< (mail-header-lines h1)
3589 (mail-header-lines h2)))
3591 (defun gnus-thread-sort-by-lines (h1 h2)
3592 "Sort threads by root article Lines header."
3593 (gnus-article-sort-by-lines
3594 (gnus-thread-header h1) (gnus-thread-header h2)))
3596 (defsubst gnus-article-sort-by-chars (h1 h2)
3597 "Sort articles by octet length."
3598 (< (mail-header-chars h1)
3599 (mail-header-chars h2)))
3601 (defun gnus-thread-sort-by-chars (h1 h2)
3602 "Sort threads by root article octet length."
3603 (gnus-article-sort-by-chars
3604 (gnus-thread-header h1) (gnus-thread-header h2)))
3606 (defsubst gnus-article-sort-by-author (h1 h2)
3607 "Sort articles by root author."
3609 (let ((extract (funcall
3610 gnus-extract-address-components
3611 (mail-header-from h1))))
3612 (or (car extract) (cadr extract) ""))
3613 (let ((extract (funcall
3614 gnus-extract-address-components
3615 (mail-header-from h2))))
3616 (or (car extract) (cadr extract) ""))))
3618 (defun gnus-thread-sort-by-author (h1 h2)
3619 "Sort threads by root author."
3620 (gnus-article-sort-by-author
3621 (gnus-thread-header h1) (gnus-thread-header h2)))
3623 (defsubst gnus-article-sort-by-subject (h1 h2)
3624 "Sort articles by root subject."
3626 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3627 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3629 (defun gnus-thread-sort-by-subject (h1 h2)
3630 "Sort threads by root subject."
3631 (gnus-article-sort-by-subject
3632 (gnus-thread-header h1) (gnus-thread-header h2)))
3634 (defsubst gnus-article-sort-by-date (h1 h2)
3635 "Sort articles by root article date."
3637 (gnus-date-get-time (mail-header-date h1))
3638 (gnus-date-get-time (mail-header-date h2))))
3640 (defun gnus-thread-sort-by-date (h1 h2)
3641 "Sort threads by root article date."
3642 (gnus-article-sort-by-date
3643 (gnus-thread-header h1) (gnus-thread-header h2)))
3645 (defsubst gnus-article-sort-by-score (h1 h2)
3646 "Sort articles by root article score.
3647 Unscored articles will be counted as having a score of zero."
3648 (> (or (cdr (assq (mail-header-number h1)
3649 gnus-newsgroup-scored))
3650 gnus-summary-default-score 0)
3651 (or (cdr (assq (mail-header-number h2)
3652 gnus-newsgroup-scored))
3653 gnus-summary-default-score 0)))
3655 (defun gnus-thread-sort-by-score (h1 h2)
3656 "Sort threads by root article score."
3657 (gnus-article-sort-by-score
3658 (gnus-thread-header h1) (gnus-thread-header h2)))
3660 (defun gnus-thread-sort-by-total-score (h1 h2)
3661 "Sort threads by the sum of all scores in the thread.
3662 Unscored articles will be counted as having a score of zero."
3663 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3665 (defun gnus-thread-total-score (thread)
3666 ;; This function find the total score of THREAD.
3667 (cond ((null thread)
3670 (if (stringp (car thread))
3671 (apply gnus-thread-score-function 0
3672 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3673 (gnus-thread-total-score-1 thread)))
3675 (gnus-thread-total-score-1 (list thread)))))
3677 (defun gnus-thread-total-score-1 (root)
3678 ;; This function find the total score of the thread below ROOT.
3679 (setq root (car root))
3680 (apply gnus-thread-score-function
3682 (mapcar 'gnus-thread-total-score
3683 (cdr (gnus-id-to-thread (mail-header-id root))))
3684 (when (> (mail-header-number root) 0)
3685 (list (or (cdr (assq (mail-header-number root)
3686 gnus-newsgroup-scored))
3687 gnus-summary-default-score 0))))
3688 (list gnus-summary-default-score)
3691 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3692 (defvar gnus-tmp-prev-subject nil)
3693 (defvar gnus-tmp-false-parent nil)
3694 (defvar gnus-tmp-root-expunged nil)
3695 (defvar gnus-tmp-dummy-line nil)
3697 (defvar gnus-tmp-header)
3698 (defun gnus-extra-header (type &optional header)
3699 "Return the extra header of TYPE."
3700 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3703 (defun gnus-summary-prepare-threads (threads)
3704 "Prepare summary buffer from THREADS and indentation LEVEL.
3705 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3706 or a straight list of headers."
3707 (gnus-message 7 "Generating summary...")
3709 (setq gnus-newsgroup-threads threads)
3712 (let ((gnus-tmp-level 0)
3713 (default-score (or gnus-summary-default-score 0))
3714 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3715 thread number subject stack state gnus-tmp-gathered beg-match
3716 new-roots gnus-tmp-new-adopts thread-end
3717 gnus-tmp-header gnus-tmp-unread
3718 gnus-tmp-replied gnus-tmp-subject-or-nil
3719 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3720 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3721 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3723 (setq gnus-tmp-prev-subject nil)
3725 (if (vectorp (car threads))
3726 ;; If this is a straight (sic) list of headers, then a
3727 ;; threaded summary display isn't required, so we just create
3728 ;; an unthreaded one.
3729 (gnus-summary-prepare-unthreaded threads)
3731 ;; Do the threaded display.
3733 (while (or threads stack gnus-tmp-new-adopts new-roots)
3735 (if (and (= gnus-tmp-level 0)
3738 (not gnus-tmp-false-parent)
3739 (or gnus-tmp-new-adopts new-roots))
3740 (if gnus-tmp-new-adopts
3741 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3742 thread (list (car gnus-tmp-new-adopts))
3743 gnus-tmp-header (caar thread)
3744 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3746 (setq thread (list (car new-roots))
3747 gnus-tmp-header (caar thread)
3748 new-roots (cdr new-roots))))
3751 ;; If there are some threads, we do them before the
3752 ;; threads on the stack.
3753 (setq thread threads
3754 gnus-tmp-header (caar thread))
3755 ;; There were no current threads, so we pop something off
3757 (setq state (car stack)
3758 gnus-tmp-level (car state)
3761 gnus-tmp-header (caar thread))))
3763 (setq gnus-tmp-false-parent nil)
3764 (setq gnus-tmp-root-expunged nil)
3765 (setq thread-end nil)
3767 (if (stringp gnus-tmp-header)
3768 ;; The header is a dummy root.
3770 ((eq gnus-summary-make-false-root 'adopt)
3771 ;; We let the first article adopt the rest.
3772 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3774 (setq gnus-tmp-gathered
3776 (lambda (h) (mail-header-number (car h)))
3779 (setq thread (cons (list (caar thread)
3782 (setq gnus-tmp-level -1
3783 gnus-tmp-false-parent t))
3784 ((eq gnus-summary-make-false-root 'empty)
3785 ;; We print adopted articles with empty subject fields.
3786 (setq gnus-tmp-gathered
3788 (lambda (h) (mail-header-number (car h)))
3791 (setq gnus-tmp-level -1))
3792 ((eq gnus-summary-make-false-root 'dummy)
3793 ;; We remember that we probably want to output a dummy
3795 (setq gnus-tmp-dummy-line gnus-tmp-header)
3796 (setq gnus-tmp-prev-subject gnus-tmp-header))
3798 ;; We do not make a root for the gathered
3799 ;; sub-threads at all.
3800 (setq gnus-tmp-level -1)))
3802 (setq number (mail-header-number gnus-tmp-header)
3803 subject (mail-header-subject gnus-tmp-header))
3806 ;; If the thread has changed subject, we might want to make
3807 ;; this subthread into a root.
3808 ((and (null gnus-thread-ignore-subject)
3809 (not (zerop gnus-tmp-level))
3810 gnus-tmp-prev-subject
3812 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3813 (setq new-roots (nconc new-roots (list (car thread)))
3815 gnus-tmp-header nil))
3816 ;; If the article lies outside the current limit,
3817 ;; then we do not display it.
3818 ((not (memq number gnus-newsgroup-limit))
3819 (setq gnus-tmp-gathered
3821 (lambda (h) (mail-header-number (car h)))
3824 (setq gnus-tmp-new-adopts (if (cdar thread)
3825 (append gnus-tmp-new-adopts
3827 gnus-tmp-new-adopts)
3829 gnus-tmp-header nil)
3830 (when (zerop gnus-tmp-level)
3831 (setq gnus-tmp-root-expunged t)))
3832 ;; Perhaps this article is to be marked as read?
3833 ((and gnus-summary-mark-below
3834 (< (or (cdr (assq number gnus-newsgroup-scored))
3836 gnus-summary-mark-below)
3837 ;; Don't touch sparse articles.
3838 (not (gnus-summary-article-sparse-p number))
3839 (not (gnus-summary-article-ancient-p number)))
3840 (setq gnus-newsgroup-unreads
3841 (delq number gnus-newsgroup-unreads))
3842 (if gnus-newsgroup-auto-expire
3843 (push number gnus-newsgroup-expirable)
3844 (push (cons number gnus-low-score-mark)
3845 gnus-newsgroup-reads))))
3847 (when gnus-tmp-header
3848 ;; We may have an old dummy line to output before this
3850 (when (and gnus-tmp-dummy-line
3853 (mail-header-subject gnus-tmp-header)))
3854 (gnus-summary-insert-dummy-line
3855 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3856 (setq gnus-tmp-dummy-line nil))
3858 ;; Compute the mark.
3859 (setq gnus-tmp-unread (gnus-article-mark number))
3861 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3862 gnus-tmp-header gnus-tmp-level)
3863 gnus-newsgroup-data)
3865 ;; Actually insert the line.
3867 gnus-tmp-subject-or-nil
3869 ((and gnus-thread-ignore-subject
3870 gnus-tmp-prev-subject
3871 (not (inline (gnus-subject-equal
3872 gnus-tmp-prev-subject subject))))
3874 ((zerop gnus-tmp-level)
3875 (if (and (eq gnus-summary-make-false-root 'empty)
3876 (memq number gnus-tmp-gathered)
3877 gnus-tmp-prev-subject
3878 (inline (gnus-subject-equal
3879 gnus-tmp-prev-subject subject)))
3880 gnus-summary-same-subject
3882 (t gnus-summary-same-subject)))
3883 (if (and (eq gnus-summary-make-false-root 'adopt)
3884 (= gnus-tmp-level 1)
3885 (memq number gnus-tmp-gathered))
3886 (setq gnus-tmp-opening-bracket ?\<
3887 gnus-tmp-closing-bracket ?\>)
3888 (setq gnus-tmp-opening-bracket ?\[
3889 gnus-tmp-closing-bracket ?\]))
3891 gnus-tmp-indentation
3892 (aref gnus-thread-indent-array gnus-tmp-level)
3893 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3894 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3895 gnus-summary-default-score 0)
3897 (if (or (null gnus-summary-default-score)
3898 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3899 gnus-summary-zcore-fuzz))
3901 (if (< gnus-tmp-score gnus-summary-default-score)
3902 gnus-score-below-mark gnus-score-over-mark))
3904 (cond ((memq number gnus-newsgroup-processable)
3906 ((memq number gnus-newsgroup-cached)
3908 ((memq number gnus-newsgroup-replied)
3910 ((memq number gnus-newsgroup-saved)
3912 (t gnus-unread-mark))
3913 gnus-tmp-from (mail-header-from gnus-tmp-header)
3916 ((string-match "<[^>]+> *$" gnus-tmp-from)
3917 (setq beg-match (match-beginning 0))
3918 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3919 (substring gnus-tmp-from (1+ (match-beginning 0))
3920 (1- (match-end 0))))
3921 (substring gnus-tmp-from 0 beg-match)))
3922 ((string-match "(.+)" gnus-tmp-from)
3923 (substring gnus-tmp-from
3924 (1+ (match-beginning 0)) (1- (match-end 0))))
3926 (when (string= gnus-tmp-name "")
3927 (setq gnus-tmp-name gnus-tmp-from))
3928 (unless (numberp gnus-tmp-lines)
3929 (setq gnus-tmp-lines 0))
3930 (gnus-put-text-property
3932 (progn (eval gnus-summary-line-format-spec) (point))
3933 'gnus-number number)
3936 (gnus-run-hooks 'gnus-summary-update-hook)
3939 (setq gnus-tmp-prev-subject subject)))
3941 (when (nth 1 thread)
3942 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3943 (incf gnus-tmp-level)
3944 (setq threads (if thread-end nil (cdar thread)))
3946 (setq gnus-tmp-level 0)))))
3947 (gnus-message 7 "Generating summary...done"))
3949 (defun gnus-summary-prepare-unthreaded (headers)
3950 "Generate an unthreaded summary buffer based on HEADERS."
3951 (let (header number mark)
3956 ;; We may have to root out some bad articles...
3957 (when (memq (setq number (mail-header-number
3958 (setq header (pop headers))))
3959 gnus-newsgroup-limit)
3960 ;; Mark article as read when it has a low score.
3961 (when (and gnus-summary-mark-below
3962 (< (or (cdr (assq number gnus-newsgroup-scored))
3963 gnus-summary-default-score 0)
3964 gnus-summary-mark-below)
3965 (not (gnus-summary-article-ancient-p number)))
3966 (setq gnus-newsgroup-unreads
3967 (delq number gnus-newsgroup-unreads))
3968 (if gnus-newsgroup-auto-expire
3969 (push number gnus-newsgroup-expirable)
3970 (push (cons number gnus-low-score-mark)
3971 gnus-newsgroup-reads)))
3973 (setq mark (gnus-article-mark number))
3974 (push (gnus-data-make number mark (1+ (point)) header 0)
3975 gnus-newsgroup-data)
3976 (gnus-summary-insert-line
3978 mark (memq number gnus-newsgroup-replied)
3979 (memq number gnus-newsgroup-expirable)
3980 (mail-header-subject header) nil
3981 (cdr (assq number gnus-newsgroup-scored))
3982 (memq number gnus-newsgroup-processable))))))
3984 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3985 "Select newsgroup GROUP.
3986 If READ-ALL is non-nil, all articles in the group are selected.
3987 If SELECT-ARTICLES, only select those articles from GROUP."
3988 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3989 ;;!!! Dirty hack; should be removed.
3990 (gnus-summary-ignore-duplicates
3991 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3993 gnus-summary-ignore-duplicates))
3994 (info (nth 2 entry))
3995 articles fetched-articles cached)
3997 (unless (gnus-check-server
3998 (setq gnus-current-select-method
3999 (gnus-find-method-for-group group)))
4000 (error "Couldn't open server"))
4002 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4003 (gnus-activate-group group) ; Or we can activate it...
4004 (progn ; Or we bug out.
4005 (when (equal major-mode 'gnus-summary-mode)
4006 (kill-buffer (current-buffer)))
4007 (error "Couldn't request group %s: %s"
4008 group (gnus-status-message group))))
4010 (unless (gnus-request-group group t)
4011 (when (equal major-mode 'gnus-summary-mode)
4012 (kill-buffer (current-buffer)))
4013 (error "Couldn't request group %s: %s"
4014 group (gnus-status-message group)))
4016 (setq gnus-newsgroup-name group)
4017 (setq gnus-newsgroup-unselected nil)
4018 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4019 (gnus-summary-setup-default-charset)
4021 ;; Adjust and set lists of article marks.
4023 (gnus-adjust-marked-articles info))
4025 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4026 (when (gnus-virtual-group-p group)
4027 (setq cached gnus-newsgroup-cached))
4029 (setq gnus-newsgroup-unreads
4030 (gnus-set-difference
4031 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4032 gnus-newsgroup-dormant))
4034 (setq gnus-newsgroup-processable nil)
4036 (gnus-update-read-articles group gnus-newsgroup-unreads)
4038 (if (setq articles select-articles)
4039 (setq gnus-newsgroup-unselected
4040 (gnus-sorted-intersection
4041 gnus-newsgroup-unreads
4042 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4043 (setq articles (gnus-articles-to-read group read-all)))
4047 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4049 ((eq articles 0) nil)
4051 ;; Init the dependencies hash table.
4052 (setq gnus-newsgroup-dependencies
4053 (gnus-make-hashtable (length articles)))
4054 (gnus-set-global-variables)
4055 ;; Retrieve the headers and read them in.
4056 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4057 (setq gnus-newsgroup-headers
4059 (setq gnus-headers-retrieved-by
4060 (gnus-retrieve-headers
4061 articles gnus-newsgroup-name
4062 ;; We might want to fetch old headers, but
4063 ;; not if there is only 1 article.
4065 (not (eq gnus-fetch-old-headers 'some))
4066 (not (numberp gnus-fetch-old-headers)))
4067 (> (length articles) 1))
4068 gnus-fetch-old-headers))))
4069 (gnus-get-newsgroup-headers-xover
4070 articles nil nil gnus-newsgroup-name t)
4071 (gnus-get-newsgroup-headers)))
4072 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4074 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4076 (setq gnus-newsgroup-cached cached))
4078 ;; Suppress duplicates?
4079 (when gnus-suppress-duplicates
4080 (gnus-dup-suppress-articles))
4082 ;; Set the initial limit.
4083 (setq gnus-newsgroup-limit (copy-sequence articles))
4084 ;; Remove canceled articles from the list of unread articles.
4085 (setq gnus-newsgroup-unreads
4086 (gnus-set-sorted-intersection
4087 gnus-newsgroup-unreads
4088 (setq fetched-articles
4089 (mapcar (lambda (headers) (mail-header-number headers))
4090 gnus-newsgroup-headers))))
4091 ;; Removed marked articles that do not exist.
4092 (gnus-update-missing-marks
4093 (gnus-sorted-complement fetched-articles articles))
4094 ;; We might want to build some more threads first.
4095 (when (and gnus-fetch-old-headers
4096 (eq gnus-headers-retrieved-by 'nov))
4097 (if (eq gnus-fetch-old-headers 'invisible)
4098 (gnus-build-all-threads)
4099 (gnus-build-old-threads)))
4100 ;; Let the Gnus agent mark articles as read.
4102 (gnus-agent-get-undownloaded-list))
4103 ;; Check whether auto-expire is to be done in this group.
4104 (setq gnus-newsgroup-auto-expire
4105 (gnus-group-auto-expirable-p group))
4106 ;; Set up the article buffer now, if necessary.
4107 (unless gnus-single-article-buffer
4108 (gnus-article-setup-buffer))
4109 ;; First and last article in this newsgroup.
4110 (when gnus-newsgroup-headers
4111 (setq gnus-newsgroup-begin
4112 (mail-header-number (car gnus-newsgroup-headers))
4115 (gnus-last-element gnus-newsgroup-headers))))
4116 ;; GROUP is successfully selected.
4117 (or gnus-newsgroup-headers t)))))
4119 (defun gnus-articles-to-read (group &optional read-all)
4120 ;; Find out what articles the user wants to read.
4122 ;; Select all articles if `read-all' is non-nil, or if there
4123 ;; are no unread articles.
4125 (and (zerop (length gnus-newsgroup-marked))
4126 (zerop (length gnus-newsgroup-unreads)))
4127 (eq (gnus-group-find-parameter group 'display)
4129 (gnus-uncompress-range (gnus-active group))
4130 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4131 (copy-sequence gnus-newsgroup-unreads))
4133 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4134 (scored (length scored-list))
4135 (number (length articles))
4136 (marked (+ (length gnus-newsgroup-marked)
4137 (length gnus-newsgroup-dormant)))
4145 ((and (or (<= scored marked) (= scored number))
4146 (numberp gnus-large-newsgroup)
4147 (> number gnus-large-newsgroup))
4151 "How many articles from %s (default %d): "
4152 (gnus-limit-string gnus-newsgroup-name 35)
4154 (if (string-match "^[ \t]*$" input) number input)))
4155 ((and (> scored marked) (< scored number)
4156 (> (- scored number) 20))
4159 (format "%s %s (%d scored, %d total): "
4160 "How many articles from"
4161 group scored number))))
4162 (if (string-match "^[ \t]*$" input)
4166 (setq select (if (stringp select) (string-to-number select) select))
4167 (if (or (null select) (zerop select))
4169 (if (and (not (zerop scored)) (<= (abs select) scored))
4171 (setq articles (sort scored-list '<))
4172 (setq number (length articles)))
4173 (setq articles (copy-sequence articles)))
4175 (when (< (abs select) number)
4177 ;; Select the N oldest articles.
4178 (setcdr (nthcdr (1- (abs select)) articles) nil)
4179 ;; Select the N most recent articles.
4180 (setq articles (nthcdr (- number select) articles))))
4181 (setq gnus-newsgroup-unselected
4182 (gnus-sorted-intersection
4183 gnus-newsgroup-unreads
4184 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4187 (defun gnus-killed-articles (killed articles)
4190 (when (inline (gnus-member-of-range (car articles) killed))
4191 (push (car articles) out))
4192 (setq articles (cdr articles)))
4195 (defun gnus-uncompress-marks (marks)
4196 "Uncompress the mark ranges in MARKS."
4197 (let ((uncompressed '(score bookmark))
4200 (if (memq (caar marks) uncompressed)
4201 (push (car marks) out)
4202 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4203 (setq marks (cdr marks)))
4206 (defun gnus-adjust-marked-articles (info)
4207 "Set all article lists and remove all marks that are no longer valid."
4208 (let* ((marked-lists (gnus-info-marks info))
4209 (active (gnus-active (gnus-info-group info)))
4212 (types gnus-article-mark-lists)
4213 (uncompressed '(score bookmark killed))
4214 marks var articles article mark)
4217 (setq marks (pop marked-lists))
4218 (set (setq var (intern (format "gnus-newsgroup-%s"
4219 (car (rassq (setq mark (car marks))
4221 (if (memq (car marks) uncompressed) (cdr marks)
4222 (gnus-uncompress-range (cdr marks))))
4224 (setq articles (symbol-value var))
4226 ;; All articles have to be subsets of the active articles.
4228 ;; Adjust "simple" lists.
4229 ((memq mark '(tick dormant expire reply save))
4231 (when (or (< (setq article (pop articles)) min) (> article max))
4232 (set var (delq article (symbol-value var))))))
4234 ((memq mark uncompressed)
4235 (when (not (listp (cdr (symbol-value var))))
4236 (set var (list (symbol-value var))))
4237 (when (not (listp (cdr articles)))
4238 (setq articles (list articles)))
4240 (when (or (not (consp (setq article (pop articles))))
4241 (< (car article) min)
4242 (> (car article) max))
4243 (set var (delq article (symbol-value var))))))))))
4245 (defun gnus-update-missing-marks (missing)
4246 "Go through the list of MISSING articles and remove them from the mark lists."
4248 (let ((types gnus-article-mark-lists)
4250 ;; Go through all types.
4252 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4253 (when (symbol-value var)
4254 ;; This list has articles. So we delete all missing articles
4258 (set var (delq (pop m) (symbol-value var)))))))))
4260 (defun gnus-update-marks ()
4261 "Enter the various lists of marked articles into the newsgroup info list."
4262 (let ((types gnus-article-mark-lists)
4263 (info (gnus-get-info gnus-newsgroup-name))
4264 (uncompressed '(score bookmark killed))
4265 type list newmarked symbol delta-marks)
4267 ;; Add all marks lists that are non-nil to the list of marks lists.
4268 (while (setq type (pop types))
4269 (when (setq list (symbol-value
4271 (intern (format "gnus-newsgroup-%s"
4274 ;; Get rid of the entries of the articles that have the
4276 (when (and (eq (cdr type) 'score)
4280 (prev (cons nil list))
4283 (if (or (not (consp (car arts)))
4284 (= (cdar arts) gnus-summary-default-score))
4285 (setcdr prev (cdr arts))
4287 (setq arts (cdr arts)))
4288 (setq list (cdr all))))
4290 (when (gnus-check-backend-function 'request-set-mark
4291 gnus-newsgroup-name)
4292 ;; uncompressed:s are not proper flags (they are cons cells)
4293 ;; cache is a internal gnus flag
4294 (unless (memq (cdr type) (cons 'cache uncompressed))
4295 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4296 (list (gnus-compress-sequence (sort list '<)))
4297 (del (gnus-remove-from-range old list))
4298 (add (gnus-remove-from-range list old)))
4300 (push (list add 'add (list (cdr type))) delta-marks))
4302 (push (list del 'del (list (cdr type))) delta-marks)))))
4304 (push (cons (cdr type)
4305 (if (memq (cdr type) uncompressed) list
4306 (gnus-compress-sequence
4307 (set symbol (sort list '<)) t)))
4311 (unless (gnus-check-group gnus-newsgroup-name)
4312 (error "Can't open server for %s" gnus-newsgroup-name))
4313 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4315 ;; Enter these new marks into the info of the group.
4317 (setcar (nthcdr 3 info) newmarked)
4318 ;; Add the marks lists to the end of the info.
4320 (setcdr (nthcdr 2 info) (list newmarked))))
4322 ;; Cut off the end of the info if there's nothing else there.
4326 (when (nthcdr (decf i) info)
4327 (setcdr (nthcdr i info) nil)))))))
4329 (defun gnus-set-mode-line (where)
4330 "This function sets the mode line of the article or summary buffers.
4331 If WHERE is `summary', the summary mode line format will be used."
4332 ;; Is this mode line one we keep updated?
4333 (when (and (memq where gnus-updated-mode-lines)
4335 (intern (format "gnus-%s-mode-line-format-spec" where))))
4338 ;; We evaluate this in the summary buffer since these
4339 ;; variables are buffer-local to that buffer.
4340 (set-buffer gnus-summary-buffer)
4341 ;; We bind all these variables that are used in the `eval' form
4343 (let* ((mformat (symbol-value
4345 (format "gnus-%s-mode-line-format-spec" where))))
4346 (gnus-tmp-group-name gnus-newsgroup-name)
4347 (gnus-tmp-article-number (or gnus-current-article 0))
4348 (gnus-tmp-unread gnus-newsgroup-unreads)
4349 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4350 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4351 (gnus-tmp-unread-and-unselected
4352 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4353 (zerop gnus-tmp-unselected))
4355 ((zerop gnus-tmp-unselected)
4356 (format "{%d more}" gnus-tmp-unread-and-unticked))
4357 (t (format "{%d(+%d) more}"
4358 gnus-tmp-unread-and-unticked
4359 gnus-tmp-unselected))))
4361 (if (and gnus-current-headers
4362 (vectorp gnus-current-headers))
4363 (gnus-mode-string-quote
4364 (mail-header-subject gnus-current-headers))
4366 bufname-length max-len
4367 gnus-tmp-header);; passed as argument to any user-format-funcs
4368 (setq mode-string (eval mformat))
4369 (setq bufname-length (if (string-match "%b" mode-string)
4372 (if (eq where 'summary)
4374 (get-buffer gnus-article-buffer))))
4377 (setq max-len (max 4 (if gnus-mode-non-string-length
4379 gnus-mode-non-string-length
4381 (length mode-string))))
4382 ;; We might have to chop a bit of the string off...
4383 (when (> (length mode-string) max-len)
4385 (concat (truncate-string-to-width mode-string (- max-len 3))
4387 ;; Pad the mode string a bit.
4388 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4389 ;; Update the mode line.
4390 (setq mode-line-buffer-identification
4391 (gnus-mode-line-buffer-identification (list mode-string)))
4392 (set-buffer-modified-p t))))
4394 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4395 "Go through the HEADERS list and add all Xrefs to a hash table.
4396 The resulting hash table is returned, or nil if no Xrefs were found."
4397 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4398 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4399 (xref-hashtb (gnus-make-hashtable))
4400 start group entry number xrefs header)
4402 (setq header (pop headers))
4403 (when (and (setq xrefs (mail-header-xref header))
4404 (not (memq (setq number (mail-header-number header))
4407 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4408 (setq start (match-end 0))
4409 (setq group (if prefix
4410 (concat prefix (substring xrefs (match-beginning 1)
4412 (substring xrefs (match-beginning 1) (match-end 1))))
4414 (string-to-int (substring xrefs (match-beginning 2)
4416 (if (setq entry (gnus-gethash group xref-hashtb))
4417 (setcdr entry (cons number (cdr entry)))
4418 (gnus-sethash group (cons number nil) xref-hashtb)))))
4419 (and start xref-hashtb)))
4421 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4422 "Look through all the headers and mark the Xrefs as read."
4423 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4424 name entry info xref-hashtb idlist method nth4)
4426 (set-buffer gnus-group-buffer)
4427 (when (setq xref-hashtb
4428 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4431 (unless (string= from-newsgroup (setq name (symbol-name group)))
4432 (setq idlist (symbol-value group))
4433 ;; Dead groups are not updated.
4435 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4437 (when (stringp (setq nth4 (gnus-info-method info)))
4438 (setq nth4 (gnus-server-to-method nth4))))
4439 ;; Only do the xrefs if the group has the same
4440 ;; select method as the group we have just read.
4441 (or (gnus-methods-equal-p
4442 nth4 (gnus-find-method-for-group from-newsgroup))
4444 (equal nth4 (setq method (gnus-find-method-for-group
4446 (and (equal (car nth4) (car method))
4447 (equal (nth 1 nth4) (nth 1 method))))
4448 gnus-use-cross-reference
4449 (or (not (eq gnus-use-cross-reference t))
4451 ;; Only do cross-references on subscribed
4452 ;; groups, if that is what is wanted.
4453 (<= (gnus-info-level info) gnus-level-subscribed))
4454 (gnus-group-make-articles-read name idlist))))
4457 (defun gnus-compute-read-articles (group articles)
4458 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4459 (info (nth 2 entry))
4460 (active (gnus-active group))
4463 ;; First peel off all invalid article numbers.
4465 (let ((ids articles)
4467 (while (setq id (pop ids))
4468 (when (and first (> id (cdr active)))
4469 ;; We'll end up in this situation in one particular
4470 ;; obscure situation. If you re-scan a group and get
4471 ;; a new article that is cross-posted to a different
4472 ;; group that has not been re-scanned, you might get
4473 ;; crossposted article that has a higher number than
4474 ;; Gnus believes possible. So we re-activate this
4475 ;; group as well. This might mean doing the
4476 ;; crossposting thingy will *increase* the number
4477 ;; of articles in some groups. Tsk, tsk.
4478 (setq active (or (gnus-activate-group group) active)))
4479 (when (or (> id (cdr active))
4480 (< id (car active)))
4481 (setq articles (delq id articles))))))
4482 ;; If the read list is nil, we init it.
4484 (null (gnus-info-read info))
4486 (setq ninfo (cons 1 (1- (car active))))
4487 (setq ninfo (gnus-info-read info)))
4488 ;; Then we add the read articles to the range.
4490 ninfo (setq articles (sort articles '<))))))
4492 (defun gnus-group-make-articles-read (group articles)
4493 "Update the info of GROUP to say that ARTICLES are read."
4495 (entry (gnus-gethash group gnus-newsrc-hashtb))
4496 (info (nth 2 entry))
4497 (active (gnus-active group))
4500 (setq range (gnus-compute-read-articles group articles))
4502 (set-buffer gnus-group-buffer)
4505 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4506 (gnus-info-set-read ',info ',(gnus-info-read info))
4507 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4508 (gnus-group-update-group ,group t))))
4509 ;; Add the read articles to the range.
4510 (gnus-info-set-read info range)
4511 ;; Then we have to re-compute how many unread
4512 ;; articles there are in this group.
4516 (setq num (- (1+ (cdr active)) (car active))))
4517 ((not (listp (cdr range)))
4518 (setq num (- (cdr active) (- (1+ (cdr range))
4522 (if (numberp (car range))
4524 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4525 (setq range (cdr range)))
4526 (setq num (- (cdr active) num))))
4527 ;; Update the number of unread articles.
4529 ;; Update the group buffer.
4530 (gnus-group-update-group group t)))))
4532 (defvar gnus-newsgroup-none-id 0)
4534 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4535 (let ((cur nntp-server-buffer)
4538 (save-excursion (set-buffer gnus-summary-buffer)
4539 gnus-newsgroup-dependencies)))
4541 (mail-parse-charset gnus-newsgroup-charset))
4543 (set-buffer nntp-server-buffer)
4544 ;; Translate all TAB characters into SPACE characters.
4545 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4546 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4547 (gnus-run-hooks 'gnus-parse-headers-hook)
4548 (let ((case-fold-search t)
4549 in-reply-to header p lines chars)
4550 (goto-char (point-min))
4551 ;; Search to the beginning of the next header. Error messages
4552 ;; do not begin with 2 or 3.
4553 (while (re-search-forward "^[23][0-9]+ " nil t)
4556 ;; This implementation of this function, with nine
4557 ;; search-forwards instead of the one re-search-forward and
4558 ;; a case (which basically was the old function) is actually
4559 ;; about twice as fast, even though it looks messier. You
4560 ;; can't have everything, I guess. Speed and elegance
4561 ;; doesn't always go hand in hand.
4570 (narrow-to-region (point)
4571 (or (and (search-forward "\n.\n" nil t)
4577 (if (search-forward "\nsubject: " nil t)
4578 (funcall gnus-decode-encoded-word-function
4579 (nnheader-header-value))
4584 (if (search-forward "\nfrom: " nil t)
4585 (funcall gnus-decode-encoded-word-function
4586 (nnheader-header-value))
4591 (if (search-forward "\ndate: " nil t)
4592 (nnheader-header-value) ""))
4596 (setq id (if (re-search-forward
4597 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4598 ;; We do it this way to make sure the Message-ID
4599 ;; is (somewhat) syntactically valid.
4600 (buffer-substring (match-beginning 1)
4602 ;; If there was no message-id, we just fake one
4603 ;; to make subsequent routines simpler.
4604 (nnheader-generate-fake-message-id))))
4608 (if (search-forward "\nreferences: " nil t)
4612 (nnheader-header-value)
4617 (search-backward ">" end t)
4620 (search-backward "<" end t)
4622 ;; Get the references from the in-reply-to header if there
4623 ;; were no references and the in-reply-to header looks
4625 (if (and (search-forward "\nin-reply-to: " nil t)
4626 (setq in-reply-to (nnheader-header-value))
4627 (string-match "<[^>]+>" in-reply-to))
4629 (setq ref (substring in-reply-to (match-beginning 0)
4631 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4632 (setq ref2 (substring in-reply-to (match-beginning 0)
4634 (when (> (length ref2) (length ref))
4641 (if (search-forward "\nchars: " nil t)
4642 (if (numberp (setq chars (ignore-errors (read cur))))
4648 (if (search-forward "\nlines: " nil t)
4649 (if (numberp (setq lines (ignore-errors (read cur))))
4655 (and (search-forward "\nxref: " nil t)
4656 (nnheader-header-value)))
4658 (when gnus-extra-headers
4659 (let ((extra gnus-extra-headers)
4663 (when (search-forward
4664 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4665 (push (cons (car extra) (nnheader-header-value))
4669 (when (equal id ref)
4672 (when gnus-alter-header-function
4673 (funcall gnus-alter-header-function header)
4674 (setq id (mail-header-id header)
4675 ref (gnus-parent-id (mail-header-references header))))
4678 (gnus-dependencies-add-header
4679 header dependencies force-new))
4680 (push header headers))
4681 (goto-char (point-max))
4683 (nreverse headers)))))
4685 ;; Goes through the xover lines and returns a list of vectors
4686 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4687 force-new dependencies
4688 group also-fetch-heads)
4689 "Parse the news overview data in the server buffer, and return a
4690 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4691 ;; Get the Xref when the users reads the articles since most/some
4692 ;; NNTP servers do not include Xrefs when using XOVER.
4693 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4694 (let ((mail-parse-charset gnus-newsgroup-charset)
4695 (cur nntp-server-buffer)
4696 (dependencies (or dependencies gnus-newsgroup-dependencies))
4697 number headers header)
4699 (set-buffer nntp-server-buffer)
4700 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4701 ;; Allow the user to mangle the headers before parsing them.
4702 (gnus-run-hooks 'gnus-parse-headers-hook)
4703 (goto-char (point-min))
4706 (while (and sequence (not (eobp)))
4707 (setq number (read cur))
4708 (while (and sequence
4709 (< (car sequence) number))
4710 (setq sequence (cdr sequence)))
4712 (eq number (car sequence))
4714 (setq sequence (cdr sequence))
4715 (setq header (inline
4716 (gnus-nov-parse-line
4717 number dependencies force-new))))
4718 (push header headers))
4721 (gnus-error 4 "Strange nov line (%d)"
4722 (count-lines (point-min) (point)))))
4724 ;; A common bug in inn is that if you have posted an article and
4725 ;; then retrieves the active file, it will answer correctly --
4726 ;; the new article is included. However, a NOV entry for the
4727 ;; article may not have been generated yet, so this may fail.
4728 ;; We work around this problem by retrieving the last few
4729 ;; headers using HEAD.
4730 (if (or (not also-fetch-heads)
4732 ;; We (probably) got all the headers.
4734 (let ((gnus-nov-is-evil t))
4737 (when (gnus-retrieve-headers sequence group)
4738 (gnus-get-newsgroup-headers))))))))
4740 (defun gnus-article-get-xrefs ()
4741 "Fill in the Xref value in `gnus-current-headers', if necessary.
4742 This is meant to be called in `gnus-article-internal-prepare-hook'."
4743 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4744 gnus-current-headers)))
4745 (or (not gnus-use-cross-reference)
4747 (and (mail-header-xref headers)
4748 (not (string= (mail-header-xref headers) "")))
4749 (let ((case-fold-search t)
4752 (nnheader-narrow-to-headers)
4753 (goto-char (point-min))
4754 (when (or (and (eq (downcase (char-after)) ?x)
4755 (looking-at "Xref:"))
4756 (search-forward "\nXref:" nil t))
4757 (goto-char (1+ (match-end 0)))
4758 (setq xref (buffer-substring (point)
4759 (progn (end-of-line) (point))))
4760 (mail-header-set-xref headers xref)))))))
4762 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4763 "Find article ID and insert the summary line for that article.
4764 OLD-HEADER can either be a header or a line number to insert
4765 the subject line on."
4766 (let* ((line (and (numberp old-header) old-header))
4767 (old-header (and (vectorp old-header) old-header))
4768 (header (cond ((and old-header use-old-header)
4771 (gnus-number-to-header id))
4772 (gnus-number-to-header id))
4774 (gnus-read-header id))))
4775 (number (and (numberp id) id))
4778 ;; Rebuild the thread that this article is part of and go to the
4779 ;; article we have fetched.
4780 (when (and (not gnus-show-threads)
4783 (setq d (gnus-data-find (mail-header-number old-header))))
4784 (goto-char (gnus-data-pos d))
4787 (- (gnus-point-at-bol)
4789 (1+ (gnus-point-at-eol))
4790 (gnus-delete-line))))))
4792 (mail-header-set-number header (mail-header-number old-header)))
4793 (setq gnus-newsgroup-sparse
4794 (delq (setq number (mail-header-number header))
4795 gnus-newsgroup-sparse))
4796 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4797 (push number gnus-newsgroup-limit)
4798 (gnus-rebuild-thread (mail-header-id header) line)
4799 (gnus-summary-goto-subject number nil t))
4800 (when (and (numberp number)
4802 ;; We have to update the boundaries even if we can't fetch the
4803 ;; article if ID is a number -- so that the next `P' or `N'
4804 ;; command will fetch the previous (or next) article even
4805 ;; if the one we tried to fetch this time has been canceled.
4806 (when (> number gnus-newsgroup-end)
4807 (setq gnus-newsgroup-end number))
4808 (when (< number gnus-newsgroup-begin)
4809 (setq gnus-newsgroup-begin number))
4810 (setq gnus-newsgroup-unselected
4811 (delq number gnus-newsgroup-unselected)))
4812 ;; Report back a success?
4813 (and header (mail-header-number header))))
4815 ;;; Process/prefix in the summary buffer
4817 (defun gnus-summary-work-articles (n)
4818 "Return a list of articles to be worked upon.
4819 The prefix argument, the list of process marked articles, and the
4820 current article will be taken into consideration."
4822 (set-buffer gnus-summary-buffer)
4825 ;; A numerical prefix has been given.
4826 (setq n (prefix-numeric-value n))
4827 (let ((backward (< n 0))
4828 (n (abs (prefix-numeric-value n)))
4833 (push (setq article (gnus-summary-article-number))
4836 (gnus-summary-find-prev nil article)
4837 (gnus-summary-find-next nil article)))
4839 (nreverse articles)))
4840 ((and (gnus-region-active-p) (mark))
4841 (message "region active")
4842 ;; Work on the region between point and mark.
4843 (let ((max (max (point) (mark)))
4846 (goto-char (min (min (point) (mark))))
4849 (push (setq article (gnus-summary-article-number)) articles)
4850 (gnus-summary-find-next nil article)
4852 (nreverse articles))))
4853 (gnus-newsgroup-processable
4854 ;; There are process-marked articles present.
4855 ;; Save current state.
4856 (gnus-summary-save-process-mark)
4858 (reverse gnus-newsgroup-processable))
4860 ;; Just return the current article.
4861 (list (gnus-summary-article-number))))))
4863 (defmacro gnus-summary-iterate (arg &rest forms)
4864 "Iterate over the process/prefixed articles and do FORMS.
4865 ARG is the interactive prefix given to the command. FORMS will be
4866 executed with point over the summary line of the articles."
4867 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4868 `(let ((,articles (gnus-summary-work-articles ,arg)))
4870 (gnus-summary-goto-subject (car ,articles))
4873 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4874 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4876 (defun gnus-summary-save-process-mark ()
4877 "Push the current set of process marked articles on the stack."
4879 (push (copy-sequence gnus-newsgroup-processable)
4880 gnus-newsgroup-process-stack))
4882 (defun gnus-summary-kill-process-mark ()
4883 "Push the current set of process marked articles on the stack and unmark."
4885 (gnus-summary-save-process-mark)
4886 (gnus-summary-unmark-all-processable))
4888 (defun gnus-summary-yank-process-mark ()
4889 "Pop the last process mark state off the stack and restore it."
4891 (unless gnus-newsgroup-process-stack
4892 (error "Empty mark stack"))
4893 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4895 (defun gnus-summary-process-mark-set (set)
4896 "Make SET into the current process marked articles."
4897 (gnus-summary-unmark-all-processable)
4899 (gnus-summary-set-process-mark (pop set))))
4901 ;;; Searching and stuff
4903 (defun gnus-summary-search-group (&optional backward use-level)
4904 "Search for next unread newsgroup.
4905 If optional argument BACKWARD is non-nil, search backward instead."
4907 (set-buffer gnus-group-buffer)
4908 (when (gnus-group-search-forward
4909 backward nil (if use-level (gnus-group-group-level) nil))
4910 (gnus-group-group-name))))
4912 (defun gnus-summary-best-group (&optional exclude-group)
4913 "Find the name of the best unread group.
4914 If EXCLUDE-GROUP, do not go to this group."
4916 (set-buffer gnus-group-buffer)
4918 (gnus-group-best-unread-group exclude-group))))
4920 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4921 (if backward (gnus-summary-find-prev)
4922 (let* ((dummy (gnus-summary-article-intangible-p))
4923 (article (or article (gnus-summary-article-number)))
4924 (arts (gnus-data-find-list article))
4926 (when (and (not dummy)
4927 (or (not gnus-summary-check-current)
4929 (not (gnus-data-unread-p (car arts)))))
4930 (setq arts (cdr arts)))
4935 (when (or (and undownloaded
4936 (eq gnus-undownloaded-mark
4937 (gnus-data-mark (car arts))))
4938 (gnus-data-unread-p (car arts)))
4939 (setq result (car arts)
4941 (setq arts (cdr arts)))
4944 (goto-char (gnus-data-pos result))
4945 (gnus-data-number result)))))
4947 (defun gnus-summary-find-prev (&optional unread article)
4948 (let* ((eobp (eobp))
4949 (article (or article (gnus-summary-article-number)))
4950 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4952 (when (and (not eobp)
4953 (or (not gnus-summary-check-current)
4955 (not (gnus-data-unread-p (car arts)))))
4956 (setq arts (cdr arts)))
4961 (when (gnus-data-unread-p (car arts))
4962 (setq result (car arts)
4964 (setq arts (cdr arts)))
4967 (goto-char (gnus-data-pos result))
4968 (gnus-data-number result))))
4970 (defun gnus-summary-find-subject (subject &optional unread backward article)
4971 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4972 (article (or article (gnus-summary-article-number)))
4973 (articles (gnus-data-list backward))
4974 (arts (gnus-data-find-list article articles))
4976 (when (or (not gnus-summary-check-current)
4978 (not (gnus-data-unread-p (car arts))))
4979 (setq arts (cdr arts)))
4981 (and (or (not unread)
4982 (gnus-data-unread-p (car arts)))
4983 (vectorp (gnus-data-header (car arts)))
4985 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4986 (setq result (car arts)
4988 (setq arts (cdr arts)))
4990 (goto-char (gnus-data-pos result))
4991 (gnus-data-number result))))
4993 (defun gnus-summary-search-forward (&optional unread subject backward)
4994 "Search forward for an article.
4995 If UNREAD, look for unread articles. If SUBJECT, look for
4996 articles with that subject. If BACKWARD, search backward instead."
4997 (cond (subject (gnus-summary-find-subject subject unread backward))
4998 (backward (gnus-summary-find-prev unread))
4999 (t (gnus-summary-find-next unread))))
5001 (defun gnus-recenter (&optional n)
5002 "Center point in window and redisplay frame.
5003 Also do horizontal recentering."
5005 (when (and gnus-auto-center-summary
5006 (not (eq gnus-auto-center-summary 'vertical)))
5007 (gnus-horizontal-recenter))
5010 (defun gnus-summary-recenter ()
5011 "Center point in the summary window.
5012 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5013 displayed, no centering will be performed."
5014 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5015 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5016 (let* ((top (cond ((< (window-height) 4) 0)
5017 ((< (window-height) 7) 1)
5018 (t (if (numberp gnus-auto-center-summary)
5019 gnus-auto-center-summary
5021 (height (1- (window-height)))
5022 (bottom (save-excursion (goto-char (point-max))
5023 (forward-line (- height))
5025 (window (get-buffer-window (current-buffer))))
5026 ;; The user has to want it.
5027 (when gnus-auto-center-summary
5028 (when (get-buffer-window gnus-article-buffer)
5029 ;; Only do recentering when the article buffer is displayed,
5030 ;; Set the window start to either `bottom', which is the biggest
5031 ;; possible valid number, or the second line from the top,
5032 ;; whichever is the least.
5034 window (min bottom (save-excursion
5035 (forward-line (- top)) (point)))))
5036 ;; Do horizontal recentering while we're at it.
5037 (when (and (get-buffer-window (current-buffer) t)
5038 (not (eq gnus-auto-center-summary 'vertical)))
5039 (let ((selected (selected-window)))
5040 (select-window (get-buffer-window (current-buffer) t))
5041 (gnus-summary-position-point)
5042 (gnus-horizontal-recenter)
5043 (select-window selected))))))
5045 (defun gnus-summary-jump-to-group (newsgroup)
5046 "Move point to NEWSGROUP in group mode buffer."
5047 ;; Keep update point of group mode buffer if visible.
5048 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5049 (save-window-excursion
5050 ;; Take care of tree window mode.
5051 (when (get-buffer-window gnus-group-buffer)
5052 (pop-to-buffer gnus-group-buffer))
5053 (gnus-group-jump-to-group newsgroup))
5055 ;; Take care of tree window mode.
5056 (if (get-buffer-window gnus-group-buffer)
5057 (pop-to-buffer gnus-group-buffer)
5058 (set-buffer gnus-group-buffer))
5059 (gnus-group-jump-to-group newsgroup))))
5061 ;; This function returns a list of article numbers based on the
5062 ;; difference between the ranges of read articles in this group and
5063 ;; the range of active articles.
5064 (defun gnus-list-of-unread-articles (group)
5065 (let* ((read (gnus-info-read (gnus-get-info group)))
5066 (active (or (gnus-active group) (gnus-activate-group group)))
5069 ;; If none are read, then all are unread.
5071 (setq first (car active))
5072 ;; If the range of read articles is a single range, then the
5073 ;; first unread article is the article after the last read
5074 ;; article. Sounds logical, doesn't it?
5075 (if (not (listp (cdr read)))
5076 (setq first (max (car active) (1+ (cdr read))))
5077 ;; `read' is a list of ranges.
5078 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5081 (setq first (car active)))
5084 (while (< first nlast)
5086 (setq first (1+ first))))
5087 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5088 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5089 (setq read (cdr read)))))
5090 ;; And add the last unread articles.
5091 (while (<= first last)
5093 (setq first (1+ first)))
5094 ;; Return the list of unread articles.
5095 (delq 0 (nreverse unread))))
5097 (defun gnus-list-of-read-articles (group)
5098 "Return a list of unread, unticked and non-dormant articles."
5099 (let* ((info (gnus-get-info group))
5100 (marked (gnus-info-marks info))
5101 (active (gnus-active group)))
5103 (gnus-set-difference
5104 (gnus-sorted-complement
5105 (gnus-uncompress-range active)
5106 (gnus-list-of-unread-articles group))
5108 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5109 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5111 ;; Various summary commands
5113 (defun gnus-summary-select-article-buffer ()
5114 "Reconfigure windows to show article buffer."
5116 (if (not (gnus-buffer-live-p gnus-article-buffer))
5117 (error "There is no article buffer for this summary buffer")
5118 (gnus-configure-windows 'article)
5119 (select-window (get-buffer-window gnus-article-buffer))))
5121 (defun gnus-summary-universal-argument (arg)
5122 "Perform any operation on all articles that are process/prefixed."
5124 (let ((articles (gnus-summary-work-articles arg))
5131 (substitute-command-keys
5132 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5135 (gnus-error 1 "Undefined key")
5138 (gnus-summary-goto-subject (setq article (pop articles)))
5139 (let (gnus-newsgroup-processable)
5140 (command-execute func))
5141 (gnus-summary-remove-process-mark article)))))
5142 (gnus-summary-position-point))
5144 (defun gnus-summary-toggle-truncation (&optional arg)
5145 "Toggle truncation of summary lines.
5146 With arg, turn line truncation on iff arg is positive."
5148 (setq truncate-lines
5149 (if (null arg) (not truncate-lines)
5150 (> (prefix-numeric-value arg) 0)))
5153 (defun gnus-summary-reselect-current-group (&optional all rescan)
5154 "Exit and then reselect the current newsgroup.
5155 The prefix argument ALL means to select all articles."
5157 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5158 (error "Ephemeral groups can't be reselected"))
5159 (let ((current-subject (gnus-summary-article-number))
5160 (group gnus-newsgroup-name))
5161 (setq gnus-newsgroup-begin nil)
5163 ;; We have to adjust the point of group mode buffer because
5164 ;; point was moved to the next unread newsgroup by exiting.
5165 (gnus-summary-jump-to-group group)
5168 (gnus-group-get-new-news-this-group 1)))
5169 (gnus-group-read-group all t)
5170 (gnus-summary-goto-subject current-subject nil t)))
5172 (defun gnus-summary-rescan-group (&optional all)
5173 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5175 (gnus-summary-reselect-current-group all t))
5177 (defun gnus-summary-update-info (&optional non-destructive)
5179 (let ((group gnus-newsgroup-name))
5181 (when gnus-newsgroup-kill-headers
5182 (setq gnus-newsgroup-killed
5183 (gnus-compress-sequence
5185 (gnus-set-sorted-intersection
5186 (gnus-uncompress-range gnus-newsgroup-killed)
5187 (setq gnus-newsgroup-unselected
5188 (sort gnus-newsgroup-unselected '<)))
5189 (setq gnus-newsgroup-unreads
5190 (sort gnus-newsgroup-unreads '<)))
5192 (unless (listp (cdr gnus-newsgroup-killed))
5193 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5194 (let ((headers gnus-newsgroup-headers))
5195 ;; Set the new ranges of read articles.
5197 (set-buffer gnus-group-buffer)
5198 (gnus-undo-force-boundary))
5199 (gnus-update-read-articles
5200 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5201 ;; Set the current article marks.
5202 (let ((gnus-newsgroup-scored
5203 (if (and (not gnus-save-score)
5204 (not non-destructive))
5206 gnus-newsgroup-scored)))
5208 (gnus-update-marks)))
5209 ;; Do the cross-ref thing.
5210 (when gnus-use-cross-reference
5211 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5212 ;; Do not switch windows but change the buffer to work.
5213 (set-buffer gnus-group-buffer)
5214 (unless (gnus-ephemeral-group-p group)
5215 (gnus-group-update-group group)))))))
5217 (defun gnus-summary-save-newsrc (&optional force)
5218 "Save the current number of read/marked articles in the dribble buffer.
5219 The dribble buffer will then be saved.
5220 If FORCE (the prefix), also save the .newsrc file(s)."
5222 (gnus-summary-update-info t)
5224 (gnus-save-newsrc-file)
5225 (gnus-dribble-save)))
5227 (defun gnus-summary-exit (&optional temporary)
5228 "Exit reading current newsgroup, and then return to group selection mode.
5229 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5231 (gnus-set-global-variables)
5232 (when (gnus-buffer-live-p gnus-article-buffer)
5234 (set-buffer gnus-article-buffer)
5235 (mm-destroy-parts gnus-article-mime-handles)))
5236 (gnus-kill-save-kill-buffer)
5237 (gnus-async-halt-prefetch)
5238 (let* ((group gnus-newsgroup-name)
5239 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5242 (buf (current-buffer)))
5244 ;; Do adaptive scoring, and possibly save score files.
5245 (when gnus-newsgroup-adaptive
5246 (gnus-score-adaptive))
5247 (when gnus-use-scoring
5249 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5250 ;; If we have several article buffers, we kill them at exit.
5251 (unless gnus-single-article-buffer
5252 (gnus-kill-buffer gnus-original-article-buffer)
5253 (setq gnus-article-current nil))
5254 (when gnus-use-cache
5255 (gnus-cache-possibly-remove-articles)
5256 (gnus-cache-save-buffers))
5257 (gnus-async-prefetch-remove-group group)
5258 (when gnus-suppress-duplicates
5259 (gnus-dup-enter-articles))
5260 (when gnus-use-trees
5261 (gnus-tree-close group))
5262 ;; Remove entries for this group.
5263 (nnmail-purge-split-history (gnus-group-real-name group))
5264 ;; Make all changes in this group permanent.
5266 (gnus-run-hooks 'gnus-exit-group-hook)
5267 (gnus-summary-update-info))
5268 (gnus-close-group group)
5269 ;; Make sure where we were, and go to next newsgroup.
5270 (set-buffer gnus-group-buffer)
5272 (gnus-group-jump-to-group group))
5273 (gnus-run-hooks 'gnus-summary-exit-hook)
5274 (unless (or quit-config
5275 ;; If this group has disappeared from the summary
5276 ;; buffer, don't skip forwards.
5277 (not (string= group (gnus-group-group-name))))
5278 (gnus-group-next-unread-group 1))
5279 (setq group-point (point))
5282 ;; If we have several article buffers, we kill them at exit.
5283 (unless gnus-single-article-buffer
5284 (gnus-kill-buffer gnus-article-buffer)
5285 (gnus-kill-buffer gnus-original-article-buffer)
5286 (setq gnus-article-current nil))
5288 (if (not gnus-kill-summary-on-exit)
5289 (gnus-deaden-summary)
5290 ;; We set all buffer-local variables to nil. It is unclear why
5291 ;; this is needed, but if we don't, buffer-local variables are
5292 ;; not garbage-collected, it seems. This would the lead to en
5293 ;; ever-growing Emacs.
5294 (gnus-summary-clear-local-variables)
5295 (when (get-buffer gnus-article-buffer)
5296 (bury-buffer gnus-article-buffer))
5297 ;; We clear the global counterparts of the buffer-local
5298 ;; variables as well, just to be on the safe side.
5299 (set-buffer gnus-group-buffer)
5300 (gnus-summary-clear-local-variables)
5301 ;; Return to group mode buffer.
5302 (when (eq mode 'gnus-summary-mode)
5303 (gnus-kill-buffer buf)))
5304 (setq gnus-current-select-method gnus-select-method)
5305 (pop-to-buffer gnus-group-buffer)
5306 (if (not quit-config)
5308 (goto-char group-point)
5309 (gnus-configure-windows 'group 'force))
5310 (gnus-handle-ephemeral-exit quit-config))
5311 ;; Clear the current group name.
5313 (setq gnus-newsgroup-name nil)))))
5315 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5316 (defun gnus-summary-exit-no-update (&optional no-questions)
5317 "Quit reading current newsgroup without updating read article info."
5319 (let* ((group gnus-newsgroup-name)
5320 (quit-config (gnus-group-quit-config group)))
5321 (when (or no-questions
5323 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5324 (gnus-async-halt-prefetch)
5326 (delq 'gnus-summary-expire-articles
5327 (copy-list gnus-summary-prepare-exit-hook)))
5328 (when (gnus-buffer-live-p gnus-article-buffer)
5330 (set-buffer gnus-article-buffer)
5331 (mm-destroy-parts gnus-article-mime-handles)))
5332 ;; If we have several article buffers, we kill them at exit.
5333 (unless gnus-single-article-buffer
5334 (gnus-kill-buffer gnus-article-buffer)
5335 (gnus-kill-buffer gnus-original-article-buffer)
5336 (setq gnus-article-current nil))
5337 (if (not gnus-kill-summary-on-exit)
5338 (gnus-deaden-summary)
5339 (gnus-close-group group)
5340 (gnus-summary-clear-local-variables)
5341 (set-buffer gnus-group-buffer)
5342 (gnus-summary-clear-local-variables)
5343 (when (get-buffer gnus-summary-buffer)
5344 (kill-buffer gnus-summary-buffer)))
5345 (unless gnus-single-article-buffer
5346 (setq gnus-article-current nil))
5347 (when gnus-use-trees
5348 (gnus-tree-close group))
5349 (gnus-async-prefetch-remove-group group)
5350 (when (get-buffer gnus-article-buffer)
5351 (bury-buffer gnus-article-buffer))
5352 ;; Return to the group buffer.
5353 (gnus-configure-windows 'group 'force)
5354 ;; Clear the current group name.
5355 (setq gnus-newsgroup-name nil)
5356 (when (equal (gnus-group-group-name) group)
5357 (gnus-group-next-unread-group 1))
5359 (gnus-handle-ephemeral-exit quit-config)))))
5361 (defun gnus-handle-ephemeral-exit (quit-config)
5362 "Handle movement when leaving an ephemeral group.
5363 The state which existed when entering the ephemeral is reset."
5364 (if (not (buffer-name (car quit-config)))
5365 (gnus-configure-windows 'group 'force)
5366 (set-buffer (car quit-config))
5367 (cond ((eq major-mode 'gnus-summary-mode)
5368 (gnus-set-global-variables))
5369 ((eq major-mode 'gnus-article-mode)
5371 ;; The `gnus-summary-buffer' variable may point
5372 ;; to the old summary buffer when using a single
5374 (unless (gnus-buffer-live-p gnus-summary-buffer)
5375 (set-buffer gnus-group-buffer))
5376 (set-buffer gnus-summary-buffer)
5377 (gnus-set-global-variables))))
5378 (if (or (eq (cdr quit-config) 'article)
5379 (eq (cdr quit-config) 'pick))
5381 ;; The current article may be from the ephemeral group
5382 ;; thus it is best that we reload this article
5383 (gnus-summary-show-article)
5384 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5385 (gnus-configure-windows 'pick 'force)
5386 (gnus-configure-windows (cdr quit-config) 'force)))
5387 (gnus-configure-windows (cdr quit-config) 'force))
5388 (when (eq major-mode 'gnus-summary-mode)
5389 (gnus-summary-next-subject 1 nil t)
5390 (gnus-summary-recenter)
5391 (gnus-summary-position-point))))
5395 (defvar gnus-dead-summary-mode-map nil)
5397 (unless gnus-dead-summary-mode-map
5398 (setq gnus-dead-summary-mode-map (make-keymap))
5399 (suppress-keymap gnus-dead-summary-mode-map)
5400 (substitute-key-definition
5401 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5402 (let ((keys '("\C-d" "\r" "\177" [delete])))
5404 (define-key gnus-dead-summary-mode-map
5405 (pop keys) 'gnus-summary-wake-up-the-dead))))
5407 (defvar gnus-dead-summary-mode nil
5408 "Minor mode for Gnus summary buffers.")
5410 (defun gnus-dead-summary-mode (&optional arg)
5411 "Minor mode for Gnus summary buffers."
5413 (when (eq major-mode 'gnus-summary-mode)
5414 (make-local-variable 'gnus-dead-summary-mode)
5415 (setq gnus-dead-summary-mode
5416 (if (null arg) (not gnus-dead-summary-mode)
5417 (> (prefix-numeric-value arg) 0)))
5418 (when gnus-dead-summary-mode
5419 (gnus-add-minor-mode
5420 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5422 (defun gnus-deaden-summary ()
5423 "Make the current summary buffer into a dead summary buffer."
5424 ;; Kill any previous dead summary buffer.
5425 (when (and gnus-dead-summary
5426 (buffer-name gnus-dead-summary))
5428 (set-buffer gnus-dead-summary)
5429 (when gnus-dead-summary-mode
5430 (kill-buffer (current-buffer)))))
5431 ;; Make this the current dead summary.
5432 (setq gnus-dead-summary (current-buffer))
5433 (gnus-dead-summary-mode 1)
5434 (let ((name (buffer-name)))
5435 (when (string-match "Summary" name)
5437 (concat (substring name 0 (match-beginning 0)) "Dead "
5438 (substring name (match-beginning 0)))
5441 (defun gnus-kill-or-deaden-summary (buffer)
5442 "Kill or deaden the summary BUFFER."
5444 (when (and (buffer-name buffer)
5445 (not gnus-single-article-buffer))
5448 (gnus-kill-buffer gnus-article-buffer)
5449 (gnus-kill-buffer gnus-original-article-buffer)))
5450 (cond (gnus-kill-summary-on-exit
5451 (when (and gnus-use-trees
5452 (gnus-buffer-exists-p buffer))
5455 (gnus-tree-close gnus-newsgroup-name)))
5456 (gnus-kill-buffer buffer))
5457 ((gnus-buffer-exists-p buffer)
5460 (gnus-deaden-summary))))))
5462 (defun gnus-summary-wake-up-the-dead (&rest args)
5463 "Wake up the dead summary buffer."
5465 (gnus-dead-summary-mode -1)
5466 (let ((name (buffer-name)))
5467 (when (string-match "Dead " name)
5469 (concat (substring name 0 (match-beginning 0))
5470 (substring name (match-end 0)))
5472 (gnus-message 3 "This dead summary is now alive again"))
5474 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5475 (defun gnus-summary-fetch-faq (&optional faq-dir)
5476 "Fetch the FAQ for the current group.
5477 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5481 (when current-prefix-arg
5483 "Faq dir: " (and (listp gnus-group-faq-directory)
5484 (mapcar (lambda (file) (list file))
5485 gnus-group-faq-directory))))))
5486 (let (gnus-faq-buffer)
5487 (when (setq gnus-faq-buffer
5488 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5489 (gnus-configure-windows 'summary-faq))))
5491 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5492 (defun gnus-summary-describe-group (&optional force)
5493 "Describe the current newsgroup."
5495 (gnus-group-describe-group force gnus-newsgroup-name))
5497 (defun gnus-summary-describe-briefly ()
5498 "Describe summary mode commands briefly."
5500 (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")))
5502 ;; Walking around group mode buffer from summary mode.
5504 (defun gnus-summary-next-group (&optional no-article target-group backward)
5505 "Exit current newsgroup and then select next unread newsgroup.
5506 If prefix argument NO-ARTICLE is non-nil, no article is selected
5507 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5508 previous group instead."
5510 ;; Stop pre-fetching.
5511 (gnus-async-halt-prefetch)
5512 (let ((current-group gnus-newsgroup-name)
5513 (current-buffer (current-buffer))
5515 ;; First we semi-exit this group to update Xrefs and all variables.
5516 ;; We can't do a real exit, because the window conf must remain
5517 ;; the same in case the user is prompted for info, and we don't
5518 ;; want the window conf to change before that...
5519 (gnus-summary-exit t)
5520 (while (not entered)
5521 ;; Then we find what group we are supposed to enter.
5522 (set-buffer gnus-group-buffer)
5523 (gnus-group-jump-to-group current-group)
5526 (if (eq gnus-keep-same-level 'best)
5527 (gnus-summary-best-group gnus-newsgroup-name)
5528 (gnus-summary-search-group backward gnus-keep-same-level))))
5529 (if (not target-group)
5530 ;; There are no further groups, so we return to the group
5533 (gnus-message 5 "Returning to the group buffer")
5535 (when (gnus-buffer-live-p current-buffer)
5536 (set-buffer current-buffer)
5537 (gnus-summary-exit))
5538 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5539 ;; We try to enter the target group.
5540 (gnus-group-jump-to-group target-group)
5541 (let ((unreads (gnus-group-group-unread)))
5542 (if (and (or (eq t unreads)
5543 (and unreads (not (zerop unreads))))
5544 (gnus-summary-read-group
5545 target-group nil no-article
5546 (and (buffer-name current-buffer) current-buffer)
5549 (setq current-group target-group
5550 target-group nil)))))))
5552 (defun gnus-summary-prev-group (&optional no-article)
5553 "Exit current newsgroup and then select previous unread newsgroup.
5554 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5556 (gnus-summary-next-group no-article nil t))
5558 ;; Walking around summary lines.
5560 (defun gnus-summary-first-subject (&optional unread undownloaded)
5561 "Go to the first unread subject.
5562 If UNREAD is non-nil, go to the first unread article.
5563 Returns the article selected or nil if there are no unread articles."
5568 ((null gnus-newsgroup-data)
5569 (gnus-message 3 "No articles in the group")
5571 ;; Pick the first article.
5573 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5574 (gnus-data-number (car gnus-newsgroup-data)))
5575 ;; No unread articles.
5576 ((null gnus-newsgroup-unreads)
5577 (gnus-message 3 "No more unread articles")
5579 ;; Find the first unread article.
5581 (let ((data gnus-newsgroup-data))
5583 (and (not (and undownloaded
5584 (eq gnus-undownloaded-mark
5585 (gnus-data-mark (car data)))))
5586 (not (gnus-data-unread-p (car data)))))
5587 (setq data (cdr data)))
5589 (goto-char (gnus-data-pos (car data)))
5590 (gnus-data-number (car data))))))
5591 (gnus-summary-position-point)))
5593 (defun gnus-summary-next-subject (n &optional unread dont-display)
5594 "Go to next N'th summary line.
5595 If N is negative, go to the previous N'th subject line.
5596 If UNREAD is non-nil, only unread articles are selected.
5597 The difference between N and the actual number of steps taken is
5600 (let ((backward (< n 0))
5604 (gnus-summary-find-prev unread)
5605 (gnus-summary-find-next unread)))
5606 (gnus-summary-show-thread)
5609 (gnus-message 7 "No more%s articles"
5610 (if unread " unread" "")))
5611 (unless dont-display
5612 (gnus-summary-recenter)
5613 (gnus-summary-position-point))
5616 (defun gnus-summary-next-unread-subject (n)
5617 "Go to next N'th unread summary line."
5619 (gnus-summary-next-subject n t))
5621 (defun gnus-summary-prev-subject (n &optional unread)
5622 "Go to previous N'th summary line.
5623 If optional argument UNREAD is non-nil, only unread article is selected."
5625 (gnus-summary-next-subject (- n) unread))
5627 (defun gnus-summary-prev-unread-subject (n)
5628 "Go to previous N'th unread summary line."
5630 (gnus-summary-next-subject (- n) t))
5632 (defun gnus-summary-goto-subject (article &optional force silent)
5633 "Go the subject line of ARTICLE.
5634 If FORCE, also allow jumping to articles not currently shown."
5635 (interactive "nArticle number: ")
5637 (data (gnus-data-find article)))
5638 ;; We read in the article if we have to.
5641 (gnus-summary-insert-subject
5643 (if (or (numberp force) (vectorp force)) force)
5645 (setq data (gnus-data-find article)))
5650 (gnus-message 3 "Can't find article %d" article))
5652 (goto-char (gnus-data-pos data))
5653 (gnus-summary-position-point)
5656 ;; Walking around summary lines with displaying articles.
5658 (defun gnus-summary-expand-window (&optional arg)
5659 "Make the summary buffer take up the entire Emacs frame.
5660 Given a prefix, will force an `article' buffer configuration."
5663 (gnus-configure-windows 'article 'force)
5664 (gnus-configure-windows 'summary 'force)))
5666 (defun gnus-summary-display-article (article &optional all-header)
5667 "Display ARTICLE in article buffer."
5668 (gnus-set-global-variables)
5672 (if gnus-summary-display-article-function
5673 (funcall gnus-summary-display-article-function article all-header)
5674 (gnus-article-prepare article all-header))
5675 (gnus-run-hooks 'gnus-select-article-hook)
5676 (when (and gnus-current-article
5677 (not (zerop gnus-current-article)))
5678 (gnus-summary-goto-subject gnus-current-article))
5679 (gnus-summary-recenter)
5680 (when (and gnus-use-trees gnus-show-threads)
5681 (gnus-possibly-generate-tree article)
5682 (gnus-highlight-selected-tree article))
5683 ;; Successfully display article.
5684 (gnus-article-set-window-start
5685 (cdr (assq article gnus-newsgroup-bookmarks))))))
5687 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5688 "Select the current article.
5689 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5690 non-nil, the article will be re-fetched even if it already present in
5691 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5693 ;; Make sure we are in the summary buffer to work around bbdb bug.
5694 (unless (eq major-mode 'gnus-summary-mode)
5695 (set-buffer gnus-summary-buffer))
5696 (let ((article (or article (gnus-summary-article-number)))
5697 (all-headers (not (not all-headers))) ;Must be T or NIL.
5698 gnus-summary-display-article-function
5701 (gnus-summary-article-pseudo-p article)
5702 (error "This is a pseudo-article"))
5705 (set-buffer gnus-summary-buffer)
5706 (if (or (and gnus-single-article-buffer
5707 (or (null gnus-current-article)
5708 (null gnus-article-current)
5709 (null (get-buffer gnus-article-buffer))
5710 (not (eq article (cdr gnus-article-current)))
5711 (not (equal (car gnus-article-current)
5712 gnus-newsgroup-name))))
5713 (and (not gnus-single-article-buffer)
5714 (or (null gnus-current-article)
5715 (not (eq gnus-current-article article))))
5717 ;; The requested article is different from the current article.
5719 (gnus-summary-display-article article all-headers)
5721 (when (or all-headers gnus-show-all-headers)
5722 (gnus-article-show-all-headers)))
5723 (when (or all-headers gnus-show-all-headers)
5724 (gnus-article-show-all-headers))
5727 (gnus-article-set-window-start
5728 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5730 (defun gnus-summary-set-current-mark (&optional current-mark)
5731 "Obsolete function."
5734 (defun gnus-summary-next-article (&optional unread subject backward push)
5735 "Select the next article.
5736 If UNREAD, only unread articles are selected.
5737 If SUBJECT, only articles with SUBJECT are selected.
5738 If BACKWARD, the previous article is selected instead of the next."
5741 ;; Is there such an article?
5742 ((and (gnus-summary-search-forward unread subject backward)
5743 (or (gnus-summary-display-article (gnus-summary-article-number))
5744 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5745 (gnus-summary-position-point))
5746 ;; If not, we try the first unread, if that is wanted.
5748 gnus-auto-select-same
5749 (gnus-summary-first-unread-article))
5750 (gnus-summary-position-point)
5751 (gnus-message 6 "Wrapped"))
5752 ;; Try to get next/previous article not displayed in this group.
5753 ((and gnus-auto-extend-newsgroup
5754 (not unread) (not subject))
5755 (gnus-summary-goto-article
5756 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5757 nil (count-lines (point-min) (point))))
5758 ;; Go to next/previous group.
5760 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5761 (gnus-summary-jump-to-group gnus-newsgroup-name))
5762 (let ((cmd last-command-char)
5765 (set-buffer gnus-group-buffer)
5768 (if (eq gnus-keep-same-level 'best)
5769 (gnus-summary-best-group gnus-newsgroup-name)
5770 (gnus-summary-search-group backward gnus-keep-same-level))))
5771 ;; For some reason, the group window gets selected. We change
5773 (select-window (get-buffer-window (current-buffer)))
5774 ;; Select next unread newsgroup automagically.
5776 ((or (not gnus-auto-select-next)
5778 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5779 ((or (eq gnus-auto-select-next 'quietly)
5780 (and (eq gnus-auto-select-next 'slightly-quietly)
5782 (and (eq gnus-auto-select-next 'almost-quietly)
5783 (gnus-summary-last-article-p)))
5785 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5787 (gnus-message 7 "No more%s articles (%s)..."
5788 (if unread " unread" "")
5789 (if group (concat "selecting " group)
5791 (gnus-summary-next-group nil group backward)))
5793 (when (gnus-key-press-event-p last-input-event)
5794 (gnus-summary-walk-group-buffer
5795 gnus-newsgroup-name cmd unread backward point))))))))
5797 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5798 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5799 (?\C-p (gnus-group-prev-unread-group 1))))
5800 (cursor-in-echo-area t)
5801 keve key group ended)
5803 (set-buffer gnus-group-buffer)
5806 (if (eq gnus-keep-same-level 'best)
5807 (gnus-summary-best-group gnus-newsgroup-name)
5808 (gnus-summary-search-group backward gnus-keep-same-level))))
5811 5 "No more%s articles%s" (if unread " unread" "")
5813 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5814 (format " (Type %s for %s [%s])"
5815 (single-key-description cmd) group
5816 (car (gnus-gethash group gnus-newsrc-hashtb)))
5817 (format " (Type %s to exit %s)"
5818 (single-key-description cmd)
5819 gnus-newsgroup-name)))
5820 ;; Confirm auto selection.
5821 (setq key (car (setq keve (gnus-read-event-char))))
5824 ((assq key keystrokes)
5825 (let ((obuf (current-buffer)))
5826 (switch-to-buffer gnus-group-buffer)
5828 (gnus-group-jump-to-group group))
5829 (eval (cadr (assq key keystrokes)))
5830 (setq group (gnus-group-group-name))
5831 (switch-to-buffer obuf))
5835 (gnus-ephemeral-group-p gnus-newsgroup-name))
5837 (gnus-summary-next-group nil group backward)))
5839 (push (cdr keve) unread-command-events))))))
5841 (defun gnus-summary-next-unread-article ()
5842 "Select unread article after current one."
5844 (gnus-summary-next-article
5845 (or (not (eq gnus-summary-goto-unread 'never))
5846 (gnus-summary-last-article-p (gnus-summary-article-number)))
5847 (and gnus-auto-select-same
5848 (gnus-summary-article-subject))))
5850 (defun gnus-summary-prev-article (&optional unread subject)
5851 "Select the article after the current one.
5852 If UNREAD is non-nil, only unread articles are selected."
5854 (gnus-summary-next-article unread subject t))
5856 (defun gnus-summary-prev-unread-article ()
5857 "Select unread article before current one."
5859 (gnus-summary-prev-article
5860 (or (not (eq gnus-summary-goto-unread 'never))
5861 (gnus-summary-first-article-p (gnus-summary-article-number)))
5862 (and gnus-auto-select-same
5863 (gnus-summary-article-subject))))
5865 (defun gnus-summary-next-page (&optional lines circular)
5866 "Show next page of the selected article.
5867 If at the end of the current article, select the next article.
5868 LINES says how many lines should be scrolled up.
5870 If CIRCULAR is non-nil, go to the start of the article instead of
5871 selecting the next article when reaching the end of the current
5874 (setq gnus-summary-buffer (current-buffer))
5875 (gnus-set-global-variables)
5876 (let ((article (gnus-summary-article-number))
5877 (article-window (get-buffer-window gnus-article-buffer t))
5879 ;; If the buffer is empty, we have no article.
5881 (error "No article to select"))
5882 (gnus-configure-windows 'article)
5883 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5884 (if (and (eq gnus-summary-goto-unread 'never)
5885 (not (gnus-summary-last-article-p article)))
5886 (gnus-summary-next-article)
5887 (gnus-summary-next-unread-article))
5888 (if (or (null gnus-current-article)
5889 (null gnus-article-current)
5890 (/= article (cdr gnus-article-current))
5891 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5892 ;; Selected subject is different from current article's.
5893 (gnus-summary-display-article article)
5894 (when article-window
5895 (gnus-eval-in-buffer-window gnus-article-buffer
5896 (setq endp (gnus-article-next-page lines)))
5899 (gnus-summary-beginning-of-article))
5901 (gnus-message 3 "End of message"))
5903 (if (and (eq gnus-summary-goto-unread 'never)
5904 (not (gnus-summary-last-article-p article)))
5905 (gnus-summary-next-article)
5906 (gnus-summary-next-unread-article))))))))
5907 (gnus-summary-recenter)
5908 (gnus-summary-position-point)))
5910 (defun gnus-summary-prev-page (&optional lines move)
5911 "Show previous page of selected article.
5912 Argument LINES specifies lines to be scrolled down.
5913 If MOVE, move to the previous unread article if point is at
5914 the beginning of the buffer."
5916 (let ((article (gnus-summary-article-number))
5917 (article-window (get-buffer-window gnus-article-buffer t))
5919 (gnus-configure-windows 'article)
5920 (if (or (null gnus-current-article)
5921 (null gnus-article-current)
5922 (/= article (cdr gnus-article-current))
5923 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5924 ;; Selected subject is different from current article's.
5925 (gnus-summary-display-article article)
5926 (gnus-summary-recenter)
5927 (when article-window
5928 (gnus-eval-in-buffer-window gnus-article-buffer
5929 (setq endp (gnus-article-prev-page lines)))
5930 (when (and move endp)
5932 (gnus-message 3 "Beginning of message"))
5934 (if (and (eq gnus-summary-goto-unread 'never)
5935 (not (gnus-summary-first-article-p article)))
5936 (gnus-summary-prev-article)
5937 (gnus-summary-prev-unread-article))))))))
5938 (gnus-summary-position-point))
5940 (defun gnus-summary-prev-page-or-article (&optional lines)
5941 "Show previous page of selected article.
5942 Argument LINES specifies lines to be scrolled down.
5943 If at the beginning of the article, go to the next article."
5945 (gnus-summary-prev-page lines t))
5947 (defun gnus-summary-scroll-up (lines)
5948 "Scroll up (or down) one line current article.
5949 Argument LINES specifies lines to be scrolled up (or down if negative)."
5951 (gnus-configure-windows 'article)
5952 (gnus-summary-show-thread)
5953 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5954 (gnus-eval-in-buffer-window gnus-article-buffer
5956 (when (gnus-article-next-page lines)
5957 (gnus-message 3 "End of message")))
5959 (gnus-article-prev-page (- lines))))))
5960 (gnus-summary-recenter)
5961 (gnus-summary-position-point))
5963 (defun gnus-summary-scroll-down (lines)
5964 "Scroll down (or up) one line current article.
5965 Argument LINES specifies lines to be scrolled down (or up if negative)."
5967 (gnus-summary-scroll-up (- lines)))
5969 (defun gnus-summary-next-same-subject ()
5970 "Select next article which has the same subject as current one."
5972 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5974 (defun gnus-summary-prev-same-subject ()
5975 "Select previous article which has the same subject as current one."
5977 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5979 (defun gnus-summary-next-unread-same-subject ()
5980 "Select next unread article which has the same subject as current one."
5982 (gnus-summary-next-article t (gnus-summary-article-subject)))
5984 (defun gnus-summary-prev-unread-same-subject ()
5985 "Select previous unread article which has the same subject as current one."
5987 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5989 (defun gnus-summary-first-unread-article ()
5990 "Select the first unread article.
5991 Return nil if there are no unread articles."
5994 (when (gnus-summary-first-subject t)
5995 (gnus-summary-show-thread)
5996 (gnus-summary-first-subject t)
5997 (gnus-summary-display-article (gnus-summary-article-number)))
5998 (gnus-summary-position-point)))
6000 (defun gnus-summary-first-unread-subject ()
6001 "Place the point on the subject line of the first unread article.
6002 Return nil if there are no unread articles."
6005 (when (gnus-summary-first-subject t)
6006 (gnus-summary-show-thread)
6007 (gnus-summary-first-subject t))
6008 (gnus-summary-position-point)))
6010 (defun gnus-summary-first-article ()
6011 "Select the first article.
6012 Return nil if there are no articles."
6015 (when (gnus-summary-first-subject)
6016 (gnus-summary-show-thread)
6017 (gnus-summary-first-subject)
6018 (gnus-summary-display-article (gnus-summary-article-number)))
6019 (gnus-summary-position-point)))
6021 (defun gnus-summary-best-unread-article ()
6022 "Select the unread article with the highest score."
6024 (let ((best -1000000)
6025 (data gnus-newsgroup-data)
6028 (and (gnus-data-unread-p (car data))
6030 (gnus-summary-article-score (gnus-data-number (car data))))
6033 article (gnus-data-number (car data))))
6034 (setq data (cdr data)))
6037 (gnus-summary-goto-article article)
6038 (error "No unread articles"))
6039 (gnus-summary-position-point))))
6041 (defun gnus-summary-last-subject ()
6042 "Go to the last displayed subject line in the group."
6043 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6045 (gnus-summary-goto-subject article))))
6047 (defun gnus-summary-goto-article (article &optional all-headers force)
6048 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6049 If ALL-HEADERS is non-nil, no header lines are hidden.
6050 If FORCE, go to the article even if it isn't displayed. If FORCE
6051 is a number, it is the line the article is to be displayed on."
6055 "Article number or Message-ID: "
6056 (mapcar (lambda (number) (list (int-to-string number)))
6057 gnus-newsgroup-limit))
6061 (if (and (stringp article)
6062 (string-match "@" article))
6063 (gnus-summary-refer-article article)
6064 (when (stringp article)
6065 (setq article (string-to-number article)))
6066 (if (gnus-summary-goto-subject article force)
6067 (gnus-summary-display-article article all-headers)
6068 (gnus-message 4 "Couldn't go to article %s" article) nil))
6069 (gnus-summary-position-point)))
6071 (defun gnus-summary-goto-last-article ()
6072 "Go to the previously read article."
6075 (when gnus-last-article
6076 (gnus-summary-goto-article gnus-last-article nil t))
6077 (gnus-summary-position-point)))
6079 (defun gnus-summary-pop-article (number)
6080 "Pop one article off the history and go to the previous.
6081 NUMBER articles will be popped off."
6084 (setq gnus-newsgroup-history
6085 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6087 (gnus-summary-goto-article (car to) nil t)
6088 (error "Article history empty")))
6089 (gnus-summary-position-point))
6091 ;; Summary commands and functions for limiting the summary buffer.
6093 (defun gnus-summary-limit-to-articles (n)
6094 "Limit the summary buffer to the next N articles.
6095 If not given a prefix, use the process marked articles instead."
6098 (let ((articles (gnus-summary-work-articles n)))
6099 (setq gnus-newsgroup-processable nil)
6100 (gnus-summary-limit articles))
6101 (gnus-summary-position-point)))
6103 (defun gnus-summary-pop-limit (&optional total)
6104 "Restore the previous limit.
6105 If given a prefix, remove all limits."
6108 (setq gnus-newsgroup-limits
6109 (list (mapcar (lambda (h) (mail-header-number h))
6110 gnus-newsgroup-headers))))
6111 (unless gnus-newsgroup-limits
6112 (error "No limit to pop"))
6114 (gnus-summary-limit nil 'pop)
6115 (gnus-summary-position-point)))
6117 (defun gnus-summary-limit-to-subject (subject &optional header)
6118 "Limit the summary buffer to articles that have subjects that match a regexp."
6119 (interactive "sLimit to subject (regexp): ")
6121 (setq header "subject"))
6122 (when (not (equal "" subject))
6124 (let ((articles (gnus-summary-find-matching
6125 (or header "subject") subject 'all)))
6127 (error "Found no matches for \"%s\"" subject))
6128 (gnus-summary-limit articles))
6129 (gnus-summary-position-point))))
6131 (defun gnus-summary-limit-to-author (from)
6132 "Limit the summary buffer to articles that have authors that match a regexp."
6133 (interactive "sLimit to author (regexp): ")
6134 (gnus-summary-limit-to-subject from "from"))
6136 (defun gnus-summary-limit-to-age (age &optional younger-p)
6137 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6138 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6139 articles that are younger than AGE days."
6140 (interactive "nTime in days: \nP")
6142 (let ((data gnus-newsgroup-data)
6143 (cutoff (days-to-time age))
6144 articles d date is-younger)
6145 (while (setq d (pop data))
6146 (when (and (vectorp (gnus-data-header d))
6147 (setq date (mail-header-date (gnus-data-header d))))
6148 (setq is-younger (time-less-p
6149 (time-since (date-to-time date))
6154 (push (gnus-data-number d) articles))))
6155 (gnus-summary-limit (nreverse articles)))
6156 (gnus-summary-position-point)))
6158 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6160 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6162 (defun gnus-summary-limit-to-unread (&optional all)
6163 "Limit the summary buffer to articles that are not marked as read.
6164 If ALL is non-nil, limit strictly to unread articles."
6167 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6168 (gnus-summary-limit-to-marks
6169 ;; Concat all the marks that say that an article is read and have
6171 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6172 gnus-killed-mark gnus-kill-file-mark
6173 gnus-low-score-mark gnus-expirable-mark
6174 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6175 gnus-duplicate-mark gnus-souped-mark)
6178 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6179 (make-obsolete 'gnus-summary-delete-marked-with
6180 'gnus-summary-limit-exlude-marks)
6182 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6183 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6184 If REVERSE, limit the summary buffer to articles that are marked
6185 with MARKS. MARKS can either be a string of marks or a list of marks.
6186 Returns how many articles were removed."
6187 (interactive "sMarks: ")
6188 (gnus-summary-limit-to-marks marks t))
6190 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6191 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6192 If REVERSE (the prefix), limit the summary buffer to articles that are
6193 not marked with MARKS. MARKS can either be a string of marks or a
6195 Returns how many articles were removed."
6196 (interactive "sMarks: \nP")
6198 (let ((data gnus-newsgroup-data)
6199 (marks (if (listp marks) marks
6200 (append marks nil))) ; Transform to list.
6203 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6204 (memq (gnus-data-mark (car data)) marks))
6205 (push (gnus-data-number (car data)) articles))
6206 (setq data (cdr data)))
6207 (gnus-summary-limit articles))
6208 (gnus-summary-position-point)))
6210 (defun gnus-summary-limit-to-score (&optional score)
6211 "Limit to articles with score at or above SCORE."
6213 (setq score (if score
6214 (prefix-numeric-value score)
6215 (or gnus-summary-default-score 0)))
6216 (let ((data gnus-newsgroup-data)
6219 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6221 (push (gnus-data-number (car data)) articles))
6222 (setq data (cdr data)))
6224 (gnus-summary-limit articles)
6225 (gnus-summary-position-point))))
6227 (defun gnus-summary-limit-include-thread (id)
6228 "Display all the hidden articles that in the current thread."
6229 (interactive (list (mail-header-id (gnus-summary-article-header))))
6230 (let ((articles (gnus-articles-in-thread
6231 (gnus-id-to-thread (gnus-root-id id)))))
6233 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6234 (gnus-summary-position-point))))
6236 (defun gnus-summary-limit-include-dormant ()
6237 "Display all the hidden articles that are marked as dormant.
6238 Note that this command only works on a subset of the articles currently
6239 fetched for this group."
6241 (unless gnus-newsgroup-dormant
6242 (error "There are no dormant articles in this group"))
6244 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6245 (gnus-summary-position-point)))
6247 (defun gnus-summary-limit-exclude-dormant ()
6248 "Hide all dormant articles."
6251 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6252 (gnus-summary-position-point)))
6254 (defun gnus-summary-limit-exclude-childless-dormant ()
6255 "Hide all dormant articles that have no children."
6257 (let ((data (gnus-data-list t))
6258 articles d children)
6259 ;; Find all articles that are either not dormant or have
6261 (while (setq d (pop data))
6262 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6264 (gnus-article-children (gnus-data-number d)))
6267 (when (memq (car children) articles)
6272 (push (gnus-data-number d) articles)))
6275 (gnus-summary-limit articles)
6276 (gnus-summary-position-point))))
6278 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6279 "Mark all unread excluded articles as read.
6280 If ALL, mark even excluded ticked and dormants as read."
6282 (let ((articles (gnus-sorted-complement
6284 (mapcar (lambda (h) (mail-header-number h))
6285 gnus-newsgroup-headers)
6287 (sort gnus-newsgroup-limit '<)))
6289 (setq gnus-newsgroup-unreads
6290 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6292 (setq gnus-newsgroup-dormant nil
6293 gnus-newsgroup-marked nil
6294 gnus-newsgroup-reads
6296 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6297 gnus-newsgroup-reads))
6298 (while (setq article (pop articles))
6299 (unless (or (memq article gnus-newsgroup-dormant)
6300 (memq article gnus-newsgroup-marked))
6301 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6303 (defun gnus-summary-limit (articles &optional pop)
6305 ;; We pop the previous limit off the stack and use that.
6306 (setq articles (car gnus-newsgroup-limits)
6307 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6308 ;; We use the new limit, so we push the old limit on the stack.
6309 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6311 (setq gnus-newsgroup-limit articles)
6312 (let ((total (length gnus-newsgroup-data))
6313 (data (gnus-data-find-list (gnus-summary-article-number)))
6314 (gnus-summary-mark-below nil) ; Inhibit this.
6316 ;; This will do all the work of generating the new summary buffer
6317 ;; according to the new limit.
6318 (gnus-summary-prepare)
6319 ;; Hide any threads, possibly.
6320 (and gnus-show-threads
6321 gnus-thread-hide-subtree
6322 (gnus-summary-hide-all-threads))
6323 ;; Try to return to the article you were at, or one in the
6326 ;; We try to find some article after the current one.
6328 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6331 (setq data (cdr data))))
6333 ;; If there is no data, that means that we were after the last
6334 ;; article. The same goes when we can't find any articles
6335 ;; after the current one.
6336 (goto-char (point-max))
6337 (gnus-summary-find-prev))
6338 (gnus-set-mode-line 'summary)
6339 ;; We return how many articles were removed from the summary
6340 ;; buffer as a result of the new limit.
6341 (- total (length gnus-newsgroup-data))))
6343 (defsubst gnus-invisible-cut-children (threads)
6346 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6351 (defsubst gnus-cut-thread (thread)
6352 "Go forwards in the thread until we find an article that we want to display."
6353 (when (or (eq gnus-fetch-old-headers 'some)
6354 (eq gnus-fetch-old-headers 'invisible)
6355 (eq gnus-build-sparse-threads 'some)
6356 (eq gnus-build-sparse-threads 'more))
6357 ;; Deal with old-fetched headers and sparse threads.
6361 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6362 (gnus-summary-article-ancient-p
6363 (mail-header-number (car thread))))
6364 (if (or (<= (length (cdr thread)) 1)
6365 (eq gnus-fetch-old-headers 'invisible))
6366 (setq gnus-newsgroup-limit
6367 (delq (mail-header-number (car thread))
6368 gnus-newsgroup-limit)
6369 thread (cadr thread))
6370 (when (gnus-invisible-cut-children (cdr thread))
6371 (let ((th (cdr thread)))
6373 (if (memq (mail-header-number (caar th))
6374 gnus-newsgroup-limit)
6375 (setq thread (car th)
6377 (setq th (cdr th))))))))))
6380 (defun gnus-cut-threads (threads)
6381 "Cut off all uninteresting articles from the beginning of threads."
6382 (when (or (eq gnus-fetch-old-headers 'some)
6383 (eq gnus-fetch-old-headers 'invisible)
6384 (eq gnus-build-sparse-threads 'some)
6385 (eq gnus-build-sparse-threads 'more))
6388 (setcar th (gnus-cut-thread (car th)))
6389 (setq th (cdr th)))))
6390 ;; Remove nixed out threads.
6393 (defun gnus-summary-initial-limit (&optional show-if-empty)
6394 "Figure out what the initial limit is supposed to be on group entry.
6395 This entails weeding out unwanted dormants, low-scored articles,
6396 fetch-old-headers verbiage, and so on."
6397 ;; Most groups have nothing to remove.
6398 (if (or gnus-inhibit-limiting
6399 (and (null gnus-newsgroup-dormant)
6400 (not (eq gnus-fetch-old-headers 'some))
6401 (not (eq gnus-fetch-old-headers 'invisible))
6402 (null gnus-summary-expunge-below)
6403 (not (eq gnus-build-sparse-threads 'some))
6404 (not (eq gnus-build-sparse-threads 'more))
6405 (null gnus-thread-expunge-below)
6406 (not gnus-use-nocem)))
6408 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6409 (setq gnus-newsgroup-limit nil)
6412 (unless (car (symbol-value node))
6413 ;; These threads have no parents -- they are roots.
6414 (let ((nodes (cdr (symbol-value node)))
6417 (if (and gnus-thread-expunge-below
6418 (< (gnus-thread-total-score (car nodes))
6419 gnus-thread-expunge-below))
6420 (gnus-expunge-thread (pop nodes))
6421 (setq thread (pop nodes))
6422 (gnus-summary-limit-children thread))))))
6423 gnus-newsgroup-dependencies)
6424 ;; If this limitation resulted in an empty group, we might
6425 ;; pop the previous limit and use it instead.
6426 (when (and (not gnus-newsgroup-limit)
6428 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6429 gnus-newsgroup-limit))
6431 (defun gnus-summary-limit-children (thread)
6432 "Return 1 if this subthread is visible and 0 if it is not."
6433 ;; First we get the number of visible children to this thread. This
6434 ;; is done by recursing down the thread using this function, so this
6435 ;; will really go down to a leaf article first, before slowly
6436 ;; working its way up towards the root.
6440 (apply '+ (mapcar 'gnus-summary-limit-children
6443 (number (mail-header-number (car thread)))
6446 (not (memq number gnus-newsgroup-marked))
6448 ;; If this article is dormant and has absolutely no visible
6449 ;; children, then this article isn't visible.
6450 (and (memq number gnus-newsgroup-dormant)
6452 ;; If this is "fetch-old-headered" and there is no
6453 ;; visible children, then we don't want this article.
6454 (and (eq gnus-fetch-old-headers 'some)
6455 (gnus-summary-article-ancient-p number)
6457 ;; If this is "fetch-old-headered" and `invisible', then
6458 ;; we don't want this article.
6459 (and (eq gnus-fetch-old-headers 'invisible)
6460 (gnus-summary-article-ancient-p number))
6461 ;; If this is a sparsely inserted article with no children,
6462 ;; we don't want it.
6463 (and (eq gnus-build-sparse-threads 'some)
6464 (gnus-summary-article-sparse-p number)
6466 ;; If we use expunging, and this article is really
6467 ;; low-scored, then we don't want this article.
6468 (when (and gnus-summary-expunge-below
6470 (or (cdr (assq number gnus-newsgroup-scored))
6471 gnus-summary-default-score))
6472 gnus-summary-expunge-below))
6473 ;; We increase the expunge-tally here, but that has
6474 ;; nothing to do with the limits, really.
6475 (incf gnus-newsgroup-expunged-tally)
6476 ;; We also mark as read here, if that's wanted.
6477 (when (and gnus-summary-mark-below
6478 (< score gnus-summary-mark-below))
6479 (setq gnus-newsgroup-unreads
6480 (delq number gnus-newsgroup-unreads))
6481 (if gnus-newsgroup-auto-expire
6482 (push number gnus-newsgroup-expirable)
6483 (push (cons number gnus-low-score-mark)
6484 gnus-newsgroup-reads)))
6486 ;; Check NoCeM things.
6487 (if (and gnus-use-nocem
6488 (gnus-nocem-unwanted-article-p
6489 (mail-header-id (car thread))))
6491 (setq gnus-newsgroup-unreads
6492 (delq number gnus-newsgroup-unreads))
6494 ;; Nope, invisible article.
6496 ;; Ok, this article is to be visible, so we add it to the limit
6498 (push number gnus-newsgroup-limit)
6501 (defun gnus-expunge-thread (thread)
6502 "Mark all articles in THREAD as read."
6503 (let* ((number (mail-header-number (car thread))))
6504 (incf gnus-newsgroup-expunged-tally)
6505 ;; We also mark as read here, if that's wanted.
6506 (setq gnus-newsgroup-unreads
6507 (delq number gnus-newsgroup-unreads))
6508 (if gnus-newsgroup-auto-expire
6509 (push number gnus-newsgroup-expirable)
6510 (push (cons number gnus-low-score-mark)
6511 gnus-newsgroup-reads)))
6512 ;; Go recursively through all subthreads.
6513 (mapcar 'gnus-expunge-thread (cdr thread)))
6515 ;; Summary article oriented commands
6517 (defun gnus-summary-refer-parent-article (n)
6518 "Refer parent article N times.
6519 If N is negative, go to ancestor -N instead.
6520 The difference between N and the number of articles fetched is returned."
6524 (when (not (natnump n))
6529 (setq header (gnus-summary-article-header))
6530 (if (and (eq (mail-header-number header)
6531 (cdr gnus-article-current))
6532 (equal gnus-newsgroup-name
6533 (car gnus-article-current)))
6534 ;; If we try to find the parent of the currently
6535 ;; displayed article, then we take a look at the actual
6536 ;; References header, since this is slightly more
6537 ;; reliable than the References field we got from the
6540 (set-buffer gnus-original-article-buffer)
6541 (nnheader-narrow-to-headers)
6542 (unless (setq ref (message-fetch-field "references"))
6543 (setq ref (message-fetch-field "in-reply-to")))
6546 ;; It's not the current article, so we take a bet on
6547 ;; the value we got from the server.
6548 (mail-header-references header)))
6550 (not (equal ref "")))
6551 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6552 (gnus-message 1 "Couldn't find parent"))
6553 (gnus-message 1 "No references in article %d"
6554 (gnus-summary-article-number))
6557 (gnus-summary-position-point)
6560 (defun gnus-summary-refer-references ()
6561 "Fetch all articles mentioned in the References header.
6562 Return the number of articles fetched."
6564 (let ((ref (mail-header-references (gnus-summary-article-header)))
6565 (current (gnus-summary-article-number))
6569 (error "No References in the current article")
6570 ;; For each Message-ID in the References header...
6571 (while (string-match "<[^>]*>" ref)
6573 ;; ... fetch that article.
6574 (gnus-summary-refer-article
6575 (prog1 (match-string 0 ref)
6576 (setq ref (substring ref (match-end 0))))))
6577 (gnus-summary-goto-subject current)
6578 (gnus-summary-position-point)
6581 (defun gnus-summary-refer-thread (&optional limit)
6582 "Fetch all articles in the current thread.
6583 If LIMIT (the numerical prefix), fetch that many old headers instead
6584 of what's specified by the `gnus-refer-thread-limit' variable."
6586 (let ((id (mail-header-id (gnus-summary-article-header)))
6587 (limit (if limit (prefix-numeric-value limit)
6588 gnus-refer-thread-limit)))
6589 ;; We want to fetch LIMIT *old* headers, but we also have to
6590 ;; re-fetch all the headers in the current buffer, because many of
6591 ;; them may be undisplayed. So we adjust LIMIT.
6592 (when (numberp limit)
6593 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6594 (unless (eq gnus-fetch-old-headers 'invisible)
6595 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6596 ;; Retrieve the headers and read them in.
6597 (if (eq (gnus-retrieve-headers
6598 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6600 (gnus-build-all-threads)
6601 (error "Can't fetch thread from backends that don't support NOV"))
6602 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6603 (gnus-summary-limit-include-thread id)))
6605 (defun gnus-summary-refer-article (message-id &optional arg)
6606 "Fetch an article specified by MESSAGE-ID.
6607 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6608 or `gnus-select-method', no matter what backend the article comes from."
6609 (interactive "sMessage-ID: \nP")
6610 (when (and (stringp message-id)
6611 (not (zerop (length message-id))))
6612 ;; Construct the correct Message-ID if necessary.
6613 ;; Suggested by tale@pawl.rpi.edu.
6614 (unless (string-match "^<" message-id)
6615 (setq message-id (concat "<" message-id)))
6616 (unless (string-match ">$" message-id)
6617 (setq message-id (concat message-id ">")))
6618 (let* ((header (gnus-id-to-header message-id))
6620 (gnus-summary-article-sparse-p
6621 (mail-header-number header))
6622 (memq (mail-header-number header)
6623 gnus-newsgroup-limit))))
6625 ;; If the article is present in the buffer we just go to it.
6627 (or (not (gnus-summary-article-sparse-p
6628 (mail-header-number header)))
6631 (gnus-summary-goto-article
6632 (mail-header-number header) nil t)
6634 (gnus-summary-update-article (mail-header-number header)))))
6636 ;; We fetch the article
6637 (let ((gnus-override-method
6638 (cond ((gnus-news-group-p gnus-newsgroup-name)
6639 gnus-refer-article-method)
6641 (or gnus-refer-article-method gnus-select-method))
6644 ;; Start the special refer-article method, if necessary.
6645 (when (and gnus-refer-article-method
6646 (gnus-news-group-p gnus-newsgroup-name))
6647 (gnus-check-server gnus-refer-article-method))
6648 ;; Fetch the header, and display the article.
6649 (if (setq number (gnus-summary-insert-subject message-id))
6650 (gnus-summary-select-article nil nil nil number)
6651 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6653 (defun gnus-summary-edit-parameters ()
6654 "Edit the group parameters of the current group."
6656 (gnus-group-edit-group gnus-newsgroup-name 'params))
6658 (defun gnus-summary-customize-parameters ()
6659 "Customize the group parameters of the current group."
6661 (gnus-group-customize gnus-newsgroup-name))
6663 (defun gnus-summary-enter-digest-group (&optional force)
6664 "Enter an nndoc group based on the current article.
6665 If FORCE, force a digest interpretation. If not, try
6666 to guess what the document format is."
6668 (let ((conf gnus-current-window-configuration))
6670 (gnus-summary-select-article))
6671 (setq gnus-current-window-configuration conf)
6672 (let* ((name (format "%s-%d"
6673 (gnus-group-prefixed-name
6674 gnus-newsgroup-name (list 'nndoc ""))
6676 (set-buffer gnus-summary-buffer)
6677 gnus-current-article)))
6678 (ogroup gnus-newsgroup-name)
6679 (params (append (gnus-info-params (gnus-get-info ogroup))
6680 (list (cons 'to-group ogroup))
6681 (list (cons 'save-article-group ogroup))))
6682 (case-fold-search t)
6683 (buf (current-buffer))
6686 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6687 (insert-buffer-substring gnus-original-article-buffer)
6688 ;; Remove lines that may lead nndoc to misinterpret the
6691 (goto-char (point-min))
6692 (or (search-forward "\n\n" nil t) (point)))
6693 (goto-char (point-min))
6694 (delete-matching-lines "^\\(Path\\):\\|^From ")
6697 (if (gnus-group-read-ephemeral-group
6698 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6700 ,(if force 'digest 'guess))) t)
6701 ;; Make all postings to this group go to the parent group.
6702 (nconc (gnus-info-params (gnus-get-info name))
6704 ;; Couldn't select this doc group.
6705 (switch-to-buffer buf)
6706 (gnus-set-global-variables)
6707 (gnus-configure-windows 'summary)
6708 (gnus-message 3 "Article couldn't be entered?"))
6709 (kill-buffer dig)))))
6711 (defun gnus-summary-read-document (n)
6712 "Open a new group based on the current article(s).
6713 This will allow you to read digests and other similar
6714 documents as newsgroups.
6715 Obeys the standard process/prefix convention."
6717 (let* ((articles (gnus-summary-work-articles n))
6718 (ogroup gnus-newsgroup-name)
6719 (params (append (gnus-info-params (gnus-get-info ogroup))
6720 (list (cons 'to-group ogroup))))
6721 article group egroup groups vgroup)
6722 (while (setq article (pop articles))
6723 (setq group (format "%s-%d" gnus-newsgroup-name article))
6724 (gnus-summary-remove-process-mark article)
6725 (when (gnus-summary-display-article article)
6728 (insert-buffer-substring gnus-original-article-buffer)
6729 ;; Remove some headers that may lead nndoc to make
6731 (message-narrow-to-head)
6732 (goto-char (point-min))
6733 (delete-matching-lines "^\\(Path\\):\\|^From ")
6736 (gnus-group-read-ephemeral-group
6737 group `(nndoc ,group (nndoc-address ,(current-buffer))
6738 (nndoc-article-type guess))
6741 ;; Make all postings to this group go to the parent group.
6742 (nconc (gnus-info-params (gnus-get-info egroup))
6744 (push egroup groups))
6745 ;; Couldn't select this doc group.
6746 (gnus-error 3 "Article couldn't be entered"))))))
6747 ;; Now we have selected all the documents.
6750 (error "None of the articles could be interpreted as documents"))
6751 ((gnus-group-read-ephemeral-group
6752 (setq vgroup (format
6753 "nnvirtual:%s-%s" gnus-newsgroup-name
6754 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6755 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6757 (cons (current-buffer) 'summary)))
6759 (error "Couldn't select virtual nndoc group")))))
6761 (defun gnus-summary-isearch-article (&optional regexp-p)
6762 "Do incremental search forward on the current article.
6763 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6765 (gnus-summary-select-article)
6766 (gnus-configure-windows 'article)
6767 (gnus-eval-in-buffer-window gnus-article-buffer
6770 (isearch-forward regexp-p))))
6772 (defun gnus-summary-search-article-forward (regexp &optional backward)
6773 "Search for an article containing REGEXP forward.
6774 If BACKWARD, search backward instead."
6777 (format "Search article %s (regexp%s): "
6778 (if current-prefix-arg "backward" "forward")
6779 (if gnus-last-search-regexp
6780 (concat ", default " gnus-last-search-regexp)
6782 current-prefix-arg))
6783 (if (string-equal regexp "")
6784 (setq regexp (or gnus-last-search-regexp ""))
6785 (setq gnus-last-search-regexp regexp))
6786 (if (gnus-summary-search-article regexp backward)
6787 (gnus-summary-show-thread)
6788 (error "Search failed: \"%s\"" regexp)))
6790 (defun gnus-summary-search-article-backward (regexp)
6791 "Search for an article containing REGEXP backward."
6794 (format "Search article backward (regexp%s): "
6795 (if gnus-last-search-regexp
6796 (concat ", default " gnus-last-search-regexp)
6798 (gnus-summary-search-article-forward regexp 'backward))
6800 (defun gnus-summary-search-article (regexp &optional backward)
6801 "Search for an article containing REGEXP.
6802 Optional argument BACKWARD means do search for backward.
6803 `gnus-select-article-hook' is not called during the search."
6804 ;; We have to require this here to make sure that the following
6805 ;; dynamic binding isn't shadowed by autoloading.
6806 (require 'gnus-async)
6808 (let ((gnus-select-article-hook nil) ;Disable hook.
6809 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6810 (gnus-use-article-prefetch nil)
6811 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6812 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6813 (sum (current-buffer))
6814 (gnus-display-mime-function nil)
6817 (gnus-save-hidden-threads
6818 (gnus-summary-select-article)
6819 (set-buffer gnus-article-buffer)
6823 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6825 (re-search-backward regexp nil t)
6826 (re-search-forward regexp nil t))
6827 ;; We found the regexp.
6832 (get-buffer-window (current-buffer))
6836 (setq point (point)))
6837 ;; We didn't find it, so we go to the next article.
6840 (while (eq found 'not)
6841 (if (not (if backward (gnus-summary-find-prev)
6842 (gnus-summary-find-next)))
6843 ;; No more articles.
6845 ;; Select the next article and adjust point.
6846 (unless (gnus-summary-article-sparse-p
6847 (gnus-summary-article-number))
6849 (gnus-summary-select-article)
6850 (set-buffer gnus-article-buffer)
6852 (goto-char (if backward (point-max) (point-min))))))))
6853 (gnus-message 7 ""))
6854 ;; Return whether we found the regexp.
6855 (when (eq found 'found)
6857 (gnus-summary-show-thread)
6858 (gnus-summary-goto-subject gnus-current-article)
6859 (gnus-summary-position-point)
6862 (defun gnus-summary-find-matching (header regexp &optional backward unread
6864 "Return a list of all articles that match REGEXP on HEADER.
6865 The search stars on the current article and goes forwards unless
6866 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6867 If UNREAD is non-nil, only unread articles will
6868 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6869 in the comparisons."
6870 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6871 (gnus-data-find-list
6872 (gnus-summary-article-number) (gnus-data-list backward))))
6873 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6874 (case-fold-search (not not-case-fold))
6876 (unless (fboundp (intern (concat "mail-header-" header)))
6877 (error "%s is not a valid header" header))
6880 (and (or (not unread) ; We want all articles...
6881 (gnus-data-unread-p d)) ; Or just unreads.
6882 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6883 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6884 (push (gnus-data-number d) articles)) ; Success!
6885 (setq data (cdr data)))
6886 (nreverse articles)))
6888 (defun gnus-summary-execute-command (header regexp command &optional backward)
6889 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6890 If HEADER is an empty string (or nil), the match is done on the entire
6891 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6893 (list (let ((completion-ignore-case t))
6896 (mapcar (lambda (string) (list string))
6897 '("Number" "Subject" "From" "Lines" "Date"
6898 "Message-ID" "Xref" "References" "Body"))
6899 nil 'require-match))
6900 (read-string "Regexp: ")
6901 (read-key-sequence "Command: ")
6902 current-prefix-arg))
6903 (when (equal header "Body")
6905 ;; Hidden thread subtrees must be searched as well.
6906 (gnus-summary-show-all-threads)
6907 ;; We don't want to change current point nor window configuration.
6909 (save-window-excursion
6910 (gnus-message 6 "Executing %s..." (key-description command))
6911 ;; We'd like to execute COMMAND interactively so as to give arguments.
6912 (gnus-execute header regexp
6913 `(call-interactively ',(key-binding command))
6915 (gnus-message 6 "Executing %s...done" (key-description command)))))
6917 (defun gnus-summary-beginning-of-article ()
6918 "Scroll the article back to the beginning."
6920 (gnus-summary-select-article)
6921 (gnus-configure-windows 'article)
6922 (gnus-eval-in-buffer-window gnus-article-buffer
6924 (goto-char (point-min))
6925 (when gnus-page-broken
6926 (gnus-narrow-to-page))))
6928 (defun gnus-summary-end-of-article ()
6929 "Scroll to the end of the article."
6931 (gnus-summary-select-article)
6932 (gnus-configure-windows 'article)
6933 (gnus-eval-in-buffer-window gnus-article-buffer
6935 (goto-char (point-max))
6937 (when gnus-page-broken
6938 (gnus-narrow-to-page))))
6940 (defun gnus-summary-print-article (&optional filename n)
6941 "Generate and print a PostScript image of the N next (mail) articles.
6943 If N is negative, print the N previous articles. If N is nil and articles
6944 have been marked with the process mark, print these instead.
6946 If the optional first argument FILENAME is nil, send the image to the
6947 printer. If FILENAME is a string, save the PostScript image in a file with
6948 that name. If FILENAME is a number, prompt the user for the name of the file
6950 (interactive (list (ps-print-preprint current-prefix-arg)
6951 current-prefix-arg))
6952 (dolist (article (gnus-summary-work-articles n))
6953 (gnus-summary-select-article nil nil 'pseudo article)
6954 (gnus-eval-in-buffer-window gnus-article-buffer
6955 (let ((buffer (generate-new-buffer " *print*")))
6958 (copy-to-buffer buffer (point-min) (point-max))
6960 (gnus-article-delete-invisible-text)
6961 (let ((ps-left-header
6964 (mail-header-subject gnus-current-headers) ")")
6966 (mail-header-from gnus-current-headers) ")")))
6969 "/pagenumberstring load"
6971 (mail-header-date gnus-current-headers) ")"))))
6972 (gnus-run-hooks 'gnus-ps-print-hook)
6974 (ps-print-buffer-with-faces filename))))
6975 (kill-buffer buffer))))))
6977 (defun gnus-summary-show-article (&optional arg)
6978 "Force re-fetching of the current article.
6979 If ARG (the prefix) is non-nil, show the raw article without any
6980 article massaging functions being run."
6983 ;; Select the article the normal way.
6984 (gnus-summary-select-article nil 'force)
6985 ;; We have to require this here to make sure that the following
6986 ;; dynamic binding isn't shadowed by autoloading.
6987 (require 'gnus-async)
6989 ;; Bind the article treatment functions to nil.
6990 (let ((gnus-have-all-headers t)
6991 gnus-article-prepare-hook
6992 gnus-article-decode-hook
6993 gnus-display-mime-function
6996 ;; Destroy any MIME parts.
6997 (when (gnus-buffer-live-p gnus-article-buffer)
6999 (set-buffer gnus-article-buffer)
7000 (mm-destroy-parts gnus-article-mime-handles)))
7001 (gnus-summary-select-article nil 'force)))
7002 (gnus-summary-goto-subject gnus-current-article)
7003 (gnus-summary-position-point))
7005 (defun gnus-summary-verbose-headers (&optional arg)
7006 "Toggle permanent full header display.
7007 If ARG is a positive number, turn header display on.
7008 If ARG is a negative number, turn header display off."
7010 (setq gnus-show-all-headers
7011 (cond ((or (not (numberp arg))
7013 (not gnus-show-all-headers))
7016 (gnus-summary-show-article))
7018 (defun gnus-summary-toggle-header (&optional arg)
7019 "Show the headers if they are hidden, or hide them if they are shown.
7020 If ARG is a positive number, show the entire header.
7021 If ARG is a negative number, hide the unwanted header lines."
7024 (set-buffer gnus-article-buffer)
7026 (let* ((buffer-read-only nil)
7027 (inhibit-point-motion-hooks t)
7030 (message-narrow-to-head)
7031 (setq hidden (gnus-article-hidden-text-p 'headers)))
7032 (goto-char (point-min))
7033 (when (search-forward "\n\n" nil t)
7034 (delete-region (point-min) (1- (point))))
7035 (goto-char (point-min))
7037 (set-buffer gnus-original-article-buffer)
7038 (goto-char (point-min))
7039 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7040 (insert-buffer-substring gnus-original-article-buffer 1 e)
7042 (narrow-to-region (point-min) (point))
7043 (article-decode-encoded-words)
7045 (and (numberp arg) (< arg 0)))
7046 (let ((gnus-treat-hide-headers nil)
7047 (gnus-treat-hide-boring-headers nil))
7048 (gnus-treat-article 'head))
7049 (gnus-treat-article 'head)))))))
7051 (defun gnus-summary-show-all-headers ()
7052 "Make all header lines visible."
7054 (gnus-article-show-all-headers))
7056 (defun gnus-summary-caesar-message (&optional arg)
7057 "Caesar rotate the current article by 13.
7058 The numerical prefix specifies how many places to rotate each letter
7061 (gnus-summary-select-article)
7062 (let ((mail-header-separator ""))
7063 (gnus-eval-in-buffer-window gnus-article-buffer
7066 (let ((start (window-start))
7068 (message-caesar-buffer-body arg)
7069 (set-window-start (get-buffer-window (current-buffer)) start))))))
7071 (defun gnus-summary-stop-page-breaking ()
7072 "Stop page breaking in the current article."
7074 (gnus-summary-select-article)
7075 (gnus-eval-in-buffer-window gnus-article-buffer
7077 (when (gnus-visual-p 'page-marker)
7078 (let ((buffer-read-only nil))
7079 (gnus-remove-text-with-property 'gnus-prev)
7080 (gnus-remove-text-with-property 'gnus-next))
7081 (setq gnus-page-broken nil))))
7083 (defun gnus-summary-move-article (&optional n to-newsgroup
7084 select-method action)
7085 "Move the current article to a different newsgroup.
7086 If N is a positive number, move the N next articles.
7087 If N is a negative number, move the N previous articles.
7088 If N is nil and any articles have been marked with the process mark,
7089 move those articles instead.
7090 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7091 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7092 re-spool using this method.
7094 For this function to work, both the current newsgroup and the
7095 newsgroup that you want to move to have to support the `request-move'
7096 and `request-accept' functions."
7099 (setq action 'move))
7100 ;; Disable marking as read.
7101 (let (gnus-mark-article-hook)
7102 (save-window-excursion
7103 (gnus-summary-select-article)))
7104 ;; Check whether the source group supports the required functions.
7105 (cond ((and (eq action 'move)
7106 (not (gnus-check-backend-function
7107 'request-move-article gnus-newsgroup-name)))
7108 (error "The current group does not support article moving"))
7109 ((and (eq action 'crosspost)
7110 (not (gnus-check-backend-function
7111 'request-replace-article gnus-newsgroup-name)))
7112 (error "The current group does not support article editing")))
7113 (let ((articles (gnus-summary-work-articles n))
7114 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7115 (names '((move "Move" "Moving")
7116 (copy "Copy" "Copying")
7117 (crosspost "Crosspost" "Crossposting")))
7118 (copy-buf (save-excursion
7119 (nnheader-set-temp-buffer " *copy article*")))
7120 art-group to-method new-xref article to-groups)
7121 (unless (assq action names)
7122 (error "Unknown action %s" action))
7123 ;; Read the newsgroup name.
7124 (when (and (not to-newsgroup)
7125 (not select-method))
7127 (gnus-read-move-group-name
7128 (cadr (assq action names))
7129 (symbol-value (intern (format "gnus-current-%s-group" action)))
7131 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7132 (setq to-method (or select-method
7133 (gnus-group-name-to-method to-newsgroup)))
7134 ;; Check the method we are to move this article to...
7135 (unless (gnus-check-backend-function
7136 'request-accept-article (car to-method))
7137 (error "%s does not support article copying" (car to-method)))
7138 (unless (gnus-check-server to-method)
7139 (error "Can't open server %s" (car to-method)))
7140 (gnus-message 6 "%s to %s: %s..."
7141 (caddr (assq action names))
7142 (or (car select-method) to-newsgroup) articles)
7144 (setq article (pop articles))
7148 ;; Move the article.
7150 ;; Remove this article from future suppression.
7151 (gnus-dup-unsuppress-article article)
7152 (gnus-request-move-article
7153 article ; Article to move
7154 gnus-newsgroup-name ; From newsgroup
7155 (nth 1 (gnus-find-method-for-group
7156 gnus-newsgroup-name)) ; Server
7157 (list 'gnus-request-accept-article
7158 to-newsgroup (list 'quote select-method)
7159 (not articles) t) ; Accept form
7160 (not articles))) ; Only save nov last time
7161 ;; Copy the article.
7164 (set-buffer copy-buf)
7165 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7166 (gnus-request-accept-article
7167 to-newsgroup select-method (not articles) t))))
7168 ;; Crosspost the article.
7169 ((eq action 'crosspost)
7170 (let ((xref (message-tokenize-header
7171 (mail-header-xref (gnus-summary-article-header article))
7173 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7176 (setq xref (list (system-name))))
7179 (mapconcat 'identity
7180 (delete "Xref:" (delete new-xref xref))
7184 (set-buffer copy-buf)
7185 ;; First put the article in the destination group.
7186 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7187 (when (consp (setq art-group
7188 (gnus-request-accept-article
7189 to-newsgroup select-method (not articles))))
7190 (setq new-xref (concat new-xref " " (car art-group)
7191 ":" (cdr art-group)))
7192 ;; Now we have the new Xrefs header, so we insert
7193 ;; it and replace the new article.
7194 (nnheader-replace-header "Xref" new-xref)
7195 (gnus-request-replace-article
7196 (cdr art-group) to-newsgroup (current-buffer))
7200 (gnus-message 1 "Couldn't %s article %s"
7201 (cadr (assq action names)) article))
7202 ((and (eq art-group 'junk)
7204 (gnus-summary-mark-article article gnus-canceled-mark)
7205 (gnus-message 4 "Deleted article %s" article))
7207 (let* ((pto-group (gnus-group-prefixed-name
7208 (car art-group) to-method))
7210 (gnus-gethash pto-group gnus-newsrc-hashtb))
7211 (info (nth 2 entry))
7212 (to-group (gnus-info-group info)))
7213 ;; Update the group that has been moved to.
7215 (memq action '(move copy)))
7216 (unless (member to-group to-groups)
7217 (push to-group to-groups))
7219 (unless (memq article gnus-newsgroup-unreads)
7221 info (gnus-add-to-range (gnus-info-read info)
7222 (list (cdr art-group)))))
7224 ;; Copy any marks over to the new group.
7225 (let ((marks gnus-article-mark-lists)
7226 (to-article (cdr art-group)))
7228 ;; See whether the article is to be put in the cache.
7229 (when gnus-use-cache
7230 (gnus-cache-possibly-enter-article
7232 (let ((header (copy-sequence
7233 (gnus-summary-article-header article))))
7234 (mail-header-set-number header to-article)
7236 (memq article gnus-newsgroup-marked)
7237 (memq article gnus-newsgroup-dormant)
7238 (memq article gnus-newsgroup-unreads)))
7240 (when (and (equal to-group gnus-newsgroup-name)
7241 (not (memq article gnus-newsgroup-unreads)))
7242 ;; Mark this article as read in this group.
7243 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7244 (setcdr (gnus-active to-group) to-article)
7245 (setcdr gnus-newsgroup-active to-article))
7248 (when (memq article (symbol-value
7249 (intern (format "gnus-newsgroup-%s"
7251 ;; If the other group is the same as this group,
7252 ;; then we have to add the mark to the list.
7253 (when (equal to-group gnus-newsgroup-name)
7254 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7257 (intern (format "gnus-newsgroup-%s"
7259 ;; Copy the marks to other group.
7260 (gnus-add-marked-articles
7261 to-group (cdar marks) (list to-article) info))
7262 (setq marks (cdr marks)))
7265 (concat "(gnus-group-set-info '"
7266 (gnus-prin1-to-string (gnus-get-info to-group))
7269 ;; Update the Xref header in this article to point to
7270 ;; the new crossposted article we have just created.
7271 (when (eq action 'crosspost)
7273 (set-buffer copy-buf)
7274 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7275 (nnheader-replace-header "Xref" new-xref)
7276 (gnus-request-replace-article
7277 article gnus-newsgroup-name (current-buffer)))))
7279 ;;;!!!Why is this necessary?
7280 (set-buffer gnus-summary-buffer)
7282 (gnus-summary-goto-subject article)
7283 (when (eq action 'move)
7284 (gnus-summary-mark-article article gnus-canceled-mark))))
7285 (gnus-summary-remove-process-mark article))
7286 ;; Re-activate all groups that have been moved to.
7289 (set-buffer gnus-group-buffer)
7290 (when (gnus-group-goto-group (car to-groups) t)
7291 (gnus-group-get-new-news-this-group 1 t))
7294 (gnus-kill-buffer copy-buf)
7295 (gnus-summary-position-point)
7296 (gnus-set-mode-line 'summary)))
7298 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7299 "Move the current article to a different newsgroup.
7300 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7301 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7302 re-spool using this method."
7304 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7306 (defun gnus-summary-crosspost-article (&optional n)
7307 "Crosspost the current article to some other group."
7309 (gnus-summary-move-article n nil nil 'crosspost))
7311 (defcustom gnus-summary-respool-default-method nil
7312 "Default method for respooling an article.
7313 If nil, use to the current newsgroup method."
7314 :type '(choice (gnus-select-method :value (nnml ""))
7316 :group 'gnus-summary-mail)
7318 (defun gnus-summary-respool-article (&optional n method)
7319 "Respool the current article.
7320 The article will be squeezed through the mail spooling process again,
7321 which means that it will be put in some mail newsgroup or other
7322 depending on `nnmail-split-methods'.
7323 If N is a positive number, respool the N next articles.
7324 If N is a negative number, respool the N previous articles.
7325 If N is nil and any articles have been marked with the process mark,
7326 respool those articles instead.
7328 Respooling can be done both from mail groups and \"real\" newsgroups.
7329 In the former case, the articles in question will be moved from the
7330 current group into whatever groups they are destined to. In the
7331 latter case, they will be copied into the relevant groups."
7333 (list current-prefix-arg
7334 (let* ((methods (gnus-methods-using 'respool))
7336 (symbol-name (or gnus-summary-respool-default-method
7337 (car (gnus-find-method-for-group
7338 gnus-newsgroup-name)))))
7340 (gnus-completing-read
7341 methname "What backend do you want to use when respooling?"
7342 methods nil t nil 'gnus-mail-method-history))
7345 ((zerop (length (setq ms (gnus-servers-using-backend
7347 (list (intern method) ""))
7351 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7352 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7355 (error "No method given for respooling"))
7356 (if (assoc (symbol-name
7357 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7358 (gnus-methods-using 'respool))
7359 (gnus-summary-move-article n nil method)
7360 (gnus-summary-copy-article n nil method)))
7362 (defun gnus-summary-import-article (file)
7363 "Import an arbitrary file into a mail newsgroup."
7364 (interactive "fImport file: ")
7365 (let ((group gnus-newsgroup-name)
7366 (now (current-time))
7368 (unless (gnus-check-backend-function 'request-accept-article group)
7369 (error "%s does not support article importing" group))
7370 (or (file-readable-p file)
7371 (not (file-regular-p file))
7372 (error "Can't read %s" file))
7374 (set-buffer (gnus-get-buffer-create " *import file*"))
7376 (insert-file-contents file)
7377 (goto-char (point-min))
7378 (unless (nnheader-article-p)
7379 ;; This doesn't look like an article, so we fudge some headers.
7380 (setq atts (file-attributes file)
7381 lines (count-lines (point-min) (point-max)))
7382 (insert "From: " (read-string "From: ") "\n"
7383 "Subject: " (read-string "Subject: ") "\n"
7384 "Date: " (message-make-date (nth 5 atts))
7386 "Message-ID: " (message-make-message-id) "\n"
7387 "Lines: " (int-to-string lines) "\n"
7388 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7389 (gnus-request-accept-article group nil t)
7390 (kill-buffer (current-buffer)))))
7392 (defun gnus-summary-article-posted-p ()
7393 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7394 This will be the case if the article has both been mailed and posted."
7396 (let ((id (mail-header-references (gnus-summary-article-header)))
7397 (gnus-override-method
7398 (or gnus-refer-article-method gnus-select-method)))
7399 (if (gnus-request-head id "")
7400 (gnus-message 2 "The current message was found on %s"
7401 gnus-override-method)
7402 (gnus-message 2 "The current message couldn't be found on %s"
7403 gnus-override-method)
7406 (defun gnus-summary-expire-articles (&optional now)
7407 "Expire all articles that are marked as expirable in the current group."
7409 (when (gnus-check-backend-function
7410 'request-expire-articles gnus-newsgroup-name)
7411 ;; This backend supports expiry.
7412 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7413 (expirable (if total
7415 ;; We need to update the info for
7416 ;; this group for `gnus-list-of-read-articles'
7417 ;; to give us the right answer.
7418 (gnus-run-hooks 'gnus-exit-group-hook)
7419 (gnus-summary-update-info)
7420 (gnus-list-of-read-articles gnus-newsgroup-name))
7421 (setq gnus-newsgroup-expirable
7422 (sort gnus-newsgroup-expirable '<))))
7423 (expiry-wait (if now 'immediate
7424 (gnus-group-find-parameter
7425 gnus-newsgroup-name 'expiry-wait)))
7428 ;; There are expirable articles in this group, so we run them
7429 ;; through the expiry process.
7430 (gnus-message 6 "Expiring articles...")
7431 (unless (gnus-check-group gnus-newsgroup-name)
7432 (error "Can't open server for %s" gnus-newsgroup-name))
7433 ;; The list of articles that weren't expired is returned.
7436 (let ((nnmail-expiry-wait-function nil)
7437 (nnmail-expiry-wait expiry-wait))
7438 (setq es (gnus-request-expire-articles
7439 expirable gnus-newsgroup-name)))
7440 (setq es (gnus-request-expire-articles
7441 expirable gnus-newsgroup-name))))
7443 (setq gnus-newsgroup-expirable es))
7444 ;; We go through the old list of expirable, and mark all
7445 ;; really expired articles as nonexistent.
7446 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7447 (let ((gnus-use-cache nil))
7449 (unless (memq (car expirable) es)
7450 (when (gnus-data-find (car expirable))
7451 (gnus-summary-mark-article
7452 (car expirable) gnus-canceled-mark)))
7453 (setq expirable (cdr expirable)))))
7454 (gnus-message 6 "Expiring articles...done")))))
7456 (defun gnus-summary-expire-articles-now ()
7457 "Expunge all expirable articles in the current group.
7458 This means that *all* articles that are marked as expirable will be
7459 deleted forever, right now."
7461 (or gnus-expert-user
7463 "Are you really, really, really sure you want to delete all these messages? ")
7465 (gnus-summary-expire-articles t))
7467 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7468 (defun gnus-summary-delete-article (&optional n)
7469 "Delete the N next (mail) articles.
7470 This command actually deletes articles. This is not a marking
7471 command. The article will disappear forever from your life, never to
7473 If N is negative, delete backwards.
7474 If N is nil and articles have been marked with the process mark,
7475 delete these instead."
7477 (unless (gnus-check-backend-function 'request-expire-articles
7478 gnus-newsgroup-name)
7479 (error "The current newsgroup does not support article deletion"))
7480 ;; Compute the list of articles to delete.
7481 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7483 (if (and gnus-novice-user
7484 (not (gnus-yes-or-no-p
7485 (format "Do you really want to delete %s forever? "
7486 (if (> (length articles) 1)
7487 (format "these %s articles" (length articles))
7490 ;; Delete the articles.
7491 (setq not-deleted (gnus-request-expire-articles
7492 articles gnus-newsgroup-name 'force))
7494 (gnus-summary-remove-process-mark (car articles))
7495 ;; The backend might not have been able to delete the article
7497 (unless (memq (car articles) not-deleted)
7498 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7499 (setq articles (cdr articles)))
7501 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7502 (gnus-summary-position-point)
7503 (gnus-set-mode-line 'summary)
7506 (defun gnus-summary-edit-article (&optional force)
7507 "Edit the current article.
7508 This will have permanent effect only in mail groups.
7509 If FORCE is non-nil, allow editing of articles even in read-only
7512 (let ((mail-parse-charset gnus-newsgroup-charset))
7514 (set-buffer gnus-summary-buffer)
7515 (gnus-set-global-variables)
7516 (when (and (not force)
7517 (gnus-group-read-only-p))
7518 (error "The current newsgroup does not support article editing"))
7519 (gnus-summary-show-article t)
7520 (gnus-article-edit-article
7522 `(lambda (no-highlight)
7523 (let ((mail-parse-charset ',gnus-newsgroup-charset))
7525 (gnus-summary-edit-article-done
7526 ,(or (mail-header-references gnus-current-headers) "")
7527 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7529 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7531 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7533 "Make edits to the current article permanent."
7535 ;; Replace the article.
7536 (let ((buf (current-buffer)))
7538 (insert-buffer-substring buf)
7539 (if (and (not read-only)
7540 (not (gnus-request-replace-article
7541 (cdr gnus-article-current) (car gnus-article-current)
7542 (current-buffer) t)))
7543 (error "Couldn't replace article")
7544 ;; Update the summary buffer.
7546 (equal (message-tokenize-header references " ")
7547 (message-tokenize-header
7548 (or (message-fetch-field "references") "") " ")))
7549 ;; We only have to update this line.
7552 (message-narrow-to-head)
7553 (let ((head (buffer-string))
7556 (insert (format "211 %d Article retrieved.\n"
7557 (cdr gnus-article-current)))
7560 (let ((nntp-server-buffer (current-buffer)))
7561 (setq header (car (gnus-get-newsgroup-headers
7563 (set-buffer gnus-summary-buffer)
7564 gnus-newsgroup-dependencies)
7567 (set-buffer gnus-summary-buffer)
7568 (gnus-data-set-header
7569 (gnus-data-find (cdr gnus-article-current))
7571 (gnus-summary-update-article-line
7572 (cdr gnus-article-current) header))))))
7574 (set-buffer (or buffer gnus-summary-buffer))
7575 (gnus-summary-update-article (cdr gnus-article-current)))
7576 ;; Prettify the article buffer again.
7577 (unless no-highlight
7579 (set-buffer gnus-article-buffer)
7580 ;;;!!! Fix this -- article should be rehighlighted.
7581 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7582 (set-buffer gnus-original-article-buffer)
7583 (gnus-request-article
7584 (cdr gnus-article-current)
7585 (car gnus-article-current) (current-buffer))))
7586 ;; Prettify the summary buffer line.
7587 (when (gnus-visual-p 'summary-highlight 'highlight)
7588 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7590 (defun gnus-summary-edit-wash (key)
7591 "Perform editing command KEY in the article buffer."
7595 (message "%s" (concat (this-command-keys) "- "))
7598 (gnus-summary-edit-article)
7599 (execute-kbd-macro (concat (this-command-keys) key))
7600 (gnus-article-edit-done))
7604 (defun gnus-summary-respool-query (&optional silent trace)
7605 "Query where the respool algorithm would put this article."
7607 (let (gnus-mark-article-hook)
7608 (gnus-summary-select-article)
7610 (set-buffer gnus-original-article-buffer)
7612 (message-narrow-to-head)
7613 (let ((groups (nnmail-article-group 'identity trace)))
7616 (message "This message would go to %s"
7617 (mapconcat 'car groups ", "))
7618 (message "This message would go to no groups"))
7621 (defun gnus-summary-respool-trace ()
7622 "Trace where the respool algorithm would put this article.
7623 Display a buffer showing all fancy splitting patterns which matched."
7625 (gnus-summary-respool-query nil t))
7627 ;; Summary marking commands.
7629 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7630 "Mark articles which has the same subject as read, and then select the next.
7631 If UNMARK is positive, remove any kind of mark.
7632 If UNMARK is negative, tick articles."
7635 (setq unmark (prefix-numeric-value unmark)))
7637 (gnus-summary-mark-same-subject
7638 (gnus-summary-article-subject) unmark)))
7639 ;; Select next unread article. If auto-select-same mode, should
7640 ;; select the first unread article.
7641 (gnus-summary-next-article t (and gnus-auto-select-same
7642 (gnus-summary-article-subject)))
7643 (gnus-message 7 "%d article%s marked as %s"
7644 count (if (= count 1) " is" "s are")
7645 (if unmark "unread" "read"))))
7647 (defun gnus-summary-kill-same-subject (&optional unmark)
7648 "Mark articles which has the same subject as read.
7649 If UNMARK is positive, remove any kind of mark.
7650 If UNMARK is negative, tick articles."
7653 (setq unmark (prefix-numeric-value unmark)))
7655 (gnus-summary-mark-same-subject
7656 (gnus-summary-article-subject) unmark)))
7657 ;; If marked as read, go to next unread subject.
7659 ;; Go to next unread subject.
7660 (gnus-summary-next-subject 1 t))
7661 (gnus-message 7 "%d articles are marked as %s"
7662 count (if unmark "unread" "read"))))
7664 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7665 "Mark articles with same SUBJECT as read, and return marked number.
7666 If optional argument UNMARK is positive, remove any kinds of marks.
7667 If optional argument UNMARK is negative, mark articles as unread instead."
7671 ((null unmark) ; Mark as read.
7674 (gnus-summary-mark-article-as-read gnus-killed-mark)
7675 (gnus-summary-show-thread) t)
7676 (gnus-summary-find-subject subject))
7677 (setq count (1+ count))))
7678 ((> unmark 0) ; Tick.
7681 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7682 (gnus-summary-show-thread) t)
7683 (gnus-summary-find-subject subject))
7684 (setq count (1+ count))))
7685 (t ; Mark as unread.
7688 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7689 (gnus-summary-show-thread) t)
7690 (gnus-summary-find-subject subject))
7691 (setq count (1+ count)))))
7692 (gnus-set-mode-line 'summary)
7693 ;; Return the number of marked articles.
7696 (defun gnus-summary-mark-as-processable (n &optional unmark)
7697 "Set the process mark on the next N articles.
7698 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7699 the process mark instead. The difference between N and the actual
7700 number of articles marked is returned."
7702 (let ((backward (< n 0))
7707 (gnus-summary-remove-process-mark
7708 (gnus-summary-article-number))
7709 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7710 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7713 (gnus-message 7 "No more articles"))
7714 (gnus-summary-recenter)
7715 (gnus-summary-position-point)
7718 (defun gnus-summary-unmark-as-processable (n)
7719 "Remove the process mark from the next N articles.
7720 If N is negative, unmark backward instead. The difference between N and
7721 the actual number of articles unmarked is returned."
7723 (gnus-summary-mark-as-processable n t))
7725 (defun gnus-summary-unmark-all-processable ()
7726 "Remove the process mark from all articles."
7729 (while gnus-newsgroup-processable
7730 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7731 (gnus-summary-position-point))
7733 (defun gnus-summary-mark-as-expirable (n)
7734 "Mark N articles forward as expirable.
7735 If N is negative, mark backward instead. The difference between N and
7736 the actual number of articles marked is returned."
7738 (gnus-summary-mark-forward n gnus-expirable-mark))
7740 (defun gnus-summary-mark-article-as-replied (article)
7741 "Mark ARTICLE replied and update the summary line."
7742 (push article gnus-newsgroup-replied)
7743 (let ((buffer-read-only nil))
7744 (when (gnus-summary-goto-subject article nil t)
7745 (gnus-summary-update-secondary-mark article))))
7747 (defun gnus-summary-set-bookmark (article)
7748 "Set a bookmark in current article."
7749 (interactive (list (gnus-summary-article-number)))
7750 (when (or (not (get-buffer gnus-article-buffer))
7751 (not gnus-current-article)
7752 (not gnus-article-current)
7753 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7754 (error "No current article selected"))
7755 ;; Remove old bookmark, if one exists.
7756 (let ((old (assq article gnus-newsgroup-bookmarks)))
7758 (setq gnus-newsgroup-bookmarks
7759 (delq old gnus-newsgroup-bookmarks))))
7760 ;; Set the new bookmark, which is on the form
7761 ;; (article-number . line-number-in-body).
7765 (set-buffer gnus-article-buffer)
7769 (goto-char (point-min))
7770 (search-forward "\n\n" nil t)
7773 gnus-newsgroup-bookmarks)
7774 (gnus-message 6 "A bookmark has been added to the current article."))
7776 (defun gnus-summary-remove-bookmark (article)
7777 "Remove the bookmark from the current article."
7778 (interactive (list (gnus-summary-article-number)))
7779 ;; Remove old bookmark, if one exists.
7780 (let ((old (assq article gnus-newsgroup-bookmarks)))
7783 (setq gnus-newsgroup-bookmarks
7784 (delq old gnus-newsgroup-bookmarks))
7785 (gnus-message 6 "Removed bookmark."))
7786 (gnus-message 6 "No bookmark in current article."))))
7788 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7789 (defun gnus-summary-mark-as-dormant (n)
7790 "Mark N articles forward as dormant.
7791 If N is negative, mark backward instead. The difference between N and
7792 the actual number of articles marked is returned."
7794 (gnus-summary-mark-forward n gnus-dormant-mark))
7796 (defun gnus-summary-set-process-mark (article)
7797 "Set the process mark on ARTICLE and update the summary line."
7798 (setq gnus-newsgroup-processable
7800 (delq article gnus-newsgroup-processable)))
7801 (when (gnus-summary-goto-subject article)
7802 (gnus-summary-show-thread)
7803 (gnus-summary-goto-subject article)
7804 (gnus-summary-update-secondary-mark article)))
7806 (defun gnus-summary-remove-process-mark (article)
7807 "Remove the process mark from ARTICLE and update the summary line."
7808 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7809 (when (gnus-summary-goto-subject article)
7810 (gnus-summary-show-thread)
7811 (gnus-summary-goto-subject article)
7812 (gnus-summary-update-secondary-mark article)))
7814 (defun gnus-summary-set-saved-mark (article)
7815 "Set the process mark on ARTICLE and update the summary line."
7816 (push article gnus-newsgroup-saved)
7817 (when (gnus-summary-goto-subject article)
7818 (gnus-summary-update-secondary-mark article)))
7820 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7821 "Mark N articles as read forwards.
7822 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7823 The difference between N and the actual number of articles marked is
7826 (gnus-summary-show-thread)
7827 (let ((backward (< n 0))
7828 (gnus-summary-goto-unread
7829 (and gnus-summary-goto-unread
7830 (not (eq gnus-summary-goto-unread 'never))
7831 (not (memq mark (list gnus-unread-mark
7832 gnus-ticked-mark gnus-dormant-mark)))))
7834 (mark (or mark gnus-del-mark)))
7836 (gnus-summary-mark-article nil mark no-expire)
7837 (zerop (gnus-summary-next-subject
7839 (and gnus-summary-goto-unread
7840 (not (eq gnus-summary-goto-unread 'never)))
7844 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7845 (gnus-summary-recenter)
7846 (gnus-summary-position-point)
7847 (gnus-set-mode-line 'summary)
7850 (defun gnus-summary-mark-article-as-read (mark)
7851 "Mark the current article quickly as read with MARK."
7852 (let ((article (gnus-summary-article-number)))
7853 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7854 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7855 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7856 (push (cons article mark) gnus-newsgroup-reads)
7857 ;; Possibly remove from cache, if that is used.
7858 (when gnus-use-cache
7859 (gnus-cache-enter-remove-article article))
7860 ;; Allow the backend to change the mark.
7861 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7862 ;; Check for auto-expiry.
7863 (when (and gnus-newsgroup-auto-expire
7864 (memq mark gnus-auto-expirable-marks))
7865 (setq mark gnus-expirable-mark)
7866 ;; Let the backend know about the mark change.
7867 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7868 (push article gnus-newsgroup-expirable))
7869 ;; Set the mark in the buffer.
7870 (gnus-summary-update-mark mark 'unread)
7873 (defun gnus-summary-mark-article-as-unread (mark)
7874 "Mark the current article quickly as unread with MARK."
7875 (let* ((article (gnus-summary-article-number))
7876 (old-mark (gnus-summary-article-mark article)))
7877 ;; Allow the backend to change the mark.
7878 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7879 (if (eq mark old-mark)
7883 (gnus-error 1 "Can't mark negative article numbers")
7885 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7886 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7887 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7888 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7889 (cond ((= mark gnus-ticked-mark)
7890 (push article gnus-newsgroup-marked))
7891 ((= mark gnus-dormant-mark)
7892 (push article gnus-newsgroup-dormant))
7894 (push article gnus-newsgroup-unreads)))
7895 (gnus-pull article gnus-newsgroup-reads)
7897 ;; See whether the article is to be put in the cache.
7899 (vectorp (gnus-summary-article-header article))
7901 (gnus-cache-possibly-enter-article
7902 gnus-newsgroup-name article
7903 (gnus-summary-article-header article)
7904 (= mark gnus-ticked-mark)
7905 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7908 (gnus-summary-update-mark mark 'unread)
7911 (defun gnus-summary-mark-article (&optional article mark no-expire)
7912 "Mark ARTICLE with MARK. MARK can be any character.
7913 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7914 `??' (dormant) and `?E' (expirable).
7915 If MARK is nil, then the default character `?r' is used.
7916 If ARTICLE is nil, then the article on the current line will be
7918 ;; The mark might be a string.
7919 (when (stringp mark)
7920 (setq mark (aref mark 0)))
7921 ;; If no mark is given, then we check auto-expiring.
7923 (setq mark gnus-del-mark))
7924 (when (and (not no-expire)
7925 gnus-newsgroup-auto-expire
7926 (memq mark gnus-auto-expirable-marks))
7927 (setq mark gnus-expirable-mark))
7928 (let ((article (or article (gnus-summary-article-number)))
7929 (old-mark (gnus-summary-article-mark article)))
7930 ;; Allow the backend to change the mark.
7931 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7932 (if (eq mark old-mark)
7935 (error "No article on current line"))
7936 (if (not (if (or (= mark gnus-unread-mark)
7937 (= mark gnus-ticked-mark)
7938 (= mark gnus-dormant-mark))
7939 (gnus-mark-article-as-unread article mark)
7940 (gnus-mark-article-as-read article mark)))
7942 ;; See whether the article is to be put in the cache.
7944 (not (= mark gnus-canceled-mark))
7945 (vectorp (gnus-summary-article-header article))
7947 (gnus-cache-possibly-enter-article
7948 gnus-newsgroup-name article
7949 (gnus-summary-article-header article)
7950 (= mark gnus-ticked-mark)
7951 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7953 (when (gnus-summary-goto-subject article nil t)
7954 (let ((buffer-read-only nil))
7955 (gnus-summary-show-thread)
7957 (gnus-summary-update-mark mark 'unread)
7960 (defun gnus-summary-update-secondary-mark (article)
7961 "Update the secondary (read, process, cache) mark."
7962 (gnus-summary-update-mark
7963 (cond ((memq article gnus-newsgroup-processable)
7965 ((memq article gnus-newsgroup-cached)
7967 ((memq article gnus-newsgroup-replied)
7969 ((memq article gnus-newsgroup-saved)
7971 (t gnus-unread-mark))
7973 (when (gnus-visual-p 'summary-highlight 'highlight)
7974 (gnus-run-hooks 'gnus-summary-update-hook))
7977 (defun gnus-summary-update-mark (mark type)
7978 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7979 (buffer-read-only nil))
7980 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7982 (when (looking-at "\r")
7984 (when (<= (+ forward (point)) (point-max))
7985 ;; Go to the right position on the line.
7986 (goto-char (+ forward (point)))
7987 ;; Replace the old mark with the new mark.
7988 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
7989 ;; Optionally update the marks by some user rule.
7990 (when (eq type 'unread)
7992 (gnus-data-find (gnus-summary-article-number)) mark)
7993 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
7995 (defun gnus-mark-article-as-read (article &optional mark)
7996 "Enter ARTICLE in the pertinent lists and remove it from others."
7997 ;; Make the article expirable.
7998 (let ((mark (or mark gnus-del-mark)))
7999 (if (= mark gnus-expirable-mark)
8000 (push article gnus-newsgroup-expirable)
8001 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8002 ;; Remove from unread and marked lists.
8003 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8004 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8005 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8006 (push (cons article mark) gnus-newsgroup-reads)
8007 ;; Possibly remove from cache, if that is used.
8008 (when gnus-use-cache
8009 (gnus-cache-enter-remove-article article))
8012 (defun gnus-mark-article-as-unread (article &optional mark)
8013 "Enter ARTICLE in the pertinent lists and remove it from others."
8014 (let ((mark (or mark gnus-ticked-mark)))
8017 (gnus-error 1 "Can't mark negative article numbers")
8019 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8020 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8021 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8022 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8024 ;; Unsuppress duplicates?
8025 (when gnus-suppress-duplicates
8026 (gnus-dup-unsuppress-article article))
8028 (cond ((= mark gnus-ticked-mark)
8029 (push article gnus-newsgroup-marked))
8030 ((= mark gnus-dormant-mark)
8031 (push article gnus-newsgroup-dormant))
8033 (push article gnus-newsgroup-unreads)))
8034 (gnus-pull article gnus-newsgroup-reads)
8037 (defalias 'gnus-summary-mark-as-unread-forward
8038 'gnus-summary-tick-article-forward)
8039 (make-obsolete 'gnus-summary-mark-as-unread-forward
8040 'gnus-summary-tick-article-forward)
8041 (defun gnus-summary-tick-article-forward (n)
8042 "Tick N articles forwards.
8043 If N is negative, tick backwards instead.
8044 The difference between N and the number of articles ticked is returned."
8046 (gnus-summary-mark-forward n gnus-ticked-mark))
8048 (defalias 'gnus-summary-mark-as-unread-backward
8049 'gnus-summary-tick-article-backward)
8050 (make-obsolete 'gnus-summary-mark-as-unread-backward
8051 'gnus-summary-tick-article-backward)
8052 (defun gnus-summary-tick-article-backward (n)
8053 "Tick N articles backwards.
8054 The difference between N and the number of articles ticked is returned."
8056 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8058 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8059 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8060 (defun gnus-summary-tick-article (&optional article clear-mark)
8061 "Mark current article as unread.
8062 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8063 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8065 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8068 (defun gnus-summary-mark-as-read-forward (n)
8069 "Mark N articles as read forwards.
8070 If N is negative, mark backwards instead.
8071 The difference between N and the actual number of articles marked is
8074 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8076 (defun gnus-summary-mark-as-read-backward (n)
8077 "Mark the N articles as read backwards.
8078 The difference between N and the actual number of articles marked is
8081 (gnus-summary-mark-forward
8082 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8084 (defun gnus-summary-mark-as-read (&optional article mark)
8085 "Mark current article as read.
8086 ARTICLE specifies the article to be marked as read.
8087 MARK specifies a string to be inserted at the beginning of the line."
8088 (gnus-summary-mark-article article mark))
8090 (defun gnus-summary-clear-mark-forward (n)
8091 "Clear marks from N articles forward.
8092 If N is negative, clear backward instead.
8093 The difference between N and the number of marks cleared is returned."
8095 (gnus-summary-mark-forward n gnus-unread-mark))
8097 (defun gnus-summary-clear-mark-backward (n)
8098 "Clear marks from N articles backward.
8099 The difference between N and the number of marks cleared is returned."
8101 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8103 (defun gnus-summary-mark-unread-as-read ()
8104 "Intended to be used by `gnus-summary-mark-article-hook'."
8105 (when (memq gnus-current-article gnus-newsgroup-unreads)
8106 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8108 (defun gnus-summary-mark-read-and-unread-as-read ()
8109 "Intended to be used by `gnus-summary-mark-article-hook'."
8110 (let ((mark (gnus-summary-article-mark)))
8111 (when (or (gnus-unread-mark-p mark)
8112 (gnus-read-mark-p mark))
8113 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8115 (defun gnus-summary-mark-region-as-read (point mark all)
8116 "Mark all unread articles between point and mark as read.
8117 If given a prefix, mark all articles between point and mark as read,
8118 even ticked and dormant ones."
8119 (interactive "r\nP")
8128 (memq (setq article (gnus-summary-article-number))
8129 gnus-newsgroup-unreads))
8130 (gnus-summary-mark-article article gnus-del-mark))
8132 (gnus-summary-find-next))))))
8134 (defun gnus-summary-mark-below (score mark)
8135 "Mark articles with score less than SCORE with MARK."
8136 (interactive "P\ncMark: ")
8137 (setq score (if score
8138 (prefix-numeric-value score)
8139 (or gnus-summary-default-score 0)))
8141 (set-buffer gnus-summary-buffer)
8142 (goto-char (point-min))
8145 (and (< (gnus-summary-article-score) score)
8146 (gnus-summary-mark-article nil mark))
8147 (gnus-summary-find-next)))))
8149 (defun gnus-summary-kill-below (&optional score)
8150 "Mark articles with score below SCORE as read."
8152 (gnus-summary-mark-below score gnus-killed-mark))
8154 (defun gnus-summary-clear-above (&optional score)
8155 "Clear all marks from articles with score above SCORE."
8157 (gnus-summary-mark-above score gnus-unread-mark))
8159 (defun gnus-summary-tick-above (&optional score)
8160 "Tick all articles with score above SCORE."
8162 (gnus-summary-mark-above score gnus-ticked-mark))
8164 (defun gnus-summary-mark-above (score mark)
8165 "Mark articles with score over SCORE with MARK."
8166 (interactive "P\ncMark: ")
8167 (setq score (if score
8168 (prefix-numeric-value score)
8169 (or gnus-summary-default-score 0)))
8171 (set-buffer gnus-summary-buffer)
8172 (goto-char (point-min))
8174 (when (> (gnus-summary-article-score) score)
8175 (gnus-summary-mark-article nil mark))
8177 (gnus-summary-find-next)))))
8179 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8180 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8181 (defun gnus-summary-limit-include-expunged (&optional no-error)
8182 "Display all the hidden articles that were expunged for low scores."
8184 (let ((buffer-read-only nil))
8185 (let ((scored gnus-newsgroup-scored)
8188 (unless (gnus-summary-goto-subject (caar scored))
8189 (and (setq h (gnus-summary-article-header (caar scored)))
8190 (< (cdar scored) gnus-summary-expunge-below)
8192 (setq scored (cdr scored)))
8194 (when (not no-error)
8195 (error "No expunged articles hidden"))
8196 (goto-char (point-min))
8197 (gnus-summary-prepare-unthreaded (nreverse headers))
8198 (goto-char (point-min))
8199 (gnus-summary-position-point)
8202 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8203 "Mark all unread articles in this newsgroup as read.
8204 If prefix argument ALL is non-nil, ticked and dormant articles will
8205 also be marked as read.
8206 If QUIETLY is non-nil, no questions will be asked.
8207 If TO-HERE is non-nil, it should be a point in the buffer. All
8208 articles before this point will be marked as read.
8209 Note that this function will only catch up the unread article
8210 in the current summary buffer limitation.
8211 The number of articles marked as read is returned."
8216 (not gnus-interactive-catchup) ;Without confirmation?
8220 "Mark absolutely all articles as read? "
8221 "Mark all unread articles as read? ")))
8223 (not gnus-newsgroup-adaptive)
8224 (not gnus-newsgroup-auto-expire)
8225 (not gnus-suppress-duplicates)
8226 (or (not gnus-use-cache)
8227 (eq gnus-use-cache 'passive)))
8230 (setq gnus-newsgroup-marked nil
8231 gnus-newsgroup-dormant nil))
8232 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8233 ;; We actually mark all articles as canceled, which we
8234 ;; have to do when using auto-expiry or adaptive scoring.
8235 (gnus-summary-show-all-threads)
8236 (when (gnus-summary-first-subject (not all) t)
8238 (if to-here (< (point) to-here) t)
8239 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8240 (gnus-summary-find-next (not all) nil nil t))))
8241 (gnus-set-mode-line 'summary))
8243 (gnus-summary-position-point)))
8245 (defun gnus-summary-catchup-to-here (&optional all)
8246 "Mark all unticked articles before the current one as read.
8247 If ALL is non-nil, also mark ticked and dormant articles as read."
8250 (gnus-save-hidden-threads
8251 (let ((beg (point)))
8252 ;; We check that there are unread articles.
8253 (when (or all (gnus-summary-find-prev))
8254 (gnus-summary-catchup all t beg)))))
8255 (gnus-summary-position-point))
8257 (defun gnus-summary-catchup-all (&optional quietly)
8258 "Mark all articles in this newsgroup as read."
8260 (gnus-summary-catchup t quietly))
8262 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8263 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8264 If prefix argument ALL is non-nil, all articles are marked as read."
8266 (when (gnus-summary-catchup all quietly nil 'fast)
8267 ;; Select next newsgroup or exit.
8268 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8269 (eq gnus-auto-select-next 'quietly))
8270 (gnus-summary-next-group nil)
8271 (gnus-summary-exit))))
8273 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8274 "Mark all articles in this newsgroup as read, and then exit."
8276 (gnus-summary-catchup-and-exit t quietly))
8278 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8279 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8280 "Mark all articles in this group as read and select the next group.
8281 If given a prefix, mark all articles, unread as well as ticked, as
8285 (gnus-summary-catchup all))
8286 (gnus-summary-next-article t nil nil t))
8288 ;; Thread-based commands.
8290 (defun gnus-summary-articles-in-thread (&optional article)
8291 "Return a list of all articles in the current thread.
8292 If ARTICLE is non-nil, return all articles in the thread that starts
8294 (let* ((article (or article (gnus-summary-article-number)))
8295 (data (gnus-data-find-list article))
8296 (top-level (gnus-data-level (car data)))
8298 (cond ((null gnus-thread-operation-ignore-subject)
8299 (gnus-simplify-subject-re
8300 (mail-header-subject (gnus-data-header (car data)))))
8301 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8302 (gnus-simplify-subject-fuzzy
8303 (mail-header-subject (gnus-data-header (car data)))))
8305 (end-point (save-excursion
8306 (if (gnus-summary-go-to-next-thread)
8307 (point) (point-max))))
8310 (< (gnus-data-pos (car data)) end-point))
8311 (when (or (not top-subject)
8312 (string= top-subject
8313 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8314 (gnus-simplify-subject-fuzzy
8315 (mail-header-subject
8316 (gnus-data-header (car data))))
8317 (gnus-simplify-subject-re
8318 (mail-header-subject
8319 (gnus-data-header (car data)))))))
8320 (push (gnus-data-number (car data)) articles))
8321 (unless (and (setq data (cdr data))
8322 (> (gnus-data-level (car data)) top-level))
8324 ;; Return the list of articles.
8325 (nreverse articles)))
8327 (defun gnus-summary-rethread-current ()
8328 "Rethread the thread the current article is part of."
8330 (let* ((gnus-show-threads t)
8331 (article (gnus-summary-article-number))
8332 (id (mail-header-id (gnus-summary-article-header)))
8333 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8335 (error "No article on the current line"))
8336 (gnus-rebuild-thread id)
8337 (gnus-summary-goto-subject article)))
8339 (defun gnus-summary-reparent-thread ()
8340 "Make the current article child of the marked (or previous) article.
8342 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8343 is non-nil or the Subject: of both articles are the same."
8345 (unless (not (gnus-group-read-only-p))
8346 (error "The current newsgroup does not support article editing"))
8347 (unless (<= (length gnus-newsgroup-processable) 1)
8348 (error "No more than one article may be marked"))
8349 (save-window-excursion
8350 (let ((gnus-article-buffer " *reparent*")
8351 (current-article (gnus-summary-article-number))
8352 ;; First grab the marked article, otherwise one line up.
8353 (parent-article (if (not (null gnus-newsgroup-processable))
8354 (car gnus-newsgroup-processable)
8356 (if (eq (forward-line -1) 0)
8357 (gnus-summary-article-number)
8358 (error "Beginning of summary buffer"))))))
8359 (unless (not (eq current-article parent-article))
8360 (error "An article may not be self-referential"))
8361 (let ((message-id (mail-header-id
8362 (gnus-summary-article-header parent-article))))
8363 (unless (and message-id (not (equal message-id "")))
8364 (error "No message-id in desired parent"))
8365 (gnus-with-article current-article
8366 (goto-char (point-min))
8367 (if (re-search-forward "^References: " nil t)
8369 (re-search-forward "^[^ \t]" nil t)
8372 (insert " " message-id))
8373 (insert "References: " message-id "\n")))
8374 (set-buffer gnus-summary-buffer)
8375 (gnus-summary-unmark-all-processable)
8376 (gnus-summary-update-article current-article)
8377 (gnus-summary-rethread-current)
8378 (gnus-message 3 "Article %d is now the child of article %d"
8379 current-article parent-article)))))
8381 (defun gnus-summary-toggle-threads (&optional arg)
8382 "Toggle showing conversation threads.
8383 If ARG is positive number, turn showing conversation threads on."
8385 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8386 (setq gnus-show-threads
8387 (if (null arg) (not gnus-show-threads)
8388 (> (prefix-numeric-value arg) 0)))
8389 (gnus-summary-prepare)
8390 (gnus-summary-goto-subject current)
8391 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8392 (gnus-summary-position-point)))
8394 (defun gnus-summary-show-all-threads ()
8398 (let ((buffer-read-only nil))
8399 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8400 (gnus-summary-position-point))
8402 (defun gnus-summary-show-thread ()
8403 "Show thread subtrees.
8404 Returns nil if no thread was there to be shown."
8406 (let ((buffer-read-only nil)
8408 ;; first goto end then to beg, to have point at beg after let
8409 (end (progn (end-of-line) (point)))
8410 (beg (progn (beginning-of-line) (point))))
8412 ;; Any hidden lines here?
8413 (search-forward "\r" end t)
8414 (subst-char-in-region beg end ?\^M ?\n t)
8416 (gnus-summary-position-point))))
8418 (defun gnus-summary-hide-all-threads ()
8419 "Hide all thread subtrees."
8422 (goto-char (point-min))
8423 (gnus-summary-hide-thread)
8424 (while (zerop (gnus-summary-next-thread 1 t))
8425 (gnus-summary-hide-thread)))
8426 (gnus-summary-position-point))
8428 (defun gnus-summary-hide-thread ()
8429 "Hide thread subtrees.
8430 Returns nil if no threads were there to be hidden."
8432 (let ((buffer-read-only nil)
8434 (article (gnus-summary-article-number)))
8436 ;; Go forward until either the buffer ends or the subthread
8438 (when (and (not (eobp))
8439 (or (zerop (gnus-summary-next-thread 1 t))
8440 (goto-char (point-max))))
8442 (if (and (> (point) start)
8443 (search-backward "\n" start t))
8445 (subst-char-in-region start (point) ?\n ?\^M)
8446 (gnus-summary-goto-subject article))
8449 ;;(gnus-summary-position-point)
8452 (defun gnus-summary-go-to-next-thread (&optional previous)
8453 "Go to the same level (or less) next thread.
8454 If PREVIOUS is non-nil, go to previous thread instead.
8455 Return the article number moved to, or nil if moving was impossible."
8456 (let ((level (gnus-summary-thread-level))
8457 (way (if previous -1 1))
8460 (while (and (not (eobp))
8461 (< level (gnus-summary-thread-level)))
8469 (gnus-summary-article-number)
8472 (defun gnus-summary-next-thread (n &optional silent)
8473 "Go to the same level next N'th thread.
8474 If N is negative, search backward instead.
8475 Returns the difference between N and the number of skips actually
8478 If SILENT, don't output messages."
8480 (let ((backward (< n 0))
8483 (gnus-summary-go-to-next-thread backward))
8486 (gnus-summary-position-point))
8487 (when (and (not silent) (/= 0 n))
8488 (gnus-message 7 "No more threads"))
8491 (defun gnus-summary-prev-thread (n)
8492 "Go to the same level previous N'th thread.
8493 Returns the difference between N and the number of skips actually
8496 (gnus-summary-next-thread (- n)))
8498 (defun gnus-summary-go-down-thread ()
8499 "Go down one level in the current thread."
8500 (let ((children (gnus-summary-article-children)))
8502 (gnus-summary-goto-subject (car children)))))
8504 (defun gnus-summary-go-up-thread ()
8505 "Go up one level in the current thread."
8506 (let ((parent (gnus-summary-article-parent)))
8508 (gnus-summary-goto-subject parent))))
8510 (defun gnus-summary-down-thread (n)
8511 "Go down thread N steps.
8512 If N is negative, go up instead.
8513 Returns the difference between N and how many steps down that were
8519 (if up (gnus-summary-go-up-thread)
8520 (gnus-summary-go-down-thread)))
8522 (gnus-summary-position-point)
8524 (gnus-message 7 "Can't go further"))
8527 (defun gnus-summary-up-thread (n)
8528 "Go up thread N steps.
8529 If N is negative, go up instead.
8530 Returns the difference between N and how many steps down that were
8533 (gnus-summary-down-thread (- n)))
8535 (defun gnus-summary-top-thread ()
8536 "Go to the top of the thread."
8538 (while (gnus-summary-go-up-thread))
8539 (gnus-summary-article-number))
8541 (defun gnus-summary-kill-thread (&optional unmark)
8542 "Mark articles under current thread as read.
8543 If the prefix argument is positive, remove any kinds of marks.
8544 If the prefix argument is negative, tick articles instead."
8547 (setq unmark (prefix-numeric-value unmark)))
8548 (let ((articles (gnus-summary-articles-in-thread)))
8550 ;; Expand the thread.
8551 (gnus-summary-show-thread)
8552 ;; Mark all the articles.
8554 (gnus-summary-goto-subject (car articles))
8555 (cond ((null unmark)
8556 (gnus-summary-mark-article-as-read gnus-killed-mark))
8558 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8560 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8561 (setq articles (cdr articles))))
8562 ;; Hide killed subtrees.
8564 gnus-thread-hide-killed
8565 (gnus-summary-hide-thread))
8566 ;; If marked as read, go to next unread subject.
8568 ;; Go to next unread subject.
8569 (gnus-summary-next-subject 1 t)))
8570 (gnus-set-mode-line 'summary))
8572 ;; Summary sorting commands
8574 (defun gnus-summary-sort-by-number (&optional reverse)
8575 "Sort the summary buffer by article number.
8576 Argument REVERSE means reverse order."
8578 (gnus-summary-sort 'number reverse))
8580 (defun gnus-summary-sort-by-author (&optional reverse)
8581 "Sort the summary buffer by author name alphabetically.
8582 If case-fold-search is non-nil, case of letters is ignored.
8583 Argument REVERSE means reverse order."
8585 (gnus-summary-sort 'author reverse))
8587 (defun gnus-summary-sort-by-subject (&optional reverse)
8588 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8589 If case-fold-search is non-nil, case of letters is ignored.
8590 Argument REVERSE means reverse order."
8592 (gnus-summary-sort 'subject reverse))
8594 (defun gnus-summary-sort-by-date (&optional reverse)
8595 "Sort the summary buffer by date.
8596 Argument REVERSE means reverse order."
8598 (gnus-summary-sort 'date reverse))
8600 (defun gnus-summary-sort-by-score (&optional reverse)
8601 "Sort the summary buffer by score.
8602 Argument REVERSE means reverse order."
8604 (gnus-summary-sort 'score reverse))
8606 (defun gnus-summary-sort-by-lines (&optional reverse)
8607 "Sort the summary buffer by the number of lines.
8608 Argument REVERSE means reverse order."
8610 (gnus-summary-sort 'lines reverse))
8612 (defun gnus-summary-sort-by-chars (&optional reverse)
8613 "Sort the summary buffer by article length.
8614 Argument REVERSE means reverse order."
8616 (gnus-summary-sort 'chars reverse))
8618 (defun gnus-summary-sort (predicate reverse)
8619 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8620 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8621 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8622 (gnus-thread-sort-functions
8627 (gnus-article-sort-functions
8633 (gnus-summary-prepare-hook nil))
8634 ;; We do the sorting by regenerating the threads.
8635 (gnus-summary-prepare)
8636 ;; Hide subthreads if needed.
8637 (when (and gnus-show-threads gnus-thread-hide-subtree)
8638 (gnus-summary-hide-all-threads))))
8640 ;; Summary saving commands.
8642 (defun gnus-summary-save-article (&optional n not-saved)
8643 "Save the current article using the default saver function.
8644 If N is a positive number, save the N next articles.
8645 If N is a negative number, save the N previous articles.
8646 If N is nil and any articles have been marked with the process mark,
8647 save those articles instead.
8648 The variable `gnus-default-article-saver' specifies the saver function."
8650 (let* ((articles (gnus-summary-work-articles n))
8651 (save-buffer (save-excursion
8652 (nnheader-set-temp-buffer " *Gnus Save*")))
8653 (num (length articles))
8655 (dolist (article articles)
8656 (setq header (gnus-summary-article-header article))
8657 (if (not (vectorp header))
8658 ;; This is a pseudo-article.
8659 (if (assq 'name header)
8660 (gnus-copy-file (cdr (assq 'name header)))
8661 (gnus-message 1 "Article %d is unsaveable" article))
8662 ;; This is a real article.
8663 (save-window-excursion
8664 (gnus-summary-select-article t nil nil article))
8666 (set-buffer save-buffer)
8668 (insert-buffer-substring gnus-original-article-buffer))
8669 (setq file (gnus-article-save save-buffer file num))
8670 (gnus-summary-remove-process-mark article)
8672 (gnus-summary-set-saved-mark article))))
8673 (gnus-kill-buffer save-buffer)
8674 (gnus-summary-position-point)
8675 (gnus-set-mode-line 'summary)
8678 (defun gnus-summary-pipe-output (&optional arg)
8679 "Pipe the current article to a subprocess.
8680 If N is a positive number, pipe the N next articles.
8681 If N is a negative number, pipe the N previous articles.
8682 If N is nil and any articles have been marked with the process mark,
8683 pipe those articles instead."
8685 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8686 (gnus-summary-save-article arg t))
8687 (gnus-configure-windows 'pipe))
8689 (defun gnus-summary-save-article-mail (&optional arg)
8690 "Append the current article to an mail file.
8691 If N is a positive number, save the N next articles.
8692 If N is a negative number, save the N previous articles.
8693 If N is nil and any articles have been marked with the process mark,
8694 save those articles instead."
8696 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8697 (gnus-summary-save-article arg)))
8699 (defun gnus-summary-save-article-rmail (&optional arg)
8700 "Append the current article to an rmail file.
8701 If N is a positive number, save the N next articles.
8702 If N is a negative number, save the N previous articles.
8703 If N is nil and any articles have been marked with the process mark,
8704 save those articles instead."
8706 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8707 (gnus-summary-save-article arg)))
8709 (defun gnus-summary-save-article-file (&optional arg)
8710 "Append the current article to a file.
8711 If N is a positive number, save the N next articles.
8712 If N is a negative number, save the N previous articles.
8713 If N is nil and any articles have been marked with the process mark,
8714 save those articles instead."
8716 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8717 (gnus-summary-save-article arg)))
8719 (defun gnus-summary-write-article-file (&optional arg)
8720 "Write the current article to a file, deleting the previous file.
8721 If N is a positive number, save the N next articles.
8722 If N is a negative number, save the N previous articles.
8723 If N is nil and any articles have been marked with the process mark,
8724 save those articles instead."
8726 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8727 (gnus-summary-save-article arg)))
8729 (defun gnus-summary-save-article-body-file (&optional arg)
8730 "Append the current article body to a file.
8731 If N is a positive number, save the N next articles.
8732 If N is a negative number, save the N previous articles.
8733 If N is nil and any articles have been marked with the process mark,
8734 save those articles instead."
8736 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8737 (gnus-summary-save-article arg)))
8739 (defun gnus-summary-pipe-message (program)
8740 "Pipe the current article through PROGRAM."
8741 (interactive "sProgram: ")
8742 (gnus-summary-select-article)
8743 (let ((mail-header-separator ""))
8744 (gnus-eval-in-buffer-window gnus-article-buffer
8747 (let ((start (window-start))
8749 (message-pipe-buffer-body program)
8750 (set-window-start (get-buffer-window (current-buffer)) start))))))
8752 (defun gnus-get-split-value (methods)
8753 "Return a value based on the split METHODS."
8754 (let (split-name method result match)
8757 (set-buffer gnus-original-article-buffer)
8759 (nnheader-narrow-to-headers)
8761 (goto-char (point-min))
8762 (setq method (pop methods))
8763 (setq match (car method))
8766 ;; Regular expression.
8768 (re-search-forward match nil t)))
8769 ((gnus-functionp match)
8773 (setq result (funcall match gnus-newsgroup-name))))
8778 (setq result (eval match)))))
8779 (setq split-name (append (cdr method) split-name))
8780 (cond ((stringp result)
8781 (push (expand-file-name
8782 result gnus-article-save-directory)
8785 (setq split-name (append result split-name)))))))))
8786 (nreverse split-name)))
8788 (defun gnus-valid-move-group-p (group)
8791 (symbol-value group)
8794 (car (gnus-find-method-for-group
8795 (symbol-name group))))
8796 gnus-valid-select-methods))))
8798 (defun gnus-read-move-group-name (prompt default articles prefix)
8799 "Read a group name."
8800 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8801 (minibuffer-confirm-incomplete nil) ; XEmacs
8805 (if (> (length articles) 1)
8806 (format "these %d articles" (length articles))
8811 (gnus-completing-read default prom
8813 'gnus-valid-move-group-p
8815 'gnus-group-history))
8816 ((= 1 (length split-name))
8817 (gnus-completing-read (car split-name) prom
8819 'gnus-valid-move-group-p
8821 'gnus-group-history))
8823 (gnus-completing-read nil prom
8824 (mapcar (lambda (el) (list el))
8825 (nreverse split-name))
8827 'gnus-group-history)))))
8829 (if (or (string= to-newsgroup "")
8830 (string= to-newsgroup prefix))
8831 (setq to-newsgroup default))
8832 (unless to-newsgroup
8833 (error "No group name entered"))
8834 (or (gnus-active to-newsgroup)
8835 (gnus-activate-group to-newsgroup)
8836 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8838 (or (and (gnus-request-create-group
8839 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8840 (gnus-activate-group to-newsgroup nil nil
8841 (gnus-group-name-to-method
8843 (error "Couldn't create group %s" to-newsgroup)))
8844 (error "No such group: %s" to-newsgroup)))
8847 ;; Summary extract commands
8849 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8850 (let ((buffer-read-only nil)
8851 (article (gnus-summary-article-number))
8853 (unless (gnus-summary-goto-subject article)
8854 (error "No such article: %d" article))
8855 (gnus-summary-position-point)
8856 ;; If all commands are to be bunched up on one line, we collect
8858 (unless gnus-view-pseudos-separately
8859 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8862 (setq action (cdr (assq 'action (car ps))))
8863 (setq files (list (cdr (assq 'name (car ps)))))
8864 (while (and ps (cdr ps)
8865 (string= (or action "1")
8866 (or (cdr (assq 'action (cadr ps))) "2")))
8867 (push (cdr (assq 'name (cadr ps))) files)
8868 (setcdr ps (cddr ps)))
8870 (when (not (string-match "%s" action))
8873 (when (assq 'execute (car ps))
8874 (setcdr (assq 'execute (car ps))
8875 (funcall (if (string-match "%s" action)
8884 (setq ps (cdr ps)))))
8885 (if (and gnus-view-pseudos (not not-view))
8887 (when (assq 'execute (car pslist))
8888 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8889 (eq gnus-view-pseudos 'not-confirm)))
8890 (setq pslist (cdr pslist)))
8893 (setq after-article (or (cdr (assq 'article (car pslist)))
8894 (gnus-summary-article-number)))
8895 (gnus-summary-goto-subject after-article)
8898 (insert " " (file-name-nondirectory
8899 (cdr (assq 'name (car pslist))))
8900 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8902 (forward-line -1) ; back to `b'
8903 (gnus-add-text-properties
8904 b (1- e) (list 'gnus-number gnus-reffed-article-number
8905 gnus-mouse-face-prop gnus-mouse-face))
8907 after-article gnus-reffed-article-number
8908 gnus-unread-mark b (car pslist) 0 (- e b))
8909 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8910 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8911 (setq pslist (cdr pslist)))))))
8913 (defun gnus-pseudos< (p1 p2)
8914 (let ((c1 (cdr (assq 'action p1)))
8915 (c2 (cdr (assq 'action p2))))
8916 (and c1 c2 (string< c1 c2))))
8918 (defun gnus-request-pseudo-article (props)
8919 (cond ((assq 'execute props)
8920 (gnus-execute-command (cdr (assq 'execute props)))))
8921 (let ((gnus-current-article (gnus-summary-article-number)))
8922 (gnus-run-hooks 'gnus-mark-article-hook)))
8924 (defun gnus-execute-command (command &optional automatic)
8926 (gnus-article-setup-buffer)
8927 (set-buffer gnus-article-buffer)
8928 (setq buffer-read-only nil)
8929 (let ((command (if automatic command
8930 (read-string "Command: " (cons command 0)))))
8932 (insert "$ " command "\n\n")
8933 (if gnus-view-pseudo-asynchronously
8934 (start-process "gnus-execute" (current-buffer) shell-file-name
8935 shell-command-switch command)
8936 (call-process shell-file-name nil t nil
8937 shell-command-switch command)))))
8939 ;; Summary kill commands.
8941 (defun gnus-summary-edit-global-kill (article)
8942 "Edit the \"global\" kill file."
8943 (interactive (list (gnus-summary-article-number)))
8944 (gnus-group-edit-global-kill article))
8946 (defun gnus-summary-edit-local-kill ()
8947 "Edit a local kill file applied to the current newsgroup."
8949 (setq gnus-current-headers (gnus-summary-article-header))
8950 (gnus-group-edit-local-kill
8951 (gnus-summary-article-number) gnus-newsgroup-name))
8955 (defun gnus-read-header (id &optional header)
8956 "Read the headers of article ID and enter them into the Gnus system."
8957 (let ((group gnus-newsgroup-name)
8958 (gnus-override-method
8959 (and (gnus-news-group-p gnus-newsgroup-name)
8960 gnus-refer-article-method))
8962 ;; First we check to see whether the header in question is already
8965 ;; This is a Message-ID.
8966 (setq header (or header (gnus-id-to-header id)))
8967 ;; This is an article number.
8968 (setq header (or header (gnus-summary-article-header id))))
8970 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8971 ;; We have found the header.
8973 ;; If this is a sparse article, we have to nix out its
8974 ;; previous entry in the thread hashtb.
8976 (gnus-summary-article-sparse-p (mail-header-number header)))
8977 (let* ((parent (gnus-parent-id (mail-header-references header)))
8978 (thread (and parent (gnus-id-to-thread parent))))
8980 (delq (assq header thread) thread))))
8981 ;; We have to really fetch the header to this article.
8983 (set-buffer nntp-server-buffer)
8984 (when (setq where (gnus-request-head id group))
8985 (nnheader-fold-continuation-lines)
8986 (goto-char (point-max))
8988 (goto-char (point-min))
8992 ((cdr where) (cdr where))
8993 (header (mail-header-number header))
8994 (t gnus-reffed-article-number))
8996 (insert " Article retrieved.\n"))
8998 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8999 () ; Malformed head.
9000 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9001 (when (and (stringp id)
9002 (not (string= (gnus-group-real-name group)
9004 ;; If we fetched by Message-ID and the article came
9005 ;; from a different group, we fudge some bogus article
9006 ;; numbers for this article.
9007 (mail-header-set-number header gnus-reffed-article-number))
9009 (set-buffer gnus-summary-buffer)
9010 (decf gnus-reffed-article-number)
9011 (gnus-remove-header (mail-header-number header))
9012 (push header gnus-newsgroup-headers)
9013 (setq gnus-current-headers header)
9014 (push (mail-header-number header) gnus-newsgroup-limit)))
9017 (defun gnus-remove-header (number)
9018 "Remove header NUMBER from `gnus-newsgroup-headers'."
9019 (if (and gnus-newsgroup-headers
9020 (= number (mail-header-number (car gnus-newsgroup-headers))))
9021 (pop gnus-newsgroup-headers)
9022 (let ((headers gnus-newsgroup-headers))
9023 (while (and (cdr headers)
9024 (not (= number (mail-header-number (cadr headers)))))
9027 (setcdr headers (cddr headers))))))
9030 ;;; summary highlights
9033 (defun gnus-highlight-selected-summary ()
9034 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9035 ;; Highlight selected article in summary buffer
9036 (when gnus-summary-selected-face
9038 (let* ((beg (progn (beginning-of-line) (point)))
9039 (end (progn (end-of-line) (point)))
9040 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9041 (from (if (get-text-property beg gnus-mouse-face-prop)
9043 (or (next-single-property-change
9044 beg gnus-mouse-face-prop nil end)
9049 (or (next-single-property-change
9050 from gnus-mouse-face-prop nil end)
9052 ;; If no mouse-face prop on line we will have to = from = end,
9053 ;; so we highlight the entire line instead.
9054 (when (= (+ to 2) from)
9057 (if gnus-newsgroup-selected-overlay
9058 ;; Move old overlay.
9060 gnus-newsgroup-selected-overlay from to (current-buffer))
9061 ;; Create new overlay.
9063 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9064 'face gnus-summary-selected-face))))))
9066 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9067 (defun gnus-summary-highlight-line ()
9068 "Highlight current line according to `gnus-summary-highlight'."
9069 (let* ((list gnus-summary-highlight)
9071 (end (progn (end-of-line) (point)))
9072 ;; now find out where the line starts and leave point there.
9073 (beg (progn (beginning-of-line) (point)))
9074 (article (gnus-summary-article-number))
9075 (score (or (cdr (assq (or article gnus-current-article)
9076 gnus-newsgroup-scored))
9077 gnus-summary-default-score 0))
9078 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9079 (inhibit-read-only t))
9080 ;; Eval the cars of the lists until we find a match.
9081 (let ((default gnus-summary-default-score))
9083 (not (eval (caar list))))
9084 (setq list (cdr list))))
9085 (let ((face (cdar list)))
9086 (unless (eq face (get-text-property beg 'face))
9087 (gnus-put-text-property-excluding-characters-with-faces
9089 (setq face (if (boundp face) (symbol-value face) face)))
9090 (when gnus-summary-highlight-line-function
9091 (funcall gnus-summary-highlight-line-function article face))))
9094 (defun gnus-update-read-articles (group unread &optional compute)
9095 "Update the list of read articles in GROUP."
9096 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9097 (entry (gnus-gethash group gnus-newsrc-hashtb))
9098 (info (nth 2 entry))
9100 (unread (sort (copy-sequence unread) '<))
9102 (if (or (not info) (not active))
9103 ;; There is no info on this group if it was, in fact,
9104 ;; killed. Gnus stores no information on killed groups, so
9105 ;; there's nothing to be done.
9106 ;; One could store the information somewhere temporarily,
9107 ;; perhaps... Hmmm...
9109 ;; Remove any negative articles numbers.
9110 (while (and unread (< (car unread) 0))
9111 (setq unread (cdr unread)))
9112 ;; Remove any expired article numbers
9113 (while (and unread (< (car unread) (car active)))
9114 (setq unread (cdr unread)))
9115 ;; Compute the ranges of read articles by looking at the list of
9118 (when (/= (car unread) prev)
9119 (push (if (= prev (1- (car unread))) prev
9120 (cons prev (1- (car unread))))
9122 (setq prev (1+ (car unread)))
9123 (setq unread (cdr unread)))
9124 (when (<= prev (cdr active))
9125 (push (cons prev (cdr active)) read))
9126 (setq read (if (> (length read) 1) (nreverse read) read))
9130 (set-buffer gnus-group-buffer)
9133 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9134 (gnus-info-set-read ',info ',(gnus-info-read info))
9135 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9136 (gnus-group-update-group ,group t))))
9137 ;; Propagate the read marks to the backend.
9138 (if (gnus-check-backend-function 'request-set-mark group)
9139 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9140 (add (gnus-remove-from-range read (gnus-info-read info))))
9142 (unless (gnus-check-group group)
9143 (error "Can't open server for %s" group))
9144 (gnus-request-set-mark
9145 group (delq nil (list (if add (list add 'add '(read)))
9146 (if del (list del 'del '(read)))))))))
9147 ;; Enter this list into the group info.
9148 (gnus-info-set-read info read)
9149 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9150 (gnus-get-unread-articles-in-group info (gnus-active group))
9153 (defun gnus-offer-save-summaries ()
9154 "Offer to save all active summary buffers."
9156 (let ((buflist (buffer-list))
9158 ;; Go through all buffers and find all summaries.
9160 (and (setq bufname (buffer-name (car buflist)))
9161 (string-match "Summary" bufname)
9163 (set-buffer bufname)
9164 ;; We check that this is, indeed, a summary buffer.
9165 (and (eq major-mode 'gnus-summary-mode)
9166 ;; Also make sure this isn't bogus.
9167 gnus-newsgroup-prepared
9168 ;; Also make sure that this isn't a dead summary buffer.
9169 (not gnus-dead-summary-mode)))
9170 (push bufname buffers))
9171 (setq buflist (cdr buflist)))
9172 ;; Go through all these summary buffers and offer to save them.
9175 "Update summary buffer %s? "
9177 (switch-to-buffer buf)
9178 (gnus-summary-exit))
9181 (defun gnus-summary-setup-default-charset ()
9182 "Setup newsgroup default charset."
9183 (let ((name (and gnus-newsgroup-name
9184 (gnus-group-real-name gnus-newsgroup-name))))
9185 (setq gnus-newsgroup-charset
9186 (or (and gnus-newsgroup-name
9187 (or (gnus-group-find-parameter gnus-newsgroup-name
9189 (let ((alist gnus-group-charset-alist)
9191 (while (setq elem (pop alist))
9193 (string-match (car elem) name))
9195 charset (cadr elem))))
9197 gnus-default-charset))))
9203 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9204 "Display the current article buffer fully MIME-buttonized.
9205 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9206 treated as multipart/mixed."
9209 (let ((gnus-unbuttonized-mime-types nil)
9210 (gnus-mime-display-multipart-as-mixed show-all-parts))
9211 (gnus-summary-show-article)))
9213 (defun gnus-summary-repair-multipart (article)
9214 "Add a Content-Type header to a multipart article without one."
9215 (interactive (list (gnus-summary-article-number)))
9216 (gnus-with-article article
9217 (message-narrow-to-head)
9218 (goto-char (point-max))
9220 (when (search-forward "\n--" nil t)
9221 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9222 (message-narrow-to-head)
9223 (message-remove-header "Mime-Version")
9224 (message-remove-header "Content-Type")
9225 (goto-char (point-max))
9226 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9228 (insert "Mime-Version: 1.0\n")
9230 (let (gnus-mark-article-hook)
9231 (gnus-summary-select-article t t nil article)))
9233 (defun gnus-summary-toggle-display-buttonized ()
9234 "Toggle the buttonizing of the article buffer."
9237 (if (setq gnus-inhibit-mime-unbuttonizing
9238 (not gnus-inhibit-mime-unbuttonizing))
9239 (let ((gnus-unbuttonized-mime-types nil))
9240 (gnus-summary-show-article))
9241 (gnus-summary-show-article)))
9247 (defmacro gnus-with-article (article &rest forms)
9248 "Select ARTICLE and perform FORMS in the original article buffer.
9249 Then replace the article with the result."
9251 ;; We don't want the article to be marked as read.
9252 (let (gnus-mark-article-hook)
9253 (gnus-summary-select-article t t nil ,article))
9254 (set-buffer gnus-original-article-buffer)
9256 (if (not (gnus-check-backend-function
9257 'request-replace-article (car gnus-article-current)))
9258 (gnus-message 5 "Read-only group; not replacing")
9259 (unless (gnus-request-replace-article
9260 ,article (car gnus-article-current)
9262 (error "Couldn't replace article")))
9263 ;; The cache and backlog have to be flushed somewhat.
9264 (when gnus-keep-backlog
9265 (gnus-backlog-remove-article
9266 (car gnus-article-current) (cdr gnus-article-current)))
9267 (when gnus-use-cache
9268 (gnus-cache-update-article
9269 (car gnus-article-current) (cdr gnus-article-current)))))
9271 (put 'gnus-with-article 'lisp-indent-function 1)
9272 (put 'gnus-with-article 'edebug-form-spec '(form body))
9275 ;;; Generic summary marking commands
9278 (defvar gnus-summary-marking-alist
9279 '((read gnus-del-mark "d")
9280 (unread gnus-unread-mark "u")
9281 (ticked gnus-ticked-mark "!")
9282 (dormant gnus-dormant-mark "?")
9283 (expirable gnus-expirable-mark "e"))
9284 "An alist of names/marks/keystrokes.")
9286 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9287 (defvar gnus-summary-mark-map)
9289 (defun gnus-summary-make-all-marking-commands ()
9290 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9291 (dolist (elem gnus-summary-marking-alist)
9292 (apply 'gnus-summary-make-marking-command elem)))
9294 (defun gnus-summary-make-marking-command (name mark keystroke)
9295 (let ((map (make-sparse-keymap)))
9296 (define-key gnus-summary-generic-mark-map keystroke map)
9297 (dolist (lway `((next "next" next nil "n")
9298 (next-unread "next unread" next t "N")
9299 (prev "previous" prev nil "p")
9300 (prev-unread "previous unread" prev t "P")
9301 (nomove "" nil nil ,keystroke)))
9302 (let ((func (gnus-summary-make-marking-command-1
9303 mark (car lway) lway name)))
9304 (setq func (eval func))
9305 (define-key map (nth 4 lway) func)))))
9307 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9309 (format "gnus-summary-put-mark-as-%s%s"
9310 name (if (eq way 'nomove)
9312 (concat "-" (symbol-name way)))))
9315 "Mark the current article as %s%s.
9316 If N, the prefix, then repeat N times.
9317 If N is negative, move in reverse order.
9318 The difference between N and the actual number of articles marked is
9322 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9324 (defun gnus-summary-generic-mark (n mark move unread)
9325 "Mark N articles with MARK."
9326 (unless (eq major-mode 'gnus-summary-mode)
9327 (error "This command can only be used in the summary buffer"))
9328 (gnus-summary-show-thread)
9332 ((eq move 'prev) -1)
9338 nummove (* -1 nummove))))
9340 (gnus-summary-mark-article nil mark)
9341 (zerop (gnus-summary-next-subject nummove unread t)))
9344 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9345 (gnus-summary-recenter)
9346 (gnus-summary-position-point)
9347 (gnus-set-mode-line 'summary)
9350 (gnus-summary-make-all-marking-commands)
9356 (run-hooks 'gnus-sum-load-hook)
9358 ;;; gnus-sum.el ends here