1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
55 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
56 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
59 (defcustom gnus-kill-summary-on-exit t
60 "*If non-nil, kill the summary buffer when you exit from it.
61 If nil, the summary will become a \"*Dead Summary*\" buffer, and
62 it will be killed sometime later."
63 :group 'gnus-summary-exit
66 (defcustom gnus-fetch-old-headers nil
67 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
68 If an unread article in the group refers to an older, already read (or
69 just marked as read) article, the old article will not normally be
70 displayed in the Summary buffer. If this variable is non-nil, Gnus
71 will attempt to grab the headers to the old articles, and thereby
72 build complete threads. If it has the value `some', only enough
73 headers to connect otherwise loose threads will be displayed. This
74 variable can also be a number. In that case, no more than that number
75 of old headers will be fetched. If it has the value `invisible', all
76 old headers will be fetched, but none will be displayed.
78 The server has to support NOV for any of this to work."
80 :type '(choice (const :tag "off" nil)
83 (sexp :menu-tag "other" t)))
85 (defcustom gnus-refer-thread-limit 200
86 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
87 If t, fetch all the available old headers."
90 (sexp :menu-tag "other" t)))
92 (defcustom gnus-summary-make-false-root 'adopt
93 "*nil means that Gnus won't gather loose threads.
94 If the root of a thread has expired or been read in a previous
95 session, the information necessary to build a complete thread has been
96 lost. Instead of having many small sub-threads from this original thread
97 scattered all over the summary buffer, Gnus can gather them.
99 If non-nil, Gnus will try to gather all loose sub-threads from an
100 original thread into one large thread.
102 If this variable is non-nil, it should be one of `none', `adopt',
105 If this variable is `none', Gnus will not make a false root, but just
106 present the sub-threads after another.
107 If this variable is `dummy', Gnus will create a dummy root that will
108 have all the sub-threads as children.
109 If this variable is `adopt', Gnus will make one of the \"children\"
110 the parent and mark all the step-children as such.
111 If this variable is `empty', the \"children\" are printed with empty
112 subject fields. (Or rather, they will be printed with a string
113 given by the `gnus-summary-same-subject' variable.)"
115 :type '(choice (const :tag "off" nil)
121 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
122 "*A regexp to match subjects to be excluded from loose thread gathering.
123 As loose thread gathering is done on subjects only, that means that
124 there can be many false gatherings performed. By rooting out certain
125 common subjects, gathering might become saner."
129 (defcustom gnus-summary-gather-subject-limit nil
130 "*Maximum length of subject comparisons when gathering loose threads.
131 Use nil to compare full subjects. Setting this variable to a low
132 number will help gather threads that have been corrupted by
133 newsreaders chopping off subject lines, but it might also mean that
134 unrelated articles that have subject that happen to begin with the
135 same few characters will be incorrectly gathered.
137 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
140 :type '(choice (const :tag "off" nil)
142 (sexp :menu-tag "on" t)))
144 (defcustom gnus-simplify-subject-functions nil
145 "List of functions taking a string argument that simplify subjects.
146 The functions are applied recursively.
148 Useful functions to put in this list include: `gnus-simplify-subject-re',
149 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
151 :type '(repeat function))
153 (defcustom gnus-simplify-ignored-prefixes nil
154 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
156 :type '(choice (const :tag "off" nil)
159 (defcustom gnus-build-sparse-threads nil
160 "*If non-nil, fill in the gaps in threads.
161 If `some', only fill in the gaps that are needed to tie loose threads
162 together. If `more', fill in all leaf nodes that Gnus can find. If
163 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
165 :type '(choice (const :tag "off" nil)
168 (sexp :menu-tag "all" t)))
170 (defcustom gnus-summary-thread-gathering-function
171 'gnus-gather-threads-by-subject
172 "*Function used for gathering loose threads.
173 There are two pre-defined functions: `gnus-gather-threads-by-subject',
174 which only takes Subjects into consideration; and
175 `gnus-gather-threads-by-references', which compared the References
176 headers of the articles to find matches."
178 :type '(radio (function-item gnus-gather-threads-by-subject)
179 (function-item gnus-gather-threads-by-references)
180 (function :tag "other")))
182 (defcustom gnus-summary-same-subject ""
183 "*String indicating that the current article has the same subject as the previous.
184 This variable will only be used if the value of
185 `gnus-summary-make-false-root' is `empty'."
186 :group 'gnus-summary-format
189 (defcustom gnus-summary-goto-unread t
190 "*If t, many commands will go to the next unread article.
191 This applies to marking commands as well as other commands that
192 \"naturally\" select the next article, like, for instance, `SPC' at
193 the end of an article.
195 If nil, the marking commands do NOT go to the next unread article
196 (they go to the next article instead). If `never', commands that
197 usually go to the next unread article, will go to the next article,
198 whether it is read or not."
199 :group 'gnus-summary-marks
200 :link '(custom-manual "(gnus)Setting Marks")
201 :type '(choice (const :tag "off" nil)
203 (sexp :menu-tag "on" t)))
205 (defcustom gnus-summary-default-score 0
206 "*Default article score level.
207 All scores generated by the score files will be added to this score.
208 If this variable is nil, scoring will be disabled."
209 :group 'gnus-score-default
210 :type '(choice (const :tag "disable")
213 (defcustom gnus-summary-default-high-score 0
214 "*Default threshold for a high scored article.
215 An article will be highlighted as high scored if its score is greater
217 :group 'gnus-score-default
220 (defcustom gnus-summary-default-low-score 0
221 "*Default threshold for a low scored article.
222 An article will be highlighted as low scored if its score is smaller
224 :group 'gnus-score-default
227 (defcustom gnus-summary-zcore-fuzz 0
228 "*Fuzziness factor for the zcore in the summary buffer.
229 Articles with scores closer than this to `gnus-summary-default-score'
231 :group 'gnus-summary-format
234 (defcustom gnus-simplify-subject-fuzzy-regexp nil
235 "*Strings to be removed when doing fuzzy matches.
236 This can either be a regular expression or list of regular expressions
237 that will be removed from subject strings if fuzzy subject
238 simplification is selected."
240 :type '(repeat regexp))
242 (defcustom gnus-show-threads t
243 "*If non-nil, display threads in summary mode."
247 (defcustom gnus-thread-hide-subtree nil
248 "*If non-nil, hide all threads initially.
249 This can be a predicate specifier which says which threads to hide.
250 If threads are hidden, you have to run the command
251 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
252 to expose hidden threads."
256 (defcustom gnus-thread-hide-killed t
257 "*If non-nil, hide killed threads automatically."
261 (defcustom gnus-thread-ignore-subject t
262 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
263 If nil, articles that have different subjects from their parents will
264 start separate threads."
268 (defcustom gnus-thread-operation-ignore-subject t
269 "*If non-nil, subjects will be ignored when doing thread commands.
270 This affects commands like `gnus-summary-kill-thread' and
271 `gnus-summary-lower-thread'.
273 If this variable is nil, articles in the same thread with different
274 subjects will not be included in the operation in question. If this
275 variable is `fuzzy', only articles that have subjects that are fuzzily
276 equal will be included."
278 :type '(choice (const :tag "off" nil)
282 (defcustom gnus-thread-indent-level 4
283 "*Number that says how much each sub-thread should be indented."
287 (defcustom gnus-auto-extend-newsgroup t
288 "*If non-nil, extend newsgroup forward and backward when requested."
289 :group 'gnus-summary-choose
292 (defcustom gnus-auto-select-first t
293 "*If non-nil, select the article under point.
294 Which article this is is controlled by the `gnus-auto-select-subject'
297 If you want to prevent automatic selection of articles in some
298 newsgroups, set the variable to nil in `gnus-select-group-hook'."
299 :group 'gnus-group-select
300 :type '(choice (const :tag "none" nil)
301 (sexp :menu-tag "first" t)))
303 (defcustom gnus-auto-select-subject 'unread
304 "*Says what subject to place under point when entering a group.
306 This variable can either be the symbols `first' (place point on the
307 first subject), `unread' (place point on the subject line of the first
308 unread article), `best' (place point on the subject line of the
309 higest-scored article), `unseen' (place point on the subject line of
310 the first unseen article), 'unseen-or-unread' (place point on the subject
311 line of the first unseen article or, if all article have been seen, on the
312 subject line of the first unread article), or a function to be called to
313 place point on some subject line.."
314 :group 'gnus-group-select
315 :type '(choice (const best)
319 (const unseen-or-unread)))
321 (defcustom gnus-dont-select-after-jump-to-other-group nil
322 "If non-nil, don't select the first unread article after entering the
323 other group by the command `gnus-summary-jump-to-other-group'. If nil,
324 it is depend on the value of `gnus-auto-select-first' whether to select
326 :group 'gnus-group-select
329 (defcustom gnus-auto-select-next t
330 "*If non-nil, offer to go to the next group from the end of the previous.
331 If the value is t and the next newsgroup is empty, Gnus will exit
332 summary mode and go back to group mode. If the value is neither nil
333 nor t, Gnus will select the following unread newsgroup. In
334 particular, if the value is the symbol `quietly', the next unread
335 newsgroup will be selected without any confirmation, and if it is
336 `almost-quietly', the next group will be selected without any
337 confirmation if you are located on the last article in the group.
338 Finally, if this variable is `slightly-quietly', the `Z n' command
339 will go to the next group without confirmation."
340 :group 'gnus-summary-maneuvering
341 :type '(choice (const :tag "off" nil)
343 (const almost-quietly)
344 (const slightly-quietly)
345 (sexp :menu-tag "on" t)))
347 (defcustom gnus-auto-select-same nil
348 "*If non-nil, select the next article with the same subject.
349 If there are no more articles with the same subject, go to
350 the first unread article."
351 :group 'gnus-summary-maneuvering
354 (defcustom gnus-summary-check-current nil
355 "*If non-nil, consider the current article when moving.
356 The \"unread\" movement commands will stay on the same line if the
357 current article is unread."
358 :group 'gnus-summary-maneuvering
361 (defcustom gnus-auto-center-summary t
362 "*If non-nil, always center the current summary buffer.
363 In particular, if `vertical' do only vertical recentering. If non-nil
364 and non-`vertical', do both horizontal and vertical recentering."
365 :group 'gnus-summary-maneuvering
366 :type '(choice (const :tag "none" nil)
368 (integer :tag "height")
369 (sexp :menu-tag "both" t)))
371 (defcustom gnus-show-all-headers nil
372 "*If non-nil, don't hide any headers."
373 :group 'gnus-article-hiding
374 :group 'gnus-article-headers
377 (defcustom gnus-summary-ignore-duplicates nil
378 "*If non-nil, ignore articles with identical Message-ID headers."
382 (defcustom gnus-single-article-buffer t
383 "*If non-nil, display all articles in the same buffer.
384 If nil, each group will get its own article buffer."
385 :group 'gnus-article-various
388 (defcustom gnus-break-pages t
389 "*If non-nil, do page breaking on articles.
390 The page delimiter is specified by the `gnus-page-delimiter'
392 :group 'gnus-article-various
395 (defcustom gnus-show-mime t
396 "*If non-nil, do mime processing of articles.
397 The articles will simply be fed to the function given by
398 `gnus-article-display-method-for-mime'."
399 :group 'gnus-article-mime
402 (defcustom gnus-move-split-methods nil
403 "*Variable used to suggest where articles are to be moved to.
404 It uses the same syntax as the `gnus-split-methods' variable.
405 However, whereas `gnus-split-methods' specifies file names as targets,
406 this variable specifies group names."
407 :group 'gnus-summary-mail
408 :type '(repeat (choice (list :value (fun) function)
409 (cons :value ("" "") regexp (repeat string))
412 (defcustom gnus-unread-mark ?\ ;;;Whitespace
413 "*Mark used for unread articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-ticked-mark ?!
418 "*Mark used for ticked articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-dormant-mark ??
423 "*Mark used for dormant articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-del-mark ?r
428 "*Mark used for del'd articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-read-mark ?R
433 "*Mark used for read articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-expirable-mark ?E
438 "*Mark used for expirable articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-killed-mark ?K
443 "*Mark used for killed articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-souped-mark ?F
448 "*Mark used for souped articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-kill-file-mark ?X
453 "*Mark used for articles killed by kill files."
454 :group 'gnus-summary-marks
457 (defcustom gnus-low-score-mark ?Y
458 "*Mark used for articles with a low score."
459 :group 'gnus-summary-marks
462 (defcustom gnus-catchup-mark ?C
463 "*Mark used for articles that are caught up."
464 :group 'gnus-summary-marks
467 (defcustom gnus-replied-mark ?A
468 "*Mark used for articles that have been replied to."
469 :group 'gnus-summary-marks
472 (defcustom gnus-forwarded-mark ?F
473 "*Mark used for articles that have been forwarded."
474 :group 'gnus-summary-marks
477 (defcustom gnus-recent-mark ?N
478 "*Mark used for articles that are recent."
479 :group 'gnus-summary-marks
482 (defcustom gnus-cached-mark ?*
483 "*Mark used for articles that are in the cache."
484 :group 'gnus-summary-marks
487 (defcustom gnus-saved-mark ?S
488 "*Mark used for articles that have been saved."
489 :group 'gnus-summary-marks
492 (defcustom gnus-unseen-mark ?.
493 "*Mark used for articles that haven't been seen."
494 :group 'gnus-summary-marks
497 (defcustom gnus-no-mark ?\ ;;;Whitespace
498 "*Mark used for articles that have no other secondary mark."
499 :group 'gnus-summary-marks
502 (defcustom gnus-ancient-mark ?O
503 "*Mark used for ancient articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-sparse-mark ?Q
508 "*Mark used for sparsely reffed articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-canceled-mark ?G
513 "*Mark used for canceled articles."
514 :group 'gnus-summary-marks
517 (defcustom gnus-duplicate-mark ?M
518 "*Mark used for duplicate articles."
519 :group 'gnus-summary-marks
522 (defcustom gnus-undownloaded-mark ?@
523 "*Mark used for articles that weren't downloaded."
524 :group 'gnus-summary-marks
527 (defcustom gnus-downloadable-mark ?%
528 "*Mark used for articles that are to be downloaded."
529 :group 'gnus-summary-marks
532 (defcustom gnus-unsendable-mark ?=
533 "*Mark used for articles that won't be sent."
534 :group 'gnus-summary-marks
537 (defcustom gnus-score-over-mark ?+
538 "*Score mark used for articles with high scores."
539 :group 'gnus-summary-marks
542 (defcustom gnus-score-below-mark ?-
543 "*Score mark used for articles with low scores."
544 :group 'gnus-summary-marks
547 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
548 "*There is no thread under the article."
549 :group 'gnus-summary-marks
552 (defcustom gnus-not-empty-thread-mark ?=
553 "*There is a thread under the article."
554 :group 'gnus-summary-marks
557 (defcustom gnus-view-pseudo-asynchronously nil
558 "*If non-nil, Gnus will view pseudo-articles asynchronously."
559 :group 'gnus-extract-view
562 (defcustom gnus-auto-expirable-marks
563 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
564 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
565 gnus-souped-mark gnus-duplicate-mark)
566 "*The list of marks converted into expiration if a group is auto-expirable."
569 :type '(repeat character))
571 (defcustom gnus-inhibit-user-auto-expire t
572 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
577 (defcustom gnus-view-pseudos nil
578 "*If `automatic', pseudo-articles will be viewed automatically.
579 If `not-confirm', pseudos will be viewed automatically, and the user
580 will not be asked to confirm the command."
581 :group 'gnus-extract-view
582 :type '(choice (const :tag "off" nil)
584 (const not-confirm)))
586 (defcustom gnus-view-pseudos-separately t
587 "*If non-nil, one pseudo-article will be created for each file to be viewed.
588 If nil, all files that use the same viewing command will be given as a
589 list of parameters to that command."
590 :group 'gnus-extract-view
593 (defcustom gnus-insert-pseudo-articles t
594 "*If non-nil, insert pseudo-articles when decoding articles."
595 :group 'gnus-extract-view
598 (defcustom gnus-summary-dummy-line-format
600 "*The format specification for the dummy roots in the summary buffer.
601 It works along the same lines as a normal formatting string,
602 with some simple extensions.
606 General format specifiers can also be used.
607 See (gnus)Formatting Variables."
608 :link '(custom-manual "(gnus)Formatting Variables")
609 :group 'gnus-threading
612 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
613 "*The format specification for the summary mode line.
614 It works along the same lines as a normal formatting string,
615 with some simple extensions:
618 %p Unprefixed group name
619 %A Current article number
620 %z Current article score
622 %U Number of unread articles in the group
623 %e Number of unselected articles in the group
624 %Z A string with unread/unselected article counts
625 %g Shortish group name
626 %S Subject of the current article
628 %s Current score file name
629 %d Number of dormant articles
630 %r Number of articles that have been marked as read in this session
631 %E Number of articles expunged by the score files"
632 :group 'gnus-summary-format
635 (defcustom gnus-list-identifiers nil
636 "Regexp that matches list identifiers to be removed from subject.
637 This can also be a list of regexps."
639 :group 'gnus-summary-format
640 :group 'gnus-article-hiding
641 :type '(choice (const :tag "none" nil)
643 (repeat :value (".*") regexp)))
645 (defcustom gnus-summary-mark-below 0
646 "*Mark all articles with a score below this variable as read.
647 This variable is local to each summary buffer and usually set by the
649 :group 'gnus-score-default
652 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
653 "*List of functions used for sorting articles in the summary buffer.
655 Each function takes two articles and returns non-nil if the first
656 article should be sorted before the other. If you use more than one
657 function, the primary sort function should be the last. You should
658 probably always include `gnus-article-sort-by-number' in the list of
659 sorting functions -- preferably first. Also note that sorting by date
660 is often much slower than sorting by number, and the sorting order is
661 very similar. (Sorting by date means sorting by the time the message
662 was sent, sorting by number means sorting by arrival time.)
664 Ready-made functions include `gnus-article-sort-by-number',
665 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
666 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
668 When threading is turned on, the variable `gnus-thread-sort-functions'
669 controls how articles are sorted."
670 :group 'gnus-summary-sort
671 :type '(repeat (choice (function-item gnus-article-sort-by-number)
672 (function-item gnus-article-sort-by-author)
673 (function-item gnus-article-sort-by-subject)
674 (function-item gnus-article-sort-by-date)
675 (function-item gnus-article-sort-by-score)
676 (function :tag "other"))))
678 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
679 "*List of functions used for sorting threads in the summary buffer.
680 By default, threads are sorted by article number.
682 Each function takes two threads and returns non-nil if the first
683 thread should be sorted before the other. If you use more than one
684 function, the primary sort function should be the last. You should
685 probably always include `gnus-thread-sort-by-number' in the list of
686 sorting functions -- preferably first. Also note that sorting by date
687 is often much slower than sorting by number, and the sorting order is
688 very similar. (Sorting by date means sorting by the time the message
689 was sent, sorting by number means sorting by arrival time.)
691 Ready-made functions include `gnus-thread-sort-by-number',
692 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
693 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
694 `gnus-thread-sort-by-most-recent-number',
695 `gnus-thread-sort-by-most-recent-date', and
696 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
698 When threading is turned off, the variable
699 `gnus-article-sort-functions' controls how articles are sorted."
700 :group 'gnus-summary-sort
701 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
702 (function-item gnus-thread-sort-by-author)
703 (function-item gnus-thread-sort-by-subject)
704 (function-item gnus-thread-sort-by-date)
705 (function-item gnus-thread-sort-by-score)
706 (function-item gnus-thread-sort-by-total-score)
707 (function :tag "other"))))
709 (defcustom gnus-thread-score-function '+
710 "*Function used for calculating the total score of a thread.
712 The function is called with the scores of the article and each
713 subthread and should then return the score of the thread.
715 Some functions you can use are `+', `max', or `min'."
716 :group 'gnus-summary-sort
719 (defcustom gnus-summary-expunge-below nil
720 "All articles that have a score less than this variable will be expunged.
721 This variable is local to the summary buffers."
722 :group 'gnus-score-default
723 :type '(choice (const :tag "off" nil)
726 (defcustom gnus-thread-expunge-below nil
727 "All threads that have a total score less than this variable will be expunged.
728 See `gnus-thread-score-function' for en explanation of what a
731 This variable is local to the summary buffers."
732 :group 'gnus-threading
733 :group 'gnus-score-default
734 :type '(choice (const :tag "off" nil)
737 (defcustom gnus-summary-mode-hook nil
738 "*A hook for Gnus summary mode.
739 This hook is run before any variables are set in the summary buffer."
740 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
741 :group 'gnus-summary-various
744 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
745 (when (featurep 'xemacs)
746 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
747 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
748 (add-hook 'gnus-summary-mode-hook
749 'gnus-xmas-switch-horizontal-scrollbar-off))
751 (defcustom gnus-summary-menu-hook nil
752 "*Hook run after the creation of the summary mode menu."
753 :group 'gnus-summary-visual
756 (defcustom gnus-summary-exit-hook nil
757 "*A hook called on exit from the summary buffer.
758 It will be called with point in the group buffer."
759 :group 'gnus-summary-exit
762 (defcustom gnus-summary-prepare-hook nil
763 "*A hook called after the summary buffer has been generated.
764 If you want to modify the summary buffer, you can use this hook."
765 :group 'gnus-summary-various
768 (defcustom gnus-summary-prepared-hook nil
769 "*A hook called as the last thing after the summary buffer has been generated."
770 :group 'gnus-summary-various
773 (defcustom gnus-summary-generate-hook nil
774 "*A hook run just before generating the summary buffer.
775 This hook is commonly used to customize threading variables and the
777 :group 'gnus-summary-various
780 (defcustom gnus-select-group-hook nil
781 "*A hook called when a newsgroup is selected.
783 If you'd like to simplify subjects like the
784 `gnus-summary-next-same-subject' command does, you can use the
787 (add-hook gnus-select-group-hook
789 (mapcar (lambda (header)
790 (mail-header-set-subject
792 (gnus-simplify-subject
793 (mail-header-subject header) 're-only)))
794 gnus-newsgroup-headers)))"
795 :group 'gnus-group-select
798 (defcustom gnus-select-article-hook nil
799 "*A hook called when an article is selected."
800 :group 'gnus-summary-choose
803 (defcustom gnus-visual-mark-article-hook
804 (list 'gnus-highlight-selected-summary)
805 "*Hook run after selecting an article in the summary buffer.
806 It is meant to be used for highlighting the article in some way. It
807 is not run if `gnus-visual' is nil."
808 :group 'gnus-summary-visual
811 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
812 "*A hook called before parsing the headers."
816 (defcustom gnus-exit-group-hook nil
817 "*A hook called when exiting summary mode.
818 This hook is not called from the non-updating exit commands like `Q'."
822 (defcustom gnus-summary-update-hook
823 (list 'gnus-summary-highlight-line)
824 "*A hook called when a summary line is changed.
825 The hook will not be called if `gnus-visual' is nil.
827 The default function `gnus-summary-highlight-line' will
828 highlight the line according to the `gnus-summary-highlight'
830 :group 'gnus-summary-visual
833 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
834 "*A hook called when an article is selected for the first time.
835 The hook is intended to mark an article as read (or unread)
836 automatically when it is selected."
837 :group 'gnus-summary-choose
840 (defcustom gnus-group-no-more-groups-hook nil
841 "*A hook run when returning to group mode having no more (unread) groups."
842 :group 'gnus-group-select
845 (defcustom gnus-ps-print-hook nil
846 "*A hook run before ps-printing something from Gnus."
850 (defcustom gnus-summary-display-arrow
851 (and (fboundp 'display-graphic-p)
853 "*If non-nil, display an arrow highlighting the current article."
858 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
859 "Face used for highlighting the current article in the summary buffer."
860 :group 'gnus-summary-visual
863 (defcustom gnus-summary-highlight
864 '(((= mark gnus-canceled-mark)
865 . gnus-summary-cancelled-face)
866 ((and (> score default-high)
867 (or (= mark gnus-dormant-mark)
868 (= mark gnus-ticked-mark)))
869 . gnus-summary-high-ticked-face)
870 ((and (< score default-low)
871 (or (= mark gnus-dormant-mark)
872 (= mark gnus-ticked-mark)))
873 . gnus-summary-low-ticked-face)
874 ((or (= mark gnus-dormant-mark)
875 (= mark gnus-ticked-mark))
876 . gnus-summary-normal-ticked-face)
877 ((and (> score default-high) (= mark gnus-ancient-mark))
878 . gnus-summary-high-ancient-face)
879 ((and (< score default-low) (= mark gnus-ancient-mark))
880 . gnus-summary-low-ancient-face)
881 ((= mark gnus-ancient-mark)
882 . gnus-summary-normal-ancient-face)
883 ((and (> score default-high) (= mark gnus-unread-mark))
884 . gnus-summary-high-unread-face)
885 ((and (< score default-low) (= mark gnus-unread-mark))
886 . gnus-summary-low-unread-face)
887 ((= mark gnus-unread-mark)
888 . gnus-summary-normal-unread-face)
889 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
890 gnus-undownloaded-mark)))
891 . gnus-summary-high-unread-face)
892 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
893 gnus-undownloaded-mark)))
894 . gnus-summary-low-unread-face)
895 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
896 (memq article gnus-newsgroup-unreads))
897 . gnus-summary-normal-unread-face)
898 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
899 . gnus-summary-normal-read-face)
900 ((> score default-high)
901 . gnus-summary-high-read-face)
902 ((< score default-low)
903 . gnus-summary-low-read-face)
905 . gnus-summary-normal-read-face))
906 "*Controls the highlighting of summary buffer lines.
908 A list of (FORM . FACE) pairs. When deciding how a a particular
909 summary line should be displayed, each form is evaluated. The content
910 of the face field after the first true form is used. You can change
911 how those summary lines are displayed, by editing the face field.
913 You can use the following variables in the FORM field.
915 score: The article's score
916 default: The default article score.
917 default-high: The default score for high scored articles.
918 default-low: The default score for low scored articles.
919 below: The score below which articles are automatically marked as read.
920 mark: The articles mark."
921 :group 'gnus-summary-visual
922 :type '(repeat (cons (sexp :tag "Form" nil)
925 (defcustom gnus-alter-header-function nil
926 "Function called to allow alteration of article header structures.
927 The function is called with one parameter, the article header vector,
928 which it may alter in any way.")
930 (defvar gnus-decode-encoded-word-function
931 (mime-find-field-decoder 'From 'nov)
932 "Variable that says which function should be used to decode a string with encoded words.")
934 (defcustom gnus-extra-headers '(To Newsgroups)
935 "*Extra headers to parse."
938 :type '(repeat symbol))
940 (defcustom gnus-ignored-from-addresses
941 (and user-mail-address (regexp-quote user-mail-address))
942 "*Regexp of From headers that may be suppressed in favor of To headers."
947 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
948 "List of charsets that should be ignored.
949 When these charsets are used in the \"charset\" parameter, the
950 default charset will be used instead."
952 :type '(repeat symbol)
953 :group 'gnus-charset)
955 (gnus-define-group-parameter
959 "Return the ignored charsets of GROUP."
960 :variable gnus-group-ignored-charsets-alist
962 '(("alt\\.chinese\\.text" iso-8859-1))
964 "Alist of regexps (to match group names) and charsets that should be ignored.
965 When these charsets are used in the \"charset\" parameter, the
966 default charset will be used instead."
967 :variable-group gnus-charset
968 :variable-type '(repeat (cons (regexp :tag "Group")
970 :parameter-type '(choice :tag "Ignored charsets"
973 :parameter-document "\
974 List of charsets that should be ignored.
976 When these charsets are used in the \"charset\" parameter, the
977 default charset will be used instead.")
979 (defcustom gnus-group-highlight-words-alist nil
980 "Alist of group regexps and highlight regexps.
981 This variable uses the same syntax as `gnus-emphasis-alist'."
983 :type '(repeat (cons (regexp :tag "Group")
984 (repeat (list (regexp :tag "Highlight regexp")
985 (number :tag "Group for entire word" 0)
986 (number :tag "Group for displayed part" 0)
988 gnus-emphasis-highlight-words)))))
989 :group 'gnus-summary-visual)
991 (defcustom gnus-use-wheel nil
992 "Use Intelli-mouse on summary movement"
994 :group 'gnus-summary-maneuvering)
996 (defcustom gnus-wheel-scroll-amount '(5 . 1)
997 "Amount to scroll messages by spinning the mouse wheel.
998 This is actually a cons cell, where the first item is the amount to scroll
999 on a normal wheel event, and the second is the amount to scroll when the
1000 wheel is moved with the shift key depressed."
1001 :type '(cons (integer :tag "Shift") integer)
1002 :group 'gnus-summary-maneuvering)
1004 (defcustom gnus-wheel-edge-resistance 2
1005 "How hard it should be to change the current article
1006 by moving the mouse over the edge of the article window."
1008 :group 'gnus-summary-maneuvering)
1010 (defcustom gnus-summary-show-article-charset-alist
1012 "Alist of number and charset.
1013 The article will be shown with the charset corresponding to the
1015 For example: ((1 . cn-gb-2312) (2 . big5))."
1017 :type '(repeat (cons (number :tag "Argument" 1)
1018 (symbol :tag "Charset")))
1019 :group 'gnus-charset)
1021 (defcustom gnus-preserve-marks t
1022 "Whether marks are preserved when moving, copying and respooling messages."
1025 :group 'gnus-summary-marks)
1027 (defcustom gnus-alter-articles-to-read-function nil
1028 "Function to be called to alter the list of articles to be selected."
1029 :type '(choice (const nil) function)
1030 :group 'gnus-summary)
1032 (defcustom gnus-orphan-score nil
1033 "*All orphans get this score added. Set in the score file."
1034 :group 'gnus-score-default
1035 :type '(choice (const nil)
1038 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1039 "*A regexp to match MIME parts when saving multiple parts of a message
1040 with gnus-summary-save-parts (X m). This regexp will be used by default
1041 when prompting the user for which type of files to save."
1042 :group 'gnus-summary
1046 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1047 "*A regexp to match MIME parts when saving multiple parts of a message
1048 with gnus-summary-save-parts (X m). This regexp will be used by default
1049 when prompting the user for which type of files to save."
1050 :group 'gnus-summary
1053 (defcustom gnus-read-all-available-headers nil
1054 "Whether Gnus should parse all headers made available to it.
1055 This is mostly relevant for slow backends where the user may
1056 wish to widen the summary buffer to include all headers
1057 that were fetched. Say, for nnultimate groups."
1058 :group 'gnus-summary
1059 :type '(choice boolean regexp))
1061 (defcustom gnus-summary-muttprint-program "muttprint"
1062 "Command (and optional arguments) used to run Muttprint."
1063 :group 'gnus-summary
1066 ;;; Internal variables
1068 (defvar gnus-summary-display-cache nil)
1069 (defvar gnus-article-mime-handles nil)
1070 (defvar gnus-article-decoded-p nil)
1071 (defvar gnus-article-charset nil)
1072 (defvar gnus-article-ignored-charsets nil)
1073 (defvar gnus-scores-exclude-files nil)
1074 (defvar gnus-page-broken nil)
1075 (defvar gnus-inhibit-mime-unbuttonizing nil)
1077 (defvar gnus-original-article nil)
1078 (defvar gnus-article-internal-prepare-hook nil)
1079 (defvar gnus-newsgroup-process-stack nil)
1081 (defvar gnus-thread-indent-array nil)
1082 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1083 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1084 "Function called to sort the articles within a thread after it has been gathered together.")
1086 (defvar gnus-summary-save-parts-type-history nil)
1087 (defvar gnus-summary-save-parts-last-directory nil)
1089 (defvar gnus-summary-save-parts-type-history nil)
1090 (defvar gnus-summary-save-parts-last-directory nil)
1092 ;; Avoid highlighting in kill files.
1093 (defvar gnus-summary-inhibit-highlight nil)
1094 (defvar gnus-newsgroup-selected-overlay nil)
1095 (defvar gnus-inhibit-limiting nil)
1096 (defvar gnus-newsgroup-adaptive-score-file nil)
1097 (defvar gnus-current-score-file nil)
1098 (defvar gnus-current-move-group nil)
1099 (defvar gnus-current-copy-group nil)
1100 (defvar gnus-current-crosspost-group nil)
1101 (defvar gnus-newsgroup-display nil)
1103 (defvar gnus-newsgroup-dependencies nil)
1104 (defvar gnus-newsgroup-adaptive nil)
1105 (defvar gnus-summary-display-article-function nil)
1106 (defvar gnus-summary-highlight-line-function nil
1107 "Function called after highlighting a summary line.")
1109 (defvar gnus-summary-line-format-alist
1110 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1111 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1112 (?s gnus-tmp-subject-or-nil ?s)
1113 (?n gnus-tmp-name ?s)
1114 (?A (std11-address-string
1115 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1116 (?a (or (std11-full-name-string
1117 (car (mime-entity-read-field gnus-tmp-header 'From)))
1119 (?F gnus-tmp-from ?s)
1120 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1121 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1122 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1123 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1124 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1125 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1126 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1127 (?L gnus-tmp-lines ?s)
1128 (?I gnus-tmp-indentation ?s)
1129 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1130 (?R gnus-tmp-replied ?c)
1131 (?\[ gnus-tmp-opening-bracket ?c)
1132 (?\] gnus-tmp-closing-bracket ?c)
1133 (?\> (make-string gnus-tmp-level ? ) ?s)
1134 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1135 (?i gnus-tmp-score ?d)
1136 (?z gnus-tmp-score-char ?c)
1137 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1138 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1139 (?U gnus-tmp-unread ?c)
1140 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1142 (?t (gnus-summary-number-of-articles-in-thread
1143 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1145 (?e (gnus-summary-number-of-articles-in-thread
1146 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1148 (?u gnus-tmp-user-defined ?s)
1149 (?P (gnus-pick-line-number) ?d)
1150 (?B gnus-tmp-thread-tree-header-string ?s)
1151 (user-date (gnus-user-date
1152 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1153 "An alist of format specifications that can appear in summary lines.
1154 These are paired with what variables they correspond with, along with
1155 the type of the variable (string, integer, character, etc).")
1157 (defvar gnus-summary-dummy-line-format-alist
1158 `((?S gnus-tmp-subject ?s)
1159 (?N gnus-tmp-number ?d)
1160 (?u gnus-tmp-user-defined ?s)))
1162 (defvar gnus-summary-mode-line-format-alist
1163 `((?G gnus-tmp-group-name ?s)
1164 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1165 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1166 (?A gnus-tmp-article-number ?d)
1167 (?Z gnus-tmp-unread-and-unselected ?s)
1168 (?V gnus-version ?s)
1169 (?U gnus-tmp-unread-and-unticked ?d)
1170 (?S gnus-tmp-subject ?s)
1171 (?e gnus-tmp-unselected ?d)
1172 (?u gnus-tmp-user-defined ?s)
1173 (?d (length gnus-newsgroup-dormant) ?d)
1174 (?t (length gnus-newsgroup-marked) ?d)
1175 (?r (length gnus-newsgroup-reads) ?d)
1176 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1177 (?E gnus-newsgroup-expunged-tally ?d)
1178 (?s (gnus-current-score-file-nondirectory) ?s)))
1180 (defvar gnus-last-search-regexp nil
1181 "Default regexp for article search command.")
1183 (defvar gnus-summary-search-article-matched-data nil
1184 "Last matched data of article search command. It is the local variable
1185 in `gnus-article-buffer' which consists of the list of start position,
1186 end position and text.")
1188 (defvar gnus-last-shell-command nil
1189 "Default shell command on article.")
1191 (defvar gnus-newsgroup-begin nil)
1192 (defvar gnus-newsgroup-end nil)
1193 (defvar gnus-newsgroup-last-rmail nil)
1194 (defvar gnus-newsgroup-last-mail nil)
1195 (defvar gnus-newsgroup-last-folder nil)
1196 (defvar gnus-newsgroup-last-file nil)
1197 (defvar gnus-newsgroup-auto-expire nil)
1198 (defvar gnus-newsgroup-active nil)
1200 (defvar gnus-newsgroup-data nil)
1201 (defvar gnus-newsgroup-data-reverse nil)
1202 (defvar gnus-newsgroup-limit nil)
1203 (defvar gnus-newsgroup-limits nil)
1205 (defvar gnus-newsgroup-unreads nil
1206 "List of unread articles in the current newsgroup.")
1208 (defvar gnus-newsgroup-unselected nil
1209 "List of unselected unread articles in the current newsgroup.")
1211 (defvar gnus-newsgroup-reads nil
1212 "Alist of read articles and article marks in the current newsgroup.")
1214 (defvar gnus-newsgroup-expunged-tally nil)
1216 (defvar gnus-newsgroup-marked nil
1217 "List of ticked articles in the current newsgroup (a subset of unread art).")
1219 (defvar gnus-newsgroup-killed nil
1220 "List of ranges of articles that have been through the scoring process.")
1222 (defvar gnus-newsgroup-cached nil
1223 "List of articles that come from the article cache.")
1225 (defvar gnus-newsgroup-saved nil
1226 "List of articles that have been saved.")
1228 (defvar gnus-newsgroup-kill-headers nil)
1230 (defvar gnus-newsgroup-replied nil
1231 "List of articles that have been replied to in the current newsgroup.")
1233 (defvar gnus-newsgroup-forwarded nil
1234 "List of articles that have been forwarded in the current newsgroup.")
1236 (defvar gnus-newsgroup-recent nil
1237 "List of articles that have are recent in the current newsgroup.")
1239 (defvar gnus-newsgroup-expirable nil
1240 "List of articles in the current newsgroup that can be expired.")
1242 (defvar gnus-newsgroup-processable nil
1243 "List of articles in the current newsgroup that can be processed.")
1245 (defvar gnus-newsgroup-downloadable nil
1246 "List of articles in the current newsgroup that can be processed.")
1248 (defvar gnus-newsgroup-undownloaded nil
1249 "List of articles in the current newsgroup that haven't been downloaded..")
1251 (defvar gnus-newsgroup-unsendable nil
1252 "List of articles in the current newsgroup that won't be sent.")
1254 (defvar gnus-newsgroup-bookmarks nil
1255 "List of articles in the current newsgroup that have bookmarks.")
1257 (defvar gnus-newsgroup-dormant nil
1258 "List of dormant articles in the current newsgroup.")
1260 (defvar gnus-newsgroup-unseen nil
1261 "List of unseen articles in the current newsgroup.")
1263 (defvar gnus-newsgroup-seen nil
1264 "Range of seen articles in the current newsgroup.")
1266 (defvar gnus-newsgroup-articles nil
1267 "List of articles in the current newsgroup.")
1269 (defvar gnus-newsgroup-scored nil
1270 "List of scored articles in the current newsgroup.")
1272 (defvar gnus-newsgroup-incorporated nil
1273 "List of incorporated articles in the current newsgroup.")
1275 (defvar gnus-newsgroup-headers nil
1276 "List of article headers in the current newsgroup.")
1278 (defvar gnus-newsgroup-threads nil)
1280 (defvar gnus-newsgroup-prepared nil
1281 "Whether the current group has been prepared properly.")
1283 (defvar gnus-newsgroup-ancient nil
1284 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1286 (defvar gnus-newsgroup-sparse nil)
1288 (defvar gnus-current-article nil)
1289 (defvar gnus-article-current nil)
1290 (defvar gnus-current-headers nil)
1291 (defvar gnus-have-all-headers nil)
1292 (defvar gnus-last-article nil)
1293 (defvar gnus-newsgroup-history nil)
1294 (defvar gnus-newsgroup-charset nil)
1295 (defvar gnus-newsgroup-ephemeral-charset nil)
1296 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1298 (defvar gnus-article-before-search nil)
1300 (defconst gnus-summary-local-variables
1301 '(gnus-newsgroup-name
1302 gnus-newsgroup-begin gnus-newsgroup-end
1303 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1304 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1305 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1306 gnus-newsgroup-unselected gnus-newsgroup-marked
1307 gnus-newsgroup-reads gnus-newsgroup-saved
1308 gnus-newsgroup-replied gnus-newsgroup-forwarded
1309 gnus-newsgroup-recent
1310 gnus-newsgroup-expirable
1311 gnus-newsgroup-processable gnus-newsgroup-killed
1312 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1313 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1314 gnus-newsgroup-seen gnus-newsgroup-articles
1315 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1316 gnus-newsgroup-headers gnus-newsgroup-threads
1317 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1318 gnus-current-article gnus-current-headers gnus-have-all-headers
1319 gnus-last-article gnus-article-internal-prepare-hook
1320 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1321 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1322 gnus-thread-expunge-below
1323 gnus-score-alist gnus-current-score-file
1324 (gnus-summary-expunge-below . global)
1325 (gnus-summary-mark-below . global)
1326 (gnus-orphan-score . global)
1327 gnus-newsgroup-active gnus-scores-exclude-files
1328 gnus-newsgroup-history gnus-newsgroup-ancient
1329 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1330 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1331 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1332 (gnus-newsgroup-expunged-tally . 0)
1333 gnus-cache-removable-articles gnus-newsgroup-cached
1334 gnus-newsgroup-data gnus-newsgroup-data-reverse
1335 gnus-newsgroup-limit gnus-newsgroup-limits
1336 gnus-newsgroup-charset gnus-newsgroup-display
1337 gnus-newsgroup-incorporated)
1338 "Variables that are buffer-local to the summary buffers.")
1340 (defvar gnus-newsgroup-variables nil
1341 "A list of variables that have separate values in different newsgroups.
1342 A list of newsgroup (summary buffer) local variables, or cons of
1343 variables and their default values (when the default values are not
1344 nil), that should be made global while the summary buffer is active.
1345 These variables can be used to set variables in the group parameters
1346 while still allowing them to affect operations done in other
1347 buffers. For example:
1349 \(setq gnus-newsgroup-variables
1350 '(message-use-followup-to
1351 (gnus-visible-headers .
1352 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1355 ;; Byte-compiler warning.
1356 (eval-when-compile (defvar gnus-article-mode-map))
1358 ;; Subject simplification.
1360 (defun gnus-simplify-whitespace (str)
1361 "Remove excessive whitespace from STR."
1364 (while (string-match "[ \t][ \t]+" mystr)
1365 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1367 (substring mystr (match-end 0)))))
1369 (when (string-match "^[ \t]+" mystr)
1370 (setq mystr (substring mystr (match-end 0))))
1372 (when (string-match "[ \t]+$" mystr)
1373 (setq mystr (substring mystr 0 (match-beginning 0))))
1376 (defsubst gnus-simplify-subject-re (subject)
1377 "Remove \"Re:\" from subject lines."
1378 (if (string-match message-subject-re-regexp subject)
1379 (substring subject (match-end 0))
1382 (defun gnus-simplify-subject (subject &optional re-only)
1383 "Remove `Re:' and words in parentheses.
1384 If RE-ONLY is non-nil, strip leading `Re:'s only."
1385 (let ((case-fold-search t)) ;Ignore case.
1386 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1387 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1388 (setq subject (substring subject (match-end 0))))
1389 ;; Remove uninteresting prefixes.
1390 (when (and (not re-only)
1391 gnus-simplify-ignored-prefixes
1392 (string-match gnus-simplify-ignored-prefixes subject))
1393 (setq subject (substring subject (match-end 0))))
1394 ;; Remove words in parentheses from end.
1396 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1397 (setq subject (substring subject 0 (match-beginning 0)))))
1398 ;; Return subject string.
1401 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1403 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1404 (goto-char (point-min))
1405 (while (re-search-forward regexp nil t)
1406 (replace-match (or newtext ""))))
1408 (defun gnus-simplify-buffer-fuzzy ()
1409 "Simplify string in the buffer fuzzily.
1410 The string in the accessible portion of the current buffer is simplified.
1411 It is assumed to be a single-line subject.
1412 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1413 matter is removed. Additional things can be deleted by setting
1414 `gnus-simplify-subject-fuzzy-regexp'."
1415 (let ((case-fold-search t)
1417 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1419 (while (not (eq modified-tick (buffer-modified-tick)))
1420 (setq modified-tick (buffer-modified-tick))
1422 ((listp gnus-simplify-subject-fuzzy-regexp)
1423 (mapcar 'gnus-simplify-buffer-fuzzy-step
1424 gnus-simplify-subject-fuzzy-regexp))
1425 (gnus-simplify-subject-fuzzy-regexp
1426 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1427 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1428 (gnus-simplify-buffer-fuzzy-step
1429 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1430 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1432 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1433 (gnus-simplify-buffer-fuzzy-step " +" " ")
1434 (gnus-simplify-buffer-fuzzy-step " $")
1435 (gnus-simplify-buffer-fuzzy-step "^ +")))
1437 (defun gnus-simplify-subject-fuzzy (subject)
1438 "Simplify a subject string fuzzily.
1439 See `gnus-simplify-buffer-fuzzy' for details."
1441 (gnus-set-work-buffer)
1442 (let ((case-fold-search t))
1443 ;; Remove uninteresting prefixes.
1444 (when (and gnus-simplify-ignored-prefixes
1445 (string-match gnus-simplify-ignored-prefixes subject))
1446 (setq subject (substring subject (match-end 0))))
1448 (inline (gnus-simplify-buffer-fuzzy))
1451 (defsubst gnus-simplify-subject-fully (subject)
1452 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1454 (gnus-simplify-subject-functions
1455 (gnus-map-function gnus-simplify-subject-functions subject))
1456 ((null gnus-summary-gather-subject-limit)
1457 (gnus-simplify-subject-re subject))
1458 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1459 (gnus-simplify-subject-fuzzy subject))
1460 ((numberp gnus-summary-gather-subject-limit)
1461 (gnus-limit-string (gnus-simplify-subject-re subject)
1462 gnus-summary-gather-subject-limit))
1466 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1467 "Check whether two subjects are equal.
1468 If optional argument simple-first is t, first argument is already
1471 ((null simple-first)
1472 (equal (gnus-simplify-subject-fully s1)
1473 (gnus-simplify-subject-fully s2)))
1476 (gnus-simplify-subject-fully s2)))))
1478 (defun gnus-summary-bubble-group ()
1479 "Increase the score of the current group.
1480 This is a handy function to add to `gnus-summary-exit-hook' to
1481 increase the score of each group you read."
1482 (gnus-group-add-score gnus-newsgroup-name))
1486 ;;; Gnus summary mode
1489 (put 'gnus-summary-mode 'mode-class 'special)
1491 (defvar gnus-article-commands-menu)
1494 ;; Non-orthogonal keys
1496 (gnus-define-keys gnus-summary-mode-map
1497 " " gnus-summary-next-page
1498 "\177" gnus-summary-prev-page
1499 [delete] gnus-summary-prev-page
1500 [backspace] gnus-summary-prev-page
1501 "\r" gnus-summary-scroll-up
1502 "\M-\r" gnus-summary-scroll-down
1503 "n" gnus-summary-next-unread-article
1504 "p" gnus-summary-prev-unread-article
1505 "N" gnus-summary-next-article
1506 "P" gnus-summary-prev-article
1507 "\M-\C-n" gnus-summary-next-same-subject
1508 "\M-\C-p" gnus-summary-prev-same-subject
1509 "\M-n" gnus-summary-next-unread-subject
1510 "\M-p" gnus-summary-prev-unread-subject
1511 "." gnus-summary-first-unread-article
1512 "," gnus-summary-best-unread-article
1513 "\M-s" gnus-summary-search-article-forward
1514 "\M-r" gnus-summary-search-article-backward
1515 "<" gnus-summary-beginning-of-article
1516 ">" gnus-summary-end-of-article
1517 "j" gnus-summary-goto-article
1518 "^" gnus-summary-refer-parent-article
1519 "\M-^" gnus-summary-refer-article
1520 "u" gnus-summary-tick-article-forward
1521 "!" gnus-summary-tick-article-forward
1522 "U" gnus-summary-tick-article-backward
1523 "d" gnus-summary-mark-as-read-forward
1524 "D" gnus-summary-mark-as-read-backward
1525 "E" gnus-summary-mark-as-expirable
1526 "\M-u" gnus-summary-clear-mark-forward
1527 "\M-U" gnus-summary-clear-mark-backward
1528 "k" gnus-summary-kill-same-subject-and-select
1529 "\C-k" gnus-summary-kill-same-subject
1530 "\M-\C-k" gnus-summary-kill-thread
1531 "\M-\C-l" gnus-summary-lower-thread
1532 "e" gnus-summary-edit-article
1533 "#" gnus-summary-mark-as-processable
1534 "\M-#" gnus-summary-unmark-as-processable
1535 "\M-\C-t" gnus-summary-toggle-threads
1536 "\M-\C-s" gnus-summary-show-thread
1537 "\M-\C-h" gnus-summary-hide-thread
1538 "\M-\C-f" gnus-summary-next-thread
1539 "\M-\C-b" gnus-summary-prev-thread
1540 [(meta down)] gnus-summary-next-thread
1541 [(meta up)] gnus-summary-prev-thread
1542 "\M-\C-u" gnus-summary-up-thread
1543 "\M-\C-d" gnus-summary-down-thread
1544 "&" gnus-summary-execute-command
1545 "c" gnus-summary-catchup-and-exit
1546 "\C-w" gnus-summary-mark-region-as-read
1547 "\C-t" gnus-summary-toggle-truncation
1548 "?" gnus-summary-mark-as-dormant
1549 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1550 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1551 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1552 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1553 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1554 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1555 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1556 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1557 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1558 "=" gnus-summary-expand-window
1559 "\C-x\C-s" gnus-summary-reselect-current-group
1560 "\M-g" gnus-summary-rescan-group
1561 "w" gnus-summary-stop-page-breaking
1562 "\C-c\C-r" gnus-summary-caesar-message
1563 "\M-t" gnus-summary-toggle-mime
1564 "f" gnus-summary-followup
1565 "F" gnus-summary-followup-with-original
1566 "C" gnus-summary-cancel-article
1567 "r" gnus-summary-reply
1568 "R" gnus-summary-reply-with-original
1569 "\C-c\C-f" gnus-summary-mail-forward
1570 "o" gnus-summary-save-article
1571 "\C-o" gnus-summary-save-article-mail
1572 "|" gnus-summary-pipe-output
1573 "\M-k" gnus-summary-edit-local-kill
1574 "\M-K" gnus-summary-edit-global-kill
1576 "\C-c\C-d" gnus-summary-describe-group
1577 "q" gnus-summary-exit
1578 "Q" gnus-summary-exit-no-update
1579 "\C-c\C-i" gnus-info-find-node
1580 gnus-mouse-2 gnus-mouse-pick-article
1581 "m" gnus-summary-mail-other-window
1582 "a" gnus-summary-post-news
1583 "i" gnus-summary-news-other-window
1584 "x" gnus-summary-limit-to-unread
1585 "s" gnus-summary-isearch-article
1586 "t" gnus-article-toggle-headers
1587 "g" gnus-summary-show-article
1588 "l" gnus-summary-goto-last-article
1589 "v" gnus-summary-preview-mime-message
1590 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1591 "\C-d" gnus-summary-enter-digest-group
1592 "\M-\C-d" gnus-summary-read-document
1593 "\M-\C-e" gnus-summary-edit-parameters
1594 "\M-\C-a" gnus-summary-customize-parameters
1596 "\C-c\C-n" gnus-namazu-search
1597 "*" gnus-cache-enter-article
1598 "\M-*" gnus-cache-remove-article
1599 "\M-&" gnus-summary-universal-argument
1600 "\C-l" gnus-recenter
1601 "I" gnus-summary-increase-score
1602 "L" gnus-summary-lower-score
1603 "\M-i" gnus-symbolic-argument
1604 "h" gnus-summary-select-article-buffer
1606 "V" gnus-summary-score-map
1607 "X" gnus-uu-extract-map
1608 "S" gnus-summary-send-map)
1610 ;; Sort of orthogonal keymap
1611 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1612 "t" gnus-summary-tick-article-forward
1613 "!" gnus-summary-tick-article-forward
1614 "d" gnus-summary-mark-as-read-forward
1615 "r" gnus-summary-mark-as-read-forward
1616 "c" gnus-summary-clear-mark-forward
1617 " " gnus-summary-clear-mark-forward
1618 "e" gnus-summary-mark-as-expirable
1619 "x" gnus-summary-mark-as-expirable
1620 "?" gnus-summary-mark-as-dormant
1621 "b" gnus-summary-set-bookmark
1622 "B" gnus-summary-remove-bookmark
1623 "#" gnus-summary-mark-as-processable
1624 "\M-#" gnus-summary-unmark-as-processable
1625 "S" gnus-summary-limit-include-expunged
1626 "C" gnus-summary-catchup
1627 "H" gnus-summary-catchup-to-here
1628 "h" gnus-summary-catchup-from-here
1629 "\C-c" gnus-summary-catchup-all
1630 "k" gnus-summary-kill-same-subject-and-select
1631 "K" gnus-summary-kill-same-subject
1632 "P" gnus-uu-mark-map)
1634 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1635 "c" gnus-summary-clear-above
1636 "u" gnus-summary-tick-above
1637 "m" gnus-summary-mark-above
1638 "k" gnus-summary-kill-below)
1640 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1641 "/" gnus-summary-limit-to-subject
1642 "n" gnus-summary-limit-to-articles
1643 "w" gnus-summary-pop-limit
1644 "s" gnus-summary-limit-to-subject
1645 "a" gnus-summary-limit-to-author
1646 "u" gnus-summary-limit-to-unread
1647 "m" gnus-summary-limit-to-marks
1648 "M" gnus-summary-limit-exclude-marks
1649 "v" gnus-summary-limit-to-score
1650 "*" gnus-summary-limit-include-cached
1651 "D" gnus-summary-limit-include-dormant
1652 "T" gnus-summary-limit-include-thread
1653 "d" gnus-summary-limit-exclude-dormant
1654 "t" gnus-summary-limit-to-age
1655 "x" gnus-summary-limit-to-extra
1656 "p" gnus-summary-limit-to-display-predicate
1657 "E" gnus-summary-limit-include-expunged
1658 "c" gnus-summary-limit-exclude-childless-dormant
1659 "C" gnus-summary-limit-mark-excluded-as-read
1660 "o" gnus-summary-insert-old-articles
1661 "N" gnus-summary-insert-new-articles)
1663 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1664 "n" gnus-summary-next-unread-article
1665 "p" gnus-summary-prev-unread-article
1666 "N" gnus-summary-next-article
1667 "P" gnus-summary-prev-article
1668 "\C-n" gnus-summary-next-same-subject
1669 "\C-p" gnus-summary-prev-same-subject
1670 "\M-n" gnus-summary-next-unread-subject
1671 "\M-p" gnus-summary-prev-unread-subject
1672 "f" gnus-summary-first-unread-article
1673 "b" gnus-summary-best-unread-article
1674 "j" gnus-summary-goto-article
1675 "g" gnus-summary-goto-subject
1676 "l" gnus-summary-goto-last-article
1677 "o" gnus-summary-pop-article)
1679 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1680 "k" gnus-summary-kill-thread
1681 "l" gnus-summary-lower-thread
1682 "i" gnus-summary-raise-thread
1683 "T" gnus-summary-toggle-threads
1684 "t" gnus-summary-rethread-current
1685 "^" gnus-summary-reparent-thread
1686 "s" gnus-summary-show-thread
1687 "S" gnus-summary-show-all-threads
1688 "h" gnus-summary-hide-thread
1689 "H" gnus-summary-hide-all-threads
1690 "n" gnus-summary-next-thread
1691 "p" gnus-summary-prev-thread
1692 "u" gnus-summary-up-thread
1693 "o" gnus-summary-top-thread
1694 "d" gnus-summary-down-thread
1695 "#" gnus-uu-mark-thread
1696 "\M-#" gnus-uu-unmark-thread)
1698 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1699 "g" gnus-summary-prepare
1700 "c" gnus-summary-insert-cached-articles)
1702 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1703 "c" gnus-summary-catchup-and-exit
1704 "C" gnus-summary-catchup-all-and-exit
1705 "E" gnus-summary-exit-no-update
1706 "J" gnus-summary-jump-to-other-group
1707 "Q" gnus-summary-exit
1708 "Z" gnus-summary-exit
1709 "n" gnus-summary-catchup-and-goto-next-group
1710 "R" gnus-summary-reselect-current-group
1711 "G" gnus-summary-rescan-group
1712 "N" gnus-summary-next-group
1713 "s" gnus-summary-save-newsrc
1714 "P" gnus-summary-prev-group)
1716 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1717 " " gnus-summary-next-page
1718 "n" gnus-summary-next-page
1719 "\177" gnus-summary-prev-page
1720 [delete] gnus-summary-prev-page
1721 "p" gnus-summary-prev-page
1722 "\r" gnus-summary-scroll-up
1723 "\M-\r" gnus-summary-scroll-down
1724 "<" gnus-summary-beginning-of-article
1725 ">" gnus-summary-end-of-article
1726 "b" gnus-summary-beginning-of-article
1727 "e" gnus-summary-end-of-article
1728 "^" gnus-summary-refer-parent-article
1729 "r" gnus-summary-refer-parent-article
1730 "D" gnus-summary-enter-digest-group
1731 "R" gnus-summary-refer-references
1732 "T" gnus-summary-refer-thread
1733 "g" gnus-summary-show-article
1734 "s" gnus-summary-isearch-article
1735 "P" gnus-summary-print-article
1736 "M" gnus-mailing-list-insinuate
1737 "t" gnus-article-babel)
1739 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1740 "b" gnus-article-add-buttons
1741 "B" gnus-article-add-buttons-to-head
1742 "o" gnus-article-treat-overstrike
1743 "e" gnus-article-emphasize
1744 "w" gnus-article-fill-cited-article
1745 "Q" gnus-article-fill-long-lines
1746 "C" gnus-article-capitalize-sentences
1747 "c" gnus-article-remove-cr
1748 "Z" gnus-article-decode-HZ
1749 "h" gnus-article-wash-html
1750 "f" gnus-article-display-x-face
1751 "l" gnus-summary-stop-page-breaking
1752 "r" gnus-summary-caesar-message
1753 "t" gnus-article-toggle-headers
1754 "g" gnus-treat-smiley
1755 "v" gnus-summary-verbose-headers
1756 "m" gnus-summary-toggle-mime
1757 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1758 "p" gnus-article-verify-x-pgp-sig
1759 "d" gnus-article-treat-dumbquotes)
1761 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1762 "a" gnus-article-hide
1763 "h" gnus-article-toggle-headers
1764 "b" gnus-article-hide-boring-headers
1765 "s" gnus-article-hide-signature
1766 "c" gnus-article-hide-citation
1767 "C" gnus-article-hide-citation-in-followups
1768 "l" gnus-article-hide-list-identifiers
1769 "p" gnus-article-hide-pgp
1770 "B" gnus-article-strip-banner
1771 "P" gnus-article-hide-pem
1772 "\C-c" gnus-article-hide-citation-maybe)
1774 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1775 "a" gnus-article-highlight
1776 "h" gnus-article-highlight-headers
1777 "c" gnus-article-highlight-citation
1778 "s" gnus-article-highlight-signature)
1780 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1781 "f" gnus-article-treat-fold-headers
1782 "u" gnus-article-treat-unfold-headers
1783 "n" gnus-article-treat-fold-newsgroups)
1785 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1786 "x" gnus-article-display-x-face
1787 "s" gnus-treat-smiley
1788 "D" gnus-article-remove-images
1789 "f" gnus-treat-from-picon
1790 "m" gnus-treat-mail-picon
1791 "n" gnus-treat-newsgroups-picon)
1793 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1794 "z" gnus-article-date-ut
1795 "u" gnus-article-date-ut
1796 "l" gnus-article-date-local
1797 "p" gnus-article-date-english
1798 "e" gnus-article-date-lapsed
1799 "o" gnus-article-date-original
1800 "i" gnus-article-date-iso8601
1801 "s" gnus-article-date-user)
1803 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1804 "t" gnus-article-remove-trailing-blank-lines
1805 "l" gnus-article-strip-leading-blank-lines
1806 "m" gnus-article-strip-multiple-blank-lines
1807 "a" gnus-article-strip-blank-lines
1808 "A" gnus-article-strip-all-blank-lines
1809 "s" gnus-article-strip-leading-space
1810 "e" gnus-article-strip-trailing-space
1811 "w" gnus-article-remove-leading-whitespace)
1813 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1815 "f" gnus-summary-fetch-faq
1816 "d" gnus-summary-describe-group
1817 "h" gnus-summary-describe-briefly
1818 "i" gnus-info-find-node)
1820 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1821 "e" gnus-summary-expire-articles
1822 "\M-\C-e" gnus-summary-expire-articles-now
1823 "\177" gnus-summary-delete-article
1824 [delete] gnus-summary-delete-article
1825 [backspace] gnus-summary-delete-article
1826 "m" gnus-summary-move-article
1827 "r" gnus-summary-respool-article
1828 "w" gnus-summary-edit-article
1829 "c" gnus-summary-copy-article
1830 "B" gnus-summary-crosspost-article
1831 "q" gnus-summary-respool-query
1832 "t" gnus-summary-respool-trace
1833 "i" gnus-summary-import-article
1834 "I" gnus-summary-create-article
1835 "p" gnus-summary-article-posted-p)
1837 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1838 "o" gnus-summary-save-article
1839 "m" gnus-summary-save-article-mail
1840 "F" gnus-summary-write-article-file
1841 "r" gnus-summary-save-article-rmail
1842 "f" gnus-summary-save-article-file
1843 "b" gnus-summary-save-article-body-file
1844 "h" gnus-summary-save-article-folder
1845 "v" gnus-summary-save-article-vm
1846 "p" gnus-summary-pipe-output
1847 "P" gnus-summary-muttprint
1848 "s" gnus-soup-add-article)
1850 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1851 "b" gnus-summary-display-buttonized
1852 "m" gnus-summary-repair-multipart
1853 "v" gnus-article-view-part
1854 "o" gnus-article-save-part
1855 "c" gnus-article-copy-part
1856 "C" gnus-article-view-part-as-charset
1857 "e" gnus-article-externalize-part
1858 "E" gnus-article-encrypt-body
1859 "i" gnus-article-inline-part
1860 "|" gnus-article-pipe-part))
1862 (defvar gnus-article-post-menu nil)
1864 (defun gnus-summary-make-menu-bar ()
1865 (gnus-turn-off-edit-menu 'summary)
1867 (unless (boundp 'gnus-summary-misc-menu)
1870 gnus-summary-kill-menu gnus-summary-mode-map ""
1875 ["Customize" gnus-score-customize t])
1876 (gnus-make-score-map 'increase)
1877 (gnus-make-score-map 'lower)
1879 ["Kill below" gnus-summary-kill-below t]
1880 ["Mark above" gnus-summary-mark-above t]
1881 ["Tick above" gnus-summary-tick-above t]
1882 ["Clear above" gnus-summary-clear-above t])
1883 ["Current score" gnus-summary-current-score t]
1884 ["Set score" gnus-summary-set-score t]
1885 ["Switch current score file..." gnus-score-change-score-file t]
1886 ["Set mark below..." gnus-score-set-mark-below t]
1887 ["Set expunge below..." gnus-score-set-expunge-below t]
1888 ["Edit current score file" gnus-score-edit-current-scores t]
1889 ["Edit score file" gnus-score-edit-file t]
1890 ["Trace score" gnus-score-find-trace t]
1891 ["Find words" gnus-score-find-favourite-words t]
1892 ["Rescore buffer" gnus-summary-rescore t]
1893 ["Increase score..." gnus-summary-increase-score t]
1894 ["Lower score..." gnus-summary-lower-score t]))))
1896 ;; Define both the Article menu in the summary buffer and the
1897 ;; equivalent Commands menu in the article buffer here for
1901 ["All" gnus-article-hide t]
1902 ["Headers" gnus-article-toggle-headers t]
1903 ["Signature" gnus-article-hide-signature t]
1904 ["Citation" gnus-article-hide-citation t]
1905 ["List identifiers" gnus-article-hide-list-identifiers t]
1906 ["PGP" gnus-article-hide-pgp t]
1907 ["Banner" gnus-article-strip-banner t]
1908 ["Boring headers" gnus-article-hide-boring-headers t])
1910 ["All" gnus-article-highlight t]
1911 ["Headers" gnus-article-highlight-headers t]
1912 ["Signature" gnus-article-highlight-signature t]
1913 ["Citation" gnus-article-highlight-citation t])
1915 ["Local" gnus-article-date-local t]
1916 ["ISO8601" gnus-article-date-iso8601 t]
1917 ["UT" gnus-article-date-ut t]
1918 ["Original" gnus-article-date-original t]
1919 ["Lapsed" gnus-article-date-lapsed t]
1920 ["User-defined" gnus-article-date-user t])
1922 ["Remove images" gnus-article-remove-images t]
1923 ["Toggle smiley" gnus-treat-smiley t]
1924 ["Show X-Face" gnus-article-display-x-face t]
1925 ["Show picons in From" gnus-treat-from-picon t]
1926 ["Show picons in mail headers" gnus-treat-mail-picon t]
1927 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1930 ["Leading" gnus-article-strip-leading-blank-lines t]
1931 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1932 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1933 ["All of the above" gnus-article-strip-blank-lines t]
1934 ["All" gnus-article-strip-all-blank-lines t]
1935 ["Leading space" gnus-article-strip-leading-space t]
1936 ["Trailing space" gnus-article-strip-trailing-space t]
1937 ["Leading space in headers"
1938 gnus-article-remove-leading-whitespace t])
1939 ["Overstrike" gnus-article-treat-overstrike t]
1940 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1941 ["Emphasis" gnus-article-emphasize t]
1942 ["Word wrap" gnus-article-fill-cited-article t]
1943 ["Fill long lines" gnus-article-fill-long-lines t]
1944 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1945 ["CR" gnus-article-remove-cr t]
1946 ["Rot 13" gnus-summary-caesar-message
1947 ,@(if (featurep 'xemacs) '(t)
1948 '(:help "\"Caesar rotate\" article by 13"))]
1949 ["Unix pipe" gnus-summary-pipe-message t]
1950 ["Add buttons" gnus-article-add-buttons t]
1951 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1952 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1953 ["Toggle MIME" gnus-summary-toggle-mime t]
1954 ["Verbose header" gnus-summary-verbose-headers t]
1955 ["Toggle header" gnus-summary-toggle-header t]
1956 ["Unfold headers" gnus-article-treat-unfold-headers t]
1957 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1958 ["Html" gnus-article-wash-html t]
1959 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1960 ["HZ" gnus-article-decode-HZ t])
1962 ["Save in default format" gnus-summary-save-article
1963 ,@(if (featurep 'xemacs) '(t)
1964 '(:help "Save article using default method"))]
1965 ["Save in file" gnus-summary-save-article-file
1966 ,@(if (featurep 'xemacs) '(t)
1967 '(:help "Save article in file"))]
1968 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1969 ["Save in MH folder" gnus-summary-save-article-folder t]
1970 ["Save in VM folder" gnus-summary-save-article-vm t]
1971 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1972 ["Save body in file" gnus-summary-save-article-body-file t]
1973 ["Pipe through a filter" gnus-summary-pipe-output t]
1974 ["Add to SOUP packet" gnus-soup-add-article t]
1975 ["Print with Muttprint" gnus-summary-muttprint t]
1976 ["Print" gnus-summary-print-article t])
1978 ["Respool article..." gnus-summary-respool-article t]
1979 ["Move article..." gnus-summary-move-article
1980 (gnus-check-backend-function
1981 'request-move-article gnus-newsgroup-name)]
1982 ["Copy article..." gnus-summary-copy-article t]
1983 ["Crosspost article..." gnus-summary-crosspost-article
1984 (gnus-check-backend-function
1985 'request-replace-article gnus-newsgroup-name)]
1986 ["Import file..." gnus-summary-import-article t]
1987 ["Create article..." gnus-summary-create-article t]
1988 ["Check if posted" gnus-summary-article-posted-p t]
1989 ["Edit article" gnus-summary-edit-article
1990 (not (gnus-group-read-only-p))]
1991 ["Delete article" gnus-summary-delete-article
1992 (gnus-check-backend-function
1993 'request-expire-articles gnus-newsgroup-name)]
1994 ["Query respool" gnus-summary-respool-query t]
1995 ["Trace respool" gnus-summary-respool-trace t]
1996 ["Delete expirable articles" gnus-summary-expire-articles-now
1997 (gnus-check-backend-function
1998 'request-expire-articles gnus-newsgroup-name)])
2000 ["Uudecode" gnus-uu-decode-uu
2001 ,@(if (featurep 'xemacs) '(t)
2002 '(:help "Decode uuencoded article(s)"))]
2003 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2004 ["Unshar" gnus-uu-decode-unshar t]
2005 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2006 ["Save" gnus-uu-decode-save t]
2007 ["Binhex" gnus-uu-decode-binhex t]
2008 ["Postscript" gnus-uu-decode-postscript t])
2010 ["Enter article" gnus-cache-enter-article t]
2011 ["Remove article" gnus-cache-remove-article t])
2012 ["Translate" gnus-article-babel t]
2013 ["Select article buffer" gnus-summary-select-article-buffer t]
2014 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2015 ["Isearch article..." gnus-summary-isearch-article t]
2016 ["Beginning of the article" gnus-summary-beginning-of-article t]
2017 ["End of the article" gnus-summary-end-of-article t]
2018 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2019 ["Fetch referenced articles" gnus-summary-refer-references t]
2020 ["Fetch current thread" gnus-summary-refer-thread t]
2021 ["Fetch article with id..." gnus-summary-refer-article t]
2022 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2023 ["Redisplay" gnus-summary-show-article t]
2024 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2026 gnus-summary-article-menu gnus-summary-mode-map ""
2027 (cons "Article" innards))
2029 (if (not (keymapp gnus-summary-article-menu))
2031 gnus-article-commands-menu gnus-article-mode-map ""
2032 (cons "Commands" innards))
2033 ;; in Emacs, don't share menu.
2034 (setq gnus-article-commands-menu
2035 (copy-keymap gnus-summary-article-menu))
2036 (define-key gnus-article-mode-map [menu-bar commands]
2037 (cons "Commands" gnus-article-commands-menu))))
2040 gnus-summary-thread-menu gnus-summary-mode-map ""
2042 ["Toggle threading" gnus-summary-toggle-threads t]
2043 ["Hide threads" gnus-summary-hide-all-threads t]
2044 ["Show threads" gnus-summary-show-all-threads t]
2045 ["Hide thread" gnus-summary-hide-thread t]
2046 ["Show thread" gnus-summary-show-thread t]
2047 ["Go to next thread" gnus-summary-next-thread t]
2048 ["Go to previous thread" gnus-summary-prev-thread t]
2049 ["Go down thread" gnus-summary-down-thread t]
2050 ["Go up thread" gnus-summary-up-thread t]
2051 ["Top of thread" gnus-summary-top-thread t]
2052 ["Mark thread as read" gnus-summary-kill-thread t]
2053 ["Lower thread score" gnus-summary-lower-thread t]
2054 ["Raise thread score" gnus-summary-raise-thread t]
2055 ["Rethread current" gnus-summary-rethread-current t]))
2058 gnus-summary-post-menu gnus-summary-mode-map ""
2060 ["Send a message (mail or news)" gnus-summary-post-news
2061 ,@(if (featurep 'xemacs) '(t)
2062 '(:help "Post an article"))]
2063 ["Followup" gnus-summary-followup
2064 ,@(if (featurep 'xemacs) '(t)
2065 '(:help "Post followup to this article"))]
2066 ["Followup and yank" gnus-summary-followup-with-original
2067 ,@(if (featurep 'xemacs) '(t)
2068 '(:help "Post followup to this article, quoting its contents"))]
2069 ["Supersede article" gnus-summary-supersede-article t]
2070 ["Cancel article" gnus-summary-cancel-article
2071 ,@(if (featurep 'xemacs) '(t)
2072 '(:help "Cancel an article you posted"))]
2073 ["Reply" gnus-summary-reply t]
2074 ["Reply and yank" gnus-summary-reply-with-original t]
2075 ["Wide reply" gnus-summary-wide-reply t]
2076 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2077 ,@(if (featurep 'xemacs) '(t)
2078 '(:help "Mail a reply, quoting this article"))]
2079 ["Very wide reply" gnus-summary-very-wide-reply t]
2080 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2081 ,@(if (featurep 'xemacs) '(t)
2082 '(:help "Mail a very wide reply, quoting this article"))]
2083 ["Mail forward" gnus-summary-mail-forward t]
2084 ["Post forward" gnus-summary-post-forward t]
2085 ["Digest and mail" gnus-summary-digest-mail-forward t]
2086 ["Digest and post" gnus-summary-digest-post-forward t]
2087 ["Resend message" gnus-summary-resend-message t]
2088 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2089 ["Send a mail" gnus-summary-mail-other-window t]
2090 ["Create a local message" gnus-summary-news-other-window t]
2091 ["Uuencode and post" gnus-uu-post-news
2092 ,@(if (featurep 'xemacs) '(t)
2093 '(:help "Post a uuencoded article"))]
2094 ["Followup via news" gnus-summary-followup-to-mail t]
2095 ["Followup via news and yank"
2096 gnus-summary-followup-to-mail-with-original t]
2098 ;;["Send" gnus-summary-send-draft t]
2099 ;;["Send bounced" gnus-resend-bounced-mail t])
2103 ((not (keymapp gnus-summary-post-menu))
2104 (setq gnus-article-post-menu gnus-summary-post-menu))
2105 ((not gnus-article-post-menu)
2106 ;; Don't share post menu.
2107 (setq gnus-article-post-menu
2108 (copy-keymap gnus-summary-post-menu))))
2109 (define-key gnus-article-mode-map [menu-bar post]
2110 (cons "Post" gnus-article-post-menu))
2113 gnus-summary-misc-menu gnus-summary-mode-map ""
2116 ["Mark as read" gnus-summary-mark-as-read-forward t]
2117 ["Mark same subject and select"
2118 gnus-summary-kill-same-subject-and-select t]
2119 ["Mark same subject" gnus-summary-kill-same-subject t]
2120 ["Catchup" gnus-summary-catchup
2121 ,@(if (featurep 'xemacs) '(t)
2122 '(:help "Mark unread articles in this group as read"))]
2123 ["Catchup all" gnus-summary-catchup-all t]
2124 ["Catchup to here" gnus-summary-catchup-to-here t]
2125 ["Catchup from here" gnus-summary-catchup-from-here t]
2126 ["Catchup region" gnus-summary-mark-region-as-read t]
2127 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2129 ["Tick" gnus-summary-tick-article-forward t]
2130 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2131 ["Remove marks" gnus-summary-clear-mark-forward t]
2132 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2133 ["Set bookmark" gnus-summary-set-bookmark t]
2134 ["Remove bookmark" gnus-summary-remove-bookmark t])
2136 ["Marks..." gnus-summary-limit-to-marks t]
2137 ["Subject..." gnus-summary-limit-to-subject t]
2138 ["Author..." gnus-summary-limit-to-author t]
2139 ["Age..." gnus-summary-limit-to-age t]
2140 ["Extra..." gnus-summary-limit-to-extra t]
2141 ["Score" gnus-summary-limit-to-score t]
2142 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2143 ["Unread" gnus-summary-limit-to-unread t]
2144 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2145 ["Articles" gnus-summary-limit-to-articles t]
2146 ["Pop limit" gnus-summary-pop-limit t]
2147 ["Show dormant" gnus-summary-limit-include-dormant t]
2148 ["Hide childless dormant"
2149 gnus-summary-limit-exclude-childless-dormant t]
2150 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2151 ["Hide marked" gnus-summary-limit-exclude-marks t]
2152 ["Show expunged" gnus-summary-limit-include-expunged t])
2154 ["Set mark" gnus-summary-mark-as-processable t]
2155 ["Remove mark" gnus-summary-unmark-as-processable t]
2156 ["Remove all marks" gnus-summary-unmark-all-processable t]
2157 ["Mark above" gnus-uu-mark-over t]
2158 ["Mark series" gnus-uu-mark-series t]
2159 ["Mark region" gnus-uu-mark-region t]
2160 ["Unmark region" gnus-uu-unmark-region t]
2161 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2162 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2163 ["Mark all" gnus-uu-mark-all t]
2164 ["Mark buffer" gnus-uu-mark-buffer t]
2165 ["Mark sparse" gnus-uu-mark-sparse t]
2166 ["Mark thread" gnus-uu-mark-thread t]
2167 ["Unmark thread" gnus-uu-unmark-thread t]
2168 ("Process Mark Sets"
2169 ["Kill" gnus-summary-kill-process-mark t]
2170 ["Yank" gnus-summary-yank-process-mark
2171 gnus-newsgroup-process-stack]
2172 ["Save" gnus-summary-save-process-mark t]))
2174 ["Page forward" gnus-summary-next-page
2175 ,@(if (featurep 'xemacs) '(t)
2176 '(:help "Show next page of article"))]
2177 ["Page backward" gnus-summary-prev-page
2178 ,@(if (featurep 'xemacs) '(t)
2179 '(:help "Show previous page of article"))]
2180 ["Line forward" gnus-summary-scroll-up t])
2182 ["Next unread article" gnus-summary-next-unread-article t]
2183 ["Previous unread article" gnus-summary-prev-unread-article t]
2184 ["Next article" gnus-summary-next-article t]
2185 ["Previous article" gnus-summary-prev-article t]
2186 ["Next unread subject" gnus-summary-next-unread-subject t]
2187 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2188 ["Next article same subject" gnus-summary-next-same-subject t]
2189 ["Previous article same subject" gnus-summary-prev-same-subject t]
2190 ["First unread article" gnus-summary-first-unread-article t]
2191 ["Best unread article" gnus-summary-best-unread-article t]
2192 ["Go to subject number..." gnus-summary-goto-subject t]
2193 ["Go to article number..." gnus-summary-goto-article t]
2194 ["Go to the last article" gnus-summary-goto-last-article t]
2195 ["Pop article off history" gnus-summary-pop-article t])
2197 ["Sort by number" gnus-summary-sort-by-number t]
2198 ["Sort by author" gnus-summary-sort-by-author t]
2199 ["Sort by subject" gnus-summary-sort-by-subject t]
2200 ["Sort by date" gnus-summary-sort-by-date t]
2201 ["Sort by score" gnus-summary-sort-by-score t]
2202 ["Sort by lines" gnus-summary-sort-by-lines t]
2203 ["Sort by characters" gnus-summary-sort-by-chars t]
2204 ["Original sort" gnus-summary-sort-by-original t])
2206 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2207 ["Describe group" gnus-summary-describe-group t]
2208 ["Read manual" gnus-info-find-node t])
2210 ["Pick and read" gnus-pick-mode t]
2211 ["Binary" gnus-binary-mode t])
2213 ["Regenerate" gnus-summary-prepare t]
2214 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2215 ["Toggle threading" gnus-summary-toggle-threads t])
2216 ["See old articles" gnus-summary-insert-old-articles t]
2217 ["See new articles" gnus-summary-insert-new-articles t]
2218 ["Filter articles..." gnus-summary-execute-command t]
2219 ["Run command on subjects..." gnus-summary-universal-argument t]
2220 ["Search articles forward..." gnus-summary-search-article-forward t]
2221 ["Search articles backward..." gnus-summary-search-article-backward t]
2222 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2223 ["Expand window" gnus-summary-expand-window t]
2224 ["Expire expirable articles" gnus-summary-expire-articles
2225 (gnus-check-backend-function
2226 'request-expire-articles gnus-newsgroup-name)]
2227 ["Edit local kill file" gnus-summary-edit-local-kill t]
2228 ["Edit main kill file" gnus-summary-edit-global-kill t]
2229 ["Edit group parameters" gnus-summary-edit-parameters t]
2230 ["Customize group parameters" gnus-summary-customize-parameters t]
2231 ["Send a bug report" gnus-bug t]
2233 ["Catchup and exit" gnus-summary-catchup-and-exit
2234 ,@(if (featurep 'xemacs) '(t)
2235 '(:help "Mark unread articles in this group as read, then exit"))]
2236 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2237 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2238 ["Exit group" gnus-summary-exit
2239 ,@(if (featurep 'xemacs) '(t)
2240 '(:help "Exit current group, return to group selection mode"))]
2241 ["Exit group without updating" gnus-summary-exit-no-update t]
2242 ["Exit and goto next group" gnus-summary-next-group t]
2243 ["Exit and goto prev group" gnus-summary-prev-group t]
2244 ["Reselect group" gnus-summary-reselect-current-group t]
2245 ["Rescan group" gnus-summary-rescan-group t]
2246 ["Update dribble" gnus-summary-save-newsrc t])))
2248 (gnus-run-hooks 'gnus-summary-menu-hook)))
2250 (defvar gnus-summary-tool-bar-map nil)
2252 ;; Emacs 21 tool bar. Should be no-op otherwise.
2253 (defun gnus-summary-make-tool-bar ()
2254 (if (and (fboundp 'tool-bar-add-item-from-menu)
2255 (default-value 'tool-bar-mode)
2256 (not gnus-summary-tool-bar-map))
2257 (setq gnus-summary-tool-bar-map
2258 (let ((tool-bar-map (make-sparse-keymap))
2259 (load-path (mm-image-load-path)))
2260 (tool-bar-add-item-from-menu
2261 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2262 (tool-bar-add-item-from-menu
2263 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2264 (tool-bar-add-item-from-menu
2265 'gnus-summary-post-news "post" gnus-summary-mode-map)
2266 (tool-bar-add-item-from-menu
2267 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2268 (tool-bar-add-item-from-menu
2269 'gnus-summary-followup "followup" gnus-summary-mode-map)
2270 (tool-bar-add-item-from-menu
2271 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2272 (tool-bar-add-item-from-menu
2273 'gnus-summary-reply "reply" gnus-summary-mode-map)
2274 (tool-bar-add-item-from-menu
2275 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2276 (tool-bar-add-item-from-menu
2277 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2278 (tool-bar-add-item-from-menu
2279 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2280 (tool-bar-add-item-from-menu
2281 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2282 (tool-bar-add-item-from-menu
2283 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2284 (tool-bar-add-item-from-menu
2285 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2286 (tool-bar-add-item-from-menu
2287 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2288 (tool-bar-add-item-from-menu
2289 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2291 (if gnus-summary-tool-bar-map
2292 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2294 (defun gnus-score-set-default (var value)
2295 "A version of set that updates the GNU Emacs menu-bar."
2297 ;; It is the message that forces the active status to be updated.
2300 (defun gnus-make-score-map (type)
2301 "Make a summary score map of type TYPE."
2304 (let ((headers '(("author" "from" string)
2305 ("subject" "subject" string)
2306 ("article body" "body" string)
2307 ("article head" "head" string)
2308 ("xref" "xref" string)
2309 ("extra header" "extra" string)
2310 ("lines" "lines" number)
2311 ("followups to author" "followup" string)))
2312 (types '((number ("less than" <)
2315 (string ("substring" s)
2319 (perms '(("temporary" (current-time-string))
2327 (if (eq type 'lower)
2332 (setq header (car headers))
2338 (let ((ts (cdr (assoc (nth 2 header) types)))
2354 'gnus-summary-score-entry
2356 (if (or (string= (nth 1 header)
2358 (string= (nth 1 header)
2361 (list 'gnus-summary-header
2363 (list 'quote (nth 1 (car ts)))
2364 (list 'gnus-score-delta-default
2371 (list (nreverse outp))))
2374 (list (nreverse outt))))
2376 (setq headers (cdr headers)))
2377 (list (nreverse outh))))))))
2381 (defun gnus-summary-mode (&optional group)
2382 "Major mode for reading articles.
2384 All normal editing commands are switched off.
2385 \\<gnus-summary-mode-map>
2386 Each line in this buffer represents one article. To read an
2387 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2388 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2391 You can also post articles and send mail from this buffer. To
2392 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2393 of an article, type `\\[gnus-summary-reply]'.
2395 There are approx. one gazillion commands you can execute in this
2396 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2398 The following commands are available:
2400 \\{gnus-summary-mode-map}"
2402 (kill-all-local-variables)
2403 (when (gnus-visual-p 'summary-menu 'menu)
2404 (gnus-summary-make-menu-bar)
2405 (gnus-summary-make-tool-bar))
2406 (gnus-summary-make-local-variables)
2407 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2408 (gnus-summary-make-local-variables))
2409 (gnus-make-thread-indent-array)
2410 (gnus-simplify-mode-line)
2411 (setq major-mode 'gnus-summary-mode)
2412 (setq mode-name "Summary")
2413 (make-local-variable 'minor-mode-alist)
2414 (use-local-map gnus-summary-mode-map)
2415 (buffer-disable-undo)
2416 (setq buffer-read-only t) ;Disable modification
2417 (setq truncate-lines t)
2418 (setq selective-display t)
2419 (setq selective-display-ellipses t) ;Display `...'
2420 (gnus-summary-set-display-table)
2421 (gnus-set-default-directory)
2422 (setq gnus-newsgroup-name group)
2423 (unless (gnus-news-group-p group)
2424 (setq gnus-newsgroup-incorporated
2425 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2426 (make-local-variable 'gnus-summary-line-format)
2427 (make-local-variable 'gnus-summary-line-format-spec)
2428 (make-local-variable 'gnus-summary-dummy-line-format)
2429 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2430 (make-local-variable 'gnus-summary-mark-positions)
2431 (make-local-hook 'pre-command-hook)
2432 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2433 (gnus-run-hooks 'gnus-summary-mode-hook)
2434 (turn-on-gnus-mailing-list-mode)
2435 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2436 (gnus-update-summary-mark-positions))
2438 (defun gnus-summary-make-local-variables ()
2439 "Make all the local summary buffer variables."
2441 (dolist (local gnus-summary-local-variables)
2444 (if (eq (cdr local) 'global)
2445 ;; Copy the global value of the variable.
2446 (setq global (symbol-value (car local)))
2447 ;; Use the value from the list.
2448 (setq global (eval (cdr local))))
2449 (set (make-local-variable (car local)) global))
2450 ;; Simple nil-valued local variable.
2451 (set (make-local-variable local) nil)))))
2453 (defun gnus-summary-clear-local-variables ()
2454 (let ((locals gnus-summary-local-variables))
2456 (if (consp (car locals))
2457 (and (vectorp (caar locals))
2458 (set (caar locals) nil))
2459 (and (vectorp (car locals))
2460 (set (car locals) nil)))
2461 (setq locals (cdr locals)))))
2463 ;; Summary data functions.
2465 (defmacro gnus-data-number (data)
2468 (defmacro gnus-data-set-number (data number)
2469 `(setcar ,data ,number))
2471 (defmacro gnus-data-mark (data)
2474 (defmacro gnus-data-set-mark (data mark)
2475 `(setcar (nthcdr 1 ,data) ,mark))
2477 (defmacro gnus-data-pos (data)
2480 (defmacro gnus-data-set-pos (data pos)
2481 `(setcar (nthcdr 2 ,data) ,pos))
2483 (defmacro gnus-data-header (data)
2486 (defmacro gnus-data-set-header (data header)
2487 `(setcar (nthcdr 3 ,data) ,header))
2489 (defmacro gnus-data-level (data)
2492 (defmacro gnus-data-unread-p (data)
2493 `(= (nth 1 ,data) gnus-unread-mark))
2495 (defmacro gnus-data-read-p (data)
2496 `(/= (nth 1 ,data) gnus-unread-mark))
2498 (defmacro gnus-data-pseudo-p (data)
2499 `(consp (nth 3 ,data)))
2501 (defmacro gnus-data-find (number)
2502 `(assq ,number gnus-newsgroup-data))
2504 (defmacro gnus-data-find-list (number &optional data)
2505 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2506 (memq (assq ,number bdata)
2509 (defmacro gnus-data-make (number mark pos header level)
2510 `(list ,number ,mark ,pos ,header ,level))
2512 (defun gnus-data-enter (after-article number mark pos header level offset)
2513 (let ((data (gnus-data-find-list after-article)))
2515 (error "No such article: %d" after-article))
2516 (setcdr data (cons (gnus-data-make number mark pos header level)
2518 (setq gnus-newsgroup-data-reverse nil)
2519 (gnus-data-update-list (cddr data) offset)))
2521 (defun gnus-data-enter-list (after-article list &optional offset)
2523 (let ((data (and after-article (gnus-data-find-list after-article)))
2527 (let ((odata gnus-newsgroup-data))
2528 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2530 (gnus-data-update-list odata offset)))
2531 ;; Find the last element in the list to be spliced into the main
2534 (setq list (cdr list)))
2537 (setcdr list gnus-newsgroup-data)
2538 (setq gnus-newsgroup-data ilist)
2540 (gnus-data-update-list (cdr list) offset)))
2541 (setcdr list (cdr data))
2544 (gnus-data-update-list (cdr list) offset))))
2545 (setq gnus-newsgroup-data-reverse nil))))
2547 (defun gnus-data-remove (article &optional offset)
2548 (let ((data gnus-newsgroup-data))
2549 (if (= (gnus-data-number (car data)) article)
2551 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2552 gnus-newsgroup-data-reverse nil)
2554 (gnus-data-update-list gnus-newsgroup-data offset)))
2556 (when (= (gnus-data-number (cadr data)) article)
2557 (setcdr data (cddr data))
2559 (gnus-data-update-list (cdr data) offset))
2561 gnus-newsgroup-data-reverse nil))
2562 (setq data (cdr data))))))
2564 (defmacro gnus-data-list (backward)
2566 (or gnus-newsgroup-data-reverse
2567 (setq gnus-newsgroup-data-reverse
2568 (reverse gnus-newsgroup-data)))
2569 gnus-newsgroup-data))
2571 (defun gnus-data-update-list (data offset)
2572 "Add OFFSET to the POS of all data entries in DATA."
2573 (setq gnus-newsgroup-data-reverse nil)
2575 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2576 (setq data (cdr data))))
2578 (defun gnus-summary-article-pseudo-p (article)
2579 "Say whether this article is a pseudo article or not."
2580 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2582 (defmacro gnus-summary-article-sparse-p (article)
2583 "Say whether this article is a sparse article or not."
2584 `(memq ,article gnus-newsgroup-sparse))
2586 (defmacro gnus-summary-article-ancient-p (article)
2587 "Say whether this article is a sparse article or not."
2588 `(memq ,article gnus-newsgroup-ancient))
2590 (defun gnus-article-parent-p (number)
2591 "Say whether this article is a parent or not."
2592 (let ((data (gnus-data-find-list number)))
2593 (and (cdr data) ; There has to be an article after...
2594 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2595 (gnus-data-level (nth 1 data))))))
2597 (defun gnus-article-children (number)
2598 "Return a list of all children to NUMBER."
2599 (let* ((data (gnus-data-find-list number))
2600 (level (gnus-data-level (car data)))
2602 (setq data (cdr data))
2604 (= (gnus-data-level (car data)) (1+ level)))
2605 (push (gnus-data-number (car data)) children)
2606 (setq data (cdr data)))
2609 (defmacro gnus-summary-skip-intangible ()
2610 "If the current article is intangible, then jump to a different article."
2611 '(let ((to (get-text-property (point) 'gnus-intangible)))
2612 (and to (gnus-summary-goto-subject to))))
2614 (defmacro gnus-summary-article-intangible-p ()
2615 "Say whether this article is intangible or not."
2616 '(get-text-property (point) 'gnus-intangible))
2618 (defun gnus-article-read-p (article)
2619 "Say whether ARTICLE is read or not."
2620 (not (or (memq article gnus-newsgroup-marked)
2621 (memq article gnus-newsgroup-unreads)
2622 (memq article gnus-newsgroup-unselected)
2623 (memq article gnus-newsgroup-dormant))))
2625 ;; Some summary mode macros.
2627 (defmacro gnus-summary-article-number ()
2628 "The article number of the article on the current line.
2629 If there isn's an article number here, then we return the current
2632 (gnus-summary-skip-intangible)
2633 (or (get-text-property (point) 'gnus-number)
2634 (gnus-summary-last-subject))))
2636 (defmacro gnus-summary-article-header (&optional number)
2637 "Return the header of article NUMBER."
2638 `(gnus-data-header (gnus-data-find
2639 ,(or number '(gnus-summary-article-number)))))
2641 (defmacro gnus-summary-thread-level (&optional number)
2642 "Return the level of thread that starts with article NUMBER."
2643 `(if (and (eq gnus-summary-make-false-root 'dummy)
2644 (get-text-property (point) 'gnus-intangible))
2646 (gnus-data-level (gnus-data-find
2647 ,(or number '(gnus-summary-article-number))))))
2649 (defmacro gnus-summary-article-mark (&optional number)
2650 "Return the mark of article NUMBER."
2651 `(gnus-data-mark (gnus-data-find
2652 ,(or number '(gnus-summary-article-number)))))
2654 (defmacro gnus-summary-article-pos (&optional number)
2655 "Return the position of the line of article NUMBER."
2656 `(gnus-data-pos (gnus-data-find
2657 ,(or number '(gnus-summary-article-number)))))
2659 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2660 (defmacro gnus-summary-article-subject (&optional number)
2661 "Return current subject string or nil if nothing."
2664 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2665 '(gnus-data-header (assq (gnus-summary-article-number)
2666 gnus-newsgroup-data)))))
2669 (mail-header-subject headers))))
2671 (defmacro gnus-summary-article-score (&optional number)
2672 "Return current article score."
2673 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2674 gnus-newsgroup-scored))
2675 gnus-summary-default-score 0))
2677 (defun gnus-summary-article-children (&optional number)
2678 "Return a list of article numbers that are children of article NUMBER."
2679 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2680 (level (gnus-data-level (car data)))
2682 (while (and (setq data (cdr data))
2683 (> (setq l (gnus-data-level (car data))) level))
2684 (and (= (1+ level) l)
2685 (push (gnus-data-number (car data))
2687 (nreverse children)))
2689 (defun gnus-summary-article-parent (&optional number)
2690 "Return the article number of the parent of article NUMBER."
2691 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2692 (gnus-data-list t)))
2693 (level (gnus-data-level (car data))))
2695 () ; This is a root.
2696 ;; We search until we find an article with a level less than
2697 ;; this one. That function has to be the parent.
2698 (while (and (setq data (cdr data))
2699 (not (< (gnus-data-level (car data)) level))))
2700 (and data (gnus-data-number (car data))))))
2702 (defun gnus-unread-mark-p (mark)
2703 "Say whether MARK is the unread mark."
2704 (= mark gnus-unread-mark))
2706 (defun gnus-read-mark-p (mark)
2707 "Say whether MARK is one of the marks that mark as read.
2708 This is all marks except unread, ticked, dormant, and expirable."
2709 (not (or (= mark gnus-unread-mark)
2710 (= mark gnus-ticked-mark)
2711 (= mark gnus-dormant-mark)
2712 (= mark gnus-expirable-mark))))
2714 (defmacro gnus-article-mark (number)
2715 "Return the MARK of article NUMBER.
2716 This macro should only be used when computing the mark the \"first\"
2717 time; i.e., when generating the summary lines. After that,
2718 `gnus-summary-article-mark' should be used to examine the
2721 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2722 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2723 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2724 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2725 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2726 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2727 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2728 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2729 gnus-ancient-mark))))
2731 ;; Saving hidden threads.
2733 (defmacro gnus-save-hidden-threads (&rest forms)
2734 "Save hidden threads, eval FORMS, and restore the hidden threads."
2735 (let ((config (make-symbol "config")))
2736 `(let ((,config (gnus-hidden-threads-configuration)))
2740 (gnus-restore-hidden-threads-configuration ,config)))))
2741 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2742 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2744 (defun gnus-data-compute-positions ()
2745 "Compute the positions of all articles."
2746 (setq gnus-newsgroup-data-reverse nil)
2747 (let ((data gnus-newsgroup-data))
2749 (gnus-save-hidden-threads
2750 (gnus-summary-show-all-threads)
2751 (goto-char (point-min))
2753 (while (get-text-property (point) 'gnus-intangible)
2755 (gnus-data-set-pos (car data) (+ (point) 3))
2756 (setq data (cdr data))
2757 (forward-line 1))))))
2759 (defun gnus-hidden-threads-configuration ()
2760 "Return the current hidden threads configuration."
2763 (goto-char (point-min))
2764 (while (search-forward "\r" nil t)
2765 (push (1- (point)) config))
2768 (defun gnus-restore-hidden-threads-configuration (config)
2769 "Restore hidden threads configuration from CONFIG."
2771 (let (point buffer-read-only)
2772 (while (setq point (pop config))
2773 (when (and (< point (point-max))
2775 (eq (char-after) ?\n))
2776 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2778 ;; Various summary mode internalish functions.
2780 (defun gnus-mouse-pick-article (e)
2783 (gnus-summary-next-page nil t))
2785 (defun gnus-summary-set-display-table ()
2786 "Change the display table.
2787 Odd characters have a tendency to mess
2788 up nicely formatted displays - we make all possible glyphs
2789 display only a single character."
2791 ;; We start from the standard display table, if any.
2792 (let ((table (or (copy-sequence standard-display-table)
2793 (make-display-table)))
2795 ;; Nix out all the control chars...
2796 (while (>= (setq i (1- i)) 0)
2797 (aset table i [??]))
2798 ;; ... but not newline and cr, of course. (cr is necessary for the
2799 ;; selective display).
2800 (aset table ?\n nil)
2801 (aset table ?\r nil)
2802 ;; We keep TAB as well.
2803 (aset table ?\t nil)
2804 ;; We nix out any glyphs over 126 that are not set already.
2806 (while (>= (setq i (1- i)) 127)
2807 ;; Only modify if the entry is nil.
2808 (unless (aref table i)
2809 (aset table i [??]))))
2810 (setq buffer-display-table table)))
2812 (defun gnus-summary-set-article-display-arrow (pos)
2813 "Update the overlay arrow to point to line at position POS."
2814 (when (and gnus-summary-display-arrow
2815 (boundp 'overlay-arrow-position)
2816 (boundp 'overlay-arrow-string))
2820 (unless overlay-arrow-position
2821 (setq overlay-arrow-position (make-marker)))
2822 (setq overlay-arrow-string "=>"
2823 overlay-arrow-position (set-marker overlay-arrow-position
2825 (current-buffer))))))
2827 (defun gnus-summary-buffer-name (group)
2828 "Return the summary buffer name of GROUP."
2829 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2831 (defun gnus-summary-setup-buffer (group)
2832 "Initialize summary buffer."
2833 (let ((buffer (gnus-summary-buffer-name group))
2834 (dead-name (concat "*Dead Summary "
2835 (gnus-group-decoded-name group) "*")))
2836 ;; If a dead summary buffer exists, we kill it.
2837 (when (gnus-buffer-live-p dead-name)
2838 (gnus-kill-buffer dead-name))
2839 (if (get-buffer buffer)
2842 (setq gnus-summary-buffer (current-buffer))
2843 (not gnus-newsgroup-prepared))
2844 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2845 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2846 (gnus-summary-mode group)
2848 (gnus-carpal-setup-buffer 'summary))
2849 (unless gnus-single-article-buffer
2850 (make-local-variable 'gnus-article-buffer)
2851 (make-local-variable 'gnus-article-current)
2852 (make-local-variable 'gnus-original-article-buffer))
2853 (setq gnus-newsgroup-name group)
2854 ;; Set any local variables in the group parameters.
2855 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2858 (defun gnus-set-global-variables ()
2859 "Set the global equivalents of the buffer-local variables.
2860 They are set to the latest values they had. These reflect the summary
2861 buffer that was in action when the last article was fetched."
2862 (when (eq major-mode 'gnus-summary-mode)
2863 (setq gnus-summary-buffer (current-buffer))
2864 (let ((name gnus-newsgroup-name)
2865 (marked gnus-newsgroup-marked)
2866 (unread gnus-newsgroup-unreads)
2867 (headers gnus-current-headers)
2868 (data gnus-newsgroup-data)
2869 (summary gnus-summary-buffer)
2870 (article-buffer gnus-article-buffer)
2871 (original gnus-original-article-buffer)
2872 (gac gnus-article-current)
2873 (reffed gnus-reffed-article-number)
2874 (score-file gnus-current-score-file)
2875 (default-charset gnus-newsgroup-charset)
2877 (let ((locals gnus-newsgroup-variables))
2879 (if (consp (car locals))
2880 (push (eval (caar locals)) vlist)
2881 (push (eval (car locals)) vlist))
2882 (setq locals (cdr locals)))
2883 (setq vlist (nreverse vlist)))
2885 (set-buffer gnus-group-buffer)
2886 (setq gnus-newsgroup-name name
2887 gnus-newsgroup-marked marked
2888 gnus-newsgroup-unreads unread
2889 gnus-current-headers headers
2890 gnus-newsgroup-data data
2891 gnus-article-current gac
2892 gnus-summary-buffer summary
2893 gnus-article-buffer article-buffer
2894 gnus-original-article-buffer original
2895 gnus-reffed-article-number reffed
2896 gnus-current-score-file score-file
2897 gnus-newsgroup-charset default-charset)
2898 (let ((locals gnus-newsgroup-variables))
2900 (if (consp (car locals))
2901 (set (caar locals) (pop vlist))
2902 (set (car locals) (pop vlist)))
2903 (setq locals (cdr locals))))
2904 ;; The article buffer also has local variables.
2905 (when (gnus-buffer-live-p gnus-article-buffer)
2906 (set-buffer gnus-article-buffer)
2907 (setq gnus-summary-buffer summary))))))
2909 (defun gnus-summary-article-unread-p (article)
2910 "Say whether ARTICLE is unread or not."
2911 (memq article gnus-newsgroup-unreads))
2913 (defun gnus-summary-first-article-p (&optional article)
2914 "Return whether ARTICLE is the first article in the buffer."
2915 (if (not (setq article (or article (gnus-summary-article-number))))
2917 (eq article (caar gnus-newsgroup-data))))
2919 (defun gnus-summary-last-article-p (&optional article)
2920 "Return whether ARTICLE is the last article in the buffer."
2921 (if (not (setq article (or article (gnus-summary-article-number))))
2922 ;; All non-existent numbers are the last article. :-)
2924 (not (cdr (gnus-data-find-list article)))))
2926 (defun gnus-make-thread-indent-array ()
2928 (unless (and gnus-thread-indent-array
2929 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2930 (setq gnus-thread-indent-array (make-vector 201 "")
2931 gnus-thread-indent-array-level gnus-thread-indent-level)
2933 (aset gnus-thread-indent-array n
2934 (make-string (* n gnus-thread-indent-level) ? ))
2937 (defun gnus-update-summary-mark-positions ()
2938 "Compute where the summary marks are to go."
2940 (when (gnus-buffer-exists-p gnus-summary-buffer)
2941 (set-buffer gnus-summary-buffer))
2942 (let ((gnus-replied-mark 129)
2943 (gnus-score-below-mark 130)
2944 (gnus-score-over-mark 130)
2945 (gnus-download-mark 131)
2946 (spec gnus-summary-line-format-spec)
2949 (gnus-set-work-buffer)
2950 (let ((gnus-summary-line-format-spec spec)
2951 (gnus-newsgroup-downloadable '((0 . t))))
2952 (gnus-summary-insert-line
2953 (make-full-mail-header 0 "" "nobody"
2954 "05 Apr 2001 23:33:09 +0400"
2956 0 nil 128 t nil "" nil 1)
2957 (goto-char (point-min))
2958 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2960 (goto-char (point-min))
2961 (push (cons 'replied (and (search-forward "\201" nil t)
2964 (goto-char (point-min))
2965 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2967 (goto-char (point-min))
2968 (push (cons 'download
2969 (and (search-forward "\203" nil t) (- (point) 2)))
2971 (setq gnus-summary-mark-positions pos))))
2973 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2974 "Insert a dummy root in the summary buffer."
2976 (gnus-add-text-properties
2977 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2978 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2980 (defun gnus-summary-extract-address-component (from)
2981 (or (car (funcall gnus-extract-address-components from))
2984 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2985 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
2986 default-mime-charset)))
2987 ;; Is it really necessary to do this next part for each summary line?
2988 ;; Luckily, doesn't seem to slow things down much.
2990 (and gnus-ignored-from-addresses
2991 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2992 (let ((extra-headers (mail-header-extra header))
2996 ((setq to (cdr (assq 'To extra-headers)))
2999 (gnus-summary-extract-address-component
3000 (funcall gnus-decode-encoded-word-function to)))))
3001 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3002 (concat "=> " newsgroups)))))
3003 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3005 (defun gnus-summary-insert-line (gnus-tmp-header
3006 gnus-tmp-level gnus-tmp-current
3007 gnus-tmp-unread gnus-tmp-replied
3008 gnus-tmp-expirable gnus-tmp-subject-or-nil
3009 &optional gnus-tmp-dummy gnus-tmp-score
3011 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3012 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3013 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3014 (gnus-tmp-score-char
3015 (if (or (null gnus-summary-default-score)
3016 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3017 gnus-summary-zcore-fuzz))
3019 (if (< gnus-tmp-score gnus-summary-default-score)
3020 gnus-score-below-mark gnus-score-over-mark)))
3021 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3023 (cond (gnus-tmp-process gnus-process-mark)
3024 ((memq gnus-tmp-current gnus-newsgroup-cached)
3026 (gnus-tmp-replied gnus-replied-mark)
3027 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3028 gnus-forwarded-mark)
3029 ((memq gnus-tmp-current gnus-newsgroup-saved)
3031 ((memq gnus-tmp-number gnus-newsgroup-recent)
3033 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3036 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3039 ((string-match "<[^>]+> *$" gnus-tmp-from)
3040 (let ((beg (match-beginning 0)))
3041 (or (and (string-match "^\".+\"" gnus-tmp-from)
3042 (substring gnus-tmp-from 1 (1- (match-end 0))))
3043 (substring gnus-tmp-from 0 beg))))
3044 ((string-match "(.+)" gnus-tmp-from)
3045 (substring gnus-tmp-from
3046 (1+ (match-beginning 0)) (1- (match-end 0))))
3048 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3049 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3050 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3051 (buffer-read-only nil))
3052 (when (string= gnus-tmp-name "")
3053 (setq gnus-tmp-name gnus-tmp-from))
3054 (unless (numberp gnus-tmp-lines)
3055 (setq gnus-tmp-lines -1))
3056 (if (= gnus-tmp-lines -1)
3057 (setq gnus-tmp-lines "?")
3058 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3059 (gnus-put-text-property-excluding-characters-with-faces
3061 (progn (eval gnus-summary-line-format-spec) (point))
3062 'gnus-number gnus-tmp-number)
3063 (when (gnus-visual-p 'summary-highlight 'highlight)
3065 (gnus-run-hooks 'gnus-summary-update-hook)
3068 (defun gnus-summary-update-line (&optional dont-update)
3069 "Update summary line after change."
3070 (when (and gnus-summary-default-score
3071 (not gnus-summary-inhibit-highlight))
3072 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3073 (article (gnus-summary-article-number))
3074 (score (gnus-summary-article-score article)))
3076 (if (and gnus-summary-mark-below
3077 (< (gnus-summary-article-score)
3078 gnus-summary-mark-below))
3079 ;; This article has a low score, so we mark it as read.
3080 (when (memq article gnus-newsgroup-unreads)
3081 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3082 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3083 ;; This article was previously marked as read on account
3084 ;; of a low score, but now it has risen, so we mark it as
3086 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3087 (gnus-summary-update-mark
3088 (if (or (null gnus-summary-default-score)
3089 (<= (abs (- score gnus-summary-default-score))
3090 gnus-summary-zcore-fuzz))
3092 (if (< score gnus-summary-default-score)
3093 gnus-score-below-mark gnus-score-over-mark))
3095 ;; Do visual highlighting.
3096 (when (gnus-visual-p 'summary-highlight 'highlight)
3097 (gnus-run-hooks 'gnus-summary-update-hook)))))
3099 (defvar gnus-tmp-new-adopts nil)
3101 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3102 "Return the number of articles in THREAD.
3103 This may be 0 in some cases -- if none of the articles in
3104 the thread are to be displayed."
3106 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3108 ((not (listp thread))
3110 ((and (consp thread) (cdr thread))
3113 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3116 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3119 (when (and level (zerop level) gnus-tmp-new-adopts)
3122 'gnus-summary-number-of-articles-in-thread
3123 gnus-tmp-new-adopts))))
3125 (if (> number 1) gnus-not-empty-thread-mark
3126 gnus-empty-thread-mark)
3129 (defun gnus-summary-set-local-parameters (group)
3130 "Go through the local params of GROUP and set all variable specs in that list."
3131 (let ((params (gnus-group-find-parameter group))
3132 (vars '(quit-config)) ; Ignore quit-config.
3135 (setq elem (car params)
3136 params (cdr params))
3137 (and (consp elem) ; Has to be a cons.
3138 (consp (cdr elem)) ; The cdr has to be a list.
3139 (symbolp (car elem)) ; Has to be a symbol in there.
3140 (not (memq (car elem) vars))
3141 (ignore-errors ; So we set it.
3142 (push (car elem) vars)
3143 (make-local-variable (car elem))
3144 (set (car elem) (eval (nth 1 elem))))))))
3146 (defun gnus-summary-read-group (group &optional show-all no-article
3147 kill-buffer no-display backward
3149 "Start reading news in newsgroup GROUP.
3150 If SHOW-ALL is non-nil, already read articles are also listed.
3151 If NO-ARTICLE is non-nil, no article is selected initially.
3152 If NO-DISPLAY, don't generate a summary buffer."
3156 (let ((gnus-auto-select-next nil))
3157 (or (gnus-summary-read-group-1
3158 group show-all no-article
3159 kill-buffer no-display
3162 select-articles nil)))))
3163 (eq gnus-auto-select-next 'quietly))
3164 (set-buffer gnus-group-buffer)
3165 ;; The entry function called above goes to the next
3166 ;; group automatically, so we go two groups back
3167 ;; if we are searching for the previous group.
3169 (gnus-group-prev-unread-group 2))
3170 (if (not (equal group (gnus-group-group-name)))
3171 (setq group (gnus-group-group-name))
3175 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3176 "Directly jump to the other GROUP from summary buffer.
3177 If SHOW-ALL is non-nil, already read articles are also listed."
3179 (if (eq gnus-summary-buffer (current-buffer))
3180 (list (completing-read
3181 "Group: " gnus-active-hashtb nil t
3182 (when (and gnus-newsgroup-name
3183 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3184 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3185 'gnus-group-history)
3187 (error "%s must be invoked from a gnus summary buffer." this-command)))
3188 (unless (or (zerop (length group))
3189 (and gnus-newsgroup-name
3190 (string-equal gnus-newsgroup-name group)))
3192 (gnus-summary-read-group group show-all
3193 gnus-dont-select-after-jump-to-other-group)))
3195 (defun gnus-summary-read-group-1 (group show-all no-article
3196 kill-buffer no-display
3197 &optional select-articles)
3198 ;; Killed foreign groups can't be entered.
3199 ;; (when (and (not (gnus-group-native-p group))
3200 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3201 ;; (error "Dead non-native groups can't be entered"))
3202 (gnus-message 5 "Retrieving newsgroup: %s..."
3203 (gnus-group-decoded-name group))
3204 (let* ((new-group (gnus-summary-setup-buffer group))
3205 (quit-config (gnus-group-quit-config group))
3206 (did-select (and new-group (gnus-select-newsgroup
3207 group show-all select-articles))))
3209 ;; This summary buffer exists already, so we just select it.
3211 (gnus-set-global-variables)
3213 (gnus-kill-or-deaden-summary kill-buffer))
3214 (gnus-configure-windows 'summary 'force)
3215 (gnus-set-mode-line 'summary)
3216 (gnus-summary-position-point)
3219 ;; We couldn't select this group.
3221 (when (and (eq major-mode 'gnus-summary-mode)
3222 (not (equal (current-buffer) kill-buffer)))
3223 (kill-buffer (current-buffer))
3224 (if (not quit-config)
3226 ;; Update the info -- marks might need to be removed,
3228 (gnus-summary-update-info)
3229 (set-buffer gnus-group-buffer)
3230 (gnus-group-jump-to-group group)
3231 (gnus-group-next-unread-group 1))
3232 (gnus-handle-ephemeral-exit quit-config)))
3233 (let ((grpinfo (gnus-get-info group)))
3234 (if (null (gnus-info-read grpinfo))
3235 (gnus-message 3 "Group %s contains no messages"
3236 (gnus-group-decoded-name group))
3237 (gnus-message 3 "Can't select group")))
3239 ;; The user did a `C-g' while prompting for number of articles,
3240 ;; so we exit this group.
3241 ((eq did-select 'quit)
3242 (and (eq major-mode 'gnus-summary-mode)
3243 (not (equal (current-buffer) kill-buffer))
3244 (kill-buffer (current-buffer)))
3246 (gnus-kill-or-deaden-summary kill-buffer))
3247 (if (not quit-config)
3249 (set-buffer gnus-group-buffer)
3250 (gnus-group-jump-to-group group)
3251 (gnus-group-next-unread-group 1)
3252 (gnus-configure-windows 'group 'force))
3253 (gnus-handle-ephemeral-exit quit-config))
3254 ;; Finally signal the quit.
3256 ;; The group was successfully selected.
3258 (gnus-set-global-variables)
3259 ;; Save the active value in effect when the group was entered.
3260 (setq gnus-newsgroup-active
3262 (gnus-active gnus-newsgroup-name)))
3263 ;; You can change the summary buffer in some way with this hook.
3264 (gnus-run-hooks 'gnus-select-group-hook)
3265 (gnus-update-format-specifications
3266 nil 'summary 'summary-mode 'summary-dummy)
3267 (gnus-update-summary-mark-positions)
3268 ;; Do score processing.
3269 (when gnus-use-scoring
3270 (gnus-possibly-score-headers))
3271 ;; Check whether to fill in the gaps in the threads.
3272 (when gnus-build-sparse-threads
3273 (gnus-build-sparse-threads))
3274 ;; Find the initial limit.
3275 (if gnus-show-threads
3277 (let ((gnus-newsgroup-dormant nil))
3278 (gnus-summary-initial-limit show-all))
3279 (gnus-summary-initial-limit show-all))
3280 ;; When untreaded, all articles are always shown.
3281 (setq gnus-newsgroup-limit
3283 (lambda (header) (mail-header-number header))
3284 gnus-newsgroup-headers)))
3285 ;; Generate the summary buffer.
3287 (gnus-summary-prepare))
3288 (when gnus-use-trees
3289 (gnus-tree-open group)
3290 (setq gnus-summary-highlight-line-function
3291 'gnus-tree-highlight-article))
3292 ;; If the summary buffer is empty, but there are some low-scored
3293 ;; articles or some excluded dormants, we include these in the
3295 (when (and (zerop (buffer-size))
3297 (cond (gnus-newsgroup-dormant
3298 (gnus-summary-limit-include-dormant))
3299 ((and gnus-newsgroup-scored show-all)
3300 (gnus-summary-limit-include-expunged t))))
3301 ;; Function `gnus-apply-kill-file' must be called in this hook.
3302 (gnus-run-hooks 'gnus-apply-kill-hook)
3303 (if (and (zerop (buffer-size))
3306 ;; This newsgroup is empty.
3307 (gnus-summary-catchup-and-exit nil t)
3308 (gnus-message 6 "No unread news")
3310 (gnus-kill-or-deaden-summary kill-buffer))
3311 ;; Return nil from this function.
3313 ;; Hide conversation thread subtrees. We cannot do this in
3314 ;; gnus-summary-prepare-hook since kill processing may not
3315 ;; work with hidden articles.
3316 (gnus-summary-maybe-hide-threads)
3318 (gnus-kill-or-deaden-summary kill-buffer))
3319 (gnus-summary-auto-select-subject)
3320 ;; Show first unread article if requested.
3321 (if (and (not no-article)
3323 gnus-newsgroup-unreads
3324 gnus-auto-select-first)
3326 (gnus-configure-windows 'summary)
3327 (let ((art (gnus-summary-article-number)))
3328 (unless (or (memq art gnus-newsgroup-undownloaded)
3329 (memq art gnus-newsgroup-downloadable))
3330 (gnus-summary-goto-article art))))
3331 ;; Don't select any articles.
3332 (gnus-summary-position-point)
3333 (gnus-configure-windows 'summary 'force)
3334 (gnus-set-mode-line 'summary))
3335 (when (get-buffer-window gnus-group-buffer t)
3336 ;; Gotta use windows, because recenter does weird stuff if
3337 ;; the current buffer ain't the displayed window.
3338 (let ((owin (selected-window)))
3339 (select-window (get-buffer-window gnus-group-buffer t))
3340 (when (gnus-group-goto-group group)
3342 (select-window owin)))
3343 ;; Mark this buffer as "prepared".
3344 (setq gnus-newsgroup-prepared t)
3345 (gnus-run-hooks 'gnus-summary-prepared-hook)
3348 (defun gnus-summary-auto-select-subject ()
3349 "Select the subject line on initial group entry."
3350 (goto-char (point-min))
3352 ((eq gnus-auto-select-subject 'best)
3353 (gnus-summary-best-unread-subject))
3354 ((eq gnus-auto-select-subject 'unread)
3355 (gnus-summary-first-unread-subject))
3356 ((eq gnus-auto-select-subject 'unseen)
3357 (gnus-summary-first-unseen-subject))
3358 ((eq gnus-auto-select-subject 'unseen-or-unread)
3359 (gnus-summary-first-unseen-or-unread-subject))
3360 ((eq gnus-auto-select-subject 'first)
3363 ((gnus-functionp gnus-auto-select-subject)
3364 (funcall gnus-auto-select-subject))))
3366 (defun gnus-summary-prepare ()
3367 "Generate the summary buffer."
3369 (let ((buffer-read-only nil))
3371 (setq gnus-newsgroup-data nil
3372 gnus-newsgroup-data-reverse nil)
3373 (gnus-run-hooks 'gnus-summary-generate-hook)
3374 ;; Generate the buffer, either with threads or without.
3375 (when gnus-newsgroup-headers
3376 (gnus-summary-prepare-threads
3377 (if gnus-show-threads
3378 (gnus-sort-gathered-threads
3379 (funcall gnus-summary-thread-gathering-function
3381 (gnus-cut-threads (gnus-make-threads)))))
3382 ;; Unthreaded display.
3383 (gnus-sort-articles gnus-newsgroup-headers))))
3384 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3385 ;; Call hooks for modifying summary buffer.
3386 (goto-char (point-min))
3387 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3389 (defsubst gnus-general-simplify-subject (subject)
3390 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3393 ;; Truncate the subject.
3394 (gnus-simplify-subject-functions
3395 (gnus-map-function gnus-simplify-subject-functions subject))
3396 ((numberp gnus-summary-gather-subject-limit)
3397 (setq subject (gnus-simplify-subject-re subject))
3398 (if (> (length subject) gnus-summary-gather-subject-limit)
3399 (substring subject 0 gnus-summary-gather-subject-limit)
3401 ;; Fuzzily simplify it.
3402 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3403 (gnus-simplify-subject-fuzzy subject))
3404 ;; Just remove the leading "Re:".
3406 (gnus-simplify-subject-re subject))))
3408 (if (and gnus-summary-gather-exclude-subject
3409 (string-match gnus-summary-gather-exclude-subject subject))
3410 nil ; This article shouldn't be gathered
3413 (defun gnus-summary-simplify-subject-query ()
3414 "Query where the respool algorithm would put this article."
3416 (gnus-summary-select-article)
3418 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3420 (defun gnus-gather-threads-by-subject (threads)
3421 "Gather threads by looking at Subject headers."
3422 (if (not gnus-summary-make-false-root)
3424 (let ((hashtb (gnus-make-hashtable 1024))
3427 subject hthread whole-subject)
3429 (setq subject (gnus-general-simplify-subject
3430 (setq whole-subject (mail-header-subject
3433 (if (setq hthread (gnus-gethash subject hashtb))
3435 ;; We enter a dummy root into the thread, if we
3436 ;; haven't done that already.
3437 (unless (stringp (caar hthread))
3438 (setcar hthread (list whole-subject (car hthread))))
3439 ;; We add this new gathered thread to this gathered
3441 (setcdr (car hthread)
3442 (nconc (cdar hthread) (list (car threads))))
3443 ;; Remove it from the list of threads.
3444 (setcdr prev (cdr threads))
3445 (setq threads prev))
3446 ;; Enter this thread into the hash table.
3447 (gnus-sethash subject threads hashtb)))
3449 (setq threads (cdr threads)))
3452 (defun gnus-gather-threads-by-references (threads)
3453 "Gather threads by looking at References headers."
3454 (let ((idhashtb (gnus-make-hashtable 1024))
3455 (thhashtb (gnus-make-hashtable 1024))
3458 ids references id gthread gid entered ref)
3460 (when (setq references (mail-header-references (caar threads)))
3461 (setq id (mail-header-id (caar threads))
3462 ids (inline (gnus-split-references references))
3464 (while (setq ref (pop ids))
3465 (setq ids (delete ref ids))
3466 (if (not (setq gid (gnus-gethash ref idhashtb)))
3468 (gnus-sethash ref id idhashtb)
3469 (gnus-sethash id threads thhashtb))
3470 (setq gthread (gnus-gethash gid thhashtb))
3472 ;; We enter a dummy root into the thread, if we
3473 ;; haven't done that already.
3474 (unless (stringp (caar gthread))
3475 (setcar gthread (list (mail-header-subject (caar gthread))
3477 ;; We add this new gathered thread to this gathered
3479 (setcdr (car gthread)
3480 (nconc (cdar gthread) (list (car threads)))))
3481 ;; Add it into the thread hash table.
3482 (gnus-sethash id gthread thhashtb)
3484 ;; Remove it from the list of threads.
3485 (setcdr prev (cdr threads))
3486 (setq threads prev))))
3488 (setq threads (cdr threads)))
3491 (defun gnus-sort-gathered-threads (threads)
3492 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3493 (let ((result threads))
3495 (when (stringp (caar threads))
3496 (setcdr (car threads)
3497 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3498 (setq threads (cdr threads)))
3501 (defun gnus-thread-loop-p (root thread)
3502 "Say whether ROOT is in THREAD."
3503 (let ((stack (list thread))
3506 (while (setq thread (pop stack))
3507 (setq th (cdr thread))
3509 (not (eq (caar th) root)))
3512 ;; We have found a loop.
3514 (setcdr thread (delq (car th) (cdr thread)))
3515 (if (boundp (setq ref-dep (intern "none"
3516 gnus-newsgroup-dependencies)))
3517 (setcdr (symbol-value ref-dep)
3518 (nconc (cdr (symbol-value ref-dep))
3520 (set ref-dep (list nil (car th))))
3523 ;; Push all the subthreads onto the stack.
3524 (push (cdr thread) stack)))
3527 (defun gnus-make-threads ()
3528 "Go through the dependency hashtb and find the roots. Return all threads."
3530 (while (catch 'infloop
3533 ;; Deal with self-referencing References loops.
3534 (when (and (car (symbol-value refs))
3541 (car (symbol-value refs)) thread))
3542 (cdr (symbol-value refs)))))))
3545 (unless (car (symbol-value refs))
3546 ;; These threads do not refer back to any other articles,
3547 ;; so they're roots.
3548 (setq threads (append (cdr (symbol-value refs)) threads))))
3549 gnus-newsgroup-dependencies)))
3552 ;; Build the thread tree.
3553 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3554 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3556 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3557 if it was already present.
3559 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3560 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3561 Message-IDs will be renamed be renamed to a unique Message-ID before
3564 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3565 (let* ((id (mail-header-id header))
3566 (id-dep (and id (intern id dependencies)))
3567 ref ref-dep ref-header)
3568 ;; Enter this `header' in the `dependencies' table.
3572 ;; The first two cases do the normal part: enter a new `header'
3573 ;; in the `dependencies' table.
3574 ((not (boundp id-dep))
3575 (set id-dep (list header)))
3576 ((null (car (symbol-value id-dep)))
3577 (setcar (symbol-value id-dep) header))
3579 ;; From here the `header' was already present in the
3580 ;; `dependencies' table.
3582 ;; Overrides an existing entry;
3583 ;; just set the header part of the entry.
3584 (setcar (symbol-value id-dep) header))
3586 ;; Renames the existing `header' to a unique Message-ID.
3587 ((not gnus-summary-ignore-duplicates)
3588 ;; An article with this Message-ID has already been seen.
3589 ;; We rename the Message-ID.
3590 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3592 (mail-header-set-id header id))
3594 ;; The last case ignores an existing entry, except it adds any
3595 ;; additional Xrefs (in case the two articles came from different
3597 ;; Also sets `header' to `nil' meaning that the `dependencies'
3598 ;; table was *not* modified.
3600 (mail-header-set-xref
3601 (car (symbol-value id-dep))
3602 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3604 (or (mail-header-xref header) "")))
3608 ;; First check if that we are not creating a References loop.
3609 (setq ref (gnus-parent-id (mail-header-references header)))
3611 (setq ref-dep (intern-soft ref dependencies))
3613 (setq ref-header (car (symbol-value ref-dep))))
3614 (if (string= id ref)
3615 ;; Yuk! This is a reference loop. Make the article be a
3618 (mail-header-set-references (car (symbol-value id-dep)) "none")
3620 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3621 (setq ref (gnus-parent-id (mail-header-references header)))
3622 (setq ref-dep (intern (or ref "none") dependencies))
3623 (if (boundp ref-dep)
3624 (setcdr (symbol-value ref-dep)
3625 (nconc (cdr (symbol-value ref-dep))
3626 (list (symbol-value id-dep))))
3627 (set ref-dep (list nil (symbol-value id-dep)))))
3630 (defun gnus-build-sparse-threads ()
3631 (let ((headers gnus-newsgroup-headers)
3632 (mail-parse-charset gnus-newsgroup-charset)
3633 (gnus-summary-ignore-duplicates t)
3634 header references generation relations
3635 subject child end new-child date)
3636 ;; First we create an alist of generations/relations, where
3637 ;; generations is how much we trust the relation, and the relation
3639 (gnus-message 7 "Making sparse threads...")
3641 (nnheader-set-temp-buffer " *gnus sparse threads*")
3642 (while (setq header (pop headers))
3643 (when (and (setq references (mail-header-references header))
3644 (not (string= references "")))
3646 (setq child (mail-header-id header)
3647 subject (mail-header-subject header)
3648 date (mail-header-date header)
3650 (while (search-backward ">" nil t)
3651 (setq end (1+ (point)))
3652 (when (search-backward "<" nil t)
3653 (setq new-child (buffer-substring (point) end))
3654 (push (list (incf generation)
3655 child (setq child new-child)
3659 (push (list (1+ generation) child nil subject) relations))
3661 (kill-buffer (current-buffer)))
3662 ;; Sort over trustworthiness.
3665 (when (gnus-dependencies-add-header
3666 (make-full-mail-header-from-decoded-header
3667 gnus-reffed-article-number
3668 (nth 3 relation) "" (or (nth 4 relation) "")
3670 (or (nth 2 relation) "") 0 0 "")
3671 gnus-newsgroup-dependencies nil)
3672 (push gnus-reffed-article-number gnus-newsgroup-limit)
3673 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3674 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3675 gnus-newsgroup-reads)
3676 (decf gnus-reffed-article-number)))
3677 (sort relations 'car-less-than-car))
3678 (gnus-message 7 "Making sparse threads...done")))
3680 (defun gnus-build-old-threads ()
3681 ;; Look at all the articles that refer back to old articles, and
3682 ;; fetch the headers for the articles that aren't there. This will
3683 ;; build complete threads - if the roots haven't been expired by the
3685 (let ((mail-parse-charset gnus-newsgroup-charset)
3689 (when (not (car (symbol-value refs)))
3690 (setq heads (cdr (symbol-value refs)))
3692 (if (memq (mail-header-number (caar heads))
3693 gnus-newsgroup-dormant)
3694 (setq heads (cdr heads))
3695 (setq id (symbol-name refs))
3696 (while (and (setq id (gnus-build-get-header id))
3697 (not (car (gnus-id-to-thread id)))))
3698 (setq heads nil)))))
3699 gnus-newsgroup-dependencies)))
3701 ;; This function has to be called with point after the article number
3702 ;; on the beginning of the line.
3703 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3704 (let ((eol (gnus-point-at-eol))
3705 (buffer (current-buffer))
3708 ;; overview: [num subject from date id refs chars lines misc]
3711 (narrow-to-region (point) eol)
3716 (make-full-mail-header
3718 (nnheader-nov-field) ; subject
3719 (nnheader-nov-field) ; from
3720 (nnheader-nov-field) ; date
3721 (nnheader-nov-read-message-id) ; id
3722 (nnheader-nov-field) ; refs
3723 (nnheader-nov-read-integer) ; chars
3724 (nnheader-nov-read-integer) ; lines
3726 (if (looking-at "Xref: ")
3727 (goto-char (match-end 0)))
3728 (nnheader-nov-field)) ; Xref
3729 (nnheader-nov-parse-extra)))) ; extra
3733 (when gnus-alter-header-function
3734 (funcall gnus-alter-header-function header))
3735 (gnus-dependencies-add-header header dependencies force-new)))
3737 (defun gnus-build-get-header (id)
3738 "Look through the buffer of NOV lines and find the header to ID.
3739 Enter this line into the dependencies hash table, and return
3740 the id of the parent article (if any)."
3741 (let ((deps gnus-newsgroup-dependencies)
3745 (set-buffer nntp-server-buffer)
3746 (let ((case-fold-search nil))
3747 (goto-char (point-min))
3748 (while (and (not found)
3749 (search-forward id nil t))
3751 (setq found (looking-at
3752 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3753 (regexp-quote id))))
3754 (or found (beginning-of-line 2)))
3758 (setq header (gnus-nov-parse-line
3759 (read (current-buffer)) deps))
3760 (gnus-parent-id (mail-header-references header))))))
3762 (let ((number (mail-header-number header)))
3763 (push number gnus-newsgroup-limit)
3764 (push header gnus-newsgroup-headers)
3765 (if (memq number gnus-newsgroup-unselected)
3767 (push number gnus-newsgroup-unreads)
3768 (setq gnus-newsgroup-unselected
3769 (delq number gnus-newsgroup-unselected)))
3770 (push number gnus-newsgroup-ancient)))))))
3772 (defun gnus-build-all-threads ()
3773 "Read all the headers."
3774 (let ((gnus-summary-ignore-duplicates t)
3775 (mail-parse-charset gnus-newsgroup-charset)
3776 (dependencies gnus-newsgroup-dependencies)
3779 (set-buffer nntp-server-buffer)
3780 (let ((case-fold-search nil))
3781 (goto-char (point-min))
3784 (setq article (read (current-buffer))
3785 header (gnus-nov-parse-line article dependencies)))
3788 (set-buffer gnus-summary-buffer)
3789 (push header gnus-newsgroup-headers)
3790 (if (memq (setq article (mail-header-number header))
3791 gnus-newsgroup-unselected)
3793 (push article gnus-newsgroup-unreads)
3794 (setq gnus-newsgroup-unselected
3795 (delq article gnus-newsgroup-unselected)))
3796 (push article gnus-newsgroup-ancient)))
3797 (forward-line 1)))))))
3799 (defun gnus-summary-update-article-line (article header)
3800 "Update the line for ARTICLE using HEADERS."
3801 (let* ((id (mail-header-id header))
3802 (thread (gnus-id-to-thread id)))
3804 (error "Article in no thread"))
3805 ;; Update the thread.
3806 (setcar thread header)
3807 (gnus-summary-goto-subject article)
3808 (let* ((datal (gnus-data-find-list article))
3810 (length (when (cdr datal)
3811 (- (gnus-data-pos data)
3812 (gnus-data-pos (cadr datal)))))
3813 (buffer-read-only nil)
3814 (level (gnus-summary-thread-level)))
3816 (gnus-summary-insert-line
3817 header level nil (gnus-article-mark article)
3818 (memq article gnus-newsgroup-replied)
3819 (memq article gnus-newsgroup-expirable)
3820 ;; Only insert the Subject string when it's different
3821 ;; from the previous Subject string.
3826 (mail-header-subject
3829 (gnus-data-find-list
3831 (gnus-data-list t)))))
3832 ;; Error on the side of excessive subjects.
3834 (mail-header-subject header)))
3836 (mail-header-subject header))
3837 nil (cdr (assq article gnus-newsgroup-scored))
3838 (memq article gnus-newsgroup-processable))
3840 (gnus-data-update-list
3841 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3843 (defun gnus-summary-update-article (article &optional iheader)
3844 "Update ARTICLE in the summary buffer."
3845 (set-buffer gnus-summary-buffer)
3846 (let* ((header (gnus-summary-article-header article))
3847 (id (mail-header-id header))
3848 (data (gnus-data-find article))
3849 (thread (gnus-id-to-thread id))
3850 (references (mail-header-references header))
3854 (when (and references
3855 (not (equal "" references)))
3858 (buffer-read-only nil)
3864 (delq thread parent)))
3865 (if (gnus-summary-insert-subject id header)
3866 ;; Set the (possibly) new article number in the data structure.
3867 (gnus-data-set-number data (gnus-id-to-article id))
3871 (defun gnus-rebuild-thread (id &optional line)
3872 "Rebuild the thread containing ID.
3873 If LINE, insert the rebuilt thread starting on line LINE."
3874 (let ((buffer-read-only nil)
3875 old-pos current thread data)
3876 (if (not gnus-show-threads)
3877 (setq thread (list (car (gnus-id-to-thread id))))
3878 ;; Get the thread this article is part of.
3879 (setq thread (gnus-remove-thread id)))
3880 (setq old-pos (gnus-point-at-bol))
3881 (setq current (save-excursion
3882 (and (re-search-backward "[\r\n]" nil t)
3883 (gnus-summary-article-number))))
3884 ;; If this is a gathered thread, we have to go some re-gathering.
3885 (when (stringp (car thread))
3886 (let ((subject (car thread))
3888 (setq thread (cdr thread))
3890 (unless (memq (setq thr (gnus-id-to-thread
3892 (mail-header-id (caar thread)))))
3895 (setq thread (cdr thread)))
3896 ;; We now have all (unique) roots.
3897 (if (= (length roots) 1)
3898 ;; All the loose roots are now one solid root.
3899 (setq thread (car roots))
3900 (setq thread (cons subject (gnus-sort-threads roots))))))
3902 ;; We then insert this thread into the summary buffer.
3904 (goto-char (point-min))
3905 (forward-line (1- line)))
3906 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3907 (if gnus-show-threads
3908 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3909 (gnus-summary-prepare-unthreaded thread))
3910 (setq data (nreverse gnus-newsgroup-data))
3911 (setq threads gnus-newsgroup-threads))
3912 ;; We splice the new data into the data structure.
3913 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3914 ;;!!! then we want to insert at the beginning of the buffer.
3915 ;;!!! That happens to be true with Gnus now, but that may
3916 ;;!!! change in the future. Perhaps.
3917 (gnus-data-enter-list
3918 (if line nil current) data (- (point) old-pos))
3919 (setq gnus-newsgroup-threads
3920 (nconc threads gnus-newsgroup-threads))
3921 (gnus-data-compute-positions))))
3923 (defun gnus-number-to-header (number)
3924 "Return the header for article NUMBER."
3925 (let ((headers gnus-newsgroup-headers))
3927 (not (= number (mail-header-number (car headers)))))
3932 (defun gnus-parent-headers (in-headers &optional generation)
3933 "Return the headers of the GENERATIONeth parent of HEADERS."
3935 (setq generation 1))
3937 (headers in-headers)
3940 (not (zerop generation))
3941 (setq references (mail-header-references headers)))
3942 (setq headers (if (and references
3943 (setq parent (gnus-parent-id references)))
3944 (car (gnus-id-to-thread parent))
3947 (and (not (eq headers in-headers))
3950 (defun gnus-id-to-thread (id)
3951 "Return the (sub-)thread where ID appears."
3952 (gnus-gethash id gnus-newsgroup-dependencies))
3954 (defun gnus-id-to-article (id)
3955 "Return the article number of ID."
3956 (let ((thread (gnus-id-to-thread id)))
3959 (mail-header-number (car thread)))))
3961 (defun gnus-id-to-header (id)
3962 "Return the article headers of ID."
3963 (car (gnus-id-to-thread id)))
3965 (defun gnus-article-displayed-root-p (article)
3966 "Say whether ARTICLE is a root(ish) article."
3967 (let ((level (gnus-summary-thread-level article))
3968 (refs (mail-header-references (gnus-summary-article-header article)))
3974 ((null (gnus-parent-id refs)) t)
3976 (null (setq particle (gnus-id-to-article
3977 (gnus-parent-id refs))))
3978 (null (gnus-summary-thread-level particle)))))))
3980 (defun gnus-root-id (id)
3981 "Return the id of the root of the thread where ID appears."
3983 (while (and id (setq prev (car (gnus-id-to-thread id))))
3985 id (gnus-parent-id (mail-header-references prev))))
3988 (defun gnus-articles-in-thread (thread)
3989 "Return the list of articles in THREAD."
3990 (cons (mail-header-number (car thread))
3991 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3993 (defun gnus-remove-thread (id &optional dont-remove)
3994 "Remove the thread that has ID in it."
3995 (let (headers thread last-id)
3996 ;; First go up in this thread until we find the root.
3997 (setq last-id (gnus-root-id id)
3998 headers (message-flatten-list (gnus-id-to-thread last-id)))
3999 ;; We have now found the real root of this thread. It might have
4000 ;; been gathered into some loose thread, so we have to search
4001 ;; through the threads to find the thread we wanted.
4002 (let ((threads gnus-newsgroup-threads)
4005 (setq sub (car threads))
4006 (if (stringp (car sub))
4007 ;; This is a gathered thread, so we look at the roots
4008 ;; below it to find whether this article is in this
4011 (setq sub (cdr sub))
4013 (when (member (caar sub) headers)
4014 (setq thread (car threads)
4017 (setq sub (cdr sub))))
4018 ;; It's an ordinary thread, so we check it.
4019 (when (eq (car sub) (car headers))
4022 (setq threads (cdr threads)))
4023 ;; If this article is in no thread, then it's a root.
4026 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4027 (setq thread (gnus-id-to-thread last-id)))
4030 thread ; We return this thread.
4032 (if (stringp (car thread))
4034 ;; If we use dummy roots, then we have to remove the
4035 ;; dummy root as well.
4036 (when (eq gnus-summary-make-false-root 'dummy)
4037 ;; We go to the dummy root by going to
4038 ;; the first sub-"thread", and then one line up.
4039 (gnus-summary-goto-article
4040 (mail-header-number (caadr thread)))
4043 (gnus-data-compute-positions))
4044 (setq thread (cdr thread))
4046 (gnus-remove-thread-1 (car thread))
4047 (setq thread (cdr thread))))
4048 (gnus-remove-thread-1 thread))))))))
4050 (defun gnus-remove-thread-1 (thread)
4051 "Remove the thread THREAD recursively."
4052 (let ((number (mail-header-number (pop thread)))
4054 (setq thread (reverse thread))
4056 (gnus-remove-thread-1 (pop thread)))
4057 (when (setq d (gnus-data-find number))
4058 (goto-char (gnus-data-pos d))
4059 (gnus-summary-show-thread)
4062 (- (gnus-point-at-bol)
4064 (1+ (gnus-point-at-eol))
4065 (gnus-delete-line)))))))
4067 (defun gnus-sort-threads-1 (threads func)
4068 (sort (mapcar (lambda (thread)
4071 (gnus-sort-threads-1 (cdr thread) func))))
4074 (defun gnus-sort-threads (threads)
4076 (if (not gnus-thread-sort-functions)
4078 (gnus-message 8 "Sorting threads...")
4080 (gnus-sort-threads-1
4082 (gnus-make-sort-function gnus-thread-sort-functions))
4083 (gnus-message 8 "Sorting threads...done"))))
4085 (defun gnus-sort-articles (articles)
4087 (when gnus-article-sort-functions
4088 (gnus-message 7 "Sorting articles...")
4090 (setq gnus-newsgroup-headers
4091 (sort articles (gnus-make-sort-function
4092 gnus-article-sort-functions)))
4093 (gnus-message 7 "Sorting articles...done"))))
4095 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4096 (defmacro gnus-thread-header (thread)
4097 "Return header of first article in THREAD.
4098 Note that THREAD must never, ever be anything else than a variable -
4099 using some other form will lead to serious barfage."
4100 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4101 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4102 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4105 (defsubst gnus-article-sort-by-number (h1 h2)
4106 "Sort articles by article number."
4107 (< (mail-header-number h1)
4108 (mail-header-number h2)))
4110 (defun gnus-thread-sort-by-number (h1 h2)
4111 "Sort threads by root article number."
4112 (gnus-article-sort-by-number
4113 (gnus-thread-header h1) (gnus-thread-header h2)))
4115 (defsubst gnus-article-sort-by-lines (h1 h2)
4116 "Sort articles by article Lines header."
4117 (< (mail-header-lines h1)
4118 (mail-header-lines h2)))
4120 (defun gnus-thread-sort-by-lines (h1 h2)
4121 "Sort threads by root article Lines header."
4122 (gnus-article-sort-by-lines
4123 (gnus-thread-header h1) (gnus-thread-header h2)))
4125 (defsubst gnus-article-sort-by-chars (h1 h2)
4126 "Sort articles by octet length."
4127 (< (mail-header-chars h1)
4128 (mail-header-chars h2)))
4130 (defun gnus-thread-sort-by-chars (h1 h2)
4131 "Sort threads by root article octet length."
4132 (gnus-article-sort-by-chars
4133 (gnus-thread-header h1) (gnus-thread-header h2)))
4135 (defsubst gnus-article-sort-by-author (h1 h2)
4136 "Sort articles by root author."
4138 (let ((addr (car (mime-entity-read-field h1 'From))))
4139 (or (std11-full-name-string addr)
4140 (std11-address-string addr)
4142 (let ((addr (car (mime-entity-read-field h2 'From))))
4143 (or (std11-full-name-string addr)
4144 (std11-address-string addr)
4148 (defun gnus-thread-sort-by-author (h1 h2)
4149 "Sort threads by root author."
4150 (gnus-article-sort-by-author
4151 (gnus-thread-header h1) (gnus-thread-header h2)))
4153 (defsubst gnus-article-sort-by-subject (h1 h2)
4154 "Sort articles by root subject."
4156 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4157 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4159 (defun gnus-thread-sort-by-subject (h1 h2)
4160 "Sort threads by root subject."
4161 (gnus-article-sort-by-subject
4162 (gnus-thread-header h1) (gnus-thread-header h2)))
4164 (defsubst gnus-article-sort-by-date (h1 h2)
4165 "Sort articles by root article date."
4167 (gnus-date-get-time (mail-header-date h1))
4168 (gnus-date-get-time (mail-header-date h2))))
4170 (defun gnus-thread-sort-by-date (h1 h2)
4171 "Sort threads by root article date."
4172 (gnus-article-sort-by-date
4173 (gnus-thread-header h1) (gnus-thread-header h2)))
4175 (defsubst gnus-article-sort-by-score (h1 h2)
4176 "Sort articles by root article score.
4177 Unscored articles will be counted as having a score of zero."
4178 (> (or (cdr (assq (mail-header-number h1)
4179 gnus-newsgroup-scored))
4180 gnus-summary-default-score 0)
4181 (or (cdr (assq (mail-header-number h2)
4182 gnus-newsgroup-scored))
4183 gnus-summary-default-score 0)))
4185 (defun gnus-thread-sort-by-score (h1 h2)
4186 "Sort threads by root article score."
4187 (gnus-article-sort-by-score
4188 (gnus-thread-header h1) (gnus-thread-header h2)))
4190 (defun gnus-thread-sort-by-total-score (h1 h2)
4191 "Sort threads by the sum of all scores in the thread.
4192 Unscored articles will be counted as having a score of zero."
4193 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4195 (defun gnus-thread-total-score (thread)
4196 ;; This function find the total score of THREAD.
4201 (if (stringp (car thread))
4202 (apply gnus-thread-score-function 0
4203 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4204 (gnus-thread-total-score-1 thread)))
4206 (gnus-thread-total-score-1 (list thread)))))
4208 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4209 "Sort threads such that the thread with the most recently arrived article comes first."
4210 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4212 (defun gnus-thread-highest-number (thread)
4213 "Return the highest article number in THREAD."
4214 (apply 'max (mapcar (lambda (header)
4215 (mail-header-number header))
4216 (message-flatten-list thread))))
4218 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4219 "Sort threads such that the thread with the most recently dated article comes first."
4220 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4222 (defun gnus-thread-latest-date (thread)
4223 "Return the highest article date in THREAD."
4224 (let ((previous-time 0))
4229 (mail-header-parse-date
4231 (mail-header-date header)
4232 (error previous-time))))))
4234 (message-flatten-list thread)
4236 (< (mail-header-number h1)
4237 (mail-header-number h2))))))))
4239 (defun gnus-thread-total-score-1 (root)
4240 ;; This function find the total score of the thread below ROOT.
4241 (setq root (car root))
4242 (apply gnus-thread-score-function
4244 (mapcar 'gnus-thread-total-score
4245 (cdr (gnus-id-to-thread (mail-header-id root))))
4246 (when (> (mail-header-number root) 0)
4247 (list (or (cdr (assq (mail-header-number root)
4248 gnus-newsgroup-scored))
4249 gnus-summary-default-score 0))))
4250 (list gnus-summary-default-score)
4253 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4254 (defvar gnus-tmp-prev-subject nil)
4255 (defvar gnus-tmp-false-parent nil)
4256 (defvar gnus-tmp-root-expunged nil)
4257 (defvar gnus-tmp-dummy-line nil)
4259 (eval-when-compile (defvar gnus-tmp-header))
4260 (defun gnus-extra-header (type &optional header)
4261 "Return the extra header of TYPE."
4262 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4265 (defvar gnus-tmp-thread-tree-header-string "")
4267 (defvar gnus-sum-thread-tree-root "> "
4268 "With %B spec, used for the root of a thread.
4269 If nil, use subject instead.")
4270 (defvar gnus-sum-thread-tree-single-indent ""
4271 "With %B spec, used for a thread with just one message.
4272 If nil, use subject instead.")
4273 (defvar gnus-sum-thread-tree-vertical "| "
4274 "With %B spec, used for drawing a vertical line.")
4275 (defvar gnus-sum-thread-tree-indent " "
4276 "With %B spec, used for indenting.")
4277 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4278 "With %B spec, used for a leaf with brothers.")
4279 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4280 "With %B spec, used for a leaf without brothers.")
4282 (defun gnus-summary-prepare-threads (threads)
4283 "Prepare summary buffer from THREADS and indentation LEVEL.
4284 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4285 or a straight list of headers."
4286 (gnus-message 7 "Generating summary...")
4288 (setq gnus-newsgroup-threads threads)
4291 (let ((gnus-tmp-level 0)
4292 (default-score (or gnus-summary-default-score 0))
4293 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4294 thread number subject stack state gnus-tmp-gathered beg-match
4295 new-roots gnus-tmp-new-adopts thread-end
4296 gnus-tmp-header gnus-tmp-unread
4297 gnus-tmp-replied gnus-tmp-subject-or-nil
4298 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4299 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4300 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4303 (setq gnus-tmp-prev-subject nil)
4305 (if (vectorp (car threads))
4306 ;; If this is a straight (sic) list of headers, then a
4307 ;; threaded summary display isn't required, so we just create
4308 ;; an unthreaded one.
4309 (gnus-summary-prepare-unthreaded threads)
4311 ;; Do the threaded display.
4313 (while (or threads stack gnus-tmp-new-adopts new-roots)
4315 (if (and (= gnus-tmp-level 0)
4318 (not gnus-tmp-false-parent)
4319 (or gnus-tmp-new-adopts new-roots))
4320 (if gnus-tmp-new-adopts
4321 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4322 thread (list (car gnus-tmp-new-adopts))
4323 gnus-tmp-header (caar thread)
4324 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4326 (setq thread (list (car new-roots))
4327 gnus-tmp-header (caar thread)
4328 new-roots (cdr new-roots))))
4331 ;; If there are some threads, we do them before the
4332 ;; threads on the stack.
4333 (setq thread threads
4334 gnus-tmp-header (caar thread))
4335 ;; There were no current threads, so we pop something off
4337 (setq state (car stack)
4338 gnus-tmp-level (car state)
4339 tree-stack (cadr state)
4340 thread (caddr state)
4342 gnus-tmp-header (caar thread))))
4344 (setq gnus-tmp-false-parent nil)
4345 (setq gnus-tmp-root-expunged nil)
4346 (setq thread-end nil)
4348 (if (stringp gnus-tmp-header)
4349 ;; The header is a dummy root.
4351 ((eq gnus-summary-make-false-root 'adopt)
4352 ;; We let the first article adopt the rest.
4353 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4355 (setq gnus-tmp-gathered
4357 (lambda (h) (mail-header-number (car h)))
4360 (setq thread (cons (list (caar thread)
4363 (setq gnus-tmp-level -1
4364 gnus-tmp-false-parent t))
4365 ((eq gnus-summary-make-false-root 'empty)
4366 ;; We print adopted articles with empty subject fields.
4367 (setq gnus-tmp-gathered
4369 (lambda (h) (mail-header-number (car h)))
4372 (setq gnus-tmp-level -1))
4373 ((eq gnus-summary-make-false-root 'dummy)
4374 ;; We remember that we probably want to output a dummy
4376 (setq gnus-tmp-dummy-line gnus-tmp-header)
4377 (setq gnus-tmp-prev-subject gnus-tmp-header))
4379 ;; We do not make a root for the gathered
4380 ;; sub-threads at all.
4381 (setq gnus-tmp-level -1)))
4383 (setq number (mail-header-number gnus-tmp-header)
4384 subject (mail-header-subject gnus-tmp-header))
4387 ;; If the thread has changed subject, we might want to make
4388 ;; this subthread into a root.
4389 ((and (null gnus-thread-ignore-subject)
4390 (not (zerop gnus-tmp-level))
4391 gnus-tmp-prev-subject
4393 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4394 (setq new-roots (nconc new-roots (list (car thread)))
4396 gnus-tmp-header nil))
4397 ;; If the article lies outside the current limit,
4398 ;; then we do not display it.
4399 ((not (memq number gnus-newsgroup-limit))
4400 (setq gnus-tmp-gathered
4402 (lambda (h) (mail-header-number (car h)))
4405 (setq gnus-tmp-new-adopts (if (cdar thread)
4406 (append gnus-tmp-new-adopts
4408 gnus-tmp-new-adopts)
4410 gnus-tmp-header nil)
4411 (when (zerop gnus-tmp-level)
4412 (setq gnus-tmp-root-expunged t)))
4413 ;; Perhaps this article is to be marked as read?
4414 ((and gnus-summary-mark-below
4415 (< (or (cdr (assq number gnus-newsgroup-scored))
4417 gnus-summary-mark-below)
4418 ;; Don't touch sparse articles.
4419 (not (gnus-summary-article-sparse-p number))
4420 (not (gnus-summary-article-ancient-p number)))
4421 (setq gnus-newsgroup-unreads
4422 (delq number gnus-newsgroup-unreads))
4423 (if gnus-newsgroup-auto-expire
4424 (push number gnus-newsgroup-expirable)
4425 (push (cons number gnus-low-score-mark)
4426 gnus-newsgroup-reads))))
4428 (when gnus-tmp-header
4429 ;; We may have an old dummy line to output before this
4431 (when (and gnus-tmp-dummy-line
4434 (mail-header-subject gnus-tmp-header)))
4435 (gnus-summary-insert-dummy-line
4436 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4437 (setq gnus-tmp-dummy-line nil))
4439 ;; Compute the mark.
4440 (setq gnus-tmp-unread (gnus-article-mark number))
4442 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4443 gnus-tmp-header gnus-tmp-level)
4444 gnus-newsgroup-data)
4446 ;; Actually insert the line.
4448 gnus-tmp-subject-or-nil
4450 ((and gnus-thread-ignore-subject
4451 gnus-tmp-prev-subject
4452 (not (inline (gnus-subject-equal
4453 gnus-tmp-prev-subject subject))))
4455 ((zerop gnus-tmp-level)
4456 (if (and (eq gnus-summary-make-false-root 'empty)
4457 (memq number gnus-tmp-gathered)
4458 gnus-tmp-prev-subject
4459 (inline (gnus-subject-equal
4460 gnus-tmp-prev-subject subject)))
4461 gnus-summary-same-subject
4463 (t gnus-summary-same-subject)))
4464 (if (and (eq gnus-summary-make-false-root 'adopt)
4465 (= gnus-tmp-level 1)
4466 (memq number gnus-tmp-gathered))
4467 (setq gnus-tmp-opening-bracket ?\<
4468 gnus-tmp-closing-bracket ?\>)
4469 (setq gnus-tmp-opening-bracket ?\[
4470 gnus-tmp-closing-bracket ?\]))
4472 gnus-tmp-indentation
4473 (aref gnus-thread-indent-array gnus-tmp-level)
4474 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4475 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4476 gnus-summary-default-score 0)
4478 (if (or (null gnus-summary-default-score)
4479 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4480 gnus-summary-zcore-fuzz))
4482 (if (< gnus-tmp-score gnus-summary-default-score)
4483 gnus-score-below-mark gnus-score-over-mark))
4485 (cond ((memq number gnus-newsgroup-processable)
4487 ((memq number gnus-newsgroup-cached)
4489 ((memq number gnus-newsgroup-replied)
4491 ((memq number gnus-newsgroup-forwarded)
4492 gnus-forwarded-mark)
4493 ((memq number gnus-newsgroup-saved)
4495 ((memq number gnus-newsgroup-recent)
4497 ((memq number gnus-newsgroup-unseen)
4500 gnus-tmp-from (mail-header-from gnus-tmp-header)
4503 ((string-match "<[^>]+> *$" gnus-tmp-from)
4504 (setq beg-match (match-beginning 0))
4505 (or (and (string-match "^\".+\"" gnus-tmp-from)
4506 (substring gnus-tmp-from 1 (1- (match-end 0))))
4507 (substring gnus-tmp-from 0 beg-match)))
4508 ((string-match "(.+)" gnus-tmp-from)
4509 (substring gnus-tmp-from
4510 (1+ (match-beginning 0)) (1- (match-end 0))))
4512 gnus-tmp-thread-tree-header-string
4514 ((not gnus-show-threads) "")
4515 ((zerop gnus-tmp-level)
4517 (or gnus-sum-thread-tree-root subject)
4518 (or gnus-sum-thread-tree-single-indent subject)))
4520 (concat (apply 'concat
4521 (mapcar (lambda (item)
4523 gnus-sum-thread-tree-vertical
4524 gnus-sum-thread-tree-indent))
4525 (cdr (reverse tree-stack))))
4527 gnus-sum-thread-tree-leaf-with-other
4528 gnus-sum-thread-tree-single-leaf)))))
4529 (when (string= gnus-tmp-name "")
4530 (setq gnus-tmp-name gnus-tmp-from))
4531 (unless (numberp gnus-tmp-lines)
4532 (setq gnus-tmp-lines -1))
4533 (if (= gnus-tmp-lines -1)
4534 (setq gnus-tmp-lines "?")
4535 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4536 (gnus-put-text-property
4538 (progn (eval gnus-summary-line-format-spec) (point))
4539 'gnus-number number)
4542 (gnus-run-hooks 'gnus-summary-update-hook)
4545 (setq gnus-tmp-prev-subject subject)))
4547 (when (nth 1 thread)
4548 (push (list (max 0 gnus-tmp-level)
4549 (copy-list tree-stack)
4552 (push (if (nth 1 thread) 1 0) tree-stack)
4553 (incf gnus-tmp-level)
4554 (setq threads (if thread-end nil (cdar thread)))
4556 (setq gnus-tmp-level 0)))))
4557 (gnus-message 7 "Generating summary...done"))
4559 (defun gnus-summary-prepare-unthreaded (headers)
4560 "Generate an unthreaded summary buffer based on HEADERS."
4561 (let (header number mark)
4566 ;; We may have to root out some bad articles...
4567 (when (memq (setq number (mail-header-number
4568 (setq header (pop headers))))
4569 gnus-newsgroup-limit)
4570 ;; Mark article as read when it has a low score.
4571 (when (and gnus-summary-mark-below
4572 (< (or (cdr (assq number gnus-newsgroup-scored))
4573 gnus-summary-default-score 0)
4574 gnus-summary-mark-below)
4575 (not (gnus-summary-article-ancient-p number)))
4576 (setq gnus-newsgroup-unreads
4577 (delq number gnus-newsgroup-unreads))
4578 (if gnus-newsgroup-auto-expire
4579 (push number gnus-newsgroup-expirable)
4580 (push (cons number gnus-low-score-mark)
4581 gnus-newsgroup-reads)))
4583 (setq mark (gnus-article-mark number))
4584 (push (gnus-data-make number mark (1+ (point)) header 0)
4585 gnus-newsgroup-data)
4586 (gnus-summary-insert-line
4588 mark (memq number gnus-newsgroup-replied)
4589 (memq number gnus-newsgroup-expirable)
4590 (mail-header-subject header) nil
4591 (cdr (assq number gnus-newsgroup-scored))
4592 (memq number gnus-newsgroup-processable))))))
4594 (defun gnus-summary-remove-list-identifiers ()
4595 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4596 (let ((regexp (if (consp gnus-list-identifiers)
4597 (mapconcat 'identity gnus-list-identifiers " *\\|")
4598 gnus-list-identifiers))
4601 (dolist (header gnus-newsgroup-headers)
4602 (setq subject (mail-header-subject header)
4604 (while (string-match
4605 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4608 (concat (substring subject 0 (match-beginning 2))
4609 (substring subject (match-end 0)))
4613 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4615 (concat (substring subject 0 (match-beginning 1))
4616 (substring subject (match-end 1)))))
4618 (mail-header-set-subject header subject))))))
4620 (defun gnus-fetch-headers (articles)
4621 "Fetch headers of ARTICLES."
4622 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4623 (gnus-message 5 "Fetching headers for %s..." name)
4626 (setq gnus-headers-retrieved-by
4627 (gnus-retrieve-headers
4628 articles gnus-newsgroup-name
4629 ;; We might want to fetch old headers, but
4630 ;; not if there is only 1 article.
4632 (not (eq gnus-fetch-old-headers 'some))
4633 (not (numberp gnus-fetch-old-headers)))
4634 (> (length articles) 1))
4635 gnus-fetch-old-headers))))
4636 (gnus-get-newsgroup-headers-xover
4637 articles nil nil gnus-newsgroup-name t)
4638 (gnus-get-newsgroup-headers))
4639 (gnus-message 5 "Fetching headers for %s...done" name))))
4641 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4642 "Select newsgroup GROUP.
4643 If READ-ALL is non-nil, all articles in the group are selected.
4644 If SELECT-ARTICLES, only select those articles from GROUP."
4645 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4646 ;;!!! Dirty hack; should be removed.
4647 (gnus-summary-ignore-duplicates
4648 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4650 gnus-summary-ignore-duplicates))
4651 (info (nth 2 entry))
4652 articles fetched-articles cached)
4654 (unless (gnus-check-server
4655 (set (make-local-variable 'gnus-current-select-method)
4656 (gnus-find-method-for-group group)))
4657 (error "Couldn't open server"))
4659 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4660 (gnus-activate-group group) ; Or we can activate it...
4661 (progn ; Or we bug out.
4662 (when (equal major-mode 'gnus-summary-mode)
4663 (kill-buffer (current-buffer)))
4664 (error "Couldn't activate group %s: %s"
4665 group (gnus-status-message group))))
4667 (unless (gnus-request-group group t)
4668 (when (equal major-mode 'gnus-summary-mode)
4669 (kill-buffer (current-buffer)))
4670 (error "Couldn't request group %s: %s"
4671 group (gnus-status-message group)))
4673 (setq gnus-newsgroup-name group
4674 gnus-newsgroup-unselected nil
4675 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4677 (let ((display (gnus-group-find-parameter group 'display)))
4678 (setq gnus-newsgroup-display
4680 ((not (zerop (or (car-safe read-all) 0)))
4681 ;; The user entered the group with C-u SPC/RET, let's show
4687 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4689 ;; The following is probably the "correct" solution, but
4690 ;; it makes Gnus fetch all headers and then limit the
4691 ;; articles (which is slow), so instead we hack the
4692 ;; select-articles parameter instead. -- Simon Josefsson
4695 ;; (gnus-byte-compile
4696 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4698 (setq select-articles
4699 (gnus-uncompress-range
4700 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4704 (cdr (gnus-active group)))))
4709 (gnus-summary-setup-default-charset)
4711 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4712 (when (gnus-virtual-group-p group)
4713 (setq cached gnus-newsgroup-cached))
4715 (setq gnus-newsgroup-unreads
4716 (gnus-set-difference
4717 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4718 gnus-newsgroup-dormant))
4720 (setq gnus-newsgroup-processable nil)
4722 (gnus-update-read-articles group gnus-newsgroup-unreads)
4724 ;; Adjust and set lists of article marks.
4726 (gnus-adjust-marked-articles info))
4728 (if (setq articles select-articles)
4729 (setq gnus-newsgroup-unselected
4730 (gnus-sorted-intersection
4731 gnus-newsgroup-unreads
4732 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4733 (setq articles (gnus-articles-to-read group read-all)))
4737 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4739 ((eq articles 0) nil)
4741 ;; Init the dependencies hash table.
4742 (setq gnus-newsgroup-dependencies
4743 (gnus-make-hashtable (length articles)))
4744 (gnus-set-global-variables)
4745 ;; Retrieve the headers and read them in.
4746 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4748 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4750 (setq gnus-newsgroup-cached cached))
4752 ;; Suppress duplicates?
4753 (when gnus-suppress-duplicates
4754 (gnus-dup-suppress-articles))
4756 ;; Set the initial limit.
4757 (setq gnus-newsgroup-limit (copy-sequence articles))
4758 ;; Remove canceled articles from the list of unread articles.
4759 (setq fetched-articles
4760 (mapcar (lambda (headers) (mail-header-number headers))
4761 gnus-newsgroup-headers))
4762 (setq gnus-newsgroup-articles fetched-articles)
4763 (setq gnus-newsgroup-unreads
4764 (gnus-set-sorted-intersection
4765 gnus-newsgroup-unreads fetched-articles))
4767 ;; The `seen' marks are treated specially.
4768 (if (not gnus-newsgroup-seen)
4769 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4770 (dolist (article gnus-newsgroup-articles)
4771 (unless (gnus-member-of-range article gnus-newsgroup-seen)
4772 (push article gnus-newsgroup-unseen)))
4773 (setq gnus-newsgroup-unseen (nreverse gnus-newsgroup-unseen)))
4775 ;; Removed marked articles that do not exist.
4776 (gnus-update-missing-marks
4777 (gnus-sorted-complement fetched-articles articles))
4778 ;; We might want to build some more threads first.
4779 (when (and gnus-fetch-old-headers
4780 (eq gnus-headers-retrieved-by 'nov))
4781 (if (eq gnus-fetch-old-headers 'invisible)
4782 (gnus-build-all-threads)
4783 (gnus-build-old-threads)))
4784 ;; Let the Gnus agent mark articles as read.
4786 (gnus-agent-get-undownloaded-list))
4787 ;; Remove list identifiers from subject
4788 (when gnus-list-identifiers
4789 (gnus-summary-remove-list-identifiers))
4790 ;; Check whether auto-expire is to be done in this group.
4791 (setq gnus-newsgroup-auto-expire
4792 (gnus-group-auto-expirable-p group))
4793 ;; Set up the article buffer now, if necessary.
4794 (unless gnus-single-article-buffer
4795 (gnus-article-setup-buffer))
4796 ;; First and last article in this newsgroup.
4797 (when gnus-newsgroup-headers
4798 (setq gnus-newsgroup-begin
4799 (mail-header-number (car gnus-newsgroup-headers))
4802 (gnus-last-element gnus-newsgroup-headers))))
4803 ;; GROUP is successfully selected.
4804 (or gnus-newsgroup-headers t)))))
4806 (defun gnus-summary-display-make-predicate (display)
4807 (require 'gnus-agent)
4808 (when (= (length display) 1)
4809 (setq display (car display)))
4810 (unless gnus-summary-display-cache
4811 (dolist (elem (append (list (cons 'read 'read)
4812 (cons 'unseen 'unseen))
4813 gnus-article-mark-lists))
4814 (push (cons (cdr elem)
4816 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4817 gnus-summary-display-cache)))
4818 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4819 (gnus-get-predicate display)))
4821 ;; Uses the dynamically bound `number' variable.
4823 (defun gnus-article-marked-p (type &optional article)
4824 (let ((article (or article number)))
4827 (memq article gnus-newsgroup-marked))
4829 (memq article gnus-newsgroup-unsendable))
4830 ((eq type 'undownload)
4831 (memq article gnus-newsgroup-undownloaded))
4832 ((eq type 'download)
4833 (memq article gnus-newsgroup-downloadable))
4835 (memq article gnus-newsgroup-unreads))
4837 (memq article gnus-newsgroup-reads))
4839 (memq article gnus-newsgroup-dormant) )
4841 (memq article gnus-newsgroup-expirable))
4843 (memq article gnus-newsgroup-replied))
4845 (memq article gnus-newsgroup-killed))
4846 ((eq type 'bookmark)
4847 (assq article gnus-newsgroup-bookmarks))
4849 (assq article gnus-newsgroup-scored))
4851 (memq article gnus-newsgroup-saved))
4853 (memq article gnus-newsgroup-cached))
4855 (memq article gnus-newsgroup-forwarded))
4857 (not (memq article gnus-newsgroup-unseen)))
4859 (memq article gnus-newsgroup-recent))
4862 (defun gnus-articles-to-read (group &optional read-all)
4863 "Find out what articles the user wants to read."
4865 ;; Select all articles if `read-all' is non-nil, or if there
4866 ;; are no unread articles.
4868 (and (zerop (length gnus-newsgroup-marked))
4869 (zerop (length gnus-newsgroup-unreads)))
4870 (eq gnus-newsgroup-display 'gnus-not-ignore))
4871 ;; We want to select the headers for all the articles in
4872 ;; the group, so we select either all the active
4873 ;; articles in the group, or (if that's nil), the
4874 ;; articles in the cache.
4876 (gnus-uncompress-range (gnus-active group))
4877 (gnus-cache-articles-in-group group))
4878 ;; Select only the "normal" subset of articles.
4879 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4880 (copy-sequence gnus-newsgroup-unreads))
4882 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4883 (scored (length scored-list))
4884 (number (length articles))
4885 (marked (+ (length gnus-newsgroup-marked)
4886 (length gnus-newsgroup-dormant)))
4894 ((and (or (<= scored marked) (= scored number))
4895 (natnump gnus-large-newsgroup)
4896 (> number gnus-large-newsgroup))
4897 (let* ((cursor-in-echo-area nil)
4899 (read-from-minibuffer
4901 "How many articles from %s (max %d): "
4903 (gnus-group-decoded-name gnus-newsgroup-name)
4906 (cons (number-to-string gnus-large-newsgroup)
4908 (if (string-match "^[ \t]*$" input)
4911 ((and (> scored marked) (< scored number)
4912 (> (- scored number) 20))
4915 (format "%s %s (%d scored, %d total): "
4916 "How many articles from"
4917 (gnus-group-decoded-name group)
4919 (if (string-match "^[ \t]*$" input)
4923 (message "Quit getting the articles to read")
4925 (setq select (if (stringp select) (string-to-number select) select))
4926 (if (or (null select) (zerop select))
4928 (if (and (not (zerop scored)) (<= (abs select) scored))
4930 (setq articles (sort scored-list '<))
4931 (setq number (length articles)))
4932 (setq articles (copy-sequence articles)))
4934 (when (< (abs select) number)
4936 ;; Select the N oldest articles.
4937 (setcdr (nthcdr (1- (abs select)) articles) nil)
4938 ;; Select the N most recent articles.
4939 (setq articles (nthcdr (- number select) articles))))
4940 (setq gnus-newsgroup-unselected
4941 (gnus-sorted-intersection
4942 gnus-newsgroup-unreads
4943 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4944 (when gnus-alter-articles-to-read-function
4945 (setq gnus-newsgroup-unreads
4947 (funcall gnus-alter-articles-to-read-function
4948 gnus-newsgroup-name gnus-newsgroup-unreads)
4952 (defun gnus-killed-articles (killed articles)
4955 (when (inline (gnus-member-of-range (car articles) killed))
4956 (push (car articles) out))
4957 (setq articles (cdr articles)))
4960 (defun gnus-uncompress-marks (marks)
4961 "Uncompress the mark ranges in MARKS."
4962 (let ((uncompressed '(score bookmark))
4965 (if (memq (caar marks) uncompressed)
4966 (push (car marks) out)
4967 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4968 (setq marks (cdr marks)))
4971 (defun gnus-article-mark-to-type (mark)
4972 "Return the type of MARK."
4973 (or (cadr (assq mark gnus-article-special-mark-lists))
4976 (defun gnus-article-unpropagatable-p (mark)
4977 "Return whether MARK should be propagated to backend."
4978 (memq mark gnus-article-unpropagated-mark-lists))
4980 (defun gnus-adjust-marked-articles (info)
4981 "Set all article lists and remove all marks that are no longer valid."
4982 (let* ((marked-lists (gnus-info-marks info))
4983 (active (gnus-active (gnus-info-group info)))
4986 (types gnus-article-mark-lists)
4987 marks var articles article mark mark-type)
4989 (dolist (marks marked-lists)
4990 (setq mark (car marks)
4991 mark-type (gnus-article-mark-to-type mark)
4992 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4994 ;; We set the variable according to the type of the marks list,
4995 ;; and then adjust the marks to a subset of the active articles.
4997 ;; Adjust "simple" lists.
4998 ((eq mark-type 'list)
4999 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5000 (when (memq mark '(tick dormant expire reply save))
5002 (when (or (< (setq article (pop articles)) min) (> article max))
5003 (set var (delq article (symbol-value var)))))))
5005 ((eq mark-type 'tuple)
5006 (set var (setq articles (cdr marks)))
5007 (when (not (listp (cdr (symbol-value var))))
5008 (set var (list (symbol-value var))))
5009 (when (not (listp (cdr articles)))
5010 (setq articles (list articles)))
5012 (when (or (not (consp (setq article (pop articles))))
5013 (< (car article) min)
5014 (> (car article) max))
5015 (set var (delq article (symbol-value var))))))
5016 ;; Adjust ranges (sloppily).
5017 ((eq mark-type 'range)
5020 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5021 ;; It should be (seen (NUM1 . NUM2)).
5022 (when (numberp (cddr marks))
5023 (setcdr marks (list (cdr marks))))
5024 (setq articles (cdr marks))
5025 (while (and articles
5026 (or (and (consp (car articles))
5027 (> min (cdar articles)))
5028 (and (numberp (car articles))
5029 (> min (car articles)))))
5031 (set var articles))))))))
5033 (defun gnus-update-missing-marks (missing)
5034 "Go through the list of MISSING articles and remove them from the mark lists."
5037 ;; Go through all types.
5038 (dolist (elem gnus-article-mark-lists)
5039 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5040 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5041 (when (symbol-value var)
5042 ;; This list has articles. So we delete all missing
5043 ;; articles from it.
5046 (set var (delq (pop m) (symbol-value var))))))))))
5048 (defun gnus-update-marks ()
5049 "Enter the various lists of marked articles into the newsgroup info list."
5050 (let ((types gnus-article-mark-lists)
5051 (info (gnus-get-info gnus-newsgroup-name))
5052 type list newmarked symbol delta-marks)
5054 ;; Add all marks lists to the list of marks lists.
5055 (while (setq type (pop types))
5056 (setq list (symbol-value
5058 (intern (format "gnus-newsgroup-%s" (car type))))))
5061 ;; Get rid of the entries of the articles that have the
5063 (when (and (eq (cdr type) 'score)
5067 (prev (cons nil list))
5070 (if (or (not (consp (car arts)))
5071 (= (cdar arts) gnus-summary-default-score))
5072 (setcdr prev (cdr arts))
5074 (setq arts (cdr arts)))
5075 (setq list (cdr all)))))
5077 (when (eq (cdr type) 'seen)
5078 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5080 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5081 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5083 (when (and (gnus-check-backend-function
5084 'request-set-mark gnus-newsgroup-name)
5085 (not (gnus-article-unpropagatable-p (cdr type))))
5086 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5087 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5088 (add (gnus-remove-from-range
5089 (gnus-copy-sequence list) old)))
5091 (push (list add 'add (list (cdr type))) delta-marks))
5093 (push (list del 'del (list (cdr type))) delta-marks))))
5096 (push (cons (cdr type) list) newmarked)))
5099 (unless (gnus-check-group gnus-newsgroup-name)
5100 (error "Can't open server for %s" gnus-newsgroup-name))
5101 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5103 ;; Enter these new marks into the info of the group.
5105 (setcar (nthcdr 3 info) newmarked)
5106 ;; Add the marks lists to the end of the info.
5108 (setcdr (nthcdr 2 info) (list newmarked))))
5110 ;; Cut off the end of the info if there's nothing else there.
5114 (when (nthcdr (decf i) info)
5115 (setcdr (nthcdr i info) nil)))))))
5117 (defun gnus-set-mode-line (where)
5118 "Set the mode line of the article or summary buffers.
5119 If WHERE is `summary', the summary mode line format will be used."
5120 ;; Is this mode line one we keep updated?
5121 (when (and (memq where gnus-updated-mode-lines)
5123 (intern (format "gnus-%s-mode-line-format-spec" where))))
5126 ;; We evaluate this in the summary buffer since these
5127 ;; variables are buffer-local to that buffer.
5128 (set-buffer gnus-summary-buffer)
5129 ;; We bind all these variables that are used in the `eval' form
5131 (let* ((mformat (symbol-value
5133 (format "gnus-%s-mode-line-format-spec" where))))
5134 (gnus-tmp-group-name (gnus-group-decoded-name
5135 gnus-newsgroup-name))
5136 (gnus-tmp-article-number (or gnus-current-article 0))
5137 (gnus-tmp-unread gnus-newsgroup-unreads)
5138 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5139 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5140 (gnus-tmp-unread-and-unselected
5141 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5142 (zerop gnus-tmp-unselected))
5144 ((zerop gnus-tmp-unselected)
5145 (format "{%d more}" gnus-tmp-unread-and-unticked))
5146 (t (format "{%d(+%d) more}"
5147 gnus-tmp-unread-and-unticked
5148 gnus-tmp-unselected))))
5150 (if (and gnus-current-headers
5151 (vectorp gnus-current-headers))
5152 (gnus-mode-string-quote
5153 (mail-header-subject gnus-current-headers))
5155 bufname-length max-len
5156 gnus-tmp-header);; passed as argument to any user-format-funcs
5157 (setq mode-string (eval mformat))
5158 (setq bufname-length (if (string-match "%b" mode-string)
5161 (if (eq where 'summary)
5163 (get-buffer gnus-article-buffer))))
5166 (setq max-len (max 4 (if gnus-mode-non-string-length
5168 gnus-mode-non-string-length
5170 (length mode-string))))
5171 ;; We might have to chop a bit of the string off...
5172 (when (> (length mode-string) max-len)
5174 (concat (gnus-truncate-string mode-string (- max-len 3))
5176 ;; Pad the mode string a bit.
5177 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5178 ;; Update the mode line.
5179 (setq mode-line-buffer-identification
5180 (gnus-mode-line-buffer-identification (list mode-string)))
5181 (set-buffer-modified-p t))))
5183 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5184 "Go through the HEADERS list and add all Xrefs to a hash table.
5185 The resulting hash table is returned, or nil if no Xrefs were found."
5186 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5187 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5188 (xref-hashtb (gnus-make-hashtable))
5189 start group entry number xrefs header)
5191 (setq header (pop headers))
5192 (when (and (setq xrefs (mail-header-xref header))
5193 (not (memq (setq number (mail-header-number header))
5196 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5197 (setq start (match-end 0))
5198 (setq group (if prefix
5199 (concat prefix (substring xrefs (match-beginning 1)
5201 (substring xrefs (match-beginning 1) (match-end 1))))
5203 (string-to-int (substring xrefs (match-beginning 2)
5205 (if (setq entry (gnus-gethash group xref-hashtb))
5206 (setcdr entry (cons number (cdr entry)))
5207 (gnus-sethash group (cons number nil) xref-hashtb)))))
5208 (and start xref-hashtb)))
5210 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5211 "Look through all the headers and mark the Xrefs as read."
5212 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5213 name entry info xref-hashtb idlist method nth4)
5215 (set-buffer gnus-group-buffer)
5216 (when (setq xref-hashtb
5217 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5220 (unless (string= from-newsgroup (setq name (symbol-name group)))
5221 (setq idlist (symbol-value group))
5222 ;; Dead groups are not updated.
5224 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5226 (when (stringp (setq nth4 (gnus-info-method info)))
5227 (setq nth4 (gnus-server-to-method nth4))))
5228 ;; Only do the xrefs if the group has the same
5229 ;; select method as the group we have just read.
5230 (or (gnus-methods-equal-p
5231 nth4 (gnus-find-method-for-group from-newsgroup))
5233 (equal nth4 (setq method (gnus-find-method-for-group
5235 (and (equal (car nth4) (car method))
5236 (equal (nth 1 nth4) (nth 1 method))))
5237 gnus-use-cross-reference
5238 (or (not (eq gnus-use-cross-reference t))
5240 ;; Only do cross-references on subscribed
5241 ;; groups, if that is what is wanted.
5242 (<= (gnus-info-level info) gnus-level-subscribed))
5243 (gnus-group-make-articles-read name idlist))))
5246 (defun gnus-compute-read-articles (group articles)
5247 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5248 (info (nth 2 entry))
5249 (active (gnus-active group))
5252 ;; First peel off all invalid article numbers.
5254 (let ((ids articles)
5256 (while (setq id (pop ids))
5257 (when (and first (> id (cdr active)))
5258 ;; We'll end up in this situation in one particular
5259 ;; obscure situation. If you re-scan a group and get
5260 ;; a new article that is cross-posted to a different
5261 ;; group that has not been re-scanned, you might get
5262 ;; crossposted article that has a higher number than
5263 ;; Gnus believes possible. So we re-activate this
5264 ;; group as well. This might mean doing the
5265 ;; crossposting thingy will *increase* the number
5266 ;; of articles in some groups. Tsk, tsk.
5267 (setq active (or (gnus-activate-group group) active)))
5268 (when (or (> id (cdr active))
5269 (< id (car active)))
5270 (setq articles (delq id articles))))))
5271 ;; If the read list is nil, we init it.
5273 (null (gnus-info-read info))
5275 (setq ninfo (cons 1 (1- (car active))))
5276 (setq ninfo (gnus-info-read info)))
5277 ;; Then we add the read articles to the range.
5279 ninfo (setq articles (sort articles '<))))))
5281 (defun gnus-group-make-articles-read (group articles)
5282 "Update the info of GROUP to say that ARTICLES are read."
5284 (entry (gnus-gethash group gnus-newsrc-hashtb))
5285 (info (nth 2 entry))
5286 (active (gnus-active group))
5289 (setq range (gnus-compute-read-articles group articles))
5291 (set-buffer gnus-group-buffer)
5294 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5295 (gnus-info-set-read ',info ',(gnus-info-read info))
5296 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5297 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5298 (gnus-group-update-group ,group t))))
5299 ;; Add the read articles to the range.
5300 (gnus-info-set-read info range)
5301 (gnus-request-set-mark group (list (list range 'add '(read))))
5302 ;; Then we have to re-compute how many unread
5303 ;; articles there are in this group.
5307 (setq num (- (1+ (cdr active)) (car active))))
5308 ((not (listp (cdr range)))
5309 (setq num (- (cdr active) (- (1+ (cdr range))
5313 (if (numberp (car range))
5315 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5316 (setq range (cdr range)))
5317 (setq num (- (cdr active) num))))
5318 ;; Update the number of unread articles.
5320 ;; Update the group buffer.
5321 (gnus-group-update-group group t)))))
5323 (defvar gnus-newsgroup-none-id 0)
5325 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5326 (let ((cur nntp-server-buffer)
5329 (save-excursion (set-buffer gnus-summary-buffer)
5330 gnus-newsgroup-dependencies)))
5332 (mail-parse-charset gnus-newsgroup-charset)
5333 (mail-parse-ignored-charsets
5334 (save-excursion (condition-case nil
5335 (set-buffer gnus-summary-buffer)
5337 gnus-newsgroup-ignored-charsets)))
5339 (set-buffer nntp-server-buffer)
5340 ;; Translate all TAB characters into SPACE characters.
5341 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5342 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5343 (gnus-run-hooks 'gnus-parse-headers-hook)
5344 (let ((case-fold-search t)
5345 in-reply-to header p lines chars ctype)
5346 (goto-char (point-min))
5347 ;; Search to the beginning of the next header. Error messages
5348 ;; do not begin with 2 or 3.
5349 (while (re-search-forward "^[23][0-9]+ " nil t)
5352 ;; This implementation of this function, with nine
5353 ;; search-forwards instead of the one re-search-forward and
5354 ;; a case (which basically was the old function) is actually
5355 ;; about twice as fast, even though it looks messier. You
5356 ;; can't have everything, I guess. Speed and elegance
5357 ;; doesn't always go hand in hand.
5360 (make-full-mail-header
5366 (narrow-to-region (point)
5367 (or (and (search-forward "\n.\n" nil t)
5373 (if (search-forward "\nsubject:" nil t)
5374 (nnheader-header-value)
5379 (if (search-forward "\nfrom:" nil t)
5380 (nnheader-header-value)
5385 (if (search-forward "\ndate:" nil t)
5386 (nnheader-header-value) ""))
5390 (setq id (if (re-search-forward
5391 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5392 ;; We do it this way to make sure the Message-ID
5393 ;; is (somewhat) syntactically valid.
5394 (buffer-substring (match-beginning 1)
5396 ;; If there was no message-id, we just fake one
5397 ;; to make subsequent routines simpler.
5398 (nnheader-generate-fake-message-id))))
5402 (if (search-forward "\nreferences:" nil t)
5406 (nnheader-header-value)
5411 (search-backward ">" end t)
5414 (search-backward "<" end t)
5416 ;; Get the references from the in-reply-to header if there
5417 ;; were no references and the in-reply-to header looks
5419 (if (and (search-forward "\nin-reply-to:" nil t)
5420 (setq in-reply-to (nnheader-header-value))
5421 (string-match "<[^>]+>" in-reply-to))
5423 (setq ref (substring in-reply-to (match-beginning 0)
5425 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5426 (setq ref2 (substring in-reply-to (match-beginning 0)
5428 (when (> (length ref2) (length ref))
5435 (if (search-forward "\nchars: " nil t)
5436 (if (numberp (setq chars (ignore-errors (read cur))))
5442 (if (search-forward "\nlines: " nil t)
5443 (if (numberp (setq lines (ignore-errors (read cur))))
5449 (and (search-forward "\nxref:" nil t)
5450 (nnheader-header-value)))
5452 (when gnus-extra-headers
5453 (let ((extra gnus-extra-headers)
5457 (when (search-forward
5458 (concat "\n" (symbol-name (car extra)) ":") nil t)
5459 (push (cons (car extra) (nnheader-header-value)) out))
5463 (if (and (search-forward "\ncontent-type: " nil t)
5464 (setq ctype (nnheader-header-value)))
5465 (mime-entity-set-content-type-internal
5466 header (mime-parse-Content-Type ctype)))
5467 (when (equal id ref)
5470 (when gnus-alter-header-function
5471 (funcall gnus-alter-header-function header)
5472 (setq id (mail-header-id header)
5473 ref (gnus-parent-id (mail-header-references header))))
5476 (gnus-dependencies-add-header
5477 header dependencies force-new))
5478 (push header headers))
5479 (goto-char (point-max))
5481 (nreverse headers)))))
5483 ;; Goes through the xover lines and returns a list of vectors
5484 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5485 force-new dependencies
5486 group also-fetch-heads)
5487 "Parse the news overview data in the server buffer.
5488 Return a list of headers that match SEQUENCE (see
5489 `nntp-retrieve-headers')."
5490 ;; Get the Xref when the users reads the articles since most/some
5491 ;; NNTP servers do not include Xrefs when using XOVER.
5492 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5493 (let ((mail-parse-charset gnus-newsgroup-charset)
5494 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5495 (cur nntp-server-buffer)
5496 (dependencies (or dependencies gnus-newsgroup-dependencies))
5498 ((eq gnus-read-all-available-headers t)
5500 ((stringp gnus-read-all-available-headers)
5501 (string-match gnus-read-all-available-headers group))
5504 number headers header)
5506 (set-buffer nntp-server-buffer)
5507 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5508 ;; Allow the user to mangle the headers before parsing them.
5509 (gnus-run-hooks 'gnus-parse-headers-hook)
5510 (goto-char (point-min))
5513 (while (and (or sequence allp)
5515 (setq number (read cur))
5517 (while (and sequence
5518 (< (car sequence) number))
5519 (setq sequence (cdr sequence))))
5522 (eq number (car sequence))))
5524 (setq sequence (cdr sequence))
5525 (setq header (inline
5526 (gnus-nov-parse-line
5527 number dependencies force-new)))))
5528 (push header headers))
5531 (gnus-error 4 "Strange nov line (%d)"
5532 (count-lines (point-min) (point)))))
5534 ;; A common bug in inn is that if you have posted an article and
5535 ;; then retrieves the active file, it will answer correctly --
5536 ;; the new article is included. However, a NOV entry for the
5537 ;; article may not have been generated yet, so this may fail.
5538 ;; We work around this problem by retrieving the last few
5539 ;; headers using HEAD.
5540 (if (or (not also-fetch-heads)
5542 ;; We (probably) got all the headers.
5544 (let ((gnus-nov-is-evil t))
5547 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5548 (gnus-get-newsgroup-headers))))))))
5550 (defun gnus-article-get-xrefs ()
5551 "Fill in the Xref value in `gnus-current-headers', if necessary.
5552 This is meant to be called in `gnus-article-internal-prepare-hook'."
5553 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5554 gnus-current-headers)))
5555 (or (not gnus-use-cross-reference)
5557 (and (mail-header-xref headers)
5558 (not (string= (mail-header-xref headers) "")))
5559 (let ((case-fold-search t)
5562 (nnheader-narrow-to-headers)
5563 (goto-char (point-min))
5564 (when (or (and (not (eobp))
5565 (eq (downcase (char-after)) ?x)
5566 (looking-at "Xref:"))
5567 (search-forward "\nXref:" nil t))
5568 (goto-char (1+ (match-end 0)))
5569 (setq xref (buffer-substring (point)
5570 (progn (end-of-line) (point))))
5571 (mail-header-set-xref headers xref)))))))
5573 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5574 "Find article ID and insert the summary line for that article.
5575 OLD-HEADER can either be a header or a line number to insert
5576 the subject line on."
5577 (let* ((line (and (numberp old-header) old-header))
5578 (old-header (and (vectorp old-header) old-header))
5579 (header (cond ((and old-header use-old-header)
5582 (gnus-number-to-header id))
5583 (gnus-number-to-header id))
5585 (gnus-read-header id))))
5586 (number (and (numberp id) id))
5589 ;; Rebuild the thread that this article is part of and go to the
5590 ;; article we have fetched.
5591 (when (and (not gnus-show-threads)
5594 (setq d (gnus-data-find (mail-header-number old-header))))
5595 (goto-char (gnus-data-pos d))
5598 (- (gnus-point-at-bol)
5600 (1+ (gnus-point-at-eol))
5601 (gnus-delete-line))))))
5603 (mail-header-set-number header (mail-header-number old-header)))
5604 (setq gnus-newsgroup-sparse
5605 (delq (setq number (mail-header-number header))
5606 gnus-newsgroup-sparse))
5607 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5608 (push number gnus-newsgroup-limit)
5609 (gnus-rebuild-thread (mail-header-id header) line)
5610 (gnus-summary-goto-subject number nil t))
5611 (when (and (numberp number)
5613 ;; We have to update the boundaries even if we can't fetch the
5614 ;; article if ID is a number -- so that the next `P' or `N'
5615 ;; command will fetch the previous (or next) article even
5616 ;; if the one we tried to fetch this time has been canceled.
5617 (when (> number gnus-newsgroup-end)
5618 (setq gnus-newsgroup-end number))
5619 (when (< number gnus-newsgroup-begin)
5620 (setq gnus-newsgroup-begin number))
5621 (setq gnus-newsgroup-unselected
5622 (delq number gnus-newsgroup-unselected)))
5623 ;; Report back a success?
5624 (and header (mail-header-number header))))
5626 ;;; Process/prefix in the summary buffer
5628 (defun gnus-summary-work-articles (n)
5629 "Return a list of articles to be worked upon.
5630 The prefix argument, the list of process marked articles, and the
5631 current article will be taken into consideration."
5633 (set-buffer gnus-summary-buffer)
5636 ;; A numerical prefix has been given.
5637 (setq n (prefix-numeric-value n))
5638 (let ((backward (< n 0))
5639 (n (abs (prefix-numeric-value n)))
5644 (push (setq article (gnus-summary-article-number))
5647 (gnus-summary-find-prev nil article)
5648 (gnus-summary-find-next nil article)))
5650 (nreverse articles)))
5651 ((and (gnus-region-active-p) (mark))
5652 (message "region active")
5653 ;; Work on the region between point and mark.
5654 (let ((max (max (point) (mark)))
5657 (goto-char (min (point) (mark)))
5660 (push (setq article (gnus-summary-article-number)) articles)
5661 (gnus-summary-find-next nil article)
5663 (nreverse articles))))
5664 (gnus-newsgroup-processable
5665 ;; There are process-marked articles present.
5666 ;; Save current state.
5667 (gnus-summary-save-process-mark)
5669 (reverse gnus-newsgroup-processable))
5671 ;; Just return the current article.
5672 (list (gnus-summary-article-number))))))
5674 (defmacro gnus-summary-iterate (arg &rest forms)
5675 "Iterate over the process/prefixed articles and do FORMS.
5676 ARG is the interactive prefix given to the command. FORMS will be
5677 executed with point over the summary line of the articles."
5678 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5679 `(let ((,articles (gnus-summary-work-articles ,arg)))
5681 (gnus-summary-goto-subject (car ,articles))
5685 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5686 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5688 (defun gnus-summary-save-process-mark ()
5689 "Push the current set of process marked articles on the stack."
5691 (push (copy-sequence gnus-newsgroup-processable)
5692 gnus-newsgroup-process-stack))
5694 (defun gnus-summary-kill-process-mark ()
5695 "Push the current set of process marked articles on the stack and unmark."
5697 (gnus-summary-save-process-mark)
5698 (gnus-summary-unmark-all-processable))
5700 (defun gnus-summary-yank-process-mark ()
5701 "Pop the last process mark state off the stack and restore it."
5703 (unless gnus-newsgroup-process-stack
5704 (error "Empty mark stack"))
5705 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5707 (defun gnus-summary-process-mark-set (set)
5708 "Make SET into the current process marked articles."
5709 (gnus-summary-unmark-all-processable)
5711 (gnus-summary-set-process-mark (pop set))))
5713 ;;; Searching and stuff
5715 (defun gnus-summary-search-group (&optional backward use-level)
5716 "Search for next unread newsgroup.
5717 If optional argument BACKWARD is non-nil, search backward instead."
5719 (set-buffer gnus-group-buffer)
5720 (when (gnus-group-search-forward
5721 backward nil (if use-level (gnus-group-group-level) nil))
5722 (gnus-group-group-name))))
5724 (defun gnus-summary-best-group (&optional exclude-group)
5725 "Find the name of the best unread group.
5726 If EXCLUDE-GROUP, do not go to this group."
5728 (set-buffer gnus-group-buffer)
5730 (gnus-group-best-unread-group exclude-group))))
5732 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5733 (if backward (gnus-summary-find-prev)
5734 (let* ((dummy (gnus-summary-article-intangible-p))
5735 (article (or article (gnus-summary-article-number)))
5736 (arts (gnus-data-find-list article))
5738 (when (and (not dummy)
5739 (or (not gnus-summary-check-current)
5741 (not (gnus-data-unread-p (car arts)))))
5742 (setq arts (cdr arts)))
5747 (when (or (and undownloaded
5748 (eq gnus-undownloaded-mark
5749 (gnus-data-mark (car arts))))
5750 (gnus-data-unread-p (car arts)))
5751 (setq result (car arts)
5753 (setq arts (cdr arts)))
5756 (goto-char (gnus-data-pos result))
5757 (gnus-data-number result)))))
5759 (defun gnus-summary-find-prev (&optional unread article)
5760 (let* ((eobp (eobp))
5761 (article (or article (gnus-summary-article-number)))
5762 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5764 (when (and (not eobp)
5765 (or (not gnus-summary-check-current)
5767 (not (gnus-data-unread-p (car arts)))))
5768 (setq arts (cdr arts)))
5773 (when (gnus-data-unread-p (car arts))
5774 (setq result (car arts)
5776 (setq arts (cdr arts)))
5779 (goto-char (gnus-data-pos result))
5780 (gnus-data-number result))))
5782 (defun gnus-summary-find-subject (subject &optional unread backward article)
5783 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5784 (article (or article (gnus-summary-article-number)))
5785 (articles (gnus-data-list backward))
5786 (arts (gnus-data-find-list article articles))
5788 (when (or (not gnus-summary-check-current)
5790 (not (gnus-data-unread-p (car arts))))
5791 (setq arts (cdr arts)))
5793 (and (or (not unread)
5794 (gnus-data-unread-p (car arts)))
5795 (vectorp (gnus-data-header (car arts)))
5797 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5798 (setq result (car arts)
5800 (setq arts (cdr arts)))
5802 (goto-char (gnus-data-pos result))
5803 (gnus-data-number result))))
5805 (defun gnus-summary-search-forward (&optional unread subject backward)
5806 "Search forward for an article.
5807 If UNREAD, look for unread articles. If SUBJECT, look for
5808 articles with that subject. If BACKWARD, search backward instead."
5809 (cond (subject (gnus-summary-find-subject subject unread backward))
5810 (backward (gnus-summary-find-prev unread))
5811 (t (gnus-summary-find-next unread))))
5813 (defun gnus-recenter (&optional n)
5814 "Center point in window and redisplay frame.
5815 Also do horizontal recentering."
5817 (when (and gnus-auto-center-summary
5818 (not (eq gnus-auto-center-summary 'vertical)))
5819 (gnus-horizontal-recenter))
5822 (defun gnus-summary-recenter ()
5823 "Center point in the summary window.
5824 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5825 displayed, no centering will be performed."
5826 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5827 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5829 (let* ((top (cond ((< (window-height) 4) 0)
5830 ((< (window-height) 7) 1)
5831 (t (if (numberp gnus-auto-center-summary)
5832 gnus-auto-center-summary
5834 (height (1- (window-height)))
5835 (bottom (save-excursion (goto-char (point-max))
5836 (forward-line (- height))
5838 (window (get-buffer-window (current-buffer))))
5839 ;; The user has to want it.
5840 (when gnus-auto-center-summary
5841 (when (get-buffer-window gnus-article-buffer)
5842 ;; Only do recentering when the article buffer is displayed,
5843 ;; Set the window start to either `bottom', which is the biggest
5844 ;; possible valid number, or the second line from the top,
5845 ;; whichever is the least.
5846 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5847 (if (> bottom top-pos)
5848 ;; Keep the second line from the top visible
5849 (set-window-start window top-pos t)
5850 ;; Try to keep the bottom line visible; if it's partially
5851 ;; obscured, either scroll one more line to make it fully
5852 ;; visible, or revert to using TOP-POS.
5854 (goto-char (point-max))
5856 (let ((last-line-start (point)))
5858 (set-window-start window (point) t)
5859 (when (not (pos-visible-in-window-p last-line-start window))
5861 (set-window-start window (min (point) top-pos) t)))))))
5862 ;; Do horizontal recentering while we're at it.
5863 (when (and (get-buffer-window (current-buffer) t)
5864 (not (eq gnus-auto-center-summary 'vertical)))
5865 (let ((selected (selected-window)))
5866 (select-window (get-buffer-window (current-buffer) t))
5867 (gnus-summary-position-point)
5868 (gnus-horizontal-recenter)
5869 (select-window selected))))))
5871 (defun gnus-summary-jump-to-group (newsgroup)
5872 "Move point to NEWSGROUP in group mode buffer."
5873 ;; Keep update point of group mode buffer if visible.
5874 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5875 (save-window-excursion
5876 ;; Take care of tree window mode.
5877 (when (get-buffer-window gnus-group-buffer)
5878 (pop-to-buffer gnus-group-buffer))
5879 (gnus-group-jump-to-group newsgroup))
5881 ;; Take care of tree window mode.
5882 (if (get-buffer-window gnus-group-buffer)
5883 (pop-to-buffer gnus-group-buffer)
5884 (set-buffer gnus-group-buffer))
5885 (gnus-group-jump-to-group newsgroup))))
5887 ;; This function returns a list of article numbers based on the
5888 ;; difference between the ranges of read articles in this group and
5889 ;; the range of active articles.
5890 (defun gnus-list-of-unread-articles (group)
5891 (let* ((read (gnus-info-read (gnus-get-info group)))
5892 (active (or (gnus-active group) (gnus-activate-group group)))
5895 ;; If none are read, then all are unread.
5897 (setq first (car active))
5898 ;; If the range of read articles is a single range, then the
5899 ;; first unread article is the article after the last read
5900 ;; article. Sounds logical, doesn't it?
5901 (if (and (not (listp (cdr read)))
5902 (or (< (car read) (car active))
5903 (progn (setq read (list read))
5905 (setq first (max (car active) (1+ (cdr read))))
5906 ;; `read' is a list of ranges.
5907 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5910 (setq first (car active)))
5913 (while (< first nlast)
5915 (setq first (1+ first))))
5916 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5917 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5918 (setq read (cdr read)))))
5919 ;; And add the last unread articles.
5920 (while (<= first last)
5922 (setq first (1+ first)))
5923 ;; Return the list of unread articles.
5924 (delq 0 (nreverse unread))))
5926 (defun gnus-list-of-read-articles (group)
5927 "Return a list of unread, unticked and non-dormant articles."
5928 (let* ((info (gnus-get-info group))
5929 (marked (gnus-info-marks info))
5930 (active (gnus-active group)))
5932 (gnus-set-difference
5933 (gnus-sorted-complement
5934 (gnus-uncompress-range active)
5935 (gnus-list-of-unread-articles group))
5937 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5938 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5940 ;; Various summary commands
5942 (defun gnus-summary-select-article-buffer ()
5943 "Reconfigure windows to show article buffer."
5945 (if (not (gnus-buffer-live-p gnus-article-buffer))
5946 (error "There is no article buffer for this summary buffer")
5947 (gnus-configure-windows 'article)
5948 (select-window (get-buffer-window gnus-article-buffer))))
5950 (defun gnus-summary-universal-argument (arg)
5951 "Perform any operation on all articles that are process/prefixed."
5953 (let ((articles (gnus-summary-work-articles arg))
5960 (substitute-command-keys
5961 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5963 (gnus-error 1 "Undefined key")
5966 (gnus-summary-goto-subject (setq article (pop articles)))
5967 (let (gnus-newsgroup-processable)
5968 (command-execute func))
5969 (gnus-summary-remove-process-mark article)))))
5970 (gnus-summary-position-point))
5972 (defun gnus-summary-toggle-truncation (&optional arg)
5973 "Toggle truncation of summary lines.
5974 With arg, turn line truncation on iff arg is positive."
5976 (setq truncate-lines
5977 (if (null arg) (not truncate-lines)
5978 (> (prefix-numeric-value arg) 0)))
5981 (defun gnus-summary-reselect-current-group (&optional all rescan)
5982 "Exit and then reselect the current newsgroup.
5983 The prefix argument ALL means to select all articles."
5985 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5986 (error "Ephemeral groups can't be reselected"))
5987 (let ((current-subject (gnus-summary-article-number))
5988 (group gnus-newsgroup-name))
5989 (setq gnus-newsgroup-begin nil)
5991 ;; We have to adjust the point of group mode buffer because
5992 ;; point was moved to the next unread newsgroup by exiting.
5993 (gnus-summary-jump-to-group group)
5996 (save-window-excursion
5997 ;; Don't show group contents.
5998 (set-window-start (selected-window) (point-max))
5999 (gnus-group-get-new-news-this-group 1))))
6000 (gnus-group-read-group all t)
6001 (gnus-summary-goto-subject current-subject nil t)))
6003 (defun gnus-summary-rescan-group (&optional all)
6004 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6006 (gnus-summary-reselect-current-group all t))
6008 (defun gnus-summary-update-info (&optional non-destructive)
6010 (let ((group gnus-newsgroup-name))
6012 (when gnus-newsgroup-kill-headers
6013 (setq gnus-newsgroup-killed
6014 (gnus-compress-sequence
6016 (gnus-set-sorted-intersection
6017 (gnus-uncompress-range gnus-newsgroup-killed)
6018 (setq gnus-newsgroup-unselected
6019 (sort gnus-newsgroup-unselected '<)))
6020 (setq gnus-newsgroup-unreads
6021 (sort gnus-newsgroup-unreads '<)))
6023 (unless (listp (cdr gnus-newsgroup-killed))
6024 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6025 (let ((headers gnus-newsgroup-headers))
6026 ;; Set the new ranges of read articles.
6028 (set-buffer gnus-group-buffer)
6029 (gnus-undo-force-boundary))
6030 (gnus-update-read-articles
6031 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
6032 ;; Set the current article marks.
6033 (let ((gnus-newsgroup-scored
6034 (if (and (not gnus-save-score)
6035 (not non-destructive))
6037 gnus-newsgroup-scored)))
6039 (gnus-update-marks)))
6040 ;; Do the cross-ref thing.
6041 (when gnus-use-cross-reference
6042 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6043 ;; Do not switch windows but change the buffer to work.
6044 (set-buffer gnus-group-buffer)
6045 (unless (gnus-ephemeral-group-p group)
6046 (gnus-group-update-group group)))))))
6048 (defun gnus-summary-save-newsrc (&optional force)
6049 "Save the current number of read/marked articles in the dribble buffer.
6050 The dribble buffer will then be saved.
6051 If FORCE (the prefix), also save the .newsrc file(s)."
6053 (gnus-summary-update-info t)
6055 (gnus-save-newsrc-file)
6056 (gnus-dribble-save)))
6058 (defun gnus-summary-exit (&optional temporary)
6059 "Exit reading current newsgroup, and then return to group selection mode.
6060 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6062 (gnus-set-global-variables)
6063 (gnus-kill-save-kill-buffer)
6064 (gnus-async-halt-prefetch)
6065 (let* ((group gnus-newsgroup-name)
6066 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6069 (buf (current-buffer)))
6071 ;; Do adaptive scoring, and possibly save score files.
6072 (when gnus-newsgroup-adaptive
6073 (gnus-score-adaptive))
6074 (when gnus-use-scoring
6076 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6077 ;; If we have several article buffers, we kill them at exit.
6078 (unless gnus-single-article-buffer
6079 (gnus-kill-buffer gnus-original-article-buffer)
6080 (setq gnus-article-current nil))
6081 (when gnus-use-cache
6082 (gnus-cache-possibly-remove-articles)
6083 (gnus-cache-save-buffers))
6084 (gnus-async-prefetch-remove-group group)
6085 (when gnus-suppress-duplicates
6086 (gnus-dup-enter-articles))
6087 (when gnus-use-trees
6088 (gnus-tree-close group))
6089 (when gnus-use-cache
6090 (gnus-cache-write-active))
6091 ;; Remove entries for this group.
6092 (nnmail-purge-split-history (gnus-group-real-name group))
6093 ;; Make all changes in this group permanent.
6095 (gnus-run-hooks 'gnus-exit-group-hook)
6096 (gnus-summary-update-info))
6097 (gnus-close-group group)
6098 ;; Make sure where we were, and go to next newsgroup.
6099 (set-buffer gnus-group-buffer)
6101 (gnus-group-jump-to-group group))
6102 (gnus-run-hooks 'gnus-summary-exit-hook)
6103 (unless (or quit-config
6104 ;; If this group has disappeared from the summary
6105 ;; buffer, don't skip forwards.
6106 (not (string= group (gnus-group-group-name))))
6107 (gnus-group-next-unread-group 1))
6108 (setq group-point (point))
6111 ;; If we have several article buffers, we kill them at exit.
6112 (unless gnus-single-article-buffer
6113 (gnus-kill-buffer gnus-article-buffer)
6114 (gnus-kill-buffer gnus-original-article-buffer)
6115 (setq gnus-article-current nil))
6117 (if (not gnus-kill-summary-on-exit)
6119 (gnus-deaden-summary)
6121 ;; We set all buffer-local variables to nil. It is unclear why
6122 ;; this is needed, but if we don't, buffer-local variables are
6123 ;; not garbage-collected, it seems. This would the lead to en
6124 ;; ever-growing Emacs.
6125 (gnus-summary-clear-local-variables)
6126 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6127 (gnus-summary-clear-local-variables))
6128 (when (get-buffer gnus-article-buffer)
6129 (bury-buffer gnus-article-buffer))
6130 ;; We clear the global counterparts of the buffer-local
6131 ;; variables as well, just to be on the safe side.
6132 (set-buffer gnus-group-buffer)
6133 (gnus-summary-clear-local-variables)
6134 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6135 (gnus-summary-clear-local-variables)))
6136 (setq gnus-current-select-method gnus-select-method)
6137 (pop-to-buffer gnus-group-buffer)
6138 (if (not quit-config)
6140 (goto-char group-point)
6141 (gnus-configure-windows 'group 'force)
6142 (unless (pos-visible-in-window-p)
6143 (forward-line (/ (static-if (featurep 'xemacs)
6144 (window-displayed-height)
6145 (1- (window-height)))
6147 (set-window-start (selected-window) (point))
6148 (goto-char group-point)))
6149 (gnus-handle-ephemeral-exit quit-config))
6150 ;; Return to group mode buffer.
6151 (when (eq mode 'gnus-summary-mode)
6152 (gnus-kill-buffer buf))
6153 ;; Clear the current group name.
6155 (setq gnus-newsgroup-name nil)))))
6157 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6158 (defun gnus-summary-exit-no-update (&optional no-questions)
6159 "Quit reading current newsgroup without updating read article info."
6161 (let* ((group gnus-newsgroup-name)
6162 (quit-config (gnus-group-quit-config group)))
6163 (when (or no-questions
6165 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6166 (gnus-async-halt-prefetch)
6168 (delq 'gnus-summary-expire-articles
6169 (copy-sequence gnus-summary-prepare-exit-hook)))
6170 ;; If we have several article buffers, we kill them at exit.
6171 (unless gnus-single-article-buffer
6172 (gnus-kill-buffer gnus-article-buffer)
6173 (gnus-kill-buffer gnus-original-article-buffer)
6174 (setq gnus-article-current nil))
6175 (if (not gnus-kill-summary-on-exit)
6176 (gnus-deaden-summary)
6177 (gnus-close-group group)
6178 (gnus-summary-clear-local-variables)
6179 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6180 (gnus-summary-clear-local-variables))
6181 (set-buffer gnus-group-buffer)
6182 (gnus-summary-clear-local-variables)
6183 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6184 (gnus-summary-clear-local-variables))
6185 (when (get-buffer gnus-summary-buffer)
6186 (kill-buffer gnus-summary-buffer)))
6187 (unless gnus-single-article-buffer
6188 (setq gnus-article-current nil))
6189 (when gnus-use-trees
6190 (gnus-tree-close group))
6191 (gnus-async-prefetch-remove-group group)
6192 (when (get-buffer gnus-article-buffer)
6193 (bury-buffer gnus-article-buffer))
6194 ;; Return to the group buffer.
6195 (gnus-configure-windows 'group 'force)
6196 ;; Clear the current group name.
6197 (setq gnus-newsgroup-name nil)
6198 (when (equal (gnus-group-group-name) group)
6199 (gnus-group-next-unread-group 1))
6201 (gnus-handle-ephemeral-exit quit-config)))))
6203 (defun gnus-handle-ephemeral-exit (quit-config)
6204 "Handle movement when leaving an ephemeral group.
6205 The state which existed when entering the ephemeral is reset."
6206 (if (not (buffer-name (car quit-config)))
6207 (gnus-configure-windows 'group 'force)
6208 (set-buffer (car quit-config))
6209 (cond ((eq major-mode 'gnus-summary-mode)
6210 (gnus-set-global-variables))
6211 ((eq major-mode 'gnus-article-mode)
6213 ;; The `gnus-summary-buffer' variable may point
6214 ;; to the old summary buffer when using a single
6216 (unless (gnus-buffer-live-p gnus-summary-buffer)
6217 (set-buffer gnus-group-buffer))
6218 (set-buffer gnus-summary-buffer)
6219 (gnus-set-global-variables))))
6220 (if (or (eq (cdr quit-config) 'article)
6221 (eq (cdr quit-config) 'pick))
6223 ;; The current article may be from the ephemeral group
6224 ;; thus it is best that we reload this article
6225 (gnus-summary-show-article)
6226 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6227 (gnus-configure-windows 'pick 'force)
6228 (gnus-configure-windows (cdr quit-config) 'force)))
6229 (gnus-configure-windows (cdr quit-config) 'force))
6230 (when (eq major-mode 'gnus-summary-mode)
6231 (gnus-summary-next-subject 1 nil t)
6232 (gnus-summary-recenter)
6233 (gnus-summary-position-point))))
6235 (defun gnus-summary-preview-mime-message ()
6236 "MIME decode and play this message."
6238 (let ((gnus-break-pages nil)
6240 (gnus-summary-select-article gnus-show-all-headers t))
6241 (let ((w (get-buffer-window gnus-article-buffer)))
6243 (select-window (get-buffer-window gnus-article-buffer)))))
6247 (defvar gnus-dead-summary-mode-map nil)
6249 (unless gnus-dead-summary-mode-map
6250 (setq gnus-dead-summary-mode-map (make-keymap))
6251 (suppress-keymap gnus-dead-summary-mode-map)
6252 (substitute-key-definition
6253 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6254 (dolist (key '("\C-d" "\r" "\177" [delete]))
6255 (define-key gnus-dead-summary-mode-map
6256 key 'gnus-summary-wake-up-the-dead))
6257 (dolist (key '("q" "Q"))
6258 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6260 (defvar gnus-dead-summary-mode nil
6261 "Minor mode for Gnus summary buffers.")
6263 (defun gnus-dead-summary-mode (&optional arg)
6264 "Minor mode for Gnus summary buffers."
6266 (when (eq major-mode 'gnus-summary-mode)
6267 (make-local-variable 'gnus-dead-summary-mode)
6268 (setq gnus-dead-summary-mode
6269 (if (null arg) (not gnus-dead-summary-mode)
6270 (> (prefix-numeric-value arg) 0)))
6271 (when gnus-dead-summary-mode
6272 (gnus-add-minor-mode
6273 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6275 (defun gnus-deaden-summary ()
6276 "Make the current summary buffer into a dead summary buffer."
6277 ;; Kill any previous dead summary buffer.
6278 (when (and gnus-dead-summary
6279 (buffer-name gnus-dead-summary))
6281 (set-buffer gnus-dead-summary)
6282 (when gnus-dead-summary-mode
6283 (kill-buffer (current-buffer)))))
6284 ;; Make this the current dead summary.
6285 (setq gnus-dead-summary (current-buffer))
6286 (gnus-dead-summary-mode 1)
6287 (let ((name (buffer-name)))
6288 (when (string-match "Summary" name)
6290 (concat (substring name 0 (match-beginning 0)) "Dead "
6291 (substring name (match-beginning 0)))
6295 (defun gnus-kill-or-deaden-summary (buffer)
6296 "Kill or deaden the summary BUFFER."
6298 (when (and (buffer-name buffer)
6299 (not gnus-single-article-buffer))
6302 (gnus-kill-buffer gnus-article-buffer)
6303 (gnus-kill-buffer gnus-original-article-buffer)))
6306 (gnus-kill-summary-on-exit
6307 (when (and gnus-use-trees
6308 (gnus-buffer-exists-p buffer))
6311 (gnus-tree-close gnus-newsgroup-name)))
6312 (gnus-kill-buffer buffer))
6313 ;; Deaden the buffer.
6314 ((gnus-buffer-exists-p buffer)
6317 (gnus-deaden-summary))))))
6319 (defun gnus-summary-wake-up-the-dead (&rest args)
6320 "Wake up the dead summary buffer."
6322 (gnus-dead-summary-mode -1)
6323 (let ((name (buffer-name)))
6324 (when (string-match "Dead " name)
6326 (concat (substring name 0 (match-beginning 0))
6327 (substring name (match-end 0)))
6329 (gnus-message 3 "This dead summary is now alive again"))
6331 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6332 (defun gnus-summary-fetch-faq (&optional faq-dir)
6333 "Fetch the FAQ for the current group.
6334 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6338 (when current-prefix-arg
6340 "Faq dir: " (and (listp gnus-group-faq-directory)
6341 (mapcar (lambda (file) (list file))
6342 gnus-group-faq-directory))))))
6343 (let (gnus-faq-buffer)
6344 (when (setq gnus-faq-buffer
6345 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6346 (gnus-configure-windows 'summary-faq))))
6348 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6349 (defun gnus-summary-describe-group (&optional force)
6350 "Describe the current newsgroup."
6352 (gnus-group-describe-group force gnus-newsgroup-name))
6354 (defun gnus-summary-describe-briefly ()
6355 "Describe summary mode commands briefly."
6357 (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")))
6359 ;; Walking around group mode buffer from summary mode.
6361 (defun gnus-summary-next-group (&optional no-article target-group backward)
6362 "Exit current newsgroup and then select next unread newsgroup.
6363 If prefix argument NO-ARTICLE is non-nil, no article is selected
6364 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6365 previous group instead."
6367 ;; Stop pre-fetching.
6368 (gnus-async-halt-prefetch)
6369 (let ((current-group gnus-newsgroup-name)
6370 (current-buffer (current-buffer))
6372 ;; First we semi-exit this group to update Xrefs and all variables.
6373 ;; We can't do a real exit, because the window conf must remain
6374 ;; the same in case the user is prompted for info, and we don't
6375 ;; want the window conf to change before that...
6376 (gnus-summary-exit t)
6377 (while (not entered)
6378 ;; Then we find what group we are supposed to enter.
6379 (set-buffer gnus-group-buffer)
6380 (gnus-group-jump-to-group current-group)
6383 (if (eq gnus-keep-same-level 'best)
6384 (gnus-summary-best-group gnus-newsgroup-name)
6385 (gnus-summary-search-group backward gnus-keep-same-level))))
6386 (if (not target-group)
6387 ;; There are no further groups, so we return to the group
6390 (gnus-message 5 "Returning to the group buffer")
6392 (when (gnus-buffer-live-p current-buffer)
6393 (set-buffer current-buffer)
6394 (gnus-summary-exit))
6395 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6396 ;; We try to enter the target group.
6397 (gnus-group-jump-to-group target-group)
6398 (let ((unreads (gnus-group-group-unread)))
6399 (if (and (or (eq t unreads)
6400 (and unreads (not (zerop unreads))))
6401 (gnus-summary-read-group
6402 target-group nil no-article
6403 (and (buffer-name current-buffer) current-buffer)
6406 (setq current-group target-group
6407 target-group nil)))))))
6409 (defun gnus-summary-prev-group (&optional no-article)
6410 "Exit current newsgroup and then select previous unread newsgroup.
6411 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6413 (gnus-summary-next-group no-article nil t))
6415 ;; Walking around summary lines.
6417 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6418 "Go to the first unread subject.
6419 If UNREAD is non-nil, go to the first unread article.
6420 Returns the article selected or nil if there are no unread articles."
6425 ((null gnus-newsgroup-data)
6426 (gnus-message 3 "No articles in the group")
6428 ;; Pick the first article.
6430 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6431 (gnus-data-number (car gnus-newsgroup-data)))
6432 ;; No unread articles.
6433 ((null gnus-newsgroup-unreads)
6434 (gnus-message 3 "No more unread articles")
6436 ;; Find the first unread article.
6438 (let ((data gnus-newsgroup-data))
6440 (and (not (and undownloaded
6441 (eq gnus-undownloaded-mark
6442 (gnus-data-mark (car data)))))
6445 (gnus-data-number (car data))
6446 gnus-newsgroup-unseen))
6447 (not (gnus-data-unread-p (car data))))
6448 (not (gnus-data-unread-p (car data))))))
6449 (setq data (cdr data)))
6451 (goto-char (gnus-data-pos (car data)))
6452 (gnus-data-number (car data))))))
6453 (gnus-summary-position-point)))
6455 (defun gnus-summary-next-subject (n &optional unread dont-display)
6456 "Go to next N'th summary line.
6457 If N is negative, go to the previous N'th subject line.
6458 If UNREAD is non-nil, only unread articles are selected.
6459 The difference between N and the actual number of steps taken is
6462 (let ((backward (< n 0))
6466 (gnus-summary-find-prev unread)
6467 (gnus-summary-find-next unread)))
6468 (unless (zerop (setq n (1- n)))
6469 (gnus-summary-show-thread)))
6471 (gnus-message 7 "No more%s articles"
6472 (if unread " unread" "")))
6473 (unless dont-display
6474 (gnus-summary-recenter)
6475 (gnus-summary-position-point))
6478 (defun gnus-summary-next-unread-subject (n)
6479 "Go to next N'th unread summary line."
6481 (gnus-summary-next-subject n t))
6483 (defun gnus-summary-prev-subject (n &optional unread)
6484 "Go to previous N'th summary line.
6485 If optional argument UNREAD is non-nil, only unread article is selected."
6487 (gnus-summary-next-subject (- n) unread))
6489 (defun gnus-summary-prev-unread-subject (n)
6490 "Go to previous N'th unread summary line."
6492 (gnus-summary-next-subject (- n) t))
6494 (defun gnus-summary-goto-subject (article &optional force silent)
6495 "Go the subject line of ARTICLE.
6496 If FORCE, also allow jumping to articles not currently shown."
6497 (interactive "nArticle number: ")
6498 (unless (numberp article)
6499 (error "Article %s is not a number" article))
6501 (data (gnus-data-find article)))
6502 ;; We read in the article if we have to.
6505 (gnus-summary-insert-subject
6507 (if (or (numberp force) (vectorp force)) force)
6509 (setq data (gnus-data-find article)))
6514 (gnus-message 3 "Can't find article %d" article))
6516 (let ((pt (gnus-data-pos data)))
6518 (gnus-summary-set-article-display-arrow pt))
6519 (gnus-summary-position-point)
6522 ;; Walking around summary lines with displaying articles.
6524 (defun gnus-summary-expand-window (&optional arg)
6525 "Make the summary buffer take up the entire Emacs frame.
6526 Given a prefix, will force an `article' buffer configuration."
6529 (gnus-configure-windows 'article 'force)
6530 (gnus-configure-windows 'summary 'force)))
6532 (defun gnus-summary-display-article (article &optional all-header)
6533 "Display ARTICLE in article buffer."
6534 (when (gnus-buffer-live-p gnus-article-buffer)
6535 (with-current-buffer gnus-article-buffer
6536 (set-buffer-multibyte t)))
6537 (gnus-set-global-variables)
6538 (when (gnus-buffer-live-p gnus-article-buffer)
6539 (with-current-buffer gnus-article-buffer
6540 (setq gnus-article-charset gnus-newsgroup-charset)
6541 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6542 (set-buffer-multibyte t)))
6546 (if gnus-summary-display-article-function
6547 (funcall gnus-summary-display-article-function article all-header)
6548 (gnus-article-prepare article all-header))
6549 (with-current-buffer gnus-article-buffer
6550 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6552 (gnus-run-hooks 'gnus-select-article-hook)
6553 (when (and gnus-current-article
6554 (not (zerop gnus-current-article)))
6555 (gnus-summary-goto-subject gnus-current-article))
6556 (gnus-summary-recenter)
6557 (when (and gnus-use-trees gnus-show-threads)
6558 (gnus-possibly-generate-tree article)
6559 (gnus-highlight-selected-tree article))
6560 ;; Successfully display article.
6561 (gnus-article-set-window-start
6562 (cdr (assq article gnus-newsgroup-bookmarks))))))
6564 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6565 "Select the current article.
6566 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6567 non-nil, the article will be re-fetched even if it already present in
6568 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6570 ;; Make sure we are in the summary buffer to work around bbdb bug.
6571 (unless (eq major-mode 'gnus-summary-mode)
6572 (set-buffer gnus-summary-buffer))
6573 (let ((article (or article (gnus-summary-article-number)))
6574 (all-headers (not (not all-headers))) ;Must be T or NIL.
6575 gnus-summary-display-article-function)
6577 (gnus-summary-article-pseudo-p article)
6578 (error "This is a pseudo-article"))
6580 (set-buffer gnus-summary-buffer)
6581 (if (or (and gnus-single-article-buffer
6582 (or (null gnus-current-article)
6583 (null gnus-article-current)
6584 (null (get-buffer gnus-article-buffer))
6585 (not (eq article (cdr gnus-article-current)))
6586 (not (equal (car gnus-article-current)
6587 gnus-newsgroup-name))))
6588 (and (not gnus-single-article-buffer)
6589 (or (null gnus-current-article)
6590 (not (eq gnus-current-article article))))
6592 ;; The requested article is different from the current article.
6594 (gnus-summary-display-article article all-headers)
6595 ;;; Hidden headers are not hidden text any more.
6596 ;; (when (or all-headers gnus-show-all-headers)
6597 ;; (gnus-article-show-all-headers))
6598 (gnus-article-set-window-start
6599 (cdr (assq article gnus-newsgroup-bookmarks)))
6601 ;; (when (or all-headers gnus-show-all-headers)
6602 ;; (gnus-article-show-all-headers))
6605 (defun gnus-summary-force-verify-and-decrypt ()
6607 (let ((mm-verify-option 'known)
6608 (mm-decrypt-option 'known))
6609 (gnus-summary-select-article nil 'force)))
6611 (defun gnus-summary-set-current-mark (&optional current-mark)
6612 "Obsolete function."
6615 (defun gnus-summary-next-article (&optional unread subject backward push)
6616 "Select the next article.
6617 If UNREAD, only unread articles are selected.
6618 If SUBJECT, only articles with SUBJECT are selected.
6619 If BACKWARD, the previous article is selected instead of the next."
6622 ;; Is there such an article?
6623 ((and (gnus-summary-search-forward unread subject backward)
6624 (or (gnus-summary-display-article (gnus-summary-article-number))
6625 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6626 (gnus-summary-position-point))
6627 ;; If not, we try the first unread, if that is wanted.
6629 gnus-auto-select-same
6630 (gnus-summary-first-unread-article))
6631 (gnus-summary-position-point)
6632 (gnus-message 6 "Wrapped"))
6633 ;; Try to get next/previous article not displayed in this group.
6634 ((and gnus-auto-extend-newsgroup
6635 (not unread) (not subject))
6636 (gnus-summary-goto-article
6637 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6638 nil (count-lines (point-min) (point))))
6639 ;; Go to next/previous group.
6641 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6642 (gnus-summary-jump-to-group gnus-newsgroup-name))
6643 (let ((cmd last-command-char)
6646 (set-buffer gnus-group-buffer)
6649 (if (eq gnus-keep-same-level 'best)
6650 (gnus-summary-best-group gnus-newsgroup-name)
6651 (gnus-summary-search-group backward gnus-keep-same-level))))
6652 ;; For some reason, the group window gets selected. We change
6654 (select-window (get-buffer-window (current-buffer)))
6655 ;; Select next unread newsgroup automagically.
6657 ((or (not gnus-auto-select-next)
6659 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6660 ((or (eq gnus-auto-select-next 'quietly)
6661 (and (eq gnus-auto-select-next 'slightly-quietly)
6663 (and (eq gnus-auto-select-next 'almost-quietly)
6664 (gnus-summary-last-article-p)))
6666 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6668 (gnus-message 7 "No more%s articles (%s)..."
6669 (if unread " unread" "")
6670 (if group (concat "selecting " group)
6672 (gnus-summary-next-group nil group backward)))
6674 (when (gnus-key-press-event-p last-input-event)
6675 (gnus-summary-walk-group-buffer
6676 gnus-newsgroup-name cmd unread backward point))))))))
6678 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6679 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6680 (?\C-p (gnus-group-prev-unread-group 1))))
6681 (cursor-in-echo-area t)
6682 keve key group ended)
6684 (set-buffer gnus-group-buffer)
6687 (if (eq gnus-keep-same-level 'best)
6688 (gnus-summary-best-group gnus-newsgroup-name)
6689 (gnus-summary-search-group backward gnus-keep-same-level))))
6692 5 "No more%s articles%s" (if unread " unread" "")
6694 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6695 (format " (Type %s for %s [%s])"
6696 (single-key-description cmd) group
6697 (car (gnus-gethash group gnus-newsrc-hashtb)))
6698 (format " (Type %s to exit %s)"
6699 (single-key-description cmd)
6700 gnus-newsgroup-name)))
6701 ;; Confirm auto selection.
6702 (setq key (car (setq keve (gnus-read-event-char))))
6705 ((assq key keystrokes)
6706 (let ((obuf (current-buffer)))
6707 (switch-to-buffer gnus-group-buffer)
6709 (gnus-group-jump-to-group group))
6710 (eval (cadr (assq key keystrokes)))
6711 (setq group (gnus-group-group-name))
6712 (switch-to-buffer obuf))
6716 (gnus-ephemeral-group-p gnus-newsgroup-name))
6718 (gnus-summary-next-group nil group backward)))
6720 (push (cdr keve) unread-command-events))))))
6722 (defun gnus-summary-next-unread-article ()
6723 "Select unread article after current one."
6725 (gnus-summary-next-article
6726 (or (not (eq gnus-summary-goto-unread 'never))
6727 (gnus-summary-last-article-p (gnus-summary-article-number)))
6728 (and gnus-auto-select-same
6729 (gnus-summary-article-subject))))
6731 (defun gnus-summary-prev-article (&optional unread subject)
6732 "Select the article after the current one.
6733 If UNREAD is non-nil, only unread articles are selected."
6735 (gnus-summary-next-article unread subject t))
6737 (defun gnus-summary-prev-unread-article ()
6738 "Select unread article before current one."
6740 (gnus-summary-prev-article
6741 (or (not (eq gnus-summary-goto-unread 'never))
6742 (gnus-summary-first-article-p (gnus-summary-article-number)))
6743 (and gnus-auto-select-same
6744 (gnus-summary-article-subject))))
6746 (defun gnus-summary-next-page (&optional lines circular)
6747 "Show next page of the selected article.
6748 If at the end of the current article, select the next article.
6749 LINES says how many lines should be scrolled up.
6751 If CIRCULAR is non-nil, go to the start of the article instead of
6752 selecting the next article when reaching the end of the current
6755 (setq gnus-summary-buffer (current-buffer))
6756 (gnus-set-global-variables)
6757 (let ((article (gnus-summary-article-number))
6758 (article-window (get-buffer-window gnus-article-buffer t))
6760 ;; If the buffer is empty, we have no article.
6762 (error "No article to select"))
6763 (gnus-configure-windows 'article)
6764 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6765 (if (and (eq gnus-summary-goto-unread 'never)
6766 (not (gnus-summary-last-article-p article)))
6767 (gnus-summary-next-article)
6768 (gnus-summary-next-unread-article))
6769 (if (or (null gnus-current-article)
6770 (null gnus-article-current)
6771 (/= article (cdr gnus-article-current))
6772 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6773 ;; Selected subject is different from current article's.
6774 (gnus-summary-display-article article)
6775 (when article-window
6776 (gnus-eval-in-buffer-window gnus-article-buffer
6777 (setq endp (gnus-article-next-page lines)))
6780 (gnus-summary-beginning-of-article))
6782 (gnus-message 3 "End of message"))
6784 (if (and (eq gnus-summary-goto-unread 'never)
6785 (not (gnus-summary-last-article-p article)))
6786 (gnus-summary-next-article)
6787 (gnus-summary-next-unread-article))))))))
6788 (gnus-summary-recenter)
6789 (gnus-summary-position-point)))
6791 (defun gnus-summary-prev-page (&optional lines move)
6792 "Show previous page of selected article.
6793 Argument LINES specifies lines to be scrolled down.
6794 If MOVE, move to the previous unread article if point is at
6795 the beginning of the buffer."
6797 (let ((article (gnus-summary-article-number))
6798 (article-window (get-buffer-window gnus-article-buffer t))
6800 (gnus-configure-windows 'article)
6801 (if (or (null gnus-current-article)
6802 (null gnus-article-current)
6803 (/= article (cdr gnus-article-current))
6804 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6805 ;; Selected subject is different from current article's.
6806 (gnus-summary-display-article article)
6807 (gnus-summary-recenter)
6808 (when article-window
6809 (gnus-eval-in-buffer-window gnus-article-buffer
6810 (setq endp (gnus-article-prev-page lines)))
6811 (when (and move endp)
6813 (gnus-message 3 "Beginning of message"))
6815 (if (and (eq gnus-summary-goto-unread 'never)
6816 (not (gnus-summary-first-article-p article)))
6817 (gnus-summary-prev-article)
6818 (gnus-summary-prev-unread-article))))))))
6819 (gnus-summary-position-point))
6821 (defun gnus-summary-prev-page-or-article (&optional lines)
6822 "Show previous page of selected article.
6823 Argument LINES specifies lines to be scrolled down.
6824 If at the beginning of the article, go to the next article."
6826 (gnus-summary-prev-page lines t))
6828 (defun gnus-summary-scroll-up (lines)
6829 "Scroll up (or down) one line current article.
6830 Argument LINES specifies lines to be scrolled up (or down if negative)."
6832 (gnus-configure-windows 'article)
6833 (gnus-summary-show-thread)
6834 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6835 (gnus-eval-in-buffer-window gnus-article-buffer
6837 (when (gnus-article-next-page lines)
6838 (gnus-message 3 "End of message")))
6840 (gnus-article-prev-page (- lines))))))
6841 (gnus-summary-recenter)
6842 (gnus-summary-position-point))
6844 (defun gnus-summary-scroll-down (lines)
6845 "Scroll down (or up) one line current article.
6846 Argument LINES specifies lines to be scrolled down (or up if negative)."
6848 (gnus-summary-scroll-up (- lines)))
6850 (defun gnus-summary-next-same-subject ()
6851 "Select next article which has the same subject as current one."
6853 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6855 (defun gnus-summary-prev-same-subject ()
6856 "Select previous article which has the same subject as current one."
6858 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6860 (defun gnus-summary-next-unread-same-subject ()
6861 "Select next unread article which has the same subject as current one."
6863 (gnus-summary-next-article t (gnus-summary-article-subject)))
6865 (defun gnus-summary-prev-unread-same-subject ()
6866 "Select previous unread article which has the same subject as current one."
6868 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6870 (defun gnus-summary-first-unread-article ()
6871 "Select the first unread article.
6872 Return nil if there are no unread articles."
6875 (when (gnus-summary-first-subject t)
6876 (gnus-summary-show-thread)
6877 (gnus-summary-first-subject t)
6878 (gnus-summary-display-article (gnus-summary-article-number)))
6879 (gnus-summary-position-point)))
6881 (defun gnus-summary-first-unread-subject ()
6882 "Place the point on the subject line of the first unread article.
6883 Return nil if there are no unread articles."
6886 (when (gnus-summary-first-subject t)
6887 (gnus-summary-show-thread)
6888 (gnus-summary-first-subject t))
6889 (gnus-summary-position-point)))
6891 (defun gnus-summary-first-unseen-subject ()
6892 "Place the point on the subject line of the first unseen article.
6893 Return nil if there are no unseen articles."
6896 (when (gnus-summary-first-subject t t t)
6897 (gnus-summary-show-thread)
6898 (gnus-summary-first-subject t t t))
6899 (gnus-summary-position-point)))
6901 (defun gnus-summary-first-unseen-or-unread-subject ()
6902 "Place the point on the subject line of the first unseen article.
6903 Return nil if there are no unseen articles."
6906 (unless (when (gnus-summary-first-subject t t t)
6907 (gnus-summary-show-thread)
6908 (gnus-summary-first-subject t t t))
6909 (when (gnus-summary-first-subject t)
6910 (gnus-summary-show-thread)
6911 (gnus-summary-first-subject t)))
6912 (gnus-summary-position-point)))
6914 (defun gnus-summary-first-article ()
6915 "Select the first article.
6916 Return nil if there are no articles."
6919 (when (gnus-summary-first-subject)
6920 (gnus-summary-show-thread)
6921 (gnus-summary-first-subject)
6922 (gnus-summary-display-article (gnus-summary-article-number)))
6923 (gnus-summary-position-point)))
6925 (defun gnus-summary-best-unread-article (&optional arg)
6926 "Select the unread article with the highest score.
6927 If given a prefix argument, select the next unread article that has a
6928 score higher than the default score."
6930 (let ((article (if arg
6931 (gnus-summary-better-unread-subject)
6932 (gnus-summary-best-unread-subject))))
6934 (gnus-summary-goto-article article)
6935 (error "No unread articles"))))
6937 (defun gnus-summary-best-unread-subject ()
6938 "Select the unread subject with the highest score."
6940 (let ((best -1000000)
6941 (data gnus-newsgroup-data)
6944 (and (gnus-data-unread-p (car data))
6946 (gnus-summary-article-score (gnus-data-number (car data))))
6949 article (gnus-data-number (car data))))
6950 (setq data (cdr data)))
6952 (gnus-summary-goto-subject article))
6953 (gnus-summary-position-point)
6956 (defun gnus-summary-better-unread-subject ()
6957 "Select the first unread subject that has a score over the default score."
6959 (let ((data gnus-newsgroup-data)
6961 (while (and (setq article (gnus-data-number (car data)))
6962 (or (gnus-data-read-p (car data))
6963 (not (> (gnus-summary-article-score article)
6964 gnus-summary-default-score))))
6965 (setq data (cdr data)))
6967 (gnus-summary-goto-subject article))
6968 (gnus-summary-position-point)
6971 (defun gnus-summary-last-subject ()
6972 "Go to the last displayed subject line in the group."
6973 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6975 (gnus-summary-goto-subject article))))
6977 (defun gnus-summary-goto-article (article &optional all-headers force)
6978 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6979 If ALL-HEADERS is non-nil, no header lines are hidden.
6980 If FORCE, go to the article even if it isn't displayed. If FORCE
6981 is a number, it is the line the article is to be displayed on."
6985 "Article number or Message-ID: "
6986 (mapcar (lambda (number) (list (int-to-string number)))
6987 gnus-newsgroup-limit))
6991 (if (and (stringp article)
6992 (string-match "@" article))
6993 (gnus-summary-refer-article article)
6994 (when (stringp article)
6995 (setq article (string-to-number article)))
6996 (if (gnus-summary-goto-subject article force)
6997 (gnus-summary-display-article article all-headers)
6998 (gnus-message 4 "Couldn't go to article %s" article) nil))
6999 (gnus-summary-position-point)))
7001 (defun gnus-summary-goto-last-article ()
7002 "Go to the previously read article."
7005 (when gnus-last-article
7006 (gnus-summary-goto-article gnus-last-article nil t))
7007 (gnus-summary-position-point)))
7009 (defun gnus-summary-pop-article (number)
7010 "Pop one article off the history and go to the previous.
7011 NUMBER articles will be popped off."
7014 (setq gnus-newsgroup-history
7015 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7017 (gnus-summary-goto-article (car to) nil t)
7018 (error "Article history empty")))
7019 (gnus-summary-position-point))
7021 ;; Summary commands and functions for limiting the summary buffer.
7023 (defun gnus-summary-limit-to-articles (n)
7024 "Limit the summary buffer to the next N articles.
7025 If not given a prefix, use the process marked articles instead."
7028 (let ((articles (gnus-summary-work-articles n)))
7029 (setq gnus-newsgroup-processable nil)
7030 (gnus-summary-limit articles))
7031 (gnus-summary-position-point)))
7033 (defun gnus-summary-pop-limit (&optional total)
7034 "Restore the previous limit.
7035 If given a prefix, remove all limits."
7038 (setq gnus-newsgroup-limits
7039 (list (mapcar (lambda (h) (mail-header-number h))
7040 gnus-newsgroup-headers))))
7041 (unless gnus-newsgroup-limits
7042 (error "No limit to pop"))
7044 (gnus-summary-limit nil 'pop)
7045 (gnus-summary-position-point)))
7047 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7048 "Limit the summary buffer to articles that have subjects that match a regexp.
7049 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7051 (list (read-string (if current-prefix-arg
7052 "Exclude subject (regexp): "
7053 "Limit to subject (regexp): "))
7054 nil current-prefix-arg))
7056 (setq header "subject"))
7057 (when (not (equal "" subject))
7059 (let ((articles (gnus-summary-find-matching
7060 (or header "subject") subject 'all nil nil
7063 (error "Found no matches for \"%s\"" subject))
7064 (gnus-summary-limit articles))
7065 (gnus-summary-position-point))))
7067 (defun gnus-summary-limit-to-author (from &optional not-matching)
7068 "Limit the summary buffer to articles that have authors that match a regexp.
7069 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7071 (list (read-string (if current-prefix-arg
7072 "Exclude author (regexp): "
7073 "Limit to author (regexp): "))
7074 current-prefix-arg))
7075 (gnus-summary-limit-to-subject from "from" not-matching))
7077 (defun gnus-summary-limit-to-age (age &optional younger-p)
7078 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7079 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7080 articles that are younger than AGE days."
7082 (let ((younger current-prefix-arg)
7085 (while (not days-got)
7086 (setq days (if younger
7087 (read-string "Limit to articles within (in days): ")
7088 (read-string "Limit to articles older than (in days): ")))
7089 (when (> (length days) 0)
7090 (setq days (read days)))
7096 (setq younger (not younger))
7097 (setq days (* days -1)))))
7098 (message "Please enter a number.")
7100 (list days younger)))
7102 (let ((data gnus-newsgroup-data)
7103 (cutoff (days-to-time age))
7104 articles d date is-younger)
7105 (while (setq d (pop data))
7106 (when (and (vectorp (gnus-data-header d))
7107 (setq date (mail-header-date (gnus-data-header d))))
7108 (setq is-younger (time-less-p
7109 (time-since (condition-case ()
7116 (push (gnus-data-number d) articles))))
7117 (gnus-summary-limit (nreverse articles)))
7118 (gnus-summary-position-point)))
7120 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7121 "Limit the summary buffer to articles that match an 'extra' header."
7125 (gnus-completing-read-with-default
7126 (symbol-name (car gnus-extra-headers))
7127 (if current-prefix-arg
7128 "Exclude extra header:"
7129 "Limit extra header:")
7131 (cons (symbol-name x) x))
7136 (read-string (format "%s header %s (regexp): "
7137 (if current-prefix-arg "Exclude" "Limit to")
7139 current-prefix-arg)))
7140 (when (not (equal "" regexp))
7142 (let ((articles (gnus-summary-find-matching
7143 (cons 'extra header) regexp 'all nil nil
7146 (error "Found no matches for \"%s\"" regexp))
7147 (gnus-summary-limit articles))
7148 (gnus-summary-position-point))))
7150 (defun gnus-summary-limit-to-display-predicate ()
7151 "Limit the summary buffer to the predicated in the `display' group parameter."
7153 (unless gnus-newsgroup-display
7154 (error "There is no `display' group parameter"))
7156 (dolist (number gnus-newsgroup-articles)
7157 (when (funcall gnus-newsgroup-display)
7158 (push number articles)))
7159 (gnus-summary-limit articles))
7160 (gnus-summary-position-point))
7162 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7164 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7166 (defun gnus-summary-limit-to-unread (&optional all)
7167 "Limit the summary buffer to articles that are not marked as read.
7168 If ALL is non-nil, limit strictly to unread articles."
7171 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7172 (gnus-summary-limit-to-marks
7173 ;; Concat all the marks that say that an article is read and have
7175 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7176 gnus-killed-mark gnus-kill-file-mark
7177 gnus-low-score-mark gnus-expirable-mark
7178 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7179 gnus-duplicate-mark gnus-souped-mark)
7182 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7183 (make-obsolete 'gnus-summary-delete-marked-with
7184 'gnus-summary-limit-exlude-marks)
7186 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7187 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7188 If REVERSE, limit the summary buffer to articles that are marked
7189 with MARKS. MARKS can either be a string of marks or a list of marks.
7190 Returns how many articles were removed."
7191 (interactive "sMarks: ")
7192 (gnus-summary-limit-to-marks marks t))
7194 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7195 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7196 If REVERSE (the prefix), limit the summary buffer to articles that are
7197 not marked with MARKS. MARKS can either be a string of marks or a
7199 Returns how many articles were removed."
7200 (interactive "sMarks: \nP")
7202 (let ((data gnus-newsgroup-data)
7203 (marks (if (listp marks) marks
7204 (append marks nil))) ; Transform to list.
7207 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7208 (memq (gnus-data-mark (car data)) marks))
7209 (push (gnus-data-number (car data)) articles))
7210 (setq data (cdr data)))
7211 (gnus-summary-limit articles))
7212 (gnus-summary-position-point)))
7214 (defun gnus-summary-limit-to-score (score)
7215 "Limit to articles with score at or above SCORE."
7216 (interactive "NLimit to articles with score of at least: ")
7217 (let ((data gnus-newsgroup-data)
7220 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7222 (push (gnus-data-number (car data)) articles))
7223 (setq data (cdr data)))
7225 (gnus-summary-limit articles)
7226 (gnus-summary-position-point))))
7228 (defun gnus-summary-limit-include-thread (id)
7229 "Display all the hidden articles that is in the thread with ID in it.
7230 When called interactively, ID is the Message-ID of the current
7232 (interactive (list (mail-header-id (gnus-summary-article-header))))
7233 (let ((articles (gnus-articles-in-thread
7234 (gnus-id-to-thread (gnus-root-id id)))))
7236 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7237 (gnus-summary-limit-include-matching-articles
7239 (regexp-quote (gnus-simplify-subject-re
7240 (mail-header-subject (gnus-id-to-header id)))))
7241 (gnus-summary-position-point))))
7243 (defun gnus-summary-limit-include-matching-articles (header regexp)
7244 "Display all the hidden articles that have HEADERs that match REGEXP."
7245 (interactive (list (read-string "Match on header: ")
7246 (read-string "Regexp: ")))
7247 (let ((articles (gnus-find-matching-articles header regexp)))
7249 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7250 (gnus-summary-position-point))))
7252 (defun gnus-summary-limit-include-dormant ()
7253 "Display all the hidden articles that are marked as dormant.
7254 Note that this command only works on a subset of the articles currently
7255 fetched for this group."
7257 (unless gnus-newsgroup-dormant
7258 (error "There are no dormant articles in this group"))
7260 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7261 (gnus-summary-position-point)))
7263 (defun gnus-summary-limit-exclude-dormant ()
7264 "Hide all dormant articles."
7267 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7268 (gnus-summary-position-point)))
7270 (defun gnus-summary-limit-exclude-childless-dormant ()
7271 "Hide all dormant articles that have no children."
7273 (let ((data (gnus-data-list t))
7274 articles d children)
7275 ;; Find all articles that are either not dormant or have
7277 (while (setq d (pop data))
7278 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7280 (gnus-article-children (gnus-data-number d)))
7283 (when (memq (car children) articles)
7288 (push (gnus-data-number d) articles)))
7291 (gnus-summary-limit articles)
7292 (gnus-summary-position-point))))
7294 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7295 "Mark all unread excluded articles as read.
7296 If ALL, mark even excluded ticked and dormants as read."
7298 (let ((articles (gnus-sorted-complement
7300 (mapcar (lambda (h) (mail-header-number h))
7301 gnus-newsgroup-headers)
7303 (sort gnus-newsgroup-limit '<)))
7305 (setq gnus-newsgroup-unreads
7306 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7308 (setq gnus-newsgroup-dormant nil
7309 gnus-newsgroup-marked nil
7310 gnus-newsgroup-reads
7312 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7313 gnus-newsgroup-reads))
7314 (while (setq article (pop articles))
7315 (unless (or (memq article gnus-newsgroup-dormant)
7316 (memq article gnus-newsgroup-marked))
7317 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7319 (defun gnus-summary-limit (articles &optional pop)
7321 ;; We pop the previous limit off the stack and use that.
7322 (setq articles (car gnus-newsgroup-limits)
7323 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7324 ;; We use the new limit, so we push the old limit on the stack.
7325 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7327 (setq gnus-newsgroup-limit articles)
7328 (let ((total (length gnus-newsgroup-data))
7329 (data (gnus-data-find-list (gnus-summary-article-number)))
7330 (gnus-summary-mark-below nil) ; Inhibit this.
7332 ;; This will do all the work of generating the new summary buffer
7333 ;; according to the new limit.
7334 (gnus-summary-prepare)
7335 ;; Hide any threads, possibly.
7336 (gnus-summary-maybe-hide-threads)
7337 ;; Try to return to the article you were at, or one in the
7340 ;; We try to find some article after the current one.
7342 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7345 (setq data (cdr data))))
7347 ;; If there is no data, that means that we were after the last
7348 ;; article. The same goes when we can't find any articles
7349 ;; after the current one.
7350 (goto-char (point-max))
7351 (gnus-summary-find-prev))
7352 (gnus-set-mode-line 'summary)
7353 ;; We return how many articles were removed from the summary
7354 ;; buffer as a result of the new limit.
7355 (- total (length gnus-newsgroup-data))))
7357 (defsubst gnus-invisible-cut-children (threads)
7360 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7365 (defsubst gnus-cut-thread (thread)
7366 "Go forwards in the thread until we find an article that we want to display."
7367 (when (or (eq gnus-fetch-old-headers 'some)
7368 (eq gnus-fetch-old-headers 'invisible)
7369 (numberp gnus-fetch-old-headers)
7370 (eq gnus-build-sparse-threads 'some)
7371 (eq gnus-build-sparse-threads 'more))
7372 ;; Deal with old-fetched headers and sparse threads.
7376 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7377 (gnus-summary-article-ancient-p
7378 (mail-header-number (car thread))))
7379 (if (or (<= (length (cdr thread)) 1)
7380 (eq gnus-fetch-old-headers 'invisible))
7381 (setq gnus-newsgroup-limit
7382 (delq (mail-header-number (car thread))
7383 gnus-newsgroup-limit)
7384 thread (cadr thread))
7385 (when (gnus-invisible-cut-children (cdr thread))
7386 (let ((th (cdr thread)))
7388 (if (memq (mail-header-number (caar th))
7389 gnus-newsgroup-limit)
7390 (setq thread (car th)
7392 (setq th (cdr th))))))))))
7395 (defun gnus-cut-threads (threads)
7396 "Cut off all uninteresting articles from the beginning of threads."
7397 (when (or (eq gnus-fetch-old-headers 'some)
7398 (eq gnus-fetch-old-headers 'invisible)
7399 (numberp gnus-fetch-old-headers)
7400 (eq gnus-build-sparse-threads 'some)
7401 (eq gnus-build-sparse-threads 'more))
7404 (setcar th (gnus-cut-thread (car th)))
7405 (setq th (cdr th)))))
7406 ;; Remove nixed out threads.
7409 (defun gnus-summary-initial-limit (&optional show-if-empty)
7410 "Figure out what the initial limit is supposed to be on group entry.
7411 This entails weeding out unwanted dormants, low-scored articles,
7412 fetch-old-headers verbiage, and so on."
7413 ;; Most groups have nothing to remove.
7414 (if (or gnus-inhibit-limiting
7415 (and (null gnus-newsgroup-dormant)
7416 (eq gnus-newsgroup-display 'gnus-not-ignore)
7417 (not (eq gnus-fetch-old-headers 'some))
7418 (not (numberp gnus-fetch-old-headers))
7419 (not (eq gnus-fetch-old-headers 'invisible))
7420 (null gnus-summary-expunge-below)
7421 (not (eq gnus-build-sparse-threads 'some))
7422 (not (eq gnus-build-sparse-threads 'more))
7423 (null gnus-thread-expunge-below)
7424 (not gnus-use-nocem)))
7426 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7427 (setq gnus-newsgroup-limit nil)
7430 (unless (car (symbol-value node))
7431 ;; These threads have no parents -- they are roots.
7432 (let ((nodes (cdr (symbol-value node)))
7435 (if (and gnus-thread-expunge-below
7436 (< (gnus-thread-total-score (car nodes))
7437 gnus-thread-expunge-below))
7438 (gnus-expunge-thread (pop nodes))
7439 (setq thread (pop nodes))
7440 (gnus-summary-limit-children thread))))))
7441 gnus-newsgroup-dependencies)
7442 ;; If this limitation resulted in an empty group, we might
7443 ;; pop the previous limit and use it instead.
7444 (when (and (not gnus-newsgroup-limit)
7446 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7447 gnus-newsgroup-limit))
7449 (defun gnus-summary-limit-children (thread)
7450 "Return 1 if this subthread is visible and 0 if it is not."
7451 ;; First we get the number of visible children to this thread. This
7452 ;; is done by recursing down the thread using this function, so this
7453 ;; will really go down to a leaf article first, before slowly
7454 ;; working its way up towards the root.
7458 (apply '+ (mapcar 'gnus-summary-limit-children
7461 (number (mail-header-number (car thread)))
7464 (not (memq number gnus-newsgroup-marked))
7466 ;; If this article is dormant and has absolutely no visible
7467 ;; children, then this article isn't visible.
7468 (and (memq number gnus-newsgroup-dormant)
7470 ;; If this is "fetch-old-headered" and there is no
7471 ;; visible children, then we don't want this article.
7472 (and (or (eq gnus-fetch-old-headers 'some)
7473 (numberp gnus-fetch-old-headers))
7474 (gnus-summary-article-ancient-p number)
7476 ;; If this is "fetch-old-headered" and `invisible', then
7477 ;; we don't want this article.
7478 (and (eq gnus-fetch-old-headers 'invisible)
7479 (gnus-summary-article-ancient-p number))
7480 ;; If this is a sparsely inserted article with no children,
7481 ;; we don't want it.
7482 (and (eq gnus-build-sparse-threads 'some)
7483 (gnus-summary-article-sparse-p number)
7485 ;; If we use expunging, and this article is really
7486 ;; low-scored, then we don't want this article.
7487 (when (and gnus-summary-expunge-below
7489 (or (cdr (assq number gnus-newsgroup-scored))
7490 gnus-summary-default-score))
7491 gnus-summary-expunge-below))
7492 ;; We increase the expunge-tally here, but that has
7493 ;; nothing to do with the limits, really.
7494 (incf gnus-newsgroup-expunged-tally)
7495 ;; We also mark as read here, if that's wanted.
7496 (when (and gnus-summary-mark-below
7497 (< score gnus-summary-mark-below))
7498 (setq gnus-newsgroup-unreads
7499 (delq number gnus-newsgroup-unreads))
7500 (if gnus-newsgroup-auto-expire
7501 (push number gnus-newsgroup-expirable)
7502 (push (cons number gnus-low-score-mark)
7503 gnus-newsgroup-reads)))
7505 ;; Do the `display' group parameter.
7506 (and gnus-newsgroup-display
7507 (not (funcall gnus-newsgroup-display)))
7508 ;; Check NoCeM things.
7509 (if (and gnus-use-nocem
7510 (gnus-nocem-unwanted-article-p
7511 (mail-header-id (car thread))))
7513 (setq gnus-newsgroup-unreads
7514 (delq number gnus-newsgroup-unreads))
7516 ;; Nope, invisible article.
7518 ;; Ok, this article is to be visible, so we add it to the limit
7520 (push number gnus-newsgroup-limit)
7523 (defun gnus-expunge-thread (thread)
7524 "Mark all articles in THREAD as read."
7525 (let* ((number (mail-header-number (car thread))))
7526 (incf gnus-newsgroup-expunged-tally)
7527 ;; We also mark as read here, if that's wanted.
7528 (setq gnus-newsgroup-unreads
7529 (delq number gnus-newsgroup-unreads))
7530 (if gnus-newsgroup-auto-expire
7531 (push number gnus-newsgroup-expirable)
7532 (push (cons number gnus-low-score-mark)
7533 gnus-newsgroup-reads)))
7534 ;; Go recursively through all subthreads.
7535 (mapcar 'gnus-expunge-thread (cdr thread)))
7537 ;; Summary article oriented commands
7539 (defun gnus-summary-refer-parent-article (n)
7540 "Refer parent article N times.
7541 If N is negative, go to ancestor -N instead.
7542 The difference between N and the number of articles fetched is returned."
7546 (when (not (natnump n))
7551 (setq header (gnus-summary-article-header))
7552 (if (and (eq (mail-header-number header)
7553 (cdr gnus-article-current))
7554 (equal gnus-newsgroup-name
7555 (car gnus-article-current)))
7556 ;; If we try to find the parent of the currently
7557 ;; displayed article, then we take a look at the actual
7558 ;; References header, since this is slightly more
7559 ;; reliable than the References field we got from the
7562 (set-buffer gnus-original-article-buffer)
7563 (nnheader-narrow-to-headers)
7564 (unless (setq ref (message-fetch-field "references"))
7565 (setq ref (message-fetch-field "in-reply-to")))
7568 ;; It's not the current article, so we take a bet on
7569 ;; the value we got from the server.
7570 (mail-header-references header)))
7572 (not (equal ref "")))
7573 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7574 (gnus-message 1 "Couldn't find parent"))
7575 (gnus-message 1 "No references in article %d"
7576 (gnus-summary-article-number))
7579 (gnus-summary-position-point)
7582 (defun gnus-summary-refer-references ()
7583 "Fetch all articles mentioned in the References header.
7584 Return the number of articles fetched."
7586 (let ((ref (mail-header-references (gnus-summary-article-header)))
7587 (current (gnus-summary-article-number))
7591 (error "No References in the current article")
7592 ;; For each Message-ID in the References header...
7593 (while (string-match "<[^>]*>" ref)
7595 ;; ... fetch that article.
7596 (gnus-summary-refer-article
7597 (prog1 (match-string 0 ref)
7598 (setq ref (substring ref (match-end 0))))))
7599 (gnus-summary-goto-subject current)
7600 (gnus-summary-position-point)
7603 (defun gnus-summary-refer-thread (&optional limit)
7604 "Fetch all articles in the current thread.
7605 If LIMIT (the numerical prefix), fetch that many old headers instead
7606 of what's specified by the `gnus-refer-thread-limit' variable."
7608 (let ((id (mail-header-id (gnus-summary-article-header)))
7609 (limit (if limit (prefix-numeric-value limit)
7610 gnus-refer-thread-limit)))
7611 ;; We want to fetch LIMIT *old* headers, but we also have to
7612 ;; re-fetch all the headers in the current buffer, because many of
7613 ;; them may be undisplayed. So we adjust LIMIT.
7614 (when (numberp limit)
7615 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7616 (unless (eq gnus-fetch-old-headers 'invisible)
7617 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7618 ;; Retrieve the headers and read them in.
7619 (if (eq (gnus-retrieve-headers
7620 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7622 (gnus-build-all-threads)
7623 (error "Can't fetch thread from backends that don't support NOV"))
7624 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7625 (gnus-summary-limit-include-thread id)))
7627 (defun gnus-summary-refer-article (message-id)
7628 "Fetch an article specified by MESSAGE-ID."
7629 (interactive "sMessage-ID: ")
7630 (when (and (stringp message-id)
7631 (not (zerop (length message-id))))
7632 ;; Construct the correct Message-ID if necessary.
7633 ;; Suggested by tale@pawl.rpi.edu.
7634 (unless (string-match "^<" message-id)
7635 (setq message-id (concat "<" message-id)))
7636 (unless (string-match ">$" message-id)
7637 (setq message-id (concat message-id ">")))
7638 (let* ((header (gnus-id-to-header message-id))
7640 (gnus-summary-article-sparse-p
7641 (mail-header-number header))
7642 (memq (mail-header-number header)
7643 gnus-newsgroup-limit)))
7646 ;; If the article is present in the buffer we just go to it.
7648 (or (not (gnus-summary-article-sparse-p
7649 (mail-header-number header)))
7652 (gnus-summary-goto-article
7653 (mail-header-number header) nil t)
7655 (gnus-summary-update-article (mail-header-number header)))))
7657 ;; We fetch the article.
7659 (dolist (gnus-override-method (gnus-refer-article-methods))
7660 (gnus-check-server gnus-override-method)
7661 ;; Fetch the header, and display the article.
7662 (when (setq number (gnus-summary-insert-subject message-id))
7663 (gnus-summary-select-article nil nil nil number)
7665 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7667 (defun gnus-refer-article-methods ()
7668 "Return a list of referrable methods."
7670 ;; No method, so we default to current and native.
7671 ((null gnus-refer-article-method)
7672 (list gnus-current-select-method gnus-select-method))
7674 ((eq 'current gnus-refer-article-method)
7675 (list gnus-current-select-method))
7676 ;; List of select methods.
7677 ((not (and (symbolp (car gnus-refer-article-method))
7678 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7680 (dolist (method gnus-refer-article-method)
7681 (push (if (eq 'current method)
7682 gnus-current-select-method
7686 ;; One single select method.
7688 (list gnus-refer-article-method))))
7690 (defun gnus-summary-edit-parameters ()
7691 "Edit the group parameters of the current group."
7693 (gnus-group-edit-group gnus-newsgroup-name 'params))
7695 (defun gnus-summary-customize-parameters ()
7696 "Customize the group parameters of the current group."
7698 (gnus-group-customize gnus-newsgroup-name))
7700 (defun gnus-summary-enter-digest-group (&optional force)
7701 "Enter an nndoc group based on the current article.
7702 If FORCE, force a digest interpretation. If not, try
7703 to guess what the document format is."
7705 (let ((conf gnus-current-window-configuration))
7707 (gnus-summary-select-article))
7708 (setq gnus-current-window-configuration conf)
7709 (let* ((name (format "%s-%d"
7710 (gnus-group-prefixed-name
7711 gnus-newsgroup-name (list 'nndoc ""))
7713 (set-buffer gnus-summary-buffer)
7714 gnus-current-article)))
7715 (ogroup gnus-newsgroup-name)
7716 (params (append (gnus-info-params (gnus-get-info ogroup))
7717 (list (cons 'to-group ogroup))
7718 (list (cons 'save-article-group ogroup))))
7719 (case-fold-search t)
7720 (buf (current-buffer))
7723 (set-buffer gnus-original-article-buffer)
7724 ;; Have the digest group inherit the main mail address of
7725 ;; the parent article.
7726 (when (setq to-address (or (message-fetch-field "reply-to")
7727 (message-fetch-field "from")))
7728 (setq params (append
7729 (list (cons 'to-address
7730 (funcall gnus-decode-encoded-word-function
7732 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7733 (insert-buffer-substring gnus-original-article-buffer)
7734 ;; Remove lines that may lead nndoc to misinterpret the
7737 (goto-char (point-min))
7738 (or (search-forward "\n\n" nil t) (point)))
7739 (goto-char (point-min))
7740 (delete-matching-lines "^Path:\\|^From ")
7743 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7744 (gnus-newsgroup-ephemeral-ignored-charsets
7745 gnus-newsgroup-ignored-charsets))
7746 (gnus-group-read-ephemeral-group
7747 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7749 ,(if force 'mbox 'guess)))
7751 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7753 ;; Make all postings to this group go to the parent group.
7754 (nconc (gnus-info-params (gnus-get-info name))
7756 ;; Couldn't select this doc group.
7757 (switch-to-buffer buf)
7758 (gnus-set-global-variables)
7759 (gnus-configure-windows 'summary)
7760 (gnus-message 3 "Article couldn't be entered?"))
7761 (kill-buffer dig)))))
7763 (defun gnus-summary-read-document (n)
7764 "Open a new group based on the current article(s).
7765 This will allow you to read digests and other similar
7766 documents as newsgroups.
7767 Obeys the standard process/prefix convention."
7769 (let* ((articles (gnus-summary-work-articles n))
7770 (ogroup gnus-newsgroup-name)
7771 (params (append (gnus-info-params (gnus-get-info ogroup))
7772 (list (cons 'to-group ogroup))))
7773 article group egroup groups vgroup)
7774 (while (setq article (pop articles))
7775 (setq group (format "%s-%d" gnus-newsgroup-name article))
7776 (gnus-summary-remove-process-mark article)
7777 (when (gnus-summary-display-article article)
7780 (insert-buffer-substring gnus-original-article-buffer)
7781 ;; Remove some headers that may lead nndoc to make
7783 (message-narrow-to-head)
7784 (goto-char (point-min))
7785 (delete-matching-lines "^\\(Path\\):\\|^From ")
7788 (gnus-group-read-ephemeral-group
7789 group `(nndoc ,group (nndoc-address ,(current-buffer))
7790 (nndoc-article-type guess))
7793 ;; Make all postings to this group go to the parent group.
7794 (nconc (gnus-info-params (gnus-get-info egroup))
7796 (push egroup groups))
7797 ;; Couldn't select this doc group.
7798 (gnus-error 3 "Article couldn't be entered"))))))
7799 ;; Now we have selected all the documents.
7802 (error "None of the articles could be interpreted as documents"))
7803 ((gnus-group-read-ephemeral-group
7804 (setq vgroup (format
7805 "nnvirtual:%s-%s" gnus-newsgroup-name
7806 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7807 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7809 (cons (current-buffer) 'summary)))
7811 (error "Couldn't select virtual nndoc group")))))
7813 (defun gnus-summary-isearch-article (&optional regexp-p)
7814 "Do incremental search forward on the current article.
7815 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7817 (let* ((gnus-inhibit-treatment t)
7818 (old (gnus-summary-select-article)))
7819 (gnus-configure-windows 'article)
7820 (gnus-eval-in-buffer-window gnus-article-buffer
7824 (gnus-article-show-all-headers))
7825 (goto-char (point-min))
7826 (isearch-forward regexp-p)))))
7828 (defun gnus-summary-search-article-forward (regexp &optional backward)
7829 "Search for an article containing REGEXP forward.
7830 If BACKWARD, search backward instead."
7833 (format "Search article %s (regexp%s): "
7834 (if current-prefix-arg "backward" "forward")
7835 (if gnus-last-search-regexp
7836 (concat ", default " gnus-last-search-regexp)
7838 current-prefix-arg))
7839 (if (string-equal regexp "")
7840 (setq regexp (or gnus-last-search-regexp ""))
7841 (setq gnus-last-search-regexp regexp)
7842 (setq gnus-article-before-search gnus-current-article))
7843 ;; Intentionally set gnus-last-article.
7844 (setq gnus-last-article gnus-article-before-search)
7845 (let ((gnus-last-article gnus-last-article))
7846 (if (gnus-summary-search-article regexp backward)
7847 (gnus-summary-show-thread)
7848 (error "Search failed: \"%s\"" regexp))))
7850 (defun gnus-summary-search-article-backward (regexp)
7851 "Search for an article containing REGEXP backward."
7854 (format "Search article backward (regexp%s): "
7855 (if gnus-last-search-regexp
7856 (concat ", default " gnus-last-search-regexp)
7858 (gnus-summary-search-article-forward regexp 'backward))
7861 (defmacro gnus-summary-search-article-position-point (regexp backward)
7862 "Dehighlight the last matched text and goto the beginning position."
7863 (` (if (and gnus-summary-search-article-matched-data
7864 (let ((text (caddr gnus-summary-search-article-matched-data))
7865 (inhibit-read-only t)
7868 (goto-char (car gnus-summary-search-article-matched-data))
7869 (cadr gnus-summary-search-article-matched-data))
7871 (string-match (, regexp) text)))
7872 (if (, backward) (beginning-of-line) (end-of-line))
7873 (goto-char (if (, backward) (point-max) (point-min))))))
7875 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7876 "Place point where X-Face image is displayed."
7877 (if (featurep 'xemacs)
7878 (` (let ((end (if (search-forward "\n\n" nil t)
7879 (goto-char (1- (point)))
7882 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7883 (unless (and (re-search-forward "^From:" end t)
7884 (setq extent (extent-at (point)))
7885 (extent-begin-glyph extent))
7886 (goto-char (, opoint)))))
7887 (` (let ((end (if (search-forward "\n\n" nil t)
7888 (goto-char (1- (point)))
7890 (start (or (search-backward "\n\n" nil t) (point-min))))
7892 (or (text-property-any start end 'x-face-image t);; x-face-e21
7893 (text-property-any start end 'x-face-mule-bitmap-image t)
7896 (defmacro gnus-summary-search-article-highlight-matched-text
7897 (backward treated x-face)
7898 "Highlight matched text in the function `gnus-summary-search-article'."
7899 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7900 (end (set-marker (make-marker) (match-end 0)))
7901 (inhibit-read-only t)
7905 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7907 (lambda (item) (setq items (delq item items)))
7908 '(gnus-treat-buttonize
7909 gnus-treat-fill-article
7910 gnus-treat-fill-long-lines
7911 gnus-treat-emphasize
7912 gnus-treat-highlight-headers
7913 gnus-treat-highlight-citation
7914 gnus-treat-highlight-signature
7915 gnus-treat-overstrike
7916 gnus-treat-display-xface
7917 gnus-treat-buttonize-head
7918 gnus-treat-decode-article-as-default-mime-charset))
7919 (static-if (featurep 'xemacs)
7921 (cons '(x-face-mule-delete-x-face-field
7924 (gnus-treat-display-xface
7925 (when (, x-face) gnus-treat-display-xface)))
7926 (gnus-article-prepare-mime-display)))
7927 (goto-char (if (, backward) start end))
7929 (gnus-summary-search-article-highlight-goto-x-face (point)))
7930 (setq gnus-summary-search-article-matched-data
7931 (list start end (buffer-substring start end)))
7932 (unless (eq start end);; matched text has been deleted. :-<
7933 (put-text-property start end 'face
7934 (or (find-face 'isearch)
7935 'secondary-selection))))))
7938 (defun gnus-summary-search-article (regexp &optional backward)
7939 "Search for an article containing REGEXP.
7940 Optional argument BACKWARD means do search for backward.
7941 `gnus-select-article-hook' is not called during the search."
7942 ;; We have to require this here to make sure that the following
7943 ;; dynamic binding isn't shadowed by autoloading.
7944 (require 'gnus-async)
7946 (let ((gnus-select-article-hook nil) ;Disable hook.
7947 (gnus-article-prepare-hook nil)
7948 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7949 (gnus-use-article-prefetch nil)
7950 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7951 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7952 (sum (current-buffer))
7955 (gnus-save-hidden-threads
7956 (static-if (featurep 'xemacs)
7957 (let ((gnus-inhibit-treatment t))
7958 (setq treated (eq 'old (gnus-summary-select-article)))
7960 (not (and (gnus-buffer-live-p gnus-article-buffer)
7961 (window-live-p (get-buffer-window
7962 gnus-article-buffer t)))))
7963 (gnus-summary-select-article nil t)
7964 (setq treated nil)))
7965 (let ((gnus-inhibit-treatment t)
7966 (x-face-mule-delete-x-face-field 'never))
7967 (setq treated (eq 'old (gnus-summary-select-article)))
7970 (and (gnus-buffer-live-p gnus-article-buffer)
7971 (window-live-p (get-buffer-window
7972 gnus-article-buffer t))
7973 (or (not (string-match "^\\^X-Face:" regexp))
7974 (with-current-buffer gnus-article-buffer
7975 gnus-summary-search-article-matched-data)))))
7976 (gnus-summary-select-article nil t)
7977 (setq treated nil))))
7978 (set-buffer gnus-article-buffer)
7982 (gnus-article-show-all-headers)
7983 (gnus-summary-search-article-position-point regexp backward))
7984 (goto-char (if backward (point-max) (point-min))))
7986 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7988 (re-search-backward regexp nil t)
7989 (re-search-forward regexp nil t))
7990 ;; We found the regexp.
7992 (gnus-summary-search-article-highlight-matched-text
7993 backward treated (string-match "^\\^X-Face:" regexp))
7996 (/ (- 2 (window-height
7997 (get-buffer-window gnus-article-buffer t)))
8000 (get-buffer-window (current-buffer))
8003 (setq point (point)))
8004 ;; We didn't find it, so we go to the next article.
8007 (while (eq found 'not)
8008 (if (not (if backward (gnus-summary-find-prev)
8009 (gnus-summary-find-next)))
8010 ;; No more articles.
8012 ;; Select the next article and adjust point.
8013 (unless (gnus-summary-article-sparse-p
8014 (gnus-summary-article-number))
8016 (let ((gnus-inhibit-treatment t))
8017 (gnus-summary-select-article))
8019 (set-buffer gnus-article-buffer)
8021 (goto-char (if backward (point-max) (point-min))))))))
8022 (gnus-message 7 ""))
8023 ;; Return whether we found the regexp.
8024 (when (eq found 'found)
8026 (gnus-summary-show-thread)
8027 (gnus-summary-goto-subject gnus-current-article)
8028 (gnus-summary-position-point)
8031 (defun gnus-find-matching-articles (header regexp)
8032 "Return a list of all articles that match REGEXP on HEADER.
8033 This search includes all articles in the current group that Gnus has
8034 fetched headers for, whether they are displayed or not."
8035 (let ((articles nil)
8036 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8037 (case-fold-search t))
8038 (dolist (header gnus-newsgroup-headers)
8039 (when (string-match regexp (funcall func header))
8040 (push (mail-header-number header) articles)))
8041 (nreverse articles)))
8043 (defun gnus-summary-find-matching (header regexp &optional backward unread
8044 not-case-fold not-matching)
8045 "Return a list of all articles that match REGEXP on HEADER.
8046 The search stars on the current article and goes forwards unless
8047 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8048 If UNREAD is non-nil, only unread articles will
8049 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8050 in the comparisons. If NOT-MATCHING, return a list of all articles that
8051 not match REGEXP on HEADER."
8052 (let ((case-fold-search (not not-case-fold))
8055 (if (eq (car header) 'extra)
8058 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8060 (error "%s is an invalid header" header))
8061 (unless (fboundp (intern (concat "mail-header-" header)))
8062 (error "%s is not a valid header" header))
8063 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8064 (dolist (d (if (eq backward 'all)
8066 (gnus-data-find-list
8067 (gnus-summary-article-number)
8068 (gnus-data-list backward))))
8069 (when (and (or (not unread) ; We want all articles...
8070 (gnus-data-unread-p d)) ; Or just unreads.
8071 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8075 (funcall func (gnus-data-header d))))
8076 (string-match regexp
8077 (funcall func (gnus-data-header d)))))
8078 (push (gnus-data-number d) articles))) ; Success!
8079 (nreverse articles)))
8081 (defun gnus-summary-execute-command (header regexp command &optional backward)
8082 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8083 If HEADER is an empty string (or nil), the match is done on the entire
8084 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8086 (list (let ((completion-ignore-case t))
8089 (mapcar (lambda (header) (list (format "%s" header)))
8091 '("Number" "Subject" "From" "Lines" "Date"
8092 "Message-ID" "Xref" "References" "Body")
8093 gnus-extra-headers))
8094 nil 'require-match))
8095 (read-string "Regexp: ")
8096 (read-key-sequence "Command: ")
8097 current-prefix-arg))
8098 (when (equal header "Body")
8100 ;; Hidden thread subtrees must be searched as well.
8101 (gnus-summary-show-all-threads)
8102 ;; We don't want to change current point nor window configuration.
8104 (save-window-excursion
8105 (gnus-message 6 "Executing %s..." (key-description command))
8106 ;; We'd like to execute COMMAND interactively so as to give arguments.
8107 (gnus-execute header regexp
8108 `(call-interactively ',(key-binding command))
8110 (gnus-message 6 "Executing %s...done" (key-description command)))))
8112 (defun gnus-summary-beginning-of-article ()
8113 "Scroll the article back to the beginning."
8115 (gnus-summary-select-article)
8116 (gnus-configure-windows 'article)
8117 (gnus-eval-in-buffer-window gnus-article-buffer
8119 (goto-char (point-min))
8120 (when gnus-page-broken
8121 (gnus-narrow-to-page))))
8123 (defun gnus-summary-end-of-article ()
8124 "Scroll to the end of the article."
8126 (gnus-summary-select-article)
8127 (gnus-configure-windows 'article)
8128 (gnus-eval-in-buffer-window gnus-article-buffer
8130 (goto-char (point-max))
8132 (when gnus-page-broken
8133 (gnus-narrow-to-page))))
8135 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8136 "Truncate to LEN and quote all \"(\"'s in STRING."
8137 (gnus-replace-in-string (if (and len (> (length string) len))
8138 (substring string 0 len)
8142 (defun gnus-summary-print-article (&optional filename n)
8143 "Generate and print a PostScript image of the N next (mail) articles.
8145 If N is negative, print the N previous articles. If N is nil and articles
8146 have been marked with the process mark, print these instead.
8148 If the optional first argument FILENAME is nil, send the image to the
8149 printer. If FILENAME is a string, save the PostScript image in a file with
8150 that name. If FILENAME is a number, prompt the user for the name of the file
8152 (interactive (list (ps-print-preprint current-prefix-arg)))
8153 (dolist (article (gnus-summary-work-articles n))
8154 (gnus-summary-select-article nil nil 'pseudo article)
8155 (gnus-eval-in-buffer-window gnus-article-buffer
8156 (gnus-print-buffer))
8157 (gnus-summary-remove-process-mark article))
8158 (ps-despool filename))
8160 (defun gnus-print-buffer ()
8161 (let ((buffer (generate-new-buffer " *print*")))
8164 (copy-to-buffer buffer (point-min) (point-max))
8166 (gnus-article-delete-invisible-text)
8167 (when (gnus-visual-p 'article-highlight 'highlight)
8168 ;; Copy-to-buffer doesn't copy overlay. So redo
8170 (let ((gnus-article-buffer buffer))
8171 (gnus-article-highlight-citation t)
8172 (gnus-article-highlight-signature)))
8173 (let ((ps-left-header
8176 (gnus-summary-print-truncate-and-quote
8177 (mail-header-subject gnus-current-headers)
8180 (gnus-summary-print-truncate-and-quote
8181 (mail-header-from gnus-current-headers)
8185 "/pagenumberstring load"
8187 (mail-header-date gnus-current-headers) ")"))))
8188 (gnus-run-hooks 'gnus-ps-print-hook)
8191 (ps-spool-buffer-with-faces)
8192 (ps-spool-buffer)))))
8193 (kill-buffer buffer))))
8195 (defun gnus-summary-show-article (&optional arg)
8196 "Force redisplaying of the current article.
8197 If ARG (the prefix) is a number, show the article with the charset
8198 defined in `gnus-summary-show-article-charset-alist', or the charset
8200 If ARG (the prefix) is non-nil and not a number, show the raw article
8201 without any article massaging functions being run. Normally, the key strokes
8206 (gnus-summary-show-article t)
8207 (let* ((gnus-newsgroup-charset
8208 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8209 (mm-read-coding-system
8210 "View as charset: " ;; actually it is coding system.
8212 (set-buffer gnus-article-buffer)
8213 (mm-detect-coding-region (point) (point-max))))))
8214 (default-mime-charset gnus-newsgroup-charset)
8215 (gnus-newsgroup-ignored-charsets 'gnus-all))
8216 (gnus-summary-select-article nil 'force)
8217 (let ((deps gnus-newsgroup-dependencies)
8220 (set-buffer gnus-original-article-buffer)
8222 (message-narrow-to-head)
8223 (setq head (buffer-string))
8224 (goto-char (point-min))
8225 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8226 (goto-char (point-max))
8228 (setq lines (1- (count-lines (point) (point-max))))))
8230 (insert (format "211 %d Article retrieved.\n"
8231 (cdr gnus-article-current)))
8233 (if lines (insert (format "Lines: %d\n" lines)))
8235 (let ((nntp-server-buffer (current-buffer)))
8236 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8237 (gnus-data-set-header
8238 (gnus-data-find (cdr gnus-article-current))
8240 (gnus-summary-update-article-line
8241 (cdr gnus-article-current) header)
8242 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8243 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8245 ;; Select the article the normal way.
8246 (gnus-summary-select-article nil 'force))
8248 ;; We have to require this here to make sure that the following
8249 ;; dynamic binding isn't shadowed by autoloading.
8250 (require 'gnus-async)
8252 ;; Bind the article treatment functions to nil.
8253 (let ((gnus-have-all-headers t)
8254 gnus-article-prepare-hook
8255 gnus-article-decode-hook
8258 (gnus-inhibit-treatment t))
8259 (gnus-summary-select-article nil 'force))))
8260 (gnus-summary-goto-subject gnus-current-article)
8261 (gnus-summary-position-point))
8263 (defun gnus-summary-show-raw-article ()
8264 "Show the raw article without any article massaging functions being run."
8266 (gnus-summary-show-article t))
8268 (defun gnus-summary-verbose-headers (&optional arg)
8269 "Toggle permanent full header display.
8270 If ARG is a positive number, turn header display on.
8271 If ARG is a negative number, turn header display off."
8273 (setq gnus-show-all-headers
8274 (cond ((or (not (numberp arg))
8276 (not gnus-show-all-headers))
8279 (gnus-summary-show-article))
8281 (defun gnus-summary-toggle-header (&optional arg)
8282 "Show the headers if they are hidden, or hide them if they are shown.
8283 If ARG is a positive number, show the entire header.
8284 If ARG is a negative number, hide the unwanted header lines."
8287 (set-buffer gnus-article-buffer)
8289 (let* ((buffer-read-only nil)
8290 (inhibit-point-motion-hooks t)
8296 (article-narrow-to-head)
8297 (gnus-article-hidden-text-p 'headers))))
8298 (goto-char (point-min))
8299 (when (search-forward "\n\n" nil t)
8300 (delete-region (point-min) (1- (point))))
8301 (goto-char (point-min))
8303 (set-buffer gnus-original-article-buffer)
8304 (goto-char (point-min))
8305 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8306 (insert-buffer-substring gnus-original-article-buffer 1 e)
8308 (narrow-to-region (point-min) (point))
8309 (article-decode-encoded-words)
8311 (let ((gnus-treat-hide-headers nil)
8312 (gnus-treat-hide-boring-headers nil))
8313 (gnus-delete-wash-type 'headers)
8314 (gnus-treat-article 'head))
8315 (gnus-treat-article 'head)))
8316 (gnus-set-mode-line 'article)))))
8318 (defun gnus-summary-show-all-headers ()
8319 "Make all header lines visible."
8321 (gnus-summary-toggle-header 1))
8323 (defun gnus-summary-toggle-mime (&optional arg)
8324 "Toggle MIME processing.
8325 If ARG is a positive number, turn MIME processing on."
8327 (setq gnus-show-mime
8329 (not gnus-show-mime)
8330 (> (prefix-numeric-value arg) 0)))
8331 (gnus-summary-select-article t 'force))
8333 (defun gnus-summary-caesar-message (&optional arg)
8334 "Caesar rotate the current article by 13.
8335 The numerical prefix specifies how many places to rotate each letter
8338 (gnus-summary-select-article)
8339 (let ((mail-header-separator ""))
8340 (gnus-eval-in-buffer-window gnus-article-buffer
8343 (let ((start (window-start))
8345 (message-caesar-buffer-body arg)
8346 (set-window-start (get-buffer-window (current-buffer)) start))))))
8348 (defun gnus-summary-stop-page-breaking ()
8349 "Stop page breaking in the current article."
8351 (gnus-summary-select-article)
8352 (gnus-eval-in-buffer-window gnus-article-buffer
8354 (when (gnus-visual-p 'page-marker)
8355 (let ((buffer-read-only nil))
8356 (gnus-remove-text-with-property 'gnus-prev)
8357 (gnus-remove-text-with-property 'gnus-next))
8358 (setq gnus-page-broken nil))))
8360 (defun gnus-summary-move-article (&optional n to-newsgroup
8361 select-method action)
8362 "Move the current article to a different newsgroup.
8363 If N is a positive number, move the N next articles.
8364 If N is a negative number, move the N previous articles.
8365 If N is nil and any articles have been marked with the process mark,
8366 move those articles instead.
8367 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8368 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8369 re-spool using this method.
8371 For this function to work, both the current newsgroup and the
8372 newsgroup that you want to move to have to support the `request-move'
8373 and `request-accept' functions.
8375 ACTION can be either `move' (the default), `crosspost' or `copy'."
8378 (setq action 'move))
8379 ;; Check whether the source group supports the required functions.
8380 (cond ((and (eq action 'move)
8381 (not (gnus-check-backend-function
8382 'request-move-article gnus-newsgroup-name)))
8383 (error "The current group does not support article moving"))
8384 ((and (eq action 'crosspost)
8385 (not (gnus-check-backend-function
8386 'request-replace-article gnus-newsgroup-name)))
8387 (error "The current group does not support article editing")))
8388 (let ((articles (gnus-summary-work-articles n))
8389 (prefix (if (gnus-check-backend-function
8390 'request-move-article gnus-newsgroup-name)
8391 (gnus-group-real-prefix gnus-newsgroup-name)
8393 (names '((move "Move" "Moving")
8394 (copy "Copy" "Copying")
8395 (crosspost "Crosspost" "Crossposting")))
8396 (copy-buf (save-excursion
8397 (nnheader-set-temp-buffer " *copy article*")))
8398 (default-marks gnus-article-mark-lists)
8399 (no-expire-marks (delete '(expirable . expire)
8400 (copy-sequence gnus-article-mark-lists)))
8401 art-group to-method new-xref article to-groups)
8402 (unless (assq action names)
8403 (error "Unknown action %s" action))
8404 ;; We have to select an article to give
8405 ;; `gnus-read-move-group-name' an opportunity to suggest an
8406 ;; appropriate default.
8407 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8408 (let ((gnus-display-mime-function nil)
8409 (gnus-article-prepare-hook nil))
8410 (gnus-summary-select-article nil nil nil (car articles))))
8411 ;; Read the newsgroup name.
8412 (when (and (not to-newsgroup)
8413 (not select-method))
8415 (gnus-read-move-group-name
8416 (cadr (assq action names))
8417 (symbol-value (intern (format "gnus-current-%s-group" action)))
8419 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8420 (setq to-method (or select-method
8421 (gnus-server-to-method
8422 (gnus-group-method to-newsgroup))))
8423 ;; Check the method we are to move this article to...
8424 (unless (gnus-check-backend-function
8425 'request-accept-article (car to-method))
8426 (error "%s does not support article copying" (car to-method)))
8427 (unless (gnus-check-server to-method)
8428 (error "Can't open server %s" (car to-method)))
8429 (gnus-message 6 "%s to %s: %s..."
8430 (caddr (assq action names))
8431 (or (car select-method) to-newsgroup) articles)
8433 (setq article (pop articles))
8437 ;; Move the article.
8439 ;; Remove this article from future suppression.
8440 (gnus-dup-unsuppress-article article)
8441 (gnus-request-move-article
8442 article ; Article to move
8443 gnus-newsgroup-name ; From newsgroup
8444 (nth 1 (gnus-find-method-for-group
8445 gnus-newsgroup-name)) ; Server
8446 (list 'gnus-request-accept-article
8447 to-newsgroup (list 'quote select-method)
8448 (not articles) t) ; Accept form
8449 (not articles))) ; Only save nov last time
8450 ;; Copy the article.
8453 (set-buffer copy-buf)
8454 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8455 (gnus-request-accept-article
8456 to-newsgroup select-method (not articles) t))))
8457 ;; Crosspost the article.
8458 ((eq action 'crosspost)
8459 (let ((xref (message-tokenize-header
8460 (mail-header-xref (gnus-summary-article-header article))
8462 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8463 ":" (number-to-string article)))
8465 (setq xref (list (system-name))))
8468 (mapconcat 'identity
8469 (delete "Xref:" (delete new-xref xref))
8473 (set-buffer copy-buf)
8474 ;; First put the article in the destination group.
8475 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8476 (when (consp (setq art-group
8477 (gnus-request-accept-article
8478 to-newsgroup select-method (not articles))))
8479 (setq new-xref (concat new-xref " " (car art-group)
8481 (number-to-string (cdr art-group))))
8482 ;; Now we have the new Xrefs header, so we insert
8483 ;; it and replace the new article.
8484 (nnheader-replace-header "Xref" new-xref)
8485 (gnus-request-replace-article
8486 (cdr art-group) to-newsgroup (current-buffer))
8490 (gnus-message 1 "Couldn't %s article %s: %s"
8491 (cadr (assq action names)) article
8492 (nnheader-get-report (car to-method))))
8493 ((eq art-group 'junk)
8494 (when (eq action 'move)
8495 (gnus-summary-mark-article article gnus-canceled-mark)
8496 (gnus-message 4 "Deleted article %s" article)))
8498 (let* ((pto-group (gnus-group-prefixed-name
8499 (car art-group) to-method))
8501 (gnus-gethash pto-group gnus-newsrc-hashtb))
8502 (info (nth 2 entry))
8503 (to-group (gnus-info-group info))
8505 ;; Update the group that has been moved to.
8507 (memq action '(move copy)))
8508 (unless (member to-group to-groups)
8509 (push to-group to-groups))
8511 (unless (memq article gnus-newsgroup-unreads)
8512 (push 'read to-marks)
8514 info (gnus-add-to-range (gnus-info-read info)
8515 (list (cdr art-group)))))
8517 ;; See whether the article is to be put in the cache.
8518 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8521 (to-article (cdr art-group)))
8523 ;; Enter the article into the cache in the new group,
8524 ;; if that is required.
8525 (when gnus-use-cache
8526 (gnus-cache-possibly-enter-article
8528 (let ((header (copy-sequence
8529 (gnus-summary-article-header article))))
8530 (mail-header-set-number header to-article)
8532 (memq article gnus-newsgroup-marked)
8533 (memq article gnus-newsgroup-dormant)
8534 (memq article gnus-newsgroup-unreads)))
8536 (when gnus-preserve-marks
8537 ;; Copy any marks over to the new group.
8538 (when (and (equal to-group gnus-newsgroup-name)
8539 (not (memq article gnus-newsgroup-unreads)))
8540 ;; Mark this article as read in this group.
8541 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8542 (setcdr (gnus-active to-group) to-article)
8543 (setcdr gnus-newsgroup-active to-article))
8546 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8547 (when (memq article (symbol-value
8548 (intern (format "gnus-newsgroup-%s"
8550 (push (cdar marks) to-marks)
8551 ;; If the other group is the same as this group,
8552 ;; then we have to add the mark to the list.
8553 (when (equal to-group gnus-newsgroup-name)
8554 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8557 (intern (format "gnus-newsgroup-%s"
8559 ;; Copy the marks to other group.
8560 (gnus-add-marked-articles
8561 to-group (cdar marks) (list to-article) info)))
8562 (setq marks (cdr marks)))
8564 (gnus-request-set-mark to-group (list (list (list to-article)
8569 (concat "(gnus-group-set-info '"
8570 (gnus-prin1-to-string (gnus-get-info to-group))
8573 ;; Update the Xref header in this article to point to
8574 ;; the new crossposted article we have just created.
8575 (when (eq action 'crosspost)
8577 (set-buffer copy-buf)
8578 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8579 (nnheader-replace-header "Xref" new-xref)
8580 (gnus-request-replace-article
8581 article gnus-newsgroup-name (current-buffer)))))
8583 ;;;!!!Why is this necessary?
8584 (set-buffer gnus-summary-buffer)
8586 (gnus-summary-goto-subject article)
8587 (when (eq action 'move)
8588 (gnus-summary-mark-article article gnus-canceled-mark))))
8589 (gnus-summary-remove-process-mark article))
8590 ;; Re-activate all groups that have been moved to.
8592 (set-buffer gnus-group-buffer)
8593 (let ((gnus-group-marked to-groups))
8594 (gnus-group-get-new-news-this-group nil t)))
8596 (gnus-kill-buffer copy-buf)
8597 (gnus-summary-position-point)
8598 (gnus-set-mode-line 'summary)))
8600 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8601 "Move the current article to a different newsgroup.
8602 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8603 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8604 re-spool using this method."
8606 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8608 (defun gnus-summary-crosspost-article (&optional n)
8609 "Crosspost the current article to some other group."
8611 (gnus-summary-move-article n nil nil 'crosspost))
8613 (defcustom gnus-summary-respool-default-method nil
8614 "Default method type for respooling an article.
8615 If nil, use to the current newsgroup method."
8617 :group 'gnus-summary-mail)
8619 (defun gnus-summary-respool-article (&optional n method)
8620 "Respool the current article.
8621 The article will be squeezed through the mail spooling process again,
8622 which means that it will be put in some mail newsgroup or other
8623 depending on `nnmail-split-methods'.
8624 If N is a positive number, respool the N next articles.
8625 If N is a negative number, respool the N previous articles.
8626 If N is nil and any articles have been marked with the process mark,
8627 respool those articles instead.
8629 Respooling can be done both from mail groups and \"real\" newsgroups.
8630 In the former case, the articles in question will be moved from the
8631 current group into whatever groups they are destined to. In the
8632 latter case, they will be copied into the relevant groups."
8634 (list current-prefix-arg
8635 (let* ((methods (gnus-methods-using 'respool))
8637 (symbol-name (or gnus-summary-respool-default-method
8638 (car (gnus-find-method-for-group
8639 gnus-newsgroup-name)))))
8641 (gnus-completing-read-with-default
8642 methname "What backend do you want to use when respooling?"
8643 methods nil t nil 'gnus-mail-method-history))
8646 ((zerop (length (setq ms (gnus-servers-using-backend
8648 (list (intern method) ""))
8652 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8653 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8656 (error "No method given for respooling"))
8657 (if (assoc (symbol-name
8658 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8659 (gnus-methods-using 'respool))
8660 (gnus-summary-move-article n nil method)
8661 (gnus-summary-copy-article n nil method)))
8663 (defun gnus-summary-import-article (file &optional edit)
8664 "Import an arbitrary file into a mail newsgroup."
8665 (interactive "fImport file: \nP")
8666 (let ((group gnus-newsgroup-name)
8667 (now (current-time))
8668 atts lines group-art)
8669 (unless (gnus-check-backend-function 'request-accept-article group)
8670 (error "%s does not support article importing" group))
8671 (or (file-readable-p file)
8672 (not (file-regular-p file))
8673 (error "Can't read %s" file))
8675 (set-buffer (gnus-get-buffer-create " *import file*"))
8677 (nnheader-insert-file-contents file)
8678 (goto-char (point-min))
8679 (if (nnheader-article-p)
8681 (goto-char (point-min))
8682 (search-forward "\n\n" nil t)
8683 (narrow-to-region (point-min) (1- (point)))
8684 (goto-char (point-min))
8685 (unless (re-search-forward "^date:" nil t)
8686 (goto-char (point-max))
8687 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8688 ;; This doesn't look like an article, so we fudge some headers.
8689 (setq atts (file-attributes file)
8690 lines (count-lines (point-min) (point-max)))
8691 (insert "From: " (read-string "From: ") "\n"
8692 "Subject: " (read-string "Subject: ") "\n"
8693 "Date: " (message-make-date (nth 5 atts)) "\n"
8694 "Message-ID: " (message-make-message-id) "\n"
8695 "Lines: " (int-to-string lines) "\n"
8696 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8697 (setq group-art (gnus-request-accept-article group nil t))
8698 (kill-buffer (current-buffer)))
8699 (setq gnus-newsgroup-active (gnus-activate-group group))
8701 (gnus-summary-goto-article (cdr group-art) nil t)
8703 (gnus-summary-edit-article))))
8705 (defun gnus-summary-create-article ()
8706 "Create an article in a mail newsgroup."
8708 (let ((group gnus-newsgroup-name)
8709 (now (current-time))
8711 (unless (gnus-check-backend-function 'request-accept-article group)
8712 (error "%s does not support article importing" group))
8714 (set-buffer (gnus-get-buffer-create " *import file*"))
8716 (goto-char (point-min))
8717 ;; This doesn't look like an article, so we fudge some headers.
8718 (insert "From: " (read-string "From: ") "\n"
8719 "Subject: " (read-string "Subject: ") "\n"
8720 "Date: " (message-make-date now) "\n"
8721 "Message-ID: " (message-make-message-id) "\n")
8722 (setq group-art (gnus-request-accept-article group nil t))
8723 (kill-buffer (current-buffer)))
8724 (setq gnus-newsgroup-active (gnus-activate-group group))
8726 (gnus-summary-goto-article (cdr group-art) nil t)
8727 (gnus-summary-edit-article)))
8729 (defun gnus-summary-article-posted-p ()
8730 "Say whether the current (mail) article is available from news as well.
8731 This will be the case if the article has both been mailed and posted."
8733 (let ((id (mail-header-references (gnus-summary-article-header)))
8734 (gnus-override-method (car (gnus-refer-article-methods))))
8735 (if (gnus-request-head id "")
8736 (gnus-message 2 "The current message was found on %s"
8737 gnus-override-method)
8738 (gnus-message 2 "The current message couldn't be found on %s"
8739 gnus-override-method)
8742 (defun gnus-summary-expire-articles (&optional now)
8743 "Expire all articles that are marked as expirable in the current group."
8745 (when (gnus-check-backend-function
8746 'request-expire-articles gnus-newsgroup-name)
8747 ;; This backend supports expiry.
8748 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8749 (expirable (if total
8751 ;; We need to update the info for
8752 ;; this group for `gnus-list-of-read-articles'
8753 ;; to give us the right answer.
8754 (gnus-run-hooks 'gnus-exit-group-hook)
8755 (gnus-summary-update-info)
8756 (gnus-list-of-read-articles gnus-newsgroup-name))
8757 (setq gnus-newsgroup-expirable
8758 (sort gnus-newsgroup-expirable '<))))
8759 (expiry-wait (if now 'immediate
8760 (gnus-group-find-parameter
8761 gnus-newsgroup-name 'expiry-wait)))
8762 (nnmail-expiry-target
8763 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8764 nnmail-expiry-target))
8767 ;; There are expirable articles in this group, so we run them
8768 ;; through the expiry process.
8769 (gnus-message 6 "Expiring articles...")
8770 (unless (gnus-check-group gnus-newsgroup-name)
8771 (error "Can't open server for %s" gnus-newsgroup-name))
8772 ;; The list of articles that weren't expired is returned.
8775 (let ((nnmail-expiry-wait-function nil)
8776 (nnmail-expiry-wait expiry-wait))
8777 (setq es (gnus-request-expire-articles
8778 expirable gnus-newsgroup-name)))
8779 (setq es (gnus-request-expire-articles
8780 expirable gnus-newsgroup-name)))
8782 (setq gnus-newsgroup-expirable es))
8783 ;; We go through the old list of expirable, and mark all
8784 ;; really expired articles as nonexistent.
8785 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8786 (let ((gnus-use-cache nil))
8788 (unless (memq (car expirable) es)
8789 (when (gnus-data-find (car expirable))
8790 (gnus-summary-mark-article
8791 (car expirable) gnus-canceled-mark)))
8792 (setq expirable (cdr expirable))))))
8793 (gnus-message 6 "Expiring articles...done")))))
8795 (defun gnus-summary-expire-articles-now ()
8796 "Expunge all expirable articles in the current group.
8797 This means that *all* articles that are marked as expirable will be
8798 deleted forever, right now."
8800 (or gnus-expert-user
8802 "Are you really, really, really sure you want to delete all these messages? ")
8804 (gnus-summary-expire-articles t))
8806 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8807 (defun gnus-summary-delete-article (&optional n)
8808 "Delete the N next (mail) articles.
8809 This command actually deletes articles. This is not a marking
8810 command. The article will disappear forever from your life, never to
8812 If N is negative, delete backwards.
8813 If N is nil and articles have been marked with the process mark,
8814 delete these instead."
8816 (unless (gnus-check-backend-function 'request-expire-articles
8817 gnus-newsgroup-name)
8818 (error "The current newsgroup does not support article deletion"))
8819 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8820 (error "Couldn't open server"))
8821 ;; Compute the list of articles to delete.
8822 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8824 (if (and gnus-novice-user
8825 (not (gnus-yes-or-no-p
8826 (format "Do you really want to delete %s forever? "
8827 (if (> (length articles) 1)
8828 (format "these %s articles" (length articles))
8831 ;; Delete the articles.
8832 (setq not-deleted (gnus-request-expire-articles
8833 articles gnus-newsgroup-name 'force))
8835 (gnus-summary-remove-process-mark (car articles))
8836 ;; The backend might not have been able to delete the article
8838 (unless (memq (car articles) not-deleted)
8839 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8840 (setq articles (cdr articles)))
8842 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8843 (gnus-summary-position-point)
8844 (gnus-set-mode-line 'summary)
8847 (defun gnus-summary-edit-article (&optional force)
8848 "Edit the current article.
8849 This will have permanent effect only in mail groups.
8850 If FORCE is non-nil, allow editing of articles even in read-only
8854 (set-buffer gnus-summary-buffer)
8855 (let ((mail-parse-charset gnus-newsgroup-charset)
8856 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8857 (gnus-set-global-variables)
8858 (when (and (not force)
8859 (gnus-group-read-only-p))
8860 (error "The current newsgroup does not support article editing"))
8861 (gnus-summary-show-article t)
8862 (gnus-article-edit-article
8864 `(lambda (no-highlight)
8865 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8866 (message-options message-options)
8867 (message-options-set-recipient)
8868 (mail-parse-ignored-charsets
8869 ',gnus-newsgroup-ignored-charsets))
8870 (gnus-summary-edit-article-done
8871 ,(or (mail-header-references gnus-current-headers) "")
8872 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8874 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8876 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8878 "Make edits to the current article permanent."
8881 ;; The buffer restriction contains the entire article if it exists.
8882 (when (article-goto-body)
8883 (let ((lines (count-lines (point) (point-max)))
8884 (length (- (point-max) (point)))
8885 (case-fold-search t)
8886 (body (copy-marker (point))))
8887 (goto-char (point-min))
8888 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8889 (delete-region (match-beginning 1) (match-end 1))
8890 (insert (number-to-string length)))
8891 (goto-char (point-min))
8892 (when (re-search-forward
8893 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8894 (delete-region (match-beginning 1) (match-end 1))
8895 (insert (number-to-string length)))
8896 (goto-char (point-min))
8897 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8898 (delete-region (match-beginning 1) (match-end 1))
8899 (insert (number-to-string lines))))))
8900 ;; Replace the article.
8901 (let ((buf (current-buffer)))
8903 (insert-buffer-substring buf)
8905 (if (and (not read-only)
8906 (not (gnus-request-replace-article
8907 (cdr gnus-article-current) (car gnus-article-current)
8908 (current-buffer) t)))
8909 (error "Couldn't replace article")
8910 ;; Update the summary buffer.
8912 (equal (message-tokenize-header references " ")
8913 (message-tokenize-header
8914 (or (message-fetch-field "references") "") " ")))
8915 ;; We only have to update this line.
8918 (message-narrow-to-head)
8919 (let ((head (buffer-string))
8922 (insert (format "211 %d Article retrieved.\n"
8923 (cdr gnus-article-current)))
8926 (let ((nntp-server-buffer (current-buffer)))
8927 (setq header (car (gnus-get-newsgroup-headers
8929 (set-buffer gnus-summary-buffer)
8930 gnus-newsgroup-dependencies)
8933 (set-buffer gnus-summary-buffer)
8934 (gnus-data-set-header
8935 (gnus-data-find (cdr gnus-article-current))
8937 (gnus-summary-update-article-line
8938 (cdr gnus-article-current) header)
8939 (if (gnus-summary-goto-subject
8940 (cdr gnus-article-current) nil t)
8941 (gnus-summary-update-secondary-mark
8942 (cdr gnus-article-current))))))))
8944 (set-buffer (or buffer gnus-summary-buffer))
8945 (gnus-summary-update-article (cdr gnus-article-current))
8946 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8947 (gnus-summary-update-secondary-mark
8948 (cdr gnus-article-current))))
8949 ;; Prettify the article buffer again.
8950 (unless no-highlight
8952 (set-buffer gnus-article-buffer)
8953 ;;;!!! Fix this -- article should be rehighlighted.
8954 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8955 (set-buffer gnus-original-article-buffer)
8956 (gnus-request-article
8957 (cdr gnus-article-current)
8958 (car gnus-article-current) (current-buffer))))
8959 ;; Prettify the summary buffer line.
8960 (when (gnus-visual-p 'summary-highlight 'highlight)
8961 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8963 (defun gnus-summary-edit-wash (key)
8964 "Perform editing command KEY in the article buffer."
8968 (message "%s" (concat (this-command-keys) "- "))
8971 (gnus-summary-edit-article)
8972 (execute-kbd-macro (concat (this-command-keys) key))
8973 (gnus-article-edit-done))
8977 (defun gnus-summary-respool-query (&optional silent trace)
8978 "Query where the respool algorithm would put this article."
8980 (let (gnus-mark-article-hook)
8981 (gnus-summary-select-article)
8983 (set-buffer gnus-original-article-buffer)
8985 (message-narrow-to-head)
8986 (let ((groups (nnmail-article-group 'identity trace)))
8989 (message "This message would go to %s"
8990 (mapconcat 'car groups ", "))
8991 (message "This message would go to no groups"))
8994 (defun gnus-summary-respool-trace ()
8995 "Trace where the respool algorithm would put this article.
8996 Display a buffer showing all fancy splitting patterns which matched."
8998 (gnus-summary-respool-query nil t))
9000 ;; Summary marking commands.
9002 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9003 "Mark articles which has the same subject as read, and then select the next.
9004 If UNMARK is positive, remove any kind of mark.
9005 If UNMARK is negative, tick articles."
9008 (setq unmark (prefix-numeric-value unmark)))
9010 (gnus-summary-mark-same-subject
9011 (gnus-summary-article-subject) unmark)))
9012 ;; Select next unread article. If auto-select-same mode, should
9013 ;; select the first unread article.
9014 (gnus-summary-next-article t (and gnus-auto-select-same
9015 (gnus-summary-article-subject)))
9016 (gnus-message 7 "%d article%s marked as %s"
9017 count (if (= count 1) " is" "s are")
9018 (if unmark "unread" "read"))))
9020 (defun gnus-summary-kill-same-subject (&optional unmark)
9021 "Mark articles which has the same subject as read.
9022 If UNMARK is positive, remove any kind of mark.
9023 If UNMARK is negative, tick articles."
9026 (setq unmark (prefix-numeric-value unmark)))
9028 (gnus-summary-mark-same-subject
9029 (gnus-summary-article-subject) unmark)))
9030 ;; If marked as read, go to next unread subject.
9032 ;; Go to next unread subject.
9033 (gnus-summary-next-subject 1 t))
9034 (gnus-message 7 "%d articles are marked as %s"
9035 count (if unmark "unread" "read"))))
9037 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9038 "Mark articles with same SUBJECT as read, and return marked number.
9039 If optional argument UNMARK is positive, remove any kinds of marks.
9040 If optional argument UNMARK is negative, mark articles as unread instead."
9044 ((null unmark) ; Mark as read.
9047 (gnus-summary-mark-article-as-read gnus-killed-mark)
9048 (gnus-summary-show-thread) t)
9049 (gnus-summary-find-subject subject))
9050 (setq count (1+ count))))
9051 ((> unmark 0) ; Tick.
9054 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9055 (gnus-summary-show-thread) t)
9056 (gnus-summary-find-subject subject))
9057 (setq count (1+ count))))
9058 (t ; Mark as unread.
9061 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9062 (gnus-summary-show-thread) t)
9063 (gnus-summary-find-subject subject))
9064 (setq count (1+ count)))))
9065 (gnus-set-mode-line 'summary)
9066 ;; Return the number of marked articles.
9069 (defun gnus-summary-mark-as-processable (n &optional unmark)
9070 "Set the process mark on the next N articles.
9071 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9072 the process mark instead. The difference between N and the actual
9073 number of articles marked is returned."
9075 (if (and (null n) (gnus-region-active-p))
9076 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9077 (setq n (prefix-numeric-value n))
9078 (let ((backward (< n 0))
9083 (gnus-summary-remove-process-mark
9084 (gnus-summary-article-number))
9085 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9086 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9089 (gnus-message 7 "No more articles"))
9090 (gnus-summary-recenter)
9091 (gnus-summary-position-point)
9094 (defun gnus-summary-unmark-as-processable (n)
9095 "Remove the process mark from the next N articles.
9096 If N is negative, unmark backward instead. The difference between N and
9097 the actual number of articles unmarked is returned."
9099 (gnus-summary-mark-as-processable n t))
9101 (defun gnus-summary-unmark-all-processable ()
9102 "Remove the process mark from all articles."
9105 (while gnus-newsgroup-processable
9106 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9107 (gnus-summary-position-point))
9109 (defun gnus-summary-add-mark (article type)
9110 "Mark ARTICLE with a mark of TYPE."
9111 (let ((vtype (car (assq type gnus-article-mark-lists)))
9114 (error "No such mark type: %s" type)
9115 (setq var (intern (format "gnus-newsgroup-%s" type)))
9116 (set var (cons article (symbol-value var)))
9117 (if (memq type '(processable cached replied forwarded recent saved))
9118 (gnus-summary-update-secondary-mark article)
9119 ;;; !!! This is bogus. We should find out what primary
9120 ;;; !!! mark we want to set.
9121 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9123 (defun gnus-summary-mark-as-expirable (n)
9124 "Mark N articles forward as expirable.
9125 If N is negative, mark backward instead. The difference between N and
9126 the actual number of articles marked is returned."
9128 (gnus-summary-mark-forward n gnus-expirable-mark))
9130 (defun gnus-summary-mark-article-as-replied (article)
9131 "Mark ARTICLE as replied to and update the summary line.
9132 ARTICLE can also be a list of articles."
9133 (interactive (list (gnus-summary-article-number)))
9134 (let ((articles (if (listp article) article (list article))))
9135 (dolist (article articles)
9136 (push article gnus-newsgroup-replied)
9137 (let ((buffer-read-only nil))
9138 (when (gnus-summary-goto-subject article nil t)
9139 (gnus-summary-update-secondary-mark article))))))
9141 (defun gnus-summary-mark-article-as-forwarded (article)
9142 "Mark ARTICLE as forwarded and update the summary line.
9143 ARTICLE can also be a list of articles."
9144 (let ((articles (if (listp article) article (list article))))
9145 (dolist (article articles)
9146 (push article gnus-newsgroup-forwarded)
9147 (let ((buffer-read-only nil))
9148 (when (gnus-summary-goto-subject article nil t)
9149 (gnus-summary-update-secondary-mark article))))))
9151 (defun gnus-summary-set-bookmark (article)
9152 "Set a bookmark in current article."
9153 (interactive (list (gnus-summary-article-number)))
9154 (when (or (not (get-buffer gnus-article-buffer))
9155 (not gnus-current-article)
9156 (not gnus-article-current)
9157 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9158 (error "No current article selected"))
9159 ;; Remove old bookmark, if one exists.
9160 (let ((old (assq article gnus-newsgroup-bookmarks)))
9162 (setq gnus-newsgroup-bookmarks
9163 (delq old gnus-newsgroup-bookmarks))))
9164 ;; Set the new bookmark, which is on the form
9165 ;; (article-number . line-number-in-body).
9169 (set-buffer gnus-article-buffer)
9173 (goto-char (point-min))
9174 (search-forward "\n\n" nil t)
9177 gnus-newsgroup-bookmarks)
9178 (gnus-message 6 "A bookmark has been added to the current article."))
9180 (defun gnus-summary-remove-bookmark (article)
9181 "Remove the bookmark from the current article."
9182 (interactive (list (gnus-summary-article-number)))
9183 ;; Remove old bookmark, if one exists.
9184 (let ((old (assq article gnus-newsgroup-bookmarks)))
9187 (setq gnus-newsgroup-bookmarks
9188 (delq old gnus-newsgroup-bookmarks))
9189 (gnus-message 6 "Removed bookmark."))
9190 (gnus-message 6 "No bookmark in current article."))))
9192 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9193 (defun gnus-summary-mark-as-dormant (n)
9194 "Mark N articles forward as dormant.
9195 If N is negative, mark backward instead. The difference between N and
9196 the actual number of articles marked is returned."
9198 (gnus-summary-mark-forward n gnus-dormant-mark))
9200 (defun gnus-summary-set-process-mark (article)
9201 "Set the process mark on ARTICLE and update the summary line."
9202 (setq gnus-newsgroup-processable
9204 (delq article gnus-newsgroup-processable)))
9205 (when (gnus-summary-goto-subject article)
9206 (gnus-summary-show-thread)
9207 (gnus-summary-goto-subject article)
9208 (gnus-summary-update-secondary-mark article)))
9210 (defun gnus-summary-remove-process-mark (article)
9211 "Remove the process mark from ARTICLE and update the summary line."
9212 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9213 (when (gnus-summary-goto-subject article)
9214 (gnus-summary-show-thread)
9215 (gnus-summary-goto-subject article)
9216 (gnus-summary-update-secondary-mark article)))
9218 (defun gnus-summary-set-saved-mark (article)
9219 "Set the process mark on ARTICLE and update the summary line."
9220 (push article gnus-newsgroup-saved)
9221 (when (gnus-summary-goto-subject article)
9222 (gnus-summary-update-secondary-mark article)))
9224 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9225 "Mark N articles as read forwards.
9226 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9227 The difference between N and the actual number of articles marked is
9229 Iff NO-EXPIRE, auto-expiry will be inhibited."
9231 (gnus-summary-show-thread)
9232 (let ((backward (< n 0))
9233 (gnus-summary-goto-unread
9234 (and gnus-summary-goto-unread
9235 (not (eq gnus-summary-goto-unread 'never))
9236 (not (memq mark (list gnus-unread-mark
9237 gnus-ticked-mark gnus-dormant-mark)))))
9239 (mark (or mark gnus-del-mark)))
9241 (gnus-summary-mark-article nil mark no-expire)
9242 (zerop (gnus-summary-next-subject
9244 (and gnus-summary-goto-unread
9245 (not (eq gnus-summary-goto-unread 'never)))
9249 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9250 (gnus-summary-recenter)
9251 (gnus-summary-position-point)
9252 (gnus-set-mode-line 'summary)
9255 (defun gnus-summary-mark-article-as-read (mark)
9256 "Mark the current article quickly as read with MARK."
9257 (let ((article (gnus-summary-article-number)))
9258 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9259 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9260 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9261 (push (cons article mark) gnus-newsgroup-reads)
9262 ;; Possibly remove from cache, if that is used.
9263 (when gnus-use-cache
9264 (gnus-cache-enter-remove-article article))
9265 ;; Allow the backend to change the mark.
9266 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9267 ;; Check for auto-expiry.
9268 (when (and gnus-newsgroup-auto-expire
9269 (memq mark gnus-auto-expirable-marks))
9270 (setq mark gnus-expirable-mark)
9271 ;; Let the backend know about the mark change.
9272 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9273 (push article gnus-newsgroup-expirable))
9274 ;; Set the mark in the buffer.
9275 (gnus-summary-update-mark mark 'unread)
9278 (defun gnus-summary-mark-article-as-unread (mark)
9279 "Mark the current article quickly as unread with MARK."
9280 (let* ((article (gnus-summary-article-number))
9281 (old-mark (gnus-summary-article-mark article)))
9282 ;; Allow the backend to change the mark.
9283 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9284 (if (eq mark old-mark)
9288 (gnus-error 1 "Can't mark negative article numbers")
9290 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9291 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9292 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9293 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9294 (cond ((= mark gnus-ticked-mark)
9295 (push article gnus-newsgroup-marked))
9296 ((= mark gnus-dormant-mark)
9297 (push article gnus-newsgroup-dormant))
9299 (push article gnus-newsgroup-unreads)))
9300 (gnus-pull article gnus-newsgroup-reads)
9302 ;; See whether the article is to be put in the cache.
9304 (vectorp (gnus-summary-article-header article))
9306 (gnus-cache-possibly-enter-article
9307 gnus-newsgroup-name article
9308 (gnus-summary-article-header article)
9309 (= mark gnus-ticked-mark)
9310 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9313 (gnus-summary-update-mark mark 'unread)
9316 (defun gnus-summary-mark-article (&optional article mark no-expire)
9317 "Mark ARTICLE with MARK. MARK can be any character.
9318 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9319 `??' (dormant) and `?E' (expirable).
9320 If MARK is nil, then the default character `?r' is used.
9321 If ARTICLE is nil, then the article on the current line will be
9323 Iff NO-EXPIRE, auto-expiry will be inhibited."
9324 ;; The mark might be a string.
9325 (when (stringp mark)
9326 (setq mark (aref mark 0)))
9327 ;; If no mark is given, then we check auto-expiring.
9329 (setq mark gnus-del-mark))
9330 (when (and (not no-expire)
9331 gnus-newsgroup-auto-expire
9332 (memq mark gnus-auto-expirable-marks))
9333 (setq mark gnus-expirable-mark))
9334 (let ((article (or article (gnus-summary-article-number)))
9335 (old-mark (gnus-summary-article-mark article)))
9336 ;; Allow the backend to change the mark.
9337 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9338 (if (eq mark old-mark)
9341 (error "No article on current line"))
9342 (if (not (if (or (= mark gnus-unread-mark)
9343 (= mark gnus-ticked-mark)
9344 (= mark gnus-dormant-mark))
9345 (gnus-mark-article-as-unread article mark)
9346 (gnus-mark-article-as-read article mark)))
9348 ;; See whether the article is to be put in the cache.
9350 (not (= mark gnus-canceled-mark))
9351 (vectorp (gnus-summary-article-header article))
9353 (gnus-cache-possibly-enter-article
9354 gnus-newsgroup-name article
9355 (gnus-summary-article-header article)
9356 (= mark gnus-ticked-mark)
9357 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9359 (when (gnus-summary-goto-subject article nil t)
9360 (let ((buffer-read-only nil))
9361 (gnus-summary-show-thread)
9363 (gnus-summary-update-mark mark 'unread)
9366 (defun gnus-summary-update-secondary-mark (article)
9367 "Update the secondary (read, process, cache) mark."
9368 (gnus-summary-update-mark
9369 (cond ((memq article gnus-newsgroup-processable)
9371 ((memq article gnus-newsgroup-cached)
9373 ((memq article gnus-newsgroup-replied)
9375 ((memq article gnus-newsgroup-forwarded)
9376 gnus-forwarded-mark)
9377 ((memq article gnus-newsgroup-saved)
9379 ((memq article gnus-newsgroup-recent)
9381 ((memq article gnus-newsgroup-unseen)
9385 (when (gnus-visual-p 'summary-highlight 'highlight)
9386 (gnus-run-hooks 'gnus-summary-update-hook))
9389 (defun gnus-summary-update-mark (mark type)
9390 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9391 (buffer-read-only nil))
9392 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9394 (when (looking-at "\r")
9396 (when (<= (+ forward (point)) (point-max))
9397 ;; Go to the right position on the line.
9398 (goto-char (+ forward (point)))
9399 ;; Replace the old mark with the new mark.
9400 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9401 ;; Optionally update the marks by some user rule.
9402 (when (eq type 'unread)
9404 (gnus-data-find (gnus-summary-article-number)) mark)
9405 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9407 (defun gnus-mark-article-as-read (article &optional mark)
9408 "Enter ARTICLE in the pertinent lists and remove it from others."
9409 ;; Make the article expirable.
9410 (let ((mark (or mark gnus-del-mark)))
9411 (if (= mark gnus-expirable-mark)
9412 (push article gnus-newsgroup-expirable)
9413 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9414 ;; Remove from unread and marked lists.
9415 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9416 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9417 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9418 (push (cons article mark) gnus-newsgroup-reads)
9419 ;; Possibly remove from cache, if that is used.
9420 (when gnus-use-cache
9421 (gnus-cache-enter-remove-article article))
9424 (defun gnus-mark-article-as-unread (article &optional mark)
9425 "Enter ARTICLE in the pertinent lists and remove it from others."
9426 (let ((mark (or mark gnus-ticked-mark)))
9429 (gnus-error 1 "Can't mark negative article numbers")
9431 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9432 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9433 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9434 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9436 ;; Unsuppress duplicates?
9437 (when gnus-suppress-duplicates
9438 (gnus-dup-unsuppress-article article))
9440 (cond ((= mark gnus-ticked-mark)
9441 (push article gnus-newsgroup-marked))
9442 ((= mark gnus-dormant-mark)
9443 (push article gnus-newsgroup-dormant))
9445 (push article gnus-newsgroup-unreads)))
9446 (gnus-pull article gnus-newsgroup-reads)
9449 (defalias 'gnus-summary-mark-as-unread-forward
9450 'gnus-summary-tick-article-forward)
9451 (make-obsolete 'gnus-summary-mark-as-unread-forward
9452 'gnus-summary-tick-article-forward)
9453 (defun gnus-summary-tick-article-forward (n)
9454 "Tick N articles forwards.
9455 If N is negative, tick backwards instead.
9456 The difference between N and the number of articles ticked is returned."
9458 (gnus-summary-mark-forward n gnus-ticked-mark))
9460 (defalias 'gnus-summary-mark-as-unread-backward
9461 'gnus-summary-tick-article-backward)
9462 (make-obsolete 'gnus-summary-mark-as-unread-backward
9463 'gnus-summary-tick-article-backward)
9464 (defun gnus-summary-tick-article-backward (n)
9465 "Tick N articles backwards.
9466 The difference between N and the number of articles ticked is returned."
9468 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9470 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9471 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9472 (defun gnus-summary-tick-article (&optional article clear-mark)
9473 "Mark current article as unread.
9474 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9475 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9477 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9480 (defun gnus-summary-mark-as-read-forward (n)
9481 "Mark N articles as read forwards.
9482 If N is negative, mark backwards instead.
9483 The difference between N and the actual number of articles marked is
9486 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9488 (defun gnus-summary-mark-as-read-backward (n)
9489 "Mark the N articles as read backwards.
9490 The difference between N and the actual number of articles marked is
9493 (gnus-summary-mark-forward
9494 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9496 (defun gnus-summary-mark-as-read (&optional article mark)
9497 "Mark current article as read.
9498 ARTICLE specifies the article to be marked as read.
9499 MARK specifies a string to be inserted at the beginning of the line."
9500 (gnus-summary-mark-article article mark))
9502 (defun gnus-summary-clear-mark-forward (n)
9503 "Clear marks from N articles forward.
9504 If N is negative, clear backward instead.
9505 The difference between N and the number of marks cleared is returned."
9507 (gnus-summary-mark-forward n gnus-unread-mark))
9509 (defun gnus-summary-clear-mark-backward (n)
9510 "Clear marks from N articles backward.
9511 The difference between N and the number of marks cleared is returned."
9513 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9515 (defun gnus-summary-mark-unread-as-read ()
9516 "Intended to be used by `gnus-summary-mark-article-hook'."
9517 (when (memq gnus-current-article gnus-newsgroup-unreads)
9518 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9520 (defun gnus-summary-mark-read-and-unread-as-read ()
9521 "Intended to be used by `gnus-summary-mark-article-hook'."
9522 (let ((mark (gnus-summary-article-mark)))
9523 (when (or (gnus-unread-mark-p mark)
9524 (gnus-read-mark-p mark))
9525 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9527 (defun gnus-summary-mark-unread-as-ticked ()
9528 "Intended to be used by `gnus-summary-mark-article-hook'."
9529 (when (memq gnus-current-article gnus-newsgroup-unreads)
9530 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9532 (defun gnus-summary-mark-region-as-read (point mark all)
9533 "Mark all unread articles between point and mark as read.
9534 If given a prefix, mark all articles between point and mark as read,
9535 even ticked and dormant ones."
9536 (interactive "r\nP")
9545 (memq (setq article (gnus-summary-article-number))
9546 gnus-newsgroup-unreads))
9547 (gnus-summary-mark-article article gnus-del-mark))
9549 (gnus-summary-find-next))))))
9551 (defun gnus-summary-mark-below (score mark)
9552 "Mark articles with score less than SCORE with MARK."
9553 (interactive "P\ncMark: ")
9554 (setq score (if score
9555 (prefix-numeric-value score)
9556 (or gnus-summary-default-score 0)))
9558 (set-buffer gnus-summary-buffer)
9559 (goto-char (point-min))
9562 (and (< (gnus-summary-article-score) score)
9563 (gnus-summary-mark-article nil mark))
9564 (gnus-summary-find-next)))))
9566 (defun gnus-summary-kill-below (&optional score)
9567 "Mark articles with score below SCORE as read."
9569 (gnus-summary-mark-below score gnus-killed-mark))
9571 (defun gnus-summary-clear-above (&optional score)
9572 "Clear all marks from articles with score above SCORE."
9574 (gnus-summary-mark-above score gnus-unread-mark))
9576 (defun gnus-summary-tick-above (&optional score)
9577 "Tick all articles with score above SCORE."
9579 (gnus-summary-mark-above score gnus-ticked-mark))
9581 (defun gnus-summary-mark-above (score mark)
9582 "Mark articles with score over SCORE with MARK."
9583 (interactive "P\ncMark: ")
9584 (setq score (if score
9585 (prefix-numeric-value score)
9586 (or gnus-summary-default-score 0)))
9588 (set-buffer gnus-summary-buffer)
9589 (goto-char (point-min))
9591 (when (> (gnus-summary-article-score) score)
9592 (gnus-summary-mark-article nil mark))
9594 (gnus-summary-find-next)))))
9596 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9597 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9598 (defun gnus-summary-limit-include-expunged (&optional no-error)
9599 "Display all the hidden articles that were expunged for low scores."
9601 (let ((buffer-read-only nil))
9602 (let ((scored gnus-newsgroup-scored)
9605 (unless (gnus-summary-article-header (caar scored))
9606 (and (setq h (gnus-number-to-header (caar scored)))
9607 (< (cdar scored) gnus-summary-expunge-below)
9609 (setq scored (cdr scored)))
9611 (when (not no-error)
9612 (error "No expunged articles hidden"))
9613 (goto-char (point-min))
9614 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9615 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9616 (mapcar (lambda (x) (push (mail-header-number x)
9617 gnus-newsgroup-limit))
9619 (gnus-summary-prepare-unthreaded (nreverse headers))
9620 (goto-char (point-min))
9621 (gnus-summary-position-point)
9624 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9625 "Mark all unread articles in this newsgroup as read.
9626 If prefix argument ALL is non-nil, ticked and dormant articles will
9627 also be marked as read.
9628 If QUIETLY is non-nil, no questions will be asked.
9629 If TO-HERE is non-nil, it should be a point in the buffer. All
9630 articles before (after, if REVERSE is set) this point will be marked as read.
9631 Note that this function will only catch up the unread article
9632 in the current summary buffer limitation.
9633 The number of articles marked as read is returned."
9638 (not gnus-interactive-catchup) ;Without confirmation?
9642 "Mark absolutely all articles as read? "
9643 "Mark all unread articles as read? ")))
9645 (not gnus-newsgroup-adaptive)
9646 (not gnus-newsgroup-auto-expire)
9647 (not gnus-suppress-duplicates)
9648 (or (not gnus-use-cache)
9649 (eq gnus-use-cache 'passive)))
9652 (setq gnus-newsgroup-marked nil
9653 gnus-newsgroup-dormant nil))
9654 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9655 ;; We actually mark all articles as canceled, which we
9656 ;; have to do when using auto-expiry or adaptive scoring.
9657 (gnus-summary-show-all-threads)
9658 (if (and to-here reverse)
9662 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9663 (gnus-summary-find-next (not all) nil nil t))))
9664 (when (gnus-summary-first-subject (not all) t)
9666 (if to-here (< (point) to-here) t)
9667 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9668 (gnus-summary-find-next (not all) nil nil t)))))
9669 (gnus-set-mode-line 'summary))
9671 (gnus-summary-position-point)))
9673 (defun gnus-summary-catchup-to-here (&optional all)
9674 "Mark all unticked articles before the current one as read.
9675 If ALL is non-nil, also mark ticked and dormant articles as read."
9678 (gnus-save-hidden-threads
9679 (let ((beg (point)))
9680 ;; We check that there are unread articles.
9681 (when (or all (gnus-summary-find-prev))
9682 (gnus-summary-catchup all t beg)))))
9683 (gnus-summary-position-point))
9685 (defun gnus-summary-catchup-from-here (&optional all)
9686 "Mark all unticked articles after the current one as read.
9687 If ALL is non-nil, also mark ticked and dormant articles as read."
9690 (gnus-save-hidden-threads
9691 (let ((beg (point)))
9692 ;; We check that there are unread articles.
9693 (when (or all (gnus-summary-find-next))
9694 (gnus-summary-catchup all t beg nil t)))))
9695 (gnus-summary-position-point))
9697 (defun gnus-summary-catchup-all (&optional quietly)
9698 "Mark all articles in this newsgroup as read."
9700 (gnus-summary-catchup t quietly))
9702 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9703 "Mark all unread articles in this group as read, then exit.
9704 If prefix argument ALL is non-nil, all articles are marked as read.
9705 If QUIETLY is non-nil, no questions will be asked."
9707 (when (gnus-summary-catchup all quietly nil 'fast)
9708 ;; Select next newsgroup or exit.
9709 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9710 (eq gnus-auto-select-next 'quietly))
9711 (gnus-summary-next-group nil)
9712 (gnus-summary-exit))))
9714 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9715 "Mark all articles in this newsgroup as read, and then exit."
9717 (gnus-summary-catchup-and-exit t quietly))
9719 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9720 "Mark all articles in this group as read and select the next group.
9721 If given a prefix, mark all articles, unread as well as ticked, as
9725 (gnus-summary-catchup all))
9726 (gnus-summary-next-group))
9732 (defmacro gnus-with-article (article &rest forms)
9733 "Select ARTICLE and perform FORMS in the original article buffer.
9734 Then replace the article with the result."
9736 ;; We don't want the article to be marked as read.
9737 (let (gnus-mark-article-hook)
9738 (gnus-summary-select-article t t nil ,article))
9739 (set-buffer gnus-original-article-buffer)
9741 (if (not (gnus-check-backend-function
9742 'request-replace-article (car gnus-article-current)))
9743 (gnus-message 5 "Read-only group; not replacing")
9744 (unless (gnus-request-replace-article
9745 ,article (car gnus-article-current)
9747 (error "Couldn't replace article")))
9748 ;; The cache and backlog have to be flushed somewhat.
9749 (when gnus-keep-backlog
9750 (gnus-backlog-remove-article
9751 (car gnus-article-current) (cdr gnus-article-current)))
9752 (when gnus-use-cache
9753 (gnus-cache-update-article
9754 (car gnus-article-current) (cdr gnus-article-current)))))
9756 (put 'gnus-with-article 'lisp-indent-function 1)
9757 (put 'gnus-with-article 'edebug-form-spec '(form body))
9759 ;; Thread-based commands.
9761 (defun gnus-summary-articles-in-thread (&optional article)
9762 "Return a list of all articles in the current thread.
9763 If ARTICLE is non-nil, return all articles in the thread that starts
9765 (let* ((article (or article (gnus-summary-article-number)))
9766 (data (gnus-data-find-list article))
9767 (top-level (gnus-data-level (car data)))
9769 (cond ((null gnus-thread-operation-ignore-subject)
9770 (gnus-simplify-subject-re
9771 (mail-header-subject (gnus-data-header (car data)))))
9772 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9773 (gnus-simplify-subject-fuzzy
9774 (mail-header-subject (gnus-data-header (car data)))))
9776 (end-point (save-excursion
9777 (if (gnus-summary-go-to-next-thread)
9778 (point) (point-max))))
9781 (< (gnus-data-pos (car data)) end-point))
9782 (when (or (not top-subject)
9783 (string= top-subject
9784 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9785 (gnus-simplify-subject-fuzzy
9786 (mail-header-subject
9787 (gnus-data-header (car data))))
9788 (gnus-simplify-subject-re
9789 (mail-header-subject
9790 (gnus-data-header (car data)))))))
9791 (push (gnus-data-number (car data)) articles))
9792 (unless (and (setq data (cdr data))
9793 (> (gnus-data-level (car data)) top-level))
9795 ;; Return the list of articles.
9796 (nreverse articles)))
9798 (defun gnus-summary-rethread-current ()
9799 "Rethread the thread the current article is part of."
9801 (let* ((gnus-show-threads t)
9802 (article (gnus-summary-article-number))
9803 (id (mail-header-id (gnus-summary-article-header)))
9804 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9806 (error "No article on the current line"))
9807 (gnus-rebuild-thread id)
9808 (gnus-summary-goto-subject article)))
9810 (defun gnus-summary-reparent-thread ()
9811 "Make the current article child of the marked (or previous) article.
9813 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9814 is non-nil or the Subject: of both articles are the same."
9816 (unless (not (gnus-group-read-only-p))
9817 (error "The current newsgroup does not support article editing"))
9818 (unless (<= (length gnus-newsgroup-processable) 1)
9819 (error "No more than one article may be marked"))
9820 (save-window-excursion
9821 (let ((gnus-article-buffer " *reparent*")
9822 (current-article (gnus-summary-article-number))
9823 ;; First grab the marked article, otherwise one line up.
9824 (parent-article (if (not (null gnus-newsgroup-processable))
9825 (car gnus-newsgroup-processable)
9827 (if (eq (forward-line -1) 0)
9828 (gnus-summary-article-number)
9829 (error "Beginning of summary buffer"))))))
9830 (unless (not (eq current-article parent-article))
9831 (error "An article may not be self-referential"))
9832 (let ((message-id (mail-header-id
9833 (gnus-summary-article-header parent-article))))
9834 (unless (and message-id (not (equal message-id "")))
9835 (error "No message-id in desired parent"))
9836 (gnus-with-article current-article
9838 (goto-char (point-min))
9839 (message-narrow-to-head)
9840 (if (re-search-forward "^References: " nil t)
9842 (re-search-forward "^[^ \t]" nil t)
9845 (insert " " message-id))
9846 (insert "References: " message-id "\n"))))
9847 (set-buffer gnus-summary-buffer)
9848 (gnus-summary-unmark-all-processable)
9849 (gnus-summary-update-article current-article)
9850 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9851 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9852 (gnus-summary-rethread-current)
9853 (gnus-message 3 "Article %d is now the child of article %d"
9854 current-article parent-article)))))
9856 (defun gnus-summary-toggle-threads (&optional arg)
9857 "Toggle showing conversation threads.
9858 If ARG is positive number, turn showing conversation threads on."
9860 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9861 (setq gnus-show-threads
9862 (if (null arg) (not gnus-show-threads)
9863 (> (prefix-numeric-value arg) 0)))
9864 (gnus-summary-prepare)
9865 (gnus-summary-goto-subject current)
9866 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9867 (gnus-summary-position-point)))
9869 (defun gnus-summary-show-all-threads ()
9873 (let ((buffer-read-only nil))
9874 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9875 (gnus-summary-position-point))
9877 (defun gnus-summary-show-thread ()
9878 "Show thread subtrees.
9879 Returns nil if no thread was there to be shown."
9881 (let ((buffer-read-only nil)
9883 ;; first goto end then to beg, to have point at beg after let
9884 (end (progn (end-of-line) (point)))
9885 (beg (progn (beginning-of-line) (point))))
9887 ;; Any hidden lines here?
9888 (search-forward "\r" end t)
9889 (subst-char-in-region beg end ?\^M ?\n t)
9891 (gnus-summary-position-point))))
9893 (defun gnus-summary-maybe-hide-threads ()
9894 "If requested, hide the threads that should be hidden."
9895 (when (and gnus-show-threads
9896 gnus-thread-hide-subtree)
9897 (gnus-summary-hide-all-threads
9898 (if (or (consp gnus-thread-hide-subtree)
9899 (gnus-functionp gnus-thread-hide-subtree))
9900 (gnus-make-predicate gnus-thread-hide-subtree)
9903 ;;; Hiding predicates.
9905 (defun gnus-article-unread-p (header)
9906 (memq (mail-header-number header) gnus-newsgroup-unreads))
9908 (defun gnus-article-unseen-p (header)
9909 (memq (mail-header-number header) gnus-newsgroup-unseen))
9911 (defun gnus-map-articles (predicate articles)
9912 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
9913 (apply 'gnus-or (mapcar predicate
9914 (mapcar 'gnus-summary-article-header articles))))
9916 (defun gnus-summary-hide-all-threads (&optional predicate)
9917 "Hide all thread subtrees.
9918 If PREDICATE is supplied, threads that satisfy this predicate
9919 will not be hidden."
9922 (goto-char (point-min))
9925 (when (or (not predicate)
9927 predicate (gnus-summary-article-children)))
9928 (gnus-summary-hide-thread))
9929 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
9930 (gnus-summary-position-point))
9932 (defun gnus-summary-hide-thread ()
9933 "Hide thread subtrees.
9934 If PREDICATE is supplied, threads that satisfy this predicate
9936 Returns nil if no threads were there to be hidden."
9938 (let ((buffer-read-only nil)
9940 (article (gnus-summary-article-number)))
9942 ;; Go forward until either the buffer ends or the subthread
9944 (when (and (not (eobp))
9945 (or (zerop (gnus-summary-next-thread 1 t))
9946 (goto-char (point-max))))
9948 (if (and (> (point) start)
9949 (search-backward "\n" start t))
9951 (subst-char-in-region start (point) ?\n ?\^M)
9952 (gnus-summary-goto-subject article))
9956 (defun gnus-summary-go-to-next-thread (&optional previous)
9957 "Go to the same level (or less) next thread.
9958 If PREVIOUS is non-nil, go to previous thread instead.
9959 Return the article number moved to, or nil if moving was impossible."
9960 (let ((level (gnus-summary-thread-level))
9961 (way (if previous -1 1))
9964 (while (and (not (eobp))
9965 (< level (gnus-summary-thread-level)))
9973 (gnus-summary-article-number)
9976 (defun gnus-summary-next-thread (n &optional silent)
9977 "Go to the same level next N'th thread.
9978 If N is negative, search backward instead.
9979 Returns the difference between N and the number of skips actually
9982 If SILENT, don't output messages."
9984 (let ((backward (< n 0))
9987 (gnus-summary-go-to-next-thread backward))
9990 (gnus-summary-position-point))
9991 (when (and (not silent) (/= 0 n))
9992 (gnus-message 7 "No more threads"))
9995 (defun gnus-summary-prev-thread (n)
9996 "Go to the same level previous N'th thread.
9997 Returns the difference between N and the number of skips actually
10000 (gnus-summary-next-thread (- n)))
10002 (defun gnus-summary-go-down-thread ()
10003 "Go down one level in the current thread."
10004 (let ((children (gnus-summary-article-children)))
10006 (gnus-summary-goto-subject (car children)))))
10008 (defun gnus-summary-go-up-thread ()
10009 "Go up one level in the current thread."
10010 (let ((parent (gnus-summary-article-parent)))
10012 (gnus-summary-goto-subject parent))))
10014 (defun gnus-summary-down-thread (n)
10015 "Go down thread N steps.
10016 If N is negative, go up instead.
10017 Returns the difference between N and how many steps down that were
10022 (while (and (> n 0)
10023 (if up (gnus-summary-go-up-thread)
10024 (gnus-summary-go-down-thread)))
10026 (gnus-summary-position-point)
10028 (gnus-message 7 "Can't go further"))
10031 (defun gnus-summary-up-thread (n)
10032 "Go up thread N steps.
10033 If N is negative, go down instead.
10034 Returns the difference between N and how many steps down that were
10037 (gnus-summary-down-thread (- n)))
10039 (defun gnus-summary-top-thread ()
10040 "Go to the top of the thread."
10042 (while (gnus-summary-go-up-thread))
10043 (gnus-summary-article-number))
10045 (defun gnus-summary-kill-thread (&optional unmark)
10046 "Mark articles under current thread as read.
10047 If the prefix argument is positive, remove any kinds of marks.
10048 If the prefix argument is negative, tick articles instead."
10051 (setq unmark (prefix-numeric-value unmark)))
10052 (let ((articles (gnus-summary-articles-in-thread)))
10054 ;; Expand the thread.
10055 (gnus-summary-show-thread)
10056 ;; Mark all the articles.
10058 (gnus-summary-goto-subject (car articles))
10059 (cond ((null unmark)
10060 (gnus-summary-mark-article-as-read gnus-killed-mark))
10062 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10064 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10065 (setq articles (cdr articles))))
10066 ;; Hide killed subtrees.
10068 gnus-thread-hide-killed
10069 (gnus-summary-hide-thread))
10070 ;; If marked as read, go to next unread subject.
10071 (when (null unmark)
10072 ;; Go to next unread subject.
10073 (gnus-summary-next-subject 1 t)))
10074 (gnus-set-mode-line 'summary))
10076 ;; Summary sorting commands
10078 (defun gnus-summary-sort-by-number (&optional reverse)
10079 "Sort the summary buffer by article number.
10080 Argument REVERSE means reverse order."
10082 (gnus-summary-sort 'number reverse))
10084 (defun gnus-summary-sort-by-author (&optional reverse)
10085 "Sort the summary buffer by author name alphabetically.
10086 If `case-fold-search' is non-nil, case of letters is ignored.
10087 Argument REVERSE means reverse order."
10089 (gnus-summary-sort 'author reverse))
10091 (defun gnus-summary-sort-by-subject (&optional reverse)
10092 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10093 If `case-fold-search' is non-nil, case of letters is ignored.
10094 Argument REVERSE means reverse order."
10096 (gnus-summary-sort 'subject reverse))
10098 (defun gnus-summary-sort-by-date (&optional reverse)
10099 "Sort the summary buffer by date.
10100 Argument REVERSE means reverse order."
10102 (gnus-summary-sort 'date reverse))
10104 (defun gnus-summary-sort-by-score (&optional reverse)
10105 "Sort the summary buffer by score.
10106 Argument REVERSE means reverse order."
10108 (gnus-summary-sort 'score reverse))
10110 (defun gnus-summary-sort-by-lines (&optional reverse)
10111 "Sort the summary buffer by the number of lines.
10112 Argument REVERSE means reverse order."
10114 (gnus-summary-sort 'lines reverse))
10116 (defun gnus-summary-sort-by-chars (&optional reverse)
10117 "Sort the summary buffer by article length.
10118 Argument REVERSE means reverse order."
10120 (gnus-summary-sort 'chars reverse))
10122 (defun gnus-summary-sort-by-original (&optional reverse)
10123 "Sort the summary buffer using the default sorting method.
10124 Argument REVERSE means reverse order."
10126 (let* ((buffer-read-only)
10127 (gnus-summary-prepare-hook nil))
10128 ;; We do the sorting by regenerating the threads.
10129 (gnus-summary-prepare)
10130 ;; Hide subthreads if needed.
10131 (gnus-summary-maybe-hide-threads)))
10133 (defun gnus-summary-sort (predicate reverse)
10134 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10135 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10136 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10137 (gnus-thread-sort-functions
10142 (gnus-sort-gathered-threads-function
10143 gnus-thread-sort-functions)
10144 (gnus-article-sort-functions
10148 (,article t2 t1))))
10150 (gnus-summary-prepare-hook nil))
10151 ;; We do the sorting by regenerating the threads.
10152 (gnus-summary-prepare)
10153 ;; Hide subthreads if needed.
10154 (gnus-summary-maybe-hide-threads)))
10156 ;; Summary saving commands.
10158 (defun gnus-summary-save-article (&optional n not-saved)
10159 "Save the current article using the default saver function.
10160 If N is a positive number, save the N next articles.
10161 If N is a negative number, save the N previous articles.
10162 If N is nil and any articles have been marked with the process mark,
10163 save those articles instead.
10164 The variable `gnus-default-article-saver' specifies the saver function."
10166 (let* ((articles (gnus-summary-work-articles n))
10167 (save-buffer (save-excursion
10168 (nnheader-set-temp-buffer " *Gnus Save*")))
10169 (num (length articles))
10171 (dolist (article articles)
10172 (setq header (gnus-summary-article-header article))
10173 (if (not (vectorp header))
10174 ;; This is a pseudo-article.
10175 (if (assq 'name header)
10176 (gnus-copy-file (cdr (assq 'name header)))
10177 (gnus-message 1 "Article %d is unsaveable" article))
10178 ;; This is a real article.
10179 (save-window-excursion
10180 (let ((gnus-display-mime-function nil)
10181 (gnus-article-prepare-hook nil))
10182 (gnus-summary-select-article t nil nil article)))
10184 (set-buffer save-buffer)
10186 (insert-buffer-substring gnus-original-article-buffer))
10187 (setq file (gnus-article-save save-buffer file num))
10188 (gnus-summary-remove-process-mark article)
10190 (gnus-summary-set-saved-mark article))))
10191 (gnus-kill-buffer save-buffer)
10192 (gnus-summary-position-point)
10193 (gnus-set-mode-line 'summary)
10196 (defun gnus-summary-pipe-output (&optional arg)
10197 "Pipe the current article to a subprocess.
10198 If N is a positive number, pipe the N next articles.
10199 If N is a negative number, pipe the N previous articles.
10200 If N is nil and any articles have been marked with the process mark,
10201 pipe those articles instead."
10203 (require 'gnus-art)
10204 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10205 (gnus-summary-save-article arg t))
10206 (let ((buffer (get-buffer "*Shell Command Output*")))
10208 (with-current-buffer buffer (> (point-max) (point-min))))
10209 (gnus-configure-windows 'pipe))))
10211 (defun gnus-summary-save-article-mail (&optional arg)
10212 "Append the current article to an mail file.
10213 If N is a positive number, save the N next articles.
10214 If N is a negative number, save the N previous articles.
10215 If N is nil and any articles have been marked with the process mark,
10216 save those articles instead."
10218 (require 'gnus-art)
10219 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10220 (gnus-summary-save-article arg)))
10222 (defun gnus-summary-save-article-rmail (&optional arg)
10223 "Append the current article to an rmail file.
10224 If N is a positive number, save the N next articles.
10225 If N is a negative number, save the N previous articles.
10226 If N is nil and any articles have been marked with the process mark,
10227 save those articles instead."
10229 (require 'gnus-art)
10230 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10231 (gnus-summary-save-article arg)))
10233 (defun gnus-summary-save-article-file (&optional arg)
10234 "Append the current article to a file.
10235 If N is a positive number, save the N next articles.
10236 If N is a negative number, save the N previous articles.
10237 If N is nil and any articles have been marked with the process mark,
10238 save those articles instead."
10240 (require 'gnus-art)
10241 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10242 (gnus-summary-save-article arg)))
10244 (defun gnus-summary-write-article-file (&optional arg)
10245 "Write the current article to a file, deleting the previous file.
10246 If N is a positive number, save the N next articles.
10247 If N is a negative number, save the N previous articles.
10248 If N is nil and any articles have been marked with the process mark,
10249 save those articles instead."
10251 (require 'gnus-art)
10252 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10253 (gnus-summary-save-article arg)))
10255 (defun gnus-summary-save-article-body-file (&optional arg)
10256 "Append the current article body to a file.
10257 If N is a positive number, save the N next articles.
10258 If N is a negative number, save the N previous articles.
10259 If N is nil and any articles have been marked with the process mark,
10260 save those articles instead."
10262 (require 'gnus-art)
10263 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10264 (gnus-summary-save-article arg)))
10266 (defun gnus-summary-muttprint (&optional arg)
10267 "Print the current article using Muttprint.
10268 If N is a positive number, save the N next articles.
10269 If N is a negative number, save the N previous articles.
10270 If N is nil and any articles have been marked with the process mark,
10271 save those articles instead."
10273 (require 'gnus-art)
10274 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10275 (gnus-summary-save-article arg t)))
10277 (defun gnus-summary-pipe-message (program)
10278 "Pipe the current article through PROGRAM."
10279 (interactive "sProgram: ")
10280 (gnus-summary-select-article)
10281 (let ((mail-header-separator ""))
10282 (gnus-eval-in-buffer-window gnus-article-buffer
10285 (let ((start (window-start))
10287 (message-pipe-buffer-body program)
10288 (set-window-start (get-buffer-window (current-buffer)) start))))))
10290 (defun gnus-get-split-value (methods)
10291 "Return a value based on the split METHODS."
10292 (let (split-name method result match)
10295 (set-buffer gnus-original-article-buffer)
10297 (nnheader-narrow-to-headers)
10298 (while (and methods (not split-name))
10299 (goto-char (point-min))
10300 (setq method (pop methods))
10301 (setq match (car method))
10304 ;; Regular expression.
10306 (re-search-forward match nil t)))
10307 ((gnus-functionp match)
10311 (setq result (funcall match gnus-newsgroup-name))))
10316 (setq result (eval match)))))
10317 (setq split-name (cdr method))
10318 (cond ((stringp result)
10319 (push (expand-file-name
10320 result gnus-article-save-directory)
10323 (setq split-name (append result split-name)))))))))
10324 (nreverse split-name)))
10326 (defun gnus-valid-move-group-p (group)
10327 (and (boundp group)
10328 (symbol-name group)
10329 (symbol-value group)
10330 (gnus-get-function (gnus-find-method-for-group
10331 (symbol-name group)) 'request-accept-article t)))
10333 (defun gnus-read-move-group-name (prompt default articles prefix)
10334 "Read a group name."
10335 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10336 (minibuffer-confirm-incomplete nil) ; XEmacs
10338 (format "%s %s to:"
10340 (if (> (length articles) 1)
10341 (format "these %d articles" (length articles))
10346 (gnus-completing-read-with-default
10349 'gnus-valid-move-group-p
10351 'gnus-group-history))
10352 ((= 1 (length split-name))
10353 (gnus-completing-read-with-default
10354 (car split-name) prom
10356 'gnus-valid-move-group-p
10358 'gnus-group-history))
10360 (gnus-completing-read-with-default
10362 (mapcar (lambda (el) (list el))
10363 (nreverse split-name))
10365 'gnus-group-history))))
10366 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10368 (if (or (string= to-newsgroup "")
10369 (string= to-newsgroup prefix))
10370 (setq to-newsgroup default))
10371 (unless to-newsgroup
10372 (error "No group name entered"))
10373 (or (gnus-active to-newsgroup)
10374 (gnus-activate-group to-newsgroup nil nil to-method)
10375 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10377 (or (and (gnus-request-create-group to-newsgroup to-method)
10378 (gnus-activate-group
10379 to-newsgroup nil nil to-method)
10380 (gnus-subscribe-group to-newsgroup))
10381 (error "Couldn't create group %s" to-newsgroup)))
10382 (error "No such group: %s" to-newsgroup)))
10385 (defun gnus-summary-save-parts (type dir n &optional reverse)
10386 "Save parts matching TYPE to DIR.
10387 If REVERSE, save parts that do not match TYPE."
10389 (list (read-string "Save parts of type: "
10390 (or (car gnus-summary-save-parts-type-history)
10391 gnus-summary-save-parts-default-mime)
10392 'gnus-summary-save-parts-type-history)
10393 (setq gnus-summary-save-parts-last-directory
10394 (read-file-name "Save to directory: "
10395 gnus-summary-save-parts-last-directory
10397 current-prefix-arg))
10398 (gnus-summary-iterate n
10399 (let ((gnus-display-mime-function nil)
10400 (gnus-inhibit-treatment t))
10401 (gnus-summary-select-article))
10403 (set-buffer gnus-article-buffer)
10404 (let ((handles (or gnus-article-mime-handles
10405 (mm-dissect-buffer) (mm-uu-dissect))))
10407 (gnus-summary-save-parts-1 type dir handles reverse)
10408 (unless gnus-article-mime-handles ;; Don't destroy this case.
10409 (mm-destroy-parts handles)))))))
10411 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10412 (if (stringp (car handle))
10413 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10416 (not (string-match type (mm-handle-media-type handle)))
10417 (string-match type (mm-handle-media-type handle)))
10418 (let ((file (expand-file-name
10419 (file-name-nondirectory
10421 (mail-content-type-get
10422 (mm-handle-disposition handle) 'filename)
10423 (concat gnus-newsgroup-name
10424 "." (number-to-string
10425 (cdr gnus-article-current)))))
10427 (unless (file-exists-p file)
10428 (mm-save-part-to-file handle file))))))
10430 ;; Summary extract commands
10432 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10433 (let ((buffer-read-only nil)
10434 (article (gnus-summary-article-number))
10436 (unless (gnus-summary-goto-subject article)
10437 (error "No such article: %d" article))
10438 (gnus-summary-position-point)
10439 ;; If all commands are to be bunched up on one line, we collect
10441 (unless gnus-view-pseudos-separately
10442 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10445 (setq action (cdr (assq 'action (car ps))))
10446 (setq files (list (cdr (assq 'name (car ps)))))
10447 (while (and ps (cdr ps)
10448 (string= (or action "1")
10449 (or (cdr (assq 'action (cadr ps))) "2")))
10450 (push (cdr (assq 'name (cadr ps))) files)
10451 (setcdr ps (cddr ps)))
10453 (when (not (string-match "%s" action))
10456 (when (assq 'execute (car ps))
10457 (setcdr (assq 'execute (car ps))
10458 (funcall (if (string-match "%s" action)
10465 (gnus-quote-arg-for-sh-or-csh f)))
10467 (setq ps (cdr ps)))))
10468 (if (and gnus-view-pseudos (not not-view))
10470 (when (assq 'execute (car pslist))
10471 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10472 (eq gnus-view-pseudos 'not-confirm)))
10473 (setq pslist (cdr pslist)))
10476 (setq after-article (or (cdr (assq 'article (car pslist)))
10477 (gnus-summary-article-number)))
10478 (gnus-summary-goto-subject after-article)
10481 (insert " " (file-name-nondirectory
10482 (cdr (assq 'name (car pslist))))
10483 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10485 (forward-line -1) ; back to `b'
10486 (gnus-add-text-properties
10487 b (1- e) (list 'gnus-number gnus-reffed-article-number
10488 gnus-mouse-face-prop gnus-mouse-face))
10490 after-article gnus-reffed-article-number
10491 gnus-unread-mark b (car pslist) 0 (- e b))
10492 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10493 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10494 (setq pslist (cdr pslist)))))))
10496 (defun gnus-pseudos< (p1 p2)
10497 (let ((c1 (cdr (assq 'action p1)))
10498 (c2 (cdr (assq 'action p2))))
10499 (and c1 c2 (string< c1 c2))))
10501 (defun gnus-request-pseudo-article (props)
10502 (cond ((assq 'execute props)
10503 (gnus-execute-command (cdr (assq 'execute props)))))
10504 (let ((gnus-current-article (gnus-summary-article-number)))
10505 (gnus-run-hooks 'gnus-mark-article-hook)))
10507 (defun gnus-execute-command (command &optional automatic)
10509 (gnus-article-setup-buffer)
10510 (set-buffer gnus-article-buffer)
10511 (setq buffer-read-only nil)
10512 (let ((command (if automatic command
10513 (read-string "Command: " (cons command 0)))))
10515 (insert "$ " command "\n\n")
10516 (if gnus-view-pseudo-asynchronously
10517 (start-process "gnus-execute" (current-buffer) shell-file-name
10518 shell-command-switch command)
10519 (call-process shell-file-name nil t nil
10520 shell-command-switch command)))))
10522 ;; Summary kill commands.
10524 (defun gnus-summary-edit-global-kill (article)
10525 "Edit the \"global\" kill file."
10526 (interactive (list (gnus-summary-article-number)))
10527 (gnus-group-edit-global-kill article))
10529 (defun gnus-summary-edit-local-kill ()
10530 "Edit a local kill file applied to the current newsgroup."
10532 (setq gnus-current-headers (gnus-summary-article-header))
10533 (gnus-group-edit-local-kill
10534 (gnus-summary-article-number) gnus-newsgroup-name))
10536 ;;; Header reading.
10538 (defun gnus-read-header (id &optional header)
10539 "Read the headers of article ID and enter them into the Gnus system."
10540 (let ((group gnus-newsgroup-name)
10541 (gnus-override-method
10543 gnus-override-method
10544 (and (gnus-news-group-p gnus-newsgroup-name)
10545 (car (gnus-refer-article-methods)))))
10547 ;; First we check to see whether the header in question is already
10550 ;; This is a Message-ID.
10551 (setq header (or header (gnus-id-to-header id)))
10552 ;; This is an article number.
10553 (setq header (or header (gnus-summary-article-header id))))
10555 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10556 ;; We have found the header.
10558 ;; If this is a sparse article, we have to nix out its
10559 ;; previous entry in the thread hashtb.
10561 (gnus-summary-article-sparse-p (mail-header-number header)))
10562 (let* ((parent (gnus-parent-id (mail-header-references header)))
10563 (thread (and parent (gnus-id-to-thread parent))))
10565 (delq (assq header thread) thread))))
10566 ;; We have to really fetch the header to this article.
10568 (set-buffer nntp-server-buffer)
10569 (when (setq where (gnus-request-head id group))
10570 (nnheader-fold-continuation-lines)
10571 (goto-char (point-max))
10573 (goto-char (point-min))
10577 ((cdr where) (cdr where))
10578 (header (mail-header-number header))
10579 (t gnus-reffed-article-number))
10581 (insert " Article retrieved.\n"))
10582 (if (or (not where)
10583 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10584 () ; Malformed head.
10585 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10586 (when (and (stringp id)
10587 (not (string= (gnus-group-real-name group)
10589 ;; If we fetched by Message-ID and the article came
10590 ;; from a different group, we fudge some bogus article
10591 ;; numbers for this article.
10592 (mail-header-set-number header gnus-reffed-article-number))
10594 (set-buffer gnus-summary-buffer)
10595 (decf gnus-reffed-article-number)
10596 (gnus-remove-header (mail-header-number header))
10597 (push header gnus-newsgroup-headers)
10598 (setq gnus-current-headers header)
10599 (push (mail-header-number header) gnus-newsgroup-limit)))
10602 (defun gnus-remove-header (number)
10603 "Remove header NUMBER from `gnus-newsgroup-headers'."
10604 (if (and gnus-newsgroup-headers
10605 (= number (mail-header-number (car gnus-newsgroup-headers))))
10606 (pop gnus-newsgroup-headers)
10607 (let ((headers gnus-newsgroup-headers))
10608 (while (and (cdr headers)
10609 (not (= number (mail-header-number (cadr headers)))))
10611 (when (cdr headers)
10612 (setcdr headers (cddr headers))))))
10615 ;;; summary highlights
10618 (defun gnus-highlight-selected-summary ()
10619 "Highlight selected article in summary buffer."
10620 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10621 (when gnus-summary-selected-face
10623 (let* ((beg (progn (beginning-of-line) (point)))
10624 (end (progn (end-of-line) (point)))
10625 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10626 (from (if (get-text-property beg gnus-mouse-face-prop)
10628 (or (next-single-property-change
10629 beg gnus-mouse-face-prop nil end)
10634 (or (next-single-property-change
10635 from gnus-mouse-face-prop nil end)
10637 ;; If no mouse-face prop on line we will have to = from = end,
10638 ;; so we highlight the entire line instead.
10639 (when (= (+ to 2) from)
10642 (if gnus-newsgroup-selected-overlay
10643 ;; Move old overlay.
10645 gnus-newsgroup-selected-overlay from to (current-buffer))
10646 ;; Create new overlay.
10648 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10649 'face gnus-summary-selected-face))))))
10651 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10652 (defun gnus-summary-highlight-line ()
10653 "Highlight current line according to `gnus-summary-highlight'."
10654 (let* ((list gnus-summary-highlight)
10656 (end (progn (end-of-line) (point)))
10657 ;; now find out where the line starts and leave point there.
10658 (beg (progn (beginning-of-line) (point)))
10659 (article (gnus-summary-article-number))
10660 (score (or (cdr (assq (or article gnus-current-article)
10661 gnus-newsgroup-scored))
10662 gnus-summary-default-score 0))
10663 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10664 (inhibit-read-only t))
10665 ;; Eval the cars of the lists until we find a match.
10666 (let ((default gnus-summary-default-score)
10667 (default-high gnus-summary-default-high-score)
10668 (default-low gnus-summary-default-low-score))
10670 (not (eval (caar list))))
10671 (setq list (cdr list))))
10672 (let ((face (cdar list)))
10673 (unless (eq face (get-text-property beg 'face))
10674 (gnus-put-text-property-excluding-characters-with-faces
10676 (setq face (if (boundp face) (symbol-value face) face)))
10677 (when gnus-summary-highlight-line-function
10678 (funcall gnus-summary-highlight-line-function article face))))
10681 (defun gnus-update-read-articles (group unread &optional compute)
10682 "Update the list of read articles in GROUP."
10683 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10684 (entry (gnus-gethash group gnus-newsrc-hashtb))
10685 (info (nth 2 entry))
10687 (unread (sort (copy-sequence unread) '<))
10689 (if (or (not info) (not active))
10690 ;; There is no info on this group if it was, in fact,
10691 ;; killed. Gnus stores no information on killed groups, so
10692 ;; there's nothing to be done.
10693 ;; One could store the information somewhere temporarily,
10694 ;; perhaps... Hmmm...
10696 ;; Remove any negative articles numbers.
10697 (while (and unread (< (car unread) 0))
10698 (setq unread (cdr unread)))
10699 ;; Remove any expired article numbers
10700 (while (and unread (< (car unread) (car active)))
10701 (setq unread (cdr unread)))
10702 ;; Compute the ranges of read articles by looking at the list of
10703 ;; unread articles.
10705 (when (/= (car unread) prev)
10706 (push (if (= prev (1- (car unread))) prev
10707 (cons prev (1- (car unread))))
10709 (setq prev (1+ (car unread)))
10710 (setq unread (cdr unread)))
10711 (when (<= prev (cdr active))
10712 (push (cons prev (cdr active)) read))
10713 (setq read (if (> (length read) 1) (nreverse read) read))
10718 ;; Propagate the read marks to the backend.
10719 (when (gnus-check-backend-function 'request-set-mark group)
10720 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10721 (add (gnus-remove-from-range read (gnus-info-read info))))
10723 (unless (gnus-check-group group)
10724 (error "Can't open server for %s" group))
10725 (gnus-request-set-mark
10726 group (delq nil (list (if add (list add 'add '(read)))
10727 (if del (list del 'del '(read))))))
10729 `(gnus-request-set-mark
10732 (if del (list del 'add '(read)))
10733 (if add (list add 'del '(read))))))))))
10734 (set-buffer gnus-group-buffer)
10735 (gnus-undo-register
10737 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10738 (gnus-info-set-read ',info ',(gnus-info-read info))
10739 (gnus-get-unread-articles-in-group ',info
10740 (gnus-active ,group))
10741 (gnus-group-update-group ,group t)
10743 ;; Enter this list into the group info.
10744 (gnus-info-set-read info read)
10745 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10746 (gnus-get-unread-articles-in-group info (gnus-active group))
10749 (defun gnus-offer-save-summaries ()
10750 "Offer to save all active summary buffers."
10752 ;; Go through all buffers and find all summaries.
10753 (dolist (buffer (buffer-list))
10754 (when (and (setq buffer (buffer-name buffer))
10755 (string-match "Summary" buffer)
10757 (set-buffer buffer)
10758 ;; We check that this is, indeed, a summary buffer.
10759 (and (eq major-mode 'gnus-summary-mode)
10760 ;; Also make sure this isn't bogus.
10761 gnus-newsgroup-prepared
10762 ;; Also make sure that this isn't a
10763 ;; dead summary buffer.
10764 (not gnus-dead-summary-mode))))
10765 (push buffer buffers)))
10766 ;; Go through all these summary buffers and offer to save them.
10770 "Update summary buffer %s? "
10772 (switch-to-buffer buf)
10773 (gnus-summary-exit))
10777 ;;; @ for mime-partial
10780 (defun gnus-request-partial-message ()
10782 (let ((number (gnus-summary-article-number))
10783 (group gnus-newsgroup-name)
10784 (mother gnus-article-buffer))
10785 (set-buffer (get-buffer-create " *Partial Article*"))
10787 (setq mime-preview-buffer mother)
10788 (gnus-request-article-this-buffer number group)
10789 (mime-parse-buffer)
10792 (autoload 'mime-combine-message/partial-pieces-automatically
10794 "Internal method to combine message/partial messages automatically.")
10796 (mime-add-condition
10797 'action '((type . message)(subtype . partial)
10798 (major-mode . gnus-original-article-mode)
10799 (method . mime-combine-message/partial-pieces-automatically)
10800 (summary-buffer-exp . gnus-summary-buffer)
10801 (request-partial-message-method . gnus-request-partial-message)
10805 ;;; @ for message/rfc822
10808 (defun gnus-mime-extract-message/rfc822 (entity situation)
10809 (let (group article num cwin swin cur)
10811 (mime-insert-entity-content entity)
10812 (setq group (or (cdr (assq 'group situation))
10813 (completing-read "Group: "
10816 (gnus-read-active-file-p)
10817 gnus-newsgroup-name))
10818 article (gnus-request-accept-article group)))
10819 (when (and (consp article)
10820 (numberp (setq article (cdr article))))
10821 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10822 cwin (get-buffer-window (current-buffer) t))
10823 (save-window-excursion
10824 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10825 (select-window swin)
10826 (set-buffer gnus-summary-buffer))
10827 (setq cur gnus-current-article)
10829 (let (gnus-show-threads)
10830 (gnus-summary-goto-subject article t))
10831 (gnus-summary-clear-mark-forward 1)
10832 (gnus-summary-goto-subject cur))
10833 (when (and cwin (window-frame cwin))
10834 (select-frame (window-frame cwin)))
10835 (when (boundp 'mime-acting-situation-to-override)
10836 (set-alist 'mime-acting-situation-to-override
10839 (set-alist 'mime-acting-situation-to-override
10842 (save-current-buffer
10843 (set-buffer gnus-group-buffer)
10844 (gnus-activate-group ,group))
10845 (gnus-summary-goto-article ,cur
10846 gnus-show-all-headers)))
10847 (set-alist 'mime-acting-situation-to-override
10850 (mime-add-condition
10851 'action '((type . message)(subtype . rfc822)
10852 (major-mode . gnus-original-article-mode)
10853 (method . gnus-mime-extract-message/rfc822)
10857 (mime-add-condition
10858 'action '((type . message)(subtype . news)
10859 (major-mode . gnus-original-article-mode)
10860 (method . gnus-mime-extract-message/rfc822)
10864 (defun gnus-mime-extract-multipart (entity situation)
10865 (let ((children (mime-entity-children entity))
10866 mime-acting-situation-to-override
10869 (mime-play-entity (car children)
10870 (cons (assq 'mode situation)
10871 mime-acting-situation-to-override))
10872 (setq children (cdr children)))
10873 (if (setq f (cdr (assq 'after-method
10874 mime-acting-situation-to-override)))
10878 (mime-add-condition
10879 'action '((type . multipart)
10880 (method . gnus-mime-extract-multipart)
10889 (defun gnus-summary-setup-default-charset ()
10890 "Setup newsgroup default charset."
10891 (if (equal gnus-newsgroup-name "nndraft:drafts")
10892 (setq gnus-newsgroup-charset nil)
10893 (let* ((ignored-charsets
10894 (or gnus-newsgroup-ephemeral-ignored-charsets
10896 (and gnus-newsgroup-name
10897 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10898 gnus-newsgroup-ignored-charsets))))
10899 (setq gnus-newsgroup-charset
10900 (or gnus-newsgroup-ephemeral-charset
10901 (and gnus-newsgroup-name
10902 (gnus-parameter-charset gnus-newsgroup-name))
10903 gnus-default-charset))
10904 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10905 ignored-charsets))))
10911 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10912 "Display the current article buffer fully MIME-buttonized.
10913 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10914 treated as multipart/mixed."
10916 (require 'gnus-art)
10917 (let ((gnus-unbuttonized-mime-types nil)
10918 (gnus-mime-display-multipart-as-mixed show-all-parts))
10919 (gnus-summary-show-article)))
10921 (defun gnus-summary-repair-multipart (article)
10922 "Add a Content-Type header to a multipart article without one."
10923 (interactive (list (gnus-summary-article-number)))
10924 (gnus-with-article article
10925 (message-narrow-to-head)
10926 (message-remove-header "Mime-Version")
10927 (goto-char (point-max))
10928 (insert "Mime-Version: 1.0\n")
10930 (when (search-forward "\n--" nil t)
10931 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10932 (message-narrow-to-head)
10933 (message-remove-header "Content-Type")
10934 (goto-char (point-max))
10935 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10938 (let (gnus-mark-article-hook)
10939 (gnus-summary-select-article t t nil article)))
10941 (defun gnus-summary-toggle-display-buttonized ()
10942 "Toggle the buttonizing of the article buffer."
10944 (require 'gnus-art)
10945 (if (setq gnus-inhibit-mime-unbuttonizing
10946 (not gnus-inhibit-mime-unbuttonizing))
10947 (let ((gnus-unbuttonized-mime-types nil))
10948 (gnus-summary-show-article))
10949 (gnus-summary-show-article)))
10952 ;;; Intelli-mouse commmands
10955 (defun gnus-wheel-summary-scroll (event)
10957 (let ((amount (if (memq 'shift (event-modifiers event))
10958 (car gnus-wheel-scroll-amount)
10959 (cdr gnus-wheel-scroll-amount)))
10960 (direction (- (* (static-if (featurep 'xemacs)
10961 (event-button event)
10962 (cond ((eq 'mouse-4 (event-basic-type event))
10964 ((eq 'mouse-5 (event-basic-type event))
10968 (gnus-summary-scroll-up (* amount direction))
10969 (when (gnus-eval-in-buffer-window gnus-article-buffer
10972 (and (if (< 0 direction)
10973 (gnus-article-next-page 0)
10974 (gnus-article-prev-page 0)
10976 (if (setq edge (get-text-property
10977 (point-min) 'gnus-wheel-edge))
10978 (setq edge (* edge direction))
10981 (let ((buffer-read-only nil)
10982 (inhibit-read-only t))
10983 (put-text-property (point-min) (point-max)
10984 'gnus-wheel-edge direction)
10986 (or (> edge gnus-wheel-edge-resistance)
10987 (let ((buffer-read-only nil)
10988 (inhibit-read-only t))
10989 (put-text-property (point-min) (point-max)
10991 (* (1+ edge) direction))
10993 (eq last-command 'gnus-wheel-summary-scroll))))
10994 (gnus-summary-next-article nil nil (minusp direction)))))
10996 (defun gnus-wheel-install ()
10997 "Enable mouse wheel support on summary window."
10998 (when gnus-use-wheel
11000 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11002 (define-key gnus-summary-mode-map key
11003 'gnus-wheel-summary-scroll)))))
11005 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11008 ;;; Traditional PGP commmands
11011 (defun gnus-summary-decrypt-article (&optional force)
11012 "Decrypt the current article in traditional PGP way.
11013 This will have permanent effect only in mail groups.
11014 If FORCE is non-nil, allow editing of articles even in read-only
11017 (gnus-summary-select-article t)
11018 (gnus-eval-in-buffer-window gnus-article-buffer
11022 (goto-char (point-min))
11023 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11024 (error "Not a traditional PGP message!"))
11025 (let ((armor-start (match-beginning 0)))
11026 (if (and (pgg-decrypt-region armor-start (point-max))
11027 (or force (not (gnus-group-read-only-p))))
11028 (let ((inhibit-read-only t)
11030 (delete-region armor-start
11032 (re-search-forward "^-+END PGP" nil t)
11033 (beginning-of-line 2)
11035 (insert-buffer-substring pgg-output-buffer))))))))
11037 (defun gnus-summary-verify-article ()
11038 "Verify the current article in traditional PGP way."
11041 (set-buffer gnus-original-article-buffer)
11042 (goto-char (point-min))
11043 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11044 (error "Not a traditional PGP message!"))
11045 (re-search-forward "^-+END PGP" nil t)
11046 (beginning-of-line 2)
11047 (call-interactively (function pgg-verify-region))))
11050 ;;; Generic summary marking commands
11053 (defvar gnus-summary-marking-alist
11054 '((read gnus-del-mark "d")
11055 (unread gnus-unread-mark "u")
11056 (ticked gnus-ticked-mark "!")
11057 (dormant gnus-dormant-mark "?")
11058 (expirable gnus-expirable-mark "e"))
11059 "An alist of names/marks/keystrokes.")
11061 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11062 (defvar gnus-summary-mark-map)
11064 (defun gnus-summary-make-all-marking-commands ()
11065 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11066 (dolist (elem gnus-summary-marking-alist)
11067 (apply 'gnus-summary-make-marking-command elem)))
11069 (defun gnus-summary-make-marking-command (name mark keystroke)
11070 (let ((map (make-sparse-keymap)))
11071 (define-key gnus-summary-generic-mark-map keystroke map)
11072 (dolist (lway `((next "next" next nil "n")
11073 (next-unread "next unread" next t "N")
11074 (prev "previous" prev nil "p")
11075 (prev-unread "previous unread" prev t "P")
11076 (nomove "" nil nil ,keystroke)))
11077 (let ((func (gnus-summary-make-marking-command-1
11078 mark (car lway) lway name)))
11079 (setq func (eval func))
11080 (define-key map (nth 4 lway) func)))))
11082 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11084 (format "gnus-summary-put-mark-as-%s%s"
11085 name (if (eq way 'nomove)
11087 (concat "-" (symbol-name way)))))
11090 "Mark the current article as %s%s.
11091 If N, the prefix, then repeat N times.
11092 If N is negative, move in reverse order.
11093 The difference between N and the actual number of articles marked is
11095 name (car (cdr lway)))
11097 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11099 (defun gnus-summary-generic-mark (n mark move unread)
11100 "Mark N articles with MARK."
11101 (unless (eq major-mode 'gnus-summary-mode)
11102 (error "This command can only be used in the summary buffer"))
11103 (gnus-summary-show-thread)
11106 ((eq move 'next) 1)
11107 ((eq move 'prev) -1)
11109 (if (zerop nummove)
11113 nummove (* -1 nummove))))
11114 (while (and (> n 0)
11115 (gnus-summary-mark-article nil mark)
11116 (zerop (gnus-summary-next-subject nummove unread t)))
11119 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11120 (gnus-summary-recenter)
11121 (gnus-summary-position-point)
11122 (gnus-set-mode-line 'summary)
11125 (defun gnus-summary-insert-articles (articles)
11126 (when (setq articles
11127 (gnus-set-difference articles
11128 (mapcar (lambda (h) (mail-header-number h))
11129 gnus-newsgroup-headers)))
11130 (setq gnus-newsgroup-headers
11132 gnus-newsgroup-headers
11133 (gnus-fetch-headers articles)
11134 'gnus-article-sort-by-number))
11135 ;; Suppress duplicates?
11136 (when gnus-suppress-duplicates
11137 (gnus-dup-suppress-articles))
11139 ;; We might want to build some more threads first.
11140 (when (and gnus-fetch-old-headers
11141 (eq gnus-headers-retrieved-by 'nov))
11142 (if (eq gnus-fetch-old-headers 'invisible)
11143 (gnus-build-all-threads)
11144 (gnus-build-old-threads)))
11145 ;; Let the Gnus agent mark articles as read.
11147 (gnus-agent-get-undownloaded-list))
11148 ;; Remove list identifiers from subject
11149 (when gnus-list-identifiers
11150 (gnus-summary-remove-list-identifiers))
11151 ;; First and last article in this newsgroup.
11152 (when gnus-newsgroup-headers
11153 (setq gnus-newsgroup-begin
11154 (mail-header-number (car gnus-newsgroup-headers))
11156 (mail-header-number
11157 (gnus-last-element gnus-newsgroup-headers))))
11158 (when gnus-use-scoring
11159 (gnus-possibly-score-headers))))
11161 (defun gnus-summary-insert-old-articles (&optional all)
11162 "Insert all old articles in this group.
11163 If ALL is non-nil, already read articles become readable.
11164 If ALL is a number, fetch this number of articles."
11167 (let ((old (mapcar 'car gnus-newsgroup-data))
11168 (i (car gnus-newsgroup-active))
11170 (while (<= i (cdr gnus-newsgroup-active))
11171 (or (memq i old) (push i older))
11173 (setq len (length older))
11178 (setq older (subseq older 0 all))))
11181 (if (and (numberp gnus-large-newsgroup)
11182 (> len gnus-large-newsgroup))
11186 "How many articles from %s (default %d): "
11188 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11190 (unless (string-match "^[ \t]*$" input)
11191 (setq all (string-to-number input))
11193 (setq older (subseq older 0 all))))))))
11195 (message "No old news.")
11196 (let ((gnus-fetch-old-headers t))
11197 (gnus-summary-insert-articles older))
11198 (gnus-summary-limit (gnus-union older old))))
11199 (gnus-summary-position-point)))
11201 (defun gnus-summary-insert-new-articles ()
11202 "Insert all new articles in this group."
11205 (let ((old (mapcar 'car gnus-newsgroup-data))
11206 (old-active gnus-newsgroup-active)
11207 (nnmail-fetched-sources (list t))
11209 (setq gnus-newsgroup-active
11210 (gnus-activate-group gnus-newsgroup-name 'scan))
11211 (setq i (1+ (cdr old-active)))
11212 (while (<= i (cdr gnus-newsgroup-active))
11216 (message "No gnus is bad news.")
11217 (setq new (nreverse new))
11218 (gnus-summary-insert-articles new)
11219 (setq gnus-newsgroup-unreads
11220 (append gnus-newsgroup-unreads new))
11221 (gnus-summary-limit (gnus-union old new))))
11222 (gnus-summary-position-point)))
11224 (gnus-summary-make-all-marking-commands)
11226 (gnus-ems-redefine)
11228 (provide 'gnus-sum)
11230 (run-hooks 'gnus-sum-load-hook)
11232 ;;; gnus-sum.el ends here