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 `Z n' 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 (defcustom gnus-show-all-headers nil
364 "*If non-nil, don't hide any headers."
365 :group 'gnus-article-hiding
366 :group 'gnus-article-headers
369 (defcustom gnus-summary-ignore-duplicates nil
370 "*If non-nil, ignore articles with identical Message-ID headers."
374 (defcustom gnus-single-article-buffer t
375 "*If non-nil, display all articles in the same buffer.
376 If nil, each group will get its own article buffer."
377 :group 'gnus-article-various
380 (defcustom gnus-break-pages t
381 "*If non-nil, do page breaking on articles.
382 The page delimiter is specified by the `gnus-page-delimiter'
384 :group 'gnus-article-various
387 (defcustom gnus-move-split-methods nil
388 "*Variable used to suggest where articles are to be moved to.
389 It uses the same syntax as the `gnus-split-methods' variable.
390 However, whereas `gnus-split-methods' specifies file names as targets,
391 this variable specifies group names."
392 :group 'gnus-summary-mail
393 :type '(repeat (choice (list :value (fun) function)
394 (cons :value ("" "") regexp (repeat string))
397 (defcustom gnus-unread-mark ? ;Whitespace
398 "*Mark used for unread articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-ticked-mark ?!
403 "*Mark used for ticked articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-dormant-mark ??
408 "*Mark used for dormant articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-del-mark ?r
413 "*Mark used for del'd articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-read-mark ?R
418 "*Mark used for read articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-expirable-mark ?E
423 "*Mark used for expirable articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-killed-mark ?K
428 "*Mark used for killed articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-spam-mark ?$
433 "*Mark used for spam articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-souped-mark ?F
438 "*Mark used for souped articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-kill-file-mark ?X
443 "*Mark used for articles killed by kill files."
444 :group 'gnus-summary-marks
447 (defcustom gnus-low-score-mark ?Y
448 "*Mark used for articles with a low score."
449 :group 'gnus-summary-marks
452 (defcustom gnus-catchup-mark ?C
453 "*Mark used for articles that are caught up."
454 :group 'gnus-summary-marks
457 (defcustom gnus-replied-mark ?A
458 "*Mark used for articles that have been replied to."
459 :group 'gnus-summary-marks
462 (defcustom gnus-forwarded-mark ?F
463 "*Mark used for articles that have been forwarded."
464 :group 'gnus-summary-marks
467 (defcustom gnus-recent-mark ?N
468 "*Mark used for articles that are recent."
469 :group 'gnus-summary-marks
472 (defcustom gnus-cached-mark ?*
473 "*Mark used for articles that are in the cache."
474 :group 'gnus-summary-marks
477 (defcustom gnus-saved-mark ?S
478 "*Mark used for articles that have been saved."
479 :group 'gnus-summary-marks
482 (defcustom gnus-unseen-mark ?.
483 "*Mark used for articles that haven't been seen."
484 :group 'gnus-summary-marks
487 (defcustom gnus-no-mark ? ;Whitespace
488 "*Mark used for articles that have no other secondary mark."
489 :group 'gnus-summary-marks
492 (defcustom gnus-ancient-mark ?O
493 "*Mark used for ancient articles."
494 :group 'gnus-summary-marks
497 (defcustom gnus-sparse-mark ?Q
498 "*Mark used for sparsely reffed articles."
499 :group 'gnus-summary-marks
502 (defcustom gnus-canceled-mark ?G
503 "*Mark used for canceled articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-duplicate-mark ?M
508 "*Mark used for duplicate articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-undownloaded-mark ?-
513 "*Mark used for articles that weren't downloaded."
514 :group 'gnus-summary-marks
517 (defcustom gnus-downloaded-mark ?+
518 "*Mark used for articles that were downloaded."
519 :group 'gnus-summary-marks
522 (defcustom gnus-downloadable-mark ?%
523 "*Mark used for articles that are to be downloaded."
524 :group 'gnus-summary-marks
527 (defcustom gnus-unsendable-mark ?=
528 "*Mark used for articles that won't be sent."
529 :group 'gnus-summary-marks
532 (defcustom gnus-score-over-mark ?+
533 "*Score mark used for articles with high scores."
534 :group 'gnus-summary-marks
537 (defcustom gnus-score-below-mark ?-
538 "*Score mark used for articles with low scores."
539 :group 'gnus-summary-marks
542 (defcustom gnus-empty-thread-mark ? ;Whitespace
543 "*There is no thread under the article."
544 :group 'gnus-summary-marks
547 (defcustom gnus-not-empty-thread-mark ?=
548 "*There is a thread under the article."
549 :group 'gnus-summary-marks
552 (defcustom gnus-view-pseudo-asynchronously nil
553 "*If non-nil, Gnus will view pseudo-articles asynchronously."
554 :group 'gnus-extract-view
557 (defcustom gnus-auto-expirable-marks
558 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
559 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
560 gnus-souped-mark gnus-duplicate-mark)
561 "*The list of marks converted into expiration if a group is auto-expirable."
564 :type '(repeat character))
566 (defcustom gnus-inhibit-user-auto-expire t
567 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
572 (defcustom gnus-view-pseudos nil
573 "*If `automatic', pseudo-articles will be viewed automatically.
574 If `not-confirm', pseudos will be viewed automatically, and the user
575 will not be asked to confirm the command."
576 :group 'gnus-extract-view
577 :type '(choice (const :tag "off" nil)
579 (const not-confirm)))
581 (defcustom gnus-view-pseudos-separately t
582 "*If non-nil, one pseudo-article will be created for each file to be viewed.
583 If nil, all files that use the same viewing command will be given as a
584 list of parameters to that command."
585 :group 'gnus-extract-view
588 (defcustom gnus-insert-pseudo-articles t
589 "*If non-nil, insert pseudo-articles when decoding articles."
590 :group 'gnus-extract-view
593 (defcustom gnus-summary-dummy-line-format
595 "*The format specification for the dummy roots in the summary buffer.
596 It works along the same lines as a normal formatting string,
597 with some simple extensions.
601 General format specifiers can also be used.
602 See `(gnus)Formatting Variables'."
603 :link '(custom-manual "(gnus)Formatting Variables")
604 :group 'gnus-threading
607 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
608 "*The format specification for the summary mode line.
609 It works along the same lines as a normal formatting string,
610 with some simple extensions:
613 %p Unprefixed group name
614 %A Current article number
615 %z Current article score
617 %U Number of unread articles in the group
618 %e Number of unselected articles in the group
619 %Z A string with unread/unselected article counts
620 %g Shortish group name
621 %S Subject of the current article
623 %s Current score file name
624 %d Number of dormant articles
625 %r Number of articles that have been marked as read in this session
626 %E Number of articles expunged by the score files"
627 :group 'gnus-summary-format
630 (defcustom gnus-list-identifiers nil
631 "Regexp that matches list identifiers to be removed from subject.
632 This can also be a list of regexps."
634 :group 'gnus-summary-format
635 :group 'gnus-article-hiding
636 :type '(choice (const :tag "none" nil)
638 (repeat :value (".*") regexp)))
640 (defcustom gnus-summary-mark-below 0
641 "*Mark all articles with a score below this variable as read.
642 This variable is local to each summary buffer and usually set by the
644 :group 'gnus-score-default
647 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
648 "*List of functions used for sorting articles in the summary buffer.
650 Each function takes two articles and returns non-nil if the first
651 article should be sorted before the other. If you use more than one
652 function, the primary sort function should be the last. You should
653 probably always include `gnus-article-sort-by-number' in the list of
654 sorting functions -- preferably first. Also note that sorting by date
655 is often much slower than sorting by number, and the sorting order is
656 very similar. (Sorting by date means sorting by the time the message
657 was sent, sorting by number means sorting by arrival time.)
659 Ready-made functions include `gnus-article-sort-by-number',
660 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
661 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
662 and `gnus-article-sort-by-score'.
664 When threading is turned on, the variable `gnus-thread-sort-functions'
665 controls how articles are sorted."
666 :group 'gnus-summary-sort
667 :type '(repeat (choice (function-item gnus-article-sort-by-number)
668 (function-item gnus-article-sort-by-author)
669 (function-item gnus-article-sort-by-subject)
670 (function-item gnus-article-sort-by-date)
671 (function-item gnus-article-sort-by-score)
672 (function-item gnus-article-sort-by-random)
673 (function :tag "other"))))
675 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
676 "*List of functions used for sorting threads in the summary buffer.
677 By default, threads are sorted by article number.
679 Each function takes two threads and returns non-nil if the first
680 thread should be sorted before the other. If you use more than one
681 function, the primary sort function should be the last. You should
682 probably always include `gnus-thread-sort-by-number' in the list of
683 sorting functions -- preferably first. Also note that sorting by date
684 is often much slower than sorting by number, and the sorting order is
685 very similar. (Sorting by date means sorting by the time the message
686 was sent, sorting by number means sorting by arrival time.)
688 Ready-made functions include `gnus-thread-sort-by-number',
689 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
690 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
691 `gnus-thread-sort-by-most-recent-number',
692 `gnus-thread-sort-by-most-recent-date',
693 `gnus-thread-sort-by-random', and
694 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
696 When threading is turned off, the variable
697 `gnus-article-sort-functions' controls how articles are sorted."
698 :group 'gnus-summary-sort
699 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
700 (function-item gnus-thread-sort-by-author)
701 (function-item gnus-thread-sort-by-subject)
702 (function-item gnus-thread-sort-by-date)
703 (function-item gnus-thread-sort-by-score)
704 (function-item gnus-thread-sort-by-total-score)
705 (function-item gnus-thread-sort-by-random)
706 (function :tag "other"))))
708 (defcustom gnus-thread-score-function '+
709 "*Function used for calculating the total score of a thread.
711 The function is called with the scores of the article and each
712 subthread and should then return the score of the thread.
714 Some functions you can use are `+', `max', or `min'."
715 :group 'gnus-summary-sort
718 (defcustom gnus-summary-expunge-below nil
719 "All articles that have a score less than this variable will be expunged.
720 This variable is local to the summary buffers."
721 :group 'gnus-score-default
722 :type '(choice (const :tag "off" nil)
725 (defcustom gnus-thread-expunge-below nil
726 "All threads that have a total score less than this variable will be expunged.
727 See `gnus-thread-score-function' for en explanation of what a
730 This variable is local to the summary buffers."
731 :group 'gnus-threading
732 :group 'gnus-score-default
733 :type '(choice (const :tag "off" nil)
736 (defcustom gnus-summary-mode-hook nil
737 "*A hook for Gnus summary mode.
738 This hook is run before any variables are set in the summary buffer."
739 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
740 :group 'gnus-summary-various
743 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
744 (when (featurep 'xemacs)
745 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
746 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
747 (add-hook 'gnus-summary-mode-hook
748 'gnus-xmas-switch-horizontal-scrollbar-off))
750 (defcustom gnus-summary-menu-hook nil
751 "*Hook run after the creation of the summary mode menu."
752 :group 'gnus-summary-visual
755 (defcustom gnus-summary-exit-hook nil
756 "*A hook called on exit from the summary buffer.
757 It will be called with point in the group buffer."
758 :group 'gnus-summary-exit
761 (defcustom gnus-summary-prepare-hook nil
762 "*A hook called after the summary buffer has been generated.
763 If you want to modify the summary buffer, you can use this hook."
764 :group 'gnus-summary-various
767 (defcustom gnus-summary-prepared-hook nil
768 "*A hook called as the last thing after the summary buffer has been generated."
769 :group 'gnus-summary-various
772 (defcustom gnus-summary-generate-hook nil
773 "*A hook run just before generating the summary buffer.
774 This hook is commonly used to customize threading variables and the
776 :group 'gnus-summary-various
779 (defcustom gnus-select-group-hook nil
780 "*A hook called when a newsgroup is selected.
782 If you'd like to simplify subjects like the
783 `gnus-summary-next-same-subject' command does, you can use the
786 (add-hook gnus-select-group-hook
788 (mapcar (lambda (header)
789 (mail-header-set-subject
791 (gnus-simplify-subject
792 (mail-header-subject header) 're-only)))
793 gnus-newsgroup-headers)))"
794 :group 'gnus-group-select
797 (defcustom gnus-select-article-hook nil
798 "*A hook called when an article is selected."
799 :group 'gnus-summary-choose
800 :options '(gnus-agent-fetch-selected-article)
803 (defcustom gnus-visual-mark-article-hook
804 (list 'gnus-highlight-selected-summary)
805 "*Hook run after selecting an article in the summary buffer.
806 It is meant to be used for highlighting the article in some way. It
807 is not run if `gnus-visual' is nil."
808 :group 'gnus-summary-visual
811 (defcustom gnus-parse-headers-hook nil
812 "*A hook called before parsing the headers."
816 (defcustom gnus-exit-group-hook nil
817 "*A hook called when exiting summary mode.
818 This hook is not called from the non-updating exit commands like `Q'."
822 (defcustom gnus-summary-update-hook
823 (list 'gnus-summary-highlight-line)
824 "*A hook called when a summary line is changed.
825 The hook will not be called if `gnus-visual' is nil.
827 The default function `gnus-summary-highlight-line' will
828 highlight the line according to the `gnus-summary-highlight'
830 :group 'gnus-summary-visual
833 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
834 "*A hook called when an article is selected for the first time.
835 The hook is intended to mark an article as read (or unread)
836 automatically when it is selected."
837 :group 'gnus-summary-choose
840 (defcustom gnus-group-no-more-groups-hook nil
841 "*A hook run when returning to group mode having no more (unread) groups."
842 :group 'gnus-group-select
845 (defcustom gnus-ps-print-hook nil
846 "*A hook run before ps-printing something from Gnus."
850 (defcustom gnus-summary-display-arrow
851 (and (fboundp 'display-graphic-p)
853 "*If non-nil, display an arrow highlighting the current article."
858 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
859 "Face used for highlighting the current article in the summary buffer."
860 :group 'gnus-summary-visual
863 (defvar gnus-tmp-downloaded nil)
865 (defcustom gnus-summary-highlight
866 '(((eq mark gnus-canceled-mark)
867 . gnus-summary-cancelled-face)
868 ((and uncached (> score default-high))
869 . gnus-summary-high-undownloaded-face)
870 ((and uncached (< score default-low))
871 . gnus-summary-low-undownloaded-face)
873 . gnus-summary-normal-undownloaded-face)
874 ((and (> score default-high)
875 (or (eq mark gnus-dormant-mark)
876 (eq mark gnus-ticked-mark)))
877 . gnus-summary-high-ticked-face)
878 ((and (< score default-low)
879 (or (eq mark gnus-dormant-mark)
880 (eq mark gnus-ticked-mark)))
881 . gnus-summary-low-ticked-face)
882 ((or (eq mark gnus-dormant-mark)
883 (eq mark gnus-ticked-mark))
884 . gnus-summary-normal-ticked-face)
885 ((and (> score default-high) (eq mark gnus-ancient-mark))
886 . gnus-summary-high-ancient-face)
887 ((and (< score default-low) (eq mark gnus-ancient-mark))
888 . gnus-summary-low-ancient-face)
889 ((eq mark gnus-ancient-mark)
890 . gnus-summary-normal-ancient-face)
891 ((and (> score default-high) (eq mark gnus-unread-mark))
892 . gnus-summary-high-unread-face)
893 ((and (< score default-low) (eq mark gnus-unread-mark))
894 . gnus-summary-low-unread-face)
895 ((eq mark gnus-unread-mark)
896 . gnus-summary-normal-unread-face)
897 ((> score default-high)
898 . gnus-summary-high-read-face)
899 ((< score default-low)
900 . gnus-summary-low-read-face)
902 . gnus-summary-normal-read-face))
903 "*Controls the highlighting of summary buffer lines.
905 A list of (FORM . FACE) pairs. When deciding how a a particular
906 summary line should be displayed, each form is evaluated. The content
907 of the face field after the first true form is used. You can change
908 how those summary lines are displayed, by editing the face field.
910 You can use the following variables in the FORM field.
912 score: The article's score
913 default: The default article score.
914 default-high: The default score for high scored articles.
915 default-low: The default score for low scored articles.
916 below: The score below which articles are automatically marked as read.
917 mark: The articles mark."
918 :group 'gnus-summary-visual
919 :type '(repeat (cons (sexp :tag "Form" nil)
922 (defcustom gnus-alter-header-function nil
923 "Function called to allow alteration of article header structures.
924 The function is called with one parameter, the article header vector,
925 which it may alter in any way."
926 :type '(choice (const :tag "None" nil)
928 :group 'gnus-summary)
930 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
931 "Variable that says which function should be used to decode a string with encoded words.")
933 (defcustom gnus-extra-headers '(To Newsgroups)
934 "*Extra headers to parse."
937 :type '(repeat symbol))
939 (defcustom gnus-ignored-from-addresses
940 (and user-mail-address (regexp-quote user-mail-address))
941 "*Regexp of From headers that may be suppressed in favor of To headers."
946 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
947 "List of charsets that should be ignored.
948 When these charsets are used in the \"charset\" parameter, the
949 default charset will be used instead."
951 :type '(repeat symbol)
952 :group 'gnus-charset)
954 (gnus-define-group-parameter
958 "Return the ignored charsets of GROUP."
959 :variable gnus-group-ignored-charsets-alist
961 '(("alt\\.chinese\\.text" iso-8859-1))
963 "Alist of regexps (to match group names) and charsets that should be ignored.
964 When these charsets are used in the \"charset\" parameter, the
965 default charset will be used instead."
966 :variable-group gnus-charset
967 :variable-type '(repeat (cons (regexp :tag "Group")
969 :parameter-type '(choice :tag "Ignored charsets"
972 :parameter-document "\
973 List of charsets that should be ignored.
975 When these charsets are used in the \"charset\" parameter, the
976 default charset will be used instead.")
978 (defcustom gnus-group-highlight-words-alist nil
979 "Alist of group regexps and highlight regexps.
980 This variable uses the same syntax as `gnus-emphasis-alist'."
982 :type '(repeat (cons (regexp :tag "Group")
983 (repeat (list (regexp :tag "Highlight regexp")
984 (number :tag "Group for entire word" 0)
985 (number :tag "Group for displayed part" 0)
987 gnus-emphasis-highlight-words)))))
988 :group 'gnus-summary-visual)
990 (defcustom gnus-summary-show-article-charset-alist
992 "Alist of number and charset.
993 The article will be shown with the charset corresponding to the
995 For example: ((1 . cn-gb-2312) (2 . big5))."
997 :type '(repeat (cons (number :tag "Argument" 1)
998 (symbol :tag "Charset")))
999 :group 'gnus-charset)
1001 (defcustom gnus-preserve-marks t
1002 "Whether marks are preserved when moving, copying and respooling messages."
1005 :group 'gnus-summary-marks)
1007 (defcustom gnus-alter-articles-to-read-function nil
1008 "Function to be called to alter the list of articles to be selected."
1009 :type '(choice (const nil) function)
1010 :group 'gnus-summary)
1012 (defcustom gnus-orphan-score nil
1013 "*All orphans get this score added. Set in the score file."
1014 :group 'gnus-score-default
1015 :type '(choice (const nil)
1018 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1019 "*A regexp to match MIME parts when saving multiple parts of a message
1020 with gnus-summary-save-parts (X m). This regexp will be used by default
1021 when prompting the user for which type of files to save."
1022 :group 'gnus-summary
1025 (defcustom gnus-read-all-available-headers nil
1026 "Whether Gnus should parse all headers made available to it.
1027 This is mostly relevant for slow backends where the user may
1028 wish to widen the summary buffer to include all headers
1029 that were fetched. Say, for nnultimate groups."
1030 :group 'gnus-summary
1031 :type '(choice boolean regexp))
1033 (defcustom gnus-summary-muttprint-program "muttprint"
1034 "Command (and optional arguments) used to run Muttprint."
1036 :group 'gnus-summary
1039 (defcustom gnus-article-loose-mime nil
1040 "If non-nil, don't require MIME-Version header.
1041 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1042 supply the MIME-Version header or deliberately strip it From the mail.
1043 Set it to non-nil, Gnus will treat some articles as MIME even if
1044 the MIME-Version header is missed."
1047 :group 'gnus-article)
1049 (defcustom gnus-article-emulate-mime t
1050 "If non-nil, use MIME emulation for uuencode and the like.
1051 This means that Gnus will search message bodies for text that look
1052 like uuencoded bits, yEncoded bits, and so on, and present that using
1053 the normal Gnus MIME machinery."
1055 :group 'gnus-article)
1057 ;;; Internal variables
1059 (defvar gnus-summary-display-cache nil)
1060 (defvar gnus-article-mime-handles nil)
1061 (defvar gnus-article-decoded-p nil)
1062 (defvar gnus-article-charset nil)
1063 (defvar gnus-article-ignored-charsets nil)
1064 (defvar gnus-scores-exclude-files nil)
1065 (defvar gnus-page-broken nil)
1067 (defvar gnus-original-article nil)
1068 (defvar gnus-article-internal-prepare-hook nil)
1069 (defvar gnus-newsgroup-process-stack nil)
1071 (defvar gnus-thread-indent-array nil)
1072 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1073 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1074 "Function called to sort the articles within a thread after it has been gathered together.")
1076 (defvar gnus-summary-save-parts-type-history nil)
1077 (defvar gnus-summary-save-parts-last-directory nil)
1079 ;; Avoid highlighting in kill files.
1080 (defvar gnus-summary-inhibit-highlight nil)
1081 (defvar gnus-newsgroup-selected-overlay nil)
1082 (defvar gnus-inhibit-limiting nil)
1083 (defvar gnus-newsgroup-adaptive-score-file nil)
1084 (defvar gnus-current-score-file nil)
1085 (defvar gnus-current-move-group nil)
1086 (defvar gnus-current-copy-group nil)
1087 (defvar gnus-current-crosspost-group nil)
1088 (defvar gnus-newsgroup-display nil)
1090 (defvar gnus-newsgroup-dependencies nil)
1091 (defvar gnus-newsgroup-adaptive nil)
1092 (defvar gnus-summary-display-article-function nil)
1093 (defvar gnus-summary-highlight-line-function nil
1094 "Function called after highlighting a summary line.")
1096 (defvar gnus-summary-line-format-alist
1097 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1098 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1099 (?s gnus-tmp-subject-or-nil ?s)
1100 (?n gnus-tmp-name ?s)
1101 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1103 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1105 (?F gnus-tmp-from ?s)
1106 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1107 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1108 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1109 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1110 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1111 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1112 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1113 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1114 (?L gnus-tmp-lines ?s)
1115 (?O gnus-tmp-downloaded ?c)
1116 (?I gnus-tmp-indentation ?s)
1117 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1118 (?R gnus-tmp-replied ?c)
1119 (?\[ gnus-tmp-opening-bracket ?c)
1120 (?\] gnus-tmp-closing-bracket ?c)
1121 (?\> (make-string gnus-tmp-level ? ) ?s)
1122 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1123 (?i gnus-tmp-score ?d)
1124 (?z gnus-tmp-score-char ?c)
1125 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1126 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1127 (?U gnus-tmp-unread ?c)
1128 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1130 (?t (gnus-summary-number-of-articles-in-thread
1131 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1133 (?e (gnus-summary-number-of-articles-in-thread
1134 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1136 (?u gnus-tmp-user-defined ?s)
1137 (?P (gnus-pick-line-number) ?d)
1138 (?B gnus-tmp-thread-tree-header-string ?s)
1139 (user-date (gnus-user-date
1140 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1141 "An alist of format specifications that can appear in summary lines.
1142 These are paired with what variables they correspond with, along with
1143 the type of the variable (string, integer, character, etc).")
1145 (defvar gnus-summary-dummy-line-format-alist
1146 `((?S gnus-tmp-subject ?s)
1147 (?N gnus-tmp-number ?d)
1148 (?u gnus-tmp-user-defined ?s)))
1150 (defvar gnus-summary-mode-line-format-alist
1151 `((?G gnus-tmp-group-name ?s)
1152 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1153 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1154 (?A gnus-tmp-article-number ?d)
1155 (?Z gnus-tmp-unread-and-unselected ?s)
1156 (?V gnus-version ?s)
1157 (?U gnus-tmp-unread-and-unticked ?d)
1158 (?S gnus-tmp-subject ?s)
1159 (?e gnus-tmp-unselected ?d)
1160 (?u gnus-tmp-user-defined ?s)
1161 (?d (length gnus-newsgroup-dormant) ?d)
1162 (?t (length gnus-newsgroup-marked) ?d)
1163 (?h (length gnus-newsgroup-spam-marked) ?d)
1164 (?r (length gnus-newsgroup-reads) ?d)
1165 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1166 (?E gnus-newsgroup-expunged-tally ?d)
1167 (?s (gnus-current-score-file-nondirectory) ?s)))
1169 (defvar gnus-last-search-regexp nil
1170 "Default regexp for article search command.")
1172 (defvar gnus-last-shell-command nil
1173 "Default shell command on article.")
1175 (defvar gnus-newsgroup-agentized nil
1176 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1177 (defvar gnus-newsgroup-begin nil)
1178 (defvar gnus-newsgroup-end nil)
1179 (defvar gnus-newsgroup-last-rmail nil)
1180 (defvar gnus-newsgroup-last-mail nil)
1181 (defvar gnus-newsgroup-last-folder nil)
1182 (defvar gnus-newsgroup-last-file nil)
1183 (defvar gnus-newsgroup-auto-expire nil)
1184 (defvar gnus-newsgroup-active nil)
1186 (defvar gnus-newsgroup-data nil)
1187 (defvar gnus-newsgroup-data-reverse nil)
1188 (defvar gnus-newsgroup-limit nil)
1189 (defvar gnus-newsgroup-limits nil)
1191 (defvar gnus-newsgroup-unreads nil
1192 "Sorted list of unread articles in the current newsgroup.")
1194 (defvar gnus-newsgroup-unselected nil
1195 "Sorted list of unselected unread articles in the current newsgroup.")
1197 (defvar gnus-newsgroup-reads nil
1198 "Alist of read articles and article marks in the current newsgroup.")
1200 (defvar gnus-newsgroup-expunged-tally nil)
1202 (defvar gnus-newsgroup-marked nil
1203 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1205 (defvar gnus-newsgroup-spam-marked nil
1206 "List of ranges of articles that have been marked as spam.")
1208 (defvar gnus-newsgroup-killed nil
1209 "List of ranges of articles that have been through the scoring process.")
1211 (defvar gnus-newsgroup-cached nil
1212 "Sorted list of articles that come from the article cache.")
1214 (defvar gnus-newsgroup-saved nil
1215 "List of articles that have been saved.")
1217 (defvar gnus-newsgroup-kill-headers nil)
1219 (defvar gnus-newsgroup-replied nil
1220 "List of articles that have been replied to in the current newsgroup.")
1222 (defvar gnus-newsgroup-forwarded nil
1223 "List of articles that have been forwarded in the current newsgroup.")
1225 (defvar gnus-newsgroup-recent nil
1226 "List of articles that have are recent in the current newsgroup.")
1228 (defvar gnus-newsgroup-expirable nil
1229 "Sorted list of articles in the current newsgroup that can be expired.")
1231 (defvar gnus-newsgroup-processable nil
1232 "List of articles in the current newsgroup that can be processed.")
1234 (defvar gnus-newsgroup-downloadable nil
1235 "Sorted list of articles in the current newsgroup that can be processed.")
1237 (defvar gnus-newsgroup-unfetched nil
1238 "Sorted list of articles in the current newsgroup whose headers have not been fetched into the agent.")
1240 (defvar gnus-newsgroup-undownloaded nil
1241 "List of articles in the current newsgroup that haven't been downloaded..")
1243 (defvar gnus-newsgroup-unsendable nil
1244 "List of articles in the current newsgroup that won't be sent.")
1246 (defvar gnus-newsgroup-bookmarks nil
1247 "List of articles in the current newsgroup that have bookmarks.")
1249 (defvar gnus-newsgroup-dormant nil
1250 "Sorted list of dormant articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-unseen nil
1253 "List of unseen articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-seen nil
1256 "Range of seen articles in the current newsgroup.")
1258 (defvar gnus-newsgroup-articles nil
1259 "List of articles in the current newsgroup.")
1261 (defvar gnus-newsgroup-scored nil
1262 "List of scored articles in the current newsgroup.")
1264 (defvar gnus-newsgroup-headers nil
1265 "List of article headers in the current newsgroup.")
1267 (defvar gnus-newsgroup-threads nil)
1269 (defvar gnus-newsgroup-prepared nil
1270 "Whether the current group has been prepared properly.")
1272 (defvar gnus-newsgroup-ancient nil
1273 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1275 (defvar gnus-newsgroup-sparse nil)
1277 (defvar gnus-current-article nil)
1278 (defvar gnus-article-current nil)
1279 (defvar gnus-current-headers nil)
1280 (defvar gnus-have-all-headers nil)
1281 (defvar gnus-last-article nil)
1282 (defvar gnus-newsgroup-history nil)
1283 (defvar gnus-newsgroup-charset nil)
1284 (defvar gnus-newsgroup-ephemeral-charset nil)
1285 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1287 (defvar gnus-article-before-search nil)
1289 (defconst gnus-summary-local-variables
1290 '(gnus-newsgroup-name
1291 gnus-newsgroup-begin gnus-newsgroup-end
1292 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1293 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1294 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1295 gnus-newsgroup-unselected gnus-newsgroup-marked
1296 gnus-newsgroup-spam-marked
1297 gnus-newsgroup-reads gnus-newsgroup-saved
1298 gnus-newsgroup-replied gnus-newsgroup-forwarded
1299 gnus-newsgroup-recent
1300 gnus-newsgroup-expirable
1301 gnus-newsgroup-processable gnus-newsgroup-killed
1302 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1303 gnus-newsgroup-unfetched
1304 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1305 gnus-newsgroup-seen gnus-newsgroup-articles
1306 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1307 gnus-newsgroup-headers gnus-newsgroup-threads
1308 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1309 gnus-current-article gnus-current-headers gnus-have-all-headers
1310 gnus-last-article gnus-article-internal-prepare-hook
1311 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1312 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1313 gnus-thread-expunge-below
1314 gnus-score-alist gnus-current-score-file
1315 (gnus-summary-expunge-below . global)
1316 (gnus-summary-mark-below . global)
1317 (gnus-orphan-score . global)
1318 gnus-newsgroup-active gnus-scores-exclude-files
1319 gnus-newsgroup-history gnus-newsgroup-ancient
1320 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1321 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1322 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1323 (gnus-newsgroup-expunged-tally . 0)
1324 gnus-cache-removable-articles gnus-newsgroup-cached
1325 gnus-newsgroup-data gnus-newsgroup-data-reverse
1326 gnus-newsgroup-limit gnus-newsgroup-limits
1327 gnus-newsgroup-charset gnus-newsgroup-display)
1328 "Variables that are buffer-local to the summary buffers.")
1330 (defvar gnus-newsgroup-variables nil
1331 "A list of variables that have separate values in different newsgroups.
1332 A list of newsgroup (summary buffer) local variables, or cons of
1333 variables and their default values (when the default values are not
1334 nil), that should be made global while the summary buffer is active.
1335 These variables can be used to set variables in the group parameters
1336 while still allowing them to affect operations done in other
1337 buffers. For example:
1339 \(setq gnus-newsgroup-variables
1340 '(message-use-followup-to
1341 (gnus-visible-headers .
1342 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1345 ;; Byte-compiler warning.
1346 ;(eval-when-compile (defvar gnus-article-mode-map))
1348 (let ((features (cons 'gnus-sum features)))
1350 (require 'gnus-agent)
1351 (require 'gnus-art)))
1355 (defvar gnus-decode-encoded-word-methods
1356 '(mail-decode-encoded-word-string)
1357 "List of methods used to decode encoded words.
1359 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1360 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1361 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1362 whose names match REGEXP.
1365 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1366 mail-decode-encoded-word-string
1367 (\"chinese\" . rfc1843-decode-string))")
1369 (defvar gnus-decode-encoded-word-methods-cache nil)
1371 (defun gnus-multi-decode-encoded-word-string (string)
1372 "Apply the functions from `gnus-encoded-word-methods' that match."
1373 (unless (and gnus-decode-encoded-word-methods-cache
1374 (eq gnus-newsgroup-name
1375 (car gnus-decode-encoded-word-methods-cache)))
1376 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1379 (nconc gnus-decode-encoded-word-methods-cache (list x))
1380 (if (and gnus-newsgroup-name
1381 (string-match (car x) gnus-newsgroup-name))
1382 (nconc gnus-decode-encoded-word-methods-cache
1384 gnus-decode-encoded-word-methods))
1385 (let ((xlist gnus-decode-encoded-word-methods-cache))
1388 (setq string (funcall (pop xlist) string))))
1391 ;; Subject simplification.
1393 (defun gnus-simplify-whitespace (str)
1394 "Remove excessive whitespace from STR."
1396 (while (string-match "[ \t][ \t]+" str)
1397 (setq str (concat (substring str 0 (match-beginning 0))
1399 (substring str (match-end 0)))))
1401 (when (string-match "^[ \t]+" str)
1402 (setq str (substring str (match-end 0))))
1404 (when (string-match "[ \t]+$" str)
1405 (setq str (substring str 0 (match-beginning 0))))
1408 (defun gnus-simplify-all-whitespace (str)
1409 "Remove all whitespace from STR."
1410 (while (string-match "[ \t\n]+" str)
1411 (setq str (replace-match "" nil nil str)))
1414 (defsubst gnus-simplify-subject-re (subject)
1415 "Remove \"Re:\" from subject lines."
1416 (if (string-match message-subject-re-regexp subject)
1417 (substring subject (match-end 0))
1420 (defun gnus-simplify-subject (subject &optional re-only)
1421 "Remove `Re:' and words in parentheses.
1422 If RE-ONLY is non-nil, strip leading `Re:'s only."
1423 (let ((case-fold-search t)) ;Ignore case.
1424 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1425 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1426 (setq subject (substring subject (match-end 0))))
1427 ;; Remove uninteresting prefixes.
1428 (when (and (not re-only)
1429 gnus-simplify-ignored-prefixes
1430 (string-match gnus-simplify-ignored-prefixes subject))
1431 (setq subject (substring subject (match-end 0))))
1432 ;; Remove words in parentheses from end.
1434 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1435 (setq subject (substring subject 0 (match-beginning 0)))))
1436 ;; Return subject string.
1439 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1441 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1442 (goto-char (point-min))
1443 (while (re-search-forward regexp nil t)
1444 (replace-match (or newtext ""))))
1446 (defun gnus-simplify-buffer-fuzzy ()
1447 "Simplify string in the buffer fuzzily.
1448 The string in the accessible portion of the current buffer is simplified.
1449 It is assumed to be a single-line subject.
1450 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1451 matter is removed. Additional things can be deleted by setting
1452 `gnus-simplify-subject-fuzzy-regexp'."
1453 (let ((case-fold-search t)
1455 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1457 (while (not (eq modified-tick (buffer-modified-tick)))
1458 (setq modified-tick (buffer-modified-tick))
1460 ((listp gnus-simplify-subject-fuzzy-regexp)
1461 (mapcar 'gnus-simplify-buffer-fuzzy-step
1462 gnus-simplify-subject-fuzzy-regexp))
1463 (gnus-simplify-subject-fuzzy-regexp
1464 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1465 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1466 (gnus-simplify-buffer-fuzzy-step
1467 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1468 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1470 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1471 (gnus-simplify-buffer-fuzzy-step " +" " ")
1472 (gnus-simplify-buffer-fuzzy-step " $")
1473 (gnus-simplify-buffer-fuzzy-step "^ +")))
1475 (defun gnus-simplify-subject-fuzzy (subject)
1476 "Simplify a subject string fuzzily.
1477 See `gnus-simplify-buffer-fuzzy' for details."
1479 (gnus-set-work-buffer)
1480 (let ((case-fold-search t))
1481 ;; Remove uninteresting prefixes.
1482 (when (and gnus-simplify-ignored-prefixes
1483 (string-match gnus-simplify-ignored-prefixes subject))
1484 (setq subject (substring subject (match-end 0))))
1486 (inline (gnus-simplify-buffer-fuzzy))
1489 (defsubst gnus-simplify-subject-fully (subject)
1490 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1492 (gnus-simplify-subject-functions
1493 (gnus-map-function gnus-simplify-subject-functions subject))
1494 ((null gnus-summary-gather-subject-limit)
1495 (gnus-simplify-subject-re subject))
1496 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1497 (gnus-simplify-subject-fuzzy subject))
1498 ((numberp gnus-summary-gather-subject-limit)
1499 (gnus-limit-string (gnus-simplify-subject-re subject)
1500 gnus-summary-gather-subject-limit))
1504 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1505 "Check whether two subjects are equal.
1506 If optional argument simple-first is t, first argument is already
1509 ((null simple-first)
1510 (equal (gnus-simplify-subject-fully s1)
1511 (gnus-simplify-subject-fully s2)))
1514 (gnus-simplify-subject-fully s2)))))
1516 (defun gnus-summary-bubble-group ()
1517 "Increase the score of the current group.
1518 This is a handy function to add to `gnus-summary-exit-hook' to
1519 increase the score of each group you read."
1520 (gnus-group-add-score gnus-newsgroup-name))
1524 ;;; Gnus summary mode
1527 (put 'gnus-summary-mode 'mode-class 'special)
1529 (defvar gnus-article-commands-menu)
1531 ;; Non-orthogonal keys
1533 (gnus-define-keys gnus-summary-mode-map
1534 " " gnus-summary-next-page
1535 "\177" gnus-summary-prev-page
1536 [delete] gnus-summary-prev-page
1537 [backspace] gnus-summary-prev-page
1538 "\r" gnus-summary-scroll-up
1539 "\M-\r" gnus-summary-scroll-down
1540 "n" gnus-summary-next-unread-article
1541 "p" gnus-summary-prev-unread-article
1542 "N" gnus-summary-next-article
1543 "P" gnus-summary-prev-article
1544 "\M-\C-n" gnus-summary-next-same-subject
1545 "\M-\C-p" gnus-summary-prev-same-subject
1546 "\M-n" gnus-summary-next-unread-subject
1547 "\M-p" gnus-summary-prev-unread-subject
1548 "." gnus-summary-first-unread-article
1549 "," gnus-summary-best-unread-article
1550 "\M-s" gnus-summary-search-article-forward
1551 "\M-r" gnus-summary-search-article-backward
1552 "<" gnus-summary-beginning-of-article
1553 ">" gnus-summary-end-of-article
1554 "j" gnus-summary-goto-article
1555 "^" gnus-summary-refer-parent-article
1556 "\M-^" gnus-summary-refer-article
1557 "u" gnus-summary-tick-article-forward
1558 "!" gnus-summary-tick-article-forward
1559 "U" gnus-summary-tick-article-backward
1560 "d" gnus-summary-mark-as-read-forward
1561 "D" gnus-summary-mark-as-read-backward
1562 "E" gnus-summary-mark-as-expirable
1563 "\M-u" gnus-summary-clear-mark-forward
1564 "\M-U" gnus-summary-clear-mark-backward
1565 "k" gnus-summary-kill-same-subject-and-select
1566 "\C-k" gnus-summary-kill-same-subject
1567 "\M-\C-k" gnus-summary-kill-thread
1568 "\M-\C-l" gnus-summary-lower-thread
1569 "e" gnus-summary-edit-article
1570 "#" gnus-summary-mark-as-processable
1571 "\M-#" gnus-summary-unmark-as-processable
1572 "\M-\C-t" gnus-summary-toggle-threads
1573 "\M-\C-s" gnus-summary-show-thread
1574 "\M-\C-h" gnus-summary-hide-thread
1575 "\M-\C-f" gnus-summary-next-thread
1576 "\M-\C-b" gnus-summary-prev-thread
1577 [(meta down)] gnus-summary-next-thread
1578 [(meta up)] gnus-summary-prev-thread
1579 "\M-\C-u" gnus-summary-up-thread
1580 "\M-\C-d" gnus-summary-down-thread
1581 "&" gnus-summary-execute-command
1582 "c" gnus-summary-catchup-and-exit
1583 "\C-w" gnus-summary-mark-region-as-read
1584 "\C-t" gnus-summary-toggle-truncation
1585 "?" gnus-summary-mark-as-dormant
1586 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1587 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1588 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1589 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1590 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1591 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1592 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1593 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1594 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1595 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1596 "=" gnus-summary-expand-window
1597 "\C-x\C-s" gnus-summary-reselect-current-group
1598 "\M-g" gnus-summary-rescan-group
1599 "w" gnus-summary-stop-page-breaking
1600 "\C-c\C-r" gnus-summary-caesar-message
1601 "f" gnus-summary-followup
1602 "F" gnus-summary-followup-with-original
1603 "C" gnus-summary-cancel-article
1604 "r" gnus-summary-reply
1605 "R" gnus-summary-reply-with-original
1606 "\C-c\C-f" gnus-summary-mail-forward
1607 "o" gnus-summary-save-article
1608 "\C-o" gnus-summary-save-article-mail
1609 "|" gnus-summary-pipe-output
1610 "\M-k" gnus-summary-edit-local-kill
1611 "\M-K" gnus-summary-edit-global-kill
1613 "\C-c\C-d" gnus-summary-describe-group
1614 "q" gnus-summary-exit
1615 "Q" gnus-summary-exit-no-update
1616 "\C-c\C-i" gnus-info-find-node
1617 gnus-mouse-2 gnus-mouse-pick-article
1618 "m" gnus-summary-mail-other-window
1619 "a" gnus-summary-post-news
1620 "i" gnus-summary-news-other-window
1621 "x" gnus-summary-limit-to-unread
1622 "s" gnus-summary-isearch-article
1623 "t" gnus-summary-toggle-header
1624 "g" gnus-summary-show-article
1625 "l" gnus-summary-goto-last-article
1626 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1627 "\C-d" gnus-summary-enter-digest-group
1628 "\M-\C-d" gnus-summary-read-document
1629 "\M-\C-e" gnus-summary-edit-parameters
1630 "\M-\C-a" gnus-summary-customize-parameters
1632 "*" gnus-cache-enter-article
1633 "\M-*" gnus-cache-remove-article
1634 "\M-&" gnus-summary-universal-argument
1635 "\C-l" gnus-recenter
1636 "I" gnus-summary-increase-score
1637 "L" gnus-summary-lower-score
1638 "\M-i" gnus-symbolic-argument
1639 "h" gnus-summary-select-article-buffer
1641 "b" gnus-article-view-part
1642 "\M-t" gnus-summary-toggle-display-buttonized
1644 "V" gnus-summary-score-map
1645 "X" gnus-uu-extract-map
1646 "S" gnus-summary-send-map)
1648 ;; Sort of orthogonal keymap
1649 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1650 "t" gnus-summary-tick-article-forward
1651 "!" gnus-summary-tick-article-forward
1652 "d" gnus-summary-mark-as-read-forward
1653 "r" gnus-summary-mark-as-read-forward
1654 "c" gnus-summary-clear-mark-forward
1655 " " gnus-summary-clear-mark-forward
1656 "e" gnus-summary-mark-as-expirable
1657 "x" gnus-summary-mark-as-expirable
1658 "?" gnus-summary-mark-as-dormant
1659 "b" gnus-summary-set-bookmark
1660 "B" gnus-summary-remove-bookmark
1661 "#" gnus-summary-mark-as-processable
1662 "\M-#" gnus-summary-unmark-as-processable
1663 "S" gnus-summary-limit-include-expunged
1664 "C" gnus-summary-catchup
1665 "H" gnus-summary-catchup-to-here
1666 "h" gnus-summary-catchup-from-here
1667 "\C-c" gnus-summary-catchup-all
1668 "k" gnus-summary-kill-same-subject-and-select
1669 "K" gnus-summary-kill-same-subject
1670 "P" gnus-uu-mark-map)
1672 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1673 "c" gnus-summary-clear-above
1674 "u" gnus-summary-tick-above
1675 "m" gnus-summary-mark-above
1676 "k" gnus-summary-kill-below)
1678 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1679 "/" gnus-summary-limit-to-subject
1680 "n" gnus-summary-limit-to-articles
1681 "w" gnus-summary-pop-limit
1682 "s" gnus-summary-limit-to-subject
1683 "a" gnus-summary-limit-to-author
1684 "u" gnus-summary-limit-to-unread
1685 "m" gnus-summary-limit-to-marks
1686 "M" gnus-summary-limit-exclude-marks
1687 "v" gnus-summary-limit-to-score
1688 "*" gnus-summary-limit-include-cached
1689 "D" gnus-summary-limit-include-dormant
1690 "T" gnus-summary-limit-include-thread
1691 "d" gnus-summary-limit-exclude-dormant
1692 "t" gnus-summary-limit-to-age
1693 "." gnus-summary-limit-to-unseen
1694 "x" gnus-summary-limit-to-extra
1695 "p" gnus-summary-limit-to-display-predicate
1696 "E" gnus-summary-limit-include-expunged
1697 "c" gnus-summary-limit-exclude-childless-dormant
1698 "C" gnus-summary-limit-mark-excluded-as-read
1699 "o" gnus-summary-insert-old-articles
1700 "N" gnus-summary-insert-new-articles)
1702 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1703 "n" gnus-summary-next-unread-article
1704 "p" gnus-summary-prev-unread-article
1705 "N" gnus-summary-next-article
1706 "P" gnus-summary-prev-article
1707 "\C-n" gnus-summary-next-same-subject
1708 "\C-p" gnus-summary-prev-same-subject
1709 "\M-n" gnus-summary-next-unread-subject
1710 "\M-p" gnus-summary-prev-unread-subject
1711 "f" gnus-summary-first-unread-article
1712 "b" gnus-summary-best-unread-article
1713 "j" gnus-summary-goto-article
1714 "g" gnus-summary-goto-subject
1715 "l" gnus-summary-goto-last-article
1716 "o" gnus-summary-pop-article)
1718 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1719 "k" gnus-summary-kill-thread
1720 "l" gnus-summary-lower-thread
1721 "i" gnus-summary-raise-thread
1722 "T" gnus-summary-toggle-threads
1723 "t" gnus-summary-rethread-current
1724 "^" gnus-summary-reparent-thread
1725 "s" gnus-summary-show-thread
1726 "S" gnus-summary-show-all-threads
1727 "h" gnus-summary-hide-thread
1728 "H" gnus-summary-hide-all-threads
1729 "n" gnus-summary-next-thread
1730 "p" gnus-summary-prev-thread
1731 "u" gnus-summary-up-thread
1732 "o" gnus-summary-top-thread
1733 "d" gnus-summary-down-thread
1734 "#" gnus-uu-mark-thread
1735 "\M-#" gnus-uu-unmark-thread)
1737 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1738 "g" gnus-summary-prepare
1739 "c" gnus-summary-insert-cached-articles
1740 "d" gnus-summary-insert-dormant-articles)
1742 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1743 "c" gnus-summary-catchup-and-exit
1744 "C" gnus-summary-catchup-all-and-exit
1745 "E" gnus-summary-exit-no-update
1746 "Q" gnus-summary-exit
1747 "Z" gnus-summary-exit
1748 "n" gnus-summary-catchup-and-goto-next-group
1749 "R" gnus-summary-reselect-current-group
1750 "G" gnus-summary-rescan-group
1751 "N" gnus-summary-next-group
1752 "s" gnus-summary-save-newsrc
1753 "P" gnus-summary-prev-group)
1755 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1756 " " gnus-summary-next-page
1757 "n" gnus-summary-next-page
1758 "\177" gnus-summary-prev-page
1759 [delete] gnus-summary-prev-page
1760 "p" gnus-summary-prev-page
1761 "\r" gnus-summary-scroll-up
1762 "\M-\r" gnus-summary-scroll-down
1763 "<" gnus-summary-beginning-of-article
1764 ">" gnus-summary-end-of-article
1765 "b" gnus-summary-beginning-of-article
1766 "e" gnus-summary-end-of-article
1767 "^" gnus-summary-refer-parent-article
1768 "r" gnus-summary-refer-parent-article
1769 "D" gnus-summary-enter-digest-group
1770 "R" gnus-summary-refer-references
1771 "T" gnus-summary-refer-thread
1772 "g" gnus-summary-show-article
1773 "s" gnus-summary-isearch-article
1774 "P" gnus-summary-print-article
1775 "M" gnus-mailing-list-insinuate
1776 "t" gnus-article-babel)
1778 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1779 "b" gnus-article-add-buttons
1780 "B" gnus-article-add-buttons-to-head
1781 "o" gnus-article-treat-overstrike
1782 "e" gnus-article-emphasize
1783 "w" gnus-article-fill-cited-article
1784 "Q" gnus-article-fill-long-lines
1785 "C" gnus-article-capitalize-sentences
1786 "c" gnus-article-remove-cr
1787 "q" gnus-article-de-quoted-unreadable
1788 "6" gnus-article-de-base64-unreadable
1789 "Z" gnus-article-decode-HZ
1790 "h" gnus-article-wash-html
1791 "u" gnus-article-unsplit-urls
1792 "s" gnus-summary-force-verify-and-decrypt
1793 "f" gnus-article-display-x-face
1794 "l" gnus-summary-stop-page-breaking
1795 "r" gnus-summary-caesar-message
1796 "m" gnus-summary-morse-message
1797 "t" gnus-summary-toggle-header
1798 "g" gnus-treat-smiley
1799 "v" gnus-summary-verbose-headers
1800 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1801 "p" gnus-article-verify-x-pgp-sig
1802 "d" gnus-article-treat-dumbquotes)
1804 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1805 ;; mnemonic: deuglif*Y*
1806 "u" gnus-article-outlook-unwrap-lines
1807 "a" gnus-article-outlook-repair-attribution
1808 "c" gnus-article-outlook-rearrange-citation
1809 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1811 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1812 "a" gnus-article-hide
1813 "h" gnus-article-hide-headers
1814 "b" gnus-article-hide-boring-headers
1815 "s" gnus-article-hide-signature
1816 "c" gnus-article-hide-citation
1817 "C" gnus-article-hide-citation-in-followups
1818 "l" gnus-article-hide-list-identifiers
1819 "B" gnus-article-strip-banner
1820 "P" gnus-article-hide-pem
1821 "\C-c" gnus-article-hide-citation-maybe)
1823 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1824 "a" gnus-article-highlight
1825 "h" gnus-article-highlight-headers
1826 "c" gnus-article-highlight-citation
1827 "s" gnus-article-highlight-signature)
1829 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1830 "f" gnus-article-treat-fold-headers
1831 "u" gnus-article-treat-unfold-headers
1832 "n" gnus-article-treat-fold-newsgroups)
1834 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1835 "x" gnus-article-display-x-face
1836 "d" gnus-article-display-face
1837 "s" gnus-treat-smiley
1838 "D" gnus-article-remove-images
1839 "f" gnus-treat-from-picon
1840 "m" gnus-treat-mail-picon
1841 "n" gnus-treat-newsgroups-picon)
1843 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1844 "w" gnus-article-decode-mime-words
1845 "c" gnus-article-decode-charset
1846 "v" gnus-mime-view-all-parts
1847 "b" gnus-article-view-part)
1849 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1850 "z" gnus-article-date-ut
1851 "u" gnus-article-date-ut
1852 "l" gnus-article-date-local
1853 "p" gnus-article-date-english
1854 "e" gnus-article-date-lapsed
1855 "o" gnus-article-date-original
1856 "i" gnus-article-date-iso8601
1857 "s" gnus-article-date-user)
1859 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1860 "t" gnus-article-remove-trailing-blank-lines
1861 "l" gnus-article-strip-leading-blank-lines
1862 "m" gnus-article-strip-multiple-blank-lines
1863 "a" gnus-article-strip-blank-lines
1864 "A" gnus-article-strip-all-blank-lines
1865 "s" gnus-article-strip-leading-space
1866 "e" gnus-article-strip-trailing-space
1867 "w" gnus-article-remove-leading-whitespace)
1869 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1871 "f" gnus-summary-fetch-faq
1872 "d" gnus-summary-describe-group
1873 "h" gnus-summary-describe-briefly
1874 "i" gnus-info-find-node
1875 "c" gnus-group-fetch-charter
1876 "C" gnus-group-fetch-control)
1878 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1879 "e" gnus-summary-expire-articles
1880 "\M-\C-e" gnus-summary-expire-articles-now
1881 "\177" gnus-summary-delete-article
1882 [delete] gnus-summary-delete-article
1883 [backspace] gnus-summary-delete-article
1884 "m" gnus-summary-move-article
1885 "r" gnus-summary-respool-article
1886 "w" gnus-summary-edit-article
1887 "c" gnus-summary-copy-article
1888 "B" gnus-summary-crosspost-article
1889 "q" gnus-summary-respool-query
1890 "t" gnus-summary-respool-trace
1891 "i" gnus-summary-import-article
1892 "I" gnus-summary-create-article
1893 "p" gnus-summary-article-posted-p)
1895 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1896 "o" gnus-summary-save-article
1897 "m" gnus-summary-save-article-mail
1898 "F" gnus-summary-write-article-file
1899 "r" gnus-summary-save-article-rmail
1900 "f" gnus-summary-save-article-file
1901 "b" gnus-summary-save-article-body-file
1902 "h" gnus-summary-save-article-folder
1903 "v" gnus-summary-save-article-vm
1904 "p" gnus-summary-pipe-output
1905 "P" gnus-summary-muttprint
1906 "s" gnus-soup-add-article)
1908 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1909 "b" gnus-summary-display-buttonized
1910 "m" gnus-summary-repair-multipart
1911 "v" gnus-article-view-part
1912 "o" gnus-article-save-part
1913 "c" gnus-article-copy-part
1914 "C" gnus-article-view-part-as-charset
1915 "e" gnus-article-view-part-externally
1916 "E" gnus-article-encrypt-body
1917 "i" gnus-article-inline-part
1918 "|" gnus-article-pipe-part)
1920 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1921 "p" gnus-summary-mark-as-processable
1922 "u" gnus-summary-unmark-as-processable
1923 "U" gnus-summary-unmark-all-processable
1924 "v" gnus-uu-mark-over
1925 "s" gnus-uu-mark-series
1926 "r" gnus-uu-mark-region
1927 "g" gnus-uu-unmark-region
1928 "R" gnus-uu-mark-by-regexp
1929 "G" gnus-uu-unmark-by-regexp
1930 "t" gnus-uu-mark-thread
1931 "T" gnus-uu-unmark-thread
1932 "a" gnus-uu-mark-all
1933 "b" gnus-uu-mark-buffer
1934 "S" gnus-uu-mark-sparse
1935 "k" gnus-summary-kill-process-mark
1936 "y" gnus-summary-yank-process-mark
1937 "w" gnus-summary-save-process-mark
1938 "i" gnus-uu-invert-processable)
1940 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1941 ;;"x" gnus-uu-extract-any
1942 "m" gnus-summary-save-parts
1943 "u" gnus-uu-decode-uu
1944 "U" gnus-uu-decode-uu-and-save
1945 "s" gnus-uu-decode-unshar
1946 "S" gnus-uu-decode-unshar-and-save
1947 "o" gnus-uu-decode-save
1948 "O" gnus-uu-decode-save
1949 "b" gnus-uu-decode-binhex
1950 "B" gnus-uu-decode-binhex
1951 "p" gnus-uu-decode-postscript
1952 "P" gnus-uu-decode-postscript-and-save)
1955 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1956 "u" gnus-uu-decode-uu-view
1957 "U" gnus-uu-decode-uu-and-save-view
1958 "s" gnus-uu-decode-unshar-view
1959 "S" gnus-uu-decode-unshar-and-save-view
1960 "o" gnus-uu-decode-save-view
1961 "O" gnus-uu-decode-save-view
1962 "b" gnus-uu-decode-binhex-view
1963 "B" gnus-uu-decode-binhex-view
1964 "p" gnus-uu-decode-postscript-view
1965 "P" gnus-uu-decode-postscript-and-save-view)
1967 (defvar gnus-article-post-menu nil)
1969 (defconst gnus-summary-menu-maxlen 20)
1971 (defun gnus-summary-menu-split (menu)
1972 ;; If we have lots of elements, divide them into groups of 20
1973 ;; and make a pane (or submenu) for each one.
1974 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1975 (let ((menu menu) sublists next
1978 ;; Pull off the next gnus-summary-menu-maxlen elements
1979 ;; and make them the next element of sublist.
1980 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1982 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1984 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1985 (aref (car (last menu)) 0)) menu)
1989 (nreverse sublists))
1990 ;; Few elements--put them all in one pane.
1993 (defun gnus-summary-make-menu-bar ()
1994 (gnus-turn-off-edit-menu 'summary)
1996 (unless (boundp 'gnus-summary-misc-menu)
1999 gnus-summary-kill-menu gnus-summary-mode-map ""
2004 ["Customize" gnus-score-customize t])
2005 (gnus-make-score-map 'increase)
2006 (gnus-make-score-map 'lower)
2008 ["Kill below" gnus-summary-kill-below t]
2009 ["Mark above" gnus-summary-mark-above t]
2010 ["Tick above" gnus-summary-tick-above t]
2011 ["Clear above" gnus-summary-clear-above t])
2012 ["Current score" gnus-summary-current-score t]
2013 ["Set score" gnus-summary-set-score t]
2014 ["Switch current score file..." gnus-score-change-score-file t]
2015 ["Set mark below..." gnus-score-set-mark-below t]
2016 ["Set expunge below..." gnus-score-set-expunge-below t]
2017 ["Edit current score file" gnus-score-edit-current-scores t]
2018 ["Edit score file" gnus-score-edit-file t]
2019 ["Trace score" gnus-score-find-trace t]
2020 ["Find words" gnus-score-find-favourite-words t]
2021 ["Rescore buffer" gnus-summary-rescore t]
2022 ["Increase score..." gnus-summary-increase-score t]
2023 ["Lower score..." gnus-summary-lower-score t]))))
2025 ;; Define both the Article menu in the summary buffer and the
2026 ;; equivalent Commands menu in the article buffer here for
2030 ["All" gnus-article-hide t]
2031 ["Headers" gnus-article-hide-headers t]
2032 ["Signature" gnus-article-hide-signature t]
2033 ["Citation" gnus-article-hide-citation t]
2034 ["List identifiers" gnus-article-hide-list-identifiers t]
2035 ["Banner" gnus-article-strip-banner t]
2036 ["Boring headers" gnus-article-hide-boring-headers t])
2038 ["All" gnus-article-highlight t]
2039 ["Headers" gnus-article-highlight-headers t]
2040 ["Signature" gnus-article-highlight-signature t]
2041 ["Citation" gnus-article-highlight-citation t])
2043 ["Words" gnus-article-decode-mime-words t]
2044 ["Charset" gnus-article-decode-charset t]
2045 ["QP" gnus-article-de-quoted-unreadable t]
2046 ["Base64" gnus-article-de-base64-unreadable t]
2047 ["View MIME buttons" gnus-summary-display-buttonized t]
2048 ["View all" gnus-mime-view-all-parts t]
2049 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2050 ["Encrypt body" gnus-article-encrypt-body t]
2051 ["Extract all parts" gnus-summary-save-parts t])
2053 ["Local" gnus-article-date-local t]
2054 ["ISO8601" gnus-article-date-iso8601 t]
2055 ["UT" gnus-article-date-ut t]
2056 ["Original" gnus-article-date-original t]
2057 ["Lapsed" gnus-article-date-lapsed t]
2058 ["User-defined" gnus-article-date-user t])
2060 ["Remove images" gnus-article-remove-images t]
2061 ["Toggle smiley" gnus-treat-smiley t]
2062 ["Show X-Face" gnus-article-display-x-face t]
2063 ["Show picons in From" gnus-treat-from-picon t]
2064 ["Show picons in mail headers" gnus-treat-mail-picon t]
2065 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2066 ("View as different encoding"
2067 ,@(gnus-summary-menu-split
2070 ;; Since easymenu under FSF Emacs doesn't allow lambda
2071 ;; forms for menu commands, we should provide intern'ed
2072 ;; function symbols.
2073 (let ((command (intern (format "\
2074 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2078 (let ((gnus-summary-show-article-charset-alist
2080 (gnus-summary-show-article 1))))
2081 `[,(symbol-name cs) ,command t]))
2082 (sort (if (fboundp 'coding-system-list)
2083 (coding-system-list)
2084 (mapcar 'car mm-mime-mule-charset-alist))
2088 ["Leading" gnus-article-strip-leading-blank-lines t]
2089 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2090 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2091 ["All of the above" gnus-article-strip-blank-lines t]
2092 ["All" gnus-article-strip-all-blank-lines t]
2093 ["Leading space" gnus-article-strip-leading-space t]
2094 ["Trailing space" gnus-article-strip-trailing-space t]
2095 ["Leading space in headers"
2096 gnus-article-remove-leading-whitespace t])
2097 ["Overstrike" gnus-article-treat-overstrike t]
2098 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2099 ["Emphasis" gnus-article-emphasize t]
2100 ["Word wrap" gnus-article-fill-cited-article t]
2101 ["Fill long lines" gnus-article-fill-long-lines t]
2102 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2103 ["CR" gnus-article-remove-cr t]
2104 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2105 ["Base64" gnus-article-de-base64-unreadable t]
2106 ["Rot 13" gnus-summary-caesar-message
2107 ,@(if (featurep 'xemacs) '(t)
2108 '(:help "\"Caesar rotate\" article by 13"))]
2109 ["Morse decode" gnus-summary-morse-message t]
2110 ["Unix pipe..." gnus-summary-pipe-message t]
2111 ["Add buttons" gnus-article-add-buttons t]
2112 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2113 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2114 ["Verbose header" gnus-summary-verbose-headers t]
2115 ["Toggle header" gnus-summary-toggle-header t]
2116 ["Unfold headers" gnus-article-treat-unfold-headers t]
2117 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2118 ["Html" gnus-article-wash-html t]
2119 ["URLs" gnus-article-unsplit-urls t]
2120 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2121 ["HZ" gnus-article-decode-HZ t]
2122 ("(Outlook) Deuglify"
2123 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2124 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2125 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2126 ["Full (Outlook) deuglify"
2127 gnus-article-outlook-deuglify-article t])
2130 ["Save in default format" gnus-summary-save-article
2131 ,@(if (featurep 'xemacs) '(t)
2132 '(:help "Save article using default method"))]
2133 ["Save in file" gnus-summary-save-article-file
2134 ,@(if (featurep 'xemacs) '(t)
2135 '(:help "Save article in file"))]
2136 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2137 ["Save in MH folder" gnus-summary-save-article-folder t]
2138 ["Save in VM folder" gnus-summary-save-article-vm t]
2139 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2140 ["Save body in file" gnus-summary-save-article-body-file t]
2141 ["Pipe through a filter" gnus-summary-pipe-output t]
2142 ["Add to SOUP packet" gnus-soup-add-article t]
2143 ["Print with Muttprint" gnus-summary-muttprint t]
2144 ["Print" gnus-summary-print-article t])
2146 ["Respool article..." gnus-summary-respool-article t]
2147 ["Move article..." gnus-summary-move-article
2148 (gnus-check-backend-function
2149 'request-move-article gnus-newsgroup-name)]
2150 ["Copy article..." gnus-summary-copy-article t]
2151 ["Crosspost article..." gnus-summary-crosspost-article
2152 (gnus-check-backend-function
2153 'request-replace-article gnus-newsgroup-name)]
2154 ["Import file..." gnus-summary-import-article t]
2155 ["Create article..." gnus-summary-create-article t]
2156 ["Check if posted" gnus-summary-article-posted-p t]
2157 ["Edit article" gnus-summary-edit-article
2158 (not (gnus-group-read-only-p))]
2159 ["Delete article" gnus-summary-delete-article
2160 (gnus-check-backend-function
2161 'request-expire-articles gnus-newsgroup-name)]
2162 ["Query respool" gnus-summary-respool-query t]
2163 ["Trace respool" gnus-summary-respool-trace t]
2164 ["Delete expirable articles" gnus-summary-expire-articles-now
2165 (gnus-check-backend-function
2166 'request-expire-articles gnus-newsgroup-name)])
2168 ["Uudecode" gnus-uu-decode-uu
2169 ,@(if (featurep 'xemacs) '(t)
2170 '(:help "Decode uuencoded article(s)"))]
2171 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2172 ["Unshar" gnus-uu-decode-unshar t]
2173 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2174 ["Save" gnus-uu-decode-save t]
2175 ["Binhex" gnus-uu-decode-binhex t]
2176 ["Postscript" gnus-uu-decode-postscript t]
2177 ["All MIME parts" gnus-summary-save-parts t])
2179 ["Enter article" gnus-cache-enter-article t]
2180 ["Remove article" gnus-cache-remove-article t])
2181 ["Translate" gnus-article-babel t]
2182 ["Select article buffer" gnus-summary-select-article-buffer t]
2183 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2184 ["Isearch article..." gnus-summary-isearch-article t]
2185 ["Beginning of the article" gnus-summary-beginning-of-article t]
2186 ["End of the article" gnus-summary-end-of-article t]
2187 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2188 ["Fetch referenced articles" gnus-summary-refer-references t]
2189 ["Fetch current thread" gnus-summary-refer-thread t]
2190 ["Fetch article with id..." gnus-summary-refer-article t]
2191 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2192 ["Redisplay" gnus-summary-show-article t]
2193 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2195 gnus-summary-article-menu gnus-summary-mode-map ""
2196 (cons "Article" innards))
2198 (if (not (keymapp gnus-summary-article-menu))
2200 gnus-article-commands-menu gnus-article-mode-map ""
2201 (cons "Commands" innards))
2202 ;; in Emacs, don't share menu.
2203 (setq gnus-article-commands-menu
2204 (copy-keymap gnus-summary-article-menu))
2205 (define-key gnus-article-mode-map [menu-bar commands]
2206 (cons "Commands" gnus-article-commands-menu))))
2209 gnus-summary-thread-menu gnus-summary-mode-map ""
2211 ["Find all messages in thread" gnus-summary-refer-thread t]
2212 ["Toggle threading" gnus-summary-toggle-threads t]
2213 ["Hide threads" gnus-summary-hide-all-threads t]
2214 ["Show threads" gnus-summary-show-all-threads t]
2215 ["Hide thread" gnus-summary-hide-thread t]
2216 ["Show thread" gnus-summary-show-thread t]
2217 ["Go to next thread" gnus-summary-next-thread t]
2218 ["Go to previous thread" gnus-summary-prev-thread t]
2219 ["Go down thread" gnus-summary-down-thread t]
2220 ["Go up thread" gnus-summary-up-thread t]
2221 ["Top of thread" gnus-summary-top-thread t]
2222 ["Mark thread as read" gnus-summary-kill-thread t]
2223 ["Lower thread score" gnus-summary-lower-thread t]
2224 ["Raise thread score" gnus-summary-raise-thread t]
2225 ["Rethread current" gnus-summary-rethread-current t]))
2228 gnus-summary-post-menu gnus-summary-mode-map ""
2230 ["Send a message (mail or news)" gnus-summary-post-news
2231 ,@(if (featurep 'xemacs) '(t)
2232 '(:help "Post an article"))]
2233 ["Followup" gnus-summary-followup
2234 ,@(if (featurep 'xemacs) '(t)
2235 '(:help "Post followup to this article"))]
2236 ["Followup and yank" gnus-summary-followup-with-original
2237 ,@(if (featurep 'xemacs) '(t)
2238 '(:help "Post followup to this article, quoting its contents"))]
2239 ["Supersede article" gnus-summary-supersede-article t]
2240 ["Cancel article" gnus-summary-cancel-article
2241 ,@(if (featurep 'xemacs) '(t)
2242 '(:help "Cancel an article you posted"))]
2243 ["Reply" gnus-summary-reply t]
2244 ["Reply and yank" gnus-summary-reply-with-original t]
2245 ["Wide reply" gnus-summary-wide-reply t]
2246 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2247 ,@(if (featurep 'xemacs) '(t)
2248 '(:help "Mail a reply, quoting this article"))]
2249 ["Very wide reply" gnus-summary-very-wide-reply t]
2250 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2251 ,@(if (featurep 'xemacs) '(t)
2252 '(:help "Mail a very wide reply, quoting this article"))]
2253 ["Mail forward" gnus-summary-mail-forward t]
2254 ["Post forward" gnus-summary-post-forward t]
2255 ["Digest and mail" gnus-uu-digest-mail-forward t]
2256 ["Digest and post" gnus-uu-digest-post-forward t]
2257 ["Resend message" gnus-summary-resend-message t]
2258 ["Resend message edit" gnus-summary-resend-message-edit t]
2259 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2260 ["Send a mail" gnus-summary-mail-other-window t]
2261 ["Create a local message" gnus-summary-news-other-window t]
2262 ["Uuencode and post" gnus-uu-post-news
2263 ,@(if (featurep 'xemacs) '(t)
2264 '(:help "Post a uuencoded article"))]
2265 ["Followup via news" gnus-summary-followup-to-mail t]
2266 ["Followup via news and yank"
2267 gnus-summary-followup-to-mail-with-original t]
2269 ;;["Send" gnus-summary-send-draft t]
2270 ;;["Send bounced" gnus-resend-bounced-mail t])
2274 ((not (keymapp gnus-summary-post-menu))
2275 (setq gnus-article-post-menu gnus-summary-post-menu))
2276 ((not gnus-article-post-menu)
2277 ;; Don't share post menu.
2278 (setq gnus-article-post-menu
2279 (copy-keymap gnus-summary-post-menu))))
2280 (define-key gnus-article-mode-map [menu-bar post]
2281 (cons "Post" gnus-article-post-menu))
2284 gnus-summary-misc-menu gnus-summary-mode-map ""
2287 ["Mark as read" gnus-summary-mark-as-read-forward t]
2288 ["Mark same subject and select"
2289 gnus-summary-kill-same-subject-and-select t]
2290 ["Mark same subject" gnus-summary-kill-same-subject t]
2291 ["Catchup" gnus-summary-catchup
2292 ,@(if (featurep 'xemacs) '(t)
2293 '(:help "Mark unread articles in this group as read"))]
2294 ["Catchup all" gnus-summary-catchup-all t]
2295 ["Catchup to here" gnus-summary-catchup-to-here t]
2296 ["Catchup from here" gnus-summary-catchup-from-here t]
2297 ["Catchup region" gnus-summary-mark-region-as-read
2298 (gnus-mark-active-p)]
2299 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2301 ["Tick" gnus-summary-tick-article-forward t]
2302 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2303 ["Remove marks" gnus-summary-clear-mark-forward t]
2304 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2305 ["Set bookmark" gnus-summary-set-bookmark t]
2306 ["Remove bookmark" gnus-summary-remove-bookmark t])
2308 ["Marks..." gnus-summary-limit-to-marks t]
2309 ["Subject..." gnus-summary-limit-to-subject t]
2310 ["Author..." gnus-summary-limit-to-author t]
2311 ["Age..." gnus-summary-limit-to-age t]
2312 ["Extra..." gnus-summary-limit-to-extra t]
2313 ["Score..." gnus-summary-limit-to-score t]
2314 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2315 ["Unread" gnus-summary-limit-to-unread t]
2316 ["Unseen" gnus-summary-limit-to-unseen t]
2317 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2318 ["Next articles" gnus-summary-limit-to-articles t]
2319 ["Pop limit" gnus-summary-pop-limit t]
2320 ["Show dormant" gnus-summary-limit-include-dormant t]
2321 ["Hide childless dormant"
2322 gnus-summary-limit-exclude-childless-dormant t]
2323 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2324 ["Hide marked" gnus-summary-limit-exclude-marks t]
2325 ["Show expunged" gnus-summary-limit-include-expunged t])
2327 ["Set mark" gnus-summary-mark-as-processable t]
2328 ["Remove mark" gnus-summary-unmark-as-processable t]
2329 ["Remove all marks" gnus-summary-unmark-all-processable t]
2330 ["Mark above" gnus-uu-mark-over t]
2331 ["Mark series" gnus-uu-mark-series t]
2332 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2333 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2334 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2335 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2336 ["Mark all" gnus-uu-mark-all t]
2337 ["Mark buffer" gnus-uu-mark-buffer t]
2338 ["Mark sparse" gnus-uu-mark-sparse t]
2339 ["Mark thread" gnus-uu-mark-thread t]
2340 ["Unmark thread" gnus-uu-unmark-thread t]
2341 ("Process Mark Sets"
2342 ["Kill" gnus-summary-kill-process-mark t]
2343 ["Yank" gnus-summary-yank-process-mark
2344 gnus-newsgroup-process-stack]
2345 ["Save" gnus-summary-save-process-mark t]
2346 ["Run command on marked..." gnus-summary-universal-argument t]))
2348 ["Page forward" gnus-summary-next-page
2349 ,@(if (featurep 'xemacs) '(t)
2350 '(:help "Show next page of article"))]
2351 ["Page backward" gnus-summary-prev-page
2352 ,@(if (featurep 'xemacs) '(t)
2353 '(:help "Show previous page of article"))]
2354 ["Line forward" gnus-summary-scroll-up t])
2356 ["Next unread article" gnus-summary-next-unread-article t]
2357 ["Previous unread article" gnus-summary-prev-unread-article t]
2358 ["Next article" gnus-summary-next-article t]
2359 ["Previous article" gnus-summary-prev-article t]
2360 ["Next unread subject" gnus-summary-next-unread-subject t]
2361 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2362 ["Next article same subject" gnus-summary-next-same-subject t]
2363 ["Previous article same subject" gnus-summary-prev-same-subject t]
2364 ["First unread article" gnus-summary-first-unread-article t]
2365 ["Best unread article" gnus-summary-best-unread-article t]
2366 ["Go to subject number..." gnus-summary-goto-subject t]
2367 ["Go to article number..." gnus-summary-goto-article t]
2368 ["Go to the last article" gnus-summary-goto-last-article t]
2369 ["Pop article off history" gnus-summary-pop-article t])
2371 ["Sort by number" gnus-summary-sort-by-number t]
2372 ["Sort by author" gnus-summary-sort-by-author t]
2373 ["Sort by subject" gnus-summary-sort-by-subject t]
2374 ["Sort by date" gnus-summary-sort-by-date t]
2375 ["Sort by score" gnus-summary-sort-by-score t]
2376 ["Sort by lines" gnus-summary-sort-by-lines t]
2377 ["Sort by characters" gnus-summary-sort-by-chars t]
2378 ["Randomize" gnus-summary-sort-by-random t]
2379 ["Original sort" gnus-summary-sort-by-original t])
2381 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2382 ["Describe group" gnus-summary-describe-group t]
2383 ["Fetch charter" gnus-group-fetch-charter
2384 ,@(if (featurep 'xemacs) nil
2385 '(:help "Display the charter of the current group"))]
2386 ["Fetch control message" gnus-group-fetch-control
2387 ,@(if (featurep 'xemacs) nil
2388 '(:help "Display the archived control message for the current group"))]
2389 ["Read manual" gnus-info-find-node t])
2391 ["Pick and read" gnus-pick-mode t]
2392 ["Binary" gnus-binary-mode t])
2394 ["Regenerate" gnus-summary-prepare t]
2395 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2396 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2397 ["Toggle threading" gnus-summary-toggle-threads t])
2398 ["See old articles" gnus-summary-insert-old-articles t]
2399 ["See new articles" gnus-summary-insert-new-articles t]
2400 ["Filter articles..." gnus-summary-execute-command t]
2401 ["Run command on articles..." gnus-summary-universal-argument t]
2402 ["Search articles forward..." gnus-summary-search-article-forward t]
2403 ["Search articles backward..." gnus-summary-search-article-backward t]
2404 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2405 ["Expand window" gnus-summary-expand-window t]
2406 ["Expire expirable articles" gnus-summary-expire-articles
2407 (gnus-check-backend-function
2408 'request-expire-articles gnus-newsgroup-name)]
2409 ["Edit local kill file" gnus-summary-edit-local-kill t]
2410 ["Edit main kill file" gnus-summary-edit-global-kill t]
2411 ["Edit group parameters" gnus-summary-edit-parameters t]
2412 ["Customize group parameters" gnus-summary-customize-parameters t]
2413 ["Send a bug report" gnus-bug t]
2415 ["Catchup and exit" gnus-summary-catchup-and-exit
2416 ,@(if (featurep 'xemacs) '(t)
2417 '(:help "Mark unread articles in this group as read, then exit"))]
2418 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2419 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2420 ["Exit group" gnus-summary-exit
2421 ,@(if (featurep 'xemacs) '(t)
2422 '(:help "Exit current group, return to group selection mode"))]
2423 ["Exit group without updating" gnus-summary-exit-no-update t]
2424 ["Exit and goto next group" gnus-summary-next-group t]
2425 ["Exit and goto prev group" gnus-summary-prev-group t]
2426 ["Reselect group" gnus-summary-reselect-current-group t]
2427 ["Rescan group" gnus-summary-rescan-group t]
2428 ["Update dribble" gnus-summary-save-newsrc t])))
2430 (gnus-run-hooks 'gnus-summary-menu-hook)))
2432 (defvar gnus-summary-tool-bar-map nil)
2434 ;; Emacs 21 tool bar. Should be no-op otherwise.
2435 (defun gnus-summary-make-tool-bar ()
2436 (if (and (fboundp 'tool-bar-add-item-from-menu)
2437 (default-value 'tool-bar-mode)
2438 (not gnus-summary-tool-bar-map))
2439 (setq gnus-summary-tool-bar-map
2440 (let ((tool-bar-map (make-sparse-keymap))
2441 (load-path (mm-image-load-path)))
2442 (tool-bar-add-item-from-menu
2443 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2444 (tool-bar-add-item-from-menu
2445 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2446 (tool-bar-add-item-from-menu
2447 'gnus-summary-post-news "post" gnus-summary-mode-map)
2448 (tool-bar-add-item-from-menu
2449 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2450 (tool-bar-add-item-from-menu
2451 'gnus-summary-followup "followup" gnus-summary-mode-map)
2452 (tool-bar-add-item-from-menu
2453 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2454 (tool-bar-add-item-from-menu
2455 'gnus-summary-reply "reply" gnus-summary-mode-map)
2456 (tool-bar-add-item-from-menu
2457 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2458 (tool-bar-add-item-from-menu
2459 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2460 (tool-bar-add-item-from-menu
2461 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2462 (tool-bar-add-item-from-menu
2463 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2464 (tool-bar-add-item-from-menu
2465 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2466 (tool-bar-add-item-from-menu
2467 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2468 (tool-bar-add-item-from-menu
2469 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2470 (tool-bar-add-item-from-menu
2471 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2473 (if gnus-summary-tool-bar-map
2474 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2476 (defun gnus-score-set-default (var value)
2477 "A version of set that updates the GNU Emacs menu-bar."
2479 ;; It is the message that forces the active status to be updated.
2482 (defun gnus-make-score-map (type)
2483 "Make a summary score map of type TYPE."
2486 (let ((headers '(("author" "from" string)
2487 ("subject" "subject" string)
2488 ("article body" "body" string)
2489 ("article head" "head" string)
2490 ("xref" "xref" string)
2491 ("extra header" "extra" string)
2492 ("lines" "lines" number)
2493 ("followups to author" "followup" string)))
2494 (types '((number ("less than" <)
2497 (string ("substring" s)
2501 (perms '(("temporary" (current-time-string))
2509 (if (eq type 'lower)
2514 (setq header (car headers))
2520 (let ((ts (cdr (assoc (nth 2 header) types)))
2536 'gnus-summary-score-entry
2538 (if (or (string= (nth 1 header)
2540 (string= (nth 1 header)
2543 (list 'gnus-summary-header
2545 (list 'quote (nth 1 (car ts)))
2546 (list 'gnus-score-delta-default
2553 (list (nreverse outp))))
2556 (list (nreverse outt))))
2558 (setq headers (cdr headers)))
2559 (list (nreverse outh))))))))
2563 (defun gnus-summary-mode (&optional group)
2564 "Major mode for reading articles.
2566 All normal editing commands are switched off.
2567 \\<gnus-summary-mode-map>
2568 Each line in this buffer represents one article. To read an
2569 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2570 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2573 You can also post articles and send mail from this buffer. To
2574 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2575 of an article, type `\\[gnus-summary-reply]'.
2577 There are approx. one gazillion commands you can execute in this
2578 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2580 The following commands are available:
2582 \\{gnus-summary-mode-map}"
2584 (kill-all-local-variables)
2585 (when (gnus-visual-p 'summary-menu 'menu)
2586 (gnus-summary-make-menu-bar)
2587 (gnus-summary-make-tool-bar))
2588 (gnus-summary-make-local-variables)
2589 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2590 (gnus-summary-make-local-variables))
2591 (gnus-make-thread-indent-array)
2592 (gnus-simplify-mode-line)
2593 (setq major-mode 'gnus-summary-mode)
2594 (setq mode-name "Summary")
2595 (make-local-variable 'minor-mode-alist)
2596 (use-local-map gnus-summary-mode-map)
2597 (buffer-disable-undo)
2598 (setq buffer-read-only t) ;Disable modification
2599 (setq truncate-lines t)
2600 (setq selective-display t)
2601 (setq selective-display-ellipses t) ;Display `...'
2602 (gnus-summary-set-display-table)
2603 (gnus-set-default-directory)
2604 (setq gnus-newsgroup-name group)
2605 (make-local-variable 'gnus-summary-line-format)
2606 (make-local-variable 'gnus-summary-line-format-spec)
2607 (make-local-variable 'gnus-summary-dummy-line-format)
2608 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2609 (make-local-variable 'gnus-summary-mark-positions)
2610 (make-local-hook 'pre-command-hook)
2611 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2612 (gnus-run-hooks 'gnus-summary-mode-hook)
2613 (turn-on-gnus-mailing-list-mode)
2614 (mm-enable-multibyte)
2615 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2616 (gnus-update-summary-mark-positions))
2618 (defun gnus-summary-make-local-variables ()
2619 "Make all the local summary buffer variables."
2621 (dolist (local gnus-summary-local-variables)
2624 (if (eq (cdr local) 'global)
2625 ;; Copy the global value of the variable.
2626 (setq global (symbol-value (car local)))
2627 ;; Use the value from the list.
2628 (setq global (eval (cdr local))))
2629 (set (make-local-variable (car local)) global))
2630 ;; Simple nil-valued local variable.
2631 (set (make-local-variable local) nil)))))
2633 (defun gnus-summary-clear-local-variables ()
2634 (let ((locals gnus-summary-local-variables))
2636 (if (consp (car locals))
2637 (and (vectorp (caar locals))
2638 (set (caar locals) nil))
2639 (and (vectorp (car locals))
2640 (set (car locals) nil)))
2641 (setq locals (cdr locals)))))
2643 ;; Summary data functions.
2645 (defmacro gnus-data-number (data)
2648 (defmacro gnus-data-set-number (data number)
2649 `(setcar ,data ,number))
2651 (defmacro gnus-data-mark (data)
2654 (defmacro gnus-data-set-mark (data mark)
2655 `(setcar (nthcdr 1 ,data) ,mark))
2657 (defmacro gnus-data-pos (data)
2660 (defmacro gnus-data-set-pos (data pos)
2661 `(setcar (nthcdr 2 ,data) ,pos))
2663 (defmacro gnus-data-header (data)
2666 (defmacro gnus-data-set-header (data header)
2667 `(setf (nth 3 ,data) ,header))
2669 (defmacro gnus-data-level (data)
2672 (defmacro gnus-data-unread-p (data)
2673 `(= (nth 1 ,data) gnus-unread-mark))
2675 (defmacro gnus-data-read-p (data)
2676 `(/= (nth 1 ,data) gnus-unread-mark))
2678 (defmacro gnus-data-pseudo-p (data)
2679 `(consp (nth 3 ,data)))
2681 (defmacro gnus-data-find (number)
2682 `(assq ,number gnus-newsgroup-data))
2684 (defmacro gnus-data-find-list (number &optional data)
2685 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2686 (memq (assq ,number bdata)
2689 (defmacro gnus-data-make (number mark pos header level)
2690 `(list ,number ,mark ,pos ,header ,level))
2692 (defun gnus-data-enter (after-article number mark pos header level offset)
2693 (let ((data (gnus-data-find-list after-article)))
2695 (error "No such article: %d" after-article))
2696 (setcdr data (cons (gnus-data-make number mark pos header level)
2698 (setq gnus-newsgroup-data-reverse nil)
2699 (gnus-data-update-list (cddr data) offset)))
2701 (defun gnus-data-enter-list (after-article list &optional offset)
2703 (let ((data (and after-article (gnus-data-find-list after-article)))
2707 (let ((odata gnus-newsgroup-data))
2708 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2710 (gnus-data-update-list odata offset)))
2711 ;; Find the last element in the list to be spliced into the main
2714 (setq list (cdr list)))
2717 (setcdr list gnus-newsgroup-data)
2718 (setq gnus-newsgroup-data ilist)
2720 (gnus-data-update-list (cdr list) offset)))
2721 (setcdr list (cdr data))
2724 (gnus-data-update-list (cdr list) offset))))
2725 (setq gnus-newsgroup-data-reverse nil))))
2727 (defun gnus-data-remove (article &optional offset)
2728 (let ((data gnus-newsgroup-data))
2729 (if (= (gnus-data-number (car data)) article)
2731 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2732 gnus-newsgroup-data-reverse nil)
2734 (gnus-data-update-list gnus-newsgroup-data offset)))
2736 (when (= (gnus-data-number (cadr data)) article)
2737 (setcdr data (cddr data))
2739 (gnus-data-update-list (cdr data) offset))
2741 gnus-newsgroup-data-reverse nil))
2742 (setq data (cdr data))))))
2744 (defmacro gnus-data-list (backward)
2746 (or gnus-newsgroup-data-reverse
2747 (setq gnus-newsgroup-data-reverse
2748 (reverse gnus-newsgroup-data)))
2749 gnus-newsgroup-data))
2751 (defun gnus-data-update-list (data offset)
2752 "Add OFFSET to the POS of all data entries in DATA."
2753 (setq gnus-newsgroup-data-reverse nil)
2755 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2756 (setq data (cdr data))))
2758 (defun gnus-summary-article-pseudo-p (article)
2759 "Say whether this article is a pseudo article or not."
2760 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2762 (defmacro gnus-summary-article-sparse-p (article)
2763 "Say whether this article is a sparse article or not."
2764 `(memq ,article gnus-newsgroup-sparse))
2766 (defmacro gnus-summary-article-ancient-p (article)
2767 "Say whether this article is a sparse article or not."
2768 `(memq ,article gnus-newsgroup-ancient))
2770 (defun gnus-article-parent-p (number)
2771 "Say whether this article is a parent or not."
2772 (let ((data (gnus-data-find-list number)))
2773 (and (cdr data) ; There has to be an article after...
2774 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2775 (gnus-data-level (nth 1 data))))))
2777 (defun gnus-article-children (number)
2778 "Return a list of all children to NUMBER."
2779 (let* ((data (gnus-data-find-list number))
2780 (level (gnus-data-level (car data)))
2782 (setq data (cdr data))
2784 (= (gnus-data-level (car data)) (1+ level)))
2785 (push (gnus-data-number (car data)) children)
2786 (setq data (cdr data)))
2789 (defmacro gnus-summary-skip-intangible ()
2790 "If the current article is intangible, then jump to a different article."
2791 '(let ((to (get-text-property (point) 'gnus-intangible)))
2792 (and to (gnus-summary-goto-subject to))))
2794 (defmacro gnus-summary-article-intangible-p ()
2795 "Say whether this article is intangible or not."
2796 '(get-text-property (point) 'gnus-intangible))
2798 (defun gnus-article-read-p (article)
2799 "Say whether ARTICLE is read or not."
2800 (not (or (memq article gnus-newsgroup-marked)
2801 (memq article gnus-newsgroup-spam-marked)
2802 (memq article gnus-newsgroup-unreads)
2803 (memq article gnus-newsgroup-unselected)
2804 (memq article gnus-newsgroup-dormant))))
2806 ;; Some summary mode macros.
2808 (defmacro gnus-summary-article-number ()
2809 "The article number of the article on the current line.
2810 If there isn't an article number here, then we return the current
2813 (gnus-summary-skip-intangible)
2814 (or (get-text-property (point) 'gnus-number)
2815 (gnus-summary-last-subject))))
2817 (defmacro gnus-summary-article-header (&optional number)
2818 "Return the header of article NUMBER."
2819 `(gnus-data-header (gnus-data-find
2820 ,(or number '(gnus-summary-article-number)))))
2822 (defmacro gnus-summary-thread-level (&optional number)
2823 "Return the level of thread that starts with article NUMBER."
2824 `(if (and (eq gnus-summary-make-false-root 'dummy)
2825 (get-text-property (point) 'gnus-intangible))
2827 (gnus-data-level (gnus-data-find
2828 ,(or number '(gnus-summary-article-number))))))
2830 (defmacro gnus-summary-article-mark (&optional number)
2831 "Return the mark of article NUMBER."
2832 `(gnus-data-mark (gnus-data-find
2833 ,(or number '(gnus-summary-article-number)))))
2835 (defmacro gnus-summary-article-pos (&optional number)
2836 "Return the position of the line of article NUMBER."
2837 `(gnus-data-pos (gnus-data-find
2838 ,(or number '(gnus-summary-article-number)))))
2840 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2841 (defmacro gnus-summary-article-subject (&optional number)
2842 "Return current subject string or nil if nothing."
2845 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2846 '(gnus-data-header (assq (gnus-summary-article-number)
2847 gnus-newsgroup-data)))))
2850 (mail-header-subject headers))))
2852 (defmacro gnus-summary-article-score (&optional number)
2853 "Return current article score."
2854 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2855 gnus-newsgroup-scored))
2856 gnus-summary-default-score 0))
2858 (defun gnus-summary-article-children (&optional number)
2859 "Return a list of article numbers that are children of article NUMBER."
2860 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2861 (level (gnus-data-level (car data)))
2863 (while (and (setq data (cdr data))
2864 (> (setq l (gnus-data-level (car data))) level))
2865 (and (= (1+ level) l)
2866 (push (gnus-data-number (car data))
2868 (nreverse children)))
2870 (defun gnus-summary-article-parent (&optional number)
2871 "Return the article number of the parent of article NUMBER."
2872 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2873 (gnus-data-list t)))
2874 (level (gnus-data-level (car data))))
2876 () ; This is a root.
2877 ;; We search until we find an article with a level less than
2878 ;; this one. That function has to be the parent.
2879 (while (and (setq data (cdr data))
2880 (not (< (gnus-data-level (car data)) level))))
2881 (and data (gnus-data-number (car data))))))
2883 (defun gnus-unread-mark-p (mark)
2884 "Say whether MARK is the unread mark."
2885 (= mark gnus-unread-mark))
2887 (defun gnus-read-mark-p (mark)
2888 "Say whether MARK is one of the marks that mark as read.
2889 This is all marks except unread, ticked, dormant, and expirable."
2890 (not (or (= mark gnus-unread-mark)
2891 (= mark gnus-ticked-mark)
2892 (= mark gnus-spam-mark)
2893 (= mark gnus-dormant-mark)
2894 (= mark gnus-expirable-mark))))
2896 (defmacro gnus-article-mark (number)
2897 "Return the MARK of article NUMBER.
2898 This macro should only be used when computing the mark the \"first\"
2899 time; i.e., when generating the summary lines. After that,
2900 `gnus-summary-article-mark' should be used to examine the
2903 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2904 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2905 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2906 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2907 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2908 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2909 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2910 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2911 gnus-ancient-mark))))
2913 ;; Saving hidden threads.
2915 (defmacro gnus-save-hidden-threads (&rest forms)
2916 "Save hidden threads, eval FORMS, and restore the hidden threads."
2917 (let ((config (make-symbol "config")))
2918 `(let ((,config (gnus-hidden-threads-configuration)))
2922 (gnus-restore-hidden-threads-configuration ,config)))))
2923 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2924 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2926 (defun gnus-data-compute-positions ()
2927 "Compute the positions of all articles."
2928 (setq gnus-newsgroup-data-reverse nil)
2929 (let ((data gnus-newsgroup-data))
2931 (gnus-save-hidden-threads
2932 (gnus-summary-show-all-threads)
2933 (goto-char (point-min))
2935 (while (get-text-property (point) 'gnus-intangible)
2937 (gnus-data-set-pos (car data) (+ (point) 3))
2938 (setq data (cdr data))
2939 (forward-line 1))))))
2941 (defun gnus-hidden-threads-configuration ()
2942 "Return the current hidden threads configuration."
2945 (goto-char (point-min))
2946 (while (search-forward "\r" nil t)
2947 (push (1- (point)) config))
2950 (defun gnus-restore-hidden-threads-configuration (config)
2951 "Restore hidden threads configuration from CONFIG."
2953 (let (point buffer-read-only)
2954 (while (setq point (pop config))
2955 (when (and (< point (point-max))
2957 (eq (char-after) ?\n))
2958 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2960 ;; Various summary mode internalish functions.
2962 (defun gnus-mouse-pick-article (e)
2965 (gnus-summary-next-page nil t))
2967 (defun gnus-summary-set-display-table ()
2968 "Change the display table.
2969 Odd characters have a tendency to mess
2970 up nicely formatted displays - we make all possible glyphs
2971 display only a single character."
2973 ;; We start from the standard display table, if any.
2974 (let ((table (or (copy-sequence standard-display-table)
2975 (make-display-table)))
2977 ;; Nix out all the control chars...
2978 (while (>= (setq i (1- i)) 0)
2979 (aset table i [??]))
2980 ;; ... but not newline and cr, of course. (cr is necessary for the
2981 ;; selective display).
2982 (aset table ?\n nil)
2983 (aset table ?\r nil)
2984 ;; We keep TAB as well.
2985 (aset table ?\t nil)
2986 ;; We nix out any glyphs over 126 that are not set already.
2988 (while (>= (setq i (1- i)) 127)
2989 ;; Only modify if the entry is nil.
2990 (unless (aref table i)
2991 (aset table i [??]))))
2992 (setq buffer-display-table table)))
2994 (defun gnus-summary-set-article-display-arrow (pos)
2995 "Update the overlay arrow to point to line at position POS."
2996 (when (and gnus-summary-display-arrow
2997 (boundp 'overlay-arrow-position)
2998 (boundp 'overlay-arrow-string))
3002 (unless overlay-arrow-position
3003 (setq overlay-arrow-position (make-marker)))
3004 (setq overlay-arrow-string "=>"
3005 overlay-arrow-position (set-marker overlay-arrow-position
3007 (current-buffer))))))
3009 (defun gnus-summary-buffer-name (group)
3010 "Return the summary buffer name of GROUP."
3011 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3013 (defun gnus-summary-setup-buffer (group)
3014 "Initialize summary buffer."
3015 (let ((buffer (gnus-summary-buffer-name group))
3016 (dead-name (concat "*Dead Summary "
3017 (gnus-group-decoded-name group) "*")))
3018 ;; If a dead summary buffer exists, we kill it.
3019 (when (gnus-buffer-live-p dead-name)
3020 (gnus-kill-buffer dead-name))
3021 (if (get-buffer buffer)
3024 (setq gnus-summary-buffer (current-buffer))
3025 (not gnus-newsgroup-prepared))
3026 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3027 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3028 (gnus-summary-mode group)
3030 (gnus-carpal-setup-buffer 'summary))
3031 (unless gnus-single-article-buffer
3032 (make-local-variable 'gnus-article-buffer)
3033 (make-local-variable 'gnus-article-current)
3034 (make-local-variable 'gnus-original-article-buffer))
3035 (setq gnus-newsgroup-name group)
3036 ;; Set any local variables in the group parameters.
3037 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3040 (defun gnus-set-global-variables ()
3041 "Set the global equivalents of the buffer-local variables.
3042 They are set to the latest values they had. These reflect the summary
3043 buffer that was in action when the last article was fetched."
3044 (when (eq major-mode 'gnus-summary-mode)
3045 (setq gnus-summary-buffer (current-buffer))
3046 (let ((name gnus-newsgroup-name)
3047 (marked gnus-newsgroup-marked)
3048 (spam gnus-newsgroup-spam-marked)
3049 (unread gnus-newsgroup-unreads)
3050 (headers gnus-current-headers)
3051 (data gnus-newsgroup-data)
3052 (summary gnus-summary-buffer)
3053 (article-buffer gnus-article-buffer)
3054 (original gnus-original-article-buffer)
3055 (gac gnus-article-current)
3056 (reffed gnus-reffed-article-number)
3057 (score-file gnus-current-score-file)
3058 (default-charset gnus-newsgroup-charset)
3060 (let ((locals gnus-newsgroup-variables))
3062 (if (consp (car locals))
3063 (push (eval (caar locals)) vlist)
3064 (push (eval (car locals)) vlist))
3065 (setq locals (cdr locals)))
3066 (setq vlist (nreverse vlist)))
3068 (set-buffer gnus-group-buffer)
3069 (setq gnus-newsgroup-name name
3070 gnus-newsgroup-marked marked
3071 gnus-newsgroup-spam-marked spam
3072 gnus-newsgroup-unreads unread
3073 gnus-current-headers headers
3074 gnus-newsgroup-data data
3075 gnus-article-current gac
3076 gnus-summary-buffer summary
3077 gnus-article-buffer article-buffer
3078 gnus-original-article-buffer original
3079 gnus-reffed-article-number reffed
3080 gnus-current-score-file score-file
3081 gnus-newsgroup-charset default-charset)
3082 (let ((locals gnus-newsgroup-variables))
3084 (if (consp (car locals))
3085 (set (caar locals) (pop vlist))
3086 (set (car locals) (pop vlist)))
3087 (setq locals (cdr locals))))
3088 ;; The article buffer also has local variables.
3089 (when (gnus-buffer-live-p gnus-article-buffer)
3090 (set-buffer gnus-article-buffer)
3091 (setq gnus-summary-buffer summary))))))
3093 (defun gnus-summary-article-unread-p (article)
3094 "Say whether ARTICLE is unread or not."
3095 (memq article gnus-newsgroup-unreads))
3097 (defun gnus-summary-first-article-p (&optional article)
3098 "Return whether ARTICLE is the first article in the buffer."
3099 (if (not (setq article (or article (gnus-summary-article-number))))
3101 (eq article (caar gnus-newsgroup-data))))
3103 (defun gnus-summary-last-article-p (&optional article)
3104 "Return whether ARTICLE is the last article in the buffer."
3105 (if (not (setq article (or article (gnus-summary-article-number))))
3106 ;; All non-existent numbers are the last article. :-)
3108 (not (cdr (gnus-data-find-list article)))))
3110 (defun gnus-make-thread-indent-array ()
3112 (unless (and gnus-thread-indent-array
3113 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3114 (setq gnus-thread-indent-array (make-vector 201 "")
3115 gnus-thread-indent-array-level gnus-thread-indent-level)
3117 (aset gnus-thread-indent-array n
3118 (make-string (* n gnus-thread-indent-level) ? ))
3121 (defun gnus-update-summary-mark-positions ()
3122 "Compute where the summary marks are to go."
3124 (when (gnus-buffer-exists-p gnus-summary-buffer)
3125 (set-buffer gnus-summary-buffer))
3126 (let ((gnus-replied-mark 129)
3127 (gnus-score-below-mark 130)
3128 (gnus-score-over-mark 130)
3129 (gnus-undownloaded-mark 131)
3130 (spec gnus-summary-line-format-spec)
3133 (gnus-set-work-buffer)
3134 (let ((gnus-summary-line-format-spec spec)
3135 (gnus-newsgroup-downloadable '(0)))
3136 (gnus-summary-insert-line
3137 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3138 0 nil t 128 t nil "" nil 1)
3139 (goto-char (point-min))
3140 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3141 (- (point) (point-min) 1)))))
3142 (goto-char (point-min))
3143 (push (cons 'replied (and (search-forward "\201" nil t)
3144 (- (point) (point-min) 1)))
3146 (goto-char (point-min))
3147 (push (cons 'score (and (search-forward "\202" nil t)
3148 (- (point) (point-min) 1)))
3150 (goto-char (point-min))
3151 (push (cons 'download
3152 (and (search-forward "\203" nil t)
3153 (- (point) (point-min) 1)))
3155 (setq gnus-summary-mark-positions pos))))
3157 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3158 "Insert a dummy root in the summary buffer."
3160 (gnus-add-text-properties
3161 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3162 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3164 (defun gnus-summary-extract-address-component (from)
3165 (or (car (funcall gnus-extract-address-components from))
3168 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3169 (let ((mail-parse-charset gnus-newsgroup-charset)
3170 ; Is it really necessary to do this next part for each summary line?
3171 ; Luckily, doesn't seem to slow things down much.
3172 (mail-parse-ignored-charsets
3173 (save-excursion (set-buffer gnus-summary-buffer)
3174 gnus-newsgroup-ignored-charsets)))
3176 (and gnus-ignored-from-addresses
3177 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3178 (let ((extra-headers (mail-header-extra header))
3182 ((setq to (cdr (assq 'To extra-headers)))
3185 (gnus-summary-extract-address-component
3186 (funcall gnus-decode-encoded-word-function to)))))
3187 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3188 (concat "=> " newsgroups)))))
3189 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3191 (defun gnus-summary-insert-line (gnus-tmp-header
3192 gnus-tmp-level gnus-tmp-current
3193 undownloaded gnus-tmp-unread gnus-tmp-replied
3194 gnus-tmp-expirable gnus-tmp-subject-or-nil
3195 &optional gnus-tmp-dummy gnus-tmp-score
3197 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3198 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3199 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3200 (gnus-tmp-score-char
3201 (if (or (null gnus-summary-default-score)
3202 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3203 gnus-summary-zcore-fuzz))
3205 (if (< gnus-tmp-score gnus-summary-default-score)
3206 gnus-score-below-mark gnus-score-over-mark)))
3207 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3209 (cond (gnus-tmp-process gnus-process-mark)
3210 ((memq gnus-tmp-current gnus-newsgroup-cached)
3212 (gnus-tmp-replied gnus-replied-mark)
3213 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3214 gnus-forwarded-mark)
3215 ((memq gnus-tmp-current gnus-newsgroup-saved)
3217 ((memq gnus-tmp-number gnus-newsgroup-recent)
3219 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3222 (gnus-tmp-downloaded
3224 gnus-undownloaded-mark)
3225 (gnus-newsgroup-agentized
3226 gnus-downloaded-mark)
3229 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3232 ((string-match "<[^>]+> *$" gnus-tmp-from)
3233 (let ((beg (match-beginning 0)))
3234 (or (and (string-match "^\".+\"" gnus-tmp-from)
3235 (substring gnus-tmp-from 1 (1- (match-end 0))))
3236 (substring gnus-tmp-from 0 beg))))
3237 ((string-match "(.+)" gnus-tmp-from)
3238 (substring gnus-tmp-from
3239 (1+ (match-beginning 0)) (1- (match-end 0))))
3241 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3242 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3243 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3244 (buffer-read-only nil))
3245 (when (string= gnus-tmp-name "")
3246 (setq gnus-tmp-name gnus-tmp-from))
3247 (unless (numberp gnus-tmp-lines)
3248 (setq gnus-tmp-lines -1))
3249 (if (= gnus-tmp-lines -1)
3250 (setq gnus-tmp-lines "?")
3251 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3252 (gnus-put-text-property
3254 (progn (eval gnus-summary-line-format-spec) (point))
3255 'gnus-number gnus-tmp-number)
3256 (when (gnus-visual-p 'summary-highlight 'highlight)
3258 (gnus-run-hooks 'gnus-summary-update-hook)
3261 (defun gnus-summary-update-line (&optional dont-update)
3262 "Update summary line after change."
3263 (when (and gnus-summary-default-score
3264 (not gnus-summary-inhibit-highlight))
3265 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3266 (article (gnus-summary-article-number))
3267 (score (gnus-summary-article-score article)))
3269 (if (and gnus-summary-mark-below
3270 (< (gnus-summary-article-score)
3271 gnus-summary-mark-below))
3272 ;; This article has a low score, so we mark it as read.
3273 (when (memq article gnus-newsgroup-unreads)
3274 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3275 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3276 ;; This article was previously marked as read on account
3277 ;; of a low score, but now it has risen, so we mark it as
3279 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3280 (gnus-summary-update-mark
3281 (if (or (null gnus-summary-default-score)
3282 (<= (abs (- score gnus-summary-default-score))
3283 gnus-summary-zcore-fuzz))
3285 (if (< score gnus-summary-default-score)
3286 gnus-score-below-mark gnus-score-over-mark))
3288 ;; Do visual highlighting.
3289 (when (gnus-visual-p 'summary-highlight 'highlight)
3290 (gnus-run-hooks 'gnus-summary-update-hook)))))
3292 (defvar gnus-tmp-new-adopts nil)
3294 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3295 "Return the number of articles in THREAD.
3296 This may be 0 in some cases -- if none of the articles in
3297 the thread are to be displayed."
3299 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3301 ((not (listp thread))
3303 ((and (consp thread) (cdr thread))
3306 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3309 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3312 (when (and level (zerop level) gnus-tmp-new-adopts)
3315 'gnus-summary-number-of-articles-in-thread
3316 gnus-tmp-new-adopts))))
3318 (if (> number 1) gnus-not-empty-thread-mark
3319 gnus-empty-thread-mark)
3322 (defsubst gnus-summary-line-message-size (head)
3323 "Return pretty-printed version of message size.
3324 This function is intended to be used in
3325 `gnus-summary-line-format-alist', which see."
3326 (let ((c (or (mail-header-chars head) -1)))
3327 (cond ((< c 0) "n/a") ; chars not available
3328 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3329 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3330 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3331 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3334 (defun gnus-summary-set-local-parameters (group)
3335 "Go through the local params of GROUP and set all variable specs in that list."
3336 (let ((params (gnus-group-find-parameter group))
3337 (vars '(quit-config)) ; Ignore quit-config.
3340 (setq elem (car params)
3341 params (cdr params))
3342 (and (consp elem) ; Has to be a cons.
3343 (consp (cdr elem)) ; The cdr has to be a list.
3344 (symbolp (car elem)) ; Has to be a symbol in there.
3345 (not (memq (car elem) vars))
3346 (ignore-errors ; So we set it.
3347 (push (car elem) vars)
3348 (make-local-variable (car elem))
3349 (set (car elem) (eval (nth 1 elem))))))))
3351 (defun gnus-summary-read-group (group &optional show-all no-article
3352 kill-buffer no-display backward
3354 "Start reading news in newsgroup GROUP.
3355 If SHOW-ALL is non-nil, already read articles are also listed.
3356 If NO-ARTICLE is non-nil, no article is selected initially.
3357 If NO-DISPLAY, don't generate a summary buffer."
3361 (let ((gnus-auto-select-next nil))
3362 (or (gnus-summary-read-group-1
3363 group show-all no-article
3364 kill-buffer no-display
3367 select-articles nil)))))
3368 (eq gnus-auto-select-next 'quietly))
3369 (set-buffer gnus-group-buffer)
3370 ;; The entry function called above goes to the next
3371 ;; group automatically, so we go two groups back
3372 ;; if we are searching for the previous group.
3374 (gnus-group-prev-unread-group 2))
3375 (if (not (equal group (gnus-group-group-name)))
3376 (setq group (gnus-group-group-name))
3380 (defun gnus-summary-read-group-1 (group show-all no-article
3381 kill-buffer no-display
3382 &optional select-articles)
3383 ;; Killed foreign groups can't be entered.
3384 ;; (when (and (not (gnus-group-native-p group))
3385 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3386 ;; (error "Dead non-native groups can't be entered"))
3387 (gnus-message 5 "Retrieving newsgroup: %s..."
3388 (gnus-group-decoded-name group))
3389 (let* ((new-group (gnus-summary-setup-buffer group))
3390 (quit-config (gnus-group-quit-config group))
3391 (did-select (and new-group (gnus-select-newsgroup
3392 group show-all select-articles))))
3394 ;; This summary buffer exists already, so we just select it.
3396 (gnus-set-global-variables)
3398 (gnus-kill-or-deaden-summary kill-buffer))
3399 (gnus-configure-windows 'summary 'force)
3400 (gnus-set-mode-line 'summary)
3401 (gnus-summary-position-point)
3404 ;; We couldn't select this group.
3406 (when (and (eq major-mode 'gnus-summary-mode)
3407 (not (equal (current-buffer) kill-buffer)))
3408 (kill-buffer (current-buffer))
3409 (if (not quit-config)
3411 ;; Update the info -- marks might need to be removed,
3413 (gnus-summary-update-info)
3414 (set-buffer gnus-group-buffer)
3415 (gnus-group-jump-to-group group)
3416 (gnus-group-next-unread-group 1))
3417 (gnus-handle-ephemeral-exit quit-config)))
3418 (let ((grpinfo (gnus-get-info group)))
3419 (if (null (gnus-info-read grpinfo))
3420 (gnus-message 3 "Group %s contains no messages"
3421 (gnus-group-decoded-name group))
3422 (gnus-message 3 "Can't select group")))
3424 ;; The user did a `C-g' while prompting for number of articles,
3425 ;; so we exit this group.
3426 ((eq did-select 'quit)
3427 (and (eq major-mode 'gnus-summary-mode)
3428 (not (equal (current-buffer) kill-buffer))
3429 (kill-buffer (current-buffer)))
3431 (gnus-kill-or-deaden-summary kill-buffer))
3432 (if (not quit-config)
3434 (set-buffer gnus-group-buffer)
3435 (gnus-group-jump-to-group group)
3436 (gnus-group-next-unread-group 1)
3437 (gnus-configure-windows 'group 'force))
3438 (gnus-handle-ephemeral-exit quit-config))
3439 ;; Finally signal the quit.
3441 ;; The group was successfully selected.
3443 (gnus-set-global-variables)
3444 ;; Save the active value in effect when the group was entered.
3445 (setq gnus-newsgroup-active
3447 (gnus-active gnus-newsgroup-name)))
3448 ;; You can change the summary buffer in some way with this hook.
3449 (gnus-run-hooks 'gnus-select-group-hook)
3450 (gnus-update-format-specifications
3451 nil 'summary 'summary-mode 'summary-dummy)
3452 (gnus-update-summary-mark-positions)
3453 ;; Do score processing.
3454 (when gnus-use-scoring
3455 (gnus-possibly-score-headers))
3456 ;; Check whether to fill in the gaps in the threads.
3457 (when gnus-build-sparse-threads
3458 (gnus-build-sparse-threads))
3459 ;; Find the initial limit.
3460 (if gnus-show-threads
3462 (let ((gnus-newsgroup-dormant nil))
3463 (gnus-summary-initial-limit show-all))
3464 (gnus-summary-initial-limit show-all))
3465 ;; When unthreaded, all articles are always shown.
3466 (setq gnus-newsgroup-limit
3468 (lambda (header) (mail-header-number header))
3469 gnus-newsgroup-headers)))
3470 ;; Generate the summary buffer.
3472 (gnus-summary-prepare))
3473 (when gnus-use-trees
3474 (gnus-tree-open group)
3475 (setq gnus-summary-highlight-line-function
3476 'gnus-tree-highlight-article))
3477 ;; If the summary buffer is empty, but there are some low-scored
3478 ;; articles or some excluded dormants, we include these in the
3480 (when (and (zerop (buffer-size))
3482 (cond (gnus-newsgroup-dormant
3483 (gnus-summary-limit-include-dormant))
3484 ((and gnus-newsgroup-scored show-all)
3485 (gnus-summary-limit-include-expunged t))))
3486 ;; Function `gnus-apply-kill-file' must be called in this hook.
3487 (gnus-run-hooks 'gnus-apply-kill-hook)
3488 (if (and (zerop (buffer-size))
3491 ;; This newsgroup is empty.
3492 (gnus-summary-catchup-and-exit nil t)
3493 (gnus-message 6 "No unread news")
3495 (gnus-kill-or-deaden-summary kill-buffer))
3496 ;; Return nil from this function.
3498 ;; Hide conversation thread subtrees. We cannot do this in
3499 ;; gnus-summary-prepare-hook since kill processing may not
3500 ;; work with hidden articles.
3501 (gnus-summary-maybe-hide-threads)
3503 (gnus-kill-or-deaden-summary kill-buffer))
3504 (gnus-summary-auto-select-subject)
3505 ;; Show first unread article if requested.
3506 (if (and (not no-article)
3508 gnus-newsgroup-unreads
3509 gnus-auto-select-first)
3511 (gnus-configure-windows 'summary)
3512 (let ((art (gnus-summary-article-number)))
3513 (unless (and (not gnus-plugged)
3514 (or (memq art gnus-newsgroup-undownloaded)
3515 (memq art gnus-newsgroup-downloadable)))
3516 (gnus-summary-goto-article art))))
3517 ;; Don't select any articles.
3518 (gnus-summary-position-point)
3519 (gnus-configure-windows 'summary 'force)
3520 (gnus-set-mode-line 'summary))
3521 (when (get-buffer-window gnus-group-buffer t)
3522 ;; Gotta use windows, because recenter does weird stuff if
3523 ;; the current buffer ain't the displayed window.
3524 (let ((owin (selected-window)))
3525 (select-window (get-buffer-window gnus-group-buffer t))
3526 (when (gnus-group-goto-group group)
3528 (select-window owin)))
3529 ;; Mark this buffer as "prepared".
3530 (setq gnus-newsgroup-prepared t)
3531 (gnus-run-hooks 'gnus-summary-prepared-hook)
3532 (unless (gnus-ephemeral-group-p group)
3533 (gnus-group-update-group group))
3536 (defun gnus-summary-auto-select-subject ()
3537 "Select the subject line on initial group entry."
3538 (goto-char (point-min))
3540 ((eq gnus-auto-select-subject 'best)
3541 (gnus-summary-best-unread-subject))
3542 ((eq gnus-auto-select-subject 'unread)
3543 (gnus-summary-first-unread-subject))
3544 ((eq gnus-auto-select-subject 'unseen)
3545 (gnus-summary-first-unseen-subject))
3546 ((eq gnus-auto-select-subject 'unseen-or-unread)
3547 (gnus-summary-first-unseen-or-unread-subject))
3548 ((eq gnus-auto-select-subject 'first)
3551 ((gnus-functionp gnus-auto-select-subject)
3552 (funcall gnus-auto-select-subject))))
3554 (defun gnus-summary-prepare ()
3555 "Generate the summary buffer."
3557 (let ((buffer-read-only nil))
3559 (setq gnus-newsgroup-data nil
3560 gnus-newsgroup-data-reverse nil)
3561 (gnus-run-hooks 'gnus-summary-generate-hook)
3562 ;; Generate the buffer, either with threads or without.
3563 (when gnus-newsgroup-headers
3564 (gnus-summary-prepare-threads
3565 (if gnus-show-threads
3566 (gnus-sort-gathered-threads
3567 (funcall gnus-summary-thread-gathering-function
3569 (gnus-cut-threads (gnus-make-threads)))))
3570 ;; Unthreaded display.
3571 (gnus-sort-articles gnus-newsgroup-headers))))
3572 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3573 ;; Call hooks for modifying summary buffer.
3574 (goto-char (point-min))
3575 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3577 (defsubst gnus-general-simplify-subject (subject)
3578 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3581 ;; Truncate the subject.
3582 (gnus-simplify-subject-functions
3583 (gnus-map-function gnus-simplify-subject-functions subject))
3584 ((numberp gnus-summary-gather-subject-limit)
3585 (setq subject (gnus-simplify-subject-re subject))
3586 (if (> (length subject) gnus-summary-gather-subject-limit)
3587 (substring subject 0 gnus-summary-gather-subject-limit)
3589 ;; Fuzzily simplify it.
3590 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3591 (gnus-simplify-subject-fuzzy subject))
3592 ;; Just remove the leading "Re:".
3594 (gnus-simplify-subject-re subject))))
3596 (if (and gnus-summary-gather-exclude-subject
3597 (string-match gnus-summary-gather-exclude-subject subject))
3598 nil ; This article shouldn't be gathered
3601 (defun gnus-summary-simplify-subject-query ()
3602 "Query where the respool algorithm would put this article."
3604 (gnus-summary-select-article)
3605 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3607 (defun gnus-gather-threads-by-subject (threads)
3608 "Gather threads by looking at Subject headers."
3609 (if (not gnus-summary-make-false-root)
3611 (let ((hashtb (gnus-make-hashtable 1024))
3614 subject hthread whole-subject)
3616 (setq subject (gnus-general-simplify-subject
3617 (setq whole-subject (mail-header-subject
3620 (if (setq hthread (gnus-gethash subject hashtb))
3622 ;; We enter a dummy root into the thread, if we
3623 ;; haven't done that already.
3624 (unless (stringp (caar hthread))
3625 (setcar hthread (list whole-subject (car hthread))))
3626 ;; We add this new gathered thread to this gathered
3628 (setcdr (car hthread)
3629 (nconc (cdar hthread) (list (car threads))))
3630 ;; Remove it from the list of threads.
3631 (setcdr prev (cdr threads))
3632 (setq threads prev))
3633 ;; Enter this thread into the hash table.
3634 (gnus-sethash subject
3635 (if gnus-summary-make-false-root-always
3637 ;; If you want a dummy root above all
3639 (setcar threads (list whole-subject
3645 (setq threads (cdr threads)))
3648 (defun gnus-gather-threads-by-references (threads)
3649 "Gather threads by looking at References headers."
3650 (let ((idhashtb (gnus-make-hashtable 1024))
3651 (thhashtb (gnus-make-hashtable 1024))
3654 ids references id gthread gid entered ref)
3656 (when (setq references (mail-header-references (caar threads)))
3657 (setq id (mail-header-id (caar threads))
3658 ids (inline (gnus-split-references references))
3660 (while (setq ref (pop ids))
3661 (setq ids (delete ref ids))
3662 (if (not (setq gid (gnus-gethash ref idhashtb)))
3664 (gnus-sethash ref id idhashtb)
3665 (gnus-sethash id threads thhashtb))
3666 (setq gthread (gnus-gethash gid thhashtb))
3668 ;; We enter a dummy root into the thread, if we
3669 ;; haven't done that already.
3670 (unless (stringp (caar gthread))
3671 (setcar gthread (list (mail-header-subject (caar gthread))
3673 ;; We add this new gathered thread to this gathered
3675 (setcdr (car gthread)
3676 (nconc (cdar gthread) (list (car threads)))))
3677 ;; Add it into the thread hash table.
3678 (gnus-sethash id gthread thhashtb)
3680 ;; Remove it from the list of threads.
3681 (setcdr prev (cdr threads))
3682 (setq threads prev))))
3684 (setq threads (cdr threads)))
3687 (defun gnus-sort-gathered-threads (threads)
3688 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3689 (let ((result threads))
3691 (when (stringp (caar threads))
3692 (setcdr (car threads)
3693 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3694 (setq threads (cdr threads)))
3697 (defun gnus-thread-loop-p (root thread)
3698 "Say whether ROOT is in THREAD."
3699 (let ((stack (list thread))
3702 (while (setq thread (pop stack))
3703 (setq th (cdr thread))
3705 (not (eq (caar th) root)))
3708 ;; We have found a loop.
3710 (setcdr thread (delq (car th) (cdr thread)))
3711 (if (boundp (setq ref-dep (intern "none"
3712 gnus-newsgroup-dependencies)))
3713 (setcdr (symbol-value ref-dep)
3714 (nconc (cdr (symbol-value ref-dep))
3716 (set ref-dep (list nil (car th))))
3719 ;; Push all the subthreads onto the stack.
3720 (push (cdr thread) stack)))
3723 (defun gnus-make-threads ()
3724 "Go through the dependency hashtb and find the roots. Return all threads."
3726 (while (catch 'infloop
3729 ;; Deal with self-referencing References loops.
3730 (when (and (car (symbol-value refs))
3737 (car (symbol-value refs)) thread))
3738 (cdr (symbol-value refs)))))))
3741 (unless (car (symbol-value refs))
3742 ;; These threads do not refer back to any other
3743 ;; articles, so they're roots.
3744 (setq threads (append (cdr (symbol-value refs)) threads))))
3745 gnus-newsgroup-dependencies)))
3748 ;; Build the thread tree.
3749 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3750 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3752 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3753 if it was already present.
3755 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3756 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3757 Message-IDs will be renamed to a unique Message-ID before being
3760 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3761 (let* ((id (mail-header-id header))
3762 (id-dep (and id (intern id dependencies)))
3763 parent-id ref ref-dep ref-header replaced)
3764 ;; Enter this `header' in the `dependencies' table.
3768 ;; The first two cases do the normal part: enter a new `header'
3769 ;; in the `dependencies' table.
3770 ((not (boundp id-dep))
3771 (set id-dep (list header)))
3772 ((null (car (symbol-value id-dep)))
3773 (setcar (symbol-value id-dep) header))
3775 ;; From here the `header' was already present in the
3776 ;; `dependencies' table.
3778 ;; Overrides an existing entry;
3779 ;; just set the header part of the entry.
3780 (setcar (symbol-value id-dep) header)
3783 ;; Renames the existing `header' to a unique Message-ID.
3784 ((not gnus-summary-ignore-duplicates)
3785 ;; An article with this Message-ID has already been seen.
3786 ;; We rename the Message-ID.
3787 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3789 (mail-header-set-id header id))
3791 ;; The last case ignores an existing entry, except it adds any
3792 ;; additional Xrefs (in case the two articles came from different
3794 ;; Also sets `header' to `nil' meaning that the `dependencies'
3795 ;; table was *not* modified.
3797 (mail-header-set-xref
3798 (car (symbol-value id-dep))
3799 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3801 (or (mail-header-xref header) "")))
3804 (when (and header (not replaced))
3805 ;; First check that we are not creating a References loop.
3806 (setq parent-id (gnus-parent-id (mail-header-references header)))
3807 (setq ref parent-id)
3809 (setq ref-dep (intern-soft ref dependencies))
3811 (setq ref-header (car (symbol-value ref-dep))))
3812 (if (string= id ref)
3813 ;; Yuk! This is a reference loop. Make the article be a
3816 (mail-header-set-references (car (symbol-value id-dep)) "none")
3818 (setq parent-id nil))
3819 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3820 (setq ref-dep (intern (or parent-id "none") dependencies))
3821 (if (boundp ref-dep)
3822 (setcdr (symbol-value ref-dep)
3823 (nconc (cdr (symbol-value ref-dep))
3824 (list (symbol-value id-dep))))
3825 (set ref-dep (list nil (symbol-value id-dep)))))
3828 (defun gnus-extract-message-id-from-in-reply-to (string)
3829 (if (string-match "<[^>]+>" string)
3830 (substring string (match-beginning 0) (match-end 0))
3833 (defun gnus-build-sparse-threads ()
3834 (let ((headers gnus-newsgroup-headers)
3835 (mail-parse-charset gnus-newsgroup-charset)
3836 (gnus-summary-ignore-duplicates t)
3837 header references generation relations
3838 subject child end new-child date)
3839 ;; First we create an alist of generations/relations, where
3840 ;; generations is how much we trust the relation, and the relation
3842 (gnus-message 7 "Making sparse threads...")
3844 (nnheader-set-temp-buffer " *gnus sparse threads*")
3845 (while (setq header (pop headers))
3846 (when (and (setq references (mail-header-references header))
3847 (not (string= references "")))
3849 (setq child (mail-header-id header)
3850 subject (mail-header-subject header)
3851 date (mail-header-date header)
3853 (while (search-backward ">" nil t)
3854 (setq end (1+ (point)))
3855 (when (search-backward "<" nil t)
3856 (setq new-child (buffer-substring (point) end))
3857 (push (list (incf generation)
3858 child (setq child new-child)
3862 (push (list (1+ generation) child nil subject) relations))
3864 (kill-buffer (current-buffer)))
3865 ;; Sort over trustworthiness.
3868 (when (gnus-dependencies-add-header
3869 (make-full-mail-header
3870 gnus-reffed-article-number
3871 (nth 3 relation) "" (or (nth 4 relation) "")
3873 (or (nth 2 relation) "") 0 0 "")
3874 gnus-newsgroup-dependencies nil)
3875 (push gnus-reffed-article-number gnus-newsgroup-limit)
3876 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3877 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3878 gnus-newsgroup-reads)
3879 (decf gnus-reffed-article-number)))
3880 (sort relations 'car-less-than-car))
3881 (gnus-message 7 "Making sparse threads...done")))
3883 (defun gnus-build-old-threads ()
3884 ;; Look at all the articles that refer back to old articles, and
3885 ;; fetch the headers for the articles that aren't there. This will
3886 ;; build complete threads - if the roots haven't been expired by the
3888 (let ((mail-parse-charset gnus-newsgroup-charset)
3892 (when (not (car (symbol-value refs)))
3893 (setq heads (cdr (symbol-value refs)))
3895 (if (memq (mail-header-number (caar heads))
3896 gnus-newsgroup-dormant)
3897 (setq heads (cdr heads))
3898 (setq id (symbol-name refs))
3899 (while (and (setq id (gnus-build-get-header id))
3900 (not (car (gnus-id-to-thread id)))))
3901 (setq heads nil)))))
3902 gnus-newsgroup-dependencies)))
3904 ;; This function has to be called with point after the article number
3905 ;; on the beginning of the line.
3906 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3907 (let ((eol (gnus-point-at-eol))
3908 (buffer (current-buffer))
3909 header references in-reply-to)
3911 ;; overview: [num subject from date id refs chars lines misc]
3914 (narrow-to-region (point) eol)
3919 (make-full-mail-header
3921 (condition-case () ; subject
3922 (funcall gnus-decode-encoded-word-function
3923 (setq x (nnheader-nov-field)))
3925 (condition-case () ; from
3926 (funcall gnus-decode-encoded-word-function
3927 (setq x (nnheader-nov-field)))
3929 (nnheader-nov-field) ; date
3930 (nnheader-nov-read-message-id) ; id
3931 (setq references (nnheader-nov-field)) ; refs
3932 (nnheader-nov-read-integer) ; chars
3933 (nnheader-nov-read-integer) ; lines
3935 (if (looking-at "Xref: ")
3936 (goto-char (match-end 0)))
3937 (nnheader-nov-field)) ; Xref
3938 (nnheader-nov-parse-extra)))) ; extra
3942 (when (and (string= references "")
3943 (setq in-reply-to (mail-header-extra header))
3944 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3945 (mail-header-set-references
3946 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3948 (when gnus-alter-header-function
3949 (funcall gnus-alter-header-function header))
3950 (gnus-dependencies-add-header header dependencies force-new)))
3952 (defun gnus-build-get-header (id)
3953 "Look through the buffer of NOV lines and find the header to ID.
3954 Enter this line into the dependencies hash table, and return
3955 the id of the parent article (if any)."
3956 (let ((deps gnus-newsgroup-dependencies)
3960 (set-buffer nntp-server-buffer)
3961 (let ((case-fold-search nil))
3962 (goto-char (point-min))
3963 (while (and (not found)
3964 (search-forward id nil t))
3966 (setq found (looking-at
3967 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3968 (regexp-quote id))))
3969 (or found (beginning-of-line 2)))
3973 (setq header (gnus-nov-parse-line
3974 (read (current-buffer)) deps))
3975 (gnus-parent-id (mail-header-references header))))))
3977 (let ((number (mail-header-number header)))
3978 (push number gnus-newsgroup-limit)
3979 (push header gnus-newsgroup-headers)
3980 (if (memq number gnus-newsgroup-unselected)
3982 (setq gnus-newsgroup-unreads
3983 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3985 (setq gnus-newsgroup-unselected
3986 (delq number gnus-newsgroup-unselected)))
3987 (push number gnus-newsgroup-ancient)))))))
3989 (defun gnus-build-all-threads ()
3990 "Read all the headers."
3991 (let ((gnus-summary-ignore-duplicates t)
3992 (mail-parse-charset gnus-newsgroup-charset)
3993 (dependencies gnus-newsgroup-dependencies)
3996 (set-buffer nntp-server-buffer)
3997 (let ((case-fold-search nil))
3998 (goto-char (point-min))
4001 (setq article (read (current-buffer))
4002 header (gnus-nov-parse-line article dependencies)))
4005 (set-buffer gnus-summary-buffer)
4006 (push header gnus-newsgroup-headers)
4007 (if (memq (setq article (mail-header-number header))
4008 gnus-newsgroup-unselected)
4010 (setq gnus-newsgroup-unreads
4011 (gnus-add-to-sorted-list
4012 gnus-newsgroup-unreads article))
4013 (setq gnus-newsgroup-unselected
4014 (delq article gnus-newsgroup-unselected)))
4015 (push article gnus-newsgroup-ancient)))
4016 (forward-line 1)))))))
4018 (defun gnus-summary-update-article-line (article header)
4019 "Update the line for ARTICLE using HEADERS."
4020 (let* ((id (mail-header-id header))
4021 (thread (gnus-id-to-thread id)))
4023 (error "Article in no thread"))
4024 ;; Update the thread.
4025 (setcar thread header)
4026 (gnus-summary-goto-subject article)
4027 (let* ((datal (gnus-data-find-list article))
4029 (buffer-read-only nil)
4030 (level (gnus-summary-thread-level)))
4032 (let ((inserted (- (point)
4034 (gnus-summary-insert-line
4036 (memq article gnus-newsgroup-undownloaded)
4037 (gnus-article-mark article)
4038 (memq article gnus-newsgroup-replied)
4039 (memq article gnus-newsgroup-expirable)
4040 ;; Only insert the Subject string when it's different
4041 ;; from the previous Subject string.
4046 (mail-header-subject
4049 (gnus-data-find-list
4051 (gnus-data-list t)))))
4052 ;; Error on the side of excessive subjects.
4054 (mail-header-subject header)))
4056 (mail-header-subject header))
4057 nil (cdr (assq article gnus-newsgroup-scored))
4058 (memq article gnus-newsgroup-processable))
4061 (gnus-data-update-list
4063 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4065 (defun gnus-summary-update-article (article &optional iheader)
4066 "Update ARTICLE in the summary buffer."
4067 (set-buffer gnus-summary-buffer)
4068 (let* ((header (gnus-summary-article-header article))
4069 (id (mail-header-id header))
4070 (data (gnus-data-find article))
4071 (thread (gnus-id-to-thread id))
4072 (references (mail-header-references header))
4076 (when (and references
4077 (not (equal "" references)))
4080 (buffer-read-only nil)
4086 (delq thread parent)))
4087 (if (gnus-summary-insert-subject id header)
4088 ;; Set the (possibly) new article number in the data structure.
4089 (gnus-data-set-number data (gnus-id-to-article id))
4093 (defun gnus-rebuild-thread (id &optional line)
4094 "Rebuild the thread containing ID.
4095 If LINE, insert the rebuilt thread starting on line LINE."
4096 (let ((buffer-read-only nil)
4097 old-pos current thread data)
4098 (if (not gnus-show-threads)
4099 (setq thread (list (car (gnus-id-to-thread id))))
4100 ;; Get the thread this article is part of.
4101 (setq thread (gnus-remove-thread id)))
4102 (setq old-pos (gnus-point-at-bol))
4103 (setq current (save-excursion
4104 (and (re-search-backward "[\r\n]" nil t)
4105 (gnus-summary-article-number))))
4106 ;; If this is a gathered thread, we have to go some re-gathering.
4107 (when (stringp (car thread))
4108 (let ((subject (car thread))
4110 (setq thread (cdr thread))
4112 (unless (memq (setq thr (gnus-id-to-thread
4114 (mail-header-id (caar thread)))))
4117 (setq thread (cdr thread)))
4118 ;; We now have all (unique) roots.
4119 (if (= (length roots) 1)
4120 ;; All the loose roots are now one solid root.
4121 (setq thread (car roots))
4122 (setq thread (cons subject (gnus-sort-threads roots))))))
4124 ;; We then insert this thread into the summary buffer.
4126 (goto-char (point-min))
4127 (forward-line (1- line)))
4128 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4129 (if gnus-show-threads
4130 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4131 (gnus-summary-prepare-unthreaded thread))
4132 (setq data (nreverse gnus-newsgroup-data))
4133 (setq threads gnus-newsgroup-threads))
4134 ;; We splice the new data into the data structure.
4135 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4136 ;;!!! then we want to insert at the beginning of the buffer.
4137 ;;!!! That happens to be true with Gnus now, but that may
4138 ;;!!! change in the future. Perhaps.
4139 (gnus-data-enter-list
4140 (if line nil current) data (- (point) old-pos))
4141 (setq gnus-newsgroup-threads
4142 (nconc threads gnus-newsgroup-threads))
4143 (gnus-data-compute-positions))))
4145 (defun gnus-number-to-header (number)
4146 "Return the header for article NUMBER."
4147 (let ((headers gnus-newsgroup-headers))
4149 (not (= number (mail-header-number (car headers)))))
4154 (defun gnus-parent-headers (in-headers &optional generation)
4155 "Return the headers of the GENERATIONeth parent of HEADERS."
4157 (setq generation 1))
4159 (headers in-headers)
4162 (not (zerop generation))
4163 (setq references (mail-header-references headers)))
4164 (setq headers (if (and references
4165 (setq parent (gnus-parent-id references)))
4166 (car (gnus-id-to-thread parent))
4169 (and (not (eq headers in-headers))
4172 (defun gnus-id-to-thread (id)
4173 "Return the (sub-)thread where ID appears."
4174 (gnus-gethash id gnus-newsgroup-dependencies))
4176 (defun gnus-id-to-article (id)
4177 "Return the article number of ID."
4178 (let ((thread (gnus-id-to-thread id)))
4181 (mail-header-number (car thread)))))
4183 (defun gnus-id-to-header (id)
4184 "Return the article headers of ID."
4185 (car (gnus-id-to-thread id)))
4187 (defun gnus-article-displayed-root-p (article)
4188 "Say whether ARTICLE is a root(ish) article."
4189 (let ((level (gnus-summary-thread-level article))
4190 (refs (mail-header-references (gnus-summary-article-header article)))
4196 ((null (gnus-parent-id refs)) t)
4198 (null (setq particle (gnus-id-to-article
4199 (gnus-parent-id refs))))
4200 (null (gnus-summary-thread-level particle)))))))
4202 (defun gnus-root-id (id)
4203 "Return the id of the root of the thread where ID appears."
4205 (while (and id (setq prev (car (gnus-id-to-thread id))))
4207 id (gnus-parent-id (mail-header-references prev))))
4210 (defun gnus-articles-in-thread (thread)
4211 "Return the list of articles in THREAD."
4212 (cons (mail-header-number (car thread))
4213 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4215 (defun gnus-remove-thread (id &optional dont-remove)
4216 "Remove the thread that has ID in it."
4217 (let (headers thread last-id)
4218 ;; First go up in this thread until we find the root.
4219 (setq last-id (gnus-root-id id)
4220 headers (message-flatten-list (gnus-id-to-thread last-id)))
4221 ;; We have now found the real root of this thread. It might have
4222 ;; been gathered into some loose thread, so we have to search
4223 ;; through the threads to find the thread we wanted.
4224 (let ((threads gnus-newsgroup-threads)
4227 (setq sub (car threads))
4228 (if (stringp (car sub))
4229 ;; This is a gathered thread, so we look at the roots
4230 ;; below it to find whether this article is in this
4233 (setq sub (cdr sub))
4235 (when (member (caar sub) headers)
4236 (setq thread (car threads)
4239 (setq sub (cdr sub))))
4240 ;; It's an ordinary thread, so we check it.
4241 (when (eq (car sub) (car headers))
4244 (setq threads (cdr threads)))
4245 ;; If this article is in no thread, then it's a root.
4248 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4249 (setq thread (gnus-id-to-thread last-id)))
4252 thread ; We return this thread.
4254 (if (stringp (car thread))
4256 ;; If we use dummy roots, then we have to remove the
4257 ;; dummy root as well.
4258 (when (eq gnus-summary-make-false-root 'dummy)
4259 ;; We go to the dummy root by going to
4260 ;; the first sub-"thread", and then one line up.
4261 (gnus-summary-goto-article
4262 (mail-header-number (caadr thread)))
4265 (gnus-data-compute-positions))
4266 (setq thread (cdr thread))
4268 (gnus-remove-thread-1 (car thread))
4269 (setq thread (cdr thread))))
4270 (gnus-remove-thread-1 thread))))))))
4272 (defun gnus-remove-thread-1 (thread)
4273 "Remove the thread THREAD recursively."
4274 (let ((number (mail-header-number (pop thread)))
4276 (setq thread (reverse thread))
4278 (gnus-remove-thread-1 (pop thread)))
4279 (when (setq d (gnus-data-find number))
4280 (goto-char (gnus-data-pos d))
4281 (gnus-summary-show-thread)
4284 (- (gnus-point-at-bol)
4286 (1+ (gnus-point-at-eol))
4287 (gnus-delete-line)))))))
4289 (defun gnus-sort-threads-1 (threads func)
4290 (sort (mapcar (lambda (thread)
4293 (gnus-sort-threads-1 (cdr thread) func))))
4296 (defun gnus-sort-threads (threads)
4298 (if (not gnus-thread-sort-functions)
4300 (gnus-message 8 "Sorting threads...")
4301 (let ((max-lisp-eval-depth 5000))
4302 (prog1 (gnus-sort-threads-1
4304 (gnus-make-sort-function gnus-thread-sort-functions))
4305 (gnus-message 8 "Sorting threads...done")))))
4307 (defun gnus-sort-articles (articles)
4309 (when gnus-article-sort-functions
4310 (gnus-message 7 "Sorting articles...")
4312 (setq gnus-newsgroup-headers
4313 (sort articles (gnus-make-sort-function
4314 gnus-article-sort-functions)))
4315 (gnus-message 7 "Sorting articles...done"))))
4317 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4318 (defmacro gnus-thread-header (thread)
4319 "Return header of first article in THREAD.
4320 Note that THREAD must never, ever be anything else than a variable -
4321 using some other form will lead to serious barfage."
4322 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4323 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4324 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4327 (defsubst gnus-article-sort-by-number (h1 h2)
4328 "Sort articles by article number."
4329 (< (mail-header-number h1)
4330 (mail-header-number h2)))
4332 (defun gnus-thread-sort-by-number (h1 h2)
4333 "Sort threads by root article number."
4334 (gnus-article-sort-by-number
4335 (gnus-thread-header h1) (gnus-thread-header h2)))
4337 (defsubst gnus-article-sort-by-random (h1 h2)
4338 "Sort articles by article number."
4341 (defun gnus-thread-sort-by-random (h1 h2)
4342 "Sort threads by root article number."
4343 (gnus-article-sort-by-random
4344 (gnus-thread-header h1) (gnus-thread-header h2)))
4346 (defsubst gnus-article-sort-by-lines (h1 h2)
4347 "Sort articles by article Lines header."
4348 (< (mail-header-lines h1)
4349 (mail-header-lines h2)))
4351 (defun gnus-thread-sort-by-lines (h1 h2)
4352 "Sort threads by root article Lines header."
4353 (gnus-article-sort-by-lines
4354 (gnus-thread-header h1) (gnus-thread-header h2)))
4356 (defsubst gnus-article-sort-by-chars (h1 h2)
4357 "Sort articles by octet length."
4358 (< (mail-header-chars h1)
4359 (mail-header-chars h2)))
4361 (defun gnus-thread-sort-by-chars (h1 h2)
4362 "Sort threads by root article octet length."
4363 (gnus-article-sort-by-chars
4364 (gnus-thread-header h1) (gnus-thread-header h2)))
4366 (defsubst gnus-article-sort-by-author (h1 h2)
4367 "Sort articles by root author."
4369 (let ((extract (funcall
4370 gnus-extract-address-components
4371 (mail-header-from h1))))
4372 (or (car extract) (cadr extract) ""))
4373 (let ((extract (funcall
4374 gnus-extract-address-components
4375 (mail-header-from h2))))
4376 (or (car extract) (cadr extract) ""))))
4378 (defun gnus-thread-sort-by-author (h1 h2)
4379 "Sort threads by root author."
4380 (gnus-article-sort-by-author
4381 (gnus-thread-header h1) (gnus-thread-header h2)))
4383 (defsubst gnus-article-sort-by-subject (h1 h2)
4384 "Sort articles by root subject."
4386 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4387 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4389 (defun gnus-thread-sort-by-subject (h1 h2)
4390 "Sort threads by root subject."
4391 (gnus-article-sort-by-subject
4392 (gnus-thread-header h1) (gnus-thread-header h2)))
4394 (defsubst gnus-article-sort-by-date (h1 h2)
4395 "Sort articles by root article date."
4397 (gnus-date-get-time (mail-header-date h1))
4398 (gnus-date-get-time (mail-header-date h2))))
4400 (defun gnus-thread-sort-by-date (h1 h2)
4401 "Sort threads by root article date."
4402 (gnus-article-sort-by-date
4403 (gnus-thread-header h1) (gnus-thread-header h2)))
4405 (defsubst gnus-article-sort-by-score (h1 h2)
4406 "Sort articles by root article score.
4407 Unscored articles will be counted as having a score of zero."
4408 (> (or (cdr (assq (mail-header-number h1)
4409 gnus-newsgroup-scored))
4410 gnus-summary-default-score 0)
4411 (or (cdr (assq (mail-header-number h2)
4412 gnus-newsgroup-scored))
4413 gnus-summary-default-score 0)))
4415 (defun gnus-thread-sort-by-score (h1 h2)
4416 "Sort threads by root article score."
4417 (gnus-article-sort-by-score
4418 (gnus-thread-header h1) (gnus-thread-header h2)))
4420 (defun gnus-thread-sort-by-total-score (h1 h2)
4421 "Sort threads by the sum of all scores in the thread.
4422 Unscored articles will be counted as having a score of zero."
4423 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4425 (defun gnus-thread-total-score (thread)
4426 ;; This function find the total score of THREAD.
4431 (if (stringp (car thread))
4432 (apply gnus-thread-score-function 0
4433 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4434 (gnus-thread-total-score-1 thread)))
4436 (gnus-thread-total-score-1 (list thread)))))
4438 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4439 "Sort threads such that the thread with the most recently arrived article comes first."
4440 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4442 (defun gnus-thread-highest-number (thread)
4443 "Return the highest article number in THREAD."
4444 (apply 'max (mapcar (lambda (header)
4445 (mail-header-number header))
4446 (message-flatten-list thread))))
4448 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4449 "Sort threads such that the thread with the most recently dated article comes first."
4450 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4452 (defun gnus-thread-latest-date (thread)
4453 "Return the highest article date in THREAD."
4454 (let ((previous-time 0))
4461 (mail-header-parse-date (mail-header-date header))
4462 (error previous-time)))))
4464 (message-flatten-list thread)
4466 (< (mail-header-number h1)
4467 (mail-header-number h2))))))))
4469 (defun gnus-thread-total-score-1 (root)
4470 ;; This function find the total score of the thread below ROOT.
4471 (setq root (car root))
4472 (apply gnus-thread-score-function
4474 (mapcar 'gnus-thread-total-score
4475 (cdr (gnus-id-to-thread (mail-header-id root))))
4476 (when (> (mail-header-number root) 0)
4477 (list (or (cdr (assq (mail-header-number root)
4478 gnus-newsgroup-scored))
4479 gnus-summary-default-score 0))))
4480 (list gnus-summary-default-score)
4483 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4484 (defvar gnus-tmp-prev-subject nil)
4485 (defvar gnus-tmp-false-parent nil)
4486 (defvar gnus-tmp-root-expunged nil)
4487 (defvar gnus-tmp-dummy-line nil)
4489 (eval-when-compile (defvar gnus-tmp-header))
4490 (defun gnus-extra-header (type &optional header)
4491 "Return the extra header of TYPE."
4492 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4495 (defvar gnus-tmp-thread-tree-header-string "")
4497 (defcustom gnus-sum-thread-tree-root "> "
4498 "With %B spec, used for the root of a thread.
4499 If nil, use subject instead."
4501 :group 'gnus-thread)
4502 (defcustom gnus-sum-thread-tree-single-indent ""
4503 "With %B spec, used for a thread with just one message.
4504 If nil, use subject instead."
4506 :group 'gnus-thread)
4507 (defcustom gnus-sum-thread-tree-vertical "| "
4508 "With %B spec, used for drawing a vertical line."
4510 :group 'gnus-thread)
4511 (defcustom gnus-sum-thread-tree-indent " "
4512 "With %B spec, used for indenting."
4514 :group 'gnus-thread)
4515 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4516 "With %B spec, used for a leaf with brothers."
4518 :group 'gnus-thread)
4519 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4520 "With %B spec, used for a leaf without brothers."
4522 :group 'gnus-thread)
4524 (defun gnus-summary-prepare-threads (threads)
4525 "Prepare summary buffer from THREADS and indentation LEVEL.
4526 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4527 or a straight list of headers."
4528 (gnus-message 7 "Generating summary...")
4530 (setq gnus-newsgroup-threads threads)
4533 (let ((gnus-tmp-level 0)
4534 (default-score (or gnus-summary-default-score 0))
4535 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4536 (building-line-count gnus-summary-display-while-building)
4537 (building-count (integerp gnus-summary-display-while-building))
4538 thread number subject stack state gnus-tmp-gathered beg-match
4539 new-roots gnus-tmp-new-adopts thread-end simp-subject
4540 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4541 gnus-tmp-replied gnus-tmp-subject-or-nil
4542 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4543 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4544 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4547 (setq gnus-tmp-prev-subject nil
4548 gnus-tmp-thread-tree-header-string "")
4550 (if (vectorp (car threads))
4551 ;; If this is a straight (sic) list of headers, then a
4552 ;; threaded summary display isn't required, so we just create
4553 ;; an unthreaded one.
4554 (gnus-summary-prepare-unthreaded threads)
4556 ;; Do the threaded display.
4558 (if gnus-summary-display-while-building
4559 (switch-to-buffer (buffer-name)))
4560 (while (or threads stack gnus-tmp-new-adopts new-roots)
4562 (if (and (= gnus-tmp-level 0)
4565 (not gnus-tmp-false-parent)
4566 (or gnus-tmp-new-adopts new-roots))
4567 (if gnus-tmp-new-adopts
4568 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4569 thread (list (car gnus-tmp-new-adopts))
4570 gnus-tmp-header (caar thread)
4571 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4573 (setq thread (list (car new-roots))
4574 gnus-tmp-header (caar thread)
4575 new-roots (cdr new-roots))))
4578 ;; If there are some threads, we do them before the
4579 ;; threads on the stack.
4580 (setq thread threads
4581 gnus-tmp-header (caar thread))
4582 ;; There were no current threads, so we pop something off
4584 (setq state (car stack)
4585 gnus-tmp-level (car state)
4586 tree-stack (cadr state)
4587 thread (caddr state)
4589 gnus-tmp-header (caar thread))))
4591 (setq gnus-tmp-false-parent nil)
4592 (setq gnus-tmp-root-expunged nil)
4593 (setq thread-end nil)
4595 (if (stringp gnus-tmp-header)
4596 ;; The header is a dummy root.
4598 ((eq gnus-summary-make-false-root 'adopt)
4599 ;; We let the first article adopt the rest.
4600 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4602 (setq gnus-tmp-gathered
4604 (lambda (h) (mail-header-number (car h)))
4607 (setq thread (cons (list (caar thread)
4610 (setq gnus-tmp-level -1
4611 gnus-tmp-false-parent t))
4612 ((eq gnus-summary-make-false-root 'empty)
4613 ;; We print adopted articles with empty subject fields.
4614 (setq gnus-tmp-gathered
4616 (lambda (h) (mail-header-number (car h)))
4619 (setq gnus-tmp-level -1))
4620 ((eq gnus-summary-make-false-root 'dummy)
4621 ;; We remember that we probably want to output a dummy
4623 (setq gnus-tmp-dummy-line gnus-tmp-header)
4624 (setq gnus-tmp-prev-subject gnus-tmp-header))
4626 ;; We do not make a root for the gathered
4627 ;; sub-threads at all.
4628 (setq gnus-tmp-level -1)))
4630 (setq number (mail-header-number gnus-tmp-header)
4631 subject (mail-header-subject gnus-tmp-header)
4632 simp-subject (gnus-simplify-subject-fully subject))
4635 ;; If the thread has changed subject, we might want to make
4636 ;; this subthread into a root.
4637 ((and (null gnus-thread-ignore-subject)
4638 (not (zerop gnus-tmp-level))
4639 gnus-tmp-prev-subject
4640 (not (string= gnus-tmp-prev-subject simp-subject)))
4641 (setq new-roots (nconc new-roots (list (car thread)))
4643 gnus-tmp-header nil))
4644 ;; If the article lies outside the current limit,
4645 ;; then we do not display it.
4646 ((not (memq number gnus-newsgroup-limit))
4647 (setq gnus-tmp-gathered
4649 (lambda (h) (mail-header-number (car h)))
4652 (setq gnus-tmp-new-adopts (if (cdar thread)
4653 (append gnus-tmp-new-adopts
4655 gnus-tmp-new-adopts)
4657 gnus-tmp-header nil)
4658 (when (zerop gnus-tmp-level)
4659 (setq gnus-tmp-root-expunged t)))
4660 ;; Perhaps this article is to be marked as read?
4661 ((and gnus-summary-mark-below
4662 (< (or (cdr (assq number gnus-newsgroup-scored))
4664 gnus-summary-mark-below)
4665 ;; Don't touch sparse articles.
4666 (not (gnus-summary-article-sparse-p number))
4667 (not (gnus-summary-article-ancient-p number)))
4668 (setq gnus-newsgroup-unreads
4669 (delq number gnus-newsgroup-unreads))
4670 (if gnus-newsgroup-auto-expire
4671 (setq gnus-newsgroup-expirable
4672 (gnus-add-to-sorted-list
4673 gnus-newsgroup-expirable number))
4674 (push (cons number gnus-low-score-mark)
4675 gnus-newsgroup-reads))))
4677 (when gnus-tmp-header
4678 ;; We may have an old dummy line to output before this
4680 (when (and gnus-tmp-dummy-line
4683 (mail-header-subject gnus-tmp-header)))
4684 (gnus-summary-insert-dummy-line
4685 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4686 (setq gnus-tmp-dummy-line nil))
4688 ;; Compute the mark.
4689 (setq gnus-tmp-unread (gnus-article-mark number))
4691 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4692 gnus-tmp-header gnus-tmp-level)
4693 gnus-newsgroup-data)
4695 ;; Actually insert the line.
4697 gnus-tmp-subject-or-nil
4699 ((and gnus-thread-ignore-subject
4700 gnus-tmp-prev-subject
4701 (not (string= gnus-tmp-prev-subject simp-subject)))
4703 ((zerop gnus-tmp-level)
4704 (if (and (eq gnus-summary-make-false-root 'empty)
4705 (memq number gnus-tmp-gathered)
4706 gnus-tmp-prev-subject
4707 (string= gnus-tmp-prev-subject simp-subject))
4708 gnus-summary-same-subject
4710 (t gnus-summary-same-subject)))
4711 (if (and (eq gnus-summary-make-false-root 'adopt)
4712 (= gnus-tmp-level 1)
4713 (memq number gnus-tmp-gathered))
4714 (setq gnus-tmp-opening-bracket ?\<
4715 gnus-tmp-closing-bracket ?\>)
4716 (setq gnus-tmp-opening-bracket ?\[
4717 gnus-tmp-closing-bracket ?\]))
4719 gnus-tmp-indentation
4720 (aref gnus-thread-indent-array gnus-tmp-level)
4721 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4722 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4723 gnus-summary-default-score 0)
4725 (if (or (null gnus-summary-default-score)
4726 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4727 gnus-summary-zcore-fuzz))
4729 (if (< gnus-tmp-score gnus-summary-default-score)
4730 gnus-score-below-mark gnus-score-over-mark))
4732 (cond ((memq number gnus-newsgroup-processable)
4734 ((memq number gnus-newsgroup-cached)
4736 ((memq number gnus-newsgroup-replied)
4738 ((memq number gnus-newsgroup-forwarded)
4739 gnus-forwarded-mark)
4740 ((memq number gnus-newsgroup-saved)
4742 ((memq number gnus-newsgroup-recent)
4744 ((memq number gnus-newsgroup-unseen)
4748 (cond ((memq number gnus-newsgroup-undownloaded)
4749 gnus-undownloaded-mark)
4750 (gnus-newsgroup-agentized
4751 gnus-downloaded-mark)
4754 gnus-tmp-from (mail-header-from gnus-tmp-header)
4757 ((string-match "<[^>]+> *$" gnus-tmp-from)
4758 (setq beg-match (match-beginning 0))
4759 (or (and (string-match "^\".+\"" gnus-tmp-from)
4760 (substring gnus-tmp-from 1 (1- (match-end 0))))
4761 (substring gnus-tmp-from 0 beg-match)))
4762 ((string-match "(.+)" gnus-tmp-from)
4763 (substring gnus-tmp-from
4764 (1+ (match-beginning 0)) (1- (match-end 0))))
4766 gnus-tmp-thread-tree-header-string
4768 ((not gnus-show-threads) "")
4769 ((zerop gnus-tmp-level)
4771 (or gnus-sum-thread-tree-root subject)
4772 (or gnus-sum-thread-tree-single-indent subject)))
4774 (concat (apply 'concat
4775 (mapcar (lambda (item)
4777 gnus-sum-thread-tree-vertical
4778 gnus-sum-thread-tree-indent))
4779 (cdr (reverse tree-stack))))
4781 gnus-sum-thread-tree-leaf-with-other
4782 gnus-sum-thread-tree-single-leaf)))))
4783 (when (string= gnus-tmp-name "")
4784 (setq gnus-tmp-name gnus-tmp-from))
4785 (unless (numberp gnus-tmp-lines)
4786 (setq gnus-tmp-lines -1))
4787 (if (= gnus-tmp-lines -1)
4788 (setq gnus-tmp-lines "?")
4789 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4790 (gnus-put-text-property
4792 (progn (eval gnus-summary-line-format-spec) (point))
4793 'gnus-number number)
4796 (gnus-run-hooks 'gnus-summary-update-hook)
4799 (setq gnus-tmp-prev-subject simp-subject)))
4801 (when (nth 1 thread)
4802 (push (list (max 0 gnus-tmp-level)
4803 (copy-list tree-stack)
4806 (push (if (nth 1 thread) 1 0) tree-stack)
4807 (incf gnus-tmp-level)
4808 (setq threads (if thread-end nil (cdar thread)))
4809 (if gnus-summary-display-while-building
4812 ;; use a set frequency
4813 (setq building-line-count (1- building-line-count))
4814 (when (= building-line-count 0)
4816 (setq building-line-count
4817 gnus-summary-display-while-building)))
4821 (setq gnus-tmp-level 0)))))
4822 (gnus-message 7 "Generating summary...done"))
4824 (defun gnus-summary-prepare-unthreaded (headers)
4825 "Generate an unthreaded summary buffer based on HEADERS."
4826 (let (header number mark)
4831 ;; We may have to root out some bad articles...
4832 (when (memq (setq number (mail-header-number
4833 (setq header (pop headers))))
4834 gnus-newsgroup-limit)
4835 ;; Mark article as read when it has a low score.
4836 (when (and gnus-summary-mark-below
4837 (< (or (cdr (assq number gnus-newsgroup-scored))
4838 gnus-summary-default-score 0)
4839 gnus-summary-mark-below)
4840 (not (gnus-summary-article-ancient-p number)))
4841 (setq gnus-newsgroup-unreads
4842 (delq number gnus-newsgroup-unreads))
4843 (if gnus-newsgroup-auto-expire
4844 (push number gnus-newsgroup-expirable)
4845 (push (cons number gnus-low-score-mark)
4846 gnus-newsgroup-reads)))
4848 (setq mark (gnus-article-mark number))
4849 (push (gnus-data-make number mark (1+ (point)) header 0)
4850 gnus-newsgroup-data)
4851 (gnus-summary-insert-line
4853 (memq number gnus-newsgroup-undownloaded)
4854 mark (memq number gnus-newsgroup-replied)
4855 (memq number gnus-newsgroup-expirable)
4856 (mail-header-subject header) nil
4857 (cdr (assq number gnus-newsgroup-scored))
4858 (memq number gnus-newsgroup-processable))))))
4860 (defun gnus-summary-remove-list-identifiers ()
4861 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4862 (let ((regexp (if (consp gnus-list-identifiers)
4863 (mapconcat 'identity gnus-list-identifiers " *\\|")
4864 gnus-list-identifiers))
4867 (dolist (header gnus-newsgroup-headers)
4868 (setq subject (mail-header-subject header)
4870 (while (string-match
4871 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4874 (concat (substring subject 0 (match-beginning 2))
4875 (substring subject (match-end 0)))
4879 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4881 (concat (substring subject 0 (match-beginning 1))
4882 (substring subject (match-end 1)))))
4884 (mail-header-set-subject header subject))))))
4886 (defun gnus-fetch-headers (articles)
4887 "Fetch headers of ARTICLES."
4888 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4889 (gnus-message 5 "Fetching headers for %s..." name)
4892 (setq gnus-headers-retrieved-by
4893 (gnus-retrieve-headers
4894 articles gnus-newsgroup-name
4895 ;; We might want to fetch old headers, but
4896 ;; not if there is only 1 article.
4898 (not (eq gnus-fetch-old-headers 'some))
4899 (not (numberp gnus-fetch-old-headers)))
4900 (> (length articles) 1))
4901 gnus-fetch-old-headers))))
4902 (gnus-get-newsgroup-headers-xover
4903 articles nil nil gnus-newsgroup-name t)
4904 (gnus-get-newsgroup-headers))
4905 (gnus-message 5 "Fetching headers for %s...done" name))))
4907 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4908 "Select newsgroup GROUP.
4909 If READ-ALL is non-nil, all articles in the group are selected.
4910 If SELECT-ARTICLES, only select those articles from GROUP."
4911 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4912 ;;!!! Dirty hack; should be removed.
4913 (gnus-summary-ignore-duplicates
4914 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4916 gnus-summary-ignore-duplicates))
4917 (info (nth 2 entry))
4918 articles fetched-articles cached)
4920 (unless (gnus-check-server
4921 (set (make-local-variable 'gnus-current-select-method)
4922 (gnus-find-method-for-group group)))
4923 (error "Couldn't open server"))
4925 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4926 (gnus-activate-group group) ; Or we can activate it...
4927 (progn ; Or we bug out.
4928 (when (equal major-mode 'gnus-summary-mode)
4929 (gnus-kill-buffer (current-buffer)))
4930 (error "Couldn't activate group %s: %s"
4931 group (gnus-status-message group))))
4933 (unless (gnus-request-group group t)
4934 (when (equal major-mode 'gnus-summary-mode)
4935 (gnus-kill-buffer (current-buffer)))
4936 (error "Couldn't request group %s: %s"
4937 group (gnus-status-message group)))
4939 (setq gnus-newsgroup-name group
4940 gnus-newsgroup-unselected nil
4941 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4943 (let ((display (gnus-group-find-parameter group 'display)))
4944 (setq gnus-newsgroup-display
4946 ((not (zerop (or (car-safe read-all) 0)))
4947 ;; The user entered the group with C-u SPC/RET, let's show
4953 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4955 ;; The following is probably the "correct" solution, but
4956 ;; it makes Gnus fetch all headers and then limit the
4957 ;; articles (which is slow), so instead we hack the
4958 ;; select-articles parameter instead. -- Simon Josefsson
4961 ;; (gnus-byte-compile
4962 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4964 (setq select-articles
4965 (gnus-uncompress-range
4966 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4970 (cdr (gnus-active group)))))
4975 (gnus-summary-setup-default-charset)
4977 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4978 (when (gnus-virtual-group-p group)
4979 (setq cached gnus-newsgroup-cached))
4981 (setq gnus-newsgroup-unreads
4982 (gnus-sorted-ndifference
4983 (gnus-sorted-ndifference gnus-newsgroup-unreads
4984 gnus-newsgroup-marked)
4985 gnus-newsgroup-dormant))
4987 (setq gnus-newsgroup-processable nil)
4989 (gnus-update-read-articles group gnus-newsgroup-unreads)
4991 ;; Adjust and set lists of article marks.
4993 (gnus-adjust-marked-articles info))
4994 (if (setq articles select-articles)
4995 (setq gnus-newsgroup-unselected
4996 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4997 (setq articles (gnus-articles-to-read group read-all)))
5001 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5003 ((eq articles 0) nil)
5005 ;; Init the dependencies hash table.
5006 (setq gnus-newsgroup-dependencies
5007 (gnus-make-hashtable (length articles)))
5008 (gnus-set-global-variables)
5009 ;; Retrieve the headers and read them in.
5011 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5013 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5015 (setq gnus-newsgroup-cached cached))
5017 ;; Suppress duplicates?
5018 (when gnus-suppress-duplicates
5019 (gnus-dup-suppress-articles))
5021 ;; Set the initial limit.
5022 (setq gnus-newsgroup-limit (copy-sequence articles))
5023 ;; Remove canceled articles from the list of unread articles.
5024 (setq fetched-articles
5025 (mapcar (lambda (headers) (mail-header-number headers))
5026 gnus-newsgroup-headers))
5027 (setq gnus-newsgroup-articles fetched-articles)
5028 (setq gnus-newsgroup-unreads
5029 (gnus-sorted-nintersection
5030 gnus-newsgroup-unreads fetched-articles))
5031 (gnus-compute-unseen-list)
5033 ;; Removed marked articles that do not exist.
5034 (gnus-update-missing-marks
5035 (gnus-sorted-difference articles fetched-articles))
5036 ;; We might want to build some more threads first.
5037 (when (and gnus-fetch-old-headers
5038 (eq gnus-headers-retrieved-by 'nov))
5039 (if (eq gnus-fetch-old-headers 'invisible)
5040 (gnus-build-all-threads)
5041 (gnus-build-old-threads)))
5042 ;; Let the Gnus agent mark articles as read.
5044 (gnus-agent-get-undownloaded-list))
5045 ;; Remove list identifiers from subject
5046 (when gnus-list-identifiers
5047 (gnus-summary-remove-list-identifiers))
5048 ;; Check whether auto-expire is to be done in this group.
5049 (setq gnus-newsgroup-auto-expire
5050 (gnus-group-auto-expirable-p group))
5051 ;; Set up the article buffer now, if necessary.
5052 (unless gnus-single-article-buffer
5053 (gnus-article-setup-buffer))
5054 ;; First and last article in this newsgroup.
5055 (when gnus-newsgroup-headers
5056 (setq gnus-newsgroup-begin
5057 (mail-header-number (car gnus-newsgroup-headers))
5060 (gnus-last-element gnus-newsgroup-headers))))
5061 ;; GROUP is successfully selected.
5062 (or gnus-newsgroup-headers t)))))
5064 (defun gnus-compute-unseen-list ()
5065 ;; The `seen' marks are treated specially.
5066 (if (not gnus-newsgroup-seen)
5067 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5068 (setq gnus-newsgroup-unseen
5069 (gnus-inverse-list-range-intersection
5070 gnus-newsgroup-articles gnus-newsgroup-seen))))
5072 (defun gnus-summary-display-make-predicate (display)
5073 (require 'gnus-agent)
5074 (when (= (length display) 1)
5075 (setq display (car display)))
5076 (unless gnus-summary-display-cache
5077 (dolist (elem (append '((unread . unread)
5080 gnus-article-mark-lists))
5081 (push (cons (cdr elem)
5083 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5084 gnus-summary-display-cache)))
5085 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5086 (gnus-category-predicate-cache gnus-summary-display-cache))
5087 (gnus-get-predicate display)))
5089 ;; Uses the dynamically bound `number' variable.
5092 (defun gnus-article-marked-p (type &optional article)
5093 (let ((article (or article number)))
5096 (memq article gnus-newsgroup-marked))
5098 (memq article gnus-newsgroup-spam-marked))
5100 (memq article gnus-newsgroup-unsendable))
5101 ((eq type 'undownload)
5102 (memq article gnus-newsgroup-undownloaded))
5103 ((eq type 'download)
5104 (memq article gnus-newsgroup-downloadable))
5106 (memq article gnus-newsgroup-unreads))
5108 (memq article gnus-newsgroup-reads))
5110 (memq article gnus-newsgroup-dormant) )
5112 (memq article gnus-newsgroup-expirable))
5114 (memq article gnus-newsgroup-replied))
5116 (memq article gnus-newsgroup-killed))
5117 ((eq type 'bookmark)
5118 (assq article gnus-newsgroup-bookmarks))
5120 (assq article gnus-newsgroup-scored))
5122 (memq article gnus-newsgroup-saved))
5124 (memq article gnus-newsgroup-cached))
5126 (memq article gnus-newsgroup-forwarded))
5128 (not (memq article gnus-newsgroup-unseen)))
5130 (memq article gnus-newsgroup-recent))
5133 (defun gnus-articles-to-read (group &optional read-all)
5134 "Find out what articles the user wants to read."
5135 (let* ((display (gnus-group-find-parameter group 'display))
5137 ;; Select all articles if `read-all' is non-nil, or if there
5138 ;; are no unread articles.
5140 (and (zerop (length gnus-newsgroup-marked))
5141 (zerop (length gnus-newsgroup-unreads)))
5142 ;; Fetch all if the predicate is non-nil.
5143 gnus-newsgroup-display)
5144 ;; We want to select the headers for all the articles in
5145 ;; the group, so we select either all the active
5146 ;; articles in the group, or (if that's nil), the
5147 ;; articles in the cache.
5149 (gnus-uncompress-range (gnus-active group))
5150 (gnus-cache-articles-in-group group))
5151 ;; Select only the "normal" subset of articles.
5153 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5154 gnus-newsgroup-unreads)))
5155 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5156 (scored (length scored-list))
5157 (number (length articles))
5158 (marked (+ (length gnus-newsgroup-marked)
5159 (length gnus-newsgroup-dormant)))
5164 ((numberp gnus-newsgroup-display)
5165 gnus-newsgroup-display)
5169 ((and (or (<= scored marked) (= scored number))
5170 (numberp gnus-large-newsgroup)
5171 (> number gnus-large-newsgroup))
5172 (let* ((cursor-in-echo-area nil)
5173 (initial (gnus-parameter-large-newsgroup-initial
5174 gnus-newsgroup-name))
5178 "How many articles from %s (%s %d): "
5180 (gnus-group-decoded-name gnus-newsgroup-name)
5182 (if initial "max" "default")
5185 (cons (number-to-string initial)
5187 (if (string-match "^[ \t]*$" input) number input)))
5188 ((and (> scored marked) (< scored number)
5189 (> (- scored number) 20))
5192 (format "%s %s (%d scored, %d total): "
5193 "How many articles from"
5194 (gnus-group-decoded-name group)
5196 (if (string-match "^[ \t]*$" input)
5200 (message "Quit getting the articles to read")
5202 (setq select (if (stringp select) (string-to-number select) select))
5203 (if (or (null select) (zerop select))
5205 (if (and (not (zerop scored)) (<= (abs select) scored))
5207 (setq articles (sort scored-list '<))
5208 (setq number (length articles)))
5209 (setq articles (copy-sequence articles)))
5211 (when (< (abs select) number)
5213 ;; Select the N oldest articles.
5214 (setcdr (nthcdr (1- (abs select)) articles) nil)
5215 ;; Select the N most recent articles.
5216 (setq articles (nthcdr (- number select) articles))))
5217 (setq gnus-newsgroup-unselected
5218 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5219 (when gnus-alter-articles-to-read-function
5222 (funcall gnus-alter-articles-to-read-function
5223 gnus-newsgroup-name articles)
5227 (defun gnus-killed-articles (killed articles)
5230 (when (inline (gnus-member-of-range (car articles) killed))
5231 (push (car articles) out))
5232 (setq articles (cdr articles)))
5235 (defun gnus-uncompress-marks (marks)
5236 "Uncompress the mark ranges in MARKS."
5237 (let ((uncompressed '(score bookmark))
5240 (if (memq (caar marks) uncompressed)
5241 (push (car marks) out)
5242 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5243 (setq marks (cdr marks)))
5246 (defun gnus-article-mark-to-type (mark)
5247 "Return the type of MARK."
5248 (or (cadr (assq mark gnus-article-special-mark-lists))
5251 (defun gnus-article-unpropagatable-p (mark)
5252 "Return whether MARK should be propagated to backend."
5253 (memq mark gnus-article-unpropagated-mark-lists))
5255 (defun gnus-adjust-marked-articles (info)
5256 "Set all article lists and remove all marks that are no longer valid."
5257 (let* ((marked-lists (gnus-info-marks info))
5258 (active (gnus-active (gnus-info-group info)))
5261 (types gnus-article-mark-lists)
5262 marks var articles article mark mark-type)
5264 (dolist (marks marked-lists)
5265 (setq mark (car marks)
5266 mark-type (gnus-article-mark-to-type mark)
5267 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5269 ;; We set the variable according to the type of the marks list,
5270 ;; and then adjust the marks to a subset of the active articles.
5272 ;; Adjust "simple" lists.
5273 ((eq mark-type 'list)
5274 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5275 (when (memq mark '(tick dormant expire reply save))
5277 (when (or (< (setq article (pop articles)) min) (> article max))
5278 (set var (delq article (symbol-value var)))))))
5280 ((eq mark-type 'tuple)
5281 (set var (setq articles (cdr marks)))
5282 (when (not (listp (cdr (symbol-value var))))
5283 (set var (list (symbol-value var))))
5284 (when (not (listp (cdr articles)))
5285 (setq articles (list articles)))
5287 (when (or (not (consp (setq article (pop articles))))
5288 (< (car article) min)
5289 (> (car article) max))
5290 (set var (delq article (symbol-value var))))))
5291 ;; Adjust ranges (sloppily).
5292 ((eq mark-type 'range)
5295 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5296 ;; It should be (seen (NUM1 . NUM2)).
5297 (when (numberp (cddr marks))
5298 (setcdr marks (list (cdr marks))))
5299 (setq articles (cdr marks))
5300 (while (and articles
5301 (or (and (consp (car articles))
5302 (> min (cdar articles)))
5303 (and (numberp (car articles))
5304 (> min (car articles)))))
5306 (set var articles))))))))
5308 (defun gnus-update-missing-marks (missing)
5309 "Go through the list of MISSING articles and remove them from the mark lists."
5312 ;; Go through all types.
5313 (dolist (elem gnus-article-mark-lists)
5314 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5315 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5316 (when (symbol-value var)
5317 ;; This list has articles. So we delete all missing
5318 ;; articles from it.
5321 (set var (delq (pop m) (symbol-value var))))))))))
5323 (defun gnus-update-marks ()
5324 "Enter the various lists of marked articles into the newsgroup info list."
5325 (let ((types gnus-article-mark-lists)
5326 (info (gnus-get-info gnus-newsgroup-name))
5327 type list newmarked symbol delta-marks)
5329 ;; Add all marks lists to the list of marks lists.
5330 (while (setq type (pop types))
5331 (setq list (symbol-value
5333 (intern (format "gnus-newsgroup-%s" (car type))))))
5336 ;; Get rid of the entries of the articles that have the
5338 (when (and (eq (cdr type) 'score)
5342 (prev (cons nil list))
5345 (if (or (not (consp (car arts)))
5346 (= (cdar arts) gnus-summary-default-score))
5347 (setcdr prev (cdr arts))
5349 (setq arts (cdr arts)))
5350 (setq list (cdr all)))))
5352 (when (eq (cdr type) 'seen)
5353 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5355 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5356 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5358 (when (and (gnus-check-backend-function
5359 'request-set-mark gnus-newsgroup-name)
5360 (not (gnus-article-unpropagatable-p (cdr type))))
5361 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5362 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5363 (add (gnus-remove-from-range
5364 (gnus-copy-sequence list) old)))
5366 (push (list add 'add (list (cdr type))) delta-marks))
5368 (push (list del 'del (list (cdr type))) delta-marks))))
5371 (push (cons (cdr type) list) newmarked)))
5374 (unless (gnus-check-group gnus-newsgroup-name)
5375 (error "Can't open server for %s" gnus-newsgroup-name))
5376 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5378 ;; Enter these new marks into the info of the group.
5380 (setcar (nthcdr 3 info) newmarked)
5381 ;; Add the marks lists to the end of the info.
5383 (setcdr (nthcdr 2 info) (list newmarked))))
5385 ;; Cut off the end of the info if there's nothing else there.
5389 (when (nthcdr (decf i) info)
5390 (setcdr (nthcdr i info) nil)))))))
5392 (defun gnus-set-mode-line (where)
5393 "Set the mode line of the article or summary buffers.
5394 If WHERE is `summary', the summary mode line format will be used."
5395 ;; Is this mode line one we keep updated?
5396 (when (and (memq where gnus-updated-mode-lines)
5398 (intern (format "gnus-%s-mode-line-format-spec" where))))
5401 ;; We evaluate this in the summary buffer since these
5402 ;; variables are buffer-local to that buffer.
5403 (set-buffer gnus-summary-buffer)
5404 ;; We bind all these variables that are used in the `eval' form
5406 (let* ((mformat (symbol-value
5408 (format "gnus-%s-mode-line-format-spec" where))))
5409 (gnus-tmp-group-name (gnus-group-decoded-name
5410 gnus-newsgroup-name))
5411 (gnus-tmp-article-number (or gnus-current-article 0))
5412 (gnus-tmp-unread gnus-newsgroup-unreads)
5413 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5414 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5415 (gnus-tmp-unread-and-unselected
5416 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5417 (zerop gnus-tmp-unselected))
5419 ((zerop gnus-tmp-unselected)
5420 (format "{%d more}" gnus-tmp-unread-and-unticked))
5421 (t (format "{%d(+%d) more}"
5422 gnus-tmp-unread-and-unticked
5423 gnus-tmp-unselected))))
5425 (if (and gnus-current-headers
5426 (vectorp gnus-current-headers))
5427 (gnus-mode-string-quote
5428 (mail-header-subject gnus-current-headers))
5430 bufname-length max-len
5431 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5432 (setq mode-string (eval mformat))
5433 (setq bufname-length (if (string-match "%b" mode-string)
5436 (if (eq where 'summary)
5438 (get-buffer gnus-article-buffer))))
5441 (setq max-len (max 4 (if gnus-mode-non-string-length
5443 gnus-mode-non-string-length
5445 (length mode-string))))
5446 ;; We might have to chop a bit of the string off...
5447 (when (> (length mode-string) max-len)
5449 (concat (truncate-string-to-width mode-string (- max-len 3))
5451 ;; Pad the mode string a bit.
5452 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5453 ;; Update the mode line.
5454 (setq mode-line-buffer-identification
5455 (gnus-mode-line-buffer-identification (list mode-string)))
5456 (set-buffer-modified-p t))))
5458 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5459 "Go through the HEADERS list and add all Xrefs to a hash table.
5460 The resulting hash table is returned, or nil if no Xrefs were found."
5461 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5462 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5463 (xref-hashtb (gnus-make-hashtable))
5464 start group entry number xrefs header)
5466 (setq header (pop headers))
5467 (when (and (setq xrefs (mail-header-xref header))
5468 (not (memq (setq number (mail-header-number header))
5471 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5472 (setq start (match-end 0))
5473 (setq group (if prefix
5474 (concat prefix (substring xrefs (match-beginning 1)
5476 (substring xrefs (match-beginning 1) (match-end 1))))
5478 (string-to-int (substring xrefs (match-beginning 2)
5480 (if (setq entry (gnus-gethash group xref-hashtb))
5481 (setcdr entry (cons number (cdr entry)))
5482 (gnus-sethash group (cons number nil) xref-hashtb)))))
5483 (and start xref-hashtb)))
5485 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5486 "Look through all the headers and mark the Xrefs as read."
5487 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5488 name entry info xref-hashtb idlist method nth4)
5490 (set-buffer gnus-group-buffer)
5491 (when (setq xref-hashtb
5492 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5495 (unless (string= from-newsgroup (setq name (symbol-name group)))
5496 (setq idlist (symbol-value group))
5497 ;; Dead groups are not updated.
5499 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5501 (when (stringp (setq nth4 (gnus-info-method info)))
5502 (setq nth4 (gnus-server-to-method nth4))))
5503 ;; Only do the xrefs if the group has the same
5504 ;; select method as the group we have just read.
5505 (or (gnus-methods-equal-p
5506 nth4 (gnus-find-method-for-group from-newsgroup))
5508 (equal nth4 (setq method (gnus-find-method-for-group
5510 (and (equal (car nth4) (car method))
5511 (equal (nth 1 nth4) (nth 1 method))))
5512 gnus-use-cross-reference
5513 (or (not (eq gnus-use-cross-reference t))
5515 ;; Only do cross-references on subscribed
5516 ;; groups, if that is what is wanted.
5517 (<= (gnus-info-level info) gnus-level-subscribed))
5518 (gnus-group-make-articles-read name idlist))))
5521 (defun gnus-compute-read-articles (group articles)
5522 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5523 (info (nth 2 entry))
5524 (active (gnus-active group))
5527 ;; First peel off all invalid article numbers.
5529 (let ((ids articles)
5531 (while (setq id (pop ids))
5532 (when (and first (> id (cdr active)))
5533 ;; We'll end up in this situation in one particular
5534 ;; obscure situation. If you re-scan a group and get
5535 ;; a new article that is cross-posted to a different
5536 ;; group that has not been re-scanned, you might get
5537 ;; crossposted article that has a higher number than
5538 ;; Gnus believes possible. So we re-activate this
5539 ;; group as well. This might mean doing the
5540 ;; crossposting thingy will *increase* the number
5541 ;; of articles in some groups. Tsk, tsk.
5542 (setq active (or (gnus-activate-group group) active)))
5543 (when (or (> id (cdr active))
5544 (< id (car active)))
5545 (setq articles (delq id articles))))))
5546 ;; If the read list is nil, we init it.
5548 (null (gnus-info-read info))
5550 (setq ninfo (cons 1 (1- (car active))))
5551 (setq ninfo (gnus-info-read info)))
5552 ;; Then we add the read articles to the range.
5554 ninfo (setq articles (sort articles '<))))))
5556 (defun gnus-group-make-articles-read (group articles)
5557 "Update the info of GROUP to say that ARTICLES are read."
5559 (entry (gnus-gethash group gnus-newsrc-hashtb))
5560 (info (nth 2 entry))
5561 (active (gnus-active group))
5564 (setq range (gnus-compute-read-articles group articles))
5566 (set-buffer gnus-group-buffer)
5569 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5570 (gnus-info-set-read ',info ',(gnus-info-read info))
5571 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5572 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5573 (gnus-group-update-group ,group t))))
5574 ;; Add the read articles to the range.
5575 (gnus-info-set-read info range)
5576 (gnus-request-set-mark group (list (list range 'add '(read))))
5577 ;; Then we have to re-compute how many unread
5578 ;; articles there are in this group.
5582 (setq num (- (1+ (cdr active)) (car active))))
5583 ((not (listp (cdr range)))
5584 (setq num (- (cdr active) (- (1+ (cdr range))
5588 (if (numberp (car range))
5590 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5591 (setq range (cdr range)))
5592 (setq num (- (cdr active) num))))
5593 ;; Update the number of unread articles.
5595 ;; Update the group buffer.
5596 (unless (gnus-ephemeral-group-p group)
5597 (gnus-group-update-group group t))))))
5599 (defvar gnus-newsgroup-none-id 0)
5601 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5602 (let ((cur nntp-server-buffer)
5605 (save-excursion (set-buffer gnus-summary-buffer)
5606 gnus-newsgroup-dependencies)))
5608 (mail-parse-charset gnus-newsgroup-charset)
5609 (mail-parse-ignored-charsets
5610 (save-excursion (condition-case nil
5611 (set-buffer gnus-summary-buffer)
5613 gnus-newsgroup-ignored-charsets)))
5615 (set-buffer nntp-server-buffer)
5616 ;; Translate all TAB characters into SPACE characters.
5617 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5618 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5619 (gnus-run-hooks 'gnus-parse-headers-hook)
5620 (let ((case-fold-search t)
5621 in-reply-to header p lines chars)
5622 (goto-char (point-min))
5623 ;; Search to the beginning of the next header. Error messages
5624 ;; do not begin with 2 or 3.
5625 (while (re-search-forward "^[23][0-9]+ " nil t)
5628 ;; This implementation of this function, with nine
5629 ;; search-forwards instead of the one re-search-forward and
5630 ;; a case (which basically was the old function) is actually
5631 ;; about twice as fast, even though it looks messier. You
5632 ;; can't have everything, I guess. Speed and elegance
5633 ;; doesn't always go hand in hand.
5642 (narrow-to-region (point)
5643 (or (and (search-forward "\n.\n" nil t)
5649 (if (search-forward "\nsubject:" nil t)
5650 (funcall gnus-decode-encoded-word-function
5651 (nnheader-header-value))
5656 (if (search-forward "\nfrom:" nil t)
5657 (funcall gnus-decode-encoded-word-function
5658 (nnheader-header-value))
5663 (if (search-forward "\ndate:" nil t)
5664 (nnheader-header-value) ""))
5668 (setq id (if (re-search-forward
5669 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5670 ;; We do it this way to make sure the Message-ID
5671 ;; is (somewhat) syntactically valid.
5672 (buffer-substring (match-beginning 1)
5674 ;; If there was no message-id, we just fake one
5675 ;; to make subsequent routines simpler.
5676 (nnheader-generate-fake-message-id))))
5680 (if (search-forward "\nreferences:" nil t)
5684 (nnheader-header-value)
5689 (search-backward ">" end t)
5692 (search-backward "<" end t)
5694 ;; Get the references from the in-reply-to header if there
5695 ;; were no references and the in-reply-to header looks
5697 (if (and (search-forward "\nin-reply-to:" nil t)
5698 (setq in-reply-to (nnheader-header-value))
5699 (string-match "<[^>]+>" in-reply-to))
5701 (setq ref (substring in-reply-to (match-beginning 0)
5703 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5704 (setq ref2 (substring in-reply-to (match-beginning 0)
5706 (when (> (length ref2) (length ref))
5713 (if (search-forward "\nchars: " nil t)
5714 (if (numberp (setq chars (ignore-errors (read cur))))
5720 (if (search-forward "\nlines: " nil t)
5721 (if (numberp (setq lines (ignore-errors (read cur))))
5727 (and (search-forward "\nxref:" nil t)
5728 (nnheader-header-value)))
5730 (when gnus-extra-headers
5731 (let ((extra gnus-extra-headers)
5735 (when (search-forward
5736 (concat "\n" (symbol-name (car extra)) ":") nil t)
5737 (push (cons (car extra) (nnheader-header-value))
5741 (when (equal id ref)
5744 (when gnus-alter-header-function
5745 (funcall gnus-alter-header-function header)
5746 (setq id (mail-header-id header)
5747 ref (gnus-parent-id (mail-header-references header))))
5750 (gnus-dependencies-add-header
5751 header dependencies force-new))
5752 (push header headers))
5753 (goto-char (point-max))
5755 (nreverse headers)))))
5757 ;; Goes through the xover lines and returns a list of vectors
5758 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5759 force-new dependencies
5760 group also-fetch-heads)
5761 "Parse the news overview data in the server buffer.
5762 Return a list of headers that match SEQUENCE (see
5763 `nntp-retrieve-headers')."
5764 ;; Get the Xref when the users reads the articles since most/some
5765 ;; NNTP servers do not include Xrefs when using XOVER.
5766 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5767 (let ((mail-parse-charset gnus-newsgroup-charset)
5768 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5769 (cur nntp-server-buffer)
5770 (dependencies (or dependencies gnus-newsgroup-dependencies))
5772 ((eq gnus-read-all-available-headers t)
5774 ((stringp gnus-read-all-available-headers)
5775 (string-match gnus-read-all-available-headers group))
5778 number headers header)
5780 (set-buffer nntp-server-buffer)
5781 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5782 ;; Allow the user to mangle the headers before parsing them.
5783 (gnus-run-hooks 'gnus-parse-headers-hook)
5784 (goto-char (point-min))
5785 (gnus-parse-without-error
5786 (while (and (or sequence allp)
5788 (setq number (read cur))
5790 (while (and sequence
5791 (< (car sequence) number))
5792 (setq sequence (cdr sequence))))
5795 (eq number (car sequence))))
5797 (setq sequence (cdr sequence))
5798 (setq header (inline
5799 (gnus-nov-parse-line
5800 number dependencies force-new)))))
5801 (push header headers))
5803 ;; A common bug in inn is that if you have posted an article and
5804 ;; then retrieves the active file, it will answer correctly --
5805 ;; the new article is included. However, a NOV entry for the
5806 ;; article may not have been generated yet, so this may fail.
5807 ;; We work around this problem by retrieving the last few
5808 ;; headers using HEAD.
5809 (if (or (not also-fetch-heads)
5811 ;; We (probably) got all the headers.
5813 (let ((gnus-nov-is-evil t))
5816 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5817 (gnus-get-newsgroup-headers))))))))
5819 (defun gnus-article-get-xrefs ()
5820 "Fill in the Xref value in `gnus-current-headers', if necessary.
5821 This is meant to be called in `gnus-article-internal-prepare-hook'."
5822 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5823 gnus-current-headers)))
5824 (or (not gnus-use-cross-reference)
5826 (and (mail-header-xref headers)
5827 (not (string= (mail-header-xref headers) "")))
5828 (let ((case-fold-search t)
5831 (nnheader-narrow-to-headers)
5832 (goto-char (point-min))
5833 (when (or (and (not (eobp))
5834 (eq (downcase (char-after)) ?x)
5835 (looking-at "Xref:"))
5836 (search-forward "\nXref:" nil t))
5837 (goto-char (1+ (match-end 0)))
5838 (setq xref (buffer-substring (point)
5839 (progn (end-of-line) (point))))
5840 (mail-header-set-xref headers xref)))))))
5842 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5843 "Find article ID and insert the summary line for that article.
5844 OLD-HEADER can either be a header or a line number to insert
5845 the subject line on."
5846 (let* ((line (and (numberp old-header) old-header))
5847 (old-header (and (vectorp old-header) old-header))
5848 (header (cond ((and old-header use-old-header)
5851 (gnus-number-to-header id))
5852 (gnus-number-to-header id))
5854 (gnus-read-header id))))
5855 (number (and (numberp id) id))
5858 ;; Rebuild the thread that this article is part of and go to the
5859 ;; article we have fetched.
5860 (when (and (not gnus-show-threads)
5863 (setq d (gnus-data-find (mail-header-number old-header))))
5864 (goto-char (gnus-data-pos d))
5867 (- (gnus-point-at-bol)
5869 (1+ (gnus-point-at-eol))
5870 (gnus-delete-line))))))
5872 (mail-header-set-number header (mail-header-number old-header)))
5873 (setq gnus-newsgroup-sparse
5874 (delq (setq number (mail-header-number header))
5875 gnus-newsgroup-sparse))
5876 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5877 (push number gnus-newsgroup-limit)
5878 (gnus-rebuild-thread (mail-header-id header) line)
5879 (gnus-summary-goto-subject number nil t))
5880 (when (and (numberp number)
5882 ;; We have to update the boundaries even if we can't fetch the
5883 ;; article if ID is a number -- so that the next `P' or `N'
5884 ;; command will fetch the previous (or next) article even
5885 ;; if the one we tried to fetch this time has been canceled.
5886 (when (> number gnus-newsgroup-end)
5887 (setq gnus-newsgroup-end number))
5888 (when (< number gnus-newsgroup-begin)
5889 (setq gnus-newsgroup-begin number))
5890 (setq gnus-newsgroup-unselected
5891 (delq number gnus-newsgroup-unselected)))
5892 ;; Report back a success?
5893 (and header (mail-header-number header))))
5895 ;;; Process/prefix in the summary buffer
5897 (defun gnus-summary-work-articles (n)
5898 "Return a list of articles to be worked upon.
5899 The prefix argument, the list of process marked articles, and the
5900 current article will be taken into consideration."
5902 (set-buffer gnus-summary-buffer)
5905 ;; A numerical prefix has been given.
5906 (setq n (prefix-numeric-value n))
5907 (let ((backward (< n 0))
5908 (n (abs (prefix-numeric-value n)))
5913 (push (setq article (gnus-summary-article-number))
5916 (gnus-summary-find-prev nil article)
5917 (gnus-summary-find-next nil article)))
5919 (nreverse articles)))
5920 ((and (gnus-region-active-p) (mark))
5921 (message "region active")
5922 ;; Work on the region between point and mark.
5923 (let ((max (max (point) (mark)))
5926 (goto-char (min (min (point) (mark))))
5929 (push (setq article (gnus-summary-article-number)) articles)
5930 (gnus-summary-find-next nil article)
5932 (nreverse articles))))
5933 (gnus-newsgroup-processable
5934 ;; There are process-marked articles present.
5935 ;; Save current state.
5936 (gnus-summary-save-process-mark)
5938 (reverse gnus-newsgroup-processable))
5940 ;; Just return the current article.
5941 (list (gnus-summary-article-number))))))
5943 (defmacro gnus-summary-iterate (arg &rest forms)
5944 "Iterate over the process/prefixed articles and do FORMS.
5945 ARG is the interactive prefix given to the command. FORMS will be
5946 executed with point over the summary line of the articles."
5947 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5948 `(let ((,articles (gnus-summary-work-articles ,arg)))
5950 (gnus-summary-goto-subject (car ,articles))
5954 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5955 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5957 (defun gnus-summary-save-process-mark ()
5958 "Push the current set of process marked articles on the stack."
5960 (push (copy-sequence gnus-newsgroup-processable)
5961 gnus-newsgroup-process-stack))
5963 (defun gnus-summary-kill-process-mark ()
5964 "Push the current set of process marked articles on the stack and unmark."
5966 (gnus-summary-save-process-mark)
5967 (gnus-summary-unmark-all-processable))
5969 (defun gnus-summary-yank-process-mark ()
5970 "Pop the last process mark state off the stack and restore it."
5972 (unless gnus-newsgroup-process-stack
5973 (error "Empty mark stack"))
5974 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5976 (defun gnus-summary-process-mark-set (set)
5977 "Make SET into the current process marked articles."
5978 (gnus-summary-unmark-all-processable)
5980 (gnus-summary-set-process-mark (pop set))))
5982 ;;; Searching and stuff
5984 (defun gnus-summary-search-group (&optional backward use-level)
5985 "Search for next unread newsgroup.
5986 If optional argument BACKWARD is non-nil, search backward instead."
5988 (set-buffer gnus-group-buffer)
5989 (when (gnus-group-search-forward
5990 backward nil (if use-level (gnus-group-group-level) nil))
5991 (gnus-group-group-name))))
5993 (defun gnus-summary-best-group (&optional exclude-group)
5994 "Find the name of the best unread group.
5995 If EXCLUDE-GROUP, do not go to this group."
5997 (set-buffer gnus-group-buffer)
5999 (gnus-group-best-unread-group exclude-group))))
6001 (defun gnus-summary-find-next (&optional unread article backward)
6002 (if backward (gnus-summary-find-prev)
6003 (let* ((dummy (gnus-summary-article-intangible-p))
6004 (article (or article (gnus-summary-article-number)))
6005 (data (gnus-data-find-list article))
6007 (when (and (not dummy)
6008 (or (not gnus-summary-check-current)
6010 (not (gnus-data-unread-p (car data)))))
6011 (setq data (cdr data)))
6016 (unless (memq (gnus-data-number (car data))
6017 gnus-newsgroup-unfetched)
6018 (when (gnus-data-unread-p (car data))
6019 (setq result (car data)
6021 (setq data (cdr data)))
6024 (goto-char (gnus-data-pos result))
6025 (gnus-data-number result)))))
6027 (defun gnus-summary-find-prev (&optional unread article)
6028 (let* ((eobp (eobp))
6029 (article (or article (gnus-summary-article-number)))
6030 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6032 (when (and (not eobp)
6033 (or (not gnus-summary-check-current)
6035 (not (gnus-data-unread-p (car data)))))
6036 (setq data (cdr data)))
6041 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6042 (when (gnus-data-unread-p (car data))
6043 (setq result (car data)
6045 (setq data (cdr data)))
6048 (goto-char (gnus-data-pos result))
6049 (gnus-data-number result))))
6051 (defun gnus-summary-find-subject (subject &optional unread backward article)
6052 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6053 (article (or article (gnus-summary-article-number)))
6054 (articles (gnus-data-list backward))
6055 (arts (gnus-data-find-list article articles))
6057 (when (or (not gnus-summary-check-current)
6059 (not (gnus-data-unread-p (car arts))))
6060 (setq arts (cdr arts)))
6062 (and (or (not unread)
6063 (gnus-data-unread-p (car arts)))
6064 (vectorp (gnus-data-header (car arts)))
6066 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6067 (setq result (car arts)
6069 (setq arts (cdr arts)))
6071 (goto-char (gnus-data-pos result))
6072 (gnus-data-number result))))
6074 (defun gnus-summary-search-forward (&optional unread subject backward)
6075 "Search forward for an article.
6076 If UNREAD, look for unread articles. If SUBJECT, look for
6077 articles with that subject. If BACKWARD, search backward instead."
6078 (cond (subject (gnus-summary-find-subject subject unread backward))
6079 (backward (gnus-summary-find-prev unread))
6080 (t (gnus-summary-find-next unread))))
6082 (defun gnus-recenter (&optional n)
6083 "Center point in window and redisplay frame.
6084 Also do horizontal recentering."
6086 (when (and gnus-auto-center-summary
6087 (not (eq gnus-auto-center-summary 'vertical)))
6088 (gnus-horizontal-recenter))
6091 (defun gnus-summary-recenter ()
6092 "Center point in the summary window.
6093 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6094 displayed, no centering will be performed."
6095 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6096 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6098 ;; The user has to want it.
6099 (when gnus-auto-center-summary
6100 (let* ((top (cond ((< (window-height) 4) 0)
6101 ((< (window-height) 7) 1)
6102 (t (if (numberp gnus-auto-center-summary)
6103 gnus-auto-center-summary
6105 (height (1- (window-height)))
6106 (bottom (save-excursion (goto-char (point-max))
6107 (forward-line (- height))
6109 (window (get-buffer-window (current-buffer))))
6110 (when (get-buffer-window gnus-article-buffer)
6111 ;; Only do recentering when the article buffer is displayed,
6112 ;; Set the window start to either `bottom', which is the biggest
6113 ;; possible valid number, or the second line from the top,
6114 ;; whichever is the least.
6115 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6116 (if (> bottom top-pos)
6117 ;; Keep the second line from the top visible
6118 (set-window-start window top-pos t)
6119 ;; Try to keep the bottom line visible; if it's partially
6120 ;; obscured, either scroll one more line to make it fully
6121 ;; visible, or revert to using TOP-POS.
6123 (goto-char (point-max))
6125 (let ((last-line-start (point)))
6127 (set-window-start window (point) t)
6128 (when (not (pos-visible-in-window-p last-line-start window))
6130 (set-window-start window (min (point) top-pos) t)))))))
6131 ;; Do horizontal recentering while we're at it.
6132 (when (and (get-buffer-window (current-buffer) t)
6133 (not (eq gnus-auto-center-summary 'vertical)))
6134 (let ((selected (selected-window)))
6135 (select-window (get-buffer-window (current-buffer) t))
6136 (gnus-summary-position-point)
6137 (gnus-horizontal-recenter)
6138 (select-window selected))))))
6140 (defun gnus-summary-jump-to-group (newsgroup)
6141 "Move point to NEWSGROUP in group mode buffer."
6142 ;; Keep update point of group mode buffer if visible.
6143 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6144 (save-window-excursion
6145 ;; Take care of tree window mode.
6146 (when (get-buffer-window gnus-group-buffer)
6147 (pop-to-buffer gnus-group-buffer))
6148 (gnus-group-jump-to-group newsgroup))
6150 ;; Take care of tree window mode.
6151 (if (get-buffer-window gnus-group-buffer)
6152 (pop-to-buffer gnus-group-buffer)
6153 (set-buffer gnus-group-buffer))
6154 (gnus-group-jump-to-group newsgroup))))
6156 ;; This function returns a list of article numbers based on the
6157 ;; difference between the ranges of read articles in this group and
6158 ;; the range of active articles.
6159 (defun gnus-list-of-unread-articles (group)
6160 (let* ((read (gnus-info-read (gnus-get-info group)))
6161 (active (or (gnus-active group) (gnus-activate-group group)))
6164 ;; If none are read, then all are unread.
6166 (setq first (car active))
6167 ;; If the range of read articles is a single range, then the
6168 ;; first unread article is the article after the last read
6169 ;; article. Sounds logical, doesn't it?
6170 (if (and (not (listp (cdr read)))
6171 (or (< (car read) (car active))
6172 (progn (setq read (list read))
6174 (setq first (max (car active) (1+ (cdr read))))
6175 ;; `read' is a list of ranges.
6176 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6179 (setq first (car active)))
6182 (while (< first nlast)
6184 (setq first (1+ first))))
6185 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6186 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6187 (setq read (cdr read)))))
6188 ;; And add the last unread articles.
6189 (while (<= first last)
6191 (setq first (1+ first)))
6192 ;; Return the list of unread articles.
6193 (delq 0 (nreverse unread))))
6195 (defun gnus-list-of-read-articles (group)
6196 "Return a list of unread, unticked and non-dormant articles."
6197 (let* ((info (gnus-get-info group))
6198 (marked (gnus-info-marks info))
6199 (active (gnus-active group)))
6201 (gnus-list-range-difference
6202 (gnus-list-range-difference
6203 (gnus-sorted-complement
6204 (gnus-uncompress-range active)
6205 (gnus-list-of-unread-articles group))
6206 (cdr (assq 'dormant marked)))
6207 (cdr (assq 'tick marked))))))
6209 ;; Various summary commands
6211 (defun gnus-summary-select-article-buffer ()
6212 "Reconfigure windows to show article buffer."
6214 (if (not (gnus-buffer-live-p gnus-article-buffer))
6215 (error "There is no article buffer for this summary buffer")
6216 (gnus-configure-windows 'article)
6217 (select-window (get-buffer-window gnus-article-buffer))))
6219 (defun gnus-summary-universal-argument (arg)
6220 "Perform any operation on all articles that are process/prefixed."
6222 (let ((articles (gnus-summary-work-articles arg))
6229 (substitute-command-keys
6230 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6232 (gnus-error 1 "Undefined key")
6235 (gnus-summary-goto-subject (setq article (pop articles)))
6236 (let (gnus-newsgroup-processable)
6237 (command-execute func))
6238 (gnus-summary-remove-process-mark article)))))
6239 (gnus-summary-position-point))
6241 (defun gnus-summary-toggle-truncation (&optional arg)
6242 "Toggle truncation of summary lines.
6243 With arg, turn line truncation on if arg is positive."
6245 (setq truncate-lines
6246 (if (null arg) (not truncate-lines)
6247 (> (prefix-numeric-value arg) 0)))
6250 (defun gnus-summary-find-uncancelled ()
6251 "Return the number of an uncancelled article.
6252 The current article is considered, then following articles, then previous
6253 articles. If all articles are cancelled then return a dummy 0."
6255 (dolist (rev '(nil t))
6256 (unless found ; don't demand the reverse list if we don't need it
6257 (let ((data (gnus-data-find-list
6258 (gnus-summary-article-number) (gnus-data-list rev))))
6259 (while (and data (not found))
6260 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6261 (setq found (gnus-data-number (car data))))
6262 (setq data (cdr data))))))
6265 (defun gnus-summary-reselect-current-group (&optional all rescan)
6266 "Exit and then reselect the current newsgroup.
6267 The prefix argument ALL means to select all articles."
6269 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6270 (error "Ephemeral groups can't be reselected"))
6271 (let ((current-subject (gnus-summary-find-uncancelled))
6272 (group gnus-newsgroup-name))
6273 (setq gnus-newsgroup-begin nil)
6275 ;; We have to adjust the point of group mode buffer because
6276 ;; point was moved to the next unread newsgroup by exiting.
6277 (gnus-summary-jump-to-group group)
6280 (gnus-group-get-new-news-this-group 1)))
6281 (gnus-group-read-group all t)
6282 (gnus-summary-goto-subject current-subject nil t)))
6284 (defun gnus-summary-rescan-group (&optional all)
6285 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6287 (gnus-summary-reselect-current-group all t))
6289 (defun gnus-summary-update-info (&optional non-destructive)
6291 (let ((group gnus-newsgroup-name))
6293 (when gnus-newsgroup-kill-headers
6294 (setq gnus-newsgroup-killed
6295 (gnus-compress-sequence
6297 (gnus-list-range-intersection
6298 gnus-newsgroup-unselected gnus-newsgroup-killed)
6299 gnus-newsgroup-unreads)
6301 (unless (listp (cdr gnus-newsgroup-killed))
6302 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6303 (let ((headers gnus-newsgroup-headers))
6304 ;; Set the new ranges of read articles.
6306 (set-buffer gnus-group-buffer)
6307 (gnus-undo-force-boundary))
6308 (gnus-update-read-articles
6309 group (gnus-sorted-union
6310 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6311 ;; Set the current article marks.
6312 (let ((gnus-newsgroup-scored
6313 (if (and (not gnus-save-score)
6314 (not non-destructive))
6316 gnus-newsgroup-scored)))
6318 (gnus-update-marks)))
6319 ;; Do the cross-ref thing.
6320 (when gnus-use-cross-reference
6321 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6322 ;; Do not switch windows but change the buffer to work.
6323 (set-buffer gnus-group-buffer)
6324 (unless (gnus-ephemeral-group-p group)
6325 (gnus-group-update-group group)))))))
6327 (defun gnus-summary-save-newsrc (&optional force)
6328 "Save the current number of read/marked articles in the dribble buffer.
6329 The dribble buffer will then be saved.
6330 If FORCE (the prefix), also save the .newsrc file(s)."
6332 (gnus-summary-update-info t)
6334 (gnus-save-newsrc-file)
6335 (gnus-dribble-save)))
6337 (defun gnus-summary-exit (&optional temporary)
6338 "Exit reading current newsgroup, and then return to group selection mode.
6339 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6341 (gnus-set-global-variables)
6342 (when (gnus-buffer-live-p gnus-article-buffer)
6344 (set-buffer gnus-article-buffer)
6345 (mm-destroy-parts gnus-article-mime-handles)
6346 ;; Set it to nil for safety reason.
6347 (setq gnus-article-mime-handle-alist nil)
6348 (setq gnus-article-mime-handles nil)))
6349 (gnus-kill-save-kill-buffer)
6350 (gnus-async-halt-prefetch)
6351 (let* ((group gnus-newsgroup-name)
6352 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6353 (gnus-group-is-exiting-p t)
6356 (buf (current-buffer)))
6358 ;; Do adaptive scoring, and possibly save score files.
6359 (when gnus-newsgroup-adaptive
6360 (gnus-score-adaptive))
6361 (when gnus-use-scoring
6363 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6364 ;; If we have several article buffers, we kill them at exit.
6365 (unless gnus-single-article-buffer
6366 (gnus-kill-buffer gnus-original-article-buffer)
6367 (setq gnus-article-current nil))
6368 (when gnus-use-cache
6369 (gnus-cache-possibly-remove-articles)
6370 (gnus-cache-save-buffers))
6371 (gnus-async-prefetch-remove-group group)
6372 (when gnus-suppress-duplicates
6373 (gnus-dup-enter-articles))
6374 (when gnus-use-trees
6375 (gnus-tree-close group))
6376 (when gnus-use-cache
6377 (gnus-cache-write-active))
6378 ;; Remove entries for this group.
6379 (nnmail-purge-split-history (gnus-group-real-name group))
6380 ;; Make all changes in this group permanent.
6382 (gnus-run-hooks 'gnus-exit-group-hook)
6383 (gnus-summary-update-info))
6384 (gnus-close-group group)
6385 ;; Make sure where we were, and go to next newsgroup.
6386 (set-buffer gnus-group-buffer)
6388 (gnus-group-jump-to-group group))
6389 (gnus-run-hooks 'gnus-summary-exit-hook)
6390 (unless (or quit-config
6391 ;; If this group has disappeared from the summary
6392 ;; buffer, don't skip forwards.
6393 (not (string= group (gnus-group-group-name))))
6394 (gnus-group-next-unread-group 1))
6395 (setq group-point (point))
6398 ;; If we have several article buffers, we kill them at exit.
6399 (unless gnus-single-article-buffer
6400 (gnus-kill-buffer gnus-article-buffer)
6401 (gnus-kill-buffer gnus-original-article-buffer)
6402 (setq gnus-article-current nil))
6404 (if (not gnus-kill-summary-on-exit)
6406 (gnus-deaden-summary)
6408 ;; We set all buffer-local variables to nil. It is unclear why
6409 ;; this is needed, but if we don't, buffer-local variables are
6410 ;; not garbage-collected, it seems. This would the lead to en
6411 ;; ever-growing Emacs.
6412 (gnus-summary-clear-local-variables)
6413 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6414 (gnus-summary-clear-local-variables))
6415 (when (get-buffer gnus-article-buffer)
6416 (bury-buffer gnus-article-buffer))
6417 ;; We clear the global counterparts of the buffer-local
6418 ;; variables as well, just to be on the safe side.
6419 (set-buffer gnus-group-buffer)
6420 (gnus-summary-clear-local-variables)
6421 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6422 (gnus-summary-clear-local-variables))
6423 ;; Return to group mode buffer.
6424 (when (eq mode 'gnus-summary-mode)
6425 (gnus-kill-buffer buf)))
6426 (setq gnus-current-select-method gnus-select-method)
6427 (pop-to-buffer gnus-group-buffer)
6428 (if (not quit-config)
6430 (goto-char group-point)
6431 (gnus-configure-windows 'group 'force))
6432 (gnus-handle-ephemeral-exit quit-config))
6433 ;; Clear the current group name.
6435 (setq gnus-newsgroup-name nil)))))
6437 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6438 (defun gnus-summary-exit-no-update (&optional no-questions)
6439 "Quit reading current newsgroup without updating read article info."
6441 (let* ((group gnus-newsgroup-name)
6442 (gnus-group-is-exiting-p t)
6443 (quit-config (gnus-group-quit-config group)))
6444 (when (or no-questions
6446 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6447 (gnus-async-halt-prefetch)
6449 (delq 'gnus-summary-expire-articles
6450 (copy-sequence gnus-summary-prepare-exit-hook)))
6451 (when (gnus-buffer-live-p gnus-article-buffer)
6453 (set-buffer gnus-article-buffer)
6454 (mm-destroy-parts gnus-article-mime-handles)
6455 ;; Set it to nil for safety reason.
6456 (setq gnus-article-mime-handle-alist nil)
6457 (setq gnus-article-mime-handles nil)))
6458 ;; If we have several article buffers, we kill them at exit.
6459 (unless gnus-single-article-buffer
6460 (gnus-kill-buffer gnus-article-buffer)
6461 (gnus-kill-buffer gnus-original-article-buffer)
6462 (setq gnus-article-current nil))
6463 (if (not gnus-kill-summary-on-exit)
6464 (gnus-deaden-summary)
6465 (gnus-close-group group)
6466 (gnus-summary-clear-local-variables)
6467 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6468 (gnus-summary-clear-local-variables))
6469 (set-buffer gnus-group-buffer)
6470 (gnus-summary-clear-local-variables)
6471 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6472 (gnus-summary-clear-local-variables))
6473 (when (get-buffer gnus-summary-buffer)
6474 (kill-buffer gnus-summary-buffer)))
6475 (unless gnus-single-article-buffer
6476 (setq gnus-article-current nil))
6477 (when gnus-use-trees
6478 (gnus-tree-close group))
6479 (gnus-async-prefetch-remove-group group)
6480 (when (get-buffer gnus-article-buffer)
6481 (bury-buffer gnus-article-buffer))
6482 ;; Return to the group buffer.
6483 (gnus-configure-windows 'group 'force)
6484 ;; Clear the current group name.
6485 (setq gnus-newsgroup-name nil)
6486 (unless (gnus-ephemeral-group-p group)
6487 (gnus-group-update-group group))
6488 (when (equal (gnus-group-group-name) group)
6489 (gnus-group-next-unread-group 1))
6491 (gnus-handle-ephemeral-exit quit-config)))))
6493 (defun gnus-handle-ephemeral-exit (quit-config)
6494 "Handle movement when leaving an ephemeral group.
6495 The state which existed when entering the ephemeral is reset."
6496 (if (not (buffer-name (car quit-config)))
6497 (gnus-configure-windows 'group 'force)
6498 (set-buffer (car quit-config))
6499 (cond ((eq major-mode 'gnus-summary-mode)
6500 (gnus-set-global-variables))
6501 ((eq major-mode 'gnus-article-mode)
6503 ;; The `gnus-summary-buffer' variable may point
6504 ;; to the old summary buffer when using a single
6506 (unless (gnus-buffer-live-p gnus-summary-buffer)
6507 (set-buffer gnus-group-buffer))
6508 (set-buffer gnus-summary-buffer)
6509 (gnus-set-global-variables))))
6510 (if (or (eq (cdr quit-config) 'article)
6511 (eq (cdr quit-config) 'pick))
6513 ;; The current article may be from the ephemeral group
6514 ;; thus it is best that we reload this article
6515 (gnus-summary-show-article)
6516 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6517 (gnus-configure-windows 'pick 'force)
6518 (gnus-configure-windows (cdr quit-config) 'force)))
6519 (gnus-configure-windows (cdr quit-config) 'force))
6520 (when (eq major-mode 'gnus-summary-mode)
6521 (gnus-summary-next-subject 1 nil t)
6522 (gnus-summary-recenter)
6523 (gnus-summary-position-point))))
6527 (defvar gnus-dead-summary-mode-map nil)
6529 (unless gnus-dead-summary-mode-map
6530 (setq gnus-dead-summary-mode-map (make-keymap))
6531 (suppress-keymap gnus-dead-summary-mode-map)
6532 (substitute-key-definition
6533 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6534 (dolist (key '("\C-d" "\r" "\177" [delete]))
6535 (define-key gnus-dead-summary-mode-map
6536 key 'gnus-summary-wake-up-the-dead))
6537 (dolist (key '("q" "Q"))
6538 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6540 (defvar gnus-dead-summary-mode nil
6541 "Minor mode for Gnus summary buffers.")
6543 (defun gnus-dead-summary-mode (&optional arg)
6544 "Minor mode for Gnus summary buffers."
6546 (when (eq major-mode 'gnus-summary-mode)
6547 (make-local-variable 'gnus-dead-summary-mode)
6548 (setq gnus-dead-summary-mode
6549 (if (null arg) (not gnus-dead-summary-mode)
6550 (> (prefix-numeric-value arg) 0)))
6551 (when gnus-dead-summary-mode
6552 (gnus-add-minor-mode
6553 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6555 (defun gnus-deaden-summary ()
6556 "Make the current summary buffer into a dead summary buffer."
6557 ;; Kill any previous dead summary buffer.
6558 (when (and gnus-dead-summary
6559 (buffer-name gnus-dead-summary))
6561 (set-buffer gnus-dead-summary)
6562 (when gnus-dead-summary-mode
6563 (kill-buffer (current-buffer)))))
6564 ;; Make this the current dead summary.
6565 (setq gnus-dead-summary (current-buffer))
6566 (gnus-dead-summary-mode 1)
6567 (let ((name (buffer-name)))
6568 (when (string-match "Summary" name)
6570 (concat (substring name 0 (match-beginning 0)) "Dead "
6571 (substring name (match-beginning 0)))
6575 (defun gnus-kill-or-deaden-summary (buffer)
6576 "Kill or deaden the summary BUFFER."
6578 (when (and (buffer-name buffer)
6579 (not gnus-single-article-buffer))
6582 (gnus-kill-buffer gnus-article-buffer)
6583 (gnus-kill-buffer gnus-original-article-buffer)))
6586 (gnus-kill-summary-on-exit
6587 (when (and gnus-use-trees
6588 (gnus-buffer-exists-p buffer))
6591 (gnus-tree-close gnus-newsgroup-name)))
6592 (gnus-kill-buffer buffer))
6593 ;; Deaden the buffer.
6594 ((gnus-buffer-exists-p buffer)
6597 (gnus-deaden-summary))))))
6599 (defun gnus-summary-wake-up-the-dead (&rest args)
6600 "Wake up the dead summary buffer."
6602 (gnus-dead-summary-mode -1)
6603 (let ((name (buffer-name)))
6604 (when (string-match "Dead " name)
6606 (concat (substring name 0 (match-beginning 0))
6607 (substring name (match-end 0)))
6609 (gnus-message 3 "This dead summary is now alive again"))
6611 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6612 (defun gnus-summary-fetch-faq (&optional faq-dir)
6613 "Fetch the FAQ for the current group.
6614 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6618 (when current-prefix-arg
6620 "FAQ dir: " (and (listp gnus-group-faq-directory)
6621 (mapcar (lambda (file) (list file))
6622 gnus-group-faq-directory))))))
6623 (let (gnus-faq-buffer)
6624 (when (setq gnus-faq-buffer
6625 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6626 (gnus-configure-windows 'summary-faq))))
6628 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6629 (defun gnus-summary-describe-group (&optional force)
6630 "Describe the current newsgroup."
6632 (gnus-group-describe-group force gnus-newsgroup-name))
6634 (defun gnus-summary-describe-briefly ()
6635 "Describe summary mode commands briefly."
6637 (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")))
6639 ;; Walking around group mode buffer from summary mode.
6641 (defun gnus-summary-next-group (&optional no-article target-group backward)
6642 "Exit current newsgroup and then select next unread newsgroup.
6643 If prefix argument NO-ARTICLE is non-nil, no article is selected
6644 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6645 previous group instead."
6647 ;; Stop pre-fetching.
6648 (gnus-async-halt-prefetch)
6649 (let ((current-group gnus-newsgroup-name)
6650 (current-buffer (current-buffer))
6652 (while (not entered)
6653 ;; Then we find what group we are supposed to enter.
6654 (set-buffer gnus-group-buffer)
6655 (gnus-group-jump-to-group current-group)
6658 (if (eq gnus-keep-same-level 'best)
6659 (gnus-summary-best-group gnus-newsgroup-name)
6660 (gnus-summary-search-group backward gnus-keep-same-level))))
6661 (if (not target-group)
6662 ;; There are no further groups, so we return to the group
6665 (gnus-message 5 "Returning to the group buffer")
6667 (when (gnus-buffer-live-p current-buffer)
6668 (set-buffer current-buffer)
6669 (gnus-summary-exit))
6670 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6671 ;; We try to enter the target group.
6672 (gnus-group-jump-to-group target-group)
6673 (let ((unreads (gnus-group-group-unread)))
6674 (if (and (or (eq t unreads)
6675 (and unreads (not (zerop unreads))))
6677 ;; Now we semi-exit this group to update Xrefs
6678 ;; and all variables. We can't do a real exit,
6679 ;; because the window conf must remain the same
6680 ;; in case the user is prompted for info, and we
6681 ;; don't want the window conf to change before
6683 (when (gnus-buffer-live-p current-buffer)
6684 (set-buffer current-buffer)
6685 (gnus-summary-exit t))
6686 (gnus-summary-read-group
6687 target-group nil no-article
6688 (and (buffer-name current-buffer) current-buffer)
6691 (setq current-group target-group
6692 target-group nil)))))))
6694 (defun gnus-summary-prev-group (&optional no-article)
6695 "Exit current newsgroup and then select previous unread newsgroup.
6696 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6698 (gnus-summary-next-group no-article nil t))
6700 ;; Walking around summary lines.
6702 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6703 "Go to the first subject satisfying any non-nil constraint.
6704 If UNREAD is non-nil, the article should be unread.
6705 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6706 If UNSEED is non-nil, the article should be unseen.
6707 Returns the article selected or nil if there are no matching articles."
6711 ((null gnus-newsgroup-data)
6712 (gnus-message 3 "No articles in the group")
6714 ;; Pick the first article.
6715 ((not (or unread undownloaded unseen))
6716 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6717 (gnus-data-number (car gnus-newsgroup-data)))
6718 ;; Find the first unread article.
6720 (let ((data gnus-newsgroup-data))
6722 (let ((num (gnus-data-number (car data))))
6723 (or (memq num gnus-newsgroup-unfetched)
6724 (not (or (and unread
6725 (memq num gnus-newsgroup-unreads))
6727 (memq num gnus-newsgroup-undownloaded))
6729 (memq num gnus-newsgroup-unseen)))))))
6730 (setq data (cdr data)))
6734 (goto-char (gnus-data-pos (car data)))
6735 (gnus-data-number (car data)))
6736 (gnus-message 3 "No more%s articles"
6737 (let* ((r (when unread " unread"))
6738 (d (when undownloaded " undownloaded"))
6739 (s (when unseen " unseen"))
6740 (l (delq nil (list r d s))))
6741 (cond ((= 3 (length l))
6742 (concat r "," d ", or" s))
6744 (concat (car l) ", or" (cadr l)))
6751 (gnus-summary-position-point))))))
6753 (defun gnus-summary-next-subject (n &optional unread dont-display)
6754 "Go to next N'th summary line.
6755 If N is negative, go to the previous N'th subject line.
6756 If UNREAD is non-nil, only unread articles are selected.
6757 The difference between N and the actual number of steps taken is
6760 (let ((backward (< n 0))
6764 (gnus-summary-find-prev unread)
6765 (gnus-summary-find-next unread)))
6766 (unless (zerop (setq n (1- n)))
6767 (gnus-summary-show-thread)))
6769 (gnus-message 7 "No more%s articles"
6770 (if unread " unread" "")))
6771 (unless dont-display
6772 (gnus-summary-recenter)
6773 (gnus-summary-position-point))
6776 (defun gnus-summary-next-unread-subject (n)
6777 "Go to next N'th unread summary line."
6779 (gnus-summary-next-subject n t))
6781 (defun gnus-summary-prev-subject (n &optional unread)
6782 "Go to previous N'th summary line.
6783 If optional argument UNREAD is non-nil, only unread article is selected."
6785 (gnus-summary-next-subject (- n) unread))
6787 (defun gnus-summary-prev-unread-subject (n)
6788 "Go to previous N'th unread summary line."
6790 (gnus-summary-next-subject (- n) t))
6792 (defun gnus-summary-goto-subjects (articles)
6793 "Insert the subject header for ARTICLES in the current buffer."
6795 (dolist (article articles)
6796 (gnus-summary-goto-subject article t)))
6797 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6798 (gnus-summary-position-point))
6800 (defun gnus-summary-goto-subject (article &optional force silent)
6801 "Go the subject line of ARTICLE.
6802 If FORCE, also allow jumping to articles not currently shown."
6803 (interactive "nArticle number: ")
6804 (unless (numberp article)
6805 (error "Article %s is not a number" article))
6807 (data (gnus-data-find article)))
6808 ;; We read in the article if we have to.
6811 (gnus-summary-insert-subject
6813 (if (or (numberp force) (vectorp force)) force)
6815 (setq data (gnus-data-find article)))
6820 (gnus-message 3 "Can't find article %d" article))
6822 (let ((pt (gnus-data-pos data)))
6824 (gnus-summary-set-article-display-arrow pt))
6825 (gnus-summary-position-point)
6828 ;; Walking around summary lines with displaying articles.
6830 (defun gnus-summary-expand-window (&optional arg)
6831 "Make the summary buffer take up the entire Emacs frame.
6832 Given a prefix, will force an `article' buffer configuration."
6835 (gnus-configure-windows 'article 'force)
6836 (gnus-configure-windows 'summary 'force)))
6838 (defun gnus-summary-display-article (article &optional all-header)
6839 "Display ARTICLE in article buffer."
6840 (when (gnus-buffer-live-p gnus-article-buffer)
6841 (with-current-buffer gnus-article-buffer
6842 (mm-enable-multibyte)))
6843 (gnus-set-global-variables)
6844 (when (gnus-buffer-live-p gnus-article-buffer)
6845 (with-current-buffer gnus-article-buffer
6846 (setq gnus-article-charset gnus-newsgroup-charset)
6847 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6848 (mm-enable-multibyte)))
6852 (if gnus-summary-display-article-function
6853 (funcall gnus-summary-display-article-function article all-header)
6854 (gnus-article-prepare article all-header))
6855 (gnus-run-hooks 'gnus-select-article-hook)
6856 (when (and gnus-current-article
6857 (not (zerop gnus-current-article)))
6858 (gnus-summary-goto-subject gnus-current-article))
6859 (gnus-summary-recenter)
6860 (when (and gnus-use-trees gnus-show-threads)
6861 (gnus-possibly-generate-tree article)
6862 (gnus-highlight-selected-tree article))
6863 ;; Successfully display article.
6864 (gnus-article-set-window-start
6865 (cdr (assq article gnus-newsgroup-bookmarks))))))
6867 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6868 "Select the current article.
6869 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6870 non-nil, the article will be re-fetched even if it already present in
6871 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6873 ;; Make sure we are in the summary buffer to work around bbdb bug.
6874 (unless (eq major-mode 'gnus-summary-mode)
6875 (set-buffer gnus-summary-buffer))
6876 (let ((article (or article (gnus-summary-article-number)))
6877 (all-headers (not (not all-headers))) ;Must be t or nil.
6878 ;; prevent redisplay to cause flashy displays
6879 (inhibit-redisplay t)
6880 gnus-summary-display-article-function)
6882 (gnus-summary-article-pseudo-p article)
6883 (error "This is a pseudo-article"))
6885 (set-buffer gnus-summary-buffer)
6886 (if (or (and gnus-single-article-buffer
6887 (or (null gnus-current-article)
6888 (null gnus-article-current)
6889 (null (get-buffer gnus-article-buffer))
6890 (not (eq article (cdr gnus-article-current)))
6891 (not (equal (car gnus-article-current)
6892 gnus-newsgroup-name))))
6893 (and (not gnus-single-article-buffer)
6894 (or (null gnus-current-article)
6895 (not (eq gnus-current-article article))))
6897 ;; The requested article is different from the current article.
6899 (gnus-summary-display-article article all-headers)
6900 (when (gnus-buffer-live-p gnus-article-buffer)
6901 (with-current-buffer gnus-article-buffer
6902 (if (not gnus-article-decoded-p) ;; a local variable
6903 (mm-disable-multibyte))))
6904 (gnus-article-set-window-start
6905 (cdr (assq article gnus-newsgroup-bookmarks)))
6909 (defun gnus-summary-force-verify-and-decrypt ()
6910 "Display buttons for signed/encrypted parts and verify/decrypt them."
6912 (let ((mm-verify-option 'known)
6913 (mm-decrypt-option 'known)
6914 (gnus-buttonized-mime-types (append (list "multipart/signed"
6915 "multipart/encrypted")
6916 gnus-buttonized-mime-types)))
6917 (gnus-summary-select-article nil 'force)))
6919 (defun gnus-summary-set-current-mark (&optional current-mark)
6920 "Obsolete function."
6923 (defun gnus-summary-next-article (&optional unread subject backward push)
6924 "Select the next article.
6925 If UNREAD, only unread articles are selected.
6926 If SUBJECT, only articles with SUBJECT are selected.
6927 If BACKWARD, the previous article is selected instead of the next."
6930 ;; Is there such an article?
6931 ((and (gnus-summary-search-forward unread subject backward)
6932 (or (gnus-summary-display-article (gnus-summary-article-number))
6933 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6934 (gnus-summary-position-point))
6935 ;; If not, we try the first unread, if that is wanted.
6937 gnus-auto-select-same
6938 (gnus-summary-first-unread-article))
6939 (gnus-summary-position-point)
6940 (gnus-message 6 "Wrapped"))
6941 ;; Try to get next/previous article not displayed in this group.
6942 ((and gnus-auto-extend-newsgroup
6943 (not unread) (not subject))
6944 (gnus-summary-goto-article
6945 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6946 nil (count-lines (point-min) (point))))
6947 ;; Go to next/previous group.
6949 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6950 (gnus-summary-jump-to-group gnus-newsgroup-name))
6951 (let ((cmd last-command-char)
6954 (set-buffer gnus-group-buffer)
6957 (if (eq gnus-keep-same-level 'best)
6958 (gnus-summary-best-group gnus-newsgroup-name)
6959 (gnus-summary-search-group backward gnus-keep-same-level))))
6960 ;; For some reason, the group window gets selected. We change
6962 (select-window (get-buffer-window (current-buffer)))
6963 ;; Select next unread newsgroup automagically.
6965 ((or (not gnus-auto-select-next)
6967 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6968 ((or (eq gnus-auto-select-next 'quietly)
6969 (and (eq gnus-auto-select-next 'slightly-quietly)
6971 (and (eq gnus-auto-select-next 'almost-quietly)
6972 (gnus-summary-last-article-p)))
6974 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6976 (gnus-message 7 "No more%s articles (%s)..."
6977 (if unread " unread" "")
6978 (if group (concat "selecting " group)
6980 (gnus-summary-next-group nil group backward)))
6982 (when (gnus-key-press-event-p last-input-event)
6983 (gnus-summary-walk-group-buffer
6984 gnus-newsgroup-name cmd unread backward point))))))))
6986 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6987 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6988 (?\C-p (gnus-group-prev-unread-group 1))))
6989 (cursor-in-echo-area t)
6990 keve key group ended prompt)
6992 (set-buffer gnus-group-buffer)
6995 (if (eq gnus-keep-same-level 'best)
6996 (gnus-summary-best-group gnus-newsgroup-name)
6997 (gnus-summary-search-group backward gnus-keep-same-level))))
7001 "No more%s articles%s " (if unread " unread" "")
7003 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7004 (format " (Type %s for %s [%s])"
7005 (single-key-description cmd) group
7006 (car (gnus-gethash group gnus-newsrc-hashtb)))
7007 (format " (Type %s to exit %s)"
7008 (single-key-description cmd)
7009 gnus-newsgroup-name))))
7010 ;; Confirm auto selection.
7011 (setq key (car (setq keve (gnus-read-event-char prompt)))
7014 ((assq key keystrokes)
7015 (let ((obuf (current-buffer)))
7016 (switch-to-buffer gnus-group-buffer)
7018 (gnus-group-jump-to-group group))
7019 (eval (cadr (assq key keystrokes)))
7020 (setq group (gnus-group-group-name))
7021 (switch-to-buffer obuf))
7025 (gnus-ephemeral-group-p gnus-newsgroup-name))
7027 (gnus-summary-next-group nil group backward)))
7029 (push (cdr keve) unread-command-events))))))
7031 (defun gnus-summary-next-unread-article ()
7032 "Select unread article after current one."
7034 (gnus-summary-next-article
7035 (or (not (eq gnus-summary-goto-unread 'never))
7036 (gnus-summary-last-article-p (gnus-summary-article-number)))
7037 (and gnus-auto-select-same
7038 (gnus-summary-article-subject))))
7040 (defun gnus-summary-prev-article (&optional unread subject)
7041 "Select the article after the current one.
7042 If UNREAD is non-nil, only unread articles are selected."
7044 (gnus-summary-next-article unread subject t))
7046 (defun gnus-summary-prev-unread-article ()
7047 "Select unread article before current one."
7049 (gnus-summary-prev-article
7050 (or (not (eq gnus-summary-goto-unread 'never))
7051 (gnus-summary-first-article-p (gnus-summary-article-number)))
7052 (and gnus-auto-select-same
7053 (gnus-summary-article-subject))))
7055 (defun gnus-summary-next-page (&optional lines circular stop)
7056 "Show next page of the selected article.
7057 If at the end of the current article, select the next article.
7058 LINES says how many lines should be scrolled up.
7060 If CIRCULAR is non-nil, go to the start of the article instead of
7061 selecting the next article when reaching the end of the current
7064 If STOP is non-nil, just stop when reaching the end of the message."
7066 (setq gnus-summary-buffer (current-buffer))
7067 (gnus-set-global-variables)
7068 (let ((article (gnus-summary-article-number))
7069 (article-window (get-buffer-window gnus-article-buffer t))
7071 ;; If the buffer is empty, we have no article.
7073 (error "No article to select"))
7074 (gnus-configure-windows 'article)
7075 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7076 (if (and (eq gnus-summary-goto-unread 'never)
7077 (not (gnus-summary-last-article-p article)))
7078 (gnus-summary-next-article)
7079 (gnus-summary-next-unread-article))
7080 (if (or (null gnus-current-article)
7081 (null gnus-article-current)
7082 (/= article (cdr gnus-article-current))
7083 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7084 ;; Selected subject is different from current article's.
7085 (gnus-summary-display-article article)
7086 (when article-window
7087 (gnus-eval-in-buffer-window gnus-article-buffer
7088 (setq endp (gnus-article-next-page lines)))
7091 (gnus-message 3 "End of message"))
7093 (gnus-summary-beginning-of-article))
7095 (gnus-message 3 "End of message"))
7097 (if (and (eq gnus-summary-goto-unread 'never)
7098 (not (gnus-summary-last-article-p article)))
7099 (gnus-summary-next-article)
7100 (gnus-summary-next-unread-article))))))))
7101 (gnus-summary-recenter)
7102 (gnus-summary-position-point)))
7104 (defun gnus-summary-prev-page (&optional lines move)
7105 "Show previous page of selected article.
7106 Argument LINES specifies lines to be scrolled down.
7107 If MOVE, move to the previous unread article if point is at
7108 the beginning of the buffer."
7110 (let ((article (gnus-summary-article-number))
7111 (article-window (get-buffer-window gnus-article-buffer t))
7113 (gnus-configure-windows 'article)
7114 (if (or (null gnus-current-article)
7115 (null gnus-article-current)
7116 (/= article (cdr gnus-article-current))
7117 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7118 ;; Selected subject is different from current article's.
7119 (gnus-summary-display-article article)
7120 (gnus-summary-recenter)
7121 (when article-window
7122 (gnus-eval-in-buffer-window gnus-article-buffer
7123 (setq endp (gnus-article-prev-page lines)))
7124 (when (and move endp)
7126 (gnus-message 3 "Beginning of message"))
7128 (if (and (eq gnus-summary-goto-unread 'never)
7129 (not (gnus-summary-first-article-p article)))
7130 (gnus-summary-prev-article)
7131 (gnus-summary-prev-unread-article))))))))
7132 (gnus-summary-position-point))
7134 (defun gnus-summary-prev-page-or-article (&optional lines)
7135 "Show previous page of selected article.
7136 Argument LINES specifies lines to be scrolled down.
7137 If at the beginning of the article, go to the next article."
7139 (gnus-summary-prev-page lines t))
7141 (defun gnus-summary-scroll-up (lines)
7142 "Scroll up (or down) one line current article.
7143 Argument LINES specifies lines to be scrolled up (or down if negative)."
7145 (gnus-configure-windows 'article)
7146 (gnus-summary-show-thread)
7147 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7148 (gnus-eval-in-buffer-window gnus-article-buffer
7150 (when (gnus-article-next-page lines)
7151 (gnus-message 3 "End of message")))
7153 (gnus-article-prev-page (- lines))))))
7154 (gnus-summary-recenter)
7155 (gnus-summary-position-point))
7157 (defun gnus-summary-scroll-down (lines)
7158 "Scroll down (or up) one line current article.
7159 Argument LINES specifies lines to be scrolled down (or up if negative)."
7161 (gnus-summary-scroll-up (- lines)))
7163 (defun gnus-summary-next-same-subject ()
7164 "Select next article which has the same subject as current one."
7166 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7168 (defun gnus-summary-prev-same-subject ()
7169 "Select previous article which has the same subject as current one."
7171 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7173 (defun gnus-summary-next-unread-same-subject ()
7174 "Select next unread article which has the same subject as current one."
7176 (gnus-summary-next-article t (gnus-summary-article-subject)))
7178 (defun gnus-summary-prev-unread-same-subject ()
7179 "Select previous unread article which has the same subject as current one."
7181 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7183 (defun gnus-summary-first-unread-article ()
7184 "Select the first unread article.
7185 Return nil if there are no unread articles."
7188 (when (gnus-summary-first-subject t)
7189 (gnus-summary-show-thread)
7190 (gnus-summary-first-subject t)
7191 (gnus-summary-display-article (gnus-summary-article-number)))
7192 (gnus-summary-position-point)))
7194 (defun gnus-summary-first-unread-subject ()
7195 "Place the point on the subject line of the first unread article.
7196 Return nil if there are no unread articles."
7199 (when (gnus-summary-first-subject t)
7200 (gnus-summary-show-thread)
7201 (gnus-summary-first-subject t))
7202 (gnus-summary-position-point)))
7204 (defun gnus-summary-first-unseen-subject ()
7205 "Place the point on the subject line of the first unseen article.
7206 Return nil if there are no unseen articles."
7209 (when (gnus-summary-first-subject nil nil t)
7210 (gnus-summary-show-thread)
7211 (gnus-summary-first-subject nil nil t))
7212 (gnus-summary-position-point)))
7214 (defun gnus-summary-first-unseen-or-unread-subject ()
7215 "Place the point on the subject line of the first unseen article or,
7216 if all article have been seen, on the subject line of the first unread
7220 (unless (when (gnus-summary-first-subject nil nil t)
7221 (gnus-summary-show-thread)
7222 (gnus-summary-first-subject nil nil t))
7223 (when (gnus-summary-first-subject t)
7224 (gnus-summary-show-thread)
7225 (gnus-summary-first-subject t)))
7226 (gnus-summary-position-point)))
7228 (defun gnus-summary-first-article ()
7229 "Select the first article.
7230 Return nil if there are no articles."
7233 (when (gnus-summary-first-subject)
7234 (gnus-summary-show-thread)
7235 (gnus-summary-first-subject)
7236 (gnus-summary-display-article (gnus-summary-article-number)))
7237 (gnus-summary-position-point)))
7239 (defun gnus-summary-best-unread-article (&optional arg)
7240 "Select the unread article with the highest score.
7241 If given a prefix argument, select the next unread article that has a
7242 score higher than the default score."
7244 (let ((article (if arg
7245 (gnus-summary-better-unread-subject)
7246 (gnus-summary-best-unread-subject))))
7248 (gnus-summary-goto-article article)
7249 (error "No unread articles"))))
7251 (defun gnus-summary-best-unread-subject ()
7252 "Select the unread subject with the highest score."
7254 (let ((best -1000000)
7255 (data gnus-newsgroup-data)
7258 (and (gnus-data-unread-p (car data))
7260 (gnus-summary-article-score (gnus-data-number (car data))))
7263 article (gnus-data-number (car data))))
7264 (setq data (cdr data)))
7266 (gnus-summary-goto-subject article))
7267 (gnus-summary-position-point)
7270 (defun gnus-summary-better-unread-subject ()
7271 "Select the first unread subject that has a score over the default score."
7273 (let ((data gnus-newsgroup-data)
7275 (while (and (setq article (gnus-data-number (car data)))
7276 (or (gnus-data-read-p (car data))
7277 (not (> (gnus-summary-article-score article)
7278 gnus-summary-default-score))))
7279 (setq data (cdr data)))
7281 (gnus-summary-goto-subject article))
7282 (gnus-summary-position-point)
7285 (defun gnus-summary-last-subject ()
7286 "Go to the last displayed subject line in the group."
7287 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7289 (gnus-summary-goto-subject article))))
7291 (defun gnus-summary-goto-article (article &optional all-headers force)
7292 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7293 If ALL-HEADERS is non-nil, no header lines are hidden.
7294 If FORCE, go to the article even if it isn't displayed. If FORCE
7295 is a number, it is the line the article is to be displayed on."
7299 "Article number or Message-ID: "
7300 (mapcar (lambda (number) (list (int-to-string number)))
7301 gnus-newsgroup-limit))
7305 (if (and (stringp article)
7306 (string-match "@" article))
7307 (gnus-summary-refer-article article)
7308 (when (stringp article)
7309 (setq article (string-to-number article)))
7310 (if (gnus-summary-goto-subject article force)
7311 (gnus-summary-display-article article all-headers)
7312 (gnus-message 4 "Couldn't go to article %s" article) nil))
7313 (gnus-summary-position-point)))
7315 (defun gnus-summary-goto-last-article ()
7316 "Go to the previously read article."
7319 (when gnus-last-article
7320 (gnus-summary-goto-article gnus-last-article nil t))
7321 (gnus-summary-position-point)))
7323 (defun gnus-summary-pop-article (number)
7324 "Pop one article off the history and go to the previous.
7325 NUMBER articles will be popped off."
7328 (setq gnus-newsgroup-history
7329 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7331 (gnus-summary-goto-article (car to) nil t)
7332 (error "Article history empty")))
7333 (gnus-summary-position-point))
7335 ;; Summary commands and functions for limiting the summary buffer.
7337 (defun gnus-summary-limit-to-articles (n)
7338 "Limit the summary buffer to the next N articles.
7339 If not given a prefix, use the process marked articles instead."
7342 (let ((articles (gnus-summary-work-articles n)))
7343 (setq gnus-newsgroup-processable nil)
7344 (gnus-summary-limit articles))
7345 (gnus-summary-position-point)))
7347 (defun gnus-summary-pop-limit (&optional total)
7348 "Restore the previous limit.
7349 If given a prefix, remove all limits."
7352 (setq gnus-newsgroup-limits
7353 (list (mapcar (lambda (h) (mail-header-number h))
7354 gnus-newsgroup-headers))))
7355 (unless gnus-newsgroup-limits
7356 (error "No limit to pop"))
7358 (gnus-summary-limit nil 'pop)
7359 (gnus-summary-position-point)))
7361 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7362 "Limit the summary buffer to articles that have subjects that match a regexp.
7363 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7365 (list (read-string (if current-prefix-arg
7366 "Exclude subject (regexp): "
7367 "Limit to subject (regexp): "))
7368 nil current-prefix-arg))
7370 (setq header "subject"))
7371 (when (not (equal "" subject))
7373 (let ((articles (gnus-summary-find-matching
7374 (or header "subject") subject 'all nil nil
7377 (error "Found no matches for \"%s\"" subject))
7378 (gnus-summary-limit articles))
7379 (gnus-summary-position-point))))
7381 (defun gnus-summary-limit-to-author (from &optional not-matching)
7382 "Limit the summary buffer to articles that have authors that match a regexp.
7383 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7385 (list (read-string (if current-prefix-arg
7386 "Exclude author (regexp): "
7387 "Limit to author (regexp): "))
7388 current-prefix-arg))
7389 (gnus-summary-limit-to-subject from "from" not-matching))
7391 (defun gnus-summary-limit-to-age (age &optional younger-p)
7392 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7393 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7394 articles that are younger than AGE days."
7396 (let ((younger current-prefix-arg)
7399 (while (not days-got)
7400 (setq days (if younger
7401 (read-string "Limit to articles younger than (in days, older when negative): ")
7403 "Limit to articles older than (in days, younger when negative): ")))
7404 (when (> (length days) 0)
7405 (setq days (read days)))
7411 (setq younger (not younger))
7412 (setq days (* days -1)))))
7413 (message "Please enter a number.")
7415 (list days younger)))
7417 (let ((data gnus-newsgroup-data)
7418 (cutoff (days-to-time age))
7419 articles d date is-younger)
7420 (while (setq d (pop data))
7421 (when (and (vectorp (gnus-data-header d))
7422 (setq date (mail-header-date (gnus-data-header d))))
7423 (setq is-younger (time-less-p
7424 (time-since (condition-case ()
7431 (push (gnus-data-number d) articles))))
7432 (gnus-summary-limit (nreverse articles)))
7433 (gnus-summary-position-point)))
7435 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7436 "Limit the summary buffer to articles that match an 'extra' header."
7440 (gnus-completing-read-with-default
7441 (symbol-name (car gnus-extra-headers))
7442 (if current-prefix-arg
7443 "Exclude extra header:"
7444 "Limit extra header:")
7446 (cons (symbol-name x) x))
7451 (read-string (format "%s header %s (regexp): "
7452 (if current-prefix-arg "Exclude" "Limit to")
7454 current-prefix-arg)))
7455 (when (not (equal "" regexp))
7457 (let ((articles (gnus-summary-find-matching
7458 (cons 'extra header) regexp 'all nil nil
7461 (error "Found no matches for \"%s\"" regexp))
7462 (gnus-summary-limit articles))
7463 (gnus-summary-position-point))))
7465 (defun gnus-summary-limit-to-display-predicate ()
7466 "Limit the summary buffer to the predicated in the `display' group parameter."
7468 (unless gnus-newsgroup-display
7469 (error "There is no `display' group parameter"))
7471 (dolist (number gnus-newsgroup-articles)
7472 (when (funcall gnus-newsgroup-display)
7473 (push number articles)))
7474 (gnus-summary-limit articles))
7475 (gnus-summary-position-point))
7477 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7479 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7481 (defun gnus-summary-limit-to-unread (&optional all)
7482 "Limit the summary buffer to articles that are not marked as read.
7483 If ALL is non-nil, limit strictly to unread articles."
7486 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7487 (gnus-summary-limit-to-marks
7488 ;; Concat all the marks that say that an article is read and have
7490 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7491 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7492 gnus-low-score-mark gnus-expirable-mark
7493 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7494 gnus-duplicate-mark gnus-souped-mark)
7497 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7498 (make-obsolete 'gnus-summary-delete-marked-with
7499 'gnus-summary-limit-exclude-marks)
7501 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7502 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7503 If REVERSE, limit the summary buffer to articles that are marked
7504 with MARKS. MARKS can either be a string of marks or a list of marks.
7505 Returns how many articles were removed."
7506 (interactive "sMarks: ")
7507 (gnus-summary-limit-to-marks marks t))
7509 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7510 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7511 If REVERSE (the prefix), limit the summary buffer to articles that are
7512 not marked with MARKS. MARKS can either be a string of marks or a
7514 Returns how many articles were removed."
7515 (interactive "sMarks: \nP")
7517 (let ((data gnus-newsgroup-data)
7518 (marks (if (listp marks) marks
7519 (append marks nil))) ; Transform to list.
7522 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7523 (memq (gnus-data-mark (car data)) marks))
7524 (push (gnus-data-number (car data)) articles))
7525 (setq data (cdr data)))
7526 (gnus-summary-limit articles))
7527 (gnus-summary-position-point)))
7529 (defun gnus-summary-limit-to-score (score)
7530 "Limit to articles with score at or above SCORE."
7531 (interactive "NLimit to articles with score of at least: ")
7532 (let ((data gnus-newsgroup-data)
7535 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7537 (push (gnus-data-number (car data)) articles))
7538 (setq data (cdr data)))
7540 (gnus-summary-limit articles)
7541 (gnus-summary-position-point))))
7543 (defun gnus-summary-limit-to-unseen ()
7544 "Limit to unseen articles."
7547 (gnus-summary-limit gnus-newsgroup-unseen)
7548 (gnus-summary-position-point)))
7550 (defun gnus-summary-limit-include-thread (id)
7551 "Display all the hidden articles that is in the thread with ID in it.
7552 When called interactively, ID is the Message-ID of the current
7554 (interactive (list (mail-header-id (gnus-summary-article-header))))
7555 (let ((articles (gnus-articles-in-thread
7556 (gnus-id-to-thread (gnus-root-id id)))))
7558 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7559 (gnus-summary-limit-include-matching-articles
7561 (regexp-quote (gnus-simplify-subject-re
7562 (mail-header-subject (gnus-id-to-header id)))))
7563 (gnus-summary-position-point))))
7565 (defun gnus-summary-limit-include-matching-articles (header regexp)
7566 "Display all the hidden articles that have HEADERs that match REGEXP."
7567 (interactive (list (read-string "Match on header: ")
7568 (read-string "Regexp: ")))
7569 (let ((articles (gnus-find-matching-articles header regexp)))
7571 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7572 (gnus-summary-position-point))))
7574 (defun gnus-summary-insert-dormant-articles ()
7575 "Insert all the dormat articles for this group into the current buffer."
7577 (let ((gnus-verbose (max 6 gnus-verbose)))
7578 (if (not gnus-newsgroup-dormant)
7579 (gnus-message 3 "No cached articles for this group")
7580 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7582 (defun gnus-summary-limit-include-dormant ()
7583 "Display all the hidden articles that are marked as dormant.
7584 Note that this command only works on a subset of the articles currently
7585 fetched for this group."
7587 (unless gnus-newsgroup-dormant
7588 (error "There are no dormant articles in this group"))
7590 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7591 (gnus-summary-position-point)))
7593 (defun gnus-summary-limit-exclude-dormant ()
7594 "Hide all dormant articles."
7597 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7598 (gnus-summary-position-point)))
7600 (defun gnus-summary-limit-exclude-childless-dormant ()
7601 "Hide all dormant articles that have no children."
7603 (let ((data (gnus-data-list t))
7604 articles d children)
7605 ;; Find all articles that are either not dormant or have
7607 (while (setq d (pop data))
7608 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7610 (gnus-article-children (gnus-data-number d)))
7613 (when (memq (car children) articles)
7618 (push (gnus-data-number d) articles)))
7621 (gnus-summary-limit articles)
7622 (gnus-summary-position-point))))
7624 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7625 "Mark all unread excluded articles as read.
7626 If ALL, mark even excluded ticked and dormants as read."
7628 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7629 (let ((articles (gnus-sorted-ndifference
7631 (mapcar (lambda (h) (mail-header-number h))
7632 gnus-newsgroup-headers)
7634 gnus-newsgroup-limit))
7636 (setq gnus-newsgroup-unreads
7637 (gnus-sorted-intersection gnus-newsgroup-unreads
7638 gnus-newsgroup-limit))
7640 (setq gnus-newsgroup-dormant nil
7641 gnus-newsgroup-marked nil
7642 gnus-newsgroup-reads
7644 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7645 gnus-newsgroup-reads))
7646 (while (setq article (pop articles))
7647 (unless (or (memq article gnus-newsgroup-dormant)
7648 (memq article gnus-newsgroup-marked))
7649 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7651 (defun gnus-summary-limit (articles &optional pop)
7653 ;; We pop the previous limit off the stack and use that.
7654 (setq articles (car gnus-newsgroup-limits)
7655 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7656 ;; We use the new limit, so we push the old limit on the stack.
7657 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7659 (setq gnus-newsgroup-limit articles)
7660 (let ((total (length gnus-newsgroup-data))
7661 (data (gnus-data-find-list (gnus-summary-article-number)))
7662 (gnus-summary-mark-below nil) ; Inhibit this.
7664 ;; This will do all the work of generating the new summary buffer
7665 ;; according to the new limit.
7666 (gnus-summary-prepare)
7667 ;; Hide any threads, possibly.
7668 (gnus-summary-maybe-hide-threads)
7669 ;; Try to return to the article you were at, or one in the
7672 ;; We try to find some article after the current one.
7674 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7677 (setq data (cdr data))))
7679 ;; If there is no data, that means that we were after the last
7680 ;; article. The same goes when we can't find any articles
7681 ;; after the current one.
7682 (goto-char (point-max))
7683 (gnus-summary-find-prev))
7684 (gnus-set-mode-line 'summary)
7685 ;; We return how many articles were removed from the summary
7686 ;; buffer as a result of the new limit.
7687 (- total (length gnus-newsgroup-data))))
7689 (defsubst gnus-invisible-cut-children (threads)
7692 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7697 (defsubst gnus-cut-thread (thread)
7698 "Go forwards in the thread until we find an article that we want to display."
7699 (when (or (eq gnus-fetch-old-headers 'some)
7700 (eq gnus-fetch-old-headers 'invisible)
7701 (numberp gnus-fetch-old-headers)
7702 (eq gnus-build-sparse-threads 'some)
7703 (eq gnus-build-sparse-threads 'more))
7704 ;; Deal with old-fetched headers and sparse threads.
7708 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7709 (gnus-summary-article-ancient-p
7710 (mail-header-number (car thread))))
7711 (if (or (<= (length (cdr thread)) 1)
7712 (eq gnus-fetch-old-headers 'invisible))
7713 (setq gnus-newsgroup-limit
7714 (delq (mail-header-number (car thread))
7715 gnus-newsgroup-limit)
7716 thread (cadr thread))
7717 (when (gnus-invisible-cut-children (cdr thread))
7718 (let ((th (cdr thread)))
7720 (if (memq (mail-header-number (caar th))
7721 gnus-newsgroup-limit)
7722 (setq thread (car th)
7724 (setq th (cdr th))))))))))
7727 (defun gnus-cut-threads (threads)
7728 "Cut off all uninteresting articles from the beginning of threads."
7729 (when (or (eq gnus-fetch-old-headers 'some)
7730 (eq gnus-fetch-old-headers 'invisible)
7731 (numberp gnus-fetch-old-headers)
7732 (eq gnus-build-sparse-threads 'some)
7733 (eq gnus-build-sparse-threads 'more))
7736 (setcar th (gnus-cut-thread (car th)))
7737 (setq th (cdr th)))))
7738 ;; Remove nixed out threads.
7741 (defun gnus-summary-initial-limit (&optional show-if-empty)
7742 "Figure out what the initial limit is supposed to be on group entry.
7743 This entails weeding out unwanted dormants, low-scored articles,
7744 fetch-old-headers verbiage, and so on."
7745 ;; Most groups have nothing to remove.
7746 (if (or gnus-inhibit-limiting
7747 (and (null gnus-newsgroup-dormant)
7748 (eq gnus-newsgroup-display 'gnus-not-ignore)
7749 (not (eq gnus-fetch-old-headers 'some))
7750 (not (numberp gnus-fetch-old-headers))
7751 (not (eq gnus-fetch-old-headers 'invisible))
7752 (null gnus-summary-expunge-below)
7753 (not (eq gnus-build-sparse-threads 'some))
7754 (not (eq gnus-build-sparse-threads 'more))
7755 (null gnus-thread-expunge-below)
7756 (not gnus-use-nocem)))
7758 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7759 (setq gnus-newsgroup-limit nil)
7762 (unless (car (symbol-value node))
7763 ;; These threads have no parents -- they are roots.
7764 (let ((nodes (cdr (symbol-value node)))
7767 (if (and gnus-thread-expunge-below
7768 (< (gnus-thread-total-score (car nodes))
7769 gnus-thread-expunge-below))
7770 (gnus-expunge-thread (pop nodes))
7771 (setq thread (pop nodes))
7772 (gnus-summary-limit-children thread))))))
7773 gnus-newsgroup-dependencies)
7774 ;; If this limitation resulted in an empty group, we might
7775 ;; pop the previous limit and use it instead.
7776 (when (and (not gnus-newsgroup-limit)
7778 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7779 gnus-newsgroup-limit))
7781 (defun gnus-summary-limit-children (thread)
7782 "Return 1 if this subthread is visible and 0 if it is not."
7783 ;; First we get the number of visible children to this thread. This
7784 ;; is done by recursing down the thread using this function, so this
7785 ;; will really go down to a leaf article first, before slowly
7786 ;; working its way up towards the root.
7788 (let* ((max-lisp-eval-depth 5000)
7791 (apply '+ (mapcar 'gnus-summary-limit-children
7794 (number (mail-header-number (car thread)))
7797 (not (memq number gnus-newsgroup-marked))
7799 ;; If this article is dormant and has absolutely no visible
7800 ;; children, then this article isn't visible.
7801 (and (memq number gnus-newsgroup-dormant)
7803 ;; If this is "fetch-old-headered" and there is no
7804 ;; visible children, then we don't want this article.
7805 (and (or (eq gnus-fetch-old-headers 'some)
7806 (numberp gnus-fetch-old-headers))
7807 (gnus-summary-article-ancient-p number)
7809 ;; If this is "fetch-old-headered" and `invisible', then
7810 ;; we don't want this article.
7811 (and (eq gnus-fetch-old-headers 'invisible)
7812 (gnus-summary-article-ancient-p number))
7813 ;; If this is a sparsely inserted article with no children,
7814 ;; we don't want it.
7815 (and (eq gnus-build-sparse-threads 'some)
7816 (gnus-summary-article-sparse-p number)
7818 ;; If we use expunging, and this article is really
7819 ;; low-scored, then we don't want this article.
7820 (when (and gnus-summary-expunge-below
7822 (or (cdr (assq number gnus-newsgroup-scored))
7823 gnus-summary-default-score))
7824 gnus-summary-expunge-below))
7825 ;; We increase the expunge-tally here, but that has
7826 ;; nothing to do with the limits, really.
7827 (incf gnus-newsgroup-expunged-tally)
7828 ;; We also mark as read here, if that's wanted.
7829 (when (and gnus-summary-mark-below
7830 (< score gnus-summary-mark-below))
7831 (setq gnus-newsgroup-unreads
7832 (delq number gnus-newsgroup-unreads))
7833 (if gnus-newsgroup-auto-expire
7834 (push number gnus-newsgroup-expirable)
7835 (push (cons number gnus-low-score-mark)
7836 gnus-newsgroup-reads)))
7838 ;; Do the `display' group parameter.
7839 (and gnus-newsgroup-display
7840 (not (funcall gnus-newsgroup-display)))
7841 ;; Check NoCeM things.
7842 (if (and gnus-use-nocem
7843 (gnus-nocem-unwanted-article-p
7844 (mail-header-id (car thread))))
7846 (setq gnus-newsgroup-unreads
7847 (delq number gnus-newsgroup-unreads))
7849 ;; Nope, invisible article.
7851 ;; Ok, this article is to be visible, so we add it to the limit
7853 (push number gnus-newsgroup-limit)
7856 (defun gnus-expunge-thread (thread)
7857 "Mark all articles in THREAD as read."
7858 (let* ((number (mail-header-number (car thread))))
7859 (incf gnus-newsgroup-expunged-tally)
7860 ;; We also mark as read here, if that's wanted.
7861 (setq gnus-newsgroup-unreads
7862 (delq number gnus-newsgroup-unreads))
7863 (if gnus-newsgroup-auto-expire
7864 (push number gnus-newsgroup-expirable)
7865 (push (cons number gnus-low-score-mark)
7866 gnus-newsgroup-reads)))
7867 ;; Go recursively through all subthreads.
7868 (mapcar 'gnus-expunge-thread (cdr thread)))
7870 ;; Summary article oriented commands
7872 (defun gnus-summary-refer-parent-article (n)
7873 "Refer parent article N times.
7874 If N is negative, go to ancestor -N instead.
7875 The difference between N and the number of articles fetched is returned."
7879 (when (not (natnump n))
7884 (setq header (gnus-summary-article-header))
7885 (if (and (eq (mail-header-number header)
7886 (cdr gnus-article-current))
7887 (equal gnus-newsgroup-name
7888 (car gnus-article-current)))
7889 ;; If we try to find the parent of the currently
7890 ;; displayed article, then we take a look at the actual
7891 ;; References header, since this is slightly more
7892 ;; reliable than the References field we got from the
7895 (set-buffer gnus-original-article-buffer)
7896 (nnheader-narrow-to-headers)
7897 (unless (setq ref (message-fetch-field "references"))
7898 (setq ref (message-fetch-field "in-reply-to")))
7901 ;; It's not the current article, so we take a bet on
7902 ;; the value we got from the server.
7903 (mail-header-references header)))
7905 (not (equal ref "")))
7906 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7907 (gnus-message 1 "Couldn't find parent"))
7908 (gnus-message 1 "No references in article %d"
7909 (gnus-summary-article-number))
7912 (gnus-summary-position-point)
7915 (defun gnus-summary-refer-references ()
7916 "Fetch all articles mentioned in the References header.
7917 Return the number of articles fetched."
7919 (let ((ref (mail-header-references (gnus-summary-article-header)))
7920 (current (gnus-summary-article-number))
7924 (error "No References in the current article")
7925 ;; For each Message-ID in the References header...
7926 (while (string-match "<[^>]*>" ref)
7928 ;; ... fetch that article.
7929 (gnus-summary-refer-article
7930 (prog1 (match-string 0 ref)
7931 (setq ref (substring ref (match-end 0))))))
7932 (gnus-summary-goto-subject current)
7933 (gnus-summary-position-point)
7936 (defun gnus-summary-refer-thread (&optional limit)
7937 "Fetch all articles in the current thread.
7938 If LIMIT (the numerical prefix), fetch that many old headers instead
7939 of what's specified by the `gnus-refer-thread-limit' variable."
7941 (let ((id (mail-header-id (gnus-summary-article-header)))
7942 (limit (if limit (prefix-numeric-value limit)
7943 gnus-refer-thread-limit)))
7944 ;; We want to fetch LIMIT *old* headers, but we also have to
7945 ;; re-fetch all the headers in the current buffer, because many of
7946 ;; them may be undisplayed. So we adjust LIMIT.
7947 (when (numberp limit)
7948 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7949 (unless (eq gnus-fetch-old-headers 'invisible)
7950 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7951 ;; Retrieve the headers and read them in.
7952 (if (eq (gnus-retrieve-headers
7953 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7955 (gnus-build-all-threads)
7956 (error "Can't fetch thread from backends that don't support NOV"))
7957 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7958 (gnus-summary-limit-include-thread id)))
7960 (defun gnus-summary-refer-article (message-id)
7961 "Fetch an article specified by MESSAGE-ID."
7962 (interactive "sMessage-ID: ")
7963 (when (and (stringp message-id)
7964 (not (zerop (length message-id))))
7965 ;; Construct the correct Message-ID if necessary.
7966 ;; Suggested by tale@pawl.rpi.edu.
7967 (unless (string-match "^<" message-id)
7968 (setq message-id (concat "<" message-id)))
7969 (unless (string-match ">$" message-id)
7970 (setq message-id (concat message-id ">")))
7971 (let* ((header (gnus-id-to-header message-id))
7973 (gnus-summary-article-sparse-p
7974 (mail-header-number header))
7975 (memq (mail-header-number header)
7976 gnus-newsgroup-limit)))
7979 ;; If the article is present in the buffer we just go to it.
7981 (or (not (gnus-summary-article-sparse-p
7982 (mail-header-number header)))
7985 (gnus-summary-goto-article
7986 (mail-header-number header) nil t)
7988 (gnus-summary-update-article (mail-header-number header)))))
7990 ;; We fetch the article.
7992 (dolist (gnus-override-method (gnus-refer-article-methods))
7993 (gnus-check-server gnus-override-method)
7994 ;; Fetch the header, and display the article.
7995 (when (setq number (gnus-summary-insert-subject message-id))
7996 (gnus-summary-select-article nil nil nil number)
7998 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8000 (defun gnus-refer-article-methods ()
8001 "Return a list of referable methods."
8003 ;; No method, so we default to current and native.
8004 ((null gnus-refer-article-method)
8005 (list gnus-current-select-method gnus-select-method))
8007 ((eq 'current gnus-refer-article-method)
8008 (list gnus-current-select-method))
8009 ;; List of select methods.
8010 ((not (and (symbolp (car gnus-refer-article-method))
8011 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8013 (dolist (method gnus-refer-article-method)
8014 (push (if (eq 'current method)
8015 gnus-current-select-method
8019 ;; One single select method.
8021 (list gnus-refer-article-method))))
8023 (defun gnus-summary-edit-parameters ()
8024 "Edit the group parameters of the current group."
8026 (gnus-group-edit-group gnus-newsgroup-name 'params))
8028 (defun gnus-summary-customize-parameters ()
8029 "Customize the group parameters of the current group."
8031 (gnus-group-customize gnus-newsgroup-name))
8033 (defun gnus-summary-enter-digest-group (&optional force)
8034 "Enter an nndoc group based on the current article.
8035 If FORCE, force a digest interpretation. If not, try
8036 to guess what the document format is."
8038 (let ((conf gnus-current-window-configuration))
8040 (gnus-summary-select-article))
8041 (setq gnus-current-window-configuration conf)
8042 (let* ((name (format "%s-%d"
8043 (gnus-group-prefixed-name
8044 gnus-newsgroup-name (list 'nndoc ""))
8046 (set-buffer gnus-summary-buffer)
8047 gnus-current-article)))
8048 (ogroup gnus-newsgroup-name)
8049 (params (append (gnus-info-params (gnus-get-info ogroup))
8050 (list (cons 'to-group ogroup))
8051 (list (cons 'save-article-group ogroup))))
8052 (case-fold-search t)
8053 (buf (current-buffer))
8056 (set-buffer gnus-original-article-buffer)
8057 ;; Have the digest group inherit the main mail address of
8058 ;; the parent article.
8059 (when (setq to-address (or (gnus-fetch-field "reply-to")
8060 (gnus-fetch-field "from")))
8061 (setq params (append
8062 (list (cons 'to-address
8063 (funcall gnus-decode-encoded-word-function
8065 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8066 (insert-buffer-substring gnus-original-article-buffer)
8067 ;; Remove lines that may lead nndoc to misinterpret the
8070 (goto-char (point-min))
8071 (or (search-forward "\n\n" nil t) (point)))
8072 (goto-char (point-min))
8073 (delete-matching-lines "^Path:\\|^From ")
8076 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8077 (gnus-newsgroup-ephemeral-ignored-charsets
8078 gnus-newsgroup-ignored-charsets))
8079 (gnus-group-read-ephemeral-group
8080 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8082 ,(if force 'mbox 'guess)))
8084 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8086 ;; Make all postings to this group go to the parent group.
8087 (nconc (gnus-info-params (gnus-get-info name))
8089 ;; Couldn't select this doc group.
8090 (switch-to-buffer buf)
8091 (gnus-set-global-variables)
8092 (gnus-configure-windows 'summary)
8093 (gnus-message 3 "Article couldn't be entered?"))
8094 (kill-buffer dig)))))
8096 (defun gnus-summary-read-document (n)
8097 "Open a new group based on the current article(s).
8098 This will allow you to read digests and other similar
8099 documents as newsgroups.
8100 Obeys the standard process/prefix convention."
8102 (let* ((articles (gnus-summary-work-articles n))
8103 (ogroup gnus-newsgroup-name)
8104 (params (append (gnus-info-params (gnus-get-info ogroup))
8105 (list (cons 'to-group ogroup))))
8106 article group egroup groups vgroup)
8107 (while (setq article (pop articles))
8108 (setq group (format "%s-%d" gnus-newsgroup-name article))
8109 (gnus-summary-remove-process-mark article)
8110 (when (gnus-summary-display-article article)
8113 (insert-buffer-substring gnus-original-article-buffer)
8114 ;; Remove some headers that may lead nndoc to make
8116 (message-narrow-to-head)
8117 (goto-char (point-min))
8118 (delete-matching-lines "^\\(Path\\):\\|^From ")
8121 (gnus-group-read-ephemeral-group
8122 group `(nndoc ,group (nndoc-address ,(current-buffer))
8123 (nndoc-article-type guess))
8126 ;; Make all postings to this group go to the parent group.
8127 (nconc (gnus-info-params (gnus-get-info egroup))
8129 (push egroup groups))
8130 ;; Couldn't select this doc group.
8131 (gnus-error 3 "Article couldn't be entered"))))))
8132 ;; Now we have selected all the documents.
8135 (error "None of the articles could be interpreted as documents"))
8136 ((gnus-group-read-ephemeral-group
8137 (setq vgroup (format
8138 "nnvirtual:%s-%s" gnus-newsgroup-name
8139 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8140 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8142 (cons (current-buffer) 'summary)))
8144 (error "Couldn't select virtual nndoc group")))))
8146 (defun gnus-summary-isearch-article (&optional regexp-p)
8147 "Do incremental search forward on the current article.
8148 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8150 (gnus-summary-select-article)
8151 (gnus-configure-windows 'article)
8152 (gnus-eval-in-buffer-window gnus-article-buffer
8155 (isearch-forward regexp-p))))
8157 (defun gnus-summary-search-article-forward (regexp &optional backward)
8158 "Search for an article containing REGEXP forward.
8159 If BACKWARD, search backward instead."
8162 (format "Search article %s (regexp%s): "
8163 (if current-prefix-arg "backward" "forward")
8164 (if gnus-last-search-regexp
8165 (concat ", default " gnus-last-search-regexp)
8167 current-prefix-arg))
8168 (if (string-equal regexp "")
8169 (setq regexp (or gnus-last-search-regexp ""))
8170 (setq gnus-last-search-regexp regexp)
8171 (setq gnus-article-before-search gnus-current-article))
8172 ;; Intentionally set gnus-last-article.
8173 (setq gnus-last-article gnus-article-before-search)
8174 (let ((gnus-last-article gnus-last-article))
8175 (if (gnus-summary-search-article regexp backward)
8176 (gnus-summary-show-thread)
8177 (error "Search failed: \"%s\"" regexp))))
8179 (defun gnus-summary-search-article-backward (regexp)
8180 "Search for an article containing REGEXP backward."
8183 (format "Search article backward (regexp%s): "
8184 (if gnus-last-search-regexp
8185 (concat ", default " gnus-last-search-regexp)
8187 (gnus-summary-search-article-forward regexp 'backward))
8189 (defun gnus-summary-search-article (regexp &optional backward)
8190 "Search for an article containing REGEXP.
8191 Optional argument BACKWARD means do search for backward.
8192 `gnus-select-article-hook' is not called during the search."
8193 ;; We have to require this here to make sure that the following
8194 ;; dynamic binding isn't shadowed by autoloading.
8195 (require 'gnus-async)
8197 (let ((gnus-select-article-hook nil) ;Disable hook.
8198 (gnus-article-prepare-hook nil)
8199 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8200 (gnus-use-article-prefetch nil)
8201 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8202 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8204 (gnus-keep-backlog nil)
8205 (gnus-break-pages nil)
8206 (gnus-summary-display-arrow nil)
8207 (gnus-updated-mode-lines nil)
8208 (gnus-auto-center-summary nil)
8209 (sum (current-buffer))
8210 (gnus-display-mime-function nil)
8213 (gnus-save-hidden-threads
8214 (gnus-summary-select-article)
8215 (set-buffer gnus-article-buffer)
8216 (goto-char (window-point (get-buffer-window (current-buffer))))
8220 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8222 (re-search-backward regexp nil t)
8223 (re-search-forward regexp nil t))
8224 ;; We found the regexp.
8229 (get-buffer-window (current-buffer))
8233 (get-buffer-window (current-buffer))
8236 (setq point (point)))
8237 ;; We didn't find it, so we go to the next article.
8240 (while (eq found 'not)
8241 (if (not (if backward (gnus-summary-find-prev)
8242 (gnus-summary-find-next)))
8243 ;; No more articles.
8245 ;; Select the next article and adjust point.
8246 (unless (gnus-summary-article-sparse-p
8247 (gnus-summary-article-number))
8249 (gnus-summary-select-article)
8250 (set-buffer gnus-article-buffer)
8252 (goto-char (if backward (point-max) (point-min))))))))
8253 (gnus-message 7 ""))
8254 ;; Return whether we found the regexp.
8255 (when (eq found 'found)
8257 (gnus-summary-show-thread)
8258 (gnus-summary-goto-subject gnus-current-article)
8259 (gnus-summary-position-point)
8262 (defun gnus-find-matching-articles (header regexp)
8263 "Return a list of all articles that match REGEXP on HEADER.
8264 This search includes all articles in the current group that Gnus has
8265 fetched headers for, whether they are displayed or not."
8266 (let ((articles nil)
8267 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8268 (case-fold-search t))
8269 (dolist (header gnus-newsgroup-headers)
8270 (when (string-match regexp (funcall func header))
8271 (push (mail-header-number header) articles)))
8272 (nreverse articles)))
8274 (defun gnus-summary-find-matching (header regexp &optional backward unread
8275 not-case-fold not-matching)
8276 "Return a list of all articles that match REGEXP on HEADER.
8277 The search stars on the current article and goes forwards unless
8278 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8279 If UNREAD is non-nil, only unread articles will
8280 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8281 in the comparisons. If NOT-MATCHING, return a list of all articles that
8282 not match REGEXP on HEADER."
8283 (let ((case-fold-search (not not-case-fold))
8286 (if (eq (car header) 'extra)
8289 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8291 (error "%s is an invalid header" header))
8292 (unless (fboundp (intern (concat "mail-header-" header)))
8293 (error "%s is not a valid header" header))
8294 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8295 (dolist (d (if (eq backward 'all)
8297 (gnus-data-find-list
8298 (gnus-summary-article-number)
8299 (gnus-data-list backward))))
8300 (when (and (or (not unread) ; We want all articles...
8301 (gnus-data-unread-p d)) ; Or just unreads.
8302 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8306 (funcall func (gnus-data-header d))))
8307 (string-match regexp
8308 (funcall func (gnus-data-header d)))))
8309 (push (gnus-data-number d) articles))) ; Success!
8310 (nreverse articles)))
8312 (defun gnus-summary-execute-command (header regexp command &optional backward)
8313 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8314 If HEADER is an empty string (or nil), the match is done on the entire
8315 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8317 (list (let ((completion-ignore-case t))
8320 (mapcar (lambda (header) (list (format "%s" header)))
8322 '("Number" "Subject" "From" "Lines" "Date"
8323 "Message-ID" "Xref" "References" "Body")
8324 gnus-extra-headers))
8325 nil 'require-match))
8326 (read-string "Regexp: ")
8327 (read-key-sequence "Command: ")
8328 current-prefix-arg))
8329 (when (equal header "Body")
8331 ;; Hidden thread subtrees must be searched as well.
8332 (gnus-summary-show-all-threads)
8333 ;; We don't want to change current point nor window configuration.
8335 (save-window-excursion
8337 gnus-treat-strip-trailing-blank-lines
8338 gnus-treat-strip-leading-blank-lines
8339 gnus-treat-strip-multiple-blank-lines
8340 gnus-treat-hide-boring-headers
8341 gnus-treat-fold-newsgroups
8342 gnus-article-prepare-hook)
8343 (gnus-message 6 "Executing %s..." (key-description command))
8344 ;; We'd like to execute COMMAND interactively so as to give arguments.
8345 (gnus-execute header regexp
8346 `(call-interactively ',(key-binding command))
8348 (gnus-message 6 "Executing %s...done" (key-description command))))))
8350 (defun gnus-summary-beginning-of-article ()
8351 "Scroll the article back to the beginning."
8353 (gnus-summary-select-article)
8354 (gnus-configure-windows 'article)
8355 (gnus-eval-in-buffer-window gnus-article-buffer
8357 (goto-char (point-min))
8358 (when gnus-page-broken
8359 (gnus-narrow-to-page))))
8361 (defun gnus-summary-end-of-article ()
8362 "Scroll to the end of the article."
8364 (gnus-summary-select-article)
8365 (gnus-configure-windows 'article)
8366 (gnus-eval-in-buffer-window gnus-article-buffer
8368 (goto-char (point-max))
8370 (when gnus-page-broken
8371 (gnus-narrow-to-page))))
8373 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8374 "Truncate to LEN and quote all \"(\"'s in STRING."
8375 (gnus-replace-in-string (if (and len (> (length string) len))
8376 (substring string 0 len)
8380 (defun gnus-summary-print-article (&optional filename n)
8381 "Generate and print a PostScript image of the N next (mail) articles.
8383 If N is negative, print the N previous articles. If N is nil and articles
8384 have been marked with the process mark, print these instead.
8386 If the optional first argument FILENAME is nil, send the image to the
8387 printer. If FILENAME is a string, save the PostScript image in a file with
8388 that name. If FILENAME is a number, prompt the user for the name of the file
8390 (interactive (list (ps-print-preprint current-prefix-arg)))
8391 (dolist (article (gnus-summary-work-articles n))
8392 (gnus-summary-select-article nil nil 'pseudo article)
8393 (gnus-eval-in-buffer-window gnus-article-buffer
8394 (gnus-print-buffer))
8395 (gnus-summary-remove-process-mark article))
8396 (ps-despool filename))
8398 (defun gnus-print-buffer ()
8399 (let ((buffer (generate-new-buffer " *print*")))
8402 (copy-to-buffer buffer (point-min) (point-max))
8404 (gnus-article-delete-invisible-text)
8405 (gnus-remove-text-with-property 'gnus-decoration)
8406 (when (gnus-visual-p 'article-highlight 'highlight)
8407 ;; Copy-to-buffer doesn't copy overlay. So redo
8409 (let ((gnus-article-buffer buffer))
8410 (gnus-article-highlight-citation t)
8411 (gnus-article-highlight-signature)))
8412 (let ((ps-left-header
8415 (gnus-summary-print-truncate-and-quote
8416 (mail-header-subject gnus-current-headers)
8419 (gnus-summary-print-truncate-and-quote
8420 (mail-header-from gnus-current-headers)
8424 "/pagenumberstring load"
8426 (mail-header-date gnus-current-headers) ")"))))
8427 (gnus-run-hooks 'gnus-ps-print-hook)
8430 (ps-spool-buffer-with-faces)
8431 (ps-spool-buffer)))))
8432 (kill-buffer buffer))))
8434 (defun gnus-summary-show-article (&optional arg)
8435 "Force redisplaying of the current article.
8436 If ARG (the prefix) is a number, show the article with the charset
8437 defined in `gnus-summary-show-article-charset-alist', or the charset
8439 If ARG (the prefix) is non-nil and not a number, show the raw article
8440 without any article massaging functions being run. Normally, the key strokes
8445 (gnus-summary-show-article t)
8446 (let ((gnus-newsgroup-charset
8447 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8448 (mm-read-coding-system
8449 "View as charset: " ;; actually it is coding system.
8451 (set-buffer gnus-article-buffer)
8452 (mm-detect-coding-region (point) (point-max))))))
8453 (gnus-newsgroup-ignored-charsets 'gnus-all))
8454 (gnus-summary-select-article nil 'force)
8455 (let ((deps gnus-newsgroup-dependencies)
8458 (set-buffer gnus-original-article-buffer)
8460 (message-narrow-to-head)
8461 (setq head (buffer-string))
8462 (goto-char (point-min))
8463 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8464 (goto-char (point-max))
8466 (setq lines (1- (count-lines (point) (point-max))))))
8468 (insert (format "211 %d Article retrieved.\n"
8469 (cdr gnus-article-current)))
8471 (if lines (insert (format "Lines: %d\n" lines)))
8473 (let ((nntp-server-buffer (current-buffer)))
8474 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8475 (gnus-data-set-header
8476 (gnus-data-find (cdr gnus-article-current))
8478 (gnus-summary-update-article-line
8479 (cdr gnus-article-current) header)
8480 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8481 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8483 ;; Select the article the normal way.
8484 (gnus-summary-select-article nil 'force))
8486 ;; We have to require this here to make sure that the following
8487 ;; dynamic binding isn't shadowed by autoloading.
8488 (require 'gnus-async)
8490 ;; Bind the article treatment functions to nil.
8491 (let ((gnus-have-all-headers t)
8492 gnus-article-prepare-hook
8493 gnus-article-decode-hook
8494 gnus-display-mime-function
8496 ;; Destroy any MIME parts.
8497 (when (gnus-buffer-live-p gnus-article-buffer)
8499 (set-buffer gnus-article-buffer)
8500 (mm-destroy-parts gnus-article-mime-handles)
8501 ;; Set it to nil for safety reason.
8502 (setq gnus-article-mime-handle-alist nil)
8503 (setq gnus-article-mime-handles nil)))
8504 (gnus-summary-select-article nil 'force))))
8505 (gnus-summary-goto-subject gnus-current-article)
8506 (gnus-summary-position-point))
8508 (defun gnus-summary-show-raw-article ()
8509 "Show the raw article without any article massaging functions being run."
8511 (gnus-summary-show-article t))
8513 (defun gnus-summary-verbose-headers (&optional arg)
8514 "Toggle permanent full header display.
8515 If ARG is a positive number, turn header display on.
8516 If ARG is a negative number, turn header display off."
8518 (setq gnus-show-all-headers
8519 (cond ((or (not (numberp arg))
8521 (not gnus-show-all-headers))
8524 (gnus-summary-show-article))
8526 (defun gnus-summary-toggle-header (&optional arg)
8527 "Show the headers if they are hidden, or hide them if they are shown.
8528 If ARG is a positive number, show the entire header.
8529 If ARG is a negative number, hide the unwanted header lines."
8531 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8532 (get-buffer-window gnus-article-buffer t))))
8533 (with-current-buffer gnus-article-buffer
8535 (article-narrow-to-head)
8536 (let* ((buffer-read-only nil)
8537 (inhibit-point-motion-hooks t)
8538 (hidden (if (numberp arg)
8540 (gnus-article-hidden-text-p 'headers)))
8542 (delete-region (point-min) (point-max))
8543 (with-current-buffer gnus-original-article-buffer
8544 (goto-char (setq s (point-min)))
8545 (setq e (if (search-forward "\n\n" nil t)
8548 (insert-buffer-substring gnus-original-article-buffer s e)
8549 (article-decode-encoded-words)
8551 (let ((gnus-treat-hide-headers nil)
8552 (gnus-treat-hide-boring-headers nil))
8553 (gnus-delete-wash-type 'headers)
8554 (gnus-treat-article 'head))
8555 (gnus-treat-article 'head))
8558 (set-window-start window (goto-char (point-min))))
8559 (setq gnus-page-broken
8560 (when gnus-break-pages
8561 (gnus-narrow-to-page)
8563 (gnus-set-mode-line 'article)))))
8565 (defun gnus-summary-show-all-headers ()
8566 "Make all header lines visible."
8568 (gnus-summary-toggle-header 1))
8570 (defun gnus-summary-caesar-message (&optional arg)
8571 "Caesar rotate the current article by 13.
8572 The numerical prefix specifies how many places to rotate each letter
8575 (gnus-summary-select-article)
8576 (let ((mail-header-separator ""))
8577 (gnus-eval-in-buffer-window gnus-article-buffer
8580 (let ((start (window-start))
8582 (message-caesar-buffer-body arg)
8583 (set-window-start (get-buffer-window (current-buffer)) start))))))
8585 (autoload 'unmorse-region "morse"
8586 "Convert morse coded text in region to ordinary ASCII text."
8589 (defun gnus-summary-morse-message (&optional arg)
8590 "Morse decode the current article."
8592 (gnus-summary-select-article)
8593 (let ((mail-header-separator ""))
8594 (gnus-eval-in-buffer-window gnus-article-buffer
8598 (let ((pos (window-start))
8600 (goto-char (point-min))
8601 (when (message-goto-body)
8602 (gnus-narrow-to-body))
8603 (goto-char (point-min))
8604 (while (re-search-forward "·" (point-max) t)
8605 (replace-match "."))
8606 (unmorse-region (point-min) (point-max))
8608 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8610 (defun gnus-summary-stop-page-breaking ()
8611 "Stop page breaking in the current article."
8613 (gnus-summary-select-article)
8614 (gnus-eval-in-buffer-window gnus-article-buffer
8616 (when (gnus-visual-p 'page-marker)
8617 (let ((buffer-read-only nil))
8618 (gnus-remove-text-with-property 'gnus-prev)
8619 (gnus-remove-text-with-property 'gnus-next))
8620 (setq gnus-page-broken nil))))
8622 (defun gnus-summary-move-article (&optional n to-newsgroup
8623 select-method action)
8624 "Move the current article to a different newsgroup.
8625 If N is a positive number, move the N next articles.
8626 If N is a negative number, move the N previous articles.
8627 If N is nil and any articles have been marked with the process mark,
8628 move those articles instead.
8629 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8630 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8631 re-spool using this method.
8633 When called interactively with TO-NEWSGROUP being nil, the value of
8634 the variable `gnus-move-split-methods' is used for finding a default
8635 for the target newsgroup.
8637 For this function to work, both the current newsgroup and the
8638 newsgroup that you want to move to have to support the `request-move'
8639 and `request-accept' functions.
8641 ACTION can be either `move' (the default), `crosspost' or `copy'."
8644 (setq action 'move))
8645 ;; Check whether the source group supports the required functions.
8646 (cond ((and (eq action 'move)
8647 (not (gnus-check-backend-function
8648 'request-move-article gnus-newsgroup-name)))
8649 (error "The current group does not support article moving"))
8650 ((and (eq action 'crosspost)
8651 (not (gnus-check-backend-function
8652 'request-replace-article gnus-newsgroup-name)))
8653 (error "The current group does not support article editing")))
8654 (let ((articles (gnus-summary-work-articles n))
8655 (prefix (if (gnus-check-backend-function
8656 'request-move-article gnus-newsgroup-name)
8657 (gnus-group-real-prefix gnus-newsgroup-name)
8659 (names '((move "Move" "Moving")
8660 (copy "Copy" "Copying")
8661 (crosspost "Crosspost" "Crossposting")))
8662 (copy-buf (save-excursion
8663 (nnheader-set-temp-buffer " *copy article*")))
8664 art-group to-method new-xref article to-groups)
8665 (unless (assq action names)
8666 (error "Unknown action %s" action))
8667 ;; Read the newsgroup name.
8668 (when (and (not to-newsgroup)
8669 (not select-method))
8670 (if (and gnus-move-split-methods
8672 (and (memq gnus-current-article articles)
8673 (gnus-buffer-live-p gnus-original-article-buffer))))
8674 ;; When `gnus-move-split-methods' is non-nil, we have to
8675 ;; select an article to give `gnus-read-move-group-name' an
8676 ;; opportunity to suggest an appropriate default. However,
8677 ;; we needn't render or mark the article.
8678 (let ((gnus-display-mime-function nil)
8679 (gnus-article-prepare-hook nil)
8680 (gnus-mark-article-hook nil))
8681 (gnus-summary-select-article nil nil nil (car articles))))
8683 (gnus-read-move-group-name
8684 (cadr (assq action names))
8685 (symbol-value (intern (format "gnus-current-%s-group" action)))
8687 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8688 (setq to-method (or select-method
8689 (gnus-server-to-method
8690 (gnus-group-method to-newsgroup))))
8691 ;; Check the method we are to move this article to...
8692 (unless (gnus-check-backend-function
8693 'request-accept-article (car to-method))
8694 (error "%s does not support article copying" (car to-method)))
8695 (unless (gnus-check-server to-method)
8696 (error "Can't open server %s" (car to-method)))
8697 (gnus-message 6 "%s to %s: %s..."
8698 (caddr (assq action names))
8699 (or (car select-method) to-newsgroup) articles)
8701 (setq article (pop articles))
8705 ;; Move the article.
8707 ;; Remove this article from future suppression.
8708 (gnus-dup-unsuppress-article article)
8709 (gnus-request-move-article
8710 article ; Article to move
8711 gnus-newsgroup-name ; From newsgroup
8712 (nth 1 (gnus-find-method-for-group
8713 gnus-newsgroup-name)) ; Server
8714 (list 'gnus-request-accept-article
8715 to-newsgroup (list 'quote select-method)
8716 (not articles) t) ; Accept form
8717 (not articles))) ; Only save nov last time
8718 ;; Copy the article.
8721 (set-buffer copy-buf)
8722 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8723 (gnus-request-accept-article
8724 to-newsgroup select-method (not articles) t))))
8725 ;; Crosspost the article.
8726 ((eq action 'crosspost)
8727 (let ((xref (message-tokenize-header
8728 (mail-header-xref (gnus-summary-article-header article))
8730 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8731 ":" (number-to-string article)))
8733 (setq xref (list (system-name))))
8736 (mapconcat 'identity
8737 (delete "Xref:" (delete new-xref xref))
8741 (set-buffer copy-buf)
8742 ;; First put the article in the destination group.
8743 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8744 (when (consp (setq art-group
8745 (gnus-request-accept-article
8746 to-newsgroup select-method (not articles))))
8747 (setq new-xref (concat new-xref " " (car art-group)
8749 (number-to-string (cdr art-group))))
8750 ;; Now we have the new Xrefs header, so we insert
8751 ;; it and replace the new article.
8752 (nnheader-replace-header "Xref" new-xref)
8753 (gnus-request-replace-article
8754 (cdr art-group) to-newsgroup (current-buffer))
8758 (gnus-message 1 "Couldn't %s article %s: %s"
8759 (cadr (assq action names)) article
8760 (nnheader-get-report (car to-method))))
8761 ((eq art-group 'junk)
8762 (when (eq action 'move)
8763 (gnus-summary-mark-article article gnus-canceled-mark)
8764 (gnus-message 4 "Deleted article %s" article)))
8766 (let* ((pto-group (gnus-group-prefixed-name
8767 (car art-group) to-method))
8769 (gnus-gethash pto-group gnus-newsrc-hashtb))
8770 (info (nth 2 entry))
8771 (to-group (gnus-info-group info))
8773 ;; Update the group that has been moved to.
8775 (memq action '(move copy)))
8776 (unless (member to-group to-groups)
8777 (push to-group to-groups))
8779 (unless (memq article gnus-newsgroup-unreads)
8780 (push 'read to-marks)
8782 info (gnus-add-to-range (gnus-info-read info)
8783 (list (cdr art-group)))))
8785 ;; See whether the article is to be put in the cache.
8786 (let ((marks gnus-article-mark-lists)
8787 (to-article (cdr art-group)))
8789 ;; Enter the article into the cache in the new group,
8790 ;; if that is required.
8791 (when gnus-use-cache
8792 (gnus-cache-possibly-enter-article
8794 (memq article gnus-newsgroup-marked)
8795 (memq article gnus-newsgroup-dormant)
8796 (memq article gnus-newsgroup-unreads)))
8798 (when gnus-preserve-marks
8799 ;; Copy any marks over to the new group.
8800 (when (and (equal to-group gnus-newsgroup-name)
8801 (not (memq article gnus-newsgroup-unreads)))
8802 ;; Mark this article as read in this group.
8803 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8804 (setcdr (gnus-active to-group) to-article)
8805 (setcdr gnus-newsgroup-active to-article))
8808 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8809 (when (memq article (symbol-value
8810 (intern (format "gnus-newsgroup-%s"
8812 (push (cdar marks) to-marks)
8813 ;; If the other group is the same as this group,
8814 ;; then we have to add the mark to the list.
8815 (when (equal to-group gnus-newsgroup-name)
8816 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8819 (intern (format "gnus-newsgroup-%s"
8821 ;; Copy the marks to other group.
8822 (gnus-add-marked-articles
8823 to-group (cdar marks) (list to-article) info)))
8824 (setq marks (cdr marks)))
8826 (gnus-request-set-mark
8827 to-group (list (list (list to-article) 'add to-marks))))
8830 (concat "(gnus-group-set-info '"
8831 (gnus-prin1-to-string (gnus-get-info to-group))
8834 ;; Update the Xref header in this article to point to
8835 ;; the new crossposted article we have just created.
8836 (when (eq action 'crosspost)
8838 (set-buffer copy-buf)
8839 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8840 (nnheader-replace-header "Xref" new-xref)
8841 (gnus-request-replace-article
8842 article gnus-newsgroup-name (current-buffer)))))
8844 ;;;!!!Why is this necessary?
8845 (set-buffer gnus-summary-buffer)
8847 (gnus-summary-goto-subject article)
8848 (when (eq action 'move)
8849 (gnus-summary-mark-article article gnus-canceled-mark))))
8850 (gnus-summary-remove-process-mark article))
8851 ;; Re-activate all groups that have been moved to.
8853 (set-buffer gnus-group-buffer)
8854 (let ((gnus-group-marked to-groups))
8855 (gnus-group-get-new-news-this-group nil t)))
8857 (gnus-kill-buffer copy-buf)
8858 (gnus-summary-position-point)
8859 (gnus-set-mode-line 'summary)))
8861 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8862 "Move the current article to a different newsgroup.
8863 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8864 When called interactively, if TO-NEWSGROUP is nil, use the value of
8865 the variable `gnus-move-split-methods' for finding a default target
8867 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8868 re-spool using this method."
8870 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8872 (defun gnus-summary-crosspost-article (&optional n)
8873 "Crosspost the current article to some other group."
8875 (gnus-summary-move-article n nil nil 'crosspost))
8877 (defcustom gnus-summary-respool-default-method nil
8878 "Default method type for respooling an article.
8879 If nil, use to the current newsgroup method."
8881 :group 'gnus-summary-mail)
8883 (defcustom gnus-summary-display-while-building nil
8884 "If not-nil, show and update the summary buffer as it's being built.
8885 If the value is t, update the buffer after every line is inserted. If
8886 the value is an integer (N), update the display every N lines."
8888 :type '(choice (const :tag "off" nil)
8890 (const :tag "frequently" t)))
8892 (defun gnus-summary-respool-article (&optional n method)
8893 "Respool the current article.
8894 The article will be squeezed through the mail spooling process again,
8895 which means that it will be put in some mail newsgroup or other
8896 depending on `nnmail-split-methods'.
8897 If N is a positive number, respool the N next articles.
8898 If N is a negative number, respool the N previous articles.
8899 If N is nil and any articles have been marked with the process mark,
8900 respool those articles instead.
8902 Respooling can be done both from mail groups and \"real\" newsgroups.
8903 In the former case, the articles in question will be moved from the
8904 current group into whatever groups they are destined to. In the
8905 latter case, they will be copied into the relevant groups."
8907 (list current-prefix-arg
8908 (let* ((methods (gnus-methods-using 'respool))
8910 (symbol-name (or gnus-summary-respool-default-method
8911 (car (gnus-find-method-for-group
8912 gnus-newsgroup-name)))))
8914 (gnus-completing-read-with-default
8915 methname "What backend do you want to use when respooling?"
8916 methods nil t nil 'gnus-mail-method-history))
8919 ((zerop (length (setq ms (gnus-servers-using-backend
8921 (list (intern method) ""))
8925 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8926 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8929 (error "No method given for respooling"))
8930 (if (assoc (symbol-name
8931 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8932 (gnus-methods-using 'respool))
8933 (gnus-summary-move-article n nil method)
8934 (gnus-summary-copy-article n nil method)))
8936 (defun gnus-summary-import-article (file &optional edit)
8937 "Import an arbitrary file into a mail newsgroup."
8938 (interactive "fImport file: \nP")
8939 (let ((group gnus-newsgroup-name)
8940 (now (current-time))
8941 atts lines group-art)
8942 (unless (gnus-check-backend-function 'request-accept-article group)
8943 (error "%s does not support article importing" group))
8944 (or (file-readable-p file)
8945 (not (file-regular-p file))
8946 (error "Can't read %s" file))
8948 (set-buffer (gnus-get-buffer-create " *import file*"))
8950 (nnheader-insert-file-contents file)
8951 (goto-char (point-min))
8952 (if (nnheader-article-p)
8954 (goto-char (point-min))
8955 (search-forward "\n\n" nil t)
8956 (narrow-to-region (point-min) (1- (point)))
8957 (goto-char (point-min))
8958 (unless (re-search-forward "^date:" nil t)
8959 (goto-char (point-max))
8960 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8961 ;; This doesn't look like an article, so we fudge some headers.
8962 (setq atts (file-attributes file)
8963 lines (count-lines (point-min) (point-max)))
8964 (insert "From: " (read-string "From: ") "\n"
8965 "Subject: " (read-string "Subject: ") "\n"
8966 "Date: " (message-make-date (nth 5 atts)) "\n"
8967 "Message-ID: " (message-make-message-id) "\n"
8968 "Lines: " (int-to-string lines) "\n"
8969 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8970 (setq group-art (gnus-request-accept-article group nil t))
8971 (kill-buffer (current-buffer)))
8972 (setq gnus-newsgroup-active (gnus-activate-group group))
8974 (gnus-summary-goto-article (cdr group-art) nil t)
8976 (gnus-summary-edit-article))))
8978 (defun gnus-summary-create-article ()
8979 "Create an article in a mail newsgroup."
8981 (let ((group gnus-newsgroup-name)
8982 (now (current-time))
8984 (unless (gnus-check-backend-function 'request-accept-article group)
8985 (error "%s does not support article importing" group))
8987 (set-buffer (gnus-get-buffer-create " *import file*"))
8989 (goto-char (point-min))
8990 ;; This doesn't look like an article, so we fudge some headers.
8991 (insert "From: " (read-string "From: ") "\n"
8992 "Subject: " (read-string "Subject: ") "\n"
8993 "Date: " (message-make-date now) "\n"
8994 "Message-ID: " (message-make-message-id) "\n")
8995 (setq group-art (gnus-request-accept-article group nil t))
8996 (kill-buffer (current-buffer)))
8997 (setq gnus-newsgroup-active (gnus-activate-group group))
8999 (gnus-summary-goto-article (cdr group-art) nil t)
9000 (gnus-summary-edit-article)))
9002 (defun gnus-summary-article-posted-p ()
9003 "Say whether the current (mail) article is available from news as well.
9004 This will be the case if the article has both been mailed and posted."
9006 (let ((id (mail-header-references (gnus-summary-article-header)))
9007 (gnus-override-method (car (gnus-refer-article-methods))))
9008 (if (gnus-request-head id "")
9009 (gnus-message 2 "The current message was found on %s"
9010 gnus-override-method)
9011 (gnus-message 2 "The current message couldn't be found on %s"
9012 gnus-override-method)
9015 (defun gnus-summary-expire-articles (&optional now)
9016 "Expire all articles that are marked as expirable in the current group."
9018 (when (gnus-check-backend-function
9019 'request-expire-articles gnus-newsgroup-name)
9020 ;; This backend supports expiry.
9021 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9022 (expirable (if total
9024 ;; We need to update the info for
9025 ;; this group for `gnus-list-of-read-articles'
9026 ;; to give us the right answer.
9027 (gnus-run-hooks 'gnus-exit-group-hook)
9028 (gnus-summary-update-info)
9029 (gnus-list-of-read-articles gnus-newsgroup-name))
9030 (setq gnus-newsgroup-expirable
9031 (sort gnus-newsgroup-expirable '<))))
9032 (expiry-wait (if now 'immediate
9033 (gnus-group-find-parameter
9034 gnus-newsgroup-name 'expiry-wait)))
9035 (nnmail-expiry-target
9036 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9037 nnmail-expiry-target))
9040 ;; There are expirable articles in this group, so we run them
9041 ;; through the expiry process.
9042 (gnus-message 6 "Expiring articles...")
9043 (unless (gnus-check-group gnus-newsgroup-name)
9044 (error "Can't open server for %s" gnus-newsgroup-name))
9045 ;; The list of articles that weren't expired is returned.
9048 (let ((nnmail-expiry-wait-function nil)
9049 (nnmail-expiry-wait expiry-wait))
9050 (setq es (gnus-request-expire-articles
9051 expirable gnus-newsgroup-name)))
9052 (setq es (gnus-request-expire-articles
9053 expirable gnus-newsgroup-name)))
9055 (setq gnus-newsgroup-expirable es))
9056 ;; We go through the old list of expirable, and mark all
9057 ;; really expired articles as nonexistent.
9058 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9059 (let ((gnus-use-cache nil))
9060 (dolist (article expirable)
9061 (when (and (not (memq article es))
9062 (gnus-data-find article))
9063 (gnus-summary-mark-article article gnus-canceled-mark))))))
9064 (gnus-message 6 "Expiring articles...done")))))
9066 (defun gnus-summary-expire-articles-now ()
9067 "Expunge all expirable articles in the current group.
9068 This means that *all* articles that are marked as expirable will be
9069 deleted forever, right now."
9071 (or gnus-expert-user
9073 "Are you really, really, really sure you want to delete all these messages? ")
9075 (gnus-summary-expire-articles t))
9077 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9078 (defun gnus-summary-delete-article (&optional n)
9079 "Delete the N next (mail) articles.
9080 This command actually deletes articles. This is not a marking
9081 command. The article will disappear forever from your life, never to
9083 If N is negative, delete backwards.
9084 If N is nil and articles have been marked with the process mark,
9085 delete these instead."
9087 (unless (gnus-check-backend-function 'request-expire-articles
9088 gnus-newsgroup-name)
9089 (error "The current newsgroup does not support article deletion"))
9090 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9091 (error "Couldn't open server"))
9092 ;; Compute the list of articles to delete.
9093 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9094 (nnmail-expiry-target 'delete)
9096 (if (and gnus-novice-user
9097 (not (gnus-yes-or-no-p
9098 (format "Do you really want to delete %s forever? "
9099 (if (> (length articles) 1)
9100 (format "these %s articles" (length articles))
9103 ;; Delete the articles.
9104 (setq not-deleted (gnus-request-expire-articles
9105 articles gnus-newsgroup-name 'force))
9107 (gnus-summary-remove-process-mark (car articles))
9108 ;; The backend might not have been able to delete the article
9110 (unless (memq (car articles) not-deleted)
9111 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9112 (setq articles (cdr articles)))
9114 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9115 (gnus-summary-position-point)
9116 (gnus-set-mode-line 'summary)
9119 (defun gnus-summary-edit-article (&optional arg)
9120 "Edit the current article.
9121 This will have permanent effect only in mail groups.
9122 If ARG is nil, edit the decoded articles.
9123 If ARG is 1, edit the raw articles.
9124 If ARG is 2, edit the raw articles even in read-only groups.
9125 If ARG is 3, edit the articles with the current handles.
9126 Otherwise, allow editing of articles even in read-only
9129 (let (force raw current-handles)
9138 (setq current-handles
9139 (and (gnus-buffer-live-p gnus-article-buffer)
9140 (with-current-buffer gnus-article-buffer
9142 gnus-article-mime-handles
9143 (setq gnus-article-mime-handles nil))))))
9146 (when (and raw (not force)
9147 (member gnus-newsgroup-name '("nndraft:delayed"
9150 (error "Can't edit the raw article in group %s"
9151 gnus-newsgroup-name))
9153 (set-buffer gnus-summary-buffer)
9154 (let ((mail-parse-charset gnus-newsgroup-charset)
9155 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9156 (gnus-set-global-variables)
9157 (when (and (not force)
9158 (gnus-group-read-only-p))
9159 (error "The current newsgroup does not support article editing"))
9160 (gnus-summary-show-article t)
9161 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9162 (with-current-buffer gnus-article-buffer
9163 (mm-enable-multibyte)))
9164 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9166 (gnus-article-edit-article
9169 (let ((mbl mml-buffer-list))
9170 (setq mml-buffer-list nil)
9171 (mime-to-mml ,'current-handles)
9172 (let ((mbl1 mml-buffer-list))
9173 (setq mml-buffer-list mbl)
9174 (set (make-local-variable 'mml-buffer-list) mbl1))
9175 (make-local-hook 'kill-buffer-hook)
9176 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9177 `(lambda (no-highlight)
9178 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9179 (message-options message-options)
9180 (message-options-set-recipient)
9181 (mail-parse-ignored-charsets
9182 ',gnus-newsgroup-ignored-charsets))
9183 ,(if (not raw) '(progn
9185 (mml-destroy-buffers)
9186 (remove-hook 'kill-buffer-hook
9187 'mml-destroy-buffers t)
9188 (kill-local-variable 'mml-buffer-list)))
9189 (gnus-summary-edit-article-done
9190 ,(or (mail-header-references gnus-current-headers) "")
9191 ,(gnus-group-read-only-p)
9192 ,gnus-summary-buffer no-highlight))))))))
9194 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9196 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9198 "Make edits to the current article permanent."
9201 ;; The buffer restriction contains the entire article if it exists.
9202 (when (article-goto-body)
9203 (let ((lines (count-lines (point) (point-max)))
9204 (length (- (point-max) (point)))
9205 (case-fold-search t)
9206 (body (copy-marker (point))))
9207 (goto-char (point-min))
9208 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9209 (delete-region (match-beginning 1) (match-end 1))
9210 (insert (number-to-string length)))
9211 (goto-char (point-min))
9212 (when (re-search-forward
9213 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9214 (delete-region (match-beginning 1) (match-end 1))
9215 (insert (number-to-string length)))
9216 (goto-char (point-min))
9217 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9218 (delete-region (match-beginning 1) (match-end 1))
9219 (insert (number-to-string lines))))))
9220 ;; Replace the article.
9221 (let ((buf (current-buffer)))
9223 (insert-buffer-substring buf)
9225 (if (and (not read-only)
9226 (not (gnus-request-replace-article
9227 (cdr gnus-article-current) (car gnus-article-current)
9228 (current-buffer) t)))
9229 (error "Couldn't replace article")
9230 ;; Update the summary buffer.
9232 (equal (message-tokenize-header references " ")
9233 (message-tokenize-header
9234 (or (message-fetch-field "references") "") " ")))
9235 ;; We only have to update this line.
9238 (message-narrow-to-head)
9239 (let ((head (buffer-string))
9242 (insert (format "211 %d Article retrieved.\n"
9243 (cdr gnus-article-current)))
9246 (let ((nntp-server-buffer (current-buffer)))
9247 (setq header (car (gnus-get-newsgroup-headers
9250 (set-buffer gnus-summary-buffer)
9251 (gnus-data-set-header
9252 (gnus-data-find (cdr gnus-article-current))
9254 (gnus-summary-update-article-line
9255 (cdr gnus-article-current) header)
9256 (if (gnus-summary-goto-subject
9257 (cdr gnus-article-current) nil t)
9258 (gnus-summary-update-secondary-mark
9259 (cdr gnus-article-current))))))))
9261 (set-buffer (or buffer gnus-summary-buffer))
9262 (gnus-summary-update-article (cdr gnus-article-current))
9263 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9264 (gnus-summary-update-secondary-mark
9265 (cdr gnus-article-current))))
9266 ;; Prettify the article buffer again.
9267 (unless no-highlight
9269 (set-buffer gnus-article-buffer)
9270 ;;;!!! Fix this -- article should be rehighlighted.
9271 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9272 (set-buffer gnus-original-article-buffer)
9273 (gnus-request-article
9274 (cdr gnus-article-current)
9275 (car gnus-article-current) (current-buffer))))
9276 ;; Prettify the summary buffer line.
9277 (when (gnus-visual-p 'summary-highlight 'highlight)
9278 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9280 (defun gnus-summary-edit-wash (key)
9281 "Perform editing command KEY in the article buffer."
9285 (message "%s" (concat (this-command-keys) "- "))
9288 (gnus-summary-edit-article)
9289 (execute-kbd-macro (concat (this-command-keys) key))
9290 (gnus-article-edit-done))
9294 (defun gnus-summary-respool-query (&optional silent trace)
9295 "Query where the respool algorithm would put this article."
9297 (let (gnus-mark-article-hook)
9298 (gnus-summary-select-article)
9300 (set-buffer gnus-original-article-buffer)
9302 (message-narrow-to-head)
9303 (let ((groups (nnmail-article-group 'identity trace)))
9306 (message "This message would go to %s"
9307 (mapconcat 'car groups ", "))
9308 (message "This message would go to no groups"))
9311 (defun gnus-summary-respool-trace ()
9312 "Trace where the respool algorithm would put this article.
9313 Display a buffer showing all fancy splitting patterns which matched."
9315 (gnus-summary-respool-query nil t))
9317 ;; Summary marking commands.
9319 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9320 "Mark articles which has the same subject as read, and then select the next.
9321 If UNMARK is positive, remove any kind of mark.
9322 If UNMARK is negative, tick articles."
9325 (setq unmark (prefix-numeric-value unmark)))
9327 (gnus-summary-mark-same-subject
9328 (gnus-summary-article-subject) unmark)))
9329 ;; Select next unread article. If auto-select-same mode, should
9330 ;; select the first unread article.
9331 (gnus-summary-next-article t (and gnus-auto-select-same
9332 (gnus-summary-article-subject)))
9333 (gnus-message 7 "%d article%s marked as %s"
9334 count (if (= count 1) " is" "s are")
9335 (if unmark "unread" "read"))))
9337 (defun gnus-summary-kill-same-subject (&optional unmark)
9338 "Mark articles which has the same subject as read.
9339 If UNMARK is positive, remove any kind of mark.
9340 If UNMARK is negative, tick articles."
9343 (setq unmark (prefix-numeric-value unmark)))
9345 (gnus-summary-mark-same-subject
9346 (gnus-summary-article-subject) unmark)))
9347 ;; If marked as read, go to next unread subject.
9349 ;; Go to next unread subject.
9350 (gnus-summary-next-subject 1 t))
9351 (gnus-message 7 "%d articles are marked as %s"
9352 count (if unmark "unread" "read"))))
9354 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9355 "Mark articles with same SUBJECT as read, and return marked number.
9356 If optional argument UNMARK is positive, remove any kinds of marks.
9357 If optional argument UNMARK is negative, mark articles as unread instead."
9361 ((null unmark) ; Mark as read.
9364 (gnus-summary-mark-article-as-read gnus-killed-mark)
9365 (gnus-summary-show-thread) t)
9366 (gnus-summary-find-subject subject))
9367 (setq count (1+ count))))
9368 ((> unmark 0) ; Tick.
9371 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9372 (gnus-summary-show-thread) t)
9373 (gnus-summary-find-subject subject))
9374 (setq count (1+ count))))
9375 (t ; Mark as unread.
9378 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9379 (gnus-summary-show-thread) t)
9380 (gnus-summary-find-subject subject))
9381 (setq count (1+ count)))))
9382 (gnus-set-mode-line 'summary)
9383 ;; Return the number of marked articles.
9386 (defun gnus-summary-mark-as-processable (n &optional unmark)
9387 "Set the process mark on the next N articles.
9388 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9389 the process mark instead. The difference between N and the actual
9390 number of articles marked is returned."
9392 (if (and (null n) (gnus-region-active-p))
9393 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9394 (setq n (prefix-numeric-value n))
9395 (let ((backward (< n 0))
9400 (gnus-summary-remove-process-mark
9401 (gnus-summary-article-number))
9402 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9403 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9406 (gnus-message 7 "No more articles"))
9407 (gnus-summary-recenter)
9408 (gnus-summary-position-point)
9411 (defun gnus-summary-unmark-as-processable (n)
9412 "Remove the process mark from the next N articles.
9413 If N is negative, unmark backward instead. The difference between N and
9414 the actual number of articles unmarked is returned."
9416 (gnus-summary-mark-as-processable n t))
9418 (defun gnus-summary-unmark-all-processable ()
9419 "Remove the process mark from all articles."
9422 (while gnus-newsgroup-processable
9423 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9424 (gnus-summary-position-point))
9426 (defun gnus-summary-add-mark (article type)
9427 "Mark ARTICLE with a mark of TYPE."
9428 (let ((vtype (car (assq type gnus-article-mark-lists)))
9431 (error "No such mark type: %s" type)
9432 (setq var (intern (format "gnus-newsgroup-%s" type)))
9433 (set var (cons article (symbol-value var)))
9434 (if (memq type '(processable cached replied forwarded recent saved))
9435 (gnus-summary-update-secondary-mark article)
9436 ;;; !!! This is bogus. We should find out what primary
9437 ;;; !!! mark we want to set.
9438 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9440 (defun gnus-summary-mark-as-expirable (n)
9441 "Mark N articles forward as expirable.
9442 If N is negative, mark backward instead. The difference between N and
9443 the actual number of articles marked is returned."
9445 (gnus-summary-mark-forward n gnus-expirable-mark))
9447 (defun gnus-summary-mark-as-spam (n)
9448 "Mark N articles forward as spam.
9449 If N is negative, mark backward instead. The difference between N and
9450 the actual number of articles marked is returned."
9452 (gnus-summary-mark-forward n gnus-spam-mark))
9454 (defun gnus-summary-mark-article-as-replied (article)
9455 "Mark ARTICLE as replied to and update the summary line.
9456 ARTICLE can also be a list of articles."
9457 (interactive (list (gnus-summary-article-number)))
9458 (let ((articles (if (listp article) article (list article))))
9459 (dolist (article articles)
9460 (unless (numberp article)
9461 (error "%s is not a number" article))
9462 (push article gnus-newsgroup-replied)
9463 (let ((buffer-read-only nil))
9464 (when (gnus-summary-goto-subject article nil t)
9465 (gnus-summary-update-secondary-mark article))))))
9467 (defun gnus-summary-mark-article-as-forwarded (article)
9468 "Mark ARTICLE as forwarded and update the summary line.
9469 ARTICLE can also be a list of articles."
9470 (let ((articles (if (listp article) article (list article))))
9471 (dolist (article articles)
9472 (push article gnus-newsgroup-forwarded)
9473 (let ((buffer-read-only nil))
9474 (when (gnus-summary-goto-subject article nil t)
9475 (gnus-summary-update-secondary-mark article))))))
9477 (defun gnus-summary-set-bookmark (article)
9478 "Set a bookmark in current article."
9479 (interactive (list (gnus-summary-article-number)))
9480 (when (or (not (get-buffer gnus-article-buffer))
9481 (not gnus-current-article)
9482 (not gnus-article-current)
9483 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9484 (error "No current article selected"))
9485 ;; Remove old bookmark, if one exists.
9486 (gnus-pull article gnus-newsgroup-bookmarks)
9487 ;; Set the new bookmark, which is on the form
9488 ;; (article-number . line-number-in-body).
9492 (set-buffer gnus-article-buffer)
9499 gnus-newsgroup-bookmarks)
9500 (gnus-message 6 "A bookmark has been added to the current article."))
9502 (defun gnus-summary-remove-bookmark (article)
9503 "Remove the bookmark from the current article."
9504 (interactive (list (gnus-summary-article-number)))
9505 ;; Remove old bookmark, if one exists.
9506 (if (not (assq article gnus-newsgroup-bookmarks))
9507 (gnus-message 6 "No bookmark in current article.")
9508 (gnus-pull article gnus-newsgroup-bookmarks)
9509 (gnus-message 6 "Removed bookmark.")))
9511 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9512 (defun gnus-summary-mark-as-dormant (n)
9513 "Mark N articles forward as dormant.
9514 If N is negative, mark backward instead. The difference between N and
9515 the actual number of articles marked is returned."
9517 (gnus-summary-mark-forward n gnus-dormant-mark))
9519 (defun gnus-summary-set-process-mark (article)
9520 "Set the process mark on ARTICLE and update the summary line."
9521 (setq gnus-newsgroup-processable
9523 (delq article gnus-newsgroup-processable)))
9524 (when (gnus-summary-goto-subject article)
9525 (gnus-summary-show-thread)
9526 (gnus-summary-goto-subject article)
9527 (gnus-summary-update-secondary-mark article)))
9529 (defun gnus-summary-remove-process-mark (article)
9530 "Remove the process mark from ARTICLE and update the summary line."
9531 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9532 (when (gnus-summary-goto-subject article)
9533 (gnus-summary-show-thread)
9534 (gnus-summary-goto-subject article)
9535 (gnus-summary-update-secondary-mark article)))
9537 (defun gnus-summary-set-saved-mark (article)
9538 "Set the process mark on ARTICLE and update the summary line."
9539 (push article gnus-newsgroup-saved)
9540 (when (gnus-summary-goto-subject article)
9541 (gnus-summary-update-secondary-mark article)))
9543 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9544 "Mark N articles as read forwards.
9545 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9546 The difference between N and the actual number of articles marked is
9548 If NO-EXPIRE, auto-expiry will be inhibited."
9550 (gnus-summary-show-thread)
9551 (let ((backward (< n 0))
9552 (gnus-summary-goto-unread
9553 (and gnus-summary-goto-unread
9554 (not (eq gnus-summary-goto-unread 'never))
9555 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9556 gnus-ticked-mark gnus-dormant-mark)))))
9558 (mark (or mark gnus-del-mark)))
9560 (gnus-summary-mark-article nil mark no-expire)
9561 (zerop (gnus-summary-next-subject
9563 (and gnus-summary-goto-unread
9564 (not (eq gnus-summary-goto-unread 'never)))
9568 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9569 (gnus-summary-recenter)
9570 (gnus-summary-position-point)
9571 (gnus-set-mode-line 'summary)
9574 (defun gnus-summary-mark-article-as-read (mark)
9575 "Mark the current article quickly as read with MARK."
9576 (let ((article (gnus-summary-article-number)))
9577 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9578 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9579 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9580 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9581 (push (cons article mark) gnus-newsgroup-reads)
9582 ;; Possibly remove from cache, if that is used.
9583 (when gnus-use-cache
9584 (gnus-cache-enter-remove-article article))
9585 ;; Allow the backend to change the mark.
9586 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9587 ;; Check for auto-expiry.
9588 (when (and gnus-newsgroup-auto-expire
9589 (memq mark gnus-auto-expirable-marks))
9590 (setq mark gnus-expirable-mark)
9591 ;; Let the backend know about the mark change.
9592 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9593 (push article gnus-newsgroup-expirable))
9594 ;; Set the mark in the buffer.
9595 (gnus-summary-update-mark mark 'unread)
9598 (defun gnus-summary-mark-article-as-unread (mark)
9599 "Mark the current article quickly as unread with MARK."
9600 (let* ((article (gnus-summary-article-number))
9601 (old-mark (gnus-summary-article-mark article)))
9602 ;; Allow the backend to change the mark.
9603 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9604 (if (eq mark old-mark)
9608 (gnus-error 1 "Can't mark negative article numbers")
9610 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9611 (setq gnus-newsgroup-spam-marked
9612 (delq article gnus-newsgroup-spam-marked))
9613 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9614 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9615 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9616 (cond ((= mark gnus-ticked-mark)
9617 (setq gnus-newsgroup-marked
9618 (gnus-add-to-sorted-list gnus-newsgroup-marked
9620 ((= mark gnus-spam-mark)
9621 (setq gnus-newsgroup-spam-marked
9622 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9624 ((= mark gnus-dormant-mark)
9625 (setq gnus-newsgroup-dormant
9626 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9629 (setq gnus-newsgroup-unreads
9630 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9632 (gnus-pull article gnus-newsgroup-reads)
9634 ;; See whether the article is to be put in the cache.
9636 (vectorp (gnus-summary-article-header article))
9638 (gnus-cache-possibly-enter-article
9639 gnus-newsgroup-name article
9640 (= mark gnus-ticked-mark)
9641 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9644 (gnus-summary-update-mark mark 'unread)
9647 (defun gnus-summary-mark-article (&optional article mark no-expire)
9648 "Mark ARTICLE with MARK. MARK can be any character.
9649 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9650 `??' (dormant) and `?E' (expirable).
9651 If MARK is nil, then the default character `?r' is used.
9652 If ARTICLE is nil, then the article on the current line will be
9654 If NO-EXPIRE, auto-expiry will be inhibited."
9655 ;; The mark might be a string.
9656 (when (stringp mark)
9657 (setq mark (aref mark 0)))
9658 ;; If no mark is given, then we check auto-expiring.
9660 (setq mark gnus-del-mark))
9661 (when (and (not no-expire)
9662 gnus-newsgroup-auto-expire
9663 (memq mark gnus-auto-expirable-marks))
9664 (setq mark gnus-expirable-mark))
9665 (let ((article (or article (gnus-summary-article-number)))
9666 (old-mark (gnus-summary-article-mark article)))
9667 ;; Allow the backend to change the mark.
9668 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9669 (if (eq mark old-mark)
9672 (error "No article on current line"))
9673 (if (not (if (or (= mark gnus-unread-mark)
9674 (= mark gnus-ticked-mark)
9675 (= mark gnus-spam-mark)
9676 (= mark gnus-dormant-mark))
9677 (gnus-mark-article-as-unread article mark)
9678 (gnus-mark-article-as-read article mark)))
9680 ;; See whether the article is to be put in the cache.
9682 (not (= mark gnus-canceled-mark))
9683 (vectorp (gnus-summary-article-header article))
9685 (gnus-cache-possibly-enter-article
9686 gnus-newsgroup-name article
9687 (= mark gnus-ticked-mark)
9688 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9690 (when (gnus-summary-goto-subject article nil t)
9691 (let ((buffer-read-only nil))
9692 (gnus-summary-show-thread)
9694 (gnus-summary-update-mark mark 'unread)
9697 (defun gnus-summary-update-secondary-mark (article)
9698 "Update the secondary (read, process, cache) mark."
9699 (gnus-summary-update-mark
9700 (cond ((memq article gnus-newsgroup-processable)
9702 ((memq article gnus-newsgroup-cached)
9704 ((memq article gnus-newsgroup-replied)
9706 ((memq article gnus-newsgroup-forwarded)
9707 gnus-forwarded-mark)
9708 ((memq article gnus-newsgroup-saved)
9710 ((memq article gnus-newsgroup-recent)
9712 ((memq article gnus-newsgroup-unseen)
9716 (when (gnus-visual-p 'summary-highlight 'highlight)
9717 (gnus-run-hooks 'gnus-summary-update-hook))
9720 (defun gnus-summary-update-download-mark (article)
9721 "Update the secondary (read, process, cache) mark."
9722 (gnus-summary-update-mark
9723 (cond ((memq article gnus-newsgroup-undownloaded)
9724 gnus-undownloaded-mark)
9725 (gnus-newsgroup-agentized
9726 gnus-downloaded-mark)
9730 (gnus-summary-update-line t)
9733 (defun gnus-summary-update-mark (mark type)
9734 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9735 (buffer-read-only nil))
9736 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9738 (when (looking-at "\r")
9740 (when (<= (+ forward (point)) (point-max))
9741 ;; Go to the right position on the line.
9742 (goto-char (+ forward (point)))
9743 ;; Replace the old mark with the new mark.
9744 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9745 ;; Optionally update the marks by some user rule.
9746 (when (eq type 'unread)
9748 (gnus-data-find (gnus-summary-article-number)) mark)
9749 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9751 (defun gnus-mark-article-as-read (article &optional mark)
9752 "Enter ARTICLE in the pertinent lists and remove it from others."
9753 ;; Make the article expirable.
9754 (let ((mark (or mark gnus-del-mark)))
9755 (setq gnus-newsgroup-expirable
9756 (if (= mark gnus-expirable-mark)
9757 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9758 (delq article gnus-newsgroup-expirable)))
9759 ;; Remove from unread and marked lists.
9760 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9761 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9762 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9763 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9764 (push (cons article mark) gnus-newsgroup-reads)
9765 ;; Possibly remove from cache, if that is used.
9766 (when gnus-use-cache
9767 (gnus-cache-enter-remove-article article))
9770 (defun gnus-mark-article-as-unread (article &optional mark)
9771 "Enter ARTICLE in the pertinent lists and remove it from others."
9772 (let ((mark (or mark gnus-ticked-mark)))
9775 (gnus-error 1 "Can't mark negative article numbers")
9777 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9778 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9779 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9780 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9781 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9783 ;; Unsuppress duplicates?
9784 (when gnus-suppress-duplicates
9785 (gnus-dup-unsuppress-article article))
9787 (cond ((= mark gnus-ticked-mark)
9788 (setq gnus-newsgroup-marked
9789 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9790 ((= mark gnus-spam-mark)
9791 (setq gnus-newsgroup-spam-marked
9792 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9794 ((= mark gnus-dormant-mark)
9795 (setq gnus-newsgroup-dormant
9796 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9798 (setq gnus-newsgroup-unreads
9799 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9800 (gnus-pull article gnus-newsgroup-reads)
9803 (defalias 'gnus-summary-mark-as-unread-forward
9804 'gnus-summary-tick-article-forward)
9805 (make-obsolete 'gnus-summary-mark-as-unread-forward
9806 'gnus-summary-tick-article-forward)
9807 (defun gnus-summary-tick-article-forward (n)
9808 "Tick N articles forwards.
9809 If N is negative, tick backwards instead.
9810 The difference between N and the number of articles ticked is returned."
9812 (gnus-summary-mark-forward n gnus-ticked-mark))
9814 (defalias 'gnus-summary-mark-as-unread-backward
9815 'gnus-summary-tick-article-backward)
9816 (make-obsolete 'gnus-summary-mark-as-unread-backward
9817 'gnus-summary-tick-article-backward)
9818 (defun gnus-summary-tick-article-backward (n)
9819 "Tick N articles backwards.
9820 The difference between N and the number of articles ticked is returned."
9822 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9824 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9825 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9826 (defun gnus-summary-tick-article (&optional article clear-mark)
9827 "Mark current article as unread.
9828 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9829 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9831 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9834 (defun gnus-summary-mark-as-read-forward (n)
9835 "Mark N articles as read forwards.
9836 If N is negative, mark backwards instead.
9837 The difference between N and the actual number of articles marked is
9840 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9842 (defun gnus-summary-mark-as-read-backward (n)
9843 "Mark the N articles as read backwards.
9844 The difference between N and the actual number of articles marked is
9847 (gnus-summary-mark-forward
9848 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9850 (defun gnus-summary-mark-as-read (&optional article mark)
9851 "Mark current article as read.
9852 ARTICLE specifies the article to be marked as read.
9853 MARK specifies a string to be inserted at the beginning of the line."
9854 (gnus-summary-mark-article article mark))
9856 (defun gnus-summary-clear-mark-forward (n)
9857 "Clear marks from N articles forward.
9858 If N is negative, clear backward instead.
9859 The difference between N and the number of marks cleared is returned."
9861 (gnus-summary-mark-forward n gnus-unread-mark))
9863 (defun gnus-summary-clear-mark-backward (n)
9864 "Clear marks from N articles backward.
9865 The difference between N and the number of marks cleared is returned."
9867 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9869 (defun gnus-summary-mark-unread-as-read ()
9870 "Intended to be used by `gnus-summary-mark-article-hook'."
9871 (when (memq gnus-current-article gnus-newsgroup-unreads)
9872 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9874 (defun gnus-summary-mark-read-and-unread-as-read ()
9875 "Intended to be used by `gnus-summary-mark-article-hook'."
9876 (let ((mark (gnus-summary-article-mark)))
9877 (when (or (gnus-unread-mark-p mark)
9878 (gnus-read-mark-p mark))
9879 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9881 (defun gnus-summary-mark-unread-as-ticked ()
9882 "Intended to be used by `gnus-summary-mark-article-hook'."
9883 (when (memq gnus-current-article gnus-newsgroup-unreads)
9884 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9886 (defun gnus-summary-mark-region-as-read (point mark all)
9887 "Mark all unread articles between point and mark as read.
9888 If given a prefix, mark all articles between point and mark as read,
9889 even ticked and dormant ones."
9890 (interactive "r\nP")
9899 (memq (setq article (gnus-summary-article-number))
9900 gnus-newsgroup-unreads))
9901 (gnus-summary-mark-article article gnus-del-mark))
9903 (gnus-summary-find-next))))))
9905 (defun gnus-summary-mark-below (score mark)
9906 "Mark articles with score less than SCORE with MARK."
9907 (interactive "P\ncMark: ")
9908 (setq score (if score
9909 (prefix-numeric-value score)
9910 (or gnus-summary-default-score 0)))
9912 (set-buffer gnus-summary-buffer)
9913 (goto-char (point-min))
9916 (and (< (gnus-summary-article-score) score)
9917 (gnus-summary-mark-article nil mark))
9918 (gnus-summary-find-next)))))
9920 (defun gnus-summary-kill-below (&optional score)
9921 "Mark articles with score below SCORE as read."
9923 (gnus-summary-mark-below score gnus-killed-mark))
9925 (defun gnus-summary-clear-above (&optional score)
9926 "Clear all marks from articles with score above SCORE."
9928 (gnus-summary-mark-above score gnus-unread-mark))
9930 (defun gnus-summary-tick-above (&optional score)
9931 "Tick all articles with score above SCORE."
9933 (gnus-summary-mark-above score gnus-ticked-mark))
9935 (defun gnus-summary-mark-above (score mark)
9936 "Mark articles with score over SCORE with MARK."
9937 (interactive "P\ncMark: ")
9938 (setq score (if score
9939 (prefix-numeric-value score)
9940 (or gnus-summary-default-score 0)))
9942 (set-buffer gnus-summary-buffer)
9943 (goto-char (point-min))
9945 (when (> (gnus-summary-article-score) score)
9946 (gnus-summary-mark-article nil mark))
9948 (gnus-summary-find-next)))))
9950 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9951 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9952 (defun gnus-summary-limit-include-expunged (&optional no-error)
9953 "Display all the hidden articles that were expunged for low scores."
9955 (let ((buffer-read-only nil))
9956 (let ((scored gnus-newsgroup-scored)
9959 (unless (gnus-summary-article-header (caar scored))
9960 (and (setq h (gnus-number-to-header (caar scored)))
9961 (< (cdar scored) gnus-summary-expunge-below)
9963 (setq scored (cdr scored)))
9965 (when (not no-error)
9966 (error "No expunged articles hidden"))
9967 (goto-char (point-min))
9968 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9969 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9970 (mapcar (lambda (x) (push (mail-header-number x)
9971 gnus-newsgroup-limit))
9973 (gnus-summary-prepare-unthreaded (nreverse headers))
9974 (goto-char (point-min))
9975 (gnus-summary-position-point)
9978 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9979 "Mark all unread articles in this newsgroup as read.
9980 If prefix argument ALL is non-nil, ticked and dormant articles will
9981 also be marked as read.
9982 If QUIETLY is non-nil, no questions will be asked.
9983 If TO-HERE is non-nil, it should be a point in the buffer. All
9984 articles before (after, if REVERSE is set) this point will be marked as read.
9985 Note that this function will only catch up the unread article
9986 in the current summary buffer limitation.
9987 The number of articles marked as read is returned."
9992 (not gnus-interactive-catchup) ;Without confirmation?
9996 "Mark absolutely all articles as read? "
9997 "Mark all unread articles as read? ")))
9999 (not gnus-newsgroup-adaptive)
10000 (not gnus-newsgroup-auto-expire)
10001 (not gnus-suppress-duplicates)
10002 (or (not gnus-use-cache)
10003 (eq gnus-use-cache 'passive)))
10006 (setq gnus-newsgroup-marked nil
10007 gnus-newsgroup-spam-marked nil
10008 gnus-newsgroup-dormant nil))
10009 (setq gnus-newsgroup-unreads
10010 (gnus-sorted-nunion
10011 (gnus-intersection gnus-newsgroup-unreads
10012 gnus-newsgroup-downloadable)
10013 gnus-newsgroup-unfetched)))
10014 ;; We actually mark all articles as canceled, which we
10015 ;; have to do when using auto-expiry or adaptive scoring.
10016 (gnus-summary-show-all-threads)
10017 (if (and to-here reverse)
10019 (goto-char to-here)
10021 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10022 (gnus-summary-find-next (not all)))))
10023 (when (gnus-summary-first-subject (not all))
10025 (if to-here (< (point) to-here) t)
10026 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10027 (gnus-summary-find-next (not all))))))
10028 (gnus-set-mode-line 'summary))
10030 (gnus-summary-position-point)))
10032 (defun gnus-summary-catchup-to-here (&optional all)
10033 "Mark all unticked articles before the current one as read.
10034 If ALL is non-nil, also mark ticked and dormant articles as read."
10037 (gnus-save-hidden-threads
10038 (let ((beg (point)))
10039 ;; We check that there are unread articles.
10040 (when (or all (gnus-summary-find-prev))
10041 (gnus-summary-catchup all t beg)))))
10042 (gnus-summary-position-point))
10044 (defun gnus-summary-catchup-from-here (&optional all)
10045 "Mark all unticked articles after the current one as read.
10046 If ALL is non-nil, also mark ticked and dormant articles as read."
10049 (gnus-save-hidden-threads
10050 (let ((beg (point)))
10051 ;; We check that there are unread articles.
10052 (when (or all (gnus-summary-find-next))
10053 (gnus-summary-catchup all t beg nil t)))))
10055 (gnus-summary-position-point))
10056 (defun gnus-summary-catchup-all (&optional quietly)
10057 "Mark all articles in this newsgroup as read.
10058 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10059 instead, which marks only unread articles as read."
10061 (gnus-summary-catchup t quietly))
10063 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10064 "Mark all unread articles in this group as read, then exit.
10065 If prefix argument ALL is non-nil, all articles are marked as read.
10066 If QUIETLY is non-nil, no questions will be asked."
10068 (when (gnus-summary-catchup all quietly nil 'fast)
10069 ;; Select next newsgroup or exit.
10070 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10071 (eq gnus-auto-select-next 'quietly))
10072 (gnus-summary-next-group nil)
10073 (gnus-summary-exit))))
10075 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10076 "Mark all articles in this newsgroup as read, and then exit.
10077 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10078 instead, which marks only unread articles as read."
10080 (gnus-summary-catchup-and-exit t quietly))
10082 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10083 "Mark all articles in this group as read and select the next group.
10084 If given a prefix, mark all articles, unread as well as ticked, as
10088 (gnus-summary-catchup all))
10089 (gnus-summary-next-group))
10095 (defmacro gnus-with-article (article &rest forms)
10096 "Select ARTICLE and perform FORMS in the original article buffer.
10097 Then replace the article with the result."
10099 ;; We don't want the article to be marked as read.
10100 (let (gnus-mark-article-hook)
10101 (gnus-summary-select-article t t nil ,article))
10102 (set-buffer gnus-original-article-buffer)
10104 (if (not (gnus-check-backend-function
10105 'request-replace-article (car gnus-article-current)))
10106 (gnus-message 5 "Read-only group; not replacing")
10107 (unless (gnus-request-replace-article
10108 ,article (car gnus-article-current)
10109 (current-buffer) t)
10110 (error "Couldn't replace article")))
10111 ;; The cache and backlog have to be flushed somewhat.
10112 (when gnus-keep-backlog
10113 (gnus-backlog-remove-article
10114 (car gnus-article-current) (cdr gnus-article-current)))
10115 (when gnus-use-cache
10116 (gnus-cache-update-article
10117 (car gnus-article-current) (cdr gnus-article-current)))))
10119 (put 'gnus-with-article 'lisp-indent-function 1)
10120 (put 'gnus-with-article 'edebug-form-spec '(form body))
10122 ;; Thread-based commands.
10124 (defun gnus-summary-articles-in-thread (&optional article)
10125 "Return a list of all articles in the current thread.
10126 If ARTICLE is non-nil, return all articles in the thread that starts
10127 with that article."
10128 (let* ((article (or article (gnus-summary-article-number)))
10129 (data (gnus-data-find-list article))
10130 (top-level (gnus-data-level (car data)))
10132 (cond ((null gnus-thread-operation-ignore-subject)
10133 (gnus-simplify-subject-re
10134 (mail-header-subject (gnus-data-header (car data)))))
10135 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10136 (gnus-simplify-subject-fuzzy
10137 (mail-header-subject (gnus-data-header (car data)))))
10139 (end-point (save-excursion
10140 (if (gnus-summary-go-to-next-thread)
10141 (point) (point-max))))
10144 (< (gnus-data-pos (car data)) end-point))
10145 (when (or (not top-subject)
10146 (string= top-subject
10147 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10148 (gnus-simplify-subject-fuzzy
10149 (mail-header-subject
10150 (gnus-data-header (car data))))
10151 (gnus-simplify-subject-re
10152 (mail-header-subject
10153 (gnus-data-header (car data)))))))
10154 (push (gnus-data-number (car data)) articles))
10155 (unless (and (setq data (cdr data))
10156 (> (gnus-data-level (car data)) top-level))
10158 ;; Return the list of articles.
10159 (nreverse articles)))
10161 (defun gnus-summary-rethread-current ()
10162 "Rethread the thread the current article is part of."
10164 (let* ((gnus-show-threads t)
10165 (article (gnus-summary-article-number))
10166 (id (mail-header-id (gnus-summary-article-header)))
10167 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10169 (error "No article on the current line"))
10170 (gnus-rebuild-thread id)
10171 (gnus-summary-goto-subject article)))
10173 (defun gnus-summary-reparent-thread ()
10174 "Make the current article child of the marked (or previous) article.
10176 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10177 is non-nil or the Subject: of both articles are the same."
10179 (unless (not (gnus-group-read-only-p))
10180 (error "The current newsgroup does not support article editing"))
10181 (unless (<= (length gnus-newsgroup-processable) 1)
10182 (error "No more than one article may be marked"))
10183 (save-window-excursion
10184 (let ((gnus-article-buffer " *reparent*")
10185 (current-article (gnus-summary-article-number))
10186 ;; First grab the marked article, otherwise one line up.
10187 (parent-article (if (not (null gnus-newsgroup-processable))
10188 (car gnus-newsgroup-processable)
10190 (if (eq (forward-line -1) 0)
10191 (gnus-summary-article-number)
10192 (error "Beginning of summary buffer"))))))
10193 (unless (not (eq current-article parent-article))
10194 (error "An article may not be self-referential"))
10195 (let ((message-id (mail-header-id
10196 (gnus-summary-article-header parent-article))))
10197 (unless (and message-id (not (equal message-id "")))
10198 (error "No message-id in desired parent"))
10199 (gnus-with-article current-article
10201 (goto-char (point-min))
10202 (message-narrow-to-head)
10203 (if (re-search-forward "^References: " nil t)
10205 (re-search-forward "^[^ \t]" nil t)
10208 (insert " " message-id))
10209 (insert "References: " message-id "\n"))))
10210 (set-buffer gnus-summary-buffer)
10211 (gnus-summary-unmark-all-processable)
10212 (gnus-summary-update-article current-article)
10213 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10214 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10215 (gnus-summary-rethread-current)
10216 (gnus-message 3 "Article %d is now the child of article %d"
10217 current-article parent-article)))))
10219 (defun gnus-summary-toggle-threads (&optional arg)
10220 "Toggle showing conversation threads.
10221 If ARG is positive number, turn showing conversation threads on."
10223 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10224 (setq gnus-show-threads
10225 (if (null arg) (not gnus-show-threads)
10226 (> (prefix-numeric-value arg) 0)))
10227 (gnus-summary-prepare)
10228 (gnus-summary-goto-subject current)
10229 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10230 (gnus-summary-position-point)))
10232 (defun gnus-summary-show-all-threads ()
10233 "Show all threads."
10236 (let ((buffer-read-only nil))
10237 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10238 (gnus-summary-position-point))
10240 (defun gnus-summary-show-thread ()
10241 "Show thread subtrees.
10242 Returns nil if no thread was there to be shown."
10244 (let ((buffer-read-only nil)
10246 ;; first goto end then to beg, to have point at beg after let
10247 (end (progn (end-of-line) (point)))
10248 (beg (progn (beginning-of-line) (point))))
10250 ;; Any hidden lines here?
10251 (search-forward "\r" end t)
10252 (subst-char-in-region beg end ?\^M ?\n t)
10254 (gnus-summary-position-point))))
10256 (defun gnus-summary-maybe-hide-threads ()
10257 "If requested, hide the threads that should be hidden."
10258 (when (and gnus-show-threads
10259 gnus-thread-hide-subtree)
10260 (gnus-summary-hide-all-threads
10261 (if (or (consp gnus-thread-hide-subtree)
10262 (gnus-functionp gnus-thread-hide-subtree))
10263 (gnus-make-predicate gnus-thread-hide-subtree)
10266 ;;; Hiding predicates.
10268 (defun gnus-article-unread-p (header)
10269 (memq (mail-header-number header) gnus-newsgroup-unreads))
10271 (defun gnus-article-unseen-p (header)
10272 (memq (mail-header-number header) gnus-newsgroup-unseen))
10274 (defun gnus-map-articles (predicate articles)
10275 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10276 (apply 'gnus-or (mapcar predicate
10277 (mapcar 'gnus-summary-article-header articles))))
10279 (defun gnus-summary-hide-all-threads (&optional predicate)
10280 "Hide all thread subtrees.
10281 If PREDICATE is supplied, threads that satisfy this predicate
10282 will not be hidden."
10285 (goto-char (point-min))
10288 (when (or (not predicate)
10290 predicate (gnus-summary-article-children)))
10291 (gnus-summary-hide-thread))
10292 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10293 (gnus-summary-position-point))
10295 (defun gnus-summary-hide-thread ()
10296 "Hide thread subtrees.
10297 If PREDICATE is supplied, threads that satisfy this predicate
10298 will not be hidden.
10299 Returns nil if no threads were there to be hidden."
10301 (let ((buffer-read-only nil)
10303 (article (gnus-summary-article-number)))
10305 ;; Go forward until either the buffer ends or the subthread
10307 (when (and (not (eobp))
10308 (or (zerop (gnus-summary-next-thread 1 t))
10309 (goto-char (point-max))))
10311 (if (and (> (point) start)
10312 (search-backward "\n" start t))
10314 (subst-char-in-region start (point) ?\n ?\^M)
10315 (gnus-summary-goto-subject article))
10319 (defun gnus-summary-go-to-next-thread (&optional previous)
10320 "Go to the same level (or less) next thread.
10321 If PREVIOUS is non-nil, go to previous thread instead.
10322 Return the article number moved to, or nil if moving was impossible."
10323 (let ((level (gnus-summary-thread-level))
10324 (way (if previous -1 1))
10327 (while (and (not (eobp))
10328 (< level (gnus-summary-thread-level)))
10329 (forward-line way))
10336 (gnus-summary-article-number)
10337 (goto-char beg)))))
10339 (defun gnus-summary-next-thread (n &optional silent)
10340 "Go to the same level next N'th thread.
10341 If N is negative, search backward instead.
10342 Returns the difference between N and the number of skips actually
10345 If SILENT, don't output messages."
10347 (let ((backward (< n 0))
10349 (while (and (> n 0)
10350 (gnus-summary-go-to-next-thread backward))
10353 (gnus-summary-position-point))
10354 (when (and (not silent) (/= 0 n))
10355 (gnus-message 7 "No more threads"))
10358 (defun gnus-summary-prev-thread (n)
10359 "Go to the same level previous N'th thread.
10360 Returns the difference between N and the number of skips actually
10363 (gnus-summary-next-thread (- n)))
10365 (defun gnus-summary-go-down-thread ()
10366 "Go down one level in the current thread."
10367 (let ((children (gnus-summary-article-children)))
10369 (gnus-summary-goto-subject (car children)))))
10371 (defun gnus-summary-go-up-thread ()
10372 "Go up one level in the current thread."
10373 (let ((parent (gnus-summary-article-parent)))
10375 (gnus-summary-goto-subject parent))))
10377 (defun gnus-summary-down-thread (n)
10378 "Go down thread N steps.
10379 If N is negative, go up instead.
10380 Returns the difference between N and how many steps down that were
10385 (while (and (> n 0)
10386 (if up (gnus-summary-go-up-thread)
10387 (gnus-summary-go-down-thread)))
10389 (gnus-summary-position-point)
10391 (gnus-message 7 "Can't go further"))
10394 (defun gnus-summary-up-thread (n)
10395 "Go up thread N steps.
10396 If N is negative, go down instead.
10397 Returns the difference between N and how many steps down that were
10400 (gnus-summary-down-thread (- n)))
10402 (defun gnus-summary-top-thread ()
10403 "Go to the top of the thread."
10405 (while (gnus-summary-go-up-thread))
10406 (gnus-summary-article-number))
10408 (defun gnus-summary-kill-thread (&optional unmark)
10409 "Mark articles under current thread as read.
10410 If the prefix argument is positive, remove any kinds of marks.
10411 If the prefix argument is negative, tick articles instead."
10414 (setq unmark (prefix-numeric-value unmark)))
10415 (let ((articles (gnus-summary-articles-in-thread)))
10417 ;; Expand the thread.
10418 (gnus-summary-show-thread)
10419 ;; Mark all the articles.
10421 (gnus-summary-goto-subject (car articles))
10422 (cond ((null unmark)
10423 (gnus-summary-mark-article-as-read gnus-killed-mark))
10425 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10427 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10428 (setq articles (cdr articles))))
10429 ;; Hide killed subtrees.
10431 gnus-thread-hide-killed
10432 (gnus-summary-hide-thread))
10433 ;; If marked as read, go to next unread subject.
10434 (when (null unmark)
10435 ;; Go to next unread subject.
10436 (gnus-summary-next-subject 1 t)))
10437 (gnus-set-mode-line 'summary))
10439 ;; Summary sorting commands
10441 (defun gnus-summary-sort-by-number (&optional reverse)
10442 "Sort the summary buffer by article number.
10443 Argument REVERSE means reverse order."
10445 (gnus-summary-sort 'number reverse))
10447 (defun gnus-summary-sort-by-random (&optional reverse)
10448 "Randomize the order in the summary buffer.
10449 Argument REVERSE means to randomize in reverse order."
10451 (gnus-summary-sort 'random reverse))
10453 (defun gnus-summary-sort-by-author (&optional reverse)
10454 "Sort the summary buffer by author name alphabetically.
10455 If `case-fold-search' is non-nil, case of letters is ignored.
10456 Argument REVERSE means reverse order."
10458 (gnus-summary-sort 'author reverse))
10460 (defun gnus-summary-sort-by-subject (&optional reverse)
10461 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10462 If `case-fold-search' is non-nil, case of letters is ignored.
10463 Argument REVERSE means reverse order."
10465 (gnus-summary-sort 'subject reverse))
10467 (defun gnus-summary-sort-by-date (&optional reverse)
10468 "Sort the summary buffer by date.
10469 Argument REVERSE means reverse order."
10471 (gnus-summary-sort 'date reverse))
10473 (defun gnus-summary-sort-by-score (&optional reverse)
10474 "Sort the summary buffer by score.
10475 Argument REVERSE means reverse order."
10477 (gnus-summary-sort 'score reverse))
10479 (defun gnus-summary-sort-by-lines (&optional reverse)
10480 "Sort the summary buffer by the number of lines.
10481 Argument REVERSE means reverse order."
10483 (gnus-summary-sort 'lines reverse))
10485 (defun gnus-summary-sort-by-chars (&optional reverse)
10486 "Sort the summary buffer by article length.
10487 Argument REVERSE means reverse order."
10489 (gnus-summary-sort 'chars reverse))
10491 (defun gnus-summary-sort-by-original (&optional reverse)
10492 "Sort the summary buffer using the default sorting method.
10493 Argument REVERSE means reverse order."
10495 (let* ((buffer-read-only)
10496 (gnus-summary-prepare-hook nil))
10497 ;; We do the sorting by regenerating the threads.
10498 (gnus-summary-prepare)
10499 ;; Hide subthreads if needed.
10500 (gnus-summary-maybe-hide-threads)))
10502 (defun gnus-summary-sort (predicate reverse)
10503 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10504 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10505 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10506 (gnus-thread-sort-functions
10511 (gnus-sort-gathered-threads-function
10512 gnus-thread-sort-functions)
10513 (gnus-article-sort-functions
10517 (,article t2 t1))))
10519 (gnus-summary-prepare-hook nil))
10520 ;; We do the sorting by regenerating the threads.
10521 (gnus-summary-prepare)
10522 ;; Hide subthreads if needed.
10523 (gnus-summary-maybe-hide-threads)))
10525 ;; Summary saving commands.
10527 (defun gnus-summary-save-article (&optional n not-saved)
10528 "Save the current article using the default saver function.
10529 If N is a positive number, save the N next articles.
10530 If N is a negative number, save the N previous articles.
10531 If N is nil and any articles have been marked with the process mark,
10532 save those articles instead.
10533 The variable `gnus-default-article-saver' specifies the saver function."
10535 (let* ((articles (gnus-summary-work-articles n))
10536 (save-buffer (save-excursion
10537 (nnheader-set-temp-buffer " *Gnus Save*")))
10538 (num (length articles))
10540 (dolist (article articles)
10541 (setq header (gnus-summary-article-header article))
10542 (if (not (vectorp header))
10543 ;; This is a pseudo-article.
10544 (if (assq 'name header)
10545 (gnus-copy-file (cdr (assq 'name header)))
10546 (gnus-message 1 "Article %d is unsaveable" article))
10547 ;; This is a real article.
10548 (save-window-excursion
10549 (let ((gnus-display-mime-function nil)
10550 (gnus-article-prepare-hook nil))
10551 (gnus-summary-select-article t nil nil article)))
10553 (set-buffer save-buffer)
10555 (insert-buffer-substring gnus-original-article-buffer))
10556 (setq file (gnus-article-save save-buffer file num))
10557 (gnus-summary-remove-process-mark article)
10559 (gnus-summary-set-saved-mark article))))
10560 (gnus-kill-buffer save-buffer)
10561 (gnus-summary-position-point)
10562 (gnus-set-mode-line 'summary)
10565 (defun gnus-summary-pipe-output (&optional arg headers)
10566 "Pipe the current article to a subprocess.
10567 If N is a positive number, pipe the N next articles.
10568 If N is a negative number, pipe the N previous articles.
10569 If N is nil and any articles have been marked with the process mark,
10570 pipe those articles instead.
10571 If HEADERS (the symbolic prefix), include the headers, too."
10572 (interactive (gnus-interactive "P\ny"))
10573 (require 'gnus-art)
10574 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10575 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10576 (gnus-summary-save-article arg t))
10577 (let ((buffer (get-buffer "*Shell Command Output*")))
10579 (not (zerop (buffer-size buffer))))
10580 (gnus-configure-windows 'pipe))))
10582 (defun gnus-summary-save-article-mail (&optional arg)
10583 "Append the current article to an mail file.
10584 If N is a positive number, save the N next articles.
10585 If N is a negative number, save the N previous articles.
10586 If N is nil and any articles have been marked with the process mark,
10587 save those articles instead."
10589 (require 'gnus-art)
10590 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10591 (gnus-summary-save-article arg)))
10593 (defun gnus-summary-save-article-rmail (&optional arg)
10594 "Append the current article to an rmail file.
10595 If N is a positive number, save the N next articles.
10596 If N is a negative number, save the N previous articles.
10597 If N is nil and any articles have been marked with the process mark,
10598 save those articles instead."
10600 (require 'gnus-art)
10601 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10602 (gnus-summary-save-article arg)))
10604 (defun gnus-summary-save-article-file (&optional arg)
10605 "Append the current article to a file.
10606 If N is a positive number, save the N next articles.
10607 If N is a negative number, save the N previous articles.
10608 If N is nil and any articles have been marked with the process mark,
10609 save those articles instead."
10611 (require 'gnus-art)
10612 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10613 (gnus-summary-save-article arg)))
10615 (defun gnus-summary-write-article-file (&optional arg)
10616 "Write the current article to a file, deleting the previous file.
10617 If N is a positive number, save the N next articles.
10618 If N is a negative number, save the N previous articles.
10619 If N is nil and any articles have been marked with the process mark,
10620 save those articles instead."
10622 (require 'gnus-art)
10623 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10624 (gnus-summary-save-article arg)))
10626 (defun gnus-summary-save-article-body-file (&optional arg)
10627 "Append the current article body to a file.
10628 If N is a positive number, save the N next articles.
10629 If N is a negative number, save the N previous articles.
10630 If N is nil and any articles have been marked with the process mark,
10631 save those articles instead."
10633 (require 'gnus-art)
10634 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10635 (gnus-summary-save-article arg)))
10637 (defun gnus-summary-muttprint (&optional arg)
10638 "Print the current article using Muttprint.
10639 If N is a positive number, save the N next articles.
10640 If N is a negative number, save the N previous articles.
10641 If N is nil and any articles have been marked with the process mark,
10642 save those articles instead."
10644 (require 'gnus-art)
10645 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10646 (gnus-summary-save-article arg t)))
10648 (defun gnus-summary-pipe-message (program)
10649 "Pipe the current article through PROGRAM."
10650 (interactive "sProgram: ")
10651 (gnus-summary-select-article)
10652 (let ((mail-header-separator ""))
10653 (gnus-eval-in-buffer-window gnus-article-buffer
10656 (let ((start (window-start))
10658 (message-pipe-buffer-body program)
10659 (set-window-start (get-buffer-window (current-buffer)) start))))))
10661 (defun gnus-get-split-value (methods)
10662 "Return a value based on the split METHODS."
10663 (let (split-name method result match)
10666 (set-buffer gnus-original-article-buffer)
10668 (nnheader-narrow-to-headers)
10669 (while (and methods (not split-name))
10670 (goto-char (point-min))
10671 (setq method (pop methods))
10672 (setq match (car method))
10675 ;; Regular expression.
10677 (re-search-forward match nil t)))
10678 ((gnus-functionp match)
10682 (setq result (funcall match gnus-newsgroup-name))))
10687 (setq result (eval match)))))
10688 (setq split-name (cdr method))
10689 (cond ((stringp result)
10690 (push (expand-file-name
10691 result gnus-article-save-directory)
10694 (setq split-name (append result split-name)))))))))
10695 (nreverse split-name)))
10697 (defun gnus-valid-move-group-p (group)
10698 (and (boundp group)
10699 (symbol-name group)
10700 (symbol-value group)
10701 (gnus-get-function (gnus-find-method-for-group
10702 (symbol-name group)) 'request-accept-article t)))
10704 (defun gnus-read-move-group-name (prompt default articles prefix)
10705 "Read a group name."
10706 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10707 (minibuffer-confirm-incomplete nil) ; XEmacs
10709 (format "%s %s to:"
10711 (if (> (length articles) 1)
10712 (format "these %d articles" (length articles))
10717 (gnus-completing-read-with-default
10720 'gnus-valid-move-group-p
10722 'gnus-group-history))
10723 ((= 1 (length split-name))
10724 (gnus-completing-read-with-default
10725 (car split-name) prom
10727 'gnus-valid-move-group-p
10729 'gnus-group-history))
10731 (gnus-completing-read-with-default
10733 (mapcar (lambda (el) (list el))
10734 (nreverse split-name))
10736 'gnus-group-history))))
10737 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10739 (if (or (string= to-newsgroup "")
10740 (string= to-newsgroup prefix))
10741 (setq to-newsgroup default))
10742 (unless to-newsgroup
10743 (error "No group name entered"))
10744 (or (gnus-active to-newsgroup)
10745 (gnus-activate-group to-newsgroup nil nil to-method)
10746 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10748 (or (and (gnus-request-create-group to-newsgroup to-method)
10749 (gnus-activate-group
10750 to-newsgroup nil nil to-method)
10751 (gnus-subscribe-group to-newsgroup))
10752 (error "Couldn't create group %s" to-newsgroup)))
10753 (error "No such group: %s" to-newsgroup)))
10756 (defun gnus-summary-save-parts (type dir n &optional reverse)
10757 "Save parts matching TYPE to DIR.
10758 If REVERSE, save parts that do not match TYPE."
10760 (list (read-string "Save parts of type: "
10761 (or (car gnus-summary-save-parts-type-history)
10762 gnus-summary-save-parts-default-mime)
10763 'gnus-summary-save-parts-type-history)
10764 (setq gnus-summary-save-parts-last-directory
10765 (read-file-name "Save to directory: "
10766 gnus-summary-save-parts-last-directory
10768 current-prefix-arg))
10769 (gnus-summary-iterate n
10770 (let ((gnus-display-mime-function nil)
10771 (gnus-inhibit-treatment t))
10772 (gnus-summary-select-article))
10774 (set-buffer gnus-article-buffer)
10775 (let ((handles (or gnus-article-mime-handles
10776 (mm-dissect-buffer nil gnus-article-loose-mime)
10777 (and gnus-article-emulate-mime
10778 (mm-uu-dissect)))))
10780 (gnus-summary-save-parts-1 type dir handles reverse)
10781 (unless gnus-article-mime-handles ;; Don't destroy this case.
10782 (mm-destroy-parts handles)))))))
10784 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10785 (if (stringp (car handle))
10786 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10789 (not (string-match type (mm-handle-media-type handle)))
10790 (string-match type (mm-handle-media-type handle)))
10791 (let ((file (expand-file-name
10792 (file-name-nondirectory
10794 (mail-content-type-get
10795 (mm-handle-disposition handle) 'filename)
10796 (concat gnus-newsgroup-name
10797 "." (number-to-string
10798 (cdr gnus-article-current)))))
10800 (unless (file-exists-p file)
10801 (mm-save-part-to-file handle file))))))
10803 ;; Summary extract commands
10805 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10806 (let ((buffer-read-only nil)
10807 (article (gnus-summary-article-number))
10809 (unless (gnus-summary-goto-subject article)
10810 (error "No such article: %d" article))
10811 (gnus-summary-position-point)
10812 ;; If all commands are to be bunched up on one line, we collect
10814 (unless gnus-view-pseudos-separately
10815 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10818 (setq action (cdr (assq 'action (car ps))))
10819 (setq files (list (cdr (assq 'name (car ps)))))
10820 (while (and ps (cdr ps)
10821 (string= (or action "1")
10822 (or (cdr (assq 'action (cadr ps))) "2")))
10823 (push (cdr (assq 'name (cadr ps))) files)
10824 (setcdr ps (cddr ps)))
10826 (when (not (string-match "%s" action))
10829 (when (assq 'execute (car ps))
10830 (setcdr (assq 'execute (car ps))
10831 (funcall (if (string-match "%s" action)
10840 (setq ps (cdr ps)))))
10841 (if (and gnus-view-pseudos (not not-view))
10843 (when (assq 'execute (car pslist))
10844 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10845 (eq gnus-view-pseudos 'not-confirm)))
10846 (setq pslist (cdr pslist)))
10849 (setq after-article (or (cdr (assq 'article (car pslist)))
10850 (gnus-summary-article-number)))
10851 (gnus-summary-goto-subject after-article)
10854 (insert " " (file-name-nondirectory
10855 (cdr (assq 'name (car pslist))))
10856 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10858 (forward-line -1) ; back to `b'
10859 (gnus-add-text-properties
10860 b (1- e) (list 'gnus-number gnus-reffed-article-number
10861 gnus-mouse-face-prop gnus-mouse-face))
10863 after-article gnus-reffed-article-number
10864 gnus-unread-mark b (car pslist) 0 (- e b))
10865 (setq gnus-newsgroup-unreads
10866 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10867 gnus-reffed-article-number))
10868 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10869 (setq pslist (cdr pslist)))))))
10871 (defun gnus-pseudos< (p1 p2)
10872 (let ((c1 (cdr (assq 'action p1)))
10873 (c2 (cdr (assq 'action p2))))
10874 (and c1 c2 (string< c1 c2))))
10876 (defun gnus-request-pseudo-article (props)
10877 (cond ((assq 'execute props)
10878 (gnus-execute-command (cdr (assq 'execute props)))))
10879 (let ((gnus-current-article (gnus-summary-article-number)))
10880 (gnus-run-hooks 'gnus-mark-article-hook)))
10882 (defun gnus-execute-command (command &optional automatic)
10884 (gnus-article-setup-buffer)
10885 (set-buffer gnus-article-buffer)
10886 (setq buffer-read-only nil)
10887 (let ((command (if automatic command
10888 (read-string "Command: " (cons command 0)))))
10890 (insert "$ " command "\n\n")
10891 (if gnus-view-pseudo-asynchronously
10892 (start-process "gnus-execute" (current-buffer) shell-file-name
10893 shell-command-switch command)
10894 (call-process shell-file-name nil t nil
10895 shell-command-switch command)))))
10897 ;; Summary kill commands.
10899 (defun gnus-summary-edit-global-kill (article)
10900 "Edit the \"global\" kill file."
10901 (interactive (list (gnus-summary-article-number)))
10902 (gnus-group-edit-global-kill article))
10904 (defun gnus-summary-edit-local-kill ()
10905 "Edit a local kill file applied to the current newsgroup."
10907 (setq gnus-current-headers (gnus-summary-article-header))
10908 (gnus-group-edit-local-kill
10909 (gnus-summary-article-number) gnus-newsgroup-name))
10911 ;;; Header reading.
10913 (defun gnus-read-header (id &optional header)
10914 "Read the headers of article ID and enter them into the Gnus system."
10915 (let ((group gnus-newsgroup-name)
10916 (gnus-override-method
10918 gnus-override-method
10919 (and (gnus-news-group-p gnus-newsgroup-name)
10920 (car (gnus-refer-article-methods)))))
10922 ;; First we check to see whether the header in question is already
10925 ;; This is a Message-ID.
10926 (setq header (or header (gnus-id-to-header id)))
10927 ;; This is an article number.
10928 (setq header (or header (gnus-summary-article-header id))))
10930 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10931 ;; We have found the header.
10933 ;; If this is a sparse article, we have to nix out its
10934 ;; previous entry in the thread hashtb.
10936 (gnus-summary-article-sparse-p (mail-header-number header)))
10937 (let* ((parent (gnus-parent-id (mail-header-references header)))
10938 (thread (and parent (gnus-id-to-thread parent))))
10940 (delq (assq header thread) thread))))
10941 ;; We have to really fetch the header to this article.
10943 (set-buffer nntp-server-buffer)
10944 (when (setq where (gnus-request-head id group))
10945 (nnheader-fold-continuation-lines)
10946 (goto-char (point-max))
10948 (goto-char (point-min))
10952 ((cdr where) (cdr where))
10953 (header (mail-header-number header))
10954 (t gnus-reffed-article-number))
10956 (insert " Article retrieved.\n"))
10957 (if (or (not where)
10958 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10959 () ; Malformed head.
10960 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10961 (when (and (stringp id)
10962 (not (string= (gnus-group-real-name group)
10964 ;; If we fetched by Message-ID and the article came
10965 ;; from a different group, we fudge some bogus article
10966 ;; numbers for this article.
10967 (mail-header-set-number header gnus-reffed-article-number))
10969 (set-buffer gnus-summary-buffer)
10970 (decf gnus-reffed-article-number)
10971 (gnus-remove-header (mail-header-number header))
10972 (push header gnus-newsgroup-headers)
10973 (setq gnus-current-headers header)
10974 (push (mail-header-number header) gnus-newsgroup-limit)))
10977 (defun gnus-remove-header (number)
10978 "Remove header NUMBER from `gnus-newsgroup-headers'."
10979 (if (and gnus-newsgroup-headers
10980 (= number (mail-header-number (car gnus-newsgroup-headers))))
10981 (pop gnus-newsgroup-headers)
10982 (let ((headers gnus-newsgroup-headers))
10983 (while (and (cdr headers)
10984 (not (= number (mail-header-number (cadr headers)))))
10986 (when (cdr headers)
10987 (setcdr headers (cddr headers))))))
10990 ;;; summary highlights
10993 (defun gnus-highlight-selected-summary ()
10994 "Highlight selected article in summary buffer."
10995 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10996 (when gnus-summary-selected-face
10998 (let* ((beg (progn (beginning-of-line) (point)))
10999 (end (progn (end-of-line) (point)))
11000 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11001 (from (if (get-text-property beg gnus-mouse-face-prop)
11003 (or (next-single-property-change
11004 beg gnus-mouse-face-prop nil end)
11009 (or (next-single-property-change
11010 from gnus-mouse-face-prop nil end)
11012 ;; If no mouse-face prop on line we will have to = from = end,
11013 ;; so we highlight the entire line instead.
11014 (when (= (+ to 2) from)
11017 (if gnus-newsgroup-selected-overlay
11018 ;; Move old overlay.
11020 gnus-newsgroup-selected-overlay from to (current-buffer))
11021 ;; Create new overlay.
11023 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11024 'face gnus-summary-selected-face))))))
11026 (defvar gnus-summary-highlight-line-cached nil)
11027 (defvar gnus-summary-highlight-line-trigger nil)
11029 (defun gnus-summary-highlight-line-0 ()
11030 (if (and (eq gnus-summary-highlight-line-trigger
11031 gnus-summary-highlight)
11032 gnus-summary-highlight-line-cached)
11033 gnus-summary-highlight-line-cached
11034 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11035 gnus-summary-highlight-line-cached
11036 (let* ((cond (list 'cond))
11038 (list gnus-summary-highlight))
11040 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11043 (gnus-byte-compile (list 'lambda nil cond))))))
11045 (defun gnus-summary-highlight-line ()
11046 "Highlight current line according to `gnus-summary-highlight'."
11047 (let* ((beg (gnus-point-at-bol))
11048 (article (or (gnus-summary-article-number) gnus-current-article))
11049 (score (or (cdr (assq article
11050 gnus-newsgroup-scored))
11051 gnus-summary-default-score 0))
11052 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11053 (inhibit-read-only t)
11054 (default gnus-summary-default-score)
11055 (default-high gnus-summary-default-high-score)
11056 (default-low gnus-summary-default-low-score)
11057 (uncached (memq article gnus-newsgroup-undownloaded))
11058 (downloaded (not uncached)))
11059 (let ((face (funcall (gnus-summary-highlight-line-0))))
11060 (unless (eq face (get-text-property beg 'face))
11061 (gnus-put-text-property-excluding-characters-with-faces
11062 beg (gnus-point-at-eol) 'face
11063 (setq face (if (boundp face) (symbol-value face) face)))
11064 (when gnus-summary-highlight-line-function
11065 (funcall gnus-summary-highlight-line-function article face))))))
11067 (defun gnus-update-read-articles (group unread &optional compute)
11068 "Update the list of read articles in GROUP.
11069 UNREAD is a sorted list."
11070 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11071 (entry (gnus-gethash group gnus-newsrc-hashtb))
11072 (info (nth 2 entry))
11075 (if (or (not info) (not active))
11076 ;; There is no info on this group if it was, in fact,
11077 ;; killed. Gnus stores no information on killed groups, so
11078 ;; there's nothing to be done.
11079 ;; One could store the information somewhere temporarily,
11080 ;; perhaps... Hmmm...
11082 ;; Remove any negative articles numbers.
11083 (while (and unread (< (car unread) 0))
11084 (setq unread (cdr unread)))
11085 ;; Remove any expired article numbers
11086 (while (and unread (< (car unread) (car active)))
11087 (setq unread (cdr unread)))
11088 ;; Compute the ranges of read articles by looking at the list of
11089 ;; unread articles.
11091 (when (/= (car unread) prev)
11092 (push (if (= prev (1- (car unread))) prev
11093 (cons prev (1- (car unread))))
11095 (setq prev (1+ (car unread)))
11096 (setq unread (cdr unread)))
11097 (when (<= prev (cdr active))
11098 (push (cons prev (cdr active)) read))
11099 (setq read (if (> (length read) 1) (nreverse read) read))
11104 ;; Propagate the read marks to the backend.
11105 (when (gnus-check-backend-function 'request-set-mark group)
11106 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11107 (add (gnus-remove-from-range read (gnus-info-read info))))
11109 (unless (gnus-check-group group)
11110 (error "Can't open server for %s" group))
11111 (gnus-request-set-mark
11112 group (delq nil (list (if add (list add 'add '(read)))
11113 (if del (list del 'del '(read))))))
11115 `(gnus-request-set-mark
11118 (if del (list del 'add '(read)))
11119 (if add (list add 'del '(read))))))))))
11120 (set-buffer gnus-group-buffer)
11121 (gnus-undo-register
11123 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11124 (gnus-info-set-read ',info ',(gnus-info-read info))
11125 (gnus-get-unread-articles-in-group ',info
11126 (gnus-active ,group))
11127 (gnus-group-update-group ,group t)
11129 ;; Enter this list into the group info.
11130 (gnus-info-set-read info read)
11131 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11132 (gnus-get-unread-articles-in-group info (gnus-active group))
11135 (defun gnus-offer-save-summaries ()
11136 "Offer to save all active summary buffers."
11138 ;; Go through all buffers and find all summaries.
11139 (dolist (buffer (buffer-list))
11140 (when (and (setq buffer (buffer-name buffer))
11141 (string-match "Summary" buffer)
11143 (set-buffer buffer)
11144 ;; We check that this is, indeed, a summary buffer.
11145 (and (eq major-mode 'gnus-summary-mode)
11146 ;; Also make sure this isn't bogus.
11147 gnus-newsgroup-prepared
11148 ;; Also make sure that this isn't a
11149 ;; dead summary buffer.
11150 (not gnus-dead-summary-mode))))
11151 (push buffer buffers)))
11152 ;; Go through all these summary buffers and offer to save them.
11156 "Update summary buffer %s? "
11158 (switch-to-buffer buf)
11159 (gnus-summary-exit))
11162 (defun gnus-summary-setup-default-charset ()
11163 "Setup newsgroup default charset."
11164 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11165 (setq gnus-newsgroup-charset nil)
11166 (let* ((ignored-charsets
11167 (or gnus-newsgroup-ephemeral-ignored-charsets
11169 (and gnus-newsgroup-name
11170 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11171 gnus-newsgroup-ignored-charsets))))
11172 (setq gnus-newsgroup-charset
11173 (or gnus-newsgroup-ephemeral-charset
11174 (and gnus-newsgroup-name
11175 (gnus-parameter-charset gnus-newsgroup-name))
11176 gnus-default-charset))
11177 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11178 ignored-charsets))))
11184 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11185 "Display the current article buffer fully MIME-buttonized.
11186 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11187 treated as multipart/mixed."
11189 (require 'gnus-art)
11190 (let ((gnus-unbuttonized-mime-types nil)
11191 (gnus-mime-display-multipart-as-mixed show-all-parts))
11192 (gnus-summary-show-article)))
11194 (defun gnus-summary-repair-multipart (article)
11195 "Add a Content-Type header to a multipart article without one."
11196 (interactive (list (gnus-summary-article-number)))
11197 (gnus-with-article article
11198 (message-narrow-to-head)
11199 (message-remove-header "Mime-Version")
11200 (goto-char (point-max))
11201 (insert "Mime-Version: 1.0\n")
11203 (when (search-forward "\n--" nil t)
11204 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11205 (message-narrow-to-head)
11206 (message-remove-header "Content-Type")
11207 (goto-char (point-max))
11208 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11211 (let (gnus-mark-article-hook)
11212 (gnus-summary-select-article t t nil article)))
11214 (defun gnus-summary-toggle-display-buttonized ()
11215 "Toggle the buttonizing of the article buffer."
11217 (require 'gnus-art)
11218 (if (setq gnus-inhibit-mime-unbuttonizing
11219 (not gnus-inhibit-mime-unbuttonizing))
11220 (let ((gnus-unbuttonized-mime-types nil))
11221 (gnus-summary-show-article))
11222 (gnus-summary-show-article)))
11225 ;;; Generic summary marking commands
11228 (defvar gnus-summary-marking-alist
11229 '((read gnus-del-mark "d")
11230 (unread gnus-unread-mark "u")
11231 (ticked gnus-ticked-mark "!")
11232 (dormant gnus-dormant-mark "?")
11233 (expirable gnus-expirable-mark "e"))
11234 "An alist of names/marks/keystrokes.")
11236 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11237 (defvar gnus-summary-mark-map)
11239 (defun gnus-summary-make-all-marking-commands ()
11240 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11241 (dolist (elem gnus-summary-marking-alist)
11242 (apply 'gnus-summary-make-marking-command elem)))
11244 (defun gnus-summary-make-marking-command (name mark keystroke)
11245 (let ((map (make-sparse-keymap)))
11246 (define-key gnus-summary-generic-mark-map keystroke map)
11247 (dolist (lway `((next "next" next nil "n")
11248 (next-unread "next unread" next t "N")
11249 (prev "previous" prev nil "p")
11250 (prev-unread "previous unread" prev t "P")
11251 (nomove "" nil nil ,keystroke)))
11252 (let ((func (gnus-summary-make-marking-command-1
11253 mark (car lway) lway name)))
11254 (setq func (eval func))
11255 (define-key map (nth 4 lway) func)))))
11257 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11259 (format "gnus-summary-put-mark-as-%s%s"
11260 name (if (eq way 'nomove)
11262 (concat "-" (symbol-name way)))))
11265 "Mark the current article as %s%s.
11266 If N, the prefix, then repeat N times.
11267 If N is negative, move in reverse order.
11268 The difference between N and the actual number of articles marked is
11272 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11274 (defun gnus-summary-generic-mark (n mark move unread)
11275 "Mark N articles with MARK."
11276 (unless (eq major-mode 'gnus-summary-mode)
11277 (error "This command can only be used in the summary buffer"))
11278 (gnus-summary-show-thread)
11281 ((eq move 'next) 1)
11282 ((eq move 'prev) -1)
11284 (if (zerop nummove)
11288 nummove (* -1 nummove))))
11289 (while (and (> n 0)
11290 (gnus-summary-mark-article nil mark)
11291 (zerop (gnus-summary-next-subject nummove unread t)))
11294 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11295 (gnus-summary-recenter)
11296 (gnus-summary-position-point)
11297 (gnus-set-mode-line 'summary)
11300 (defun gnus-summary-insert-articles (articles)
11301 (when (setq articles
11302 (gnus-sorted-difference articles
11303 (mapcar (lambda (h)
11304 (mail-header-number h))
11305 gnus-newsgroup-headers)))
11306 (setq gnus-newsgroup-headers
11308 gnus-newsgroup-headers
11309 (gnus-fetch-headers articles)
11310 'gnus-article-sort-by-number))
11311 ;; Suppress duplicates?
11312 (when gnus-suppress-duplicates
11313 (gnus-dup-suppress-articles))
11315 ;; We might want to build some more threads first.
11316 (when (and gnus-fetch-old-headers
11317 (eq gnus-headers-retrieved-by 'nov))
11318 (if (eq gnus-fetch-old-headers 'invisible)
11319 (gnus-build-all-threads)
11320 (gnus-build-old-threads)))
11321 ;; Let the Gnus agent mark articles as read.
11323 (gnus-agent-get-undownloaded-list))
11324 ;; Remove list identifiers from subject
11325 (when gnus-list-identifiers
11326 (gnus-summary-remove-list-identifiers))
11327 ;; First and last article in this newsgroup.
11328 (when gnus-newsgroup-headers
11329 (setq gnus-newsgroup-begin
11330 (mail-header-number (car gnus-newsgroup-headers))
11332 (mail-header-number
11333 (gnus-last-element gnus-newsgroup-headers))))
11334 (when gnus-use-scoring
11335 (gnus-possibly-score-headers))))
11337 (defun gnus-summary-insert-old-articles (&optional all)
11338 "Insert all old articles in this group.
11339 If ALL is non-nil, already read articles become readable.
11340 If ALL is a number, fetch this number of articles."
11343 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11346 ;; Some nntp servers lie about their active range. When
11347 ;; this happens, the active range can be in the millions.
11348 ;; Use a compressed range to avoid creating a huge list.
11349 (gnus-range-difference (list gnus-newsgroup-active) old))
11350 (setq len (gnus-range-length older))
11355 (let ((older-range (nreverse older)))
11359 (let* ((r (pop older-range))
11360 (min (if (numberp r) r (car r)))
11361 (max (if (numberp r) r (cdr r))))
11362 (while (and (<= min max)
11367 (setq older (gnus-uncompress-range older))))
11369 (setq older (gnus-uncompress-range older)))
11371 (when (and (numberp gnus-large-newsgroup)
11372 (> len gnus-large-newsgroup))
11373 (let* ((cursor-in-echo-area nil)
11374 (initial (gnus-parameter-large-newsgroup-initial
11375 gnus-newsgroup-name))
11379 "How many articles from %s (%s %d): "
11381 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11382 (if initial "max" "default")
11385 (cons (number-to-string initial)
11387 (unless (string-match "^[ \t]*$" input)
11388 (setq all (string-to-number input))
11390 (let ((older-range (nreverse older)))
11394 (let* ((r (pop older-range))
11395 (min (if (numberp r) r (car r)))
11396 (max (if (numberp r) r (cdr r))))
11397 (while (and (<= min max)
11401 max (1- max))))))))))
11402 (setq older (gnus-uncompress-range older))))
11404 (message "No old news.")
11405 (gnus-summary-insert-articles older)
11406 (gnus-summary-limit (gnus-sorted-nunion old older))))
11407 (gnus-summary-position-point)))
11409 (defun gnus-summary-insert-new-articles ()
11410 "Insert all new articles in this group."
11413 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11414 (old-active gnus-newsgroup-active)
11415 (nnmail-fetched-sources (list t))
11417 (setq gnus-newsgroup-active
11418 (gnus-activate-group gnus-newsgroup-name 'scan))
11419 (setq i (cdr gnus-newsgroup-active))
11420 (while (> i (cdr old-active))
11424 (message "No gnus is bad news.")
11425 (gnus-summary-insert-articles new)
11426 (setq gnus-newsgroup-unreads
11427 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11428 (gnus-summary-limit (gnus-sorted-nunion old new))))
11429 (gnus-summary-position-point)))
11431 (gnus-summary-make-all-marking-commands)
11433 (gnus-ems-redefine)
11435 (provide 'gnus-sum)
11437 (run-hooks 'gnus-sum-load-hook)
11439 ;;; gnus-sum.el ends here