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 ?H
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-undownloaded nil
1238 "List of articles in the current newsgroup that haven't been downloaded..")
1240 (defvar gnus-newsgroup-unsendable nil
1241 "List of articles in the current newsgroup that won't be sent.")
1243 (defvar gnus-newsgroup-bookmarks nil
1244 "List of articles in the current newsgroup that have bookmarks.")
1246 (defvar gnus-newsgroup-dormant nil
1247 "Sorted list of dormant articles in the current newsgroup.")
1249 (defvar gnus-newsgroup-unseen nil
1250 "List of unseen articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-seen nil
1253 "Range of seen articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-articles nil
1256 "List of articles in the current newsgroup.")
1258 (defvar gnus-newsgroup-scored nil
1259 "List of scored articles in the current newsgroup.")
1261 (defvar gnus-newsgroup-headers nil
1262 "List of article headers in the current newsgroup.")
1264 (defvar gnus-newsgroup-threads nil)
1266 (defvar gnus-newsgroup-prepared nil
1267 "Whether the current group has been prepared properly.")
1269 (defvar gnus-newsgroup-ancient nil
1270 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1272 (defvar gnus-newsgroup-sparse nil)
1274 (defvar gnus-current-article nil)
1275 (defvar gnus-article-current nil)
1276 (defvar gnus-current-headers nil)
1277 (defvar gnus-have-all-headers nil)
1278 (defvar gnus-last-article nil)
1279 (defvar gnus-newsgroup-history nil)
1280 (defvar gnus-newsgroup-charset nil)
1281 (defvar gnus-newsgroup-ephemeral-charset nil)
1282 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1284 (defvar gnus-article-before-search nil)
1286 (defconst gnus-summary-local-variables
1287 '(gnus-newsgroup-name
1288 gnus-newsgroup-begin gnus-newsgroup-end
1289 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1290 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1291 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1292 gnus-newsgroup-unselected gnus-newsgroup-marked
1293 gnus-newsgroup-spam-marked
1294 gnus-newsgroup-reads gnus-newsgroup-saved
1295 gnus-newsgroup-replied gnus-newsgroup-forwarded
1296 gnus-newsgroup-recent
1297 gnus-newsgroup-expirable
1298 gnus-newsgroup-processable gnus-newsgroup-killed
1299 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1300 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1301 gnus-newsgroup-seen gnus-newsgroup-articles
1302 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1303 gnus-newsgroup-headers gnus-newsgroup-threads
1304 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1305 gnus-current-article gnus-current-headers gnus-have-all-headers
1306 gnus-last-article gnus-article-internal-prepare-hook
1307 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1308 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1309 gnus-thread-expunge-below
1310 gnus-score-alist gnus-current-score-file
1311 (gnus-summary-expunge-below . global)
1312 (gnus-summary-mark-below . global)
1313 (gnus-orphan-score . global)
1314 gnus-newsgroup-active gnus-scores-exclude-files
1315 gnus-newsgroup-history gnus-newsgroup-ancient
1316 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1317 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1318 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1319 (gnus-newsgroup-expunged-tally . 0)
1320 gnus-cache-removable-articles gnus-newsgroup-cached
1321 gnus-newsgroup-data gnus-newsgroup-data-reverse
1322 gnus-newsgroup-limit gnus-newsgroup-limits
1323 gnus-newsgroup-charset gnus-newsgroup-display)
1324 "Variables that are buffer-local to the summary buffers.")
1326 (defvar gnus-newsgroup-variables nil
1327 "A list of variables that have separate values in different newsgroups.
1328 A list of newsgroup (summary buffer) local variables, or cons of
1329 variables and their default values (when the default values are not
1330 nil), that should be made global while the summary buffer is active.
1331 These variables can be used to set variables in the group parameters
1332 while still allowing them to affect operations done in other
1333 buffers. For example:
1335 \(setq gnus-newsgroup-variables
1336 '(message-use-followup-to
1337 (gnus-visible-headers .
1338 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1341 ;; Byte-compiler warning.
1342 ;(eval-when-compile (defvar gnus-article-mode-map))
1344 (let ((features (cons 'gnus-sum features)))
1346 (require 'gnus-agent)
1347 (require 'gnus-art)))
1351 (defvar gnus-decode-encoded-word-methods
1352 '(mail-decode-encoded-word-string)
1353 "List of methods used to decode encoded words.
1355 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1356 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1357 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1358 whose names match REGEXP.
1361 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1362 mail-decode-encoded-word-string
1363 (\"chinese\" . rfc1843-decode-string))")
1365 (defvar gnus-decode-encoded-word-methods-cache nil)
1367 (defun gnus-multi-decode-encoded-word-string (string)
1368 "Apply the functions from `gnus-encoded-word-methods' that match."
1369 (unless (and gnus-decode-encoded-word-methods-cache
1370 (eq gnus-newsgroup-name
1371 (car gnus-decode-encoded-word-methods-cache)))
1372 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1375 (nconc gnus-decode-encoded-word-methods-cache (list x))
1376 (if (and gnus-newsgroup-name
1377 (string-match (car x) gnus-newsgroup-name))
1378 (nconc gnus-decode-encoded-word-methods-cache
1380 gnus-decode-encoded-word-methods))
1381 (let ((xlist gnus-decode-encoded-word-methods-cache))
1384 (setq string (funcall (pop xlist) string))))
1387 ;; Subject simplification.
1389 (defun gnus-simplify-whitespace (str)
1390 "Remove excessive whitespace from STR."
1393 (while (string-match "[ \t][ \t]+" mystr)
1394 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1396 (substring mystr (match-end 0)))))
1398 (when (string-match "^[ \t]+" mystr)
1399 (setq mystr (substring mystr (match-end 0))))
1401 (when (string-match "[ \t]+$" mystr)
1402 (setq mystr (substring mystr 0 (match-beginning 0))))
1405 (defun gnus-simplify-all-whitespace (str)
1406 "Remove all whitespace from STR."
1408 (while (string-match "[ \t\n]+" mystr)
1409 (setq mystr (replace-match "" nil nil mystr)))
1412 (defsubst gnus-simplify-subject-re (subject)
1413 "Remove \"Re:\" from subject lines."
1414 (if (string-match message-subject-re-regexp subject)
1415 (substring subject (match-end 0))
1418 (defun gnus-simplify-subject (subject &optional re-only)
1419 "Remove `Re:' and words in parentheses.
1420 If RE-ONLY is non-nil, strip leading `Re:'s only."
1421 (let ((case-fold-search t)) ;Ignore case.
1422 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1423 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1424 (setq subject (substring subject (match-end 0))))
1425 ;; Remove uninteresting prefixes.
1426 (when (and (not re-only)
1427 gnus-simplify-ignored-prefixes
1428 (string-match gnus-simplify-ignored-prefixes subject))
1429 (setq subject (substring subject (match-end 0))))
1430 ;; Remove words in parentheses from end.
1432 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1433 (setq subject (substring subject 0 (match-beginning 0)))))
1434 ;; Return subject string.
1437 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1439 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1440 (goto-char (point-min))
1441 (while (re-search-forward regexp nil t)
1442 (replace-match (or newtext ""))))
1444 (defun gnus-simplify-buffer-fuzzy ()
1445 "Simplify string in the buffer fuzzily.
1446 The string in the accessible portion of the current buffer is simplified.
1447 It is assumed to be a single-line subject.
1448 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1449 matter is removed. Additional things can be deleted by setting
1450 `gnus-simplify-subject-fuzzy-regexp'."
1451 (let ((case-fold-search t)
1453 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1455 (while (not (eq modified-tick (buffer-modified-tick)))
1456 (setq modified-tick (buffer-modified-tick))
1458 ((listp gnus-simplify-subject-fuzzy-regexp)
1459 (mapcar 'gnus-simplify-buffer-fuzzy-step
1460 gnus-simplify-subject-fuzzy-regexp))
1461 (gnus-simplify-subject-fuzzy-regexp
1462 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1463 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1464 (gnus-simplify-buffer-fuzzy-step
1465 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1466 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1468 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1469 (gnus-simplify-buffer-fuzzy-step " +" " ")
1470 (gnus-simplify-buffer-fuzzy-step " $")
1471 (gnus-simplify-buffer-fuzzy-step "^ +")))
1473 (defun gnus-simplify-subject-fuzzy (subject)
1474 "Simplify a subject string fuzzily.
1475 See `gnus-simplify-buffer-fuzzy' for details."
1477 (gnus-set-work-buffer)
1478 (let ((case-fold-search t))
1479 ;; Remove uninteresting prefixes.
1480 (when (and gnus-simplify-ignored-prefixes
1481 (string-match gnus-simplify-ignored-prefixes subject))
1482 (setq subject (substring subject (match-end 0))))
1484 (inline (gnus-simplify-buffer-fuzzy))
1487 (defsubst gnus-simplify-subject-fully (subject)
1488 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1490 (gnus-simplify-subject-functions
1491 (gnus-map-function gnus-simplify-subject-functions subject))
1492 ((null gnus-summary-gather-subject-limit)
1493 (gnus-simplify-subject-re subject))
1494 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1495 (gnus-simplify-subject-fuzzy subject))
1496 ((numberp gnus-summary-gather-subject-limit)
1497 (gnus-limit-string (gnus-simplify-subject-re subject)
1498 gnus-summary-gather-subject-limit))
1502 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1503 "Check whether two subjects are equal.
1504 If optional argument simple-first is t, first argument is already
1507 ((null simple-first)
1508 (equal (gnus-simplify-subject-fully s1)
1509 (gnus-simplify-subject-fully s2)))
1512 (gnus-simplify-subject-fully s2)))))
1514 (defun gnus-summary-bubble-group ()
1515 "Increase the score of the current group.
1516 This is a handy function to add to `gnus-summary-exit-hook' to
1517 increase the score of each group you read."
1518 (gnus-group-add-score gnus-newsgroup-name))
1522 ;;; Gnus summary mode
1525 (put 'gnus-summary-mode 'mode-class 'special)
1527 (defvar gnus-article-commands-menu)
1529 ;; Non-orthogonal keys
1531 (gnus-define-keys gnus-summary-mode-map
1532 " " gnus-summary-next-page
1533 "\177" gnus-summary-prev-page
1534 [delete] gnus-summary-prev-page
1535 [backspace] gnus-summary-prev-page
1536 "\r" gnus-summary-scroll-up
1537 "\M-\r" gnus-summary-scroll-down
1538 "n" gnus-summary-next-unread-article
1539 "p" gnus-summary-prev-unread-article
1540 "N" gnus-summary-next-article
1541 "P" gnus-summary-prev-article
1542 "\M-\C-n" gnus-summary-next-same-subject
1543 "\M-\C-p" gnus-summary-prev-same-subject
1544 "\M-n" gnus-summary-next-unread-subject
1545 "\M-p" gnus-summary-prev-unread-subject
1546 "." gnus-summary-first-unread-article
1547 "," gnus-summary-best-unread-article
1548 "\M-s" gnus-summary-search-article-forward
1549 "\M-r" gnus-summary-search-article-backward
1550 "<" gnus-summary-beginning-of-article
1551 ">" gnus-summary-end-of-article
1552 "j" gnus-summary-goto-article
1553 "^" gnus-summary-refer-parent-article
1554 "\M-^" gnus-summary-refer-article
1555 "u" gnus-summary-tick-article-forward
1556 "!" gnus-summary-tick-article-forward
1557 "U" gnus-summary-tick-article-backward
1558 "d" gnus-summary-mark-as-read-forward
1559 "D" gnus-summary-mark-as-read-backward
1560 "E" gnus-summary-mark-as-expirable
1561 "\M-u" gnus-summary-clear-mark-forward
1562 "\M-U" gnus-summary-clear-mark-backward
1563 "k" gnus-summary-kill-same-subject-and-select
1564 "\C-k" gnus-summary-kill-same-subject
1565 "\M-\C-k" gnus-summary-kill-thread
1566 "\M-\C-l" gnus-summary-lower-thread
1567 "e" gnus-summary-edit-article
1568 "#" gnus-summary-mark-as-processable
1569 "\M-#" gnus-summary-unmark-as-processable
1570 "\M-\C-t" gnus-summary-toggle-threads
1571 "\M-\C-s" gnus-summary-show-thread
1572 "\M-\C-h" gnus-summary-hide-thread
1573 "\M-\C-f" gnus-summary-next-thread
1574 "\M-\C-b" gnus-summary-prev-thread
1575 [(meta down)] gnus-summary-next-thread
1576 [(meta up)] gnus-summary-prev-thread
1577 "\M-\C-u" gnus-summary-up-thread
1578 "\M-\C-d" gnus-summary-down-thread
1579 "&" gnus-summary-execute-command
1580 "c" gnus-summary-catchup-and-exit
1581 "\C-w" gnus-summary-mark-region-as-read
1582 "\C-t" gnus-summary-toggle-truncation
1583 "?" gnus-summary-mark-as-dormant
1584 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1585 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1586 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1587 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1588 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1589 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1590 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1591 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1592 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1593 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1594 "=" gnus-summary-expand-window
1595 "\C-x\C-s" gnus-summary-reselect-current-group
1596 "\M-g" gnus-summary-rescan-group
1597 "w" gnus-summary-stop-page-breaking
1598 "\C-c\C-r" gnus-summary-caesar-message
1599 "f" gnus-summary-followup
1600 "F" gnus-summary-followup-with-original
1601 "C" gnus-summary-cancel-article
1602 "r" gnus-summary-reply
1603 "R" gnus-summary-reply-with-original
1604 "\C-c\C-f" gnus-summary-mail-forward
1605 "o" gnus-summary-save-article
1606 "\C-o" gnus-summary-save-article-mail
1607 "|" gnus-summary-pipe-output
1608 "\M-k" gnus-summary-edit-local-kill
1609 "\M-K" gnus-summary-edit-global-kill
1611 "\C-c\C-d" gnus-summary-describe-group
1612 "q" gnus-summary-exit
1613 "Q" gnus-summary-exit-no-update
1614 "\C-c\C-i" gnus-info-find-node
1615 gnus-mouse-2 gnus-mouse-pick-article
1616 "m" gnus-summary-mail-other-window
1617 "a" gnus-summary-post-news
1618 "i" gnus-summary-news-other-window
1619 "x" gnus-summary-limit-to-unread
1620 "s" gnus-summary-isearch-article
1621 "t" gnus-summary-toggle-header
1622 "g" gnus-summary-show-article
1623 "l" gnus-summary-goto-last-article
1624 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1625 "\C-d" gnus-summary-enter-digest-group
1626 "\M-\C-d" gnus-summary-read-document
1627 "\M-\C-e" gnus-summary-edit-parameters
1628 "\M-\C-a" gnus-summary-customize-parameters
1630 "*" gnus-cache-enter-article
1631 "\M-*" gnus-cache-remove-article
1632 "\M-&" gnus-summary-universal-argument
1633 "\C-l" gnus-recenter
1634 "I" gnus-summary-increase-score
1635 "L" gnus-summary-lower-score
1636 "\M-i" gnus-symbolic-argument
1637 "h" gnus-summary-select-article-buffer
1639 "b" gnus-article-view-part
1640 "\M-t" gnus-summary-toggle-display-buttonized
1642 "V" gnus-summary-score-map
1643 "X" gnus-uu-extract-map
1644 "S" gnus-summary-send-map)
1646 ;; Sort of orthogonal keymap
1647 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1648 "t" gnus-summary-tick-article-forward
1649 "!" gnus-summary-tick-article-forward
1650 "d" gnus-summary-mark-as-read-forward
1651 "r" gnus-summary-mark-as-read-forward
1652 "c" gnus-summary-clear-mark-forward
1653 " " gnus-summary-clear-mark-forward
1654 "e" gnus-summary-mark-as-expirable
1655 "x" gnus-summary-mark-as-expirable
1656 "?" gnus-summary-mark-as-dormant
1657 "b" gnus-summary-set-bookmark
1658 "B" gnus-summary-remove-bookmark
1659 "#" gnus-summary-mark-as-processable
1660 "\M-#" gnus-summary-unmark-as-processable
1661 "S" gnus-summary-limit-include-expunged
1662 "C" gnus-summary-catchup
1663 "H" gnus-summary-catchup-to-here
1664 "h" gnus-summary-catchup-from-here
1665 "\C-c" gnus-summary-catchup-all
1666 "k" gnus-summary-kill-same-subject-and-select
1667 "K" gnus-summary-kill-same-subject
1668 "P" gnus-uu-mark-map)
1670 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1671 "c" gnus-summary-clear-above
1672 "u" gnus-summary-tick-above
1673 "m" gnus-summary-mark-above
1674 "k" gnus-summary-kill-below)
1676 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1677 "/" gnus-summary-limit-to-subject
1678 "n" gnus-summary-limit-to-articles
1679 "w" gnus-summary-pop-limit
1680 "s" gnus-summary-limit-to-subject
1681 "a" gnus-summary-limit-to-author
1682 "u" gnus-summary-limit-to-unread
1683 "m" gnus-summary-limit-to-marks
1684 "M" gnus-summary-limit-exclude-marks
1685 "v" gnus-summary-limit-to-score
1686 "*" gnus-summary-limit-include-cached
1687 "D" gnus-summary-limit-include-dormant
1688 "T" gnus-summary-limit-include-thread
1689 "d" gnus-summary-limit-exclude-dormant
1690 "t" gnus-summary-limit-to-age
1691 "." gnus-summary-limit-to-unseen
1692 "x" gnus-summary-limit-to-extra
1693 "p" gnus-summary-limit-to-display-predicate
1694 "E" gnus-summary-limit-include-expunged
1695 "c" gnus-summary-limit-exclude-childless-dormant
1696 "C" gnus-summary-limit-mark-excluded-as-read
1697 "o" gnus-summary-insert-old-articles
1698 "N" gnus-summary-insert-new-articles)
1700 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1701 "n" gnus-summary-next-unread-article
1702 "p" gnus-summary-prev-unread-article
1703 "N" gnus-summary-next-article
1704 "P" gnus-summary-prev-article
1705 "\C-n" gnus-summary-next-same-subject
1706 "\C-p" gnus-summary-prev-same-subject
1707 "\M-n" gnus-summary-next-unread-subject
1708 "\M-p" gnus-summary-prev-unread-subject
1709 "f" gnus-summary-first-unread-article
1710 "b" gnus-summary-best-unread-article
1711 "j" gnus-summary-goto-article
1712 "g" gnus-summary-goto-subject
1713 "l" gnus-summary-goto-last-article
1714 "o" gnus-summary-pop-article)
1716 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1717 "k" gnus-summary-kill-thread
1718 "l" gnus-summary-lower-thread
1719 "i" gnus-summary-raise-thread
1720 "T" gnus-summary-toggle-threads
1721 "t" gnus-summary-rethread-current
1722 "^" gnus-summary-reparent-thread
1723 "s" gnus-summary-show-thread
1724 "S" gnus-summary-show-all-threads
1725 "h" gnus-summary-hide-thread
1726 "H" gnus-summary-hide-all-threads
1727 "n" gnus-summary-next-thread
1728 "p" gnus-summary-prev-thread
1729 "u" gnus-summary-up-thread
1730 "o" gnus-summary-top-thread
1731 "d" gnus-summary-down-thread
1732 "#" gnus-uu-mark-thread
1733 "\M-#" gnus-uu-unmark-thread)
1735 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1736 "g" gnus-summary-prepare
1737 "c" gnus-summary-insert-cached-articles
1738 "d" gnus-summary-insert-dormant-articles)
1740 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1741 "c" gnus-summary-catchup-and-exit
1742 "C" gnus-summary-catchup-all-and-exit
1743 "E" gnus-summary-exit-no-update
1744 "Q" gnus-summary-exit
1745 "Z" gnus-summary-exit
1746 "n" gnus-summary-catchup-and-goto-next-group
1747 "R" gnus-summary-reselect-current-group
1748 "G" gnus-summary-rescan-group
1749 "N" gnus-summary-next-group
1750 "s" gnus-summary-save-newsrc
1751 "P" gnus-summary-prev-group)
1753 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1754 " " gnus-summary-next-page
1755 "n" gnus-summary-next-page
1756 "\177" gnus-summary-prev-page
1757 [delete] gnus-summary-prev-page
1758 "p" gnus-summary-prev-page
1759 "\r" gnus-summary-scroll-up
1760 "\M-\r" gnus-summary-scroll-down
1761 "<" gnus-summary-beginning-of-article
1762 ">" gnus-summary-end-of-article
1763 "b" gnus-summary-beginning-of-article
1764 "e" gnus-summary-end-of-article
1765 "^" gnus-summary-refer-parent-article
1766 "r" gnus-summary-refer-parent-article
1767 "D" gnus-summary-enter-digest-group
1768 "R" gnus-summary-refer-references
1769 "T" gnus-summary-refer-thread
1770 "g" gnus-summary-show-article
1771 "s" gnus-summary-isearch-article
1772 "P" gnus-summary-print-article
1773 "M" gnus-mailing-list-insinuate
1774 "t" gnus-article-babel)
1776 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1777 "b" gnus-article-add-buttons
1778 "B" gnus-article-add-buttons-to-head
1779 "o" gnus-article-treat-overstrike
1780 "e" gnus-article-emphasize
1781 "w" gnus-article-fill-cited-article
1782 "Q" gnus-article-fill-long-lines
1783 "C" gnus-article-capitalize-sentences
1784 "c" gnus-article-remove-cr
1785 "q" gnus-article-de-quoted-unreadable
1786 "6" gnus-article-de-base64-unreadable
1787 "Z" gnus-article-decode-HZ
1788 "h" gnus-article-wash-html
1789 "u" gnus-article-unsplit-urls
1790 "s" gnus-summary-force-verify-and-decrypt
1791 "f" gnus-article-display-x-face
1792 "l" gnus-summary-stop-page-breaking
1793 "r" gnus-summary-caesar-message
1794 "m" gnus-summary-morse-message
1795 "t" gnus-summary-toggle-header
1796 "g" gnus-treat-smiley
1797 "v" gnus-summary-verbose-headers
1798 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1799 "p" gnus-article-verify-x-pgp-sig
1800 "d" gnus-article-treat-dumbquotes)
1802 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1803 ;; mnemonic: deuglif*Y*
1804 "u" gnus-article-outlook-unwrap-lines
1805 "a" gnus-article-outlook-repair-attribution
1806 "c" gnus-article-outlook-rearrange-citation
1807 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1809 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1810 "a" gnus-article-hide
1811 "h" gnus-article-hide-headers
1812 "b" gnus-article-hide-boring-headers
1813 "s" gnus-article-hide-signature
1814 "c" gnus-article-hide-citation
1815 "C" gnus-article-hide-citation-in-followups
1816 "l" gnus-article-hide-list-identifiers
1817 "p" gnus-article-hide-pgp
1818 "B" gnus-article-strip-banner
1819 "P" gnus-article-hide-pem
1820 "\C-c" gnus-article-hide-citation-maybe)
1822 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1823 "a" gnus-article-highlight
1824 "h" gnus-article-highlight-headers
1825 "c" gnus-article-highlight-citation
1826 "s" gnus-article-highlight-signature)
1828 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1829 "f" gnus-article-treat-fold-headers
1830 "u" gnus-article-treat-unfold-headers
1831 "n" gnus-article-treat-fold-newsgroups)
1833 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1834 "x" gnus-article-display-x-face
1835 "d" gnus-article-display-face
1836 "s" gnus-treat-smiley
1837 "D" gnus-article-remove-images
1838 "f" gnus-treat-from-picon
1839 "m" gnus-treat-mail-picon
1840 "n" gnus-treat-newsgroups-picon)
1842 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1843 "w" gnus-article-decode-mime-words
1844 "c" gnus-article-decode-charset
1845 "v" gnus-mime-view-all-parts
1846 "b" gnus-article-view-part)
1848 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1849 "z" gnus-article-date-ut
1850 "u" gnus-article-date-ut
1851 "l" gnus-article-date-local
1852 "p" gnus-article-date-english
1853 "e" gnus-article-date-lapsed
1854 "o" gnus-article-date-original
1855 "i" gnus-article-date-iso8601
1856 "s" gnus-article-date-user)
1858 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1859 "t" gnus-article-remove-trailing-blank-lines
1860 "l" gnus-article-strip-leading-blank-lines
1861 "m" gnus-article-strip-multiple-blank-lines
1862 "a" gnus-article-strip-blank-lines
1863 "A" gnus-article-strip-all-blank-lines
1864 "s" gnus-article-strip-leading-space
1865 "e" gnus-article-strip-trailing-space
1866 "w" gnus-article-remove-leading-whitespace)
1868 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1870 "f" gnus-summary-fetch-faq
1871 "d" gnus-summary-describe-group
1872 "h" gnus-summary-describe-briefly
1873 "i" gnus-info-find-node
1874 "c" gnus-group-fetch-charter
1875 "C" gnus-group-fetch-control)
1877 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1878 "e" gnus-summary-expire-articles
1879 "\M-\C-e" gnus-summary-expire-articles-now
1880 "\177" gnus-summary-delete-article
1881 [delete] gnus-summary-delete-article
1882 [backspace] gnus-summary-delete-article
1883 "m" gnus-summary-move-article
1884 "r" gnus-summary-respool-article
1885 "w" gnus-summary-edit-article
1886 "c" gnus-summary-copy-article
1887 "B" gnus-summary-crosspost-article
1888 "q" gnus-summary-respool-query
1889 "t" gnus-summary-respool-trace
1890 "i" gnus-summary-import-article
1891 "I" gnus-summary-create-article
1892 "p" gnus-summary-article-posted-p)
1894 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1895 "o" gnus-summary-save-article
1896 "m" gnus-summary-save-article-mail
1897 "F" gnus-summary-write-article-file
1898 "r" gnus-summary-save-article-rmail
1899 "f" gnus-summary-save-article-file
1900 "b" gnus-summary-save-article-body-file
1901 "h" gnus-summary-save-article-folder
1902 "v" gnus-summary-save-article-vm
1903 "p" gnus-summary-pipe-output
1904 "P" gnus-summary-muttprint
1905 "s" gnus-soup-add-article)
1907 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1908 "b" gnus-summary-display-buttonized
1909 "m" gnus-summary-repair-multipart
1910 "v" gnus-article-view-part
1911 "o" gnus-article-save-part
1912 "c" gnus-article-copy-part
1913 "C" gnus-article-view-part-as-charset
1914 "e" gnus-article-view-part-externally
1915 "E" gnus-article-encrypt-body
1916 "i" gnus-article-inline-part
1917 "|" gnus-article-pipe-part)
1919 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1920 "p" gnus-summary-mark-as-processable
1921 "u" gnus-summary-unmark-as-processable
1922 "U" gnus-summary-unmark-all-processable
1923 "v" gnus-uu-mark-over
1924 "s" gnus-uu-mark-series
1925 "r" gnus-uu-mark-region
1926 "g" gnus-uu-unmark-region
1927 "R" gnus-uu-mark-by-regexp
1928 "G" gnus-uu-unmark-by-regexp
1929 "t" gnus-uu-mark-thread
1930 "T" gnus-uu-unmark-thread
1931 "a" gnus-uu-mark-all
1932 "b" gnus-uu-mark-buffer
1933 "S" gnus-uu-mark-sparse
1934 "k" gnus-summary-kill-process-mark
1935 "y" gnus-summary-yank-process-mark
1936 "w" gnus-summary-save-process-mark
1937 "i" gnus-uu-invert-processable)
1939 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1940 ;;"x" gnus-uu-extract-any
1941 "m" gnus-summary-save-parts
1942 "u" gnus-uu-decode-uu
1943 "U" gnus-uu-decode-uu-and-save
1944 "s" gnus-uu-decode-unshar
1945 "S" gnus-uu-decode-unshar-and-save
1946 "o" gnus-uu-decode-save
1947 "O" gnus-uu-decode-save
1948 "b" gnus-uu-decode-binhex
1949 "B" gnus-uu-decode-binhex
1950 "p" gnus-uu-decode-postscript
1951 "P" gnus-uu-decode-postscript-and-save)
1954 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1955 "u" gnus-uu-decode-uu-view
1956 "U" gnus-uu-decode-uu-and-save-view
1957 "s" gnus-uu-decode-unshar-view
1958 "S" gnus-uu-decode-unshar-and-save-view
1959 "o" gnus-uu-decode-save-view
1960 "O" gnus-uu-decode-save-view
1961 "b" gnus-uu-decode-binhex-view
1962 "B" gnus-uu-decode-binhex-view
1963 "p" gnus-uu-decode-postscript-view
1964 "P" gnus-uu-decode-postscript-and-save-view)
1966 (defvar gnus-article-post-menu nil)
1968 (defconst gnus-summary-menu-maxlen 20)
1970 (defun gnus-summary-menu-split (menu)
1971 ;; If we have lots of elements, divide them into groups of 20
1972 ;; and make a pane (or submenu) for each one.
1973 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1974 (let ((menu menu) sublists next
1977 ;; Pull off the next gnus-summary-menu-maxlen elements
1978 ;; and make them the next element of sublist.
1979 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1981 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1983 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1984 (aref (car (last menu)) 0)) menu)
1988 (nreverse sublists))
1989 ;; Few elements--put them all in one pane.
1992 (defun gnus-summary-make-menu-bar ()
1993 (gnus-turn-off-edit-menu 'summary)
1995 (unless (boundp 'gnus-summary-misc-menu)
1998 gnus-summary-kill-menu gnus-summary-mode-map ""
2003 ["Customize" gnus-score-customize t])
2004 (gnus-make-score-map 'increase)
2005 (gnus-make-score-map 'lower)
2007 ["Kill below" gnus-summary-kill-below t]
2008 ["Mark above" gnus-summary-mark-above t]
2009 ["Tick above" gnus-summary-tick-above t]
2010 ["Clear above" gnus-summary-clear-above t])
2011 ["Current score" gnus-summary-current-score t]
2012 ["Set score" gnus-summary-set-score t]
2013 ["Switch current score file..." gnus-score-change-score-file t]
2014 ["Set mark below..." gnus-score-set-mark-below t]
2015 ["Set expunge below..." gnus-score-set-expunge-below t]
2016 ["Edit current score file" gnus-score-edit-current-scores t]
2017 ["Edit score file" gnus-score-edit-file t]
2018 ["Trace score" gnus-score-find-trace t]
2019 ["Find words" gnus-score-find-favourite-words t]
2020 ["Rescore buffer" gnus-summary-rescore t]
2021 ["Increase score..." gnus-summary-increase-score t]
2022 ["Lower score..." gnus-summary-lower-score t]))))
2024 ;; Define both the Article menu in the summary buffer and the
2025 ;; equivalent Commands menu in the article buffer here for
2029 ["All" gnus-article-hide t]
2030 ["Headers" gnus-article-hide-headers t]
2031 ["Signature" gnus-article-hide-signature t]
2032 ["Citation" gnus-article-hide-citation t]
2033 ["List identifiers" gnus-article-hide-list-identifiers t]
2034 ["PGP" gnus-article-hide-pgp 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]))
2347 ["Page forward" gnus-summary-next-page
2348 ,@(if (featurep 'xemacs) '(t)
2349 '(:help "Show next page of article"))]
2350 ["Page backward" gnus-summary-prev-page
2351 ,@(if (featurep 'xemacs) '(t)
2352 '(:help "Show previous page of article"))]
2353 ["Line forward" gnus-summary-scroll-up t])
2355 ["Next unread article" gnus-summary-next-unread-article t]
2356 ["Previous unread article" gnus-summary-prev-unread-article t]
2357 ["Next article" gnus-summary-next-article t]
2358 ["Previous article" gnus-summary-prev-article t]
2359 ["Next unread subject" gnus-summary-next-unread-subject t]
2360 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2361 ["Next article same subject" gnus-summary-next-same-subject t]
2362 ["Previous article same subject" gnus-summary-prev-same-subject t]
2363 ["First unread article" gnus-summary-first-unread-article t]
2364 ["Best unread article" gnus-summary-best-unread-article t]
2365 ["Go to subject number..." gnus-summary-goto-subject t]
2366 ["Go to article number..." gnus-summary-goto-article t]
2367 ["Go to the last article" gnus-summary-goto-last-article t]
2368 ["Pop article off history" gnus-summary-pop-article t])
2370 ["Sort by number" gnus-summary-sort-by-number t]
2371 ["Sort by author" gnus-summary-sort-by-author t]
2372 ["Sort by subject" gnus-summary-sort-by-subject t]
2373 ["Sort by date" gnus-summary-sort-by-date t]
2374 ["Sort by score" gnus-summary-sort-by-score t]
2375 ["Sort by lines" gnus-summary-sort-by-lines t]
2376 ["Sort by characters" gnus-summary-sort-by-chars t]
2377 ["Randomize" gnus-summary-sort-by-random t]
2378 ["Original sort" gnus-summary-sort-by-original t])
2380 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2381 ["Describe group" gnus-summary-describe-group t]
2382 ["Fetch charter" gnus-group-fetch-charter
2383 ,@(if (featurep 'xemacs) nil
2384 '(:help "Display the charter of the current group"))]
2385 ["Fetch control message" gnus-group-fetch-control
2386 ,@(if (featurep 'xemacs) nil
2387 '(:help "Display the archived control message for the current group"))]
2388 ["Read manual" gnus-info-find-node t])
2390 ["Pick and read" gnus-pick-mode t]
2391 ["Binary" gnus-binary-mode t])
2393 ["Regenerate" gnus-summary-prepare t]
2394 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2395 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2396 ["Toggle threading" gnus-summary-toggle-threads t])
2397 ["See old articles" gnus-summary-insert-old-articles t]
2398 ["See new articles" gnus-summary-insert-new-articles t]
2399 ["Filter articles..." gnus-summary-execute-command t]
2400 ["Run command on subjects..." gnus-summary-universal-argument t]
2401 ["Search articles forward..." gnus-summary-search-article-forward t]
2402 ["Search articles backward..." gnus-summary-search-article-backward t]
2403 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2404 ["Expand window" gnus-summary-expand-window t]
2405 ["Expire expirable articles" gnus-summary-expire-articles
2406 (gnus-check-backend-function
2407 'request-expire-articles gnus-newsgroup-name)]
2408 ["Edit local kill file" gnus-summary-edit-local-kill t]
2409 ["Edit main kill file" gnus-summary-edit-global-kill t]
2410 ["Edit group parameters" gnus-summary-edit-parameters t]
2411 ["Customize group parameters" gnus-summary-customize-parameters t]
2412 ["Send a bug report" gnus-bug t]
2414 ["Catchup and exit" gnus-summary-catchup-and-exit
2415 ,@(if (featurep 'xemacs) '(t)
2416 '(:help "Mark unread articles in this group as read, then exit"))]
2417 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2418 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2419 ["Exit group" gnus-summary-exit
2420 ,@(if (featurep 'xemacs) '(t)
2421 '(:help "Exit current group, return to group selection mode"))]
2422 ["Exit group without updating" gnus-summary-exit-no-update t]
2423 ["Exit and goto next group" gnus-summary-next-group t]
2424 ["Exit and goto prev group" gnus-summary-prev-group t]
2425 ["Reselect group" gnus-summary-reselect-current-group t]
2426 ["Rescan group" gnus-summary-rescan-group t]
2427 ["Update dribble" gnus-summary-save-newsrc t])))
2429 (gnus-run-hooks 'gnus-summary-menu-hook)))
2431 (defvar gnus-summary-tool-bar-map nil)
2433 ;; Emacs 21 tool bar. Should be no-op otherwise.
2434 (defun gnus-summary-make-tool-bar ()
2435 (if (and (fboundp 'tool-bar-add-item-from-menu)
2436 (default-value 'tool-bar-mode)
2437 (not gnus-summary-tool-bar-map))
2438 (setq gnus-summary-tool-bar-map
2439 (let ((tool-bar-map (make-sparse-keymap))
2440 (load-path (mm-image-load-path)))
2441 (tool-bar-add-item-from-menu
2442 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2443 (tool-bar-add-item-from-menu
2444 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2445 (tool-bar-add-item-from-menu
2446 'gnus-summary-post-news "post" gnus-summary-mode-map)
2447 (tool-bar-add-item-from-menu
2448 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2449 (tool-bar-add-item-from-menu
2450 'gnus-summary-followup "followup" gnus-summary-mode-map)
2451 (tool-bar-add-item-from-menu
2452 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2453 (tool-bar-add-item-from-menu
2454 'gnus-summary-reply "reply" gnus-summary-mode-map)
2455 (tool-bar-add-item-from-menu
2456 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2457 (tool-bar-add-item-from-menu
2458 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2459 (tool-bar-add-item-from-menu
2460 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2461 (tool-bar-add-item-from-menu
2462 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2463 (tool-bar-add-item-from-menu
2464 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2465 (tool-bar-add-item-from-menu
2466 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2467 (tool-bar-add-item-from-menu
2468 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2469 (tool-bar-add-item-from-menu
2470 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2472 (if gnus-summary-tool-bar-map
2473 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2475 (defun gnus-score-set-default (var value)
2476 "A version of set that updates the GNU Emacs menu-bar."
2478 ;; It is the message that forces the active status to be updated.
2481 (defun gnus-make-score-map (type)
2482 "Make a summary score map of type TYPE."
2485 (let ((headers '(("author" "from" string)
2486 ("subject" "subject" string)
2487 ("article body" "body" string)
2488 ("article head" "head" string)
2489 ("xref" "xref" string)
2490 ("extra header" "extra" string)
2491 ("lines" "lines" number)
2492 ("followups to author" "followup" string)))
2493 (types '((number ("less than" <)
2496 (string ("substring" s)
2500 (perms '(("temporary" (current-time-string))
2508 (if (eq type 'lower)
2513 (setq header (car headers))
2519 (let ((ts (cdr (assoc (nth 2 header) types)))
2535 'gnus-summary-score-entry
2537 (if (or (string= (nth 1 header)
2539 (string= (nth 1 header)
2542 (list 'gnus-summary-header
2544 (list 'quote (nth 1 (car ts)))
2545 (list 'gnus-score-delta-default
2552 (list (nreverse outp))))
2555 (list (nreverse outt))))
2557 (setq headers (cdr headers)))
2558 (list (nreverse outh))))))))
2562 (defun gnus-summary-mode (&optional group)
2563 "Major mode for reading articles.
2565 All normal editing commands are switched off.
2566 \\<gnus-summary-mode-map>
2567 Each line in this buffer represents one article. To read an
2568 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2569 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2572 You can also post articles and send mail from this buffer. To
2573 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2574 of an article, type `\\[gnus-summary-reply]'.
2576 There are approx. one gazillion commands you can execute in this
2577 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2579 The following commands are available:
2581 \\{gnus-summary-mode-map}"
2583 (kill-all-local-variables)
2584 (when (gnus-visual-p 'summary-menu 'menu)
2585 (gnus-summary-make-menu-bar)
2586 (gnus-summary-make-tool-bar))
2587 (gnus-summary-make-local-variables)
2588 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2589 (gnus-summary-make-local-variables))
2590 (gnus-make-thread-indent-array)
2591 (gnus-simplify-mode-line)
2592 (setq major-mode 'gnus-summary-mode)
2593 (setq mode-name "Summary")
2594 (make-local-variable 'minor-mode-alist)
2595 (use-local-map gnus-summary-mode-map)
2596 (buffer-disable-undo)
2597 (setq buffer-read-only t) ;Disable modification
2598 (setq truncate-lines t)
2599 (setq selective-display t)
2600 (setq selective-display-ellipses t) ;Display `...'
2601 (gnus-summary-set-display-table)
2602 (gnus-set-default-directory)
2603 (setq gnus-newsgroup-name group)
2604 (make-local-variable 'gnus-summary-line-format)
2605 (make-local-variable 'gnus-summary-line-format-spec)
2606 (make-local-variable 'gnus-summary-dummy-line-format)
2607 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2608 (make-local-variable 'gnus-summary-mark-positions)
2609 (make-local-hook 'pre-command-hook)
2610 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2611 (gnus-run-hooks 'gnus-summary-mode-hook)
2612 (turn-on-gnus-mailing-list-mode)
2613 (mm-enable-multibyte)
2614 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2615 (gnus-update-summary-mark-positions))
2617 (defun gnus-summary-make-local-variables ()
2618 "Make all the local summary buffer variables."
2620 (dolist (local gnus-summary-local-variables)
2623 (if (eq (cdr local) 'global)
2624 ;; Copy the global value of the variable.
2625 (setq global (symbol-value (car local)))
2626 ;; Use the value from the list.
2627 (setq global (eval (cdr local))))
2628 (set (make-local-variable (car local)) global))
2629 ;; Simple nil-valued local variable.
2630 (set (make-local-variable local) nil)))))
2632 (defun gnus-summary-clear-local-variables ()
2633 (let ((locals gnus-summary-local-variables))
2635 (if (consp (car locals))
2636 (and (vectorp (caar locals))
2637 (set (caar locals) nil))
2638 (and (vectorp (car locals))
2639 (set (car locals) nil)))
2640 (setq locals (cdr locals)))))
2642 ;; Summary data functions.
2644 (defmacro gnus-data-number (data)
2647 (defmacro gnus-data-set-number (data number)
2648 `(setcar ,data ,number))
2650 (defmacro gnus-data-mark (data)
2653 (defmacro gnus-data-set-mark (data mark)
2654 `(setcar (nthcdr 1 ,data) ,mark))
2656 (defmacro gnus-data-pos (data)
2659 (defmacro gnus-data-set-pos (data pos)
2660 `(setcar (nthcdr 2 ,data) ,pos))
2662 (defmacro gnus-data-header (data)
2665 (defmacro gnus-data-set-header (data header)
2666 `(setf (nth 3 ,data) ,header))
2668 (defmacro gnus-data-level (data)
2671 (defmacro gnus-data-unread-p (data)
2672 `(= (nth 1 ,data) gnus-unread-mark))
2674 (defmacro gnus-data-read-p (data)
2675 `(/= (nth 1 ,data) gnus-unread-mark))
2677 (defmacro gnus-data-pseudo-p (data)
2678 `(consp (nth 3 ,data)))
2680 (defmacro gnus-data-find (number)
2681 `(assq ,number gnus-newsgroup-data))
2683 (defmacro gnus-data-find-list (number &optional data)
2684 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2685 (memq (assq ,number bdata)
2688 (defmacro gnus-data-make (number mark pos header level)
2689 `(list ,number ,mark ,pos ,header ,level))
2691 (defun gnus-data-enter (after-article number mark pos header level offset)
2692 (let ((data (gnus-data-find-list after-article)))
2694 (error "No such article: %d" after-article))
2695 (setcdr data (cons (gnus-data-make number mark pos header level)
2697 (setq gnus-newsgroup-data-reverse nil)
2698 (gnus-data-update-list (cddr data) offset)))
2700 (defun gnus-data-enter-list (after-article list &optional offset)
2702 (let ((data (and after-article (gnus-data-find-list after-article)))
2706 (let ((odata gnus-newsgroup-data))
2707 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2709 (gnus-data-update-list odata offset)))
2710 ;; Find the last element in the list to be spliced into the main
2713 (setq list (cdr list)))
2716 (setcdr list gnus-newsgroup-data)
2717 (setq gnus-newsgroup-data ilist)
2719 (gnus-data-update-list (cdr list) offset)))
2720 (setcdr list (cdr data))
2723 (gnus-data-update-list (cdr list) offset))))
2724 (setq gnus-newsgroup-data-reverse nil))))
2726 (defun gnus-data-remove (article &optional offset)
2727 (let ((data gnus-newsgroup-data))
2728 (if (= (gnus-data-number (car data)) article)
2730 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2731 gnus-newsgroup-data-reverse nil)
2733 (gnus-data-update-list gnus-newsgroup-data offset)))
2735 (when (= (gnus-data-number (cadr data)) article)
2736 (setcdr data (cddr data))
2738 (gnus-data-update-list (cdr data) offset))
2740 gnus-newsgroup-data-reverse nil))
2741 (setq data (cdr data))))))
2743 (defmacro gnus-data-list (backward)
2745 (or gnus-newsgroup-data-reverse
2746 (setq gnus-newsgroup-data-reverse
2747 (reverse gnus-newsgroup-data)))
2748 gnus-newsgroup-data))
2750 (defun gnus-data-update-list (data offset)
2751 "Add OFFSET to the POS of all data entries in DATA."
2752 (setq gnus-newsgroup-data-reverse nil)
2754 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2755 (setq data (cdr data))))
2757 (defun gnus-summary-article-pseudo-p (article)
2758 "Say whether this article is a pseudo article or not."
2759 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2761 (defmacro gnus-summary-article-sparse-p (article)
2762 "Say whether this article is a sparse article or not."
2763 `(memq ,article gnus-newsgroup-sparse))
2765 (defmacro gnus-summary-article-ancient-p (article)
2766 "Say whether this article is a sparse article or not."
2767 `(memq ,article gnus-newsgroup-ancient))
2769 (defun gnus-article-parent-p (number)
2770 "Say whether this article is a parent or not."
2771 (let ((data (gnus-data-find-list number)))
2772 (and (cdr data) ; There has to be an article after...
2773 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2774 (gnus-data-level (nth 1 data))))))
2776 (defun gnus-article-children (number)
2777 "Return a list of all children to NUMBER."
2778 (let* ((data (gnus-data-find-list number))
2779 (level (gnus-data-level (car data)))
2781 (setq data (cdr data))
2783 (= (gnus-data-level (car data)) (1+ level)))
2784 (push (gnus-data-number (car data)) children)
2785 (setq data (cdr data)))
2788 (defmacro gnus-summary-skip-intangible ()
2789 "If the current article is intangible, then jump to a different article."
2790 '(let ((to (get-text-property (point) 'gnus-intangible)))
2791 (and to (gnus-summary-goto-subject to))))
2793 (defmacro gnus-summary-article-intangible-p ()
2794 "Say whether this article is intangible or not."
2795 '(get-text-property (point) 'gnus-intangible))
2797 (defun gnus-article-read-p (article)
2798 "Say whether ARTICLE is read or not."
2799 (not (or (memq article gnus-newsgroup-marked)
2800 (memq article gnus-newsgroup-spam-marked)
2801 (memq article gnus-newsgroup-unreads)
2802 (memq article gnus-newsgroup-unselected)
2803 (memq article gnus-newsgroup-dormant))))
2805 ;; Some summary mode macros.
2807 (defmacro gnus-summary-article-number ()
2808 "The article number of the article on the current line.
2809 If there isn't an article number here, then we return the current
2812 (gnus-summary-skip-intangible)
2813 (or (get-text-property (point) 'gnus-number)
2814 (gnus-summary-last-subject))))
2816 (defmacro gnus-summary-article-header (&optional number)
2817 "Return the header of article NUMBER."
2818 `(gnus-data-header (gnus-data-find
2819 ,(or number '(gnus-summary-article-number)))))
2821 (defmacro gnus-summary-thread-level (&optional number)
2822 "Return the level of thread that starts with article NUMBER."
2823 `(if (and (eq gnus-summary-make-false-root 'dummy)
2824 (get-text-property (point) 'gnus-intangible))
2826 (gnus-data-level (gnus-data-find
2827 ,(or number '(gnus-summary-article-number))))))
2829 (defmacro gnus-summary-article-mark (&optional number)
2830 "Return the mark of article NUMBER."
2831 `(gnus-data-mark (gnus-data-find
2832 ,(or number '(gnus-summary-article-number)))))
2834 (defmacro gnus-summary-article-pos (&optional number)
2835 "Return the position of the line of article NUMBER."
2836 `(gnus-data-pos (gnus-data-find
2837 ,(or number '(gnus-summary-article-number)))))
2839 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2840 (defmacro gnus-summary-article-subject (&optional number)
2841 "Return current subject string or nil if nothing."
2844 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2845 '(gnus-data-header (assq (gnus-summary-article-number)
2846 gnus-newsgroup-data)))))
2849 (mail-header-subject headers))))
2851 (defmacro gnus-summary-article-score (&optional number)
2852 "Return current article score."
2853 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2854 gnus-newsgroup-scored))
2855 gnus-summary-default-score 0))
2857 (defun gnus-summary-article-children (&optional number)
2858 "Return a list of article numbers that are children of article NUMBER."
2859 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2860 (level (gnus-data-level (car data)))
2862 (while (and (setq data (cdr data))
2863 (> (setq l (gnus-data-level (car data))) level))
2864 (and (= (1+ level) l)
2865 (push (gnus-data-number (car data))
2867 (nreverse children)))
2869 (defun gnus-summary-article-parent (&optional number)
2870 "Return the article number of the parent of article NUMBER."
2871 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2872 (gnus-data-list t)))
2873 (level (gnus-data-level (car data))))
2875 () ; This is a root.
2876 ;; We search until we find an article with a level less than
2877 ;; this one. That function has to be the parent.
2878 (while (and (setq data (cdr data))
2879 (not (< (gnus-data-level (car data)) level))))
2880 (and data (gnus-data-number (car data))))))
2882 (defun gnus-unread-mark-p (mark)
2883 "Say whether MARK is the unread mark."
2884 (= mark gnus-unread-mark))
2886 (defun gnus-read-mark-p (mark)
2887 "Say whether MARK is one of the marks that mark as read.
2888 This is all marks except unread, ticked, dormant, and expirable."
2889 (not (or (= mark gnus-unread-mark)
2890 (= mark gnus-ticked-mark)
2891 (= mark gnus-spam-mark)
2892 (= mark gnus-dormant-mark)
2893 (= mark gnus-expirable-mark))))
2895 (defmacro gnus-article-mark (number)
2896 "Return the MARK of article NUMBER.
2897 This macro should only be used when computing the mark the \"first\"
2898 time; i.e., when generating the summary lines. After that,
2899 `gnus-summary-article-mark' should be used to examine the
2902 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2903 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2904 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2905 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2906 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2907 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2908 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2909 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2910 gnus-ancient-mark))))
2912 ;; Saving hidden threads.
2914 (defmacro gnus-save-hidden-threads (&rest forms)
2915 "Save hidden threads, eval FORMS, and restore the hidden threads."
2916 (let ((config (make-symbol "config")))
2917 `(let ((,config (gnus-hidden-threads-configuration)))
2921 (gnus-restore-hidden-threads-configuration ,config)))))
2922 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2923 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2925 (defun gnus-data-compute-positions ()
2926 "Compute the positions of all articles."
2927 (setq gnus-newsgroup-data-reverse nil)
2928 (let ((data gnus-newsgroup-data))
2930 (gnus-save-hidden-threads
2931 (gnus-summary-show-all-threads)
2932 (goto-char (point-min))
2934 (while (get-text-property (point) 'gnus-intangible)
2936 (gnus-data-set-pos (car data) (+ (point) 3))
2937 (setq data (cdr data))
2938 (forward-line 1))))))
2940 (defun gnus-hidden-threads-configuration ()
2941 "Return the current hidden threads configuration."
2944 (goto-char (point-min))
2945 (while (search-forward "\r" nil t)
2946 (push (1- (point)) config))
2949 (defun gnus-restore-hidden-threads-configuration (config)
2950 "Restore hidden threads configuration from CONFIG."
2952 (let (point buffer-read-only)
2953 (while (setq point (pop config))
2954 (when (and (< point (point-max))
2956 (eq (char-after) ?\n))
2957 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2959 ;; Various summary mode internalish functions.
2961 (defun gnus-mouse-pick-article (e)
2964 (gnus-summary-next-page nil t))
2966 (defun gnus-summary-set-display-table ()
2967 "Change the display table.
2968 Odd characters have a tendency to mess
2969 up nicely formatted displays - we make all possible glyphs
2970 display only a single character."
2972 ;; We start from the standard display table, if any.
2973 (let ((table (or (copy-sequence standard-display-table)
2974 (make-display-table)))
2976 ;; Nix out all the control chars...
2977 (while (>= (setq i (1- i)) 0)
2978 (aset table i [??]))
2979 ;; ... but not newline and cr, of course. (cr is necessary for the
2980 ;; selective display).
2981 (aset table ?\n nil)
2982 (aset table ?\r nil)
2983 ;; We keep TAB as well.
2984 (aset table ?\t nil)
2985 ;; We nix out any glyphs over 126 that are not set already.
2987 (while (>= (setq i (1- i)) 127)
2988 ;; Only modify if the entry is nil.
2989 (unless (aref table i)
2990 (aset table i [??]))))
2991 (setq buffer-display-table table)))
2993 (defun gnus-summary-set-article-display-arrow (pos)
2994 "Update the overlay arrow to point to line at position POS."
2995 (when (and gnus-summary-display-arrow
2996 (boundp 'overlay-arrow-position)
2997 (boundp 'overlay-arrow-string))
3001 (unless overlay-arrow-position
3002 (setq overlay-arrow-position (make-marker)))
3003 (setq overlay-arrow-string "=>"
3004 overlay-arrow-position (set-marker overlay-arrow-position
3006 (current-buffer))))))
3008 (defun gnus-summary-buffer-name (group)
3009 "Return the summary buffer name of GROUP."
3010 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3012 (defun gnus-summary-setup-buffer (group)
3013 "Initialize summary buffer."
3014 (let ((buffer (gnus-summary-buffer-name group))
3015 (dead-name (concat "*Dead Summary "
3016 (gnus-group-decoded-name group) "*")))
3017 ;; If a dead summary buffer exists, we kill it.
3018 (when (gnus-buffer-live-p dead-name)
3019 (gnus-kill-buffer dead-name))
3020 (if (get-buffer buffer)
3023 (setq gnus-summary-buffer (current-buffer))
3024 (not gnus-newsgroup-prepared))
3025 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3026 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3027 (gnus-summary-mode group)
3029 (gnus-carpal-setup-buffer 'summary))
3030 (unless gnus-single-article-buffer
3031 (make-local-variable 'gnus-article-buffer)
3032 (make-local-variable 'gnus-article-current)
3033 (make-local-variable 'gnus-original-article-buffer))
3034 (setq gnus-newsgroup-name group)
3035 ;; Set any local variables in the group parameters.
3036 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3039 (defun gnus-set-global-variables ()
3040 "Set the global equivalents of the buffer-local variables.
3041 They are set to the latest values they had. These reflect the summary
3042 buffer that was in action when the last article was fetched."
3043 (when (eq major-mode 'gnus-summary-mode)
3044 (setq gnus-summary-buffer (current-buffer))
3045 (let ((name gnus-newsgroup-name)
3046 (marked gnus-newsgroup-marked)
3047 (spam gnus-newsgroup-spam-marked)
3048 (unread gnus-newsgroup-unreads)
3049 (headers gnus-current-headers)
3050 (data gnus-newsgroup-data)
3051 (summary gnus-summary-buffer)
3052 (article-buffer gnus-article-buffer)
3053 (original gnus-original-article-buffer)
3054 (gac gnus-article-current)
3055 (reffed gnus-reffed-article-number)
3056 (score-file gnus-current-score-file)
3057 (default-charset gnus-newsgroup-charset)
3059 (let ((locals gnus-newsgroup-variables))
3061 (if (consp (car locals))
3062 (push (eval (caar locals)) vlist)
3063 (push (eval (car locals)) vlist))
3064 (setq locals (cdr locals)))
3065 (setq vlist (nreverse vlist)))
3067 (set-buffer gnus-group-buffer)
3068 (setq gnus-newsgroup-name name
3069 gnus-newsgroup-marked marked
3070 gnus-newsgroup-spam-marked spam
3071 gnus-newsgroup-unreads unread
3072 gnus-current-headers headers
3073 gnus-newsgroup-data data
3074 gnus-article-current gac
3075 gnus-summary-buffer summary
3076 gnus-article-buffer article-buffer
3077 gnus-original-article-buffer original
3078 gnus-reffed-article-number reffed
3079 gnus-current-score-file score-file
3080 gnus-newsgroup-charset default-charset)
3081 (let ((locals gnus-newsgroup-variables))
3083 (if (consp (car locals))
3084 (set (caar locals) (pop vlist))
3085 (set (car locals) (pop vlist)))
3086 (setq locals (cdr locals))))
3087 ;; The article buffer also has local variables.
3088 (when (gnus-buffer-live-p gnus-article-buffer)
3089 (set-buffer gnus-article-buffer)
3090 (setq gnus-summary-buffer summary))))))
3092 (defun gnus-summary-article-unread-p (article)
3093 "Say whether ARTICLE is unread or not."
3094 (memq article gnus-newsgroup-unreads))
3096 (defun gnus-summary-first-article-p (&optional article)
3097 "Return whether ARTICLE is the first article in the buffer."
3098 (if (not (setq article (or article (gnus-summary-article-number))))
3100 (eq article (caar gnus-newsgroup-data))))
3102 (defun gnus-summary-last-article-p (&optional article)
3103 "Return whether ARTICLE is the last article in the buffer."
3104 (if (not (setq article (or article (gnus-summary-article-number))))
3105 ;; All non-existent numbers are the last article. :-)
3107 (not (cdr (gnus-data-find-list article)))))
3109 (defun gnus-make-thread-indent-array ()
3111 (unless (and gnus-thread-indent-array
3112 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3113 (setq gnus-thread-indent-array (make-vector 201 "")
3114 gnus-thread-indent-array-level gnus-thread-indent-level)
3116 (aset gnus-thread-indent-array n
3117 (make-string (* n gnus-thread-indent-level) ? ))
3120 (defun gnus-update-summary-mark-positions ()
3121 "Compute where the summary marks are to go."
3123 (when (gnus-buffer-exists-p gnus-summary-buffer)
3124 (set-buffer gnus-summary-buffer))
3125 (let ((gnus-replied-mark 129)
3126 (gnus-score-below-mark 130)
3127 (gnus-score-over-mark 130)
3128 (gnus-undownloaded-mark 131)
3129 (spec gnus-summary-line-format-spec)
3132 (gnus-set-work-buffer)
3133 (let ((gnus-summary-line-format-spec spec)
3134 (gnus-newsgroup-downloadable '(0)))
3135 (gnus-summary-insert-line
3136 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3137 0 nil t 128 t nil "" nil 1)
3138 (goto-char (point-min))
3139 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3140 (- (point) (point-min) 1)))))
3141 (goto-char (point-min))
3142 (push (cons 'replied (and (search-forward "\201" nil t)
3143 (- (point) (point-min) 1)))
3145 (goto-char (point-min))
3146 (push (cons 'score (and (search-forward "\202" nil t)
3147 (- (point) (point-min) 1)))
3149 (goto-char (point-min))
3150 (push (cons 'download
3151 (and (search-forward "\203" nil t)
3152 (- (point) (point-min) 1)))
3154 (setq gnus-summary-mark-positions pos))))
3156 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3157 "Insert a dummy root in the summary buffer."
3159 (gnus-add-text-properties
3160 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3161 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3163 (defun gnus-summary-extract-address-component (from)
3164 (or (car (funcall gnus-extract-address-components from))
3167 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3168 (let ((mail-parse-charset gnus-newsgroup-charset)
3169 ; Is it really necessary to do this next part for each summary line?
3170 ; Luckily, doesn't seem to slow things down much.
3171 (mail-parse-ignored-charsets
3172 (save-excursion (set-buffer gnus-summary-buffer)
3173 gnus-newsgroup-ignored-charsets)))
3175 (and gnus-ignored-from-addresses
3176 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3177 (let ((extra-headers (mail-header-extra header))
3181 ((setq to (cdr (assq 'To extra-headers)))
3184 (gnus-summary-extract-address-component
3185 (funcall gnus-decode-encoded-word-function to)))))
3186 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3187 (concat "=> " newsgroups)))))
3188 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3190 (defun gnus-summary-insert-line (gnus-tmp-header
3191 gnus-tmp-level gnus-tmp-current
3192 undownloaded gnus-tmp-unread gnus-tmp-replied
3193 gnus-tmp-expirable gnus-tmp-subject-or-nil
3194 &optional gnus-tmp-dummy gnus-tmp-score
3196 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3197 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3198 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3199 (gnus-tmp-score-char
3200 (if (or (null gnus-summary-default-score)
3201 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3202 gnus-summary-zcore-fuzz))
3204 (if (< gnus-tmp-score gnus-summary-default-score)
3205 gnus-score-below-mark gnus-score-over-mark)))
3206 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3208 (cond (gnus-tmp-process gnus-process-mark)
3209 ((memq gnus-tmp-current gnus-newsgroup-cached)
3211 (gnus-tmp-replied gnus-replied-mark)
3212 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3213 gnus-forwarded-mark)
3214 ((memq gnus-tmp-current gnus-newsgroup-saved)
3216 ((memq gnus-tmp-number gnus-newsgroup-recent)
3218 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3221 (gnus-tmp-downloaded
3223 gnus-undownloaded-mark)
3224 (gnus-newsgroup-agentized
3225 gnus-downloaded-mark)
3228 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3231 ((string-match "<[^>]+> *$" gnus-tmp-from)
3232 (let ((beg (match-beginning 0)))
3233 (or (and (string-match "^\".+\"" gnus-tmp-from)
3234 (substring gnus-tmp-from 1 (1- (match-end 0))))
3235 (substring gnus-tmp-from 0 beg))))
3236 ((string-match "(.+)" gnus-tmp-from)
3237 (substring gnus-tmp-from
3238 (1+ (match-beginning 0)) (1- (match-end 0))))
3240 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3241 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3242 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3243 (buffer-read-only nil))
3244 (when (string= gnus-tmp-name "")
3245 (setq gnus-tmp-name gnus-tmp-from))
3246 (unless (numberp gnus-tmp-lines)
3247 (setq gnus-tmp-lines -1))
3248 (if (= gnus-tmp-lines -1)
3249 (setq gnus-tmp-lines "?")
3250 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3251 (gnus-put-text-property
3253 (progn (eval gnus-summary-line-format-spec) (point))
3254 'gnus-number gnus-tmp-number)
3255 (when (gnus-visual-p 'summary-highlight 'highlight)
3257 (gnus-run-hooks 'gnus-summary-update-hook)
3260 (defun gnus-summary-update-line (&optional dont-update)
3261 "Update summary line after change."
3262 (when (and gnus-summary-default-score
3263 (not gnus-summary-inhibit-highlight))
3264 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3265 (article (gnus-summary-article-number))
3266 (score (gnus-summary-article-score article)))
3268 (if (and gnus-summary-mark-below
3269 (< (gnus-summary-article-score)
3270 gnus-summary-mark-below))
3271 ;; This article has a low score, so we mark it as read.
3272 (when (memq article gnus-newsgroup-unreads)
3273 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3274 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3275 ;; This article was previously marked as read on account
3276 ;; of a low score, but now it has risen, so we mark it as
3278 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3279 (gnus-summary-update-mark
3280 (if (or (null gnus-summary-default-score)
3281 (<= (abs (- score gnus-summary-default-score))
3282 gnus-summary-zcore-fuzz))
3284 (if (< score gnus-summary-default-score)
3285 gnus-score-below-mark gnus-score-over-mark))
3287 ;; Do visual highlighting.
3288 (when (gnus-visual-p 'summary-highlight 'highlight)
3289 (gnus-run-hooks 'gnus-summary-update-hook)))))
3291 (defvar gnus-tmp-new-adopts nil)
3293 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3294 "Return the number of articles in THREAD.
3295 This may be 0 in some cases -- if none of the articles in
3296 the thread are to be displayed."
3298 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3300 ((not (listp thread))
3302 ((and (consp thread) (cdr thread))
3305 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3308 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3311 (when (and level (zerop level) gnus-tmp-new-adopts)
3314 'gnus-summary-number-of-articles-in-thread
3315 gnus-tmp-new-adopts))))
3317 (if (> number 1) gnus-not-empty-thread-mark
3318 gnus-empty-thread-mark)
3321 (defsubst gnus-summary-line-message-size (head)
3322 "Return pretty-printed version of message size.
3323 This function is intended to be used in
3324 `gnus-summary-line-format-alist', which see."
3325 (let ((c (or (mail-header-chars head) -1)))
3326 (cond ((< c 0) "n/a") ; chars not available
3327 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3328 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3329 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3330 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3333 (defun gnus-summary-set-local-parameters (group)
3334 "Go through the local params of GROUP and set all variable specs in that list."
3335 (let ((params (gnus-group-find-parameter group))
3336 (vars '(quit-config)) ; Ignore quit-config.
3339 (setq elem (car params)
3340 params (cdr params))
3341 (and (consp elem) ; Has to be a cons.
3342 (consp (cdr elem)) ; The cdr has to be a list.
3343 (symbolp (car elem)) ; Has to be a symbol in there.
3344 (not (memq (car elem) vars))
3345 (ignore-errors ; So we set it.
3346 (push (car elem) vars)
3347 (make-local-variable (car elem))
3348 (set (car elem) (eval (nth 1 elem))))))))
3350 (defun gnus-summary-read-group (group &optional show-all no-article
3351 kill-buffer no-display backward
3353 "Start reading news in newsgroup GROUP.
3354 If SHOW-ALL is non-nil, already read articles are also listed.
3355 If NO-ARTICLE is non-nil, no article is selected initially.
3356 If NO-DISPLAY, don't generate a summary buffer."
3360 (let ((gnus-auto-select-next nil))
3361 (or (gnus-summary-read-group-1
3362 group show-all no-article
3363 kill-buffer no-display
3366 select-articles nil)))))
3367 (eq gnus-auto-select-next 'quietly))
3368 (set-buffer gnus-group-buffer)
3369 ;; The entry function called above goes to the next
3370 ;; group automatically, so we go two groups back
3371 ;; if we are searching for the previous group.
3373 (gnus-group-prev-unread-group 2))
3374 (if (not (equal group (gnus-group-group-name)))
3375 (setq group (gnus-group-group-name))
3379 (defun gnus-summary-read-group-1 (group show-all no-article
3380 kill-buffer no-display
3381 &optional select-articles)
3382 ;; Killed foreign groups can't be entered.
3383 ;; (when (and (not (gnus-group-native-p group))
3384 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3385 ;; (error "Dead non-native groups can't be entered"))
3386 (gnus-message 5 "Retrieving newsgroup: %s..."
3387 (gnus-group-decoded-name group))
3388 (let* ((new-group (gnus-summary-setup-buffer group))
3389 (quit-config (gnus-group-quit-config group))
3390 (did-select (and new-group (gnus-select-newsgroup
3391 group show-all select-articles))))
3393 ;; This summary buffer exists already, so we just select it.
3395 (gnus-set-global-variables)
3397 (gnus-kill-or-deaden-summary kill-buffer))
3398 (gnus-configure-windows 'summary 'force)
3399 (gnus-set-mode-line 'summary)
3400 (gnus-summary-position-point)
3403 ;; We couldn't select this group.
3405 (when (and (eq major-mode 'gnus-summary-mode)
3406 (not (equal (current-buffer) kill-buffer)))
3407 (kill-buffer (current-buffer))
3408 (if (not quit-config)
3410 ;; Update the info -- marks might need to be removed,
3412 (gnus-summary-update-info)
3413 (set-buffer gnus-group-buffer)
3414 (gnus-group-jump-to-group group)
3415 (gnus-group-next-unread-group 1))
3416 (gnus-handle-ephemeral-exit quit-config)))
3417 (let ((grpinfo (gnus-get-info group)))
3418 (if (null (gnus-info-read grpinfo))
3419 (gnus-message 3 "Group %s contains no messages"
3420 (gnus-group-decoded-name group))
3421 (gnus-message 3 "Can't select group")))
3423 ;; The user did a `C-g' while prompting for number of articles,
3424 ;; so we exit this group.
3425 ((eq did-select 'quit)
3426 (and (eq major-mode 'gnus-summary-mode)
3427 (not (equal (current-buffer) kill-buffer))
3428 (kill-buffer (current-buffer)))
3430 (gnus-kill-or-deaden-summary kill-buffer))
3431 (if (not quit-config)
3433 (set-buffer gnus-group-buffer)
3434 (gnus-group-jump-to-group group)
3435 (gnus-group-next-unread-group 1)
3436 (gnus-configure-windows 'group 'force))
3437 (gnus-handle-ephemeral-exit quit-config))
3438 ;; Finally signal the quit.
3440 ;; The group was successfully selected.
3442 (gnus-set-global-variables)
3443 ;; Save the active value in effect when the group was entered.
3444 (setq gnus-newsgroup-active
3446 (gnus-active gnus-newsgroup-name)))
3447 ;; You can change the summary buffer in some way with this hook.
3448 (gnus-run-hooks 'gnus-select-group-hook)
3449 (gnus-update-format-specifications
3450 nil 'summary 'summary-mode 'summary-dummy)
3451 (gnus-update-summary-mark-positions)
3452 ;; Do score processing.
3453 (when gnus-use-scoring
3454 (gnus-possibly-score-headers))
3455 ;; Check whether to fill in the gaps in the threads.
3456 (when gnus-build-sparse-threads
3457 (gnus-build-sparse-threads))
3458 ;; Find the initial limit.
3459 (if gnus-show-threads
3461 (let ((gnus-newsgroup-dormant nil))
3462 (gnus-summary-initial-limit show-all))
3463 (gnus-summary-initial-limit show-all))
3464 ;; When unthreaded, all articles are always shown.
3465 (setq gnus-newsgroup-limit
3467 (lambda (header) (mail-header-number header))
3468 gnus-newsgroup-headers)))
3469 ;; Generate the summary buffer.
3471 (gnus-summary-prepare))
3472 (when gnus-use-trees
3473 (gnus-tree-open group)
3474 (setq gnus-summary-highlight-line-function
3475 'gnus-tree-highlight-article))
3476 ;; If the summary buffer is empty, but there are some low-scored
3477 ;; articles or some excluded dormants, we include these in the
3479 (when (and (zerop (buffer-size))
3481 (cond (gnus-newsgroup-dormant
3482 (gnus-summary-limit-include-dormant))
3483 ((and gnus-newsgroup-scored show-all)
3484 (gnus-summary-limit-include-expunged t))))
3485 ;; Function `gnus-apply-kill-file' must be called in this hook.
3486 (gnus-run-hooks 'gnus-apply-kill-hook)
3487 (if (and (zerop (buffer-size))
3490 ;; This newsgroup is empty.
3491 (gnus-summary-catchup-and-exit nil t)
3492 (gnus-message 6 "No unread news")
3494 (gnus-kill-or-deaden-summary kill-buffer))
3495 ;; Return nil from this function.
3497 ;; Hide conversation thread subtrees. We cannot do this in
3498 ;; gnus-summary-prepare-hook since kill processing may not
3499 ;; work with hidden articles.
3500 (gnus-summary-maybe-hide-threads)
3502 (gnus-kill-or-deaden-summary kill-buffer))
3503 (gnus-summary-auto-select-subject)
3504 ;; Show first unread article if requested.
3505 (if (and (not no-article)
3507 gnus-newsgroup-unreads
3508 gnus-auto-select-first)
3510 (gnus-configure-windows 'summary)
3511 (let ((art (gnus-summary-article-number)))
3512 (unless (and (not gnus-plugged)
3513 (or (memq art gnus-newsgroup-undownloaded)
3514 (memq art gnus-newsgroup-downloadable)))
3515 (gnus-summary-goto-article art))))
3516 ;; Don't select any articles.
3517 (gnus-summary-position-point)
3518 (gnus-configure-windows 'summary 'force)
3519 (gnus-set-mode-line 'summary))
3520 (when (get-buffer-window gnus-group-buffer t)
3521 ;; Gotta use windows, because recenter does weird stuff if
3522 ;; the current buffer ain't the displayed window.
3523 (let ((owin (selected-window)))
3524 (select-window (get-buffer-window gnus-group-buffer t))
3525 (when (gnus-group-goto-group group)
3527 (select-window owin)))
3528 ;; Mark this buffer as "prepared".
3529 (setq gnus-newsgroup-prepared t)
3530 (gnus-run-hooks 'gnus-summary-prepared-hook)
3531 (unless (gnus-ephemeral-group-p group)
3532 (gnus-group-update-group group))
3535 (defun gnus-summary-auto-select-subject ()
3536 "Select the subject line on initial group entry."
3537 (goto-char (point-min))
3539 ((eq gnus-auto-select-subject 'best)
3540 (gnus-summary-best-unread-subject))
3541 ((eq gnus-auto-select-subject 'unread)
3542 (gnus-summary-first-unread-subject))
3543 ((eq gnus-auto-select-subject 'unseen)
3544 (gnus-summary-first-unseen-subject))
3545 ((eq gnus-auto-select-subject 'unseen-or-unread)
3546 (gnus-summary-first-unseen-or-unread-subject))
3547 ((eq gnus-auto-select-subject 'first)
3550 ((gnus-functionp gnus-auto-select-subject)
3551 (funcall gnus-auto-select-subject))))
3553 (defun gnus-summary-prepare ()
3554 "Generate the summary buffer."
3556 (let ((buffer-read-only nil))
3558 (setq gnus-newsgroup-data nil
3559 gnus-newsgroup-data-reverse nil)
3560 (gnus-run-hooks 'gnus-summary-generate-hook)
3561 ;; Generate the buffer, either with threads or without.
3562 (when gnus-newsgroup-headers
3563 (gnus-summary-prepare-threads
3564 (if gnus-show-threads
3565 (gnus-sort-gathered-threads
3566 (funcall gnus-summary-thread-gathering-function
3568 (gnus-cut-threads (gnus-make-threads)))))
3569 ;; Unthreaded display.
3570 (gnus-sort-articles gnus-newsgroup-headers))))
3571 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3572 ;; Call hooks for modifying summary buffer.
3573 (goto-char (point-min))
3574 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3576 (defsubst gnus-general-simplify-subject (subject)
3577 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3580 ;; Truncate the subject.
3581 (gnus-simplify-subject-functions
3582 (gnus-map-function gnus-simplify-subject-functions subject))
3583 ((numberp gnus-summary-gather-subject-limit)
3584 (setq subject (gnus-simplify-subject-re subject))
3585 (if (> (length subject) gnus-summary-gather-subject-limit)
3586 (substring subject 0 gnus-summary-gather-subject-limit)
3588 ;; Fuzzily simplify it.
3589 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3590 (gnus-simplify-subject-fuzzy subject))
3591 ;; Just remove the leading "Re:".
3593 (gnus-simplify-subject-re subject))))
3595 (if (and gnus-summary-gather-exclude-subject
3596 (string-match gnus-summary-gather-exclude-subject subject))
3597 nil ; This article shouldn't be gathered
3600 (defun gnus-summary-simplify-subject-query ()
3601 "Query where the respool algorithm would put this article."
3603 (gnus-summary-select-article)
3604 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3606 (defun gnus-gather-threads-by-subject (threads)
3607 "Gather threads by looking at Subject headers."
3608 (if (not gnus-summary-make-false-root)
3610 (let ((hashtb (gnus-make-hashtable 1024))
3613 subject hthread whole-subject)
3615 (setq subject (gnus-general-simplify-subject
3616 (setq whole-subject (mail-header-subject
3619 (if (setq hthread (gnus-gethash subject hashtb))
3621 ;; We enter a dummy root into the thread, if we
3622 ;; haven't done that already.
3623 (unless (stringp (caar hthread))
3624 (setcar hthread (list whole-subject (car hthread))))
3625 ;; We add this new gathered thread to this gathered
3627 (setcdr (car hthread)
3628 (nconc (cdar hthread) (list (car threads))))
3629 ;; Remove it from the list of threads.
3630 (setcdr prev (cdr threads))
3631 (setq threads prev))
3632 ;; Enter this thread into the hash table.
3633 (gnus-sethash subject
3634 (if gnus-summary-make-false-root-always
3636 ;; If you want a dummy root above all
3638 (setcar threads (list whole-subject
3644 (setq threads (cdr threads)))
3647 (defun gnus-gather-threads-by-references (threads)
3648 "Gather threads by looking at References headers."
3649 (let ((idhashtb (gnus-make-hashtable 1024))
3650 (thhashtb (gnus-make-hashtable 1024))
3653 ids references id gthread gid entered ref)
3655 (when (setq references (mail-header-references (caar threads)))
3656 (setq id (mail-header-id (caar threads))
3657 ids (inline (gnus-split-references references))
3659 (while (setq ref (pop ids))
3660 (setq ids (delete ref ids))
3661 (if (not (setq gid (gnus-gethash ref idhashtb)))
3663 (gnus-sethash ref id idhashtb)
3664 (gnus-sethash id threads thhashtb))
3665 (setq gthread (gnus-gethash gid thhashtb))
3667 ;; We enter a dummy root into the thread, if we
3668 ;; haven't done that already.
3669 (unless (stringp (caar gthread))
3670 (setcar gthread (list (mail-header-subject (caar gthread))
3672 ;; We add this new gathered thread to this gathered
3674 (setcdr (car gthread)
3675 (nconc (cdar gthread) (list (car threads)))))
3676 ;; Add it into the thread hash table.
3677 (gnus-sethash id gthread thhashtb)
3679 ;; Remove it from the list of threads.
3680 (setcdr prev (cdr threads))
3681 (setq threads prev))))
3683 (setq threads (cdr threads)))
3686 (defun gnus-sort-gathered-threads (threads)
3687 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3688 (let ((result threads))
3690 (when (stringp (caar threads))
3691 (setcdr (car threads)
3692 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3693 (setq threads (cdr threads)))
3696 (defun gnus-thread-loop-p (root thread)
3697 "Say whether ROOT is in THREAD."
3698 (let ((stack (list thread))
3701 (while (setq thread (pop stack))
3702 (setq th (cdr thread))
3704 (not (eq (caar th) root)))
3707 ;; We have found a loop.
3709 (setcdr thread (delq (car th) (cdr thread)))
3710 (if (boundp (setq ref-dep (intern "none"
3711 gnus-newsgroup-dependencies)))
3712 (setcdr (symbol-value ref-dep)
3713 (nconc (cdr (symbol-value ref-dep))
3715 (set ref-dep (list nil (car th))))
3718 ;; Push all the subthreads onto the stack.
3719 (push (cdr thread) stack)))
3722 (defun gnus-make-threads ()
3723 "Go through the dependency hashtb and find the roots. Return all threads."
3725 (while (catch 'infloop
3728 ;; Deal with self-referencing References loops.
3729 (when (and (car (symbol-value refs))
3736 (car (symbol-value refs)) thread))
3737 (cdr (symbol-value refs)))))))
3740 (unless (car (symbol-value refs))
3741 ;; These threads do not refer back to any other
3742 ;; articles, so they're roots.
3743 (setq threads (append (cdr (symbol-value refs)) threads))))
3744 gnus-newsgroup-dependencies)))
3747 ;; Build the thread tree.
3748 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3749 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3751 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3752 if it was already present.
3754 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3755 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3756 Message-IDs will be renamed to a unique Message-ID before being
3759 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3760 (let* ((id (mail-header-id header))
3761 (id-dep (and id (intern id dependencies)))
3762 parent-id ref ref-dep ref-header replaced)
3763 ;; Enter this `header' in the `dependencies' table.
3767 ;; The first two cases do the normal part: enter a new `header'
3768 ;; in the `dependencies' table.
3769 ((not (boundp id-dep))
3770 (set id-dep (list header)))
3771 ((null (car (symbol-value id-dep)))
3772 (setcar (symbol-value id-dep) header))
3774 ;; From here the `header' was already present in the
3775 ;; `dependencies' table.
3777 ;; Overrides an existing entry;
3778 ;; just set the header part of the entry.
3779 (setcar (symbol-value id-dep) header)
3782 ;; Renames the existing `header' to a unique Message-ID.
3783 ((not gnus-summary-ignore-duplicates)
3784 ;; An article with this Message-ID has already been seen.
3785 ;; We rename the Message-ID.
3786 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3788 (mail-header-set-id header id))
3790 ;; The last case ignores an existing entry, except it adds any
3791 ;; additional Xrefs (in case the two articles came from different
3793 ;; Also sets `header' to `nil' meaning that the `dependencies'
3794 ;; table was *not* modified.
3796 (mail-header-set-xref
3797 (car (symbol-value id-dep))
3798 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3800 (or (mail-header-xref header) "")))
3803 (when (and header (not replaced))
3804 ;; First check that we are not creating a References loop.
3805 (setq parent-id (gnus-parent-id (mail-header-references header)))
3806 (setq ref parent-id)
3808 (setq ref-dep (intern-soft ref dependencies))
3810 (setq ref-header (car (symbol-value ref-dep))))
3811 (if (string= id ref)
3812 ;; Yuk! This is a reference loop. Make the article be a
3815 (mail-header-set-references (car (symbol-value id-dep)) "none")
3817 (setq parent-id nil))
3818 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3819 (setq ref-dep (intern (or parent-id "none") dependencies))
3820 (if (boundp ref-dep)
3821 (setcdr (symbol-value ref-dep)
3822 (nconc (cdr (symbol-value ref-dep))
3823 (list (symbol-value id-dep))))
3824 (set ref-dep (list nil (symbol-value id-dep)))))
3827 (defun gnus-extract-message-id-from-in-reply-to (string)
3828 (if (string-match "<[^>]+>" string)
3829 (substring string (match-beginning 0) (match-end 0))
3832 (defun gnus-build-sparse-threads ()
3833 (let ((headers gnus-newsgroup-headers)
3834 (mail-parse-charset gnus-newsgroup-charset)
3835 (gnus-summary-ignore-duplicates t)
3836 header references generation relations
3837 subject child end new-child date)
3838 ;; First we create an alist of generations/relations, where
3839 ;; generations is how much we trust the relation, and the relation
3841 (gnus-message 7 "Making sparse threads...")
3843 (nnheader-set-temp-buffer " *gnus sparse threads*")
3844 (while (setq header (pop headers))
3845 (when (and (setq references (mail-header-references header))
3846 (not (string= references "")))
3848 (setq child (mail-header-id header)
3849 subject (mail-header-subject header)
3850 date (mail-header-date header)
3852 (while (search-backward ">" nil t)
3853 (setq end (1+ (point)))
3854 (when (search-backward "<" nil t)
3855 (setq new-child (buffer-substring (point) end))
3856 (push (list (incf generation)
3857 child (setq child new-child)
3861 (push (list (1+ generation) child nil subject) relations))
3863 (kill-buffer (current-buffer)))
3864 ;; Sort over trustworthiness.
3867 (when (gnus-dependencies-add-header
3868 (make-full-mail-header
3869 gnus-reffed-article-number
3870 (nth 3 relation) "" (or (nth 4 relation) "")
3872 (or (nth 2 relation) "") 0 0 "")
3873 gnus-newsgroup-dependencies nil)
3874 (push gnus-reffed-article-number gnus-newsgroup-limit)
3875 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3876 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3877 gnus-newsgroup-reads)
3878 (decf gnus-reffed-article-number)))
3879 (sort relations 'car-less-than-car))
3880 (gnus-message 7 "Making sparse threads...done")))
3882 (defun gnus-build-old-threads ()
3883 ;; Look at all the articles that refer back to old articles, and
3884 ;; fetch the headers for the articles that aren't there. This will
3885 ;; build complete threads - if the roots haven't been expired by the
3887 (let ((mail-parse-charset gnus-newsgroup-charset)
3891 (when (not (car (symbol-value refs)))
3892 (setq heads (cdr (symbol-value refs)))
3894 (if (memq (mail-header-number (caar heads))
3895 gnus-newsgroup-dormant)
3896 (setq heads (cdr heads))
3897 (setq id (symbol-name refs))
3898 (while (and (setq id (gnus-build-get-header id))
3899 (not (car (gnus-id-to-thread id)))))
3900 (setq heads nil)))))
3901 gnus-newsgroup-dependencies)))
3903 ;; This function has to be called with point after the article number
3904 ;; on the beginning of the line.
3905 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3906 (let ((eol (gnus-point-at-eol))
3907 (buffer (current-buffer))
3908 header references in-reply-to)
3910 ;; overview: [num subject from date id refs chars lines misc]
3913 (narrow-to-region (point) eol)
3918 (make-full-mail-header
3920 (condition-case () ; subject
3921 (funcall gnus-decode-encoded-word-function
3922 (setq x (nnheader-nov-field)))
3924 (condition-case () ; from
3925 (funcall gnus-decode-encoded-word-function
3926 (setq x (nnheader-nov-field)))
3928 (nnheader-nov-field) ; date
3929 (nnheader-nov-read-message-id) ; id
3930 (setq references (nnheader-nov-field)) ; refs
3931 (nnheader-nov-read-integer) ; chars
3932 (nnheader-nov-read-integer) ; lines
3934 (if (looking-at "Xref: ")
3935 (goto-char (match-end 0)))
3936 (nnheader-nov-field)) ; Xref
3937 (nnheader-nov-parse-extra)))) ; extra
3941 (when (and (string= references "")
3942 (setq in-reply-to (mail-header-extra header))
3943 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3944 (mail-header-set-references
3945 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3947 (when gnus-alter-header-function
3948 (funcall gnus-alter-header-function header))
3949 (gnus-dependencies-add-header header dependencies force-new)))
3951 (defun gnus-build-get-header (id)
3952 "Look through the buffer of NOV lines and find the header to ID.
3953 Enter this line into the dependencies hash table, and return
3954 the id of the parent article (if any)."
3955 (let ((deps gnus-newsgroup-dependencies)
3959 (set-buffer nntp-server-buffer)
3960 (let ((case-fold-search nil))
3961 (goto-char (point-min))
3962 (while (and (not found)
3963 (search-forward id nil t))
3965 (setq found (looking-at
3966 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3967 (regexp-quote id))))
3968 (or found (beginning-of-line 2)))
3972 (setq header (gnus-nov-parse-line
3973 (read (current-buffer)) deps))
3974 (gnus-parent-id (mail-header-references header))))))
3976 (let ((number (mail-header-number header)))
3977 (push number gnus-newsgroup-limit)
3978 (push header gnus-newsgroup-headers)
3979 (if (memq number gnus-newsgroup-unselected)
3981 (setq gnus-newsgroup-unreads
3982 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3984 (setq gnus-newsgroup-unselected
3985 (delq number gnus-newsgroup-unselected)))
3986 (push number gnus-newsgroup-ancient)))))))
3988 (defun gnus-build-all-threads ()
3989 "Read all the headers."
3990 (let ((gnus-summary-ignore-duplicates t)
3991 (mail-parse-charset gnus-newsgroup-charset)
3992 (dependencies gnus-newsgroup-dependencies)
3995 (set-buffer nntp-server-buffer)
3996 (let ((case-fold-search nil))
3997 (goto-char (point-min))
4000 (setq article (read (current-buffer))
4001 header (gnus-nov-parse-line article dependencies)))
4004 (set-buffer gnus-summary-buffer)
4005 (push header gnus-newsgroup-headers)
4006 (if (memq (setq article (mail-header-number header))
4007 gnus-newsgroup-unselected)
4009 (setq gnus-newsgroup-unreads
4010 (gnus-add-to-sorted-list
4011 gnus-newsgroup-unreads article))
4012 (setq gnus-newsgroup-unselected
4013 (delq article gnus-newsgroup-unselected)))
4014 (push article gnus-newsgroup-ancient)))
4015 (forward-line 1)))))))
4017 (defun gnus-summary-update-article-line (article header)
4018 "Update the line for ARTICLE using HEADERS."
4019 (let* ((id (mail-header-id header))
4020 (thread (gnus-id-to-thread id)))
4022 (error "Article in no thread"))
4023 ;; Update the thread.
4024 (setcar thread header)
4025 (gnus-summary-goto-subject article)
4026 (let* ((datal (gnus-data-find-list article))
4028 (buffer-read-only nil)
4029 (level (gnus-summary-thread-level)))
4031 (let ((inserted (- (point)
4033 (gnus-summary-insert-line
4035 (memq article gnus-newsgroup-undownloaded)
4036 (gnus-article-mark article)
4037 (memq article gnus-newsgroup-replied)
4038 (memq article gnus-newsgroup-expirable)
4039 ;; Only insert the Subject string when it's different
4040 ;; from the previous Subject string.
4045 (mail-header-subject
4048 (gnus-data-find-list
4050 (gnus-data-list t)))))
4051 ;; Error on the side of excessive subjects.
4053 (mail-header-subject header)))
4055 (mail-header-subject header))
4056 nil (cdr (assq article gnus-newsgroup-scored))
4057 (memq article gnus-newsgroup-processable))
4060 (gnus-data-update-list
4062 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4064 (defun gnus-summary-update-article (article &optional iheader)
4065 "Update ARTICLE in the summary buffer."
4066 (set-buffer gnus-summary-buffer)
4067 (let* ((header (gnus-summary-article-header article))
4068 (id (mail-header-id header))
4069 (data (gnus-data-find article))
4070 (thread (gnus-id-to-thread id))
4071 (references (mail-header-references header))
4075 (when (and references
4076 (not (equal "" references)))
4079 (buffer-read-only nil)
4085 (delq thread parent)))
4086 (if (gnus-summary-insert-subject id header)
4087 ;; Set the (possibly) new article number in the data structure.
4088 (gnus-data-set-number data (gnus-id-to-article id))
4092 (defun gnus-rebuild-thread (id &optional line)
4093 "Rebuild the thread containing ID.
4094 If LINE, insert the rebuilt thread starting on line LINE."
4095 (let ((buffer-read-only nil)
4096 old-pos current thread data)
4097 (if (not gnus-show-threads)
4098 (setq thread (list (car (gnus-id-to-thread id))))
4099 ;; Get the thread this article is part of.
4100 (setq thread (gnus-remove-thread id)))
4101 (setq old-pos (gnus-point-at-bol))
4102 (setq current (save-excursion
4103 (and (re-search-backward "[\r\n]" nil t)
4104 (gnus-summary-article-number))))
4105 ;; If this is a gathered thread, we have to go some re-gathering.
4106 (when (stringp (car thread))
4107 (let ((subject (car thread))
4109 (setq thread (cdr thread))
4111 (unless (memq (setq thr (gnus-id-to-thread
4113 (mail-header-id (caar thread)))))
4116 (setq thread (cdr thread)))
4117 ;; We now have all (unique) roots.
4118 (if (= (length roots) 1)
4119 ;; All the loose roots are now one solid root.
4120 (setq thread (car roots))
4121 (setq thread (cons subject (gnus-sort-threads roots))))))
4123 ;; We then insert this thread into the summary buffer.
4125 (goto-char (point-min))
4126 (forward-line (1- line)))
4127 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4128 (if gnus-show-threads
4129 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4130 (gnus-summary-prepare-unthreaded thread))
4131 (setq data (nreverse gnus-newsgroup-data))
4132 (setq threads gnus-newsgroup-threads))
4133 ;; We splice the new data into the data structure.
4134 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4135 ;;!!! then we want to insert at the beginning of the buffer.
4136 ;;!!! That happens to be true with Gnus now, but that may
4137 ;;!!! change in the future. Perhaps.
4138 (gnus-data-enter-list
4139 (if line nil current) data (- (point) old-pos))
4140 (setq gnus-newsgroup-threads
4141 (nconc threads gnus-newsgroup-threads))
4142 (gnus-data-compute-positions))))
4144 (defun gnus-number-to-header (number)
4145 "Return the header for article NUMBER."
4146 (let ((headers gnus-newsgroup-headers))
4148 (not (= number (mail-header-number (car headers)))))
4153 (defun gnus-parent-headers (in-headers &optional generation)
4154 "Return the headers of the GENERATIONeth parent of HEADERS."
4156 (setq generation 1))
4158 (headers in-headers)
4161 (not (zerop generation))
4162 (setq references (mail-header-references headers)))
4163 (setq headers (if (and references
4164 (setq parent (gnus-parent-id references)))
4165 (car (gnus-id-to-thread parent))
4168 (and (not (eq headers in-headers))
4171 (defun gnus-id-to-thread (id)
4172 "Return the (sub-)thread where ID appears."
4173 (gnus-gethash id gnus-newsgroup-dependencies))
4175 (defun gnus-id-to-article (id)
4176 "Return the article number of ID."
4177 (let ((thread (gnus-id-to-thread id)))
4180 (mail-header-number (car thread)))))
4182 (defun gnus-id-to-header (id)
4183 "Return the article headers of ID."
4184 (car (gnus-id-to-thread id)))
4186 (defun gnus-article-displayed-root-p (article)
4187 "Say whether ARTICLE is a root(ish) article."
4188 (let ((level (gnus-summary-thread-level article))
4189 (refs (mail-header-references (gnus-summary-article-header article)))
4195 ((null (gnus-parent-id refs)) t)
4197 (null (setq particle (gnus-id-to-article
4198 (gnus-parent-id refs))))
4199 (null (gnus-summary-thread-level particle)))))))
4201 (defun gnus-root-id (id)
4202 "Return the id of the root of the thread where ID appears."
4204 (while (and id (setq prev (car (gnus-id-to-thread id))))
4206 id (gnus-parent-id (mail-header-references prev))))
4209 (defun gnus-articles-in-thread (thread)
4210 "Return the list of articles in THREAD."
4211 (cons (mail-header-number (car thread))
4212 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4214 (defun gnus-remove-thread (id &optional dont-remove)
4215 "Remove the thread that has ID in it."
4216 (let (headers thread last-id)
4217 ;; First go up in this thread until we find the root.
4218 (setq last-id (gnus-root-id id)
4219 headers (message-flatten-list (gnus-id-to-thread last-id)))
4220 ;; We have now found the real root of this thread. It might have
4221 ;; been gathered into some loose thread, so we have to search
4222 ;; through the threads to find the thread we wanted.
4223 (let ((threads gnus-newsgroup-threads)
4226 (setq sub (car threads))
4227 (if (stringp (car sub))
4228 ;; This is a gathered thread, so we look at the roots
4229 ;; below it to find whether this article is in this
4232 (setq sub (cdr sub))
4234 (when (member (caar sub) headers)
4235 (setq thread (car threads)
4238 (setq sub (cdr sub))))
4239 ;; It's an ordinary thread, so we check it.
4240 (when (eq (car sub) (car headers))
4243 (setq threads (cdr threads)))
4244 ;; If this article is in no thread, then it's a root.
4247 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4248 (setq thread (gnus-id-to-thread last-id)))
4251 thread ; We return this thread.
4253 (if (stringp (car thread))
4255 ;; If we use dummy roots, then we have to remove the
4256 ;; dummy root as well.
4257 (when (eq gnus-summary-make-false-root 'dummy)
4258 ;; We go to the dummy root by going to
4259 ;; the first sub-"thread", and then one line up.
4260 (gnus-summary-goto-article
4261 (mail-header-number (caadr thread)))
4264 (gnus-data-compute-positions))
4265 (setq thread (cdr thread))
4267 (gnus-remove-thread-1 (car thread))
4268 (setq thread (cdr thread))))
4269 (gnus-remove-thread-1 thread))))))))
4271 (defun gnus-remove-thread-1 (thread)
4272 "Remove the thread THREAD recursively."
4273 (let ((number (mail-header-number (pop thread)))
4275 (setq thread (reverse thread))
4277 (gnus-remove-thread-1 (pop thread)))
4278 (when (setq d (gnus-data-find number))
4279 (goto-char (gnus-data-pos d))
4280 (gnus-summary-show-thread)
4283 (- (gnus-point-at-bol)
4285 (1+ (gnus-point-at-eol))
4286 (gnus-delete-line)))))))
4288 (defun gnus-sort-threads-1 (threads func)
4289 (sort (mapcar (lambda (thread)
4292 (gnus-sort-threads-1 (cdr thread) func))))
4295 (defun gnus-sort-threads (threads)
4297 (if (not gnus-thread-sort-functions)
4299 (gnus-message 8 "Sorting threads...")
4300 (let ((max-lisp-eval-depth 5000))
4301 (prog1 (gnus-sort-threads-1
4303 (gnus-make-sort-function gnus-thread-sort-functions))
4304 (gnus-message 8 "Sorting threads...done")))))
4306 (defun gnus-sort-articles (articles)
4308 (when gnus-article-sort-functions
4309 (gnus-message 7 "Sorting articles...")
4311 (setq gnus-newsgroup-headers
4312 (sort articles (gnus-make-sort-function
4313 gnus-article-sort-functions)))
4314 (gnus-message 7 "Sorting articles...done"))))
4316 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4317 (defmacro gnus-thread-header (thread)
4318 "Return header of first article in THREAD.
4319 Note that THREAD must never, ever be anything else than a variable -
4320 using some other form will lead to serious barfage."
4321 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4322 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4323 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4326 (defsubst gnus-article-sort-by-number (h1 h2)
4327 "Sort articles by article number."
4328 (< (mail-header-number h1)
4329 (mail-header-number h2)))
4331 (defun gnus-thread-sort-by-number (h1 h2)
4332 "Sort threads by root article number."
4333 (gnus-article-sort-by-number
4334 (gnus-thread-header h1) (gnus-thread-header h2)))
4336 (defsubst gnus-article-sort-by-random (h1 h2)
4337 "Sort articles by article number."
4340 (defun gnus-thread-sort-by-random (h1 h2)
4341 "Sort threads by root article number."
4342 (gnus-article-sort-by-random
4343 (gnus-thread-header h1) (gnus-thread-header h2)))
4345 (defsubst gnus-article-sort-by-lines (h1 h2)
4346 "Sort articles by article Lines header."
4347 (< (mail-header-lines h1)
4348 (mail-header-lines h2)))
4350 (defun gnus-thread-sort-by-lines (h1 h2)
4351 "Sort threads by root article Lines header."
4352 (gnus-article-sort-by-lines
4353 (gnus-thread-header h1) (gnus-thread-header h2)))
4355 (defsubst gnus-article-sort-by-chars (h1 h2)
4356 "Sort articles by octet length."
4357 (< (mail-header-chars h1)
4358 (mail-header-chars h2)))
4360 (defun gnus-thread-sort-by-chars (h1 h2)
4361 "Sort threads by root article octet length."
4362 (gnus-article-sort-by-chars
4363 (gnus-thread-header h1) (gnus-thread-header h2)))
4365 (defsubst gnus-article-sort-by-author (h1 h2)
4366 "Sort articles by root author."
4368 (let ((extract (funcall
4369 gnus-extract-address-components
4370 (mail-header-from h1))))
4371 (or (car extract) (cadr extract) ""))
4372 (let ((extract (funcall
4373 gnus-extract-address-components
4374 (mail-header-from h2))))
4375 (or (car extract) (cadr extract) ""))))
4377 (defun gnus-thread-sort-by-author (h1 h2)
4378 "Sort threads by root author."
4379 (gnus-article-sort-by-author
4380 (gnus-thread-header h1) (gnus-thread-header h2)))
4382 (defsubst gnus-article-sort-by-subject (h1 h2)
4383 "Sort articles by root subject."
4385 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4386 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4388 (defun gnus-thread-sort-by-subject (h1 h2)
4389 "Sort threads by root subject."
4390 (gnus-article-sort-by-subject
4391 (gnus-thread-header h1) (gnus-thread-header h2)))
4393 (defsubst gnus-article-sort-by-date (h1 h2)
4394 "Sort articles by root article date."
4396 (gnus-date-get-time (mail-header-date h1))
4397 (gnus-date-get-time (mail-header-date h2))))
4399 (defun gnus-thread-sort-by-date (h1 h2)
4400 "Sort threads by root article date."
4401 (gnus-article-sort-by-date
4402 (gnus-thread-header h1) (gnus-thread-header h2)))
4404 (defsubst gnus-article-sort-by-score (h1 h2)
4405 "Sort articles by root article score.
4406 Unscored articles will be counted as having a score of zero."
4407 (> (or (cdr (assq (mail-header-number h1)
4408 gnus-newsgroup-scored))
4409 gnus-summary-default-score 0)
4410 (or (cdr (assq (mail-header-number h2)
4411 gnus-newsgroup-scored))
4412 gnus-summary-default-score 0)))
4414 (defun gnus-thread-sort-by-score (h1 h2)
4415 "Sort threads by root article score."
4416 (gnus-article-sort-by-score
4417 (gnus-thread-header h1) (gnus-thread-header h2)))
4419 (defun gnus-thread-sort-by-total-score (h1 h2)
4420 "Sort threads by the sum of all scores in the thread.
4421 Unscored articles will be counted as having a score of zero."
4422 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4424 (defun gnus-thread-total-score (thread)
4425 ;; This function find the total score of THREAD.
4430 (if (stringp (car thread))
4431 (apply gnus-thread-score-function 0
4432 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4433 (gnus-thread-total-score-1 thread)))
4435 (gnus-thread-total-score-1 (list thread)))))
4437 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4438 "Sort threads such that the thread with the most recently arrived article comes first."
4439 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4441 (defun gnus-thread-highest-number (thread)
4442 "Return the highest article number in THREAD."
4443 (apply 'max (mapcar (lambda (header)
4444 (mail-header-number header))
4445 (message-flatten-list thread))))
4447 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4448 "Sort threads such that the thread with the most recently dated article comes first."
4449 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4451 (defun gnus-thread-latest-date (thread)
4452 "Return the highest article date in THREAD."
4453 (let ((previous-time 0))
4460 (mail-header-parse-date (mail-header-date header))
4461 (error previous-time)))))
4463 (message-flatten-list thread)
4465 (< (mail-header-number h1)
4466 (mail-header-number h2))))))))
4468 (defun gnus-thread-total-score-1 (root)
4469 ;; This function find the total score of the thread below ROOT.
4470 (setq root (car root))
4471 (apply gnus-thread-score-function
4473 (mapcar 'gnus-thread-total-score
4474 (cdr (gnus-id-to-thread (mail-header-id root))))
4475 (when (> (mail-header-number root) 0)
4476 (list (or (cdr (assq (mail-header-number root)
4477 gnus-newsgroup-scored))
4478 gnus-summary-default-score 0))))
4479 (list gnus-summary-default-score)
4482 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4483 (defvar gnus-tmp-prev-subject nil)
4484 (defvar gnus-tmp-false-parent nil)
4485 (defvar gnus-tmp-root-expunged nil)
4486 (defvar gnus-tmp-dummy-line nil)
4488 (eval-when-compile (defvar gnus-tmp-header))
4489 (defun gnus-extra-header (type &optional header)
4490 "Return the extra header of TYPE."
4491 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4494 (defvar gnus-tmp-thread-tree-header-string "")
4496 (defcustom gnus-sum-thread-tree-root "> "
4497 "With %B spec, used for the root of a thread.
4498 If nil, use subject instead."
4500 :group 'gnus-thread)
4501 (defcustom gnus-sum-thread-tree-single-indent ""
4502 "With %B spec, used for a thread with just one message.
4503 If nil, use subject instead."
4505 :group 'gnus-thread)
4506 (defcustom gnus-sum-thread-tree-vertical "| "
4507 "With %B spec, used for drawing a vertical line."
4509 :group 'gnus-thread)
4510 (defcustom gnus-sum-thread-tree-indent " "
4511 "With %B spec, used for indenting."
4513 :group 'gnus-thread)
4514 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4515 "With %B spec, used for a leaf with brothers."
4517 :group 'gnus-thread)
4518 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4519 "With %B spec, used for a leaf without brothers."
4521 :group 'gnus-thread)
4523 (defun gnus-summary-prepare-threads (threads)
4524 "Prepare summary buffer from THREADS and indentation LEVEL.
4525 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4526 or a straight list of headers."
4527 (gnus-message 7 "Generating summary...")
4529 (setq gnus-newsgroup-threads threads)
4532 (let ((gnus-tmp-level 0)
4533 (default-score (or gnus-summary-default-score 0))
4534 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4535 (building-line-count gnus-summary-display-while-building)
4536 (building-count (integerp gnus-summary-display-while-building))
4537 thread number subject stack state gnus-tmp-gathered beg-match
4538 new-roots gnus-tmp-new-adopts thread-end simp-subject
4539 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4540 gnus-tmp-replied gnus-tmp-subject-or-nil
4541 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4542 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4543 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4546 (setq gnus-tmp-prev-subject nil)
4548 (if (vectorp (car threads))
4549 ;; If this is a straight (sic) list of headers, then a
4550 ;; threaded summary display isn't required, so we just create
4551 ;; an unthreaded one.
4552 (gnus-summary-prepare-unthreaded threads)
4554 ;; Do the threaded display.
4556 (if gnus-summary-display-while-building
4557 (switch-to-buffer (buffer-name)))
4558 (while (or threads stack gnus-tmp-new-adopts new-roots)
4560 (if (and (= gnus-tmp-level 0)
4563 (not gnus-tmp-false-parent)
4564 (or gnus-tmp-new-adopts new-roots))
4565 (if gnus-tmp-new-adopts
4566 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4567 thread (list (car gnus-tmp-new-adopts))
4568 gnus-tmp-header (caar thread)
4569 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4571 (setq thread (list (car new-roots))
4572 gnus-tmp-header (caar thread)
4573 new-roots (cdr new-roots))))
4576 ;; If there are some threads, we do them before the
4577 ;; threads on the stack.
4578 (setq thread threads
4579 gnus-tmp-header (caar thread))
4580 ;; There were no current threads, so we pop something off
4582 (setq state (car stack)
4583 gnus-tmp-level (car state)
4584 tree-stack (cadr state)
4585 thread (caddr state)
4587 gnus-tmp-header (caar thread))))
4589 (setq gnus-tmp-false-parent nil)
4590 (setq gnus-tmp-root-expunged nil)
4591 (setq thread-end nil)
4593 (if (stringp gnus-tmp-header)
4594 ;; The header is a dummy root.
4596 ((eq gnus-summary-make-false-root 'adopt)
4597 ;; We let the first article adopt the rest.
4598 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4600 (setq gnus-tmp-gathered
4602 (lambda (h) (mail-header-number (car h)))
4605 (setq thread (cons (list (caar thread)
4608 (setq gnus-tmp-level -1
4609 gnus-tmp-false-parent t))
4610 ((eq gnus-summary-make-false-root 'empty)
4611 ;; We print adopted articles with empty subject fields.
4612 (setq gnus-tmp-gathered
4614 (lambda (h) (mail-header-number (car h)))
4617 (setq gnus-tmp-level -1))
4618 ((eq gnus-summary-make-false-root 'dummy)
4619 ;; We remember that we probably want to output a dummy
4621 (setq gnus-tmp-dummy-line gnus-tmp-header)
4622 (setq gnus-tmp-prev-subject gnus-tmp-header))
4624 ;; We do not make a root for the gathered
4625 ;; sub-threads at all.
4626 (setq gnus-tmp-level -1)))
4628 (setq number (mail-header-number gnus-tmp-header)
4629 subject (mail-header-subject gnus-tmp-header)
4630 simp-subject (gnus-simplify-subject-fully subject))
4633 ;; If the thread has changed subject, we might want to make
4634 ;; this subthread into a root.
4635 ((and (null gnus-thread-ignore-subject)
4636 (not (zerop gnus-tmp-level))
4637 gnus-tmp-prev-subject
4638 (not (string= gnus-tmp-prev-subject simp-subject)))
4639 (setq new-roots (nconc new-roots (list (car thread)))
4641 gnus-tmp-header nil))
4642 ;; If the article lies outside the current limit,
4643 ;; then we do not display it.
4644 ((not (memq number gnus-newsgroup-limit))
4645 (setq gnus-tmp-gathered
4647 (lambda (h) (mail-header-number (car h)))
4650 (setq gnus-tmp-new-adopts (if (cdar thread)
4651 (append gnus-tmp-new-adopts
4653 gnus-tmp-new-adopts)
4655 gnus-tmp-header nil)
4656 (when (zerop gnus-tmp-level)
4657 (setq gnus-tmp-root-expunged t)))
4658 ;; Perhaps this article is to be marked as read?
4659 ((and gnus-summary-mark-below
4660 (< (or (cdr (assq number gnus-newsgroup-scored))
4662 gnus-summary-mark-below)
4663 ;; Don't touch sparse articles.
4664 (not (gnus-summary-article-sparse-p number))
4665 (not (gnus-summary-article-ancient-p number)))
4666 (setq gnus-newsgroup-unreads
4667 (delq number gnus-newsgroup-unreads))
4668 (if gnus-newsgroup-auto-expire
4669 (setq gnus-newsgroup-expirable
4670 (gnus-add-to-sorted-list
4671 gnus-newsgroup-expirable number))
4672 (push (cons number gnus-low-score-mark)
4673 gnus-newsgroup-reads))))
4675 (when gnus-tmp-header
4676 ;; We may have an old dummy line to output before this
4678 (when (and gnus-tmp-dummy-line
4681 (mail-header-subject gnus-tmp-header)))
4682 (gnus-summary-insert-dummy-line
4683 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4684 (setq gnus-tmp-dummy-line nil))
4686 ;; Compute the mark.
4687 (setq gnus-tmp-unread (gnus-article-mark number))
4689 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4690 gnus-tmp-header gnus-tmp-level)
4691 gnus-newsgroup-data)
4693 ;; Actually insert the line.
4695 gnus-tmp-subject-or-nil
4697 ((and gnus-thread-ignore-subject
4698 gnus-tmp-prev-subject
4699 (not (string= gnus-tmp-prev-subject simp-subject)))
4701 ((zerop gnus-tmp-level)
4702 (if (and (eq gnus-summary-make-false-root 'empty)
4703 (memq number gnus-tmp-gathered)
4704 gnus-tmp-prev-subject
4705 (string= gnus-tmp-prev-subject simp-subject))
4706 gnus-summary-same-subject
4708 (t gnus-summary-same-subject)))
4709 (if (and (eq gnus-summary-make-false-root 'adopt)
4710 (= gnus-tmp-level 1)
4711 (memq number gnus-tmp-gathered))
4712 (setq gnus-tmp-opening-bracket ?\<
4713 gnus-tmp-closing-bracket ?\>)
4714 (setq gnus-tmp-opening-bracket ?\[
4715 gnus-tmp-closing-bracket ?\]))
4717 gnus-tmp-indentation
4718 (aref gnus-thread-indent-array gnus-tmp-level)
4719 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4720 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4721 gnus-summary-default-score 0)
4723 (if (or (null gnus-summary-default-score)
4724 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4725 gnus-summary-zcore-fuzz))
4727 (if (< gnus-tmp-score gnus-summary-default-score)
4728 gnus-score-below-mark gnus-score-over-mark))
4730 (cond ((memq number gnus-newsgroup-processable)
4732 ((memq number gnus-newsgroup-cached)
4734 ((memq number gnus-newsgroup-replied)
4736 ((memq number gnus-newsgroup-forwarded)
4737 gnus-forwarded-mark)
4738 ((memq number gnus-newsgroup-saved)
4740 ((memq number gnus-newsgroup-recent)
4742 ((memq number gnus-newsgroup-unseen)
4746 (cond ((memq number gnus-newsgroup-undownloaded)
4747 gnus-undownloaded-mark)
4748 (gnus-newsgroup-agentized
4749 gnus-downloaded-mark)
4752 gnus-tmp-from (mail-header-from gnus-tmp-header)
4755 ((string-match "<[^>]+> *$" gnus-tmp-from)
4756 (setq beg-match (match-beginning 0))
4757 (or (and (string-match "^\".+\"" gnus-tmp-from)
4758 (substring gnus-tmp-from 1 (1- (match-end 0))))
4759 (substring gnus-tmp-from 0 beg-match)))
4760 ((string-match "(.+)" gnus-tmp-from)
4761 (substring gnus-tmp-from
4762 (1+ (match-beginning 0)) (1- (match-end 0))))
4764 gnus-tmp-thread-tree-header-string
4766 ((not gnus-show-threads) "")
4767 ((zerop gnus-tmp-level)
4769 (or gnus-sum-thread-tree-root subject)
4770 (or gnus-sum-thread-tree-single-indent subject)))
4772 (concat (apply 'concat
4773 (mapcar (lambda (item)
4775 gnus-sum-thread-tree-vertical
4776 gnus-sum-thread-tree-indent))
4777 (cdr (reverse tree-stack))))
4779 gnus-sum-thread-tree-leaf-with-other
4780 gnus-sum-thread-tree-single-leaf)))))
4781 (when (string= gnus-tmp-name "")
4782 (setq gnus-tmp-name gnus-tmp-from))
4783 (unless (numberp gnus-tmp-lines)
4784 (setq gnus-tmp-lines -1))
4785 (if (= gnus-tmp-lines -1)
4786 (setq gnus-tmp-lines "?")
4787 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4788 (gnus-put-text-property
4790 (progn (eval gnus-summary-line-format-spec) (point))
4791 'gnus-number number)
4794 (gnus-run-hooks 'gnus-summary-update-hook)
4797 (setq gnus-tmp-prev-subject simp-subject)))
4799 (when (nth 1 thread)
4800 (push (list (max 0 gnus-tmp-level)
4801 (copy-list tree-stack)
4804 (push (if (nth 1 thread) 1 0) tree-stack)
4805 (incf gnus-tmp-level)
4806 (setq threads (if thread-end nil (cdar thread)))
4807 (if gnus-summary-display-while-building
4810 ;; use a set frequency
4811 (setq building-line-count (1- building-line-count))
4812 (when (= building-line-count 0)
4814 (setq building-line-count
4815 gnus-summary-display-while-building)))
4819 (setq gnus-tmp-level 0)))))
4820 (gnus-message 7 "Generating summary...done"))
4822 (defun gnus-summary-prepare-unthreaded (headers)
4823 "Generate an unthreaded summary buffer based on HEADERS."
4824 (let (header number mark)
4829 ;; We may have to root out some bad articles...
4830 (when (memq (setq number (mail-header-number
4831 (setq header (pop headers))))
4832 gnus-newsgroup-limit)
4833 ;; Mark article as read when it has a low score.
4834 (when (and gnus-summary-mark-below
4835 (< (or (cdr (assq number gnus-newsgroup-scored))
4836 gnus-summary-default-score 0)
4837 gnus-summary-mark-below)
4838 (not (gnus-summary-article-ancient-p number)))
4839 (setq gnus-newsgroup-unreads
4840 (delq number gnus-newsgroup-unreads))
4841 (if gnus-newsgroup-auto-expire
4842 (push number gnus-newsgroup-expirable)
4843 (push (cons number gnus-low-score-mark)
4844 gnus-newsgroup-reads)))
4846 (setq mark (gnus-article-mark number))
4847 (push (gnus-data-make number mark (1+ (point)) header 0)
4848 gnus-newsgroup-data)
4849 (gnus-summary-insert-line
4851 (memq number gnus-newsgroup-undownloaded)
4852 mark (memq number gnus-newsgroup-replied)
4853 (memq number gnus-newsgroup-expirable)
4854 (mail-header-subject header) nil
4855 (cdr (assq number gnus-newsgroup-scored))
4856 (memq number gnus-newsgroup-processable))))))
4858 (defun gnus-summary-remove-list-identifiers ()
4859 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4860 (let ((regexp (if (consp gnus-list-identifiers)
4861 (mapconcat 'identity gnus-list-identifiers " *\\|")
4862 gnus-list-identifiers))
4865 (dolist (header gnus-newsgroup-headers)
4866 (setq subject (mail-header-subject header)
4868 (while (string-match
4869 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4872 (concat (substring subject 0 (match-beginning 2))
4873 (substring subject (match-end 0)))
4877 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4879 (concat (substring subject 0 (match-beginning 1))
4880 (substring subject (match-end 1)))))
4882 (mail-header-set-subject header subject))))))
4884 (defun gnus-fetch-headers (articles)
4885 "Fetch headers of ARTICLES."
4886 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4887 (gnus-message 5 "Fetching headers for %s..." name)
4890 (setq gnus-headers-retrieved-by
4891 (gnus-retrieve-headers
4892 articles gnus-newsgroup-name
4893 ;; We might want to fetch old headers, but
4894 ;; not if there is only 1 article.
4896 (not (eq gnus-fetch-old-headers 'some))
4897 (not (numberp gnus-fetch-old-headers)))
4898 (> (length articles) 1))
4899 gnus-fetch-old-headers))))
4900 (gnus-get-newsgroup-headers-xover
4901 articles nil nil gnus-newsgroup-name t)
4902 (gnus-get-newsgroup-headers))
4903 (gnus-message 5 "Fetching headers for %s...done" name))))
4905 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4906 "Select newsgroup GROUP.
4907 If READ-ALL is non-nil, all articles in the group are selected.
4908 If SELECT-ARTICLES, only select those articles from GROUP."
4909 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4910 ;;!!! Dirty hack; should be removed.
4911 (gnus-summary-ignore-duplicates
4912 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4914 gnus-summary-ignore-duplicates))
4915 (info (nth 2 entry))
4916 articles fetched-articles cached)
4918 (unless (gnus-check-server
4919 (set (make-local-variable 'gnus-current-select-method)
4920 (gnus-find-method-for-group group)))
4921 (error "Couldn't open server"))
4923 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4924 (gnus-activate-group group) ; Or we can activate it...
4925 (progn ; Or we bug out.
4926 (when (equal major-mode 'gnus-summary-mode)
4927 (kill-buffer (current-buffer)))
4928 (error "Couldn't activate group %s: %s"
4929 group (gnus-status-message group))))
4931 (unless (gnus-request-group group t)
4932 (when (equal major-mode 'gnus-summary-mode)
4933 (kill-buffer (current-buffer)))
4934 (error "Couldn't request group %s: %s"
4935 group (gnus-status-message group)))
4937 (setq gnus-newsgroup-name group
4938 gnus-newsgroup-unselected nil
4939 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4941 (let ((display (gnus-group-find-parameter group 'display)))
4942 (setq gnus-newsgroup-display
4944 ((not (zerop (or (car-safe read-all) 0)))
4945 ;; The user entered the group with C-u SPC/RET, let's show
4951 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4953 ;; The following is probably the "correct" solution, but
4954 ;; it makes Gnus fetch all headers and then limit the
4955 ;; articles (which is slow), so instead we hack the
4956 ;; select-articles parameter instead. -- Simon Josefsson
4959 ;; (gnus-byte-compile
4960 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4962 (setq select-articles
4963 (gnus-uncompress-range
4964 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4968 (cdr (gnus-active group)))))
4973 (gnus-summary-setup-default-charset)
4975 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4976 (when (gnus-virtual-group-p group)
4977 (setq cached gnus-newsgroup-cached))
4979 (setq gnus-newsgroup-unreads
4980 (gnus-sorted-ndifference
4981 (gnus-sorted-ndifference gnus-newsgroup-unreads
4982 gnus-newsgroup-marked)
4983 gnus-newsgroup-dormant))
4985 (setq gnus-newsgroup-processable nil)
4987 (gnus-update-read-articles group gnus-newsgroup-unreads)
4989 ;; Adjust and set lists of article marks.
4991 (gnus-adjust-marked-articles info))
4992 (if (setq articles select-articles)
4993 (setq gnus-newsgroup-unselected
4994 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4995 (setq articles (gnus-articles-to-read group read-all)))
4999 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5001 ((eq articles 0) nil)
5003 ;; Init the dependencies hash table.
5004 (setq gnus-newsgroup-dependencies
5005 (gnus-make-hashtable (length articles)))
5006 (gnus-set-global-variables)
5007 ;; Retrieve the headers and read them in.
5009 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5011 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5013 (setq gnus-newsgroup-cached cached))
5015 ;; Suppress duplicates?
5016 (when gnus-suppress-duplicates
5017 (gnus-dup-suppress-articles))
5019 ;; Set the initial limit.
5020 (setq gnus-newsgroup-limit (copy-sequence articles))
5021 ;; Remove canceled articles from the list of unread articles.
5022 (setq fetched-articles
5023 (mapcar (lambda (headers) (mail-header-number headers))
5024 gnus-newsgroup-headers))
5025 (setq gnus-newsgroup-articles fetched-articles)
5026 (setq gnus-newsgroup-unreads
5027 (gnus-sorted-nintersection
5028 gnus-newsgroup-unreads fetched-articles))
5029 (gnus-compute-unseen-list)
5031 ;; Removed marked articles that do not exist.
5032 (gnus-update-missing-marks
5033 (gnus-sorted-difference articles fetched-articles))
5034 ;; We might want to build some more threads first.
5035 (when (and gnus-fetch-old-headers
5036 (eq gnus-headers-retrieved-by 'nov))
5037 (if (eq gnus-fetch-old-headers 'invisible)
5038 (gnus-build-all-threads)
5039 (gnus-build-old-threads)))
5040 ;; Let the Gnus agent mark articles as read.
5042 (gnus-agent-get-undownloaded-list))
5043 ;; Remove list identifiers from subject
5044 (when gnus-list-identifiers
5045 (gnus-summary-remove-list-identifiers))
5046 ;; Check whether auto-expire is to be done in this group.
5047 (setq gnus-newsgroup-auto-expire
5048 (gnus-group-auto-expirable-p group))
5049 ;; Set up the article buffer now, if necessary.
5050 (unless gnus-single-article-buffer
5051 (gnus-article-setup-buffer))
5052 ;; First and last article in this newsgroup.
5053 (when gnus-newsgroup-headers
5054 (setq gnus-newsgroup-begin
5055 (mail-header-number (car gnus-newsgroup-headers))
5058 (gnus-last-element gnus-newsgroup-headers))))
5059 ;; GROUP is successfully selected.
5060 (or gnus-newsgroup-headers t)))))
5062 (defun gnus-compute-unseen-list ()
5063 ;; The `seen' marks are treated specially.
5064 (if (not gnus-newsgroup-seen)
5065 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5066 (setq gnus-newsgroup-unseen
5067 (gnus-inverse-list-range-intersection
5068 gnus-newsgroup-articles gnus-newsgroup-seen))))
5070 (defun gnus-summary-display-make-predicate (display)
5071 (require 'gnus-agent)
5072 (when (= (length display) 1)
5073 (setq display (car display)))
5074 (unless gnus-summary-display-cache
5075 (dolist (elem (append '((unread . unread)
5078 gnus-article-mark-lists))
5079 (push (cons (cdr elem)
5081 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5082 gnus-summary-display-cache)))
5083 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5084 (gnus-category-predicate-cache gnus-summary-display-cache))
5085 (gnus-get-predicate display)))
5087 ;; Uses the dynamically bound `number' variable.
5090 (defun gnus-article-marked-p (type &optional article)
5091 (let ((article (or article number)))
5094 (memq article gnus-newsgroup-marked))
5096 (memq article gnus-newsgroup-spam-marked))
5098 (memq article gnus-newsgroup-unsendable))
5099 ((eq type 'undownload)
5100 (memq article gnus-newsgroup-undownloaded))
5101 ((eq type 'download)
5102 (memq article gnus-newsgroup-downloadable))
5104 (memq article gnus-newsgroup-unreads))
5106 (memq article gnus-newsgroup-reads))
5108 (memq article gnus-newsgroup-dormant) )
5110 (memq article gnus-newsgroup-expirable))
5112 (memq article gnus-newsgroup-replied))
5114 (memq article gnus-newsgroup-killed))
5115 ((eq type 'bookmark)
5116 (assq article gnus-newsgroup-bookmarks))
5118 (assq article gnus-newsgroup-scored))
5120 (memq article gnus-newsgroup-saved))
5122 (memq article gnus-newsgroup-cached))
5124 (memq article gnus-newsgroup-forwarded))
5126 (not (memq article gnus-newsgroup-unseen)))
5128 (memq article gnus-newsgroup-recent))
5131 (defun gnus-articles-to-read (group &optional read-all)
5132 "Find out what articles the user wants to read."
5133 (let* ((display (gnus-group-find-parameter group 'display))
5135 ;; Select all articles if `read-all' is non-nil, or if there
5136 ;; are no unread articles.
5138 (and (zerop (length gnus-newsgroup-marked))
5139 (zerop (length gnus-newsgroup-unreads)))
5140 ;; Fetch all if the predicate is non-nil.
5141 gnus-newsgroup-display)
5142 ;; We want to select the headers for all the articles in
5143 ;; the group, so we select either all the active
5144 ;; articles in the group, or (if that's nil), the
5145 ;; articles in the cache.
5147 (gnus-uncompress-range (gnus-active group))
5148 (gnus-cache-articles-in-group group))
5149 ;; Select only the "normal" subset of articles.
5151 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5152 gnus-newsgroup-unreads)))
5153 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5154 (scored (length scored-list))
5155 (number (length articles))
5156 (marked (+ (length gnus-newsgroup-marked)
5157 (length gnus-newsgroup-dormant)))
5162 ((numberp gnus-newsgroup-display)
5163 gnus-newsgroup-display)
5167 ((and (or (<= scored marked) (= scored number))
5168 (numberp gnus-large-newsgroup)
5169 (> number gnus-large-newsgroup))
5170 (let* ((cursor-in-echo-area nil)
5171 (initial (gnus-parameter-large-newsgroup-initial
5172 gnus-newsgroup-name))
5176 "How many articles from %s (%s %d): "
5178 (gnus-group-decoded-name gnus-newsgroup-name)
5180 (if initial "max" "default")
5183 (cons (number-to-string initial)
5185 (if (string-match "^[ \t]*$" input) number input)))
5186 ((and (> scored marked) (< scored number)
5187 (> (- scored number) 20))
5190 (format "%s %s (%d scored, %d total): "
5191 "How many articles from"
5192 (gnus-group-decoded-name group)
5194 (if (string-match "^[ \t]*$" input)
5198 (message "Quit getting the articles to read")
5200 (setq select (if (stringp select) (string-to-number select) select))
5201 (if (or (null select) (zerop select))
5203 (if (and (not (zerop scored)) (<= (abs select) scored))
5205 (setq articles (sort scored-list '<))
5206 (setq number (length articles)))
5207 (setq articles (copy-sequence articles)))
5209 (when (< (abs select) number)
5211 ;; Select the N oldest articles.
5212 (setcdr (nthcdr (1- (abs select)) articles) nil)
5213 ;; Select the N most recent articles.
5214 (setq articles (nthcdr (- number select) articles))))
5215 (setq gnus-newsgroup-unselected
5216 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5217 (when gnus-alter-articles-to-read-function
5220 (funcall gnus-alter-articles-to-read-function
5221 gnus-newsgroup-name articles)
5225 (defun gnus-killed-articles (killed articles)
5228 (when (inline (gnus-member-of-range (car articles) killed))
5229 (push (car articles) out))
5230 (setq articles (cdr articles)))
5233 (defun gnus-uncompress-marks (marks)
5234 "Uncompress the mark ranges in MARKS."
5235 (let ((uncompressed '(score bookmark))
5238 (if (memq (caar marks) uncompressed)
5239 (push (car marks) out)
5240 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5241 (setq marks (cdr marks)))
5244 (defun gnus-article-mark-to-type (mark)
5245 "Return the type of MARK."
5246 (or (cadr (assq mark gnus-article-special-mark-lists))
5249 (defun gnus-article-unpropagatable-p (mark)
5250 "Return whether MARK should be propagated to backend."
5251 (memq mark gnus-article-unpropagated-mark-lists))
5253 (defun gnus-adjust-marked-articles (info)
5254 "Set all article lists and remove all marks that are no longer valid."
5255 (let* ((marked-lists (gnus-info-marks info))
5256 (active (gnus-active (gnus-info-group info)))
5259 (types gnus-article-mark-lists)
5260 marks var articles article mark mark-type)
5262 (dolist (marks marked-lists)
5263 (setq mark (car marks)
5264 mark-type (gnus-article-mark-to-type mark)
5265 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5267 ;; We set the variable according to the type of the marks list,
5268 ;; and then adjust the marks to a subset of the active articles.
5270 ;; Adjust "simple" lists.
5271 ((eq mark-type 'list)
5272 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5273 (when (memq mark '(tick dormant expire reply save))
5275 (when (or (< (setq article (pop articles)) min) (> article max))
5276 (set var (delq article (symbol-value var)))))))
5278 ((eq mark-type 'tuple)
5279 (set var (setq articles (cdr marks)))
5280 (when (not (listp (cdr (symbol-value var))))
5281 (set var (list (symbol-value var))))
5282 (when (not (listp (cdr articles)))
5283 (setq articles (list articles)))
5285 (when (or (not (consp (setq article (pop articles))))
5286 (< (car article) min)
5287 (> (car article) max))
5288 (set var (delq article (symbol-value var))))))
5289 ;; Adjust ranges (sloppily).
5290 ((eq mark-type 'range)
5293 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5294 ;; It should be (seen (NUM1 . NUM2)).
5295 (when (numberp (cddr marks))
5296 (setcdr marks (list (cdr marks))))
5297 (setq articles (cdr marks))
5298 (while (and articles
5299 (or (and (consp (car articles))
5300 (> min (cdar articles)))
5301 (and (numberp (car articles))
5302 (> min (car articles)))))
5304 (set var articles))))))))
5306 (defun gnus-update-missing-marks (missing)
5307 "Go through the list of MISSING articles and remove them from the mark lists."
5310 ;; Go through all types.
5311 (dolist (elem gnus-article-mark-lists)
5312 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5313 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5314 (when (symbol-value var)
5315 ;; This list has articles. So we delete all missing
5316 ;; articles from it.
5319 (set var (delq (pop m) (symbol-value var))))))))))
5321 (defun gnus-update-marks ()
5322 "Enter the various lists of marked articles into the newsgroup info list."
5323 (let ((types gnus-article-mark-lists)
5324 (info (gnus-get-info gnus-newsgroup-name))
5325 type list newmarked symbol delta-marks)
5327 ;; Add all marks lists to the list of marks lists.
5328 (while (setq type (pop types))
5329 (setq list (symbol-value
5331 (intern (format "gnus-newsgroup-%s" (car type))))))
5334 ;; Get rid of the entries of the articles that have the
5336 (when (and (eq (cdr type) 'score)
5340 (prev (cons nil list))
5343 (if (or (not (consp (car arts)))
5344 (= (cdar arts) gnus-summary-default-score))
5345 (setcdr prev (cdr arts))
5347 (setq arts (cdr arts)))
5348 (setq list (cdr all)))))
5350 (when (eq (cdr type) 'seen)
5351 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5353 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5354 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5356 (when (and (gnus-check-backend-function
5357 'request-set-mark gnus-newsgroup-name)
5358 (not (gnus-article-unpropagatable-p (cdr type))))
5359 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5360 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5361 (add (gnus-remove-from-range
5362 (gnus-copy-sequence list) old)))
5364 (push (list add 'add (list (cdr type))) delta-marks))
5366 (push (list del 'del (list (cdr type))) delta-marks))))
5369 (push (cons (cdr type) list) newmarked)))
5372 (unless (gnus-check-group gnus-newsgroup-name)
5373 (error "Can't open server for %s" gnus-newsgroup-name))
5374 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5376 ;; Enter these new marks into the info of the group.
5378 (setcar (nthcdr 3 info) newmarked)
5379 ;; Add the marks lists to the end of the info.
5381 (setcdr (nthcdr 2 info) (list newmarked))))
5383 ;; Cut off the end of the info if there's nothing else there.
5387 (when (nthcdr (decf i) info)
5388 (setcdr (nthcdr i info) nil)))))))
5390 (defun gnus-set-mode-line (where)
5391 "Set the mode line of the article or summary buffers.
5392 If WHERE is `summary', the summary mode line format will be used."
5393 ;; Is this mode line one we keep updated?
5394 (when (and (memq where gnus-updated-mode-lines)
5396 (intern (format "gnus-%s-mode-line-format-spec" where))))
5399 ;; We evaluate this in the summary buffer since these
5400 ;; variables are buffer-local to that buffer.
5401 (set-buffer gnus-summary-buffer)
5402 ;; We bind all these variables that are used in the `eval' form
5404 (let* ((mformat (symbol-value
5406 (format "gnus-%s-mode-line-format-spec" where))))
5407 (gnus-tmp-group-name (gnus-group-decoded-name
5408 gnus-newsgroup-name))
5409 (gnus-tmp-article-number (or gnus-current-article 0))
5410 (gnus-tmp-unread gnus-newsgroup-unreads)
5411 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5412 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5413 (gnus-tmp-unread-and-unselected
5414 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5415 (zerop gnus-tmp-unselected))
5417 ((zerop gnus-tmp-unselected)
5418 (format "{%d more}" gnus-tmp-unread-and-unticked))
5419 (t (format "{%d(+%d) more}"
5420 gnus-tmp-unread-and-unticked
5421 gnus-tmp-unselected))))
5423 (if (and gnus-current-headers
5424 (vectorp gnus-current-headers))
5425 (gnus-mode-string-quote
5426 (mail-header-subject gnus-current-headers))
5428 bufname-length max-len
5429 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5430 (setq mode-string (eval mformat))
5431 (setq bufname-length (if (string-match "%b" mode-string)
5434 (if (eq where 'summary)
5436 (get-buffer gnus-article-buffer))))
5439 (setq max-len (max 4 (if gnus-mode-non-string-length
5441 gnus-mode-non-string-length
5443 (length mode-string))))
5444 ;; We might have to chop a bit of the string off...
5445 (when (> (length mode-string) max-len)
5447 (concat (truncate-string-to-width mode-string (- max-len 3))
5449 ;; Pad the mode string a bit.
5450 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5451 ;; Update the mode line.
5452 (setq mode-line-buffer-identification
5453 (gnus-mode-line-buffer-identification (list mode-string)))
5454 (set-buffer-modified-p t))))
5456 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5457 "Go through the HEADERS list and add all Xrefs to a hash table.
5458 The resulting hash table is returned, or nil if no Xrefs were found."
5459 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5460 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5461 (xref-hashtb (gnus-make-hashtable))
5462 start group entry number xrefs header)
5464 (setq header (pop headers))
5465 (when (and (setq xrefs (mail-header-xref header))
5466 (not (memq (setq number (mail-header-number header))
5469 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5470 (setq start (match-end 0))
5471 (setq group (if prefix
5472 (concat prefix (substring xrefs (match-beginning 1)
5474 (substring xrefs (match-beginning 1) (match-end 1))))
5476 (string-to-int (substring xrefs (match-beginning 2)
5478 (if (setq entry (gnus-gethash group xref-hashtb))
5479 (setcdr entry (cons number (cdr entry)))
5480 (gnus-sethash group (cons number nil) xref-hashtb)))))
5481 (and start xref-hashtb)))
5483 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5484 "Look through all the headers and mark the Xrefs as read."
5485 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5486 name entry info xref-hashtb idlist method nth4)
5488 (set-buffer gnus-group-buffer)
5489 (when (setq xref-hashtb
5490 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5493 (unless (string= from-newsgroup (setq name (symbol-name group)))
5494 (setq idlist (symbol-value group))
5495 ;; Dead groups are not updated.
5497 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5499 (when (stringp (setq nth4 (gnus-info-method info)))
5500 (setq nth4 (gnus-server-to-method nth4))))
5501 ;; Only do the xrefs if the group has the same
5502 ;; select method as the group we have just read.
5503 (or (gnus-methods-equal-p
5504 nth4 (gnus-find-method-for-group from-newsgroup))
5506 (equal nth4 (setq method (gnus-find-method-for-group
5508 (and (equal (car nth4) (car method))
5509 (equal (nth 1 nth4) (nth 1 method))))
5510 gnus-use-cross-reference
5511 (or (not (eq gnus-use-cross-reference t))
5513 ;; Only do cross-references on subscribed
5514 ;; groups, if that is what is wanted.
5515 (<= (gnus-info-level info) gnus-level-subscribed))
5516 (gnus-group-make-articles-read name idlist))))
5519 (defun gnus-compute-read-articles (group articles)
5520 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5521 (info (nth 2 entry))
5522 (active (gnus-active group))
5525 ;; First peel off all invalid article numbers.
5527 (let ((ids articles)
5529 (while (setq id (pop ids))
5530 (when (and first (> id (cdr active)))
5531 ;; We'll end up in this situation in one particular
5532 ;; obscure situation. If you re-scan a group and get
5533 ;; a new article that is cross-posted to a different
5534 ;; group that has not been re-scanned, you might get
5535 ;; crossposted article that has a higher number than
5536 ;; Gnus believes possible. So we re-activate this
5537 ;; group as well. This might mean doing the
5538 ;; crossposting thingy will *increase* the number
5539 ;; of articles in some groups. Tsk, tsk.
5540 (setq active (or (gnus-activate-group group) active)))
5541 (when (or (> id (cdr active))
5542 (< id (car active)))
5543 (setq articles (delq id articles))))))
5544 ;; If the read list is nil, we init it.
5546 (null (gnus-info-read info))
5548 (setq ninfo (cons 1 (1- (car active))))
5549 (setq ninfo (gnus-info-read info)))
5550 ;; Then we add the read articles to the range.
5552 ninfo (setq articles (sort articles '<))))))
5554 (defun gnus-group-make-articles-read (group articles)
5555 "Update the info of GROUP to say that ARTICLES are read."
5557 (entry (gnus-gethash group gnus-newsrc-hashtb))
5558 (info (nth 2 entry))
5559 (active (gnus-active group))
5562 (setq range (gnus-compute-read-articles group articles))
5564 (set-buffer gnus-group-buffer)
5567 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5568 (gnus-info-set-read ',info ',(gnus-info-read info))
5569 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5570 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5571 (gnus-group-update-group ,group t))))
5572 ;; Add the read articles to the range.
5573 (gnus-info-set-read info range)
5574 (gnus-request-set-mark group (list (list range 'add '(read))))
5575 ;; Then we have to re-compute how many unread
5576 ;; articles there are in this group.
5580 (setq num (- (1+ (cdr active)) (car active))))
5581 ((not (listp (cdr range)))
5582 (setq num (- (cdr active) (- (1+ (cdr range))
5586 (if (numberp (car range))
5588 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5589 (setq range (cdr range)))
5590 (setq num (- (cdr active) num))))
5591 ;; Update the number of unread articles.
5593 ;; Update the group buffer.
5594 (unless (gnus-ephemeral-group-p group)
5595 (gnus-group-update-group group t))))))
5597 (defvar gnus-newsgroup-none-id 0)
5599 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5600 (let ((cur nntp-server-buffer)
5603 (save-excursion (set-buffer gnus-summary-buffer)
5604 gnus-newsgroup-dependencies)))
5606 (mail-parse-charset gnus-newsgroup-charset)
5607 (mail-parse-ignored-charsets
5608 (save-excursion (condition-case nil
5609 (set-buffer gnus-summary-buffer)
5611 gnus-newsgroup-ignored-charsets)))
5613 (set-buffer nntp-server-buffer)
5614 ;; Translate all TAB characters into SPACE characters.
5615 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5616 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5617 (gnus-run-hooks 'gnus-parse-headers-hook)
5618 (let ((case-fold-search t)
5619 in-reply-to header p lines chars)
5620 (goto-char (point-min))
5621 ;; Search to the beginning of the next header. Error messages
5622 ;; do not begin with 2 or 3.
5623 (while (re-search-forward "^[23][0-9]+ " nil t)
5626 ;; This implementation of this function, with nine
5627 ;; search-forwards instead of the one re-search-forward and
5628 ;; a case (which basically was the old function) is actually
5629 ;; about twice as fast, even though it looks messier. You
5630 ;; can't have everything, I guess. Speed and elegance
5631 ;; doesn't always go hand in hand.
5640 (narrow-to-region (point)
5641 (or (and (search-forward "\n.\n" nil t)
5647 (if (search-forward "\nsubject:" nil t)
5648 (funcall gnus-decode-encoded-word-function
5649 (nnheader-header-value))
5654 (if (search-forward "\nfrom:" nil t)
5655 (funcall gnus-decode-encoded-word-function
5656 (nnheader-header-value))
5661 (if (search-forward "\ndate:" nil t)
5662 (nnheader-header-value) ""))
5666 (setq id (if (re-search-forward
5667 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5668 ;; We do it this way to make sure the Message-ID
5669 ;; is (somewhat) syntactically valid.
5670 (buffer-substring (match-beginning 1)
5672 ;; If there was no message-id, we just fake one
5673 ;; to make subsequent routines simpler.
5674 (nnheader-generate-fake-message-id))))
5678 (if (search-forward "\nreferences:" nil t)
5682 (nnheader-header-value)
5687 (search-backward ">" end t)
5690 (search-backward "<" end t)
5692 ;; Get the references from the in-reply-to header if there
5693 ;; were no references and the in-reply-to header looks
5695 (if (and (search-forward "\nin-reply-to:" nil t)
5696 (setq in-reply-to (nnheader-header-value))
5697 (string-match "<[^>]+>" in-reply-to))
5699 (setq ref (substring in-reply-to (match-beginning 0)
5701 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5702 (setq ref2 (substring in-reply-to (match-beginning 0)
5704 (when (> (length ref2) (length ref))
5711 (if (search-forward "\nchars: " nil t)
5712 (if (numberp (setq chars (ignore-errors (read cur))))
5718 (if (search-forward "\nlines: " nil t)
5719 (if (numberp (setq lines (ignore-errors (read cur))))
5725 (and (search-forward "\nxref:" nil t)
5726 (nnheader-header-value)))
5728 (when gnus-extra-headers
5729 (let ((extra gnus-extra-headers)
5733 (when (search-forward
5734 (concat "\n" (symbol-name (car extra)) ":") nil t)
5735 (push (cons (car extra) (nnheader-header-value))
5739 (when (equal id ref)
5742 (when gnus-alter-header-function
5743 (funcall gnus-alter-header-function header)
5744 (setq id (mail-header-id header)
5745 ref (gnus-parent-id (mail-header-references header))))
5748 (gnus-dependencies-add-header
5749 header dependencies force-new))
5750 (push header headers))
5751 (goto-char (point-max))
5753 (nreverse headers)))))
5755 ;; Goes through the xover lines and returns a list of vectors
5756 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5757 force-new dependencies
5758 group also-fetch-heads)
5759 "Parse the news overview data in the server buffer.
5760 Return a list of headers that match SEQUENCE (see
5761 `nntp-retrieve-headers')."
5762 ;; Get the Xref when the users reads the articles since most/some
5763 ;; NNTP servers do not include Xrefs when using XOVER.
5764 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5765 (let ((mail-parse-charset gnus-newsgroup-charset)
5766 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5767 (cur nntp-server-buffer)
5768 (dependencies (or dependencies gnus-newsgroup-dependencies))
5770 ((eq gnus-read-all-available-headers t)
5772 ((stringp gnus-read-all-available-headers)
5773 (string-match gnus-read-all-available-headers group))
5776 number headers header)
5778 (set-buffer nntp-server-buffer)
5779 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5780 ;; Allow the user to mangle the headers before parsing them.
5781 (gnus-run-hooks 'gnus-parse-headers-hook)
5782 (goto-char (point-min))
5783 (gnus-parse-without-error
5784 (while (and (or sequence allp)
5786 (setq number (read cur))
5788 (while (and sequence
5789 (< (car sequence) number))
5790 (setq sequence (cdr sequence))))
5793 (eq number (car sequence))))
5795 (setq sequence (cdr sequence))
5796 (setq header (inline
5797 (gnus-nov-parse-line
5798 number dependencies force-new)))))
5799 (push header headers))
5801 ;; A common bug in inn is that if you have posted an article and
5802 ;; then retrieves the active file, it will answer correctly --
5803 ;; the new article is included. However, a NOV entry for the
5804 ;; article may not have been generated yet, so this may fail.
5805 ;; We work around this problem by retrieving the last few
5806 ;; headers using HEAD.
5807 (if (or (not also-fetch-heads)
5809 ;; We (probably) got all the headers.
5811 (let ((gnus-nov-is-evil t))
5814 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5815 (gnus-get-newsgroup-headers))))))))
5817 (defun gnus-article-get-xrefs ()
5818 "Fill in the Xref value in `gnus-current-headers', if necessary.
5819 This is meant to be called in `gnus-article-internal-prepare-hook'."
5820 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5821 gnus-current-headers)))
5822 (or (not gnus-use-cross-reference)
5824 (and (mail-header-xref headers)
5825 (not (string= (mail-header-xref headers) "")))
5826 (let ((case-fold-search t)
5829 (nnheader-narrow-to-headers)
5830 (goto-char (point-min))
5831 (when (or (and (not (eobp))
5832 (eq (downcase (char-after)) ?x)
5833 (looking-at "Xref:"))
5834 (search-forward "\nXref:" nil t))
5835 (goto-char (1+ (match-end 0)))
5836 (setq xref (buffer-substring (point)
5837 (progn (end-of-line) (point))))
5838 (mail-header-set-xref headers xref)))))))
5840 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5841 "Find article ID and insert the summary line for that article.
5842 OLD-HEADER can either be a header or a line number to insert
5843 the subject line on."
5844 (let* ((line (and (numberp old-header) old-header))
5845 (old-header (and (vectorp old-header) old-header))
5846 (header (cond ((and old-header use-old-header)
5849 (gnus-number-to-header id))
5850 (gnus-number-to-header id))
5852 (gnus-read-header id))))
5853 (number (and (numberp id) id))
5856 ;; Rebuild the thread that this article is part of and go to the
5857 ;; article we have fetched.
5858 (when (and (not gnus-show-threads)
5861 (setq d (gnus-data-find (mail-header-number old-header))))
5862 (goto-char (gnus-data-pos d))
5865 (- (gnus-point-at-bol)
5867 (1+ (gnus-point-at-eol))
5868 (gnus-delete-line))))))
5870 (mail-header-set-number header (mail-header-number old-header)))
5871 (setq gnus-newsgroup-sparse
5872 (delq (setq number (mail-header-number header))
5873 gnus-newsgroup-sparse))
5874 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5875 (push number gnus-newsgroup-limit)
5876 (gnus-rebuild-thread (mail-header-id header) line)
5877 (gnus-summary-goto-subject number nil t))
5878 (when (and (numberp number)
5880 ;; We have to update the boundaries even if we can't fetch the
5881 ;; article if ID is a number -- so that the next `P' or `N'
5882 ;; command will fetch the previous (or next) article even
5883 ;; if the one we tried to fetch this time has been canceled.
5884 (when (> number gnus-newsgroup-end)
5885 (setq gnus-newsgroup-end number))
5886 (when (< number gnus-newsgroup-begin)
5887 (setq gnus-newsgroup-begin number))
5888 (setq gnus-newsgroup-unselected
5889 (delq number gnus-newsgroup-unselected)))
5890 ;; Report back a success?
5891 (and header (mail-header-number header))))
5893 ;;; Process/prefix in the summary buffer
5895 (defun gnus-summary-work-articles (n)
5896 "Return a list of articles to be worked upon.
5897 The prefix argument, the list of process marked articles, and the
5898 current article will be taken into consideration."
5900 (set-buffer gnus-summary-buffer)
5903 ;; A numerical prefix has been given.
5904 (setq n (prefix-numeric-value n))
5905 (let ((backward (< n 0))
5906 (n (abs (prefix-numeric-value n)))
5911 (push (setq article (gnus-summary-article-number))
5914 (gnus-summary-find-prev nil article)
5915 (gnus-summary-find-next nil article)))
5917 (nreverse articles)))
5918 ((and (gnus-region-active-p) (mark))
5919 (message "region active")
5920 ;; Work on the region between point and mark.
5921 (let ((max (max (point) (mark)))
5924 (goto-char (min (min (point) (mark))))
5927 (push (setq article (gnus-summary-article-number)) articles)
5928 (gnus-summary-find-next nil article)
5930 (nreverse articles))))
5931 (gnus-newsgroup-processable
5932 ;; There are process-marked articles present.
5933 ;; Save current state.
5934 (gnus-summary-save-process-mark)
5936 (reverse gnus-newsgroup-processable))
5938 ;; Just return the current article.
5939 (list (gnus-summary-article-number))))))
5941 (defmacro gnus-summary-iterate (arg &rest forms)
5942 "Iterate over the process/prefixed articles and do FORMS.
5943 ARG is the interactive prefix given to the command. FORMS will be
5944 executed with point over the summary line of the articles."
5945 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5946 `(let ((,articles (gnus-summary-work-articles ,arg)))
5948 (gnus-summary-goto-subject (car ,articles))
5952 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5953 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5955 (defun gnus-summary-save-process-mark ()
5956 "Push the current set of process marked articles on the stack."
5958 (push (copy-sequence gnus-newsgroup-processable)
5959 gnus-newsgroup-process-stack))
5961 (defun gnus-summary-kill-process-mark ()
5962 "Push the current set of process marked articles on the stack and unmark."
5964 (gnus-summary-save-process-mark)
5965 (gnus-summary-unmark-all-processable))
5967 (defun gnus-summary-yank-process-mark ()
5968 "Pop the last process mark state off the stack and restore it."
5970 (unless gnus-newsgroup-process-stack
5971 (error "Empty mark stack"))
5972 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5974 (defun gnus-summary-process-mark-set (set)
5975 "Make SET into the current process marked articles."
5976 (gnus-summary-unmark-all-processable)
5978 (gnus-summary-set-process-mark (pop set))))
5980 ;;; Searching and stuff
5982 (defun gnus-summary-search-group (&optional backward use-level)
5983 "Search for next unread newsgroup.
5984 If optional argument BACKWARD is non-nil, search backward instead."
5986 (set-buffer gnus-group-buffer)
5987 (when (gnus-group-search-forward
5988 backward nil (if use-level (gnus-group-group-level) nil))
5989 (gnus-group-group-name))))
5991 (defun gnus-summary-best-group (&optional exclude-group)
5992 "Find the name of the best unread group.
5993 If EXCLUDE-GROUP, do not go to this group."
5995 (set-buffer gnus-group-buffer)
5997 (gnus-group-best-unread-group exclude-group))))
5999 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
6000 (if backward (gnus-summary-find-prev)
6001 (let* ((dummy (gnus-summary-article-intangible-p))
6002 (article (or article (gnus-summary-article-number)))
6003 (arts (gnus-data-find-list article))
6005 (when (and (not dummy)
6006 (or (not gnus-summary-check-current)
6008 (not (gnus-data-unread-p (car arts)))))
6009 (setq arts (cdr arts)))
6014 (when (or (and undownloaded
6015 (memq (car arts) gnus-newsgroup-undownloaded))
6016 (gnus-data-unread-p (car arts)))
6017 (setq result (car arts)
6019 (setq arts (cdr arts)))
6022 (goto-char (gnus-data-pos result))
6023 (gnus-data-number result)))))
6025 (defun gnus-summary-find-prev (&optional unread article)
6026 (let* ((eobp (eobp))
6027 (article (or article (gnus-summary-article-number)))
6028 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
6030 (when (and (not eobp)
6031 (or (not gnus-summary-check-current)
6033 (not (gnus-data-unread-p (car arts)))))
6034 (setq arts (cdr arts)))
6039 (when (gnus-data-unread-p (car arts))
6040 (setq result (car arts)
6042 (setq arts (cdr arts)))
6045 (goto-char (gnus-data-pos result))
6046 (gnus-data-number result))))
6048 (defun gnus-summary-find-subject (subject &optional unread backward article)
6049 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6050 (article (or article (gnus-summary-article-number)))
6051 (articles (gnus-data-list backward))
6052 (arts (gnus-data-find-list article articles))
6054 (when (or (not gnus-summary-check-current)
6056 (not (gnus-data-unread-p (car arts))))
6057 (setq arts (cdr arts)))
6059 (and (or (not unread)
6060 (gnus-data-unread-p (car arts)))
6061 (vectorp (gnus-data-header (car arts)))
6063 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6064 (setq result (car arts)
6066 (setq arts (cdr arts)))
6068 (goto-char (gnus-data-pos result))
6069 (gnus-data-number result))))
6071 (defun gnus-summary-search-forward (&optional unread subject backward)
6072 "Search forward for an article.
6073 If UNREAD, look for unread articles. If SUBJECT, look for
6074 articles with that subject. If BACKWARD, search backward instead."
6075 (cond (subject (gnus-summary-find-subject subject unread backward))
6076 (backward (gnus-summary-find-prev unread))
6077 (t (gnus-summary-find-next unread))))
6079 (defun gnus-recenter (&optional n)
6080 "Center point in window and redisplay frame.
6081 Also do horizontal recentering."
6083 (when (and gnus-auto-center-summary
6084 (not (eq gnus-auto-center-summary 'vertical)))
6085 (gnus-horizontal-recenter))
6088 (defun gnus-summary-recenter ()
6089 "Center point in the summary window.
6090 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6091 displayed, no centering will be performed."
6092 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6093 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6095 (let* ((top (cond ((< (window-height) 4) 0)
6096 ((< (window-height) 7) 1)
6097 (t (if (numberp gnus-auto-center-summary)
6098 gnus-auto-center-summary
6100 (height (1- (window-height)))
6101 (bottom (save-excursion (goto-char (point-max))
6102 (forward-line (- height))
6104 (window (get-buffer-window (current-buffer))))
6105 ;; The user has to want it.
6106 (when gnus-auto-center-summary
6107 (when (get-buffer-window gnus-article-buffer)
6108 ;; Only do recentering when the article buffer is displayed,
6109 ;; Set the window start to either `bottom', which is the biggest
6110 ;; possible valid number, or the second line from the top,
6111 ;; whichever is the least.
6112 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6113 (if (> bottom top-pos)
6114 ;; Keep the second line from the top visible
6115 (set-window-start window top-pos t)
6116 ;; Try to keep the bottom line visible; if it's partially
6117 ;; obscured, either scroll one more line to make it fully
6118 ;; visible, or revert to using TOP-POS.
6120 (goto-char (point-max))
6122 (let ((last-line-start (point)))
6124 (set-window-start window (point) t)
6125 (when (not (pos-visible-in-window-p last-line-start window))
6127 (set-window-start window (min (point) top-pos) t)))))))
6128 ;; Do horizontal recentering while we're at it.
6129 (when (and (get-buffer-window (current-buffer) t)
6130 (not (eq gnus-auto-center-summary 'vertical)))
6131 (let ((selected (selected-window)))
6132 (select-window (get-buffer-window (current-buffer) t))
6133 (gnus-summary-position-point)
6134 (gnus-horizontal-recenter)
6135 (select-window selected))))))
6137 (defun gnus-summary-jump-to-group (newsgroup)
6138 "Move point to NEWSGROUP in group mode buffer."
6139 ;; Keep update point of group mode buffer if visible.
6140 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6141 (save-window-excursion
6142 ;; Take care of tree window mode.
6143 (when (get-buffer-window gnus-group-buffer)
6144 (pop-to-buffer gnus-group-buffer))
6145 (gnus-group-jump-to-group newsgroup))
6147 ;; Take care of tree window mode.
6148 (if (get-buffer-window gnus-group-buffer)
6149 (pop-to-buffer gnus-group-buffer)
6150 (set-buffer gnus-group-buffer))
6151 (gnus-group-jump-to-group newsgroup))))
6153 ;; This function returns a list of article numbers based on the
6154 ;; difference between the ranges of read articles in this group and
6155 ;; the range of active articles.
6156 (defun gnus-list-of-unread-articles (group)
6157 (let* ((read (gnus-info-read (gnus-get-info group)))
6158 (active (or (gnus-active group) (gnus-activate-group group)))
6161 ;; If none are read, then all are unread.
6163 (setq first (car active))
6164 ;; If the range of read articles is a single range, then the
6165 ;; first unread article is the article after the last read
6166 ;; article. Sounds logical, doesn't it?
6167 (if (and (not (listp (cdr read)))
6168 (or (< (car read) (car active))
6169 (progn (setq read (list read))
6171 (setq first (max (car active) (1+ (cdr read))))
6172 ;; `read' is a list of ranges.
6173 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6176 (setq first (car active)))
6179 (while (< first nlast)
6181 (setq first (1+ first))))
6182 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6183 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6184 (setq read (cdr read)))))
6185 ;; And add the last unread articles.
6186 (while (<= first last)
6188 (setq first (1+ first)))
6189 ;; Return the list of unread articles.
6190 (delq 0 (nreverse unread))))
6192 (defun gnus-list-of-read-articles (group)
6193 "Return a list of unread, unticked and non-dormant articles."
6194 (let* ((info (gnus-get-info group))
6195 (marked (gnus-info-marks info))
6196 (active (gnus-active group)))
6198 (gnus-list-range-difference
6199 (gnus-list-range-difference
6200 (gnus-sorted-complement
6201 (gnus-uncompress-range active)
6202 (gnus-list-of-unread-articles group))
6203 (cdr (assq 'dormant marked)))
6204 (cdr (assq 'tick marked))))))
6206 ;; Various summary commands
6208 (defun gnus-summary-select-article-buffer ()
6209 "Reconfigure windows to show article buffer."
6211 (if (not (gnus-buffer-live-p gnus-article-buffer))
6212 (error "There is no article buffer for this summary buffer")
6213 (gnus-configure-windows 'article)
6214 (select-window (get-buffer-window gnus-article-buffer))))
6216 (defun gnus-summary-universal-argument (arg)
6217 "Perform any operation on all articles that are process/prefixed."
6219 (let ((articles (gnus-summary-work-articles arg))
6226 (substitute-command-keys
6227 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6229 (gnus-error 1 "Undefined key")
6232 (gnus-summary-goto-subject (setq article (pop articles)))
6233 (let (gnus-newsgroup-processable)
6234 (command-execute func))
6235 (gnus-summary-remove-process-mark article)))))
6236 (gnus-summary-position-point))
6238 (defun gnus-summary-toggle-truncation (&optional arg)
6239 "Toggle truncation of summary lines.
6240 With arg, turn line truncation on if arg is positive."
6242 (setq truncate-lines
6243 (if (null arg) (not truncate-lines)
6244 (> (prefix-numeric-value arg) 0)))
6247 (defun gnus-summary-find-uncancelled ()
6248 "Return the number of an uncancelled article.
6249 The current article is considered, then following articles, then previous
6250 articles. If all articles are cancelled then return a dummy 0."
6252 (dolist (rev '(nil t))
6253 (unless found ; don't demand the reverse list if we don't need it
6254 (let ((data (gnus-data-find-list
6255 (gnus-summary-article-number) (gnus-data-list rev))))
6256 (while (and data (not found))
6257 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6258 (setq found (gnus-data-number (car data))))
6259 (setq data (cdr data))))))
6262 (defun gnus-summary-reselect-current-group (&optional all rescan)
6263 "Exit and then reselect the current newsgroup.
6264 The prefix argument ALL means to select all articles."
6266 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6267 (error "Ephemeral groups can't be reselected"))
6268 (let ((current-subject (gnus-summary-find-uncancelled))
6269 (group gnus-newsgroup-name))
6270 (setq gnus-newsgroup-begin nil)
6272 ;; We have to adjust the point of group mode buffer because
6273 ;; point was moved to the next unread newsgroup by exiting.
6274 (gnus-summary-jump-to-group group)
6277 (gnus-group-get-new-news-this-group 1)))
6278 (gnus-group-read-group all t)
6279 (gnus-summary-goto-subject current-subject nil t)))
6281 (defun gnus-summary-rescan-group (&optional all)
6282 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6284 (gnus-summary-reselect-current-group all t))
6286 (defun gnus-summary-update-info (&optional non-destructive)
6288 (let ((group gnus-newsgroup-name))
6290 (when gnus-newsgroup-kill-headers
6291 (setq gnus-newsgroup-killed
6292 (gnus-compress-sequence
6294 (gnus-list-range-intersection
6295 gnus-newsgroup-unselected gnus-newsgroup-killed)
6296 gnus-newsgroup-unreads)
6298 (unless (listp (cdr gnus-newsgroup-killed))
6299 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6300 (let ((headers gnus-newsgroup-headers))
6301 ;; Set the new ranges of read articles.
6303 (set-buffer gnus-group-buffer)
6304 (gnus-undo-force-boundary))
6305 (gnus-update-read-articles
6306 group (gnus-sorted-union
6307 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6308 ;; Set the current article marks.
6309 (let ((gnus-newsgroup-scored
6310 (if (and (not gnus-save-score)
6311 (not non-destructive))
6313 gnus-newsgroup-scored)))
6315 (gnus-update-marks)))
6316 ;; Do the cross-ref thing.
6317 (when gnus-use-cross-reference
6318 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6319 ;; Do not switch windows but change the buffer to work.
6320 (set-buffer gnus-group-buffer)
6321 (unless (gnus-ephemeral-group-p group)
6322 (gnus-group-update-group group)))))))
6324 (defun gnus-summary-save-newsrc (&optional force)
6325 "Save the current number of read/marked articles in the dribble buffer.
6326 The dribble buffer will then be saved.
6327 If FORCE (the prefix), also save the .newsrc file(s)."
6329 (gnus-summary-update-info t)
6331 (gnus-save-newsrc-file)
6332 (gnus-dribble-save)))
6334 (defun gnus-summary-exit (&optional temporary)
6335 "Exit reading current newsgroup, and then return to group selection mode.
6336 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6338 (gnus-set-global-variables)
6339 (when (gnus-buffer-live-p gnus-article-buffer)
6341 (set-buffer gnus-article-buffer)
6342 (mm-destroy-parts gnus-article-mime-handles)
6343 ;; Set it to nil for safety reason.
6344 (setq gnus-article-mime-handle-alist nil)
6345 (setq gnus-article-mime-handles nil)))
6346 (gnus-kill-save-kill-buffer)
6347 (gnus-async-halt-prefetch)
6348 (let* ((group gnus-newsgroup-name)
6349 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6350 (gnus-group-is-exiting-p t)
6353 (buf (current-buffer)))
6355 ;; Do adaptive scoring, and possibly save score files.
6356 (when gnus-newsgroup-adaptive
6357 (gnus-score-adaptive))
6358 (when gnus-use-scoring
6360 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6361 ;; If we have several article buffers, we kill them at exit.
6362 (unless gnus-single-article-buffer
6363 (gnus-kill-buffer gnus-original-article-buffer)
6364 (setq gnus-article-current nil))
6365 (when gnus-use-cache
6366 (gnus-cache-possibly-remove-articles)
6367 (gnus-cache-save-buffers))
6368 (gnus-async-prefetch-remove-group group)
6369 (when gnus-suppress-duplicates
6370 (gnus-dup-enter-articles))
6371 (when gnus-use-trees
6372 (gnus-tree-close group))
6373 (when gnus-use-cache
6374 (gnus-cache-write-active))
6375 ;; Remove entries for this group.
6376 (nnmail-purge-split-history (gnus-group-real-name group))
6377 ;; Make all changes in this group permanent.
6379 (gnus-run-hooks 'gnus-exit-group-hook)
6380 (gnus-summary-update-info))
6381 (gnus-close-group group)
6382 ;; Make sure where we were, and go to next newsgroup.
6383 (set-buffer gnus-group-buffer)
6385 (gnus-group-jump-to-group group))
6386 (gnus-run-hooks 'gnus-summary-exit-hook)
6387 (unless (or quit-config
6388 ;; If this group has disappeared from the summary
6389 ;; buffer, don't skip forwards.
6390 (not (string= group (gnus-group-group-name))))
6391 (gnus-group-next-unread-group 1))
6392 (setq group-point (point))
6395 ;; If we have several article buffers, we kill them at exit.
6396 (unless gnus-single-article-buffer
6397 (gnus-kill-buffer gnus-article-buffer)
6398 (gnus-kill-buffer gnus-original-article-buffer)
6399 (setq gnus-article-current nil))
6401 (if (not gnus-kill-summary-on-exit)
6403 (gnus-deaden-summary)
6405 ;; We set all buffer-local variables to nil. It is unclear why
6406 ;; this is needed, but if we don't, buffer-local variables are
6407 ;; not garbage-collected, it seems. This would the lead to en
6408 ;; ever-growing Emacs.
6409 (gnus-summary-clear-local-variables)
6410 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6411 (gnus-summary-clear-local-variables))
6412 (when (get-buffer gnus-article-buffer)
6413 (bury-buffer gnus-article-buffer))
6414 ;; We clear the global counterparts of the buffer-local
6415 ;; variables as well, just to be on the safe side.
6416 (set-buffer gnus-group-buffer)
6417 (gnus-summary-clear-local-variables)
6418 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6419 (gnus-summary-clear-local-variables))
6420 ;; Return to group mode buffer.
6421 (when (eq mode 'gnus-summary-mode)
6422 (gnus-kill-buffer buf)))
6423 (setq gnus-current-select-method gnus-select-method)
6424 (pop-to-buffer gnus-group-buffer)
6425 (if (not quit-config)
6427 (goto-char group-point)
6428 (gnus-configure-windows 'group 'force))
6429 (gnus-handle-ephemeral-exit quit-config))
6430 ;; Clear the current group name.
6432 (setq gnus-newsgroup-name nil)))))
6434 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6435 (defun gnus-summary-exit-no-update (&optional no-questions)
6436 "Quit reading current newsgroup without updating read article info."
6438 (let* ((group gnus-newsgroup-name)
6439 (gnus-group-is-exiting-p t)
6440 (quit-config (gnus-group-quit-config group)))
6441 (when (or no-questions
6443 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6444 (gnus-async-halt-prefetch)
6446 (delq 'gnus-summary-expire-articles
6447 (copy-sequence gnus-summary-prepare-exit-hook)))
6448 (when (gnus-buffer-live-p gnus-article-buffer)
6450 (set-buffer gnus-article-buffer)
6451 (mm-destroy-parts gnus-article-mime-handles)
6452 ;; Set it to nil for safety reason.
6453 (setq gnus-article-mime-handle-alist nil)
6454 (setq gnus-article-mime-handles nil)))
6455 ;; If we have several article buffers, we kill them at exit.
6456 (unless gnus-single-article-buffer
6457 (gnus-kill-buffer gnus-article-buffer)
6458 (gnus-kill-buffer gnus-original-article-buffer)
6459 (setq gnus-article-current nil))
6460 (if (not gnus-kill-summary-on-exit)
6461 (gnus-deaden-summary)
6462 (gnus-close-group group)
6463 (gnus-summary-clear-local-variables)
6464 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6465 (gnus-summary-clear-local-variables))
6466 (set-buffer gnus-group-buffer)
6467 (gnus-summary-clear-local-variables)
6468 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6469 (gnus-summary-clear-local-variables))
6470 (when (get-buffer gnus-summary-buffer)
6471 (kill-buffer gnus-summary-buffer)))
6472 (unless gnus-single-article-buffer
6473 (setq gnus-article-current nil))
6474 (when gnus-use-trees
6475 (gnus-tree-close group))
6476 (gnus-async-prefetch-remove-group group)
6477 (when (get-buffer gnus-article-buffer)
6478 (bury-buffer gnus-article-buffer))
6479 ;; Return to the group buffer.
6480 (gnus-configure-windows 'group 'force)
6481 ;; Clear the current group name.
6482 (setq gnus-newsgroup-name nil)
6483 (unless (gnus-ephemeral-group-p group)
6484 (gnus-group-update-group group))
6485 (when (equal (gnus-group-group-name) group)
6486 (gnus-group-next-unread-group 1))
6488 (gnus-handle-ephemeral-exit quit-config)))))
6490 (defun gnus-handle-ephemeral-exit (quit-config)
6491 "Handle movement when leaving an ephemeral group.
6492 The state which existed when entering the ephemeral is reset."
6493 (if (not (buffer-name (car quit-config)))
6494 (gnus-configure-windows 'group 'force)
6495 (set-buffer (car quit-config))
6496 (cond ((eq major-mode 'gnus-summary-mode)
6497 (gnus-set-global-variables))
6498 ((eq major-mode 'gnus-article-mode)
6500 ;; The `gnus-summary-buffer' variable may point
6501 ;; to the old summary buffer when using a single
6503 (unless (gnus-buffer-live-p gnus-summary-buffer)
6504 (set-buffer gnus-group-buffer))
6505 (set-buffer gnus-summary-buffer)
6506 (gnus-set-global-variables))))
6507 (if (or (eq (cdr quit-config) 'article)
6508 (eq (cdr quit-config) 'pick))
6510 ;; The current article may be from the ephemeral group
6511 ;; thus it is best that we reload this article
6512 (gnus-summary-show-article)
6513 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6514 (gnus-configure-windows 'pick 'force)
6515 (gnus-configure-windows (cdr quit-config) 'force)))
6516 (gnus-configure-windows (cdr quit-config) 'force))
6517 (when (eq major-mode 'gnus-summary-mode)
6518 (gnus-summary-next-subject 1 nil t)
6519 (gnus-summary-recenter)
6520 (gnus-summary-position-point))))
6524 (defvar gnus-dead-summary-mode-map nil)
6526 (unless gnus-dead-summary-mode-map
6527 (setq gnus-dead-summary-mode-map (make-keymap))
6528 (suppress-keymap gnus-dead-summary-mode-map)
6529 (substitute-key-definition
6530 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6531 (dolist (key '("\C-d" "\r" "\177" [delete]))
6532 (define-key gnus-dead-summary-mode-map
6533 key 'gnus-summary-wake-up-the-dead))
6534 (dolist (key '("q" "Q"))
6535 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6537 (defvar gnus-dead-summary-mode nil
6538 "Minor mode for Gnus summary buffers.")
6540 (defun gnus-dead-summary-mode (&optional arg)
6541 "Minor mode for Gnus summary buffers."
6543 (when (eq major-mode 'gnus-summary-mode)
6544 (make-local-variable 'gnus-dead-summary-mode)
6545 (setq gnus-dead-summary-mode
6546 (if (null arg) (not gnus-dead-summary-mode)
6547 (> (prefix-numeric-value arg) 0)))
6548 (when gnus-dead-summary-mode
6549 (gnus-add-minor-mode
6550 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6552 (defun gnus-deaden-summary ()
6553 "Make the current summary buffer into a dead summary buffer."
6554 ;; Kill any previous dead summary buffer.
6555 (when (and gnus-dead-summary
6556 (buffer-name gnus-dead-summary))
6558 (set-buffer gnus-dead-summary)
6559 (when gnus-dead-summary-mode
6560 (kill-buffer (current-buffer)))))
6561 ;; Make this the current dead summary.
6562 (setq gnus-dead-summary (current-buffer))
6563 (gnus-dead-summary-mode 1)
6564 (let ((name (buffer-name)))
6565 (when (string-match "Summary" name)
6567 (concat (substring name 0 (match-beginning 0)) "Dead "
6568 (substring name (match-beginning 0)))
6572 (defun gnus-kill-or-deaden-summary (buffer)
6573 "Kill or deaden the summary BUFFER."
6575 (when (and (buffer-name buffer)
6576 (not gnus-single-article-buffer))
6579 (gnus-kill-buffer gnus-article-buffer)
6580 (gnus-kill-buffer gnus-original-article-buffer)))
6583 (gnus-kill-summary-on-exit
6584 (when (and gnus-use-trees
6585 (gnus-buffer-exists-p buffer))
6588 (gnus-tree-close gnus-newsgroup-name)))
6589 (gnus-kill-buffer buffer))
6590 ;; Deaden the buffer.
6591 ((gnus-buffer-exists-p buffer)
6594 (gnus-deaden-summary))))))
6596 (defun gnus-summary-wake-up-the-dead (&rest args)
6597 "Wake up the dead summary buffer."
6599 (gnus-dead-summary-mode -1)
6600 (let ((name (buffer-name)))
6601 (when (string-match "Dead " name)
6603 (concat (substring name 0 (match-beginning 0))
6604 (substring name (match-end 0)))
6606 (gnus-message 3 "This dead summary is now alive again"))
6608 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6609 (defun gnus-summary-fetch-faq (&optional faq-dir)
6610 "Fetch the FAQ for the current group.
6611 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6615 (when current-prefix-arg
6617 "FAQ dir: " (and (listp gnus-group-faq-directory)
6618 (mapcar (lambda (file) (list file))
6619 gnus-group-faq-directory))))))
6620 (let (gnus-faq-buffer)
6621 (when (setq gnus-faq-buffer
6622 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6623 (gnus-configure-windows 'summary-faq))))
6625 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6626 (defun gnus-summary-describe-group (&optional force)
6627 "Describe the current newsgroup."
6629 (gnus-group-describe-group force gnus-newsgroup-name))
6631 (defun gnus-summary-describe-briefly ()
6632 "Describe summary mode commands briefly."
6634 (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")))
6636 ;; Walking around group mode buffer from summary mode.
6638 (defun gnus-summary-next-group (&optional no-article target-group backward)
6639 "Exit current newsgroup and then select next unread newsgroup.
6640 If prefix argument NO-ARTICLE is non-nil, no article is selected
6641 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6642 previous group instead."
6644 ;; Stop pre-fetching.
6645 (gnus-async-halt-prefetch)
6646 (let ((current-group gnus-newsgroup-name)
6647 (current-buffer (current-buffer))
6649 (while (not entered)
6650 ;; Then we find what group we are supposed to enter.
6651 (set-buffer gnus-group-buffer)
6652 (gnus-group-jump-to-group current-group)
6655 (if (eq gnus-keep-same-level 'best)
6656 (gnus-summary-best-group gnus-newsgroup-name)
6657 (gnus-summary-search-group backward gnus-keep-same-level))))
6658 (if (not target-group)
6659 ;; There are no further groups, so we return to the group
6662 (gnus-message 5 "Returning to the group buffer")
6664 (when (gnus-buffer-live-p current-buffer)
6665 (set-buffer current-buffer)
6666 (gnus-summary-exit))
6667 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6668 ;; We try to enter the target group.
6669 (gnus-group-jump-to-group target-group)
6670 (let ((unreads (gnus-group-group-unread)))
6671 (if (and (or (eq t unreads)
6672 (and unreads (not (zerop unreads))))
6674 ;; Now we semi-exit this group to update Xrefs
6675 ;; and all variables. We can't do a real exit,
6676 ;; because the window conf must remain the same
6677 ;; in case the user is prompted for info, and we
6678 ;; don't want the window conf to change before
6680 (when (gnus-buffer-live-p current-buffer)
6681 (set-buffer current-buffer)
6682 (gnus-summary-exit t))
6683 (gnus-summary-read-group
6684 target-group nil no-article
6685 (and (buffer-name current-buffer) current-buffer)
6688 (setq current-group target-group
6689 target-group nil)))))))
6691 (defun gnus-summary-prev-group (&optional no-article)
6692 "Exit current newsgroup and then select previous unread newsgroup.
6693 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6695 (gnus-summary-next-group no-article nil t))
6697 ;; Walking around summary lines.
6699 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6700 "Go to the first unread subject.
6701 If UNREAD is non-nil, go to the first unread article.
6702 Returns the article selected or nil if there are no unread articles."
6707 ((null gnus-newsgroup-data)
6708 (gnus-message 3 "No articles in the group")
6710 ;; Pick the first article.
6712 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6713 (gnus-data-number (car gnus-newsgroup-data)))
6714 ;; No unread articles.
6715 ((null gnus-newsgroup-unreads)
6716 (gnus-message 3 "No more unread articles")
6718 ;; Find the first unread article.
6720 (let ((data gnus-newsgroup-data))
6722 (and (not (and undownloaded
6724 gnus-newsgroup-undownloaded)))
6727 (gnus-data-number (car data))
6728 gnus-newsgroup-unseen))
6729 (not (gnus-data-unread-p (car data))))
6730 (not (gnus-data-unread-p (car data))))))
6731 (setq data (cdr data)))
6733 (goto-char (gnus-data-pos (car data)))
6734 (gnus-data-number (car data))))))
6735 (gnus-summary-position-point)))
6737 (defun gnus-summary-next-subject (n &optional unread dont-display)
6738 "Go to next N'th summary line.
6739 If N is negative, go to the previous N'th subject line.
6740 If UNREAD is non-nil, only unread articles are selected.
6741 The difference between N and the actual number of steps taken is
6744 (let ((backward (< n 0))
6748 (gnus-summary-find-prev unread)
6749 (gnus-summary-find-next unread)))
6750 (unless (zerop (setq n (1- n)))
6751 (gnus-summary-show-thread)))
6753 (gnus-message 7 "No more%s articles"
6754 (if unread " unread" "")))
6755 (unless dont-display
6756 (gnus-summary-recenter)
6757 (gnus-summary-position-point))
6760 (defun gnus-summary-next-unread-subject (n)
6761 "Go to next N'th unread summary line."
6763 (gnus-summary-next-subject n t))
6765 (defun gnus-summary-prev-subject (n &optional unread)
6766 "Go to previous N'th summary line.
6767 If optional argument UNREAD is non-nil, only unread article is selected."
6769 (gnus-summary-next-subject (- n) unread))
6771 (defun gnus-summary-prev-unread-subject (n)
6772 "Go to previous N'th unread summary line."
6774 (gnus-summary-next-subject (- n) t))
6776 (defun gnus-summary-goto-subjects (articles)
6777 "Insert the subject header for ARTICLES in the current buffer."
6779 (dolist (article articles)
6780 (gnus-summary-goto-subject article t)))
6781 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6782 (gnus-summary-position-point))
6784 (defun gnus-summary-goto-subject (article &optional force silent)
6785 "Go the subject line of ARTICLE.
6786 If FORCE, also allow jumping to articles not currently shown."
6787 (interactive "nArticle number: ")
6788 (unless (numberp article)
6789 (error "Article %s is not a number" article))
6791 (data (gnus-data-find article)))
6792 ;; We read in the article if we have to.
6795 (gnus-summary-insert-subject
6797 (if (or (numberp force) (vectorp force)) force)
6799 (setq data (gnus-data-find article)))
6804 (gnus-message 3 "Can't find article %d" article))
6806 (let ((pt (gnus-data-pos data)))
6808 (gnus-summary-set-article-display-arrow pt))
6809 (gnus-summary-position-point)
6812 ;; Walking around summary lines with displaying articles.
6814 (defun gnus-summary-expand-window (&optional arg)
6815 "Make the summary buffer take up the entire Emacs frame.
6816 Given a prefix, will force an `article' buffer configuration."
6819 (gnus-configure-windows 'article 'force)
6820 (gnus-configure-windows 'summary 'force)))
6822 (defun gnus-summary-display-article (article &optional all-header)
6823 "Display ARTICLE in article buffer."
6824 (when (gnus-buffer-live-p gnus-article-buffer)
6825 (with-current-buffer gnus-article-buffer
6826 (mm-enable-multibyte)))
6827 (gnus-set-global-variables)
6828 (when (gnus-buffer-live-p gnus-article-buffer)
6829 (with-current-buffer gnus-article-buffer
6830 (setq gnus-article-charset gnus-newsgroup-charset)
6831 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6832 (mm-enable-multibyte)))
6836 (if gnus-summary-display-article-function
6837 (funcall gnus-summary-display-article-function article all-header)
6838 (gnus-article-prepare article all-header))
6839 (gnus-run-hooks 'gnus-select-article-hook)
6840 (when (and gnus-current-article
6841 (not (zerop gnus-current-article)))
6842 (gnus-summary-goto-subject gnus-current-article))
6843 (gnus-summary-recenter)
6844 (when (and gnus-use-trees gnus-show-threads)
6845 (gnus-possibly-generate-tree article)
6846 (gnus-highlight-selected-tree article))
6847 ;; Successfully display article.
6848 (gnus-article-set-window-start
6849 (cdr (assq article gnus-newsgroup-bookmarks))))))
6851 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6852 "Select the current article.
6853 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6854 non-nil, the article will be re-fetched even if it already present in
6855 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6857 ;; Make sure we are in the summary buffer to work around bbdb bug.
6858 (unless (eq major-mode 'gnus-summary-mode)
6859 (set-buffer gnus-summary-buffer))
6860 (let ((article (or article (gnus-summary-article-number)))
6861 (all-headers (not (not all-headers))) ;Must be t or nil.
6862 gnus-summary-display-article-function)
6864 (gnus-summary-article-pseudo-p article)
6865 (error "This is a pseudo-article"))
6867 (set-buffer gnus-summary-buffer)
6868 (if (or (and gnus-single-article-buffer
6869 (or (null gnus-current-article)
6870 (null gnus-article-current)
6871 (null (get-buffer gnus-article-buffer))
6872 (not (eq article (cdr gnus-article-current)))
6873 (not (equal (car gnus-article-current)
6874 gnus-newsgroup-name))))
6875 (and (not gnus-single-article-buffer)
6876 (or (null gnus-current-article)
6877 (not (eq gnus-current-article article))))
6879 ;; The requested article is different from the current article.
6881 (gnus-summary-display-article article all-headers)
6882 (when (gnus-buffer-live-p gnus-article-buffer)
6883 (with-current-buffer gnus-article-buffer
6884 (if (not gnus-article-decoded-p) ;; a local variable
6885 (mm-disable-multibyte))))
6886 (gnus-article-set-window-start
6887 (cdr (assq article gnus-newsgroup-bookmarks)))
6891 (defun gnus-summary-force-verify-and-decrypt ()
6893 (let ((mm-verify-option 'known)
6894 (mm-decrypt-option 'known)
6895 (gnus-buttonized-mime-types (append (list "multipart/signed"
6896 "multipart/encrypted")
6897 gnus-buttonized-mime-types)))
6898 (gnus-summary-select-article nil 'force)))
6900 (defun gnus-summary-set-current-mark (&optional current-mark)
6901 "Obsolete function."
6904 (defun gnus-summary-next-article (&optional unread subject backward push)
6905 "Select the next article.
6906 If UNREAD, only unread articles are selected.
6907 If SUBJECT, only articles with SUBJECT are selected.
6908 If BACKWARD, the previous article is selected instead of the next."
6911 ;; Is there such an article?
6912 ((and (gnus-summary-search-forward unread subject backward)
6913 (or (gnus-summary-display-article (gnus-summary-article-number))
6914 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6915 (gnus-summary-position-point))
6916 ;; If not, we try the first unread, if that is wanted.
6918 gnus-auto-select-same
6919 (gnus-summary-first-unread-article))
6920 (gnus-summary-position-point)
6921 (gnus-message 6 "Wrapped"))
6922 ;; Try to get next/previous article not displayed in this group.
6923 ((and gnus-auto-extend-newsgroup
6924 (not unread) (not subject))
6925 (gnus-summary-goto-article
6926 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6927 nil (count-lines (point-min) (point))))
6928 ;; Go to next/previous group.
6930 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6931 (gnus-summary-jump-to-group gnus-newsgroup-name))
6932 (let ((cmd last-command-char)
6935 (set-buffer gnus-group-buffer)
6938 (if (eq gnus-keep-same-level 'best)
6939 (gnus-summary-best-group gnus-newsgroup-name)
6940 (gnus-summary-search-group backward gnus-keep-same-level))))
6941 ;; For some reason, the group window gets selected. We change
6943 (select-window (get-buffer-window (current-buffer)))
6944 ;; Select next unread newsgroup automagically.
6946 ((or (not gnus-auto-select-next)
6948 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6949 ((or (eq gnus-auto-select-next 'quietly)
6950 (and (eq gnus-auto-select-next 'slightly-quietly)
6952 (and (eq gnus-auto-select-next 'almost-quietly)
6953 (gnus-summary-last-article-p)))
6955 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6957 (gnus-message 7 "No more%s articles (%s)..."
6958 (if unread " unread" "")
6959 (if group (concat "selecting " group)
6961 (gnus-summary-next-group nil group backward)))
6963 (when (gnus-key-press-event-p last-input-event)
6964 (gnus-summary-walk-group-buffer
6965 gnus-newsgroup-name cmd unread backward point))))))))
6967 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6968 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6969 (?\C-p (gnus-group-prev-unread-group 1))))
6970 (cursor-in-echo-area t)
6971 keve key group ended prompt)
6973 (set-buffer gnus-group-buffer)
6976 (if (eq gnus-keep-same-level 'best)
6977 (gnus-summary-best-group gnus-newsgroup-name)
6978 (gnus-summary-search-group backward gnus-keep-same-level))))
6982 "No more%s articles%s " (if unread " unread" "")
6984 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6985 (format " (Type %s for %s [%s])"
6986 (single-key-description cmd) group
6987 (car (gnus-gethash group gnus-newsrc-hashtb)))
6988 (format " (Type %s to exit %s)"
6989 (single-key-description cmd)
6990 gnus-newsgroup-name))))
6991 ;; Confirm auto selection.
6992 (setq key (car (setq keve (gnus-read-event-char prompt)))
6995 ((assq key keystrokes)
6996 (let ((obuf (current-buffer)))
6997 (switch-to-buffer gnus-group-buffer)
6999 (gnus-group-jump-to-group group))
7000 (eval (cadr (assq key keystrokes)))
7001 (setq group (gnus-group-group-name))
7002 (switch-to-buffer obuf))
7006 (gnus-ephemeral-group-p gnus-newsgroup-name))
7008 (gnus-summary-next-group nil group backward)))
7010 (push (cdr keve) unread-command-events))))))
7012 (defun gnus-summary-next-unread-article ()
7013 "Select unread article after current one."
7015 (gnus-summary-next-article
7016 (or (not (eq gnus-summary-goto-unread 'never))
7017 (gnus-summary-last-article-p (gnus-summary-article-number)))
7018 (and gnus-auto-select-same
7019 (gnus-summary-article-subject))))
7021 (defun gnus-summary-prev-article (&optional unread subject)
7022 "Select the article after the current one.
7023 If UNREAD is non-nil, only unread articles are selected."
7025 (gnus-summary-next-article unread subject t))
7027 (defun gnus-summary-prev-unread-article ()
7028 "Select unread article before current one."
7030 (gnus-summary-prev-article
7031 (or (not (eq gnus-summary-goto-unread 'never))
7032 (gnus-summary-first-article-p (gnus-summary-article-number)))
7033 (and gnus-auto-select-same
7034 (gnus-summary-article-subject))))
7036 (defun gnus-summary-next-page (&optional lines circular stop)
7037 "Show next page of the selected article.
7038 If at the end of the current article, select the next article.
7039 LINES says how many lines should be scrolled up.
7041 If CIRCULAR is non-nil, go to the start of the article instead of
7042 selecting the next article when reaching the end of the current
7045 If STOP is non-nil, just stop when reaching the end of the message."
7047 (setq gnus-summary-buffer (current-buffer))
7048 (gnus-set-global-variables)
7049 (let ((article (gnus-summary-article-number))
7050 (article-window (get-buffer-window gnus-article-buffer t))
7052 ;; If the buffer is empty, we have no article.
7054 (error "No article to select"))
7055 (gnus-configure-windows 'article)
7056 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7057 (if (and (eq gnus-summary-goto-unread 'never)
7058 (not (gnus-summary-last-article-p article)))
7059 (gnus-summary-next-article)
7060 (gnus-summary-next-unread-article))
7061 (if (or (null gnus-current-article)
7062 (null gnus-article-current)
7063 (/= article (cdr gnus-article-current))
7064 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7065 ;; Selected subject is different from current article's.
7066 (gnus-summary-display-article article)
7067 (when article-window
7068 (gnus-eval-in-buffer-window gnus-article-buffer
7069 (setq endp (gnus-article-next-page lines)))
7072 (gnus-message 3 "End of message"))
7074 (gnus-summary-beginning-of-article))
7076 (gnus-message 3 "End of message"))
7078 (if (and (eq gnus-summary-goto-unread 'never)
7079 (not (gnus-summary-last-article-p article)))
7080 (gnus-summary-next-article)
7081 (gnus-summary-next-unread-article))))))))
7082 (gnus-summary-recenter)
7083 (gnus-summary-position-point)))
7085 (defun gnus-summary-prev-page (&optional lines move)
7086 "Show previous page of selected article.
7087 Argument LINES specifies lines to be scrolled down.
7088 If MOVE, move to the previous unread article if point is at
7089 the beginning of the buffer."
7091 (let ((article (gnus-summary-article-number))
7092 (article-window (get-buffer-window gnus-article-buffer t))
7094 (gnus-configure-windows 'article)
7095 (if (or (null gnus-current-article)
7096 (null gnus-article-current)
7097 (/= article (cdr gnus-article-current))
7098 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7099 ;; Selected subject is different from current article's.
7100 (gnus-summary-display-article article)
7101 (gnus-summary-recenter)
7102 (when article-window
7103 (gnus-eval-in-buffer-window gnus-article-buffer
7104 (setq endp (gnus-article-prev-page lines)))
7105 (when (and move endp)
7107 (gnus-message 3 "Beginning of message"))
7109 (if (and (eq gnus-summary-goto-unread 'never)
7110 (not (gnus-summary-first-article-p article)))
7111 (gnus-summary-prev-article)
7112 (gnus-summary-prev-unread-article))))))))
7113 (gnus-summary-position-point))
7115 (defun gnus-summary-prev-page-or-article (&optional lines)
7116 "Show previous page of selected article.
7117 Argument LINES specifies lines to be scrolled down.
7118 If at the beginning of the article, go to the next article."
7120 (gnus-summary-prev-page lines t))
7122 (defun gnus-summary-scroll-up (lines)
7123 "Scroll up (or down) one line current article.
7124 Argument LINES specifies lines to be scrolled up (or down if negative)."
7126 (gnus-configure-windows 'article)
7127 (gnus-summary-show-thread)
7128 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7129 (gnus-eval-in-buffer-window gnus-article-buffer
7131 (when (gnus-article-next-page lines)
7132 (gnus-message 3 "End of message")))
7134 (gnus-article-prev-page (- lines))))))
7135 (gnus-summary-recenter)
7136 (gnus-summary-position-point))
7138 (defun gnus-summary-scroll-down (lines)
7139 "Scroll down (or up) one line current article.
7140 Argument LINES specifies lines to be scrolled down (or up if negative)."
7142 (gnus-summary-scroll-up (- lines)))
7144 (defun gnus-summary-next-same-subject ()
7145 "Select next article which has the same subject as current one."
7147 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7149 (defun gnus-summary-prev-same-subject ()
7150 "Select previous article which has the same subject as current one."
7152 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7154 (defun gnus-summary-next-unread-same-subject ()
7155 "Select next unread article which has the same subject as current one."
7157 (gnus-summary-next-article t (gnus-summary-article-subject)))
7159 (defun gnus-summary-prev-unread-same-subject ()
7160 "Select previous unread article which has the same subject as current one."
7162 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7164 (defun gnus-summary-first-unread-article ()
7165 "Select the first unread article.
7166 Return nil if there are no unread articles."
7169 (when (gnus-summary-first-subject t)
7170 (gnus-summary-show-thread)
7171 (gnus-summary-first-subject t)
7172 (gnus-summary-display-article (gnus-summary-article-number)))
7173 (gnus-summary-position-point)))
7175 (defun gnus-summary-first-unread-subject ()
7176 "Place the point on the subject line of the first unread article.
7177 Return nil if there are no unread articles."
7180 (when (gnus-summary-first-subject t)
7181 (gnus-summary-show-thread)
7182 (gnus-summary-first-subject t))
7183 (gnus-summary-position-point)))
7185 (defun gnus-summary-first-unseen-subject ()
7186 "Place the point on the subject line of the first unseen article.
7187 Return nil if there are no unseen articles."
7190 (when (gnus-summary-first-subject t t t)
7191 (gnus-summary-show-thread)
7192 (gnus-summary-first-subject t t t))
7193 (gnus-summary-position-point)))
7195 (defun gnus-summary-first-unseen-or-unread-subject ()
7196 "Place the point on the subject line of the first unseen article.
7197 Return nil if there are no unseen articles."
7200 (unless (when (gnus-summary-first-subject t t t)
7201 (gnus-summary-show-thread)
7202 (gnus-summary-first-subject t t t))
7203 (when (gnus-summary-first-subject t)
7204 (gnus-summary-show-thread)
7205 (gnus-summary-first-subject t)))
7206 (gnus-summary-position-point)))
7208 (defun gnus-summary-first-article ()
7209 "Select the first article.
7210 Return nil if there are no articles."
7213 (when (gnus-summary-first-subject)
7214 (gnus-summary-show-thread)
7215 (gnus-summary-first-subject)
7216 (gnus-summary-display-article (gnus-summary-article-number)))
7217 (gnus-summary-position-point)))
7219 (defun gnus-summary-best-unread-article (&optional arg)
7220 "Select the unread article with the highest score.
7221 If given a prefix argument, select the next unread article that has a
7222 score higher than the default score."
7224 (let ((article (if arg
7225 (gnus-summary-better-unread-subject)
7226 (gnus-summary-best-unread-subject))))
7228 (gnus-summary-goto-article article)
7229 (error "No unread articles"))))
7231 (defun gnus-summary-best-unread-subject ()
7232 "Select the unread subject with the highest score."
7234 (let ((best -1000000)
7235 (data gnus-newsgroup-data)
7238 (and (gnus-data-unread-p (car data))
7240 (gnus-summary-article-score (gnus-data-number (car data))))
7243 article (gnus-data-number (car data))))
7244 (setq data (cdr data)))
7246 (gnus-summary-goto-subject article))
7247 (gnus-summary-position-point)
7250 (defun gnus-summary-better-unread-subject ()
7251 "Select the first unread subject that has a score over the default score."
7253 (let ((data gnus-newsgroup-data)
7255 (while (and (setq article (gnus-data-number (car data)))
7256 (or (gnus-data-read-p (car data))
7257 (not (> (gnus-summary-article-score article)
7258 gnus-summary-default-score))))
7259 (setq data (cdr data)))
7261 (gnus-summary-goto-subject article))
7262 (gnus-summary-position-point)
7265 (defun gnus-summary-last-subject ()
7266 "Go to the last displayed subject line in the group."
7267 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7269 (gnus-summary-goto-subject article))))
7271 (defun gnus-summary-goto-article (article &optional all-headers force)
7272 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7273 If ALL-HEADERS is non-nil, no header lines are hidden.
7274 If FORCE, go to the article even if it isn't displayed. If FORCE
7275 is a number, it is the line the article is to be displayed on."
7279 "Article number or Message-ID: "
7280 (mapcar (lambda (number) (list (int-to-string number)))
7281 gnus-newsgroup-limit))
7285 (if (and (stringp article)
7286 (string-match "@" article))
7287 (gnus-summary-refer-article article)
7288 (when (stringp article)
7289 (setq article (string-to-number article)))
7290 (if (gnus-summary-goto-subject article force)
7291 (gnus-summary-display-article article all-headers)
7292 (gnus-message 4 "Couldn't go to article %s" article) nil))
7293 (gnus-summary-position-point)))
7295 (defun gnus-summary-goto-last-article ()
7296 "Go to the previously read article."
7299 (when gnus-last-article
7300 (gnus-summary-goto-article gnus-last-article nil t))
7301 (gnus-summary-position-point)))
7303 (defun gnus-summary-pop-article (number)
7304 "Pop one article off the history and go to the previous.
7305 NUMBER articles will be popped off."
7308 (setq gnus-newsgroup-history
7309 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7311 (gnus-summary-goto-article (car to) nil t)
7312 (error "Article history empty")))
7313 (gnus-summary-position-point))
7315 ;; Summary commands and functions for limiting the summary buffer.
7317 (defun gnus-summary-limit-to-articles (n)
7318 "Limit the summary buffer to the next N articles.
7319 If not given a prefix, use the process marked articles instead."
7322 (let ((articles (gnus-summary-work-articles n)))
7323 (setq gnus-newsgroup-processable nil)
7324 (gnus-summary-limit articles))
7325 (gnus-summary-position-point)))
7327 (defun gnus-summary-pop-limit (&optional total)
7328 "Restore the previous limit.
7329 If given a prefix, remove all limits."
7332 (setq gnus-newsgroup-limits
7333 (list (mapcar (lambda (h) (mail-header-number h))
7334 gnus-newsgroup-headers))))
7335 (unless gnus-newsgroup-limits
7336 (error "No limit to pop"))
7338 (gnus-summary-limit nil 'pop)
7339 (gnus-summary-position-point)))
7341 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7342 "Limit the summary buffer to articles that have subjects that match a regexp.
7343 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7345 (list (read-string (if current-prefix-arg
7346 "Exclude subject (regexp): "
7347 "Limit to subject (regexp): "))
7348 nil current-prefix-arg))
7350 (setq header "subject"))
7351 (when (not (equal "" subject))
7353 (let ((articles (gnus-summary-find-matching
7354 (or header "subject") subject 'all nil nil
7357 (error "Found no matches for \"%s\"" subject))
7358 (gnus-summary-limit articles))
7359 (gnus-summary-position-point))))
7361 (defun gnus-summary-limit-to-author (from &optional not-matching)
7362 "Limit the summary buffer to articles that have authors that match a regexp.
7363 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7365 (list (read-string (if current-prefix-arg
7366 "Exclude author (regexp): "
7367 "Limit to author (regexp): "))
7368 current-prefix-arg))
7369 (gnus-summary-limit-to-subject from "from" not-matching))
7371 (defun gnus-summary-limit-to-age (age &optional younger-p)
7372 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7373 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7374 articles that are younger than AGE days."
7376 (let ((younger current-prefix-arg)
7379 (while (not days-got)
7380 (setq days (if younger
7381 (read-string "Limit to articles younger than (in days, older when negative): ")
7383 "Limit to articles older than (in days, younger when negative): ")))
7384 (when (> (length days) 0)
7385 (setq days (read days)))
7391 (setq younger (not younger))
7392 (setq days (* days -1)))))
7393 (message "Please enter a number.")
7395 (list days younger)))
7397 (let ((data gnus-newsgroup-data)
7398 (cutoff (days-to-time age))
7399 articles d date is-younger)
7400 (while (setq d (pop data))
7401 (when (and (vectorp (gnus-data-header d))
7402 (setq date (mail-header-date (gnus-data-header d))))
7403 (setq is-younger (time-less-p
7404 (time-since (condition-case ()
7411 (push (gnus-data-number d) articles))))
7412 (gnus-summary-limit (nreverse articles)))
7413 (gnus-summary-position-point)))
7415 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7416 "Limit the summary buffer to articles that match an 'extra' header."
7420 (gnus-completing-read-with-default
7421 (symbol-name (car gnus-extra-headers))
7422 (if current-prefix-arg
7423 "Exclude extra header:"
7424 "Limit extra header:")
7426 (cons (symbol-name x) x))
7431 (read-string (format "%s header %s (regexp): "
7432 (if current-prefix-arg "Exclude" "Limit to")
7434 current-prefix-arg)))
7435 (when (not (equal "" regexp))
7437 (let ((articles (gnus-summary-find-matching
7438 (cons 'extra header) regexp 'all nil nil
7441 (error "Found no matches for \"%s\"" regexp))
7442 (gnus-summary-limit articles))
7443 (gnus-summary-position-point))))
7445 (defun gnus-summary-limit-to-display-predicate ()
7446 "Limit the summary buffer to the predicated in the `display' group parameter."
7448 (unless gnus-newsgroup-display
7449 (error "There is no `display' group parameter"))
7451 (dolist (number gnus-newsgroup-articles)
7452 (when (funcall gnus-newsgroup-display)
7453 (push number articles)))
7454 (gnus-summary-limit articles))
7455 (gnus-summary-position-point))
7457 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7459 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7461 (defun gnus-summary-limit-to-unread (&optional all)
7462 "Limit the summary buffer to articles that are not marked as read.
7463 If ALL is non-nil, limit strictly to unread articles."
7466 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7467 (gnus-summary-limit-to-marks
7468 ;; Concat all the marks that say that an article is read and have
7470 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7471 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7472 gnus-low-score-mark gnus-expirable-mark
7473 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7474 gnus-duplicate-mark gnus-souped-mark)
7477 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7478 (make-obsolete 'gnus-summary-delete-marked-with
7479 'gnus-summary-limit-exclude-marks)
7481 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7482 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7483 If REVERSE, limit the summary buffer to articles that are marked
7484 with MARKS. MARKS can either be a string of marks or a list of marks.
7485 Returns how many articles were removed."
7486 (interactive "sMarks: ")
7487 (gnus-summary-limit-to-marks marks t))
7489 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7490 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7491 If REVERSE (the prefix), limit the summary buffer to articles that are
7492 not marked with MARKS. MARKS can either be a string of marks or a
7494 Returns how many articles were removed."
7495 (interactive "sMarks: \nP")
7497 (let ((data gnus-newsgroup-data)
7498 (marks (if (listp marks) marks
7499 (append marks nil))) ; Transform to list.
7502 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7503 (memq (gnus-data-mark (car data)) marks))
7504 (push (gnus-data-number (car data)) articles))
7505 (setq data (cdr data)))
7506 (gnus-summary-limit articles))
7507 (gnus-summary-position-point)))
7509 (defun gnus-summary-limit-to-score (score)
7510 "Limit to articles with score at or above SCORE."
7511 (interactive "NLimit to articles with score of at least: ")
7512 (let ((data gnus-newsgroup-data)
7515 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7517 (push (gnus-data-number (car data)) articles))
7518 (setq data (cdr data)))
7520 (gnus-summary-limit articles)
7521 (gnus-summary-position-point))))
7523 (defun gnus-summary-limit-to-unseen ()
7524 "Limit to unseen articles."
7527 (gnus-summary-limit gnus-newsgroup-unseen)
7528 (gnus-summary-position-point)))
7530 (defun gnus-summary-limit-include-thread (id)
7531 "Display all the hidden articles that is in the thread with ID in it.
7532 When called interactively, ID is the Message-ID of the current
7534 (interactive (list (mail-header-id (gnus-summary-article-header))))
7535 (let ((articles (gnus-articles-in-thread
7536 (gnus-id-to-thread (gnus-root-id id)))))
7538 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7539 (gnus-summary-limit-include-matching-articles
7541 (regexp-quote (gnus-simplify-subject-re
7542 (mail-header-subject (gnus-id-to-header id)))))
7543 (gnus-summary-position-point))))
7545 (defun gnus-summary-limit-include-matching-articles (header regexp)
7546 "Display all the hidden articles that have HEADERs that match REGEXP."
7547 (interactive (list (read-string "Match on header: ")
7548 (read-string "Regexp: ")))
7549 (let ((articles (gnus-find-matching-articles header regexp)))
7551 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7552 (gnus-summary-position-point))))
7554 (defun gnus-summary-insert-dormant-articles ()
7555 "Insert all the dormat articles for this group into the current buffer."
7557 (let ((gnus-verbose (max 6 gnus-verbose)))
7558 (if (not gnus-newsgroup-dormant)
7559 (gnus-message 3 "No cached articles for this group")
7560 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7562 (defun gnus-summary-limit-include-dormant ()
7563 "Display all the hidden articles that are marked as dormant.
7564 Note that this command only works on a subset of the articles currently
7565 fetched for this group."
7567 (unless gnus-newsgroup-dormant
7568 (error "There are no dormant articles in this group"))
7570 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7571 (gnus-summary-position-point)))
7573 (defun gnus-summary-limit-exclude-dormant ()
7574 "Hide all dormant articles."
7577 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7578 (gnus-summary-position-point)))
7580 (defun gnus-summary-limit-exclude-childless-dormant ()
7581 "Hide all dormant articles that have no children."
7583 (let ((data (gnus-data-list t))
7584 articles d children)
7585 ;; Find all articles that are either not dormant or have
7587 (while (setq d (pop data))
7588 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7590 (gnus-article-children (gnus-data-number d)))
7593 (when (memq (car children) articles)
7598 (push (gnus-data-number d) articles)))
7601 (gnus-summary-limit articles)
7602 (gnus-summary-position-point))))
7604 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7605 "Mark all unread excluded articles as read.
7606 If ALL, mark even excluded ticked and dormants as read."
7608 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7609 (let ((articles (gnus-sorted-ndifference
7611 (mapcar (lambda (h) (mail-header-number h))
7612 gnus-newsgroup-headers)
7614 gnus-newsgroup-limit))
7616 (setq gnus-newsgroup-unreads
7617 (gnus-sorted-intersection gnus-newsgroup-unreads
7618 gnus-newsgroup-limit))
7620 (setq gnus-newsgroup-dormant nil
7621 gnus-newsgroup-marked nil
7622 gnus-newsgroup-reads
7624 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7625 gnus-newsgroup-reads))
7626 (while (setq article (pop articles))
7627 (unless (or (memq article gnus-newsgroup-dormant)
7628 (memq article gnus-newsgroup-marked))
7629 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7631 (defun gnus-summary-limit (articles &optional pop)
7633 ;; We pop the previous limit off the stack and use that.
7634 (setq articles (car gnus-newsgroup-limits)
7635 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7636 ;; We use the new limit, so we push the old limit on the stack.
7637 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7639 (setq gnus-newsgroup-limit articles)
7640 (let ((total (length gnus-newsgroup-data))
7641 (data (gnus-data-find-list (gnus-summary-article-number)))
7642 (gnus-summary-mark-below nil) ; Inhibit this.
7644 ;; This will do all the work of generating the new summary buffer
7645 ;; according to the new limit.
7646 (gnus-summary-prepare)
7647 ;; Hide any threads, possibly.
7648 (gnus-summary-maybe-hide-threads)
7649 ;; Try to return to the article you were at, or one in the
7652 ;; We try to find some article after the current one.
7654 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7657 (setq data (cdr data))))
7659 ;; If there is no data, that means that we were after the last
7660 ;; article. The same goes when we can't find any articles
7661 ;; after the current one.
7662 (goto-char (point-max))
7663 (gnus-summary-find-prev))
7664 (gnus-set-mode-line 'summary)
7665 ;; We return how many articles were removed from the summary
7666 ;; buffer as a result of the new limit.
7667 (- total (length gnus-newsgroup-data))))
7669 (defsubst gnus-invisible-cut-children (threads)
7672 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7677 (defsubst gnus-cut-thread (thread)
7678 "Go forwards in the thread until we find an article that we want to display."
7679 (when (or (eq gnus-fetch-old-headers 'some)
7680 (eq gnus-fetch-old-headers 'invisible)
7681 (numberp gnus-fetch-old-headers)
7682 (eq gnus-build-sparse-threads 'some)
7683 (eq gnus-build-sparse-threads 'more))
7684 ;; Deal with old-fetched headers and sparse threads.
7688 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7689 (gnus-summary-article-ancient-p
7690 (mail-header-number (car thread))))
7691 (if (or (<= (length (cdr thread)) 1)
7692 (eq gnus-fetch-old-headers 'invisible))
7693 (setq gnus-newsgroup-limit
7694 (delq (mail-header-number (car thread))
7695 gnus-newsgroup-limit)
7696 thread (cadr thread))
7697 (when (gnus-invisible-cut-children (cdr thread))
7698 (let ((th (cdr thread)))
7700 (if (memq (mail-header-number (caar th))
7701 gnus-newsgroup-limit)
7702 (setq thread (car th)
7704 (setq th (cdr th))))))))))
7707 (defun gnus-cut-threads (threads)
7708 "Cut off all uninteresting articles from the beginning of threads."
7709 (when (or (eq gnus-fetch-old-headers 'some)
7710 (eq gnus-fetch-old-headers 'invisible)
7711 (numberp gnus-fetch-old-headers)
7712 (eq gnus-build-sparse-threads 'some)
7713 (eq gnus-build-sparse-threads 'more))
7716 (setcar th (gnus-cut-thread (car th)))
7717 (setq th (cdr th)))))
7718 ;; Remove nixed out threads.
7721 (defun gnus-summary-initial-limit (&optional show-if-empty)
7722 "Figure out what the initial limit is supposed to be on group entry.
7723 This entails weeding out unwanted dormants, low-scored articles,
7724 fetch-old-headers verbiage, and so on."
7725 ;; Most groups have nothing to remove.
7726 (if (or gnus-inhibit-limiting
7727 (and (null gnus-newsgroup-dormant)
7728 (eq gnus-newsgroup-display 'gnus-not-ignore)
7729 (not (eq gnus-fetch-old-headers 'some))
7730 (not (numberp gnus-fetch-old-headers))
7731 (not (eq gnus-fetch-old-headers 'invisible))
7732 (null gnus-summary-expunge-below)
7733 (not (eq gnus-build-sparse-threads 'some))
7734 (not (eq gnus-build-sparse-threads 'more))
7735 (null gnus-thread-expunge-below)
7736 (not gnus-use-nocem)))
7738 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7739 (setq gnus-newsgroup-limit nil)
7742 (unless (car (symbol-value node))
7743 ;; These threads have no parents -- they are roots.
7744 (let ((nodes (cdr (symbol-value node)))
7747 (if (and gnus-thread-expunge-below
7748 (< (gnus-thread-total-score (car nodes))
7749 gnus-thread-expunge-below))
7750 (gnus-expunge-thread (pop nodes))
7751 (setq thread (pop nodes))
7752 (gnus-summary-limit-children thread))))))
7753 gnus-newsgroup-dependencies)
7754 ;; If this limitation resulted in an empty group, we might
7755 ;; pop the previous limit and use it instead.
7756 (when (and (not gnus-newsgroup-limit)
7758 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7759 gnus-newsgroup-limit))
7761 (defun gnus-summary-limit-children (thread)
7762 "Return 1 if this subthread is visible and 0 if it is not."
7763 ;; First we get the number of visible children to this thread. This
7764 ;; is done by recursing down the thread using this function, so this
7765 ;; will really go down to a leaf article first, before slowly
7766 ;; working its way up towards the root.
7768 (let* ((max-lisp-eval-depth 5000)
7771 (apply '+ (mapcar 'gnus-summary-limit-children
7774 (number (mail-header-number (car thread)))
7777 (not (memq number gnus-newsgroup-marked))
7779 ;; If this article is dormant and has absolutely no visible
7780 ;; children, then this article isn't visible.
7781 (and (memq number gnus-newsgroup-dormant)
7783 ;; If this is "fetch-old-headered" and there is no
7784 ;; visible children, then we don't want this article.
7785 (and (or (eq gnus-fetch-old-headers 'some)
7786 (numberp gnus-fetch-old-headers))
7787 (gnus-summary-article-ancient-p number)
7789 ;; If this is "fetch-old-headered" and `invisible', then
7790 ;; we don't want this article.
7791 (and (eq gnus-fetch-old-headers 'invisible)
7792 (gnus-summary-article-ancient-p number))
7793 ;; If this is a sparsely inserted article with no children,
7794 ;; we don't want it.
7795 (and (eq gnus-build-sparse-threads 'some)
7796 (gnus-summary-article-sparse-p number)
7798 ;; If we use expunging, and this article is really
7799 ;; low-scored, then we don't want this article.
7800 (when (and gnus-summary-expunge-below
7802 (or (cdr (assq number gnus-newsgroup-scored))
7803 gnus-summary-default-score))
7804 gnus-summary-expunge-below))
7805 ;; We increase the expunge-tally here, but that has
7806 ;; nothing to do with the limits, really.
7807 (incf gnus-newsgroup-expunged-tally)
7808 ;; We also mark as read here, if that's wanted.
7809 (when (and gnus-summary-mark-below
7810 (< score gnus-summary-mark-below))
7811 (setq gnus-newsgroup-unreads
7812 (delq number gnus-newsgroup-unreads))
7813 (if gnus-newsgroup-auto-expire
7814 (push number gnus-newsgroup-expirable)
7815 (push (cons number gnus-low-score-mark)
7816 gnus-newsgroup-reads)))
7818 ;; Do the `display' group parameter.
7819 (and gnus-newsgroup-display
7820 (not (funcall gnus-newsgroup-display)))
7821 ;; Check NoCeM things.
7822 (if (and gnus-use-nocem
7823 (gnus-nocem-unwanted-article-p
7824 (mail-header-id (car thread))))
7826 (setq gnus-newsgroup-unreads
7827 (delq number gnus-newsgroup-unreads))
7829 ;; Nope, invisible article.
7831 ;; Ok, this article is to be visible, so we add it to the limit
7833 (push number gnus-newsgroup-limit)
7836 (defun gnus-expunge-thread (thread)
7837 "Mark all articles in THREAD as read."
7838 (let* ((number (mail-header-number (car thread))))
7839 (incf gnus-newsgroup-expunged-tally)
7840 ;; We also mark as read here, if that's wanted.
7841 (setq gnus-newsgroup-unreads
7842 (delq number gnus-newsgroup-unreads))
7843 (if gnus-newsgroup-auto-expire
7844 (push number gnus-newsgroup-expirable)
7845 (push (cons number gnus-low-score-mark)
7846 gnus-newsgroup-reads)))
7847 ;; Go recursively through all subthreads.
7848 (mapcar 'gnus-expunge-thread (cdr thread)))
7850 ;; Summary article oriented commands
7852 (defun gnus-summary-refer-parent-article (n)
7853 "Refer parent article N times.
7854 If N is negative, go to ancestor -N instead.
7855 The difference between N and the number of articles fetched is returned."
7859 (when (not (natnump n))
7864 (setq header (gnus-summary-article-header))
7865 (if (and (eq (mail-header-number header)
7866 (cdr gnus-article-current))
7867 (equal gnus-newsgroup-name
7868 (car gnus-article-current)))
7869 ;; If we try to find the parent of the currently
7870 ;; displayed article, then we take a look at the actual
7871 ;; References header, since this is slightly more
7872 ;; reliable than the References field we got from the
7875 (set-buffer gnus-original-article-buffer)
7876 (nnheader-narrow-to-headers)
7877 (unless (setq ref (message-fetch-field "references"))
7878 (setq ref (message-fetch-field "in-reply-to")))
7881 ;; It's not the current article, so we take a bet on
7882 ;; the value we got from the server.
7883 (mail-header-references header)))
7885 (not (equal ref "")))
7886 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7887 (gnus-message 1 "Couldn't find parent"))
7888 (gnus-message 1 "No references in article %d"
7889 (gnus-summary-article-number))
7892 (gnus-summary-position-point)
7895 (defun gnus-summary-refer-references ()
7896 "Fetch all articles mentioned in the References header.
7897 Return the number of articles fetched."
7899 (let ((ref (mail-header-references (gnus-summary-article-header)))
7900 (current (gnus-summary-article-number))
7904 (error "No References in the current article")
7905 ;; For each Message-ID in the References header...
7906 (while (string-match "<[^>]*>" ref)
7908 ;; ... fetch that article.
7909 (gnus-summary-refer-article
7910 (prog1 (match-string 0 ref)
7911 (setq ref (substring ref (match-end 0))))))
7912 (gnus-summary-goto-subject current)
7913 (gnus-summary-position-point)
7916 (defun gnus-summary-refer-thread (&optional limit)
7917 "Fetch all articles in the current thread.
7918 If LIMIT (the numerical prefix), fetch that many old headers instead
7919 of what's specified by the `gnus-refer-thread-limit' variable."
7921 (let ((id (mail-header-id (gnus-summary-article-header)))
7922 (limit (if limit (prefix-numeric-value limit)
7923 gnus-refer-thread-limit)))
7924 ;; We want to fetch LIMIT *old* headers, but we also have to
7925 ;; re-fetch all the headers in the current buffer, because many of
7926 ;; them may be undisplayed. So we adjust LIMIT.
7927 (when (numberp limit)
7928 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7929 (unless (eq gnus-fetch-old-headers 'invisible)
7930 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7931 ;; Retrieve the headers and read them in.
7932 (if (eq (gnus-retrieve-headers
7933 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7935 (gnus-build-all-threads)
7936 (error "Can't fetch thread from backends that don't support NOV"))
7937 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7938 (gnus-summary-limit-include-thread id)))
7940 (defun gnus-summary-refer-article (message-id)
7941 "Fetch an article specified by MESSAGE-ID."
7942 (interactive "sMessage-ID: ")
7943 (when (and (stringp message-id)
7944 (not (zerop (length message-id))))
7945 ;; Construct the correct Message-ID if necessary.
7946 ;; Suggested by tale@pawl.rpi.edu.
7947 (unless (string-match "^<" message-id)
7948 (setq message-id (concat "<" message-id)))
7949 (unless (string-match ">$" message-id)
7950 (setq message-id (concat message-id ">")))
7951 (let* ((header (gnus-id-to-header message-id))
7953 (gnus-summary-article-sparse-p
7954 (mail-header-number header))
7955 (memq (mail-header-number header)
7956 gnus-newsgroup-limit)))
7959 ;; If the article is present in the buffer we just go to it.
7961 (or (not (gnus-summary-article-sparse-p
7962 (mail-header-number header)))
7965 (gnus-summary-goto-article
7966 (mail-header-number header) nil t)
7968 (gnus-summary-update-article (mail-header-number header)))))
7970 ;; We fetch the article.
7972 (dolist (gnus-override-method (gnus-refer-article-methods))
7973 (gnus-check-server gnus-override-method)
7974 ;; Fetch the header, and display the article.
7975 (when (setq number (gnus-summary-insert-subject message-id))
7976 (gnus-summary-select-article nil nil nil number)
7978 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7980 (defun gnus-refer-article-methods ()
7981 "Return a list of referable methods."
7983 ;; No method, so we default to current and native.
7984 ((null gnus-refer-article-method)
7985 (list gnus-current-select-method gnus-select-method))
7987 ((eq 'current gnus-refer-article-method)
7988 (list gnus-current-select-method))
7989 ;; List of select methods.
7990 ((not (and (symbolp (car gnus-refer-article-method))
7991 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7993 (dolist (method gnus-refer-article-method)
7994 (push (if (eq 'current method)
7995 gnus-current-select-method
7999 ;; One single select method.
8001 (list gnus-refer-article-method))))
8003 (defun gnus-summary-edit-parameters ()
8004 "Edit the group parameters of the current group."
8006 (gnus-group-edit-group gnus-newsgroup-name 'params))
8008 (defun gnus-summary-customize-parameters ()
8009 "Customize the group parameters of the current group."
8011 (gnus-group-customize gnus-newsgroup-name))
8013 (defun gnus-summary-enter-digest-group (&optional force)
8014 "Enter an nndoc group based on the current article.
8015 If FORCE, force a digest interpretation. If not, try
8016 to guess what the document format is."
8018 (let ((conf gnus-current-window-configuration))
8020 (gnus-summary-select-article))
8021 (setq gnus-current-window-configuration conf)
8022 (let* ((name (format "%s-%d"
8023 (gnus-group-prefixed-name
8024 gnus-newsgroup-name (list 'nndoc ""))
8026 (set-buffer gnus-summary-buffer)
8027 gnus-current-article)))
8028 (ogroup gnus-newsgroup-name)
8029 (params (append (gnus-info-params (gnus-get-info ogroup))
8030 (list (cons 'to-group ogroup))
8031 (list (cons 'save-article-group ogroup))))
8032 (case-fold-search t)
8033 (buf (current-buffer))
8036 (set-buffer gnus-original-article-buffer)
8037 ;; Have the digest group inherit the main mail address of
8038 ;; the parent article.
8039 (when (setq to-address (or (gnus-fetch-field "reply-to")
8040 (gnus-fetch-field "from")))
8041 (setq params (append
8042 (list (cons 'to-address
8043 (funcall gnus-decode-encoded-word-function
8045 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8046 (insert-buffer-substring gnus-original-article-buffer)
8047 ;; Remove lines that may lead nndoc to misinterpret the
8050 (goto-char (point-min))
8051 (or (search-forward "\n\n" nil t) (point)))
8052 (goto-char (point-min))
8053 (delete-matching-lines "^Path:\\|^From ")
8056 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8057 (gnus-newsgroup-ephemeral-ignored-charsets
8058 gnus-newsgroup-ignored-charsets))
8059 (gnus-group-read-ephemeral-group
8060 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8062 ,(if force 'mbox 'guess)))
8064 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8066 ;; Make all postings to this group go to the parent group.
8067 (nconc (gnus-info-params (gnus-get-info name))
8069 ;; Couldn't select this doc group.
8070 (switch-to-buffer buf)
8071 (gnus-set-global-variables)
8072 (gnus-configure-windows 'summary)
8073 (gnus-message 3 "Article couldn't be entered?"))
8074 (kill-buffer dig)))))
8076 (defun gnus-summary-read-document (n)
8077 "Open a new group based on the current article(s).
8078 This will allow you to read digests and other similar
8079 documents as newsgroups.
8080 Obeys the standard process/prefix convention."
8082 (let* ((articles (gnus-summary-work-articles n))
8083 (ogroup gnus-newsgroup-name)
8084 (params (append (gnus-info-params (gnus-get-info ogroup))
8085 (list (cons 'to-group ogroup))))
8086 article group egroup groups vgroup)
8087 (while (setq article (pop articles))
8088 (setq group (format "%s-%d" gnus-newsgroup-name article))
8089 (gnus-summary-remove-process-mark article)
8090 (when (gnus-summary-display-article article)
8093 (insert-buffer-substring gnus-original-article-buffer)
8094 ;; Remove some headers that may lead nndoc to make
8096 (message-narrow-to-head)
8097 (goto-char (point-min))
8098 (delete-matching-lines "^\\(Path\\):\\|^From ")
8101 (gnus-group-read-ephemeral-group
8102 group `(nndoc ,group (nndoc-address ,(current-buffer))
8103 (nndoc-article-type guess))
8106 ;; Make all postings to this group go to the parent group.
8107 (nconc (gnus-info-params (gnus-get-info egroup))
8109 (push egroup groups))
8110 ;; Couldn't select this doc group.
8111 (gnus-error 3 "Article couldn't be entered"))))))
8112 ;; Now we have selected all the documents.
8115 (error "None of the articles could be interpreted as documents"))
8116 ((gnus-group-read-ephemeral-group
8117 (setq vgroup (format
8118 "nnvirtual:%s-%s" gnus-newsgroup-name
8119 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8120 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8122 (cons (current-buffer) 'summary)))
8124 (error "Couldn't select virtual nndoc group")))))
8126 (defun gnus-summary-isearch-article (&optional regexp-p)
8127 "Do incremental search forward on the current article.
8128 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8130 (gnus-summary-select-article)
8131 (gnus-configure-windows 'article)
8132 (gnus-eval-in-buffer-window gnus-article-buffer
8135 (isearch-forward regexp-p))))
8137 (defun gnus-summary-search-article-forward (regexp &optional backward)
8138 "Search for an article containing REGEXP forward.
8139 If BACKWARD, search backward instead."
8142 (format "Search article %s (regexp%s): "
8143 (if current-prefix-arg "backward" "forward")
8144 (if gnus-last-search-regexp
8145 (concat ", default " gnus-last-search-regexp)
8147 current-prefix-arg))
8148 (if (string-equal regexp "")
8149 (setq regexp (or gnus-last-search-regexp ""))
8150 (setq gnus-last-search-regexp regexp)
8151 (setq gnus-article-before-search gnus-current-article))
8152 ;; Intentionally set gnus-last-article.
8153 (setq gnus-last-article gnus-article-before-search)
8154 (let ((gnus-last-article gnus-last-article))
8155 (if (gnus-summary-search-article regexp backward)
8156 (gnus-summary-show-thread)
8157 (error "Search failed: \"%s\"" regexp))))
8159 (defun gnus-summary-search-article-backward (regexp)
8160 "Search for an article containing REGEXP backward."
8163 (format "Search article backward (regexp%s): "
8164 (if gnus-last-search-regexp
8165 (concat ", default " gnus-last-search-regexp)
8167 (gnus-summary-search-article-forward regexp 'backward))
8169 (defun gnus-summary-search-article (regexp &optional backward)
8170 "Search for an article containing REGEXP.
8171 Optional argument BACKWARD means do search for backward.
8172 `gnus-select-article-hook' is not called during the search."
8173 ;; We have to require this here to make sure that the following
8174 ;; dynamic binding isn't shadowed by autoloading.
8175 (require 'gnus-async)
8177 (let ((gnus-select-article-hook nil) ;Disable hook.
8178 (gnus-article-prepare-hook nil)
8179 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8180 (gnus-use-article-prefetch nil)
8181 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8182 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8183 (sum (current-buffer))
8184 (gnus-display-mime-function nil)
8187 (gnus-save-hidden-threads
8188 (gnus-summary-select-article)
8189 (set-buffer gnus-article-buffer)
8190 (goto-char (window-point (get-buffer-window (current-buffer))))
8194 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8196 (re-search-backward regexp nil t)
8197 (re-search-forward regexp nil t))
8198 ;; We found the regexp.
8203 (get-buffer-window (current-buffer))
8207 (get-buffer-window (current-buffer))
8210 (setq point (point)))
8211 ;; We didn't find it, so we go to the next article.
8214 (while (eq found 'not)
8215 (if (not (if backward (gnus-summary-find-prev)
8216 (gnus-summary-find-next)))
8217 ;; No more articles.
8219 ;; Select the next article and adjust point.
8220 (unless (gnus-summary-article-sparse-p
8221 (gnus-summary-article-number))
8223 (gnus-summary-select-article)
8224 (set-buffer gnus-article-buffer)
8226 (goto-char (if backward (point-max) (point-min))))))))
8227 (gnus-message 7 ""))
8228 ;; Return whether we found the regexp.
8229 (when (eq found 'found)
8231 (gnus-summary-show-thread)
8232 (gnus-summary-goto-subject gnus-current-article)
8233 (gnus-summary-position-point)
8236 (defun gnus-find-matching-articles (header regexp)
8237 "Return a list of all articles that match REGEXP on HEADER.
8238 This search includes all articles in the current group that Gnus has
8239 fetched headers for, whether they are displayed or not."
8240 (let ((articles nil)
8241 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8242 (case-fold-search t))
8243 (dolist (header gnus-newsgroup-headers)
8244 (when (string-match regexp (funcall func header))
8245 (push (mail-header-number header) articles)))
8246 (nreverse articles)))
8248 (defun gnus-summary-find-matching (header regexp &optional backward unread
8249 not-case-fold not-matching)
8250 "Return a list of all articles that match REGEXP on HEADER.
8251 The search stars on the current article and goes forwards unless
8252 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8253 If UNREAD is non-nil, only unread articles will
8254 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8255 in the comparisons. If NOT-MATCHING, return a list of all articles that
8256 not match REGEXP on HEADER."
8257 (let ((case-fold-search (not not-case-fold))
8260 (if (eq (car header) 'extra)
8263 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8265 (error "%s is an invalid header" header))
8266 (unless (fboundp (intern (concat "mail-header-" header)))
8267 (error "%s is not a valid header" header))
8268 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8269 (dolist (d (if (eq backward 'all)
8271 (gnus-data-find-list
8272 (gnus-summary-article-number)
8273 (gnus-data-list backward))))
8274 (when (and (or (not unread) ; We want all articles...
8275 (gnus-data-unread-p d)) ; Or just unreads.
8276 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8280 (funcall func (gnus-data-header d))))
8281 (string-match regexp
8282 (funcall func (gnus-data-header d)))))
8283 (push (gnus-data-number d) articles))) ; Success!
8284 (nreverse articles)))
8286 (defun gnus-summary-execute-command (header regexp command &optional backward)
8287 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8288 If HEADER is an empty string (or nil), the match is done on the entire
8289 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8291 (list (let ((completion-ignore-case t))
8294 (mapcar (lambda (header) (list (format "%s" header)))
8296 '("Number" "Subject" "From" "Lines" "Date"
8297 "Message-ID" "Xref" "References" "Body")
8298 gnus-extra-headers))
8299 nil 'require-match))
8300 (read-string "Regexp: ")
8301 (read-key-sequence "Command: ")
8302 current-prefix-arg))
8303 (when (equal header "Body")
8305 ;; Hidden thread subtrees must be searched as well.
8306 (gnus-summary-show-all-threads)
8307 ;; We don't want to change current point nor window configuration.
8309 (save-window-excursion
8311 gnus-treat-strip-trailing-blank-lines
8312 gnus-treat-strip-leading-blank-lines
8313 gnus-treat-strip-multiple-blank-lines
8314 gnus-treat-hide-boring-headers
8315 gnus-treat-fold-newsgroups
8316 gnus-article-prepare-hook)
8317 (gnus-message 6 "Executing %s..." (key-description command))
8318 ;; We'd like to execute COMMAND interactively so as to give arguments.
8319 (gnus-execute header regexp
8320 `(call-interactively ',(key-binding command))
8322 (gnus-message 6 "Executing %s...done" (key-description command))))))
8324 (defun gnus-summary-beginning-of-article ()
8325 "Scroll the article back to the beginning."
8327 (gnus-summary-select-article)
8328 (gnus-configure-windows 'article)
8329 (gnus-eval-in-buffer-window gnus-article-buffer
8331 (goto-char (point-min))
8332 (when gnus-page-broken
8333 (gnus-narrow-to-page))))
8335 (defun gnus-summary-end-of-article ()
8336 "Scroll to the end of the article."
8338 (gnus-summary-select-article)
8339 (gnus-configure-windows 'article)
8340 (gnus-eval-in-buffer-window gnus-article-buffer
8342 (goto-char (point-max))
8344 (when gnus-page-broken
8345 (gnus-narrow-to-page))))
8347 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8348 "Truncate to LEN and quote all \"(\"'s in STRING."
8349 (gnus-replace-in-string (if (and len (> (length string) len))
8350 (substring string 0 len)
8354 (defun gnus-summary-print-article (&optional filename n)
8355 "Generate and print a PostScript image of the N next (mail) articles.
8357 If N is negative, print the N previous articles. If N is nil and articles
8358 have been marked with the process mark, print these instead.
8360 If the optional first argument FILENAME is nil, send the image to the
8361 printer. If FILENAME is a string, save the PostScript image in a file with
8362 that name. If FILENAME is a number, prompt the user for the name of the file
8364 (interactive (list (ps-print-preprint current-prefix-arg)))
8365 (dolist (article (gnus-summary-work-articles n))
8366 (gnus-summary-select-article nil nil 'pseudo article)
8367 (gnus-eval-in-buffer-window gnus-article-buffer
8368 (gnus-print-buffer))
8369 (gnus-summary-remove-process-mark article))
8370 (ps-despool filename))
8372 (defun gnus-print-buffer ()
8373 (let ((buffer (generate-new-buffer " *print*")))
8376 (copy-to-buffer buffer (point-min) (point-max))
8378 (gnus-article-delete-invisible-text)
8379 (gnus-remove-text-with-property 'gnus-decoration)
8380 (when (gnus-visual-p 'article-highlight 'highlight)
8381 ;; Copy-to-buffer doesn't copy overlay. So redo
8383 (let ((gnus-article-buffer buffer))
8384 (gnus-article-highlight-citation t)
8385 (gnus-article-highlight-signature)))
8386 (let ((ps-left-header
8389 (gnus-summary-print-truncate-and-quote
8390 (mail-header-subject gnus-current-headers)
8393 (gnus-summary-print-truncate-and-quote
8394 (mail-header-from gnus-current-headers)
8398 "/pagenumberstring load"
8400 (mail-header-date gnus-current-headers) ")"))))
8401 (gnus-run-hooks 'gnus-ps-print-hook)
8404 (ps-spool-buffer-with-faces)
8405 (ps-spool-buffer)))))
8406 (kill-buffer buffer))))
8408 (defun gnus-summary-show-article (&optional arg)
8409 "Force redisplaying of the current article.
8410 If ARG (the prefix) is a number, show the article with the charset
8411 defined in `gnus-summary-show-article-charset-alist', or the charset
8413 If ARG (the prefix) is non-nil and not a number, show the raw article
8414 without any article massaging functions being run. Normally, the key strokes
8419 (gnus-summary-show-article t)
8420 (let ((gnus-newsgroup-charset
8421 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8422 (mm-read-coding-system
8423 "View as charset: " ;; actually it is coding system.
8425 (set-buffer gnus-article-buffer)
8426 (mm-detect-coding-region (point) (point-max))))))
8427 (gnus-newsgroup-ignored-charsets 'gnus-all))
8428 (gnus-summary-select-article nil 'force)
8429 (let ((deps gnus-newsgroup-dependencies)
8432 (set-buffer gnus-original-article-buffer)
8434 (message-narrow-to-head)
8435 (setq head (buffer-string))
8436 (goto-char (point-min))
8437 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8438 (goto-char (point-max))
8440 (setq lines (1- (count-lines (point) (point-max))))))
8442 (insert (format "211 %d Article retrieved.\n"
8443 (cdr gnus-article-current)))
8445 (if lines (insert (format "Lines: %d\n" lines)))
8447 (let ((nntp-server-buffer (current-buffer)))
8448 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8449 (gnus-data-set-header
8450 (gnus-data-find (cdr gnus-article-current))
8452 (gnus-summary-update-article-line
8453 (cdr gnus-article-current) header)
8454 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8455 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8457 ;; Select the article the normal way.
8458 (gnus-summary-select-article nil 'force))
8460 ;; We have to require this here to make sure that the following
8461 ;; dynamic binding isn't shadowed by autoloading.
8462 (require 'gnus-async)
8464 ;; Bind the article treatment functions to nil.
8465 (let ((gnus-have-all-headers t)
8466 gnus-article-prepare-hook
8467 gnus-article-decode-hook
8468 gnus-display-mime-function
8470 ;; Destroy any MIME parts.
8471 (when (gnus-buffer-live-p gnus-article-buffer)
8473 (set-buffer gnus-article-buffer)
8474 (mm-destroy-parts gnus-article-mime-handles)
8475 ;; Set it to nil for safety reason.
8476 (setq gnus-article-mime-handle-alist nil)
8477 (setq gnus-article-mime-handles nil)))
8478 (gnus-summary-select-article nil 'force))))
8479 (gnus-summary-goto-subject gnus-current-article)
8480 (gnus-summary-position-point))
8482 (defun gnus-summary-show-raw-article ()
8483 "Show the raw article without any article massaging functions being run."
8485 (gnus-summary-show-article t))
8487 (defun gnus-summary-verbose-headers (&optional arg)
8488 "Toggle permanent full header display.
8489 If ARG is a positive number, turn header display on.
8490 If ARG is a negative number, turn header display off."
8492 (setq gnus-show-all-headers
8493 (cond ((or (not (numberp arg))
8495 (not gnus-show-all-headers))
8498 (gnus-summary-show-article))
8500 (defun gnus-summary-toggle-header (&optional arg)
8501 "Show the headers if they are hidden, or hide them if they are shown.
8502 If ARG is a positive number, show the entire header.
8503 If ARG is a negative number, hide the unwanted header lines."
8505 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8506 (get-buffer-window gnus-article-buffer t))))
8507 (with-current-buffer gnus-article-buffer
8509 (article-narrow-to-head)
8510 (let* ((buffer-read-only nil)
8511 (inhibit-point-motion-hooks t)
8512 (hidden (if (numberp arg)
8514 (gnus-article-hidden-text-p 'headers)))
8516 (delete-region (point-min) (point-max))
8517 (with-current-buffer gnus-original-article-buffer
8518 (goto-char (setq s (point-min)))
8519 (setq e (if (search-forward "\n\n" nil t)
8522 (insert-buffer-substring gnus-original-article-buffer s e)
8523 (article-decode-encoded-words)
8525 (let ((gnus-treat-hide-headers nil)
8526 (gnus-treat-hide-boring-headers nil))
8527 (gnus-delete-wash-type 'headers)
8528 (gnus-treat-article 'head))
8529 (gnus-treat-article 'head))
8532 (set-window-start window (goto-char (point-min))))
8533 (setq gnus-page-broken
8534 (when gnus-break-pages
8535 (gnus-narrow-to-page)
8537 (gnus-set-mode-line 'article)))))
8539 (defun gnus-summary-show-all-headers ()
8540 "Make all header lines visible."
8542 (gnus-summary-toggle-header 1))
8544 (defun gnus-summary-caesar-message (&optional arg)
8545 "Caesar rotate the current article by 13.
8546 The numerical prefix specifies how many places to rotate each letter
8549 (gnus-summary-select-article)
8550 (let ((mail-header-separator ""))
8551 (gnus-eval-in-buffer-window gnus-article-buffer
8554 (let ((start (window-start))
8556 (message-caesar-buffer-body arg)
8557 (set-window-start (get-buffer-window (current-buffer)) start))))))
8559 (autoload 'unmorse-region "morse"
8560 "Convert morse coded text in region to ordinary ASCII text."
8563 (defun gnus-summary-morse-message (&optional arg)
8564 "Morse decode the current article."
8566 (gnus-summary-select-article)
8567 (let ((mail-header-separator ""))
8568 (gnus-eval-in-buffer-window gnus-article-buffer
8572 (let ((pos (window-start))
8574 (goto-char (point-min))
8575 (when (message-goto-body)
8576 (gnus-narrow-to-body))
8577 (goto-char (point-min))
8578 (while (re-search-forward "·" (point-max) t)
8579 (replace-match "."))
8580 (unmorse-region (point-min) (point-max))
8582 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8584 (defun gnus-summary-stop-page-breaking ()
8585 "Stop page breaking in the current article."
8587 (gnus-summary-select-article)
8588 (gnus-eval-in-buffer-window gnus-article-buffer
8590 (when (gnus-visual-p 'page-marker)
8591 (let ((buffer-read-only nil))
8592 (gnus-remove-text-with-property 'gnus-prev)
8593 (gnus-remove-text-with-property 'gnus-next))
8594 (setq gnus-page-broken nil))))
8596 (defun gnus-summary-move-article (&optional n to-newsgroup
8597 select-method action)
8598 "Move the current article to a different newsgroup.
8599 If N is a positive number, move the N next articles.
8600 If N is a negative number, move the N previous articles.
8601 If N is nil and any articles have been marked with the process mark,
8602 move those articles instead.
8603 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8604 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8605 re-spool using this method.
8607 When called interactively with TO-NEWSGROUP being nil, the value of
8608 the variable `gnus-move-split-methods' is used for finding a default
8609 for the target newsgroup.
8611 For this function to work, both the current newsgroup and the
8612 newsgroup that you want to move to have to support the `request-move'
8613 and `request-accept' functions.
8615 ACTION can be either `move' (the default), `crosspost' or `copy'."
8618 (setq action 'move))
8619 ;; Check whether the source group supports the required functions.
8620 (cond ((and (eq action 'move)
8621 (not (gnus-check-backend-function
8622 'request-move-article gnus-newsgroup-name)))
8623 (error "The current group does not support article moving"))
8624 ((and (eq action 'crosspost)
8625 (not (gnus-check-backend-function
8626 'request-replace-article gnus-newsgroup-name)))
8627 (error "The current group does not support article editing")))
8628 (let ((articles (gnus-summary-work-articles n))
8629 (prefix (if (gnus-check-backend-function
8630 'request-move-article gnus-newsgroup-name)
8631 (gnus-group-real-prefix gnus-newsgroup-name)
8633 (names '((move "Move" "Moving")
8634 (copy "Copy" "Copying")
8635 (crosspost "Crosspost" "Crossposting")))
8636 (copy-buf (save-excursion
8637 (nnheader-set-temp-buffer " *copy article*")))
8638 art-group to-method new-xref article to-groups)
8639 (unless (assq action names)
8640 (error "Unknown action %s" action))
8641 ;; Read the newsgroup name.
8642 (when (and (not to-newsgroup)
8643 (not select-method))
8644 (if (and gnus-move-split-methods
8646 (and (memq gnus-current-article articles)
8647 (gnus-buffer-live-p gnus-original-article-buffer))))
8648 ;; When `gnus-move-split-methods' is non-nil, we have to
8649 ;; select an article to give `gnus-read-move-group-name' an
8650 ;; opportunity to suggest an appropriate default. However,
8651 ;; we needn't render or mark the article.
8652 (let ((gnus-display-mime-function nil)
8653 (gnus-article-prepare-hook nil)
8654 (gnus-mark-article-hook nil))
8655 (gnus-summary-select-article nil nil nil (car articles))))
8657 (gnus-read-move-group-name
8658 (cadr (assq action names))
8659 (symbol-value (intern (format "gnus-current-%s-group" action)))
8661 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8662 (setq to-method (or select-method
8663 (gnus-server-to-method
8664 (gnus-group-method to-newsgroup))))
8665 ;; Check the method we are to move this article to...
8666 (unless (gnus-check-backend-function
8667 'request-accept-article (car to-method))
8668 (error "%s does not support article copying" (car to-method)))
8669 (unless (gnus-check-server to-method)
8670 (error "Can't open server %s" (car to-method)))
8671 (gnus-message 6 "%s to %s: %s..."
8672 (caddr (assq action names))
8673 (or (car select-method) to-newsgroup) articles)
8675 (setq article (pop articles))
8679 ;; Move the article.
8681 ;; Remove this article from future suppression.
8682 (gnus-dup-unsuppress-article article)
8683 (gnus-request-move-article
8684 article ; Article to move
8685 gnus-newsgroup-name ; From newsgroup
8686 (nth 1 (gnus-find-method-for-group
8687 gnus-newsgroup-name)) ; Server
8688 (list 'gnus-request-accept-article
8689 to-newsgroup (list 'quote select-method)
8690 (not articles) t) ; Accept form
8691 (not articles))) ; Only save nov last time
8692 ;; Copy the article.
8695 (set-buffer copy-buf)
8696 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8697 (gnus-request-accept-article
8698 to-newsgroup select-method (not articles) t))))
8699 ;; Crosspost the article.
8700 ((eq action 'crosspost)
8701 (let ((xref (message-tokenize-header
8702 (mail-header-xref (gnus-summary-article-header article))
8704 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8705 ":" (number-to-string article)))
8707 (setq xref (list (system-name))))
8710 (mapconcat 'identity
8711 (delete "Xref:" (delete new-xref xref))
8715 (set-buffer copy-buf)
8716 ;; First put the article in the destination group.
8717 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8718 (when (consp (setq art-group
8719 (gnus-request-accept-article
8720 to-newsgroup select-method (not articles))))
8721 (setq new-xref (concat new-xref " " (car art-group)
8723 (number-to-string (cdr art-group))))
8724 ;; Now we have the new Xrefs header, so we insert
8725 ;; it and replace the new article.
8726 (nnheader-replace-header "Xref" new-xref)
8727 (gnus-request-replace-article
8728 (cdr art-group) to-newsgroup (current-buffer))
8732 (gnus-message 1 "Couldn't %s article %s: %s"
8733 (cadr (assq action names)) article
8734 (nnheader-get-report (car to-method))))
8735 ((eq art-group 'junk)
8736 (when (eq action 'move)
8737 (gnus-summary-mark-article article gnus-canceled-mark)
8738 (gnus-message 4 "Deleted article %s" article)))
8740 (let* ((pto-group (gnus-group-prefixed-name
8741 (car art-group) to-method))
8743 (gnus-gethash pto-group gnus-newsrc-hashtb))
8744 (info (nth 2 entry))
8745 (to-group (gnus-info-group info))
8747 ;; Update the group that has been moved to.
8749 (memq action '(move copy)))
8750 (unless (member to-group to-groups)
8751 (push to-group to-groups))
8753 (unless (memq article gnus-newsgroup-unreads)
8754 (push 'read to-marks)
8756 info (gnus-add-to-range (gnus-info-read info)
8757 (list (cdr art-group)))))
8759 ;; See whether the article is to be put in the cache.
8760 (let ((marks gnus-article-mark-lists)
8761 (to-article (cdr art-group)))
8763 ;; Enter the article into the cache in the new group,
8764 ;; if that is required.
8765 (when gnus-use-cache
8766 (gnus-cache-possibly-enter-article
8768 (memq article gnus-newsgroup-marked)
8769 (memq article gnus-newsgroup-dormant)
8770 (memq article gnus-newsgroup-unreads)))
8772 (when gnus-preserve-marks
8773 ;; Copy any marks over to the new group.
8774 (when (and (equal to-group gnus-newsgroup-name)
8775 (not (memq article gnus-newsgroup-unreads)))
8776 ;; Mark this article as read in this group.
8777 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8778 (setcdr (gnus-active to-group) to-article)
8779 (setcdr gnus-newsgroup-active to-article))
8782 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8783 (when (memq article (symbol-value
8784 (intern (format "gnus-newsgroup-%s"
8786 (push (cdar marks) to-marks)
8787 ;; If the other group is the same as this group,
8788 ;; then we have to add the mark to the list.
8789 (when (equal to-group gnus-newsgroup-name)
8790 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8793 (intern (format "gnus-newsgroup-%s"
8795 ;; Copy the marks to other group.
8796 (gnus-add-marked-articles
8797 to-group (cdar marks) (list to-article) info)))
8798 (setq marks (cdr marks)))
8800 (gnus-request-set-mark
8801 to-group (list (list (list to-article) 'add to-marks))))
8804 (concat "(gnus-group-set-info '"
8805 (gnus-prin1-to-string (gnus-get-info to-group))
8808 ;; Update the Xref header in this article to point to
8809 ;; the new crossposted article we have just created.
8810 (when (eq action 'crosspost)
8812 (set-buffer copy-buf)
8813 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8814 (nnheader-replace-header "Xref" new-xref)
8815 (gnus-request-replace-article
8816 article gnus-newsgroup-name (current-buffer)))))
8818 ;;;!!!Why is this necessary?
8819 (set-buffer gnus-summary-buffer)
8821 (gnus-summary-goto-subject article)
8822 (when (eq action 'move)
8823 (gnus-summary-mark-article article gnus-canceled-mark))))
8824 (gnus-summary-remove-process-mark article))
8825 ;; Re-activate all groups that have been moved to.
8827 (set-buffer gnus-group-buffer)
8828 (let ((gnus-group-marked to-groups))
8829 (gnus-group-get-new-news-this-group nil t)))
8831 (gnus-kill-buffer copy-buf)
8832 (gnus-summary-position-point)
8833 (gnus-set-mode-line 'summary)))
8835 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8836 "Move the current article to a different newsgroup.
8837 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8838 When called interactively, if TO-NEWSGROUP is nil, use the value of
8839 the variable `gnus-move-split-methods' for finding a default target
8841 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8842 re-spool using this method."
8844 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8846 (defun gnus-summary-crosspost-article (&optional n)
8847 "Crosspost the current article to some other group."
8849 (gnus-summary-move-article n nil nil 'crosspost))
8851 (defcustom gnus-summary-respool-default-method nil
8852 "Default method type for respooling an article.
8853 If nil, use to the current newsgroup method."
8855 :group 'gnus-summary-mail)
8857 (defcustom gnus-summary-display-while-building nil
8858 "If not-nil, show and update the summary buffer as it's being built.
8859 If the value is t, update the buffer after every line is inserted. If
8860 the value is an integer (N), update the display every N lines."
8862 :type '(choice (const :tag "off" nil)
8864 (const :tag "frequently" t)))
8866 (defun gnus-summary-respool-article (&optional n method)
8867 "Respool the current article.
8868 The article will be squeezed through the mail spooling process again,
8869 which means that it will be put in some mail newsgroup or other
8870 depending on `nnmail-split-methods'.
8871 If N is a positive number, respool the N next articles.
8872 If N is a negative number, respool the N previous articles.
8873 If N is nil and any articles have been marked with the process mark,
8874 respool those articles instead.
8876 Respooling can be done both from mail groups and \"real\" newsgroups.
8877 In the former case, the articles in question will be moved from the
8878 current group into whatever groups they are destined to. In the
8879 latter case, they will be copied into the relevant groups."
8881 (list current-prefix-arg
8882 (let* ((methods (gnus-methods-using 'respool))
8884 (symbol-name (or gnus-summary-respool-default-method
8885 (car (gnus-find-method-for-group
8886 gnus-newsgroup-name)))))
8888 (gnus-completing-read-with-default
8889 methname "What backend do you want to use when respooling?"
8890 methods nil t nil 'gnus-mail-method-history))
8893 ((zerop (length (setq ms (gnus-servers-using-backend
8895 (list (intern method) ""))
8899 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8900 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8903 (error "No method given for respooling"))
8904 (if (assoc (symbol-name
8905 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8906 (gnus-methods-using 'respool))
8907 (gnus-summary-move-article n nil method)
8908 (gnus-summary-copy-article n nil method)))
8910 (defun gnus-summary-import-article (file &optional edit)
8911 "Import an arbitrary file into a mail newsgroup."
8912 (interactive "fImport file: \nP")
8913 (let ((group gnus-newsgroup-name)
8914 (now (current-time))
8915 atts lines group-art)
8916 (unless (gnus-check-backend-function 'request-accept-article group)
8917 (error "%s does not support article importing" group))
8918 (or (file-readable-p file)
8919 (not (file-regular-p file))
8920 (error "Can't read %s" file))
8922 (set-buffer (gnus-get-buffer-create " *import file*"))
8924 (nnheader-insert-file-contents file)
8925 (goto-char (point-min))
8926 (if (nnheader-article-p)
8928 (goto-char (point-min))
8929 (search-forward "\n\n" nil t)
8930 (narrow-to-region (point-min) (1- (point)))
8931 (goto-char (point-min))
8932 (unless (re-search-forward "^date:" nil t)
8933 (goto-char (point-max))
8934 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8935 ;; This doesn't look like an article, so we fudge some headers.
8936 (setq atts (file-attributes file)
8937 lines (count-lines (point-min) (point-max)))
8938 (insert "From: " (read-string "From: ") "\n"
8939 "Subject: " (read-string "Subject: ") "\n"
8940 "Date: " (message-make-date (nth 5 atts)) "\n"
8941 "Message-ID: " (message-make-message-id) "\n"
8942 "Lines: " (int-to-string lines) "\n"
8943 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8944 (setq group-art (gnus-request-accept-article group nil t))
8945 (kill-buffer (current-buffer)))
8946 (setq gnus-newsgroup-active (gnus-activate-group group))
8948 (gnus-summary-goto-article (cdr group-art) nil t)
8950 (gnus-summary-edit-article))))
8952 (defun gnus-summary-create-article ()
8953 "Create an article in a mail newsgroup."
8955 (let ((group gnus-newsgroup-name)
8956 (now (current-time))
8958 (unless (gnus-check-backend-function 'request-accept-article group)
8959 (error "%s does not support article importing" group))
8961 (set-buffer (gnus-get-buffer-create " *import file*"))
8963 (goto-char (point-min))
8964 ;; This doesn't look like an article, so we fudge some headers.
8965 (insert "From: " (read-string "From: ") "\n"
8966 "Subject: " (read-string "Subject: ") "\n"
8967 "Date: " (message-make-date now) "\n"
8968 "Message-ID: " (message-make-message-id) "\n")
8969 (setq group-art (gnus-request-accept-article group nil t))
8970 (kill-buffer (current-buffer)))
8971 (setq gnus-newsgroup-active (gnus-activate-group group))
8973 (gnus-summary-goto-article (cdr group-art) nil t)
8974 (gnus-summary-edit-article)))
8976 (defun gnus-summary-article-posted-p ()
8977 "Say whether the current (mail) article is available from news as well.
8978 This will be the case if the article has both been mailed and posted."
8980 (let ((id (mail-header-references (gnus-summary-article-header)))
8981 (gnus-override-method (car (gnus-refer-article-methods))))
8982 (if (gnus-request-head id "")
8983 (gnus-message 2 "The current message was found on %s"
8984 gnus-override-method)
8985 (gnus-message 2 "The current message couldn't be found on %s"
8986 gnus-override-method)
8989 (defun gnus-summary-expire-articles (&optional now)
8990 "Expire all articles that are marked as expirable in the current group."
8992 (when (gnus-check-backend-function
8993 'request-expire-articles gnus-newsgroup-name)
8994 ;; This backend supports expiry.
8995 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8996 (expirable (if total
8998 ;; We need to update the info for
8999 ;; this group for `gnus-list-of-read-articles'
9000 ;; to give us the right answer.
9001 (gnus-run-hooks 'gnus-exit-group-hook)
9002 (gnus-summary-update-info)
9003 (gnus-list-of-read-articles gnus-newsgroup-name))
9004 (setq gnus-newsgroup-expirable
9005 (sort gnus-newsgroup-expirable '<))))
9006 (expiry-wait (if now 'immediate
9007 (gnus-group-find-parameter
9008 gnus-newsgroup-name 'expiry-wait)))
9009 (nnmail-expiry-target
9010 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9011 nnmail-expiry-target))
9014 ;; There are expirable articles in this group, so we run them
9015 ;; through the expiry process.
9016 (gnus-message 6 "Expiring articles...")
9017 (unless (gnus-check-group gnus-newsgroup-name)
9018 (error "Can't open server for %s" gnus-newsgroup-name))
9019 ;; The list of articles that weren't expired is returned.
9022 (let ((nnmail-expiry-wait-function nil)
9023 (nnmail-expiry-wait expiry-wait))
9024 (setq es (gnus-request-expire-articles
9025 expirable gnus-newsgroup-name)))
9026 (setq es (gnus-request-expire-articles
9027 expirable gnus-newsgroup-name)))
9029 (setq gnus-newsgroup-expirable es))
9030 ;; We go through the old list of expirable, and mark all
9031 ;; really expired articles as nonexistent.
9032 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9033 (let ((gnus-use-cache nil))
9034 (dolist (article expirable)
9035 (when (and (not (memq article es))
9036 (gnus-data-find article))
9037 (gnus-summary-mark-article article gnus-canceled-mark))))))
9038 (gnus-message 6 "Expiring articles...done")))))
9040 (defun gnus-summary-expire-articles-now ()
9041 "Expunge all expirable articles in the current group.
9042 This means that *all* articles that are marked as expirable will be
9043 deleted forever, right now."
9045 (or gnus-expert-user
9047 "Are you really, really, really sure you want to delete all these messages? ")
9049 (gnus-summary-expire-articles t))
9051 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9052 (defun gnus-summary-delete-article (&optional n)
9053 "Delete the N next (mail) articles.
9054 This command actually deletes articles. This is not a marking
9055 command. The article will disappear forever from your life, never to
9057 If N is negative, delete backwards.
9058 If N is nil and articles have been marked with the process mark,
9059 delete these instead."
9061 (unless (gnus-check-backend-function 'request-expire-articles
9062 gnus-newsgroup-name)
9063 (error "The current newsgroup does not support article deletion"))
9064 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9065 (error "Couldn't open server"))
9066 ;; Compute the list of articles to delete.
9067 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9068 (nnmail-expiry-target 'delete)
9070 (if (and gnus-novice-user
9071 (not (gnus-yes-or-no-p
9072 (format "Do you really want to delete %s forever? "
9073 (if (> (length articles) 1)
9074 (format "these %s articles" (length articles))
9077 ;; Delete the articles.
9078 (setq not-deleted (gnus-request-expire-articles
9079 articles gnus-newsgroup-name 'force))
9081 (gnus-summary-remove-process-mark (car articles))
9082 ;; The backend might not have been able to delete the article
9084 (unless (memq (car articles) not-deleted)
9085 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9086 (setq articles (cdr articles)))
9088 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9089 (gnus-summary-position-point)
9090 (gnus-set-mode-line 'summary)
9093 (defun gnus-summary-edit-article (&optional arg)
9094 "Edit the current article.
9095 This will have permanent effect only in mail groups.
9096 If ARG is nil, edit the decoded articles.
9097 If ARG is 1, edit the raw articles.
9098 If ARG is 2, edit the raw articles even in read-only groups.
9099 If ARG is 3, edit the articles with the current handles.
9100 Otherwise, allow editing of articles even in read-only
9103 (let (force raw current-handles)
9112 (setq current-handles
9113 (and (gnus-buffer-live-p gnus-article-buffer)
9114 (with-current-buffer gnus-article-buffer
9116 gnus-article-mime-handles
9117 (setq gnus-article-mime-handles nil))))))
9120 (when (and raw (not force)
9121 (member gnus-newsgroup-name '("nndraft:delayed"
9124 (error "Can't edit the raw article in group %s"
9125 gnus-newsgroup-name))
9127 (set-buffer gnus-summary-buffer)
9128 (let ((mail-parse-charset gnus-newsgroup-charset)
9129 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9130 (gnus-set-global-variables)
9131 (when (and (not force)
9132 (gnus-group-read-only-p))
9133 (error "The current newsgroup does not support article editing"))
9134 (gnus-summary-show-article t)
9135 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9136 (with-current-buffer gnus-article-buffer
9137 (mm-enable-multibyte)))
9138 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9140 (gnus-article-edit-article
9143 (let ((mbl mml-buffer-list))
9144 (setq mml-buffer-list nil)
9145 (mime-to-mml ,'current-handles)
9146 (let ((mbl1 mml-buffer-list))
9147 (setq mml-buffer-list mbl)
9148 (set (make-local-variable 'mml-buffer-list) mbl1))
9149 (make-local-hook 'kill-buffer-hook)
9150 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9151 `(lambda (no-highlight)
9152 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9153 (message-options message-options)
9154 (message-options-set-recipient)
9155 (mail-parse-ignored-charsets
9156 ',gnus-newsgroup-ignored-charsets))
9157 ,(if (not raw) '(progn
9159 (mml-destroy-buffers)
9160 (remove-hook 'kill-buffer-hook
9161 'mml-destroy-buffers t)
9162 (kill-local-variable 'mml-buffer-list)))
9163 (gnus-summary-edit-article-done
9164 ,(or (mail-header-references gnus-current-headers) "")
9165 ,(gnus-group-read-only-p)
9166 ,gnus-summary-buffer no-highlight))))))))
9168 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9170 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9172 "Make edits to the current article permanent."
9175 ;; The buffer restriction contains the entire article if it exists.
9176 (when (article-goto-body)
9177 (let ((lines (count-lines (point) (point-max)))
9178 (length (- (point-max) (point)))
9179 (case-fold-search t)
9180 (body (copy-marker (point))))
9181 (goto-char (point-min))
9182 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9183 (delete-region (match-beginning 1) (match-end 1))
9184 (insert (number-to-string length)))
9185 (goto-char (point-min))
9186 (when (re-search-forward
9187 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9188 (delete-region (match-beginning 1) (match-end 1))
9189 (insert (number-to-string length)))
9190 (goto-char (point-min))
9191 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9192 (delete-region (match-beginning 1) (match-end 1))
9193 (insert (number-to-string lines))))))
9194 ;; Replace the article.
9195 (let ((buf (current-buffer)))
9197 (insert-buffer-substring buf)
9199 (if (and (not read-only)
9200 (not (gnus-request-replace-article
9201 (cdr gnus-article-current) (car gnus-article-current)
9202 (current-buffer) t)))
9203 (error "Couldn't replace article")
9204 ;; Update the summary buffer.
9206 (equal (message-tokenize-header references " ")
9207 (message-tokenize-header
9208 (or (message-fetch-field "references") "") " ")))
9209 ;; We only have to update this line.
9212 (message-narrow-to-head)
9213 (let ((head (buffer-string))
9216 (insert (format "211 %d Article retrieved.\n"
9217 (cdr gnus-article-current)))
9220 (let ((nntp-server-buffer (current-buffer)))
9221 (setq header (car (gnus-get-newsgroup-headers
9224 (set-buffer gnus-summary-buffer)
9225 (gnus-data-set-header
9226 (gnus-data-find (cdr gnus-article-current))
9228 (gnus-summary-update-article-line
9229 (cdr gnus-article-current) header)
9230 (if (gnus-summary-goto-subject
9231 (cdr gnus-article-current) nil t)
9232 (gnus-summary-update-secondary-mark
9233 (cdr gnus-article-current))))))))
9235 (set-buffer (or buffer gnus-summary-buffer))
9236 (gnus-summary-update-article (cdr gnus-article-current))
9237 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9238 (gnus-summary-update-secondary-mark
9239 (cdr gnus-article-current))))
9240 ;; Prettify the article buffer again.
9241 (unless no-highlight
9243 (set-buffer gnus-article-buffer)
9244 ;;;!!! Fix this -- article should be rehighlighted.
9245 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9246 (set-buffer gnus-original-article-buffer)
9247 (gnus-request-article
9248 (cdr gnus-article-current)
9249 (car gnus-article-current) (current-buffer))))
9250 ;; Prettify the summary buffer line.
9251 (when (gnus-visual-p 'summary-highlight 'highlight)
9252 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9254 (defun gnus-summary-edit-wash (key)
9255 "Perform editing command KEY in the article buffer."
9259 (message "%s" (concat (this-command-keys) "- "))
9262 (gnus-summary-edit-article)
9263 (execute-kbd-macro (concat (this-command-keys) key))
9264 (gnus-article-edit-done))
9268 (defun gnus-summary-respool-query (&optional silent trace)
9269 "Query where the respool algorithm would put this article."
9271 (let (gnus-mark-article-hook)
9272 (gnus-summary-select-article)
9274 (set-buffer gnus-original-article-buffer)
9276 (message-narrow-to-head)
9277 (let ((groups (nnmail-article-group 'identity trace)))
9280 (message "This message would go to %s"
9281 (mapconcat 'car groups ", "))
9282 (message "This message would go to no groups"))
9285 (defun gnus-summary-respool-trace ()
9286 "Trace where the respool algorithm would put this article.
9287 Display a buffer showing all fancy splitting patterns which matched."
9289 (gnus-summary-respool-query nil t))
9291 ;; Summary marking commands.
9293 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9294 "Mark articles which has the same subject as read, and then select the next.
9295 If UNMARK is positive, remove any kind of mark.
9296 If UNMARK is negative, tick articles."
9299 (setq unmark (prefix-numeric-value unmark)))
9301 (gnus-summary-mark-same-subject
9302 (gnus-summary-article-subject) unmark)))
9303 ;; Select next unread article. If auto-select-same mode, should
9304 ;; select the first unread article.
9305 (gnus-summary-next-article t (and gnus-auto-select-same
9306 (gnus-summary-article-subject)))
9307 (gnus-message 7 "%d article%s marked as %s"
9308 count (if (= count 1) " is" "s are")
9309 (if unmark "unread" "read"))))
9311 (defun gnus-summary-kill-same-subject (&optional unmark)
9312 "Mark articles which has the same subject as read.
9313 If UNMARK is positive, remove any kind of mark.
9314 If UNMARK is negative, tick articles."
9317 (setq unmark (prefix-numeric-value unmark)))
9319 (gnus-summary-mark-same-subject
9320 (gnus-summary-article-subject) unmark)))
9321 ;; If marked as read, go to next unread subject.
9323 ;; Go to next unread subject.
9324 (gnus-summary-next-subject 1 t))
9325 (gnus-message 7 "%d articles are marked as %s"
9326 count (if unmark "unread" "read"))))
9328 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9329 "Mark articles with same SUBJECT as read, and return marked number.
9330 If optional argument UNMARK is positive, remove any kinds of marks.
9331 If optional argument UNMARK is negative, mark articles as unread instead."
9335 ((null unmark) ; Mark as read.
9338 (gnus-summary-mark-article-as-read gnus-killed-mark)
9339 (gnus-summary-show-thread) t)
9340 (gnus-summary-find-subject subject))
9341 (setq count (1+ count))))
9342 ((> unmark 0) ; Tick.
9345 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9346 (gnus-summary-show-thread) t)
9347 (gnus-summary-find-subject subject))
9348 (setq count (1+ count))))
9349 (t ; Mark as unread.
9352 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9353 (gnus-summary-show-thread) t)
9354 (gnus-summary-find-subject subject))
9355 (setq count (1+ count)))))
9356 (gnus-set-mode-line 'summary)
9357 ;; Return the number of marked articles.
9360 (defun gnus-summary-mark-as-processable (n &optional unmark)
9361 "Set the process mark on the next N articles.
9362 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9363 the process mark instead. The difference between N and the actual
9364 number of articles marked is returned."
9366 (if (and (null n) (gnus-region-active-p))
9367 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9368 (setq n (prefix-numeric-value n))
9369 (let ((backward (< n 0))
9374 (gnus-summary-remove-process-mark
9375 (gnus-summary-article-number))
9376 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9377 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9380 (gnus-message 7 "No more articles"))
9381 (gnus-summary-recenter)
9382 (gnus-summary-position-point)
9385 (defun gnus-summary-unmark-as-processable (n)
9386 "Remove the process mark from the next N articles.
9387 If N is negative, unmark backward instead. The difference between N and
9388 the actual number of articles unmarked is returned."
9390 (gnus-summary-mark-as-processable n t))
9392 (defun gnus-summary-unmark-all-processable ()
9393 "Remove the process mark from all articles."
9396 (while gnus-newsgroup-processable
9397 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9398 (gnus-summary-position-point))
9400 (defun gnus-summary-add-mark (article type)
9401 "Mark ARTICLE with a mark of TYPE."
9402 (let ((vtype (car (assq type gnus-article-mark-lists)))
9405 (error "No such mark type: %s" type)
9406 (setq var (intern (format "gnus-newsgroup-%s" type)))
9407 (set var (cons article (symbol-value var)))
9408 (if (memq type '(processable cached replied forwarded recent saved))
9409 (gnus-summary-update-secondary-mark article)
9410 ;;; !!! This is bogus. We should find out what primary
9411 ;;; !!! mark we want to set.
9412 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9414 (defun gnus-summary-mark-as-expirable (n)
9415 "Mark N articles forward as expirable.
9416 If N is negative, mark backward instead. The difference between N and
9417 the actual number of articles marked is returned."
9419 (gnus-summary-mark-forward n gnus-expirable-mark))
9421 (defun gnus-summary-mark-as-spam (n)
9422 "Mark N articles forward as spam.
9423 If N is negative, mark backward instead. The difference between N and
9424 the actual number of articles marked is returned."
9426 (gnus-summary-mark-forward n gnus-spam-mark))
9428 (defun gnus-summary-mark-article-as-replied (article)
9429 "Mark ARTICLE as replied to and update the summary line.
9430 ARTICLE can also be a list of articles."
9431 (interactive (list (gnus-summary-article-number)))
9432 (let ((articles (if (listp article) article (list article))))
9433 (dolist (article articles)
9434 (push article gnus-newsgroup-replied)
9435 (let ((buffer-read-only nil))
9436 (when (gnus-summary-goto-subject article nil t)
9437 (gnus-summary-update-secondary-mark article))))))
9439 (defun gnus-summary-mark-article-as-forwarded (article)
9440 "Mark ARTICLE as forwarded and update the summary line.
9441 ARTICLE can also be a list of articles."
9442 (let ((articles (if (listp article) article (list article))))
9443 (dolist (article articles)
9444 (push article gnus-newsgroup-forwarded)
9445 (let ((buffer-read-only nil))
9446 (when (gnus-summary-goto-subject article nil t)
9447 (gnus-summary-update-secondary-mark article))))))
9449 (defun gnus-summary-set-bookmark (article)
9450 "Set a bookmark in current article."
9451 (interactive (list (gnus-summary-article-number)))
9452 (when (or (not (get-buffer gnus-article-buffer))
9453 (not gnus-current-article)
9454 (not gnus-article-current)
9455 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9456 (error "No current article selected"))
9457 ;; Remove old bookmark, if one exists.
9458 (gnus-pull article gnus-newsgroup-bookmarks)
9459 ;; Set the new bookmark, which is on the form
9460 ;; (article-number . line-number-in-body).
9464 (set-buffer gnus-article-buffer)
9471 gnus-newsgroup-bookmarks)
9472 (gnus-message 6 "A bookmark has been added to the current article."))
9474 (defun gnus-summary-remove-bookmark (article)
9475 "Remove the bookmark from the current article."
9476 (interactive (list (gnus-summary-article-number)))
9477 ;; Remove old bookmark, if one exists.
9478 (if (not (assq article gnus-newsgroup-bookmarks))
9479 (gnus-message 6 "No bookmark in current article.")
9480 (gnus-pull article gnus-newsgroup-bookmarks)
9481 (gnus-message 6 "Removed bookmark.")))
9483 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9484 (defun gnus-summary-mark-as-dormant (n)
9485 "Mark N articles forward as dormant.
9486 If N is negative, mark backward instead. The difference between N and
9487 the actual number of articles marked is returned."
9489 (gnus-summary-mark-forward n gnus-dormant-mark))
9491 (defun gnus-summary-set-process-mark (article)
9492 "Set the process mark on ARTICLE and update the summary line."
9493 (setq gnus-newsgroup-processable
9495 (delq article gnus-newsgroup-processable)))
9496 (when (gnus-summary-goto-subject article)
9497 (gnus-summary-show-thread)
9498 (gnus-summary-goto-subject article)
9499 (gnus-summary-update-secondary-mark article)))
9501 (defun gnus-summary-remove-process-mark (article)
9502 "Remove the process mark from ARTICLE and update the summary line."
9503 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9504 (when (gnus-summary-goto-subject article)
9505 (gnus-summary-show-thread)
9506 (gnus-summary-goto-subject article)
9507 (gnus-summary-update-secondary-mark article)))
9509 (defun gnus-summary-set-saved-mark (article)
9510 "Set the process mark on ARTICLE and update the summary line."
9511 (push article gnus-newsgroup-saved)
9512 (when (gnus-summary-goto-subject article)
9513 (gnus-summary-update-secondary-mark article)))
9515 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9516 "Mark N articles as read forwards.
9517 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9518 The difference between N and the actual number of articles marked is
9520 If NO-EXPIRE, auto-expiry will be inhibited."
9522 (gnus-summary-show-thread)
9523 (let ((backward (< n 0))
9524 (gnus-summary-goto-unread
9525 (and gnus-summary-goto-unread
9526 (not (eq gnus-summary-goto-unread 'never))
9527 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9528 gnus-ticked-mark gnus-dormant-mark)))))
9530 (mark (or mark gnus-del-mark)))
9532 (gnus-summary-mark-article nil mark no-expire)
9533 (zerop (gnus-summary-next-subject
9535 (and gnus-summary-goto-unread
9536 (not (eq gnus-summary-goto-unread 'never)))
9540 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9541 (gnus-summary-recenter)
9542 (gnus-summary-position-point)
9543 (gnus-set-mode-line 'summary)
9546 (defun gnus-summary-mark-article-as-read (mark)
9547 "Mark the current article quickly as read with MARK."
9548 (let ((article (gnus-summary-article-number)))
9549 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9550 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9551 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9552 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9553 (push (cons article mark) gnus-newsgroup-reads)
9554 ;; Possibly remove from cache, if that is used.
9555 (when gnus-use-cache
9556 (gnus-cache-enter-remove-article article))
9557 ;; Allow the backend to change the mark.
9558 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9559 ;; Check for auto-expiry.
9560 (when (and gnus-newsgroup-auto-expire
9561 (memq mark gnus-auto-expirable-marks))
9562 (setq mark gnus-expirable-mark)
9563 ;; Let the backend know about the mark change.
9564 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9565 (push article gnus-newsgroup-expirable))
9566 ;; Set the mark in the buffer.
9567 (gnus-summary-update-mark mark 'unread)
9570 (defun gnus-summary-mark-article-as-unread (mark)
9571 "Mark the current article quickly as unread with MARK."
9572 (let* ((article (gnus-summary-article-number))
9573 (old-mark (gnus-summary-article-mark article)))
9574 ;; Allow the backend to change the mark.
9575 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9576 (if (eq mark old-mark)
9580 (gnus-error 1 "Can't mark negative article numbers")
9582 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9583 (setq gnus-newsgroup-spam-marked
9584 (delq article gnus-newsgroup-spam-marked))
9585 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9586 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9587 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9588 (cond ((= mark gnus-ticked-mark)
9589 (setq gnus-newsgroup-marked
9590 (gnus-add-to-sorted-list gnus-newsgroup-marked
9592 ((= mark gnus-spam-mark)
9593 (setq gnus-newsgroup-spam-marked
9594 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9596 ((= mark gnus-dormant-mark)
9597 (setq gnus-newsgroup-dormant
9598 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9601 (setq gnus-newsgroup-unreads
9602 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9604 (gnus-pull article gnus-newsgroup-reads)
9606 ;; See whether the article is to be put in the cache.
9608 (vectorp (gnus-summary-article-header article))
9610 (gnus-cache-possibly-enter-article
9611 gnus-newsgroup-name article
9612 (= mark gnus-ticked-mark)
9613 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9616 (gnus-summary-update-mark mark 'unread)
9619 (defun gnus-summary-mark-article (&optional article mark no-expire)
9620 "Mark ARTICLE with MARK. MARK can be any character.
9621 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9622 `??' (dormant) and `?E' (expirable).
9623 If MARK is nil, then the default character `?r' is used.
9624 If ARTICLE is nil, then the article on the current line will be
9626 If NO-EXPIRE, auto-expiry will be inhibited."
9627 ;; The mark might be a string.
9628 (when (stringp mark)
9629 (setq mark (aref mark 0)))
9630 ;; If no mark is given, then we check auto-expiring.
9632 (setq mark gnus-del-mark))
9633 (when (and (not no-expire)
9634 gnus-newsgroup-auto-expire
9635 (memq mark gnus-auto-expirable-marks))
9636 (setq mark gnus-expirable-mark))
9637 (let ((article (or article (gnus-summary-article-number)))
9638 (old-mark (gnus-summary-article-mark article)))
9639 ;; Allow the backend to change the mark.
9640 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9641 (if (eq mark old-mark)
9644 (error "No article on current line"))
9645 (if (not (if (or (= mark gnus-unread-mark)
9646 (= mark gnus-ticked-mark)
9647 (= mark gnus-spam-mark)
9648 (= mark gnus-dormant-mark))
9649 (gnus-mark-article-as-unread article mark)
9650 (gnus-mark-article-as-read article mark)))
9652 ;; See whether the article is to be put in the cache.
9654 (not (= mark gnus-canceled-mark))
9655 (vectorp (gnus-summary-article-header article))
9657 (gnus-cache-possibly-enter-article
9658 gnus-newsgroup-name article
9659 (= mark gnus-ticked-mark)
9660 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9662 (when (gnus-summary-goto-subject article nil t)
9663 (let ((buffer-read-only nil))
9664 (gnus-summary-show-thread)
9666 (gnus-summary-update-mark mark 'unread)
9669 (defun gnus-summary-update-secondary-mark (article)
9670 "Update the secondary (read, process, cache) mark."
9671 (gnus-summary-update-mark
9672 (cond ((memq article gnus-newsgroup-processable)
9674 ((memq article gnus-newsgroup-cached)
9676 ((memq article gnus-newsgroup-replied)
9678 ((memq article gnus-newsgroup-forwarded)
9679 gnus-forwarded-mark)
9680 ((memq article gnus-newsgroup-saved)
9682 ((memq article gnus-newsgroup-recent)
9684 ((memq article gnus-newsgroup-unseen)
9688 (when (gnus-visual-p 'summary-highlight 'highlight)
9689 (gnus-run-hooks 'gnus-summary-update-hook))
9692 (defun gnus-summary-update-download-mark (article)
9693 "Update the secondary (read, process, cache) mark."
9694 (gnus-summary-update-mark
9695 (cond ((memq article gnus-newsgroup-undownloaded)
9696 gnus-undownloaded-mark)
9697 (gnus-newsgroup-agentized
9698 gnus-downloaded-mark)
9702 (gnus-summary-update-line t)
9705 (defun gnus-summary-update-mark (mark type)
9706 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9707 (buffer-read-only nil))
9708 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9710 (when (looking-at "\r")
9712 (when (<= (+ forward (point)) (point-max))
9713 ;; Go to the right position on the line.
9714 (goto-char (+ forward (point)))
9715 ;; Replace the old mark with the new mark.
9716 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9717 ;; Optionally update the marks by some user rule.
9718 (when (eq type 'unread)
9720 (gnus-data-find (gnus-summary-article-number)) mark)
9721 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9723 (defun gnus-mark-article-as-read (article &optional mark)
9724 "Enter ARTICLE in the pertinent lists and remove it from others."
9725 ;; Make the article expirable.
9726 (let ((mark (or mark gnus-del-mark)))
9727 (setq gnus-newsgroup-expirable
9728 (if (= mark gnus-expirable-mark)
9729 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9730 (delq article gnus-newsgroup-expirable)))
9731 ;; Remove from unread and marked lists.
9732 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9733 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9734 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9735 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9736 (push (cons article mark) gnus-newsgroup-reads)
9737 ;; Possibly remove from cache, if that is used.
9738 (when gnus-use-cache
9739 (gnus-cache-enter-remove-article article))
9742 (defun gnus-mark-article-as-unread (article &optional mark)
9743 "Enter ARTICLE in the pertinent lists and remove it from others."
9744 (let ((mark (or mark gnus-ticked-mark)))
9747 (gnus-error 1 "Can't mark negative article numbers")
9749 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9750 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9751 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9752 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9753 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9755 ;; Unsuppress duplicates?
9756 (when gnus-suppress-duplicates
9757 (gnus-dup-unsuppress-article article))
9759 (cond ((= mark gnus-ticked-mark)
9760 (setq gnus-newsgroup-marked
9761 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9762 ((= mark gnus-spam-mark)
9763 (setq gnus-newsgroup-spam-marked
9764 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9766 ((= mark gnus-dormant-mark)
9767 (setq gnus-newsgroup-dormant
9768 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9770 (setq gnus-newsgroup-unreads
9771 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9772 (gnus-pull article gnus-newsgroup-reads)
9775 (defalias 'gnus-summary-mark-as-unread-forward
9776 'gnus-summary-tick-article-forward)
9777 (make-obsolete 'gnus-summary-mark-as-unread-forward
9778 'gnus-summary-tick-article-forward)
9779 (defun gnus-summary-tick-article-forward (n)
9780 "Tick N articles forwards.
9781 If N is negative, tick backwards instead.
9782 The difference between N and the number of articles ticked is returned."
9784 (gnus-summary-mark-forward n gnus-ticked-mark))
9786 (defalias 'gnus-summary-mark-as-unread-backward
9787 'gnus-summary-tick-article-backward)
9788 (make-obsolete 'gnus-summary-mark-as-unread-backward
9789 'gnus-summary-tick-article-backward)
9790 (defun gnus-summary-tick-article-backward (n)
9791 "Tick N articles backwards.
9792 The difference between N and the number of articles ticked is returned."
9794 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9796 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9797 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9798 (defun gnus-summary-tick-article (&optional article clear-mark)
9799 "Mark current article as unread.
9800 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9801 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9803 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9806 (defun gnus-summary-mark-as-read-forward (n)
9807 "Mark N articles as read forwards.
9808 If N is negative, mark backwards instead.
9809 The difference between N and the actual number of articles marked is
9812 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9814 (defun gnus-summary-mark-as-read-backward (n)
9815 "Mark the N articles as read backwards.
9816 The difference between N and the actual number of articles marked is
9819 (gnus-summary-mark-forward
9820 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9822 (defun gnus-summary-mark-as-read (&optional article mark)
9823 "Mark current article as read.
9824 ARTICLE specifies the article to be marked as read.
9825 MARK specifies a string to be inserted at the beginning of the line."
9826 (gnus-summary-mark-article article mark))
9828 (defun gnus-summary-clear-mark-forward (n)
9829 "Clear marks from N articles forward.
9830 If N is negative, clear backward instead.
9831 The difference between N and the number of marks cleared is returned."
9833 (gnus-summary-mark-forward n gnus-unread-mark))
9835 (defun gnus-summary-clear-mark-backward (n)
9836 "Clear marks from N articles backward.
9837 The difference between N and the number of marks cleared is returned."
9839 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9841 (defun gnus-summary-mark-unread-as-read ()
9842 "Intended to be used by `gnus-summary-mark-article-hook'."
9843 (when (memq gnus-current-article gnus-newsgroup-unreads)
9844 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9846 (defun gnus-summary-mark-read-and-unread-as-read ()
9847 "Intended to be used by `gnus-summary-mark-article-hook'."
9848 (let ((mark (gnus-summary-article-mark)))
9849 (when (or (gnus-unread-mark-p mark)
9850 (gnus-read-mark-p mark))
9851 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9853 (defun gnus-summary-mark-unread-as-ticked ()
9854 "Intended to be used by `gnus-summary-mark-article-hook'."
9855 (when (memq gnus-current-article gnus-newsgroup-unreads)
9856 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9858 (defun gnus-summary-mark-region-as-read (point mark all)
9859 "Mark all unread articles between point and mark as read.
9860 If given a prefix, mark all articles between point and mark as read,
9861 even ticked and dormant ones."
9862 (interactive "r\nP")
9871 (memq (setq article (gnus-summary-article-number))
9872 gnus-newsgroup-unreads))
9873 (gnus-summary-mark-article article gnus-del-mark))
9875 (gnus-summary-find-next))))))
9877 (defun gnus-summary-mark-below (score mark)
9878 "Mark articles with score less than SCORE with MARK."
9879 (interactive "P\ncMark: ")
9880 (setq score (if score
9881 (prefix-numeric-value score)
9882 (or gnus-summary-default-score 0)))
9884 (set-buffer gnus-summary-buffer)
9885 (goto-char (point-min))
9888 (and (< (gnus-summary-article-score) score)
9889 (gnus-summary-mark-article nil mark))
9890 (gnus-summary-find-next)))))
9892 (defun gnus-summary-kill-below (&optional score)
9893 "Mark articles with score below SCORE as read."
9895 (gnus-summary-mark-below score gnus-killed-mark))
9897 (defun gnus-summary-clear-above (&optional score)
9898 "Clear all marks from articles with score above SCORE."
9900 (gnus-summary-mark-above score gnus-unread-mark))
9902 (defun gnus-summary-tick-above (&optional score)
9903 "Tick all articles with score above SCORE."
9905 (gnus-summary-mark-above score gnus-ticked-mark))
9907 (defun gnus-summary-mark-above (score mark)
9908 "Mark articles with score over SCORE with MARK."
9909 (interactive "P\ncMark: ")
9910 (setq score (if score
9911 (prefix-numeric-value score)
9912 (or gnus-summary-default-score 0)))
9914 (set-buffer gnus-summary-buffer)
9915 (goto-char (point-min))
9917 (when (> (gnus-summary-article-score) score)
9918 (gnus-summary-mark-article nil mark))
9920 (gnus-summary-find-next)))))
9922 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9923 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9924 (defun gnus-summary-limit-include-expunged (&optional no-error)
9925 "Display all the hidden articles that were expunged for low scores."
9927 (let ((buffer-read-only nil))
9928 (let ((scored gnus-newsgroup-scored)
9931 (unless (gnus-summary-article-header (caar scored))
9932 (and (setq h (gnus-number-to-header (caar scored)))
9933 (< (cdar scored) gnus-summary-expunge-below)
9935 (setq scored (cdr scored)))
9937 (when (not no-error)
9938 (error "No expunged articles hidden"))
9939 (goto-char (point-min))
9940 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9941 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9942 (mapcar (lambda (x) (push (mail-header-number x)
9943 gnus-newsgroup-limit))
9945 (gnus-summary-prepare-unthreaded (nreverse headers))
9946 (goto-char (point-min))
9947 (gnus-summary-position-point)
9950 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9951 "Mark all unread articles in this newsgroup as read.
9952 If prefix argument ALL is non-nil, ticked and dormant articles will
9953 also be marked as read.
9954 If QUIETLY is non-nil, no questions will be asked.
9955 If TO-HERE is non-nil, it should be a point in the buffer. All
9956 articles before (after, if REVERSE is set) this point will be marked as read.
9957 Note that this function will only catch up the unread article
9958 in the current summary buffer limitation.
9959 The number of articles marked as read is returned."
9964 (not gnus-interactive-catchup) ;Without confirmation?
9968 "Mark absolutely all articles as read? "
9969 "Mark all unread articles as read? ")))
9971 (not gnus-newsgroup-adaptive)
9972 (not gnus-newsgroup-auto-expire)
9973 (not gnus-suppress-duplicates)
9974 (or (not gnus-use-cache)
9975 (eq gnus-use-cache 'passive)))
9978 (setq gnus-newsgroup-marked nil
9979 gnus-newsgroup-spam-marked nil
9980 gnus-newsgroup-dormant nil))
9981 (setq gnus-newsgroup-unreads
9982 (gnus-intersection gnus-newsgroup-unreads
9983 gnus-newsgroup-downloadable)))
9984 ;; We actually mark all articles as canceled, which we
9985 ;; have to do when using auto-expiry or adaptive scoring.
9986 (gnus-summary-show-all-threads)
9987 (if (and to-here reverse)
9991 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9992 (gnus-summary-find-next (not all) nil nil t))))
9993 (when (gnus-summary-first-subject (not all) t)
9995 (if to-here (< (point) to-here) t)
9996 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9997 (gnus-summary-find-next (not all) nil nil t)))))
9998 (gnus-set-mode-line 'summary))
10000 (gnus-summary-position-point)))
10002 (defun gnus-summary-catchup-to-here (&optional all)
10003 "Mark all unticked articles before the current one as read.
10004 If ALL is non-nil, also mark ticked and dormant articles as read."
10007 (gnus-save-hidden-threads
10008 (let ((beg (point)))
10009 ;; We check that there are unread articles.
10010 (when (or all (gnus-summary-find-prev))
10011 (gnus-summary-catchup all t beg)))))
10012 (gnus-summary-position-point))
10014 (defun gnus-summary-catchup-from-here (&optional all)
10015 "Mark all unticked articles after the current one as read.
10016 If ALL is non-nil, also mark ticked and dormant articles as read."
10019 (gnus-save-hidden-threads
10020 (let ((beg (point)))
10021 ;; We check that there are unread articles.
10022 (when (or all (gnus-summary-find-next))
10023 (gnus-summary-catchup all t beg nil t)))))
10025 (gnus-summary-position-point))
10026 (defun gnus-summary-catchup-all (&optional quietly)
10027 "Mark all articles in this newsgroup as read.
10028 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10029 instead, which marks only unread articles as read."
10031 (gnus-summary-catchup t quietly))
10033 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10034 "Mark all unread articles in this group as read, then exit.
10035 If prefix argument ALL is non-nil, all articles are marked as read.
10036 If QUIETLY is non-nil, no questions will be asked."
10038 (when (gnus-summary-catchup all quietly nil 'fast)
10039 ;; Select next newsgroup or exit.
10040 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10041 (eq gnus-auto-select-next 'quietly))
10042 (gnus-summary-next-group nil)
10043 (gnus-summary-exit))))
10045 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10046 "Mark all articles in this newsgroup as read, and then exit.
10047 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10048 instead, which marks only unread articles as read."
10050 (gnus-summary-catchup-and-exit t quietly))
10052 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10053 "Mark all articles in this group as read and select the next group.
10054 If given a prefix, mark all articles, unread as well as ticked, as
10058 (gnus-summary-catchup all))
10059 (gnus-summary-next-group))
10065 (defmacro gnus-with-article (article &rest forms)
10066 "Select ARTICLE and perform FORMS in the original article buffer.
10067 Then replace the article with the result."
10069 ;; We don't want the article to be marked as read.
10070 (let (gnus-mark-article-hook)
10071 (gnus-summary-select-article t t nil ,article))
10072 (set-buffer gnus-original-article-buffer)
10074 (if (not (gnus-check-backend-function
10075 'request-replace-article (car gnus-article-current)))
10076 (gnus-message 5 "Read-only group; not replacing")
10077 (unless (gnus-request-replace-article
10078 ,article (car gnus-article-current)
10079 (current-buffer) t)
10080 (error "Couldn't replace article")))
10081 ;; The cache and backlog have to be flushed somewhat.
10082 (when gnus-keep-backlog
10083 (gnus-backlog-remove-article
10084 (car gnus-article-current) (cdr gnus-article-current)))
10085 (when gnus-use-cache
10086 (gnus-cache-update-article
10087 (car gnus-article-current) (cdr gnus-article-current)))))
10089 (put 'gnus-with-article 'lisp-indent-function 1)
10090 (put 'gnus-with-article 'edebug-form-spec '(form body))
10092 ;; Thread-based commands.
10094 (defun gnus-summary-articles-in-thread (&optional article)
10095 "Return a list of all articles in the current thread.
10096 If ARTICLE is non-nil, return all articles in the thread that starts
10097 with that article."
10098 (let* ((article (or article (gnus-summary-article-number)))
10099 (data (gnus-data-find-list article))
10100 (top-level (gnus-data-level (car data)))
10102 (cond ((null gnus-thread-operation-ignore-subject)
10103 (gnus-simplify-subject-re
10104 (mail-header-subject (gnus-data-header (car data)))))
10105 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10106 (gnus-simplify-subject-fuzzy
10107 (mail-header-subject (gnus-data-header (car data)))))
10109 (end-point (save-excursion
10110 (if (gnus-summary-go-to-next-thread)
10111 (point) (point-max))))
10114 (< (gnus-data-pos (car data)) end-point))
10115 (when (or (not top-subject)
10116 (string= top-subject
10117 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10118 (gnus-simplify-subject-fuzzy
10119 (mail-header-subject
10120 (gnus-data-header (car data))))
10121 (gnus-simplify-subject-re
10122 (mail-header-subject
10123 (gnus-data-header (car data)))))))
10124 (push (gnus-data-number (car data)) articles))
10125 (unless (and (setq data (cdr data))
10126 (> (gnus-data-level (car data)) top-level))
10128 ;; Return the list of articles.
10129 (nreverse articles)))
10131 (defun gnus-summary-rethread-current ()
10132 "Rethread the thread the current article is part of."
10134 (let* ((gnus-show-threads t)
10135 (article (gnus-summary-article-number))
10136 (id (mail-header-id (gnus-summary-article-header)))
10137 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10139 (error "No article on the current line"))
10140 (gnus-rebuild-thread id)
10141 (gnus-summary-goto-subject article)))
10143 (defun gnus-summary-reparent-thread ()
10144 "Make the current article child of the marked (or previous) article.
10146 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10147 is non-nil or the Subject: of both articles are the same."
10149 (unless (not (gnus-group-read-only-p))
10150 (error "The current newsgroup does not support article editing"))
10151 (unless (<= (length gnus-newsgroup-processable) 1)
10152 (error "No more than one article may be marked"))
10153 (save-window-excursion
10154 (let ((gnus-article-buffer " *reparent*")
10155 (current-article (gnus-summary-article-number))
10156 ;; First grab the marked article, otherwise one line up.
10157 (parent-article (if (not (null gnus-newsgroup-processable))
10158 (car gnus-newsgroup-processable)
10160 (if (eq (forward-line -1) 0)
10161 (gnus-summary-article-number)
10162 (error "Beginning of summary buffer"))))))
10163 (unless (not (eq current-article parent-article))
10164 (error "An article may not be self-referential"))
10165 (let ((message-id (mail-header-id
10166 (gnus-summary-article-header parent-article))))
10167 (unless (and message-id (not (equal message-id "")))
10168 (error "No message-id in desired parent"))
10169 (gnus-with-article current-article
10171 (goto-char (point-min))
10172 (message-narrow-to-head)
10173 (if (re-search-forward "^References: " nil t)
10175 (re-search-forward "^[^ \t]" nil t)
10178 (insert " " message-id))
10179 (insert "References: " message-id "\n"))))
10180 (set-buffer gnus-summary-buffer)
10181 (gnus-summary-unmark-all-processable)
10182 (gnus-summary-update-article current-article)
10183 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10184 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10185 (gnus-summary-rethread-current)
10186 (gnus-message 3 "Article %d is now the child of article %d"
10187 current-article parent-article)))))
10189 (defun gnus-summary-toggle-threads (&optional arg)
10190 "Toggle showing conversation threads.
10191 If ARG is positive number, turn showing conversation threads on."
10193 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10194 (setq gnus-show-threads
10195 (if (null arg) (not gnus-show-threads)
10196 (> (prefix-numeric-value arg) 0)))
10197 (gnus-summary-prepare)
10198 (gnus-summary-goto-subject current)
10199 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10200 (gnus-summary-position-point)))
10202 (defun gnus-summary-show-all-threads ()
10203 "Show all threads."
10206 (let ((buffer-read-only nil))
10207 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10208 (gnus-summary-position-point))
10210 (defun gnus-summary-show-thread ()
10211 "Show thread subtrees.
10212 Returns nil if no thread was there to be shown."
10214 (let ((buffer-read-only nil)
10216 ;; first goto end then to beg, to have point at beg after let
10217 (end (progn (end-of-line) (point)))
10218 (beg (progn (beginning-of-line) (point))))
10220 ;; Any hidden lines here?
10221 (search-forward "\r" end t)
10222 (subst-char-in-region beg end ?\^M ?\n t)
10224 (gnus-summary-position-point))))
10226 (defun gnus-summary-maybe-hide-threads ()
10227 "If requested, hide the threads that should be hidden."
10228 (when (and gnus-show-threads
10229 gnus-thread-hide-subtree)
10230 (gnus-summary-hide-all-threads
10231 (if (or (consp gnus-thread-hide-subtree)
10232 (gnus-functionp gnus-thread-hide-subtree))
10233 (gnus-make-predicate gnus-thread-hide-subtree)
10236 ;;; Hiding predicates.
10238 (defun gnus-article-unread-p (header)
10239 (memq (mail-header-number header) gnus-newsgroup-unreads))
10241 (defun gnus-article-unseen-p (header)
10242 (memq (mail-header-number header) gnus-newsgroup-unseen))
10244 (defun gnus-map-articles (predicate articles)
10245 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10246 (apply 'gnus-or (mapcar predicate
10247 (mapcar 'gnus-summary-article-header articles))))
10249 (defun gnus-summary-hide-all-threads (&optional predicate)
10250 "Hide all thread subtrees.
10251 If PREDICATE is supplied, threads that satisfy this predicate
10252 will not be hidden."
10255 (goto-char (point-min))
10258 (when (or (not predicate)
10260 predicate (gnus-summary-article-children)))
10261 (gnus-summary-hide-thread))
10262 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10263 (gnus-summary-position-point))
10265 (defun gnus-summary-hide-thread ()
10266 "Hide thread subtrees.
10267 If PREDICATE is supplied, threads that satisfy this predicate
10268 will not be hidden.
10269 Returns nil if no threads were there to be hidden."
10271 (let ((buffer-read-only nil)
10273 (article (gnus-summary-article-number)))
10275 ;; Go forward until either the buffer ends or the subthread
10277 (when (and (not (eobp))
10278 (or (zerop (gnus-summary-next-thread 1 t))
10279 (goto-char (point-max))))
10281 (if (and (> (point) start)
10282 (search-backward "\n" start t))
10284 (subst-char-in-region start (point) ?\n ?\^M)
10285 (gnus-summary-goto-subject article))
10289 (defun gnus-summary-go-to-next-thread (&optional previous)
10290 "Go to the same level (or less) next thread.
10291 If PREVIOUS is non-nil, go to previous thread instead.
10292 Return the article number moved to, or nil if moving was impossible."
10293 (let ((level (gnus-summary-thread-level))
10294 (way (if previous -1 1))
10297 (while (and (not (eobp))
10298 (< level (gnus-summary-thread-level)))
10299 (forward-line way))
10306 (gnus-summary-article-number)
10307 (goto-char beg)))))
10309 (defun gnus-summary-next-thread (n &optional silent)
10310 "Go to the same level next N'th thread.
10311 If N is negative, search backward instead.
10312 Returns the difference between N and the number of skips actually
10315 If SILENT, don't output messages."
10317 (let ((backward (< n 0))
10319 (while (and (> n 0)
10320 (gnus-summary-go-to-next-thread backward))
10323 (gnus-summary-position-point))
10324 (when (and (not silent) (/= 0 n))
10325 (gnus-message 7 "No more threads"))
10328 (defun gnus-summary-prev-thread (n)
10329 "Go to the same level previous N'th thread.
10330 Returns the difference between N and the number of skips actually
10333 (gnus-summary-next-thread (- n)))
10335 (defun gnus-summary-go-down-thread ()
10336 "Go down one level in the current thread."
10337 (let ((children (gnus-summary-article-children)))
10339 (gnus-summary-goto-subject (car children)))))
10341 (defun gnus-summary-go-up-thread ()
10342 "Go up one level in the current thread."
10343 (let ((parent (gnus-summary-article-parent)))
10345 (gnus-summary-goto-subject parent))))
10347 (defun gnus-summary-down-thread (n)
10348 "Go down thread N steps.
10349 If N is negative, go up instead.
10350 Returns the difference between N and how many steps down that were
10355 (while (and (> n 0)
10356 (if up (gnus-summary-go-up-thread)
10357 (gnus-summary-go-down-thread)))
10359 (gnus-summary-position-point)
10361 (gnus-message 7 "Can't go further"))
10364 (defun gnus-summary-up-thread (n)
10365 "Go up thread N steps.
10366 If N is negative, go down instead.
10367 Returns the difference between N and how many steps down that were
10370 (gnus-summary-down-thread (- n)))
10372 (defun gnus-summary-top-thread ()
10373 "Go to the top of the thread."
10375 (while (gnus-summary-go-up-thread))
10376 (gnus-summary-article-number))
10378 (defun gnus-summary-kill-thread (&optional unmark)
10379 "Mark articles under current thread as read.
10380 If the prefix argument is positive, remove any kinds of marks.
10381 If the prefix argument is negative, tick articles instead."
10384 (setq unmark (prefix-numeric-value unmark)))
10385 (let ((articles (gnus-summary-articles-in-thread)))
10387 ;; Expand the thread.
10388 (gnus-summary-show-thread)
10389 ;; Mark all the articles.
10391 (gnus-summary-goto-subject (car articles))
10392 (cond ((null unmark)
10393 (gnus-summary-mark-article-as-read gnus-killed-mark))
10395 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10397 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10398 (setq articles (cdr articles))))
10399 ;; Hide killed subtrees.
10401 gnus-thread-hide-killed
10402 (gnus-summary-hide-thread))
10403 ;; If marked as read, go to next unread subject.
10404 (when (null unmark)
10405 ;; Go to next unread subject.
10406 (gnus-summary-next-subject 1 t)))
10407 (gnus-set-mode-line 'summary))
10409 ;; Summary sorting commands
10411 (defun gnus-summary-sort-by-number (&optional reverse)
10412 "Sort the summary buffer by article number.
10413 Argument REVERSE means reverse order."
10415 (gnus-summary-sort 'number reverse))
10417 (defun gnus-summary-sort-by-random (&optional reverse)
10418 "Randomize the order in the summary buffer.
10419 Argument REVERSE means to randomize in reverse order."
10421 (gnus-summary-sort 'random reverse))
10423 (defun gnus-summary-sort-by-author (&optional reverse)
10424 "Sort the summary buffer by author name alphabetically.
10425 If `case-fold-search' is non-nil, case of letters is ignored.
10426 Argument REVERSE means reverse order."
10428 (gnus-summary-sort 'author reverse))
10430 (defun gnus-summary-sort-by-subject (&optional reverse)
10431 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10432 If `case-fold-search' is non-nil, case of letters is ignored.
10433 Argument REVERSE means reverse order."
10435 (gnus-summary-sort 'subject reverse))
10437 (defun gnus-summary-sort-by-date (&optional reverse)
10438 "Sort the summary buffer by date.
10439 Argument REVERSE means reverse order."
10441 (gnus-summary-sort 'date reverse))
10443 (defun gnus-summary-sort-by-score (&optional reverse)
10444 "Sort the summary buffer by score.
10445 Argument REVERSE means reverse order."
10447 (gnus-summary-sort 'score reverse))
10449 (defun gnus-summary-sort-by-lines (&optional reverse)
10450 "Sort the summary buffer by the number of lines.
10451 Argument REVERSE means reverse order."
10453 (gnus-summary-sort 'lines reverse))
10455 (defun gnus-summary-sort-by-chars (&optional reverse)
10456 "Sort the summary buffer by article length.
10457 Argument REVERSE means reverse order."
10459 (gnus-summary-sort 'chars reverse))
10461 (defun gnus-summary-sort-by-original (&optional reverse)
10462 "Sort the summary buffer using the default sorting method.
10463 Argument REVERSE means reverse order."
10465 (let* ((buffer-read-only)
10466 (gnus-summary-prepare-hook nil))
10467 ;; We do the sorting by regenerating the threads.
10468 (gnus-summary-prepare)
10469 ;; Hide subthreads if needed.
10470 (gnus-summary-maybe-hide-threads)))
10472 (defun gnus-summary-sort (predicate reverse)
10473 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10474 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10475 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10476 (gnus-thread-sort-functions
10481 (gnus-sort-gathered-threads-function
10482 gnus-thread-sort-functions)
10483 (gnus-article-sort-functions
10487 (,article t2 t1))))
10489 (gnus-summary-prepare-hook nil))
10490 ;; We do the sorting by regenerating the threads.
10491 (gnus-summary-prepare)
10492 ;; Hide subthreads if needed.
10493 (gnus-summary-maybe-hide-threads)))
10495 ;; Summary saving commands.
10497 (defun gnus-summary-save-article (&optional n not-saved)
10498 "Save the current article using the default saver function.
10499 If N is a positive number, save the N next articles.
10500 If N is a negative number, save the N previous articles.
10501 If N is nil and any articles have been marked with the process mark,
10502 save those articles instead.
10503 The variable `gnus-default-article-saver' specifies the saver function."
10505 (let* ((articles (gnus-summary-work-articles n))
10506 (save-buffer (save-excursion
10507 (nnheader-set-temp-buffer " *Gnus Save*")))
10508 (num (length articles))
10510 (dolist (article articles)
10511 (setq header (gnus-summary-article-header article))
10512 (if (not (vectorp header))
10513 ;; This is a pseudo-article.
10514 (if (assq 'name header)
10515 (gnus-copy-file (cdr (assq 'name header)))
10516 (gnus-message 1 "Article %d is unsaveable" article))
10517 ;; This is a real article.
10518 (save-window-excursion
10519 (let ((gnus-display-mime-function nil)
10520 (gnus-article-prepare-hook nil))
10521 (gnus-summary-select-article t nil nil article)))
10523 (set-buffer save-buffer)
10525 (insert-buffer-substring gnus-original-article-buffer))
10526 (setq file (gnus-article-save save-buffer file num))
10527 (gnus-summary-remove-process-mark article)
10529 (gnus-summary-set-saved-mark article))))
10530 (gnus-kill-buffer save-buffer)
10531 (gnus-summary-position-point)
10532 (gnus-set-mode-line 'summary)
10535 (defun gnus-summary-pipe-output (&optional arg headers)
10536 "Pipe the current article to a subprocess.
10537 If N is a positive number, pipe the N next articles.
10538 If N is a negative number, pipe the N previous articles.
10539 If N is nil and any articles have been marked with the process mark,
10540 pipe those articles instead.
10541 If HEADERS (the symbolic prefix), include the headers, too."
10542 (interactive (gnus-interactive "P\ny"))
10543 (require 'gnus-art)
10544 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10545 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10546 (gnus-summary-save-article arg t))
10547 (let ((buffer (get-buffer "*Shell Command Output*")))
10549 (not (zerop (buffer-size buffer))))
10550 (gnus-configure-windows 'pipe))))
10552 (defun gnus-summary-save-article-mail (&optional arg)
10553 "Append the current article to an mail file.
10554 If N is a positive number, save the N next articles.
10555 If N is a negative number, save the N previous articles.
10556 If N is nil and any articles have been marked with the process mark,
10557 save those articles instead."
10559 (require 'gnus-art)
10560 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10561 (gnus-summary-save-article arg)))
10563 (defun gnus-summary-save-article-rmail (&optional arg)
10564 "Append the current article to an rmail file.
10565 If N is a positive number, save the N next articles.
10566 If N is a negative number, save the N previous articles.
10567 If N is nil and any articles have been marked with the process mark,
10568 save those articles instead."
10570 (require 'gnus-art)
10571 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10572 (gnus-summary-save-article arg)))
10574 (defun gnus-summary-save-article-file (&optional arg)
10575 "Append the current article to a file.
10576 If N is a positive number, save the N next articles.
10577 If N is a negative number, save the N previous articles.
10578 If N is nil and any articles have been marked with the process mark,
10579 save those articles instead."
10581 (require 'gnus-art)
10582 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10583 (gnus-summary-save-article arg)))
10585 (defun gnus-summary-write-article-file (&optional arg)
10586 "Write the current article to a file, deleting the previous file.
10587 If N is a positive number, save the N next articles.
10588 If N is a negative number, save the N previous articles.
10589 If N is nil and any articles have been marked with the process mark,
10590 save those articles instead."
10592 (require 'gnus-art)
10593 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10594 (gnus-summary-save-article arg)))
10596 (defun gnus-summary-save-article-body-file (&optional arg)
10597 "Append the current article body to a file.
10598 If N is a positive number, save the N next articles.
10599 If N is a negative number, save the N previous articles.
10600 If N is nil and any articles have been marked with the process mark,
10601 save those articles instead."
10603 (require 'gnus-art)
10604 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10605 (gnus-summary-save-article arg)))
10607 (defun gnus-summary-muttprint (&optional arg)
10608 "Print the current article using Muttprint.
10609 If N is a positive number, save the N next articles.
10610 If N is a negative number, save the N previous articles.
10611 If N is nil and any articles have been marked with the process mark,
10612 save those articles instead."
10614 (require 'gnus-art)
10615 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10616 (gnus-summary-save-article arg t)))
10618 (defun gnus-summary-pipe-message (program)
10619 "Pipe the current article through PROGRAM."
10620 (interactive "sProgram: ")
10621 (gnus-summary-select-article)
10622 (let ((mail-header-separator ""))
10623 (gnus-eval-in-buffer-window gnus-article-buffer
10626 (let ((start (window-start))
10628 (message-pipe-buffer-body program)
10629 (set-window-start (get-buffer-window (current-buffer)) start))))))
10631 (defun gnus-get-split-value (methods)
10632 "Return a value based on the split METHODS."
10633 (let (split-name method result match)
10636 (set-buffer gnus-original-article-buffer)
10638 (nnheader-narrow-to-headers)
10639 (while (and methods (not split-name))
10640 (goto-char (point-min))
10641 (setq method (pop methods))
10642 (setq match (car method))
10645 ;; Regular expression.
10647 (re-search-forward match nil t)))
10648 ((gnus-functionp match)
10652 (setq result (funcall match gnus-newsgroup-name))))
10657 (setq result (eval match)))))
10658 (setq split-name (cdr method))
10659 (cond ((stringp result)
10660 (push (expand-file-name
10661 result gnus-article-save-directory)
10664 (setq split-name (append result split-name)))))))))
10665 (nreverse split-name)))
10667 (defun gnus-valid-move-group-p (group)
10668 (and (boundp group)
10669 (symbol-name group)
10670 (symbol-value group)
10671 (gnus-get-function (gnus-find-method-for-group
10672 (symbol-name group)) 'request-accept-article t)))
10674 (defun gnus-read-move-group-name (prompt default articles prefix)
10675 "Read a group name."
10676 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10677 (minibuffer-confirm-incomplete nil) ; XEmacs
10679 (format "%s %s to:"
10681 (if (> (length articles) 1)
10682 (format "these %d articles" (length articles))
10687 (gnus-completing-read-with-default
10690 'gnus-valid-move-group-p
10692 'gnus-group-history))
10693 ((= 1 (length split-name))
10694 (gnus-completing-read-with-default
10695 (car split-name) prom
10697 'gnus-valid-move-group-p
10699 'gnus-group-history))
10701 (gnus-completing-read-with-default
10703 (mapcar (lambda (el) (list el))
10704 (nreverse split-name))
10706 'gnus-group-history))))
10707 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10709 (if (or (string= to-newsgroup "")
10710 (string= to-newsgroup prefix))
10711 (setq to-newsgroup default))
10712 (unless to-newsgroup
10713 (error "No group name entered"))
10714 (or (gnus-active to-newsgroup)
10715 (gnus-activate-group to-newsgroup nil nil to-method)
10716 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10718 (or (and (gnus-request-create-group to-newsgroup to-method)
10719 (gnus-activate-group
10720 to-newsgroup nil nil to-method)
10721 (gnus-subscribe-group to-newsgroup))
10722 (error "Couldn't create group %s" to-newsgroup)))
10723 (error "No such group: %s" to-newsgroup)))
10726 (defun gnus-summary-save-parts (type dir n &optional reverse)
10727 "Save parts matching TYPE to DIR.
10728 If REVERSE, save parts that do not match TYPE."
10730 (list (read-string "Save parts of type: "
10731 (or (car gnus-summary-save-parts-type-history)
10732 gnus-summary-save-parts-default-mime)
10733 'gnus-summary-save-parts-type-history)
10734 (setq gnus-summary-save-parts-last-directory
10735 (read-file-name "Save to directory: "
10736 gnus-summary-save-parts-last-directory
10738 current-prefix-arg))
10739 (gnus-summary-iterate n
10740 (let ((gnus-display-mime-function nil)
10741 (gnus-inhibit-treatment t))
10742 (gnus-summary-select-article))
10744 (set-buffer gnus-article-buffer)
10745 (let ((handles (or gnus-article-mime-handles
10746 (mm-dissect-buffer nil gnus-article-loose-mime)
10747 (and gnus-article-emulate-mime
10748 (mm-uu-dissect)))))
10750 (gnus-summary-save-parts-1 type dir handles reverse)
10751 (unless gnus-article-mime-handles ;; Don't destroy this case.
10752 (mm-destroy-parts handles)))))))
10754 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10755 (if (stringp (car handle))
10756 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10759 (not (string-match type (mm-handle-media-type handle)))
10760 (string-match type (mm-handle-media-type handle)))
10761 (let ((file (expand-file-name
10762 (file-name-nondirectory
10764 (mail-content-type-get
10765 (mm-handle-disposition handle) 'filename)
10766 (concat gnus-newsgroup-name
10767 "." (number-to-string
10768 (cdr gnus-article-current)))))
10770 (unless (file-exists-p file)
10771 (mm-save-part-to-file handle file))))))
10773 ;; Summary extract commands
10775 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10776 (let ((buffer-read-only nil)
10777 (article (gnus-summary-article-number))
10779 (unless (gnus-summary-goto-subject article)
10780 (error "No such article: %d" article))
10781 (gnus-summary-position-point)
10782 ;; If all commands are to be bunched up on one line, we collect
10784 (unless gnus-view-pseudos-separately
10785 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10788 (setq action (cdr (assq 'action (car ps))))
10789 (setq files (list (cdr (assq 'name (car ps)))))
10790 (while (and ps (cdr ps)
10791 (string= (or action "1")
10792 (or (cdr (assq 'action (cadr ps))) "2")))
10793 (push (cdr (assq 'name (cadr ps))) files)
10794 (setcdr ps (cddr ps)))
10796 (when (not (string-match "%s" action))
10799 (when (assq 'execute (car ps))
10800 (setcdr (assq 'execute (car ps))
10801 (funcall (if (string-match "%s" action)
10810 (setq ps (cdr ps)))))
10811 (if (and gnus-view-pseudos (not not-view))
10813 (when (assq 'execute (car pslist))
10814 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10815 (eq gnus-view-pseudos 'not-confirm)))
10816 (setq pslist (cdr pslist)))
10819 (setq after-article (or (cdr (assq 'article (car pslist)))
10820 (gnus-summary-article-number)))
10821 (gnus-summary-goto-subject after-article)
10824 (insert " " (file-name-nondirectory
10825 (cdr (assq 'name (car pslist))))
10826 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10828 (forward-line -1) ; back to `b'
10829 (gnus-add-text-properties
10830 b (1- e) (list 'gnus-number gnus-reffed-article-number
10831 gnus-mouse-face-prop gnus-mouse-face))
10833 after-article gnus-reffed-article-number
10834 gnus-unread-mark b (car pslist) 0 (- e b))
10835 (setq gnus-newsgroup-unreads
10836 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10837 gnus-reffed-article-number))
10838 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10839 (setq pslist (cdr pslist)))))))
10841 (defun gnus-pseudos< (p1 p2)
10842 (let ((c1 (cdr (assq 'action p1)))
10843 (c2 (cdr (assq 'action p2))))
10844 (and c1 c2 (string< c1 c2))))
10846 (defun gnus-request-pseudo-article (props)
10847 (cond ((assq 'execute props)
10848 (gnus-execute-command (cdr (assq 'execute props)))))
10849 (let ((gnus-current-article (gnus-summary-article-number)))
10850 (gnus-run-hooks 'gnus-mark-article-hook)))
10852 (defun gnus-execute-command (command &optional automatic)
10854 (gnus-article-setup-buffer)
10855 (set-buffer gnus-article-buffer)
10856 (setq buffer-read-only nil)
10857 (let ((command (if automatic command
10858 (read-string "Command: " (cons command 0)))))
10860 (insert "$ " command "\n\n")
10861 (if gnus-view-pseudo-asynchronously
10862 (start-process "gnus-execute" (current-buffer) shell-file-name
10863 shell-command-switch command)
10864 (call-process shell-file-name nil t nil
10865 shell-command-switch command)))))
10867 ;; Summary kill commands.
10869 (defun gnus-summary-edit-global-kill (article)
10870 "Edit the \"global\" kill file."
10871 (interactive (list (gnus-summary-article-number)))
10872 (gnus-group-edit-global-kill article))
10874 (defun gnus-summary-edit-local-kill ()
10875 "Edit a local kill file applied to the current newsgroup."
10877 (setq gnus-current-headers (gnus-summary-article-header))
10878 (gnus-group-edit-local-kill
10879 (gnus-summary-article-number) gnus-newsgroup-name))
10881 ;;; Header reading.
10883 (defun gnus-read-header (id &optional header)
10884 "Read the headers of article ID and enter them into the Gnus system."
10885 (let ((group gnus-newsgroup-name)
10886 (gnus-override-method
10888 gnus-override-method
10889 (and (gnus-news-group-p gnus-newsgroup-name)
10890 (car (gnus-refer-article-methods)))))
10892 ;; First we check to see whether the header in question is already
10895 ;; This is a Message-ID.
10896 (setq header (or header (gnus-id-to-header id)))
10897 ;; This is an article number.
10898 (setq header (or header (gnus-summary-article-header id))))
10900 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10901 ;; We have found the header.
10903 ;; If this is a sparse article, we have to nix out its
10904 ;; previous entry in the thread hashtb.
10906 (gnus-summary-article-sparse-p (mail-header-number header)))
10907 (let* ((parent (gnus-parent-id (mail-header-references header)))
10908 (thread (and parent (gnus-id-to-thread parent))))
10910 (delq (assq header thread) thread))))
10911 ;; We have to really fetch the header to this article.
10913 (set-buffer nntp-server-buffer)
10914 (when (setq where (gnus-request-head id group))
10915 (nnheader-fold-continuation-lines)
10916 (goto-char (point-max))
10918 (goto-char (point-min))
10922 ((cdr where) (cdr where))
10923 (header (mail-header-number header))
10924 (t gnus-reffed-article-number))
10926 (insert " Article retrieved.\n"))
10927 (if (or (not where)
10928 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10929 () ; Malformed head.
10930 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10931 (when (and (stringp id)
10932 (not (string= (gnus-group-real-name group)
10934 ;; If we fetched by Message-ID and the article came
10935 ;; from a different group, we fudge some bogus article
10936 ;; numbers for this article.
10937 (mail-header-set-number header gnus-reffed-article-number))
10939 (set-buffer gnus-summary-buffer)
10940 (decf gnus-reffed-article-number)
10941 (gnus-remove-header (mail-header-number header))
10942 (push header gnus-newsgroup-headers)
10943 (setq gnus-current-headers header)
10944 (push (mail-header-number header) gnus-newsgroup-limit)))
10947 (defun gnus-remove-header (number)
10948 "Remove header NUMBER from `gnus-newsgroup-headers'."
10949 (if (and gnus-newsgroup-headers
10950 (= number (mail-header-number (car gnus-newsgroup-headers))))
10951 (pop gnus-newsgroup-headers)
10952 (let ((headers gnus-newsgroup-headers))
10953 (while (and (cdr headers)
10954 (not (= number (mail-header-number (cadr headers)))))
10956 (when (cdr headers)
10957 (setcdr headers (cddr headers))))))
10960 ;;; summary highlights
10963 (defun gnus-highlight-selected-summary ()
10964 "Highlight selected article in summary buffer."
10965 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10966 (when gnus-summary-selected-face
10968 (let* ((beg (progn (beginning-of-line) (point)))
10969 (end (progn (end-of-line) (point)))
10970 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10971 (from (if (get-text-property beg gnus-mouse-face-prop)
10973 (or (next-single-property-change
10974 beg gnus-mouse-face-prop nil end)
10979 (or (next-single-property-change
10980 from gnus-mouse-face-prop nil end)
10982 ;; If no mouse-face prop on line we will have to = from = end,
10983 ;; so we highlight the entire line instead.
10984 (when (= (+ to 2) from)
10987 (if gnus-newsgroup-selected-overlay
10988 ;; Move old overlay.
10990 gnus-newsgroup-selected-overlay from to (current-buffer))
10991 ;; Create new overlay.
10993 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10994 'face gnus-summary-selected-face))))))
10996 (defvar gnus-summary-highlight-line-cached nil)
10997 (defvar gnus-summary-highlight-line-trigger nil)
10999 (defun gnus-summary-highlight-line-0 ()
11000 (if (and (eq gnus-summary-highlight-line-trigger
11001 gnus-summary-highlight)
11002 gnus-summary-highlight-line-cached)
11003 gnus-summary-highlight-line-cached
11004 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11005 gnus-summary-highlight-line-cached
11006 (let* ((cond (list 'cond))
11008 (list gnus-summary-highlight))
11010 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11013 (gnus-byte-compile (list 'lambda nil cond))))))
11015 (defun gnus-summary-highlight-line ()
11016 "Highlight current line according to `gnus-summary-highlight'."
11017 (let* ((beg (gnus-point-at-bol))
11018 (article (or (gnus-summary-article-number) gnus-current-article))
11019 (score (or (cdr (assq article
11020 gnus-newsgroup-scored))
11021 gnus-summary-default-score 0))
11022 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11023 (inhibit-read-only t)
11024 (default gnus-summary-default-score)
11025 (default-high gnus-summary-default-high-score)
11026 (default-low gnus-summary-default-low-score)
11027 (uncached (memq article gnus-newsgroup-undownloaded))
11028 (downloaded (not uncached)))
11029 (let ((face (funcall (gnus-summary-highlight-line-0))))
11030 (unless (eq face (get-text-property beg 'face))
11031 (gnus-put-text-property-excluding-characters-with-faces
11032 beg (gnus-point-at-eol) 'face
11033 (setq face (if (boundp face) (symbol-value face) face)))
11034 (when gnus-summary-highlight-line-function
11035 (funcall gnus-summary-highlight-line-function article face))))))
11037 (defun gnus-update-read-articles (group unread &optional compute)
11038 "Update the list of read articles in GROUP.
11039 UNREAD is a sorted list."
11040 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11041 (entry (gnus-gethash group gnus-newsrc-hashtb))
11042 (info (nth 2 entry))
11045 (if (or (not info) (not active))
11046 ;; There is no info on this group if it was, in fact,
11047 ;; killed. Gnus stores no information on killed groups, so
11048 ;; there's nothing to be done.
11049 ;; One could store the information somewhere temporarily,
11050 ;; perhaps... Hmmm...
11052 ;; Remove any negative articles numbers.
11053 (while (and unread (< (car unread) 0))
11054 (setq unread (cdr unread)))
11055 ;; Remove any expired article numbers
11056 (while (and unread (< (car unread) (car active)))
11057 (setq unread (cdr unread)))
11058 ;; Compute the ranges of read articles by looking at the list of
11059 ;; unread articles.
11061 (when (/= (car unread) prev)
11062 (push (if (= prev (1- (car unread))) prev
11063 (cons prev (1- (car unread))))
11065 (setq prev (1+ (car unread)))
11066 (setq unread (cdr unread)))
11067 (when (<= prev (cdr active))
11068 (push (cons prev (cdr active)) read))
11069 (setq read (if (> (length read) 1) (nreverse read) read))
11074 ;; Propagate the read marks to the backend.
11075 (when (gnus-check-backend-function 'request-set-mark group)
11076 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11077 (add (gnus-remove-from-range read (gnus-info-read info))))
11079 (unless (gnus-check-group group)
11080 (error "Can't open server for %s" group))
11081 (gnus-request-set-mark
11082 group (delq nil (list (if add (list add 'add '(read)))
11083 (if del (list del 'del '(read))))))
11085 `(gnus-request-set-mark
11088 (if del (list del 'add '(read)))
11089 (if add (list add 'del '(read))))))))))
11090 (set-buffer gnus-group-buffer)
11091 (gnus-undo-register
11093 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11094 (gnus-info-set-read ',info ',(gnus-info-read info))
11095 (gnus-get-unread-articles-in-group ',info
11096 (gnus-active ,group))
11097 (gnus-group-update-group ,group t)
11099 ;; Enter this list into the group info.
11100 (gnus-info-set-read info read)
11101 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11102 (gnus-get-unread-articles-in-group info (gnus-active group))
11105 (defun gnus-offer-save-summaries ()
11106 "Offer to save all active summary buffers."
11108 ;; Go through all buffers and find all summaries.
11109 (dolist (buffer (buffer-list))
11110 (when (and (setq buffer (buffer-name buffer))
11111 (string-match "Summary" buffer)
11113 (set-buffer buffer)
11114 ;; We check that this is, indeed, a summary buffer.
11115 (and (eq major-mode 'gnus-summary-mode)
11116 ;; Also make sure this isn't bogus.
11117 gnus-newsgroup-prepared
11118 ;; Also make sure that this isn't a
11119 ;; dead summary buffer.
11120 (not gnus-dead-summary-mode))))
11121 (push buffer buffers)))
11122 ;; Go through all these summary buffers and offer to save them.
11126 "Update summary buffer %s? "
11128 (switch-to-buffer buf)
11129 (gnus-summary-exit))
11132 (defun gnus-summary-setup-default-charset ()
11133 "Setup newsgroup default charset."
11134 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11135 (setq gnus-newsgroup-charset nil)
11136 (let* ((ignored-charsets
11137 (or gnus-newsgroup-ephemeral-ignored-charsets
11139 (and gnus-newsgroup-name
11140 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11141 gnus-newsgroup-ignored-charsets))))
11142 (setq gnus-newsgroup-charset
11143 (or gnus-newsgroup-ephemeral-charset
11144 (and gnus-newsgroup-name
11145 (gnus-parameter-charset gnus-newsgroup-name))
11146 gnus-default-charset))
11147 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11148 ignored-charsets))))
11154 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11155 "Display the current article buffer fully MIME-buttonized.
11156 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11157 treated as multipart/mixed."
11159 (require 'gnus-art)
11160 (let ((gnus-unbuttonized-mime-types nil)
11161 (gnus-mime-display-multipart-as-mixed show-all-parts))
11162 (gnus-summary-show-article)))
11164 (defun gnus-summary-repair-multipart (article)
11165 "Add a Content-Type header to a multipart article without one."
11166 (interactive (list (gnus-summary-article-number)))
11167 (gnus-with-article article
11168 (message-narrow-to-head)
11169 (message-remove-header "Mime-Version")
11170 (goto-char (point-max))
11171 (insert "Mime-Version: 1.0\n")
11173 (when (search-forward "\n--" nil t)
11174 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11175 (message-narrow-to-head)
11176 (message-remove-header "Content-Type")
11177 (goto-char (point-max))
11178 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11181 (let (gnus-mark-article-hook)
11182 (gnus-summary-select-article t t nil article)))
11184 (defun gnus-summary-toggle-display-buttonized ()
11185 "Toggle the buttonizing of the article buffer."
11187 (require 'gnus-art)
11188 (if (setq gnus-inhibit-mime-unbuttonizing
11189 (not gnus-inhibit-mime-unbuttonizing))
11190 (let ((gnus-unbuttonized-mime-types nil))
11191 (gnus-summary-show-article))
11192 (gnus-summary-show-article)))
11195 ;;; Generic summary marking commands
11198 (defvar gnus-summary-marking-alist
11199 '((read gnus-del-mark "d")
11200 (unread gnus-unread-mark "u")
11201 (ticked gnus-ticked-mark "!")
11202 (dormant gnus-dormant-mark "?")
11203 (expirable gnus-expirable-mark "e"))
11204 "An alist of names/marks/keystrokes.")
11206 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11207 (defvar gnus-summary-mark-map)
11209 (defun gnus-summary-make-all-marking-commands ()
11210 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11211 (dolist (elem gnus-summary-marking-alist)
11212 (apply 'gnus-summary-make-marking-command elem)))
11214 (defun gnus-summary-make-marking-command (name mark keystroke)
11215 (let ((map (make-sparse-keymap)))
11216 (define-key gnus-summary-generic-mark-map keystroke map)
11217 (dolist (lway `((next "next" next nil "n")
11218 (next-unread "next unread" next t "N")
11219 (prev "previous" prev nil "p")
11220 (prev-unread "previous unread" prev t "P")
11221 (nomove "" nil nil ,keystroke)))
11222 (let ((func (gnus-summary-make-marking-command-1
11223 mark (car lway) lway name)))
11224 (setq func (eval func))
11225 (define-key map (nth 4 lway) func)))))
11227 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11229 (format "gnus-summary-put-mark-as-%s%s"
11230 name (if (eq way 'nomove)
11232 (concat "-" (symbol-name way)))))
11235 "Mark the current article as %s%s.
11236 If N, the prefix, then repeat N times.
11237 If N is negative, move in reverse order.
11238 The difference between N and the actual number of articles marked is
11242 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11244 (defun gnus-summary-generic-mark (n mark move unread)
11245 "Mark N articles with MARK."
11246 (unless (eq major-mode 'gnus-summary-mode)
11247 (error "This command can only be used in the summary buffer"))
11248 (gnus-summary-show-thread)
11251 ((eq move 'next) 1)
11252 ((eq move 'prev) -1)
11254 (if (zerop nummove)
11258 nummove (* -1 nummove))))
11259 (while (and (> n 0)
11260 (gnus-summary-mark-article nil mark)
11261 (zerop (gnus-summary-next-subject nummove unread t)))
11264 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11265 (gnus-summary-recenter)
11266 (gnus-summary-position-point)
11267 (gnus-set-mode-line 'summary)
11270 (defun gnus-summary-insert-articles (articles)
11271 (when (setq articles
11272 (gnus-sorted-difference articles
11273 (mapcar (lambda (h)
11274 (mail-header-number h))
11275 gnus-newsgroup-headers)))
11276 (setq gnus-newsgroup-headers
11278 gnus-newsgroup-headers
11279 (gnus-fetch-headers articles)
11280 'gnus-article-sort-by-number))
11281 ;; Suppress duplicates?
11282 (when gnus-suppress-duplicates
11283 (gnus-dup-suppress-articles))
11285 ;; We might want to build some more threads first.
11286 (when (and gnus-fetch-old-headers
11287 (eq gnus-headers-retrieved-by 'nov))
11288 (if (eq gnus-fetch-old-headers 'invisible)
11289 (gnus-build-all-threads)
11290 (gnus-build-old-threads)))
11291 ;; Let the Gnus agent mark articles as read.
11293 (gnus-agent-get-undownloaded-list))
11294 ;; Remove list identifiers from subject
11295 (when gnus-list-identifiers
11296 (gnus-summary-remove-list-identifiers))
11297 ;; First and last article in this newsgroup.
11298 (when gnus-newsgroup-headers
11299 (setq gnus-newsgroup-begin
11300 (mail-header-number (car gnus-newsgroup-headers))
11302 (mail-header-number
11303 (gnus-last-element gnus-newsgroup-headers))))
11304 (when gnus-use-scoring
11305 (gnus-possibly-score-headers))))
11307 (defun gnus-summary-insert-old-articles (&optional all)
11308 "Insert all old articles in this group.
11309 If ALL is non-nil, already read articles become readable.
11310 If ALL is a number, fetch this number of articles."
11313 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11316 ;; Some nntp servers lie about their active range. When
11317 ;; this happens, the active range can be in the millions.
11318 ;; Use a compressed range to avoid creating a huge list.
11319 (gnus-range-difference (list gnus-newsgroup-active) old))
11320 (setq len (gnus-range-length older))
11325 (let ((older-range (nreverse older)))
11329 (let* ((r (pop older-range))
11330 (min (if (numberp r) r (car r)))
11331 (max (if (numberp r) r (cdr r))))
11332 (while (and (<= min max)
11337 (setq older (gnus-uncompress-range older))))
11339 (setq older (gnus-uncompress-range older)))
11341 (when (and (numberp gnus-large-newsgroup)
11342 (> len gnus-large-newsgroup))
11343 (let* ((cursor-in-echo-area nil)
11344 (initial (gnus-parameter-large-newsgroup-initial
11345 gnus-newsgroup-name))
11349 "How many articles from %s (%s %d): "
11351 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11352 (if initial "max" "default")
11355 (cons (number-to-string initial)
11357 (unless (string-match "^[ \t]*$" input)
11358 (setq all (string-to-number input))
11360 (let ((older-range (nreverse older)))
11364 (let* ((r (pop older-range))
11365 (min (if (numberp r) r (car r)))
11366 (max (if (numberp r) r (cdr r))))
11367 (while (and (<= min max)
11371 max (1- max))))))))))
11372 (setq older (gnus-uncompress-range older))))
11374 (message "No old news.")
11375 (gnus-summary-insert-articles older)
11376 (gnus-summary-limit (gnus-sorted-nunion old older))))
11377 (gnus-summary-position-point)))
11379 (defun gnus-summary-insert-new-articles ()
11380 "Insert all new articles in this group."
11383 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11384 (old-active gnus-newsgroup-active)
11385 (nnmail-fetched-sources (list t))
11387 (setq gnus-newsgroup-active
11388 (gnus-activate-group gnus-newsgroup-name 'scan))
11389 (setq i (cdr gnus-newsgroup-active))
11390 (while (> i (cdr old-active))
11394 (message "No gnus is bad news.")
11395 (gnus-summary-insert-articles new)
11396 (setq gnus-newsgroup-unreads
11397 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11398 (gnus-summary-limit (gnus-sorted-nunion old new))))
11399 (gnus-summary-position-point)))
11401 (gnus-summary-make-all-marking-commands)
11403 (gnus-ems-redefine)
11405 (provide 'gnus-sum)
11407 (run-hooks 'gnus-sum-load-hook)
11409 ;;; gnus-sum.el ends here