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]
2348 ["Run command on marked..." gnus-summary-universal-argument t]))
2350 ["Page forward" gnus-summary-next-page
2351 ,@(if (featurep 'xemacs) '(t)
2352 '(:help "Show next page of article"))]
2353 ["Page backward" gnus-summary-prev-page
2354 ,@(if (featurep 'xemacs) '(t)
2355 '(:help "Show previous page of article"))]
2356 ["Line forward" gnus-summary-scroll-up t])
2358 ["Next unread article" gnus-summary-next-unread-article t]
2359 ["Previous unread article" gnus-summary-prev-unread-article t]
2360 ["Next article" gnus-summary-next-article t]
2361 ["Previous article" gnus-summary-prev-article t]
2362 ["Next unread subject" gnus-summary-next-unread-subject t]
2363 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2364 ["Next article same subject" gnus-summary-next-same-subject t]
2365 ["Previous article same subject" gnus-summary-prev-same-subject t]
2366 ["First unread article" gnus-summary-first-unread-article t]
2367 ["Best unread article" gnus-summary-best-unread-article t]
2368 ["Go to subject number..." gnus-summary-goto-subject t]
2369 ["Go to article number..." gnus-summary-goto-article t]
2370 ["Go to the last article" gnus-summary-goto-last-article t]
2371 ["Pop article off history" gnus-summary-pop-article t])
2373 ["Sort by number" gnus-summary-sort-by-number t]
2374 ["Sort by author" gnus-summary-sort-by-author t]
2375 ["Sort by subject" gnus-summary-sort-by-subject t]
2376 ["Sort by date" gnus-summary-sort-by-date t]
2377 ["Sort by score" gnus-summary-sort-by-score t]
2378 ["Sort by lines" gnus-summary-sort-by-lines t]
2379 ["Sort by characters" gnus-summary-sort-by-chars t]
2380 ["Randomize" gnus-summary-sort-by-random t]
2381 ["Original sort" gnus-summary-sort-by-original t])
2383 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2384 ["Describe group" gnus-summary-describe-group t]
2385 ["Fetch charter" gnus-group-fetch-charter
2386 ,@(if (featurep 'xemacs) nil
2387 '(:help "Display the charter of the current group"))]
2388 ["Fetch control message" gnus-group-fetch-control
2389 ,@(if (featurep 'xemacs) nil
2390 '(:help "Display the archived control message for the current group"))]
2391 ["Read manual" gnus-info-find-node t])
2393 ["Pick and read" gnus-pick-mode t]
2394 ["Binary" gnus-binary-mode t])
2396 ["Regenerate" gnus-summary-prepare t]
2397 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2398 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2399 ["Toggle threading" gnus-summary-toggle-threads t])
2400 ["See old articles" gnus-summary-insert-old-articles t]
2401 ["See new articles" gnus-summary-insert-new-articles t]
2402 ["Filter articles..." gnus-summary-execute-command t]
2403 ["Run command on articles..." gnus-summary-universal-argument t]
2404 ["Search articles forward..." gnus-summary-search-article-forward t]
2405 ["Search articles backward..." gnus-summary-search-article-backward t]
2406 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2407 ["Expand window" gnus-summary-expand-window t]
2408 ["Expire expirable articles" gnus-summary-expire-articles
2409 (gnus-check-backend-function
2410 'request-expire-articles gnus-newsgroup-name)]
2411 ["Edit local kill file" gnus-summary-edit-local-kill t]
2412 ["Edit main kill file" gnus-summary-edit-global-kill t]
2413 ["Edit group parameters" gnus-summary-edit-parameters t]
2414 ["Customize group parameters" gnus-summary-customize-parameters t]
2415 ["Send a bug report" gnus-bug t]
2417 ["Catchup and exit" gnus-summary-catchup-and-exit
2418 ,@(if (featurep 'xemacs) '(t)
2419 '(:help "Mark unread articles in this group as read, then exit"))]
2420 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2421 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2422 ["Exit group" gnus-summary-exit
2423 ,@(if (featurep 'xemacs) '(t)
2424 '(:help "Exit current group, return to group selection mode"))]
2425 ["Exit group without updating" gnus-summary-exit-no-update t]
2426 ["Exit and goto next group" gnus-summary-next-group t]
2427 ["Exit and goto prev group" gnus-summary-prev-group t]
2428 ["Reselect group" gnus-summary-reselect-current-group t]
2429 ["Rescan group" gnus-summary-rescan-group t]
2430 ["Update dribble" gnus-summary-save-newsrc t])))
2432 (gnus-run-hooks 'gnus-summary-menu-hook)))
2434 (defvar gnus-summary-tool-bar-map nil)
2436 ;; Emacs 21 tool bar. Should be no-op otherwise.
2437 (defun gnus-summary-make-tool-bar ()
2438 (if (and (fboundp 'tool-bar-add-item-from-menu)
2439 (default-value 'tool-bar-mode)
2440 (not gnus-summary-tool-bar-map))
2441 (setq gnus-summary-tool-bar-map
2442 (let ((tool-bar-map (make-sparse-keymap))
2443 (load-path (mm-image-load-path)))
2444 (tool-bar-add-item-from-menu
2445 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2446 (tool-bar-add-item-from-menu
2447 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2448 (tool-bar-add-item-from-menu
2449 'gnus-summary-post-news "post" gnus-summary-mode-map)
2450 (tool-bar-add-item-from-menu
2451 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2452 (tool-bar-add-item-from-menu
2453 'gnus-summary-followup "followup" gnus-summary-mode-map)
2454 (tool-bar-add-item-from-menu
2455 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2456 (tool-bar-add-item-from-menu
2457 'gnus-summary-reply "reply" gnus-summary-mode-map)
2458 (tool-bar-add-item-from-menu
2459 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2460 (tool-bar-add-item-from-menu
2461 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2462 (tool-bar-add-item-from-menu
2463 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2464 (tool-bar-add-item-from-menu
2465 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2466 (tool-bar-add-item-from-menu
2467 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2468 (tool-bar-add-item-from-menu
2469 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2470 (tool-bar-add-item-from-menu
2471 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2472 (tool-bar-add-item-from-menu
2473 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2475 (if gnus-summary-tool-bar-map
2476 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2478 (defun gnus-score-set-default (var value)
2479 "A version of set that updates the GNU Emacs menu-bar."
2481 ;; It is the message that forces the active status to be updated.
2484 (defun gnus-make-score-map (type)
2485 "Make a summary score map of type TYPE."
2488 (let ((headers '(("author" "from" string)
2489 ("subject" "subject" string)
2490 ("article body" "body" string)
2491 ("article head" "head" string)
2492 ("xref" "xref" string)
2493 ("extra header" "extra" string)
2494 ("lines" "lines" number)
2495 ("followups to author" "followup" string)))
2496 (types '((number ("less than" <)
2499 (string ("substring" s)
2503 (perms '(("temporary" (current-time-string))
2511 (if (eq type 'lower)
2516 (setq header (car headers))
2522 (let ((ts (cdr (assoc (nth 2 header) types)))
2538 'gnus-summary-score-entry
2540 (if (or (string= (nth 1 header)
2542 (string= (nth 1 header)
2545 (list 'gnus-summary-header
2547 (list 'quote (nth 1 (car ts)))
2548 (list 'gnus-score-delta-default
2555 (list (nreverse outp))))
2558 (list (nreverse outt))))
2560 (setq headers (cdr headers)))
2561 (list (nreverse outh))))))))
2565 (defun gnus-summary-mode (&optional group)
2566 "Major mode for reading articles.
2568 All normal editing commands are switched off.
2569 \\<gnus-summary-mode-map>
2570 Each line in this buffer represents one article. To read an
2571 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2572 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2575 You can also post articles and send mail from this buffer. To
2576 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2577 of an article, type `\\[gnus-summary-reply]'.
2579 There are approx. one gazillion commands you can execute in this
2580 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2582 The following commands are available:
2584 \\{gnus-summary-mode-map}"
2586 (kill-all-local-variables)
2587 (when (gnus-visual-p 'summary-menu 'menu)
2588 (gnus-summary-make-menu-bar)
2589 (gnus-summary-make-tool-bar))
2590 (gnus-summary-make-local-variables)
2591 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2592 (gnus-summary-make-local-variables))
2593 (gnus-make-thread-indent-array)
2594 (gnus-simplify-mode-line)
2595 (setq major-mode 'gnus-summary-mode)
2596 (setq mode-name "Summary")
2597 (make-local-variable 'minor-mode-alist)
2598 (use-local-map gnus-summary-mode-map)
2599 (buffer-disable-undo)
2600 (setq buffer-read-only t) ;Disable modification
2601 (setq truncate-lines t)
2602 (setq selective-display t)
2603 (setq selective-display-ellipses t) ;Display `...'
2604 (gnus-summary-set-display-table)
2605 (gnus-set-default-directory)
2606 (setq gnus-newsgroup-name group)
2607 (make-local-variable 'gnus-summary-line-format)
2608 (make-local-variable 'gnus-summary-line-format-spec)
2609 (make-local-variable 'gnus-summary-dummy-line-format)
2610 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2611 (make-local-variable 'gnus-summary-mark-positions)
2612 (make-local-hook 'pre-command-hook)
2613 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2614 (gnus-run-hooks 'gnus-summary-mode-hook)
2615 (turn-on-gnus-mailing-list-mode)
2616 (mm-enable-multibyte)
2617 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2618 (gnus-update-summary-mark-positions))
2620 (defun gnus-summary-make-local-variables ()
2621 "Make all the local summary buffer variables."
2623 (dolist (local gnus-summary-local-variables)
2626 (if (eq (cdr local) 'global)
2627 ;; Copy the global value of the variable.
2628 (setq global (symbol-value (car local)))
2629 ;; Use the value from the list.
2630 (setq global (eval (cdr local))))
2631 (set (make-local-variable (car local)) global))
2632 ;; Simple nil-valued local variable.
2633 (set (make-local-variable local) nil)))))
2635 (defun gnus-summary-clear-local-variables ()
2636 (let ((locals gnus-summary-local-variables))
2638 (if (consp (car locals))
2639 (and (vectorp (caar locals))
2640 (set (caar locals) nil))
2641 (and (vectorp (car locals))
2642 (set (car locals) nil)))
2643 (setq locals (cdr locals)))))
2645 ;; Summary data functions.
2647 (defmacro gnus-data-number (data)
2650 (defmacro gnus-data-set-number (data number)
2651 `(setcar ,data ,number))
2653 (defmacro gnus-data-mark (data)
2656 (defmacro gnus-data-set-mark (data mark)
2657 `(setcar (nthcdr 1 ,data) ,mark))
2659 (defmacro gnus-data-pos (data)
2662 (defmacro gnus-data-set-pos (data pos)
2663 `(setcar (nthcdr 2 ,data) ,pos))
2665 (defmacro gnus-data-header (data)
2668 (defmacro gnus-data-set-header (data header)
2669 `(setf (nth 3 ,data) ,header))
2671 (defmacro gnus-data-level (data)
2674 (defmacro gnus-data-unread-p (data)
2675 `(= (nth 1 ,data) gnus-unread-mark))
2677 (defmacro gnus-data-read-p (data)
2678 `(/= (nth 1 ,data) gnus-unread-mark))
2680 (defmacro gnus-data-pseudo-p (data)
2681 `(consp (nth 3 ,data)))
2683 (defmacro gnus-data-find (number)
2684 `(assq ,number gnus-newsgroup-data))
2686 (defmacro gnus-data-find-list (number &optional data)
2687 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2688 (memq (assq ,number bdata)
2691 (defmacro gnus-data-make (number mark pos header level)
2692 `(list ,number ,mark ,pos ,header ,level))
2694 (defun gnus-data-enter (after-article number mark pos header level offset)
2695 (let ((data (gnus-data-find-list after-article)))
2697 (error "No such article: %d" after-article))
2698 (setcdr data (cons (gnus-data-make number mark pos header level)
2700 (setq gnus-newsgroup-data-reverse nil)
2701 (gnus-data-update-list (cddr data) offset)))
2703 (defun gnus-data-enter-list (after-article list &optional offset)
2705 (let ((data (and after-article (gnus-data-find-list after-article)))
2709 (let ((odata gnus-newsgroup-data))
2710 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2712 (gnus-data-update-list odata offset)))
2713 ;; Find the last element in the list to be spliced into the main
2716 (setq list (cdr list)))
2719 (setcdr list gnus-newsgroup-data)
2720 (setq gnus-newsgroup-data ilist)
2722 (gnus-data-update-list (cdr list) offset)))
2723 (setcdr list (cdr data))
2726 (gnus-data-update-list (cdr list) offset))))
2727 (setq gnus-newsgroup-data-reverse nil))))
2729 (defun gnus-data-remove (article &optional offset)
2730 (let ((data gnus-newsgroup-data))
2731 (if (= (gnus-data-number (car data)) article)
2733 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2734 gnus-newsgroup-data-reverse nil)
2736 (gnus-data-update-list gnus-newsgroup-data offset)))
2738 (when (= (gnus-data-number (cadr data)) article)
2739 (setcdr data (cddr data))
2741 (gnus-data-update-list (cdr data) offset))
2743 gnus-newsgroup-data-reverse nil))
2744 (setq data (cdr data))))))
2746 (defmacro gnus-data-list (backward)
2748 (or gnus-newsgroup-data-reverse
2749 (setq gnus-newsgroup-data-reverse
2750 (reverse gnus-newsgroup-data)))
2751 gnus-newsgroup-data))
2753 (defun gnus-data-update-list (data offset)
2754 "Add OFFSET to the POS of all data entries in DATA."
2755 (setq gnus-newsgroup-data-reverse nil)
2757 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2758 (setq data (cdr data))))
2760 (defun gnus-summary-article-pseudo-p (article)
2761 "Say whether this article is a pseudo article or not."
2762 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2764 (defmacro gnus-summary-article-sparse-p (article)
2765 "Say whether this article is a sparse article or not."
2766 `(memq ,article gnus-newsgroup-sparse))
2768 (defmacro gnus-summary-article-ancient-p (article)
2769 "Say whether this article is a sparse article or not."
2770 `(memq ,article gnus-newsgroup-ancient))
2772 (defun gnus-article-parent-p (number)
2773 "Say whether this article is a parent or not."
2774 (let ((data (gnus-data-find-list number)))
2775 (and (cdr data) ; There has to be an article after...
2776 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2777 (gnus-data-level (nth 1 data))))))
2779 (defun gnus-article-children (number)
2780 "Return a list of all children to NUMBER."
2781 (let* ((data (gnus-data-find-list number))
2782 (level (gnus-data-level (car data)))
2784 (setq data (cdr data))
2786 (= (gnus-data-level (car data)) (1+ level)))
2787 (push (gnus-data-number (car data)) children)
2788 (setq data (cdr data)))
2791 (defmacro gnus-summary-skip-intangible ()
2792 "If the current article is intangible, then jump to a different article."
2793 '(let ((to (get-text-property (point) 'gnus-intangible)))
2794 (and to (gnus-summary-goto-subject to))))
2796 (defmacro gnus-summary-article-intangible-p ()
2797 "Say whether this article is intangible or not."
2798 '(get-text-property (point) 'gnus-intangible))
2800 (defun gnus-article-read-p (article)
2801 "Say whether ARTICLE is read or not."
2802 (not (or (memq article gnus-newsgroup-marked)
2803 (memq article gnus-newsgroup-spam-marked)
2804 (memq article gnus-newsgroup-unreads)
2805 (memq article gnus-newsgroup-unselected)
2806 (memq article gnus-newsgroup-dormant))))
2808 ;; Some summary mode macros.
2810 (defmacro gnus-summary-article-number ()
2811 "The article number of the article on the current line.
2812 If there isn't an article number here, then we return the current
2815 (gnus-summary-skip-intangible)
2816 (or (get-text-property (point) 'gnus-number)
2817 (gnus-summary-last-subject))))
2819 (defmacro gnus-summary-article-header (&optional number)
2820 "Return the header of article NUMBER."
2821 `(gnus-data-header (gnus-data-find
2822 ,(or number '(gnus-summary-article-number)))))
2824 (defmacro gnus-summary-thread-level (&optional number)
2825 "Return the level of thread that starts with article NUMBER."
2826 `(if (and (eq gnus-summary-make-false-root 'dummy)
2827 (get-text-property (point) 'gnus-intangible))
2829 (gnus-data-level (gnus-data-find
2830 ,(or number '(gnus-summary-article-number))))))
2832 (defmacro gnus-summary-article-mark (&optional number)
2833 "Return the mark of article NUMBER."
2834 `(gnus-data-mark (gnus-data-find
2835 ,(or number '(gnus-summary-article-number)))))
2837 (defmacro gnus-summary-article-pos (&optional number)
2838 "Return the position of the line of article NUMBER."
2839 `(gnus-data-pos (gnus-data-find
2840 ,(or number '(gnus-summary-article-number)))))
2842 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2843 (defmacro gnus-summary-article-subject (&optional number)
2844 "Return current subject string or nil if nothing."
2847 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2848 '(gnus-data-header (assq (gnus-summary-article-number)
2849 gnus-newsgroup-data)))))
2852 (mail-header-subject headers))))
2854 (defmacro gnus-summary-article-score (&optional number)
2855 "Return current article score."
2856 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2857 gnus-newsgroup-scored))
2858 gnus-summary-default-score 0))
2860 (defun gnus-summary-article-children (&optional number)
2861 "Return a list of article numbers that are children of article NUMBER."
2862 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2863 (level (gnus-data-level (car data)))
2865 (while (and (setq data (cdr data))
2866 (> (setq l (gnus-data-level (car data))) level))
2867 (and (= (1+ level) l)
2868 (push (gnus-data-number (car data))
2870 (nreverse children)))
2872 (defun gnus-summary-article-parent (&optional number)
2873 "Return the article number of the parent of article NUMBER."
2874 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2875 (gnus-data-list t)))
2876 (level (gnus-data-level (car data))))
2878 () ; This is a root.
2879 ;; We search until we find an article with a level less than
2880 ;; this one. That function has to be the parent.
2881 (while (and (setq data (cdr data))
2882 (not (< (gnus-data-level (car data)) level))))
2883 (and data (gnus-data-number (car data))))))
2885 (defun gnus-unread-mark-p (mark)
2886 "Say whether MARK is the unread mark."
2887 (= mark gnus-unread-mark))
2889 (defun gnus-read-mark-p (mark)
2890 "Say whether MARK is one of the marks that mark as read.
2891 This is all marks except unread, ticked, dormant, and expirable."
2892 (not (or (= mark gnus-unread-mark)
2893 (= mark gnus-ticked-mark)
2894 (= mark gnus-spam-mark)
2895 (= mark gnus-dormant-mark)
2896 (= mark gnus-expirable-mark))))
2898 (defmacro gnus-article-mark (number)
2899 "Return the MARK of article NUMBER.
2900 This macro should only be used when computing the mark the \"first\"
2901 time; i.e., when generating the summary lines. After that,
2902 `gnus-summary-article-mark' should be used to examine the
2905 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2906 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2907 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2908 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2909 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2910 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2911 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2912 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2913 gnus-ancient-mark))))
2915 ;; Saving hidden threads.
2917 (defmacro gnus-save-hidden-threads (&rest forms)
2918 "Save hidden threads, eval FORMS, and restore the hidden threads."
2919 (let ((config (make-symbol "config")))
2920 `(let ((,config (gnus-hidden-threads-configuration)))
2924 (gnus-restore-hidden-threads-configuration ,config)))))
2925 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2926 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2928 (defun gnus-data-compute-positions ()
2929 "Compute the positions of all articles."
2930 (setq gnus-newsgroup-data-reverse nil)
2931 (let ((data gnus-newsgroup-data))
2933 (gnus-save-hidden-threads
2934 (gnus-summary-show-all-threads)
2935 (goto-char (point-min))
2937 (while (get-text-property (point) 'gnus-intangible)
2939 (gnus-data-set-pos (car data) (+ (point) 3))
2940 (setq data (cdr data))
2941 (forward-line 1))))))
2943 (defun gnus-hidden-threads-configuration ()
2944 "Return the current hidden threads configuration."
2947 (goto-char (point-min))
2948 (while (search-forward "\r" nil t)
2949 (push (1- (point)) config))
2952 (defun gnus-restore-hidden-threads-configuration (config)
2953 "Restore hidden threads configuration from CONFIG."
2955 (let (point buffer-read-only)
2956 (while (setq point (pop config))
2957 (when (and (< point (point-max))
2959 (eq (char-after) ?\n))
2960 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2962 ;; Various summary mode internalish functions.
2964 (defun gnus-mouse-pick-article (e)
2967 (gnus-summary-next-page nil t))
2969 (defun gnus-summary-set-display-table ()
2970 "Change the display table.
2971 Odd characters have a tendency to mess
2972 up nicely formatted displays - we make all possible glyphs
2973 display only a single character."
2975 ;; We start from the standard display table, if any.
2976 (let ((table (or (copy-sequence standard-display-table)
2977 (make-display-table)))
2979 ;; Nix out all the control chars...
2980 (while (>= (setq i (1- i)) 0)
2981 (aset table i [??]))
2982 ;; ... but not newline and cr, of course. (cr is necessary for the
2983 ;; selective display).
2984 (aset table ?\n nil)
2985 (aset table ?\r nil)
2986 ;; We keep TAB as well.
2987 (aset table ?\t nil)
2988 ;; We nix out any glyphs over 126 that are not set already.
2990 (while (>= (setq i (1- i)) 127)
2991 ;; Only modify if the entry is nil.
2992 (unless (aref table i)
2993 (aset table i [??]))))
2994 (setq buffer-display-table table)))
2996 (defun gnus-summary-set-article-display-arrow (pos)
2997 "Update the overlay arrow to point to line at position POS."
2998 (when (and gnus-summary-display-arrow
2999 (boundp 'overlay-arrow-position)
3000 (boundp 'overlay-arrow-string))
3004 (unless overlay-arrow-position
3005 (setq overlay-arrow-position (make-marker)))
3006 (setq overlay-arrow-string "=>"
3007 overlay-arrow-position (set-marker overlay-arrow-position
3009 (current-buffer))))))
3011 (defun gnus-summary-buffer-name (group)
3012 "Return the summary buffer name of GROUP."
3013 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3015 (defun gnus-summary-setup-buffer (group)
3016 "Initialize summary buffer."
3017 (let ((buffer (gnus-summary-buffer-name group))
3018 (dead-name (concat "*Dead Summary "
3019 (gnus-group-decoded-name group) "*")))
3020 ;; If a dead summary buffer exists, we kill it.
3021 (when (gnus-buffer-live-p dead-name)
3022 (gnus-kill-buffer dead-name))
3023 (if (get-buffer buffer)
3026 (setq gnus-summary-buffer (current-buffer))
3027 (not gnus-newsgroup-prepared))
3028 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3029 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3030 (gnus-summary-mode group)
3032 (gnus-carpal-setup-buffer 'summary))
3033 (unless gnus-single-article-buffer
3034 (make-local-variable 'gnus-article-buffer)
3035 (make-local-variable 'gnus-article-current)
3036 (make-local-variable 'gnus-original-article-buffer))
3037 (setq gnus-newsgroup-name group)
3038 ;; Set any local variables in the group parameters.
3039 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3042 (defun gnus-set-global-variables ()
3043 "Set the global equivalents of the buffer-local variables.
3044 They are set to the latest values they had. These reflect the summary
3045 buffer that was in action when the last article was fetched."
3046 (when (eq major-mode 'gnus-summary-mode)
3047 (setq gnus-summary-buffer (current-buffer))
3048 (let ((name gnus-newsgroup-name)
3049 (marked gnus-newsgroup-marked)
3050 (spam gnus-newsgroup-spam-marked)
3051 (unread gnus-newsgroup-unreads)
3052 (headers gnus-current-headers)
3053 (data gnus-newsgroup-data)
3054 (summary gnus-summary-buffer)
3055 (article-buffer gnus-article-buffer)
3056 (original gnus-original-article-buffer)
3057 (gac gnus-article-current)
3058 (reffed gnus-reffed-article-number)
3059 (score-file gnus-current-score-file)
3060 (default-charset gnus-newsgroup-charset)
3062 (let ((locals gnus-newsgroup-variables))
3064 (if (consp (car locals))
3065 (push (eval (caar locals)) vlist)
3066 (push (eval (car locals)) vlist))
3067 (setq locals (cdr locals)))
3068 (setq vlist (nreverse vlist)))
3070 (set-buffer gnus-group-buffer)
3071 (setq gnus-newsgroup-name name
3072 gnus-newsgroup-marked marked
3073 gnus-newsgroup-spam-marked spam
3074 gnus-newsgroup-unreads unread
3075 gnus-current-headers headers
3076 gnus-newsgroup-data data
3077 gnus-article-current gac
3078 gnus-summary-buffer summary
3079 gnus-article-buffer article-buffer
3080 gnus-original-article-buffer original
3081 gnus-reffed-article-number reffed
3082 gnus-current-score-file score-file
3083 gnus-newsgroup-charset default-charset)
3084 (let ((locals gnus-newsgroup-variables))
3086 (if (consp (car locals))
3087 (set (caar locals) (pop vlist))
3088 (set (car locals) (pop vlist)))
3089 (setq locals (cdr locals))))
3090 ;; The article buffer also has local variables.
3091 (when (gnus-buffer-live-p gnus-article-buffer)
3092 (set-buffer gnus-article-buffer)
3093 (setq gnus-summary-buffer summary))))))
3095 (defun gnus-summary-article-unread-p (article)
3096 "Say whether ARTICLE is unread or not."
3097 (memq article gnus-newsgroup-unreads))
3099 (defun gnus-summary-first-article-p (&optional article)
3100 "Return whether ARTICLE is the first article in the buffer."
3101 (if (not (setq article (or article (gnus-summary-article-number))))
3103 (eq article (caar gnus-newsgroup-data))))
3105 (defun gnus-summary-last-article-p (&optional article)
3106 "Return whether ARTICLE is the last article in the buffer."
3107 (if (not (setq article (or article (gnus-summary-article-number))))
3108 ;; All non-existent numbers are the last article. :-)
3110 (not (cdr (gnus-data-find-list article)))))
3112 (defun gnus-make-thread-indent-array ()
3114 (unless (and gnus-thread-indent-array
3115 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3116 (setq gnus-thread-indent-array (make-vector 201 "")
3117 gnus-thread-indent-array-level gnus-thread-indent-level)
3119 (aset gnus-thread-indent-array n
3120 (make-string (* n gnus-thread-indent-level) ? ))
3123 (defun gnus-update-summary-mark-positions ()
3124 "Compute where the summary marks are to go."
3126 (when (gnus-buffer-exists-p gnus-summary-buffer)
3127 (set-buffer gnus-summary-buffer))
3128 (let ((gnus-replied-mark 129)
3129 (gnus-score-below-mark 130)
3130 (gnus-score-over-mark 130)
3131 (gnus-undownloaded-mark 131)
3132 (spec gnus-summary-line-format-spec)
3135 (gnus-set-work-buffer)
3136 (let ((gnus-summary-line-format-spec spec)
3137 (gnus-newsgroup-downloadable '(0)))
3138 (gnus-summary-insert-line
3139 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3140 0 nil t 128 t nil "" nil 1)
3141 (goto-char (point-min))
3142 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3143 (- (point) (point-min) 1)))))
3144 (goto-char (point-min))
3145 (push (cons 'replied (and (search-forward "\201" nil t)
3146 (- (point) (point-min) 1)))
3148 (goto-char (point-min))
3149 (push (cons 'score (and (search-forward "\202" nil t)
3150 (- (point) (point-min) 1)))
3152 (goto-char (point-min))
3153 (push (cons 'download
3154 (and (search-forward "\203" nil t)
3155 (- (point) (point-min) 1)))
3157 (setq gnus-summary-mark-positions pos))))
3159 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3160 "Insert a dummy root in the summary buffer."
3162 (gnus-add-text-properties
3163 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3164 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3166 (defun gnus-summary-extract-address-component (from)
3167 (or (car (funcall gnus-extract-address-components from))
3170 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3171 (let ((mail-parse-charset gnus-newsgroup-charset)
3172 ; Is it really necessary to do this next part for each summary line?
3173 ; Luckily, doesn't seem to slow things down much.
3174 (mail-parse-ignored-charsets
3175 (save-excursion (set-buffer gnus-summary-buffer)
3176 gnus-newsgroup-ignored-charsets)))
3178 (and gnus-ignored-from-addresses
3179 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3180 (let ((extra-headers (mail-header-extra header))
3184 ((setq to (cdr (assq 'To extra-headers)))
3187 (gnus-summary-extract-address-component
3188 (funcall gnus-decode-encoded-word-function to)))))
3189 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3190 (concat "=> " newsgroups)))))
3191 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3193 (defun gnus-summary-insert-line (gnus-tmp-header
3194 gnus-tmp-level gnus-tmp-current
3195 undownloaded gnus-tmp-unread gnus-tmp-replied
3196 gnus-tmp-expirable gnus-tmp-subject-or-nil
3197 &optional gnus-tmp-dummy gnus-tmp-score
3199 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3200 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3201 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3202 (gnus-tmp-score-char
3203 (if (or (null gnus-summary-default-score)
3204 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3205 gnus-summary-zcore-fuzz))
3207 (if (< gnus-tmp-score gnus-summary-default-score)
3208 gnus-score-below-mark gnus-score-over-mark)))
3209 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3211 (cond (gnus-tmp-process gnus-process-mark)
3212 ((memq gnus-tmp-current gnus-newsgroup-cached)
3214 (gnus-tmp-replied gnus-replied-mark)
3215 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3216 gnus-forwarded-mark)
3217 ((memq gnus-tmp-current gnus-newsgroup-saved)
3219 ((memq gnus-tmp-number gnus-newsgroup-recent)
3221 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3224 (gnus-tmp-downloaded
3226 gnus-undownloaded-mark)
3227 (gnus-newsgroup-agentized
3228 gnus-downloaded-mark)
3231 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3234 ((string-match "<[^>]+> *$" gnus-tmp-from)
3235 (let ((beg (match-beginning 0)))
3236 (or (and (string-match "^\".+\"" gnus-tmp-from)
3237 (substring gnus-tmp-from 1 (1- (match-end 0))))
3238 (substring gnus-tmp-from 0 beg))))
3239 ((string-match "(.+)" gnus-tmp-from)
3240 (substring gnus-tmp-from
3241 (1+ (match-beginning 0)) (1- (match-end 0))))
3243 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3244 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3245 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3246 (buffer-read-only nil))
3247 (when (string= gnus-tmp-name "")
3248 (setq gnus-tmp-name gnus-tmp-from))
3249 (unless (numberp gnus-tmp-lines)
3250 (setq gnus-tmp-lines -1))
3251 (if (= gnus-tmp-lines -1)
3252 (setq gnus-tmp-lines "?")
3253 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3254 (gnus-put-text-property
3256 (progn (eval gnus-summary-line-format-spec) (point))
3257 'gnus-number gnus-tmp-number)
3258 (when (gnus-visual-p 'summary-highlight 'highlight)
3260 (gnus-run-hooks 'gnus-summary-update-hook)
3263 (defun gnus-summary-update-line (&optional dont-update)
3264 "Update summary line after change."
3265 (when (and gnus-summary-default-score
3266 (not gnus-summary-inhibit-highlight))
3267 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3268 (article (gnus-summary-article-number))
3269 (score (gnus-summary-article-score article)))
3271 (if (and gnus-summary-mark-below
3272 (< (gnus-summary-article-score)
3273 gnus-summary-mark-below))
3274 ;; This article has a low score, so we mark it as read.
3275 (when (memq article gnus-newsgroup-unreads)
3276 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3277 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3278 ;; This article was previously marked as read on account
3279 ;; of a low score, but now it has risen, so we mark it as
3281 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3282 (gnus-summary-update-mark
3283 (if (or (null gnus-summary-default-score)
3284 (<= (abs (- score gnus-summary-default-score))
3285 gnus-summary-zcore-fuzz))
3287 (if (< score gnus-summary-default-score)
3288 gnus-score-below-mark gnus-score-over-mark))
3290 ;; Do visual highlighting.
3291 (when (gnus-visual-p 'summary-highlight 'highlight)
3292 (gnus-run-hooks 'gnus-summary-update-hook)))))
3294 (defvar gnus-tmp-new-adopts nil)
3296 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3297 "Return the number of articles in THREAD.
3298 This may be 0 in some cases -- if none of the articles in
3299 the thread are to be displayed."
3301 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3303 ((not (listp thread))
3305 ((and (consp thread) (cdr thread))
3308 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3311 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3314 (when (and level (zerop level) gnus-tmp-new-adopts)
3317 'gnus-summary-number-of-articles-in-thread
3318 gnus-tmp-new-adopts))))
3320 (if (> number 1) gnus-not-empty-thread-mark
3321 gnus-empty-thread-mark)
3324 (defsubst gnus-summary-line-message-size (head)
3325 "Return pretty-printed version of message size.
3326 This function is intended to be used in
3327 `gnus-summary-line-format-alist', which see."
3328 (let ((c (or (mail-header-chars head) -1)))
3329 (cond ((< c 0) "n/a") ; chars not available
3330 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3331 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3332 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3333 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3336 (defun gnus-summary-set-local-parameters (group)
3337 "Go through the local params of GROUP and set all variable specs in that list."
3338 (let ((params (gnus-group-find-parameter group))
3339 (vars '(quit-config)) ; Ignore quit-config.
3342 (setq elem (car params)
3343 params (cdr params))
3344 (and (consp elem) ; Has to be a cons.
3345 (consp (cdr elem)) ; The cdr has to be a list.
3346 (symbolp (car elem)) ; Has to be a symbol in there.
3347 (not (memq (car elem) vars))
3348 (ignore-errors ; So we set it.
3349 (push (car elem) vars)
3350 (make-local-variable (car elem))
3351 (set (car elem) (eval (nth 1 elem))))))))
3353 (defun gnus-summary-read-group (group &optional show-all no-article
3354 kill-buffer no-display backward
3356 "Start reading news in newsgroup GROUP.
3357 If SHOW-ALL is non-nil, already read articles are also listed.
3358 If NO-ARTICLE is non-nil, no article is selected initially.
3359 If NO-DISPLAY, don't generate a summary buffer."
3363 (let ((gnus-auto-select-next nil))
3364 (or (gnus-summary-read-group-1
3365 group show-all no-article
3366 kill-buffer no-display
3369 select-articles nil)))))
3370 (eq gnus-auto-select-next 'quietly))
3371 (set-buffer gnus-group-buffer)
3372 ;; The entry function called above goes to the next
3373 ;; group automatically, so we go two groups back
3374 ;; if we are searching for the previous group.
3376 (gnus-group-prev-unread-group 2))
3377 (if (not (equal group (gnus-group-group-name)))
3378 (setq group (gnus-group-group-name))
3382 (defun gnus-summary-read-group-1 (group show-all no-article
3383 kill-buffer no-display
3384 &optional select-articles)
3385 ;; Killed foreign groups can't be entered.
3386 ;; (when (and (not (gnus-group-native-p group))
3387 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3388 ;; (error "Dead non-native groups can't be entered"))
3389 (gnus-message 5 "Retrieving newsgroup: %s..."
3390 (gnus-group-decoded-name group))
3391 (let* ((new-group (gnus-summary-setup-buffer group))
3392 (quit-config (gnus-group-quit-config group))
3393 (did-select (and new-group (gnus-select-newsgroup
3394 group show-all select-articles))))
3396 ;; This summary buffer exists already, so we just select it.
3398 (gnus-set-global-variables)
3400 (gnus-kill-or-deaden-summary kill-buffer))
3401 (gnus-configure-windows 'summary 'force)
3402 (gnus-set-mode-line 'summary)
3403 (gnus-summary-position-point)
3406 ;; We couldn't select this group.
3408 (when (and (eq major-mode 'gnus-summary-mode)
3409 (not (equal (current-buffer) kill-buffer)))
3410 (kill-buffer (current-buffer))
3411 (if (not quit-config)
3413 ;; Update the info -- marks might need to be removed,
3415 (gnus-summary-update-info)
3416 (set-buffer gnus-group-buffer)
3417 (gnus-group-jump-to-group group)
3418 (gnus-group-next-unread-group 1))
3419 (gnus-handle-ephemeral-exit quit-config)))
3420 (let ((grpinfo (gnus-get-info group)))
3421 (if (null (gnus-info-read grpinfo))
3422 (gnus-message 3 "Group %s contains no messages"
3423 (gnus-group-decoded-name group))
3424 (gnus-message 3 "Can't select group")))
3426 ;; The user did a `C-g' while prompting for number of articles,
3427 ;; so we exit this group.
3428 ((eq did-select 'quit)
3429 (and (eq major-mode 'gnus-summary-mode)
3430 (not (equal (current-buffer) kill-buffer))
3431 (kill-buffer (current-buffer)))
3433 (gnus-kill-or-deaden-summary kill-buffer))
3434 (if (not quit-config)
3436 (set-buffer gnus-group-buffer)
3437 (gnus-group-jump-to-group group)
3438 (gnus-group-next-unread-group 1)
3439 (gnus-configure-windows 'group 'force))
3440 (gnus-handle-ephemeral-exit quit-config))
3441 ;; Finally signal the quit.
3443 ;; The group was successfully selected.
3445 (gnus-set-global-variables)
3446 ;; Save the active value in effect when the group was entered.
3447 (setq gnus-newsgroup-active
3449 (gnus-active gnus-newsgroup-name)))
3450 ;; You can change the summary buffer in some way with this hook.
3451 (gnus-run-hooks 'gnus-select-group-hook)
3452 (gnus-update-format-specifications
3453 nil 'summary 'summary-mode 'summary-dummy)
3454 (gnus-update-summary-mark-positions)
3455 ;; Do score processing.
3456 (when gnus-use-scoring
3457 (gnus-possibly-score-headers))
3458 ;; Check whether to fill in the gaps in the threads.
3459 (when gnus-build-sparse-threads
3460 (gnus-build-sparse-threads))
3461 ;; Find the initial limit.
3462 (if gnus-show-threads
3464 (let ((gnus-newsgroup-dormant nil))
3465 (gnus-summary-initial-limit show-all))
3466 (gnus-summary-initial-limit show-all))
3467 ;; When unthreaded, all articles are always shown.
3468 (setq gnus-newsgroup-limit
3470 (lambda (header) (mail-header-number header))
3471 gnus-newsgroup-headers)))
3472 ;; Generate the summary buffer.
3474 (gnus-summary-prepare))
3475 (when gnus-use-trees
3476 (gnus-tree-open group)
3477 (setq gnus-summary-highlight-line-function
3478 'gnus-tree-highlight-article))
3479 ;; If the summary buffer is empty, but there are some low-scored
3480 ;; articles or some excluded dormants, we include these in the
3482 (when (and (zerop (buffer-size))
3484 (cond (gnus-newsgroup-dormant
3485 (gnus-summary-limit-include-dormant))
3486 ((and gnus-newsgroup-scored show-all)
3487 (gnus-summary-limit-include-expunged t))))
3488 ;; Function `gnus-apply-kill-file' must be called in this hook.
3489 (gnus-run-hooks 'gnus-apply-kill-hook)
3490 (if (and (zerop (buffer-size))
3493 ;; This newsgroup is empty.
3494 (gnus-summary-catchup-and-exit nil t)
3495 (gnus-message 6 "No unread news")
3497 (gnus-kill-or-deaden-summary kill-buffer))
3498 ;; Return nil from this function.
3500 ;; Hide conversation thread subtrees. We cannot do this in
3501 ;; gnus-summary-prepare-hook since kill processing may not
3502 ;; work with hidden articles.
3503 (gnus-summary-maybe-hide-threads)
3505 (gnus-kill-or-deaden-summary kill-buffer))
3506 (gnus-summary-auto-select-subject)
3507 ;; Show first unread article if requested.
3508 (if (and (not no-article)
3510 gnus-newsgroup-unreads
3511 gnus-auto-select-first)
3513 (gnus-configure-windows 'summary)
3514 (let ((art (gnus-summary-article-number)))
3515 (unless (and (not gnus-plugged)
3516 (or (memq art gnus-newsgroup-undownloaded)
3517 (memq art gnus-newsgroup-downloadable)))
3518 (gnus-summary-goto-article art))))
3519 ;; Don't select any articles.
3520 (gnus-summary-position-point)
3521 (gnus-configure-windows 'summary 'force)
3522 (gnus-set-mode-line 'summary))
3523 (when (get-buffer-window gnus-group-buffer t)
3524 ;; Gotta use windows, because recenter does weird stuff if
3525 ;; the current buffer ain't the displayed window.
3526 (let ((owin (selected-window)))
3527 (select-window (get-buffer-window gnus-group-buffer t))
3528 (when (gnus-group-goto-group group)
3530 (select-window owin)))
3531 ;; Mark this buffer as "prepared".
3532 (setq gnus-newsgroup-prepared t)
3533 (gnus-run-hooks 'gnus-summary-prepared-hook)
3534 (unless (gnus-ephemeral-group-p group)
3535 (gnus-group-update-group group))
3538 (defun gnus-summary-auto-select-subject ()
3539 "Select the subject line on initial group entry."
3540 (goto-char (point-min))
3542 ((eq gnus-auto-select-subject 'best)
3543 (gnus-summary-best-unread-subject))
3544 ((eq gnus-auto-select-subject 'unread)
3545 (gnus-summary-first-unread-subject))
3546 ((eq gnus-auto-select-subject 'unseen)
3547 (gnus-summary-first-unseen-subject))
3548 ((eq gnus-auto-select-subject 'unseen-or-unread)
3549 (gnus-summary-first-unseen-or-unread-subject))
3550 ((eq gnus-auto-select-subject 'first)
3553 ((gnus-functionp gnus-auto-select-subject)
3554 (funcall gnus-auto-select-subject))))
3556 (defun gnus-summary-prepare ()
3557 "Generate the summary buffer."
3559 (let ((buffer-read-only nil))
3561 (setq gnus-newsgroup-data nil
3562 gnus-newsgroup-data-reverse nil)
3563 (gnus-run-hooks 'gnus-summary-generate-hook)
3564 ;; Generate the buffer, either with threads or without.
3565 (when gnus-newsgroup-headers
3566 (gnus-summary-prepare-threads
3567 (if gnus-show-threads
3568 (gnus-sort-gathered-threads
3569 (funcall gnus-summary-thread-gathering-function
3571 (gnus-cut-threads (gnus-make-threads)))))
3572 ;; Unthreaded display.
3573 (gnus-sort-articles gnus-newsgroup-headers))))
3574 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3575 ;; Call hooks for modifying summary buffer.
3576 (goto-char (point-min))
3577 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3579 (defsubst gnus-general-simplify-subject (subject)
3580 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3583 ;; Truncate the subject.
3584 (gnus-simplify-subject-functions
3585 (gnus-map-function gnus-simplify-subject-functions subject))
3586 ((numberp gnus-summary-gather-subject-limit)
3587 (setq subject (gnus-simplify-subject-re subject))
3588 (if (> (length subject) gnus-summary-gather-subject-limit)
3589 (substring subject 0 gnus-summary-gather-subject-limit)
3591 ;; Fuzzily simplify it.
3592 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3593 (gnus-simplify-subject-fuzzy subject))
3594 ;; Just remove the leading "Re:".
3596 (gnus-simplify-subject-re subject))))
3598 (if (and gnus-summary-gather-exclude-subject
3599 (string-match gnus-summary-gather-exclude-subject subject))
3600 nil ; This article shouldn't be gathered
3603 (defun gnus-summary-simplify-subject-query ()
3604 "Query where the respool algorithm would put this article."
3606 (gnus-summary-select-article)
3607 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3609 (defun gnus-gather-threads-by-subject (threads)
3610 "Gather threads by looking at Subject headers."
3611 (if (not gnus-summary-make-false-root)
3613 (let ((hashtb (gnus-make-hashtable 1024))
3616 subject hthread whole-subject)
3618 (setq subject (gnus-general-simplify-subject
3619 (setq whole-subject (mail-header-subject
3622 (if (setq hthread (gnus-gethash subject hashtb))
3624 ;; We enter a dummy root into the thread, if we
3625 ;; haven't done that already.
3626 (unless (stringp (caar hthread))
3627 (setcar hthread (list whole-subject (car hthread))))
3628 ;; We add this new gathered thread to this gathered
3630 (setcdr (car hthread)
3631 (nconc (cdar hthread) (list (car threads))))
3632 ;; Remove it from the list of threads.
3633 (setcdr prev (cdr threads))
3634 (setq threads prev))
3635 ;; Enter this thread into the hash table.
3636 (gnus-sethash subject
3637 (if gnus-summary-make-false-root-always
3639 ;; If you want a dummy root above all
3641 (setcar threads (list whole-subject
3647 (setq threads (cdr threads)))
3650 (defun gnus-gather-threads-by-references (threads)
3651 "Gather threads by looking at References headers."
3652 (let ((idhashtb (gnus-make-hashtable 1024))
3653 (thhashtb (gnus-make-hashtable 1024))
3656 ids references id gthread gid entered ref)
3658 (when (setq references (mail-header-references (caar threads)))
3659 (setq id (mail-header-id (caar threads))
3660 ids (inline (gnus-split-references references))
3662 (while (setq ref (pop ids))
3663 (setq ids (delete ref ids))
3664 (if (not (setq gid (gnus-gethash ref idhashtb)))
3666 (gnus-sethash ref id idhashtb)
3667 (gnus-sethash id threads thhashtb))
3668 (setq gthread (gnus-gethash gid thhashtb))
3670 ;; We enter a dummy root into the thread, if we
3671 ;; haven't done that already.
3672 (unless (stringp (caar gthread))
3673 (setcar gthread (list (mail-header-subject (caar gthread))
3675 ;; We add this new gathered thread to this gathered
3677 (setcdr (car gthread)
3678 (nconc (cdar gthread) (list (car threads)))))
3679 ;; Add it into the thread hash table.
3680 (gnus-sethash id gthread thhashtb)
3682 ;; Remove it from the list of threads.
3683 (setcdr prev (cdr threads))
3684 (setq threads prev))))
3686 (setq threads (cdr threads)))
3689 (defun gnus-sort-gathered-threads (threads)
3690 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3691 (let ((result threads))
3693 (when (stringp (caar threads))
3694 (setcdr (car threads)
3695 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3696 (setq threads (cdr threads)))
3699 (defun gnus-thread-loop-p (root thread)
3700 "Say whether ROOT is in THREAD."
3701 (let ((stack (list thread))
3704 (while (setq thread (pop stack))
3705 (setq th (cdr thread))
3707 (not (eq (caar th) root)))
3710 ;; We have found a loop.
3712 (setcdr thread (delq (car th) (cdr thread)))
3713 (if (boundp (setq ref-dep (intern "none"
3714 gnus-newsgroup-dependencies)))
3715 (setcdr (symbol-value ref-dep)
3716 (nconc (cdr (symbol-value ref-dep))
3718 (set ref-dep (list nil (car th))))
3721 ;; Push all the subthreads onto the stack.
3722 (push (cdr thread) stack)))
3725 (defun gnus-make-threads ()
3726 "Go through the dependency hashtb and find the roots. Return all threads."
3728 (while (catch 'infloop
3731 ;; Deal with self-referencing References loops.
3732 (when (and (car (symbol-value refs))
3739 (car (symbol-value refs)) thread))
3740 (cdr (symbol-value refs)))))))
3743 (unless (car (symbol-value refs))
3744 ;; These threads do not refer back to any other
3745 ;; articles, so they're roots.
3746 (setq threads (append (cdr (symbol-value refs)) threads))))
3747 gnus-newsgroup-dependencies)))
3750 ;; Build the thread tree.
3751 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3752 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3754 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3755 if it was already present.
3757 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3758 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3759 Message-IDs will be renamed to a unique Message-ID before being
3762 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3763 (let* ((id (mail-header-id header))
3764 (id-dep (and id (intern id dependencies)))
3765 parent-id ref ref-dep ref-header replaced)
3766 ;; Enter this `header' in the `dependencies' table.
3770 ;; The first two cases do the normal part: enter a new `header'
3771 ;; in the `dependencies' table.
3772 ((not (boundp id-dep))
3773 (set id-dep (list header)))
3774 ((null (car (symbol-value id-dep)))
3775 (setcar (symbol-value id-dep) header))
3777 ;; From here the `header' was already present in the
3778 ;; `dependencies' table.
3780 ;; Overrides an existing entry;
3781 ;; just set the header part of the entry.
3782 (setcar (symbol-value id-dep) header)
3785 ;; Renames the existing `header' to a unique Message-ID.
3786 ((not gnus-summary-ignore-duplicates)
3787 ;; An article with this Message-ID has already been seen.
3788 ;; We rename the Message-ID.
3789 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3791 (mail-header-set-id header id))
3793 ;; The last case ignores an existing entry, except it adds any
3794 ;; additional Xrefs (in case the two articles came from different
3796 ;; Also sets `header' to `nil' meaning that the `dependencies'
3797 ;; table was *not* modified.
3799 (mail-header-set-xref
3800 (car (symbol-value id-dep))
3801 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3803 (or (mail-header-xref header) "")))
3806 (when (and header (not replaced))
3807 ;; First check that we are not creating a References loop.
3808 (setq parent-id (gnus-parent-id (mail-header-references header)))
3809 (setq ref parent-id)
3811 (setq ref-dep (intern-soft ref dependencies))
3813 (setq ref-header (car (symbol-value ref-dep))))
3814 (if (string= id ref)
3815 ;; Yuk! This is a reference loop. Make the article be a
3818 (mail-header-set-references (car (symbol-value id-dep)) "none")
3820 (setq parent-id nil))
3821 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3822 (setq ref-dep (intern (or parent-id "none") dependencies))
3823 (if (boundp ref-dep)
3824 (setcdr (symbol-value ref-dep)
3825 (nconc (cdr (symbol-value ref-dep))
3826 (list (symbol-value id-dep))))
3827 (set ref-dep (list nil (symbol-value id-dep)))))
3830 (defun gnus-extract-message-id-from-in-reply-to (string)
3831 (if (string-match "<[^>]+>" string)
3832 (substring string (match-beginning 0) (match-end 0))
3835 (defun gnus-build-sparse-threads ()
3836 (let ((headers gnus-newsgroup-headers)
3837 (mail-parse-charset gnus-newsgroup-charset)
3838 (gnus-summary-ignore-duplicates t)
3839 header references generation relations
3840 subject child end new-child date)
3841 ;; First we create an alist of generations/relations, where
3842 ;; generations is how much we trust the relation, and the relation
3844 (gnus-message 7 "Making sparse threads...")
3846 (nnheader-set-temp-buffer " *gnus sparse threads*")
3847 (while (setq header (pop headers))
3848 (when (and (setq references (mail-header-references header))
3849 (not (string= references "")))
3851 (setq child (mail-header-id header)
3852 subject (mail-header-subject header)
3853 date (mail-header-date header)
3855 (while (search-backward ">" nil t)
3856 (setq end (1+ (point)))
3857 (when (search-backward "<" nil t)
3858 (setq new-child (buffer-substring (point) end))
3859 (push (list (incf generation)
3860 child (setq child new-child)
3864 (push (list (1+ generation) child nil subject) relations))
3866 (kill-buffer (current-buffer)))
3867 ;; Sort over trustworthiness.
3870 (when (gnus-dependencies-add-header
3871 (make-full-mail-header
3872 gnus-reffed-article-number
3873 (nth 3 relation) "" (or (nth 4 relation) "")
3875 (or (nth 2 relation) "") 0 0 "")
3876 gnus-newsgroup-dependencies nil)
3877 (push gnus-reffed-article-number gnus-newsgroup-limit)
3878 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3879 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3880 gnus-newsgroup-reads)
3881 (decf gnus-reffed-article-number)))
3882 (sort relations 'car-less-than-car))
3883 (gnus-message 7 "Making sparse threads...done")))
3885 (defun gnus-build-old-threads ()
3886 ;; Look at all the articles that refer back to old articles, and
3887 ;; fetch the headers for the articles that aren't there. This will
3888 ;; build complete threads - if the roots haven't been expired by the
3890 (let ((mail-parse-charset gnus-newsgroup-charset)
3894 (when (not (car (symbol-value refs)))
3895 (setq heads (cdr (symbol-value refs)))
3897 (if (memq (mail-header-number (caar heads))
3898 gnus-newsgroup-dormant)
3899 (setq heads (cdr heads))
3900 (setq id (symbol-name refs))
3901 (while (and (setq id (gnus-build-get-header id))
3902 (not (car (gnus-id-to-thread id)))))
3903 (setq heads nil)))))
3904 gnus-newsgroup-dependencies)))
3906 ;; This function has to be called with point after the article number
3907 ;; on the beginning of the line.
3908 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3909 (let ((eol (gnus-point-at-eol))
3910 (buffer (current-buffer))
3911 header references in-reply-to)
3913 ;; overview: [num subject from date id refs chars lines misc]
3916 (narrow-to-region (point) eol)
3921 (make-full-mail-header
3923 (condition-case () ; subject
3924 (funcall gnus-decode-encoded-word-function
3925 (setq x (nnheader-nov-field)))
3927 (condition-case () ; from
3928 (funcall gnus-decode-encoded-word-function
3929 (setq x (nnheader-nov-field)))
3931 (nnheader-nov-field) ; date
3932 (nnheader-nov-read-message-id) ; id
3933 (setq references (nnheader-nov-field)) ; refs
3934 (nnheader-nov-read-integer) ; chars
3935 (nnheader-nov-read-integer) ; lines
3937 (if (looking-at "Xref: ")
3938 (goto-char (match-end 0)))
3939 (nnheader-nov-field)) ; Xref
3940 (nnheader-nov-parse-extra)))) ; extra
3944 (when (and (string= references "")
3945 (setq in-reply-to (mail-header-extra header))
3946 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3947 (mail-header-set-references
3948 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3950 (when gnus-alter-header-function
3951 (funcall gnus-alter-header-function header))
3952 (gnus-dependencies-add-header header dependencies force-new)))
3954 (defun gnus-build-get-header (id)
3955 "Look through the buffer of NOV lines and find the header to ID.
3956 Enter this line into the dependencies hash table, and return
3957 the id of the parent article (if any)."
3958 (let ((deps gnus-newsgroup-dependencies)
3962 (set-buffer nntp-server-buffer)
3963 (let ((case-fold-search nil))
3964 (goto-char (point-min))
3965 (while (and (not found)
3966 (search-forward id nil t))
3968 (setq found (looking-at
3969 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3970 (regexp-quote id))))
3971 (or found (beginning-of-line 2)))
3975 (setq header (gnus-nov-parse-line
3976 (read (current-buffer)) deps))
3977 (gnus-parent-id (mail-header-references header))))))
3979 (let ((number (mail-header-number header)))
3980 (push number gnus-newsgroup-limit)
3981 (push header gnus-newsgroup-headers)
3982 (if (memq number gnus-newsgroup-unselected)
3984 (setq gnus-newsgroup-unreads
3985 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3987 (setq gnus-newsgroup-unselected
3988 (delq number gnus-newsgroup-unselected)))
3989 (push number gnus-newsgroup-ancient)))))))
3991 (defun gnus-build-all-threads ()
3992 "Read all the headers."
3993 (let ((gnus-summary-ignore-duplicates t)
3994 (mail-parse-charset gnus-newsgroup-charset)
3995 (dependencies gnus-newsgroup-dependencies)
3998 (set-buffer nntp-server-buffer)
3999 (let ((case-fold-search nil))
4000 (goto-char (point-min))
4003 (setq article (read (current-buffer))
4004 header (gnus-nov-parse-line article dependencies)))
4007 (set-buffer gnus-summary-buffer)
4008 (push header gnus-newsgroup-headers)
4009 (if (memq (setq article (mail-header-number header))
4010 gnus-newsgroup-unselected)
4012 (setq gnus-newsgroup-unreads
4013 (gnus-add-to-sorted-list
4014 gnus-newsgroup-unreads article))
4015 (setq gnus-newsgroup-unselected
4016 (delq article gnus-newsgroup-unselected)))
4017 (push article gnus-newsgroup-ancient)))
4018 (forward-line 1)))))))
4020 (defun gnus-summary-update-article-line (article header)
4021 "Update the line for ARTICLE using HEADERS."
4022 (let* ((id (mail-header-id header))
4023 (thread (gnus-id-to-thread id)))
4025 (error "Article in no thread"))
4026 ;; Update the thread.
4027 (setcar thread header)
4028 (gnus-summary-goto-subject article)
4029 (let* ((datal (gnus-data-find-list article))
4031 (buffer-read-only nil)
4032 (level (gnus-summary-thread-level)))
4034 (let ((inserted (- (point)
4036 (gnus-summary-insert-line
4038 (memq article gnus-newsgroup-undownloaded)
4039 (gnus-article-mark article)
4040 (memq article gnus-newsgroup-replied)
4041 (memq article gnus-newsgroup-expirable)
4042 ;; Only insert the Subject string when it's different
4043 ;; from the previous Subject string.
4048 (mail-header-subject
4051 (gnus-data-find-list
4053 (gnus-data-list t)))))
4054 ;; Error on the side of excessive subjects.
4056 (mail-header-subject header)))
4058 (mail-header-subject header))
4059 nil (cdr (assq article gnus-newsgroup-scored))
4060 (memq article gnus-newsgroup-processable))
4063 (gnus-data-update-list
4065 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4067 (defun gnus-summary-update-article (article &optional iheader)
4068 "Update ARTICLE in the summary buffer."
4069 (set-buffer gnus-summary-buffer)
4070 (let* ((header (gnus-summary-article-header article))
4071 (id (mail-header-id header))
4072 (data (gnus-data-find article))
4073 (thread (gnus-id-to-thread id))
4074 (references (mail-header-references header))
4078 (when (and references
4079 (not (equal "" references)))
4082 (buffer-read-only nil)
4088 (delq thread parent)))
4089 (if (gnus-summary-insert-subject id header)
4090 ;; Set the (possibly) new article number in the data structure.
4091 (gnus-data-set-number data (gnus-id-to-article id))
4095 (defun gnus-rebuild-thread (id &optional line)
4096 "Rebuild the thread containing ID.
4097 If LINE, insert the rebuilt thread starting on line LINE."
4098 (let ((buffer-read-only nil)
4099 old-pos current thread data)
4100 (if (not gnus-show-threads)
4101 (setq thread (list (car (gnus-id-to-thread id))))
4102 ;; Get the thread this article is part of.
4103 (setq thread (gnus-remove-thread id)))
4104 (setq old-pos (gnus-point-at-bol))
4105 (setq current (save-excursion
4106 (and (re-search-backward "[\r\n]" nil t)
4107 (gnus-summary-article-number))))
4108 ;; If this is a gathered thread, we have to go some re-gathering.
4109 (when (stringp (car thread))
4110 (let ((subject (car thread))
4112 (setq thread (cdr thread))
4114 (unless (memq (setq thr (gnus-id-to-thread
4116 (mail-header-id (caar thread)))))
4119 (setq thread (cdr thread)))
4120 ;; We now have all (unique) roots.
4121 (if (= (length roots) 1)
4122 ;; All the loose roots are now one solid root.
4123 (setq thread (car roots))
4124 (setq thread (cons subject (gnus-sort-threads roots))))))
4126 ;; We then insert this thread into the summary buffer.
4128 (goto-char (point-min))
4129 (forward-line (1- line)))
4130 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4131 (if gnus-show-threads
4132 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4133 (gnus-summary-prepare-unthreaded thread))
4134 (setq data (nreverse gnus-newsgroup-data))
4135 (setq threads gnus-newsgroup-threads))
4136 ;; We splice the new data into the data structure.
4137 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4138 ;;!!! then we want to insert at the beginning of the buffer.
4139 ;;!!! That happens to be true with Gnus now, but that may
4140 ;;!!! change in the future. Perhaps.
4141 (gnus-data-enter-list
4142 (if line nil current) data (- (point) old-pos))
4143 (setq gnus-newsgroup-threads
4144 (nconc threads gnus-newsgroup-threads))
4145 (gnus-data-compute-positions))))
4147 (defun gnus-number-to-header (number)
4148 "Return the header for article NUMBER."
4149 (let ((headers gnus-newsgroup-headers))
4151 (not (= number (mail-header-number (car headers)))))
4156 (defun gnus-parent-headers (in-headers &optional generation)
4157 "Return the headers of the GENERATIONeth parent of HEADERS."
4159 (setq generation 1))
4161 (headers in-headers)
4164 (not (zerop generation))
4165 (setq references (mail-header-references headers)))
4166 (setq headers (if (and references
4167 (setq parent (gnus-parent-id references)))
4168 (car (gnus-id-to-thread parent))
4171 (and (not (eq headers in-headers))
4174 (defun gnus-id-to-thread (id)
4175 "Return the (sub-)thread where ID appears."
4176 (gnus-gethash id gnus-newsgroup-dependencies))
4178 (defun gnus-id-to-article (id)
4179 "Return the article number of ID."
4180 (let ((thread (gnus-id-to-thread id)))
4183 (mail-header-number (car thread)))))
4185 (defun gnus-id-to-header (id)
4186 "Return the article headers of ID."
4187 (car (gnus-id-to-thread id)))
4189 (defun gnus-article-displayed-root-p (article)
4190 "Say whether ARTICLE is a root(ish) article."
4191 (let ((level (gnus-summary-thread-level article))
4192 (refs (mail-header-references (gnus-summary-article-header article)))
4198 ((null (gnus-parent-id refs)) t)
4200 (null (setq particle (gnus-id-to-article
4201 (gnus-parent-id refs))))
4202 (null (gnus-summary-thread-level particle)))))))
4204 (defun gnus-root-id (id)
4205 "Return the id of the root of the thread where ID appears."
4207 (while (and id (setq prev (car (gnus-id-to-thread id))))
4209 id (gnus-parent-id (mail-header-references prev))))
4212 (defun gnus-articles-in-thread (thread)
4213 "Return the list of articles in THREAD."
4214 (cons (mail-header-number (car thread))
4215 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4217 (defun gnus-remove-thread (id &optional dont-remove)
4218 "Remove the thread that has ID in it."
4219 (let (headers thread last-id)
4220 ;; First go up in this thread until we find the root.
4221 (setq last-id (gnus-root-id id)
4222 headers (message-flatten-list (gnus-id-to-thread last-id)))
4223 ;; We have now found the real root of this thread. It might have
4224 ;; been gathered into some loose thread, so we have to search
4225 ;; through the threads to find the thread we wanted.
4226 (let ((threads gnus-newsgroup-threads)
4229 (setq sub (car threads))
4230 (if (stringp (car sub))
4231 ;; This is a gathered thread, so we look at the roots
4232 ;; below it to find whether this article is in this
4235 (setq sub (cdr sub))
4237 (when (member (caar sub) headers)
4238 (setq thread (car threads)
4241 (setq sub (cdr sub))))
4242 ;; It's an ordinary thread, so we check it.
4243 (when (eq (car sub) (car headers))
4246 (setq threads (cdr threads)))
4247 ;; If this article is in no thread, then it's a root.
4250 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4251 (setq thread (gnus-id-to-thread last-id)))
4254 thread ; We return this thread.
4256 (if (stringp (car thread))
4258 ;; If we use dummy roots, then we have to remove the
4259 ;; dummy root as well.
4260 (when (eq gnus-summary-make-false-root 'dummy)
4261 ;; We go to the dummy root by going to
4262 ;; the first sub-"thread", and then one line up.
4263 (gnus-summary-goto-article
4264 (mail-header-number (caadr thread)))
4267 (gnus-data-compute-positions))
4268 (setq thread (cdr thread))
4270 (gnus-remove-thread-1 (car thread))
4271 (setq thread (cdr thread))))
4272 (gnus-remove-thread-1 thread))))))))
4274 (defun gnus-remove-thread-1 (thread)
4275 "Remove the thread THREAD recursively."
4276 (let ((number (mail-header-number (pop thread)))
4278 (setq thread (reverse thread))
4280 (gnus-remove-thread-1 (pop thread)))
4281 (when (setq d (gnus-data-find number))
4282 (goto-char (gnus-data-pos d))
4283 (gnus-summary-show-thread)
4286 (- (gnus-point-at-bol)
4288 (1+ (gnus-point-at-eol))
4289 (gnus-delete-line)))))))
4291 (defun gnus-sort-threads-1 (threads func)
4292 (sort (mapcar (lambda (thread)
4295 (gnus-sort-threads-1 (cdr thread) func))))
4298 (defun gnus-sort-threads (threads)
4300 (if (not gnus-thread-sort-functions)
4302 (gnus-message 8 "Sorting threads...")
4303 (let ((max-lisp-eval-depth 5000))
4304 (prog1 (gnus-sort-threads-1
4306 (gnus-make-sort-function gnus-thread-sort-functions))
4307 (gnus-message 8 "Sorting threads...done")))))
4309 (defun gnus-sort-articles (articles)
4311 (when gnus-article-sort-functions
4312 (gnus-message 7 "Sorting articles...")
4314 (setq gnus-newsgroup-headers
4315 (sort articles (gnus-make-sort-function
4316 gnus-article-sort-functions)))
4317 (gnus-message 7 "Sorting articles...done"))))
4319 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4320 (defmacro gnus-thread-header (thread)
4321 "Return header of first article in THREAD.
4322 Note that THREAD must never, ever be anything else than a variable -
4323 using some other form will lead to serious barfage."
4324 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4325 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4326 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4329 (defsubst gnus-article-sort-by-number (h1 h2)
4330 "Sort articles by article number."
4331 (< (mail-header-number h1)
4332 (mail-header-number h2)))
4334 (defun gnus-thread-sort-by-number (h1 h2)
4335 "Sort threads by root article number."
4336 (gnus-article-sort-by-number
4337 (gnus-thread-header h1) (gnus-thread-header h2)))
4339 (defsubst gnus-article-sort-by-random (h1 h2)
4340 "Sort articles by article number."
4343 (defun gnus-thread-sort-by-random (h1 h2)
4344 "Sort threads by root article number."
4345 (gnus-article-sort-by-random
4346 (gnus-thread-header h1) (gnus-thread-header h2)))
4348 (defsubst gnus-article-sort-by-lines (h1 h2)
4349 "Sort articles by article Lines header."
4350 (< (mail-header-lines h1)
4351 (mail-header-lines h2)))
4353 (defun gnus-thread-sort-by-lines (h1 h2)
4354 "Sort threads by root article Lines header."
4355 (gnus-article-sort-by-lines
4356 (gnus-thread-header h1) (gnus-thread-header h2)))
4358 (defsubst gnus-article-sort-by-chars (h1 h2)
4359 "Sort articles by octet length."
4360 (< (mail-header-chars h1)
4361 (mail-header-chars h2)))
4363 (defun gnus-thread-sort-by-chars (h1 h2)
4364 "Sort threads by root article octet length."
4365 (gnus-article-sort-by-chars
4366 (gnus-thread-header h1) (gnus-thread-header h2)))
4368 (defsubst gnus-article-sort-by-author (h1 h2)
4369 "Sort articles by root author."
4371 (let ((extract (funcall
4372 gnus-extract-address-components
4373 (mail-header-from h1))))
4374 (or (car extract) (cadr extract) ""))
4375 (let ((extract (funcall
4376 gnus-extract-address-components
4377 (mail-header-from h2))))
4378 (or (car extract) (cadr extract) ""))))
4380 (defun gnus-thread-sort-by-author (h1 h2)
4381 "Sort threads by root author."
4382 (gnus-article-sort-by-author
4383 (gnus-thread-header h1) (gnus-thread-header h2)))
4385 (defsubst gnus-article-sort-by-subject (h1 h2)
4386 "Sort articles by root subject."
4388 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4389 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4391 (defun gnus-thread-sort-by-subject (h1 h2)
4392 "Sort threads by root subject."
4393 (gnus-article-sort-by-subject
4394 (gnus-thread-header h1) (gnus-thread-header h2)))
4396 (defsubst gnus-article-sort-by-date (h1 h2)
4397 "Sort articles by root article date."
4399 (gnus-date-get-time (mail-header-date h1))
4400 (gnus-date-get-time (mail-header-date h2))))
4402 (defun gnus-thread-sort-by-date (h1 h2)
4403 "Sort threads by root article date."
4404 (gnus-article-sort-by-date
4405 (gnus-thread-header h1) (gnus-thread-header h2)))
4407 (defsubst gnus-article-sort-by-score (h1 h2)
4408 "Sort articles by root article score.
4409 Unscored articles will be counted as having a score of zero."
4410 (> (or (cdr (assq (mail-header-number h1)
4411 gnus-newsgroup-scored))
4412 gnus-summary-default-score 0)
4413 (or (cdr (assq (mail-header-number h2)
4414 gnus-newsgroup-scored))
4415 gnus-summary-default-score 0)))
4417 (defun gnus-thread-sort-by-score (h1 h2)
4418 "Sort threads by root article score."
4419 (gnus-article-sort-by-score
4420 (gnus-thread-header h1) (gnus-thread-header h2)))
4422 (defun gnus-thread-sort-by-total-score (h1 h2)
4423 "Sort threads by the sum of all scores in the thread.
4424 Unscored articles will be counted as having a score of zero."
4425 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4427 (defun gnus-thread-total-score (thread)
4428 ;; This function find the total score of THREAD.
4433 (if (stringp (car thread))
4434 (apply gnus-thread-score-function 0
4435 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4436 (gnus-thread-total-score-1 thread)))
4438 (gnus-thread-total-score-1 (list thread)))))
4440 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4441 "Sort threads such that the thread with the most recently arrived article comes first."
4442 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4444 (defun gnus-thread-highest-number (thread)
4445 "Return the highest article number in THREAD."
4446 (apply 'max (mapcar (lambda (header)
4447 (mail-header-number header))
4448 (message-flatten-list thread))))
4450 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4451 "Sort threads such that the thread with the most recently dated article comes first."
4452 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4454 (defun gnus-thread-latest-date (thread)
4455 "Return the highest article date in THREAD."
4456 (let ((previous-time 0))
4463 (mail-header-parse-date (mail-header-date header))
4464 (error previous-time)))))
4466 (message-flatten-list thread)
4468 (< (mail-header-number h1)
4469 (mail-header-number h2))))))))
4471 (defun gnus-thread-total-score-1 (root)
4472 ;; This function find the total score of the thread below ROOT.
4473 (setq root (car root))
4474 (apply gnus-thread-score-function
4476 (mapcar 'gnus-thread-total-score
4477 (cdr (gnus-id-to-thread (mail-header-id root))))
4478 (when (> (mail-header-number root) 0)
4479 (list (or (cdr (assq (mail-header-number root)
4480 gnus-newsgroup-scored))
4481 gnus-summary-default-score 0))))
4482 (list gnus-summary-default-score)
4485 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4486 (defvar gnus-tmp-prev-subject nil)
4487 (defvar gnus-tmp-false-parent nil)
4488 (defvar gnus-tmp-root-expunged nil)
4489 (defvar gnus-tmp-dummy-line nil)
4491 (eval-when-compile (defvar gnus-tmp-header))
4492 (defun gnus-extra-header (type &optional header)
4493 "Return the extra header of TYPE."
4494 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4497 (defvar gnus-tmp-thread-tree-header-string "")
4499 (defcustom gnus-sum-thread-tree-root "> "
4500 "With %B spec, used for the root of a thread.
4501 If nil, use subject instead."
4503 :group 'gnus-thread)
4504 (defcustom gnus-sum-thread-tree-single-indent ""
4505 "With %B spec, used for a thread with just one message.
4506 If nil, use subject instead."
4508 :group 'gnus-thread)
4509 (defcustom gnus-sum-thread-tree-vertical "| "
4510 "With %B spec, used for drawing a vertical line."
4512 :group 'gnus-thread)
4513 (defcustom gnus-sum-thread-tree-indent " "
4514 "With %B spec, used for indenting."
4516 :group 'gnus-thread)
4517 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4518 "With %B spec, used for a leaf with brothers."
4520 :group 'gnus-thread)
4521 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4522 "With %B spec, used for a leaf without brothers."
4524 :group 'gnus-thread)
4526 (defun gnus-summary-prepare-threads (threads)
4527 "Prepare summary buffer from THREADS and indentation LEVEL.
4528 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4529 or a straight list of headers."
4530 (gnus-message 7 "Generating summary...")
4532 (setq gnus-newsgroup-threads threads)
4535 (let ((gnus-tmp-level 0)
4536 (default-score (or gnus-summary-default-score 0))
4537 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4538 (building-line-count gnus-summary-display-while-building)
4539 (building-count (integerp gnus-summary-display-while-building))
4540 thread number subject stack state gnus-tmp-gathered beg-match
4541 new-roots gnus-tmp-new-adopts thread-end simp-subject
4542 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4543 gnus-tmp-replied gnus-tmp-subject-or-nil
4544 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4545 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4546 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4549 (setq gnus-tmp-prev-subject nil
4550 gnus-tmp-thread-tree-header-string "")
4552 (if (vectorp (car threads))
4553 ;; If this is a straight (sic) list of headers, then a
4554 ;; threaded summary display isn't required, so we just create
4555 ;; an unthreaded one.
4556 (gnus-summary-prepare-unthreaded threads)
4558 ;; Do the threaded display.
4560 (if gnus-summary-display-while-building
4561 (switch-to-buffer (buffer-name)))
4562 (while (or threads stack gnus-tmp-new-adopts new-roots)
4564 (if (and (= gnus-tmp-level 0)
4567 (not gnus-tmp-false-parent)
4568 (or gnus-tmp-new-adopts new-roots))
4569 (if gnus-tmp-new-adopts
4570 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4571 thread (list (car gnus-tmp-new-adopts))
4572 gnus-tmp-header (caar thread)
4573 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4575 (setq thread (list (car new-roots))
4576 gnus-tmp-header (caar thread)
4577 new-roots (cdr new-roots))))
4580 ;; If there are some threads, we do them before the
4581 ;; threads on the stack.
4582 (setq thread threads
4583 gnus-tmp-header (caar thread))
4584 ;; There were no current threads, so we pop something off
4586 (setq state (car stack)
4587 gnus-tmp-level (car state)
4588 tree-stack (cadr state)
4589 thread (caddr state)
4591 gnus-tmp-header (caar thread))))
4593 (setq gnus-tmp-false-parent nil)
4594 (setq gnus-tmp-root-expunged nil)
4595 (setq thread-end nil)
4597 (if (stringp gnus-tmp-header)
4598 ;; The header is a dummy root.
4600 ((eq gnus-summary-make-false-root 'adopt)
4601 ;; We let the first article adopt the rest.
4602 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4604 (setq gnus-tmp-gathered
4606 (lambda (h) (mail-header-number (car h)))
4609 (setq thread (cons (list (caar thread)
4612 (setq gnus-tmp-level -1
4613 gnus-tmp-false-parent t))
4614 ((eq gnus-summary-make-false-root 'empty)
4615 ;; We print adopted articles with empty subject fields.
4616 (setq gnus-tmp-gathered
4618 (lambda (h) (mail-header-number (car h)))
4621 (setq gnus-tmp-level -1))
4622 ((eq gnus-summary-make-false-root 'dummy)
4623 ;; We remember that we probably want to output a dummy
4625 (setq gnus-tmp-dummy-line gnus-tmp-header)
4626 (setq gnus-tmp-prev-subject gnus-tmp-header))
4628 ;; We do not make a root for the gathered
4629 ;; sub-threads at all.
4630 (setq gnus-tmp-level -1)))
4632 (setq number (mail-header-number gnus-tmp-header)
4633 subject (mail-header-subject gnus-tmp-header)
4634 simp-subject (gnus-simplify-subject-fully subject))
4637 ;; If the thread has changed subject, we might want to make
4638 ;; this subthread into a root.
4639 ((and (null gnus-thread-ignore-subject)
4640 (not (zerop gnus-tmp-level))
4641 gnus-tmp-prev-subject
4642 (not (string= gnus-tmp-prev-subject simp-subject)))
4643 (setq new-roots (nconc new-roots (list (car thread)))
4645 gnus-tmp-header nil))
4646 ;; If the article lies outside the current limit,
4647 ;; then we do not display it.
4648 ((not (memq number gnus-newsgroup-limit))
4649 (setq gnus-tmp-gathered
4651 (lambda (h) (mail-header-number (car h)))
4654 (setq gnus-tmp-new-adopts (if (cdar thread)
4655 (append gnus-tmp-new-adopts
4657 gnus-tmp-new-adopts)
4659 gnus-tmp-header nil)
4660 (when (zerop gnus-tmp-level)
4661 (setq gnus-tmp-root-expunged t)))
4662 ;; Perhaps this article is to be marked as read?
4663 ((and gnus-summary-mark-below
4664 (< (or (cdr (assq number gnus-newsgroup-scored))
4666 gnus-summary-mark-below)
4667 ;; Don't touch sparse articles.
4668 (not (gnus-summary-article-sparse-p number))
4669 (not (gnus-summary-article-ancient-p number)))
4670 (setq gnus-newsgroup-unreads
4671 (delq number gnus-newsgroup-unreads))
4672 (if gnus-newsgroup-auto-expire
4673 (setq gnus-newsgroup-expirable
4674 (gnus-add-to-sorted-list
4675 gnus-newsgroup-expirable number))
4676 (push (cons number gnus-low-score-mark)
4677 gnus-newsgroup-reads))))
4679 (when gnus-tmp-header
4680 ;; We may have an old dummy line to output before this
4682 (when (and gnus-tmp-dummy-line
4685 (mail-header-subject gnus-tmp-header)))
4686 (gnus-summary-insert-dummy-line
4687 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4688 (setq gnus-tmp-dummy-line nil))
4690 ;; Compute the mark.
4691 (setq gnus-tmp-unread (gnus-article-mark number))
4693 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4694 gnus-tmp-header gnus-tmp-level)
4695 gnus-newsgroup-data)
4697 ;; Actually insert the line.
4699 gnus-tmp-subject-or-nil
4701 ((and gnus-thread-ignore-subject
4702 gnus-tmp-prev-subject
4703 (not (string= gnus-tmp-prev-subject simp-subject)))
4705 ((zerop gnus-tmp-level)
4706 (if (and (eq gnus-summary-make-false-root 'empty)
4707 (memq number gnus-tmp-gathered)
4708 gnus-tmp-prev-subject
4709 (string= gnus-tmp-prev-subject simp-subject))
4710 gnus-summary-same-subject
4712 (t gnus-summary-same-subject)))
4713 (if (and (eq gnus-summary-make-false-root 'adopt)
4714 (= gnus-tmp-level 1)
4715 (memq number gnus-tmp-gathered))
4716 (setq gnus-tmp-opening-bracket ?\<
4717 gnus-tmp-closing-bracket ?\>)
4718 (setq gnus-tmp-opening-bracket ?\[
4719 gnus-tmp-closing-bracket ?\]))
4721 gnus-tmp-indentation
4722 (aref gnus-thread-indent-array gnus-tmp-level)
4723 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4724 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4725 gnus-summary-default-score 0)
4727 (if (or (null gnus-summary-default-score)
4728 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4729 gnus-summary-zcore-fuzz))
4731 (if (< gnus-tmp-score gnus-summary-default-score)
4732 gnus-score-below-mark gnus-score-over-mark))
4734 (cond ((memq number gnus-newsgroup-processable)
4736 ((memq number gnus-newsgroup-cached)
4738 ((memq number gnus-newsgroup-replied)
4740 ((memq number gnus-newsgroup-forwarded)
4741 gnus-forwarded-mark)
4742 ((memq number gnus-newsgroup-saved)
4744 ((memq number gnus-newsgroup-recent)
4746 ((memq number gnus-newsgroup-unseen)
4750 (cond ((memq number gnus-newsgroup-undownloaded)
4751 gnus-undownloaded-mark)
4752 (gnus-newsgroup-agentized
4753 gnus-downloaded-mark)
4756 gnus-tmp-from (mail-header-from gnus-tmp-header)
4759 ((string-match "<[^>]+> *$" gnus-tmp-from)
4760 (setq beg-match (match-beginning 0))
4761 (or (and (string-match "^\".+\"" gnus-tmp-from)
4762 (substring gnus-tmp-from 1 (1- (match-end 0))))
4763 (substring gnus-tmp-from 0 beg-match)))
4764 ((string-match "(.+)" gnus-tmp-from)
4765 (substring gnus-tmp-from
4766 (1+ (match-beginning 0)) (1- (match-end 0))))
4768 gnus-tmp-thread-tree-header-string
4770 ((not gnus-show-threads) "")
4771 ((zerop gnus-tmp-level)
4773 (or gnus-sum-thread-tree-root subject)
4774 (or gnus-sum-thread-tree-single-indent subject)))
4776 (concat (apply 'concat
4777 (mapcar (lambda (item)
4779 gnus-sum-thread-tree-vertical
4780 gnus-sum-thread-tree-indent))
4781 (cdr (reverse tree-stack))))
4783 gnus-sum-thread-tree-leaf-with-other
4784 gnus-sum-thread-tree-single-leaf)))))
4785 (when (string= gnus-tmp-name "")
4786 (setq gnus-tmp-name gnus-tmp-from))
4787 (unless (numberp gnus-tmp-lines)
4788 (setq gnus-tmp-lines -1))
4789 (if (= gnus-tmp-lines -1)
4790 (setq gnus-tmp-lines "?")
4791 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4792 (gnus-put-text-property
4794 (progn (eval gnus-summary-line-format-spec) (point))
4795 'gnus-number number)
4798 (gnus-run-hooks 'gnus-summary-update-hook)
4801 (setq gnus-tmp-prev-subject simp-subject)))
4803 (when (nth 1 thread)
4804 (push (list (max 0 gnus-tmp-level)
4805 (copy-list tree-stack)
4808 (push (if (nth 1 thread) 1 0) tree-stack)
4809 (incf gnus-tmp-level)
4810 (setq threads (if thread-end nil (cdar thread)))
4811 (if gnus-summary-display-while-building
4814 ;; use a set frequency
4815 (setq building-line-count (1- building-line-count))
4816 (when (= building-line-count 0)
4818 (setq building-line-count
4819 gnus-summary-display-while-building)))
4823 (setq gnus-tmp-level 0)))))
4824 (gnus-message 7 "Generating summary...done"))
4826 (defun gnus-summary-prepare-unthreaded (headers)
4827 "Generate an unthreaded summary buffer based on HEADERS."
4828 (let (header number mark)
4833 ;; We may have to root out some bad articles...
4834 (when (memq (setq number (mail-header-number
4835 (setq header (pop headers))))
4836 gnus-newsgroup-limit)
4837 ;; Mark article as read when it has a low score.
4838 (when (and gnus-summary-mark-below
4839 (< (or (cdr (assq number gnus-newsgroup-scored))
4840 gnus-summary-default-score 0)
4841 gnus-summary-mark-below)
4842 (not (gnus-summary-article-ancient-p number)))
4843 (setq gnus-newsgroup-unreads
4844 (delq number gnus-newsgroup-unreads))
4845 (if gnus-newsgroup-auto-expire
4846 (push number gnus-newsgroup-expirable)
4847 (push (cons number gnus-low-score-mark)
4848 gnus-newsgroup-reads)))
4850 (setq mark (gnus-article-mark number))
4851 (push (gnus-data-make number mark (1+ (point)) header 0)
4852 gnus-newsgroup-data)
4853 (gnus-summary-insert-line
4855 (memq number gnus-newsgroup-undownloaded)
4856 mark (memq number gnus-newsgroup-replied)
4857 (memq number gnus-newsgroup-expirable)
4858 (mail-header-subject header) nil
4859 (cdr (assq number gnus-newsgroup-scored))
4860 (memq number gnus-newsgroup-processable))))))
4862 (defun gnus-summary-remove-list-identifiers ()
4863 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4864 (let ((regexp (if (consp gnus-list-identifiers)
4865 (mapconcat 'identity gnus-list-identifiers " *\\|")
4866 gnus-list-identifiers))
4869 (dolist (header gnus-newsgroup-headers)
4870 (setq subject (mail-header-subject header)
4872 (while (string-match
4873 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4876 (concat (substring subject 0 (match-beginning 2))
4877 (substring subject (match-end 0)))
4881 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4883 (concat (substring subject 0 (match-beginning 1))
4884 (substring subject (match-end 1)))))
4886 (mail-header-set-subject header subject))))))
4888 (defun gnus-fetch-headers (articles)
4889 "Fetch headers of ARTICLES."
4890 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4891 (gnus-message 5 "Fetching headers for %s..." name)
4894 (setq gnus-headers-retrieved-by
4895 (gnus-retrieve-headers
4896 articles gnus-newsgroup-name
4897 ;; We might want to fetch old headers, but
4898 ;; not if there is only 1 article.
4900 (not (eq gnus-fetch-old-headers 'some))
4901 (not (numberp gnus-fetch-old-headers)))
4902 (> (length articles) 1))
4903 gnus-fetch-old-headers))))
4904 (gnus-get-newsgroup-headers-xover
4905 articles nil nil gnus-newsgroup-name t)
4906 (gnus-get-newsgroup-headers))
4907 (gnus-message 5 "Fetching headers for %s...done" name))))
4909 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4910 "Select newsgroup GROUP.
4911 If READ-ALL is non-nil, all articles in the group are selected.
4912 If SELECT-ARTICLES, only select those articles from GROUP."
4913 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4914 ;;!!! Dirty hack; should be removed.
4915 (gnus-summary-ignore-duplicates
4916 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4918 gnus-summary-ignore-duplicates))
4919 (info (nth 2 entry))
4920 articles fetched-articles cached)
4922 (unless (gnus-check-server
4923 (set (make-local-variable 'gnus-current-select-method)
4924 (gnus-find-method-for-group group)))
4925 (error "Couldn't open server"))
4927 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4928 (gnus-activate-group group) ; Or we can activate it...
4929 (progn ; Or we bug out.
4930 (when (equal major-mode 'gnus-summary-mode)
4931 (gnus-kill-buffer (current-buffer)))
4932 (error "Couldn't activate group %s: %s"
4933 group (gnus-status-message group))))
4935 (unless (gnus-request-group group t)
4936 (when (equal major-mode 'gnus-summary-mode)
4937 (gnus-kill-buffer (current-buffer)))
4938 (error "Couldn't request group %s: %s"
4939 group (gnus-status-message group)))
4941 (setq gnus-newsgroup-name group
4942 gnus-newsgroup-unselected nil
4943 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4945 (let ((display (gnus-group-find-parameter group 'display)))
4946 (setq gnus-newsgroup-display
4948 ((not (zerop (or (car-safe read-all) 0)))
4949 ;; The user entered the group with C-u SPC/RET, let's show
4955 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4957 ;; The following is probably the "correct" solution, but
4958 ;; it makes Gnus fetch all headers and then limit the
4959 ;; articles (which is slow), so instead we hack the
4960 ;; select-articles parameter instead. -- Simon Josefsson
4963 ;; (gnus-byte-compile
4964 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4966 (setq select-articles
4967 (gnus-uncompress-range
4968 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4972 (cdr (gnus-active group)))))
4977 (gnus-summary-setup-default-charset)
4979 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4980 (when (gnus-virtual-group-p group)
4981 (setq cached gnus-newsgroup-cached))
4983 (setq gnus-newsgroup-unreads
4984 (gnus-sorted-ndifference
4985 (gnus-sorted-ndifference gnus-newsgroup-unreads
4986 gnus-newsgroup-marked)
4987 gnus-newsgroup-dormant))
4989 (setq gnus-newsgroup-processable nil)
4991 (gnus-update-read-articles group gnus-newsgroup-unreads)
4993 ;; Adjust and set lists of article marks.
4995 (gnus-adjust-marked-articles info))
4996 (if (setq articles select-articles)
4997 (setq gnus-newsgroup-unselected
4998 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4999 (setq articles (gnus-articles-to-read group read-all)))
5003 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5005 ((eq articles 0) nil)
5007 ;; Init the dependencies hash table.
5008 (setq gnus-newsgroup-dependencies
5009 (gnus-make-hashtable (length articles)))
5010 (gnus-set-global-variables)
5011 ;; Retrieve the headers and read them in.
5013 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5015 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5017 (setq gnus-newsgroup-cached cached))
5019 ;; Suppress duplicates?
5020 (when gnus-suppress-duplicates
5021 (gnus-dup-suppress-articles))
5023 ;; Set the initial limit.
5024 (setq gnus-newsgroup-limit (copy-sequence articles))
5025 ;; Remove canceled articles from the list of unread articles.
5026 (setq fetched-articles
5027 (mapcar (lambda (headers) (mail-header-number headers))
5028 gnus-newsgroup-headers))
5029 (setq gnus-newsgroup-articles fetched-articles)
5030 (setq gnus-newsgroup-unreads
5031 (gnus-sorted-nintersection
5032 gnus-newsgroup-unreads fetched-articles))
5033 (gnus-compute-unseen-list)
5035 ;; Removed marked articles that do not exist.
5036 (gnus-update-missing-marks
5037 (gnus-sorted-difference articles fetched-articles))
5038 ;; We might want to build some more threads first.
5039 (when (and gnus-fetch-old-headers
5040 (eq gnus-headers-retrieved-by 'nov))
5041 (if (eq gnus-fetch-old-headers 'invisible)
5042 (gnus-build-all-threads)
5043 (gnus-build-old-threads)))
5044 ;; Let the Gnus agent mark articles as read.
5046 (gnus-agent-get-undownloaded-list))
5047 ;; Remove list identifiers from subject
5048 (when gnus-list-identifiers
5049 (gnus-summary-remove-list-identifiers))
5050 ;; Check whether auto-expire is to be done in this group.
5051 (setq gnus-newsgroup-auto-expire
5052 (gnus-group-auto-expirable-p group))
5053 ;; Set up the article buffer now, if necessary.
5054 (unless gnus-single-article-buffer
5055 (gnus-article-setup-buffer))
5056 ;; First and last article in this newsgroup.
5057 (when gnus-newsgroup-headers
5058 (setq gnus-newsgroup-begin
5059 (mail-header-number (car gnus-newsgroup-headers))
5062 (gnus-last-element gnus-newsgroup-headers))))
5063 ;; GROUP is successfully selected.
5064 (or gnus-newsgroup-headers t)))))
5066 (defun gnus-compute-unseen-list ()
5067 ;; The `seen' marks are treated specially.
5068 (if (not gnus-newsgroup-seen)
5069 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5070 (setq gnus-newsgroup-unseen
5071 (gnus-inverse-list-range-intersection
5072 gnus-newsgroup-articles gnus-newsgroup-seen))))
5074 (defun gnus-summary-display-make-predicate (display)
5075 (require 'gnus-agent)
5076 (when (= (length display) 1)
5077 (setq display (car display)))
5078 (unless gnus-summary-display-cache
5079 (dolist (elem (append '((unread . unread)
5082 gnus-article-mark-lists))
5083 (push (cons (cdr elem)
5085 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5086 gnus-summary-display-cache)))
5087 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5088 (gnus-category-predicate-cache gnus-summary-display-cache))
5089 (gnus-get-predicate display)))
5091 ;; Uses the dynamically bound `number' variable.
5094 (defun gnus-article-marked-p (type &optional article)
5095 (let ((article (or article number)))
5098 (memq article gnus-newsgroup-marked))
5100 (memq article gnus-newsgroup-spam-marked))
5102 (memq article gnus-newsgroup-unsendable))
5103 ((eq type 'undownload)
5104 (memq article gnus-newsgroup-undownloaded))
5105 ((eq type 'download)
5106 (memq article gnus-newsgroup-downloadable))
5108 (memq article gnus-newsgroup-unreads))
5110 (memq article gnus-newsgroup-reads))
5112 (memq article gnus-newsgroup-dormant) )
5114 (memq article gnus-newsgroup-expirable))
5116 (memq article gnus-newsgroup-replied))
5118 (memq article gnus-newsgroup-killed))
5119 ((eq type 'bookmark)
5120 (assq article gnus-newsgroup-bookmarks))
5122 (assq article gnus-newsgroup-scored))
5124 (memq article gnus-newsgroup-saved))
5126 (memq article gnus-newsgroup-cached))
5128 (memq article gnus-newsgroup-forwarded))
5130 (not (memq article gnus-newsgroup-unseen)))
5132 (memq article gnus-newsgroup-recent))
5135 (defun gnus-articles-to-read (group &optional read-all)
5136 "Find out what articles the user wants to read."
5137 (let* ((display (gnus-group-find-parameter group 'display))
5139 ;; Select all articles if `read-all' is non-nil, or if there
5140 ;; are no unread articles.
5142 (and (zerop (length gnus-newsgroup-marked))
5143 (zerop (length gnus-newsgroup-unreads)))
5144 ;; Fetch all if the predicate is non-nil.
5145 gnus-newsgroup-display)
5146 ;; We want to select the headers for all the articles in
5147 ;; the group, so we select either all the active
5148 ;; articles in the group, or (if that's nil), the
5149 ;; articles in the cache.
5151 (gnus-uncompress-range (gnus-active group))
5152 (gnus-cache-articles-in-group group))
5153 ;; Select only the "normal" subset of articles.
5155 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5156 gnus-newsgroup-unreads)))
5157 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5158 (scored (length scored-list))
5159 (number (length articles))
5160 (marked (+ (length gnus-newsgroup-marked)
5161 (length gnus-newsgroup-dormant)))
5166 ((numberp gnus-newsgroup-display)
5167 gnus-newsgroup-display)
5171 ((and (or (<= scored marked) (= scored number))
5172 (numberp gnus-large-newsgroup)
5173 (> number gnus-large-newsgroup))
5174 (let* ((cursor-in-echo-area nil)
5175 (initial (gnus-parameter-large-newsgroup-initial
5176 gnus-newsgroup-name))
5180 "How many articles from %s (%s %d): "
5182 (gnus-group-decoded-name gnus-newsgroup-name)
5184 (if initial "max" "default")
5187 (cons (number-to-string initial)
5189 (if (string-match "^[ \t]*$" input) number input)))
5190 ((and (> scored marked) (< scored number)
5191 (> (- scored number) 20))
5194 (format "%s %s (%d scored, %d total): "
5195 "How many articles from"
5196 (gnus-group-decoded-name group)
5198 (if (string-match "^[ \t]*$" input)
5202 (message "Quit getting the articles to read")
5204 (setq select (if (stringp select) (string-to-number select) select))
5205 (if (or (null select) (zerop select))
5207 (if (and (not (zerop scored)) (<= (abs select) scored))
5209 (setq articles (sort scored-list '<))
5210 (setq number (length articles)))
5211 (setq articles (copy-sequence articles)))
5213 (when (< (abs select) number)
5215 ;; Select the N oldest articles.
5216 (setcdr (nthcdr (1- (abs select)) articles) nil)
5217 ;; Select the N most recent articles.
5218 (setq articles (nthcdr (- number select) articles))))
5219 (setq gnus-newsgroup-unselected
5220 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5221 (when gnus-alter-articles-to-read-function
5224 (funcall gnus-alter-articles-to-read-function
5225 gnus-newsgroup-name articles)
5229 (defun gnus-killed-articles (killed articles)
5232 (when (inline (gnus-member-of-range (car articles) killed))
5233 (push (car articles) out))
5234 (setq articles (cdr articles)))
5237 (defun gnus-uncompress-marks (marks)
5238 "Uncompress the mark ranges in MARKS."
5239 (let ((uncompressed '(score bookmark))
5242 (if (memq (caar marks) uncompressed)
5243 (push (car marks) out)
5244 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5245 (setq marks (cdr marks)))
5248 (defun gnus-article-mark-to-type (mark)
5249 "Return the type of MARK."
5250 (or (cadr (assq mark gnus-article-special-mark-lists))
5253 (defun gnus-article-unpropagatable-p (mark)
5254 "Return whether MARK should be propagated to backend."
5255 (memq mark gnus-article-unpropagated-mark-lists))
5257 (defun gnus-adjust-marked-articles (info)
5258 "Set all article lists and remove all marks that are no longer valid."
5259 (let* ((marked-lists (gnus-info-marks info))
5260 (active (gnus-active (gnus-info-group info)))
5263 (types gnus-article-mark-lists)
5264 marks var articles article mark mark-type)
5266 (dolist (marks marked-lists)
5267 (setq mark (car marks)
5268 mark-type (gnus-article-mark-to-type mark)
5269 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5271 ;; We set the variable according to the type of the marks list,
5272 ;; and then adjust the marks to a subset of the active articles.
5274 ;; Adjust "simple" lists.
5275 ((eq mark-type 'list)
5276 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5277 (when (memq mark '(tick dormant expire reply save))
5279 (when (or (< (setq article (pop articles)) min) (> article max))
5280 (set var (delq article (symbol-value var)))))))
5282 ((eq mark-type 'tuple)
5283 (set var (setq articles (cdr marks)))
5284 (when (not (listp (cdr (symbol-value var))))
5285 (set var (list (symbol-value var))))
5286 (when (not (listp (cdr articles)))
5287 (setq articles (list articles)))
5289 (when (or (not (consp (setq article (pop articles))))
5290 (< (car article) min)
5291 (> (car article) max))
5292 (set var (delq article (symbol-value var))))))
5293 ;; Adjust ranges (sloppily).
5294 ((eq mark-type 'range)
5297 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5298 ;; It should be (seen (NUM1 . NUM2)).
5299 (when (numberp (cddr marks))
5300 (setcdr marks (list (cdr marks))))
5301 (setq articles (cdr marks))
5302 (while (and articles
5303 (or (and (consp (car articles))
5304 (> min (cdar articles)))
5305 (and (numberp (car articles))
5306 (> min (car articles)))))
5308 (set var articles))))))))
5310 (defun gnus-update-missing-marks (missing)
5311 "Go through the list of MISSING articles and remove them from the mark lists."
5314 ;; Go through all types.
5315 (dolist (elem gnus-article-mark-lists)
5316 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5317 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5318 (when (symbol-value var)
5319 ;; This list has articles. So we delete all missing
5320 ;; articles from it.
5323 (set var (delq (pop m) (symbol-value var))))))))))
5325 (defun gnus-update-marks ()
5326 "Enter the various lists of marked articles into the newsgroup info list."
5327 (let ((types gnus-article-mark-lists)
5328 (info (gnus-get-info gnus-newsgroup-name))
5329 type list newmarked symbol delta-marks)
5331 ;; Add all marks lists to the list of marks lists.
5332 (while (setq type (pop types))
5333 (setq list (symbol-value
5335 (intern (format "gnus-newsgroup-%s" (car type))))))
5338 ;; Get rid of the entries of the articles that have the
5340 (when (and (eq (cdr type) 'score)
5344 (prev (cons nil list))
5347 (if (or (not (consp (car arts)))
5348 (= (cdar arts) gnus-summary-default-score))
5349 (setcdr prev (cdr arts))
5351 (setq arts (cdr arts)))
5352 (setq list (cdr all)))))
5354 (when (eq (cdr type) 'seen)
5355 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5357 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5358 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5360 (when (and (gnus-check-backend-function
5361 'request-set-mark gnus-newsgroup-name)
5362 (not (gnus-article-unpropagatable-p (cdr type))))
5363 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5364 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5365 (add (gnus-remove-from-range
5366 (gnus-copy-sequence list) old)))
5368 (push (list add 'add (list (cdr type))) delta-marks))
5370 (push (list del 'del (list (cdr type))) delta-marks))))
5373 (push (cons (cdr type) list) newmarked)))
5376 (unless (gnus-check-group gnus-newsgroup-name)
5377 (error "Can't open server for %s" gnus-newsgroup-name))
5378 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5380 ;; Enter these new marks into the info of the group.
5382 (setcar (nthcdr 3 info) newmarked)
5383 ;; Add the marks lists to the end of the info.
5385 (setcdr (nthcdr 2 info) (list newmarked))))
5387 ;; Cut off the end of the info if there's nothing else there.
5391 (when (nthcdr (decf i) info)
5392 (setcdr (nthcdr i info) nil)))))))
5394 (defun gnus-set-mode-line (where)
5395 "Set the mode line of the article or summary buffers.
5396 If WHERE is `summary', the summary mode line format will be used."
5397 ;; Is this mode line one we keep updated?
5398 (when (and (memq where gnus-updated-mode-lines)
5400 (intern (format "gnus-%s-mode-line-format-spec" where))))
5403 ;; We evaluate this in the summary buffer since these
5404 ;; variables are buffer-local to that buffer.
5405 (set-buffer gnus-summary-buffer)
5406 ;; We bind all these variables that are used in the `eval' form
5408 (let* ((mformat (symbol-value
5410 (format "gnus-%s-mode-line-format-spec" where))))
5411 (gnus-tmp-group-name (gnus-group-decoded-name
5412 gnus-newsgroup-name))
5413 (gnus-tmp-article-number (or gnus-current-article 0))
5414 (gnus-tmp-unread gnus-newsgroup-unreads)
5415 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5416 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5417 (gnus-tmp-unread-and-unselected
5418 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5419 (zerop gnus-tmp-unselected))
5421 ((zerop gnus-tmp-unselected)
5422 (format "{%d more}" gnus-tmp-unread-and-unticked))
5423 (t (format "{%d(+%d) more}"
5424 gnus-tmp-unread-and-unticked
5425 gnus-tmp-unselected))))
5427 (if (and gnus-current-headers
5428 (vectorp gnus-current-headers))
5429 (gnus-mode-string-quote
5430 (mail-header-subject gnus-current-headers))
5432 bufname-length max-len
5433 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5434 (setq mode-string (eval mformat))
5435 (setq bufname-length (if (string-match "%b" mode-string)
5438 (if (eq where 'summary)
5440 (get-buffer gnus-article-buffer))))
5443 (setq max-len (max 4 (if gnus-mode-non-string-length
5445 gnus-mode-non-string-length
5447 (length mode-string))))
5448 ;; We might have to chop a bit of the string off...
5449 (when (> (length mode-string) max-len)
5451 (concat (truncate-string-to-width mode-string (- max-len 3))
5453 ;; Pad the mode string a bit.
5454 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5455 ;; Update the mode line.
5456 (setq mode-line-buffer-identification
5457 (gnus-mode-line-buffer-identification (list mode-string)))
5458 (set-buffer-modified-p t))))
5460 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5461 "Go through the HEADERS list and add all Xrefs to a hash table.
5462 The resulting hash table is returned, or nil if no Xrefs were found."
5463 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5464 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5465 (xref-hashtb (gnus-make-hashtable))
5466 start group entry number xrefs header)
5468 (setq header (pop headers))
5469 (when (and (setq xrefs (mail-header-xref header))
5470 (not (memq (setq number (mail-header-number header))
5473 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5474 (setq start (match-end 0))
5475 (setq group (if prefix
5476 (concat prefix (substring xrefs (match-beginning 1)
5478 (substring xrefs (match-beginning 1) (match-end 1))))
5480 (string-to-int (substring xrefs (match-beginning 2)
5482 (if (setq entry (gnus-gethash group xref-hashtb))
5483 (setcdr entry (cons number (cdr entry)))
5484 (gnus-sethash group (cons number nil) xref-hashtb)))))
5485 (and start xref-hashtb)))
5487 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5488 "Look through all the headers and mark the Xrefs as read."
5489 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5490 name entry info xref-hashtb idlist method nth4)
5492 (set-buffer gnus-group-buffer)
5493 (when (setq xref-hashtb
5494 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5497 (unless (string= from-newsgroup (setq name (symbol-name group)))
5498 (setq idlist (symbol-value group))
5499 ;; Dead groups are not updated.
5501 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5503 (when (stringp (setq nth4 (gnus-info-method info)))
5504 (setq nth4 (gnus-server-to-method nth4))))
5505 ;; Only do the xrefs if the group has the same
5506 ;; select method as the group we have just read.
5507 (or (gnus-methods-equal-p
5508 nth4 (gnus-find-method-for-group from-newsgroup))
5510 (equal nth4 (setq method (gnus-find-method-for-group
5512 (and (equal (car nth4) (car method))
5513 (equal (nth 1 nth4) (nth 1 method))))
5514 gnus-use-cross-reference
5515 (or (not (eq gnus-use-cross-reference t))
5517 ;; Only do cross-references on subscribed
5518 ;; groups, if that is what is wanted.
5519 (<= (gnus-info-level info) gnus-level-subscribed))
5520 (gnus-group-make-articles-read name idlist))))
5523 (defun gnus-compute-read-articles (group articles)
5524 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5525 (info (nth 2 entry))
5526 (active (gnus-active group))
5529 ;; First peel off all invalid article numbers.
5531 (let ((ids articles)
5533 (while (setq id (pop ids))
5534 (when (and first (> id (cdr active)))
5535 ;; We'll end up in this situation in one particular
5536 ;; obscure situation. If you re-scan a group and get
5537 ;; a new article that is cross-posted to a different
5538 ;; group that has not been re-scanned, you might get
5539 ;; crossposted article that has a higher number than
5540 ;; Gnus believes possible. So we re-activate this
5541 ;; group as well. This might mean doing the
5542 ;; crossposting thingy will *increase* the number
5543 ;; of articles in some groups. Tsk, tsk.
5544 (setq active (or (gnus-activate-group group) active)))
5545 (when (or (> id (cdr active))
5546 (< id (car active)))
5547 (setq articles (delq id articles))))))
5548 ;; If the read list is nil, we init it.
5550 (null (gnus-info-read info))
5552 (setq ninfo (cons 1 (1- (car active))))
5553 (setq ninfo (gnus-info-read info)))
5554 ;; Then we add the read articles to the range.
5556 ninfo (setq articles (sort articles '<))))))
5558 (defun gnus-group-make-articles-read (group articles)
5559 "Update the info of GROUP to say that ARTICLES are read."
5561 (entry (gnus-gethash group gnus-newsrc-hashtb))
5562 (info (nth 2 entry))
5563 (active (gnus-active group))
5566 (setq range (gnus-compute-read-articles group articles))
5568 (set-buffer gnus-group-buffer)
5571 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5572 (gnus-info-set-read ',info ',(gnus-info-read info))
5573 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5574 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5575 (gnus-group-update-group ,group t))))
5576 ;; Add the read articles to the range.
5577 (gnus-info-set-read info range)
5578 (gnus-request-set-mark group (list (list range 'add '(read))))
5579 ;; Then we have to re-compute how many unread
5580 ;; articles there are in this group.
5584 (setq num (- (1+ (cdr active)) (car active))))
5585 ((not (listp (cdr range)))
5586 (setq num (- (cdr active) (- (1+ (cdr range))
5590 (if (numberp (car range))
5592 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5593 (setq range (cdr range)))
5594 (setq num (- (cdr active) num))))
5595 ;; Update the number of unread articles.
5597 ;; Update the group buffer.
5598 (unless (gnus-ephemeral-group-p group)
5599 (gnus-group-update-group group t))))))
5601 (defvar gnus-newsgroup-none-id 0)
5603 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5604 (let ((cur nntp-server-buffer)
5607 (save-excursion (set-buffer gnus-summary-buffer)
5608 gnus-newsgroup-dependencies)))
5610 (mail-parse-charset gnus-newsgroup-charset)
5611 (mail-parse-ignored-charsets
5612 (save-excursion (condition-case nil
5613 (set-buffer gnus-summary-buffer)
5615 gnus-newsgroup-ignored-charsets)))
5617 (set-buffer nntp-server-buffer)
5618 ;; Translate all TAB characters into SPACE characters.
5619 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5620 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5621 (gnus-run-hooks 'gnus-parse-headers-hook)
5622 (let ((case-fold-search t)
5623 in-reply-to header p lines chars)
5624 (goto-char (point-min))
5625 ;; Search to the beginning of the next header. Error messages
5626 ;; do not begin with 2 or 3.
5627 (while (re-search-forward "^[23][0-9]+ " nil t)
5630 ;; This implementation of this function, with nine
5631 ;; search-forwards instead of the one re-search-forward and
5632 ;; a case (which basically was the old function) is actually
5633 ;; about twice as fast, even though it looks messier. You
5634 ;; can't have everything, I guess. Speed and elegance
5635 ;; doesn't always go hand in hand.
5644 (narrow-to-region (point)
5645 (or (and (search-forward "\n.\n" nil t)
5651 (if (search-forward "\nsubject:" nil t)
5652 (funcall gnus-decode-encoded-word-function
5653 (nnheader-header-value))
5658 (if (search-forward "\nfrom:" nil t)
5659 (funcall gnus-decode-encoded-word-function
5660 (nnheader-header-value))
5665 (if (search-forward "\ndate:" nil t)
5666 (nnheader-header-value) ""))
5670 (setq id (if (re-search-forward
5671 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5672 ;; We do it this way to make sure the Message-ID
5673 ;; is (somewhat) syntactically valid.
5674 (buffer-substring (match-beginning 1)
5676 ;; If there was no message-id, we just fake one
5677 ;; to make subsequent routines simpler.
5678 (nnheader-generate-fake-message-id))))
5682 (if (search-forward "\nreferences:" nil t)
5686 (nnheader-header-value)
5691 (search-backward ">" end t)
5694 (search-backward "<" end t)
5696 ;; Get the references from the in-reply-to header if there
5697 ;; were no references and the in-reply-to header looks
5699 (if (and (search-forward "\nin-reply-to:" nil t)
5700 (setq in-reply-to (nnheader-header-value))
5701 (string-match "<[^>]+>" in-reply-to))
5703 (setq ref (substring in-reply-to (match-beginning 0)
5705 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5706 (setq ref2 (substring in-reply-to (match-beginning 0)
5708 (when (> (length ref2) (length ref))
5715 (if (search-forward "\nchars: " nil t)
5716 (if (numberp (setq chars (ignore-errors (read cur))))
5722 (if (search-forward "\nlines: " nil t)
5723 (if (numberp (setq lines (ignore-errors (read cur))))
5729 (and (search-forward "\nxref:" nil t)
5730 (nnheader-header-value)))
5732 (when gnus-extra-headers
5733 (let ((extra gnus-extra-headers)
5737 (when (search-forward
5738 (concat "\n" (symbol-name (car extra)) ":") nil t)
5739 (push (cons (car extra) (nnheader-header-value))
5743 (when (equal id ref)
5746 (when gnus-alter-header-function
5747 (funcall gnus-alter-header-function header)
5748 (setq id (mail-header-id header)
5749 ref (gnus-parent-id (mail-header-references header))))
5752 (gnus-dependencies-add-header
5753 header dependencies force-new))
5754 (push header headers))
5755 (goto-char (point-max))
5757 (nreverse headers)))))
5759 ;; Goes through the xover lines and returns a list of vectors
5760 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5761 force-new dependencies
5762 group also-fetch-heads)
5763 "Parse the news overview data in the server buffer.
5764 Return a list of headers that match SEQUENCE (see
5765 `nntp-retrieve-headers')."
5766 ;; Get the Xref when the users reads the articles since most/some
5767 ;; NNTP servers do not include Xrefs when using XOVER.
5768 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5769 (let ((mail-parse-charset gnus-newsgroup-charset)
5770 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5771 (cur nntp-server-buffer)
5772 (dependencies (or dependencies gnus-newsgroup-dependencies))
5774 ((eq gnus-read-all-available-headers t)
5776 ((stringp gnus-read-all-available-headers)
5777 (string-match gnus-read-all-available-headers group))
5780 number headers header)
5782 (set-buffer nntp-server-buffer)
5783 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5784 ;; Allow the user to mangle the headers before parsing them.
5785 (gnus-run-hooks 'gnus-parse-headers-hook)
5786 (goto-char (point-min))
5787 (gnus-parse-without-error
5788 (while (and (or sequence allp)
5790 (setq number (read cur))
5792 (while (and sequence
5793 (< (car sequence) number))
5794 (setq sequence (cdr sequence))))
5797 (eq number (car sequence))))
5799 (setq sequence (cdr sequence))
5800 (setq header (inline
5801 (gnus-nov-parse-line
5802 number dependencies force-new)))))
5803 (push header headers))
5805 ;; A common bug in inn is that if you have posted an article and
5806 ;; then retrieves the active file, it will answer correctly --
5807 ;; the new article is included. However, a NOV entry for the
5808 ;; article may not have been generated yet, so this may fail.
5809 ;; We work around this problem by retrieving the last few
5810 ;; headers using HEAD.
5811 (if (or (not also-fetch-heads)
5813 ;; We (probably) got all the headers.
5815 (let ((gnus-nov-is-evil t))
5818 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5819 (gnus-get-newsgroup-headers))))))))
5821 (defun gnus-article-get-xrefs ()
5822 "Fill in the Xref value in `gnus-current-headers', if necessary.
5823 This is meant to be called in `gnus-article-internal-prepare-hook'."
5824 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5825 gnus-current-headers)))
5826 (or (not gnus-use-cross-reference)
5828 (and (mail-header-xref headers)
5829 (not (string= (mail-header-xref headers) "")))
5830 (let ((case-fold-search t)
5833 (nnheader-narrow-to-headers)
5834 (goto-char (point-min))
5835 (when (or (and (not (eobp))
5836 (eq (downcase (char-after)) ?x)
5837 (looking-at "Xref:"))
5838 (search-forward "\nXref:" nil t))
5839 (goto-char (1+ (match-end 0)))
5840 (setq xref (buffer-substring (point)
5841 (progn (end-of-line) (point))))
5842 (mail-header-set-xref headers xref)))))))
5844 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5845 "Find article ID and insert the summary line for that article.
5846 OLD-HEADER can either be a header or a line number to insert
5847 the subject line on."
5848 (let* ((line (and (numberp old-header) old-header))
5849 (old-header (and (vectorp old-header) old-header))
5850 (header (cond ((and old-header use-old-header)
5853 (gnus-number-to-header id))
5854 (gnus-number-to-header id))
5856 (gnus-read-header id))))
5857 (number (and (numberp id) id))
5860 ;; Rebuild the thread that this article is part of and go to the
5861 ;; article we have fetched.
5862 (when (and (not gnus-show-threads)
5865 (setq d (gnus-data-find (mail-header-number old-header))))
5866 (goto-char (gnus-data-pos d))
5869 (- (gnus-point-at-bol)
5871 (1+ (gnus-point-at-eol))
5872 (gnus-delete-line))))))
5874 (mail-header-set-number header (mail-header-number old-header)))
5875 (setq gnus-newsgroup-sparse
5876 (delq (setq number (mail-header-number header))
5877 gnus-newsgroup-sparse))
5878 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5879 (push number gnus-newsgroup-limit)
5880 (gnus-rebuild-thread (mail-header-id header) line)
5881 (gnus-summary-goto-subject number nil t))
5882 (when (and (numberp number)
5884 ;; We have to update the boundaries even if we can't fetch the
5885 ;; article if ID is a number -- so that the next `P' or `N'
5886 ;; command will fetch the previous (or next) article even
5887 ;; if the one we tried to fetch this time has been canceled.
5888 (when (> number gnus-newsgroup-end)
5889 (setq gnus-newsgroup-end number))
5890 (when (< number gnus-newsgroup-begin)
5891 (setq gnus-newsgroup-begin number))
5892 (setq gnus-newsgroup-unselected
5893 (delq number gnus-newsgroup-unselected)))
5894 ;; Report back a success?
5895 (and header (mail-header-number header))))
5897 ;;; Process/prefix in the summary buffer
5899 (defun gnus-summary-work-articles (n)
5900 "Return a list of articles to be worked upon.
5901 The prefix argument, the list of process marked articles, and the
5902 current article will be taken into consideration."
5904 (set-buffer gnus-summary-buffer)
5907 ;; A numerical prefix has been given.
5908 (setq n (prefix-numeric-value n))
5909 (let ((backward (< n 0))
5910 (n (abs (prefix-numeric-value n)))
5915 (push (setq article (gnus-summary-article-number))
5918 (gnus-summary-find-prev nil article)
5919 (gnus-summary-find-next nil article)))
5921 (nreverse articles)))
5922 ((and (gnus-region-active-p) (mark))
5923 (message "region active")
5924 ;; Work on the region between point and mark.
5925 (let ((max (max (point) (mark)))
5928 (goto-char (min (min (point) (mark))))
5931 (push (setq article (gnus-summary-article-number)) articles)
5932 (gnus-summary-find-next nil article)
5934 (nreverse articles))))
5935 (gnus-newsgroup-processable
5936 ;; There are process-marked articles present.
5937 ;; Save current state.
5938 (gnus-summary-save-process-mark)
5940 (reverse gnus-newsgroup-processable))
5942 ;; Just return the current article.
5943 (list (gnus-summary-article-number))))))
5945 (defmacro gnus-summary-iterate (arg &rest forms)
5946 "Iterate over the process/prefixed articles and do FORMS.
5947 ARG is the interactive prefix given to the command. FORMS will be
5948 executed with point over the summary line of the articles."
5949 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5950 `(let ((,articles (gnus-summary-work-articles ,arg)))
5952 (gnus-summary-goto-subject (car ,articles))
5956 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5957 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5959 (defun gnus-summary-save-process-mark ()
5960 "Push the current set of process marked articles on the stack."
5962 (push (copy-sequence gnus-newsgroup-processable)
5963 gnus-newsgroup-process-stack))
5965 (defun gnus-summary-kill-process-mark ()
5966 "Push the current set of process marked articles on the stack and unmark."
5968 (gnus-summary-save-process-mark)
5969 (gnus-summary-unmark-all-processable))
5971 (defun gnus-summary-yank-process-mark ()
5972 "Pop the last process mark state off the stack and restore it."
5974 (unless gnus-newsgroup-process-stack
5975 (error "Empty mark stack"))
5976 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5978 (defun gnus-summary-process-mark-set (set)
5979 "Make SET into the current process marked articles."
5980 (gnus-summary-unmark-all-processable)
5982 (gnus-summary-set-process-mark (pop set))))
5984 ;;; Searching and stuff
5986 (defun gnus-summary-search-group (&optional backward use-level)
5987 "Search for next unread newsgroup.
5988 If optional argument BACKWARD is non-nil, search backward instead."
5990 (set-buffer gnus-group-buffer)
5991 (when (gnus-group-search-forward
5992 backward nil (if use-level (gnus-group-group-level) nil))
5993 (gnus-group-group-name))))
5995 (defun gnus-summary-best-group (&optional exclude-group)
5996 "Find the name of the best unread group.
5997 If EXCLUDE-GROUP, do not go to this group."
5999 (set-buffer gnus-group-buffer)
6001 (gnus-group-best-unread-group exclude-group))))
6003 (defun gnus-summary-find-next (&optional unread article backward)
6004 (if backward (gnus-summary-find-prev)
6005 (let* ((dummy (gnus-summary-article-intangible-p))
6006 (article (or article (gnus-summary-article-number)))
6007 (data (gnus-data-find-list article))
6009 (when (and (not dummy)
6010 (or (not gnus-summary-check-current)
6012 (not (gnus-data-unread-p (car data)))))
6013 (setq data (cdr data)))
6018 (unless (memq (gnus-data-number (car data))
6019 gnus-newsgroup-unfetched)
6020 (when (gnus-data-unread-p (car data))
6021 (setq result (car data)
6023 (setq data (cdr data)))
6026 (goto-char (gnus-data-pos result))
6027 (gnus-data-number result)))))
6029 (defun gnus-summary-find-prev (&optional unread article)
6030 (let* ((eobp (eobp))
6031 (article (or article (gnus-summary-article-number)))
6032 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6034 (when (and (not eobp)
6035 (or (not gnus-summary-check-current)
6037 (not (gnus-data-unread-p (car data)))))
6038 (setq data (cdr data)))
6043 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6044 (when (gnus-data-unread-p (car data))
6045 (setq result (car data)
6047 (setq data (cdr data)))
6050 (goto-char (gnus-data-pos result))
6051 (gnus-data-number result))))
6053 (defun gnus-summary-find-subject (subject &optional unread backward article)
6054 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6055 (article (or article (gnus-summary-article-number)))
6056 (articles (gnus-data-list backward))
6057 (arts (gnus-data-find-list article articles))
6059 (when (or (not gnus-summary-check-current)
6061 (not (gnus-data-unread-p (car arts))))
6062 (setq arts (cdr arts)))
6064 (and (or (not unread)
6065 (gnus-data-unread-p (car arts)))
6066 (vectorp (gnus-data-header (car arts)))
6068 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6069 (setq result (car arts)
6071 (setq arts (cdr arts)))
6073 (goto-char (gnus-data-pos result))
6074 (gnus-data-number result))))
6076 (defun gnus-summary-search-forward (&optional unread subject backward)
6077 "Search forward for an article.
6078 If UNREAD, look for unread articles. If SUBJECT, look for
6079 articles with that subject. If BACKWARD, search backward instead."
6080 (cond (subject (gnus-summary-find-subject subject unread backward))
6081 (backward (gnus-summary-find-prev unread))
6082 (t (gnus-summary-find-next unread))))
6084 (defun gnus-recenter (&optional n)
6085 "Center point in window and redisplay frame.
6086 Also do horizontal recentering."
6088 (when (and gnus-auto-center-summary
6089 (not (eq gnus-auto-center-summary 'vertical)))
6090 (gnus-horizontal-recenter))
6093 (defun gnus-summary-recenter ()
6094 "Center point in the summary window.
6095 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6096 displayed, no centering will be performed."
6097 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6098 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6100 (let* ((top (cond ((< (window-height) 4) 0)
6101 ((< (window-height) 7) 1)
6102 (t (if (numberp gnus-auto-center-summary)
6103 gnus-auto-center-summary
6105 (height (1- (window-height)))
6106 (bottom (save-excursion (goto-char (point-max))
6107 (forward-line (- height))
6109 (window (get-buffer-window (current-buffer))))
6110 ;; The user has to want it.
6111 (when gnus-auto-center-summary
6112 (when (get-buffer-window gnus-article-buffer)
6113 ;; Only do recentering when the article buffer is displayed,
6114 ;; Set the window start to either `bottom', which is the biggest
6115 ;; possible valid number, or the second line from the top,
6116 ;; whichever is the least.
6117 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6118 (if (> bottom top-pos)
6119 ;; Keep the second line from the top visible
6120 (set-window-start window top-pos t)
6121 ;; Try to keep the bottom line visible; if it's partially
6122 ;; obscured, either scroll one more line to make it fully
6123 ;; visible, or revert to using TOP-POS.
6125 (goto-char (point-max))
6127 (let ((last-line-start (point)))
6129 (set-window-start window (point) t)
6130 (when (not (pos-visible-in-window-p last-line-start window))
6132 (set-window-start window (min (point) top-pos) t)))))))
6133 ;; Do horizontal recentering while we're at it.
6134 (when (and (get-buffer-window (current-buffer) t)
6135 (not (eq gnus-auto-center-summary 'vertical)))
6136 (let ((selected (selected-window)))
6137 (select-window (get-buffer-window (current-buffer) t))
6138 (gnus-summary-position-point)
6139 (gnus-horizontal-recenter)
6140 (select-window selected))))))
6142 (defun gnus-summary-jump-to-group (newsgroup)
6143 "Move point to NEWSGROUP in group mode buffer."
6144 ;; Keep update point of group mode buffer if visible.
6145 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6146 (save-window-excursion
6147 ;; Take care of tree window mode.
6148 (when (get-buffer-window gnus-group-buffer)
6149 (pop-to-buffer gnus-group-buffer))
6150 (gnus-group-jump-to-group newsgroup))
6152 ;; Take care of tree window mode.
6153 (if (get-buffer-window gnus-group-buffer)
6154 (pop-to-buffer gnus-group-buffer)
6155 (set-buffer gnus-group-buffer))
6156 (gnus-group-jump-to-group newsgroup))))
6158 ;; This function returns a list of article numbers based on the
6159 ;; difference between the ranges of read articles in this group and
6160 ;; the range of active articles.
6161 (defun gnus-list-of-unread-articles (group)
6162 (let* ((read (gnus-info-read (gnus-get-info group)))
6163 (active (or (gnus-active group) (gnus-activate-group group)))
6166 ;; If none are read, then all are unread.
6168 (setq first (car active))
6169 ;; If the range of read articles is a single range, then the
6170 ;; first unread article is the article after the last read
6171 ;; article. Sounds logical, doesn't it?
6172 (if (and (not (listp (cdr read)))
6173 (or (< (car read) (car active))
6174 (progn (setq read (list read))
6176 (setq first (max (car active) (1+ (cdr read))))
6177 ;; `read' is a list of ranges.
6178 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6181 (setq first (car active)))
6184 (while (< first nlast)
6186 (setq first (1+ first))))
6187 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6188 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6189 (setq read (cdr read)))))
6190 ;; And add the last unread articles.
6191 (while (<= first last)
6193 (setq first (1+ first)))
6194 ;; Return the list of unread articles.
6195 (delq 0 (nreverse unread))))
6197 (defun gnus-list-of-read-articles (group)
6198 "Return a list of unread, unticked and non-dormant articles."
6199 (let* ((info (gnus-get-info group))
6200 (marked (gnus-info-marks info))
6201 (active (gnus-active group)))
6203 (gnus-list-range-difference
6204 (gnus-list-range-difference
6205 (gnus-sorted-complement
6206 (gnus-uncompress-range active)
6207 (gnus-list-of-unread-articles group))
6208 (cdr (assq 'dormant marked)))
6209 (cdr (assq 'tick marked))))))
6211 ;; Various summary commands
6213 (defun gnus-summary-select-article-buffer ()
6214 "Reconfigure windows to show article buffer."
6216 (if (not (gnus-buffer-live-p gnus-article-buffer))
6217 (error "There is no article buffer for this summary buffer")
6218 (gnus-configure-windows 'article)
6219 (select-window (get-buffer-window gnus-article-buffer))))
6221 (defun gnus-summary-universal-argument (arg)
6222 "Perform any operation on all articles that are process/prefixed."
6224 (let ((articles (gnus-summary-work-articles arg))
6231 (substitute-command-keys
6232 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6234 (gnus-error 1 "Undefined key")
6237 (gnus-summary-goto-subject (setq article (pop articles)))
6238 (let (gnus-newsgroup-processable)
6239 (command-execute func))
6240 (gnus-summary-remove-process-mark article)))))
6241 (gnus-summary-position-point))
6243 (defun gnus-summary-toggle-truncation (&optional arg)
6244 "Toggle truncation of summary lines.
6245 With arg, turn line truncation on if arg is positive."
6247 (setq truncate-lines
6248 (if (null arg) (not truncate-lines)
6249 (> (prefix-numeric-value arg) 0)))
6252 (defun gnus-summary-find-uncancelled ()
6253 "Return the number of an uncancelled article.
6254 The current article is considered, then following articles, then previous
6255 articles. If all articles are cancelled then return a dummy 0."
6257 (dolist (rev '(nil t))
6258 (unless found ; don't demand the reverse list if we don't need it
6259 (let ((data (gnus-data-find-list
6260 (gnus-summary-article-number) (gnus-data-list rev))))
6261 (while (and data (not found))
6262 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6263 (setq found (gnus-data-number (car data))))
6264 (setq data (cdr data))))))
6267 (defun gnus-summary-reselect-current-group (&optional all rescan)
6268 "Exit and then reselect the current newsgroup.
6269 The prefix argument ALL means to select all articles."
6271 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6272 (error "Ephemeral groups can't be reselected"))
6273 (let ((current-subject (gnus-summary-find-uncancelled))
6274 (group gnus-newsgroup-name))
6275 (setq gnus-newsgroup-begin nil)
6277 ;; We have to adjust the point of group mode buffer because
6278 ;; point was moved to the next unread newsgroup by exiting.
6279 (gnus-summary-jump-to-group group)
6282 (gnus-group-get-new-news-this-group 1)))
6283 (gnus-group-read-group all t)
6284 (gnus-summary-goto-subject current-subject nil t)))
6286 (defun gnus-summary-rescan-group (&optional all)
6287 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6289 (gnus-summary-reselect-current-group all t))
6291 (defun gnus-summary-update-info (&optional non-destructive)
6293 (let ((group gnus-newsgroup-name))
6295 (when gnus-newsgroup-kill-headers
6296 (setq gnus-newsgroup-killed
6297 (gnus-compress-sequence
6299 (gnus-list-range-intersection
6300 gnus-newsgroup-unselected gnus-newsgroup-killed)
6301 gnus-newsgroup-unreads)
6303 (unless (listp (cdr gnus-newsgroup-killed))
6304 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6305 (let ((headers gnus-newsgroup-headers))
6306 ;; Set the new ranges of read articles.
6308 (set-buffer gnus-group-buffer)
6309 (gnus-undo-force-boundary))
6310 (gnus-update-read-articles
6311 group (gnus-sorted-union
6312 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6313 ;; Set the current article marks.
6314 (let ((gnus-newsgroup-scored
6315 (if (and (not gnus-save-score)
6316 (not non-destructive))
6318 gnus-newsgroup-scored)))
6320 (gnus-update-marks)))
6321 ;; Do the cross-ref thing.
6322 (when gnus-use-cross-reference
6323 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6324 ;; Do not switch windows but change the buffer to work.
6325 (set-buffer gnus-group-buffer)
6326 (unless (gnus-ephemeral-group-p group)
6327 (gnus-group-update-group group)))))))
6329 (defun gnus-summary-save-newsrc (&optional force)
6330 "Save the current number of read/marked articles in the dribble buffer.
6331 The dribble buffer will then be saved.
6332 If FORCE (the prefix), also save the .newsrc file(s)."
6334 (gnus-summary-update-info t)
6336 (gnus-save-newsrc-file)
6337 (gnus-dribble-save)))
6339 (defun gnus-summary-exit (&optional temporary)
6340 "Exit reading current newsgroup, and then return to group selection mode.
6341 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6343 (gnus-set-global-variables)
6344 (when (gnus-buffer-live-p gnus-article-buffer)
6346 (set-buffer gnus-article-buffer)
6347 (mm-destroy-parts gnus-article-mime-handles)
6348 ;; Set it to nil for safety reason.
6349 (setq gnus-article-mime-handle-alist nil)
6350 (setq gnus-article-mime-handles nil)))
6351 (gnus-kill-save-kill-buffer)
6352 (gnus-async-halt-prefetch)
6353 (let* ((group gnus-newsgroup-name)
6354 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6355 (gnus-group-is-exiting-p t)
6358 (buf (current-buffer)))
6360 ;; Do adaptive scoring, and possibly save score files.
6361 (when gnus-newsgroup-adaptive
6362 (gnus-score-adaptive))
6363 (when gnus-use-scoring
6365 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6366 ;; If we have several article buffers, we kill them at exit.
6367 (unless gnus-single-article-buffer
6368 (gnus-kill-buffer gnus-original-article-buffer)
6369 (setq gnus-article-current nil))
6370 (when gnus-use-cache
6371 (gnus-cache-possibly-remove-articles)
6372 (gnus-cache-save-buffers))
6373 (gnus-async-prefetch-remove-group group)
6374 (when gnus-suppress-duplicates
6375 (gnus-dup-enter-articles))
6376 (when gnus-use-trees
6377 (gnus-tree-close group))
6378 (when gnus-use-cache
6379 (gnus-cache-write-active))
6380 ;; Remove entries for this group.
6381 (nnmail-purge-split-history (gnus-group-real-name group))
6382 ;; Make all changes in this group permanent.
6384 (gnus-run-hooks 'gnus-exit-group-hook)
6385 (gnus-summary-update-info))
6386 (gnus-close-group group)
6387 ;; Make sure where we were, and go to next newsgroup.
6388 (set-buffer gnus-group-buffer)
6390 (gnus-group-jump-to-group group))
6391 (gnus-run-hooks 'gnus-summary-exit-hook)
6392 (unless (or quit-config
6393 ;; If this group has disappeared from the summary
6394 ;; buffer, don't skip forwards.
6395 (not (string= group (gnus-group-group-name))))
6396 (gnus-group-next-unread-group 1))
6397 (setq group-point (point))
6400 ;; If we have several article buffers, we kill them at exit.
6401 (unless gnus-single-article-buffer
6402 (gnus-kill-buffer gnus-article-buffer)
6403 (gnus-kill-buffer gnus-original-article-buffer)
6404 (setq gnus-article-current nil))
6406 (if (not gnus-kill-summary-on-exit)
6408 (gnus-deaden-summary)
6410 ;; We set all buffer-local variables to nil. It is unclear why
6411 ;; this is needed, but if we don't, buffer-local variables are
6412 ;; not garbage-collected, it seems. This would the lead to en
6413 ;; ever-growing Emacs.
6414 (gnus-summary-clear-local-variables)
6415 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6416 (gnus-summary-clear-local-variables))
6417 (when (get-buffer gnus-article-buffer)
6418 (bury-buffer gnus-article-buffer))
6419 ;; We clear the global counterparts of the buffer-local
6420 ;; variables as well, just to be on the safe side.
6421 (set-buffer gnus-group-buffer)
6422 (gnus-summary-clear-local-variables)
6423 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6424 (gnus-summary-clear-local-variables))
6425 ;; Return to group mode buffer.
6426 (when (eq mode 'gnus-summary-mode)
6427 (gnus-kill-buffer buf)))
6428 (setq gnus-current-select-method gnus-select-method)
6429 (pop-to-buffer gnus-group-buffer)
6430 (if (not quit-config)
6432 (goto-char group-point)
6433 (gnus-configure-windows 'group 'force))
6434 (gnus-handle-ephemeral-exit quit-config))
6435 ;; Clear the current group name.
6437 (setq gnus-newsgroup-name nil)))))
6439 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6440 (defun gnus-summary-exit-no-update (&optional no-questions)
6441 "Quit reading current newsgroup without updating read article info."
6443 (let* ((group gnus-newsgroup-name)
6444 (gnus-group-is-exiting-p t)
6445 (quit-config (gnus-group-quit-config group)))
6446 (when (or no-questions
6448 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6449 (gnus-async-halt-prefetch)
6451 (delq 'gnus-summary-expire-articles
6452 (copy-sequence gnus-summary-prepare-exit-hook)))
6453 (when (gnus-buffer-live-p gnus-article-buffer)
6455 (set-buffer gnus-article-buffer)
6456 (mm-destroy-parts gnus-article-mime-handles)
6457 ;; Set it to nil for safety reason.
6458 (setq gnus-article-mime-handle-alist nil)
6459 (setq gnus-article-mime-handles nil)))
6460 ;; If we have several article buffers, we kill them at exit.
6461 (unless gnus-single-article-buffer
6462 (gnus-kill-buffer gnus-article-buffer)
6463 (gnus-kill-buffer gnus-original-article-buffer)
6464 (setq gnus-article-current nil))
6465 (if (not gnus-kill-summary-on-exit)
6466 (gnus-deaden-summary)
6467 (gnus-close-group group)
6468 (gnus-summary-clear-local-variables)
6469 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6470 (gnus-summary-clear-local-variables))
6471 (set-buffer gnus-group-buffer)
6472 (gnus-summary-clear-local-variables)
6473 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6474 (gnus-summary-clear-local-variables))
6475 (when (get-buffer gnus-summary-buffer)
6476 (kill-buffer gnus-summary-buffer)))
6477 (unless gnus-single-article-buffer
6478 (setq gnus-article-current nil))
6479 (when gnus-use-trees
6480 (gnus-tree-close group))
6481 (gnus-async-prefetch-remove-group group)
6482 (when (get-buffer gnus-article-buffer)
6483 (bury-buffer gnus-article-buffer))
6484 ;; Return to the group buffer.
6485 (gnus-configure-windows 'group 'force)
6486 ;; Clear the current group name.
6487 (setq gnus-newsgroup-name nil)
6488 (unless (gnus-ephemeral-group-p group)
6489 (gnus-group-update-group group))
6490 (when (equal (gnus-group-group-name) group)
6491 (gnus-group-next-unread-group 1))
6493 (gnus-handle-ephemeral-exit quit-config)))))
6495 (defun gnus-handle-ephemeral-exit (quit-config)
6496 "Handle movement when leaving an ephemeral group.
6497 The state which existed when entering the ephemeral is reset."
6498 (if (not (buffer-name (car quit-config)))
6499 (gnus-configure-windows 'group 'force)
6500 (set-buffer (car quit-config))
6501 (cond ((eq major-mode 'gnus-summary-mode)
6502 (gnus-set-global-variables))
6503 ((eq major-mode 'gnus-article-mode)
6505 ;; The `gnus-summary-buffer' variable may point
6506 ;; to the old summary buffer when using a single
6508 (unless (gnus-buffer-live-p gnus-summary-buffer)
6509 (set-buffer gnus-group-buffer))
6510 (set-buffer gnus-summary-buffer)
6511 (gnus-set-global-variables))))
6512 (if (or (eq (cdr quit-config) 'article)
6513 (eq (cdr quit-config) 'pick))
6515 ;; The current article may be from the ephemeral group
6516 ;; thus it is best that we reload this article
6517 (gnus-summary-show-article)
6518 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6519 (gnus-configure-windows 'pick 'force)
6520 (gnus-configure-windows (cdr quit-config) 'force)))
6521 (gnus-configure-windows (cdr quit-config) 'force))
6522 (when (eq major-mode 'gnus-summary-mode)
6523 (gnus-summary-next-subject 1 nil t)
6524 (gnus-summary-recenter)
6525 (gnus-summary-position-point))))
6529 (defvar gnus-dead-summary-mode-map nil)
6531 (unless gnus-dead-summary-mode-map
6532 (setq gnus-dead-summary-mode-map (make-keymap))
6533 (suppress-keymap gnus-dead-summary-mode-map)
6534 (substitute-key-definition
6535 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6536 (dolist (key '("\C-d" "\r" "\177" [delete]))
6537 (define-key gnus-dead-summary-mode-map
6538 key 'gnus-summary-wake-up-the-dead))
6539 (dolist (key '("q" "Q"))
6540 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6542 (defvar gnus-dead-summary-mode nil
6543 "Minor mode for Gnus summary buffers.")
6545 (defun gnus-dead-summary-mode (&optional arg)
6546 "Minor mode for Gnus summary buffers."
6548 (when (eq major-mode 'gnus-summary-mode)
6549 (make-local-variable 'gnus-dead-summary-mode)
6550 (setq gnus-dead-summary-mode
6551 (if (null arg) (not gnus-dead-summary-mode)
6552 (> (prefix-numeric-value arg) 0)))
6553 (when gnus-dead-summary-mode
6554 (gnus-add-minor-mode
6555 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6557 (defun gnus-deaden-summary ()
6558 "Make the current summary buffer into a dead summary buffer."
6559 ;; Kill any previous dead summary buffer.
6560 (when (and gnus-dead-summary
6561 (buffer-name gnus-dead-summary))
6563 (set-buffer gnus-dead-summary)
6564 (when gnus-dead-summary-mode
6565 (kill-buffer (current-buffer)))))
6566 ;; Make this the current dead summary.
6567 (setq gnus-dead-summary (current-buffer))
6568 (gnus-dead-summary-mode 1)
6569 (let ((name (buffer-name)))
6570 (when (string-match "Summary" name)
6572 (concat (substring name 0 (match-beginning 0)) "Dead "
6573 (substring name (match-beginning 0)))
6577 (defun gnus-kill-or-deaden-summary (buffer)
6578 "Kill or deaden the summary BUFFER."
6580 (when (and (buffer-name buffer)
6581 (not gnus-single-article-buffer))
6584 (gnus-kill-buffer gnus-article-buffer)
6585 (gnus-kill-buffer gnus-original-article-buffer)))
6588 (gnus-kill-summary-on-exit
6589 (when (and gnus-use-trees
6590 (gnus-buffer-exists-p buffer))
6593 (gnus-tree-close gnus-newsgroup-name)))
6594 (gnus-kill-buffer buffer))
6595 ;; Deaden the buffer.
6596 ((gnus-buffer-exists-p buffer)
6599 (gnus-deaden-summary))))))
6601 (defun gnus-summary-wake-up-the-dead (&rest args)
6602 "Wake up the dead summary buffer."
6604 (gnus-dead-summary-mode -1)
6605 (let ((name (buffer-name)))
6606 (when (string-match "Dead " name)
6608 (concat (substring name 0 (match-beginning 0))
6609 (substring name (match-end 0)))
6611 (gnus-message 3 "This dead summary is now alive again"))
6613 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6614 (defun gnus-summary-fetch-faq (&optional faq-dir)
6615 "Fetch the FAQ for the current group.
6616 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6620 (when current-prefix-arg
6622 "FAQ dir: " (and (listp gnus-group-faq-directory)
6623 (mapcar (lambda (file) (list file))
6624 gnus-group-faq-directory))))))
6625 (let (gnus-faq-buffer)
6626 (when (setq gnus-faq-buffer
6627 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6628 (gnus-configure-windows 'summary-faq))))
6630 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6631 (defun gnus-summary-describe-group (&optional force)
6632 "Describe the current newsgroup."
6634 (gnus-group-describe-group force gnus-newsgroup-name))
6636 (defun gnus-summary-describe-briefly ()
6637 "Describe summary mode commands briefly."
6639 (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")))
6641 ;; Walking around group mode buffer from summary mode.
6643 (defun gnus-summary-next-group (&optional no-article target-group backward)
6644 "Exit current newsgroup and then select next unread newsgroup.
6645 If prefix argument NO-ARTICLE is non-nil, no article is selected
6646 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6647 previous group instead."
6649 ;; Stop pre-fetching.
6650 (gnus-async-halt-prefetch)
6651 (let ((current-group gnus-newsgroup-name)
6652 (current-buffer (current-buffer))
6654 (while (not entered)
6655 ;; Then we find what group we are supposed to enter.
6656 (set-buffer gnus-group-buffer)
6657 (gnus-group-jump-to-group current-group)
6660 (if (eq gnus-keep-same-level 'best)
6661 (gnus-summary-best-group gnus-newsgroup-name)
6662 (gnus-summary-search-group backward gnus-keep-same-level))))
6663 (if (not target-group)
6664 ;; There are no further groups, so we return to the group
6667 (gnus-message 5 "Returning to the group buffer")
6669 (when (gnus-buffer-live-p current-buffer)
6670 (set-buffer current-buffer)
6671 (gnus-summary-exit))
6672 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6673 ;; We try to enter the target group.
6674 (gnus-group-jump-to-group target-group)
6675 (let ((unreads (gnus-group-group-unread)))
6676 (if (and (or (eq t unreads)
6677 (and unreads (not (zerop unreads))))
6679 ;; Now we semi-exit this group to update Xrefs
6680 ;; and all variables. We can't do a real exit,
6681 ;; because the window conf must remain the same
6682 ;; in case the user is prompted for info, and we
6683 ;; don't want the window conf to change before
6685 (when (gnus-buffer-live-p current-buffer)
6686 (set-buffer current-buffer)
6687 (gnus-summary-exit t))
6688 (gnus-summary-read-group
6689 target-group nil no-article
6690 (and (buffer-name current-buffer) current-buffer)
6693 (setq current-group target-group
6694 target-group nil)))))))
6696 (defun gnus-summary-prev-group (&optional no-article)
6697 "Exit current newsgroup and then select previous unread newsgroup.
6698 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6700 (gnus-summary-next-group no-article nil t))
6702 ;; Walking around summary lines.
6704 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6705 "Go to the first subject satisfying any non-nil constraint.
6706 If UNREAD is non-nil, the article should be unread.
6707 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6708 If UNSEED is non-nil, the article should be unseen.
6709 Returns the article selected or nil if there are no matching articles."
6713 ((null gnus-newsgroup-data)
6714 (gnus-message 3 "No articles in the group")
6716 ;; Pick the first article.
6717 ((not (or unread undownloaded unseen))
6718 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6719 (gnus-data-number (car gnus-newsgroup-data)))
6720 ;; Find the first unread article.
6722 (let ((data gnus-newsgroup-data))
6724 (let ((num (gnus-data-number (car data))))
6725 (or (memq num gnus-newsgroup-unfetched)
6726 (not (or (and unread
6727 (memq num gnus-newsgroup-unreads))
6729 (memq num gnus-newsgroup-undownloaded))
6731 (memq num gnus-newsgroup-unseen)))))))
6732 (setq data (cdr data)))
6736 (goto-char (gnus-data-pos (car data)))
6737 (gnus-data-number (car data)))
6738 (gnus-message 3 "No more%s articles"
6739 (let* ((r (when unread " unread"))
6740 (d (when undownloaded " undownloaded"))
6741 (s (when unseen " unseen"))
6742 (l (delq nil (list r d s))))
6743 (cond ((= 3 (length l))
6744 (concat r "," d ", or" s))
6746 (concat (car l) ", or" (cadr l)))
6753 (gnus-summary-position-point))))))
6755 (defun gnus-summary-next-subject (n &optional unread dont-display)
6756 "Go to next N'th summary line.
6757 If N is negative, go to the previous N'th subject line.
6758 If UNREAD is non-nil, only unread articles are selected.
6759 The difference between N and the actual number of steps taken is
6762 (let ((backward (< n 0))
6766 (gnus-summary-find-prev unread)
6767 (gnus-summary-find-next unread)))
6768 (unless (zerop (setq n (1- n)))
6769 (gnus-summary-show-thread)))
6771 (gnus-message 7 "No more%s articles"
6772 (if unread " unread" "")))
6773 (unless dont-display
6774 (gnus-summary-recenter)
6775 (gnus-summary-position-point))
6778 (defun gnus-summary-next-unread-subject (n)
6779 "Go to next N'th unread summary line."
6781 (gnus-summary-next-subject n t))
6783 (defun gnus-summary-prev-subject (n &optional unread)
6784 "Go to previous N'th summary line.
6785 If optional argument UNREAD is non-nil, only unread article is selected."
6787 (gnus-summary-next-subject (- n) unread))
6789 (defun gnus-summary-prev-unread-subject (n)
6790 "Go to previous N'th unread summary line."
6792 (gnus-summary-next-subject (- n) t))
6794 (defun gnus-summary-goto-subjects (articles)
6795 "Insert the subject header for ARTICLES in the current buffer."
6797 (dolist (article articles)
6798 (gnus-summary-goto-subject article t)))
6799 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6800 (gnus-summary-position-point))
6802 (defun gnus-summary-goto-subject (article &optional force silent)
6803 "Go the subject line of ARTICLE.
6804 If FORCE, also allow jumping to articles not currently shown."
6805 (interactive "nArticle number: ")
6806 (unless (numberp article)
6807 (error "Article %s is not a number" article))
6809 (data (gnus-data-find article)))
6810 ;; We read in the article if we have to.
6813 (gnus-summary-insert-subject
6815 (if (or (numberp force) (vectorp force)) force)
6817 (setq data (gnus-data-find article)))
6822 (gnus-message 3 "Can't find article %d" article))
6824 (let ((pt (gnus-data-pos data)))
6826 (gnus-summary-set-article-display-arrow pt))
6827 (gnus-summary-position-point)
6830 ;; Walking around summary lines with displaying articles.
6832 (defun gnus-summary-expand-window (&optional arg)
6833 "Make the summary buffer take up the entire Emacs frame.
6834 Given a prefix, will force an `article' buffer configuration."
6837 (gnus-configure-windows 'article 'force)
6838 (gnus-configure-windows 'summary 'force)))
6840 (defun gnus-summary-display-article (article &optional all-header)
6841 "Display ARTICLE in article buffer."
6842 (when (gnus-buffer-live-p gnus-article-buffer)
6843 (with-current-buffer gnus-article-buffer
6844 (mm-enable-multibyte)))
6845 (gnus-set-global-variables)
6846 (when (gnus-buffer-live-p gnus-article-buffer)
6847 (with-current-buffer gnus-article-buffer
6848 (setq gnus-article-charset gnus-newsgroup-charset)
6849 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6850 (mm-enable-multibyte)))
6854 (if gnus-summary-display-article-function
6855 (funcall gnus-summary-display-article-function article all-header)
6856 (gnus-article-prepare article all-header))
6857 (gnus-run-hooks 'gnus-select-article-hook)
6858 (when (and gnus-current-article
6859 (not (zerop gnus-current-article)))
6860 (gnus-summary-goto-subject gnus-current-article))
6861 (gnus-summary-recenter)
6862 (when (and gnus-use-trees gnus-show-threads)
6863 (gnus-possibly-generate-tree article)
6864 (gnus-highlight-selected-tree article))
6865 ;; Successfully display article.
6866 (gnus-article-set-window-start
6867 (cdr (assq article gnus-newsgroup-bookmarks))))))
6869 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6870 "Select the current article.
6871 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6872 non-nil, the article will be re-fetched even if it already present in
6873 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6875 ;; Make sure we are in the summary buffer to work around bbdb bug.
6876 (unless (eq major-mode 'gnus-summary-mode)
6877 (set-buffer gnus-summary-buffer))
6878 (let ((article (or article (gnus-summary-article-number)))
6879 (all-headers (not (not all-headers))) ;Must be t or nil.
6880 ;; prevent redisplay to cause flashy displays
6881 (inhibit-redisplay t)
6882 gnus-summary-display-article-function)
6884 (gnus-summary-article-pseudo-p article)
6885 (error "This is a pseudo-article"))
6887 (set-buffer gnus-summary-buffer)
6888 (if (or (and gnus-single-article-buffer
6889 (or (null gnus-current-article)
6890 (null gnus-article-current)
6891 (null (get-buffer gnus-article-buffer))
6892 (not (eq article (cdr gnus-article-current)))
6893 (not (equal (car gnus-article-current)
6894 gnus-newsgroup-name))))
6895 (and (not gnus-single-article-buffer)
6896 (or (null gnus-current-article)
6897 (not (eq gnus-current-article article))))
6899 ;; The requested article is different from the current article.
6901 (gnus-summary-display-article article all-headers)
6902 (when (gnus-buffer-live-p gnus-article-buffer)
6903 (with-current-buffer gnus-article-buffer
6904 (if (not gnus-article-decoded-p) ;; a local variable
6905 (mm-disable-multibyte))))
6906 (gnus-article-set-window-start
6907 (cdr (assq article gnus-newsgroup-bookmarks)))
6911 (defun gnus-summary-force-verify-and-decrypt ()
6912 "Display buttons for signed/encrypted parts and verify/decrypt them."
6914 (let ((mm-verify-option 'known)
6915 (mm-decrypt-option 'known)
6916 (gnus-buttonized-mime-types (append (list "multipart/signed"
6917 "multipart/encrypted")
6918 gnus-buttonized-mime-types)))
6919 (gnus-summary-select-article nil 'force)))
6921 (defun gnus-summary-set-current-mark (&optional current-mark)
6922 "Obsolete function."
6925 (defun gnus-summary-next-article (&optional unread subject backward push)
6926 "Select the next article.
6927 If UNREAD, only unread articles are selected.
6928 If SUBJECT, only articles with SUBJECT are selected.
6929 If BACKWARD, the previous article is selected instead of the next."
6932 ;; Is there such an article?
6933 ((and (gnus-summary-search-forward unread subject backward)
6934 (or (gnus-summary-display-article (gnus-summary-article-number))
6935 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6936 (gnus-summary-position-point))
6937 ;; If not, we try the first unread, if that is wanted.
6939 gnus-auto-select-same
6940 (gnus-summary-first-unread-article))
6941 (gnus-summary-position-point)
6942 (gnus-message 6 "Wrapped"))
6943 ;; Try to get next/previous article not displayed in this group.
6944 ((and gnus-auto-extend-newsgroup
6945 (not unread) (not subject))
6946 (gnus-summary-goto-article
6947 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6948 nil (count-lines (point-min) (point))))
6949 ;; Go to next/previous group.
6951 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6952 (gnus-summary-jump-to-group gnus-newsgroup-name))
6953 (let ((cmd last-command-char)
6956 (set-buffer gnus-group-buffer)
6959 (if (eq gnus-keep-same-level 'best)
6960 (gnus-summary-best-group gnus-newsgroup-name)
6961 (gnus-summary-search-group backward gnus-keep-same-level))))
6962 ;; For some reason, the group window gets selected. We change
6964 (select-window (get-buffer-window (current-buffer)))
6965 ;; Select next unread newsgroup automagically.
6967 ((or (not gnus-auto-select-next)
6969 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6970 ((or (eq gnus-auto-select-next 'quietly)
6971 (and (eq gnus-auto-select-next 'slightly-quietly)
6973 (and (eq gnus-auto-select-next 'almost-quietly)
6974 (gnus-summary-last-article-p)))
6976 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6978 (gnus-message 7 "No more%s articles (%s)..."
6979 (if unread " unread" "")
6980 (if group (concat "selecting " group)
6982 (gnus-summary-next-group nil group backward)))
6984 (when (gnus-key-press-event-p last-input-event)
6985 (gnus-summary-walk-group-buffer
6986 gnus-newsgroup-name cmd unread backward point))))))))
6988 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6989 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6990 (?\C-p (gnus-group-prev-unread-group 1))))
6991 (cursor-in-echo-area t)
6992 keve key group ended prompt)
6994 (set-buffer gnus-group-buffer)
6997 (if (eq gnus-keep-same-level 'best)
6998 (gnus-summary-best-group gnus-newsgroup-name)
6999 (gnus-summary-search-group backward gnus-keep-same-level))))
7003 "No more%s articles%s " (if unread " unread" "")
7005 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7006 (format " (Type %s for %s [%s])"
7007 (single-key-description cmd) group
7008 (car (gnus-gethash group gnus-newsrc-hashtb)))
7009 (format " (Type %s to exit %s)"
7010 (single-key-description cmd)
7011 gnus-newsgroup-name))))
7012 ;; Confirm auto selection.
7013 (setq key (car (setq keve (gnus-read-event-char prompt)))
7016 ((assq key keystrokes)
7017 (let ((obuf (current-buffer)))
7018 (switch-to-buffer gnus-group-buffer)
7020 (gnus-group-jump-to-group group))
7021 (eval (cadr (assq key keystrokes)))
7022 (setq group (gnus-group-group-name))
7023 (switch-to-buffer obuf))
7027 (gnus-ephemeral-group-p gnus-newsgroup-name))
7029 (gnus-summary-next-group nil group backward)))
7031 (push (cdr keve) unread-command-events))))))
7033 (defun gnus-summary-next-unread-article ()
7034 "Select unread article after current one."
7036 (gnus-summary-next-article
7037 (or (not (eq gnus-summary-goto-unread 'never))
7038 (gnus-summary-last-article-p (gnus-summary-article-number)))
7039 (and gnus-auto-select-same
7040 (gnus-summary-article-subject))))
7042 (defun gnus-summary-prev-article (&optional unread subject)
7043 "Select the article after the current one.
7044 If UNREAD is non-nil, only unread articles are selected."
7046 (gnus-summary-next-article unread subject t))
7048 (defun gnus-summary-prev-unread-article ()
7049 "Select unread article before current one."
7051 (gnus-summary-prev-article
7052 (or (not (eq gnus-summary-goto-unread 'never))
7053 (gnus-summary-first-article-p (gnus-summary-article-number)))
7054 (and gnus-auto-select-same
7055 (gnus-summary-article-subject))))
7057 (defun gnus-summary-next-page (&optional lines circular stop)
7058 "Show next page of the selected article.
7059 If at the end of the current article, select the next article.
7060 LINES says how many lines should be scrolled up.
7062 If CIRCULAR is non-nil, go to the start of the article instead of
7063 selecting the next article when reaching the end of the current
7066 If STOP is non-nil, just stop when reaching the end of the message."
7068 (setq gnus-summary-buffer (current-buffer))
7069 (gnus-set-global-variables)
7070 (let ((article (gnus-summary-article-number))
7071 (article-window (get-buffer-window gnus-article-buffer t))
7073 ;; If the buffer is empty, we have no article.
7075 (error "No article to select"))
7076 (gnus-configure-windows 'article)
7077 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7078 (if (and (eq gnus-summary-goto-unread 'never)
7079 (not (gnus-summary-last-article-p article)))
7080 (gnus-summary-next-article)
7081 (gnus-summary-next-unread-article))
7082 (if (or (null gnus-current-article)
7083 (null gnus-article-current)
7084 (/= article (cdr gnus-article-current))
7085 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7086 ;; Selected subject is different from current article's.
7087 (gnus-summary-display-article article)
7088 (when article-window
7089 (gnus-eval-in-buffer-window gnus-article-buffer
7090 (setq endp (gnus-article-next-page lines)))
7093 (gnus-message 3 "End of message"))
7095 (gnus-summary-beginning-of-article))
7097 (gnus-message 3 "End of message"))
7099 (if (and (eq gnus-summary-goto-unread 'never)
7100 (not (gnus-summary-last-article-p article)))
7101 (gnus-summary-next-article)
7102 (gnus-summary-next-unread-article))))))))
7103 (gnus-summary-recenter)
7104 (gnus-summary-position-point)))
7106 (defun gnus-summary-prev-page (&optional lines move)
7107 "Show previous page of selected article.
7108 Argument LINES specifies lines to be scrolled down.
7109 If MOVE, move to the previous unread article if point is at
7110 the beginning of the buffer."
7112 (let ((article (gnus-summary-article-number))
7113 (article-window (get-buffer-window gnus-article-buffer t))
7115 (gnus-configure-windows 'article)
7116 (if (or (null gnus-current-article)
7117 (null gnus-article-current)
7118 (/= article (cdr gnus-article-current))
7119 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7120 ;; Selected subject is different from current article's.
7121 (gnus-summary-display-article article)
7122 (gnus-summary-recenter)
7123 (when article-window
7124 (gnus-eval-in-buffer-window gnus-article-buffer
7125 (setq endp (gnus-article-prev-page lines)))
7126 (when (and move endp)
7128 (gnus-message 3 "Beginning of message"))
7130 (if (and (eq gnus-summary-goto-unread 'never)
7131 (not (gnus-summary-first-article-p article)))
7132 (gnus-summary-prev-article)
7133 (gnus-summary-prev-unread-article))))))))
7134 (gnus-summary-position-point))
7136 (defun gnus-summary-prev-page-or-article (&optional lines)
7137 "Show previous page of selected article.
7138 Argument LINES specifies lines to be scrolled down.
7139 If at the beginning of the article, go to the next article."
7141 (gnus-summary-prev-page lines t))
7143 (defun gnus-summary-scroll-up (lines)
7144 "Scroll up (or down) one line current article.
7145 Argument LINES specifies lines to be scrolled up (or down if negative)."
7147 (gnus-configure-windows 'article)
7148 (gnus-summary-show-thread)
7149 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7150 (gnus-eval-in-buffer-window gnus-article-buffer
7152 (when (gnus-article-next-page lines)
7153 (gnus-message 3 "End of message")))
7155 (gnus-article-prev-page (- lines))))))
7156 (gnus-summary-recenter)
7157 (gnus-summary-position-point))
7159 (defun gnus-summary-scroll-down (lines)
7160 "Scroll down (or up) one line current article.
7161 Argument LINES specifies lines to be scrolled down (or up if negative)."
7163 (gnus-summary-scroll-up (- lines)))
7165 (defun gnus-summary-next-same-subject ()
7166 "Select next article which has the same subject as current one."
7168 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7170 (defun gnus-summary-prev-same-subject ()
7171 "Select previous article which has the same subject as current one."
7173 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7175 (defun gnus-summary-next-unread-same-subject ()
7176 "Select next unread article which has the same subject as current one."
7178 (gnus-summary-next-article t (gnus-summary-article-subject)))
7180 (defun gnus-summary-prev-unread-same-subject ()
7181 "Select previous unread article which has the same subject as current one."
7183 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7185 (defun gnus-summary-first-unread-article ()
7186 "Select the first unread article.
7187 Return nil if there are no unread articles."
7190 (when (gnus-summary-first-subject t)
7191 (gnus-summary-show-thread)
7192 (gnus-summary-first-subject t)
7193 (gnus-summary-display-article (gnus-summary-article-number)))
7194 (gnus-summary-position-point)))
7196 (defun gnus-summary-first-unread-subject ()
7197 "Place the point on the subject line of the first unread article.
7198 Return nil if there are no unread articles."
7201 (when (gnus-summary-first-subject t)
7202 (gnus-summary-show-thread)
7203 (gnus-summary-first-subject t))
7204 (gnus-summary-position-point)))
7206 (defun gnus-summary-first-unseen-subject ()
7207 "Place the point on the subject line of the first unseen article.
7208 Return nil if there are no unseen articles."
7211 (when (gnus-summary-first-subject nil nil t)
7212 (gnus-summary-show-thread)
7213 (gnus-summary-first-subject nil nil t))
7214 (gnus-summary-position-point)))
7216 (defun gnus-summary-first-unseen-or-unread-subject ()
7217 "Place the point on the subject line of the first unseen article or,
7218 if all article have been seen, on the subject line of the first unread
7222 (unless (when (gnus-summary-first-subject nil nil t)
7223 (gnus-summary-show-thread)
7224 (gnus-summary-first-subject nil nil t))
7225 (when (gnus-summary-first-subject t)
7226 (gnus-summary-show-thread)
7227 (gnus-summary-first-subject t)))
7228 (gnus-summary-position-point)))
7230 (defun gnus-summary-first-article ()
7231 "Select the first article.
7232 Return nil if there are no articles."
7235 (when (gnus-summary-first-subject)
7236 (gnus-summary-show-thread)
7237 (gnus-summary-first-subject)
7238 (gnus-summary-display-article (gnus-summary-article-number)))
7239 (gnus-summary-position-point)))
7241 (defun gnus-summary-best-unread-article (&optional arg)
7242 "Select the unread article with the highest score.
7243 If given a prefix argument, select the next unread article that has a
7244 score higher than the default score."
7246 (let ((article (if arg
7247 (gnus-summary-better-unread-subject)
7248 (gnus-summary-best-unread-subject))))
7250 (gnus-summary-goto-article article)
7251 (error "No unread articles"))))
7253 (defun gnus-summary-best-unread-subject ()
7254 "Select the unread subject with the highest score."
7256 (let ((best -1000000)
7257 (data gnus-newsgroup-data)
7260 (and (gnus-data-unread-p (car data))
7262 (gnus-summary-article-score (gnus-data-number (car data))))
7265 article (gnus-data-number (car data))))
7266 (setq data (cdr data)))
7268 (gnus-summary-goto-subject article))
7269 (gnus-summary-position-point)
7272 (defun gnus-summary-better-unread-subject ()
7273 "Select the first unread subject that has a score over the default score."
7275 (let ((data gnus-newsgroup-data)
7277 (while (and (setq article (gnus-data-number (car data)))
7278 (or (gnus-data-read-p (car data))
7279 (not (> (gnus-summary-article-score article)
7280 gnus-summary-default-score))))
7281 (setq data (cdr data)))
7283 (gnus-summary-goto-subject article))
7284 (gnus-summary-position-point)
7287 (defun gnus-summary-last-subject ()
7288 "Go to the last displayed subject line in the group."
7289 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7291 (gnus-summary-goto-subject article))))
7293 (defun gnus-summary-goto-article (article &optional all-headers force)
7294 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7295 If ALL-HEADERS is non-nil, no header lines are hidden.
7296 If FORCE, go to the article even if it isn't displayed. If FORCE
7297 is a number, it is the line the article is to be displayed on."
7301 "Article number or Message-ID: "
7302 (mapcar (lambda (number) (list (int-to-string number)))
7303 gnus-newsgroup-limit))
7307 (if (and (stringp article)
7308 (string-match "@" article))
7309 (gnus-summary-refer-article article)
7310 (when (stringp article)
7311 (setq article (string-to-number article)))
7312 (if (gnus-summary-goto-subject article force)
7313 (gnus-summary-display-article article all-headers)
7314 (gnus-message 4 "Couldn't go to article %s" article) nil))
7315 (gnus-summary-position-point)))
7317 (defun gnus-summary-goto-last-article ()
7318 "Go to the previously read article."
7321 (when gnus-last-article
7322 (gnus-summary-goto-article gnus-last-article nil t))
7323 (gnus-summary-position-point)))
7325 (defun gnus-summary-pop-article (number)
7326 "Pop one article off the history and go to the previous.
7327 NUMBER articles will be popped off."
7330 (setq gnus-newsgroup-history
7331 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7333 (gnus-summary-goto-article (car to) nil t)
7334 (error "Article history empty")))
7335 (gnus-summary-position-point))
7337 ;; Summary commands and functions for limiting the summary buffer.
7339 (defun gnus-summary-limit-to-articles (n)
7340 "Limit the summary buffer to the next N articles.
7341 If not given a prefix, use the process marked articles instead."
7344 (let ((articles (gnus-summary-work-articles n)))
7345 (setq gnus-newsgroup-processable nil)
7346 (gnus-summary-limit articles))
7347 (gnus-summary-position-point)))
7349 (defun gnus-summary-pop-limit (&optional total)
7350 "Restore the previous limit.
7351 If given a prefix, remove all limits."
7354 (setq gnus-newsgroup-limits
7355 (list (mapcar (lambda (h) (mail-header-number h))
7356 gnus-newsgroup-headers))))
7357 (unless gnus-newsgroup-limits
7358 (error "No limit to pop"))
7360 (gnus-summary-limit nil 'pop)
7361 (gnus-summary-position-point)))
7363 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7364 "Limit the summary buffer to articles that have subjects that match a regexp.
7365 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7367 (list (read-string (if current-prefix-arg
7368 "Exclude subject (regexp): "
7369 "Limit to subject (regexp): "))
7370 nil current-prefix-arg))
7372 (setq header "subject"))
7373 (when (not (equal "" subject))
7375 (let ((articles (gnus-summary-find-matching
7376 (or header "subject") subject 'all nil nil
7379 (error "Found no matches for \"%s\"" subject))
7380 (gnus-summary-limit articles))
7381 (gnus-summary-position-point))))
7383 (defun gnus-summary-limit-to-author (from &optional not-matching)
7384 "Limit the summary buffer to articles that have authors that match a regexp.
7385 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7387 (list (read-string (if current-prefix-arg
7388 "Exclude author (regexp): "
7389 "Limit to author (regexp): "))
7390 current-prefix-arg))
7391 (gnus-summary-limit-to-subject from "from" not-matching))
7393 (defun gnus-summary-limit-to-age (age &optional younger-p)
7394 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7395 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7396 articles that are younger than AGE days."
7398 (let ((younger current-prefix-arg)
7401 (while (not days-got)
7402 (setq days (if younger
7403 (read-string "Limit to articles younger than (in days, older when negative): ")
7405 "Limit to articles older than (in days, younger when negative): ")))
7406 (when (> (length days) 0)
7407 (setq days (read days)))
7413 (setq younger (not younger))
7414 (setq days (* days -1)))))
7415 (message "Please enter a number.")
7417 (list days younger)))
7419 (let ((data gnus-newsgroup-data)
7420 (cutoff (days-to-time age))
7421 articles d date is-younger)
7422 (while (setq d (pop data))
7423 (when (and (vectorp (gnus-data-header d))
7424 (setq date (mail-header-date (gnus-data-header d))))
7425 (setq is-younger (time-less-p
7426 (time-since (condition-case ()
7433 (push (gnus-data-number d) articles))))
7434 (gnus-summary-limit (nreverse articles)))
7435 (gnus-summary-position-point)))
7437 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7438 "Limit the summary buffer to articles that match an 'extra' header."
7442 (gnus-completing-read-with-default
7443 (symbol-name (car gnus-extra-headers))
7444 (if current-prefix-arg
7445 "Exclude extra header:"
7446 "Limit extra header:")
7448 (cons (symbol-name x) x))
7453 (read-string (format "%s header %s (regexp): "
7454 (if current-prefix-arg "Exclude" "Limit to")
7456 current-prefix-arg)))
7457 (when (not (equal "" regexp))
7459 (let ((articles (gnus-summary-find-matching
7460 (cons 'extra header) regexp 'all nil nil
7463 (error "Found no matches for \"%s\"" regexp))
7464 (gnus-summary-limit articles))
7465 (gnus-summary-position-point))))
7467 (defun gnus-summary-limit-to-display-predicate ()
7468 "Limit the summary buffer to the predicated in the `display' group parameter."
7470 (unless gnus-newsgroup-display
7471 (error "There is no `display' group parameter"))
7473 (dolist (number gnus-newsgroup-articles)
7474 (when (funcall gnus-newsgroup-display)
7475 (push number articles)))
7476 (gnus-summary-limit articles))
7477 (gnus-summary-position-point))
7479 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7481 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7483 (defun gnus-summary-limit-to-unread (&optional all)
7484 "Limit the summary buffer to articles that are not marked as read.
7485 If ALL is non-nil, limit strictly to unread articles."
7488 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7489 (gnus-summary-limit-to-marks
7490 ;; Concat all the marks that say that an article is read and have
7492 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7493 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7494 gnus-low-score-mark gnus-expirable-mark
7495 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7496 gnus-duplicate-mark gnus-souped-mark)
7499 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7500 (make-obsolete 'gnus-summary-delete-marked-with
7501 'gnus-summary-limit-exclude-marks)
7503 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7504 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7505 If REVERSE, limit the summary buffer to articles that are marked
7506 with MARKS. MARKS can either be a string of marks or a list of marks.
7507 Returns how many articles were removed."
7508 (interactive "sMarks: ")
7509 (gnus-summary-limit-to-marks marks t))
7511 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7512 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7513 If REVERSE (the prefix), limit the summary buffer to articles that are
7514 not marked with MARKS. MARKS can either be a string of marks or a
7516 Returns how many articles were removed."
7517 (interactive "sMarks: \nP")
7519 (let ((data gnus-newsgroup-data)
7520 (marks (if (listp marks) marks
7521 (append marks nil))) ; Transform to list.
7524 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7525 (memq (gnus-data-mark (car data)) marks))
7526 (push (gnus-data-number (car data)) articles))
7527 (setq data (cdr data)))
7528 (gnus-summary-limit articles))
7529 (gnus-summary-position-point)))
7531 (defun gnus-summary-limit-to-score (score)
7532 "Limit to articles with score at or above SCORE."
7533 (interactive "NLimit to articles with score of at least: ")
7534 (let ((data gnus-newsgroup-data)
7537 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7539 (push (gnus-data-number (car data)) articles))
7540 (setq data (cdr data)))
7542 (gnus-summary-limit articles)
7543 (gnus-summary-position-point))))
7545 (defun gnus-summary-limit-to-unseen ()
7546 "Limit to unseen articles."
7549 (gnus-summary-limit gnus-newsgroup-unseen)
7550 (gnus-summary-position-point)))
7552 (defun gnus-summary-limit-include-thread (id)
7553 "Display all the hidden articles that is in the thread with ID in it.
7554 When called interactively, ID is the Message-ID of the current
7556 (interactive (list (mail-header-id (gnus-summary-article-header))))
7557 (let ((articles (gnus-articles-in-thread
7558 (gnus-id-to-thread (gnus-root-id id)))))
7560 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7561 (gnus-summary-limit-include-matching-articles
7563 (regexp-quote (gnus-simplify-subject-re
7564 (mail-header-subject (gnus-id-to-header id)))))
7565 (gnus-summary-position-point))))
7567 (defun gnus-summary-limit-include-matching-articles (header regexp)
7568 "Display all the hidden articles that have HEADERs that match REGEXP."
7569 (interactive (list (read-string "Match on header: ")
7570 (read-string "Regexp: ")))
7571 (let ((articles (gnus-find-matching-articles header regexp)))
7573 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7574 (gnus-summary-position-point))))
7576 (defun gnus-summary-insert-dormant-articles ()
7577 "Insert all the dormat articles for this group into the current buffer."
7579 (let ((gnus-verbose (max 6 gnus-verbose)))
7580 (if (not gnus-newsgroup-dormant)
7581 (gnus-message 3 "No cached articles for this group")
7582 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7584 (defun gnus-summary-limit-include-dormant ()
7585 "Display all the hidden articles that are marked as dormant.
7586 Note that this command only works on a subset of the articles currently
7587 fetched for this group."
7589 (unless gnus-newsgroup-dormant
7590 (error "There are no dormant articles in this group"))
7592 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7593 (gnus-summary-position-point)))
7595 (defun gnus-summary-limit-exclude-dormant ()
7596 "Hide all dormant articles."
7599 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7600 (gnus-summary-position-point)))
7602 (defun gnus-summary-limit-exclude-childless-dormant ()
7603 "Hide all dormant articles that have no children."
7605 (let ((data (gnus-data-list t))
7606 articles d children)
7607 ;; Find all articles that are either not dormant or have
7609 (while (setq d (pop data))
7610 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7612 (gnus-article-children (gnus-data-number d)))
7615 (when (memq (car children) articles)
7620 (push (gnus-data-number d) articles)))
7623 (gnus-summary-limit articles)
7624 (gnus-summary-position-point))))
7626 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7627 "Mark all unread excluded articles as read.
7628 If ALL, mark even excluded ticked and dormants as read."
7630 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7631 (let ((articles (gnus-sorted-ndifference
7633 (mapcar (lambda (h) (mail-header-number h))
7634 gnus-newsgroup-headers)
7636 gnus-newsgroup-limit))
7638 (setq gnus-newsgroup-unreads
7639 (gnus-sorted-intersection gnus-newsgroup-unreads
7640 gnus-newsgroup-limit))
7642 (setq gnus-newsgroup-dormant nil
7643 gnus-newsgroup-marked nil
7644 gnus-newsgroup-reads
7646 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7647 gnus-newsgroup-reads))
7648 (while (setq article (pop articles))
7649 (unless (or (memq article gnus-newsgroup-dormant)
7650 (memq article gnus-newsgroup-marked))
7651 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7653 (defun gnus-summary-limit (articles &optional pop)
7655 ;; We pop the previous limit off the stack and use that.
7656 (setq articles (car gnus-newsgroup-limits)
7657 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7658 ;; We use the new limit, so we push the old limit on the stack.
7659 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7661 (setq gnus-newsgroup-limit articles)
7662 (let ((total (length gnus-newsgroup-data))
7663 (data (gnus-data-find-list (gnus-summary-article-number)))
7664 (gnus-summary-mark-below nil) ; Inhibit this.
7666 ;; This will do all the work of generating the new summary buffer
7667 ;; according to the new limit.
7668 (gnus-summary-prepare)
7669 ;; Hide any threads, possibly.
7670 (gnus-summary-maybe-hide-threads)
7671 ;; Try to return to the article you were at, or one in the
7674 ;; We try to find some article after the current one.
7676 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7679 (setq data (cdr data))))
7681 ;; If there is no data, that means that we were after the last
7682 ;; article. The same goes when we can't find any articles
7683 ;; after the current one.
7684 (goto-char (point-max))
7685 (gnus-summary-find-prev))
7686 (gnus-set-mode-line 'summary)
7687 ;; We return how many articles were removed from the summary
7688 ;; buffer as a result of the new limit.
7689 (- total (length gnus-newsgroup-data))))
7691 (defsubst gnus-invisible-cut-children (threads)
7694 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7699 (defsubst gnus-cut-thread (thread)
7700 "Go forwards in the thread until we find an article that we want to display."
7701 (when (or (eq gnus-fetch-old-headers 'some)
7702 (eq gnus-fetch-old-headers 'invisible)
7703 (numberp gnus-fetch-old-headers)
7704 (eq gnus-build-sparse-threads 'some)
7705 (eq gnus-build-sparse-threads 'more))
7706 ;; Deal with old-fetched headers and sparse threads.
7710 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7711 (gnus-summary-article-ancient-p
7712 (mail-header-number (car thread))))
7713 (if (or (<= (length (cdr thread)) 1)
7714 (eq gnus-fetch-old-headers 'invisible))
7715 (setq gnus-newsgroup-limit
7716 (delq (mail-header-number (car thread))
7717 gnus-newsgroup-limit)
7718 thread (cadr thread))
7719 (when (gnus-invisible-cut-children (cdr thread))
7720 (let ((th (cdr thread)))
7722 (if (memq (mail-header-number (caar th))
7723 gnus-newsgroup-limit)
7724 (setq thread (car th)
7726 (setq th (cdr th))))))))))
7729 (defun gnus-cut-threads (threads)
7730 "Cut off all uninteresting articles from the beginning of threads."
7731 (when (or (eq gnus-fetch-old-headers 'some)
7732 (eq gnus-fetch-old-headers 'invisible)
7733 (numberp gnus-fetch-old-headers)
7734 (eq gnus-build-sparse-threads 'some)
7735 (eq gnus-build-sparse-threads 'more))
7738 (setcar th (gnus-cut-thread (car th)))
7739 (setq th (cdr th)))))
7740 ;; Remove nixed out threads.
7743 (defun gnus-summary-initial-limit (&optional show-if-empty)
7744 "Figure out what the initial limit is supposed to be on group entry.
7745 This entails weeding out unwanted dormants, low-scored articles,
7746 fetch-old-headers verbiage, and so on."
7747 ;; Most groups have nothing to remove.
7748 (if (or gnus-inhibit-limiting
7749 (and (null gnus-newsgroup-dormant)
7750 (eq gnus-newsgroup-display 'gnus-not-ignore)
7751 (not (eq gnus-fetch-old-headers 'some))
7752 (not (numberp gnus-fetch-old-headers))
7753 (not (eq gnus-fetch-old-headers 'invisible))
7754 (null gnus-summary-expunge-below)
7755 (not (eq gnus-build-sparse-threads 'some))
7756 (not (eq gnus-build-sparse-threads 'more))
7757 (null gnus-thread-expunge-below)
7758 (not gnus-use-nocem)))
7760 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7761 (setq gnus-newsgroup-limit nil)
7764 (unless (car (symbol-value node))
7765 ;; These threads have no parents -- they are roots.
7766 (let ((nodes (cdr (symbol-value node)))
7769 (if (and gnus-thread-expunge-below
7770 (< (gnus-thread-total-score (car nodes))
7771 gnus-thread-expunge-below))
7772 (gnus-expunge-thread (pop nodes))
7773 (setq thread (pop nodes))
7774 (gnus-summary-limit-children thread))))))
7775 gnus-newsgroup-dependencies)
7776 ;; If this limitation resulted in an empty group, we might
7777 ;; pop the previous limit and use it instead.
7778 (when (and (not gnus-newsgroup-limit)
7780 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7781 gnus-newsgroup-limit))
7783 (defun gnus-summary-limit-children (thread)
7784 "Return 1 if this subthread is visible and 0 if it is not."
7785 ;; First we get the number of visible children to this thread. This
7786 ;; is done by recursing down the thread using this function, so this
7787 ;; will really go down to a leaf article first, before slowly
7788 ;; working its way up towards the root.
7790 (let* ((max-lisp-eval-depth 5000)
7793 (apply '+ (mapcar 'gnus-summary-limit-children
7796 (number (mail-header-number (car thread)))
7799 (not (memq number gnus-newsgroup-marked))
7801 ;; If this article is dormant and has absolutely no visible
7802 ;; children, then this article isn't visible.
7803 (and (memq number gnus-newsgroup-dormant)
7805 ;; If this is "fetch-old-headered" and there is no
7806 ;; visible children, then we don't want this article.
7807 (and (or (eq gnus-fetch-old-headers 'some)
7808 (numberp gnus-fetch-old-headers))
7809 (gnus-summary-article-ancient-p number)
7811 ;; If this is "fetch-old-headered" and `invisible', then
7812 ;; we don't want this article.
7813 (and (eq gnus-fetch-old-headers 'invisible)
7814 (gnus-summary-article-ancient-p number))
7815 ;; If this is a sparsely inserted article with no children,
7816 ;; we don't want it.
7817 (and (eq gnus-build-sparse-threads 'some)
7818 (gnus-summary-article-sparse-p number)
7820 ;; If we use expunging, and this article is really
7821 ;; low-scored, then we don't want this article.
7822 (when (and gnus-summary-expunge-below
7824 (or (cdr (assq number gnus-newsgroup-scored))
7825 gnus-summary-default-score))
7826 gnus-summary-expunge-below))
7827 ;; We increase the expunge-tally here, but that has
7828 ;; nothing to do with the limits, really.
7829 (incf gnus-newsgroup-expunged-tally)
7830 ;; We also mark as read here, if that's wanted.
7831 (when (and gnus-summary-mark-below
7832 (< score gnus-summary-mark-below))
7833 (setq gnus-newsgroup-unreads
7834 (delq number gnus-newsgroup-unreads))
7835 (if gnus-newsgroup-auto-expire
7836 (push number gnus-newsgroup-expirable)
7837 (push (cons number gnus-low-score-mark)
7838 gnus-newsgroup-reads)))
7840 ;; Do the `display' group parameter.
7841 (and gnus-newsgroup-display
7842 (not (funcall gnus-newsgroup-display)))
7843 ;; Check NoCeM things.
7844 (if (and gnus-use-nocem
7845 (gnus-nocem-unwanted-article-p
7846 (mail-header-id (car thread))))
7848 (setq gnus-newsgroup-unreads
7849 (delq number gnus-newsgroup-unreads))
7851 ;; Nope, invisible article.
7853 ;; Ok, this article is to be visible, so we add it to the limit
7855 (push number gnus-newsgroup-limit)
7858 (defun gnus-expunge-thread (thread)
7859 "Mark all articles in THREAD as read."
7860 (let* ((number (mail-header-number (car thread))))
7861 (incf gnus-newsgroup-expunged-tally)
7862 ;; We also mark as read here, if that's wanted.
7863 (setq gnus-newsgroup-unreads
7864 (delq number gnus-newsgroup-unreads))
7865 (if gnus-newsgroup-auto-expire
7866 (push number gnus-newsgroup-expirable)
7867 (push (cons number gnus-low-score-mark)
7868 gnus-newsgroup-reads)))
7869 ;; Go recursively through all subthreads.
7870 (mapcar 'gnus-expunge-thread (cdr thread)))
7872 ;; Summary article oriented commands
7874 (defun gnus-summary-refer-parent-article (n)
7875 "Refer parent article N times.
7876 If N is negative, go to ancestor -N instead.
7877 The difference between N and the number of articles fetched is returned."
7881 (when (not (natnump n))
7886 (setq header (gnus-summary-article-header))
7887 (if (and (eq (mail-header-number header)
7888 (cdr gnus-article-current))
7889 (equal gnus-newsgroup-name
7890 (car gnus-article-current)))
7891 ;; If we try to find the parent of the currently
7892 ;; displayed article, then we take a look at the actual
7893 ;; References header, since this is slightly more
7894 ;; reliable than the References field we got from the
7897 (set-buffer gnus-original-article-buffer)
7898 (nnheader-narrow-to-headers)
7899 (unless (setq ref (message-fetch-field "references"))
7900 (setq ref (message-fetch-field "in-reply-to")))
7903 ;; It's not the current article, so we take a bet on
7904 ;; the value we got from the server.
7905 (mail-header-references header)))
7907 (not (equal ref "")))
7908 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7909 (gnus-message 1 "Couldn't find parent"))
7910 (gnus-message 1 "No references in article %d"
7911 (gnus-summary-article-number))
7914 (gnus-summary-position-point)
7917 (defun gnus-summary-refer-references ()
7918 "Fetch all articles mentioned in the References header.
7919 Return the number of articles fetched."
7921 (let ((ref (mail-header-references (gnus-summary-article-header)))
7922 (current (gnus-summary-article-number))
7926 (error "No References in the current article")
7927 ;; For each Message-ID in the References header...
7928 (while (string-match "<[^>]*>" ref)
7930 ;; ... fetch that article.
7931 (gnus-summary-refer-article
7932 (prog1 (match-string 0 ref)
7933 (setq ref (substring ref (match-end 0))))))
7934 (gnus-summary-goto-subject current)
7935 (gnus-summary-position-point)
7938 (defun gnus-summary-refer-thread (&optional limit)
7939 "Fetch all articles in the current thread.
7940 If LIMIT (the numerical prefix), fetch that many old headers instead
7941 of what's specified by the `gnus-refer-thread-limit' variable."
7943 (let ((id (mail-header-id (gnus-summary-article-header)))
7944 (limit (if limit (prefix-numeric-value limit)
7945 gnus-refer-thread-limit)))
7946 ;; We want to fetch LIMIT *old* headers, but we also have to
7947 ;; re-fetch all the headers in the current buffer, because many of
7948 ;; them may be undisplayed. So we adjust LIMIT.
7949 (when (numberp limit)
7950 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7951 (unless (eq gnus-fetch-old-headers 'invisible)
7952 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7953 ;; Retrieve the headers and read them in.
7954 (if (eq (gnus-retrieve-headers
7955 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7957 (gnus-build-all-threads)
7958 (error "Can't fetch thread from backends that don't support NOV"))
7959 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7960 (gnus-summary-limit-include-thread id)))
7962 (defun gnus-summary-refer-article (message-id)
7963 "Fetch an article specified by MESSAGE-ID."
7964 (interactive "sMessage-ID: ")
7965 (when (and (stringp message-id)
7966 (not (zerop (length message-id))))
7967 ;; Construct the correct Message-ID if necessary.
7968 ;; Suggested by tale@pawl.rpi.edu.
7969 (unless (string-match "^<" message-id)
7970 (setq message-id (concat "<" message-id)))
7971 (unless (string-match ">$" message-id)
7972 (setq message-id (concat message-id ">")))
7973 (let* ((header (gnus-id-to-header message-id))
7975 (gnus-summary-article-sparse-p
7976 (mail-header-number header))
7977 (memq (mail-header-number header)
7978 gnus-newsgroup-limit)))
7981 ;; If the article is present in the buffer we just go to it.
7983 (or (not (gnus-summary-article-sparse-p
7984 (mail-header-number header)))
7987 (gnus-summary-goto-article
7988 (mail-header-number header) nil t)
7990 (gnus-summary-update-article (mail-header-number header)))))
7992 ;; We fetch the article.
7994 (dolist (gnus-override-method (gnus-refer-article-methods))
7995 (gnus-check-server gnus-override-method)
7996 ;; Fetch the header, and display the article.
7997 (when (setq number (gnus-summary-insert-subject message-id))
7998 (gnus-summary-select-article nil nil nil number)
8000 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8002 (defun gnus-refer-article-methods ()
8003 "Return a list of referable methods."
8005 ;; No method, so we default to current and native.
8006 ((null gnus-refer-article-method)
8007 (list gnus-current-select-method gnus-select-method))
8009 ((eq 'current gnus-refer-article-method)
8010 (list gnus-current-select-method))
8011 ;; List of select methods.
8012 ((not (and (symbolp (car gnus-refer-article-method))
8013 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8015 (dolist (method gnus-refer-article-method)
8016 (push (if (eq 'current method)
8017 gnus-current-select-method
8021 ;; One single select method.
8023 (list gnus-refer-article-method))))
8025 (defun gnus-summary-edit-parameters ()
8026 "Edit the group parameters of the current group."
8028 (gnus-group-edit-group gnus-newsgroup-name 'params))
8030 (defun gnus-summary-customize-parameters ()
8031 "Customize the group parameters of the current group."
8033 (gnus-group-customize gnus-newsgroup-name))
8035 (defun gnus-summary-enter-digest-group (&optional force)
8036 "Enter an nndoc group based on the current article.
8037 If FORCE, force a digest interpretation. If not, try
8038 to guess what the document format is."
8040 (let ((conf gnus-current-window-configuration))
8042 (gnus-summary-select-article))
8043 (setq gnus-current-window-configuration conf)
8044 (let* ((name (format "%s-%d"
8045 (gnus-group-prefixed-name
8046 gnus-newsgroup-name (list 'nndoc ""))
8048 (set-buffer gnus-summary-buffer)
8049 gnus-current-article)))
8050 (ogroup gnus-newsgroup-name)
8051 (params (append (gnus-info-params (gnus-get-info ogroup))
8052 (list (cons 'to-group ogroup))
8053 (list (cons 'save-article-group ogroup))))
8054 (case-fold-search t)
8055 (buf (current-buffer))
8058 (set-buffer gnus-original-article-buffer)
8059 ;; Have the digest group inherit the main mail address of
8060 ;; the parent article.
8061 (when (setq to-address (or (gnus-fetch-field "reply-to")
8062 (gnus-fetch-field "from")))
8063 (setq params (append
8064 (list (cons 'to-address
8065 (funcall gnus-decode-encoded-word-function
8067 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8068 (insert-buffer-substring gnus-original-article-buffer)
8069 ;; Remove lines that may lead nndoc to misinterpret the
8072 (goto-char (point-min))
8073 (or (search-forward "\n\n" nil t) (point)))
8074 (goto-char (point-min))
8075 (delete-matching-lines "^Path:\\|^From ")
8078 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8079 (gnus-newsgroup-ephemeral-ignored-charsets
8080 gnus-newsgroup-ignored-charsets))
8081 (gnus-group-read-ephemeral-group
8082 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8084 ,(if force 'mbox 'guess)))
8086 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8088 ;; Make all postings to this group go to the parent group.
8089 (nconc (gnus-info-params (gnus-get-info name))
8091 ;; Couldn't select this doc group.
8092 (switch-to-buffer buf)
8093 (gnus-set-global-variables)
8094 (gnus-configure-windows 'summary)
8095 (gnus-message 3 "Article couldn't be entered?"))
8096 (kill-buffer dig)))))
8098 (defun gnus-summary-read-document (n)
8099 "Open a new group based on the current article(s).
8100 This will allow you to read digests and other similar
8101 documents as newsgroups.
8102 Obeys the standard process/prefix convention."
8104 (let* ((articles (gnus-summary-work-articles n))
8105 (ogroup gnus-newsgroup-name)
8106 (params (append (gnus-info-params (gnus-get-info ogroup))
8107 (list (cons 'to-group ogroup))))
8108 article group egroup groups vgroup)
8109 (while (setq article (pop articles))
8110 (setq group (format "%s-%d" gnus-newsgroup-name article))
8111 (gnus-summary-remove-process-mark article)
8112 (when (gnus-summary-display-article article)
8115 (insert-buffer-substring gnus-original-article-buffer)
8116 ;; Remove some headers that may lead nndoc to make
8118 (message-narrow-to-head)
8119 (goto-char (point-min))
8120 (delete-matching-lines "^\\(Path\\):\\|^From ")
8123 (gnus-group-read-ephemeral-group
8124 group `(nndoc ,group (nndoc-address ,(current-buffer))
8125 (nndoc-article-type guess))
8128 ;; Make all postings to this group go to the parent group.
8129 (nconc (gnus-info-params (gnus-get-info egroup))
8131 (push egroup groups))
8132 ;; Couldn't select this doc group.
8133 (gnus-error 3 "Article couldn't be entered"))))))
8134 ;; Now we have selected all the documents.
8137 (error "None of the articles could be interpreted as documents"))
8138 ((gnus-group-read-ephemeral-group
8139 (setq vgroup (format
8140 "nnvirtual:%s-%s" gnus-newsgroup-name
8141 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8142 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8144 (cons (current-buffer) 'summary)))
8146 (error "Couldn't select virtual nndoc group")))))
8148 (defun gnus-summary-isearch-article (&optional regexp-p)
8149 "Do incremental search forward on the current article.
8150 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8152 (gnus-summary-select-article)
8153 (gnus-configure-windows 'article)
8154 (gnus-eval-in-buffer-window gnus-article-buffer
8157 (isearch-forward regexp-p))))
8159 (defun gnus-summary-search-article-forward (regexp &optional backward)
8160 "Search for an article containing REGEXP forward.
8161 If BACKWARD, search backward instead."
8164 (format "Search article %s (regexp%s): "
8165 (if current-prefix-arg "backward" "forward")
8166 (if gnus-last-search-regexp
8167 (concat ", default " gnus-last-search-regexp)
8169 current-prefix-arg))
8170 (if (string-equal regexp "")
8171 (setq regexp (or gnus-last-search-regexp ""))
8172 (setq gnus-last-search-regexp regexp)
8173 (setq gnus-article-before-search gnus-current-article))
8174 ;; Intentionally set gnus-last-article.
8175 (setq gnus-last-article gnus-article-before-search)
8176 (let ((gnus-last-article gnus-last-article))
8177 (if (gnus-summary-search-article regexp backward)
8178 (gnus-summary-show-thread)
8179 (error "Search failed: \"%s\"" regexp))))
8181 (defun gnus-summary-search-article-backward (regexp)
8182 "Search for an article containing REGEXP backward."
8185 (format "Search article backward (regexp%s): "
8186 (if gnus-last-search-regexp
8187 (concat ", default " gnus-last-search-regexp)
8189 (gnus-summary-search-article-forward regexp 'backward))
8191 (defun gnus-summary-search-article (regexp &optional backward)
8192 "Search for an article containing REGEXP.
8193 Optional argument BACKWARD means do search for backward.
8194 `gnus-select-article-hook' is not called during the search."
8195 ;; We have to require this here to make sure that the following
8196 ;; dynamic binding isn't shadowed by autoloading.
8197 (require 'gnus-async)
8199 (let ((gnus-select-article-hook nil) ;Disable hook.
8200 (gnus-article-prepare-hook nil)
8201 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8202 (gnus-use-article-prefetch nil)
8203 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8204 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8205 (sum (current-buffer))
8206 (gnus-display-mime-function nil)
8209 (gnus-save-hidden-threads
8210 (gnus-summary-select-article)
8211 (set-buffer gnus-article-buffer)
8212 (goto-char (window-point (get-buffer-window (current-buffer))))
8216 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8218 (re-search-backward regexp nil t)
8219 (re-search-forward regexp nil t))
8220 ;; We found the regexp.
8225 (get-buffer-window (current-buffer))
8229 (get-buffer-window (current-buffer))
8232 (setq point (point)))
8233 ;; We didn't find it, so we go to the next article.
8236 (while (eq found 'not)
8237 (if (not (if backward (gnus-summary-find-prev)
8238 (gnus-summary-find-next)))
8239 ;; No more articles.
8241 ;; Select the next article and adjust point.
8242 (unless (gnus-summary-article-sparse-p
8243 (gnus-summary-article-number))
8245 (gnus-summary-select-article)
8246 (set-buffer gnus-article-buffer)
8248 (goto-char (if backward (point-max) (point-min))))))))
8249 (gnus-message 7 ""))
8250 ;; Return whether we found the regexp.
8251 (when (eq found 'found)
8253 (gnus-summary-show-thread)
8254 (gnus-summary-goto-subject gnus-current-article)
8255 (gnus-summary-position-point)
8258 (defun gnus-find-matching-articles (header regexp)
8259 "Return a list of all articles that match REGEXP on HEADER.
8260 This search includes all articles in the current group that Gnus has
8261 fetched headers for, whether they are displayed or not."
8262 (let ((articles nil)
8263 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8264 (case-fold-search t))
8265 (dolist (header gnus-newsgroup-headers)
8266 (when (string-match regexp (funcall func header))
8267 (push (mail-header-number header) articles)))
8268 (nreverse articles)))
8270 (defun gnus-summary-find-matching (header regexp &optional backward unread
8271 not-case-fold not-matching)
8272 "Return a list of all articles that match REGEXP on HEADER.
8273 The search stars on the current article and goes forwards unless
8274 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8275 If UNREAD is non-nil, only unread articles will
8276 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8277 in the comparisons. If NOT-MATCHING, return a list of all articles that
8278 not match REGEXP on HEADER."
8279 (let ((case-fold-search (not not-case-fold))
8282 (if (eq (car header) 'extra)
8285 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8287 (error "%s is an invalid header" header))
8288 (unless (fboundp (intern (concat "mail-header-" header)))
8289 (error "%s is not a valid header" header))
8290 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8291 (dolist (d (if (eq backward 'all)
8293 (gnus-data-find-list
8294 (gnus-summary-article-number)
8295 (gnus-data-list backward))))
8296 (when (and (or (not unread) ; We want all articles...
8297 (gnus-data-unread-p d)) ; Or just unreads.
8298 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8302 (funcall func (gnus-data-header d))))
8303 (string-match regexp
8304 (funcall func (gnus-data-header d)))))
8305 (push (gnus-data-number d) articles))) ; Success!
8306 (nreverse articles)))
8308 (defun gnus-summary-execute-command (header regexp command &optional backward)
8309 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8310 If HEADER is an empty string (or nil), the match is done on the entire
8311 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8313 (list (let ((completion-ignore-case t))
8316 (mapcar (lambda (header) (list (format "%s" header)))
8318 '("Number" "Subject" "From" "Lines" "Date"
8319 "Message-ID" "Xref" "References" "Body")
8320 gnus-extra-headers))
8321 nil 'require-match))
8322 (read-string "Regexp: ")
8323 (read-key-sequence "Command: ")
8324 current-prefix-arg))
8325 (when (equal header "Body")
8327 ;; Hidden thread subtrees must be searched as well.
8328 (gnus-summary-show-all-threads)
8329 ;; We don't want to change current point nor window configuration.
8331 (save-window-excursion
8333 gnus-treat-strip-trailing-blank-lines
8334 gnus-treat-strip-leading-blank-lines
8335 gnus-treat-strip-multiple-blank-lines
8336 gnus-treat-hide-boring-headers
8337 gnus-treat-fold-newsgroups
8338 gnus-article-prepare-hook)
8339 (gnus-message 6 "Executing %s..." (key-description command))
8340 ;; We'd like to execute COMMAND interactively so as to give arguments.
8341 (gnus-execute header regexp
8342 `(call-interactively ',(key-binding command))
8344 (gnus-message 6 "Executing %s...done" (key-description command))))))
8346 (defun gnus-summary-beginning-of-article ()
8347 "Scroll the article back to the beginning."
8349 (gnus-summary-select-article)
8350 (gnus-configure-windows 'article)
8351 (gnus-eval-in-buffer-window gnus-article-buffer
8353 (goto-char (point-min))
8354 (when gnus-page-broken
8355 (gnus-narrow-to-page))))
8357 (defun gnus-summary-end-of-article ()
8358 "Scroll to the end of the article."
8360 (gnus-summary-select-article)
8361 (gnus-configure-windows 'article)
8362 (gnus-eval-in-buffer-window gnus-article-buffer
8364 (goto-char (point-max))
8366 (when gnus-page-broken
8367 (gnus-narrow-to-page))))
8369 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8370 "Truncate to LEN and quote all \"(\"'s in STRING."
8371 (gnus-replace-in-string (if (and len (> (length string) len))
8372 (substring string 0 len)
8376 (defun gnus-summary-print-article (&optional filename n)
8377 "Generate and print a PostScript image of the N next (mail) articles.
8379 If N is negative, print the N previous articles. If N is nil and articles
8380 have been marked with the process mark, print these instead.
8382 If the optional first argument FILENAME is nil, send the image to the
8383 printer. If FILENAME is a string, save the PostScript image in a file with
8384 that name. If FILENAME is a number, prompt the user for the name of the file
8386 (interactive (list (ps-print-preprint current-prefix-arg)))
8387 (dolist (article (gnus-summary-work-articles n))
8388 (gnus-summary-select-article nil nil 'pseudo article)
8389 (gnus-eval-in-buffer-window gnus-article-buffer
8390 (gnus-print-buffer))
8391 (gnus-summary-remove-process-mark article))
8392 (ps-despool filename))
8394 (defun gnus-print-buffer ()
8395 (let ((buffer (generate-new-buffer " *print*")))
8398 (copy-to-buffer buffer (point-min) (point-max))
8400 (gnus-article-delete-invisible-text)
8401 (gnus-remove-text-with-property 'gnus-decoration)
8402 (when (gnus-visual-p 'article-highlight 'highlight)
8403 ;; Copy-to-buffer doesn't copy overlay. So redo
8405 (let ((gnus-article-buffer buffer))
8406 (gnus-article-highlight-citation t)
8407 (gnus-article-highlight-signature)))
8408 (let ((ps-left-header
8411 (gnus-summary-print-truncate-and-quote
8412 (mail-header-subject gnus-current-headers)
8415 (gnus-summary-print-truncate-and-quote
8416 (mail-header-from gnus-current-headers)
8420 "/pagenumberstring load"
8422 (mail-header-date gnus-current-headers) ")"))))
8423 (gnus-run-hooks 'gnus-ps-print-hook)
8426 (ps-spool-buffer-with-faces)
8427 (ps-spool-buffer)))))
8428 (kill-buffer buffer))))
8430 (defun gnus-summary-show-article (&optional arg)
8431 "Force redisplaying of the current article.
8432 If ARG (the prefix) is a number, show the article with the charset
8433 defined in `gnus-summary-show-article-charset-alist', or the charset
8435 If ARG (the prefix) is non-nil and not a number, show the raw article
8436 without any article massaging functions being run. Normally, the key strokes
8441 (gnus-summary-show-article t)
8442 (let ((gnus-newsgroup-charset
8443 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8444 (mm-read-coding-system
8445 "View as charset: " ;; actually it is coding system.
8447 (set-buffer gnus-article-buffer)
8448 (mm-detect-coding-region (point) (point-max))))))
8449 (gnus-newsgroup-ignored-charsets 'gnus-all))
8450 (gnus-summary-select-article nil 'force)
8451 (let ((deps gnus-newsgroup-dependencies)
8454 (set-buffer gnus-original-article-buffer)
8456 (message-narrow-to-head)
8457 (setq head (buffer-string))
8458 (goto-char (point-min))
8459 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8460 (goto-char (point-max))
8462 (setq lines (1- (count-lines (point) (point-max))))))
8464 (insert (format "211 %d Article retrieved.\n"
8465 (cdr gnus-article-current)))
8467 (if lines (insert (format "Lines: %d\n" lines)))
8469 (let ((nntp-server-buffer (current-buffer)))
8470 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8471 (gnus-data-set-header
8472 (gnus-data-find (cdr gnus-article-current))
8474 (gnus-summary-update-article-line
8475 (cdr gnus-article-current) header)
8476 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8477 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8479 ;; Select the article the normal way.
8480 (gnus-summary-select-article nil 'force))
8482 ;; We have to require this here to make sure that the following
8483 ;; dynamic binding isn't shadowed by autoloading.
8484 (require 'gnus-async)
8486 ;; Bind the article treatment functions to nil.
8487 (let ((gnus-have-all-headers t)
8488 gnus-article-prepare-hook
8489 gnus-article-decode-hook
8490 gnus-display-mime-function
8492 ;; Destroy any MIME parts.
8493 (when (gnus-buffer-live-p gnus-article-buffer)
8495 (set-buffer gnus-article-buffer)
8496 (mm-destroy-parts gnus-article-mime-handles)
8497 ;; Set it to nil for safety reason.
8498 (setq gnus-article-mime-handle-alist nil)
8499 (setq gnus-article-mime-handles nil)))
8500 (gnus-summary-select-article nil 'force))))
8501 (gnus-summary-goto-subject gnus-current-article)
8502 (gnus-summary-position-point))
8504 (defun gnus-summary-show-raw-article ()
8505 "Show the raw article without any article massaging functions being run."
8507 (gnus-summary-show-article t))
8509 (defun gnus-summary-verbose-headers (&optional arg)
8510 "Toggle permanent full header display.
8511 If ARG is a positive number, turn header display on.
8512 If ARG is a negative number, turn header display off."
8514 (setq gnus-show-all-headers
8515 (cond ((or (not (numberp arg))
8517 (not gnus-show-all-headers))
8520 (gnus-summary-show-article))
8522 (defun gnus-summary-toggle-header (&optional arg)
8523 "Show the headers if they are hidden, or hide them if they are shown.
8524 If ARG is a positive number, show the entire header.
8525 If ARG is a negative number, hide the unwanted header lines."
8527 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8528 (get-buffer-window gnus-article-buffer t))))
8529 (with-current-buffer gnus-article-buffer
8531 (article-narrow-to-head)
8532 (let* ((buffer-read-only nil)
8533 (inhibit-point-motion-hooks t)
8534 (hidden (if (numberp arg)
8536 (gnus-article-hidden-text-p 'headers)))
8538 (delete-region (point-min) (point-max))
8539 (with-current-buffer gnus-original-article-buffer
8540 (goto-char (setq s (point-min)))
8541 (setq e (if (search-forward "\n\n" nil t)
8544 (insert-buffer-substring gnus-original-article-buffer s e)
8545 (article-decode-encoded-words)
8547 (let ((gnus-treat-hide-headers nil)
8548 (gnus-treat-hide-boring-headers nil))
8549 (gnus-delete-wash-type 'headers)
8550 (gnus-treat-article 'head))
8551 (gnus-treat-article 'head))
8554 (set-window-start window (goto-char (point-min))))
8555 (setq gnus-page-broken
8556 (when gnus-break-pages
8557 (gnus-narrow-to-page)
8559 (gnus-set-mode-line 'article)))))
8561 (defun gnus-summary-show-all-headers ()
8562 "Make all header lines visible."
8564 (gnus-summary-toggle-header 1))
8566 (defun gnus-summary-caesar-message (&optional arg)
8567 "Caesar rotate the current article by 13.
8568 The numerical prefix specifies how many places to rotate each letter
8571 (gnus-summary-select-article)
8572 (let ((mail-header-separator ""))
8573 (gnus-eval-in-buffer-window gnus-article-buffer
8576 (let ((start (window-start))
8578 (message-caesar-buffer-body arg)
8579 (set-window-start (get-buffer-window (current-buffer)) start))))))
8581 (autoload 'unmorse-region "morse"
8582 "Convert morse coded text in region to ordinary ASCII text."
8585 (defun gnus-summary-morse-message (&optional arg)
8586 "Morse decode the current article."
8588 (gnus-summary-select-article)
8589 (let ((mail-header-separator ""))
8590 (gnus-eval-in-buffer-window gnus-article-buffer
8594 (let ((pos (window-start))
8596 (goto-char (point-min))
8597 (when (message-goto-body)
8598 (gnus-narrow-to-body))
8599 (goto-char (point-min))
8600 (while (re-search-forward "·" (point-max) t)
8601 (replace-match "."))
8602 (unmorse-region (point-min) (point-max))
8604 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8606 (defun gnus-summary-stop-page-breaking ()
8607 "Stop page breaking in the current article."
8609 (gnus-summary-select-article)
8610 (gnus-eval-in-buffer-window gnus-article-buffer
8612 (when (gnus-visual-p 'page-marker)
8613 (let ((buffer-read-only nil))
8614 (gnus-remove-text-with-property 'gnus-prev)
8615 (gnus-remove-text-with-property 'gnus-next))
8616 (setq gnus-page-broken nil))))
8618 (defun gnus-summary-move-article (&optional n to-newsgroup
8619 select-method action)
8620 "Move the current article to a different newsgroup.
8621 If N is a positive number, move the N next articles.
8622 If N is a negative number, move the N previous articles.
8623 If N is nil and any articles have been marked with the process mark,
8624 move those articles instead.
8625 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8626 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8627 re-spool using this method.
8629 When called interactively with TO-NEWSGROUP being nil, the value of
8630 the variable `gnus-move-split-methods' is used for finding a default
8631 for the target newsgroup.
8633 For this function to work, both the current newsgroup and the
8634 newsgroup that you want to move to have to support the `request-move'
8635 and `request-accept' functions.
8637 ACTION can be either `move' (the default), `crosspost' or `copy'."
8640 (setq action 'move))
8641 ;; Check whether the source group supports the required functions.
8642 (cond ((and (eq action 'move)
8643 (not (gnus-check-backend-function
8644 'request-move-article gnus-newsgroup-name)))
8645 (error "The current group does not support article moving"))
8646 ((and (eq action 'crosspost)
8647 (not (gnus-check-backend-function
8648 'request-replace-article gnus-newsgroup-name)))
8649 (error "The current group does not support article editing")))
8650 (let ((articles (gnus-summary-work-articles n))
8651 (prefix (if (gnus-check-backend-function
8652 'request-move-article gnus-newsgroup-name)
8653 (gnus-group-real-prefix gnus-newsgroup-name)
8655 (names '((move "Move" "Moving")
8656 (copy "Copy" "Copying")
8657 (crosspost "Crosspost" "Crossposting")))
8658 (copy-buf (save-excursion
8659 (nnheader-set-temp-buffer " *copy article*")))
8660 art-group to-method new-xref article to-groups)
8661 (unless (assq action names)
8662 (error "Unknown action %s" action))
8663 ;; Read the newsgroup name.
8664 (when (and (not to-newsgroup)
8665 (not select-method))
8666 (if (and gnus-move-split-methods
8668 (and (memq gnus-current-article articles)
8669 (gnus-buffer-live-p gnus-original-article-buffer))))
8670 ;; When `gnus-move-split-methods' is non-nil, we have to
8671 ;; select an article to give `gnus-read-move-group-name' an
8672 ;; opportunity to suggest an appropriate default. However,
8673 ;; we needn't render or mark the article.
8674 (let ((gnus-display-mime-function nil)
8675 (gnus-article-prepare-hook nil)
8676 (gnus-mark-article-hook nil))
8677 (gnus-summary-select-article nil nil nil (car articles))))
8679 (gnus-read-move-group-name
8680 (cadr (assq action names))
8681 (symbol-value (intern (format "gnus-current-%s-group" action)))
8683 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8684 (setq to-method (or select-method
8685 (gnus-server-to-method
8686 (gnus-group-method to-newsgroup))))
8687 ;; Check the method we are to move this article to...
8688 (unless (gnus-check-backend-function
8689 'request-accept-article (car to-method))
8690 (error "%s does not support article copying" (car to-method)))
8691 (unless (gnus-check-server to-method)
8692 (error "Can't open server %s" (car to-method)))
8693 (gnus-message 6 "%s to %s: %s..."
8694 (caddr (assq action names))
8695 (or (car select-method) to-newsgroup) articles)
8697 (setq article (pop articles))
8701 ;; Move the article.
8703 ;; Remove this article from future suppression.
8704 (gnus-dup-unsuppress-article article)
8705 (gnus-request-move-article
8706 article ; Article to move
8707 gnus-newsgroup-name ; From newsgroup
8708 (nth 1 (gnus-find-method-for-group
8709 gnus-newsgroup-name)) ; Server
8710 (list 'gnus-request-accept-article
8711 to-newsgroup (list 'quote select-method)
8712 (not articles) t) ; Accept form
8713 (not articles))) ; Only save nov last time
8714 ;; Copy the article.
8717 (set-buffer copy-buf)
8718 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8719 (gnus-request-accept-article
8720 to-newsgroup select-method (not articles) t))))
8721 ;; Crosspost the article.
8722 ((eq action 'crosspost)
8723 (let ((xref (message-tokenize-header
8724 (mail-header-xref (gnus-summary-article-header article))
8726 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8727 ":" (number-to-string article)))
8729 (setq xref (list (system-name))))
8732 (mapconcat 'identity
8733 (delete "Xref:" (delete new-xref xref))
8737 (set-buffer copy-buf)
8738 ;; First put the article in the destination group.
8739 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8740 (when (consp (setq art-group
8741 (gnus-request-accept-article
8742 to-newsgroup select-method (not articles))))
8743 (setq new-xref (concat new-xref " " (car art-group)
8745 (number-to-string (cdr art-group))))
8746 ;; Now we have the new Xrefs header, so we insert
8747 ;; it and replace the new article.
8748 (nnheader-replace-header "Xref" new-xref)
8749 (gnus-request-replace-article
8750 (cdr art-group) to-newsgroup (current-buffer))
8754 (gnus-message 1 "Couldn't %s article %s: %s"
8755 (cadr (assq action names)) article
8756 (nnheader-get-report (car to-method))))
8757 ((eq art-group 'junk)
8758 (when (eq action 'move)
8759 (gnus-summary-mark-article article gnus-canceled-mark)
8760 (gnus-message 4 "Deleted article %s" article)))
8762 (let* ((pto-group (gnus-group-prefixed-name
8763 (car art-group) to-method))
8765 (gnus-gethash pto-group gnus-newsrc-hashtb))
8766 (info (nth 2 entry))
8767 (to-group (gnus-info-group info))
8769 ;; Update the group that has been moved to.
8771 (memq action '(move copy)))
8772 (unless (member to-group to-groups)
8773 (push to-group to-groups))
8775 (unless (memq article gnus-newsgroup-unreads)
8776 (push 'read to-marks)
8778 info (gnus-add-to-range (gnus-info-read info)
8779 (list (cdr art-group)))))
8781 ;; See whether the article is to be put in the cache.
8782 (let ((marks gnus-article-mark-lists)
8783 (to-article (cdr art-group)))
8785 ;; Enter the article into the cache in the new group,
8786 ;; if that is required.
8787 (when gnus-use-cache
8788 (gnus-cache-possibly-enter-article
8790 (memq article gnus-newsgroup-marked)
8791 (memq article gnus-newsgroup-dormant)
8792 (memq article gnus-newsgroup-unreads)))
8794 (when gnus-preserve-marks
8795 ;; Copy any marks over to the new group.
8796 (when (and (equal to-group gnus-newsgroup-name)
8797 (not (memq article gnus-newsgroup-unreads)))
8798 ;; Mark this article as read in this group.
8799 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8800 (setcdr (gnus-active to-group) to-article)
8801 (setcdr gnus-newsgroup-active to-article))
8804 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8805 (when (memq article (symbol-value
8806 (intern (format "gnus-newsgroup-%s"
8808 (push (cdar marks) to-marks)
8809 ;; If the other group is the same as this group,
8810 ;; then we have to add the mark to the list.
8811 (when (equal to-group gnus-newsgroup-name)
8812 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8815 (intern (format "gnus-newsgroup-%s"
8817 ;; Copy the marks to other group.
8818 (gnus-add-marked-articles
8819 to-group (cdar marks) (list to-article) info)))
8820 (setq marks (cdr marks)))
8822 (gnus-request-set-mark
8823 to-group (list (list (list to-article) 'add to-marks))))
8826 (concat "(gnus-group-set-info '"
8827 (gnus-prin1-to-string (gnus-get-info to-group))
8830 ;; Update the Xref header in this article to point to
8831 ;; the new crossposted article we have just created.
8832 (when (eq action 'crosspost)
8834 (set-buffer copy-buf)
8835 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8836 (nnheader-replace-header "Xref" new-xref)
8837 (gnus-request-replace-article
8838 article gnus-newsgroup-name (current-buffer)))))
8840 ;;;!!!Why is this necessary?
8841 (set-buffer gnus-summary-buffer)
8843 (gnus-summary-goto-subject article)
8844 (when (eq action 'move)
8845 (gnus-summary-mark-article article gnus-canceled-mark))))
8846 (gnus-summary-remove-process-mark article))
8847 ;; Re-activate all groups that have been moved to.
8849 (set-buffer gnus-group-buffer)
8850 (let ((gnus-group-marked to-groups))
8851 (gnus-group-get-new-news-this-group nil t)))
8853 (gnus-kill-buffer copy-buf)
8854 (gnus-summary-position-point)
8855 (gnus-set-mode-line 'summary)))
8857 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8858 "Move the current article to a different newsgroup.
8859 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8860 When called interactively, if TO-NEWSGROUP is nil, use the value of
8861 the variable `gnus-move-split-methods' for finding a default target
8863 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8864 re-spool using this method."
8866 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8868 (defun gnus-summary-crosspost-article (&optional n)
8869 "Crosspost the current article to some other group."
8871 (gnus-summary-move-article n nil nil 'crosspost))
8873 (defcustom gnus-summary-respool-default-method nil
8874 "Default method type for respooling an article.
8875 If nil, use to the current newsgroup method."
8877 :group 'gnus-summary-mail)
8879 (defcustom gnus-summary-display-while-building nil
8880 "If not-nil, show and update the summary buffer as it's being built.
8881 If the value is t, update the buffer after every line is inserted. If
8882 the value is an integer (N), update the display every N lines."
8884 :type '(choice (const :tag "off" nil)
8886 (const :tag "frequently" t)))
8888 (defun gnus-summary-respool-article (&optional n method)
8889 "Respool the current article.
8890 The article will be squeezed through the mail spooling process again,
8891 which means that it will be put in some mail newsgroup or other
8892 depending on `nnmail-split-methods'.
8893 If N is a positive number, respool the N next articles.
8894 If N is a negative number, respool the N previous articles.
8895 If N is nil and any articles have been marked with the process mark,
8896 respool those articles instead.
8898 Respooling can be done both from mail groups and \"real\" newsgroups.
8899 In the former case, the articles in question will be moved from the
8900 current group into whatever groups they are destined to. In the
8901 latter case, they will be copied into the relevant groups."
8903 (list current-prefix-arg
8904 (let* ((methods (gnus-methods-using 'respool))
8906 (symbol-name (or gnus-summary-respool-default-method
8907 (car (gnus-find-method-for-group
8908 gnus-newsgroup-name)))))
8910 (gnus-completing-read-with-default
8911 methname "What backend do you want to use when respooling?"
8912 methods nil t nil 'gnus-mail-method-history))
8915 ((zerop (length (setq ms (gnus-servers-using-backend
8917 (list (intern method) ""))
8921 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8922 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8925 (error "No method given for respooling"))
8926 (if (assoc (symbol-name
8927 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8928 (gnus-methods-using 'respool))
8929 (gnus-summary-move-article n nil method)
8930 (gnus-summary-copy-article n nil method)))
8932 (defun gnus-summary-import-article (file &optional edit)
8933 "Import an arbitrary file into a mail newsgroup."
8934 (interactive "fImport file: \nP")
8935 (let ((group gnus-newsgroup-name)
8936 (now (current-time))
8937 atts lines group-art)
8938 (unless (gnus-check-backend-function 'request-accept-article group)
8939 (error "%s does not support article importing" group))
8940 (or (file-readable-p file)
8941 (not (file-regular-p file))
8942 (error "Can't read %s" file))
8944 (set-buffer (gnus-get-buffer-create " *import file*"))
8946 (nnheader-insert-file-contents file)
8947 (goto-char (point-min))
8948 (if (nnheader-article-p)
8950 (goto-char (point-min))
8951 (search-forward "\n\n" nil t)
8952 (narrow-to-region (point-min) (1- (point)))
8953 (goto-char (point-min))
8954 (unless (re-search-forward "^date:" nil t)
8955 (goto-char (point-max))
8956 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8957 ;; This doesn't look like an article, so we fudge some headers.
8958 (setq atts (file-attributes file)
8959 lines (count-lines (point-min) (point-max)))
8960 (insert "From: " (read-string "From: ") "\n"
8961 "Subject: " (read-string "Subject: ") "\n"
8962 "Date: " (message-make-date (nth 5 atts)) "\n"
8963 "Message-ID: " (message-make-message-id) "\n"
8964 "Lines: " (int-to-string lines) "\n"
8965 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8966 (setq group-art (gnus-request-accept-article group nil t))
8967 (kill-buffer (current-buffer)))
8968 (setq gnus-newsgroup-active (gnus-activate-group group))
8970 (gnus-summary-goto-article (cdr group-art) nil t)
8972 (gnus-summary-edit-article))))
8974 (defun gnus-summary-create-article ()
8975 "Create an article in a mail newsgroup."
8977 (let ((group gnus-newsgroup-name)
8978 (now (current-time))
8980 (unless (gnus-check-backend-function 'request-accept-article group)
8981 (error "%s does not support article importing" group))
8983 (set-buffer (gnus-get-buffer-create " *import file*"))
8985 (goto-char (point-min))
8986 ;; This doesn't look like an article, so we fudge some headers.
8987 (insert "From: " (read-string "From: ") "\n"
8988 "Subject: " (read-string "Subject: ") "\n"
8989 "Date: " (message-make-date now) "\n"
8990 "Message-ID: " (message-make-message-id) "\n")
8991 (setq group-art (gnus-request-accept-article group nil t))
8992 (kill-buffer (current-buffer)))
8993 (setq gnus-newsgroup-active (gnus-activate-group group))
8995 (gnus-summary-goto-article (cdr group-art) nil t)
8996 (gnus-summary-edit-article)))
8998 (defun gnus-summary-article-posted-p ()
8999 "Say whether the current (mail) article is available from news as well.
9000 This will be the case if the article has both been mailed and posted."
9002 (let ((id (mail-header-references (gnus-summary-article-header)))
9003 (gnus-override-method (car (gnus-refer-article-methods))))
9004 (if (gnus-request-head id "")
9005 (gnus-message 2 "The current message was found on %s"
9006 gnus-override-method)
9007 (gnus-message 2 "The current message couldn't be found on %s"
9008 gnus-override-method)
9011 (defun gnus-summary-expire-articles (&optional now)
9012 "Expire all articles that are marked as expirable in the current group."
9014 (when (gnus-check-backend-function
9015 'request-expire-articles gnus-newsgroup-name)
9016 ;; This backend supports expiry.
9017 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9018 (expirable (if total
9020 ;; We need to update the info for
9021 ;; this group for `gnus-list-of-read-articles'
9022 ;; to give us the right answer.
9023 (gnus-run-hooks 'gnus-exit-group-hook)
9024 (gnus-summary-update-info)
9025 (gnus-list-of-read-articles gnus-newsgroup-name))
9026 (setq gnus-newsgroup-expirable
9027 (sort gnus-newsgroup-expirable '<))))
9028 (expiry-wait (if now 'immediate
9029 (gnus-group-find-parameter
9030 gnus-newsgroup-name 'expiry-wait)))
9031 (nnmail-expiry-target
9032 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9033 nnmail-expiry-target))
9036 ;; There are expirable articles in this group, so we run them
9037 ;; through the expiry process.
9038 (gnus-message 6 "Expiring articles...")
9039 (unless (gnus-check-group gnus-newsgroup-name)
9040 (error "Can't open server for %s" gnus-newsgroup-name))
9041 ;; The list of articles that weren't expired is returned.
9044 (let ((nnmail-expiry-wait-function nil)
9045 (nnmail-expiry-wait expiry-wait))
9046 (setq es (gnus-request-expire-articles
9047 expirable gnus-newsgroup-name)))
9048 (setq es (gnus-request-expire-articles
9049 expirable gnus-newsgroup-name)))
9051 (setq gnus-newsgroup-expirable es))
9052 ;; We go through the old list of expirable, and mark all
9053 ;; really expired articles as nonexistent.
9054 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9055 (let ((gnus-use-cache nil))
9056 (dolist (article expirable)
9057 (when (and (not (memq article es))
9058 (gnus-data-find article))
9059 (gnus-summary-mark-article article gnus-canceled-mark))))))
9060 (gnus-message 6 "Expiring articles...done")))))
9062 (defun gnus-summary-expire-articles-now ()
9063 "Expunge all expirable articles in the current group.
9064 This means that *all* articles that are marked as expirable will be
9065 deleted forever, right now."
9067 (or gnus-expert-user
9069 "Are you really, really, really sure you want to delete all these messages? ")
9071 (gnus-summary-expire-articles t))
9073 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9074 (defun gnus-summary-delete-article (&optional n)
9075 "Delete the N next (mail) articles.
9076 This command actually deletes articles. This is not a marking
9077 command. The article will disappear forever from your life, never to
9079 If N is negative, delete backwards.
9080 If N is nil and articles have been marked with the process mark,
9081 delete these instead."
9083 (unless (gnus-check-backend-function 'request-expire-articles
9084 gnus-newsgroup-name)
9085 (error "The current newsgroup does not support article deletion"))
9086 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9087 (error "Couldn't open server"))
9088 ;; Compute the list of articles to delete.
9089 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9090 (nnmail-expiry-target 'delete)
9092 (if (and gnus-novice-user
9093 (not (gnus-yes-or-no-p
9094 (format "Do you really want to delete %s forever? "
9095 (if (> (length articles) 1)
9096 (format "these %s articles" (length articles))
9099 ;; Delete the articles.
9100 (setq not-deleted (gnus-request-expire-articles
9101 articles gnus-newsgroup-name 'force))
9103 (gnus-summary-remove-process-mark (car articles))
9104 ;; The backend might not have been able to delete the article
9106 (unless (memq (car articles) not-deleted)
9107 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9108 (setq articles (cdr articles)))
9110 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9111 (gnus-summary-position-point)
9112 (gnus-set-mode-line 'summary)
9115 (defun gnus-summary-edit-article (&optional arg)
9116 "Edit the current article.
9117 This will have permanent effect only in mail groups.
9118 If ARG is nil, edit the decoded articles.
9119 If ARG is 1, edit the raw articles.
9120 If ARG is 2, edit the raw articles even in read-only groups.
9121 If ARG is 3, edit the articles with the current handles.
9122 Otherwise, allow editing of articles even in read-only
9125 (let (force raw current-handles)
9134 (setq current-handles
9135 (and (gnus-buffer-live-p gnus-article-buffer)
9136 (with-current-buffer gnus-article-buffer
9138 gnus-article-mime-handles
9139 (setq gnus-article-mime-handles nil))))))
9142 (when (and raw (not force)
9143 (member gnus-newsgroup-name '("nndraft:delayed"
9146 (error "Can't edit the raw article in group %s"
9147 gnus-newsgroup-name))
9149 (set-buffer gnus-summary-buffer)
9150 (let ((mail-parse-charset gnus-newsgroup-charset)
9151 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9152 (gnus-set-global-variables)
9153 (when (and (not force)
9154 (gnus-group-read-only-p))
9155 (error "The current newsgroup does not support article editing"))
9156 (gnus-summary-show-article t)
9157 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9158 (with-current-buffer gnus-article-buffer
9159 (mm-enable-multibyte)))
9160 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9162 (gnus-article-edit-article
9165 (let ((mbl mml-buffer-list))
9166 (setq mml-buffer-list nil)
9167 (mime-to-mml ,'current-handles)
9168 (let ((mbl1 mml-buffer-list))
9169 (setq mml-buffer-list mbl)
9170 (set (make-local-variable 'mml-buffer-list) mbl1))
9171 (make-local-hook 'kill-buffer-hook)
9172 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9173 `(lambda (no-highlight)
9174 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9175 (message-options message-options)
9176 (message-options-set-recipient)
9177 (mail-parse-ignored-charsets
9178 ',gnus-newsgroup-ignored-charsets))
9179 ,(if (not raw) '(progn
9181 (mml-destroy-buffers)
9182 (remove-hook 'kill-buffer-hook
9183 'mml-destroy-buffers t)
9184 (kill-local-variable 'mml-buffer-list)))
9185 (gnus-summary-edit-article-done
9186 ,(or (mail-header-references gnus-current-headers) "")
9187 ,(gnus-group-read-only-p)
9188 ,gnus-summary-buffer no-highlight))))))))
9190 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9192 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9194 "Make edits to the current article permanent."
9197 ;; The buffer restriction contains the entire article if it exists.
9198 (when (article-goto-body)
9199 (let ((lines (count-lines (point) (point-max)))
9200 (length (- (point-max) (point)))
9201 (case-fold-search t)
9202 (body (copy-marker (point))))
9203 (goto-char (point-min))
9204 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9205 (delete-region (match-beginning 1) (match-end 1))
9206 (insert (number-to-string length)))
9207 (goto-char (point-min))
9208 (when (re-search-forward
9209 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9210 (delete-region (match-beginning 1) (match-end 1))
9211 (insert (number-to-string length)))
9212 (goto-char (point-min))
9213 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9214 (delete-region (match-beginning 1) (match-end 1))
9215 (insert (number-to-string lines))))))
9216 ;; Replace the article.
9217 (let ((buf (current-buffer)))
9219 (insert-buffer-substring buf)
9221 (if (and (not read-only)
9222 (not (gnus-request-replace-article
9223 (cdr gnus-article-current) (car gnus-article-current)
9224 (current-buffer) t)))
9225 (error "Couldn't replace article")
9226 ;; Update the summary buffer.
9228 (equal (message-tokenize-header references " ")
9229 (message-tokenize-header
9230 (or (message-fetch-field "references") "") " ")))
9231 ;; We only have to update this line.
9234 (message-narrow-to-head)
9235 (let ((head (buffer-string))
9238 (insert (format "211 %d Article retrieved.\n"
9239 (cdr gnus-article-current)))
9242 (let ((nntp-server-buffer (current-buffer)))
9243 (setq header (car (gnus-get-newsgroup-headers
9246 (set-buffer gnus-summary-buffer)
9247 (gnus-data-set-header
9248 (gnus-data-find (cdr gnus-article-current))
9250 (gnus-summary-update-article-line
9251 (cdr gnus-article-current) header)
9252 (if (gnus-summary-goto-subject
9253 (cdr gnus-article-current) nil t)
9254 (gnus-summary-update-secondary-mark
9255 (cdr gnus-article-current))))))))
9257 (set-buffer (or buffer gnus-summary-buffer))
9258 (gnus-summary-update-article (cdr gnus-article-current))
9259 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9260 (gnus-summary-update-secondary-mark
9261 (cdr gnus-article-current))))
9262 ;; Prettify the article buffer again.
9263 (unless no-highlight
9265 (set-buffer gnus-article-buffer)
9266 ;;;!!! Fix this -- article should be rehighlighted.
9267 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9268 (set-buffer gnus-original-article-buffer)
9269 (gnus-request-article
9270 (cdr gnus-article-current)
9271 (car gnus-article-current) (current-buffer))))
9272 ;; Prettify the summary buffer line.
9273 (when (gnus-visual-p 'summary-highlight 'highlight)
9274 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9276 (defun gnus-summary-edit-wash (key)
9277 "Perform editing command KEY in the article buffer."
9281 (message "%s" (concat (this-command-keys) "- "))
9284 (gnus-summary-edit-article)
9285 (execute-kbd-macro (concat (this-command-keys) key))
9286 (gnus-article-edit-done))
9290 (defun gnus-summary-respool-query (&optional silent trace)
9291 "Query where the respool algorithm would put this article."
9293 (let (gnus-mark-article-hook)
9294 (gnus-summary-select-article)
9296 (set-buffer gnus-original-article-buffer)
9298 (message-narrow-to-head)
9299 (let ((groups (nnmail-article-group 'identity trace)))
9302 (message "This message would go to %s"
9303 (mapconcat 'car groups ", "))
9304 (message "This message would go to no groups"))
9307 (defun gnus-summary-respool-trace ()
9308 "Trace where the respool algorithm would put this article.
9309 Display a buffer showing all fancy splitting patterns which matched."
9311 (gnus-summary-respool-query nil t))
9313 ;; Summary marking commands.
9315 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9316 "Mark articles which has the same subject as read, and then select the next.
9317 If UNMARK is positive, remove any kind of mark.
9318 If UNMARK is negative, tick articles."
9321 (setq unmark (prefix-numeric-value unmark)))
9323 (gnus-summary-mark-same-subject
9324 (gnus-summary-article-subject) unmark)))
9325 ;; Select next unread article. If auto-select-same mode, should
9326 ;; select the first unread article.
9327 (gnus-summary-next-article t (and gnus-auto-select-same
9328 (gnus-summary-article-subject)))
9329 (gnus-message 7 "%d article%s marked as %s"
9330 count (if (= count 1) " is" "s are")
9331 (if unmark "unread" "read"))))
9333 (defun gnus-summary-kill-same-subject (&optional unmark)
9334 "Mark articles which has the same subject as read.
9335 If UNMARK is positive, remove any kind of mark.
9336 If UNMARK is negative, tick articles."
9339 (setq unmark (prefix-numeric-value unmark)))
9341 (gnus-summary-mark-same-subject
9342 (gnus-summary-article-subject) unmark)))
9343 ;; If marked as read, go to next unread subject.
9345 ;; Go to next unread subject.
9346 (gnus-summary-next-subject 1 t))
9347 (gnus-message 7 "%d articles are marked as %s"
9348 count (if unmark "unread" "read"))))
9350 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9351 "Mark articles with same SUBJECT as read, and return marked number.
9352 If optional argument UNMARK is positive, remove any kinds of marks.
9353 If optional argument UNMARK is negative, mark articles as unread instead."
9357 ((null unmark) ; Mark as read.
9360 (gnus-summary-mark-article-as-read gnus-killed-mark)
9361 (gnus-summary-show-thread) t)
9362 (gnus-summary-find-subject subject))
9363 (setq count (1+ count))))
9364 ((> unmark 0) ; Tick.
9367 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9368 (gnus-summary-show-thread) t)
9369 (gnus-summary-find-subject subject))
9370 (setq count (1+ count))))
9371 (t ; Mark as unread.
9374 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9375 (gnus-summary-show-thread) t)
9376 (gnus-summary-find-subject subject))
9377 (setq count (1+ count)))))
9378 (gnus-set-mode-line 'summary)
9379 ;; Return the number of marked articles.
9382 (defun gnus-summary-mark-as-processable (n &optional unmark)
9383 "Set the process mark on the next N articles.
9384 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9385 the process mark instead. The difference between N and the actual
9386 number of articles marked is returned."
9388 (if (and (null n) (gnus-region-active-p))
9389 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9390 (setq n (prefix-numeric-value n))
9391 (let ((backward (< n 0))
9396 (gnus-summary-remove-process-mark
9397 (gnus-summary-article-number))
9398 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9399 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9402 (gnus-message 7 "No more articles"))
9403 (gnus-summary-recenter)
9404 (gnus-summary-position-point)
9407 (defun gnus-summary-unmark-as-processable (n)
9408 "Remove the process mark from the next N articles.
9409 If N is negative, unmark backward instead. The difference between N and
9410 the actual number of articles unmarked is returned."
9412 (gnus-summary-mark-as-processable n t))
9414 (defun gnus-summary-unmark-all-processable ()
9415 "Remove the process mark from all articles."
9418 (while gnus-newsgroup-processable
9419 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9420 (gnus-summary-position-point))
9422 (defun gnus-summary-add-mark (article type)
9423 "Mark ARTICLE with a mark of TYPE."
9424 (let ((vtype (car (assq type gnus-article-mark-lists)))
9427 (error "No such mark type: %s" type)
9428 (setq var (intern (format "gnus-newsgroup-%s" type)))
9429 (set var (cons article (symbol-value var)))
9430 (if (memq type '(processable cached replied forwarded recent saved))
9431 (gnus-summary-update-secondary-mark article)
9432 ;;; !!! This is bogus. We should find out what primary
9433 ;;; !!! mark we want to set.
9434 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9436 (defun gnus-summary-mark-as-expirable (n)
9437 "Mark N articles forward as expirable.
9438 If N is negative, mark backward instead. The difference between N and
9439 the actual number of articles marked is returned."
9441 (gnus-summary-mark-forward n gnus-expirable-mark))
9443 (defun gnus-summary-mark-as-spam (n)
9444 "Mark N articles forward as spam.
9445 If N is negative, mark backward instead. The difference between N and
9446 the actual number of articles marked is returned."
9448 (gnus-summary-mark-forward n gnus-spam-mark))
9450 (defun gnus-summary-mark-article-as-replied (article)
9451 "Mark ARTICLE as replied to and update the summary line.
9452 ARTICLE can also be a list of articles."
9453 (interactive (list (gnus-summary-article-number)))
9454 (let ((articles (if (listp article) article (list article))))
9455 (dolist (article articles)
9456 (unless (numberp article)
9457 (error "%s is not a number" article))
9458 (push article gnus-newsgroup-replied)
9459 (let ((buffer-read-only nil))
9460 (when (gnus-summary-goto-subject article nil t)
9461 (gnus-summary-update-secondary-mark article))))))
9463 (defun gnus-summary-mark-article-as-forwarded (article)
9464 "Mark ARTICLE as forwarded and update the summary line.
9465 ARTICLE can also be a list of articles."
9466 (let ((articles (if (listp article) article (list article))))
9467 (dolist (article articles)
9468 (push article gnus-newsgroup-forwarded)
9469 (let ((buffer-read-only nil))
9470 (when (gnus-summary-goto-subject article nil t)
9471 (gnus-summary-update-secondary-mark article))))))
9473 (defun gnus-summary-set-bookmark (article)
9474 "Set a bookmark in current article."
9475 (interactive (list (gnus-summary-article-number)))
9476 (when (or (not (get-buffer gnus-article-buffer))
9477 (not gnus-current-article)
9478 (not gnus-article-current)
9479 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9480 (error "No current article selected"))
9481 ;; Remove old bookmark, if one exists.
9482 (gnus-pull article gnus-newsgroup-bookmarks)
9483 ;; Set the new bookmark, which is on the form
9484 ;; (article-number . line-number-in-body).
9488 (set-buffer gnus-article-buffer)
9495 gnus-newsgroup-bookmarks)
9496 (gnus-message 6 "A bookmark has been added to the current article."))
9498 (defun gnus-summary-remove-bookmark (article)
9499 "Remove the bookmark from the current article."
9500 (interactive (list (gnus-summary-article-number)))
9501 ;; Remove old bookmark, if one exists.
9502 (if (not (assq article gnus-newsgroup-bookmarks))
9503 (gnus-message 6 "No bookmark in current article.")
9504 (gnus-pull article gnus-newsgroup-bookmarks)
9505 (gnus-message 6 "Removed bookmark.")))
9507 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9508 (defun gnus-summary-mark-as-dormant (n)
9509 "Mark N articles forward as dormant.
9510 If N is negative, mark backward instead. The difference between N and
9511 the actual number of articles marked is returned."
9513 (gnus-summary-mark-forward n gnus-dormant-mark))
9515 (defun gnus-summary-set-process-mark (article)
9516 "Set the process mark on ARTICLE and update the summary line."
9517 (setq gnus-newsgroup-processable
9519 (delq article gnus-newsgroup-processable)))
9520 (when (gnus-summary-goto-subject article)
9521 (gnus-summary-show-thread)
9522 (gnus-summary-goto-subject article)
9523 (gnus-summary-update-secondary-mark article)))
9525 (defun gnus-summary-remove-process-mark (article)
9526 "Remove the process mark from ARTICLE and update the summary line."
9527 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9528 (when (gnus-summary-goto-subject article)
9529 (gnus-summary-show-thread)
9530 (gnus-summary-goto-subject article)
9531 (gnus-summary-update-secondary-mark article)))
9533 (defun gnus-summary-set-saved-mark (article)
9534 "Set the process mark on ARTICLE and update the summary line."
9535 (push article gnus-newsgroup-saved)
9536 (when (gnus-summary-goto-subject article)
9537 (gnus-summary-update-secondary-mark article)))
9539 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9540 "Mark N articles as read forwards.
9541 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9542 The difference between N and the actual number of articles marked is
9544 If NO-EXPIRE, auto-expiry will be inhibited."
9546 (gnus-summary-show-thread)
9547 (let ((backward (< n 0))
9548 (gnus-summary-goto-unread
9549 (and gnus-summary-goto-unread
9550 (not (eq gnus-summary-goto-unread 'never))
9551 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9552 gnus-ticked-mark gnus-dormant-mark)))))
9554 (mark (or mark gnus-del-mark)))
9556 (gnus-summary-mark-article nil mark no-expire)
9557 (zerop (gnus-summary-next-subject
9559 (and gnus-summary-goto-unread
9560 (not (eq gnus-summary-goto-unread 'never)))
9564 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9565 (gnus-summary-recenter)
9566 (gnus-summary-position-point)
9567 (gnus-set-mode-line 'summary)
9570 (defun gnus-summary-mark-article-as-read (mark)
9571 "Mark the current article quickly as read with MARK."
9572 (let ((article (gnus-summary-article-number)))
9573 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9574 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9575 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9576 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9577 (push (cons article mark) gnus-newsgroup-reads)
9578 ;; Possibly remove from cache, if that is used.
9579 (when gnus-use-cache
9580 (gnus-cache-enter-remove-article article))
9581 ;; Allow the backend to change the mark.
9582 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9583 ;; Check for auto-expiry.
9584 (when (and gnus-newsgroup-auto-expire
9585 (memq mark gnus-auto-expirable-marks))
9586 (setq mark gnus-expirable-mark)
9587 ;; Let the backend know about the mark change.
9588 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9589 (push article gnus-newsgroup-expirable))
9590 ;; Set the mark in the buffer.
9591 (gnus-summary-update-mark mark 'unread)
9594 (defun gnus-summary-mark-article-as-unread (mark)
9595 "Mark the current article quickly as unread with MARK."
9596 (let* ((article (gnus-summary-article-number))
9597 (old-mark (gnus-summary-article-mark article)))
9598 ;; Allow the backend to change the mark.
9599 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9600 (if (eq mark old-mark)
9604 (gnus-error 1 "Can't mark negative article numbers")
9606 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9607 (setq gnus-newsgroup-spam-marked
9608 (delq article gnus-newsgroup-spam-marked))
9609 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9610 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9611 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9612 (cond ((= mark gnus-ticked-mark)
9613 (setq gnus-newsgroup-marked
9614 (gnus-add-to-sorted-list gnus-newsgroup-marked
9616 ((= mark gnus-spam-mark)
9617 (setq gnus-newsgroup-spam-marked
9618 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9620 ((= mark gnus-dormant-mark)
9621 (setq gnus-newsgroup-dormant
9622 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9625 (setq gnus-newsgroup-unreads
9626 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9628 (gnus-pull article gnus-newsgroup-reads)
9630 ;; See whether the article is to be put in the cache.
9632 (vectorp (gnus-summary-article-header article))
9634 (gnus-cache-possibly-enter-article
9635 gnus-newsgroup-name article
9636 (= mark gnus-ticked-mark)
9637 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9640 (gnus-summary-update-mark mark 'unread)
9643 (defun gnus-summary-mark-article (&optional article mark no-expire)
9644 "Mark ARTICLE with MARK. MARK can be any character.
9645 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9646 `??' (dormant) and `?E' (expirable).
9647 If MARK is nil, then the default character `?r' is used.
9648 If ARTICLE is nil, then the article on the current line will be
9650 If NO-EXPIRE, auto-expiry will be inhibited."
9651 ;; The mark might be a string.
9652 (when (stringp mark)
9653 (setq mark (aref mark 0)))
9654 ;; If no mark is given, then we check auto-expiring.
9656 (setq mark gnus-del-mark))
9657 (when (and (not no-expire)
9658 gnus-newsgroup-auto-expire
9659 (memq mark gnus-auto-expirable-marks))
9660 (setq mark gnus-expirable-mark))
9661 (let ((article (or article (gnus-summary-article-number)))
9662 (old-mark (gnus-summary-article-mark article)))
9663 ;; Allow the backend to change the mark.
9664 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9665 (if (eq mark old-mark)
9668 (error "No article on current line"))
9669 (if (not (if (or (= mark gnus-unread-mark)
9670 (= mark gnus-ticked-mark)
9671 (= mark gnus-spam-mark)
9672 (= mark gnus-dormant-mark))
9673 (gnus-mark-article-as-unread article mark)
9674 (gnus-mark-article-as-read article mark)))
9676 ;; See whether the article is to be put in the cache.
9678 (not (= mark gnus-canceled-mark))
9679 (vectorp (gnus-summary-article-header article))
9681 (gnus-cache-possibly-enter-article
9682 gnus-newsgroup-name article
9683 (= mark gnus-ticked-mark)
9684 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9686 (when (gnus-summary-goto-subject article nil t)
9687 (let ((buffer-read-only nil))
9688 (gnus-summary-show-thread)
9690 (gnus-summary-update-mark mark 'unread)
9693 (defun gnus-summary-update-secondary-mark (article)
9694 "Update the secondary (read, process, cache) mark."
9695 (gnus-summary-update-mark
9696 (cond ((memq article gnus-newsgroup-processable)
9698 ((memq article gnus-newsgroup-cached)
9700 ((memq article gnus-newsgroup-replied)
9702 ((memq article gnus-newsgroup-forwarded)
9703 gnus-forwarded-mark)
9704 ((memq article gnus-newsgroup-saved)
9706 ((memq article gnus-newsgroup-recent)
9708 ((memq article gnus-newsgroup-unseen)
9712 (when (gnus-visual-p 'summary-highlight 'highlight)
9713 (gnus-run-hooks 'gnus-summary-update-hook))
9716 (defun gnus-summary-update-download-mark (article)
9717 "Update the secondary (read, process, cache) mark."
9718 (gnus-summary-update-mark
9719 (cond ((memq article gnus-newsgroup-undownloaded)
9720 gnus-undownloaded-mark)
9721 (gnus-newsgroup-agentized
9722 gnus-downloaded-mark)
9726 (gnus-summary-update-line t)
9729 (defun gnus-summary-update-mark (mark type)
9730 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9731 (buffer-read-only nil))
9732 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9734 (when (looking-at "\r")
9736 (when (<= (+ forward (point)) (point-max))
9737 ;; Go to the right position on the line.
9738 (goto-char (+ forward (point)))
9739 ;; Replace the old mark with the new mark.
9740 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9741 ;; Optionally update the marks by some user rule.
9742 (when (eq type 'unread)
9744 (gnus-data-find (gnus-summary-article-number)) mark)
9745 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9747 (defun gnus-mark-article-as-read (article &optional mark)
9748 "Enter ARTICLE in the pertinent lists and remove it from others."
9749 ;; Make the article expirable.
9750 (let ((mark (or mark gnus-del-mark)))
9751 (setq gnus-newsgroup-expirable
9752 (if (= mark gnus-expirable-mark)
9753 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9754 (delq article gnus-newsgroup-expirable)))
9755 ;; Remove from unread and marked lists.
9756 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9757 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9758 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9759 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9760 (push (cons article mark) gnus-newsgroup-reads)
9761 ;; Possibly remove from cache, if that is used.
9762 (when gnus-use-cache
9763 (gnus-cache-enter-remove-article article))
9766 (defun gnus-mark-article-as-unread (article &optional mark)
9767 "Enter ARTICLE in the pertinent lists and remove it from others."
9768 (let ((mark (or mark gnus-ticked-mark)))
9771 (gnus-error 1 "Can't mark negative article numbers")
9773 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9774 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9775 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9776 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9777 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9779 ;; Unsuppress duplicates?
9780 (when gnus-suppress-duplicates
9781 (gnus-dup-unsuppress-article article))
9783 (cond ((= mark gnus-ticked-mark)
9784 (setq gnus-newsgroup-marked
9785 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9786 ((= mark gnus-spam-mark)
9787 (setq gnus-newsgroup-spam-marked
9788 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9790 ((= mark gnus-dormant-mark)
9791 (setq gnus-newsgroup-dormant
9792 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9794 (setq gnus-newsgroup-unreads
9795 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9796 (gnus-pull article gnus-newsgroup-reads)
9799 (defalias 'gnus-summary-mark-as-unread-forward
9800 'gnus-summary-tick-article-forward)
9801 (make-obsolete 'gnus-summary-mark-as-unread-forward
9802 'gnus-summary-tick-article-forward)
9803 (defun gnus-summary-tick-article-forward (n)
9804 "Tick N articles forwards.
9805 If N is negative, tick backwards instead.
9806 The difference between N and the number of articles ticked is returned."
9808 (gnus-summary-mark-forward n gnus-ticked-mark))
9810 (defalias 'gnus-summary-mark-as-unread-backward
9811 'gnus-summary-tick-article-backward)
9812 (make-obsolete 'gnus-summary-mark-as-unread-backward
9813 'gnus-summary-tick-article-backward)
9814 (defun gnus-summary-tick-article-backward (n)
9815 "Tick N articles backwards.
9816 The difference between N and the number of articles ticked is returned."
9818 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9820 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9821 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9822 (defun gnus-summary-tick-article (&optional article clear-mark)
9823 "Mark current article as unread.
9824 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9825 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9827 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9830 (defun gnus-summary-mark-as-read-forward (n)
9831 "Mark N articles as read forwards.
9832 If N is negative, mark backwards instead.
9833 The difference between N and the actual number of articles marked is
9836 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9838 (defun gnus-summary-mark-as-read-backward (n)
9839 "Mark the N articles as read backwards.
9840 The difference between N and the actual number of articles marked is
9843 (gnus-summary-mark-forward
9844 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9846 (defun gnus-summary-mark-as-read (&optional article mark)
9847 "Mark current article as read.
9848 ARTICLE specifies the article to be marked as read.
9849 MARK specifies a string to be inserted at the beginning of the line."
9850 (gnus-summary-mark-article article mark))
9852 (defun gnus-summary-clear-mark-forward (n)
9853 "Clear marks from N articles forward.
9854 If N is negative, clear backward instead.
9855 The difference between N and the number of marks cleared is returned."
9857 (gnus-summary-mark-forward n gnus-unread-mark))
9859 (defun gnus-summary-clear-mark-backward (n)
9860 "Clear marks from N articles backward.
9861 The difference between N and the number of marks cleared is returned."
9863 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9865 (defun gnus-summary-mark-unread-as-read ()
9866 "Intended to be used by `gnus-summary-mark-article-hook'."
9867 (when (memq gnus-current-article gnus-newsgroup-unreads)
9868 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9870 (defun gnus-summary-mark-read-and-unread-as-read ()
9871 "Intended to be used by `gnus-summary-mark-article-hook'."
9872 (let ((mark (gnus-summary-article-mark)))
9873 (when (or (gnus-unread-mark-p mark)
9874 (gnus-read-mark-p mark))
9875 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9877 (defun gnus-summary-mark-unread-as-ticked ()
9878 "Intended to be used by `gnus-summary-mark-article-hook'."
9879 (when (memq gnus-current-article gnus-newsgroup-unreads)
9880 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9882 (defun gnus-summary-mark-region-as-read (point mark all)
9883 "Mark all unread articles between point and mark as read.
9884 If given a prefix, mark all articles between point and mark as read,
9885 even ticked and dormant ones."
9886 (interactive "r\nP")
9895 (memq (setq article (gnus-summary-article-number))
9896 gnus-newsgroup-unreads))
9897 (gnus-summary-mark-article article gnus-del-mark))
9899 (gnus-summary-find-next))))))
9901 (defun gnus-summary-mark-below (score mark)
9902 "Mark articles with score less than SCORE with MARK."
9903 (interactive "P\ncMark: ")
9904 (setq score (if score
9905 (prefix-numeric-value score)
9906 (or gnus-summary-default-score 0)))
9908 (set-buffer gnus-summary-buffer)
9909 (goto-char (point-min))
9912 (and (< (gnus-summary-article-score) score)
9913 (gnus-summary-mark-article nil mark))
9914 (gnus-summary-find-next)))))
9916 (defun gnus-summary-kill-below (&optional score)
9917 "Mark articles with score below SCORE as read."
9919 (gnus-summary-mark-below score gnus-killed-mark))
9921 (defun gnus-summary-clear-above (&optional score)
9922 "Clear all marks from articles with score above SCORE."
9924 (gnus-summary-mark-above score gnus-unread-mark))
9926 (defun gnus-summary-tick-above (&optional score)
9927 "Tick all articles with score above SCORE."
9929 (gnus-summary-mark-above score gnus-ticked-mark))
9931 (defun gnus-summary-mark-above (score mark)
9932 "Mark articles with score over SCORE with MARK."
9933 (interactive "P\ncMark: ")
9934 (setq score (if score
9935 (prefix-numeric-value score)
9936 (or gnus-summary-default-score 0)))
9938 (set-buffer gnus-summary-buffer)
9939 (goto-char (point-min))
9941 (when (> (gnus-summary-article-score) score)
9942 (gnus-summary-mark-article nil mark))
9944 (gnus-summary-find-next)))))
9946 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9947 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9948 (defun gnus-summary-limit-include-expunged (&optional no-error)
9949 "Display all the hidden articles that were expunged for low scores."
9951 (let ((buffer-read-only nil))
9952 (let ((scored gnus-newsgroup-scored)
9955 (unless (gnus-summary-article-header (caar scored))
9956 (and (setq h (gnus-number-to-header (caar scored)))
9957 (< (cdar scored) gnus-summary-expunge-below)
9959 (setq scored (cdr scored)))
9961 (when (not no-error)
9962 (error "No expunged articles hidden"))
9963 (goto-char (point-min))
9964 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9965 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9966 (mapcar (lambda (x) (push (mail-header-number x)
9967 gnus-newsgroup-limit))
9969 (gnus-summary-prepare-unthreaded (nreverse headers))
9970 (goto-char (point-min))
9971 (gnus-summary-position-point)
9974 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9975 "Mark all unread articles in this newsgroup as read.
9976 If prefix argument ALL is non-nil, ticked and dormant articles will
9977 also be marked as read.
9978 If QUIETLY is non-nil, no questions will be asked.
9979 If TO-HERE is non-nil, it should be a point in the buffer. All
9980 articles before (after, if REVERSE is set) this point will be marked as read.
9981 Note that this function will only catch up the unread article
9982 in the current summary buffer limitation.
9983 The number of articles marked as read is returned."
9988 (not gnus-interactive-catchup) ;Without confirmation?
9992 "Mark absolutely all articles as read? "
9993 "Mark all unread articles as read? ")))
9995 (not gnus-newsgroup-adaptive)
9996 (not gnus-newsgroup-auto-expire)
9997 (not gnus-suppress-duplicates)
9998 (or (not gnus-use-cache)
9999 (eq gnus-use-cache 'passive)))
10002 (setq gnus-newsgroup-marked nil
10003 gnus-newsgroup-spam-marked nil
10004 gnus-newsgroup-dormant nil))
10005 (setq gnus-newsgroup-unreads
10006 (gnus-sorted-nunion
10007 (gnus-intersection gnus-newsgroup-unreads
10008 gnus-newsgroup-downloadable)
10009 gnus-newsgroup-unfetched)))
10010 ;; We actually mark all articles as canceled, which we
10011 ;; have to do when using auto-expiry or adaptive scoring.
10012 (gnus-summary-show-all-threads)
10013 (if (and to-here reverse)
10015 (goto-char to-here)
10017 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10018 (gnus-summary-find-next (not all)))))
10019 (when (gnus-summary-first-subject (not all))
10021 (if to-here (< (point) to-here) t)
10022 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10023 (gnus-summary-find-next (not all))))))
10024 (gnus-set-mode-line 'summary))
10026 (gnus-summary-position-point)))
10028 (defun gnus-summary-catchup-to-here (&optional all)
10029 "Mark all unticked articles before the current one as read.
10030 If ALL is non-nil, also mark ticked and dormant articles as read."
10033 (gnus-save-hidden-threads
10034 (let ((beg (point)))
10035 ;; We check that there are unread articles.
10036 (when (or all (gnus-summary-find-prev))
10037 (gnus-summary-catchup all t beg)))))
10038 (gnus-summary-position-point))
10040 (defun gnus-summary-catchup-from-here (&optional all)
10041 "Mark all unticked articles after the current one as read.
10042 If ALL is non-nil, also mark ticked and dormant articles as read."
10045 (gnus-save-hidden-threads
10046 (let ((beg (point)))
10047 ;; We check that there are unread articles.
10048 (when (or all (gnus-summary-find-next))
10049 (gnus-summary-catchup all t beg nil t)))))
10051 (gnus-summary-position-point))
10052 (defun gnus-summary-catchup-all (&optional quietly)
10053 "Mark all articles in this newsgroup as read.
10054 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10055 instead, which marks only unread articles as read."
10057 (gnus-summary-catchup t quietly))
10059 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10060 "Mark all unread articles in this group as read, then exit.
10061 If prefix argument ALL is non-nil, all articles are marked as read.
10062 If QUIETLY is non-nil, no questions will be asked."
10064 (when (gnus-summary-catchup all quietly nil 'fast)
10065 ;; Select next newsgroup or exit.
10066 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10067 (eq gnus-auto-select-next 'quietly))
10068 (gnus-summary-next-group nil)
10069 (gnus-summary-exit))))
10071 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10072 "Mark all articles in this newsgroup as read, and then exit.
10073 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10074 instead, which marks only unread articles as read."
10076 (gnus-summary-catchup-and-exit t quietly))
10078 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10079 "Mark all articles in this group as read and select the next group.
10080 If given a prefix, mark all articles, unread as well as ticked, as
10084 (gnus-summary-catchup all))
10085 (gnus-summary-next-group))
10091 (defmacro gnus-with-article (article &rest forms)
10092 "Select ARTICLE and perform FORMS in the original article buffer.
10093 Then replace the article with the result."
10095 ;; We don't want the article to be marked as read.
10096 (let (gnus-mark-article-hook)
10097 (gnus-summary-select-article t t nil ,article))
10098 (set-buffer gnus-original-article-buffer)
10100 (if (not (gnus-check-backend-function
10101 'request-replace-article (car gnus-article-current)))
10102 (gnus-message 5 "Read-only group; not replacing")
10103 (unless (gnus-request-replace-article
10104 ,article (car gnus-article-current)
10105 (current-buffer) t)
10106 (error "Couldn't replace article")))
10107 ;; The cache and backlog have to be flushed somewhat.
10108 (when gnus-keep-backlog
10109 (gnus-backlog-remove-article
10110 (car gnus-article-current) (cdr gnus-article-current)))
10111 (when gnus-use-cache
10112 (gnus-cache-update-article
10113 (car gnus-article-current) (cdr gnus-article-current)))))
10115 (put 'gnus-with-article 'lisp-indent-function 1)
10116 (put 'gnus-with-article 'edebug-form-spec '(form body))
10118 ;; Thread-based commands.
10120 (defun gnus-summary-articles-in-thread (&optional article)
10121 "Return a list of all articles in the current thread.
10122 If ARTICLE is non-nil, return all articles in the thread that starts
10123 with that article."
10124 (let* ((article (or article (gnus-summary-article-number)))
10125 (data (gnus-data-find-list article))
10126 (top-level (gnus-data-level (car data)))
10128 (cond ((null gnus-thread-operation-ignore-subject)
10129 (gnus-simplify-subject-re
10130 (mail-header-subject (gnus-data-header (car data)))))
10131 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10132 (gnus-simplify-subject-fuzzy
10133 (mail-header-subject (gnus-data-header (car data)))))
10135 (end-point (save-excursion
10136 (if (gnus-summary-go-to-next-thread)
10137 (point) (point-max))))
10140 (< (gnus-data-pos (car data)) end-point))
10141 (when (or (not top-subject)
10142 (string= top-subject
10143 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10144 (gnus-simplify-subject-fuzzy
10145 (mail-header-subject
10146 (gnus-data-header (car data))))
10147 (gnus-simplify-subject-re
10148 (mail-header-subject
10149 (gnus-data-header (car data)))))))
10150 (push (gnus-data-number (car data)) articles))
10151 (unless (and (setq data (cdr data))
10152 (> (gnus-data-level (car data)) top-level))
10154 ;; Return the list of articles.
10155 (nreverse articles)))
10157 (defun gnus-summary-rethread-current ()
10158 "Rethread the thread the current article is part of."
10160 (let* ((gnus-show-threads t)
10161 (article (gnus-summary-article-number))
10162 (id (mail-header-id (gnus-summary-article-header)))
10163 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10165 (error "No article on the current line"))
10166 (gnus-rebuild-thread id)
10167 (gnus-summary-goto-subject article)))
10169 (defun gnus-summary-reparent-thread ()
10170 "Make the current article child of the marked (or previous) article.
10172 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10173 is non-nil or the Subject: of both articles are the same."
10175 (unless (not (gnus-group-read-only-p))
10176 (error "The current newsgroup does not support article editing"))
10177 (unless (<= (length gnus-newsgroup-processable) 1)
10178 (error "No more than one article may be marked"))
10179 (save-window-excursion
10180 (let ((gnus-article-buffer " *reparent*")
10181 (current-article (gnus-summary-article-number))
10182 ;; First grab the marked article, otherwise one line up.
10183 (parent-article (if (not (null gnus-newsgroup-processable))
10184 (car gnus-newsgroup-processable)
10186 (if (eq (forward-line -1) 0)
10187 (gnus-summary-article-number)
10188 (error "Beginning of summary buffer"))))))
10189 (unless (not (eq current-article parent-article))
10190 (error "An article may not be self-referential"))
10191 (let ((message-id (mail-header-id
10192 (gnus-summary-article-header parent-article))))
10193 (unless (and message-id (not (equal message-id "")))
10194 (error "No message-id in desired parent"))
10195 (gnus-with-article current-article
10197 (goto-char (point-min))
10198 (message-narrow-to-head)
10199 (if (re-search-forward "^References: " nil t)
10201 (re-search-forward "^[^ \t]" nil t)
10204 (insert " " message-id))
10205 (insert "References: " message-id "\n"))))
10206 (set-buffer gnus-summary-buffer)
10207 (gnus-summary-unmark-all-processable)
10208 (gnus-summary-update-article current-article)
10209 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10210 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10211 (gnus-summary-rethread-current)
10212 (gnus-message 3 "Article %d is now the child of article %d"
10213 current-article parent-article)))))
10215 (defun gnus-summary-toggle-threads (&optional arg)
10216 "Toggle showing conversation threads.
10217 If ARG is positive number, turn showing conversation threads on."
10219 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10220 (setq gnus-show-threads
10221 (if (null arg) (not gnus-show-threads)
10222 (> (prefix-numeric-value arg) 0)))
10223 (gnus-summary-prepare)
10224 (gnus-summary-goto-subject current)
10225 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10226 (gnus-summary-position-point)))
10228 (defun gnus-summary-show-all-threads ()
10229 "Show all threads."
10232 (let ((buffer-read-only nil))
10233 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10234 (gnus-summary-position-point))
10236 (defun gnus-summary-show-thread ()
10237 "Show thread subtrees.
10238 Returns nil if no thread was there to be shown."
10240 (let ((buffer-read-only nil)
10242 ;; first goto end then to beg, to have point at beg after let
10243 (end (progn (end-of-line) (point)))
10244 (beg (progn (beginning-of-line) (point))))
10246 ;; Any hidden lines here?
10247 (search-forward "\r" end t)
10248 (subst-char-in-region beg end ?\^M ?\n t)
10250 (gnus-summary-position-point))))
10252 (defun gnus-summary-maybe-hide-threads ()
10253 "If requested, hide the threads that should be hidden."
10254 (when (and gnus-show-threads
10255 gnus-thread-hide-subtree)
10256 (gnus-summary-hide-all-threads
10257 (if (or (consp gnus-thread-hide-subtree)
10258 (gnus-functionp gnus-thread-hide-subtree))
10259 (gnus-make-predicate gnus-thread-hide-subtree)
10262 ;;; Hiding predicates.
10264 (defun gnus-article-unread-p (header)
10265 (memq (mail-header-number header) gnus-newsgroup-unreads))
10267 (defun gnus-article-unseen-p (header)
10268 (memq (mail-header-number header) gnus-newsgroup-unseen))
10270 (defun gnus-map-articles (predicate articles)
10271 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10272 (apply 'gnus-or (mapcar predicate
10273 (mapcar 'gnus-summary-article-header articles))))
10275 (defun gnus-summary-hide-all-threads (&optional predicate)
10276 "Hide all thread subtrees.
10277 If PREDICATE is supplied, threads that satisfy this predicate
10278 will not be hidden."
10281 (goto-char (point-min))
10284 (when (or (not predicate)
10286 predicate (gnus-summary-article-children)))
10287 (gnus-summary-hide-thread))
10288 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10289 (gnus-summary-position-point))
10291 (defun gnus-summary-hide-thread ()
10292 "Hide thread subtrees.
10293 If PREDICATE is supplied, threads that satisfy this predicate
10294 will not be hidden.
10295 Returns nil if no threads were there to be hidden."
10297 (let ((buffer-read-only nil)
10299 (article (gnus-summary-article-number)))
10301 ;; Go forward until either the buffer ends or the subthread
10303 (when (and (not (eobp))
10304 (or (zerop (gnus-summary-next-thread 1 t))
10305 (goto-char (point-max))))
10307 (if (and (> (point) start)
10308 (search-backward "\n" start t))
10310 (subst-char-in-region start (point) ?\n ?\^M)
10311 (gnus-summary-goto-subject article))
10315 (defun gnus-summary-go-to-next-thread (&optional previous)
10316 "Go to the same level (or less) next thread.
10317 If PREVIOUS is non-nil, go to previous thread instead.
10318 Return the article number moved to, or nil if moving was impossible."
10319 (let ((level (gnus-summary-thread-level))
10320 (way (if previous -1 1))
10323 (while (and (not (eobp))
10324 (< level (gnus-summary-thread-level)))
10325 (forward-line way))
10332 (gnus-summary-article-number)
10333 (goto-char beg)))))
10335 (defun gnus-summary-next-thread (n &optional silent)
10336 "Go to the same level next N'th thread.
10337 If N is negative, search backward instead.
10338 Returns the difference between N and the number of skips actually
10341 If SILENT, don't output messages."
10343 (let ((backward (< n 0))
10345 (while (and (> n 0)
10346 (gnus-summary-go-to-next-thread backward))
10349 (gnus-summary-position-point))
10350 (when (and (not silent) (/= 0 n))
10351 (gnus-message 7 "No more threads"))
10354 (defun gnus-summary-prev-thread (n)
10355 "Go to the same level previous N'th thread.
10356 Returns the difference between N and the number of skips actually
10359 (gnus-summary-next-thread (- n)))
10361 (defun gnus-summary-go-down-thread ()
10362 "Go down one level in the current thread."
10363 (let ((children (gnus-summary-article-children)))
10365 (gnus-summary-goto-subject (car children)))))
10367 (defun gnus-summary-go-up-thread ()
10368 "Go up one level in the current thread."
10369 (let ((parent (gnus-summary-article-parent)))
10371 (gnus-summary-goto-subject parent))))
10373 (defun gnus-summary-down-thread (n)
10374 "Go down thread N steps.
10375 If N is negative, go up instead.
10376 Returns the difference between N and how many steps down that were
10381 (while (and (> n 0)
10382 (if up (gnus-summary-go-up-thread)
10383 (gnus-summary-go-down-thread)))
10385 (gnus-summary-position-point)
10387 (gnus-message 7 "Can't go further"))
10390 (defun gnus-summary-up-thread (n)
10391 "Go up thread N steps.
10392 If N is negative, go down instead.
10393 Returns the difference between N and how many steps down that were
10396 (gnus-summary-down-thread (- n)))
10398 (defun gnus-summary-top-thread ()
10399 "Go to the top of the thread."
10401 (while (gnus-summary-go-up-thread))
10402 (gnus-summary-article-number))
10404 (defun gnus-summary-kill-thread (&optional unmark)
10405 "Mark articles under current thread as read.
10406 If the prefix argument is positive, remove any kinds of marks.
10407 If the prefix argument is negative, tick articles instead."
10410 (setq unmark (prefix-numeric-value unmark)))
10411 (let ((articles (gnus-summary-articles-in-thread)))
10413 ;; Expand the thread.
10414 (gnus-summary-show-thread)
10415 ;; Mark all the articles.
10417 (gnus-summary-goto-subject (car articles))
10418 (cond ((null unmark)
10419 (gnus-summary-mark-article-as-read gnus-killed-mark))
10421 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10423 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10424 (setq articles (cdr articles))))
10425 ;; Hide killed subtrees.
10427 gnus-thread-hide-killed
10428 (gnus-summary-hide-thread))
10429 ;; If marked as read, go to next unread subject.
10430 (when (null unmark)
10431 ;; Go to next unread subject.
10432 (gnus-summary-next-subject 1 t)))
10433 (gnus-set-mode-line 'summary))
10435 ;; Summary sorting commands
10437 (defun gnus-summary-sort-by-number (&optional reverse)
10438 "Sort the summary buffer by article number.
10439 Argument REVERSE means reverse order."
10441 (gnus-summary-sort 'number reverse))
10443 (defun gnus-summary-sort-by-random (&optional reverse)
10444 "Randomize the order in the summary buffer.
10445 Argument REVERSE means to randomize in reverse order."
10447 (gnus-summary-sort 'random reverse))
10449 (defun gnus-summary-sort-by-author (&optional reverse)
10450 "Sort the summary buffer by author name alphabetically.
10451 If `case-fold-search' is non-nil, case of letters is ignored.
10452 Argument REVERSE means reverse order."
10454 (gnus-summary-sort 'author reverse))
10456 (defun gnus-summary-sort-by-subject (&optional reverse)
10457 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10458 If `case-fold-search' is non-nil, case of letters is ignored.
10459 Argument REVERSE means reverse order."
10461 (gnus-summary-sort 'subject reverse))
10463 (defun gnus-summary-sort-by-date (&optional reverse)
10464 "Sort the summary buffer by date.
10465 Argument REVERSE means reverse order."
10467 (gnus-summary-sort 'date reverse))
10469 (defun gnus-summary-sort-by-score (&optional reverse)
10470 "Sort the summary buffer by score.
10471 Argument REVERSE means reverse order."
10473 (gnus-summary-sort 'score reverse))
10475 (defun gnus-summary-sort-by-lines (&optional reverse)
10476 "Sort the summary buffer by the number of lines.
10477 Argument REVERSE means reverse order."
10479 (gnus-summary-sort 'lines reverse))
10481 (defun gnus-summary-sort-by-chars (&optional reverse)
10482 "Sort the summary buffer by article length.
10483 Argument REVERSE means reverse order."
10485 (gnus-summary-sort 'chars reverse))
10487 (defun gnus-summary-sort-by-original (&optional reverse)
10488 "Sort the summary buffer using the default sorting method.
10489 Argument REVERSE means reverse order."
10491 (let* ((buffer-read-only)
10492 (gnus-summary-prepare-hook nil))
10493 ;; We do the sorting by regenerating the threads.
10494 (gnus-summary-prepare)
10495 ;; Hide subthreads if needed.
10496 (gnus-summary-maybe-hide-threads)))
10498 (defun gnus-summary-sort (predicate reverse)
10499 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10500 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10501 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10502 (gnus-thread-sort-functions
10507 (gnus-sort-gathered-threads-function
10508 gnus-thread-sort-functions)
10509 (gnus-article-sort-functions
10513 (,article t2 t1))))
10515 (gnus-summary-prepare-hook nil))
10516 ;; We do the sorting by regenerating the threads.
10517 (gnus-summary-prepare)
10518 ;; Hide subthreads if needed.
10519 (gnus-summary-maybe-hide-threads)))
10521 ;; Summary saving commands.
10523 (defun gnus-summary-save-article (&optional n not-saved)
10524 "Save the current article using the default saver function.
10525 If N is a positive number, save the N next articles.
10526 If N is a negative number, save the N previous articles.
10527 If N is nil and any articles have been marked with the process mark,
10528 save those articles instead.
10529 The variable `gnus-default-article-saver' specifies the saver function."
10531 (let* ((articles (gnus-summary-work-articles n))
10532 (save-buffer (save-excursion
10533 (nnheader-set-temp-buffer " *Gnus Save*")))
10534 (num (length articles))
10536 (dolist (article articles)
10537 (setq header (gnus-summary-article-header article))
10538 (if (not (vectorp header))
10539 ;; This is a pseudo-article.
10540 (if (assq 'name header)
10541 (gnus-copy-file (cdr (assq 'name header)))
10542 (gnus-message 1 "Article %d is unsaveable" article))
10543 ;; This is a real article.
10544 (save-window-excursion
10545 (let ((gnus-display-mime-function nil)
10546 (gnus-article-prepare-hook nil))
10547 (gnus-summary-select-article t nil nil article)))
10549 (set-buffer save-buffer)
10551 (insert-buffer-substring gnus-original-article-buffer))
10552 (setq file (gnus-article-save save-buffer file num))
10553 (gnus-summary-remove-process-mark article)
10555 (gnus-summary-set-saved-mark article))))
10556 (gnus-kill-buffer save-buffer)
10557 (gnus-summary-position-point)
10558 (gnus-set-mode-line 'summary)
10561 (defun gnus-summary-pipe-output (&optional arg headers)
10562 "Pipe the current article to a subprocess.
10563 If N is a positive number, pipe the N next articles.
10564 If N is a negative number, pipe the N previous articles.
10565 If N is nil and any articles have been marked with the process mark,
10566 pipe those articles instead.
10567 If HEADERS (the symbolic prefix), include the headers, too."
10568 (interactive (gnus-interactive "P\ny"))
10569 (require 'gnus-art)
10570 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10571 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10572 (gnus-summary-save-article arg t))
10573 (let ((buffer (get-buffer "*Shell Command Output*")))
10575 (not (zerop (buffer-size buffer))))
10576 (gnus-configure-windows 'pipe))))
10578 (defun gnus-summary-save-article-mail (&optional arg)
10579 "Append the current article to an mail file.
10580 If N is a positive number, save the N next articles.
10581 If N is a negative number, save the N previous articles.
10582 If N is nil and any articles have been marked with the process mark,
10583 save those articles instead."
10585 (require 'gnus-art)
10586 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10587 (gnus-summary-save-article arg)))
10589 (defun gnus-summary-save-article-rmail (&optional arg)
10590 "Append the current article to an rmail file.
10591 If N is a positive number, save the N next articles.
10592 If N is a negative number, save the N previous articles.
10593 If N is nil and any articles have been marked with the process mark,
10594 save those articles instead."
10596 (require 'gnus-art)
10597 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10598 (gnus-summary-save-article arg)))
10600 (defun gnus-summary-save-article-file (&optional arg)
10601 "Append the current article to a file.
10602 If N is a positive number, save the N next articles.
10603 If N is a negative number, save the N previous articles.
10604 If N is nil and any articles have been marked with the process mark,
10605 save those articles instead."
10607 (require 'gnus-art)
10608 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10609 (gnus-summary-save-article arg)))
10611 (defun gnus-summary-write-article-file (&optional arg)
10612 "Write the current article to a file, deleting the previous file.
10613 If N is a positive number, save the N next articles.
10614 If N is a negative number, save the N previous articles.
10615 If N is nil and any articles have been marked with the process mark,
10616 save those articles instead."
10618 (require 'gnus-art)
10619 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10620 (gnus-summary-save-article arg)))
10622 (defun gnus-summary-save-article-body-file (&optional arg)
10623 "Append the current article body to a file.
10624 If N is a positive number, save the N next articles.
10625 If N is a negative number, save the N previous articles.
10626 If N is nil and any articles have been marked with the process mark,
10627 save those articles instead."
10629 (require 'gnus-art)
10630 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10631 (gnus-summary-save-article arg)))
10633 (defun gnus-summary-muttprint (&optional arg)
10634 "Print the current article using Muttprint.
10635 If N is a positive number, save the N next articles.
10636 If N is a negative number, save the N previous articles.
10637 If N is nil and any articles have been marked with the process mark,
10638 save those articles instead."
10640 (require 'gnus-art)
10641 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10642 (gnus-summary-save-article arg t)))
10644 (defun gnus-summary-pipe-message (program)
10645 "Pipe the current article through PROGRAM."
10646 (interactive "sProgram: ")
10647 (gnus-summary-select-article)
10648 (let ((mail-header-separator ""))
10649 (gnus-eval-in-buffer-window gnus-article-buffer
10652 (let ((start (window-start))
10654 (message-pipe-buffer-body program)
10655 (set-window-start (get-buffer-window (current-buffer)) start))))))
10657 (defun gnus-get-split-value (methods)
10658 "Return a value based on the split METHODS."
10659 (let (split-name method result match)
10662 (set-buffer gnus-original-article-buffer)
10664 (nnheader-narrow-to-headers)
10665 (while (and methods (not split-name))
10666 (goto-char (point-min))
10667 (setq method (pop methods))
10668 (setq match (car method))
10671 ;; Regular expression.
10673 (re-search-forward match nil t)))
10674 ((gnus-functionp match)
10678 (setq result (funcall match gnus-newsgroup-name))))
10683 (setq result (eval match)))))
10684 (setq split-name (cdr method))
10685 (cond ((stringp result)
10686 (push (expand-file-name
10687 result gnus-article-save-directory)
10690 (setq split-name (append result split-name)))))))))
10691 (nreverse split-name)))
10693 (defun gnus-valid-move-group-p (group)
10694 (and (boundp group)
10695 (symbol-name group)
10696 (symbol-value group)
10697 (gnus-get-function (gnus-find-method-for-group
10698 (symbol-name group)) 'request-accept-article t)))
10700 (defun gnus-read-move-group-name (prompt default articles prefix)
10701 "Read a group name."
10702 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10703 (minibuffer-confirm-incomplete nil) ; XEmacs
10705 (format "%s %s to:"
10707 (if (> (length articles) 1)
10708 (format "these %d articles" (length articles))
10713 (gnus-completing-read-with-default
10716 'gnus-valid-move-group-p
10718 'gnus-group-history))
10719 ((= 1 (length split-name))
10720 (gnus-completing-read-with-default
10721 (car split-name) prom
10723 'gnus-valid-move-group-p
10725 'gnus-group-history))
10727 (gnus-completing-read-with-default
10729 (mapcar (lambda (el) (list el))
10730 (nreverse split-name))
10732 'gnus-group-history))))
10733 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10735 (if (or (string= to-newsgroup "")
10736 (string= to-newsgroup prefix))
10737 (setq to-newsgroup default))
10738 (unless to-newsgroup
10739 (error "No group name entered"))
10740 (or (gnus-active to-newsgroup)
10741 (gnus-activate-group to-newsgroup nil nil to-method)
10742 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10744 (or (and (gnus-request-create-group to-newsgroup to-method)
10745 (gnus-activate-group
10746 to-newsgroup nil nil to-method)
10747 (gnus-subscribe-group to-newsgroup))
10748 (error "Couldn't create group %s" to-newsgroup)))
10749 (error "No such group: %s" to-newsgroup)))
10752 (defun gnus-summary-save-parts (type dir n &optional reverse)
10753 "Save parts matching TYPE to DIR.
10754 If REVERSE, save parts that do not match TYPE."
10756 (list (read-string "Save parts of type: "
10757 (or (car gnus-summary-save-parts-type-history)
10758 gnus-summary-save-parts-default-mime)
10759 'gnus-summary-save-parts-type-history)
10760 (setq gnus-summary-save-parts-last-directory
10761 (read-file-name "Save to directory: "
10762 gnus-summary-save-parts-last-directory
10764 current-prefix-arg))
10765 (gnus-summary-iterate n
10766 (let ((gnus-display-mime-function nil)
10767 (gnus-inhibit-treatment t))
10768 (gnus-summary-select-article))
10770 (set-buffer gnus-article-buffer)
10771 (let ((handles (or gnus-article-mime-handles
10772 (mm-dissect-buffer nil gnus-article-loose-mime)
10773 (and gnus-article-emulate-mime
10774 (mm-uu-dissect)))))
10776 (gnus-summary-save-parts-1 type dir handles reverse)
10777 (unless gnus-article-mime-handles ;; Don't destroy this case.
10778 (mm-destroy-parts handles)))))))
10780 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10781 (if (stringp (car handle))
10782 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10785 (not (string-match type (mm-handle-media-type handle)))
10786 (string-match type (mm-handle-media-type handle)))
10787 (let ((file (expand-file-name
10788 (file-name-nondirectory
10790 (mail-content-type-get
10791 (mm-handle-disposition handle) 'filename)
10792 (concat gnus-newsgroup-name
10793 "." (number-to-string
10794 (cdr gnus-article-current)))))
10796 (unless (file-exists-p file)
10797 (mm-save-part-to-file handle file))))))
10799 ;; Summary extract commands
10801 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10802 (let ((buffer-read-only nil)
10803 (article (gnus-summary-article-number))
10805 (unless (gnus-summary-goto-subject article)
10806 (error "No such article: %d" article))
10807 (gnus-summary-position-point)
10808 ;; If all commands are to be bunched up on one line, we collect
10810 (unless gnus-view-pseudos-separately
10811 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10814 (setq action (cdr (assq 'action (car ps))))
10815 (setq files (list (cdr (assq 'name (car ps)))))
10816 (while (and ps (cdr ps)
10817 (string= (or action "1")
10818 (or (cdr (assq 'action (cadr ps))) "2")))
10819 (push (cdr (assq 'name (cadr ps))) files)
10820 (setcdr ps (cddr ps)))
10822 (when (not (string-match "%s" action))
10825 (when (assq 'execute (car ps))
10826 (setcdr (assq 'execute (car ps))
10827 (funcall (if (string-match "%s" action)
10836 (setq ps (cdr ps)))))
10837 (if (and gnus-view-pseudos (not not-view))
10839 (when (assq 'execute (car pslist))
10840 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10841 (eq gnus-view-pseudos 'not-confirm)))
10842 (setq pslist (cdr pslist)))
10845 (setq after-article (or (cdr (assq 'article (car pslist)))
10846 (gnus-summary-article-number)))
10847 (gnus-summary-goto-subject after-article)
10850 (insert " " (file-name-nondirectory
10851 (cdr (assq 'name (car pslist))))
10852 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10854 (forward-line -1) ; back to `b'
10855 (gnus-add-text-properties
10856 b (1- e) (list 'gnus-number gnus-reffed-article-number
10857 gnus-mouse-face-prop gnus-mouse-face))
10859 after-article gnus-reffed-article-number
10860 gnus-unread-mark b (car pslist) 0 (- e b))
10861 (setq gnus-newsgroup-unreads
10862 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10863 gnus-reffed-article-number))
10864 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10865 (setq pslist (cdr pslist)))))))
10867 (defun gnus-pseudos< (p1 p2)
10868 (let ((c1 (cdr (assq 'action p1)))
10869 (c2 (cdr (assq 'action p2))))
10870 (and c1 c2 (string< c1 c2))))
10872 (defun gnus-request-pseudo-article (props)
10873 (cond ((assq 'execute props)
10874 (gnus-execute-command (cdr (assq 'execute props)))))
10875 (let ((gnus-current-article (gnus-summary-article-number)))
10876 (gnus-run-hooks 'gnus-mark-article-hook)))
10878 (defun gnus-execute-command (command &optional automatic)
10880 (gnus-article-setup-buffer)
10881 (set-buffer gnus-article-buffer)
10882 (setq buffer-read-only nil)
10883 (let ((command (if automatic command
10884 (read-string "Command: " (cons command 0)))))
10886 (insert "$ " command "\n\n")
10887 (if gnus-view-pseudo-asynchronously
10888 (start-process "gnus-execute" (current-buffer) shell-file-name
10889 shell-command-switch command)
10890 (call-process shell-file-name nil t nil
10891 shell-command-switch command)))))
10893 ;; Summary kill commands.
10895 (defun gnus-summary-edit-global-kill (article)
10896 "Edit the \"global\" kill file."
10897 (interactive (list (gnus-summary-article-number)))
10898 (gnus-group-edit-global-kill article))
10900 (defun gnus-summary-edit-local-kill ()
10901 "Edit a local kill file applied to the current newsgroup."
10903 (setq gnus-current-headers (gnus-summary-article-header))
10904 (gnus-group-edit-local-kill
10905 (gnus-summary-article-number) gnus-newsgroup-name))
10907 ;;; Header reading.
10909 (defun gnus-read-header (id &optional header)
10910 "Read the headers of article ID and enter them into the Gnus system."
10911 (let ((group gnus-newsgroup-name)
10912 (gnus-override-method
10914 gnus-override-method
10915 (and (gnus-news-group-p gnus-newsgroup-name)
10916 (car (gnus-refer-article-methods)))))
10918 ;; First we check to see whether the header in question is already
10921 ;; This is a Message-ID.
10922 (setq header (or header (gnus-id-to-header id)))
10923 ;; This is an article number.
10924 (setq header (or header (gnus-summary-article-header id))))
10926 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10927 ;; We have found the header.
10929 ;; If this is a sparse article, we have to nix out its
10930 ;; previous entry in the thread hashtb.
10932 (gnus-summary-article-sparse-p (mail-header-number header)))
10933 (let* ((parent (gnus-parent-id (mail-header-references header)))
10934 (thread (and parent (gnus-id-to-thread parent))))
10936 (delq (assq header thread) thread))))
10937 ;; We have to really fetch the header to this article.
10939 (set-buffer nntp-server-buffer)
10940 (when (setq where (gnus-request-head id group))
10941 (nnheader-fold-continuation-lines)
10942 (goto-char (point-max))
10944 (goto-char (point-min))
10948 ((cdr where) (cdr where))
10949 (header (mail-header-number header))
10950 (t gnus-reffed-article-number))
10952 (insert " Article retrieved.\n"))
10953 (if (or (not where)
10954 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10955 () ; Malformed head.
10956 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10957 (when (and (stringp id)
10958 (not (string= (gnus-group-real-name group)
10960 ;; If we fetched by Message-ID and the article came
10961 ;; from a different group, we fudge some bogus article
10962 ;; numbers for this article.
10963 (mail-header-set-number header gnus-reffed-article-number))
10965 (set-buffer gnus-summary-buffer)
10966 (decf gnus-reffed-article-number)
10967 (gnus-remove-header (mail-header-number header))
10968 (push header gnus-newsgroup-headers)
10969 (setq gnus-current-headers header)
10970 (push (mail-header-number header) gnus-newsgroup-limit)))
10973 (defun gnus-remove-header (number)
10974 "Remove header NUMBER from `gnus-newsgroup-headers'."
10975 (if (and gnus-newsgroup-headers
10976 (= number (mail-header-number (car gnus-newsgroup-headers))))
10977 (pop gnus-newsgroup-headers)
10978 (let ((headers gnus-newsgroup-headers))
10979 (while (and (cdr headers)
10980 (not (= number (mail-header-number (cadr headers)))))
10982 (when (cdr headers)
10983 (setcdr headers (cddr headers))))))
10986 ;;; summary highlights
10989 (defun gnus-highlight-selected-summary ()
10990 "Highlight selected article in summary buffer."
10991 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10992 (when gnus-summary-selected-face
10994 (let* ((beg (progn (beginning-of-line) (point)))
10995 (end (progn (end-of-line) (point)))
10996 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10997 (from (if (get-text-property beg gnus-mouse-face-prop)
10999 (or (next-single-property-change
11000 beg gnus-mouse-face-prop nil end)
11005 (or (next-single-property-change
11006 from gnus-mouse-face-prop nil end)
11008 ;; If no mouse-face prop on line we will have to = from = end,
11009 ;; so we highlight the entire line instead.
11010 (when (= (+ to 2) from)
11013 (if gnus-newsgroup-selected-overlay
11014 ;; Move old overlay.
11016 gnus-newsgroup-selected-overlay from to (current-buffer))
11017 ;; Create new overlay.
11019 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11020 'face gnus-summary-selected-face))))))
11022 (defvar gnus-summary-highlight-line-cached nil)
11023 (defvar gnus-summary-highlight-line-trigger nil)
11025 (defun gnus-summary-highlight-line-0 ()
11026 (if (and (eq gnus-summary-highlight-line-trigger
11027 gnus-summary-highlight)
11028 gnus-summary-highlight-line-cached)
11029 gnus-summary-highlight-line-cached
11030 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11031 gnus-summary-highlight-line-cached
11032 (let* ((cond (list 'cond))
11034 (list gnus-summary-highlight))
11036 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11039 (gnus-byte-compile (list 'lambda nil cond))))))
11041 (defun gnus-summary-highlight-line ()
11042 "Highlight current line according to `gnus-summary-highlight'."
11043 (let* ((beg (gnus-point-at-bol))
11044 (article (or (gnus-summary-article-number) gnus-current-article))
11045 (score (or (cdr (assq article
11046 gnus-newsgroup-scored))
11047 gnus-summary-default-score 0))
11048 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11049 (inhibit-read-only t)
11050 (default gnus-summary-default-score)
11051 (default-high gnus-summary-default-high-score)
11052 (default-low gnus-summary-default-low-score)
11053 (uncached (memq article gnus-newsgroup-undownloaded))
11054 (downloaded (not uncached)))
11055 (let ((face (funcall (gnus-summary-highlight-line-0))))
11056 (unless (eq face (get-text-property beg 'face))
11057 (gnus-put-text-property-excluding-characters-with-faces
11058 beg (gnus-point-at-eol) 'face
11059 (setq face (if (boundp face) (symbol-value face) face)))
11060 (when gnus-summary-highlight-line-function
11061 (funcall gnus-summary-highlight-line-function article face))))))
11063 (defun gnus-update-read-articles (group unread &optional compute)
11064 "Update the list of read articles in GROUP.
11065 UNREAD is a sorted list."
11066 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11067 (entry (gnus-gethash group gnus-newsrc-hashtb))
11068 (info (nth 2 entry))
11071 (if (or (not info) (not active))
11072 ;; There is no info on this group if it was, in fact,
11073 ;; killed. Gnus stores no information on killed groups, so
11074 ;; there's nothing to be done.
11075 ;; One could store the information somewhere temporarily,
11076 ;; perhaps... Hmmm...
11078 ;; Remove any negative articles numbers.
11079 (while (and unread (< (car unread) 0))
11080 (setq unread (cdr unread)))
11081 ;; Remove any expired article numbers
11082 (while (and unread (< (car unread) (car active)))
11083 (setq unread (cdr unread)))
11084 ;; Compute the ranges of read articles by looking at the list of
11085 ;; unread articles.
11087 (when (/= (car unread) prev)
11088 (push (if (= prev (1- (car unread))) prev
11089 (cons prev (1- (car unread))))
11091 (setq prev (1+ (car unread)))
11092 (setq unread (cdr unread)))
11093 (when (<= prev (cdr active))
11094 (push (cons prev (cdr active)) read))
11095 (setq read (if (> (length read) 1) (nreverse read) read))
11100 ;; Propagate the read marks to the backend.
11101 (when (gnus-check-backend-function 'request-set-mark group)
11102 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11103 (add (gnus-remove-from-range read (gnus-info-read info))))
11105 (unless (gnus-check-group group)
11106 (error "Can't open server for %s" group))
11107 (gnus-request-set-mark
11108 group (delq nil (list (if add (list add 'add '(read)))
11109 (if del (list del 'del '(read))))))
11111 `(gnus-request-set-mark
11114 (if del (list del 'add '(read)))
11115 (if add (list add 'del '(read))))))))))
11116 (set-buffer gnus-group-buffer)
11117 (gnus-undo-register
11119 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11120 (gnus-info-set-read ',info ',(gnus-info-read info))
11121 (gnus-get-unread-articles-in-group ',info
11122 (gnus-active ,group))
11123 (gnus-group-update-group ,group t)
11125 ;; Enter this list into the group info.
11126 (gnus-info-set-read info read)
11127 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11128 (gnus-get-unread-articles-in-group info (gnus-active group))
11131 (defun gnus-offer-save-summaries ()
11132 "Offer to save all active summary buffers."
11134 ;; Go through all buffers and find all summaries.
11135 (dolist (buffer (buffer-list))
11136 (when (and (setq buffer (buffer-name buffer))
11137 (string-match "Summary" buffer)
11139 (set-buffer buffer)
11140 ;; We check that this is, indeed, a summary buffer.
11141 (and (eq major-mode 'gnus-summary-mode)
11142 ;; Also make sure this isn't bogus.
11143 gnus-newsgroup-prepared
11144 ;; Also make sure that this isn't a
11145 ;; dead summary buffer.
11146 (not gnus-dead-summary-mode))))
11147 (push buffer buffers)))
11148 ;; Go through all these summary buffers and offer to save them.
11152 "Update summary buffer %s? "
11154 (switch-to-buffer buf)
11155 (gnus-summary-exit))
11158 (defun gnus-summary-setup-default-charset ()
11159 "Setup newsgroup default charset."
11160 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11161 (setq gnus-newsgroup-charset nil)
11162 (let* ((ignored-charsets
11163 (or gnus-newsgroup-ephemeral-ignored-charsets
11165 (and gnus-newsgroup-name
11166 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11167 gnus-newsgroup-ignored-charsets))))
11168 (setq gnus-newsgroup-charset
11169 (or gnus-newsgroup-ephemeral-charset
11170 (and gnus-newsgroup-name
11171 (gnus-parameter-charset gnus-newsgroup-name))
11172 gnus-default-charset))
11173 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11174 ignored-charsets))))
11180 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11181 "Display the current article buffer fully MIME-buttonized.
11182 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11183 treated as multipart/mixed."
11185 (require 'gnus-art)
11186 (let ((gnus-unbuttonized-mime-types nil)
11187 (gnus-mime-display-multipart-as-mixed show-all-parts))
11188 (gnus-summary-show-article)))
11190 (defun gnus-summary-repair-multipart (article)
11191 "Add a Content-Type header to a multipart article without one."
11192 (interactive (list (gnus-summary-article-number)))
11193 (gnus-with-article article
11194 (message-narrow-to-head)
11195 (message-remove-header "Mime-Version")
11196 (goto-char (point-max))
11197 (insert "Mime-Version: 1.0\n")
11199 (when (search-forward "\n--" nil t)
11200 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11201 (message-narrow-to-head)
11202 (message-remove-header "Content-Type")
11203 (goto-char (point-max))
11204 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11207 (let (gnus-mark-article-hook)
11208 (gnus-summary-select-article t t nil article)))
11210 (defun gnus-summary-toggle-display-buttonized ()
11211 "Toggle the buttonizing of the article buffer."
11213 (require 'gnus-art)
11214 (if (setq gnus-inhibit-mime-unbuttonizing
11215 (not gnus-inhibit-mime-unbuttonizing))
11216 (let ((gnus-unbuttonized-mime-types nil))
11217 (gnus-summary-show-article))
11218 (gnus-summary-show-article)))
11221 ;;; Generic summary marking commands
11224 (defvar gnus-summary-marking-alist
11225 '((read gnus-del-mark "d")
11226 (unread gnus-unread-mark "u")
11227 (ticked gnus-ticked-mark "!")
11228 (dormant gnus-dormant-mark "?")
11229 (expirable gnus-expirable-mark "e"))
11230 "An alist of names/marks/keystrokes.")
11232 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11233 (defvar gnus-summary-mark-map)
11235 (defun gnus-summary-make-all-marking-commands ()
11236 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11237 (dolist (elem gnus-summary-marking-alist)
11238 (apply 'gnus-summary-make-marking-command elem)))
11240 (defun gnus-summary-make-marking-command (name mark keystroke)
11241 (let ((map (make-sparse-keymap)))
11242 (define-key gnus-summary-generic-mark-map keystroke map)
11243 (dolist (lway `((next "next" next nil "n")
11244 (next-unread "next unread" next t "N")
11245 (prev "previous" prev nil "p")
11246 (prev-unread "previous unread" prev t "P")
11247 (nomove "" nil nil ,keystroke)))
11248 (let ((func (gnus-summary-make-marking-command-1
11249 mark (car lway) lway name)))
11250 (setq func (eval func))
11251 (define-key map (nth 4 lway) func)))))
11253 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11255 (format "gnus-summary-put-mark-as-%s%s"
11256 name (if (eq way 'nomove)
11258 (concat "-" (symbol-name way)))))
11261 "Mark the current article as %s%s.
11262 If N, the prefix, then repeat N times.
11263 If N is negative, move in reverse order.
11264 The difference between N and the actual number of articles marked is
11268 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11270 (defun gnus-summary-generic-mark (n mark move unread)
11271 "Mark N articles with MARK."
11272 (unless (eq major-mode 'gnus-summary-mode)
11273 (error "This command can only be used in the summary buffer"))
11274 (gnus-summary-show-thread)
11277 ((eq move 'next) 1)
11278 ((eq move 'prev) -1)
11280 (if (zerop nummove)
11284 nummove (* -1 nummove))))
11285 (while (and (> n 0)
11286 (gnus-summary-mark-article nil mark)
11287 (zerop (gnus-summary-next-subject nummove unread t)))
11290 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11291 (gnus-summary-recenter)
11292 (gnus-summary-position-point)
11293 (gnus-set-mode-line 'summary)
11296 (defun gnus-summary-insert-articles (articles)
11297 (when (setq articles
11298 (gnus-sorted-difference articles
11299 (mapcar (lambda (h)
11300 (mail-header-number h))
11301 gnus-newsgroup-headers)))
11302 (setq gnus-newsgroup-headers
11304 gnus-newsgroup-headers
11305 (gnus-fetch-headers articles)
11306 'gnus-article-sort-by-number))
11307 ;; Suppress duplicates?
11308 (when gnus-suppress-duplicates
11309 (gnus-dup-suppress-articles))
11311 ;; We might want to build some more threads first.
11312 (when (and gnus-fetch-old-headers
11313 (eq gnus-headers-retrieved-by 'nov))
11314 (if (eq gnus-fetch-old-headers 'invisible)
11315 (gnus-build-all-threads)
11316 (gnus-build-old-threads)))
11317 ;; Let the Gnus agent mark articles as read.
11319 (gnus-agent-get-undownloaded-list))
11320 ;; Remove list identifiers from subject
11321 (when gnus-list-identifiers
11322 (gnus-summary-remove-list-identifiers))
11323 ;; First and last article in this newsgroup.
11324 (when gnus-newsgroup-headers
11325 (setq gnus-newsgroup-begin
11326 (mail-header-number (car gnus-newsgroup-headers))
11328 (mail-header-number
11329 (gnus-last-element gnus-newsgroup-headers))))
11330 (when gnus-use-scoring
11331 (gnus-possibly-score-headers))))
11333 (defun gnus-summary-insert-old-articles (&optional all)
11334 "Insert all old articles in this group.
11335 If ALL is non-nil, already read articles become readable.
11336 If ALL is a number, fetch this number of articles."
11339 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11342 ;; Some nntp servers lie about their active range. When
11343 ;; this happens, the active range can be in the millions.
11344 ;; Use a compressed range to avoid creating a huge list.
11345 (gnus-range-difference (list gnus-newsgroup-active) old))
11346 (setq len (gnus-range-length older))
11351 (let ((older-range (nreverse older)))
11355 (let* ((r (pop older-range))
11356 (min (if (numberp r) r (car r)))
11357 (max (if (numberp r) r (cdr r))))
11358 (while (and (<= min max)
11363 (setq older (gnus-uncompress-range older))))
11365 (setq older (gnus-uncompress-range older)))
11367 (when (and (numberp gnus-large-newsgroup)
11368 (> len gnus-large-newsgroup))
11369 (let* ((cursor-in-echo-area nil)
11370 (initial (gnus-parameter-large-newsgroup-initial
11371 gnus-newsgroup-name))
11375 "How many articles from %s (%s %d): "
11377 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11378 (if initial "max" "default")
11381 (cons (number-to-string initial)
11383 (unless (string-match "^[ \t]*$" input)
11384 (setq all (string-to-number input))
11386 (let ((older-range (nreverse older)))
11390 (let* ((r (pop older-range))
11391 (min (if (numberp r) r (car r)))
11392 (max (if (numberp r) r (cdr r))))
11393 (while (and (<= min max)
11397 max (1- max))))))))))
11398 (setq older (gnus-uncompress-range older))))
11400 (message "No old news.")
11401 (gnus-summary-insert-articles older)
11402 (gnus-summary-limit (gnus-sorted-nunion old older))))
11403 (gnus-summary-position-point)))
11405 (defun gnus-summary-insert-new-articles ()
11406 "Insert all new articles in this group."
11409 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11410 (old-active gnus-newsgroup-active)
11411 (nnmail-fetched-sources (list t))
11413 (setq gnus-newsgroup-active
11414 (gnus-activate-group gnus-newsgroup-name 'scan))
11415 (setq i (cdr gnus-newsgroup-active))
11416 (while (> i (cdr old-active))
11420 (message "No gnus is bad news.")
11421 (gnus-summary-insert-articles new)
11422 (setq gnus-newsgroup-unreads
11423 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11424 (gnus-summary-limit (gnus-sorted-nunion old new))))
11425 (gnus-summary-position-point)))
11427 (gnus-summary-make-all-marking-commands)
11429 (gnus-ems-redefine)
11431 (provide 'gnus-sum)
11433 (run-hooks 'gnus-sum-load-hook)
11435 ;;; gnus-sum.el ends here