1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
42 (autoload 'gnus-cache-write-active "gnus-cache")
43 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
44 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
47 (defcustom gnus-kill-summary-on-exit t
48 "*If non-nil, kill the summary buffer when you exit from it.
49 If nil, the summary will become a \"*Dead Summary*\" buffer, and
50 it will be killed sometime later."
51 :group 'gnus-summary-exit
54 (defcustom gnus-fetch-old-headers nil
55 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
56 If an unread article in the group refers to an older, already read (or
57 just marked as read) article, the old article will not normally be
58 displayed in the Summary buffer. If this variable is non-nil, Gnus
59 will attempt to grab the headers to the old articles, and thereby
60 build complete threads. If it has the value `some', only enough
61 headers to connect otherwise loose threads will be displayed. This
62 variable can also be a number. In that case, no more than that number
63 of old headers will be fetched. If it has the value `invisible', all
64 old headers will be fetched, but none will be displayed.
66 The server has to support NOV for any of this to work."
68 :type '(choice (const :tag "off" nil)
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-refer-thread-limit 200
74 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
75 If t, fetch all the available old headers."
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-summary-make-false-root 'adopt
81 "*nil means that Gnus won't gather loose threads.
82 If the root of a thread has expired or been read in a previous
83 session, the information necessary to build a complete thread has been
84 lost. Instead of having many small sub-threads from this original thread
85 scattered all over the summary buffer, Gnus can gather them.
87 If non-nil, Gnus will try to gather all loose sub-threads from an
88 original thread into one large thread.
90 If this variable is non-nil, it should be one of `none', `adopt',
93 If this variable is `none', Gnus will not make a false root, but just
94 present the sub-threads after another.
95 If this variable is `dummy', Gnus will create a dummy root that will
96 have all the sub-threads as children.
97 If this variable is `adopt', Gnus will make one of the \"children\"
98 the parent and mark all the step-children as such.
99 If this variable is `empty', the \"children\" are printed with empty
100 subject fields. (Or rather, they will be printed with a string
101 given by the `gnus-summary-same-subject' variable.)"
103 :type '(choice (const :tag "off" nil)
109 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
110 "*A regexp to match subjects to be excluded from loose thread gathering.
111 As loose thread gathering is done on subjects only, that means that
112 there can be many false gatherings performed. By rooting out certain
113 common subjects, gathering might become saner."
117 (defcustom gnus-summary-gather-subject-limit nil
118 "*Maximum length of subject comparisons when gathering loose threads.
119 Use nil to compare full subjects. Setting this variable to a low
120 number will help gather threads that have been corrupted by
121 newsreaders chopping off subject lines, but it might also mean that
122 unrelated articles that have subject that happen to begin with the
123 same few characters will be incorrectly gathered.
125 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
128 :type '(choice (const :tag "off" nil)
130 (sexp :menu-tag "on" t)))
132 (defcustom gnus-simplify-subject-functions nil
133 "List of functions taking a string argument that simplify subjects.
134 The functions are applied recursively.
136 Useful functions to put in this list include: `gnus-simplify-subject-re',
137 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
139 :type '(repeat function))
141 (defcustom gnus-simplify-ignored-prefixes nil
142 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
144 :type '(choice (const :tag "off" nil)
147 (defcustom gnus-build-sparse-threads nil
148 "*If non-nil, fill in the gaps in threads.
149 If `some', only fill in the gaps that are needed to tie loose threads
150 together. If `more', fill in all leaf nodes that Gnus can find. If
151 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
153 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "all" t)))
158 (defcustom gnus-summary-thread-gathering-function
159 'gnus-gather-threads-by-subject
160 "*Function used for gathering loose threads.
161 There are two pre-defined functions: `gnus-gather-threads-by-subject',
162 which only takes Subjects into consideration; and
163 `gnus-gather-threads-by-references', which compared the References
164 headers of the articles to find matches."
166 :type '(radio (function-item gnus-gather-threads-by-subject)
167 (function-item gnus-gather-threads-by-references)
168 (function :tag "other")))
170 (defcustom gnus-summary-same-subject ""
171 "*String indicating that the current article has the same subject as the previous.
172 This variable will only be used if the value of
173 `gnus-summary-make-false-root' is `empty'."
174 :group 'gnus-summary-format
177 (defcustom gnus-summary-goto-unread t
178 "*If t, many commands will go to the next unread article.
179 This applies to marking commands as well as other commands that
180 \"naturally\" select the next article, like, for instance, `SPC' at
181 the end of an article.
183 If nil, the marking commands do NOT go to the next unread article
184 (they go to the next article instead). If `never', commands that
185 usually go to the next unread article, will go to the next article,
186 whether it is read or not."
187 :group 'gnus-summary-marks
188 :link '(custom-manual "(gnus)Setting Marks")
189 :type '(choice (const :tag "off" nil)
191 (sexp :menu-tag "on" t)))
193 (defcustom gnus-summary-default-score 0
194 "*Default article score level.
195 All scores generated by the score files will be added to this score.
196 If this variable is nil, scoring will be disabled."
197 :group 'gnus-score-default
198 :type '(choice (const :tag "disable")
201 (defcustom gnus-summary-default-high-score 0
202 "*Default threshold for a high scored article.
203 An article will be highlighted as high scored if its score is greater
205 :group 'gnus-score-default
208 (defcustom gnus-summary-default-low-score 0
209 "*Default threshold for a low scored article.
210 An article will be highlighted as low scored if its score is smaller
212 :group 'gnus-score-default
215 (defcustom gnus-summary-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 This can be a predicate specifier which says which threads to hide.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If non-nil, select the article under point.
282 Which article this is is controlled by the `gnus-auto-select-subject'
285 If you want to prevent automatic selection of articles in some
286 newsgroups, set the variable to nil in `gnus-select-group-hook'."
287 :group 'gnus-group-select
288 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)))
291 (defcustom gnus-auto-select-subject 'unread
292 "*Says what subject to place under point when entering a group.
294 This variable can either be the symbols `first' (place point on the
295 first subject), `unread' (place point on the subject line of the first
296 unread article), `best' (place point on the subject line of the
297 higest-scored article), `unseen' (place point on the subject line of
298 the first unseen article), 'unseen-or-unread' (place point on the subject
299 line of the first unseen article or, if all article have been seen, on the
300 subject line of the first unread article), or a function to be called to
301 place point on some subject line.."
302 :group 'gnus-group-select
303 :type '(choice (const best)
307 (const unseen-or-unread)))
309 (defcustom gnus-auto-select-next t
310 "*If non-nil, offer to go to the next group from the end of the previous.
311 If the value is t and the next newsgroup is empty, Gnus will exit
312 summary mode and go back to group mode. If the value is neither nil
313 nor t, Gnus will select the following unread newsgroup. In
314 particular, if the value is the symbol `quietly', the next unread
315 newsgroup will be selected without any confirmation, and if it is
316 `almost-quietly', the next group will be selected without any
317 confirmation if you are located on the last article in the group.
318 Finally, if this variable is `slightly-quietly', the `Z n' command
319 will go to the next group without confirmation."
320 :group 'gnus-summary-maneuvering
321 :type '(choice (const :tag "off" nil)
323 (const almost-quietly)
324 (const slightly-quietly)
325 (sexp :menu-tag "on" t)))
327 (defcustom gnus-auto-select-same nil
328 "*If non-nil, select the next article with the same subject.
329 If there are no more articles with the same subject, go to
330 the first unread article."
331 :group 'gnus-summary-maneuvering
334 (defcustom gnus-summary-check-current nil
335 "*If non-nil, consider the current article when moving.
336 The \"unread\" movement commands will stay on the same line if the
337 current article is unread."
338 :group 'gnus-summary-maneuvering
341 (defcustom gnus-auto-center-summary t
342 "*If non-nil, always center the current summary buffer.
343 In particular, if `vertical' do only vertical recentering. If non-nil
344 and non-`vertical', do both horizontal and vertical recentering."
345 :group 'gnus-summary-maneuvering
346 :type '(choice (const :tag "none" nil)
348 (integer :tag "height")
349 (sexp :menu-tag "both" t)))
351 (defcustom gnus-show-all-headers nil
352 "*If non-nil, don't hide any headers."
353 :group 'gnus-article-hiding
354 :group 'gnus-article-headers
357 (defcustom gnus-summary-ignore-duplicates nil
358 "*If non-nil, ignore articles with identical Message-ID headers."
362 (defcustom gnus-single-article-buffer t
363 "*If non-nil, display all articles in the same buffer.
364 If nil, each group will get its own article buffer."
365 :group 'gnus-article-various
368 (defcustom gnus-break-pages t
369 "*If non-nil, do page breaking on articles.
370 The page delimiter is specified by the `gnus-page-delimiter'
372 :group 'gnus-article-various
375 (defcustom gnus-move-split-methods nil
376 "*Variable used to suggest where articles are to be moved to.
377 It uses the same syntax as the `gnus-split-methods' variable.
378 However, whereas `gnus-split-methods' specifies file names as targets,
379 this variable specifies group names."
380 :group 'gnus-summary-mail
381 :type '(repeat (choice (list :value (fun) function)
382 (cons :value ("" "") regexp (repeat string))
385 (defcustom gnus-unread-mark ? ;Whitespace
386 "*Mark used for unread articles."
387 :group 'gnus-summary-marks
390 (defcustom gnus-ticked-mark ?!
391 "*Mark used for ticked articles."
392 :group 'gnus-summary-marks
395 (defcustom gnus-dormant-mark ??
396 "*Mark used for dormant articles."
397 :group 'gnus-summary-marks
400 (defcustom gnus-del-mark ?r
401 "*Mark used for del'd articles."
402 :group 'gnus-summary-marks
405 (defcustom gnus-read-mark ?R
406 "*Mark used for read articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-expirable-mark ?E
411 "*Mark used for expirable articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-killed-mark ?K
416 "*Mark used for killed articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-souped-mark ?F
421 "*Mark used for souped articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-kill-file-mark ?X
426 "*Mark used for articles killed by kill files."
427 :group 'gnus-summary-marks
430 (defcustom gnus-low-score-mark ?Y
431 "*Mark used for articles with a low score."
432 :group 'gnus-summary-marks
435 (defcustom gnus-catchup-mark ?C
436 "*Mark used for articles that are caught up."
437 :group 'gnus-summary-marks
440 (defcustom gnus-replied-mark ?A
441 "*Mark used for articles that have been replied to."
442 :group 'gnus-summary-marks
445 (defcustom gnus-forwarded-mark ?F
446 "*Mark used for articles that have been forwarded."
447 :group 'gnus-summary-marks
450 (defcustom gnus-recent-mark ?N
451 "*Mark used for articles that are recent."
452 :group 'gnus-summary-marks
455 (defcustom gnus-cached-mark ?*
456 "*Mark used for articles that are in the cache."
457 :group 'gnus-summary-marks
460 (defcustom gnus-saved-mark ?S
461 "*Mark used for articles that have been saved."
462 :group 'gnus-summary-marks
465 (defcustom gnus-unseen-mark ?.
466 "*Mark used for articles that haven't been seen."
467 :group 'gnus-summary-marks
470 (defcustom gnus-no-mark ? ;Whitespace
471 "*Mark used for articles that have no other secondary mark."
472 :group 'gnus-summary-marks
475 (defcustom gnus-ancient-mark ?O
476 "*Mark used for ancient articles."
477 :group 'gnus-summary-marks
480 (defcustom gnus-sparse-mark ?Q
481 "*Mark used for sparsely reffed articles."
482 :group 'gnus-summary-marks
485 (defcustom gnus-canceled-mark ?G
486 "*Mark used for canceled articles."
487 :group 'gnus-summary-marks
490 (defcustom gnus-duplicate-mark ?M
491 "*Mark used for duplicate articles."
492 :group 'gnus-summary-marks
495 (defcustom gnus-undownloaded-mark ?@
496 "*Mark used for articles that weren't downloaded."
497 :group 'gnus-summary-marks
500 (defcustom gnus-downloadable-mark ?%
501 "*Mark used for articles that are to be downloaded."
502 :group 'gnus-summary-marks
505 (defcustom gnus-unsendable-mark ?=
506 "*Mark used for articles that won't be sent."
507 :group 'gnus-summary-marks
510 (defcustom gnus-score-over-mark ?+
511 "*Score mark used for articles with high scores."
512 :group 'gnus-summary-marks
515 (defcustom gnus-score-below-mark ?-
516 "*Score mark used for articles with low scores."
517 :group 'gnus-summary-marks
520 (defcustom gnus-empty-thread-mark ? ;Whitespace
521 "*There is no thread under the article."
522 :group 'gnus-summary-marks
525 (defcustom gnus-not-empty-thread-mark ?=
526 "*There is a thread under the article."
527 :group 'gnus-summary-marks
530 (defcustom gnus-view-pseudo-asynchronously nil
531 "*If non-nil, Gnus will view pseudo-articles asynchronously."
532 :group 'gnus-extract-view
535 (defcustom gnus-auto-expirable-marks
536 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
537 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
538 gnus-souped-mark gnus-duplicate-mark)
539 "*The list of marks converted into expiration if a group is auto-expirable."
542 :type '(repeat character))
544 (defcustom gnus-inhibit-user-auto-expire t
545 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
550 (defcustom gnus-view-pseudos nil
551 "*If `automatic', pseudo-articles will be viewed automatically.
552 If `not-confirm', pseudos will be viewed automatically, and the user
553 will not be asked to confirm the command."
554 :group 'gnus-extract-view
555 :type '(choice (const :tag "off" nil)
557 (const not-confirm)))
559 (defcustom gnus-view-pseudos-separately t
560 "*If non-nil, one pseudo-article will be created for each file to be viewed.
561 If nil, all files that use the same viewing command will be given as a
562 list of parameters to that command."
563 :group 'gnus-extract-view
566 (defcustom gnus-insert-pseudo-articles t
567 "*If non-nil, insert pseudo-articles when decoding articles."
568 :group 'gnus-extract-view
571 (defcustom gnus-summary-dummy-line-format
573 "*The format specification for the dummy roots in the summary buffer.
574 It works along the same lines as a normal formatting string,
575 with some simple extensions.
579 General format specifiers can also be used.
580 See (gnus)Formatting Variables."
581 :link '(custom-manual "(gnus)Formatting Variables")
582 :group 'gnus-threading
585 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
586 "*The format specification for the summary mode line.
587 It works along the same lines as a normal formatting string,
588 with some simple extensions:
591 %p Unprefixed group name
592 %A Current article number
593 %z Current article score
595 %U Number of unread articles in the group
596 %e Number of unselected articles in the group
597 %Z A string with unread/unselected article counts
598 %g Shortish group name
599 %S Subject of the current article
601 %s Current score file name
602 %d Number of dormant articles
603 %r Number of articles that have been marked as read in this session
604 %E Number of articles expunged by the score files"
605 :group 'gnus-summary-format
608 (defcustom gnus-list-identifiers nil
609 "Regexp that matches list identifiers to be removed from subject.
610 This can also be a list of regexps."
612 :group 'gnus-summary-format
613 :group 'gnus-article-hiding
614 :type '(choice (const :tag "none" nil)
616 (repeat :value (".*") regexp)))
618 (defcustom gnus-summary-mark-below 0
619 "*Mark all articles with a score below this variable as read.
620 This variable is local to each summary buffer and usually set by the
622 :group 'gnus-score-default
625 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
626 "*List of functions used for sorting articles in the summary buffer.
628 Each function takes two articles and returns non-nil if the first
629 article should be sorted before the other. If you use more than one
630 function, the primary sort function should be the last. You should
631 probably always include `gnus-article-sort-by-number' in the list of
632 sorting functions -- preferably first. Also note that sorting by date
633 is often much slower than sorting by number, and the sorting order is
634 very similar. (Sorting by date means sorting by the time the message
635 was sent, sorting by number means sorting by arrival time.)
637 Ready-made functions include `gnus-article-sort-by-number',
638 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
639 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
641 When threading is turned on, the variable `gnus-thread-sort-functions'
642 controls how articles are sorted."
643 :group 'gnus-summary-sort
644 :type '(repeat (choice (function-item gnus-article-sort-by-number)
645 (function-item gnus-article-sort-by-author)
646 (function-item gnus-article-sort-by-subject)
647 (function-item gnus-article-sort-by-date)
648 (function-item gnus-article-sort-by-score)
649 (function :tag "other"))))
651 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
652 "*List of functions used for sorting threads in the summary buffer.
653 By default, threads are sorted by article number.
655 Each function takes two threads and returns non-nil if the first
656 thread 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-thread-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-thread-sort-by-number',
665 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
666 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
667 `gnus-thread-sort-by-most-recent-number',
668 `gnus-thread-sort-by-most-recent-date', and
669 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
671 When threading is turned off, the variable
672 `gnus-article-sort-functions' controls how articles are sorted."
673 :group 'gnus-summary-sort
674 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
675 (function-item gnus-thread-sort-by-author)
676 (function-item gnus-thread-sort-by-subject)
677 (function-item gnus-thread-sort-by-date)
678 (function-item gnus-thread-sort-by-score)
679 (function-item gnus-thread-sort-by-total-score)
680 (function :tag "other"))))
682 (defcustom gnus-thread-score-function '+
683 "*Function used for calculating the total score of a thread.
685 The function is called with the scores of the article and each
686 subthread and should then return the score of the thread.
688 Some functions you can use are `+', `max', or `min'."
689 :group 'gnus-summary-sort
692 (defcustom gnus-summary-expunge-below nil
693 "All articles that have a score less than this variable will be expunged.
694 This variable is local to the summary buffers."
695 :group 'gnus-score-default
696 :type '(choice (const :tag "off" nil)
699 (defcustom gnus-thread-expunge-below nil
700 "All threads that have a total score less than this variable will be expunged.
701 See `gnus-thread-score-function' for en explanation of what a
704 This variable is local to the summary buffers."
705 :group 'gnus-threading
706 :group 'gnus-score-default
707 :type '(choice (const :tag "off" nil)
710 (defcustom gnus-summary-mode-hook nil
711 "*A hook for Gnus summary mode.
712 This hook is run before any variables are set in the summary buffer."
713 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
714 :group 'gnus-summary-various
717 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
718 (when (featurep 'xemacs)
719 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
720 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
721 (add-hook 'gnus-summary-mode-hook
722 'gnus-xmas-switch-horizontal-scrollbar-off))
724 (defcustom gnus-summary-menu-hook nil
725 "*Hook run after the creation of the summary mode menu."
726 :group 'gnus-summary-visual
729 (defcustom gnus-summary-exit-hook nil
730 "*A hook called on exit from the summary buffer.
731 It will be called with point in the group buffer."
732 :group 'gnus-summary-exit
735 (defcustom gnus-summary-prepare-hook nil
736 "*A hook called after the summary buffer has been generated.
737 If you want to modify the summary buffer, you can use this hook."
738 :group 'gnus-summary-various
741 (defcustom gnus-summary-prepared-hook nil
742 "*A hook called as the last thing after the summary buffer has been generated."
743 :group 'gnus-summary-various
746 (defcustom gnus-summary-generate-hook nil
747 "*A hook run just before generating the summary buffer.
748 This hook is commonly used to customize threading variables and the
750 :group 'gnus-summary-various
753 (defcustom gnus-select-group-hook nil
754 "*A hook called when a newsgroup is selected.
756 If you'd like to simplify subjects like the
757 `gnus-summary-next-same-subject' command does, you can use the
760 (add-hook gnus-select-group-hook
762 (mapcar (lambda (header)
763 (mail-header-set-subject
765 (gnus-simplify-subject
766 (mail-header-subject header) 're-only)))
767 gnus-newsgroup-headers)))"
768 :group 'gnus-group-select
771 (defcustom gnus-select-article-hook nil
772 "*A hook called when an article is selected."
773 :group 'gnus-summary-choose
776 (defcustom gnus-visual-mark-article-hook
777 (list 'gnus-highlight-selected-summary)
778 "*Hook run after selecting an article in the summary buffer.
779 It is meant to be used for highlighting the article in some way. It
780 is not run if `gnus-visual' is nil."
781 :group 'gnus-summary-visual
784 (defcustom gnus-parse-headers-hook nil
785 "*A hook called before parsing the headers."
789 (defcustom gnus-exit-group-hook nil
790 "*A hook called when exiting summary mode.
791 This hook is not called from the non-updating exit commands like `Q'."
795 (defcustom gnus-summary-update-hook
796 (list 'gnus-summary-highlight-line)
797 "*A hook called when a summary line is changed.
798 The hook will not be called if `gnus-visual' is nil.
800 The default function `gnus-summary-highlight-line' will
801 highlight the line according to the `gnus-summary-highlight'
803 :group 'gnus-summary-visual
806 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
807 "*A hook called when an article is selected for the first time.
808 The hook is intended to mark an article as read (or unread)
809 automatically when it is selected."
810 :group 'gnus-summary-choose
813 (defcustom gnus-group-no-more-groups-hook nil
814 "*A hook run when returning to group mode having no more (unread) groups."
815 :group 'gnus-group-select
818 (defcustom gnus-ps-print-hook nil
819 "*A hook run before ps-printing something from Gnus."
823 (defcustom gnus-summary-display-arrow
824 (and (fboundp 'display-graphic-p)
826 "*If non-nil, display an arrow highlighting the current article."
831 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
832 "Face used for highlighting the current article in the summary buffer."
833 :group 'gnus-summary-visual
836 (defcustom gnus-summary-highlight
837 '(((= mark gnus-canceled-mark)
838 . gnus-summary-cancelled-face)
839 ((and (> score default-high)
840 (or (= mark gnus-dormant-mark)
841 (= mark gnus-ticked-mark)))
842 . gnus-summary-high-ticked-face)
843 ((and (< score default-low)
844 (or (= mark gnus-dormant-mark)
845 (= mark gnus-ticked-mark)))
846 . gnus-summary-low-ticked-face)
847 ((or (= mark gnus-dormant-mark)
848 (= mark gnus-ticked-mark))
849 . gnus-summary-normal-ticked-face)
850 ((and (> score default-high) (= mark gnus-ancient-mark))
851 . gnus-summary-high-ancient-face)
852 ((and (< score default-low) (= mark gnus-ancient-mark))
853 . gnus-summary-low-ancient-face)
854 ((= mark gnus-ancient-mark)
855 . gnus-summary-normal-ancient-face)
856 ((and (> score default-high) (= mark gnus-unread-mark))
857 . gnus-summary-high-unread-face)
858 ((and (< score default-low) (= mark gnus-unread-mark))
859 . gnus-summary-low-unread-face)
860 ((= mark gnus-unread-mark)
861 . gnus-summary-normal-unread-face)
862 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
863 gnus-undownloaded-mark)))
864 . gnus-summary-high-unread-face)
865 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
866 gnus-undownloaded-mark)))
867 . gnus-summary-low-unread-face)
868 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
869 (memq article gnus-newsgroup-unreads))
870 . gnus-summary-normal-unread-face)
871 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
872 . gnus-summary-normal-read-face)
873 ((> score default-high)
874 . gnus-summary-high-read-face)
875 ((< score default-low)
876 . gnus-summary-low-read-face)
878 . gnus-summary-normal-read-face))
879 "*Controls the highlighting of summary buffer lines.
881 A list of (FORM . FACE) pairs. When deciding how a a particular
882 summary line should be displayed, each form is evaluated. The content
883 of the face field after the first true form is used. You can change
884 how those summary lines are displayed, by editing the face field.
886 You can use the following variables in the FORM field.
888 score: The article's score
889 default: The default article score.
890 default-high: The default score for high scored articles.
891 default-low: The default score for low scored articles.
892 below: The score below which articles are automatically marked as read.
893 mark: The articles mark."
894 :group 'gnus-summary-visual
895 :type '(repeat (cons (sexp :tag "Form" nil)
898 (defcustom gnus-alter-header-function nil
899 "Function called to allow alteration of article header structures.
900 The function is called with one parameter, the article header vector,
901 which it may alter in any way.")
903 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
904 "Variable that says which function should be used to decode a string with encoded words.")
906 (defcustom gnus-extra-headers '(To Newsgroups)
907 "*Extra headers to parse."
910 :type '(repeat symbol))
912 (defcustom gnus-ignored-from-addresses
913 (and user-mail-address (regexp-quote user-mail-address))
914 "*Regexp of From headers that may be suppressed in favor of To headers."
919 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
920 "List of charsets that should be ignored.
921 When these charsets are used in the \"charset\" parameter, the
922 default charset will be used instead."
924 :type '(repeat symbol)
925 :group 'gnus-charset)
927 (gnus-define-group-parameter
931 "Return the ignored charsets of GROUP."
932 :variable gnus-group-ignored-charsets-alist
934 '(("alt\\.chinese\\.text" iso-8859-1))
936 "Alist of regexps (to match group names) and charsets that should be ignored.
937 When these charsets are used in the \"charset\" parameter, the
938 default charset will be used instead."
939 :variable-group gnus-charset
940 :variable-type '(repeat (cons (regexp :tag "Group")
942 :parameter-type '(choice :tag "Ignored charsets"
945 :parameter-document "\
946 List of charsets that should be ignored.
948 When these charsets are used in the \"charset\" parameter, the
949 default charset will be used instead.")
951 (defcustom gnus-group-highlight-words-alist nil
952 "Alist of group regexps and highlight regexps.
953 This variable uses the same syntax as `gnus-emphasis-alist'."
955 :type '(repeat (cons (regexp :tag "Group")
956 (repeat (list (regexp :tag "Highlight regexp")
957 (number :tag "Group for entire word" 0)
958 (number :tag "Group for displayed part" 0)
960 gnus-emphasis-highlight-words)))))
961 :group 'gnus-summary-visual)
963 (defcustom gnus-summary-show-article-charset-alist
965 "Alist of number and charset.
966 The article will be shown with the charset corresponding to the
968 For example: ((1 . cn-gb-2312) (2 . big5))."
970 :type '(repeat (cons (number :tag "Argument" 1)
971 (symbol :tag "Charset")))
972 :group 'gnus-charset)
974 (defcustom gnus-preserve-marks t
975 "Whether marks are preserved when moving, copying and respooling messages."
978 :group 'gnus-summary-marks)
980 (defcustom gnus-alter-articles-to-read-function nil
981 "Function to be called to alter the list of articles to be selected."
982 :type '(choice (const nil) function)
983 :group 'gnus-summary)
985 (defcustom gnus-orphan-score nil
986 "*All orphans get this score added. Set in the score file."
987 :group 'gnus-score-default
988 :type '(choice (const nil)
991 (defcustom gnus-summary-save-parts-default-mime "image/.*"
992 "*A regexp to match MIME parts when saving multiple parts of a message
993 with gnus-summary-save-parts (X m). This regexp will be used by default
994 when prompting the user for which type of files to save."
999 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1000 "*A regexp to match MIME parts when saving multiple parts of a message
1001 with gnus-summary-save-parts (X m). This regexp will be used by default
1002 when prompting the user for which type of files to save."
1003 :group 'gnus-summary
1006 (defcustom gnus-read-all-available-headers nil
1007 "Whether Gnus should parse all headers made available to it.
1008 This is mostly relevant for slow backends where the user may
1009 wish to widen the summary buffer to include all headers
1010 that were fetched. Say, for nnultimate groups."
1011 :group 'gnus-summary
1012 :type '(choice boolean regexp))
1014 (defcustom gnus-summary-muttprint-program "muttprint"
1015 "Command (and optional arguments) used to run Muttprint."
1016 :group 'gnus-summary
1019 ;;; Internal variables
1021 (defvar gnus-summary-display-cache nil)
1022 (defvar gnus-article-mime-handles nil)
1023 (defvar gnus-article-decoded-p nil)
1024 (defvar gnus-article-charset nil)
1025 (defvar gnus-article-ignored-charsets nil)
1026 (defvar gnus-scores-exclude-files nil)
1027 (defvar gnus-page-broken nil)
1028 (defvar gnus-inhibit-mime-unbuttonizing nil)
1030 (defvar gnus-original-article nil)
1031 (defvar gnus-article-internal-prepare-hook nil)
1032 (defvar gnus-newsgroup-process-stack nil)
1034 (defvar gnus-thread-indent-array nil)
1035 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1036 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1037 "Function called to sort the articles within a thread after it has been gathered together.")
1039 (defvar gnus-summary-save-parts-type-history nil)
1040 (defvar gnus-summary-save-parts-last-directory nil)
1042 (defvar gnus-summary-save-parts-type-history nil)
1043 (defvar gnus-summary-save-parts-last-directory nil)
1045 ;; Avoid highlighting in kill files.
1046 (defvar gnus-summary-inhibit-highlight nil)
1047 (defvar gnus-newsgroup-selected-overlay nil)
1048 (defvar gnus-inhibit-limiting nil)
1049 (defvar gnus-newsgroup-adaptive-score-file nil)
1050 (defvar gnus-current-score-file nil)
1051 (defvar gnus-current-move-group nil)
1052 (defvar gnus-current-copy-group nil)
1053 (defvar gnus-current-crosspost-group nil)
1054 (defvar gnus-newsgroup-display nil)
1056 (defvar gnus-newsgroup-dependencies nil)
1057 (defvar gnus-newsgroup-adaptive nil)
1058 (defvar gnus-summary-display-article-function nil)
1059 (defvar gnus-summary-highlight-line-function nil
1060 "Function called after highlighting a summary line.")
1062 (defvar gnus-summary-line-format-alist
1063 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1064 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1065 (?s gnus-tmp-subject-or-nil ?s)
1066 (?n gnus-tmp-name ?s)
1067 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1069 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1071 (?F gnus-tmp-from ?s)
1072 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1073 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1074 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1075 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1076 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1077 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1078 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1079 (?L gnus-tmp-lines ?s)
1080 (?I gnus-tmp-indentation ?s)
1081 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1082 (?R gnus-tmp-replied ?c)
1083 (?\[ gnus-tmp-opening-bracket ?c)
1084 (?\] gnus-tmp-closing-bracket ?c)
1085 (?\> (make-string gnus-tmp-level ? ) ?s)
1086 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1087 (?i gnus-tmp-score ?d)
1088 (?z gnus-tmp-score-char ?c)
1089 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1090 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1091 (?U gnus-tmp-unread ?c)
1092 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1094 (?t (gnus-summary-number-of-articles-in-thread
1095 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1097 (?e (gnus-summary-number-of-articles-in-thread
1098 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1100 (?u gnus-tmp-user-defined ?s)
1101 (?P (gnus-pick-line-number) ?d)
1102 (?B gnus-tmp-thread-tree-header-string ?s)
1103 (user-date (gnus-user-date
1104 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1105 "An alist of format specifications that can appear in summary lines.
1106 These are paired with what variables they correspond with, along with
1107 the type of the variable (string, integer, character, etc).")
1109 (defvar gnus-summary-dummy-line-format-alist
1110 `((?S gnus-tmp-subject ?s)
1111 (?N gnus-tmp-number ?d)
1112 (?u gnus-tmp-user-defined ?s)))
1114 (defvar gnus-summary-mode-line-format-alist
1115 `((?G gnus-tmp-group-name ?s)
1116 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1117 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1118 (?A gnus-tmp-article-number ?d)
1119 (?Z gnus-tmp-unread-and-unselected ?s)
1120 (?V gnus-version ?s)
1121 (?U gnus-tmp-unread-and-unticked ?d)
1122 (?S gnus-tmp-subject ?s)
1123 (?e gnus-tmp-unselected ?d)
1124 (?u gnus-tmp-user-defined ?s)
1125 (?d (length gnus-newsgroup-dormant) ?d)
1126 (?t (length gnus-newsgroup-marked) ?d)
1127 (?r (length gnus-newsgroup-reads) ?d)
1128 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1129 (?E gnus-newsgroup-expunged-tally ?d)
1130 (?s (gnus-current-score-file-nondirectory) ?s)))
1132 (defvar gnus-last-search-regexp nil
1133 "Default regexp for article search command.")
1135 (defvar gnus-last-shell-command nil
1136 "Default shell command on article.")
1138 (defvar gnus-newsgroup-begin nil)
1139 (defvar gnus-newsgroup-end nil)
1140 (defvar gnus-newsgroup-last-rmail nil)
1141 (defvar gnus-newsgroup-last-mail nil)
1142 (defvar gnus-newsgroup-last-folder nil)
1143 (defvar gnus-newsgroup-last-file nil)
1144 (defvar gnus-newsgroup-auto-expire nil)
1145 (defvar gnus-newsgroup-active nil)
1147 (defvar gnus-newsgroup-data nil)
1148 (defvar gnus-newsgroup-data-reverse nil)
1149 (defvar gnus-newsgroup-limit nil)
1150 (defvar gnus-newsgroup-limits nil)
1152 (defvar gnus-newsgroup-unreads nil
1153 "List of unread articles in the current newsgroup.")
1155 (defvar gnus-newsgroup-unselected nil
1156 "List of unselected unread articles in the current newsgroup.")
1158 (defvar gnus-newsgroup-reads nil
1159 "Alist of read articles and article marks in the current newsgroup.")
1161 (defvar gnus-newsgroup-expunged-tally nil)
1163 (defvar gnus-newsgroup-marked nil
1164 "List of ticked articles in the current newsgroup (a subset of unread art).")
1166 (defvar gnus-newsgroup-killed nil
1167 "List of ranges of articles that have been through the scoring process.")
1169 (defvar gnus-newsgroup-cached nil
1170 "List of articles that come from the article cache.")
1172 (defvar gnus-newsgroup-saved nil
1173 "List of articles that have been saved.")
1175 (defvar gnus-newsgroup-kill-headers nil)
1177 (defvar gnus-newsgroup-replied nil
1178 "List of articles that have been replied to in the current newsgroup.")
1180 (defvar gnus-newsgroup-forwarded nil
1181 "List of articles that have been forwarded in the current newsgroup.")
1183 (defvar gnus-newsgroup-recent nil
1184 "List of articles that have are recent in the current newsgroup.")
1186 (defvar gnus-newsgroup-expirable nil
1187 "List of articles in the current newsgroup that can be expired.")
1189 (defvar gnus-newsgroup-processable nil
1190 "List of articles in the current newsgroup that can be processed.")
1192 (defvar gnus-newsgroup-downloadable nil
1193 "List of articles in the current newsgroup that can be processed.")
1195 (defvar gnus-newsgroup-undownloaded nil
1196 "List of articles in the current newsgroup that haven't been downloaded..")
1198 (defvar gnus-newsgroup-unsendable nil
1199 "List of articles in the current newsgroup that won't be sent.")
1201 (defvar gnus-newsgroup-bookmarks nil
1202 "List of articles in the current newsgroup that have bookmarks.")
1204 (defvar gnus-newsgroup-dormant nil
1205 "List of dormant articles in the current newsgroup.")
1207 (defvar gnus-newsgroup-unseen nil
1208 "List of unseen articles in the current newsgroup.")
1210 (defvar gnus-newsgroup-seen nil
1211 "Range of seen articles in the current newsgroup.")
1213 (defvar gnus-newsgroup-articles nil
1214 "List of articles in the current newsgroup.")
1216 (defvar gnus-newsgroup-scored nil
1217 "List of scored articles in the current newsgroup.")
1219 (defvar gnus-newsgroup-headers nil
1220 "List of article headers in the current newsgroup.")
1222 (defvar gnus-newsgroup-threads nil)
1224 (defvar gnus-newsgroup-prepared nil
1225 "Whether the current group has been prepared properly.")
1227 (defvar gnus-newsgroup-ancient nil
1228 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1230 (defvar gnus-newsgroup-sparse nil)
1232 (defvar gnus-current-article nil)
1233 (defvar gnus-article-current nil)
1234 (defvar gnus-current-headers nil)
1235 (defvar gnus-have-all-headers nil)
1236 (defvar gnus-last-article nil)
1237 (defvar gnus-newsgroup-history nil)
1238 (defvar gnus-newsgroup-charset nil)
1239 (defvar gnus-newsgroup-ephemeral-charset nil)
1240 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1242 (defvar gnus-article-before-search nil)
1244 (defconst gnus-summary-local-variables
1245 '(gnus-newsgroup-name
1246 gnus-newsgroup-begin gnus-newsgroup-end
1247 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1248 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1249 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1250 gnus-newsgroup-unselected gnus-newsgroup-marked
1251 gnus-newsgroup-reads gnus-newsgroup-saved
1252 gnus-newsgroup-replied gnus-newsgroup-forwarded
1253 gnus-newsgroup-recent
1254 gnus-newsgroup-expirable
1255 gnus-newsgroup-processable gnus-newsgroup-killed
1256 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1257 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1258 gnus-newsgroup-seen gnus-newsgroup-articles
1259 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1260 gnus-newsgroup-headers gnus-newsgroup-threads
1261 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1262 gnus-current-article gnus-current-headers gnus-have-all-headers
1263 gnus-last-article gnus-article-internal-prepare-hook
1264 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1265 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1266 gnus-thread-expunge-below
1267 gnus-score-alist gnus-current-score-file
1268 (gnus-summary-expunge-below . global)
1269 (gnus-summary-mark-below . global)
1270 (gnus-orphan-score . global)
1271 gnus-newsgroup-active gnus-scores-exclude-files
1272 gnus-newsgroup-history gnus-newsgroup-ancient
1273 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1274 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1275 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1276 (gnus-newsgroup-expunged-tally . 0)
1277 gnus-cache-removable-articles gnus-newsgroup-cached
1278 gnus-newsgroup-data gnus-newsgroup-data-reverse
1279 gnus-newsgroup-limit gnus-newsgroup-limits
1280 gnus-newsgroup-charset gnus-newsgroup-display)
1281 "Variables that are buffer-local to the summary buffers.")
1283 (defvar gnus-newsgroup-variables nil
1284 "A list of variables that have separate values in different newsgroups.
1285 A list of newsgroup (summary buffer) local variables, or cons of
1286 variables and their default values (when the default values are not
1287 nil), that should be made global while the summary buffer is active.
1288 These variables can be used to set variables in the group parameters
1289 while still allowing them to affect operations done in other
1290 buffers. For example:
1292 \(setq gnus-newsgroup-variables
1293 '(message-use-followup-to
1294 (gnus-visible-headers .
1295 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1298 ;; Byte-compiler warning.
1299 (eval-when-compile (defvar gnus-article-mode-map))
1303 (defvar gnus-decode-encoded-word-methods
1304 '(mail-decode-encoded-word-string)
1305 "List of methods used to decode encoded words.
1307 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1308 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1309 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1310 whose names match REGEXP.
1313 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1314 mail-decode-encoded-word-string
1315 (\"chinese\" . rfc1843-decode-string))")
1317 (defvar gnus-decode-encoded-word-methods-cache nil)
1319 (defun gnus-multi-decode-encoded-word-string (string)
1320 "Apply the functions from `gnus-encoded-word-methods' that match."
1321 (unless (and gnus-decode-encoded-word-methods-cache
1322 (eq gnus-newsgroup-name
1323 (car gnus-decode-encoded-word-methods-cache)))
1324 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1327 (nconc gnus-decode-encoded-word-methods-cache (list x))
1328 (if (and gnus-newsgroup-name
1329 (string-match (car x) gnus-newsgroup-name))
1330 (nconc gnus-decode-encoded-word-methods-cache
1332 gnus-decode-encoded-word-methods))
1333 (let ((xlist gnus-decode-encoded-word-methods-cache))
1336 (setq string (funcall (pop xlist) string))))
1339 ;; Subject simplification.
1341 (defun gnus-simplify-whitespace (str)
1342 "Remove excessive whitespace from STR."
1345 (while (string-match "[ \t][ \t]+" mystr)
1346 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1348 (substring mystr (match-end 0)))))
1350 (when (string-match "^[ \t]+" mystr)
1351 (setq mystr (substring mystr (match-end 0))))
1353 (when (string-match "[ \t]+$" mystr)
1354 (setq mystr (substring mystr 0 (match-beginning 0))))
1357 (defsubst gnus-simplify-subject-re (subject)
1358 "Remove \"Re:\" from subject lines."
1359 (if (string-match message-subject-re-regexp subject)
1360 (substring subject (match-end 0))
1363 (defun gnus-simplify-subject (subject &optional re-only)
1364 "Remove `Re:' and words in parentheses.
1365 If RE-ONLY is non-nil, strip leading `Re:'s only."
1366 (let ((case-fold-search t)) ;Ignore case.
1367 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1368 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1369 (setq subject (substring subject (match-end 0))))
1370 ;; Remove uninteresting prefixes.
1371 (when (and (not re-only)
1372 gnus-simplify-ignored-prefixes
1373 (string-match gnus-simplify-ignored-prefixes subject))
1374 (setq subject (substring subject (match-end 0))))
1375 ;; Remove words in parentheses from end.
1377 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1378 (setq subject (substring subject 0 (match-beginning 0)))))
1379 ;; Return subject string.
1382 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1384 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1385 (goto-char (point-min))
1386 (while (re-search-forward regexp nil t)
1387 (replace-match (or newtext ""))))
1389 (defun gnus-simplify-buffer-fuzzy ()
1390 "Simplify string in the buffer fuzzily.
1391 The string in the accessible portion of the current buffer is simplified.
1392 It is assumed to be a single-line subject.
1393 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1394 matter is removed. Additional things can be deleted by setting
1395 `gnus-simplify-subject-fuzzy-regexp'."
1396 (let ((case-fold-search t)
1398 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1400 (while (not (eq modified-tick (buffer-modified-tick)))
1401 (setq modified-tick (buffer-modified-tick))
1403 ((listp gnus-simplify-subject-fuzzy-regexp)
1404 (mapcar 'gnus-simplify-buffer-fuzzy-step
1405 gnus-simplify-subject-fuzzy-regexp))
1406 (gnus-simplify-subject-fuzzy-regexp
1407 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1408 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1409 (gnus-simplify-buffer-fuzzy-step
1410 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1411 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1413 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1414 (gnus-simplify-buffer-fuzzy-step " +" " ")
1415 (gnus-simplify-buffer-fuzzy-step " $")
1416 (gnus-simplify-buffer-fuzzy-step "^ +")))
1418 (defun gnus-simplify-subject-fuzzy (subject)
1419 "Simplify a subject string fuzzily.
1420 See `gnus-simplify-buffer-fuzzy' for details."
1422 (gnus-set-work-buffer)
1423 (let ((case-fold-search t))
1424 ;; Remove uninteresting prefixes.
1425 (when (and gnus-simplify-ignored-prefixes
1426 (string-match gnus-simplify-ignored-prefixes subject))
1427 (setq subject (substring subject (match-end 0))))
1429 (inline (gnus-simplify-buffer-fuzzy))
1432 (defsubst gnus-simplify-subject-fully (subject)
1433 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1435 (gnus-simplify-subject-functions
1436 (gnus-map-function gnus-simplify-subject-functions subject))
1437 ((null gnus-summary-gather-subject-limit)
1438 (gnus-simplify-subject-re subject))
1439 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1440 (gnus-simplify-subject-fuzzy subject))
1441 ((numberp gnus-summary-gather-subject-limit)
1442 (gnus-limit-string (gnus-simplify-subject-re subject)
1443 gnus-summary-gather-subject-limit))
1447 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1448 "Check whether two subjects are equal.
1449 If optional argument simple-first is t, first argument is already
1452 ((null simple-first)
1453 (equal (gnus-simplify-subject-fully s1)
1454 (gnus-simplify-subject-fully s2)))
1457 (gnus-simplify-subject-fully s2)))))
1459 (defun gnus-summary-bubble-group ()
1460 "Increase the score of the current group.
1461 This is a handy function to add to `gnus-summary-exit-hook' to
1462 increase the score of each group you read."
1463 (gnus-group-add-score gnus-newsgroup-name))
1467 ;;; Gnus summary mode
1470 (put 'gnus-summary-mode 'mode-class 'special)
1472 (defvar gnus-article-commands-menu)
1475 ;; Non-orthogonal keys
1477 (gnus-define-keys gnus-summary-mode-map
1478 " " gnus-summary-next-page
1479 "\177" gnus-summary-prev-page
1480 [delete] gnus-summary-prev-page
1481 [backspace] gnus-summary-prev-page
1482 "\r" gnus-summary-scroll-up
1483 "\M-\r" gnus-summary-scroll-down
1484 "n" gnus-summary-next-unread-article
1485 "p" gnus-summary-prev-unread-article
1486 "N" gnus-summary-next-article
1487 "P" gnus-summary-prev-article
1488 "\M-\C-n" gnus-summary-next-same-subject
1489 "\M-\C-p" gnus-summary-prev-same-subject
1490 "\M-n" gnus-summary-next-unread-subject
1491 "\M-p" gnus-summary-prev-unread-subject
1492 "." gnus-summary-first-unread-article
1493 "," gnus-summary-best-unread-article
1494 "\M-s" gnus-summary-search-article-forward
1495 "\M-r" gnus-summary-search-article-backward
1496 "<" gnus-summary-beginning-of-article
1497 ">" gnus-summary-end-of-article
1498 "j" gnus-summary-goto-article
1499 "^" gnus-summary-refer-parent-article
1500 "\M-^" gnus-summary-refer-article
1501 "u" gnus-summary-tick-article-forward
1502 "!" gnus-summary-tick-article-forward
1503 "U" gnus-summary-tick-article-backward
1504 "d" gnus-summary-mark-as-read-forward
1505 "D" gnus-summary-mark-as-read-backward
1506 "E" gnus-summary-mark-as-expirable
1507 "\M-u" gnus-summary-clear-mark-forward
1508 "\M-U" gnus-summary-clear-mark-backward
1509 "k" gnus-summary-kill-same-subject-and-select
1510 "\C-k" gnus-summary-kill-same-subject
1511 "\M-\C-k" gnus-summary-kill-thread
1512 "\M-\C-l" gnus-summary-lower-thread
1513 "e" gnus-summary-edit-article
1514 "#" gnus-summary-mark-as-processable
1515 "\M-#" gnus-summary-unmark-as-processable
1516 "\M-\C-t" gnus-summary-toggle-threads
1517 "\M-\C-s" gnus-summary-show-thread
1518 "\M-\C-h" gnus-summary-hide-thread
1519 "\M-\C-f" gnus-summary-next-thread
1520 "\M-\C-b" gnus-summary-prev-thread
1521 [(meta down)] gnus-summary-next-thread
1522 [(meta up)] gnus-summary-prev-thread
1523 "\M-\C-u" gnus-summary-up-thread
1524 "\M-\C-d" gnus-summary-down-thread
1525 "&" gnus-summary-execute-command
1526 "c" gnus-summary-catchup-and-exit
1527 "\C-w" gnus-summary-mark-region-as-read
1528 "\C-t" gnus-summary-toggle-truncation
1529 "?" gnus-summary-mark-as-dormant
1530 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1531 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1532 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1533 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1534 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1535 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1536 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1537 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1538 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1539 "=" gnus-summary-expand-window
1540 "\C-x\C-s" gnus-summary-reselect-current-group
1541 "\M-g" gnus-summary-rescan-group
1542 "w" gnus-summary-stop-page-breaking
1543 "\C-c\C-r" gnus-summary-caesar-message
1544 "f" gnus-summary-followup
1545 "F" gnus-summary-followup-with-original
1546 "C" gnus-summary-cancel-article
1547 "r" gnus-summary-reply
1548 "R" gnus-summary-reply-with-original
1549 "\C-c\C-f" gnus-summary-mail-forward
1550 "o" gnus-summary-save-article
1551 "\C-o" gnus-summary-save-article-mail
1552 "|" gnus-summary-pipe-output
1553 "\M-k" gnus-summary-edit-local-kill
1554 "\M-K" gnus-summary-edit-global-kill
1556 "\C-c\C-d" gnus-summary-describe-group
1557 "q" gnus-summary-exit
1558 "Q" gnus-summary-exit-no-update
1559 "\C-c\C-i" gnus-info-find-node
1560 gnus-mouse-2 gnus-mouse-pick-article
1561 "m" gnus-summary-mail-other-window
1562 "a" gnus-summary-post-news
1563 "i" gnus-summary-news-other-window
1564 "x" gnus-summary-limit-to-unread
1565 "s" gnus-summary-isearch-article
1566 "t" gnus-summary-toggle-header
1567 "g" gnus-summary-show-article
1568 "l" gnus-summary-goto-last-article
1569 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1570 "\C-d" gnus-summary-enter-digest-group
1571 "\M-\C-d" gnus-summary-read-document
1572 "\M-\C-e" gnus-summary-edit-parameters
1573 "\M-\C-a" gnus-summary-customize-parameters
1575 "*" gnus-cache-enter-article
1576 "\M-*" gnus-cache-remove-article
1577 "\M-&" gnus-summary-universal-argument
1578 "\C-l" gnus-recenter
1579 "I" gnus-summary-increase-score
1580 "L" gnus-summary-lower-score
1581 "\M-i" gnus-symbolic-argument
1582 "h" gnus-summary-select-article-buffer
1584 "b" gnus-article-view-part
1585 "\M-t" gnus-summary-toggle-display-buttonized
1587 "V" gnus-summary-score-map
1588 "X" gnus-uu-extract-map
1589 "S" gnus-summary-send-map)
1591 ;; Sort of orthogonal keymap
1592 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1593 "t" gnus-summary-tick-article-forward
1594 "!" gnus-summary-tick-article-forward
1595 "d" gnus-summary-mark-as-read-forward
1596 "r" gnus-summary-mark-as-read-forward
1597 "c" gnus-summary-clear-mark-forward
1598 " " gnus-summary-clear-mark-forward
1599 "e" gnus-summary-mark-as-expirable
1600 "x" gnus-summary-mark-as-expirable
1601 "?" gnus-summary-mark-as-dormant
1602 "b" gnus-summary-set-bookmark
1603 "B" gnus-summary-remove-bookmark
1604 "#" gnus-summary-mark-as-processable
1605 "\M-#" gnus-summary-unmark-as-processable
1606 "S" gnus-summary-limit-include-expunged
1607 "C" gnus-summary-catchup
1608 "H" gnus-summary-catchup-to-here
1609 "h" gnus-summary-catchup-from-here
1610 "\C-c" gnus-summary-catchup-all
1611 "k" gnus-summary-kill-same-subject-and-select
1612 "K" gnus-summary-kill-same-subject
1613 "P" gnus-uu-mark-map)
1615 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1616 "c" gnus-summary-clear-above
1617 "u" gnus-summary-tick-above
1618 "m" gnus-summary-mark-above
1619 "k" gnus-summary-kill-below)
1621 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1622 "/" gnus-summary-limit-to-subject
1623 "n" gnus-summary-limit-to-articles
1624 "w" gnus-summary-pop-limit
1625 "s" gnus-summary-limit-to-subject
1626 "a" gnus-summary-limit-to-author
1627 "u" gnus-summary-limit-to-unread
1628 "m" gnus-summary-limit-to-marks
1629 "M" gnus-summary-limit-exclude-marks
1630 "v" gnus-summary-limit-to-score
1631 "*" gnus-summary-limit-include-cached
1632 "D" gnus-summary-limit-include-dormant
1633 "T" gnus-summary-limit-include-thread
1634 "d" gnus-summary-limit-exclude-dormant
1635 "t" gnus-summary-limit-to-age
1636 "x" gnus-summary-limit-to-extra
1637 "p" gnus-summary-limit-to-display-predicate
1638 "E" gnus-summary-limit-include-expunged
1639 "c" gnus-summary-limit-exclude-childless-dormant
1640 "C" gnus-summary-limit-mark-excluded-as-read
1641 "o" gnus-summary-insert-old-articles
1642 "N" gnus-summary-insert-new-articles)
1644 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1645 "n" gnus-summary-next-unread-article
1646 "p" gnus-summary-prev-unread-article
1647 "N" gnus-summary-next-article
1648 "P" gnus-summary-prev-article
1649 "\C-n" gnus-summary-next-same-subject
1650 "\C-p" gnus-summary-prev-same-subject
1651 "\M-n" gnus-summary-next-unread-subject
1652 "\M-p" gnus-summary-prev-unread-subject
1653 "f" gnus-summary-first-unread-article
1654 "b" gnus-summary-best-unread-article
1655 "j" gnus-summary-goto-article
1656 "g" gnus-summary-goto-subject
1657 "l" gnus-summary-goto-last-article
1658 "o" gnus-summary-pop-article)
1660 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1661 "k" gnus-summary-kill-thread
1662 "l" gnus-summary-lower-thread
1663 "i" gnus-summary-raise-thread
1664 "T" gnus-summary-toggle-threads
1665 "t" gnus-summary-rethread-current
1666 "^" gnus-summary-reparent-thread
1667 "s" gnus-summary-show-thread
1668 "S" gnus-summary-show-all-threads
1669 "h" gnus-summary-hide-thread
1670 "H" gnus-summary-hide-all-threads
1671 "n" gnus-summary-next-thread
1672 "p" gnus-summary-prev-thread
1673 "u" gnus-summary-up-thread
1674 "o" gnus-summary-top-thread
1675 "d" gnus-summary-down-thread
1676 "#" gnus-uu-mark-thread
1677 "\M-#" gnus-uu-unmark-thread)
1679 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1680 "g" gnus-summary-prepare
1681 "c" gnus-summary-insert-cached-articles)
1683 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1684 "c" gnus-summary-catchup-and-exit
1685 "C" gnus-summary-catchup-all-and-exit
1686 "E" gnus-summary-exit-no-update
1687 "Q" gnus-summary-exit
1688 "Z" gnus-summary-exit
1689 "n" gnus-summary-catchup-and-goto-next-group
1690 "R" gnus-summary-reselect-current-group
1691 "G" gnus-summary-rescan-group
1692 "N" gnus-summary-next-group
1693 "s" gnus-summary-save-newsrc
1694 "P" gnus-summary-prev-group)
1696 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1697 " " gnus-summary-next-page
1698 "n" gnus-summary-next-page
1699 "\177" gnus-summary-prev-page
1700 [delete] gnus-summary-prev-page
1701 "p" gnus-summary-prev-page
1702 "\r" gnus-summary-scroll-up
1703 "\M-\r" gnus-summary-scroll-down
1704 "<" gnus-summary-beginning-of-article
1705 ">" gnus-summary-end-of-article
1706 "b" gnus-summary-beginning-of-article
1707 "e" gnus-summary-end-of-article
1708 "^" gnus-summary-refer-parent-article
1709 "r" gnus-summary-refer-parent-article
1710 "D" gnus-summary-enter-digest-group
1711 "R" gnus-summary-refer-references
1712 "T" gnus-summary-refer-thread
1713 "g" gnus-summary-show-article
1714 "s" gnus-summary-isearch-article
1715 "P" gnus-summary-print-article
1716 "M" gnus-mailing-list-insinuate
1717 "t" gnus-article-babel)
1719 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1720 "b" gnus-article-add-buttons
1721 "B" gnus-article-add-buttons-to-head
1722 "o" gnus-article-treat-overstrike
1723 "e" gnus-article-emphasize
1724 "w" gnus-article-fill-cited-article
1725 "Q" gnus-article-fill-long-lines
1726 "C" gnus-article-capitalize-sentences
1727 "c" gnus-article-remove-cr
1728 "q" gnus-article-de-quoted-unreadable
1729 "6" gnus-article-de-base64-unreadable
1730 "Z" gnus-article-decode-HZ
1731 "h" gnus-article-wash-html
1732 "s" gnus-summary-force-verify-and-decrypt
1733 "f" gnus-article-display-x-face
1734 "l" gnus-summary-stop-page-breaking
1735 "r" gnus-summary-caesar-message
1736 "t" gnus-summary-toggle-header
1737 "g" gnus-treat-smiley
1738 "v" gnus-summary-verbose-headers
1739 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1740 "p" gnus-article-verify-x-pgp-sig
1741 "d" gnus-article-treat-dumbquotes)
1743 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1744 "a" gnus-article-hide
1745 "h" gnus-article-hide-headers
1746 "b" gnus-article-hide-boring-headers
1747 "s" gnus-article-hide-signature
1748 "c" gnus-article-hide-citation
1749 "C" gnus-article-hide-citation-in-followups
1750 "l" gnus-article-hide-list-identifiers
1751 "p" gnus-article-hide-pgp
1752 "B" gnus-article-strip-banner
1753 "P" gnus-article-hide-pem
1754 "\C-c" gnus-article-hide-citation-maybe)
1756 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1757 "a" gnus-article-highlight
1758 "h" gnus-article-highlight-headers
1759 "c" gnus-article-highlight-citation
1760 "s" gnus-article-highlight-signature)
1762 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1763 "f" gnus-article-treat-fold-headers
1764 "u" gnus-article-treat-unfold-headers
1765 "n" gnus-article-treat-fold-newsgroups)
1767 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1768 "x" gnus-article-display-x-face
1769 "s" gnus-treat-smiley
1770 "D" gnus-article-remove-images
1771 "f" gnus-treat-from-picon
1772 "m" gnus-treat-mail-picon
1773 "n" gnus-treat-newsgroups-picon)
1775 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1776 "w" gnus-article-decode-mime-words
1777 "c" gnus-article-decode-charset
1778 "v" gnus-mime-view-all-parts
1779 "b" gnus-article-view-part)
1781 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1782 "z" gnus-article-date-ut
1783 "u" gnus-article-date-ut
1784 "l" gnus-article-date-local
1785 "p" gnus-article-date-english
1786 "e" gnus-article-date-lapsed
1787 "o" gnus-article-date-original
1788 "i" gnus-article-date-iso8601
1789 "s" gnus-article-date-user)
1791 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1792 "t" gnus-article-remove-trailing-blank-lines
1793 "l" gnus-article-strip-leading-blank-lines
1794 "m" gnus-article-strip-multiple-blank-lines
1795 "a" gnus-article-strip-blank-lines
1796 "A" gnus-article-strip-all-blank-lines
1797 "s" gnus-article-strip-leading-space
1798 "e" gnus-article-strip-trailing-space
1799 "w" gnus-article-remove-leading-whitespace)
1801 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1803 "f" gnus-summary-fetch-faq
1804 "d" gnus-summary-describe-group
1805 "h" gnus-summary-describe-briefly
1806 "i" gnus-info-find-node)
1808 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1809 "e" gnus-summary-expire-articles
1810 "\M-\C-e" gnus-summary-expire-articles-now
1811 "\177" gnus-summary-delete-article
1812 [delete] gnus-summary-delete-article
1813 [backspace] gnus-summary-delete-article
1814 "m" gnus-summary-move-article
1815 "r" gnus-summary-respool-article
1816 "w" gnus-summary-edit-article
1817 "c" gnus-summary-copy-article
1818 "B" gnus-summary-crosspost-article
1819 "q" gnus-summary-respool-query
1820 "t" gnus-summary-respool-trace
1821 "i" gnus-summary-import-article
1822 "I" gnus-summary-create-article
1823 "p" gnus-summary-article-posted-p)
1825 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1826 "o" gnus-summary-save-article
1827 "m" gnus-summary-save-article-mail
1828 "F" gnus-summary-write-article-file
1829 "r" gnus-summary-save-article-rmail
1830 "f" gnus-summary-save-article-file
1831 "b" gnus-summary-save-article-body-file
1832 "h" gnus-summary-save-article-folder
1833 "v" gnus-summary-save-article-vm
1834 "p" gnus-summary-pipe-output
1835 "P" gnus-summary-muttprint
1836 "s" gnus-soup-add-article)
1838 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1839 "b" gnus-summary-display-buttonized
1840 "m" gnus-summary-repair-multipart
1841 "v" gnus-article-view-part
1842 "o" gnus-article-save-part
1843 "c" gnus-article-copy-part
1844 "C" gnus-article-view-part-as-charset
1845 "e" gnus-article-externalize-part
1846 "E" gnus-article-encrypt-body
1847 "i" gnus-article-inline-part
1848 "|" gnus-article-pipe-part))
1850 (defvar gnus-article-post-menu nil)
1852 (defun gnus-summary-make-menu-bar ()
1853 (gnus-turn-off-edit-menu 'summary)
1855 (unless (boundp 'gnus-summary-misc-menu)
1858 gnus-summary-kill-menu gnus-summary-mode-map ""
1863 ["Customize" gnus-score-customize t])
1864 (gnus-make-score-map 'increase)
1865 (gnus-make-score-map 'lower)
1867 ["Kill below" gnus-summary-kill-below t]
1868 ["Mark above" gnus-summary-mark-above t]
1869 ["Tick above" gnus-summary-tick-above t]
1870 ["Clear above" gnus-summary-clear-above t])
1871 ["Current score" gnus-summary-current-score t]
1872 ["Set score" gnus-summary-set-score t]
1873 ["Switch current score file..." gnus-score-change-score-file t]
1874 ["Set mark below..." gnus-score-set-mark-below t]
1875 ["Set expunge below..." gnus-score-set-expunge-below t]
1876 ["Edit current score file" gnus-score-edit-current-scores t]
1877 ["Edit score file" gnus-score-edit-file t]
1878 ["Trace score" gnus-score-find-trace t]
1879 ["Find words" gnus-score-find-favourite-words t]
1880 ["Rescore buffer" gnus-summary-rescore t]
1881 ["Increase score..." gnus-summary-increase-score t]
1882 ["Lower score..." gnus-summary-lower-score t]))))
1884 ;; Define both the Article menu in the summary buffer and the
1885 ;; equivalent Commands menu in the article buffer here for
1889 ["All" gnus-article-hide t]
1890 ["Headers" gnus-article-hide-headers t]
1891 ["Signature" gnus-article-hide-signature t]
1892 ["Citation" gnus-article-hide-citation t]
1893 ["List identifiers" gnus-article-hide-list-identifiers t]
1894 ["PGP" gnus-article-hide-pgp t]
1895 ["Banner" gnus-article-strip-banner t]
1896 ["Boring headers" gnus-article-hide-boring-headers t])
1898 ["All" gnus-article-highlight t]
1899 ["Headers" gnus-article-highlight-headers t]
1900 ["Signature" gnus-article-highlight-signature t]
1901 ["Citation" gnus-article-highlight-citation t])
1903 ["Words" gnus-article-decode-mime-words t]
1904 ["Charset" gnus-article-decode-charset t]
1905 ["QP" gnus-article-de-quoted-unreadable t]
1906 ["Base64" gnus-article-de-base64-unreadable t]
1907 ["View all" gnus-mime-view-all-parts t]
1908 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1909 ["Encrypt body" gnus-article-encrypt-body t])
1911 ["Local" gnus-article-date-local t]
1912 ["ISO8601" gnus-article-date-iso8601 t]
1913 ["UT" gnus-article-date-ut t]
1914 ["Original" gnus-article-date-original t]
1915 ["Lapsed" gnus-article-date-lapsed t]
1916 ["User-defined" gnus-article-date-user t])
1918 ["Remove images" gnus-article-remove-images t]
1919 ["Toggle smiley" gnus-treat-smiley t]
1920 ["Show X-Face" gnus-article-display-x-face t]
1921 ["Show picons in From" gnus-treat-from-picon t]
1922 ["Show picons in mail headers" gnus-treat-mail-picon t]
1923 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1926 ["Leading" gnus-article-strip-leading-blank-lines t]
1927 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1928 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1929 ["All of the above" gnus-article-strip-blank-lines t]
1930 ["All" gnus-article-strip-all-blank-lines t]
1931 ["Leading space" gnus-article-strip-leading-space t]
1932 ["Trailing space" gnus-article-strip-trailing-space t]
1933 ["Leading space in headers"
1934 gnus-article-remove-leading-whitespace t])
1935 ["Overstrike" gnus-article-treat-overstrike t]
1936 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1937 ["Emphasis" gnus-article-emphasize t]
1938 ["Word wrap" gnus-article-fill-cited-article t]
1939 ["Fill long lines" gnus-article-fill-long-lines t]
1940 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1941 ["CR" gnus-article-remove-cr t]
1942 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1943 ["Base64" gnus-article-de-base64-unreadable t]
1944 ["Rot 13" gnus-summary-caesar-message
1945 ,@(if (featurep 'xemacs) '(t)
1946 '(:help "\"Caesar rotate\" article by 13"))]
1947 ["Unix pipe" gnus-summary-pipe-message t]
1948 ["Add buttons" gnus-article-add-buttons t]
1949 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1950 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1951 ["Verbose header" gnus-summary-verbose-headers t]
1952 ["Toggle header" gnus-summary-toggle-header t]
1953 ["Unfold headers" gnus-article-treat-unfold-headers t]
1954 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1955 ["Html" gnus-article-wash-html t]
1956 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1957 ["HZ" gnus-article-decode-HZ t])
1959 ["Save in default format" gnus-summary-save-article
1960 ,@(if (featurep 'xemacs) '(t)
1961 '(:help "Save article using default method"))]
1962 ["Save in file" gnus-summary-save-article-file
1963 ,@(if (featurep 'xemacs) '(t)
1964 '(:help "Save article in file"))]
1965 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1966 ["Save in MH folder" gnus-summary-save-article-folder t]
1967 ["Save in VM folder" gnus-summary-save-article-vm t]
1968 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1969 ["Save body in file" gnus-summary-save-article-body-file t]
1970 ["Pipe through a filter" gnus-summary-pipe-output t]
1971 ["Add to SOUP packet" gnus-soup-add-article t]
1972 ["Print with Muttprint" gnus-summary-muttprint t]
1973 ["Print" gnus-summary-print-article t])
1975 ["Respool article..." gnus-summary-respool-article t]
1976 ["Move article..." gnus-summary-move-article
1977 (gnus-check-backend-function
1978 'request-move-article gnus-newsgroup-name)]
1979 ["Copy article..." gnus-summary-copy-article t]
1980 ["Crosspost article..." gnus-summary-crosspost-article
1981 (gnus-check-backend-function
1982 'request-replace-article gnus-newsgroup-name)]
1983 ["Import file..." gnus-summary-import-article t]
1984 ["Create article..." gnus-summary-create-article t]
1985 ["Check if posted" gnus-summary-article-posted-p t]
1986 ["Edit article" gnus-summary-edit-article
1987 (not (gnus-group-read-only-p))]
1988 ["Delete article" gnus-summary-delete-article
1989 (gnus-check-backend-function
1990 'request-expire-articles gnus-newsgroup-name)]
1991 ["Query respool" gnus-summary-respool-query t]
1992 ["Trace respool" gnus-summary-respool-trace t]
1993 ["Delete expirable articles" gnus-summary-expire-articles-now
1994 (gnus-check-backend-function
1995 'request-expire-articles gnus-newsgroup-name)])
1997 ["Uudecode" gnus-uu-decode-uu
1998 ,@(if (featurep 'xemacs) '(t)
1999 '(:help "Decode uuencoded article(s)"))]
2000 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2001 ["Unshar" gnus-uu-decode-unshar t]
2002 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2003 ["Save" gnus-uu-decode-save t]
2004 ["Binhex" gnus-uu-decode-binhex t]
2005 ["Postscript" gnus-uu-decode-postscript t])
2007 ["Enter article" gnus-cache-enter-article t]
2008 ["Remove article" gnus-cache-remove-article t])
2009 ["Translate" gnus-article-babel t]
2010 ["Select article buffer" gnus-summary-select-article-buffer t]
2011 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2012 ["Isearch article..." gnus-summary-isearch-article t]
2013 ["Beginning of the article" gnus-summary-beginning-of-article t]
2014 ["End of the article" gnus-summary-end-of-article t]
2015 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2016 ["Fetch referenced articles" gnus-summary-refer-references t]
2017 ["Fetch current thread" gnus-summary-refer-thread t]
2018 ["Fetch article with id..." gnus-summary-refer-article t]
2019 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2020 ["Redisplay" gnus-summary-show-article t]
2021 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2023 gnus-summary-article-menu gnus-summary-mode-map ""
2024 (cons "Article" innards))
2026 (if (not (keymapp gnus-summary-article-menu))
2028 gnus-article-commands-menu gnus-article-mode-map ""
2029 (cons "Commands" innards))
2030 ;; in Emacs, don't share menu.
2031 (setq gnus-article-commands-menu
2032 (copy-keymap gnus-summary-article-menu))
2033 (define-key gnus-article-mode-map [menu-bar commands]
2034 (cons "Commands" gnus-article-commands-menu))))
2037 gnus-summary-thread-menu gnus-summary-mode-map ""
2039 ["Toggle threading" gnus-summary-toggle-threads t]
2040 ["Hide threads" gnus-summary-hide-all-threads t]
2041 ["Show threads" gnus-summary-show-all-threads t]
2042 ["Hide thread" gnus-summary-hide-thread t]
2043 ["Show thread" gnus-summary-show-thread t]
2044 ["Go to next thread" gnus-summary-next-thread t]
2045 ["Go to previous thread" gnus-summary-prev-thread t]
2046 ["Go down thread" gnus-summary-down-thread t]
2047 ["Go up thread" gnus-summary-up-thread t]
2048 ["Top of thread" gnus-summary-top-thread t]
2049 ["Mark thread as read" gnus-summary-kill-thread t]
2050 ["Lower thread score" gnus-summary-lower-thread t]
2051 ["Raise thread score" gnus-summary-raise-thread t]
2052 ["Rethread current" gnus-summary-rethread-current t]))
2055 gnus-summary-post-menu gnus-summary-mode-map ""
2057 ["Send a message (mail or news)" gnus-summary-post-news
2058 ,@(if (featurep 'xemacs) '(t)
2059 '(:help "Post an article"))]
2060 ["Followup" gnus-summary-followup
2061 ,@(if (featurep 'xemacs) '(t)
2062 '(:help "Post followup to this article"))]
2063 ["Followup and yank" gnus-summary-followup-with-original
2064 ,@(if (featurep 'xemacs) '(t)
2065 '(:help "Post followup to this article, quoting its contents"))]
2066 ["Supersede article" gnus-summary-supersede-article t]
2067 ["Cancel article" gnus-summary-cancel-article
2068 ,@(if (featurep 'xemacs) '(t)
2069 '(:help "Cancel an article you posted"))]
2070 ["Reply" gnus-summary-reply t]
2071 ["Reply and yank" gnus-summary-reply-with-original t]
2072 ["Wide reply" gnus-summary-wide-reply t]
2073 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2074 ,@(if (featurep 'xemacs) '(t)
2075 '(:help "Mail a reply, quoting this article"))]
2076 ["Very wide reply" gnus-summary-very-wide-reply t]
2077 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2078 ,@(if (featurep 'xemacs) '(t)
2079 '(:help "Mail a very wide reply, quoting this article"))]
2080 ["Mail forward" gnus-summary-mail-forward t]
2081 ["Post forward" gnus-summary-post-forward t]
2082 ["Digest and mail" gnus-uu-digest-mail-forward t]
2083 ["Digest and post" gnus-uu-digest-post-forward t]
2084 ["Resend message" gnus-summary-resend-message t]
2085 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2086 ["Send a mail" gnus-summary-mail-other-window t]
2087 ["Create a local message" gnus-summary-news-other-window t]
2088 ["Uuencode and post" gnus-uu-post-news
2089 ,@(if (featurep 'xemacs) '(t)
2090 '(:help "Post a uuencoded article"))]
2091 ["Followup via news" gnus-summary-followup-to-mail t]
2092 ["Followup via news and yank"
2093 gnus-summary-followup-to-mail-with-original t]
2095 ;;["Send" gnus-summary-send-draft t]
2096 ;;["Send bounced" gnus-resend-bounced-mail t])
2100 ((not (keymapp gnus-summary-post-menu))
2101 (setq gnus-article-post-menu gnus-summary-post-menu))
2102 ((not gnus-article-post-menu)
2103 ;; Don't share post menu.
2104 (setq gnus-article-post-menu
2105 (copy-keymap gnus-summary-post-menu))))
2106 (define-key gnus-article-mode-map [menu-bar post]
2107 (cons "Post" gnus-article-post-menu))
2110 gnus-summary-misc-menu gnus-summary-mode-map ""
2113 ["Mark as read" gnus-summary-mark-as-read-forward t]
2114 ["Mark same subject and select"
2115 gnus-summary-kill-same-subject-and-select t]
2116 ["Mark same subject" gnus-summary-kill-same-subject t]
2117 ["Catchup" gnus-summary-catchup
2118 ,@(if (featurep 'xemacs) '(t)
2119 '(:help "Mark unread articles in this group as read"))]
2120 ["Catchup all" gnus-summary-catchup-all t]
2121 ["Catchup to here" gnus-summary-catchup-to-here t]
2122 ["Catchup from here" gnus-summary-catchup-from-here t]
2123 ["Catchup region" gnus-summary-mark-region-as-read t]
2124 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2126 ["Tick" gnus-summary-tick-article-forward t]
2127 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2128 ["Remove marks" gnus-summary-clear-mark-forward t]
2129 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2130 ["Set bookmark" gnus-summary-set-bookmark t]
2131 ["Remove bookmark" gnus-summary-remove-bookmark t])
2133 ["Marks..." gnus-summary-limit-to-marks t]
2134 ["Subject..." gnus-summary-limit-to-subject t]
2135 ["Author..." gnus-summary-limit-to-author t]
2136 ["Age..." gnus-summary-limit-to-age t]
2137 ["Extra..." gnus-summary-limit-to-extra t]
2138 ["Score" gnus-summary-limit-to-score t]
2139 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2140 ["Unread" gnus-summary-limit-to-unread t]
2141 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2142 ["Articles" gnus-summary-limit-to-articles t]
2143 ["Pop limit" gnus-summary-pop-limit t]
2144 ["Show dormant" gnus-summary-limit-include-dormant t]
2145 ["Hide childless dormant"
2146 gnus-summary-limit-exclude-childless-dormant t]
2147 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2148 ["Hide marked" gnus-summary-limit-exclude-marks t]
2149 ["Show expunged" gnus-summary-limit-include-expunged t])
2151 ["Set mark" gnus-summary-mark-as-processable t]
2152 ["Remove mark" gnus-summary-unmark-as-processable t]
2153 ["Remove all marks" gnus-summary-unmark-all-processable t]
2154 ["Mark above" gnus-uu-mark-over t]
2155 ["Mark series" gnus-uu-mark-series t]
2156 ["Mark region" gnus-uu-mark-region t]
2157 ["Unmark region" gnus-uu-unmark-region t]
2158 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2159 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2160 ["Mark all" gnus-uu-mark-all t]
2161 ["Mark buffer" gnus-uu-mark-buffer t]
2162 ["Mark sparse" gnus-uu-mark-sparse t]
2163 ["Mark thread" gnus-uu-mark-thread t]
2164 ["Unmark thread" gnus-uu-unmark-thread t]
2165 ("Process Mark Sets"
2166 ["Kill" gnus-summary-kill-process-mark t]
2167 ["Yank" gnus-summary-yank-process-mark
2168 gnus-newsgroup-process-stack]
2169 ["Save" gnus-summary-save-process-mark t]))
2171 ["Page forward" gnus-summary-next-page
2172 ,@(if (featurep 'xemacs) '(t)
2173 '(:help "Show next page of article"))]
2174 ["Page backward" gnus-summary-prev-page
2175 ,@(if (featurep 'xemacs) '(t)
2176 '(:help "Show previous page of article"))]
2177 ["Line forward" gnus-summary-scroll-up t])
2179 ["Next unread article" gnus-summary-next-unread-article t]
2180 ["Previous unread article" gnus-summary-prev-unread-article t]
2181 ["Next article" gnus-summary-next-article t]
2182 ["Previous article" gnus-summary-prev-article t]
2183 ["Next unread subject" gnus-summary-next-unread-subject t]
2184 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2185 ["Next article same subject" gnus-summary-next-same-subject t]
2186 ["Previous article same subject" gnus-summary-prev-same-subject t]
2187 ["First unread article" gnus-summary-first-unread-article t]
2188 ["Best unread article" gnus-summary-best-unread-article t]
2189 ["Go to subject number..." gnus-summary-goto-subject t]
2190 ["Go to article number..." gnus-summary-goto-article t]
2191 ["Go to the last article" gnus-summary-goto-last-article t]
2192 ["Pop article off history" gnus-summary-pop-article t])
2194 ["Sort by number" gnus-summary-sort-by-number t]
2195 ["Sort by author" gnus-summary-sort-by-author t]
2196 ["Sort by subject" gnus-summary-sort-by-subject t]
2197 ["Sort by date" gnus-summary-sort-by-date t]
2198 ["Sort by score" gnus-summary-sort-by-score t]
2199 ["Sort by lines" gnus-summary-sort-by-lines t]
2200 ["Sort by characters" gnus-summary-sort-by-chars t]
2201 ["Original sort" gnus-summary-sort-by-original t])
2203 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2204 ["Describe group" gnus-summary-describe-group t]
2205 ["Read manual" gnus-info-find-node t])
2207 ["Pick and read" gnus-pick-mode t]
2208 ["Binary" gnus-binary-mode t])
2210 ["Regenerate" gnus-summary-prepare t]
2211 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2212 ["Toggle threading" gnus-summary-toggle-threads t])
2213 ["See old articles" gnus-summary-insert-old-articles t]
2214 ["See new articles" gnus-summary-insert-new-articles t]
2215 ["Filter articles..." gnus-summary-execute-command t]
2216 ["Run command on subjects..." gnus-summary-universal-argument t]
2217 ["Search articles forward..." gnus-summary-search-article-forward t]
2218 ["Search articles backward..." gnus-summary-search-article-backward t]
2219 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2220 ["Expand window" gnus-summary-expand-window t]
2221 ["Expire expirable articles" gnus-summary-expire-articles
2222 (gnus-check-backend-function
2223 'request-expire-articles gnus-newsgroup-name)]
2224 ["Edit local kill file" gnus-summary-edit-local-kill t]
2225 ["Edit main kill file" gnus-summary-edit-global-kill t]
2226 ["Edit group parameters" gnus-summary-edit-parameters t]
2227 ["Customize group parameters" gnus-summary-customize-parameters t]
2228 ["Send a bug report" gnus-bug t]
2230 ["Catchup and exit" gnus-summary-catchup-and-exit
2231 ,@(if (featurep 'xemacs) '(t)
2232 '(:help "Mark unread articles in this group as read, then exit"))]
2233 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2234 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2235 ["Exit group" gnus-summary-exit
2236 ,@(if (featurep 'xemacs) '(t)
2237 '(:help "Exit current group, return to group selection mode"))]
2238 ["Exit group without updating" gnus-summary-exit-no-update t]
2239 ["Exit and goto next group" gnus-summary-next-group t]
2240 ["Exit and goto prev group" gnus-summary-prev-group t]
2241 ["Reselect group" gnus-summary-reselect-current-group t]
2242 ["Rescan group" gnus-summary-rescan-group t]
2243 ["Update dribble" gnus-summary-save-newsrc t])))
2245 (gnus-run-hooks 'gnus-summary-menu-hook)))
2247 (defvar gnus-summary-tool-bar-map nil)
2249 ;; Emacs 21 tool bar. Should be no-op otherwise.
2250 (defun gnus-summary-make-tool-bar ()
2251 (if (and (fboundp 'tool-bar-add-item-from-menu)
2252 (default-value 'tool-bar-mode)
2253 (not gnus-summary-tool-bar-map))
2254 (setq gnus-summary-tool-bar-map
2255 (let ((tool-bar-map (make-sparse-keymap))
2256 (load-path (mm-image-load-path)))
2257 (tool-bar-add-item-from-menu
2258 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2259 (tool-bar-add-item-from-menu
2260 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2261 (tool-bar-add-item-from-menu
2262 'gnus-summary-post-news "post" gnus-summary-mode-map)
2263 (tool-bar-add-item-from-menu
2264 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2265 (tool-bar-add-item-from-menu
2266 'gnus-summary-followup "followup" gnus-summary-mode-map)
2267 (tool-bar-add-item-from-menu
2268 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2269 (tool-bar-add-item-from-menu
2270 'gnus-summary-reply "reply" gnus-summary-mode-map)
2271 (tool-bar-add-item-from-menu
2272 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2273 (tool-bar-add-item-from-menu
2274 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2275 (tool-bar-add-item-from-menu
2276 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2277 (tool-bar-add-item-from-menu
2278 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2279 (tool-bar-add-item-from-menu
2280 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2281 (tool-bar-add-item-from-menu
2282 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2283 (tool-bar-add-item-from-menu
2284 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2285 (tool-bar-add-item-from-menu
2286 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2288 (if gnus-summary-tool-bar-map
2289 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2291 (defun gnus-score-set-default (var value)
2292 "A version of set that updates the GNU Emacs menu-bar."
2294 ;; It is the message that forces the active status to be updated.
2297 (defun gnus-make-score-map (type)
2298 "Make a summary score map of type TYPE."
2301 (let ((headers '(("author" "from" string)
2302 ("subject" "subject" string)
2303 ("article body" "body" string)
2304 ("article head" "head" string)
2305 ("xref" "xref" string)
2306 ("extra header" "extra" string)
2307 ("lines" "lines" number)
2308 ("followups to author" "followup" string)))
2309 (types '((number ("less than" <)
2312 (string ("substring" s)
2316 (perms '(("temporary" (current-time-string))
2324 (if (eq type 'lower)
2329 (setq header (car headers))
2335 (let ((ts (cdr (assoc (nth 2 header) types)))
2351 'gnus-summary-score-entry
2353 (if (or (string= (nth 1 header)
2355 (string= (nth 1 header)
2358 (list 'gnus-summary-header
2360 (list 'quote (nth 1 (car ts)))
2361 (list 'gnus-score-delta-default
2368 (list (nreverse outp))))
2371 (list (nreverse outt))))
2373 (setq headers (cdr headers)))
2374 (list (nreverse outh))))))))
2378 (defun gnus-summary-mode (&optional group)
2379 "Major mode for reading articles.
2381 All normal editing commands are switched off.
2382 \\<gnus-summary-mode-map>
2383 Each line in this buffer represents one article. To read an
2384 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2385 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2388 You can also post articles and send mail from this buffer. To
2389 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2390 of an article, type `\\[gnus-summary-reply]'.
2392 There are approx. one gazillion commands you can execute in this
2393 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2395 The following commands are available:
2397 \\{gnus-summary-mode-map}"
2399 (kill-all-local-variables)
2400 (when (gnus-visual-p 'summary-menu 'menu)
2401 (gnus-summary-make-menu-bar)
2402 (gnus-summary-make-tool-bar))
2403 (gnus-summary-make-local-variables)
2404 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2405 (gnus-summary-make-local-variables))
2406 (gnus-make-thread-indent-array)
2407 (gnus-simplify-mode-line)
2408 (setq major-mode 'gnus-summary-mode)
2409 (setq mode-name "Summary")
2410 (make-local-variable 'minor-mode-alist)
2411 (use-local-map gnus-summary-mode-map)
2412 (buffer-disable-undo)
2413 (setq buffer-read-only t) ;Disable modification
2414 (setq truncate-lines t)
2415 (setq selective-display t)
2416 (setq selective-display-ellipses t) ;Display `...'
2417 (gnus-summary-set-display-table)
2418 (gnus-set-default-directory)
2419 (setq gnus-newsgroup-name group)
2420 (make-local-variable 'gnus-summary-line-format)
2421 (make-local-variable 'gnus-summary-line-format-spec)
2422 (make-local-variable 'gnus-summary-dummy-line-format)
2423 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2424 (make-local-variable 'gnus-summary-mark-positions)
2425 (make-local-hook 'pre-command-hook)
2426 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2427 (gnus-run-hooks 'gnus-summary-mode-hook)
2428 (turn-on-gnus-mailing-list-mode)
2429 (mm-enable-multibyte)
2430 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2431 (gnus-update-summary-mark-positions))
2433 (defun gnus-summary-make-local-variables ()
2434 "Make all the local summary buffer variables."
2436 (dolist (local gnus-summary-local-variables)
2439 (if (eq (cdr local) 'global)
2440 ;; Copy the global value of the variable.
2441 (setq global (symbol-value (car local)))
2442 ;; Use the value from the list.
2443 (setq global (eval (cdr local))))
2444 (set (make-local-variable (car local)) global))
2445 ;; Simple nil-valued local variable.
2446 (set (make-local-variable local) nil)))))
2448 (defun gnus-summary-clear-local-variables ()
2449 (let ((locals gnus-summary-local-variables))
2451 (if (consp (car locals))
2452 (and (vectorp (caar locals))
2453 (set (caar locals) nil))
2454 (and (vectorp (car locals))
2455 (set (car locals) nil)))
2456 (setq locals (cdr locals)))))
2458 ;; Summary data functions.
2460 (defmacro gnus-data-number (data)
2463 (defmacro gnus-data-set-number (data number)
2464 `(setcar ,data ,number))
2466 (defmacro gnus-data-mark (data)
2469 (defmacro gnus-data-set-mark (data mark)
2470 `(setcar (nthcdr 1 ,data) ,mark))
2472 (defmacro gnus-data-pos (data)
2475 (defmacro gnus-data-set-pos (data pos)
2476 `(setcar (nthcdr 2 ,data) ,pos))
2478 (defmacro gnus-data-header (data)
2481 (defmacro gnus-data-set-header (data header)
2482 `(setf (nth 3 ,data) ,header))
2484 (defmacro gnus-data-level (data)
2487 (defmacro gnus-data-unread-p (data)
2488 `(= (nth 1 ,data) gnus-unread-mark))
2490 (defmacro gnus-data-read-p (data)
2491 `(/= (nth 1 ,data) gnus-unread-mark))
2493 (defmacro gnus-data-pseudo-p (data)
2494 `(consp (nth 3 ,data)))
2496 (defmacro gnus-data-find (number)
2497 `(assq ,number gnus-newsgroup-data))
2499 (defmacro gnus-data-find-list (number &optional data)
2500 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2501 (memq (assq ,number bdata)
2504 (defmacro gnus-data-make (number mark pos header level)
2505 `(list ,number ,mark ,pos ,header ,level))
2507 (defun gnus-data-enter (after-article number mark pos header level offset)
2508 (let ((data (gnus-data-find-list after-article)))
2510 (error "No such article: %d" after-article))
2511 (setcdr data (cons (gnus-data-make number mark pos header level)
2513 (setq gnus-newsgroup-data-reverse nil)
2514 (gnus-data-update-list (cddr data) offset)))
2516 (defun gnus-data-enter-list (after-article list &optional offset)
2518 (let ((data (and after-article (gnus-data-find-list after-article)))
2522 (let ((odata gnus-newsgroup-data))
2523 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2525 (gnus-data-update-list odata offset)))
2526 ;; Find the last element in the list to be spliced into the main
2529 (setq list (cdr list)))
2532 (setcdr list gnus-newsgroup-data)
2533 (setq gnus-newsgroup-data ilist)
2535 (gnus-data-update-list (cdr list) offset)))
2536 (setcdr list (cdr data))
2539 (gnus-data-update-list (cdr list) offset))))
2540 (setq gnus-newsgroup-data-reverse nil))))
2542 (defun gnus-data-remove (article &optional offset)
2543 (let ((data gnus-newsgroup-data))
2544 (if (= (gnus-data-number (car data)) article)
2546 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2547 gnus-newsgroup-data-reverse nil)
2549 (gnus-data-update-list gnus-newsgroup-data offset)))
2551 (when (= (gnus-data-number (cadr data)) article)
2552 (setcdr data (cddr data))
2554 (gnus-data-update-list (cdr data) offset))
2556 gnus-newsgroup-data-reverse nil))
2557 (setq data (cdr data))))))
2559 (defmacro gnus-data-list (backward)
2561 (or gnus-newsgroup-data-reverse
2562 (setq gnus-newsgroup-data-reverse
2563 (reverse gnus-newsgroup-data)))
2564 gnus-newsgroup-data))
2566 (defun gnus-data-update-list (data offset)
2567 "Add OFFSET to the POS of all data entries in DATA."
2568 (setq gnus-newsgroup-data-reverse nil)
2570 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2571 (setq data (cdr data))))
2573 (defun gnus-summary-article-pseudo-p (article)
2574 "Say whether this article is a pseudo article or not."
2575 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2577 (defmacro gnus-summary-article-sparse-p (article)
2578 "Say whether this article is a sparse article or not."
2579 `(memq ,article gnus-newsgroup-sparse))
2581 (defmacro gnus-summary-article-ancient-p (article)
2582 "Say whether this article is a sparse article or not."
2583 `(memq ,article gnus-newsgroup-ancient))
2585 (defun gnus-article-parent-p (number)
2586 "Say whether this article is a parent or not."
2587 (let ((data (gnus-data-find-list number)))
2588 (and (cdr data) ; There has to be an article after...
2589 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2590 (gnus-data-level (nth 1 data))))))
2592 (defun gnus-article-children (number)
2593 "Return a list of all children to NUMBER."
2594 (let* ((data (gnus-data-find-list number))
2595 (level (gnus-data-level (car data)))
2597 (setq data (cdr data))
2599 (= (gnus-data-level (car data)) (1+ level)))
2600 (push (gnus-data-number (car data)) children)
2601 (setq data (cdr data)))
2604 (defmacro gnus-summary-skip-intangible ()
2605 "If the current article is intangible, then jump to a different article."
2606 '(let ((to (get-text-property (point) 'gnus-intangible)))
2607 (and to (gnus-summary-goto-subject to))))
2609 (defmacro gnus-summary-article-intangible-p ()
2610 "Say whether this article is intangible or not."
2611 '(get-text-property (point) 'gnus-intangible))
2613 (defun gnus-article-read-p (article)
2614 "Say whether ARTICLE is read or not."
2615 (not (or (memq article gnus-newsgroup-marked)
2616 (memq article gnus-newsgroup-unreads)
2617 (memq article gnus-newsgroup-unselected)
2618 (memq article gnus-newsgroup-dormant))))
2620 ;; Some summary mode macros.
2622 (defmacro gnus-summary-article-number ()
2623 "The article number of the article on the current line.
2624 If there isn's an article number here, then we return the current
2627 (gnus-summary-skip-intangible)
2628 (or (get-text-property (point) 'gnus-number)
2629 (gnus-summary-last-subject))))
2631 (defmacro gnus-summary-article-header (&optional number)
2632 "Return the header of article NUMBER."
2633 `(gnus-data-header (gnus-data-find
2634 ,(or number '(gnus-summary-article-number)))))
2636 (defmacro gnus-summary-thread-level (&optional number)
2637 "Return the level of thread that starts with article NUMBER."
2638 `(if (and (eq gnus-summary-make-false-root 'dummy)
2639 (get-text-property (point) 'gnus-intangible))
2641 (gnus-data-level (gnus-data-find
2642 ,(or number '(gnus-summary-article-number))))))
2644 (defmacro gnus-summary-article-mark (&optional number)
2645 "Return the mark of article NUMBER."
2646 `(gnus-data-mark (gnus-data-find
2647 ,(or number '(gnus-summary-article-number)))))
2649 (defmacro gnus-summary-article-pos (&optional number)
2650 "Return the position of the line of article NUMBER."
2651 `(gnus-data-pos (gnus-data-find
2652 ,(or number '(gnus-summary-article-number)))))
2654 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2655 (defmacro gnus-summary-article-subject (&optional number)
2656 "Return current subject string or nil if nothing."
2659 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2660 '(gnus-data-header (assq (gnus-summary-article-number)
2661 gnus-newsgroup-data)))))
2664 (mail-header-subject headers))))
2666 (defmacro gnus-summary-article-score (&optional number)
2667 "Return current article score."
2668 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2669 gnus-newsgroup-scored))
2670 gnus-summary-default-score 0))
2672 (defun gnus-summary-article-children (&optional number)
2673 "Return a list of article numbers that are children of article NUMBER."
2674 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2675 (level (gnus-data-level (car data)))
2677 (while (and (setq data (cdr data))
2678 (> (setq l (gnus-data-level (car data))) level))
2679 (and (= (1+ level) l)
2680 (push (gnus-data-number (car data))
2682 (nreverse children)))
2684 (defun gnus-summary-article-parent (&optional number)
2685 "Return the article number of the parent of article NUMBER."
2686 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2687 (gnus-data-list t)))
2688 (level (gnus-data-level (car data))))
2690 () ; This is a root.
2691 ;; We search until we find an article with a level less than
2692 ;; this one. That function has to be the parent.
2693 (while (and (setq data (cdr data))
2694 (not (< (gnus-data-level (car data)) level))))
2695 (and data (gnus-data-number (car data))))))
2697 (defun gnus-unread-mark-p (mark)
2698 "Say whether MARK is the unread mark."
2699 (= mark gnus-unread-mark))
2701 (defun gnus-read-mark-p (mark)
2702 "Say whether MARK is one of the marks that mark as read.
2703 This is all marks except unread, ticked, dormant, and expirable."
2704 (not (or (= mark gnus-unread-mark)
2705 (= mark gnus-ticked-mark)
2706 (= mark gnus-dormant-mark)
2707 (= mark gnus-expirable-mark))))
2709 (defmacro gnus-article-mark (number)
2710 "Return the MARK of article NUMBER.
2711 This macro should only be used when computing the mark the \"first\"
2712 time; i.e., when generating the summary lines. After that,
2713 `gnus-summary-article-mark' should be used to examine the
2716 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2717 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2718 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2719 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2720 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2721 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2722 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2723 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2724 gnus-ancient-mark))))
2726 ;; Saving hidden threads.
2728 (defmacro gnus-save-hidden-threads (&rest forms)
2729 "Save hidden threads, eval FORMS, and restore the hidden threads."
2730 (let ((config (make-symbol "config")))
2731 `(let ((,config (gnus-hidden-threads-configuration)))
2735 (gnus-restore-hidden-threads-configuration ,config)))))
2736 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2737 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2739 (defun gnus-data-compute-positions ()
2740 "Compute the positions of all articles."
2741 (setq gnus-newsgroup-data-reverse nil)
2742 (let ((data gnus-newsgroup-data))
2744 (gnus-save-hidden-threads
2745 (gnus-summary-show-all-threads)
2746 (goto-char (point-min))
2748 (while (get-text-property (point) 'gnus-intangible)
2750 (gnus-data-set-pos (car data) (+ (point) 3))
2751 (setq data (cdr data))
2752 (forward-line 1))))))
2754 (defun gnus-hidden-threads-configuration ()
2755 "Return the current hidden threads configuration."
2758 (goto-char (point-min))
2759 (while (search-forward "\r" nil t)
2760 (push (1- (point)) config))
2763 (defun gnus-restore-hidden-threads-configuration (config)
2764 "Restore hidden threads configuration from CONFIG."
2766 (let (point buffer-read-only)
2767 (while (setq point (pop config))
2768 (when (and (< point (point-max))
2770 (eq (char-after) ?\n))
2771 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2773 ;; Various summary mode internalish functions.
2775 (defun gnus-mouse-pick-article (e)
2778 (gnus-summary-next-page nil t))
2780 (defun gnus-summary-set-display-table ()
2781 "Change the display table.
2782 Odd characters have a tendency to mess
2783 up nicely formatted displays - we make all possible glyphs
2784 display only a single character."
2786 ;; We start from the standard display table, if any.
2787 (let ((table (or (copy-sequence standard-display-table)
2788 (make-display-table)))
2790 ;; Nix out all the control chars...
2791 (while (>= (setq i (1- i)) 0)
2792 (aset table i [??]))
2793 ;; ... but not newline and cr, of course. (cr is necessary for the
2794 ;; selective display).
2795 (aset table ?\n nil)
2796 (aset table ?\r nil)
2797 ;; We keep TAB as well.
2798 (aset table ?\t nil)
2799 ;; We nix out any glyphs over 126 that are not set already.
2801 (while (>= (setq i (1- i)) 127)
2802 ;; Only modify if the entry is nil.
2803 (unless (aref table i)
2804 (aset table i [??]))))
2805 (setq buffer-display-table table)))
2807 (defun gnus-summary-set-article-display-arrow (pos)
2808 "Update the overlay arrow to point to line at position POS."
2809 (when (and gnus-summary-display-arrow
2810 (boundp 'overlay-arrow-position)
2811 (boundp 'overlay-arrow-string))
2815 (unless overlay-arrow-position
2816 (setq overlay-arrow-position (make-marker)))
2817 (setq overlay-arrow-string "=>"
2818 overlay-arrow-position (set-marker overlay-arrow-position
2820 (current-buffer))))))
2822 (defun gnus-summary-buffer-name (group)
2823 "Return the summary buffer name of GROUP."
2824 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2826 (defun gnus-summary-setup-buffer (group)
2827 "Initialize summary buffer."
2828 (let ((buffer (gnus-summary-buffer-name group))
2829 (dead-name (concat "*Dead Summary "
2830 (gnus-group-decoded-name group) "*")))
2831 ;; If a dead summary buffer exists, we kill it.
2832 (when (gnus-buffer-live-p dead-name)
2833 (gnus-kill-buffer dead-name))
2834 (if (get-buffer buffer)
2837 (setq gnus-summary-buffer (current-buffer))
2838 (not gnus-newsgroup-prepared))
2839 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2840 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2841 (gnus-summary-mode group)
2843 (gnus-carpal-setup-buffer 'summary))
2844 (unless gnus-single-article-buffer
2845 (make-local-variable 'gnus-article-buffer)
2846 (make-local-variable 'gnus-article-current)
2847 (make-local-variable 'gnus-original-article-buffer))
2848 (setq gnus-newsgroup-name group)
2849 ;; Set any local variables in the group parameters.
2850 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2853 (defun gnus-set-global-variables ()
2854 "Set the global equivalents of the buffer-local variables.
2855 They are set to the latest values they had. These reflect the summary
2856 buffer that was in action when the last article was fetched."
2857 (when (eq major-mode 'gnus-summary-mode)
2858 (setq gnus-summary-buffer (current-buffer))
2859 (let ((name gnus-newsgroup-name)
2860 (marked gnus-newsgroup-marked)
2861 (unread gnus-newsgroup-unreads)
2862 (headers gnus-current-headers)
2863 (data gnus-newsgroup-data)
2864 (summary gnus-summary-buffer)
2865 (article-buffer gnus-article-buffer)
2866 (original gnus-original-article-buffer)
2867 (gac gnus-article-current)
2868 (reffed gnus-reffed-article-number)
2869 (score-file gnus-current-score-file)
2870 (default-charset gnus-newsgroup-charset)
2872 (let ((locals gnus-newsgroup-variables))
2874 (if (consp (car locals))
2875 (push (eval (caar locals)) vlist)
2876 (push (eval (car locals)) vlist))
2877 (setq locals (cdr locals)))
2878 (setq vlist (nreverse vlist)))
2880 (set-buffer gnus-group-buffer)
2881 (setq gnus-newsgroup-name name
2882 gnus-newsgroup-marked marked
2883 gnus-newsgroup-unreads unread
2884 gnus-current-headers headers
2885 gnus-newsgroup-data data
2886 gnus-article-current gac
2887 gnus-summary-buffer summary
2888 gnus-article-buffer article-buffer
2889 gnus-original-article-buffer original
2890 gnus-reffed-article-number reffed
2891 gnus-current-score-file score-file
2892 gnus-newsgroup-charset default-charset)
2893 (let ((locals gnus-newsgroup-variables))
2895 (if (consp (car locals))
2896 (set (caar locals) (pop vlist))
2897 (set (car locals) (pop vlist)))
2898 (setq locals (cdr locals))))
2899 ;; The article buffer also has local variables.
2900 (when (gnus-buffer-live-p gnus-article-buffer)
2901 (set-buffer gnus-article-buffer)
2902 (setq gnus-summary-buffer summary))))))
2904 (defun gnus-summary-article-unread-p (article)
2905 "Say whether ARTICLE is unread or not."
2906 (memq article gnus-newsgroup-unreads))
2908 (defun gnus-summary-first-article-p (&optional article)
2909 "Return whether ARTICLE is the first article in the buffer."
2910 (if (not (setq article (or article (gnus-summary-article-number))))
2912 (eq article (caar gnus-newsgroup-data))))
2914 (defun gnus-summary-last-article-p (&optional article)
2915 "Return whether ARTICLE is the last article in the buffer."
2916 (if (not (setq article (or article (gnus-summary-article-number))))
2917 ;; All non-existent numbers are the last article. :-)
2919 (not (cdr (gnus-data-find-list article)))))
2921 (defun gnus-make-thread-indent-array ()
2923 (unless (and gnus-thread-indent-array
2924 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2925 (setq gnus-thread-indent-array (make-vector 201 "")
2926 gnus-thread-indent-array-level gnus-thread-indent-level)
2928 (aset gnus-thread-indent-array n
2929 (make-string (* n gnus-thread-indent-level) ? ))
2932 (defun gnus-update-summary-mark-positions ()
2933 "Compute where the summary marks are to go."
2935 (when (gnus-buffer-exists-p gnus-summary-buffer)
2936 (set-buffer gnus-summary-buffer))
2937 (let ((gnus-replied-mark 129)
2938 (gnus-score-below-mark 130)
2939 (gnus-score-over-mark 130)
2940 (gnus-download-mark 131)
2941 (spec gnus-summary-line-format-spec)
2944 (gnus-set-work-buffer)
2945 (let ((gnus-summary-line-format-spec spec)
2946 (gnus-newsgroup-downloadable '((0 . t))))
2947 (gnus-summary-insert-line
2948 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2949 0 nil 128 t nil "" nil 1)
2950 (goto-char (point-min))
2951 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2953 (goto-char (point-min))
2954 (push (cons 'replied (and (search-forward "\201" nil t)
2957 (goto-char (point-min))
2958 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2960 (goto-char (point-min))
2961 (push (cons 'download
2962 (and (search-forward "\203" nil t) (- (point) 2)))
2964 (setq gnus-summary-mark-positions pos))))
2966 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2967 "Insert a dummy root in the summary buffer."
2969 (gnus-add-text-properties
2970 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2971 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2973 (defun gnus-summary-extract-address-component (from)
2974 (or (car (funcall gnus-extract-address-components from))
2977 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2978 (let ((mail-parse-charset gnus-newsgroup-charset)
2979 ; Is it really necessary to do this next part for each summary line?
2980 ; Luckily, doesn't seem to slow things down much.
2981 (mail-parse-ignored-charsets
2982 (save-excursion (set-buffer gnus-summary-buffer)
2983 gnus-newsgroup-ignored-charsets)))
2985 (and gnus-ignored-from-addresses
2986 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2987 (let ((extra-headers (mail-header-extra header))
2991 ((setq to (cdr (assq 'To extra-headers)))
2994 (gnus-summary-extract-address-component
2995 (funcall gnus-decode-encoded-word-function to)))))
2996 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2997 (concat "=> " newsgroups)))))
2998 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3000 (defun gnus-summary-insert-line (gnus-tmp-header
3001 gnus-tmp-level gnus-tmp-current
3002 gnus-tmp-unread gnus-tmp-replied
3003 gnus-tmp-expirable gnus-tmp-subject-or-nil
3004 &optional gnus-tmp-dummy gnus-tmp-score
3006 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3007 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3008 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3009 (gnus-tmp-score-char
3010 (if (or (null gnus-summary-default-score)
3011 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3012 gnus-summary-zcore-fuzz))
3014 (if (< gnus-tmp-score gnus-summary-default-score)
3015 gnus-score-below-mark gnus-score-over-mark)))
3016 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3018 (cond (gnus-tmp-process gnus-process-mark)
3019 ((memq gnus-tmp-current gnus-newsgroup-cached)
3021 (gnus-tmp-replied gnus-replied-mark)
3022 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3023 gnus-forwarded-mark)
3024 ((memq gnus-tmp-current gnus-newsgroup-saved)
3026 ((memq gnus-tmp-number gnus-newsgroup-recent)
3028 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3031 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3034 ((string-match "<[^>]+> *$" gnus-tmp-from)
3035 (let ((beg (match-beginning 0)))
3036 (or (and (string-match "^\".+\"" gnus-tmp-from)
3037 (substring gnus-tmp-from 1 (1- (match-end 0))))
3038 (substring gnus-tmp-from 0 beg))))
3039 ((string-match "(.+)" gnus-tmp-from)
3040 (substring gnus-tmp-from
3041 (1+ (match-beginning 0)) (1- (match-end 0))))
3043 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3044 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3045 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3046 (buffer-read-only nil))
3047 (when (string= gnus-tmp-name "")
3048 (setq gnus-tmp-name gnus-tmp-from))
3049 (unless (numberp gnus-tmp-lines)
3050 (setq gnus-tmp-lines -1))
3051 (if (= gnus-tmp-lines -1)
3052 (setq gnus-tmp-lines "?")
3053 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3054 (gnus-put-text-property
3056 (progn (eval gnus-summary-line-format-spec) (point))
3057 'gnus-number gnus-tmp-number)
3058 (when (gnus-visual-p 'summary-highlight 'highlight)
3060 (gnus-run-hooks 'gnus-summary-update-hook)
3063 (defun gnus-summary-update-line (&optional dont-update)
3064 "Update summary line after change."
3065 (when (and gnus-summary-default-score
3066 (not gnus-summary-inhibit-highlight))
3067 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3068 (article (gnus-summary-article-number))
3069 (score (gnus-summary-article-score article)))
3071 (if (and gnus-summary-mark-below
3072 (< (gnus-summary-article-score)
3073 gnus-summary-mark-below))
3074 ;; This article has a low score, so we mark it as read.
3075 (when (memq article gnus-newsgroup-unreads)
3076 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3077 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3078 ;; This article was previously marked as read on account
3079 ;; of a low score, but now it has risen, so we mark it as
3081 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3082 (gnus-summary-update-mark
3083 (if (or (null gnus-summary-default-score)
3084 (<= (abs (- score gnus-summary-default-score))
3085 gnus-summary-zcore-fuzz))
3087 (if (< score gnus-summary-default-score)
3088 gnus-score-below-mark gnus-score-over-mark))
3090 ;; Do visual highlighting.
3091 (when (gnus-visual-p 'summary-highlight 'highlight)
3092 (gnus-run-hooks 'gnus-summary-update-hook)))))
3094 (defvar gnus-tmp-new-adopts nil)
3096 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3097 "Return the number of articles in THREAD.
3098 This may be 0 in some cases -- if none of the articles in
3099 the thread are to be displayed."
3101 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3103 ((not (listp thread))
3105 ((and (consp thread) (cdr thread))
3108 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3111 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3114 (when (and level (zerop level) gnus-tmp-new-adopts)
3117 'gnus-summary-number-of-articles-in-thread
3118 gnus-tmp-new-adopts))))
3120 (if (> number 1) gnus-not-empty-thread-mark
3121 gnus-empty-thread-mark)
3124 (defun gnus-summary-set-local-parameters (group)
3125 "Go through the local params of GROUP and set all variable specs in that list."
3126 (let ((params (gnus-group-find-parameter group))
3127 (vars '(quit-config)) ; Ignore quit-config.
3130 (setq elem (car params)
3131 params (cdr params))
3132 (and (consp elem) ; Has to be a cons.
3133 (consp (cdr elem)) ; The cdr has to be a list.
3134 (symbolp (car elem)) ; Has to be a symbol in there.
3135 (not (memq (car elem) vars))
3136 (ignore-errors ; So we set it.
3137 (push (car elem) vars)
3138 (make-local-variable (car elem))
3139 (set (car elem) (eval (nth 1 elem))))))))
3141 (defun gnus-summary-read-group (group &optional show-all no-article
3142 kill-buffer no-display backward
3144 "Start reading news in newsgroup GROUP.
3145 If SHOW-ALL is non-nil, already read articles are also listed.
3146 If NO-ARTICLE is non-nil, no article is selected initially.
3147 If NO-DISPLAY, don't generate a summary buffer."
3151 (let ((gnus-auto-select-next nil))
3152 (or (gnus-summary-read-group-1
3153 group show-all no-article
3154 kill-buffer no-display
3157 select-articles nil)))))
3158 (eq gnus-auto-select-next 'quietly))
3159 (set-buffer gnus-group-buffer)
3160 ;; The entry function called above goes to the next
3161 ;; group automatically, so we go two groups back
3162 ;; if we are searching for the previous group.
3164 (gnus-group-prev-unread-group 2))
3165 (if (not (equal group (gnus-group-group-name)))
3166 (setq group (gnus-group-group-name))
3170 (defun gnus-summary-read-group-1 (group show-all no-article
3171 kill-buffer no-display
3172 &optional select-articles)
3173 ;; Killed foreign groups can't be entered.
3174 ;; (when (and (not (gnus-group-native-p group))
3175 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3176 ;; (error "Dead non-native groups can't be entered"))
3177 (gnus-message 5 "Retrieving newsgroup: %s..."
3178 (gnus-group-decoded-name group))
3179 (let* ((new-group (gnus-summary-setup-buffer group))
3180 (quit-config (gnus-group-quit-config group))
3181 (did-select (and new-group (gnus-select-newsgroup
3182 group show-all select-articles))))
3184 ;; This summary buffer exists already, so we just select it.
3186 (gnus-set-global-variables)
3188 (gnus-kill-or-deaden-summary kill-buffer))
3189 (gnus-configure-windows 'summary 'force)
3190 (gnus-set-mode-line 'summary)
3191 (gnus-summary-position-point)
3194 ;; We couldn't select this group.
3196 (when (and (eq major-mode 'gnus-summary-mode)
3197 (not (equal (current-buffer) kill-buffer)))
3198 (kill-buffer (current-buffer))
3199 (if (not quit-config)
3201 ;; Update the info -- marks might need to be removed,
3203 (gnus-summary-update-info)
3204 (set-buffer gnus-group-buffer)
3205 (gnus-group-jump-to-group group)
3206 (gnus-group-next-unread-group 1))
3207 (gnus-handle-ephemeral-exit quit-config)))
3208 (let ((grpinfo (gnus-get-info group)))
3209 (if (null (gnus-info-read grpinfo))
3210 (gnus-message 3 "Group %s contains no messages"
3211 (gnus-group-decoded-name group))
3212 (gnus-message 3 "Can't select group")))
3214 ;; The user did a `C-g' while prompting for number of articles,
3215 ;; so we exit this group.
3216 ((eq did-select 'quit)
3217 (and (eq major-mode 'gnus-summary-mode)
3218 (not (equal (current-buffer) kill-buffer))
3219 (kill-buffer (current-buffer)))
3221 (gnus-kill-or-deaden-summary kill-buffer))
3222 (if (not quit-config)
3224 (set-buffer gnus-group-buffer)
3225 (gnus-group-jump-to-group group)
3226 (gnus-group-next-unread-group 1)
3227 (gnus-configure-windows 'group 'force))
3228 (gnus-handle-ephemeral-exit quit-config))
3229 ;; Finally signal the quit.
3231 ;; The group was successfully selected.
3233 (gnus-set-global-variables)
3234 ;; Save the active value in effect when the group was entered.
3235 (setq gnus-newsgroup-active
3237 (gnus-active gnus-newsgroup-name)))
3238 ;; You can change the summary buffer in some way with this hook.
3239 (gnus-run-hooks 'gnus-select-group-hook)
3240 (gnus-update-format-specifications
3241 nil 'summary 'summary-mode 'summary-dummy)
3242 (gnus-update-summary-mark-positions)
3243 ;; Do score processing.
3244 (when gnus-use-scoring
3245 (gnus-possibly-score-headers))
3246 ;; Check whether to fill in the gaps in the threads.
3247 (when gnus-build-sparse-threads
3248 (gnus-build-sparse-threads))
3249 ;; Find the initial limit.
3250 (if gnus-show-threads
3252 (let ((gnus-newsgroup-dormant nil))
3253 (gnus-summary-initial-limit show-all))
3254 (gnus-summary-initial-limit show-all))
3255 ;; When untreaded, all articles are always shown.
3256 (setq gnus-newsgroup-limit
3258 (lambda (header) (mail-header-number header))
3259 gnus-newsgroup-headers)))
3260 ;; Generate the summary buffer.
3262 (gnus-summary-prepare))
3263 (when gnus-use-trees
3264 (gnus-tree-open group)
3265 (setq gnus-summary-highlight-line-function
3266 'gnus-tree-highlight-article))
3267 ;; If the summary buffer is empty, but there are some low-scored
3268 ;; articles or some excluded dormants, we include these in the
3270 (when (and (zerop (buffer-size))
3272 (cond (gnus-newsgroup-dormant
3273 (gnus-summary-limit-include-dormant))
3274 ((and gnus-newsgroup-scored show-all)
3275 (gnus-summary-limit-include-expunged t))))
3276 ;; Function `gnus-apply-kill-file' must be called in this hook.
3277 (gnus-run-hooks 'gnus-apply-kill-hook)
3278 (if (and (zerop (buffer-size))
3281 ;; This newsgroup is empty.
3282 (gnus-summary-catchup-and-exit nil t)
3283 (gnus-message 6 "No unread news")
3285 (gnus-kill-or-deaden-summary kill-buffer))
3286 ;; Return nil from this function.
3288 ;; Hide conversation thread subtrees. We cannot do this in
3289 ;; gnus-summary-prepare-hook since kill processing may not
3290 ;; work with hidden articles.
3291 (gnus-summary-maybe-hide-threads)
3293 (gnus-kill-or-deaden-summary kill-buffer))
3294 (gnus-summary-auto-select-subject)
3295 ;; Show first unread article if requested.
3296 (if (and (not no-article)
3298 gnus-newsgroup-unreads
3299 gnus-auto-select-first)
3301 (gnus-configure-windows 'summary)
3302 (let ((art (gnus-summary-article-number)))
3303 (unless (or (memq art gnus-newsgroup-undownloaded)
3304 (memq art gnus-newsgroup-downloadable))
3305 (gnus-summary-goto-article art))))
3306 ;; Don't select any articles.
3307 (gnus-summary-position-point)
3308 (gnus-configure-windows 'summary 'force)
3309 (gnus-set-mode-line 'summary))
3310 (when (get-buffer-window gnus-group-buffer t)
3311 ;; Gotta use windows, because recenter does weird stuff if
3312 ;; the current buffer ain't the displayed window.
3313 (let ((owin (selected-window)))
3314 (select-window (get-buffer-window gnus-group-buffer t))
3315 (when (gnus-group-goto-group group)
3317 (select-window owin)))
3318 ;; Mark this buffer as "prepared".
3319 (setq gnus-newsgroup-prepared t)
3320 (gnus-run-hooks 'gnus-summary-prepared-hook)
3323 (defun gnus-summary-auto-select-subject ()
3324 "Select the subject line on initial group entry."
3325 (goto-char (point-min))
3327 ((eq gnus-auto-select-subject 'best)
3328 (gnus-summary-best-unread-subject))
3329 ((eq gnus-auto-select-subject 'unread)
3330 (gnus-summary-first-unread-subject))
3331 ((eq gnus-auto-select-subject 'unseen)
3332 (gnus-summary-first-unseen-subject))
3333 ((eq gnus-auto-select-subject 'unseen-or-unread)
3334 (gnus-summary-first-unseen-or-unread-subject))
3335 ((eq gnus-auto-select-subject 'first)
3338 ((gnus-functionp gnus-auto-select-subject)
3339 (funcall gnus-auto-select-subject))))
3341 (defun gnus-summary-prepare ()
3342 "Generate the summary buffer."
3344 (let ((buffer-read-only nil))
3346 (setq gnus-newsgroup-data nil
3347 gnus-newsgroup-data-reverse nil)
3348 (gnus-run-hooks 'gnus-summary-generate-hook)
3349 ;; Generate the buffer, either with threads or without.
3350 (when gnus-newsgroup-headers
3351 (gnus-summary-prepare-threads
3352 (if gnus-show-threads
3353 (gnus-sort-gathered-threads
3354 (funcall gnus-summary-thread-gathering-function
3356 (gnus-cut-threads (gnus-make-threads)))))
3357 ;; Unthreaded display.
3358 (gnus-sort-articles gnus-newsgroup-headers))))
3359 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3360 ;; Call hooks for modifying summary buffer.
3361 (goto-char (point-min))
3362 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3364 (defsubst gnus-general-simplify-subject (subject)
3365 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3368 ;; Truncate the subject.
3369 (gnus-simplify-subject-functions
3370 (gnus-map-function gnus-simplify-subject-functions subject))
3371 ((numberp gnus-summary-gather-subject-limit)
3372 (setq subject (gnus-simplify-subject-re subject))
3373 (if (> (length subject) gnus-summary-gather-subject-limit)
3374 (substring subject 0 gnus-summary-gather-subject-limit)
3376 ;; Fuzzily simplify it.
3377 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3378 (gnus-simplify-subject-fuzzy subject))
3379 ;; Just remove the leading "Re:".
3381 (gnus-simplify-subject-re subject))))
3383 (if (and gnus-summary-gather-exclude-subject
3384 (string-match gnus-summary-gather-exclude-subject subject))
3385 nil ; This article shouldn't be gathered
3388 (defun gnus-summary-simplify-subject-query ()
3389 "Query where the respool algorithm would put this article."
3391 (gnus-summary-select-article)
3392 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3394 (defun gnus-gather-threads-by-subject (threads)
3395 "Gather threads by looking at Subject headers."
3396 (if (not gnus-summary-make-false-root)
3398 (let ((hashtb (gnus-make-hashtable 1024))
3401 subject hthread whole-subject)
3403 (setq subject (gnus-general-simplify-subject
3404 (setq whole-subject (mail-header-subject
3407 (if (setq hthread (gnus-gethash subject hashtb))
3409 ;; We enter a dummy root into the thread, if we
3410 ;; haven't done that already.
3411 (unless (stringp (caar hthread))
3412 (setcar hthread (list whole-subject (car hthread))))
3413 ;; We add this new gathered thread to this gathered
3415 (setcdr (car hthread)
3416 (nconc (cdar hthread) (list (car threads))))
3417 ;; Remove it from the list of threads.
3418 (setcdr prev (cdr threads))
3419 (setq threads prev))
3420 ;; Enter this thread into the hash table.
3421 (gnus-sethash subject threads hashtb)))
3423 (setq threads (cdr threads)))
3426 (defun gnus-gather-threads-by-references (threads)
3427 "Gather threads by looking at References headers."
3428 (let ((idhashtb (gnus-make-hashtable 1024))
3429 (thhashtb (gnus-make-hashtable 1024))
3432 ids references id gthread gid entered ref)
3434 (when (setq references (mail-header-references (caar threads)))
3435 (setq id (mail-header-id (caar threads))
3436 ids (inline (gnus-split-references references))
3438 (while (setq ref (pop ids))
3439 (setq ids (delete ref ids))
3440 (if (not (setq gid (gnus-gethash ref idhashtb)))
3442 (gnus-sethash ref id idhashtb)
3443 (gnus-sethash id threads thhashtb))
3444 (setq gthread (gnus-gethash gid thhashtb))
3446 ;; We enter a dummy root into the thread, if we
3447 ;; haven't done that already.
3448 (unless (stringp (caar gthread))
3449 (setcar gthread (list (mail-header-subject (caar gthread))
3451 ;; We add this new gathered thread to this gathered
3453 (setcdr (car gthread)
3454 (nconc (cdar gthread) (list (car threads)))))
3455 ;; Add it into the thread hash table.
3456 (gnus-sethash id gthread thhashtb)
3458 ;; Remove it from the list of threads.
3459 (setcdr prev (cdr threads))
3460 (setq threads prev))))
3462 (setq threads (cdr threads)))
3465 (defun gnus-sort-gathered-threads (threads)
3466 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3467 (let ((result threads))
3469 (when (stringp (caar threads))
3470 (setcdr (car threads)
3471 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3472 (setq threads (cdr threads)))
3475 (defun gnus-thread-loop-p (root thread)
3476 "Say whether ROOT is in THREAD."
3477 (let ((stack (list thread))
3480 (while (setq thread (pop stack))
3481 (setq th (cdr thread))
3483 (not (eq (caar th) root)))
3486 ;; We have found a loop.
3488 (setcdr thread (delq (car th) (cdr thread)))
3489 (if (boundp (setq ref-dep (intern "none"
3490 gnus-newsgroup-dependencies)))
3491 (setcdr (symbol-value ref-dep)
3492 (nconc (cdr (symbol-value ref-dep))
3494 (set ref-dep (list nil (car th))))
3497 ;; Push all the subthreads onto the stack.
3498 (push (cdr thread) stack)))
3501 (defun gnus-make-threads ()
3502 "Go through the dependency hashtb and find the roots. Return all threads."
3504 (while (catch 'infloop
3507 ;; Deal with self-referencing References loops.
3508 (when (and (car (symbol-value refs))
3515 (car (symbol-value refs)) thread))
3516 (cdr (symbol-value refs)))))))
3519 (unless (car (symbol-value refs))
3520 ;; These threads do not refer back to any other articles,
3521 ;; so they're roots.
3522 (setq threads (append (cdr (symbol-value refs)) threads))))
3523 gnus-newsgroup-dependencies)))
3526 ;; Build the thread tree.
3527 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3528 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3530 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3531 if it was already present.
3533 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3534 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3535 Message-IDs will be renamed be renamed to a unique Message-ID before
3538 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3539 (let* ((id (mail-header-id header))
3540 (id-dep (and id (intern id dependencies)))
3541 ref ref-dep ref-header)
3542 ;; Enter this `header' in the `dependencies' table.
3546 ;; The first two cases do the normal part: enter a new `header'
3547 ;; in the `dependencies' table.
3548 ((not (boundp id-dep))
3549 (set id-dep (list header)))
3550 ((null (car (symbol-value id-dep)))
3551 (setcar (symbol-value id-dep) header))
3553 ;; From here the `header' was already present in the
3554 ;; `dependencies' table.
3556 ;; Overrides an existing entry;
3557 ;; just set the header part of the entry.
3558 (setcar (symbol-value id-dep) header))
3560 ;; Renames the existing `header' to a unique Message-ID.
3561 ((not gnus-summary-ignore-duplicates)
3562 ;; An article with this Message-ID has already been seen.
3563 ;; We rename the Message-ID.
3564 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3566 (mail-header-set-id header id))
3568 ;; The last case ignores an existing entry, except it adds any
3569 ;; additional Xrefs (in case the two articles came from different
3571 ;; Also sets `header' to `nil' meaning that the `dependencies'
3572 ;; table was *not* modified.
3574 (mail-header-set-xref
3575 (car (symbol-value id-dep))
3576 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3578 (or (mail-header-xref header) "")))
3582 ;; First check that we are not creating a References loop.
3583 (setq ref (gnus-parent-id (mail-header-references header)))
3585 (setq ref-dep (intern-soft ref dependencies))
3587 (setq ref-header (car (symbol-value ref-dep))))
3588 (if (string= id ref)
3589 ;; Yuk! This is a reference loop. Make the article be a
3592 (mail-header-set-references (car (symbol-value id-dep)) "none")
3594 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3595 (setq ref (gnus-parent-id (mail-header-references header)))
3596 (setq ref-dep (intern (or ref "none") dependencies))
3597 (if (boundp ref-dep)
3598 (setcdr (symbol-value ref-dep)
3599 (nconc (cdr (symbol-value ref-dep))
3600 (list (symbol-value id-dep))))
3601 (set ref-dep (list nil (symbol-value id-dep)))))
3604 (defun gnus-extract-message-id-from-in-reply-to (string)
3605 (if (string-match "<[^>]+>" string)
3606 (substring string (match-beginning 0) (match-end 0))
3609 (defun gnus-build-sparse-threads ()
3610 (let ((headers gnus-newsgroup-headers)
3611 (mail-parse-charset gnus-newsgroup-charset)
3612 (gnus-summary-ignore-duplicates t)
3613 header references generation relations
3614 subject child end new-child date)
3615 ;; First we create an alist of generations/relations, where
3616 ;; generations is how much we trust the relation, and the relation
3618 (gnus-message 7 "Making sparse threads...")
3620 (nnheader-set-temp-buffer " *gnus sparse threads*")
3621 (while (setq header (pop headers))
3622 (when (and (setq references (mail-header-references header))
3623 (not (string= references "")))
3625 (setq child (mail-header-id header)
3626 subject (mail-header-subject header)
3627 date (mail-header-date header)
3629 (while (search-backward ">" nil t)
3630 (setq end (1+ (point)))
3631 (when (search-backward "<" nil t)
3632 (setq new-child (buffer-substring (point) end))
3633 (push (list (incf generation)
3634 child (setq child new-child)
3638 (push (list (1+ generation) child nil subject) relations))
3640 (kill-buffer (current-buffer)))
3641 ;; Sort over trustworthiness.
3644 (when (gnus-dependencies-add-header
3645 (make-full-mail-header
3646 gnus-reffed-article-number
3647 (nth 3 relation) "" (or (nth 4 relation) "")
3649 (or (nth 2 relation) "") 0 0 "")
3650 gnus-newsgroup-dependencies nil)
3651 (push gnus-reffed-article-number gnus-newsgroup-limit)
3652 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3653 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3654 gnus-newsgroup-reads)
3655 (decf gnus-reffed-article-number)))
3656 (sort relations 'car-less-than-car))
3657 (gnus-message 7 "Making sparse threads...done")))
3659 (defun gnus-build-old-threads ()
3660 ;; Look at all the articles that refer back to old articles, and
3661 ;; fetch the headers for the articles that aren't there. This will
3662 ;; build complete threads - if the roots haven't been expired by the
3664 (let ((mail-parse-charset gnus-newsgroup-charset)
3668 (when (not (car (symbol-value refs)))
3669 (setq heads (cdr (symbol-value refs)))
3671 (if (memq (mail-header-number (caar heads))
3672 gnus-newsgroup-dormant)
3673 (setq heads (cdr heads))
3674 (setq id (symbol-name refs))
3675 (while (and (setq id (gnus-build-get-header id))
3676 (not (car (gnus-id-to-thread id)))))
3677 (setq heads nil)))))
3678 gnus-newsgroup-dependencies)))
3680 ;; This function has to be called with point after the article number
3681 ;; on the beginning of the line.
3682 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3683 (let ((eol (gnus-point-at-eol))
3684 (buffer (current-buffer))
3685 header references in-reply-to)
3687 ;; overview: [num subject from date id refs chars lines misc]
3690 (narrow-to-region (point) eol)
3695 (make-full-mail-header
3697 (funcall gnus-decode-encoded-word-function
3698 (nnheader-nov-field)) ; subject
3699 (funcall gnus-decode-encoded-word-function
3700 (nnheader-nov-field)) ; from
3701 (nnheader-nov-field) ; date
3702 (nnheader-nov-read-message-id) ; id
3703 (setq references (nnheader-nov-field)) ; refs
3704 (nnheader-nov-read-integer) ; chars
3705 (nnheader-nov-read-integer) ; lines
3707 (if (looking-at "Xref: ")
3708 (goto-char (match-end 0)))
3709 (nnheader-nov-field)) ; Xref
3710 (nnheader-nov-parse-extra)))) ; extra
3714 (when (and (string= references "")
3715 (setq in-reply-to (mail-header-extra header))
3716 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3717 (mail-header-set-references
3718 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3720 (when gnus-alter-header-function
3721 (funcall gnus-alter-header-function header))
3722 (gnus-dependencies-add-header header dependencies force-new)))
3724 (defun gnus-build-get-header (id)
3725 "Look through the buffer of NOV lines and find the header to ID.
3726 Enter this line into the dependencies hash table, and return
3727 the id of the parent article (if any)."
3728 (let ((deps gnus-newsgroup-dependencies)
3732 (set-buffer nntp-server-buffer)
3733 (let ((case-fold-search nil))
3734 (goto-char (point-min))
3735 (while (and (not found)
3736 (search-forward id nil t))
3738 (setq found (looking-at
3739 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3740 (regexp-quote id))))
3741 (or found (beginning-of-line 2)))
3745 (setq header (gnus-nov-parse-line
3746 (read (current-buffer)) deps))
3747 (gnus-parent-id (mail-header-references header))))))
3749 (let ((number (mail-header-number header)))
3750 (push number gnus-newsgroup-limit)
3751 (push header gnus-newsgroup-headers)
3752 (if (memq number gnus-newsgroup-unselected)
3754 (setq gnus-newsgroup-unselected
3755 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3757 (setq gnus-newsgroup-unselected
3758 (delq number gnus-newsgroup-unselected)))
3759 (push number gnus-newsgroup-ancient)))))))
3761 (defun gnus-build-all-threads ()
3762 "Read all the headers."
3763 (let ((gnus-summary-ignore-duplicates t)
3764 (mail-parse-charset gnus-newsgroup-charset)
3765 (dependencies gnus-newsgroup-dependencies)
3768 (set-buffer nntp-server-buffer)
3769 (let ((case-fold-search nil))
3770 (goto-char (point-min))
3773 (setq article (read (current-buffer))
3774 header (gnus-nov-parse-line article dependencies)))
3777 (set-buffer gnus-summary-buffer)
3778 (push header gnus-newsgroup-headers)
3779 (if (memq (setq article (mail-header-number header))
3780 gnus-newsgroup-unselected)
3782 (push article gnus-newsgroup-unreads)
3783 (setq gnus-newsgroup-unselected
3784 (delq article gnus-newsgroup-unselected)))
3785 (push article gnus-newsgroup-ancient)))
3786 (forward-line 1)))))))
3788 (defun gnus-summary-update-article-line (article header)
3789 "Update the line for ARTICLE using HEADERS."
3790 (let* ((id (mail-header-id header))
3791 (thread (gnus-id-to-thread id)))
3793 (error "Article in no thread"))
3794 ;; Update the thread.
3795 (setcar thread header)
3796 (gnus-summary-goto-subject article)
3797 (let* ((datal (gnus-data-find-list article))
3799 (length (when (cdr datal)
3800 (- (gnus-data-pos data)
3801 (gnus-data-pos (cadr datal)))))
3802 (buffer-read-only nil)
3803 (level (gnus-summary-thread-level)))
3805 (gnus-summary-insert-line
3806 header level nil (gnus-article-mark article)
3807 (memq article gnus-newsgroup-replied)
3808 (memq article gnus-newsgroup-expirable)
3809 ;; Only insert the Subject string when it's different
3810 ;; from the previous Subject string.
3815 (mail-header-subject
3818 (gnus-data-find-list
3820 (gnus-data-list t)))))
3821 ;; Error on the side of excessive subjects.
3823 (mail-header-subject header)))
3825 (mail-header-subject header))
3826 nil (cdr (assq article gnus-newsgroup-scored))
3827 (memq article gnus-newsgroup-processable))
3829 (gnus-data-update-list
3830 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3832 (defun gnus-summary-update-article (article &optional iheader)
3833 "Update ARTICLE in the summary buffer."
3834 (set-buffer gnus-summary-buffer)
3835 (let* ((header (gnus-summary-article-header article))
3836 (id (mail-header-id header))
3837 (data (gnus-data-find article))
3838 (thread (gnus-id-to-thread id))
3839 (references (mail-header-references header))
3843 (when (and references
3844 (not (equal "" references)))
3847 (buffer-read-only nil)
3853 (delq thread parent)))
3854 (if (gnus-summary-insert-subject id header)
3855 ;; Set the (possibly) new article number in the data structure.
3856 (gnus-data-set-number data (gnus-id-to-article id))
3860 (defun gnus-rebuild-thread (id &optional line)
3861 "Rebuild the thread containing ID.
3862 If LINE, insert the rebuilt thread starting on line LINE."
3863 (let ((buffer-read-only nil)
3864 old-pos current thread data)
3865 (if (not gnus-show-threads)
3866 (setq thread (list (car (gnus-id-to-thread id))))
3867 ;; Get the thread this article is part of.
3868 (setq thread (gnus-remove-thread id)))
3869 (setq old-pos (gnus-point-at-bol))
3870 (setq current (save-excursion
3871 (and (re-search-backward "[\r\n]" nil t)
3872 (gnus-summary-article-number))))
3873 ;; If this is a gathered thread, we have to go some re-gathering.
3874 (when (stringp (car thread))
3875 (let ((subject (car thread))
3877 (setq thread (cdr thread))
3879 (unless (memq (setq thr (gnus-id-to-thread
3881 (mail-header-id (caar thread)))))
3884 (setq thread (cdr thread)))
3885 ;; We now have all (unique) roots.
3886 (if (= (length roots) 1)
3887 ;; All the loose roots are now one solid root.
3888 (setq thread (car roots))
3889 (setq thread (cons subject (gnus-sort-threads roots))))))
3891 ;; We then insert this thread into the summary buffer.
3893 (goto-char (point-min))
3894 (forward-line (1- line)))
3895 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3896 (if gnus-show-threads
3897 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3898 (gnus-summary-prepare-unthreaded thread))
3899 (setq data (nreverse gnus-newsgroup-data))
3900 (setq threads gnus-newsgroup-threads))
3901 ;; We splice the new data into the data structure.
3902 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3903 ;;!!! then we want to insert at the beginning of the buffer.
3904 ;;!!! That happens to be true with Gnus now, but that may
3905 ;;!!! change in the future. Perhaps.
3906 (gnus-data-enter-list
3907 (if line nil current) data (- (point) old-pos))
3908 (setq gnus-newsgroup-threads
3909 (nconc threads gnus-newsgroup-threads))
3910 (gnus-data-compute-positions))))
3912 (defun gnus-number-to-header (number)
3913 "Return the header for article NUMBER."
3914 (let ((headers gnus-newsgroup-headers))
3916 (not (= number (mail-header-number (car headers)))))
3921 (defun gnus-parent-headers (in-headers &optional generation)
3922 "Return the headers of the GENERATIONeth parent of HEADERS."
3924 (setq generation 1))
3926 (headers in-headers)
3929 (not (zerop generation))
3930 (setq references (mail-header-references headers)))
3931 (setq headers (if (and references
3932 (setq parent (gnus-parent-id references)))
3933 (car (gnus-id-to-thread parent))
3936 (and (not (eq headers in-headers))
3939 (defun gnus-id-to-thread (id)
3940 "Return the (sub-)thread where ID appears."
3941 (gnus-gethash id gnus-newsgroup-dependencies))
3943 (defun gnus-id-to-article (id)
3944 "Return the article number of ID."
3945 (let ((thread (gnus-id-to-thread id)))
3948 (mail-header-number (car thread)))))
3950 (defun gnus-id-to-header (id)
3951 "Return the article headers of ID."
3952 (car (gnus-id-to-thread id)))
3954 (defun gnus-article-displayed-root-p (article)
3955 "Say whether ARTICLE is a root(ish) article."
3956 (let ((level (gnus-summary-thread-level article))
3957 (refs (mail-header-references (gnus-summary-article-header article)))
3963 ((null (gnus-parent-id refs)) t)
3965 (null (setq particle (gnus-id-to-article
3966 (gnus-parent-id refs))))
3967 (null (gnus-summary-thread-level particle)))))))
3969 (defun gnus-root-id (id)
3970 "Return the id of the root of the thread where ID appears."
3972 (while (and id (setq prev (car (gnus-id-to-thread id))))
3974 id (gnus-parent-id (mail-header-references prev))))
3977 (defun gnus-articles-in-thread (thread)
3978 "Return the list of articles in THREAD."
3979 (cons (mail-header-number (car thread))
3980 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3982 (defun gnus-remove-thread (id &optional dont-remove)
3983 "Remove the thread that has ID in it."
3984 (let (headers thread last-id)
3985 ;; First go up in this thread until we find the root.
3986 (setq last-id (gnus-root-id id)
3987 headers (message-flatten-list (gnus-id-to-thread last-id)))
3988 ;; We have now found the real root of this thread. It might have
3989 ;; been gathered into some loose thread, so we have to search
3990 ;; through the threads to find the thread we wanted.
3991 (let ((threads gnus-newsgroup-threads)
3994 (setq sub (car threads))
3995 (if (stringp (car sub))
3996 ;; This is a gathered thread, so we look at the roots
3997 ;; below it to find whether this article is in this
4000 (setq sub (cdr sub))
4002 (when (member (caar sub) headers)
4003 (setq thread (car threads)
4006 (setq sub (cdr sub))))
4007 ;; It's an ordinary thread, so we check it.
4008 (when (eq (car sub) (car headers))
4011 (setq threads (cdr threads)))
4012 ;; If this article is in no thread, then it's a root.
4015 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4016 (setq thread (gnus-id-to-thread last-id)))
4019 thread ; We return this thread.
4021 (if (stringp (car thread))
4023 ;; If we use dummy roots, then we have to remove the
4024 ;; dummy root as well.
4025 (when (eq gnus-summary-make-false-root 'dummy)
4026 ;; We go to the dummy root by going to
4027 ;; the first sub-"thread", and then one line up.
4028 (gnus-summary-goto-article
4029 (mail-header-number (caadr thread)))
4032 (gnus-data-compute-positions))
4033 (setq thread (cdr thread))
4035 (gnus-remove-thread-1 (car thread))
4036 (setq thread (cdr thread))))
4037 (gnus-remove-thread-1 thread))))))))
4039 (defun gnus-remove-thread-1 (thread)
4040 "Remove the thread THREAD recursively."
4041 (let ((number (mail-header-number (pop thread)))
4043 (setq thread (reverse thread))
4045 (gnus-remove-thread-1 (pop thread)))
4046 (when (setq d (gnus-data-find number))
4047 (goto-char (gnus-data-pos d))
4048 (gnus-summary-show-thread)
4051 (- (gnus-point-at-bol)
4053 (1+ (gnus-point-at-eol))
4054 (gnus-delete-line)))))))
4056 (defun gnus-sort-threads-1 (threads func)
4057 (sort (mapcar (lambda (thread)
4060 (gnus-sort-threads-1 (cdr thread) func))))
4063 (defun gnus-sort-threads (threads)
4065 (if (not gnus-thread-sort-functions)
4067 (gnus-message 8 "Sorting threads...")
4069 (gnus-sort-threads-1
4071 (gnus-make-sort-function gnus-thread-sort-functions))
4072 (gnus-message 8 "Sorting threads...done"))))
4074 (defun gnus-sort-articles (articles)
4076 (when gnus-article-sort-functions
4077 (gnus-message 7 "Sorting articles...")
4079 (setq gnus-newsgroup-headers
4080 (sort articles (gnus-make-sort-function
4081 gnus-article-sort-functions)))
4082 (gnus-message 7 "Sorting articles...done"))))
4084 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4085 (defmacro gnus-thread-header (thread)
4086 "Return header of first article in THREAD.
4087 Note that THREAD must never, ever be anything else than a variable -
4088 using some other form will lead to serious barfage."
4089 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4090 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4091 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4094 (defsubst gnus-article-sort-by-number (h1 h2)
4095 "Sort articles by article number."
4096 (< (mail-header-number h1)
4097 (mail-header-number h2)))
4099 (defun gnus-thread-sort-by-number (h1 h2)
4100 "Sort threads by root article number."
4101 (gnus-article-sort-by-number
4102 (gnus-thread-header h1) (gnus-thread-header h2)))
4104 (defsubst gnus-article-sort-by-lines (h1 h2)
4105 "Sort articles by article Lines header."
4106 (< (mail-header-lines h1)
4107 (mail-header-lines h2)))
4109 (defun gnus-thread-sort-by-lines (h1 h2)
4110 "Sort threads by root article Lines header."
4111 (gnus-article-sort-by-lines
4112 (gnus-thread-header h1) (gnus-thread-header h2)))
4114 (defsubst gnus-article-sort-by-chars (h1 h2)
4115 "Sort articles by octet length."
4116 (< (mail-header-chars h1)
4117 (mail-header-chars h2)))
4119 (defun gnus-thread-sort-by-chars (h1 h2)
4120 "Sort threads by root article octet length."
4121 (gnus-article-sort-by-chars
4122 (gnus-thread-header h1) (gnus-thread-header h2)))
4124 (defsubst gnus-article-sort-by-author (h1 h2)
4125 "Sort articles by root author."
4127 (let ((extract (funcall
4128 gnus-extract-address-components
4129 (mail-header-from h1))))
4130 (or (car extract) (cadr extract) ""))
4131 (let ((extract (funcall
4132 gnus-extract-address-components
4133 (mail-header-from h2))))
4134 (or (car extract) (cadr extract) ""))))
4136 (defun gnus-thread-sort-by-author (h1 h2)
4137 "Sort threads by root author."
4138 (gnus-article-sort-by-author
4139 (gnus-thread-header h1) (gnus-thread-header h2)))
4141 (defsubst gnus-article-sort-by-subject (h1 h2)
4142 "Sort articles by root subject."
4144 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4145 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4147 (defun gnus-thread-sort-by-subject (h1 h2)
4148 "Sort threads by root subject."
4149 (gnus-article-sort-by-subject
4150 (gnus-thread-header h1) (gnus-thread-header h2)))
4152 (defsubst gnus-article-sort-by-date (h1 h2)
4153 "Sort articles by root article date."
4155 (gnus-date-get-time (mail-header-date h1))
4156 (gnus-date-get-time (mail-header-date h2))))
4158 (defun gnus-thread-sort-by-date (h1 h2)
4159 "Sort threads by root article date."
4160 (gnus-article-sort-by-date
4161 (gnus-thread-header h1) (gnus-thread-header h2)))
4163 (defsubst gnus-article-sort-by-score (h1 h2)
4164 "Sort articles by root article score.
4165 Unscored articles will be counted as having a score of zero."
4166 (> (or (cdr (assq (mail-header-number h1)
4167 gnus-newsgroup-scored))
4168 gnus-summary-default-score 0)
4169 (or (cdr (assq (mail-header-number h2)
4170 gnus-newsgroup-scored))
4171 gnus-summary-default-score 0)))
4173 (defun gnus-thread-sort-by-score (h1 h2)
4174 "Sort threads by root article score."
4175 (gnus-article-sort-by-score
4176 (gnus-thread-header h1) (gnus-thread-header h2)))
4178 (defun gnus-thread-sort-by-total-score (h1 h2)
4179 "Sort threads by the sum of all scores in the thread.
4180 Unscored articles will be counted as having a score of zero."
4181 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4183 (defun gnus-thread-total-score (thread)
4184 ;; This function find the total score of THREAD.
4189 (if (stringp (car thread))
4190 (apply gnus-thread-score-function 0
4191 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4192 (gnus-thread-total-score-1 thread)))
4194 (gnus-thread-total-score-1 (list thread)))))
4196 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4197 "Sort threads such that the thread with the most recently arrived article comes first."
4198 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4200 (defun gnus-thread-highest-number (thread)
4201 "Return the highest article number in THREAD."
4202 (apply 'max (mapcar (lambda (header)
4203 (mail-header-number header))
4204 (message-flatten-list thread))))
4206 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4207 "Sort threads such that the thread with the most recently dated article comes first."
4208 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4210 (defun gnus-thread-latest-date (thread)
4211 "Return the highest article date in THREAD."
4212 (let ((previous-time 0))
4217 (mail-header-parse-date
4219 (mail-header-date header)
4220 (error previous-time))))))
4222 (message-flatten-list thread)
4224 (< (mail-header-number h1)
4225 (mail-header-number h2))))))))
4227 (defun gnus-thread-total-score-1 (root)
4228 ;; This function find the total score of the thread below ROOT.
4229 (setq root (car root))
4230 (apply gnus-thread-score-function
4232 (mapcar 'gnus-thread-total-score
4233 (cdr (gnus-id-to-thread (mail-header-id root))))
4234 (when (> (mail-header-number root) 0)
4235 (list (or (cdr (assq (mail-header-number root)
4236 gnus-newsgroup-scored))
4237 gnus-summary-default-score 0))))
4238 (list gnus-summary-default-score)
4241 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4242 (defvar gnus-tmp-prev-subject nil)
4243 (defvar gnus-tmp-false-parent nil)
4244 (defvar gnus-tmp-root-expunged nil)
4245 (defvar gnus-tmp-dummy-line nil)
4247 (eval-when-compile (defvar gnus-tmp-header))
4248 (defun gnus-extra-header (type &optional header)
4249 "Return the extra header of TYPE."
4250 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4253 (defvar gnus-tmp-thread-tree-header-string "")
4255 (defvar gnus-sum-thread-tree-root "> "
4256 "With %B spec, used for the root of a thread.
4257 If nil, use subject instead.")
4258 (defvar gnus-sum-thread-tree-single-indent ""
4259 "With %B spec, used for a thread with just one message.
4260 If nil, use subject instead.")
4261 (defvar gnus-sum-thread-tree-vertical "| "
4262 "With %B spec, used for drawing a vertical line.")
4263 (defvar gnus-sum-thread-tree-indent " "
4264 "With %B spec, used for indenting.")
4265 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4266 "With %B spec, used for a leaf with brothers.")
4267 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4268 "With %B spec, used for a leaf without brothers.")
4270 (defun gnus-summary-prepare-threads (threads)
4271 "Prepare summary buffer from THREADS and indentation LEVEL.
4272 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4273 or a straight list of headers."
4274 (gnus-message 7 "Generating summary...")
4276 (setq gnus-newsgroup-threads threads)
4279 (let ((gnus-tmp-level 0)
4280 (default-score (or gnus-summary-default-score 0))
4281 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4282 thread number subject stack state gnus-tmp-gathered beg-match
4283 new-roots gnus-tmp-new-adopts thread-end
4284 gnus-tmp-header gnus-tmp-unread
4285 gnus-tmp-replied gnus-tmp-subject-or-nil
4286 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4287 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4288 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4291 (setq gnus-tmp-prev-subject nil)
4293 (if (vectorp (car threads))
4294 ;; If this is a straight (sic) list of headers, then a
4295 ;; threaded summary display isn't required, so we just create
4296 ;; an unthreaded one.
4297 (gnus-summary-prepare-unthreaded threads)
4299 ;; Do the threaded display.
4301 (while (or threads stack gnus-tmp-new-adopts new-roots)
4303 (if (and (= gnus-tmp-level 0)
4306 (not gnus-tmp-false-parent)
4307 (or gnus-tmp-new-adopts new-roots))
4308 (if gnus-tmp-new-adopts
4309 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4310 thread (list (car gnus-tmp-new-adopts))
4311 gnus-tmp-header (caar thread)
4312 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4314 (setq thread (list (car new-roots))
4315 gnus-tmp-header (caar thread)
4316 new-roots (cdr new-roots))))
4319 ;; If there are some threads, we do them before the
4320 ;; threads on the stack.
4321 (setq thread threads
4322 gnus-tmp-header (caar thread))
4323 ;; There were no current threads, so we pop something off
4325 (setq state (car stack)
4326 gnus-tmp-level (car state)
4327 tree-stack (cadr state)
4328 thread (caddr state)
4330 gnus-tmp-header (caar thread))))
4332 (setq gnus-tmp-false-parent nil)
4333 (setq gnus-tmp-root-expunged nil)
4334 (setq thread-end nil)
4336 (if (stringp gnus-tmp-header)
4337 ;; The header is a dummy root.
4339 ((eq gnus-summary-make-false-root 'adopt)
4340 ;; We let the first article adopt the rest.
4341 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4343 (setq gnus-tmp-gathered
4345 (lambda (h) (mail-header-number (car h)))
4348 (setq thread (cons (list (caar thread)
4351 (setq gnus-tmp-level -1
4352 gnus-tmp-false-parent t))
4353 ((eq gnus-summary-make-false-root 'empty)
4354 ;; We print adopted articles with empty subject fields.
4355 (setq gnus-tmp-gathered
4357 (lambda (h) (mail-header-number (car h)))
4360 (setq gnus-tmp-level -1))
4361 ((eq gnus-summary-make-false-root 'dummy)
4362 ;; We remember that we probably want to output a dummy
4364 (setq gnus-tmp-dummy-line gnus-tmp-header)
4365 (setq gnus-tmp-prev-subject gnus-tmp-header))
4367 ;; We do not make a root for the gathered
4368 ;; sub-threads at all.
4369 (setq gnus-tmp-level -1)))
4371 (setq number (mail-header-number gnus-tmp-header)
4372 subject (mail-header-subject gnus-tmp-header))
4375 ;; If the thread has changed subject, we might want to make
4376 ;; this subthread into a root.
4377 ((and (null gnus-thread-ignore-subject)
4378 (not (zerop gnus-tmp-level))
4379 gnus-tmp-prev-subject
4381 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4382 (setq new-roots (nconc new-roots (list (car thread)))
4384 gnus-tmp-header nil))
4385 ;; If the article lies outside the current limit,
4386 ;; then we do not display it.
4387 ((not (memq number gnus-newsgroup-limit))
4388 (setq gnus-tmp-gathered
4390 (lambda (h) (mail-header-number (car h)))
4393 (setq gnus-tmp-new-adopts (if (cdar thread)
4394 (append gnus-tmp-new-adopts
4396 gnus-tmp-new-adopts)
4398 gnus-tmp-header nil)
4399 (when (zerop gnus-tmp-level)
4400 (setq gnus-tmp-root-expunged t)))
4401 ;; Perhaps this article is to be marked as read?
4402 ((and gnus-summary-mark-below
4403 (< (or (cdr (assq number gnus-newsgroup-scored))
4405 gnus-summary-mark-below)
4406 ;; Don't touch sparse articles.
4407 (not (gnus-summary-article-sparse-p number))
4408 (not (gnus-summary-article-ancient-p number)))
4409 (setq gnus-newsgroup-unreads
4410 (delq number gnus-newsgroup-unreads))
4411 (if gnus-newsgroup-auto-expire
4412 (setq gnus-newsgroup-expirable
4413 (gnus-add-to-sorted-list
4414 gnus-newsgroup-expirable number))
4415 (push (cons number gnus-low-score-mark)
4416 gnus-newsgroup-reads))))
4418 (when gnus-tmp-header
4419 ;; We may have an old dummy line to output before this
4421 (when (and gnus-tmp-dummy-line
4424 (mail-header-subject gnus-tmp-header)))
4425 (gnus-summary-insert-dummy-line
4426 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4427 (setq gnus-tmp-dummy-line nil))
4429 ;; Compute the mark.
4430 (setq gnus-tmp-unread (gnus-article-mark number))
4432 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4433 gnus-tmp-header gnus-tmp-level)
4434 gnus-newsgroup-data)
4436 ;; Actually insert the line.
4438 gnus-tmp-subject-or-nil
4440 ((and gnus-thread-ignore-subject
4441 gnus-tmp-prev-subject
4442 (not (inline (gnus-subject-equal
4443 gnus-tmp-prev-subject subject))))
4445 ((zerop gnus-tmp-level)
4446 (if (and (eq gnus-summary-make-false-root 'empty)
4447 (memq number gnus-tmp-gathered)
4448 gnus-tmp-prev-subject
4449 (inline (gnus-subject-equal
4450 gnus-tmp-prev-subject subject)))
4451 gnus-summary-same-subject
4453 (t gnus-summary-same-subject)))
4454 (if (and (eq gnus-summary-make-false-root 'adopt)
4455 (= gnus-tmp-level 1)
4456 (memq number gnus-tmp-gathered))
4457 (setq gnus-tmp-opening-bracket ?\<
4458 gnus-tmp-closing-bracket ?\>)
4459 (setq gnus-tmp-opening-bracket ?\[
4460 gnus-tmp-closing-bracket ?\]))
4462 gnus-tmp-indentation
4463 (aref gnus-thread-indent-array gnus-tmp-level)
4464 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4465 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4466 gnus-summary-default-score 0)
4468 (if (or (null gnus-summary-default-score)
4469 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4470 gnus-summary-zcore-fuzz))
4472 (if (< gnus-tmp-score gnus-summary-default-score)
4473 gnus-score-below-mark gnus-score-over-mark))
4475 (cond ((memq number gnus-newsgroup-processable)
4477 ((memq number gnus-newsgroup-cached)
4479 ((memq number gnus-newsgroup-replied)
4481 ((memq number gnus-newsgroup-forwarded)
4482 gnus-forwarded-mark)
4483 ((memq number gnus-newsgroup-saved)
4485 ((memq number gnus-newsgroup-recent)
4487 ((memq number gnus-newsgroup-unseen)
4490 gnus-tmp-from (mail-header-from gnus-tmp-header)
4493 ((string-match "<[^>]+> *$" gnus-tmp-from)
4494 (setq beg-match (match-beginning 0))
4495 (or (and (string-match "^\".+\"" gnus-tmp-from)
4496 (substring gnus-tmp-from 1 (1- (match-end 0))))
4497 (substring gnus-tmp-from 0 beg-match)))
4498 ((string-match "(.+)" gnus-tmp-from)
4499 (substring gnus-tmp-from
4500 (1+ (match-beginning 0)) (1- (match-end 0))))
4502 gnus-tmp-thread-tree-header-string
4504 ((not gnus-show-threads) "")
4505 ((zerop gnus-tmp-level)
4507 (or gnus-sum-thread-tree-root subject)
4508 (or gnus-sum-thread-tree-single-indent subject)))
4510 (concat (apply 'concat
4511 (mapcar (lambda (item)
4513 gnus-sum-thread-tree-vertical
4514 gnus-sum-thread-tree-indent))
4515 (cdr (reverse tree-stack))))
4517 gnus-sum-thread-tree-leaf-with-other
4518 gnus-sum-thread-tree-single-leaf)))))
4519 (when (string= gnus-tmp-name "")
4520 (setq gnus-tmp-name gnus-tmp-from))
4521 (unless (numberp gnus-tmp-lines)
4522 (setq gnus-tmp-lines -1))
4523 (if (= gnus-tmp-lines -1)
4524 (setq gnus-tmp-lines "?")
4525 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4526 (gnus-put-text-property
4528 (progn (eval gnus-summary-line-format-spec) (point))
4529 'gnus-number number)
4532 (gnus-run-hooks 'gnus-summary-update-hook)
4535 (setq gnus-tmp-prev-subject subject)))
4537 (when (nth 1 thread)
4538 (push (list (max 0 gnus-tmp-level)
4539 (copy-list tree-stack)
4542 (push (if (nth 1 thread) 1 0) tree-stack)
4543 (incf gnus-tmp-level)
4544 (setq threads (if thread-end nil (cdar thread)))
4546 (setq gnus-tmp-level 0)))))
4547 (gnus-message 7 "Generating summary...done"))
4549 (defun gnus-summary-prepare-unthreaded (headers)
4550 "Generate an unthreaded summary buffer based on HEADERS."
4551 (let (header number mark)
4556 ;; We may have to root out some bad articles...
4557 (when (memq (setq number (mail-header-number
4558 (setq header (pop headers))))
4559 gnus-newsgroup-limit)
4560 ;; Mark article as read when it has a low score.
4561 (when (and gnus-summary-mark-below
4562 (< (or (cdr (assq number gnus-newsgroup-scored))
4563 gnus-summary-default-score 0)
4564 gnus-summary-mark-below)
4565 (not (gnus-summary-article-ancient-p number)))
4566 (setq gnus-newsgroup-unreads
4567 (delq number gnus-newsgroup-unreads))
4568 (if gnus-newsgroup-auto-expire
4569 (push number gnus-newsgroup-expirable)
4570 (push (cons number gnus-low-score-mark)
4571 gnus-newsgroup-reads)))
4573 (setq mark (gnus-article-mark number))
4574 (push (gnus-data-make number mark (1+ (point)) header 0)
4575 gnus-newsgroup-data)
4576 (gnus-summary-insert-line
4578 mark (memq number gnus-newsgroup-replied)
4579 (memq number gnus-newsgroup-expirable)
4580 (mail-header-subject header) nil
4581 (cdr (assq number gnus-newsgroup-scored))
4582 (memq number gnus-newsgroup-processable))))))
4584 (defun gnus-summary-remove-list-identifiers ()
4585 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4586 (let ((regexp (if (consp gnus-list-identifiers)
4587 (mapconcat 'identity gnus-list-identifiers " *\\|")
4588 gnus-list-identifiers))
4591 (dolist (header gnus-newsgroup-headers)
4592 (setq subject (mail-header-subject header)
4594 (while (string-match
4595 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4598 (concat (substring subject 0 (match-beginning 2))
4599 (substring subject (match-end 0)))
4603 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4605 (concat (substring subject 0 (match-beginning 1))
4606 (substring subject (match-end 1)))))
4608 (mail-header-set-subject header subject))))))
4610 (defun gnus-fetch-headers (articles)
4611 "Fetch headers of ARTICLES."
4612 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4613 (gnus-message 5 "Fetching headers for %s..." name)
4616 (setq gnus-headers-retrieved-by
4617 (gnus-retrieve-headers
4618 articles gnus-newsgroup-name
4619 ;; We might want to fetch old headers, but
4620 ;; not if there is only 1 article.
4622 (not (eq gnus-fetch-old-headers 'some))
4623 (not (numberp gnus-fetch-old-headers)))
4624 (> (length articles) 1))
4625 gnus-fetch-old-headers))))
4626 (gnus-get-newsgroup-headers-xover
4627 articles nil nil gnus-newsgroup-name t)
4628 (gnus-get-newsgroup-headers))
4629 (gnus-message 5 "Fetching headers for %s...done" name))))
4631 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4632 "Select newsgroup GROUP.
4633 If READ-ALL is non-nil, all articles in the group are selected.
4634 If SELECT-ARTICLES, only select those articles from GROUP."
4635 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4636 ;;!!! Dirty hack; should be removed.
4637 (gnus-summary-ignore-duplicates
4638 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4640 gnus-summary-ignore-duplicates))
4641 (info (nth 2 entry))
4642 articles fetched-articles cached)
4644 (unless (gnus-check-server
4645 (set (make-local-variable 'gnus-current-select-method)
4646 (gnus-find-method-for-group group)))
4647 (error "Couldn't open server"))
4649 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4650 (gnus-activate-group group) ; Or we can activate it...
4651 (progn ; Or we bug out.
4652 (when (equal major-mode 'gnus-summary-mode)
4653 (kill-buffer (current-buffer)))
4654 (error "Couldn't activate group %s: %s"
4655 group (gnus-status-message group))))
4657 (unless (gnus-request-group group t)
4658 (when (equal major-mode 'gnus-summary-mode)
4659 (kill-buffer (current-buffer)))
4660 (error "Couldn't request group %s: %s"
4661 group (gnus-status-message group)))
4663 (setq gnus-newsgroup-name group
4664 gnus-newsgroup-unselected nil
4665 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4667 (let ((display (gnus-group-find-parameter group 'display)))
4668 (setq gnus-newsgroup-display
4670 ((not (zerop (or (car-safe read-all) 0)))
4671 ;; The user entered the group with C-u SPC/RET, let's show
4677 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4679 ;; The following is probably the "correct" solution, but
4680 ;; it makes Gnus fetch all headers and then limit the
4681 ;; articles (which is slow), so instead we hack the
4682 ;; select-articles parameter instead. -- Simon Josefsson
4685 ;; (gnus-byte-compile
4686 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4688 (setq select-articles
4689 (gnus-uncompress-range
4690 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4694 (cdr (gnus-active group)))))
4699 (gnus-summary-setup-default-charset)
4701 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4702 (when (gnus-virtual-group-p group)
4703 (setq cached gnus-newsgroup-cached))
4705 (setq gnus-newsgroup-unreads
4706 (gnus-sorted-ndifference
4707 (gnus-sorted-ndifference gnus-newsgroup-unreads
4708 gnus-newsgroup-marked)
4709 gnus-newsgroup-dormant))
4711 (setq gnus-newsgroup-processable nil)
4713 (gnus-update-read-articles group gnus-newsgroup-unreads)
4715 ;; Adjust and set lists of article marks.
4717 (gnus-adjust-marked-articles info))
4719 (if (setq articles select-articles)
4720 (setq gnus-newsgroup-unselected
4721 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4722 (setq articles (gnus-articles-to-read group read-all)))
4726 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4728 ((eq articles 0) nil)
4730 ;; Init the dependencies hash table.
4731 (setq gnus-newsgroup-dependencies
4732 (gnus-make-hashtable (length articles)))
4733 (gnus-set-global-variables)
4734 ;; Retrieve the headers and read them in.
4735 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4737 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4739 (setq gnus-newsgroup-cached cached))
4741 ;; Suppress duplicates?
4742 (when gnus-suppress-duplicates
4743 (gnus-dup-suppress-articles))
4745 ;; Set the initial limit.
4746 (setq gnus-newsgroup-limit (copy-sequence articles))
4747 ;; Remove canceled articles from the list of unread articles.
4748 (setq fetched-articles
4749 (mapcar (lambda (headers) (mail-header-number headers))
4750 gnus-newsgroup-headers))
4751 (setq gnus-newsgroup-articles fetched-articles)
4752 (setq gnus-newsgroup-unreads
4753 (gnus-sorted-nintersection
4754 gnus-newsgroup-unreads fetched-articles))
4755 (gnus-compute-unseen-list)
4757 ;; Removed marked articles that do not exist.
4758 (gnus-update-missing-marks
4759 (gnus-sorted-difference articles fetched-articles))
4760 ;; We might want to build some more threads first.
4761 (when (and gnus-fetch-old-headers
4762 (eq gnus-headers-retrieved-by 'nov))
4763 (if (eq gnus-fetch-old-headers 'invisible)
4764 (gnus-build-all-threads)
4765 (gnus-build-old-threads)))
4766 ;; Let the Gnus agent mark articles as read.
4768 (gnus-agent-get-undownloaded-list))
4769 ;; Remove list identifiers from subject
4770 (when gnus-list-identifiers
4771 (gnus-summary-remove-list-identifiers))
4772 ;; Check whether auto-expire is to be done in this group.
4773 (setq gnus-newsgroup-auto-expire
4774 (gnus-group-auto-expirable-p group))
4775 ;; Set up the article buffer now, if necessary.
4776 (unless gnus-single-article-buffer
4777 (gnus-article-setup-buffer))
4778 ;; First and last article in this newsgroup.
4779 (when gnus-newsgroup-headers
4780 (setq gnus-newsgroup-begin
4781 (mail-header-number (car gnus-newsgroup-headers))
4784 (gnus-last-element gnus-newsgroup-headers))))
4785 ;; GROUP is successfully selected.
4786 (or gnus-newsgroup-headers t)))))
4788 (defun gnus-compute-unseen-list ()
4789 ;; The `seen' marks are treated specially.
4790 (if (not gnus-newsgroup-seen)
4791 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4792 (setq gnus-newsgroup-unseen
4793 (gnus-inverse-list-range-intersection
4794 gnus-newsgroup-articles gnus-newsgroup-seen))))
4796 (defun gnus-summary-display-make-predicate (display)
4797 (require 'gnus-agent)
4798 (when (= (length display) 1)
4799 (setq display (car display)))
4800 (unless gnus-summary-display-cache
4801 (dolist (elem (append (list (cons 'read 'read)
4802 (cons 'unseen 'unseen))
4803 gnus-article-mark-lists))
4804 (push (cons (cdr elem)
4806 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4807 gnus-summary-display-cache)))
4808 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4809 (gnus-get-predicate display)))
4811 ;; Uses the dynamically bound `number' variable.
4813 (defun gnus-article-marked-p (type &optional article)
4814 (let ((article (or article number)))
4817 (memq article gnus-newsgroup-marked))
4819 (memq article gnus-newsgroup-unsendable))
4820 ((eq type 'undownload)
4821 (memq article gnus-newsgroup-undownloaded))
4822 ((eq type 'download)
4823 (memq article gnus-newsgroup-downloadable))
4825 (memq article gnus-newsgroup-unreads))
4827 (memq article gnus-newsgroup-reads))
4829 (memq article gnus-newsgroup-dormant) )
4831 (memq article gnus-newsgroup-expirable))
4833 (memq article gnus-newsgroup-replied))
4835 (memq article gnus-newsgroup-killed))
4836 ((eq type 'bookmark)
4837 (assq article gnus-newsgroup-bookmarks))
4839 (assq article gnus-newsgroup-scored))
4841 (memq article gnus-newsgroup-saved))
4843 (memq article gnus-newsgroup-cached))
4845 (memq article gnus-newsgroup-forwarded))
4847 (not (memq article gnus-newsgroup-unseen)))
4849 (memq article gnus-newsgroup-recent))
4852 (defun gnus-articles-to-read (group &optional read-all)
4853 "Find out what articles the user wants to read."
4855 ;; Select all articles if `read-all' is non-nil, or if there
4856 ;; are no unread articles.
4858 (and (zerop (length gnus-newsgroup-marked))
4859 (zerop (length gnus-newsgroup-unreads)))
4860 (eq gnus-newsgroup-display 'gnus-not-ignore))
4861 ;; We want to select the headers for all the articles in
4862 ;; the group, so we select either all the active
4863 ;; articles in the group, or (if that's nil), the
4864 ;; articles in the cache.
4866 (gnus-uncompress-range (gnus-active group))
4867 (gnus-cache-articles-in-group group))
4868 ;; Select only the "normal" subset of articles.
4870 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
4871 gnus-newsgroup-unreads)))
4872 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4873 (scored (length scored-list))
4874 (number (length articles))
4875 (marked (+ (length gnus-newsgroup-marked)
4876 (length gnus-newsgroup-dormant)))
4884 ((and (or (<= scored marked) (= scored number))
4885 (numberp gnus-large-newsgroup)
4886 (> number gnus-large-newsgroup))
4890 "How many articles from %s (default %d): "
4892 (gnus-group-decoded-name gnus-newsgroup-name)
4895 (if (string-match "^[ \t]*$" input) number input)))
4896 ((and (> scored marked) (< scored number)
4897 (> (- scored number) 20))
4900 (format "%s %s (%d scored, %d total): "
4901 "How many articles from"
4902 (gnus-group-decoded-name group)
4904 (if (string-match "^[ \t]*$" input)
4908 (message "Quit getting the articles to read")
4910 (setq select (if (stringp select) (string-to-number select) select))
4911 (if (or (null select) (zerop select))
4913 (if (and (not (zerop scored)) (<= (abs select) scored))
4915 (setq articles (sort scored-list '<))
4916 (setq number (length articles)))
4917 (setq articles (copy-sequence articles)))
4919 (when (< (abs select) number)
4921 ;; Select the N oldest articles.
4922 (setcdr (nthcdr (1- (abs select)) articles) nil)
4923 ;; Select the N most recent articles.
4924 (setq articles (nthcdr (- number select) articles))))
4925 (setq gnus-newsgroup-unselected
4926 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4927 (when gnus-alter-articles-to-read-function
4928 (setq gnus-newsgroup-unreads
4930 (funcall gnus-alter-articles-to-read-function
4931 gnus-newsgroup-name gnus-newsgroup-unreads)
4935 (defun gnus-killed-articles (killed articles)
4938 (when (inline (gnus-member-of-range (car articles) killed))
4939 (push (car articles) out))
4940 (setq articles (cdr articles)))
4943 (defun gnus-uncompress-marks (marks)
4944 "Uncompress the mark ranges in MARKS."
4945 (let ((uncompressed '(score bookmark))
4948 (if (memq (caar marks) uncompressed)
4949 (push (car marks) out)
4950 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4951 (setq marks (cdr marks)))
4954 (defun gnus-article-mark-to-type (mark)
4955 "Return the type of MARK."
4956 (or (cadr (assq mark gnus-article-special-mark-lists))
4959 (defun gnus-article-unpropagatable-p (mark)
4960 "Return whether MARK should be propagated to backend."
4961 (memq mark gnus-article-unpropagated-mark-lists))
4963 (defun gnus-adjust-marked-articles (info)
4964 "Set all article lists and remove all marks that are no longer valid."
4965 (let* ((marked-lists (gnus-info-marks info))
4966 (active (gnus-active (gnus-info-group info)))
4969 (types gnus-article-mark-lists)
4970 marks var articles article mark mark-type)
4972 (dolist (marks marked-lists)
4973 (setq mark (car marks)
4974 mark-type (gnus-article-mark-to-type mark)
4975 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4977 ;; We set the variable according to the type of the marks list,
4978 ;; and then adjust the marks to a subset of the active articles.
4980 ;; Adjust "simple" lists.
4981 ((eq mark-type 'list)
4982 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4983 (when (memq mark '(tick dormant expire reply save))
4985 (when (or (< (setq article (pop articles)) min) (> article max))
4986 (set var (delq article (symbol-value var)))))))
4988 ((eq mark-type 'tuple)
4989 (set var (setq articles (cdr marks)))
4990 (when (not (listp (cdr (symbol-value var))))
4991 (set var (list (symbol-value var))))
4992 (when (not (listp (cdr articles)))
4993 (setq articles (list articles)))
4995 (when (or (not (consp (setq article (pop articles))))
4996 (< (car article) min)
4997 (> (car article) max))
4998 (set var (delq article (symbol-value var))))))
4999 ;; Adjust ranges (sloppily).
5000 ((eq mark-type 'range)
5003 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5004 ;; It should be (seen (NUM1 . NUM2)).
5005 (when (numberp (cddr marks))
5006 (setcdr marks (list (cdr marks))))
5007 (setq articles (cdr marks))
5008 (while (and articles
5009 (or (and (consp (car articles))
5010 (> min (cdar articles)))
5011 (and (numberp (car articles))
5012 (> min (car articles)))))
5014 (set var articles))))))))
5016 (defun gnus-update-missing-marks (missing)
5017 "Go through the list of MISSING articles and remove them from the mark lists."
5020 ;; Go through all types.
5021 (dolist (elem gnus-article-mark-lists)
5022 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5023 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5024 (when (symbol-value var)
5025 ;; This list has articles. So we delete all missing
5026 ;; articles from it.
5029 (set var (delq (pop m) (symbol-value var))))))))))
5031 (defun gnus-update-marks ()
5032 "Enter the various lists of marked articles into the newsgroup info list."
5033 (let ((types gnus-article-mark-lists)
5034 (info (gnus-get-info gnus-newsgroup-name))
5035 type list newmarked symbol delta-marks)
5037 ;; Add all marks lists to the list of marks lists.
5038 (while (setq type (pop types))
5039 (setq list (symbol-value
5041 (intern (format "gnus-newsgroup-%s" (car type))))))
5044 ;; Get rid of the entries of the articles that have the
5046 (when (and (eq (cdr type) 'score)
5050 (prev (cons nil list))
5053 (if (or (not (consp (car arts)))
5054 (= (cdar arts) gnus-summary-default-score))
5055 (setcdr prev (cdr arts))
5057 (setq arts (cdr arts)))
5058 (setq list (cdr all)))))
5060 (when (eq (cdr type) 'seen)
5061 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5063 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5064 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5066 (when (and (gnus-check-backend-function
5067 'request-set-mark gnus-newsgroup-name)
5068 (not (gnus-article-unpropagatable-p (cdr type))))
5069 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5070 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5071 (add (gnus-remove-from-range
5072 (gnus-copy-sequence list) old)))
5074 (push (list add 'add (list (cdr type))) delta-marks))
5076 (push (list del 'del (list (cdr type))) delta-marks))))
5079 (push (cons (cdr type) list) newmarked)))
5082 (unless (gnus-check-group gnus-newsgroup-name)
5083 (error "Can't open server for %s" gnus-newsgroup-name))
5084 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5086 ;; Enter these new marks into the info of the group.
5088 (setcar (nthcdr 3 info) newmarked)
5089 ;; Add the marks lists to the end of the info.
5091 (setcdr (nthcdr 2 info) (list newmarked))))
5093 ;; Cut off the end of the info if there's nothing else there.
5097 (when (nthcdr (decf i) info)
5098 (setcdr (nthcdr i info) nil)))))))
5100 (defun gnus-set-mode-line (where)
5101 "Set the mode line of the article or summary buffers.
5102 If WHERE is `summary', the summary mode line format will be used."
5103 ;; Is this mode line one we keep updated?
5104 (when (and (memq where gnus-updated-mode-lines)
5106 (intern (format "gnus-%s-mode-line-format-spec" where))))
5109 ;; We evaluate this in the summary buffer since these
5110 ;; variables are buffer-local to that buffer.
5111 (set-buffer gnus-summary-buffer)
5112 ;; We bind all these variables that are used in the `eval' form
5114 (let* ((mformat (symbol-value
5116 (format "gnus-%s-mode-line-format-spec" where))))
5117 (gnus-tmp-group-name (gnus-group-decoded-name
5118 gnus-newsgroup-name))
5119 (gnus-tmp-article-number (or gnus-current-article 0))
5120 (gnus-tmp-unread gnus-newsgroup-unreads)
5121 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5122 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5123 (gnus-tmp-unread-and-unselected
5124 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5125 (zerop gnus-tmp-unselected))
5127 ((zerop gnus-tmp-unselected)
5128 (format "{%d more}" gnus-tmp-unread-and-unticked))
5129 (t (format "{%d(+%d) more}"
5130 gnus-tmp-unread-and-unticked
5131 gnus-tmp-unselected))))
5133 (if (and gnus-current-headers
5134 (vectorp gnus-current-headers))
5135 (gnus-mode-string-quote
5136 (mail-header-subject gnus-current-headers))
5138 bufname-length max-len
5139 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5140 (setq mode-string (eval mformat))
5141 (setq bufname-length (if (string-match "%b" mode-string)
5144 (if (eq where 'summary)
5146 (get-buffer gnus-article-buffer))))
5149 (setq max-len (max 4 (if gnus-mode-non-string-length
5151 gnus-mode-non-string-length
5153 (length mode-string))))
5154 ;; We might have to chop a bit of the string off...
5155 (when (> (length mode-string) max-len)
5157 (concat (truncate-string-to-width mode-string (- max-len 3))
5159 ;; Pad the mode string a bit.
5160 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5161 ;; Update the mode line.
5162 (setq mode-line-buffer-identification
5163 (gnus-mode-line-buffer-identification (list mode-string)))
5164 (set-buffer-modified-p t))))
5166 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5167 "Go through the HEADERS list and add all Xrefs to a hash table.
5168 The resulting hash table is returned, or nil if no Xrefs were found."
5169 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5170 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5171 (xref-hashtb (gnus-make-hashtable))
5172 start group entry number xrefs header)
5174 (setq header (pop headers))
5175 (when (and (setq xrefs (mail-header-xref header))
5176 (not (memq (setq number (mail-header-number header))
5179 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5180 (setq start (match-end 0))
5181 (setq group (if prefix
5182 (concat prefix (substring xrefs (match-beginning 1)
5184 (substring xrefs (match-beginning 1) (match-end 1))))
5186 (string-to-int (substring xrefs (match-beginning 2)
5188 (if (setq entry (gnus-gethash group xref-hashtb))
5189 (setcdr entry (cons number (cdr entry)))
5190 (gnus-sethash group (cons number nil) xref-hashtb)))))
5191 (and start xref-hashtb)))
5193 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5194 "Look through all the headers and mark the Xrefs as read."
5195 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5196 name entry info xref-hashtb idlist method nth4)
5198 (set-buffer gnus-group-buffer)
5199 (when (setq xref-hashtb
5200 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5203 (unless (string= from-newsgroup (setq name (symbol-name group)))
5204 (setq idlist (symbol-value group))
5205 ;; Dead groups are not updated.
5207 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5209 (when (stringp (setq nth4 (gnus-info-method info)))
5210 (setq nth4 (gnus-server-to-method nth4))))
5211 ;; Only do the xrefs if the group has the same
5212 ;; select method as the group we have just read.
5213 (or (gnus-methods-equal-p
5214 nth4 (gnus-find-method-for-group from-newsgroup))
5216 (equal nth4 (setq method (gnus-find-method-for-group
5218 (and (equal (car nth4) (car method))
5219 (equal (nth 1 nth4) (nth 1 method))))
5220 gnus-use-cross-reference
5221 (or (not (eq gnus-use-cross-reference t))
5223 ;; Only do cross-references on subscribed
5224 ;; groups, if that is what is wanted.
5225 (<= (gnus-info-level info) gnus-level-subscribed))
5226 (gnus-group-make-articles-read name idlist))))
5229 (defun gnus-compute-read-articles (group articles)
5230 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5231 (info (nth 2 entry))
5232 (active (gnus-active group))
5235 ;; First peel off all invalid article numbers.
5237 (let ((ids articles)
5239 (while (setq id (pop ids))
5240 (when (and first (> id (cdr active)))
5241 ;; We'll end up in this situation in one particular
5242 ;; obscure situation. If you re-scan a group and get
5243 ;; a new article that is cross-posted to a different
5244 ;; group that has not been re-scanned, you might get
5245 ;; crossposted article that has a higher number than
5246 ;; Gnus believes possible. So we re-activate this
5247 ;; group as well. This might mean doing the
5248 ;; crossposting thingy will *increase* the number
5249 ;; of articles in some groups. Tsk, tsk.
5250 (setq active (or (gnus-activate-group group) active)))
5251 (when (or (> id (cdr active))
5252 (< id (car active)))
5253 (setq articles (delq id articles))))))
5254 ;; If the read list is nil, we init it.
5256 (null (gnus-info-read info))
5258 (setq ninfo (cons 1 (1- (car active))))
5259 (setq ninfo (gnus-info-read info)))
5260 ;; Then we add the read articles to the range.
5262 ninfo (setq articles (sort articles '<))))))
5264 (defun gnus-group-make-articles-read (group articles)
5265 "Update the info of GROUP to say that ARTICLES are read."
5267 (entry (gnus-gethash group gnus-newsrc-hashtb))
5268 (info (nth 2 entry))
5269 (active (gnus-active group))
5272 (setq range (gnus-compute-read-articles group articles))
5274 (set-buffer gnus-group-buffer)
5277 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5278 (gnus-info-set-read ',info ',(gnus-info-read info))
5279 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5280 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5281 (gnus-group-update-group ,group t))))
5282 ;; Add the read articles to the range.
5283 (gnus-info-set-read info range)
5284 (gnus-request-set-mark group (list (list range 'add '(read))))
5285 ;; Then we have to re-compute how many unread
5286 ;; articles there are in this group.
5290 (setq num (- (1+ (cdr active)) (car active))))
5291 ((not (listp (cdr range)))
5292 (setq num (- (cdr active) (- (1+ (cdr range))
5296 (if (numberp (car range))
5298 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5299 (setq range (cdr range)))
5300 (setq num (- (cdr active) num))))
5301 ;; Update the number of unread articles.
5303 ;; Update the group buffer.
5304 (gnus-group-update-group group t)))))
5306 (defvar gnus-newsgroup-none-id 0)
5308 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5309 (let ((cur nntp-server-buffer)
5312 (save-excursion (set-buffer gnus-summary-buffer)
5313 gnus-newsgroup-dependencies)))
5315 (mail-parse-charset gnus-newsgroup-charset)
5316 (mail-parse-ignored-charsets
5317 (save-excursion (condition-case nil
5318 (set-buffer gnus-summary-buffer)
5320 gnus-newsgroup-ignored-charsets)))
5322 (set-buffer nntp-server-buffer)
5323 ;; Translate all TAB characters into SPACE characters.
5324 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5325 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5326 (gnus-run-hooks 'gnus-parse-headers-hook)
5327 (let ((case-fold-search t)
5328 in-reply-to header p lines chars)
5329 (goto-char (point-min))
5330 ;; Search to the beginning of the next header. Error messages
5331 ;; do not begin with 2 or 3.
5332 (while (re-search-forward "^[23][0-9]+ " nil t)
5335 ;; This implementation of this function, with nine
5336 ;; search-forwards instead of the one re-search-forward and
5337 ;; a case (which basically was the old function) is actually
5338 ;; about twice as fast, even though it looks messier. You
5339 ;; can't have everything, I guess. Speed and elegance
5340 ;; doesn't always go hand in hand.
5349 (narrow-to-region (point)
5350 (or (and (search-forward "\n.\n" nil t)
5356 (if (search-forward "\nsubject:" nil t)
5357 (funcall gnus-decode-encoded-word-function
5358 (nnheader-header-value))
5363 (if (search-forward "\nfrom:" nil t)
5364 (funcall gnus-decode-encoded-word-function
5365 (nnheader-header-value))
5370 (if (search-forward "\ndate:" nil t)
5371 (nnheader-header-value) ""))
5375 (setq id (if (re-search-forward
5376 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5377 ;; We do it this way to make sure the Message-ID
5378 ;; is (somewhat) syntactically valid.
5379 (buffer-substring (match-beginning 1)
5381 ;; If there was no message-id, we just fake one
5382 ;; to make subsequent routines simpler.
5383 (nnheader-generate-fake-message-id))))
5387 (if (search-forward "\nreferences:" nil t)
5391 (nnheader-header-value)
5396 (search-backward ">" end t)
5399 (search-backward "<" end t)
5401 ;; Get the references from the in-reply-to header if there
5402 ;; were no references and the in-reply-to header looks
5404 (if (and (search-forward "\nin-reply-to:" nil t)
5405 (setq in-reply-to (nnheader-header-value))
5406 (string-match "<[^>]+>" in-reply-to))
5408 (setq ref (substring in-reply-to (match-beginning 0)
5410 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5411 (setq ref2 (substring in-reply-to (match-beginning 0)
5413 (when (> (length ref2) (length ref))
5420 (if (search-forward "\nchars: " nil t)
5421 (if (numberp (setq chars (ignore-errors (read cur))))
5427 (if (search-forward "\nlines: " nil t)
5428 (if (numberp (setq lines (ignore-errors (read cur))))
5434 (and (search-forward "\nxref:" nil t)
5435 (nnheader-header-value)))
5437 (when gnus-extra-headers
5438 (let ((extra gnus-extra-headers)
5442 (when (search-forward
5443 (concat "\n" (symbol-name (car extra)) ":") nil t)
5444 (push (cons (car extra) (nnheader-header-value))
5448 (when (equal id ref)
5451 (when gnus-alter-header-function
5452 (funcall gnus-alter-header-function header)
5453 (setq id (mail-header-id header)
5454 ref (gnus-parent-id (mail-header-references header))))
5457 (gnus-dependencies-add-header
5458 header dependencies force-new))
5459 (push header headers))
5460 (goto-char (point-max))
5462 (nreverse headers)))))
5464 ;; Goes through the xover lines and returns a list of vectors
5465 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5466 force-new dependencies
5467 group also-fetch-heads)
5468 "Parse the news overview data in the server buffer.
5469 Return a list of headers that match SEQUENCE (see
5470 `nntp-retrieve-headers')."
5471 ;; Get the Xref when the users reads the articles since most/some
5472 ;; NNTP servers do not include Xrefs when using XOVER.
5473 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5474 (let ((mail-parse-charset gnus-newsgroup-charset)
5475 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5476 (cur nntp-server-buffer)
5477 (dependencies (or dependencies gnus-newsgroup-dependencies))
5479 ((eq gnus-read-all-available-headers t)
5481 ((stringp gnus-read-all-available-headers)
5482 (string-match gnus-read-all-available-headers group))
5485 number headers header)
5487 (set-buffer nntp-server-buffer)
5488 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5489 ;; Allow the user to mangle the headers before parsing them.
5490 (gnus-run-hooks 'gnus-parse-headers-hook)
5491 (goto-char (point-min))
5492 (gnus-parse-without-error
5493 (while (and (or sequence allp)
5495 (setq number (read cur))
5497 (while (and sequence
5498 (< (car sequence) number))
5499 (setq sequence (cdr sequence))))
5502 (eq number (car sequence))))
5504 (setq sequence (cdr sequence))
5505 (setq header (inline
5506 (gnus-nov-parse-line
5507 number dependencies force-new)))))
5508 (push header headers))
5510 ;; A common bug in inn is that if you have posted an article and
5511 ;; then retrieves the active file, it will answer correctly --
5512 ;; the new article is included. However, a NOV entry for the
5513 ;; article may not have been generated yet, so this may fail.
5514 ;; We work around this problem by retrieving the last few
5515 ;; headers using HEAD.
5516 (if (or (not also-fetch-heads)
5518 ;; We (probably) got all the headers.
5520 (let ((gnus-nov-is-evil t))
5523 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5524 (gnus-get-newsgroup-headers))))))))
5526 (defun gnus-article-get-xrefs ()
5527 "Fill in the Xref value in `gnus-current-headers', if necessary.
5528 This is meant to be called in `gnus-article-internal-prepare-hook'."
5529 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5530 gnus-current-headers)))
5531 (or (not gnus-use-cross-reference)
5533 (and (mail-header-xref headers)
5534 (not (string= (mail-header-xref headers) "")))
5535 (let ((case-fold-search t)
5538 (nnheader-narrow-to-headers)
5539 (goto-char (point-min))
5540 (when (or (and (not (eobp))
5541 (eq (downcase (char-after)) ?x)
5542 (looking-at "Xref:"))
5543 (search-forward "\nXref:" nil t))
5544 (goto-char (1+ (match-end 0)))
5545 (setq xref (buffer-substring (point)
5546 (progn (end-of-line) (point))))
5547 (mail-header-set-xref headers xref)))))))
5549 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5550 "Find article ID and insert the summary line for that article.
5551 OLD-HEADER can either be a header or a line number to insert
5552 the subject line on."
5553 (let* ((line (and (numberp old-header) old-header))
5554 (old-header (and (vectorp old-header) old-header))
5555 (header (cond ((and old-header use-old-header)
5558 (gnus-number-to-header id))
5559 (gnus-number-to-header id))
5561 (gnus-read-header id))))
5562 (number (and (numberp id) id))
5565 ;; Rebuild the thread that this article is part of and go to the
5566 ;; article we have fetched.
5567 (when (and (not gnus-show-threads)
5570 (setq d (gnus-data-find (mail-header-number old-header))))
5571 (goto-char (gnus-data-pos d))
5574 (- (gnus-point-at-bol)
5576 (1+ (gnus-point-at-eol))
5577 (gnus-delete-line))))))
5579 (mail-header-set-number header (mail-header-number old-header)))
5580 (setq gnus-newsgroup-sparse
5581 (delq (setq number (mail-header-number header))
5582 gnus-newsgroup-sparse))
5583 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5584 (push number gnus-newsgroup-limit)
5585 (gnus-rebuild-thread (mail-header-id header) line)
5586 (gnus-summary-goto-subject number nil t))
5587 (when (and (numberp number)
5589 ;; We have to update the boundaries even if we can't fetch the
5590 ;; article if ID is a number -- so that the next `P' or `N'
5591 ;; command will fetch the previous (or next) article even
5592 ;; if the one we tried to fetch this time has been canceled.
5593 (when (> number gnus-newsgroup-end)
5594 (setq gnus-newsgroup-end number))
5595 (when (< number gnus-newsgroup-begin)
5596 (setq gnus-newsgroup-begin number))
5597 (setq gnus-newsgroup-unselected
5598 (delq number gnus-newsgroup-unselected)))
5599 ;; Report back a success?
5600 (and header (mail-header-number header))))
5602 ;;; Process/prefix in the summary buffer
5604 (defun gnus-summary-work-articles (n)
5605 "Return a list of articles to be worked upon.
5606 The prefix argument, the list of process marked articles, and the
5607 current article will be taken into consideration."
5609 (set-buffer gnus-summary-buffer)
5612 ;; A numerical prefix has been given.
5613 (setq n (prefix-numeric-value n))
5614 (let ((backward (< n 0))
5615 (n (abs (prefix-numeric-value n)))
5620 (push (setq article (gnus-summary-article-number))
5623 (gnus-summary-find-prev nil article)
5624 (gnus-summary-find-next nil article)))
5626 (nreverse articles)))
5627 ((and (gnus-region-active-p) (mark))
5628 (message "region active")
5629 ;; Work on the region between point and mark.
5630 (let ((max (max (point) (mark)))
5633 (goto-char (min (min (point) (mark))))
5636 (push (setq article (gnus-summary-article-number)) articles)
5637 (gnus-summary-find-next nil article)
5639 (nreverse articles))))
5640 (gnus-newsgroup-processable
5641 ;; There are process-marked articles present.
5642 ;; Save current state.
5643 (gnus-summary-save-process-mark)
5645 (reverse gnus-newsgroup-processable))
5647 ;; Just return the current article.
5648 (list (gnus-summary-article-number))))))
5650 (defmacro gnus-summary-iterate (arg &rest forms)
5651 "Iterate over the process/prefixed articles and do FORMS.
5652 ARG is the interactive prefix given to the command. FORMS will be
5653 executed with point over the summary line of the articles."
5654 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5655 `(let ((,articles (gnus-summary-work-articles ,arg)))
5657 (gnus-summary-goto-subject (car ,articles))
5661 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5662 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5664 (defun gnus-summary-save-process-mark ()
5665 "Push the current set of process marked articles on the stack."
5667 (push (copy-sequence gnus-newsgroup-processable)
5668 gnus-newsgroup-process-stack))
5670 (defun gnus-summary-kill-process-mark ()
5671 "Push the current set of process marked articles on the stack and unmark."
5673 (gnus-summary-save-process-mark)
5674 (gnus-summary-unmark-all-processable))
5676 (defun gnus-summary-yank-process-mark ()
5677 "Pop the last process mark state off the stack and restore it."
5679 (unless gnus-newsgroup-process-stack
5680 (error "Empty mark stack"))
5681 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5683 (defun gnus-summary-process-mark-set (set)
5684 "Make SET into the current process marked articles."
5685 (gnus-summary-unmark-all-processable)
5687 (gnus-summary-set-process-mark (pop set))))
5689 ;;; Searching and stuff
5691 (defun gnus-summary-search-group (&optional backward use-level)
5692 "Search for next unread newsgroup.
5693 If optional argument BACKWARD is non-nil, search backward instead."
5695 (set-buffer gnus-group-buffer)
5696 (when (gnus-group-search-forward
5697 backward nil (if use-level (gnus-group-group-level) nil))
5698 (gnus-group-group-name))))
5700 (defun gnus-summary-best-group (&optional exclude-group)
5701 "Find the name of the best unread group.
5702 If EXCLUDE-GROUP, do not go to this group."
5704 (set-buffer gnus-group-buffer)
5706 (gnus-group-best-unread-group exclude-group))))
5708 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5709 (if backward (gnus-summary-find-prev)
5710 (let* ((dummy (gnus-summary-article-intangible-p))
5711 (article (or article (gnus-summary-article-number)))
5712 (arts (gnus-data-find-list article))
5714 (when (and (not dummy)
5715 (or (not gnus-summary-check-current)
5717 (not (gnus-data-unread-p (car arts)))))
5718 (setq arts (cdr arts)))
5723 (when (or (and undownloaded
5724 (eq gnus-undownloaded-mark
5725 (gnus-data-mark (car arts))))
5726 (gnus-data-unread-p (car arts)))
5727 (setq result (car arts)
5729 (setq arts (cdr arts)))
5732 (goto-char (gnus-data-pos result))
5733 (gnus-data-number result)))))
5735 (defun gnus-summary-find-prev (&optional unread article)
5736 (let* ((eobp (eobp))
5737 (article (or article (gnus-summary-article-number)))
5738 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5740 (when (and (not eobp)
5741 (or (not gnus-summary-check-current)
5743 (not (gnus-data-unread-p (car arts)))))
5744 (setq arts (cdr arts)))
5749 (when (gnus-data-unread-p (car arts))
5750 (setq result (car arts)
5752 (setq arts (cdr arts)))
5755 (goto-char (gnus-data-pos result))
5756 (gnus-data-number result))))
5758 (defun gnus-summary-find-subject (subject &optional unread backward article)
5759 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5760 (article (or article (gnus-summary-article-number)))
5761 (articles (gnus-data-list backward))
5762 (arts (gnus-data-find-list article articles))
5764 (when (or (not gnus-summary-check-current)
5766 (not (gnus-data-unread-p (car arts))))
5767 (setq arts (cdr arts)))
5769 (and (or (not unread)
5770 (gnus-data-unread-p (car arts)))
5771 (vectorp (gnus-data-header (car arts)))
5773 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5774 (setq result (car arts)
5776 (setq arts (cdr arts)))
5778 (goto-char (gnus-data-pos result))
5779 (gnus-data-number result))))
5781 (defun gnus-summary-search-forward (&optional unread subject backward)
5782 "Search forward for an article.
5783 If UNREAD, look for unread articles. If SUBJECT, look for
5784 articles with that subject. If BACKWARD, search backward instead."
5785 (cond (subject (gnus-summary-find-subject subject unread backward))
5786 (backward (gnus-summary-find-prev unread))
5787 (t (gnus-summary-find-next unread))))
5789 (defun gnus-recenter (&optional n)
5790 "Center point in window and redisplay frame.
5791 Also do horizontal recentering."
5793 (when (and gnus-auto-center-summary
5794 (not (eq gnus-auto-center-summary 'vertical)))
5795 (gnus-horizontal-recenter))
5798 (defun gnus-summary-recenter ()
5799 "Center point in the summary window.
5800 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5801 displayed, no centering will be performed."
5802 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5803 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5805 (let* ((top (cond ((< (window-height) 4) 0)
5806 ((< (window-height) 7) 1)
5807 (t (if (numberp gnus-auto-center-summary)
5808 gnus-auto-center-summary
5810 (height (1- (window-height)))
5811 (bottom (save-excursion (goto-char (point-max))
5812 (forward-line (- height))
5814 (window (get-buffer-window (current-buffer))))
5815 ;; The user has to want it.
5816 (when gnus-auto-center-summary
5817 (when (get-buffer-window gnus-article-buffer)
5818 ;; Only do recentering when the article buffer is displayed,
5819 ;; Set the window start to either `bottom', which is the biggest
5820 ;; possible valid number, or the second line from the top,
5821 ;; whichever is the least.
5822 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5823 (if (> bottom top-pos)
5824 ;; Keep the second line from the top visible
5825 (set-window-start window top-pos t)
5826 ;; Try to keep the bottom line visible; if it's partially
5827 ;; obscured, either scroll one more line to make it fully
5828 ;; visible, or revert to using TOP-POS.
5830 (goto-char (point-max))
5832 (let ((last-line-start (point)))
5834 (set-window-start window (point) t)
5835 (when (not (pos-visible-in-window-p last-line-start window))
5837 (set-window-start window (min (point) top-pos) t)))))))
5838 ;; Do horizontal recentering while we're at it.
5839 (when (and (get-buffer-window (current-buffer) t)
5840 (not (eq gnus-auto-center-summary 'vertical)))
5841 (let ((selected (selected-window)))
5842 (select-window (get-buffer-window (current-buffer) t))
5843 (gnus-summary-position-point)
5844 (gnus-horizontal-recenter)
5845 (select-window selected))))))
5847 (defun gnus-summary-jump-to-group (newsgroup)
5848 "Move point to NEWSGROUP in group mode buffer."
5849 ;; Keep update point of group mode buffer if visible.
5850 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5851 (save-window-excursion
5852 ;; Take care of tree window mode.
5853 (when (get-buffer-window gnus-group-buffer)
5854 (pop-to-buffer gnus-group-buffer))
5855 (gnus-group-jump-to-group newsgroup))
5857 ;; Take care of tree window mode.
5858 (if (get-buffer-window gnus-group-buffer)
5859 (pop-to-buffer gnus-group-buffer)
5860 (set-buffer gnus-group-buffer))
5861 (gnus-group-jump-to-group newsgroup))))
5863 ;; This function returns a list of article numbers based on the
5864 ;; difference between the ranges of read articles in this group and
5865 ;; the range of active articles.
5866 (defun gnus-list-of-unread-articles (group)
5867 (let* ((read (gnus-info-read (gnus-get-info group)))
5868 (active (or (gnus-active group) (gnus-activate-group group)))
5871 ;; If none are read, then all are unread.
5873 (setq first (car active))
5874 ;; If the range of read articles is a single range, then the
5875 ;; first unread article is the article after the last read
5876 ;; article. Sounds logical, doesn't it?
5877 (if (and (not (listp (cdr read)))
5878 (or (< (car read) (car active))
5879 (progn (setq read (list read))
5881 (setq first (max (car active) (1+ (cdr read))))
5882 ;; `read' is a list of ranges.
5883 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5886 (setq first (car active)))
5889 (while (< first nlast)
5891 (setq first (1+ first))))
5892 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5893 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5894 (setq read (cdr read)))))
5895 ;; And add the last unread articles.
5896 (while (<= first last)
5898 (setq first (1+ first)))
5899 ;; Return the list of unread articles.
5900 (delq 0 (nreverse unread))))
5902 (defun gnus-list-of-read-articles (group)
5903 "Return a list of unread, unticked and non-dormant articles."
5904 (let* ((info (gnus-get-info group))
5905 (marked (gnus-info-marks info))
5906 (active (gnus-active group)))
5908 (gnus-list-range-difference
5909 (gnus-list-range-difference
5910 (gnus-sorted-complement
5911 (gnus-uncompress-range active)
5912 (gnus-list-of-unread-articles group))
5913 (cdr (assq 'dormant marked)))
5914 (cdr (assq 'tick marked))))))
5916 ;; Various summary commands
5918 (defun gnus-summary-select-article-buffer ()
5919 "Reconfigure windows to show article buffer."
5921 (if (not (gnus-buffer-live-p gnus-article-buffer))
5922 (error "There is no article buffer for this summary buffer")
5923 (gnus-configure-windows 'article)
5924 (select-window (get-buffer-window gnus-article-buffer))))
5926 (defun gnus-summary-universal-argument (arg)
5927 "Perform any operation on all articles that are process/prefixed."
5929 (let ((articles (gnus-summary-work-articles arg))
5936 (substitute-command-keys
5937 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5939 (gnus-error 1 "Undefined key")
5942 (gnus-summary-goto-subject (setq article (pop articles)))
5943 (let (gnus-newsgroup-processable)
5944 (command-execute func))
5945 (gnus-summary-remove-process-mark article)))))
5946 (gnus-summary-position-point))
5948 (defun gnus-summary-toggle-truncation (&optional arg)
5949 "Toggle truncation of summary lines.
5950 With arg, turn line truncation on iff arg is positive."
5952 (setq truncate-lines
5953 (if (null arg) (not truncate-lines)
5954 (> (prefix-numeric-value arg) 0)))
5957 (defun gnus-summary-reselect-current-group (&optional all rescan)
5958 "Exit and then reselect the current newsgroup.
5959 The prefix argument ALL means to select all articles."
5961 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5962 (error "Ephemeral groups can't be reselected"))
5963 (let ((current-subject (gnus-summary-article-number))
5964 (group gnus-newsgroup-name))
5965 (setq gnus-newsgroup-begin nil)
5967 ;; We have to adjust the point of group mode buffer because
5968 ;; point was moved to the next unread newsgroup by exiting.
5969 (gnus-summary-jump-to-group group)
5972 (gnus-group-get-new-news-this-group 1)))
5973 (gnus-group-read-group all t)
5974 (gnus-summary-goto-subject current-subject nil t)))
5976 (defun gnus-summary-rescan-group (&optional all)
5977 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5979 (gnus-summary-reselect-current-group all t))
5981 (defun gnus-summary-update-info (&optional non-destructive)
5983 (let ((group gnus-newsgroup-name))
5985 (when gnus-newsgroup-kill-headers
5986 (setq gnus-newsgroup-killed
5987 (gnus-compress-sequence
5989 (gnus-list-range-intersection
5990 (setq gnus-newsgroup-unselected
5991 (sort gnus-newsgroup-unselected '<))
5992 gnus-newsgroup-killed)
5993 (setq gnus-newsgroup-unreads
5994 (sort gnus-newsgroup-unreads '<)))
5996 (unless (listp (cdr gnus-newsgroup-killed))
5997 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5998 (let ((headers gnus-newsgroup-headers))
5999 ;; Set the new ranges of read articles.
6001 (set-buffer gnus-group-buffer)
6002 (gnus-undo-force-boundary))
6003 (gnus-update-read-articles
6004 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
6005 ;; Set the current article marks.
6006 (let ((gnus-newsgroup-scored
6007 (if (and (not gnus-save-score)
6008 (not non-destructive))
6010 gnus-newsgroup-scored)))
6012 (gnus-update-marks)))
6013 ;; Do the cross-ref thing.
6014 (when gnus-use-cross-reference
6015 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6016 ;; Do not switch windows but change the buffer to work.
6017 (set-buffer gnus-group-buffer)
6018 (unless (gnus-ephemeral-group-p group)
6019 (gnus-group-update-group group)))))))
6021 (defun gnus-summary-save-newsrc (&optional force)
6022 "Save the current number of read/marked articles in the dribble buffer.
6023 The dribble buffer will then be saved.
6024 If FORCE (the prefix), also save the .newsrc file(s)."
6026 (gnus-summary-update-info t)
6028 (gnus-save-newsrc-file)
6029 (gnus-dribble-save)))
6031 (defun gnus-summary-exit (&optional temporary)
6032 "Exit reading current newsgroup, and then return to group selection mode.
6033 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6035 (gnus-set-global-variables)
6036 (when (gnus-buffer-live-p gnus-article-buffer)
6038 (set-buffer gnus-article-buffer)
6039 (mm-destroy-parts gnus-article-mime-handles)
6040 ;; Set it to nil for safety reason.
6041 (setq gnus-article-mime-handle-alist nil)
6042 (setq gnus-article-mime-handles nil)))
6043 (gnus-kill-save-kill-buffer)
6044 (gnus-async-halt-prefetch)
6045 (let* ((group gnus-newsgroup-name)
6046 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6049 (buf (current-buffer)))
6051 ;; Do adaptive scoring, and possibly save score files.
6052 (when gnus-newsgroup-adaptive
6053 (gnus-score-adaptive))
6054 (when gnus-use-scoring
6056 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6057 ;; If we have several article buffers, we kill them at exit.
6058 (unless gnus-single-article-buffer
6059 (gnus-kill-buffer gnus-original-article-buffer)
6060 (setq gnus-article-current nil))
6061 (when gnus-use-cache
6062 (gnus-cache-possibly-remove-articles)
6063 (gnus-cache-save-buffers))
6064 (gnus-async-prefetch-remove-group group)
6065 (when gnus-suppress-duplicates
6066 (gnus-dup-enter-articles))
6067 (when gnus-use-trees
6068 (gnus-tree-close group))
6069 (when gnus-use-cache
6070 (gnus-cache-write-active))
6071 ;; Remove entries for this group.
6072 (nnmail-purge-split-history (gnus-group-real-name group))
6073 ;; Make all changes in this group permanent.
6075 (gnus-run-hooks 'gnus-exit-group-hook)
6076 (gnus-summary-update-info))
6077 (gnus-close-group group)
6078 ;; Make sure where we were, and go to next newsgroup.
6079 (set-buffer gnus-group-buffer)
6081 (gnus-group-jump-to-group group))
6082 (gnus-run-hooks 'gnus-summary-exit-hook)
6083 (unless (or quit-config
6084 ;; If this group has disappeared from the summary
6085 ;; buffer, don't skip forwards.
6086 (not (string= group (gnus-group-group-name))))
6087 (gnus-group-next-unread-group 1))
6088 (setq group-point (point))
6091 ;; If we have several article buffers, we kill them at exit.
6092 (unless gnus-single-article-buffer
6093 (gnus-kill-buffer gnus-article-buffer)
6094 (gnus-kill-buffer gnus-original-article-buffer)
6095 (setq gnus-article-current nil))
6097 (if (not gnus-kill-summary-on-exit)
6099 (gnus-deaden-summary)
6101 ;; We set all buffer-local variables to nil. It is unclear why
6102 ;; this is needed, but if we don't, buffer-local variables are
6103 ;; not garbage-collected, it seems. This would the lead to en
6104 ;; ever-growing Emacs.
6105 (gnus-summary-clear-local-variables)
6106 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6107 (gnus-summary-clear-local-variables))
6108 (when (get-buffer gnus-article-buffer)
6109 (bury-buffer gnus-article-buffer))
6110 ;; We clear the global counterparts of the buffer-local
6111 ;; variables as well, just to be on the safe side.
6112 (set-buffer gnus-group-buffer)
6113 (gnus-summary-clear-local-variables)
6114 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6115 (gnus-summary-clear-local-variables)))
6116 (setq gnus-current-select-method gnus-select-method)
6117 (pop-to-buffer gnus-group-buffer)
6118 (if (not quit-config)
6120 (goto-char group-point)
6121 (gnus-configure-windows 'group 'force))
6122 (gnus-handle-ephemeral-exit quit-config))
6123 ;; Return to group mode buffer.
6124 (when (eq mode 'gnus-summary-mode)
6125 (gnus-kill-buffer buf))
6126 ;; Clear the current group name.
6128 (setq gnus-newsgroup-name nil)))))
6130 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6131 (defun gnus-summary-exit-no-update (&optional no-questions)
6132 "Quit reading current newsgroup without updating read article info."
6134 (let* ((group gnus-newsgroup-name)
6135 (quit-config (gnus-group-quit-config group)))
6136 (when (or no-questions
6138 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6139 (gnus-async-halt-prefetch)
6141 (delq 'gnus-summary-expire-articles
6142 (copy-sequence gnus-summary-prepare-exit-hook)))
6143 (when (gnus-buffer-live-p gnus-article-buffer)
6145 (set-buffer gnus-article-buffer)
6146 (mm-destroy-parts gnus-article-mime-handles)
6147 ;; Set it to nil for safety reason.
6148 (setq gnus-article-mime-handle-alist nil)
6149 (setq gnus-article-mime-handles nil)))
6150 ;; If we have several article buffers, we kill them at exit.
6151 (unless gnus-single-article-buffer
6152 (gnus-kill-buffer gnus-article-buffer)
6153 (gnus-kill-buffer gnus-original-article-buffer)
6154 (setq gnus-article-current nil))
6155 (if (not gnus-kill-summary-on-exit)
6156 (gnus-deaden-summary)
6157 (gnus-close-group group)
6158 (gnus-summary-clear-local-variables)
6159 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6160 (gnus-summary-clear-local-variables))
6161 (set-buffer gnus-group-buffer)
6162 (gnus-summary-clear-local-variables)
6163 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6164 (gnus-summary-clear-local-variables))
6165 (when (get-buffer gnus-summary-buffer)
6166 (kill-buffer gnus-summary-buffer)))
6167 (unless gnus-single-article-buffer
6168 (setq gnus-article-current nil))
6169 (when gnus-use-trees
6170 (gnus-tree-close group))
6171 (gnus-async-prefetch-remove-group group)
6172 (when (get-buffer gnus-article-buffer)
6173 (bury-buffer gnus-article-buffer))
6174 ;; Return to the group buffer.
6175 (gnus-configure-windows 'group 'force)
6176 ;; Clear the current group name.
6177 (setq gnus-newsgroup-name nil)
6178 (when (equal (gnus-group-group-name) group)
6179 (gnus-group-next-unread-group 1))
6181 (gnus-handle-ephemeral-exit quit-config)))))
6183 (defun gnus-handle-ephemeral-exit (quit-config)
6184 "Handle movement when leaving an ephemeral group.
6185 The state which existed when entering the ephemeral is reset."
6186 (if (not (buffer-name (car quit-config)))
6187 (gnus-configure-windows 'group 'force)
6188 (set-buffer (car quit-config))
6189 (cond ((eq major-mode 'gnus-summary-mode)
6190 (gnus-set-global-variables))
6191 ((eq major-mode 'gnus-article-mode)
6193 ;; The `gnus-summary-buffer' variable may point
6194 ;; to the old summary buffer when using a single
6196 (unless (gnus-buffer-live-p gnus-summary-buffer)
6197 (set-buffer gnus-group-buffer))
6198 (set-buffer gnus-summary-buffer)
6199 (gnus-set-global-variables))))
6200 (if (or (eq (cdr quit-config) 'article)
6201 (eq (cdr quit-config) 'pick))
6203 ;; The current article may be from the ephemeral group
6204 ;; thus it is best that we reload this article
6205 (gnus-summary-show-article)
6206 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6207 (gnus-configure-windows 'pick 'force)
6208 (gnus-configure-windows (cdr quit-config) 'force)))
6209 (gnus-configure-windows (cdr quit-config) 'force))
6210 (when (eq major-mode 'gnus-summary-mode)
6211 (gnus-summary-next-subject 1 nil t)
6212 (gnus-summary-recenter)
6213 (gnus-summary-position-point))))
6217 (defvar gnus-dead-summary-mode-map nil)
6219 (unless gnus-dead-summary-mode-map
6220 (setq gnus-dead-summary-mode-map (make-keymap))
6221 (suppress-keymap gnus-dead-summary-mode-map)
6222 (substitute-key-definition
6223 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6224 (dolist (key '("\C-d" "\r" "\177" [delete]))
6225 (define-key gnus-dead-summary-mode-map
6226 key 'gnus-summary-wake-up-the-dead))
6227 (dolist (key '("q" "Q"))
6228 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6230 (defvar gnus-dead-summary-mode nil
6231 "Minor mode for Gnus summary buffers.")
6233 (defun gnus-dead-summary-mode (&optional arg)
6234 "Minor mode for Gnus summary buffers."
6236 (when (eq major-mode 'gnus-summary-mode)
6237 (make-local-variable 'gnus-dead-summary-mode)
6238 (setq gnus-dead-summary-mode
6239 (if (null arg) (not gnus-dead-summary-mode)
6240 (> (prefix-numeric-value arg) 0)))
6241 (when gnus-dead-summary-mode
6242 (gnus-add-minor-mode
6243 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6245 (defun gnus-deaden-summary ()
6246 "Make the current summary buffer into a dead summary buffer."
6247 ;; Kill any previous dead summary buffer.
6248 (when (and gnus-dead-summary
6249 (buffer-name gnus-dead-summary))
6251 (set-buffer gnus-dead-summary)
6252 (when gnus-dead-summary-mode
6253 (kill-buffer (current-buffer)))))
6254 ;; Make this the current dead summary.
6255 (setq gnus-dead-summary (current-buffer))
6256 (gnus-dead-summary-mode 1)
6257 (let ((name (buffer-name)))
6258 (when (string-match "Summary" name)
6260 (concat (substring name 0 (match-beginning 0)) "Dead "
6261 (substring name (match-beginning 0)))
6265 (defun gnus-kill-or-deaden-summary (buffer)
6266 "Kill or deaden the summary BUFFER."
6268 (when (and (buffer-name buffer)
6269 (not gnus-single-article-buffer))
6272 (gnus-kill-buffer gnus-article-buffer)
6273 (gnus-kill-buffer gnus-original-article-buffer)))
6276 (gnus-kill-summary-on-exit
6277 (when (and gnus-use-trees
6278 (gnus-buffer-exists-p buffer))
6281 (gnus-tree-close gnus-newsgroup-name)))
6282 (gnus-kill-buffer buffer))
6283 ;; Deaden the buffer.
6284 ((gnus-buffer-exists-p buffer)
6287 (gnus-deaden-summary))))))
6289 (defun gnus-summary-wake-up-the-dead (&rest args)
6290 "Wake up the dead summary buffer."
6292 (gnus-dead-summary-mode -1)
6293 (let ((name (buffer-name)))
6294 (when (string-match "Dead " name)
6296 (concat (substring name 0 (match-beginning 0))
6297 (substring name (match-end 0)))
6299 (gnus-message 3 "This dead summary is now alive again"))
6301 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6302 (defun gnus-summary-fetch-faq (&optional faq-dir)
6303 "Fetch the FAQ for the current group.
6304 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6308 (when current-prefix-arg
6310 "Faq dir: " (and (listp gnus-group-faq-directory)
6311 (mapcar (lambda (file) (list file))
6312 gnus-group-faq-directory))))))
6313 (let (gnus-faq-buffer)
6314 (when (setq gnus-faq-buffer
6315 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6316 (gnus-configure-windows 'summary-faq))))
6318 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6319 (defun gnus-summary-describe-group (&optional force)
6320 "Describe the current newsgroup."
6322 (gnus-group-describe-group force gnus-newsgroup-name))
6324 (defun gnus-summary-describe-briefly ()
6325 "Describe summary mode commands briefly."
6327 (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")))
6329 ;; Walking around group mode buffer from summary mode.
6331 (defun gnus-summary-next-group (&optional no-article target-group backward)
6332 "Exit current newsgroup and then select next unread newsgroup.
6333 If prefix argument NO-ARTICLE is non-nil, no article is selected
6334 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6335 previous group instead."
6337 ;; Stop pre-fetching.
6338 (gnus-async-halt-prefetch)
6339 (let ((current-group gnus-newsgroup-name)
6340 (current-buffer (current-buffer))
6342 ;; First we semi-exit this group to update Xrefs and all variables.
6343 ;; We can't do a real exit, because the window conf must remain
6344 ;; the same in case the user is prompted for info, and we don't
6345 ;; want the window conf to change before that...
6346 (gnus-summary-exit t)
6347 (while (not entered)
6348 ;; Then we find what group we are supposed to enter.
6349 (set-buffer gnus-group-buffer)
6350 (gnus-group-jump-to-group current-group)
6353 (if (eq gnus-keep-same-level 'best)
6354 (gnus-summary-best-group gnus-newsgroup-name)
6355 (gnus-summary-search-group backward gnus-keep-same-level))))
6356 (if (not target-group)
6357 ;; There are no further groups, so we return to the group
6360 (gnus-message 5 "Returning to the group buffer")
6362 (when (gnus-buffer-live-p current-buffer)
6363 (set-buffer current-buffer)
6364 (gnus-summary-exit))
6365 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6366 ;; We try to enter the target group.
6367 (gnus-group-jump-to-group target-group)
6368 (let ((unreads (gnus-group-group-unread)))
6369 (if (and (or (eq t unreads)
6370 (and unreads (not (zerop unreads))))
6371 (gnus-summary-read-group
6372 target-group nil no-article
6373 (and (buffer-name current-buffer) current-buffer)
6376 (setq current-group target-group
6377 target-group nil)))))))
6379 (defun gnus-summary-prev-group (&optional no-article)
6380 "Exit current newsgroup and then select previous unread newsgroup.
6381 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6383 (gnus-summary-next-group no-article nil t))
6385 ;; Walking around summary lines.
6387 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6388 "Go to the first unread subject.
6389 If UNREAD is non-nil, go to the first unread article.
6390 Returns the article selected or nil if there are no unread articles."
6395 ((null gnus-newsgroup-data)
6396 (gnus-message 3 "No articles in the group")
6398 ;; Pick the first article.
6400 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6401 (gnus-data-number (car gnus-newsgroup-data)))
6402 ;; No unread articles.
6403 ((null gnus-newsgroup-unreads)
6404 (gnus-message 3 "No more unread articles")
6406 ;; Find the first unread article.
6408 (let ((data gnus-newsgroup-data))
6410 (and (not (and undownloaded
6411 (eq gnus-undownloaded-mark
6412 (gnus-data-mark (car data)))))
6415 (gnus-data-number (car data))
6416 gnus-newsgroup-unseen))
6417 (not (gnus-data-unread-p (car data))))
6418 (not (gnus-data-unread-p (car data))))))
6419 (setq data (cdr data)))
6421 (goto-char (gnus-data-pos (car data)))
6422 (gnus-data-number (car data))))))
6423 (gnus-summary-position-point)))
6425 (defun gnus-summary-next-subject (n &optional unread dont-display)
6426 "Go to next N'th summary line.
6427 If N is negative, go to the previous N'th subject line.
6428 If UNREAD is non-nil, only unread articles are selected.
6429 The difference between N and the actual number of steps taken is
6432 (let ((backward (< n 0))
6436 (gnus-summary-find-prev unread)
6437 (gnus-summary-find-next unread)))
6438 (unless (zerop (setq n (1- n)))
6439 (gnus-summary-show-thread)))
6441 (gnus-message 7 "No more%s articles"
6442 (if unread " unread" "")))
6443 (unless dont-display
6444 (gnus-summary-recenter)
6445 (gnus-summary-position-point))
6448 (defun gnus-summary-next-unread-subject (n)
6449 "Go to next N'th unread summary line."
6451 (gnus-summary-next-subject n t))
6453 (defun gnus-summary-prev-subject (n &optional unread)
6454 "Go to previous N'th summary line.
6455 If optional argument UNREAD is non-nil, only unread article is selected."
6457 (gnus-summary-next-subject (- n) unread))
6459 (defun gnus-summary-prev-unread-subject (n)
6460 "Go to previous N'th unread summary line."
6462 (gnus-summary-next-subject (- n) t))
6464 (defun gnus-summary-goto-subject (article &optional force silent)
6465 "Go the subject line of ARTICLE.
6466 If FORCE, also allow jumping to articles not currently shown."
6467 (interactive "nArticle number: ")
6468 (unless (numberp article)
6469 (error "Article %s is not a number" article))
6471 (data (gnus-data-find article)))
6472 ;; We read in the article if we have to.
6475 (gnus-summary-insert-subject
6477 (if (or (numberp force) (vectorp force)) force)
6479 (setq data (gnus-data-find article)))
6484 (gnus-message 3 "Can't find article %d" article))
6486 (let ((pt (gnus-data-pos data)))
6488 (gnus-summary-set-article-display-arrow pt))
6489 (gnus-summary-position-point)
6492 ;; Walking around summary lines with displaying articles.
6494 (defun gnus-summary-expand-window (&optional arg)
6495 "Make the summary buffer take up the entire Emacs frame.
6496 Given a prefix, will force an `article' buffer configuration."
6499 (gnus-configure-windows 'article 'force)
6500 (gnus-configure-windows 'summary 'force)))
6502 (defun gnus-summary-display-article (article &optional all-header)
6503 "Display ARTICLE in article buffer."
6504 (when (gnus-buffer-live-p gnus-article-buffer)
6505 (with-current-buffer gnus-article-buffer
6506 (mm-enable-multibyte)))
6507 (gnus-set-global-variables)
6508 (when (gnus-buffer-live-p gnus-article-buffer)
6509 (with-current-buffer gnus-article-buffer
6510 (setq gnus-article-charset gnus-newsgroup-charset)
6511 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6512 (mm-enable-multibyte)))
6516 (if gnus-summary-display-article-function
6517 (funcall gnus-summary-display-article-function article all-header)
6518 (gnus-article-prepare article all-header))
6519 (gnus-run-hooks 'gnus-select-article-hook)
6520 (when (and gnus-current-article
6521 (not (zerop gnus-current-article)))
6522 (gnus-summary-goto-subject gnus-current-article))
6523 (gnus-summary-recenter)
6524 (when (and gnus-use-trees gnus-show-threads)
6525 (gnus-possibly-generate-tree article)
6526 (gnus-highlight-selected-tree article))
6527 ;; Successfully display article.
6528 (gnus-article-set-window-start
6529 (cdr (assq article gnus-newsgroup-bookmarks))))))
6531 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6532 "Select the current article.
6533 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6534 non-nil, the article will be re-fetched even if it already present in
6535 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6537 ;; Make sure we are in the summary buffer to work around bbdb bug.
6538 (unless (eq major-mode 'gnus-summary-mode)
6539 (set-buffer gnus-summary-buffer))
6540 (let ((article (or article (gnus-summary-article-number)))
6541 (all-headers (not (not all-headers))) ;Must be t or nil.
6542 gnus-summary-display-article-function)
6544 (gnus-summary-article-pseudo-p article)
6545 (error "This is a pseudo-article"))
6547 (set-buffer gnus-summary-buffer)
6548 (if (or (and gnus-single-article-buffer
6549 (or (null gnus-current-article)
6550 (null gnus-article-current)
6551 (null (get-buffer gnus-article-buffer))
6552 (not (eq article (cdr gnus-article-current)))
6553 (not (equal (car gnus-article-current)
6554 gnus-newsgroup-name))))
6555 (and (not gnus-single-article-buffer)
6556 (or (null gnus-current-article)
6557 (not (eq gnus-current-article article))))
6559 ;; The requested article is different from the current article.
6561 (gnus-summary-display-article article all-headers)
6562 (when (gnus-buffer-live-p gnus-article-buffer)
6563 (with-current-buffer gnus-article-buffer
6564 (if (not gnus-article-decoded-p) ;; a local variable
6565 (mm-disable-multibyte))))
6566 ;;; Hidden headers are not hidden text any more.
6567 ;; (when (or all-headers gnus-show-all-headers)
6568 ;; (gnus-article-show-all-headers))
6569 (gnus-article-set-window-start
6570 (cdr (assq article gnus-newsgroup-bookmarks)))
6572 ;; (when (or all-headers gnus-show-all-headers)
6573 ;; (gnus-article-show-all-headers))
6576 (defun gnus-summary-force-verify-and-decrypt ()
6578 (let ((mm-verify-option 'known)
6579 (mm-decrypt-option 'known))
6580 (gnus-summary-select-article nil 'force)))
6582 (defun gnus-summary-set-current-mark (&optional current-mark)
6583 "Obsolete function."
6586 (defun gnus-summary-next-article (&optional unread subject backward push)
6587 "Select the next article.
6588 If UNREAD, only unread articles are selected.
6589 If SUBJECT, only articles with SUBJECT are selected.
6590 If BACKWARD, the previous article is selected instead of the next."
6593 ;; Is there such an article?
6594 ((and (gnus-summary-search-forward unread subject backward)
6595 (or (gnus-summary-display-article (gnus-summary-article-number))
6596 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6597 (gnus-summary-position-point))
6598 ;; If not, we try the first unread, if that is wanted.
6600 gnus-auto-select-same
6601 (gnus-summary-first-unread-article))
6602 (gnus-summary-position-point)
6603 (gnus-message 6 "Wrapped"))
6604 ;; Try to get next/previous article not displayed in this group.
6605 ((and gnus-auto-extend-newsgroup
6606 (not unread) (not subject))
6607 (gnus-summary-goto-article
6608 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6609 nil (count-lines (point-min) (point))))
6610 ;; Go to next/previous group.
6612 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6613 (gnus-summary-jump-to-group gnus-newsgroup-name))
6614 (let ((cmd last-command-char)
6617 (set-buffer gnus-group-buffer)
6620 (if (eq gnus-keep-same-level 'best)
6621 (gnus-summary-best-group gnus-newsgroup-name)
6622 (gnus-summary-search-group backward gnus-keep-same-level))))
6623 ;; For some reason, the group window gets selected. We change
6625 (select-window (get-buffer-window (current-buffer)))
6626 ;; Select next unread newsgroup automagically.
6628 ((or (not gnus-auto-select-next)
6630 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6631 ((or (eq gnus-auto-select-next 'quietly)
6632 (and (eq gnus-auto-select-next 'slightly-quietly)
6634 (and (eq gnus-auto-select-next 'almost-quietly)
6635 (gnus-summary-last-article-p)))
6637 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6639 (gnus-message 7 "No more%s articles (%s)..."
6640 (if unread " unread" "")
6641 (if group (concat "selecting " group)
6643 (gnus-summary-next-group nil group backward)))
6645 (when (gnus-key-press-event-p last-input-event)
6646 (gnus-summary-walk-group-buffer
6647 gnus-newsgroup-name cmd unread backward point))))))))
6649 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6650 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6651 (?\C-p (gnus-group-prev-unread-group 1))))
6652 (cursor-in-echo-area t)
6653 keve key group ended)
6655 (set-buffer gnus-group-buffer)
6658 (if (eq gnus-keep-same-level 'best)
6659 (gnus-summary-best-group gnus-newsgroup-name)
6660 (gnus-summary-search-group backward gnus-keep-same-level))))
6663 5 "No more%s articles%s" (if unread " unread" "")
6665 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6666 (format " (Type %s for %s [%s])"
6667 (single-key-description cmd) group
6668 (car (gnus-gethash group gnus-newsrc-hashtb)))
6669 (format " (Type %s to exit %s)"
6670 (single-key-description cmd)
6671 gnus-newsgroup-name)))
6672 ;; Confirm auto selection.
6673 (setq key (car (setq keve (gnus-read-event-char))))
6676 ((assq key keystrokes)
6677 (let ((obuf (current-buffer)))
6678 (switch-to-buffer gnus-group-buffer)
6680 (gnus-group-jump-to-group group))
6681 (eval (cadr (assq key keystrokes)))
6682 (setq group (gnus-group-group-name))
6683 (switch-to-buffer obuf))
6687 (gnus-ephemeral-group-p gnus-newsgroup-name))
6689 (gnus-summary-next-group nil group backward)))
6691 (push (cdr keve) unread-command-events))))))
6693 (defun gnus-summary-next-unread-article ()
6694 "Select unread article after current one."
6696 (gnus-summary-next-article
6697 (or (not (eq gnus-summary-goto-unread 'never))
6698 (gnus-summary-last-article-p (gnus-summary-article-number)))
6699 (and gnus-auto-select-same
6700 (gnus-summary-article-subject))))
6702 (defun gnus-summary-prev-article (&optional unread subject)
6703 "Select the article after the current one.
6704 If UNREAD is non-nil, only unread articles are selected."
6706 (gnus-summary-next-article unread subject t))
6708 (defun gnus-summary-prev-unread-article ()
6709 "Select unread article before current one."
6711 (gnus-summary-prev-article
6712 (or (not (eq gnus-summary-goto-unread 'never))
6713 (gnus-summary-first-article-p (gnus-summary-article-number)))
6714 (and gnus-auto-select-same
6715 (gnus-summary-article-subject))))
6717 (defun gnus-summary-next-page (&optional lines circular)
6718 "Show next page of the selected article.
6719 If at the end of the current article, select the next article.
6720 LINES says how many lines should be scrolled up.
6722 If CIRCULAR is non-nil, go to the start of the article instead of
6723 selecting the next article when reaching the end of the current
6726 (setq gnus-summary-buffer (current-buffer))
6727 (gnus-set-global-variables)
6728 (let ((article (gnus-summary-article-number))
6729 (article-window (get-buffer-window gnus-article-buffer t))
6731 ;; If the buffer is empty, we have no article.
6733 (error "No article to select"))
6734 (gnus-configure-windows 'article)
6735 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6736 (if (and (eq gnus-summary-goto-unread 'never)
6737 (not (gnus-summary-last-article-p article)))
6738 (gnus-summary-next-article)
6739 (gnus-summary-next-unread-article))
6740 (if (or (null gnus-current-article)
6741 (null gnus-article-current)
6742 (/= article (cdr gnus-article-current))
6743 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6744 ;; Selected subject is different from current article's.
6745 (gnus-summary-display-article article)
6746 (when article-window
6747 (gnus-eval-in-buffer-window gnus-article-buffer
6748 (setq endp (gnus-article-next-page lines)))
6751 (gnus-summary-beginning-of-article))
6753 (gnus-message 3 "End of message"))
6755 (if (and (eq gnus-summary-goto-unread 'never)
6756 (not (gnus-summary-last-article-p article)))
6757 (gnus-summary-next-article)
6758 (gnus-summary-next-unread-article))))))))
6759 (gnus-summary-recenter)
6760 (gnus-summary-position-point)))
6762 (defun gnus-summary-prev-page (&optional lines move)
6763 "Show previous page of selected article.
6764 Argument LINES specifies lines to be scrolled down.
6765 If MOVE, move to the previous unread article if point is at
6766 the beginning of the buffer."
6768 (let ((article (gnus-summary-article-number))
6769 (article-window (get-buffer-window gnus-article-buffer t))
6771 (gnus-configure-windows 'article)
6772 (if (or (null gnus-current-article)
6773 (null gnus-article-current)
6774 (/= article (cdr gnus-article-current))
6775 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6776 ;; Selected subject is different from current article's.
6777 (gnus-summary-display-article article)
6778 (gnus-summary-recenter)
6779 (when article-window
6780 (gnus-eval-in-buffer-window gnus-article-buffer
6781 (setq endp (gnus-article-prev-page lines)))
6782 (when (and move endp)
6784 (gnus-message 3 "Beginning of message"))
6786 (if (and (eq gnus-summary-goto-unread 'never)
6787 (not (gnus-summary-first-article-p article)))
6788 (gnus-summary-prev-article)
6789 (gnus-summary-prev-unread-article))))))))
6790 (gnus-summary-position-point))
6792 (defun gnus-summary-prev-page-or-article (&optional lines)
6793 "Show previous page of selected article.
6794 Argument LINES specifies lines to be scrolled down.
6795 If at the beginning of the article, go to the next article."
6797 (gnus-summary-prev-page lines t))
6799 (defun gnus-summary-scroll-up (lines)
6800 "Scroll up (or down) one line current article.
6801 Argument LINES specifies lines to be scrolled up (or down if negative)."
6803 (gnus-configure-windows 'article)
6804 (gnus-summary-show-thread)
6805 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6806 (gnus-eval-in-buffer-window gnus-article-buffer
6808 (when (gnus-article-next-page lines)
6809 (gnus-message 3 "End of message")))
6811 (gnus-article-prev-page (- lines))))))
6812 (gnus-summary-recenter)
6813 (gnus-summary-position-point))
6815 (defun gnus-summary-scroll-down (lines)
6816 "Scroll down (or up) one line current article.
6817 Argument LINES specifies lines to be scrolled down (or up if negative)."
6819 (gnus-summary-scroll-up (- lines)))
6821 (defun gnus-summary-next-same-subject ()
6822 "Select next article which has the same subject as current one."
6824 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6826 (defun gnus-summary-prev-same-subject ()
6827 "Select previous article which has the same subject as current one."
6829 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6831 (defun gnus-summary-next-unread-same-subject ()
6832 "Select next unread article which has the same subject as current one."
6834 (gnus-summary-next-article t (gnus-summary-article-subject)))
6836 (defun gnus-summary-prev-unread-same-subject ()
6837 "Select previous unread article which has the same subject as current one."
6839 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6841 (defun gnus-summary-first-unread-article ()
6842 "Select the first unread article.
6843 Return nil if there are no unread articles."
6846 (when (gnus-summary-first-subject t)
6847 (gnus-summary-show-thread)
6848 (gnus-summary-first-subject t)
6849 (gnus-summary-display-article (gnus-summary-article-number)))
6850 (gnus-summary-position-point)))
6852 (defun gnus-summary-first-unread-subject ()
6853 "Place the point on the subject line of the first unread article.
6854 Return nil if there are no unread articles."
6857 (when (gnus-summary-first-subject t)
6858 (gnus-summary-show-thread)
6859 (gnus-summary-first-subject t))
6860 (gnus-summary-position-point)))
6862 (defun gnus-summary-first-unseen-subject ()
6863 "Place the point on the subject line of the first unseen article.
6864 Return nil if there are no unseen articles."
6867 (when (gnus-summary-first-subject t t t)
6868 (gnus-summary-show-thread)
6869 (gnus-summary-first-subject t t t))
6870 (gnus-summary-position-point)))
6872 (defun gnus-summary-first-unseen-or-unread-subject ()
6873 "Place the point on the subject line of the first unseen article.
6874 Return nil if there are no unseen articles."
6877 (unless (when (gnus-summary-first-subject t t t)
6878 (gnus-summary-show-thread)
6879 (gnus-summary-first-subject t t t))
6880 (when (gnus-summary-first-subject t)
6881 (gnus-summary-show-thread)
6882 (gnus-summary-first-subject t)))
6883 (gnus-summary-position-point)))
6885 (defun gnus-summary-first-article ()
6886 "Select the first article.
6887 Return nil if there are no articles."
6890 (when (gnus-summary-first-subject)
6891 (gnus-summary-show-thread)
6892 (gnus-summary-first-subject)
6893 (gnus-summary-display-article (gnus-summary-article-number)))
6894 (gnus-summary-position-point)))
6896 (defun gnus-summary-best-unread-article (&optional arg)
6897 "Select the unread article with the highest score.
6898 If given a prefix argument, select the next unread article that has a
6899 score higher than the default score."
6901 (let ((article (if arg
6902 (gnus-summary-better-unread-subject)
6903 (gnus-summary-best-unread-subject))))
6905 (gnus-summary-goto-article article)
6906 (error "No unread articles"))))
6908 (defun gnus-summary-best-unread-subject ()
6909 "Select the unread subject with the highest score."
6911 (let ((best -1000000)
6912 (data gnus-newsgroup-data)
6915 (and (gnus-data-unread-p (car data))
6917 (gnus-summary-article-score (gnus-data-number (car data))))
6920 article (gnus-data-number (car data))))
6921 (setq data (cdr data)))
6923 (gnus-summary-goto-subject article))
6924 (gnus-summary-position-point)
6927 (defun gnus-summary-better-unread-subject ()
6928 "Select the first unread subject that has a score over the default score."
6930 (let ((data gnus-newsgroup-data)
6932 (while (and (setq article (gnus-data-number (car data)))
6933 (or (gnus-data-read-p (car data))
6934 (not (> (gnus-summary-article-score article)
6935 gnus-summary-default-score))))
6936 (setq data (cdr data)))
6938 (gnus-summary-goto-subject article))
6939 (gnus-summary-position-point)
6942 (defun gnus-summary-last-subject ()
6943 "Go to the last displayed subject line in the group."
6944 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6946 (gnus-summary-goto-subject article))))
6948 (defun gnus-summary-goto-article (article &optional all-headers force)
6949 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6950 If ALL-HEADERS is non-nil, no header lines are hidden.
6951 If FORCE, go to the article even if it isn't displayed. If FORCE
6952 is a number, it is the line the article is to be displayed on."
6956 "Article number or Message-ID: "
6957 (mapcar (lambda (number) (list (int-to-string number)))
6958 gnus-newsgroup-limit))
6962 (if (and (stringp article)
6963 (string-match "@" article))
6964 (gnus-summary-refer-article article)
6965 (when (stringp article)
6966 (setq article (string-to-number article)))
6967 (if (gnus-summary-goto-subject article force)
6968 (gnus-summary-display-article article all-headers)
6969 (gnus-message 4 "Couldn't go to article %s" article) nil))
6970 (gnus-summary-position-point)))
6972 (defun gnus-summary-goto-last-article ()
6973 "Go to the previously read article."
6976 (when gnus-last-article
6977 (gnus-summary-goto-article gnus-last-article nil t))
6978 (gnus-summary-position-point)))
6980 (defun gnus-summary-pop-article (number)
6981 "Pop one article off the history and go to the previous.
6982 NUMBER articles will be popped off."
6985 (setq gnus-newsgroup-history
6986 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6988 (gnus-summary-goto-article (car to) nil t)
6989 (error "Article history empty")))
6990 (gnus-summary-position-point))
6992 ;; Summary commands and functions for limiting the summary buffer.
6994 (defun gnus-summary-limit-to-articles (n)
6995 "Limit the summary buffer to the next N articles.
6996 If not given a prefix, use the process marked articles instead."
6999 (let ((articles (gnus-summary-work-articles n)))
7000 (setq gnus-newsgroup-processable nil)
7001 (gnus-summary-limit articles))
7002 (gnus-summary-position-point)))
7004 (defun gnus-summary-pop-limit (&optional total)
7005 "Restore the previous limit.
7006 If given a prefix, remove all limits."
7009 (setq gnus-newsgroup-limits
7010 (list (mapcar (lambda (h) (mail-header-number h))
7011 gnus-newsgroup-headers))))
7012 (unless gnus-newsgroup-limits
7013 (error "No limit to pop"))
7015 (gnus-summary-limit nil 'pop)
7016 (gnus-summary-position-point)))
7018 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7019 "Limit the summary buffer to articles that have subjects that match a regexp.
7020 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7022 (list (read-string (if current-prefix-arg
7023 "Exclude subject (regexp): "
7024 "Limit to subject (regexp): "))
7025 nil current-prefix-arg))
7027 (setq header "subject"))
7028 (when (not (equal "" subject))
7030 (let ((articles (gnus-summary-find-matching
7031 (or header "subject") subject 'all nil nil
7034 (error "Found no matches for \"%s\"" subject))
7035 (gnus-summary-limit articles))
7036 (gnus-summary-position-point))))
7038 (defun gnus-summary-limit-to-author (from &optional not-matching)
7039 "Limit the summary buffer to articles that have authors that match a regexp.
7040 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7042 (list (read-string (if current-prefix-arg
7043 "Exclude author (regexp): "
7044 "Limit to author (regexp): "))
7045 current-prefix-arg))
7046 (gnus-summary-limit-to-subject from "from" not-matching))
7048 (defun gnus-summary-limit-to-age (age &optional younger-p)
7049 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7050 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7051 articles that are younger than AGE days."
7053 (let ((younger current-prefix-arg)
7056 (while (not days-got)
7057 (setq days (if younger
7058 (read-string "Limit to articles within (in days): ")
7059 (read-string "Limit to articles older than (in days): ")))
7060 (when (> (length days) 0)
7061 (setq days (read days)))
7067 (setq younger (not younger))
7068 (setq days (* days -1)))))
7069 (message "Please enter a number.")
7071 (list days younger)))
7073 (let ((data gnus-newsgroup-data)
7074 (cutoff (days-to-time age))
7075 articles d date is-younger)
7076 (while (setq d (pop data))
7077 (when (and (vectorp (gnus-data-header d))
7078 (setq date (mail-header-date (gnus-data-header d))))
7079 (setq is-younger (time-less-p
7080 (time-since (condition-case ()
7087 (push (gnus-data-number d) articles))))
7088 (gnus-summary-limit (nreverse articles)))
7089 (gnus-summary-position-point)))
7091 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7092 "Limit the summary buffer to articles that match an 'extra' header."
7096 (gnus-completing-read-with-default
7097 (symbol-name (car gnus-extra-headers))
7098 (if current-prefix-arg
7099 "Exclude extra header:"
7100 "Limit extra header:")
7102 (cons (symbol-name x) x))
7107 (read-string (format "%s header %s (regexp): "
7108 (if current-prefix-arg "Exclude" "Limit to")
7110 current-prefix-arg)))
7111 (when (not (equal "" regexp))
7113 (let ((articles (gnus-summary-find-matching
7114 (cons 'extra header) regexp 'all nil nil
7117 (error "Found no matches for \"%s\"" regexp))
7118 (gnus-summary-limit articles))
7119 (gnus-summary-position-point))))
7121 (defun gnus-summary-limit-to-display-predicate ()
7122 "Limit the summary buffer to the predicated in the `display' group parameter."
7124 (unless gnus-newsgroup-display
7125 (error "There is no `display' group parameter"))
7127 (dolist (number gnus-newsgroup-articles)
7128 (when (funcall gnus-newsgroup-display)
7129 (push number articles)))
7130 (gnus-summary-limit articles))
7131 (gnus-summary-position-point))
7133 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7135 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7137 (defun gnus-summary-limit-to-unread (&optional all)
7138 "Limit the summary buffer to articles that are not marked as read.
7139 If ALL is non-nil, limit strictly to unread articles."
7142 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7143 (gnus-summary-limit-to-marks
7144 ;; Concat all the marks that say that an article is read and have
7146 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7147 gnus-killed-mark gnus-kill-file-mark
7148 gnus-low-score-mark gnus-expirable-mark
7149 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7150 gnus-duplicate-mark gnus-souped-mark)
7153 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7154 (make-obsolete 'gnus-summary-delete-marked-with
7155 'gnus-summary-limit-exlude-marks)
7157 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7158 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7159 If REVERSE, limit the summary buffer to articles that are marked
7160 with MARKS. MARKS can either be a string of marks or a list of marks.
7161 Returns how many articles were removed."
7162 (interactive "sMarks: ")
7163 (gnus-summary-limit-to-marks marks t))
7165 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7166 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7167 If REVERSE (the prefix), limit the summary buffer to articles that are
7168 not marked with MARKS. MARKS can either be a string of marks or a
7170 Returns how many articles were removed."
7171 (interactive "sMarks: \nP")
7173 (let ((data gnus-newsgroup-data)
7174 (marks (if (listp marks) marks
7175 (append marks nil))) ; Transform to list.
7178 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7179 (memq (gnus-data-mark (car data)) marks))
7180 (push (gnus-data-number (car data)) articles))
7181 (setq data (cdr data)))
7182 (gnus-summary-limit articles))
7183 (gnus-summary-position-point)))
7185 (defun gnus-summary-limit-to-score (score)
7186 "Limit to articles with score at or above SCORE."
7187 (interactive "NLimit to articles with score of at least: ")
7188 (let ((data gnus-newsgroup-data)
7191 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7193 (push (gnus-data-number (car data)) articles))
7194 (setq data (cdr data)))
7196 (gnus-summary-limit articles)
7197 (gnus-summary-position-point))))
7199 (defun gnus-summary-limit-include-thread (id)
7200 "Display all the hidden articles that is in the thread with ID in it.
7201 When called interactively, ID is the Message-ID of the current
7203 (interactive (list (mail-header-id (gnus-summary-article-header))))
7204 (let ((articles (gnus-articles-in-thread
7205 (gnus-id-to-thread (gnus-root-id id)))))
7207 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7208 (gnus-summary-limit-include-matching-articles
7210 (regexp-quote (gnus-simplify-subject-re
7211 (mail-header-subject (gnus-id-to-header id)))))
7212 (gnus-summary-position-point))))
7214 (defun gnus-summary-limit-include-matching-articles (header regexp)
7215 "Display all the hidden articles that have HEADERs that match REGEXP."
7216 (interactive (list (read-string "Match on header: ")
7217 (read-string "Regexp: ")))
7218 (let ((articles (gnus-find-matching-articles header regexp)))
7220 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7221 (gnus-summary-position-point))))
7223 (defun gnus-summary-limit-include-dormant ()
7224 "Display all the hidden articles that are marked as dormant.
7225 Note that this command only works on a subset of the articles currently
7226 fetched for this group."
7228 (unless gnus-newsgroup-dormant
7229 (error "There are no dormant articles in this group"))
7231 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7232 (gnus-summary-position-point)))
7234 (defun gnus-summary-limit-exclude-dormant ()
7235 "Hide all dormant articles."
7238 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7239 (gnus-summary-position-point)))
7241 (defun gnus-summary-limit-exclude-childless-dormant ()
7242 "Hide all dormant articles that have no children."
7244 (let ((data (gnus-data-list t))
7245 articles d children)
7246 ;; Find all articles that are either not dormant or have
7248 (while (setq d (pop data))
7249 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7251 (gnus-article-children (gnus-data-number d)))
7254 (when (memq (car children) articles)
7259 (push (gnus-data-number d) articles)))
7262 (gnus-summary-limit articles)
7263 (gnus-summary-position-point))))
7265 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7266 "Mark all unread excluded articles as read.
7267 If ALL, mark even excluded ticked and dormants as read."
7269 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7270 (let ((articles (gnus-sorted-ndifference
7272 (mapcar (lambda (h) (mail-header-number h))
7273 gnus-newsgroup-headers)
7275 gnus-newsgroup-limit))
7277 (setq gnus-newsgroup-unreads
7278 (gnus-sorted-intersection gnus-newsgroup-unreads
7279 gnus-newsgroup-limit))
7281 (setq gnus-newsgroup-dormant nil
7282 gnus-newsgroup-marked nil
7283 gnus-newsgroup-reads
7285 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7286 gnus-newsgroup-reads))
7287 (while (setq article (pop articles))
7288 (unless (or (memq article gnus-newsgroup-dormant)
7289 (memq article gnus-newsgroup-marked))
7290 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7292 (defun gnus-summary-limit (articles &optional pop)
7294 ;; We pop the previous limit off the stack and use that.
7295 (setq articles (car gnus-newsgroup-limits)
7296 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7297 ;; We use the new limit, so we push the old limit on the stack.
7298 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7300 (setq gnus-newsgroup-limit articles)
7301 (let ((total (length gnus-newsgroup-data))
7302 (data (gnus-data-find-list (gnus-summary-article-number)))
7303 (gnus-summary-mark-below nil) ; Inhibit this.
7305 ;; This will do all the work of generating the new summary buffer
7306 ;; according to the new limit.
7307 (gnus-summary-prepare)
7308 ;; Hide any threads, possibly.
7309 (gnus-summary-maybe-hide-threads)
7310 ;; Try to return to the article you were at, or one in the
7313 ;; We try to find some article after the current one.
7315 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7318 (setq data (cdr data))))
7320 ;; If there is no data, that means that we were after the last
7321 ;; article. The same goes when we can't find any articles
7322 ;; after the current one.
7323 (goto-char (point-max))
7324 (gnus-summary-find-prev))
7325 (gnus-set-mode-line 'summary)
7326 ;; We return how many articles were removed from the summary
7327 ;; buffer as a result of the new limit.
7328 (- total (length gnus-newsgroup-data))))
7330 (defsubst gnus-invisible-cut-children (threads)
7333 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7338 (defsubst gnus-cut-thread (thread)
7339 "Go forwards in the thread until we find an article that we want to display."
7340 (when (or (eq gnus-fetch-old-headers 'some)
7341 (eq gnus-fetch-old-headers 'invisible)
7342 (numberp gnus-fetch-old-headers)
7343 (eq gnus-build-sparse-threads 'some)
7344 (eq gnus-build-sparse-threads 'more))
7345 ;; Deal with old-fetched headers and sparse threads.
7349 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7350 (gnus-summary-article-ancient-p
7351 (mail-header-number (car thread))))
7352 (if (or (<= (length (cdr thread)) 1)
7353 (eq gnus-fetch-old-headers 'invisible))
7354 (setq gnus-newsgroup-limit
7355 (delq (mail-header-number (car thread))
7356 gnus-newsgroup-limit)
7357 thread (cadr thread))
7358 (when (gnus-invisible-cut-children (cdr thread))
7359 (let ((th (cdr thread)))
7361 (if (memq (mail-header-number (caar th))
7362 gnus-newsgroup-limit)
7363 (setq thread (car th)
7365 (setq th (cdr th))))))))))
7368 (defun gnus-cut-threads (threads)
7369 "Cut off all uninteresting articles from the beginning of threads."
7370 (when (or (eq gnus-fetch-old-headers 'some)
7371 (eq gnus-fetch-old-headers 'invisible)
7372 (numberp gnus-fetch-old-headers)
7373 (eq gnus-build-sparse-threads 'some)
7374 (eq gnus-build-sparse-threads 'more))
7377 (setcar th (gnus-cut-thread (car th)))
7378 (setq th (cdr th)))))
7379 ;; Remove nixed out threads.
7382 (defun gnus-summary-initial-limit (&optional show-if-empty)
7383 "Figure out what the initial limit is supposed to be on group entry.
7384 This entails weeding out unwanted dormants, low-scored articles,
7385 fetch-old-headers verbiage, and so on."
7386 ;; Most groups have nothing to remove.
7387 (if (or gnus-inhibit-limiting
7388 (and (null gnus-newsgroup-dormant)
7389 (eq gnus-newsgroup-display 'gnus-not-ignore)
7390 (not (eq gnus-fetch-old-headers 'some))
7391 (not (numberp gnus-fetch-old-headers))
7392 (not (eq gnus-fetch-old-headers 'invisible))
7393 (null gnus-summary-expunge-below)
7394 (not (eq gnus-build-sparse-threads 'some))
7395 (not (eq gnus-build-sparse-threads 'more))
7396 (null gnus-thread-expunge-below)
7397 (not gnus-use-nocem)))
7399 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7400 (setq gnus-newsgroup-limit nil)
7403 (unless (car (symbol-value node))
7404 ;; These threads have no parents -- they are roots.
7405 (let ((nodes (cdr (symbol-value node)))
7408 (if (and gnus-thread-expunge-below
7409 (< (gnus-thread-total-score (car nodes))
7410 gnus-thread-expunge-below))
7411 (gnus-expunge-thread (pop nodes))
7412 (setq thread (pop nodes))
7413 (gnus-summary-limit-children thread))))))
7414 gnus-newsgroup-dependencies)
7415 ;; If this limitation resulted in an empty group, we might
7416 ;; pop the previous limit and use it instead.
7417 (when (and (not gnus-newsgroup-limit)
7419 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7420 gnus-newsgroup-limit))
7422 (defun gnus-summary-limit-children (thread)
7423 "Return 1 if this subthread is visible and 0 if it is not."
7424 ;; First we get the number of visible children to this thread. This
7425 ;; is done by recursing down the thread using this function, so this
7426 ;; will really go down to a leaf article first, before slowly
7427 ;; working its way up towards the root.
7431 (apply '+ (mapcar 'gnus-summary-limit-children
7434 (number (mail-header-number (car thread)))
7437 (not (memq number gnus-newsgroup-marked))
7439 ;; If this article is dormant and has absolutely no visible
7440 ;; children, then this article isn't visible.
7441 (and (memq number gnus-newsgroup-dormant)
7443 ;; If this is "fetch-old-headered" and there is no
7444 ;; visible children, then we don't want this article.
7445 (and (or (eq gnus-fetch-old-headers 'some)
7446 (numberp gnus-fetch-old-headers))
7447 (gnus-summary-article-ancient-p number)
7449 ;; If this is "fetch-old-headered" and `invisible', then
7450 ;; we don't want this article.
7451 (and (eq gnus-fetch-old-headers 'invisible)
7452 (gnus-summary-article-ancient-p number))
7453 ;; If this is a sparsely inserted article with no children,
7454 ;; we don't want it.
7455 (and (eq gnus-build-sparse-threads 'some)
7456 (gnus-summary-article-sparse-p number)
7458 ;; If we use expunging, and this article is really
7459 ;; low-scored, then we don't want this article.
7460 (when (and gnus-summary-expunge-below
7462 (or (cdr (assq number gnus-newsgroup-scored))
7463 gnus-summary-default-score))
7464 gnus-summary-expunge-below))
7465 ;; We increase the expunge-tally here, but that has
7466 ;; nothing to do with the limits, really.
7467 (incf gnus-newsgroup-expunged-tally)
7468 ;; We also mark as read here, if that's wanted.
7469 (when (and gnus-summary-mark-below
7470 (< score gnus-summary-mark-below))
7471 (setq gnus-newsgroup-unreads
7472 (delq number gnus-newsgroup-unreads))
7473 (if gnus-newsgroup-auto-expire
7474 (push number gnus-newsgroup-expirable)
7475 (push (cons number gnus-low-score-mark)
7476 gnus-newsgroup-reads)))
7478 ;; Do the `display' group parameter.
7479 (and gnus-newsgroup-display
7480 (not (funcall gnus-newsgroup-display)))
7481 ;; Check NoCeM things.
7482 (if (and gnus-use-nocem
7483 (gnus-nocem-unwanted-article-p
7484 (mail-header-id (car thread))))
7486 (setq gnus-newsgroup-unreads
7487 (delq number gnus-newsgroup-unreads))
7489 ;; Nope, invisible article.
7491 ;; Ok, this article is to be visible, so we add it to the limit
7493 (push number gnus-newsgroup-limit)
7496 (defun gnus-expunge-thread (thread)
7497 "Mark all articles in THREAD as read."
7498 (let* ((number (mail-header-number (car thread))))
7499 (incf gnus-newsgroup-expunged-tally)
7500 ;; We also mark as read here, if that's wanted.
7501 (setq gnus-newsgroup-unreads
7502 (delq number gnus-newsgroup-unreads))
7503 (if gnus-newsgroup-auto-expire
7504 (push number gnus-newsgroup-expirable)
7505 (push (cons number gnus-low-score-mark)
7506 gnus-newsgroup-reads)))
7507 ;; Go recursively through all subthreads.
7508 (mapcar 'gnus-expunge-thread (cdr thread)))
7510 ;; Summary article oriented commands
7512 (defun gnus-summary-refer-parent-article (n)
7513 "Refer parent article N times.
7514 If N is negative, go to ancestor -N instead.
7515 The difference between N and the number of articles fetched is returned."
7519 (when (not (natnump n))
7524 (setq header (gnus-summary-article-header))
7525 (if (and (eq (mail-header-number header)
7526 (cdr gnus-article-current))
7527 (equal gnus-newsgroup-name
7528 (car gnus-article-current)))
7529 ;; If we try to find the parent of the currently
7530 ;; displayed article, then we take a look at the actual
7531 ;; References header, since this is slightly more
7532 ;; reliable than the References field we got from the
7535 (set-buffer gnus-original-article-buffer)
7536 (nnheader-narrow-to-headers)
7537 (unless (setq ref (message-fetch-field "references"))
7538 (setq ref (message-fetch-field "in-reply-to")))
7541 ;; It's not the current article, so we take a bet on
7542 ;; the value we got from the server.
7543 (mail-header-references header)))
7545 (not (equal ref "")))
7546 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7547 (gnus-message 1 "Couldn't find parent"))
7548 (gnus-message 1 "No references in article %d"
7549 (gnus-summary-article-number))
7552 (gnus-summary-position-point)
7555 (defun gnus-summary-refer-references ()
7556 "Fetch all articles mentioned in the References header.
7557 Return the number of articles fetched."
7559 (let ((ref (mail-header-references (gnus-summary-article-header)))
7560 (current (gnus-summary-article-number))
7564 (error "No References in the current article")
7565 ;; For each Message-ID in the References header...
7566 (while (string-match "<[^>]*>" ref)
7568 ;; ... fetch that article.
7569 (gnus-summary-refer-article
7570 (prog1 (match-string 0 ref)
7571 (setq ref (substring ref (match-end 0))))))
7572 (gnus-summary-goto-subject current)
7573 (gnus-summary-position-point)
7576 (defun gnus-summary-refer-thread (&optional limit)
7577 "Fetch all articles in the current thread.
7578 If LIMIT (the numerical prefix), fetch that many old headers instead
7579 of what's specified by the `gnus-refer-thread-limit' variable."
7581 (let ((id (mail-header-id (gnus-summary-article-header)))
7582 (limit (if limit (prefix-numeric-value limit)
7583 gnus-refer-thread-limit)))
7584 ;; We want to fetch LIMIT *old* headers, but we also have to
7585 ;; re-fetch all the headers in the current buffer, because many of
7586 ;; them may be undisplayed. So we adjust LIMIT.
7587 (when (numberp limit)
7588 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7589 (unless (eq gnus-fetch-old-headers 'invisible)
7590 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7591 ;; Retrieve the headers and read them in.
7592 (if (eq (gnus-retrieve-headers
7593 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7595 (gnus-build-all-threads)
7596 (error "Can't fetch thread from backends that don't support NOV"))
7597 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7598 (gnus-summary-limit-include-thread id)))
7600 (defun gnus-summary-refer-article (message-id)
7601 "Fetch an article specified by MESSAGE-ID."
7602 (interactive "sMessage-ID: ")
7603 (when (and (stringp message-id)
7604 (not (zerop (length message-id))))
7605 ;; Construct the correct Message-ID if necessary.
7606 ;; Suggested by tale@pawl.rpi.edu.
7607 (unless (string-match "^<" message-id)
7608 (setq message-id (concat "<" message-id)))
7609 (unless (string-match ">$" message-id)
7610 (setq message-id (concat message-id ">")))
7611 (let* ((header (gnus-id-to-header message-id))
7613 (gnus-summary-article-sparse-p
7614 (mail-header-number header))
7615 (memq (mail-header-number header)
7616 gnus-newsgroup-limit)))
7619 ;; If the article is present in the buffer we just go to it.
7621 (or (not (gnus-summary-article-sparse-p
7622 (mail-header-number header)))
7625 (gnus-summary-goto-article
7626 (mail-header-number header) nil t)
7628 (gnus-summary-update-article (mail-header-number header)))))
7630 ;; We fetch the article.
7632 (dolist (gnus-override-method (gnus-refer-article-methods))
7633 (gnus-check-server gnus-override-method)
7634 ;; Fetch the header, and display the article.
7635 (when (setq number (gnus-summary-insert-subject message-id))
7636 (gnus-summary-select-article nil nil nil number)
7638 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7640 (defun gnus-refer-article-methods ()
7641 "Return a list of referrable methods."
7643 ;; No method, so we default to current and native.
7644 ((null gnus-refer-article-method)
7645 (list gnus-current-select-method gnus-select-method))
7647 ((eq 'current gnus-refer-article-method)
7648 (list gnus-current-select-method))
7649 ;; List of select methods.
7650 ((not (and (symbolp (car gnus-refer-article-method))
7651 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7653 (dolist (method gnus-refer-article-method)
7654 (push (if (eq 'current method)
7655 gnus-current-select-method
7659 ;; One single select method.
7661 (list gnus-refer-article-method))))
7663 (defun gnus-summary-edit-parameters ()
7664 "Edit the group parameters of the current group."
7666 (gnus-group-edit-group gnus-newsgroup-name 'params))
7668 (defun gnus-summary-customize-parameters ()
7669 "Customize the group parameters of the current group."
7671 (gnus-group-customize gnus-newsgroup-name))
7673 (defun gnus-summary-enter-digest-group (&optional force)
7674 "Enter an nndoc group based on the current article.
7675 If FORCE, force a digest interpretation. If not, try
7676 to guess what the document format is."
7678 (let ((conf gnus-current-window-configuration))
7680 (gnus-summary-select-article))
7681 (setq gnus-current-window-configuration conf)
7682 (let* ((name (format "%s-%d"
7683 (gnus-group-prefixed-name
7684 gnus-newsgroup-name (list 'nndoc ""))
7686 (set-buffer gnus-summary-buffer)
7687 gnus-current-article)))
7688 (ogroup gnus-newsgroup-name)
7689 (params (append (gnus-info-params (gnus-get-info ogroup))
7690 (list (cons 'to-group ogroup))
7691 (list (cons 'save-article-group ogroup))))
7692 (case-fold-search t)
7693 (buf (current-buffer))
7696 (set-buffer gnus-original-article-buffer)
7697 ;; Have the digest group inherit the main mail address of
7698 ;; the parent article.
7699 (when (setq to-address (or (message-fetch-field "reply-to")
7700 (message-fetch-field "from")))
7701 (setq params (append
7702 (list (cons 'to-address
7703 (funcall gnus-decode-encoded-word-function
7705 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7706 (insert-buffer-substring gnus-original-article-buffer)
7707 ;; Remove lines that may lead nndoc to misinterpret the
7710 (goto-char (point-min))
7711 (or (search-forward "\n\n" nil t) (point)))
7712 (goto-char (point-min))
7713 (delete-matching-lines "^Path:\\|^From ")
7716 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7717 (gnus-newsgroup-ephemeral-ignored-charsets
7718 gnus-newsgroup-ignored-charsets))
7719 (gnus-group-read-ephemeral-group
7720 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7722 ,(if force 'mbox 'guess)))
7724 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7726 ;; Make all postings to this group go to the parent group.
7727 (nconc (gnus-info-params (gnus-get-info name))
7729 ;; Couldn't select this doc group.
7730 (switch-to-buffer buf)
7731 (gnus-set-global-variables)
7732 (gnus-configure-windows 'summary)
7733 (gnus-message 3 "Article couldn't be entered?"))
7734 (kill-buffer dig)))))
7736 (defun gnus-summary-read-document (n)
7737 "Open a new group based on the current article(s).
7738 This will allow you to read digests and other similar
7739 documents as newsgroups.
7740 Obeys the standard process/prefix convention."
7742 (let* ((articles (gnus-summary-work-articles n))
7743 (ogroup gnus-newsgroup-name)
7744 (params (append (gnus-info-params (gnus-get-info ogroup))
7745 (list (cons 'to-group ogroup))))
7746 article group egroup groups vgroup)
7747 (while (setq article (pop articles))
7748 (setq group (format "%s-%d" gnus-newsgroup-name article))
7749 (gnus-summary-remove-process-mark article)
7750 (when (gnus-summary-display-article article)
7753 (insert-buffer-substring gnus-original-article-buffer)
7754 ;; Remove some headers that may lead nndoc to make
7756 (message-narrow-to-head)
7757 (goto-char (point-min))
7758 (delete-matching-lines "^\\(Path\\):\\|^From ")
7761 (gnus-group-read-ephemeral-group
7762 group `(nndoc ,group (nndoc-address ,(current-buffer))
7763 (nndoc-article-type guess))
7766 ;; Make all postings to this group go to the parent group.
7767 (nconc (gnus-info-params (gnus-get-info egroup))
7769 (push egroup groups))
7770 ;; Couldn't select this doc group.
7771 (gnus-error 3 "Article couldn't be entered"))))))
7772 ;; Now we have selected all the documents.
7775 (error "None of the articles could be interpreted as documents"))
7776 ((gnus-group-read-ephemeral-group
7777 (setq vgroup (format
7778 "nnvirtual:%s-%s" gnus-newsgroup-name
7779 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7780 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7782 (cons (current-buffer) 'summary)))
7784 (error "Couldn't select virtual nndoc group")))))
7786 (defun gnus-summary-isearch-article (&optional regexp-p)
7787 "Do incremental search forward on the current article.
7788 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7790 (gnus-summary-select-article)
7791 (gnus-configure-windows 'article)
7792 (gnus-eval-in-buffer-window gnus-article-buffer
7795 (isearch-forward regexp-p))))
7797 (defun gnus-summary-search-article-forward (regexp &optional backward)
7798 "Search for an article containing REGEXP forward.
7799 If BACKWARD, search backward instead."
7802 (format "Search article %s (regexp%s): "
7803 (if current-prefix-arg "backward" "forward")
7804 (if gnus-last-search-regexp
7805 (concat ", default " gnus-last-search-regexp)
7807 current-prefix-arg))
7808 (if (string-equal regexp "")
7809 (setq regexp (or gnus-last-search-regexp ""))
7810 (setq gnus-last-search-regexp regexp)
7811 (setq gnus-article-before-search gnus-current-article))
7812 ;; Intentionally set gnus-last-article.
7813 (setq gnus-last-article gnus-article-before-search)
7814 (let ((gnus-last-article gnus-last-article))
7815 (if (gnus-summary-search-article regexp backward)
7816 (gnus-summary-show-thread)
7817 (error "Search failed: \"%s\"" regexp))))
7819 (defun gnus-summary-search-article-backward (regexp)
7820 "Search for an article containing REGEXP backward."
7823 (format "Search article backward (regexp%s): "
7824 (if gnus-last-search-regexp
7825 (concat ", default " gnus-last-search-regexp)
7827 (gnus-summary-search-article-forward regexp 'backward))
7829 (defun gnus-summary-search-article (regexp &optional backward)
7830 "Search for an article containing REGEXP.
7831 Optional argument BACKWARD means do search for backward.
7832 `gnus-select-article-hook' is not called during the search."
7833 ;; We have to require this here to make sure that the following
7834 ;; dynamic binding isn't shadowed by autoloading.
7835 (require 'gnus-async)
7837 (let ((gnus-select-article-hook nil) ;Disable hook.
7838 (gnus-article-prepare-hook nil)
7839 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7840 (gnus-use-article-prefetch nil)
7841 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7842 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7843 (sum (current-buffer))
7844 (gnus-display-mime-function nil)
7847 (gnus-save-hidden-threads
7848 (gnus-summary-select-article)
7849 (set-buffer gnus-article-buffer)
7850 (goto-char (window-point (get-buffer-window (current-buffer))))
7854 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7856 (re-search-backward regexp nil t)
7857 (re-search-forward regexp nil t))
7858 ;; We found the regexp.
7863 (get-buffer-window (current-buffer))
7867 (get-buffer-window (current-buffer))
7870 (setq point (point)))
7871 ;; We didn't find it, so we go to the next article.
7874 (while (eq found 'not)
7875 (if (not (if backward (gnus-summary-find-prev)
7876 (gnus-summary-find-next)))
7877 ;; No more articles.
7879 ;; Select the next article and adjust point.
7880 (unless (gnus-summary-article-sparse-p
7881 (gnus-summary-article-number))
7883 (gnus-summary-select-article)
7884 (set-buffer gnus-article-buffer)
7886 (goto-char (if backward (point-max) (point-min))))))))
7887 (gnus-message 7 ""))
7888 ;; Return whether we found the regexp.
7889 (when (eq found 'found)
7891 (gnus-summary-show-thread)
7892 (gnus-summary-goto-subject gnus-current-article)
7893 (gnus-summary-position-point)
7896 (defun gnus-find-matching-articles (header regexp)
7897 "Return a list of all articles that match REGEXP on HEADER.
7898 This search includes all articles in the current group that Gnus has
7899 fetched headers for, whether they are displayed or not."
7900 (let ((articles nil)
7901 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7902 (case-fold-search t))
7903 (dolist (header gnus-newsgroup-headers)
7904 (when (string-match regexp (funcall func header))
7905 (push (mail-header-number header) articles)))
7906 (nreverse articles)))
7908 (defun gnus-summary-find-matching (header regexp &optional backward unread
7909 not-case-fold not-matching)
7910 "Return a list of all articles that match REGEXP on HEADER.
7911 The search stars on the current article and goes forwards unless
7912 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7913 If UNREAD is non-nil, only unread articles will
7914 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7915 in the comparisons. If NOT-MATCHING, return a list of all articles that
7916 not match REGEXP on HEADER."
7917 (let ((case-fold-search (not not-case-fold))
7920 (if (eq (car header) 'extra)
7923 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7925 (error "%s is an invalid header" header))
7926 (unless (fboundp (intern (concat "mail-header-" header)))
7927 (error "%s is not a valid header" header))
7928 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7929 (dolist (d (if (eq backward 'all)
7931 (gnus-data-find-list
7932 (gnus-summary-article-number)
7933 (gnus-data-list backward))))
7934 (when (and (or (not unread) ; We want all articles...
7935 (gnus-data-unread-p d)) ; Or just unreads.
7936 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7940 (funcall func (gnus-data-header d))))
7941 (string-match regexp
7942 (funcall func (gnus-data-header d)))))
7943 (push (gnus-data-number d) articles))) ; Success!
7944 (nreverse articles)))
7946 (defun gnus-summary-execute-command (header regexp command &optional backward)
7947 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7948 If HEADER is an empty string (or nil), the match is done on the entire
7949 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7951 (list (let ((completion-ignore-case t))
7954 (mapcar (lambda (header) (list (format "%s" header)))
7956 '("Number" "Subject" "From" "Lines" "Date"
7957 "Message-ID" "Xref" "References" "Body")
7958 gnus-extra-headers))
7959 nil 'require-match))
7960 (read-string "Regexp: ")
7961 (read-key-sequence "Command: ")
7962 current-prefix-arg))
7963 (when (equal header "Body")
7965 ;; Hidden thread subtrees must be searched as well.
7966 (gnus-summary-show-all-threads)
7967 ;; We don't want to change current point nor window configuration.
7969 (save-window-excursion
7970 (gnus-message 6 "Executing %s..." (key-description command))
7971 ;; We'd like to execute COMMAND interactively so as to give arguments.
7972 (gnus-execute header regexp
7973 `(call-interactively ',(key-binding command))
7975 (gnus-message 6 "Executing %s...done" (key-description command)))))
7977 (defun gnus-summary-beginning-of-article ()
7978 "Scroll the article back to the beginning."
7980 (gnus-summary-select-article)
7981 (gnus-configure-windows 'article)
7982 (gnus-eval-in-buffer-window gnus-article-buffer
7984 (goto-char (point-min))
7985 (when gnus-page-broken
7986 (gnus-narrow-to-page))))
7988 (defun gnus-summary-end-of-article ()
7989 "Scroll to the end of the article."
7991 (gnus-summary-select-article)
7992 (gnus-configure-windows 'article)
7993 (gnus-eval-in-buffer-window gnus-article-buffer
7995 (goto-char (point-max))
7997 (when gnus-page-broken
7998 (gnus-narrow-to-page))))
8000 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8001 "Truncate to LEN and quote all \"(\"'s in STRING."
8002 (gnus-replace-in-string (if (and len (> (length string) len))
8003 (substring string 0 len)
8007 (defun gnus-summary-print-article (&optional filename n)
8008 "Generate and print a PostScript image of the N next (mail) articles.
8010 If N is negative, print the N previous articles. If N is nil and articles
8011 have been marked with the process mark, print these instead.
8013 If the optional first argument FILENAME is nil, send the image to the
8014 printer. If FILENAME is a string, save the PostScript image in a file with
8015 that name. If FILENAME is a number, prompt the user for the name of the file
8017 (interactive (list (ps-print-preprint current-prefix-arg)))
8018 (dolist (article (gnus-summary-work-articles n))
8019 (gnus-summary-select-article nil nil 'pseudo article)
8020 (gnus-eval-in-buffer-window gnus-article-buffer
8021 (gnus-print-buffer))
8022 (gnus-summary-remove-process-mark article))
8023 (ps-despool filename))
8025 (defun gnus-print-buffer ()
8026 (let ((buffer (generate-new-buffer " *print*")))
8029 (copy-to-buffer buffer (point-min) (point-max))
8031 (gnus-article-delete-invisible-text)
8032 (when (gnus-visual-p 'article-highlight 'highlight)
8033 ;; Copy-to-buffer doesn't copy overlay. So redo
8035 (let ((gnus-article-buffer buffer))
8036 (gnus-article-highlight-citation t)
8037 (gnus-article-highlight-signature)))
8038 (let ((ps-left-header
8041 (gnus-summary-print-truncate-and-quote
8042 (mail-header-subject gnus-current-headers)
8045 (gnus-summary-print-truncate-and-quote
8046 (mail-header-from gnus-current-headers)
8050 "/pagenumberstring load"
8052 (mail-header-date gnus-current-headers) ")"))))
8053 (gnus-run-hooks 'gnus-ps-print-hook)
8056 (ps-spool-buffer-with-faces)
8057 (ps-spool-buffer)))))
8058 (kill-buffer buffer))))
8060 (defun gnus-summary-show-article (&optional arg)
8061 "Force redisplaying of the current article.
8062 If ARG (the prefix) is a number, show the article with the charset
8063 defined in `gnus-summary-show-article-charset-alist', or the charset
8065 If ARG (the prefix) is non-nil and not a number, show the raw article
8066 without any article massaging functions being run. Normally, the key strokes
8071 (gnus-summary-show-article t)
8072 (let ((gnus-newsgroup-charset
8073 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8074 (mm-read-coding-system
8075 "View as charset: " ;; actually it is coding system.
8077 (set-buffer gnus-article-buffer)
8078 (mm-detect-coding-region (point) (point-max))))))
8079 (gnus-newsgroup-ignored-charsets 'gnus-all))
8080 (gnus-summary-select-article nil 'force)
8081 (let ((deps gnus-newsgroup-dependencies)
8084 (set-buffer gnus-original-article-buffer)
8086 (message-narrow-to-head)
8087 (setq head (buffer-string))
8088 (goto-char (point-min))
8089 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8090 (goto-char (point-max))
8092 (setq lines (1- (count-lines (point) (point-max))))))
8094 (insert (format "211 %d Article retrieved.\n"
8095 (cdr gnus-article-current)))
8097 (if lines (insert (format "Lines: %d\n" lines)))
8099 (let ((nntp-server-buffer (current-buffer)))
8100 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8101 (gnus-data-set-header
8102 (gnus-data-find (cdr gnus-article-current))
8104 (gnus-summary-update-article-line
8105 (cdr gnus-article-current) header)
8106 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8107 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8109 ;; Select the article the normal way.
8110 (gnus-summary-select-article nil 'force))
8112 ;; We have to require this here to make sure that the following
8113 ;; dynamic binding isn't shadowed by autoloading.
8114 (require 'gnus-async)
8116 ;; Bind the article treatment functions to nil.
8117 (let ((gnus-have-all-headers t)
8118 gnus-article-prepare-hook
8119 gnus-article-decode-hook
8120 gnus-display-mime-function
8122 ;; Destroy any MIME parts.
8123 (when (gnus-buffer-live-p gnus-article-buffer)
8125 (set-buffer gnus-article-buffer)
8126 (mm-destroy-parts gnus-article-mime-handles)
8127 ;; Set it to nil for safety reason.
8128 (setq gnus-article-mime-handle-alist nil)
8129 (setq gnus-article-mime-handles nil)))
8130 (gnus-summary-select-article nil 'force))))
8131 (gnus-summary-goto-subject gnus-current-article)
8132 (gnus-summary-position-point))
8134 (defun gnus-summary-show-raw-article ()
8135 "Show the raw article without any article massaging functions being run."
8137 (gnus-summary-show-article t))
8139 (defun gnus-summary-verbose-headers (&optional arg)
8140 "Toggle permanent full header display.
8141 If ARG is a positive number, turn header display on.
8142 If ARG is a negative number, turn header display off."
8144 (setq gnus-show-all-headers
8145 (cond ((or (not (numberp arg))
8147 (not gnus-show-all-headers))
8150 (gnus-summary-show-article))
8152 (defun gnus-summary-toggle-header (&optional arg)
8153 "Show the headers if they are hidden, or hide them if they are shown.
8154 If ARG is a positive number, show the entire header.
8155 If ARG is a negative number, hide the unwanted header lines."
8158 (set-buffer gnus-article-buffer)
8160 (let* ((buffer-read-only nil)
8161 (inhibit-point-motion-hooks t)
8167 (article-narrow-to-head)
8168 (gnus-article-hidden-text-p 'headers))))
8169 (goto-char (point-min))
8170 (when (search-forward "\n\n" nil t)
8171 (delete-region (point-min) (1- (point))))
8172 (goto-char (point-min))
8174 (set-buffer gnus-original-article-buffer)
8175 (goto-char (point-min))
8176 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8177 (insert-buffer-substring gnus-original-article-buffer 1 e)
8179 (narrow-to-region (point-min) (point))
8180 (article-decode-encoded-words)
8182 (let ((gnus-treat-hide-headers nil)
8183 (gnus-treat-hide-boring-headers nil))
8184 (gnus-delete-wash-type 'headers)
8185 (gnus-treat-article 'head))
8186 (gnus-treat-article 'head)))
8187 (gnus-set-mode-line 'article)))))
8189 (defun gnus-summary-show-all-headers ()
8190 "Make all header lines visible."
8192 (gnus-summary-toggle-header 1))
8194 (defun gnus-summary-caesar-message (&optional arg)
8195 "Caesar rotate the current article by 13.
8196 The numerical prefix specifies how many places to rotate each letter
8199 (gnus-summary-select-article)
8200 (let ((mail-header-separator ""))
8201 (gnus-eval-in-buffer-window gnus-article-buffer
8204 (let ((start (window-start))
8206 (message-caesar-buffer-body arg)
8207 (set-window-start (get-buffer-window (current-buffer)) start))))))
8209 (defun gnus-summary-stop-page-breaking ()
8210 "Stop page breaking in the current article."
8212 (gnus-summary-select-article)
8213 (gnus-eval-in-buffer-window gnus-article-buffer
8215 (when (gnus-visual-p 'page-marker)
8216 (let ((buffer-read-only nil))
8217 (gnus-remove-text-with-property 'gnus-prev)
8218 (gnus-remove-text-with-property 'gnus-next))
8219 (setq gnus-page-broken nil))))
8221 (defun gnus-summary-move-article (&optional n to-newsgroup
8222 select-method action)
8223 "Move the current article to a different newsgroup.
8224 If N is a positive number, move the N next articles.
8225 If N is a negative number, move the N previous articles.
8226 If N is nil and any articles have been marked with the process mark,
8227 move those articles instead.
8228 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8229 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8230 re-spool using this method.
8232 For this function to work, both the current newsgroup and the
8233 newsgroup that you want to move to have to support the `request-move'
8234 and `request-accept' functions.
8236 ACTION can be either `move' (the default), `crosspost' or `copy'."
8239 (setq action 'move))
8240 ;; Check whether the source group supports the required functions.
8241 (cond ((and (eq action 'move)
8242 (not (gnus-check-backend-function
8243 'request-move-article gnus-newsgroup-name)))
8244 (error "The current group does not support article moving"))
8245 ((and (eq action 'crosspost)
8246 (not (gnus-check-backend-function
8247 'request-replace-article gnus-newsgroup-name)))
8248 (error "The current group does not support article editing")))
8249 (let ((articles (gnus-summary-work-articles n))
8250 (prefix (if (gnus-check-backend-function
8251 'request-move-article gnus-newsgroup-name)
8252 (gnus-group-real-prefix gnus-newsgroup-name)
8254 (names '((move "Move" "Moving")
8255 (copy "Copy" "Copying")
8256 (crosspost "Crosspost" "Crossposting")))
8257 (copy-buf (save-excursion
8258 (nnheader-set-temp-buffer " *copy article*")))
8259 art-group to-method new-xref article to-groups)
8260 (unless (assq action names)
8261 (error "Unknown action %s" action))
8262 ;; We have to select an article to give
8263 ;; `gnus-read-move-group-name' an opportunity to suggest an
8264 ;; appropriate default.
8265 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8266 (let ((gnus-display-mime-function nil)
8267 (gnus-article-prepare-hook nil))
8268 (gnus-summary-select-article nil nil nil (car articles))))
8269 ;; Read the newsgroup name.
8270 (when (and (not to-newsgroup)
8271 (not select-method))
8273 (gnus-read-move-group-name
8274 (cadr (assq action names))
8275 (symbol-value (intern (format "gnus-current-%s-group" action)))
8277 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8278 (setq to-method (or select-method
8279 (gnus-server-to-method
8280 (gnus-group-method to-newsgroup))))
8281 ;; Check the method we are to move this article to...
8282 (unless (gnus-check-backend-function
8283 'request-accept-article (car to-method))
8284 (error "%s does not support article copying" (car to-method)))
8285 (unless (gnus-check-server to-method)
8286 (error "Can't open server %s" (car to-method)))
8287 (gnus-message 6 "%s to %s: %s..."
8288 (caddr (assq action names))
8289 (or (car select-method) to-newsgroup) articles)
8291 (setq article (pop articles))
8295 ;; Move the article.
8297 ;; Remove this article from future suppression.
8298 (gnus-dup-unsuppress-article article)
8299 (gnus-request-move-article
8300 article ; Article to move
8301 gnus-newsgroup-name ; From newsgroup
8302 (nth 1 (gnus-find-method-for-group
8303 gnus-newsgroup-name)) ; Server
8304 (list 'gnus-request-accept-article
8305 to-newsgroup (list 'quote select-method)
8306 (not articles) t) ; Accept form
8307 (not articles))) ; Only save nov last time
8308 ;; Copy the article.
8311 (set-buffer copy-buf)
8312 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8313 (gnus-request-accept-article
8314 to-newsgroup select-method (not articles) t))))
8315 ;; Crosspost the article.
8316 ((eq action 'crosspost)
8317 (let ((xref (message-tokenize-header
8318 (mail-header-xref (gnus-summary-article-header article))
8320 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8321 ":" (number-to-string article)))
8323 (setq xref (list (system-name))))
8326 (mapconcat 'identity
8327 (delete "Xref:" (delete new-xref xref))
8331 (set-buffer copy-buf)
8332 ;; First put the article in the destination group.
8333 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8334 (when (consp (setq art-group
8335 (gnus-request-accept-article
8336 to-newsgroup select-method (not articles))))
8337 (setq new-xref (concat new-xref " " (car art-group)
8339 (number-to-string (cdr art-group))))
8340 ;; Now we have the new Xrefs header, so we insert
8341 ;; it and replace the new article.
8342 (nnheader-replace-header "Xref" new-xref)
8343 (gnus-request-replace-article
8344 (cdr art-group) to-newsgroup (current-buffer))
8348 (gnus-message 1 "Couldn't %s article %s: %s"
8349 (cadr (assq action names)) article
8350 (nnheader-get-report (car to-method))))
8351 ((eq art-group 'junk)
8352 (when (eq action 'move)
8353 (gnus-summary-mark-article article gnus-canceled-mark)
8354 (gnus-message 4 "Deleted article %s" article)))
8356 (let* ((pto-group (gnus-group-prefixed-name
8357 (car art-group) to-method))
8359 (gnus-gethash pto-group gnus-newsrc-hashtb))
8360 (info (nth 2 entry))
8361 (to-group (gnus-info-group info))
8363 ;; Update the group that has been moved to.
8365 (memq action '(move copy)))
8366 (unless (member to-group to-groups)
8367 (push to-group to-groups))
8369 (unless (memq article gnus-newsgroup-unreads)
8370 (push 'read to-marks)
8372 info (gnus-add-to-range (gnus-info-read info)
8373 (list (cdr art-group)))))
8375 ;; See whether the article is to be put in the cache.
8376 (let ((marks gnus-article-mark-lists)
8377 (to-article (cdr art-group)))
8379 ;; Enter the article into the cache in the new group,
8380 ;; if that is required.
8381 (when gnus-use-cache
8382 (gnus-cache-possibly-enter-article
8384 (memq article gnus-newsgroup-marked)
8385 (memq article gnus-newsgroup-dormant)
8386 (memq article gnus-newsgroup-unreads)))
8388 (when gnus-preserve-marks
8389 ;; Copy any marks over to the new group.
8390 (when (and (equal to-group gnus-newsgroup-name)
8391 (not (memq article gnus-newsgroup-unreads)))
8392 ;; Mark this article as read in this group.
8393 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8394 (setcdr (gnus-active to-group) to-article)
8395 (setcdr gnus-newsgroup-active to-article))
8398 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8399 (when (memq article (symbol-value
8400 (intern (format "gnus-newsgroup-%s"
8402 (push (cdar marks) to-marks)
8403 ;; If the other group is the same as this group,
8404 ;; then we have to add the mark to the list.
8405 (when (equal to-group gnus-newsgroup-name)
8406 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8409 (intern (format "gnus-newsgroup-%s"
8411 ;; Copy the marks to other group.
8412 (gnus-add-marked-articles
8413 to-group (cdar marks) (list to-article) info)))
8414 (setq marks (cdr marks)))
8416 (gnus-request-set-mark to-group (list (list (list to-article)
8421 (concat "(gnus-group-set-info '"
8422 (gnus-prin1-to-string (gnus-get-info to-group))
8425 ;; Update the Xref header in this article to point to
8426 ;; the new crossposted article we have just created.
8427 (when (eq action 'crosspost)
8429 (set-buffer copy-buf)
8430 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8431 (nnheader-replace-header "Xref" new-xref)
8432 (gnus-request-replace-article
8433 article gnus-newsgroup-name (current-buffer)))))
8435 ;;;!!!Why is this necessary?
8436 (set-buffer gnus-summary-buffer)
8438 (gnus-summary-goto-subject article)
8439 (when (eq action 'move)
8440 (gnus-summary-mark-article article gnus-canceled-mark))))
8441 (gnus-summary-remove-process-mark article))
8442 ;; Re-activate all groups that have been moved to.
8444 (set-buffer gnus-group-buffer)
8445 (let ((gnus-group-marked to-groups))
8446 (gnus-group-get-new-news-this-group nil t)))
8448 (gnus-kill-buffer copy-buf)
8449 (gnus-summary-position-point)
8450 (gnus-set-mode-line 'summary)))
8452 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8453 "Move the current article to a different newsgroup.
8454 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8455 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8456 re-spool using this method."
8458 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8460 (defun gnus-summary-crosspost-article (&optional n)
8461 "Crosspost the current article to some other group."
8463 (gnus-summary-move-article n nil nil 'crosspost))
8465 (defcustom gnus-summary-respool-default-method nil
8466 "Default method type for respooling an article.
8467 If nil, use to the current newsgroup method."
8469 :group 'gnus-summary-mail)
8471 (defun gnus-summary-respool-article (&optional n method)
8472 "Respool the current article.
8473 The article will be squeezed through the mail spooling process again,
8474 which means that it will be put in some mail newsgroup or other
8475 depending on `nnmail-split-methods'.
8476 If N is a positive number, respool the N next articles.
8477 If N is a negative number, respool the N previous articles.
8478 If N is nil and any articles have been marked with the process mark,
8479 respool those articles instead.
8481 Respooling can be done both from mail groups and \"real\" newsgroups.
8482 In the former case, the articles in question will be moved from the
8483 current group into whatever groups they are destined to. In the
8484 latter case, they will be copied into the relevant groups."
8486 (list current-prefix-arg
8487 (let* ((methods (gnus-methods-using 'respool))
8489 (symbol-name (or gnus-summary-respool-default-method
8490 (car (gnus-find-method-for-group
8491 gnus-newsgroup-name)))))
8493 (gnus-completing-read-with-default
8494 methname "What backend do you want to use when respooling?"
8495 methods nil t nil 'gnus-mail-method-history))
8498 ((zerop (length (setq ms (gnus-servers-using-backend
8500 (list (intern method) ""))
8504 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8505 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8508 (error "No method given for respooling"))
8509 (if (assoc (symbol-name
8510 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8511 (gnus-methods-using 'respool))
8512 (gnus-summary-move-article n nil method)
8513 (gnus-summary-copy-article n nil method)))
8515 (defun gnus-summary-import-article (file &optional edit)
8516 "Import an arbitrary file into a mail newsgroup."
8517 (interactive "fImport file: \nP")
8518 (let ((group gnus-newsgroup-name)
8519 (now (current-time))
8520 atts lines group-art)
8521 (unless (gnus-check-backend-function 'request-accept-article group)
8522 (error "%s does not support article importing" group))
8523 (or (file-readable-p file)
8524 (not (file-regular-p file))
8525 (error "Can't read %s" file))
8527 (set-buffer (gnus-get-buffer-create " *import file*"))
8529 (nnheader-insert-file-contents file)
8530 (goto-char (point-min))
8531 (if (nnheader-article-p)
8533 (goto-char (point-min))
8534 (search-forward "\n\n" nil t)
8535 (narrow-to-region (point-min) (1- (point)))
8536 (goto-char (point-min))
8537 (unless (re-search-forward "^date:" nil t)
8538 (goto-char (point-max))
8539 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8540 ;; This doesn't look like an article, so we fudge some headers.
8541 (setq atts (file-attributes file)
8542 lines (count-lines (point-min) (point-max)))
8543 (insert "From: " (read-string "From: ") "\n"
8544 "Subject: " (read-string "Subject: ") "\n"
8545 "Date: " (message-make-date (nth 5 atts)) "\n"
8546 "Message-ID: " (message-make-message-id) "\n"
8547 "Lines: " (int-to-string lines) "\n"
8548 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8549 (setq group-art (gnus-request-accept-article group nil t))
8550 (kill-buffer (current-buffer)))
8551 (setq gnus-newsgroup-active (gnus-activate-group group))
8553 (gnus-summary-goto-article (cdr group-art) nil t)
8555 (gnus-summary-edit-article))))
8557 (defun gnus-summary-create-article ()
8558 "Create an article in a mail newsgroup."
8560 (let ((group gnus-newsgroup-name)
8561 (now (current-time))
8563 (unless (gnus-check-backend-function 'request-accept-article group)
8564 (error "%s does not support article importing" group))
8566 (set-buffer (gnus-get-buffer-create " *import file*"))
8568 (goto-char (point-min))
8569 ;; This doesn't look like an article, so we fudge some headers.
8570 (insert "From: " (read-string "From: ") "\n"
8571 "Subject: " (read-string "Subject: ") "\n"
8572 "Date: " (message-make-date now) "\n"
8573 "Message-ID: " (message-make-message-id) "\n")
8574 (setq group-art (gnus-request-accept-article group nil t))
8575 (kill-buffer (current-buffer)))
8576 (setq gnus-newsgroup-active (gnus-activate-group group))
8578 (gnus-summary-goto-article (cdr group-art) nil t)
8579 (gnus-summary-edit-article)))
8581 (defun gnus-summary-article-posted-p ()
8582 "Say whether the current (mail) article is available from news as well.
8583 This will be the case if the article has both been mailed and posted."
8585 (let ((id (mail-header-references (gnus-summary-article-header)))
8586 (gnus-override-method (car (gnus-refer-article-methods))))
8587 (if (gnus-request-head id "")
8588 (gnus-message 2 "The current message was found on %s"
8589 gnus-override-method)
8590 (gnus-message 2 "The current message couldn't be found on %s"
8591 gnus-override-method)
8594 (defun gnus-summary-expire-articles (&optional now)
8595 "Expire all articles that are marked as expirable in the current group."
8597 (when (gnus-check-backend-function
8598 'request-expire-articles gnus-newsgroup-name)
8599 ;; This backend supports expiry.
8600 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8601 (expirable (if total
8603 ;; We need to update the info for
8604 ;; this group for `gnus-list-of-read-articles'
8605 ;; to give us the right answer.
8606 (gnus-run-hooks 'gnus-exit-group-hook)
8607 (gnus-summary-update-info)
8608 (gnus-list-of-read-articles gnus-newsgroup-name))
8609 (setq gnus-newsgroup-expirable
8610 (sort gnus-newsgroup-expirable '<))))
8611 (expiry-wait (if now 'immediate
8612 (gnus-group-find-parameter
8613 gnus-newsgroup-name 'expiry-wait)))
8614 (nnmail-expiry-target
8615 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8616 nnmail-expiry-target))
8619 ;; There are expirable articles in this group, so we run them
8620 ;; through the expiry process.
8621 (gnus-message 6 "Expiring articles...")
8622 (unless (gnus-check-group gnus-newsgroup-name)
8623 (error "Can't open server for %s" gnus-newsgroup-name))
8624 ;; The list of articles that weren't expired is returned.
8627 (let ((nnmail-expiry-wait-function nil)
8628 (nnmail-expiry-wait expiry-wait))
8629 (setq es (gnus-request-expire-articles
8630 expirable gnus-newsgroup-name)))
8631 (setq es (gnus-request-expire-articles
8632 expirable gnus-newsgroup-name)))
8634 (setq gnus-newsgroup-expirable es))
8635 ;; We go through the old list of expirable, and mark all
8636 ;; really expired articles as nonexistent.
8637 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8638 (let ((gnus-use-cache nil))
8639 (dolist (article expirable)
8640 (when (and (not (memq article es))
8641 (gnus-data-find article))
8642 (gnus-summary-mark-article article gnus-canceled-mark))))))
8643 (gnus-message 6 "Expiring articles...done")))))
8645 (defun gnus-summary-expire-articles-now ()
8646 "Expunge all expirable articles in the current group.
8647 This means that *all* articles that are marked as expirable will be
8648 deleted forever, right now."
8650 (or gnus-expert-user
8652 "Are you really, really, really sure you want to delete all these messages? ")
8654 (gnus-summary-expire-articles t))
8656 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8657 (defun gnus-summary-delete-article (&optional n)
8658 "Delete the N next (mail) articles.
8659 This command actually deletes articles. This is not a marking
8660 command. The article will disappear forever from your life, never to
8662 If N is negative, delete backwards.
8663 If N is nil and articles have been marked with the process mark,
8664 delete these instead."
8666 (unless (gnus-check-backend-function 'request-expire-articles
8667 gnus-newsgroup-name)
8668 (error "The current newsgroup does not support article deletion"))
8669 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8670 (error "Couldn't open server"))
8671 ;; Compute the list of articles to delete.
8672 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8674 (if (and gnus-novice-user
8675 (not (gnus-yes-or-no-p
8676 (format "Do you really want to delete %s forever? "
8677 (if (> (length articles) 1)
8678 (format "these %s articles" (length articles))
8681 ;; Delete the articles.
8682 (setq not-deleted (gnus-request-expire-articles
8683 articles gnus-newsgroup-name 'force))
8685 (gnus-summary-remove-process-mark (car articles))
8686 ;; The backend might not have been able to delete the article
8688 (unless (memq (car articles) not-deleted)
8689 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8690 (setq articles (cdr articles)))
8692 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8693 (gnus-summary-position-point)
8694 (gnus-set-mode-line 'summary)
8697 (defun gnus-summary-edit-article (&optional arg)
8698 "Edit the current article.
8699 This will have permanent effect only in mail groups.
8700 If ARG is nil, edit the decoded articles.
8701 If ARG is 1, edit the raw articles.
8702 If ARG is 2, edit the raw articles even in read-only groups.
8703 If ARG is 3, edit the articles with the current handles.
8704 Otherwise, allow editing of articles even in read-only
8707 (let (force raw current-handles)
8716 (setq current-handles
8717 (and (gnus-buffer-live-p gnus-article-buffer)
8718 (with-current-buffer gnus-article-buffer
8720 gnus-article-mime-handles
8721 (setq gnus-article-mime-handles nil))))))
8724 (when (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8725 (error "Can't edit the raw article in group nndraft:drafts"))
8727 (set-buffer gnus-summary-buffer)
8728 (let ((mail-parse-charset gnus-newsgroup-charset)
8729 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8730 (gnus-set-global-variables)
8731 (when (and (not force)
8732 (gnus-group-read-only-p))
8733 (error "The current newsgroup does not support article editing"))
8734 (gnus-summary-show-article t)
8735 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8736 (with-current-buffer gnus-article-buffer
8737 (mm-enable-multibyte)))
8738 (if (equal gnus-newsgroup-name "nndraft:drafts")
8740 (gnus-article-edit-article
8743 (let ((mbl mml-buffer-list))
8744 (setq mml-buffer-list nil)
8745 (mime-to-mml ,'current-handles)
8746 (let ((mbl1 mml-buffer-list))
8747 (setq mml-buffer-list mbl)
8748 (set (make-local-variable 'mml-buffer-list) mbl1))
8749 (make-local-hook 'kill-buffer-hook)
8750 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8751 `(lambda (no-highlight)
8752 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8753 (message-options message-options)
8754 (message-options-set-recipient)
8755 (mail-parse-ignored-charsets
8756 ',gnus-newsgroup-ignored-charsets))
8757 ,(if (not raw) '(progn
8759 (mml-destroy-buffers)
8760 (remove-hook 'kill-buffer-hook
8761 'mml-destroy-buffers t)
8762 (kill-local-variable 'mml-buffer-list)))
8763 (gnus-summary-edit-article-done
8764 ,(or (mail-header-references gnus-current-headers) "")
8765 ,(gnus-group-read-only-p)
8766 ,gnus-summary-buffer no-highlight))))))))
8768 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8770 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8772 "Make edits to the current article permanent."
8775 ;; The buffer restriction contains the entire article if it exists.
8776 (when (article-goto-body)
8777 (let ((lines (count-lines (point) (point-max)))
8778 (length (- (point-max) (point)))
8779 (case-fold-search t)
8780 (body (copy-marker (point))))
8781 (goto-char (point-min))
8782 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8783 (delete-region (match-beginning 1) (match-end 1))
8784 (insert (number-to-string length)))
8785 (goto-char (point-min))
8786 (when (re-search-forward
8787 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8788 (delete-region (match-beginning 1) (match-end 1))
8789 (insert (number-to-string length)))
8790 (goto-char (point-min))
8791 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8792 (delete-region (match-beginning 1) (match-end 1))
8793 (insert (number-to-string lines))))))
8794 ;; Replace the article.
8795 (let ((buf (current-buffer)))
8797 (insert-buffer-substring buf)
8799 (if (and (not read-only)
8800 (not (gnus-request-replace-article
8801 (cdr gnus-article-current) (car gnus-article-current)
8802 (current-buffer) t)))
8803 (error "Couldn't replace article")
8804 ;; Update the summary buffer.
8806 (equal (message-tokenize-header references " ")
8807 (message-tokenize-header
8808 (or (message-fetch-field "references") "") " ")))
8809 ;; We only have to update this line.
8812 (message-narrow-to-head)
8813 (let ((head (buffer-string))
8816 (insert (format "211 %d Article retrieved.\n"
8817 (cdr gnus-article-current)))
8820 (let ((nntp-server-buffer (current-buffer)))
8821 (setq header (car (gnus-get-newsgroup-headers
8823 (set-buffer gnus-summary-buffer)
8824 gnus-newsgroup-dependencies)
8827 (set-buffer gnus-summary-buffer)
8828 (gnus-data-set-header
8829 (gnus-data-find (cdr gnus-article-current))
8831 (gnus-summary-update-article-line
8832 (cdr gnus-article-current) header)
8833 (if (gnus-summary-goto-subject
8834 (cdr gnus-article-current) nil t)
8835 (gnus-summary-update-secondary-mark
8836 (cdr gnus-article-current))))))))
8838 (set-buffer (or buffer gnus-summary-buffer))
8839 (gnus-summary-update-article (cdr gnus-article-current))
8840 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8841 (gnus-summary-update-secondary-mark
8842 (cdr gnus-article-current))))
8843 ;; Prettify the article buffer again.
8844 (unless no-highlight
8846 (set-buffer gnus-article-buffer)
8847 ;;;!!! Fix this -- article should be rehighlighted.
8848 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8849 (set-buffer gnus-original-article-buffer)
8850 (gnus-request-article
8851 (cdr gnus-article-current)
8852 (car gnus-article-current) (current-buffer))))
8853 ;; Prettify the summary buffer line.
8854 (when (gnus-visual-p 'summary-highlight 'highlight)
8855 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8857 (defun gnus-summary-edit-wash (key)
8858 "Perform editing command KEY in the article buffer."
8862 (message "%s" (concat (this-command-keys) "- "))
8865 (gnus-summary-edit-article)
8866 (execute-kbd-macro (concat (this-command-keys) key))
8867 (gnus-article-edit-done))
8871 (defun gnus-summary-respool-query (&optional silent trace)
8872 "Query where the respool algorithm would put this article."
8874 (let (gnus-mark-article-hook)
8875 (gnus-summary-select-article)
8877 (set-buffer gnus-original-article-buffer)
8879 (message-narrow-to-head)
8880 (let ((groups (nnmail-article-group 'identity trace)))
8883 (message "This message would go to %s"
8884 (mapconcat 'car groups ", "))
8885 (message "This message would go to no groups"))
8888 (defun gnus-summary-respool-trace ()
8889 "Trace where the respool algorithm would put this article.
8890 Display a buffer showing all fancy splitting patterns which matched."
8892 (gnus-summary-respool-query nil t))
8894 ;; Summary marking commands.
8896 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8897 "Mark articles which has the same subject as read, and then select the next.
8898 If UNMARK is positive, remove any kind of mark.
8899 If UNMARK is negative, tick articles."
8902 (setq unmark (prefix-numeric-value unmark)))
8904 (gnus-summary-mark-same-subject
8905 (gnus-summary-article-subject) unmark)))
8906 ;; Select next unread article. If auto-select-same mode, should
8907 ;; select the first unread article.
8908 (gnus-summary-next-article t (and gnus-auto-select-same
8909 (gnus-summary-article-subject)))
8910 (gnus-message 7 "%d article%s marked as %s"
8911 count (if (= count 1) " is" "s are")
8912 (if unmark "unread" "read"))))
8914 (defun gnus-summary-kill-same-subject (&optional unmark)
8915 "Mark articles which has the same subject as read.
8916 If UNMARK is positive, remove any kind of mark.
8917 If UNMARK is negative, tick articles."
8920 (setq unmark (prefix-numeric-value unmark)))
8922 (gnus-summary-mark-same-subject
8923 (gnus-summary-article-subject) unmark)))
8924 ;; If marked as read, go to next unread subject.
8926 ;; Go to next unread subject.
8927 (gnus-summary-next-subject 1 t))
8928 (gnus-message 7 "%d articles are marked as %s"
8929 count (if unmark "unread" "read"))))
8931 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8932 "Mark articles with same SUBJECT as read, and return marked number.
8933 If optional argument UNMARK is positive, remove any kinds of marks.
8934 If optional argument UNMARK is negative, mark articles as unread instead."
8938 ((null unmark) ; Mark as read.
8941 (gnus-summary-mark-article-as-read gnus-killed-mark)
8942 (gnus-summary-show-thread) t)
8943 (gnus-summary-find-subject subject))
8944 (setq count (1+ count))))
8945 ((> unmark 0) ; Tick.
8948 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8949 (gnus-summary-show-thread) t)
8950 (gnus-summary-find-subject subject))
8951 (setq count (1+ count))))
8952 (t ; Mark as unread.
8955 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8956 (gnus-summary-show-thread) t)
8957 (gnus-summary-find-subject subject))
8958 (setq count (1+ count)))))
8959 (gnus-set-mode-line 'summary)
8960 ;; Return the number of marked articles.
8963 (defun gnus-summary-mark-as-processable (n &optional unmark)
8964 "Set the process mark on the next N articles.
8965 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8966 the process mark instead. The difference between N and the actual
8967 number of articles marked is returned."
8969 (if (and (null n) (gnus-region-active-p))
8970 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8971 (setq n (prefix-numeric-value n))
8972 (let ((backward (< n 0))
8977 (gnus-summary-remove-process-mark
8978 (gnus-summary-article-number))
8979 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8980 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8983 (gnus-message 7 "No more articles"))
8984 (gnus-summary-recenter)
8985 (gnus-summary-position-point)
8988 (defun gnus-summary-unmark-as-processable (n)
8989 "Remove the process mark from the next N articles.
8990 If N is negative, unmark backward instead. The difference between N and
8991 the actual number of articles unmarked is returned."
8993 (gnus-summary-mark-as-processable n t))
8995 (defun gnus-summary-unmark-all-processable ()
8996 "Remove the process mark from all articles."
8999 (while gnus-newsgroup-processable
9000 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9001 (gnus-summary-position-point))
9003 (defun gnus-summary-add-mark (article type)
9004 "Mark ARTICLE with a mark of TYPE."
9005 (let ((vtype (car (assq type gnus-article-mark-lists)))
9008 (error "No such mark type: %s" type)
9009 (setq var (intern (format "gnus-newsgroup-%s" type)))
9010 (set var (cons article (symbol-value var)))
9011 (if (memq type '(processable cached replied forwarded recent saved))
9012 (gnus-summary-update-secondary-mark article)
9013 ;;; !!! This is bogus. We should find out what primary
9014 ;;; !!! mark we want to set.
9015 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9017 (defun gnus-summary-mark-as-expirable (n)
9018 "Mark N articles forward as expirable.
9019 If N is negative, mark backward instead. The difference between N and
9020 the actual number of articles marked is returned."
9022 (gnus-summary-mark-forward n gnus-expirable-mark))
9024 (defun gnus-summary-mark-article-as-replied (article)
9025 "Mark ARTICLE as replied to and update the summary line.
9026 ARTICLE can also be a list of articles."
9027 (interactive (list (gnus-summary-article-number)))
9028 (let ((articles (if (listp article) article (list article))))
9029 (dolist (article articles)
9030 (push article gnus-newsgroup-replied)
9031 (let ((buffer-read-only nil))
9032 (when (gnus-summary-goto-subject article nil t)
9033 (gnus-summary-update-secondary-mark article))))))
9035 (defun gnus-summary-mark-article-as-forwarded (article)
9036 "Mark ARTICLE as forwarded and update the summary line.
9037 ARTICLE can also be a list of articles."
9038 (let ((articles (if (listp article) article (list article))))
9039 (dolist (article articles)
9040 (push article gnus-newsgroup-forwarded)
9041 (let ((buffer-read-only nil))
9042 (when (gnus-summary-goto-subject article nil t)
9043 (gnus-summary-update-secondary-mark article))))))
9045 (defun gnus-summary-set-bookmark (article)
9046 "Set a bookmark in current article."
9047 (interactive (list (gnus-summary-article-number)))
9048 (when (or (not (get-buffer gnus-article-buffer))
9049 (not gnus-current-article)
9050 (not gnus-article-current)
9051 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9052 (error "No current article selected"))
9053 ;; Remove old bookmark, if one exists.
9054 (let ((old (assq article gnus-newsgroup-bookmarks)))
9056 (setq gnus-newsgroup-bookmarks
9057 (delq old gnus-newsgroup-bookmarks))))
9058 ;; Set the new bookmark, which is on the form
9059 ;; (article-number . line-number-in-body).
9063 (set-buffer gnus-article-buffer)
9067 (goto-char (point-min))
9068 (search-forward "\n\n" nil t)
9071 gnus-newsgroup-bookmarks)
9072 (gnus-message 6 "A bookmark has been added to the current article."))
9074 (defun gnus-summary-remove-bookmark (article)
9075 "Remove the bookmark from the current article."
9076 (interactive (list (gnus-summary-article-number)))
9077 ;; Remove old bookmark, if one exists.
9078 (let ((old (assq article gnus-newsgroup-bookmarks)))
9081 (setq gnus-newsgroup-bookmarks
9082 (delq old gnus-newsgroup-bookmarks))
9083 (gnus-message 6 "Removed bookmark."))
9084 (gnus-message 6 "No bookmark in current article."))))
9086 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9087 (defun gnus-summary-mark-as-dormant (n)
9088 "Mark N articles forward as dormant.
9089 If N is negative, mark backward instead. The difference between N and
9090 the actual number of articles marked is returned."
9092 (gnus-summary-mark-forward n gnus-dormant-mark))
9094 (defun gnus-summary-set-process-mark (article)
9095 "Set the process mark on ARTICLE and update the summary line."
9096 (setq gnus-newsgroup-processable
9098 (delq article gnus-newsgroup-processable)))
9099 (when (gnus-summary-goto-subject article)
9100 (gnus-summary-show-thread)
9101 (gnus-summary-goto-subject article)
9102 (gnus-summary-update-secondary-mark article)))
9104 (defun gnus-summary-remove-process-mark (article)
9105 "Remove the process mark from ARTICLE and update the summary line."
9106 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9107 (when (gnus-summary-goto-subject article)
9108 (gnus-summary-show-thread)
9109 (gnus-summary-goto-subject article)
9110 (gnus-summary-update-secondary-mark article)))
9112 (defun gnus-summary-set-saved-mark (article)
9113 "Set the process mark on ARTICLE and update the summary line."
9114 (push article gnus-newsgroup-saved)
9115 (when (gnus-summary-goto-subject article)
9116 (gnus-summary-update-secondary-mark article)))
9118 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9119 "Mark N articles as read forwards.
9120 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9121 The difference between N and the actual number of articles marked is
9123 Iff NO-EXPIRE, auto-expiry will be inhibited."
9125 (gnus-summary-show-thread)
9126 (let ((backward (< n 0))
9127 (gnus-summary-goto-unread
9128 (and gnus-summary-goto-unread
9129 (not (eq gnus-summary-goto-unread 'never))
9130 (not (memq mark (list gnus-unread-mark
9131 gnus-ticked-mark gnus-dormant-mark)))))
9133 (mark (or mark gnus-del-mark)))
9135 (gnus-summary-mark-article nil mark no-expire)
9136 (zerop (gnus-summary-next-subject
9138 (and gnus-summary-goto-unread
9139 (not (eq gnus-summary-goto-unread 'never)))
9143 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9144 (gnus-summary-recenter)
9145 (gnus-summary-position-point)
9146 (gnus-set-mode-line 'summary)
9149 (defun gnus-summary-mark-article-as-read (mark)
9150 "Mark the current article quickly as read with MARK."
9151 (let ((article (gnus-summary-article-number)))
9152 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9153 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9154 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9155 (push (cons article mark) gnus-newsgroup-reads)
9156 ;; Possibly remove from cache, if that is used.
9157 (when gnus-use-cache
9158 (gnus-cache-enter-remove-article article))
9159 ;; Allow the backend to change the mark.
9160 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9161 ;; Check for auto-expiry.
9162 (when (and gnus-newsgroup-auto-expire
9163 (memq mark gnus-auto-expirable-marks))
9164 (setq mark gnus-expirable-mark)
9165 ;; Let the backend know about the mark change.
9166 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9167 (push article gnus-newsgroup-expirable))
9168 ;; Set the mark in the buffer.
9169 (gnus-summary-update-mark mark 'unread)
9172 (defun gnus-summary-mark-article-as-unread (mark)
9173 "Mark the current article quickly as unread with MARK."
9174 (let* ((article (gnus-summary-article-number))
9175 (old-mark (gnus-summary-article-mark article)))
9176 ;; Allow the backend to change the mark.
9177 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9178 (if (eq mark old-mark)
9182 (gnus-error 1 "Can't mark negative article numbers")
9184 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9185 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9186 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9187 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9188 (cond ((= mark gnus-ticked-mark)
9189 (setq gnus-newsgroup-marked
9190 (gnus-add-to-sorted-list gnus-newsgroup-marked
9192 ((= mark gnus-dormant-mark)
9193 (setq gnus-newsgroup-dormant
9194 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9197 (setq gnus-newsgroup-unreads
9198 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9200 (gnus-pull article gnus-newsgroup-reads)
9202 ;; See whether the article is to be put in the cache.
9204 (vectorp (gnus-summary-article-header article))
9206 (gnus-cache-possibly-enter-article
9207 gnus-newsgroup-name article
9208 (= mark gnus-ticked-mark)
9209 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9212 (gnus-summary-update-mark mark 'unread)
9215 (defun gnus-summary-mark-article (&optional article mark no-expire)
9216 "Mark ARTICLE with MARK. MARK can be any character.
9217 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9218 `??' (dormant) and `?E' (expirable).
9219 If MARK is nil, then the default character `?r' is used.
9220 If ARTICLE is nil, then the article on the current line will be
9222 Iff NO-EXPIRE, auto-expiry will be inhibited."
9223 ;; The mark might be a string.
9224 (when (stringp mark)
9225 (setq mark (aref mark 0)))
9226 ;; If no mark is given, then we check auto-expiring.
9228 (setq mark gnus-del-mark))
9229 (when (and (not no-expire)
9230 gnus-newsgroup-auto-expire
9231 (memq mark gnus-auto-expirable-marks))
9232 (setq mark gnus-expirable-mark))
9233 (let ((article (or article (gnus-summary-article-number)))
9234 (old-mark (gnus-summary-article-mark article)))
9235 ;; Allow the backend to change the mark.
9236 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9237 (if (eq mark old-mark)
9240 (error "No article on current line"))
9241 (if (not (if (or (= mark gnus-unread-mark)
9242 (= mark gnus-ticked-mark)
9243 (= mark gnus-dormant-mark))
9244 (gnus-mark-article-as-unread article mark)
9245 (gnus-mark-article-as-read article mark)))
9247 ;; See whether the article is to be put in the cache.
9249 (not (= mark gnus-canceled-mark))
9250 (vectorp (gnus-summary-article-header article))
9252 (gnus-cache-possibly-enter-article
9253 gnus-newsgroup-name article
9254 (= mark gnus-ticked-mark)
9255 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9257 (when (gnus-summary-goto-subject article nil t)
9258 (let ((buffer-read-only nil))
9259 (gnus-summary-show-thread)
9261 (gnus-summary-update-mark mark 'unread)
9264 (defun gnus-summary-update-secondary-mark (article)
9265 "Update the secondary (read, process, cache) mark."
9266 (gnus-summary-update-mark
9267 (cond ((memq article gnus-newsgroup-processable)
9269 ((memq article gnus-newsgroup-cached)
9271 ((memq article gnus-newsgroup-replied)
9273 ((memq article gnus-newsgroup-forwarded)
9274 gnus-forwarded-mark)
9275 ((memq article gnus-newsgroup-saved)
9277 ((memq article gnus-newsgroup-recent)
9279 ((memq article gnus-newsgroup-unseen)
9283 (when (gnus-visual-p 'summary-highlight 'highlight)
9284 (gnus-run-hooks 'gnus-summary-update-hook))
9287 (defun gnus-summary-update-mark (mark type)
9288 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9289 (buffer-read-only nil))
9290 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9292 (when (looking-at "\r")
9294 (when (<= (+ forward (point)) (point-max))
9295 ;; Go to the right position on the line.
9296 (goto-char (+ forward (point)))
9297 ;; Replace the old mark with the new mark.
9298 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9299 ;; Optionally update the marks by some user rule.
9300 (when (eq type 'unread)
9302 (gnus-data-find (gnus-summary-article-number)) mark)
9303 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9305 (defun gnus-mark-article-as-read (article &optional mark)
9306 "Enter ARTICLE in the pertinent lists and remove it from others."
9307 ;; Make the article expirable.
9308 (let ((mark (or mark gnus-del-mark)))
9309 (setq gnus-newsgroup-expirable
9310 (if (= mark gnus-expirable-mark)
9311 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9312 (delq article gnus-newsgroup-expirable)))
9313 ;; Remove from unread and marked lists.
9314 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9315 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9316 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9317 (push (cons article mark) gnus-newsgroup-reads)
9318 ;; Possibly remove from cache, if that is used.
9319 (when gnus-use-cache
9320 (gnus-cache-enter-remove-article article))
9323 (defun gnus-mark-article-as-unread (article &optional mark)
9324 "Enter ARTICLE in the pertinent lists and remove it from others."
9325 (let ((mark (or mark gnus-ticked-mark)))
9328 (gnus-error 1 "Can't mark negative article numbers")
9330 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9331 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9332 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9333 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9335 ;; Unsuppress duplicates?
9336 (when gnus-suppress-duplicates
9337 (gnus-dup-unsuppress-article article))
9339 (cond ((= mark gnus-ticked-mark)
9340 (setq gnus-newsgroup-marked
9341 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9342 ((= mark gnus-dormant-mark)
9343 (setq gnus-newsgroup-dormant
9344 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9346 (setq gnus-newsgroup-unreads
9347 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9348 (gnus-pull article gnus-newsgroup-reads)
9351 (defalias 'gnus-summary-mark-as-unread-forward
9352 'gnus-summary-tick-article-forward)
9353 (make-obsolete 'gnus-summary-mark-as-unread-forward
9354 'gnus-summary-tick-article-forward)
9355 (defun gnus-summary-tick-article-forward (n)
9356 "Tick N articles forwards.
9357 If N is negative, tick backwards instead.
9358 The difference between N and the number of articles ticked is returned."
9360 (gnus-summary-mark-forward n gnus-ticked-mark))
9362 (defalias 'gnus-summary-mark-as-unread-backward
9363 'gnus-summary-tick-article-backward)
9364 (make-obsolete 'gnus-summary-mark-as-unread-backward
9365 'gnus-summary-tick-article-backward)
9366 (defun gnus-summary-tick-article-backward (n)
9367 "Tick N articles backwards.
9368 The difference between N and the number of articles ticked is returned."
9370 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9372 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9373 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9374 (defun gnus-summary-tick-article (&optional article clear-mark)
9375 "Mark current article as unread.
9376 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9377 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9379 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9382 (defun gnus-summary-mark-as-read-forward (n)
9383 "Mark N articles as read forwards.
9384 If N is negative, mark backwards instead.
9385 The difference between N and the actual number of articles marked is
9388 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9390 (defun gnus-summary-mark-as-read-backward (n)
9391 "Mark the N articles as read backwards.
9392 The difference between N and the actual number of articles marked is
9395 (gnus-summary-mark-forward
9396 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9398 (defun gnus-summary-mark-as-read (&optional article mark)
9399 "Mark current article as read.
9400 ARTICLE specifies the article to be marked as read.
9401 MARK specifies a string to be inserted at the beginning of the line."
9402 (gnus-summary-mark-article article mark))
9404 (defun gnus-summary-clear-mark-forward (n)
9405 "Clear marks from N articles forward.
9406 If N is negative, clear backward instead.
9407 The difference between N and the number of marks cleared is returned."
9409 (gnus-summary-mark-forward n gnus-unread-mark))
9411 (defun gnus-summary-clear-mark-backward (n)
9412 "Clear marks from N articles backward.
9413 The difference between N and the number of marks cleared is returned."
9415 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9417 (defun gnus-summary-mark-unread-as-read ()
9418 "Intended to be used by `gnus-summary-mark-article-hook'."
9419 (when (memq gnus-current-article gnus-newsgroup-unreads)
9420 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9422 (defun gnus-summary-mark-read-and-unread-as-read ()
9423 "Intended to be used by `gnus-summary-mark-article-hook'."
9424 (let ((mark (gnus-summary-article-mark)))
9425 (when (or (gnus-unread-mark-p mark)
9426 (gnus-read-mark-p mark))
9427 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9429 (defun gnus-summary-mark-unread-as-ticked ()
9430 "Intended to be used by `gnus-summary-mark-article-hook'."
9431 (when (memq gnus-current-article gnus-newsgroup-unreads)
9432 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9434 (defun gnus-summary-mark-region-as-read (point mark all)
9435 "Mark all unread articles between point and mark as read.
9436 If given a prefix, mark all articles between point and mark as read,
9437 even ticked and dormant ones."
9438 (interactive "r\nP")
9447 (memq (setq article (gnus-summary-article-number))
9448 gnus-newsgroup-unreads))
9449 (gnus-summary-mark-article article gnus-del-mark))
9451 (gnus-summary-find-next))))))
9453 (defun gnus-summary-mark-below (score mark)
9454 "Mark articles with score less than SCORE with MARK."
9455 (interactive "P\ncMark: ")
9456 (setq score (if score
9457 (prefix-numeric-value score)
9458 (or gnus-summary-default-score 0)))
9460 (set-buffer gnus-summary-buffer)
9461 (goto-char (point-min))
9464 (and (< (gnus-summary-article-score) score)
9465 (gnus-summary-mark-article nil mark))
9466 (gnus-summary-find-next)))))
9468 (defun gnus-summary-kill-below (&optional score)
9469 "Mark articles with score below SCORE as read."
9471 (gnus-summary-mark-below score gnus-killed-mark))
9473 (defun gnus-summary-clear-above (&optional score)
9474 "Clear all marks from articles with score above SCORE."
9476 (gnus-summary-mark-above score gnus-unread-mark))
9478 (defun gnus-summary-tick-above (&optional score)
9479 "Tick all articles with score above SCORE."
9481 (gnus-summary-mark-above score gnus-ticked-mark))
9483 (defun gnus-summary-mark-above (score mark)
9484 "Mark articles with score over SCORE with MARK."
9485 (interactive "P\ncMark: ")
9486 (setq score (if score
9487 (prefix-numeric-value score)
9488 (or gnus-summary-default-score 0)))
9490 (set-buffer gnus-summary-buffer)
9491 (goto-char (point-min))
9493 (when (> (gnus-summary-article-score) score)
9494 (gnus-summary-mark-article nil mark))
9496 (gnus-summary-find-next)))))
9498 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9499 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9500 (defun gnus-summary-limit-include-expunged (&optional no-error)
9501 "Display all the hidden articles that were expunged for low scores."
9503 (let ((buffer-read-only nil))
9504 (let ((scored gnus-newsgroup-scored)
9507 (unless (gnus-summary-article-header (caar scored))
9508 (and (setq h (gnus-number-to-header (caar scored)))
9509 (< (cdar scored) gnus-summary-expunge-below)
9511 (setq scored (cdr scored)))
9513 (when (not no-error)
9514 (error "No expunged articles hidden"))
9515 (goto-char (point-min))
9516 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9517 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9518 (mapcar (lambda (x) (push (mail-header-number x)
9519 gnus-newsgroup-limit))
9521 (gnus-summary-prepare-unthreaded (nreverse headers))
9522 (goto-char (point-min))
9523 (gnus-summary-position-point)
9526 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9527 "Mark all unread articles in this newsgroup as read.
9528 If prefix argument ALL is non-nil, ticked and dormant articles will
9529 also be marked as read.
9530 If QUIETLY is non-nil, no questions will be asked.
9531 If TO-HERE is non-nil, it should be a point in the buffer. All
9532 articles before (after, if REVERSE is set) this point will be marked as read.
9533 Note that this function will only catch up the unread article
9534 in the current summary buffer limitation.
9535 The number of articles marked as read is returned."
9540 (not gnus-interactive-catchup) ;Without confirmation?
9544 "Mark absolutely all articles as read? "
9545 "Mark all unread articles as read? ")))
9547 (not gnus-newsgroup-adaptive)
9548 (not gnus-newsgroup-auto-expire)
9549 (not gnus-suppress-duplicates)
9550 (or (not gnus-use-cache)
9551 (eq gnus-use-cache 'passive)))
9554 (setq gnus-newsgroup-marked nil
9555 gnus-newsgroup-dormant nil))
9556 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9557 ;; We actually mark all articles as canceled, which we
9558 ;; have to do when using auto-expiry or adaptive scoring.
9559 (gnus-summary-show-all-threads)
9560 (if (and to-here reverse)
9564 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9565 (gnus-summary-find-next (not all) nil nil t))))
9566 (when (gnus-summary-first-subject (not all) t)
9568 (if to-here (< (point) to-here) t)
9569 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9570 (gnus-summary-find-next (not all) nil nil t)))))
9571 (gnus-set-mode-line 'summary))
9573 (gnus-summary-position-point)))
9575 (defun gnus-summary-catchup-to-here (&optional all)
9576 "Mark all unticked articles before the current one as read.
9577 If ALL is non-nil, also mark ticked and dormant articles as read."
9580 (gnus-save-hidden-threads
9581 (let ((beg (point)))
9582 ;; We check that there are unread articles.
9583 (when (or all (gnus-summary-find-prev))
9584 (gnus-summary-catchup all t beg)))))
9585 (gnus-summary-position-point))
9587 (defun gnus-summary-catchup-from-here (&optional all)
9588 "Mark all unticked articles after the current one as read.
9589 If ALL is non-nil, also mark ticked and dormant articles as read."
9592 (gnus-save-hidden-threads
9593 (let ((beg (point)))
9594 ;; We check that there are unread articles.
9595 (when (or all (gnus-summary-find-next))
9596 (gnus-summary-catchup all t beg nil t)))))
9598 (gnus-summary-position-point))
9599 (defun gnus-summary-catchup-all (&optional quietly)
9600 "Mark all articles in this newsgroup as read."
9602 (gnus-summary-catchup t quietly))
9604 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9605 "Mark all unread articles in this group as read, then exit.
9606 If prefix argument ALL is non-nil, all articles are marked as read.
9607 If QUIETLY is non-nil, no questions will be asked."
9609 (when (gnus-summary-catchup all quietly nil 'fast)
9610 ;; Select next newsgroup or exit.
9611 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9612 (eq gnus-auto-select-next 'quietly))
9613 (gnus-summary-next-group nil)
9614 (gnus-summary-exit))))
9616 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9617 "Mark all articles in this newsgroup as read, and then exit."
9619 (gnus-summary-catchup-and-exit t quietly))
9621 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9622 "Mark all articles in this group as read and select the next group.
9623 If given a prefix, mark all articles, unread as well as ticked, as
9627 (gnus-summary-catchup all))
9628 (gnus-summary-next-group))
9634 (defmacro gnus-with-article (article &rest forms)
9635 "Select ARTICLE and perform FORMS in the original article buffer.
9636 Then replace the article with the result."
9638 ;; We don't want the article to be marked as read.
9639 (let (gnus-mark-article-hook)
9640 (gnus-summary-select-article t t nil ,article))
9641 (set-buffer gnus-original-article-buffer)
9643 (if (not (gnus-check-backend-function
9644 'request-replace-article (car gnus-article-current)))
9645 (gnus-message 5 "Read-only group; not replacing")
9646 (unless (gnus-request-replace-article
9647 ,article (car gnus-article-current)
9649 (error "Couldn't replace article")))
9650 ;; The cache and backlog have to be flushed somewhat.
9651 (when gnus-keep-backlog
9652 (gnus-backlog-remove-article
9653 (car gnus-article-current) (cdr gnus-article-current)))
9654 (when gnus-use-cache
9655 (gnus-cache-update-article
9656 (car gnus-article-current) (cdr gnus-article-current)))))
9658 (put 'gnus-with-article 'lisp-indent-function 1)
9659 (put 'gnus-with-article 'edebug-form-spec '(form body))
9661 ;; Thread-based commands.
9663 (defun gnus-summary-articles-in-thread (&optional article)
9664 "Return a list of all articles in the current thread.
9665 If ARTICLE is non-nil, return all articles in the thread that starts
9667 (let* ((article (or article (gnus-summary-article-number)))
9668 (data (gnus-data-find-list article))
9669 (top-level (gnus-data-level (car data)))
9671 (cond ((null gnus-thread-operation-ignore-subject)
9672 (gnus-simplify-subject-re
9673 (mail-header-subject (gnus-data-header (car data)))))
9674 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9675 (gnus-simplify-subject-fuzzy
9676 (mail-header-subject (gnus-data-header (car data)))))
9678 (end-point (save-excursion
9679 (if (gnus-summary-go-to-next-thread)
9680 (point) (point-max))))
9683 (< (gnus-data-pos (car data)) end-point))
9684 (when (or (not top-subject)
9685 (string= top-subject
9686 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9687 (gnus-simplify-subject-fuzzy
9688 (mail-header-subject
9689 (gnus-data-header (car data))))
9690 (gnus-simplify-subject-re
9691 (mail-header-subject
9692 (gnus-data-header (car data)))))))
9693 (push (gnus-data-number (car data)) articles))
9694 (unless (and (setq data (cdr data))
9695 (> (gnus-data-level (car data)) top-level))
9697 ;; Return the list of articles.
9698 (nreverse articles)))
9700 (defun gnus-summary-rethread-current ()
9701 "Rethread the thread the current article is part of."
9703 (let* ((gnus-show-threads t)
9704 (article (gnus-summary-article-number))
9705 (id (mail-header-id (gnus-summary-article-header)))
9706 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9708 (error "No article on the current line"))
9709 (gnus-rebuild-thread id)
9710 (gnus-summary-goto-subject article)))
9712 (defun gnus-summary-reparent-thread ()
9713 "Make the current article child of the marked (or previous) article.
9715 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9716 is non-nil or the Subject: of both articles are the same."
9718 (unless (not (gnus-group-read-only-p))
9719 (error "The current newsgroup does not support article editing"))
9720 (unless (<= (length gnus-newsgroup-processable) 1)
9721 (error "No more than one article may be marked"))
9722 (save-window-excursion
9723 (let ((gnus-article-buffer " *reparent*")
9724 (current-article (gnus-summary-article-number))
9725 ;; First grab the marked article, otherwise one line up.
9726 (parent-article (if (not (null gnus-newsgroup-processable))
9727 (car gnus-newsgroup-processable)
9729 (if (eq (forward-line -1) 0)
9730 (gnus-summary-article-number)
9731 (error "Beginning of summary buffer"))))))
9732 (unless (not (eq current-article parent-article))
9733 (error "An article may not be self-referential"))
9734 (let ((message-id (mail-header-id
9735 (gnus-summary-article-header parent-article))))
9736 (unless (and message-id (not (equal message-id "")))
9737 (error "No message-id in desired parent"))
9738 (gnus-with-article current-article
9740 (goto-char (point-min))
9741 (message-narrow-to-head)
9742 (if (re-search-forward "^References: " nil t)
9744 (re-search-forward "^[^ \t]" nil t)
9747 (insert " " message-id))
9748 (insert "References: " message-id "\n"))))
9749 (set-buffer gnus-summary-buffer)
9750 (gnus-summary-unmark-all-processable)
9751 (gnus-summary-update-article current-article)
9752 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9753 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9754 (gnus-summary-rethread-current)
9755 (gnus-message 3 "Article %d is now the child of article %d"
9756 current-article parent-article)))))
9758 (defun gnus-summary-toggle-threads (&optional arg)
9759 "Toggle showing conversation threads.
9760 If ARG is positive number, turn showing conversation threads on."
9762 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9763 (setq gnus-show-threads
9764 (if (null arg) (not gnus-show-threads)
9765 (> (prefix-numeric-value arg) 0)))
9766 (gnus-summary-prepare)
9767 (gnus-summary-goto-subject current)
9768 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9769 (gnus-summary-position-point)))
9771 (defun gnus-summary-show-all-threads ()
9775 (let ((buffer-read-only nil))
9776 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9777 (gnus-summary-position-point))
9779 (defun gnus-summary-show-thread ()
9780 "Show thread subtrees.
9781 Returns nil if no thread was there to be shown."
9783 (let ((buffer-read-only nil)
9785 ;; first goto end then to beg, to have point at beg after let
9786 (end (progn (end-of-line) (point)))
9787 (beg (progn (beginning-of-line) (point))))
9789 ;; Any hidden lines here?
9790 (search-forward "\r" end t)
9791 (subst-char-in-region beg end ?\^M ?\n t)
9793 (gnus-summary-position-point))))
9795 (defun gnus-summary-maybe-hide-threads ()
9796 "If requested, hide the threads that should be hidden."
9797 (when (and gnus-show-threads
9798 gnus-thread-hide-subtree)
9799 (gnus-summary-hide-all-threads
9800 (if (or (consp gnus-thread-hide-subtree)
9801 (gnus-functionp gnus-thread-hide-subtree))
9802 (gnus-make-predicate gnus-thread-hide-subtree)
9805 ;;; Hiding predicates.
9807 (defun gnus-article-unread-p (header)
9808 (memq (mail-header-number header) gnus-newsgroup-unreads))
9810 (defun gnus-article-unseen-p (header)
9811 (memq (mail-header-number header) gnus-newsgroup-unseen))
9813 (defun gnus-map-articles (predicate articles)
9814 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
9815 (apply 'gnus-or (mapcar predicate
9816 (mapcar 'gnus-summary-article-header articles))))
9818 (defun gnus-summary-hide-all-threads (&optional predicate)
9819 "Hide all thread subtrees.
9820 If PREDICATE is supplied, threads that satisfy this predicate
9821 will not be hidden."
9824 (goto-char (point-min))
9827 (when (or (not predicate)
9829 predicate (gnus-summary-article-children)))
9830 (gnus-summary-hide-thread))
9831 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
9832 (gnus-summary-position-point))
9834 (defun gnus-summary-hide-thread ()
9835 "Hide thread subtrees.
9836 If PREDICATE is supplied, threads that satisfy this predicate
9838 Returns nil if no threads were there to be hidden."
9840 (let ((buffer-read-only nil)
9842 (article (gnus-summary-article-number)))
9844 ;; Go forward until either the buffer ends or the subthread
9846 (when (and (not (eobp))
9847 (or (zerop (gnus-summary-next-thread 1 t))
9848 (goto-char (point-max))))
9850 (if (and (> (point) start)
9851 (search-backward "\n" start t))
9853 (subst-char-in-region start (point) ?\n ?\^M)
9854 (gnus-summary-goto-subject article))
9858 (defun gnus-summary-go-to-next-thread (&optional previous)
9859 "Go to the same level (or less) next thread.
9860 If PREVIOUS is non-nil, go to previous thread instead.
9861 Return the article number moved to, or nil if moving was impossible."
9862 (let ((level (gnus-summary-thread-level))
9863 (way (if previous -1 1))
9866 (while (and (not (eobp))
9867 (< level (gnus-summary-thread-level)))
9875 (gnus-summary-article-number)
9878 (defun gnus-summary-next-thread (n &optional silent)
9879 "Go to the same level next N'th thread.
9880 If N is negative, search backward instead.
9881 Returns the difference between N and the number of skips actually
9884 If SILENT, don't output messages."
9886 (let ((backward (< n 0))
9889 (gnus-summary-go-to-next-thread backward))
9892 (gnus-summary-position-point))
9893 (when (and (not silent) (/= 0 n))
9894 (gnus-message 7 "No more threads"))
9897 (defun gnus-summary-prev-thread (n)
9898 "Go to the same level previous N'th thread.
9899 Returns the difference between N and the number of skips actually
9902 (gnus-summary-next-thread (- n)))
9904 (defun gnus-summary-go-down-thread ()
9905 "Go down one level in the current thread."
9906 (let ((children (gnus-summary-article-children)))
9908 (gnus-summary-goto-subject (car children)))))
9910 (defun gnus-summary-go-up-thread ()
9911 "Go up one level in the current thread."
9912 (let ((parent (gnus-summary-article-parent)))
9914 (gnus-summary-goto-subject parent))))
9916 (defun gnus-summary-down-thread (n)
9917 "Go down thread N steps.
9918 If N is negative, go up instead.
9919 Returns the difference between N and how many steps down that were
9925 (if up (gnus-summary-go-up-thread)
9926 (gnus-summary-go-down-thread)))
9928 (gnus-summary-position-point)
9930 (gnus-message 7 "Can't go further"))
9933 (defun gnus-summary-up-thread (n)
9934 "Go up thread N steps.
9935 If N is negative, go down instead.
9936 Returns the difference between N and how many steps down that were
9939 (gnus-summary-down-thread (- n)))
9941 (defun gnus-summary-top-thread ()
9942 "Go to the top of the thread."
9944 (while (gnus-summary-go-up-thread))
9945 (gnus-summary-article-number))
9947 (defun gnus-summary-kill-thread (&optional unmark)
9948 "Mark articles under current thread as read.
9949 If the prefix argument is positive, remove any kinds of marks.
9950 If the prefix argument is negative, tick articles instead."
9953 (setq unmark (prefix-numeric-value unmark)))
9954 (let ((articles (gnus-summary-articles-in-thread)))
9956 ;; Expand the thread.
9957 (gnus-summary-show-thread)
9958 ;; Mark all the articles.
9960 (gnus-summary-goto-subject (car articles))
9961 (cond ((null unmark)
9962 (gnus-summary-mark-article-as-read gnus-killed-mark))
9964 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9966 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9967 (setq articles (cdr articles))))
9968 ;; Hide killed subtrees.
9970 gnus-thread-hide-killed
9971 (gnus-summary-hide-thread))
9972 ;; If marked as read, go to next unread subject.
9974 ;; Go to next unread subject.
9975 (gnus-summary-next-subject 1 t)))
9976 (gnus-set-mode-line 'summary))
9978 ;; Summary sorting commands
9980 (defun gnus-summary-sort-by-number (&optional reverse)
9981 "Sort the summary buffer by article number.
9982 Argument REVERSE means reverse order."
9984 (gnus-summary-sort 'number reverse))
9986 (defun gnus-summary-sort-by-author (&optional reverse)
9987 "Sort the summary buffer by author name alphabetically.
9988 If `case-fold-search' is non-nil, case of letters is ignored.
9989 Argument REVERSE means reverse order."
9991 (gnus-summary-sort 'author reverse))
9993 (defun gnus-summary-sort-by-subject (&optional reverse)
9994 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9995 If `case-fold-search' is non-nil, case of letters is ignored.
9996 Argument REVERSE means reverse order."
9998 (gnus-summary-sort 'subject reverse))
10000 (defun gnus-summary-sort-by-date (&optional reverse)
10001 "Sort the summary buffer by date.
10002 Argument REVERSE means reverse order."
10004 (gnus-summary-sort 'date reverse))
10006 (defun gnus-summary-sort-by-score (&optional reverse)
10007 "Sort the summary buffer by score.
10008 Argument REVERSE means reverse order."
10010 (gnus-summary-sort 'score reverse))
10012 (defun gnus-summary-sort-by-lines (&optional reverse)
10013 "Sort the summary buffer by the number of lines.
10014 Argument REVERSE means reverse order."
10016 (gnus-summary-sort 'lines reverse))
10018 (defun gnus-summary-sort-by-chars (&optional reverse)
10019 "Sort the summary buffer by article length.
10020 Argument REVERSE means reverse order."
10022 (gnus-summary-sort 'chars reverse))
10024 (defun gnus-summary-sort-by-original (&optional reverse)
10025 "Sort the summary buffer using the default sorting method.
10026 Argument REVERSE means reverse order."
10028 (let* ((buffer-read-only)
10029 (gnus-summary-prepare-hook nil))
10030 ;; We do the sorting by regenerating the threads.
10031 (gnus-summary-prepare)
10032 ;; Hide subthreads if needed.
10033 (gnus-summary-maybe-hide-threads)))
10035 (defun gnus-summary-sort (predicate reverse)
10036 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10037 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10038 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10039 (gnus-thread-sort-functions
10044 (gnus-sort-gathered-threads-function
10045 gnus-thread-sort-functions)
10046 (gnus-article-sort-functions
10050 (,article t2 t1))))
10052 (gnus-summary-prepare-hook nil))
10053 ;; We do the sorting by regenerating the threads.
10054 (gnus-summary-prepare)
10055 ;; Hide subthreads if needed.
10056 (gnus-summary-maybe-hide-threads)))
10058 ;; Summary saving commands.
10060 (defun gnus-summary-save-article (&optional n not-saved)
10061 "Save the current article using the default saver function.
10062 If N is a positive number, save the N next articles.
10063 If N is a negative number, save the N previous articles.
10064 If N is nil and any articles have been marked with the process mark,
10065 save those articles instead.
10066 The variable `gnus-default-article-saver' specifies the saver function."
10068 (let* ((articles (gnus-summary-work-articles n))
10069 (save-buffer (save-excursion
10070 (nnheader-set-temp-buffer " *Gnus Save*")))
10071 (num (length articles))
10073 (dolist (article articles)
10074 (setq header (gnus-summary-article-header article))
10075 (if (not (vectorp header))
10076 ;; This is a pseudo-article.
10077 (if (assq 'name header)
10078 (gnus-copy-file (cdr (assq 'name header)))
10079 (gnus-message 1 "Article %d is unsaveable" article))
10080 ;; This is a real article.
10081 (save-window-excursion
10082 (let ((gnus-display-mime-function nil)
10083 (gnus-article-prepare-hook nil))
10084 (gnus-summary-select-article t nil nil article)))
10086 (set-buffer save-buffer)
10088 (insert-buffer-substring gnus-original-article-buffer))
10089 (setq file (gnus-article-save save-buffer file num))
10090 (gnus-summary-remove-process-mark article)
10092 (gnus-summary-set-saved-mark article))))
10093 (gnus-kill-buffer save-buffer)
10094 (gnus-summary-position-point)
10095 (gnus-set-mode-line 'summary)
10098 (defun gnus-summary-pipe-output (&optional arg)
10099 "Pipe the current article to a subprocess.
10100 If N is a positive number, pipe the N next articles.
10101 If N is a negative number, pipe the N previous articles.
10102 If N is nil and any articles have been marked with the process mark,
10103 pipe those articles instead."
10105 (require 'gnus-art)
10106 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10107 (gnus-summary-save-article arg t))
10108 (let ((buffer (get-buffer "*Shell Command Output*")))
10110 (with-current-buffer buffer (> (point-max) (point-min))))
10111 (gnus-configure-windows 'pipe))))
10113 (defun gnus-summary-save-article-mail (&optional arg)
10114 "Append the current article to an mail file.
10115 If N is a positive number, save the N next articles.
10116 If N is a negative number, save the N previous articles.
10117 If N is nil and any articles have been marked with the process mark,
10118 save those articles instead."
10120 (require 'gnus-art)
10121 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10122 (gnus-summary-save-article arg)))
10124 (defun gnus-summary-save-article-rmail (&optional arg)
10125 "Append the current article to an rmail file.
10126 If N is a positive number, save the N next articles.
10127 If N is a negative number, save the N previous articles.
10128 If N is nil and any articles have been marked with the process mark,
10129 save those articles instead."
10131 (require 'gnus-art)
10132 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10133 (gnus-summary-save-article arg)))
10135 (defun gnus-summary-save-article-file (&optional arg)
10136 "Append the current article to a file.
10137 If N is a positive number, save the N next articles.
10138 If N is a negative number, save the N previous articles.
10139 If N is nil and any articles have been marked with the process mark,
10140 save those articles instead."
10142 (require 'gnus-art)
10143 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10144 (gnus-summary-save-article arg)))
10146 (defun gnus-summary-write-article-file (&optional arg)
10147 "Write the current article to a file, deleting the previous file.
10148 If N is a positive number, save the N next articles.
10149 If N is a negative number, save the N previous articles.
10150 If N is nil and any articles have been marked with the process mark,
10151 save those articles instead."
10153 (require 'gnus-art)
10154 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10155 (gnus-summary-save-article arg)))
10157 (defun gnus-summary-save-article-body-file (&optional arg)
10158 "Append the current article body to a file.
10159 If N is a positive number, save the N next articles.
10160 If N is a negative number, save the N previous articles.
10161 If N is nil and any articles have been marked with the process mark,
10162 save those articles instead."
10164 (require 'gnus-art)
10165 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10166 (gnus-summary-save-article arg)))
10168 (defun gnus-summary-muttprint (&optional arg)
10169 "Print the current article using Muttprint.
10170 If N is a positive number, save the N next articles.
10171 If N is a negative number, save the N previous articles.
10172 If N is nil and any articles have been marked with the process mark,
10173 save those articles instead."
10175 (require 'gnus-art)
10176 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10177 (gnus-summary-save-article arg t)))
10179 (defun gnus-summary-pipe-message (program)
10180 "Pipe the current article through PROGRAM."
10181 (interactive "sProgram: ")
10182 (gnus-summary-select-article)
10183 (let ((mail-header-separator ""))
10184 (gnus-eval-in-buffer-window gnus-article-buffer
10187 (let ((start (window-start))
10189 (message-pipe-buffer-body program)
10190 (set-window-start (get-buffer-window (current-buffer)) start))))))
10192 (defun gnus-get-split-value (methods)
10193 "Return a value based on the split METHODS."
10194 (let (split-name method result match)
10197 (set-buffer gnus-original-article-buffer)
10199 (nnheader-narrow-to-headers)
10200 (while (and methods (not split-name))
10201 (goto-char (point-min))
10202 (setq method (pop methods))
10203 (setq match (car method))
10206 ;; Regular expression.
10208 (re-search-forward match nil t)))
10209 ((gnus-functionp match)
10213 (setq result (funcall match gnus-newsgroup-name))))
10218 (setq result (eval match)))))
10219 (setq split-name (cdr method))
10220 (cond ((stringp result)
10221 (push (expand-file-name
10222 result gnus-article-save-directory)
10225 (setq split-name (append result split-name)))))))))
10226 (nreverse split-name)))
10228 (defun gnus-valid-move-group-p (group)
10229 (and (boundp group)
10230 (symbol-name group)
10231 (symbol-value group)
10232 (gnus-get-function (gnus-find-method-for-group
10233 (symbol-name group)) 'request-accept-article t)))
10235 (defun gnus-read-move-group-name (prompt default articles prefix)
10236 "Read a group name."
10237 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10238 (minibuffer-confirm-incomplete nil) ; XEmacs
10240 (format "%s %s to:"
10242 (if (> (length articles) 1)
10243 (format "these %d articles" (length articles))
10248 (gnus-completing-read-with-default
10251 'gnus-valid-move-group-p
10253 'gnus-group-history))
10254 ((= 1 (length split-name))
10255 (gnus-completing-read-with-default
10256 (car split-name) prom
10258 'gnus-valid-move-group-p
10260 'gnus-group-history))
10262 (gnus-completing-read-with-default
10264 (mapcar (lambda (el) (list el))
10265 (nreverse split-name))
10267 'gnus-group-history))))
10268 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10270 (if (or (string= to-newsgroup "")
10271 (string= to-newsgroup prefix))
10272 (setq to-newsgroup default))
10273 (unless to-newsgroup
10274 (error "No group name entered"))
10275 (or (gnus-active to-newsgroup)
10276 (gnus-activate-group to-newsgroup nil nil to-method)
10277 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10279 (or (and (gnus-request-create-group to-newsgroup to-method)
10280 (gnus-activate-group
10281 to-newsgroup nil nil to-method)
10282 (gnus-subscribe-group to-newsgroup))
10283 (error "Couldn't create group %s" to-newsgroup)))
10284 (error "No such group: %s" to-newsgroup)))
10287 (defun gnus-summary-save-parts (type dir n &optional reverse)
10288 "Save parts matching TYPE to DIR.
10289 If REVERSE, save parts that do not match TYPE."
10291 (list (read-string "Save parts of type: "
10292 (or (car gnus-summary-save-parts-type-history)
10293 gnus-summary-save-parts-default-mime)
10294 'gnus-summary-save-parts-type-history)
10295 (setq gnus-summary-save-parts-last-directory
10296 (read-file-name "Save to directory: "
10297 gnus-summary-save-parts-last-directory
10299 current-prefix-arg))
10300 (gnus-summary-iterate n
10301 (let ((gnus-display-mime-function nil)
10302 (gnus-inhibit-treatment t))
10303 (gnus-summary-select-article))
10305 (set-buffer gnus-article-buffer)
10306 (let ((handles (or gnus-article-mime-handles
10307 (mm-dissect-buffer) (mm-uu-dissect))))
10309 (gnus-summary-save-parts-1 type dir handles reverse)
10310 (unless gnus-article-mime-handles ;; Don't destroy this case.
10311 (mm-destroy-parts handles)))))))
10313 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10314 (if (stringp (car handle))
10315 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10318 (not (string-match type (mm-handle-media-type handle)))
10319 (string-match type (mm-handle-media-type handle)))
10320 (let ((file (expand-file-name
10321 (file-name-nondirectory
10323 (mail-content-type-get
10324 (mm-handle-disposition handle) 'filename)
10325 (concat gnus-newsgroup-name
10326 "." (number-to-string
10327 (cdr gnus-article-current)))))
10329 (unless (file-exists-p file)
10330 (mm-save-part-to-file handle file))))))
10332 ;; Summary extract commands
10334 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10335 (let ((buffer-read-only nil)
10336 (article (gnus-summary-article-number))
10338 (unless (gnus-summary-goto-subject article)
10339 (error "No such article: %d" article))
10340 (gnus-summary-position-point)
10341 ;; If all commands are to be bunched up on one line, we collect
10343 (unless gnus-view-pseudos-separately
10344 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10347 (setq action (cdr (assq 'action (car ps))))
10348 (setq files (list (cdr (assq 'name (car ps)))))
10349 (while (and ps (cdr ps)
10350 (string= (or action "1")
10351 (or (cdr (assq 'action (cadr ps))) "2")))
10352 (push (cdr (assq 'name (cadr ps))) files)
10353 (setcdr ps (cddr ps)))
10355 (when (not (string-match "%s" action))
10358 (when (assq 'execute (car ps))
10359 (setcdr (assq 'execute (car ps))
10360 (funcall (if (string-match "%s" action)
10369 (setq ps (cdr ps)))))
10370 (if (and gnus-view-pseudos (not not-view))
10372 (when (assq 'execute (car pslist))
10373 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10374 (eq gnus-view-pseudos 'not-confirm)))
10375 (setq pslist (cdr pslist)))
10378 (setq after-article (or (cdr (assq 'article (car pslist)))
10379 (gnus-summary-article-number)))
10380 (gnus-summary-goto-subject after-article)
10383 (insert " " (file-name-nondirectory
10384 (cdr (assq 'name (car pslist))))
10385 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10387 (forward-line -1) ; back to `b'
10388 (gnus-add-text-properties
10389 b (1- e) (list 'gnus-number gnus-reffed-article-number
10390 gnus-mouse-face-prop gnus-mouse-face))
10392 after-article gnus-reffed-article-number
10393 gnus-unread-mark b (car pslist) 0 (- e b))
10394 (setq gnus-newsgroup-unreads
10395 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10396 gnus-reffed-article-number))
10397 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10398 (setq pslist (cdr pslist)))))))
10400 (defun gnus-pseudos< (p1 p2)
10401 (let ((c1 (cdr (assq 'action p1)))
10402 (c2 (cdr (assq 'action p2))))
10403 (and c1 c2 (string< c1 c2))))
10405 (defun gnus-request-pseudo-article (props)
10406 (cond ((assq 'execute props)
10407 (gnus-execute-command (cdr (assq 'execute props)))))
10408 (let ((gnus-current-article (gnus-summary-article-number)))
10409 (gnus-run-hooks 'gnus-mark-article-hook)))
10411 (defun gnus-execute-command (command &optional automatic)
10413 (gnus-article-setup-buffer)
10414 (set-buffer gnus-article-buffer)
10415 (setq buffer-read-only nil)
10416 (let ((command (if automatic command
10417 (read-string "Command: " (cons command 0)))))
10419 (insert "$ " command "\n\n")
10420 (if gnus-view-pseudo-asynchronously
10421 (start-process "gnus-execute" (current-buffer) shell-file-name
10422 shell-command-switch command)
10423 (call-process shell-file-name nil t nil
10424 shell-command-switch command)))))
10426 ;; Summary kill commands.
10428 (defun gnus-summary-edit-global-kill (article)
10429 "Edit the \"global\" kill file."
10430 (interactive (list (gnus-summary-article-number)))
10431 (gnus-group-edit-global-kill article))
10433 (defun gnus-summary-edit-local-kill ()
10434 "Edit a local kill file applied to the current newsgroup."
10436 (setq gnus-current-headers (gnus-summary-article-header))
10437 (gnus-group-edit-local-kill
10438 (gnus-summary-article-number) gnus-newsgroup-name))
10440 ;;; Header reading.
10442 (defun gnus-read-header (id &optional header)
10443 "Read the headers of article ID and enter them into the Gnus system."
10444 (let ((group gnus-newsgroup-name)
10445 (gnus-override-method
10447 gnus-override-method
10448 (and (gnus-news-group-p gnus-newsgroup-name)
10449 (car (gnus-refer-article-methods)))))
10451 ;; First we check to see whether the header in question is already
10454 ;; This is a Message-ID.
10455 (setq header (or header (gnus-id-to-header id)))
10456 ;; This is an article number.
10457 (setq header (or header (gnus-summary-article-header id))))
10459 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10460 ;; We have found the header.
10462 ;; If this is a sparse article, we have to nix out its
10463 ;; previous entry in the thread hashtb.
10465 (gnus-summary-article-sparse-p (mail-header-number header)))
10466 (let* ((parent (gnus-parent-id (mail-header-references header)))
10467 (thread (and parent (gnus-id-to-thread parent))))
10469 (delq (assq header thread) thread))))
10470 ;; We have to really fetch the header to this article.
10472 (set-buffer nntp-server-buffer)
10473 (when (setq where (gnus-request-head id group))
10474 (nnheader-fold-continuation-lines)
10475 (goto-char (point-max))
10477 (goto-char (point-min))
10481 ((cdr where) (cdr where))
10482 (header (mail-header-number header))
10483 (t gnus-reffed-article-number))
10485 (insert " Article retrieved.\n"))
10486 (if (or (not where)
10487 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10488 () ; Malformed head.
10489 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10490 (when (and (stringp id)
10491 (not (string= (gnus-group-real-name group)
10493 ;; If we fetched by Message-ID and the article came
10494 ;; from a different group, we fudge some bogus article
10495 ;; numbers for this article.
10496 (mail-header-set-number header gnus-reffed-article-number))
10498 (set-buffer gnus-summary-buffer)
10499 (decf gnus-reffed-article-number)
10500 (gnus-remove-header (mail-header-number header))
10501 (push header gnus-newsgroup-headers)
10502 (setq gnus-current-headers header)
10503 (push (mail-header-number header) gnus-newsgroup-limit)))
10506 (defun gnus-remove-header (number)
10507 "Remove header NUMBER from `gnus-newsgroup-headers'."
10508 (if (and gnus-newsgroup-headers
10509 (= number (mail-header-number (car gnus-newsgroup-headers))))
10510 (pop gnus-newsgroup-headers)
10511 (let ((headers gnus-newsgroup-headers))
10512 (while (and (cdr headers)
10513 (not (= number (mail-header-number (cadr headers)))))
10515 (when (cdr headers)
10516 (setcdr headers (cddr headers))))))
10519 ;;; summary highlights
10522 (defun gnus-highlight-selected-summary ()
10523 "Highlight selected article in summary buffer."
10524 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10525 (when gnus-summary-selected-face
10527 (let* ((beg (progn (beginning-of-line) (point)))
10528 (end (progn (end-of-line) (point)))
10529 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10530 (from (if (get-text-property beg gnus-mouse-face-prop)
10532 (or (next-single-property-change
10533 beg gnus-mouse-face-prop nil end)
10538 (or (next-single-property-change
10539 from gnus-mouse-face-prop nil end)
10541 ;; If no mouse-face prop on line we will have to = from = end,
10542 ;; so we highlight the entire line instead.
10543 (when (= (+ to 2) from)
10546 (if gnus-newsgroup-selected-overlay
10547 ;; Move old overlay.
10549 gnus-newsgroup-selected-overlay from to (current-buffer))
10550 ;; Create new overlay.
10552 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10553 'face gnus-summary-selected-face))))))
10555 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10556 (defun gnus-summary-highlight-line ()
10557 "Highlight current line according to `gnus-summary-highlight'."
10558 (let* ((list gnus-summary-highlight)
10560 (end (progn (end-of-line) (point)))
10561 ;; now find out where the line starts and leave point there.
10562 (beg (progn (beginning-of-line) (point)))
10563 (article (gnus-summary-article-number))
10564 (score (or (cdr (assq (or article gnus-current-article)
10565 gnus-newsgroup-scored))
10566 gnus-summary-default-score 0))
10567 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10568 (inhibit-read-only t))
10569 ;; Eval the cars of the lists until we find a match.
10570 (let ((default gnus-summary-default-score)
10571 (default-high gnus-summary-default-high-score)
10572 (default-low gnus-summary-default-low-score))
10574 (not (eval (caar list))))
10575 (setq list (cdr list))))
10576 (let ((face (cdar list)))
10577 (unless (eq face (get-text-property beg 'face))
10578 (gnus-put-text-property-excluding-characters-with-faces
10580 (setq face (if (boundp face) (symbol-value face) face)))
10581 (when gnus-summary-highlight-line-function
10582 (funcall gnus-summary-highlight-line-function article face))))
10585 (defun gnus-update-read-articles (group unread &optional compute)
10586 "Update the list of read articles in GROUP."
10587 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10588 (entry (gnus-gethash group gnus-newsrc-hashtb))
10589 (info (nth 2 entry))
10591 (unread (sort (copy-sequence unread) '<))
10593 (if (or (not info) (not active))
10594 ;; There is no info on this group if it was, in fact,
10595 ;; killed. Gnus stores no information on killed groups, so
10596 ;; there's nothing to be done.
10597 ;; One could store the information somewhere temporarily,
10598 ;; perhaps... Hmmm...
10600 ;; Remove any negative articles numbers.
10601 (while (and unread (< (car unread) 0))
10602 (setq unread (cdr unread)))
10603 ;; Remove any expired article numbers
10604 (while (and unread (< (car unread) (car active)))
10605 (setq unread (cdr unread)))
10606 ;; Compute the ranges of read articles by looking at the list of
10607 ;; unread articles.
10609 (when (/= (car unread) prev)
10610 (push (if (= prev (1- (car unread))) prev
10611 (cons prev (1- (car unread))))
10613 (setq prev (1+ (car unread)))
10614 (setq unread (cdr unread)))
10615 (when (<= prev (cdr active))
10616 (push (cons prev (cdr active)) read))
10617 (setq read (if (> (length read) 1) (nreverse read) read))
10622 ;; Propagate the read marks to the backend.
10623 (when (gnus-check-backend-function 'request-set-mark group)
10624 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10625 (add (gnus-remove-from-range read (gnus-info-read info))))
10627 (unless (gnus-check-group group)
10628 (error "Can't open server for %s" group))
10629 (gnus-request-set-mark
10630 group (delq nil (list (if add (list add 'add '(read)))
10631 (if del (list del 'del '(read))))))
10633 `(gnus-request-set-mark
10636 (if del (list del 'add '(read)))
10637 (if add (list add 'del '(read))))))))))
10638 (set-buffer gnus-group-buffer)
10639 (gnus-undo-register
10641 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10642 (gnus-info-set-read ',info ',(gnus-info-read info))
10643 (gnus-get-unread-articles-in-group ',info
10644 (gnus-active ,group))
10645 (gnus-group-update-group ,group t)
10647 ;; Enter this list into the group info.
10648 (gnus-info-set-read info read)
10649 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10650 (gnus-get-unread-articles-in-group info (gnus-active group))
10653 (defun gnus-offer-save-summaries ()
10654 "Offer to save all active summary buffers."
10656 ;; Go through all buffers and find all summaries.
10657 (dolist (buffer (buffer-list))
10658 (when (and (setq buffer (buffer-name buffer))
10659 (string-match "Summary" buffer)
10661 (set-buffer buffer)
10662 ;; We check that this is, indeed, a summary buffer.
10663 (and (eq major-mode 'gnus-summary-mode)
10664 ;; Also make sure this isn't bogus.
10665 gnus-newsgroup-prepared
10666 ;; Also make sure that this isn't a
10667 ;; dead summary buffer.
10668 (not gnus-dead-summary-mode))))
10669 (push buffer buffers)))
10670 ;; Go through all these summary buffers and offer to save them.
10674 "Update summary buffer %s? "
10676 (switch-to-buffer buf)
10677 (gnus-summary-exit))
10680 (defun gnus-summary-setup-default-charset ()
10681 "Setup newsgroup default charset."
10682 (if (equal gnus-newsgroup-name "nndraft:drafts")
10683 (setq gnus-newsgroup-charset nil)
10684 (let* ((ignored-charsets
10685 (or gnus-newsgroup-ephemeral-ignored-charsets
10687 (and gnus-newsgroup-name
10688 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10689 gnus-newsgroup-ignored-charsets))))
10690 (setq gnus-newsgroup-charset
10691 (or gnus-newsgroup-ephemeral-charset
10692 (and gnus-newsgroup-name
10693 (gnus-parameter-charset gnus-newsgroup-name))
10694 gnus-default-charset))
10695 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10696 ignored-charsets))))
10702 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10703 "Display the current article buffer fully MIME-buttonized.
10704 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10705 treated as multipart/mixed."
10707 (require 'gnus-art)
10708 (let ((gnus-unbuttonized-mime-types nil)
10709 (gnus-mime-display-multipart-as-mixed show-all-parts))
10710 (gnus-summary-show-article)))
10712 (defun gnus-summary-repair-multipart (article)
10713 "Add a Content-Type header to a multipart article without one."
10714 (interactive (list (gnus-summary-article-number)))
10715 (gnus-with-article article
10716 (message-narrow-to-head)
10717 (message-remove-header "Mime-Version")
10718 (goto-char (point-max))
10719 (insert "Mime-Version: 1.0\n")
10721 (when (search-forward "\n--" nil t)
10722 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10723 (message-narrow-to-head)
10724 (message-remove-header "Content-Type")
10725 (goto-char (point-max))
10726 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10729 (let (gnus-mark-article-hook)
10730 (gnus-summary-select-article t t nil article)))
10732 (defun gnus-summary-toggle-display-buttonized ()
10733 "Toggle the buttonizing of the article buffer."
10735 (require 'gnus-art)
10736 (if (setq gnus-inhibit-mime-unbuttonizing
10737 (not gnus-inhibit-mime-unbuttonizing))
10738 (let ((gnus-unbuttonized-mime-types nil))
10739 (gnus-summary-show-article))
10740 (gnus-summary-show-article)))
10743 ;;; Generic summary marking commands
10746 (defvar gnus-summary-marking-alist
10747 '((read gnus-del-mark "d")
10748 (unread gnus-unread-mark "u")
10749 (ticked gnus-ticked-mark "!")
10750 (dormant gnus-dormant-mark "?")
10751 (expirable gnus-expirable-mark "e"))
10752 "An alist of names/marks/keystrokes.")
10754 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10755 (defvar gnus-summary-mark-map)
10757 (defun gnus-summary-make-all-marking-commands ()
10758 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10759 (dolist (elem gnus-summary-marking-alist)
10760 (apply 'gnus-summary-make-marking-command elem)))
10762 (defun gnus-summary-make-marking-command (name mark keystroke)
10763 (let ((map (make-sparse-keymap)))
10764 (define-key gnus-summary-generic-mark-map keystroke map)
10765 (dolist (lway `((next "next" next nil "n")
10766 (next-unread "next unread" next t "N")
10767 (prev "previous" prev nil "p")
10768 (prev-unread "previous unread" prev t "P")
10769 (nomove "" nil nil ,keystroke)))
10770 (let ((func (gnus-summary-make-marking-command-1
10771 mark (car lway) lway name)))
10772 (setq func (eval func))
10773 (define-key map (nth 4 lway) func)))))
10775 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10777 (format "gnus-summary-put-mark-as-%s%s"
10778 name (if (eq way 'nomove)
10780 (concat "-" (symbol-name way)))))
10783 "Mark the current article as %s%s.
10784 If N, the prefix, then repeat N times.
10785 If N is negative, move in reverse order.
10786 The difference between N and the actual number of articles marked is
10790 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10792 (defun gnus-summary-generic-mark (n mark move unread)
10793 "Mark N articles with MARK."
10794 (unless (eq major-mode 'gnus-summary-mode)
10795 (error "This command can only be used in the summary buffer"))
10796 (gnus-summary-show-thread)
10799 ((eq move 'next) 1)
10800 ((eq move 'prev) -1)
10802 (if (zerop nummove)
10806 nummove (* -1 nummove))))
10807 (while (and (> n 0)
10808 (gnus-summary-mark-article nil mark)
10809 (zerop (gnus-summary-next-subject nummove unread t)))
10812 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10813 (gnus-summary-recenter)
10814 (gnus-summary-position-point)
10815 (gnus-set-mode-line 'summary)
10818 (defun gnus-summary-insert-articles (articles)
10819 (when (setq articles
10820 (gnus-sorted-difference articles
10821 (mapcar (lambda (h)
10822 (mail-header-number h))
10823 gnus-newsgroup-headers)))
10824 (setq gnus-newsgroup-headers
10826 gnus-newsgroup-headers
10827 (gnus-fetch-headers articles)
10828 'gnus-article-sort-by-number))
10829 ;; Suppress duplicates?
10830 (when gnus-suppress-duplicates
10831 (gnus-dup-suppress-articles))
10833 ;; We might want to build some more threads first.
10834 (when (and gnus-fetch-old-headers
10835 (eq gnus-headers-retrieved-by 'nov))
10836 (if (eq gnus-fetch-old-headers 'invisible)
10837 (gnus-build-all-threads)
10838 (gnus-build-old-threads)))
10839 ;; Let the Gnus agent mark articles as read.
10841 (gnus-agent-get-undownloaded-list))
10842 ;; Remove list identifiers from subject
10843 (when gnus-list-identifiers
10844 (gnus-summary-remove-list-identifiers))
10845 ;; First and last article in this newsgroup.
10846 (when gnus-newsgroup-headers
10847 (setq gnus-newsgroup-begin
10848 (mail-header-number (car gnus-newsgroup-headers))
10850 (mail-header-number
10851 (gnus-last-element gnus-newsgroup-headers))))
10852 (when gnus-use-scoring
10853 (gnus-possibly-score-headers))))
10855 (defun gnus-summary-insert-old-articles (&optional all)
10856 "Insert all old articles in this group.
10857 If ALL is non-nil, already read articles become readable.
10858 If ALL is a number, fetch this number of articles."
10861 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
10864 (gnus-sorted-difference
10865 (gnus-uncompress-range (list gnus-newsgroup-active))
10867 (setq len (length older))
10872 (setq older (last older all))))
10875 (if (and (numberp gnus-large-newsgroup)
10876 (> len gnus-large-newsgroup))
10880 "How many articles from %s (default %d): "
10882 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10884 (unless (string-match "^[ \t]*$" input)
10885 (setq all (string-to-number input))
10887 (setq older (last older all))))))))
10889 (message "No old news.")
10890 (gnus-summary-insert-articles older)
10891 (gnus-summary-limit (gnus-sorted-nunion old older))))
10892 (gnus-summary-position-point)))
10894 (defun gnus-summary-insert-new-articles ()
10895 "Insert all new articles in this group."
10898 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
10899 (old-active gnus-newsgroup-active)
10900 (nnmail-fetched-sources (list t))
10902 (setq gnus-newsgroup-active
10903 (gnus-activate-group gnus-newsgroup-name 'scan))
10904 (setq i (1+ (cdr old-active)))
10905 (while (<= i (cdr gnus-newsgroup-active))
10909 (message "No gnus is bad news.")
10910 (setq new (nreverse new))
10911 (gnus-summary-insert-articles new)
10912 (setq gnus-newsgroup-unreads
10913 (gnus-sorted-nunion gnus-newsgroup-unreads new))
10914 (gnus-summary-limit (gnus-sorted-nunion old new))))
10915 (gnus-summary-position-point)))
10917 (gnus-summary-make-all-marking-commands)
10919 (gnus-ems-redefine)
10921 (provide 'gnus-sum)
10923 (run-hooks 'gnus-sum-load-hook)
10925 ;;; gnus-sum.el ends here