1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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")
46 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
47 "Deuglify broken Outlook (Express) articles and redisplay."
49 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
50 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
51 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
53 (defcustom gnus-kill-summary-on-exit t
54 "*If non-nil, kill the summary buffer when you exit from it.
55 If nil, the summary will become a \"*Dead Summary*\" buffer, and
56 it will be killed sometime later."
57 :group 'gnus-summary-exit
60 (defcustom gnus-fetch-old-headers nil
61 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
62 If an unread article in the group refers to an older, already read (or
63 just marked as read) article, the old article will not normally be
64 displayed in the Summary buffer. If this variable is non-nil, Gnus
65 will attempt to grab the headers to the old articles, and thereby
66 build complete threads. If it has the value `some', only enough
67 headers to connect otherwise loose threads will be displayed. This
68 variable can also be a number. In that case, no more than that number
69 of old headers will be fetched. If it has the value `invisible', all
70 old headers will be fetched, but none will be displayed.
72 The server has to support NOV for any of this to work."
74 :type '(choice (const :tag "off" nil)
77 (sexp :menu-tag "other" t)))
79 (defcustom gnus-refer-thread-limit 200
80 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
81 If t, fetch all the available old headers."
84 (sexp :menu-tag "other" t)))
86 (defcustom gnus-summary-make-false-root 'adopt
87 "*nil means that Gnus won't gather loose threads.
88 If the root of a thread has expired or been read in a previous
89 session, the information necessary to build a complete thread has been
90 lost. Instead of having many small sub-threads from this original thread
91 scattered all over the summary buffer, Gnus can gather them.
93 If non-nil, Gnus will try to gather all loose sub-threads from an
94 original thread into one large thread.
96 If this variable is non-nil, it should be one of `none', `adopt',
99 If this variable is `none', Gnus will not make a false root, but just
100 present the sub-threads after another.
101 If this variable is `dummy', Gnus will create a dummy root that will
102 have all the sub-threads as children.
103 If this variable is `adopt', Gnus will make one of the \"children\"
104 the parent and mark all the step-children as such.
105 If this variable is `empty', the \"children\" are printed with empty
106 subject fields. (Or rather, they will be printed with a string
107 given by the `gnus-summary-same-subject' variable.)"
109 :type '(choice (const :tag "off" nil)
115 (defcustom gnus-summary-make-false-root-always nil
116 "Always make a false dummy root."
120 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
121 "*A regexp to match subjects to be excluded from loose thread gathering.
122 As loose thread gathering is done on subjects only, that means that
123 there can be many false gatherings performed. By rooting out certain
124 common subjects, gathering might become saner."
128 (defcustom gnus-summary-gather-subject-limit nil
129 "*Maximum length of subject comparisons when gathering loose threads.
130 Use nil to compare full subjects. Setting this variable to a low
131 number will help gather threads that have been corrupted by
132 newsreaders chopping off subject lines, but it might also mean that
133 unrelated articles that have subject that happen to begin with the
134 same few characters will be incorrectly gathered.
136 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
139 :type '(choice (const :tag "off" nil)
141 (sexp :menu-tag "on" t)))
143 (defcustom gnus-simplify-subject-functions nil
144 "List of functions taking a string argument that simplify subjects.
145 The functions are applied recursively.
147 Useful functions to put in this list include:
148 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
149 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
151 :type '(repeat function))
153 (defcustom gnus-simplify-ignored-prefixes nil
154 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
156 :type '(choice (const :tag "off" nil)
159 (defcustom gnus-build-sparse-threads nil
160 "*If non-nil, fill in the gaps in threads.
161 If `some', only fill in the gaps that are needed to tie loose threads
162 together. If `more', fill in all leaf nodes that Gnus can find. If
163 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
165 :type '(choice (const :tag "off" nil)
168 (sexp :menu-tag "all" t)))
170 (defcustom gnus-summary-thread-gathering-function
171 'gnus-gather-threads-by-subject
172 "*Function used for gathering loose threads.
173 There are two pre-defined functions: `gnus-gather-threads-by-subject',
174 which only takes Subjects into consideration; and
175 `gnus-gather-threads-by-references', which compared the References
176 headers of the articles to find matches."
178 :type '(radio (function-item gnus-gather-threads-by-subject)
179 (function-item gnus-gather-threads-by-references)
180 (function :tag "other")))
182 (defcustom gnus-summary-same-subject ""
183 "*String indicating that the current article has the same subject as the previous.
184 This variable will only be used if the value of
185 `gnus-summary-make-false-root' is `empty'."
186 :group 'gnus-summary-format
189 (defcustom gnus-summary-goto-unread t
190 "*If t, many commands will go to the next unread article.
191 This applies to marking commands as well as other commands that
192 \"naturally\" select the next article, like, for instance, `SPC' at
193 the end of an article.
195 If nil, the marking commands do NOT go to the next unread article
196 \(they go to the next article instead). If `never', commands that
197 usually go to the next unread article, will go to the next article,
198 whether it is read or not."
199 :group 'gnus-summary-marks
200 :link '(custom-manual "(gnus)Setting Marks")
201 :type '(choice (const :tag "off" nil)
203 (sexp :menu-tag "on" t)))
205 (defcustom gnus-summary-default-score 0
206 "*Default article score level.
207 All scores generated by the score files will be added to this score.
208 If this variable is nil, scoring will be disabled."
209 :group 'gnus-score-default
210 :type '(choice (const :tag "disable")
213 (defcustom gnus-summary-default-high-score 0
214 "*Default threshold for a high scored article.
215 An article will be highlighted as high scored if its score is greater
217 :group 'gnus-score-default
220 (defcustom gnus-summary-default-low-score 0
221 "*Default threshold for a low scored article.
222 An article will be highlighted as low scored if its score is smaller
224 :group 'gnus-score-default
227 (defcustom gnus-summary-zcore-fuzz 0
228 "*Fuzziness factor for the zcore in the summary buffer.
229 Articles with scores closer than this to `gnus-summary-default-score'
231 :group 'gnus-summary-format
234 (defcustom gnus-simplify-subject-fuzzy-regexp nil
235 "*Strings to be removed when doing fuzzy matches.
236 This can either be a regular expression or list of regular expressions
237 that will be removed from subject strings if fuzzy subject
238 simplification is selected."
240 :type '(repeat regexp))
242 (defcustom gnus-show-threads t
243 "*If non-nil, display threads in summary mode."
247 (defcustom gnus-thread-hide-subtree nil
248 "*If non-nil, hide all threads initially.
249 This can be a predicate specifier which says which threads to hide.
250 If threads are hidden, you have to run the command
251 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
252 to expose hidden threads."
256 (defcustom gnus-thread-hide-killed t
257 "*If non-nil, hide killed threads automatically."
261 (defcustom gnus-thread-ignore-subject t
262 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
263 If nil, articles that have different subjects from their parents will
264 start separate threads."
268 (defcustom gnus-thread-operation-ignore-subject t
269 "*If non-nil, subjects will be ignored when doing thread commands.
270 This affects commands like `gnus-summary-kill-thread' and
271 `gnus-summary-lower-thread'.
273 If this variable is nil, articles in the same thread with different
274 subjects will not be included in the operation in question. If this
275 variable is `fuzzy', only articles that have subjects that are fuzzily
276 equal will be included."
278 :type '(choice (const :tag "off" nil)
282 (defcustom gnus-thread-indent-level 4
283 "*Number that says how much each sub-thread should be indented."
287 (defcustom gnus-auto-extend-newsgroup t
288 "*If non-nil, extend newsgroup forward and backward when requested."
289 :group 'gnus-summary-choose
292 (defcustom gnus-auto-select-first t
293 "*If non-nil, select the article under point.
294 Which article this is is controlled by the `gnus-auto-select-subject'
297 If you want to prevent automatic selection of articles in some
298 newsgroups, set the variable to nil in `gnus-select-group-hook'."
299 :group 'gnus-group-select
300 :type '(choice (const :tag "none" nil)
301 (sexp :menu-tag "first" t)))
303 (defcustom gnus-auto-select-subject 'unread
304 "*Says what subject to place under point when entering a group.
306 This variable can either be the symbols `first' (place point on the
307 first subject), `unread' (place point on the subject line of the first
308 unread article), `best' (place point on the subject line of the
309 higest-scored article), `unseen' (place point on the subject line of
310 the first unseen article), 'unseen-or-unread' (place point on the subject
311 line of the first unseen article or, if all article have been seen, on the
312 subject line of the first unread article), or a function to be called to
313 place point on some subject line."
314 :group 'gnus-group-select
315 :type '(choice (const best)
319 (const unseen-or-unread)))
321 (defcustom gnus-auto-select-next t
322 "*If non-nil, offer to go to the next group from the end of the previous.
323 If the value is t and the next newsgroup is empty, Gnus will exit
324 summary mode and go back to group mode. If the value is neither nil
325 nor t, Gnus will select the following unread newsgroup. In
326 particular, if the value is the symbol `quietly', the next unread
327 newsgroup will be selected without any confirmation, and if it is
328 `almost-quietly', the next group will be selected without any
329 confirmation if you are located on the last article in the group.
330 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
331 will go to the next group without confirmation."
332 :group 'gnus-summary-maneuvering
333 :type '(choice (const :tag "off" nil)
335 (const almost-quietly)
336 (const slightly-quietly)
337 (sexp :menu-tag "on" t)))
339 (defcustom gnus-auto-select-same nil
340 "*If non-nil, select the next article with the same subject.
341 If there are no more articles with the same subject, go to
342 the first unread article."
343 :group 'gnus-summary-maneuvering
346 (defcustom gnus-summary-check-current nil
347 "*If non-nil, consider the current article when moving.
348 The \"unread\" movement commands will stay on the same line if the
349 current article is unread."
350 :group 'gnus-summary-maneuvering
353 (defcustom gnus-auto-center-summary t
354 "*If non-nil, always center the current summary buffer.
355 In particular, if `vertical' do only vertical recentering. If non-nil
356 and non-`vertical', do both horizontal and vertical recentering."
357 :group 'gnus-summary-maneuvering
358 :type '(choice (const :tag "none" nil)
360 (integer :tag "height")
361 (sexp :menu-tag "both" t)))
363 (defvar gnus-auto-center-group t
364 "*If non-nil, always center the group buffer.")
366 (defcustom gnus-show-all-headers nil
367 "*If non-nil, don't hide any headers."
368 :group 'gnus-article-hiding
369 :group 'gnus-article-headers
372 (defcustom gnus-summary-ignore-duplicates nil
373 "*If non-nil, ignore articles with identical Message-ID headers."
377 (defcustom gnus-single-article-buffer t
378 "*If non-nil, display all articles in the same buffer.
379 If nil, each group will get its own article buffer."
380 :group 'gnus-article-various
383 (defcustom gnus-break-pages t
384 "*If non-nil, do page breaking on articles.
385 The page delimiter is specified by the `gnus-page-delimiter'
387 :group 'gnus-article-various
390 (defcustom gnus-move-split-methods nil
391 "*Variable used to suggest where articles are to be moved to.
392 It uses the same syntax as the `gnus-split-methods' variable.
393 However, whereas `gnus-split-methods' specifies file names as targets,
394 this variable specifies group names."
395 :group 'gnus-summary-mail
396 :type '(repeat (choice (list :value (fun) function)
397 (cons :value ("" "") regexp (repeat string))
400 (defcustom gnus-unread-mark ? ;Whitespace
401 "*Mark used for unread articles."
402 :group 'gnus-summary-marks
405 (defcustom gnus-ticked-mark ?!
406 "*Mark used for ticked articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-dormant-mark ??
411 "*Mark used for dormant articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-del-mark ?r
416 "*Mark used for del'd articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-read-mark ?R
421 "*Mark used for read articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-expirable-mark ?E
426 "*Mark used for expirable articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-killed-mark ?K
431 "*Mark used for killed articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-spam-mark ?$
436 "*Mark used for spam articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-souped-mark ?F
441 "*Mark used for souped articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-kill-file-mark ?X
446 "*Mark used for articles killed by kill files."
447 :group 'gnus-summary-marks
450 (defcustom gnus-low-score-mark ?Y
451 "*Mark used for articles with a low score."
452 :group 'gnus-summary-marks
455 (defcustom gnus-catchup-mark ?C
456 "*Mark used for articles that are caught up."
457 :group 'gnus-summary-marks
460 (defcustom gnus-replied-mark ?A
461 "*Mark used for articles that have been replied to."
462 :group 'gnus-summary-marks
465 (defcustom gnus-forwarded-mark ?F
466 "*Mark used for articles that have been forwarded."
467 :group 'gnus-summary-marks
470 (defcustom gnus-recent-mark ?N
471 "*Mark used for articles that are recent."
472 :group 'gnus-summary-marks
475 (defcustom gnus-cached-mark ?*
476 "*Mark used for articles that are in the cache."
477 :group 'gnus-summary-marks
480 (defcustom gnus-saved-mark ?S
481 "*Mark used for articles that have been saved."
482 :group 'gnus-summary-marks
485 (defcustom gnus-unseen-mark ?.
486 "*Mark used for articles that haven't been seen."
487 :group 'gnus-summary-marks
490 (defcustom gnus-no-mark ? ;Whitespace
491 "*Mark used for articles that have no other secondary mark."
492 :group 'gnus-summary-marks
495 (defcustom gnus-ancient-mark ?O
496 "*Mark used for ancient articles."
497 :group 'gnus-summary-marks
500 (defcustom gnus-sparse-mark ?Q
501 "*Mark used for sparsely reffed articles."
502 :group 'gnus-summary-marks
505 (defcustom gnus-canceled-mark ?G
506 "*Mark used for canceled articles."
507 :group 'gnus-summary-marks
510 (defcustom gnus-duplicate-mark ?M
511 "*Mark used for duplicate articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-undownloaded-mark ?-
516 "*Mark used for articles that weren't downloaded."
517 :group 'gnus-summary-marks
520 (defcustom gnus-downloaded-mark ?+
521 "*Mark used for articles that were downloaded."
522 :group 'gnus-summary-marks
525 (defcustom gnus-downloadable-mark ?%
526 "*Mark used for articles that are to be downloaded."
527 :group 'gnus-summary-marks
530 (defcustom gnus-unsendable-mark ?=
531 "*Mark used for articles that won't be sent."
532 :group 'gnus-summary-marks
535 (defcustom gnus-score-over-mark ?+
536 "*Score mark used for articles with high scores."
537 :group 'gnus-summary-marks
540 (defcustom gnus-score-below-mark ?-
541 "*Score mark used for articles with low scores."
542 :group 'gnus-summary-marks
545 (defcustom gnus-empty-thread-mark ? ;Whitespace
546 "*There is no thread under the article."
547 :group 'gnus-summary-marks
550 (defcustom gnus-not-empty-thread-mark ?=
551 "*There is a thread under the article."
552 :group 'gnus-summary-marks
555 (defcustom gnus-view-pseudo-asynchronously nil
556 "*If non-nil, Gnus will view pseudo-articles asynchronously."
557 :group 'gnus-extract-view
560 (defcustom gnus-auto-expirable-marks
561 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
562 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
563 gnus-souped-mark gnus-duplicate-mark)
564 "*The list of marks converted into expiration if a group is auto-expirable."
567 :type '(repeat character))
569 (defcustom gnus-inhibit-user-auto-expire t
570 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
575 (defcustom gnus-view-pseudos nil
576 "*If `automatic', pseudo-articles will be viewed automatically.
577 If `not-confirm', pseudos will be viewed automatically, and the user
578 will not be asked to confirm the command."
579 :group 'gnus-extract-view
580 :type '(choice (const :tag "off" nil)
582 (const not-confirm)))
584 (defcustom gnus-view-pseudos-separately t
585 "*If non-nil, one pseudo-article will be created for each file to be viewed.
586 If nil, all files that use the same viewing command will be given as a
587 list of parameters to that command."
588 :group 'gnus-extract-view
591 (defcustom gnus-insert-pseudo-articles t
592 "*If non-nil, insert pseudo-articles when decoding articles."
593 :group 'gnus-extract-view
596 (defcustom gnus-summary-dummy-line-format
598 "*The format specification for the dummy roots in the summary buffer.
599 It works along the same lines as a normal formatting string,
600 with some simple extensions.
604 General format specifiers can also be used.
605 See `(gnus)Formatting Variables'."
606 :link '(custom-manual "(gnus)Formatting Variables")
607 :group 'gnus-threading
610 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
611 "*The format specification for the summary mode line.
612 It works along the same lines as a normal formatting string,
613 with some simple extensions:
616 %p Unprefixed group name
617 %A Current article number
618 %z Current article score
620 %U Number of unread articles in the group
621 %e Number of unselected articles in the group
622 %Z A string with unread/unselected article counts
623 %g Shortish group name
624 %S Subject of the current article
626 %s Current score file name
627 %d Number of dormant articles
628 %r Number of articles that have been marked as read in this session
629 %E Number of articles expunged by the score files"
630 :group 'gnus-summary-format
633 (defcustom gnus-list-identifiers nil
634 "Regexp that matches list identifiers to be removed from subject.
635 This can also be a list of regexps."
637 :group 'gnus-summary-format
638 :group 'gnus-article-hiding
639 :type '(choice (const :tag "none" nil)
641 (repeat :value (".*") regexp)))
643 (defcustom gnus-summary-mark-below 0
644 "*Mark all articles with a score below this variable as read.
645 This variable is local to each summary buffer and usually set by the
647 :group 'gnus-score-default
650 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
651 "*List of functions used for sorting articles in the summary buffer.
653 Each function takes two articles and returns non-nil if the first
654 article should be sorted before the other. If you use more than one
655 function, the primary sort function should be the last. You should
656 probably always include `gnus-article-sort-by-number' in the list of
657 sorting functions -- preferably first. Also note that sorting by date
658 is often much slower than sorting by number, and the sorting order is
659 very similar. (Sorting by date means sorting by the time the message
660 was sent, sorting by number means sorting by arrival time.)
662 Ready-made functions include `gnus-article-sort-by-number',
663 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
664 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
665 and `gnus-article-sort-by-score'.
667 When threading is turned on, the variable `gnus-thread-sort-functions'
668 controls how articles are sorted."
669 :group 'gnus-summary-sort
670 :type '(repeat (choice (function-item gnus-article-sort-by-number)
671 (function-item gnus-article-sort-by-author)
672 (function-item gnus-article-sort-by-subject)
673 (function-item gnus-article-sort-by-date)
674 (function-item gnus-article-sort-by-score)
675 (function-item gnus-article-sort-by-random)
676 (function :tag "other"))))
678 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
679 "*List of functions used for sorting threads in the summary buffer.
680 By default, threads are sorted by article number.
682 Each function takes two threads and returns non-nil if the first
683 thread should be sorted before the other. If you use more than one
684 function, the primary sort function should be the last. You should
685 probably always include `gnus-thread-sort-by-number' in the list of
686 sorting functions -- preferably first. Also note that sorting by date
687 is often much slower than sorting by number, and the sorting order is
688 very similar. (Sorting by date means sorting by the time the message
689 was sent, sorting by number means sorting by arrival time.)
691 Ready-made functions include `gnus-thread-sort-by-number',
692 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
693 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
694 `gnus-thread-sort-by-most-recent-number',
695 `gnus-thread-sort-by-most-recent-date',
696 `gnus-thread-sort-by-random', and
697 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
699 When threading is turned off, the variable
700 `gnus-article-sort-functions' controls how articles are sorted."
701 :group 'gnus-summary-sort
702 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
703 (function-item gnus-thread-sort-by-author)
704 (function-item gnus-thread-sort-by-subject)
705 (function-item gnus-thread-sort-by-date)
706 (function-item gnus-thread-sort-by-score)
707 (function-item gnus-thread-sort-by-total-score)
708 (function-item gnus-thread-sort-by-random)
709 (function :tag "other"))))
711 (defcustom gnus-thread-score-function '+
712 "*Function used for calculating the total score of a thread.
714 The function is called with the scores of the article and each
715 subthread and should then return the score of the thread.
717 Some functions you can use are `+', `max', or `min'."
718 :group 'gnus-summary-sort
721 (defcustom gnus-summary-expunge-below nil
722 "All articles that have a score less than this variable will be expunged.
723 This variable is local to the summary buffers."
724 :group 'gnus-score-default
725 :type '(choice (const :tag "off" nil)
728 (defcustom gnus-thread-expunge-below nil
729 "All threads that have a total score less than this variable will be expunged.
730 See `gnus-thread-score-function' for en explanation of what a
733 This variable is local to the summary buffers."
734 :group 'gnus-threading
735 :group 'gnus-score-default
736 :type '(choice (const :tag "off" nil)
739 (defcustom gnus-summary-mode-hook nil
740 "*A hook for Gnus summary mode.
741 This hook is run before any variables are set in the summary buffer."
742 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
743 :group 'gnus-summary-various
746 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
747 (when (featurep 'xemacs)
748 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
749 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
750 (add-hook 'gnus-summary-mode-hook
751 'gnus-xmas-switch-horizontal-scrollbar-off))
753 (defcustom gnus-summary-menu-hook nil
754 "*Hook run after the creation of the summary mode menu."
755 :group 'gnus-summary-visual
758 (defcustom gnus-summary-exit-hook nil
759 "*A hook called on exit from the summary buffer.
760 It will be called with point in the group buffer."
761 :group 'gnus-summary-exit
764 (defcustom gnus-summary-prepare-hook nil
765 "*A hook called after the summary buffer has been generated.
766 If you want to modify the summary buffer, you can use this hook."
767 :group 'gnus-summary-various
770 (defcustom gnus-summary-prepared-hook nil
771 "*A hook called as the last thing after the summary buffer has been generated."
772 :group 'gnus-summary-various
775 (defcustom gnus-summary-generate-hook nil
776 "*A hook run just before generating the summary buffer.
777 This hook is commonly used to customize threading variables and the
779 :group 'gnus-summary-various
782 (defcustom gnus-select-group-hook nil
783 "*A hook called when a newsgroup is selected.
785 If you'd like to simplify subjects like the
786 `gnus-summary-next-same-subject' command does, you can use the
789 (add-hook gnus-select-group-hook
791 (mapcar (lambda (header)
792 (mail-header-set-subject
794 (gnus-simplify-subject
795 (mail-header-subject header) 're-only)))
796 gnus-newsgroup-headers)))"
797 :group 'gnus-group-select
800 (defcustom gnus-select-article-hook nil
801 "*A hook called when an article is selected."
802 :group 'gnus-summary-choose
803 :options '(gnus-agent-fetch-selected-article)
806 (defcustom gnus-visual-mark-article-hook
807 (list 'gnus-highlight-selected-summary)
808 "*Hook run after selecting an article in the summary buffer.
809 It is meant to be used for highlighting the article in some way. It
810 is not run if `gnus-visual' is nil."
811 :group 'gnus-summary-visual
814 (defcustom gnus-parse-headers-hook nil
815 "*A hook called before parsing the headers."
819 (defcustom gnus-exit-group-hook nil
820 "*A hook called when exiting summary mode.
821 This hook is not called from the non-updating exit commands like `Q'."
825 (defcustom gnus-summary-update-hook
826 (list 'gnus-summary-highlight-line)
827 "*A hook called when a summary line is changed.
828 The hook will not be called if `gnus-visual' is nil.
830 The default function `gnus-summary-highlight-line' will
831 highlight the line according to the `gnus-summary-highlight'
833 :group 'gnus-summary-visual
836 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
837 "*A hook called when an article is selected for the first time.
838 The hook is intended to mark an article as read (or unread)
839 automatically when it is selected."
840 :group 'gnus-summary-choose
843 (defcustom gnus-group-no-more-groups-hook nil
844 "*A hook run when returning to group mode having no more (unread) groups."
845 :group 'gnus-group-select
848 (defcustom gnus-ps-print-hook nil
849 "*A hook run before ps-printing something from Gnus."
853 (defcustom gnus-summary-article-move-hook nil
854 "*A hook called after an article is moved, copied, respooled, or crossposted."
858 (defcustom gnus-summary-article-delete-hook nil
859 "*A hook called after an article is deleted."
863 (defcustom gnus-summary-article-expire-hook nil
864 "*A hook called after an article is expired."
868 (defcustom gnus-summary-display-arrow
869 (and (fboundp 'display-graphic-p)
871 "*If non-nil, display an arrow highlighting the current article."
876 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
877 "Face used for highlighting the current article in the summary buffer."
878 :group 'gnus-summary-visual
881 (defvar gnus-tmp-downloaded nil)
883 (defcustom gnus-summary-highlight
884 '(((eq mark gnus-canceled-mark)
885 . gnus-summary-cancelled-face)
886 ((and uncached (> score default-high))
887 . gnus-summary-high-undownloaded-face)
888 ((and uncached (< score default-low))
889 . gnus-summary-low-undownloaded-face)
891 . gnus-summary-normal-undownloaded-face)
892 ((and (> score default-high)
893 (or (eq mark gnus-dormant-mark)
894 (eq mark gnus-ticked-mark)))
895 . gnus-summary-high-ticked-face)
896 ((and (< score default-low)
897 (or (eq mark gnus-dormant-mark)
898 (eq mark gnus-ticked-mark)))
899 . gnus-summary-low-ticked-face)
900 ((or (eq mark gnus-dormant-mark)
901 (eq mark gnus-ticked-mark))
902 . gnus-summary-normal-ticked-face)
903 ((and (> score default-high) (eq mark gnus-ancient-mark))
904 . gnus-summary-high-ancient-face)
905 ((and (< score default-low) (eq mark gnus-ancient-mark))
906 . gnus-summary-low-ancient-face)
907 ((eq mark gnus-ancient-mark)
908 . gnus-summary-normal-ancient-face)
909 ((and (> score default-high) (eq mark gnus-unread-mark))
910 . gnus-summary-high-unread-face)
911 ((and (< score default-low) (eq mark gnus-unread-mark))
912 . gnus-summary-low-unread-face)
913 ((eq mark gnus-unread-mark)
914 . gnus-summary-normal-unread-face)
915 ((> score default-high)
916 . gnus-summary-high-read-face)
917 ((< score default-low)
918 . gnus-summary-low-read-face)
920 . gnus-summary-normal-read-face))
921 "*Controls the highlighting of summary buffer lines.
923 A list of (FORM . FACE) pairs. When deciding how a a particular
924 summary line should be displayed, each form is evaluated. The content
925 of the face field after the first true form is used. You can change
926 how those summary lines are displayed, by editing the face field.
928 You can use the following variables in the FORM field.
930 score: The article's score
931 default: The default article score.
932 default-high: The default score for high scored articles.
933 default-low: The default score for low scored articles.
934 below: The score below which articles are automatically marked as read.
935 mark: The articles mark."
936 :group 'gnus-summary-visual
937 :type '(repeat (cons (sexp :tag "Form" nil)
940 (defcustom gnus-alter-header-function nil
941 "Function called to allow alteration of article header structures.
942 The function is called with one parameter, the article header vector,
943 which it may alter in any way."
944 :type '(choice (const :tag "None" nil)
946 :group 'gnus-summary)
948 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
949 "Variable that says which function should be used to decode a string with encoded words.")
951 (defcustom gnus-extra-headers '(To Newsgroups)
952 "*Extra headers to parse."
955 :type '(repeat symbol))
957 (defcustom gnus-ignored-from-addresses
958 (and user-mail-address (regexp-quote user-mail-address))
959 "*Regexp of From headers that may be suppressed in favor of To headers."
964 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
965 "List of charsets that should be ignored.
966 When these charsets are used in the \"charset\" parameter, the
967 default charset will be used instead."
969 :type '(repeat symbol)
970 :group 'gnus-charset)
972 (gnus-define-group-parameter
976 "Return the ignored charsets of GROUP."
977 :variable gnus-group-ignored-charsets-alist
979 '(("alt\\.chinese\\.text" iso-8859-1))
981 "Alist of regexps (to match group names) and charsets that should be ignored.
982 When these charsets are used in the \"charset\" parameter, the
983 default charset will be used instead."
984 :variable-group gnus-charset
985 :variable-type '(repeat (cons (regexp :tag "Group")
987 :parameter-type '(choice :tag "Ignored charsets"
990 :parameter-document "\
991 List of charsets that should be ignored.
993 When these charsets are used in the \"charset\" parameter, the
994 default charset will be used instead.")
996 (defcustom gnus-group-highlight-words-alist nil
997 "Alist of group regexps and highlight regexps.
998 This variable uses the same syntax as `gnus-emphasis-alist'."
1000 :type '(repeat (cons (regexp :tag "Group")
1001 (repeat (list (regexp :tag "Highlight regexp")
1002 (number :tag "Group for entire word" 0)
1003 (number :tag "Group for displayed part" 0)
1005 gnus-emphasis-highlight-words)))))
1006 :group 'gnus-summary-visual)
1008 (defcustom gnus-summary-show-article-charset-alist
1010 "Alist of number and charset.
1011 The article will be shown with the charset corresponding to the
1013 For example: ((1 . cn-gb-2312) (2 . big5))."
1015 :type '(repeat (cons (number :tag "Argument" 1)
1016 (symbol :tag "Charset")))
1017 :group 'gnus-charset)
1019 (defcustom gnus-preserve-marks t
1020 "Whether marks are preserved when moving, copying and respooling messages."
1023 :group 'gnus-summary-marks)
1025 (defcustom gnus-alter-articles-to-read-function nil
1026 "Function to be called to alter the list of articles to be selected."
1027 :type '(choice (const nil) function)
1028 :group 'gnus-summary)
1030 (defcustom gnus-orphan-score nil
1031 "*All orphans get this score added. Set in the score file."
1032 :group 'gnus-score-default
1033 :type '(choice (const nil)
1036 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1037 "*A regexp to match MIME parts when saving multiple parts of a
1038 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1039 This regexp will be used by default when prompting the user for which
1040 type of files to save."
1041 :group 'gnus-summary
1044 (defcustom gnus-read-all-available-headers nil
1045 "Whether Gnus should parse all headers made available to it.
1046 This is mostly relevant for slow backends where the user may
1047 wish to widen the summary buffer to include all headers
1048 that were fetched. Say, for nnultimate groups."
1049 :group 'gnus-summary
1050 :type '(choice boolean regexp))
1052 (defcustom gnus-summary-muttprint-program "muttprint"
1053 "Command (and optional arguments) used to run Muttprint."
1055 :group 'gnus-summary
1058 (defcustom gnus-article-loose-mime nil
1059 "If non-nil, don't require MIME-Version header.
1060 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1061 supply the MIME-Version header or deliberately strip it From the mail.
1062 Set it to non-nil, Gnus will treat some articles as MIME even if
1063 the MIME-Version header is missed."
1066 :group 'gnus-article)
1068 (defcustom gnus-article-emulate-mime t
1069 "If non-nil, use MIME emulation for uuencode and the like.
1070 This means that Gnus will search message bodies for text that look
1071 like uuencoded bits, yEncoded bits, and so on, and present that using
1072 the normal Gnus MIME machinery."
1074 :group 'gnus-article)
1076 ;;; Internal variables
1078 (defvar gnus-summary-display-cache nil)
1079 (defvar gnus-article-mime-handles nil)
1080 (defvar gnus-article-decoded-p nil)
1081 (defvar gnus-article-charset nil)
1082 (defvar gnus-article-ignored-charsets nil)
1083 (defvar gnus-scores-exclude-files nil)
1084 (defvar gnus-page-broken nil)
1086 (defvar gnus-original-article nil)
1087 (defvar gnus-article-internal-prepare-hook nil)
1088 (defvar gnus-newsgroup-process-stack nil)
1090 (defvar gnus-thread-indent-array nil)
1091 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1092 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1093 "Function called to sort the articles within a thread after it has been gathered together.")
1095 (defvar gnus-summary-save-parts-type-history nil)
1096 (defvar gnus-summary-save-parts-last-directory nil)
1098 ;; Avoid highlighting in kill files.
1099 (defvar gnus-summary-inhibit-highlight nil)
1100 (defvar gnus-newsgroup-selected-overlay nil)
1101 (defvar gnus-inhibit-limiting nil)
1102 (defvar gnus-newsgroup-adaptive-score-file nil)
1103 (defvar gnus-current-score-file nil)
1104 (defvar gnus-current-move-group nil)
1105 (defvar gnus-current-copy-group nil)
1106 (defvar gnus-current-crosspost-group nil)
1107 (defvar gnus-newsgroup-display nil)
1109 (defvar gnus-newsgroup-dependencies nil)
1110 (defvar gnus-newsgroup-adaptive nil)
1111 (defvar gnus-summary-display-article-function nil)
1112 (defvar gnus-summary-highlight-line-function nil
1113 "Function called after highlighting a summary line.")
1115 (defvar gnus-summary-line-format-alist
1116 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1117 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1118 (?s gnus-tmp-subject-or-nil ?s)
1119 (?n gnus-tmp-name ?s)
1120 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1122 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1124 (?F gnus-tmp-from ?s)
1125 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1126 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1127 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1128 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1129 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1130 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1131 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1132 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1133 (?L gnus-tmp-lines ?s)
1134 (?O gnus-tmp-downloaded ?c)
1135 (?I gnus-tmp-indentation ?s)
1136 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1137 (?R gnus-tmp-replied ?c)
1138 (?\[ gnus-tmp-opening-bracket ?c)
1139 (?\] gnus-tmp-closing-bracket ?c)
1140 (?\> (make-string gnus-tmp-level ? ) ?s)
1141 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1142 (?i gnus-tmp-score ?d)
1143 (?z gnus-tmp-score-char ?c)
1144 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1145 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1146 (?U gnus-tmp-unread ?c)
1147 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1149 (?t (gnus-summary-number-of-articles-in-thread
1150 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1152 (?e (gnus-summary-number-of-articles-in-thread
1153 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1155 (?u gnus-tmp-user-defined ?s)
1156 (?P (gnus-pick-line-number) ?d)
1157 (?B gnus-tmp-thread-tree-header-string ?s)
1158 (user-date (gnus-user-date
1159 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1160 "An alist of format specifications that can appear in summary lines.
1161 These are paired with what variables they correspond with, along with
1162 the type of the variable (string, integer, character, etc).")
1164 (defvar gnus-summary-dummy-line-format-alist
1165 `((?S gnus-tmp-subject ?s)
1166 (?N gnus-tmp-number ?d)
1167 (?u gnus-tmp-user-defined ?s)))
1169 (defvar gnus-summary-mode-line-format-alist
1170 `((?G gnus-tmp-group-name ?s)
1171 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1172 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1173 (?A gnus-tmp-article-number ?d)
1174 (?Z gnus-tmp-unread-and-unselected ?s)
1175 (?V gnus-version ?s)
1176 (?U gnus-tmp-unread-and-unticked ?d)
1177 (?S gnus-tmp-subject ?s)
1178 (?e gnus-tmp-unselected ?d)
1179 (?u gnus-tmp-user-defined ?s)
1180 (?d (length gnus-newsgroup-dormant) ?d)
1181 (?t (length gnus-newsgroup-marked) ?d)
1182 (?h (length gnus-newsgroup-spam-marked) ?d)
1183 (?r (length gnus-newsgroup-reads) ?d)
1184 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1185 (?E gnus-newsgroup-expunged-tally ?d)
1186 (?s (gnus-current-score-file-nondirectory) ?s)))
1188 (defvar gnus-last-search-regexp nil
1189 "Default regexp for article search command.")
1191 (defvar gnus-last-shell-command nil
1192 "Default shell command on article.")
1194 (defvar gnus-newsgroup-agentized nil
1195 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1196 (defvar gnus-newsgroup-begin nil)
1197 (defvar gnus-newsgroup-end nil)
1198 (defvar gnus-newsgroup-last-rmail nil)
1199 (defvar gnus-newsgroup-last-mail nil)
1200 (defvar gnus-newsgroup-last-folder nil)
1201 (defvar gnus-newsgroup-last-file nil)
1202 (defvar gnus-newsgroup-auto-expire nil)
1203 (defvar gnus-newsgroup-active nil)
1205 (defvar gnus-newsgroup-data nil)
1206 (defvar gnus-newsgroup-data-reverse nil)
1207 (defvar gnus-newsgroup-limit nil)
1208 (defvar gnus-newsgroup-limits nil)
1210 (defvar gnus-newsgroup-unreads nil
1211 "Sorted list of unread articles in the current newsgroup.")
1213 (defvar gnus-newsgroup-unselected nil
1214 "Sorted list of unselected unread articles in the current newsgroup.")
1216 (defvar gnus-newsgroup-reads nil
1217 "Alist of read articles and article marks in the current newsgroup.")
1219 (defvar gnus-newsgroup-expunged-tally nil)
1221 (defvar gnus-newsgroup-marked nil
1222 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1224 (defvar gnus-newsgroup-spam-marked nil
1225 "List of ranges of articles that have been marked as spam.")
1227 (defvar gnus-newsgroup-killed nil
1228 "List of ranges of articles that have been through the scoring process.")
1230 (defvar gnus-newsgroup-cached nil
1231 "Sorted list of articles that come from the article cache.")
1233 (defvar gnus-newsgroup-saved nil
1234 "List of articles that have been saved.")
1236 (defvar gnus-newsgroup-kill-headers nil)
1238 (defvar gnus-newsgroup-replied nil
1239 "List of articles that have been replied to in the current newsgroup.")
1241 (defvar gnus-newsgroup-forwarded nil
1242 "List of articles that have been forwarded in the current newsgroup.")
1244 (defvar gnus-newsgroup-recent nil
1245 "List of articles that have are recent in the current newsgroup.")
1247 (defvar gnus-newsgroup-expirable nil
1248 "Sorted list of articles in the current newsgroup that can be expired.")
1250 (defvar gnus-newsgroup-processable nil
1251 "List of articles in the current newsgroup that can be processed.")
1253 (defvar gnus-newsgroup-downloadable nil
1254 "Sorted list of articles in the current newsgroup that can be processed.")
1256 (defvar gnus-newsgroup-unfetched nil
1257 "Sorted list of articles in the current newsgroup whose headers have not been fetched into the agent.")
1259 (defvar gnus-newsgroup-undownloaded nil
1260 "List of articles in the current newsgroup that haven't been downloaded.")
1262 (defvar gnus-newsgroup-unsendable nil
1263 "List of articles in the current newsgroup that won't be sent.")
1265 (defvar gnus-newsgroup-bookmarks nil
1266 "List of articles in the current newsgroup that have bookmarks.")
1268 (defvar gnus-newsgroup-dormant nil
1269 "Sorted list of dormant articles in the current newsgroup.")
1271 (defvar gnus-newsgroup-unseen nil
1272 "List of unseen articles in the current newsgroup.")
1274 (defvar gnus-newsgroup-seen nil
1275 "Range of seen articles in the current newsgroup.")
1277 (defvar gnus-newsgroup-articles nil
1278 "List of articles in the current newsgroup.")
1280 (defvar gnus-newsgroup-scored nil
1281 "List of scored articles in the current newsgroup.")
1283 (defvar gnus-newsgroup-headers nil
1284 "List of article headers in the current newsgroup.")
1286 (defvar gnus-newsgroup-threads nil)
1288 (defvar gnus-newsgroup-prepared nil
1289 "Whether the current group has been prepared properly.")
1291 (defvar gnus-newsgroup-ancient nil
1292 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1294 (defvar gnus-newsgroup-sparse nil)
1296 (defvar gnus-current-article nil)
1297 (defvar gnus-article-current nil)
1298 (defvar gnus-current-headers nil)
1299 (defvar gnus-have-all-headers nil)
1300 (defvar gnus-last-article nil)
1301 (defvar gnus-newsgroup-history nil)
1302 (defvar gnus-newsgroup-charset nil)
1303 (defvar gnus-newsgroup-ephemeral-charset nil)
1304 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1306 (defvar gnus-article-before-search nil)
1308 (defconst gnus-summary-local-variables
1309 '(gnus-newsgroup-name
1310 gnus-newsgroup-begin gnus-newsgroup-end
1311 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1312 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1313 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1314 gnus-newsgroup-unselected gnus-newsgroup-marked
1315 gnus-newsgroup-spam-marked
1316 gnus-newsgroup-reads gnus-newsgroup-saved
1317 gnus-newsgroup-replied gnus-newsgroup-forwarded
1318 gnus-newsgroup-recent
1319 gnus-newsgroup-expirable
1320 gnus-newsgroup-processable gnus-newsgroup-killed
1321 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1322 gnus-newsgroup-unfetched
1323 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1324 gnus-newsgroup-seen gnus-newsgroup-articles
1325 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1326 gnus-newsgroup-headers gnus-newsgroup-threads
1327 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1328 gnus-current-article gnus-current-headers gnus-have-all-headers
1329 gnus-last-article gnus-article-internal-prepare-hook
1330 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1331 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1332 gnus-thread-expunge-below
1333 gnus-score-alist gnus-current-score-file
1334 (gnus-summary-expunge-below . global)
1335 (gnus-summary-mark-below . global)
1336 (gnus-orphan-score . global)
1337 gnus-newsgroup-active gnus-scores-exclude-files
1338 gnus-newsgroup-history gnus-newsgroup-ancient
1339 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1340 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1341 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1342 (gnus-newsgroup-expunged-tally . 0)
1343 gnus-cache-removable-articles gnus-newsgroup-cached
1344 gnus-newsgroup-data gnus-newsgroup-data-reverse
1345 gnus-newsgroup-limit gnus-newsgroup-limits
1346 gnus-newsgroup-charset gnus-newsgroup-display)
1347 "Variables that are buffer-local to the summary buffers.")
1349 (defvar gnus-newsgroup-variables nil
1350 "A list of variables that have separate values in different newsgroups.
1351 A list of newsgroup (summary buffer) local variables, or cons of
1352 variables and their default values (when the default values are not
1353 nil), that should be made global while the summary buffer is active.
1354 These variables can be used to set variables in the group parameters
1355 while still allowing them to affect operations done in other
1356 buffers. For example:
1358 \(setq gnus-newsgroup-variables
1359 '(message-use-followup-to
1360 (gnus-visible-headers .
1361 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1364 ;; Byte-compiler warning.
1365 ;(eval-when-compile (defvar gnus-article-mode-map))
1367 (let ((features (cons 'gnus-sum features)))
1369 (require 'gnus-agent)
1370 (require 'gnus-art)))
1374 (defvar gnus-decode-encoded-word-methods
1375 '(mail-decode-encoded-word-string)
1376 "List of methods used to decode encoded words.
1378 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1379 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1380 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1381 whose names match REGEXP.
1384 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1385 mail-decode-encoded-word-string
1386 (\"chinese\" . rfc1843-decode-string))")
1388 (defvar gnus-decode-encoded-word-methods-cache nil)
1390 (defun gnus-multi-decode-encoded-word-string (string)
1391 "Apply the functions from `gnus-encoded-word-methods' that match."
1392 (unless (and gnus-decode-encoded-word-methods-cache
1393 (eq gnus-newsgroup-name
1394 (car gnus-decode-encoded-word-methods-cache)))
1395 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1398 (nconc gnus-decode-encoded-word-methods-cache (list x))
1399 (if (and gnus-newsgroup-name
1400 (string-match (car x) gnus-newsgroup-name))
1401 (nconc gnus-decode-encoded-word-methods-cache
1403 gnus-decode-encoded-word-methods))
1404 (let ((xlist gnus-decode-encoded-word-methods-cache))
1407 (setq string (funcall (pop xlist) string))))
1410 ;; Subject simplification.
1412 (defun gnus-simplify-whitespace (str)
1413 "Remove excessive whitespace from STR."
1415 (while (string-match "[ \t][ \t]+" str)
1416 (setq str (concat (substring str 0 (match-beginning 0))
1418 (substring str (match-end 0)))))
1420 (when (string-match "^[ \t]+" str)
1421 (setq str (substring str (match-end 0))))
1423 (when (string-match "[ \t]+$" str)
1424 (setq str (substring str 0 (match-beginning 0))))
1427 (defun gnus-simplify-all-whitespace (str)
1428 "Remove all whitespace from STR."
1429 (while (string-match "[ \t\n]+" str)
1430 (setq str (replace-match "" nil nil str)))
1433 (defsubst gnus-simplify-subject-re (subject)
1434 "Remove \"Re:\" from subject lines."
1435 (if (string-match message-subject-re-regexp subject)
1436 (substring subject (match-end 0))
1439 (defun gnus-simplify-subject (subject &optional re-only)
1440 "Remove `Re:' and words in parentheses.
1441 If RE-ONLY is non-nil, strip leading `Re:'s only."
1442 (let ((case-fold-search t)) ;Ignore case.
1443 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1444 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1445 (setq subject (substring subject (match-end 0))))
1446 ;; Remove uninteresting prefixes.
1447 (when (and (not re-only)
1448 gnus-simplify-ignored-prefixes
1449 (string-match gnus-simplify-ignored-prefixes subject))
1450 (setq subject (substring subject (match-end 0))))
1451 ;; Remove words in parentheses from end.
1453 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1454 (setq subject (substring subject 0 (match-beginning 0)))))
1455 ;; Return subject string.
1458 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1460 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1461 (goto-char (point-min))
1462 (while (re-search-forward regexp nil t)
1463 (replace-match (or newtext ""))))
1465 (defun gnus-simplify-buffer-fuzzy ()
1466 "Simplify string in the buffer fuzzily.
1467 The string in the accessible portion of the current buffer is simplified.
1468 It is assumed to be a single-line subject.
1469 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1470 matter is removed. Additional things can be deleted by setting
1471 `gnus-simplify-subject-fuzzy-regexp'."
1472 (let ((case-fold-search t)
1474 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1476 (while (not (eq modified-tick (buffer-modified-tick)))
1477 (setq modified-tick (buffer-modified-tick))
1479 ((listp gnus-simplify-subject-fuzzy-regexp)
1480 (mapcar 'gnus-simplify-buffer-fuzzy-step
1481 gnus-simplify-subject-fuzzy-regexp))
1482 (gnus-simplify-subject-fuzzy-regexp
1483 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1484 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1485 (gnus-simplify-buffer-fuzzy-step
1486 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1487 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1489 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1490 (gnus-simplify-buffer-fuzzy-step " +" " ")
1491 (gnus-simplify-buffer-fuzzy-step " $")
1492 (gnus-simplify-buffer-fuzzy-step "^ +")))
1494 (defun gnus-simplify-subject-fuzzy (subject)
1495 "Simplify a subject string fuzzily.
1496 See `gnus-simplify-buffer-fuzzy' for details."
1498 (gnus-set-work-buffer)
1499 (let ((case-fold-search t))
1500 ;; Remove uninteresting prefixes.
1501 (when (and gnus-simplify-ignored-prefixes
1502 (string-match gnus-simplify-ignored-prefixes subject))
1503 (setq subject (substring subject (match-end 0))))
1505 (inline (gnus-simplify-buffer-fuzzy))
1508 (defsubst gnus-simplify-subject-fully (subject)
1509 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1511 (gnus-simplify-subject-functions
1512 (gnus-map-function gnus-simplify-subject-functions subject))
1513 ((null gnus-summary-gather-subject-limit)
1514 (gnus-simplify-subject-re subject))
1515 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1516 (gnus-simplify-subject-fuzzy subject))
1517 ((numberp gnus-summary-gather-subject-limit)
1518 (gnus-limit-string (gnus-simplify-subject-re subject)
1519 gnus-summary-gather-subject-limit))
1523 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1524 "Check whether two subjects are equal.
1525 If optional argument SIMPLE-FIRST is t, first argument is already
1528 ((null simple-first)
1529 (equal (gnus-simplify-subject-fully s1)
1530 (gnus-simplify-subject-fully s2)))
1533 (gnus-simplify-subject-fully s2)))))
1535 (defun gnus-summary-bubble-group ()
1536 "Increase the score of the current group.
1537 This is a handy function to add to `gnus-summary-exit-hook' to
1538 increase the score of each group you read."
1539 (gnus-group-add-score gnus-newsgroup-name))
1543 ;;; Gnus summary mode
1546 (put 'gnus-summary-mode 'mode-class 'special)
1548 (defvar gnus-article-commands-menu)
1550 ;; Non-orthogonal keys
1552 (gnus-define-keys gnus-summary-mode-map
1553 " " gnus-summary-next-page
1554 "\177" gnus-summary-prev-page
1555 [delete] gnus-summary-prev-page
1556 [backspace] gnus-summary-prev-page
1557 "\r" gnus-summary-scroll-up
1558 "\M-\r" gnus-summary-scroll-down
1559 "n" gnus-summary-next-unread-article
1560 "p" gnus-summary-prev-unread-article
1561 "N" gnus-summary-next-article
1562 "P" gnus-summary-prev-article
1563 "\M-\C-n" gnus-summary-next-same-subject
1564 "\M-\C-p" gnus-summary-prev-same-subject
1565 "\M-n" gnus-summary-next-unread-subject
1566 "\M-p" gnus-summary-prev-unread-subject
1567 "." gnus-summary-first-unread-article
1568 "," gnus-summary-best-unread-article
1569 "\M-s" gnus-summary-search-article-forward
1570 "\M-r" gnus-summary-search-article-backward
1571 "<" gnus-summary-beginning-of-article
1572 ">" gnus-summary-end-of-article
1573 "j" gnus-summary-goto-article
1574 "^" gnus-summary-refer-parent-article
1575 "\M-^" gnus-summary-refer-article
1576 "u" gnus-summary-tick-article-forward
1577 "!" gnus-summary-tick-article-forward
1578 "U" gnus-summary-tick-article-backward
1579 "d" gnus-summary-mark-as-read-forward
1580 "D" gnus-summary-mark-as-read-backward
1581 "E" gnus-summary-mark-as-expirable
1582 "\M-u" gnus-summary-clear-mark-forward
1583 "\M-U" gnus-summary-clear-mark-backward
1584 "k" gnus-summary-kill-same-subject-and-select
1585 "\C-k" gnus-summary-kill-same-subject
1586 "\M-\C-k" gnus-summary-kill-thread
1587 "\M-\C-l" gnus-summary-lower-thread
1588 "e" gnus-summary-edit-article
1589 "#" gnus-summary-mark-as-processable
1590 "\M-#" gnus-summary-unmark-as-processable
1591 "\M-\C-t" gnus-summary-toggle-threads
1592 "\M-\C-s" gnus-summary-show-thread
1593 "\M-\C-h" gnus-summary-hide-thread
1594 "\M-\C-f" gnus-summary-next-thread
1595 "\M-\C-b" gnus-summary-prev-thread
1596 [(meta down)] gnus-summary-next-thread
1597 [(meta up)] gnus-summary-prev-thread
1598 "\M-\C-u" gnus-summary-up-thread
1599 "\M-\C-d" gnus-summary-down-thread
1600 "&" gnus-summary-execute-command
1601 "c" gnus-summary-catchup-and-exit
1602 "\C-w" gnus-summary-mark-region-as-read
1603 "\C-t" gnus-summary-toggle-truncation
1604 "?" gnus-summary-mark-as-dormant
1605 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1606 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1607 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1608 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1609 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1610 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1611 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1612 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1613 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1614 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1615 "=" gnus-summary-expand-window
1616 "\C-x\C-s" gnus-summary-reselect-current-group
1617 "\M-g" gnus-summary-rescan-group
1618 "w" gnus-summary-stop-page-breaking
1619 "\C-c\C-r" gnus-summary-caesar-message
1620 "f" gnus-summary-followup
1621 "F" gnus-summary-followup-with-original
1622 "C" gnus-summary-cancel-article
1623 "r" gnus-summary-reply
1624 "R" gnus-summary-reply-with-original
1625 "\C-c\C-f" gnus-summary-mail-forward
1626 "o" gnus-summary-save-article
1627 "\C-o" gnus-summary-save-article-mail
1628 "|" gnus-summary-pipe-output
1629 "\M-k" gnus-summary-edit-local-kill
1630 "\M-K" gnus-summary-edit-global-kill
1632 "\C-c\C-d" gnus-summary-describe-group
1633 "q" gnus-summary-exit
1634 "Q" gnus-summary-exit-no-update
1635 "\C-c\C-i" gnus-info-find-node
1636 gnus-mouse-2 gnus-mouse-pick-article
1637 "m" gnus-summary-mail-other-window
1638 "a" gnus-summary-post-news
1639 "i" gnus-summary-news-other-window
1640 "x" gnus-summary-limit-to-unread
1641 "s" gnus-summary-isearch-article
1642 "t" gnus-summary-toggle-header
1643 "g" gnus-summary-show-article
1644 "l" gnus-summary-goto-last-article
1645 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1646 "\C-d" gnus-summary-enter-digest-group
1647 "\M-\C-d" gnus-summary-read-document
1648 "\M-\C-e" gnus-summary-edit-parameters
1649 "\M-\C-a" gnus-summary-customize-parameters
1651 "*" gnus-cache-enter-article
1652 "\M-*" gnus-cache-remove-article
1653 "\M-&" gnus-summary-universal-argument
1654 "\C-l" gnus-recenter
1655 "I" gnus-summary-increase-score
1656 "L" gnus-summary-lower-score
1657 "\M-i" gnus-symbolic-argument
1658 "h" gnus-summary-select-article-buffer
1660 "b" gnus-article-view-part
1661 "\M-t" gnus-summary-toggle-display-buttonized
1663 "V" gnus-summary-score-map
1664 "X" gnus-uu-extract-map
1665 "S" gnus-summary-send-map)
1667 ;; Sort of orthogonal keymap
1668 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1669 "t" gnus-summary-tick-article-forward
1670 "!" gnus-summary-tick-article-forward
1671 "d" gnus-summary-mark-as-read-forward
1672 "r" gnus-summary-mark-as-read-forward
1673 "c" gnus-summary-clear-mark-forward
1674 " " gnus-summary-clear-mark-forward
1675 "e" gnus-summary-mark-as-expirable
1676 "x" gnus-summary-mark-as-expirable
1677 "?" gnus-summary-mark-as-dormant
1678 "b" gnus-summary-set-bookmark
1679 "B" gnus-summary-remove-bookmark
1680 "#" gnus-summary-mark-as-processable
1681 "\M-#" gnus-summary-unmark-as-processable
1682 "S" gnus-summary-limit-include-expunged
1683 "C" gnus-summary-catchup
1684 "H" gnus-summary-catchup-to-here
1685 "h" gnus-summary-catchup-from-here
1686 "\C-c" gnus-summary-catchup-all
1687 "k" gnus-summary-kill-same-subject-and-select
1688 "K" gnus-summary-kill-same-subject
1689 "P" gnus-uu-mark-map)
1691 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1692 "c" gnus-summary-clear-above
1693 "u" gnus-summary-tick-above
1694 "m" gnus-summary-mark-above
1695 "k" gnus-summary-kill-below)
1697 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1698 "/" gnus-summary-limit-to-subject
1699 "n" gnus-summary-limit-to-articles
1700 "w" gnus-summary-pop-limit
1701 "s" gnus-summary-limit-to-subject
1702 "a" gnus-summary-limit-to-author
1703 "u" gnus-summary-limit-to-unread
1704 "m" gnus-summary-limit-to-marks
1705 "M" gnus-summary-limit-exclude-marks
1706 "v" gnus-summary-limit-to-score
1707 "*" gnus-summary-limit-include-cached
1708 "D" gnus-summary-limit-include-dormant
1709 "T" gnus-summary-limit-include-thread
1710 "d" gnus-summary-limit-exclude-dormant
1711 "t" gnus-summary-limit-to-age
1712 "." gnus-summary-limit-to-unseen
1713 "x" gnus-summary-limit-to-extra
1714 "p" gnus-summary-limit-to-display-predicate
1715 "E" gnus-summary-limit-include-expunged
1716 "c" gnus-summary-limit-exclude-childless-dormant
1717 "C" gnus-summary-limit-mark-excluded-as-read
1718 "o" gnus-summary-insert-old-articles
1719 "N" gnus-summary-insert-new-articles)
1721 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1722 "n" gnus-summary-next-unread-article
1723 "p" gnus-summary-prev-unread-article
1724 "N" gnus-summary-next-article
1725 "P" gnus-summary-prev-article
1726 "\C-n" gnus-summary-next-same-subject
1727 "\C-p" gnus-summary-prev-same-subject
1728 "\M-n" gnus-summary-next-unread-subject
1729 "\M-p" gnus-summary-prev-unread-subject
1730 "f" gnus-summary-first-unread-article
1731 "b" gnus-summary-best-unread-article
1732 "j" gnus-summary-goto-article
1733 "g" gnus-summary-goto-subject
1734 "l" gnus-summary-goto-last-article
1735 "o" gnus-summary-pop-article)
1737 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1738 "k" gnus-summary-kill-thread
1739 "l" gnus-summary-lower-thread
1740 "i" gnus-summary-raise-thread
1741 "T" gnus-summary-toggle-threads
1742 "t" gnus-summary-rethread-current
1743 "^" gnus-summary-reparent-thread
1744 "s" gnus-summary-show-thread
1745 "S" gnus-summary-show-all-threads
1746 "h" gnus-summary-hide-thread
1747 "H" gnus-summary-hide-all-threads
1748 "n" gnus-summary-next-thread
1749 "p" gnus-summary-prev-thread
1750 "u" gnus-summary-up-thread
1751 "o" gnus-summary-top-thread
1752 "d" gnus-summary-down-thread
1753 "#" gnus-uu-mark-thread
1754 "\M-#" gnus-uu-unmark-thread)
1756 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1757 "g" gnus-summary-prepare
1758 "c" gnus-summary-insert-cached-articles
1759 "d" gnus-summary-insert-dormant-articles)
1761 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1762 "c" gnus-summary-catchup-and-exit
1763 "C" gnus-summary-catchup-all-and-exit
1764 "E" gnus-summary-exit-no-update
1765 "Q" gnus-summary-exit
1766 "Z" gnus-summary-exit
1767 "n" gnus-summary-catchup-and-goto-next-group
1768 "R" gnus-summary-reselect-current-group
1769 "G" gnus-summary-rescan-group
1770 "N" gnus-summary-next-group
1771 "s" gnus-summary-save-newsrc
1772 "P" gnus-summary-prev-group)
1774 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1775 " " gnus-summary-next-page
1776 "n" gnus-summary-next-page
1777 "\177" gnus-summary-prev-page
1778 [delete] gnus-summary-prev-page
1779 "p" gnus-summary-prev-page
1780 "\r" gnus-summary-scroll-up
1781 "\M-\r" gnus-summary-scroll-down
1782 "<" gnus-summary-beginning-of-article
1783 ">" gnus-summary-end-of-article
1784 "b" gnus-summary-beginning-of-article
1785 "e" gnus-summary-end-of-article
1786 "^" gnus-summary-refer-parent-article
1787 "r" gnus-summary-refer-parent-article
1788 "D" gnus-summary-enter-digest-group
1789 "R" gnus-summary-refer-references
1790 "T" gnus-summary-refer-thread
1791 "g" gnus-summary-show-article
1792 "s" gnus-summary-isearch-article
1793 "P" gnus-summary-print-article
1794 "M" gnus-mailing-list-insinuate
1795 "t" gnus-article-babel)
1797 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1798 "b" gnus-article-add-buttons
1799 "B" gnus-article-add-buttons-to-head
1800 "o" gnus-article-treat-overstrike
1801 "e" gnus-article-emphasize
1802 "w" gnus-article-fill-cited-article
1803 "Q" gnus-article-fill-long-lines
1804 "C" gnus-article-capitalize-sentences
1805 "c" gnus-article-remove-cr
1806 "q" gnus-article-de-quoted-unreadable
1807 "6" gnus-article-de-base64-unreadable
1808 "Z" gnus-article-decode-HZ
1809 "h" gnus-article-wash-html
1810 "u" gnus-article-unsplit-urls
1811 "s" gnus-summary-force-verify-and-decrypt
1812 "f" gnus-article-display-x-face
1813 "l" gnus-summary-stop-page-breaking
1814 "r" gnus-summary-caesar-message
1815 "m" gnus-summary-morse-message
1816 "t" gnus-summary-toggle-header
1817 "g" gnus-treat-smiley
1818 "v" gnus-summary-verbose-headers
1819 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1820 "p" gnus-article-verify-x-pgp-sig
1821 "d" gnus-article-treat-dumbquotes)
1823 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1824 ;; mnemonic: deuglif*Y*
1825 "u" gnus-article-outlook-unwrap-lines
1826 "a" gnus-article-outlook-repair-attribution
1827 "c" gnus-article-outlook-rearrange-citation
1828 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1830 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1831 "a" gnus-article-hide
1832 "h" gnus-article-hide-headers
1833 "b" gnus-article-hide-boring-headers
1834 "s" gnus-article-hide-signature
1835 "c" gnus-article-hide-citation
1836 "C" gnus-article-hide-citation-in-followups
1837 "l" gnus-article-hide-list-identifiers
1838 "B" gnus-article-strip-banner
1839 "P" gnus-article-hide-pem
1840 "\C-c" gnus-article-hide-citation-maybe)
1842 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1843 "a" gnus-article-highlight
1844 "h" gnus-article-highlight-headers
1845 "c" gnus-article-highlight-citation
1846 "s" gnus-article-highlight-signature)
1848 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1849 "f" gnus-article-treat-fold-headers
1850 "u" gnus-article-treat-unfold-headers
1851 "n" gnus-article-treat-fold-newsgroups)
1853 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1854 "x" gnus-article-display-x-face
1855 "d" gnus-article-display-face
1856 "s" gnus-treat-smiley
1857 "D" gnus-article-remove-images
1858 "f" gnus-treat-from-picon
1859 "m" gnus-treat-mail-picon
1860 "n" gnus-treat-newsgroups-picon)
1862 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1863 "w" gnus-article-decode-mime-words
1864 "c" gnus-article-decode-charset
1865 "v" gnus-mime-view-all-parts
1866 "b" gnus-article-view-part)
1868 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1869 "z" gnus-article-date-ut
1870 "u" gnus-article-date-ut
1871 "l" gnus-article-date-local
1872 "p" gnus-article-date-english
1873 "e" gnus-article-date-lapsed
1874 "o" gnus-article-date-original
1875 "i" gnus-article-date-iso8601
1876 "s" gnus-article-date-user)
1878 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1879 "t" gnus-article-remove-trailing-blank-lines
1880 "l" gnus-article-strip-leading-blank-lines
1881 "m" gnus-article-strip-multiple-blank-lines
1882 "a" gnus-article-strip-blank-lines
1883 "A" gnus-article-strip-all-blank-lines
1884 "s" gnus-article-strip-leading-space
1885 "e" gnus-article-strip-trailing-space
1886 "w" gnus-article-remove-leading-whitespace)
1888 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1890 "f" gnus-summary-fetch-faq
1891 "d" gnus-summary-describe-group
1892 "h" gnus-summary-describe-briefly
1893 "i" gnus-info-find-node
1894 "c" gnus-group-fetch-charter
1895 "C" gnus-group-fetch-control)
1897 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1898 "e" gnus-summary-expire-articles
1899 "\M-\C-e" gnus-summary-expire-articles-now
1900 "\177" gnus-summary-delete-article
1901 [delete] gnus-summary-delete-article
1902 [backspace] gnus-summary-delete-article
1903 "m" gnus-summary-move-article
1904 "r" gnus-summary-respool-article
1905 "w" gnus-summary-edit-article
1906 "c" gnus-summary-copy-article
1907 "B" gnus-summary-crosspost-article
1908 "q" gnus-summary-respool-query
1909 "t" gnus-summary-respool-trace
1910 "i" gnus-summary-import-article
1911 "I" gnus-summary-create-article
1912 "p" gnus-summary-article-posted-p)
1914 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1915 "o" gnus-summary-save-article
1916 "m" gnus-summary-save-article-mail
1917 "F" gnus-summary-write-article-file
1918 "r" gnus-summary-save-article-rmail
1919 "f" gnus-summary-save-article-file
1920 "b" gnus-summary-save-article-body-file
1921 "h" gnus-summary-save-article-folder
1922 "v" gnus-summary-save-article-vm
1923 "p" gnus-summary-pipe-output
1924 "P" gnus-summary-muttprint
1925 "s" gnus-soup-add-article)
1927 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1928 "b" gnus-summary-display-buttonized
1929 "m" gnus-summary-repair-multipart
1930 "v" gnus-article-view-part
1931 "o" gnus-article-save-part
1932 "c" gnus-article-copy-part
1933 "C" gnus-article-view-part-as-charset
1934 "e" gnus-article-view-part-externally
1935 "E" gnus-article-encrypt-body
1936 "i" gnus-article-inline-part
1937 "|" gnus-article-pipe-part)
1939 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1940 "p" gnus-summary-mark-as-processable
1941 "u" gnus-summary-unmark-as-processable
1942 "U" gnus-summary-unmark-all-processable
1943 "v" gnus-uu-mark-over
1944 "s" gnus-uu-mark-series
1945 "r" gnus-uu-mark-region
1946 "g" gnus-uu-unmark-region
1947 "R" gnus-uu-mark-by-regexp
1948 "G" gnus-uu-unmark-by-regexp
1949 "t" gnus-uu-mark-thread
1950 "T" gnus-uu-unmark-thread
1951 "a" gnus-uu-mark-all
1952 "b" gnus-uu-mark-buffer
1953 "S" gnus-uu-mark-sparse
1954 "k" gnus-summary-kill-process-mark
1955 "y" gnus-summary-yank-process-mark
1956 "w" gnus-summary-save-process-mark
1957 "i" gnus-uu-invert-processable)
1959 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1960 ;;"x" gnus-uu-extract-any
1961 "m" gnus-summary-save-parts
1962 "u" gnus-uu-decode-uu
1963 "U" gnus-uu-decode-uu-and-save
1964 "s" gnus-uu-decode-unshar
1965 "S" gnus-uu-decode-unshar-and-save
1966 "o" gnus-uu-decode-save
1967 "O" gnus-uu-decode-save
1968 "b" gnus-uu-decode-binhex
1969 "B" gnus-uu-decode-binhex
1970 "p" gnus-uu-decode-postscript
1971 "P" gnus-uu-decode-postscript-and-save)
1974 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1975 "u" gnus-uu-decode-uu-view
1976 "U" gnus-uu-decode-uu-and-save-view
1977 "s" gnus-uu-decode-unshar-view
1978 "S" gnus-uu-decode-unshar-and-save-view
1979 "o" gnus-uu-decode-save-view
1980 "O" gnus-uu-decode-save-view
1981 "b" gnus-uu-decode-binhex-view
1982 "B" gnus-uu-decode-binhex-view
1983 "p" gnus-uu-decode-postscript-view
1984 "P" gnus-uu-decode-postscript-and-save-view)
1986 (defvar gnus-article-post-menu nil)
1988 (defconst gnus-summary-menu-maxlen 20)
1990 (defun gnus-summary-menu-split (menu)
1991 ;; If we have lots of elements, divide them into groups of 20
1992 ;; and make a pane (or submenu) for each one.
1993 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1994 (let ((menu menu) sublists next
1997 ;; Pull off the next gnus-summary-menu-maxlen elements
1998 ;; and make them the next element of sublist.
1999 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2001 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2003 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2004 (aref (car (last menu)) 0)) menu)
2008 (nreverse sublists))
2009 ;; Few elements--put them all in one pane.
2012 (defun gnus-summary-make-menu-bar ()
2013 (gnus-turn-off-edit-menu 'summary)
2015 (unless (boundp 'gnus-summary-misc-menu)
2018 gnus-summary-kill-menu gnus-summary-mode-map ""
2023 ["Customize" gnus-score-customize t])
2024 (gnus-make-score-map 'increase)
2025 (gnus-make-score-map 'lower)
2027 ["Kill below" gnus-summary-kill-below t]
2028 ["Mark above" gnus-summary-mark-above t]
2029 ["Tick above" gnus-summary-tick-above t]
2030 ["Clear above" gnus-summary-clear-above t])
2031 ["Current score" gnus-summary-current-score t]
2032 ["Set score" gnus-summary-set-score t]
2033 ["Switch current score file..." gnus-score-change-score-file t]
2034 ["Set mark below..." gnus-score-set-mark-below t]
2035 ["Set expunge below..." gnus-score-set-expunge-below t]
2036 ["Edit current score file" gnus-score-edit-current-scores t]
2037 ["Edit score file" gnus-score-edit-file t]
2038 ["Trace score" gnus-score-find-trace t]
2039 ["Find words" gnus-score-find-favourite-words t]
2040 ["Rescore buffer" gnus-summary-rescore t]
2041 ["Increase score..." gnus-summary-increase-score t]
2042 ["Lower score..." gnus-summary-lower-score t]))))
2044 ;; Define both the Article menu in the summary buffer and the
2045 ;; equivalent Commands menu in the article buffer here for
2049 ["All" gnus-article-hide t]
2050 ["Headers" gnus-article-hide-headers t]
2051 ["Signature" gnus-article-hide-signature t]
2052 ["Citation" gnus-article-hide-citation t]
2053 ["List identifiers" gnus-article-hide-list-identifiers t]
2054 ["Banner" gnus-article-strip-banner t]
2055 ["Boring headers" gnus-article-hide-boring-headers t])
2057 ["All" gnus-article-highlight t]
2058 ["Headers" gnus-article-highlight-headers t]
2059 ["Signature" gnus-article-highlight-signature t]
2060 ["Citation" gnus-article-highlight-citation t])
2062 ["Words" gnus-article-decode-mime-words t]
2063 ["Charset" gnus-article-decode-charset t]
2064 ["QP" gnus-article-de-quoted-unreadable t]
2065 ["Base64" gnus-article-de-base64-unreadable t]
2066 ["View MIME buttons" gnus-summary-display-buttonized t]
2067 ["View all" gnus-mime-view-all-parts t]
2068 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2069 ["Encrypt body" gnus-article-encrypt-body t]
2070 ["Extract all parts" gnus-summary-save-parts t]
2072 ["Repair multipart" gnus-summary-repair-multipart t]
2073 ["Add buttons" gnus-summary-display-buttonized t]
2074 ["Pipe part" gnus-article-pipe-part t]
2075 ["Inline part" gnus-article-inline-part t]
2076 ["Encrypt body" gnus-article-encrypt-body t]
2077 ["View part externally" gnus-article-view-part-externally t]
2078 ["View part with charset" gnus-article-view-part-as-charset t]
2079 ["Copy part" gnus-article-copy-part t]
2080 ["Save part" gnus-article-save-part t]
2081 ["View part" gnus-article-view-part t]))
2083 ["Local" gnus-article-date-local t]
2084 ["ISO8601" gnus-article-date-iso8601 t]
2085 ["UT" gnus-article-date-ut t]
2086 ["Original" gnus-article-date-original t]
2087 ["Lapsed" gnus-article-date-lapsed t]
2088 ["User-defined" gnus-article-date-user t])
2090 ["Remove images" gnus-article-remove-images t]
2091 ["Toggle smiley" gnus-treat-smiley t]
2092 ["Show X-Face" gnus-article-display-x-face t]
2093 ["Show picons in From" gnus-treat-from-picon t]
2094 ["Show picons in mail headers" gnus-treat-mail-picon t]
2095 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2096 ("View as different encoding"
2097 ,@(gnus-summary-menu-split
2100 ;; Since easymenu under FSF Emacs doesn't allow lambda
2101 ;; forms for menu commands, we should provide intern'ed
2102 ;; function symbols.
2103 (let ((command (intern (format "\
2104 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2108 (let ((gnus-summary-show-article-charset-alist
2110 (gnus-summary-show-article 1))))
2111 `[,(symbol-name cs) ,command t]))
2112 (sort (if (fboundp 'coding-system-list)
2113 (coding-system-list)
2114 (mapcar 'car mm-mime-mule-charset-alist))
2118 ["Leading" gnus-article-strip-leading-blank-lines t]
2119 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2120 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2121 ["All of the above" gnus-article-strip-blank-lines t]
2122 ["All" gnus-article-strip-all-blank-lines t]
2123 ["Leading space" gnus-article-strip-leading-space t]
2124 ["Trailing space" gnus-article-strip-trailing-space t]
2125 ["Leading space in headers"
2126 gnus-article-remove-leading-whitespace t])
2127 ["Overstrike" gnus-article-treat-overstrike t]
2128 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2129 ["Emphasis" gnus-article-emphasize t]
2130 ["Word wrap" gnus-article-fill-cited-article t]
2131 ["Fill long lines" gnus-article-fill-long-lines t]
2132 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2133 ["CR" gnus-article-remove-cr t]
2134 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2135 ["Base64" gnus-article-de-base64-unreadable t]
2136 ["Rot 13" gnus-summary-caesar-message
2137 ,@(if (featurep 'xemacs) '(t)
2138 '(:help "\"Caesar rotate\" article by 13"))]
2139 ["Morse decode" gnus-summary-morse-message t]
2140 ["Unix pipe..." gnus-summary-pipe-message t]
2141 ["Add buttons" gnus-article-add-buttons t]
2142 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2143 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2144 ["Verbose header" gnus-summary-verbose-headers t]
2145 ["Toggle header" gnus-summary-toggle-header t]
2146 ["Unfold headers" gnus-article-treat-unfold-headers t]
2147 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2148 ["Html" gnus-article-wash-html t]
2149 ["URLs" gnus-article-unsplit-urls t]
2150 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2151 ["HZ" gnus-article-decode-HZ t]
2152 ("(Outlook) Deuglify"
2153 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2154 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2155 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2156 ["Full (Outlook) deuglify"
2157 gnus-article-outlook-deuglify-article t])
2160 ["Save in default format" gnus-summary-save-article
2161 ,@(if (featurep 'xemacs) '(t)
2162 '(:help "Save article using default method"))]
2163 ["Save in file" gnus-summary-save-article-file
2164 ,@(if (featurep 'xemacs) '(t)
2165 '(:help "Save article in file"))]
2166 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2167 ["Save in MH folder" gnus-summary-save-article-folder t]
2168 ["Save in VM folder" gnus-summary-save-article-vm t]
2169 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2170 ["Save body in file" gnus-summary-save-article-body-file t]
2171 ["Pipe through a filter" gnus-summary-pipe-output t]
2172 ["Add to SOUP packet" gnus-soup-add-article t]
2173 ["Print with Muttprint" gnus-summary-muttprint t]
2174 ["Print" gnus-summary-print-article t])
2176 ["Respool article..." gnus-summary-respool-article t]
2177 ["Move article..." gnus-summary-move-article
2178 (gnus-check-backend-function
2179 'request-move-article gnus-newsgroup-name)]
2180 ["Copy article..." gnus-summary-copy-article t]
2181 ["Crosspost article..." gnus-summary-crosspost-article
2182 (gnus-check-backend-function
2183 'request-replace-article gnus-newsgroup-name)]
2184 ["Import file..." gnus-summary-import-article t]
2185 ["Create article..." gnus-summary-create-article t]
2186 ["Check if posted" gnus-summary-article-posted-p t]
2187 ["Edit article" gnus-summary-edit-article
2188 (not (gnus-group-read-only-p))]
2189 ["Delete article" gnus-summary-delete-article
2190 (gnus-check-backend-function
2191 'request-expire-articles gnus-newsgroup-name)]
2192 ["Query respool" gnus-summary-respool-query t]
2193 ["Trace respool" gnus-summary-respool-trace t]
2194 ["Delete expirable articles" gnus-summary-expire-articles-now
2195 (gnus-check-backend-function
2196 'request-expire-articles gnus-newsgroup-name)])
2198 ["Uudecode" gnus-uu-decode-uu
2199 ,@(if (featurep 'xemacs) '(t)
2200 '(:help "Decode uuencoded article(s)"))]
2201 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2202 ["Unshar" gnus-uu-decode-unshar t]
2203 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2204 ["Save" gnus-uu-decode-save t]
2205 ["Binhex" gnus-uu-decode-binhex t]
2206 ["Postscript" gnus-uu-decode-postscript t]
2207 ["All MIME parts" gnus-summary-save-parts t])
2209 ["Enter article" gnus-cache-enter-article t]
2210 ["Remove article" gnus-cache-remove-article t])
2211 ["Translate" gnus-article-babel t]
2212 ["Select article buffer" gnus-summary-select-article-buffer t]
2213 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2214 ["Isearch article..." gnus-summary-isearch-article t]
2215 ["Beginning of the article" gnus-summary-beginning-of-article t]
2216 ["End of the article" gnus-summary-end-of-article t]
2217 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2218 ["Fetch referenced articles" gnus-summary-refer-references t]
2219 ["Fetch current thread" gnus-summary-refer-thread t]
2220 ["Fetch article with id..." gnus-summary-refer-article t]
2221 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2222 ["Redisplay" gnus-summary-show-article t]
2223 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2225 gnus-summary-article-menu gnus-summary-mode-map ""
2226 (cons "Article" innards))
2228 (if (not (keymapp gnus-summary-article-menu))
2230 gnus-article-commands-menu gnus-article-mode-map ""
2231 (cons "Commands" innards))
2232 ;; in Emacs, don't share menu.
2233 (setq gnus-article-commands-menu
2234 (copy-keymap gnus-summary-article-menu))
2235 (define-key gnus-article-mode-map [menu-bar commands]
2236 (cons "Commands" gnus-article-commands-menu))))
2239 gnus-summary-thread-menu gnus-summary-mode-map ""
2241 ["Find all messages in thread" gnus-summary-refer-thread t]
2242 ["Toggle threading" gnus-summary-toggle-threads t]
2243 ["Hide threads" gnus-summary-hide-all-threads t]
2244 ["Show threads" gnus-summary-show-all-threads t]
2245 ["Hide thread" gnus-summary-hide-thread t]
2246 ["Show thread" gnus-summary-show-thread t]
2247 ["Go to next thread" gnus-summary-next-thread t]
2248 ["Go to previous thread" gnus-summary-prev-thread t]
2249 ["Go down thread" gnus-summary-down-thread t]
2250 ["Go up thread" gnus-summary-up-thread t]
2251 ["Top of thread" gnus-summary-top-thread t]
2252 ["Mark thread as read" gnus-summary-kill-thread t]
2253 ["Lower thread score" gnus-summary-lower-thread t]
2254 ["Raise thread score" gnus-summary-raise-thread t]
2255 ["Rethread current" gnus-summary-rethread-current t]))
2258 gnus-summary-post-menu gnus-summary-mode-map ""
2260 ["Send a message (mail or news)" gnus-summary-post-news
2261 ,@(if (featurep 'xemacs) '(t)
2262 '(:help "Post an article"))]
2263 ["Followup" gnus-summary-followup
2264 ,@(if (featurep 'xemacs) '(t)
2265 '(:help "Post followup to this article"))]
2266 ["Followup and yank" gnus-summary-followup-with-original
2267 ,@(if (featurep 'xemacs) '(t)
2268 '(:help "Post followup to this article, quoting its contents"))]
2269 ["Supersede article" gnus-summary-supersede-article t]
2270 ["Cancel article" gnus-summary-cancel-article
2271 ,@(if (featurep 'xemacs) '(t)
2272 '(:help "Cancel an article you posted"))]
2273 ["Reply" gnus-summary-reply t]
2274 ["Reply and yank" gnus-summary-reply-with-original t]
2275 ["Wide reply" gnus-summary-wide-reply t]
2276 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2277 ,@(if (featurep 'xemacs) '(t)
2278 '(:help "Mail a reply, quoting this article"))]
2279 ["Very wide reply" gnus-summary-very-wide-reply t]
2280 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2281 ,@(if (featurep 'xemacs) '(t)
2282 '(:help "Mail a very wide reply, quoting this article"))]
2283 ["Mail forward" gnus-summary-mail-forward t]
2284 ["Post forward" gnus-summary-post-forward t]
2285 ["Digest and mail" gnus-uu-digest-mail-forward t]
2286 ["Digest and post" gnus-uu-digest-post-forward t]
2287 ["Resend message" gnus-summary-resend-message t]
2288 ["Resend message edit" gnus-summary-resend-message-edit t]
2289 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2290 ["Send a mail" gnus-summary-mail-other-window t]
2291 ["Create a local message" gnus-summary-news-other-window t]
2292 ["Uuencode and post" gnus-uu-post-news
2293 ,@(if (featurep 'xemacs) '(t)
2294 '(:help "Post a uuencoded article"))]
2295 ["Followup via news" gnus-summary-followup-to-mail t]
2296 ["Followup via news and yank"
2297 gnus-summary-followup-to-mail-with-original t]
2299 ;;["Send" gnus-summary-send-draft t]
2300 ;;["Send bounced" gnus-resend-bounced-mail t])
2304 ((not (keymapp gnus-summary-post-menu))
2305 (setq gnus-article-post-menu gnus-summary-post-menu))
2306 ((not gnus-article-post-menu)
2307 ;; Don't share post menu.
2308 (setq gnus-article-post-menu
2309 (copy-keymap gnus-summary-post-menu))))
2310 (define-key gnus-article-mode-map [menu-bar post]
2311 (cons "Post" gnus-article-post-menu))
2314 gnus-summary-misc-menu gnus-summary-mode-map ""
2317 ["Mark as read" gnus-summary-mark-as-read-forward t]
2318 ["Mark same subject and select"
2319 gnus-summary-kill-same-subject-and-select t]
2320 ["Mark same subject" gnus-summary-kill-same-subject t]
2321 ["Catchup" gnus-summary-catchup
2322 ,@(if (featurep 'xemacs) '(t)
2323 '(:help "Mark unread articles in this group as read"))]
2324 ["Catchup all" gnus-summary-catchup-all t]
2325 ["Catchup to here" gnus-summary-catchup-to-here t]
2326 ["Catchup from here" gnus-summary-catchup-from-here t]
2327 ["Catchup region" gnus-summary-mark-region-as-read
2328 (gnus-mark-active-p)]
2329 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2331 ["Tick" gnus-summary-tick-article-forward t]
2332 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2333 ["Remove marks" gnus-summary-clear-mark-forward t]
2334 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2335 ["Set bookmark" gnus-summary-set-bookmark t]
2336 ["Remove bookmark" gnus-summary-remove-bookmark t])
2338 ["Marks..." gnus-summary-limit-to-marks t]
2339 ["Subject..." gnus-summary-limit-to-subject t]
2340 ["Author..." gnus-summary-limit-to-author t]
2341 ["Age..." gnus-summary-limit-to-age t]
2342 ["Extra..." gnus-summary-limit-to-extra t]
2343 ["Score..." gnus-summary-limit-to-score t]
2344 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2345 ["Unread" gnus-summary-limit-to-unread t]
2346 ["Unseen" gnus-summary-limit-to-unseen t]
2347 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2348 ["Next articles" gnus-summary-limit-to-articles t]
2349 ["Pop limit" gnus-summary-pop-limit t]
2350 ["Show dormant" gnus-summary-limit-include-dormant t]
2351 ["Hide childless dormant"
2352 gnus-summary-limit-exclude-childless-dormant t]
2353 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2354 ["Hide marked" gnus-summary-limit-exclude-marks t]
2355 ["Show expunged" gnus-summary-limit-include-expunged t])
2357 ["Set mark" gnus-summary-mark-as-processable t]
2358 ["Remove mark" gnus-summary-unmark-as-processable t]
2359 ["Remove all marks" gnus-summary-unmark-all-processable t]
2360 ["Mark above" gnus-uu-mark-over t]
2361 ["Mark series" gnus-uu-mark-series t]
2362 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2363 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2364 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2365 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2366 ["Mark all" gnus-uu-mark-all t]
2367 ["Mark buffer" gnus-uu-mark-buffer t]
2368 ["Mark sparse" gnus-uu-mark-sparse t]
2369 ["Mark thread" gnus-uu-mark-thread t]
2370 ["Unmark thread" gnus-uu-unmark-thread t]
2371 ("Process Mark Sets"
2372 ["Kill" gnus-summary-kill-process-mark t]
2373 ["Yank" gnus-summary-yank-process-mark
2374 gnus-newsgroup-process-stack]
2375 ["Save" gnus-summary-save-process-mark t]
2376 ["Run command on marked..." gnus-summary-universal-argument t]))
2378 ["Page forward" gnus-summary-next-page
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "Show next page of article"))]
2381 ["Page backward" gnus-summary-prev-page
2382 ,@(if (featurep 'xemacs) '(t)
2383 '(:help "Show previous page of article"))]
2384 ["Line forward" gnus-summary-scroll-up t])
2386 ["Next unread article" gnus-summary-next-unread-article t]
2387 ["Previous unread article" gnus-summary-prev-unread-article t]
2388 ["Next article" gnus-summary-next-article t]
2389 ["Previous article" gnus-summary-prev-article t]
2390 ["Next unread subject" gnus-summary-next-unread-subject t]
2391 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2392 ["Next article same subject" gnus-summary-next-same-subject t]
2393 ["Previous article same subject" gnus-summary-prev-same-subject t]
2394 ["First unread article" gnus-summary-first-unread-article t]
2395 ["Best unread article" gnus-summary-best-unread-article t]
2396 ["Go to subject number..." gnus-summary-goto-subject t]
2397 ["Go to article number..." gnus-summary-goto-article t]
2398 ["Go to the last article" gnus-summary-goto-last-article t]
2399 ["Pop article off history" gnus-summary-pop-article t])
2401 ["Sort by number" gnus-summary-sort-by-number t]
2402 ["Sort by author" gnus-summary-sort-by-author t]
2403 ["Sort by subject" gnus-summary-sort-by-subject t]
2404 ["Sort by date" gnus-summary-sort-by-date t]
2405 ["Sort by score" gnus-summary-sort-by-score t]
2406 ["Sort by lines" gnus-summary-sort-by-lines t]
2407 ["Sort by characters" gnus-summary-sort-by-chars t]
2408 ["Randomize" gnus-summary-sort-by-random t]
2409 ["Original sort" gnus-summary-sort-by-original t])
2411 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2412 ["Describe group" gnus-summary-describe-group t]
2413 ["Fetch charter" gnus-group-fetch-charter
2414 ,@(if (featurep 'xemacs) nil
2415 '(:help "Display the charter of the current group"))]
2416 ["Fetch control message" gnus-group-fetch-control
2417 ,@(if (featurep 'xemacs) nil
2418 '(:help "Display the archived control message for the current group"))]
2419 ["Read manual" gnus-info-find-node t])
2421 ["Pick and read" gnus-pick-mode t]
2422 ["Binary" gnus-binary-mode t])
2424 ["Regenerate" gnus-summary-prepare t]
2425 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2426 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2427 ["Toggle threading" gnus-summary-toggle-threads t])
2428 ["See old articles" gnus-summary-insert-old-articles t]
2429 ["See new articles" gnus-summary-insert-new-articles t]
2430 ["Filter articles..." gnus-summary-execute-command t]
2431 ["Run command on articles..." gnus-summary-universal-argument t]
2432 ["Search articles forward..." gnus-summary-search-article-forward t]
2433 ["Search articles backward..." gnus-summary-search-article-backward t]
2434 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2435 ["Expand window" gnus-summary-expand-window t]
2436 ["Expire expirable articles" gnus-summary-expire-articles
2437 (gnus-check-backend-function
2438 'request-expire-articles gnus-newsgroup-name)]
2439 ["Edit local kill file" gnus-summary-edit-local-kill t]
2440 ["Edit main kill file" gnus-summary-edit-global-kill t]
2441 ["Edit group parameters" gnus-summary-edit-parameters t]
2442 ["Customize group parameters" gnus-summary-customize-parameters t]
2443 ["Send a bug report" gnus-bug t]
2445 ["Catchup and exit" gnus-summary-catchup-and-exit
2446 ,@(if (featurep 'xemacs) '(t)
2447 '(:help "Mark unread articles in this group as read, then exit"))]
2448 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2449 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2450 ["Exit group" gnus-summary-exit
2451 ,@(if (featurep 'xemacs) '(t)
2452 '(:help "Exit current group, return to group selection mode"))]
2453 ["Exit group without updating" gnus-summary-exit-no-update t]
2454 ["Exit and goto next group" gnus-summary-next-group t]
2455 ["Exit and goto prev group" gnus-summary-prev-group t]
2456 ["Reselect group" gnus-summary-reselect-current-group t]
2457 ["Rescan group" gnus-summary-rescan-group t]
2458 ["Update dribble" gnus-summary-save-newsrc t])))
2460 (gnus-run-hooks 'gnus-summary-menu-hook)))
2462 (defvar gnus-summary-tool-bar-map nil)
2464 ;; Emacs 21 tool bar. Should be no-op otherwise.
2465 (defun gnus-summary-make-tool-bar ()
2466 (if (and (fboundp 'tool-bar-add-item-from-menu)
2467 (default-value 'tool-bar-mode)
2468 (not gnus-summary-tool-bar-map))
2469 (setq gnus-summary-tool-bar-map
2470 (let ((tool-bar-map (make-sparse-keymap))
2471 (load-path (mm-image-load-path)))
2472 (tool-bar-add-item-from-menu
2473 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2474 (tool-bar-add-item-from-menu
2475 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2476 (tool-bar-add-item-from-menu
2477 'gnus-summary-post-news "post" gnus-summary-mode-map)
2478 (tool-bar-add-item-from-menu
2479 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2480 (tool-bar-add-item-from-menu
2481 'gnus-summary-followup "followup" gnus-summary-mode-map)
2482 (tool-bar-add-item-from-menu
2483 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2484 (tool-bar-add-item-from-menu
2485 'gnus-summary-reply "reply" gnus-summary-mode-map)
2486 (tool-bar-add-item-from-menu
2487 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2488 (tool-bar-add-item-from-menu
2489 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2490 (tool-bar-add-item-from-menu
2491 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2492 (tool-bar-add-item-from-menu
2493 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2494 (tool-bar-add-item-from-menu
2495 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2496 (tool-bar-add-item-from-menu
2497 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2498 (tool-bar-add-item-from-menu
2499 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2500 (tool-bar-add-item-from-menu
2501 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2503 (if gnus-summary-tool-bar-map
2504 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2506 (defun gnus-score-set-default (var value)
2507 "A version of set that updates the GNU Emacs menu-bar."
2509 ;; It is the message that forces the active status to be updated.
2512 (defun gnus-make-score-map (type)
2513 "Make a summary score map of type TYPE."
2516 (let ((headers '(("author" "from" string)
2517 ("subject" "subject" string)
2518 ("article body" "body" string)
2519 ("article head" "head" string)
2520 ("xref" "xref" string)
2521 ("extra header" "extra" string)
2522 ("lines" "lines" number)
2523 ("followups to author" "followup" string)))
2524 (types '((number ("less than" <)
2527 (string ("substring" s)
2531 (perms '(("temporary" (current-time-string))
2539 (if (eq type 'lower)
2544 (setq header (car headers))
2550 (let ((ts (cdr (assoc (nth 2 header) types)))
2566 'gnus-summary-score-entry
2568 (if (or (string= (nth 1 header)
2570 (string= (nth 1 header)
2573 (list 'gnus-summary-header
2575 (list 'quote (nth 1 (car ts)))
2576 (list 'gnus-score-delta-default
2583 (list (nreverse outp))))
2586 (list (nreverse outt))))
2588 (setq headers (cdr headers)))
2589 (list (nreverse outh))))))))
2593 (defun gnus-summary-mode (&optional group)
2594 "Major mode for reading articles.
2596 All normal editing commands are switched off.
2597 \\<gnus-summary-mode-map>
2598 Each line in this buffer represents one article. To read an
2599 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2600 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2603 You can also post articles and send mail from this buffer. To
2604 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2605 of an article, type `\\[gnus-summary-reply]'.
2607 There are approx. one gazillion commands you can execute in this
2608 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2610 The following commands are available:
2612 \\{gnus-summary-mode-map}"
2614 (kill-all-local-variables)
2615 (when (gnus-visual-p 'summary-menu 'menu)
2616 (gnus-summary-make-menu-bar)
2617 (gnus-summary-make-tool-bar))
2618 (gnus-summary-make-local-variables)
2619 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2620 (gnus-summary-make-local-variables))
2621 (gnus-make-thread-indent-array)
2622 (gnus-simplify-mode-line)
2623 (setq major-mode 'gnus-summary-mode)
2624 (setq mode-name "Summary")
2625 (make-local-variable 'minor-mode-alist)
2626 (use-local-map gnus-summary-mode-map)
2627 (buffer-disable-undo)
2628 (setq buffer-read-only t) ;Disable modification
2629 (setq truncate-lines t)
2630 (setq selective-display t)
2631 (setq selective-display-ellipses t) ;Display `...'
2632 (gnus-summary-set-display-table)
2633 (gnus-set-default-directory)
2634 (setq gnus-newsgroup-name group)
2635 (make-local-variable 'gnus-summary-line-format)
2636 (make-local-variable 'gnus-summary-line-format-spec)
2637 (make-local-variable 'gnus-summary-dummy-line-format)
2638 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2639 (make-local-variable 'gnus-summary-mark-positions)
2640 (make-local-hook 'pre-command-hook)
2641 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2642 (gnus-run-hooks 'gnus-summary-mode-hook)
2643 (turn-on-gnus-mailing-list-mode)
2644 (mm-enable-multibyte)
2645 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2646 (gnus-update-summary-mark-positions))
2648 (defun gnus-summary-make-local-variables ()
2649 "Make all the local summary buffer variables."
2651 (dolist (local gnus-summary-local-variables)
2654 (if (eq (cdr local) 'global)
2655 ;; Copy the global value of the variable.
2656 (setq global (symbol-value (car local)))
2657 ;; Use the value from the list.
2658 (setq global (eval (cdr local))))
2659 (set (make-local-variable (car local)) global))
2660 ;; Simple nil-valued local variable.
2661 (set (make-local-variable local) nil)))))
2663 (defun gnus-summary-clear-local-variables ()
2664 (let ((locals gnus-summary-local-variables))
2666 (if (consp (car locals))
2667 (and (vectorp (caar locals))
2668 (set (caar locals) nil))
2669 (and (vectorp (car locals))
2670 (set (car locals) nil)))
2671 (setq locals (cdr locals)))))
2673 ;; Summary data functions.
2675 (defmacro gnus-data-number (data)
2678 (defmacro gnus-data-set-number (data number)
2679 `(setcar ,data ,number))
2681 (defmacro gnus-data-mark (data)
2684 (defmacro gnus-data-set-mark (data mark)
2685 `(setcar (nthcdr 1 ,data) ,mark))
2687 (defmacro gnus-data-pos (data)
2690 (defmacro gnus-data-set-pos (data pos)
2691 `(setcar (nthcdr 2 ,data) ,pos))
2693 (defmacro gnus-data-header (data)
2696 (defmacro gnus-data-set-header (data header)
2697 `(setf (nth 3 ,data) ,header))
2699 (defmacro gnus-data-level (data)
2702 (defmacro gnus-data-unread-p (data)
2703 `(= (nth 1 ,data) gnus-unread-mark))
2705 (defmacro gnus-data-read-p (data)
2706 `(/= (nth 1 ,data) gnus-unread-mark))
2708 (defmacro gnus-data-pseudo-p (data)
2709 `(consp (nth 3 ,data)))
2711 (defmacro gnus-data-find (number)
2712 `(assq ,number gnus-newsgroup-data))
2714 (defmacro gnus-data-find-list (number &optional data)
2715 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2716 (memq (assq ,number bdata)
2719 (defmacro gnus-data-make (number mark pos header level)
2720 `(list ,number ,mark ,pos ,header ,level))
2722 (defun gnus-data-enter (after-article number mark pos header level offset)
2723 (let ((data (gnus-data-find-list after-article)))
2725 (error "No such article: %d" after-article))
2726 (setcdr data (cons (gnus-data-make number mark pos header level)
2728 (setq gnus-newsgroup-data-reverse nil)
2729 (gnus-data-update-list (cddr data) offset)))
2731 (defun gnus-data-enter-list (after-article list &optional offset)
2733 (let ((data (and after-article (gnus-data-find-list after-article)))
2737 (let ((odata gnus-newsgroup-data))
2738 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2740 (gnus-data-update-list odata offset)))
2741 ;; Find the last element in the list to be spliced into the main
2744 (setq list (cdr list)))
2747 (setcdr list gnus-newsgroup-data)
2748 (setq gnus-newsgroup-data ilist)
2750 (gnus-data-update-list (cdr list) offset)))
2751 (setcdr list (cdr data))
2754 (gnus-data-update-list (cdr list) offset))))
2755 (setq gnus-newsgroup-data-reverse nil))))
2757 (defun gnus-data-remove (article &optional offset)
2758 (let ((data gnus-newsgroup-data))
2759 (if (= (gnus-data-number (car data)) article)
2761 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2762 gnus-newsgroup-data-reverse nil)
2764 (gnus-data-update-list gnus-newsgroup-data offset)))
2766 (when (= (gnus-data-number (cadr data)) article)
2767 (setcdr data (cddr data))
2769 (gnus-data-update-list (cdr data) offset))
2771 gnus-newsgroup-data-reverse nil))
2772 (setq data (cdr data))))))
2774 (defmacro gnus-data-list (backward)
2776 (or gnus-newsgroup-data-reverse
2777 (setq gnus-newsgroup-data-reverse
2778 (reverse gnus-newsgroup-data)))
2779 gnus-newsgroup-data))
2781 (defun gnus-data-update-list (data offset)
2782 "Add OFFSET to the POS of all data entries in DATA."
2783 (setq gnus-newsgroup-data-reverse nil)
2785 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2786 (setq data (cdr data))))
2788 (defun gnus-summary-article-pseudo-p (article)
2789 "Say whether this article is a pseudo article or not."
2790 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2792 (defmacro gnus-summary-article-sparse-p (article)
2793 "Say whether this article is a sparse article or not."
2794 `(memq ,article gnus-newsgroup-sparse))
2796 (defmacro gnus-summary-article-ancient-p (article)
2797 "Say whether this article is a sparse article or not."
2798 `(memq ,article gnus-newsgroup-ancient))
2800 (defun gnus-article-parent-p (number)
2801 "Say whether this article is a parent or not."
2802 (let ((data (gnus-data-find-list number)))
2803 (and (cdr data) ; There has to be an article after...
2804 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2805 (gnus-data-level (nth 1 data))))))
2807 (defun gnus-article-children (number)
2808 "Return a list of all children to NUMBER."
2809 (let* ((data (gnus-data-find-list number))
2810 (level (gnus-data-level (car data)))
2812 (setq data (cdr data))
2814 (= (gnus-data-level (car data)) (1+ level)))
2815 (push (gnus-data-number (car data)) children)
2816 (setq data (cdr data)))
2819 (defmacro gnus-summary-skip-intangible ()
2820 "If the current article is intangible, then jump to a different article."
2821 '(let ((to (get-text-property (point) 'gnus-intangible)))
2822 (and to (gnus-summary-goto-subject to))))
2824 (defmacro gnus-summary-article-intangible-p ()
2825 "Say whether this article is intangible or not."
2826 '(get-text-property (point) 'gnus-intangible))
2828 (defun gnus-article-read-p (article)
2829 "Say whether ARTICLE is read or not."
2830 (not (or (memq article gnus-newsgroup-marked)
2831 (memq article gnus-newsgroup-spam-marked)
2832 (memq article gnus-newsgroup-unreads)
2833 (memq article gnus-newsgroup-unselected)
2834 (memq article gnus-newsgroup-dormant))))
2836 ;; Some summary mode macros.
2838 (defmacro gnus-summary-article-number ()
2839 "The article number of the article on the current line.
2840 If there isn't an article number here, then we return the current
2843 (gnus-summary-skip-intangible)
2844 (or (get-text-property (point) 'gnus-number)
2845 (gnus-summary-last-subject))))
2847 (defmacro gnus-summary-article-header (&optional number)
2848 "Return the header of article NUMBER."
2849 `(gnus-data-header (gnus-data-find
2850 ,(or number '(gnus-summary-article-number)))))
2852 (defmacro gnus-summary-thread-level (&optional number)
2853 "Return the level of thread that starts with article NUMBER."
2854 `(if (and (eq gnus-summary-make-false-root 'dummy)
2855 (get-text-property (point) 'gnus-intangible))
2857 (gnus-data-level (gnus-data-find
2858 ,(or number '(gnus-summary-article-number))))))
2860 (defmacro gnus-summary-article-mark (&optional number)
2861 "Return the mark of article NUMBER."
2862 `(gnus-data-mark (gnus-data-find
2863 ,(or number '(gnus-summary-article-number)))))
2865 (defmacro gnus-summary-article-pos (&optional number)
2866 "Return the position of the line of article NUMBER."
2867 `(gnus-data-pos (gnus-data-find
2868 ,(or number '(gnus-summary-article-number)))))
2870 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2871 (defmacro gnus-summary-article-subject (&optional number)
2872 "Return current subject string or nil if nothing."
2875 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2876 '(gnus-data-header (assq (gnus-summary-article-number)
2877 gnus-newsgroup-data)))))
2880 (mail-header-subject headers))))
2882 (defmacro gnus-summary-article-score (&optional number)
2883 "Return current article score."
2884 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2885 gnus-newsgroup-scored))
2886 gnus-summary-default-score 0))
2888 (defun gnus-summary-article-children (&optional number)
2889 "Return a list of article numbers that are children of article NUMBER."
2890 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2891 (level (gnus-data-level (car data)))
2893 (while (and (setq data (cdr data))
2894 (> (setq l (gnus-data-level (car data))) level))
2895 (and (= (1+ level) l)
2896 (push (gnus-data-number (car data))
2898 (nreverse children)))
2900 (defun gnus-summary-article-parent (&optional number)
2901 "Return the article number of the parent of article NUMBER."
2902 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2903 (gnus-data-list t)))
2904 (level (gnus-data-level (car data))))
2906 () ; This is a root.
2907 ;; We search until we find an article with a level less than
2908 ;; this one. That function has to be the parent.
2909 (while (and (setq data (cdr data))
2910 (not (< (gnus-data-level (car data)) level))))
2911 (and data (gnus-data-number (car data))))))
2913 (defun gnus-unread-mark-p (mark)
2914 "Say whether MARK is the unread mark."
2915 (= mark gnus-unread-mark))
2917 (defun gnus-read-mark-p (mark)
2918 "Say whether MARK is one of the marks that mark as read.
2919 This is all marks except unread, ticked, dormant, and expirable."
2920 (not (or (= mark gnus-unread-mark)
2921 (= mark gnus-ticked-mark)
2922 (= mark gnus-spam-mark)
2923 (= mark gnus-dormant-mark)
2924 (= mark gnus-expirable-mark))))
2926 (defmacro gnus-article-mark (number)
2927 "Return the MARK of article NUMBER.
2928 This macro should only be used when computing the mark the \"first\"
2929 time; i.e., when generating the summary lines. After that,
2930 `gnus-summary-article-mark' should be used to examine the
2933 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2934 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2935 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2936 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2937 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2938 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2939 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2940 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2941 gnus-ancient-mark))))
2943 ;; Saving hidden threads.
2945 (defmacro gnus-save-hidden-threads (&rest forms)
2946 "Save hidden threads, eval FORMS, and restore the hidden threads."
2947 (let ((config (make-symbol "config")))
2948 `(let ((,config (gnus-hidden-threads-configuration)))
2952 (gnus-restore-hidden-threads-configuration ,config)))))
2953 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2954 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2956 (defun gnus-data-compute-positions ()
2957 "Compute the positions of all articles."
2958 (setq gnus-newsgroup-data-reverse nil)
2959 (let ((data gnus-newsgroup-data))
2961 (gnus-save-hidden-threads
2962 (gnus-summary-show-all-threads)
2963 (goto-char (point-min))
2965 (while (get-text-property (point) 'gnus-intangible)
2967 (gnus-data-set-pos (car data) (+ (point) 3))
2968 (setq data (cdr data))
2969 (forward-line 1))))))
2971 (defun gnus-hidden-threads-configuration ()
2972 "Return the current hidden threads configuration."
2975 (goto-char (point-min))
2976 (while (search-forward "\r" nil t)
2977 (push (1- (point)) config))
2980 (defun gnus-restore-hidden-threads-configuration (config)
2981 "Restore hidden threads configuration from CONFIG."
2983 (let (point buffer-read-only)
2984 (while (setq point (pop config))
2985 (when (and (< point (point-max))
2987 (eq (char-after) ?\n))
2988 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2990 ;; Various summary mode internalish functions.
2992 (defun gnus-mouse-pick-article (e)
2995 (gnus-summary-next-page nil t))
2997 (defun gnus-summary-set-display-table ()
2998 "Change the display table.
2999 Odd characters have a tendency to mess
3000 up nicely formatted displays - we make all possible glyphs
3001 display only a single character."
3003 ;; We start from the standard display table, if any.
3004 (let ((table (or (copy-sequence standard-display-table)
3005 (make-display-table)))
3007 ;; Nix out all the control chars...
3008 (while (>= (setq i (1- i)) 0)
3009 (aset table i [??]))
3010 ;; ... but not newline and cr, of course. (cr is necessary for the
3011 ;; selective display).
3012 (aset table ?\n nil)
3013 (aset table ?\r nil)
3014 ;; We keep TAB as well.
3015 (aset table ?\t nil)
3016 ;; We nix out any glyphs over 126 that are not set already.
3018 (while (>= (setq i (1- i)) 127)
3019 ;; Only modify if the entry is nil.
3020 (unless (aref table i)
3021 (aset table i [??]))))
3022 (setq buffer-display-table table)))
3024 (defun gnus-summary-set-article-display-arrow (pos)
3025 "Update the overlay arrow to point to line at position POS."
3026 (when (and gnus-summary-display-arrow
3027 (boundp 'overlay-arrow-position)
3028 (boundp 'overlay-arrow-string))
3032 (unless overlay-arrow-position
3033 (setq overlay-arrow-position (make-marker)))
3034 (setq overlay-arrow-string "=>"
3035 overlay-arrow-position (set-marker overlay-arrow-position
3037 (current-buffer))))))
3039 (defun gnus-summary-buffer-name (group)
3040 "Return the summary buffer name of GROUP."
3041 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3043 (defun gnus-summary-setup-buffer (group)
3044 "Initialize summary buffer."
3045 (let ((buffer (gnus-summary-buffer-name group))
3046 (dead-name (concat "*Dead Summary "
3047 (gnus-group-decoded-name group) "*")))
3048 ;; If a dead summary buffer exists, we kill it.
3049 (when (gnus-buffer-live-p dead-name)
3050 (gnus-kill-buffer dead-name))
3051 (if (get-buffer buffer)
3054 (setq gnus-summary-buffer (current-buffer))
3055 (not gnus-newsgroup-prepared))
3056 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3057 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3058 (gnus-summary-mode group)
3060 (gnus-carpal-setup-buffer 'summary))
3061 (unless gnus-single-article-buffer
3062 (make-local-variable 'gnus-article-buffer)
3063 (make-local-variable 'gnus-article-current)
3064 (make-local-variable 'gnus-original-article-buffer))
3065 (setq gnus-newsgroup-name group)
3066 ;; Set any local variables in the group parameters.
3067 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3070 (defun gnus-set-global-variables ()
3071 "Set the global equivalents of the buffer-local variables.
3072 They are set to the latest values they had. These reflect the summary
3073 buffer that was in action when the last article was fetched."
3074 (when (eq major-mode 'gnus-summary-mode)
3075 (setq gnus-summary-buffer (current-buffer))
3076 (let ((name gnus-newsgroup-name)
3077 (marked gnus-newsgroup-marked)
3078 (spam gnus-newsgroup-spam-marked)
3079 (unread gnus-newsgroup-unreads)
3080 (headers gnus-current-headers)
3081 (data gnus-newsgroup-data)
3082 (summary gnus-summary-buffer)
3083 (article-buffer gnus-article-buffer)
3084 (original gnus-original-article-buffer)
3085 (gac gnus-article-current)
3086 (reffed gnus-reffed-article-number)
3087 (score-file gnus-current-score-file)
3088 (default-charset gnus-newsgroup-charset)
3090 (let ((locals gnus-newsgroup-variables))
3092 (if (consp (car locals))
3093 (push (eval (caar locals)) vlist)
3094 (push (eval (car locals)) vlist))
3095 (setq locals (cdr locals)))
3096 (setq vlist (nreverse vlist)))
3098 (set-buffer gnus-group-buffer)
3099 (setq gnus-newsgroup-name name
3100 gnus-newsgroup-marked marked
3101 gnus-newsgroup-spam-marked spam
3102 gnus-newsgroup-unreads unread
3103 gnus-current-headers headers
3104 gnus-newsgroup-data data
3105 gnus-article-current gac
3106 gnus-summary-buffer summary
3107 gnus-article-buffer article-buffer
3108 gnus-original-article-buffer original
3109 gnus-reffed-article-number reffed
3110 gnus-current-score-file score-file
3111 gnus-newsgroup-charset default-charset)
3112 (let ((locals gnus-newsgroup-variables))
3114 (if (consp (car locals))
3115 (set (caar locals) (pop vlist))
3116 (set (car locals) (pop vlist)))
3117 (setq locals (cdr locals))))
3118 ;; The article buffer also has local variables.
3119 (when (gnus-buffer-live-p gnus-article-buffer)
3120 (set-buffer gnus-article-buffer)
3121 (setq gnus-summary-buffer summary))))))
3123 (defun gnus-summary-article-unread-p (article)
3124 "Say whether ARTICLE is unread or not."
3125 (memq article gnus-newsgroup-unreads))
3127 (defun gnus-summary-first-article-p (&optional article)
3128 "Return whether ARTICLE is the first article in the buffer."
3129 (if (not (setq article (or article (gnus-summary-article-number))))
3131 (eq article (caar gnus-newsgroup-data))))
3133 (defun gnus-summary-last-article-p (&optional article)
3134 "Return whether ARTICLE is the last article in the buffer."
3135 (if (not (setq article (or article (gnus-summary-article-number))))
3136 ;; All non-existent numbers are the last article. :-)
3138 (not (cdr (gnus-data-find-list article)))))
3140 (defun gnus-make-thread-indent-array ()
3142 (unless (and gnus-thread-indent-array
3143 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3144 (setq gnus-thread-indent-array (make-vector 201 "")
3145 gnus-thread-indent-array-level gnus-thread-indent-level)
3147 (aset gnus-thread-indent-array n
3148 (make-string (* n gnus-thread-indent-level) ? ))
3151 (defun gnus-update-summary-mark-positions ()
3152 "Compute where the summary marks are to go."
3154 (when (gnus-buffer-exists-p gnus-summary-buffer)
3155 (set-buffer gnus-summary-buffer))
3156 (let ((gnus-replied-mark 129)
3157 (gnus-score-below-mark 130)
3158 (gnus-score-over-mark 130)
3159 (gnus-undownloaded-mark 131)
3160 (spec gnus-summary-line-format-spec)
3163 (gnus-set-work-buffer)
3164 (let ((gnus-summary-line-format-spec spec)
3165 (gnus-newsgroup-downloadable '(0)))
3166 (gnus-summary-insert-line
3167 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3168 0 nil t 128 t nil "" nil 1)
3169 (goto-char (point-min))
3170 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3171 (- (point) (point-min) 1)))))
3172 (goto-char (point-min))
3173 (push (cons 'replied (and (search-forward "\201" nil t)
3174 (- (point) (point-min) 1)))
3176 (goto-char (point-min))
3177 (push (cons 'score (and (search-forward "\202" nil t)
3178 (- (point) (point-min) 1)))
3180 (goto-char (point-min))
3181 (push (cons 'download
3182 (and (search-forward "\203" nil t)
3183 (- (point) (point-min) 1)))
3185 (setq gnus-summary-mark-positions pos))))
3187 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3188 "Insert a dummy root in the summary buffer."
3190 (gnus-add-text-properties
3191 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3192 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3194 (defun gnus-summary-extract-address-component (from)
3195 (or (car (funcall gnus-extract-address-components from))
3198 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3199 (let ((mail-parse-charset gnus-newsgroup-charset)
3200 ; Is it really necessary to do this next part for each summary line?
3201 ; Luckily, doesn't seem to slow things down much.
3202 (mail-parse-ignored-charsets
3203 (save-excursion (set-buffer gnus-summary-buffer)
3204 gnus-newsgroup-ignored-charsets)))
3206 (and gnus-ignored-from-addresses
3207 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3208 (let ((extra-headers (mail-header-extra header))
3212 ((setq to (cdr (assq 'To extra-headers)))
3215 (gnus-summary-extract-address-component
3216 (funcall gnus-decode-encoded-word-function to)))))
3217 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3218 (concat "=> " newsgroups)))))
3219 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3221 (defun gnus-summary-insert-line (gnus-tmp-header
3222 gnus-tmp-level gnus-tmp-current
3223 undownloaded gnus-tmp-unread gnus-tmp-replied
3224 gnus-tmp-expirable gnus-tmp-subject-or-nil
3225 &optional gnus-tmp-dummy gnus-tmp-score
3227 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3228 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3229 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3230 (gnus-tmp-score-char
3231 (if (or (null gnus-summary-default-score)
3232 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3233 gnus-summary-zcore-fuzz))
3235 (if (< gnus-tmp-score gnus-summary-default-score)
3236 gnus-score-below-mark gnus-score-over-mark)))
3237 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3239 (cond (gnus-tmp-process gnus-process-mark)
3240 ((memq gnus-tmp-current gnus-newsgroup-cached)
3242 (gnus-tmp-replied gnus-replied-mark)
3243 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3244 gnus-forwarded-mark)
3245 ((memq gnus-tmp-current gnus-newsgroup-saved)
3247 ((memq gnus-tmp-number gnus-newsgroup-recent)
3249 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3252 (gnus-tmp-downloaded
3254 gnus-undownloaded-mark)
3255 (gnus-newsgroup-agentized
3256 gnus-downloaded-mark)
3259 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3262 ((string-match "<[^>]+> *$" gnus-tmp-from)
3263 (let ((beg (match-beginning 0)))
3264 (or (and (string-match "^\".+\"" gnus-tmp-from)
3265 (substring gnus-tmp-from 1 (1- (match-end 0))))
3266 (substring gnus-tmp-from 0 beg))))
3267 ((string-match "(.+)" gnus-tmp-from)
3268 (substring gnus-tmp-from
3269 (1+ (match-beginning 0)) (1- (match-end 0))))
3271 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3272 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3273 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3274 (buffer-read-only nil))
3275 (when (string= gnus-tmp-name "")
3276 (setq gnus-tmp-name gnus-tmp-from))
3277 (unless (numberp gnus-tmp-lines)
3278 (setq gnus-tmp-lines -1))
3279 (if (= gnus-tmp-lines -1)
3280 (setq gnus-tmp-lines "?")
3281 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3282 (gnus-put-text-property
3284 (progn (eval gnus-summary-line-format-spec) (point))
3285 'gnus-number gnus-tmp-number)
3286 (when (gnus-visual-p 'summary-highlight 'highlight)
3288 (gnus-run-hooks 'gnus-summary-update-hook)
3291 (defun gnus-summary-update-line (&optional dont-update)
3292 "Update summary line after change."
3293 (when (and gnus-summary-default-score
3294 (not gnus-summary-inhibit-highlight))
3295 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3296 (article (gnus-summary-article-number))
3297 (score (gnus-summary-article-score article)))
3299 (if (and gnus-summary-mark-below
3300 (< (gnus-summary-article-score)
3301 gnus-summary-mark-below))
3302 ;; This article has a low score, so we mark it as read.
3303 (when (memq article gnus-newsgroup-unreads)
3304 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3305 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3306 ;; This article was previously marked as read on account
3307 ;; of a low score, but now it has risen, so we mark it as
3309 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3310 (gnus-summary-update-mark
3311 (if (or (null gnus-summary-default-score)
3312 (<= (abs (- score gnus-summary-default-score))
3313 gnus-summary-zcore-fuzz))
3315 (if (< score gnus-summary-default-score)
3316 gnus-score-below-mark gnus-score-over-mark))
3318 ;; Do visual highlighting.
3319 (when (gnus-visual-p 'summary-highlight 'highlight)
3320 (gnus-run-hooks 'gnus-summary-update-hook)))))
3322 (defvar gnus-tmp-new-adopts nil)
3324 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3325 "Return the number of articles in THREAD.
3326 This may be 0 in some cases -- if none of the articles in
3327 the thread are to be displayed."
3329 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3331 ((not (listp thread))
3333 ((and (consp thread) (cdr thread))
3336 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3339 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3342 (when (and level (zerop level) gnus-tmp-new-adopts)
3345 'gnus-summary-number-of-articles-in-thread
3346 gnus-tmp-new-adopts))))
3348 (if (> number 1) gnus-not-empty-thread-mark
3349 gnus-empty-thread-mark)
3352 (defsubst gnus-summary-line-message-size (head)
3353 "Return pretty-printed version of message size.
3354 This function is intended to be used in
3355 `gnus-summary-line-format-alist', which see."
3356 (let ((c (or (mail-header-chars head) -1)))
3357 (cond ((< c 0) "n/a") ; chars not available
3358 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3359 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3360 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3361 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3364 (defun gnus-summary-set-local-parameters (group)
3365 "Go through the local params of GROUP and set all variable specs in that list."
3366 (let ((params (gnus-group-find-parameter group))
3367 (vars '(quit-config)) ; Ignore quit-config.
3370 (setq elem (car params)
3371 params (cdr params))
3372 (and (consp elem) ; Has to be a cons.
3373 (consp (cdr elem)) ; The cdr has to be a list.
3374 (symbolp (car elem)) ; Has to be a symbol in there.
3375 (not (memq (car elem) vars))
3376 (ignore-errors ; So we set it.
3377 (push (car elem) vars)
3378 (make-local-variable (car elem))
3379 (set (car elem) (eval (nth 1 elem))))))))
3381 (defun gnus-summary-read-group (group &optional show-all no-article
3382 kill-buffer no-display backward
3384 "Start reading news in newsgroup GROUP.
3385 If SHOW-ALL is non-nil, already read articles are also listed.
3386 If NO-ARTICLE is non-nil, no article is selected initially.
3387 If NO-DISPLAY, don't generate a summary buffer."
3391 (let ((gnus-auto-select-next nil))
3392 (or (gnus-summary-read-group-1
3393 group show-all no-article
3394 kill-buffer no-display
3397 select-articles nil)))))
3398 (eq gnus-auto-select-next 'quietly))
3399 (set-buffer gnus-group-buffer)
3400 ;; The entry function called above goes to the next
3401 ;; group automatically, so we go two groups back
3402 ;; if we are searching for the previous group.
3404 (gnus-group-prev-unread-group 2))
3405 (if (not (equal group (gnus-group-group-name)))
3406 (setq group (gnus-group-group-name))
3410 (defun gnus-summary-read-group-1 (group show-all no-article
3411 kill-buffer no-display
3412 &optional select-articles)
3413 ;; Killed foreign groups can't be entered.
3414 ;; (when (and (not (gnus-group-native-p group))
3415 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3416 ;; (error "Dead non-native groups can't be entered"))
3417 (gnus-message 5 "Retrieving newsgroup: %s..."
3418 (gnus-group-decoded-name group))
3419 (let* ((new-group (gnus-summary-setup-buffer group))
3420 (quit-config (gnus-group-quit-config group))
3421 (did-select (and new-group (gnus-select-newsgroup
3422 group show-all select-articles))))
3424 ;; This summary buffer exists already, so we just select it.
3426 (gnus-set-global-variables)
3428 (gnus-kill-or-deaden-summary kill-buffer))
3429 (gnus-configure-windows 'summary 'force)
3430 (gnus-set-mode-line 'summary)
3431 (gnus-summary-position-point)
3434 ;; We couldn't select this group.
3436 (when (and (eq major-mode 'gnus-summary-mode)
3437 (not (equal (current-buffer) kill-buffer)))
3438 (kill-buffer (current-buffer))
3439 (if (not quit-config)
3441 ;; Update the info -- marks might need to be removed,
3443 (gnus-summary-update-info)
3444 (set-buffer gnus-group-buffer)
3445 (gnus-group-jump-to-group group)
3446 (gnus-group-next-unread-group 1))
3447 (gnus-handle-ephemeral-exit quit-config)))
3448 (let ((grpinfo (gnus-get-info group)))
3449 (if (null (gnus-info-read grpinfo))
3450 (gnus-message 3 "Group %s contains no messages"
3451 (gnus-group-decoded-name group))
3452 (gnus-message 3 "Can't select group")))
3454 ;; The user did a `C-g' while prompting for number of articles,
3455 ;; so we exit this group.
3456 ((eq did-select 'quit)
3457 (and (eq major-mode 'gnus-summary-mode)
3458 (not (equal (current-buffer) kill-buffer))
3459 (kill-buffer (current-buffer)))
3461 (gnus-kill-or-deaden-summary kill-buffer))
3462 (if (not quit-config)
3464 (set-buffer gnus-group-buffer)
3465 (gnus-group-jump-to-group group)
3466 (gnus-group-next-unread-group 1)
3467 (gnus-configure-windows 'group 'force))
3468 (gnus-handle-ephemeral-exit quit-config))
3469 ;; Finally signal the quit.
3471 ;; The group was successfully selected.
3473 (gnus-set-global-variables)
3474 ;; Save the active value in effect when the group was entered.
3475 (setq gnus-newsgroup-active
3477 (gnus-active gnus-newsgroup-name)))
3478 ;; You can change the summary buffer in some way with this hook.
3479 (gnus-run-hooks 'gnus-select-group-hook)
3480 (gnus-update-format-specifications
3481 nil 'summary 'summary-mode 'summary-dummy)
3482 (gnus-update-summary-mark-positions)
3483 ;; Do score processing.
3484 (when gnus-use-scoring
3485 (gnus-possibly-score-headers))
3486 ;; Check whether to fill in the gaps in the threads.
3487 (when gnus-build-sparse-threads
3488 (gnus-build-sparse-threads))
3489 ;; Find the initial limit.
3490 (if gnus-show-threads
3492 (let ((gnus-newsgroup-dormant nil))
3493 (gnus-summary-initial-limit show-all))
3494 (gnus-summary-initial-limit show-all))
3495 ;; When unthreaded, all articles are always shown.
3496 (setq gnus-newsgroup-limit
3498 (lambda (header) (mail-header-number header))
3499 gnus-newsgroup-headers)))
3500 ;; Generate the summary buffer.
3502 (gnus-summary-prepare))
3503 (when gnus-use-trees
3504 (gnus-tree-open group)
3505 (setq gnus-summary-highlight-line-function
3506 'gnus-tree-highlight-article))
3507 ;; If the summary buffer is empty, but there are some low-scored
3508 ;; articles or some excluded dormants, we include these in the
3510 (when (and (zerop (buffer-size))
3512 (cond (gnus-newsgroup-dormant
3513 (gnus-summary-limit-include-dormant))
3514 ((and gnus-newsgroup-scored show-all)
3515 (gnus-summary-limit-include-expunged t))))
3516 ;; Function `gnus-apply-kill-file' must be called in this hook.
3517 (gnus-run-hooks 'gnus-apply-kill-hook)
3518 (if (and (zerop (buffer-size))
3521 ;; This newsgroup is empty.
3522 (gnus-summary-catchup-and-exit nil t)
3523 (gnus-message 6 "No unread news")
3525 (gnus-kill-or-deaden-summary kill-buffer))
3526 ;; Return nil from this function.
3528 ;; Hide conversation thread subtrees. We cannot do this in
3529 ;; gnus-summary-prepare-hook since kill processing may not
3530 ;; work with hidden articles.
3531 (gnus-summary-maybe-hide-threads)
3533 (gnus-kill-or-deaden-summary kill-buffer))
3534 (gnus-summary-auto-select-subject)
3535 ;; Show first unread article if requested.
3536 (if (and (not no-article)
3538 gnus-newsgroup-unreads
3539 gnus-auto-select-first)
3541 (gnus-configure-windows 'summary)
3542 (let ((art (gnus-summary-article-number)))
3543 (unless (and (not gnus-plugged)
3544 (or (memq art gnus-newsgroup-undownloaded)
3545 (memq art gnus-newsgroup-downloadable)))
3546 (gnus-summary-goto-article art))))
3547 ;; Don't select any articles.
3548 (gnus-summary-position-point)
3549 (gnus-configure-windows 'summary 'force)
3550 (gnus-set-mode-line 'summary))
3551 (when (and gnus-auto-center-group
3552 (get-buffer-window gnus-group-buffer t))
3553 ;; Gotta use windows, because recenter does weird stuff if
3554 ;; the current buffer ain't the displayed window.
3555 (let ((owin (selected-window)))
3556 (select-window (get-buffer-window gnus-group-buffer t))
3557 (when (gnus-group-goto-group group)
3559 (select-window owin)))
3560 ;; Mark this buffer as "prepared".
3561 (setq gnus-newsgroup-prepared t)
3562 (gnus-run-hooks 'gnus-summary-prepared-hook)
3563 (unless (gnus-ephemeral-group-p group)
3564 (gnus-group-update-group group))
3567 (defun gnus-summary-auto-select-subject ()
3568 "Select the subject line on initial group entry."
3569 (goto-char (point-min))
3571 ((eq gnus-auto-select-subject 'best)
3572 (gnus-summary-best-unread-subject))
3573 ((eq gnus-auto-select-subject 'unread)
3574 (gnus-summary-first-unread-subject))
3575 ((eq gnus-auto-select-subject 'unseen)
3576 (gnus-summary-first-unseen-subject))
3577 ((eq gnus-auto-select-subject 'unseen-or-unread)
3578 (gnus-summary-first-unseen-or-unread-subject))
3579 ((eq gnus-auto-select-subject 'first)
3582 ((gnus-functionp gnus-auto-select-subject)
3583 (funcall gnus-auto-select-subject))))
3585 (defun gnus-summary-prepare ()
3586 "Generate the summary buffer."
3588 (let ((buffer-read-only nil))
3590 (setq gnus-newsgroup-data nil
3591 gnus-newsgroup-data-reverse nil)
3592 (gnus-run-hooks 'gnus-summary-generate-hook)
3593 ;; Generate the buffer, either with threads or without.
3594 (when gnus-newsgroup-headers
3595 (gnus-summary-prepare-threads
3596 (if gnus-show-threads
3597 (gnus-sort-gathered-threads
3598 (funcall gnus-summary-thread-gathering-function
3600 (gnus-cut-threads (gnus-make-threads)))))
3601 ;; Unthreaded display.
3602 (gnus-sort-articles gnus-newsgroup-headers))))
3603 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3604 ;; Call hooks for modifying summary buffer.
3605 (goto-char (point-min))
3606 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3608 (defsubst gnus-general-simplify-subject (subject)
3609 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3612 ;; Truncate the subject.
3613 (gnus-simplify-subject-functions
3614 (gnus-map-function gnus-simplify-subject-functions subject))
3615 ((numberp gnus-summary-gather-subject-limit)
3616 (setq subject (gnus-simplify-subject-re subject))
3617 (if (> (length subject) gnus-summary-gather-subject-limit)
3618 (substring subject 0 gnus-summary-gather-subject-limit)
3620 ;; Fuzzily simplify it.
3621 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3622 (gnus-simplify-subject-fuzzy subject))
3623 ;; Just remove the leading "Re:".
3625 (gnus-simplify-subject-re subject))))
3627 (if (and gnus-summary-gather-exclude-subject
3628 (string-match gnus-summary-gather-exclude-subject subject))
3629 nil ; This article shouldn't be gathered
3632 (defun gnus-summary-simplify-subject-query ()
3633 "Query where the respool algorithm would put this article."
3635 (gnus-summary-select-article)
3636 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3638 (defun gnus-gather-threads-by-subject (threads)
3639 "Gather threads by looking at Subject headers."
3640 (if (not gnus-summary-make-false-root)
3642 (let ((hashtb (gnus-make-hashtable 1024))
3645 subject hthread whole-subject)
3647 (setq subject (gnus-general-simplify-subject
3648 (setq whole-subject (mail-header-subject
3651 (if (setq hthread (gnus-gethash subject hashtb))
3653 ;; We enter a dummy root into the thread, if we
3654 ;; haven't done that already.
3655 (unless (stringp (caar hthread))
3656 (setcar hthread (list whole-subject (car hthread))))
3657 ;; We add this new gathered thread to this gathered
3659 (setcdr (car hthread)
3660 (nconc (cdar hthread) (list (car threads))))
3661 ;; Remove it from the list of threads.
3662 (setcdr prev (cdr threads))
3663 (setq threads prev))
3664 ;; Enter this thread into the hash table.
3665 (gnus-sethash subject
3666 (if gnus-summary-make-false-root-always
3668 ;; If you want a dummy root above all
3670 (setcar threads (list whole-subject
3676 (setq threads (cdr threads)))
3679 (defun gnus-gather-threads-by-references (threads)
3680 "Gather threads by looking at References headers."
3681 (let ((idhashtb (gnus-make-hashtable 1024))
3682 (thhashtb (gnus-make-hashtable 1024))
3685 ids references id gthread gid entered ref)
3687 (when (setq references (mail-header-references (caar threads)))
3688 (setq id (mail-header-id (caar threads))
3689 ids (inline (gnus-split-references references))
3691 (while (setq ref (pop ids))
3692 (setq ids (delete ref ids))
3693 (if (not (setq gid (gnus-gethash ref idhashtb)))
3695 (gnus-sethash ref id idhashtb)
3696 (gnus-sethash id threads thhashtb))
3697 (setq gthread (gnus-gethash gid thhashtb))
3699 ;; We enter a dummy root into the thread, if we
3700 ;; haven't done that already.
3701 (unless (stringp (caar gthread))
3702 (setcar gthread (list (mail-header-subject (caar gthread))
3704 ;; We add this new gathered thread to this gathered
3706 (setcdr (car gthread)
3707 (nconc (cdar gthread) (list (car threads)))))
3708 ;; Add it into the thread hash table.
3709 (gnus-sethash id gthread thhashtb)
3711 ;; Remove it from the list of threads.
3712 (setcdr prev (cdr threads))
3713 (setq threads prev))))
3715 (setq threads (cdr threads)))
3718 (defun gnus-sort-gathered-threads (threads)
3719 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3720 (let ((result threads))
3722 (when (stringp (caar threads))
3723 (setcdr (car threads)
3724 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3725 (setq threads (cdr threads)))
3728 (defun gnus-thread-loop-p (root thread)
3729 "Say whether ROOT is in THREAD."
3730 (let ((stack (list thread))
3733 (while (setq thread (pop stack))
3734 (setq th (cdr thread))
3736 (not (eq (caar th) root)))
3739 ;; We have found a loop.
3741 (setcdr thread (delq (car th) (cdr thread)))
3742 (if (boundp (setq ref-dep (intern "none"
3743 gnus-newsgroup-dependencies)))
3744 (setcdr (symbol-value ref-dep)
3745 (nconc (cdr (symbol-value ref-dep))
3747 (set ref-dep (list nil (car th))))
3750 ;; Push all the subthreads onto the stack.
3751 (push (cdr thread) stack)))
3754 (defun gnus-make-threads ()
3755 "Go through the dependency hashtb and find the roots. Return all threads."
3757 (while (catch 'infloop
3760 ;; Deal with self-referencing References loops.
3761 (when (and (car (symbol-value refs))
3768 (car (symbol-value refs)) thread))
3769 (cdr (symbol-value refs)))))))
3772 (unless (car (symbol-value refs))
3773 ;; These threads do not refer back to any other
3774 ;; articles, so they're roots.
3775 (setq threads (append (cdr (symbol-value refs)) threads))))
3776 gnus-newsgroup-dependencies)))
3779 ;; Build the thread tree.
3780 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3781 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3783 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3784 if it was already present.
3786 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3787 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3788 Message-IDs will be renamed to a unique Message-ID before being
3791 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3792 (let* ((id (mail-header-id header))
3793 (id-dep (and id (intern id dependencies)))
3794 parent-id ref ref-dep ref-header replaced)
3795 ;; Enter this `header' in the `dependencies' table.
3799 ;; The first two cases do the normal part: enter a new `header'
3800 ;; in the `dependencies' table.
3801 ((not (boundp id-dep))
3802 (set id-dep (list header)))
3803 ((null (car (symbol-value id-dep)))
3804 (setcar (symbol-value id-dep) header))
3806 ;; From here the `header' was already present in the
3807 ;; `dependencies' table.
3809 ;; Overrides an existing entry;
3810 ;; just set the header part of the entry.
3811 (setcar (symbol-value id-dep) header)
3814 ;; Renames the existing `header' to a unique Message-ID.
3815 ((not gnus-summary-ignore-duplicates)
3816 ;; An article with this Message-ID has already been seen.
3817 ;; We rename the Message-ID.
3818 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3820 (mail-header-set-id header id))
3822 ;; The last case ignores an existing entry, except it adds any
3823 ;; additional Xrefs (in case the two articles came from different
3825 ;; Also sets `header' to `nil' meaning that the `dependencies'
3826 ;; table was *not* modified.
3828 (mail-header-set-xref
3829 (car (symbol-value id-dep))
3830 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3832 (or (mail-header-xref header) "")))
3835 (when (and header (not replaced))
3836 ;; First check that we are not creating a References loop.
3837 (setq parent-id (gnus-parent-id (mail-header-references header)))
3838 (setq ref parent-id)
3840 (setq ref-dep (intern-soft ref dependencies))
3842 (setq ref-header (car (symbol-value ref-dep))))
3843 (if (string= id ref)
3844 ;; Yuk! This is a reference loop. Make the article be a
3847 (mail-header-set-references (car (symbol-value id-dep)) "none")
3849 (setq parent-id nil))
3850 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3851 (setq ref-dep (intern (or parent-id "none") dependencies))
3852 (if (boundp ref-dep)
3853 (setcdr (symbol-value ref-dep)
3854 (nconc (cdr (symbol-value ref-dep))
3855 (list (symbol-value id-dep))))
3856 (set ref-dep (list nil (symbol-value id-dep)))))
3859 (defun gnus-extract-message-id-from-in-reply-to (string)
3860 (if (string-match "<[^>]+>" string)
3861 (substring string (match-beginning 0) (match-end 0))
3864 (defun gnus-build-sparse-threads ()
3865 (let ((headers gnus-newsgroup-headers)
3866 (mail-parse-charset gnus-newsgroup-charset)
3867 (gnus-summary-ignore-duplicates t)
3868 header references generation relations
3869 subject child end new-child date)
3870 ;; First we create an alist of generations/relations, where
3871 ;; generations is how much we trust the relation, and the relation
3873 (gnus-message 7 "Making sparse threads...")
3875 (nnheader-set-temp-buffer " *gnus sparse threads*")
3876 (while (setq header (pop headers))
3877 (when (and (setq references (mail-header-references header))
3878 (not (string= references "")))
3880 (setq child (mail-header-id header)
3881 subject (mail-header-subject header)
3882 date (mail-header-date header)
3884 (while (search-backward ">" nil t)
3885 (setq end (1+ (point)))
3886 (when (search-backward "<" nil t)
3887 (setq new-child (buffer-substring (point) end))
3888 (push (list (incf generation)
3889 child (setq child new-child)
3893 (push (list (1+ generation) child nil subject) relations))
3895 (kill-buffer (current-buffer)))
3896 ;; Sort over trustworthiness.
3899 (when (gnus-dependencies-add-header
3900 (make-full-mail-header
3901 gnus-reffed-article-number
3902 (nth 3 relation) "" (or (nth 4 relation) "")
3904 (or (nth 2 relation) "") 0 0 "")
3905 gnus-newsgroup-dependencies nil)
3906 (push gnus-reffed-article-number gnus-newsgroup-limit)
3907 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3908 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3909 gnus-newsgroup-reads)
3910 (decf gnus-reffed-article-number)))
3911 (sort relations 'car-less-than-car))
3912 (gnus-message 7 "Making sparse threads...done")))
3914 (defun gnus-build-old-threads ()
3915 ;; Look at all the articles that refer back to old articles, and
3916 ;; fetch the headers for the articles that aren't there. This will
3917 ;; build complete threads - if the roots haven't been expired by the
3919 (let ((mail-parse-charset gnus-newsgroup-charset)
3923 (when (not (car (symbol-value refs)))
3924 (setq heads (cdr (symbol-value refs)))
3926 (if (memq (mail-header-number (caar heads))
3927 gnus-newsgroup-dormant)
3928 (setq heads (cdr heads))
3929 (setq id (symbol-name refs))
3930 (while (and (setq id (gnus-build-get-header id))
3931 (not (car (gnus-id-to-thread id)))))
3932 (setq heads nil)))))
3933 gnus-newsgroup-dependencies)))
3935 ;; This function has to be called with point after the article number
3936 ;; on the beginning of the line.
3937 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3938 (let ((eol (gnus-point-at-eol))
3939 (buffer (current-buffer))
3940 header references in-reply-to)
3942 ;; overview: [num subject from date id refs chars lines misc]
3945 (narrow-to-region (point) eol)
3950 (make-full-mail-header
3952 (condition-case () ; subject
3953 (funcall gnus-decode-encoded-word-function
3954 (setq x (nnheader-nov-field)))
3956 (condition-case () ; from
3957 (funcall gnus-decode-encoded-word-function
3958 (setq x (nnheader-nov-field)))
3960 (nnheader-nov-field) ; date
3961 (nnheader-nov-read-message-id) ; id
3962 (setq references (nnheader-nov-field)) ; refs
3963 (nnheader-nov-read-integer) ; chars
3964 (nnheader-nov-read-integer) ; lines
3966 (if (looking-at "Xref: ")
3967 (goto-char (match-end 0)))
3968 (nnheader-nov-field)) ; Xref
3969 (nnheader-nov-parse-extra)))) ; extra
3973 (when (and (string= references "")
3974 (setq in-reply-to (mail-header-extra header))
3975 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3976 (mail-header-set-references
3977 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3979 (when gnus-alter-header-function
3980 (funcall gnus-alter-header-function header))
3981 (gnus-dependencies-add-header header dependencies force-new)))
3983 (defun gnus-build-get-header (id)
3984 "Look through the buffer of NOV lines and find the header to ID.
3985 Enter this line into the dependencies hash table, and return
3986 the id of the parent article (if any)."
3987 (let ((deps gnus-newsgroup-dependencies)
3991 (set-buffer nntp-server-buffer)
3992 (let ((case-fold-search nil))
3993 (goto-char (point-min))
3994 (while (and (not found)
3995 (search-forward id nil t))
3997 (setq found (looking-at
3998 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3999 (regexp-quote id))))
4000 (or found (beginning-of-line 2)))
4004 (setq header (gnus-nov-parse-line
4005 (read (current-buffer)) deps))
4006 (gnus-parent-id (mail-header-references header))))))
4008 (let ((number (mail-header-number header)))
4009 (push number gnus-newsgroup-limit)
4010 (push header gnus-newsgroup-headers)
4011 (if (memq number gnus-newsgroup-unselected)
4013 (setq gnus-newsgroup-unreads
4014 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4016 (setq gnus-newsgroup-unselected
4017 (delq number gnus-newsgroup-unselected)))
4018 (push number gnus-newsgroup-ancient)))))))
4020 (defun gnus-build-all-threads ()
4021 "Read all the headers."
4022 (let ((gnus-summary-ignore-duplicates t)
4023 (mail-parse-charset gnus-newsgroup-charset)
4024 (dependencies gnus-newsgroup-dependencies)
4027 (set-buffer nntp-server-buffer)
4028 (let ((case-fold-search nil))
4029 (goto-char (point-min))
4032 (setq article (read (current-buffer))
4033 header (gnus-nov-parse-line article dependencies)))
4036 (set-buffer gnus-summary-buffer)
4037 (push header gnus-newsgroup-headers)
4038 (if (memq (setq article (mail-header-number header))
4039 gnus-newsgroup-unselected)
4041 (setq gnus-newsgroup-unreads
4042 (gnus-add-to-sorted-list
4043 gnus-newsgroup-unreads article))
4044 (setq gnus-newsgroup-unselected
4045 (delq article gnus-newsgroup-unselected)))
4046 (push article gnus-newsgroup-ancient)))
4047 (forward-line 1)))))))
4049 (defun gnus-summary-update-article-line (article header)
4050 "Update the line for ARTICLE using HEADERS."
4051 (let* ((id (mail-header-id header))
4052 (thread (gnus-id-to-thread id)))
4054 (error "Article in no thread"))
4055 ;; Update the thread.
4056 (setcar thread header)
4057 (gnus-summary-goto-subject article)
4058 (let* ((datal (gnus-data-find-list article))
4060 (buffer-read-only nil)
4061 (level (gnus-summary-thread-level)))
4063 (let ((inserted (- (point)
4065 (gnus-summary-insert-line
4067 (memq article gnus-newsgroup-undownloaded)
4068 (gnus-article-mark article)
4069 (memq article gnus-newsgroup-replied)
4070 (memq article gnus-newsgroup-expirable)
4071 ;; Only insert the Subject string when it's different
4072 ;; from the previous Subject string.
4077 (mail-header-subject
4080 (gnus-data-find-list
4082 (gnus-data-list t)))))
4083 ;; Error on the side of excessive subjects.
4085 (mail-header-subject header)))
4087 (mail-header-subject header))
4088 nil (cdr (assq article gnus-newsgroup-scored))
4089 (memq article gnus-newsgroup-processable))
4092 (gnus-data-update-list
4094 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4096 (defun gnus-summary-update-article (article &optional iheader)
4097 "Update ARTICLE in the summary buffer."
4098 (set-buffer gnus-summary-buffer)
4099 (let* ((header (gnus-summary-article-header article))
4100 (id (mail-header-id header))
4101 (data (gnus-data-find article))
4102 (thread (gnus-id-to-thread id))
4103 (references (mail-header-references header))
4107 (when (and references
4108 (not (equal "" references)))
4111 (buffer-read-only nil)
4117 (delq thread parent)))
4118 (if (gnus-summary-insert-subject id header)
4119 ;; Set the (possibly) new article number in the data structure.
4120 (gnus-data-set-number data (gnus-id-to-article id))
4124 (defun gnus-rebuild-thread (id &optional line)
4125 "Rebuild the thread containing ID.
4126 If LINE, insert the rebuilt thread starting on line LINE."
4127 (let ((buffer-read-only nil)
4128 old-pos current thread data)
4129 (if (not gnus-show-threads)
4130 (setq thread (list (car (gnus-id-to-thread id))))
4131 ;; Get the thread this article is part of.
4132 (setq thread (gnus-remove-thread id)))
4133 (setq old-pos (gnus-point-at-bol))
4134 (setq current (save-excursion
4135 (and (re-search-backward "[\r\n]" nil t)
4136 (gnus-summary-article-number))))
4137 ;; If this is a gathered thread, we have to go some re-gathering.
4138 (when (stringp (car thread))
4139 (let ((subject (car thread))
4141 (setq thread (cdr thread))
4143 (unless (memq (setq thr (gnus-id-to-thread
4145 (mail-header-id (caar thread)))))
4148 (setq thread (cdr thread)))
4149 ;; We now have all (unique) roots.
4150 (if (= (length roots) 1)
4151 ;; All the loose roots are now one solid root.
4152 (setq thread (car roots))
4153 (setq thread (cons subject (gnus-sort-threads roots))))))
4155 ;; We then insert this thread into the summary buffer.
4157 (goto-char (point-min))
4158 (forward-line (1- line)))
4159 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4160 (if gnus-show-threads
4161 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4162 (gnus-summary-prepare-unthreaded thread))
4163 (setq data (nreverse gnus-newsgroup-data))
4164 (setq threads gnus-newsgroup-threads))
4165 ;; We splice the new data into the data structure.
4166 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4167 ;;!!! then we want to insert at the beginning of the buffer.
4168 ;;!!! That happens to be true with Gnus now, but that may
4169 ;;!!! change in the future. Perhaps.
4170 (gnus-data-enter-list
4171 (if line nil current) data (- (point) old-pos))
4172 (setq gnus-newsgroup-threads
4173 (nconc threads gnus-newsgroup-threads))
4174 (gnus-data-compute-positions))))
4176 (defun gnus-number-to-header (number)
4177 "Return the header for article NUMBER."
4178 (let ((headers gnus-newsgroup-headers))
4180 (not (= number (mail-header-number (car headers)))))
4185 (defun gnus-parent-headers (in-headers &optional generation)
4186 "Return the headers of the GENERATIONeth parent of HEADERS."
4188 (setq generation 1))
4190 (headers in-headers)
4193 (not (zerop generation))
4194 (setq references (mail-header-references headers)))
4195 (setq headers (if (and references
4196 (setq parent (gnus-parent-id references)))
4197 (car (gnus-id-to-thread parent))
4200 (and (not (eq headers in-headers))
4203 (defun gnus-id-to-thread (id)
4204 "Return the (sub-)thread where ID appears."
4205 (gnus-gethash id gnus-newsgroup-dependencies))
4207 (defun gnus-id-to-article (id)
4208 "Return the article number of ID."
4209 (let ((thread (gnus-id-to-thread id)))
4212 (mail-header-number (car thread)))))
4214 (defun gnus-id-to-header (id)
4215 "Return the article headers of ID."
4216 (car (gnus-id-to-thread id)))
4218 (defun gnus-article-displayed-root-p (article)
4219 "Say whether ARTICLE is a root(ish) article."
4220 (let ((level (gnus-summary-thread-level article))
4221 (refs (mail-header-references (gnus-summary-article-header article)))
4227 ((null (gnus-parent-id refs)) t)
4229 (null (setq particle (gnus-id-to-article
4230 (gnus-parent-id refs))))
4231 (null (gnus-summary-thread-level particle)))))))
4233 (defun gnus-root-id (id)
4234 "Return the id of the root of the thread where ID appears."
4236 (while (and id (setq prev (car (gnus-id-to-thread id))))
4238 id (gnus-parent-id (mail-header-references prev))))
4241 (defun gnus-articles-in-thread (thread)
4242 "Return the list of articles in THREAD."
4243 (cons (mail-header-number (car thread))
4244 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4246 (defun gnus-remove-thread (id &optional dont-remove)
4247 "Remove the thread that has ID in it."
4248 (let (headers thread last-id)
4249 ;; First go up in this thread until we find the root.
4250 (setq last-id (gnus-root-id id)
4251 headers (message-flatten-list (gnus-id-to-thread last-id)))
4252 ;; We have now found the real root of this thread. It might have
4253 ;; been gathered into some loose thread, so we have to search
4254 ;; through the threads to find the thread we wanted.
4255 (let ((threads gnus-newsgroup-threads)
4258 (setq sub (car threads))
4259 (if (stringp (car sub))
4260 ;; This is a gathered thread, so we look at the roots
4261 ;; below it to find whether this article is in this
4264 (setq sub (cdr sub))
4266 (when (member (caar sub) headers)
4267 (setq thread (car threads)
4270 (setq sub (cdr sub))))
4271 ;; It's an ordinary thread, so we check it.
4272 (when (eq (car sub) (car headers))
4275 (setq threads (cdr threads)))
4276 ;; If this article is in no thread, then it's a root.
4279 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4280 (setq thread (gnus-id-to-thread last-id)))
4283 thread ; We return this thread.
4285 (if (stringp (car thread))
4287 ;; If we use dummy roots, then we have to remove the
4288 ;; dummy root as well.
4289 (when (eq gnus-summary-make-false-root 'dummy)
4290 ;; We go to the dummy root by going to
4291 ;; the first sub-"thread", and then one line up.
4292 (gnus-summary-goto-article
4293 (mail-header-number (caadr thread)))
4296 (gnus-data-compute-positions))
4297 (setq thread (cdr thread))
4299 (gnus-remove-thread-1 (car thread))
4300 (setq thread (cdr thread))))
4301 (gnus-remove-thread-1 thread))))))))
4303 (defun gnus-remove-thread-1 (thread)
4304 "Remove the thread THREAD recursively."
4305 (let ((number (mail-header-number (pop thread)))
4307 (setq thread (reverse thread))
4309 (gnus-remove-thread-1 (pop thread)))
4310 (when (setq d (gnus-data-find number))
4311 (goto-char (gnus-data-pos d))
4312 (gnus-summary-show-thread)
4315 (- (gnus-point-at-bol)
4317 (1+ (gnus-point-at-eol))
4318 (gnus-delete-line)))))))
4320 (defun gnus-sort-threads-1 (threads func)
4321 (sort (mapcar (lambda (thread)
4324 (gnus-sort-threads-1 (cdr thread) func))))
4327 (defun gnus-sort-threads (threads)
4329 (if (not gnus-thread-sort-functions)
4331 (gnus-message 8 "Sorting threads...")
4332 (let ((max-lisp-eval-depth 5000))
4333 (prog1 (gnus-sort-threads-1
4335 (gnus-make-sort-function gnus-thread-sort-functions))
4336 (gnus-message 8 "Sorting threads...done")))))
4338 (defun gnus-sort-articles (articles)
4340 (when gnus-article-sort-functions
4341 (gnus-message 7 "Sorting articles...")
4343 (setq gnus-newsgroup-headers
4344 (sort articles (gnus-make-sort-function
4345 gnus-article-sort-functions)))
4346 (gnus-message 7 "Sorting articles...done"))))
4348 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4349 (defmacro gnus-thread-header (thread)
4350 "Return header of first article in THREAD.
4351 Note that THREAD must never, ever be anything else than a variable -
4352 using some other form will lead to serious barfage."
4353 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4354 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4355 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4358 (defsubst gnus-article-sort-by-number (h1 h2)
4359 "Sort articles by article number."
4360 (< (mail-header-number h1)
4361 (mail-header-number h2)))
4363 (defun gnus-thread-sort-by-number (h1 h2)
4364 "Sort threads by root article number."
4365 (gnus-article-sort-by-number
4366 (gnus-thread-header h1) (gnus-thread-header h2)))
4368 (defsubst gnus-article-sort-by-random (h1 h2)
4369 "Sort articles by article number."
4372 (defun gnus-thread-sort-by-random (h1 h2)
4373 "Sort threads by root article number."
4374 (gnus-article-sort-by-random
4375 (gnus-thread-header h1) (gnus-thread-header h2)))
4377 (defsubst gnus-article-sort-by-lines (h1 h2)
4378 "Sort articles by article Lines header."
4379 (< (mail-header-lines h1)
4380 (mail-header-lines h2)))
4382 (defun gnus-thread-sort-by-lines (h1 h2)
4383 "Sort threads by root article Lines header."
4384 (gnus-article-sort-by-lines
4385 (gnus-thread-header h1) (gnus-thread-header h2)))
4387 (defsubst gnus-article-sort-by-chars (h1 h2)
4388 "Sort articles by octet length."
4389 (< (mail-header-chars h1)
4390 (mail-header-chars h2)))
4392 (defun gnus-thread-sort-by-chars (h1 h2)
4393 "Sort threads by root article octet length."
4394 (gnus-article-sort-by-chars
4395 (gnus-thread-header h1) (gnus-thread-header h2)))
4397 (defsubst gnus-article-sort-by-author (h1 h2)
4398 "Sort articles by root author."
4400 (let ((extract (funcall
4401 gnus-extract-address-components
4402 (mail-header-from h1))))
4403 (or (car extract) (cadr extract) ""))
4404 (let ((extract (funcall
4405 gnus-extract-address-components
4406 (mail-header-from h2))))
4407 (or (car extract) (cadr extract) ""))))
4409 (defun gnus-thread-sort-by-author (h1 h2)
4410 "Sort threads by root author."
4411 (gnus-article-sort-by-author
4412 (gnus-thread-header h1) (gnus-thread-header h2)))
4414 (defsubst gnus-article-sort-by-subject (h1 h2)
4415 "Sort articles by root subject."
4417 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4418 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4420 (defun gnus-thread-sort-by-subject (h1 h2)
4421 "Sort threads by root subject."
4422 (gnus-article-sort-by-subject
4423 (gnus-thread-header h1) (gnus-thread-header h2)))
4425 (defsubst gnus-article-sort-by-date (h1 h2)
4426 "Sort articles by root article date."
4428 (gnus-date-get-time (mail-header-date h1))
4429 (gnus-date-get-time (mail-header-date h2))))
4431 (defun gnus-thread-sort-by-date (h1 h2)
4432 "Sort threads by root article date."
4433 (gnus-article-sort-by-date
4434 (gnus-thread-header h1) (gnus-thread-header h2)))
4436 (defsubst gnus-article-sort-by-score (h1 h2)
4437 "Sort articles by root article score.
4438 Unscored articles will be counted as having a score of zero."
4439 (> (or (cdr (assq (mail-header-number h1)
4440 gnus-newsgroup-scored))
4441 gnus-summary-default-score 0)
4442 (or (cdr (assq (mail-header-number h2)
4443 gnus-newsgroup-scored))
4444 gnus-summary-default-score 0)))
4446 (defun gnus-thread-sort-by-score (h1 h2)
4447 "Sort threads by root article score."
4448 (gnus-article-sort-by-score
4449 (gnus-thread-header h1) (gnus-thread-header h2)))
4451 (defun gnus-thread-sort-by-total-score (h1 h2)
4452 "Sort threads by the sum of all scores in the thread.
4453 Unscored articles will be counted as having a score of zero."
4454 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4456 (defun gnus-thread-total-score (thread)
4457 ;; This function find the total score of THREAD.
4462 (if (stringp (car thread))
4463 (apply gnus-thread-score-function 0
4464 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4465 (gnus-thread-total-score-1 thread)))
4467 (gnus-thread-total-score-1 (list thread)))))
4469 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4470 "Sort threads such that the thread with the most recently arrived article comes first."
4471 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4473 (defun gnus-thread-highest-number (thread)
4474 "Return the highest article number in THREAD."
4475 (apply 'max (mapcar (lambda (header)
4476 (mail-header-number header))
4477 (message-flatten-list thread))))
4479 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4480 "Sort threads such that the thread with the most recently dated article comes first."
4481 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4483 (defun gnus-thread-latest-date (thread)
4484 "Return the highest article date in THREAD."
4485 (let ((previous-time 0))
4492 (mail-header-parse-date (mail-header-date header))
4493 (error previous-time)))))
4495 (message-flatten-list thread)
4497 (< (mail-header-number h1)
4498 (mail-header-number h2))))))))
4500 (defun gnus-thread-total-score-1 (root)
4501 ;; This function find the total score of the thread below ROOT.
4502 (setq root (car root))
4503 (apply gnus-thread-score-function
4505 (mapcar 'gnus-thread-total-score
4506 (cdr (gnus-id-to-thread (mail-header-id root))))
4507 (when (> (mail-header-number root) 0)
4508 (list (or (cdr (assq (mail-header-number root)
4509 gnus-newsgroup-scored))
4510 gnus-summary-default-score 0))))
4511 (list gnus-summary-default-score)
4514 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4515 (defvar gnus-tmp-prev-subject nil)
4516 (defvar gnus-tmp-false-parent nil)
4517 (defvar gnus-tmp-root-expunged nil)
4518 (defvar gnus-tmp-dummy-line nil)
4520 (eval-when-compile (defvar gnus-tmp-header))
4521 (defun gnus-extra-header (type &optional header)
4522 "Return the extra header of TYPE."
4523 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4526 (defvar gnus-tmp-thread-tree-header-string "")
4528 (defcustom gnus-sum-thread-tree-root "> "
4529 "With %B spec, used for the root of a thread.
4530 If nil, use subject instead."
4532 :group 'gnus-thread)
4533 (defcustom gnus-sum-thread-tree-single-indent ""
4534 "With %B spec, used for a thread with just one message.
4535 If nil, use subject instead."
4537 :group 'gnus-thread)
4538 (defcustom gnus-sum-thread-tree-vertical "| "
4539 "With %B spec, used for drawing a vertical line."
4541 :group 'gnus-thread)
4542 (defcustom gnus-sum-thread-tree-indent " "
4543 "With %B spec, used for indenting."
4545 :group 'gnus-thread)
4546 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4547 "With %B spec, used for a leaf with brothers."
4549 :group 'gnus-thread)
4550 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4551 "With %B spec, used for a leaf without brothers."
4553 :group 'gnus-thread)
4555 (defun gnus-summary-prepare-threads (threads)
4556 "Prepare summary buffer from THREADS and indentation LEVEL.
4557 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4558 or a straight list of headers."
4559 (gnus-message 7 "Generating summary...")
4561 (setq gnus-newsgroup-threads threads)
4564 (let ((gnus-tmp-level 0)
4565 (default-score (or gnus-summary-default-score 0))
4566 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4567 (building-line-count gnus-summary-display-while-building)
4568 (building-count (integerp gnus-summary-display-while-building))
4569 thread number subject stack state gnus-tmp-gathered beg-match
4570 new-roots gnus-tmp-new-adopts thread-end simp-subject
4571 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4572 gnus-tmp-replied gnus-tmp-subject-or-nil
4573 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4574 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4575 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4578 (setq gnus-tmp-prev-subject nil
4579 gnus-tmp-thread-tree-header-string "")
4581 (if (vectorp (car threads))
4582 ;; If this is a straight (sic) list of headers, then a
4583 ;; threaded summary display isn't required, so we just create
4584 ;; an unthreaded one.
4585 (gnus-summary-prepare-unthreaded threads)
4587 ;; Do the threaded display.
4589 (if gnus-summary-display-while-building
4590 (switch-to-buffer (buffer-name)))
4591 (while (or threads stack gnus-tmp-new-adopts new-roots)
4593 (if (and (= gnus-tmp-level 0)
4596 (not gnus-tmp-false-parent)
4597 (or gnus-tmp-new-adopts new-roots))
4598 (if gnus-tmp-new-adopts
4599 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4600 thread (list (car gnus-tmp-new-adopts))
4601 gnus-tmp-header (caar thread)
4602 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4604 (setq thread (list (car new-roots))
4605 gnus-tmp-header (caar thread)
4606 new-roots (cdr new-roots))))
4609 ;; If there are some threads, we do them before the
4610 ;; threads on the stack.
4611 (setq thread threads
4612 gnus-tmp-header (caar thread))
4613 ;; There were no current threads, so we pop something off
4615 (setq state (car stack)
4616 gnus-tmp-level (car state)
4617 tree-stack (cadr state)
4618 thread (caddr state)
4620 gnus-tmp-header (caar thread))))
4622 (setq gnus-tmp-false-parent nil)
4623 (setq gnus-tmp-root-expunged nil)
4624 (setq thread-end nil)
4626 (if (stringp gnus-tmp-header)
4627 ;; The header is a dummy root.
4629 ((eq gnus-summary-make-false-root 'adopt)
4630 ;; We let the first article adopt the rest.
4631 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4633 (setq gnus-tmp-gathered
4635 (lambda (h) (mail-header-number (car h)))
4638 (setq thread (cons (list (caar thread)
4641 (setq gnus-tmp-level -1
4642 gnus-tmp-false-parent t))
4643 ((eq gnus-summary-make-false-root 'empty)
4644 ;; We print adopted articles with empty subject fields.
4645 (setq gnus-tmp-gathered
4647 (lambda (h) (mail-header-number (car h)))
4650 (setq gnus-tmp-level -1))
4651 ((eq gnus-summary-make-false-root 'dummy)
4652 ;; We remember that we probably want to output a dummy
4654 (setq gnus-tmp-dummy-line gnus-tmp-header)
4655 (setq gnus-tmp-prev-subject gnus-tmp-header))
4657 ;; We do not make a root for the gathered
4658 ;; sub-threads at all.
4659 (setq gnus-tmp-level -1)))
4661 (setq number (mail-header-number gnus-tmp-header)
4662 subject (mail-header-subject gnus-tmp-header)
4663 simp-subject (gnus-simplify-subject-fully subject))
4666 ;; If the thread has changed subject, we might want to make
4667 ;; this subthread into a root.
4668 ((and (null gnus-thread-ignore-subject)
4669 (not (zerop gnus-tmp-level))
4670 gnus-tmp-prev-subject
4671 (not (string= gnus-tmp-prev-subject simp-subject)))
4672 (setq new-roots (nconc new-roots (list (car thread)))
4674 gnus-tmp-header nil))
4675 ;; If the article lies outside the current limit,
4676 ;; then we do not display it.
4677 ((not (memq number gnus-newsgroup-limit))
4678 (setq gnus-tmp-gathered
4680 (lambda (h) (mail-header-number (car h)))
4683 (setq gnus-tmp-new-adopts (if (cdar thread)
4684 (append gnus-tmp-new-adopts
4686 gnus-tmp-new-adopts)
4688 gnus-tmp-header nil)
4689 (when (zerop gnus-tmp-level)
4690 (setq gnus-tmp-root-expunged t)))
4691 ;; Perhaps this article is to be marked as read?
4692 ((and gnus-summary-mark-below
4693 (< (or (cdr (assq number gnus-newsgroup-scored))
4695 gnus-summary-mark-below)
4696 ;; Don't touch sparse articles.
4697 (not (gnus-summary-article-sparse-p number))
4698 (not (gnus-summary-article-ancient-p number)))
4699 (setq gnus-newsgroup-unreads
4700 (delq number gnus-newsgroup-unreads))
4701 (if gnus-newsgroup-auto-expire
4702 (setq gnus-newsgroup-expirable
4703 (gnus-add-to-sorted-list
4704 gnus-newsgroup-expirable number))
4705 (push (cons number gnus-low-score-mark)
4706 gnus-newsgroup-reads))))
4708 (when gnus-tmp-header
4709 ;; We may have an old dummy line to output before this
4711 (when (and gnus-tmp-dummy-line
4714 (mail-header-subject gnus-tmp-header)))
4715 (gnus-summary-insert-dummy-line
4716 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4717 (setq gnus-tmp-dummy-line nil))
4719 ;; Compute the mark.
4720 (setq gnus-tmp-unread (gnus-article-mark number))
4722 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4723 gnus-tmp-header gnus-tmp-level)
4724 gnus-newsgroup-data)
4726 ;; Actually insert the line.
4728 gnus-tmp-subject-or-nil
4730 ((and gnus-thread-ignore-subject
4731 gnus-tmp-prev-subject
4732 (not (string= gnus-tmp-prev-subject simp-subject)))
4734 ((zerop gnus-tmp-level)
4735 (if (and (eq gnus-summary-make-false-root 'empty)
4736 (memq number gnus-tmp-gathered)
4737 gnus-tmp-prev-subject
4738 (string= gnus-tmp-prev-subject simp-subject))
4739 gnus-summary-same-subject
4741 (t gnus-summary-same-subject)))
4742 (if (and (eq gnus-summary-make-false-root 'adopt)
4743 (= gnus-tmp-level 1)
4744 (memq number gnus-tmp-gathered))
4745 (setq gnus-tmp-opening-bracket ?\<
4746 gnus-tmp-closing-bracket ?\>)
4747 (setq gnus-tmp-opening-bracket ?\[
4748 gnus-tmp-closing-bracket ?\]))
4750 gnus-tmp-indentation
4751 (aref gnus-thread-indent-array gnus-tmp-level)
4752 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4753 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4754 gnus-summary-default-score 0)
4756 (if (or (null gnus-summary-default-score)
4757 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4758 gnus-summary-zcore-fuzz))
4760 (if (< gnus-tmp-score gnus-summary-default-score)
4761 gnus-score-below-mark gnus-score-over-mark))
4763 (cond ((memq number gnus-newsgroup-processable)
4765 ((memq number gnus-newsgroup-cached)
4767 ((memq number gnus-newsgroup-replied)
4769 ((memq number gnus-newsgroup-forwarded)
4770 gnus-forwarded-mark)
4771 ((memq number gnus-newsgroup-saved)
4773 ((memq number gnus-newsgroup-recent)
4775 ((memq number gnus-newsgroup-unseen)
4779 (cond ((memq number gnus-newsgroup-undownloaded)
4780 gnus-undownloaded-mark)
4781 (gnus-newsgroup-agentized
4782 gnus-downloaded-mark)
4785 gnus-tmp-from (mail-header-from gnus-tmp-header)
4788 ((string-match "<[^>]+> *$" gnus-tmp-from)
4789 (setq beg-match (match-beginning 0))
4790 (or (and (string-match "^\".+\"" gnus-tmp-from)
4791 (substring gnus-tmp-from 1 (1- (match-end 0))))
4792 (substring gnus-tmp-from 0 beg-match)))
4793 ((string-match "(.+)" gnus-tmp-from)
4794 (substring gnus-tmp-from
4795 (1+ (match-beginning 0)) (1- (match-end 0))))
4797 gnus-tmp-thread-tree-header-string
4799 ((not gnus-show-threads) "")
4800 ((zerop gnus-tmp-level)
4802 (or gnus-sum-thread-tree-root subject)
4803 (or gnus-sum-thread-tree-single-indent subject)))
4805 (concat (apply 'concat
4806 (mapcar (lambda (item)
4808 gnus-sum-thread-tree-vertical
4809 gnus-sum-thread-tree-indent))
4810 (cdr (reverse tree-stack))))
4812 gnus-sum-thread-tree-leaf-with-other
4813 gnus-sum-thread-tree-single-leaf)))))
4814 (when (string= gnus-tmp-name "")
4815 (setq gnus-tmp-name gnus-tmp-from))
4816 (unless (numberp gnus-tmp-lines)
4817 (setq gnus-tmp-lines -1))
4818 (if (= gnus-tmp-lines -1)
4819 (setq gnus-tmp-lines "?")
4820 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4821 (gnus-put-text-property
4823 (progn (eval gnus-summary-line-format-spec) (point))
4824 'gnus-number number)
4827 (gnus-run-hooks 'gnus-summary-update-hook)
4830 (setq gnus-tmp-prev-subject simp-subject)))
4832 (when (nth 1 thread)
4833 (push (list (max 0 gnus-tmp-level)
4834 (copy-list tree-stack)
4837 (push (if (nth 1 thread) 1 0) tree-stack)
4838 (incf gnus-tmp-level)
4839 (setq threads (if thread-end nil (cdar thread)))
4840 (if gnus-summary-display-while-building
4843 ;; use a set frequency
4844 (setq building-line-count (1- building-line-count))
4845 (when (= building-line-count 0)
4847 (setq building-line-count
4848 gnus-summary-display-while-building)))
4852 (setq gnus-tmp-level 0)))))
4853 (gnus-message 7 "Generating summary...done"))
4855 (defun gnus-summary-prepare-unthreaded (headers)
4856 "Generate an unthreaded summary buffer based on HEADERS."
4857 (let (header number mark)
4862 ;; We may have to root out some bad articles...
4863 (when (memq (setq number (mail-header-number
4864 (setq header (pop headers))))
4865 gnus-newsgroup-limit)
4866 ;; Mark article as read when it has a low score.
4867 (when (and gnus-summary-mark-below
4868 (< (or (cdr (assq number gnus-newsgroup-scored))
4869 gnus-summary-default-score 0)
4870 gnus-summary-mark-below)
4871 (not (gnus-summary-article-ancient-p number)))
4872 (setq gnus-newsgroup-unreads
4873 (delq number gnus-newsgroup-unreads))
4874 (if gnus-newsgroup-auto-expire
4875 (push number gnus-newsgroup-expirable)
4876 (push (cons number gnus-low-score-mark)
4877 gnus-newsgroup-reads)))
4879 (setq mark (gnus-article-mark number))
4880 (push (gnus-data-make number mark (1+ (point)) header 0)
4881 gnus-newsgroup-data)
4882 (gnus-summary-insert-line
4884 (memq number gnus-newsgroup-undownloaded)
4885 mark (memq number gnus-newsgroup-replied)
4886 (memq number gnus-newsgroup-expirable)
4887 (mail-header-subject header) nil
4888 (cdr (assq number gnus-newsgroup-scored))
4889 (memq number gnus-newsgroup-processable))))))
4891 (defun gnus-summary-remove-list-identifiers ()
4892 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4893 (let ((regexp (if (consp gnus-list-identifiers)
4894 (mapconcat 'identity gnus-list-identifiers " *\\|")
4895 gnus-list-identifiers))
4898 (dolist (header gnus-newsgroup-headers)
4899 (setq subject (mail-header-subject header)
4901 (while (string-match
4902 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4905 (concat (substring subject 0 (match-beginning 2))
4906 (substring subject (match-end 0)))
4910 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4912 (concat (substring subject 0 (match-beginning 1))
4913 (substring subject (match-end 1)))))
4915 (mail-header-set-subject header subject))))))
4917 (defun gnus-fetch-headers (articles)
4918 "Fetch headers of ARTICLES."
4919 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4920 (gnus-message 5 "Fetching headers for %s..." name)
4923 (setq gnus-headers-retrieved-by
4924 (gnus-retrieve-headers
4925 articles gnus-newsgroup-name
4926 ;; We might want to fetch old headers, but
4927 ;; not if there is only 1 article.
4929 (not (eq gnus-fetch-old-headers 'some))
4930 (not (numberp gnus-fetch-old-headers)))
4931 (> (length articles) 1))
4932 gnus-fetch-old-headers))))
4933 (gnus-get-newsgroup-headers-xover
4934 articles nil nil gnus-newsgroup-name t)
4935 (gnus-get-newsgroup-headers))
4936 (gnus-message 5 "Fetching headers for %s...done" name))))
4938 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4939 "Select newsgroup GROUP.
4940 If READ-ALL is non-nil, all articles in the group are selected.
4941 If SELECT-ARTICLES, only select those articles from GROUP."
4942 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4943 ;;!!! Dirty hack; should be removed.
4944 (gnus-summary-ignore-duplicates
4945 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4947 gnus-summary-ignore-duplicates))
4948 (info (nth 2 entry))
4949 articles fetched-articles cached)
4951 (unless (gnus-check-server
4952 (set (make-local-variable 'gnus-current-select-method)
4953 (gnus-find-method-for-group group)))
4954 (error "Couldn't open server"))
4956 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4957 (gnus-activate-group group) ; Or we can activate it...
4958 (progn ; Or we bug out.
4959 (when (equal major-mode 'gnus-summary-mode)
4960 (gnus-kill-buffer (current-buffer)))
4961 (error "Couldn't activate group %s: %s"
4962 group (gnus-status-message group))))
4964 (unless (gnus-request-group group t)
4965 (when (equal major-mode 'gnus-summary-mode)
4966 (gnus-kill-buffer (current-buffer)))
4967 (error "Couldn't request group %s: %s"
4968 group (gnus-status-message group)))
4970 (setq gnus-newsgroup-name group
4971 gnus-newsgroup-unselected nil
4972 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4974 (let ((display (gnus-group-find-parameter group 'display)))
4975 (setq gnus-newsgroup-display
4977 ((not (zerop (or (car-safe read-all) 0)))
4978 ;; The user entered the group with C-u SPC/RET, let's show
4984 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4986 ;; The following is probably the "correct" solution, but
4987 ;; it makes Gnus fetch all headers and then limit the
4988 ;; articles (which is slow), so instead we hack the
4989 ;; select-articles parameter instead. -- Simon Josefsson
4992 ;; (gnus-byte-compile
4993 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4995 (setq select-articles
4996 (gnus-uncompress-range
4997 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5001 (cdr (gnus-active group)))))
5006 (gnus-summary-setup-default-charset)
5008 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5009 (when (gnus-virtual-group-p group)
5010 (setq cached gnus-newsgroup-cached))
5012 (setq gnus-newsgroup-unreads
5013 (gnus-sorted-ndifference
5014 (gnus-sorted-ndifference gnus-newsgroup-unreads
5015 gnus-newsgroup-marked)
5016 gnus-newsgroup-dormant))
5018 (setq gnus-newsgroup-processable nil)
5020 (gnus-update-read-articles group gnus-newsgroup-unreads)
5022 ;; Adjust and set lists of article marks.
5024 (gnus-adjust-marked-articles info))
5025 (if (setq articles select-articles)
5026 (setq gnus-newsgroup-unselected
5027 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5028 (setq articles (gnus-articles-to-read group read-all)))
5032 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5034 ((eq articles 0) nil)
5036 ;; Init the dependencies hash table.
5037 (setq gnus-newsgroup-dependencies
5038 (gnus-make-hashtable (length articles)))
5039 (gnus-set-global-variables)
5040 ;; Retrieve the headers and read them in.
5042 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5044 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5046 (setq gnus-newsgroup-cached cached))
5048 ;; Suppress duplicates?
5049 (when gnus-suppress-duplicates
5050 (gnus-dup-suppress-articles))
5052 ;; Set the initial limit.
5053 (setq gnus-newsgroup-limit (copy-sequence articles))
5054 ;; Remove canceled articles from the list of unread articles.
5055 (setq fetched-articles
5056 (mapcar (lambda (headers) (mail-header-number headers))
5057 gnus-newsgroup-headers))
5058 (setq gnus-newsgroup-articles fetched-articles)
5059 (setq gnus-newsgroup-unreads
5060 (gnus-sorted-nintersection
5061 gnus-newsgroup-unreads fetched-articles))
5062 (gnus-compute-unseen-list)
5064 ;; Removed marked articles that do not exist.
5065 (gnus-update-missing-marks
5066 (gnus-sorted-difference articles fetched-articles))
5067 ;; We might want to build some more threads first.
5068 (when (and gnus-fetch-old-headers
5069 (eq gnus-headers-retrieved-by 'nov))
5070 (if (eq gnus-fetch-old-headers 'invisible)
5071 (gnus-build-all-threads)
5072 (gnus-build-old-threads)))
5073 ;; Let the Gnus agent mark articles as read.
5075 (gnus-agent-get-undownloaded-list))
5076 ;; Remove list identifiers from subject
5077 (when gnus-list-identifiers
5078 (gnus-summary-remove-list-identifiers))
5079 ;; Check whether auto-expire is to be done in this group.
5080 (setq gnus-newsgroup-auto-expire
5081 (gnus-group-auto-expirable-p group))
5082 ;; Set up the article buffer now, if necessary.
5083 (unless gnus-single-article-buffer
5084 (gnus-article-setup-buffer))
5085 ;; First and last article in this newsgroup.
5086 (when gnus-newsgroup-headers
5087 (setq gnus-newsgroup-begin
5088 (mail-header-number (car gnus-newsgroup-headers))
5091 (gnus-last-element gnus-newsgroup-headers))))
5092 ;; GROUP is successfully selected.
5093 (or gnus-newsgroup-headers t)))))
5095 (defun gnus-compute-unseen-list ()
5096 ;; The `seen' marks are treated specially.
5097 (if (not gnus-newsgroup-seen)
5098 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5099 (setq gnus-newsgroup-unseen
5100 (gnus-inverse-list-range-intersection
5101 gnus-newsgroup-articles gnus-newsgroup-seen))))
5103 (defun gnus-summary-display-make-predicate (display)
5104 (require 'gnus-agent)
5105 (when (= (length display) 1)
5106 (setq display (car display)))
5107 (unless gnus-summary-display-cache
5108 (dolist (elem (append '((unread . unread)
5111 gnus-article-mark-lists))
5112 (push (cons (cdr elem)
5114 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5115 gnus-summary-display-cache)))
5116 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5117 (gnus-category-predicate-cache gnus-summary-display-cache))
5118 (gnus-get-predicate display)))
5120 ;; Uses the dynamically bound `number' variable.
5123 (defun gnus-article-marked-p (type &optional article)
5124 (let ((article (or article number)))
5127 (memq article gnus-newsgroup-marked))
5129 (memq article gnus-newsgroup-spam-marked))
5131 (memq article gnus-newsgroup-unsendable))
5132 ((eq type 'undownload)
5133 (memq article gnus-newsgroup-undownloaded))
5134 ((eq type 'download)
5135 (memq article gnus-newsgroup-downloadable))
5137 (memq article gnus-newsgroup-unreads))
5139 (memq article gnus-newsgroup-reads))
5141 (memq article gnus-newsgroup-dormant) )
5143 (memq article gnus-newsgroup-expirable))
5145 (memq article gnus-newsgroup-replied))
5147 (memq article gnus-newsgroup-killed))
5148 ((eq type 'bookmark)
5149 (assq article gnus-newsgroup-bookmarks))
5151 (assq article gnus-newsgroup-scored))
5153 (memq article gnus-newsgroup-saved))
5155 (memq article gnus-newsgroup-cached))
5157 (memq article gnus-newsgroup-forwarded))
5159 (not (memq article gnus-newsgroup-unseen)))
5161 (memq article gnus-newsgroup-recent))
5164 (defun gnus-articles-to-read (group &optional read-all)
5165 "Find out what articles the user wants to read."
5166 (let* ((display (gnus-group-find-parameter group 'display))
5168 ;; Select all articles if `read-all' is non-nil, or if there
5169 ;; are no unread articles.
5171 (and (zerop (length gnus-newsgroup-marked))
5172 (zerop (length gnus-newsgroup-unreads)))
5173 ;; Fetch all if the predicate is non-nil.
5174 gnus-newsgroup-display)
5175 ;; We want to select the headers for all the articles in
5176 ;; the group, so we select either all the active
5177 ;; articles in the group, or (if that's nil), the
5178 ;; articles in the cache.
5180 (gnus-uncompress-range (gnus-active group))
5181 (gnus-cache-articles-in-group group))
5182 ;; Select only the "normal" subset of articles.
5184 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5185 gnus-newsgroup-unreads)))
5186 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5187 (scored (length scored-list))
5188 (number (length articles))
5189 (marked (+ (length gnus-newsgroup-marked)
5190 (length gnus-newsgroup-dormant)))
5195 ((numberp gnus-newsgroup-display)
5196 gnus-newsgroup-display)
5200 ((and (or (<= scored marked) (= scored number))
5201 (numberp gnus-large-newsgroup)
5202 (> number gnus-large-newsgroup))
5203 (let* ((cursor-in-echo-area nil)
5204 (initial (gnus-parameter-large-newsgroup-initial
5205 gnus-newsgroup-name))
5209 "How many articles from %s (%s %d): "
5211 (gnus-group-decoded-name gnus-newsgroup-name)
5213 (if initial "max" "default")
5216 (cons (number-to-string initial)
5218 (if (string-match "^[ \t]*$" input) number input)))
5219 ((and (> scored marked) (< scored number)
5220 (> (- scored number) 20))
5223 (format "%s %s (%d scored, %d total): "
5224 "How many articles from"
5225 (gnus-group-decoded-name group)
5227 (if (string-match "^[ \t]*$" input)
5231 (message "Quit getting the articles to read")
5233 (setq select (if (stringp select) (string-to-number select) select))
5234 (if (or (null select) (zerop select))
5236 (if (and (not (zerop scored)) (<= (abs select) scored))
5238 (setq articles (sort scored-list '<))
5239 (setq number (length articles)))
5240 (setq articles (copy-sequence articles)))
5242 (when (< (abs select) number)
5244 ;; Select the N oldest articles.
5245 (setcdr (nthcdr (1- (abs select)) articles) nil)
5246 ;; Select the N most recent articles.
5247 (setq articles (nthcdr (- number select) articles))))
5248 (setq gnus-newsgroup-unselected
5249 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5250 (when gnus-alter-articles-to-read-function
5253 (funcall gnus-alter-articles-to-read-function
5254 gnus-newsgroup-name articles)
5258 (defun gnus-killed-articles (killed articles)
5261 (when (inline (gnus-member-of-range (car articles) killed))
5262 (push (car articles) out))
5263 (setq articles (cdr articles)))
5266 (defun gnus-uncompress-marks (marks)
5267 "Uncompress the mark ranges in MARKS."
5268 (let ((uncompressed '(score bookmark))
5271 (if (memq (caar marks) uncompressed)
5272 (push (car marks) out)
5273 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5274 (setq marks (cdr marks)))
5277 (defun gnus-article-mark-to-type (mark)
5278 "Return the type of MARK."
5279 (or (cadr (assq mark gnus-article-special-mark-lists))
5282 (defun gnus-article-unpropagatable-p (mark)
5283 "Return whether MARK should be propagated to backend."
5284 (memq mark gnus-article-unpropagated-mark-lists))
5286 (defun gnus-adjust-marked-articles (info)
5287 "Set all article lists and remove all marks that are no longer valid."
5288 (let* ((marked-lists (gnus-info-marks info))
5289 (active (gnus-active (gnus-info-group info)))
5292 (types gnus-article-mark-lists)
5293 marks var articles article mark mark-type)
5295 (dolist (marks marked-lists)
5296 (setq mark (car marks)
5297 mark-type (gnus-article-mark-to-type mark)
5298 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5300 ;; We set the variable according to the type of the marks list,
5301 ;; and then adjust the marks to a subset of the active articles.
5303 ;; Adjust "simple" lists.
5304 ((eq mark-type 'list)
5305 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5306 (when (memq mark '(tick dormant expire reply save))
5308 (when (or (< (setq article (pop articles)) min) (> article max))
5309 (set var (delq article (symbol-value var)))))))
5311 ((eq mark-type 'tuple)
5312 (set var (setq articles (cdr marks)))
5313 (when (not (listp (cdr (symbol-value var))))
5314 (set var (list (symbol-value var))))
5315 (when (not (listp (cdr articles)))
5316 (setq articles (list articles)))
5318 (when (or (not (consp (setq article (pop articles))))
5319 (< (car article) min)
5320 (> (car article) max))
5321 (set var (delq article (symbol-value var))))))
5322 ;; Adjust ranges (sloppily).
5323 ((eq mark-type 'range)
5326 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5327 ;; It should be (seen (NUM1 . NUM2)).
5328 (when (numberp (cddr marks))
5329 (setcdr marks (list (cdr marks))))
5330 (setq articles (cdr marks))
5331 (while (and articles
5332 (or (and (consp (car articles))
5333 (> min (cdar articles)))
5334 (and (numberp (car articles))
5335 (> min (car articles)))))
5337 (set var articles))))))))
5339 (defun gnus-update-missing-marks (missing)
5340 "Go through the list of MISSING articles and remove them from the mark lists."
5343 ;; Go through all types.
5344 (dolist (elem gnus-article-mark-lists)
5345 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5346 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5347 (when (symbol-value var)
5348 ;; This list has articles. So we delete all missing
5349 ;; articles from it.
5352 (set var (delq (pop m) (symbol-value var))))))))))
5354 (defun gnus-update-marks ()
5355 "Enter the various lists of marked articles into the newsgroup info list."
5356 (let ((types gnus-article-mark-lists)
5357 (info (gnus-get-info gnus-newsgroup-name))
5358 type list newmarked symbol delta-marks)
5360 ;; Add all marks lists to the list of marks lists.
5361 (while (setq type (pop types))
5362 (setq list (symbol-value
5364 (intern (format "gnus-newsgroup-%s" (car type))))))
5367 ;; Get rid of the entries of the articles that have the
5369 (when (and (eq (cdr type) 'score)
5373 (prev (cons nil list))
5376 (if (or (not (consp (car arts)))
5377 (= (cdar arts) gnus-summary-default-score))
5378 (setcdr prev (cdr arts))
5380 (setq arts (cdr arts)))
5381 (setq list (cdr all)))))
5383 (when (eq (cdr type) 'seen)
5384 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5386 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5387 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5389 (when (and (gnus-check-backend-function
5390 'request-set-mark gnus-newsgroup-name)
5391 (not (gnus-article-unpropagatable-p (cdr type))))
5392 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5393 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5394 (add (gnus-remove-from-range
5395 (gnus-copy-sequence list) old)))
5397 (push (list add 'add (list (cdr type))) delta-marks))
5399 (push (list del 'del (list (cdr type))) delta-marks))))
5402 (push (cons (cdr type) list) newmarked)))
5405 (unless (gnus-check-group gnus-newsgroup-name)
5406 (error "Can't open server for %s" gnus-newsgroup-name))
5407 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5409 ;; Enter these new marks into the info of the group.
5411 (setcar (nthcdr 3 info) newmarked)
5412 ;; Add the marks lists to the end of the info.
5414 (setcdr (nthcdr 2 info) (list newmarked))))
5416 ;; Cut off the end of the info if there's nothing else there.
5420 (when (nthcdr (decf i) info)
5421 (setcdr (nthcdr i info) nil)))))))
5423 (defun gnus-set-mode-line (where)
5424 "Set the mode line of the article or summary buffers.
5425 If WHERE is `summary', the summary mode line format will be used."
5426 ;; Is this mode line one we keep updated?
5427 (when (and (memq where gnus-updated-mode-lines)
5429 (intern (format "gnus-%s-mode-line-format-spec" where))))
5432 ;; We evaluate this in the summary buffer since these
5433 ;; variables are buffer-local to that buffer.
5434 (set-buffer gnus-summary-buffer)
5435 ;; We bind all these variables that are used in the `eval' form
5437 (let* ((mformat (symbol-value
5439 (format "gnus-%s-mode-line-format-spec" where))))
5440 (gnus-tmp-group-name (gnus-group-decoded-name
5441 gnus-newsgroup-name))
5442 (gnus-tmp-article-number (or gnus-current-article 0))
5443 (gnus-tmp-unread gnus-newsgroup-unreads)
5444 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5445 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5446 (gnus-tmp-unread-and-unselected
5447 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5448 (zerop gnus-tmp-unselected))
5450 ((zerop gnus-tmp-unselected)
5451 (format "{%d more}" gnus-tmp-unread-and-unticked))
5452 (t (format "{%d(+%d) more}"
5453 gnus-tmp-unread-and-unticked
5454 gnus-tmp-unselected))))
5456 (if (and gnus-current-headers
5457 (vectorp gnus-current-headers))
5458 (gnus-mode-string-quote
5459 (mail-header-subject gnus-current-headers))
5461 bufname-length max-len
5462 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5463 (setq mode-string (eval mformat))
5464 (setq bufname-length (if (string-match "%b" mode-string)
5467 (if (eq where 'summary)
5469 (get-buffer gnus-article-buffer))))
5472 (setq max-len (max 4 (if gnus-mode-non-string-length
5474 gnus-mode-non-string-length
5476 (length mode-string))))
5477 ;; We might have to chop a bit of the string off...
5478 (when (> (length mode-string) max-len)
5480 (concat (truncate-string-to-width mode-string (- max-len 3))
5482 ;; Pad the mode string a bit.
5483 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5484 ;; Update the mode line.
5485 (setq mode-line-buffer-identification
5486 (gnus-mode-line-buffer-identification (list mode-string)))
5487 (set-buffer-modified-p t))))
5489 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5490 "Go through the HEADERS list and add all Xrefs to a hash table.
5491 The resulting hash table is returned, or nil if no Xrefs were found."
5492 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5493 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5494 (xref-hashtb (gnus-make-hashtable))
5495 start group entry number xrefs header)
5497 (setq header (pop headers))
5498 (when (and (setq xrefs (mail-header-xref header))
5499 (not (memq (setq number (mail-header-number header))
5502 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5503 (setq start (match-end 0))
5504 (setq group (if prefix
5505 (concat prefix (substring xrefs (match-beginning 1)
5507 (substring xrefs (match-beginning 1) (match-end 1))))
5509 (string-to-int (substring xrefs (match-beginning 2)
5511 (if (setq entry (gnus-gethash group xref-hashtb))
5512 (setcdr entry (cons number (cdr entry)))
5513 (gnus-sethash group (cons number nil) xref-hashtb)))))
5514 (and start xref-hashtb)))
5516 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5517 "Look through all the headers and mark the Xrefs as read."
5518 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5519 name entry info xref-hashtb idlist method nth4)
5521 (set-buffer gnus-group-buffer)
5522 (when (setq xref-hashtb
5523 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5526 (unless (string= from-newsgroup (setq name (symbol-name group)))
5527 (setq idlist (symbol-value group))
5528 ;; Dead groups are not updated.
5530 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5532 (when (stringp (setq nth4 (gnus-info-method info)))
5533 (setq nth4 (gnus-server-to-method nth4))))
5534 ;; Only do the xrefs if the group has the same
5535 ;; select method as the group we have just read.
5536 (or (gnus-methods-equal-p
5537 nth4 (gnus-find-method-for-group from-newsgroup))
5539 (equal nth4 (setq method (gnus-find-method-for-group
5541 (and (equal (car nth4) (car method))
5542 (equal (nth 1 nth4) (nth 1 method))))
5543 gnus-use-cross-reference
5544 (or (not (eq gnus-use-cross-reference t))
5546 ;; Only do cross-references on subscribed
5547 ;; groups, if that is what is wanted.
5548 (<= (gnus-info-level info) gnus-level-subscribed))
5549 (gnus-group-make-articles-read name idlist))))
5552 (defun gnus-compute-read-articles (group articles)
5553 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5554 (info (nth 2 entry))
5555 (active (gnus-active group))
5558 ;; First peel off all invalid article numbers.
5560 (let ((ids articles)
5562 (while (setq id (pop ids))
5563 (when (and first (> id (cdr active)))
5564 ;; We'll end up in this situation in one particular
5565 ;; obscure situation. If you re-scan a group and get
5566 ;; a new article that is cross-posted to a different
5567 ;; group that has not been re-scanned, you might get
5568 ;; crossposted article that has a higher number than
5569 ;; Gnus believes possible. So we re-activate this
5570 ;; group as well. This might mean doing the
5571 ;; crossposting thingy will *increase* the number
5572 ;; of articles in some groups. Tsk, tsk.
5573 (setq active (or (gnus-activate-group group) active)))
5574 (when (or (> id (cdr active))
5575 (< id (car active)))
5576 (setq articles (delq id articles))))))
5577 ;; If the read list is nil, we init it.
5579 (null (gnus-info-read info))
5581 (setq ninfo (cons 1 (1- (car active))))
5582 (setq ninfo (gnus-info-read info)))
5583 ;; Then we add the read articles to the range.
5585 ninfo (setq articles (sort articles '<))))))
5587 (defun gnus-group-make-articles-read (group articles)
5588 "Update the info of GROUP to say that ARTICLES are read."
5590 (entry (gnus-gethash group gnus-newsrc-hashtb))
5591 (info (nth 2 entry))
5592 (active (gnus-active group))
5595 (setq range (gnus-compute-read-articles group articles))
5597 (set-buffer gnus-group-buffer)
5600 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5601 (gnus-info-set-read ',info ',(gnus-info-read info))
5602 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5603 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5604 (gnus-group-update-group ,group t))))
5605 ;; Add the read articles to the range.
5606 (gnus-info-set-read info range)
5607 (gnus-request-set-mark group (list (list range 'add '(read))))
5608 ;; Then we have to re-compute how many unread
5609 ;; articles there are in this group.
5613 (setq num (- (1+ (cdr active)) (car active))))
5614 ((not (listp (cdr range)))
5615 (setq num (- (cdr active) (- (1+ (cdr range))
5619 (if (numberp (car range))
5621 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5622 (setq range (cdr range)))
5623 (setq num (- (cdr active) num))))
5624 ;; Update the number of unread articles.
5626 ;; Update the group buffer.
5627 (unless (gnus-ephemeral-group-p group)
5628 (gnus-group-update-group group t))))))
5630 (defvar gnus-newsgroup-none-id 0)
5632 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5633 (let ((cur nntp-server-buffer)
5636 (save-excursion (set-buffer gnus-summary-buffer)
5637 gnus-newsgroup-dependencies)))
5639 (mail-parse-charset gnus-newsgroup-charset)
5640 (mail-parse-ignored-charsets
5641 (save-excursion (condition-case nil
5642 (set-buffer gnus-summary-buffer)
5644 gnus-newsgroup-ignored-charsets)))
5646 (set-buffer nntp-server-buffer)
5647 ;; Translate all TAB characters into SPACE characters.
5648 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5649 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5650 (gnus-run-hooks 'gnus-parse-headers-hook)
5651 (let ((case-fold-search t)
5652 in-reply-to header p lines chars)
5653 (goto-char (point-min))
5654 ;; Search to the beginning of the next header. Error messages
5655 ;; do not begin with 2 or 3.
5656 (while (re-search-forward "^[23][0-9]+ " nil t)
5659 ;; This implementation of this function, with nine
5660 ;; search-forwards instead of the one re-search-forward and
5661 ;; a case (which basically was the old function) is actually
5662 ;; about twice as fast, even though it looks messier. You
5663 ;; can't have everything, I guess. Speed and elegance
5664 ;; doesn't always go hand in hand.
5673 (narrow-to-region (point)
5674 (or (and (search-forward "\n.\n" nil t)
5680 (if (search-forward "\nsubject:" nil t)
5681 (funcall gnus-decode-encoded-word-function
5682 (nnheader-header-value))
5687 (if (search-forward "\nfrom:" nil t)
5688 (funcall gnus-decode-encoded-word-function
5689 (nnheader-header-value))
5694 (if (search-forward "\ndate:" nil t)
5695 (nnheader-header-value) ""))
5699 (setq id (if (re-search-forward
5700 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5701 ;; We do it this way to make sure the Message-ID
5702 ;; is (somewhat) syntactically valid.
5703 (buffer-substring (match-beginning 1)
5705 ;; If there was no message-id, we just fake one
5706 ;; to make subsequent routines simpler.
5707 (nnheader-generate-fake-message-id))))
5711 (if (search-forward "\nreferences:" nil t)
5715 (nnheader-header-value)
5720 (search-backward ">" end t)
5723 (search-backward "<" end t)
5725 ;; Get the references from the in-reply-to header if there
5726 ;; were no references and the in-reply-to header looks
5728 (if (and (search-forward "\nin-reply-to:" nil t)
5729 (setq in-reply-to (nnheader-header-value))
5730 (string-match "<[^>]+>" in-reply-to))
5732 (setq ref (substring in-reply-to (match-beginning 0)
5734 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5735 (setq ref2 (substring in-reply-to (match-beginning 0)
5737 (when (> (length ref2) (length ref))
5744 (if (search-forward "\nchars: " nil t)
5745 (if (numberp (setq chars (ignore-errors (read cur))))
5751 (if (search-forward "\nlines: " nil t)
5752 (if (numberp (setq lines (ignore-errors (read cur))))
5758 (and (search-forward "\nxref:" nil t)
5759 (nnheader-header-value)))
5761 (when gnus-extra-headers
5762 (let ((extra gnus-extra-headers)
5766 (when (search-forward
5767 (concat "\n" (symbol-name (car extra)) ":") nil t)
5768 (push (cons (car extra) (nnheader-header-value))
5772 (when (equal id ref)
5775 (when gnus-alter-header-function
5776 (funcall gnus-alter-header-function header)
5777 (setq id (mail-header-id header)
5778 ref (gnus-parent-id (mail-header-references header))))
5781 (gnus-dependencies-add-header
5782 header dependencies force-new))
5783 (push header headers))
5784 (goto-char (point-max))
5786 (nreverse headers)))))
5788 ;; Goes through the xover lines and returns a list of vectors
5789 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5790 force-new dependencies
5791 group also-fetch-heads)
5792 "Parse the news overview data in the server buffer.
5793 Return a list of headers that match SEQUENCE (see
5794 `nntp-retrieve-headers')."
5795 ;; Get the Xref when the users reads the articles since most/some
5796 ;; NNTP servers do not include Xrefs when using XOVER.
5797 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5798 (let ((mail-parse-charset gnus-newsgroup-charset)
5799 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5800 (cur nntp-server-buffer)
5801 (dependencies (or dependencies gnus-newsgroup-dependencies))
5803 ((eq gnus-read-all-available-headers t)
5805 ((stringp gnus-read-all-available-headers)
5806 (string-match gnus-read-all-available-headers group))
5809 number headers header)
5811 (set-buffer nntp-server-buffer)
5812 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5813 ;; Allow the user to mangle the headers before parsing them.
5814 (gnus-run-hooks 'gnus-parse-headers-hook)
5815 (goto-char (point-min))
5816 (gnus-parse-without-error
5817 (while (and (or sequence allp)
5819 (setq number (read cur))
5821 (while (and sequence
5822 (< (car sequence) number))
5823 (setq sequence (cdr sequence))))
5826 (eq number (car sequence))))
5828 (setq sequence (cdr sequence))
5829 (setq header (inline
5830 (gnus-nov-parse-line
5831 number dependencies force-new)))))
5832 (push header headers))
5834 ;; A common bug in inn is that if you have posted an article and
5835 ;; then retrieves the active file, it will answer correctly --
5836 ;; the new article is included. However, a NOV entry for the
5837 ;; article may not have been generated yet, so this may fail.
5838 ;; We work around this problem by retrieving the last few
5839 ;; headers using HEAD.
5840 (if (or (not also-fetch-heads)
5842 ;; We (probably) got all the headers.
5844 (let ((gnus-nov-is-evil t))
5847 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5848 (gnus-get-newsgroup-headers))))))))
5850 (defun gnus-article-get-xrefs ()
5851 "Fill in the Xref value in `gnus-current-headers', if necessary.
5852 This is meant to be called in `gnus-article-internal-prepare-hook'."
5853 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5854 gnus-current-headers)))
5855 (or (not gnus-use-cross-reference)
5857 (and (mail-header-xref headers)
5858 (not (string= (mail-header-xref headers) "")))
5859 (let ((case-fold-search t)
5862 (nnheader-narrow-to-headers)
5863 (goto-char (point-min))
5864 (when (or (and (not (eobp))
5865 (eq (downcase (char-after)) ?x)
5866 (looking-at "Xref:"))
5867 (search-forward "\nXref:" nil t))
5868 (goto-char (1+ (match-end 0)))
5869 (setq xref (buffer-substring (point)
5870 (progn (end-of-line) (point))))
5871 (mail-header-set-xref headers xref)))))))
5873 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5874 "Find article ID and insert the summary line for that article.
5875 OLD-HEADER can either be a header or a line number to insert
5876 the subject line on."
5877 (let* ((line (and (numberp old-header) old-header))
5878 (old-header (and (vectorp old-header) old-header))
5879 (header (cond ((and old-header use-old-header)
5882 (gnus-number-to-header id))
5883 (gnus-number-to-header id))
5885 (gnus-read-header id))))
5886 (number (and (numberp id) id))
5889 ;; Rebuild the thread that this article is part of and go to the
5890 ;; article we have fetched.
5891 (when (and (not gnus-show-threads)
5894 (setq d (gnus-data-find (mail-header-number old-header))))
5895 (goto-char (gnus-data-pos d))
5898 (- (gnus-point-at-bol)
5900 (1+ (gnus-point-at-eol))
5901 (gnus-delete-line))))))
5903 (mail-header-set-number header (mail-header-number old-header)))
5904 (setq gnus-newsgroup-sparse
5905 (delq (setq number (mail-header-number header))
5906 gnus-newsgroup-sparse))
5907 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5908 (push number gnus-newsgroup-limit)
5909 (gnus-rebuild-thread (mail-header-id header) line)
5910 (gnus-summary-goto-subject number nil t))
5911 (when (and (numberp number)
5913 ;; We have to update the boundaries even if we can't fetch the
5914 ;; article if ID is a number -- so that the next `P' or `N'
5915 ;; command will fetch the previous (or next) article even
5916 ;; if the one we tried to fetch this time has been canceled.
5917 (when (> number gnus-newsgroup-end)
5918 (setq gnus-newsgroup-end number))
5919 (when (< number gnus-newsgroup-begin)
5920 (setq gnus-newsgroup-begin number))
5921 (setq gnus-newsgroup-unselected
5922 (delq number gnus-newsgroup-unselected)))
5923 ;; Report back a success?
5924 (and header (mail-header-number header))))
5926 ;;; Process/prefix in the summary buffer
5928 (defun gnus-summary-work-articles (n)
5929 "Return a list of articles to be worked upon.
5930 The prefix argument, the list of process marked articles, and the
5931 current article will be taken into consideration."
5933 (set-buffer gnus-summary-buffer)
5936 ;; A numerical prefix has been given.
5937 (setq n (prefix-numeric-value n))
5938 (let ((backward (< n 0))
5939 (n (abs (prefix-numeric-value n)))
5944 (push (setq article (gnus-summary-article-number))
5947 (gnus-summary-find-prev nil article)
5948 (gnus-summary-find-next nil article)))
5950 (nreverse articles)))
5951 ((and (gnus-region-active-p) (mark))
5952 (message "region active")
5953 ;; Work on the region between point and mark.
5954 (let ((max (max (point) (mark)))
5957 (goto-char (min (min (point) (mark))))
5960 (push (setq article (gnus-summary-article-number)) articles)
5961 (gnus-summary-find-next nil article)
5963 (nreverse articles))))
5964 (gnus-newsgroup-processable
5965 ;; There are process-marked articles present.
5966 ;; Save current state.
5967 (gnus-summary-save-process-mark)
5969 (reverse gnus-newsgroup-processable))
5971 ;; Just return the current article.
5972 (list (gnus-summary-article-number))))))
5974 (defmacro gnus-summary-iterate (arg &rest forms)
5975 "Iterate over the process/prefixed articles and do FORMS.
5976 ARG is the interactive prefix given to the command. FORMS will be
5977 executed with point over the summary line of the articles."
5978 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5979 `(let ((,articles (gnus-summary-work-articles ,arg)))
5981 (gnus-summary-goto-subject (car ,articles))
5985 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5986 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5988 (defun gnus-summary-save-process-mark ()
5989 "Push the current set of process marked articles on the stack."
5991 (push (copy-sequence gnus-newsgroup-processable)
5992 gnus-newsgroup-process-stack))
5994 (defun gnus-summary-kill-process-mark ()
5995 "Push the current set of process marked articles on the stack and unmark."
5997 (gnus-summary-save-process-mark)
5998 (gnus-summary-unmark-all-processable))
6000 (defun gnus-summary-yank-process-mark ()
6001 "Pop the last process mark state off the stack and restore it."
6003 (unless gnus-newsgroup-process-stack
6004 (error "Empty mark stack"))
6005 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6007 (defun gnus-summary-process-mark-set (set)
6008 "Make SET into the current process marked articles."
6009 (gnus-summary-unmark-all-processable)
6011 (gnus-summary-set-process-mark (pop set))))
6013 ;;; Searching and stuff
6015 (defun gnus-summary-search-group (&optional backward use-level)
6016 "Search for next unread newsgroup.
6017 If optional argument BACKWARD is non-nil, search backward instead."
6019 (set-buffer gnus-group-buffer)
6020 (when (gnus-group-search-forward
6021 backward nil (if use-level (gnus-group-group-level) nil))
6022 (gnus-group-group-name))))
6024 (defun gnus-summary-best-group (&optional exclude-group)
6025 "Find the name of the best unread group.
6026 If EXCLUDE-GROUP, do not go to this group."
6028 (set-buffer gnus-group-buffer)
6030 (gnus-group-best-unread-group exclude-group))))
6032 (defun gnus-summary-find-next (&optional unread article backward)
6033 (if backward (gnus-summary-find-prev)
6034 (let* ((dummy (gnus-summary-article-intangible-p))
6035 (article (or article (gnus-summary-article-number)))
6036 (data (gnus-data-find-list article))
6038 (when (and (not dummy)
6039 (or (not gnus-summary-check-current)
6041 (not (gnus-data-unread-p (car data)))))
6042 (setq data (cdr data)))
6047 (unless (memq (gnus-data-number (car data))
6048 gnus-newsgroup-unfetched)
6049 (when (gnus-data-unread-p (car data))
6050 (setq result (car data)
6052 (setq data (cdr data)))
6055 (goto-char (gnus-data-pos result))
6056 (gnus-data-number result)))))
6058 (defun gnus-summary-find-prev (&optional unread article)
6059 (let* ((eobp (eobp))
6060 (article (or article (gnus-summary-article-number)))
6061 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6063 (when (and (not eobp)
6064 (or (not gnus-summary-check-current)
6066 (not (gnus-data-unread-p (car data)))))
6067 (setq data (cdr data)))
6072 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6073 (when (gnus-data-unread-p (car data))
6074 (setq result (car data)
6076 (setq data (cdr data)))
6079 (goto-char (gnus-data-pos result))
6080 (gnus-data-number result))))
6082 (defun gnus-summary-find-subject (subject &optional unread backward article)
6083 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6084 (article (or article (gnus-summary-article-number)))
6085 (articles (gnus-data-list backward))
6086 (arts (gnus-data-find-list article articles))
6088 (when (or (not gnus-summary-check-current)
6090 (not (gnus-data-unread-p (car arts))))
6091 (setq arts (cdr arts)))
6093 (and (or (not unread)
6094 (gnus-data-unread-p (car arts)))
6095 (vectorp (gnus-data-header (car arts)))
6097 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6098 (setq result (car arts)
6100 (setq arts (cdr arts)))
6102 (goto-char (gnus-data-pos result))
6103 (gnus-data-number result))))
6105 (defun gnus-summary-search-forward (&optional unread subject backward)
6106 "Search forward for an article.
6107 If UNREAD, look for unread articles. If SUBJECT, look for
6108 articles with that subject. If BACKWARD, search backward instead."
6109 (cond (subject (gnus-summary-find-subject subject unread backward))
6110 (backward (gnus-summary-find-prev unread))
6111 (t (gnus-summary-find-next unread))))
6113 (defun gnus-recenter (&optional n)
6114 "Center point in window and redisplay frame.
6115 Also do horizontal recentering."
6117 (when (and gnus-auto-center-summary
6118 (not (eq gnus-auto-center-summary 'vertical)))
6119 (gnus-horizontal-recenter))
6122 (defun gnus-summary-recenter ()
6123 "Center point in the summary window.
6124 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6125 displayed, no centering will be performed."
6126 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6127 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6129 ;; The user has to want it.
6130 (when gnus-auto-center-summary
6131 (let* ((top (cond ((< (window-height) 4) 0)
6132 ((< (window-height) 7) 1)
6133 (t (if (numberp gnus-auto-center-summary)
6134 gnus-auto-center-summary
6136 (height (1- (window-height)))
6137 (bottom (save-excursion (goto-char (point-max))
6138 (forward-line (- height))
6140 (window (get-buffer-window (current-buffer))))
6141 (when (get-buffer-window gnus-article-buffer)
6142 ;; Only do recentering when the article buffer is displayed,
6143 ;; Set the window start to either `bottom', which is the biggest
6144 ;; possible valid number, or the second line from the top,
6145 ;; whichever is the least.
6146 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6147 (if (> bottom top-pos)
6148 ;; Keep the second line from the top visible
6149 (set-window-start window top-pos t)
6150 ;; Try to keep the bottom line visible; if it's partially
6151 ;; obscured, either scroll one more line to make it fully
6152 ;; visible, or revert to using TOP-POS.
6154 (goto-char (point-max))
6156 (let ((last-line-start (point)))
6158 (set-window-start window (point) t)
6159 (when (not (pos-visible-in-window-p last-line-start window))
6161 (set-window-start window (min (point) top-pos) t)))))))
6162 ;; Do horizontal recentering while we're at it.
6163 (when (and (get-buffer-window (current-buffer) t)
6164 (not (eq gnus-auto-center-summary 'vertical)))
6165 (let ((selected (selected-window)))
6166 (select-window (get-buffer-window (current-buffer) t))
6167 (gnus-summary-position-point)
6168 (gnus-horizontal-recenter)
6169 (select-window selected))))))
6171 (defun gnus-summary-jump-to-group (newsgroup)
6172 "Move point to NEWSGROUP in group mode buffer."
6173 ;; Keep update point of group mode buffer if visible.
6174 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6175 (save-window-excursion
6176 ;; Take care of tree window mode.
6177 (when (get-buffer-window gnus-group-buffer)
6178 (pop-to-buffer gnus-group-buffer))
6179 (gnus-group-jump-to-group newsgroup))
6181 ;; Take care of tree window mode.
6182 (if (get-buffer-window gnus-group-buffer)
6183 (pop-to-buffer gnus-group-buffer)
6184 (set-buffer gnus-group-buffer))
6185 (gnus-group-jump-to-group newsgroup))))
6187 ;; This function returns a list of article numbers based on the
6188 ;; difference between the ranges of read articles in this group and
6189 ;; the range of active articles.
6190 (defun gnus-list-of-unread-articles (group)
6191 (let* ((read (gnus-info-read (gnus-get-info group)))
6192 (active (or (gnus-active group) (gnus-activate-group group)))
6195 ;; If none are read, then all are unread.
6197 (setq first (car active))
6198 ;; If the range of read articles is a single range, then the
6199 ;; first unread article is the article after the last read
6200 ;; article. Sounds logical, doesn't it?
6201 (if (and (not (listp (cdr read)))
6202 (or (< (car read) (car active))
6203 (progn (setq read (list read))
6205 (setq first (max (car active) (1+ (cdr read))))
6206 ;; `read' is a list of ranges.
6207 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6210 (setq first (car active)))
6213 (while (< first nlast)
6215 (setq first (1+ first))))
6216 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6217 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6218 (setq read (cdr read)))))
6219 ;; And add the last unread articles.
6220 (while (<= first last)
6222 (setq first (1+ first)))
6223 ;; Return the list of unread articles.
6224 (delq 0 (nreverse unread))))
6226 (defun gnus-list-of-read-articles (group)
6227 "Return a list of unread, unticked and non-dormant articles."
6228 (let* ((info (gnus-get-info group))
6229 (marked (gnus-info-marks info))
6230 (active (gnus-active group)))
6232 (gnus-list-range-difference
6233 (gnus-list-range-difference
6234 (gnus-sorted-complement
6235 (gnus-uncompress-range active)
6236 (gnus-list-of-unread-articles group))
6237 (cdr (assq 'dormant marked)))
6238 (cdr (assq 'tick marked))))))
6240 ;; Various summary commands
6242 (defun gnus-summary-select-article-buffer ()
6243 "Reconfigure windows to show article buffer."
6245 (if (not (gnus-buffer-live-p gnus-article-buffer))
6246 (error "There is no article buffer for this summary buffer")
6247 (gnus-configure-windows 'article)
6248 (select-window (get-buffer-window gnus-article-buffer))))
6250 (defun gnus-summary-universal-argument (arg)
6251 "Perform any operation on all articles that are process/prefixed."
6253 (let ((articles (gnus-summary-work-articles arg))
6260 (substitute-command-keys
6261 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6263 (gnus-error 1 "Undefined key")
6266 (gnus-summary-goto-subject (setq article (pop articles)))
6267 (let (gnus-newsgroup-processable)
6268 (command-execute func))
6269 (gnus-summary-remove-process-mark article)))))
6270 (gnus-summary-position-point))
6272 (defun gnus-summary-toggle-truncation (&optional arg)
6273 "Toggle truncation of summary lines.
6274 With arg, turn line truncation on if arg is positive."
6276 (setq truncate-lines
6277 (if (null arg) (not truncate-lines)
6278 (> (prefix-numeric-value arg) 0)))
6281 (defun gnus-summary-find-uncancelled ()
6282 "Return the number of an uncancelled article.
6283 The current article is considered, then following articles, then previous
6284 articles. If all articles are cancelled then return a dummy 0."
6286 (dolist (rev '(nil t))
6287 (unless found ; don't demand the reverse list if we don't need it
6288 (let ((data (gnus-data-find-list
6289 (gnus-summary-article-number) (gnus-data-list rev))))
6290 (while (and data (not found))
6291 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6292 (setq found (gnus-data-number (car data))))
6293 (setq data (cdr data))))))
6296 (defun gnus-summary-reselect-current-group (&optional all rescan)
6297 "Exit and then reselect the current newsgroup.
6298 The prefix argument ALL means to select all articles."
6300 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6301 (error "Ephemeral groups can't be reselected"))
6302 (let ((current-subject (gnus-summary-find-uncancelled))
6303 (group gnus-newsgroup-name))
6304 (setq gnus-newsgroup-begin nil)
6306 ;; We have to adjust the point of group mode buffer because
6307 ;; point was moved to the next unread newsgroup by exiting.
6308 (gnus-summary-jump-to-group group)
6311 (gnus-group-get-new-news-this-group 1)))
6312 (gnus-group-read-group all t)
6313 (gnus-summary-goto-subject current-subject nil t)))
6315 (defun gnus-summary-rescan-group (&optional all)
6316 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6318 (gnus-summary-reselect-current-group all t))
6320 (defun gnus-summary-update-info (&optional non-destructive)
6322 (let ((group gnus-newsgroup-name))
6324 (when gnus-newsgroup-kill-headers
6325 (setq gnus-newsgroup-killed
6326 (gnus-compress-sequence
6328 (gnus-list-range-intersection
6329 gnus-newsgroup-unselected gnus-newsgroup-killed)
6330 gnus-newsgroup-unreads)
6332 (unless (listp (cdr gnus-newsgroup-killed))
6333 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6334 (let ((headers gnus-newsgroup-headers))
6335 ;; Set the new ranges of read articles.
6337 (set-buffer gnus-group-buffer)
6338 (gnus-undo-force-boundary))
6339 (gnus-update-read-articles
6340 group (gnus-sorted-union
6341 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6342 ;; Set the current article marks.
6343 (let ((gnus-newsgroup-scored
6344 (if (and (not gnus-save-score)
6345 (not non-destructive))
6347 gnus-newsgroup-scored)))
6349 (gnus-update-marks)))
6350 ;; Do the cross-ref thing.
6351 (when gnus-use-cross-reference
6352 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6353 ;; Do not switch windows but change the buffer to work.
6354 (set-buffer gnus-group-buffer)
6355 (unless (gnus-ephemeral-group-p group)
6356 (gnus-group-update-group group)))))))
6358 (defun gnus-summary-save-newsrc (&optional force)
6359 "Save the current number of read/marked articles in the dribble buffer.
6360 The dribble buffer will then be saved.
6361 If FORCE (the prefix), also save the .newsrc file(s)."
6363 (gnus-summary-update-info t)
6365 (gnus-save-newsrc-file)
6366 (gnus-dribble-save)))
6368 (defun gnus-summary-exit (&optional temporary)
6369 "Exit reading current newsgroup, and then return to group selection mode.
6370 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6372 (gnus-set-global-variables)
6373 (when (gnus-buffer-live-p gnus-article-buffer)
6375 (set-buffer gnus-article-buffer)
6376 (mm-destroy-parts gnus-article-mime-handles)
6377 ;; Set it to nil for safety reason.
6378 (setq gnus-article-mime-handle-alist nil)
6379 (setq gnus-article-mime-handles nil)))
6380 (gnus-kill-save-kill-buffer)
6381 (gnus-async-halt-prefetch)
6382 (let* ((group gnus-newsgroup-name)
6383 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6384 (gnus-group-is-exiting-p t)
6387 (buf (current-buffer)))
6389 ;; Do adaptive scoring, and possibly save score files.
6390 (when gnus-newsgroup-adaptive
6391 (gnus-score-adaptive))
6392 (when gnus-use-scoring
6394 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6395 ;; If we have several article buffers, we kill them at exit.
6396 (unless gnus-single-article-buffer
6397 (gnus-kill-buffer gnus-original-article-buffer)
6398 (setq gnus-article-current nil))
6399 (when gnus-use-cache
6400 (gnus-cache-possibly-remove-articles)
6401 (gnus-cache-save-buffers))
6402 (gnus-async-prefetch-remove-group group)
6403 (when gnus-suppress-duplicates
6404 (gnus-dup-enter-articles))
6405 (when gnus-use-trees
6406 (gnus-tree-close group))
6407 (when gnus-use-cache
6408 (gnus-cache-write-active))
6409 ;; Remove entries for this group.
6410 (nnmail-purge-split-history (gnus-group-real-name group))
6411 ;; Make all changes in this group permanent.
6413 (gnus-run-hooks 'gnus-exit-group-hook)
6414 (gnus-summary-update-info))
6415 (gnus-close-group group)
6416 ;; Make sure where we were, and go to next newsgroup.
6417 (set-buffer gnus-group-buffer)
6419 (gnus-group-jump-to-group group))
6420 (gnus-run-hooks 'gnus-summary-exit-hook)
6421 (unless (or quit-config
6422 ;; If this group has disappeared from the summary
6423 ;; buffer, don't skip forwards.
6424 (not (string= group (gnus-group-group-name))))
6425 (gnus-group-next-unread-group 1))
6426 (setq group-point (point))
6429 ;; If we have several article buffers, we kill them at exit.
6430 (unless gnus-single-article-buffer
6431 (gnus-kill-buffer gnus-article-buffer)
6432 (gnus-kill-buffer gnus-original-article-buffer)
6433 (setq gnus-article-current nil))
6435 (if (not gnus-kill-summary-on-exit)
6437 (gnus-deaden-summary)
6439 ;; We set all buffer-local variables to nil. It is unclear why
6440 ;; this is needed, but if we don't, buffer-local variables are
6441 ;; not garbage-collected, it seems. This would the lead to en
6442 ;; ever-growing Emacs.
6443 (gnus-summary-clear-local-variables)
6444 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6445 (gnus-summary-clear-local-variables))
6446 (when (get-buffer gnus-article-buffer)
6447 (bury-buffer gnus-article-buffer))
6448 ;; We clear the global counterparts of the buffer-local
6449 ;; variables as well, just to be on the safe side.
6450 (set-buffer gnus-group-buffer)
6451 (gnus-summary-clear-local-variables)
6452 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6453 (gnus-summary-clear-local-variables))
6454 ;; Return to group mode buffer.
6455 (when (eq mode 'gnus-summary-mode)
6456 (gnus-kill-buffer buf)))
6457 (setq gnus-current-select-method gnus-select-method)
6458 (pop-to-buffer gnus-group-buffer)
6459 (if (not quit-config)
6461 (goto-char group-point)
6462 (gnus-configure-windows 'group 'force))
6463 (gnus-handle-ephemeral-exit quit-config))
6464 ;; Clear the current group name.
6466 (setq gnus-newsgroup-name nil)))))
6468 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6469 (defun gnus-summary-exit-no-update (&optional no-questions)
6470 "Quit reading current newsgroup without updating read article info."
6472 (let* ((group gnus-newsgroup-name)
6473 (gnus-group-is-exiting-p t)
6474 (quit-config (gnus-group-quit-config group)))
6475 (when (or no-questions
6477 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6478 (gnus-async-halt-prefetch)
6480 (delq 'gnus-summary-expire-articles
6481 (copy-sequence gnus-summary-prepare-exit-hook)))
6482 (when (gnus-buffer-live-p gnus-article-buffer)
6484 (set-buffer gnus-article-buffer)
6485 (mm-destroy-parts gnus-article-mime-handles)
6486 ;; Set it to nil for safety reason.
6487 (setq gnus-article-mime-handle-alist nil)
6488 (setq gnus-article-mime-handles nil)))
6489 ;; If we have several article buffers, we kill them at exit.
6490 (unless gnus-single-article-buffer
6491 (gnus-kill-buffer gnus-article-buffer)
6492 (gnus-kill-buffer gnus-original-article-buffer)
6493 (setq gnus-article-current nil))
6494 (if (not gnus-kill-summary-on-exit)
6495 (gnus-deaden-summary)
6496 (gnus-close-group group)
6497 (gnus-summary-clear-local-variables)
6498 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6499 (gnus-summary-clear-local-variables))
6500 (set-buffer gnus-group-buffer)
6501 (gnus-summary-clear-local-variables)
6502 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6503 (gnus-summary-clear-local-variables))
6504 (gnus-kill-buffer gnus-summary-buffer))
6505 (unless gnus-single-article-buffer
6506 (setq gnus-article-current nil))
6507 (when gnus-use-trees
6508 (gnus-tree-close group))
6509 (gnus-async-prefetch-remove-group group)
6510 (when (get-buffer gnus-article-buffer)
6511 (bury-buffer gnus-article-buffer))
6512 ;; Return to the group buffer.
6513 (gnus-configure-windows 'group 'force)
6514 ;; Clear the current group name.
6515 (setq gnus-newsgroup-name nil)
6516 (unless (gnus-ephemeral-group-p group)
6517 (gnus-group-update-group group))
6518 (when (equal (gnus-group-group-name) group)
6519 (gnus-group-next-unread-group 1))
6521 (gnus-handle-ephemeral-exit quit-config)))))
6523 (defun gnus-handle-ephemeral-exit (quit-config)
6524 "Handle movement when leaving an ephemeral group.
6525 The state which existed when entering the ephemeral is reset."
6526 (if (not (buffer-name (car quit-config)))
6527 (gnus-configure-windows 'group 'force)
6528 (set-buffer (car quit-config))
6529 (cond ((eq major-mode 'gnus-summary-mode)
6530 (gnus-set-global-variables))
6531 ((eq major-mode 'gnus-article-mode)
6533 ;; The `gnus-summary-buffer' variable may point
6534 ;; to the old summary buffer when using a single
6536 (unless (gnus-buffer-live-p gnus-summary-buffer)
6537 (set-buffer gnus-group-buffer))
6538 (set-buffer gnus-summary-buffer)
6539 (gnus-set-global-variables))))
6540 (if (or (eq (cdr quit-config) 'article)
6541 (eq (cdr quit-config) 'pick))
6543 ;; The current article may be from the ephemeral group
6544 ;; thus it is best that we reload this article
6545 (gnus-summary-show-article)
6546 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6547 (gnus-configure-windows 'pick 'force)
6548 (gnus-configure-windows (cdr quit-config) 'force)))
6549 (gnus-configure-windows (cdr quit-config) 'force))
6550 (when (eq major-mode 'gnus-summary-mode)
6551 (gnus-summary-next-subject 1 nil t)
6552 (gnus-summary-recenter)
6553 (gnus-summary-position-point))))
6557 (defvar gnus-dead-summary-mode-map nil)
6559 (unless gnus-dead-summary-mode-map
6560 (setq gnus-dead-summary-mode-map (make-keymap))
6561 (suppress-keymap gnus-dead-summary-mode-map)
6562 (substitute-key-definition
6563 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6564 (dolist (key '("\C-d" "\r" "\177" [delete]))
6565 (define-key gnus-dead-summary-mode-map
6566 key 'gnus-summary-wake-up-the-dead))
6567 (dolist (key '("q" "Q"))
6568 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6570 (defvar gnus-dead-summary-mode nil
6571 "Minor mode for Gnus summary buffers.")
6573 (defun gnus-dead-summary-mode (&optional arg)
6574 "Minor mode for Gnus summary buffers."
6576 (when (eq major-mode 'gnus-summary-mode)
6577 (make-local-variable 'gnus-dead-summary-mode)
6578 (setq gnus-dead-summary-mode
6579 (if (null arg) (not gnus-dead-summary-mode)
6580 (> (prefix-numeric-value arg) 0)))
6581 (when gnus-dead-summary-mode
6582 (gnus-add-minor-mode
6583 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6585 (defun gnus-deaden-summary ()
6586 "Make the current summary buffer into a dead summary buffer."
6587 ;; Kill any previous dead summary buffer.
6588 (when (and gnus-dead-summary
6589 (buffer-name gnus-dead-summary))
6591 (set-buffer gnus-dead-summary)
6592 (when gnus-dead-summary-mode
6593 (kill-buffer (current-buffer)))))
6594 ;; Make this the current dead summary.
6595 (setq gnus-dead-summary (current-buffer))
6596 (gnus-dead-summary-mode 1)
6597 (let ((name (buffer-name)))
6598 (when (string-match "Summary" name)
6600 (concat (substring name 0 (match-beginning 0)) "Dead "
6601 (substring name (match-beginning 0)))
6605 (defun gnus-kill-or-deaden-summary (buffer)
6606 "Kill or deaden the summary BUFFER."
6608 (when (and (buffer-name buffer)
6609 (not gnus-single-article-buffer))
6612 (gnus-kill-buffer gnus-article-buffer)
6613 (gnus-kill-buffer gnus-original-article-buffer)))
6616 (gnus-kill-summary-on-exit
6617 (when (and gnus-use-trees
6618 (gnus-buffer-exists-p buffer))
6621 (gnus-tree-close gnus-newsgroup-name)))
6622 (gnus-kill-buffer buffer))
6623 ;; Deaden the buffer.
6624 ((gnus-buffer-exists-p buffer)
6627 (gnus-deaden-summary))))))
6629 (defun gnus-summary-wake-up-the-dead (&rest args)
6630 "Wake up the dead summary buffer."
6632 (gnus-dead-summary-mode -1)
6633 (let ((name (buffer-name)))
6634 (when (string-match "Dead " name)
6636 (concat (substring name 0 (match-beginning 0))
6637 (substring name (match-end 0)))
6639 (gnus-message 3 "This dead summary is now alive again"))
6641 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6642 (defun gnus-summary-fetch-faq (&optional faq-dir)
6643 "Fetch the FAQ for the current group.
6644 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6648 (when current-prefix-arg
6650 "FAQ dir: " (and (listp gnus-group-faq-directory)
6651 (mapcar (lambda (file) (list file))
6652 gnus-group-faq-directory))))))
6653 (let (gnus-faq-buffer)
6654 (when (setq gnus-faq-buffer
6655 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6656 (gnus-configure-windows 'summary-faq))))
6658 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6659 (defun gnus-summary-describe-group (&optional force)
6660 "Describe the current newsgroup."
6662 (gnus-group-describe-group force gnus-newsgroup-name))
6664 (defun gnus-summary-describe-briefly ()
6665 "Describe summary mode commands briefly."
6667 (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")))
6669 ;; Walking around group mode buffer from summary mode.
6671 (defun gnus-summary-next-group (&optional no-article target-group backward)
6672 "Exit current newsgroup and then select next unread newsgroup.
6673 If prefix argument NO-ARTICLE is non-nil, no article is selected
6674 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6675 previous group instead."
6677 ;; Stop pre-fetching.
6678 (gnus-async-halt-prefetch)
6679 (let ((current-group gnus-newsgroup-name)
6680 (current-buffer (current-buffer))
6682 (while (not entered)
6683 ;; Then we find what group we are supposed to enter.
6684 (set-buffer gnus-group-buffer)
6685 (gnus-group-jump-to-group current-group)
6688 (if (eq gnus-keep-same-level 'best)
6689 (gnus-summary-best-group gnus-newsgroup-name)
6690 (gnus-summary-search-group backward gnus-keep-same-level))))
6691 (if (not target-group)
6692 ;; There are no further groups, so we return to the group
6695 (gnus-message 5 "Returning to the group buffer")
6697 (when (gnus-buffer-live-p current-buffer)
6698 (set-buffer current-buffer)
6699 (gnus-summary-exit))
6700 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6701 ;; We try to enter the target group.
6702 (gnus-group-jump-to-group target-group)
6703 (let ((unreads (gnus-group-group-unread)))
6704 (if (and (or (eq t unreads)
6705 (and unreads (not (zerop unreads))))
6707 ;; Now we semi-exit this group to update Xrefs
6708 ;; and all variables. We can't do a real exit,
6709 ;; because the window conf must remain the same
6710 ;; in case the user is prompted for info, and we
6711 ;; don't want the window conf to change before
6713 (when (gnus-buffer-live-p current-buffer)
6714 (set-buffer current-buffer)
6715 (gnus-summary-exit t))
6716 (gnus-summary-read-group
6717 target-group nil no-article
6718 (and (buffer-name current-buffer) current-buffer)
6721 (setq current-group target-group
6722 target-group nil)))))))
6724 (defun gnus-summary-prev-group (&optional no-article)
6725 "Exit current newsgroup and then select previous unread newsgroup.
6726 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6728 (gnus-summary-next-group no-article nil t))
6730 ;; Walking around summary lines.
6732 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6733 "Go to the first subject satisfying any non-nil constraint.
6734 If UNREAD is non-nil, the article should be unread.
6735 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6736 If UNSEED is non-nil, the article should be unseen.
6737 Returns the article selected or nil if there are no matching articles."
6741 ((null gnus-newsgroup-data)
6742 (gnus-message 3 "No articles in the group")
6744 ;; Pick the first article.
6745 ((not (or unread undownloaded unseen))
6746 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6747 (gnus-data-number (car gnus-newsgroup-data)))
6748 ;; Find the first unread article.
6750 (let ((data gnus-newsgroup-data))
6752 (let ((num (gnus-data-number (car data))))
6753 (or (memq num gnus-newsgroup-unfetched)
6754 (not (or (and unread
6755 (memq num gnus-newsgroup-unreads))
6757 (memq num gnus-newsgroup-undownloaded))
6759 (memq num gnus-newsgroup-unseen)))))))
6760 (setq data (cdr data)))
6764 (goto-char (gnus-data-pos (car data)))
6765 (gnus-data-number (car data)))
6766 (gnus-message 3 "No more%s articles"
6767 (let* ((r (when unread " unread"))
6768 (d (when undownloaded " undownloaded"))
6769 (s (when unseen " unseen"))
6770 (l (delq nil (list r d s))))
6771 (cond ((= 3 (length l))
6772 (concat r "," d ", or" s))
6774 (concat (car l) ", or" (cadr l)))
6781 (gnus-summary-position-point))))))
6783 (defun gnus-summary-next-subject (n &optional unread dont-display)
6784 "Go to next N'th summary line.
6785 If N is negative, go to the previous N'th subject line.
6786 If UNREAD is non-nil, only unread articles are selected.
6787 The difference between N and the actual number of steps taken is
6790 (let ((backward (< n 0))
6794 (gnus-summary-find-prev unread)
6795 (gnus-summary-find-next unread)))
6796 (unless (zerop (setq n (1- n)))
6797 (gnus-summary-show-thread)))
6799 (gnus-message 7 "No more%s articles"
6800 (if unread " unread" "")))
6801 (unless dont-display
6802 (gnus-summary-recenter)
6803 (gnus-summary-position-point))
6806 (defun gnus-summary-next-unread-subject (n)
6807 "Go to next N'th unread summary line."
6809 (gnus-summary-next-subject n t))
6811 (defun gnus-summary-prev-subject (n &optional unread)
6812 "Go to previous N'th summary line.
6813 If optional argument UNREAD is non-nil, only unread article is selected."
6815 (gnus-summary-next-subject (- n) unread))
6817 (defun gnus-summary-prev-unread-subject (n)
6818 "Go to previous N'th unread summary line."
6820 (gnus-summary-next-subject (- n) t))
6822 (defun gnus-summary-goto-subjects (articles)
6823 "Insert the subject header for ARTICLES in the current buffer."
6825 (dolist (article articles)
6826 (gnus-summary-goto-subject article t)))
6827 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6828 (gnus-summary-position-point))
6830 (defun gnus-summary-goto-subject (article &optional force silent)
6831 "Go the subject line of ARTICLE.
6832 If FORCE, also allow jumping to articles not currently shown."
6833 (interactive "nArticle number: ")
6834 (unless (numberp article)
6835 (error "Article %s is not a number" article))
6837 (data (gnus-data-find article)))
6838 ;; We read in the article if we have to.
6841 (gnus-summary-insert-subject
6843 (if (or (numberp force) (vectorp force)) force)
6845 (setq data (gnus-data-find article)))
6850 (gnus-message 3 "Can't find article %d" article))
6852 (let ((pt (gnus-data-pos data)))
6854 (gnus-summary-set-article-display-arrow pt))
6855 (gnus-summary-position-point)
6858 ;; Walking around summary lines with displaying articles.
6860 (defun gnus-summary-expand-window (&optional arg)
6861 "Make the summary buffer take up the entire Emacs frame.
6862 Given a prefix, will force an `article' buffer configuration."
6865 (gnus-configure-windows 'article 'force)
6866 (gnus-configure-windows 'summary 'force)))
6868 (defun gnus-summary-display-article (article &optional all-header)
6869 "Display ARTICLE in article buffer."
6870 (when (gnus-buffer-live-p gnus-article-buffer)
6871 (with-current-buffer gnus-article-buffer
6872 (mm-enable-multibyte)))
6873 (gnus-set-global-variables)
6874 (when (gnus-buffer-live-p gnus-article-buffer)
6875 (with-current-buffer gnus-article-buffer
6876 (setq gnus-article-charset gnus-newsgroup-charset)
6877 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6878 (mm-enable-multibyte)))
6882 (if gnus-summary-display-article-function
6883 (funcall gnus-summary-display-article-function article all-header)
6884 (gnus-article-prepare article all-header))
6885 (gnus-run-hooks 'gnus-select-article-hook)
6886 (when (and gnus-current-article
6887 (not (zerop gnus-current-article)))
6888 (gnus-summary-goto-subject gnus-current-article))
6889 (gnus-summary-recenter)
6890 (when (and gnus-use-trees gnus-show-threads)
6891 (gnus-possibly-generate-tree article)
6892 (gnus-highlight-selected-tree article))
6893 ;; Successfully display article.
6894 (gnus-article-set-window-start
6895 (cdr (assq article gnus-newsgroup-bookmarks))))))
6897 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6898 "Select the current article.
6899 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6900 non-nil, the article will be re-fetched even if it already present in
6901 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6903 ;; Make sure we are in the summary buffer to work around bbdb bug.
6904 (unless (eq major-mode 'gnus-summary-mode)
6905 (set-buffer gnus-summary-buffer))
6906 (let ((article (or article (gnus-summary-article-number)))
6907 (all-headers (not (not all-headers))) ;Must be t or nil.
6908 gnus-summary-display-article-function)
6910 (gnus-summary-article-pseudo-p article)
6911 (error "This is a pseudo-article"))
6913 (set-buffer gnus-summary-buffer)
6914 (if (or (and gnus-single-article-buffer
6915 (or (null gnus-current-article)
6916 (null gnus-article-current)
6917 (null (get-buffer gnus-article-buffer))
6918 (not (eq article (cdr gnus-article-current)))
6919 (not (equal (car gnus-article-current)
6920 gnus-newsgroup-name))))
6921 (and (not gnus-single-article-buffer)
6922 (or (null gnus-current-article)
6923 (not (eq gnus-current-article article))))
6925 ;; The requested article is different from the current article.
6927 (gnus-summary-display-article article all-headers)
6928 (when (gnus-buffer-live-p gnus-article-buffer)
6929 (with-current-buffer gnus-article-buffer
6930 (if (not gnus-article-decoded-p) ;; a local variable
6931 (mm-disable-multibyte))))
6932 (gnus-article-set-window-start
6933 (cdr (assq article gnus-newsgroup-bookmarks)))
6937 (defun gnus-summary-force-verify-and-decrypt ()
6938 "Display buttons for signed/encrypted parts and verify/decrypt them."
6940 (let ((mm-verify-option 'known)
6941 (mm-decrypt-option 'known)
6942 (gnus-buttonized-mime-types (append (list "multipart/signed"
6943 "multipart/encrypted")
6944 gnus-buttonized-mime-types)))
6945 (gnus-summary-select-article nil 'force)))
6947 (defun gnus-summary-set-current-mark (&optional current-mark)
6948 "Obsolete function."
6951 (defun gnus-summary-next-article (&optional unread subject backward push)
6952 "Select the next article.
6953 If UNREAD, only unread articles are selected.
6954 If SUBJECT, only articles with SUBJECT are selected.
6955 If BACKWARD, the previous article is selected instead of the next."
6958 ;; Is there such an article?
6959 ((and (gnus-summary-search-forward unread subject backward)
6960 (or (gnus-summary-display-article (gnus-summary-article-number))
6961 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6962 (gnus-summary-position-point))
6963 ;; If not, we try the first unread, if that is wanted.
6965 gnus-auto-select-same
6966 (gnus-summary-first-unread-article))
6967 (gnus-summary-position-point)
6968 (gnus-message 6 "Wrapped"))
6969 ;; Try to get next/previous article not displayed in this group.
6970 ((and gnus-auto-extend-newsgroup
6971 (not unread) (not subject))
6972 (gnus-summary-goto-article
6973 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6974 nil (count-lines (point-min) (point))))
6975 ;; Go to next/previous group.
6977 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6978 (gnus-summary-jump-to-group gnus-newsgroup-name))
6979 (let ((cmd last-command-char)
6982 (set-buffer gnus-group-buffer)
6985 (if (eq gnus-keep-same-level 'best)
6986 (gnus-summary-best-group gnus-newsgroup-name)
6987 (gnus-summary-search-group backward gnus-keep-same-level))))
6988 ;; For some reason, the group window gets selected. We change
6990 (select-window (get-buffer-window (current-buffer)))
6991 ;; Select next unread newsgroup automagically.
6993 ((or (not gnus-auto-select-next)
6995 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6996 ((or (eq gnus-auto-select-next 'quietly)
6997 (and (eq gnus-auto-select-next 'slightly-quietly)
6999 (and (eq gnus-auto-select-next 'almost-quietly)
7000 (gnus-summary-last-article-p)))
7002 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7004 (gnus-message 7 "No more%s articles (%s)..."
7005 (if unread " unread" "")
7006 (if group (concat "selecting " group)
7008 (gnus-summary-next-group nil group backward)))
7010 (when (gnus-key-press-event-p last-input-event)
7011 (gnus-summary-walk-group-buffer
7012 gnus-newsgroup-name cmd unread backward point))))))))
7014 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7015 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7016 (?\C-p (gnus-group-prev-unread-group 1))))
7017 (cursor-in-echo-area t)
7018 keve key group ended prompt)
7020 (set-buffer gnus-group-buffer)
7023 (if (eq gnus-keep-same-level 'best)
7024 (gnus-summary-best-group gnus-newsgroup-name)
7025 (gnus-summary-search-group backward gnus-keep-same-level))))
7029 "No more%s articles%s " (if unread " unread" "")
7031 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7032 (format " (Type %s for %s [%s])"
7033 (single-key-description cmd) group
7034 (car (gnus-gethash group gnus-newsrc-hashtb)))
7035 (format " (Type %s to exit %s)"
7036 (single-key-description cmd)
7037 gnus-newsgroup-name))))
7038 ;; Confirm auto selection.
7039 (setq key (car (setq keve (gnus-read-event-char prompt)))
7042 ((assq key keystrokes)
7043 (let ((obuf (current-buffer)))
7044 (switch-to-buffer gnus-group-buffer)
7046 (gnus-group-jump-to-group group))
7047 (eval (cadr (assq key keystrokes)))
7048 (setq group (gnus-group-group-name))
7049 (switch-to-buffer obuf))
7053 (gnus-ephemeral-group-p gnus-newsgroup-name))
7055 (gnus-summary-next-group nil group backward)))
7057 (push (cdr keve) unread-command-events))))))
7059 (defun gnus-summary-next-unread-article ()
7060 "Select unread article after current one."
7062 (gnus-summary-next-article
7063 (or (not (eq gnus-summary-goto-unread 'never))
7064 (gnus-summary-last-article-p (gnus-summary-article-number)))
7065 (and gnus-auto-select-same
7066 (gnus-summary-article-subject))))
7068 (defun gnus-summary-prev-article (&optional unread subject)
7069 "Select the article after the current one.
7070 If UNREAD is non-nil, only unread articles are selected."
7072 (gnus-summary-next-article unread subject t))
7074 (defun gnus-summary-prev-unread-article ()
7075 "Select unread article before current one."
7077 (gnus-summary-prev-article
7078 (or (not (eq gnus-summary-goto-unread 'never))
7079 (gnus-summary-first-article-p (gnus-summary-article-number)))
7080 (and gnus-auto-select-same
7081 (gnus-summary-article-subject))))
7083 (defun gnus-summary-next-page (&optional lines circular stop)
7084 "Show next page of the selected article.
7085 If at the end of the current article, select the next article.
7086 LINES says how many lines should be scrolled up.
7088 If CIRCULAR is non-nil, go to the start of the article instead of
7089 selecting the next article when reaching the end of the current
7092 If STOP is non-nil, just stop when reaching the end of the message."
7094 (setq gnus-summary-buffer (current-buffer))
7095 (gnus-set-global-variables)
7096 (let ((article (gnus-summary-article-number))
7097 (article-window (get-buffer-window gnus-article-buffer t))
7099 ;; If the buffer is empty, we have no article.
7101 (error "No article to select"))
7102 (gnus-configure-windows 'article)
7103 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7104 (if (and (eq gnus-summary-goto-unread 'never)
7105 (not (gnus-summary-last-article-p article)))
7106 (gnus-summary-next-article)
7107 (gnus-summary-next-unread-article))
7108 (if (or (null gnus-current-article)
7109 (null gnus-article-current)
7110 (/= article (cdr gnus-article-current))
7111 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7112 ;; Selected subject is different from current article's.
7113 (gnus-summary-display-article article)
7114 (when article-window
7115 (gnus-eval-in-buffer-window gnus-article-buffer
7116 (setq endp (or (gnus-article-next-page lines)
7117 (gnus-article-only-boring-p))))
7120 (gnus-message 3 "End of message"))
7122 (gnus-summary-beginning-of-article))
7124 (gnus-message 3 "End of message"))
7126 (if (and (eq gnus-summary-goto-unread 'never)
7127 (not (gnus-summary-last-article-p article)))
7128 (gnus-summary-next-article)
7129 (gnus-summary-next-unread-article))))))))
7130 (gnus-summary-recenter)
7131 (gnus-summary-position-point)))
7133 (defun gnus-summary-prev-page (&optional lines move)
7134 "Show previous page of selected article.
7135 Argument LINES specifies lines to be scrolled down.
7136 If MOVE, move to the previous unread article if point is at
7137 the beginning of the buffer."
7139 (let ((article (gnus-summary-article-number))
7140 (article-window (get-buffer-window gnus-article-buffer t))
7142 (gnus-configure-windows 'article)
7143 (if (or (null gnus-current-article)
7144 (null gnus-article-current)
7145 (/= article (cdr gnus-article-current))
7146 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7147 ;; Selected subject is different from current article's.
7148 (gnus-summary-display-article article)
7149 (gnus-summary-recenter)
7150 (when article-window
7151 (gnus-eval-in-buffer-window gnus-article-buffer
7152 (setq endp (gnus-article-prev-page lines)))
7153 (when (and move endp)
7155 (gnus-message 3 "Beginning of message"))
7157 (if (and (eq gnus-summary-goto-unread 'never)
7158 (not (gnus-summary-first-article-p article)))
7159 (gnus-summary-prev-article)
7160 (gnus-summary-prev-unread-article))))))))
7161 (gnus-summary-position-point))
7163 (defun gnus-summary-prev-page-or-article (&optional lines)
7164 "Show previous page of selected article.
7165 Argument LINES specifies lines to be scrolled down.
7166 If at the beginning of the article, go to the next article."
7168 (gnus-summary-prev-page lines t))
7170 (defun gnus-summary-scroll-up (lines)
7171 "Scroll up (or down) one line current article.
7172 Argument LINES specifies lines to be scrolled up (or down if negative)."
7174 (gnus-configure-windows 'article)
7175 (gnus-summary-show-thread)
7176 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7177 (gnus-eval-in-buffer-window gnus-article-buffer
7179 (when (gnus-article-next-page lines)
7180 (gnus-message 3 "End of message")))
7182 (gnus-article-prev-page (- lines))))))
7183 (gnus-summary-recenter)
7184 (gnus-summary-position-point))
7186 (defun gnus-summary-scroll-down (lines)
7187 "Scroll down (or up) one line current article.
7188 Argument LINES specifies lines to be scrolled down (or up if negative)."
7190 (gnus-summary-scroll-up (- lines)))
7192 (defun gnus-summary-next-same-subject ()
7193 "Select next article which has the same subject as current one."
7195 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7197 (defun gnus-summary-prev-same-subject ()
7198 "Select previous article which has the same subject as current one."
7200 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7202 (defun gnus-summary-next-unread-same-subject ()
7203 "Select next unread article which has the same subject as current one."
7205 (gnus-summary-next-article t (gnus-summary-article-subject)))
7207 (defun gnus-summary-prev-unread-same-subject ()
7208 "Select previous unread article which has the same subject as current one."
7210 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7212 (defun gnus-summary-first-unread-article ()
7213 "Select the first unread article.
7214 Return nil if there are no unread articles."
7217 (when (gnus-summary-first-subject t)
7218 (gnus-summary-show-thread)
7219 (gnus-summary-first-subject t)
7220 (gnus-summary-display-article (gnus-summary-article-number)))
7221 (gnus-summary-position-point)))
7223 (defun gnus-summary-first-unread-subject ()
7224 "Place the point on the subject line of the first unread article.
7225 Return nil if there are no unread articles."
7228 (when (gnus-summary-first-subject t)
7229 (gnus-summary-show-thread)
7230 (gnus-summary-first-subject t))
7231 (gnus-summary-position-point)))
7233 (defun gnus-summary-first-unseen-subject ()
7234 "Place the point on the subject line of the first unseen article.
7235 Return nil if there are no unseen articles."
7238 (when (gnus-summary-first-subject nil nil t)
7239 (gnus-summary-show-thread)
7240 (gnus-summary-first-subject nil nil t))
7241 (gnus-summary-position-point)))
7243 (defun gnus-summary-first-unseen-or-unread-subject ()
7244 "Place the point on the subject line of the first unseen article or,
7245 if all article have been seen, on the subject line of the first unread
7249 (unless (when (gnus-summary-first-subject nil nil t)
7250 (gnus-summary-show-thread)
7251 (gnus-summary-first-subject nil nil t))
7252 (when (gnus-summary-first-subject t)
7253 (gnus-summary-show-thread)
7254 (gnus-summary-first-subject t)))
7255 (gnus-summary-position-point)))
7257 (defun gnus-summary-first-article ()
7258 "Select the first article.
7259 Return nil if there are no articles."
7262 (when (gnus-summary-first-subject)
7263 (gnus-summary-show-thread)
7264 (gnus-summary-first-subject)
7265 (gnus-summary-display-article (gnus-summary-article-number)))
7266 (gnus-summary-position-point)))
7268 (defun gnus-summary-best-unread-article (&optional arg)
7269 "Select the unread article with the highest score.
7270 If given a prefix argument, select the next unread article that has a
7271 score higher than the default score."
7273 (let ((article (if arg
7274 (gnus-summary-better-unread-subject)
7275 (gnus-summary-best-unread-subject))))
7277 (gnus-summary-goto-article article)
7278 (error "No unread articles"))))
7280 (defun gnus-summary-best-unread-subject ()
7281 "Select the unread subject with the highest score."
7283 (let ((best -1000000)
7284 (data gnus-newsgroup-data)
7287 (and (gnus-data-unread-p (car data))
7289 (gnus-summary-article-score (gnus-data-number (car data))))
7292 article (gnus-data-number (car data))))
7293 (setq data (cdr data)))
7295 (gnus-summary-goto-subject article))
7296 (gnus-summary-position-point)
7299 (defun gnus-summary-better-unread-subject ()
7300 "Select the first unread subject that has a score over the default score."
7302 (let ((data gnus-newsgroup-data)
7304 (while (and (setq article (gnus-data-number (car data)))
7305 (or (gnus-data-read-p (car data))
7306 (not (> (gnus-summary-article-score article)
7307 gnus-summary-default-score))))
7308 (setq data (cdr data)))
7310 (gnus-summary-goto-subject article))
7311 (gnus-summary-position-point)
7314 (defun gnus-summary-last-subject ()
7315 "Go to the last displayed subject line in the group."
7316 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7318 (gnus-summary-goto-subject article))))
7320 (defun gnus-summary-goto-article (article &optional all-headers force)
7321 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7322 If ALL-HEADERS is non-nil, no header lines are hidden.
7323 If FORCE, go to the article even if it isn't displayed. If FORCE
7324 is a number, it is the line the article is to be displayed on."
7328 "Article number or Message-ID: "
7329 (mapcar (lambda (number) (list (int-to-string number)))
7330 gnus-newsgroup-limit))
7334 (if (and (stringp article)
7335 (string-match "@" article))
7336 (gnus-summary-refer-article article)
7337 (when (stringp article)
7338 (setq article (string-to-number article)))
7339 (if (gnus-summary-goto-subject article force)
7340 (gnus-summary-display-article article all-headers)
7341 (gnus-message 4 "Couldn't go to article %s" article) nil))
7342 (gnus-summary-position-point)))
7344 (defun gnus-summary-goto-last-article ()
7345 "Go to the previously read article."
7348 (when gnus-last-article
7349 (gnus-summary-goto-article gnus-last-article nil t))
7350 (gnus-summary-position-point)))
7352 (defun gnus-summary-pop-article (number)
7353 "Pop one article off the history and go to the previous.
7354 NUMBER articles will be popped off."
7357 (setq gnus-newsgroup-history
7358 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7360 (gnus-summary-goto-article (car to) nil t)
7361 (error "Article history empty")))
7362 (gnus-summary-position-point))
7364 ;; Summary commands and functions for limiting the summary buffer.
7366 (defun gnus-summary-limit-to-articles (n)
7367 "Limit the summary buffer to the next N articles.
7368 If not given a prefix, use the process marked articles instead."
7371 (let ((articles (gnus-summary-work-articles n)))
7372 (setq gnus-newsgroup-processable nil)
7373 (gnus-summary-limit articles))
7374 (gnus-summary-position-point)))
7376 (defun gnus-summary-pop-limit (&optional total)
7377 "Restore the previous limit.
7378 If given a prefix, remove all limits."
7381 (setq gnus-newsgroup-limits
7382 (list (mapcar (lambda (h) (mail-header-number h))
7383 gnus-newsgroup-headers))))
7384 (unless gnus-newsgroup-limits
7385 (error "No limit to pop"))
7387 (gnus-summary-limit nil 'pop)
7388 (gnus-summary-position-point)))
7390 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7391 "Limit the summary buffer to articles that have subjects that match a regexp.
7392 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7394 (list (read-string (if current-prefix-arg
7395 "Exclude subject (regexp): "
7396 "Limit to subject (regexp): "))
7397 nil current-prefix-arg))
7399 (setq header "subject"))
7400 (when (not (equal "" subject))
7402 (let ((articles (gnus-summary-find-matching
7403 (or header "subject") subject 'all nil nil
7406 (error "Found no matches for \"%s\"" subject))
7407 (gnus-summary-limit articles))
7408 (gnus-summary-position-point))))
7410 (defun gnus-summary-limit-to-author (from &optional not-matching)
7411 "Limit the summary buffer to articles that have authors that match a regexp.
7412 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7414 (list (read-string (if current-prefix-arg
7415 "Exclude author (regexp): "
7416 "Limit to author (regexp): "))
7417 current-prefix-arg))
7418 (gnus-summary-limit-to-subject from "from" not-matching))
7420 (defun gnus-summary-limit-to-age (age &optional younger-p)
7421 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7422 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7423 articles that are younger than AGE days."
7425 (let ((younger current-prefix-arg)
7428 (while (not days-got)
7429 (setq days (if younger
7430 (read-string "Limit to articles younger than (in days, older when negative): ")
7432 "Limit to articles older than (in days, younger when negative): ")))
7433 (when (> (length days) 0)
7434 (setq days (read days)))
7440 (setq younger (not younger))
7441 (setq days (* days -1)))))
7442 (message "Please enter a number.")
7444 (list days younger)))
7446 (let ((data gnus-newsgroup-data)
7447 (cutoff (days-to-time age))
7448 articles d date is-younger)
7449 (while (setq d (pop data))
7450 (when (and (vectorp (gnus-data-header d))
7451 (setq date (mail-header-date (gnus-data-header d))))
7452 (setq is-younger (time-less-p
7453 (time-since (condition-case ()
7460 (push (gnus-data-number d) articles))))
7461 (gnus-summary-limit (nreverse articles)))
7462 (gnus-summary-position-point)))
7464 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7465 "Limit the summary buffer to articles that match an 'extra' header."
7469 (gnus-completing-read-with-default
7470 (symbol-name (car gnus-extra-headers))
7471 (if current-prefix-arg
7472 "Exclude extra header:"
7473 "Limit extra header:")
7475 (cons (symbol-name x) x))
7480 (read-string (format "%s header %s (regexp): "
7481 (if current-prefix-arg "Exclude" "Limit to")
7483 current-prefix-arg)))
7484 (when (not (equal "" regexp))
7486 (let ((articles (gnus-summary-find-matching
7487 (cons 'extra header) regexp 'all nil nil
7490 (error "Found no matches for \"%s\"" regexp))
7491 (gnus-summary-limit articles))
7492 (gnus-summary-position-point))))
7494 (defun gnus-summary-limit-to-display-predicate ()
7495 "Limit the summary buffer to the predicated in the `display' group parameter."
7497 (unless gnus-newsgroup-display
7498 (error "There is no `display' group parameter"))
7500 (dolist (number gnus-newsgroup-articles)
7501 (when (funcall gnus-newsgroup-display)
7502 (push number articles)))
7503 (gnus-summary-limit articles))
7504 (gnus-summary-position-point))
7506 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7508 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7510 (defun gnus-summary-limit-to-unread (&optional all)
7511 "Limit the summary buffer to articles that are not marked as read.
7512 If ALL is non-nil, limit strictly to unread articles."
7515 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7516 (gnus-summary-limit-to-marks
7517 ;; Concat all the marks that say that an article is read and have
7519 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7520 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7521 gnus-low-score-mark gnus-expirable-mark
7522 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7523 gnus-duplicate-mark gnus-souped-mark)
7526 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7527 (make-obsolete 'gnus-summary-delete-marked-with
7528 'gnus-summary-limit-exclude-marks)
7530 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7531 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7532 If REVERSE, limit the summary buffer to articles that are marked
7533 with MARKS. MARKS can either be a string of marks or a list of marks.
7534 Returns how many articles were removed."
7535 (interactive "sMarks: ")
7536 (gnus-summary-limit-to-marks marks t))
7538 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7539 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7540 If REVERSE (the prefix), limit the summary buffer to articles that are
7541 not marked with MARKS. MARKS can either be a string of marks or a
7543 Returns how many articles were removed."
7544 (interactive "sMarks: \nP")
7546 (let ((data gnus-newsgroup-data)
7547 (marks (if (listp marks) marks
7548 (append marks nil))) ; Transform to list.
7551 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7552 (memq (gnus-data-mark (car data)) marks))
7553 (push (gnus-data-number (car data)) articles))
7554 (setq data (cdr data)))
7555 (gnus-summary-limit articles))
7556 (gnus-summary-position-point)))
7558 (defun gnus-summary-limit-to-score (score)
7559 "Limit to articles with score at or above SCORE."
7560 (interactive "NLimit to articles with score of at least: ")
7561 (let ((data gnus-newsgroup-data)
7564 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7566 (push (gnus-data-number (car data)) articles))
7567 (setq data (cdr data)))
7569 (gnus-summary-limit articles)
7570 (gnus-summary-position-point))))
7572 (defun gnus-summary-limit-to-unseen ()
7573 "Limit to unseen articles."
7576 (gnus-summary-limit gnus-newsgroup-unseen)
7577 (gnus-summary-position-point)))
7579 (defun gnus-summary-limit-include-thread (id)
7580 "Display all the hidden articles that is in the thread with ID in it.
7581 When called interactively, ID is the Message-ID of the current
7583 (interactive (list (mail-header-id (gnus-summary-article-header))))
7584 (let ((articles (gnus-articles-in-thread
7585 (gnus-id-to-thread (gnus-root-id id)))))
7587 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7588 (gnus-summary-limit-include-matching-articles
7590 (regexp-quote (gnus-simplify-subject-re
7591 (mail-header-subject (gnus-id-to-header id)))))
7592 (gnus-summary-position-point))))
7594 (defun gnus-summary-limit-include-matching-articles (header regexp)
7595 "Display all the hidden articles that have HEADERs that match REGEXP."
7596 (interactive (list (read-string "Match on header: ")
7597 (read-string "Regexp: ")))
7598 (let ((articles (gnus-find-matching-articles header regexp)))
7600 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7601 (gnus-summary-position-point))))
7603 (defun gnus-summary-insert-dormant-articles ()
7604 "Insert all the dormat articles for this group into the current buffer."
7606 (let ((gnus-verbose (max 6 gnus-verbose)))
7607 (if (not gnus-newsgroup-dormant)
7608 (gnus-message 3 "No cached articles for this group")
7609 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7611 (defun gnus-summary-limit-include-dormant ()
7612 "Display all the hidden articles that are marked as dormant.
7613 Note that this command only works on a subset of the articles currently
7614 fetched for this group."
7616 (unless gnus-newsgroup-dormant
7617 (error "There are no dormant articles in this group"))
7619 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7620 (gnus-summary-position-point)))
7622 (defun gnus-summary-limit-exclude-dormant ()
7623 "Hide all dormant articles."
7626 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7627 (gnus-summary-position-point)))
7629 (defun gnus-summary-limit-exclude-childless-dormant ()
7630 "Hide all dormant articles that have no children."
7632 (let ((data (gnus-data-list t))
7633 articles d children)
7634 ;; Find all articles that are either not dormant or have
7636 (while (setq d (pop data))
7637 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7639 (gnus-article-children (gnus-data-number d)))
7642 (when (memq (car children) articles)
7647 (push (gnus-data-number d) articles)))
7650 (gnus-summary-limit articles)
7651 (gnus-summary-position-point))))
7653 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7654 "Mark all unread excluded articles as read.
7655 If ALL, mark even excluded ticked and dormants as read."
7657 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7658 (let ((articles (gnus-sorted-ndifference
7660 (mapcar (lambda (h) (mail-header-number h))
7661 gnus-newsgroup-headers)
7663 gnus-newsgroup-limit))
7665 (setq gnus-newsgroup-unreads
7666 (gnus-sorted-intersection gnus-newsgroup-unreads
7667 gnus-newsgroup-limit))
7669 (setq gnus-newsgroup-dormant nil
7670 gnus-newsgroup-marked nil
7671 gnus-newsgroup-reads
7673 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7674 gnus-newsgroup-reads))
7675 (while (setq article (pop articles))
7676 (unless (or (memq article gnus-newsgroup-dormant)
7677 (memq article gnus-newsgroup-marked))
7678 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7680 (defun gnus-summary-limit (articles &optional pop)
7682 ;; We pop the previous limit off the stack and use that.
7683 (setq articles (car gnus-newsgroup-limits)
7684 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7685 ;; We use the new limit, so we push the old limit on the stack.
7686 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7688 (setq gnus-newsgroup-limit articles)
7689 (let ((total (length gnus-newsgroup-data))
7690 (data (gnus-data-find-list (gnus-summary-article-number)))
7691 (gnus-summary-mark-below nil) ; Inhibit this.
7693 ;; This will do all the work of generating the new summary buffer
7694 ;; according to the new limit.
7695 (gnus-summary-prepare)
7696 ;; Hide any threads, possibly.
7697 (gnus-summary-maybe-hide-threads)
7698 ;; Try to return to the article you were at, or one in the
7701 ;; We try to find some article after the current one.
7703 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7706 (setq data (cdr data))))
7708 ;; If there is no data, that means that we were after the last
7709 ;; article. The same goes when we can't find any articles
7710 ;; after the current one.
7711 (goto-char (point-max))
7712 (gnus-summary-find-prev))
7713 (gnus-set-mode-line 'summary)
7714 ;; We return how many articles were removed from the summary
7715 ;; buffer as a result of the new limit.
7716 (- total (length gnus-newsgroup-data))))
7718 (defsubst gnus-invisible-cut-children (threads)
7721 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7726 (defsubst gnus-cut-thread (thread)
7727 "Go forwards in the thread until we find an article that we want to display."
7728 (when (or (eq gnus-fetch-old-headers 'some)
7729 (eq gnus-fetch-old-headers 'invisible)
7730 (numberp gnus-fetch-old-headers)
7731 (eq gnus-build-sparse-threads 'some)
7732 (eq gnus-build-sparse-threads 'more))
7733 ;; Deal with old-fetched headers and sparse threads.
7737 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7738 (gnus-summary-article-ancient-p
7739 (mail-header-number (car thread))))
7740 (if (or (<= (length (cdr thread)) 1)
7741 (eq gnus-fetch-old-headers 'invisible))
7742 (setq gnus-newsgroup-limit
7743 (delq (mail-header-number (car thread))
7744 gnus-newsgroup-limit)
7745 thread (cadr thread))
7746 (when (gnus-invisible-cut-children (cdr thread))
7747 (let ((th (cdr thread)))
7749 (if (memq (mail-header-number (caar th))
7750 gnus-newsgroup-limit)
7751 (setq thread (car th)
7753 (setq th (cdr th))))))))))
7756 (defun gnus-cut-threads (threads)
7757 "Cut off all uninteresting articles from the beginning of threads."
7758 (when (or (eq gnus-fetch-old-headers 'some)
7759 (eq gnus-fetch-old-headers 'invisible)
7760 (numberp gnus-fetch-old-headers)
7761 (eq gnus-build-sparse-threads 'some)
7762 (eq gnus-build-sparse-threads 'more))
7765 (setcar th (gnus-cut-thread (car th)))
7766 (setq th (cdr th)))))
7767 ;; Remove nixed out threads.
7770 (defun gnus-summary-initial-limit (&optional show-if-empty)
7771 "Figure out what the initial limit is supposed to be on group entry.
7772 This entails weeding out unwanted dormants, low-scored articles,
7773 fetch-old-headers verbiage, and so on."
7774 ;; Most groups have nothing to remove.
7775 (if (or gnus-inhibit-limiting
7776 (and (null gnus-newsgroup-dormant)
7777 (eq gnus-newsgroup-display 'gnus-not-ignore)
7778 (not (eq gnus-fetch-old-headers 'some))
7779 (not (numberp gnus-fetch-old-headers))
7780 (not (eq gnus-fetch-old-headers 'invisible))
7781 (null gnus-summary-expunge-below)
7782 (not (eq gnus-build-sparse-threads 'some))
7783 (not (eq gnus-build-sparse-threads 'more))
7784 (null gnus-thread-expunge-below)
7785 (not gnus-use-nocem)))
7787 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7788 (setq gnus-newsgroup-limit nil)
7791 (unless (car (symbol-value node))
7792 ;; These threads have no parents -- they are roots.
7793 (let ((nodes (cdr (symbol-value node)))
7796 (if (and gnus-thread-expunge-below
7797 (< (gnus-thread-total-score (car nodes))
7798 gnus-thread-expunge-below))
7799 (gnus-expunge-thread (pop nodes))
7800 (setq thread (pop nodes))
7801 (gnus-summary-limit-children thread))))))
7802 gnus-newsgroup-dependencies)
7803 ;; If this limitation resulted in an empty group, we might
7804 ;; pop the previous limit and use it instead.
7805 (when (and (not gnus-newsgroup-limit)
7807 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7808 gnus-newsgroup-limit))
7810 (defun gnus-summary-limit-children (thread)
7811 "Return 1 if this subthread is visible and 0 if it is not."
7812 ;; First we get the number of visible children to this thread. This
7813 ;; is done by recursing down the thread using this function, so this
7814 ;; will really go down to a leaf article first, before slowly
7815 ;; working its way up towards the root.
7817 (let* ((max-lisp-eval-depth 5000)
7820 (apply '+ (mapcar 'gnus-summary-limit-children
7823 (number (mail-header-number (car thread)))
7826 (not (memq number gnus-newsgroup-marked))
7828 ;; If this article is dormant and has absolutely no visible
7829 ;; children, then this article isn't visible.
7830 (and (memq number gnus-newsgroup-dormant)
7832 ;; If this is "fetch-old-headered" and there is no
7833 ;; visible children, then we don't want this article.
7834 (and (or (eq gnus-fetch-old-headers 'some)
7835 (numberp gnus-fetch-old-headers))
7836 (gnus-summary-article-ancient-p number)
7838 ;; If this is "fetch-old-headered" and `invisible', then
7839 ;; we don't want this article.
7840 (and (eq gnus-fetch-old-headers 'invisible)
7841 (gnus-summary-article-ancient-p number))
7842 ;; If this is a sparsely inserted article with no children,
7843 ;; we don't want it.
7844 (and (eq gnus-build-sparse-threads 'some)
7845 (gnus-summary-article-sparse-p number)
7847 ;; If we use expunging, and this article is really
7848 ;; low-scored, then we don't want this article.
7849 (when (and gnus-summary-expunge-below
7851 (or (cdr (assq number gnus-newsgroup-scored))
7852 gnus-summary-default-score))
7853 gnus-summary-expunge-below))
7854 ;; We increase the expunge-tally here, but that has
7855 ;; nothing to do with the limits, really.
7856 (incf gnus-newsgroup-expunged-tally)
7857 ;; We also mark as read here, if that's wanted.
7858 (when (and gnus-summary-mark-below
7859 (< score gnus-summary-mark-below))
7860 (setq gnus-newsgroup-unreads
7861 (delq number gnus-newsgroup-unreads))
7862 (if gnus-newsgroup-auto-expire
7863 (push number gnus-newsgroup-expirable)
7864 (push (cons number gnus-low-score-mark)
7865 gnus-newsgroup-reads)))
7867 ;; Do the `display' group parameter.
7868 (and gnus-newsgroup-display
7869 (not (funcall gnus-newsgroup-display)))
7870 ;; Check NoCeM things.
7871 (if (and gnus-use-nocem
7872 (gnus-nocem-unwanted-article-p
7873 (mail-header-id (car thread))))
7875 (setq gnus-newsgroup-unreads
7876 (delq number gnus-newsgroup-unreads))
7878 ;; Nope, invisible article.
7880 ;; Ok, this article is to be visible, so we add it to the limit
7882 (push number gnus-newsgroup-limit)
7885 (defun gnus-expunge-thread (thread)
7886 "Mark all articles in THREAD as read."
7887 (let* ((number (mail-header-number (car thread))))
7888 (incf gnus-newsgroup-expunged-tally)
7889 ;; We also mark as read here, if that's wanted.
7890 (setq gnus-newsgroup-unreads
7891 (delq number gnus-newsgroup-unreads))
7892 (if gnus-newsgroup-auto-expire
7893 (push number gnus-newsgroup-expirable)
7894 (push (cons number gnus-low-score-mark)
7895 gnus-newsgroup-reads)))
7896 ;; Go recursively through all subthreads.
7897 (mapcar 'gnus-expunge-thread (cdr thread)))
7899 ;; Summary article oriented commands
7901 (defun gnus-summary-refer-parent-article (n)
7902 "Refer parent article N times.
7903 If N is negative, go to ancestor -N instead.
7904 The difference between N and the number of articles fetched is returned."
7908 (when (not (natnump n))
7913 (setq header (gnus-summary-article-header))
7914 (if (and (eq (mail-header-number header)
7915 (cdr gnus-article-current))
7916 (equal gnus-newsgroup-name
7917 (car gnus-article-current)))
7918 ;; If we try to find the parent of the currently
7919 ;; displayed article, then we take a look at the actual
7920 ;; References header, since this is slightly more
7921 ;; reliable than the References field we got from the
7924 (set-buffer gnus-original-article-buffer)
7925 (nnheader-narrow-to-headers)
7926 (unless (setq ref (message-fetch-field "references"))
7927 (setq ref (message-fetch-field "in-reply-to")))
7930 ;; It's not the current article, so we take a bet on
7931 ;; the value we got from the server.
7932 (mail-header-references header)))
7934 (not (equal ref "")))
7935 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7936 (gnus-message 1 "Couldn't find parent"))
7937 (gnus-message 1 "No references in article %d"
7938 (gnus-summary-article-number))
7941 (gnus-summary-position-point)
7944 (defun gnus-summary-refer-references ()
7945 "Fetch all articles mentioned in the References header.
7946 Return the number of articles fetched."
7948 (let ((ref (mail-header-references (gnus-summary-article-header)))
7949 (current (gnus-summary-article-number))
7953 (error "No References in the current article")
7954 ;; For each Message-ID in the References header...
7955 (while (string-match "<[^>]*>" ref)
7957 ;; ... fetch that article.
7958 (gnus-summary-refer-article
7959 (prog1 (match-string 0 ref)
7960 (setq ref (substring ref (match-end 0))))))
7961 (gnus-summary-goto-subject current)
7962 (gnus-summary-position-point)
7965 (defun gnus-summary-refer-thread (&optional limit)
7966 "Fetch all articles in the current thread.
7967 If LIMIT (the numerical prefix), fetch that many old headers instead
7968 of what's specified by the `gnus-refer-thread-limit' variable."
7970 (let ((id (mail-header-id (gnus-summary-article-header)))
7971 (limit (if limit (prefix-numeric-value limit)
7972 gnus-refer-thread-limit)))
7973 (unless (eq gnus-fetch-old-headers 'invisible)
7974 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7975 ;; Retrieve the headers and read them in.
7976 (if (eq (if (numberp limit)
7977 (gnus-retrieve-headers
7979 (+ (mail-header-number
7980 (gnus-summary-article-header))
7982 gnus-newsgroup-end))
7983 gnus-newsgroup-name (* limit 2))
7984 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
7986 (gnus-retrieve-headers (list gnus-newsgroup-end)
7987 gnus-newsgroup-name limit))
7989 (gnus-build-all-threads)
7990 (error "Can't fetch thread from backends that don't support NOV"))
7991 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7992 (gnus-summary-limit-include-thread id)))
7994 (defun gnus-summary-refer-article (message-id)
7995 "Fetch an article specified by MESSAGE-ID."
7996 (interactive "sMessage-ID: ")
7997 (when (and (stringp message-id)
7998 (not (zerop (length message-id))))
7999 ;; Construct the correct Message-ID if necessary.
8000 ;; Suggested by tale@pawl.rpi.edu.
8001 (unless (string-match "^<" message-id)
8002 (setq message-id (concat "<" message-id)))
8003 (unless (string-match ">$" message-id)
8004 (setq message-id (concat message-id ">")))
8005 (let* ((header (gnus-id-to-header message-id))
8007 (gnus-summary-article-sparse-p
8008 (mail-header-number header))
8009 (memq (mail-header-number header)
8010 gnus-newsgroup-limit)))
8013 ;; If the article is present in the buffer we just go to it.
8015 (or (not (gnus-summary-article-sparse-p
8016 (mail-header-number header)))
8019 (gnus-summary-goto-article
8020 (mail-header-number header) nil t)
8022 (gnus-summary-update-article (mail-header-number header)))))
8024 ;; We fetch the article.
8026 (dolist (gnus-override-method (gnus-refer-article-methods))
8027 (gnus-check-server gnus-override-method)
8028 ;; Fetch the header, and display the article.
8029 (when (setq number (gnus-summary-insert-subject message-id))
8030 (gnus-summary-select-article nil nil nil number)
8032 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8034 (defun gnus-refer-article-methods ()
8035 "Return a list of referable methods."
8037 ;; No method, so we default to current and native.
8038 ((null gnus-refer-article-method)
8039 (list gnus-current-select-method gnus-select-method))
8041 ((eq 'current gnus-refer-article-method)
8042 (list gnus-current-select-method))
8043 ;; List of select methods.
8044 ((not (and (symbolp (car gnus-refer-article-method))
8045 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8047 (dolist (method gnus-refer-article-method)
8048 (push (if (eq 'current method)
8049 gnus-current-select-method
8053 ;; One single select method.
8055 (list gnus-refer-article-method))))
8057 (defun gnus-summary-edit-parameters ()
8058 "Edit the group parameters of the current group."
8060 (gnus-group-edit-group gnus-newsgroup-name 'params))
8062 (defun gnus-summary-customize-parameters ()
8063 "Customize the group parameters of the current group."
8065 (gnus-group-customize gnus-newsgroup-name))
8067 (defun gnus-summary-enter-digest-group (&optional force)
8068 "Enter an nndoc group based on the current article.
8069 If FORCE, force a digest interpretation. If not, try
8070 to guess what the document format is."
8072 (let ((conf gnus-current-window-configuration))
8074 (gnus-summary-select-article))
8075 (setq gnus-current-window-configuration conf)
8076 (let* ((name (format "%s-%d"
8077 (gnus-group-prefixed-name
8078 gnus-newsgroup-name (list 'nndoc ""))
8080 (set-buffer gnus-summary-buffer)
8081 gnus-current-article)))
8082 (ogroup gnus-newsgroup-name)
8083 (params (append (gnus-info-params (gnus-get-info ogroup))
8084 (list (cons 'to-group ogroup))
8085 (list (cons 'save-article-group ogroup))))
8086 (case-fold-search t)
8087 (buf (current-buffer))
8090 (set-buffer gnus-original-article-buffer)
8091 ;; Have the digest group inherit the main mail address of
8092 ;; the parent article.
8093 (when (setq to-address (or (gnus-fetch-field "reply-to")
8094 (gnus-fetch-field "from")))
8095 (setq params (append
8096 (list (cons 'to-address
8097 (funcall gnus-decode-encoded-word-function
8099 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8100 (insert-buffer-substring gnus-original-article-buffer)
8101 ;; Remove lines that may lead nndoc to misinterpret the
8104 (goto-char (point-min))
8105 (or (search-forward "\n\n" nil t) (point)))
8106 (goto-char (point-min))
8107 (delete-matching-lines "^Path:\\|^From ")
8110 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8111 (gnus-newsgroup-ephemeral-ignored-charsets
8112 gnus-newsgroup-ignored-charsets))
8113 (gnus-group-read-ephemeral-group
8114 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8116 ,(if force 'mbox 'guess)))
8118 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8120 ;; Make all postings to this group go to the parent group.
8121 (nconc (gnus-info-params (gnus-get-info name))
8123 ;; Couldn't select this doc group.
8124 (switch-to-buffer buf)
8125 (gnus-set-global-variables)
8126 (gnus-configure-windows 'summary)
8127 (gnus-message 3 "Article couldn't be entered?"))
8128 (kill-buffer dig)))))
8130 (defun gnus-summary-read-document (n)
8131 "Open a new group based on the current article(s).
8132 This will allow you to read digests and other similar
8133 documents as newsgroups.
8134 Obeys the standard process/prefix convention."
8136 (let* ((articles (gnus-summary-work-articles n))
8137 (ogroup gnus-newsgroup-name)
8138 (params (append (gnus-info-params (gnus-get-info ogroup))
8139 (list (cons 'to-group ogroup))))
8140 article group egroup groups vgroup)
8141 (while (setq article (pop articles))
8142 (setq group (format "%s-%d" gnus-newsgroup-name article))
8143 (gnus-summary-remove-process-mark article)
8144 (when (gnus-summary-display-article article)
8147 (insert-buffer-substring gnus-original-article-buffer)
8148 ;; Remove some headers that may lead nndoc to make
8150 (message-narrow-to-head)
8151 (goto-char (point-min))
8152 (delete-matching-lines "^\\(Path\\):\\|^From ")
8155 (gnus-group-read-ephemeral-group
8156 group `(nndoc ,group (nndoc-address ,(current-buffer))
8157 (nndoc-article-type guess))
8160 ;; Make all postings to this group go to the parent group.
8161 (nconc (gnus-info-params (gnus-get-info egroup))
8163 (push egroup groups))
8164 ;; Couldn't select this doc group.
8165 (gnus-error 3 "Article couldn't be entered"))))))
8166 ;; Now we have selected all the documents.
8169 (error "None of the articles could be interpreted as documents"))
8170 ((gnus-group-read-ephemeral-group
8171 (setq vgroup (format
8172 "nnvirtual:%s-%s" gnus-newsgroup-name
8173 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8174 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8176 (cons (current-buffer) 'summary)))
8178 (error "Couldn't select virtual nndoc group")))))
8180 (defun gnus-summary-isearch-article (&optional regexp-p)
8181 "Do incremental search forward on the current article.
8182 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8184 (gnus-summary-select-article)
8185 (gnus-configure-windows 'article)
8186 (gnus-eval-in-buffer-window gnus-article-buffer
8189 (isearch-forward regexp-p))))
8191 (defun gnus-summary-search-article-forward (regexp &optional backward)
8192 "Search for an article containing REGEXP forward.
8193 If BACKWARD, search backward instead."
8196 (format "Search article %s (regexp%s): "
8197 (if current-prefix-arg "backward" "forward")
8198 (if gnus-last-search-regexp
8199 (concat ", default " gnus-last-search-regexp)
8201 current-prefix-arg))
8202 (if (string-equal regexp "")
8203 (setq regexp (or gnus-last-search-regexp ""))
8204 (setq gnus-last-search-regexp regexp)
8205 (setq gnus-article-before-search gnus-current-article))
8206 ;; Intentionally set gnus-last-article.
8207 (setq gnus-last-article gnus-article-before-search)
8208 (let ((gnus-last-article gnus-last-article))
8209 (if (gnus-summary-search-article regexp backward)
8210 (gnus-summary-show-thread)
8211 (error "Search failed: \"%s\"" regexp))))
8213 (defun gnus-summary-search-article-backward (regexp)
8214 "Search for an article containing REGEXP backward."
8217 (format "Search article backward (regexp%s): "
8218 (if gnus-last-search-regexp
8219 (concat ", default " gnus-last-search-regexp)
8221 (gnus-summary-search-article-forward regexp 'backward))
8223 (defun gnus-summary-search-article (regexp &optional backward)
8224 "Search for an article containing REGEXP.
8225 Optional argument BACKWARD means do search for backward.
8226 `gnus-select-article-hook' is not called during the search."
8227 ;; We have to require this here to make sure that the following
8228 ;; dynamic binding isn't shadowed by autoloading.
8229 (require 'gnus-async)
8231 (let ((gnus-select-article-hook nil) ;Disable hook.
8232 (gnus-article-prepare-hook nil)
8233 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8234 (gnus-use-article-prefetch nil)
8235 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8236 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8238 (gnus-keep-backlog nil)
8239 (gnus-break-pages nil)
8240 (gnus-summary-display-arrow nil)
8241 (gnus-updated-mode-lines nil)
8242 (gnus-auto-center-summary nil)
8243 (sum (current-buffer))
8244 (gnus-display-mime-function nil)
8247 (gnus-save-hidden-threads
8248 (gnus-summary-select-article)
8249 (set-buffer gnus-article-buffer)
8250 (goto-char (window-point (get-buffer-window (current-buffer))))
8254 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8256 (re-search-backward regexp nil t)
8257 (re-search-forward regexp nil t))
8258 ;; We found the regexp.
8263 (get-buffer-window (current-buffer))
8267 (get-buffer-window (current-buffer))
8270 (setq point (point)))
8271 ;; We didn't find it, so we go to the next article.
8274 (while (eq found 'not)
8275 (if (not (if backward (gnus-summary-find-prev)
8276 (gnus-summary-find-next)))
8277 ;; No more articles.
8279 ;; Select the next article and adjust point.
8280 (unless (gnus-summary-article-sparse-p
8281 (gnus-summary-article-number))
8283 (gnus-summary-select-article)
8284 (set-buffer gnus-article-buffer)
8286 (goto-char (if backward (point-max) (point-min))))))))
8287 (gnus-message 7 ""))
8288 ;; Return whether we found the regexp.
8289 (when (eq found 'found)
8291 (gnus-summary-show-thread)
8292 (gnus-summary-goto-subject gnus-current-article)
8293 (gnus-summary-position-point)
8296 (defun gnus-find-matching-articles (header regexp)
8297 "Return a list of all articles that match REGEXP on HEADER.
8298 This search includes all articles in the current group that Gnus has
8299 fetched headers for, whether they are displayed or not."
8300 (let ((articles nil)
8301 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8302 (case-fold-search t))
8303 (dolist (header gnus-newsgroup-headers)
8304 (when (string-match regexp (funcall func header))
8305 (push (mail-header-number header) articles)))
8306 (nreverse articles)))
8308 (defun gnus-summary-find-matching (header regexp &optional backward unread
8309 not-case-fold not-matching)
8310 "Return a list of all articles that match REGEXP on HEADER.
8311 The search stars on the current article and goes forwards unless
8312 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8313 If UNREAD is non-nil, only unread articles will
8314 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8315 in the comparisons. If NOT-MATCHING, return a list of all articles that
8316 not match REGEXP on HEADER."
8317 (let ((case-fold-search (not not-case-fold))
8320 (if (eq (car header) 'extra)
8323 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8325 (error "%s is an invalid header" header))
8326 (unless (fboundp (intern (concat "mail-header-" header)))
8327 (error "%s is not a valid header" header))
8328 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8329 (dolist (d (if (eq backward 'all)
8331 (gnus-data-find-list
8332 (gnus-summary-article-number)
8333 (gnus-data-list backward))))
8334 (when (and (or (not unread) ; We want all articles...
8335 (gnus-data-unread-p d)) ; Or just unreads.
8336 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8340 (funcall func (gnus-data-header d))))
8341 (string-match regexp
8342 (funcall func (gnus-data-header d)))))
8343 (push (gnus-data-number d) articles))) ; Success!
8344 (nreverse articles)))
8346 (defun gnus-summary-execute-command (header regexp command &optional backward)
8347 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8348 If HEADER is an empty string (or nil), the match is done on the entire
8349 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8351 (list (let ((completion-ignore-case t))
8354 (mapcar (lambda (header) (list (format "%s" header)))
8356 '("Number" "Subject" "From" "Lines" "Date"
8357 "Message-ID" "Xref" "References" "Body")
8358 gnus-extra-headers))
8359 nil 'require-match))
8360 (read-string "Regexp: ")
8361 (read-key-sequence "Command: ")
8362 current-prefix-arg))
8363 (when (equal header "Body")
8365 ;; Hidden thread subtrees must be searched as well.
8366 (gnus-summary-show-all-threads)
8367 ;; We don't want to change current point nor window configuration.
8369 (save-window-excursion
8371 gnus-treat-strip-trailing-blank-lines
8372 gnus-treat-strip-leading-blank-lines
8373 gnus-treat-strip-multiple-blank-lines
8374 gnus-treat-hide-boring-headers
8375 gnus-treat-fold-newsgroups
8376 gnus-article-prepare-hook)
8377 (gnus-message 6 "Executing %s..." (key-description command))
8378 ;; We'd like to execute COMMAND interactively so as to give arguments.
8379 (gnus-execute header regexp
8380 `(call-interactively ',(key-binding command))
8382 (gnus-message 6 "Executing %s...done" (key-description command))))))
8384 (defun gnus-summary-beginning-of-article ()
8385 "Scroll the article back to the beginning."
8387 (gnus-summary-select-article)
8388 (gnus-configure-windows 'article)
8389 (gnus-eval-in-buffer-window gnus-article-buffer
8391 (goto-char (point-min))
8392 (when gnus-page-broken
8393 (gnus-narrow-to-page))))
8395 (defun gnus-summary-end-of-article ()
8396 "Scroll to the end of the article."
8398 (gnus-summary-select-article)
8399 (gnus-configure-windows 'article)
8400 (gnus-eval-in-buffer-window gnus-article-buffer
8402 (goto-char (point-max))
8404 (when gnus-page-broken
8405 (gnus-narrow-to-page))))
8407 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8408 "Truncate to LEN and quote all \"(\"'s in STRING."
8409 (gnus-replace-in-string (if (and len (> (length string) len))
8410 (substring string 0 len)
8414 (defun gnus-summary-print-article (&optional filename n)
8415 "Generate and print a PostScript image of the N next (mail) articles.
8417 If N is negative, print the N previous articles. If N is nil and articles
8418 have been marked with the process mark, print these instead.
8420 If the optional first argument FILENAME is nil, send the image to the
8421 printer. If FILENAME is a string, save the PostScript image in a file with
8422 that name. If FILENAME is a number, prompt the user for the name of the file
8424 (interactive (list (ps-print-preprint current-prefix-arg)))
8425 (dolist (article (gnus-summary-work-articles n))
8426 (gnus-summary-select-article nil nil 'pseudo article)
8427 (gnus-eval-in-buffer-window gnus-article-buffer
8428 (gnus-print-buffer))
8429 (gnus-summary-remove-process-mark article))
8430 (ps-despool filename))
8432 (defun gnus-print-buffer ()
8433 (let ((buffer (generate-new-buffer " *print*")))
8436 (copy-to-buffer buffer (point-min) (point-max))
8438 (gnus-article-delete-invisible-text)
8439 (gnus-remove-text-with-property 'gnus-decoration)
8440 (when (gnus-visual-p 'article-highlight 'highlight)
8441 ;; Copy-to-buffer doesn't copy overlay. So redo
8443 (let ((gnus-article-buffer buffer))
8444 (gnus-article-highlight-citation t)
8445 (gnus-article-highlight-signature)))
8446 (let ((ps-left-header
8449 (gnus-summary-print-truncate-and-quote
8450 (mail-header-subject gnus-current-headers)
8453 (gnus-summary-print-truncate-and-quote
8454 (mail-header-from gnus-current-headers)
8458 "/pagenumberstring load"
8460 (mail-header-date gnus-current-headers) ")"))))
8461 (gnus-run-hooks 'gnus-ps-print-hook)
8464 (ps-spool-buffer-with-faces)
8465 (ps-spool-buffer)))))
8466 (kill-buffer buffer))))
8468 (defun gnus-summary-show-article (&optional arg)
8469 "Force redisplaying of the current article.
8470 If ARG (the prefix) is a number, show the article with the charset
8471 defined in `gnus-summary-show-article-charset-alist', or the charset
8473 If ARG (the prefix) is non-nil and not a number, show the raw article
8474 without any article massaging functions being run. Normally, the key strokes
8479 (gnus-summary-show-article t)
8480 (let ((gnus-newsgroup-charset
8481 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8482 (mm-read-coding-system
8483 "View as charset: " ;; actually it is coding system.
8485 (set-buffer gnus-article-buffer)
8486 (mm-detect-coding-region (point) (point-max))))))
8487 (gnus-newsgroup-ignored-charsets 'gnus-all))
8488 (gnus-summary-select-article nil 'force)
8489 (let ((deps gnus-newsgroup-dependencies)
8492 (set-buffer gnus-original-article-buffer)
8494 (message-narrow-to-head)
8495 (setq head (buffer-string))
8496 (goto-char (point-min))
8497 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8498 (goto-char (point-max))
8500 (setq lines (1- (count-lines (point) (point-max))))))
8502 (insert (format "211 %d Article retrieved.\n"
8503 (cdr gnus-article-current)))
8505 (if lines (insert (format "Lines: %d\n" lines)))
8507 (let ((nntp-server-buffer (current-buffer)))
8508 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8509 (gnus-data-set-header
8510 (gnus-data-find (cdr gnus-article-current))
8512 (gnus-summary-update-article-line
8513 (cdr gnus-article-current) header)
8514 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8515 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8517 ;; Select the article the normal way.
8518 (gnus-summary-select-article nil 'force))
8520 ;; We have to require this here to make sure that the following
8521 ;; dynamic binding isn't shadowed by autoloading.
8522 (require 'gnus-async)
8524 ;; Bind the article treatment functions to nil.
8525 (let ((gnus-have-all-headers t)
8526 gnus-article-prepare-hook
8527 gnus-article-decode-hook
8528 gnus-display-mime-function
8530 ;; Destroy any MIME parts.
8531 (when (gnus-buffer-live-p gnus-article-buffer)
8533 (set-buffer gnus-article-buffer)
8534 (mm-destroy-parts gnus-article-mime-handles)
8535 ;; Set it to nil for safety reason.
8536 (setq gnus-article-mime-handle-alist nil)
8537 (setq gnus-article-mime-handles nil)))
8538 (gnus-summary-select-article nil 'force))))
8539 (gnus-summary-goto-subject gnus-current-article)
8540 (gnus-summary-position-point))
8542 (defun gnus-summary-show-raw-article ()
8543 "Show the raw article without any article massaging functions being run."
8545 (gnus-summary-show-article t))
8547 (defun gnus-summary-verbose-headers (&optional arg)
8548 "Toggle permanent full header display.
8549 If ARG is a positive number, turn header display on.
8550 If ARG is a negative number, turn header display off."
8552 (setq gnus-show-all-headers
8553 (cond ((or (not (numberp arg))
8555 (not gnus-show-all-headers))
8558 (gnus-summary-show-article))
8560 (defun gnus-summary-toggle-header (&optional arg)
8561 "Show the headers if they are hidden, or hide them if they are shown.
8562 If ARG is a positive number, show the entire header.
8563 If ARG is a negative number, hide the unwanted header lines."
8565 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8566 (get-buffer-window gnus-article-buffer t))))
8567 (with-current-buffer gnus-article-buffer
8569 (article-narrow-to-head)
8570 (let* ((buffer-read-only nil)
8571 (inhibit-point-motion-hooks t)
8572 (hidden (if (numberp arg)
8574 (gnus-article-hidden-text-p 'headers)))
8576 (delete-region (point-min) (point-max))
8577 (with-current-buffer gnus-original-article-buffer
8578 (goto-char (setq s (point-min)))
8579 (setq e (if (search-forward "\n\n" nil t)
8582 (insert-buffer-substring gnus-original-article-buffer s e)
8583 (article-decode-encoded-words)
8585 (let ((gnus-treat-hide-headers nil)
8586 (gnus-treat-hide-boring-headers nil))
8587 (gnus-delete-wash-type 'headers)
8588 (gnus-treat-article 'head))
8589 (gnus-treat-article 'head))
8592 (set-window-start window (goto-char (point-min))))
8593 (setq gnus-page-broken
8594 (when gnus-break-pages
8595 (gnus-narrow-to-page)
8597 (gnus-set-mode-line 'article)))))
8599 (defun gnus-summary-show-all-headers ()
8600 "Make all header lines visible."
8602 (gnus-summary-toggle-header 1))
8604 (defun gnus-summary-caesar-message (&optional arg)
8605 "Caesar rotate the current article by 13.
8606 The numerical prefix specifies how many places to rotate each letter
8609 (gnus-summary-select-article)
8610 (let ((mail-header-separator ""))
8611 (gnus-eval-in-buffer-window gnus-article-buffer
8614 (let ((start (window-start))
8616 (message-caesar-buffer-body arg)
8617 (set-window-start (get-buffer-window (current-buffer)) start))))))
8619 (autoload 'unmorse-region "morse"
8620 "Convert morse coded text in region to ordinary ASCII text."
8623 (defun gnus-summary-morse-message (&optional arg)
8624 "Morse decode the current article."
8626 (gnus-summary-select-article)
8627 (let ((mail-header-separator ""))
8628 (gnus-eval-in-buffer-window gnus-article-buffer
8632 (let ((pos (window-start))
8634 (goto-char (point-min))
8635 (when (message-goto-body)
8636 (gnus-narrow-to-body))
8637 (goto-char (point-min))
8638 (while (re-search-forward "·" (point-max) t)
8639 (replace-match "."))
8640 (unmorse-region (point-min) (point-max))
8642 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8644 (defun gnus-summary-stop-page-breaking ()
8645 "Stop page breaking in the current article."
8647 (gnus-summary-select-article)
8648 (gnus-eval-in-buffer-window gnus-article-buffer
8650 (when (gnus-visual-p 'page-marker)
8651 (let ((buffer-read-only nil))
8652 (gnus-remove-text-with-property 'gnus-prev)
8653 (gnus-remove-text-with-property 'gnus-next))
8654 (setq gnus-page-broken nil))))
8656 (defun gnus-summary-move-article (&optional n to-newsgroup
8657 select-method action)
8658 "Move the current article to a different newsgroup.
8659 If N is a positive number, move the N next articles.
8660 If N is a negative number, move the N previous articles.
8661 If N is nil and any articles have been marked with the process mark,
8662 move those articles instead.
8663 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8664 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8665 re-spool using this method.
8667 When called interactively with TO-NEWSGROUP being nil, the value of
8668 the variable `gnus-move-split-methods' is used for finding a default
8669 for the target newsgroup.
8671 For this function to work, both the current newsgroup and the
8672 newsgroup that you want to move to have to support the `request-move'
8673 and `request-accept' functions.
8675 ACTION can be either `move' (the default), `crosspost' or `copy'."
8678 (setq action 'move))
8679 ;; Check whether the source group supports the required functions.
8680 (cond ((and (eq action 'move)
8681 (not (gnus-check-backend-function
8682 'request-move-article gnus-newsgroup-name)))
8683 (error "The current group does not support article moving"))
8684 ((and (eq action 'crosspost)
8685 (not (gnus-check-backend-function
8686 'request-replace-article gnus-newsgroup-name)))
8687 (error "The current group does not support article editing")))
8688 (let ((articles (gnus-summary-work-articles n))
8689 (prefix (if (gnus-check-backend-function
8690 'request-move-article gnus-newsgroup-name)
8691 (gnus-group-real-prefix gnus-newsgroup-name)
8693 (names '((move "Move" "Moving")
8694 (copy "Copy" "Copying")
8695 (crosspost "Crosspost" "Crossposting")))
8696 (copy-buf (save-excursion
8697 (nnheader-set-temp-buffer " *copy article*")))
8698 art-group to-method new-xref article to-groups)
8699 (unless (assq action names)
8700 (error "Unknown action %s" action))
8701 ;; Read the newsgroup name.
8702 (when (and (not to-newsgroup)
8703 (not select-method))
8704 (if (and gnus-move-split-methods
8706 (and (memq gnus-current-article articles)
8707 (gnus-buffer-live-p gnus-original-article-buffer))))
8708 ;; When `gnus-move-split-methods' is non-nil, we have to
8709 ;; select an article to give `gnus-read-move-group-name' an
8710 ;; opportunity to suggest an appropriate default. However,
8711 ;; we needn't render or mark the article.
8712 (let ((gnus-display-mime-function nil)
8713 (gnus-article-prepare-hook nil)
8714 (gnus-mark-article-hook nil))
8715 (gnus-summary-select-article nil nil nil (car articles))))
8717 (gnus-read-move-group-name
8718 (cadr (assq action names))
8719 (symbol-value (intern (format "gnus-current-%s-group" action)))
8721 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8722 (setq to-method (or select-method
8723 (gnus-server-to-method
8724 (gnus-group-method to-newsgroup))))
8725 ;; Check the method we are to move this article to...
8726 (unless (gnus-check-backend-function
8727 'request-accept-article (car to-method))
8728 (error "%s does not support article copying" (car to-method)))
8729 (unless (gnus-check-server to-method)
8730 (error "Can't open server %s" (car to-method)))
8731 (gnus-message 6 "%s to %s: %s..."
8732 (caddr (assq action names))
8733 (or (car select-method) to-newsgroup) articles)
8735 (setq article (pop articles))
8739 ;; Move the article.
8741 ;; Remove this article from future suppression.
8742 (gnus-dup-unsuppress-article article)
8743 (gnus-request-move-article
8744 article ; Article to move
8745 gnus-newsgroup-name ; From newsgroup
8746 (nth 1 (gnus-find-method-for-group
8747 gnus-newsgroup-name)) ; Server
8748 (list 'gnus-request-accept-article
8749 to-newsgroup (list 'quote select-method)
8750 (not articles) t) ; Accept form
8751 (not articles))) ; Only save nov last time
8752 ;; Copy the article.
8755 (set-buffer copy-buf)
8756 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8757 (gnus-request-accept-article
8758 to-newsgroup select-method (not articles) t))))
8759 ;; Crosspost the article.
8760 ((eq action 'crosspost)
8761 (let ((xref (message-tokenize-header
8762 (mail-header-xref (gnus-summary-article-header article))
8764 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8765 ":" (number-to-string article)))
8767 (setq xref (list (system-name))))
8770 (mapconcat 'identity
8771 (delete "Xref:" (delete new-xref xref))
8775 (set-buffer copy-buf)
8776 ;; First put the article in the destination group.
8777 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8778 (when (consp (setq art-group
8779 (gnus-request-accept-article
8780 to-newsgroup select-method (not articles))))
8781 (setq new-xref (concat new-xref " " (car art-group)
8783 (number-to-string (cdr art-group))))
8784 ;; Now we have the new Xrefs header, so we insert
8785 ;; it and replace the new article.
8786 (nnheader-replace-header "Xref" new-xref)
8787 (gnus-request-replace-article
8788 (cdr art-group) to-newsgroup (current-buffer))
8792 (gnus-message 1 "Couldn't %s article %s: %s"
8793 (cadr (assq action names)) article
8794 (nnheader-get-report (car to-method))))
8795 ((eq art-group 'junk)
8796 (when (eq action 'move)
8797 (let ((id (mail-header-id (gnus-data-header
8798 (assoc article (gnus-data-list nil))))))
8799 (gnus-summary-mark-article article gnus-canceled-mark)
8800 (gnus-message 4 "Deleted article %s" article)
8801 ;; run the move/copy/crosspost/respool hook
8802 (run-hook-with-args 'gnus-summary-article-delete-hook
8803 action id gnus-newsgroup-name nil
8806 (let* ((pto-group (gnus-group-prefixed-name
8807 (car art-group) to-method))
8809 (gnus-gethash pto-group gnus-newsrc-hashtb))
8810 (info (nth 2 entry))
8811 (to-group (gnus-info-group info))
8813 ;; Update the group that has been moved to.
8815 (memq action '(move copy)))
8816 (unless (member to-group to-groups)
8817 (push to-group to-groups))
8819 (unless (memq article gnus-newsgroup-unreads)
8820 (push 'read to-marks)
8822 info (gnus-add-to-range (gnus-info-read info)
8823 (list (cdr art-group)))))
8825 ;; See whether the article is to be put in the cache.
8826 (let ((marks gnus-article-mark-lists)
8827 (to-article (cdr art-group)))
8829 ;; Enter the article into the cache in the new group,
8830 ;; if that is required.
8831 (when gnus-use-cache
8832 (gnus-cache-possibly-enter-article
8834 (memq article gnus-newsgroup-marked)
8835 (memq article gnus-newsgroup-dormant)
8836 (memq article gnus-newsgroup-unreads)))
8838 (when gnus-preserve-marks
8839 ;; Copy any marks over to the new group.
8840 (when (and (equal to-group gnus-newsgroup-name)
8841 (not (memq article gnus-newsgroup-unreads)))
8842 ;; Mark this article as read in this group.
8843 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8844 (setcdr (gnus-active to-group) to-article)
8845 (setcdr gnus-newsgroup-active to-article))
8848 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8849 (when (memq article (symbol-value
8850 (intern (format "gnus-newsgroup-%s"
8852 (push (cdar marks) to-marks)
8853 ;; If the other group is the same as this group,
8854 ;; then we have to add the mark to the list.
8855 (when (equal to-group gnus-newsgroup-name)
8856 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8859 (intern (format "gnus-newsgroup-%s"
8861 ;; Copy the marks to other group.
8862 (gnus-add-marked-articles
8863 to-group (cdar marks) (list to-article) info)))
8864 (setq marks (cdr marks)))
8866 (gnus-request-set-mark
8867 to-group (list (list (list to-article) 'add to-marks))))
8870 (concat "(gnus-group-set-info '"
8871 (gnus-prin1-to-string (gnus-get-info to-group))
8874 ;; Update the Xref header in this article to point to
8875 ;; the new crossposted article we have just created.
8876 (when (eq action 'crosspost)
8878 (set-buffer copy-buf)
8879 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8880 (nnheader-replace-header "Xref" new-xref)
8881 (gnus-request-replace-article
8882 article gnus-newsgroup-name (current-buffer))))
8884 ;; run the move/copy/crosspost/respool hook
8885 (let ((id (mail-header-id (gnus-data-header
8886 (assoc article (gnus-data-list nil))))))
8887 (run-hook-with-args 'gnus-summary-article-move-hook
8888 action id gnus-newsgroup-name to-newsgroup
8891 ;;;!!!Why is this necessary?
8892 (set-buffer gnus-summary-buffer)
8894 (gnus-summary-goto-subject article)
8895 (when (eq action 'move)
8896 (gnus-summary-mark-article article gnus-canceled-mark))))
8897 (gnus-summary-remove-process-mark article))
8898 ;; Re-activate all groups that have been moved to.
8900 (set-buffer gnus-group-buffer)
8901 (let ((gnus-group-marked to-groups))
8902 (gnus-group-get-new-news-this-group nil t)))
8904 (gnus-kill-buffer copy-buf)
8905 (gnus-summary-position-point)
8906 (gnus-set-mode-line 'summary)))
8908 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8909 "Move the current article to a different newsgroup.
8910 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8911 When called interactively, if TO-NEWSGROUP is nil, use the value of
8912 the variable `gnus-move-split-methods' for finding a default target
8914 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8915 re-spool using this method."
8917 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8919 (defun gnus-summary-crosspost-article (&optional n)
8920 "Crosspost the current article to some other group."
8922 (gnus-summary-move-article n nil nil 'crosspost))
8924 (defcustom gnus-summary-respool-default-method nil
8925 "Default method type for respooling an article.
8926 If nil, use to the current newsgroup method."
8928 :group 'gnus-summary-mail)
8930 (defcustom gnus-summary-display-while-building nil
8931 "If not-nil, show and update the summary buffer as it's being built.
8932 If the value is t, update the buffer after every line is inserted. If
8933 the value is an integer (N), update the display every N lines."
8935 :type '(choice (const :tag "off" nil)
8937 (const :tag "frequently" t)))
8939 (defun gnus-summary-respool-article (&optional n method)
8940 "Respool the current article.
8941 The article will be squeezed through the mail spooling process again,
8942 which means that it will be put in some mail newsgroup or other
8943 depending on `nnmail-split-methods'.
8944 If N is a positive number, respool the N next articles.
8945 If N is a negative number, respool the N previous articles.
8946 If N is nil and any articles have been marked with the process mark,
8947 respool those articles instead.
8949 Respooling can be done both from mail groups and \"real\" newsgroups.
8950 In the former case, the articles in question will be moved from the
8951 current group into whatever groups they are destined to. In the
8952 latter case, they will be copied into the relevant groups."
8954 (list current-prefix-arg
8955 (let* ((methods (gnus-methods-using 'respool))
8957 (symbol-name (or gnus-summary-respool-default-method
8958 (car (gnus-find-method-for-group
8959 gnus-newsgroup-name)))))
8961 (gnus-completing-read-with-default
8962 methname "What backend do you want to use when respooling?"
8963 methods nil t nil 'gnus-mail-method-history))
8966 ((zerop (length (setq ms (gnus-servers-using-backend
8968 (list (intern method) ""))
8972 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8973 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8976 (error "No method given for respooling"))
8977 (if (assoc (symbol-name
8978 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8979 (gnus-methods-using 'respool))
8980 (gnus-summary-move-article n nil method)
8981 (gnus-summary-copy-article n nil method)))
8983 (defun gnus-summary-import-article (file &optional edit)
8984 "Import an arbitrary file into a mail newsgroup."
8985 (interactive "fImport file: \nP")
8986 (let ((group gnus-newsgroup-name)
8987 (now (current-time))
8988 atts lines group-art)
8989 (unless (gnus-check-backend-function 'request-accept-article group)
8990 (error "%s does not support article importing" group))
8991 (or (file-readable-p file)
8992 (not (file-regular-p file))
8993 (error "Can't read %s" file))
8995 (set-buffer (gnus-get-buffer-create " *import file*"))
8997 (nnheader-insert-file-contents file)
8998 (goto-char (point-min))
8999 (if (nnheader-article-p)
9001 (goto-char (point-min))
9002 (search-forward "\n\n" nil t)
9003 (narrow-to-region (point-min) (1- (point)))
9004 (goto-char (point-min))
9005 (unless (re-search-forward "^date:" nil t)
9006 (goto-char (point-max))
9007 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9008 ;; This doesn't look like an article, so we fudge some headers.
9009 (setq atts (file-attributes file)
9010 lines (count-lines (point-min) (point-max)))
9011 (insert "From: " (read-string "From: ") "\n"
9012 "Subject: " (read-string "Subject: ") "\n"
9013 "Date: " (message-make-date (nth 5 atts)) "\n"
9014 "Message-ID: " (message-make-message-id) "\n"
9015 "Lines: " (int-to-string lines) "\n"
9016 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9017 (setq group-art (gnus-request-accept-article group nil t))
9018 (kill-buffer (current-buffer)))
9019 (setq gnus-newsgroup-active (gnus-activate-group group))
9021 (gnus-summary-goto-article (cdr group-art) nil t)
9023 (gnus-summary-edit-article))))
9025 (defun gnus-summary-create-article ()
9026 "Create an article in a mail newsgroup."
9028 (let ((group gnus-newsgroup-name)
9029 (now (current-time))
9031 (unless (gnus-check-backend-function 'request-accept-article group)
9032 (error "%s does not support article importing" group))
9034 (set-buffer (gnus-get-buffer-create " *import file*"))
9036 (goto-char (point-min))
9037 ;; This doesn't look like an article, so we fudge some headers.
9038 (insert "From: " (read-string "From: ") "\n"
9039 "Subject: " (read-string "Subject: ") "\n"
9040 "Date: " (message-make-date now) "\n"
9041 "Message-ID: " (message-make-message-id) "\n")
9042 (setq group-art (gnus-request-accept-article group nil t))
9043 (kill-buffer (current-buffer)))
9044 (setq gnus-newsgroup-active (gnus-activate-group group))
9046 (gnus-summary-goto-article (cdr group-art) nil t)
9047 (gnus-summary-edit-article)))
9049 (defun gnus-summary-article-posted-p ()
9050 "Say whether the current (mail) article is available from news as well.
9051 This will be the case if the article has both been mailed and posted."
9053 (let ((id (mail-header-references (gnus-summary-article-header)))
9054 (gnus-override-method (car (gnus-refer-article-methods))))
9055 (if (gnus-request-head id "")
9056 (gnus-message 2 "The current message was found on %s"
9057 gnus-override-method)
9058 (gnus-message 2 "The current message couldn't be found on %s"
9059 gnus-override-method)
9062 (defun gnus-summary-expire-articles (&optional now)
9063 "Expire all articles that are marked as expirable in the current group."
9065 (when (gnus-check-backend-function
9066 'request-expire-articles gnus-newsgroup-name)
9067 ;; This backend supports expiry.
9068 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9069 (expirable (if total
9071 ;; We need to update the info for
9072 ;; this group for `gnus-list-of-read-articles'
9073 ;; to give us the right answer.
9074 (gnus-run-hooks 'gnus-exit-group-hook)
9075 (gnus-summary-update-info)
9076 (gnus-list-of-read-articles gnus-newsgroup-name))
9077 (setq gnus-newsgroup-expirable
9078 (sort gnus-newsgroup-expirable '<))))
9079 (expiry-wait (if now 'immediate
9080 (gnus-group-find-parameter
9081 gnus-newsgroup-name 'expiry-wait)))
9082 (nnmail-expiry-target
9083 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9084 nnmail-expiry-target))
9087 ;; There are expirable articles in this group, so we run them
9088 ;; through the expiry process.
9089 (gnus-message 6 "Expiring articles...")
9090 (unless (gnus-check-group gnus-newsgroup-name)
9091 (error "Can't open server for %s" gnus-newsgroup-name))
9092 ;; The list of articles that weren't expired is returned.
9095 (let ((nnmail-expiry-wait-function nil)
9096 (nnmail-expiry-wait expiry-wait))
9097 (setq es (gnus-request-expire-articles
9098 expirable gnus-newsgroup-name)))
9099 (setq es (gnus-request-expire-articles
9100 expirable gnus-newsgroup-name)))
9102 (setq gnus-newsgroup-expirable es))
9103 ;; We go through the old list of expirable, and mark all
9104 ;; really expired articles as nonexistent.
9105 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9106 (let ((gnus-use-cache nil))
9107 (dolist (article expirable)
9108 (when (and (not (memq article es))
9109 (gnus-data-find article))
9110 (gnus-summary-mark-article article gnus-canceled-mark)
9111 (let ((id (mail-header-id (gnus-data-header
9113 (gnus-data-list nil))))))
9114 (run-hook-with-args 'gnus-summary-article-expire-hook
9115 'delete id gnus-newsgroup-name nil
9117 (gnus-message 6 "Expiring articles...done")))))
9119 (defun gnus-summary-expire-articles-now ()
9120 "Expunge all expirable articles in the current group.
9121 This means that *all* articles that are marked as expirable will be
9122 deleted forever, right now."
9124 (or gnus-expert-user
9126 "Are you really, really, really sure you want to delete all these messages? ")
9128 (gnus-summary-expire-articles t))
9130 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9131 (defun gnus-summary-delete-article (&optional n)
9132 "Delete the N next (mail) articles.
9133 This command actually deletes articles. This is not a marking
9134 command. The article will disappear forever from your life, never to
9136 If N is negative, delete backwards.
9137 If N is nil and articles have been marked with the process mark,
9138 delete these instead."
9140 (unless (gnus-check-backend-function 'request-expire-articles
9141 gnus-newsgroup-name)
9142 (error "The current newsgroup does not support article deletion"))
9143 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9144 (error "Couldn't open server"))
9145 ;; Compute the list of articles to delete.
9146 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9147 (nnmail-expiry-target 'delete)
9149 (if (and gnus-novice-user
9150 (not (gnus-yes-or-no-p
9151 (format "Do you really want to delete %s forever? "
9152 (if (> (length articles) 1)
9153 (format "these %s articles" (length articles))
9156 ;; Delete the articles.
9157 (setq not-deleted (gnus-request-expire-articles
9158 articles gnus-newsgroup-name 'force))
9160 (gnus-summary-remove-process-mark (car articles))
9161 ;; The backend might not have been able to delete the article
9163 (unless (memq (car articles) not-deleted)
9164 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9165 (let* ((article (car articles))
9166 (id (mail-header-id (gnus-data-header
9167 (assoc article (gnus-data-list nil))))))
9168 (run-hook-with-args 'gnus-summary-article-delete-hook
9169 'delete id gnus-newsgroup-name nil
9171 (setq articles (cdr articles)))
9173 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9174 (gnus-summary-position-point)
9175 (gnus-set-mode-line 'summary)
9178 (defun gnus-summary-edit-article (&optional arg)
9179 "Edit the current article.
9180 This will have permanent effect only in mail groups.
9181 If ARG is nil, edit the decoded articles.
9182 If ARG is 1, edit the raw articles.
9183 If ARG is 2, edit the raw articles even in read-only groups.
9184 If ARG is 3, edit the articles with the current handles.
9185 Otherwise, allow editing of articles even in read-only
9188 (let (force raw current-handles)
9197 (setq current-handles
9198 (and (gnus-buffer-live-p gnus-article-buffer)
9199 (with-current-buffer gnus-article-buffer
9201 gnus-article-mime-handles
9202 (setq gnus-article-mime-handles nil))))))
9205 (when (and raw (not force)
9206 (member gnus-newsgroup-name '("nndraft:delayed"
9209 (error "Can't edit the raw article in group %s"
9210 gnus-newsgroup-name))
9212 (set-buffer gnus-summary-buffer)
9213 (let ((mail-parse-charset gnus-newsgroup-charset)
9214 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9215 (gnus-set-global-variables)
9216 (when (and (not force)
9217 (gnus-group-read-only-p))
9218 (error "The current newsgroup does not support article editing"))
9219 (gnus-summary-show-article t)
9220 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9221 (with-current-buffer gnus-article-buffer
9222 (mm-enable-multibyte)))
9223 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9225 (gnus-article-edit-article
9228 (let ((mbl mml-buffer-list))
9229 (setq mml-buffer-list nil)
9230 (mime-to-mml ,'current-handles)
9231 (let ((mbl1 mml-buffer-list))
9232 (setq mml-buffer-list mbl)
9233 (set (make-local-variable 'mml-buffer-list) mbl1))
9234 (make-local-hook 'kill-buffer-hook)
9235 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9236 `(lambda (no-highlight)
9237 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9238 (message-options message-options)
9239 (message-options-set-recipient)
9240 (mail-parse-ignored-charsets
9241 ',gnus-newsgroup-ignored-charsets))
9242 ,(if (not raw) '(progn
9244 (mml-destroy-buffers)
9245 (remove-hook 'kill-buffer-hook
9246 'mml-destroy-buffers t)
9247 (kill-local-variable 'mml-buffer-list)))
9248 (gnus-summary-edit-article-done
9249 ,(or (mail-header-references gnus-current-headers) "")
9250 ,(gnus-group-read-only-p)
9251 ,gnus-summary-buffer no-highlight))))))))
9253 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9255 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9257 "Make edits to the current article permanent."
9260 ;; The buffer restriction contains the entire article if it exists.
9261 (when (article-goto-body)
9262 (let ((lines (count-lines (point) (point-max)))
9263 (length (- (point-max) (point)))
9264 (case-fold-search t)
9265 (body (copy-marker (point))))
9266 (goto-char (point-min))
9267 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9268 (delete-region (match-beginning 1) (match-end 1))
9269 (insert (number-to-string length)))
9270 (goto-char (point-min))
9271 (when (re-search-forward
9272 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9273 (delete-region (match-beginning 1) (match-end 1))
9274 (insert (number-to-string length)))
9275 (goto-char (point-min))
9276 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9277 (delete-region (match-beginning 1) (match-end 1))
9278 (insert (number-to-string lines))))))
9279 ;; Replace the article.
9280 (let ((buf (current-buffer)))
9282 (insert-buffer-substring buf)
9284 (if (and (not read-only)
9285 (not (gnus-request-replace-article
9286 (cdr gnus-article-current) (car gnus-article-current)
9287 (current-buffer) t)))
9288 (error "Couldn't replace article")
9289 ;; Update the summary buffer.
9291 (equal (message-tokenize-header references " ")
9292 (message-tokenize-header
9293 (or (message-fetch-field "references") "") " ")))
9294 ;; We only have to update this line.
9297 (message-narrow-to-head)
9298 (let ((head (buffer-string))
9301 (insert (format "211 %d Article retrieved.\n"
9302 (cdr gnus-article-current)))
9305 (let ((nntp-server-buffer (current-buffer)))
9306 (setq header (car (gnus-get-newsgroup-headers
9309 (set-buffer gnus-summary-buffer)
9310 (gnus-data-set-header
9311 (gnus-data-find (cdr gnus-article-current))
9313 (gnus-summary-update-article-line
9314 (cdr gnus-article-current) header)
9315 (if (gnus-summary-goto-subject
9316 (cdr gnus-article-current) nil t)
9317 (gnus-summary-update-secondary-mark
9318 (cdr gnus-article-current))))))))
9320 (set-buffer (or buffer gnus-summary-buffer))
9321 (gnus-summary-update-article (cdr gnus-article-current))
9322 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9323 (gnus-summary-update-secondary-mark
9324 (cdr gnus-article-current))))
9325 ;; Prettify the article buffer again.
9326 (unless no-highlight
9328 (set-buffer gnus-article-buffer)
9329 ;;;!!! Fix this -- article should be rehighlighted.
9330 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9331 (set-buffer gnus-original-article-buffer)
9332 (gnus-request-article
9333 (cdr gnus-article-current)
9334 (car gnus-article-current) (current-buffer))))
9335 ;; Prettify the summary buffer line.
9336 (when (gnus-visual-p 'summary-highlight 'highlight)
9337 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9339 (defun gnus-summary-edit-wash (key)
9340 "Perform editing command KEY in the article buffer."
9344 (message "%s" (concat (this-command-keys) "- "))
9347 (gnus-summary-edit-article)
9348 (execute-kbd-macro (concat (this-command-keys) key))
9349 (gnus-article-edit-done))
9353 (defun gnus-summary-respool-query (&optional silent trace)
9354 "Query where the respool algorithm would put this article."
9356 (let (gnus-mark-article-hook)
9357 (gnus-summary-select-article)
9359 (set-buffer gnus-original-article-buffer)
9361 (message-narrow-to-head)
9362 (let ((groups (nnmail-article-group 'identity trace)))
9365 (message "This message would go to %s"
9366 (mapconcat 'car groups ", "))
9367 (message "This message would go to no groups"))
9370 (defun gnus-summary-respool-trace ()
9371 "Trace where the respool algorithm would put this article.
9372 Display a buffer showing all fancy splitting patterns which matched."
9374 (gnus-summary-respool-query nil t))
9376 ;; Summary marking commands.
9378 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9379 "Mark articles which has the same subject as read, and then select the next.
9380 If UNMARK is positive, remove any kind of mark.
9381 If UNMARK is negative, tick articles."
9384 (setq unmark (prefix-numeric-value unmark)))
9386 (gnus-summary-mark-same-subject
9387 (gnus-summary-article-subject) unmark)))
9388 ;; Select next unread article. If auto-select-same mode, should
9389 ;; select the first unread article.
9390 (gnus-summary-next-article t (and gnus-auto-select-same
9391 (gnus-summary-article-subject)))
9392 (gnus-message 7 "%d article%s marked as %s"
9393 count (if (= count 1) " is" "s are")
9394 (if unmark "unread" "read"))))
9396 (defun gnus-summary-kill-same-subject (&optional unmark)
9397 "Mark articles which has the same subject as read.
9398 If UNMARK is positive, remove any kind of mark.
9399 If UNMARK is negative, tick articles."
9402 (setq unmark (prefix-numeric-value unmark)))
9404 (gnus-summary-mark-same-subject
9405 (gnus-summary-article-subject) unmark)))
9406 ;; If marked as read, go to next unread subject.
9408 ;; Go to next unread subject.
9409 (gnus-summary-next-subject 1 t))
9410 (gnus-message 7 "%d articles are marked as %s"
9411 count (if unmark "unread" "read"))))
9413 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9414 "Mark articles with same SUBJECT as read, and return marked number.
9415 If optional argument UNMARK is positive, remove any kinds of marks.
9416 If optional argument UNMARK is negative, mark articles as unread instead."
9420 ((null unmark) ; Mark as read.
9423 (gnus-summary-mark-article-as-read gnus-killed-mark)
9424 (gnus-summary-show-thread) t)
9425 (gnus-summary-find-subject subject))
9426 (setq count (1+ count))))
9427 ((> unmark 0) ; Tick.
9430 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9431 (gnus-summary-show-thread) t)
9432 (gnus-summary-find-subject subject))
9433 (setq count (1+ count))))
9434 (t ; Mark as unread.
9437 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9438 (gnus-summary-show-thread) t)
9439 (gnus-summary-find-subject subject))
9440 (setq count (1+ count)))))
9441 (gnus-set-mode-line 'summary)
9442 ;; Return the number of marked articles.
9445 (defun gnus-summary-mark-as-processable (n &optional unmark)
9446 "Set the process mark on the next N articles.
9447 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9448 the process mark instead. The difference between N and the actual
9449 number of articles marked is returned."
9451 (if (and (null n) (gnus-region-active-p))
9452 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9453 (setq n (prefix-numeric-value n))
9454 (let ((backward (< n 0))
9459 (gnus-summary-remove-process-mark
9460 (gnus-summary-article-number))
9461 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9462 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9465 (gnus-message 7 "No more articles"))
9466 (gnus-summary-recenter)
9467 (gnus-summary-position-point)
9470 (defun gnus-summary-unmark-as-processable (n)
9471 "Remove the process mark from the next N articles.
9472 If N is negative, unmark backward instead. The difference between N and
9473 the actual number of articles unmarked is returned."
9475 (gnus-summary-mark-as-processable n t))
9477 (defun gnus-summary-unmark-all-processable ()
9478 "Remove the process mark from all articles."
9481 (while gnus-newsgroup-processable
9482 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9483 (gnus-summary-position-point))
9485 (defun gnus-summary-add-mark (article type)
9486 "Mark ARTICLE with a mark of TYPE."
9487 (let ((vtype (car (assq type gnus-article-mark-lists)))
9490 (error "No such mark type: %s" type)
9491 (setq var (intern (format "gnus-newsgroup-%s" type)))
9492 (set var (cons article (symbol-value var)))
9493 (if (memq type '(processable cached replied forwarded recent saved))
9494 (gnus-summary-update-secondary-mark article)
9495 ;;; !!! This is bogus. We should find out what primary
9496 ;;; !!! mark we want to set.
9497 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9499 (defun gnus-summary-mark-as-expirable (n)
9500 "Mark N articles forward as expirable.
9501 If N is negative, mark backward instead. The difference between N and
9502 the actual number of articles marked is returned."
9504 (gnus-summary-mark-forward n gnus-expirable-mark))
9506 (defun gnus-summary-mark-as-spam (n)
9507 "Mark N articles forward as spam.
9508 If N is negative, mark backward instead. The difference between N and
9509 the actual number of articles marked is returned."
9511 (gnus-summary-mark-forward n gnus-spam-mark))
9513 (defun gnus-summary-mark-article-as-replied (article)
9514 "Mark ARTICLE as replied to and update the summary line.
9515 ARTICLE can also be a list of articles."
9516 (interactive (list (gnus-summary-article-number)))
9517 (let ((articles (if (listp article) article (list article))))
9518 (dolist (article articles)
9519 (unless (numberp article)
9520 (error "%s is not a number" article))
9521 (push article gnus-newsgroup-replied)
9522 (let ((buffer-read-only nil))
9523 (when (gnus-summary-goto-subject article nil t)
9524 (gnus-summary-update-secondary-mark article))))))
9526 (defun gnus-summary-mark-article-as-forwarded (article)
9527 "Mark ARTICLE as forwarded and update the summary line.
9528 ARTICLE can also be a list of articles."
9529 (let ((articles (if (listp article) article (list article))))
9530 (dolist (article articles)
9531 (push article gnus-newsgroup-forwarded)
9532 (let ((buffer-read-only nil))
9533 (when (gnus-summary-goto-subject article nil t)
9534 (gnus-summary-update-secondary-mark article))))))
9536 (defun gnus-summary-set-bookmark (article)
9537 "Set a bookmark in current article."
9538 (interactive (list (gnus-summary-article-number)))
9539 (when (or (not (get-buffer gnus-article-buffer))
9540 (not gnus-current-article)
9541 (not gnus-article-current)
9542 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9543 (error "No current article selected"))
9544 ;; Remove old bookmark, if one exists.
9545 (gnus-pull article gnus-newsgroup-bookmarks)
9546 ;; Set the new bookmark, which is on the form
9547 ;; (article-number . line-number-in-body).
9551 (set-buffer gnus-article-buffer)
9558 gnus-newsgroup-bookmarks)
9559 (gnus-message 6 "A bookmark has been added to the current article."))
9561 (defun gnus-summary-remove-bookmark (article)
9562 "Remove the bookmark from the current article."
9563 (interactive (list (gnus-summary-article-number)))
9564 ;; Remove old bookmark, if one exists.
9565 (if (not (assq article gnus-newsgroup-bookmarks))
9566 (gnus-message 6 "No bookmark in current article.")
9567 (gnus-pull article gnus-newsgroup-bookmarks)
9568 (gnus-message 6 "Removed bookmark.")))
9570 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9571 (defun gnus-summary-mark-as-dormant (n)
9572 "Mark N articles forward as dormant.
9573 If N is negative, mark backward instead. The difference between N and
9574 the actual number of articles marked is returned."
9576 (gnus-summary-mark-forward n gnus-dormant-mark))
9578 (defun gnus-summary-set-process-mark (article)
9579 "Set the process mark on ARTICLE and update the summary line."
9580 (setq gnus-newsgroup-processable
9582 (delq article gnus-newsgroup-processable)))
9583 (when (gnus-summary-goto-subject article)
9584 (gnus-summary-show-thread)
9585 (gnus-summary-goto-subject article)
9586 (gnus-summary-update-secondary-mark article)))
9588 (defun gnus-summary-remove-process-mark (article)
9589 "Remove the process mark from ARTICLE and update the summary line."
9590 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9591 (when (gnus-summary-goto-subject article)
9592 (gnus-summary-show-thread)
9593 (gnus-summary-goto-subject article)
9594 (gnus-summary-update-secondary-mark article)))
9596 (defun gnus-summary-set-saved-mark (article)
9597 "Set the process mark on ARTICLE and update the summary line."
9598 (push article gnus-newsgroup-saved)
9599 (when (gnus-summary-goto-subject article)
9600 (gnus-summary-update-secondary-mark article)))
9602 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9603 "Mark N articles as read forwards.
9604 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9605 The difference between N and the actual number of articles marked is
9607 If NO-EXPIRE, auto-expiry will be inhibited."
9609 (gnus-summary-show-thread)
9610 (let ((backward (< n 0))
9611 (gnus-summary-goto-unread
9612 (and gnus-summary-goto-unread
9613 (not (eq gnus-summary-goto-unread 'never))
9614 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9615 gnus-ticked-mark gnus-dormant-mark)))))
9617 (mark (or mark gnus-del-mark)))
9619 (gnus-summary-mark-article nil mark no-expire)
9620 (zerop (gnus-summary-next-subject
9622 (and gnus-summary-goto-unread
9623 (not (eq gnus-summary-goto-unread 'never)))
9627 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9628 (gnus-summary-recenter)
9629 (gnus-summary-position-point)
9630 (gnus-set-mode-line 'summary)
9633 (defun gnus-summary-mark-article-as-read (mark)
9634 "Mark the current article quickly as read with MARK."
9635 (let ((article (gnus-summary-article-number)))
9636 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9637 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9638 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9639 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9640 (push (cons article mark) gnus-newsgroup-reads)
9641 ;; Possibly remove from cache, if that is used.
9642 (when gnus-use-cache
9643 (gnus-cache-enter-remove-article article))
9644 ;; Allow the backend to change the mark.
9645 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9646 ;; Check for auto-expiry.
9647 (when (and gnus-newsgroup-auto-expire
9648 (memq mark gnus-auto-expirable-marks))
9649 (setq mark gnus-expirable-mark)
9650 ;; Let the backend know about the mark change.
9651 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9652 (push article gnus-newsgroup-expirable))
9653 ;; Set the mark in the buffer.
9654 (gnus-summary-update-mark mark 'unread)
9657 (defun gnus-summary-mark-article-as-unread (mark)
9658 "Mark the current article quickly as unread with MARK."
9659 (let* ((article (gnus-summary-article-number))
9660 (old-mark (gnus-summary-article-mark article)))
9661 ;; Allow the backend to change the mark.
9662 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9663 (if (eq mark old-mark)
9667 (gnus-error 1 "Can't mark negative article numbers")
9669 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9670 (setq gnus-newsgroup-spam-marked
9671 (delq article gnus-newsgroup-spam-marked))
9672 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9673 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9674 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9675 (cond ((= mark gnus-ticked-mark)
9676 (setq gnus-newsgroup-marked
9677 (gnus-add-to-sorted-list gnus-newsgroup-marked
9679 ((= mark gnus-spam-mark)
9680 (setq gnus-newsgroup-spam-marked
9681 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9683 ((= mark gnus-dormant-mark)
9684 (setq gnus-newsgroup-dormant
9685 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9688 (setq gnus-newsgroup-unreads
9689 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9691 (gnus-pull article gnus-newsgroup-reads)
9693 ;; See whether the article is to be put in the cache.
9695 (vectorp (gnus-summary-article-header article))
9697 (gnus-cache-possibly-enter-article
9698 gnus-newsgroup-name article
9699 (= mark gnus-ticked-mark)
9700 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9703 (gnus-summary-update-mark mark 'unread)
9706 (defun gnus-summary-mark-article (&optional article mark no-expire)
9707 "Mark ARTICLE with MARK. MARK can be any character.
9708 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9709 `??' (dormant) and `?E' (expirable).
9710 If MARK is nil, then the default character `?r' is used.
9711 If ARTICLE is nil, then the article on the current line will be
9713 If NO-EXPIRE, auto-expiry will be inhibited."
9714 ;; The mark might be a string.
9715 (when (stringp mark)
9716 (setq mark (aref mark 0)))
9717 ;; If no mark is given, then we check auto-expiring.
9719 (setq mark gnus-del-mark))
9720 (when (and (not no-expire)
9721 gnus-newsgroup-auto-expire
9722 (memq mark gnus-auto-expirable-marks))
9723 (setq mark gnus-expirable-mark))
9724 (let ((article (or article (gnus-summary-article-number)))
9725 (old-mark (gnus-summary-article-mark article)))
9726 ;; Allow the backend to change the mark.
9727 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9728 (if (eq mark old-mark)
9731 (error "No article on current line"))
9732 (if (not (if (or (= mark gnus-unread-mark)
9733 (= mark gnus-ticked-mark)
9734 (= mark gnus-spam-mark)
9735 (= mark gnus-dormant-mark))
9736 (gnus-mark-article-as-unread article mark)
9737 (gnus-mark-article-as-read article mark)))
9739 ;; See whether the article is to be put in the cache.
9741 (not (= mark gnus-canceled-mark))
9742 (vectorp (gnus-summary-article-header article))
9744 (gnus-cache-possibly-enter-article
9745 gnus-newsgroup-name article
9746 (= mark gnus-ticked-mark)
9747 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9749 (when (gnus-summary-goto-subject article nil t)
9750 (let ((buffer-read-only nil))
9751 (gnus-summary-show-thread)
9753 (gnus-summary-update-mark mark 'unread)
9756 (defun gnus-summary-update-secondary-mark (article)
9757 "Update the secondary (read, process, cache) mark."
9758 (gnus-summary-update-mark
9759 (cond ((memq article gnus-newsgroup-processable)
9761 ((memq article gnus-newsgroup-cached)
9763 ((memq article gnus-newsgroup-replied)
9765 ((memq article gnus-newsgroup-forwarded)
9766 gnus-forwarded-mark)
9767 ((memq article gnus-newsgroup-saved)
9769 ((memq article gnus-newsgroup-recent)
9771 ((memq article gnus-newsgroup-unseen)
9775 (when (gnus-visual-p 'summary-highlight 'highlight)
9776 (gnus-run-hooks 'gnus-summary-update-hook))
9779 (defun gnus-summary-update-download-mark (article)
9780 "Update the secondary (read, process, cache) mark."
9781 (gnus-summary-update-mark
9782 (cond ((memq article gnus-newsgroup-undownloaded)
9783 gnus-undownloaded-mark)
9784 (gnus-newsgroup-agentized
9785 gnus-downloaded-mark)
9789 (gnus-summary-update-line t)
9792 (defun gnus-summary-update-mark (mark type)
9793 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9794 (buffer-read-only nil))
9795 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9797 (when (looking-at "\r")
9799 (when (<= (+ forward (point)) (point-max))
9800 ;; Go to the right position on the line.
9801 (goto-char (+ forward (point)))
9802 ;; Replace the old mark with the new mark.
9803 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9804 ;; Optionally update the marks by some user rule.
9805 (when (eq type 'unread)
9807 (gnus-data-find (gnus-summary-article-number)) mark)
9808 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9810 (defun gnus-mark-article-as-read (article &optional mark)
9811 "Enter ARTICLE in the pertinent lists and remove it from others."
9812 ;; Make the article expirable.
9813 (let ((mark (or mark gnus-del-mark)))
9814 (setq gnus-newsgroup-expirable
9815 (if (= mark gnus-expirable-mark)
9816 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9817 (delq article gnus-newsgroup-expirable)))
9818 ;; Remove from unread and marked lists.
9819 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9820 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9821 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9822 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9823 (push (cons article mark) gnus-newsgroup-reads)
9824 ;; Possibly remove from cache, if that is used.
9825 (when gnus-use-cache
9826 (gnus-cache-enter-remove-article article))
9829 (defun gnus-mark-article-as-unread (article &optional mark)
9830 "Enter ARTICLE in the pertinent lists and remove it from others."
9831 (let ((mark (or mark gnus-ticked-mark)))
9834 (gnus-error 1 "Can't mark negative article numbers")
9836 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9837 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9838 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9839 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9840 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9842 ;; Unsuppress duplicates?
9843 (when gnus-suppress-duplicates
9844 (gnus-dup-unsuppress-article article))
9846 (cond ((= mark gnus-ticked-mark)
9847 (setq gnus-newsgroup-marked
9848 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9849 ((= mark gnus-spam-mark)
9850 (setq gnus-newsgroup-spam-marked
9851 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9853 ((= mark gnus-dormant-mark)
9854 (setq gnus-newsgroup-dormant
9855 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9857 (setq gnus-newsgroup-unreads
9858 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9859 (gnus-pull article gnus-newsgroup-reads)
9862 (defalias 'gnus-summary-mark-as-unread-forward
9863 'gnus-summary-tick-article-forward)
9864 (make-obsolete 'gnus-summary-mark-as-unread-forward
9865 'gnus-summary-tick-article-forward)
9866 (defun gnus-summary-tick-article-forward (n)
9867 "Tick N articles forwards.
9868 If N is negative, tick backwards instead.
9869 The difference between N and the number of articles ticked is returned."
9871 (gnus-summary-mark-forward n gnus-ticked-mark))
9873 (defalias 'gnus-summary-mark-as-unread-backward
9874 'gnus-summary-tick-article-backward)
9875 (make-obsolete 'gnus-summary-mark-as-unread-backward
9876 'gnus-summary-tick-article-backward)
9877 (defun gnus-summary-tick-article-backward (n)
9878 "Tick N articles backwards.
9879 The difference between N and the number of articles ticked is returned."
9881 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9883 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9884 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9885 (defun gnus-summary-tick-article (&optional article clear-mark)
9886 "Mark current article as unread.
9887 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9888 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9890 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9893 (defun gnus-summary-mark-as-read-forward (n)
9894 "Mark N articles as read forwards.
9895 If N is negative, mark backwards instead.
9896 The difference between N and the actual number of articles marked is
9899 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9901 (defun gnus-summary-mark-as-read-backward (n)
9902 "Mark the N articles as read backwards.
9903 The difference between N and the actual number of articles marked is
9906 (gnus-summary-mark-forward
9907 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9909 (defun gnus-summary-mark-as-read (&optional article mark)
9910 "Mark current article as read.
9911 ARTICLE specifies the article to be marked as read.
9912 MARK specifies a string to be inserted at the beginning of the line."
9913 (gnus-summary-mark-article article mark))
9915 (defun gnus-summary-clear-mark-forward (n)
9916 "Clear marks from N articles forward.
9917 If N is negative, clear backward instead.
9918 The difference between N and the number of marks cleared is returned."
9920 (gnus-summary-mark-forward n gnus-unread-mark))
9922 (defun gnus-summary-clear-mark-backward (n)
9923 "Clear marks from N articles backward.
9924 The difference between N and the number of marks cleared is returned."
9926 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9928 (defun gnus-summary-mark-unread-as-read ()
9929 "Intended to be used by `gnus-summary-mark-article-hook'."
9930 (when (memq gnus-current-article gnus-newsgroup-unreads)
9931 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9933 (defun gnus-summary-mark-read-and-unread-as-read ()
9934 "Intended to be used by `gnus-summary-mark-article-hook'."
9935 (let ((mark (gnus-summary-article-mark)))
9936 (when (or (gnus-unread-mark-p mark)
9937 (gnus-read-mark-p mark))
9938 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9940 (defun gnus-summary-mark-unread-as-ticked ()
9941 "Intended to be used by `gnus-summary-mark-article-hook'."
9942 (when (memq gnus-current-article gnus-newsgroup-unreads)
9943 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9945 (defun gnus-summary-mark-region-as-read (point mark all)
9946 "Mark all unread articles between point and mark as read.
9947 If given a prefix, mark all articles between point and mark as read,
9948 even ticked and dormant ones."
9949 (interactive "r\nP")
9958 (memq (setq article (gnus-summary-article-number))
9959 gnus-newsgroup-unreads))
9960 (gnus-summary-mark-article article gnus-del-mark))
9962 (gnus-summary-find-next))))))
9964 (defun gnus-summary-mark-below (score mark)
9965 "Mark articles with score less than SCORE with MARK."
9966 (interactive "P\ncMark: ")
9967 (setq score (if score
9968 (prefix-numeric-value score)
9969 (or gnus-summary-default-score 0)))
9971 (set-buffer gnus-summary-buffer)
9972 (goto-char (point-min))
9975 (and (< (gnus-summary-article-score) score)
9976 (gnus-summary-mark-article nil mark))
9977 (gnus-summary-find-next)))))
9979 (defun gnus-summary-kill-below (&optional score)
9980 "Mark articles with score below SCORE as read."
9982 (gnus-summary-mark-below score gnus-killed-mark))
9984 (defun gnus-summary-clear-above (&optional score)
9985 "Clear all marks from articles with score above SCORE."
9987 (gnus-summary-mark-above score gnus-unread-mark))
9989 (defun gnus-summary-tick-above (&optional score)
9990 "Tick all articles with score above SCORE."
9992 (gnus-summary-mark-above score gnus-ticked-mark))
9994 (defun gnus-summary-mark-above (score mark)
9995 "Mark articles with score over SCORE with MARK."
9996 (interactive "P\ncMark: ")
9997 (setq score (if score
9998 (prefix-numeric-value score)
9999 (or gnus-summary-default-score 0)))
10001 (set-buffer gnus-summary-buffer)
10002 (goto-char (point-min))
10004 (when (> (gnus-summary-article-score) score)
10005 (gnus-summary-mark-article nil mark))
10007 (gnus-summary-find-next)))))
10009 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10010 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10011 (defun gnus-summary-limit-include-expunged (&optional no-error)
10012 "Display all the hidden articles that were expunged for low scores."
10014 (let ((buffer-read-only nil))
10015 (let ((scored gnus-newsgroup-scored)
10018 (unless (gnus-summary-article-header (caar scored))
10019 (and (setq h (gnus-number-to-header (caar scored)))
10020 (< (cdar scored) gnus-summary-expunge-below)
10022 (setq scored (cdr scored)))
10024 (when (not no-error)
10025 (error "No expunged articles hidden"))
10026 (goto-char (point-min))
10027 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10028 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10029 (mapcar (lambda (x) (push (mail-header-number x)
10030 gnus-newsgroup-limit))
10032 (gnus-summary-prepare-unthreaded (nreverse headers))
10033 (goto-char (point-min))
10034 (gnus-summary-position-point)
10037 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10038 "Mark all unread articles in this newsgroup as read.
10039 If prefix argument ALL is non-nil, ticked and dormant articles will
10040 also be marked as read.
10041 If QUIETLY is non-nil, no questions will be asked.
10042 If TO-HERE is non-nil, it should be a point in the buffer. All
10043 articles before (after, if REVERSE is set) this point will be marked as read.
10044 Note that this function will only catch up the unread article
10045 in the current summary buffer limitation.
10046 The number of articles marked as read is returned."
10051 (not gnus-interactive-catchup) ;Without confirmation?
10055 "Mark absolutely all articles as read? "
10056 "Mark all unread articles as read? ")))
10058 (not gnus-newsgroup-adaptive)
10059 (not gnus-newsgroup-auto-expire)
10060 (not gnus-suppress-duplicates)
10061 (or (not gnus-use-cache)
10062 (eq gnus-use-cache 'passive)))
10065 (setq gnus-newsgroup-marked nil
10066 gnus-newsgroup-spam-marked nil
10067 gnus-newsgroup-dormant nil))
10068 (setq gnus-newsgroup-unreads
10069 (gnus-sorted-nunion
10070 (gnus-intersection gnus-newsgroup-unreads
10071 gnus-newsgroup-downloadable)
10072 gnus-newsgroup-unfetched)))
10073 ;; We actually mark all articles as canceled, which we
10074 ;; have to do when using auto-expiry or adaptive scoring.
10075 (gnus-summary-show-all-threads)
10076 (if (and to-here reverse)
10078 (goto-char to-here)
10080 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10081 (gnus-summary-find-next (not all)))))
10082 (when (gnus-summary-first-subject (not all))
10084 (if to-here (< (point) to-here) t)
10085 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10086 (gnus-summary-find-next (not all))))))
10087 (gnus-set-mode-line 'summary))
10089 (gnus-summary-position-point)))
10091 (defun gnus-summary-catchup-to-here (&optional all)
10092 "Mark all unticked articles before the current one as read.
10093 If ALL is non-nil, also mark ticked and dormant articles as read."
10096 (gnus-save-hidden-threads
10097 (let ((beg (point)))
10098 ;; We check that there are unread articles.
10099 (when (or all (gnus-summary-find-prev))
10100 (gnus-summary-catchup all t beg)))))
10101 (gnus-summary-position-point))
10103 (defun gnus-summary-catchup-from-here (&optional all)
10104 "Mark all unticked articles after the current one as read.
10105 If ALL is non-nil, also mark ticked and dormant articles as read."
10108 (gnus-save-hidden-threads
10109 (let ((beg (point)))
10110 ;; We check that there are unread articles.
10111 (when (or all (gnus-summary-find-next))
10112 (gnus-summary-catchup all t beg nil t)))))
10114 (gnus-summary-position-point))
10115 (defun gnus-summary-catchup-all (&optional quietly)
10116 "Mark all articles in this newsgroup as read.
10117 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10118 instead, which marks only unread articles as read."
10120 (gnus-summary-catchup t quietly))
10122 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10123 "Mark all unread articles in this group as read, then exit.
10124 If prefix argument ALL is non-nil, all articles are marked as read.
10125 If QUIETLY is non-nil, no questions will be asked."
10127 (when (gnus-summary-catchup all quietly nil 'fast)
10128 ;; Select next newsgroup or exit.
10129 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10130 (eq gnus-auto-select-next 'quietly))
10131 (gnus-summary-next-group nil)
10132 (gnus-summary-exit))))
10134 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10135 "Mark all articles in this newsgroup as read, and then exit.
10136 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10137 instead, which marks only unread articles as read."
10139 (gnus-summary-catchup-and-exit t quietly))
10141 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10142 "Mark all articles in this group as read and select the next group.
10143 If given a prefix, mark all articles, unread as well as ticked, as
10147 (gnus-summary-catchup all))
10148 (gnus-summary-next-group))
10154 (defmacro gnus-with-article (article &rest forms)
10155 "Select ARTICLE and perform FORMS in the original article buffer.
10156 Then replace the article with the result."
10158 ;; We don't want the article to be marked as read.
10159 (let (gnus-mark-article-hook)
10160 (gnus-summary-select-article t t nil ,article))
10161 (set-buffer gnus-original-article-buffer)
10163 (if (not (gnus-check-backend-function
10164 'request-replace-article (car gnus-article-current)))
10165 (gnus-message 5 "Read-only group; not replacing")
10166 (unless (gnus-request-replace-article
10167 ,article (car gnus-article-current)
10168 (current-buffer) t)
10169 (error "Couldn't replace article")))
10170 ;; The cache and backlog have to be flushed somewhat.
10171 (when gnus-keep-backlog
10172 (gnus-backlog-remove-article
10173 (car gnus-article-current) (cdr gnus-article-current)))
10174 (when gnus-use-cache
10175 (gnus-cache-update-article
10176 (car gnus-article-current) (cdr gnus-article-current)))))
10178 (put 'gnus-with-article 'lisp-indent-function 1)
10179 (put 'gnus-with-article 'edebug-form-spec '(form body))
10181 ;; Thread-based commands.
10183 (defun gnus-summary-articles-in-thread (&optional article)
10184 "Return a list of all articles in the current thread.
10185 If ARTICLE is non-nil, return all articles in the thread that starts
10186 with that article."
10187 (let* ((article (or article (gnus-summary-article-number)))
10188 (data (gnus-data-find-list article))
10189 (top-level (gnus-data-level (car data)))
10191 (cond ((null gnus-thread-operation-ignore-subject)
10192 (gnus-simplify-subject-re
10193 (mail-header-subject (gnus-data-header (car data)))))
10194 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10195 (gnus-simplify-subject-fuzzy
10196 (mail-header-subject (gnus-data-header (car data)))))
10198 (end-point (save-excursion
10199 (if (gnus-summary-go-to-next-thread)
10200 (point) (point-max))))
10203 (< (gnus-data-pos (car data)) end-point))
10204 (when (or (not top-subject)
10205 (string= top-subject
10206 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10207 (gnus-simplify-subject-fuzzy
10208 (mail-header-subject
10209 (gnus-data-header (car data))))
10210 (gnus-simplify-subject-re
10211 (mail-header-subject
10212 (gnus-data-header (car data)))))))
10213 (push (gnus-data-number (car data)) articles))
10214 (unless (and (setq data (cdr data))
10215 (> (gnus-data-level (car data)) top-level))
10217 ;; Return the list of articles.
10218 (nreverse articles)))
10220 (defun gnus-summary-rethread-current ()
10221 "Rethread the thread the current article is part of."
10223 (let* ((gnus-show-threads t)
10224 (article (gnus-summary-article-number))
10225 (id (mail-header-id (gnus-summary-article-header)))
10226 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10228 (error "No article on the current line"))
10229 (gnus-rebuild-thread id)
10230 (gnus-summary-goto-subject article)))
10232 (defun gnus-summary-reparent-thread ()
10233 "Make the current article child of the marked (or previous) article.
10235 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10236 is non-nil or the Subject: of both articles are the same."
10238 (unless (not (gnus-group-read-only-p))
10239 (error "The current newsgroup does not support article editing"))
10240 (unless (<= (length gnus-newsgroup-processable) 1)
10241 (error "No more than one article may be marked"))
10242 (save-window-excursion
10243 (let ((gnus-article-buffer " *reparent*")
10244 (current-article (gnus-summary-article-number))
10245 ;; First grab the marked article, otherwise one line up.
10246 (parent-article (if (not (null gnus-newsgroup-processable))
10247 (car gnus-newsgroup-processable)
10249 (if (eq (forward-line -1) 0)
10250 (gnus-summary-article-number)
10251 (error "Beginning of summary buffer"))))))
10252 (unless (not (eq current-article parent-article))
10253 (error "An article may not be self-referential"))
10254 (let ((message-id (mail-header-id
10255 (gnus-summary-article-header parent-article))))
10256 (unless (and message-id (not (equal message-id "")))
10257 (error "No message-id in desired parent"))
10258 (gnus-with-article current-article
10260 (goto-char (point-min))
10261 (message-narrow-to-head)
10262 (if (re-search-forward "^References: " nil t)
10264 (re-search-forward "^[^ \t]" nil t)
10267 (insert " " message-id))
10268 (insert "References: " message-id "\n"))))
10269 (set-buffer gnus-summary-buffer)
10270 (gnus-summary-unmark-all-processable)
10271 (gnus-summary-update-article current-article)
10272 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10273 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10274 (gnus-summary-rethread-current)
10275 (gnus-message 3 "Article %d is now the child of article %d"
10276 current-article parent-article)))))
10278 (defun gnus-summary-toggle-threads (&optional arg)
10279 "Toggle showing conversation threads.
10280 If ARG is positive number, turn showing conversation threads on."
10282 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10283 (setq gnus-show-threads
10284 (if (null arg) (not gnus-show-threads)
10285 (> (prefix-numeric-value arg) 0)))
10286 (gnus-summary-prepare)
10287 (gnus-summary-goto-subject current)
10288 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10289 (gnus-summary-position-point)))
10291 (defun gnus-summary-show-all-threads ()
10292 "Show all threads."
10295 (let ((buffer-read-only nil))
10296 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10297 (gnus-summary-position-point))
10299 (defun gnus-summary-show-thread ()
10300 "Show thread subtrees.
10301 Returns nil if no thread was there to be shown."
10303 (let ((buffer-read-only nil)
10305 ;; first goto end then to beg, to have point at beg after let
10306 (end (progn (end-of-line) (point)))
10307 (beg (progn (beginning-of-line) (point))))
10309 ;; Any hidden lines here?
10310 (search-forward "\r" end t)
10311 (subst-char-in-region beg end ?\^M ?\n t)
10313 (gnus-summary-position-point))))
10315 (defun gnus-summary-maybe-hide-threads ()
10316 "If requested, hide the threads that should be hidden."
10317 (when (and gnus-show-threads
10318 gnus-thread-hide-subtree)
10319 (gnus-summary-hide-all-threads
10320 (if (or (consp gnus-thread-hide-subtree)
10321 (gnus-functionp gnus-thread-hide-subtree))
10322 (gnus-make-predicate gnus-thread-hide-subtree)
10325 ;;; Hiding predicates.
10327 (defun gnus-article-unread-p (header)
10328 (memq (mail-header-number header) gnus-newsgroup-unreads))
10330 (defun gnus-article-unseen-p (header)
10331 (memq (mail-header-number header) gnus-newsgroup-unseen))
10333 (defun gnus-map-articles (predicate articles)
10334 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10335 (apply 'gnus-or (mapcar predicate
10336 (mapcar 'gnus-summary-article-header articles))))
10338 (defun gnus-summary-hide-all-threads (&optional predicate)
10339 "Hide all thread subtrees.
10340 If PREDICATE is supplied, threads that satisfy this predicate
10341 will not be hidden."
10344 (goto-char (point-min))
10347 (when (or (not predicate)
10349 predicate (gnus-summary-article-children)))
10350 (gnus-summary-hide-thread))
10351 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10352 (gnus-summary-position-point))
10354 (defun gnus-summary-hide-thread ()
10355 "Hide thread subtrees.
10356 If PREDICATE is supplied, threads that satisfy this predicate
10357 will not be hidden.
10358 Returns nil if no threads were there to be hidden."
10360 (let ((buffer-read-only nil)
10362 (article (gnus-summary-article-number)))
10364 ;; Go forward until either the buffer ends or the subthread
10366 (when (and (not (eobp))
10367 (or (zerop (gnus-summary-next-thread 1 t))
10368 (goto-char (point-max))))
10370 (if (and (> (point) start)
10371 (search-backward "\n" start t))
10373 (subst-char-in-region start (point) ?\n ?\^M)
10374 (gnus-summary-goto-subject article))
10378 (defun gnus-summary-go-to-next-thread (&optional previous)
10379 "Go to the same level (or less) next thread.
10380 If PREVIOUS is non-nil, go to previous thread instead.
10381 Return the article number moved to, or nil if moving was impossible."
10382 (let ((level (gnus-summary-thread-level))
10383 (way (if previous -1 1))
10386 (while (and (not (eobp))
10387 (< level (gnus-summary-thread-level)))
10388 (forward-line way))
10395 (gnus-summary-article-number)
10396 (goto-char beg)))))
10398 (defun gnus-summary-next-thread (n &optional silent)
10399 "Go to the same level next N'th thread.
10400 If N is negative, search backward instead.
10401 Returns the difference between N and the number of skips actually
10404 If SILENT, don't output messages."
10406 (let ((backward (< n 0))
10408 (while (and (> n 0)
10409 (gnus-summary-go-to-next-thread backward))
10412 (gnus-summary-position-point))
10413 (when (and (not silent) (/= 0 n))
10414 (gnus-message 7 "No more threads"))
10417 (defun gnus-summary-prev-thread (n)
10418 "Go to the same level previous N'th thread.
10419 Returns the difference between N and the number of skips actually
10422 (gnus-summary-next-thread (- n)))
10424 (defun gnus-summary-go-down-thread ()
10425 "Go down one level in the current thread."
10426 (let ((children (gnus-summary-article-children)))
10428 (gnus-summary-goto-subject (car children)))))
10430 (defun gnus-summary-go-up-thread ()
10431 "Go up one level in the current thread."
10432 (let ((parent (gnus-summary-article-parent)))
10434 (gnus-summary-goto-subject parent))))
10436 (defun gnus-summary-down-thread (n)
10437 "Go down thread N steps.
10438 If N is negative, go up instead.
10439 Returns the difference between N and how many steps down that were
10444 (while (and (> n 0)
10445 (if up (gnus-summary-go-up-thread)
10446 (gnus-summary-go-down-thread)))
10448 (gnus-summary-position-point)
10450 (gnus-message 7 "Can't go further"))
10453 (defun gnus-summary-up-thread (n)
10454 "Go up thread N steps.
10455 If N is negative, go down instead.
10456 Returns the difference between N and how many steps down that were
10459 (gnus-summary-down-thread (- n)))
10461 (defun gnus-summary-top-thread ()
10462 "Go to the top of the thread."
10464 (while (gnus-summary-go-up-thread))
10465 (gnus-summary-article-number))
10467 (defun gnus-summary-kill-thread (&optional unmark)
10468 "Mark articles under current thread as read.
10469 If the prefix argument is positive, remove any kinds of marks.
10470 If the prefix argument is negative, tick articles instead."
10473 (setq unmark (prefix-numeric-value unmark)))
10474 (let ((articles (gnus-summary-articles-in-thread)))
10476 ;; Expand the thread.
10477 (gnus-summary-show-thread)
10478 ;; Mark all the articles.
10480 (gnus-summary-goto-subject (car articles))
10481 (cond ((null unmark)
10482 (gnus-summary-mark-article-as-read gnus-killed-mark))
10484 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10486 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10487 (setq articles (cdr articles))))
10488 ;; Hide killed subtrees.
10490 gnus-thread-hide-killed
10491 (gnus-summary-hide-thread))
10492 ;; If marked as read, go to next unread subject.
10493 (when (null unmark)
10494 ;; Go to next unread subject.
10495 (gnus-summary-next-subject 1 t)))
10496 (gnus-set-mode-line 'summary))
10498 ;; Summary sorting commands
10500 (defun gnus-summary-sort-by-number (&optional reverse)
10501 "Sort the summary buffer by article number.
10502 Argument REVERSE means reverse order."
10504 (gnus-summary-sort 'number reverse))
10506 (defun gnus-summary-sort-by-random (&optional reverse)
10507 "Randomize the order in the summary buffer.
10508 Argument REVERSE means to randomize in reverse order."
10510 (gnus-summary-sort 'random reverse))
10512 (defun gnus-summary-sort-by-author (&optional reverse)
10513 "Sort the summary buffer by author name alphabetically.
10514 If `case-fold-search' is non-nil, case of letters is ignored.
10515 Argument REVERSE means reverse order."
10517 (gnus-summary-sort 'author reverse))
10519 (defun gnus-summary-sort-by-subject (&optional reverse)
10520 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10521 If `case-fold-search' is non-nil, case of letters is ignored.
10522 Argument REVERSE means reverse order."
10524 (gnus-summary-sort 'subject reverse))
10526 (defun gnus-summary-sort-by-date (&optional reverse)
10527 "Sort the summary buffer by date.
10528 Argument REVERSE means reverse order."
10530 (gnus-summary-sort 'date reverse))
10532 (defun gnus-summary-sort-by-score (&optional reverse)
10533 "Sort the summary buffer by score.
10534 Argument REVERSE means reverse order."
10536 (gnus-summary-sort 'score reverse))
10538 (defun gnus-summary-sort-by-lines (&optional reverse)
10539 "Sort the summary buffer by the number of lines.
10540 Argument REVERSE means reverse order."
10542 (gnus-summary-sort 'lines reverse))
10544 (defun gnus-summary-sort-by-chars (&optional reverse)
10545 "Sort the summary buffer by article length.
10546 Argument REVERSE means reverse order."
10548 (gnus-summary-sort 'chars reverse))
10550 (defun gnus-summary-sort-by-original (&optional reverse)
10551 "Sort the summary buffer using the default sorting method.
10552 Argument REVERSE means reverse order."
10554 (let* ((buffer-read-only)
10555 (gnus-summary-prepare-hook nil))
10556 ;; We do the sorting by regenerating the threads.
10557 (gnus-summary-prepare)
10558 ;; Hide subthreads if needed.
10559 (gnus-summary-maybe-hide-threads)))
10561 (defun gnus-summary-sort (predicate reverse)
10562 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10563 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10564 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10565 (gnus-thread-sort-functions
10570 (gnus-sort-gathered-threads-function
10571 gnus-thread-sort-functions)
10572 (gnus-article-sort-functions
10576 (,article t2 t1))))
10578 (gnus-summary-prepare-hook nil))
10579 ;; We do the sorting by regenerating the threads.
10580 (gnus-summary-prepare)
10581 ;; Hide subthreads if needed.
10582 (gnus-summary-maybe-hide-threads)))
10584 ;; Summary saving commands.
10586 (defun gnus-summary-save-article (&optional n not-saved)
10587 "Save the current article using the default saver function.
10588 If N is a positive number, save the N next articles.
10589 If N is a negative number, save the N previous articles.
10590 If N is nil and any articles have been marked with the process mark,
10591 save those articles instead.
10592 The variable `gnus-default-article-saver' specifies the saver function."
10594 (let* ((articles (gnus-summary-work-articles n))
10595 (save-buffer (save-excursion
10596 (nnheader-set-temp-buffer " *Gnus Save*")))
10597 (num (length articles))
10599 (dolist (article articles)
10600 (setq header (gnus-summary-article-header article))
10601 (if (not (vectorp header))
10602 ;; This is a pseudo-article.
10603 (if (assq 'name header)
10604 (gnus-copy-file (cdr (assq 'name header)))
10605 (gnus-message 1 "Article %d is unsaveable" article))
10606 ;; This is a real article.
10607 (save-window-excursion
10608 (let ((gnus-display-mime-function nil)
10609 (gnus-article-prepare-hook nil))
10610 (gnus-summary-select-article t nil nil article)))
10612 (set-buffer save-buffer)
10614 (insert-buffer-substring gnus-original-article-buffer))
10615 (setq file (gnus-article-save save-buffer file num))
10616 (gnus-summary-remove-process-mark article)
10618 (gnus-summary-set-saved-mark article))))
10619 (gnus-kill-buffer save-buffer)
10620 (gnus-summary-position-point)
10621 (gnus-set-mode-line 'summary)
10624 (defun gnus-summary-pipe-output (&optional arg headers)
10625 "Pipe the current article to a subprocess.
10626 If N is a positive number, pipe the N next articles.
10627 If N is a negative number, pipe the N previous articles.
10628 If N is nil and any articles have been marked with the process mark,
10629 pipe those articles instead.
10630 If HEADERS (the symbolic prefix), include the headers, too."
10631 (interactive (gnus-interactive "P\ny"))
10632 (require 'gnus-art)
10633 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10634 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10635 (gnus-summary-save-article arg t))
10636 (let ((buffer (get-buffer "*Shell Command Output*")))
10638 (not (zerop (buffer-size buffer))))
10639 (gnus-configure-windows 'pipe))))
10641 (defun gnus-summary-save-article-mail (&optional arg)
10642 "Append the current article to an mail file.
10643 If N is a positive number, save the N next articles.
10644 If N is a negative number, save the N previous articles.
10645 If N is nil and any articles have been marked with the process mark,
10646 save those articles instead."
10648 (require 'gnus-art)
10649 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10650 (gnus-summary-save-article arg)))
10652 (defun gnus-summary-save-article-rmail (&optional arg)
10653 "Append the current article to an rmail file.
10654 If N is a positive number, save the N next articles.
10655 If N is a negative number, save the N previous articles.
10656 If N is nil and any articles have been marked with the process mark,
10657 save those articles instead."
10659 (require 'gnus-art)
10660 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10661 (gnus-summary-save-article arg)))
10663 (defun gnus-summary-save-article-file (&optional arg)
10664 "Append the current article to a file.
10665 If N is a positive number, save the N next articles.
10666 If N is a negative number, save the N previous articles.
10667 If N is nil and any articles have been marked with the process mark,
10668 save those articles instead."
10670 (require 'gnus-art)
10671 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10672 (gnus-summary-save-article arg)))
10674 (defun gnus-summary-write-article-file (&optional arg)
10675 "Write the current article to a file, deleting the previous file.
10676 If N is a positive number, save the N next articles.
10677 If N is a negative number, save the N previous articles.
10678 If N is nil and any articles have been marked with the process mark,
10679 save those articles instead."
10681 (require 'gnus-art)
10682 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10683 (gnus-summary-save-article arg)))
10685 (defun gnus-summary-save-article-body-file (&optional arg)
10686 "Append the current article body to a file.
10687 If N is a positive number, save the N next articles.
10688 If N is a negative number, save the N previous articles.
10689 If N is nil and any articles have been marked with the process mark,
10690 save those articles instead."
10692 (require 'gnus-art)
10693 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10694 (gnus-summary-save-article arg)))
10696 (defun gnus-summary-muttprint (&optional arg)
10697 "Print the current article using Muttprint.
10698 If N is a positive number, save the N next articles.
10699 If N is a negative number, save the N previous articles.
10700 If N is nil and any articles have been marked with the process mark,
10701 save those articles instead."
10703 (require 'gnus-art)
10704 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10705 (gnus-summary-save-article arg t)))
10707 (defun gnus-summary-pipe-message (program)
10708 "Pipe the current article through PROGRAM."
10709 (interactive "sProgram: ")
10710 (gnus-summary-select-article)
10711 (let ((mail-header-separator ""))
10712 (gnus-eval-in-buffer-window gnus-article-buffer
10715 (let ((start (window-start))
10717 (message-pipe-buffer-body program)
10718 (set-window-start (get-buffer-window (current-buffer)) start))))))
10720 (defun gnus-get-split-value (methods)
10721 "Return a value based on the split METHODS."
10722 (let (split-name method result match)
10725 (set-buffer gnus-original-article-buffer)
10727 (nnheader-narrow-to-headers)
10728 (while (and methods (not split-name))
10729 (goto-char (point-min))
10730 (setq method (pop methods))
10731 (setq match (car method))
10734 ;; Regular expression.
10736 (re-search-forward match nil t)))
10737 ((gnus-functionp match)
10741 (setq result (funcall match gnus-newsgroup-name))))
10746 (setq result (eval match)))))
10747 (setq split-name (cdr method))
10748 (cond ((stringp result)
10749 (push (expand-file-name
10750 result gnus-article-save-directory)
10753 (setq split-name (append result split-name)))))))))
10754 (nreverse split-name)))
10756 (defun gnus-valid-move-group-p (group)
10757 (and (boundp group)
10758 (symbol-name group)
10759 (symbol-value group)
10760 (gnus-get-function (gnus-find-method-for-group
10761 (symbol-name group)) 'request-accept-article t)))
10763 (defun gnus-read-move-group-name (prompt default articles prefix)
10764 "Read a group name."
10765 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10766 (minibuffer-confirm-incomplete nil) ; XEmacs
10768 (format "%s %s to:"
10770 (if (> (length articles) 1)
10771 (format "these %d articles" (length articles))
10776 (gnus-completing-read-with-default
10779 'gnus-valid-move-group-p
10781 'gnus-group-history))
10782 ((= 1 (length split-name))
10783 (gnus-completing-read-with-default
10784 (car split-name) prom
10786 'gnus-valid-move-group-p
10788 'gnus-group-history))
10790 (gnus-completing-read-with-default
10792 (mapcar (lambda (el) (list el))
10793 (nreverse split-name))
10795 'gnus-group-history))))
10796 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10798 (if (or (string= to-newsgroup "")
10799 (string= to-newsgroup prefix))
10800 (setq to-newsgroup default))
10801 (unless to-newsgroup
10802 (error "No group name entered"))
10803 (or (gnus-active to-newsgroup)
10804 (gnus-activate-group to-newsgroup nil nil to-method)
10805 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10807 (or (and (gnus-request-create-group to-newsgroup to-method)
10808 (gnus-activate-group
10809 to-newsgroup nil nil to-method)
10810 (gnus-subscribe-group to-newsgroup))
10811 (error "Couldn't create group %s" to-newsgroup)))
10812 (error "No such group: %s" to-newsgroup)))
10815 (defun gnus-summary-save-parts (type dir n &optional reverse)
10816 "Save parts matching TYPE to DIR.
10817 If REVERSE, save parts that do not match TYPE."
10819 (list (read-string "Save parts of type: "
10820 (or (car gnus-summary-save-parts-type-history)
10821 gnus-summary-save-parts-default-mime)
10822 'gnus-summary-save-parts-type-history)
10823 (setq gnus-summary-save-parts-last-directory
10824 (read-file-name "Save to directory: "
10825 gnus-summary-save-parts-last-directory
10827 current-prefix-arg))
10828 (gnus-summary-iterate n
10829 (let ((gnus-display-mime-function nil)
10830 (gnus-inhibit-treatment t))
10831 (gnus-summary-select-article))
10833 (set-buffer gnus-article-buffer)
10834 (let ((handles (or gnus-article-mime-handles
10835 (mm-dissect-buffer nil gnus-article-loose-mime)
10836 (and gnus-article-emulate-mime
10837 (mm-uu-dissect)))))
10839 (gnus-summary-save-parts-1 type dir handles reverse)
10840 (unless gnus-article-mime-handles ;; Don't destroy this case.
10841 (mm-destroy-parts handles)))))))
10843 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10844 (if (stringp (car handle))
10845 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10848 (not (string-match type (mm-handle-media-type handle)))
10849 (string-match type (mm-handle-media-type handle)))
10850 (let ((file (expand-file-name
10851 (file-name-nondirectory
10853 (mail-content-type-get
10854 (mm-handle-disposition handle) 'filename)
10855 (concat gnus-newsgroup-name
10856 "." (number-to-string
10857 (cdr gnus-article-current)))))
10859 (unless (file-exists-p file)
10860 (mm-save-part-to-file handle file))))))
10862 ;; Summary extract commands
10864 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10865 (let ((buffer-read-only nil)
10866 (article (gnus-summary-article-number))
10868 (unless (gnus-summary-goto-subject article)
10869 (error "No such article: %d" article))
10870 (gnus-summary-position-point)
10871 ;; If all commands are to be bunched up on one line, we collect
10873 (unless gnus-view-pseudos-separately
10874 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10877 (setq action (cdr (assq 'action (car ps))))
10878 (setq files (list (cdr (assq 'name (car ps)))))
10879 (while (and ps (cdr ps)
10880 (string= (or action "1")
10881 (or (cdr (assq 'action (cadr ps))) "2")))
10882 (push (cdr (assq 'name (cadr ps))) files)
10883 (setcdr ps (cddr ps)))
10885 (when (not (string-match "%s" action))
10888 (when (assq 'execute (car ps))
10889 (setcdr (assq 'execute (car ps))
10890 (funcall (if (string-match "%s" action)
10899 (setq ps (cdr ps)))))
10900 (if (and gnus-view-pseudos (not not-view))
10902 (when (assq 'execute (car pslist))
10903 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10904 (eq gnus-view-pseudos 'not-confirm)))
10905 (setq pslist (cdr pslist)))
10908 (setq after-article (or (cdr (assq 'article (car pslist)))
10909 (gnus-summary-article-number)))
10910 (gnus-summary-goto-subject after-article)
10913 (insert " " (file-name-nondirectory
10914 (cdr (assq 'name (car pslist))))
10915 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10917 (forward-line -1) ; back to `b'
10918 (gnus-add-text-properties
10919 b (1- e) (list 'gnus-number gnus-reffed-article-number
10920 gnus-mouse-face-prop gnus-mouse-face))
10922 after-article gnus-reffed-article-number
10923 gnus-unread-mark b (car pslist) 0 (- e b))
10924 (setq gnus-newsgroup-unreads
10925 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10926 gnus-reffed-article-number))
10927 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10928 (setq pslist (cdr pslist)))))))
10930 (defun gnus-pseudos< (p1 p2)
10931 (let ((c1 (cdr (assq 'action p1)))
10932 (c2 (cdr (assq 'action p2))))
10933 (and c1 c2 (string< c1 c2))))
10935 (defun gnus-request-pseudo-article (props)
10936 (cond ((assq 'execute props)
10937 (gnus-execute-command (cdr (assq 'execute props)))))
10938 (let ((gnus-current-article (gnus-summary-article-number)))
10939 (gnus-run-hooks 'gnus-mark-article-hook)))
10941 (defun gnus-execute-command (command &optional automatic)
10943 (gnus-article-setup-buffer)
10944 (set-buffer gnus-article-buffer)
10945 (setq buffer-read-only nil)
10946 (let ((command (if automatic command
10947 (read-string "Command: " (cons command 0)))))
10949 (insert "$ " command "\n\n")
10950 (if gnus-view-pseudo-asynchronously
10951 (start-process "gnus-execute" (current-buffer) shell-file-name
10952 shell-command-switch command)
10953 (call-process shell-file-name nil t nil
10954 shell-command-switch command)))))
10956 ;; Summary kill commands.
10958 (defun gnus-summary-edit-global-kill (article)
10959 "Edit the \"global\" kill file."
10960 (interactive (list (gnus-summary-article-number)))
10961 (gnus-group-edit-global-kill article))
10963 (defun gnus-summary-edit-local-kill ()
10964 "Edit a local kill file applied to the current newsgroup."
10966 (setq gnus-current-headers (gnus-summary-article-header))
10967 (gnus-group-edit-local-kill
10968 (gnus-summary-article-number) gnus-newsgroup-name))
10970 ;;; Header reading.
10972 (defun gnus-read-header (id &optional header)
10973 "Read the headers of article ID and enter them into the Gnus system."
10974 (let ((group gnus-newsgroup-name)
10975 (gnus-override-method
10977 gnus-override-method
10978 (and (gnus-news-group-p gnus-newsgroup-name)
10979 (car (gnus-refer-article-methods)))))
10981 ;; First we check to see whether the header in question is already
10984 ;; This is a Message-ID.
10985 (setq header (or header (gnus-id-to-header id)))
10986 ;; This is an article number.
10987 (setq header (or header (gnus-summary-article-header id))))
10989 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10990 ;; We have found the header.
10992 ;; If this is a sparse article, we have to nix out its
10993 ;; previous entry in the thread hashtb.
10995 (gnus-summary-article-sparse-p (mail-header-number header)))
10996 (let* ((parent (gnus-parent-id (mail-header-references header)))
10997 (thread (and parent (gnus-id-to-thread parent))))
10999 (delq (assq header thread) thread))))
11000 ;; We have to really fetch the header to this article.
11002 (set-buffer nntp-server-buffer)
11003 (when (setq where (gnus-request-head id group))
11004 (nnheader-fold-continuation-lines)
11005 (goto-char (point-max))
11007 (goto-char (point-min))
11011 ((cdr where) (cdr where))
11012 (header (mail-header-number header))
11013 (t gnus-reffed-article-number))
11015 (insert " Article retrieved.\n"))
11016 (if (or (not where)
11017 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11018 () ; Malformed head.
11019 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11020 (when (and (stringp id)
11021 (not (string= (gnus-group-real-name group)
11023 ;; If we fetched by Message-ID and the article came
11024 ;; from a different group, we fudge some bogus article
11025 ;; numbers for this article.
11026 (mail-header-set-number header gnus-reffed-article-number))
11028 (set-buffer gnus-summary-buffer)
11029 (decf gnus-reffed-article-number)
11030 (gnus-remove-header (mail-header-number header))
11031 (push header gnus-newsgroup-headers)
11032 (setq gnus-current-headers header)
11033 (push (mail-header-number header) gnus-newsgroup-limit)))
11036 (defun gnus-remove-header (number)
11037 "Remove header NUMBER from `gnus-newsgroup-headers'."
11038 (if (and gnus-newsgroup-headers
11039 (= number (mail-header-number (car gnus-newsgroup-headers))))
11040 (pop gnus-newsgroup-headers)
11041 (let ((headers gnus-newsgroup-headers))
11042 (while (and (cdr headers)
11043 (not (= number (mail-header-number (cadr headers)))))
11045 (when (cdr headers)
11046 (setcdr headers (cddr headers))))))
11049 ;;; summary highlights
11052 (defun gnus-highlight-selected-summary ()
11053 "Highlight selected article in summary buffer."
11054 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11055 (when gnus-summary-selected-face
11057 (let* ((beg (progn (beginning-of-line) (point)))
11058 (end (progn (end-of-line) (point)))
11059 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11060 (from (if (get-text-property beg gnus-mouse-face-prop)
11062 (or (next-single-property-change
11063 beg gnus-mouse-face-prop nil end)
11068 (or (next-single-property-change
11069 from gnus-mouse-face-prop nil end)
11071 ;; If no mouse-face prop on line we will have to = from = end,
11072 ;; so we highlight the entire line instead.
11073 (when (= (+ to 2) from)
11076 (if gnus-newsgroup-selected-overlay
11077 ;; Move old overlay.
11079 gnus-newsgroup-selected-overlay from to (current-buffer))
11080 ;; Create new overlay.
11082 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11083 'face gnus-summary-selected-face))))))
11085 (defvar gnus-summary-highlight-line-cached nil)
11086 (defvar gnus-summary-highlight-line-trigger nil)
11088 (defun gnus-summary-highlight-line-0 ()
11089 (if (and (eq gnus-summary-highlight-line-trigger
11090 gnus-summary-highlight)
11091 gnus-summary-highlight-line-cached)
11092 gnus-summary-highlight-line-cached
11093 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11094 gnus-summary-highlight-line-cached
11095 (let* ((cond (list 'cond))
11097 (list gnus-summary-highlight))
11099 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11102 (gnus-byte-compile (list 'lambda nil cond))))))
11104 (defun gnus-summary-highlight-line ()
11105 "Highlight current line according to `gnus-summary-highlight'."
11106 (let* ((beg (gnus-point-at-bol))
11107 (article (or (gnus-summary-article-number) gnus-current-article))
11108 (score (or (cdr (assq article
11109 gnus-newsgroup-scored))
11110 gnus-summary-default-score 0))
11111 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11112 (inhibit-read-only t)
11113 (default gnus-summary-default-score)
11114 (default-high gnus-summary-default-high-score)
11115 (default-low gnus-summary-default-low-score)
11116 (uncached (memq article gnus-newsgroup-undownloaded))
11117 (downloaded (not uncached)))
11118 (let ((face (funcall (gnus-summary-highlight-line-0))))
11119 (unless (eq face (get-text-property beg 'face))
11120 (gnus-put-text-property-excluding-characters-with-faces
11121 beg (gnus-point-at-eol) 'face
11122 (setq face (if (boundp face) (symbol-value face) face)))
11123 (when gnus-summary-highlight-line-function
11124 (funcall gnus-summary-highlight-line-function article face))))))
11126 (defun gnus-update-read-articles (group unread &optional compute)
11127 "Update the list of read articles in GROUP.
11128 UNREAD is a sorted list."
11129 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11130 (entry (gnus-gethash group gnus-newsrc-hashtb))
11131 (info (nth 2 entry))
11134 (if (or (not info) (not active))
11135 ;; There is no info on this group if it was, in fact,
11136 ;; killed. Gnus stores no information on killed groups, so
11137 ;; there's nothing to be done.
11138 ;; One could store the information somewhere temporarily,
11139 ;; perhaps... Hmmm...
11141 ;; Remove any negative articles numbers.
11142 (while (and unread (< (car unread) 0))
11143 (setq unread (cdr unread)))
11144 ;; Remove any expired article numbers
11145 (while (and unread (< (car unread) (car active)))
11146 (setq unread (cdr unread)))
11147 ;; Compute the ranges of read articles by looking at the list of
11148 ;; unread articles.
11150 (when (/= (car unread) prev)
11151 (push (if (= prev (1- (car unread))) prev
11152 (cons prev (1- (car unread))))
11154 (setq prev (1+ (car unread)))
11155 (setq unread (cdr unread)))
11156 (when (<= prev (cdr active))
11157 (push (cons prev (cdr active)) read))
11158 (setq read (if (> (length read) 1) (nreverse read) read))
11163 ;; Propagate the read marks to the backend.
11164 (when (gnus-check-backend-function 'request-set-mark group)
11165 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11166 (add (gnus-remove-from-range read (gnus-info-read info))))
11168 (unless (gnus-check-group group)
11169 (error "Can't open server for %s" group))
11170 (gnus-request-set-mark
11171 group (delq nil (list (if add (list add 'add '(read)))
11172 (if del (list del 'del '(read))))))
11174 `(gnus-request-set-mark
11177 (if del (list del 'add '(read)))
11178 (if add (list add 'del '(read))))))))))
11179 (set-buffer gnus-group-buffer)
11180 (gnus-undo-register
11182 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11183 (gnus-info-set-read ',info ',(gnus-info-read info))
11184 (gnus-get-unread-articles-in-group ',info
11185 (gnus-active ,group))
11186 (gnus-group-update-group ,group t)
11188 ;; Enter this list into the group info.
11189 (gnus-info-set-read info read)
11190 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11191 (gnus-get-unread-articles-in-group info (gnus-active group))
11194 (defun gnus-offer-save-summaries ()
11195 "Offer to save all active summary buffers."
11197 ;; Go through all buffers and find all summaries.
11198 (dolist (buffer (buffer-list))
11199 (when (and (setq buffer (buffer-name buffer))
11200 (string-match "Summary" buffer)
11202 (set-buffer buffer)
11203 ;; We check that this is, indeed, a summary buffer.
11204 (and (eq major-mode 'gnus-summary-mode)
11205 ;; Also make sure this isn't bogus.
11206 gnus-newsgroup-prepared
11207 ;; Also make sure that this isn't a
11208 ;; dead summary buffer.
11209 (not gnus-dead-summary-mode))))
11210 (push buffer buffers)))
11211 ;; Go through all these summary buffers and offer to save them.
11215 "Update summary buffer %s? "
11217 (switch-to-buffer buf)
11218 (gnus-summary-exit))
11221 (defun gnus-summary-setup-default-charset ()
11222 "Setup newsgroup default charset."
11223 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11224 (setq gnus-newsgroup-charset nil)
11225 (let* ((ignored-charsets
11226 (or gnus-newsgroup-ephemeral-ignored-charsets
11228 (and gnus-newsgroup-name
11229 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11230 gnus-newsgroup-ignored-charsets))))
11231 (setq gnus-newsgroup-charset
11232 (or gnus-newsgroup-ephemeral-charset
11233 (and gnus-newsgroup-name
11234 (gnus-parameter-charset gnus-newsgroup-name))
11235 gnus-default-charset))
11236 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11237 ignored-charsets))))
11243 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11244 "Display the current article buffer fully MIME-buttonized.
11245 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11246 treated as multipart/mixed."
11248 (require 'gnus-art)
11249 (let ((gnus-unbuttonized-mime-types nil)
11250 (gnus-mime-display-multipart-as-mixed show-all-parts))
11251 (gnus-summary-show-article)))
11253 (defun gnus-summary-repair-multipart (article)
11254 "Add a Content-Type header to a multipart article without one."
11255 (interactive (list (gnus-summary-article-number)))
11256 (gnus-with-article article
11257 (message-narrow-to-head)
11258 (message-remove-header "Mime-Version")
11259 (goto-char (point-max))
11260 (insert "Mime-Version: 1.0\n")
11262 (when (search-forward "\n--" nil t)
11263 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11264 (message-narrow-to-head)
11265 (message-remove-header "Content-Type")
11266 (goto-char (point-max))
11267 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11270 (let (gnus-mark-article-hook)
11271 (gnus-summary-select-article t t nil article)))
11273 (defun gnus-summary-toggle-display-buttonized ()
11274 "Toggle the buttonizing of the article buffer."
11276 (require 'gnus-art)
11277 (if (setq gnus-inhibit-mime-unbuttonizing
11278 (not gnus-inhibit-mime-unbuttonizing))
11279 (let ((gnus-unbuttonized-mime-types nil))
11280 (gnus-summary-show-article))
11281 (gnus-summary-show-article)))
11284 ;;; Generic summary marking commands
11287 (defvar gnus-summary-marking-alist
11288 '((read gnus-del-mark "d")
11289 (unread gnus-unread-mark "u")
11290 (ticked gnus-ticked-mark "!")
11291 (dormant gnus-dormant-mark "?")
11292 (expirable gnus-expirable-mark "e"))
11293 "An alist of names/marks/keystrokes.")
11295 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11296 (defvar gnus-summary-mark-map)
11298 (defun gnus-summary-make-all-marking-commands ()
11299 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11300 (dolist (elem gnus-summary-marking-alist)
11301 (apply 'gnus-summary-make-marking-command elem)))
11303 (defun gnus-summary-make-marking-command (name mark keystroke)
11304 (let ((map (make-sparse-keymap)))
11305 (define-key gnus-summary-generic-mark-map keystroke map)
11306 (dolist (lway `((next "next" next nil "n")
11307 (next-unread "next unread" next t "N")
11308 (prev "previous" prev nil "p")
11309 (prev-unread "previous unread" prev t "P")
11310 (nomove "" nil nil ,keystroke)))
11311 (let ((func (gnus-summary-make-marking-command-1
11312 mark (car lway) lway name)))
11313 (setq func (eval func))
11314 (define-key map (nth 4 lway) func)))))
11316 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11318 (format "gnus-summary-put-mark-as-%s%s"
11319 name (if (eq way 'nomove)
11321 (concat "-" (symbol-name way)))))
11324 "Mark the current article as %s%s.
11325 If N, the prefix, then repeat N times.
11326 If N is negative, move in reverse order.
11327 The difference between N and the actual number of articles marked is
11331 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11333 (defun gnus-summary-generic-mark (n mark move unread)
11334 "Mark N articles with MARK."
11335 (unless (eq major-mode 'gnus-summary-mode)
11336 (error "This command can only be used in the summary buffer"))
11337 (gnus-summary-show-thread)
11340 ((eq move 'next) 1)
11341 ((eq move 'prev) -1)
11343 (if (zerop nummove)
11347 nummove (* -1 nummove))))
11348 (while (and (> n 0)
11349 (gnus-summary-mark-article nil mark)
11350 (zerop (gnus-summary-next-subject nummove unread t)))
11353 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11354 (gnus-summary-recenter)
11355 (gnus-summary-position-point)
11356 (gnus-set-mode-line 'summary)
11359 (defun gnus-summary-insert-articles (articles)
11360 (when (setq articles
11361 (gnus-sorted-difference articles
11362 (mapcar (lambda (h)
11363 (mail-header-number h))
11364 gnus-newsgroup-headers)))
11365 (setq gnus-newsgroup-headers
11367 gnus-newsgroup-headers
11368 (gnus-fetch-headers articles)
11369 'gnus-article-sort-by-number))
11370 ;; Suppress duplicates?
11371 (when gnus-suppress-duplicates
11372 (gnus-dup-suppress-articles))
11374 ;; We might want to build some more threads first.
11375 (when (and gnus-fetch-old-headers
11376 (eq gnus-headers-retrieved-by 'nov))
11377 (if (eq gnus-fetch-old-headers 'invisible)
11378 (gnus-build-all-threads)
11379 (gnus-build-old-threads)))
11380 ;; Let the Gnus agent mark articles as read.
11382 (gnus-agent-get-undownloaded-list))
11383 ;; Remove list identifiers from subject
11384 (when gnus-list-identifiers
11385 (gnus-summary-remove-list-identifiers))
11386 ;; First and last article in this newsgroup.
11387 (when gnus-newsgroup-headers
11388 (setq gnus-newsgroup-begin
11389 (mail-header-number (car gnus-newsgroup-headers))
11391 (mail-header-number
11392 (gnus-last-element gnus-newsgroup-headers))))
11393 (when gnus-use-scoring
11394 (gnus-possibly-score-headers))))
11396 (defun gnus-summary-insert-old-articles (&optional all)
11397 "Insert all old articles in this group.
11398 If ALL is non-nil, already read articles become readable.
11399 If ALL is a number, fetch this number of articles."
11402 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11405 ;; Some nntp servers lie about their active range. When
11406 ;; this happens, the active range can be in the millions.
11407 ;; Use a compressed range to avoid creating a huge list.
11408 (gnus-range-difference (list gnus-newsgroup-active) old))
11409 (setq len (gnus-range-length older))
11414 (let ((older-range (nreverse older)))
11418 (let* ((r (pop older-range))
11419 (min (if (numberp r) r (car r)))
11420 (max (if (numberp r) r (cdr r))))
11421 (while (and (<= min max)
11426 (setq older (gnus-uncompress-range older))))
11428 (setq older (gnus-uncompress-range older)))
11430 (when (and (numberp gnus-large-newsgroup)
11431 (> len gnus-large-newsgroup))
11432 (let* ((cursor-in-echo-area nil)
11433 (initial (gnus-parameter-large-newsgroup-initial
11434 gnus-newsgroup-name))
11438 "How many articles from %s (%s %d): "
11440 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11441 (if initial "max" "default")
11444 (cons (number-to-string initial)
11446 (unless (string-match "^[ \t]*$" input)
11447 (setq all (string-to-number input))
11449 (let ((older-range (nreverse older)))
11453 (let* ((r (pop older-range))
11454 (min (if (numberp r) r (car r)))
11455 (max (if (numberp r) r (cdr r))))
11456 (while (and (<= min max)
11460 max (1- max))))))))))
11461 (setq older (gnus-uncompress-range older))))
11463 (message "No old news.")
11464 (gnus-summary-insert-articles older)
11465 (gnus-summary-limit (gnus-sorted-nunion old older))))
11466 (gnus-summary-position-point)))
11468 (defun gnus-summary-insert-new-articles ()
11469 "Insert all new articles in this group."
11472 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11473 (old-active gnus-newsgroup-active)
11474 (nnmail-fetched-sources (list t))
11476 (setq gnus-newsgroup-active
11477 (gnus-activate-group gnus-newsgroup-name 'scan))
11478 (setq i (cdr gnus-newsgroup-active))
11479 (while (> i (cdr old-active))
11483 (message "No gnus is bad news.")
11484 (gnus-summary-insert-articles new)
11485 (setq gnus-newsgroup-unreads
11486 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11487 (gnus-summary-limit (gnus-sorted-nunion old new))))
11488 (gnus-summary-position-point)))
11490 (gnus-summary-make-all-marking-commands)
11492 (gnus-ems-redefine)
11494 (provide 'gnus-sum)
11496 (run-hooks 'gnus-sum-load-hook)
11498 ;;; gnus-sum.el ends here