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-setup-buffer (group)
3040 "Initialize summary buffer."
3041 (let ((buffer (gnus-summary-buffer-name group))
3042 (dead-name (concat "*Dead Summary "
3043 (gnus-group-decoded-name group) "*")))
3044 ;; If a dead summary buffer exists, we kill it.
3045 (when (gnus-buffer-live-p dead-name)
3046 (gnus-kill-buffer dead-name))
3047 (if (get-buffer buffer)
3050 (setq gnus-summary-buffer (current-buffer))
3051 (not gnus-newsgroup-prepared))
3052 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3053 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3054 (gnus-summary-mode group)
3056 (gnus-carpal-setup-buffer 'summary))
3057 (unless gnus-single-article-buffer
3058 (make-local-variable 'gnus-article-buffer)
3059 (make-local-variable 'gnus-article-current)
3060 (make-local-variable 'gnus-original-article-buffer))
3061 (setq gnus-newsgroup-name group)
3062 ;; Set any local variables in the group parameters.
3063 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3066 (defun gnus-set-global-variables ()
3067 "Set the global equivalents of the buffer-local variables.
3068 They are set to the latest values they had. These reflect the summary
3069 buffer that was in action when the last article was fetched."
3070 (when (eq major-mode 'gnus-summary-mode)
3071 (setq gnus-summary-buffer (current-buffer))
3072 (let ((name gnus-newsgroup-name)
3073 (marked gnus-newsgroup-marked)
3074 (spam gnus-newsgroup-spam-marked)
3075 (unread gnus-newsgroup-unreads)
3076 (headers gnus-current-headers)
3077 (data gnus-newsgroup-data)
3078 (summary gnus-summary-buffer)
3079 (article-buffer gnus-article-buffer)
3080 (original gnus-original-article-buffer)
3081 (gac gnus-article-current)
3082 (reffed gnus-reffed-article-number)
3083 (score-file gnus-current-score-file)
3084 (default-charset gnus-newsgroup-charset)
3086 (let ((locals gnus-newsgroup-variables))
3088 (if (consp (car locals))
3089 (push (eval (caar locals)) vlist)
3090 (push (eval (car locals)) vlist))
3091 (setq locals (cdr locals)))
3092 (setq vlist (nreverse vlist)))
3094 (set-buffer gnus-group-buffer)
3095 (setq gnus-newsgroup-name name
3096 gnus-newsgroup-marked marked
3097 gnus-newsgroup-spam-marked spam
3098 gnus-newsgroup-unreads unread
3099 gnus-current-headers headers
3100 gnus-newsgroup-data data
3101 gnus-article-current gac
3102 gnus-summary-buffer summary
3103 gnus-article-buffer article-buffer
3104 gnus-original-article-buffer original
3105 gnus-reffed-article-number reffed
3106 gnus-current-score-file score-file
3107 gnus-newsgroup-charset default-charset)
3108 (let ((locals gnus-newsgroup-variables))
3110 (if (consp (car locals))
3111 (set (caar locals) (pop vlist))
3112 (set (car locals) (pop vlist)))
3113 (setq locals (cdr locals))))
3114 ;; The article buffer also has local variables.
3115 (when (gnus-buffer-live-p gnus-article-buffer)
3116 (set-buffer gnus-article-buffer)
3117 (setq gnus-summary-buffer summary))))))
3119 (defun gnus-summary-article-unread-p (article)
3120 "Say whether ARTICLE is unread or not."
3121 (memq article gnus-newsgroup-unreads))
3123 (defun gnus-summary-first-article-p (&optional article)
3124 "Return whether ARTICLE is the first article in the buffer."
3125 (if (not (setq article (or article (gnus-summary-article-number))))
3127 (eq article (caar gnus-newsgroup-data))))
3129 (defun gnus-summary-last-article-p (&optional article)
3130 "Return whether ARTICLE is the last article in the buffer."
3131 (if (not (setq article (or article (gnus-summary-article-number))))
3132 ;; All non-existent numbers are the last article. :-)
3134 (not (cdr (gnus-data-find-list article)))))
3136 (defun gnus-make-thread-indent-array ()
3138 (unless (and gnus-thread-indent-array
3139 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3140 (setq gnus-thread-indent-array (make-vector 201 "")
3141 gnus-thread-indent-array-level gnus-thread-indent-level)
3143 (aset gnus-thread-indent-array n
3144 (make-string (* n gnus-thread-indent-level) ? ))
3147 (defun gnus-update-summary-mark-positions ()
3148 "Compute where the summary marks are to go."
3150 (when (gnus-buffer-exists-p gnus-summary-buffer)
3151 (set-buffer gnus-summary-buffer))
3152 (let ((gnus-replied-mark 129)
3153 (gnus-score-below-mark 130)
3154 (gnus-score-over-mark 130)
3155 (gnus-undownloaded-mark 131)
3156 (spec gnus-summary-line-format-spec)
3159 (gnus-set-work-buffer)
3160 (let ((gnus-summary-line-format-spec spec)
3161 (gnus-newsgroup-downloadable '(0)))
3162 (gnus-summary-insert-line
3163 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3164 0 nil t 128 t nil "" nil 1)
3165 (goto-char (point-min))
3166 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3167 (- (point) (point-min) 1)))))
3168 (goto-char (point-min))
3169 (push (cons 'replied (and (search-forward "\201" nil t)
3170 (- (point) (point-min) 1)))
3172 (goto-char (point-min))
3173 (push (cons 'score (and (search-forward "\202" nil t)
3174 (- (point) (point-min) 1)))
3176 (goto-char (point-min))
3177 (push (cons 'download
3178 (and (search-forward "\203" nil t)
3179 (- (point) (point-min) 1)))
3181 (setq gnus-summary-mark-positions pos))))
3183 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3184 "Insert a dummy root in the summary buffer."
3186 (gnus-add-text-properties
3187 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3188 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3190 (defun gnus-summary-extract-address-component (from)
3191 (or (car (funcall gnus-extract-address-components from))
3194 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3195 (let ((mail-parse-charset gnus-newsgroup-charset)
3196 ; Is it really necessary to do this next part for each summary line?
3197 ; Luckily, doesn't seem to slow things down much.
3198 (mail-parse-ignored-charsets
3199 (save-excursion (set-buffer gnus-summary-buffer)
3200 gnus-newsgroup-ignored-charsets)))
3202 (and gnus-ignored-from-addresses
3203 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3204 (let ((extra-headers (mail-header-extra header))
3208 ((setq to (cdr (assq 'To extra-headers)))
3211 (gnus-summary-extract-address-component
3212 (funcall gnus-decode-encoded-word-function to)))))
3213 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3214 (concat "=> " newsgroups)))))
3215 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3217 (defun gnus-summary-insert-line (gnus-tmp-header
3218 gnus-tmp-level gnus-tmp-current
3219 undownloaded gnus-tmp-unread gnus-tmp-replied
3220 gnus-tmp-expirable gnus-tmp-subject-or-nil
3221 &optional gnus-tmp-dummy gnus-tmp-score
3223 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3224 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3225 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3226 (gnus-tmp-score-char
3227 (if (or (null gnus-summary-default-score)
3228 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3229 gnus-summary-zcore-fuzz))
3231 (if (< gnus-tmp-score gnus-summary-default-score)
3232 gnus-score-below-mark gnus-score-over-mark)))
3233 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3235 (cond (gnus-tmp-process gnus-process-mark)
3236 ((memq gnus-tmp-current gnus-newsgroup-cached)
3238 (gnus-tmp-replied gnus-replied-mark)
3239 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3240 gnus-forwarded-mark)
3241 ((memq gnus-tmp-current gnus-newsgroup-saved)
3243 ((memq gnus-tmp-number gnus-newsgroup-recent)
3245 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3248 (gnus-tmp-downloaded
3250 gnus-undownloaded-mark)
3251 (gnus-newsgroup-agentized
3252 gnus-downloaded-mark)
3255 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3258 ((string-match "<[^>]+> *$" gnus-tmp-from)
3259 (let ((beg (match-beginning 0)))
3260 (or (and (string-match "^\".+\"" gnus-tmp-from)
3261 (substring gnus-tmp-from 1 (1- (match-end 0))))
3262 (substring gnus-tmp-from 0 beg))))
3263 ((string-match "(.+)" gnus-tmp-from)
3264 (substring gnus-tmp-from
3265 (1+ (match-beginning 0)) (1- (match-end 0))))
3267 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3268 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3269 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3270 (buffer-read-only nil))
3271 (when (string= gnus-tmp-name "")
3272 (setq gnus-tmp-name gnus-tmp-from))
3273 (unless (numberp gnus-tmp-lines)
3274 (setq gnus-tmp-lines -1))
3275 (if (= gnus-tmp-lines -1)
3276 (setq gnus-tmp-lines "?")
3277 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3278 (gnus-put-text-property
3280 (progn (eval gnus-summary-line-format-spec) (point))
3281 'gnus-number gnus-tmp-number)
3282 (when (gnus-visual-p 'summary-highlight 'highlight)
3284 (gnus-run-hooks 'gnus-summary-update-hook)
3287 (defun gnus-summary-update-line (&optional dont-update)
3288 "Update summary line after change."
3289 (when (and gnus-summary-default-score
3290 (not gnus-summary-inhibit-highlight))
3291 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3292 (article (gnus-summary-article-number))
3293 (score (gnus-summary-article-score article)))
3295 (if (and gnus-summary-mark-below
3296 (< (gnus-summary-article-score)
3297 gnus-summary-mark-below))
3298 ;; This article has a low score, so we mark it as read.
3299 (when (memq article gnus-newsgroup-unreads)
3300 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3301 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3302 ;; This article was previously marked as read on account
3303 ;; of a low score, but now it has risen, so we mark it as
3305 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3306 (gnus-summary-update-mark
3307 (if (or (null gnus-summary-default-score)
3308 (<= (abs (- score gnus-summary-default-score))
3309 gnus-summary-zcore-fuzz))
3311 (if (< score gnus-summary-default-score)
3312 gnus-score-below-mark gnus-score-over-mark))
3314 ;; Do visual highlighting.
3315 (when (gnus-visual-p 'summary-highlight 'highlight)
3316 (gnus-run-hooks 'gnus-summary-update-hook)))))
3318 (defvar gnus-tmp-new-adopts nil)
3320 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3321 "Return the number of articles in THREAD.
3322 This may be 0 in some cases -- if none of the articles in
3323 the thread are to be displayed."
3325 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3327 ((not (listp thread))
3329 ((and (consp thread) (cdr thread))
3332 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3335 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3338 (when (and level (zerop level) gnus-tmp-new-adopts)
3341 'gnus-summary-number-of-articles-in-thread
3342 gnus-tmp-new-adopts))))
3344 (if (> number 1) gnus-not-empty-thread-mark
3345 gnus-empty-thread-mark)
3348 (defsubst gnus-summary-line-message-size (head)
3349 "Return pretty-printed version of message size.
3350 This function is intended to be used in
3351 `gnus-summary-line-format-alist', which see."
3352 (let ((c (or (mail-header-chars head) -1)))
3353 (cond ((< c 0) "n/a") ; chars not available
3354 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3355 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3356 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3357 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3360 (defun gnus-summary-set-local-parameters (group)
3361 "Go through the local params of GROUP and set all variable specs in that list."
3362 (let ((params (gnus-group-find-parameter group))
3363 (vars '(quit-config)) ; Ignore quit-config.
3366 (setq elem (car params)
3367 params (cdr params))
3368 (and (consp elem) ; Has to be a cons.
3369 (consp (cdr elem)) ; The cdr has to be a list.
3370 (symbolp (car elem)) ; Has to be a symbol in there.
3371 (not (memq (car elem) vars))
3372 (ignore-errors ; So we set it.
3373 (push (car elem) vars)
3374 (make-local-variable (car elem))
3375 (set (car elem) (eval (nth 1 elem))))))))
3377 (defun gnus-summary-read-group (group &optional show-all no-article
3378 kill-buffer no-display backward
3380 "Start reading news in newsgroup GROUP.
3381 If SHOW-ALL is non-nil, already read articles are also listed.
3382 If NO-ARTICLE is non-nil, no article is selected initially.
3383 If NO-DISPLAY, don't generate a summary buffer."
3387 (let ((gnus-auto-select-next nil))
3388 (or (gnus-summary-read-group-1
3389 group show-all no-article
3390 kill-buffer no-display
3393 select-articles nil)))))
3394 (eq gnus-auto-select-next 'quietly))
3395 (set-buffer gnus-group-buffer)
3396 ;; The entry function called above goes to the next
3397 ;; group automatically, so we go two groups back
3398 ;; if we are searching for the previous group.
3400 (gnus-group-prev-unread-group 2))
3401 (if (not (equal group (gnus-group-group-name)))
3402 (setq group (gnus-group-group-name))
3406 (defun gnus-summary-read-group-1 (group show-all no-article
3407 kill-buffer no-display
3408 &optional select-articles)
3409 ;; Killed foreign groups can't be entered.
3410 ;; (when (and (not (gnus-group-native-p group))
3411 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3412 ;; (error "Dead non-native groups can't be entered"))
3413 (gnus-message 5 "Retrieving newsgroup: %s..."
3414 (gnus-group-decoded-name group))
3415 (let* ((new-group (gnus-summary-setup-buffer group))
3416 (quit-config (gnus-group-quit-config group))
3417 (did-select (and new-group (gnus-select-newsgroup
3418 group show-all select-articles))))
3420 ;; This summary buffer exists already, so we just select it.
3422 (gnus-set-global-variables)
3424 (gnus-kill-or-deaden-summary kill-buffer))
3425 (gnus-configure-windows 'summary 'force)
3426 (gnus-set-mode-line 'summary)
3427 (gnus-summary-position-point)
3430 ;; We couldn't select this group.
3432 (when (and (eq major-mode 'gnus-summary-mode)
3433 (not (equal (current-buffer) kill-buffer)))
3434 (kill-buffer (current-buffer))
3435 (if (not quit-config)
3437 ;; Update the info -- marks might need to be removed,
3439 (gnus-summary-update-info)
3440 (set-buffer gnus-group-buffer)
3441 (gnus-group-jump-to-group group)
3442 (gnus-group-next-unread-group 1))
3443 (gnus-handle-ephemeral-exit quit-config)))
3444 (let ((grpinfo (gnus-get-info group)))
3445 (if (null (gnus-info-read grpinfo))
3446 (gnus-message 3 "Group %s contains no messages"
3447 (gnus-group-decoded-name group))
3448 (gnus-message 3 "Can't select group")))
3450 ;; The user did a `C-g' while prompting for number of articles,
3451 ;; so we exit this group.
3452 ((eq did-select 'quit)
3453 (and (eq major-mode 'gnus-summary-mode)
3454 (not (equal (current-buffer) kill-buffer))
3455 (kill-buffer (current-buffer)))
3457 (gnus-kill-or-deaden-summary kill-buffer))
3458 (if (not quit-config)
3460 (set-buffer gnus-group-buffer)
3461 (gnus-group-jump-to-group group)
3462 (gnus-group-next-unread-group 1)
3463 (gnus-configure-windows 'group 'force))
3464 (gnus-handle-ephemeral-exit quit-config))
3465 ;; Finally signal the quit.
3467 ;; The group was successfully selected.
3469 (gnus-set-global-variables)
3470 ;; Save the active value in effect when the group was entered.
3471 (setq gnus-newsgroup-active
3473 (gnus-active gnus-newsgroup-name)))
3474 ;; You can change the summary buffer in some way with this hook.
3475 (gnus-run-hooks 'gnus-select-group-hook)
3476 (gnus-update-format-specifications
3477 nil 'summary 'summary-mode 'summary-dummy)
3478 (gnus-update-summary-mark-positions)
3479 ;; Do score processing.
3480 (when gnus-use-scoring
3481 (gnus-possibly-score-headers))
3482 ;; Check whether to fill in the gaps in the threads.
3483 (when gnus-build-sparse-threads
3484 (gnus-build-sparse-threads))
3485 ;; Find the initial limit.
3486 (if gnus-show-threads
3488 (let ((gnus-newsgroup-dormant nil))
3489 (gnus-summary-initial-limit show-all))
3490 (gnus-summary-initial-limit show-all))
3491 ;; When unthreaded, all articles are always shown.
3492 (setq gnus-newsgroup-limit
3494 (lambda (header) (mail-header-number header))
3495 gnus-newsgroup-headers)))
3496 ;; Generate the summary buffer.
3498 (gnus-summary-prepare))
3499 (when gnus-use-trees
3500 (gnus-tree-open group)
3501 (setq gnus-summary-highlight-line-function
3502 'gnus-tree-highlight-article))
3503 ;; If the summary buffer is empty, but there are some low-scored
3504 ;; articles or some excluded dormants, we include these in the
3506 (when (and (zerop (buffer-size))
3508 (cond (gnus-newsgroup-dormant
3509 (gnus-summary-limit-include-dormant))
3510 ((and gnus-newsgroup-scored show-all)
3511 (gnus-summary-limit-include-expunged t))))
3512 ;; Function `gnus-apply-kill-file' must be called in this hook.
3513 (gnus-run-hooks 'gnus-apply-kill-hook)
3514 (if (and (zerop (buffer-size))
3517 ;; This newsgroup is empty.
3518 (gnus-summary-catchup-and-exit nil t)
3519 (gnus-message 6 "No unread news")
3521 (gnus-kill-or-deaden-summary kill-buffer))
3522 ;; Return nil from this function.
3524 ;; Hide conversation thread subtrees. We cannot do this in
3525 ;; gnus-summary-prepare-hook since kill processing may not
3526 ;; work with hidden articles.
3527 (gnus-summary-maybe-hide-threads)
3529 (gnus-kill-or-deaden-summary kill-buffer))
3530 (gnus-summary-auto-select-subject)
3531 ;; Show first unread article if requested.
3532 (if (and (not no-article)
3534 gnus-newsgroup-unreads
3535 gnus-auto-select-first)
3537 (gnus-configure-windows 'summary)
3538 (let ((art (gnus-summary-article-number)))
3539 (unless (and (not gnus-plugged)
3540 (or (memq art gnus-newsgroup-undownloaded)
3541 (memq art gnus-newsgroup-downloadable)))
3542 (gnus-summary-goto-article art))))
3543 ;; Don't select any articles.
3544 (gnus-summary-position-point)
3545 (gnus-configure-windows 'summary 'force)
3546 (gnus-set-mode-line 'summary))
3547 (when (and gnus-auto-center-group
3548 (get-buffer-window gnus-group-buffer t))
3549 ;; Gotta use windows, because recenter does weird stuff if
3550 ;; the current buffer ain't the displayed window.
3551 (let ((owin (selected-window)))
3552 (select-window (get-buffer-window gnus-group-buffer t))
3553 (when (gnus-group-goto-group group)
3555 (select-window owin)))
3556 ;; Mark this buffer as "prepared".
3557 (setq gnus-newsgroup-prepared t)
3558 (gnus-run-hooks 'gnus-summary-prepared-hook)
3559 (unless (gnus-ephemeral-group-p group)
3560 (gnus-group-update-group group))
3563 (defun gnus-summary-auto-select-subject ()
3564 "Select the subject line on initial group entry."
3565 (goto-char (point-min))
3567 ((eq gnus-auto-select-subject 'best)
3568 (gnus-summary-best-unread-subject))
3569 ((eq gnus-auto-select-subject 'unread)
3570 (gnus-summary-first-unread-subject))
3571 ((eq gnus-auto-select-subject 'unseen)
3572 (gnus-summary-first-unseen-subject))
3573 ((eq gnus-auto-select-subject 'unseen-or-unread)
3574 (gnus-summary-first-unseen-or-unread-subject))
3575 ((eq gnus-auto-select-subject 'first)
3578 ((gnus-functionp gnus-auto-select-subject)
3579 (funcall gnus-auto-select-subject))))
3581 (defun gnus-summary-prepare ()
3582 "Generate the summary buffer."
3584 (let ((buffer-read-only nil))
3586 (setq gnus-newsgroup-data nil
3587 gnus-newsgroup-data-reverse nil)
3588 (gnus-run-hooks 'gnus-summary-generate-hook)
3589 ;; Generate the buffer, either with threads or without.
3590 (when gnus-newsgroup-headers
3591 (gnus-summary-prepare-threads
3592 (if gnus-show-threads
3593 (gnus-sort-gathered-threads
3594 (funcall gnus-summary-thread-gathering-function
3596 (gnus-cut-threads (gnus-make-threads)))))
3597 ;; Unthreaded display.
3598 (gnus-sort-articles gnus-newsgroup-headers))))
3599 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3600 ;; Call hooks for modifying summary buffer.
3601 (goto-char (point-min))
3602 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3604 (defsubst gnus-general-simplify-subject (subject)
3605 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3608 ;; Truncate the subject.
3609 (gnus-simplify-subject-functions
3610 (gnus-map-function gnus-simplify-subject-functions subject))
3611 ((numberp gnus-summary-gather-subject-limit)
3612 (setq subject (gnus-simplify-subject-re subject))
3613 (if (> (length subject) gnus-summary-gather-subject-limit)
3614 (substring subject 0 gnus-summary-gather-subject-limit)
3616 ;; Fuzzily simplify it.
3617 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3618 (gnus-simplify-subject-fuzzy subject))
3619 ;; Just remove the leading "Re:".
3621 (gnus-simplify-subject-re subject))))
3623 (if (and gnus-summary-gather-exclude-subject
3624 (string-match gnus-summary-gather-exclude-subject subject))
3625 nil ; This article shouldn't be gathered
3628 (defun gnus-summary-simplify-subject-query ()
3629 "Query where the respool algorithm would put this article."
3631 (gnus-summary-select-article)
3632 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3634 (defun gnus-gather-threads-by-subject (threads)
3635 "Gather threads by looking at Subject headers."
3636 (if (not gnus-summary-make-false-root)
3638 (let ((hashtb (gnus-make-hashtable 1024))
3641 subject hthread whole-subject)
3643 (setq subject (gnus-general-simplify-subject
3644 (setq whole-subject (mail-header-subject
3647 (if (setq hthread (gnus-gethash subject hashtb))
3649 ;; We enter a dummy root into the thread, if we
3650 ;; haven't done that already.
3651 (unless (stringp (caar hthread))
3652 (setcar hthread (list whole-subject (car hthread))))
3653 ;; We add this new gathered thread to this gathered
3655 (setcdr (car hthread)
3656 (nconc (cdar hthread) (list (car threads))))
3657 ;; Remove it from the list of threads.
3658 (setcdr prev (cdr threads))
3659 (setq threads prev))
3660 ;; Enter this thread into the hash table.
3661 (gnus-sethash subject
3662 (if gnus-summary-make-false-root-always
3664 ;; If you want a dummy root above all
3666 (setcar threads (list whole-subject
3672 (setq threads (cdr threads)))
3675 (defun gnus-gather-threads-by-references (threads)
3676 "Gather threads by looking at References headers."
3677 (let ((idhashtb (gnus-make-hashtable 1024))
3678 (thhashtb (gnus-make-hashtable 1024))
3681 ids references id gthread gid entered ref)
3683 (when (setq references (mail-header-references (caar threads)))
3684 (setq id (mail-header-id (caar threads))
3685 ids (inline (gnus-split-references references))
3687 (while (setq ref (pop ids))
3688 (setq ids (delete ref ids))
3689 (if (not (setq gid (gnus-gethash ref idhashtb)))
3691 (gnus-sethash ref id idhashtb)
3692 (gnus-sethash id threads thhashtb))
3693 (setq gthread (gnus-gethash gid thhashtb))
3695 ;; We enter a dummy root into the thread, if we
3696 ;; haven't done that already.
3697 (unless (stringp (caar gthread))
3698 (setcar gthread (list (mail-header-subject (caar gthread))
3700 ;; We add this new gathered thread to this gathered
3702 (setcdr (car gthread)
3703 (nconc (cdar gthread) (list (car threads)))))
3704 ;; Add it into the thread hash table.
3705 (gnus-sethash id gthread thhashtb)
3707 ;; Remove it from the list of threads.
3708 (setcdr prev (cdr threads))
3709 (setq threads prev))))
3711 (setq threads (cdr threads)))
3714 (defun gnus-sort-gathered-threads (threads)
3715 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3716 (let ((result threads))
3718 (when (stringp (caar threads))
3719 (setcdr (car threads)
3720 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3721 (setq threads (cdr threads)))
3724 (defun gnus-thread-loop-p (root thread)
3725 "Say whether ROOT is in THREAD."
3726 (let ((stack (list thread))
3729 (while (setq thread (pop stack))
3730 (setq th (cdr thread))
3732 (not (eq (caar th) root)))
3735 ;; We have found a loop.
3737 (setcdr thread (delq (car th) (cdr thread)))
3738 (if (boundp (setq ref-dep (intern "none"
3739 gnus-newsgroup-dependencies)))
3740 (setcdr (symbol-value ref-dep)
3741 (nconc (cdr (symbol-value ref-dep))
3743 (set ref-dep (list nil (car th))))
3746 ;; Push all the subthreads onto the stack.
3747 (push (cdr thread) stack)))
3750 (defun gnus-make-threads ()
3751 "Go through the dependency hashtb and find the roots. Return all threads."
3753 (while (catch 'infloop
3756 ;; Deal with self-referencing References loops.
3757 (when (and (car (symbol-value refs))
3764 (car (symbol-value refs)) thread))
3765 (cdr (symbol-value refs)))))))
3768 (unless (car (symbol-value refs))
3769 ;; These threads do not refer back to any other
3770 ;; articles, so they're roots.
3771 (setq threads (append (cdr (symbol-value refs)) threads))))
3772 gnus-newsgroup-dependencies)))
3775 ;; Build the thread tree.
3776 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3777 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3779 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3780 if it was already present.
3782 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3783 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3784 Message-IDs will be renamed to a unique Message-ID before being
3787 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3788 (let* ((id (mail-header-id header))
3789 (id-dep (and id (intern id dependencies)))
3790 parent-id ref ref-dep ref-header replaced)
3791 ;; Enter this `header' in the `dependencies' table.
3795 ;; The first two cases do the normal part: enter a new `header'
3796 ;; in the `dependencies' table.
3797 ((not (boundp id-dep))
3798 (set id-dep (list header)))
3799 ((null (car (symbol-value id-dep)))
3800 (setcar (symbol-value id-dep) header))
3802 ;; From here the `header' was already present in the
3803 ;; `dependencies' table.
3805 ;; Overrides an existing entry;
3806 ;; just set the header part of the entry.
3807 (setcar (symbol-value id-dep) header)
3810 ;; Renames the existing `header' to a unique Message-ID.
3811 ((not gnus-summary-ignore-duplicates)
3812 ;; An article with this Message-ID has already been seen.
3813 ;; We rename the Message-ID.
3814 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3816 (mail-header-set-id header id))
3818 ;; The last case ignores an existing entry, except it adds any
3819 ;; additional Xrefs (in case the two articles came from different
3821 ;; Also sets `header' to `nil' meaning that the `dependencies'
3822 ;; table was *not* modified.
3824 (mail-header-set-xref
3825 (car (symbol-value id-dep))
3826 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3828 (or (mail-header-xref header) "")))
3831 (when (and header (not replaced))
3832 ;; First check that we are not creating a References loop.
3833 (setq parent-id (gnus-parent-id (mail-header-references header)))
3834 (setq ref parent-id)
3836 (setq ref-dep (intern-soft ref dependencies))
3838 (setq ref-header (car (symbol-value ref-dep))))
3839 (if (string= id ref)
3840 ;; Yuk! This is a reference loop. Make the article be a
3843 (mail-header-set-references (car (symbol-value id-dep)) "none")
3845 (setq parent-id nil))
3846 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3847 (setq ref-dep (intern (or parent-id "none") dependencies))
3848 (if (boundp ref-dep)
3849 (setcdr (symbol-value ref-dep)
3850 (nconc (cdr (symbol-value ref-dep))
3851 (list (symbol-value id-dep))))
3852 (set ref-dep (list nil (symbol-value id-dep)))))
3855 (defun gnus-extract-message-id-from-in-reply-to (string)
3856 (if (string-match "<[^>]+>" string)
3857 (substring string (match-beginning 0) (match-end 0))
3860 (defun gnus-build-sparse-threads ()
3861 (let ((headers gnus-newsgroup-headers)
3862 (mail-parse-charset gnus-newsgroup-charset)
3863 (gnus-summary-ignore-duplicates t)
3864 header references generation relations
3865 subject child end new-child date)
3866 ;; First we create an alist of generations/relations, where
3867 ;; generations is how much we trust the relation, and the relation
3869 (gnus-message 7 "Making sparse threads...")
3871 (nnheader-set-temp-buffer " *gnus sparse threads*")
3872 (while (setq header (pop headers))
3873 (when (and (setq references (mail-header-references header))
3874 (not (string= references "")))
3876 (setq child (mail-header-id header)
3877 subject (mail-header-subject header)
3878 date (mail-header-date header)
3880 (while (search-backward ">" nil t)
3881 (setq end (1+ (point)))
3882 (when (search-backward "<" nil t)
3883 (setq new-child (buffer-substring (point) end))
3884 (push (list (incf generation)
3885 child (setq child new-child)
3889 (push (list (1+ generation) child nil subject) relations))
3891 (kill-buffer (current-buffer)))
3892 ;; Sort over trustworthiness.
3895 (when (gnus-dependencies-add-header
3896 (make-full-mail-header
3897 gnus-reffed-article-number
3898 (nth 3 relation) "" (or (nth 4 relation) "")
3900 (or (nth 2 relation) "") 0 0 "")
3901 gnus-newsgroup-dependencies nil)
3902 (push gnus-reffed-article-number gnus-newsgroup-limit)
3903 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3904 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3905 gnus-newsgroup-reads)
3906 (decf gnus-reffed-article-number)))
3907 (sort relations 'car-less-than-car))
3908 (gnus-message 7 "Making sparse threads...done")))
3910 (defun gnus-build-old-threads ()
3911 ;; Look at all the articles that refer back to old articles, and
3912 ;; fetch the headers for the articles that aren't there. This will
3913 ;; build complete threads - if the roots haven't been expired by the
3915 (let ((mail-parse-charset gnus-newsgroup-charset)
3919 (when (not (car (symbol-value refs)))
3920 (setq heads (cdr (symbol-value refs)))
3922 (if (memq (mail-header-number (caar heads))
3923 gnus-newsgroup-dormant)
3924 (setq heads (cdr heads))
3925 (setq id (symbol-name refs))
3926 (while (and (setq id (gnus-build-get-header id))
3927 (not (car (gnus-id-to-thread id)))))
3928 (setq heads nil)))))
3929 gnus-newsgroup-dependencies)))
3931 ;; This function has to be called with point after the article number
3932 ;; on the beginning of the line.
3933 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3934 (let ((eol (gnus-point-at-eol))
3935 (buffer (current-buffer))
3936 header references in-reply-to)
3938 ;; overview: [num subject from date id refs chars lines misc]
3941 (narrow-to-region (point) eol)
3946 (make-full-mail-header
3948 (condition-case () ; subject
3949 (funcall gnus-decode-encoded-word-function
3950 (setq x (nnheader-nov-field)))
3952 (condition-case () ; from
3953 (funcall gnus-decode-encoded-word-function
3954 (setq x (nnheader-nov-field)))
3956 (nnheader-nov-field) ; date
3957 (nnheader-nov-read-message-id) ; id
3958 (setq references (nnheader-nov-field)) ; refs
3959 (nnheader-nov-read-integer) ; chars
3960 (nnheader-nov-read-integer) ; lines
3962 (if (looking-at "Xref: ")
3963 (goto-char (match-end 0)))
3964 (nnheader-nov-field)) ; Xref
3965 (nnheader-nov-parse-extra)))) ; extra
3969 (when (and (string= references "")
3970 (setq in-reply-to (mail-header-extra header))
3971 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3972 (mail-header-set-references
3973 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3975 (when gnus-alter-header-function
3976 (funcall gnus-alter-header-function header))
3977 (gnus-dependencies-add-header header dependencies force-new)))
3979 (defun gnus-build-get-header (id)
3980 "Look through the buffer of NOV lines and find the header to ID.
3981 Enter this line into the dependencies hash table, and return
3982 the id of the parent article (if any)."
3983 (let ((deps gnus-newsgroup-dependencies)
3987 (set-buffer nntp-server-buffer)
3988 (let ((case-fold-search nil))
3989 (goto-char (point-min))
3990 (while (and (not found)
3991 (search-forward id nil t))
3993 (setq found (looking-at
3994 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3995 (regexp-quote id))))
3996 (or found (beginning-of-line 2)))
4000 (setq header (gnus-nov-parse-line
4001 (read (current-buffer)) deps))
4002 (gnus-parent-id (mail-header-references header))))))
4004 (let ((number (mail-header-number header)))
4005 (push number gnus-newsgroup-limit)
4006 (push header gnus-newsgroup-headers)
4007 (if (memq number gnus-newsgroup-unselected)
4009 (setq gnus-newsgroup-unreads
4010 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4012 (setq gnus-newsgroup-unselected
4013 (delq number gnus-newsgroup-unselected)))
4014 (push number gnus-newsgroup-ancient)))))))
4016 (defun gnus-build-all-threads ()
4017 "Read all the headers."
4018 (let ((gnus-summary-ignore-duplicates t)
4019 (mail-parse-charset gnus-newsgroup-charset)
4020 (dependencies gnus-newsgroup-dependencies)
4023 (set-buffer nntp-server-buffer)
4024 (let ((case-fold-search nil))
4025 (goto-char (point-min))
4028 (setq article (read (current-buffer))
4029 header (gnus-nov-parse-line article dependencies)))
4032 (set-buffer gnus-summary-buffer)
4033 (push header gnus-newsgroup-headers)
4034 (if (memq (setq article (mail-header-number header))
4035 gnus-newsgroup-unselected)
4037 (setq gnus-newsgroup-unreads
4038 (gnus-add-to-sorted-list
4039 gnus-newsgroup-unreads article))
4040 (setq gnus-newsgroup-unselected
4041 (delq article gnus-newsgroup-unselected)))
4042 (push article gnus-newsgroup-ancient)))
4043 (forward-line 1)))))))
4045 (defun gnus-summary-update-article-line (article header)
4046 "Update the line for ARTICLE using HEADERS."
4047 (let* ((id (mail-header-id header))
4048 (thread (gnus-id-to-thread id)))
4050 (error "Article in no thread"))
4051 ;; Update the thread.
4052 (setcar thread header)
4053 (gnus-summary-goto-subject article)
4054 (let* ((datal (gnus-data-find-list article))
4056 (buffer-read-only nil)
4057 (level (gnus-summary-thread-level)))
4059 (let ((inserted (- (point)
4061 (gnus-summary-insert-line
4063 (memq article gnus-newsgroup-undownloaded)
4064 (gnus-article-mark article)
4065 (memq article gnus-newsgroup-replied)
4066 (memq article gnus-newsgroup-expirable)
4067 ;; Only insert the Subject string when it's different
4068 ;; from the previous Subject string.
4073 (mail-header-subject
4076 (gnus-data-find-list
4078 (gnus-data-list t)))))
4079 ;; Error on the side of excessive subjects.
4081 (mail-header-subject header)))
4083 (mail-header-subject header))
4084 nil (cdr (assq article gnus-newsgroup-scored))
4085 (memq article gnus-newsgroup-processable))
4088 (gnus-data-update-list
4090 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4092 (defun gnus-summary-update-article (article &optional iheader)
4093 "Update ARTICLE in the summary buffer."
4094 (set-buffer gnus-summary-buffer)
4095 (let* ((header (gnus-summary-article-header article))
4096 (id (mail-header-id header))
4097 (data (gnus-data-find article))
4098 (thread (gnus-id-to-thread id))
4099 (references (mail-header-references header))
4103 (when (and references
4104 (not (equal "" references)))
4107 (buffer-read-only nil)
4113 (delq thread parent)))
4114 (if (gnus-summary-insert-subject id header)
4115 ;; Set the (possibly) new article number in the data structure.
4116 (gnus-data-set-number data (gnus-id-to-article id))
4120 (defun gnus-rebuild-thread (id &optional line)
4121 "Rebuild the thread containing ID.
4122 If LINE, insert the rebuilt thread starting on line LINE."
4123 (let ((buffer-read-only nil)
4124 old-pos current thread data)
4125 (if (not gnus-show-threads)
4126 (setq thread (list (car (gnus-id-to-thread id))))
4127 ;; Get the thread this article is part of.
4128 (setq thread (gnus-remove-thread id)))
4129 (setq old-pos (gnus-point-at-bol))
4130 (setq current (save-excursion
4131 (and (re-search-backward "[\r\n]" nil t)
4132 (gnus-summary-article-number))))
4133 ;; If this is a gathered thread, we have to go some re-gathering.
4134 (when (stringp (car thread))
4135 (let ((subject (car thread))
4137 (setq thread (cdr thread))
4139 (unless (memq (setq thr (gnus-id-to-thread
4141 (mail-header-id (caar thread)))))
4144 (setq thread (cdr thread)))
4145 ;; We now have all (unique) roots.
4146 (if (= (length roots) 1)
4147 ;; All the loose roots are now one solid root.
4148 (setq thread (car roots))
4149 (setq thread (cons subject (gnus-sort-threads roots))))))
4151 ;; We then insert this thread into the summary buffer.
4153 (goto-char (point-min))
4154 (forward-line (1- line)))
4155 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4156 (if gnus-show-threads
4157 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4158 (gnus-summary-prepare-unthreaded thread))
4159 (setq data (nreverse gnus-newsgroup-data))
4160 (setq threads gnus-newsgroup-threads))
4161 ;; We splice the new data into the data structure.
4162 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4163 ;;!!! then we want to insert at the beginning of the buffer.
4164 ;;!!! That happens to be true with Gnus now, but that may
4165 ;;!!! change in the future. Perhaps.
4166 (gnus-data-enter-list
4167 (if line nil current) data (- (point) old-pos))
4168 (setq gnus-newsgroup-threads
4169 (nconc threads gnus-newsgroup-threads))
4170 (gnus-data-compute-positions))))
4172 (defun gnus-number-to-header (number)
4173 "Return the header for article NUMBER."
4174 (let ((headers gnus-newsgroup-headers))
4176 (not (= number (mail-header-number (car headers)))))
4181 (defun gnus-parent-headers (in-headers &optional generation)
4182 "Return the headers of the GENERATIONeth parent of HEADERS."
4184 (setq generation 1))
4186 (headers in-headers)
4189 (not (zerop generation))
4190 (setq references (mail-header-references headers)))
4191 (setq headers (if (and references
4192 (setq parent (gnus-parent-id references)))
4193 (car (gnus-id-to-thread parent))
4196 (and (not (eq headers in-headers))
4199 (defun gnus-id-to-thread (id)
4200 "Return the (sub-)thread where ID appears."
4201 (gnus-gethash id gnus-newsgroup-dependencies))
4203 (defun gnus-id-to-article (id)
4204 "Return the article number of ID."
4205 (let ((thread (gnus-id-to-thread id)))
4208 (mail-header-number (car thread)))))
4210 (defun gnus-id-to-header (id)
4211 "Return the article headers of ID."
4212 (car (gnus-id-to-thread id)))
4214 (defun gnus-article-displayed-root-p (article)
4215 "Say whether ARTICLE is a root(ish) article."
4216 (let ((level (gnus-summary-thread-level article))
4217 (refs (mail-header-references (gnus-summary-article-header article)))
4223 ((null (gnus-parent-id refs)) t)
4225 (null (setq particle (gnus-id-to-article
4226 (gnus-parent-id refs))))
4227 (null (gnus-summary-thread-level particle)))))))
4229 (defun gnus-root-id (id)
4230 "Return the id of the root of the thread where ID appears."
4232 (while (and id (setq prev (car (gnus-id-to-thread id))))
4234 id (gnus-parent-id (mail-header-references prev))))
4237 (defun gnus-articles-in-thread (thread)
4238 "Return the list of articles in THREAD."
4239 (cons (mail-header-number (car thread))
4240 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4242 (defun gnus-remove-thread (id &optional dont-remove)
4243 "Remove the thread that has ID in it."
4244 (let (headers thread last-id)
4245 ;; First go up in this thread until we find the root.
4246 (setq last-id (gnus-root-id id)
4247 headers (message-flatten-list (gnus-id-to-thread last-id)))
4248 ;; We have now found the real root of this thread. It might have
4249 ;; been gathered into some loose thread, so we have to search
4250 ;; through the threads to find the thread we wanted.
4251 (let ((threads gnus-newsgroup-threads)
4254 (setq sub (car threads))
4255 (if (stringp (car sub))
4256 ;; This is a gathered thread, so we look at the roots
4257 ;; below it to find whether this article is in this
4260 (setq sub (cdr sub))
4262 (when (member (caar sub) headers)
4263 (setq thread (car threads)
4266 (setq sub (cdr sub))))
4267 ;; It's an ordinary thread, so we check it.
4268 (when (eq (car sub) (car headers))
4271 (setq threads (cdr threads)))
4272 ;; If this article is in no thread, then it's a root.
4275 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4276 (setq thread (gnus-id-to-thread last-id)))
4279 thread ; We return this thread.
4281 (if (stringp (car thread))
4283 ;; If we use dummy roots, then we have to remove the
4284 ;; dummy root as well.
4285 (when (eq gnus-summary-make-false-root 'dummy)
4286 ;; We go to the dummy root by going to
4287 ;; the first sub-"thread", and then one line up.
4288 (gnus-summary-goto-article
4289 (mail-header-number (caadr thread)))
4292 (gnus-data-compute-positions))
4293 (setq thread (cdr thread))
4295 (gnus-remove-thread-1 (car thread))
4296 (setq thread (cdr thread))))
4297 (gnus-remove-thread-1 thread))))))))
4299 (defun gnus-remove-thread-1 (thread)
4300 "Remove the thread THREAD recursively."
4301 (let ((number (mail-header-number (pop thread)))
4303 (setq thread (reverse thread))
4305 (gnus-remove-thread-1 (pop thread)))
4306 (when (setq d (gnus-data-find number))
4307 (goto-char (gnus-data-pos d))
4308 (gnus-summary-show-thread)
4311 (- (gnus-point-at-bol)
4313 (1+ (gnus-point-at-eol))
4314 (gnus-delete-line)))))))
4316 (defun gnus-sort-threads-1 (threads func)
4317 (sort (mapcar (lambda (thread)
4320 (gnus-sort-threads-1 (cdr thread) func))))
4323 (defun gnus-sort-threads (threads)
4325 (if (not gnus-thread-sort-functions)
4327 (gnus-message 8 "Sorting threads...")
4328 (let ((max-lisp-eval-depth 5000))
4329 (prog1 (gnus-sort-threads-1
4331 (gnus-make-sort-function gnus-thread-sort-functions))
4332 (gnus-message 8 "Sorting threads...done")))))
4334 (defun gnus-sort-articles (articles)
4336 (when gnus-article-sort-functions
4337 (gnus-message 7 "Sorting articles...")
4339 (setq gnus-newsgroup-headers
4340 (sort articles (gnus-make-sort-function
4341 gnus-article-sort-functions)))
4342 (gnus-message 7 "Sorting articles...done"))))
4344 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4345 (defmacro gnus-thread-header (thread)
4346 "Return header of first article in THREAD.
4347 Note that THREAD must never, ever be anything else than a variable -
4348 using some other form will lead to serious barfage."
4349 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4350 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4351 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4354 (defsubst gnus-article-sort-by-number (h1 h2)
4355 "Sort articles by article number."
4356 (< (mail-header-number h1)
4357 (mail-header-number h2)))
4359 (defun gnus-thread-sort-by-number (h1 h2)
4360 "Sort threads by root article number."
4361 (gnus-article-sort-by-number
4362 (gnus-thread-header h1) (gnus-thread-header h2)))
4364 (defsubst gnus-article-sort-by-random (h1 h2)
4365 "Sort articles by article number."
4368 (defun gnus-thread-sort-by-random (h1 h2)
4369 "Sort threads by root article number."
4370 (gnus-article-sort-by-random
4371 (gnus-thread-header h1) (gnus-thread-header h2)))
4373 (defsubst gnus-article-sort-by-lines (h1 h2)
4374 "Sort articles by article Lines header."
4375 (< (mail-header-lines h1)
4376 (mail-header-lines h2)))
4378 (defun gnus-thread-sort-by-lines (h1 h2)
4379 "Sort threads by root article Lines header."
4380 (gnus-article-sort-by-lines
4381 (gnus-thread-header h1) (gnus-thread-header h2)))
4383 (defsubst gnus-article-sort-by-chars (h1 h2)
4384 "Sort articles by octet length."
4385 (< (mail-header-chars h1)
4386 (mail-header-chars h2)))
4388 (defun gnus-thread-sort-by-chars (h1 h2)
4389 "Sort threads by root article octet length."
4390 (gnus-article-sort-by-chars
4391 (gnus-thread-header h1) (gnus-thread-header h2)))
4393 (defsubst gnus-article-sort-by-author (h1 h2)
4394 "Sort articles by root author."
4396 (let ((extract (funcall
4397 gnus-extract-address-components
4398 (mail-header-from h1))))
4399 (or (car extract) (cadr extract) ""))
4400 (let ((extract (funcall
4401 gnus-extract-address-components
4402 (mail-header-from h2))))
4403 (or (car extract) (cadr extract) ""))))
4405 (defun gnus-thread-sort-by-author (h1 h2)
4406 "Sort threads by root author."
4407 (gnus-article-sort-by-author
4408 (gnus-thread-header h1) (gnus-thread-header h2)))
4410 (defsubst gnus-article-sort-by-subject (h1 h2)
4411 "Sort articles by root subject."
4413 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4414 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4416 (defun gnus-thread-sort-by-subject (h1 h2)
4417 "Sort threads by root subject."
4418 (gnus-article-sort-by-subject
4419 (gnus-thread-header h1) (gnus-thread-header h2)))
4421 (defsubst gnus-article-sort-by-date (h1 h2)
4422 "Sort articles by root article date."
4424 (gnus-date-get-time (mail-header-date h1))
4425 (gnus-date-get-time (mail-header-date h2))))
4427 (defun gnus-thread-sort-by-date (h1 h2)
4428 "Sort threads by root article date."
4429 (gnus-article-sort-by-date
4430 (gnus-thread-header h1) (gnus-thread-header h2)))
4432 (defsubst gnus-article-sort-by-score (h1 h2)
4433 "Sort articles by root article score.
4434 Unscored articles will be counted as having a score of zero."
4435 (> (or (cdr (assq (mail-header-number h1)
4436 gnus-newsgroup-scored))
4437 gnus-summary-default-score 0)
4438 (or (cdr (assq (mail-header-number h2)
4439 gnus-newsgroup-scored))
4440 gnus-summary-default-score 0)))
4442 (defun gnus-thread-sort-by-score (h1 h2)
4443 "Sort threads by root article score."
4444 (gnus-article-sort-by-score
4445 (gnus-thread-header h1) (gnus-thread-header h2)))
4447 (defun gnus-thread-sort-by-total-score (h1 h2)
4448 "Sort threads by the sum of all scores in the thread.
4449 Unscored articles will be counted as having a score of zero."
4450 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4452 (defun gnus-thread-total-score (thread)
4453 ;; This function find the total score of THREAD.
4458 (if (stringp (car thread))
4459 (apply gnus-thread-score-function 0
4460 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4461 (gnus-thread-total-score-1 thread)))
4463 (gnus-thread-total-score-1 (list thread)))))
4465 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4466 "Sort threads such that the thread with the most recently arrived article comes first."
4467 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4469 (defun gnus-thread-highest-number (thread)
4470 "Return the highest article number in THREAD."
4471 (apply 'max (mapcar (lambda (header)
4472 (mail-header-number header))
4473 (message-flatten-list thread))))
4475 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4476 "Sort threads such that the thread with the most recently dated article comes first."
4477 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4479 (defun gnus-thread-latest-date (thread)
4480 "Return the highest article date in THREAD."
4481 (let ((previous-time 0))
4488 (mail-header-parse-date (mail-header-date header))
4489 (error previous-time)))))
4491 (message-flatten-list thread)
4493 (< (mail-header-number h1)
4494 (mail-header-number h2))))))))
4496 (defun gnus-thread-total-score-1 (root)
4497 ;; This function find the total score of the thread below ROOT.
4498 (setq root (car root))
4499 (apply gnus-thread-score-function
4501 (mapcar 'gnus-thread-total-score
4502 (cdr (gnus-id-to-thread (mail-header-id root))))
4503 (when (> (mail-header-number root) 0)
4504 (list (or (cdr (assq (mail-header-number root)
4505 gnus-newsgroup-scored))
4506 gnus-summary-default-score 0))))
4507 (list gnus-summary-default-score)
4510 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4511 (defvar gnus-tmp-prev-subject nil)
4512 (defvar gnus-tmp-false-parent nil)
4513 (defvar gnus-tmp-root-expunged nil)
4514 (defvar gnus-tmp-dummy-line nil)
4516 (eval-when-compile (defvar gnus-tmp-header))
4517 (defun gnus-extra-header (type &optional header)
4518 "Return the extra header of TYPE."
4519 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4522 (defvar gnus-tmp-thread-tree-header-string "")
4524 (defcustom gnus-sum-thread-tree-root "> "
4525 "With %B spec, used for the root of a thread.
4526 If nil, use subject instead."
4528 :group 'gnus-thread)
4529 (defcustom gnus-sum-thread-tree-single-indent ""
4530 "With %B spec, used for a thread with just one message.
4531 If nil, use subject instead."
4533 :group 'gnus-thread)
4534 (defcustom gnus-sum-thread-tree-vertical "| "
4535 "With %B spec, used for drawing a vertical line."
4537 :group 'gnus-thread)
4538 (defcustom gnus-sum-thread-tree-indent " "
4539 "With %B spec, used for indenting."
4541 :group 'gnus-thread)
4542 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4543 "With %B spec, used for a leaf with brothers."
4545 :group 'gnus-thread)
4546 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4547 "With %B spec, used for a leaf without brothers."
4549 :group 'gnus-thread)
4551 (defun gnus-summary-prepare-threads (threads)
4552 "Prepare summary buffer from THREADS and indentation LEVEL.
4553 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4554 or a straight list of headers."
4555 (gnus-message 7 "Generating summary...")
4557 (setq gnus-newsgroup-threads threads)
4560 (let ((gnus-tmp-level 0)
4561 (default-score (or gnus-summary-default-score 0))
4562 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4563 (building-line-count gnus-summary-display-while-building)
4564 (building-count (integerp gnus-summary-display-while-building))
4565 thread number subject stack state gnus-tmp-gathered beg-match
4566 new-roots gnus-tmp-new-adopts thread-end simp-subject
4567 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4568 gnus-tmp-replied gnus-tmp-subject-or-nil
4569 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4570 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4571 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4574 (setq gnus-tmp-prev-subject nil
4575 gnus-tmp-thread-tree-header-string "")
4577 (if (vectorp (car threads))
4578 ;; If this is a straight (sic) list of headers, then a
4579 ;; threaded summary display isn't required, so we just create
4580 ;; an unthreaded one.
4581 (gnus-summary-prepare-unthreaded threads)
4583 ;; Do the threaded display.
4585 (if gnus-summary-display-while-building
4586 (switch-to-buffer (buffer-name)))
4587 (while (or threads stack gnus-tmp-new-adopts new-roots)
4589 (if (and (= gnus-tmp-level 0)
4592 (not gnus-tmp-false-parent)
4593 (or gnus-tmp-new-adopts new-roots))
4594 (if gnus-tmp-new-adopts
4595 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4596 thread (list (car gnus-tmp-new-adopts))
4597 gnus-tmp-header (caar thread)
4598 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4600 (setq thread (list (car new-roots))
4601 gnus-tmp-header (caar thread)
4602 new-roots (cdr new-roots))))
4605 ;; If there are some threads, we do them before the
4606 ;; threads on the stack.
4607 (setq thread threads
4608 gnus-tmp-header (caar thread))
4609 ;; There were no current threads, so we pop something off
4611 (setq state (car stack)
4612 gnus-tmp-level (car state)
4613 tree-stack (cadr state)
4614 thread (caddr state)
4616 gnus-tmp-header (caar thread))))
4618 (setq gnus-tmp-false-parent nil)
4619 (setq gnus-tmp-root-expunged nil)
4620 (setq thread-end nil)
4622 (if (stringp gnus-tmp-header)
4623 ;; The header is a dummy root.
4625 ((eq gnus-summary-make-false-root 'adopt)
4626 ;; We let the first article adopt the rest.
4627 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4629 (setq gnus-tmp-gathered
4631 (lambda (h) (mail-header-number (car h)))
4634 (setq thread (cons (list (caar thread)
4637 (setq gnus-tmp-level -1
4638 gnus-tmp-false-parent t))
4639 ((eq gnus-summary-make-false-root 'empty)
4640 ;; We print adopted articles with empty subject fields.
4641 (setq gnus-tmp-gathered
4643 (lambda (h) (mail-header-number (car h)))
4646 (setq gnus-tmp-level -1))
4647 ((eq gnus-summary-make-false-root 'dummy)
4648 ;; We remember that we probably want to output a dummy
4650 (setq gnus-tmp-dummy-line gnus-tmp-header)
4651 (setq gnus-tmp-prev-subject gnus-tmp-header))
4653 ;; We do not make a root for the gathered
4654 ;; sub-threads at all.
4655 (setq gnus-tmp-level -1)))
4657 (setq number (mail-header-number gnus-tmp-header)
4658 subject (mail-header-subject gnus-tmp-header)
4659 simp-subject (gnus-simplify-subject-fully subject))
4662 ;; If the thread has changed subject, we might want to make
4663 ;; this subthread into a root.
4664 ((and (null gnus-thread-ignore-subject)
4665 (not (zerop gnus-tmp-level))
4666 gnus-tmp-prev-subject
4667 (not (string= gnus-tmp-prev-subject simp-subject)))
4668 (setq new-roots (nconc new-roots (list (car thread)))
4670 gnus-tmp-header nil))
4671 ;; If the article lies outside the current limit,
4672 ;; then we do not display it.
4673 ((not (memq number gnus-newsgroup-limit))
4674 (setq gnus-tmp-gathered
4676 (lambda (h) (mail-header-number (car h)))
4679 (setq gnus-tmp-new-adopts (if (cdar thread)
4680 (append gnus-tmp-new-adopts
4682 gnus-tmp-new-adopts)
4684 gnus-tmp-header nil)
4685 (when (zerop gnus-tmp-level)
4686 (setq gnus-tmp-root-expunged t)))
4687 ;; Perhaps this article is to be marked as read?
4688 ((and gnus-summary-mark-below
4689 (< (or (cdr (assq number gnus-newsgroup-scored))
4691 gnus-summary-mark-below)
4692 ;; Don't touch sparse articles.
4693 (not (gnus-summary-article-sparse-p number))
4694 (not (gnus-summary-article-ancient-p number)))
4695 (setq gnus-newsgroup-unreads
4696 (delq number gnus-newsgroup-unreads))
4697 (if gnus-newsgroup-auto-expire
4698 (setq gnus-newsgroup-expirable
4699 (gnus-add-to-sorted-list
4700 gnus-newsgroup-expirable number))
4701 (push (cons number gnus-low-score-mark)
4702 gnus-newsgroup-reads))))
4704 (when gnus-tmp-header
4705 ;; We may have an old dummy line to output before this
4707 (when (and gnus-tmp-dummy-line
4710 (mail-header-subject gnus-tmp-header)))
4711 (gnus-summary-insert-dummy-line
4712 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4713 (setq gnus-tmp-dummy-line nil))
4715 ;; Compute the mark.
4716 (setq gnus-tmp-unread (gnus-article-mark number))
4718 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4719 gnus-tmp-header gnus-tmp-level)
4720 gnus-newsgroup-data)
4722 ;; Actually insert the line.
4724 gnus-tmp-subject-or-nil
4726 ((and gnus-thread-ignore-subject
4727 gnus-tmp-prev-subject
4728 (not (string= gnus-tmp-prev-subject simp-subject)))
4730 ((zerop gnus-tmp-level)
4731 (if (and (eq gnus-summary-make-false-root 'empty)
4732 (memq number gnus-tmp-gathered)
4733 gnus-tmp-prev-subject
4734 (string= gnus-tmp-prev-subject simp-subject))
4735 gnus-summary-same-subject
4737 (t gnus-summary-same-subject)))
4738 (if (and (eq gnus-summary-make-false-root 'adopt)
4739 (= gnus-tmp-level 1)
4740 (memq number gnus-tmp-gathered))
4741 (setq gnus-tmp-opening-bracket ?\<
4742 gnus-tmp-closing-bracket ?\>)
4743 (setq gnus-tmp-opening-bracket ?\[
4744 gnus-tmp-closing-bracket ?\]))
4746 gnus-tmp-indentation
4747 (aref gnus-thread-indent-array gnus-tmp-level)
4748 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4749 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4750 gnus-summary-default-score 0)
4752 (if (or (null gnus-summary-default-score)
4753 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4754 gnus-summary-zcore-fuzz))
4756 (if (< gnus-tmp-score gnus-summary-default-score)
4757 gnus-score-below-mark gnus-score-over-mark))
4759 (cond ((memq number gnus-newsgroup-processable)
4761 ((memq number gnus-newsgroup-cached)
4763 ((memq number gnus-newsgroup-replied)
4765 ((memq number gnus-newsgroup-forwarded)
4766 gnus-forwarded-mark)
4767 ((memq number gnus-newsgroup-saved)
4769 ((memq number gnus-newsgroup-recent)
4771 ((memq number gnus-newsgroup-unseen)
4775 (cond ((memq number gnus-newsgroup-undownloaded)
4776 gnus-undownloaded-mark)
4777 (gnus-newsgroup-agentized
4778 gnus-downloaded-mark)
4781 gnus-tmp-from (mail-header-from gnus-tmp-header)
4784 ((string-match "<[^>]+> *$" gnus-tmp-from)
4785 (setq beg-match (match-beginning 0))
4786 (or (and (string-match "^\".+\"" gnus-tmp-from)
4787 (substring gnus-tmp-from 1 (1- (match-end 0))))
4788 (substring gnus-tmp-from 0 beg-match)))
4789 ((string-match "(.+)" gnus-tmp-from)
4790 (substring gnus-tmp-from
4791 (1+ (match-beginning 0)) (1- (match-end 0))))
4793 gnus-tmp-thread-tree-header-string
4795 ((not gnus-show-threads) "")
4796 ((zerop gnus-tmp-level)
4798 (or gnus-sum-thread-tree-root subject)
4799 (or gnus-sum-thread-tree-single-indent subject)))
4801 (concat (apply 'concat
4802 (mapcar (lambda (item)
4804 gnus-sum-thread-tree-vertical
4805 gnus-sum-thread-tree-indent))
4806 (cdr (reverse tree-stack))))
4808 gnus-sum-thread-tree-leaf-with-other
4809 gnus-sum-thread-tree-single-leaf)))))
4810 (when (string= gnus-tmp-name "")
4811 (setq gnus-tmp-name gnus-tmp-from))
4812 (unless (numberp gnus-tmp-lines)
4813 (setq gnus-tmp-lines -1))
4814 (if (= gnus-tmp-lines -1)
4815 (setq gnus-tmp-lines "?")
4816 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4817 (gnus-put-text-property
4819 (progn (eval gnus-summary-line-format-spec) (point))
4820 'gnus-number number)
4823 (gnus-run-hooks 'gnus-summary-update-hook)
4826 (setq gnus-tmp-prev-subject simp-subject)))
4828 (when (nth 1 thread)
4829 (push (list (max 0 gnus-tmp-level)
4830 (copy-list tree-stack)
4833 (push (if (nth 1 thread) 1 0) tree-stack)
4834 (incf gnus-tmp-level)
4835 (setq threads (if thread-end nil (cdar thread)))
4836 (if gnus-summary-display-while-building
4839 ;; use a set frequency
4840 (setq building-line-count (1- building-line-count))
4841 (when (= building-line-count 0)
4843 (setq building-line-count
4844 gnus-summary-display-while-building)))
4848 (setq gnus-tmp-level 0)))))
4849 (gnus-message 7 "Generating summary...done"))
4851 (defun gnus-summary-prepare-unthreaded (headers)
4852 "Generate an unthreaded summary buffer based on HEADERS."
4853 (let (header number mark)
4858 ;; We may have to root out some bad articles...
4859 (when (memq (setq number (mail-header-number
4860 (setq header (pop headers))))
4861 gnus-newsgroup-limit)
4862 ;; Mark article as read when it has a low score.
4863 (when (and gnus-summary-mark-below
4864 (< (or (cdr (assq number gnus-newsgroup-scored))
4865 gnus-summary-default-score 0)
4866 gnus-summary-mark-below)
4867 (not (gnus-summary-article-ancient-p number)))
4868 (setq gnus-newsgroup-unreads
4869 (delq number gnus-newsgroup-unreads))
4870 (if gnus-newsgroup-auto-expire
4871 (push number gnus-newsgroup-expirable)
4872 (push (cons number gnus-low-score-mark)
4873 gnus-newsgroup-reads)))
4875 (setq mark (gnus-article-mark number))
4876 (push (gnus-data-make number mark (1+ (point)) header 0)
4877 gnus-newsgroup-data)
4878 (gnus-summary-insert-line
4880 (memq number gnus-newsgroup-undownloaded)
4881 mark (memq number gnus-newsgroup-replied)
4882 (memq number gnus-newsgroup-expirable)
4883 (mail-header-subject header) nil
4884 (cdr (assq number gnus-newsgroup-scored))
4885 (memq number gnus-newsgroup-processable))))))
4887 (defun gnus-summary-remove-list-identifiers ()
4888 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4889 (let ((regexp (if (consp gnus-list-identifiers)
4890 (mapconcat 'identity gnus-list-identifiers " *\\|")
4891 gnus-list-identifiers))
4894 (dolist (header gnus-newsgroup-headers)
4895 (setq subject (mail-header-subject header)
4897 (while (string-match
4898 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4901 (concat (substring subject 0 (match-beginning 2))
4902 (substring subject (match-end 0)))
4906 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4908 (concat (substring subject 0 (match-beginning 1))
4909 (substring subject (match-end 1)))))
4911 (mail-header-set-subject header subject))))))
4913 (defun gnus-fetch-headers (articles)
4914 "Fetch headers of ARTICLES."
4915 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4916 (gnus-message 5 "Fetching headers for %s..." name)
4919 (setq gnus-headers-retrieved-by
4920 (gnus-retrieve-headers
4921 articles gnus-newsgroup-name
4922 ;; We might want to fetch old headers, but
4923 ;; not if there is only 1 article.
4925 (not (eq gnus-fetch-old-headers 'some))
4926 (not (numberp gnus-fetch-old-headers)))
4927 (> (length articles) 1))
4928 gnus-fetch-old-headers))))
4929 (gnus-get-newsgroup-headers-xover
4930 articles nil nil gnus-newsgroup-name t)
4931 (gnus-get-newsgroup-headers))
4932 (gnus-message 5 "Fetching headers for %s...done" name))))
4934 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4935 "Select newsgroup GROUP.
4936 If READ-ALL is non-nil, all articles in the group are selected.
4937 If SELECT-ARTICLES, only select those articles from GROUP."
4938 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4939 ;;!!! Dirty hack; should be removed.
4940 (gnus-summary-ignore-duplicates
4941 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4943 gnus-summary-ignore-duplicates))
4944 (info (nth 2 entry))
4945 articles fetched-articles cached)
4947 (unless (gnus-check-server
4948 (set (make-local-variable 'gnus-current-select-method)
4949 (gnus-find-method-for-group group)))
4950 (error "Couldn't open server"))
4952 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4953 (gnus-activate-group group) ; Or we can activate it...
4954 (progn ; Or we bug out.
4955 (when (equal major-mode 'gnus-summary-mode)
4956 (gnus-kill-buffer (current-buffer)))
4957 (error "Couldn't activate group %s: %s"
4958 group (gnus-status-message group))))
4960 (unless (gnus-request-group group t)
4961 (when (equal major-mode 'gnus-summary-mode)
4962 (gnus-kill-buffer (current-buffer)))
4963 (error "Couldn't request group %s: %s"
4964 group (gnus-status-message group)))
4966 (setq gnus-newsgroup-name group
4967 gnus-newsgroup-unselected nil
4968 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4970 (let ((display (gnus-group-find-parameter group 'display)))
4971 (setq gnus-newsgroup-display
4973 ((not (zerop (or (car-safe read-all) 0)))
4974 ;; The user entered the group with C-u SPC/RET, let's show
4980 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4982 ;; The following is probably the "correct" solution, but
4983 ;; it makes Gnus fetch all headers and then limit the
4984 ;; articles (which is slow), so instead we hack the
4985 ;; select-articles parameter instead. -- Simon Josefsson
4988 ;; (gnus-byte-compile
4989 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4991 (setq select-articles
4992 (gnus-uncompress-range
4993 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4997 (cdr (gnus-active group)))))
5002 (gnus-summary-setup-default-charset)
5004 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5005 (when (gnus-virtual-group-p group)
5006 (setq cached gnus-newsgroup-cached))
5008 (setq gnus-newsgroup-unreads
5009 (gnus-sorted-ndifference
5010 (gnus-sorted-ndifference gnus-newsgroup-unreads
5011 gnus-newsgroup-marked)
5012 gnus-newsgroup-dormant))
5014 (setq gnus-newsgroup-processable nil)
5016 (gnus-update-read-articles group gnus-newsgroup-unreads)
5018 ;; Adjust and set lists of article marks.
5020 (gnus-adjust-marked-articles info))
5021 (if (setq articles select-articles)
5022 (setq gnus-newsgroup-unselected
5023 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5024 (setq articles (gnus-articles-to-read group read-all)))
5028 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5030 ((eq articles 0) nil)
5032 ;; Init the dependencies hash table.
5033 (setq gnus-newsgroup-dependencies
5034 (gnus-make-hashtable (length articles)))
5035 (gnus-set-global-variables)
5036 ;; Retrieve the headers and read them in.
5038 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5040 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5042 (setq gnus-newsgroup-cached cached))
5044 ;; Suppress duplicates?
5045 (when gnus-suppress-duplicates
5046 (gnus-dup-suppress-articles))
5048 ;; Set the initial limit.
5049 (setq gnus-newsgroup-limit (copy-sequence articles))
5050 ;; Remove canceled articles from the list of unread articles.
5051 (setq fetched-articles
5052 (mapcar (lambda (headers) (mail-header-number headers))
5053 gnus-newsgroup-headers))
5054 (setq gnus-newsgroup-articles fetched-articles)
5055 (setq gnus-newsgroup-unreads
5056 (gnus-sorted-nintersection
5057 gnus-newsgroup-unreads fetched-articles))
5058 (gnus-compute-unseen-list)
5060 ;; Removed marked articles that do not exist.
5061 (gnus-update-missing-marks
5062 (gnus-sorted-difference articles fetched-articles))
5063 ;; We might want to build some more threads first.
5064 (when (and gnus-fetch-old-headers
5065 (eq gnus-headers-retrieved-by 'nov))
5066 (if (eq gnus-fetch-old-headers 'invisible)
5067 (gnus-build-all-threads)
5068 (gnus-build-old-threads)))
5069 ;; Let the Gnus agent mark articles as read.
5071 (gnus-agent-get-undownloaded-list))
5072 ;; Remove list identifiers from subject
5073 (when gnus-list-identifiers
5074 (gnus-summary-remove-list-identifiers))
5075 ;; Check whether auto-expire is to be done in this group.
5076 (setq gnus-newsgroup-auto-expire
5077 (gnus-group-auto-expirable-p group))
5078 ;; Set up the article buffer now, if necessary.
5079 (unless gnus-single-article-buffer
5080 (gnus-article-setup-buffer))
5081 ;; First and last article in this newsgroup.
5082 (when gnus-newsgroup-headers
5083 (setq gnus-newsgroup-begin
5084 (mail-header-number (car gnus-newsgroup-headers))
5087 (gnus-last-element gnus-newsgroup-headers))))
5088 ;; GROUP is successfully selected.
5089 (or gnus-newsgroup-headers t)))))
5091 (defun gnus-compute-unseen-list ()
5092 ;; The `seen' marks are treated specially.
5093 (if (not gnus-newsgroup-seen)
5094 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5095 (setq gnus-newsgroup-unseen
5096 (gnus-inverse-list-range-intersection
5097 gnus-newsgroup-articles gnus-newsgroup-seen))))
5099 (defun gnus-summary-display-make-predicate (display)
5100 (require 'gnus-agent)
5101 (when (= (length display) 1)
5102 (setq display (car display)))
5103 (unless gnus-summary-display-cache
5104 (dolist (elem (append '((unread . unread)
5107 gnus-article-mark-lists))
5108 (push (cons (cdr elem)
5110 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5111 gnus-summary-display-cache)))
5112 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5113 (gnus-category-predicate-cache gnus-summary-display-cache))
5114 (gnus-get-predicate display)))
5116 ;; Uses the dynamically bound `number' variable.
5119 (defun gnus-article-marked-p (type &optional article)
5120 (let ((article (or article number)))
5123 (memq article gnus-newsgroup-marked))
5125 (memq article gnus-newsgroup-spam-marked))
5127 (memq article gnus-newsgroup-unsendable))
5128 ((eq type 'undownload)
5129 (memq article gnus-newsgroup-undownloaded))
5130 ((eq type 'download)
5131 (memq article gnus-newsgroup-downloadable))
5133 (memq article gnus-newsgroup-unreads))
5135 (memq article gnus-newsgroup-reads))
5137 (memq article gnus-newsgroup-dormant) )
5139 (memq article gnus-newsgroup-expirable))
5141 (memq article gnus-newsgroup-replied))
5143 (memq article gnus-newsgroup-killed))
5144 ((eq type 'bookmark)
5145 (assq article gnus-newsgroup-bookmarks))
5147 (assq article gnus-newsgroup-scored))
5149 (memq article gnus-newsgroup-saved))
5151 (memq article gnus-newsgroup-cached))
5153 (memq article gnus-newsgroup-forwarded))
5155 (not (memq article gnus-newsgroup-unseen)))
5157 (memq article gnus-newsgroup-recent))
5160 (defun gnus-articles-to-read (group &optional read-all)
5161 "Find out what articles the user wants to read."
5162 (let* ((display (gnus-group-find-parameter group 'display))
5164 ;; Select all articles if `read-all' is non-nil, or if there
5165 ;; are no unread articles.
5167 (and (zerop (length gnus-newsgroup-marked))
5168 (zerop (length gnus-newsgroup-unreads)))
5169 ;; Fetch all if the predicate is non-nil.
5170 gnus-newsgroup-display)
5171 ;; We want to select the headers for all the articles in
5172 ;; the group, so we select either all the active
5173 ;; articles in the group, or (if that's nil), the
5174 ;; articles in the cache.
5176 (gnus-uncompress-range (gnus-active group))
5177 (gnus-cache-articles-in-group group))
5178 ;; Select only the "normal" subset of articles.
5180 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5181 gnus-newsgroup-unreads)))
5182 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5183 (scored (length scored-list))
5184 (number (length articles))
5185 (marked (+ (length gnus-newsgroup-marked)
5186 (length gnus-newsgroup-dormant)))
5191 ((numberp gnus-newsgroup-display)
5192 gnus-newsgroup-display)
5196 ((and (or (<= scored marked) (= scored number))
5197 (numberp gnus-large-newsgroup)
5198 (> number gnus-large-newsgroup))
5199 (let* ((cursor-in-echo-area nil)
5200 (initial (gnus-parameter-large-newsgroup-initial
5201 gnus-newsgroup-name))
5205 "How many articles from %s (%s %d): "
5207 (gnus-group-decoded-name gnus-newsgroup-name)
5209 (if initial "max" "default")
5212 (cons (number-to-string initial)
5214 (if (string-match "^[ \t]*$" input) number input)))
5215 ((and (> scored marked) (< scored number)
5216 (> (- scored number) 20))
5219 (format "%s %s (%d scored, %d total): "
5220 "How many articles from"
5221 (gnus-group-decoded-name group)
5223 (if (string-match "^[ \t]*$" input)
5227 (message "Quit getting the articles to read")
5229 (setq select (if (stringp select) (string-to-number select) select))
5230 (if (or (null select) (zerop select))
5232 (if (and (not (zerop scored)) (<= (abs select) scored))
5234 (setq articles (sort scored-list '<))
5235 (setq number (length articles)))
5236 (setq articles (copy-sequence articles)))
5238 (when (< (abs select) number)
5240 ;; Select the N oldest articles.
5241 (setcdr (nthcdr (1- (abs select)) articles) nil)
5242 ;; Select the N most recent articles.
5243 (setq articles (nthcdr (- number select) articles))))
5244 (setq gnus-newsgroup-unselected
5245 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5246 (when gnus-alter-articles-to-read-function
5249 (funcall gnus-alter-articles-to-read-function
5250 gnus-newsgroup-name articles)
5254 (defun gnus-killed-articles (killed articles)
5257 (when (inline (gnus-member-of-range (car articles) killed))
5258 (push (car articles) out))
5259 (setq articles (cdr articles)))
5262 (defun gnus-uncompress-marks (marks)
5263 "Uncompress the mark ranges in MARKS."
5264 (let ((uncompressed '(score bookmark))
5267 (if (memq (caar marks) uncompressed)
5268 (push (car marks) out)
5269 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5270 (setq marks (cdr marks)))
5273 (defun gnus-article-mark-to-type (mark)
5274 "Return the type of MARK."
5275 (or (cadr (assq mark gnus-article-special-mark-lists))
5278 (defun gnus-article-unpropagatable-p (mark)
5279 "Return whether MARK should be propagated to backend."
5280 (memq mark gnus-article-unpropagated-mark-lists))
5282 (defun gnus-adjust-marked-articles (info)
5283 "Set all article lists and remove all marks that are no longer valid."
5284 (let* ((marked-lists (gnus-info-marks info))
5285 (active (gnus-active (gnus-info-group info)))
5288 (types gnus-article-mark-lists)
5289 marks var articles article mark mark-type)
5291 (dolist (marks marked-lists)
5292 (setq mark (car marks)
5293 mark-type (gnus-article-mark-to-type mark)
5294 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5296 ;; We set the variable according to the type of the marks list,
5297 ;; and then adjust the marks to a subset of the active articles.
5299 ;; Adjust "simple" lists.
5300 ((eq mark-type 'list)
5301 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5302 (when (memq mark '(tick dormant expire reply save))
5304 (when (or (< (setq article (pop articles)) min) (> article max))
5305 (set var (delq article (symbol-value var)))))))
5307 ((eq mark-type 'tuple)
5308 (set var (setq articles (cdr marks)))
5309 (when (not (listp (cdr (symbol-value var))))
5310 (set var (list (symbol-value var))))
5311 (when (not (listp (cdr articles)))
5312 (setq articles (list articles)))
5314 (when (or (not (consp (setq article (pop articles))))
5315 (< (car article) min)
5316 (> (car article) max))
5317 (set var (delq article (symbol-value var))))))
5318 ;; Adjust ranges (sloppily).
5319 ((eq mark-type 'range)
5322 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5323 ;; It should be (seen (NUM1 . NUM2)).
5324 (when (numberp (cddr marks))
5325 (setcdr marks (list (cdr marks))))
5326 (setq articles (cdr marks))
5327 (while (and articles
5328 (or (and (consp (car articles))
5329 (> min (cdar articles)))
5330 (and (numberp (car articles))
5331 (> min (car articles)))))
5333 (set var articles))))))))
5335 (defun gnus-update-missing-marks (missing)
5336 "Go through the list of MISSING articles and remove them from the mark lists."
5339 ;; Go through all types.
5340 (dolist (elem gnus-article-mark-lists)
5341 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5342 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5343 (when (symbol-value var)
5344 ;; This list has articles. So we delete all missing
5345 ;; articles from it.
5348 (set var (delq (pop m) (symbol-value var))))))))))
5350 (defun gnus-update-marks ()
5351 "Enter the various lists of marked articles into the newsgroup info list."
5352 (let ((types gnus-article-mark-lists)
5353 (info (gnus-get-info gnus-newsgroup-name))
5354 type list newmarked symbol delta-marks)
5356 ;; Add all marks lists to the list of marks lists.
5357 (while (setq type (pop types))
5358 (setq list (symbol-value
5360 (intern (format "gnus-newsgroup-%s" (car type))))))
5363 ;; Get rid of the entries of the articles that have the
5365 (when (and (eq (cdr type) 'score)
5369 (prev (cons nil list))
5372 (if (or (not (consp (car arts)))
5373 (= (cdar arts) gnus-summary-default-score))
5374 (setcdr prev (cdr arts))
5376 (setq arts (cdr arts)))
5377 (setq list (cdr all)))))
5379 (when (eq (cdr type) 'seen)
5380 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5382 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5383 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5385 (when (and (gnus-check-backend-function
5386 'request-set-mark gnus-newsgroup-name)
5387 (not (gnus-article-unpropagatable-p (cdr type))))
5388 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5389 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5390 (add (gnus-remove-from-range
5391 (gnus-copy-sequence list) old)))
5393 (push (list add 'add (list (cdr type))) delta-marks))
5395 (push (list del 'del (list (cdr type))) delta-marks))))
5398 (push (cons (cdr type) list) newmarked)))
5401 (unless (gnus-check-group gnus-newsgroup-name)
5402 (error "Can't open server for %s" gnus-newsgroup-name))
5403 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5405 ;; Enter these new marks into the info of the group.
5407 (setcar (nthcdr 3 info) newmarked)
5408 ;; Add the marks lists to the end of the info.
5410 (setcdr (nthcdr 2 info) (list newmarked))))
5412 ;; Cut off the end of the info if there's nothing else there.
5416 (when (nthcdr (decf i) info)
5417 (setcdr (nthcdr i info) nil)))))))
5419 (defun gnus-set-mode-line (where)
5420 "Set the mode line of the article or summary buffers.
5421 If WHERE is `summary', the summary mode line format will be used."
5422 ;; Is this mode line one we keep updated?
5423 (when (and (memq where gnus-updated-mode-lines)
5425 (intern (format "gnus-%s-mode-line-format-spec" where))))
5428 ;; We evaluate this in the summary buffer since these
5429 ;; variables are buffer-local to that buffer.
5430 (set-buffer gnus-summary-buffer)
5431 ;; We bind all these variables that are used in the `eval' form
5433 (let* ((mformat (symbol-value
5435 (format "gnus-%s-mode-line-format-spec" where))))
5436 (gnus-tmp-group-name (gnus-group-decoded-name
5437 gnus-newsgroup-name))
5438 (gnus-tmp-article-number (or gnus-current-article 0))
5439 (gnus-tmp-unread gnus-newsgroup-unreads)
5440 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5441 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5442 (gnus-tmp-unread-and-unselected
5443 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5444 (zerop gnus-tmp-unselected))
5446 ((zerop gnus-tmp-unselected)
5447 (format "{%d more}" gnus-tmp-unread-and-unticked))
5448 (t (format "{%d(+%d) more}"
5449 gnus-tmp-unread-and-unticked
5450 gnus-tmp-unselected))))
5452 (if (and gnus-current-headers
5453 (vectorp gnus-current-headers))
5454 (gnus-mode-string-quote
5455 (mail-header-subject gnus-current-headers))
5457 bufname-length max-len
5458 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5459 (setq mode-string (eval mformat))
5460 (setq bufname-length (if (string-match "%b" mode-string)
5463 (if (eq where 'summary)
5465 (get-buffer gnus-article-buffer))))
5468 (setq max-len (max 4 (if gnus-mode-non-string-length
5470 gnus-mode-non-string-length
5472 (length mode-string))))
5473 ;; We might have to chop a bit of the string off...
5474 (when (> (length mode-string) max-len)
5476 (concat (truncate-string-to-width mode-string (- max-len 3))
5478 ;; Pad the mode string a bit.
5479 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5480 ;; Update the mode line.
5481 (setq mode-line-buffer-identification
5482 (gnus-mode-line-buffer-identification (list mode-string)))
5483 (set-buffer-modified-p t))))
5485 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5486 "Go through the HEADERS list and add all Xrefs to a hash table.
5487 The resulting hash table is returned, or nil if no Xrefs were found."
5488 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5489 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5490 (xref-hashtb (gnus-make-hashtable))
5491 start group entry number xrefs header)
5493 (setq header (pop headers))
5494 (when (and (setq xrefs (mail-header-xref header))
5495 (not (memq (setq number (mail-header-number header))
5498 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5499 (setq start (match-end 0))
5500 (setq group (if prefix
5501 (concat prefix (substring xrefs (match-beginning 1)
5503 (substring xrefs (match-beginning 1) (match-end 1))))
5505 (string-to-int (substring xrefs (match-beginning 2)
5507 (if (setq entry (gnus-gethash group xref-hashtb))
5508 (setcdr entry (cons number (cdr entry)))
5509 (gnus-sethash group (cons number nil) xref-hashtb)))))
5510 (and start xref-hashtb)))
5512 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5513 "Look through all the headers and mark the Xrefs as read."
5514 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5515 name entry info xref-hashtb idlist method nth4)
5517 (set-buffer gnus-group-buffer)
5518 (when (setq xref-hashtb
5519 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5522 (unless (string= from-newsgroup (setq name (symbol-name group)))
5523 (setq idlist (symbol-value group))
5524 ;; Dead groups are not updated.
5526 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5528 (when (stringp (setq nth4 (gnus-info-method info)))
5529 (setq nth4 (gnus-server-to-method nth4))))
5530 ;; Only do the xrefs if the group has the same
5531 ;; select method as the group we have just read.
5532 (or (gnus-methods-equal-p
5533 nth4 (gnus-find-method-for-group from-newsgroup))
5535 (equal nth4 (setq method (gnus-find-method-for-group
5537 (and (equal (car nth4) (car method))
5538 (equal (nth 1 nth4) (nth 1 method))))
5539 gnus-use-cross-reference
5540 (or (not (eq gnus-use-cross-reference t))
5542 ;; Only do cross-references on subscribed
5543 ;; groups, if that is what is wanted.
5544 (<= (gnus-info-level info) gnus-level-subscribed))
5545 (gnus-group-make-articles-read name idlist))))
5548 (defun gnus-compute-read-articles (group articles)
5549 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5550 (info (nth 2 entry))
5551 (active (gnus-active group))
5554 ;; First peel off all invalid article numbers.
5556 (let ((ids articles)
5558 (while (setq id (pop ids))
5559 (when (and first (> id (cdr active)))
5560 ;; We'll end up in this situation in one particular
5561 ;; obscure situation. If you re-scan a group and get
5562 ;; a new article that is cross-posted to a different
5563 ;; group that has not been re-scanned, you might get
5564 ;; crossposted article that has a higher number than
5565 ;; Gnus believes possible. So we re-activate this
5566 ;; group as well. This might mean doing the
5567 ;; crossposting thingy will *increase* the number
5568 ;; of articles in some groups. Tsk, tsk.
5569 (setq active (or (gnus-activate-group group) active)))
5570 (when (or (> id (cdr active))
5571 (< id (car active)))
5572 (setq articles (delq id articles))))))
5573 ;; If the read list is nil, we init it.
5575 (null (gnus-info-read info))
5577 (setq ninfo (cons 1 (1- (car active))))
5578 (setq ninfo (gnus-info-read info)))
5579 ;; Then we add the read articles to the range.
5581 ninfo (setq articles (sort articles '<))))))
5583 (defun gnus-group-make-articles-read (group articles)
5584 "Update the info of GROUP to say that ARTICLES are read."
5586 (entry (gnus-gethash group gnus-newsrc-hashtb))
5587 (info (nth 2 entry))
5588 (active (gnus-active group))
5591 (setq range (gnus-compute-read-articles group articles))
5593 (set-buffer gnus-group-buffer)
5596 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5597 (gnus-info-set-read ',info ',(gnus-info-read info))
5598 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5599 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5600 (gnus-group-update-group ,group t))))
5601 ;; Add the read articles to the range.
5602 (gnus-info-set-read info range)
5603 (gnus-request-set-mark group (list (list range 'add '(read))))
5604 ;; Then we have to re-compute how many unread
5605 ;; articles there are in this group.
5609 (setq num (- (1+ (cdr active)) (car active))))
5610 ((not (listp (cdr range)))
5611 (setq num (- (cdr active) (- (1+ (cdr range))
5615 (if (numberp (car range))
5617 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5618 (setq range (cdr range)))
5619 (setq num (- (cdr active) num))))
5620 ;; Update the number of unread articles.
5622 ;; Update the group buffer.
5623 (unless (gnus-ephemeral-group-p group)
5624 (gnus-group-update-group group t))))))
5626 (defvar gnus-newsgroup-none-id 0)
5628 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5629 (let ((cur nntp-server-buffer)
5632 (save-excursion (set-buffer gnus-summary-buffer)
5633 gnus-newsgroup-dependencies)))
5635 (mail-parse-charset gnus-newsgroup-charset)
5636 (mail-parse-ignored-charsets
5637 (save-excursion (condition-case nil
5638 (set-buffer gnus-summary-buffer)
5640 gnus-newsgroup-ignored-charsets)))
5642 (set-buffer nntp-server-buffer)
5643 ;; Translate all TAB characters into SPACE characters.
5644 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5645 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5646 (gnus-run-hooks 'gnus-parse-headers-hook)
5647 (let ((case-fold-search t)
5648 in-reply-to header p lines chars)
5649 (goto-char (point-min))
5650 ;; Search to the beginning of the next header. Error messages
5651 ;; do not begin with 2 or 3.
5652 (while (re-search-forward "^[23][0-9]+ " nil t)
5655 ;; This implementation of this function, with nine
5656 ;; search-forwards instead of the one re-search-forward and
5657 ;; a case (which basically was the old function) is actually
5658 ;; about twice as fast, even though it looks messier. You
5659 ;; can't have everything, I guess. Speed and elegance
5660 ;; doesn't always go hand in hand.
5669 (narrow-to-region (point)
5670 (or (and (search-forward "\n.\n" nil t)
5676 (if (search-forward "\nsubject:" nil t)
5677 (funcall gnus-decode-encoded-word-function
5678 (nnheader-header-value))
5683 (if (search-forward "\nfrom:" nil t)
5684 (funcall gnus-decode-encoded-word-function
5685 (nnheader-header-value))
5690 (if (search-forward "\ndate:" nil t)
5691 (nnheader-header-value) ""))
5695 (setq id (if (re-search-forward
5696 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5697 ;; We do it this way to make sure the Message-ID
5698 ;; is (somewhat) syntactically valid.
5699 (buffer-substring (match-beginning 1)
5701 ;; If there was no message-id, we just fake one
5702 ;; to make subsequent routines simpler.
5703 (nnheader-generate-fake-message-id))))
5707 (if (search-forward "\nreferences:" nil t)
5711 (nnheader-header-value)
5716 (search-backward ">" end t)
5719 (search-backward "<" end t)
5721 ;; Get the references from the in-reply-to header if there
5722 ;; were no references and the in-reply-to header looks
5724 (if (and (search-forward "\nin-reply-to:" nil t)
5725 (setq in-reply-to (nnheader-header-value))
5726 (string-match "<[^>]+>" in-reply-to))
5728 (setq ref (substring in-reply-to (match-beginning 0)
5730 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5731 (setq ref2 (substring in-reply-to (match-beginning 0)
5733 (when (> (length ref2) (length ref))
5740 (if (search-forward "\nchars: " nil t)
5741 (if (numberp (setq chars (ignore-errors (read cur))))
5747 (if (search-forward "\nlines: " nil t)
5748 (if (numberp (setq lines (ignore-errors (read cur))))
5754 (and (search-forward "\nxref:" nil t)
5755 (nnheader-header-value)))
5757 (when gnus-extra-headers
5758 (let ((extra gnus-extra-headers)
5762 (when (search-forward
5763 (concat "\n" (symbol-name (car extra)) ":") nil t)
5764 (push (cons (car extra) (nnheader-header-value))
5768 (when (equal id ref)
5771 (when gnus-alter-header-function
5772 (funcall gnus-alter-header-function header)
5773 (setq id (mail-header-id header)
5774 ref (gnus-parent-id (mail-header-references header))))
5777 (gnus-dependencies-add-header
5778 header dependencies force-new))
5779 (push header headers))
5780 (goto-char (point-max))
5782 (nreverse headers)))))
5784 ;; Goes through the xover lines and returns a list of vectors
5785 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5786 force-new dependencies
5787 group also-fetch-heads)
5788 "Parse the news overview data in the server buffer.
5789 Return a list of headers that match SEQUENCE (see
5790 `nntp-retrieve-headers')."
5791 ;; Get the Xref when the users reads the articles since most/some
5792 ;; NNTP servers do not include Xrefs when using XOVER.
5793 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5794 (let ((mail-parse-charset gnus-newsgroup-charset)
5795 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5796 (cur nntp-server-buffer)
5797 (dependencies (or dependencies gnus-newsgroup-dependencies))
5799 ((eq gnus-read-all-available-headers t)
5801 ((stringp gnus-read-all-available-headers)
5802 (string-match gnus-read-all-available-headers group))
5805 number headers header)
5807 (set-buffer nntp-server-buffer)
5808 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5809 ;; Allow the user to mangle the headers before parsing them.
5810 (gnus-run-hooks 'gnus-parse-headers-hook)
5811 (goto-char (point-min))
5812 (gnus-parse-without-error
5813 (while (and (or sequence allp)
5815 (setq number (read cur))
5817 (while (and sequence
5818 (< (car sequence) number))
5819 (setq sequence (cdr sequence))))
5822 (eq number (car sequence))))
5824 (setq sequence (cdr sequence))
5825 (setq header (inline
5826 (gnus-nov-parse-line
5827 number dependencies force-new)))))
5828 (push header headers))
5830 ;; A common bug in inn is that if you have posted an article and
5831 ;; then retrieves the active file, it will answer correctly --
5832 ;; the new article is included. However, a NOV entry for the
5833 ;; article may not have been generated yet, so this may fail.
5834 ;; We work around this problem by retrieving the last few
5835 ;; headers using HEAD.
5836 (if (or (not also-fetch-heads)
5838 ;; We (probably) got all the headers.
5840 (let ((gnus-nov-is-evil t))
5843 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5844 (gnus-get-newsgroup-headers))))))))
5846 (defun gnus-article-get-xrefs ()
5847 "Fill in the Xref value in `gnus-current-headers', if necessary.
5848 This is meant to be called in `gnus-article-internal-prepare-hook'."
5849 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5850 gnus-current-headers)))
5851 (or (not gnus-use-cross-reference)
5853 (and (mail-header-xref headers)
5854 (not (string= (mail-header-xref headers) "")))
5855 (let ((case-fold-search t)
5858 (nnheader-narrow-to-headers)
5859 (goto-char (point-min))
5860 (when (or (and (not (eobp))
5861 (eq (downcase (char-after)) ?x)
5862 (looking-at "Xref:"))
5863 (search-forward "\nXref:" nil t))
5864 (goto-char (1+ (match-end 0)))
5865 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
5866 (mail-header-set-xref headers xref)))))))
5868 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5869 "Find article ID and insert the summary line for that article.
5870 OLD-HEADER can either be a header or a line number to insert
5871 the subject line on."
5872 (let* ((line (and (numberp old-header) old-header))
5873 (old-header (and (vectorp old-header) old-header))
5874 (header (cond ((and old-header use-old-header)
5877 (gnus-number-to-header id))
5878 (gnus-number-to-header id))
5880 (gnus-read-header id))))
5881 (number (and (numberp id) id))
5884 ;; Rebuild the thread that this article is part of and go to the
5885 ;; article we have fetched.
5886 (when (and (not gnus-show-threads)
5889 (setq d (gnus-data-find (mail-header-number old-header))))
5890 (goto-char (gnus-data-pos d))
5893 (- (gnus-point-at-bol)
5895 (1+ (gnus-point-at-eol))
5896 (gnus-delete-line))))))
5898 (mail-header-set-number header (mail-header-number old-header)))
5899 (setq gnus-newsgroup-sparse
5900 (delq (setq number (mail-header-number header))
5901 gnus-newsgroup-sparse))
5902 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5903 (push number gnus-newsgroup-limit)
5904 (gnus-rebuild-thread (mail-header-id header) line)
5905 (gnus-summary-goto-subject number nil t))
5906 (when (and (numberp number)
5908 ;; We have to update the boundaries even if we can't fetch the
5909 ;; article if ID is a number -- so that the next `P' or `N'
5910 ;; command will fetch the previous (or next) article even
5911 ;; if the one we tried to fetch this time has been canceled.
5912 (when (> number gnus-newsgroup-end)
5913 (setq gnus-newsgroup-end number))
5914 (when (< number gnus-newsgroup-begin)
5915 (setq gnus-newsgroup-begin number))
5916 (setq gnus-newsgroup-unselected
5917 (delq number gnus-newsgroup-unselected)))
5918 ;; Report back a success?
5919 (and header (mail-header-number header))))
5921 ;;; Process/prefix in the summary buffer
5923 (defun gnus-summary-work-articles (n)
5924 "Return a list of articles to be worked upon.
5925 The prefix argument, the list of process marked articles, and the
5926 current article will be taken into consideration."
5928 (set-buffer gnus-summary-buffer)
5931 ;; A numerical prefix has been given.
5932 (setq n (prefix-numeric-value n))
5933 (let ((backward (< n 0))
5934 (n (abs (prefix-numeric-value n)))
5939 (push (setq article (gnus-summary-article-number))
5942 (gnus-summary-find-prev nil article)
5943 (gnus-summary-find-next nil article)))
5945 (nreverse articles)))
5946 ((and (gnus-region-active-p) (mark))
5947 (message "region active")
5948 ;; Work on the region between point and mark.
5949 (let ((max (max (point) (mark)))
5952 (goto-char (min (min (point) (mark))))
5955 (push (setq article (gnus-summary-article-number)) articles)
5956 (gnus-summary-find-next nil article)
5958 (nreverse articles))))
5959 (gnus-newsgroup-processable
5960 ;; There are process-marked articles present.
5961 ;; Save current state.
5962 (gnus-summary-save-process-mark)
5964 (reverse gnus-newsgroup-processable))
5966 ;; Just return the current article.
5967 (list (gnus-summary-article-number))))))
5969 (defmacro gnus-summary-iterate (arg &rest forms)
5970 "Iterate over the process/prefixed articles and do FORMS.
5971 ARG is the interactive prefix given to the command. FORMS will be
5972 executed with point over the summary line of the articles."
5973 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5974 `(let ((,articles (gnus-summary-work-articles ,arg)))
5976 (gnus-summary-goto-subject (car ,articles))
5980 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5981 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5983 (defun gnus-summary-save-process-mark ()
5984 "Push the current set of process marked articles on the stack."
5986 (push (copy-sequence gnus-newsgroup-processable)
5987 gnus-newsgroup-process-stack))
5989 (defun gnus-summary-kill-process-mark ()
5990 "Push the current set of process marked articles on the stack and unmark."
5992 (gnus-summary-save-process-mark)
5993 (gnus-summary-unmark-all-processable))
5995 (defun gnus-summary-yank-process-mark ()
5996 "Pop the last process mark state off the stack and restore it."
5998 (unless gnus-newsgroup-process-stack
5999 (error "Empty mark stack"))
6000 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6002 (defun gnus-summary-process-mark-set (set)
6003 "Make SET into the current process marked articles."
6004 (gnus-summary-unmark-all-processable)
6006 (gnus-summary-set-process-mark (pop set))))
6008 ;;; Searching and stuff
6010 (defun gnus-summary-search-group (&optional backward use-level)
6011 "Search for next unread newsgroup.
6012 If optional argument BACKWARD is non-nil, search backward instead."
6014 (set-buffer gnus-group-buffer)
6015 (when (gnus-group-search-forward
6016 backward nil (if use-level (gnus-group-group-level) nil))
6017 (gnus-group-group-name))))
6019 (defun gnus-summary-best-group (&optional exclude-group)
6020 "Find the name of the best unread group.
6021 If EXCLUDE-GROUP, do not go to this group."
6023 (set-buffer gnus-group-buffer)
6025 (gnus-group-best-unread-group exclude-group))))
6027 (defun gnus-summary-find-next (&optional unread article backward)
6028 (if backward (gnus-summary-find-prev)
6029 (let* ((dummy (gnus-summary-article-intangible-p))
6030 (article (or article (gnus-summary-article-number)))
6031 (data (gnus-data-find-list article))
6033 (when (and (not dummy)
6034 (or (not gnus-summary-check-current)
6036 (not (gnus-data-unread-p (car data)))))
6037 (setq data (cdr data)))
6042 (unless (memq (gnus-data-number (car data))
6043 gnus-newsgroup-unfetched)
6044 (when (gnus-data-unread-p (car data))
6045 (setq result (car data)
6047 (setq data (cdr data)))
6050 (goto-char (gnus-data-pos result))
6051 (gnus-data-number result)))))
6053 (defun gnus-summary-find-prev (&optional unread article)
6054 (let* ((eobp (eobp))
6055 (article (or article (gnus-summary-article-number)))
6056 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6058 (when (and (not eobp)
6059 (or (not gnus-summary-check-current)
6061 (not (gnus-data-unread-p (car data)))))
6062 (setq data (cdr data)))
6067 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6068 (when (gnus-data-unread-p (car data))
6069 (setq result (car data)
6071 (setq data (cdr data)))
6074 (goto-char (gnus-data-pos result))
6075 (gnus-data-number result))))
6077 (defun gnus-summary-find-subject (subject &optional unread backward article)
6078 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6079 (article (or article (gnus-summary-article-number)))
6080 (articles (gnus-data-list backward))
6081 (arts (gnus-data-find-list article articles))
6083 (when (or (not gnus-summary-check-current)
6085 (not (gnus-data-unread-p (car arts))))
6086 (setq arts (cdr arts)))
6088 (and (or (not unread)
6089 (gnus-data-unread-p (car arts)))
6090 (vectorp (gnus-data-header (car arts)))
6092 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6093 (setq result (car arts)
6095 (setq arts (cdr arts)))
6097 (goto-char (gnus-data-pos result))
6098 (gnus-data-number result))))
6100 (defun gnus-summary-search-forward (&optional unread subject backward)
6101 "Search forward for an article.
6102 If UNREAD, look for unread articles. If SUBJECT, look for
6103 articles with that subject. If BACKWARD, search backward instead."
6104 (cond (subject (gnus-summary-find-subject subject unread backward))
6105 (backward (gnus-summary-find-prev unread))
6106 (t (gnus-summary-find-next unread))))
6108 (defun gnus-recenter (&optional n)
6109 "Center point in window and redisplay frame.
6110 Also do horizontal recentering."
6112 (when (and gnus-auto-center-summary
6113 (not (eq gnus-auto-center-summary 'vertical)))
6114 (gnus-horizontal-recenter))
6117 (defun gnus-summary-recenter ()
6118 "Center point in the summary window.
6119 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6120 displayed, no centering will be performed."
6121 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6122 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6124 ;; The user has to want it.
6125 (when gnus-auto-center-summary
6126 (let* ((top (cond ((< (window-height) 4) 0)
6127 ((< (window-height) 7) 1)
6128 (t (if (numberp gnus-auto-center-summary)
6129 gnus-auto-center-summary
6131 (height (1- (window-height)))
6132 (bottom (save-excursion (goto-char (point-max))
6133 (forward-line (- height))
6135 (window (get-buffer-window (current-buffer))))
6136 (when (get-buffer-window gnus-article-buffer)
6137 ;; Only do recentering when the article buffer is displayed,
6138 ;; Set the window start to either `bottom', which is the biggest
6139 ;; possible valid number, or the second line from the top,
6140 ;; whichever is the least.
6141 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6142 (if (> bottom top-pos)
6143 ;; Keep the second line from the top visible
6144 (set-window-start window top-pos t)
6145 ;; Try to keep the bottom line visible; if it's partially
6146 ;; obscured, either scroll one more line to make it fully
6147 ;; visible, or revert to using TOP-POS.
6149 (goto-char (point-max))
6151 (let ((last-line-start (point)))
6153 (set-window-start window (point) t)
6154 (when (not (pos-visible-in-window-p last-line-start window))
6156 (set-window-start window (min (point) top-pos) t)))))))
6157 ;; Do horizontal recentering while we're at it.
6158 (when (and (get-buffer-window (current-buffer) t)
6159 (not (eq gnus-auto-center-summary 'vertical)))
6160 (let ((selected (selected-window)))
6161 (select-window (get-buffer-window (current-buffer) t))
6162 (gnus-summary-position-point)
6163 (gnus-horizontal-recenter)
6164 (select-window selected))))))
6166 (defun gnus-summary-jump-to-group (newsgroup)
6167 "Move point to NEWSGROUP in group mode buffer."
6168 ;; Keep update point of group mode buffer if visible.
6169 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6170 (save-window-excursion
6171 ;; Take care of tree window mode.
6172 (when (get-buffer-window gnus-group-buffer)
6173 (pop-to-buffer gnus-group-buffer))
6174 (gnus-group-jump-to-group newsgroup))
6176 ;; Take care of tree window mode.
6177 (if (get-buffer-window gnus-group-buffer)
6178 (pop-to-buffer gnus-group-buffer)
6179 (set-buffer gnus-group-buffer))
6180 (gnus-group-jump-to-group newsgroup))))
6182 ;; This function returns a list of article numbers based on the
6183 ;; difference between the ranges of read articles in this group and
6184 ;; the range of active articles.
6185 (defun gnus-list-of-unread-articles (group)
6186 (let* ((read (gnus-info-read (gnus-get-info group)))
6187 (active (or (gnus-active group) (gnus-activate-group group)))
6190 ;; If none are read, then all are unread.
6192 (setq first (car active))
6193 ;; If the range of read articles is a single range, then the
6194 ;; first unread article is the article after the last read
6195 ;; article. Sounds logical, doesn't it?
6196 (if (and (not (listp (cdr read)))
6197 (or (< (car read) (car active))
6198 (progn (setq read (list read))
6200 (setq first (max (car active) (1+ (cdr read))))
6201 ;; `read' is a list of ranges.
6202 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6205 (setq first (car active)))
6208 (while (< first nlast)
6210 (setq first (1+ first))))
6211 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6212 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6213 (setq read (cdr read)))))
6214 ;; And add the last unread articles.
6215 (while (<= first last)
6217 (setq first (1+ first)))
6218 ;; Return the list of unread articles.
6219 (delq 0 (nreverse unread))))
6221 (defun gnus-list-of-read-articles (group)
6222 "Return a list of unread, unticked and non-dormant articles."
6223 (let* ((info (gnus-get-info group))
6224 (marked (gnus-info-marks info))
6225 (active (gnus-active group)))
6227 (gnus-list-range-difference
6228 (gnus-list-range-difference
6229 (gnus-sorted-complement
6230 (gnus-uncompress-range active)
6231 (gnus-list-of-unread-articles group))
6232 (cdr (assq 'dormant marked)))
6233 (cdr (assq 'tick marked))))))
6235 ;; Various summary commands
6237 (defun gnus-summary-select-article-buffer ()
6238 "Reconfigure windows to show article buffer."
6240 (if (not (gnus-buffer-live-p gnus-article-buffer))
6241 (error "There is no article buffer for this summary buffer")
6242 (gnus-configure-windows 'article)
6243 (select-window (get-buffer-window gnus-article-buffer))))
6245 (defun gnus-summary-universal-argument (arg)
6246 "Perform any operation on all articles that are process/prefixed."
6248 (let ((articles (gnus-summary-work-articles arg))
6255 (substitute-command-keys
6256 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6258 (gnus-error 1 "Undefined key")
6261 (gnus-summary-goto-subject (setq article (pop articles)))
6262 (let (gnus-newsgroup-processable)
6263 (command-execute func))
6264 (gnus-summary-remove-process-mark article)))))
6265 (gnus-summary-position-point))
6267 (defun gnus-summary-toggle-truncation (&optional arg)
6268 "Toggle truncation of summary lines.
6269 With arg, turn line truncation on if arg is positive."
6271 (setq truncate-lines
6272 (if (null arg) (not truncate-lines)
6273 (> (prefix-numeric-value arg) 0)))
6276 (defun gnus-summary-find-uncancelled ()
6277 "Return the number of an uncancelled article.
6278 The current article is considered, then following articles, then previous
6279 articles. If all articles are cancelled then return a dummy 0."
6281 (dolist (rev '(nil t))
6282 (unless found ; don't demand the reverse list if we don't need it
6283 (let ((data (gnus-data-find-list
6284 (gnus-summary-article-number) (gnus-data-list rev))))
6285 (while (and data (not found))
6286 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6287 (setq found (gnus-data-number (car data))))
6288 (setq data (cdr data))))))
6291 (defun gnus-summary-reselect-current-group (&optional all rescan)
6292 "Exit and then reselect the current newsgroup.
6293 The prefix argument ALL means to select all articles."
6295 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6296 (error "Ephemeral groups can't be reselected"))
6297 (let ((current-subject (gnus-summary-find-uncancelled))
6298 (group gnus-newsgroup-name))
6299 (setq gnus-newsgroup-begin nil)
6301 ;; We have to adjust the point of group mode buffer because
6302 ;; point was moved to the next unread newsgroup by exiting.
6303 (gnus-summary-jump-to-group group)
6306 (gnus-group-get-new-news-this-group 1)))
6307 (gnus-group-read-group all t)
6308 (gnus-summary-goto-subject current-subject nil t)))
6310 (defun gnus-summary-rescan-group (&optional all)
6311 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6313 (gnus-summary-reselect-current-group all t))
6315 (defun gnus-summary-update-info (&optional non-destructive)
6317 (let ((group gnus-newsgroup-name))
6319 (when gnus-newsgroup-kill-headers
6320 (setq gnus-newsgroup-killed
6321 (gnus-compress-sequence
6323 (gnus-list-range-intersection
6324 gnus-newsgroup-unselected gnus-newsgroup-killed)
6325 gnus-newsgroup-unreads)
6327 (unless (listp (cdr gnus-newsgroup-killed))
6328 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6329 (let ((headers gnus-newsgroup-headers))
6330 ;; Set the new ranges of read articles.
6332 (set-buffer gnus-group-buffer)
6333 (gnus-undo-force-boundary))
6334 (gnus-update-read-articles
6335 group (gnus-sorted-union
6336 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6337 ;; Set the current article marks.
6338 (let ((gnus-newsgroup-scored
6339 (if (and (not gnus-save-score)
6340 (not non-destructive))
6342 gnus-newsgroup-scored)))
6344 (gnus-update-marks)))
6345 ;; Do the cross-ref thing.
6346 (when gnus-use-cross-reference
6347 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6348 ;; Do not switch windows but change the buffer to work.
6349 (set-buffer gnus-group-buffer)
6350 (unless (gnus-ephemeral-group-p group)
6351 (gnus-group-update-group group)))))))
6353 (defun gnus-summary-save-newsrc (&optional force)
6354 "Save the current number of read/marked articles in the dribble buffer.
6355 The dribble buffer will then be saved.
6356 If FORCE (the prefix), also save the .newsrc file(s)."
6358 (gnus-summary-update-info t)
6360 (gnus-save-newsrc-file)
6361 (gnus-dribble-save)))
6363 (defun gnus-summary-exit (&optional temporary)
6364 "Exit reading current newsgroup, and then return to group selection mode.
6365 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6367 (gnus-set-global-variables)
6368 (when (gnus-buffer-live-p gnus-article-buffer)
6370 (set-buffer gnus-article-buffer)
6371 (mm-destroy-parts gnus-article-mime-handles)
6372 ;; Set it to nil for safety reason.
6373 (setq gnus-article-mime-handle-alist nil)
6374 (setq gnus-article-mime-handles nil)))
6375 (gnus-kill-save-kill-buffer)
6376 (gnus-async-halt-prefetch)
6377 (let* ((group gnus-newsgroup-name)
6378 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6379 (gnus-group-is-exiting-p t)
6382 (buf (current-buffer)))
6384 ;; Do adaptive scoring, and possibly save score files.
6385 (when gnus-newsgroup-adaptive
6386 (gnus-score-adaptive))
6387 (when gnus-use-scoring
6389 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6390 ;; If we have several article buffers, we kill them at exit.
6391 (unless gnus-single-article-buffer
6392 (gnus-kill-buffer gnus-original-article-buffer)
6393 (setq gnus-article-current nil))
6394 (when gnus-use-cache
6395 (gnus-cache-possibly-remove-articles)
6396 (gnus-cache-save-buffers))
6397 (gnus-async-prefetch-remove-group group)
6398 (when gnus-suppress-duplicates
6399 (gnus-dup-enter-articles))
6400 (when gnus-use-trees
6401 (gnus-tree-close group))
6402 (when gnus-use-cache
6403 (gnus-cache-write-active))
6404 ;; Remove entries for this group.
6405 (nnmail-purge-split-history (gnus-group-real-name group))
6406 ;; Make all changes in this group permanent.
6408 (gnus-run-hooks 'gnus-exit-group-hook)
6409 (gnus-summary-update-info))
6410 (gnus-close-group group)
6411 ;; Make sure where we were, and go to next newsgroup.
6412 (set-buffer gnus-group-buffer)
6414 (gnus-group-jump-to-group group))
6415 (gnus-run-hooks 'gnus-summary-exit-hook)
6416 (unless (or quit-config
6417 ;; If this group has disappeared from the summary
6418 ;; buffer, don't skip forwards.
6419 (not (string= group (gnus-group-group-name))))
6420 (gnus-group-next-unread-group 1))
6421 (setq group-point (point))
6424 ;; If we have several article buffers, we kill them at exit.
6425 (unless gnus-single-article-buffer
6426 (gnus-kill-buffer gnus-article-buffer)
6427 (gnus-kill-buffer gnus-original-article-buffer)
6428 (setq gnus-article-current nil))
6430 (if (not gnus-kill-summary-on-exit)
6432 (gnus-deaden-summary)
6434 ;; We set all buffer-local variables to nil. It is unclear why
6435 ;; this is needed, but if we don't, buffer-local variables are
6436 ;; not garbage-collected, it seems. This would the lead to en
6437 ;; ever-growing Emacs.
6438 (gnus-summary-clear-local-variables)
6439 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6440 (gnus-summary-clear-local-variables))
6441 (when (get-buffer gnus-article-buffer)
6442 (bury-buffer gnus-article-buffer))
6443 ;; We clear the global counterparts of the buffer-local
6444 ;; variables as well, just to be on the safe side.
6445 (set-buffer gnus-group-buffer)
6446 (gnus-summary-clear-local-variables)
6447 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6448 (gnus-summary-clear-local-variables))
6449 ;; Return to group mode buffer.
6450 (when (eq mode 'gnus-summary-mode)
6451 (gnus-kill-buffer buf)))
6452 (setq gnus-current-select-method gnus-select-method)
6453 (pop-to-buffer gnus-group-buffer)
6454 (if (not quit-config)
6456 (goto-char group-point)
6457 (gnus-configure-windows 'group 'force))
6458 (gnus-handle-ephemeral-exit quit-config))
6459 ;; Clear the current group name.
6461 (setq gnus-newsgroup-name nil)))))
6463 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6464 (defun gnus-summary-exit-no-update (&optional no-questions)
6465 "Quit reading current newsgroup without updating read article info."
6467 (let* ((group gnus-newsgroup-name)
6468 (gnus-group-is-exiting-p t)
6469 (gnus-group-is-exiting-without-update-p t)
6470 (quit-config (gnus-group-quit-config group)))
6471 (when (or no-questions
6473 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6474 (gnus-async-halt-prefetch)
6475 (run-hooks 'gnus-summary-prepare-exit-hook)
6476 (when (gnus-buffer-live-p gnus-article-buffer)
6478 (set-buffer gnus-article-buffer)
6479 (mm-destroy-parts gnus-article-mime-handles)
6480 ;; Set it to nil for safety reason.
6481 (setq gnus-article-mime-handle-alist nil)
6482 (setq gnus-article-mime-handles nil)))
6483 ;; If we have several article buffers, we kill them at exit.
6484 (unless gnus-single-article-buffer
6485 (gnus-kill-buffer gnus-article-buffer)
6486 (gnus-kill-buffer gnus-original-article-buffer)
6487 (setq gnus-article-current nil))
6488 (if (not gnus-kill-summary-on-exit)
6489 (gnus-deaden-summary)
6490 (gnus-close-group group)
6491 (gnus-summary-clear-local-variables)
6492 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6493 (gnus-summary-clear-local-variables))
6494 (set-buffer gnus-group-buffer)
6495 (gnus-summary-clear-local-variables)
6496 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6497 (gnus-summary-clear-local-variables))
6498 (gnus-kill-buffer gnus-summary-buffer))
6499 (unless gnus-single-article-buffer
6500 (setq gnus-article-current nil))
6501 (when gnus-use-trees
6502 (gnus-tree-close group))
6503 (gnus-async-prefetch-remove-group group)
6504 (when (get-buffer gnus-article-buffer)
6505 (bury-buffer gnus-article-buffer))
6506 ;; Return to the group buffer.
6507 (gnus-configure-windows 'group 'force)
6508 ;; Clear the current group name.
6509 (setq gnus-newsgroup-name nil)
6510 (unless (gnus-ephemeral-group-p group)
6511 (gnus-group-update-group group))
6512 (when (equal (gnus-group-group-name) group)
6513 (gnus-group-next-unread-group 1))
6515 (gnus-handle-ephemeral-exit quit-config)))))
6517 (defun gnus-handle-ephemeral-exit (quit-config)
6518 "Handle movement when leaving an ephemeral group.
6519 The state which existed when entering the ephemeral is reset."
6520 (if (not (buffer-name (car quit-config)))
6521 (gnus-configure-windows 'group 'force)
6522 (set-buffer (car quit-config))
6523 (cond ((eq major-mode 'gnus-summary-mode)
6524 (gnus-set-global-variables))
6525 ((eq major-mode 'gnus-article-mode)
6527 ;; The `gnus-summary-buffer' variable may point
6528 ;; to the old summary buffer when using a single
6530 (unless (gnus-buffer-live-p gnus-summary-buffer)
6531 (set-buffer gnus-group-buffer))
6532 (set-buffer gnus-summary-buffer)
6533 (gnus-set-global-variables))))
6534 (if (or (eq (cdr quit-config) 'article)
6535 (eq (cdr quit-config) 'pick))
6537 ;; The current article may be from the ephemeral group
6538 ;; thus it is best that we reload this article
6539 (gnus-summary-show-article)
6540 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6541 (gnus-configure-windows 'pick 'force)
6542 (gnus-configure-windows (cdr quit-config) 'force)))
6543 (gnus-configure-windows (cdr quit-config) 'force))
6544 (when (eq major-mode 'gnus-summary-mode)
6545 (gnus-summary-next-subject 1 nil t)
6546 (gnus-summary-recenter)
6547 (gnus-summary-position-point))))
6551 (defvar gnus-dead-summary-mode-map nil)
6553 (unless gnus-dead-summary-mode-map
6554 (setq gnus-dead-summary-mode-map (make-keymap))
6555 (suppress-keymap gnus-dead-summary-mode-map)
6556 (substitute-key-definition
6557 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6558 (dolist (key '("\C-d" "\r" "\177" [delete]))
6559 (define-key gnus-dead-summary-mode-map
6560 key 'gnus-summary-wake-up-the-dead))
6561 (dolist (key '("q" "Q"))
6562 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6564 (defvar gnus-dead-summary-mode nil
6565 "Minor mode for Gnus summary buffers.")
6567 (defun gnus-dead-summary-mode (&optional arg)
6568 "Minor mode for Gnus summary buffers."
6570 (when (eq major-mode 'gnus-summary-mode)
6571 (make-local-variable 'gnus-dead-summary-mode)
6572 (setq gnus-dead-summary-mode
6573 (if (null arg) (not gnus-dead-summary-mode)
6574 (> (prefix-numeric-value arg) 0)))
6575 (when gnus-dead-summary-mode
6576 (gnus-add-minor-mode
6577 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6579 (defun gnus-deaden-summary ()
6580 "Make the current summary buffer into a dead summary buffer."
6581 ;; Kill any previous dead summary buffer.
6582 (when (and gnus-dead-summary
6583 (buffer-name gnus-dead-summary))
6585 (set-buffer gnus-dead-summary)
6586 (when gnus-dead-summary-mode
6587 (kill-buffer (current-buffer)))))
6588 ;; Make this the current dead summary.
6589 (setq gnus-dead-summary (current-buffer))
6590 (gnus-dead-summary-mode 1)
6591 (let ((name (buffer-name)))
6592 (when (string-match "Summary" name)
6594 (concat (substring name 0 (match-beginning 0)) "Dead "
6595 (substring name (match-beginning 0)))
6599 (defun gnus-kill-or-deaden-summary (buffer)
6600 "Kill or deaden the summary BUFFER."
6602 (when (and (buffer-name buffer)
6603 (not gnus-single-article-buffer))
6606 (gnus-kill-buffer gnus-article-buffer)
6607 (gnus-kill-buffer gnus-original-article-buffer)))
6610 (gnus-kill-summary-on-exit
6611 (when (and gnus-use-trees
6612 (gnus-buffer-exists-p buffer))
6615 (gnus-tree-close gnus-newsgroup-name)))
6616 (gnus-kill-buffer buffer))
6617 ;; Deaden the buffer.
6618 ((gnus-buffer-exists-p buffer)
6621 (gnus-deaden-summary))))))
6623 (defun gnus-summary-wake-up-the-dead (&rest args)
6624 "Wake up the dead summary buffer."
6626 (gnus-dead-summary-mode -1)
6627 (let ((name (buffer-name)))
6628 (when (string-match "Dead " name)
6630 (concat (substring name 0 (match-beginning 0))
6631 (substring name (match-end 0)))
6633 (gnus-message 3 "This dead summary is now alive again"))
6635 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6636 (defun gnus-summary-fetch-faq (&optional faq-dir)
6637 "Fetch the FAQ for the current group.
6638 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6642 (when current-prefix-arg
6644 "FAQ dir: " (and (listp gnus-group-faq-directory)
6645 (mapcar (lambda (file) (list file))
6646 gnus-group-faq-directory))))))
6647 (let (gnus-faq-buffer)
6648 (when (setq gnus-faq-buffer
6649 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6650 (gnus-configure-windows 'summary-faq))))
6652 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6653 (defun gnus-summary-describe-group (&optional force)
6654 "Describe the current newsgroup."
6656 (gnus-group-describe-group force gnus-newsgroup-name))
6658 (defun gnus-summary-describe-briefly ()
6659 "Describe summary mode commands briefly."
6661 (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")))
6663 ;; Walking around group mode buffer from summary mode.
6665 (defun gnus-summary-next-group (&optional no-article target-group backward)
6666 "Exit current newsgroup and then select next unread newsgroup.
6667 If prefix argument NO-ARTICLE is non-nil, no article is selected
6668 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6669 previous group instead."
6671 ;; Stop pre-fetching.
6672 (gnus-async-halt-prefetch)
6673 (let ((current-group gnus-newsgroup-name)
6674 (current-buffer (current-buffer))
6676 (while (not entered)
6677 ;; Then we find what group we are supposed to enter.
6678 (set-buffer gnus-group-buffer)
6679 (gnus-group-jump-to-group current-group)
6682 (if (eq gnus-keep-same-level 'best)
6683 (gnus-summary-best-group gnus-newsgroup-name)
6684 (gnus-summary-search-group backward gnus-keep-same-level))))
6685 (if (not target-group)
6686 ;; There are no further groups, so we return to the group
6689 (gnus-message 5 "Returning to the group buffer")
6691 (when (gnus-buffer-live-p current-buffer)
6692 (set-buffer current-buffer)
6693 (gnus-summary-exit))
6694 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6695 ;; We try to enter the target group.
6696 (gnus-group-jump-to-group target-group)
6697 (let ((unreads (gnus-group-group-unread)))
6698 (if (and (or (eq t unreads)
6699 (and unreads (not (zerop unreads))))
6701 ;; Now we semi-exit this group to update Xrefs
6702 ;; and all variables. We can't do a real exit,
6703 ;; because the window conf must remain the same
6704 ;; in case the user is prompted for info, and we
6705 ;; don't want the window conf to change before
6707 (when (gnus-buffer-live-p current-buffer)
6708 (set-buffer current-buffer)
6709 (gnus-summary-exit t))
6710 (gnus-summary-read-group
6711 target-group nil no-article
6712 (and (buffer-name current-buffer) current-buffer)
6715 (setq current-group target-group
6716 target-group nil)))))))
6718 (defun gnus-summary-prev-group (&optional no-article)
6719 "Exit current newsgroup and then select previous unread newsgroup.
6720 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6722 (gnus-summary-next-group no-article nil t))
6724 ;; Walking around summary lines.
6726 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6727 "Go to the first subject satisfying any non-nil constraint.
6728 If UNREAD is non-nil, the article should be unread.
6729 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6730 If UNSEED is non-nil, the article should be unseen.
6731 Returns the article selected or nil if there are no matching articles."
6735 ((null gnus-newsgroup-data)
6736 (gnus-message 3 "No articles in the group")
6738 ;; Pick the first article.
6739 ((not (or unread undownloaded unseen))
6740 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6741 (gnus-data-number (car gnus-newsgroup-data)))
6742 ;; Find the first unread article.
6744 (let ((data gnus-newsgroup-data))
6746 (let ((num (gnus-data-number (car data))))
6747 (or (memq num gnus-newsgroup-unfetched)
6748 (not (or (and unread
6749 (memq num gnus-newsgroup-unreads))
6751 (memq num gnus-newsgroup-undownloaded))
6753 (memq num gnus-newsgroup-unseen)))))))
6754 (setq data (cdr data)))
6758 (goto-char (gnus-data-pos (car data)))
6759 (gnus-data-number (car data)))
6760 (gnus-message 3 "No more%s articles"
6761 (let* ((r (when unread " unread"))
6762 (d (when undownloaded " undownloaded"))
6763 (s (when unseen " unseen"))
6764 (l (delq nil (list r d s))))
6765 (cond ((= 3 (length l))
6766 (concat r "," d ", or" s))
6768 (concat (car l) ", or" (cadr l)))
6775 (gnus-summary-position-point))))))
6777 (defun gnus-summary-next-subject (n &optional unread dont-display)
6778 "Go to next N'th summary line.
6779 If N is negative, go to the previous N'th subject line.
6780 If UNREAD is non-nil, only unread articles are selected.
6781 The difference between N and the actual number of steps taken is
6784 (let ((backward (< n 0))
6788 (gnus-summary-find-prev unread)
6789 (gnus-summary-find-next unread)))
6790 (unless (zerop (setq n (1- n)))
6791 (gnus-summary-show-thread)))
6793 (gnus-message 7 "No more%s articles"
6794 (if unread " unread" "")))
6795 (unless dont-display
6796 (gnus-summary-recenter)
6797 (gnus-summary-position-point))
6800 (defun gnus-summary-next-unread-subject (n)
6801 "Go to next N'th unread summary line."
6803 (gnus-summary-next-subject n t))
6805 (defun gnus-summary-prev-subject (n &optional unread)
6806 "Go to previous N'th summary line.
6807 If optional argument UNREAD is non-nil, only unread article is selected."
6809 (gnus-summary-next-subject (- n) unread))
6811 (defun gnus-summary-prev-unread-subject (n)
6812 "Go to previous N'th unread summary line."
6814 (gnus-summary-next-subject (- n) t))
6816 (defun gnus-summary-goto-subjects (articles)
6817 "Insert the subject header for ARTICLES in the current buffer."
6819 (dolist (article articles)
6820 (gnus-summary-goto-subject article t)))
6821 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6822 (gnus-summary-position-point))
6824 (defun gnus-summary-goto-subject (article &optional force silent)
6825 "Go the subject line of ARTICLE.
6826 If FORCE, also allow jumping to articles not currently shown."
6827 (interactive "nArticle number: ")
6828 (unless (numberp article)
6829 (error "Article %s is not a number" article))
6831 (data (gnus-data-find article)))
6832 ;; We read in the article if we have to.
6835 (gnus-summary-insert-subject
6837 (if (or (numberp force) (vectorp force)) force)
6839 (setq data (gnus-data-find article)))
6844 (gnus-message 3 "Can't find article %d" article))
6846 (let ((pt (gnus-data-pos data)))
6848 (gnus-summary-set-article-display-arrow pt))
6849 (gnus-summary-position-point)
6852 ;; Walking around summary lines with displaying articles.
6854 (defun gnus-summary-expand-window (&optional arg)
6855 "Make the summary buffer take up the entire Emacs frame.
6856 Given a prefix, will force an `article' buffer configuration."
6859 (gnus-configure-windows 'article 'force)
6860 (gnus-configure-windows 'summary 'force)))
6862 (defun gnus-summary-display-article (article &optional all-header)
6863 "Display ARTICLE in article buffer."
6864 (when (gnus-buffer-live-p gnus-article-buffer)
6865 (with-current-buffer gnus-article-buffer
6866 (mm-enable-multibyte)))
6867 (gnus-set-global-variables)
6868 (when (gnus-buffer-live-p gnus-article-buffer)
6869 (with-current-buffer gnus-article-buffer
6870 (setq gnus-article-charset gnus-newsgroup-charset)
6871 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6872 (mm-enable-multibyte)))
6876 (if gnus-summary-display-article-function
6877 (funcall gnus-summary-display-article-function article all-header)
6878 (gnus-article-prepare article all-header))
6879 (gnus-run-hooks 'gnus-select-article-hook)
6880 (when (and gnus-current-article
6881 (not (zerop gnus-current-article)))
6882 (gnus-summary-goto-subject gnus-current-article))
6883 (gnus-summary-recenter)
6884 (when (and gnus-use-trees gnus-show-threads)
6885 (gnus-possibly-generate-tree article)
6886 (gnus-highlight-selected-tree article))
6887 ;; Successfully display article.
6888 (gnus-article-set-window-start
6889 (cdr (assq article gnus-newsgroup-bookmarks))))))
6891 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6892 "Select the current article.
6893 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6894 non-nil, the article will be re-fetched even if it already present in
6895 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6897 ;; Make sure we are in the summary buffer to work around bbdb bug.
6898 (unless (eq major-mode 'gnus-summary-mode)
6899 (set-buffer gnus-summary-buffer))
6900 (let ((article (or article (gnus-summary-article-number)))
6901 (all-headers (not (not all-headers))) ;Must be t or nil.
6902 gnus-summary-display-article-function)
6904 (gnus-summary-article-pseudo-p article)
6905 (error "This is a pseudo-article"))
6907 (set-buffer gnus-summary-buffer)
6908 (if (or (and gnus-single-article-buffer
6909 (or (null gnus-current-article)
6910 (null gnus-article-current)
6911 (null (get-buffer gnus-article-buffer))
6912 (not (eq article (cdr gnus-article-current)))
6913 (not (equal (car gnus-article-current)
6914 gnus-newsgroup-name))))
6915 (and (not gnus-single-article-buffer)
6916 (or (null gnus-current-article)
6917 (not (eq gnus-current-article article))))
6919 ;; The requested article is different from the current article.
6921 (gnus-summary-display-article article all-headers)
6922 (when (gnus-buffer-live-p gnus-article-buffer)
6923 (with-current-buffer gnus-article-buffer
6924 (if (not gnus-article-decoded-p) ;; a local variable
6925 (mm-disable-multibyte))))
6926 (gnus-article-set-window-start
6927 (cdr (assq article gnus-newsgroup-bookmarks)))
6931 (defun gnus-summary-force-verify-and-decrypt ()
6932 "Display buttons for signed/encrypted parts and verify/decrypt them."
6934 (let ((mm-verify-option 'known)
6935 (mm-decrypt-option 'known)
6936 (gnus-buttonized-mime-types (append (list "multipart/signed"
6937 "multipart/encrypted")
6938 gnus-buttonized-mime-types)))
6939 (gnus-summary-select-article nil 'force)))
6941 (defun gnus-summary-set-current-mark (&optional current-mark)
6942 "Obsolete function."
6945 (defun gnus-summary-next-article (&optional unread subject backward push)
6946 "Select the next article.
6947 If UNREAD, only unread articles are selected.
6948 If SUBJECT, only articles with SUBJECT are selected.
6949 If BACKWARD, the previous article is selected instead of the next."
6952 ;; Is there such an article?
6953 ((and (gnus-summary-search-forward unread subject backward)
6954 (or (gnus-summary-display-article (gnus-summary-article-number))
6955 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6956 (gnus-summary-position-point))
6957 ;; If not, we try the first unread, if that is wanted.
6959 gnus-auto-select-same
6960 (gnus-summary-first-unread-article))
6961 (gnus-summary-position-point)
6962 (gnus-message 6 "Wrapped"))
6963 ;; Try to get next/previous article not displayed in this group.
6964 ((and gnus-auto-extend-newsgroup
6965 (not unread) (not subject))
6966 (gnus-summary-goto-article
6967 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6968 nil (count-lines (point-min) (point))))
6969 ;; Go to next/previous group.
6971 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6972 (gnus-summary-jump-to-group gnus-newsgroup-name))
6973 (let ((cmd last-command-char)
6976 (set-buffer gnus-group-buffer)
6979 (if (eq gnus-keep-same-level 'best)
6980 (gnus-summary-best-group gnus-newsgroup-name)
6981 (gnus-summary-search-group backward gnus-keep-same-level))))
6982 ;; For some reason, the group window gets selected. We change
6984 (select-window (get-buffer-window (current-buffer)))
6985 ;; Select next unread newsgroup automagically.
6987 ((or (not gnus-auto-select-next)
6989 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6990 ((or (eq gnus-auto-select-next 'quietly)
6991 (and (eq gnus-auto-select-next 'slightly-quietly)
6993 (and (eq gnus-auto-select-next 'almost-quietly)
6994 (gnus-summary-last-article-p)))
6996 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6998 (gnus-message 7 "No more%s articles (%s)..."
6999 (if unread " unread" "")
7000 (if group (concat "selecting " group)
7002 (gnus-summary-next-group nil group backward)))
7004 (when (gnus-key-press-event-p last-input-event)
7005 (gnus-summary-walk-group-buffer
7006 gnus-newsgroup-name cmd unread backward point))))))))
7008 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7009 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7010 (?\C-p (gnus-group-prev-unread-group 1))))
7011 (cursor-in-echo-area t)
7012 keve key group ended prompt)
7014 (set-buffer gnus-group-buffer)
7017 (if (eq gnus-keep-same-level 'best)
7018 (gnus-summary-best-group gnus-newsgroup-name)
7019 (gnus-summary-search-group backward gnus-keep-same-level))))
7023 "No more%s articles%s " (if unread " unread" "")
7025 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7026 (format " (Type %s for %s [%s])"
7027 (single-key-description cmd) group
7028 (car (gnus-gethash group gnus-newsrc-hashtb)))
7029 (format " (Type %s to exit %s)"
7030 (single-key-description cmd)
7031 gnus-newsgroup-name))))
7032 ;; Confirm auto selection.
7033 (setq key (car (setq keve (gnus-read-event-char prompt)))
7036 ((assq key keystrokes)
7037 (let ((obuf (current-buffer)))
7038 (switch-to-buffer gnus-group-buffer)
7040 (gnus-group-jump-to-group group))
7041 (eval (cadr (assq key keystrokes)))
7042 (setq group (gnus-group-group-name))
7043 (switch-to-buffer obuf))
7047 (gnus-ephemeral-group-p gnus-newsgroup-name))
7049 (gnus-summary-next-group nil group backward)))
7051 (push (cdr keve) unread-command-events))))))
7053 (defun gnus-summary-next-unread-article ()
7054 "Select unread article after current one."
7056 (gnus-summary-next-article
7057 (or (not (eq gnus-summary-goto-unread 'never))
7058 (gnus-summary-last-article-p (gnus-summary-article-number)))
7059 (and gnus-auto-select-same
7060 (gnus-summary-article-subject))))
7062 (defun gnus-summary-prev-article (&optional unread subject)
7063 "Select the article after the current one.
7064 If UNREAD is non-nil, only unread articles are selected."
7066 (gnus-summary-next-article unread subject t))
7068 (defun gnus-summary-prev-unread-article ()
7069 "Select unread article before current one."
7071 (gnus-summary-prev-article
7072 (or (not (eq gnus-summary-goto-unread 'never))
7073 (gnus-summary-first-article-p (gnus-summary-article-number)))
7074 (and gnus-auto-select-same
7075 (gnus-summary-article-subject))))
7077 (defun gnus-summary-next-page (&optional lines circular stop)
7078 "Show next page of the selected article.
7079 If at the end of the current article, select the next article.
7080 LINES says how many lines should be scrolled up.
7082 If CIRCULAR is non-nil, go to the start of the article instead of
7083 selecting the next article when reaching the end of the current
7086 If STOP is non-nil, just stop when reaching the end of the message."
7088 (setq gnus-summary-buffer (current-buffer))
7089 (gnus-set-global-variables)
7090 (let ((article (gnus-summary-article-number))
7091 (article-window (get-buffer-window gnus-article-buffer t))
7093 ;; If the buffer is empty, we have no article.
7095 (error "No article to select"))
7096 (gnus-configure-windows 'article)
7097 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7098 (if (and (eq gnus-summary-goto-unread 'never)
7099 (not (gnus-summary-last-article-p article)))
7100 (gnus-summary-next-article)
7101 (gnus-summary-next-unread-article))
7102 (if (or (null gnus-current-article)
7103 (null gnus-article-current)
7104 (/= article (cdr gnus-article-current))
7105 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7106 ;; Selected subject is different from current article's.
7107 (gnus-summary-display-article article)
7108 (when article-window
7109 (gnus-eval-in-buffer-window gnus-article-buffer
7110 (setq endp (or (gnus-article-next-page lines)
7111 (gnus-article-only-boring-p))))
7114 (gnus-message 3 "End of message"))
7116 (gnus-summary-beginning-of-article))
7118 (gnus-message 3 "End of message"))
7120 (if (and (eq gnus-summary-goto-unread 'never)
7121 (not (gnus-summary-last-article-p article)))
7122 (gnus-summary-next-article)
7123 (gnus-summary-next-unread-article))))))))
7124 (gnus-summary-recenter)
7125 (gnus-summary-position-point)))
7127 (defun gnus-summary-prev-page (&optional lines move)
7128 "Show previous page of selected article.
7129 Argument LINES specifies lines to be scrolled down.
7130 If MOVE, move to the previous unread article if point is at
7131 the beginning of the buffer."
7133 (let ((article (gnus-summary-article-number))
7134 (article-window (get-buffer-window gnus-article-buffer t))
7136 (gnus-configure-windows 'article)
7137 (if (or (null gnus-current-article)
7138 (null gnus-article-current)
7139 (/= article (cdr gnus-article-current))
7140 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7141 ;; Selected subject is different from current article's.
7142 (gnus-summary-display-article article)
7143 (gnus-summary-recenter)
7144 (when article-window
7145 (gnus-eval-in-buffer-window gnus-article-buffer
7146 (setq endp (gnus-article-prev-page lines)))
7147 (when (and move endp)
7149 (gnus-message 3 "Beginning of message"))
7151 (if (and (eq gnus-summary-goto-unread 'never)
7152 (not (gnus-summary-first-article-p article)))
7153 (gnus-summary-prev-article)
7154 (gnus-summary-prev-unread-article))))))))
7155 (gnus-summary-position-point))
7157 (defun gnus-summary-prev-page-or-article (&optional lines)
7158 "Show previous page of selected article.
7159 Argument LINES specifies lines to be scrolled down.
7160 If at the beginning of the article, go to the next article."
7162 (gnus-summary-prev-page lines t))
7164 (defun gnus-summary-scroll-up (lines)
7165 "Scroll up (or down) one line current article.
7166 Argument LINES specifies lines to be scrolled up (or down if negative)."
7168 (gnus-configure-windows 'article)
7169 (gnus-summary-show-thread)
7170 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7171 (gnus-eval-in-buffer-window gnus-article-buffer
7173 (when (gnus-article-next-page lines)
7174 (gnus-message 3 "End of message")))
7176 (gnus-article-prev-page (- lines))))))
7177 (gnus-summary-recenter)
7178 (gnus-summary-position-point))
7180 (defun gnus-summary-scroll-down (lines)
7181 "Scroll down (or up) one line current article.
7182 Argument LINES specifies lines to be scrolled down (or up if negative)."
7184 (gnus-summary-scroll-up (- lines)))
7186 (defun gnus-summary-next-same-subject ()
7187 "Select next article which has the same subject as current one."
7189 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7191 (defun gnus-summary-prev-same-subject ()
7192 "Select previous article which has the same subject as current one."
7194 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7196 (defun gnus-summary-next-unread-same-subject ()
7197 "Select next unread article which has the same subject as current one."
7199 (gnus-summary-next-article t (gnus-summary-article-subject)))
7201 (defun gnus-summary-prev-unread-same-subject ()
7202 "Select previous unread article which has the same subject as current one."
7204 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7206 (defun gnus-summary-first-unread-article ()
7207 "Select the first unread article.
7208 Return nil if there are no unread articles."
7211 (when (gnus-summary-first-subject t)
7212 (gnus-summary-show-thread)
7213 (gnus-summary-first-subject t)
7214 (gnus-summary-display-article (gnus-summary-article-number)))
7215 (gnus-summary-position-point)))
7217 (defun gnus-summary-first-unread-subject ()
7218 "Place the point on the subject line of the first unread article.
7219 Return nil if there are no unread articles."
7222 (when (gnus-summary-first-subject t)
7223 (gnus-summary-show-thread)
7224 (gnus-summary-first-subject t))
7225 (gnus-summary-position-point)))
7227 (defun gnus-summary-first-unseen-subject ()
7228 "Place the point on the subject line of the first unseen article.
7229 Return nil if there are no unseen articles."
7232 (when (gnus-summary-first-subject nil nil t)
7233 (gnus-summary-show-thread)
7234 (gnus-summary-first-subject nil nil t))
7235 (gnus-summary-position-point)))
7237 (defun gnus-summary-first-unseen-or-unread-subject ()
7238 "Place the point on the subject line of the first unseen article or,
7239 if all article have been seen, on the subject line of the first unread
7243 (unless (when (gnus-summary-first-subject nil nil t)
7244 (gnus-summary-show-thread)
7245 (gnus-summary-first-subject nil nil t))
7246 (when (gnus-summary-first-subject t)
7247 (gnus-summary-show-thread)
7248 (gnus-summary-first-subject t)))
7249 (gnus-summary-position-point)))
7251 (defun gnus-summary-first-article ()
7252 "Select the first article.
7253 Return nil if there are no articles."
7256 (when (gnus-summary-first-subject)
7257 (gnus-summary-show-thread)
7258 (gnus-summary-first-subject)
7259 (gnus-summary-display-article (gnus-summary-article-number)))
7260 (gnus-summary-position-point)))
7262 (defun gnus-summary-best-unread-article (&optional arg)
7263 "Select the unread article with the highest score.
7264 If given a prefix argument, select the next unread article that has a
7265 score higher than the default score."
7267 (let ((article (if arg
7268 (gnus-summary-better-unread-subject)
7269 (gnus-summary-best-unread-subject))))
7271 (gnus-summary-goto-article article)
7272 (error "No unread articles"))))
7274 (defun gnus-summary-best-unread-subject ()
7275 "Select the unread subject with the highest score."
7277 (let ((best -1000000)
7278 (data gnus-newsgroup-data)
7281 (and (gnus-data-unread-p (car data))
7283 (gnus-summary-article-score (gnus-data-number (car data))))
7286 article (gnus-data-number (car data))))
7287 (setq data (cdr data)))
7289 (gnus-summary-goto-subject article))
7290 (gnus-summary-position-point)
7293 (defun gnus-summary-better-unread-subject ()
7294 "Select the first unread subject that has a score over the default score."
7296 (let ((data gnus-newsgroup-data)
7298 (while (and (setq article (gnus-data-number (car data)))
7299 (or (gnus-data-read-p (car data))
7300 (not (> (gnus-summary-article-score article)
7301 gnus-summary-default-score))))
7302 (setq data (cdr data)))
7304 (gnus-summary-goto-subject article))
7305 (gnus-summary-position-point)
7308 (defun gnus-summary-last-subject ()
7309 "Go to the last displayed subject line in the group."
7310 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7312 (gnus-summary-goto-subject article))))
7314 (defun gnus-summary-goto-article (article &optional all-headers force)
7315 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7316 If ALL-HEADERS is non-nil, no header lines are hidden.
7317 If FORCE, go to the article even if it isn't displayed. If FORCE
7318 is a number, it is the line the article is to be displayed on."
7322 "Article number or Message-ID: "
7323 (mapcar (lambda (number) (list (int-to-string number)))
7324 gnus-newsgroup-limit))
7328 (if (and (stringp article)
7329 (string-match "@" article))
7330 (gnus-summary-refer-article article)
7331 (when (stringp article)
7332 (setq article (string-to-number article)))
7333 (if (gnus-summary-goto-subject article force)
7334 (gnus-summary-display-article article all-headers)
7335 (gnus-message 4 "Couldn't go to article %s" article) nil))
7336 (gnus-summary-position-point)))
7338 (defun gnus-summary-goto-last-article ()
7339 "Go to the previously read article."
7342 (when gnus-last-article
7343 (gnus-summary-goto-article gnus-last-article nil t))
7344 (gnus-summary-position-point)))
7346 (defun gnus-summary-pop-article (number)
7347 "Pop one article off the history and go to the previous.
7348 NUMBER articles will be popped off."
7351 (setq gnus-newsgroup-history
7352 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7354 (gnus-summary-goto-article (car to) nil t)
7355 (error "Article history empty")))
7356 (gnus-summary-position-point))
7358 ;; Summary commands and functions for limiting the summary buffer.
7360 (defun gnus-summary-limit-to-articles (n)
7361 "Limit the summary buffer to the next N articles.
7362 If not given a prefix, use the process marked articles instead."
7365 (let ((articles (gnus-summary-work-articles n)))
7366 (setq gnus-newsgroup-processable nil)
7367 (gnus-summary-limit articles))
7368 (gnus-summary-position-point)))
7370 (defun gnus-summary-pop-limit (&optional total)
7371 "Restore the previous limit.
7372 If given a prefix, remove all limits."
7375 (setq gnus-newsgroup-limits
7376 (list (mapcar (lambda (h) (mail-header-number h))
7377 gnus-newsgroup-headers))))
7378 (unless gnus-newsgroup-limits
7379 (error "No limit to pop"))
7381 (gnus-summary-limit nil 'pop)
7382 (gnus-summary-position-point)))
7384 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7385 "Limit the summary buffer to articles that have subjects that match a regexp.
7386 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7388 (list (read-string (if current-prefix-arg
7389 "Exclude subject (regexp): "
7390 "Limit to subject (regexp): "))
7391 nil current-prefix-arg))
7393 (setq header "subject"))
7394 (when (not (equal "" subject))
7396 (let ((articles (gnus-summary-find-matching
7397 (or header "subject") subject 'all nil nil
7400 (error "Found no matches for \"%s\"" subject))
7401 (gnus-summary-limit articles))
7402 (gnus-summary-position-point))))
7404 (defun gnus-summary-limit-to-author (from &optional not-matching)
7405 "Limit the summary buffer to articles that have authors that match a regexp.
7406 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7408 (list (read-string (if current-prefix-arg
7409 "Exclude author (regexp): "
7410 "Limit to author (regexp): "))
7411 current-prefix-arg))
7412 (gnus-summary-limit-to-subject from "from" not-matching))
7414 (defun gnus-summary-limit-to-age (age &optional younger-p)
7415 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7416 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7417 articles that are younger than AGE days."
7419 (let ((younger current-prefix-arg)
7422 (while (not days-got)
7423 (setq days (if younger
7424 (read-string "Limit to articles younger than (in days, older when negative): ")
7426 "Limit to articles older than (in days, younger when negative): ")))
7427 (when (> (length days) 0)
7428 (setq days (read days)))
7434 (setq younger (not younger))
7435 (setq days (* days -1)))))
7436 (message "Please enter a number.")
7438 (list days younger)))
7440 (let ((data gnus-newsgroup-data)
7441 (cutoff (days-to-time age))
7442 articles d date is-younger)
7443 (while (setq d (pop data))
7444 (when (and (vectorp (gnus-data-header d))
7445 (setq date (mail-header-date (gnus-data-header d))))
7446 (setq is-younger (time-less-p
7447 (time-since (condition-case ()
7454 (push (gnus-data-number d) articles))))
7455 (gnus-summary-limit (nreverse articles)))
7456 (gnus-summary-position-point)))
7458 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7459 "Limit the summary buffer to articles that match an 'extra' header."
7463 (gnus-completing-read-with-default
7464 (symbol-name (car gnus-extra-headers))
7465 (if current-prefix-arg
7466 "Exclude extra header:"
7467 "Limit extra header:")
7469 (cons (symbol-name x) x))
7474 (read-string (format "%s header %s (regexp): "
7475 (if current-prefix-arg "Exclude" "Limit to")
7477 current-prefix-arg)))
7478 (when (not (equal "" regexp))
7480 (let ((articles (gnus-summary-find-matching
7481 (cons 'extra header) regexp 'all nil nil
7484 (error "Found no matches for \"%s\"" regexp))
7485 (gnus-summary-limit articles))
7486 (gnus-summary-position-point))))
7488 (defun gnus-summary-limit-to-display-predicate ()
7489 "Limit the summary buffer to the predicated in the `display' group parameter."
7491 (unless gnus-newsgroup-display
7492 (error "There is no `display' group parameter"))
7494 (dolist (number gnus-newsgroup-articles)
7495 (when (funcall gnus-newsgroup-display)
7496 (push number articles)))
7497 (gnus-summary-limit articles))
7498 (gnus-summary-position-point))
7500 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7502 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7504 (defun gnus-summary-limit-to-unread (&optional all)
7505 "Limit the summary buffer to articles that are not marked as read.
7506 If ALL is non-nil, limit strictly to unread articles."
7509 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7510 (gnus-summary-limit-to-marks
7511 ;; Concat all the marks that say that an article is read and have
7513 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7514 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7515 gnus-low-score-mark gnus-expirable-mark
7516 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7517 gnus-duplicate-mark gnus-souped-mark)
7520 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7521 (make-obsolete 'gnus-summary-delete-marked-with
7522 'gnus-summary-limit-exclude-marks)
7524 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7525 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7526 If REVERSE, limit the summary buffer to articles that are marked
7527 with MARKS. MARKS can either be a string of marks or a list of marks.
7528 Returns how many articles were removed."
7529 (interactive "sMarks: ")
7530 (gnus-summary-limit-to-marks marks t))
7532 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7533 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7534 If REVERSE (the prefix), limit the summary buffer to articles that are
7535 not marked with MARKS. MARKS can either be a string of marks or a
7537 Returns how many articles were removed."
7538 (interactive "sMarks: \nP")
7540 (let ((data gnus-newsgroup-data)
7541 (marks (if (listp marks) marks
7542 (append marks nil))) ; Transform to list.
7545 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7546 (memq (gnus-data-mark (car data)) marks))
7547 (push (gnus-data-number (car data)) articles))
7548 (setq data (cdr data)))
7549 (gnus-summary-limit articles))
7550 (gnus-summary-position-point)))
7552 (defun gnus-summary-limit-to-score (score)
7553 "Limit to articles with score at or above SCORE."
7554 (interactive "NLimit to articles with score of at least: ")
7555 (let ((data gnus-newsgroup-data)
7558 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7560 (push (gnus-data-number (car data)) articles))
7561 (setq data (cdr data)))
7563 (gnus-summary-limit articles)
7564 (gnus-summary-position-point))))
7566 (defun gnus-summary-limit-to-unseen ()
7567 "Limit to unseen articles."
7570 (gnus-summary-limit gnus-newsgroup-unseen)
7571 (gnus-summary-position-point)))
7573 (defun gnus-summary-limit-include-thread (id)
7574 "Display all the hidden articles that is in the thread with ID in it.
7575 When called interactively, ID is the Message-ID of the current
7577 (interactive (list (mail-header-id (gnus-summary-article-header))))
7578 (let ((articles (gnus-articles-in-thread
7579 (gnus-id-to-thread (gnus-root-id id)))))
7581 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7582 (gnus-summary-limit-include-matching-articles
7584 (regexp-quote (gnus-simplify-subject-re
7585 (mail-header-subject (gnus-id-to-header id)))))
7586 (gnus-summary-position-point))))
7588 (defun gnus-summary-limit-include-matching-articles (header regexp)
7589 "Display all the hidden articles that have HEADERs that match REGEXP."
7590 (interactive (list (read-string "Match on header: ")
7591 (read-string "Regexp: ")))
7592 (let ((articles (gnus-find-matching-articles header regexp)))
7594 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7595 (gnus-summary-position-point))))
7597 (defun gnus-summary-insert-dormant-articles ()
7598 "Insert all the dormat articles for this group into the current buffer."
7600 (let ((gnus-verbose (max 6 gnus-verbose)))
7601 (if (not gnus-newsgroup-dormant)
7602 (gnus-message 3 "No cached articles for this group")
7603 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7605 (defun gnus-summary-limit-include-dormant ()
7606 "Display all the hidden articles that are marked as dormant.
7607 Note that this command only works on a subset of the articles currently
7608 fetched for this group."
7610 (unless gnus-newsgroup-dormant
7611 (error "There are no dormant articles in this group"))
7613 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7614 (gnus-summary-position-point)))
7616 (defun gnus-summary-limit-exclude-dormant ()
7617 "Hide all dormant articles."
7620 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7621 (gnus-summary-position-point)))
7623 (defun gnus-summary-limit-exclude-childless-dormant ()
7624 "Hide all dormant articles that have no children."
7626 (let ((data (gnus-data-list t))
7627 articles d children)
7628 ;; Find all articles that are either not dormant or have
7630 (while (setq d (pop data))
7631 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7633 (gnus-article-children (gnus-data-number d)))
7636 (when (memq (car children) articles)
7641 (push (gnus-data-number d) articles)))
7644 (gnus-summary-limit articles)
7645 (gnus-summary-position-point))))
7647 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7648 "Mark all unread excluded articles as read.
7649 If ALL, mark even excluded ticked and dormants as read."
7651 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7652 (let ((articles (gnus-sorted-ndifference
7654 (mapcar (lambda (h) (mail-header-number h))
7655 gnus-newsgroup-headers)
7657 gnus-newsgroup-limit))
7659 (setq gnus-newsgroup-unreads
7660 (gnus-sorted-intersection gnus-newsgroup-unreads
7661 gnus-newsgroup-limit))
7663 (setq gnus-newsgroup-dormant nil
7664 gnus-newsgroup-marked nil
7665 gnus-newsgroup-reads
7667 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7668 gnus-newsgroup-reads))
7669 (while (setq article (pop articles))
7670 (unless (or (memq article gnus-newsgroup-dormant)
7671 (memq article gnus-newsgroup-marked))
7672 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7674 (defun gnus-summary-limit (articles &optional pop)
7676 ;; We pop the previous limit off the stack and use that.
7677 (setq articles (car gnus-newsgroup-limits)
7678 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7679 ;; We use the new limit, so we push the old limit on the stack.
7680 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7682 (setq gnus-newsgroup-limit articles)
7683 (let ((total (length gnus-newsgroup-data))
7684 (data (gnus-data-find-list (gnus-summary-article-number)))
7685 (gnus-summary-mark-below nil) ; Inhibit this.
7687 ;; This will do all the work of generating the new summary buffer
7688 ;; according to the new limit.
7689 (gnus-summary-prepare)
7690 ;; Hide any threads, possibly.
7691 (gnus-summary-maybe-hide-threads)
7692 ;; Try to return to the article you were at, or one in the
7695 ;; We try to find some article after the current one.
7697 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7700 (setq data (cdr data))))
7702 ;; If there is no data, that means that we were after the last
7703 ;; article. The same goes when we can't find any articles
7704 ;; after the current one.
7705 (goto-char (point-max))
7706 (gnus-summary-find-prev))
7707 (gnus-set-mode-line 'summary)
7708 ;; We return how many articles were removed from the summary
7709 ;; buffer as a result of the new limit.
7710 (- total (length gnus-newsgroup-data))))
7712 (defsubst gnus-invisible-cut-children (threads)
7715 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7720 (defsubst gnus-cut-thread (thread)
7721 "Go forwards in the thread until we find an article that we want to display."
7722 (when (or (eq gnus-fetch-old-headers 'some)
7723 (eq gnus-fetch-old-headers 'invisible)
7724 (numberp gnus-fetch-old-headers)
7725 (eq gnus-build-sparse-threads 'some)
7726 (eq gnus-build-sparse-threads 'more))
7727 ;; Deal with old-fetched headers and sparse threads.
7731 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7732 (gnus-summary-article-ancient-p
7733 (mail-header-number (car thread))))
7734 (if (or (<= (length (cdr thread)) 1)
7735 (eq gnus-fetch-old-headers 'invisible))
7736 (setq gnus-newsgroup-limit
7737 (delq (mail-header-number (car thread))
7738 gnus-newsgroup-limit)
7739 thread (cadr thread))
7740 (when (gnus-invisible-cut-children (cdr thread))
7741 (let ((th (cdr thread)))
7743 (if (memq (mail-header-number (caar th))
7744 gnus-newsgroup-limit)
7745 (setq thread (car th)
7747 (setq th (cdr th))))))))))
7750 (defun gnus-cut-threads (threads)
7751 "Cut off all uninteresting articles from the beginning of threads."
7752 (when (or (eq gnus-fetch-old-headers 'some)
7753 (eq gnus-fetch-old-headers 'invisible)
7754 (numberp gnus-fetch-old-headers)
7755 (eq gnus-build-sparse-threads 'some)
7756 (eq gnus-build-sparse-threads 'more))
7759 (setcar th (gnus-cut-thread (car th)))
7760 (setq th (cdr th)))))
7761 ;; Remove nixed out threads.
7764 (defun gnus-summary-initial-limit (&optional show-if-empty)
7765 "Figure out what the initial limit is supposed to be on group entry.
7766 This entails weeding out unwanted dormants, low-scored articles,
7767 fetch-old-headers verbiage, and so on."
7768 ;; Most groups have nothing to remove.
7769 (if (or gnus-inhibit-limiting
7770 (and (null gnus-newsgroup-dormant)
7771 (eq gnus-newsgroup-display 'gnus-not-ignore)
7772 (not (eq gnus-fetch-old-headers 'some))
7773 (not (numberp gnus-fetch-old-headers))
7774 (not (eq gnus-fetch-old-headers 'invisible))
7775 (null gnus-summary-expunge-below)
7776 (not (eq gnus-build-sparse-threads 'some))
7777 (not (eq gnus-build-sparse-threads 'more))
7778 (null gnus-thread-expunge-below)
7779 (not gnus-use-nocem)))
7781 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7782 (setq gnus-newsgroup-limit nil)
7785 (unless (car (symbol-value node))
7786 ;; These threads have no parents -- they are roots.
7787 (let ((nodes (cdr (symbol-value node)))
7790 (if (and gnus-thread-expunge-below
7791 (< (gnus-thread-total-score (car nodes))
7792 gnus-thread-expunge-below))
7793 (gnus-expunge-thread (pop nodes))
7794 (setq thread (pop nodes))
7795 (gnus-summary-limit-children thread))))))
7796 gnus-newsgroup-dependencies)
7797 ;; If this limitation resulted in an empty group, we might
7798 ;; pop the previous limit and use it instead.
7799 (when (and (not gnus-newsgroup-limit)
7801 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7802 gnus-newsgroup-limit))
7804 (defun gnus-summary-limit-children (thread)
7805 "Return 1 if this subthread is visible and 0 if it is not."
7806 ;; First we get the number of visible children to this thread. This
7807 ;; is done by recursing down the thread using this function, so this
7808 ;; will really go down to a leaf article first, before slowly
7809 ;; working its way up towards the root.
7811 (let* ((max-lisp-eval-depth 5000)
7814 (apply '+ (mapcar 'gnus-summary-limit-children
7817 (number (mail-header-number (car thread)))
7820 (not (memq number gnus-newsgroup-marked))
7822 ;; If this article is dormant and has absolutely no visible
7823 ;; children, then this article isn't visible.
7824 (and (memq number gnus-newsgroup-dormant)
7826 ;; If this is "fetch-old-headered" and there is no
7827 ;; visible children, then we don't want this article.
7828 (and (or (eq gnus-fetch-old-headers 'some)
7829 (numberp gnus-fetch-old-headers))
7830 (gnus-summary-article-ancient-p number)
7832 ;; If this is "fetch-old-headered" and `invisible', then
7833 ;; we don't want this article.
7834 (and (eq gnus-fetch-old-headers 'invisible)
7835 (gnus-summary-article-ancient-p number))
7836 ;; If this is a sparsely inserted article with no children,
7837 ;; we don't want it.
7838 (and (eq gnus-build-sparse-threads 'some)
7839 (gnus-summary-article-sparse-p number)
7841 ;; If we use expunging, and this article is really
7842 ;; low-scored, then we don't want this article.
7843 (when (and gnus-summary-expunge-below
7845 (or (cdr (assq number gnus-newsgroup-scored))
7846 gnus-summary-default-score))
7847 gnus-summary-expunge-below))
7848 ;; We increase the expunge-tally here, but that has
7849 ;; nothing to do with the limits, really.
7850 (incf gnus-newsgroup-expunged-tally)
7851 ;; We also mark as read here, if that's wanted.
7852 (when (and gnus-summary-mark-below
7853 (< score gnus-summary-mark-below))
7854 (setq gnus-newsgroup-unreads
7855 (delq number gnus-newsgroup-unreads))
7856 (if gnus-newsgroup-auto-expire
7857 (push number gnus-newsgroup-expirable)
7858 (push (cons number gnus-low-score-mark)
7859 gnus-newsgroup-reads)))
7861 ;; Do the `display' group parameter.
7862 (and gnus-newsgroup-display
7863 (not (funcall gnus-newsgroup-display)))
7864 ;; Check NoCeM things.
7865 (if (and gnus-use-nocem
7866 (gnus-nocem-unwanted-article-p
7867 (mail-header-id (car thread))))
7869 (setq gnus-newsgroup-unreads
7870 (delq number gnus-newsgroup-unreads))
7872 ;; Nope, invisible article.
7874 ;; Ok, this article is to be visible, so we add it to the limit
7876 (push number gnus-newsgroup-limit)
7879 (defun gnus-expunge-thread (thread)
7880 "Mark all articles in THREAD as read."
7881 (let* ((number (mail-header-number (car thread))))
7882 (incf gnus-newsgroup-expunged-tally)
7883 ;; We also mark as read here, if that's wanted.
7884 (setq gnus-newsgroup-unreads
7885 (delq number gnus-newsgroup-unreads))
7886 (if gnus-newsgroup-auto-expire
7887 (push number gnus-newsgroup-expirable)
7888 (push (cons number gnus-low-score-mark)
7889 gnus-newsgroup-reads)))
7890 ;; Go recursively through all subthreads.
7891 (mapcar 'gnus-expunge-thread (cdr thread)))
7893 ;; Summary article oriented commands
7895 (defun gnus-summary-refer-parent-article (n)
7896 "Refer parent article N times.
7897 If N is negative, go to ancestor -N instead.
7898 The difference between N and the number of articles fetched is returned."
7902 (when (not (natnump n))
7907 (setq header (gnus-summary-article-header))
7908 (if (and (eq (mail-header-number header)
7909 (cdr gnus-article-current))
7910 (equal gnus-newsgroup-name
7911 (car gnus-article-current)))
7912 ;; If we try to find the parent of the currently
7913 ;; displayed article, then we take a look at the actual
7914 ;; References header, since this is slightly more
7915 ;; reliable than the References field we got from the
7918 (set-buffer gnus-original-article-buffer)
7919 (nnheader-narrow-to-headers)
7920 (unless (setq ref (message-fetch-field "references"))
7921 (setq ref (message-fetch-field "in-reply-to")))
7924 ;; It's not the current article, so we take a bet on
7925 ;; the value we got from the server.
7926 (mail-header-references header)))
7928 (not (equal ref "")))
7929 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7930 (gnus-message 1 "Couldn't find parent"))
7931 (gnus-message 1 "No references in article %d"
7932 (gnus-summary-article-number))
7935 (gnus-summary-position-point)
7938 (defun gnus-summary-refer-references ()
7939 "Fetch all articles mentioned in the References header.
7940 Return the number of articles fetched."
7942 (let ((ref (mail-header-references (gnus-summary-article-header)))
7943 (current (gnus-summary-article-number))
7947 (error "No References in the current article")
7948 ;; For each Message-ID in the References header...
7949 (while (string-match "<[^>]*>" ref)
7951 ;; ... fetch that article.
7952 (gnus-summary-refer-article
7953 (prog1 (match-string 0 ref)
7954 (setq ref (substring ref (match-end 0))))))
7955 (gnus-summary-goto-subject current)
7956 (gnus-summary-position-point)
7959 (defun gnus-summary-refer-thread (&optional limit)
7960 "Fetch all articles in the current thread.
7961 If LIMIT (the numerical prefix), fetch that many old headers instead
7962 of what's specified by the `gnus-refer-thread-limit' variable."
7964 (let ((id (mail-header-id (gnus-summary-article-header)))
7965 (limit (if limit (prefix-numeric-value limit)
7966 gnus-refer-thread-limit)))
7967 (unless (eq gnus-fetch-old-headers 'invisible)
7968 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7969 ;; Retrieve the headers and read them in.
7970 (if (eq (if (numberp limit)
7971 (gnus-retrieve-headers
7973 (+ (mail-header-number
7974 (gnus-summary-article-header))
7976 gnus-newsgroup-end))
7977 gnus-newsgroup-name (* limit 2))
7978 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
7980 (gnus-retrieve-headers (list gnus-newsgroup-end)
7981 gnus-newsgroup-name limit))
7983 (gnus-build-all-threads)
7984 (error "Can't fetch thread from backends that don't support NOV"))
7985 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7986 (gnus-summary-limit-include-thread id)))
7988 (defun gnus-summary-refer-article (message-id)
7989 "Fetch an article specified by MESSAGE-ID."
7990 (interactive "sMessage-ID: ")
7991 (when (and (stringp message-id)
7992 (not (zerop (length message-id))))
7993 ;; Construct the correct Message-ID if necessary.
7994 ;; Suggested by tale@pawl.rpi.edu.
7995 (unless (string-match "^<" message-id)
7996 (setq message-id (concat "<" message-id)))
7997 (unless (string-match ">$" message-id)
7998 (setq message-id (concat message-id ">")))
7999 (let* ((header (gnus-id-to-header message-id))
8001 (gnus-summary-article-sparse-p
8002 (mail-header-number header))
8003 (memq (mail-header-number header)
8004 gnus-newsgroup-limit)))
8007 ;; If the article is present in the buffer we just go to it.
8009 (or (not (gnus-summary-article-sparse-p
8010 (mail-header-number header)))
8013 (gnus-summary-goto-article
8014 (mail-header-number header) nil t)
8016 (gnus-summary-update-article (mail-header-number header)))))
8018 ;; We fetch the article.
8020 (dolist (gnus-override-method (gnus-refer-article-methods))
8021 (when (and (gnus-check-server gnus-override-method)
8022 ;; Fetch the header,
8023 (setq number (gnus-summary-insert-subject message-id)))
8024 ;; and display the article.
8025 (gnus-summary-select-article nil nil nil number)
8027 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8029 (defun gnus-refer-article-methods ()
8030 "Return a list of referable methods."
8032 ;; No method, so we default to current and native.
8033 ((null gnus-refer-article-method)
8034 (list gnus-current-select-method gnus-select-method))
8036 ((eq 'current gnus-refer-article-method)
8037 (list gnus-current-select-method))
8038 ;; List of select methods.
8039 ((not (and (symbolp (car gnus-refer-article-method))
8040 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8042 (dolist (method gnus-refer-article-method)
8043 (push (if (eq 'current method)
8044 gnus-current-select-method
8048 ;; One single select method.
8050 (list gnus-refer-article-method))))
8052 (defun gnus-summary-edit-parameters ()
8053 "Edit the group parameters of the current group."
8055 (gnus-group-edit-group gnus-newsgroup-name 'params))
8057 (defun gnus-summary-customize-parameters ()
8058 "Customize the group parameters of the current group."
8060 (gnus-group-customize gnus-newsgroup-name))
8062 (defun gnus-summary-enter-digest-group (&optional force)
8063 "Enter an nndoc group based on the current article.
8064 If FORCE, force a digest interpretation. If not, try
8065 to guess what the document format is."
8067 (let ((conf gnus-current-window-configuration))
8069 (gnus-summary-select-article))
8070 (setq gnus-current-window-configuration conf)
8071 (let* ((name (format "%s-%d"
8072 (gnus-group-prefixed-name
8073 gnus-newsgroup-name (list 'nndoc ""))
8075 (set-buffer gnus-summary-buffer)
8076 gnus-current-article)))
8077 (ogroup gnus-newsgroup-name)
8078 (params (append (gnus-info-params (gnus-get-info ogroup))
8079 (list (cons 'to-group ogroup))
8080 (list (cons 'save-article-group ogroup))))
8081 (case-fold-search t)
8082 (buf (current-buffer))
8085 (set-buffer gnus-original-article-buffer)
8086 ;; Have the digest group inherit the main mail address of
8087 ;; the parent article.
8088 (when (setq to-address (or (gnus-fetch-field "reply-to")
8089 (gnus-fetch-field "from")))
8090 (setq params (append
8091 (list (cons 'to-address
8092 (funcall gnus-decode-encoded-word-function
8094 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8095 (insert-buffer-substring gnus-original-article-buffer)
8096 ;; Remove lines that may lead nndoc to misinterpret the
8099 (goto-char (point-min))
8100 (or (search-forward "\n\n" nil t) (point)))
8101 (goto-char (point-min))
8102 (delete-matching-lines "^Path:\\|^From ")
8105 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8106 (gnus-newsgroup-ephemeral-ignored-charsets
8107 gnus-newsgroup-ignored-charsets))
8108 (gnus-group-read-ephemeral-group
8109 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8111 ,(if force 'mbox 'guess)))
8113 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8115 ;; Make all postings to this group go to the parent group.
8116 (nconc (gnus-info-params (gnus-get-info name))
8118 ;; Couldn't select this doc group.
8119 (switch-to-buffer buf)
8120 (gnus-set-global-variables)
8121 (gnus-configure-windows 'summary)
8122 (gnus-message 3 "Article couldn't be entered?"))
8123 (kill-buffer dig)))))
8125 (defun gnus-summary-read-document (n)
8126 "Open a new group based on the current article(s).
8127 This will allow you to read digests and other similar
8128 documents as newsgroups.
8129 Obeys the standard process/prefix convention."
8131 (let* ((articles (gnus-summary-work-articles n))
8132 (ogroup gnus-newsgroup-name)
8133 (params (append (gnus-info-params (gnus-get-info ogroup))
8134 (list (cons 'to-group ogroup))))
8135 article group egroup groups vgroup)
8136 (while (setq article (pop articles))
8137 (setq group (format "%s-%d" gnus-newsgroup-name article))
8138 (gnus-summary-remove-process-mark article)
8139 (when (gnus-summary-display-article article)
8142 (insert-buffer-substring gnus-original-article-buffer)
8143 ;; Remove some headers that may lead nndoc to make
8145 (message-narrow-to-head)
8146 (goto-char (point-min))
8147 (delete-matching-lines "^\\(Path\\):\\|^From ")
8150 (gnus-group-read-ephemeral-group
8151 group `(nndoc ,group (nndoc-address ,(current-buffer))
8152 (nndoc-article-type guess))
8155 ;; Make all postings to this group go to the parent group.
8156 (nconc (gnus-info-params (gnus-get-info egroup))
8158 (push egroup groups))
8159 ;; Couldn't select this doc group.
8160 (gnus-error 3 "Article couldn't be entered"))))))
8161 ;; Now we have selected all the documents.
8164 (error "None of the articles could be interpreted as documents"))
8165 ((gnus-group-read-ephemeral-group
8166 (setq vgroup (format
8167 "nnvirtual:%s-%s" gnus-newsgroup-name
8168 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8169 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8171 (cons (current-buffer) 'summary)))
8173 (error "Couldn't select virtual nndoc group")))))
8175 (defun gnus-summary-isearch-article (&optional regexp-p)
8176 "Do incremental search forward on the current article.
8177 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8179 (gnus-summary-select-article)
8180 (gnus-configure-windows 'article)
8181 (gnus-eval-in-buffer-window gnus-article-buffer
8184 (isearch-forward regexp-p))))
8186 (defun gnus-summary-search-article-forward (regexp &optional backward)
8187 "Search for an article containing REGEXP forward.
8188 If BACKWARD, search backward instead."
8191 (format "Search article %s (regexp%s): "
8192 (if current-prefix-arg "backward" "forward")
8193 (if gnus-last-search-regexp
8194 (concat ", default " gnus-last-search-regexp)
8196 current-prefix-arg))
8197 (if (string-equal regexp "")
8198 (setq regexp (or gnus-last-search-regexp ""))
8199 (setq gnus-last-search-regexp regexp)
8200 (setq gnus-article-before-search gnus-current-article))
8201 ;; Intentionally set gnus-last-article.
8202 (setq gnus-last-article gnus-article-before-search)
8203 (let ((gnus-last-article gnus-last-article))
8204 (if (gnus-summary-search-article regexp backward)
8205 (gnus-summary-show-thread)
8206 (error "Search failed: \"%s\"" regexp))))
8208 (defun gnus-summary-search-article-backward (regexp)
8209 "Search for an article containing REGEXP backward."
8212 (format "Search article backward (regexp%s): "
8213 (if gnus-last-search-regexp
8214 (concat ", default " gnus-last-search-regexp)
8216 (gnus-summary-search-article-forward regexp 'backward))
8218 (defun gnus-summary-search-article (regexp &optional backward)
8219 "Search for an article containing REGEXP.
8220 Optional argument BACKWARD means do search for backward.
8221 `gnus-select-article-hook' is not called during the search."
8222 ;; We have to require this here to make sure that the following
8223 ;; dynamic binding isn't shadowed by autoloading.
8224 (require 'gnus-async)
8226 (let ((gnus-select-article-hook nil) ;Disable hook.
8227 (gnus-article-prepare-hook nil)
8228 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8229 (gnus-use-article-prefetch nil)
8230 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8231 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8233 (gnus-keep-backlog nil)
8234 (gnus-break-pages nil)
8235 (gnus-summary-display-arrow nil)
8236 (gnus-updated-mode-lines nil)
8237 (gnus-auto-center-summary nil)
8238 (sum (current-buffer))
8239 (gnus-display-mime-function nil)
8242 (gnus-save-hidden-threads
8243 (gnus-summary-select-article)
8244 (set-buffer gnus-article-buffer)
8245 (goto-char (window-point (get-buffer-window (current-buffer))))
8249 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8251 (re-search-backward regexp nil t)
8252 (re-search-forward regexp nil t))
8253 ;; We found the regexp.
8258 (get-buffer-window (current-buffer))
8262 (get-buffer-window (current-buffer))
8265 (setq point (point)))
8266 ;; We didn't find it, so we go to the next article.
8269 (while (eq found 'not)
8270 (if (not (if backward (gnus-summary-find-prev)
8271 (gnus-summary-find-next)))
8272 ;; No more articles.
8274 ;; Select the next article and adjust point.
8275 (unless (gnus-summary-article-sparse-p
8276 (gnus-summary-article-number))
8278 (gnus-summary-select-article)
8279 (set-buffer gnus-article-buffer)
8281 (goto-char (if backward (point-max) (point-min))))))))
8282 (gnus-message 7 ""))
8283 ;; Return whether we found the regexp.
8284 (when (eq found 'found)
8286 (gnus-summary-show-thread)
8287 (gnus-summary-goto-subject gnus-current-article)
8288 (gnus-summary-position-point)
8291 (defun gnus-find-matching-articles (header regexp)
8292 "Return a list of all articles that match REGEXP on HEADER.
8293 This search includes all articles in the current group that Gnus has
8294 fetched headers for, whether they are displayed or not."
8295 (let ((articles nil)
8296 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8297 (case-fold-search t))
8298 (dolist (header gnus-newsgroup-headers)
8299 (when (string-match regexp (funcall func header))
8300 (push (mail-header-number header) articles)))
8301 (nreverse articles)))
8303 (defun gnus-summary-find-matching (header regexp &optional backward unread
8304 not-case-fold not-matching)
8305 "Return a list of all articles that match REGEXP on HEADER.
8306 The search stars on the current article and goes forwards unless
8307 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8308 If UNREAD is non-nil, only unread articles will
8309 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8310 in the comparisons. If NOT-MATCHING, return a list of all articles that
8311 not match REGEXP on HEADER."
8312 (let ((case-fold-search (not not-case-fold))
8315 (if (eq (car header) 'extra)
8318 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8320 (error "%s is an invalid header" header))
8321 (unless (fboundp (intern (concat "mail-header-" header)))
8322 (error "%s is not a valid header" header))
8323 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8324 (dolist (d (if (eq backward 'all)
8326 (gnus-data-find-list
8327 (gnus-summary-article-number)
8328 (gnus-data-list backward))))
8329 (when (and (or (not unread) ; We want all articles...
8330 (gnus-data-unread-p d)) ; Or just unreads.
8331 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8335 (funcall func (gnus-data-header d))))
8336 (string-match regexp
8337 (funcall func (gnus-data-header d)))))
8338 (push (gnus-data-number d) articles))) ; Success!
8339 (nreverse articles)))
8341 (defun gnus-summary-execute-command (header regexp command &optional backward)
8342 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8343 If HEADER is an empty string (or nil), the match is done on the entire
8344 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8346 (list (let ((completion-ignore-case t))
8349 (mapcar (lambda (header) (list (format "%s" header)))
8351 '("Number" "Subject" "From" "Lines" "Date"
8352 "Message-ID" "Xref" "References" "Body")
8353 gnus-extra-headers))
8354 nil 'require-match))
8355 (read-string "Regexp: ")
8356 (read-key-sequence "Command: ")
8357 current-prefix-arg))
8358 (when (equal header "Body")
8360 ;; Hidden thread subtrees must be searched as well.
8361 (gnus-summary-show-all-threads)
8362 ;; We don't want to change current point nor window configuration.
8364 (save-window-excursion
8366 gnus-treat-strip-trailing-blank-lines
8367 gnus-treat-strip-leading-blank-lines
8368 gnus-treat-strip-multiple-blank-lines
8369 gnus-treat-hide-boring-headers
8370 gnus-treat-fold-newsgroups
8371 gnus-article-prepare-hook)
8372 (gnus-message 6 "Executing %s..." (key-description command))
8373 ;; We'd like to execute COMMAND interactively so as to give arguments.
8374 (gnus-execute header regexp
8375 `(call-interactively ',(key-binding command))
8377 (gnus-message 6 "Executing %s...done" (key-description command))))))
8379 (defun gnus-summary-beginning-of-article ()
8380 "Scroll the article back to the beginning."
8382 (gnus-summary-select-article)
8383 (gnus-configure-windows 'article)
8384 (gnus-eval-in-buffer-window gnus-article-buffer
8386 (goto-char (point-min))
8387 (when gnus-page-broken
8388 (gnus-narrow-to-page))))
8390 (defun gnus-summary-end-of-article ()
8391 "Scroll to the end of the article."
8393 (gnus-summary-select-article)
8394 (gnus-configure-windows 'article)
8395 (gnus-eval-in-buffer-window gnus-article-buffer
8397 (goto-char (point-max))
8399 (when gnus-page-broken
8400 (gnus-narrow-to-page))))
8402 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8403 "Truncate to LEN and quote all \"(\"'s in STRING."
8404 (gnus-replace-in-string (if (and len (> (length string) len))
8405 (substring string 0 len)
8409 (defun gnus-summary-print-article (&optional filename n)
8410 "Generate and print a PostScript image of the N next (mail) articles.
8412 If N is negative, print the N previous articles. If N is nil and articles
8413 have been marked with the process mark, print these instead.
8415 If the optional first argument FILENAME is nil, send the image to the
8416 printer. If FILENAME is a string, save the PostScript image in a file with
8417 that name. If FILENAME is a number, prompt the user for the name of the file
8419 (interactive (list (ps-print-preprint current-prefix-arg)))
8420 (dolist (article (gnus-summary-work-articles n))
8421 (gnus-summary-select-article nil nil 'pseudo article)
8422 (gnus-eval-in-buffer-window gnus-article-buffer
8423 (gnus-print-buffer))
8424 (gnus-summary-remove-process-mark article))
8425 (ps-despool filename))
8427 (defun gnus-print-buffer ()
8428 (let ((buffer (generate-new-buffer " *print*")))
8431 (copy-to-buffer buffer (point-min) (point-max))
8433 (gnus-article-delete-invisible-text)
8434 (gnus-remove-text-with-property 'gnus-decoration)
8435 (when (gnus-visual-p 'article-highlight 'highlight)
8436 ;; Copy-to-buffer doesn't copy overlay. So redo
8438 (let ((gnus-article-buffer buffer))
8439 (gnus-article-highlight-citation t)
8440 (gnus-article-highlight-signature)))
8441 (let ((ps-left-header
8444 (gnus-summary-print-truncate-and-quote
8445 (mail-header-subject gnus-current-headers)
8448 (gnus-summary-print-truncate-and-quote
8449 (mail-header-from gnus-current-headers)
8453 "/pagenumberstring load"
8455 (mail-header-date gnus-current-headers) ")"))))
8456 (gnus-run-hooks 'gnus-ps-print-hook)
8459 (ps-spool-buffer-with-faces)
8460 (ps-spool-buffer)))))
8461 (kill-buffer buffer))))
8463 (defun gnus-summary-show-article (&optional arg)
8464 "Force redisplaying of the current article.
8465 If ARG (the prefix) is a number, show the article with the charset
8466 defined in `gnus-summary-show-article-charset-alist', or the charset
8468 If ARG (the prefix) is non-nil and not a number, show the raw article
8469 without any article massaging functions being run. Normally, the key strokes
8474 (gnus-summary-show-article t)
8475 (let ((gnus-newsgroup-charset
8476 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8477 (mm-read-coding-system
8478 "View as charset: " ;; actually it is coding system.
8480 (set-buffer gnus-article-buffer)
8481 (mm-detect-coding-region (point) (point-max))))))
8482 (gnus-newsgroup-ignored-charsets 'gnus-all))
8483 (gnus-summary-select-article nil 'force)
8484 (let ((deps gnus-newsgroup-dependencies)
8487 (set-buffer gnus-original-article-buffer)
8489 (message-narrow-to-head)
8490 (setq head (buffer-string))
8491 (goto-char (point-min))
8492 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8493 (goto-char (point-max))
8495 (setq lines (1- (count-lines (point) (point-max))))))
8497 (insert (format "211 %d Article retrieved.\n"
8498 (cdr gnus-article-current)))
8500 (if lines (insert (format "Lines: %d\n" lines)))
8502 (let ((nntp-server-buffer (current-buffer)))
8503 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8504 (gnus-data-set-header
8505 (gnus-data-find (cdr gnus-article-current))
8507 (gnus-summary-update-article-line
8508 (cdr gnus-article-current) header)
8509 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8510 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8512 ;; Select the article the normal way.
8513 (gnus-summary-select-article nil 'force))
8515 ;; We have to require this here to make sure that the following
8516 ;; dynamic binding isn't shadowed by autoloading.
8517 (require 'gnus-async)
8519 ;; Bind the article treatment functions to nil.
8520 (let ((gnus-have-all-headers t)
8521 gnus-article-prepare-hook
8522 gnus-article-decode-hook
8523 gnus-display-mime-function
8525 ;; Destroy any MIME parts.
8526 (when (gnus-buffer-live-p gnus-article-buffer)
8528 (set-buffer gnus-article-buffer)
8529 (mm-destroy-parts gnus-article-mime-handles)
8530 ;; Set it to nil for safety reason.
8531 (setq gnus-article-mime-handle-alist nil)
8532 (setq gnus-article-mime-handles nil)))
8533 (gnus-summary-select-article nil 'force))))
8534 (gnus-summary-goto-subject gnus-current-article)
8535 (gnus-summary-position-point))
8537 (defun gnus-summary-show-raw-article ()
8538 "Show the raw article without any article massaging functions being run."
8540 (gnus-summary-show-article t))
8542 (defun gnus-summary-verbose-headers (&optional arg)
8543 "Toggle permanent full header display.
8544 If ARG is a positive number, turn header display on.
8545 If ARG is a negative number, turn header display off."
8547 (setq gnus-show-all-headers
8548 (cond ((or (not (numberp arg))
8550 (not gnus-show-all-headers))
8553 (gnus-summary-show-article))
8555 (defun gnus-summary-toggle-header (&optional arg)
8556 "Show the headers if they are hidden, or hide them if they are shown.
8557 If ARG is a positive number, show the entire header.
8558 If ARG is a negative number, hide the unwanted header lines."
8560 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8561 (get-buffer-window gnus-article-buffer t))))
8562 (with-current-buffer gnus-article-buffer
8564 (article-narrow-to-head)
8565 (let* ((buffer-read-only nil)
8566 (inhibit-point-motion-hooks t)
8567 (hidden (if (numberp arg)
8569 (gnus-article-hidden-text-p 'headers)))
8571 (delete-region (point-min) (point-max))
8572 (with-current-buffer gnus-original-article-buffer
8573 (goto-char (setq s (point-min)))
8574 (setq e (if (search-forward "\n\n" nil t)
8577 (insert-buffer-substring gnus-original-article-buffer s e)
8578 (run-hooks 'gnus-article-decode-hook)
8580 (let ((gnus-treat-hide-headers nil)
8581 (gnus-treat-hide-boring-headers nil))
8582 (gnus-delete-wash-type 'headers)
8583 (gnus-treat-article 'head))
8584 (gnus-treat-article 'head))
8587 (set-window-start window (goto-char (point-min))))
8588 (setq gnus-page-broken
8589 (when gnus-break-pages
8590 (gnus-narrow-to-page)
8592 (gnus-set-mode-line 'article)))))
8594 (defun gnus-summary-show-all-headers ()
8595 "Make all header lines visible."
8597 (gnus-summary-toggle-header 1))
8599 (defun gnus-summary-caesar-message (&optional arg)
8600 "Caesar rotate the current article by 13.
8601 The numerical prefix specifies how many places to rotate each letter
8604 (gnus-summary-select-article)
8605 (let ((mail-header-separator ""))
8606 (gnus-eval-in-buffer-window gnus-article-buffer
8609 (let ((start (window-start))
8611 (message-caesar-buffer-body arg)
8612 (set-window-start (get-buffer-window (current-buffer)) start))))))
8614 (autoload 'unmorse-region "morse"
8615 "Convert morse coded text in region to ordinary ASCII text."
8618 (defun gnus-summary-morse-message (&optional arg)
8619 "Morse decode the current article."
8621 (gnus-summary-select-article)
8622 (let ((mail-header-separator ""))
8623 (gnus-eval-in-buffer-window gnus-article-buffer
8627 (let ((pos (window-start))
8629 (goto-char (point-min))
8630 (when (message-goto-body)
8631 (gnus-narrow-to-body))
8632 (goto-char (point-min))
8633 (while (re-search-forward "·" (point-max) t)
8634 (replace-match "."))
8635 (unmorse-region (point-min) (point-max))
8637 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8639 (defun gnus-summary-stop-page-breaking ()
8640 "Stop page breaking in the current article."
8642 (gnus-summary-select-article)
8643 (gnus-eval-in-buffer-window gnus-article-buffer
8645 (when (gnus-visual-p 'page-marker)
8646 (let ((buffer-read-only nil))
8647 (gnus-remove-text-with-property 'gnus-prev)
8648 (gnus-remove-text-with-property 'gnus-next))
8649 (setq gnus-page-broken nil))))
8651 (defun gnus-summary-move-article (&optional n to-newsgroup
8652 select-method action)
8653 "Move the current article to a different newsgroup.
8654 If N is a positive number, move the N next articles.
8655 If N is a negative number, move the N previous articles.
8656 If N is nil and any articles have been marked with the process mark,
8657 move those articles instead.
8658 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8659 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8660 re-spool using this method.
8662 When called interactively with TO-NEWSGROUP being nil, the value of
8663 the variable `gnus-move-split-methods' is used for finding a default
8664 for the target newsgroup.
8666 For this function to work, both the current newsgroup and the
8667 newsgroup that you want to move to have to support the `request-move'
8668 and `request-accept' functions.
8670 ACTION can be either `move' (the default), `crosspost' or `copy'."
8673 (setq action 'move))
8674 ;; Check whether the source group supports the required functions.
8675 (cond ((and (eq action 'move)
8676 (not (gnus-check-backend-function
8677 'request-move-article gnus-newsgroup-name)))
8678 (error "The current group does not support article moving"))
8679 ((and (eq action 'crosspost)
8680 (not (gnus-check-backend-function
8681 'request-replace-article gnus-newsgroup-name)))
8682 (error "The current group does not support article editing")))
8683 (let ((articles (gnus-summary-work-articles n))
8684 (prefix (if (gnus-check-backend-function
8685 'request-move-article gnus-newsgroup-name)
8686 (gnus-group-real-prefix gnus-newsgroup-name)
8688 (names '((move "Move" "Moving")
8689 (copy "Copy" "Copying")
8690 (crosspost "Crosspost" "Crossposting")))
8691 (copy-buf (save-excursion
8692 (nnheader-set-temp-buffer " *copy article*")))
8693 art-group to-method new-xref article to-groups)
8694 (unless (assq action names)
8695 (error "Unknown action %s" action))
8696 ;; Read the newsgroup name.
8697 (when (and (not to-newsgroup)
8698 (not select-method))
8699 (if (and gnus-move-split-methods
8701 (and (memq gnus-current-article articles)
8702 (gnus-buffer-live-p gnus-original-article-buffer))))
8703 ;; When `gnus-move-split-methods' is non-nil, we have to
8704 ;; select an article to give `gnus-read-move-group-name' an
8705 ;; opportunity to suggest an appropriate default. However,
8706 ;; we needn't render or mark the article.
8707 (let ((gnus-display-mime-function nil)
8708 (gnus-article-prepare-hook nil)
8709 (gnus-mark-article-hook nil))
8710 (gnus-summary-select-article nil nil nil (car articles))))
8712 (gnus-read-move-group-name
8713 (cadr (assq action names))
8714 (symbol-value (intern (format "gnus-current-%s-group" action)))
8716 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8717 (setq to-method (or select-method
8718 (gnus-server-to-method
8719 (gnus-group-method to-newsgroup))))
8720 ;; Check the method we are to move this article to...
8721 (unless (gnus-check-backend-function
8722 'request-accept-article (car to-method))
8723 (error "%s does not support article copying" (car to-method)))
8724 (unless (gnus-check-server to-method)
8725 (error "Can't open server %s" (car to-method)))
8726 (gnus-message 6 "%s to %s: %s..."
8727 (caddr (assq action names))
8728 (or (car select-method) to-newsgroup) articles)
8730 (setq article (pop articles))
8734 ;; Move the article.
8736 ;; Remove this article from future suppression.
8737 (gnus-dup-unsuppress-article article)
8738 (gnus-request-move-article
8739 article ; Article to move
8740 gnus-newsgroup-name ; From newsgroup
8741 (nth 1 (gnus-find-method-for-group
8742 gnus-newsgroup-name)) ; Server
8743 (list 'gnus-request-accept-article
8744 to-newsgroup (list 'quote select-method)
8745 (not articles) t) ; Accept form
8746 (not articles))) ; Only save nov last time
8747 ;; Copy the article.
8750 (set-buffer copy-buf)
8751 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8752 (gnus-request-accept-article
8753 to-newsgroup select-method (not articles) t))))
8754 ;; Crosspost the article.
8755 ((eq action 'crosspost)
8756 (let ((xref (message-tokenize-header
8757 (mail-header-xref (gnus-summary-article-header article))
8759 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8760 ":" (number-to-string article)))
8762 (setq xref (list (system-name))))
8765 (mapconcat 'identity
8766 (delete "Xref:" (delete new-xref xref))
8770 (set-buffer copy-buf)
8771 ;; First put the article in the destination group.
8772 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8773 (when (consp (setq art-group
8774 (gnus-request-accept-article
8775 to-newsgroup select-method (not articles))))
8776 (setq new-xref (concat new-xref " " (car art-group)
8778 (number-to-string (cdr art-group))))
8779 ;; Now we have the new Xrefs header, so we insert
8780 ;; it and replace the new article.
8781 (nnheader-replace-header "Xref" new-xref)
8782 (gnus-request-replace-article
8783 (cdr art-group) to-newsgroup (current-buffer))
8787 (gnus-message 1 "Couldn't %s article %s: %s"
8788 (cadr (assq action names)) article
8789 (nnheader-get-report (car to-method))))
8790 ((eq art-group 'junk)
8791 (when (eq action 'move)
8792 (gnus-summary-mark-article article gnus-canceled-mark)
8793 (gnus-message 4 "Deleted article %s" article)
8794 ;; run the delete hook
8795 (run-hook-with-args 'gnus-summary-article-delete-hook
8798 (assoc article (gnus-data-list nil)))
8799 gnus-newsgroup-name nil
8802 (let* ((pto-group (gnus-group-prefixed-name
8803 (car art-group) to-method))
8805 (gnus-gethash pto-group gnus-newsrc-hashtb))
8806 (info (nth 2 entry))
8807 (to-group (gnus-info-group info))
8809 ;; Update the group that has been moved to.
8811 (memq action '(move copy)))
8812 (unless (member to-group to-groups)
8813 (push to-group to-groups))
8815 (unless (memq article gnus-newsgroup-unreads)
8816 (push 'read to-marks)
8818 info (gnus-add-to-range (gnus-info-read info)
8819 (list (cdr art-group)))))
8821 ;; See whether the article is to be put in the cache.
8822 (let ((marks gnus-article-mark-lists)
8823 (to-article (cdr art-group)))
8825 ;; Enter the article into the cache in the new group,
8826 ;; if that is required.
8827 (when gnus-use-cache
8828 (gnus-cache-possibly-enter-article
8830 (memq article gnus-newsgroup-marked)
8831 (memq article gnus-newsgroup-dormant)
8832 (memq article gnus-newsgroup-unreads)))
8834 (when gnus-preserve-marks
8835 ;; Copy any marks over to the new group.
8836 (when (and (equal to-group gnus-newsgroup-name)
8837 (not (memq article gnus-newsgroup-unreads)))
8838 ;; Mark this article as read in this group.
8839 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8840 (setcdr (gnus-active to-group) to-article)
8841 (setcdr gnus-newsgroup-active to-article))
8844 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8845 (when (memq article (symbol-value
8846 (intern (format "gnus-newsgroup-%s"
8848 (push (cdar marks) to-marks)
8849 ;; If the other group is the same as this group,
8850 ;; then we have to add the mark to the list.
8851 (when (equal to-group gnus-newsgroup-name)
8852 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8855 (intern (format "gnus-newsgroup-%s"
8857 ;; Copy the marks to other group.
8858 (gnus-add-marked-articles
8859 to-group (cdar marks) (list to-article) info)))
8860 (setq marks (cdr marks)))
8862 (gnus-request-set-mark
8863 to-group (list (list (list to-article) 'add to-marks))))
8866 (concat "(gnus-group-set-info '"
8867 (gnus-prin1-to-string (gnus-get-info to-group))
8870 ;; Update the Xref header in this article to point to
8871 ;; the new crossposted article we have just created.
8872 (when (eq action 'crosspost)
8874 (set-buffer copy-buf)
8875 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8876 (nnheader-replace-header "Xref" new-xref)
8877 (gnus-request-replace-article
8878 article gnus-newsgroup-name (current-buffer))))
8880 ;; run the move/copy/crosspost/respool hook
8881 (run-hook-with-args 'gnus-summary-article-move-hook
8884 (assoc article (gnus-data-list nil)))
8889 ;;;!!!Why is this necessary?
8890 (set-buffer gnus-summary-buffer)
8892 (gnus-summary-goto-subject article)
8893 (when (eq action 'move)
8894 (gnus-summary-mark-article article gnus-canceled-mark))))
8895 (gnus-summary-remove-process-mark article))
8896 ;; Re-activate all groups that have been moved to.
8898 (set-buffer gnus-group-buffer)
8899 (let ((gnus-group-marked to-groups))
8900 (gnus-group-get-new-news-this-group nil t)))
8902 (gnus-kill-buffer copy-buf)
8903 (gnus-summary-position-point)
8904 (gnus-set-mode-line 'summary)))
8906 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8907 "Move the current article to a different newsgroup.
8908 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8909 When called interactively, if TO-NEWSGROUP is nil, use the value of
8910 the variable `gnus-move-split-methods' for finding a default target
8912 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8913 re-spool using this method."
8915 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8917 (defun gnus-summary-crosspost-article (&optional n)
8918 "Crosspost the current article to some other group."
8920 (gnus-summary-move-article n nil nil 'crosspost))
8922 (defcustom gnus-summary-respool-default-method nil
8923 "Default method type for respooling an article.
8924 If nil, use to the current newsgroup method."
8926 :group 'gnus-summary-mail)
8928 (defcustom gnus-summary-display-while-building nil
8929 "If not-nil, show and update the summary buffer as it's being built.
8930 If the value is t, update the buffer after every line is inserted. If
8931 the value is an integer (N), update the display every N lines."
8933 :type '(choice (const :tag "off" nil)
8935 (const :tag "frequently" t)))
8937 (defun gnus-summary-respool-article (&optional n method)
8938 "Respool the current article.
8939 The article will be squeezed through the mail spooling process again,
8940 which means that it will be put in some mail newsgroup or other
8941 depending on `nnmail-split-methods'.
8942 If N is a positive number, respool the N next articles.
8943 If N is a negative number, respool the N previous articles.
8944 If N is nil and any articles have been marked with the process mark,
8945 respool those articles instead.
8947 Respooling can be done both from mail groups and \"real\" newsgroups.
8948 In the former case, the articles in question will be moved from the
8949 current group into whatever groups they are destined to. In the
8950 latter case, they will be copied into the relevant groups."
8952 (list current-prefix-arg
8953 (let* ((methods (gnus-methods-using 'respool))
8955 (symbol-name (or gnus-summary-respool-default-method
8956 (car (gnus-find-method-for-group
8957 gnus-newsgroup-name)))))
8959 (gnus-completing-read-with-default
8960 methname "What backend do you want to use when respooling?"
8961 methods nil t nil 'gnus-mail-method-history))
8964 ((zerop (length (setq ms (gnus-servers-using-backend
8966 (list (intern method) ""))
8970 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8971 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8974 (error "No method given for respooling"))
8975 (if (assoc (symbol-name
8976 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8977 (gnus-methods-using 'respool))
8978 (gnus-summary-move-article n nil method)
8979 (gnus-summary-copy-article n nil method)))
8981 (defun gnus-summary-import-article (file &optional edit)
8982 "Import an arbitrary file into a mail newsgroup."
8983 (interactive "fImport file: \nP")
8984 (let ((group gnus-newsgroup-name)
8985 (now (current-time))
8986 atts lines group-art)
8987 (unless (gnus-check-backend-function 'request-accept-article group)
8988 (error "%s does not support article importing" group))
8989 (or (file-readable-p file)
8990 (not (file-regular-p file))
8991 (error "Can't read %s" file))
8993 (set-buffer (gnus-get-buffer-create " *import file*"))
8995 (nnheader-insert-file-contents file)
8996 (goto-char (point-min))
8997 (if (nnheader-article-p)
8999 (goto-char (point-min))
9000 (search-forward "\n\n" nil t)
9001 (narrow-to-region (point-min) (1- (point)))
9002 (goto-char (point-min))
9003 (unless (re-search-forward "^date:" nil t)
9004 (goto-char (point-max))
9005 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9006 ;; This doesn't look like an article, so we fudge some headers.
9007 (setq atts (file-attributes file)
9008 lines (count-lines (point-min) (point-max)))
9009 (insert "From: " (read-string "From: ") "\n"
9010 "Subject: " (read-string "Subject: ") "\n"
9011 "Date: " (message-make-date (nth 5 atts)) "\n"
9012 "Message-ID: " (message-make-message-id) "\n"
9013 "Lines: " (int-to-string lines) "\n"
9014 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9015 (setq group-art (gnus-request-accept-article group nil t))
9016 (kill-buffer (current-buffer)))
9017 (setq gnus-newsgroup-active (gnus-activate-group group))
9019 (gnus-summary-goto-article (cdr group-art) nil t)
9021 (gnus-summary-edit-article))))
9023 (defun gnus-summary-create-article ()
9024 "Create an article in a mail newsgroup."
9026 (let ((group gnus-newsgroup-name)
9027 (now (current-time))
9029 (unless (gnus-check-backend-function 'request-accept-article group)
9030 (error "%s does not support article importing" group))
9032 (set-buffer (gnus-get-buffer-create " *import file*"))
9034 (goto-char (point-min))
9035 ;; This doesn't look like an article, so we fudge some headers.
9036 (insert "From: " (read-string "From: ") "\n"
9037 "Subject: " (read-string "Subject: ") "\n"
9038 "Date: " (message-make-date now) "\n"
9039 "Message-ID: " (message-make-message-id) "\n")
9040 (setq group-art (gnus-request-accept-article group nil t))
9041 (kill-buffer (current-buffer)))
9042 (setq gnus-newsgroup-active (gnus-activate-group group))
9044 (gnus-summary-goto-article (cdr group-art) nil t)
9045 (gnus-summary-edit-article)))
9047 (defun gnus-summary-article-posted-p ()
9048 "Say whether the current (mail) article is available from news as well.
9049 This will be the case if the article has both been mailed and posted."
9051 (let ((id (mail-header-references (gnus-summary-article-header)))
9052 (gnus-override-method (car (gnus-refer-article-methods))))
9053 (if (gnus-request-head id "")
9054 (gnus-message 2 "The current message was found on %s"
9055 gnus-override-method)
9056 (gnus-message 2 "The current message couldn't be found on %s"
9057 gnus-override-method)
9060 (defun gnus-summary-expire-articles (&optional now)
9061 "Expire all articles that are marked as expirable in the current group."
9063 (when (and (not gnus-group-is-exiting-without-update-p)
9064 (gnus-check-backend-function
9065 'request-expire-articles gnus-newsgroup-name))
9066 ;; This backend supports expiry.
9067 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9068 (expirable (if total
9070 ;; We need to update the info for
9071 ;; this group for `gnus-list-of-read-articles'
9072 ;; to give us the right answer.
9073 (gnus-run-hooks 'gnus-exit-group-hook)
9074 (gnus-summary-update-info)
9075 (gnus-list-of-read-articles gnus-newsgroup-name))
9076 (setq gnus-newsgroup-expirable
9077 (sort gnus-newsgroup-expirable '<))))
9078 (expiry-wait (if now 'immediate
9079 (gnus-group-find-parameter
9080 gnus-newsgroup-name 'expiry-wait)))
9081 (nnmail-expiry-target
9082 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9083 nnmail-expiry-target))
9086 ;; There are expirable articles in this group, so we run them
9087 ;; through the expiry process.
9088 (gnus-message 6 "Expiring articles...")
9089 (unless (gnus-check-group gnus-newsgroup-name)
9090 (error "Can't open server for %s" gnus-newsgroup-name))
9091 ;; The list of articles that weren't expired is returned.
9094 (let ((nnmail-expiry-wait-function nil)
9095 (nnmail-expiry-wait expiry-wait))
9096 (setq es (gnus-request-expire-articles
9097 expirable gnus-newsgroup-name)))
9098 (setq es (gnus-request-expire-articles
9099 expirable gnus-newsgroup-name)))
9101 (setq gnus-newsgroup-expirable es))
9102 ;; We go through the old list of expirable, and mark all
9103 ;; really expired articles as nonexistent.
9104 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9105 (let ((gnus-use-cache nil))
9106 (dolist (article expirable)
9107 (when (and (not (memq article es))
9108 (gnus-data-find article))
9109 (gnus-summary-mark-article article gnus-canceled-mark)
9110 (run-hook-with-args 'gnus-summary-article-expire-hook
9113 (assoc article (gnus-data-list 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 (end (gnus-point-at-eol))
10306 ;; Leave point at bol
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 (gnus-point-at-bol))
11058 (end (gnus-point-at-eol))
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