1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
42 (autoload 'gnus-cache-write-active "gnus-cache")
43 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
44 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
46 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
47 "Deuglify broken Outlook (Express) articles and redisplay."
49 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
50 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
51 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
53 (defcustom gnus-kill-summary-on-exit t
54 "*If non-nil, kill the summary buffer when you exit from it.
55 If nil, the summary will become a \"*Dead Summary*\" buffer, and
56 it will be killed sometime later."
57 :group 'gnus-summary-exit
60 (defcustom gnus-fetch-old-headers nil
61 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
62 If an unread article in the group refers to an older, already read (or
63 just marked as read) article, the old article will not normally be
64 displayed in the Summary buffer. If this variable is non-nil, Gnus
65 will attempt to grab the headers to the old articles, and thereby
66 build complete threads. If it has the value `some', only enough
67 headers to connect otherwise loose threads will be displayed. This
68 variable can also be a number. In that case, no more than that number
69 of old headers will be fetched. If it has the value `invisible', all
70 old headers will be fetched, but none will be displayed.
72 The server has to support NOV for any of this to work."
74 :type '(choice (const :tag "off" nil)
77 (sexp :menu-tag "other" t)))
79 (defcustom gnus-refer-thread-limit 200
80 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
81 If t, fetch all the available old headers."
84 (sexp :menu-tag "other" t)))
86 (defcustom gnus-summary-make-false-root 'adopt
87 "*nil means that Gnus won't gather loose threads.
88 If the root of a thread has expired or been read in a previous
89 session, the information necessary to build a complete thread has been
90 lost. Instead of having many small sub-threads from this original thread
91 scattered all over the summary buffer, Gnus can gather them.
93 If non-nil, Gnus will try to gather all loose sub-threads from an
94 original thread into one large thread.
96 If this variable is non-nil, it should be one of `none', `adopt',
99 If this variable is `none', Gnus will not make a false root, but just
100 present the sub-threads after another.
101 If this variable is `dummy', Gnus will create a dummy root that will
102 have all the sub-threads as children.
103 If this variable is `adopt', Gnus will make one of the \"children\"
104 the parent and mark all the step-children as such.
105 If this variable is `empty', the \"children\" are printed with empty
106 subject fields. (Or rather, they will be printed with a string
107 given by the `gnus-summary-same-subject' variable.)"
109 :type '(choice (const :tag "off" nil)
115 (defcustom gnus-summary-make-false-root-always nil
116 "Always make a false dummy root."
120 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
121 "*A regexp to match subjects to be excluded from loose thread gathering.
122 As loose thread gathering is done on subjects only, that means that
123 there can be many false gatherings performed. By rooting out certain
124 common subjects, gathering might become saner."
128 (defcustom gnus-summary-gather-subject-limit nil
129 "*Maximum length of subject comparisons when gathering loose threads.
130 Use nil to compare full subjects. Setting this variable to a low
131 number will help gather threads that have been corrupted by
132 newsreaders chopping off subject lines, but it might also mean that
133 unrelated articles that have subject that happen to begin with the
134 same few characters will be incorrectly gathered.
136 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
139 :type '(choice (const :tag "off" nil)
141 (sexp :menu-tag "on" t)))
143 (defcustom gnus-simplify-subject-functions nil
144 "List of functions taking a string argument that simplify subjects.
145 The functions are applied recursively.
147 Useful functions to put in this list include:
148 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
149 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
151 :type '(repeat function))
153 (defcustom gnus-simplify-ignored-prefixes nil
154 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
156 :type '(choice (const :tag "off" nil)
159 (defcustom gnus-build-sparse-threads nil
160 "*If non-nil, fill in the gaps in threads.
161 If `some', only fill in the gaps that are needed to tie loose threads
162 together. If `more', fill in all leaf nodes that Gnus can find. If
163 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
165 :type '(choice (const :tag "off" nil)
168 (sexp :menu-tag "all" t)))
170 (defcustom gnus-summary-thread-gathering-function
171 'gnus-gather-threads-by-subject
172 "*Function used for gathering loose threads.
173 There are two pre-defined functions: `gnus-gather-threads-by-subject',
174 which only takes Subjects into consideration; and
175 `gnus-gather-threads-by-references', which compared the References
176 headers of the articles to find matches."
178 :type '(radio (function-item gnus-gather-threads-by-subject)
179 (function-item gnus-gather-threads-by-references)
180 (function :tag "other")))
182 (defcustom gnus-summary-same-subject ""
183 "*String indicating that the current article has the same subject as the previous.
184 This variable will only be used if the value of
185 `gnus-summary-make-false-root' is `empty'."
186 :group 'gnus-summary-format
189 (defcustom gnus-summary-goto-unread t
190 "*If t, many commands will go to the next unread article.
191 This applies to marking commands as well as other commands that
192 \"naturally\" select the next article, like, for instance, `SPC' at
193 the end of an article.
195 If nil, the marking commands do NOT go to the next unread article
196 \(they go to the next article instead). If `never', commands that
197 usually go to the next unread article, will go to the next article,
198 whether it is read or not."
199 :group 'gnus-summary-marks
200 :link '(custom-manual "(gnus)Setting Marks")
201 :type '(choice (const :tag "off" nil)
203 (sexp :menu-tag "on" t)))
205 (defcustom gnus-summary-default-score 0
206 "*Default article score level.
207 All scores generated by the score files will be added to this score.
208 If this variable is nil, scoring will be disabled."
209 :group 'gnus-score-default
210 :type '(choice (const :tag "disable")
213 (defcustom gnus-summary-default-high-score 0
214 "*Default threshold for a high scored article.
215 An article will be highlighted as high scored if its score is greater
217 :group 'gnus-score-default
220 (defcustom gnus-summary-default-low-score 0
221 "*Default threshold for a low scored article.
222 An article will be highlighted as low scored if its score is smaller
224 :group 'gnus-score-default
227 (defcustom gnus-summary-zcore-fuzz 0
228 "*Fuzziness factor for the zcore in the summary buffer.
229 Articles with scores closer than this to `gnus-summary-default-score'
231 :group 'gnus-summary-format
234 (defcustom gnus-simplify-subject-fuzzy-regexp nil
235 "*Strings to be removed when doing fuzzy matches.
236 This can either be a regular expression or list of regular expressions
237 that will be removed from subject strings if fuzzy subject
238 simplification is selected."
240 :type '(repeat regexp))
242 (defcustom gnus-show-threads t
243 "*If non-nil, display threads in summary mode."
247 (defcustom gnus-thread-hide-subtree nil
248 "*If non-nil, hide all threads initially.
249 This can be a predicate specifier which says which threads to hide.
250 If threads are hidden, you have to run the command
251 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
252 to expose hidden threads."
256 (defcustom gnus-thread-hide-killed t
257 "*If non-nil, hide killed threads automatically."
261 (defcustom gnus-thread-ignore-subject t
262 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
263 If nil, articles that have different subjects from their parents will
264 start separate threads."
268 (defcustom gnus-thread-operation-ignore-subject t
269 "*If non-nil, subjects will be ignored when doing thread commands.
270 This affects commands like `gnus-summary-kill-thread' and
271 `gnus-summary-lower-thread'.
273 If this variable is nil, articles in the same thread with different
274 subjects will not be included in the operation in question. If this
275 variable is `fuzzy', only articles that have subjects that are fuzzily
276 equal will be included."
278 :type '(choice (const :tag "off" nil)
282 (defcustom gnus-thread-indent-level 4
283 "*Number that says how much each sub-thread should be indented."
287 (defcustom gnus-auto-extend-newsgroup t
288 "*If non-nil, extend newsgroup forward and backward when requested."
289 :group 'gnus-summary-choose
292 (defcustom gnus-auto-select-first t
293 "*If non-nil, select the article under point.
294 Which article this is is controlled by the `gnus-auto-select-subject'
297 If you want to prevent automatic selection of articles in some
298 newsgroups, set the variable to nil in `gnus-select-group-hook'."
299 :group 'gnus-group-select
300 :type '(choice (const :tag "none" nil)
301 (sexp :menu-tag "first" t)))
303 (defcustom gnus-auto-select-subject 'unread
304 "*Says what subject to place under point when entering a group.
306 This variable can either be the symbols `first' (place point on the
307 first subject), `unread' (place point on the subject line of the first
308 unread article), `best' (place point on the subject line of the
309 higest-scored article), `unseen' (place point on the subject line of
310 the first unseen article), 'unseen-or-unread' (place point on the subject
311 line of the first unseen article or, if all article have been seen, on the
312 subject line of the first unread article), or a function to be called to
313 place point on some subject line."
314 :group 'gnus-group-select
315 :type '(choice (const best)
319 (const unseen-or-unread)))
321 (defcustom gnus-auto-select-next t
322 "*If non-nil, offer to go to the next group from the end of the previous.
323 If the value is t and the next newsgroup is empty, Gnus will exit
324 summary mode and go back to group mode. If the value is neither nil
325 nor t, Gnus will select the following unread newsgroup. In
326 particular, if the value is the symbol `quietly', the next unread
327 newsgroup will be selected without any confirmation, and if it is
328 `almost-quietly', the next group will be selected without any
329 confirmation if you are located on the last article in the group.
330 Finally, if this variable is `slightly-quietly', the `Z n' command
331 will go to the next group without confirmation."
332 :group 'gnus-summary-maneuvering
333 :type '(choice (const :tag "off" nil)
335 (const almost-quietly)
336 (const slightly-quietly)
337 (sexp :menu-tag "on" t)))
339 (defcustom gnus-auto-select-same nil
340 "*If non-nil, select the next article with the same subject.
341 If there are no more articles with the same subject, go to
342 the first unread article."
343 :group 'gnus-summary-maneuvering
346 (defcustom gnus-summary-check-current nil
347 "*If non-nil, consider the current article when moving.
348 The \"unread\" movement commands will stay on the same line if the
349 current article is unread."
350 :group 'gnus-summary-maneuvering
353 (defcustom gnus-auto-center-summary t
354 "*If non-nil, always center the current summary buffer.
355 In particular, if `vertical' do only vertical recentering. If non-nil
356 and non-`vertical', do both horizontal and vertical recentering."
357 :group 'gnus-summary-maneuvering
358 :type '(choice (const :tag "none" nil)
360 (integer :tag "height")
361 (sexp :menu-tag "both" t)))
363 (defcustom gnus-show-all-headers nil
364 "*If non-nil, don't hide any headers."
365 :group 'gnus-article-hiding
366 :group 'gnus-article-headers
369 (defcustom gnus-summary-ignore-duplicates nil
370 "*If non-nil, ignore articles with identical Message-ID headers."
374 (defcustom gnus-single-article-buffer t
375 "*If non-nil, display all articles in the same buffer.
376 If nil, each group will get its own article buffer."
377 :group 'gnus-article-various
380 (defcustom gnus-break-pages t
381 "*If non-nil, do page breaking on articles.
382 The page delimiter is specified by the `gnus-page-delimiter'
384 :group 'gnus-article-various
387 (defcustom gnus-move-split-methods nil
388 "*Variable used to suggest where articles are to be moved to.
389 It uses the same syntax as the `gnus-split-methods' variable.
390 However, whereas `gnus-split-methods' specifies file names as targets,
391 this variable specifies group names."
392 :group 'gnus-summary-mail
393 :type '(repeat (choice (list :value (fun) function)
394 (cons :value ("" "") regexp (repeat string))
397 (defcustom gnus-unread-mark ? ;Whitespace
398 "*Mark used for unread articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-ticked-mark ?!
403 "*Mark used for ticked articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-dormant-mark ??
408 "*Mark used for dormant articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-del-mark ?r
413 "*Mark used for del'd articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-read-mark ?R
418 "*Mark used for read articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-expirable-mark ?E
423 "*Mark used for expirable articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-killed-mark ?K
428 "*Mark used for killed articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-spam-mark ?$
433 "*Mark used for spam articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-souped-mark ?F
438 "*Mark used for souped articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-kill-file-mark ?X
443 "*Mark used for articles killed by kill files."
444 :group 'gnus-summary-marks
447 (defcustom gnus-low-score-mark ?Y
448 "*Mark used for articles with a low score."
449 :group 'gnus-summary-marks
452 (defcustom gnus-catchup-mark ?C
453 "*Mark used for articles that are caught up."
454 :group 'gnus-summary-marks
457 (defcustom gnus-replied-mark ?A
458 "*Mark used for articles that have been replied to."
459 :group 'gnus-summary-marks
462 (defcustom gnus-forwarded-mark ?F
463 "*Mark used for articles that have been forwarded."
464 :group 'gnus-summary-marks
467 (defcustom gnus-recent-mark ?N
468 "*Mark used for articles that are recent."
469 :group 'gnus-summary-marks
472 (defcustom gnus-cached-mark ?*
473 "*Mark used for articles that are in the cache."
474 :group 'gnus-summary-marks
477 (defcustom gnus-saved-mark ?S
478 "*Mark used for articles that have been saved."
479 :group 'gnus-summary-marks
482 (defcustom gnus-unseen-mark ?.
483 "*Mark used for articles that haven't been seen."
484 :group 'gnus-summary-marks
487 (defcustom gnus-no-mark ? ;Whitespace
488 "*Mark used for articles that have no other secondary mark."
489 :group 'gnus-summary-marks
492 (defcustom gnus-ancient-mark ?O
493 "*Mark used for ancient articles."
494 :group 'gnus-summary-marks
497 (defcustom gnus-sparse-mark ?Q
498 "*Mark used for sparsely reffed articles."
499 :group 'gnus-summary-marks
502 (defcustom gnus-canceled-mark ?G
503 "*Mark used for canceled articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-duplicate-mark ?M
508 "*Mark used for duplicate articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-undownloaded-mark ?-
513 "*Mark used for articles that weren't downloaded."
514 :group 'gnus-summary-marks
517 (defcustom gnus-downloaded-mark ?+
518 "*Mark used for articles that were downloaded."
519 :group 'gnus-summary-marks
522 (defcustom gnus-downloadable-mark ?%
523 "*Mark used for articles that are to be downloaded."
524 :group 'gnus-summary-marks
527 (defcustom gnus-unsendable-mark ?=
528 "*Mark used for articles that won't be sent."
529 :group 'gnus-summary-marks
532 (defcustom gnus-score-over-mark ?+
533 "*Score mark used for articles with high scores."
534 :group 'gnus-summary-marks
537 (defcustom gnus-score-below-mark ?-
538 "*Score mark used for articles with low scores."
539 :group 'gnus-summary-marks
542 (defcustom gnus-empty-thread-mark ? ;Whitespace
543 "*There is no thread under the article."
544 :group 'gnus-summary-marks
547 (defcustom gnus-not-empty-thread-mark ?=
548 "*There is a thread under the article."
549 :group 'gnus-summary-marks
552 (defcustom gnus-view-pseudo-asynchronously nil
553 "*If non-nil, Gnus will view pseudo-articles asynchronously."
554 :group 'gnus-extract-view
557 (defcustom gnus-auto-expirable-marks
558 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
559 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
560 gnus-souped-mark gnus-duplicate-mark)
561 "*The list of marks converted into expiration if a group is auto-expirable."
564 :type '(repeat character))
566 (defcustom gnus-inhibit-user-auto-expire t
567 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
572 (defcustom gnus-view-pseudos nil
573 "*If `automatic', pseudo-articles will be viewed automatically.
574 If `not-confirm', pseudos will be viewed automatically, and the user
575 will not be asked to confirm the command."
576 :group 'gnus-extract-view
577 :type '(choice (const :tag "off" nil)
579 (const not-confirm)))
581 (defcustom gnus-view-pseudos-separately t
582 "*If non-nil, one pseudo-article will be created for each file to be viewed.
583 If nil, all files that use the same viewing command will be given as a
584 list of parameters to that command."
585 :group 'gnus-extract-view
588 (defcustom gnus-insert-pseudo-articles t
589 "*If non-nil, insert pseudo-articles when decoding articles."
590 :group 'gnus-extract-view
593 (defcustom gnus-summary-dummy-line-format
595 "*The format specification for the dummy roots in the summary buffer.
596 It works along the same lines as a normal formatting string,
597 with some simple extensions.
601 General format specifiers can also be used.
602 See `(gnus)Formatting Variables'."
603 :link '(custom-manual "(gnus)Formatting Variables")
604 :group 'gnus-threading
607 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
608 "*The format specification for the summary mode line.
609 It works along the same lines as a normal formatting string,
610 with some simple extensions:
613 %p Unprefixed group name
614 %A Current article number
615 %z Current article score
617 %U Number of unread articles in the group
618 %e Number of unselected articles in the group
619 %Z A string with unread/unselected article counts
620 %g Shortish group name
621 %S Subject of the current article
623 %s Current score file name
624 %d Number of dormant articles
625 %r Number of articles that have been marked as read in this session
626 %E Number of articles expunged by the score files"
627 :group 'gnus-summary-format
630 (defcustom gnus-list-identifiers nil
631 "Regexp that matches list identifiers to be removed from subject.
632 This can also be a list of regexps."
634 :group 'gnus-summary-format
635 :group 'gnus-article-hiding
636 :type '(choice (const :tag "none" nil)
638 (repeat :value (".*") regexp)))
640 (defcustom gnus-summary-mark-below 0
641 "*Mark all articles with a score below this variable as read.
642 This variable is local to each summary buffer and usually set by the
644 :group 'gnus-score-default
647 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
648 "*List of functions used for sorting articles in the summary buffer.
650 Each function takes two articles and returns non-nil if the first
651 article should be sorted before the other. If you use more than one
652 function, the primary sort function should be the last. You should
653 probably always include `gnus-article-sort-by-number' in the list of
654 sorting functions -- preferably first. Also note that sorting by date
655 is often much slower than sorting by number, and the sorting order is
656 very similar. (Sorting by date means sorting by the time the message
657 was sent, sorting by number means sorting by arrival time.)
659 Ready-made functions include `gnus-article-sort-by-number',
660 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
661 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
662 and `gnus-article-sort-by-score'.
664 When threading is turned on, the variable `gnus-thread-sort-functions'
665 controls how articles are sorted."
666 :group 'gnus-summary-sort
667 :type '(repeat (choice (function-item gnus-article-sort-by-number)
668 (function-item gnus-article-sort-by-author)
669 (function-item gnus-article-sort-by-subject)
670 (function-item gnus-article-sort-by-date)
671 (function-item gnus-article-sort-by-score)
672 (function-item gnus-article-sort-by-random)
673 (function :tag "other"))))
675 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
676 "*List of functions used for sorting threads in the summary buffer.
677 By default, threads are sorted by article number.
679 Each function takes two threads and returns non-nil if the first
680 thread should be sorted before the other. If you use more than one
681 function, the primary sort function should be the last. You should
682 probably always include `gnus-thread-sort-by-number' in the list of
683 sorting functions -- preferably first. Also note that sorting by date
684 is often much slower than sorting by number, and the sorting order is
685 very similar. (Sorting by date means sorting by the time the message
686 was sent, sorting by number means sorting by arrival time.)
688 Ready-made functions include `gnus-thread-sort-by-number',
689 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
690 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
691 `gnus-thread-sort-by-most-recent-number',
692 `gnus-thread-sort-by-most-recent-date',
693 `gnus-thread-sort-by-random', and
694 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
696 When threading is turned off, the variable
697 `gnus-article-sort-functions' controls how articles are sorted."
698 :group 'gnus-summary-sort
699 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
700 (function-item gnus-thread-sort-by-author)
701 (function-item gnus-thread-sort-by-subject)
702 (function-item gnus-thread-sort-by-date)
703 (function-item gnus-thread-sort-by-score)
704 (function-item gnus-thread-sort-by-total-score)
705 (function-item gnus-thread-sort-by-random)
706 (function :tag "other"))))
708 (defcustom gnus-thread-score-function '+
709 "*Function used for calculating the total score of a thread.
711 The function is called with the scores of the article and each
712 subthread and should then return the score of the thread.
714 Some functions you can use are `+', `max', or `min'."
715 :group 'gnus-summary-sort
718 (defcustom gnus-summary-expunge-below nil
719 "All articles that have a score less than this variable will be expunged.
720 This variable is local to the summary buffers."
721 :group 'gnus-score-default
722 :type '(choice (const :tag "off" nil)
725 (defcustom gnus-thread-expunge-below nil
726 "All threads that have a total score less than this variable will be expunged.
727 See `gnus-thread-score-function' for en explanation of what a
730 This variable is local to the summary buffers."
731 :group 'gnus-threading
732 :group 'gnus-score-default
733 :type '(choice (const :tag "off" nil)
736 (defcustom gnus-summary-mode-hook nil
737 "*A hook for Gnus summary mode.
738 This hook is run before any variables are set in the summary buffer."
739 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
740 :group 'gnus-summary-various
743 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
744 (when (featurep 'xemacs)
745 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
746 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
747 (add-hook 'gnus-summary-mode-hook
748 'gnus-xmas-switch-horizontal-scrollbar-off))
750 (defcustom gnus-summary-menu-hook nil
751 "*Hook run after the creation of the summary mode menu."
752 :group 'gnus-summary-visual
755 (defcustom gnus-summary-exit-hook nil
756 "*A hook called on exit from the summary buffer.
757 It will be called with point in the group buffer."
758 :group 'gnus-summary-exit
761 (defcustom gnus-summary-prepare-hook nil
762 "*A hook called after the summary buffer has been generated.
763 If you want to modify the summary buffer, you can use this hook."
764 :group 'gnus-summary-various
767 (defcustom gnus-summary-prepared-hook nil
768 "*A hook called as the last thing after the summary buffer has been generated."
769 :group 'gnus-summary-various
772 (defcustom gnus-summary-generate-hook nil
773 "*A hook run just before generating the summary buffer.
774 This hook is commonly used to customize threading variables and the
776 :group 'gnus-summary-various
779 (defcustom gnus-select-group-hook nil
780 "*A hook called when a newsgroup is selected.
782 If you'd like to simplify subjects like the
783 `gnus-summary-next-same-subject' command does, you can use the
786 (add-hook gnus-select-group-hook
788 (mapcar (lambda (header)
789 (mail-header-set-subject
791 (gnus-simplify-subject
792 (mail-header-subject header) 're-only)))
793 gnus-newsgroup-headers)))"
794 :group 'gnus-group-select
797 (defcustom gnus-select-article-hook nil
798 "*A hook called when an article is selected."
799 :group 'gnus-summary-choose
800 :options '(gnus-agent-fetch-selected-article)
803 (defcustom gnus-visual-mark-article-hook
804 (list 'gnus-highlight-selected-summary)
805 "*Hook run after selecting an article in the summary buffer.
806 It is meant to be used for highlighting the article in some way. It
807 is not run if `gnus-visual' is nil."
808 :group 'gnus-summary-visual
811 (defcustom gnus-parse-headers-hook nil
812 "*A hook called before parsing the headers."
816 (defcustom gnus-exit-group-hook nil
817 "*A hook called when exiting summary mode.
818 This hook is not called from the non-updating exit commands like `Q'."
822 (defcustom gnus-summary-update-hook
823 (list 'gnus-summary-highlight-line)
824 "*A hook called when a summary line is changed.
825 The hook will not be called if `gnus-visual' is nil.
827 The default function `gnus-summary-highlight-line' will
828 highlight the line according to the `gnus-summary-highlight'
830 :group 'gnus-summary-visual
833 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
834 "*A hook called when an article is selected for the first time.
835 The hook is intended to mark an article as read (or unread)
836 automatically when it is selected."
837 :group 'gnus-summary-choose
840 (defcustom gnus-group-no-more-groups-hook nil
841 "*A hook run when returning to group mode having no more (unread) groups."
842 :group 'gnus-group-select
845 (defcustom gnus-ps-print-hook nil
846 "*A hook run before ps-printing something from Gnus."
850 (defcustom gnus-summary-display-arrow
851 (and (fboundp 'display-graphic-p)
853 "*If non-nil, display an arrow highlighting the current article."
858 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
859 "Face used for highlighting the current article in the summary buffer."
860 :group 'gnus-summary-visual
863 (defvar gnus-tmp-downloaded nil)
865 (defcustom gnus-summary-highlight
866 '(((eq mark gnus-canceled-mark)
867 . gnus-summary-cancelled-face)
868 ((and uncached (> score default-high))
869 . gnus-summary-high-undownloaded-face)
870 ((and uncached (< score default-low))
871 . gnus-summary-low-undownloaded-face)
873 . gnus-summary-normal-undownloaded-face)
874 ((and (> score default-high)
875 (or (eq mark gnus-dormant-mark)
876 (eq mark gnus-ticked-mark)))
877 . gnus-summary-high-ticked-face)
878 ((and (< score default-low)
879 (or (eq mark gnus-dormant-mark)
880 (eq mark gnus-ticked-mark)))
881 . gnus-summary-low-ticked-face)
882 ((or (eq mark gnus-dormant-mark)
883 (eq mark gnus-ticked-mark))
884 . gnus-summary-normal-ticked-face)
885 ((and (> score default-high) (eq mark gnus-ancient-mark))
886 . gnus-summary-high-ancient-face)
887 ((and (< score default-low) (eq mark gnus-ancient-mark))
888 . gnus-summary-low-ancient-face)
889 ((eq mark gnus-ancient-mark)
890 . gnus-summary-normal-ancient-face)
891 ((and (> score default-high) (eq mark gnus-unread-mark))
892 . gnus-summary-high-unread-face)
893 ((and (< score default-low) (eq mark gnus-unread-mark))
894 . gnus-summary-low-unread-face)
895 ((eq mark gnus-unread-mark)
896 . gnus-summary-normal-unread-face)
897 ((> score default-high)
898 . gnus-summary-high-read-face)
899 ((< score default-low)
900 . gnus-summary-low-read-face)
902 . gnus-summary-normal-read-face))
903 "*Controls the highlighting of summary buffer lines.
905 A list of (FORM . FACE) pairs. When deciding how a a particular
906 summary line should be displayed, each form is evaluated. The content
907 of the face field after the first true form is used. You can change
908 how those summary lines are displayed, by editing the face field.
910 You can use the following variables in the FORM field.
912 score: The article's score
913 default: The default article score.
914 default-high: The default score for high scored articles.
915 default-low: The default score for low scored articles.
916 below: The score below which articles are automatically marked as read.
917 mark: The articles mark."
918 :group 'gnus-summary-visual
919 :type '(repeat (cons (sexp :tag "Form" nil)
922 (defcustom gnus-alter-header-function nil
923 "Function called to allow alteration of article header structures.
924 The function is called with one parameter, the article header vector,
925 which it may alter in any way."
926 :type '(choice (const :tag "None" nil)
928 :group 'gnus-summary)
930 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
931 "Variable that says which function should be used to decode a string with encoded words.")
933 (defcustom gnus-extra-headers '(To Newsgroups)
934 "*Extra headers to parse."
937 :type '(repeat symbol))
939 (defcustom gnus-ignored-from-addresses
940 (and user-mail-address (regexp-quote user-mail-address))
941 "*Regexp of From headers that may be suppressed in favor of To headers."
946 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
947 "List of charsets that should be ignored.
948 When these charsets are used in the \"charset\" parameter, the
949 default charset will be used instead."
951 :type '(repeat symbol)
952 :group 'gnus-charset)
954 (gnus-define-group-parameter
958 "Return the ignored charsets of GROUP."
959 :variable gnus-group-ignored-charsets-alist
961 '(("alt\\.chinese\\.text" iso-8859-1))
963 "Alist of regexps (to match group names) and charsets that should be ignored.
964 When these charsets are used in the \"charset\" parameter, the
965 default charset will be used instead."
966 :variable-group gnus-charset
967 :variable-type '(repeat (cons (regexp :tag "Group")
969 :parameter-type '(choice :tag "Ignored charsets"
972 :parameter-document "\
973 List of charsets that should be ignored.
975 When these charsets are used in the \"charset\" parameter, the
976 default charset will be used instead.")
978 (defcustom gnus-group-highlight-words-alist nil
979 "Alist of group regexps and highlight regexps.
980 This variable uses the same syntax as `gnus-emphasis-alist'."
982 :type '(repeat (cons (regexp :tag "Group")
983 (repeat (list (regexp :tag "Highlight regexp")
984 (number :tag "Group for entire word" 0)
985 (number :tag "Group for displayed part" 0)
987 gnus-emphasis-highlight-words)))))
988 :group 'gnus-summary-visual)
990 (defcustom gnus-summary-show-article-charset-alist
992 "Alist of number and charset.
993 The article will be shown with the charset corresponding to the
995 For example: ((1 . cn-gb-2312) (2 . big5))."
997 :type '(repeat (cons (number :tag "Argument" 1)
998 (symbol :tag "Charset")))
999 :group 'gnus-charset)
1001 (defcustom gnus-preserve-marks t
1002 "Whether marks are preserved when moving, copying and respooling messages."
1005 :group 'gnus-summary-marks)
1007 (defcustom gnus-alter-articles-to-read-function nil
1008 "Function to be called to alter the list of articles to be selected."
1009 :type '(choice (const nil) function)
1010 :group 'gnus-summary)
1012 (defcustom gnus-orphan-score nil
1013 "*All orphans get this score added. Set in the score file."
1014 :group 'gnus-score-default
1015 :type '(choice (const nil)
1018 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1019 "*A regexp to match MIME parts when saving multiple parts of a message
1020 with gnus-summary-save-parts (X m). This regexp will be used by default
1021 when prompting the user for which type of files to save."
1022 :group 'gnus-summary
1025 (defcustom gnus-read-all-available-headers nil
1026 "Whether Gnus should parse all headers made available to it.
1027 This is mostly relevant for slow backends where the user may
1028 wish to widen the summary buffer to include all headers
1029 that were fetched. Say, for nnultimate groups."
1030 :group 'gnus-summary
1031 :type '(choice boolean regexp))
1033 (defcustom gnus-summary-muttprint-program "muttprint"
1034 "Command (and optional arguments) used to run Muttprint."
1036 :group 'gnus-summary
1039 (defcustom gnus-article-loose-mime nil
1040 "If non-nil, don't require MIME-Version header.
1041 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1042 supply the MIME-Version header or deliberately strip it From the mail.
1043 Set it to non-nil, Gnus will treat some articles as MIME even if
1044 the MIME-Version header is missed."
1047 :group 'gnus-article)
1049 (defcustom gnus-article-emulate-mime t
1050 "If non-nil, use MIME emulation for uuencode and the like.
1051 This means that Gnus will search message bodies for text that look
1052 like uuencoded bits, yEncoded bits, and so on, and present that using
1053 the normal Gnus MIME machinery."
1055 :group 'gnus-article)
1057 ;;; Internal variables
1059 (defvar gnus-summary-display-cache nil)
1060 (defvar gnus-article-mime-handles nil)
1061 (defvar gnus-article-decoded-p nil)
1062 (defvar gnus-article-charset nil)
1063 (defvar gnus-article-ignored-charsets nil)
1064 (defvar gnus-scores-exclude-files nil)
1065 (defvar gnus-page-broken nil)
1067 (defvar gnus-original-article nil)
1068 (defvar gnus-article-internal-prepare-hook nil)
1069 (defvar gnus-newsgroup-process-stack nil)
1071 (defvar gnus-thread-indent-array nil)
1072 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1073 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1074 "Function called to sort the articles within a thread after it has been gathered together.")
1076 (defvar gnus-summary-save-parts-type-history nil)
1077 (defvar gnus-summary-save-parts-last-directory nil)
1079 ;; Avoid highlighting in kill files.
1080 (defvar gnus-summary-inhibit-highlight nil)
1081 (defvar gnus-newsgroup-selected-overlay nil)
1082 (defvar gnus-inhibit-limiting nil)
1083 (defvar gnus-newsgroup-adaptive-score-file nil)
1084 (defvar gnus-current-score-file nil)
1085 (defvar gnus-current-move-group nil)
1086 (defvar gnus-current-copy-group nil)
1087 (defvar gnus-current-crosspost-group nil)
1088 (defvar gnus-newsgroup-display nil)
1090 (defvar gnus-newsgroup-dependencies nil)
1091 (defvar gnus-newsgroup-adaptive nil)
1092 (defvar gnus-summary-display-article-function nil)
1093 (defvar gnus-summary-highlight-line-function nil
1094 "Function called after highlighting a summary line.")
1096 (defvar gnus-summary-line-format-alist
1097 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1098 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1099 (?s gnus-tmp-subject-or-nil ?s)
1100 (?n gnus-tmp-name ?s)
1101 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1103 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1105 (?F gnus-tmp-from ?s)
1106 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1107 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1108 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1109 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1110 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1111 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1112 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1113 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1114 (?L gnus-tmp-lines ?s)
1115 (?O gnus-tmp-downloaded ?c)
1116 (?I gnus-tmp-indentation ?s)
1117 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1118 (?R gnus-tmp-replied ?c)
1119 (?\[ gnus-tmp-opening-bracket ?c)
1120 (?\] gnus-tmp-closing-bracket ?c)
1121 (?\> (make-string gnus-tmp-level ? ) ?s)
1122 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1123 (?i gnus-tmp-score ?d)
1124 (?z gnus-tmp-score-char ?c)
1125 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1126 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1127 (?U gnus-tmp-unread ?c)
1128 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1130 (?t (gnus-summary-number-of-articles-in-thread
1131 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1133 (?e (gnus-summary-number-of-articles-in-thread
1134 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1136 (?u gnus-tmp-user-defined ?s)
1137 (?P (gnus-pick-line-number) ?d)
1138 (?B gnus-tmp-thread-tree-header-string ?s)
1139 (user-date (gnus-user-date
1140 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1141 "An alist of format specifications that can appear in summary lines.
1142 These are paired with what variables they correspond with, along with
1143 the type of the variable (string, integer, character, etc).")
1145 (defvar gnus-summary-dummy-line-format-alist
1146 `((?S gnus-tmp-subject ?s)
1147 (?N gnus-tmp-number ?d)
1148 (?u gnus-tmp-user-defined ?s)))
1150 (defvar gnus-summary-mode-line-format-alist
1151 `((?G gnus-tmp-group-name ?s)
1152 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1153 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1154 (?A gnus-tmp-article-number ?d)
1155 (?Z gnus-tmp-unread-and-unselected ?s)
1156 (?V gnus-version ?s)
1157 (?U gnus-tmp-unread-and-unticked ?d)
1158 (?S gnus-tmp-subject ?s)
1159 (?e gnus-tmp-unselected ?d)
1160 (?u gnus-tmp-user-defined ?s)
1161 (?d (length gnus-newsgroup-dormant) ?d)
1162 (?t (length gnus-newsgroup-marked) ?d)
1163 (?h (length gnus-newsgroup-spam-marked) ?d)
1164 (?r (length gnus-newsgroup-reads) ?d)
1165 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1166 (?E gnus-newsgroup-expunged-tally ?d)
1167 (?s (gnus-current-score-file-nondirectory) ?s)))
1169 (defvar gnus-last-search-regexp nil
1170 "Default regexp for article search command.")
1172 (defvar gnus-last-shell-command nil
1173 "Default shell command on article.")
1175 (defvar gnus-newsgroup-agentized nil
1176 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1177 (defvar gnus-newsgroup-begin nil)
1178 (defvar gnus-newsgroup-end nil)
1179 (defvar gnus-newsgroup-last-rmail nil)
1180 (defvar gnus-newsgroup-last-mail nil)
1181 (defvar gnus-newsgroup-last-folder nil)
1182 (defvar gnus-newsgroup-last-file nil)
1183 (defvar gnus-newsgroup-auto-expire nil)
1184 (defvar gnus-newsgroup-active nil)
1186 (defvar gnus-newsgroup-data nil)
1187 (defvar gnus-newsgroup-data-reverse nil)
1188 (defvar gnus-newsgroup-limit nil)
1189 (defvar gnus-newsgroup-limits nil)
1191 (defvar gnus-newsgroup-unreads nil
1192 "Sorted list of unread articles in the current newsgroup.")
1194 (defvar gnus-newsgroup-unselected nil
1195 "Sorted list of unselected unread articles in the current newsgroup.")
1197 (defvar gnus-newsgroup-reads nil
1198 "Alist of read articles and article marks in the current newsgroup.")
1200 (defvar gnus-newsgroup-expunged-tally nil)
1202 (defvar gnus-newsgroup-marked nil
1203 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1205 (defvar gnus-newsgroup-spam-marked nil
1206 "List of ranges of articles that have been marked as spam.")
1208 (defvar gnus-newsgroup-killed nil
1209 "List of ranges of articles that have been through the scoring process.")
1211 (defvar gnus-newsgroup-cached nil
1212 "Sorted list of articles that come from the article cache.")
1214 (defvar gnus-newsgroup-saved nil
1215 "List of articles that have been saved.")
1217 (defvar gnus-newsgroup-kill-headers nil)
1219 (defvar gnus-newsgroup-replied nil
1220 "List of articles that have been replied to in the current newsgroup.")
1222 (defvar gnus-newsgroup-forwarded nil
1223 "List of articles that have been forwarded in the current newsgroup.")
1225 (defvar gnus-newsgroup-recent nil
1226 "List of articles that have are recent in the current newsgroup.")
1228 (defvar gnus-newsgroup-expirable nil
1229 "Sorted list of articles in the current newsgroup that can be expired.")
1231 (defvar gnus-newsgroup-processable nil
1232 "List of articles in the current newsgroup that can be processed.")
1234 (defvar gnus-newsgroup-downloadable nil
1235 "Sorted list of articles in the current newsgroup that can be processed.")
1237 (defvar gnus-newsgroup-unfetched nil
1238 "Sorted list of articles in the current newsgroup whose headers have not been fetched into the agent.")
1240 (defvar gnus-newsgroup-undownloaded nil
1241 "List of articles in the current newsgroup that haven't been downloaded..")
1243 (defvar gnus-newsgroup-unsendable nil
1244 "List of articles in the current newsgroup that won't be sent.")
1246 (defvar gnus-newsgroup-bookmarks nil
1247 "List of articles in the current newsgroup that have bookmarks.")
1249 (defvar gnus-newsgroup-dormant nil
1250 "Sorted list of dormant articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-unseen nil
1253 "List of unseen articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-seen nil
1256 "Range of seen articles in the current newsgroup.")
1258 (defvar gnus-newsgroup-articles nil
1259 "List of articles in the current newsgroup.")
1261 (defvar gnus-newsgroup-scored nil
1262 "List of scored articles in the current newsgroup.")
1264 (defvar gnus-newsgroup-headers nil
1265 "List of article headers in the current newsgroup.")
1267 (defvar gnus-newsgroup-threads nil)
1269 (defvar gnus-newsgroup-prepared nil
1270 "Whether the current group has been prepared properly.")
1272 (defvar gnus-newsgroup-ancient nil
1273 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1275 (defvar gnus-newsgroup-sparse nil)
1277 (defvar gnus-current-article nil)
1278 (defvar gnus-article-current nil)
1279 (defvar gnus-current-headers nil)
1280 (defvar gnus-have-all-headers nil)
1281 (defvar gnus-last-article nil)
1282 (defvar gnus-newsgroup-history nil)
1283 (defvar gnus-newsgroup-charset nil)
1284 (defvar gnus-newsgroup-ephemeral-charset nil)
1285 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1287 (defvar gnus-article-before-search nil)
1289 (defconst gnus-summary-local-variables
1290 '(gnus-newsgroup-name
1291 gnus-newsgroup-begin gnus-newsgroup-end
1292 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1293 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1294 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1295 gnus-newsgroup-unselected gnus-newsgroup-marked
1296 gnus-newsgroup-spam-marked
1297 gnus-newsgroup-reads gnus-newsgroup-saved
1298 gnus-newsgroup-replied gnus-newsgroup-forwarded
1299 gnus-newsgroup-recent
1300 gnus-newsgroup-expirable
1301 gnus-newsgroup-processable gnus-newsgroup-killed
1302 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1303 gnus-newsgroup-unfetched
1304 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1305 gnus-newsgroup-seen gnus-newsgroup-articles
1306 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1307 gnus-newsgroup-headers gnus-newsgroup-threads
1308 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1309 gnus-current-article gnus-current-headers gnus-have-all-headers
1310 gnus-last-article gnus-article-internal-prepare-hook
1311 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1312 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1313 gnus-thread-expunge-below
1314 gnus-score-alist gnus-current-score-file
1315 (gnus-summary-expunge-below . global)
1316 (gnus-summary-mark-below . global)
1317 (gnus-orphan-score . global)
1318 gnus-newsgroup-active gnus-scores-exclude-files
1319 gnus-newsgroup-history gnus-newsgroup-ancient
1320 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1321 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1322 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1323 (gnus-newsgroup-expunged-tally . 0)
1324 gnus-cache-removable-articles gnus-newsgroup-cached
1325 gnus-newsgroup-data gnus-newsgroup-data-reverse
1326 gnus-newsgroup-limit gnus-newsgroup-limits
1327 gnus-newsgroup-charset gnus-newsgroup-display)
1328 "Variables that are buffer-local to the summary buffers.")
1330 (defvar gnus-newsgroup-variables nil
1331 "A list of variables that have separate values in different newsgroups.
1332 A list of newsgroup (summary buffer) local variables, or cons of
1333 variables and their default values (when the default values are not
1334 nil), that should be made global while the summary buffer is active.
1335 These variables can be used to set variables in the group parameters
1336 while still allowing them to affect operations done in other
1337 buffers. For example:
1339 \(setq gnus-newsgroup-variables
1340 '(message-use-followup-to
1341 (gnus-visible-headers .
1342 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1345 ;; Byte-compiler warning.
1346 ;(eval-when-compile (defvar gnus-article-mode-map))
1348 (let ((features (cons 'gnus-sum features)))
1350 (require 'gnus-agent)
1351 (require 'gnus-art)))
1355 (defvar gnus-decode-encoded-word-methods
1356 '(mail-decode-encoded-word-string)
1357 "List of methods used to decode encoded words.
1359 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1360 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1361 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1362 whose names match REGEXP.
1365 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1366 mail-decode-encoded-word-string
1367 (\"chinese\" . rfc1843-decode-string))")
1369 (defvar gnus-decode-encoded-word-methods-cache nil)
1371 (defun gnus-multi-decode-encoded-word-string (string)
1372 "Apply the functions from `gnus-encoded-word-methods' that match."
1373 (unless (and gnus-decode-encoded-word-methods-cache
1374 (eq gnus-newsgroup-name
1375 (car gnus-decode-encoded-word-methods-cache)))
1376 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1379 (nconc gnus-decode-encoded-word-methods-cache (list x))
1380 (if (and gnus-newsgroup-name
1381 (string-match (car x) gnus-newsgroup-name))
1382 (nconc gnus-decode-encoded-word-methods-cache
1384 gnus-decode-encoded-word-methods))
1385 (let ((xlist gnus-decode-encoded-word-methods-cache))
1388 (setq string (funcall (pop xlist) string))))
1391 ;; Subject simplification.
1393 (defun gnus-simplify-whitespace (str)
1394 "Remove excessive whitespace from STR."
1397 (while (string-match "[ \t][ \t]+" mystr)
1398 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1400 (substring mystr (match-end 0)))))
1402 (when (string-match "^[ \t]+" mystr)
1403 (setq mystr (substring mystr (match-end 0))))
1405 (when (string-match "[ \t]+$" mystr)
1406 (setq mystr (substring mystr 0 (match-beginning 0))))
1409 (defun gnus-simplify-all-whitespace (str)
1410 "Remove all whitespace from STR."
1412 (while (string-match "[ \t\n]+" mystr)
1413 (setq mystr (replace-match "" nil nil mystr)))
1416 (defsubst gnus-simplify-subject-re (subject)
1417 "Remove \"Re:\" from subject lines."
1418 (if (string-match message-subject-re-regexp subject)
1419 (substring subject (match-end 0))
1422 (defun gnus-simplify-subject (subject &optional re-only)
1423 "Remove `Re:' and words in parentheses.
1424 If RE-ONLY is non-nil, strip leading `Re:'s only."
1425 (let ((case-fold-search t)) ;Ignore case.
1426 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1427 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1428 (setq subject (substring subject (match-end 0))))
1429 ;; Remove uninteresting prefixes.
1430 (when (and (not re-only)
1431 gnus-simplify-ignored-prefixes
1432 (string-match gnus-simplify-ignored-prefixes subject))
1433 (setq subject (substring subject (match-end 0))))
1434 ;; Remove words in parentheses from end.
1436 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1437 (setq subject (substring subject 0 (match-beginning 0)))))
1438 ;; Return subject string.
1441 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1443 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1444 (goto-char (point-min))
1445 (while (re-search-forward regexp nil t)
1446 (replace-match (or newtext ""))))
1448 (defun gnus-simplify-buffer-fuzzy ()
1449 "Simplify string in the buffer fuzzily.
1450 The string in the accessible portion of the current buffer is simplified.
1451 It is assumed to be a single-line subject.
1452 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1453 matter is removed. Additional things can be deleted by setting
1454 `gnus-simplify-subject-fuzzy-regexp'."
1455 (let ((case-fold-search t)
1457 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1459 (while (not (eq modified-tick (buffer-modified-tick)))
1460 (setq modified-tick (buffer-modified-tick))
1462 ((listp gnus-simplify-subject-fuzzy-regexp)
1463 (mapcar 'gnus-simplify-buffer-fuzzy-step
1464 gnus-simplify-subject-fuzzy-regexp))
1465 (gnus-simplify-subject-fuzzy-regexp
1466 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1467 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1468 (gnus-simplify-buffer-fuzzy-step
1469 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1470 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1472 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1473 (gnus-simplify-buffer-fuzzy-step " +" " ")
1474 (gnus-simplify-buffer-fuzzy-step " $")
1475 (gnus-simplify-buffer-fuzzy-step "^ +")))
1477 (defun gnus-simplify-subject-fuzzy (subject)
1478 "Simplify a subject string fuzzily.
1479 See `gnus-simplify-buffer-fuzzy' for details."
1481 (gnus-set-work-buffer)
1482 (let ((case-fold-search t))
1483 ;; Remove uninteresting prefixes.
1484 (when (and gnus-simplify-ignored-prefixes
1485 (string-match gnus-simplify-ignored-prefixes subject))
1486 (setq subject (substring subject (match-end 0))))
1488 (inline (gnus-simplify-buffer-fuzzy))
1491 (defsubst gnus-simplify-subject-fully (subject)
1492 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1494 (gnus-simplify-subject-functions
1495 (gnus-map-function gnus-simplify-subject-functions subject))
1496 ((null gnus-summary-gather-subject-limit)
1497 (gnus-simplify-subject-re subject))
1498 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1499 (gnus-simplify-subject-fuzzy subject))
1500 ((numberp gnus-summary-gather-subject-limit)
1501 (gnus-limit-string (gnus-simplify-subject-re subject)
1502 gnus-summary-gather-subject-limit))
1506 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1507 "Check whether two subjects are equal.
1508 If optional argument simple-first is t, first argument is already
1511 ((null simple-first)
1512 (equal (gnus-simplify-subject-fully s1)
1513 (gnus-simplify-subject-fully s2)))
1516 (gnus-simplify-subject-fully s2)))))
1518 (defun gnus-summary-bubble-group ()
1519 "Increase the score of the current group.
1520 This is a handy function to add to `gnus-summary-exit-hook' to
1521 increase the score of each group you read."
1522 (gnus-group-add-score gnus-newsgroup-name))
1526 ;;; Gnus summary mode
1529 (put 'gnus-summary-mode 'mode-class 'special)
1531 (defvar gnus-article-commands-menu)
1533 ;; Non-orthogonal keys
1535 (gnus-define-keys gnus-summary-mode-map
1536 " " gnus-summary-next-page
1537 "\177" gnus-summary-prev-page
1538 [delete] gnus-summary-prev-page
1539 [backspace] gnus-summary-prev-page
1540 "\r" gnus-summary-scroll-up
1541 "\M-\r" gnus-summary-scroll-down
1542 "n" gnus-summary-next-unread-article
1543 "p" gnus-summary-prev-unread-article
1544 "N" gnus-summary-next-article
1545 "P" gnus-summary-prev-article
1546 "\M-\C-n" gnus-summary-next-same-subject
1547 "\M-\C-p" gnus-summary-prev-same-subject
1548 "\M-n" gnus-summary-next-unread-subject
1549 "\M-p" gnus-summary-prev-unread-subject
1550 "." gnus-summary-first-unread-article
1551 "," gnus-summary-best-unread-article
1552 "\M-s" gnus-summary-search-article-forward
1553 "\M-r" gnus-summary-search-article-backward
1554 "<" gnus-summary-beginning-of-article
1555 ">" gnus-summary-end-of-article
1556 "j" gnus-summary-goto-article
1557 "^" gnus-summary-refer-parent-article
1558 "\M-^" gnus-summary-refer-article
1559 "u" gnus-summary-tick-article-forward
1560 "!" gnus-summary-tick-article-forward
1561 "U" gnus-summary-tick-article-backward
1562 "d" gnus-summary-mark-as-read-forward
1563 "D" gnus-summary-mark-as-read-backward
1564 "E" gnus-summary-mark-as-expirable
1565 "\M-u" gnus-summary-clear-mark-forward
1566 "\M-U" gnus-summary-clear-mark-backward
1567 "k" gnus-summary-kill-same-subject-and-select
1568 "\C-k" gnus-summary-kill-same-subject
1569 "\M-\C-k" gnus-summary-kill-thread
1570 "\M-\C-l" gnus-summary-lower-thread
1571 "e" gnus-summary-edit-article
1572 "#" gnus-summary-mark-as-processable
1573 "\M-#" gnus-summary-unmark-as-processable
1574 "\M-\C-t" gnus-summary-toggle-threads
1575 "\M-\C-s" gnus-summary-show-thread
1576 "\M-\C-h" gnus-summary-hide-thread
1577 "\M-\C-f" gnus-summary-next-thread
1578 "\M-\C-b" gnus-summary-prev-thread
1579 [(meta down)] gnus-summary-next-thread
1580 [(meta up)] gnus-summary-prev-thread
1581 "\M-\C-u" gnus-summary-up-thread
1582 "\M-\C-d" gnus-summary-down-thread
1583 "&" gnus-summary-execute-command
1584 "c" gnus-summary-catchup-and-exit
1585 "\C-w" gnus-summary-mark-region-as-read
1586 "\C-t" gnus-summary-toggle-truncation
1587 "?" gnus-summary-mark-as-dormant
1588 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1589 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1590 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1591 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1592 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1593 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1594 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1595 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1596 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1597 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1598 "=" gnus-summary-expand-window
1599 "\C-x\C-s" gnus-summary-reselect-current-group
1600 "\M-g" gnus-summary-rescan-group
1601 "w" gnus-summary-stop-page-breaking
1602 "\C-c\C-r" gnus-summary-caesar-message
1603 "f" gnus-summary-followup
1604 "F" gnus-summary-followup-with-original
1605 "C" gnus-summary-cancel-article
1606 "r" gnus-summary-reply
1607 "R" gnus-summary-reply-with-original
1608 "\C-c\C-f" gnus-summary-mail-forward
1609 "o" gnus-summary-save-article
1610 "\C-o" gnus-summary-save-article-mail
1611 "|" gnus-summary-pipe-output
1612 "\M-k" gnus-summary-edit-local-kill
1613 "\M-K" gnus-summary-edit-global-kill
1615 "\C-c\C-d" gnus-summary-describe-group
1616 "q" gnus-summary-exit
1617 "Q" gnus-summary-exit-no-update
1618 "\C-c\C-i" gnus-info-find-node
1619 gnus-mouse-2 gnus-mouse-pick-article
1620 "m" gnus-summary-mail-other-window
1621 "a" gnus-summary-post-news
1622 "i" gnus-summary-news-other-window
1623 "x" gnus-summary-limit-to-unread
1624 "s" gnus-summary-isearch-article
1625 "t" gnus-summary-toggle-header
1626 "g" gnus-summary-show-article
1627 "l" gnus-summary-goto-last-article
1628 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1629 "\C-d" gnus-summary-enter-digest-group
1630 "\M-\C-d" gnus-summary-read-document
1631 "\M-\C-e" gnus-summary-edit-parameters
1632 "\M-\C-a" gnus-summary-customize-parameters
1634 "*" gnus-cache-enter-article
1635 "\M-*" gnus-cache-remove-article
1636 "\M-&" gnus-summary-universal-argument
1637 "\C-l" gnus-recenter
1638 "I" gnus-summary-increase-score
1639 "L" gnus-summary-lower-score
1640 "\M-i" gnus-symbolic-argument
1641 "h" gnus-summary-select-article-buffer
1643 "b" gnus-article-view-part
1644 "\M-t" gnus-summary-toggle-display-buttonized
1646 "V" gnus-summary-score-map
1647 "X" gnus-uu-extract-map
1648 "S" gnus-summary-send-map)
1650 ;; Sort of orthogonal keymap
1651 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1652 "t" gnus-summary-tick-article-forward
1653 "!" gnus-summary-tick-article-forward
1654 "d" gnus-summary-mark-as-read-forward
1655 "r" gnus-summary-mark-as-read-forward
1656 "c" gnus-summary-clear-mark-forward
1657 " " gnus-summary-clear-mark-forward
1658 "e" gnus-summary-mark-as-expirable
1659 "x" gnus-summary-mark-as-expirable
1660 "?" gnus-summary-mark-as-dormant
1661 "b" gnus-summary-set-bookmark
1662 "B" gnus-summary-remove-bookmark
1663 "#" gnus-summary-mark-as-processable
1664 "\M-#" gnus-summary-unmark-as-processable
1665 "S" gnus-summary-limit-include-expunged
1666 "C" gnus-summary-catchup
1667 "H" gnus-summary-catchup-to-here
1668 "h" gnus-summary-catchup-from-here
1669 "\C-c" gnus-summary-catchup-all
1670 "k" gnus-summary-kill-same-subject-and-select
1671 "K" gnus-summary-kill-same-subject
1672 "P" gnus-uu-mark-map)
1674 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1675 "c" gnus-summary-clear-above
1676 "u" gnus-summary-tick-above
1677 "m" gnus-summary-mark-above
1678 "k" gnus-summary-kill-below)
1680 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1681 "/" gnus-summary-limit-to-subject
1682 "n" gnus-summary-limit-to-articles
1683 "w" gnus-summary-pop-limit
1684 "s" gnus-summary-limit-to-subject
1685 "a" gnus-summary-limit-to-author
1686 "u" gnus-summary-limit-to-unread
1687 "m" gnus-summary-limit-to-marks
1688 "M" gnus-summary-limit-exclude-marks
1689 "v" gnus-summary-limit-to-score
1690 "*" gnus-summary-limit-include-cached
1691 "D" gnus-summary-limit-include-dormant
1692 "T" gnus-summary-limit-include-thread
1693 "d" gnus-summary-limit-exclude-dormant
1694 "t" gnus-summary-limit-to-age
1695 "." gnus-summary-limit-to-unseen
1696 "x" gnus-summary-limit-to-extra
1697 "p" gnus-summary-limit-to-display-predicate
1698 "E" gnus-summary-limit-include-expunged
1699 "c" gnus-summary-limit-exclude-childless-dormant
1700 "C" gnus-summary-limit-mark-excluded-as-read
1701 "o" gnus-summary-insert-old-articles
1702 "N" gnus-summary-insert-new-articles)
1704 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1705 "n" gnus-summary-next-unread-article
1706 "p" gnus-summary-prev-unread-article
1707 "N" gnus-summary-next-article
1708 "P" gnus-summary-prev-article
1709 "\C-n" gnus-summary-next-same-subject
1710 "\C-p" gnus-summary-prev-same-subject
1711 "\M-n" gnus-summary-next-unread-subject
1712 "\M-p" gnus-summary-prev-unread-subject
1713 "f" gnus-summary-first-unread-article
1714 "b" gnus-summary-best-unread-article
1715 "j" gnus-summary-goto-article
1716 "g" gnus-summary-goto-subject
1717 "l" gnus-summary-goto-last-article
1718 "o" gnus-summary-pop-article)
1720 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1721 "k" gnus-summary-kill-thread
1722 "l" gnus-summary-lower-thread
1723 "i" gnus-summary-raise-thread
1724 "T" gnus-summary-toggle-threads
1725 "t" gnus-summary-rethread-current
1726 "^" gnus-summary-reparent-thread
1727 "s" gnus-summary-show-thread
1728 "S" gnus-summary-show-all-threads
1729 "h" gnus-summary-hide-thread
1730 "H" gnus-summary-hide-all-threads
1731 "n" gnus-summary-next-thread
1732 "p" gnus-summary-prev-thread
1733 "u" gnus-summary-up-thread
1734 "o" gnus-summary-top-thread
1735 "d" gnus-summary-down-thread
1736 "#" gnus-uu-mark-thread
1737 "\M-#" gnus-uu-unmark-thread)
1739 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1740 "g" gnus-summary-prepare
1741 "c" gnus-summary-insert-cached-articles
1742 "d" gnus-summary-insert-dormant-articles)
1744 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1745 "c" gnus-summary-catchup-and-exit
1746 "C" gnus-summary-catchup-all-and-exit
1747 "E" gnus-summary-exit-no-update
1748 "Q" gnus-summary-exit
1749 "Z" gnus-summary-exit
1750 "n" gnus-summary-catchup-and-goto-next-group
1751 "R" gnus-summary-reselect-current-group
1752 "G" gnus-summary-rescan-group
1753 "N" gnus-summary-next-group
1754 "s" gnus-summary-save-newsrc
1755 "P" gnus-summary-prev-group)
1757 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1758 " " gnus-summary-next-page
1759 "n" gnus-summary-next-page
1760 "\177" gnus-summary-prev-page
1761 [delete] gnus-summary-prev-page
1762 "p" gnus-summary-prev-page
1763 "\r" gnus-summary-scroll-up
1764 "\M-\r" gnus-summary-scroll-down
1765 "<" gnus-summary-beginning-of-article
1766 ">" gnus-summary-end-of-article
1767 "b" gnus-summary-beginning-of-article
1768 "e" gnus-summary-end-of-article
1769 "^" gnus-summary-refer-parent-article
1770 "r" gnus-summary-refer-parent-article
1771 "D" gnus-summary-enter-digest-group
1772 "R" gnus-summary-refer-references
1773 "T" gnus-summary-refer-thread
1774 "g" gnus-summary-show-article
1775 "s" gnus-summary-isearch-article
1776 "P" gnus-summary-print-article
1777 "M" gnus-mailing-list-insinuate
1778 "t" gnus-article-babel)
1780 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1781 "b" gnus-article-add-buttons
1782 "B" gnus-article-add-buttons-to-head
1783 "o" gnus-article-treat-overstrike
1784 "e" gnus-article-emphasize
1785 "w" gnus-article-fill-cited-article
1786 "Q" gnus-article-fill-long-lines
1787 "C" gnus-article-capitalize-sentences
1788 "c" gnus-article-remove-cr
1789 "q" gnus-article-de-quoted-unreadable
1790 "6" gnus-article-de-base64-unreadable
1791 "Z" gnus-article-decode-HZ
1792 "h" gnus-article-wash-html
1793 "u" gnus-article-unsplit-urls
1794 "s" gnus-summary-force-verify-and-decrypt
1795 "f" gnus-article-display-x-face
1796 "l" gnus-summary-stop-page-breaking
1797 "r" gnus-summary-caesar-message
1798 "m" gnus-summary-morse-message
1799 "t" gnus-summary-toggle-header
1800 "g" gnus-treat-smiley
1801 "v" gnus-summary-verbose-headers
1802 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1803 "p" gnus-article-verify-x-pgp-sig
1804 "d" gnus-article-treat-dumbquotes)
1806 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1807 ;; mnemonic: deuglif*Y*
1808 "u" gnus-article-outlook-unwrap-lines
1809 "a" gnus-article-outlook-repair-attribution
1810 "c" gnus-article-outlook-rearrange-citation
1811 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1813 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1814 "a" gnus-article-hide
1815 "h" gnus-article-hide-headers
1816 "b" gnus-article-hide-boring-headers
1817 "s" gnus-article-hide-signature
1818 "c" gnus-article-hide-citation
1819 "C" gnus-article-hide-citation-in-followups
1820 "l" gnus-article-hide-list-identifiers
1821 "B" gnus-article-strip-banner
1822 "P" gnus-article-hide-pem
1823 "\C-c" gnus-article-hide-citation-maybe)
1825 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1826 "a" gnus-article-highlight
1827 "h" gnus-article-highlight-headers
1828 "c" gnus-article-highlight-citation
1829 "s" gnus-article-highlight-signature)
1831 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1832 "f" gnus-article-treat-fold-headers
1833 "u" gnus-article-treat-unfold-headers
1834 "n" gnus-article-treat-fold-newsgroups)
1836 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1837 "x" gnus-article-display-x-face
1838 "d" gnus-article-display-face
1839 "s" gnus-treat-smiley
1840 "D" gnus-article-remove-images
1841 "f" gnus-treat-from-picon
1842 "m" gnus-treat-mail-picon
1843 "n" gnus-treat-newsgroups-picon)
1845 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1846 "w" gnus-article-decode-mime-words
1847 "c" gnus-article-decode-charset
1848 "v" gnus-mime-view-all-parts
1849 "b" gnus-article-view-part)
1851 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1852 "z" gnus-article-date-ut
1853 "u" gnus-article-date-ut
1854 "l" gnus-article-date-local
1855 "p" gnus-article-date-english
1856 "e" gnus-article-date-lapsed
1857 "o" gnus-article-date-original
1858 "i" gnus-article-date-iso8601
1859 "s" gnus-article-date-user)
1861 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1862 "t" gnus-article-remove-trailing-blank-lines
1863 "l" gnus-article-strip-leading-blank-lines
1864 "m" gnus-article-strip-multiple-blank-lines
1865 "a" gnus-article-strip-blank-lines
1866 "A" gnus-article-strip-all-blank-lines
1867 "s" gnus-article-strip-leading-space
1868 "e" gnus-article-strip-trailing-space
1869 "w" gnus-article-remove-leading-whitespace)
1871 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1873 "f" gnus-summary-fetch-faq
1874 "d" gnus-summary-describe-group
1875 "h" gnus-summary-describe-briefly
1876 "i" gnus-info-find-node
1877 "c" gnus-group-fetch-charter
1878 "C" gnus-group-fetch-control)
1880 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1881 "e" gnus-summary-expire-articles
1882 "\M-\C-e" gnus-summary-expire-articles-now
1883 "\177" gnus-summary-delete-article
1884 [delete] gnus-summary-delete-article
1885 [backspace] gnus-summary-delete-article
1886 "m" gnus-summary-move-article
1887 "r" gnus-summary-respool-article
1888 "w" gnus-summary-edit-article
1889 "c" gnus-summary-copy-article
1890 "B" gnus-summary-crosspost-article
1891 "q" gnus-summary-respool-query
1892 "t" gnus-summary-respool-trace
1893 "i" gnus-summary-import-article
1894 "I" gnus-summary-create-article
1895 "p" gnus-summary-article-posted-p)
1897 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1898 "o" gnus-summary-save-article
1899 "m" gnus-summary-save-article-mail
1900 "F" gnus-summary-write-article-file
1901 "r" gnus-summary-save-article-rmail
1902 "f" gnus-summary-save-article-file
1903 "b" gnus-summary-save-article-body-file
1904 "h" gnus-summary-save-article-folder
1905 "v" gnus-summary-save-article-vm
1906 "p" gnus-summary-pipe-output
1907 "P" gnus-summary-muttprint
1908 "s" gnus-soup-add-article)
1910 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1911 "b" gnus-summary-display-buttonized
1912 "m" gnus-summary-repair-multipart
1913 "v" gnus-article-view-part
1914 "o" gnus-article-save-part
1915 "c" gnus-article-copy-part
1916 "C" gnus-article-view-part-as-charset
1917 "e" gnus-article-view-part-externally
1918 "E" gnus-article-encrypt-body
1919 "i" gnus-article-inline-part
1920 "|" gnus-article-pipe-part)
1922 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1923 "p" gnus-summary-mark-as-processable
1924 "u" gnus-summary-unmark-as-processable
1925 "U" gnus-summary-unmark-all-processable
1926 "v" gnus-uu-mark-over
1927 "s" gnus-uu-mark-series
1928 "r" gnus-uu-mark-region
1929 "g" gnus-uu-unmark-region
1930 "R" gnus-uu-mark-by-regexp
1931 "G" gnus-uu-unmark-by-regexp
1932 "t" gnus-uu-mark-thread
1933 "T" gnus-uu-unmark-thread
1934 "a" gnus-uu-mark-all
1935 "b" gnus-uu-mark-buffer
1936 "S" gnus-uu-mark-sparse
1937 "k" gnus-summary-kill-process-mark
1938 "y" gnus-summary-yank-process-mark
1939 "w" gnus-summary-save-process-mark
1940 "i" gnus-uu-invert-processable)
1942 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1943 ;;"x" gnus-uu-extract-any
1944 "m" gnus-summary-save-parts
1945 "u" gnus-uu-decode-uu
1946 "U" gnus-uu-decode-uu-and-save
1947 "s" gnus-uu-decode-unshar
1948 "S" gnus-uu-decode-unshar-and-save
1949 "o" gnus-uu-decode-save
1950 "O" gnus-uu-decode-save
1951 "b" gnus-uu-decode-binhex
1952 "B" gnus-uu-decode-binhex
1953 "p" gnus-uu-decode-postscript
1954 "P" gnus-uu-decode-postscript-and-save)
1957 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1958 "u" gnus-uu-decode-uu-view
1959 "U" gnus-uu-decode-uu-and-save-view
1960 "s" gnus-uu-decode-unshar-view
1961 "S" gnus-uu-decode-unshar-and-save-view
1962 "o" gnus-uu-decode-save-view
1963 "O" gnus-uu-decode-save-view
1964 "b" gnus-uu-decode-binhex-view
1965 "B" gnus-uu-decode-binhex-view
1966 "p" gnus-uu-decode-postscript-view
1967 "P" gnus-uu-decode-postscript-and-save-view)
1969 (defvar gnus-article-post-menu nil)
1971 (defconst gnus-summary-menu-maxlen 20)
1973 (defun gnus-summary-menu-split (menu)
1974 ;; If we have lots of elements, divide them into groups of 20
1975 ;; and make a pane (or submenu) for each one.
1976 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1977 (let ((menu menu) sublists next
1980 ;; Pull off the next gnus-summary-menu-maxlen elements
1981 ;; and make them the next element of sublist.
1982 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1984 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1986 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1987 (aref (car (last menu)) 0)) menu)
1991 (nreverse sublists))
1992 ;; Few elements--put them all in one pane.
1995 (defun gnus-summary-make-menu-bar ()
1996 (gnus-turn-off-edit-menu 'summary)
1998 (unless (boundp 'gnus-summary-misc-menu)
2001 gnus-summary-kill-menu gnus-summary-mode-map ""
2006 ["Customize" gnus-score-customize t])
2007 (gnus-make-score-map 'increase)
2008 (gnus-make-score-map 'lower)
2010 ["Kill below" gnus-summary-kill-below t]
2011 ["Mark above" gnus-summary-mark-above t]
2012 ["Tick above" gnus-summary-tick-above t]
2013 ["Clear above" gnus-summary-clear-above t])
2014 ["Current score" gnus-summary-current-score t]
2015 ["Set score" gnus-summary-set-score t]
2016 ["Switch current score file..." gnus-score-change-score-file t]
2017 ["Set mark below..." gnus-score-set-mark-below t]
2018 ["Set expunge below..." gnus-score-set-expunge-below t]
2019 ["Edit current score file" gnus-score-edit-current-scores t]
2020 ["Edit score file" gnus-score-edit-file t]
2021 ["Trace score" gnus-score-find-trace t]
2022 ["Find words" gnus-score-find-favourite-words t]
2023 ["Rescore buffer" gnus-summary-rescore t]
2024 ["Increase score..." gnus-summary-increase-score t]
2025 ["Lower score..." gnus-summary-lower-score t]))))
2027 ;; Define both the Article menu in the summary buffer and the
2028 ;; equivalent Commands menu in the article buffer here for
2032 ["All" gnus-article-hide t]
2033 ["Headers" gnus-article-hide-headers t]
2034 ["Signature" gnus-article-hide-signature t]
2035 ["Citation" gnus-article-hide-citation t]
2036 ["List identifiers" gnus-article-hide-list-identifiers t]
2037 ["Banner" gnus-article-strip-banner t]
2038 ["Boring headers" gnus-article-hide-boring-headers t])
2040 ["All" gnus-article-highlight t]
2041 ["Headers" gnus-article-highlight-headers t]
2042 ["Signature" gnus-article-highlight-signature t]
2043 ["Citation" gnus-article-highlight-citation t])
2045 ["Words" gnus-article-decode-mime-words t]
2046 ["Charset" gnus-article-decode-charset t]
2047 ["QP" gnus-article-de-quoted-unreadable t]
2048 ["Base64" gnus-article-de-base64-unreadable t]
2049 ["View MIME buttons" gnus-summary-display-buttonized t]
2050 ["View all" gnus-mime-view-all-parts t]
2051 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2052 ["Encrypt body" gnus-article-encrypt-body t]
2053 ["Extract all parts" gnus-summary-save-parts t])
2055 ["Local" gnus-article-date-local t]
2056 ["ISO8601" gnus-article-date-iso8601 t]
2057 ["UT" gnus-article-date-ut t]
2058 ["Original" gnus-article-date-original t]
2059 ["Lapsed" gnus-article-date-lapsed t]
2060 ["User-defined" gnus-article-date-user t])
2062 ["Remove images" gnus-article-remove-images t]
2063 ["Toggle smiley" gnus-treat-smiley t]
2064 ["Show X-Face" gnus-article-display-x-face t]
2065 ["Show picons in From" gnus-treat-from-picon t]
2066 ["Show picons in mail headers" gnus-treat-mail-picon t]
2067 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2068 ("View as different encoding"
2069 ,@(gnus-summary-menu-split
2072 ;; Since easymenu under FSF Emacs doesn't allow lambda
2073 ;; forms for menu commands, we should provide intern'ed
2074 ;; function symbols.
2075 (let ((command (intern (format "\
2076 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2080 (let ((gnus-summary-show-article-charset-alist
2082 (gnus-summary-show-article 1))))
2083 `[,(symbol-name cs) ,command t]))
2084 (sort (if (fboundp 'coding-system-list)
2085 (coding-system-list)
2086 (mapcar 'car mm-mime-mule-charset-alist))
2090 ["Leading" gnus-article-strip-leading-blank-lines t]
2091 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2092 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2093 ["All of the above" gnus-article-strip-blank-lines t]
2094 ["All" gnus-article-strip-all-blank-lines t]
2095 ["Leading space" gnus-article-strip-leading-space t]
2096 ["Trailing space" gnus-article-strip-trailing-space t]
2097 ["Leading space in headers"
2098 gnus-article-remove-leading-whitespace t])
2099 ["Overstrike" gnus-article-treat-overstrike t]
2100 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2101 ["Emphasis" gnus-article-emphasize t]
2102 ["Word wrap" gnus-article-fill-cited-article t]
2103 ["Fill long lines" gnus-article-fill-long-lines t]
2104 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2105 ["CR" gnus-article-remove-cr t]
2106 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2107 ["Base64" gnus-article-de-base64-unreadable t]
2108 ["Rot 13" gnus-summary-caesar-message
2109 ,@(if (featurep 'xemacs) '(t)
2110 '(:help "\"Caesar rotate\" article by 13"))]
2111 ["Morse decode" gnus-summary-morse-message t]
2112 ["Unix pipe..." gnus-summary-pipe-message t]
2113 ["Add buttons" gnus-article-add-buttons t]
2114 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2115 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2116 ["Verbose header" gnus-summary-verbose-headers t]
2117 ["Toggle header" gnus-summary-toggle-header t]
2118 ["Unfold headers" gnus-article-treat-unfold-headers t]
2119 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2120 ["Html" gnus-article-wash-html t]
2121 ["URLs" gnus-article-unsplit-urls t]
2122 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2123 ["HZ" gnus-article-decode-HZ t]
2124 ("(Outlook) Deuglify"
2125 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2126 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2127 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2128 ["Full (Outlook) deuglify"
2129 gnus-article-outlook-deuglify-article t])
2132 ["Save in default format" gnus-summary-save-article
2133 ,@(if (featurep 'xemacs) '(t)
2134 '(:help "Save article using default method"))]
2135 ["Save in file" gnus-summary-save-article-file
2136 ,@(if (featurep 'xemacs) '(t)
2137 '(:help "Save article in file"))]
2138 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2139 ["Save in MH folder" gnus-summary-save-article-folder t]
2140 ["Save in VM folder" gnus-summary-save-article-vm t]
2141 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2142 ["Save body in file" gnus-summary-save-article-body-file t]
2143 ["Pipe through a filter" gnus-summary-pipe-output t]
2144 ["Add to SOUP packet" gnus-soup-add-article t]
2145 ["Print with Muttprint" gnus-summary-muttprint t]
2146 ["Print" gnus-summary-print-article t])
2148 ["Respool article..." gnus-summary-respool-article t]
2149 ["Move article..." gnus-summary-move-article
2150 (gnus-check-backend-function
2151 'request-move-article gnus-newsgroup-name)]
2152 ["Copy article..." gnus-summary-copy-article t]
2153 ["Crosspost article..." gnus-summary-crosspost-article
2154 (gnus-check-backend-function
2155 'request-replace-article gnus-newsgroup-name)]
2156 ["Import file..." gnus-summary-import-article t]
2157 ["Create article..." gnus-summary-create-article t]
2158 ["Check if posted" gnus-summary-article-posted-p t]
2159 ["Edit article" gnus-summary-edit-article
2160 (not (gnus-group-read-only-p))]
2161 ["Delete article" gnus-summary-delete-article
2162 (gnus-check-backend-function
2163 'request-expire-articles gnus-newsgroup-name)]
2164 ["Query respool" gnus-summary-respool-query t]
2165 ["Trace respool" gnus-summary-respool-trace t]
2166 ["Delete expirable articles" gnus-summary-expire-articles-now
2167 (gnus-check-backend-function
2168 'request-expire-articles gnus-newsgroup-name)])
2170 ["Uudecode" gnus-uu-decode-uu
2171 ,@(if (featurep 'xemacs) '(t)
2172 '(:help "Decode uuencoded article(s)"))]
2173 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2174 ["Unshar" gnus-uu-decode-unshar t]
2175 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2176 ["Save" gnus-uu-decode-save t]
2177 ["Binhex" gnus-uu-decode-binhex t]
2178 ["Postscript" gnus-uu-decode-postscript t]
2179 ["All MIME parts" gnus-summary-save-parts t])
2181 ["Enter article" gnus-cache-enter-article t]
2182 ["Remove article" gnus-cache-remove-article t])
2183 ["Translate" gnus-article-babel t]
2184 ["Select article buffer" gnus-summary-select-article-buffer t]
2185 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2186 ["Isearch article..." gnus-summary-isearch-article t]
2187 ["Beginning of the article" gnus-summary-beginning-of-article t]
2188 ["End of the article" gnus-summary-end-of-article t]
2189 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2190 ["Fetch referenced articles" gnus-summary-refer-references t]
2191 ["Fetch current thread" gnus-summary-refer-thread t]
2192 ["Fetch article with id..." gnus-summary-refer-article t]
2193 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2194 ["Redisplay" gnus-summary-show-article t]
2195 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2197 gnus-summary-article-menu gnus-summary-mode-map ""
2198 (cons "Article" innards))
2200 (if (not (keymapp gnus-summary-article-menu))
2202 gnus-article-commands-menu gnus-article-mode-map ""
2203 (cons "Commands" innards))
2204 ;; in Emacs, don't share menu.
2205 (setq gnus-article-commands-menu
2206 (copy-keymap gnus-summary-article-menu))
2207 (define-key gnus-article-mode-map [menu-bar commands]
2208 (cons "Commands" gnus-article-commands-menu))))
2211 gnus-summary-thread-menu gnus-summary-mode-map ""
2213 ["Find all messages in thread" gnus-summary-refer-thread t]
2214 ["Toggle threading" gnus-summary-toggle-threads t]
2215 ["Hide threads" gnus-summary-hide-all-threads t]
2216 ["Show threads" gnus-summary-show-all-threads t]
2217 ["Hide thread" gnus-summary-hide-thread t]
2218 ["Show thread" gnus-summary-show-thread t]
2219 ["Go to next thread" gnus-summary-next-thread t]
2220 ["Go to previous thread" gnus-summary-prev-thread t]
2221 ["Go down thread" gnus-summary-down-thread t]
2222 ["Go up thread" gnus-summary-up-thread t]
2223 ["Top of thread" gnus-summary-top-thread t]
2224 ["Mark thread as read" gnus-summary-kill-thread t]
2225 ["Lower thread score" gnus-summary-lower-thread t]
2226 ["Raise thread score" gnus-summary-raise-thread t]
2227 ["Rethread current" gnus-summary-rethread-current t]))
2230 gnus-summary-post-menu gnus-summary-mode-map ""
2232 ["Send a message (mail or news)" gnus-summary-post-news
2233 ,@(if (featurep 'xemacs) '(t)
2234 '(:help "Post an article"))]
2235 ["Followup" gnus-summary-followup
2236 ,@(if (featurep 'xemacs) '(t)
2237 '(:help "Post followup to this article"))]
2238 ["Followup and yank" gnus-summary-followup-with-original
2239 ,@(if (featurep 'xemacs) '(t)
2240 '(:help "Post followup to this article, quoting its contents"))]
2241 ["Supersede article" gnus-summary-supersede-article t]
2242 ["Cancel article" gnus-summary-cancel-article
2243 ,@(if (featurep 'xemacs) '(t)
2244 '(:help "Cancel an article you posted"))]
2245 ["Reply" gnus-summary-reply t]
2246 ["Reply and yank" gnus-summary-reply-with-original t]
2247 ["Wide reply" gnus-summary-wide-reply t]
2248 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2249 ,@(if (featurep 'xemacs) '(t)
2250 '(:help "Mail a reply, quoting this article"))]
2251 ["Very wide reply" gnus-summary-very-wide-reply t]
2252 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2253 ,@(if (featurep 'xemacs) '(t)
2254 '(:help "Mail a very wide reply, quoting this article"))]
2255 ["Mail forward" gnus-summary-mail-forward t]
2256 ["Post forward" gnus-summary-post-forward t]
2257 ["Digest and mail" gnus-uu-digest-mail-forward t]
2258 ["Digest and post" gnus-uu-digest-post-forward t]
2259 ["Resend message" gnus-summary-resend-message t]
2260 ["Resend message edit" gnus-summary-resend-message-edit t]
2261 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2262 ["Send a mail" gnus-summary-mail-other-window t]
2263 ["Create a local message" gnus-summary-news-other-window t]
2264 ["Uuencode and post" gnus-uu-post-news
2265 ,@(if (featurep 'xemacs) '(t)
2266 '(:help "Post a uuencoded article"))]
2267 ["Followup via news" gnus-summary-followup-to-mail t]
2268 ["Followup via news and yank"
2269 gnus-summary-followup-to-mail-with-original t]
2271 ;;["Send" gnus-summary-send-draft t]
2272 ;;["Send bounced" gnus-resend-bounced-mail t])
2276 ((not (keymapp gnus-summary-post-menu))
2277 (setq gnus-article-post-menu gnus-summary-post-menu))
2278 ((not gnus-article-post-menu)
2279 ;; Don't share post menu.
2280 (setq gnus-article-post-menu
2281 (copy-keymap gnus-summary-post-menu))))
2282 (define-key gnus-article-mode-map [menu-bar post]
2283 (cons "Post" gnus-article-post-menu))
2286 gnus-summary-misc-menu gnus-summary-mode-map ""
2289 ["Mark as read" gnus-summary-mark-as-read-forward t]
2290 ["Mark same subject and select"
2291 gnus-summary-kill-same-subject-and-select t]
2292 ["Mark same subject" gnus-summary-kill-same-subject t]
2293 ["Catchup" gnus-summary-catchup
2294 ,@(if (featurep 'xemacs) '(t)
2295 '(:help "Mark unread articles in this group as read"))]
2296 ["Catchup all" gnus-summary-catchup-all t]
2297 ["Catchup to here" gnus-summary-catchup-to-here t]
2298 ["Catchup from here" gnus-summary-catchup-from-here t]
2299 ["Catchup region" gnus-summary-mark-region-as-read
2300 (gnus-mark-active-p)]
2301 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2303 ["Tick" gnus-summary-tick-article-forward t]
2304 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2305 ["Remove marks" gnus-summary-clear-mark-forward t]
2306 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2307 ["Set bookmark" gnus-summary-set-bookmark t]
2308 ["Remove bookmark" gnus-summary-remove-bookmark t])
2310 ["Marks..." gnus-summary-limit-to-marks t]
2311 ["Subject..." gnus-summary-limit-to-subject t]
2312 ["Author..." gnus-summary-limit-to-author t]
2313 ["Age..." gnus-summary-limit-to-age t]
2314 ["Extra..." gnus-summary-limit-to-extra t]
2315 ["Score..." gnus-summary-limit-to-score t]
2316 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2317 ["Unread" gnus-summary-limit-to-unread t]
2318 ["Unseen" gnus-summary-limit-to-unseen t]
2319 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2320 ["Next articles" gnus-summary-limit-to-articles t]
2321 ["Pop limit" gnus-summary-pop-limit t]
2322 ["Show dormant" gnus-summary-limit-include-dormant t]
2323 ["Hide childless dormant"
2324 gnus-summary-limit-exclude-childless-dormant t]
2325 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2326 ["Hide marked" gnus-summary-limit-exclude-marks t]
2327 ["Show expunged" gnus-summary-limit-include-expunged t])
2329 ["Set mark" gnus-summary-mark-as-processable t]
2330 ["Remove mark" gnus-summary-unmark-as-processable t]
2331 ["Remove all marks" gnus-summary-unmark-all-processable t]
2332 ["Mark above" gnus-uu-mark-over t]
2333 ["Mark series" gnus-uu-mark-series t]
2334 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2335 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2336 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2337 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2338 ["Mark all" gnus-uu-mark-all t]
2339 ["Mark buffer" gnus-uu-mark-buffer t]
2340 ["Mark sparse" gnus-uu-mark-sparse t]
2341 ["Mark thread" gnus-uu-mark-thread t]
2342 ["Unmark thread" gnus-uu-unmark-thread t]
2343 ("Process Mark Sets"
2344 ["Kill" gnus-summary-kill-process-mark t]
2345 ["Yank" gnus-summary-yank-process-mark
2346 gnus-newsgroup-process-stack]
2347 ["Save" gnus-summary-save-process-mark t]))
2349 ["Page forward" gnus-summary-next-page
2350 ,@(if (featurep 'xemacs) '(t)
2351 '(:help "Show next page of article"))]
2352 ["Page backward" gnus-summary-prev-page
2353 ,@(if (featurep 'xemacs) '(t)
2354 '(:help "Show previous page of article"))]
2355 ["Line forward" gnus-summary-scroll-up t])
2357 ["Next unread article" gnus-summary-next-unread-article t]
2358 ["Previous unread article" gnus-summary-prev-unread-article t]
2359 ["Next article" gnus-summary-next-article t]
2360 ["Previous article" gnus-summary-prev-article t]
2361 ["Next unread subject" gnus-summary-next-unread-subject t]
2362 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2363 ["Next article same subject" gnus-summary-next-same-subject t]
2364 ["Previous article same subject" gnus-summary-prev-same-subject t]
2365 ["First unread article" gnus-summary-first-unread-article t]
2366 ["Best unread article" gnus-summary-best-unread-article t]
2367 ["Go to subject number..." gnus-summary-goto-subject t]
2368 ["Go to article number..." gnus-summary-goto-article t]
2369 ["Go to the last article" gnus-summary-goto-last-article t]
2370 ["Pop article off history" gnus-summary-pop-article t])
2372 ["Sort by number" gnus-summary-sort-by-number t]
2373 ["Sort by author" gnus-summary-sort-by-author t]
2374 ["Sort by subject" gnus-summary-sort-by-subject t]
2375 ["Sort by date" gnus-summary-sort-by-date t]
2376 ["Sort by score" gnus-summary-sort-by-score t]
2377 ["Sort by lines" gnus-summary-sort-by-lines t]
2378 ["Sort by characters" gnus-summary-sort-by-chars t]
2379 ["Randomize" gnus-summary-sort-by-random t]
2380 ["Original sort" gnus-summary-sort-by-original t])
2382 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2383 ["Describe group" gnus-summary-describe-group t]
2384 ["Fetch charter" gnus-group-fetch-charter
2385 ,@(if (featurep 'xemacs) nil
2386 '(:help "Display the charter of the current group"))]
2387 ["Fetch control message" gnus-group-fetch-control
2388 ,@(if (featurep 'xemacs) nil
2389 '(:help "Display the archived control message for the current group"))]
2390 ["Read manual" gnus-info-find-node t])
2392 ["Pick and read" gnus-pick-mode t]
2393 ["Binary" gnus-binary-mode t])
2395 ["Regenerate" gnus-summary-prepare t]
2396 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2397 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2398 ["Toggle threading" gnus-summary-toggle-threads t])
2399 ["See old articles" gnus-summary-insert-old-articles t]
2400 ["See new articles" gnus-summary-insert-new-articles t]
2401 ["Filter articles..." gnus-summary-execute-command t]
2402 ["Run command on subjects..." gnus-summary-universal-argument t]
2403 ["Search articles forward..." gnus-summary-search-article-forward t]
2404 ["Search articles backward..." gnus-summary-search-article-backward t]
2405 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2406 ["Expand window" gnus-summary-expand-window t]
2407 ["Expire expirable articles" gnus-summary-expire-articles
2408 (gnus-check-backend-function
2409 'request-expire-articles gnus-newsgroup-name)]
2410 ["Edit local kill file" gnus-summary-edit-local-kill t]
2411 ["Edit main kill file" gnus-summary-edit-global-kill t]
2412 ["Edit group parameters" gnus-summary-edit-parameters t]
2413 ["Customize group parameters" gnus-summary-customize-parameters t]
2414 ["Send a bug report" gnus-bug t]
2416 ["Catchup and exit" gnus-summary-catchup-and-exit
2417 ,@(if (featurep 'xemacs) '(t)
2418 '(:help "Mark unread articles in this group as read, then exit"))]
2419 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2420 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2421 ["Exit group" gnus-summary-exit
2422 ,@(if (featurep 'xemacs) '(t)
2423 '(:help "Exit current group, return to group selection mode"))]
2424 ["Exit group without updating" gnus-summary-exit-no-update t]
2425 ["Exit and goto next group" gnus-summary-next-group t]
2426 ["Exit and goto prev group" gnus-summary-prev-group t]
2427 ["Reselect group" gnus-summary-reselect-current-group t]
2428 ["Rescan group" gnus-summary-rescan-group t]
2429 ["Update dribble" gnus-summary-save-newsrc t])))
2431 (gnus-run-hooks 'gnus-summary-menu-hook)))
2433 (defvar gnus-summary-tool-bar-map nil)
2435 ;; Emacs 21 tool bar. Should be no-op otherwise.
2436 (defun gnus-summary-make-tool-bar ()
2437 (if (and (fboundp 'tool-bar-add-item-from-menu)
2438 (default-value 'tool-bar-mode)
2439 (not gnus-summary-tool-bar-map))
2440 (setq gnus-summary-tool-bar-map
2441 (let ((tool-bar-map (make-sparse-keymap))
2442 (load-path (mm-image-load-path)))
2443 (tool-bar-add-item-from-menu
2444 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2445 (tool-bar-add-item-from-menu
2446 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2447 (tool-bar-add-item-from-menu
2448 'gnus-summary-post-news "post" gnus-summary-mode-map)
2449 (tool-bar-add-item-from-menu
2450 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2451 (tool-bar-add-item-from-menu
2452 'gnus-summary-followup "followup" gnus-summary-mode-map)
2453 (tool-bar-add-item-from-menu
2454 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2455 (tool-bar-add-item-from-menu
2456 'gnus-summary-reply "reply" gnus-summary-mode-map)
2457 (tool-bar-add-item-from-menu
2458 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2459 (tool-bar-add-item-from-menu
2460 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2461 (tool-bar-add-item-from-menu
2462 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2463 (tool-bar-add-item-from-menu
2464 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2465 (tool-bar-add-item-from-menu
2466 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2467 (tool-bar-add-item-from-menu
2468 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2469 (tool-bar-add-item-from-menu
2470 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2471 (tool-bar-add-item-from-menu
2472 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2474 (if gnus-summary-tool-bar-map
2475 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2477 (defun gnus-score-set-default (var value)
2478 "A version of set that updates the GNU Emacs menu-bar."
2480 ;; It is the message that forces the active status to be updated.
2483 (defun gnus-make-score-map (type)
2484 "Make a summary score map of type TYPE."
2487 (let ((headers '(("author" "from" string)
2488 ("subject" "subject" string)
2489 ("article body" "body" string)
2490 ("article head" "head" string)
2491 ("xref" "xref" string)
2492 ("extra header" "extra" string)
2493 ("lines" "lines" number)
2494 ("followups to author" "followup" string)))
2495 (types '((number ("less than" <)
2498 (string ("substring" s)
2502 (perms '(("temporary" (current-time-string))
2510 (if (eq type 'lower)
2515 (setq header (car headers))
2521 (let ((ts (cdr (assoc (nth 2 header) types)))
2537 'gnus-summary-score-entry
2539 (if (or (string= (nth 1 header)
2541 (string= (nth 1 header)
2544 (list 'gnus-summary-header
2546 (list 'quote (nth 1 (car ts)))
2547 (list 'gnus-score-delta-default
2554 (list (nreverse outp))))
2557 (list (nreverse outt))))
2559 (setq headers (cdr headers)))
2560 (list (nreverse outh))))))))
2564 (defun gnus-summary-mode (&optional group)
2565 "Major mode for reading articles.
2567 All normal editing commands are switched off.
2568 \\<gnus-summary-mode-map>
2569 Each line in this buffer represents one article. To read an
2570 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2571 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2574 You can also post articles and send mail from this buffer. To
2575 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2576 of an article, type `\\[gnus-summary-reply]'.
2578 There are approx. one gazillion commands you can execute in this
2579 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2581 The following commands are available:
2583 \\{gnus-summary-mode-map}"
2585 (kill-all-local-variables)
2586 (when (gnus-visual-p 'summary-menu 'menu)
2587 (gnus-summary-make-menu-bar)
2588 (gnus-summary-make-tool-bar))
2589 (gnus-summary-make-local-variables)
2590 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2591 (gnus-summary-make-local-variables))
2592 (gnus-make-thread-indent-array)
2593 (gnus-simplify-mode-line)
2594 (setq major-mode 'gnus-summary-mode)
2595 (setq mode-name "Summary")
2596 (make-local-variable 'minor-mode-alist)
2597 (use-local-map gnus-summary-mode-map)
2598 (buffer-disable-undo)
2599 (setq buffer-read-only t) ;Disable modification
2600 (setq truncate-lines t)
2601 (setq selective-display t)
2602 (setq selective-display-ellipses t) ;Display `...'
2603 (gnus-summary-set-display-table)
2604 (gnus-set-default-directory)
2605 (setq gnus-newsgroup-name group)
2606 (make-local-variable 'gnus-summary-line-format)
2607 (make-local-variable 'gnus-summary-line-format-spec)
2608 (make-local-variable 'gnus-summary-dummy-line-format)
2609 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2610 (make-local-variable 'gnus-summary-mark-positions)
2611 (make-local-hook 'pre-command-hook)
2612 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2613 (gnus-run-hooks 'gnus-summary-mode-hook)
2614 (turn-on-gnus-mailing-list-mode)
2615 (mm-enable-multibyte)
2616 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2617 (gnus-update-summary-mark-positions))
2619 (defun gnus-summary-make-local-variables ()
2620 "Make all the local summary buffer variables."
2622 (dolist (local gnus-summary-local-variables)
2625 (if (eq (cdr local) 'global)
2626 ;; Copy the global value of the variable.
2627 (setq global (symbol-value (car local)))
2628 ;; Use the value from the list.
2629 (setq global (eval (cdr local))))
2630 (set (make-local-variable (car local)) global))
2631 ;; Simple nil-valued local variable.
2632 (set (make-local-variable local) nil)))))
2634 (defun gnus-summary-clear-local-variables ()
2635 (let ((locals gnus-summary-local-variables))
2637 (if (consp (car locals))
2638 (and (vectorp (caar locals))
2639 (set (caar locals) nil))
2640 (and (vectorp (car locals))
2641 (set (car locals) nil)))
2642 (setq locals (cdr locals)))))
2644 ;; Summary data functions.
2646 (defmacro gnus-data-number (data)
2649 (defmacro gnus-data-set-number (data number)
2650 `(setcar ,data ,number))
2652 (defmacro gnus-data-mark (data)
2655 (defmacro gnus-data-set-mark (data mark)
2656 `(setcar (nthcdr 1 ,data) ,mark))
2658 (defmacro gnus-data-pos (data)
2661 (defmacro gnus-data-set-pos (data pos)
2662 `(setcar (nthcdr 2 ,data) ,pos))
2664 (defmacro gnus-data-header (data)
2667 (defmacro gnus-data-set-header (data header)
2668 `(setf (nth 3 ,data) ,header))
2670 (defmacro gnus-data-level (data)
2673 (defmacro gnus-data-unread-p (data)
2674 `(= (nth 1 ,data) gnus-unread-mark))
2676 (defmacro gnus-data-read-p (data)
2677 `(/= (nth 1 ,data) gnus-unread-mark))
2679 (defmacro gnus-data-pseudo-p (data)
2680 `(consp (nth 3 ,data)))
2682 (defmacro gnus-data-find (number)
2683 `(assq ,number gnus-newsgroup-data))
2685 (defmacro gnus-data-find-list (number &optional data)
2686 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2687 (memq (assq ,number bdata)
2690 (defmacro gnus-data-make (number mark pos header level)
2691 `(list ,number ,mark ,pos ,header ,level))
2693 (defun gnus-data-enter (after-article number mark pos header level offset)
2694 (let ((data (gnus-data-find-list after-article)))
2696 (error "No such article: %d" after-article))
2697 (setcdr data (cons (gnus-data-make number mark pos header level)
2699 (setq gnus-newsgroup-data-reverse nil)
2700 (gnus-data-update-list (cddr data) offset)))
2702 (defun gnus-data-enter-list (after-article list &optional offset)
2704 (let ((data (and after-article (gnus-data-find-list after-article)))
2708 (let ((odata gnus-newsgroup-data))
2709 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2711 (gnus-data-update-list odata offset)))
2712 ;; Find the last element in the list to be spliced into the main
2715 (setq list (cdr list)))
2718 (setcdr list gnus-newsgroup-data)
2719 (setq gnus-newsgroup-data ilist)
2721 (gnus-data-update-list (cdr list) offset)))
2722 (setcdr list (cdr data))
2725 (gnus-data-update-list (cdr list) offset))))
2726 (setq gnus-newsgroup-data-reverse nil))))
2728 (defun gnus-data-remove (article &optional offset)
2729 (let ((data gnus-newsgroup-data))
2730 (if (= (gnus-data-number (car data)) article)
2732 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2733 gnus-newsgroup-data-reverse nil)
2735 (gnus-data-update-list gnus-newsgroup-data offset)))
2737 (when (= (gnus-data-number (cadr data)) article)
2738 (setcdr data (cddr data))
2740 (gnus-data-update-list (cdr data) offset))
2742 gnus-newsgroup-data-reverse nil))
2743 (setq data (cdr data))))))
2745 (defmacro gnus-data-list (backward)
2747 (or gnus-newsgroup-data-reverse
2748 (setq gnus-newsgroup-data-reverse
2749 (reverse gnus-newsgroup-data)))
2750 gnus-newsgroup-data))
2752 (defun gnus-data-update-list (data offset)
2753 "Add OFFSET to the POS of all data entries in DATA."
2754 (setq gnus-newsgroup-data-reverse nil)
2756 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2757 (setq data (cdr data))))
2759 (defun gnus-summary-article-pseudo-p (article)
2760 "Say whether this article is a pseudo article or not."
2761 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2763 (defmacro gnus-summary-article-sparse-p (article)
2764 "Say whether this article is a sparse article or not."
2765 `(memq ,article gnus-newsgroup-sparse))
2767 (defmacro gnus-summary-article-ancient-p (article)
2768 "Say whether this article is a sparse article or not."
2769 `(memq ,article gnus-newsgroup-ancient))
2771 (defun gnus-article-parent-p (number)
2772 "Say whether this article is a parent or not."
2773 (let ((data (gnus-data-find-list number)))
2774 (and (cdr data) ; There has to be an article after...
2775 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2776 (gnus-data-level (nth 1 data))))))
2778 (defun gnus-article-children (number)
2779 "Return a list of all children to NUMBER."
2780 (let* ((data (gnus-data-find-list number))
2781 (level (gnus-data-level (car data)))
2783 (setq data (cdr data))
2785 (= (gnus-data-level (car data)) (1+ level)))
2786 (push (gnus-data-number (car data)) children)
2787 (setq data (cdr data)))
2790 (defmacro gnus-summary-skip-intangible ()
2791 "If the current article is intangible, then jump to a different article."
2792 '(let ((to (get-text-property (point) 'gnus-intangible)))
2793 (and to (gnus-summary-goto-subject to))))
2795 (defmacro gnus-summary-article-intangible-p ()
2796 "Say whether this article is intangible or not."
2797 '(get-text-property (point) 'gnus-intangible))
2799 (defun gnus-article-read-p (article)
2800 "Say whether ARTICLE is read or not."
2801 (not (or (memq article gnus-newsgroup-marked)
2802 (memq article gnus-newsgroup-spam-marked)
2803 (memq article gnus-newsgroup-unreads)
2804 (memq article gnus-newsgroup-unselected)
2805 (memq article gnus-newsgroup-dormant))))
2807 ;; Some summary mode macros.
2809 (defmacro gnus-summary-article-number ()
2810 "The article number of the article on the current line.
2811 If there isn't an article number here, then we return the current
2814 (gnus-summary-skip-intangible)
2815 (or (get-text-property (point) 'gnus-number)
2816 (gnus-summary-last-subject))))
2818 (defmacro gnus-summary-article-header (&optional number)
2819 "Return the header of article NUMBER."
2820 `(gnus-data-header (gnus-data-find
2821 ,(or number '(gnus-summary-article-number)))))
2823 (defmacro gnus-summary-thread-level (&optional number)
2824 "Return the level of thread that starts with article NUMBER."
2825 `(if (and (eq gnus-summary-make-false-root 'dummy)
2826 (get-text-property (point) 'gnus-intangible))
2828 (gnus-data-level (gnus-data-find
2829 ,(or number '(gnus-summary-article-number))))))
2831 (defmacro gnus-summary-article-mark (&optional number)
2832 "Return the mark of article NUMBER."
2833 `(gnus-data-mark (gnus-data-find
2834 ,(or number '(gnus-summary-article-number)))))
2836 (defmacro gnus-summary-article-pos (&optional number)
2837 "Return the position of the line of article NUMBER."
2838 `(gnus-data-pos (gnus-data-find
2839 ,(or number '(gnus-summary-article-number)))))
2841 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2842 (defmacro gnus-summary-article-subject (&optional number)
2843 "Return current subject string or nil if nothing."
2846 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2847 '(gnus-data-header (assq (gnus-summary-article-number)
2848 gnus-newsgroup-data)))))
2851 (mail-header-subject headers))))
2853 (defmacro gnus-summary-article-score (&optional number)
2854 "Return current article score."
2855 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2856 gnus-newsgroup-scored))
2857 gnus-summary-default-score 0))
2859 (defun gnus-summary-article-children (&optional number)
2860 "Return a list of article numbers that are children of article NUMBER."
2861 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2862 (level (gnus-data-level (car data)))
2864 (while (and (setq data (cdr data))
2865 (> (setq l (gnus-data-level (car data))) level))
2866 (and (= (1+ level) l)
2867 (push (gnus-data-number (car data))
2869 (nreverse children)))
2871 (defun gnus-summary-article-parent (&optional number)
2872 "Return the article number of the parent of article NUMBER."
2873 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2874 (gnus-data-list t)))
2875 (level (gnus-data-level (car data))))
2877 () ; This is a root.
2878 ;; We search until we find an article with a level less than
2879 ;; this one. That function has to be the parent.
2880 (while (and (setq data (cdr data))
2881 (not (< (gnus-data-level (car data)) level))))
2882 (and data (gnus-data-number (car data))))))
2884 (defun gnus-unread-mark-p (mark)
2885 "Say whether MARK is the unread mark."
2886 (= mark gnus-unread-mark))
2888 (defun gnus-read-mark-p (mark)
2889 "Say whether MARK is one of the marks that mark as read.
2890 This is all marks except unread, ticked, dormant, and expirable."
2891 (not (or (= mark gnus-unread-mark)
2892 (= mark gnus-ticked-mark)
2893 (= mark gnus-spam-mark)
2894 (= mark gnus-dormant-mark)
2895 (= mark gnus-expirable-mark))))
2897 (defmacro gnus-article-mark (number)
2898 "Return the MARK of article NUMBER.
2899 This macro should only be used when computing the mark the \"first\"
2900 time; i.e., when generating the summary lines. After that,
2901 `gnus-summary-article-mark' should be used to examine the
2904 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2905 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2906 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2907 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2908 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2909 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2910 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2911 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2912 gnus-ancient-mark))))
2914 ;; Saving hidden threads.
2916 (defmacro gnus-save-hidden-threads (&rest forms)
2917 "Save hidden threads, eval FORMS, and restore the hidden threads."
2918 (let ((config (make-symbol "config")))
2919 `(let ((,config (gnus-hidden-threads-configuration)))
2923 (gnus-restore-hidden-threads-configuration ,config)))))
2924 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2925 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2927 (defun gnus-data-compute-positions ()
2928 "Compute the positions of all articles."
2929 (setq gnus-newsgroup-data-reverse nil)
2930 (let ((data gnus-newsgroup-data))
2932 (gnus-save-hidden-threads
2933 (gnus-summary-show-all-threads)
2934 (goto-char (point-min))
2936 (while (get-text-property (point) 'gnus-intangible)
2938 (gnus-data-set-pos (car data) (+ (point) 3))
2939 (setq data (cdr data))
2940 (forward-line 1))))))
2942 (defun gnus-hidden-threads-configuration ()
2943 "Return the current hidden threads configuration."
2946 (goto-char (point-min))
2947 (while (search-forward "\r" nil t)
2948 (push (1- (point)) config))
2951 (defun gnus-restore-hidden-threads-configuration (config)
2952 "Restore hidden threads configuration from CONFIG."
2954 (let (point buffer-read-only)
2955 (while (setq point (pop config))
2956 (when (and (< point (point-max))
2958 (eq (char-after) ?\n))
2959 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2961 ;; Various summary mode internalish functions.
2963 (defun gnus-mouse-pick-article (e)
2966 (gnus-summary-next-page nil t))
2968 (defun gnus-summary-set-display-table ()
2969 "Change the display table.
2970 Odd characters have a tendency to mess
2971 up nicely formatted displays - we make all possible glyphs
2972 display only a single character."
2974 ;; We start from the standard display table, if any.
2975 (let ((table (or (copy-sequence standard-display-table)
2976 (make-display-table)))
2978 ;; Nix out all the control chars...
2979 (while (>= (setq i (1- i)) 0)
2980 (aset table i [??]))
2981 ;; ... but not newline and cr, of course. (cr is necessary for the
2982 ;; selective display).
2983 (aset table ?\n nil)
2984 (aset table ?\r nil)
2985 ;; We keep TAB as well.
2986 (aset table ?\t nil)
2987 ;; We nix out any glyphs over 126 that are not set already.
2989 (while (>= (setq i (1- i)) 127)
2990 ;; Only modify if the entry is nil.
2991 (unless (aref table i)
2992 (aset table i [??]))))
2993 (setq buffer-display-table table)))
2995 (defun gnus-summary-set-article-display-arrow (pos)
2996 "Update the overlay arrow to point to line at position POS."
2997 (when (and gnus-summary-display-arrow
2998 (boundp 'overlay-arrow-position)
2999 (boundp 'overlay-arrow-string))
3003 (unless overlay-arrow-position
3004 (setq overlay-arrow-position (make-marker)))
3005 (setq overlay-arrow-string "=>"
3006 overlay-arrow-position (set-marker overlay-arrow-position
3008 (current-buffer))))))
3010 (defun gnus-summary-buffer-name (group)
3011 "Return the summary buffer name of GROUP."
3012 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3014 (defun gnus-summary-setup-buffer (group)
3015 "Initialize summary buffer."
3016 (let ((buffer (gnus-summary-buffer-name group))
3017 (dead-name (concat "*Dead Summary "
3018 (gnus-group-decoded-name group) "*")))
3019 ;; If a dead summary buffer exists, we kill it.
3020 (when (gnus-buffer-live-p dead-name)
3021 (gnus-kill-buffer dead-name))
3022 (if (get-buffer buffer)
3025 (setq gnus-summary-buffer (current-buffer))
3026 (not gnus-newsgroup-prepared))
3027 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3028 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3029 (gnus-summary-mode group)
3031 (gnus-carpal-setup-buffer 'summary))
3032 (unless gnus-single-article-buffer
3033 (make-local-variable 'gnus-article-buffer)
3034 (make-local-variable 'gnus-article-current)
3035 (make-local-variable 'gnus-original-article-buffer))
3036 (setq gnus-newsgroup-name group)
3037 ;; Set any local variables in the group parameters.
3038 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3041 (defun gnus-set-global-variables ()
3042 "Set the global equivalents of the buffer-local variables.
3043 They are set to the latest values they had. These reflect the summary
3044 buffer that was in action when the last article was fetched."
3045 (when (eq major-mode 'gnus-summary-mode)
3046 (setq gnus-summary-buffer (current-buffer))
3047 (let ((name gnus-newsgroup-name)
3048 (marked gnus-newsgroup-marked)
3049 (spam gnus-newsgroup-spam-marked)
3050 (unread gnus-newsgroup-unreads)
3051 (headers gnus-current-headers)
3052 (data gnus-newsgroup-data)
3053 (summary gnus-summary-buffer)
3054 (article-buffer gnus-article-buffer)
3055 (original gnus-original-article-buffer)
3056 (gac gnus-article-current)
3057 (reffed gnus-reffed-article-number)
3058 (score-file gnus-current-score-file)
3059 (default-charset gnus-newsgroup-charset)
3061 (let ((locals gnus-newsgroup-variables))
3063 (if (consp (car locals))
3064 (push (eval (caar locals)) vlist)
3065 (push (eval (car locals)) vlist))
3066 (setq locals (cdr locals)))
3067 (setq vlist (nreverse vlist)))
3069 (set-buffer gnus-group-buffer)
3070 (setq gnus-newsgroup-name name
3071 gnus-newsgroup-marked marked
3072 gnus-newsgroup-spam-marked spam
3073 gnus-newsgroup-unreads unread
3074 gnus-current-headers headers
3075 gnus-newsgroup-data data
3076 gnus-article-current gac
3077 gnus-summary-buffer summary
3078 gnus-article-buffer article-buffer
3079 gnus-original-article-buffer original
3080 gnus-reffed-article-number reffed
3081 gnus-current-score-file score-file
3082 gnus-newsgroup-charset default-charset)
3083 (let ((locals gnus-newsgroup-variables))
3085 (if (consp (car locals))
3086 (set (caar locals) (pop vlist))
3087 (set (car locals) (pop vlist)))
3088 (setq locals (cdr locals))))
3089 ;; The article buffer also has local variables.
3090 (when (gnus-buffer-live-p gnus-article-buffer)
3091 (set-buffer gnus-article-buffer)
3092 (setq gnus-summary-buffer summary))))))
3094 (defun gnus-summary-article-unread-p (article)
3095 "Say whether ARTICLE is unread or not."
3096 (memq article gnus-newsgroup-unreads))
3098 (defun gnus-summary-first-article-p (&optional article)
3099 "Return whether ARTICLE is the first article in the buffer."
3100 (if (not (setq article (or article (gnus-summary-article-number))))
3102 (eq article (caar gnus-newsgroup-data))))
3104 (defun gnus-summary-last-article-p (&optional article)
3105 "Return whether ARTICLE is the last article in the buffer."
3106 (if (not (setq article (or article (gnus-summary-article-number))))
3107 ;; All non-existent numbers are the last article. :-)
3109 (not (cdr (gnus-data-find-list article)))))
3111 (defun gnus-make-thread-indent-array ()
3113 (unless (and gnus-thread-indent-array
3114 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3115 (setq gnus-thread-indent-array (make-vector 201 "")
3116 gnus-thread-indent-array-level gnus-thread-indent-level)
3118 (aset gnus-thread-indent-array n
3119 (make-string (* n gnus-thread-indent-level) ? ))
3122 (defun gnus-update-summary-mark-positions ()
3123 "Compute where the summary marks are to go."
3125 (when (gnus-buffer-exists-p gnus-summary-buffer)
3126 (set-buffer gnus-summary-buffer))
3127 (let ((gnus-replied-mark 129)
3128 (gnus-score-below-mark 130)
3129 (gnus-score-over-mark 130)
3130 (gnus-undownloaded-mark 131)
3131 (spec gnus-summary-line-format-spec)
3134 (gnus-set-work-buffer)
3135 (let ((gnus-summary-line-format-spec spec)
3136 (gnus-newsgroup-downloadable '(0)))
3137 (gnus-summary-insert-line
3138 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3139 0 nil t 128 t nil "" nil 1)
3140 (goto-char (point-min))
3141 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3142 (- (point) (point-min) 1)))))
3143 (goto-char (point-min))
3144 (push (cons 'replied (and (search-forward "\201" nil t)
3145 (- (point) (point-min) 1)))
3147 (goto-char (point-min))
3148 (push (cons 'score (and (search-forward "\202" nil t)
3149 (- (point) (point-min) 1)))
3151 (goto-char (point-min))
3152 (push (cons 'download
3153 (and (search-forward "\203" nil t)
3154 (- (point) (point-min) 1)))
3156 (setq gnus-summary-mark-positions pos))))
3158 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3159 "Insert a dummy root in the summary buffer."
3161 (gnus-add-text-properties
3162 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3163 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3165 (defun gnus-summary-extract-address-component (from)
3166 (or (car (funcall gnus-extract-address-components from))
3169 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3170 (let ((mail-parse-charset gnus-newsgroup-charset)
3171 ; Is it really necessary to do this next part for each summary line?
3172 ; Luckily, doesn't seem to slow things down much.
3173 (mail-parse-ignored-charsets
3174 (save-excursion (set-buffer gnus-summary-buffer)
3175 gnus-newsgroup-ignored-charsets)))
3177 (and gnus-ignored-from-addresses
3178 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3179 (let ((extra-headers (mail-header-extra header))
3183 ((setq to (cdr (assq 'To extra-headers)))
3186 (gnus-summary-extract-address-component
3187 (funcall gnus-decode-encoded-word-function to)))))
3188 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3189 (concat "=> " newsgroups)))))
3190 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3192 (defun gnus-summary-insert-line (gnus-tmp-header
3193 gnus-tmp-level gnus-tmp-current
3194 undownloaded gnus-tmp-unread gnus-tmp-replied
3195 gnus-tmp-expirable gnus-tmp-subject-or-nil
3196 &optional gnus-tmp-dummy gnus-tmp-score
3198 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3199 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3200 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3201 (gnus-tmp-score-char
3202 (if (or (null gnus-summary-default-score)
3203 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3204 gnus-summary-zcore-fuzz))
3206 (if (< gnus-tmp-score gnus-summary-default-score)
3207 gnus-score-below-mark gnus-score-over-mark)))
3208 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3210 (cond (gnus-tmp-process gnus-process-mark)
3211 ((memq gnus-tmp-current gnus-newsgroup-cached)
3213 (gnus-tmp-replied gnus-replied-mark)
3214 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3215 gnus-forwarded-mark)
3216 ((memq gnus-tmp-current gnus-newsgroup-saved)
3218 ((memq gnus-tmp-number gnus-newsgroup-recent)
3220 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3223 (gnus-tmp-downloaded
3225 gnus-undownloaded-mark)
3226 (gnus-newsgroup-agentized
3227 gnus-downloaded-mark)
3230 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3233 ((string-match "<[^>]+> *$" gnus-tmp-from)
3234 (let ((beg (match-beginning 0)))
3235 (or (and (string-match "^\".+\"" gnus-tmp-from)
3236 (substring gnus-tmp-from 1 (1- (match-end 0))))
3237 (substring gnus-tmp-from 0 beg))))
3238 ((string-match "(.+)" gnus-tmp-from)
3239 (substring gnus-tmp-from
3240 (1+ (match-beginning 0)) (1- (match-end 0))))
3242 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3243 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3244 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3245 (buffer-read-only nil))
3246 (when (string= gnus-tmp-name "")
3247 (setq gnus-tmp-name gnus-tmp-from))
3248 (unless (numberp gnus-tmp-lines)
3249 (setq gnus-tmp-lines -1))
3250 (if (= gnus-tmp-lines -1)
3251 (setq gnus-tmp-lines "?")
3252 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3253 (gnus-put-text-property
3255 (progn (eval gnus-summary-line-format-spec) (point))
3256 'gnus-number gnus-tmp-number)
3257 (when (gnus-visual-p 'summary-highlight 'highlight)
3259 (gnus-run-hooks 'gnus-summary-update-hook)
3262 (defun gnus-summary-update-line (&optional dont-update)
3263 "Update summary line after change."
3264 (when (and gnus-summary-default-score
3265 (not gnus-summary-inhibit-highlight))
3266 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3267 (article (gnus-summary-article-number))
3268 (score (gnus-summary-article-score article)))
3270 (if (and gnus-summary-mark-below
3271 (< (gnus-summary-article-score)
3272 gnus-summary-mark-below))
3273 ;; This article has a low score, so we mark it as read.
3274 (when (memq article gnus-newsgroup-unreads)
3275 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3276 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3277 ;; This article was previously marked as read on account
3278 ;; of a low score, but now it has risen, so we mark it as
3280 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3281 (gnus-summary-update-mark
3282 (if (or (null gnus-summary-default-score)
3283 (<= (abs (- score gnus-summary-default-score))
3284 gnus-summary-zcore-fuzz))
3286 (if (< score gnus-summary-default-score)
3287 gnus-score-below-mark gnus-score-over-mark))
3289 ;; Do visual highlighting.
3290 (when (gnus-visual-p 'summary-highlight 'highlight)
3291 (gnus-run-hooks 'gnus-summary-update-hook)))))
3293 (defvar gnus-tmp-new-adopts nil)
3295 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3296 "Return the number of articles in THREAD.
3297 This may be 0 in some cases -- if none of the articles in
3298 the thread are to be displayed."
3300 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3302 ((not (listp thread))
3304 ((and (consp thread) (cdr thread))
3307 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3310 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3313 (when (and level (zerop level) gnus-tmp-new-adopts)
3316 'gnus-summary-number-of-articles-in-thread
3317 gnus-tmp-new-adopts))))
3319 (if (> number 1) gnus-not-empty-thread-mark
3320 gnus-empty-thread-mark)
3323 (defsubst gnus-summary-line-message-size (head)
3324 "Return pretty-printed version of message size.
3325 This function is intended to be used in
3326 `gnus-summary-line-format-alist', which see."
3327 (let ((c (or (mail-header-chars head) -1)))
3328 (cond ((< c 0) "n/a") ; chars not available
3329 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3330 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3331 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3332 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3335 (defun gnus-summary-set-local-parameters (group)
3336 "Go through the local params of GROUP and set all variable specs in that list."
3337 (let ((params (gnus-group-find-parameter group))
3338 (vars '(quit-config)) ; Ignore quit-config.
3341 (setq elem (car params)
3342 params (cdr params))
3343 (and (consp elem) ; Has to be a cons.
3344 (consp (cdr elem)) ; The cdr has to be a list.
3345 (symbolp (car elem)) ; Has to be a symbol in there.
3346 (not (memq (car elem) vars))
3347 (ignore-errors ; So we set it.
3348 (push (car elem) vars)
3349 (make-local-variable (car elem))
3350 (set (car elem) (eval (nth 1 elem))))))))
3352 (defun gnus-summary-read-group (group &optional show-all no-article
3353 kill-buffer no-display backward
3355 "Start reading news in newsgroup GROUP.
3356 If SHOW-ALL is non-nil, already read articles are also listed.
3357 If NO-ARTICLE is non-nil, no article is selected initially.
3358 If NO-DISPLAY, don't generate a summary buffer."
3362 (let ((gnus-auto-select-next nil))
3363 (or (gnus-summary-read-group-1
3364 group show-all no-article
3365 kill-buffer no-display
3368 select-articles nil)))))
3369 (eq gnus-auto-select-next 'quietly))
3370 (set-buffer gnus-group-buffer)
3371 ;; The entry function called above goes to the next
3372 ;; group automatically, so we go two groups back
3373 ;; if we are searching for the previous group.
3375 (gnus-group-prev-unread-group 2))
3376 (if (not (equal group (gnus-group-group-name)))
3377 (setq group (gnus-group-group-name))
3381 (defun gnus-summary-read-group-1 (group show-all no-article
3382 kill-buffer no-display
3383 &optional select-articles)
3384 ;; Killed foreign groups can't be entered.
3385 ;; (when (and (not (gnus-group-native-p group))
3386 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3387 ;; (error "Dead non-native groups can't be entered"))
3388 (gnus-message 5 "Retrieving newsgroup: %s..."
3389 (gnus-group-decoded-name group))
3390 (let* ((new-group (gnus-summary-setup-buffer group))
3391 (quit-config (gnus-group-quit-config group))
3392 (did-select (and new-group (gnus-select-newsgroup
3393 group show-all select-articles))))
3395 ;; This summary buffer exists already, so we just select it.
3397 (gnus-set-global-variables)
3399 (gnus-kill-or-deaden-summary kill-buffer))
3400 (gnus-configure-windows 'summary 'force)
3401 (gnus-set-mode-line 'summary)
3402 (gnus-summary-position-point)
3405 ;; We couldn't select this group.
3407 (when (and (eq major-mode 'gnus-summary-mode)
3408 (not (equal (current-buffer) kill-buffer)))
3409 (kill-buffer (current-buffer))
3410 (if (not quit-config)
3412 ;; Update the info -- marks might need to be removed,
3414 (gnus-summary-update-info)
3415 (set-buffer gnus-group-buffer)
3416 (gnus-group-jump-to-group group)
3417 (gnus-group-next-unread-group 1))
3418 (gnus-handle-ephemeral-exit quit-config)))
3419 (let ((grpinfo (gnus-get-info group)))
3420 (if (null (gnus-info-read grpinfo))
3421 (gnus-message 3 "Group %s contains no messages"
3422 (gnus-group-decoded-name group))
3423 (gnus-message 3 "Can't select group")))
3425 ;; The user did a `C-g' while prompting for number of articles,
3426 ;; so we exit this group.
3427 ((eq did-select 'quit)
3428 (and (eq major-mode 'gnus-summary-mode)
3429 (not (equal (current-buffer) kill-buffer))
3430 (kill-buffer (current-buffer)))
3432 (gnus-kill-or-deaden-summary kill-buffer))
3433 (if (not quit-config)
3435 (set-buffer gnus-group-buffer)
3436 (gnus-group-jump-to-group group)
3437 (gnus-group-next-unread-group 1)
3438 (gnus-configure-windows 'group 'force))
3439 (gnus-handle-ephemeral-exit quit-config))
3440 ;; Finally signal the quit.
3442 ;; The group was successfully selected.
3444 (gnus-set-global-variables)
3445 ;; Save the active value in effect when the group was entered.
3446 (setq gnus-newsgroup-active
3448 (gnus-active gnus-newsgroup-name)))
3449 ;; You can change the summary buffer in some way with this hook.
3450 (gnus-run-hooks 'gnus-select-group-hook)
3451 (gnus-update-format-specifications
3452 nil 'summary 'summary-mode 'summary-dummy)
3453 (gnus-update-summary-mark-positions)
3454 ;; Do score processing.
3455 (when gnus-use-scoring
3456 (gnus-possibly-score-headers))
3457 ;; Check whether to fill in the gaps in the threads.
3458 (when gnus-build-sparse-threads
3459 (gnus-build-sparse-threads))
3460 ;; Find the initial limit.
3461 (if gnus-show-threads
3463 (let ((gnus-newsgroup-dormant nil))
3464 (gnus-summary-initial-limit show-all))
3465 (gnus-summary-initial-limit show-all))
3466 ;; When unthreaded, all articles are always shown.
3467 (setq gnus-newsgroup-limit
3469 (lambda (header) (mail-header-number header))
3470 gnus-newsgroup-headers)))
3471 ;; Generate the summary buffer.
3473 (gnus-summary-prepare))
3474 (when gnus-use-trees
3475 (gnus-tree-open group)
3476 (setq gnus-summary-highlight-line-function
3477 'gnus-tree-highlight-article))
3478 ;; If the summary buffer is empty, but there are some low-scored
3479 ;; articles or some excluded dormants, we include these in the
3481 (when (and (zerop (buffer-size))
3483 (cond (gnus-newsgroup-dormant
3484 (gnus-summary-limit-include-dormant))
3485 ((and gnus-newsgroup-scored show-all)
3486 (gnus-summary-limit-include-expunged t))))
3487 ;; Function `gnus-apply-kill-file' must be called in this hook.
3488 (gnus-run-hooks 'gnus-apply-kill-hook)
3489 (if (and (zerop (buffer-size))
3492 ;; This newsgroup is empty.
3493 (gnus-summary-catchup-and-exit nil t)
3494 (gnus-message 6 "No unread news")
3496 (gnus-kill-or-deaden-summary kill-buffer))
3497 ;; Return nil from this function.
3499 ;; Hide conversation thread subtrees. We cannot do this in
3500 ;; gnus-summary-prepare-hook since kill processing may not
3501 ;; work with hidden articles.
3502 (gnus-summary-maybe-hide-threads)
3504 (gnus-kill-or-deaden-summary kill-buffer))
3505 (gnus-summary-auto-select-subject)
3506 ;; Show first unread article if requested.
3507 (if (and (not no-article)
3509 gnus-newsgroup-unreads
3510 gnus-auto-select-first)
3512 (gnus-configure-windows 'summary)
3513 (let ((art (gnus-summary-article-number)))
3514 (unless (and (not gnus-plugged)
3515 (or (memq art gnus-newsgroup-undownloaded)
3516 (memq art gnus-newsgroup-downloadable)))
3517 (gnus-summary-goto-article art))))
3518 ;; Don't select any articles.
3519 (gnus-summary-position-point)
3520 (gnus-configure-windows 'summary 'force)
3521 (gnus-set-mode-line 'summary))
3522 (when (get-buffer-window gnus-group-buffer t)
3523 ;; Gotta use windows, because recenter does weird stuff if
3524 ;; the current buffer ain't the displayed window.
3525 (let ((owin (selected-window)))
3526 (select-window (get-buffer-window gnus-group-buffer t))
3527 (when (gnus-group-goto-group group)
3529 (select-window owin)))
3530 ;; Mark this buffer as "prepared".
3531 (setq gnus-newsgroup-prepared t)
3532 (gnus-run-hooks 'gnus-summary-prepared-hook)
3533 (unless (gnus-ephemeral-group-p group)
3534 (gnus-group-update-group group))
3537 (defun gnus-summary-auto-select-subject ()
3538 "Select the subject line on initial group entry."
3539 (goto-char (point-min))
3541 ((eq gnus-auto-select-subject 'best)
3542 (gnus-summary-best-unread-subject))
3543 ((eq gnus-auto-select-subject 'unread)
3544 (gnus-summary-first-unread-subject))
3545 ((eq gnus-auto-select-subject 'unseen)
3546 (gnus-summary-first-unseen-subject))
3547 ((eq gnus-auto-select-subject 'unseen-or-unread)
3548 (gnus-summary-first-unseen-or-unread-subject))
3549 ((eq gnus-auto-select-subject 'first)
3552 ((gnus-functionp gnus-auto-select-subject)
3553 (funcall gnus-auto-select-subject))))
3555 (defun gnus-summary-prepare ()
3556 "Generate the summary buffer."
3558 (let ((buffer-read-only nil))
3560 (setq gnus-newsgroup-data nil
3561 gnus-newsgroup-data-reverse nil)
3562 (gnus-run-hooks 'gnus-summary-generate-hook)
3563 ;; Generate the buffer, either with threads or without.
3564 (when gnus-newsgroup-headers
3565 (gnus-summary-prepare-threads
3566 (if gnus-show-threads
3567 (gnus-sort-gathered-threads
3568 (funcall gnus-summary-thread-gathering-function
3570 (gnus-cut-threads (gnus-make-threads)))))
3571 ;; Unthreaded display.
3572 (gnus-sort-articles gnus-newsgroup-headers))))
3573 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3574 ;; Call hooks for modifying summary buffer.
3575 (goto-char (point-min))
3576 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3578 (defsubst gnus-general-simplify-subject (subject)
3579 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3582 ;; Truncate the subject.
3583 (gnus-simplify-subject-functions
3584 (gnus-map-function gnus-simplify-subject-functions subject))
3585 ((numberp gnus-summary-gather-subject-limit)
3586 (setq subject (gnus-simplify-subject-re subject))
3587 (if (> (length subject) gnus-summary-gather-subject-limit)
3588 (substring subject 0 gnus-summary-gather-subject-limit)
3590 ;; Fuzzily simplify it.
3591 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3592 (gnus-simplify-subject-fuzzy subject))
3593 ;; Just remove the leading "Re:".
3595 (gnus-simplify-subject-re subject))))
3597 (if (and gnus-summary-gather-exclude-subject
3598 (string-match gnus-summary-gather-exclude-subject subject))
3599 nil ; This article shouldn't be gathered
3602 (defun gnus-summary-simplify-subject-query ()
3603 "Query where the respool algorithm would put this article."
3605 (gnus-summary-select-article)
3606 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3608 (defun gnus-gather-threads-by-subject (threads)
3609 "Gather threads by looking at Subject headers."
3610 (if (not gnus-summary-make-false-root)
3612 (let ((hashtb (gnus-make-hashtable 1024))
3615 subject hthread whole-subject)
3617 (setq subject (gnus-general-simplify-subject
3618 (setq whole-subject (mail-header-subject
3621 (if (setq hthread (gnus-gethash subject hashtb))
3623 ;; We enter a dummy root into the thread, if we
3624 ;; haven't done that already.
3625 (unless (stringp (caar hthread))
3626 (setcar hthread (list whole-subject (car hthread))))
3627 ;; We add this new gathered thread to this gathered
3629 (setcdr (car hthread)
3630 (nconc (cdar hthread) (list (car threads))))
3631 ;; Remove it from the list of threads.
3632 (setcdr prev (cdr threads))
3633 (setq threads prev))
3634 ;; Enter this thread into the hash table.
3635 (gnus-sethash subject
3636 (if gnus-summary-make-false-root-always
3638 ;; If you want a dummy root above all
3640 (setcar threads (list whole-subject
3646 (setq threads (cdr threads)))
3649 (defun gnus-gather-threads-by-references (threads)
3650 "Gather threads by looking at References headers."
3651 (let ((idhashtb (gnus-make-hashtable 1024))
3652 (thhashtb (gnus-make-hashtable 1024))
3655 ids references id gthread gid entered ref)
3657 (when (setq references (mail-header-references (caar threads)))
3658 (setq id (mail-header-id (caar threads))
3659 ids (inline (gnus-split-references references))
3661 (while (setq ref (pop ids))
3662 (setq ids (delete ref ids))
3663 (if (not (setq gid (gnus-gethash ref idhashtb)))
3665 (gnus-sethash ref id idhashtb)
3666 (gnus-sethash id threads thhashtb))
3667 (setq gthread (gnus-gethash gid thhashtb))
3669 ;; We enter a dummy root into the thread, if we
3670 ;; haven't done that already.
3671 (unless (stringp (caar gthread))
3672 (setcar gthread (list (mail-header-subject (caar gthread))
3674 ;; We add this new gathered thread to this gathered
3676 (setcdr (car gthread)
3677 (nconc (cdar gthread) (list (car threads)))))
3678 ;; Add it into the thread hash table.
3679 (gnus-sethash id gthread thhashtb)
3681 ;; Remove it from the list of threads.
3682 (setcdr prev (cdr threads))
3683 (setq threads prev))))
3685 (setq threads (cdr threads)))
3688 (defun gnus-sort-gathered-threads (threads)
3689 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3690 (let ((result threads))
3692 (when (stringp (caar threads))
3693 (setcdr (car threads)
3694 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3695 (setq threads (cdr threads)))
3698 (defun gnus-thread-loop-p (root thread)
3699 "Say whether ROOT is in THREAD."
3700 (let ((stack (list thread))
3703 (while (setq thread (pop stack))
3704 (setq th (cdr thread))
3706 (not (eq (caar th) root)))
3709 ;; We have found a loop.
3711 (setcdr thread (delq (car th) (cdr thread)))
3712 (if (boundp (setq ref-dep (intern "none"
3713 gnus-newsgroup-dependencies)))
3714 (setcdr (symbol-value ref-dep)
3715 (nconc (cdr (symbol-value ref-dep))
3717 (set ref-dep (list nil (car th))))
3720 ;; Push all the subthreads onto the stack.
3721 (push (cdr thread) stack)))
3724 (defun gnus-make-threads ()
3725 "Go through the dependency hashtb and find the roots. Return all threads."
3727 (while (catch 'infloop
3730 ;; Deal with self-referencing References loops.
3731 (when (and (car (symbol-value refs))
3738 (car (symbol-value refs)) thread))
3739 (cdr (symbol-value refs)))))))
3742 (unless (car (symbol-value refs))
3743 ;; These threads do not refer back to any other
3744 ;; articles, so they're roots.
3745 (setq threads (append (cdr (symbol-value refs)) threads))))
3746 gnus-newsgroup-dependencies)))
3749 ;; Build the thread tree.
3750 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3751 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3753 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3754 if it was already present.
3756 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3757 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3758 Message-IDs will be renamed to a unique Message-ID before being
3761 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3762 (let* ((id (mail-header-id header))
3763 (id-dep (and id (intern id dependencies)))
3764 parent-id ref ref-dep ref-header replaced)
3765 ;; Enter this `header' in the `dependencies' table.
3769 ;; The first two cases do the normal part: enter a new `header'
3770 ;; in the `dependencies' table.
3771 ((not (boundp id-dep))
3772 (set id-dep (list header)))
3773 ((null (car (symbol-value id-dep)))
3774 (setcar (symbol-value id-dep) header))
3776 ;; From here the `header' was already present in the
3777 ;; `dependencies' table.
3779 ;; Overrides an existing entry;
3780 ;; just set the header part of the entry.
3781 (setcar (symbol-value id-dep) header)
3784 ;; Renames the existing `header' to a unique Message-ID.
3785 ((not gnus-summary-ignore-duplicates)
3786 ;; An article with this Message-ID has already been seen.
3787 ;; We rename the Message-ID.
3788 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3790 (mail-header-set-id header id))
3792 ;; The last case ignores an existing entry, except it adds any
3793 ;; additional Xrefs (in case the two articles came from different
3795 ;; Also sets `header' to `nil' meaning that the `dependencies'
3796 ;; table was *not* modified.
3798 (mail-header-set-xref
3799 (car (symbol-value id-dep))
3800 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3802 (or (mail-header-xref header) "")))
3805 (when (and header (not replaced))
3806 ;; First check that we are not creating a References loop.
3807 (setq parent-id (gnus-parent-id (mail-header-references header)))
3808 (setq ref parent-id)
3810 (setq ref-dep (intern-soft ref dependencies))
3812 (setq ref-header (car (symbol-value ref-dep))))
3813 (if (string= id ref)
3814 ;; Yuk! This is a reference loop. Make the article be a
3817 (mail-header-set-references (car (symbol-value id-dep)) "none")
3819 (setq parent-id nil))
3820 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3821 (setq ref-dep (intern (or parent-id "none") dependencies))
3822 (if (boundp ref-dep)
3823 (setcdr (symbol-value ref-dep)
3824 (nconc (cdr (symbol-value ref-dep))
3825 (list (symbol-value id-dep))))
3826 (set ref-dep (list nil (symbol-value id-dep)))))
3829 (defun gnus-extract-message-id-from-in-reply-to (string)
3830 (if (string-match "<[^>]+>" string)
3831 (substring string (match-beginning 0) (match-end 0))
3834 (defun gnus-build-sparse-threads ()
3835 (let ((headers gnus-newsgroup-headers)
3836 (mail-parse-charset gnus-newsgroup-charset)
3837 (gnus-summary-ignore-duplicates t)
3838 header references generation relations
3839 subject child end new-child date)
3840 ;; First we create an alist of generations/relations, where
3841 ;; generations is how much we trust the relation, and the relation
3843 (gnus-message 7 "Making sparse threads...")
3845 (nnheader-set-temp-buffer " *gnus sparse threads*")
3846 (while (setq header (pop headers))
3847 (when (and (setq references (mail-header-references header))
3848 (not (string= references "")))
3850 (setq child (mail-header-id header)
3851 subject (mail-header-subject header)
3852 date (mail-header-date header)
3854 (while (search-backward ">" nil t)
3855 (setq end (1+ (point)))
3856 (when (search-backward "<" nil t)
3857 (setq new-child (buffer-substring (point) end))
3858 (push (list (incf generation)
3859 child (setq child new-child)
3863 (push (list (1+ generation) child nil subject) relations))
3865 (kill-buffer (current-buffer)))
3866 ;; Sort over trustworthiness.
3869 (when (gnus-dependencies-add-header
3870 (make-full-mail-header
3871 gnus-reffed-article-number
3872 (nth 3 relation) "" (or (nth 4 relation) "")
3874 (or (nth 2 relation) "") 0 0 "")
3875 gnus-newsgroup-dependencies nil)
3876 (push gnus-reffed-article-number gnus-newsgroup-limit)
3877 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3878 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3879 gnus-newsgroup-reads)
3880 (decf gnus-reffed-article-number)))
3881 (sort relations 'car-less-than-car))
3882 (gnus-message 7 "Making sparse threads...done")))
3884 (defun gnus-build-old-threads ()
3885 ;; Look at all the articles that refer back to old articles, and
3886 ;; fetch the headers for the articles that aren't there. This will
3887 ;; build complete threads - if the roots haven't been expired by the
3889 (let ((mail-parse-charset gnus-newsgroup-charset)
3893 (when (not (car (symbol-value refs)))
3894 (setq heads (cdr (symbol-value refs)))
3896 (if (memq (mail-header-number (caar heads))
3897 gnus-newsgroup-dormant)
3898 (setq heads (cdr heads))
3899 (setq id (symbol-name refs))
3900 (while (and (setq id (gnus-build-get-header id))
3901 (not (car (gnus-id-to-thread id)))))
3902 (setq heads nil)))))
3903 gnus-newsgroup-dependencies)))
3905 ;; This function has to be called with point after the article number
3906 ;; on the beginning of the line.
3907 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3908 (let ((eol (gnus-point-at-eol))
3909 (buffer (current-buffer))
3910 header references in-reply-to)
3912 ;; overview: [num subject from date id refs chars lines misc]
3915 (narrow-to-region (point) eol)
3920 (make-full-mail-header
3922 (condition-case () ; subject
3923 (funcall gnus-decode-encoded-word-function
3924 (setq x (nnheader-nov-field)))
3926 (condition-case () ; from
3927 (funcall gnus-decode-encoded-word-function
3928 (setq x (nnheader-nov-field)))
3930 (nnheader-nov-field) ; date
3931 (nnheader-nov-read-message-id) ; id
3932 (setq references (nnheader-nov-field)) ; refs
3933 (nnheader-nov-read-integer) ; chars
3934 (nnheader-nov-read-integer) ; lines
3936 (if (looking-at "Xref: ")
3937 (goto-char (match-end 0)))
3938 (nnheader-nov-field)) ; Xref
3939 (nnheader-nov-parse-extra)))) ; extra
3943 (when (and (string= references "")
3944 (setq in-reply-to (mail-header-extra header))
3945 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3946 (mail-header-set-references
3947 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3949 (when gnus-alter-header-function
3950 (funcall gnus-alter-header-function header))
3951 (gnus-dependencies-add-header header dependencies force-new)))
3953 (defun gnus-build-get-header (id)
3954 "Look through the buffer of NOV lines and find the header to ID.
3955 Enter this line into the dependencies hash table, and return
3956 the id of the parent article (if any)."
3957 (let ((deps gnus-newsgroup-dependencies)
3961 (set-buffer nntp-server-buffer)
3962 (let ((case-fold-search nil))
3963 (goto-char (point-min))
3964 (while (and (not found)
3965 (search-forward id nil t))
3967 (setq found (looking-at
3968 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3969 (regexp-quote id))))
3970 (or found (beginning-of-line 2)))
3974 (setq header (gnus-nov-parse-line
3975 (read (current-buffer)) deps))
3976 (gnus-parent-id (mail-header-references header))))))
3978 (let ((number (mail-header-number header)))
3979 (push number gnus-newsgroup-limit)
3980 (push header gnus-newsgroup-headers)
3981 (if (memq number gnus-newsgroup-unselected)
3983 (setq gnus-newsgroup-unreads
3984 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3986 (setq gnus-newsgroup-unselected
3987 (delq number gnus-newsgroup-unselected)))
3988 (push number gnus-newsgroup-ancient)))))))
3990 (defun gnus-build-all-threads ()
3991 "Read all the headers."
3992 (let ((gnus-summary-ignore-duplicates t)
3993 (mail-parse-charset gnus-newsgroup-charset)
3994 (dependencies gnus-newsgroup-dependencies)
3997 (set-buffer nntp-server-buffer)
3998 (let ((case-fold-search nil))
3999 (goto-char (point-min))
4002 (setq article (read (current-buffer))
4003 header (gnus-nov-parse-line article dependencies)))
4006 (set-buffer gnus-summary-buffer)
4007 (push header gnus-newsgroup-headers)
4008 (if (memq (setq article (mail-header-number header))
4009 gnus-newsgroup-unselected)
4011 (setq gnus-newsgroup-unreads
4012 (gnus-add-to-sorted-list
4013 gnus-newsgroup-unreads article))
4014 (setq gnus-newsgroup-unselected
4015 (delq article gnus-newsgroup-unselected)))
4016 (push article gnus-newsgroup-ancient)))
4017 (forward-line 1)))))))
4019 (defun gnus-summary-update-article-line (article header)
4020 "Update the line for ARTICLE using HEADERS."
4021 (let* ((id (mail-header-id header))
4022 (thread (gnus-id-to-thread id)))
4024 (error "Article in no thread"))
4025 ;; Update the thread.
4026 (setcar thread header)
4027 (gnus-summary-goto-subject article)
4028 (let* ((datal (gnus-data-find-list article))
4030 (buffer-read-only nil)
4031 (level (gnus-summary-thread-level)))
4033 (let ((inserted (- (point)
4035 (gnus-summary-insert-line
4037 (memq article gnus-newsgroup-undownloaded)
4038 (gnus-article-mark article)
4039 (memq article gnus-newsgroup-replied)
4040 (memq article gnus-newsgroup-expirable)
4041 ;; Only insert the Subject string when it's different
4042 ;; from the previous Subject string.
4047 (mail-header-subject
4050 (gnus-data-find-list
4052 (gnus-data-list t)))))
4053 ;; Error on the side of excessive subjects.
4055 (mail-header-subject header)))
4057 (mail-header-subject header))
4058 nil (cdr (assq article gnus-newsgroup-scored))
4059 (memq article gnus-newsgroup-processable))
4062 (gnus-data-update-list
4064 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4066 (defun gnus-summary-update-article (article &optional iheader)
4067 "Update ARTICLE in the summary buffer."
4068 (set-buffer gnus-summary-buffer)
4069 (let* ((header (gnus-summary-article-header article))
4070 (id (mail-header-id header))
4071 (data (gnus-data-find article))
4072 (thread (gnus-id-to-thread id))
4073 (references (mail-header-references header))
4077 (when (and references
4078 (not (equal "" references)))
4081 (buffer-read-only nil)
4087 (delq thread parent)))
4088 (if (gnus-summary-insert-subject id header)
4089 ;; Set the (possibly) new article number in the data structure.
4090 (gnus-data-set-number data (gnus-id-to-article id))
4094 (defun gnus-rebuild-thread (id &optional line)
4095 "Rebuild the thread containing ID.
4096 If LINE, insert the rebuilt thread starting on line LINE."
4097 (let ((buffer-read-only nil)
4098 old-pos current thread data)
4099 (if (not gnus-show-threads)
4100 (setq thread (list (car (gnus-id-to-thread id))))
4101 ;; Get the thread this article is part of.
4102 (setq thread (gnus-remove-thread id)))
4103 (setq old-pos (gnus-point-at-bol))
4104 (setq current (save-excursion
4105 (and (re-search-backward "[\r\n]" nil t)
4106 (gnus-summary-article-number))))
4107 ;; If this is a gathered thread, we have to go some re-gathering.
4108 (when (stringp (car thread))
4109 (let ((subject (car thread))
4111 (setq thread (cdr thread))
4113 (unless (memq (setq thr (gnus-id-to-thread
4115 (mail-header-id (caar thread)))))
4118 (setq thread (cdr thread)))
4119 ;; We now have all (unique) roots.
4120 (if (= (length roots) 1)
4121 ;; All the loose roots are now one solid root.
4122 (setq thread (car roots))
4123 (setq thread (cons subject (gnus-sort-threads roots))))))
4125 ;; We then insert this thread into the summary buffer.
4127 (goto-char (point-min))
4128 (forward-line (1- line)))
4129 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4130 (if gnus-show-threads
4131 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4132 (gnus-summary-prepare-unthreaded thread))
4133 (setq data (nreverse gnus-newsgroup-data))
4134 (setq threads gnus-newsgroup-threads))
4135 ;; We splice the new data into the data structure.
4136 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4137 ;;!!! then we want to insert at the beginning of the buffer.
4138 ;;!!! That happens to be true with Gnus now, but that may
4139 ;;!!! change in the future. Perhaps.
4140 (gnus-data-enter-list
4141 (if line nil current) data (- (point) old-pos))
4142 (setq gnus-newsgroup-threads
4143 (nconc threads gnus-newsgroup-threads))
4144 (gnus-data-compute-positions))))
4146 (defun gnus-number-to-header (number)
4147 "Return the header for article NUMBER."
4148 (let ((headers gnus-newsgroup-headers))
4150 (not (= number (mail-header-number (car headers)))))
4155 (defun gnus-parent-headers (in-headers &optional generation)
4156 "Return the headers of the GENERATIONeth parent of HEADERS."
4158 (setq generation 1))
4160 (headers in-headers)
4163 (not (zerop generation))
4164 (setq references (mail-header-references headers)))
4165 (setq headers (if (and references
4166 (setq parent (gnus-parent-id references)))
4167 (car (gnus-id-to-thread parent))
4170 (and (not (eq headers in-headers))
4173 (defun gnus-id-to-thread (id)
4174 "Return the (sub-)thread where ID appears."
4175 (gnus-gethash id gnus-newsgroup-dependencies))
4177 (defun gnus-id-to-article (id)
4178 "Return the article number of ID."
4179 (let ((thread (gnus-id-to-thread id)))
4182 (mail-header-number (car thread)))))
4184 (defun gnus-id-to-header (id)
4185 "Return the article headers of ID."
4186 (car (gnus-id-to-thread id)))
4188 (defun gnus-article-displayed-root-p (article)
4189 "Say whether ARTICLE is a root(ish) article."
4190 (let ((level (gnus-summary-thread-level article))
4191 (refs (mail-header-references (gnus-summary-article-header article)))
4197 ((null (gnus-parent-id refs)) t)
4199 (null (setq particle (gnus-id-to-article
4200 (gnus-parent-id refs))))
4201 (null (gnus-summary-thread-level particle)))))))
4203 (defun gnus-root-id (id)
4204 "Return the id of the root of the thread where ID appears."
4206 (while (and id (setq prev (car (gnus-id-to-thread id))))
4208 id (gnus-parent-id (mail-header-references prev))))
4211 (defun gnus-articles-in-thread (thread)
4212 "Return the list of articles in THREAD."
4213 (cons (mail-header-number (car thread))
4214 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4216 (defun gnus-remove-thread (id &optional dont-remove)
4217 "Remove the thread that has ID in it."
4218 (let (headers thread last-id)
4219 ;; First go up in this thread until we find the root.
4220 (setq last-id (gnus-root-id id)
4221 headers (message-flatten-list (gnus-id-to-thread last-id)))
4222 ;; We have now found the real root of this thread. It might have
4223 ;; been gathered into some loose thread, so we have to search
4224 ;; through the threads to find the thread we wanted.
4225 (let ((threads gnus-newsgroup-threads)
4228 (setq sub (car threads))
4229 (if (stringp (car sub))
4230 ;; This is a gathered thread, so we look at the roots
4231 ;; below it to find whether this article is in this
4234 (setq sub (cdr sub))
4236 (when (member (caar sub) headers)
4237 (setq thread (car threads)
4240 (setq sub (cdr sub))))
4241 ;; It's an ordinary thread, so we check it.
4242 (when (eq (car sub) (car headers))
4245 (setq threads (cdr threads)))
4246 ;; If this article is in no thread, then it's a root.
4249 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4250 (setq thread (gnus-id-to-thread last-id)))
4253 thread ; We return this thread.
4255 (if (stringp (car thread))
4257 ;; If we use dummy roots, then we have to remove the
4258 ;; dummy root as well.
4259 (when (eq gnus-summary-make-false-root 'dummy)
4260 ;; We go to the dummy root by going to
4261 ;; the first sub-"thread", and then one line up.
4262 (gnus-summary-goto-article
4263 (mail-header-number (caadr thread)))
4266 (gnus-data-compute-positions))
4267 (setq thread (cdr thread))
4269 (gnus-remove-thread-1 (car thread))
4270 (setq thread (cdr thread))))
4271 (gnus-remove-thread-1 thread))))))))
4273 (defun gnus-remove-thread-1 (thread)
4274 "Remove the thread THREAD recursively."
4275 (let ((number (mail-header-number (pop thread)))
4277 (setq thread (reverse thread))
4279 (gnus-remove-thread-1 (pop thread)))
4280 (when (setq d (gnus-data-find number))
4281 (goto-char (gnus-data-pos d))
4282 (gnus-summary-show-thread)
4285 (- (gnus-point-at-bol)
4287 (1+ (gnus-point-at-eol))
4288 (gnus-delete-line)))))))
4290 (defun gnus-sort-threads-1 (threads func)
4291 (sort (mapcar (lambda (thread)
4294 (gnus-sort-threads-1 (cdr thread) func))))
4297 (defun gnus-sort-threads (threads)
4299 (if (not gnus-thread-sort-functions)
4301 (gnus-message 8 "Sorting threads...")
4302 (let ((max-lisp-eval-depth 5000))
4303 (prog1 (gnus-sort-threads-1
4305 (gnus-make-sort-function gnus-thread-sort-functions))
4306 (gnus-message 8 "Sorting threads...done")))))
4308 (defun gnus-sort-articles (articles)
4310 (when gnus-article-sort-functions
4311 (gnus-message 7 "Sorting articles...")
4313 (setq gnus-newsgroup-headers
4314 (sort articles (gnus-make-sort-function
4315 gnus-article-sort-functions)))
4316 (gnus-message 7 "Sorting articles...done"))))
4318 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4319 (defmacro gnus-thread-header (thread)
4320 "Return header of first article in THREAD.
4321 Note that THREAD must never, ever be anything else than a variable -
4322 using some other form will lead to serious barfage."
4323 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4324 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4325 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4328 (defsubst gnus-article-sort-by-number (h1 h2)
4329 "Sort articles by article number."
4330 (< (mail-header-number h1)
4331 (mail-header-number h2)))
4333 (defun gnus-thread-sort-by-number (h1 h2)
4334 "Sort threads by root article number."
4335 (gnus-article-sort-by-number
4336 (gnus-thread-header h1) (gnus-thread-header h2)))
4338 (defsubst gnus-article-sort-by-random (h1 h2)
4339 "Sort articles by article number."
4342 (defun gnus-thread-sort-by-random (h1 h2)
4343 "Sort threads by root article number."
4344 (gnus-article-sort-by-random
4345 (gnus-thread-header h1) (gnus-thread-header h2)))
4347 (defsubst gnus-article-sort-by-lines (h1 h2)
4348 "Sort articles by article Lines header."
4349 (< (mail-header-lines h1)
4350 (mail-header-lines h2)))
4352 (defun gnus-thread-sort-by-lines (h1 h2)
4353 "Sort threads by root article Lines header."
4354 (gnus-article-sort-by-lines
4355 (gnus-thread-header h1) (gnus-thread-header h2)))
4357 (defsubst gnus-article-sort-by-chars (h1 h2)
4358 "Sort articles by octet length."
4359 (< (mail-header-chars h1)
4360 (mail-header-chars h2)))
4362 (defun gnus-thread-sort-by-chars (h1 h2)
4363 "Sort threads by root article octet length."
4364 (gnus-article-sort-by-chars
4365 (gnus-thread-header h1) (gnus-thread-header h2)))
4367 (defsubst gnus-article-sort-by-author (h1 h2)
4368 "Sort articles by root author."
4370 (let ((extract (funcall
4371 gnus-extract-address-components
4372 (mail-header-from h1))))
4373 (or (car extract) (cadr extract) ""))
4374 (let ((extract (funcall
4375 gnus-extract-address-components
4376 (mail-header-from h2))))
4377 (or (car extract) (cadr extract) ""))))
4379 (defun gnus-thread-sort-by-author (h1 h2)
4380 "Sort threads by root author."
4381 (gnus-article-sort-by-author
4382 (gnus-thread-header h1) (gnus-thread-header h2)))
4384 (defsubst gnus-article-sort-by-subject (h1 h2)
4385 "Sort articles by root subject."
4387 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4388 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4390 (defun gnus-thread-sort-by-subject (h1 h2)
4391 "Sort threads by root subject."
4392 (gnus-article-sort-by-subject
4393 (gnus-thread-header h1) (gnus-thread-header h2)))
4395 (defsubst gnus-article-sort-by-date (h1 h2)
4396 "Sort articles by root article date."
4398 (gnus-date-get-time (mail-header-date h1))
4399 (gnus-date-get-time (mail-header-date h2))))
4401 (defun gnus-thread-sort-by-date (h1 h2)
4402 "Sort threads by root article date."
4403 (gnus-article-sort-by-date
4404 (gnus-thread-header h1) (gnus-thread-header h2)))
4406 (defsubst gnus-article-sort-by-score (h1 h2)
4407 "Sort articles by root article score.
4408 Unscored articles will be counted as having a score of zero."
4409 (> (or (cdr (assq (mail-header-number h1)
4410 gnus-newsgroup-scored))
4411 gnus-summary-default-score 0)
4412 (or (cdr (assq (mail-header-number h2)
4413 gnus-newsgroup-scored))
4414 gnus-summary-default-score 0)))
4416 (defun gnus-thread-sort-by-score (h1 h2)
4417 "Sort threads by root article score."
4418 (gnus-article-sort-by-score
4419 (gnus-thread-header h1) (gnus-thread-header h2)))
4421 (defun gnus-thread-sort-by-total-score (h1 h2)
4422 "Sort threads by the sum of all scores in the thread.
4423 Unscored articles will be counted as having a score of zero."
4424 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4426 (defun gnus-thread-total-score (thread)
4427 ;; This function find the total score of THREAD.
4432 (if (stringp (car thread))
4433 (apply gnus-thread-score-function 0
4434 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4435 (gnus-thread-total-score-1 thread)))
4437 (gnus-thread-total-score-1 (list thread)))))
4439 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4440 "Sort threads such that the thread with the most recently arrived article comes first."
4441 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4443 (defun gnus-thread-highest-number (thread)
4444 "Return the highest article number in THREAD."
4445 (apply 'max (mapcar (lambda (header)
4446 (mail-header-number header))
4447 (message-flatten-list thread))))
4449 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4450 "Sort threads such that the thread with the most recently dated article comes first."
4451 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4453 (defun gnus-thread-latest-date (thread)
4454 "Return the highest article date in THREAD."
4455 (let ((previous-time 0))
4462 (mail-header-parse-date (mail-header-date header))
4463 (error previous-time)))))
4465 (message-flatten-list thread)
4467 (< (mail-header-number h1)
4468 (mail-header-number h2))))))))
4470 (defun gnus-thread-total-score-1 (root)
4471 ;; This function find the total score of the thread below ROOT.
4472 (setq root (car root))
4473 (apply gnus-thread-score-function
4475 (mapcar 'gnus-thread-total-score
4476 (cdr (gnus-id-to-thread (mail-header-id root))))
4477 (when (> (mail-header-number root) 0)
4478 (list (or (cdr (assq (mail-header-number root)
4479 gnus-newsgroup-scored))
4480 gnus-summary-default-score 0))))
4481 (list gnus-summary-default-score)
4484 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4485 (defvar gnus-tmp-prev-subject nil)
4486 (defvar gnus-tmp-false-parent nil)
4487 (defvar gnus-tmp-root-expunged nil)
4488 (defvar gnus-tmp-dummy-line nil)
4490 (eval-when-compile (defvar gnus-tmp-header))
4491 (defun gnus-extra-header (type &optional header)
4492 "Return the extra header of TYPE."
4493 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4496 (defvar gnus-tmp-thread-tree-header-string "")
4498 (defcustom gnus-sum-thread-tree-root "> "
4499 "With %B spec, used for the root of a thread.
4500 If nil, use subject instead."
4502 :group 'gnus-thread)
4503 (defcustom gnus-sum-thread-tree-single-indent ""
4504 "With %B spec, used for a thread with just one message.
4505 If nil, use subject instead."
4507 :group 'gnus-thread)
4508 (defcustom gnus-sum-thread-tree-vertical "| "
4509 "With %B spec, used for drawing a vertical line."
4511 :group 'gnus-thread)
4512 (defcustom gnus-sum-thread-tree-indent " "
4513 "With %B spec, used for indenting."
4515 :group 'gnus-thread)
4516 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4517 "With %B spec, used for a leaf with brothers."
4519 :group 'gnus-thread)
4520 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4521 "With %B spec, used for a leaf without brothers."
4523 :group 'gnus-thread)
4525 (defun gnus-summary-prepare-threads (threads)
4526 "Prepare summary buffer from THREADS and indentation LEVEL.
4527 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4528 or a straight list of headers."
4529 (gnus-message 7 "Generating summary...")
4531 (setq gnus-newsgroup-threads threads)
4534 (let ((gnus-tmp-level 0)
4535 (default-score (or gnus-summary-default-score 0))
4536 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4537 (building-line-count gnus-summary-display-while-building)
4538 (building-count (integerp gnus-summary-display-while-building))
4539 thread number subject stack state gnus-tmp-gathered beg-match
4540 new-roots gnus-tmp-new-adopts thread-end simp-subject
4541 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4542 gnus-tmp-replied gnus-tmp-subject-or-nil
4543 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4544 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4545 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4548 (setq gnus-tmp-prev-subject nil
4549 gnus-tmp-thread-tree-header-string "")
4551 (if (vectorp (car threads))
4552 ;; If this is a straight (sic) list of headers, then a
4553 ;; threaded summary display isn't required, so we just create
4554 ;; an unthreaded one.
4555 (gnus-summary-prepare-unthreaded threads)
4557 ;; Do the threaded display.
4559 (if gnus-summary-display-while-building
4560 (switch-to-buffer (buffer-name)))
4561 (while (or threads stack gnus-tmp-new-adopts new-roots)
4563 (if (and (= gnus-tmp-level 0)
4566 (not gnus-tmp-false-parent)
4567 (or gnus-tmp-new-adopts new-roots))
4568 (if gnus-tmp-new-adopts
4569 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4570 thread (list (car gnus-tmp-new-adopts))
4571 gnus-tmp-header (caar thread)
4572 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4574 (setq thread (list (car new-roots))
4575 gnus-tmp-header (caar thread)
4576 new-roots (cdr new-roots))))
4579 ;; If there are some threads, we do them before the
4580 ;; threads on the stack.
4581 (setq thread threads
4582 gnus-tmp-header (caar thread))
4583 ;; There were no current threads, so we pop something off
4585 (setq state (car stack)
4586 gnus-tmp-level (car state)
4587 tree-stack (cadr state)
4588 thread (caddr state)
4590 gnus-tmp-header (caar thread))))
4592 (setq gnus-tmp-false-parent nil)
4593 (setq gnus-tmp-root-expunged nil)
4594 (setq thread-end nil)
4596 (if (stringp gnus-tmp-header)
4597 ;; The header is a dummy root.
4599 ((eq gnus-summary-make-false-root 'adopt)
4600 ;; We let the first article adopt the rest.
4601 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4603 (setq gnus-tmp-gathered
4605 (lambda (h) (mail-header-number (car h)))
4608 (setq thread (cons (list (caar thread)
4611 (setq gnus-tmp-level -1
4612 gnus-tmp-false-parent t))
4613 ((eq gnus-summary-make-false-root 'empty)
4614 ;; We print adopted articles with empty subject fields.
4615 (setq gnus-tmp-gathered
4617 (lambda (h) (mail-header-number (car h)))
4620 (setq gnus-tmp-level -1))
4621 ((eq gnus-summary-make-false-root 'dummy)
4622 ;; We remember that we probably want to output a dummy
4624 (setq gnus-tmp-dummy-line gnus-tmp-header)
4625 (setq gnus-tmp-prev-subject gnus-tmp-header))
4627 ;; We do not make a root for the gathered
4628 ;; sub-threads at all.
4629 (setq gnus-tmp-level -1)))
4631 (setq number (mail-header-number gnus-tmp-header)
4632 subject (mail-header-subject gnus-tmp-header)
4633 simp-subject (gnus-simplify-subject-fully subject))
4636 ;; If the thread has changed subject, we might want to make
4637 ;; this subthread into a root.
4638 ((and (null gnus-thread-ignore-subject)
4639 (not (zerop gnus-tmp-level))
4640 gnus-tmp-prev-subject
4641 (not (string= gnus-tmp-prev-subject simp-subject)))
4642 (setq new-roots (nconc new-roots (list (car thread)))
4644 gnus-tmp-header nil))
4645 ;; If the article lies outside the current limit,
4646 ;; then we do not display it.
4647 ((not (memq number gnus-newsgroup-limit))
4648 (setq gnus-tmp-gathered
4650 (lambda (h) (mail-header-number (car h)))
4653 (setq gnus-tmp-new-adopts (if (cdar thread)
4654 (append gnus-tmp-new-adopts
4656 gnus-tmp-new-adopts)
4658 gnus-tmp-header nil)
4659 (when (zerop gnus-tmp-level)
4660 (setq gnus-tmp-root-expunged t)))
4661 ;; Perhaps this article is to be marked as read?
4662 ((and gnus-summary-mark-below
4663 (< (or (cdr (assq number gnus-newsgroup-scored))
4665 gnus-summary-mark-below)
4666 ;; Don't touch sparse articles.
4667 (not (gnus-summary-article-sparse-p number))
4668 (not (gnus-summary-article-ancient-p number)))
4669 (setq gnus-newsgroup-unreads
4670 (delq number gnus-newsgroup-unreads))
4671 (if gnus-newsgroup-auto-expire
4672 (setq gnus-newsgroup-expirable
4673 (gnus-add-to-sorted-list
4674 gnus-newsgroup-expirable number))
4675 (push (cons number gnus-low-score-mark)
4676 gnus-newsgroup-reads))))
4678 (when gnus-tmp-header
4679 ;; We may have an old dummy line to output before this
4681 (when (and gnus-tmp-dummy-line
4684 (mail-header-subject gnus-tmp-header)))
4685 (gnus-summary-insert-dummy-line
4686 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4687 (setq gnus-tmp-dummy-line nil))
4689 ;; Compute the mark.
4690 (setq gnus-tmp-unread (gnus-article-mark number))
4692 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4693 gnus-tmp-header gnus-tmp-level)
4694 gnus-newsgroup-data)
4696 ;; Actually insert the line.
4698 gnus-tmp-subject-or-nil
4700 ((and gnus-thread-ignore-subject
4701 gnus-tmp-prev-subject
4702 (not (string= gnus-tmp-prev-subject simp-subject)))
4704 ((zerop gnus-tmp-level)
4705 (if (and (eq gnus-summary-make-false-root 'empty)
4706 (memq number gnus-tmp-gathered)
4707 gnus-tmp-prev-subject
4708 (string= gnus-tmp-prev-subject simp-subject))
4709 gnus-summary-same-subject
4711 (t gnus-summary-same-subject)))
4712 (if (and (eq gnus-summary-make-false-root 'adopt)
4713 (= gnus-tmp-level 1)
4714 (memq number gnus-tmp-gathered))
4715 (setq gnus-tmp-opening-bracket ?\<
4716 gnus-tmp-closing-bracket ?\>)
4717 (setq gnus-tmp-opening-bracket ?\[
4718 gnus-tmp-closing-bracket ?\]))
4720 gnus-tmp-indentation
4721 (aref gnus-thread-indent-array gnus-tmp-level)
4722 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4723 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4724 gnus-summary-default-score 0)
4726 (if (or (null gnus-summary-default-score)
4727 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4728 gnus-summary-zcore-fuzz))
4730 (if (< gnus-tmp-score gnus-summary-default-score)
4731 gnus-score-below-mark gnus-score-over-mark))
4733 (cond ((memq number gnus-newsgroup-processable)
4735 ((memq number gnus-newsgroup-cached)
4737 ((memq number gnus-newsgroup-replied)
4739 ((memq number gnus-newsgroup-forwarded)
4740 gnus-forwarded-mark)
4741 ((memq number gnus-newsgroup-saved)
4743 ((memq number gnus-newsgroup-recent)
4745 ((memq number gnus-newsgroup-unseen)
4749 (cond ((memq number gnus-newsgroup-undownloaded)
4750 gnus-undownloaded-mark)
4751 (gnus-newsgroup-agentized
4752 gnus-downloaded-mark)
4755 gnus-tmp-from (mail-header-from gnus-tmp-header)
4758 ((string-match "<[^>]+> *$" gnus-tmp-from)
4759 (setq beg-match (match-beginning 0))
4760 (or (and (string-match "^\".+\"" gnus-tmp-from)
4761 (substring gnus-tmp-from 1 (1- (match-end 0))))
4762 (substring gnus-tmp-from 0 beg-match)))
4763 ((string-match "(.+)" gnus-tmp-from)
4764 (substring gnus-tmp-from
4765 (1+ (match-beginning 0)) (1- (match-end 0))))
4767 gnus-tmp-thread-tree-header-string
4769 ((not gnus-show-threads) "")
4770 ((zerop gnus-tmp-level)
4772 (or gnus-sum-thread-tree-root subject)
4773 (or gnus-sum-thread-tree-single-indent subject)))
4775 (concat (apply 'concat
4776 (mapcar (lambda (item)
4778 gnus-sum-thread-tree-vertical
4779 gnus-sum-thread-tree-indent))
4780 (cdr (reverse tree-stack))))
4782 gnus-sum-thread-tree-leaf-with-other
4783 gnus-sum-thread-tree-single-leaf)))))
4784 (when (string= gnus-tmp-name "")
4785 (setq gnus-tmp-name gnus-tmp-from))
4786 (unless (numberp gnus-tmp-lines)
4787 (setq gnus-tmp-lines -1))
4788 (if (= gnus-tmp-lines -1)
4789 (setq gnus-tmp-lines "?")
4790 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4791 (gnus-put-text-property
4793 (progn (eval gnus-summary-line-format-spec) (point))
4794 'gnus-number number)
4797 (gnus-run-hooks 'gnus-summary-update-hook)
4800 (setq gnus-tmp-prev-subject simp-subject)))
4802 (when (nth 1 thread)
4803 (push (list (max 0 gnus-tmp-level)
4804 (copy-list tree-stack)
4807 (push (if (nth 1 thread) 1 0) tree-stack)
4808 (incf gnus-tmp-level)
4809 (setq threads (if thread-end nil (cdar thread)))
4810 (if gnus-summary-display-while-building
4813 ;; use a set frequency
4814 (setq building-line-count (1- building-line-count))
4815 (when (= building-line-count 0)
4817 (setq building-line-count
4818 gnus-summary-display-while-building)))
4822 (setq gnus-tmp-level 0)))))
4823 (gnus-message 7 "Generating summary...done"))
4825 (defun gnus-summary-prepare-unthreaded (headers)
4826 "Generate an unthreaded summary buffer based on HEADERS."
4827 (let (header number mark)
4832 ;; We may have to root out some bad articles...
4833 (when (memq (setq number (mail-header-number
4834 (setq header (pop headers))))
4835 gnus-newsgroup-limit)
4836 ;; Mark article as read when it has a low score.
4837 (when (and gnus-summary-mark-below
4838 (< (or (cdr (assq number gnus-newsgroup-scored))
4839 gnus-summary-default-score 0)
4840 gnus-summary-mark-below)
4841 (not (gnus-summary-article-ancient-p number)))
4842 (setq gnus-newsgroup-unreads
4843 (delq number gnus-newsgroup-unreads))
4844 (if gnus-newsgroup-auto-expire
4845 (push number gnus-newsgroup-expirable)
4846 (push (cons number gnus-low-score-mark)
4847 gnus-newsgroup-reads)))
4849 (setq mark (gnus-article-mark number))
4850 (push (gnus-data-make number mark (1+ (point)) header 0)
4851 gnus-newsgroup-data)
4852 (gnus-summary-insert-line
4854 (memq number gnus-newsgroup-undownloaded)
4855 mark (memq number gnus-newsgroup-replied)
4856 (memq number gnus-newsgroup-expirable)
4857 (mail-header-subject header) nil
4858 (cdr (assq number gnus-newsgroup-scored))
4859 (memq number gnus-newsgroup-processable))))))
4861 (defun gnus-summary-remove-list-identifiers ()
4862 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4863 (let ((regexp (if (consp gnus-list-identifiers)
4864 (mapconcat 'identity gnus-list-identifiers " *\\|")
4865 gnus-list-identifiers))
4868 (dolist (header gnus-newsgroup-headers)
4869 (setq subject (mail-header-subject header)
4871 (while (string-match
4872 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4875 (concat (substring subject 0 (match-beginning 2))
4876 (substring subject (match-end 0)))
4880 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4882 (concat (substring subject 0 (match-beginning 1))
4883 (substring subject (match-end 1)))))
4885 (mail-header-set-subject header subject))))))
4887 (defun gnus-fetch-headers (articles)
4888 "Fetch headers of ARTICLES."
4889 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4890 (gnus-message 5 "Fetching headers for %s..." name)
4893 (setq gnus-headers-retrieved-by
4894 (gnus-retrieve-headers
4895 articles gnus-newsgroup-name
4896 ;; We might want to fetch old headers, but
4897 ;; not if there is only 1 article.
4899 (not (eq gnus-fetch-old-headers 'some))
4900 (not (numberp gnus-fetch-old-headers)))
4901 (> (length articles) 1))
4902 gnus-fetch-old-headers))))
4903 (gnus-get-newsgroup-headers-xover
4904 articles nil nil gnus-newsgroup-name t)
4905 (gnus-get-newsgroup-headers))
4906 (gnus-message 5 "Fetching headers for %s...done" name))))
4908 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4909 "Select newsgroup GROUP.
4910 If READ-ALL is non-nil, all articles in the group are selected.
4911 If SELECT-ARTICLES, only select those articles from GROUP."
4912 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4913 ;;!!! Dirty hack; should be removed.
4914 (gnus-summary-ignore-duplicates
4915 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4917 gnus-summary-ignore-duplicates))
4918 (info (nth 2 entry))
4919 articles fetched-articles cached)
4921 (unless (gnus-check-server
4922 (set (make-local-variable 'gnus-current-select-method)
4923 (gnus-find-method-for-group group)))
4924 (error "Couldn't open server"))
4926 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4927 (gnus-activate-group group) ; Or we can activate it...
4928 (progn ; Or we bug out.
4929 (when (equal major-mode 'gnus-summary-mode)
4930 (kill-buffer (current-buffer)))
4931 (error "Couldn't activate group %s: %s"
4932 group (gnus-status-message group))))
4934 (unless (gnus-request-group group t)
4935 (when (equal major-mode 'gnus-summary-mode)
4936 (kill-buffer (current-buffer)))
4937 (error "Couldn't request group %s: %s"
4938 group (gnus-status-message group)))
4940 (setq gnus-newsgroup-name group
4941 gnus-newsgroup-unselected nil
4942 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4944 (let ((display (gnus-group-find-parameter group 'display)))
4945 (setq gnus-newsgroup-display
4947 ((not (zerop (or (car-safe read-all) 0)))
4948 ;; The user entered the group with C-u SPC/RET, let's show
4954 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4956 ;; The following is probably the "correct" solution, but
4957 ;; it makes Gnus fetch all headers and then limit the
4958 ;; articles (which is slow), so instead we hack the
4959 ;; select-articles parameter instead. -- Simon Josefsson
4962 ;; (gnus-byte-compile
4963 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4965 (setq select-articles
4966 (gnus-uncompress-range
4967 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4971 (cdr (gnus-active group)))))
4976 (gnus-summary-setup-default-charset)
4978 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4979 (when (gnus-virtual-group-p group)
4980 (setq cached gnus-newsgroup-cached))
4982 (setq gnus-newsgroup-unreads
4983 (gnus-sorted-ndifference
4984 (gnus-sorted-ndifference gnus-newsgroup-unreads
4985 gnus-newsgroup-marked)
4986 gnus-newsgroup-dormant))
4988 (setq gnus-newsgroup-processable nil)
4990 (gnus-update-read-articles group gnus-newsgroup-unreads)
4992 ;; Adjust and set lists of article marks.
4994 (gnus-adjust-marked-articles info))
4995 (if (setq articles select-articles)
4996 (setq gnus-newsgroup-unselected
4997 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4998 (setq articles (gnus-articles-to-read group read-all)))
5002 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5004 ((eq articles 0) nil)
5006 ;; Init the dependencies hash table.
5007 (setq gnus-newsgroup-dependencies
5008 (gnus-make-hashtable (length articles)))
5009 (gnus-set-global-variables)
5010 ;; Retrieve the headers and read them in.
5012 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5014 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5016 (setq gnus-newsgroup-cached cached))
5018 ;; Suppress duplicates?
5019 (when gnus-suppress-duplicates
5020 (gnus-dup-suppress-articles))
5022 ;; Set the initial limit.
5023 (setq gnus-newsgroup-limit (copy-sequence articles))
5024 ;; Remove canceled articles from the list of unread articles.
5025 (setq fetched-articles
5026 (mapcar (lambda (headers) (mail-header-number headers))
5027 gnus-newsgroup-headers))
5028 (setq gnus-newsgroup-articles fetched-articles)
5029 (setq gnus-newsgroup-unreads
5030 (gnus-sorted-nintersection
5031 gnus-newsgroup-unreads fetched-articles))
5032 (gnus-compute-unseen-list)
5034 ;; Removed marked articles that do not exist.
5035 (gnus-update-missing-marks
5036 (gnus-sorted-difference articles fetched-articles))
5037 ;; We might want to build some more threads first.
5038 (when (and gnus-fetch-old-headers
5039 (eq gnus-headers-retrieved-by 'nov))
5040 (if (eq gnus-fetch-old-headers 'invisible)
5041 (gnus-build-all-threads)
5042 (gnus-build-old-threads)))
5043 ;; Let the Gnus agent mark articles as read.
5045 (gnus-agent-get-undownloaded-list))
5046 ;; Remove list identifiers from subject
5047 (when gnus-list-identifiers
5048 (gnus-summary-remove-list-identifiers))
5049 ;; Check whether auto-expire is to be done in this group.
5050 (setq gnus-newsgroup-auto-expire
5051 (gnus-group-auto-expirable-p group))
5052 ;; Set up the article buffer now, if necessary.
5053 (unless gnus-single-article-buffer
5054 (gnus-article-setup-buffer))
5055 ;; First and last article in this newsgroup.
5056 (when gnus-newsgroup-headers
5057 (setq gnus-newsgroup-begin
5058 (mail-header-number (car gnus-newsgroup-headers))
5061 (gnus-last-element gnus-newsgroup-headers))))
5062 ;; GROUP is successfully selected.
5063 (or gnus-newsgroup-headers t)))))
5065 (defun gnus-compute-unseen-list ()
5066 ;; The `seen' marks are treated specially.
5067 (if (not gnus-newsgroup-seen)
5068 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5069 (setq gnus-newsgroup-unseen
5070 (gnus-inverse-list-range-intersection
5071 gnus-newsgroup-articles gnus-newsgroup-seen))))
5073 (defun gnus-summary-display-make-predicate (display)
5074 (require 'gnus-agent)
5075 (when (= (length display) 1)
5076 (setq display (car display)))
5077 (unless gnus-summary-display-cache
5078 (dolist (elem (append '((unread . unread)
5081 gnus-article-mark-lists))
5082 (push (cons (cdr elem)
5084 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5085 gnus-summary-display-cache)))
5086 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5087 (gnus-category-predicate-cache gnus-summary-display-cache))
5088 (gnus-get-predicate display)))
5090 ;; Uses the dynamically bound `number' variable.
5093 (defun gnus-article-marked-p (type &optional article)
5094 (let ((article (or article number)))
5097 (memq article gnus-newsgroup-marked))
5099 (memq article gnus-newsgroup-spam-marked))
5101 (memq article gnus-newsgroup-unsendable))
5102 ((eq type 'undownload)
5103 (memq article gnus-newsgroup-undownloaded))
5104 ((eq type 'download)
5105 (memq article gnus-newsgroup-downloadable))
5107 (memq article gnus-newsgroup-unreads))
5109 (memq article gnus-newsgroup-reads))
5111 (memq article gnus-newsgroup-dormant) )
5113 (memq article gnus-newsgroup-expirable))
5115 (memq article gnus-newsgroup-replied))
5117 (memq article gnus-newsgroup-killed))
5118 ((eq type 'bookmark)
5119 (assq article gnus-newsgroup-bookmarks))
5121 (assq article gnus-newsgroup-scored))
5123 (memq article gnus-newsgroup-saved))
5125 (memq article gnus-newsgroup-cached))
5127 (memq article gnus-newsgroup-forwarded))
5129 (not (memq article gnus-newsgroup-unseen)))
5131 (memq article gnus-newsgroup-recent))
5134 (defun gnus-articles-to-read (group &optional read-all)
5135 "Find out what articles the user wants to read."
5136 (let* ((display (gnus-group-find-parameter group 'display))
5138 ;; Select all articles if `read-all' is non-nil, or if there
5139 ;; are no unread articles.
5141 (and (zerop (length gnus-newsgroup-marked))
5142 (zerop (length gnus-newsgroup-unreads)))
5143 ;; Fetch all if the predicate is non-nil.
5144 gnus-newsgroup-display)
5145 ;; We want to select the headers for all the articles in
5146 ;; the group, so we select either all the active
5147 ;; articles in the group, or (if that's nil), the
5148 ;; articles in the cache.
5150 (gnus-uncompress-range (gnus-active group))
5151 (gnus-cache-articles-in-group group))
5152 ;; Select only the "normal" subset of articles.
5154 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5155 gnus-newsgroup-unreads)))
5156 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5157 (scored (length scored-list))
5158 (number (length articles))
5159 (marked (+ (length gnus-newsgroup-marked)
5160 (length gnus-newsgroup-dormant)))
5165 ((numberp gnus-newsgroup-display)
5166 gnus-newsgroup-display)
5170 ((and (or (<= scored marked) (= scored number))
5171 (numberp gnus-large-newsgroup)
5172 (> number gnus-large-newsgroup))
5173 (let* ((cursor-in-echo-area nil)
5174 (initial (gnus-parameter-large-newsgroup-initial
5175 gnus-newsgroup-name))
5179 "How many articles from %s (%s %d): "
5181 (gnus-group-decoded-name gnus-newsgroup-name)
5183 (if initial "max" "default")
5186 (cons (number-to-string initial)
5188 (if (string-match "^[ \t]*$" input) number input)))
5189 ((and (> scored marked) (< scored number)
5190 (> (- scored number) 20))
5193 (format "%s %s (%d scored, %d total): "
5194 "How many articles from"
5195 (gnus-group-decoded-name group)
5197 (if (string-match "^[ \t]*$" input)
5201 (message "Quit getting the articles to read")
5203 (setq select (if (stringp select) (string-to-number select) select))
5204 (if (or (null select) (zerop select))
5206 (if (and (not (zerop scored)) (<= (abs select) scored))
5208 (setq articles (sort scored-list '<))
5209 (setq number (length articles)))
5210 (setq articles (copy-sequence articles)))
5212 (when (< (abs select) number)
5214 ;; Select the N oldest articles.
5215 (setcdr (nthcdr (1- (abs select)) articles) nil)
5216 ;; Select the N most recent articles.
5217 (setq articles (nthcdr (- number select) articles))))
5218 (setq gnus-newsgroup-unselected
5219 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5220 (when gnus-alter-articles-to-read-function
5223 (funcall gnus-alter-articles-to-read-function
5224 gnus-newsgroup-name articles)
5228 (defun gnus-killed-articles (killed articles)
5231 (when (inline (gnus-member-of-range (car articles) killed))
5232 (push (car articles) out))
5233 (setq articles (cdr articles)))
5236 (defun gnus-uncompress-marks (marks)
5237 "Uncompress the mark ranges in MARKS."
5238 (let ((uncompressed '(score bookmark))
5241 (if (memq (caar marks) uncompressed)
5242 (push (car marks) out)
5243 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5244 (setq marks (cdr marks)))
5247 (defun gnus-article-mark-to-type (mark)
5248 "Return the type of MARK."
5249 (or (cadr (assq mark gnus-article-special-mark-lists))
5252 (defun gnus-article-unpropagatable-p (mark)
5253 "Return whether MARK should be propagated to backend."
5254 (memq mark gnus-article-unpropagated-mark-lists))
5256 (defun gnus-adjust-marked-articles (info)
5257 "Set all article lists and remove all marks that are no longer valid."
5258 (let* ((marked-lists (gnus-info-marks info))
5259 (active (gnus-active (gnus-info-group info)))
5262 (types gnus-article-mark-lists)
5263 marks var articles article mark mark-type)
5265 (dolist (marks marked-lists)
5266 (setq mark (car marks)
5267 mark-type (gnus-article-mark-to-type mark)
5268 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5270 ;; We set the variable according to the type of the marks list,
5271 ;; and then adjust the marks to a subset of the active articles.
5273 ;; Adjust "simple" lists.
5274 ((eq mark-type 'list)
5275 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5276 (when (memq mark '(tick dormant expire reply save))
5278 (when (or (< (setq article (pop articles)) min) (> article max))
5279 (set var (delq article (symbol-value var)))))))
5281 ((eq mark-type 'tuple)
5282 (set var (setq articles (cdr marks)))
5283 (when (not (listp (cdr (symbol-value var))))
5284 (set var (list (symbol-value var))))
5285 (when (not (listp (cdr articles)))
5286 (setq articles (list articles)))
5288 (when (or (not (consp (setq article (pop articles))))
5289 (< (car article) min)
5290 (> (car article) max))
5291 (set var (delq article (symbol-value var))))))
5292 ;; Adjust ranges (sloppily).
5293 ((eq mark-type 'range)
5296 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5297 ;; It should be (seen (NUM1 . NUM2)).
5298 (when (numberp (cddr marks))
5299 (setcdr marks (list (cdr marks))))
5300 (setq articles (cdr marks))
5301 (while (and articles
5302 (or (and (consp (car articles))
5303 (> min (cdar articles)))
5304 (and (numberp (car articles))
5305 (> min (car articles)))))
5307 (set var articles))))))))
5309 (defun gnus-update-missing-marks (missing)
5310 "Go through the list of MISSING articles and remove them from the mark lists."
5313 ;; Go through all types.
5314 (dolist (elem gnus-article-mark-lists)
5315 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5316 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5317 (when (symbol-value var)
5318 ;; This list has articles. So we delete all missing
5319 ;; articles from it.
5322 (set var (delq (pop m) (symbol-value var))))))))))
5324 (defun gnus-update-marks ()
5325 "Enter the various lists of marked articles into the newsgroup info list."
5326 (let ((types gnus-article-mark-lists)
5327 (info (gnus-get-info gnus-newsgroup-name))
5328 type list newmarked symbol delta-marks)
5330 ;; Add all marks lists to the list of marks lists.
5331 (while (setq type (pop types))
5332 (setq list (symbol-value
5334 (intern (format "gnus-newsgroup-%s" (car type))))))
5337 ;; Get rid of the entries of the articles that have the
5339 (when (and (eq (cdr type) 'score)
5343 (prev (cons nil list))
5346 (if (or (not (consp (car arts)))
5347 (= (cdar arts) gnus-summary-default-score))
5348 (setcdr prev (cdr arts))
5350 (setq arts (cdr arts)))
5351 (setq list (cdr all)))))
5353 (when (eq (cdr type) 'seen)
5354 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5356 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5357 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5359 (when (and (gnus-check-backend-function
5360 'request-set-mark gnus-newsgroup-name)
5361 (not (gnus-article-unpropagatable-p (cdr type))))
5362 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5363 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5364 (add (gnus-remove-from-range
5365 (gnus-copy-sequence list) old)))
5367 (push (list add 'add (list (cdr type))) delta-marks))
5369 (push (list del 'del (list (cdr type))) delta-marks))))
5372 (push (cons (cdr type) list) newmarked)))
5375 (unless (gnus-check-group gnus-newsgroup-name)
5376 (error "Can't open server for %s" gnus-newsgroup-name))
5377 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5379 ;; Enter these new marks into the info of the group.
5381 (setcar (nthcdr 3 info) newmarked)
5382 ;; Add the marks lists to the end of the info.
5384 (setcdr (nthcdr 2 info) (list newmarked))))
5386 ;; Cut off the end of the info if there's nothing else there.
5390 (when (nthcdr (decf i) info)
5391 (setcdr (nthcdr i info) nil)))))))
5393 (defun gnus-set-mode-line (where)
5394 "Set the mode line of the article or summary buffers.
5395 If WHERE is `summary', the summary mode line format will be used."
5396 ;; Is this mode line one we keep updated?
5397 (when (and (memq where gnus-updated-mode-lines)
5399 (intern (format "gnus-%s-mode-line-format-spec" where))))
5402 ;; We evaluate this in the summary buffer since these
5403 ;; variables are buffer-local to that buffer.
5404 (set-buffer gnus-summary-buffer)
5405 ;; We bind all these variables that are used in the `eval' form
5407 (let* ((mformat (symbol-value
5409 (format "gnus-%s-mode-line-format-spec" where))))
5410 (gnus-tmp-group-name (gnus-group-decoded-name
5411 gnus-newsgroup-name))
5412 (gnus-tmp-article-number (or gnus-current-article 0))
5413 (gnus-tmp-unread gnus-newsgroup-unreads)
5414 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5415 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5416 (gnus-tmp-unread-and-unselected
5417 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5418 (zerop gnus-tmp-unselected))
5420 ((zerop gnus-tmp-unselected)
5421 (format "{%d more}" gnus-tmp-unread-and-unticked))
5422 (t (format "{%d(+%d) more}"
5423 gnus-tmp-unread-and-unticked
5424 gnus-tmp-unselected))))
5426 (if (and gnus-current-headers
5427 (vectorp gnus-current-headers))
5428 (gnus-mode-string-quote
5429 (mail-header-subject gnus-current-headers))
5431 bufname-length max-len
5432 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5433 (setq mode-string (eval mformat))
5434 (setq bufname-length (if (string-match "%b" mode-string)
5437 (if (eq where 'summary)
5439 (get-buffer gnus-article-buffer))))
5442 (setq max-len (max 4 (if gnus-mode-non-string-length
5444 gnus-mode-non-string-length
5446 (length mode-string))))
5447 ;; We might have to chop a bit of the string off...
5448 (when (> (length mode-string) max-len)
5450 (concat (truncate-string-to-width mode-string (- max-len 3))
5452 ;; Pad the mode string a bit.
5453 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5454 ;; Update the mode line.
5455 (setq mode-line-buffer-identification
5456 (gnus-mode-line-buffer-identification (list mode-string)))
5457 (set-buffer-modified-p t))))
5459 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5460 "Go through the HEADERS list and add all Xrefs to a hash table.
5461 The resulting hash table is returned, or nil if no Xrefs were found."
5462 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5463 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5464 (xref-hashtb (gnus-make-hashtable))
5465 start group entry number xrefs header)
5467 (setq header (pop headers))
5468 (when (and (setq xrefs (mail-header-xref header))
5469 (not (memq (setq number (mail-header-number header))
5472 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5473 (setq start (match-end 0))
5474 (setq group (if prefix
5475 (concat prefix (substring xrefs (match-beginning 1)
5477 (substring xrefs (match-beginning 1) (match-end 1))))
5479 (string-to-int (substring xrefs (match-beginning 2)
5481 (if (setq entry (gnus-gethash group xref-hashtb))
5482 (setcdr entry (cons number (cdr entry)))
5483 (gnus-sethash group (cons number nil) xref-hashtb)))))
5484 (and start xref-hashtb)))
5486 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5487 "Look through all the headers and mark the Xrefs as read."
5488 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5489 name entry info xref-hashtb idlist method nth4)
5491 (set-buffer gnus-group-buffer)
5492 (when (setq xref-hashtb
5493 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5496 (unless (string= from-newsgroup (setq name (symbol-name group)))
5497 (setq idlist (symbol-value group))
5498 ;; Dead groups are not updated.
5500 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5502 (when (stringp (setq nth4 (gnus-info-method info)))
5503 (setq nth4 (gnus-server-to-method nth4))))
5504 ;; Only do the xrefs if the group has the same
5505 ;; select method as the group we have just read.
5506 (or (gnus-methods-equal-p
5507 nth4 (gnus-find-method-for-group from-newsgroup))
5509 (equal nth4 (setq method (gnus-find-method-for-group
5511 (and (equal (car nth4) (car method))
5512 (equal (nth 1 nth4) (nth 1 method))))
5513 gnus-use-cross-reference
5514 (or (not (eq gnus-use-cross-reference t))
5516 ;; Only do cross-references on subscribed
5517 ;; groups, if that is what is wanted.
5518 (<= (gnus-info-level info) gnus-level-subscribed))
5519 (gnus-group-make-articles-read name idlist))))
5522 (defun gnus-compute-read-articles (group articles)
5523 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5524 (info (nth 2 entry))
5525 (active (gnus-active group))
5528 ;; First peel off all invalid article numbers.
5530 (let ((ids articles)
5532 (while (setq id (pop ids))
5533 (when (and first (> id (cdr active)))
5534 ;; We'll end up in this situation in one particular
5535 ;; obscure situation. If you re-scan a group and get
5536 ;; a new article that is cross-posted to a different
5537 ;; group that has not been re-scanned, you might get
5538 ;; crossposted article that has a higher number than
5539 ;; Gnus believes possible. So we re-activate this
5540 ;; group as well. This might mean doing the
5541 ;; crossposting thingy will *increase* the number
5542 ;; of articles in some groups. Tsk, tsk.
5543 (setq active (or (gnus-activate-group group) active)))
5544 (when (or (> id (cdr active))
5545 (< id (car active)))
5546 (setq articles (delq id articles))))))
5547 ;; If the read list is nil, we init it.
5549 (null (gnus-info-read info))
5551 (setq ninfo (cons 1 (1- (car active))))
5552 (setq ninfo (gnus-info-read info)))
5553 ;; Then we add the read articles to the range.
5555 ninfo (setq articles (sort articles '<))))))
5557 (defun gnus-group-make-articles-read (group articles)
5558 "Update the info of GROUP to say that ARTICLES are read."
5560 (entry (gnus-gethash group gnus-newsrc-hashtb))
5561 (info (nth 2 entry))
5562 (active (gnus-active group))
5565 (setq range (gnus-compute-read-articles group articles))
5567 (set-buffer gnus-group-buffer)
5570 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5571 (gnus-info-set-read ',info ',(gnus-info-read info))
5572 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5573 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5574 (gnus-group-update-group ,group t))))
5575 ;; Add the read articles to the range.
5576 (gnus-info-set-read info range)
5577 (gnus-request-set-mark group (list (list range 'add '(read))))
5578 ;; Then we have to re-compute how many unread
5579 ;; articles there are in this group.
5583 (setq num (- (1+ (cdr active)) (car active))))
5584 ((not (listp (cdr range)))
5585 (setq num (- (cdr active) (- (1+ (cdr range))
5589 (if (numberp (car range))
5591 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5592 (setq range (cdr range)))
5593 (setq num (- (cdr active) num))))
5594 ;; Update the number of unread articles.
5596 ;; Update the group buffer.
5597 (unless (gnus-ephemeral-group-p group)
5598 (gnus-group-update-group group t))))))
5600 (defvar gnus-newsgroup-none-id 0)
5602 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5603 (let ((cur nntp-server-buffer)
5606 (save-excursion (set-buffer gnus-summary-buffer)
5607 gnus-newsgroup-dependencies)))
5609 (mail-parse-charset gnus-newsgroup-charset)
5610 (mail-parse-ignored-charsets
5611 (save-excursion (condition-case nil
5612 (set-buffer gnus-summary-buffer)
5614 gnus-newsgroup-ignored-charsets)))
5616 (set-buffer nntp-server-buffer)
5617 ;; Translate all TAB characters into SPACE characters.
5618 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5619 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5620 (gnus-run-hooks 'gnus-parse-headers-hook)
5621 (let ((case-fold-search t)
5622 in-reply-to header p lines chars)
5623 (goto-char (point-min))
5624 ;; Search to the beginning of the next header. Error messages
5625 ;; do not begin with 2 or 3.
5626 (while (re-search-forward "^[23][0-9]+ " nil t)
5629 ;; This implementation of this function, with nine
5630 ;; search-forwards instead of the one re-search-forward and
5631 ;; a case (which basically was the old function) is actually
5632 ;; about twice as fast, even though it looks messier. You
5633 ;; can't have everything, I guess. Speed and elegance
5634 ;; doesn't always go hand in hand.
5643 (narrow-to-region (point)
5644 (or (and (search-forward "\n.\n" nil t)
5650 (if (search-forward "\nsubject:" nil t)
5651 (funcall gnus-decode-encoded-word-function
5652 (nnheader-header-value))
5657 (if (search-forward "\nfrom:" nil t)
5658 (funcall gnus-decode-encoded-word-function
5659 (nnheader-header-value))
5664 (if (search-forward "\ndate:" nil t)
5665 (nnheader-header-value) ""))
5669 (setq id (if (re-search-forward
5670 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5671 ;; We do it this way to make sure the Message-ID
5672 ;; is (somewhat) syntactically valid.
5673 (buffer-substring (match-beginning 1)
5675 ;; If there was no message-id, we just fake one
5676 ;; to make subsequent routines simpler.
5677 (nnheader-generate-fake-message-id))))
5681 (if (search-forward "\nreferences:" nil t)
5685 (nnheader-header-value)
5690 (search-backward ">" end t)
5693 (search-backward "<" end t)
5695 ;; Get the references from the in-reply-to header if there
5696 ;; were no references and the in-reply-to header looks
5698 (if (and (search-forward "\nin-reply-to:" nil t)
5699 (setq in-reply-to (nnheader-header-value))
5700 (string-match "<[^>]+>" in-reply-to))
5702 (setq ref (substring in-reply-to (match-beginning 0)
5704 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5705 (setq ref2 (substring in-reply-to (match-beginning 0)
5707 (when (> (length ref2) (length ref))
5714 (if (search-forward "\nchars: " nil t)
5715 (if (numberp (setq chars (ignore-errors (read cur))))
5721 (if (search-forward "\nlines: " nil t)
5722 (if (numberp (setq lines (ignore-errors (read cur))))
5728 (and (search-forward "\nxref:" nil t)
5729 (nnheader-header-value)))
5731 (when gnus-extra-headers
5732 (let ((extra gnus-extra-headers)
5736 (when (search-forward
5737 (concat "\n" (symbol-name (car extra)) ":") nil t)
5738 (push (cons (car extra) (nnheader-header-value))
5742 (when (equal id ref)
5745 (when gnus-alter-header-function
5746 (funcall gnus-alter-header-function header)
5747 (setq id (mail-header-id header)
5748 ref (gnus-parent-id (mail-header-references header))))
5751 (gnus-dependencies-add-header
5752 header dependencies force-new))
5753 (push header headers))
5754 (goto-char (point-max))
5756 (nreverse headers)))))
5758 ;; Goes through the xover lines and returns a list of vectors
5759 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5760 force-new dependencies
5761 group also-fetch-heads)
5762 "Parse the news overview data in the server buffer.
5763 Return a list of headers that match SEQUENCE (see
5764 `nntp-retrieve-headers')."
5765 ;; Get the Xref when the users reads the articles since most/some
5766 ;; NNTP servers do not include Xrefs when using XOVER.
5767 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5768 (let ((mail-parse-charset gnus-newsgroup-charset)
5769 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5770 (cur nntp-server-buffer)
5771 (dependencies (or dependencies gnus-newsgroup-dependencies))
5773 ((eq gnus-read-all-available-headers t)
5775 ((stringp gnus-read-all-available-headers)
5776 (string-match gnus-read-all-available-headers group))
5779 number headers header)
5781 (set-buffer nntp-server-buffer)
5782 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5783 ;; Allow the user to mangle the headers before parsing them.
5784 (gnus-run-hooks 'gnus-parse-headers-hook)
5785 (goto-char (point-min))
5786 (gnus-parse-without-error
5787 (while (and (or sequence allp)
5789 (setq number (read cur))
5791 (while (and sequence
5792 (< (car sequence) number))
5793 (setq sequence (cdr sequence))))
5796 (eq number (car sequence))))
5798 (setq sequence (cdr sequence))
5799 (setq header (inline
5800 (gnus-nov-parse-line
5801 number dependencies force-new)))))
5802 (push header headers))
5804 ;; A common bug in inn is that if you have posted an article and
5805 ;; then retrieves the active file, it will answer correctly --
5806 ;; the new article is included. However, a NOV entry for the
5807 ;; article may not have been generated yet, so this may fail.
5808 ;; We work around this problem by retrieving the last few
5809 ;; headers using HEAD.
5810 (if (or (not also-fetch-heads)
5812 ;; We (probably) got all the headers.
5814 (let ((gnus-nov-is-evil t))
5817 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5818 (gnus-get-newsgroup-headers))))))))
5820 (defun gnus-article-get-xrefs ()
5821 "Fill in the Xref value in `gnus-current-headers', if necessary.
5822 This is meant to be called in `gnus-article-internal-prepare-hook'."
5823 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5824 gnus-current-headers)))
5825 (or (not gnus-use-cross-reference)
5827 (and (mail-header-xref headers)
5828 (not (string= (mail-header-xref headers) "")))
5829 (let ((case-fold-search t)
5832 (nnheader-narrow-to-headers)
5833 (goto-char (point-min))
5834 (when (or (and (not (eobp))
5835 (eq (downcase (char-after)) ?x)
5836 (looking-at "Xref:"))
5837 (search-forward "\nXref:" nil t))
5838 (goto-char (1+ (match-end 0)))
5839 (setq xref (buffer-substring (point)
5840 (progn (end-of-line) (point))))
5841 (mail-header-set-xref headers xref)))))))
5843 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5844 "Find article ID and insert the summary line for that article.
5845 OLD-HEADER can either be a header or a line number to insert
5846 the subject line on."
5847 (let* ((line (and (numberp old-header) old-header))
5848 (old-header (and (vectorp old-header) old-header))
5849 (header (cond ((and old-header use-old-header)
5852 (gnus-number-to-header id))
5853 (gnus-number-to-header id))
5855 (gnus-read-header id))))
5856 (number (and (numberp id) id))
5859 ;; Rebuild the thread that this article is part of and go to the
5860 ;; article we have fetched.
5861 (when (and (not gnus-show-threads)
5864 (setq d (gnus-data-find (mail-header-number old-header))))
5865 (goto-char (gnus-data-pos d))
5868 (- (gnus-point-at-bol)
5870 (1+ (gnus-point-at-eol))
5871 (gnus-delete-line))))))
5873 (mail-header-set-number header (mail-header-number old-header)))
5874 (setq gnus-newsgroup-sparse
5875 (delq (setq number (mail-header-number header))
5876 gnus-newsgroup-sparse))
5877 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5878 (push number gnus-newsgroup-limit)
5879 (gnus-rebuild-thread (mail-header-id header) line)
5880 (gnus-summary-goto-subject number nil t))
5881 (when (and (numberp number)
5883 ;; We have to update the boundaries even if we can't fetch the
5884 ;; article if ID is a number -- so that the next `P' or `N'
5885 ;; command will fetch the previous (or next) article even
5886 ;; if the one we tried to fetch this time has been canceled.
5887 (when (> number gnus-newsgroup-end)
5888 (setq gnus-newsgroup-end number))
5889 (when (< number gnus-newsgroup-begin)
5890 (setq gnus-newsgroup-begin number))
5891 (setq gnus-newsgroup-unselected
5892 (delq number gnus-newsgroup-unselected)))
5893 ;; Report back a success?
5894 (and header (mail-header-number header))))
5896 ;;; Process/prefix in the summary buffer
5898 (defun gnus-summary-work-articles (n)
5899 "Return a list of articles to be worked upon.
5900 The prefix argument, the list of process marked articles, and the
5901 current article will be taken into consideration."
5903 (set-buffer gnus-summary-buffer)
5906 ;; A numerical prefix has been given.
5907 (setq n (prefix-numeric-value n))
5908 (let ((backward (< n 0))
5909 (n (abs (prefix-numeric-value n)))
5914 (push (setq article (gnus-summary-article-number))
5917 (gnus-summary-find-prev nil article)
5918 (gnus-summary-find-next nil article)))
5920 (nreverse articles)))
5921 ((and (gnus-region-active-p) (mark))
5922 (message "region active")
5923 ;; Work on the region between point and mark.
5924 (let ((max (max (point) (mark)))
5927 (goto-char (min (min (point) (mark))))
5930 (push (setq article (gnus-summary-article-number)) articles)
5931 (gnus-summary-find-next nil article)
5933 (nreverse articles))))
5934 (gnus-newsgroup-processable
5935 ;; There are process-marked articles present.
5936 ;; Save current state.
5937 (gnus-summary-save-process-mark)
5939 (reverse gnus-newsgroup-processable))
5941 ;; Just return the current article.
5942 (list (gnus-summary-article-number))))))
5944 (defmacro gnus-summary-iterate (arg &rest forms)
5945 "Iterate over the process/prefixed articles and do FORMS.
5946 ARG is the interactive prefix given to the command. FORMS will be
5947 executed with point over the summary line of the articles."
5948 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5949 `(let ((,articles (gnus-summary-work-articles ,arg)))
5951 (gnus-summary-goto-subject (car ,articles))
5955 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5956 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5958 (defun gnus-summary-save-process-mark ()
5959 "Push the current set of process marked articles on the stack."
5961 (push (copy-sequence gnus-newsgroup-processable)
5962 gnus-newsgroup-process-stack))
5964 (defun gnus-summary-kill-process-mark ()
5965 "Push the current set of process marked articles on the stack and unmark."
5967 (gnus-summary-save-process-mark)
5968 (gnus-summary-unmark-all-processable))
5970 (defun gnus-summary-yank-process-mark ()
5971 "Pop the last process mark state off the stack and restore it."
5973 (unless gnus-newsgroup-process-stack
5974 (error "Empty mark stack"))
5975 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5977 (defun gnus-summary-process-mark-set (set)
5978 "Make SET into the current process marked articles."
5979 (gnus-summary-unmark-all-processable)
5981 (gnus-summary-set-process-mark (pop set))))
5983 ;;; Searching and stuff
5985 (defun gnus-summary-search-group (&optional backward use-level)
5986 "Search for next unread newsgroup.
5987 If optional argument BACKWARD is non-nil, search backward instead."
5989 (set-buffer gnus-group-buffer)
5990 (when (gnus-group-search-forward
5991 backward nil (if use-level (gnus-group-group-level) nil))
5992 (gnus-group-group-name))))
5994 (defun gnus-summary-best-group (&optional exclude-group)
5995 "Find the name of the best unread group.
5996 If EXCLUDE-GROUP, do not go to this group."
5998 (set-buffer gnus-group-buffer)
6000 (gnus-group-best-unread-group exclude-group))))
6002 (defun gnus-summary-find-next (&optional unread article backward)
6003 (if backward (gnus-summary-find-prev)
6004 (let* ((dummy (gnus-summary-article-intangible-p))
6005 (article (or article (gnus-summary-article-number)))
6006 (data (gnus-data-find-list article))
6008 (when (and (not dummy)
6009 (or (not gnus-summary-check-current)
6011 (not (gnus-data-unread-p (car data)))))
6012 (setq data (cdr data)))
6017 (unless (memq (gnus-data-number (car data))
6018 gnus-newsgroup-unfetched)
6019 (when (gnus-data-unread-p (car data))
6020 (setq result (car data)
6022 (setq data (cdr data)))
6025 (goto-char (gnus-data-pos result))
6026 (gnus-data-number result)))))
6028 (defun gnus-summary-find-prev (&optional unread article)
6029 (let* ((eobp (eobp))
6030 (article (or article (gnus-summary-article-number)))
6031 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6033 (when (and (not eobp)
6034 (or (not gnus-summary-check-current)
6036 (not (gnus-data-unread-p (car data)))))
6037 (setq data (cdr data)))
6042 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6043 (when (gnus-data-unread-p (car data))
6044 (setq result (car data)
6046 (setq data (cdr data)))
6049 (goto-char (gnus-data-pos result))
6050 (gnus-data-number result))))
6052 (defun gnus-summary-find-subject (subject &optional unread backward article)
6053 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6054 (article (or article (gnus-summary-article-number)))
6055 (articles (gnus-data-list backward))
6056 (arts (gnus-data-find-list article articles))
6058 (when (or (not gnus-summary-check-current)
6060 (not (gnus-data-unread-p (car arts))))
6061 (setq arts (cdr arts)))
6063 (and (or (not unread)
6064 (gnus-data-unread-p (car arts)))
6065 (vectorp (gnus-data-header (car arts)))
6067 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6068 (setq result (car arts)
6070 (setq arts (cdr arts)))
6072 (goto-char (gnus-data-pos result))
6073 (gnus-data-number result))))
6075 (defun gnus-summary-search-forward (&optional unread subject backward)
6076 "Search forward for an article.
6077 If UNREAD, look for unread articles. If SUBJECT, look for
6078 articles with that subject. If BACKWARD, search backward instead."
6079 (cond (subject (gnus-summary-find-subject subject unread backward))
6080 (backward (gnus-summary-find-prev unread))
6081 (t (gnus-summary-find-next unread))))
6083 (defun gnus-recenter (&optional n)
6084 "Center point in window and redisplay frame.
6085 Also do horizontal recentering."
6087 (when (and gnus-auto-center-summary
6088 (not (eq gnus-auto-center-summary 'vertical)))
6089 (gnus-horizontal-recenter))
6092 (defun gnus-summary-recenter ()
6093 "Center point in the summary window.
6094 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6095 displayed, no centering will be performed."
6096 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6097 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6099 (let* ((top (cond ((< (window-height) 4) 0)
6100 ((< (window-height) 7) 1)
6101 (t (if (numberp gnus-auto-center-summary)
6102 gnus-auto-center-summary
6104 (height (1- (window-height)))
6105 (bottom (save-excursion (goto-char (point-max))
6106 (forward-line (- height))
6108 (window (get-buffer-window (current-buffer))))
6109 ;; The user has to want it.
6110 (when gnus-auto-center-summary
6111 (when (get-buffer-window gnus-article-buffer)
6112 ;; Only do recentering when the article buffer is displayed,
6113 ;; Set the window start to either `bottom', which is the biggest
6114 ;; possible valid number, or the second line from the top,
6115 ;; whichever is the least.
6116 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6117 (if (> bottom top-pos)
6118 ;; Keep the second line from the top visible
6119 (set-window-start window top-pos t)
6120 ;; Try to keep the bottom line visible; if it's partially
6121 ;; obscured, either scroll one more line to make it fully
6122 ;; visible, or revert to using TOP-POS.
6124 (goto-char (point-max))
6126 (let ((last-line-start (point)))
6128 (set-window-start window (point) t)
6129 (when (not (pos-visible-in-window-p last-line-start window))
6131 (set-window-start window (min (point) top-pos) t)))))))
6132 ;; Do horizontal recentering while we're at it.
6133 (when (and (get-buffer-window (current-buffer) t)
6134 (not (eq gnus-auto-center-summary 'vertical)))
6135 (let ((selected (selected-window)))
6136 (select-window (get-buffer-window (current-buffer) t))
6137 (gnus-summary-position-point)
6138 (gnus-horizontal-recenter)
6139 (select-window selected))))))
6141 (defun gnus-summary-jump-to-group (newsgroup)
6142 "Move point to NEWSGROUP in group mode buffer."
6143 ;; Keep update point of group mode buffer if visible.
6144 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6145 (save-window-excursion
6146 ;; Take care of tree window mode.
6147 (when (get-buffer-window gnus-group-buffer)
6148 (pop-to-buffer gnus-group-buffer))
6149 (gnus-group-jump-to-group newsgroup))
6151 ;; Take care of tree window mode.
6152 (if (get-buffer-window gnus-group-buffer)
6153 (pop-to-buffer gnus-group-buffer)
6154 (set-buffer gnus-group-buffer))
6155 (gnus-group-jump-to-group newsgroup))))
6157 ;; This function returns a list of article numbers based on the
6158 ;; difference between the ranges of read articles in this group and
6159 ;; the range of active articles.
6160 (defun gnus-list-of-unread-articles (group)
6161 (let* ((read (gnus-info-read (gnus-get-info group)))
6162 (active (or (gnus-active group) (gnus-activate-group group)))
6165 ;; If none are read, then all are unread.
6167 (setq first (car active))
6168 ;; If the range of read articles is a single range, then the
6169 ;; first unread article is the article after the last read
6170 ;; article. Sounds logical, doesn't it?
6171 (if (and (not (listp (cdr read)))
6172 (or (< (car read) (car active))
6173 (progn (setq read (list read))
6175 (setq first (max (car active) (1+ (cdr read))))
6176 ;; `read' is a list of ranges.
6177 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6180 (setq first (car active)))
6183 (while (< first nlast)
6185 (setq first (1+ first))))
6186 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6187 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6188 (setq read (cdr read)))))
6189 ;; And add the last unread articles.
6190 (while (<= first last)
6192 (setq first (1+ first)))
6193 ;; Return the list of unread articles.
6194 (delq 0 (nreverse unread))))
6196 (defun gnus-list-of-read-articles (group)
6197 "Return a list of unread, unticked and non-dormant articles."
6198 (let* ((info (gnus-get-info group))
6199 (marked (gnus-info-marks info))
6200 (active (gnus-active group)))
6202 (gnus-list-range-difference
6203 (gnus-list-range-difference
6204 (gnus-sorted-complement
6205 (gnus-uncompress-range active)
6206 (gnus-list-of-unread-articles group))
6207 (cdr (assq 'dormant marked)))
6208 (cdr (assq 'tick marked))))))
6210 ;; Various summary commands
6212 (defun gnus-summary-select-article-buffer ()
6213 "Reconfigure windows to show article buffer."
6215 (if (not (gnus-buffer-live-p gnus-article-buffer))
6216 (error "There is no article buffer for this summary buffer")
6217 (gnus-configure-windows 'article)
6218 (select-window (get-buffer-window gnus-article-buffer))))
6220 (defun gnus-summary-universal-argument (arg)
6221 "Perform any operation on all articles that are process/prefixed."
6223 (let ((articles (gnus-summary-work-articles arg))
6230 (substitute-command-keys
6231 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6233 (gnus-error 1 "Undefined key")
6236 (gnus-summary-goto-subject (setq article (pop articles)))
6237 (let (gnus-newsgroup-processable)
6238 (command-execute func))
6239 (gnus-summary-remove-process-mark article)))))
6240 (gnus-summary-position-point))
6242 (defun gnus-summary-toggle-truncation (&optional arg)
6243 "Toggle truncation of summary lines.
6244 With arg, turn line truncation on if arg is positive."
6246 (setq truncate-lines
6247 (if (null arg) (not truncate-lines)
6248 (> (prefix-numeric-value arg) 0)))
6251 (defun gnus-summary-find-uncancelled ()
6252 "Return the number of an uncancelled article.
6253 The current article is considered, then following articles, then previous
6254 articles. If all articles are cancelled then return a dummy 0."
6256 (dolist (rev '(nil t))
6257 (unless found ; don't demand the reverse list if we don't need it
6258 (let ((data (gnus-data-find-list
6259 (gnus-summary-article-number) (gnus-data-list rev))))
6260 (while (and data (not found))
6261 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6262 (setq found (gnus-data-number (car data))))
6263 (setq data (cdr data))))))
6266 (defun gnus-summary-reselect-current-group (&optional all rescan)
6267 "Exit and then reselect the current newsgroup.
6268 The prefix argument ALL means to select all articles."
6270 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6271 (error "Ephemeral groups can't be reselected"))
6272 (let ((current-subject (gnus-summary-find-uncancelled))
6273 (group gnus-newsgroup-name))
6274 (setq gnus-newsgroup-begin nil)
6276 ;; We have to adjust the point of group mode buffer because
6277 ;; point was moved to the next unread newsgroup by exiting.
6278 (gnus-summary-jump-to-group group)
6281 (gnus-group-get-new-news-this-group 1)))
6282 (gnus-group-read-group all t)
6283 (gnus-summary-goto-subject current-subject nil t)))
6285 (defun gnus-summary-rescan-group (&optional all)
6286 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6288 (gnus-summary-reselect-current-group all t))
6290 (defun gnus-summary-update-info (&optional non-destructive)
6292 (let ((group gnus-newsgroup-name))
6294 (when gnus-newsgroup-kill-headers
6295 (setq gnus-newsgroup-killed
6296 (gnus-compress-sequence
6298 (gnus-list-range-intersection
6299 gnus-newsgroup-unselected gnus-newsgroup-killed)
6300 gnus-newsgroup-unreads)
6302 (unless (listp (cdr gnus-newsgroup-killed))
6303 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6304 (let ((headers gnus-newsgroup-headers))
6305 ;; Set the new ranges of read articles.
6307 (set-buffer gnus-group-buffer)
6308 (gnus-undo-force-boundary))
6309 (gnus-update-read-articles
6310 group (gnus-sorted-union
6311 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6312 ;; Set the current article marks.
6313 (let ((gnus-newsgroup-scored
6314 (if (and (not gnus-save-score)
6315 (not non-destructive))
6317 gnus-newsgroup-scored)))
6319 (gnus-update-marks)))
6320 ;; Do the cross-ref thing.
6321 (when gnus-use-cross-reference
6322 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6323 ;; Do not switch windows but change the buffer to work.
6324 (set-buffer gnus-group-buffer)
6325 (unless (gnus-ephemeral-group-p group)
6326 (gnus-group-update-group group)))))))
6328 (defun gnus-summary-save-newsrc (&optional force)
6329 "Save the current number of read/marked articles in the dribble buffer.
6330 The dribble buffer will then be saved.
6331 If FORCE (the prefix), also save the .newsrc file(s)."
6333 (gnus-summary-update-info t)
6335 (gnus-save-newsrc-file)
6336 (gnus-dribble-save)))
6338 (defun gnus-summary-exit (&optional temporary)
6339 "Exit reading current newsgroup, and then return to group selection mode.
6340 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6342 (gnus-set-global-variables)
6343 (when (gnus-buffer-live-p gnus-article-buffer)
6345 (set-buffer gnus-article-buffer)
6346 (mm-destroy-parts gnus-article-mime-handles)
6347 ;; Set it to nil for safety reason.
6348 (setq gnus-article-mime-handle-alist nil)
6349 (setq gnus-article-mime-handles nil)))
6350 (gnus-kill-save-kill-buffer)
6351 (gnus-async-halt-prefetch)
6352 (let* ((group gnus-newsgroup-name)
6353 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6354 (gnus-group-is-exiting-p t)
6357 (buf (current-buffer)))
6359 ;; Do adaptive scoring, and possibly save score files.
6360 (when gnus-newsgroup-adaptive
6361 (gnus-score-adaptive))
6362 (when gnus-use-scoring
6364 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6365 ;; If we have several article buffers, we kill them at exit.
6366 (unless gnus-single-article-buffer
6367 (gnus-kill-buffer gnus-original-article-buffer)
6368 (setq gnus-article-current nil))
6369 (when gnus-use-cache
6370 (gnus-cache-possibly-remove-articles)
6371 (gnus-cache-save-buffers))
6372 (gnus-async-prefetch-remove-group group)
6373 (when gnus-suppress-duplicates
6374 (gnus-dup-enter-articles))
6375 (when gnus-use-trees
6376 (gnus-tree-close group))
6377 (when gnus-use-cache
6378 (gnus-cache-write-active))
6379 ;; Remove entries for this group.
6380 (nnmail-purge-split-history (gnus-group-real-name group))
6381 ;; Make all changes in this group permanent.
6383 (gnus-run-hooks 'gnus-exit-group-hook)
6384 (gnus-summary-update-info))
6385 (gnus-close-group group)
6386 ;; Make sure where we were, and go to next newsgroup.
6387 (set-buffer gnus-group-buffer)
6389 (gnus-group-jump-to-group group))
6390 (gnus-run-hooks 'gnus-summary-exit-hook)
6391 (unless (or quit-config
6392 ;; If this group has disappeared from the summary
6393 ;; buffer, don't skip forwards.
6394 (not (string= group (gnus-group-group-name))))
6395 (gnus-group-next-unread-group 1))
6396 (setq group-point (point))
6399 ;; If we have several article buffers, we kill them at exit.
6400 (unless gnus-single-article-buffer
6401 (gnus-kill-buffer gnus-article-buffer)
6402 (gnus-kill-buffer gnus-original-article-buffer)
6403 (setq gnus-article-current nil))
6405 (if (not gnus-kill-summary-on-exit)
6407 (gnus-deaden-summary)
6409 ;; We set all buffer-local variables to nil. It is unclear why
6410 ;; this is needed, but if we don't, buffer-local variables are
6411 ;; not garbage-collected, it seems. This would the lead to en
6412 ;; ever-growing Emacs.
6413 (gnus-summary-clear-local-variables)
6414 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6415 (gnus-summary-clear-local-variables))
6416 (when (get-buffer gnus-article-buffer)
6417 (bury-buffer gnus-article-buffer))
6418 ;; We clear the global counterparts of the buffer-local
6419 ;; variables as well, just to be on the safe side.
6420 (set-buffer gnus-group-buffer)
6421 (gnus-summary-clear-local-variables)
6422 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6423 (gnus-summary-clear-local-variables))
6424 ;; Return to group mode buffer.
6425 (when (eq mode 'gnus-summary-mode)
6426 (gnus-kill-buffer buf)))
6427 (setq gnus-current-select-method gnus-select-method)
6428 (pop-to-buffer gnus-group-buffer)
6429 (if (not quit-config)
6431 (goto-char group-point)
6432 (gnus-configure-windows 'group 'force))
6433 (gnus-handle-ephemeral-exit quit-config))
6434 ;; Clear the current group name.
6436 (setq gnus-newsgroup-name nil)))))
6438 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6439 (defun gnus-summary-exit-no-update (&optional no-questions)
6440 "Quit reading current newsgroup without updating read article info."
6442 (let* ((group gnus-newsgroup-name)
6443 (gnus-group-is-exiting-p t)
6444 (quit-config (gnus-group-quit-config group)))
6445 (when (or no-questions
6447 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6448 (gnus-async-halt-prefetch)
6450 (delq 'gnus-summary-expire-articles
6451 (copy-sequence gnus-summary-prepare-exit-hook)))
6452 (when (gnus-buffer-live-p gnus-article-buffer)
6454 (set-buffer gnus-article-buffer)
6455 (mm-destroy-parts gnus-article-mime-handles)
6456 ;; Set it to nil for safety reason.
6457 (setq gnus-article-mime-handle-alist nil)
6458 (setq gnus-article-mime-handles nil)))
6459 ;; If we have several article buffers, we kill them at exit.
6460 (unless gnus-single-article-buffer
6461 (gnus-kill-buffer gnus-article-buffer)
6462 (gnus-kill-buffer gnus-original-article-buffer)
6463 (setq gnus-article-current nil))
6464 (if (not gnus-kill-summary-on-exit)
6465 (gnus-deaden-summary)
6466 (gnus-close-group group)
6467 (gnus-summary-clear-local-variables)
6468 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6469 (gnus-summary-clear-local-variables))
6470 (set-buffer gnus-group-buffer)
6471 (gnus-summary-clear-local-variables)
6472 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6473 (gnus-summary-clear-local-variables))
6474 (when (get-buffer gnus-summary-buffer)
6475 (kill-buffer gnus-summary-buffer)))
6476 (unless gnus-single-article-buffer
6477 (setq gnus-article-current nil))
6478 (when gnus-use-trees
6479 (gnus-tree-close group))
6480 (gnus-async-prefetch-remove-group group)
6481 (when (get-buffer gnus-article-buffer)
6482 (bury-buffer gnus-article-buffer))
6483 ;; Return to the group buffer.
6484 (gnus-configure-windows 'group 'force)
6485 ;; Clear the current group name.
6486 (setq gnus-newsgroup-name nil)
6487 (unless (gnus-ephemeral-group-p group)
6488 (gnus-group-update-group group))
6489 (when (equal (gnus-group-group-name) group)
6490 (gnus-group-next-unread-group 1))
6492 (gnus-handle-ephemeral-exit quit-config)))))
6494 (defun gnus-handle-ephemeral-exit (quit-config)
6495 "Handle movement when leaving an ephemeral group.
6496 The state which existed when entering the ephemeral is reset."
6497 (if (not (buffer-name (car quit-config)))
6498 (gnus-configure-windows 'group 'force)
6499 (set-buffer (car quit-config))
6500 (cond ((eq major-mode 'gnus-summary-mode)
6501 (gnus-set-global-variables))
6502 ((eq major-mode 'gnus-article-mode)
6504 ;; The `gnus-summary-buffer' variable may point
6505 ;; to the old summary buffer when using a single
6507 (unless (gnus-buffer-live-p gnus-summary-buffer)
6508 (set-buffer gnus-group-buffer))
6509 (set-buffer gnus-summary-buffer)
6510 (gnus-set-global-variables))))
6511 (if (or (eq (cdr quit-config) 'article)
6512 (eq (cdr quit-config) 'pick))
6514 ;; The current article may be from the ephemeral group
6515 ;; thus it is best that we reload this article
6516 (gnus-summary-show-article)
6517 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6518 (gnus-configure-windows 'pick 'force)
6519 (gnus-configure-windows (cdr quit-config) 'force)))
6520 (gnus-configure-windows (cdr quit-config) 'force))
6521 (when (eq major-mode 'gnus-summary-mode)
6522 (gnus-summary-next-subject 1 nil t)
6523 (gnus-summary-recenter)
6524 (gnus-summary-position-point))))
6528 (defvar gnus-dead-summary-mode-map nil)
6530 (unless gnus-dead-summary-mode-map
6531 (setq gnus-dead-summary-mode-map (make-keymap))
6532 (suppress-keymap gnus-dead-summary-mode-map)
6533 (substitute-key-definition
6534 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6535 (dolist (key '("\C-d" "\r" "\177" [delete]))
6536 (define-key gnus-dead-summary-mode-map
6537 key 'gnus-summary-wake-up-the-dead))
6538 (dolist (key '("q" "Q"))
6539 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6541 (defvar gnus-dead-summary-mode nil
6542 "Minor mode for Gnus summary buffers.")
6544 (defun gnus-dead-summary-mode (&optional arg)
6545 "Minor mode for Gnus summary buffers."
6547 (when (eq major-mode 'gnus-summary-mode)
6548 (make-local-variable 'gnus-dead-summary-mode)
6549 (setq gnus-dead-summary-mode
6550 (if (null arg) (not gnus-dead-summary-mode)
6551 (> (prefix-numeric-value arg) 0)))
6552 (when gnus-dead-summary-mode
6553 (gnus-add-minor-mode
6554 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6556 (defun gnus-deaden-summary ()
6557 "Make the current summary buffer into a dead summary buffer."
6558 ;; Kill any previous dead summary buffer.
6559 (when (and gnus-dead-summary
6560 (buffer-name gnus-dead-summary))
6562 (set-buffer gnus-dead-summary)
6563 (when gnus-dead-summary-mode
6564 (kill-buffer (current-buffer)))))
6565 ;; Make this the current dead summary.
6566 (setq gnus-dead-summary (current-buffer))
6567 (gnus-dead-summary-mode 1)
6568 (let ((name (buffer-name)))
6569 (when (string-match "Summary" name)
6571 (concat (substring name 0 (match-beginning 0)) "Dead "
6572 (substring name (match-beginning 0)))
6576 (defun gnus-kill-or-deaden-summary (buffer)
6577 "Kill or deaden the summary BUFFER."
6579 (when (and (buffer-name buffer)
6580 (not gnus-single-article-buffer))
6583 (gnus-kill-buffer gnus-article-buffer)
6584 (gnus-kill-buffer gnus-original-article-buffer)))
6587 (gnus-kill-summary-on-exit
6588 (when (and gnus-use-trees
6589 (gnus-buffer-exists-p buffer))
6592 (gnus-tree-close gnus-newsgroup-name)))
6593 (gnus-kill-buffer buffer))
6594 ;; Deaden the buffer.
6595 ((gnus-buffer-exists-p buffer)
6598 (gnus-deaden-summary))))))
6600 (defun gnus-summary-wake-up-the-dead (&rest args)
6601 "Wake up the dead summary buffer."
6603 (gnus-dead-summary-mode -1)
6604 (let ((name (buffer-name)))
6605 (when (string-match "Dead " name)
6607 (concat (substring name 0 (match-beginning 0))
6608 (substring name (match-end 0)))
6610 (gnus-message 3 "This dead summary is now alive again"))
6612 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6613 (defun gnus-summary-fetch-faq (&optional faq-dir)
6614 "Fetch the FAQ for the current group.
6615 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6619 (when current-prefix-arg
6621 "FAQ dir: " (and (listp gnus-group-faq-directory)
6622 (mapcar (lambda (file) (list file))
6623 gnus-group-faq-directory))))))
6624 (let (gnus-faq-buffer)
6625 (when (setq gnus-faq-buffer
6626 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6627 (gnus-configure-windows 'summary-faq))))
6629 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6630 (defun gnus-summary-describe-group (&optional force)
6631 "Describe the current newsgroup."
6633 (gnus-group-describe-group force gnus-newsgroup-name))
6635 (defun gnus-summary-describe-briefly ()
6636 "Describe summary mode commands briefly."
6638 (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")))
6640 ;; Walking around group mode buffer from summary mode.
6642 (defun gnus-summary-next-group (&optional no-article target-group backward)
6643 "Exit current newsgroup and then select next unread newsgroup.
6644 If prefix argument NO-ARTICLE is non-nil, no article is selected
6645 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6646 previous group instead."
6648 ;; Stop pre-fetching.
6649 (gnus-async-halt-prefetch)
6650 (let ((current-group gnus-newsgroup-name)
6651 (current-buffer (current-buffer))
6653 (while (not entered)
6654 ;; Then we find what group we are supposed to enter.
6655 (set-buffer gnus-group-buffer)
6656 (gnus-group-jump-to-group current-group)
6659 (if (eq gnus-keep-same-level 'best)
6660 (gnus-summary-best-group gnus-newsgroup-name)
6661 (gnus-summary-search-group backward gnus-keep-same-level))))
6662 (if (not target-group)
6663 ;; There are no further groups, so we return to the group
6666 (gnus-message 5 "Returning to the group buffer")
6668 (when (gnus-buffer-live-p current-buffer)
6669 (set-buffer current-buffer)
6670 (gnus-summary-exit))
6671 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6672 ;; We try to enter the target group.
6673 (gnus-group-jump-to-group target-group)
6674 (let ((unreads (gnus-group-group-unread)))
6675 (if (and (or (eq t unreads)
6676 (and unreads (not (zerop unreads))))
6678 ;; Now we semi-exit this group to update Xrefs
6679 ;; and all variables. We can't do a real exit,
6680 ;; because the window conf must remain the same
6681 ;; in case the user is prompted for info, and we
6682 ;; don't want the window conf to change before
6684 (when (gnus-buffer-live-p current-buffer)
6685 (set-buffer current-buffer)
6686 (gnus-summary-exit t))
6687 (gnus-summary-read-group
6688 target-group nil no-article
6689 (and (buffer-name current-buffer) current-buffer)
6692 (setq current-group target-group
6693 target-group nil)))))))
6695 (defun gnus-summary-prev-group (&optional no-article)
6696 "Exit current newsgroup and then select previous unread newsgroup.
6697 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6699 (gnus-summary-next-group no-article nil t))
6701 ;; Walking around summary lines.
6703 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6704 "Go to the first subject satisfying any non-nil constraint.
6705 If UNREAD is non-nil, the article should be unread.
6706 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6707 If UNSEED is non-nil, the article should be unseen.
6708 Returns the article selected or nil if there are no matching articles."
6712 ((null gnus-newsgroup-data)
6713 (gnus-message 3 "No articles in the group")
6715 ;; Pick the first article.
6716 ((not (or unread undownloaded unseen))
6717 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6718 (gnus-data-number (car gnus-newsgroup-data)))
6719 ;; Find the first unread article.
6721 (let ((data gnus-newsgroup-data))
6723 (let ((num (gnus-data-number (car data))))
6724 (or (memq num gnus-newsgroup-unfetched)
6725 (not (or (and unread
6726 (memq num gnus-newsgroup-unreads))
6728 (memq num gnus-newsgroup-undownloaded))
6730 (memq num gnus-newsgroup-unseen)))))))
6731 (setq data (cdr data)))
6735 (goto-char (gnus-data-pos (car data)))
6736 (gnus-data-number (car data)))
6737 (gnus-message 3 "No more%s articles"
6738 (let* ((r (when unread " unread"))
6739 (d (when undownloaded " undownloaded"))
6740 (s (when unseen " unseen"))
6741 (l (delq nil (list r d s))))
6742 (cond ((= 3 (length l))
6743 (concat r "," d ", or" s))
6745 (concat (car l) ", or" (cadr l)))
6752 (gnus-summary-position-point))))))
6754 (defun gnus-summary-next-subject (n &optional unread dont-display)
6755 "Go to next N'th summary line.
6756 If N is negative, go to the previous N'th subject line.
6757 If UNREAD is non-nil, only unread articles are selected.
6758 The difference between N and the actual number of steps taken is
6761 (let ((backward (< n 0))
6765 (gnus-summary-find-prev unread)
6766 (gnus-summary-find-next unread)))
6767 (unless (zerop (setq n (1- n)))
6768 (gnus-summary-show-thread)))
6770 (gnus-message 7 "No more%s articles"
6771 (if unread " unread" "")))
6772 (unless dont-display
6773 (gnus-summary-recenter)
6774 (gnus-summary-position-point))
6777 (defun gnus-summary-next-unread-subject (n)
6778 "Go to next N'th unread summary line."
6780 (gnus-summary-next-subject n t))
6782 (defun gnus-summary-prev-subject (n &optional unread)
6783 "Go to previous N'th summary line.
6784 If optional argument UNREAD is non-nil, only unread article is selected."
6786 (gnus-summary-next-subject (- n) unread))
6788 (defun gnus-summary-prev-unread-subject (n)
6789 "Go to previous N'th unread summary line."
6791 (gnus-summary-next-subject (- n) t))
6793 (defun gnus-summary-goto-subjects (articles)
6794 "Insert the subject header for ARTICLES in the current buffer."
6796 (dolist (article articles)
6797 (gnus-summary-goto-subject article t)))
6798 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6799 (gnus-summary-position-point))
6801 (defun gnus-summary-goto-subject (article &optional force silent)
6802 "Go the subject line of ARTICLE.
6803 If FORCE, also allow jumping to articles not currently shown."
6804 (interactive "nArticle number: ")
6805 (unless (numberp article)
6806 (error "Article %s is not a number" article))
6808 (data (gnus-data-find article)))
6809 ;; We read in the article if we have to.
6812 (gnus-summary-insert-subject
6814 (if (or (numberp force) (vectorp force)) force)
6816 (setq data (gnus-data-find article)))
6821 (gnus-message 3 "Can't find article %d" article))
6823 (let ((pt (gnus-data-pos data)))
6825 (gnus-summary-set-article-display-arrow pt))
6826 (gnus-summary-position-point)
6829 ;; Walking around summary lines with displaying articles.
6831 (defun gnus-summary-expand-window (&optional arg)
6832 "Make the summary buffer take up the entire Emacs frame.
6833 Given a prefix, will force an `article' buffer configuration."
6836 (gnus-configure-windows 'article 'force)
6837 (gnus-configure-windows 'summary 'force)))
6839 (defun gnus-summary-display-article (article &optional all-header)
6840 "Display ARTICLE in article buffer."
6841 (when (gnus-buffer-live-p gnus-article-buffer)
6842 (with-current-buffer gnus-article-buffer
6843 (mm-enable-multibyte)))
6844 (gnus-set-global-variables)
6845 (when (gnus-buffer-live-p gnus-article-buffer)
6846 (with-current-buffer gnus-article-buffer
6847 (setq gnus-article-charset gnus-newsgroup-charset)
6848 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6849 (mm-enable-multibyte)))
6853 (if gnus-summary-display-article-function
6854 (funcall gnus-summary-display-article-function article all-header)
6855 (gnus-article-prepare article all-header))
6856 (gnus-run-hooks 'gnus-select-article-hook)
6857 (when (and gnus-current-article
6858 (not (zerop gnus-current-article)))
6859 (gnus-summary-goto-subject gnus-current-article))
6860 (gnus-summary-recenter)
6861 (when (and gnus-use-trees gnus-show-threads)
6862 (gnus-possibly-generate-tree article)
6863 (gnus-highlight-selected-tree article))
6864 ;; Successfully display article.
6865 (gnus-article-set-window-start
6866 (cdr (assq article gnus-newsgroup-bookmarks))))))
6868 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6869 "Select the current article.
6870 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6871 non-nil, the article will be re-fetched even if it already present in
6872 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6874 ;; Make sure we are in the summary buffer to work around bbdb bug.
6875 (unless (eq major-mode 'gnus-summary-mode)
6876 (set-buffer gnus-summary-buffer))
6877 (let ((article (or article (gnus-summary-article-number)))
6878 (all-headers (not (not all-headers))) ;Must be t or nil.
6879 gnus-summary-display-article-function)
6881 (gnus-summary-article-pseudo-p article)
6882 (error "This is a pseudo-article"))
6884 (set-buffer gnus-summary-buffer)
6885 (if (or (and gnus-single-article-buffer
6886 (or (null gnus-current-article)
6887 (null gnus-article-current)
6888 (null (get-buffer gnus-article-buffer))
6889 (not (eq article (cdr gnus-article-current)))
6890 (not (equal (car gnus-article-current)
6891 gnus-newsgroup-name))))
6892 (and (not gnus-single-article-buffer)
6893 (or (null gnus-current-article)
6894 (not (eq gnus-current-article article))))
6896 ;; The requested article is different from the current article.
6898 (gnus-summary-display-article article all-headers)
6899 (when (gnus-buffer-live-p gnus-article-buffer)
6900 (with-current-buffer gnus-article-buffer
6901 (if (not gnus-article-decoded-p) ;; a local variable
6902 (mm-disable-multibyte))))
6903 (gnus-article-set-window-start
6904 (cdr (assq article gnus-newsgroup-bookmarks)))
6908 (defun gnus-summary-force-verify-and-decrypt ()
6909 "Display buttons for signed/encrypted parts and verify/decrypt them."
6911 (let ((mm-verify-option 'known)
6912 (mm-decrypt-option 'known)
6913 (gnus-buttonized-mime-types (append (list "multipart/signed"
6914 "multipart/encrypted")
6915 gnus-buttonized-mime-types)))
6916 (gnus-summary-select-article nil 'force)))
6918 (defun gnus-summary-set-current-mark (&optional current-mark)
6919 "Obsolete function."
6922 (defun gnus-summary-next-article (&optional unread subject backward push)
6923 "Select the next article.
6924 If UNREAD, only unread articles are selected.
6925 If SUBJECT, only articles with SUBJECT are selected.
6926 If BACKWARD, the previous article is selected instead of the next."
6929 ;; Is there such an article?
6930 ((and (gnus-summary-search-forward unread subject backward)
6931 (or (gnus-summary-display-article (gnus-summary-article-number))
6932 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6933 (gnus-summary-position-point))
6934 ;; If not, we try the first unread, if that is wanted.
6936 gnus-auto-select-same
6937 (gnus-summary-first-unread-article))
6938 (gnus-summary-position-point)
6939 (gnus-message 6 "Wrapped"))
6940 ;; Try to get next/previous article not displayed in this group.
6941 ((and gnus-auto-extend-newsgroup
6942 (not unread) (not subject))
6943 (gnus-summary-goto-article
6944 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6945 nil (count-lines (point-min) (point))))
6946 ;; Go to next/previous group.
6948 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6949 (gnus-summary-jump-to-group gnus-newsgroup-name))
6950 (let ((cmd last-command-char)
6953 (set-buffer gnus-group-buffer)
6956 (if (eq gnus-keep-same-level 'best)
6957 (gnus-summary-best-group gnus-newsgroup-name)
6958 (gnus-summary-search-group backward gnus-keep-same-level))))
6959 ;; For some reason, the group window gets selected. We change
6961 (select-window (get-buffer-window (current-buffer)))
6962 ;; Select next unread newsgroup automagically.
6964 ((or (not gnus-auto-select-next)
6966 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6967 ((or (eq gnus-auto-select-next 'quietly)
6968 (and (eq gnus-auto-select-next 'slightly-quietly)
6970 (and (eq gnus-auto-select-next 'almost-quietly)
6971 (gnus-summary-last-article-p)))
6973 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6975 (gnus-message 7 "No more%s articles (%s)..."
6976 (if unread " unread" "")
6977 (if group (concat "selecting " group)
6979 (gnus-summary-next-group nil group backward)))
6981 (when (gnus-key-press-event-p last-input-event)
6982 (gnus-summary-walk-group-buffer
6983 gnus-newsgroup-name cmd unread backward point))))))))
6985 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6986 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6987 (?\C-p (gnus-group-prev-unread-group 1))))
6988 (cursor-in-echo-area t)
6989 keve key group ended prompt)
6991 (set-buffer gnus-group-buffer)
6994 (if (eq gnus-keep-same-level 'best)
6995 (gnus-summary-best-group gnus-newsgroup-name)
6996 (gnus-summary-search-group backward gnus-keep-same-level))))
7000 "No more%s articles%s " (if unread " unread" "")
7002 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7003 (format " (Type %s for %s [%s])"
7004 (single-key-description cmd) group
7005 (car (gnus-gethash group gnus-newsrc-hashtb)))
7006 (format " (Type %s to exit %s)"
7007 (single-key-description cmd)
7008 gnus-newsgroup-name))))
7009 ;; Confirm auto selection.
7010 (setq key (car (setq keve (gnus-read-event-char prompt)))
7013 ((assq key keystrokes)
7014 (let ((obuf (current-buffer)))
7015 (switch-to-buffer gnus-group-buffer)
7017 (gnus-group-jump-to-group group))
7018 (eval (cadr (assq key keystrokes)))
7019 (setq group (gnus-group-group-name))
7020 (switch-to-buffer obuf))
7024 (gnus-ephemeral-group-p gnus-newsgroup-name))
7026 (gnus-summary-next-group nil group backward)))
7028 (push (cdr keve) unread-command-events))))))
7030 (defun gnus-summary-next-unread-article ()
7031 "Select unread article after current one."
7033 (gnus-summary-next-article
7034 (or (not (eq gnus-summary-goto-unread 'never))
7035 (gnus-summary-last-article-p (gnus-summary-article-number)))
7036 (and gnus-auto-select-same
7037 (gnus-summary-article-subject))))
7039 (defun gnus-summary-prev-article (&optional unread subject)
7040 "Select the article after the current one.
7041 If UNREAD is non-nil, only unread articles are selected."
7043 (gnus-summary-next-article unread subject t))
7045 (defun gnus-summary-prev-unread-article ()
7046 "Select unread article before current one."
7048 (gnus-summary-prev-article
7049 (or (not (eq gnus-summary-goto-unread 'never))
7050 (gnus-summary-first-article-p (gnus-summary-article-number)))
7051 (and gnus-auto-select-same
7052 (gnus-summary-article-subject))))
7054 (defun gnus-summary-next-page (&optional lines circular stop)
7055 "Show next page of the selected article.
7056 If at the end of the current article, select the next article.
7057 LINES says how many lines should be scrolled up.
7059 If CIRCULAR is non-nil, go to the start of the article instead of
7060 selecting the next article when reaching the end of the current
7063 If STOP is non-nil, just stop when reaching the end of the message."
7065 (setq gnus-summary-buffer (current-buffer))
7066 (gnus-set-global-variables)
7067 (let ((article (gnus-summary-article-number))
7068 (article-window (get-buffer-window gnus-article-buffer t))
7070 ;; If the buffer is empty, we have no article.
7072 (error "No article to select"))
7073 (gnus-configure-windows 'article)
7074 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7075 (if (and (eq gnus-summary-goto-unread 'never)
7076 (not (gnus-summary-last-article-p article)))
7077 (gnus-summary-next-article)
7078 (gnus-summary-next-unread-article))
7079 (if (or (null gnus-current-article)
7080 (null gnus-article-current)
7081 (/= article (cdr gnus-article-current))
7082 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7083 ;; Selected subject is different from current article's.
7084 (gnus-summary-display-article article)
7085 (when article-window
7086 (gnus-eval-in-buffer-window gnus-article-buffer
7087 (setq endp (gnus-article-next-page lines)))
7090 (gnus-message 3 "End of message"))
7092 (gnus-summary-beginning-of-article))
7094 (gnus-message 3 "End of message"))
7096 (if (and (eq gnus-summary-goto-unread 'never)
7097 (not (gnus-summary-last-article-p article)))
7098 (gnus-summary-next-article)
7099 (gnus-summary-next-unread-article))))))))
7100 (gnus-summary-recenter)
7101 (gnus-summary-position-point)))
7103 (defun gnus-summary-prev-page (&optional lines move)
7104 "Show previous page of selected article.
7105 Argument LINES specifies lines to be scrolled down.
7106 If MOVE, move to the previous unread article if point is at
7107 the beginning of the buffer."
7109 (let ((article (gnus-summary-article-number))
7110 (article-window (get-buffer-window gnus-article-buffer t))
7112 (gnus-configure-windows 'article)
7113 (if (or (null gnus-current-article)
7114 (null gnus-article-current)
7115 (/= article (cdr gnus-article-current))
7116 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7117 ;; Selected subject is different from current article's.
7118 (gnus-summary-display-article article)
7119 (gnus-summary-recenter)
7120 (when article-window
7121 (gnus-eval-in-buffer-window gnus-article-buffer
7122 (setq endp (gnus-article-prev-page lines)))
7123 (when (and move endp)
7125 (gnus-message 3 "Beginning of message"))
7127 (if (and (eq gnus-summary-goto-unread 'never)
7128 (not (gnus-summary-first-article-p article)))
7129 (gnus-summary-prev-article)
7130 (gnus-summary-prev-unread-article))))))))
7131 (gnus-summary-position-point))
7133 (defun gnus-summary-prev-page-or-article (&optional lines)
7134 "Show previous page of selected article.
7135 Argument LINES specifies lines to be scrolled down.
7136 If at the beginning of the article, go to the next article."
7138 (gnus-summary-prev-page lines t))
7140 (defun gnus-summary-scroll-up (lines)
7141 "Scroll up (or down) one line current article.
7142 Argument LINES specifies lines to be scrolled up (or down if negative)."
7144 (gnus-configure-windows 'article)
7145 (gnus-summary-show-thread)
7146 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7147 (gnus-eval-in-buffer-window gnus-article-buffer
7149 (when (gnus-article-next-page lines)
7150 (gnus-message 3 "End of message")))
7152 (gnus-article-prev-page (- lines))))))
7153 (gnus-summary-recenter)
7154 (gnus-summary-position-point))
7156 (defun gnus-summary-scroll-down (lines)
7157 "Scroll down (or up) one line current article.
7158 Argument LINES specifies lines to be scrolled down (or up if negative)."
7160 (gnus-summary-scroll-up (- lines)))
7162 (defun gnus-summary-next-same-subject ()
7163 "Select next article which has the same subject as current one."
7165 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7167 (defun gnus-summary-prev-same-subject ()
7168 "Select previous article which has the same subject as current one."
7170 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7172 (defun gnus-summary-next-unread-same-subject ()
7173 "Select next unread article which has the same subject as current one."
7175 (gnus-summary-next-article t (gnus-summary-article-subject)))
7177 (defun gnus-summary-prev-unread-same-subject ()
7178 "Select previous unread article which has the same subject as current one."
7180 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7182 (defun gnus-summary-first-unread-article ()
7183 "Select the first unread article.
7184 Return nil if there are no unread articles."
7187 (when (gnus-summary-first-subject t)
7188 (gnus-summary-show-thread)
7189 (gnus-summary-first-subject t)
7190 (gnus-summary-display-article (gnus-summary-article-number)))
7191 (gnus-summary-position-point)))
7193 (defun gnus-summary-first-unread-subject ()
7194 "Place the point on the subject line of the first unread article.
7195 Return nil if there are no unread articles."
7198 (when (gnus-summary-first-subject t)
7199 (gnus-summary-show-thread)
7200 (gnus-summary-first-subject t))
7201 (gnus-summary-position-point)))
7203 (defun gnus-summary-first-unseen-subject ()
7204 "Place the point on the subject line of the first unseen article.
7205 Return nil if there are no unseen articles."
7208 (when (gnus-summary-first-subject nil nil t)
7209 (gnus-summary-show-thread)
7210 (gnus-summary-first-subject nil nil t))
7211 (gnus-summary-position-point)))
7213 (defun gnus-summary-first-unseen-or-unread-subject ()
7214 "Place the point on the subject line of the first unseen article or,
7215 if all article have been seen, on the subject line of the first unread
7219 (unless (when (gnus-summary-first-subject nil nil t)
7220 (gnus-summary-show-thread)
7221 (gnus-summary-first-subject nil nil t))
7222 (when (gnus-summary-first-subject t)
7223 (gnus-summary-show-thread)
7224 (gnus-summary-first-subject t)))
7225 (gnus-summary-position-point)))
7227 (defun gnus-summary-first-article ()
7228 "Select the first article.
7229 Return nil if there are no articles."
7232 (when (gnus-summary-first-subject)
7233 (gnus-summary-show-thread)
7234 (gnus-summary-first-subject)
7235 (gnus-summary-display-article (gnus-summary-article-number)))
7236 (gnus-summary-position-point)))
7238 (defun gnus-summary-best-unread-article (&optional arg)
7239 "Select the unread article with the highest score.
7240 If given a prefix argument, select the next unread article that has a
7241 score higher than the default score."
7243 (let ((article (if arg
7244 (gnus-summary-better-unread-subject)
7245 (gnus-summary-best-unread-subject))))
7247 (gnus-summary-goto-article article)
7248 (error "No unread articles"))))
7250 (defun gnus-summary-best-unread-subject ()
7251 "Select the unread subject with the highest score."
7253 (let ((best -1000000)
7254 (data gnus-newsgroup-data)
7257 (and (gnus-data-unread-p (car data))
7259 (gnus-summary-article-score (gnus-data-number (car data))))
7262 article (gnus-data-number (car data))))
7263 (setq data (cdr data)))
7265 (gnus-summary-goto-subject article))
7266 (gnus-summary-position-point)
7269 (defun gnus-summary-better-unread-subject ()
7270 "Select the first unread subject that has a score over the default score."
7272 (let ((data gnus-newsgroup-data)
7274 (while (and (setq article (gnus-data-number (car data)))
7275 (or (gnus-data-read-p (car data))
7276 (not (> (gnus-summary-article-score article)
7277 gnus-summary-default-score))))
7278 (setq data (cdr data)))
7280 (gnus-summary-goto-subject article))
7281 (gnus-summary-position-point)
7284 (defun gnus-summary-last-subject ()
7285 "Go to the last displayed subject line in the group."
7286 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7288 (gnus-summary-goto-subject article))))
7290 (defun gnus-summary-goto-article (article &optional all-headers force)
7291 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7292 If ALL-HEADERS is non-nil, no header lines are hidden.
7293 If FORCE, go to the article even if it isn't displayed. If FORCE
7294 is a number, it is the line the article is to be displayed on."
7298 "Article number or Message-ID: "
7299 (mapcar (lambda (number) (list (int-to-string number)))
7300 gnus-newsgroup-limit))
7304 (if (and (stringp article)
7305 (string-match "@" article))
7306 (gnus-summary-refer-article article)
7307 (when (stringp article)
7308 (setq article (string-to-number article)))
7309 (if (gnus-summary-goto-subject article force)
7310 (gnus-summary-display-article article all-headers)
7311 (gnus-message 4 "Couldn't go to article %s" article) nil))
7312 (gnus-summary-position-point)))
7314 (defun gnus-summary-goto-last-article ()
7315 "Go to the previously read article."
7318 (when gnus-last-article
7319 (gnus-summary-goto-article gnus-last-article nil t))
7320 (gnus-summary-position-point)))
7322 (defun gnus-summary-pop-article (number)
7323 "Pop one article off the history and go to the previous.
7324 NUMBER articles will be popped off."
7327 (setq gnus-newsgroup-history
7328 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7330 (gnus-summary-goto-article (car to) nil t)
7331 (error "Article history empty")))
7332 (gnus-summary-position-point))
7334 ;; Summary commands and functions for limiting the summary buffer.
7336 (defun gnus-summary-limit-to-articles (n)
7337 "Limit the summary buffer to the next N articles.
7338 If not given a prefix, use the process marked articles instead."
7341 (let ((articles (gnus-summary-work-articles n)))
7342 (setq gnus-newsgroup-processable nil)
7343 (gnus-summary-limit articles))
7344 (gnus-summary-position-point)))
7346 (defun gnus-summary-pop-limit (&optional total)
7347 "Restore the previous limit.
7348 If given a prefix, remove all limits."
7351 (setq gnus-newsgroup-limits
7352 (list (mapcar (lambda (h) (mail-header-number h))
7353 gnus-newsgroup-headers))))
7354 (unless gnus-newsgroup-limits
7355 (error "No limit to pop"))
7357 (gnus-summary-limit nil 'pop)
7358 (gnus-summary-position-point)))
7360 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7361 "Limit the summary buffer to articles that have subjects that match a regexp.
7362 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7364 (list (read-string (if current-prefix-arg
7365 "Exclude subject (regexp): "
7366 "Limit to subject (regexp): "))
7367 nil current-prefix-arg))
7369 (setq header "subject"))
7370 (when (not (equal "" subject))
7372 (let ((articles (gnus-summary-find-matching
7373 (or header "subject") subject 'all nil nil
7376 (error "Found no matches for \"%s\"" subject))
7377 (gnus-summary-limit articles))
7378 (gnus-summary-position-point))))
7380 (defun gnus-summary-limit-to-author (from &optional not-matching)
7381 "Limit the summary buffer to articles that have authors that match a regexp.
7382 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7384 (list (read-string (if current-prefix-arg
7385 "Exclude author (regexp): "
7386 "Limit to author (regexp): "))
7387 current-prefix-arg))
7388 (gnus-summary-limit-to-subject from "from" not-matching))
7390 (defun gnus-summary-limit-to-age (age &optional younger-p)
7391 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7392 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7393 articles that are younger than AGE days."
7395 (let ((younger current-prefix-arg)
7398 (while (not days-got)
7399 (setq days (if younger
7400 (read-string "Limit to articles younger than (in days, older when negative): ")
7402 "Limit to articles older than (in days, younger when negative): ")))
7403 (when (> (length days) 0)
7404 (setq days (read days)))
7410 (setq younger (not younger))
7411 (setq days (* days -1)))))
7412 (message "Please enter a number.")
7414 (list days younger)))
7416 (let ((data gnus-newsgroup-data)
7417 (cutoff (days-to-time age))
7418 articles d date is-younger)
7419 (while (setq d (pop data))
7420 (when (and (vectorp (gnus-data-header d))
7421 (setq date (mail-header-date (gnus-data-header d))))
7422 (setq is-younger (time-less-p
7423 (time-since (condition-case ()
7430 (push (gnus-data-number d) articles))))
7431 (gnus-summary-limit (nreverse articles)))
7432 (gnus-summary-position-point)))
7434 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7435 "Limit the summary buffer to articles that match an 'extra' header."
7439 (gnus-completing-read-with-default
7440 (symbol-name (car gnus-extra-headers))
7441 (if current-prefix-arg
7442 "Exclude extra header:"
7443 "Limit extra header:")
7445 (cons (symbol-name x) x))
7450 (read-string (format "%s header %s (regexp): "
7451 (if current-prefix-arg "Exclude" "Limit to")
7453 current-prefix-arg)))
7454 (when (not (equal "" regexp))
7456 (let ((articles (gnus-summary-find-matching
7457 (cons 'extra header) regexp 'all nil nil
7460 (error "Found no matches for \"%s\"" regexp))
7461 (gnus-summary-limit articles))
7462 (gnus-summary-position-point))))
7464 (defun gnus-summary-limit-to-display-predicate ()
7465 "Limit the summary buffer to the predicated in the `display' group parameter."
7467 (unless gnus-newsgroup-display
7468 (error "There is no `display' group parameter"))
7470 (dolist (number gnus-newsgroup-articles)
7471 (when (funcall gnus-newsgroup-display)
7472 (push number articles)))
7473 (gnus-summary-limit articles))
7474 (gnus-summary-position-point))
7476 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7478 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7480 (defun gnus-summary-limit-to-unread (&optional all)
7481 "Limit the summary buffer to articles that are not marked as read.
7482 If ALL is non-nil, limit strictly to unread articles."
7485 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7486 (gnus-summary-limit-to-marks
7487 ;; Concat all the marks that say that an article is read and have
7489 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7490 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7491 gnus-low-score-mark gnus-expirable-mark
7492 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7493 gnus-duplicate-mark gnus-souped-mark)
7496 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7497 (make-obsolete 'gnus-summary-delete-marked-with
7498 'gnus-summary-limit-exclude-marks)
7500 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7501 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7502 If REVERSE, limit the summary buffer to articles that are marked
7503 with MARKS. MARKS can either be a string of marks or a list of marks.
7504 Returns how many articles were removed."
7505 (interactive "sMarks: ")
7506 (gnus-summary-limit-to-marks marks t))
7508 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7509 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7510 If REVERSE (the prefix), limit the summary buffer to articles that are
7511 not marked with MARKS. MARKS can either be a string of marks or a
7513 Returns how many articles were removed."
7514 (interactive "sMarks: \nP")
7516 (let ((data gnus-newsgroup-data)
7517 (marks (if (listp marks) marks
7518 (append marks nil))) ; Transform to list.
7521 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7522 (memq (gnus-data-mark (car data)) marks))
7523 (push (gnus-data-number (car data)) articles))
7524 (setq data (cdr data)))
7525 (gnus-summary-limit articles))
7526 (gnus-summary-position-point)))
7528 (defun gnus-summary-limit-to-score (score)
7529 "Limit to articles with score at or above SCORE."
7530 (interactive "NLimit to articles with score of at least: ")
7531 (let ((data gnus-newsgroup-data)
7534 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7536 (push (gnus-data-number (car data)) articles))
7537 (setq data (cdr data)))
7539 (gnus-summary-limit articles)
7540 (gnus-summary-position-point))))
7542 (defun gnus-summary-limit-to-unseen ()
7543 "Limit to unseen articles."
7546 (gnus-summary-limit gnus-newsgroup-unseen)
7547 (gnus-summary-position-point)))
7549 (defun gnus-summary-limit-include-thread (id)
7550 "Display all the hidden articles that is in the thread with ID in it.
7551 When called interactively, ID is the Message-ID of the current
7553 (interactive (list (mail-header-id (gnus-summary-article-header))))
7554 (let ((articles (gnus-articles-in-thread
7555 (gnus-id-to-thread (gnus-root-id id)))))
7557 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7558 (gnus-summary-limit-include-matching-articles
7560 (regexp-quote (gnus-simplify-subject-re
7561 (mail-header-subject (gnus-id-to-header id)))))
7562 (gnus-summary-position-point))))
7564 (defun gnus-summary-limit-include-matching-articles (header regexp)
7565 "Display all the hidden articles that have HEADERs that match REGEXP."
7566 (interactive (list (read-string "Match on header: ")
7567 (read-string "Regexp: ")))
7568 (let ((articles (gnus-find-matching-articles header regexp)))
7570 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7571 (gnus-summary-position-point))))
7573 (defun gnus-summary-insert-dormant-articles ()
7574 "Insert all the dormat articles for this group into the current buffer."
7576 (let ((gnus-verbose (max 6 gnus-verbose)))
7577 (if (not gnus-newsgroup-dormant)
7578 (gnus-message 3 "No cached articles for this group")
7579 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7581 (defun gnus-summary-limit-include-dormant ()
7582 "Display all the hidden articles that are marked as dormant.
7583 Note that this command only works on a subset of the articles currently
7584 fetched for this group."
7586 (unless gnus-newsgroup-dormant
7587 (error "There are no dormant articles in this group"))
7589 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7590 (gnus-summary-position-point)))
7592 (defun gnus-summary-limit-exclude-dormant ()
7593 "Hide all dormant articles."
7596 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7597 (gnus-summary-position-point)))
7599 (defun gnus-summary-limit-exclude-childless-dormant ()
7600 "Hide all dormant articles that have no children."
7602 (let ((data (gnus-data-list t))
7603 articles d children)
7604 ;; Find all articles that are either not dormant or have
7606 (while (setq d (pop data))
7607 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7609 (gnus-article-children (gnus-data-number d)))
7612 (when (memq (car children) articles)
7617 (push (gnus-data-number d) articles)))
7620 (gnus-summary-limit articles)
7621 (gnus-summary-position-point))))
7623 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7624 "Mark all unread excluded articles as read.
7625 If ALL, mark even excluded ticked and dormants as read."
7627 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7628 (let ((articles (gnus-sorted-ndifference
7630 (mapcar (lambda (h) (mail-header-number h))
7631 gnus-newsgroup-headers)
7633 gnus-newsgroup-limit))
7635 (setq gnus-newsgroup-unreads
7636 (gnus-sorted-intersection gnus-newsgroup-unreads
7637 gnus-newsgroup-limit))
7639 (setq gnus-newsgroup-dormant nil
7640 gnus-newsgroup-marked nil
7641 gnus-newsgroup-reads
7643 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7644 gnus-newsgroup-reads))
7645 (while (setq article (pop articles))
7646 (unless (or (memq article gnus-newsgroup-dormant)
7647 (memq article gnus-newsgroup-marked))
7648 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7650 (defun gnus-summary-limit (articles &optional pop)
7652 ;; We pop the previous limit off the stack and use that.
7653 (setq articles (car gnus-newsgroup-limits)
7654 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7655 ;; We use the new limit, so we push the old limit on the stack.
7656 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7658 (setq gnus-newsgroup-limit articles)
7659 (let ((total (length gnus-newsgroup-data))
7660 (data (gnus-data-find-list (gnus-summary-article-number)))
7661 (gnus-summary-mark-below nil) ; Inhibit this.
7663 ;; This will do all the work of generating the new summary buffer
7664 ;; according to the new limit.
7665 (gnus-summary-prepare)
7666 ;; Hide any threads, possibly.
7667 (gnus-summary-maybe-hide-threads)
7668 ;; Try to return to the article you were at, or one in the
7671 ;; We try to find some article after the current one.
7673 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7676 (setq data (cdr data))))
7678 ;; If there is no data, that means that we were after the last
7679 ;; article. The same goes when we can't find any articles
7680 ;; after the current one.
7681 (goto-char (point-max))
7682 (gnus-summary-find-prev))
7683 (gnus-set-mode-line 'summary)
7684 ;; We return how many articles were removed from the summary
7685 ;; buffer as a result of the new limit.
7686 (- total (length gnus-newsgroup-data))))
7688 (defsubst gnus-invisible-cut-children (threads)
7691 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7696 (defsubst gnus-cut-thread (thread)
7697 "Go forwards in the thread until we find an article that we want to display."
7698 (when (or (eq gnus-fetch-old-headers 'some)
7699 (eq gnus-fetch-old-headers 'invisible)
7700 (numberp gnus-fetch-old-headers)
7701 (eq gnus-build-sparse-threads 'some)
7702 (eq gnus-build-sparse-threads 'more))
7703 ;; Deal with old-fetched headers and sparse threads.
7707 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7708 (gnus-summary-article-ancient-p
7709 (mail-header-number (car thread))))
7710 (if (or (<= (length (cdr thread)) 1)
7711 (eq gnus-fetch-old-headers 'invisible))
7712 (setq gnus-newsgroup-limit
7713 (delq (mail-header-number (car thread))
7714 gnus-newsgroup-limit)
7715 thread (cadr thread))
7716 (when (gnus-invisible-cut-children (cdr thread))
7717 (let ((th (cdr thread)))
7719 (if (memq (mail-header-number (caar th))
7720 gnus-newsgroup-limit)
7721 (setq thread (car th)
7723 (setq th (cdr th))))))))))
7726 (defun gnus-cut-threads (threads)
7727 "Cut off all uninteresting articles from the beginning of threads."
7728 (when (or (eq gnus-fetch-old-headers 'some)
7729 (eq gnus-fetch-old-headers 'invisible)
7730 (numberp gnus-fetch-old-headers)
7731 (eq gnus-build-sparse-threads 'some)
7732 (eq gnus-build-sparse-threads 'more))
7735 (setcar th (gnus-cut-thread (car th)))
7736 (setq th (cdr th)))))
7737 ;; Remove nixed out threads.
7740 (defun gnus-summary-initial-limit (&optional show-if-empty)
7741 "Figure out what the initial limit is supposed to be on group entry.
7742 This entails weeding out unwanted dormants, low-scored articles,
7743 fetch-old-headers verbiage, and so on."
7744 ;; Most groups have nothing to remove.
7745 (if (or gnus-inhibit-limiting
7746 (and (null gnus-newsgroup-dormant)
7747 (eq gnus-newsgroup-display 'gnus-not-ignore)
7748 (not (eq gnus-fetch-old-headers 'some))
7749 (not (numberp gnus-fetch-old-headers))
7750 (not (eq gnus-fetch-old-headers 'invisible))
7751 (null gnus-summary-expunge-below)
7752 (not (eq gnus-build-sparse-threads 'some))
7753 (not (eq gnus-build-sparse-threads 'more))
7754 (null gnus-thread-expunge-below)
7755 (not gnus-use-nocem)))
7757 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7758 (setq gnus-newsgroup-limit nil)
7761 (unless (car (symbol-value node))
7762 ;; These threads have no parents -- they are roots.
7763 (let ((nodes (cdr (symbol-value node)))
7766 (if (and gnus-thread-expunge-below
7767 (< (gnus-thread-total-score (car nodes))
7768 gnus-thread-expunge-below))
7769 (gnus-expunge-thread (pop nodes))
7770 (setq thread (pop nodes))
7771 (gnus-summary-limit-children thread))))))
7772 gnus-newsgroup-dependencies)
7773 ;; If this limitation resulted in an empty group, we might
7774 ;; pop the previous limit and use it instead.
7775 (when (and (not gnus-newsgroup-limit)
7777 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7778 gnus-newsgroup-limit))
7780 (defun gnus-summary-limit-children (thread)
7781 "Return 1 if this subthread is visible and 0 if it is not."
7782 ;; First we get the number of visible children to this thread. This
7783 ;; is done by recursing down the thread using this function, so this
7784 ;; will really go down to a leaf article first, before slowly
7785 ;; working its way up towards the root.
7787 (let* ((max-lisp-eval-depth 5000)
7790 (apply '+ (mapcar 'gnus-summary-limit-children
7793 (number (mail-header-number (car thread)))
7796 (not (memq number gnus-newsgroup-marked))
7798 ;; If this article is dormant and has absolutely no visible
7799 ;; children, then this article isn't visible.
7800 (and (memq number gnus-newsgroup-dormant)
7802 ;; If this is "fetch-old-headered" and there is no
7803 ;; visible children, then we don't want this article.
7804 (and (or (eq gnus-fetch-old-headers 'some)
7805 (numberp gnus-fetch-old-headers))
7806 (gnus-summary-article-ancient-p number)
7808 ;; If this is "fetch-old-headered" and `invisible', then
7809 ;; we don't want this article.
7810 (and (eq gnus-fetch-old-headers 'invisible)
7811 (gnus-summary-article-ancient-p number))
7812 ;; If this is a sparsely inserted article with no children,
7813 ;; we don't want it.
7814 (and (eq gnus-build-sparse-threads 'some)
7815 (gnus-summary-article-sparse-p number)
7817 ;; If we use expunging, and this article is really
7818 ;; low-scored, then we don't want this article.
7819 (when (and gnus-summary-expunge-below
7821 (or (cdr (assq number gnus-newsgroup-scored))
7822 gnus-summary-default-score))
7823 gnus-summary-expunge-below))
7824 ;; We increase the expunge-tally here, but that has
7825 ;; nothing to do with the limits, really.
7826 (incf gnus-newsgroup-expunged-tally)
7827 ;; We also mark as read here, if that's wanted.
7828 (when (and gnus-summary-mark-below
7829 (< score gnus-summary-mark-below))
7830 (setq gnus-newsgroup-unreads
7831 (delq number gnus-newsgroup-unreads))
7832 (if gnus-newsgroup-auto-expire
7833 (push number gnus-newsgroup-expirable)
7834 (push (cons number gnus-low-score-mark)
7835 gnus-newsgroup-reads)))
7837 ;; Do the `display' group parameter.
7838 (and gnus-newsgroup-display
7839 (not (funcall gnus-newsgroup-display)))
7840 ;; Check NoCeM things.
7841 (if (and gnus-use-nocem
7842 (gnus-nocem-unwanted-article-p
7843 (mail-header-id (car thread))))
7845 (setq gnus-newsgroup-unreads
7846 (delq number gnus-newsgroup-unreads))
7848 ;; Nope, invisible article.
7850 ;; Ok, this article is to be visible, so we add it to the limit
7852 (push number gnus-newsgroup-limit)
7855 (defun gnus-expunge-thread (thread)
7856 "Mark all articles in THREAD as read."
7857 (let* ((number (mail-header-number (car thread))))
7858 (incf gnus-newsgroup-expunged-tally)
7859 ;; We also mark as read here, if that's wanted.
7860 (setq gnus-newsgroup-unreads
7861 (delq number gnus-newsgroup-unreads))
7862 (if gnus-newsgroup-auto-expire
7863 (push number gnus-newsgroup-expirable)
7864 (push (cons number gnus-low-score-mark)
7865 gnus-newsgroup-reads)))
7866 ;; Go recursively through all subthreads.
7867 (mapcar 'gnus-expunge-thread (cdr thread)))
7869 ;; Summary article oriented commands
7871 (defun gnus-summary-refer-parent-article (n)
7872 "Refer parent article N times.
7873 If N is negative, go to ancestor -N instead.
7874 The difference between N and the number of articles fetched is returned."
7878 (when (not (natnump n))
7883 (setq header (gnus-summary-article-header))
7884 (if (and (eq (mail-header-number header)
7885 (cdr gnus-article-current))
7886 (equal gnus-newsgroup-name
7887 (car gnus-article-current)))
7888 ;; If we try to find the parent of the currently
7889 ;; displayed article, then we take a look at the actual
7890 ;; References header, since this is slightly more
7891 ;; reliable than the References field we got from the
7894 (set-buffer gnus-original-article-buffer)
7895 (nnheader-narrow-to-headers)
7896 (unless (setq ref (message-fetch-field "references"))
7897 (setq ref (message-fetch-field "in-reply-to")))
7900 ;; It's not the current article, so we take a bet on
7901 ;; the value we got from the server.
7902 (mail-header-references header)))
7904 (not (equal ref "")))
7905 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7906 (gnus-message 1 "Couldn't find parent"))
7907 (gnus-message 1 "No references in article %d"
7908 (gnus-summary-article-number))
7911 (gnus-summary-position-point)
7914 (defun gnus-summary-refer-references ()
7915 "Fetch all articles mentioned in the References header.
7916 Return the number of articles fetched."
7918 (let ((ref (mail-header-references (gnus-summary-article-header)))
7919 (current (gnus-summary-article-number))
7923 (error "No References in the current article")
7924 ;; For each Message-ID in the References header...
7925 (while (string-match "<[^>]*>" ref)
7927 ;; ... fetch that article.
7928 (gnus-summary-refer-article
7929 (prog1 (match-string 0 ref)
7930 (setq ref (substring ref (match-end 0))))))
7931 (gnus-summary-goto-subject current)
7932 (gnus-summary-position-point)
7935 (defun gnus-summary-refer-thread (&optional limit)
7936 "Fetch all articles in the current thread.
7937 If LIMIT (the numerical prefix), fetch that many old headers instead
7938 of what's specified by the `gnus-refer-thread-limit' variable."
7940 (let ((id (mail-header-id (gnus-summary-article-header)))
7941 (limit (if limit (prefix-numeric-value limit)
7942 gnus-refer-thread-limit)))
7943 ;; We want to fetch LIMIT *old* headers, but we also have to
7944 ;; re-fetch all the headers in the current buffer, because many of
7945 ;; them may be undisplayed. So we adjust LIMIT.
7946 (when (numberp limit)
7947 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7948 (unless (eq gnus-fetch-old-headers 'invisible)
7949 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7950 ;; Retrieve the headers and read them in.
7951 (if (eq (gnus-retrieve-headers
7952 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7954 (gnus-build-all-threads)
7955 (error "Can't fetch thread from backends that don't support NOV"))
7956 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7957 (gnus-summary-limit-include-thread id)))
7959 (defun gnus-summary-refer-article (message-id)
7960 "Fetch an article specified by MESSAGE-ID."
7961 (interactive "sMessage-ID: ")
7962 (when (and (stringp message-id)
7963 (not (zerop (length message-id))))
7964 ;; Construct the correct Message-ID if necessary.
7965 ;; Suggested by tale@pawl.rpi.edu.
7966 (unless (string-match "^<" message-id)
7967 (setq message-id (concat "<" message-id)))
7968 (unless (string-match ">$" message-id)
7969 (setq message-id (concat message-id ">")))
7970 (let* ((header (gnus-id-to-header message-id))
7972 (gnus-summary-article-sparse-p
7973 (mail-header-number header))
7974 (memq (mail-header-number header)
7975 gnus-newsgroup-limit)))
7978 ;; If the article is present in the buffer we just go to it.
7980 (or (not (gnus-summary-article-sparse-p
7981 (mail-header-number header)))
7984 (gnus-summary-goto-article
7985 (mail-header-number header) nil t)
7987 (gnus-summary-update-article (mail-header-number header)))))
7989 ;; We fetch the article.
7991 (dolist (gnus-override-method (gnus-refer-article-methods))
7992 (gnus-check-server gnus-override-method)
7993 ;; Fetch the header, and display the article.
7994 (when (setq number (gnus-summary-insert-subject message-id))
7995 (gnus-summary-select-article nil nil nil number)
7997 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7999 (defun gnus-refer-article-methods ()
8000 "Return a list of referable methods."
8002 ;; No method, so we default to current and native.
8003 ((null gnus-refer-article-method)
8004 (list gnus-current-select-method gnus-select-method))
8006 ((eq 'current gnus-refer-article-method)
8007 (list gnus-current-select-method))
8008 ;; List of select methods.
8009 ((not (and (symbolp (car gnus-refer-article-method))
8010 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8012 (dolist (method gnus-refer-article-method)
8013 (push (if (eq 'current method)
8014 gnus-current-select-method
8018 ;; One single select method.
8020 (list gnus-refer-article-method))))
8022 (defun gnus-summary-edit-parameters ()
8023 "Edit the group parameters of the current group."
8025 (gnus-group-edit-group gnus-newsgroup-name 'params))
8027 (defun gnus-summary-customize-parameters ()
8028 "Customize the group parameters of the current group."
8030 (gnus-group-customize gnus-newsgroup-name))
8032 (defun gnus-summary-enter-digest-group (&optional force)
8033 "Enter an nndoc group based on the current article.
8034 If FORCE, force a digest interpretation. If not, try
8035 to guess what the document format is."
8037 (let ((conf gnus-current-window-configuration))
8039 (gnus-summary-select-article))
8040 (setq gnus-current-window-configuration conf)
8041 (let* ((name (format "%s-%d"
8042 (gnus-group-prefixed-name
8043 gnus-newsgroup-name (list 'nndoc ""))
8045 (set-buffer gnus-summary-buffer)
8046 gnus-current-article)))
8047 (ogroup gnus-newsgroup-name)
8048 (params (append (gnus-info-params (gnus-get-info ogroup))
8049 (list (cons 'to-group ogroup))
8050 (list (cons 'save-article-group ogroup))))
8051 (case-fold-search t)
8052 (buf (current-buffer))
8055 (set-buffer gnus-original-article-buffer)
8056 ;; Have the digest group inherit the main mail address of
8057 ;; the parent article.
8058 (when (setq to-address (or (gnus-fetch-field "reply-to")
8059 (gnus-fetch-field "from")))
8060 (setq params (append
8061 (list (cons 'to-address
8062 (funcall gnus-decode-encoded-word-function
8064 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8065 (insert-buffer-substring gnus-original-article-buffer)
8066 ;; Remove lines that may lead nndoc to misinterpret the
8069 (goto-char (point-min))
8070 (or (search-forward "\n\n" nil t) (point)))
8071 (goto-char (point-min))
8072 (delete-matching-lines "^Path:\\|^From ")
8075 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8076 (gnus-newsgroup-ephemeral-ignored-charsets
8077 gnus-newsgroup-ignored-charsets))
8078 (gnus-group-read-ephemeral-group
8079 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8081 ,(if force 'mbox 'guess)))
8083 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8085 ;; Make all postings to this group go to the parent group.
8086 (nconc (gnus-info-params (gnus-get-info name))
8088 ;; Couldn't select this doc group.
8089 (switch-to-buffer buf)
8090 (gnus-set-global-variables)
8091 (gnus-configure-windows 'summary)
8092 (gnus-message 3 "Article couldn't be entered?"))
8093 (kill-buffer dig)))))
8095 (defun gnus-summary-read-document (n)
8096 "Open a new group based on the current article(s).
8097 This will allow you to read digests and other similar
8098 documents as newsgroups.
8099 Obeys the standard process/prefix convention."
8101 (let* ((articles (gnus-summary-work-articles n))
8102 (ogroup gnus-newsgroup-name)
8103 (params (append (gnus-info-params (gnus-get-info ogroup))
8104 (list (cons 'to-group ogroup))))
8105 article group egroup groups vgroup)
8106 (while (setq article (pop articles))
8107 (setq group (format "%s-%d" gnus-newsgroup-name article))
8108 (gnus-summary-remove-process-mark article)
8109 (when (gnus-summary-display-article article)
8112 (insert-buffer-substring gnus-original-article-buffer)
8113 ;; Remove some headers that may lead nndoc to make
8115 (message-narrow-to-head)
8116 (goto-char (point-min))
8117 (delete-matching-lines "^\\(Path\\):\\|^From ")
8120 (gnus-group-read-ephemeral-group
8121 group `(nndoc ,group (nndoc-address ,(current-buffer))
8122 (nndoc-article-type guess))
8125 ;; Make all postings to this group go to the parent group.
8126 (nconc (gnus-info-params (gnus-get-info egroup))
8128 (push egroup groups))
8129 ;; Couldn't select this doc group.
8130 (gnus-error 3 "Article couldn't be entered"))))))
8131 ;; Now we have selected all the documents.
8134 (error "None of the articles could be interpreted as documents"))
8135 ((gnus-group-read-ephemeral-group
8136 (setq vgroup (format
8137 "nnvirtual:%s-%s" gnus-newsgroup-name
8138 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8139 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8141 (cons (current-buffer) 'summary)))
8143 (error "Couldn't select virtual nndoc group")))))
8145 (defun gnus-summary-isearch-article (&optional regexp-p)
8146 "Do incremental search forward on the current article.
8147 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8149 (gnus-summary-select-article)
8150 (gnus-configure-windows 'article)
8151 (gnus-eval-in-buffer-window gnus-article-buffer
8154 (isearch-forward regexp-p))))
8156 (defun gnus-summary-search-article-forward (regexp &optional backward)
8157 "Search for an article containing REGEXP forward.
8158 If BACKWARD, search backward instead."
8161 (format "Search article %s (regexp%s): "
8162 (if current-prefix-arg "backward" "forward")
8163 (if gnus-last-search-regexp
8164 (concat ", default " gnus-last-search-regexp)
8166 current-prefix-arg))
8167 (if (string-equal regexp "")
8168 (setq regexp (or gnus-last-search-regexp ""))
8169 (setq gnus-last-search-regexp regexp)
8170 (setq gnus-article-before-search gnus-current-article))
8171 ;; Intentionally set gnus-last-article.
8172 (setq gnus-last-article gnus-article-before-search)
8173 (let ((gnus-last-article gnus-last-article))
8174 (if (gnus-summary-search-article regexp backward)
8175 (gnus-summary-show-thread)
8176 (error "Search failed: \"%s\"" regexp))))
8178 (defun gnus-summary-search-article-backward (regexp)
8179 "Search for an article containing REGEXP backward."
8182 (format "Search article backward (regexp%s): "
8183 (if gnus-last-search-regexp
8184 (concat ", default " gnus-last-search-regexp)
8186 (gnus-summary-search-article-forward regexp 'backward))
8188 (defun gnus-summary-search-article (regexp &optional backward)
8189 "Search for an article containing REGEXP.
8190 Optional argument BACKWARD means do search for backward.
8191 `gnus-select-article-hook' is not called during the search."
8192 ;; We have to require this here to make sure that the following
8193 ;; dynamic binding isn't shadowed by autoloading.
8194 (require 'gnus-async)
8196 (let ((gnus-select-article-hook nil) ;Disable hook.
8197 (gnus-article-prepare-hook nil)
8198 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8199 (gnus-use-article-prefetch nil)
8200 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8201 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8202 (sum (current-buffer))
8203 (gnus-display-mime-function nil)
8206 (gnus-save-hidden-threads
8207 (gnus-summary-select-article)
8208 (set-buffer gnus-article-buffer)
8209 (goto-char (window-point (get-buffer-window (current-buffer))))
8213 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8215 (re-search-backward regexp nil t)
8216 (re-search-forward regexp nil t))
8217 ;; We found the regexp.
8222 (get-buffer-window (current-buffer))
8226 (get-buffer-window (current-buffer))
8229 (setq point (point)))
8230 ;; We didn't find it, so we go to the next article.
8233 (while (eq found 'not)
8234 (if (not (if backward (gnus-summary-find-prev)
8235 (gnus-summary-find-next)))
8236 ;; No more articles.
8238 ;; Select the next article and adjust point.
8239 (unless (gnus-summary-article-sparse-p
8240 (gnus-summary-article-number))
8242 (gnus-summary-select-article)
8243 (set-buffer gnus-article-buffer)
8245 (goto-char (if backward (point-max) (point-min))))))))
8246 (gnus-message 7 ""))
8247 ;; Return whether we found the regexp.
8248 (when (eq found 'found)
8250 (gnus-summary-show-thread)
8251 (gnus-summary-goto-subject gnus-current-article)
8252 (gnus-summary-position-point)
8255 (defun gnus-find-matching-articles (header regexp)
8256 "Return a list of all articles that match REGEXP on HEADER.
8257 This search includes all articles in the current group that Gnus has
8258 fetched headers for, whether they are displayed or not."
8259 (let ((articles nil)
8260 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8261 (case-fold-search t))
8262 (dolist (header gnus-newsgroup-headers)
8263 (when (string-match regexp (funcall func header))
8264 (push (mail-header-number header) articles)))
8265 (nreverse articles)))
8267 (defun gnus-summary-find-matching (header regexp &optional backward unread
8268 not-case-fold not-matching)
8269 "Return a list of all articles that match REGEXP on HEADER.
8270 The search stars on the current article and goes forwards unless
8271 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8272 If UNREAD is non-nil, only unread articles will
8273 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8274 in the comparisons. If NOT-MATCHING, return a list of all articles that
8275 not match REGEXP on HEADER."
8276 (let ((case-fold-search (not not-case-fold))
8279 (if (eq (car header) 'extra)
8282 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8284 (error "%s is an invalid header" header))
8285 (unless (fboundp (intern (concat "mail-header-" header)))
8286 (error "%s is not a valid header" header))
8287 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8288 (dolist (d (if (eq backward 'all)
8290 (gnus-data-find-list
8291 (gnus-summary-article-number)
8292 (gnus-data-list backward))))
8293 (when (and (or (not unread) ; We want all articles...
8294 (gnus-data-unread-p d)) ; Or just unreads.
8295 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8299 (funcall func (gnus-data-header d))))
8300 (string-match regexp
8301 (funcall func (gnus-data-header d)))))
8302 (push (gnus-data-number d) articles))) ; Success!
8303 (nreverse articles)))
8305 (defun gnus-summary-execute-command (header regexp command &optional backward)
8306 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8307 If HEADER is an empty string (or nil), the match is done on the entire
8308 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8310 (list (let ((completion-ignore-case t))
8313 (mapcar (lambda (header) (list (format "%s" header)))
8315 '("Number" "Subject" "From" "Lines" "Date"
8316 "Message-ID" "Xref" "References" "Body")
8317 gnus-extra-headers))
8318 nil 'require-match))
8319 (read-string "Regexp: ")
8320 (read-key-sequence "Command: ")
8321 current-prefix-arg))
8322 (when (equal header "Body")
8324 ;; Hidden thread subtrees must be searched as well.
8325 (gnus-summary-show-all-threads)
8326 ;; We don't want to change current point nor window configuration.
8328 (save-window-excursion
8330 gnus-treat-strip-trailing-blank-lines
8331 gnus-treat-strip-leading-blank-lines
8332 gnus-treat-strip-multiple-blank-lines
8333 gnus-treat-hide-boring-headers
8334 gnus-treat-fold-newsgroups
8335 gnus-article-prepare-hook)
8336 (gnus-message 6 "Executing %s..." (key-description command))
8337 ;; We'd like to execute COMMAND interactively so as to give arguments.
8338 (gnus-execute header regexp
8339 `(call-interactively ',(key-binding command))
8341 (gnus-message 6 "Executing %s...done" (key-description command))))))
8343 (defun gnus-summary-beginning-of-article ()
8344 "Scroll the article back to the beginning."
8346 (gnus-summary-select-article)
8347 (gnus-configure-windows 'article)
8348 (gnus-eval-in-buffer-window gnus-article-buffer
8350 (goto-char (point-min))
8351 (when gnus-page-broken
8352 (gnus-narrow-to-page))))
8354 (defun gnus-summary-end-of-article ()
8355 "Scroll to the end of the article."
8357 (gnus-summary-select-article)
8358 (gnus-configure-windows 'article)
8359 (gnus-eval-in-buffer-window gnus-article-buffer
8361 (goto-char (point-max))
8363 (when gnus-page-broken
8364 (gnus-narrow-to-page))))
8366 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8367 "Truncate to LEN and quote all \"(\"'s in STRING."
8368 (gnus-replace-in-string (if (and len (> (length string) len))
8369 (substring string 0 len)
8373 (defun gnus-summary-print-article (&optional filename n)
8374 "Generate and print a PostScript image of the N next (mail) articles.
8376 If N is negative, print the N previous articles. If N is nil and articles
8377 have been marked with the process mark, print these instead.
8379 If the optional first argument FILENAME is nil, send the image to the
8380 printer. If FILENAME is a string, save the PostScript image in a file with
8381 that name. If FILENAME is a number, prompt the user for the name of the file
8383 (interactive (list (ps-print-preprint current-prefix-arg)))
8384 (dolist (article (gnus-summary-work-articles n))
8385 (gnus-summary-select-article nil nil 'pseudo article)
8386 (gnus-eval-in-buffer-window gnus-article-buffer
8387 (gnus-print-buffer))
8388 (gnus-summary-remove-process-mark article))
8389 (ps-despool filename))
8391 (defun gnus-print-buffer ()
8392 (let ((buffer (generate-new-buffer " *print*")))
8395 (copy-to-buffer buffer (point-min) (point-max))
8397 (gnus-article-delete-invisible-text)
8398 (gnus-remove-text-with-property 'gnus-decoration)
8399 (when (gnus-visual-p 'article-highlight 'highlight)
8400 ;; Copy-to-buffer doesn't copy overlay. So redo
8402 (let ((gnus-article-buffer buffer))
8403 (gnus-article-highlight-citation t)
8404 (gnus-article-highlight-signature)))
8405 (let ((ps-left-header
8408 (gnus-summary-print-truncate-and-quote
8409 (mail-header-subject gnus-current-headers)
8412 (gnus-summary-print-truncate-and-quote
8413 (mail-header-from gnus-current-headers)
8417 "/pagenumberstring load"
8419 (mail-header-date gnus-current-headers) ")"))))
8420 (gnus-run-hooks 'gnus-ps-print-hook)
8423 (ps-spool-buffer-with-faces)
8424 (ps-spool-buffer)))))
8425 (kill-buffer buffer))))
8427 (defun gnus-summary-show-article (&optional arg)
8428 "Force redisplaying of the current article.
8429 If ARG (the prefix) is a number, show the article with the charset
8430 defined in `gnus-summary-show-article-charset-alist', or the charset
8432 If ARG (the prefix) is non-nil and not a number, show the raw article
8433 without any article massaging functions being run. Normally, the key strokes
8438 (gnus-summary-show-article t)
8439 (let ((gnus-newsgroup-charset
8440 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8441 (mm-read-coding-system
8442 "View as charset: " ;; actually it is coding system.
8444 (set-buffer gnus-article-buffer)
8445 (mm-detect-coding-region (point) (point-max))))))
8446 (gnus-newsgroup-ignored-charsets 'gnus-all))
8447 (gnus-summary-select-article nil 'force)
8448 (let ((deps gnus-newsgroup-dependencies)
8451 (set-buffer gnus-original-article-buffer)
8453 (message-narrow-to-head)
8454 (setq head (buffer-string))
8455 (goto-char (point-min))
8456 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8457 (goto-char (point-max))
8459 (setq lines (1- (count-lines (point) (point-max))))))
8461 (insert (format "211 %d Article retrieved.\n"
8462 (cdr gnus-article-current)))
8464 (if lines (insert (format "Lines: %d\n" lines)))
8466 (let ((nntp-server-buffer (current-buffer)))
8467 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8468 (gnus-data-set-header
8469 (gnus-data-find (cdr gnus-article-current))
8471 (gnus-summary-update-article-line
8472 (cdr gnus-article-current) header)
8473 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8474 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8476 ;; Select the article the normal way.
8477 (gnus-summary-select-article nil 'force))
8479 ;; We have to require this here to make sure that the following
8480 ;; dynamic binding isn't shadowed by autoloading.
8481 (require 'gnus-async)
8483 ;; Bind the article treatment functions to nil.
8484 (let ((gnus-have-all-headers t)
8485 gnus-article-prepare-hook
8486 gnus-article-decode-hook
8487 gnus-display-mime-function
8489 ;; Destroy any MIME parts.
8490 (when (gnus-buffer-live-p gnus-article-buffer)
8492 (set-buffer gnus-article-buffer)
8493 (mm-destroy-parts gnus-article-mime-handles)
8494 ;; Set it to nil for safety reason.
8495 (setq gnus-article-mime-handle-alist nil)
8496 (setq gnus-article-mime-handles nil)))
8497 (gnus-summary-select-article nil 'force))))
8498 (gnus-summary-goto-subject gnus-current-article)
8499 (gnus-summary-position-point))
8501 (defun gnus-summary-show-raw-article ()
8502 "Show the raw article without any article massaging functions being run."
8504 (gnus-summary-show-article t))
8506 (defun gnus-summary-verbose-headers (&optional arg)
8507 "Toggle permanent full header display.
8508 If ARG is a positive number, turn header display on.
8509 If ARG is a negative number, turn header display off."
8511 (setq gnus-show-all-headers
8512 (cond ((or (not (numberp arg))
8514 (not gnus-show-all-headers))
8517 (gnus-summary-show-article))
8519 (defun gnus-summary-toggle-header (&optional arg)
8520 "Show the headers if they are hidden, or hide them if they are shown.
8521 If ARG is a positive number, show the entire header.
8522 If ARG is a negative number, hide the unwanted header lines."
8524 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8525 (get-buffer-window gnus-article-buffer t))))
8526 (with-current-buffer gnus-article-buffer
8528 (article-narrow-to-head)
8529 (let* ((buffer-read-only nil)
8530 (inhibit-point-motion-hooks t)
8531 (hidden (if (numberp arg)
8533 (gnus-article-hidden-text-p 'headers)))
8535 (delete-region (point-min) (point-max))
8536 (with-current-buffer gnus-original-article-buffer
8537 (goto-char (setq s (point-min)))
8538 (setq e (if (search-forward "\n\n" nil t)
8541 (insert-buffer-substring gnus-original-article-buffer s e)
8542 (article-decode-encoded-words)
8544 (let ((gnus-treat-hide-headers nil)
8545 (gnus-treat-hide-boring-headers nil))
8546 (gnus-delete-wash-type 'headers)
8547 (gnus-treat-article 'head))
8548 (gnus-treat-article 'head))
8551 (set-window-start window (goto-char (point-min))))
8552 (setq gnus-page-broken
8553 (when gnus-break-pages
8554 (gnus-narrow-to-page)
8556 (gnus-set-mode-line 'article)))))
8558 (defun gnus-summary-show-all-headers ()
8559 "Make all header lines visible."
8561 (gnus-summary-toggle-header 1))
8563 (defun gnus-summary-caesar-message (&optional arg)
8564 "Caesar rotate the current article by 13.
8565 The numerical prefix specifies how many places to rotate each letter
8568 (gnus-summary-select-article)
8569 (let ((mail-header-separator ""))
8570 (gnus-eval-in-buffer-window gnus-article-buffer
8573 (let ((start (window-start))
8575 (message-caesar-buffer-body arg)
8576 (set-window-start (get-buffer-window (current-buffer)) start))))))
8578 (autoload 'unmorse-region "morse"
8579 "Convert morse coded text in region to ordinary ASCII text."
8582 (defun gnus-summary-morse-message (&optional arg)
8583 "Morse decode the current article."
8585 (gnus-summary-select-article)
8586 (let ((mail-header-separator ""))
8587 (gnus-eval-in-buffer-window gnus-article-buffer
8591 (let ((pos (window-start))
8593 (goto-char (point-min))
8594 (when (message-goto-body)
8595 (gnus-narrow-to-body))
8596 (goto-char (point-min))
8597 (while (re-search-forward "·" (point-max) t)
8598 (replace-match "."))
8599 (unmorse-region (point-min) (point-max))
8601 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8603 (defun gnus-summary-stop-page-breaking ()
8604 "Stop page breaking in the current article."
8606 (gnus-summary-select-article)
8607 (gnus-eval-in-buffer-window gnus-article-buffer
8609 (when (gnus-visual-p 'page-marker)
8610 (let ((buffer-read-only nil))
8611 (gnus-remove-text-with-property 'gnus-prev)
8612 (gnus-remove-text-with-property 'gnus-next))
8613 (setq gnus-page-broken nil))))
8615 (defun gnus-summary-move-article (&optional n to-newsgroup
8616 select-method action)
8617 "Move the current article to a different newsgroup.
8618 If N is a positive number, move the N next articles.
8619 If N is a negative number, move the N previous articles.
8620 If N is nil and any articles have been marked with the process mark,
8621 move those articles instead.
8622 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8623 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8624 re-spool using this method.
8626 When called interactively with TO-NEWSGROUP being nil, the value of
8627 the variable `gnus-move-split-methods' is used for finding a default
8628 for the target newsgroup.
8630 For this function to work, both the current newsgroup and the
8631 newsgroup that you want to move to have to support the `request-move'
8632 and `request-accept' functions.
8634 ACTION can be either `move' (the default), `crosspost' or `copy'."
8637 (setq action 'move))
8638 ;; Check whether the source group supports the required functions.
8639 (cond ((and (eq action 'move)
8640 (not (gnus-check-backend-function
8641 'request-move-article gnus-newsgroup-name)))
8642 (error "The current group does not support article moving"))
8643 ((and (eq action 'crosspost)
8644 (not (gnus-check-backend-function
8645 'request-replace-article gnus-newsgroup-name)))
8646 (error "The current group does not support article editing")))
8647 (let ((articles (gnus-summary-work-articles n))
8648 (prefix (if (gnus-check-backend-function
8649 'request-move-article gnus-newsgroup-name)
8650 (gnus-group-real-prefix gnus-newsgroup-name)
8652 (names '((move "Move" "Moving")
8653 (copy "Copy" "Copying")
8654 (crosspost "Crosspost" "Crossposting")))
8655 (copy-buf (save-excursion
8656 (nnheader-set-temp-buffer " *copy article*")))
8657 art-group to-method new-xref article to-groups)
8658 (unless (assq action names)
8659 (error "Unknown action %s" action))
8660 ;; Read the newsgroup name.
8661 (when (and (not to-newsgroup)
8662 (not select-method))
8663 (if (and gnus-move-split-methods
8665 (and (memq gnus-current-article articles)
8666 (gnus-buffer-live-p gnus-original-article-buffer))))
8667 ;; When `gnus-move-split-methods' is non-nil, we have to
8668 ;; select an article to give `gnus-read-move-group-name' an
8669 ;; opportunity to suggest an appropriate default. However,
8670 ;; we needn't render or mark the article.
8671 (let ((gnus-display-mime-function nil)
8672 (gnus-article-prepare-hook nil)
8673 (gnus-mark-article-hook nil))
8674 (gnus-summary-select-article nil nil nil (car articles))))
8676 (gnus-read-move-group-name
8677 (cadr (assq action names))
8678 (symbol-value (intern (format "gnus-current-%s-group" action)))
8680 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8681 (setq to-method (or select-method
8682 (gnus-server-to-method
8683 (gnus-group-method to-newsgroup))))
8684 ;; Check the method we are to move this article to...
8685 (unless (gnus-check-backend-function
8686 'request-accept-article (car to-method))
8687 (error "%s does not support article copying" (car to-method)))
8688 (unless (gnus-check-server to-method)
8689 (error "Can't open server %s" (car to-method)))
8690 (gnus-message 6 "%s to %s: %s..."
8691 (caddr (assq action names))
8692 (or (car select-method) to-newsgroup) articles)
8694 (setq article (pop articles))
8698 ;; Move the article.
8700 ;; Remove this article from future suppression.
8701 (gnus-dup-unsuppress-article article)
8702 (gnus-request-move-article
8703 article ; Article to move
8704 gnus-newsgroup-name ; From newsgroup
8705 (nth 1 (gnus-find-method-for-group
8706 gnus-newsgroup-name)) ; Server
8707 (list 'gnus-request-accept-article
8708 to-newsgroup (list 'quote select-method)
8709 (not articles) t) ; Accept form
8710 (not articles))) ; Only save nov last time
8711 ;; Copy the article.
8714 (set-buffer copy-buf)
8715 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8716 (gnus-request-accept-article
8717 to-newsgroup select-method (not articles) t))))
8718 ;; Crosspost the article.
8719 ((eq action 'crosspost)
8720 (let ((xref (message-tokenize-header
8721 (mail-header-xref (gnus-summary-article-header article))
8723 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8724 ":" (number-to-string article)))
8726 (setq xref (list (system-name))))
8729 (mapconcat 'identity
8730 (delete "Xref:" (delete new-xref xref))
8734 (set-buffer copy-buf)
8735 ;; First put the article in the destination group.
8736 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8737 (when (consp (setq art-group
8738 (gnus-request-accept-article
8739 to-newsgroup select-method (not articles))))
8740 (setq new-xref (concat new-xref " " (car art-group)
8742 (number-to-string (cdr art-group))))
8743 ;; Now we have the new Xrefs header, so we insert
8744 ;; it and replace the new article.
8745 (nnheader-replace-header "Xref" new-xref)
8746 (gnus-request-replace-article
8747 (cdr art-group) to-newsgroup (current-buffer))
8751 (gnus-message 1 "Couldn't %s article %s: %s"
8752 (cadr (assq action names)) article
8753 (nnheader-get-report (car to-method))))
8754 ((eq art-group 'junk)
8755 (when (eq action 'move)
8756 (gnus-summary-mark-article article gnus-canceled-mark)
8757 (gnus-message 4 "Deleted article %s" article)))
8759 (let* ((pto-group (gnus-group-prefixed-name
8760 (car art-group) to-method))
8762 (gnus-gethash pto-group gnus-newsrc-hashtb))
8763 (info (nth 2 entry))
8764 (to-group (gnus-info-group info))
8766 ;; Update the group that has been moved to.
8768 (memq action '(move copy)))
8769 (unless (member to-group to-groups)
8770 (push to-group to-groups))
8772 (unless (memq article gnus-newsgroup-unreads)
8773 (push 'read to-marks)
8775 info (gnus-add-to-range (gnus-info-read info)
8776 (list (cdr art-group)))))
8778 ;; See whether the article is to be put in the cache.
8779 (let ((marks gnus-article-mark-lists)
8780 (to-article (cdr art-group)))
8782 ;; Enter the article into the cache in the new group,
8783 ;; if that is required.
8784 (when gnus-use-cache
8785 (gnus-cache-possibly-enter-article
8787 (memq article gnus-newsgroup-marked)
8788 (memq article gnus-newsgroup-dormant)
8789 (memq article gnus-newsgroup-unreads)))
8791 (when gnus-preserve-marks
8792 ;; Copy any marks over to the new group.
8793 (when (and (equal to-group gnus-newsgroup-name)
8794 (not (memq article gnus-newsgroup-unreads)))
8795 ;; Mark this article as read in this group.
8796 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8797 (setcdr (gnus-active to-group) to-article)
8798 (setcdr gnus-newsgroup-active to-article))
8801 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8802 (when (memq article (symbol-value
8803 (intern (format "gnus-newsgroup-%s"
8805 (push (cdar marks) to-marks)
8806 ;; If the other group is the same as this group,
8807 ;; then we have to add the mark to the list.
8808 (when (equal to-group gnus-newsgroup-name)
8809 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8812 (intern (format "gnus-newsgroup-%s"
8814 ;; Copy the marks to other group.
8815 (gnus-add-marked-articles
8816 to-group (cdar marks) (list to-article) info)))
8817 (setq marks (cdr marks)))
8819 (gnus-request-set-mark
8820 to-group (list (list (list to-article) 'add to-marks))))
8823 (concat "(gnus-group-set-info '"
8824 (gnus-prin1-to-string (gnus-get-info to-group))
8827 ;; Update the Xref header in this article to point to
8828 ;; the new crossposted article we have just created.
8829 (when (eq action 'crosspost)
8831 (set-buffer copy-buf)
8832 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8833 (nnheader-replace-header "Xref" new-xref)
8834 (gnus-request-replace-article
8835 article gnus-newsgroup-name (current-buffer)))))
8837 ;;;!!!Why is this necessary?
8838 (set-buffer gnus-summary-buffer)
8840 (gnus-summary-goto-subject article)
8841 (when (eq action 'move)
8842 (gnus-summary-mark-article article gnus-canceled-mark))))
8843 (gnus-summary-remove-process-mark article))
8844 ;; Re-activate all groups that have been moved to.
8846 (set-buffer gnus-group-buffer)
8847 (let ((gnus-group-marked to-groups))
8848 (gnus-group-get-new-news-this-group nil t)))
8850 (gnus-kill-buffer copy-buf)
8851 (gnus-summary-position-point)
8852 (gnus-set-mode-line 'summary)))
8854 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8855 "Move the current article to a different newsgroup.
8856 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8857 When called interactively, if TO-NEWSGROUP is nil, use the value of
8858 the variable `gnus-move-split-methods' for finding a default target
8860 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8861 re-spool using this method."
8863 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8865 (defun gnus-summary-crosspost-article (&optional n)
8866 "Crosspost the current article to some other group."
8868 (gnus-summary-move-article n nil nil 'crosspost))
8870 (defcustom gnus-summary-respool-default-method nil
8871 "Default method type for respooling an article.
8872 If nil, use to the current newsgroup method."
8874 :group 'gnus-summary-mail)
8876 (defcustom gnus-summary-display-while-building nil
8877 "If not-nil, show and update the summary buffer as it's being built.
8878 If the value is t, update the buffer after every line is inserted. If
8879 the value is an integer (N), update the display every N lines."
8881 :type '(choice (const :tag "off" nil)
8883 (const :tag "frequently" t)))
8885 (defun gnus-summary-respool-article (&optional n method)
8886 "Respool the current article.
8887 The article will be squeezed through the mail spooling process again,
8888 which means that it will be put in some mail newsgroup or other
8889 depending on `nnmail-split-methods'.
8890 If N is a positive number, respool the N next articles.
8891 If N is a negative number, respool the N previous articles.
8892 If N is nil and any articles have been marked with the process mark,
8893 respool those articles instead.
8895 Respooling can be done both from mail groups and \"real\" newsgroups.
8896 In the former case, the articles in question will be moved from the
8897 current group into whatever groups they are destined to. In the
8898 latter case, they will be copied into the relevant groups."
8900 (list current-prefix-arg
8901 (let* ((methods (gnus-methods-using 'respool))
8903 (symbol-name (or gnus-summary-respool-default-method
8904 (car (gnus-find-method-for-group
8905 gnus-newsgroup-name)))))
8907 (gnus-completing-read-with-default
8908 methname "What backend do you want to use when respooling?"
8909 methods nil t nil 'gnus-mail-method-history))
8912 ((zerop (length (setq ms (gnus-servers-using-backend
8914 (list (intern method) ""))
8918 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8919 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8922 (error "No method given for respooling"))
8923 (if (assoc (symbol-name
8924 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8925 (gnus-methods-using 'respool))
8926 (gnus-summary-move-article n nil method)
8927 (gnus-summary-copy-article n nil method)))
8929 (defun gnus-summary-import-article (file &optional edit)
8930 "Import an arbitrary file into a mail newsgroup."
8931 (interactive "fImport file: \nP")
8932 (let ((group gnus-newsgroup-name)
8933 (now (current-time))
8934 atts lines group-art)
8935 (unless (gnus-check-backend-function 'request-accept-article group)
8936 (error "%s does not support article importing" group))
8937 (or (file-readable-p file)
8938 (not (file-regular-p file))
8939 (error "Can't read %s" file))
8941 (set-buffer (gnus-get-buffer-create " *import file*"))
8943 (nnheader-insert-file-contents file)
8944 (goto-char (point-min))
8945 (if (nnheader-article-p)
8947 (goto-char (point-min))
8948 (search-forward "\n\n" nil t)
8949 (narrow-to-region (point-min) (1- (point)))
8950 (goto-char (point-min))
8951 (unless (re-search-forward "^date:" nil t)
8952 (goto-char (point-max))
8953 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8954 ;; This doesn't look like an article, so we fudge some headers.
8955 (setq atts (file-attributes file)
8956 lines (count-lines (point-min) (point-max)))
8957 (insert "From: " (read-string "From: ") "\n"
8958 "Subject: " (read-string "Subject: ") "\n"
8959 "Date: " (message-make-date (nth 5 atts)) "\n"
8960 "Message-ID: " (message-make-message-id) "\n"
8961 "Lines: " (int-to-string lines) "\n"
8962 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8963 (setq group-art (gnus-request-accept-article group nil t))
8964 (kill-buffer (current-buffer)))
8965 (setq gnus-newsgroup-active (gnus-activate-group group))
8967 (gnus-summary-goto-article (cdr group-art) nil t)
8969 (gnus-summary-edit-article))))
8971 (defun gnus-summary-create-article ()
8972 "Create an article in a mail newsgroup."
8974 (let ((group gnus-newsgroup-name)
8975 (now (current-time))
8977 (unless (gnus-check-backend-function 'request-accept-article group)
8978 (error "%s does not support article importing" group))
8980 (set-buffer (gnus-get-buffer-create " *import file*"))
8982 (goto-char (point-min))
8983 ;; This doesn't look like an article, so we fudge some headers.
8984 (insert "From: " (read-string "From: ") "\n"
8985 "Subject: " (read-string "Subject: ") "\n"
8986 "Date: " (message-make-date now) "\n"
8987 "Message-ID: " (message-make-message-id) "\n")
8988 (setq group-art (gnus-request-accept-article group nil t))
8989 (kill-buffer (current-buffer)))
8990 (setq gnus-newsgroup-active (gnus-activate-group group))
8992 (gnus-summary-goto-article (cdr group-art) nil t)
8993 (gnus-summary-edit-article)))
8995 (defun gnus-summary-article-posted-p ()
8996 "Say whether the current (mail) article is available from news as well.
8997 This will be the case if the article has both been mailed and posted."
8999 (let ((id (mail-header-references (gnus-summary-article-header)))
9000 (gnus-override-method (car (gnus-refer-article-methods))))
9001 (if (gnus-request-head id "")
9002 (gnus-message 2 "The current message was found on %s"
9003 gnus-override-method)
9004 (gnus-message 2 "The current message couldn't be found on %s"
9005 gnus-override-method)
9008 (defun gnus-summary-expire-articles (&optional now)
9009 "Expire all articles that are marked as expirable in the current group."
9011 (when (gnus-check-backend-function
9012 'request-expire-articles gnus-newsgroup-name)
9013 ;; This backend supports expiry.
9014 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9015 (expirable (if total
9017 ;; We need to update the info for
9018 ;; this group for `gnus-list-of-read-articles'
9019 ;; to give us the right answer.
9020 (gnus-run-hooks 'gnus-exit-group-hook)
9021 (gnus-summary-update-info)
9022 (gnus-list-of-read-articles gnus-newsgroup-name))
9023 (setq gnus-newsgroup-expirable
9024 (sort gnus-newsgroup-expirable '<))))
9025 (expiry-wait (if now 'immediate
9026 (gnus-group-find-parameter
9027 gnus-newsgroup-name 'expiry-wait)))
9028 (nnmail-expiry-target
9029 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9030 nnmail-expiry-target))
9033 ;; There are expirable articles in this group, so we run them
9034 ;; through the expiry process.
9035 (gnus-message 6 "Expiring articles...")
9036 (unless (gnus-check-group gnus-newsgroup-name)
9037 (error "Can't open server for %s" gnus-newsgroup-name))
9038 ;; The list of articles that weren't expired is returned.
9041 (let ((nnmail-expiry-wait-function nil)
9042 (nnmail-expiry-wait expiry-wait))
9043 (setq es (gnus-request-expire-articles
9044 expirable gnus-newsgroup-name)))
9045 (setq es (gnus-request-expire-articles
9046 expirable gnus-newsgroup-name)))
9048 (setq gnus-newsgroup-expirable es))
9049 ;; We go through the old list of expirable, and mark all
9050 ;; really expired articles as nonexistent.
9051 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9052 (let ((gnus-use-cache nil))
9053 (dolist (article expirable)
9054 (when (and (not (memq article es))
9055 (gnus-data-find article))
9056 (gnus-summary-mark-article article gnus-canceled-mark))))))
9057 (gnus-message 6 "Expiring articles...done")))))
9059 (defun gnus-summary-expire-articles-now ()
9060 "Expunge all expirable articles in the current group.
9061 This means that *all* articles that are marked as expirable will be
9062 deleted forever, right now."
9064 (or gnus-expert-user
9066 "Are you really, really, really sure you want to delete all these messages? ")
9068 (gnus-summary-expire-articles t))
9070 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9071 (defun gnus-summary-delete-article (&optional n)
9072 "Delete the N next (mail) articles.
9073 This command actually deletes articles. This is not a marking
9074 command. The article will disappear forever from your life, never to
9076 If N is negative, delete backwards.
9077 If N is nil and articles have been marked with the process mark,
9078 delete these instead."
9080 (unless (gnus-check-backend-function 'request-expire-articles
9081 gnus-newsgroup-name)
9082 (error "The current newsgroup does not support article deletion"))
9083 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9084 (error "Couldn't open server"))
9085 ;; Compute the list of articles to delete.
9086 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9087 (nnmail-expiry-target 'delete)
9089 (if (and gnus-novice-user
9090 (not (gnus-yes-or-no-p
9091 (format "Do you really want to delete %s forever? "
9092 (if (> (length articles) 1)
9093 (format "these %s articles" (length articles))
9096 ;; Delete the articles.
9097 (setq not-deleted (gnus-request-expire-articles
9098 articles gnus-newsgroup-name 'force))
9100 (gnus-summary-remove-process-mark (car articles))
9101 ;; The backend might not have been able to delete the article
9103 (unless (memq (car articles) not-deleted)
9104 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9105 (setq articles (cdr articles)))
9107 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9108 (gnus-summary-position-point)
9109 (gnus-set-mode-line 'summary)
9112 (defun gnus-summary-edit-article (&optional arg)
9113 "Edit the current article.
9114 This will have permanent effect only in mail groups.
9115 If ARG is nil, edit the decoded articles.
9116 If ARG is 1, edit the raw articles.
9117 If ARG is 2, edit the raw articles even in read-only groups.
9118 If ARG is 3, edit the articles with the current handles.
9119 Otherwise, allow editing of articles even in read-only
9122 (let (force raw current-handles)
9131 (setq current-handles
9132 (and (gnus-buffer-live-p gnus-article-buffer)
9133 (with-current-buffer gnus-article-buffer
9135 gnus-article-mime-handles
9136 (setq gnus-article-mime-handles nil))))))
9139 (when (and raw (not force)
9140 (member gnus-newsgroup-name '("nndraft:delayed"
9143 (error "Can't edit the raw article in group %s"
9144 gnus-newsgroup-name))
9146 (set-buffer gnus-summary-buffer)
9147 (let ((mail-parse-charset gnus-newsgroup-charset)
9148 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9149 (gnus-set-global-variables)
9150 (when (and (not force)
9151 (gnus-group-read-only-p))
9152 (error "The current newsgroup does not support article editing"))
9153 (gnus-summary-show-article t)
9154 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9155 (with-current-buffer gnus-article-buffer
9156 (mm-enable-multibyte)))
9157 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9159 (gnus-article-edit-article
9162 (let ((mbl mml-buffer-list))
9163 (setq mml-buffer-list nil)
9164 (mime-to-mml ,'current-handles)
9165 (let ((mbl1 mml-buffer-list))
9166 (setq mml-buffer-list mbl)
9167 (set (make-local-variable 'mml-buffer-list) mbl1))
9168 (make-local-hook 'kill-buffer-hook)
9169 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9170 `(lambda (no-highlight)
9171 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9172 (message-options message-options)
9173 (message-options-set-recipient)
9174 (mail-parse-ignored-charsets
9175 ',gnus-newsgroup-ignored-charsets))
9176 ,(if (not raw) '(progn
9178 (mml-destroy-buffers)
9179 (remove-hook 'kill-buffer-hook
9180 'mml-destroy-buffers t)
9181 (kill-local-variable 'mml-buffer-list)))
9182 (gnus-summary-edit-article-done
9183 ,(or (mail-header-references gnus-current-headers) "")
9184 ,(gnus-group-read-only-p)
9185 ,gnus-summary-buffer no-highlight))))))))
9187 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9189 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9191 "Make edits to the current article permanent."
9194 ;; The buffer restriction contains the entire article if it exists.
9195 (when (article-goto-body)
9196 (let ((lines (count-lines (point) (point-max)))
9197 (length (- (point-max) (point)))
9198 (case-fold-search t)
9199 (body (copy-marker (point))))
9200 (goto-char (point-min))
9201 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9202 (delete-region (match-beginning 1) (match-end 1))
9203 (insert (number-to-string length)))
9204 (goto-char (point-min))
9205 (when (re-search-forward
9206 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9207 (delete-region (match-beginning 1) (match-end 1))
9208 (insert (number-to-string length)))
9209 (goto-char (point-min))
9210 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9211 (delete-region (match-beginning 1) (match-end 1))
9212 (insert (number-to-string lines))))))
9213 ;; Replace the article.
9214 (let ((buf (current-buffer)))
9216 (insert-buffer-substring buf)
9218 (if (and (not read-only)
9219 (not (gnus-request-replace-article
9220 (cdr gnus-article-current) (car gnus-article-current)
9221 (current-buffer) t)))
9222 (error "Couldn't replace article")
9223 ;; Update the summary buffer.
9225 (equal (message-tokenize-header references " ")
9226 (message-tokenize-header
9227 (or (message-fetch-field "references") "") " ")))
9228 ;; We only have to update this line.
9231 (message-narrow-to-head)
9232 (let ((head (buffer-string))
9235 (insert (format "211 %d Article retrieved.\n"
9236 (cdr gnus-article-current)))
9239 (let ((nntp-server-buffer (current-buffer)))
9240 (setq header (car (gnus-get-newsgroup-headers
9243 (set-buffer gnus-summary-buffer)
9244 (gnus-data-set-header
9245 (gnus-data-find (cdr gnus-article-current))
9247 (gnus-summary-update-article-line
9248 (cdr gnus-article-current) header)
9249 (if (gnus-summary-goto-subject
9250 (cdr gnus-article-current) nil t)
9251 (gnus-summary-update-secondary-mark
9252 (cdr gnus-article-current))))))))
9254 (set-buffer (or buffer gnus-summary-buffer))
9255 (gnus-summary-update-article (cdr gnus-article-current))
9256 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9257 (gnus-summary-update-secondary-mark
9258 (cdr gnus-article-current))))
9259 ;; Prettify the article buffer again.
9260 (unless no-highlight
9262 (set-buffer gnus-article-buffer)
9263 ;;;!!! Fix this -- article should be rehighlighted.
9264 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9265 (set-buffer gnus-original-article-buffer)
9266 (gnus-request-article
9267 (cdr gnus-article-current)
9268 (car gnus-article-current) (current-buffer))))
9269 ;; Prettify the summary buffer line.
9270 (when (gnus-visual-p 'summary-highlight 'highlight)
9271 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9273 (defun gnus-summary-edit-wash (key)
9274 "Perform editing command KEY in the article buffer."
9278 (message "%s" (concat (this-command-keys) "- "))
9281 (gnus-summary-edit-article)
9282 (execute-kbd-macro (concat (this-command-keys) key))
9283 (gnus-article-edit-done))
9287 (defun gnus-summary-respool-query (&optional silent trace)
9288 "Query where the respool algorithm would put this article."
9290 (let (gnus-mark-article-hook)
9291 (gnus-summary-select-article)
9293 (set-buffer gnus-original-article-buffer)
9295 (message-narrow-to-head)
9296 (let ((groups (nnmail-article-group 'identity trace)))
9299 (message "This message would go to %s"
9300 (mapconcat 'car groups ", "))
9301 (message "This message would go to no groups"))
9304 (defun gnus-summary-respool-trace ()
9305 "Trace where the respool algorithm would put this article.
9306 Display a buffer showing all fancy splitting patterns which matched."
9308 (gnus-summary-respool-query nil t))
9310 ;; Summary marking commands.
9312 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9313 "Mark articles which has the same subject as read, and then select the next.
9314 If UNMARK is positive, remove any kind of mark.
9315 If UNMARK is negative, tick articles."
9318 (setq unmark (prefix-numeric-value unmark)))
9320 (gnus-summary-mark-same-subject
9321 (gnus-summary-article-subject) unmark)))
9322 ;; Select next unread article. If auto-select-same mode, should
9323 ;; select the first unread article.
9324 (gnus-summary-next-article t (and gnus-auto-select-same
9325 (gnus-summary-article-subject)))
9326 (gnus-message 7 "%d article%s marked as %s"
9327 count (if (= count 1) " is" "s are")
9328 (if unmark "unread" "read"))))
9330 (defun gnus-summary-kill-same-subject (&optional unmark)
9331 "Mark articles which has the same subject as read.
9332 If UNMARK is positive, remove any kind of mark.
9333 If UNMARK is negative, tick articles."
9336 (setq unmark (prefix-numeric-value unmark)))
9338 (gnus-summary-mark-same-subject
9339 (gnus-summary-article-subject) unmark)))
9340 ;; If marked as read, go to next unread subject.
9342 ;; Go to next unread subject.
9343 (gnus-summary-next-subject 1 t))
9344 (gnus-message 7 "%d articles are marked as %s"
9345 count (if unmark "unread" "read"))))
9347 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9348 "Mark articles with same SUBJECT as read, and return marked number.
9349 If optional argument UNMARK is positive, remove any kinds of marks.
9350 If optional argument UNMARK is negative, mark articles as unread instead."
9354 ((null unmark) ; Mark as read.
9357 (gnus-summary-mark-article-as-read gnus-killed-mark)
9358 (gnus-summary-show-thread) t)
9359 (gnus-summary-find-subject subject))
9360 (setq count (1+ count))))
9361 ((> unmark 0) ; Tick.
9364 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9365 (gnus-summary-show-thread) t)
9366 (gnus-summary-find-subject subject))
9367 (setq count (1+ count))))
9368 (t ; Mark as unread.
9371 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9372 (gnus-summary-show-thread) t)
9373 (gnus-summary-find-subject subject))
9374 (setq count (1+ count)))))
9375 (gnus-set-mode-line 'summary)
9376 ;; Return the number of marked articles.
9379 (defun gnus-summary-mark-as-processable (n &optional unmark)
9380 "Set the process mark on the next N articles.
9381 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9382 the process mark instead. The difference between N and the actual
9383 number of articles marked is returned."
9385 (if (and (null n) (gnus-region-active-p))
9386 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9387 (setq n (prefix-numeric-value n))
9388 (let ((backward (< n 0))
9393 (gnus-summary-remove-process-mark
9394 (gnus-summary-article-number))
9395 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9396 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9399 (gnus-message 7 "No more articles"))
9400 (gnus-summary-recenter)
9401 (gnus-summary-position-point)
9404 (defun gnus-summary-unmark-as-processable (n)
9405 "Remove the process mark from the next N articles.
9406 If N is negative, unmark backward instead. The difference between N and
9407 the actual number of articles unmarked is returned."
9409 (gnus-summary-mark-as-processable n t))
9411 (defun gnus-summary-unmark-all-processable ()
9412 "Remove the process mark from all articles."
9415 (while gnus-newsgroup-processable
9416 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9417 (gnus-summary-position-point))
9419 (defun gnus-summary-add-mark (article type)
9420 "Mark ARTICLE with a mark of TYPE."
9421 (let ((vtype (car (assq type gnus-article-mark-lists)))
9424 (error "No such mark type: %s" type)
9425 (setq var (intern (format "gnus-newsgroup-%s" type)))
9426 (set var (cons article (symbol-value var)))
9427 (if (memq type '(processable cached replied forwarded recent saved))
9428 (gnus-summary-update-secondary-mark article)
9429 ;;; !!! This is bogus. We should find out what primary
9430 ;;; !!! mark we want to set.
9431 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9433 (defun gnus-summary-mark-as-expirable (n)
9434 "Mark N articles forward as expirable.
9435 If N is negative, mark backward instead. The difference between N and
9436 the actual number of articles marked is returned."
9438 (gnus-summary-mark-forward n gnus-expirable-mark))
9440 (defun gnus-summary-mark-as-spam (n)
9441 "Mark N articles forward as spam.
9442 If N is negative, mark backward instead. The difference between N and
9443 the actual number of articles marked is returned."
9445 (gnus-summary-mark-forward n gnus-spam-mark))
9447 (defun gnus-summary-mark-article-as-replied (article)
9448 "Mark ARTICLE as replied to and update the summary line.
9449 ARTICLE can also be a list of articles."
9450 (interactive (list (gnus-summary-article-number)))
9451 (let ((articles (if (listp article) article (list article))))
9452 (dolist (article articles)
9453 (unless (numberp article)
9454 (error "%s is not a number" article))
9455 (push article gnus-newsgroup-replied)
9456 (let ((buffer-read-only nil))
9457 (when (gnus-summary-goto-subject article nil t)
9458 (gnus-summary-update-secondary-mark article))))))
9460 (defun gnus-summary-mark-article-as-forwarded (article)
9461 "Mark ARTICLE as forwarded and update the summary line.
9462 ARTICLE can also be a list of articles."
9463 (let ((articles (if (listp article) article (list article))))
9464 (dolist (article articles)
9465 (push article gnus-newsgroup-forwarded)
9466 (let ((buffer-read-only nil))
9467 (when (gnus-summary-goto-subject article nil t)
9468 (gnus-summary-update-secondary-mark article))))))
9470 (defun gnus-summary-set-bookmark (article)
9471 "Set a bookmark in current article."
9472 (interactive (list (gnus-summary-article-number)))
9473 (when (or (not (get-buffer gnus-article-buffer))
9474 (not gnus-current-article)
9475 (not gnus-article-current)
9476 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9477 (error "No current article selected"))
9478 ;; Remove old bookmark, if one exists.
9479 (gnus-pull article gnus-newsgroup-bookmarks)
9480 ;; Set the new bookmark, which is on the form
9481 ;; (article-number . line-number-in-body).
9485 (set-buffer gnus-article-buffer)
9492 gnus-newsgroup-bookmarks)
9493 (gnus-message 6 "A bookmark has been added to the current article."))
9495 (defun gnus-summary-remove-bookmark (article)
9496 "Remove the bookmark from the current article."
9497 (interactive (list (gnus-summary-article-number)))
9498 ;; Remove old bookmark, if one exists.
9499 (if (not (assq article gnus-newsgroup-bookmarks))
9500 (gnus-message 6 "No bookmark in current article.")
9501 (gnus-pull article gnus-newsgroup-bookmarks)
9502 (gnus-message 6 "Removed bookmark.")))
9504 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9505 (defun gnus-summary-mark-as-dormant (n)
9506 "Mark N articles forward as dormant.
9507 If N is negative, mark backward instead. The difference between N and
9508 the actual number of articles marked is returned."
9510 (gnus-summary-mark-forward n gnus-dormant-mark))
9512 (defun gnus-summary-set-process-mark (article)
9513 "Set the process mark on ARTICLE and update the summary line."
9514 (setq gnus-newsgroup-processable
9516 (delq article gnus-newsgroup-processable)))
9517 (when (gnus-summary-goto-subject article)
9518 (gnus-summary-show-thread)
9519 (gnus-summary-goto-subject article)
9520 (gnus-summary-update-secondary-mark article)))
9522 (defun gnus-summary-remove-process-mark (article)
9523 "Remove the process mark from ARTICLE and update the summary line."
9524 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9525 (when (gnus-summary-goto-subject article)
9526 (gnus-summary-show-thread)
9527 (gnus-summary-goto-subject article)
9528 (gnus-summary-update-secondary-mark article)))
9530 (defun gnus-summary-set-saved-mark (article)
9531 "Set the process mark on ARTICLE and update the summary line."
9532 (push article gnus-newsgroup-saved)
9533 (when (gnus-summary-goto-subject article)
9534 (gnus-summary-update-secondary-mark article)))
9536 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9537 "Mark N articles as read forwards.
9538 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9539 The difference between N and the actual number of articles marked is
9541 If NO-EXPIRE, auto-expiry will be inhibited."
9543 (gnus-summary-show-thread)
9544 (let ((backward (< n 0))
9545 (gnus-summary-goto-unread
9546 (and gnus-summary-goto-unread
9547 (not (eq gnus-summary-goto-unread 'never))
9548 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9549 gnus-ticked-mark gnus-dormant-mark)))))
9551 (mark (or mark gnus-del-mark)))
9553 (gnus-summary-mark-article nil mark no-expire)
9554 (zerop (gnus-summary-next-subject
9556 (and gnus-summary-goto-unread
9557 (not (eq gnus-summary-goto-unread 'never)))
9561 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9562 (gnus-summary-recenter)
9563 (gnus-summary-position-point)
9564 (gnus-set-mode-line 'summary)
9567 (defun gnus-summary-mark-article-as-read (mark)
9568 "Mark the current article quickly as read with MARK."
9569 (let ((article (gnus-summary-article-number)))
9570 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9571 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9572 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9573 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9574 (push (cons article mark) gnus-newsgroup-reads)
9575 ;; Possibly remove from cache, if that is used.
9576 (when gnus-use-cache
9577 (gnus-cache-enter-remove-article article))
9578 ;; Allow the backend to change the mark.
9579 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9580 ;; Check for auto-expiry.
9581 (when (and gnus-newsgroup-auto-expire
9582 (memq mark gnus-auto-expirable-marks))
9583 (setq mark gnus-expirable-mark)
9584 ;; Let the backend know about the mark change.
9585 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9586 (push article gnus-newsgroup-expirable))
9587 ;; Set the mark in the buffer.
9588 (gnus-summary-update-mark mark 'unread)
9591 (defun gnus-summary-mark-article-as-unread (mark)
9592 "Mark the current article quickly as unread with MARK."
9593 (let* ((article (gnus-summary-article-number))
9594 (old-mark (gnus-summary-article-mark article)))
9595 ;; Allow the backend to change the mark.
9596 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9597 (if (eq mark old-mark)
9601 (gnus-error 1 "Can't mark negative article numbers")
9603 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9604 (setq gnus-newsgroup-spam-marked
9605 (delq article gnus-newsgroup-spam-marked))
9606 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9607 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9608 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9609 (cond ((= mark gnus-ticked-mark)
9610 (setq gnus-newsgroup-marked
9611 (gnus-add-to-sorted-list gnus-newsgroup-marked
9613 ((= mark gnus-spam-mark)
9614 (setq gnus-newsgroup-spam-marked
9615 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9617 ((= mark gnus-dormant-mark)
9618 (setq gnus-newsgroup-dormant
9619 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9622 (setq gnus-newsgroup-unreads
9623 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9625 (gnus-pull article gnus-newsgroup-reads)
9627 ;; See whether the article is to be put in the cache.
9629 (vectorp (gnus-summary-article-header article))
9631 (gnus-cache-possibly-enter-article
9632 gnus-newsgroup-name article
9633 (= mark gnus-ticked-mark)
9634 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9637 (gnus-summary-update-mark mark 'unread)
9640 (defun gnus-summary-mark-article (&optional article mark no-expire)
9641 "Mark ARTICLE with MARK. MARK can be any character.
9642 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9643 `??' (dormant) and `?E' (expirable).
9644 If MARK is nil, then the default character `?r' is used.
9645 If ARTICLE is nil, then the article on the current line will be
9647 If NO-EXPIRE, auto-expiry will be inhibited."
9648 ;; The mark might be a string.
9649 (when (stringp mark)
9650 (setq mark (aref mark 0)))
9651 ;; If no mark is given, then we check auto-expiring.
9653 (setq mark gnus-del-mark))
9654 (when (and (not no-expire)
9655 gnus-newsgroup-auto-expire
9656 (memq mark gnus-auto-expirable-marks))
9657 (setq mark gnus-expirable-mark))
9658 (let ((article (or article (gnus-summary-article-number)))
9659 (old-mark (gnus-summary-article-mark article)))
9660 ;; Allow the backend to change the mark.
9661 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9662 (if (eq mark old-mark)
9665 (error "No article on current line"))
9666 (if (not (if (or (= mark gnus-unread-mark)
9667 (= mark gnus-ticked-mark)
9668 (= mark gnus-spam-mark)
9669 (= mark gnus-dormant-mark))
9670 (gnus-mark-article-as-unread article mark)
9671 (gnus-mark-article-as-read article mark)))
9673 ;; See whether the article is to be put in the cache.
9675 (not (= mark gnus-canceled-mark))
9676 (vectorp (gnus-summary-article-header article))
9678 (gnus-cache-possibly-enter-article
9679 gnus-newsgroup-name article
9680 (= mark gnus-ticked-mark)
9681 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9683 (when (gnus-summary-goto-subject article nil t)
9684 (let ((buffer-read-only nil))
9685 (gnus-summary-show-thread)
9687 (gnus-summary-update-mark mark 'unread)
9690 (defun gnus-summary-update-secondary-mark (article)
9691 "Update the secondary (read, process, cache) mark."
9692 (gnus-summary-update-mark
9693 (cond ((memq article gnus-newsgroup-processable)
9695 ((memq article gnus-newsgroup-cached)
9697 ((memq article gnus-newsgroup-replied)
9699 ((memq article gnus-newsgroup-forwarded)
9700 gnus-forwarded-mark)
9701 ((memq article gnus-newsgroup-saved)
9703 ((memq article gnus-newsgroup-recent)
9705 ((memq article gnus-newsgroup-unseen)
9709 (when (gnus-visual-p 'summary-highlight 'highlight)
9710 (gnus-run-hooks 'gnus-summary-update-hook))
9713 (defun gnus-summary-update-download-mark (article)
9714 "Update the secondary (read, process, cache) mark."
9715 (gnus-summary-update-mark
9716 (cond ((memq article gnus-newsgroup-undownloaded)
9717 gnus-undownloaded-mark)
9718 (gnus-newsgroup-agentized
9719 gnus-downloaded-mark)
9723 (gnus-summary-update-line t)
9726 (defun gnus-summary-update-mark (mark type)
9727 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9728 (buffer-read-only nil))
9729 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9731 (when (looking-at "\r")
9733 (when (<= (+ forward (point)) (point-max))
9734 ;; Go to the right position on the line.
9735 (goto-char (+ forward (point)))
9736 ;; Replace the old mark with the new mark.
9737 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9738 ;; Optionally update the marks by some user rule.
9739 (when (eq type 'unread)
9741 (gnus-data-find (gnus-summary-article-number)) mark)
9742 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9744 (defun gnus-mark-article-as-read (article &optional mark)
9745 "Enter ARTICLE in the pertinent lists and remove it from others."
9746 ;; Make the article expirable.
9747 (let ((mark (or mark gnus-del-mark)))
9748 (setq gnus-newsgroup-expirable
9749 (if (= mark gnus-expirable-mark)
9750 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9751 (delq article gnus-newsgroup-expirable)))
9752 ;; Remove from unread and marked lists.
9753 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9754 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9755 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9756 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9757 (push (cons article mark) gnus-newsgroup-reads)
9758 ;; Possibly remove from cache, if that is used.
9759 (when gnus-use-cache
9760 (gnus-cache-enter-remove-article article))
9763 (defun gnus-mark-article-as-unread (article &optional mark)
9764 "Enter ARTICLE in the pertinent lists and remove it from others."
9765 (let ((mark (or mark gnus-ticked-mark)))
9768 (gnus-error 1 "Can't mark negative article numbers")
9770 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9771 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9772 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9773 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9774 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9776 ;; Unsuppress duplicates?
9777 (when gnus-suppress-duplicates
9778 (gnus-dup-unsuppress-article article))
9780 (cond ((= mark gnus-ticked-mark)
9781 (setq gnus-newsgroup-marked
9782 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9783 ((= mark gnus-spam-mark)
9784 (setq gnus-newsgroup-spam-marked
9785 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9787 ((= mark gnus-dormant-mark)
9788 (setq gnus-newsgroup-dormant
9789 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9791 (setq gnus-newsgroup-unreads
9792 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9793 (gnus-pull article gnus-newsgroup-reads)
9796 (defalias 'gnus-summary-mark-as-unread-forward
9797 'gnus-summary-tick-article-forward)
9798 (make-obsolete 'gnus-summary-mark-as-unread-forward
9799 'gnus-summary-tick-article-forward)
9800 (defun gnus-summary-tick-article-forward (n)
9801 "Tick N articles forwards.
9802 If N is negative, tick backwards instead.
9803 The difference between N and the number of articles ticked is returned."
9805 (gnus-summary-mark-forward n gnus-ticked-mark))
9807 (defalias 'gnus-summary-mark-as-unread-backward
9808 'gnus-summary-tick-article-backward)
9809 (make-obsolete 'gnus-summary-mark-as-unread-backward
9810 'gnus-summary-tick-article-backward)
9811 (defun gnus-summary-tick-article-backward (n)
9812 "Tick N articles backwards.
9813 The difference between N and the number of articles ticked is returned."
9815 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9817 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9818 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9819 (defun gnus-summary-tick-article (&optional article clear-mark)
9820 "Mark current article as unread.
9821 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9822 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9824 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9827 (defun gnus-summary-mark-as-read-forward (n)
9828 "Mark N articles as read forwards.
9829 If N is negative, mark backwards instead.
9830 The difference between N and the actual number of articles marked is
9833 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9835 (defun gnus-summary-mark-as-read-backward (n)
9836 "Mark the N articles as read backwards.
9837 The difference between N and the actual number of articles marked is
9840 (gnus-summary-mark-forward
9841 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9843 (defun gnus-summary-mark-as-read (&optional article mark)
9844 "Mark current article as read.
9845 ARTICLE specifies the article to be marked as read.
9846 MARK specifies a string to be inserted at the beginning of the line."
9847 (gnus-summary-mark-article article mark))
9849 (defun gnus-summary-clear-mark-forward (n)
9850 "Clear marks from N articles forward.
9851 If N is negative, clear backward instead.
9852 The difference between N and the number of marks cleared is returned."
9854 (gnus-summary-mark-forward n gnus-unread-mark))
9856 (defun gnus-summary-clear-mark-backward (n)
9857 "Clear marks from N articles backward.
9858 The difference between N and the number of marks cleared is returned."
9860 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9862 (defun gnus-summary-mark-unread-as-read ()
9863 "Intended to be used by `gnus-summary-mark-article-hook'."
9864 (when (memq gnus-current-article gnus-newsgroup-unreads)
9865 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9867 (defun gnus-summary-mark-read-and-unread-as-read ()
9868 "Intended to be used by `gnus-summary-mark-article-hook'."
9869 (let ((mark (gnus-summary-article-mark)))
9870 (when (or (gnus-unread-mark-p mark)
9871 (gnus-read-mark-p mark))
9872 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9874 (defun gnus-summary-mark-unread-as-ticked ()
9875 "Intended to be used by `gnus-summary-mark-article-hook'."
9876 (when (memq gnus-current-article gnus-newsgroup-unreads)
9877 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9879 (defun gnus-summary-mark-region-as-read (point mark all)
9880 "Mark all unread articles between point and mark as read.
9881 If given a prefix, mark all articles between point and mark as read,
9882 even ticked and dormant ones."
9883 (interactive "r\nP")
9892 (memq (setq article (gnus-summary-article-number))
9893 gnus-newsgroup-unreads))
9894 (gnus-summary-mark-article article gnus-del-mark))
9896 (gnus-summary-find-next))))))
9898 (defun gnus-summary-mark-below (score mark)
9899 "Mark articles with score less than SCORE with MARK."
9900 (interactive "P\ncMark: ")
9901 (setq score (if score
9902 (prefix-numeric-value score)
9903 (or gnus-summary-default-score 0)))
9905 (set-buffer gnus-summary-buffer)
9906 (goto-char (point-min))
9909 (and (< (gnus-summary-article-score) score)
9910 (gnus-summary-mark-article nil mark))
9911 (gnus-summary-find-next)))))
9913 (defun gnus-summary-kill-below (&optional score)
9914 "Mark articles with score below SCORE as read."
9916 (gnus-summary-mark-below score gnus-killed-mark))
9918 (defun gnus-summary-clear-above (&optional score)
9919 "Clear all marks from articles with score above SCORE."
9921 (gnus-summary-mark-above score gnus-unread-mark))
9923 (defun gnus-summary-tick-above (&optional score)
9924 "Tick all articles with score above SCORE."
9926 (gnus-summary-mark-above score gnus-ticked-mark))
9928 (defun gnus-summary-mark-above (score mark)
9929 "Mark articles with score over SCORE with MARK."
9930 (interactive "P\ncMark: ")
9931 (setq score (if score
9932 (prefix-numeric-value score)
9933 (or gnus-summary-default-score 0)))
9935 (set-buffer gnus-summary-buffer)
9936 (goto-char (point-min))
9938 (when (> (gnus-summary-article-score) score)
9939 (gnus-summary-mark-article nil mark))
9941 (gnus-summary-find-next)))))
9943 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9944 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9945 (defun gnus-summary-limit-include-expunged (&optional no-error)
9946 "Display all the hidden articles that were expunged for low scores."
9948 (let ((buffer-read-only nil))
9949 (let ((scored gnus-newsgroup-scored)
9952 (unless (gnus-summary-article-header (caar scored))
9953 (and (setq h (gnus-number-to-header (caar scored)))
9954 (< (cdar scored) gnus-summary-expunge-below)
9956 (setq scored (cdr scored)))
9958 (when (not no-error)
9959 (error "No expunged articles hidden"))
9960 (goto-char (point-min))
9961 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9962 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9963 (mapcar (lambda (x) (push (mail-header-number x)
9964 gnus-newsgroup-limit))
9966 (gnus-summary-prepare-unthreaded (nreverse headers))
9967 (goto-char (point-min))
9968 (gnus-summary-position-point)
9971 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9972 "Mark all unread articles in this newsgroup as read.
9973 If prefix argument ALL is non-nil, ticked and dormant articles will
9974 also be marked as read.
9975 If QUIETLY is non-nil, no questions will be asked.
9976 If TO-HERE is non-nil, it should be a point in the buffer. All
9977 articles before (after, if REVERSE is set) this point will be marked as read.
9978 Note that this function will only catch up the unread article
9979 in the current summary buffer limitation.
9980 The number of articles marked as read is returned."
9985 (not gnus-interactive-catchup) ;Without confirmation?
9989 "Mark absolutely all articles as read? "
9990 "Mark all unread articles as read? ")))
9992 (not gnus-newsgroup-adaptive)
9993 (not gnus-newsgroup-auto-expire)
9994 (not gnus-suppress-duplicates)
9995 (or (not gnus-use-cache)
9996 (eq gnus-use-cache 'passive)))
9999 (setq gnus-newsgroup-marked nil
10000 gnus-newsgroup-spam-marked nil
10001 gnus-newsgroup-dormant nil))
10002 (setq gnus-newsgroup-unreads
10003 (gnus-sorted-nunion
10004 (gnus-intersection gnus-newsgroup-unreads
10005 gnus-newsgroup-downloadable)
10006 gnus-newsgroup-unfetched)))
10007 ;; We actually mark all articles as canceled, which we
10008 ;; have to do when using auto-expiry or adaptive scoring.
10009 (gnus-summary-show-all-threads)
10010 (if (and to-here reverse)
10012 (goto-char to-here)
10014 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10015 (gnus-summary-find-next (not all)))))
10016 (when (gnus-summary-first-subject (not all))
10018 (if to-here (< (point) to-here) t)
10019 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10020 (gnus-summary-find-next (not all))))))
10021 (gnus-set-mode-line 'summary))
10023 (gnus-summary-position-point)))
10025 (defun gnus-summary-catchup-to-here (&optional all)
10026 "Mark all unticked articles before the current one as read.
10027 If ALL is non-nil, also mark ticked and dormant articles as read."
10030 (gnus-save-hidden-threads
10031 (let ((beg (point)))
10032 ;; We check that there are unread articles.
10033 (when (or all (gnus-summary-find-prev))
10034 (gnus-summary-catchup all t beg)))))
10035 (gnus-summary-position-point))
10037 (defun gnus-summary-catchup-from-here (&optional all)
10038 "Mark all unticked articles after the current one as read.
10039 If ALL is non-nil, also mark ticked and dormant articles as read."
10042 (gnus-save-hidden-threads
10043 (let ((beg (point)))
10044 ;; We check that there are unread articles.
10045 (when (or all (gnus-summary-find-next))
10046 (gnus-summary-catchup all t beg nil t)))))
10048 (gnus-summary-position-point))
10049 (defun gnus-summary-catchup-all (&optional quietly)
10050 "Mark all articles in this newsgroup as read.
10051 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10052 instead, which marks only unread articles as read."
10054 (gnus-summary-catchup t quietly))
10056 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10057 "Mark all unread articles in this group as read, then exit.
10058 If prefix argument ALL is non-nil, all articles are marked as read.
10059 If QUIETLY is non-nil, no questions will be asked."
10061 (when (gnus-summary-catchup all quietly nil 'fast)
10062 ;; Select next newsgroup or exit.
10063 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10064 (eq gnus-auto-select-next 'quietly))
10065 (gnus-summary-next-group nil)
10066 (gnus-summary-exit))))
10068 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10069 "Mark all articles in this newsgroup as read, and then exit.
10070 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10071 instead, which marks only unread articles as read."
10073 (gnus-summary-catchup-and-exit t quietly))
10075 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10076 "Mark all articles in this group as read and select the next group.
10077 If given a prefix, mark all articles, unread as well as ticked, as
10081 (gnus-summary-catchup all))
10082 (gnus-summary-next-group))
10088 (defmacro gnus-with-article (article &rest forms)
10089 "Select ARTICLE and perform FORMS in the original article buffer.
10090 Then replace the article with the result."
10092 ;; We don't want the article to be marked as read.
10093 (let (gnus-mark-article-hook)
10094 (gnus-summary-select-article t t nil ,article))
10095 (set-buffer gnus-original-article-buffer)
10097 (if (not (gnus-check-backend-function
10098 'request-replace-article (car gnus-article-current)))
10099 (gnus-message 5 "Read-only group; not replacing")
10100 (unless (gnus-request-replace-article
10101 ,article (car gnus-article-current)
10102 (current-buffer) t)
10103 (error "Couldn't replace article")))
10104 ;; The cache and backlog have to be flushed somewhat.
10105 (when gnus-keep-backlog
10106 (gnus-backlog-remove-article
10107 (car gnus-article-current) (cdr gnus-article-current)))
10108 (when gnus-use-cache
10109 (gnus-cache-update-article
10110 (car gnus-article-current) (cdr gnus-article-current)))))
10112 (put 'gnus-with-article 'lisp-indent-function 1)
10113 (put 'gnus-with-article 'edebug-form-spec '(form body))
10115 ;; Thread-based commands.
10117 (defun gnus-summary-articles-in-thread (&optional article)
10118 "Return a list of all articles in the current thread.
10119 If ARTICLE is non-nil, return all articles in the thread that starts
10120 with that article."
10121 (let* ((article (or article (gnus-summary-article-number)))
10122 (data (gnus-data-find-list article))
10123 (top-level (gnus-data-level (car data)))
10125 (cond ((null gnus-thread-operation-ignore-subject)
10126 (gnus-simplify-subject-re
10127 (mail-header-subject (gnus-data-header (car data)))))
10128 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10129 (gnus-simplify-subject-fuzzy
10130 (mail-header-subject (gnus-data-header (car data)))))
10132 (end-point (save-excursion
10133 (if (gnus-summary-go-to-next-thread)
10134 (point) (point-max))))
10137 (< (gnus-data-pos (car data)) end-point))
10138 (when (or (not top-subject)
10139 (string= top-subject
10140 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10141 (gnus-simplify-subject-fuzzy
10142 (mail-header-subject
10143 (gnus-data-header (car data))))
10144 (gnus-simplify-subject-re
10145 (mail-header-subject
10146 (gnus-data-header (car data)))))))
10147 (push (gnus-data-number (car data)) articles))
10148 (unless (and (setq data (cdr data))
10149 (> (gnus-data-level (car data)) top-level))
10151 ;; Return the list of articles.
10152 (nreverse articles)))
10154 (defun gnus-summary-rethread-current ()
10155 "Rethread the thread the current article is part of."
10157 (let* ((gnus-show-threads t)
10158 (article (gnus-summary-article-number))
10159 (id (mail-header-id (gnus-summary-article-header)))
10160 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10162 (error "No article on the current line"))
10163 (gnus-rebuild-thread id)
10164 (gnus-summary-goto-subject article)))
10166 (defun gnus-summary-reparent-thread ()
10167 "Make the current article child of the marked (or previous) article.
10169 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10170 is non-nil or the Subject: of both articles are the same."
10172 (unless (not (gnus-group-read-only-p))
10173 (error "The current newsgroup does not support article editing"))
10174 (unless (<= (length gnus-newsgroup-processable) 1)
10175 (error "No more than one article may be marked"))
10176 (save-window-excursion
10177 (let ((gnus-article-buffer " *reparent*")
10178 (current-article (gnus-summary-article-number))
10179 ;; First grab the marked article, otherwise one line up.
10180 (parent-article (if (not (null gnus-newsgroup-processable))
10181 (car gnus-newsgroup-processable)
10183 (if (eq (forward-line -1) 0)
10184 (gnus-summary-article-number)
10185 (error "Beginning of summary buffer"))))))
10186 (unless (not (eq current-article parent-article))
10187 (error "An article may not be self-referential"))
10188 (let ((message-id (mail-header-id
10189 (gnus-summary-article-header parent-article))))
10190 (unless (and message-id (not (equal message-id "")))
10191 (error "No message-id in desired parent"))
10192 (gnus-with-article current-article
10194 (goto-char (point-min))
10195 (message-narrow-to-head)
10196 (if (re-search-forward "^References: " nil t)
10198 (re-search-forward "^[^ \t]" nil t)
10201 (insert " " message-id))
10202 (insert "References: " message-id "\n"))))
10203 (set-buffer gnus-summary-buffer)
10204 (gnus-summary-unmark-all-processable)
10205 (gnus-summary-update-article current-article)
10206 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10207 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10208 (gnus-summary-rethread-current)
10209 (gnus-message 3 "Article %d is now the child of article %d"
10210 current-article parent-article)))))
10212 (defun gnus-summary-toggle-threads (&optional arg)
10213 "Toggle showing conversation threads.
10214 If ARG is positive number, turn showing conversation threads on."
10216 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10217 (setq gnus-show-threads
10218 (if (null arg) (not gnus-show-threads)
10219 (> (prefix-numeric-value arg) 0)))
10220 (gnus-summary-prepare)
10221 (gnus-summary-goto-subject current)
10222 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10223 (gnus-summary-position-point)))
10225 (defun gnus-summary-show-all-threads ()
10226 "Show all threads."
10229 (let ((buffer-read-only nil))
10230 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10231 (gnus-summary-position-point))
10233 (defun gnus-summary-show-thread ()
10234 "Show thread subtrees.
10235 Returns nil if no thread was there to be shown."
10237 (let ((buffer-read-only nil)
10239 ;; first goto end then to beg, to have point at beg after let
10240 (end (progn (end-of-line) (point)))
10241 (beg (progn (beginning-of-line) (point))))
10243 ;; Any hidden lines here?
10244 (search-forward "\r" end t)
10245 (subst-char-in-region beg end ?\^M ?\n t)
10247 (gnus-summary-position-point))))
10249 (defun gnus-summary-maybe-hide-threads ()
10250 "If requested, hide the threads that should be hidden."
10251 (when (and gnus-show-threads
10252 gnus-thread-hide-subtree)
10253 (gnus-summary-hide-all-threads
10254 (if (or (consp gnus-thread-hide-subtree)
10255 (gnus-functionp gnus-thread-hide-subtree))
10256 (gnus-make-predicate gnus-thread-hide-subtree)
10259 ;;; Hiding predicates.
10261 (defun gnus-article-unread-p (header)
10262 (memq (mail-header-number header) gnus-newsgroup-unreads))
10264 (defun gnus-article-unseen-p (header)
10265 (memq (mail-header-number header) gnus-newsgroup-unseen))
10267 (defun gnus-map-articles (predicate articles)
10268 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10269 (apply 'gnus-or (mapcar predicate
10270 (mapcar 'gnus-summary-article-header articles))))
10272 (defun gnus-summary-hide-all-threads (&optional predicate)
10273 "Hide all thread subtrees.
10274 If PREDICATE is supplied, threads that satisfy this predicate
10275 will not be hidden."
10278 (goto-char (point-min))
10281 (when (or (not predicate)
10283 predicate (gnus-summary-article-children)))
10284 (gnus-summary-hide-thread))
10285 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10286 (gnus-summary-position-point))
10288 (defun gnus-summary-hide-thread ()
10289 "Hide thread subtrees.
10290 If PREDICATE is supplied, threads that satisfy this predicate
10291 will not be hidden.
10292 Returns nil if no threads were there to be hidden."
10294 (let ((buffer-read-only nil)
10296 (article (gnus-summary-article-number)))
10298 ;; Go forward until either the buffer ends or the subthread
10300 (when (and (not (eobp))
10301 (or (zerop (gnus-summary-next-thread 1 t))
10302 (goto-char (point-max))))
10304 (if (and (> (point) start)
10305 (search-backward "\n" start t))
10307 (subst-char-in-region start (point) ?\n ?\^M)
10308 (gnus-summary-goto-subject article))
10312 (defun gnus-summary-go-to-next-thread (&optional previous)
10313 "Go to the same level (or less) next thread.
10314 If PREVIOUS is non-nil, go to previous thread instead.
10315 Return the article number moved to, or nil if moving was impossible."
10316 (let ((level (gnus-summary-thread-level))
10317 (way (if previous -1 1))
10320 (while (and (not (eobp))
10321 (< level (gnus-summary-thread-level)))
10322 (forward-line way))
10329 (gnus-summary-article-number)
10330 (goto-char beg)))))
10332 (defun gnus-summary-next-thread (n &optional silent)
10333 "Go to the same level next N'th thread.
10334 If N is negative, search backward instead.
10335 Returns the difference between N and the number of skips actually
10338 If SILENT, don't output messages."
10340 (let ((backward (< n 0))
10342 (while (and (> n 0)
10343 (gnus-summary-go-to-next-thread backward))
10346 (gnus-summary-position-point))
10347 (when (and (not silent) (/= 0 n))
10348 (gnus-message 7 "No more threads"))
10351 (defun gnus-summary-prev-thread (n)
10352 "Go to the same level previous N'th thread.
10353 Returns the difference between N and the number of skips actually
10356 (gnus-summary-next-thread (- n)))
10358 (defun gnus-summary-go-down-thread ()
10359 "Go down one level in the current thread."
10360 (let ((children (gnus-summary-article-children)))
10362 (gnus-summary-goto-subject (car children)))))
10364 (defun gnus-summary-go-up-thread ()
10365 "Go up one level in the current thread."
10366 (let ((parent (gnus-summary-article-parent)))
10368 (gnus-summary-goto-subject parent))))
10370 (defun gnus-summary-down-thread (n)
10371 "Go down thread N steps.
10372 If N is negative, go up instead.
10373 Returns the difference between N and how many steps down that were
10378 (while (and (> n 0)
10379 (if up (gnus-summary-go-up-thread)
10380 (gnus-summary-go-down-thread)))
10382 (gnus-summary-position-point)
10384 (gnus-message 7 "Can't go further"))
10387 (defun gnus-summary-up-thread (n)
10388 "Go up thread N steps.
10389 If N is negative, go down instead.
10390 Returns the difference between N and how many steps down that were
10393 (gnus-summary-down-thread (- n)))
10395 (defun gnus-summary-top-thread ()
10396 "Go to the top of the thread."
10398 (while (gnus-summary-go-up-thread))
10399 (gnus-summary-article-number))
10401 (defun gnus-summary-kill-thread (&optional unmark)
10402 "Mark articles under current thread as read.
10403 If the prefix argument is positive, remove any kinds of marks.
10404 If the prefix argument is negative, tick articles instead."
10407 (setq unmark (prefix-numeric-value unmark)))
10408 (let ((articles (gnus-summary-articles-in-thread)))
10410 ;; Expand the thread.
10411 (gnus-summary-show-thread)
10412 ;; Mark all the articles.
10414 (gnus-summary-goto-subject (car articles))
10415 (cond ((null unmark)
10416 (gnus-summary-mark-article-as-read gnus-killed-mark))
10418 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10420 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10421 (setq articles (cdr articles))))
10422 ;; Hide killed subtrees.
10424 gnus-thread-hide-killed
10425 (gnus-summary-hide-thread))
10426 ;; If marked as read, go to next unread subject.
10427 (when (null unmark)
10428 ;; Go to next unread subject.
10429 (gnus-summary-next-subject 1 t)))
10430 (gnus-set-mode-line 'summary))
10432 ;; Summary sorting commands
10434 (defun gnus-summary-sort-by-number (&optional reverse)
10435 "Sort the summary buffer by article number.
10436 Argument REVERSE means reverse order."
10438 (gnus-summary-sort 'number reverse))
10440 (defun gnus-summary-sort-by-random (&optional reverse)
10441 "Randomize the order in the summary buffer.
10442 Argument REVERSE means to randomize in reverse order."
10444 (gnus-summary-sort 'random reverse))
10446 (defun gnus-summary-sort-by-author (&optional reverse)
10447 "Sort the summary buffer by author name alphabetically.
10448 If `case-fold-search' is non-nil, case of letters is ignored.
10449 Argument REVERSE means reverse order."
10451 (gnus-summary-sort 'author reverse))
10453 (defun gnus-summary-sort-by-subject (&optional reverse)
10454 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10455 If `case-fold-search' is non-nil, case of letters is ignored.
10456 Argument REVERSE means reverse order."
10458 (gnus-summary-sort 'subject reverse))
10460 (defun gnus-summary-sort-by-date (&optional reverse)
10461 "Sort the summary buffer by date.
10462 Argument REVERSE means reverse order."
10464 (gnus-summary-sort 'date reverse))
10466 (defun gnus-summary-sort-by-score (&optional reverse)
10467 "Sort the summary buffer by score.
10468 Argument REVERSE means reverse order."
10470 (gnus-summary-sort 'score reverse))
10472 (defun gnus-summary-sort-by-lines (&optional reverse)
10473 "Sort the summary buffer by the number of lines.
10474 Argument REVERSE means reverse order."
10476 (gnus-summary-sort 'lines reverse))
10478 (defun gnus-summary-sort-by-chars (&optional reverse)
10479 "Sort the summary buffer by article length.
10480 Argument REVERSE means reverse order."
10482 (gnus-summary-sort 'chars reverse))
10484 (defun gnus-summary-sort-by-original (&optional reverse)
10485 "Sort the summary buffer using the default sorting method.
10486 Argument REVERSE means reverse order."
10488 (let* ((buffer-read-only)
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 (defun gnus-summary-sort (predicate reverse)
10496 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10497 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10498 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10499 (gnus-thread-sort-functions
10504 (gnus-sort-gathered-threads-function
10505 gnus-thread-sort-functions)
10506 (gnus-article-sort-functions
10510 (,article t2 t1))))
10512 (gnus-summary-prepare-hook nil))
10513 ;; We do the sorting by regenerating the threads.
10514 (gnus-summary-prepare)
10515 ;; Hide subthreads if needed.
10516 (gnus-summary-maybe-hide-threads)))
10518 ;; Summary saving commands.
10520 (defun gnus-summary-save-article (&optional n not-saved)
10521 "Save the current article using the default saver function.
10522 If N is a positive number, save the N next articles.
10523 If N is a negative number, save the N previous articles.
10524 If N is nil and any articles have been marked with the process mark,
10525 save those articles instead.
10526 The variable `gnus-default-article-saver' specifies the saver function."
10528 (let* ((articles (gnus-summary-work-articles n))
10529 (save-buffer (save-excursion
10530 (nnheader-set-temp-buffer " *Gnus Save*")))
10531 (num (length articles))
10533 (dolist (article articles)
10534 (setq header (gnus-summary-article-header article))
10535 (if (not (vectorp header))
10536 ;; This is a pseudo-article.
10537 (if (assq 'name header)
10538 (gnus-copy-file (cdr (assq 'name header)))
10539 (gnus-message 1 "Article %d is unsaveable" article))
10540 ;; This is a real article.
10541 (save-window-excursion
10542 (let ((gnus-display-mime-function nil)
10543 (gnus-article-prepare-hook nil))
10544 (gnus-summary-select-article t nil nil article)))
10546 (set-buffer save-buffer)
10548 (insert-buffer-substring gnus-original-article-buffer))
10549 (setq file (gnus-article-save save-buffer file num))
10550 (gnus-summary-remove-process-mark article)
10552 (gnus-summary-set-saved-mark article))))
10553 (gnus-kill-buffer save-buffer)
10554 (gnus-summary-position-point)
10555 (gnus-set-mode-line 'summary)
10558 (defun gnus-summary-pipe-output (&optional arg headers)
10559 "Pipe the current article to a subprocess.
10560 If N is a positive number, pipe the N next articles.
10561 If N is a negative number, pipe the N previous articles.
10562 If N is nil and any articles have been marked with the process mark,
10563 pipe those articles instead.
10564 If HEADERS (the symbolic prefix), include the headers, too."
10565 (interactive (gnus-interactive "P\ny"))
10566 (require 'gnus-art)
10567 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10568 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10569 (gnus-summary-save-article arg t))
10570 (let ((buffer (get-buffer "*Shell Command Output*")))
10572 (not (zerop (buffer-size buffer))))
10573 (gnus-configure-windows 'pipe))))
10575 (defun gnus-summary-save-article-mail (&optional arg)
10576 "Append the current article to an mail file.
10577 If N is a positive number, save the N next articles.
10578 If N is a negative number, save the N previous articles.
10579 If N is nil and any articles have been marked with the process mark,
10580 save those articles instead."
10582 (require 'gnus-art)
10583 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10584 (gnus-summary-save-article arg)))
10586 (defun gnus-summary-save-article-rmail (&optional arg)
10587 "Append the current article to an rmail file.
10588 If N is a positive number, save the N next articles.
10589 If N is a negative number, save the N previous articles.
10590 If N is nil and any articles have been marked with the process mark,
10591 save those articles instead."
10593 (require 'gnus-art)
10594 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10595 (gnus-summary-save-article arg)))
10597 (defun gnus-summary-save-article-file (&optional arg)
10598 "Append the current article to a file.
10599 If N is a positive number, save the N next articles.
10600 If N is a negative number, save the N previous articles.
10601 If N is nil and any articles have been marked with the process mark,
10602 save those articles instead."
10604 (require 'gnus-art)
10605 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10606 (gnus-summary-save-article arg)))
10608 (defun gnus-summary-write-article-file (&optional arg)
10609 "Write the current article to a file, deleting the previous file.
10610 If N is a positive number, save the N next articles.
10611 If N is a negative number, save the N previous articles.
10612 If N is nil and any articles have been marked with the process mark,
10613 save those articles instead."
10615 (require 'gnus-art)
10616 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10617 (gnus-summary-save-article arg)))
10619 (defun gnus-summary-save-article-body-file (&optional arg)
10620 "Append the current article body to a file.
10621 If N is a positive number, save the N next articles.
10622 If N is a negative number, save the N previous articles.
10623 If N is nil and any articles have been marked with the process mark,
10624 save those articles instead."
10626 (require 'gnus-art)
10627 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10628 (gnus-summary-save-article arg)))
10630 (defun gnus-summary-muttprint (&optional arg)
10631 "Print the current article using Muttprint.
10632 If N is a positive number, save the N next articles.
10633 If N is a negative number, save the N previous articles.
10634 If N is nil and any articles have been marked with the process mark,
10635 save those articles instead."
10637 (require 'gnus-art)
10638 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10639 (gnus-summary-save-article arg t)))
10641 (defun gnus-summary-pipe-message (program)
10642 "Pipe the current article through PROGRAM."
10643 (interactive "sProgram: ")
10644 (gnus-summary-select-article)
10645 (let ((mail-header-separator ""))
10646 (gnus-eval-in-buffer-window gnus-article-buffer
10649 (let ((start (window-start))
10651 (message-pipe-buffer-body program)
10652 (set-window-start (get-buffer-window (current-buffer)) start))))))
10654 (defun gnus-get-split-value (methods)
10655 "Return a value based on the split METHODS."
10656 (let (split-name method result match)
10659 (set-buffer gnus-original-article-buffer)
10661 (nnheader-narrow-to-headers)
10662 (while (and methods (not split-name))
10663 (goto-char (point-min))
10664 (setq method (pop methods))
10665 (setq match (car method))
10668 ;; Regular expression.
10670 (re-search-forward match nil t)))
10671 ((gnus-functionp match)
10675 (setq result (funcall match gnus-newsgroup-name))))
10680 (setq result (eval match)))))
10681 (setq split-name (cdr method))
10682 (cond ((stringp result)
10683 (push (expand-file-name
10684 result gnus-article-save-directory)
10687 (setq split-name (append result split-name)))))))))
10688 (nreverse split-name)))
10690 (defun gnus-valid-move-group-p (group)
10691 (and (boundp group)
10692 (symbol-name group)
10693 (symbol-value group)
10694 (gnus-get-function (gnus-find-method-for-group
10695 (symbol-name group)) 'request-accept-article t)))
10697 (defun gnus-read-move-group-name (prompt default articles prefix)
10698 "Read a group name."
10699 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10700 (minibuffer-confirm-incomplete nil) ; XEmacs
10702 (format "%s %s to:"
10704 (if (> (length articles) 1)
10705 (format "these %d articles" (length articles))
10710 (gnus-completing-read-with-default
10713 'gnus-valid-move-group-p
10715 'gnus-group-history))
10716 ((= 1 (length split-name))
10717 (gnus-completing-read-with-default
10718 (car split-name) prom
10720 'gnus-valid-move-group-p
10722 'gnus-group-history))
10724 (gnus-completing-read-with-default
10726 (mapcar (lambda (el) (list el))
10727 (nreverse split-name))
10729 'gnus-group-history))))
10730 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10732 (if (or (string= to-newsgroup "")
10733 (string= to-newsgroup prefix))
10734 (setq to-newsgroup default))
10735 (unless to-newsgroup
10736 (error "No group name entered"))
10737 (or (gnus-active to-newsgroup)
10738 (gnus-activate-group to-newsgroup nil nil to-method)
10739 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10741 (or (and (gnus-request-create-group to-newsgroup to-method)
10742 (gnus-activate-group
10743 to-newsgroup nil nil to-method)
10744 (gnus-subscribe-group to-newsgroup))
10745 (error "Couldn't create group %s" to-newsgroup)))
10746 (error "No such group: %s" to-newsgroup)))
10749 (defun gnus-summary-save-parts (type dir n &optional reverse)
10750 "Save parts matching TYPE to DIR.
10751 If REVERSE, save parts that do not match TYPE."
10753 (list (read-string "Save parts of type: "
10754 (or (car gnus-summary-save-parts-type-history)
10755 gnus-summary-save-parts-default-mime)
10756 'gnus-summary-save-parts-type-history)
10757 (setq gnus-summary-save-parts-last-directory
10758 (read-file-name "Save to directory: "
10759 gnus-summary-save-parts-last-directory
10761 current-prefix-arg))
10762 (gnus-summary-iterate n
10763 (let ((gnus-display-mime-function nil)
10764 (gnus-inhibit-treatment t))
10765 (gnus-summary-select-article))
10767 (set-buffer gnus-article-buffer)
10768 (let ((handles (or gnus-article-mime-handles
10769 (mm-dissect-buffer nil gnus-article-loose-mime)
10770 (and gnus-article-emulate-mime
10771 (mm-uu-dissect)))))
10773 (gnus-summary-save-parts-1 type dir handles reverse)
10774 (unless gnus-article-mime-handles ;; Don't destroy this case.
10775 (mm-destroy-parts handles)))))))
10777 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10778 (if (stringp (car handle))
10779 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10782 (not (string-match type (mm-handle-media-type handle)))
10783 (string-match type (mm-handle-media-type handle)))
10784 (let ((file (expand-file-name
10785 (file-name-nondirectory
10787 (mail-content-type-get
10788 (mm-handle-disposition handle) 'filename)
10789 (concat gnus-newsgroup-name
10790 "." (number-to-string
10791 (cdr gnus-article-current)))))
10793 (unless (file-exists-p file)
10794 (mm-save-part-to-file handle file))))))
10796 ;; Summary extract commands
10798 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10799 (let ((buffer-read-only nil)
10800 (article (gnus-summary-article-number))
10802 (unless (gnus-summary-goto-subject article)
10803 (error "No such article: %d" article))
10804 (gnus-summary-position-point)
10805 ;; If all commands are to be bunched up on one line, we collect
10807 (unless gnus-view-pseudos-separately
10808 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10811 (setq action (cdr (assq 'action (car ps))))
10812 (setq files (list (cdr (assq 'name (car ps)))))
10813 (while (and ps (cdr ps)
10814 (string= (or action "1")
10815 (or (cdr (assq 'action (cadr ps))) "2")))
10816 (push (cdr (assq 'name (cadr ps))) files)
10817 (setcdr ps (cddr ps)))
10819 (when (not (string-match "%s" action))
10822 (when (assq 'execute (car ps))
10823 (setcdr (assq 'execute (car ps))
10824 (funcall (if (string-match "%s" action)
10833 (setq ps (cdr ps)))))
10834 (if (and gnus-view-pseudos (not not-view))
10836 (when (assq 'execute (car pslist))
10837 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10838 (eq gnus-view-pseudos 'not-confirm)))
10839 (setq pslist (cdr pslist)))
10842 (setq after-article (or (cdr (assq 'article (car pslist)))
10843 (gnus-summary-article-number)))
10844 (gnus-summary-goto-subject after-article)
10847 (insert " " (file-name-nondirectory
10848 (cdr (assq 'name (car pslist))))
10849 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10851 (forward-line -1) ; back to `b'
10852 (gnus-add-text-properties
10853 b (1- e) (list 'gnus-number gnus-reffed-article-number
10854 gnus-mouse-face-prop gnus-mouse-face))
10856 after-article gnus-reffed-article-number
10857 gnus-unread-mark b (car pslist) 0 (- e b))
10858 (setq gnus-newsgroup-unreads
10859 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10860 gnus-reffed-article-number))
10861 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10862 (setq pslist (cdr pslist)))))))
10864 (defun gnus-pseudos< (p1 p2)
10865 (let ((c1 (cdr (assq 'action p1)))
10866 (c2 (cdr (assq 'action p2))))
10867 (and c1 c2 (string< c1 c2))))
10869 (defun gnus-request-pseudo-article (props)
10870 (cond ((assq 'execute props)
10871 (gnus-execute-command (cdr (assq 'execute props)))))
10872 (let ((gnus-current-article (gnus-summary-article-number)))
10873 (gnus-run-hooks 'gnus-mark-article-hook)))
10875 (defun gnus-execute-command (command &optional automatic)
10877 (gnus-article-setup-buffer)
10878 (set-buffer gnus-article-buffer)
10879 (setq buffer-read-only nil)
10880 (let ((command (if automatic command
10881 (read-string "Command: " (cons command 0)))))
10883 (insert "$ " command "\n\n")
10884 (if gnus-view-pseudo-asynchronously
10885 (start-process "gnus-execute" (current-buffer) shell-file-name
10886 shell-command-switch command)
10887 (call-process shell-file-name nil t nil
10888 shell-command-switch command)))))
10890 ;; Summary kill commands.
10892 (defun gnus-summary-edit-global-kill (article)
10893 "Edit the \"global\" kill file."
10894 (interactive (list (gnus-summary-article-number)))
10895 (gnus-group-edit-global-kill article))
10897 (defun gnus-summary-edit-local-kill ()
10898 "Edit a local kill file applied to the current newsgroup."
10900 (setq gnus-current-headers (gnus-summary-article-header))
10901 (gnus-group-edit-local-kill
10902 (gnus-summary-article-number) gnus-newsgroup-name))
10904 ;;; Header reading.
10906 (defun gnus-read-header (id &optional header)
10907 "Read the headers of article ID and enter them into the Gnus system."
10908 (let ((group gnus-newsgroup-name)
10909 (gnus-override-method
10911 gnus-override-method
10912 (and (gnus-news-group-p gnus-newsgroup-name)
10913 (car (gnus-refer-article-methods)))))
10915 ;; First we check to see whether the header in question is already
10918 ;; This is a Message-ID.
10919 (setq header (or header (gnus-id-to-header id)))
10920 ;; This is an article number.
10921 (setq header (or header (gnus-summary-article-header id))))
10923 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10924 ;; We have found the header.
10926 ;; If this is a sparse article, we have to nix out its
10927 ;; previous entry in the thread hashtb.
10929 (gnus-summary-article-sparse-p (mail-header-number header)))
10930 (let* ((parent (gnus-parent-id (mail-header-references header)))
10931 (thread (and parent (gnus-id-to-thread parent))))
10933 (delq (assq header thread) thread))))
10934 ;; We have to really fetch the header to this article.
10936 (set-buffer nntp-server-buffer)
10937 (when (setq where (gnus-request-head id group))
10938 (nnheader-fold-continuation-lines)
10939 (goto-char (point-max))
10941 (goto-char (point-min))
10945 ((cdr where) (cdr where))
10946 (header (mail-header-number header))
10947 (t gnus-reffed-article-number))
10949 (insert " Article retrieved.\n"))
10950 (if (or (not where)
10951 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10952 () ; Malformed head.
10953 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10954 (when (and (stringp id)
10955 (not (string= (gnus-group-real-name group)
10957 ;; If we fetched by Message-ID and the article came
10958 ;; from a different group, we fudge some bogus article
10959 ;; numbers for this article.
10960 (mail-header-set-number header gnus-reffed-article-number))
10962 (set-buffer gnus-summary-buffer)
10963 (decf gnus-reffed-article-number)
10964 (gnus-remove-header (mail-header-number header))
10965 (push header gnus-newsgroup-headers)
10966 (setq gnus-current-headers header)
10967 (push (mail-header-number header) gnus-newsgroup-limit)))
10970 (defun gnus-remove-header (number)
10971 "Remove header NUMBER from `gnus-newsgroup-headers'."
10972 (if (and gnus-newsgroup-headers
10973 (= number (mail-header-number (car gnus-newsgroup-headers))))
10974 (pop gnus-newsgroup-headers)
10975 (let ((headers gnus-newsgroup-headers))
10976 (while (and (cdr headers)
10977 (not (= number (mail-header-number (cadr headers)))))
10979 (when (cdr headers)
10980 (setcdr headers (cddr headers))))))
10983 ;;; summary highlights
10986 (defun gnus-highlight-selected-summary ()
10987 "Highlight selected article in summary buffer."
10988 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10989 (when gnus-summary-selected-face
10991 (let* ((beg (progn (beginning-of-line) (point)))
10992 (end (progn (end-of-line) (point)))
10993 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10994 (from (if (get-text-property beg gnus-mouse-face-prop)
10996 (or (next-single-property-change
10997 beg gnus-mouse-face-prop nil end)
11002 (or (next-single-property-change
11003 from gnus-mouse-face-prop nil end)
11005 ;; If no mouse-face prop on line we will have to = from = end,
11006 ;; so we highlight the entire line instead.
11007 (when (= (+ to 2) from)
11010 (if gnus-newsgroup-selected-overlay
11011 ;; Move old overlay.
11013 gnus-newsgroup-selected-overlay from to (current-buffer))
11014 ;; Create new overlay.
11016 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11017 'face gnus-summary-selected-face))))))
11019 (defvar gnus-summary-highlight-line-cached nil)
11020 (defvar gnus-summary-highlight-line-trigger nil)
11022 (defun gnus-summary-highlight-line-0 ()
11023 (if (and (eq gnus-summary-highlight-line-trigger
11024 gnus-summary-highlight)
11025 gnus-summary-highlight-line-cached)
11026 gnus-summary-highlight-line-cached
11027 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11028 gnus-summary-highlight-line-cached
11029 (let* ((cond (list 'cond))
11031 (list gnus-summary-highlight))
11033 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11036 (gnus-byte-compile (list 'lambda nil cond))))))
11038 (defun gnus-summary-highlight-line ()
11039 "Highlight current line according to `gnus-summary-highlight'."
11040 (let* ((beg (gnus-point-at-bol))
11041 (article (or (gnus-summary-article-number) gnus-current-article))
11042 (score (or (cdr (assq article
11043 gnus-newsgroup-scored))
11044 gnus-summary-default-score 0))
11045 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11046 (inhibit-read-only t)
11047 (default gnus-summary-default-score)
11048 (default-high gnus-summary-default-high-score)
11049 (default-low gnus-summary-default-low-score)
11050 (uncached (memq article gnus-newsgroup-undownloaded))
11051 (downloaded (not uncached)))
11052 (let ((face (funcall (gnus-summary-highlight-line-0))))
11053 (unless (eq face (get-text-property beg 'face))
11054 (gnus-put-text-property-excluding-characters-with-faces
11055 beg (gnus-point-at-eol) 'face
11056 (setq face (if (boundp face) (symbol-value face) face)))
11057 (when gnus-summary-highlight-line-function
11058 (funcall gnus-summary-highlight-line-function article face))))))
11060 (defun gnus-update-read-articles (group unread &optional compute)
11061 "Update the list of read articles in GROUP.
11062 UNREAD is a sorted list."
11063 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11064 (entry (gnus-gethash group gnus-newsrc-hashtb))
11065 (info (nth 2 entry))
11068 (if (or (not info) (not active))
11069 ;; There is no info on this group if it was, in fact,
11070 ;; killed. Gnus stores no information on killed groups, so
11071 ;; there's nothing to be done.
11072 ;; One could store the information somewhere temporarily,
11073 ;; perhaps... Hmmm...
11075 ;; Remove any negative articles numbers.
11076 (while (and unread (< (car unread) 0))
11077 (setq unread (cdr unread)))
11078 ;; Remove any expired article numbers
11079 (while (and unread (< (car unread) (car active)))
11080 (setq unread (cdr unread)))
11081 ;; Compute the ranges of read articles by looking at the list of
11082 ;; unread articles.
11084 (when (/= (car unread) prev)
11085 (push (if (= prev (1- (car unread))) prev
11086 (cons prev (1- (car unread))))
11088 (setq prev (1+ (car unread)))
11089 (setq unread (cdr unread)))
11090 (when (<= prev (cdr active))
11091 (push (cons prev (cdr active)) read))
11092 (setq read (if (> (length read) 1) (nreverse read) read))
11097 ;; Propagate the read marks to the backend.
11098 (when (gnus-check-backend-function 'request-set-mark group)
11099 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11100 (add (gnus-remove-from-range read (gnus-info-read info))))
11102 (unless (gnus-check-group group)
11103 (error "Can't open server for %s" group))
11104 (gnus-request-set-mark
11105 group (delq nil (list (if add (list add 'add '(read)))
11106 (if del (list del 'del '(read))))))
11108 `(gnus-request-set-mark
11111 (if del (list del 'add '(read)))
11112 (if add (list add 'del '(read))))))))))
11113 (set-buffer gnus-group-buffer)
11114 (gnus-undo-register
11116 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11117 (gnus-info-set-read ',info ',(gnus-info-read info))
11118 (gnus-get-unread-articles-in-group ',info
11119 (gnus-active ,group))
11120 (gnus-group-update-group ,group t)
11122 ;; Enter this list into the group info.
11123 (gnus-info-set-read info read)
11124 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11125 (gnus-get-unread-articles-in-group info (gnus-active group))
11128 (defun gnus-offer-save-summaries ()
11129 "Offer to save all active summary buffers."
11131 ;; Go through all buffers and find all summaries.
11132 (dolist (buffer (buffer-list))
11133 (when (and (setq buffer (buffer-name buffer))
11134 (string-match "Summary" buffer)
11136 (set-buffer buffer)
11137 ;; We check that this is, indeed, a summary buffer.
11138 (and (eq major-mode 'gnus-summary-mode)
11139 ;; Also make sure this isn't bogus.
11140 gnus-newsgroup-prepared
11141 ;; Also make sure that this isn't a
11142 ;; dead summary buffer.
11143 (not gnus-dead-summary-mode))))
11144 (push buffer buffers)))
11145 ;; Go through all these summary buffers and offer to save them.
11149 "Update summary buffer %s? "
11151 (switch-to-buffer buf)
11152 (gnus-summary-exit))
11155 (defun gnus-summary-setup-default-charset ()
11156 "Setup newsgroup default charset."
11157 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11158 (setq gnus-newsgroup-charset nil)
11159 (let* ((ignored-charsets
11160 (or gnus-newsgroup-ephemeral-ignored-charsets
11162 (and gnus-newsgroup-name
11163 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11164 gnus-newsgroup-ignored-charsets))))
11165 (setq gnus-newsgroup-charset
11166 (or gnus-newsgroup-ephemeral-charset
11167 (and gnus-newsgroup-name
11168 (gnus-parameter-charset gnus-newsgroup-name))
11169 gnus-default-charset))
11170 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11171 ignored-charsets))))
11177 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11178 "Display the current article buffer fully MIME-buttonized.
11179 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11180 treated as multipart/mixed."
11182 (require 'gnus-art)
11183 (let ((gnus-unbuttonized-mime-types nil)
11184 (gnus-mime-display-multipart-as-mixed show-all-parts))
11185 (gnus-summary-show-article)))
11187 (defun gnus-summary-repair-multipart (article)
11188 "Add a Content-Type header to a multipart article without one."
11189 (interactive (list (gnus-summary-article-number)))
11190 (gnus-with-article article
11191 (message-narrow-to-head)
11192 (message-remove-header "Mime-Version")
11193 (goto-char (point-max))
11194 (insert "Mime-Version: 1.0\n")
11196 (when (search-forward "\n--" nil t)
11197 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11198 (message-narrow-to-head)
11199 (message-remove-header "Content-Type")
11200 (goto-char (point-max))
11201 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11204 (let (gnus-mark-article-hook)
11205 (gnus-summary-select-article t t nil article)))
11207 (defun gnus-summary-toggle-display-buttonized ()
11208 "Toggle the buttonizing of the article buffer."
11210 (require 'gnus-art)
11211 (if (setq gnus-inhibit-mime-unbuttonizing
11212 (not gnus-inhibit-mime-unbuttonizing))
11213 (let ((gnus-unbuttonized-mime-types nil))
11214 (gnus-summary-show-article))
11215 (gnus-summary-show-article)))
11218 ;;; Generic summary marking commands
11221 (defvar gnus-summary-marking-alist
11222 '((read gnus-del-mark "d")
11223 (unread gnus-unread-mark "u")
11224 (ticked gnus-ticked-mark "!")
11225 (dormant gnus-dormant-mark "?")
11226 (expirable gnus-expirable-mark "e"))
11227 "An alist of names/marks/keystrokes.")
11229 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11230 (defvar gnus-summary-mark-map)
11232 (defun gnus-summary-make-all-marking-commands ()
11233 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11234 (dolist (elem gnus-summary-marking-alist)
11235 (apply 'gnus-summary-make-marking-command elem)))
11237 (defun gnus-summary-make-marking-command (name mark keystroke)
11238 (let ((map (make-sparse-keymap)))
11239 (define-key gnus-summary-generic-mark-map keystroke map)
11240 (dolist (lway `((next "next" next nil "n")
11241 (next-unread "next unread" next t "N")
11242 (prev "previous" prev nil "p")
11243 (prev-unread "previous unread" prev t "P")
11244 (nomove "" nil nil ,keystroke)))
11245 (let ((func (gnus-summary-make-marking-command-1
11246 mark (car lway) lway name)))
11247 (setq func (eval func))
11248 (define-key map (nth 4 lway) func)))))
11250 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11252 (format "gnus-summary-put-mark-as-%s%s"
11253 name (if (eq way 'nomove)
11255 (concat "-" (symbol-name way)))))
11258 "Mark the current article as %s%s.
11259 If N, the prefix, then repeat N times.
11260 If N is negative, move in reverse order.
11261 The difference between N and the actual number of articles marked is
11265 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11267 (defun gnus-summary-generic-mark (n mark move unread)
11268 "Mark N articles with MARK."
11269 (unless (eq major-mode 'gnus-summary-mode)
11270 (error "This command can only be used in the summary buffer"))
11271 (gnus-summary-show-thread)
11274 ((eq move 'next) 1)
11275 ((eq move 'prev) -1)
11277 (if (zerop nummove)
11281 nummove (* -1 nummove))))
11282 (while (and (> n 0)
11283 (gnus-summary-mark-article nil mark)
11284 (zerop (gnus-summary-next-subject nummove unread t)))
11287 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11288 (gnus-summary-recenter)
11289 (gnus-summary-position-point)
11290 (gnus-set-mode-line 'summary)
11293 (defun gnus-summary-insert-articles (articles)
11294 (when (setq articles
11295 (gnus-sorted-difference articles
11296 (mapcar (lambda (h)
11297 (mail-header-number h))
11298 gnus-newsgroup-headers)))
11299 (setq gnus-newsgroup-headers
11301 gnus-newsgroup-headers
11302 (gnus-fetch-headers articles)
11303 'gnus-article-sort-by-number))
11304 ;; Suppress duplicates?
11305 (when gnus-suppress-duplicates
11306 (gnus-dup-suppress-articles))
11308 ;; We might want to build some more threads first.
11309 (when (and gnus-fetch-old-headers
11310 (eq gnus-headers-retrieved-by 'nov))
11311 (if (eq gnus-fetch-old-headers 'invisible)
11312 (gnus-build-all-threads)
11313 (gnus-build-old-threads)))
11314 ;; Let the Gnus agent mark articles as read.
11316 (gnus-agent-get-undownloaded-list))
11317 ;; Remove list identifiers from subject
11318 (when gnus-list-identifiers
11319 (gnus-summary-remove-list-identifiers))
11320 ;; First and last article in this newsgroup.
11321 (when gnus-newsgroup-headers
11322 (setq gnus-newsgroup-begin
11323 (mail-header-number (car gnus-newsgroup-headers))
11325 (mail-header-number
11326 (gnus-last-element gnus-newsgroup-headers))))
11327 (when gnus-use-scoring
11328 (gnus-possibly-score-headers))))
11330 (defun gnus-summary-insert-old-articles (&optional all)
11331 "Insert all old articles in this group.
11332 If ALL is non-nil, already read articles become readable.
11333 If ALL is a number, fetch this number of articles."
11336 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11339 ;; Some nntp servers lie about their active range. When
11340 ;; this happens, the active range can be in the millions.
11341 ;; Use a compressed range to avoid creating a huge list.
11342 (gnus-range-difference (list gnus-newsgroup-active) old))
11343 (setq len (gnus-range-length older))
11348 (let ((older-range (nreverse older)))
11352 (let* ((r (pop older-range))
11353 (min (if (numberp r) r (car r)))
11354 (max (if (numberp r) r (cdr r))))
11355 (while (and (<= min max)
11360 (setq older (gnus-uncompress-range older))))
11362 (setq older (gnus-uncompress-range older)))
11364 (when (and (numberp gnus-large-newsgroup)
11365 (> len gnus-large-newsgroup))
11366 (let* ((cursor-in-echo-area nil)
11367 (initial (gnus-parameter-large-newsgroup-initial
11368 gnus-newsgroup-name))
11372 "How many articles from %s (%s %d): "
11374 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11375 (if initial "max" "default")
11378 (cons (number-to-string initial)
11380 (unless (string-match "^[ \t]*$" input)
11381 (setq all (string-to-number input))
11383 (let ((older-range (nreverse older)))
11387 (let* ((r (pop older-range))
11388 (min (if (numberp r) r (car r)))
11389 (max (if (numberp r) r (cdr r))))
11390 (while (and (<= min max)
11394 max (1- max))))))))))
11395 (setq older (gnus-uncompress-range older))))
11397 (message "No old news.")
11398 (gnus-summary-insert-articles older)
11399 (gnus-summary-limit (gnus-sorted-nunion old older))))
11400 (gnus-summary-position-point)))
11402 (defun gnus-summary-insert-new-articles ()
11403 "Insert all new articles in this group."
11406 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11407 (old-active gnus-newsgroup-active)
11408 (nnmail-fetched-sources (list t))
11410 (setq gnus-newsgroup-active
11411 (gnus-activate-group gnus-newsgroup-name 'scan))
11412 (setq i (cdr gnus-newsgroup-active))
11413 (while (> i (cdr old-active))
11417 (message "No gnus is bad news.")
11418 (gnus-summary-insert-articles new)
11419 (setq gnus-newsgroup-unreads
11420 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11421 (gnus-summary-limit (gnus-sorted-nunion old new))))
11422 (gnus-summary-position-point)))
11424 (gnus-summary-make-all-marking-commands)
11426 (gnus-ems-redefine)
11428 (provide 'gnus-sum)
11430 (run-hooks 'gnus-sum-load-hook)
11432 ;;; gnus-sum.el ends here