1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
55 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
56 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
59 (defcustom gnus-kill-summary-on-exit t
60 "*If non-nil, kill the summary buffer when you exit from it.
61 If nil, the summary will become a \"*Dead Summary*\" buffer, and
62 it will be killed sometime later."
63 :group 'gnus-summary-exit
66 (defcustom gnus-fetch-old-headers nil
67 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
68 If an unread article in the group refers to an older, already read (or
69 just marked as read) article, the old article will not normally be
70 displayed in the Summary buffer. If this variable is non-nil, Gnus
71 will attempt to grab the headers to the old articles, and thereby
72 build complete threads. If it has the value `some', only enough
73 headers to connect otherwise loose threads will be displayed. This
74 variable can also be a number. In that case, no more than that number
75 of old headers will be fetched. If it has the value `invisible', all
76 old headers will be fetched, but none will be displayed.
78 The server has to support NOV for any of this to work."
80 :type '(choice (const :tag "off" nil)
83 (sexp :menu-tag "other" t)))
85 (defcustom gnus-refer-thread-limit 200
86 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
87 If t, fetch all the available old headers."
90 (sexp :menu-tag "other" t)))
92 (defcustom gnus-summary-make-false-root 'adopt
93 "*nil means that Gnus won't gather loose threads.
94 If the root of a thread has expired or been read in a previous
95 session, the information necessary to build a complete thread has been
96 lost. Instead of having many small sub-threads from this original thread
97 scattered all over the summary buffer, Gnus can gather them.
99 If non-nil, Gnus will try to gather all loose sub-threads from an
100 original thread into one large thread.
102 If this variable is non-nil, it should be one of `none', `adopt',
105 If this variable is `none', Gnus will not make a false root, but just
106 present the sub-threads after another.
107 If this variable is `dummy', Gnus will create a dummy root that will
108 have all the sub-threads as children.
109 If this variable is `adopt', Gnus will make one of the \"children\"
110 the parent and mark all the step-children as such.
111 If this variable is `empty', the \"children\" are printed with empty
112 subject fields. (Or rather, they will be printed with a string
113 given by the `gnus-summary-same-subject' variable.)"
115 :type '(choice (const :tag "off" nil)
121 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
122 "*A regexp to match subjects to be excluded from loose thread gathering.
123 As loose thread gathering is done on subjects only, that means that
124 there can be many false gatherings performed. By rooting out certain
125 common subjects, gathering might become saner."
129 (defcustom gnus-summary-gather-subject-limit nil
130 "*Maximum length of subject comparisons when gathering loose threads.
131 Use nil to compare full subjects. Setting this variable to a low
132 number will help gather threads that have been corrupted by
133 newsreaders chopping off subject lines, but it might also mean that
134 unrelated articles that have subject that happen to begin with the
135 same few characters will be incorrectly gathered.
137 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
140 :type '(choice (const :tag "off" nil)
142 (sexp :menu-tag "on" t)))
144 (defcustom gnus-simplify-subject-functions nil
145 "List of functions taking a string argument that simplify subjects.
146 The functions are applied recursively.
148 Useful functions to put in this list include: `gnus-simplify-subject-re',
149 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
151 :type '(repeat function))
153 (defcustom gnus-simplify-ignored-prefixes nil
154 "*Regexp, matches for which are removed 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-dont-select-after-jump-to-other-group nil
322 "If non-nil, don't select the first unread article after entering the
323 other group by the command `gnus-summary-jump-to-other-group'. If nil,
324 it is depend on the value of `gnus-auto-select-first' whether to select
326 :group 'gnus-group-select
329 (defcustom gnus-auto-select-next t
330 "*If non-nil, offer to go to the next group from the end of the previous.
331 If the value is t and the next newsgroup is empty, Gnus will exit
332 summary mode and go back to group mode. If the value is neither nil
333 nor t, Gnus will select the following unread newsgroup. In
334 particular, if the value is the symbol `quietly', the next unread
335 newsgroup will be selected without any confirmation, and if it is
336 `almost-quietly', the next group will be selected without any
337 confirmation if you are located on the last article in the group.
338 Finally, if this variable is `slightly-quietly', the `Z n' command
339 will go to the next group without confirmation."
340 :group 'gnus-summary-maneuvering
341 :type '(choice (const :tag "off" nil)
343 (const almost-quietly)
344 (const slightly-quietly)
345 (sexp :menu-tag "on" t)))
347 (defcustom gnus-auto-select-same nil
348 "*If non-nil, select the next article with the same subject.
349 If there are no more articles with the same subject, go to
350 the first unread article."
351 :group 'gnus-summary-maneuvering
354 (defcustom gnus-summary-check-current nil
355 "*If non-nil, consider the current article when moving.
356 The \"unread\" movement commands will stay on the same line if the
357 current article is unread."
358 :group 'gnus-summary-maneuvering
361 (defcustom gnus-auto-center-summary t
362 "*If non-nil, always center the current summary buffer.
363 In particular, if `vertical' do only vertical recentering. If non-nil
364 and non-`vertical', do both horizontal and vertical recentering."
365 :group 'gnus-summary-maneuvering
366 :type '(choice (const :tag "none" nil)
368 (integer :tag "height")
369 (sexp :menu-tag "both" t)))
371 (defcustom gnus-show-all-headers nil
372 "*If non-nil, don't hide any headers."
373 :group 'gnus-article-hiding
374 :group 'gnus-article-headers
377 (defcustom gnus-summary-ignore-duplicates nil
378 "*If non-nil, ignore articles with identical Message-ID headers."
382 (defcustom gnus-single-article-buffer t
383 "*If non-nil, display all articles in the same buffer.
384 If nil, each group will get its own article buffer."
385 :group 'gnus-article-various
388 (defcustom gnus-break-pages t
389 "*If non-nil, do page breaking on articles.
390 The page delimiter is specified by the `gnus-page-delimiter'
392 :group 'gnus-article-various
395 (defcustom gnus-show-mime t
396 "*If non-nil, do mime processing of articles.
397 The articles will simply be fed to the function given by
398 `gnus-article-display-method-for-mime'."
399 :group 'gnus-article-mime
402 (defcustom gnus-move-split-methods nil
403 "*Variable used to suggest where articles are to be moved to.
404 It uses the same syntax as the `gnus-split-methods' variable.
405 However, whereas `gnus-split-methods' specifies file names as targets,
406 this variable specifies group names."
407 :group 'gnus-summary-mail
408 :type '(repeat (choice (list :value (fun) function)
409 (cons :value ("" "") regexp (repeat string))
412 (defcustom gnus-unread-mark ?\ ;;;Whitespace
413 "*Mark used for unread articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-ticked-mark ?!
418 "*Mark used for ticked articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-dormant-mark ??
423 "*Mark used for dormant articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-del-mark ?r
428 "*Mark used for del'd articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-read-mark ?R
433 "*Mark used for read articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-expirable-mark ?E
438 "*Mark used for expirable articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-killed-mark ?K
443 "*Mark used for killed articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-souped-mark ?F
448 "*Mark used for souped articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-kill-file-mark ?X
453 "*Mark used for articles killed by kill files."
454 :group 'gnus-summary-marks
457 (defcustom gnus-low-score-mark ?Y
458 "*Mark used for articles with a low score."
459 :group 'gnus-summary-marks
462 (defcustom gnus-catchup-mark ?C
463 "*Mark used for articles that are caught up."
464 :group 'gnus-summary-marks
467 (defcustom gnus-replied-mark ?A
468 "*Mark used for articles that have been replied to."
469 :group 'gnus-summary-marks
472 (defcustom gnus-forwarded-mark ?F
473 "*Mark used for articles that have been forwarded."
474 :group 'gnus-summary-marks
477 (defcustom gnus-recent-mark ?N
478 "*Mark used for articles that are recent."
479 :group 'gnus-summary-marks
482 (defcustom gnus-cached-mark ?*
483 "*Mark used for articles that are in the cache."
484 :group 'gnus-summary-marks
487 (defcustom gnus-saved-mark ?S
488 "*Mark used for articles that have been saved."
489 :group 'gnus-summary-marks
492 (defcustom gnus-unseen-mark ?.
493 "*Mark used for articles that haven't been seen."
494 :group 'gnus-summary-marks
497 (defcustom gnus-no-mark ?\ ;;;Whitespace
498 "*Mark used for articles that have no other secondary mark."
499 :group 'gnus-summary-marks
502 (defcustom gnus-ancient-mark ?O
503 "*Mark used for ancient articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-sparse-mark ?Q
508 "*Mark used for sparsely reffed articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-canceled-mark ?G
513 "*Mark used for canceled articles."
514 :group 'gnus-summary-marks
517 (defcustom gnus-duplicate-mark ?M
518 "*Mark used for duplicate articles."
519 :group 'gnus-summary-marks
522 (defcustom gnus-undownloaded-mark ?@
523 "*Mark used for articles that weren't downloaded."
524 :group 'gnus-summary-marks
527 (defcustom gnus-downloadable-mark ?%
528 "*Mark used for articles that are to be downloaded."
529 :group 'gnus-summary-marks
532 (defcustom gnus-unsendable-mark ?=
533 "*Mark used for articles that won't be sent."
534 :group 'gnus-summary-marks
537 (defcustom gnus-score-over-mark ?+
538 "*Score mark used for articles with high scores."
539 :group 'gnus-summary-marks
542 (defcustom gnus-score-below-mark ?-
543 "*Score mark used for articles with low scores."
544 :group 'gnus-summary-marks
547 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
548 "*There is no thread under the article."
549 :group 'gnus-summary-marks
552 (defcustom gnus-not-empty-thread-mark ?=
553 "*There is a thread under the article."
554 :group 'gnus-summary-marks
557 (defcustom gnus-view-pseudo-asynchronously nil
558 "*If non-nil, Gnus will view pseudo-articles asynchronously."
559 :group 'gnus-extract-view
562 (defcustom gnus-auto-expirable-marks
563 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
564 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
565 gnus-souped-mark gnus-duplicate-mark)
566 "*The list of marks converted into expiration if a group is auto-expirable."
569 :type '(repeat character))
571 (defcustom gnus-inhibit-user-auto-expire t
572 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
577 (defcustom gnus-view-pseudos nil
578 "*If `automatic', pseudo-articles will be viewed automatically.
579 If `not-confirm', pseudos will be viewed automatically, and the user
580 will not be asked to confirm the command."
581 :group 'gnus-extract-view
582 :type '(choice (const :tag "off" nil)
584 (const not-confirm)))
586 (defcustom gnus-view-pseudos-separately t
587 "*If non-nil, one pseudo-article will be created for each file to be viewed.
588 If nil, all files that use the same viewing command will be given as a
589 list of parameters to that command."
590 :group 'gnus-extract-view
593 (defcustom gnus-insert-pseudo-articles t
594 "*If non-nil, insert pseudo-articles when decoding articles."
595 :group 'gnus-extract-view
598 (defcustom gnus-summary-dummy-line-format
600 "*The format specification for the dummy roots in the summary buffer.
601 It works along the same lines as a normal formatting string,
602 with some simple extensions.
606 General format specifiers can also be used.
607 See (gnus)Formatting Variables."
608 :link '(custom-manual "(gnus)Formatting Variables")
609 :group 'gnus-threading
612 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
613 "*The format specification for the summary mode line.
614 It works along the same lines as a normal formatting string,
615 with some simple extensions:
618 %p Unprefixed group name
619 %A Current article number
620 %z Current article score
622 %U Number of unread articles in the group
623 %e Number of unselected articles in the group
624 %Z A string with unread/unselected article counts
625 %g Shortish group name
626 %S Subject of the current article
628 %s Current score file name
629 %d Number of dormant articles
630 %r Number of articles that have been marked as read in this session
631 %E Number of articles expunged by the score files"
632 :group 'gnus-summary-format
635 (defcustom gnus-list-identifiers nil
636 "Regexp that matches list identifiers to be removed from subject.
637 This can also be a list of regexps."
639 :group 'gnus-summary-format
640 :group 'gnus-article-hiding
641 :type '(choice (const :tag "none" nil)
643 (repeat :value (".*") regexp)))
645 (defcustom gnus-summary-mark-below 0
646 "*Mark all articles with a score below this variable as read.
647 This variable is local to each summary buffer and usually set by the
649 :group 'gnus-score-default
652 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
653 "*List of functions used for sorting articles in the summary buffer.
655 Each function takes two articles and returns non-nil if the first
656 article should be sorted before the other. If you use more than one
657 function, the primary sort function should be the last. You should
658 probably always include `gnus-article-sort-by-number' in the list of
659 sorting functions -- preferably first. Also note that sorting by date
660 is often much slower than sorting by number, and the sorting order is
661 very similar. (Sorting by date means sorting by the time the message
662 was sent, sorting by number means sorting by arrival time.)
664 Ready-made functions include `gnus-article-sort-by-number',
665 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
666 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
668 When threading is turned on, the variable `gnus-thread-sort-functions'
669 controls how articles are sorted."
670 :group 'gnus-summary-sort
671 :type '(repeat (choice (function-item gnus-article-sort-by-number)
672 (function-item gnus-article-sort-by-author)
673 (function-item gnus-article-sort-by-subject)
674 (function-item gnus-article-sort-by-date)
675 (function-item gnus-article-sort-by-score)
676 (function :tag "other"))))
678 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
679 "*List of functions used for sorting threads in the summary buffer.
680 By default, threads are sorted by article number.
682 Each function takes two threads and returns non-nil if the first
683 thread should be sorted before the other. If you use more than one
684 function, the primary sort function should be the last. You should
685 probably always include `gnus-thread-sort-by-number' in the list of
686 sorting functions -- preferably first. Also note that sorting by date
687 is often much slower than sorting by number, and the sorting order is
688 very similar. (Sorting by date means sorting by the time the message
689 was sent, sorting by number means sorting by arrival time.)
691 Ready-made functions include `gnus-thread-sort-by-number',
692 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
693 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
694 `gnus-thread-sort-by-most-recent-number',
695 `gnus-thread-sort-by-most-recent-date', and
696 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
698 When threading is turned off, the variable
699 `gnus-article-sort-functions' controls how articles are sorted."
700 :group 'gnus-summary-sort
701 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
702 (function-item gnus-thread-sort-by-author)
703 (function-item gnus-thread-sort-by-subject)
704 (function-item gnus-thread-sort-by-date)
705 (function-item gnus-thread-sort-by-score)
706 (function-item gnus-thread-sort-by-total-score)
707 (function :tag "other"))))
709 (defcustom gnus-thread-score-function '+
710 "*Function used for calculating the total score of a thread.
712 The function is called with the scores of the article and each
713 subthread and should then return the score of the thread.
715 Some functions you can use are `+', `max', or `min'."
716 :group 'gnus-summary-sort
719 (defcustom gnus-summary-expunge-below nil
720 "All articles that have a score less than this variable will be expunged.
721 This variable is local to the summary buffers."
722 :group 'gnus-score-default
723 :type '(choice (const :tag "off" nil)
726 (defcustom gnus-thread-expunge-below nil
727 "All threads that have a total score less than this variable will be expunged.
728 See `gnus-thread-score-function' for en explanation of what a
731 This variable is local to the summary buffers."
732 :group 'gnus-threading
733 :group 'gnus-score-default
734 :type '(choice (const :tag "off" nil)
737 (defcustom gnus-summary-mode-hook nil
738 "*A hook for Gnus summary mode.
739 This hook is run before any variables are set in the summary buffer."
740 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
741 :group 'gnus-summary-various
744 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
745 (when (featurep 'xemacs)
746 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
747 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
748 (add-hook 'gnus-summary-mode-hook
749 'gnus-xmas-switch-horizontal-scrollbar-off))
751 (defcustom gnus-summary-menu-hook nil
752 "*Hook run after the creation of the summary mode menu."
753 :group 'gnus-summary-visual
756 (defcustom gnus-summary-exit-hook nil
757 "*A hook called on exit from the summary buffer.
758 It will be called with point in the group buffer."
759 :group 'gnus-summary-exit
762 (defcustom gnus-summary-prepare-hook nil
763 "*A hook called after the summary buffer has been generated.
764 If you want to modify the summary buffer, you can use this hook."
765 :group 'gnus-summary-various
768 (defcustom gnus-summary-prepared-hook nil
769 "*A hook called as the last thing after the summary buffer has been generated."
770 :group 'gnus-summary-various
773 (defcustom gnus-summary-generate-hook nil
774 "*A hook run just before generating the summary buffer.
775 This hook is commonly used to customize threading variables and the
777 :group 'gnus-summary-various
780 (defcustom gnus-select-group-hook nil
781 "*A hook called when a newsgroup is selected.
783 If you'd like to simplify subjects like the
784 `gnus-summary-next-same-subject' command does, you can use the
787 (add-hook gnus-select-group-hook
789 (mapcar (lambda (header)
790 (mail-header-set-subject
792 (gnus-simplify-subject
793 (mail-header-subject header) 're-only)))
794 gnus-newsgroup-headers)))"
795 :group 'gnus-group-select
798 (defcustom gnus-select-article-hook nil
799 "*A hook called when an article is selected."
800 :group 'gnus-summary-choose
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 '(gnus-set-summary-default-charset)
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 (defcustom gnus-summary-highlight
864 '(((= mark gnus-canceled-mark)
865 . gnus-summary-cancelled-face)
866 ((and (> score default-high)
867 (or (= mark gnus-dormant-mark)
868 (= mark gnus-ticked-mark)))
869 . gnus-summary-high-ticked-face)
870 ((and (< score default-low)
871 (or (= mark gnus-dormant-mark)
872 (= mark gnus-ticked-mark)))
873 . gnus-summary-low-ticked-face)
874 ((or (= mark gnus-dormant-mark)
875 (= mark gnus-ticked-mark))
876 . gnus-summary-normal-ticked-face)
877 ((and (> score default-high) (= mark gnus-ancient-mark))
878 . gnus-summary-high-ancient-face)
879 ((and (< score default-low) (= mark gnus-ancient-mark))
880 . gnus-summary-low-ancient-face)
881 ((= mark gnus-ancient-mark)
882 . gnus-summary-normal-ancient-face)
883 ((and (> score default-high) (= mark gnus-unread-mark))
884 . gnus-summary-high-unread-face)
885 ((and (< score default-low) (= mark gnus-unread-mark))
886 . gnus-summary-low-unread-face)
887 ((= mark gnus-unread-mark)
888 . gnus-summary-normal-unread-face)
889 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
890 gnus-undownloaded-mark)))
891 . gnus-summary-high-unread-face)
892 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
893 gnus-undownloaded-mark)))
894 . gnus-summary-low-unread-face)
895 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
896 (memq article gnus-newsgroup-unreads))
897 . gnus-summary-normal-unread-face)
898 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
899 . gnus-summary-normal-read-face)
900 ((> score default-high)
901 . gnus-summary-high-read-face)
902 ((< score default-low)
903 . gnus-summary-low-read-face)
905 . gnus-summary-normal-read-face))
906 "*Controls the highlighting of summary buffer lines.
908 A list of (FORM . FACE) pairs. When deciding how a a particular
909 summary line should be displayed, each form is evaluated. The content
910 of the face field after the first true form is used. You can change
911 how those summary lines are displayed, by editing the face field.
913 You can use the following variables in the FORM field.
915 score: The article's score
916 default: The default article score.
917 default-high: The default score for high scored articles.
918 default-low: The default score for low scored articles.
919 below: The score below which articles are automatically marked as read.
920 mark: The articles mark."
921 :group 'gnus-summary-visual
922 :type '(repeat (cons (sexp :tag "Form" nil)
925 (defcustom gnus-alter-header-function nil
926 "Function called to allow alteration of article header structures.
927 The function is called with one parameter, the article header vector,
928 which it may alter in any way.")
930 (defvar gnus-decode-encoded-word-function
931 (mime-find-field-decoder 'From 'nov)
932 "Variable that says which function should be used to decode a string with encoded words.")
934 (defcustom gnus-extra-headers '(To Newsgroups)
935 "*Extra headers to parse."
938 :type '(repeat symbol))
940 (defcustom gnus-ignored-from-addresses
941 (and user-mail-address (regexp-quote user-mail-address))
942 "*Regexp of From headers that may be suppressed in favor of To headers."
947 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
948 "List of charsets that should be ignored.
949 When these charsets are used in the \"charset\" parameter, the
950 default charset will be used instead."
952 :type '(repeat symbol)
953 :group 'gnus-charset)
955 (gnus-define-group-parameter
959 "Return the ignored charsets of GROUP."
960 :variable gnus-group-ignored-charsets-alist
962 '(("alt\\.chinese\\.text" iso-8859-1))
964 "Alist of regexps (to match group names) and charsets that should be ignored.
965 When these charsets are used in the \"charset\" parameter, the
966 default charset will be used instead."
967 :variable-group gnus-charset
968 :variable-type '(repeat (cons (regexp :tag "Group")
970 :parameter-type '(choice :tag "Ignored charsets"
973 :parameter-document "\
974 List of charsets that should be ignored.
976 When these charsets are used in the \"charset\" parameter, the
977 default charset will be used instead.")
979 (defcustom gnus-group-highlight-words-alist nil
980 "Alist of group regexps and highlight regexps.
981 This variable uses the same syntax as `gnus-emphasis-alist'."
983 :type '(repeat (cons (regexp :tag "Group")
984 (repeat (list (regexp :tag "Highlight regexp")
985 (number :tag "Group for entire word" 0)
986 (number :tag "Group for displayed part" 0)
988 gnus-emphasis-highlight-words)))))
989 :group 'gnus-summary-visual)
991 (defcustom gnus-use-wheel nil
992 "Use Intelli-mouse on summary movement"
994 :group 'gnus-summary-maneuvering)
996 (defcustom gnus-wheel-scroll-amount '(5 . 1)
997 "Amount to scroll messages by spinning the mouse wheel.
998 This is actually a cons cell, where the first item is the amount to scroll
999 on a normal wheel event, and the second is the amount to scroll when the
1000 wheel is moved with the shift key depressed."
1001 :type '(cons (integer :tag "Shift") integer)
1002 :group 'gnus-summary-maneuvering)
1004 (defcustom gnus-wheel-edge-resistance 2
1005 "How hard it should be to change the current article
1006 by moving the mouse over the edge of the article window."
1008 :group 'gnus-summary-maneuvering)
1010 (defcustom gnus-summary-show-article-charset-alist
1012 "Alist of number and charset.
1013 The article will be shown with the charset corresponding to the
1015 For example: ((1 . cn-gb-2312) (2 . big5))."
1017 :type '(repeat (cons (number :tag "Argument" 1)
1018 (symbol :tag "Charset")))
1019 :group 'gnus-charset)
1021 (defcustom gnus-preserve-marks t
1022 "Whether marks are preserved when moving, copying and respooling messages."
1025 :group 'gnus-summary-marks)
1027 (defcustom gnus-alter-articles-to-read-function nil
1028 "Function to be called to alter the list of articles to be selected."
1029 :type '(choice (const nil) function)
1030 :group 'gnus-summary)
1032 (defcustom gnus-orphan-score nil
1033 "*All orphans get this score added. Set in the score file."
1034 :group 'gnus-score-default
1035 :type '(choice (const nil)
1038 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1039 "*A regexp to match MIME parts when saving multiple parts of a message
1040 with gnus-summary-save-parts (X m). This regexp will be used by default
1041 when prompting the user for which type of files to save."
1042 :group 'gnus-summary
1046 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1047 "*A regexp to match MIME parts when saving multiple parts of a message
1048 with gnus-summary-save-parts (X m). This regexp will be used by default
1049 when prompting the user for which type of files to save."
1050 :group 'gnus-summary
1053 (defcustom gnus-read-all-available-headers nil
1054 "Whether Gnus should parse all headers made available to it.
1055 This is mostly relevant for slow backends where the user may
1056 wish to widen the summary buffer to include all headers
1057 that were fetched. Say, for nnultimate groups."
1058 :group 'gnus-summary
1059 :type '(choice boolean regexp))
1061 (defcustom gnus-summary-muttprint-program "muttprint"
1062 "Command (and optional arguments) used to run Muttprint."
1064 :group 'gnus-summary
1067 (defcustom gnus-article-no-strict-mime nil
1068 "If non-nil, don't require strict MIME.
1069 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1070 supply the MIME-Version header or deliberately strip it From the mail.
1071 Set it to non-nil, Gnus will treat some articles as MIME even if
1072 the MIME-Version header is missed."
1075 :group 'gnus-article)
1077 ;;; Internal variables
1079 (defvar gnus-summary-display-cache nil)
1080 (defvar gnus-article-mime-handles nil)
1081 (defvar gnus-article-decoded-p nil)
1082 (defvar gnus-article-charset nil)
1083 (defvar gnus-article-ignored-charsets nil)
1084 (defvar gnus-scores-exclude-files nil)
1085 (defvar gnus-page-broken nil)
1086 (defvar gnus-inhibit-mime-unbuttonizing nil)
1088 (defvar gnus-original-article nil)
1089 (defvar gnus-article-internal-prepare-hook nil)
1090 (defvar gnus-newsgroup-process-stack nil)
1092 (defvar gnus-thread-indent-array nil)
1093 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1094 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1095 "Function called to sort the articles within a thread after it has been gathered together.")
1097 (defvar gnus-summary-save-parts-type-history nil)
1098 (defvar gnus-summary-save-parts-last-directory nil)
1100 (defvar gnus-summary-save-parts-type-history nil)
1101 (defvar gnus-summary-save-parts-last-directory nil)
1103 ;; Avoid highlighting in kill files.
1104 (defvar gnus-summary-inhibit-highlight nil)
1105 (defvar gnus-newsgroup-selected-overlay nil)
1106 (defvar gnus-inhibit-limiting nil)
1107 (defvar gnus-newsgroup-adaptive-score-file nil)
1108 (defvar gnus-current-score-file nil)
1109 (defvar gnus-current-move-group nil)
1110 (defvar gnus-current-copy-group nil)
1111 (defvar gnus-current-crosspost-group nil)
1112 (defvar gnus-newsgroup-display nil)
1114 (defvar gnus-newsgroup-dependencies nil)
1115 (defvar gnus-newsgroup-adaptive nil)
1116 (defvar gnus-summary-display-article-function nil)
1117 (defvar gnus-summary-highlight-line-function nil
1118 "Function called after highlighting a summary line.")
1120 (defvar gnus-summary-line-format-alist
1121 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1122 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1123 (?s gnus-tmp-subject-or-nil ?s)
1124 (?n gnus-tmp-name ?s)
1125 (?A (std11-address-string
1126 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1127 (?a (or (std11-full-name-string
1128 (car (mime-entity-read-field gnus-tmp-header 'From)))
1130 (?F gnus-tmp-from ?s)
1131 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1132 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1133 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1134 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1135 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1136 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1137 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1138 (?L gnus-tmp-lines ?s)
1139 (?I gnus-tmp-indentation ?s)
1140 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1141 (?R gnus-tmp-replied ?c)
1142 (?\[ gnus-tmp-opening-bracket ?c)
1143 (?\] gnus-tmp-closing-bracket ?c)
1144 (?\> (make-string gnus-tmp-level ? ) ?s)
1145 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1146 (?i gnus-tmp-score ?d)
1147 (?z gnus-tmp-score-char ?c)
1148 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1149 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1150 (?U gnus-tmp-unread ?c)
1151 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1153 (?t (gnus-summary-number-of-articles-in-thread
1154 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1156 (?e (gnus-summary-number-of-articles-in-thread
1157 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1159 (?u gnus-tmp-user-defined ?s)
1160 (?P (gnus-pick-line-number) ?d)
1161 (?B gnus-tmp-thread-tree-header-string ?s)
1162 (user-date (gnus-user-date
1163 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1164 "An alist of format specifications that can appear in summary lines.
1165 These are paired with what variables they correspond with, along with
1166 the type of the variable (string, integer, character, etc).")
1168 (defvar gnus-summary-dummy-line-format-alist
1169 `((?S gnus-tmp-subject ?s)
1170 (?N gnus-tmp-number ?d)
1171 (?u gnus-tmp-user-defined ?s)))
1173 (defvar gnus-summary-mode-line-format-alist
1174 `((?G gnus-tmp-group-name ?s)
1175 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1176 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1177 (?A gnus-tmp-article-number ?d)
1178 (?Z gnus-tmp-unread-and-unselected ?s)
1179 (?V gnus-version ?s)
1180 (?U gnus-tmp-unread-and-unticked ?d)
1181 (?S gnus-tmp-subject ?s)
1182 (?e gnus-tmp-unselected ?d)
1183 (?u gnus-tmp-user-defined ?s)
1184 (?d (length gnus-newsgroup-dormant) ?d)
1185 (?t (length gnus-newsgroup-marked) ?d)
1186 (?r (length gnus-newsgroup-reads) ?d)
1187 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1188 (?E gnus-newsgroup-expunged-tally ?d)
1189 (?s (gnus-current-score-file-nondirectory) ?s)))
1191 (defvar gnus-last-search-regexp nil
1192 "Default regexp for article search command.")
1194 (defvar gnus-summary-search-article-matched-data nil
1195 "Last matched data of article search command. It is the local variable
1196 in `gnus-article-buffer' which consists of the list of start position,
1197 end position and text.")
1199 (defvar gnus-last-shell-command nil
1200 "Default shell command on article.")
1202 (defvar gnus-newsgroup-begin nil)
1203 (defvar gnus-newsgroup-end nil)
1204 (defvar gnus-newsgroup-last-rmail nil)
1205 (defvar gnus-newsgroup-last-mail nil)
1206 (defvar gnus-newsgroup-last-folder nil)
1207 (defvar gnus-newsgroup-last-file nil)
1208 (defvar gnus-newsgroup-auto-expire nil)
1209 (defvar gnus-newsgroup-active nil)
1211 (defvar gnus-newsgroup-data nil)
1212 (defvar gnus-newsgroup-data-reverse nil)
1213 (defvar gnus-newsgroup-limit nil)
1214 (defvar gnus-newsgroup-limits nil)
1216 (defvar gnus-newsgroup-unreads nil
1217 "Sorted list of unread articles in the current newsgroup.")
1219 (defvar gnus-newsgroup-unselected nil
1220 "Sorted list of unselected unread articles in the current newsgroup.")
1222 (defvar gnus-newsgroup-reads nil
1223 "Alist of read articles and article marks in the current newsgroup.")
1225 (defvar gnus-newsgroup-expunged-tally nil)
1227 (defvar gnus-newsgroup-marked nil
1228 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1230 (defvar gnus-newsgroup-killed nil
1231 "List of ranges of articles that have been through the scoring process.")
1233 (defvar gnus-newsgroup-cached nil
1234 "Sorted list of articles that come from the article cache.")
1236 (defvar gnus-newsgroup-saved nil
1237 "List of articles that have been saved.")
1239 (defvar gnus-newsgroup-kill-headers nil)
1241 (defvar gnus-newsgroup-replied nil
1242 "List of articles that have been replied to in the current newsgroup.")
1244 (defvar gnus-newsgroup-forwarded nil
1245 "List of articles that have been forwarded in the current newsgroup.")
1247 (defvar gnus-newsgroup-recent nil
1248 "List of articles that have are recent in the current newsgroup.")
1250 (defvar gnus-newsgroup-expirable nil
1251 "Sorted list of articles in the current newsgroup that can be expired.")
1253 (defvar gnus-newsgroup-processable nil
1254 "List of articles in the current newsgroup that can be processed.")
1256 (defvar gnus-newsgroup-downloadable nil
1257 "Sorted list of articles in the current newsgroup that can be processed.")
1259 (defvar gnus-newsgroup-undownloaded nil
1260 "List of articles in the current newsgroup that haven't been downloaded..")
1262 (defvar gnus-newsgroup-unsendable nil
1263 "List of articles in the current newsgroup that won't be sent.")
1265 (defvar gnus-newsgroup-bookmarks nil
1266 "List of articles in the current newsgroup that have bookmarks.")
1268 (defvar gnus-newsgroup-dormant nil
1269 "Sorted list of dormant articles in the current newsgroup.")
1271 (defvar gnus-newsgroup-unseen nil
1272 "List of unseen articles in the current newsgroup.")
1274 (defvar gnus-newsgroup-seen nil
1275 "Range of seen articles in the current newsgroup.")
1277 (defvar gnus-newsgroup-articles nil
1278 "List of articles in the current newsgroup.")
1280 (defvar gnus-newsgroup-scored nil
1281 "List of scored articles in the current newsgroup.")
1283 (defvar gnus-newsgroup-incorporated nil
1284 "List of incorporated articles in the current newsgroup.")
1286 (defvar gnus-newsgroup-headers nil
1287 "List of article headers in the current newsgroup.")
1289 (defvar gnus-newsgroup-threads nil)
1291 (defvar gnus-newsgroup-prepared nil
1292 "Whether the current group has been prepared properly.")
1294 (defvar gnus-newsgroup-ancient nil
1295 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1297 (defvar gnus-newsgroup-sparse nil)
1299 (defvar gnus-current-article nil)
1300 (defvar gnus-article-current nil)
1301 (defvar gnus-current-headers nil)
1302 (defvar gnus-have-all-headers nil)
1303 (defvar gnus-last-article nil)
1304 (defvar gnus-newsgroup-history nil)
1305 (defvar gnus-newsgroup-charset nil)
1306 (defvar gnus-newsgroup-ephemeral-charset nil)
1307 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1309 (defvar gnus-article-before-search nil)
1311 (defconst gnus-summary-local-variables
1312 '(gnus-newsgroup-name
1313 gnus-newsgroup-begin gnus-newsgroup-end
1314 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1315 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1316 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1317 gnus-newsgroup-unselected gnus-newsgroup-marked
1318 gnus-newsgroup-reads gnus-newsgroup-saved
1319 gnus-newsgroup-replied gnus-newsgroup-forwarded
1320 gnus-newsgroup-recent
1321 gnus-newsgroup-expirable
1322 gnus-newsgroup-processable gnus-newsgroup-killed
1323 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1324 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1325 gnus-newsgroup-seen gnus-newsgroup-articles
1326 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1327 gnus-newsgroup-headers gnus-newsgroup-threads
1328 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1329 gnus-current-article gnus-current-headers gnus-have-all-headers
1330 gnus-last-article gnus-article-internal-prepare-hook
1331 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1332 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1333 gnus-thread-expunge-below
1334 gnus-score-alist gnus-current-score-file
1335 (gnus-summary-expunge-below . global)
1336 (gnus-summary-mark-below . global)
1337 (gnus-orphan-score . global)
1338 gnus-newsgroup-active gnus-scores-exclude-files
1339 gnus-newsgroup-history gnus-newsgroup-ancient
1340 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1341 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1342 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1343 (gnus-newsgroup-expunged-tally . 0)
1344 gnus-cache-removable-articles gnus-newsgroup-cached
1345 gnus-newsgroup-data gnus-newsgroup-data-reverse
1346 gnus-newsgroup-limit gnus-newsgroup-limits
1347 gnus-newsgroup-charset gnus-newsgroup-display
1348 gnus-newsgroup-incorporated)
1349 "Variables that are buffer-local to the summary buffers.")
1351 (defvar gnus-newsgroup-variables nil
1352 "A list of variables that have separate values in different newsgroups.
1353 A list of newsgroup (summary buffer) local variables, or cons of
1354 variables and their default values (when the default values are not
1355 nil), that should be made global while the summary buffer is active.
1356 These variables can be used to set variables in the group parameters
1357 while still allowing them to affect operations done in other
1358 buffers. For example:
1360 \(setq gnus-newsgroup-variables
1361 '(message-use-followup-to
1362 (gnus-visible-headers .
1363 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1366 ;; Byte-compiler warning.
1367 (eval-when-compile (defvar gnus-article-mode-map))
1369 ;; Subject simplification.
1371 (defun gnus-simplify-whitespace (str)
1372 "Remove excessive whitespace from STR."
1375 (while (string-match "[ \t][ \t]+" mystr)
1376 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1378 (substring mystr (match-end 0)))))
1380 (when (string-match "^[ \t]+" mystr)
1381 (setq mystr (substring mystr (match-end 0))))
1383 (when (string-match "[ \t]+$" mystr)
1384 (setq mystr (substring mystr 0 (match-beginning 0))))
1387 (defsubst gnus-simplify-subject-re (subject)
1388 "Remove \"Re:\" from subject lines."
1389 (if (string-match message-subject-re-regexp subject)
1390 (substring subject (match-end 0))
1393 (defun gnus-simplify-subject (subject &optional re-only)
1394 "Remove `Re:' and words in parentheses.
1395 If RE-ONLY is non-nil, strip leading `Re:'s only."
1396 (let ((case-fold-search t)) ;Ignore case.
1397 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1398 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1399 (setq subject (substring subject (match-end 0))))
1400 ;; Remove uninteresting prefixes.
1401 (when (and (not re-only)
1402 gnus-simplify-ignored-prefixes
1403 (string-match gnus-simplify-ignored-prefixes subject))
1404 (setq subject (substring subject (match-end 0))))
1405 ;; Remove words in parentheses from end.
1407 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1408 (setq subject (substring subject 0 (match-beginning 0)))))
1409 ;; Return subject string.
1412 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1414 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1415 (goto-char (point-min))
1416 (while (re-search-forward regexp nil t)
1417 (replace-match (or newtext ""))))
1419 (defun gnus-simplify-buffer-fuzzy ()
1420 "Simplify string in the buffer fuzzily.
1421 The string in the accessible portion of the current buffer is simplified.
1422 It is assumed to be a single-line subject.
1423 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1424 matter is removed. Additional things can be deleted by setting
1425 `gnus-simplify-subject-fuzzy-regexp'."
1426 (let ((case-fold-search t)
1428 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1430 (while (not (eq modified-tick (buffer-modified-tick)))
1431 (setq modified-tick (buffer-modified-tick))
1433 ((listp gnus-simplify-subject-fuzzy-regexp)
1434 (mapcar 'gnus-simplify-buffer-fuzzy-step
1435 gnus-simplify-subject-fuzzy-regexp))
1436 (gnus-simplify-subject-fuzzy-regexp
1437 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1438 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1439 (gnus-simplify-buffer-fuzzy-step
1440 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1441 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1443 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1444 (gnus-simplify-buffer-fuzzy-step " +" " ")
1445 (gnus-simplify-buffer-fuzzy-step " $")
1446 (gnus-simplify-buffer-fuzzy-step "^ +")))
1448 (defun gnus-simplify-subject-fuzzy (subject)
1449 "Simplify a subject string fuzzily.
1450 See `gnus-simplify-buffer-fuzzy' for details."
1452 (gnus-set-work-buffer)
1453 (let ((case-fold-search t))
1454 ;; Remove uninteresting prefixes.
1455 (when (and gnus-simplify-ignored-prefixes
1456 (string-match gnus-simplify-ignored-prefixes subject))
1457 (setq subject (substring subject (match-end 0))))
1459 (inline (gnus-simplify-buffer-fuzzy))
1462 (defsubst gnus-simplify-subject-fully (subject)
1463 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1465 (gnus-simplify-subject-functions
1466 (gnus-map-function gnus-simplify-subject-functions subject))
1467 ((null gnus-summary-gather-subject-limit)
1468 (gnus-simplify-subject-re subject))
1469 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1470 (gnus-simplify-subject-fuzzy subject))
1471 ((numberp gnus-summary-gather-subject-limit)
1472 (gnus-limit-string (gnus-simplify-subject-re subject)
1473 gnus-summary-gather-subject-limit))
1477 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1478 "Check whether two subjects are equal.
1479 If optional argument simple-first is t, first argument is already
1482 ((null simple-first)
1483 (equal (gnus-simplify-subject-fully s1)
1484 (gnus-simplify-subject-fully s2)))
1487 (gnus-simplify-subject-fully s2)))))
1489 (defun gnus-summary-bubble-group ()
1490 "Increase the score of the current group.
1491 This is a handy function to add to `gnus-summary-exit-hook' to
1492 increase the score of each group you read."
1493 (gnus-group-add-score gnus-newsgroup-name))
1497 ;;; Gnus summary mode
1500 (put 'gnus-summary-mode 'mode-class 'special)
1502 (defvar gnus-article-commands-menu)
1505 ;; Non-orthogonal keys
1507 (gnus-define-keys gnus-summary-mode-map
1508 " " gnus-summary-next-page
1509 "\177" gnus-summary-prev-page
1510 [delete] gnus-summary-prev-page
1511 [backspace] gnus-summary-prev-page
1512 "\r" gnus-summary-scroll-up
1513 "\M-\r" gnus-summary-scroll-down
1514 "n" gnus-summary-next-unread-article
1515 "p" gnus-summary-prev-unread-article
1516 "N" gnus-summary-next-article
1517 "P" gnus-summary-prev-article
1518 "\M-\C-n" gnus-summary-next-same-subject
1519 "\M-\C-p" gnus-summary-prev-same-subject
1520 "\M-n" gnus-summary-next-unread-subject
1521 "\M-p" gnus-summary-prev-unread-subject
1522 "." gnus-summary-first-unread-article
1523 "," gnus-summary-best-unread-article
1524 "\M-s" gnus-summary-search-article-forward
1525 "\M-r" gnus-summary-search-article-backward
1526 "<" gnus-summary-beginning-of-article
1527 ">" gnus-summary-end-of-article
1528 "j" gnus-summary-goto-article
1529 "^" gnus-summary-refer-parent-article
1530 "\M-^" gnus-summary-refer-article
1531 "u" gnus-summary-tick-article-forward
1532 "!" gnus-summary-tick-article-forward
1533 "U" gnus-summary-tick-article-backward
1534 "d" gnus-summary-mark-as-read-forward
1535 "D" gnus-summary-mark-as-read-backward
1536 "E" gnus-summary-mark-as-expirable
1537 "\M-u" gnus-summary-clear-mark-forward
1538 "\M-U" gnus-summary-clear-mark-backward
1539 "k" gnus-summary-kill-same-subject-and-select
1540 "\C-k" gnus-summary-kill-same-subject
1541 "\M-\C-k" gnus-summary-kill-thread
1542 "\M-\C-l" gnus-summary-lower-thread
1543 "e" gnus-summary-edit-article
1544 "#" gnus-summary-mark-as-processable
1545 "\M-#" gnus-summary-unmark-as-processable
1546 "\M-\C-t" gnus-summary-toggle-threads
1547 "\M-\C-s" gnus-summary-show-thread
1548 "\M-\C-h" gnus-summary-hide-thread
1549 "\M-\C-f" gnus-summary-next-thread
1550 "\M-\C-b" gnus-summary-prev-thread
1551 [(meta down)] gnus-summary-next-thread
1552 [(meta up)] gnus-summary-prev-thread
1553 "\M-\C-u" gnus-summary-up-thread
1554 "\M-\C-d" gnus-summary-down-thread
1555 "&" gnus-summary-execute-command
1556 "c" gnus-summary-catchup-and-exit
1557 "\C-w" gnus-summary-mark-region-as-read
1558 "\C-t" gnus-summary-toggle-truncation
1559 "?" gnus-summary-mark-as-dormant
1560 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1561 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1562 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1563 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1564 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1565 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1566 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1567 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1568 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1569 "=" gnus-summary-expand-window
1570 "\C-x\C-s" gnus-summary-reselect-current-group
1571 "\M-g" gnus-summary-rescan-group
1572 "w" gnus-summary-stop-page-breaking
1573 "\C-c\C-r" gnus-summary-caesar-message
1574 "\M-t" gnus-summary-toggle-mime
1575 "f" gnus-summary-followup
1576 "F" gnus-summary-followup-with-original
1577 "C" gnus-summary-cancel-article
1578 "r" gnus-summary-reply
1579 "R" gnus-summary-reply-with-original
1580 "\C-c\C-f" gnus-summary-mail-forward
1581 "o" gnus-summary-save-article
1582 "\C-o" gnus-summary-save-article-mail
1583 "|" gnus-summary-pipe-output
1584 "\M-k" gnus-summary-edit-local-kill
1585 "\M-K" gnus-summary-edit-global-kill
1587 "\C-c\C-d" gnus-summary-describe-group
1588 "q" gnus-summary-exit
1589 "Q" gnus-summary-exit-no-update
1590 "\C-c\C-i" gnus-info-find-node
1591 gnus-mouse-2 gnus-mouse-pick-article
1592 "m" gnus-summary-mail-other-window
1593 "a" gnus-summary-post-news
1594 "i" gnus-summary-news-other-window
1595 "x" gnus-summary-limit-to-unread
1596 "s" gnus-summary-isearch-article
1597 "t" gnus-article-toggle-headers
1598 "g" gnus-summary-show-article
1599 "l" gnus-summary-goto-last-article
1600 "v" gnus-summary-preview-mime-message
1601 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1602 "\C-d" gnus-summary-enter-digest-group
1603 "\M-\C-d" gnus-summary-read-document
1604 "\M-\C-e" gnus-summary-edit-parameters
1605 "\M-\C-a" gnus-summary-customize-parameters
1607 "\C-c\C-n" gnus-namazu-search
1608 "*" gnus-cache-enter-article
1609 "\M-*" gnus-cache-remove-article
1610 "\M-&" gnus-summary-universal-argument
1611 "\C-l" gnus-recenter
1612 "I" gnus-summary-increase-score
1613 "L" gnus-summary-lower-score
1614 "\M-i" gnus-symbolic-argument
1615 "h" gnus-summary-select-article-buffer
1617 "V" gnus-summary-score-map
1618 "X" gnus-uu-extract-map
1619 "S" gnus-summary-send-map)
1621 ;; Sort of orthogonal keymap
1622 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1623 "t" gnus-summary-tick-article-forward
1624 "!" gnus-summary-tick-article-forward
1625 "d" gnus-summary-mark-as-read-forward
1626 "r" gnus-summary-mark-as-read-forward
1627 "c" gnus-summary-clear-mark-forward
1628 " " gnus-summary-clear-mark-forward
1629 "e" gnus-summary-mark-as-expirable
1630 "x" gnus-summary-mark-as-expirable
1631 "?" gnus-summary-mark-as-dormant
1632 "b" gnus-summary-set-bookmark
1633 "B" gnus-summary-remove-bookmark
1634 "#" gnus-summary-mark-as-processable
1635 "\M-#" gnus-summary-unmark-as-processable
1636 "S" gnus-summary-limit-include-expunged
1637 "C" gnus-summary-catchup
1638 "H" gnus-summary-catchup-to-here
1639 "h" gnus-summary-catchup-from-here
1640 "\C-c" gnus-summary-catchup-all
1641 "k" gnus-summary-kill-same-subject-and-select
1642 "K" gnus-summary-kill-same-subject
1643 "P" gnus-uu-mark-map)
1645 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1646 "c" gnus-summary-clear-above
1647 "u" gnus-summary-tick-above
1648 "m" gnus-summary-mark-above
1649 "k" gnus-summary-kill-below)
1651 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1652 "/" gnus-summary-limit-to-subject
1653 "n" gnus-summary-limit-to-articles
1654 "w" gnus-summary-pop-limit
1655 "s" gnus-summary-limit-to-subject
1656 "a" gnus-summary-limit-to-author
1657 "u" gnus-summary-limit-to-unread
1658 "m" gnus-summary-limit-to-marks
1659 "M" gnus-summary-limit-exclude-marks
1660 "v" gnus-summary-limit-to-score
1661 "*" gnus-summary-limit-include-cached
1662 "D" gnus-summary-limit-include-dormant
1663 "T" gnus-summary-limit-include-thread
1664 "d" gnus-summary-limit-exclude-dormant
1665 "t" gnus-summary-limit-to-age
1666 "x" gnus-summary-limit-to-extra
1667 "p" gnus-summary-limit-to-display-predicate
1668 "E" gnus-summary-limit-include-expunged
1669 "c" gnus-summary-limit-exclude-childless-dormant
1670 "C" gnus-summary-limit-mark-excluded-as-read
1671 "o" gnus-summary-insert-old-articles
1672 "N" gnus-summary-insert-new-articles)
1674 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1675 "n" gnus-summary-next-unread-article
1676 "p" gnus-summary-prev-unread-article
1677 "N" gnus-summary-next-article
1678 "P" gnus-summary-prev-article
1679 "\C-n" gnus-summary-next-same-subject
1680 "\C-p" gnus-summary-prev-same-subject
1681 "\M-n" gnus-summary-next-unread-subject
1682 "\M-p" gnus-summary-prev-unread-subject
1683 "f" gnus-summary-first-unread-article
1684 "b" gnus-summary-best-unread-article
1685 "j" gnus-summary-goto-article
1686 "g" gnus-summary-goto-subject
1687 "l" gnus-summary-goto-last-article
1688 "o" gnus-summary-pop-article)
1690 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1691 "k" gnus-summary-kill-thread
1692 "l" gnus-summary-lower-thread
1693 "i" gnus-summary-raise-thread
1694 "T" gnus-summary-toggle-threads
1695 "t" gnus-summary-rethread-current
1696 "^" gnus-summary-reparent-thread
1697 "s" gnus-summary-show-thread
1698 "S" gnus-summary-show-all-threads
1699 "h" gnus-summary-hide-thread
1700 "H" gnus-summary-hide-all-threads
1701 "n" gnus-summary-next-thread
1702 "p" gnus-summary-prev-thread
1703 "u" gnus-summary-up-thread
1704 "o" gnus-summary-top-thread
1705 "d" gnus-summary-down-thread
1706 "#" gnus-uu-mark-thread
1707 "\M-#" gnus-uu-unmark-thread)
1709 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1710 "g" gnus-summary-prepare
1711 "c" gnus-summary-insert-cached-articles)
1713 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1714 "c" gnus-summary-catchup-and-exit
1715 "C" gnus-summary-catchup-all-and-exit
1716 "E" gnus-summary-exit-no-update
1717 "J" gnus-summary-jump-to-other-group
1718 "Q" gnus-summary-exit
1719 "Z" gnus-summary-exit
1720 "n" gnus-summary-catchup-and-goto-next-group
1721 "R" gnus-summary-reselect-current-group
1722 "G" gnus-summary-rescan-group
1723 "N" gnus-summary-next-group
1724 "s" gnus-summary-save-newsrc
1725 "P" gnus-summary-prev-group)
1727 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1728 " " gnus-summary-next-page
1729 "n" gnus-summary-next-page
1730 "\177" gnus-summary-prev-page
1731 [delete] gnus-summary-prev-page
1732 "p" gnus-summary-prev-page
1733 "\r" gnus-summary-scroll-up
1734 "\M-\r" gnus-summary-scroll-down
1735 "<" gnus-summary-beginning-of-article
1736 ">" gnus-summary-end-of-article
1737 "b" gnus-summary-beginning-of-article
1738 "e" gnus-summary-end-of-article
1739 "^" gnus-summary-refer-parent-article
1740 "r" gnus-summary-refer-parent-article
1741 "D" gnus-summary-enter-digest-group
1742 "R" gnus-summary-refer-references
1743 "T" gnus-summary-refer-thread
1744 "g" gnus-summary-show-article
1745 "s" gnus-summary-isearch-article
1746 "P" gnus-summary-print-article
1747 "M" gnus-mailing-list-insinuate
1748 "t" gnus-article-babel)
1750 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1751 "b" gnus-article-add-buttons
1752 "B" gnus-article-add-buttons-to-head
1753 "o" gnus-article-treat-overstrike
1754 "e" gnus-article-emphasize
1755 "w" gnus-article-fill-cited-article
1756 "Q" gnus-article-fill-long-lines
1757 "C" gnus-article-capitalize-sentences
1758 "c" gnus-article-remove-cr
1759 "Z" gnus-article-decode-HZ
1760 "h" gnus-article-wash-html
1761 "u" gnus-article-unsplit-urls
1762 "f" gnus-article-display-x-face
1763 "l" gnus-summary-stop-page-breaking
1764 "r" gnus-summary-caesar-message
1765 "t" gnus-article-toggle-headers
1766 "g" gnus-treat-smiley
1767 "v" gnus-summary-verbose-headers
1768 "m" gnus-summary-toggle-mime
1769 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1770 "p" gnus-article-verify-x-pgp-sig
1771 "d" gnus-article-treat-dumbquotes)
1773 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1774 "a" gnus-article-hide
1775 "h" gnus-article-toggle-headers
1776 "b" gnus-article-hide-boring-headers
1777 "s" gnus-article-hide-signature
1778 "c" gnus-article-hide-citation
1779 "C" gnus-article-hide-citation-in-followups
1780 "l" gnus-article-hide-list-identifiers
1781 "p" gnus-article-hide-pgp
1782 "B" gnus-article-strip-banner
1783 "P" gnus-article-hide-pem
1784 "\C-c" gnus-article-hide-citation-maybe)
1786 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1787 "a" gnus-article-highlight
1788 "h" gnus-article-highlight-headers
1789 "c" gnus-article-highlight-citation
1790 "s" gnus-article-highlight-signature)
1792 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1793 "f" gnus-article-treat-fold-headers
1794 "u" gnus-article-treat-unfold-headers
1795 "n" gnus-article-treat-fold-newsgroups)
1797 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1798 "x" gnus-article-display-x-face
1799 "s" gnus-treat-smiley
1800 "D" gnus-article-remove-images
1801 "f" gnus-treat-from-picon
1802 "m" gnus-treat-mail-picon
1803 "n" gnus-treat-newsgroups-picon)
1805 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1806 "z" gnus-article-date-ut
1807 "u" gnus-article-date-ut
1808 "l" gnus-article-date-local
1809 "p" gnus-article-date-english
1810 "e" gnus-article-date-lapsed
1811 "o" gnus-article-date-original
1812 "i" gnus-article-date-iso8601
1813 "s" gnus-article-date-user)
1815 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1816 "t" gnus-article-remove-trailing-blank-lines
1817 "l" gnus-article-strip-leading-blank-lines
1818 "m" gnus-article-strip-multiple-blank-lines
1819 "a" gnus-article-strip-blank-lines
1820 "A" gnus-article-strip-all-blank-lines
1821 "s" gnus-article-strip-leading-space
1822 "e" gnus-article-strip-trailing-space
1823 "w" gnus-article-remove-leading-whitespace)
1825 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1827 "f" gnus-summary-fetch-faq
1828 "d" gnus-summary-describe-group
1829 "h" gnus-summary-describe-briefly
1830 "i" gnus-info-find-node)
1832 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1833 "e" gnus-summary-expire-articles
1834 "\M-\C-e" gnus-summary-expire-articles-now
1835 "\177" gnus-summary-delete-article
1836 [delete] gnus-summary-delete-article
1837 [backspace] gnus-summary-delete-article
1838 "m" gnus-summary-move-article
1839 "r" gnus-summary-respool-article
1840 "w" gnus-summary-edit-article
1841 "c" gnus-summary-copy-article
1842 "B" gnus-summary-crosspost-article
1843 "q" gnus-summary-respool-query
1844 "t" gnus-summary-respool-trace
1845 "i" gnus-summary-import-article
1846 "I" gnus-summary-create-article
1847 "p" gnus-summary-article-posted-p)
1849 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1850 "o" gnus-summary-save-article
1851 "m" gnus-summary-save-article-mail
1852 "F" gnus-summary-write-article-file
1853 "r" gnus-summary-save-article-rmail
1854 "f" gnus-summary-save-article-file
1855 "b" gnus-summary-save-article-body-file
1856 "h" gnus-summary-save-article-folder
1857 "v" gnus-summary-save-article-vm
1858 "p" gnus-summary-pipe-output
1859 "P" gnus-summary-muttprint
1860 "s" gnus-soup-add-article)
1862 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1863 "b" gnus-summary-display-buttonized
1864 "m" gnus-summary-repair-multipart
1865 "v" gnus-article-view-part
1866 "o" gnus-article-save-part
1867 "c" gnus-article-copy-part
1868 "C" gnus-article-view-part-as-charset
1869 "e" gnus-article-externalize-part
1870 "E" gnus-article-encrypt-body
1871 "i" gnus-article-inline-part
1872 "|" gnus-article-pipe-part))
1874 (defvar gnus-article-post-menu nil)
1876 (defun gnus-summary-make-menu-bar ()
1877 (gnus-turn-off-edit-menu 'summary)
1879 (unless (boundp 'gnus-summary-misc-menu)
1882 gnus-summary-kill-menu gnus-summary-mode-map ""
1887 ["Customize" gnus-score-customize t])
1888 (gnus-make-score-map 'increase)
1889 (gnus-make-score-map 'lower)
1891 ["Kill below" gnus-summary-kill-below t]
1892 ["Mark above" gnus-summary-mark-above t]
1893 ["Tick above" gnus-summary-tick-above t]
1894 ["Clear above" gnus-summary-clear-above t])
1895 ["Current score" gnus-summary-current-score t]
1896 ["Set score" gnus-summary-set-score t]
1897 ["Switch current score file..." gnus-score-change-score-file t]
1898 ["Set mark below..." gnus-score-set-mark-below t]
1899 ["Set expunge below..." gnus-score-set-expunge-below t]
1900 ["Edit current score file" gnus-score-edit-current-scores t]
1901 ["Edit score file" gnus-score-edit-file t]
1902 ["Trace score" gnus-score-find-trace t]
1903 ["Find words" gnus-score-find-favourite-words t]
1904 ["Rescore buffer" gnus-summary-rescore t]
1905 ["Increase score..." gnus-summary-increase-score t]
1906 ["Lower score..." gnus-summary-lower-score t]))))
1908 ;; Define both the Article menu in the summary buffer and the
1909 ;; equivalent Commands menu in the article buffer here for
1913 ["All" gnus-article-hide t]
1914 ["Headers" gnus-article-toggle-headers t]
1915 ["Signature" gnus-article-hide-signature t]
1916 ["Citation" gnus-article-hide-citation t]
1917 ["List identifiers" gnus-article-hide-list-identifiers t]
1918 ["PGP" gnus-article-hide-pgp t]
1919 ["Banner" gnus-article-strip-banner t]
1920 ["Boring headers" gnus-article-hide-boring-headers t])
1922 ["All" gnus-article-highlight t]
1923 ["Headers" gnus-article-highlight-headers t]
1924 ["Signature" gnus-article-highlight-signature t]
1925 ["Citation" gnus-article-highlight-citation t])
1927 ["Local" gnus-article-date-local t]
1928 ["ISO8601" gnus-article-date-iso8601 t]
1929 ["UT" gnus-article-date-ut t]
1930 ["Original" gnus-article-date-original t]
1931 ["Lapsed" gnus-article-date-lapsed t]
1932 ["User-defined" gnus-article-date-user t])
1934 ["Remove images" gnus-article-remove-images t]
1935 ["Toggle smiley" gnus-treat-smiley t]
1936 ["Show X-Face" gnus-article-display-x-face t]
1937 ["Show picons in From" gnus-treat-from-picon t]
1938 ["Show picons in mail headers" gnus-treat-mail-picon t]
1939 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1942 ["Leading" gnus-article-strip-leading-blank-lines t]
1943 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1944 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1945 ["All of the above" gnus-article-strip-blank-lines t]
1946 ["All" gnus-article-strip-all-blank-lines t]
1947 ["Leading space" gnus-article-strip-leading-space t]
1948 ["Trailing space" gnus-article-strip-trailing-space t]
1949 ["Leading space in headers"
1950 gnus-article-remove-leading-whitespace t])
1951 ["Overstrike" gnus-article-treat-overstrike t]
1952 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1953 ["Emphasis" gnus-article-emphasize t]
1954 ["Word wrap" gnus-article-fill-cited-article t]
1955 ["Fill long lines" gnus-article-fill-long-lines t]
1956 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1957 ["CR" gnus-article-remove-cr t]
1958 ["Rot 13" gnus-summary-caesar-message
1959 ,@(if (featurep 'xemacs) '(t)
1960 '(:help "\"Caesar rotate\" article by 13"))]
1961 ["Unix pipe" gnus-summary-pipe-message t]
1962 ["Add buttons" gnus-article-add-buttons t]
1963 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1964 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1965 ["Toggle MIME" gnus-summary-toggle-mime t]
1966 ["Verbose header" gnus-summary-verbose-headers t]
1967 ["Toggle header" gnus-summary-toggle-header t]
1968 ["Unfold headers" gnus-article-treat-unfold-headers t]
1969 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1970 ["Html" gnus-article-wash-html t]
1971 ["URLs" gnus-article-unsplit-urls t]
1972 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1973 ["HZ" gnus-article-decode-HZ t])
1975 ["Save in default format" gnus-summary-save-article
1976 ,@(if (featurep 'xemacs) '(t)
1977 '(:help "Save article using default method"))]
1978 ["Save in file" gnus-summary-save-article-file
1979 ,@(if (featurep 'xemacs) '(t)
1980 '(:help "Save article in file"))]
1981 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1982 ["Save in MH folder" gnus-summary-save-article-folder t]
1983 ["Save in VM folder" gnus-summary-save-article-vm t]
1984 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1985 ["Save body in file" gnus-summary-save-article-body-file t]
1986 ["Pipe through a filter" gnus-summary-pipe-output t]
1987 ["Add to SOUP packet" gnus-soup-add-article t]
1988 ["Print with Muttprint" gnus-summary-muttprint t]
1989 ["Print" gnus-summary-print-article t])
1991 ["Respool article..." gnus-summary-respool-article t]
1992 ["Move article..." gnus-summary-move-article
1993 (gnus-check-backend-function
1994 'request-move-article gnus-newsgroup-name)]
1995 ["Copy article..." gnus-summary-copy-article t]
1996 ["Crosspost article..." gnus-summary-crosspost-article
1997 (gnus-check-backend-function
1998 'request-replace-article gnus-newsgroup-name)]
1999 ["Import file..." gnus-summary-import-article t]
2000 ["Create article..." gnus-summary-create-article t]
2001 ["Check if posted" gnus-summary-article-posted-p t]
2002 ["Edit article" gnus-summary-edit-article
2003 (not (gnus-group-read-only-p))]
2004 ["Delete article" gnus-summary-delete-article
2005 (gnus-check-backend-function
2006 'request-expire-articles gnus-newsgroup-name)]
2007 ["Query respool" gnus-summary-respool-query t]
2008 ["Trace respool" gnus-summary-respool-trace t]
2009 ["Delete expirable articles" gnus-summary-expire-articles-now
2010 (gnus-check-backend-function
2011 'request-expire-articles gnus-newsgroup-name)])
2013 ["Uudecode" gnus-uu-decode-uu
2014 ,@(if (featurep 'xemacs) '(t)
2015 '(:help "Decode uuencoded article(s)"))]
2016 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2017 ["Unshar" gnus-uu-decode-unshar t]
2018 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2019 ["Save" gnus-uu-decode-save t]
2020 ["Binhex" gnus-uu-decode-binhex t]
2021 ["Postscript" gnus-uu-decode-postscript t])
2023 ["Enter article" gnus-cache-enter-article t]
2024 ["Remove article" gnus-cache-remove-article t])
2025 ["Translate" gnus-article-babel t]
2026 ["Select article buffer" gnus-summary-select-article-buffer t]
2027 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2028 ["Isearch article..." gnus-summary-isearch-article t]
2029 ["Beginning of the article" gnus-summary-beginning-of-article t]
2030 ["End of the article" gnus-summary-end-of-article t]
2031 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2032 ["Fetch referenced articles" gnus-summary-refer-references t]
2033 ["Fetch current thread" gnus-summary-refer-thread t]
2034 ["Fetch article with id..." gnus-summary-refer-article t]
2035 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2036 ["Redisplay" gnus-summary-show-article t]
2037 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2039 gnus-summary-article-menu gnus-summary-mode-map ""
2040 (cons "Article" innards))
2042 (if (not (keymapp gnus-summary-article-menu))
2044 gnus-article-commands-menu gnus-article-mode-map ""
2045 (cons "Commands" innards))
2046 ;; in Emacs, don't share menu.
2047 (setq gnus-article-commands-menu
2048 (copy-keymap gnus-summary-article-menu))
2049 (define-key gnus-article-mode-map [menu-bar commands]
2050 (cons "Commands" gnus-article-commands-menu))))
2053 gnus-summary-thread-menu gnus-summary-mode-map ""
2055 ["Toggle threading" gnus-summary-toggle-threads t]
2056 ["Hide threads" gnus-summary-hide-all-threads t]
2057 ["Show threads" gnus-summary-show-all-threads t]
2058 ["Hide thread" gnus-summary-hide-thread t]
2059 ["Show thread" gnus-summary-show-thread t]
2060 ["Go to next thread" gnus-summary-next-thread t]
2061 ["Go to previous thread" gnus-summary-prev-thread t]
2062 ["Go down thread" gnus-summary-down-thread t]
2063 ["Go up thread" gnus-summary-up-thread t]
2064 ["Top of thread" gnus-summary-top-thread t]
2065 ["Mark thread as read" gnus-summary-kill-thread t]
2066 ["Lower thread score" gnus-summary-lower-thread t]
2067 ["Raise thread score" gnus-summary-raise-thread t]
2068 ["Rethread current" gnus-summary-rethread-current t]))
2071 gnus-summary-post-menu gnus-summary-mode-map ""
2073 ["Send a message (mail or news)" gnus-summary-post-news
2074 ,@(if (featurep 'xemacs) '(t)
2075 '(:help "Post an article"))]
2076 ["Followup" gnus-summary-followup
2077 ,@(if (featurep 'xemacs) '(t)
2078 '(:help "Post followup to this article"))]
2079 ["Followup and yank" gnus-summary-followup-with-original
2080 ,@(if (featurep 'xemacs) '(t)
2081 '(:help "Post followup to this article, quoting its contents"))]
2082 ["Supersede article" gnus-summary-supersede-article t]
2083 ["Cancel article" gnus-summary-cancel-article
2084 ,@(if (featurep 'xemacs) '(t)
2085 '(:help "Cancel an article you posted"))]
2086 ["Reply" gnus-summary-reply t]
2087 ["Reply and yank" gnus-summary-reply-with-original t]
2088 ["Wide reply" gnus-summary-wide-reply t]
2089 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2090 ,@(if (featurep 'xemacs) '(t)
2091 '(:help "Mail a reply, quoting this article"))]
2092 ["Very wide reply" gnus-summary-very-wide-reply t]
2093 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2094 ,@(if (featurep 'xemacs) '(t)
2095 '(:help "Mail a very wide reply, quoting this article"))]
2096 ["Mail forward" gnus-summary-mail-forward t]
2097 ["Post forward" gnus-summary-post-forward t]
2098 ["Digest and mail" gnus-summary-digest-mail-forward t]
2099 ["Digest and post" gnus-summary-digest-post-forward t]
2100 ["Resend message" gnus-summary-resend-message t]
2101 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2102 ["Send a mail" gnus-summary-mail-other-window t]
2103 ["Create a local message" gnus-summary-news-other-window t]
2104 ["Uuencode and post" gnus-uu-post-news
2105 ,@(if (featurep 'xemacs) '(t)
2106 '(:help "Post a uuencoded article"))]
2107 ["Followup via news" gnus-summary-followup-to-mail t]
2108 ["Followup via news and yank"
2109 gnus-summary-followup-to-mail-with-original t]
2111 ;;["Send" gnus-summary-send-draft t]
2112 ;;["Send bounced" gnus-resend-bounced-mail t])
2116 ((not (keymapp gnus-summary-post-menu))
2117 (setq gnus-article-post-menu gnus-summary-post-menu))
2118 ((not gnus-article-post-menu)
2119 ;; Don't share post menu.
2120 (setq gnus-article-post-menu
2121 (copy-keymap gnus-summary-post-menu))))
2122 (define-key gnus-article-mode-map [menu-bar post]
2123 (cons "Post" gnus-article-post-menu))
2126 gnus-summary-misc-menu gnus-summary-mode-map ""
2129 ["Mark as read" gnus-summary-mark-as-read-forward t]
2130 ["Mark same subject and select"
2131 gnus-summary-kill-same-subject-and-select t]
2132 ["Mark same subject" gnus-summary-kill-same-subject t]
2133 ["Catchup" gnus-summary-catchup
2134 ,@(if (featurep 'xemacs) '(t)
2135 '(:help "Mark unread articles in this group as read"))]
2136 ["Catchup all" gnus-summary-catchup-all t]
2137 ["Catchup to here" gnus-summary-catchup-to-here t]
2138 ["Catchup from here" gnus-summary-catchup-from-here t]
2139 ["Catchup region" gnus-summary-mark-region-as-read t]
2140 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2142 ["Tick" gnus-summary-tick-article-forward t]
2143 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2144 ["Remove marks" gnus-summary-clear-mark-forward t]
2145 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2146 ["Set bookmark" gnus-summary-set-bookmark t]
2147 ["Remove bookmark" gnus-summary-remove-bookmark t])
2149 ["Marks..." gnus-summary-limit-to-marks t]
2150 ["Subject..." gnus-summary-limit-to-subject t]
2151 ["Author..." gnus-summary-limit-to-author t]
2152 ["Age..." gnus-summary-limit-to-age t]
2153 ["Extra..." gnus-summary-limit-to-extra t]
2154 ["Score" gnus-summary-limit-to-score t]
2155 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2156 ["Unread" gnus-summary-limit-to-unread t]
2157 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2158 ["Articles" gnus-summary-limit-to-articles t]
2159 ["Pop limit" gnus-summary-pop-limit t]
2160 ["Show dormant" gnus-summary-limit-include-dormant t]
2161 ["Hide childless dormant"
2162 gnus-summary-limit-exclude-childless-dormant t]
2163 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2164 ["Hide marked" gnus-summary-limit-exclude-marks t]
2165 ["Show expunged" gnus-summary-limit-include-expunged t])
2167 ["Set mark" gnus-summary-mark-as-processable t]
2168 ["Remove mark" gnus-summary-unmark-as-processable t]
2169 ["Remove all marks" gnus-summary-unmark-all-processable t]
2170 ["Mark above" gnus-uu-mark-over t]
2171 ["Mark series" gnus-uu-mark-series t]
2172 ["Mark region" gnus-uu-mark-region t]
2173 ["Unmark region" gnus-uu-unmark-region t]
2174 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2175 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2176 ["Mark all" gnus-uu-mark-all t]
2177 ["Mark buffer" gnus-uu-mark-buffer t]
2178 ["Mark sparse" gnus-uu-mark-sparse t]
2179 ["Mark thread" gnus-uu-mark-thread t]
2180 ["Unmark thread" gnus-uu-unmark-thread t]
2181 ("Process Mark Sets"
2182 ["Kill" gnus-summary-kill-process-mark t]
2183 ["Yank" gnus-summary-yank-process-mark
2184 gnus-newsgroup-process-stack]
2185 ["Save" gnus-summary-save-process-mark t]))
2187 ["Page forward" gnus-summary-next-page
2188 ,@(if (featurep 'xemacs) '(t)
2189 '(:help "Show next page of article"))]
2190 ["Page backward" gnus-summary-prev-page
2191 ,@(if (featurep 'xemacs) '(t)
2192 '(:help "Show previous page of article"))]
2193 ["Line forward" gnus-summary-scroll-up t])
2195 ["Next unread article" gnus-summary-next-unread-article t]
2196 ["Previous unread article" gnus-summary-prev-unread-article t]
2197 ["Next article" gnus-summary-next-article t]
2198 ["Previous article" gnus-summary-prev-article t]
2199 ["Next unread subject" gnus-summary-next-unread-subject t]
2200 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2201 ["Next article same subject" gnus-summary-next-same-subject t]
2202 ["Previous article same subject" gnus-summary-prev-same-subject t]
2203 ["First unread article" gnus-summary-first-unread-article t]
2204 ["Best unread article" gnus-summary-best-unread-article t]
2205 ["Go to subject number..." gnus-summary-goto-subject t]
2206 ["Go to article number..." gnus-summary-goto-article t]
2207 ["Go to the last article" gnus-summary-goto-last-article t]
2208 ["Pop article off history" gnus-summary-pop-article t])
2210 ["Sort by number" gnus-summary-sort-by-number t]
2211 ["Sort by author" gnus-summary-sort-by-author t]
2212 ["Sort by subject" gnus-summary-sort-by-subject t]
2213 ["Sort by date" gnus-summary-sort-by-date t]
2214 ["Sort by score" gnus-summary-sort-by-score t]
2215 ["Sort by lines" gnus-summary-sort-by-lines t]
2216 ["Sort by characters" gnus-summary-sort-by-chars t]
2217 ["Original sort" gnus-summary-sort-by-original t])
2219 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2220 ["Describe group" gnus-summary-describe-group t]
2221 ["Read manual" gnus-info-find-node t])
2223 ["Pick and read" gnus-pick-mode t]
2224 ["Binary" gnus-binary-mode t])
2226 ["Regenerate" gnus-summary-prepare t]
2227 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2228 ["Toggle threading" gnus-summary-toggle-threads t])
2229 ["See old articles" gnus-summary-insert-old-articles t]
2230 ["See new articles" gnus-summary-insert-new-articles t]
2231 ["Filter articles..." gnus-summary-execute-command t]
2232 ["Run command on subjects..." gnus-summary-universal-argument t]
2233 ["Search articles forward..." gnus-summary-search-article-forward t]
2234 ["Search articles backward..." gnus-summary-search-article-backward t]
2235 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2236 ["Expand window" gnus-summary-expand-window t]
2237 ["Expire expirable articles" gnus-summary-expire-articles
2238 (gnus-check-backend-function
2239 'request-expire-articles gnus-newsgroup-name)]
2240 ["Edit local kill file" gnus-summary-edit-local-kill t]
2241 ["Edit main kill file" gnus-summary-edit-global-kill t]
2242 ["Edit group parameters" gnus-summary-edit-parameters t]
2243 ["Customize group parameters" gnus-summary-customize-parameters t]
2244 ["Send a bug report" gnus-bug t]
2246 ["Catchup and exit" gnus-summary-catchup-and-exit
2247 ,@(if (featurep 'xemacs) '(t)
2248 '(:help "Mark unread articles in this group as read, then exit"))]
2249 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2250 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2251 ["Exit group" gnus-summary-exit
2252 ,@(if (featurep 'xemacs) '(t)
2253 '(:help "Exit current group, return to group selection mode"))]
2254 ["Exit group without updating" gnus-summary-exit-no-update t]
2255 ["Exit and goto next group" gnus-summary-next-group t]
2256 ["Exit and goto prev group" gnus-summary-prev-group t]
2257 ["Reselect group" gnus-summary-reselect-current-group t]
2258 ["Rescan group" gnus-summary-rescan-group t]
2259 ["Update dribble" gnus-summary-save-newsrc t])))
2261 (gnus-run-hooks 'gnus-summary-menu-hook)))
2263 (defvar gnus-summary-tool-bar-map nil)
2265 ;; Emacs 21 tool bar. Should be no-op otherwise.
2266 (defun gnus-summary-make-tool-bar ()
2267 (if (and (fboundp 'tool-bar-add-item-from-menu)
2268 (default-value 'tool-bar-mode)
2269 (not gnus-summary-tool-bar-map))
2270 (setq gnus-summary-tool-bar-map
2271 (let ((tool-bar-map (make-sparse-keymap))
2272 (load-path (mm-image-load-path)))
2273 (tool-bar-add-item-from-menu
2274 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2275 (tool-bar-add-item-from-menu
2276 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2277 (tool-bar-add-item-from-menu
2278 'gnus-summary-post-news "post" gnus-summary-mode-map)
2279 (tool-bar-add-item-from-menu
2280 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2281 (tool-bar-add-item-from-menu
2282 'gnus-summary-followup "followup" gnus-summary-mode-map)
2283 (tool-bar-add-item-from-menu
2284 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2285 (tool-bar-add-item-from-menu
2286 'gnus-summary-reply "reply" gnus-summary-mode-map)
2287 (tool-bar-add-item-from-menu
2288 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2289 (tool-bar-add-item-from-menu
2290 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2291 (tool-bar-add-item-from-menu
2292 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2293 (tool-bar-add-item-from-menu
2294 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2295 (tool-bar-add-item-from-menu
2296 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2297 (tool-bar-add-item-from-menu
2298 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2299 (tool-bar-add-item-from-menu
2300 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2301 (tool-bar-add-item-from-menu
2302 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2304 (if gnus-summary-tool-bar-map
2305 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2307 (defun gnus-score-set-default (var value)
2308 "A version of set that updates the GNU Emacs menu-bar."
2310 ;; It is the message that forces the active status to be updated.
2313 (defun gnus-make-score-map (type)
2314 "Make a summary score map of type TYPE."
2317 (let ((headers '(("author" "from" string)
2318 ("subject" "subject" string)
2319 ("article body" "body" string)
2320 ("article head" "head" string)
2321 ("xref" "xref" string)
2322 ("extra header" "extra" string)
2323 ("lines" "lines" number)
2324 ("followups to author" "followup" string)))
2325 (types '((number ("less than" <)
2328 (string ("substring" s)
2332 (perms '(("temporary" (current-time-string))
2340 (if (eq type 'lower)
2345 (setq header (car headers))
2351 (let ((ts (cdr (assoc (nth 2 header) types)))
2367 'gnus-summary-score-entry
2369 (if (or (string= (nth 1 header)
2371 (string= (nth 1 header)
2374 (list 'gnus-summary-header
2376 (list 'quote (nth 1 (car ts)))
2377 (list 'gnus-score-delta-default
2384 (list (nreverse outp))))
2387 (list (nreverse outt))))
2389 (setq headers (cdr headers)))
2390 (list (nreverse outh))))))))
2394 (defun gnus-summary-mode (&optional group)
2395 "Major mode for reading articles.
2397 All normal editing commands are switched off.
2398 \\<gnus-summary-mode-map>
2399 Each line in this buffer represents one article. To read an
2400 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2401 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2404 You can also post articles and send mail from this buffer. To
2405 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2406 of an article, type `\\[gnus-summary-reply]'.
2408 There are approx. one gazillion commands you can execute in this
2409 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2411 The following commands are available:
2413 \\{gnus-summary-mode-map}"
2415 (kill-all-local-variables)
2416 (when (gnus-visual-p 'summary-menu 'menu)
2417 (gnus-summary-make-menu-bar)
2418 (gnus-summary-make-tool-bar))
2419 (gnus-summary-make-local-variables)
2420 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2421 (gnus-summary-make-local-variables))
2422 (gnus-make-thread-indent-array)
2423 (gnus-simplify-mode-line)
2424 (setq major-mode 'gnus-summary-mode)
2425 (setq mode-name "Summary")
2426 (make-local-variable 'minor-mode-alist)
2427 (use-local-map gnus-summary-mode-map)
2428 (buffer-disable-undo)
2429 (setq buffer-read-only t) ;Disable modification
2430 (setq truncate-lines t)
2431 (setq selective-display t)
2432 (setq selective-display-ellipses t) ;Display `...'
2433 (gnus-summary-set-display-table)
2434 (gnus-set-default-directory)
2435 (setq gnus-newsgroup-name group)
2436 (unless (gnus-news-group-p group)
2437 (setq gnus-newsgroup-incorporated
2438 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2439 (make-local-variable 'gnus-summary-line-format)
2440 (make-local-variable 'gnus-summary-line-format-spec)
2441 (make-local-variable 'gnus-summary-dummy-line-format)
2442 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2443 (make-local-variable 'gnus-summary-mark-positions)
2444 (make-local-hook 'pre-command-hook)
2445 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2446 (gnus-run-hooks 'gnus-summary-mode-hook)
2447 (turn-on-gnus-mailing-list-mode)
2448 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2449 (gnus-update-summary-mark-positions))
2451 (defun gnus-summary-make-local-variables ()
2452 "Make all the local summary buffer variables."
2454 (dolist (local gnus-summary-local-variables)
2457 (if (eq (cdr local) 'global)
2458 ;; Copy the global value of the variable.
2459 (setq global (symbol-value (car local)))
2460 ;; Use the value from the list.
2461 (setq global (eval (cdr local))))
2462 (set (make-local-variable (car local)) global))
2463 ;; Simple nil-valued local variable.
2464 (set (make-local-variable local) nil)))))
2466 (defun gnus-summary-clear-local-variables ()
2467 (let ((locals gnus-summary-local-variables))
2469 (if (consp (car locals))
2470 (and (vectorp (caar locals))
2471 (set (caar locals) nil))
2472 (and (vectorp (car locals))
2473 (set (car locals) nil)))
2474 (setq locals (cdr locals)))))
2476 ;; Summary data functions.
2478 (defmacro gnus-data-number (data)
2481 (defmacro gnus-data-set-number (data number)
2482 `(setcar ,data ,number))
2484 (defmacro gnus-data-mark (data)
2487 (defmacro gnus-data-set-mark (data mark)
2488 `(setcar (nthcdr 1 ,data) ,mark))
2490 (defmacro gnus-data-pos (data)
2493 (defmacro gnus-data-set-pos (data pos)
2494 `(setcar (nthcdr 2 ,data) ,pos))
2496 (defmacro gnus-data-header (data)
2499 (defmacro gnus-data-set-header (data header)
2500 `(setcar (nthcdr 3 ,data) ,header))
2502 (defmacro gnus-data-level (data)
2505 (defmacro gnus-data-unread-p (data)
2506 `(= (nth 1 ,data) gnus-unread-mark))
2508 (defmacro gnus-data-read-p (data)
2509 `(/= (nth 1 ,data) gnus-unread-mark))
2511 (defmacro gnus-data-pseudo-p (data)
2512 `(consp (nth 3 ,data)))
2514 (defmacro gnus-data-find (number)
2515 `(assq ,number gnus-newsgroup-data))
2517 (defmacro gnus-data-find-list (number &optional data)
2518 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2519 (memq (assq ,number bdata)
2522 (defmacro gnus-data-make (number mark pos header level)
2523 `(list ,number ,mark ,pos ,header ,level))
2525 (defun gnus-data-enter (after-article number mark pos header level offset)
2526 (let ((data (gnus-data-find-list after-article)))
2528 (error "No such article: %d" after-article))
2529 (setcdr data (cons (gnus-data-make number mark pos header level)
2531 (setq gnus-newsgroup-data-reverse nil)
2532 (gnus-data-update-list (cddr data) offset)))
2534 (defun gnus-data-enter-list (after-article list &optional offset)
2536 (let ((data (and after-article (gnus-data-find-list after-article)))
2540 (let ((odata gnus-newsgroup-data))
2541 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2543 (gnus-data-update-list odata offset)))
2544 ;; Find the last element in the list to be spliced into the main
2547 (setq list (cdr list)))
2550 (setcdr list gnus-newsgroup-data)
2551 (setq gnus-newsgroup-data ilist)
2553 (gnus-data-update-list (cdr list) offset)))
2554 (setcdr list (cdr data))
2557 (gnus-data-update-list (cdr list) offset))))
2558 (setq gnus-newsgroup-data-reverse nil))))
2560 (defun gnus-data-remove (article &optional offset)
2561 (let ((data gnus-newsgroup-data))
2562 (if (= (gnus-data-number (car data)) article)
2564 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2565 gnus-newsgroup-data-reverse nil)
2567 (gnus-data-update-list gnus-newsgroup-data offset)))
2569 (when (= (gnus-data-number (cadr data)) article)
2570 (setcdr data (cddr data))
2572 (gnus-data-update-list (cdr data) offset))
2574 gnus-newsgroup-data-reverse nil))
2575 (setq data (cdr data))))))
2577 (defmacro gnus-data-list (backward)
2579 (or gnus-newsgroup-data-reverse
2580 (setq gnus-newsgroup-data-reverse
2581 (reverse gnus-newsgroup-data)))
2582 gnus-newsgroup-data))
2584 (defun gnus-data-update-list (data offset)
2585 "Add OFFSET to the POS of all data entries in DATA."
2586 (setq gnus-newsgroup-data-reverse nil)
2588 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2589 (setq data (cdr data))))
2591 (defun gnus-summary-article-pseudo-p (article)
2592 "Say whether this article is a pseudo article or not."
2593 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2595 (defmacro gnus-summary-article-sparse-p (article)
2596 "Say whether this article is a sparse article or not."
2597 `(memq ,article gnus-newsgroup-sparse))
2599 (defmacro gnus-summary-article-ancient-p (article)
2600 "Say whether this article is a sparse article or not."
2601 `(memq ,article gnus-newsgroup-ancient))
2603 (defun gnus-article-parent-p (number)
2604 "Say whether this article is a parent or not."
2605 (let ((data (gnus-data-find-list number)))
2606 (and (cdr data) ; There has to be an article after...
2607 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2608 (gnus-data-level (nth 1 data))))))
2610 (defun gnus-article-children (number)
2611 "Return a list of all children to NUMBER."
2612 (let* ((data (gnus-data-find-list number))
2613 (level (gnus-data-level (car data)))
2615 (setq data (cdr data))
2617 (= (gnus-data-level (car data)) (1+ level)))
2618 (push (gnus-data-number (car data)) children)
2619 (setq data (cdr data)))
2622 (defmacro gnus-summary-skip-intangible ()
2623 "If the current article is intangible, then jump to a different article."
2624 '(let ((to (get-text-property (point) 'gnus-intangible)))
2625 (and to (gnus-summary-goto-subject to))))
2627 (defmacro gnus-summary-article-intangible-p ()
2628 "Say whether this article is intangible or not."
2629 '(get-text-property (point) 'gnus-intangible))
2631 (defun gnus-article-read-p (article)
2632 "Say whether ARTICLE is read or not."
2633 (not (or (memq article gnus-newsgroup-marked)
2634 (memq article gnus-newsgroup-unreads)
2635 (memq article gnus-newsgroup-unselected)
2636 (memq article gnus-newsgroup-dormant))))
2638 ;; Some summary mode macros.
2640 (defmacro gnus-summary-article-number ()
2641 "The article number of the article on the current line.
2642 If there isn's an article number here, then we return the current
2645 (gnus-summary-skip-intangible)
2646 (or (get-text-property (point) 'gnus-number)
2647 (gnus-summary-last-subject))))
2649 (defmacro gnus-summary-article-header (&optional number)
2650 "Return the header of article NUMBER."
2651 `(gnus-data-header (gnus-data-find
2652 ,(or number '(gnus-summary-article-number)))))
2654 (defmacro gnus-summary-thread-level (&optional number)
2655 "Return the level of thread that starts with article NUMBER."
2656 `(if (and (eq gnus-summary-make-false-root 'dummy)
2657 (get-text-property (point) 'gnus-intangible))
2659 (gnus-data-level (gnus-data-find
2660 ,(or number '(gnus-summary-article-number))))))
2662 (defmacro gnus-summary-article-mark (&optional number)
2663 "Return the mark of article NUMBER."
2664 `(gnus-data-mark (gnus-data-find
2665 ,(or number '(gnus-summary-article-number)))))
2667 (defmacro gnus-summary-article-pos (&optional number)
2668 "Return the position of the line of article NUMBER."
2669 `(gnus-data-pos (gnus-data-find
2670 ,(or number '(gnus-summary-article-number)))))
2672 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2673 (defmacro gnus-summary-article-subject (&optional number)
2674 "Return current subject string or nil if nothing."
2677 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2678 '(gnus-data-header (assq (gnus-summary-article-number)
2679 gnus-newsgroup-data)))))
2682 (mail-header-subject headers))))
2684 (defmacro gnus-summary-article-score (&optional number)
2685 "Return current article score."
2686 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2687 gnus-newsgroup-scored))
2688 gnus-summary-default-score 0))
2690 (defun gnus-summary-article-children (&optional number)
2691 "Return a list of article numbers that are children of article NUMBER."
2692 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2693 (level (gnus-data-level (car data)))
2695 (while (and (setq data (cdr data))
2696 (> (setq l (gnus-data-level (car data))) level))
2697 (and (= (1+ level) l)
2698 (push (gnus-data-number (car data))
2700 (nreverse children)))
2702 (defun gnus-summary-article-parent (&optional number)
2703 "Return the article number of the parent of article NUMBER."
2704 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2705 (gnus-data-list t)))
2706 (level (gnus-data-level (car data))))
2708 () ; This is a root.
2709 ;; We search until we find an article with a level less than
2710 ;; this one. That function has to be the parent.
2711 (while (and (setq data (cdr data))
2712 (not (< (gnus-data-level (car data)) level))))
2713 (and data (gnus-data-number (car data))))))
2715 (defun gnus-unread-mark-p (mark)
2716 "Say whether MARK is the unread mark."
2717 (= mark gnus-unread-mark))
2719 (defun gnus-read-mark-p (mark)
2720 "Say whether MARK is one of the marks that mark as read.
2721 This is all marks except unread, ticked, dormant, and expirable."
2722 (not (or (= mark gnus-unread-mark)
2723 (= mark gnus-ticked-mark)
2724 (= mark gnus-dormant-mark)
2725 (= mark gnus-expirable-mark))))
2727 (defmacro gnus-article-mark (number)
2728 "Return the MARK of article NUMBER.
2729 This macro should only be used when computing the mark the \"first\"
2730 time; i.e., when generating the summary lines. After that,
2731 `gnus-summary-article-mark' should be used to examine the
2734 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2735 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2736 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2737 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2738 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2739 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2740 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2741 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2742 gnus-ancient-mark))))
2744 ;; Saving hidden threads.
2746 (defmacro gnus-save-hidden-threads (&rest forms)
2747 "Save hidden threads, eval FORMS, and restore the hidden threads."
2748 (let ((config (make-symbol "config")))
2749 `(let ((,config (gnus-hidden-threads-configuration)))
2753 (gnus-restore-hidden-threads-configuration ,config)))))
2754 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2755 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2757 (defun gnus-data-compute-positions ()
2758 "Compute the positions of all articles."
2759 (setq gnus-newsgroup-data-reverse nil)
2760 (let ((data gnus-newsgroup-data))
2762 (gnus-save-hidden-threads
2763 (gnus-summary-show-all-threads)
2764 (goto-char (point-min))
2766 (while (get-text-property (point) 'gnus-intangible)
2768 (gnus-data-set-pos (car data) (+ (point) 3))
2769 (setq data (cdr data))
2770 (forward-line 1))))))
2772 (defun gnus-hidden-threads-configuration ()
2773 "Return the current hidden threads configuration."
2776 (goto-char (point-min))
2777 (while (search-forward "\r" nil t)
2778 (push (1- (point)) config))
2781 (defun gnus-restore-hidden-threads-configuration (config)
2782 "Restore hidden threads configuration from CONFIG."
2784 (let (point buffer-read-only)
2785 (while (setq point (pop config))
2786 (when (and (< point (point-max))
2788 (eq (char-after) ?\n))
2789 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2791 ;; Various summary mode internalish functions.
2793 (defun gnus-mouse-pick-article (e)
2796 (gnus-summary-next-page nil t))
2798 (defun gnus-summary-set-display-table ()
2799 "Change the display table.
2800 Odd characters have a tendency to mess
2801 up nicely formatted displays - we make all possible glyphs
2802 display only a single character."
2804 ;; We start from the standard display table, if any.
2805 (let ((table (or (copy-sequence standard-display-table)
2806 (make-display-table)))
2808 ;; Nix out all the control chars...
2809 (while (>= (setq i (1- i)) 0)
2810 (aset table i [??]))
2811 ;; ... but not newline and cr, of course. (cr is necessary for the
2812 ;; selective display).
2813 (aset table ?\n nil)
2814 (aset table ?\r nil)
2815 ;; We keep TAB as well.
2816 (aset table ?\t nil)
2817 ;; We nix out any glyphs over 126 that are not set already.
2819 (while (>= (setq i (1- i)) 127)
2820 ;; Only modify if the entry is nil.
2821 (unless (aref table i)
2822 (aset table i [??]))))
2823 (setq buffer-display-table table)))
2825 (defun gnus-summary-set-article-display-arrow (pos)
2826 "Update the overlay arrow to point to line at position POS."
2827 (when (and gnus-summary-display-arrow
2828 (boundp 'overlay-arrow-position)
2829 (boundp 'overlay-arrow-string))
2833 (unless overlay-arrow-position
2834 (setq overlay-arrow-position (make-marker)))
2835 (setq overlay-arrow-string "=>"
2836 overlay-arrow-position (set-marker overlay-arrow-position
2838 (current-buffer))))))
2840 (defun gnus-summary-buffer-name (group)
2841 "Return the summary buffer name of GROUP."
2842 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2844 (defun gnus-summary-setup-buffer (group)
2845 "Initialize summary buffer."
2846 (let ((buffer (gnus-summary-buffer-name group))
2847 (dead-name (concat "*Dead Summary "
2848 (gnus-group-decoded-name group) "*")))
2849 ;; If a dead summary buffer exists, we kill it.
2850 (when (gnus-buffer-live-p dead-name)
2851 (gnus-kill-buffer dead-name))
2852 (if (get-buffer buffer)
2855 (setq gnus-summary-buffer (current-buffer))
2856 (not gnus-newsgroup-prepared))
2857 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2858 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2859 (gnus-summary-mode group)
2861 (gnus-carpal-setup-buffer 'summary))
2862 (unless gnus-single-article-buffer
2863 (make-local-variable 'gnus-article-buffer)
2864 (make-local-variable 'gnus-article-current)
2865 (make-local-variable 'gnus-original-article-buffer))
2866 (setq gnus-newsgroup-name group)
2867 ;; Set any local variables in the group parameters.
2868 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2871 (defun gnus-set-global-variables ()
2872 "Set the global equivalents of the buffer-local variables.
2873 They are set to the latest values they had. These reflect the summary
2874 buffer that was in action when the last article was fetched."
2875 (when (eq major-mode 'gnus-summary-mode)
2876 (setq gnus-summary-buffer (current-buffer))
2877 (let ((name gnus-newsgroup-name)
2878 (marked gnus-newsgroup-marked)
2879 (unread gnus-newsgroup-unreads)
2880 (headers gnus-current-headers)
2881 (data gnus-newsgroup-data)
2882 (summary gnus-summary-buffer)
2883 (article-buffer gnus-article-buffer)
2884 (original gnus-original-article-buffer)
2885 (gac gnus-article-current)
2886 (reffed gnus-reffed-article-number)
2887 (score-file gnus-current-score-file)
2888 (default-charset gnus-newsgroup-charset)
2890 (let ((locals gnus-newsgroup-variables))
2892 (if (consp (car locals))
2893 (push (eval (caar locals)) vlist)
2894 (push (eval (car locals)) vlist))
2895 (setq locals (cdr locals)))
2896 (setq vlist (nreverse vlist)))
2898 (set-buffer gnus-group-buffer)
2899 (setq gnus-newsgroup-name name
2900 gnus-newsgroup-marked marked
2901 gnus-newsgroup-unreads unread
2902 gnus-current-headers headers
2903 gnus-newsgroup-data data
2904 gnus-article-current gac
2905 gnus-summary-buffer summary
2906 gnus-article-buffer article-buffer
2907 gnus-original-article-buffer original
2908 gnus-reffed-article-number reffed
2909 gnus-current-score-file score-file
2910 gnus-newsgroup-charset default-charset)
2911 (let ((locals gnus-newsgroup-variables))
2913 (if (consp (car locals))
2914 (set (caar locals) (pop vlist))
2915 (set (car locals) (pop vlist)))
2916 (setq locals (cdr locals))))
2917 ;; The article buffer also has local variables.
2918 (when (gnus-buffer-live-p gnus-article-buffer)
2919 (set-buffer gnus-article-buffer)
2920 (setq gnus-summary-buffer summary))))))
2922 (defun gnus-summary-article-unread-p (article)
2923 "Say whether ARTICLE is unread or not."
2924 (memq article gnus-newsgroup-unreads))
2926 (defun gnus-summary-first-article-p (&optional article)
2927 "Return whether ARTICLE is the first article in the buffer."
2928 (if (not (setq article (or article (gnus-summary-article-number))))
2930 (eq article (caar gnus-newsgroup-data))))
2932 (defun gnus-summary-last-article-p (&optional article)
2933 "Return whether ARTICLE is the last article in the buffer."
2934 (if (not (setq article (or article (gnus-summary-article-number))))
2935 ;; All non-existent numbers are the last article. :-)
2937 (not (cdr (gnus-data-find-list article)))))
2939 (defun gnus-make-thread-indent-array ()
2941 (unless (and gnus-thread-indent-array
2942 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2943 (setq gnus-thread-indent-array (make-vector 201 "")
2944 gnus-thread-indent-array-level gnus-thread-indent-level)
2946 (aset gnus-thread-indent-array n
2947 (make-string (* n gnus-thread-indent-level) ? ))
2950 (defun gnus-update-summary-mark-positions ()
2951 "Compute where the summary marks are to go."
2953 (when (gnus-buffer-exists-p gnus-summary-buffer)
2954 (set-buffer gnus-summary-buffer))
2955 (let ((gnus-replied-mark 129)
2956 (gnus-score-below-mark 130)
2957 (gnus-score-over-mark 130)
2958 (gnus-download-mark 131)
2959 (spec gnus-summary-line-format-spec)
2962 (gnus-set-work-buffer)
2963 (let ((gnus-summary-line-format-spec spec)
2964 (gnus-newsgroup-downloadable '((0 . t))))
2965 (gnus-summary-insert-line
2966 (make-full-mail-header 0 "" "nobody"
2967 "05 Apr 2001 23:33:09 +0400"
2969 0 nil 128 t nil "" nil 1)
2970 (goto-char (point-min))
2971 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2973 (goto-char (point-min))
2974 (push (cons 'replied (and (search-forward "\201" nil t)
2977 (goto-char (point-min))
2978 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2980 (goto-char (point-min))
2981 (push (cons 'download
2982 (and (search-forward "\203" nil t) (- (point) 2)))
2984 (setq gnus-summary-mark-positions pos))))
2986 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2987 "Insert a dummy root in the summary buffer."
2989 (gnus-add-text-properties
2990 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2991 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2993 (defun gnus-summary-extract-address-component (from)
2994 (or (car (funcall gnus-extract-address-components from))
2997 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2998 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
2999 default-mime-charset)))
3000 ;; Is it really necessary to do this next part for each summary line?
3001 ;; Luckily, doesn't seem to slow things down much.
3003 (and gnus-ignored-from-addresses
3004 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3005 (let ((extra-headers (mail-header-extra header))
3009 ((setq to (cdr (assq 'To extra-headers)))
3012 (gnus-summary-extract-address-component
3013 (funcall gnus-decode-encoded-word-function to)))))
3014 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3015 (concat "=> " newsgroups)))))
3016 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3018 (defun gnus-summary-insert-line (gnus-tmp-header
3019 gnus-tmp-level gnus-tmp-current
3020 gnus-tmp-unread gnus-tmp-replied
3021 gnus-tmp-expirable gnus-tmp-subject-or-nil
3022 &optional gnus-tmp-dummy gnus-tmp-score
3024 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3025 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3026 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3027 (gnus-tmp-score-char
3028 (if (or (null gnus-summary-default-score)
3029 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3030 gnus-summary-zcore-fuzz))
3032 (if (< gnus-tmp-score gnus-summary-default-score)
3033 gnus-score-below-mark gnus-score-over-mark)))
3034 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3036 (cond (gnus-tmp-process gnus-process-mark)
3037 ((memq gnus-tmp-current gnus-newsgroup-cached)
3039 (gnus-tmp-replied gnus-replied-mark)
3040 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3041 gnus-forwarded-mark)
3042 ((memq gnus-tmp-current gnus-newsgroup-saved)
3044 ((memq gnus-tmp-number gnus-newsgroup-recent)
3046 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3049 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3052 ((string-match "<[^>]+> *$" gnus-tmp-from)
3053 (let ((beg (match-beginning 0)))
3054 (or (and (string-match "^\".+\"" gnus-tmp-from)
3055 (substring gnus-tmp-from 1 (1- (match-end 0))))
3056 (substring gnus-tmp-from 0 beg))))
3057 ((string-match "(.+)" gnus-tmp-from)
3058 (substring gnus-tmp-from
3059 (1+ (match-beginning 0)) (1- (match-end 0))))
3061 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3062 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3063 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3064 (buffer-read-only nil))
3065 (when (string= gnus-tmp-name "")
3066 (setq gnus-tmp-name gnus-tmp-from))
3067 (unless (numberp gnus-tmp-lines)
3068 (setq gnus-tmp-lines -1))
3069 (if (= gnus-tmp-lines -1)
3070 (setq gnus-tmp-lines "?")
3071 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3072 (gnus-put-text-property-excluding-characters-with-faces
3074 (progn (eval gnus-summary-line-format-spec) (point))
3075 'gnus-number gnus-tmp-number)
3076 (when (gnus-visual-p 'summary-highlight 'highlight)
3078 (gnus-run-hooks 'gnus-summary-update-hook)
3081 (defun gnus-summary-update-line (&optional dont-update)
3082 "Update summary line after change."
3083 (when (and gnus-summary-default-score
3084 (not gnus-summary-inhibit-highlight))
3085 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3086 (article (gnus-summary-article-number))
3087 (score (gnus-summary-article-score article)))
3089 (if (and gnus-summary-mark-below
3090 (< (gnus-summary-article-score)
3091 gnus-summary-mark-below))
3092 ;; This article has a low score, so we mark it as read.
3093 (when (memq article gnus-newsgroup-unreads)
3094 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3095 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3096 ;; This article was previously marked as read on account
3097 ;; of a low score, but now it has risen, so we mark it as
3099 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3100 (gnus-summary-update-mark
3101 (if (or (null gnus-summary-default-score)
3102 (<= (abs (- score gnus-summary-default-score))
3103 gnus-summary-zcore-fuzz))
3105 (if (< score gnus-summary-default-score)
3106 gnus-score-below-mark gnus-score-over-mark))
3108 ;; Do visual highlighting.
3109 (when (gnus-visual-p 'summary-highlight 'highlight)
3110 (gnus-run-hooks 'gnus-summary-update-hook)))))
3112 (defvar gnus-tmp-new-adopts nil)
3114 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3115 "Return the number of articles in THREAD.
3116 This may be 0 in some cases -- if none of the articles in
3117 the thread are to be displayed."
3119 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3121 ((not (listp thread))
3123 ((and (consp thread) (cdr thread))
3126 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3129 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3132 (when (and level (zerop level) gnus-tmp-new-adopts)
3135 'gnus-summary-number-of-articles-in-thread
3136 gnus-tmp-new-adopts))))
3138 (if (> number 1) gnus-not-empty-thread-mark
3139 gnus-empty-thread-mark)
3142 (defun gnus-summary-set-local-parameters (group)
3143 "Go through the local params of GROUP and set all variable specs in that list."
3144 (let ((params (gnus-group-find-parameter group))
3145 (vars '(quit-config)) ; Ignore quit-config.
3148 (setq elem (car params)
3149 params (cdr params))
3150 (and (consp elem) ; Has to be a cons.
3151 (consp (cdr elem)) ; The cdr has to be a list.
3152 (symbolp (car elem)) ; Has to be a symbol in there.
3153 (not (memq (car elem) vars))
3154 (ignore-errors ; So we set it.
3155 (push (car elem) vars)
3156 (make-local-variable (car elem))
3157 (set (car elem) (eval (nth 1 elem))))))))
3159 (defun gnus-summary-read-group (group &optional show-all no-article
3160 kill-buffer no-display backward
3162 "Start reading news in newsgroup GROUP.
3163 If SHOW-ALL is non-nil, already read articles are also listed.
3164 If NO-ARTICLE is non-nil, no article is selected initially.
3165 If NO-DISPLAY, don't generate a summary buffer."
3169 (let ((gnus-auto-select-next nil))
3170 (or (gnus-summary-read-group-1
3171 group show-all no-article
3172 kill-buffer no-display
3175 select-articles nil)))))
3176 (eq gnus-auto-select-next 'quietly))
3177 (set-buffer gnus-group-buffer)
3178 ;; The entry function called above goes to the next
3179 ;; group automatically, so we go two groups back
3180 ;; if we are searching for the previous group.
3182 (gnus-group-prev-unread-group 2))
3183 (if (not (equal group (gnus-group-group-name)))
3184 (setq group (gnus-group-group-name))
3188 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3189 "Directly jump to the other GROUP from summary buffer.
3190 If SHOW-ALL is non-nil, already read articles are also listed."
3192 (if (eq gnus-summary-buffer (current-buffer))
3193 (list (completing-read
3194 "Group: " gnus-active-hashtb nil t
3195 (when (and gnus-newsgroup-name
3196 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3197 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3198 'gnus-group-history)
3200 (error "%s must be invoked from a gnus summary buffer." this-command)))
3201 (unless (or (zerop (length group))
3202 (and gnus-newsgroup-name
3203 (string-equal gnus-newsgroup-name group)))
3205 (gnus-summary-read-group group show-all
3206 gnus-dont-select-after-jump-to-other-group)))
3208 (defun gnus-summary-read-group-1 (group show-all no-article
3209 kill-buffer no-display
3210 &optional select-articles)
3211 ;; Killed foreign groups can't be entered.
3212 ;; (when (and (not (gnus-group-native-p group))
3213 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3214 ;; (error "Dead non-native groups can't be entered"))
3215 (gnus-message 5 "Retrieving newsgroup: %s..."
3216 (gnus-group-decoded-name group))
3217 (let* ((new-group (gnus-summary-setup-buffer group))
3218 (quit-config (gnus-group-quit-config group))
3219 (did-select (and new-group (gnus-select-newsgroup
3220 group show-all select-articles))))
3222 ;; This summary buffer exists already, so we just select it.
3224 (gnus-set-global-variables)
3226 (gnus-kill-or-deaden-summary kill-buffer))
3227 (gnus-configure-windows 'summary 'force)
3228 (gnus-set-mode-line 'summary)
3229 (gnus-summary-position-point)
3232 ;; We couldn't select this group.
3234 (when (and (eq major-mode 'gnus-summary-mode)
3235 (not (equal (current-buffer) kill-buffer)))
3236 (kill-buffer (current-buffer))
3237 (if (not quit-config)
3239 ;; Update the info -- marks might need to be removed,
3241 (gnus-summary-update-info)
3242 (set-buffer gnus-group-buffer)
3243 (gnus-group-jump-to-group group)
3244 (gnus-group-next-unread-group 1))
3245 (gnus-handle-ephemeral-exit quit-config)))
3246 (let ((grpinfo (gnus-get-info group)))
3247 (if (null (gnus-info-read grpinfo))
3248 (gnus-message 3 "Group %s contains no messages"
3249 (gnus-group-decoded-name group))
3250 (gnus-message 3 "Can't select group")))
3252 ;; The user did a `C-g' while prompting for number of articles,
3253 ;; so we exit this group.
3254 ((eq did-select 'quit)
3255 (and (eq major-mode 'gnus-summary-mode)
3256 (not (equal (current-buffer) kill-buffer))
3257 (kill-buffer (current-buffer)))
3259 (gnus-kill-or-deaden-summary kill-buffer))
3260 (if (not quit-config)
3262 (set-buffer gnus-group-buffer)
3263 (gnus-group-jump-to-group group)
3264 (gnus-group-next-unread-group 1)
3265 (gnus-configure-windows 'group 'force))
3266 (gnus-handle-ephemeral-exit quit-config))
3267 ;; Finally signal the quit.
3269 ;; The group was successfully selected.
3271 (gnus-set-global-variables)
3272 ;; Save the active value in effect when the group was entered.
3273 (setq gnus-newsgroup-active
3275 (gnus-active gnus-newsgroup-name)))
3276 ;; You can change the summary buffer in some way with this hook.
3277 (gnus-run-hooks 'gnus-select-group-hook)
3278 (gnus-update-format-specifications
3279 nil 'summary 'summary-mode 'summary-dummy)
3280 (gnus-update-summary-mark-positions)
3281 ;; Do score processing.
3282 (when gnus-use-scoring
3283 (gnus-possibly-score-headers))
3284 ;; Check whether to fill in the gaps in the threads.
3285 (when gnus-build-sparse-threads
3286 (gnus-build-sparse-threads))
3287 ;; Find the initial limit.
3288 (if gnus-show-threads
3290 (let ((gnus-newsgroup-dormant nil))
3291 (gnus-summary-initial-limit show-all))
3292 (gnus-summary-initial-limit show-all))
3293 ;; When untreaded, all articles are always shown.
3294 (setq gnus-newsgroup-limit
3296 (lambda (header) (mail-header-number header))
3297 gnus-newsgroup-headers)))
3298 ;; Generate the summary buffer.
3300 (gnus-summary-prepare))
3301 (when gnus-use-trees
3302 (gnus-tree-open group)
3303 (setq gnus-summary-highlight-line-function
3304 'gnus-tree-highlight-article))
3305 ;; If the summary buffer is empty, but there are some low-scored
3306 ;; articles or some excluded dormants, we include these in the
3308 (when (and (zerop (buffer-size))
3310 (cond (gnus-newsgroup-dormant
3311 (gnus-summary-limit-include-dormant))
3312 ((and gnus-newsgroup-scored show-all)
3313 (gnus-summary-limit-include-expunged t))))
3314 ;; Function `gnus-apply-kill-file' must be called in this hook.
3315 (gnus-run-hooks 'gnus-apply-kill-hook)
3316 (if (and (zerop (buffer-size))
3319 ;; This newsgroup is empty.
3320 (gnus-summary-catchup-and-exit nil t)
3321 (gnus-message 6 "No unread news")
3323 (gnus-kill-or-deaden-summary kill-buffer))
3324 ;; Return nil from this function.
3326 ;; Hide conversation thread subtrees. We cannot do this in
3327 ;; gnus-summary-prepare-hook since kill processing may not
3328 ;; work with hidden articles.
3329 (gnus-summary-maybe-hide-threads)
3331 (gnus-kill-or-deaden-summary kill-buffer))
3332 (gnus-summary-auto-select-subject)
3333 ;; Show first unread article if requested.
3334 (if (and (not no-article)
3336 gnus-newsgroup-unreads
3337 gnus-auto-select-first)
3339 (gnus-configure-windows 'summary)
3340 (let ((art (gnus-summary-article-number)))
3341 (unless (or (memq art gnus-newsgroup-undownloaded)
3342 (memq art gnus-newsgroup-downloadable))
3343 (gnus-summary-goto-article art))))
3344 ;; Don't select any articles.
3345 (gnus-summary-position-point)
3346 (gnus-configure-windows 'summary 'force)
3347 (gnus-set-mode-line 'summary))
3348 (when (get-buffer-window gnus-group-buffer t)
3349 ;; Gotta use windows, because recenter does weird stuff if
3350 ;; the current buffer ain't the displayed window.
3351 (let ((owin (selected-window)))
3352 (select-window (get-buffer-window gnus-group-buffer t))
3353 (when (gnus-group-goto-group group)
3355 (select-window owin)))
3356 ;; Mark this buffer as "prepared".
3357 (setq gnus-newsgroup-prepared t)
3358 (gnus-run-hooks 'gnus-summary-prepared-hook)
3361 (defun gnus-summary-auto-select-subject ()
3362 "Select the subject line on initial group entry."
3363 (goto-char (point-min))
3365 ((eq gnus-auto-select-subject 'best)
3366 (gnus-summary-best-unread-subject))
3367 ((eq gnus-auto-select-subject 'unread)
3368 (gnus-summary-first-unread-subject))
3369 ((eq gnus-auto-select-subject 'unseen)
3370 (gnus-summary-first-unseen-subject))
3371 ((eq gnus-auto-select-subject 'unseen-or-unread)
3372 (gnus-summary-first-unseen-or-unread-subject))
3373 ((eq gnus-auto-select-subject 'first)
3376 ((gnus-functionp gnus-auto-select-subject)
3377 (funcall gnus-auto-select-subject))))
3379 (defun gnus-summary-prepare ()
3380 "Generate the summary buffer."
3382 (let ((buffer-read-only nil))
3384 (setq gnus-newsgroup-data nil
3385 gnus-newsgroup-data-reverse nil)
3386 (gnus-run-hooks 'gnus-summary-generate-hook)
3387 ;; Generate the buffer, either with threads or without.
3388 (when gnus-newsgroup-headers
3389 (gnus-summary-prepare-threads
3390 (if gnus-show-threads
3391 (gnus-sort-gathered-threads
3392 (funcall gnus-summary-thread-gathering-function
3394 (gnus-cut-threads (gnus-make-threads)))))
3395 ;; Unthreaded display.
3396 (gnus-sort-articles gnus-newsgroup-headers))))
3397 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3398 ;; Call hooks for modifying summary buffer.
3399 (goto-char (point-min))
3400 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3402 (defsubst gnus-general-simplify-subject (subject)
3403 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3406 ;; Truncate the subject.
3407 (gnus-simplify-subject-functions
3408 (gnus-map-function gnus-simplify-subject-functions subject))
3409 ((numberp gnus-summary-gather-subject-limit)
3410 (setq subject (gnus-simplify-subject-re subject))
3411 (if (> (length subject) gnus-summary-gather-subject-limit)
3412 (substring subject 0 gnus-summary-gather-subject-limit)
3414 ;; Fuzzily simplify it.
3415 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3416 (gnus-simplify-subject-fuzzy subject))
3417 ;; Just remove the leading "Re:".
3419 (gnus-simplify-subject-re subject))))
3421 (if (and gnus-summary-gather-exclude-subject
3422 (string-match gnus-summary-gather-exclude-subject subject))
3423 nil ; This article shouldn't be gathered
3426 (defun gnus-summary-simplify-subject-query ()
3427 "Query where the respool algorithm would put this article."
3429 (gnus-summary-select-article)
3431 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3433 (defun gnus-gather-threads-by-subject (threads)
3434 "Gather threads by looking at Subject headers."
3435 (if (not gnus-summary-make-false-root)
3437 (let ((hashtb (gnus-make-hashtable 1024))
3440 subject hthread whole-subject)
3442 (setq subject (gnus-general-simplify-subject
3443 (setq whole-subject (mail-header-subject
3446 (if (setq hthread (gnus-gethash subject hashtb))
3448 ;; We enter a dummy root into the thread, if we
3449 ;; haven't done that already.
3450 (unless (stringp (caar hthread))
3451 (setcar hthread (list whole-subject (car hthread))))
3452 ;; We add this new gathered thread to this gathered
3454 (setcdr (car hthread)
3455 (nconc (cdar hthread) (list (car threads))))
3456 ;; Remove it from the list of threads.
3457 (setcdr prev (cdr threads))
3458 (setq threads prev))
3459 ;; Enter this thread into the hash table.
3460 (gnus-sethash subject threads hashtb)))
3462 (setq threads (cdr threads)))
3465 (defun gnus-gather-threads-by-references (threads)
3466 "Gather threads by looking at References headers."
3467 (let ((idhashtb (gnus-make-hashtable 1024))
3468 (thhashtb (gnus-make-hashtable 1024))
3471 ids references id gthread gid entered ref)
3473 (when (setq references (mail-header-references (caar threads)))
3474 (setq id (mail-header-id (caar threads))
3475 ids (inline (gnus-split-references references))
3477 (while (setq ref (pop ids))
3478 (setq ids (delete ref ids))
3479 (if (not (setq gid (gnus-gethash ref idhashtb)))
3481 (gnus-sethash ref id idhashtb)
3482 (gnus-sethash id threads thhashtb))
3483 (setq gthread (gnus-gethash gid thhashtb))
3485 ;; We enter a dummy root into the thread, if we
3486 ;; haven't done that already.
3487 (unless (stringp (caar gthread))
3488 (setcar gthread (list (mail-header-subject (caar gthread))
3490 ;; We add this new gathered thread to this gathered
3492 (setcdr (car gthread)
3493 (nconc (cdar gthread) (list (car threads)))))
3494 ;; Add it into the thread hash table.
3495 (gnus-sethash id gthread thhashtb)
3497 ;; Remove it from the list of threads.
3498 (setcdr prev (cdr threads))
3499 (setq threads prev))))
3501 (setq threads (cdr threads)))
3504 (defun gnus-sort-gathered-threads (threads)
3505 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3506 (let ((result threads))
3508 (when (stringp (caar threads))
3509 (setcdr (car threads)
3510 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3511 (setq threads (cdr threads)))
3514 (defun gnus-thread-loop-p (root thread)
3515 "Say whether ROOT is in THREAD."
3516 (let ((stack (list thread))
3519 (while (setq thread (pop stack))
3520 (setq th (cdr thread))
3522 (not (eq (caar th) root)))
3525 ;; We have found a loop.
3527 (setcdr thread (delq (car th) (cdr thread)))
3528 (if (boundp (setq ref-dep (intern "none"
3529 gnus-newsgroup-dependencies)))
3530 (setcdr (symbol-value ref-dep)
3531 (nconc (cdr (symbol-value ref-dep))
3533 (set ref-dep (list nil (car th))))
3536 ;; Push all the subthreads onto the stack.
3537 (push (cdr thread) stack)))
3540 (defun gnus-make-threads ()
3541 "Go through the dependency hashtb and find the roots. Return all threads."
3543 (while (catch 'infloop
3546 ;; Deal with self-referencing References loops.
3547 (when (and (car (symbol-value refs))
3554 (car (symbol-value refs)) thread))
3555 (cdr (symbol-value refs)))))))
3558 (unless (car (symbol-value refs))
3559 ;; These threads do not refer back to any other articles,
3560 ;; so they're roots.
3561 (setq threads (append (cdr (symbol-value refs)) threads))))
3562 gnus-newsgroup-dependencies)))
3565 ;; Build the thread tree.
3566 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3567 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3569 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3570 if it was already present.
3572 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3573 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3574 Message-IDs will be renamed to a unique Message-ID before being
3577 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3578 (let* ((id (mail-header-id header))
3579 (id-dep (and id (intern id dependencies)))
3580 ref ref-dep ref-header)
3581 ;; Enter this `header' in the `dependencies' table.
3585 ;; The first two cases do the normal part: enter a new `header'
3586 ;; in the `dependencies' table.
3587 ((not (boundp id-dep))
3588 (set id-dep (list header)))
3589 ((null (car (symbol-value id-dep)))
3590 (setcar (symbol-value id-dep) header))
3592 ;; From here the `header' was already present in the
3593 ;; `dependencies' table.
3595 ;; Overrides an existing entry;
3596 ;; just set the header part of the entry.
3597 (setcar (symbol-value id-dep) header))
3599 ;; Renames the existing `header' to a unique Message-ID.
3600 ((not gnus-summary-ignore-duplicates)
3601 ;; An article with this Message-ID has already been seen.
3602 ;; We rename the Message-ID.
3603 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3605 (mail-header-set-id header id))
3607 ;; The last case ignores an existing entry, except it adds any
3608 ;; additional Xrefs (in case the two articles came from different
3610 ;; Also sets `header' to `nil' meaning that the `dependencies'
3611 ;; table was *not* modified.
3613 (mail-header-set-xref
3614 (car (symbol-value id-dep))
3615 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3617 (or (mail-header-xref header) "")))
3621 ;; First check that we are not creating a References loop.
3622 (setq ref (gnus-parent-id (mail-header-references header)))
3624 (setq ref-dep (intern-soft ref dependencies))
3626 (setq ref-header (car (symbol-value ref-dep))))
3627 (if (string= id ref)
3628 ;; Yuk! This is a reference loop. Make the article be a
3631 (mail-header-set-references (car (symbol-value id-dep)) "none")
3633 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3634 (setq ref (gnus-parent-id (mail-header-references header)))
3635 (setq ref-dep (intern (or ref "none") dependencies))
3636 (if (boundp ref-dep)
3637 (setcdr (symbol-value ref-dep)
3638 (nconc (cdr (symbol-value ref-dep))
3639 (list (symbol-value id-dep))))
3640 (set ref-dep (list nil (symbol-value id-dep)))))
3643 (defun gnus-extract-message-id-from-in-reply-to (string)
3644 (if (string-match "<[^>]+>" string)
3645 (substring string (match-beginning 0) (match-end 0))
3648 (defun gnus-build-sparse-threads ()
3649 (let ((headers gnus-newsgroup-headers)
3650 (mail-parse-charset gnus-newsgroup-charset)
3651 (gnus-summary-ignore-duplicates t)
3652 header references generation relations
3653 subject child end new-child date)
3654 ;; First we create an alist of generations/relations, where
3655 ;; generations is how much we trust the relation, and the relation
3657 (gnus-message 7 "Making sparse threads...")
3659 (nnheader-set-temp-buffer " *gnus sparse threads*")
3660 (while (setq header (pop headers))
3661 (when (and (setq references (mail-header-references header))
3662 (not (string= references "")))
3664 (setq child (mail-header-id header)
3665 subject (mail-header-subject header)
3666 date (mail-header-date header)
3668 (while (search-backward ">" nil t)
3669 (setq end (1+ (point)))
3670 (when (search-backward "<" nil t)
3671 (setq new-child (buffer-substring (point) end))
3672 (push (list (incf generation)
3673 child (setq child new-child)
3677 (push (list (1+ generation) child nil subject) relations))
3679 (kill-buffer (current-buffer)))
3680 ;; Sort over trustworthiness.
3683 (when (gnus-dependencies-add-header
3684 (make-full-mail-header-from-decoded-header
3685 gnus-reffed-article-number
3686 (nth 3 relation) "" (or (nth 4 relation) "")
3688 (or (nth 2 relation) "") 0 0 "")
3689 gnus-newsgroup-dependencies nil)
3690 (push gnus-reffed-article-number gnus-newsgroup-limit)
3691 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3692 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3693 gnus-newsgroup-reads)
3694 (decf gnus-reffed-article-number)))
3695 (sort relations 'car-less-than-car))
3696 (gnus-message 7 "Making sparse threads...done")))
3698 (defun gnus-build-old-threads ()
3699 ;; Look at all the articles that refer back to old articles, and
3700 ;; fetch the headers for the articles that aren't there. This will
3701 ;; build complete threads - if the roots haven't been expired by the
3703 (let ((mail-parse-charset gnus-newsgroup-charset)
3707 (when (not (car (symbol-value refs)))
3708 (setq heads (cdr (symbol-value refs)))
3710 (if (memq (mail-header-number (caar heads))
3711 gnus-newsgroup-dormant)
3712 (setq heads (cdr heads))
3713 (setq id (symbol-name refs))
3714 (while (and (setq id (gnus-build-get-header id))
3715 (not (car (gnus-id-to-thread id)))))
3716 (setq heads nil)))))
3717 gnus-newsgroup-dependencies)))
3719 ;; This function has to be called with point after the article number
3720 ;; on the beginning of the line.
3721 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3722 (let ((eol (gnus-point-at-eol))
3723 (buffer (current-buffer))
3724 header references in-reply-to)
3726 ;; overview: [num subject from date id refs chars lines misc]
3729 (narrow-to-region (point) eol)
3734 (make-full-mail-header
3736 (nnheader-nov-field) ; subject
3737 (nnheader-nov-field) ; from
3738 (nnheader-nov-field) ; date
3739 (nnheader-nov-read-message-id) ; id
3740 (nnheader-nov-field) ; refs
3741 (nnheader-nov-read-integer) ; chars
3742 (nnheader-nov-read-integer) ; lines
3744 (if (looking-at "Xref: ")
3745 (goto-char (match-end 0)))
3746 (nnheader-nov-field)) ; Xref
3747 (nnheader-nov-parse-extra)))) ; extra
3751 (when (and (string= references "")
3752 (setq in-reply-to (mail-header-extra header))
3753 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3754 (mail-header-set-references
3755 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3757 (when gnus-alter-header-function
3758 (funcall gnus-alter-header-function header))
3759 (gnus-dependencies-add-header header dependencies force-new)))
3761 (defun gnus-build-get-header (id)
3762 "Look through the buffer of NOV lines and find the header to ID.
3763 Enter this line into the dependencies hash table, and return
3764 the id of the parent article (if any)."
3765 (let ((deps gnus-newsgroup-dependencies)
3769 (set-buffer nntp-server-buffer)
3770 (let ((case-fold-search nil))
3771 (goto-char (point-min))
3772 (while (and (not found)
3773 (search-forward id nil t))
3775 (setq found (looking-at
3776 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3777 (regexp-quote id))))
3778 (or found (beginning-of-line 2)))
3782 (setq header (gnus-nov-parse-line
3783 (read (current-buffer)) deps))
3784 (gnus-parent-id (mail-header-references header))))))
3786 (let ((number (mail-header-number header)))
3787 (push number gnus-newsgroup-limit)
3788 (push header gnus-newsgroup-headers)
3789 (if (memq number gnus-newsgroup-unselected)
3791 (setq gnus-newsgroup-unreads
3792 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3794 (setq gnus-newsgroup-unselected
3795 (delq number gnus-newsgroup-unselected)))
3796 (push number gnus-newsgroup-ancient)))))))
3798 (defun gnus-build-all-threads ()
3799 "Read all the headers."
3800 (let ((gnus-summary-ignore-duplicates t)
3801 (mail-parse-charset gnus-newsgroup-charset)
3802 (dependencies gnus-newsgroup-dependencies)
3805 (set-buffer nntp-server-buffer)
3806 (let ((case-fold-search nil))
3807 (goto-char (point-min))
3810 (setq article (read (current-buffer))
3811 header (gnus-nov-parse-line article dependencies)))
3814 (set-buffer gnus-summary-buffer)
3815 (push header gnus-newsgroup-headers)
3816 (if (memq (setq article (mail-header-number header))
3817 gnus-newsgroup-unselected)
3819 (setq gnus-newsgroup-unreads
3820 (gnus-add-to-sorted-list
3821 gnus-newsgroup-unreads article))
3822 (setq gnus-newsgroup-unselected
3823 (delq article gnus-newsgroup-unselected)))
3824 (push article gnus-newsgroup-ancient)))
3825 (forward-line 1)))))))
3827 (defun gnus-summary-update-article-line (article header)
3828 "Update the line for ARTICLE using HEADERS."
3829 (let* ((id (mail-header-id header))
3830 (thread (gnus-id-to-thread id)))
3832 (error "Article in no thread"))
3833 ;; Update the thread.
3834 (setcar thread header)
3835 (gnus-summary-goto-subject article)
3836 (let* ((datal (gnus-data-find-list article))
3838 (length (when (cdr datal)
3839 (- (gnus-data-pos data)
3840 (gnus-data-pos (cadr datal)))))
3841 (buffer-read-only nil)
3842 (level (gnus-summary-thread-level)))
3844 (gnus-summary-insert-line
3845 header level nil (gnus-article-mark article)
3846 (memq article gnus-newsgroup-replied)
3847 (memq article gnus-newsgroup-expirable)
3848 ;; Only insert the Subject string when it's different
3849 ;; from the previous Subject string.
3854 (mail-header-subject
3857 (gnus-data-find-list
3859 (gnus-data-list t)))))
3860 ;; Error on the side of excessive subjects.
3862 (mail-header-subject header)))
3864 (mail-header-subject header))
3865 nil (cdr (assq article gnus-newsgroup-scored))
3866 (memq article gnus-newsgroup-processable))
3868 (gnus-data-update-list
3869 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3871 (defun gnus-summary-update-article (article &optional iheader)
3872 "Update ARTICLE in the summary buffer."
3873 (set-buffer gnus-summary-buffer)
3874 (let* ((header (gnus-summary-article-header article))
3875 (id (mail-header-id header))
3876 (data (gnus-data-find article))
3877 (thread (gnus-id-to-thread id))
3878 (references (mail-header-references header))
3882 (when (and references
3883 (not (equal "" references)))
3886 (buffer-read-only nil)
3892 (delq thread parent)))
3893 (if (gnus-summary-insert-subject id header)
3894 ;; Set the (possibly) new article number in the data structure.
3895 (gnus-data-set-number data (gnus-id-to-article id))
3899 (defun gnus-rebuild-thread (id &optional line)
3900 "Rebuild the thread containing ID.
3901 If LINE, insert the rebuilt thread starting on line LINE."
3902 (let ((buffer-read-only nil)
3903 old-pos current thread data)
3904 (if (not gnus-show-threads)
3905 (setq thread (list (car (gnus-id-to-thread id))))
3906 ;; Get the thread this article is part of.
3907 (setq thread (gnus-remove-thread id)))
3908 (setq old-pos (gnus-point-at-bol))
3909 (setq current (save-excursion
3910 (and (re-search-backward "[\r\n]" nil t)
3911 (gnus-summary-article-number))))
3912 ;; If this is a gathered thread, we have to go some re-gathering.
3913 (when (stringp (car thread))
3914 (let ((subject (car thread))
3916 (setq thread (cdr thread))
3918 (unless (memq (setq thr (gnus-id-to-thread
3920 (mail-header-id (caar thread)))))
3923 (setq thread (cdr thread)))
3924 ;; We now have all (unique) roots.
3925 (if (= (length roots) 1)
3926 ;; All the loose roots are now one solid root.
3927 (setq thread (car roots))
3928 (setq thread (cons subject (gnus-sort-threads roots))))))
3930 ;; We then insert this thread into the summary buffer.
3932 (goto-char (point-min))
3933 (forward-line (1- line)))
3934 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3935 (if gnus-show-threads
3936 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3937 (gnus-summary-prepare-unthreaded thread))
3938 (setq data (nreverse gnus-newsgroup-data))
3939 (setq threads gnus-newsgroup-threads))
3940 ;; We splice the new data into the data structure.
3941 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3942 ;;!!! then we want to insert at the beginning of the buffer.
3943 ;;!!! That happens to be true with Gnus now, but that may
3944 ;;!!! change in the future. Perhaps.
3945 (gnus-data-enter-list
3946 (if line nil current) data (- (point) old-pos))
3947 (setq gnus-newsgroup-threads
3948 (nconc threads gnus-newsgroup-threads))
3949 (gnus-data-compute-positions))))
3951 (defun gnus-number-to-header (number)
3952 "Return the header for article NUMBER."
3953 (let ((headers gnus-newsgroup-headers))
3955 (not (= number (mail-header-number (car headers)))))
3960 (defun gnus-parent-headers (in-headers &optional generation)
3961 "Return the headers of the GENERATIONeth parent of HEADERS."
3963 (setq generation 1))
3965 (headers in-headers)
3968 (not (zerop generation))
3969 (setq references (mail-header-references headers)))
3970 (setq headers (if (and references
3971 (setq parent (gnus-parent-id references)))
3972 (car (gnus-id-to-thread parent))
3975 (and (not (eq headers in-headers))
3978 (defun gnus-id-to-thread (id)
3979 "Return the (sub-)thread where ID appears."
3980 (gnus-gethash id gnus-newsgroup-dependencies))
3982 (defun gnus-id-to-article (id)
3983 "Return the article number of ID."
3984 (let ((thread (gnus-id-to-thread id)))
3987 (mail-header-number (car thread)))))
3989 (defun gnus-id-to-header (id)
3990 "Return the article headers of ID."
3991 (car (gnus-id-to-thread id)))
3993 (defun gnus-article-displayed-root-p (article)
3994 "Say whether ARTICLE is a root(ish) article."
3995 (let ((level (gnus-summary-thread-level article))
3996 (refs (mail-header-references (gnus-summary-article-header article)))
4002 ((null (gnus-parent-id refs)) t)
4004 (null (setq particle (gnus-id-to-article
4005 (gnus-parent-id refs))))
4006 (null (gnus-summary-thread-level particle)))))))
4008 (defun gnus-root-id (id)
4009 "Return the id of the root of the thread where ID appears."
4011 (while (and id (setq prev (car (gnus-id-to-thread id))))
4013 id (gnus-parent-id (mail-header-references prev))))
4016 (defun gnus-articles-in-thread (thread)
4017 "Return the list of articles in THREAD."
4018 (cons (mail-header-number (car thread))
4019 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4021 (defun gnus-remove-thread (id &optional dont-remove)
4022 "Remove the thread that has ID in it."
4023 (let (headers thread last-id)
4024 ;; First go up in this thread until we find the root.
4025 (setq last-id (gnus-root-id id)
4026 headers (message-flatten-list (gnus-id-to-thread last-id)))
4027 ;; We have now found the real root of this thread. It might have
4028 ;; been gathered into some loose thread, so we have to search
4029 ;; through the threads to find the thread we wanted.
4030 (let ((threads gnus-newsgroup-threads)
4033 (setq sub (car threads))
4034 (if (stringp (car sub))
4035 ;; This is a gathered thread, so we look at the roots
4036 ;; below it to find whether this article is in this
4039 (setq sub (cdr sub))
4041 (when (member (caar sub) headers)
4042 (setq thread (car threads)
4045 (setq sub (cdr sub))))
4046 ;; It's an ordinary thread, so we check it.
4047 (when (eq (car sub) (car headers))
4050 (setq threads (cdr threads)))
4051 ;; If this article is in no thread, then it's a root.
4054 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4055 (setq thread (gnus-id-to-thread last-id)))
4058 thread ; We return this thread.
4060 (if (stringp (car thread))
4062 ;; If we use dummy roots, then we have to remove the
4063 ;; dummy root as well.
4064 (when (eq gnus-summary-make-false-root 'dummy)
4065 ;; We go to the dummy root by going to
4066 ;; the first sub-"thread", and then one line up.
4067 (gnus-summary-goto-article
4068 (mail-header-number (caadr thread)))
4071 (gnus-data-compute-positions))
4072 (setq thread (cdr thread))
4074 (gnus-remove-thread-1 (car thread))
4075 (setq thread (cdr thread))))
4076 (gnus-remove-thread-1 thread))))))))
4078 (defun gnus-remove-thread-1 (thread)
4079 "Remove the thread THREAD recursively."
4080 (let ((number (mail-header-number (pop thread)))
4082 (setq thread (reverse thread))
4084 (gnus-remove-thread-1 (pop thread)))
4085 (when (setq d (gnus-data-find number))
4086 (goto-char (gnus-data-pos d))
4087 (gnus-summary-show-thread)
4090 (- (gnus-point-at-bol)
4092 (1+ (gnus-point-at-eol))
4093 (gnus-delete-line)))))))
4095 (defun gnus-sort-threads-1 (threads func)
4096 (sort (mapcar (lambda (thread)
4099 (gnus-sort-threads-1 (cdr thread) func))))
4102 (defun gnus-sort-threads (threads)
4104 (if (not gnus-thread-sort-functions)
4106 (gnus-message 8 "Sorting threads...")
4108 (gnus-sort-threads-1
4110 (gnus-make-sort-function gnus-thread-sort-functions))
4111 (gnus-message 8 "Sorting threads...done"))))
4113 (defun gnus-sort-articles (articles)
4115 (when gnus-article-sort-functions
4116 (gnus-message 7 "Sorting articles...")
4118 (setq gnus-newsgroup-headers
4119 (sort articles (gnus-make-sort-function
4120 gnus-article-sort-functions)))
4121 (gnus-message 7 "Sorting articles...done"))))
4123 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4124 (defmacro gnus-thread-header (thread)
4125 "Return header of first article in THREAD.
4126 Note that THREAD must never, ever be anything else than a variable -
4127 using some other form will lead to serious barfage."
4128 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4129 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4130 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4133 (defsubst gnus-article-sort-by-number (h1 h2)
4134 "Sort articles by article number."
4135 (< (mail-header-number h1)
4136 (mail-header-number h2)))
4138 (defun gnus-thread-sort-by-number (h1 h2)
4139 "Sort threads by root article number."
4140 (gnus-article-sort-by-number
4141 (gnus-thread-header h1) (gnus-thread-header h2)))
4143 (defsubst gnus-article-sort-by-lines (h1 h2)
4144 "Sort articles by article Lines header."
4145 (< (mail-header-lines h1)
4146 (mail-header-lines h2)))
4148 (defun gnus-thread-sort-by-lines (h1 h2)
4149 "Sort threads by root article Lines header."
4150 (gnus-article-sort-by-lines
4151 (gnus-thread-header h1) (gnus-thread-header h2)))
4153 (defsubst gnus-article-sort-by-chars (h1 h2)
4154 "Sort articles by octet length."
4155 (< (mail-header-chars h1)
4156 (mail-header-chars h2)))
4158 (defun gnus-thread-sort-by-chars (h1 h2)
4159 "Sort threads by root article octet length."
4160 (gnus-article-sort-by-chars
4161 (gnus-thread-header h1) (gnus-thread-header h2)))
4163 (defsubst gnus-article-sort-by-author (h1 h2)
4164 "Sort articles by root author."
4166 (let ((addr (car (mime-entity-read-field h1 'From))))
4167 (or (std11-full-name-string addr)
4168 (std11-address-string addr)
4170 (let ((addr (car (mime-entity-read-field h2 'From))))
4171 (or (std11-full-name-string addr)
4172 (std11-address-string addr)
4176 (defun gnus-thread-sort-by-author (h1 h2)
4177 "Sort threads by root author."
4178 (gnus-article-sort-by-author
4179 (gnus-thread-header h1) (gnus-thread-header h2)))
4181 (defsubst gnus-article-sort-by-subject (h1 h2)
4182 "Sort articles by root subject."
4184 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4185 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4187 (defun gnus-thread-sort-by-subject (h1 h2)
4188 "Sort threads by root subject."
4189 (gnus-article-sort-by-subject
4190 (gnus-thread-header h1) (gnus-thread-header h2)))
4192 (defsubst gnus-article-sort-by-date (h1 h2)
4193 "Sort articles by root article date."
4195 (gnus-date-get-time (mail-header-date h1))
4196 (gnus-date-get-time (mail-header-date h2))))
4198 (defun gnus-thread-sort-by-date (h1 h2)
4199 "Sort threads by root article date."
4200 (gnus-article-sort-by-date
4201 (gnus-thread-header h1) (gnus-thread-header h2)))
4203 (defsubst gnus-article-sort-by-score (h1 h2)
4204 "Sort articles by root article score.
4205 Unscored articles will be counted as having a score of zero."
4206 (> (or (cdr (assq (mail-header-number h1)
4207 gnus-newsgroup-scored))
4208 gnus-summary-default-score 0)
4209 (or (cdr (assq (mail-header-number h2)
4210 gnus-newsgroup-scored))
4211 gnus-summary-default-score 0)))
4213 (defun gnus-thread-sort-by-score (h1 h2)
4214 "Sort threads by root article score."
4215 (gnus-article-sort-by-score
4216 (gnus-thread-header h1) (gnus-thread-header h2)))
4218 (defun gnus-thread-sort-by-total-score (h1 h2)
4219 "Sort threads by the sum of all scores in the thread.
4220 Unscored articles will be counted as having a score of zero."
4221 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4223 (defun gnus-thread-total-score (thread)
4224 ;; This function find the total score of THREAD.
4229 (if (stringp (car thread))
4230 (apply gnus-thread-score-function 0
4231 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4232 (gnus-thread-total-score-1 thread)))
4234 (gnus-thread-total-score-1 (list thread)))))
4236 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4237 "Sort threads such that the thread with the most recently arrived article comes first."
4238 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4240 (defun gnus-thread-highest-number (thread)
4241 "Return the highest article number in THREAD."
4242 (apply 'max (mapcar (lambda (header)
4243 (mail-header-number header))
4244 (message-flatten-list thread))))
4246 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4247 "Sort threads such that the thread with the most recently dated article comes first."
4248 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4250 (defun gnus-thread-latest-date (thread)
4251 "Return the highest article date in THREAD."
4252 (let ((previous-time 0))
4257 (mail-header-parse-date
4259 (mail-header-date header)
4260 (error previous-time))))))
4262 (message-flatten-list thread)
4264 (< (mail-header-number h1)
4265 (mail-header-number h2))))))))
4267 (defun gnus-thread-total-score-1 (root)
4268 ;; This function find the total score of the thread below ROOT.
4269 (setq root (car root))
4270 (apply gnus-thread-score-function
4272 (mapcar 'gnus-thread-total-score
4273 (cdr (gnus-id-to-thread (mail-header-id root))))
4274 (when (> (mail-header-number root) 0)
4275 (list (or (cdr (assq (mail-header-number root)
4276 gnus-newsgroup-scored))
4277 gnus-summary-default-score 0))))
4278 (list gnus-summary-default-score)
4281 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4282 (defvar gnus-tmp-prev-subject nil)
4283 (defvar gnus-tmp-false-parent nil)
4284 (defvar gnus-tmp-root-expunged nil)
4285 (defvar gnus-tmp-dummy-line nil)
4287 (eval-when-compile (defvar gnus-tmp-header))
4288 (defun gnus-extra-header (type &optional header)
4289 "Return the extra header of TYPE."
4290 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4293 (defvar gnus-tmp-thread-tree-header-string "")
4295 (defvar gnus-sum-thread-tree-root "> "
4296 "With %B spec, used for the root of a thread.
4297 If nil, use subject instead.")
4298 (defvar gnus-sum-thread-tree-single-indent ""
4299 "With %B spec, used for a thread with just one message.
4300 If nil, use subject instead.")
4301 (defvar gnus-sum-thread-tree-vertical "| "
4302 "With %B spec, used for drawing a vertical line.")
4303 (defvar gnus-sum-thread-tree-indent " "
4304 "With %B spec, used for indenting.")
4305 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4306 "With %B spec, used for a leaf with brothers.")
4307 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4308 "With %B spec, used for a leaf without brothers.")
4310 (defun gnus-summary-prepare-threads (threads)
4311 "Prepare summary buffer from THREADS and indentation LEVEL.
4312 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4313 or a straight list of headers."
4314 (gnus-message 7 "Generating summary...")
4316 (setq gnus-newsgroup-threads threads)
4319 (let ((gnus-tmp-level 0)
4320 (default-score (or gnus-summary-default-score 0))
4321 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4322 thread number subject stack state gnus-tmp-gathered beg-match
4323 new-roots gnus-tmp-new-adopts thread-end
4324 gnus-tmp-header gnus-tmp-unread
4325 gnus-tmp-replied gnus-tmp-subject-or-nil
4326 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4327 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4328 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4331 (setq gnus-tmp-prev-subject nil)
4333 (if (vectorp (car threads))
4334 ;; If this is a straight (sic) list of headers, then a
4335 ;; threaded summary display isn't required, so we just create
4336 ;; an unthreaded one.
4337 (gnus-summary-prepare-unthreaded threads)
4339 ;; Do the threaded display.
4341 (while (or threads stack gnus-tmp-new-adopts new-roots)
4343 (if (and (= gnus-tmp-level 0)
4346 (not gnus-tmp-false-parent)
4347 (or gnus-tmp-new-adopts new-roots))
4348 (if gnus-tmp-new-adopts
4349 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4350 thread (list (car gnus-tmp-new-adopts))
4351 gnus-tmp-header (caar thread)
4352 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4354 (setq thread (list (car new-roots))
4355 gnus-tmp-header (caar thread)
4356 new-roots (cdr new-roots))))
4359 ;; If there are some threads, we do them before the
4360 ;; threads on the stack.
4361 (setq thread threads
4362 gnus-tmp-header (caar thread))
4363 ;; There were no current threads, so we pop something off
4365 (setq state (car stack)
4366 gnus-tmp-level (car state)
4367 tree-stack (cadr state)
4368 thread (caddr state)
4370 gnus-tmp-header (caar thread))))
4372 (setq gnus-tmp-false-parent nil)
4373 (setq gnus-tmp-root-expunged nil)
4374 (setq thread-end nil)
4376 (if (stringp gnus-tmp-header)
4377 ;; The header is a dummy root.
4379 ((eq gnus-summary-make-false-root 'adopt)
4380 ;; We let the first article adopt the rest.
4381 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4383 (setq gnus-tmp-gathered
4385 (lambda (h) (mail-header-number (car h)))
4388 (setq thread (cons (list (caar thread)
4391 (setq gnus-tmp-level -1
4392 gnus-tmp-false-parent t))
4393 ((eq gnus-summary-make-false-root 'empty)
4394 ;; We print adopted articles with empty subject fields.
4395 (setq gnus-tmp-gathered
4397 (lambda (h) (mail-header-number (car h)))
4400 (setq gnus-tmp-level -1))
4401 ((eq gnus-summary-make-false-root 'dummy)
4402 ;; We remember that we probably want to output a dummy
4404 (setq gnus-tmp-dummy-line gnus-tmp-header)
4405 (setq gnus-tmp-prev-subject gnus-tmp-header))
4407 ;; We do not make a root for the gathered
4408 ;; sub-threads at all.
4409 (setq gnus-tmp-level -1)))
4411 (setq number (mail-header-number gnus-tmp-header)
4412 subject (mail-header-subject gnus-tmp-header))
4415 ;; If the thread has changed subject, we might want to make
4416 ;; this subthread into a root.
4417 ((and (null gnus-thread-ignore-subject)
4418 (not (zerop gnus-tmp-level))
4419 gnus-tmp-prev-subject
4421 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4422 (setq new-roots (nconc new-roots (list (car thread)))
4424 gnus-tmp-header nil))
4425 ;; If the article lies outside the current limit,
4426 ;; then we do not display it.
4427 ((not (memq number gnus-newsgroup-limit))
4428 (setq gnus-tmp-gathered
4430 (lambda (h) (mail-header-number (car h)))
4433 (setq gnus-tmp-new-adopts (if (cdar thread)
4434 (append gnus-tmp-new-adopts
4436 gnus-tmp-new-adopts)
4438 gnus-tmp-header nil)
4439 (when (zerop gnus-tmp-level)
4440 (setq gnus-tmp-root-expunged t)))
4441 ;; Perhaps this article is to be marked as read?
4442 ((and gnus-summary-mark-below
4443 (< (or (cdr (assq number gnus-newsgroup-scored))
4445 gnus-summary-mark-below)
4446 ;; Don't touch sparse articles.
4447 (not (gnus-summary-article-sparse-p number))
4448 (not (gnus-summary-article-ancient-p number)))
4449 (setq gnus-newsgroup-unreads
4450 (delq number gnus-newsgroup-unreads))
4451 (if gnus-newsgroup-auto-expire
4452 (setq gnus-newsgroup-expirable
4453 (gnus-add-to-sorted-list
4454 gnus-newsgroup-expirable number))
4455 (push (cons number gnus-low-score-mark)
4456 gnus-newsgroup-reads))))
4458 (when gnus-tmp-header
4459 ;; We may have an old dummy line to output before this
4461 (when (and gnus-tmp-dummy-line
4464 (mail-header-subject gnus-tmp-header)))
4465 (gnus-summary-insert-dummy-line
4466 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4467 (setq gnus-tmp-dummy-line nil))
4469 ;; Compute the mark.
4470 (setq gnus-tmp-unread (gnus-article-mark number))
4472 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4473 gnus-tmp-header gnus-tmp-level)
4474 gnus-newsgroup-data)
4476 ;; Actually insert the line.
4478 gnus-tmp-subject-or-nil
4480 ((and gnus-thread-ignore-subject
4481 gnus-tmp-prev-subject
4482 (not (inline (gnus-subject-equal
4483 gnus-tmp-prev-subject subject))))
4485 ((zerop gnus-tmp-level)
4486 (if (and (eq gnus-summary-make-false-root 'empty)
4487 (memq number gnus-tmp-gathered)
4488 gnus-tmp-prev-subject
4489 (inline (gnus-subject-equal
4490 gnus-tmp-prev-subject subject)))
4491 gnus-summary-same-subject
4493 (t gnus-summary-same-subject)))
4494 (if (and (eq gnus-summary-make-false-root 'adopt)
4495 (= gnus-tmp-level 1)
4496 (memq number gnus-tmp-gathered))
4497 (setq gnus-tmp-opening-bracket ?\<
4498 gnus-tmp-closing-bracket ?\>)
4499 (setq gnus-tmp-opening-bracket ?\[
4500 gnus-tmp-closing-bracket ?\]))
4502 gnus-tmp-indentation
4503 (aref gnus-thread-indent-array gnus-tmp-level)
4504 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4505 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4506 gnus-summary-default-score 0)
4508 (if (or (null gnus-summary-default-score)
4509 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4510 gnus-summary-zcore-fuzz))
4512 (if (< gnus-tmp-score gnus-summary-default-score)
4513 gnus-score-below-mark gnus-score-over-mark))
4515 (cond ((memq number gnus-newsgroup-processable)
4517 ((memq number gnus-newsgroup-cached)
4519 ((memq number gnus-newsgroup-replied)
4521 ((memq number gnus-newsgroup-forwarded)
4522 gnus-forwarded-mark)
4523 ((memq number gnus-newsgroup-saved)
4525 ((memq number gnus-newsgroup-recent)
4527 ((memq number gnus-newsgroup-unseen)
4530 gnus-tmp-from (mail-header-from gnus-tmp-header)
4533 ((string-match "<[^>]+> *$" gnus-tmp-from)
4534 (setq beg-match (match-beginning 0))
4535 (or (and (string-match "^\".+\"" gnus-tmp-from)
4536 (substring gnus-tmp-from 1 (1- (match-end 0))))
4537 (substring gnus-tmp-from 0 beg-match)))
4538 ((string-match "(.+)" gnus-tmp-from)
4539 (substring gnus-tmp-from
4540 (1+ (match-beginning 0)) (1- (match-end 0))))
4542 gnus-tmp-thread-tree-header-string
4544 ((not gnus-show-threads) "")
4545 ((zerop gnus-tmp-level)
4547 (or gnus-sum-thread-tree-root subject)
4548 (or gnus-sum-thread-tree-single-indent subject)))
4550 (concat (apply 'concat
4551 (mapcar (lambda (item)
4553 gnus-sum-thread-tree-vertical
4554 gnus-sum-thread-tree-indent))
4555 (cdr (reverse tree-stack))))
4557 gnus-sum-thread-tree-leaf-with-other
4558 gnus-sum-thread-tree-single-leaf)))))
4559 (when (string= gnus-tmp-name "")
4560 (setq gnus-tmp-name gnus-tmp-from))
4561 (unless (numberp gnus-tmp-lines)
4562 (setq gnus-tmp-lines -1))
4563 (if (= gnus-tmp-lines -1)
4564 (setq gnus-tmp-lines "?")
4565 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4566 (gnus-put-text-property
4568 (progn (eval gnus-summary-line-format-spec) (point))
4569 'gnus-number number)
4572 (gnus-run-hooks 'gnus-summary-update-hook)
4575 (setq gnus-tmp-prev-subject subject)))
4577 (when (nth 1 thread)
4578 (push (list (max 0 gnus-tmp-level)
4579 (copy-list tree-stack)
4582 (push (if (nth 1 thread) 1 0) tree-stack)
4583 (incf gnus-tmp-level)
4584 (setq threads (if thread-end nil (cdar thread)))
4586 (setq gnus-tmp-level 0)))))
4587 (gnus-message 7 "Generating summary...done"))
4589 (defun gnus-summary-prepare-unthreaded (headers)
4590 "Generate an unthreaded summary buffer based on HEADERS."
4591 (let (header number mark)
4596 ;; We may have to root out some bad articles...
4597 (when (memq (setq number (mail-header-number
4598 (setq header (pop headers))))
4599 gnus-newsgroup-limit)
4600 ;; Mark article as read when it has a low score.
4601 (when (and gnus-summary-mark-below
4602 (< (or (cdr (assq number gnus-newsgroup-scored))
4603 gnus-summary-default-score 0)
4604 gnus-summary-mark-below)
4605 (not (gnus-summary-article-ancient-p number)))
4606 (setq gnus-newsgroup-unreads
4607 (delq number gnus-newsgroup-unreads))
4608 (if gnus-newsgroup-auto-expire
4609 (push number gnus-newsgroup-expirable)
4610 (push (cons number gnus-low-score-mark)
4611 gnus-newsgroup-reads)))
4613 (setq mark (gnus-article-mark number))
4614 (push (gnus-data-make number mark (1+ (point)) header 0)
4615 gnus-newsgroup-data)
4616 (gnus-summary-insert-line
4618 mark (memq number gnus-newsgroup-replied)
4619 (memq number gnus-newsgroup-expirable)
4620 (mail-header-subject header) nil
4621 (cdr (assq number gnus-newsgroup-scored))
4622 (memq number gnus-newsgroup-processable))))))
4624 (defun gnus-summary-remove-list-identifiers ()
4625 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4626 (let ((regexp (if (consp gnus-list-identifiers)
4627 (mapconcat 'identity gnus-list-identifiers " *\\|")
4628 gnus-list-identifiers))
4631 (dolist (header gnus-newsgroup-headers)
4632 (setq subject (mail-header-subject header)
4634 (while (string-match
4635 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4638 (concat (substring subject 0 (match-beginning 2))
4639 (substring subject (match-end 0)))
4643 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4645 (concat (substring subject 0 (match-beginning 1))
4646 (substring subject (match-end 1)))))
4648 (mail-header-set-subject header subject))))))
4650 (defun gnus-fetch-headers (articles)
4651 "Fetch headers of ARTICLES."
4652 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4653 (gnus-message 5 "Fetching headers for %s..." name)
4656 (setq gnus-headers-retrieved-by
4657 (gnus-retrieve-headers
4658 articles gnus-newsgroup-name
4659 ;; We might want to fetch old headers, but
4660 ;; not if there is only 1 article.
4662 (not (eq gnus-fetch-old-headers 'some))
4663 (not (numberp gnus-fetch-old-headers)))
4664 (> (length articles) 1))
4665 gnus-fetch-old-headers))))
4666 (gnus-get-newsgroup-headers-xover
4667 articles nil nil gnus-newsgroup-name t)
4668 (gnus-get-newsgroup-headers))
4669 (gnus-message 5 "Fetching headers for %s...done" name))))
4671 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4672 "Select newsgroup GROUP.
4673 If READ-ALL is non-nil, all articles in the group are selected.
4674 If SELECT-ARTICLES, only select those articles from GROUP."
4675 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4676 ;;!!! Dirty hack; should be removed.
4677 (gnus-summary-ignore-duplicates
4678 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4680 gnus-summary-ignore-duplicates))
4681 (info (nth 2 entry))
4682 articles fetched-articles cached)
4684 (unless (gnus-check-server
4685 (set (make-local-variable 'gnus-current-select-method)
4686 (gnus-find-method-for-group group)))
4687 (error "Couldn't open server"))
4689 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4690 (gnus-activate-group group) ; Or we can activate it...
4691 (progn ; Or we bug out.
4692 (when (equal major-mode 'gnus-summary-mode)
4693 (kill-buffer (current-buffer)))
4694 (error "Couldn't activate group %s: %s"
4695 group (gnus-status-message group))))
4697 (unless (gnus-request-group group t)
4698 (when (equal major-mode 'gnus-summary-mode)
4699 (kill-buffer (current-buffer)))
4700 (error "Couldn't request group %s: %s"
4701 group (gnus-status-message group)))
4703 (setq gnus-newsgroup-name group
4704 gnus-newsgroup-unselected nil
4705 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4707 (let ((display (gnus-group-find-parameter group 'display)))
4708 (setq gnus-newsgroup-display
4710 ((not (zerop (or (car-safe read-all) 0)))
4711 ;; The user entered the group with C-u SPC/RET, let's show
4717 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4719 ;; The following is probably the "correct" solution, but
4720 ;; it makes Gnus fetch all headers and then limit the
4721 ;; articles (which is slow), so instead we hack the
4722 ;; select-articles parameter instead. -- Simon Josefsson
4725 ;; (gnus-byte-compile
4726 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4728 (setq select-articles
4729 (gnus-uncompress-range
4730 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4734 (cdr (gnus-active group)))))
4739 (gnus-summary-setup-default-charset)
4741 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4742 (when (gnus-virtual-group-p group)
4743 (setq cached gnus-newsgroup-cached))
4745 (setq gnus-newsgroup-unreads
4746 (gnus-sorted-ndifference
4747 (gnus-sorted-ndifference gnus-newsgroup-unreads
4748 gnus-newsgroup-marked)
4749 gnus-newsgroup-dormant))
4751 (setq gnus-newsgroup-processable nil)
4753 (gnus-update-read-articles group gnus-newsgroup-unreads)
4755 ;; Adjust and set lists of article marks.
4757 (gnus-adjust-marked-articles info))
4759 (if (setq articles select-articles)
4760 (setq gnus-newsgroup-unselected
4761 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4762 (setq articles (gnus-articles-to-read group read-all)))
4766 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4768 ((eq articles 0) nil)
4770 ;; Init the dependencies hash table.
4771 (setq gnus-newsgroup-dependencies
4772 (gnus-make-hashtable (length articles)))
4773 (gnus-set-global-variables)
4774 ;; Retrieve the headers and read them in.
4775 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4777 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4779 (setq gnus-newsgroup-cached cached))
4781 ;; Suppress duplicates?
4782 (when gnus-suppress-duplicates
4783 (gnus-dup-suppress-articles))
4785 ;; Set the initial limit.
4786 (setq gnus-newsgroup-limit (copy-sequence articles))
4787 ;; Remove canceled articles from the list of unread articles.
4788 (setq fetched-articles
4789 (mapcar (lambda (headers) (mail-header-number headers))
4790 gnus-newsgroup-headers))
4791 (setq gnus-newsgroup-articles fetched-articles)
4792 (setq gnus-newsgroup-unreads
4793 (gnus-sorted-nintersection
4794 gnus-newsgroup-unreads fetched-articles))
4795 (gnus-compute-unseen-list)
4797 ;; Removed marked articles that do not exist.
4798 (gnus-update-missing-marks
4799 (gnus-sorted-difference articles fetched-articles))
4800 ;; We might want to build some more threads first.
4801 (when (and gnus-fetch-old-headers
4802 (eq gnus-headers-retrieved-by 'nov))
4803 (if (eq gnus-fetch-old-headers 'invisible)
4804 (gnus-build-all-threads)
4805 (gnus-build-old-threads)))
4806 ;; Let the Gnus agent mark articles as read.
4808 (gnus-agent-get-undownloaded-list))
4809 ;; Remove list identifiers from subject
4810 (when gnus-list-identifiers
4811 (gnus-summary-remove-list-identifiers))
4812 ;; Check whether auto-expire is to be done in this group.
4813 (setq gnus-newsgroup-auto-expire
4814 (gnus-group-auto-expirable-p group))
4815 ;; Set up the article buffer now, if necessary.
4816 (unless gnus-single-article-buffer
4817 (gnus-article-setup-buffer))
4818 ;; First and last article in this newsgroup.
4819 (when gnus-newsgroup-headers
4820 (setq gnus-newsgroup-begin
4821 (mail-header-number (car gnus-newsgroup-headers))
4824 (gnus-last-element gnus-newsgroup-headers))))
4825 ;; GROUP is successfully selected.
4826 (or gnus-newsgroup-headers t)))))
4828 (defun gnus-compute-unseen-list ()
4829 ;; The `seen' marks are treated specially.
4830 (if (not gnus-newsgroup-seen)
4831 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4832 (setq gnus-newsgroup-unseen
4833 (gnus-inverse-list-range-intersection
4834 gnus-newsgroup-articles gnus-newsgroup-seen))))
4836 (defun gnus-summary-display-make-predicate (display)
4837 (require 'gnus-agent)
4838 (when (= (length display) 1)
4839 (setq display (car display)))
4840 (unless gnus-summary-display-cache
4841 (dolist (elem (append (list (cons 'read 'read)
4842 (cons 'unseen 'unseen))
4843 gnus-article-mark-lists))
4844 (push (cons (cdr elem)
4846 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4847 gnus-summary-display-cache)))
4848 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4849 (gnus-get-predicate display)))
4851 ;; Uses the dynamically bound `number' variable.
4853 (defun gnus-article-marked-p (type &optional article)
4854 (let ((article (or article number)))
4857 (memq article gnus-newsgroup-marked))
4859 (memq article gnus-newsgroup-unsendable))
4860 ((eq type 'undownload)
4861 (memq article gnus-newsgroup-undownloaded))
4862 ((eq type 'download)
4863 (memq article gnus-newsgroup-downloadable))
4865 (memq article gnus-newsgroup-unreads))
4867 (memq article gnus-newsgroup-reads))
4869 (memq article gnus-newsgroup-dormant) )
4871 (memq article gnus-newsgroup-expirable))
4873 (memq article gnus-newsgroup-replied))
4875 (memq article gnus-newsgroup-killed))
4876 ((eq type 'bookmark)
4877 (assq article gnus-newsgroup-bookmarks))
4879 (assq article gnus-newsgroup-scored))
4881 (memq article gnus-newsgroup-saved))
4883 (memq article gnus-newsgroup-cached))
4885 (memq article gnus-newsgroup-forwarded))
4887 (not (memq article gnus-newsgroup-unseen)))
4889 (memq article gnus-newsgroup-recent))
4892 (defun gnus-articles-to-read (group &optional read-all)
4893 "Find out what articles the user wants to read."
4895 ;; Select all articles if `read-all' is non-nil, or if there
4896 ;; are no unread articles.
4898 (and (zerop (length gnus-newsgroup-marked))
4899 (zerop (length gnus-newsgroup-unreads)))
4900 ;; Fetch all if the predicate is non-nil.
4901 gnus-newsgroup-display)
4902 ;; We want to select the headers for all the articles in
4903 ;; the group, so we select either all the active
4904 ;; articles in the group, or (if that's nil), the
4905 ;; articles in the cache.
4907 (gnus-uncompress-range (gnus-active group))
4908 (gnus-cache-articles-in-group group))
4909 ;; Select only the "normal" subset of articles.
4911 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
4912 gnus-newsgroup-unreads)))
4913 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4914 (scored (length scored-list))
4915 (number (length articles))
4916 (marked (+ (length gnus-newsgroup-marked)
4917 (length gnus-newsgroup-dormant)))
4922 ((numberp gnus-newsgroup-display)
4923 gnus-newsgroup-display)
4927 ((and (or (<= scored marked) (= scored number))
4928 (natnump gnus-large-newsgroup)
4929 (> number gnus-large-newsgroup))
4930 (let* ((cursor-in-echo-area nil)
4932 (read-from-minibuffer
4934 "How many articles from %s (max %d): "
4936 (gnus-group-decoded-name gnus-newsgroup-name)
4939 (cons (number-to-string gnus-large-newsgroup)
4941 (if (string-match "^[ \t]*$" input)
4944 ((and (> scored marked) (< scored number)
4945 (> (- scored number) 20))
4948 (format "%s %s (%d scored, %d total): "
4949 "How many articles from"
4950 (gnus-group-decoded-name group)
4952 (if (string-match "^[ \t]*$" input)
4956 (message "Quit getting the articles to read")
4958 (setq select (if (stringp select) (string-to-number select) select))
4959 (if (or (null select) (zerop select))
4961 (if (and (not (zerop scored)) (<= (abs select) scored))
4963 (setq articles (sort scored-list '<))
4964 (setq number (length articles)))
4965 (setq articles (copy-sequence articles)))
4967 (when (< (abs select) number)
4969 ;; Select the N oldest articles.
4970 (setcdr (nthcdr (1- (abs select)) articles) nil)
4971 ;; Select the N most recent articles.
4972 (setq articles (nthcdr (- number select) articles))))
4973 (setq gnus-newsgroup-unselected
4974 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4975 (when gnus-alter-articles-to-read-function
4976 (setq gnus-newsgroup-unreads
4978 (funcall gnus-alter-articles-to-read-function
4979 gnus-newsgroup-name gnus-newsgroup-unreads)
4983 (defun gnus-killed-articles (killed articles)
4986 (when (inline (gnus-member-of-range (car articles) killed))
4987 (push (car articles) out))
4988 (setq articles (cdr articles)))
4991 (defun gnus-uncompress-marks (marks)
4992 "Uncompress the mark ranges in MARKS."
4993 (let ((uncompressed '(score bookmark))
4996 (if (memq (caar marks) uncompressed)
4997 (push (car marks) out)
4998 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4999 (setq marks (cdr marks)))
5002 (defun gnus-article-mark-to-type (mark)
5003 "Return the type of MARK."
5004 (or (cadr (assq mark gnus-article-special-mark-lists))
5007 (defun gnus-article-unpropagatable-p (mark)
5008 "Return whether MARK should be propagated to backend."
5009 (memq mark gnus-article-unpropagated-mark-lists))
5011 (defun gnus-adjust-marked-articles (info)
5012 "Set all article lists and remove all marks that are no longer valid."
5013 (let* ((marked-lists (gnus-info-marks info))
5014 (active (gnus-active (gnus-info-group info)))
5017 (types gnus-article-mark-lists)
5018 marks var articles article mark mark-type)
5020 (dolist (marks marked-lists)
5021 (setq mark (car marks)
5022 mark-type (gnus-article-mark-to-type mark)
5023 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5025 ;; We set the variable according to the type of the marks list,
5026 ;; and then adjust the marks to a subset of the active articles.
5028 ;; Adjust "simple" lists.
5029 ((eq mark-type 'list)
5030 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5031 (when (memq mark '(tick dormant expire reply save))
5033 (when (or (< (setq article (pop articles)) min) (> article max))
5034 (set var (delq article (symbol-value var)))))))
5036 ((eq mark-type 'tuple)
5037 (set var (setq articles (cdr marks)))
5038 (when (not (listp (cdr (symbol-value var))))
5039 (set var (list (symbol-value var))))
5040 (when (not (listp (cdr articles)))
5041 (setq articles (list articles)))
5043 (when (or (not (consp (setq article (pop articles))))
5044 (< (car article) min)
5045 (> (car article) max))
5046 (set var (delq article (symbol-value var))))))
5047 ;; Adjust ranges (sloppily).
5048 ((eq mark-type 'range)
5051 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5052 ;; It should be (seen (NUM1 . NUM2)).
5053 (when (numberp (cddr marks))
5054 (setcdr marks (list (cdr marks))))
5055 (setq articles (cdr marks))
5056 (while (and articles
5057 (or (and (consp (car articles))
5058 (> min (cdar articles)))
5059 (and (numberp (car articles))
5060 (> min (car articles)))))
5062 (set var articles))))))))
5064 (defun gnus-update-missing-marks (missing)
5065 "Go through the list of MISSING articles and remove them from the mark lists."
5068 ;; Go through all types.
5069 (dolist (elem gnus-article-mark-lists)
5070 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5071 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5072 (when (symbol-value var)
5073 ;; This list has articles. So we delete all missing
5074 ;; articles from it.
5077 (set var (delq (pop m) (symbol-value var))))))))))
5079 (defun gnus-update-marks ()
5080 "Enter the various lists of marked articles into the newsgroup info list."
5081 (let ((types gnus-article-mark-lists)
5082 (info (gnus-get-info gnus-newsgroup-name))
5083 type list newmarked symbol delta-marks)
5085 ;; Add all marks lists to the list of marks lists.
5086 (while (setq type (pop types))
5087 (setq list (symbol-value
5089 (intern (format "gnus-newsgroup-%s" (car type))))))
5092 ;; Get rid of the entries of the articles that have the
5094 (when (and (eq (cdr type) 'score)
5098 (prev (cons nil list))
5101 (if (or (not (consp (car arts)))
5102 (= (cdar arts) gnus-summary-default-score))
5103 (setcdr prev (cdr arts))
5105 (setq arts (cdr arts)))
5106 (setq list (cdr all)))))
5108 (when (eq (cdr type) 'seen)
5109 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5111 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5112 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5114 (when (and (gnus-check-backend-function
5115 'request-set-mark gnus-newsgroup-name)
5116 (not (gnus-article-unpropagatable-p (cdr type))))
5117 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5118 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5119 (add (gnus-remove-from-range
5120 (gnus-copy-sequence list) old)))
5122 (push (list add 'add (list (cdr type))) delta-marks))
5124 (push (list del 'del (list (cdr type))) delta-marks))))
5127 (push (cons (cdr type) list) newmarked)))
5130 (unless (gnus-check-group gnus-newsgroup-name)
5131 (error "Can't open server for %s" gnus-newsgroup-name))
5132 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5134 ;; Enter these new marks into the info of the group.
5136 (setcar (nthcdr 3 info) newmarked)
5137 ;; Add the marks lists to the end of the info.
5139 (setcdr (nthcdr 2 info) (list newmarked))))
5141 ;; Cut off the end of the info if there's nothing else there.
5145 (when (nthcdr (decf i) info)
5146 (setcdr (nthcdr i info) nil)))))))
5148 (defun gnus-set-mode-line (where)
5149 "Set the mode line of the article or summary buffers.
5150 If WHERE is `summary', the summary mode line format will be used."
5151 ;; Is this mode line one we keep updated?
5152 (when (and (memq where gnus-updated-mode-lines)
5154 (intern (format "gnus-%s-mode-line-format-spec" where))))
5157 ;; We evaluate this in the summary buffer since these
5158 ;; variables are buffer-local to that buffer.
5159 (set-buffer gnus-summary-buffer)
5160 ;; We bind all these variables that are used in the `eval' form
5162 (let* ((mformat (symbol-value
5164 (format "gnus-%s-mode-line-format-spec" where))))
5165 (gnus-tmp-group-name (gnus-group-decoded-name
5166 gnus-newsgroup-name))
5167 (gnus-tmp-article-number (or gnus-current-article 0))
5168 (gnus-tmp-unread gnus-newsgroup-unreads)
5169 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5170 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5171 (gnus-tmp-unread-and-unselected
5172 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5173 (zerop gnus-tmp-unselected))
5175 ((zerop gnus-tmp-unselected)
5176 (format "{%d more}" gnus-tmp-unread-and-unticked))
5177 (t (format "{%d(+%d) more}"
5178 gnus-tmp-unread-and-unticked
5179 gnus-tmp-unselected))))
5181 (if (and gnus-current-headers
5182 (vectorp gnus-current-headers))
5183 (gnus-mode-string-quote
5184 (mail-header-subject gnus-current-headers))
5186 bufname-length max-len
5187 gnus-tmp-header);; passed as argument to any user-format-funcs
5188 (setq mode-string (eval mformat))
5189 (setq bufname-length (if (string-match "%b" mode-string)
5192 (if (eq where 'summary)
5194 (get-buffer gnus-article-buffer))))
5197 (setq max-len (max 4 (if gnus-mode-non-string-length
5199 gnus-mode-non-string-length
5201 (length mode-string))))
5202 ;; We might have to chop a bit of the string off...
5203 (when (> (length mode-string) max-len)
5205 (concat (gnus-truncate-string mode-string (- max-len 3))
5207 ;; Pad the mode string a bit.
5208 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5209 ;; Update the mode line.
5210 (setq mode-line-buffer-identification
5211 (gnus-mode-line-buffer-identification (list mode-string)))
5212 (set-buffer-modified-p t))))
5214 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5215 "Go through the HEADERS list and add all Xrefs to a hash table.
5216 The resulting hash table is returned, or nil if no Xrefs were found."
5217 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5218 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5219 (xref-hashtb (gnus-make-hashtable))
5220 start group entry number xrefs header)
5222 (setq header (pop headers))
5223 (when (and (setq xrefs (mail-header-xref header))
5224 (not (memq (setq number (mail-header-number header))
5227 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5228 (setq start (match-end 0))
5229 (setq group (if prefix
5230 (concat prefix (substring xrefs (match-beginning 1)
5232 (substring xrefs (match-beginning 1) (match-end 1))))
5234 (string-to-int (substring xrefs (match-beginning 2)
5236 (if (setq entry (gnus-gethash group xref-hashtb))
5237 (setcdr entry (cons number (cdr entry)))
5238 (gnus-sethash group (cons number nil) xref-hashtb)))))
5239 (and start xref-hashtb)))
5241 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5242 "Look through all the headers and mark the Xrefs as read."
5243 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5244 name entry info xref-hashtb idlist method nth4)
5246 (set-buffer gnus-group-buffer)
5247 (when (setq xref-hashtb
5248 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5251 (unless (string= from-newsgroup (setq name (symbol-name group)))
5252 (setq idlist (symbol-value group))
5253 ;; Dead groups are not updated.
5255 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5257 (when (stringp (setq nth4 (gnus-info-method info)))
5258 (setq nth4 (gnus-server-to-method nth4))))
5259 ;; Only do the xrefs if the group has the same
5260 ;; select method as the group we have just read.
5261 (or (gnus-methods-equal-p
5262 nth4 (gnus-find-method-for-group from-newsgroup))
5264 (equal nth4 (setq method (gnus-find-method-for-group
5266 (and (equal (car nth4) (car method))
5267 (equal (nth 1 nth4) (nth 1 method))))
5268 gnus-use-cross-reference
5269 (or (not (eq gnus-use-cross-reference t))
5271 ;; Only do cross-references on subscribed
5272 ;; groups, if that is what is wanted.
5273 (<= (gnus-info-level info) gnus-level-subscribed))
5274 (gnus-group-make-articles-read name idlist))))
5277 (defun gnus-compute-read-articles (group articles)
5278 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5279 (info (nth 2 entry))
5280 (active (gnus-active group))
5283 ;; First peel off all invalid article numbers.
5285 (let ((ids articles)
5287 (while (setq id (pop ids))
5288 (when (and first (> id (cdr active)))
5289 ;; We'll end up in this situation in one particular
5290 ;; obscure situation. If you re-scan a group and get
5291 ;; a new article that is cross-posted to a different
5292 ;; group that has not been re-scanned, you might get
5293 ;; crossposted article that has a higher number than
5294 ;; Gnus believes possible. So we re-activate this
5295 ;; group as well. This might mean doing the
5296 ;; crossposting thingy will *increase* the number
5297 ;; of articles in some groups. Tsk, tsk.
5298 (setq active (or (gnus-activate-group group) active)))
5299 (when (or (> id (cdr active))
5300 (< id (car active)))
5301 (setq articles (delq id articles))))))
5302 ;; If the read list is nil, we init it.
5304 (null (gnus-info-read info))
5306 (setq ninfo (cons 1 (1- (car active))))
5307 (setq ninfo (gnus-info-read info)))
5308 ;; Then we add the read articles to the range.
5310 ninfo (setq articles (sort articles '<))))))
5312 (defun gnus-group-make-articles-read (group articles)
5313 "Update the info of GROUP to say that ARTICLES are read."
5315 (entry (gnus-gethash group gnus-newsrc-hashtb))
5316 (info (nth 2 entry))
5317 (active (gnus-active group))
5320 (setq range (gnus-compute-read-articles group articles))
5322 (set-buffer gnus-group-buffer)
5325 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5326 (gnus-info-set-read ',info ',(gnus-info-read info))
5327 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5328 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5329 (gnus-group-update-group ,group t))))
5330 ;; Add the read articles to the range.
5331 (gnus-info-set-read info range)
5332 (gnus-request-set-mark group (list (list range 'add '(read))))
5333 ;; Then we have to re-compute how many unread
5334 ;; articles there are in this group.
5338 (setq num (- (1+ (cdr active)) (car active))))
5339 ((not (listp (cdr range)))
5340 (setq num (- (cdr active) (- (1+ (cdr range))
5344 (if (numberp (car range))
5346 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5347 (setq range (cdr range)))
5348 (setq num (- (cdr active) num))))
5349 ;; Update the number of unread articles.
5351 ;; Update the group buffer.
5352 (gnus-group-update-group group t)))))
5354 (defvar gnus-newsgroup-none-id 0)
5356 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5357 (let ((cur nntp-server-buffer)
5360 (save-excursion (set-buffer gnus-summary-buffer)
5361 gnus-newsgroup-dependencies)))
5363 (mail-parse-charset gnus-newsgroup-charset)
5364 (mail-parse-ignored-charsets
5365 (save-excursion (condition-case nil
5366 (set-buffer gnus-summary-buffer)
5368 gnus-newsgroup-ignored-charsets)))
5370 (set-buffer nntp-server-buffer)
5371 ;; Translate all TAB characters into SPACE characters.
5372 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5373 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5374 (gnus-run-hooks 'gnus-parse-headers-hook)
5375 (let ((case-fold-search t)
5376 in-reply-to header p lines chars ctype)
5377 (goto-char (point-min))
5378 ;; Search to the beginning of the next header. Error messages
5379 ;; do not begin with 2 or 3.
5380 (while (re-search-forward "^[23][0-9]+ " nil t)
5383 ;; This implementation of this function, with nine
5384 ;; search-forwards instead of the one re-search-forward and
5385 ;; a case (which basically was the old function) is actually
5386 ;; about twice as fast, even though it looks messier. You
5387 ;; can't have everything, I guess. Speed and elegance
5388 ;; doesn't always go hand in hand.
5391 (make-full-mail-header
5397 (narrow-to-region (point)
5398 (or (and (search-forward "\n.\n" nil t)
5404 (if (search-forward "\nsubject:" nil t)
5405 (nnheader-header-value)
5410 (if (search-forward "\nfrom:" nil t)
5411 (nnheader-header-value)
5416 (if (search-forward "\ndate:" nil t)
5417 (nnheader-header-value) ""))
5421 (setq id (if (re-search-forward
5422 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5423 ;; We do it this way to make sure the Message-ID
5424 ;; is (somewhat) syntactically valid.
5425 (buffer-substring (match-beginning 1)
5427 ;; If there was no message-id, we just fake one
5428 ;; to make subsequent routines simpler.
5429 (nnheader-generate-fake-message-id))))
5433 (if (search-forward "\nreferences:" nil t)
5437 (nnheader-header-value)
5442 (search-backward ">" end t)
5445 (search-backward "<" end t)
5447 ;; Get the references from the in-reply-to header if there
5448 ;; were no references and the in-reply-to header looks
5450 (if (and (search-forward "\nin-reply-to:" nil t)
5451 (setq in-reply-to (nnheader-header-value))
5452 (string-match "<[^>]+>" in-reply-to))
5454 (setq ref (substring in-reply-to (match-beginning 0)
5456 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5457 (setq ref2 (substring in-reply-to (match-beginning 0)
5459 (when (> (length ref2) (length ref))
5466 (if (search-forward "\nchars: " nil t)
5467 (if (numberp (setq chars (ignore-errors (read cur))))
5473 (if (search-forward "\nlines: " nil t)
5474 (if (numberp (setq lines (ignore-errors (read cur))))
5480 (and (search-forward "\nxref:" nil t)
5481 (nnheader-header-value)))
5483 (when gnus-extra-headers
5484 (let ((extra gnus-extra-headers)
5488 (when (search-forward
5489 (concat "\n" (symbol-name (car extra)) ":") nil t)
5490 (push (cons (car extra) (nnheader-header-value)) out))
5494 (if (and (search-forward "\ncontent-type: " nil t)
5495 (setq ctype (nnheader-header-value)))
5496 (mime-entity-set-content-type-internal
5497 header (mime-parse-Content-Type ctype)))
5498 (when (equal id ref)
5501 (when gnus-alter-header-function
5502 (funcall gnus-alter-header-function header)
5503 (setq id (mail-header-id header)
5504 ref (gnus-parent-id (mail-header-references header))))
5507 (gnus-dependencies-add-header
5508 header dependencies force-new))
5509 (push header headers))
5510 (goto-char (point-max))
5512 (nreverse headers)))))
5514 ;; Goes through the xover lines and returns a list of vectors
5515 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5516 force-new dependencies
5517 group also-fetch-heads)
5518 "Parse the news overview data in the server buffer.
5519 Return a list of headers that match SEQUENCE (see
5520 `nntp-retrieve-headers')."
5521 ;; Get the Xref when the users reads the articles since most/some
5522 ;; NNTP servers do not include Xrefs when using XOVER.
5523 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5524 (let ((mail-parse-charset gnus-newsgroup-charset)
5525 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5526 (cur nntp-server-buffer)
5527 (dependencies (or dependencies gnus-newsgroup-dependencies))
5529 ((eq gnus-read-all-available-headers t)
5531 ((stringp gnus-read-all-available-headers)
5532 (string-match gnus-read-all-available-headers group))
5535 number headers header)
5537 (set-buffer nntp-server-buffer)
5538 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5539 ;; Allow the user to mangle the headers before parsing them.
5540 (gnus-run-hooks 'gnus-parse-headers-hook)
5541 (goto-char (point-min))
5542 (gnus-parse-without-error
5543 (while (and (or sequence allp)
5545 (setq number (read cur))
5547 (while (and sequence
5548 (< (car sequence) number))
5549 (setq sequence (cdr sequence))))
5552 (eq number (car sequence))))
5554 (setq sequence (cdr sequence))
5555 (setq header (inline
5556 (gnus-nov-parse-line
5557 number dependencies force-new)))))
5558 (push header headers))
5560 ;; A common bug in inn is that if you have posted an article and
5561 ;; then retrieves the active file, it will answer correctly --
5562 ;; the new article is included. However, a NOV entry for the
5563 ;; article may not have been generated yet, so this may fail.
5564 ;; We work around this problem by retrieving the last few
5565 ;; headers using HEAD.
5566 (if (or (not also-fetch-heads)
5568 ;; We (probably) got all the headers.
5570 (let ((gnus-nov-is-evil t))
5573 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5574 (gnus-get-newsgroup-headers))))))))
5576 (defun gnus-article-get-xrefs ()
5577 "Fill in the Xref value in `gnus-current-headers', if necessary.
5578 This is meant to be called in `gnus-article-internal-prepare-hook'."
5579 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5580 gnus-current-headers)))
5581 (or (not gnus-use-cross-reference)
5583 (and (mail-header-xref headers)
5584 (not (string= (mail-header-xref headers) "")))
5585 (let ((case-fold-search t)
5588 (nnheader-narrow-to-headers)
5589 (goto-char (point-min))
5590 (when (or (and (not (eobp))
5591 (eq (downcase (char-after)) ?x)
5592 (looking-at "Xref:"))
5593 (search-forward "\nXref:" nil t))
5594 (goto-char (1+ (match-end 0)))
5595 (setq xref (buffer-substring (point)
5596 (progn (end-of-line) (point))))
5597 (mail-header-set-xref headers xref)))))))
5599 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5600 "Find article ID and insert the summary line for that article.
5601 OLD-HEADER can either be a header or a line number to insert
5602 the subject line on."
5603 (let* ((line (and (numberp old-header) old-header))
5604 (old-header (and (vectorp old-header) old-header))
5605 (header (cond ((and old-header use-old-header)
5608 (gnus-number-to-header id))
5609 (gnus-number-to-header id))
5611 (gnus-read-header id))))
5612 (number (and (numberp id) id))
5615 ;; Rebuild the thread that this article is part of and go to the
5616 ;; article we have fetched.
5617 (when (and (not gnus-show-threads)
5620 (setq d (gnus-data-find (mail-header-number old-header))))
5621 (goto-char (gnus-data-pos d))
5624 (- (gnus-point-at-bol)
5626 (1+ (gnus-point-at-eol))
5627 (gnus-delete-line))))))
5629 (mail-header-set-number header (mail-header-number old-header)))
5630 (setq gnus-newsgroup-sparse
5631 (delq (setq number (mail-header-number header))
5632 gnus-newsgroup-sparse))
5633 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5634 (push number gnus-newsgroup-limit)
5635 (gnus-rebuild-thread (mail-header-id header) line)
5636 (gnus-summary-goto-subject number nil t))
5637 (when (and (numberp number)
5639 ;; We have to update the boundaries even if we can't fetch the
5640 ;; article if ID is a number -- so that the next `P' or `N'
5641 ;; command will fetch the previous (or next) article even
5642 ;; if the one we tried to fetch this time has been canceled.
5643 (when (> number gnus-newsgroup-end)
5644 (setq gnus-newsgroup-end number))
5645 (when (< number gnus-newsgroup-begin)
5646 (setq gnus-newsgroup-begin number))
5647 (setq gnus-newsgroup-unselected
5648 (delq number gnus-newsgroup-unselected)))
5649 ;; Report back a success?
5650 (and header (mail-header-number header))))
5652 ;;; Process/prefix in the summary buffer
5654 (defun gnus-summary-work-articles (n)
5655 "Return a list of articles to be worked upon.
5656 The prefix argument, the list of process marked articles, and the
5657 current article will be taken into consideration."
5659 (set-buffer gnus-summary-buffer)
5662 ;; A numerical prefix has been given.
5663 (setq n (prefix-numeric-value n))
5664 (let ((backward (< n 0))
5665 (n (abs (prefix-numeric-value n)))
5670 (push (setq article (gnus-summary-article-number))
5673 (gnus-summary-find-prev nil article)
5674 (gnus-summary-find-next nil article)))
5676 (nreverse articles)))
5677 ((and (gnus-region-active-p) (mark))
5678 (message "region active")
5679 ;; Work on the region between point and mark.
5680 (let ((max (max (point) (mark)))
5683 (goto-char (min (point) (mark)))
5686 (push (setq article (gnus-summary-article-number)) articles)
5687 (gnus-summary-find-next nil article)
5689 (nreverse articles))))
5690 (gnus-newsgroup-processable
5691 ;; There are process-marked articles present.
5692 ;; Save current state.
5693 (gnus-summary-save-process-mark)
5695 (reverse gnus-newsgroup-processable))
5697 ;; Just return the current article.
5698 (list (gnus-summary-article-number))))))
5700 (defmacro gnus-summary-iterate (arg &rest forms)
5701 "Iterate over the process/prefixed articles and do FORMS.
5702 ARG is the interactive prefix given to the command. FORMS will be
5703 executed with point over the summary line of the articles."
5704 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5705 `(let ((,articles (gnus-summary-work-articles ,arg)))
5707 (gnus-summary-goto-subject (car ,articles))
5711 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5712 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5714 (defun gnus-summary-save-process-mark ()
5715 "Push the current set of process marked articles on the stack."
5717 (push (copy-sequence gnus-newsgroup-processable)
5718 gnus-newsgroup-process-stack))
5720 (defun gnus-summary-kill-process-mark ()
5721 "Push the current set of process marked articles on the stack and unmark."
5723 (gnus-summary-save-process-mark)
5724 (gnus-summary-unmark-all-processable))
5726 (defun gnus-summary-yank-process-mark ()
5727 "Pop the last process mark state off the stack and restore it."
5729 (unless gnus-newsgroup-process-stack
5730 (error "Empty mark stack"))
5731 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5733 (defun gnus-summary-process-mark-set (set)
5734 "Make SET into the current process marked articles."
5735 (gnus-summary-unmark-all-processable)
5737 (gnus-summary-set-process-mark (pop set))))
5739 ;;; Searching and stuff
5741 (defun gnus-summary-search-group (&optional backward use-level)
5742 "Search for next unread newsgroup.
5743 If optional argument BACKWARD is non-nil, search backward instead."
5745 (set-buffer gnus-group-buffer)
5746 (when (gnus-group-search-forward
5747 backward nil (if use-level (gnus-group-group-level) nil))
5748 (gnus-group-group-name))))
5750 (defun gnus-summary-best-group (&optional exclude-group)
5751 "Find the name of the best unread group.
5752 If EXCLUDE-GROUP, do not go to this group."
5754 (set-buffer gnus-group-buffer)
5756 (gnus-group-best-unread-group exclude-group))))
5758 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5759 (if backward (gnus-summary-find-prev)
5760 (let* ((dummy (gnus-summary-article-intangible-p))
5761 (article (or article (gnus-summary-article-number)))
5762 (arts (gnus-data-find-list article))
5764 (when (and (not dummy)
5765 (or (not gnus-summary-check-current)
5767 (not (gnus-data-unread-p (car arts)))))
5768 (setq arts (cdr arts)))
5773 (when (or (and undownloaded
5774 (eq gnus-undownloaded-mark
5775 (gnus-data-mark (car arts))))
5776 (gnus-data-unread-p (car arts)))
5777 (setq result (car arts)
5779 (setq arts (cdr arts)))
5782 (goto-char (gnus-data-pos result))
5783 (gnus-data-number result)))))
5785 (defun gnus-summary-find-prev (&optional unread article)
5786 (let* ((eobp (eobp))
5787 (article (or article (gnus-summary-article-number)))
5788 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5790 (when (and (not eobp)
5791 (or (not gnus-summary-check-current)
5793 (not (gnus-data-unread-p (car arts)))))
5794 (setq arts (cdr arts)))
5799 (when (gnus-data-unread-p (car arts))
5800 (setq result (car arts)
5802 (setq arts (cdr arts)))
5805 (goto-char (gnus-data-pos result))
5806 (gnus-data-number result))))
5808 (defun gnus-summary-find-subject (subject &optional unread backward article)
5809 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5810 (article (or article (gnus-summary-article-number)))
5811 (articles (gnus-data-list backward))
5812 (arts (gnus-data-find-list article articles))
5814 (when (or (not gnus-summary-check-current)
5816 (not (gnus-data-unread-p (car arts))))
5817 (setq arts (cdr arts)))
5819 (and (or (not unread)
5820 (gnus-data-unread-p (car arts)))
5821 (vectorp (gnus-data-header (car arts)))
5823 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5824 (setq result (car arts)
5826 (setq arts (cdr arts)))
5828 (goto-char (gnus-data-pos result))
5829 (gnus-data-number result))))
5831 (defun gnus-summary-search-forward (&optional unread subject backward)
5832 "Search forward for an article.
5833 If UNREAD, look for unread articles. If SUBJECT, look for
5834 articles with that subject. If BACKWARD, search backward instead."
5835 (cond (subject (gnus-summary-find-subject subject unread backward))
5836 (backward (gnus-summary-find-prev unread))
5837 (t (gnus-summary-find-next unread))))
5839 (defun gnus-recenter (&optional n)
5840 "Center point in window and redisplay frame.
5841 Also do horizontal recentering."
5843 (when (and gnus-auto-center-summary
5844 (not (eq gnus-auto-center-summary 'vertical)))
5845 (gnus-horizontal-recenter))
5848 (defun gnus-summary-recenter ()
5849 "Center point in the summary window.
5850 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5851 displayed, no centering will be performed."
5852 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5853 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5855 (let* ((top (cond ((< (window-height) 4) 0)
5856 ((< (window-height) 7) 1)
5857 (t (if (numberp gnus-auto-center-summary)
5858 gnus-auto-center-summary
5860 (height (1- (window-height)))
5861 (bottom (save-excursion (goto-char (point-max))
5862 (forward-line (- height))
5864 (window (get-buffer-window (current-buffer))))
5865 ;; The user has to want it.
5866 (when gnus-auto-center-summary
5867 (when (get-buffer-window gnus-article-buffer)
5868 ;; Only do recentering when the article buffer is displayed,
5869 ;; Set the window start to either `bottom', which is the biggest
5870 ;; possible valid number, or the second line from the top,
5871 ;; whichever is the least.
5872 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5873 (if (> bottom top-pos)
5874 ;; Keep the second line from the top visible
5875 (set-window-start window top-pos t)
5876 ;; Try to keep the bottom line visible; if it's partially
5877 ;; obscured, either scroll one more line to make it fully
5878 ;; visible, or revert to using TOP-POS.
5880 (goto-char (point-max))
5882 (let ((last-line-start (point)))
5884 (set-window-start window (point) t)
5885 (when (not (pos-visible-in-window-p last-line-start window))
5887 (set-window-start window (min (point) top-pos) t)))))))
5888 ;; Do horizontal recentering while we're at it.
5889 (when (and (get-buffer-window (current-buffer) t)
5890 (not (eq gnus-auto-center-summary 'vertical)))
5891 (let ((selected (selected-window)))
5892 (select-window (get-buffer-window (current-buffer) t))
5893 (gnus-summary-position-point)
5894 (gnus-horizontal-recenter)
5895 (select-window selected))))))
5897 (defun gnus-summary-jump-to-group (newsgroup)
5898 "Move point to NEWSGROUP in group mode buffer."
5899 ;; Keep update point of group mode buffer if visible.
5900 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5901 (save-window-excursion
5902 ;; Take care of tree window mode.
5903 (when (get-buffer-window gnus-group-buffer)
5904 (pop-to-buffer gnus-group-buffer))
5905 (gnus-group-jump-to-group newsgroup))
5907 ;; Take care of tree window mode.
5908 (if (get-buffer-window gnus-group-buffer)
5909 (pop-to-buffer gnus-group-buffer)
5910 (set-buffer gnus-group-buffer))
5911 (gnus-group-jump-to-group newsgroup))))
5913 ;; This function returns a list of article numbers based on the
5914 ;; difference between the ranges of read articles in this group and
5915 ;; the range of active articles.
5916 (defun gnus-list-of-unread-articles (group)
5917 (let* ((read (gnus-info-read (gnus-get-info group)))
5918 (active (or (gnus-active group) (gnus-activate-group group)))
5921 ;; If none are read, then all are unread.
5923 (setq first (car active))
5924 ;; If the range of read articles is a single range, then the
5925 ;; first unread article is the article after the last read
5926 ;; article. Sounds logical, doesn't it?
5927 (if (and (not (listp (cdr read)))
5928 (or (< (car read) (car active))
5929 (progn (setq read (list read))
5931 (setq first (max (car active) (1+ (cdr read))))
5932 ;; `read' is a list of ranges.
5933 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5936 (setq first (car active)))
5939 (while (< first nlast)
5941 (setq first (1+ first))))
5942 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5943 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5944 (setq read (cdr read)))))
5945 ;; And add the last unread articles.
5946 (while (<= first last)
5948 (setq first (1+ first)))
5949 ;; Return the list of unread articles.
5950 (delq 0 (nreverse unread))))
5952 (defun gnus-list-of-read-articles (group)
5953 "Return a list of unread, unticked and non-dormant articles."
5954 (let* ((info (gnus-get-info group))
5955 (marked (gnus-info-marks info))
5956 (active (gnus-active group)))
5958 (gnus-list-range-difference
5959 (gnus-list-range-difference
5960 (gnus-sorted-complement
5961 (gnus-uncompress-range active)
5962 (gnus-list-of-unread-articles group))
5963 (cdr (assq 'dormant marked)))
5964 (cdr (assq 'tick marked))))))
5966 ;; Various summary commands
5968 (defun gnus-summary-select-article-buffer ()
5969 "Reconfigure windows to show article buffer."
5971 (if (not (gnus-buffer-live-p gnus-article-buffer))
5972 (error "There is no article buffer for this summary buffer")
5973 (gnus-configure-windows 'article)
5974 (select-window (get-buffer-window gnus-article-buffer))))
5976 (defun gnus-summary-universal-argument (arg)
5977 "Perform any operation on all articles that are process/prefixed."
5979 (let ((articles (gnus-summary-work-articles arg))
5986 (substitute-command-keys
5987 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5989 (gnus-error 1 "Undefined key")
5992 (gnus-summary-goto-subject (setq article (pop articles)))
5993 (let (gnus-newsgroup-processable)
5994 (command-execute func))
5995 (gnus-summary-remove-process-mark article)))))
5996 (gnus-summary-position-point))
5998 (defun gnus-summary-toggle-truncation (&optional arg)
5999 "Toggle truncation of summary lines.
6000 With arg, turn line truncation on iff arg is positive."
6002 (setq truncate-lines
6003 (if (null arg) (not truncate-lines)
6004 (> (prefix-numeric-value arg) 0)))
6007 (defun gnus-summary-reselect-current-group (&optional all rescan)
6008 "Exit and then reselect the current newsgroup.
6009 The prefix argument ALL means to select all articles."
6011 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6012 (error "Ephemeral groups can't be reselected"))
6013 (let ((current-subject (gnus-summary-article-number))
6014 (group gnus-newsgroup-name))
6015 (setq gnus-newsgroup-begin nil)
6017 ;; We have to adjust the point of group mode buffer because
6018 ;; point was moved to the next unread newsgroup by exiting.
6019 (gnus-summary-jump-to-group group)
6022 (save-window-excursion
6023 ;; Don't show group contents.
6024 (set-window-start (selected-window) (point-max))
6025 (gnus-group-get-new-news-this-group 1))))
6026 (gnus-group-read-group all t)
6027 (gnus-summary-goto-subject current-subject nil t)))
6029 (defun gnus-summary-rescan-group (&optional all)
6030 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6032 (gnus-summary-reselect-current-group all t))
6034 (defun gnus-summary-update-info (&optional non-destructive)
6036 (let ((group gnus-newsgroup-name))
6038 (when gnus-newsgroup-kill-headers
6039 (setq gnus-newsgroup-killed
6040 (gnus-compress-sequence
6042 (gnus-list-range-intersection
6043 gnus-newsgroup-unselected gnus-newsgroup-killed)
6044 gnus-newsgroup-unreads)
6046 (unless (listp (cdr gnus-newsgroup-killed))
6047 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6048 (let ((headers gnus-newsgroup-headers))
6049 ;; Set the new ranges of read articles.
6051 (set-buffer gnus-group-buffer)
6052 (gnus-undo-force-boundary))
6053 (gnus-update-read-articles
6054 group (gnus-sorted-union
6055 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6056 ;; Set the current article marks.
6057 (let ((gnus-newsgroup-scored
6058 (if (and (not gnus-save-score)
6059 (not non-destructive))
6061 gnus-newsgroup-scored)))
6063 (gnus-update-marks)))
6064 ;; Do the cross-ref thing.
6065 (when gnus-use-cross-reference
6066 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6067 ;; Do not switch windows but change the buffer to work.
6068 (set-buffer gnus-group-buffer)
6069 (unless (gnus-ephemeral-group-p group)
6070 (gnus-group-update-group group)))))))
6072 (defun gnus-summary-save-newsrc (&optional force)
6073 "Save the current number of read/marked articles in the dribble buffer.
6074 The dribble buffer will then be saved.
6075 If FORCE (the prefix), also save the .newsrc file(s)."
6077 (gnus-summary-update-info t)
6079 (gnus-save-newsrc-file)
6080 (gnus-dribble-save)))
6082 (defun gnus-summary-exit (&optional temporary)
6083 "Exit reading current newsgroup, and then return to group selection mode.
6084 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6086 (gnus-set-global-variables)
6087 (gnus-kill-save-kill-buffer)
6088 (gnus-async-halt-prefetch)
6089 (let* ((group gnus-newsgroup-name)
6090 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6093 (buf (current-buffer)))
6095 ;; Do adaptive scoring, and possibly save score files.
6096 (when gnus-newsgroup-adaptive
6097 (gnus-score-adaptive))
6098 (when gnus-use-scoring
6100 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6101 ;; If we have several article buffers, we kill them at exit.
6102 (unless gnus-single-article-buffer
6103 (gnus-kill-buffer gnus-original-article-buffer)
6104 (setq gnus-article-current nil))
6105 (when gnus-use-cache
6106 (gnus-cache-possibly-remove-articles)
6107 (gnus-cache-save-buffers))
6108 (gnus-async-prefetch-remove-group group)
6109 (when gnus-suppress-duplicates
6110 (gnus-dup-enter-articles))
6111 (when gnus-use-trees
6112 (gnus-tree-close group))
6113 (when gnus-use-cache
6114 (gnus-cache-write-active))
6115 ;; Remove entries for this group.
6116 (nnmail-purge-split-history (gnus-group-real-name group))
6117 ;; Make all changes in this group permanent.
6119 (gnus-run-hooks 'gnus-exit-group-hook)
6120 (gnus-summary-update-info))
6121 (gnus-close-group group)
6122 ;; Make sure where we were, and go to next newsgroup.
6123 (set-buffer gnus-group-buffer)
6125 (gnus-group-jump-to-group group))
6126 (gnus-run-hooks 'gnus-summary-exit-hook)
6127 (unless (or quit-config
6128 ;; If this group has disappeared from the summary
6129 ;; buffer, don't skip forwards.
6130 (not (string= group (gnus-group-group-name))))
6131 (gnus-group-next-unread-group 1))
6132 (setq group-point (point))
6135 ;; If we have several article buffers, we kill them at exit.
6136 (unless gnus-single-article-buffer
6137 (gnus-kill-buffer gnus-article-buffer)
6138 (gnus-kill-buffer gnus-original-article-buffer)
6139 (setq gnus-article-current nil))
6141 (if (not gnus-kill-summary-on-exit)
6143 (gnus-deaden-summary)
6145 ;; We set all buffer-local variables to nil. It is unclear why
6146 ;; this is needed, but if we don't, buffer-local variables are
6147 ;; not garbage-collected, it seems. This would the lead to en
6148 ;; ever-growing Emacs.
6149 (gnus-summary-clear-local-variables)
6150 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6151 (gnus-summary-clear-local-variables))
6152 (when (get-buffer gnus-article-buffer)
6153 (bury-buffer gnus-article-buffer))
6154 ;; We clear the global counterparts of the buffer-local
6155 ;; variables as well, just to be on the safe side.
6156 (set-buffer gnus-group-buffer)
6157 (gnus-summary-clear-local-variables)
6158 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6159 (gnus-summary-clear-local-variables)))
6160 (setq gnus-current-select-method gnus-select-method)
6161 (pop-to-buffer gnus-group-buffer)
6162 (if (not quit-config)
6164 (goto-char group-point)
6165 (gnus-configure-windows 'group 'force)
6166 (unless (pos-visible-in-window-p)
6167 (forward-line (/ (static-if (featurep 'xemacs)
6168 (window-displayed-height)
6169 (1- (window-height)))
6171 (set-window-start (selected-window) (point))
6172 (goto-char group-point)))
6173 (gnus-handle-ephemeral-exit quit-config))
6174 ;; Return to group mode buffer.
6175 (when (eq mode 'gnus-summary-mode)
6176 (gnus-kill-buffer buf))
6177 ;; Clear the current group name.
6179 (setq gnus-newsgroup-name nil)))))
6181 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6182 (defun gnus-summary-exit-no-update (&optional no-questions)
6183 "Quit reading current newsgroup without updating read article info."
6185 (let* ((group gnus-newsgroup-name)
6186 (quit-config (gnus-group-quit-config group)))
6187 (when (or no-questions
6189 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6190 (gnus-async-halt-prefetch)
6192 (delq 'gnus-summary-expire-articles
6193 (copy-sequence gnus-summary-prepare-exit-hook)))
6194 ;; If we have several article buffers, we kill them at exit.
6195 (unless gnus-single-article-buffer
6196 (gnus-kill-buffer gnus-article-buffer)
6197 (gnus-kill-buffer gnus-original-article-buffer)
6198 (setq gnus-article-current nil))
6199 (if (not gnus-kill-summary-on-exit)
6200 (gnus-deaden-summary)
6201 (gnus-close-group group)
6202 (gnus-summary-clear-local-variables)
6203 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6204 (gnus-summary-clear-local-variables))
6205 (set-buffer gnus-group-buffer)
6206 (gnus-summary-clear-local-variables)
6207 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6208 (gnus-summary-clear-local-variables))
6209 (when (get-buffer gnus-summary-buffer)
6210 (kill-buffer gnus-summary-buffer)))
6211 (unless gnus-single-article-buffer
6212 (setq gnus-article-current nil))
6213 (when gnus-use-trees
6214 (gnus-tree-close group))
6215 (gnus-async-prefetch-remove-group group)
6216 (when (get-buffer gnus-article-buffer)
6217 (bury-buffer gnus-article-buffer))
6218 ;; Return to the group buffer.
6219 (gnus-configure-windows 'group 'force)
6220 ;; Clear the current group name.
6221 (setq gnus-newsgroup-name nil)
6222 (when (equal (gnus-group-group-name) group)
6223 (gnus-group-next-unread-group 1))
6225 (gnus-handle-ephemeral-exit quit-config)))))
6227 (defun gnus-handle-ephemeral-exit (quit-config)
6228 "Handle movement when leaving an ephemeral group.
6229 The state which existed when entering the ephemeral is reset."
6230 (if (not (buffer-name (car quit-config)))
6231 (gnus-configure-windows 'group 'force)
6232 (set-buffer (car quit-config))
6233 (cond ((eq major-mode 'gnus-summary-mode)
6234 (gnus-set-global-variables))
6235 ((eq major-mode 'gnus-article-mode)
6237 ;; The `gnus-summary-buffer' variable may point
6238 ;; to the old summary buffer when using a single
6240 (unless (gnus-buffer-live-p gnus-summary-buffer)
6241 (set-buffer gnus-group-buffer))
6242 (set-buffer gnus-summary-buffer)
6243 (gnus-set-global-variables))))
6244 (if (or (eq (cdr quit-config) 'article)
6245 (eq (cdr quit-config) 'pick))
6247 ;; The current article may be from the ephemeral group
6248 ;; thus it is best that we reload this article
6249 (gnus-summary-show-article)
6250 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6251 (gnus-configure-windows 'pick 'force)
6252 (gnus-configure-windows (cdr quit-config) 'force)))
6253 (gnus-configure-windows (cdr quit-config) 'force))
6254 (when (eq major-mode 'gnus-summary-mode)
6255 (gnus-summary-next-subject 1 nil t)
6256 (gnus-summary-recenter)
6257 (gnus-summary-position-point))))
6259 (defun gnus-summary-preview-mime-message ()
6260 "MIME decode and play this message."
6262 (let ((gnus-break-pages nil)
6264 (gnus-summary-select-article gnus-show-all-headers t))
6265 (let ((w (get-buffer-window gnus-article-buffer)))
6267 (select-window (get-buffer-window gnus-article-buffer)))))
6271 (defvar gnus-dead-summary-mode-map nil)
6273 (unless gnus-dead-summary-mode-map
6274 (setq gnus-dead-summary-mode-map (make-keymap))
6275 (suppress-keymap gnus-dead-summary-mode-map)
6276 (substitute-key-definition
6277 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6278 (dolist (key '("\C-d" "\r" "\177" [delete]))
6279 (define-key gnus-dead-summary-mode-map
6280 key 'gnus-summary-wake-up-the-dead))
6281 (dolist (key '("q" "Q"))
6282 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6284 (defvar gnus-dead-summary-mode nil
6285 "Minor mode for Gnus summary buffers.")
6287 (defun gnus-dead-summary-mode (&optional arg)
6288 "Minor mode for Gnus summary buffers."
6290 (when (eq major-mode 'gnus-summary-mode)
6291 (make-local-variable 'gnus-dead-summary-mode)
6292 (setq gnus-dead-summary-mode
6293 (if (null arg) (not gnus-dead-summary-mode)
6294 (> (prefix-numeric-value arg) 0)))
6295 (when gnus-dead-summary-mode
6296 (gnus-add-minor-mode
6297 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6299 (defun gnus-deaden-summary ()
6300 "Make the current summary buffer into a dead summary buffer."
6301 ;; Kill any previous dead summary buffer.
6302 (when (and gnus-dead-summary
6303 (buffer-name gnus-dead-summary))
6305 (set-buffer gnus-dead-summary)
6306 (when gnus-dead-summary-mode
6307 (kill-buffer (current-buffer)))))
6308 ;; Make this the current dead summary.
6309 (setq gnus-dead-summary (current-buffer))
6310 (gnus-dead-summary-mode 1)
6311 (let ((name (buffer-name)))
6312 (when (string-match "Summary" name)
6314 (concat (substring name 0 (match-beginning 0)) "Dead "
6315 (substring name (match-beginning 0)))
6319 (defun gnus-kill-or-deaden-summary (buffer)
6320 "Kill or deaden the summary BUFFER."
6322 (when (and (buffer-name buffer)
6323 (not gnus-single-article-buffer))
6326 (gnus-kill-buffer gnus-article-buffer)
6327 (gnus-kill-buffer gnus-original-article-buffer)))
6330 (gnus-kill-summary-on-exit
6331 (when (and gnus-use-trees
6332 (gnus-buffer-exists-p buffer))
6335 (gnus-tree-close gnus-newsgroup-name)))
6336 (gnus-kill-buffer buffer))
6337 ;; Deaden the buffer.
6338 ((gnus-buffer-exists-p buffer)
6341 (gnus-deaden-summary))))))
6343 (defun gnus-summary-wake-up-the-dead (&rest args)
6344 "Wake up the dead summary buffer."
6346 (gnus-dead-summary-mode -1)
6347 (let ((name (buffer-name)))
6348 (when (string-match "Dead " name)
6350 (concat (substring name 0 (match-beginning 0))
6351 (substring name (match-end 0)))
6353 (gnus-message 3 "This dead summary is now alive again"))
6355 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6356 (defun gnus-summary-fetch-faq (&optional faq-dir)
6357 "Fetch the FAQ for the current group.
6358 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6362 (when current-prefix-arg
6364 "Faq dir: " (and (listp gnus-group-faq-directory)
6365 (mapcar (lambda (file) (list file))
6366 gnus-group-faq-directory))))))
6367 (let (gnus-faq-buffer)
6368 (when (setq gnus-faq-buffer
6369 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6370 (gnus-configure-windows 'summary-faq))))
6372 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6373 (defun gnus-summary-describe-group (&optional force)
6374 "Describe the current newsgroup."
6376 (gnus-group-describe-group force gnus-newsgroup-name))
6378 (defun gnus-summary-describe-briefly ()
6379 "Describe summary mode commands briefly."
6381 (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")))
6383 ;; Walking around group mode buffer from summary mode.
6385 (defun gnus-summary-next-group (&optional no-article target-group backward)
6386 "Exit current newsgroup and then select next unread newsgroup.
6387 If prefix argument NO-ARTICLE is non-nil, no article is selected
6388 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6389 previous group instead."
6391 ;; Stop pre-fetching.
6392 (gnus-async-halt-prefetch)
6393 (let ((current-group gnus-newsgroup-name)
6394 (current-buffer (current-buffer))
6396 ;; First we semi-exit this group to update Xrefs and all variables.
6397 ;; We can't do a real exit, because the window conf must remain
6398 ;; the same in case the user is prompted for info, and we don't
6399 ;; want the window conf to change before that...
6400 (gnus-summary-exit t)
6401 (while (not entered)
6402 ;; Then we find what group we are supposed to enter.
6403 (set-buffer gnus-group-buffer)
6404 (gnus-group-jump-to-group current-group)
6407 (if (eq gnus-keep-same-level 'best)
6408 (gnus-summary-best-group gnus-newsgroup-name)
6409 (gnus-summary-search-group backward gnus-keep-same-level))))
6410 (if (not target-group)
6411 ;; There are no further groups, so we return to the group
6414 (gnus-message 5 "Returning to the group buffer")
6416 (when (gnus-buffer-live-p current-buffer)
6417 (set-buffer current-buffer)
6418 (gnus-summary-exit))
6419 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6420 ;; We try to enter the target group.
6421 (gnus-group-jump-to-group target-group)
6422 (let ((unreads (gnus-group-group-unread)))
6423 (if (and (or (eq t unreads)
6424 (and unreads (not (zerop unreads))))
6425 (gnus-summary-read-group
6426 target-group nil no-article
6427 (and (buffer-name current-buffer) current-buffer)
6430 (setq current-group target-group
6431 target-group nil)))))))
6433 (defun gnus-summary-prev-group (&optional no-article)
6434 "Exit current newsgroup and then select previous unread newsgroup.
6435 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6437 (gnus-summary-next-group no-article nil t))
6439 ;; Walking around summary lines.
6441 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6442 "Go to the first unread subject.
6443 If UNREAD is non-nil, go to the first unread article.
6444 Returns the article selected or nil if there are no unread articles."
6449 ((null gnus-newsgroup-data)
6450 (gnus-message 3 "No articles in the group")
6452 ;; Pick the first article.
6454 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6455 (gnus-data-number (car gnus-newsgroup-data)))
6456 ;; No unread articles.
6457 ((null gnus-newsgroup-unreads)
6458 (gnus-message 3 "No more unread articles")
6460 ;; Find the first unread article.
6462 (let ((data gnus-newsgroup-data))
6464 (and (not (and undownloaded
6465 (eq gnus-undownloaded-mark
6466 (gnus-data-mark (car data)))))
6469 (gnus-data-number (car data))
6470 gnus-newsgroup-unseen))
6471 (not (gnus-data-unread-p (car data))))
6472 (not (gnus-data-unread-p (car data))))))
6473 (setq data (cdr data)))
6475 (goto-char (gnus-data-pos (car data)))
6476 (gnus-data-number (car data))))))
6477 (gnus-summary-position-point)))
6479 (defun gnus-summary-next-subject (n &optional unread dont-display)
6480 "Go to next N'th summary line.
6481 If N is negative, go to the previous N'th subject line.
6482 If UNREAD is non-nil, only unread articles are selected.
6483 The difference between N and the actual number of steps taken is
6486 (let ((backward (< n 0))
6490 (gnus-summary-find-prev unread)
6491 (gnus-summary-find-next unread)))
6492 (unless (zerop (setq n (1- n)))
6493 (gnus-summary-show-thread)))
6495 (gnus-message 7 "No more%s articles"
6496 (if unread " unread" "")))
6497 (unless dont-display
6498 (gnus-summary-recenter)
6499 (gnus-summary-position-point))
6502 (defun gnus-summary-next-unread-subject (n)
6503 "Go to next N'th unread summary line."
6505 (gnus-summary-next-subject n t))
6507 (defun gnus-summary-prev-subject (n &optional unread)
6508 "Go to previous N'th summary line.
6509 If optional argument UNREAD is non-nil, only unread article is selected."
6511 (gnus-summary-next-subject (- n) unread))
6513 (defun gnus-summary-prev-unread-subject (n)
6514 "Go to previous N'th unread summary line."
6516 (gnus-summary-next-subject (- n) t))
6518 (defun gnus-summary-goto-subject (article &optional force silent)
6519 "Go the subject line of ARTICLE.
6520 If FORCE, also allow jumping to articles not currently shown."
6521 (interactive "nArticle number: ")
6522 (unless (numberp article)
6523 (error "Article %s is not a number" article))
6525 (data (gnus-data-find article)))
6526 ;; We read in the article if we have to.
6529 (gnus-summary-insert-subject
6531 (if (or (numberp force) (vectorp force)) force)
6533 (setq data (gnus-data-find article)))
6538 (gnus-message 3 "Can't find article %d" article))
6540 (let ((pt (gnus-data-pos data)))
6542 (gnus-summary-set-article-display-arrow pt))
6543 (gnus-summary-position-point)
6546 ;; Walking around summary lines with displaying articles.
6548 (defun gnus-summary-expand-window (&optional arg)
6549 "Make the summary buffer take up the entire Emacs frame.
6550 Given a prefix, will force an `article' buffer configuration."
6553 (gnus-configure-windows 'article 'force)
6554 (gnus-configure-windows 'summary 'force)))
6556 (defun gnus-summary-display-article (article &optional all-header)
6557 "Display ARTICLE in article buffer."
6558 (when (gnus-buffer-live-p gnus-article-buffer)
6559 (with-current-buffer gnus-article-buffer
6560 (set-buffer-multibyte t)))
6561 (gnus-set-global-variables)
6562 (when (gnus-buffer-live-p gnus-article-buffer)
6563 (with-current-buffer gnus-article-buffer
6564 (setq gnus-article-charset gnus-newsgroup-charset)
6565 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6566 (set-buffer-multibyte t)))
6570 (if gnus-summary-display-article-function
6571 (funcall gnus-summary-display-article-function article all-header)
6572 (gnus-article-prepare article all-header))
6573 (with-current-buffer gnus-article-buffer
6574 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6576 (gnus-run-hooks 'gnus-select-article-hook)
6577 (when (and gnus-current-article
6578 (not (zerop gnus-current-article)))
6579 (gnus-summary-goto-subject gnus-current-article))
6580 (gnus-summary-recenter)
6581 (when (and gnus-use-trees gnus-show-threads)
6582 (gnus-possibly-generate-tree article)
6583 (gnus-highlight-selected-tree article))
6584 ;; Successfully display article.
6585 (gnus-article-set-window-start
6586 (cdr (assq article gnus-newsgroup-bookmarks))))))
6588 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6589 "Select the current article.
6590 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6591 non-nil, the article will be re-fetched even if it already present in
6592 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6594 ;; Make sure we are in the summary buffer to work around bbdb bug.
6595 (unless (eq major-mode 'gnus-summary-mode)
6596 (set-buffer gnus-summary-buffer))
6597 (let ((article (or article (gnus-summary-article-number)))
6598 (all-headers (not (not all-headers))) ;Must be T or NIL.
6599 gnus-summary-display-article-function)
6601 (gnus-summary-article-pseudo-p article)
6602 (error "This is a pseudo-article"))
6604 (set-buffer gnus-summary-buffer)
6605 (if (or (and gnus-single-article-buffer
6606 (or (null gnus-current-article)
6607 (null gnus-article-current)
6608 (null (get-buffer gnus-article-buffer))
6609 (not (eq article (cdr gnus-article-current)))
6610 (not (equal (car gnus-article-current)
6611 gnus-newsgroup-name))))
6612 (and (not gnus-single-article-buffer)
6613 (or (null gnus-current-article)
6614 (not (eq gnus-current-article article))))
6616 ;; The requested article is different from the current article.
6618 (gnus-summary-display-article article all-headers)
6619 ;;; Hidden headers are not hidden text any more.
6620 ;; (when (or all-headers gnus-show-all-headers)
6621 ;; (gnus-article-show-all-headers))
6622 (gnus-article-set-window-start
6623 (cdr (assq article gnus-newsgroup-bookmarks)))
6625 ;; (when (or all-headers gnus-show-all-headers)
6626 ;; (gnus-article-show-all-headers))
6629 (defun gnus-summary-force-verify-and-decrypt ()
6631 (let ((mm-verify-option 'known)
6632 (mm-decrypt-option 'known))
6633 (gnus-summary-select-article nil 'force)))
6635 (defun gnus-summary-set-current-mark (&optional current-mark)
6636 "Obsolete function."
6639 (defun gnus-summary-next-article (&optional unread subject backward push)
6640 "Select the next article.
6641 If UNREAD, only unread articles are selected.
6642 If SUBJECT, only articles with SUBJECT are selected.
6643 If BACKWARD, the previous article is selected instead of the next."
6646 ;; Is there such an article?
6647 ((and (gnus-summary-search-forward unread subject backward)
6648 (or (gnus-summary-display-article (gnus-summary-article-number))
6649 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6650 (gnus-summary-position-point))
6651 ;; If not, we try the first unread, if that is wanted.
6653 gnus-auto-select-same
6654 (gnus-summary-first-unread-article))
6655 (gnus-summary-position-point)
6656 (gnus-message 6 "Wrapped"))
6657 ;; Try to get next/previous article not displayed in this group.
6658 ((and gnus-auto-extend-newsgroup
6659 (not unread) (not subject))
6660 (gnus-summary-goto-article
6661 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6662 nil (count-lines (point-min) (point))))
6663 ;; Go to next/previous group.
6665 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6666 (gnus-summary-jump-to-group gnus-newsgroup-name))
6667 (let ((cmd last-command-char)
6670 (set-buffer gnus-group-buffer)
6673 (if (eq gnus-keep-same-level 'best)
6674 (gnus-summary-best-group gnus-newsgroup-name)
6675 (gnus-summary-search-group backward gnus-keep-same-level))))
6676 ;; For some reason, the group window gets selected. We change
6678 (select-window (get-buffer-window (current-buffer)))
6679 ;; Select next unread newsgroup automagically.
6681 ((or (not gnus-auto-select-next)
6683 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6684 ((or (eq gnus-auto-select-next 'quietly)
6685 (and (eq gnus-auto-select-next 'slightly-quietly)
6687 (and (eq gnus-auto-select-next 'almost-quietly)
6688 (gnus-summary-last-article-p)))
6690 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6692 (gnus-message 7 "No more%s articles (%s)..."
6693 (if unread " unread" "")
6694 (if group (concat "selecting " group)
6696 (gnus-summary-next-group nil group backward)))
6698 (when (gnus-key-press-event-p last-input-event)
6699 (gnus-summary-walk-group-buffer
6700 gnus-newsgroup-name cmd unread backward point))))))))
6702 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6703 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6704 (?\C-p (gnus-group-prev-unread-group 1))))
6705 (cursor-in-echo-area t)
6706 keve key group ended)
6708 (set-buffer gnus-group-buffer)
6711 (if (eq gnus-keep-same-level 'best)
6712 (gnus-summary-best-group gnus-newsgroup-name)
6713 (gnus-summary-search-group backward gnus-keep-same-level))))
6716 5 "No more%s articles%s" (if unread " unread" "")
6718 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6719 (format " (Type %s for %s [%s])"
6720 (single-key-description cmd) group
6721 (car (gnus-gethash group gnus-newsrc-hashtb)))
6722 (format " (Type %s to exit %s)"
6723 (single-key-description cmd)
6724 gnus-newsgroup-name)))
6725 ;; Confirm auto selection.
6726 (setq key (car (setq keve (gnus-read-event-char))))
6729 ((assq key keystrokes)
6730 (let ((obuf (current-buffer)))
6731 (switch-to-buffer gnus-group-buffer)
6733 (gnus-group-jump-to-group group))
6734 (eval (cadr (assq key keystrokes)))
6735 (setq group (gnus-group-group-name))
6736 (switch-to-buffer obuf))
6740 (gnus-ephemeral-group-p gnus-newsgroup-name))
6742 (gnus-summary-next-group nil group backward)))
6744 (push (cdr keve) unread-command-events))))))
6746 (defun gnus-summary-next-unread-article ()
6747 "Select unread article after current one."
6749 (gnus-summary-next-article
6750 (or (not (eq gnus-summary-goto-unread 'never))
6751 (gnus-summary-last-article-p (gnus-summary-article-number)))
6752 (and gnus-auto-select-same
6753 (gnus-summary-article-subject))))
6755 (defun gnus-summary-prev-article (&optional unread subject)
6756 "Select the article after the current one.
6757 If UNREAD is non-nil, only unread articles are selected."
6759 (gnus-summary-next-article unread subject t))
6761 (defun gnus-summary-prev-unread-article ()
6762 "Select unread article before current one."
6764 (gnus-summary-prev-article
6765 (or (not (eq gnus-summary-goto-unread 'never))
6766 (gnus-summary-first-article-p (gnus-summary-article-number)))
6767 (and gnus-auto-select-same
6768 (gnus-summary-article-subject))))
6770 (defun gnus-summary-next-page (&optional lines circular)
6771 "Show next page of the selected article.
6772 If at the end of the current article, select the next article.
6773 LINES says how many lines should be scrolled up.
6775 If CIRCULAR is non-nil, go to the start of the article instead of
6776 selecting the next article when reaching the end of the current
6779 (setq gnus-summary-buffer (current-buffer))
6780 (gnus-set-global-variables)
6781 (let ((article (gnus-summary-article-number))
6782 (article-window (get-buffer-window gnus-article-buffer t))
6784 ;; If the buffer is empty, we have no article.
6786 (error "No article to select"))
6787 (gnus-configure-windows 'article)
6788 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6789 (if (and (eq gnus-summary-goto-unread 'never)
6790 (not (gnus-summary-last-article-p article)))
6791 (gnus-summary-next-article)
6792 (gnus-summary-next-unread-article))
6793 (if (or (null gnus-current-article)
6794 (null gnus-article-current)
6795 (/= article (cdr gnus-article-current))
6796 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6797 ;; Selected subject is different from current article's.
6798 (gnus-summary-display-article article)
6799 (when article-window
6800 (gnus-eval-in-buffer-window gnus-article-buffer
6801 (setq endp (gnus-article-next-page lines)))
6804 (gnus-summary-beginning-of-article))
6806 (gnus-message 3 "End of message"))
6808 (if (and (eq gnus-summary-goto-unread 'never)
6809 (not (gnus-summary-last-article-p article)))
6810 (gnus-summary-next-article)
6811 (gnus-summary-next-unread-article))))))))
6812 (gnus-summary-recenter)
6813 (gnus-summary-position-point)))
6815 (defun gnus-summary-prev-page (&optional lines move)
6816 "Show previous page of selected article.
6817 Argument LINES specifies lines to be scrolled down.
6818 If MOVE, move to the previous unread article if point is at
6819 the beginning of the buffer."
6821 (let ((article (gnus-summary-article-number))
6822 (article-window (get-buffer-window gnus-article-buffer t))
6824 (gnus-configure-windows 'article)
6825 (if (or (null gnus-current-article)
6826 (null gnus-article-current)
6827 (/= article (cdr gnus-article-current))
6828 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6829 ;; Selected subject is different from current article's.
6830 (gnus-summary-display-article article)
6831 (gnus-summary-recenter)
6832 (when article-window
6833 (gnus-eval-in-buffer-window gnus-article-buffer
6834 (setq endp (gnus-article-prev-page lines)))
6835 (when (and move endp)
6837 (gnus-message 3 "Beginning of message"))
6839 (if (and (eq gnus-summary-goto-unread 'never)
6840 (not (gnus-summary-first-article-p article)))
6841 (gnus-summary-prev-article)
6842 (gnus-summary-prev-unread-article))))))))
6843 (gnus-summary-position-point))
6845 (defun gnus-summary-prev-page-or-article (&optional lines)
6846 "Show previous page of selected article.
6847 Argument LINES specifies lines to be scrolled down.
6848 If at the beginning of the article, go to the next article."
6850 (gnus-summary-prev-page lines t))
6852 (defun gnus-summary-scroll-up (lines)
6853 "Scroll up (or down) one line current article.
6854 Argument LINES specifies lines to be scrolled up (or down if negative)."
6856 (gnus-configure-windows 'article)
6857 (gnus-summary-show-thread)
6858 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6859 (gnus-eval-in-buffer-window gnus-article-buffer
6861 (when (gnus-article-next-page lines)
6862 (gnus-message 3 "End of message")))
6864 (gnus-article-prev-page (- lines))))))
6865 (gnus-summary-recenter)
6866 (gnus-summary-position-point))
6868 (defun gnus-summary-scroll-down (lines)
6869 "Scroll down (or up) one line current article.
6870 Argument LINES specifies lines to be scrolled down (or up if negative)."
6872 (gnus-summary-scroll-up (- lines)))
6874 (defun gnus-summary-next-same-subject ()
6875 "Select next article which has the same subject as current one."
6877 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6879 (defun gnus-summary-prev-same-subject ()
6880 "Select previous article which has the same subject as current one."
6882 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6884 (defun gnus-summary-next-unread-same-subject ()
6885 "Select next unread article which has the same subject as current one."
6887 (gnus-summary-next-article t (gnus-summary-article-subject)))
6889 (defun gnus-summary-prev-unread-same-subject ()
6890 "Select previous unread article which has the same subject as current one."
6892 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6894 (defun gnus-summary-first-unread-article ()
6895 "Select the first unread article.
6896 Return nil if there are no unread articles."
6899 (when (gnus-summary-first-subject t)
6900 (gnus-summary-show-thread)
6901 (gnus-summary-first-subject t)
6902 (gnus-summary-display-article (gnus-summary-article-number)))
6903 (gnus-summary-position-point)))
6905 (defun gnus-summary-first-unread-subject ()
6906 "Place the point on the subject line of the first unread article.
6907 Return nil if there are no unread articles."
6910 (when (gnus-summary-first-subject t)
6911 (gnus-summary-show-thread)
6912 (gnus-summary-first-subject t))
6913 (gnus-summary-position-point)))
6915 (defun gnus-summary-first-unseen-subject ()
6916 "Place the point on the subject line of the first unseen article.
6917 Return nil if there are no unseen articles."
6920 (when (gnus-summary-first-subject t t t)
6921 (gnus-summary-show-thread)
6922 (gnus-summary-first-subject t t t))
6923 (gnus-summary-position-point)))
6925 (defun gnus-summary-first-unseen-or-unread-subject ()
6926 "Place the point on the subject line of the first unseen article.
6927 Return nil if there are no unseen articles."
6930 (unless (when (gnus-summary-first-subject t t t)
6931 (gnus-summary-show-thread)
6932 (gnus-summary-first-subject t t t))
6933 (when (gnus-summary-first-subject t)
6934 (gnus-summary-show-thread)
6935 (gnus-summary-first-subject t)))
6936 (gnus-summary-position-point)))
6938 (defun gnus-summary-first-article ()
6939 "Select the first article.
6940 Return nil if there are no articles."
6943 (when (gnus-summary-first-subject)
6944 (gnus-summary-show-thread)
6945 (gnus-summary-first-subject)
6946 (gnus-summary-display-article (gnus-summary-article-number)))
6947 (gnus-summary-position-point)))
6949 (defun gnus-summary-best-unread-article (&optional arg)
6950 "Select the unread article with the highest score.
6951 If given a prefix argument, select the next unread article that has a
6952 score higher than the default score."
6954 (let ((article (if arg
6955 (gnus-summary-better-unread-subject)
6956 (gnus-summary-best-unread-subject))))
6958 (gnus-summary-goto-article article)
6959 (error "No unread articles"))))
6961 (defun gnus-summary-best-unread-subject ()
6962 "Select the unread subject with the highest score."
6964 (let ((best -1000000)
6965 (data gnus-newsgroup-data)
6968 (and (gnus-data-unread-p (car data))
6970 (gnus-summary-article-score (gnus-data-number (car data))))
6973 article (gnus-data-number (car data))))
6974 (setq data (cdr data)))
6976 (gnus-summary-goto-subject article))
6977 (gnus-summary-position-point)
6980 (defun gnus-summary-better-unread-subject ()
6981 "Select the first unread subject that has a score over the default score."
6983 (let ((data gnus-newsgroup-data)
6985 (while (and (setq article (gnus-data-number (car data)))
6986 (or (gnus-data-read-p (car data))
6987 (not (> (gnus-summary-article-score article)
6988 gnus-summary-default-score))))
6989 (setq data (cdr data)))
6991 (gnus-summary-goto-subject article))
6992 (gnus-summary-position-point)
6995 (defun gnus-summary-last-subject ()
6996 "Go to the last displayed subject line in the group."
6997 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6999 (gnus-summary-goto-subject article))))
7001 (defun gnus-summary-goto-article (article &optional all-headers force)
7002 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7003 If ALL-HEADERS is non-nil, no header lines are hidden.
7004 If FORCE, go to the article even if it isn't displayed. If FORCE
7005 is a number, it is the line the article is to be displayed on."
7009 "Article number or Message-ID: "
7010 (mapcar (lambda (number) (list (int-to-string number)))
7011 gnus-newsgroup-limit))
7015 (if (and (stringp article)
7016 (string-match "@" article))
7017 (gnus-summary-refer-article article)
7018 (when (stringp article)
7019 (setq article (string-to-number article)))
7020 (if (gnus-summary-goto-subject article force)
7021 (gnus-summary-display-article article all-headers)
7022 (gnus-message 4 "Couldn't go to article %s" article) nil))
7023 (gnus-summary-position-point)))
7025 (defun gnus-summary-goto-last-article ()
7026 "Go to the previously read article."
7029 (when gnus-last-article
7030 (gnus-summary-goto-article gnus-last-article nil t))
7031 (gnus-summary-position-point)))
7033 (defun gnus-summary-pop-article (number)
7034 "Pop one article off the history and go to the previous.
7035 NUMBER articles will be popped off."
7038 (setq gnus-newsgroup-history
7039 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7041 (gnus-summary-goto-article (car to) nil t)
7042 (error "Article history empty")))
7043 (gnus-summary-position-point))
7045 ;; Summary commands and functions for limiting the summary buffer.
7047 (defun gnus-summary-limit-to-articles (n)
7048 "Limit the summary buffer to the next N articles.
7049 If not given a prefix, use the process marked articles instead."
7052 (let ((articles (gnus-summary-work-articles n)))
7053 (setq gnus-newsgroup-processable nil)
7054 (gnus-summary-limit articles))
7055 (gnus-summary-position-point)))
7057 (defun gnus-summary-pop-limit (&optional total)
7058 "Restore the previous limit.
7059 If given a prefix, remove all limits."
7062 (setq gnus-newsgroup-limits
7063 (list (mapcar (lambda (h) (mail-header-number h))
7064 gnus-newsgroup-headers))))
7065 (unless gnus-newsgroup-limits
7066 (error "No limit to pop"))
7068 (gnus-summary-limit nil 'pop)
7069 (gnus-summary-position-point)))
7071 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7072 "Limit the summary buffer to articles that have subjects that match a regexp.
7073 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7075 (list (read-string (if current-prefix-arg
7076 "Exclude subject (regexp): "
7077 "Limit to subject (regexp): "))
7078 nil current-prefix-arg))
7080 (setq header "subject"))
7081 (when (not (equal "" subject))
7083 (let ((articles (gnus-summary-find-matching
7084 (or header "subject") subject 'all nil nil
7087 (error "Found no matches for \"%s\"" subject))
7088 (gnus-summary-limit articles))
7089 (gnus-summary-position-point))))
7091 (defun gnus-summary-limit-to-author (from &optional not-matching)
7092 "Limit the summary buffer to articles that have authors that match a regexp.
7093 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7095 (list (read-string (if current-prefix-arg
7096 "Exclude author (regexp): "
7097 "Limit to author (regexp): "))
7098 current-prefix-arg))
7099 (gnus-summary-limit-to-subject from "from" not-matching))
7101 (defun gnus-summary-limit-to-age (age &optional younger-p)
7102 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7103 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7104 articles that are younger than AGE days."
7106 (let ((younger current-prefix-arg)
7109 (while (not days-got)
7110 (setq days (if younger
7111 (read-string "Limit to articles within (in days): ")
7112 (read-string "Limit to articles older than (in days): ")))
7113 (when (> (length days) 0)
7114 (setq days (read days)))
7120 (setq younger (not younger))
7121 (setq days (* days -1)))))
7122 (message "Please enter a number.")
7124 (list days younger)))
7126 (let ((data gnus-newsgroup-data)
7127 (cutoff (days-to-time age))
7128 articles d date is-younger)
7129 (while (setq d (pop data))
7130 (when (and (vectorp (gnus-data-header d))
7131 (setq date (mail-header-date (gnus-data-header d))))
7132 (setq is-younger (time-less-p
7133 (time-since (condition-case ()
7140 (push (gnus-data-number d) articles))))
7141 (gnus-summary-limit (nreverse articles)))
7142 (gnus-summary-position-point)))
7144 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7145 "Limit the summary buffer to articles that match an 'extra' header."
7149 (gnus-completing-read-with-default
7150 (symbol-name (car gnus-extra-headers))
7151 (if current-prefix-arg
7152 "Exclude extra header:"
7153 "Limit extra header:")
7155 (cons (symbol-name x) x))
7160 (read-string (format "%s header %s (regexp): "
7161 (if current-prefix-arg "Exclude" "Limit to")
7163 current-prefix-arg)))
7164 (when (not (equal "" regexp))
7166 (let ((articles (gnus-summary-find-matching
7167 (cons 'extra header) regexp 'all nil nil
7170 (error "Found no matches for \"%s\"" regexp))
7171 (gnus-summary-limit articles))
7172 (gnus-summary-position-point))))
7174 (defun gnus-summary-limit-to-display-predicate ()
7175 "Limit the summary buffer to the predicated in the `display' group parameter."
7177 (unless gnus-newsgroup-display
7178 (error "There is no `display' group parameter"))
7180 (dolist (number gnus-newsgroup-articles)
7181 (when (funcall gnus-newsgroup-display)
7182 (push number articles)))
7183 (gnus-summary-limit articles))
7184 (gnus-summary-position-point))
7186 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7188 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7190 (defun gnus-summary-limit-to-unread (&optional all)
7191 "Limit the summary buffer to articles that are not marked as read.
7192 If ALL is non-nil, limit strictly to unread articles."
7195 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7196 (gnus-summary-limit-to-marks
7197 ;; Concat all the marks that say that an article is read and have
7199 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7200 gnus-killed-mark gnus-kill-file-mark
7201 gnus-low-score-mark gnus-expirable-mark
7202 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7203 gnus-duplicate-mark gnus-souped-mark)
7206 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7207 (make-obsolete 'gnus-summary-delete-marked-with
7208 'gnus-summary-limit-exlude-marks)
7210 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7211 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7212 If REVERSE, limit the summary buffer to articles that are marked
7213 with MARKS. MARKS can either be a string of marks or a list of marks.
7214 Returns how many articles were removed."
7215 (interactive "sMarks: ")
7216 (gnus-summary-limit-to-marks marks t))
7218 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7219 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7220 If REVERSE (the prefix), limit the summary buffer to articles that are
7221 not marked with MARKS. MARKS can either be a string of marks or a
7223 Returns how many articles were removed."
7224 (interactive "sMarks: \nP")
7226 (let ((data gnus-newsgroup-data)
7227 (marks (if (listp marks) marks
7228 (append marks nil))) ; Transform to list.
7231 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7232 (memq (gnus-data-mark (car data)) marks))
7233 (push (gnus-data-number (car data)) articles))
7234 (setq data (cdr data)))
7235 (gnus-summary-limit articles))
7236 (gnus-summary-position-point)))
7238 (defun gnus-summary-limit-to-score (score)
7239 "Limit to articles with score at or above SCORE."
7240 (interactive "NLimit to articles with score of at least: ")
7241 (let ((data gnus-newsgroup-data)
7244 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7246 (push (gnus-data-number (car data)) articles))
7247 (setq data (cdr data)))
7249 (gnus-summary-limit articles)
7250 (gnus-summary-position-point))))
7252 (defun gnus-summary-limit-include-thread (id)
7253 "Display all the hidden articles that is in the thread with ID in it.
7254 When called interactively, ID is the Message-ID of the current
7256 (interactive (list (mail-header-id (gnus-summary-article-header))))
7257 (let ((articles (gnus-articles-in-thread
7258 (gnus-id-to-thread (gnus-root-id id)))))
7260 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7261 (gnus-summary-limit-include-matching-articles
7263 (regexp-quote (gnus-simplify-subject-re
7264 (mail-header-subject (gnus-id-to-header id)))))
7265 (gnus-summary-position-point))))
7267 (defun gnus-summary-limit-include-matching-articles (header regexp)
7268 "Display all the hidden articles that have HEADERs that match REGEXP."
7269 (interactive (list (read-string "Match on header: ")
7270 (read-string "Regexp: ")))
7271 (let ((articles (gnus-find-matching-articles header regexp)))
7273 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7274 (gnus-summary-position-point))))
7276 (defun gnus-summary-limit-include-dormant ()
7277 "Display all the hidden articles that are marked as dormant.
7278 Note that this command only works on a subset of the articles currently
7279 fetched for this group."
7281 (unless gnus-newsgroup-dormant
7282 (error "There are no dormant articles in this group"))
7284 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7285 (gnus-summary-position-point)))
7287 (defun gnus-summary-limit-exclude-dormant ()
7288 "Hide all dormant articles."
7291 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7292 (gnus-summary-position-point)))
7294 (defun gnus-summary-limit-exclude-childless-dormant ()
7295 "Hide all dormant articles that have no children."
7297 (let ((data (gnus-data-list t))
7298 articles d children)
7299 ;; Find all articles that are either not dormant or have
7301 (while (setq d (pop data))
7302 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7304 (gnus-article-children (gnus-data-number d)))
7307 (when (memq (car children) articles)
7312 (push (gnus-data-number d) articles)))
7315 (gnus-summary-limit articles)
7316 (gnus-summary-position-point))))
7318 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7319 "Mark all unread excluded articles as read.
7320 If ALL, mark even excluded ticked and dormants as read."
7322 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7323 (let ((articles (gnus-sorted-ndifference
7325 (mapcar (lambda (h) (mail-header-number h))
7326 gnus-newsgroup-headers)
7328 gnus-newsgroup-limit))
7330 (setq gnus-newsgroup-unreads
7331 (gnus-sorted-intersection gnus-newsgroup-unreads
7332 gnus-newsgroup-limit))
7334 (setq gnus-newsgroup-dormant nil
7335 gnus-newsgroup-marked nil
7336 gnus-newsgroup-reads
7338 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7339 gnus-newsgroup-reads))
7340 (while (setq article (pop articles))
7341 (unless (or (memq article gnus-newsgroup-dormant)
7342 (memq article gnus-newsgroup-marked))
7343 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7345 (defun gnus-summary-limit (articles &optional pop)
7347 ;; We pop the previous limit off the stack and use that.
7348 (setq articles (car gnus-newsgroup-limits)
7349 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7350 ;; We use the new limit, so we push the old limit on the stack.
7351 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7353 (setq gnus-newsgroup-limit articles)
7354 (let ((total (length gnus-newsgroup-data))
7355 (data (gnus-data-find-list (gnus-summary-article-number)))
7356 (gnus-summary-mark-below nil) ; Inhibit this.
7358 ;; This will do all the work of generating the new summary buffer
7359 ;; according to the new limit.
7360 (gnus-summary-prepare)
7361 ;; Hide any threads, possibly.
7362 (gnus-summary-maybe-hide-threads)
7363 ;; Try to return to the article you were at, or one in the
7366 ;; We try to find some article after the current one.
7368 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7371 (setq data (cdr data))))
7373 ;; If there is no data, that means that we were after the last
7374 ;; article. The same goes when we can't find any articles
7375 ;; after the current one.
7376 (goto-char (point-max))
7377 (gnus-summary-find-prev))
7378 (gnus-set-mode-line 'summary)
7379 ;; We return how many articles were removed from the summary
7380 ;; buffer as a result of the new limit.
7381 (- total (length gnus-newsgroup-data))))
7383 (defsubst gnus-invisible-cut-children (threads)
7386 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7391 (defsubst gnus-cut-thread (thread)
7392 "Go forwards in the thread until we find an article that we want to display."
7393 (when (or (eq gnus-fetch-old-headers 'some)
7394 (eq gnus-fetch-old-headers 'invisible)
7395 (numberp gnus-fetch-old-headers)
7396 (eq gnus-build-sparse-threads 'some)
7397 (eq gnus-build-sparse-threads 'more))
7398 ;; Deal with old-fetched headers and sparse threads.
7402 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7403 (gnus-summary-article-ancient-p
7404 (mail-header-number (car thread))))
7405 (if (or (<= (length (cdr thread)) 1)
7406 (eq gnus-fetch-old-headers 'invisible))
7407 (setq gnus-newsgroup-limit
7408 (delq (mail-header-number (car thread))
7409 gnus-newsgroup-limit)
7410 thread (cadr thread))
7411 (when (gnus-invisible-cut-children (cdr thread))
7412 (let ((th (cdr thread)))
7414 (if (memq (mail-header-number (caar th))
7415 gnus-newsgroup-limit)
7416 (setq thread (car th)
7418 (setq th (cdr th))))))))))
7421 (defun gnus-cut-threads (threads)
7422 "Cut off all uninteresting articles from the beginning of threads."
7423 (when (or (eq gnus-fetch-old-headers 'some)
7424 (eq gnus-fetch-old-headers 'invisible)
7425 (numberp gnus-fetch-old-headers)
7426 (eq gnus-build-sparse-threads 'some)
7427 (eq gnus-build-sparse-threads 'more))
7430 (setcar th (gnus-cut-thread (car th)))
7431 (setq th (cdr th)))))
7432 ;; Remove nixed out threads.
7435 (defun gnus-summary-initial-limit (&optional show-if-empty)
7436 "Figure out what the initial limit is supposed to be on group entry.
7437 This entails weeding out unwanted dormants, low-scored articles,
7438 fetch-old-headers verbiage, and so on."
7439 ;; Most groups have nothing to remove.
7440 (if (or gnus-inhibit-limiting
7441 (and (null gnus-newsgroup-dormant)
7442 (eq gnus-newsgroup-display 'gnus-not-ignore)
7443 (not (eq gnus-fetch-old-headers 'some))
7444 (not (numberp gnus-fetch-old-headers))
7445 (not (eq gnus-fetch-old-headers 'invisible))
7446 (null gnus-summary-expunge-below)
7447 (not (eq gnus-build-sparse-threads 'some))
7448 (not (eq gnus-build-sparse-threads 'more))
7449 (null gnus-thread-expunge-below)
7450 (not gnus-use-nocem)))
7452 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7453 (setq gnus-newsgroup-limit nil)
7456 (unless (car (symbol-value node))
7457 ;; These threads have no parents -- they are roots.
7458 (let ((nodes (cdr (symbol-value node)))
7461 (if (and gnus-thread-expunge-below
7462 (< (gnus-thread-total-score (car nodes))
7463 gnus-thread-expunge-below))
7464 (gnus-expunge-thread (pop nodes))
7465 (setq thread (pop nodes))
7466 (gnus-summary-limit-children thread))))))
7467 gnus-newsgroup-dependencies)
7468 ;; If this limitation resulted in an empty group, we might
7469 ;; pop the previous limit and use it instead.
7470 (when (and (not gnus-newsgroup-limit)
7472 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7473 gnus-newsgroup-limit))
7475 (defun gnus-summary-limit-children (thread)
7476 "Return 1 if this subthread is visible and 0 if it is not."
7477 ;; First we get the number of visible children to this thread. This
7478 ;; is done by recursing down the thread using this function, so this
7479 ;; will really go down to a leaf article first, before slowly
7480 ;; working its way up towards the root.
7484 (apply '+ (mapcar 'gnus-summary-limit-children
7487 (number (mail-header-number (car thread)))
7490 (not (memq number gnus-newsgroup-marked))
7492 ;; If this article is dormant and has absolutely no visible
7493 ;; children, then this article isn't visible.
7494 (and (memq number gnus-newsgroup-dormant)
7496 ;; If this is "fetch-old-headered" and there is no
7497 ;; visible children, then we don't want this article.
7498 (and (or (eq gnus-fetch-old-headers 'some)
7499 (numberp gnus-fetch-old-headers))
7500 (gnus-summary-article-ancient-p number)
7502 ;; If this is "fetch-old-headered" and `invisible', then
7503 ;; we don't want this article.
7504 (and (eq gnus-fetch-old-headers 'invisible)
7505 (gnus-summary-article-ancient-p number))
7506 ;; If this is a sparsely inserted article with no children,
7507 ;; we don't want it.
7508 (and (eq gnus-build-sparse-threads 'some)
7509 (gnus-summary-article-sparse-p number)
7511 ;; If we use expunging, and this article is really
7512 ;; low-scored, then we don't want this article.
7513 (when (and gnus-summary-expunge-below
7515 (or (cdr (assq number gnus-newsgroup-scored))
7516 gnus-summary-default-score))
7517 gnus-summary-expunge-below))
7518 ;; We increase the expunge-tally here, but that has
7519 ;; nothing to do with the limits, really.
7520 (incf gnus-newsgroup-expunged-tally)
7521 ;; We also mark as read here, if that's wanted.
7522 (when (and gnus-summary-mark-below
7523 (< score gnus-summary-mark-below))
7524 (setq gnus-newsgroup-unreads
7525 (delq number gnus-newsgroup-unreads))
7526 (if gnus-newsgroup-auto-expire
7527 (push number gnus-newsgroup-expirable)
7528 (push (cons number gnus-low-score-mark)
7529 gnus-newsgroup-reads)))
7531 ;; Do the `display' group parameter.
7532 (and gnus-newsgroup-display
7533 (not (funcall gnus-newsgroup-display)))
7534 ;; Check NoCeM things.
7535 (if (and gnus-use-nocem
7536 (gnus-nocem-unwanted-article-p
7537 (mail-header-id (car thread))))
7539 (setq gnus-newsgroup-unreads
7540 (delq number gnus-newsgroup-unreads))
7542 ;; Nope, invisible article.
7544 ;; Ok, this article is to be visible, so we add it to the limit
7546 (push number gnus-newsgroup-limit)
7549 (defun gnus-expunge-thread (thread)
7550 "Mark all articles in THREAD as read."
7551 (let* ((number (mail-header-number (car thread))))
7552 (incf gnus-newsgroup-expunged-tally)
7553 ;; We also mark as read here, if that's wanted.
7554 (setq gnus-newsgroup-unreads
7555 (delq number gnus-newsgroup-unreads))
7556 (if gnus-newsgroup-auto-expire
7557 (push number gnus-newsgroup-expirable)
7558 (push (cons number gnus-low-score-mark)
7559 gnus-newsgroup-reads)))
7560 ;; Go recursively through all subthreads.
7561 (mapcar 'gnus-expunge-thread (cdr thread)))
7563 ;; Summary article oriented commands
7565 (defun gnus-summary-refer-parent-article (n)
7566 "Refer parent article N times.
7567 If N is negative, go to ancestor -N instead.
7568 The difference between N and the number of articles fetched is returned."
7572 (when (not (natnump n))
7577 (setq header (gnus-summary-article-header))
7578 (if (and (eq (mail-header-number header)
7579 (cdr gnus-article-current))
7580 (equal gnus-newsgroup-name
7581 (car gnus-article-current)))
7582 ;; If we try to find the parent of the currently
7583 ;; displayed article, then we take a look at the actual
7584 ;; References header, since this is slightly more
7585 ;; reliable than the References field we got from the
7588 (set-buffer gnus-original-article-buffer)
7589 (nnheader-narrow-to-headers)
7590 (unless (setq ref (message-fetch-field "references"))
7591 (setq ref (message-fetch-field "in-reply-to")))
7594 ;; It's not the current article, so we take a bet on
7595 ;; the value we got from the server.
7596 (mail-header-references header)))
7598 (not (equal ref "")))
7599 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7600 (gnus-message 1 "Couldn't find parent"))
7601 (gnus-message 1 "No references in article %d"
7602 (gnus-summary-article-number))
7605 (gnus-summary-position-point)
7608 (defun gnus-summary-refer-references ()
7609 "Fetch all articles mentioned in the References header.
7610 Return the number of articles fetched."
7612 (let ((ref (mail-header-references (gnus-summary-article-header)))
7613 (current (gnus-summary-article-number))
7617 (error "No References in the current article")
7618 ;; For each Message-ID in the References header...
7619 (while (string-match "<[^>]*>" ref)
7621 ;; ... fetch that article.
7622 (gnus-summary-refer-article
7623 (prog1 (match-string 0 ref)
7624 (setq ref (substring ref (match-end 0))))))
7625 (gnus-summary-goto-subject current)
7626 (gnus-summary-position-point)
7629 (defun gnus-summary-refer-thread (&optional limit)
7630 "Fetch all articles in the current thread.
7631 If LIMIT (the numerical prefix), fetch that many old headers instead
7632 of what's specified by the `gnus-refer-thread-limit' variable."
7634 (let ((id (mail-header-id (gnus-summary-article-header)))
7635 (limit (if limit (prefix-numeric-value limit)
7636 gnus-refer-thread-limit)))
7637 ;; We want to fetch LIMIT *old* headers, but we also have to
7638 ;; re-fetch all the headers in the current buffer, because many of
7639 ;; them may be undisplayed. So we adjust LIMIT.
7640 (when (numberp limit)
7641 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7642 (unless (eq gnus-fetch-old-headers 'invisible)
7643 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7644 ;; Retrieve the headers and read them in.
7645 (if (eq (gnus-retrieve-headers
7646 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7648 (gnus-build-all-threads)
7649 (error "Can't fetch thread from backends that don't support NOV"))
7650 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7651 (gnus-summary-limit-include-thread id)))
7653 (defun gnus-summary-refer-article (message-id)
7654 "Fetch an article specified by MESSAGE-ID."
7655 (interactive "sMessage-ID: ")
7656 (when (and (stringp message-id)
7657 (not (zerop (length message-id))))
7658 ;; Construct the correct Message-ID if necessary.
7659 ;; Suggested by tale@pawl.rpi.edu.
7660 (unless (string-match "^<" message-id)
7661 (setq message-id (concat "<" message-id)))
7662 (unless (string-match ">$" message-id)
7663 (setq message-id (concat message-id ">")))
7664 (let* ((header (gnus-id-to-header message-id))
7666 (gnus-summary-article-sparse-p
7667 (mail-header-number header))
7668 (memq (mail-header-number header)
7669 gnus-newsgroup-limit)))
7672 ;; If the article is present in the buffer we just go to it.
7674 (or (not (gnus-summary-article-sparse-p
7675 (mail-header-number header)))
7678 (gnus-summary-goto-article
7679 (mail-header-number header) nil t)
7681 (gnus-summary-update-article (mail-header-number header)))))
7683 ;; We fetch the article.
7685 (dolist (gnus-override-method (gnus-refer-article-methods))
7686 (gnus-check-server gnus-override-method)
7687 ;; Fetch the header, and display the article.
7688 (when (setq number (gnus-summary-insert-subject message-id))
7689 (gnus-summary-select-article nil nil nil number)
7691 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7693 (defun gnus-refer-article-methods ()
7694 "Return a list of referrable methods."
7696 ;; No method, so we default to current and native.
7697 ((null gnus-refer-article-method)
7698 (list gnus-current-select-method gnus-select-method))
7700 ((eq 'current gnus-refer-article-method)
7701 (list gnus-current-select-method))
7702 ;; List of select methods.
7703 ((not (and (symbolp (car gnus-refer-article-method))
7704 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7706 (dolist (method gnus-refer-article-method)
7707 (push (if (eq 'current method)
7708 gnus-current-select-method
7712 ;; One single select method.
7714 (list gnus-refer-article-method))))
7716 (defun gnus-summary-edit-parameters ()
7717 "Edit the group parameters of the current group."
7719 (gnus-group-edit-group gnus-newsgroup-name 'params))
7721 (defun gnus-summary-customize-parameters ()
7722 "Customize the group parameters of the current group."
7724 (gnus-group-customize gnus-newsgroup-name))
7726 (defun gnus-summary-enter-digest-group (&optional force)
7727 "Enter an nndoc group based on the current article.
7728 If FORCE, force a digest interpretation. If not, try
7729 to guess what the document format is."
7731 (let ((conf gnus-current-window-configuration))
7733 (gnus-summary-select-article))
7734 (setq gnus-current-window-configuration conf)
7735 (let* ((name (format "%s-%d"
7736 (gnus-group-prefixed-name
7737 gnus-newsgroup-name (list 'nndoc ""))
7739 (set-buffer gnus-summary-buffer)
7740 gnus-current-article)))
7741 (ogroup gnus-newsgroup-name)
7742 (params (append (gnus-info-params (gnus-get-info ogroup))
7743 (list (cons 'to-group ogroup))
7744 (list (cons 'save-article-group ogroup))))
7745 (case-fold-search t)
7746 (buf (current-buffer))
7749 (set-buffer gnus-original-article-buffer)
7750 ;; Have the digest group inherit the main mail address of
7751 ;; the parent article.
7752 (when (setq to-address (or (message-fetch-field "reply-to")
7753 (message-fetch-field "from")))
7754 (setq params (append
7755 (list (cons 'to-address
7756 (funcall gnus-decode-encoded-word-function
7758 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7759 (insert-buffer-substring gnus-original-article-buffer)
7760 ;; Remove lines that may lead nndoc to misinterpret the
7763 (goto-char (point-min))
7764 (or (search-forward "\n\n" nil t) (point)))
7765 (goto-char (point-min))
7766 (delete-matching-lines "^Path:\\|^From ")
7769 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7770 (gnus-newsgroup-ephemeral-ignored-charsets
7771 gnus-newsgroup-ignored-charsets))
7772 (gnus-group-read-ephemeral-group
7773 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7775 ,(if force 'mbox 'guess)))
7777 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7779 ;; Make all postings to this group go to the parent group.
7780 (nconc (gnus-info-params (gnus-get-info name))
7782 ;; Couldn't select this doc group.
7783 (switch-to-buffer buf)
7784 (gnus-set-global-variables)
7785 (gnus-configure-windows 'summary)
7786 (gnus-message 3 "Article couldn't be entered?"))
7787 (kill-buffer dig)))))
7789 (defun gnus-summary-read-document (n)
7790 "Open a new group based on the current article(s).
7791 This will allow you to read digests and other similar
7792 documents as newsgroups.
7793 Obeys the standard process/prefix convention."
7795 (let* ((articles (gnus-summary-work-articles n))
7796 (ogroup gnus-newsgroup-name)
7797 (params (append (gnus-info-params (gnus-get-info ogroup))
7798 (list (cons 'to-group ogroup))))
7799 article group egroup groups vgroup)
7800 (while (setq article (pop articles))
7801 (setq group (format "%s-%d" gnus-newsgroup-name article))
7802 (gnus-summary-remove-process-mark article)
7803 (when (gnus-summary-display-article article)
7806 (insert-buffer-substring gnus-original-article-buffer)
7807 ;; Remove some headers that may lead nndoc to make
7809 (message-narrow-to-head)
7810 (goto-char (point-min))
7811 (delete-matching-lines "^\\(Path\\):\\|^From ")
7814 (gnus-group-read-ephemeral-group
7815 group `(nndoc ,group (nndoc-address ,(current-buffer))
7816 (nndoc-article-type guess))
7819 ;; Make all postings to this group go to the parent group.
7820 (nconc (gnus-info-params (gnus-get-info egroup))
7822 (push egroup groups))
7823 ;; Couldn't select this doc group.
7824 (gnus-error 3 "Article couldn't be entered"))))))
7825 ;; Now we have selected all the documents.
7828 (error "None of the articles could be interpreted as documents"))
7829 ((gnus-group-read-ephemeral-group
7830 (setq vgroup (format
7831 "nnvirtual:%s-%s" gnus-newsgroup-name
7832 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7833 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7835 (cons (current-buffer) 'summary)))
7837 (error "Couldn't select virtual nndoc group")))))
7839 (defun gnus-summary-isearch-article (&optional regexp-p)
7840 "Do incremental search forward on the current article.
7841 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7843 (let* ((gnus-inhibit-treatment t)
7844 (old (gnus-summary-select-article)))
7845 (gnus-configure-windows 'article)
7846 (gnus-eval-in-buffer-window gnus-article-buffer
7850 (gnus-article-show-all-headers))
7851 (goto-char (point-min))
7852 (isearch-forward regexp-p)))))
7854 (defun gnus-summary-search-article-forward (regexp &optional backward)
7855 "Search for an article containing REGEXP forward.
7856 If BACKWARD, search backward instead."
7859 (format "Search article %s (regexp%s): "
7860 (if current-prefix-arg "backward" "forward")
7861 (if gnus-last-search-regexp
7862 (concat ", default " gnus-last-search-regexp)
7864 current-prefix-arg))
7865 (if (string-equal regexp "")
7866 (setq regexp (or gnus-last-search-regexp ""))
7867 (setq gnus-last-search-regexp regexp)
7868 (setq gnus-article-before-search gnus-current-article))
7869 ;; Intentionally set gnus-last-article.
7870 (setq gnus-last-article gnus-article-before-search)
7871 (let ((gnus-last-article gnus-last-article))
7872 (if (gnus-summary-search-article regexp backward)
7873 (gnus-summary-show-thread)
7874 (error "Search failed: \"%s\"" regexp))))
7876 (defun gnus-summary-search-article-backward (regexp)
7877 "Search for an article containing REGEXP backward."
7880 (format "Search article backward (regexp%s): "
7881 (if gnus-last-search-regexp
7882 (concat ", default " gnus-last-search-regexp)
7884 (gnus-summary-search-article-forward regexp 'backward))
7887 (defmacro gnus-summary-search-article-position-point (regexp backward)
7888 "Dehighlight the last matched text and goto the beginning position."
7889 (` (if (and gnus-summary-search-article-matched-data
7890 (let ((text (caddr gnus-summary-search-article-matched-data))
7891 (inhibit-read-only t)
7894 (goto-char (car gnus-summary-search-article-matched-data))
7895 (cadr gnus-summary-search-article-matched-data))
7897 (string-match (, regexp) text)))
7898 (if (, backward) (beginning-of-line) (end-of-line))
7899 (goto-char (if (, backward) (point-max) (point-min))))))
7901 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7902 "Place point where X-Face image is displayed."
7903 (if (featurep 'xemacs)
7904 (` (let ((end (if (search-forward "\n\n" nil t)
7905 (goto-char (1- (point)))
7908 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7909 (unless (and (re-search-forward "^From:" end t)
7910 (setq extent (extent-at (point)))
7911 (extent-begin-glyph extent))
7912 (goto-char (, opoint)))))
7913 (` (let ((end (if (search-forward "\n\n" nil t)
7914 (goto-char (1- (point)))
7916 (start (or (search-backward "\n\n" nil t) (point-min))))
7918 (or (text-property-any start end 'x-face-image t);; x-face-e21
7919 (text-property-any start end 'x-face-mule-bitmap-image t)
7922 (defmacro gnus-summary-search-article-highlight-matched-text
7923 (backward treated x-face)
7924 "Highlight matched text in the function `gnus-summary-search-article'."
7925 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7926 (end (set-marker (make-marker) (match-end 0)))
7927 (inhibit-read-only t)
7931 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7933 (lambda (item) (setq items (delq item items)))
7934 '(gnus-treat-buttonize
7935 gnus-treat-fill-article
7936 gnus-treat-fill-long-lines
7937 gnus-treat-emphasize
7938 gnus-treat-highlight-headers
7939 gnus-treat-highlight-citation
7940 gnus-treat-highlight-signature
7941 gnus-treat-overstrike
7942 gnus-treat-display-xface
7943 gnus-treat-buttonize-head
7944 gnus-treat-decode-article-as-default-mime-charset))
7945 (static-if (featurep 'xemacs)
7947 (cons '(x-face-mule-delete-x-face-field
7950 (gnus-treat-display-xface
7951 (when (, x-face) gnus-treat-display-xface)))
7952 (gnus-article-prepare-mime-display)))
7953 (goto-char (if (, backward) start end))
7955 (gnus-summary-search-article-highlight-goto-x-face (point)))
7956 (setq gnus-summary-search-article-matched-data
7957 (list start end (buffer-substring start end)))
7958 (unless (eq start end);; matched text has been deleted. :-<
7959 (put-text-property start end 'face
7960 (or (find-face 'isearch)
7961 'secondary-selection))))))
7964 (defun gnus-summary-search-article (regexp &optional backward)
7965 "Search for an article containing REGEXP.
7966 Optional argument BACKWARD means do search for backward.
7967 `gnus-select-article-hook' is not called during the search."
7968 ;; We have to require this here to make sure that the following
7969 ;; dynamic binding isn't shadowed by autoloading.
7970 (require 'gnus-async)
7972 (let ((gnus-select-article-hook nil) ;Disable hook.
7973 (gnus-article-prepare-hook nil)
7974 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7975 (gnus-use-article-prefetch nil)
7976 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7977 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7978 (sum (current-buffer))
7981 (gnus-save-hidden-threads
7982 (static-if (featurep 'xemacs)
7983 (let ((gnus-inhibit-treatment t))
7984 (setq treated (eq 'old (gnus-summary-select-article)))
7986 (not (and (gnus-buffer-live-p gnus-article-buffer)
7987 (window-live-p (get-buffer-window
7988 gnus-article-buffer t)))))
7989 (gnus-summary-select-article nil t)
7990 (setq treated nil)))
7991 (let ((gnus-inhibit-treatment t)
7992 (x-face-mule-delete-x-face-field 'never))
7993 (setq treated (eq 'old (gnus-summary-select-article)))
7996 (and (gnus-buffer-live-p gnus-article-buffer)
7997 (window-live-p (get-buffer-window
7998 gnus-article-buffer t))
7999 (or (not (string-match "^\\^X-Face:" regexp))
8000 (with-current-buffer gnus-article-buffer
8001 gnus-summary-search-article-matched-data)))))
8002 (gnus-summary-select-article nil t)
8003 (setq treated nil))))
8004 (set-buffer gnus-article-buffer)
8008 (gnus-article-show-all-headers)
8009 (gnus-summary-search-article-position-point regexp backward))
8010 (goto-char (if backward (point-max) (point-min))))
8012 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8014 (re-search-backward regexp nil t)
8015 (re-search-forward regexp nil t))
8016 ;; We found the regexp.
8018 (gnus-summary-search-article-highlight-matched-text
8019 backward treated (string-match "^\\^X-Face:" regexp))
8022 (/ (- 2 (window-height
8023 (get-buffer-window gnus-article-buffer t)))
8026 (get-buffer-window (current-buffer))
8029 (setq point (point)))
8030 ;; We didn't find it, so we go to the next article.
8033 (while (eq found 'not)
8034 (if (not (if backward (gnus-summary-find-prev)
8035 (gnus-summary-find-next)))
8036 ;; No more articles.
8038 ;; Select the next article and adjust point.
8039 (unless (gnus-summary-article-sparse-p
8040 (gnus-summary-article-number))
8042 (let ((gnus-inhibit-treatment t))
8043 (gnus-summary-select-article))
8045 (set-buffer gnus-article-buffer)
8047 (goto-char (if backward (point-max) (point-min))))))))
8048 (gnus-message 7 ""))
8049 ;; Return whether we found the regexp.
8050 (when (eq found 'found)
8052 (gnus-summary-show-thread)
8053 (gnus-summary-goto-subject gnus-current-article)
8054 (gnus-summary-position-point)
8057 (defun gnus-find-matching-articles (header regexp)
8058 "Return a list of all articles that match REGEXP on HEADER.
8059 This search includes all articles in the current group that Gnus has
8060 fetched headers for, whether they are displayed or not."
8061 (let ((articles nil)
8062 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8063 (case-fold-search t))
8064 (dolist (header gnus-newsgroup-headers)
8065 (when (string-match regexp (funcall func header))
8066 (push (mail-header-number header) articles)))
8067 (nreverse articles)))
8069 (defun gnus-summary-find-matching (header regexp &optional backward unread
8070 not-case-fold not-matching)
8071 "Return a list of all articles that match REGEXP on HEADER.
8072 The search stars on the current article and goes forwards unless
8073 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8074 If UNREAD is non-nil, only unread articles will
8075 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8076 in the comparisons. If NOT-MATCHING, return a list of all articles that
8077 not match REGEXP on HEADER."
8078 (let ((case-fold-search (not not-case-fold))
8081 (if (eq (car header) 'extra)
8084 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8086 (error "%s is an invalid header" header))
8087 (unless (fboundp (intern (concat "mail-header-" header)))
8088 (error "%s is not a valid header" header))
8089 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8090 (dolist (d (if (eq backward 'all)
8092 (gnus-data-find-list
8093 (gnus-summary-article-number)
8094 (gnus-data-list backward))))
8095 (when (and (or (not unread) ; We want all articles...
8096 (gnus-data-unread-p d)) ; Or just unreads.
8097 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8101 (funcall func (gnus-data-header d))))
8102 (string-match regexp
8103 (funcall func (gnus-data-header d)))))
8104 (push (gnus-data-number d) articles))) ; Success!
8105 (nreverse articles)))
8107 (defun gnus-summary-execute-command (header regexp command &optional backward)
8108 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8109 If HEADER is an empty string (or nil), the match is done on the entire
8110 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8112 (list (let ((completion-ignore-case t))
8115 (mapcar (lambda (header) (list (format "%s" header)))
8117 '("Number" "Subject" "From" "Lines" "Date"
8118 "Message-ID" "Xref" "References" "Body")
8119 gnus-extra-headers))
8120 nil 'require-match))
8121 (read-string "Regexp: ")
8122 (read-key-sequence "Command: ")
8123 current-prefix-arg))
8124 (when (equal header "Body")
8126 ;; Hidden thread subtrees must be searched as well.
8127 (gnus-summary-show-all-threads)
8128 ;; We don't want to change current point nor window configuration.
8130 (save-window-excursion
8131 (gnus-message 6 "Executing %s..." (key-description command))
8132 ;; We'd like to execute COMMAND interactively so as to give arguments.
8133 (gnus-execute header regexp
8134 `(call-interactively ',(key-binding command))
8136 (gnus-message 6 "Executing %s...done" (key-description command)))))
8138 (defun gnus-summary-beginning-of-article ()
8139 "Scroll the article back to the beginning."
8141 (gnus-summary-select-article)
8142 (gnus-configure-windows 'article)
8143 (gnus-eval-in-buffer-window gnus-article-buffer
8145 (goto-char (point-min))
8146 (when gnus-page-broken
8147 (gnus-narrow-to-page))))
8149 (defun gnus-summary-end-of-article ()
8150 "Scroll to the end of the article."
8152 (gnus-summary-select-article)
8153 (gnus-configure-windows 'article)
8154 (gnus-eval-in-buffer-window gnus-article-buffer
8156 (goto-char (point-max))
8158 (when gnus-page-broken
8159 (gnus-narrow-to-page))))
8161 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8162 "Truncate to LEN and quote all \"(\"'s in STRING."
8163 (gnus-replace-in-string (if (and len (> (length string) len))
8164 (substring string 0 len)
8168 (defun gnus-summary-print-article (&optional filename n)
8169 "Generate and print a PostScript image of the N next (mail) articles.
8171 If N is negative, print the N previous articles. If N is nil and articles
8172 have been marked with the process mark, print these instead.
8174 If the optional first argument FILENAME is nil, send the image to the
8175 printer. If FILENAME is a string, save the PostScript image in a file with
8176 that name. If FILENAME is a number, prompt the user for the name of the file
8178 (interactive (list (ps-print-preprint current-prefix-arg)))
8179 (dolist (article (gnus-summary-work-articles n))
8180 (gnus-summary-select-article nil nil 'pseudo article)
8181 (gnus-eval-in-buffer-window gnus-article-buffer
8182 (gnus-print-buffer))
8183 (gnus-summary-remove-process-mark article))
8184 (ps-despool filename))
8186 (defun gnus-print-buffer ()
8187 (let ((buffer (generate-new-buffer " *print*")))
8190 (copy-to-buffer buffer (point-min) (point-max))
8192 (gnus-article-delete-invisible-text)
8193 (when (gnus-visual-p 'article-highlight 'highlight)
8194 ;; Copy-to-buffer doesn't copy overlay. So redo
8196 (let ((gnus-article-buffer buffer))
8197 (gnus-article-highlight-citation t)
8198 (gnus-article-highlight-signature)))
8199 (let ((ps-left-header
8202 (gnus-summary-print-truncate-and-quote
8203 (mail-header-subject gnus-current-headers)
8206 (gnus-summary-print-truncate-and-quote
8207 (mail-header-from gnus-current-headers)
8211 "/pagenumberstring load"
8213 (mail-header-date gnus-current-headers) ")"))))
8214 (gnus-run-hooks 'gnus-ps-print-hook)
8217 (ps-spool-buffer-with-faces)
8218 (ps-spool-buffer)))))
8219 (kill-buffer buffer))))
8221 (defun gnus-summary-show-article (&optional arg)
8222 "Force redisplaying of the current article.
8223 If ARG (the prefix) is a number, show the article with the charset
8224 defined in `gnus-summary-show-article-charset-alist', or the charset
8226 If ARG (the prefix) is non-nil and not a number, show the raw article
8227 without any article massaging functions being run. Normally, the key strokes
8232 (gnus-summary-show-article t)
8233 (let* ((gnus-newsgroup-charset
8234 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8235 (mm-read-coding-system
8236 "View as charset: " ;; actually it is coding system.
8238 (set-buffer gnus-article-buffer)
8239 (mm-detect-coding-region (point) (point-max))))))
8240 (default-mime-charset gnus-newsgroup-charset)
8241 (gnus-newsgroup-ignored-charsets 'gnus-all))
8242 (gnus-summary-select-article nil 'force)
8243 (let ((deps gnus-newsgroup-dependencies)
8246 (set-buffer gnus-original-article-buffer)
8248 (message-narrow-to-head)
8249 (setq head (buffer-string))
8250 (goto-char (point-min))
8251 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8252 (goto-char (point-max))
8254 (setq lines (1- (count-lines (point) (point-max))))))
8256 (insert (format "211 %d Article retrieved.\n"
8257 (cdr gnus-article-current)))
8259 (if lines (insert (format "Lines: %d\n" lines)))
8261 (let ((nntp-server-buffer (current-buffer)))
8262 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8263 (gnus-data-set-header
8264 (gnus-data-find (cdr gnus-article-current))
8266 (gnus-summary-update-article-line
8267 (cdr gnus-article-current) header)
8268 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8269 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8271 ;; Select the article the normal way.
8272 (gnus-summary-select-article nil 'force))
8274 ;; We have to require this here to make sure that the following
8275 ;; dynamic binding isn't shadowed by autoloading.
8276 (require 'gnus-async)
8278 ;; Bind the article treatment functions to nil.
8279 (let ((gnus-have-all-headers t)
8280 gnus-article-prepare-hook
8281 gnus-article-decode-hook
8284 (gnus-inhibit-treatment t))
8285 (gnus-summary-select-article nil 'force))))
8286 (gnus-summary-goto-subject gnus-current-article)
8287 (gnus-summary-position-point))
8289 (defun gnus-summary-show-raw-article ()
8290 "Show the raw article without any article massaging functions being run."
8292 (gnus-summary-show-article t))
8294 (defun gnus-summary-verbose-headers (&optional arg)
8295 "Toggle permanent full header display.
8296 If ARG is a positive number, turn header display on.
8297 If ARG is a negative number, turn header display off."
8299 (setq gnus-show-all-headers
8300 (cond ((or (not (numberp arg))
8302 (not gnus-show-all-headers))
8305 (gnus-summary-show-article))
8307 (defun gnus-summary-toggle-header (&optional arg)
8308 "Show the headers if they are hidden, or hide them if they are shown.
8309 If ARG is a positive number, show the entire header.
8310 If ARG is a negative number, hide the unwanted header lines."
8313 (set-buffer gnus-article-buffer)
8315 (let* ((buffer-read-only nil)
8316 (inhibit-point-motion-hooks t)
8322 (article-narrow-to-head)
8323 (gnus-article-hidden-text-p 'headers))))
8324 (goto-char (point-min))
8325 (when (search-forward "\n\n" nil t)
8326 (delete-region (point-min) (1- (point))))
8327 (goto-char (point-min))
8329 (set-buffer gnus-original-article-buffer)
8330 (goto-char (point-min))
8331 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8332 (insert-buffer-substring gnus-original-article-buffer 1 e)
8334 (narrow-to-region (point-min) (point))
8335 (article-decode-encoded-words)
8337 (let ((gnus-treat-hide-headers nil)
8338 (gnus-treat-hide-boring-headers nil))
8339 (gnus-delete-wash-type 'headers)
8340 (gnus-treat-article 'head))
8341 (gnus-treat-article 'head)))
8342 (gnus-set-mode-line 'article)))))
8344 (defun gnus-summary-show-all-headers ()
8345 "Make all header lines visible."
8347 (gnus-summary-toggle-header 1))
8349 (defun gnus-summary-toggle-mime (&optional arg)
8350 "Toggle MIME processing.
8351 If ARG is a positive number, turn MIME processing on."
8353 (setq gnus-show-mime
8355 (not gnus-show-mime)
8356 (> (prefix-numeric-value arg) 0)))
8357 (gnus-summary-select-article t 'force))
8359 (defun gnus-summary-caesar-message (&optional arg)
8360 "Caesar rotate the current article by 13.
8361 The numerical prefix specifies how many places to rotate each letter
8364 (gnus-summary-select-article)
8365 (let ((mail-header-separator ""))
8366 (gnus-eval-in-buffer-window gnus-article-buffer
8369 (let ((start (window-start))
8371 (message-caesar-buffer-body arg)
8372 (set-window-start (get-buffer-window (current-buffer)) start))))))
8374 (defun gnus-summary-stop-page-breaking ()
8375 "Stop page breaking in the current article."
8377 (gnus-summary-select-article)
8378 (gnus-eval-in-buffer-window gnus-article-buffer
8380 (when (gnus-visual-p 'page-marker)
8381 (let ((buffer-read-only nil))
8382 (gnus-remove-text-with-property 'gnus-prev)
8383 (gnus-remove-text-with-property 'gnus-next))
8384 (setq gnus-page-broken nil))))
8386 (defun gnus-summary-move-article (&optional n to-newsgroup
8387 select-method action)
8388 "Move the current article to a different newsgroup.
8389 If N is a positive number, move the N next articles.
8390 If N is a negative number, move the N previous articles.
8391 If N is nil and any articles have been marked with the process mark,
8392 move those articles instead.
8393 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8394 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8395 re-spool using this method.
8397 For this function to work, both the current newsgroup and the
8398 newsgroup that you want to move to have to support the `request-move'
8399 and `request-accept' functions.
8401 ACTION can be either `move' (the default), `crosspost' or `copy'."
8404 (setq action 'move))
8405 ;; Check whether the source group supports the required functions.
8406 (cond ((and (eq action 'move)
8407 (not (gnus-check-backend-function
8408 'request-move-article gnus-newsgroup-name)))
8409 (error "The current group does not support article moving"))
8410 ((and (eq action 'crosspost)
8411 (not (gnus-check-backend-function
8412 'request-replace-article gnus-newsgroup-name)))
8413 (error "The current group does not support article editing")))
8414 (let ((articles (gnus-summary-work-articles n))
8415 (prefix (if (gnus-check-backend-function
8416 'request-move-article gnus-newsgroup-name)
8417 (gnus-group-real-prefix gnus-newsgroup-name)
8419 (names '((move "Move" "Moving")
8420 (copy "Copy" "Copying")
8421 (crosspost "Crosspost" "Crossposting")))
8422 (copy-buf (save-excursion
8423 (nnheader-set-temp-buffer " *copy article*")))
8424 (default-marks gnus-article-mark-lists)
8425 (no-expire-marks (delete '(expirable . expire)
8426 (copy-sequence gnus-article-mark-lists)))
8427 art-group to-method new-xref article to-groups)
8428 (unless (assq action names)
8429 (error "Unknown action %s" action))
8430 ;; We have to select an article to give
8431 ;; `gnus-read-move-group-name' an opportunity to suggest an
8432 ;; appropriate default.
8433 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8434 (let ((gnus-display-mime-function nil)
8435 (gnus-article-prepare-hook nil))
8436 (gnus-summary-select-article nil nil nil (car articles))))
8437 ;; Read the newsgroup name.
8438 (when (and (not to-newsgroup)
8439 (not select-method))
8441 (gnus-read-move-group-name
8442 (cadr (assq action names))
8443 (symbol-value (intern (format "gnus-current-%s-group" action)))
8445 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8446 (setq to-method (or select-method
8447 (gnus-server-to-method
8448 (gnus-group-method to-newsgroup))))
8449 ;; Check the method we are to move this article to...
8450 (unless (gnus-check-backend-function
8451 'request-accept-article (car to-method))
8452 (error "%s does not support article copying" (car to-method)))
8453 (unless (gnus-check-server to-method)
8454 (error "Can't open server %s" (car to-method)))
8455 (gnus-message 6 "%s to %s: %s..."
8456 (caddr (assq action names))
8457 (or (car select-method) to-newsgroup) articles)
8459 (setq article (pop articles))
8463 ;; Move the article.
8465 ;; Remove this article from future suppression.
8466 (gnus-dup-unsuppress-article article)
8467 (gnus-request-move-article
8468 article ; Article to move
8469 gnus-newsgroup-name ; From newsgroup
8470 (nth 1 (gnus-find-method-for-group
8471 gnus-newsgroup-name)) ; Server
8472 (list 'gnus-request-accept-article
8473 to-newsgroup (list 'quote select-method)
8474 (not articles) t) ; Accept form
8475 (not articles))) ; Only save nov last time
8476 ;; Copy the article.
8479 (set-buffer copy-buf)
8480 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8481 (gnus-request-accept-article
8482 to-newsgroup select-method (not articles) t))))
8483 ;; Crosspost the article.
8484 ((eq action 'crosspost)
8485 (let ((xref (message-tokenize-header
8486 (mail-header-xref (gnus-summary-article-header article))
8488 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8489 ":" (number-to-string article)))
8491 (setq xref (list (system-name))))
8494 (mapconcat 'identity
8495 (delete "Xref:" (delete new-xref xref))
8499 (set-buffer copy-buf)
8500 ;; First put the article in the destination group.
8501 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8502 (when (consp (setq art-group
8503 (gnus-request-accept-article
8504 to-newsgroup select-method (not articles))))
8505 (setq new-xref (concat new-xref " " (car art-group)
8507 (number-to-string (cdr art-group))))
8508 ;; Now we have the new Xrefs header, so we insert
8509 ;; it and replace the new article.
8510 (nnheader-replace-header "Xref" new-xref)
8511 (gnus-request-replace-article
8512 (cdr art-group) to-newsgroup (current-buffer))
8516 (gnus-message 1 "Couldn't %s article %s: %s"
8517 (cadr (assq action names)) article
8518 (nnheader-get-report (car to-method))))
8519 ((eq art-group 'junk)
8520 (when (eq action 'move)
8521 (gnus-summary-mark-article article gnus-canceled-mark)
8522 (gnus-message 4 "Deleted article %s" article)))
8524 (let* ((pto-group (gnus-group-prefixed-name
8525 (car art-group) to-method))
8527 (gnus-gethash pto-group gnus-newsrc-hashtb))
8528 (info (nth 2 entry))
8529 (to-group (gnus-info-group info))
8531 ;; Update the group that has been moved to.
8533 (memq action '(move copy)))
8534 (unless (member to-group to-groups)
8535 (push to-group to-groups))
8537 (unless (memq article gnus-newsgroup-unreads)
8538 (push 'read to-marks)
8540 info (gnus-add-to-range (gnus-info-read info)
8541 (list (cdr art-group)))))
8543 ;; See whether the article is to be put in the cache.
8544 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8547 (to-article (cdr art-group)))
8549 ;; Enter the article into the cache in the new group,
8550 ;; if that is required.
8551 (when gnus-use-cache
8552 (gnus-cache-possibly-enter-article
8554 (let ((header (copy-sequence
8555 (gnus-summary-article-header article))))
8556 (mail-header-set-number header to-article)
8558 (memq article gnus-newsgroup-marked)
8559 (memq article gnus-newsgroup-dormant)
8560 (memq article gnus-newsgroup-unreads)))
8562 (when gnus-preserve-marks
8563 ;; Copy any marks over to the new group.
8564 (when (and (equal to-group gnus-newsgroup-name)
8565 (not (memq article gnus-newsgroup-unreads)))
8566 ;; Mark this article as read in this group.
8567 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8568 (setcdr (gnus-active to-group) to-article)
8569 (setcdr gnus-newsgroup-active to-article))
8572 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8573 (when (memq article (symbol-value
8574 (intern (format "gnus-newsgroup-%s"
8576 (push (cdar marks) to-marks)
8577 ;; If the other group is the same as this group,
8578 ;; then we have to add the mark to the list.
8579 (when (equal to-group gnus-newsgroup-name)
8580 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8583 (intern (format "gnus-newsgroup-%s"
8585 ;; Copy the marks to other group.
8586 (gnus-add-marked-articles
8587 to-group (cdar marks) (list to-article) info)))
8588 (setq marks (cdr marks)))
8590 (gnus-request-set-mark to-group (list (list (list to-article)
8595 (concat "(gnus-group-set-info '"
8596 (gnus-prin1-to-string (gnus-get-info to-group))
8599 ;; Update the Xref header in this article to point to
8600 ;; the new crossposted article we have just created.
8601 (when (eq action 'crosspost)
8603 (set-buffer copy-buf)
8604 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8605 (nnheader-replace-header "Xref" new-xref)
8606 (gnus-request-replace-article
8607 article gnus-newsgroup-name (current-buffer)))))
8609 ;;;!!!Why is this necessary?
8610 (set-buffer gnus-summary-buffer)
8612 (gnus-summary-goto-subject article)
8613 (when (eq action 'move)
8614 (gnus-summary-mark-article article gnus-canceled-mark))))
8615 (gnus-summary-remove-process-mark article))
8616 ;; Re-activate all groups that have been moved to.
8618 (set-buffer gnus-group-buffer)
8619 (let ((gnus-group-marked to-groups))
8620 (gnus-group-get-new-news-this-group nil t)))
8622 (gnus-kill-buffer copy-buf)
8623 (gnus-summary-position-point)
8624 (gnus-set-mode-line 'summary)))
8626 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8627 "Move the current article to a different newsgroup.
8628 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8629 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8630 re-spool using this method."
8632 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8634 (defun gnus-summary-crosspost-article (&optional n)
8635 "Crosspost the current article to some other group."
8637 (gnus-summary-move-article n nil nil 'crosspost))
8639 (defcustom gnus-summary-respool-default-method nil
8640 "Default method type for respooling an article.
8641 If nil, use to the current newsgroup method."
8643 :group 'gnus-summary-mail)
8645 (defun gnus-summary-respool-article (&optional n method)
8646 "Respool the current article.
8647 The article will be squeezed through the mail spooling process again,
8648 which means that it will be put in some mail newsgroup or other
8649 depending on `nnmail-split-methods'.
8650 If N is a positive number, respool the N next articles.
8651 If N is a negative number, respool the N previous articles.
8652 If N is nil and any articles have been marked with the process mark,
8653 respool those articles instead.
8655 Respooling can be done both from mail groups and \"real\" newsgroups.
8656 In the former case, the articles in question will be moved from the
8657 current group into whatever groups they are destined to. In the
8658 latter case, they will be copied into the relevant groups."
8660 (list current-prefix-arg
8661 (let* ((methods (gnus-methods-using 'respool))
8663 (symbol-name (or gnus-summary-respool-default-method
8664 (car (gnus-find-method-for-group
8665 gnus-newsgroup-name)))))
8667 (gnus-completing-read-with-default
8668 methname "What backend do you want to use when respooling?"
8669 methods nil t nil 'gnus-mail-method-history))
8672 ((zerop (length (setq ms (gnus-servers-using-backend
8674 (list (intern method) ""))
8678 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8679 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8682 (error "No method given for respooling"))
8683 (if (assoc (symbol-name
8684 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8685 (gnus-methods-using 'respool))
8686 (gnus-summary-move-article n nil method)
8687 (gnus-summary-copy-article n nil method)))
8689 (defun gnus-summary-import-article (file &optional edit)
8690 "Import an arbitrary file into a mail newsgroup."
8691 (interactive "fImport file: \nP")
8692 (let ((group gnus-newsgroup-name)
8693 (now (current-time))
8694 atts lines group-art)
8695 (unless (gnus-check-backend-function 'request-accept-article group)
8696 (error "%s does not support article importing" group))
8697 (or (file-readable-p file)
8698 (not (file-regular-p file))
8699 (error "Can't read %s" file))
8701 (set-buffer (gnus-get-buffer-create " *import file*"))
8703 (nnheader-insert-file-contents file)
8704 (goto-char (point-min))
8705 (if (nnheader-article-p)
8707 (goto-char (point-min))
8708 (search-forward "\n\n" nil t)
8709 (narrow-to-region (point-min) (1- (point)))
8710 (goto-char (point-min))
8711 (unless (re-search-forward "^date:" nil t)
8712 (goto-char (point-max))
8713 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8714 ;; This doesn't look like an article, so we fudge some headers.
8715 (setq atts (file-attributes file)
8716 lines (count-lines (point-min) (point-max)))
8717 (insert "From: " (read-string "From: ") "\n"
8718 "Subject: " (read-string "Subject: ") "\n"
8719 "Date: " (message-make-date (nth 5 atts)) "\n"
8720 "Message-ID: " (message-make-message-id) "\n"
8721 "Lines: " (int-to-string lines) "\n"
8722 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8723 (setq group-art (gnus-request-accept-article group nil t))
8724 (kill-buffer (current-buffer)))
8725 (setq gnus-newsgroup-active (gnus-activate-group group))
8727 (gnus-summary-goto-article (cdr group-art) nil t)
8729 (gnus-summary-edit-article))))
8731 (defun gnus-summary-create-article ()
8732 "Create an article in a mail newsgroup."
8734 (let ((group gnus-newsgroup-name)
8735 (now (current-time))
8737 (unless (gnus-check-backend-function 'request-accept-article group)
8738 (error "%s does not support article importing" group))
8740 (set-buffer (gnus-get-buffer-create " *import file*"))
8742 (goto-char (point-min))
8743 ;; This doesn't look like an article, so we fudge some headers.
8744 (insert "From: " (read-string "From: ") "\n"
8745 "Subject: " (read-string "Subject: ") "\n"
8746 "Date: " (message-make-date now) "\n"
8747 "Message-ID: " (message-make-message-id) "\n")
8748 (setq group-art (gnus-request-accept-article group nil t))
8749 (kill-buffer (current-buffer)))
8750 (setq gnus-newsgroup-active (gnus-activate-group group))
8752 (gnus-summary-goto-article (cdr group-art) nil t)
8753 (gnus-summary-edit-article)))
8755 (defun gnus-summary-article-posted-p ()
8756 "Say whether the current (mail) article is available from news as well.
8757 This will be the case if the article has both been mailed and posted."
8759 (let ((id (mail-header-references (gnus-summary-article-header)))
8760 (gnus-override-method (car (gnus-refer-article-methods))))
8761 (if (gnus-request-head id "")
8762 (gnus-message 2 "The current message was found on %s"
8763 gnus-override-method)
8764 (gnus-message 2 "The current message couldn't be found on %s"
8765 gnus-override-method)
8768 (defun gnus-summary-expire-articles (&optional now)
8769 "Expire all articles that are marked as expirable in the current group."
8771 (when (gnus-check-backend-function
8772 'request-expire-articles gnus-newsgroup-name)
8773 ;; This backend supports expiry.
8774 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8775 (expirable (if total
8777 ;; We need to update the info for
8778 ;; this group for `gnus-list-of-read-articles'
8779 ;; to give us the right answer.
8780 (gnus-run-hooks 'gnus-exit-group-hook)
8781 (gnus-summary-update-info)
8782 (gnus-list-of-read-articles gnus-newsgroup-name))
8783 (setq gnus-newsgroup-expirable
8784 (sort gnus-newsgroup-expirable '<))))
8785 (expiry-wait (if now 'immediate
8786 (gnus-group-find-parameter
8787 gnus-newsgroup-name 'expiry-wait)))
8788 (nnmail-expiry-target
8789 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8790 nnmail-expiry-target))
8793 ;; There are expirable articles in this group, so we run them
8794 ;; through the expiry process.
8795 (gnus-message 6 "Expiring articles...")
8796 (unless (gnus-check-group gnus-newsgroup-name)
8797 (error "Can't open server for %s" gnus-newsgroup-name))
8798 ;; The list of articles that weren't expired is returned.
8801 (let ((nnmail-expiry-wait-function nil)
8802 (nnmail-expiry-wait expiry-wait))
8803 (setq es (gnus-request-expire-articles
8804 expirable gnus-newsgroup-name)))
8805 (setq es (gnus-request-expire-articles
8806 expirable gnus-newsgroup-name)))
8808 (setq gnus-newsgroup-expirable es))
8809 ;; We go through the old list of expirable, and mark all
8810 ;; really expired articles as nonexistent.
8811 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8812 (let ((gnus-use-cache nil))
8813 (dolist (article expirable)
8814 (when (and (not (memq article es))
8815 (gnus-data-find article))
8816 (gnus-summary-mark-article article gnus-canceled-mark))))))
8817 (gnus-message 6 "Expiring articles...done")))))
8819 (defun gnus-summary-expire-articles-now ()
8820 "Expunge all expirable articles in the current group.
8821 This means that *all* articles that are marked as expirable will be
8822 deleted forever, right now."
8824 (or gnus-expert-user
8826 "Are you really, really, really sure you want to delete all these messages? ")
8828 (gnus-summary-expire-articles t))
8830 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8831 (defun gnus-summary-delete-article (&optional n)
8832 "Delete the N next (mail) articles.
8833 This command actually deletes articles. This is not a marking
8834 command. The article will disappear forever from your life, never to
8836 If N is negative, delete backwards.
8837 If N is nil and articles have been marked with the process mark,
8838 delete these instead."
8840 (unless (gnus-check-backend-function 'request-expire-articles
8841 gnus-newsgroup-name)
8842 (error "The current newsgroup does not support article deletion"))
8843 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8844 (error "Couldn't open server"))
8845 ;; Compute the list of articles to delete.
8846 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8848 (if (and gnus-novice-user
8849 (not (gnus-yes-or-no-p
8850 (format "Do you really want to delete %s forever? "
8851 (if (> (length articles) 1)
8852 (format "these %s articles" (length articles))
8855 ;; Delete the articles.
8856 (setq not-deleted (gnus-request-expire-articles
8857 articles gnus-newsgroup-name 'force))
8859 (gnus-summary-remove-process-mark (car articles))
8860 ;; The backend might not have been able to delete the article
8862 (unless (memq (car articles) not-deleted)
8863 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8864 (setq articles (cdr articles)))
8866 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8867 (gnus-summary-position-point)
8868 (gnus-set-mode-line 'summary)
8871 (defun gnus-summary-edit-article (&optional force)
8872 "Edit the current article.
8873 This will have permanent effect only in mail groups.
8874 If FORCE is non-nil, allow editing of articles even in read-only
8878 (set-buffer gnus-summary-buffer)
8879 (let ((mail-parse-charset gnus-newsgroup-charset)
8880 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8881 (gnus-set-global-variables)
8882 (when (and (not force)
8883 (gnus-group-read-only-p))
8884 (error "The current newsgroup does not support article editing"))
8885 (gnus-summary-show-article t)
8886 (gnus-article-edit-article
8888 `(lambda (no-highlight)
8889 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8890 (message-options message-options)
8891 (message-options-set-recipient)
8892 (mail-parse-ignored-charsets
8893 ',gnus-newsgroup-ignored-charsets))
8894 (gnus-summary-edit-article-done
8895 ,(or (mail-header-references gnus-current-headers) "")
8896 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8898 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8900 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8902 "Make edits to the current article permanent."
8905 ;; The buffer restriction contains the entire article if it exists.
8906 (when (article-goto-body)
8907 (let ((lines (count-lines (point) (point-max)))
8908 (length (- (point-max) (point)))
8909 (case-fold-search t)
8910 (body (copy-marker (point))))
8911 (goto-char (point-min))
8912 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8913 (delete-region (match-beginning 1) (match-end 1))
8914 (insert (number-to-string length)))
8915 (goto-char (point-min))
8916 (when (re-search-forward
8917 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8918 (delete-region (match-beginning 1) (match-end 1))
8919 (insert (number-to-string length)))
8920 (goto-char (point-min))
8921 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8922 (delete-region (match-beginning 1) (match-end 1))
8923 (insert (number-to-string lines))))))
8924 ;; Replace the article.
8925 (let ((buf (current-buffer)))
8927 (insert-buffer-substring buf)
8929 (if (and (not read-only)
8930 (not (gnus-request-replace-article
8931 (cdr gnus-article-current) (car gnus-article-current)
8932 (current-buffer) t)))
8933 (error "Couldn't replace article")
8934 ;; Update the summary buffer.
8936 (equal (message-tokenize-header references " ")
8937 (message-tokenize-header
8938 (or (message-fetch-field "references") "") " ")))
8939 ;; We only have to update this line.
8942 (message-narrow-to-head)
8943 (let ((head (buffer-string))
8946 (insert (format "211 %d Article retrieved.\n"
8947 (cdr gnus-article-current)))
8950 (let ((nntp-server-buffer (current-buffer)))
8951 (setq header (car (gnus-get-newsgroup-headers
8953 (set-buffer gnus-summary-buffer)
8954 gnus-newsgroup-dependencies)
8957 (set-buffer gnus-summary-buffer)
8958 (gnus-data-set-header
8959 (gnus-data-find (cdr gnus-article-current))
8961 (gnus-summary-update-article-line
8962 (cdr gnus-article-current) header)
8963 (if (gnus-summary-goto-subject
8964 (cdr gnus-article-current) nil t)
8965 (gnus-summary-update-secondary-mark
8966 (cdr gnus-article-current))))))))
8968 (set-buffer (or buffer gnus-summary-buffer))
8969 (gnus-summary-update-article (cdr gnus-article-current))
8970 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8971 (gnus-summary-update-secondary-mark
8972 (cdr gnus-article-current))))
8973 ;; Prettify the article buffer again.
8974 (unless no-highlight
8976 (set-buffer gnus-article-buffer)
8977 ;;;!!! Fix this -- article should be rehighlighted.
8978 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8979 (set-buffer gnus-original-article-buffer)
8980 (gnus-request-article
8981 (cdr gnus-article-current)
8982 (car gnus-article-current) (current-buffer))))
8983 ;; Prettify the summary buffer line.
8984 (when (gnus-visual-p 'summary-highlight 'highlight)
8985 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8987 (defun gnus-summary-edit-wash (key)
8988 "Perform editing command KEY in the article buffer."
8992 (message "%s" (concat (this-command-keys) "- "))
8995 (gnus-summary-edit-article)
8996 (execute-kbd-macro (concat (this-command-keys) key))
8997 (gnus-article-edit-done))
9001 (defun gnus-summary-respool-query (&optional silent trace)
9002 "Query where the respool algorithm would put this article."
9004 (let (gnus-mark-article-hook)
9005 (gnus-summary-select-article)
9007 (set-buffer gnus-original-article-buffer)
9009 (message-narrow-to-head)
9010 (let ((groups (nnmail-article-group 'identity trace)))
9013 (message "This message would go to %s"
9014 (mapconcat 'car groups ", "))
9015 (message "This message would go to no groups"))
9018 (defun gnus-summary-respool-trace ()
9019 "Trace where the respool algorithm would put this article.
9020 Display a buffer showing all fancy splitting patterns which matched."
9022 (gnus-summary-respool-query nil t))
9024 ;; Summary marking commands.
9026 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9027 "Mark articles which has the same subject as read, and then select the next.
9028 If UNMARK is positive, remove any kind of mark.
9029 If UNMARK is negative, tick articles."
9032 (setq unmark (prefix-numeric-value unmark)))
9034 (gnus-summary-mark-same-subject
9035 (gnus-summary-article-subject) unmark)))
9036 ;; Select next unread article. If auto-select-same mode, should
9037 ;; select the first unread article.
9038 (gnus-summary-next-article t (and gnus-auto-select-same
9039 (gnus-summary-article-subject)))
9040 (gnus-message 7 "%d article%s marked as %s"
9041 count (if (= count 1) " is" "s are")
9042 (if unmark "unread" "read"))))
9044 (defun gnus-summary-kill-same-subject (&optional unmark)
9045 "Mark articles which has the same subject as read.
9046 If UNMARK is positive, remove any kind of mark.
9047 If UNMARK is negative, tick articles."
9050 (setq unmark (prefix-numeric-value unmark)))
9052 (gnus-summary-mark-same-subject
9053 (gnus-summary-article-subject) unmark)))
9054 ;; If marked as read, go to next unread subject.
9056 ;; Go to next unread subject.
9057 (gnus-summary-next-subject 1 t))
9058 (gnus-message 7 "%d articles are marked as %s"
9059 count (if unmark "unread" "read"))))
9061 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9062 "Mark articles with same SUBJECT as read, and return marked number.
9063 If optional argument UNMARK is positive, remove any kinds of marks.
9064 If optional argument UNMARK is negative, mark articles as unread instead."
9068 ((null unmark) ; Mark as read.
9071 (gnus-summary-mark-article-as-read gnus-killed-mark)
9072 (gnus-summary-show-thread) t)
9073 (gnus-summary-find-subject subject))
9074 (setq count (1+ count))))
9075 ((> unmark 0) ; Tick.
9078 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9079 (gnus-summary-show-thread) t)
9080 (gnus-summary-find-subject subject))
9081 (setq count (1+ count))))
9082 (t ; Mark as unread.
9085 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9086 (gnus-summary-show-thread) t)
9087 (gnus-summary-find-subject subject))
9088 (setq count (1+ count)))))
9089 (gnus-set-mode-line 'summary)
9090 ;; Return the number of marked articles.
9093 (defun gnus-summary-mark-as-processable (n &optional unmark)
9094 "Set the process mark on the next N articles.
9095 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9096 the process mark instead. The difference between N and the actual
9097 number of articles marked is returned."
9099 (if (and (null n) (gnus-region-active-p))
9100 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9101 (setq n (prefix-numeric-value n))
9102 (let ((backward (< n 0))
9107 (gnus-summary-remove-process-mark
9108 (gnus-summary-article-number))
9109 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9110 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9113 (gnus-message 7 "No more articles"))
9114 (gnus-summary-recenter)
9115 (gnus-summary-position-point)
9118 (defun gnus-summary-unmark-as-processable (n)
9119 "Remove the process mark from the next N articles.
9120 If N is negative, unmark backward instead. The difference between N and
9121 the actual number of articles unmarked is returned."
9123 (gnus-summary-mark-as-processable n t))
9125 (defun gnus-summary-unmark-all-processable ()
9126 "Remove the process mark from all articles."
9129 (while gnus-newsgroup-processable
9130 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9131 (gnus-summary-position-point))
9133 (defun gnus-summary-add-mark (article type)
9134 "Mark ARTICLE with a mark of TYPE."
9135 (let ((vtype (car (assq type gnus-article-mark-lists)))
9138 (error "No such mark type: %s" type)
9139 (setq var (intern (format "gnus-newsgroup-%s" type)))
9140 (set var (cons article (symbol-value var)))
9141 (if (memq type '(processable cached replied forwarded recent saved))
9142 (gnus-summary-update-secondary-mark article)
9143 ;;; !!! This is bogus. We should find out what primary
9144 ;;; !!! mark we want to set.
9145 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9147 (defun gnus-summary-mark-as-expirable (n)
9148 "Mark N articles forward as expirable.
9149 If N is negative, mark backward instead. The difference between N and
9150 the actual number of articles marked is returned."
9152 (gnus-summary-mark-forward n gnus-expirable-mark))
9154 (defun gnus-summary-mark-article-as-replied (article)
9155 "Mark ARTICLE as replied to and update the summary line.
9156 ARTICLE can also be a list of articles."
9157 (interactive (list (gnus-summary-article-number)))
9158 (let ((articles (if (listp article) article (list article))))
9159 (dolist (article articles)
9160 (push article gnus-newsgroup-replied)
9161 (let ((buffer-read-only nil))
9162 (when (gnus-summary-goto-subject article nil t)
9163 (gnus-summary-update-secondary-mark article))))))
9165 (defun gnus-summary-mark-article-as-forwarded (article)
9166 "Mark ARTICLE as forwarded and update the summary line.
9167 ARTICLE can also be a list of articles."
9168 (let ((articles (if (listp article) article (list article))))
9169 (dolist (article articles)
9170 (push article gnus-newsgroup-forwarded)
9171 (let ((buffer-read-only nil))
9172 (when (gnus-summary-goto-subject article nil t)
9173 (gnus-summary-update-secondary-mark article))))))
9175 (defun gnus-summary-set-bookmark (article)
9176 "Set a bookmark in current article."
9177 (interactive (list (gnus-summary-article-number)))
9178 (when (or (not (get-buffer gnus-article-buffer))
9179 (not gnus-current-article)
9180 (not gnus-article-current)
9181 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9182 (error "No current article selected"))
9183 ;; Remove old bookmark, if one exists.
9184 (let ((old (assq article gnus-newsgroup-bookmarks)))
9186 (setq gnus-newsgroup-bookmarks
9187 (delq old gnus-newsgroup-bookmarks))))
9188 ;; Set the new bookmark, which is on the form
9189 ;; (article-number . line-number-in-body).
9193 (set-buffer gnus-article-buffer)
9197 (goto-char (point-min))
9198 (search-forward "\n\n" nil t)
9201 gnus-newsgroup-bookmarks)
9202 (gnus-message 6 "A bookmark has been added to the current article."))
9204 (defun gnus-summary-remove-bookmark (article)
9205 "Remove the bookmark from the current article."
9206 (interactive (list (gnus-summary-article-number)))
9207 ;; Remove old bookmark, if one exists.
9208 (let ((old (assq article gnus-newsgroup-bookmarks)))
9211 (setq gnus-newsgroup-bookmarks
9212 (delq old gnus-newsgroup-bookmarks))
9213 (gnus-message 6 "Removed bookmark."))
9214 (gnus-message 6 "No bookmark in current article."))))
9216 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9217 (defun gnus-summary-mark-as-dormant (n)
9218 "Mark N articles forward as dormant.
9219 If N is negative, mark backward instead. The difference between N and
9220 the actual number of articles marked is returned."
9222 (gnus-summary-mark-forward n gnus-dormant-mark))
9224 (defun gnus-summary-set-process-mark (article)
9225 "Set the process mark on ARTICLE and update the summary line."
9226 (setq gnus-newsgroup-processable
9228 (delq article gnus-newsgroup-processable)))
9229 (when (gnus-summary-goto-subject article)
9230 (gnus-summary-show-thread)
9231 (gnus-summary-goto-subject article)
9232 (gnus-summary-update-secondary-mark article)))
9234 (defun gnus-summary-remove-process-mark (article)
9235 "Remove the process mark from ARTICLE and update the summary line."
9236 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9237 (when (gnus-summary-goto-subject article)
9238 (gnus-summary-show-thread)
9239 (gnus-summary-goto-subject article)
9240 (gnus-summary-update-secondary-mark article)))
9242 (defun gnus-summary-set-saved-mark (article)
9243 "Set the process mark on ARTICLE and update the summary line."
9244 (push article gnus-newsgroup-saved)
9245 (when (gnus-summary-goto-subject article)
9246 (gnus-summary-update-secondary-mark article)))
9248 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9249 "Mark N articles as read forwards.
9250 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9251 The difference between N and the actual number of articles marked is
9253 Iff NO-EXPIRE, auto-expiry will be inhibited."
9255 (gnus-summary-show-thread)
9256 (let ((backward (< n 0))
9257 (gnus-summary-goto-unread
9258 (and gnus-summary-goto-unread
9259 (not (eq gnus-summary-goto-unread 'never))
9260 (not (memq mark (list gnus-unread-mark
9261 gnus-ticked-mark gnus-dormant-mark)))))
9263 (mark (or mark gnus-del-mark)))
9265 (gnus-summary-mark-article nil mark no-expire)
9266 (zerop (gnus-summary-next-subject
9268 (and gnus-summary-goto-unread
9269 (not (eq gnus-summary-goto-unread 'never)))
9273 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9274 (gnus-summary-recenter)
9275 (gnus-summary-position-point)
9276 (gnus-set-mode-line 'summary)
9279 (defun gnus-summary-mark-article-as-read (mark)
9280 "Mark the current article quickly as read with MARK."
9281 (let ((article (gnus-summary-article-number)))
9282 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9283 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9284 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9285 (push (cons article mark) gnus-newsgroup-reads)
9286 ;; Possibly remove from cache, if that is used.
9287 (when gnus-use-cache
9288 (gnus-cache-enter-remove-article article))
9289 ;; Allow the backend to change the mark.
9290 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9291 ;; Check for auto-expiry.
9292 (when (and gnus-newsgroup-auto-expire
9293 (memq mark gnus-auto-expirable-marks))
9294 (setq mark gnus-expirable-mark)
9295 ;; Let the backend know about the mark change.
9296 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9297 (push article gnus-newsgroup-expirable))
9298 ;; Set the mark in the buffer.
9299 (gnus-summary-update-mark mark 'unread)
9302 (defun gnus-summary-mark-article-as-unread (mark)
9303 "Mark the current article quickly as unread with MARK."
9304 (let* ((article (gnus-summary-article-number))
9305 (old-mark (gnus-summary-article-mark article)))
9306 ;; Allow the backend to change the mark.
9307 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9308 (if (eq mark old-mark)
9312 (gnus-error 1 "Can't mark negative article numbers")
9314 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9315 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9316 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9317 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9318 (cond ((= mark gnus-ticked-mark)
9319 (setq gnus-newsgroup-marked
9320 (gnus-add-to-sorted-list gnus-newsgroup-marked
9322 ((= mark gnus-dormant-mark)
9323 (setq gnus-newsgroup-dormant
9324 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9327 (setq gnus-newsgroup-unreads
9328 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9330 (gnus-pull article gnus-newsgroup-reads)
9332 ;; See whether the article is to be put in the cache.
9334 (vectorp (gnus-summary-article-header article))
9336 (gnus-cache-possibly-enter-article
9337 gnus-newsgroup-name article
9338 (gnus-summary-article-header article)
9339 (= mark gnus-ticked-mark)
9340 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9343 (gnus-summary-update-mark mark 'unread)
9346 (defun gnus-summary-mark-article (&optional article mark no-expire)
9347 "Mark ARTICLE with MARK. MARK can be any character.
9348 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9349 `??' (dormant) and `?E' (expirable).
9350 If MARK is nil, then the default character `?r' is used.
9351 If ARTICLE is nil, then the article on the current line will be
9353 Iff NO-EXPIRE, auto-expiry will be inhibited."
9354 ;; The mark might be a string.
9355 (when (stringp mark)
9356 (setq mark (aref mark 0)))
9357 ;; If no mark is given, then we check auto-expiring.
9359 (setq mark gnus-del-mark))
9360 (when (and (not no-expire)
9361 gnus-newsgroup-auto-expire
9362 (memq mark gnus-auto-expirable-marks))
9363 (setq mark gnus-expirable-mark))
9364 (let ((article (or article (gnus-summary-article-number)))
9365 (old-mark (gnus-summary-article-mark article)))
9366 ;; Allow the backend to change the mark.
9367 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9368 (if (eq mark old-mark)
9371 (error "No article on current line"))
9372 (if (not (if (or (= mark gnus-unread-mark)
9373 (= mark gnus-ticked-mark)
9374 (= mark gnus-dormant-mark))
9375 (gnus-mark-article-as-unread article mark)
9376 (gnus-mark-article-as-read article mark)))
9378 ;; See whether the article is to be put in the cache.
9380 (not (= mark gnus-canceled-mark))
9381 (vectorp (gnus-summary-article-header article))
9383 (gnus-cache-possibly-enter-article
9384 gnus-newsgroup-name article
9385 (gnus-summary-article-header article)
9386 (= mark gnus-ticked-mark)
9387 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9389 (when (gnus-summary-goto-subject article nil t)
9390 (let ((buffer-read-only nil))
9391 (gnus-summary-show-thread)
9393 (gnus-summary-update-mark mark 'unread)
9396 (defun gnus-summary-update-secondary-mark (article)
9397 "Update the secondary (read, process, cache) mark."
9398 (gnus-summary-update-mark
9399 (cond ((memq article gnus-newsgroup-processable)
9401 ((memq article gnus-newsgroup-cached)
9403 ((memq article gnus-newsgroup-replied)
9405 ((memq article gnus-newsgroup-forwarded)
9406 gnus-forwarded-mark)
9407 ((memq article gnus-newsgroup-saved)
9409 ((memq article gnus-newsgroup-recent)
9411 ((memq article gnus-newsgroup-unseen)
9415 (when (gnus-visual-p 'summary-highlight 'highlight)
9416 (gnus-run-hooks 'gnus-summary-update-hook))
9419 (defun gnus-summary-update-mark (mark type)
9420 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9421 (buffer-read-only nil))
9422 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9424 (when (looking-at "\r")
9426 (when (<= (+ forward (point)) (point-max))
9427 ;; Go to the right position on the line.
9428 (goto-char (+ forward (point)))
9429 ;; Replace the old mark with the new mark.
9430 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9431 ;; Optionally update the marks by some user rule.
9432 (when (eq type 'unread)
9434 (gnus-data-find (gnus-summary-article-number)) mark)
9435 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9437 (defun gnus-mark-article-as-read (article &optional mark)
9438 "Enter ARTICLE in the pertinent lists and remove it from others."
9439 ;; Make the article expirable.
9440 (let ((mark (or mark gnus-del-mark)))
9441 (setq gnus-newsgroup-expirable
9442 (if (= mark gnus-expirable-mark)
9443 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9444 (delq article gnus-newsgroup-expirable)))
9445 ;; Remove from unread and marked lists.
9446 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9447 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9448 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9449 (push (cons article mark) gnus-newsgroup-reads)
9450 ;; Possibly remove from cache, if that is used.
9451 (when gnus-use-cache
9452 (gnus-cache-enter-remove-article article))
9455 (defun gnus-mark-article-as-unread (article &optional mark)
9456 "Enter ARTICLE in the pertinent lists and remove it from others."
9457 (let ((mark (or mark gnus-ticked-mark)))
9460 (gnus-error 1 "Can't mark negative article numbers")
9462 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9463 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9464 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9465 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9467 ;; Unsuppress duplicates?
9468 (when gnus-suppress-duplicates
9469 (gnus-dup-unsuppress-article article))
9471 (cond ((= mark gnus-ticked-mark)
9472 (setq gnus-newsgroup-marked
9473 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9474 ((= mark gnus-dormant-mark)
9475 (setq gnus-newsgroup-dormant
9476 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9478 (setq gnus-newsgroup-unreads
9479 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9480 (gnus-pull article gnus-newsgroup-reads)
9483 (defalias 'gnus-summary-mark-as-unread-forward
9484 'gnus-summary-tick-article-forward)
9485 (make-obsolete 'gnus-summary-mark-as-unread-forward
9486 'gnus-summary-tick-article-forward)
9487 (defun gnus-summary-tick-article-forward (n)
9488 "Tick N articles forwards.
9489 If N is negative, tick backwards instead.
9490 The difference between N and the number of articles ticked is returned."
9492 (gnus-summary-mark-forward n gnus-ticked-mark))
9494 (defalias 'gnus-summary-mark-as-unread-backward
9495 'gnus-summary-tick-article-backward)
9496 (make-obsolete 'gnus-summary-mark-as-unread-backward
9497 'gnus-summary-tick-article-backward)
9498 (defun gnus-summary-tick-article-backward (n)
9499 "Tick N articles backwards.
9500 The difference between N and the number of articles ticked is returned."
9502 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9504 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9505 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9506 (defun gnus-summary-tick-article (&optional article clear-mark)
9507 "Mark current article as unread.
9508 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9509 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9511 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9514 (defun gnus-summary-mark-as-read-forward (n)
9515 "Mark N articles as read forwards.
9516 If N is negative, mark backwards instead.
9517 The difference between N and the actual number of articles marked is
9520 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9522 (defun gnus-summary-mark-as-read-backward (n)
9523 "Mark the N articles as read backwards.
9524 The difference between N and the actual number of articles marked is
9527 (gnus-summary-mark-forward
9528 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9530 (defun gnus-summary-mark-as-read (&optional article mark)
9531 "Mark current article as read.
9532 ARTICLE specifies the article to be marked as read.
9533 MARK specifies a string to be inserted at the beginning of the line."
9534 (gnus-summary-mark-article article mark))
9536 (defun gnus-summary-clear-mark-forward (n)
9537 "Clear marks from N articles forward.
9538 If N is negative, clear backward instead.
9539 The difference between N and the number of marks cleared is returned."
9541 (gnus-summary-mark-forward n gnus-unread-mark))
9543 (defun gnus-summary-clear-mark-backward (n)
9544 "Clear marks from N articles backward.
9545 The difference between N and the number of marks cleared is returned."
9547 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9549 (defun gnus-summary-mark-unread-as-read ()
9550 "Intended to be used by `gnus-summary-mark-article-hook'."
9551 (when (memq gnus-current-article gnus-newsgroup-unreads)
9552 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9554 (defun gnus-summary-mark-read-and-unread-as-read ()
9555 "Intended to be used by `gnus-summary-mark-article-hook'."
9556 (let ((mark (gnus-summary-article-mark)))
9557 (when (or (gnus-unread-mark-p mark)
9558 (gnus-read-mark-p mark))
9559 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9561 (defun gnus-summary-mark-unread-as-ticked ()
9562 "Intended to be used by `gnus-summary-mark-article-hook'."
9563 (when (memq gnus-current-article gnus-newsgroup-unreads)
9564 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9566 (defun gnus-summary-mark-region-as-read (point mark all)
9567 "Mark all unread articles between point and mark as read.
9568 If given a prefix, mark all articles between point and mark as read,
9569 even ticked and dormant ones."
9570 (interactive "r\nP")
9579 (memq (setq article (gnus-summary-article-number))
9580 gnus-newsgroup-unreads))
9581 (gnus-summary-mark-article article gnus-del-mark))
9583 (gnus-summary-find-next))))))
9585 (defun gnus-summary-mark-below (score mark)
9586 "Mark articles with score less than SCORE with MARK."
9587 (interactive "P\ncMark: ")
9588 (setq score (if score
9589 (prefix-numeric-value score)
9590 (or gnus-summary-default-score 0)))
9592 (set-buffer gnus-summary-buffer)
9593 (goto-char (point-min))
9596 (and (< (gnus-summary-article-score) score)
9597 (gnus-summary-mark-article nil mark))
9598 (gnus-summary-find-next)))))
9600 (defun gnus-summary-kill-below (&optional score)
9601 "Mark articles with score below SCORE as read."
9603 (gnus-summary-mark-below score gnus-killed-mark))
9605 (defun gnus-summary-clear-above (&optional score)
9606 "Clear all marks from articles with score above SCORE."
9608 (gnus-summary-mark-above score gnus-unread-mark))
9610 (defun gnus-summary-tick-above (&optional score)
9611 "Tick all articles with score above SCORE."
9613 (gnus-summary-mark-above score gnus-ticked-mark))
9615 (defun gnus-summary-mark-above (score mark)
9616 "Mark articles with score over SCORE with MARK."
9617 (interactive "P\ncMark: ")
9618 (setq score (if score
9619 (prefix-numeric-value score)
9620 (or gnus-summary-default-score 0)))
9622 (set-buffer gnus-summary-buffer)
9623 (goto-char (point-min))
9625 (when (> (gnus-summary-article-score) score)
9626 (gnus-summary-mark-article nil mark))
9628 (gnus-summary-find-next)))))
9630 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9631 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9632 (defun gnus-summary-limit-include-expunged (&optional no-error)
9633 "Display all the hidden articles that were expunged for low scores."
9635 (let ((buffer-read-only nil))
9636 (let ((scored gnus-newsgroup-scored)
9639 (unless (gnus-summary-article-header (caar scored))
9640 (and (setq h (gnus-number-to-header (caar scored)))
9641 (< (cdar scored) gnus-summary-expunge-below)
9643 (setq scored (cdr scored)))
9645 (when (not no-error)
9646 (error "No expunged articles hidden"))
9647 (goto-char (point-min))
9648 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9649 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9650 (mapcar (lambda (x) (push (mail-header-number x)
9651 gnus-newsgroup-limit))
9653 (gnus-summary-prepare-unthreaded (nreverse headers))
9654 (goto-char (point-min))
9655 (gnus-summary-position-point)
9658 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9659 "Mark all unread articles in this newsgroup as read.
9660 If prefix argument ALL is non-nil, ticked and dormant articles will
9661 also be marked as read.
9662 If QUIETLY is non-nil, no questions will be asked.
9663 If TO-HERE is non-nil, it should be a point in the buffer. All
9664 articles before (after, if REVERSE is set) this point will be marked as read.
9665 Note that this function will only catch up the unread article
9666 in the current summary buffer limitation.
9667 The number of articles marked as read is returned."
9672 (not gnus-interactive-catchup) ;Without confirmation?
9676 "Mark absolutely all articles as read? "
9677 "Mark all unread articles as read? ")))
9679 (not gnus-newsgroup-adaptive)
9680 (not gnus-newsgroup-auto-expire)
9681 (not gnus-suppress-duplicates)
9682 (or (not gnus-use-cache)
9683 (eq gnus-use-cache 'passive)))
9686 (setq gnus-newsgroup-marked nil
9687 gnus-newsgroup-dormant nil))
9688 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9689 ;; We actually mark all articles as canceled, which we
9690 ;; have to do when using auto-expiry or adaptive scoring.
9691 (gnus-summary-show-all-threads)
9692 (if (and to-here reverse)
9696 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9697 (gnus-summary-find-next (not all) nil nil t))))
9698 (when (gnus-summary-first-subject (not all) t)
9700 (if to-here (< (point) to-here) t)
9701 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9702 (gnus-summary-find-next (not all) nil nil t)))))
9703 (gnus-set-mode-line 'summary))
9705 (gnus-summary-position-point)))
9707 (defun gnus-summary-catchup-to-here (&optional all)
9708 "Mark all unticked articles before the current one as read.
9709 If ALL is non-nil, also mark ticked and dormant articles as read."
9712 (gnus-save-hidden-threads
9713 (let ((beg (point)))
9714 ;; We check that there are unread articles.
9715 (when (or all (gnus-summary-find-prev))
9716 (gnus-summary-catchup all t beg)))))
9717 (gnus-summary-position-point))
9719 (defun gnus-summary-catchup-from-here (&optional all)
9720 "Mark all unticked articles after the current one as read.
9721 If ALL is non-nil, also mark ticked and dormant articles as read."
9724 (gnus-save-hidden-threads
9725 (let ((beg (point)))
9726 ;; We check that there are unread articles.
9727 (when (or all (gnus-summary-find-next))
9728 (gnus-summary-catchup all t beg nil t)))))
9729 (gnus-summary-position-point))
9731 (defun gnus-summary-catchup-all (&optional quietly)
9732 "Mark all articles in this newsgroup as read."
9734 (gnus-summary-catchup t quietly))
9736 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9737 "Mark all unread articles in this group as read, then exit.
9738 If prefix argument ALL is non-nil, all articles are marked as read.
9739 If QUIETLY is non-nil, no questions will be asked."
9741 (when (gnus-summary-catchup all quietly nil 'fast)
9742 ;; Select next newsgroup or exit.
9743 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9744 (eq gnus-auto-select-next 'quietly))
9745 (gnus-summary-next-group nil)
9746 (gnus-summary-exit))))
9748 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9749 "Mark all articles in this newsgroup as read, and then exit."
9751 (gnus-summary-catchup-and-exit t quietly))
9753 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9754 "Mark all articles in this group as read and select the next group.
9755 If given a prefix, mark all articles, unread as well as ticked, as
9759 (gnus-summary-catchup all))
9760 (gnus-summary-next-group))
9766 (defmacro gnus-with-article (article &rest forms)
9767 "Select ARTICLE and perform FORMS in the original article buffer.
9768 Then replace the article with the result."
9770 ;; We don't want the article to be marked as read.
9771 (let (gnus-mark-article-hook)
9772 (gnus-summary-select-article t t nil ,article))
9773 (set-buffer gnus-original-article-buffer)
9775 (if (not (gnus-check-backend-function
9776 'request-replace-article (car gnus-article-current)))
9777 (gnus-message 5 "Read-only group; not replacing")
9778 (unless (gnus-request-replace-article
9779 ,article (car gnus-article-current)
9781 (error "Couldn't replace article")))
9782 ;; The cache and backlog have to be flushed somewhat.
9783 (when gnus-keep-backlog
9784 (gnus-backlog-remove-article
9785 (car gnus-article-current) (cdr gnus-article-current)))
9786 (when gnus-use-cache
9787 (gnus-cache-update-article
9788 (car gnus-article-current) (cdr gnus-article-current)))))
9790 (put 'gnus-with-article 'lisp-indent-function 1)
9791 (put 'gnus-with-article 'edebug-form-spec '(form body))
9793 ;; Thread-based commands.
9795 (defun gnus-summary-articles-in-thread (&optional article)
9796 "Return a list of all articles in the current thread.
9797 If ARTICLE is non-nil, return all articles in the thread that starts
9799 (let* ((article (or article (gnus-summary-article-number)))
9800 (data (gnus-data-find-list article))
9801 (top-level (gnus-data-level (car data)))
9803 (cond ((null gnus-thread-operation-ignore-subject)
9804 (gnus-simplify-subject-re
9805 (mail-header-subject (gnus-data-header (car data)))))
9806 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9807 (gnus-simplify-subject-fuzzy
9808 (mail-header-subject (gnus-data-header (car data)))))
9810 (end-point (save-excursion
9811 (if (gnus-summary-go-to-next-thread)
9812 (point) (point-max))))
9815 (< (gnus-data-pos (car data)) end-point))
9816 (when (or (not top-subject)
9817 (string= top-subject
9818 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9819 (gnus-simplify-subject-fuzzy
9820 (mail-header-subject
9821 (gnus-data-header (car data))))
9822 (gnus-simplify-subject-re
9823 (mail-header-subject
9824 (gnus-data-header (car data)))))))
9825 (push (gnus-data-number (car data)) articles))
9826 (unless (and (setq data (cdr data))
9827 (> (gnus-data-level (car data)) top-level))
9829 ;; Return the list of articles.
9830 (nreverse articles)))
9832 (defun gnus-summary-rethread-current ()
9833 "Rethread the thread the current article is part of."
9835 (let* ((gnus-show-threads t)
9836 (article (gnus-summary-article-number))
9837 (id (mail-header-id (gnus-summary-article-header)))
9838 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9840 (error "No article on the current line"))
9841 (gnus-rebuild-thread id)
9842 (gnus-summary-goto-subject article)))
9844 (defun gnus-summary-reparent-thread ()
9845 "Make the current article child of the marked (or previous) article.
9847 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9848 is non-nil or the Subject: of both articles are the same."
9850 (unless (not (gnus-group-read-only-p))
9851 (error "The current newsgroup does not support article editing"))
9852 (unless (<= (length gnus-newsgroup-processable) 1)
9853 (error "No more than one article may be marked"))
9854 (save-window-excursion
9855 (let ((gnus-article-buffer " *reparent*")
9856 (current-article (gnus-summary-article-number))
9857 ;; First grab the marked article, otherwise one line up.
9858 (parent-article (if (not (null gnus-newsgroup-processable))
9859 (car gnus-newsgroup-processable)
9861 (if (eq (forward-line -1) 0)
9862 (gnus-summary-article-number)
9863 (error "Beginning of summary buffer"))))))
9864 (unless (not (eq current-article parent-article))
9865 (error "An article may not be self-referential"))
9866 (let ((message-id (mail-header-id
9867 (gnus-summary-article-header parent-article))))
9868 (unless (and message-id (not (equal message-id "")))
9869 (error "No message-id in desired parent"))
9870 (gnus-with-article current-article
9872 (goto-char (point-min))
9873 (message-narrow-to-head)
9874 (if (re-search-forward "^References: " nil t)
9876 (re-search-forward "^[^ \t]" nil t)
9879 (insert " " message-id))
9880 (insert "References: " message-id "\n"))))
9881 (set-buffer gnus-summary-buffer)
9882 (gnus-summary-unmark-all-processable)
9883 (gnus-summary-update-article current-article)
9884 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9885 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9886 (gnus-summary-rethread-current)
9887 (gnus-message 3 "Article %d is now the child of article %d"
9888 current-article parent-article)))))
9890 (defun gnus-summary-toggle-threads (&optional arg)
9891 "Toggle showing conversation threads.
9892 If ARG is positive number, turn showing conversation threads on."
9894 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9895 (setq gnus-show-threads
9896 (if (null arg) (not gnus-show-threads)
9897 (> (prefix-numeric-value arg) 0)))
9898 (gnus-summary-prepare)
9899 (gnus-summary-goto-subject current)
9900 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9901 (gnus-summary-position-point)))
9903 (defun gnus-summary-show-all-threads ()
9907 (let ((buffer-read-only nil))
9908 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9909 (gnus-summary-position-point))
9911 (defun gnus-summary-show-thread ()
9912 "Show thread subtrees.
9913 Returns nil if no thread was there to be shown."
9915 (let ((buffer-read-only nil)
9917 ;; first goto end then to beg, to have point at beg after let
9918 (end (progn (end-of-line) (point)))
9919 (beg (progn (beginning-of-line) (point))))
9921 ;; Any hidden lines here?
9922 (search-forward "\r" end t)
9923 (subst-char-in-region beg end ?\^M ?\n t)
9925 (gnus-summary-position-point))))
9927 (defun gnus-summary-maybe-hide-threads ()
9928 "If requested, hide the threads that should be hidden."
9929 (when (and gnus-show-threads
9930 gnus-thread-hide-subtree)
9931 (gnus-summary-hide-all-threads
9932 (if (or (consp gnus-thread-hide-subtree)
9933 (gnus-functionp gnus-thread-hide-subtree))
9934 (gnus-make-predicate gnus-thread-hide-subtree)
9937 ;;; Hiding predicates.
9939 (defun gnus-article-unread-p (header)
9940 (memq (mail-header-number header) gnus-newsgroup-unreads))
9942 (defun gnus-article-unseen-p (header)
9943 (memq (mail-header-number header) gnus-newsgroup-unseen))
9945 (defun gnus-map-articles (predicate articles)
9946 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
9947 (apply 'gnus-or (mapcar predicate
9948 (mapcar 'gnus-summary-article-header articles))))
9950 (defun gnus-summary-hide-all-threads (&optional predicate)
9951 "Hide all thread subtrees.
9952 If PREDICATE is supplied, threads that satisfy this predicate
9953 will not be hidden."
9956 (goto-char (point-min))
9959 (when (or (not predicate)
9961 predicate (gnus-summary-article-children)))
9962 (gnus-summary-hide-thread))
9963 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
9964 (gnus-summary-position-point))
9966 (defun gnus-summary-hide-thread ()
9967 "Hide thread subtrees.
9968 If PREDICATE is supplied, threads that satisfy this predicate
9970 Returns nil if no threads were there to be hidden."
9972 (let ((buffer-read-only nil)
9974 (article (gnus-summary-article-number)))
9976 ;; Go forward until either the buffer ends or the subthread
9978 (when (and (not (eobp))
9979 (or (zerop (gnus-summary-next-thread 1 t))
9980 (goto-char (point-max))))
9982 (if (and (> (point) start)
9983 (search-backward "\n" start t))
9985 (subst-char-in-region start (point) ?\n ?\^M)
9986 (gnus-summary-goto-subject article))
9990 (defun gnus-summary-go-to-next-thread (&optional previous)
9991 "Go to the same level (or less) next thread.
9992 If PREVIOUS is non-nil, go to previous thread instead.
9993 Return the article number moved to, or nil if moving was impossible."
9994 (let ((level (gnus-summary-thread-level))
9995 (way (if previous -1 1))
9998 (while (and (not (eobp))
9999 (< level (gnus-summary-thread-level)))
10000 (forward-line way))
10007 (gnus-summary-article-number)
10008 (goto-char beg)))))
10010 (defun gnus-summary-next-thread (n &optional silent)
10011 "Go to the same level next N'th thread.
10012 If N is negative, search backward instead.
10013 Returns the difference between N and the number of skips actually
10016 If SILENT, don't output messages."
10018 (let ((backward (< n 0))
10020 (while (and (> n 0)
10021 (gnus-summary-go-to-next-thread backward))
10024 (gnus-summary-position-point))
10025 (when (and (not silent) (/= 0 n))
10026 (gnus-message 7 "No more threads"))
10029 (defun gnus-summary-prev-thread (n)
10030 "Go to the same level previous N'th thread.
10031 Returns the difference between N and the number of skips actually
10034 (gnus-summary-next-thread (- n)))
10036 (defun gnus-summary-go-down-thread ()
10037 "Go down one level in the current thread."
10038 (let ((children (gnus-summary-article-children)))
10040 (gnus-summary-goto-subject (car children)))))
10042 (defun gnus-summary-go-up-thread ()
10043 "Go up one level in the current thread."
10044 (let ((parent (gnus-summary-article-parent)))
10046 (gnus-summary-goto-subject parent))))
10048 (defun gnus-summary-down-thread (n)
10049 "Go down thread N steps.
10050 If N is negative, go up instead.
10051 Returns the difference between N and how many steps down that were
10056 (while (and (> n 0)
10057 (if up (gnus-summary-go-up-thread)
10058 (gnus-summary-go-down-thread)))
10060 (gnus-summary-position-point)
10062 (gnus-message 7 "Can't go further"))
10065 (defun gnus-summary-up-thread (n)
10066 "Go up thread N steps.
10067 If N is negative, go down instead.
10068 Returns the difference between N and how many steps down that were
10071 (gnus-summary-down-thread (- n)))
10073 (defun gnus-summary-top-thread ()
10074 "Go to the top of the thread."
10076 (while (gnus-summary-go-up-thread))
10077 (gnus-summary-article-number))
10079 (defun gnus-summary-kill-thread (&optional unmark)
10080 "Mark articles under current thread as read.
10081 If the prefix argument is positive, remove any kinds of marks.
10082 If the prefix argument is negative, tick articles instead."
10085 (setq unmark (prefix-numeric-value unmark)))
10086 (let ((articles (gnus-summary-articles-in-thread)))
10088 ;; Expand the thread.
10089 (gnus-summary-show-thread)
10090 ;; Mark all the articles.
10092 (gnus-summary-goto-subject (car articles))
10093 (cond ((null unmark)
10094 (gnus-summary-mark-article-as-read gnus-killed-mark))
10096 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10098 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10099 (setq articles (cdr articles))))
10100 ;; Hide killed subtrees.
10102 gnus-thread-hide-killed
10103 (gnus-summary-hide-thread))
10104 ;; If marked as read, go to next unread subject.
10105 (when (null unmark)
10106 ;; Go to next unread subject.
10107 (gnus-summary-next-subject 1 t)))
10108 (gnus-set-mode-line 'summary))
10110 ;; Summary sorting commands
10112 (defun gnus-summary-sort-by-number (&optional reverse)
10113 "Sort the summary buffer by article number.
10114 Argument REVERSE means reverse order."
10116 (gnus-summary-sort 'number reverse))
10118 (defun gnus-summary-sort-by-author (&optional reverse)
10119 "Sort the summary buffer by author name alphabetically.
10120 If `case-fold-search' is non-nil, case of letters is ignored.
10121 Argument REVERSE means reverse order."
10123 (gnus-summary-sort 'author reverse))
10125 (defun gnus-summary-sort-by-subject (&optional reverse)
10126 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10127 If `case-fold-search' is non-nil, case of letters is ignored.
10128 Argument REVERSE means reverse order."
10130 (gnus-summary-sort 'subject reverse))
10132 (defun gnus-summary-sort-by-date (&optional reverse)
10133 "Sort the summary buffer by date.
10134 Argument REVERSE means reverse order."
10136 (gnus-summary-sort 'date reverse))
10138 (defun gnus-summary-sort-by-score (&optional reverse)
10139 "Sort the summary buffer by score.
10140 Argument REVERSE means reverse order."
10142 (gnus-summary-sort 'score reverse))
10144 (defun gnus-summary-sort-by-lines (&optional reverse)
10145 "Sort the summary buffer by the number of lines.
10146 Argument REVERSE means reverse order."
10148 (gnus-summary-sort 'lines reverse))
10150 (defun gnus-summary-sort-by-chars (&optional reverse)
10151 "Sort the summary buffer by article length.
10152 Argument REVERSE means reverse order."
10154 (gnus-summary-sort 'chars reverse))
10156 (defun gnus-summary-sort-by-original (&optional reverse)
10157 "Sort the summary buffer using the default sorting method.
10158 Argument REVERSE means reverse order."
10160 (let* ((buffer-read-only)
10161 (gnus-summary-prepare-hook nil))
10162 ;; We do the sorting by regenerating the threads.
10163 (gnus-summary-prepare)
10164 ;; Hide subthreads if needed.
10165 (gnus-summary-maybe-hide-threads)))
10167 (defun gnus-summary-sort (predicate reverse)
10168 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10169 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10170 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10171 (gnus-thread-sort-functions
10176 (gnus-sort-gathered-threads-function
10177 gnus-thread-sort-functions)
10178 (gnus-article-sort-functions
10182 (,article t2 t1))))
10184 (gnus-summary-prepare-hook nil))
10185 ;; We do the sorting by regenerating the threads.
10186 (gnus-summary-prepare)
10187 ;; Hide subthreads if needed.
10188 (gnus-summary-maybe-hide-threads)))
10190 ;; Summary saving commands.
10192 (defun gnus-summary-save-article (&optional n not-saved)
10193 "Save the current article using the default saver function.
10194 If N is a positive number, save the N next articles.
10195 If N is a negative number, save the N previous articles.
10196 If N is nil and any articles have been marked with the process mark,
10197 save those articles instead.
10198 The variable `gnus-default-article-saver' specifies the saver function."
10200 (let* ((articles (gnus-summary-work-articles n))
10201 (save-buffer (save-excursion
10202 (nnheader-set-temp-buffer " *Gnus Save*")))
10203 (num (length articles))
10205 (dolist (article articles)
10206 (setq header (gnus-summary-article-header article))
10207 (if (not (vectorp header))
10208 ;; This is a pseudo-article.
10209 (if (assq 'name header)
10210 (gnus-copy-file (cdr (assq 'name header)))
10211 (gnus-message 1 "Article %d is unsaveable" article))
10212 ;; This is a real article.
10213 (save-window-excursion
10214 (let ((gnus-display-mime-function nil)
10215 (gnus-article-prepare-hook nil))
10216 (gnus-summary-select-article t nil nil article)))
10218 (set-buffer save-buffer)
10220 (insert-buffer-substring gnus-original-article-buffer))
10221 (setq file (gnus-article-save save-buffer file num))
10222 (gnus-summary-remove-process-mark article)
10224 (gnus-summary-set-saved-mark article))))
10225 (gnus-kill-buffer save-buffer)
10226 (gnus-summary-position-point)
10227 (gnus-set-mode-line 'summary)
10230 (defun gnus-summary-pipe-output (&optional arg)
10231 "Pipe the current article to a subprocess.
10232 If N is a positive number, pipe the N next articles.
10233 If N is a negative number, pipe the N previous articles.
10234 If N is nil and any articles have been marked with the process mark,
10235 pipe those articles instead."
10237 (require 'gnus-art)
10238 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10239 (gnus-summary-save-article arg t))
10240 (let ((buffer (get-buffer "*Shell Command Output*")))
10242 (with-current-buffer buffer (> (point-max) (point-min))))
10243 (gnus-configure-windows 'pipe))))
10245 (defun gnus-summary-save-article-mail (&optional arg)
10246 "Append the current article to an mail file.
10247 If N is a positive number, save the N next articles.
10248 If N is a negative number, save the N previous articles.
10249 If N is nil and any articles have been marked with the process mark,
10250 save those articles instead."
10252 (require 'gnus-art)
10253 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10254 (gnus-summary-save-article arg)))
10256 (defun gnus-summary-save-article-rmail (&optional arg)
10257 "Append the current article to an rmail file.
10258 If N is a positive number, save the N next articles.
10259 If N is a negative number, save the N previous articles.
10260 If N is nil and any articles have been marked with the process mark,
10261 save those articles instead."
10263 (require 'gnus-art)
10264 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10265 (gnus-summary-save-article arg)))
10267 (defun gnus-summary-save-article-file (&optional arg)
10268 "Append the current article to a file.
10269 If N is a positive number, save the N next articles.
10270 If N is a negative number, save the N previous articles.
10271 If N is nil and any articles have been marked with the process mark,
10272 save those articles instead."
10274 (require 'gnus-art)
10275 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10276 (gnus-summary-save-article arg)))
10278 (defun gnus-summary-write-article-file (&optional arg)
10279 "Write the current article to a file, deleting the previous file.
10280 If N is a positive number, save the N next articles.
10281 If N is a negative number, save the N previous articles.
10282 If N is nil and any articles have been marked with the process mark,
10283 save those articles instead."
10285 (require 'gnus-art)
10286 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10287 (gnus-summary-save-article arg)))
10289 (defun gnus-summary-save-article-body-file (&optional arg)
10290 "Append the current article body to a file.
10291 If N is a positive number, save the N next articles.
10292 If N is a negative number, save the N previous articles.
10293 If N is nil and any articles have been marked with the process mark,
10294 save those articles instead."
10296 (require 'gnus-art)
10297 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10298 (gnus-summary-save-article arg)))
10300 (defun gnus-summary-muttprint (&optional arg)
10301 "Print the current article using Muttprint.
10302 If N is a positive number, save the N next articles.
10303 If N is a negative number, save the N previous articles.
10304 If N is nil and any articles have been marked with the process mark,
10305 save those articles instead."
10307 (require 'gnus-art)
10308 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10309 (gnus-summary-save-article arg t)))
10311 (defun gnus-summary-pipe-message (program)
10312 "Pipe the current article through PROGRAM."
10313 (interactive "sProgram: ")
10314 (gnus-summary-select-article)
10315 (let ((mail-header-separator ""))
10316 (gnus-eval-in-buffer-window gnus-article-buffer
10319 (let ((start (window-start))
10321 (message-pipe-buffer-body program)
10322 (set-window-start (get-buffer-window (current-buffer)) start))))))
10324 (defun gnus-get-split-value (methods)
10325 "Return a value based on the split METHODS."
10326 (let (split-name method result match)
10329 (set-buffer gnus-original-article-buffer)
10331 (nnheader-narrow-to-headers)
10332 (while (and methods (not split-name))
10333 (goto-char (point-min))
10334 (setq method (pop methods))
10335 (setq match (car method))
10338 ;; Regular expression.
10340 (re-search-forward match nil t)))
10341 ((gnus-functionp match)
10345 (setq result (funcall match gnus-newsgroup-name))))
10350 (setq result (eval match)))))
10351 (setq split-name (cdr method))
10352 (cond ((stringp result)
10353 (push (expand-file-name
10354 result gnus-article-save-directory)
10357 (setq split-name (append result split-name)))))))))
10358 (nreverse split-name)))
10360 (defun gnus-valid-move-group-p (group)
10361 (and (boundp group)
10362 (symbol-name group)
10363 (symbol-value group)
10364 (gnus-get-function (gnus-find-method-for-group
10365 (symbol-name group)) 'request-accept-article t)))
10367 (defun gnus-read-move-group-name (prompt default articles prefix)
10368 "Read a group name."
10369 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10370 (minibuffer-confirm-incomplete nil) ; XEmacs
10372 (format "%s %s to:"
10374 (if (> (length articles) 1)
10375 (format "these %d articles" (length articles))
10380 (gnus-completing-read-with-default
10383 'gnus-valid-move-group-p
10385 'gnus-group-history))
10386 ((= 1 (length split-name))
10387 (gnus-completing-read-with-default
10388 (car split-name) prom
10390 'gnus-valid-move-group-p
10392 'gnus-group-history))
10394 (gnus-completing-read-with-default
10396 (mapcar (lambda (el) (list el))
10397 (nreverse split-name))
10399 'gnus-group-history))))
10400 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10402 (if (or (string= to-newsgroup "")
10403 (string= to-newsgroup prefix))
10404 (setq to-newsgroup default))
10405 (unless to-newsgroup
10406 (error "No group name entered"))
10407 (or (gnus-active to-newsgroup)
10408 (gnus-activate-group to-newsgroup nil nil to-method)
10409 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10411 (or (and (gnus-request-create-group to-newsgroup to-method)
10412 (gnus-activate-group
10413 to-newsgroup nil nil to-method)
10414 (gnus-subscribe-group to-newsgroup))
10415 (error "Couldn't create group %s" to-newsgroup)))
10416 (error "No such group: %s" to-newsgroup)))
10419 (defun gnus-summary-save-parts (type dir n &optional reverse)
10420 "Save parts matching TYPE to DIR.
10421 If REVERSE, save parts that do not match TYPE."
10423 (list (read-string "Save parts of type: "
10424 (or (car gnus-summary-save-parts-type-history)
10425 gnus-summary-save-parts-default-mime)
10426 'gnus-summary-save-parts-type-history)
10427 (setq gnus-summary-save-parts-last-directory
10428 (read-file-name "Save to directory: "
10429 gnus-summary-save-parts-last-directory
10431 current-prefix-arg))
10432 (gnus-summary-iterate n
10433 (let ((gnus-display-mime-function nil)
10434 (gnus-inhibit-treatment t))
10435 (gnus-summary-select-article))
10437 (set-buffer gnus-article-buffer)
10438 (let ((handles (or gnus-article-mime-handles
10440 gnus-article-no-strict-mime)
10443 (gnus-summary-save-parts-1 type dir handles reverse)
10444 (unless gnus-article-mime-handles ;; Don't destroy this case.
10445 (mm-destroy-parts handles)))))))
10447 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10448 (if (stringp (car handle))
10449 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10452 (not (string-match type (mm-handle-media-type handle)))
10453 (string-match type (mm-handle-media-type handle)))
10454 (let ((file (expand-file-name
10455 (file-name-nondirectory
10457 (mail-content-type-get
10458 (mm-handle-disposition handle) 'filename)
10459 (concat gnus-newsgroup-name
10460 "." (number-to-string
10461 (cdr gnus-article-current)))))
10463 (unless (file-exists-p file)
10464 (mm-save-part-to-file handle file))))))
10466 ;; Summary extract commands
10468 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10469 (let ((buffer-read-only nil)
10470 (article (gnus-summary-article-number))
10472 (unless (gnus-summary-goto-subject article)
10473 (error "No such article: %d" article))
10474 (gnus-summary-position-point)
10475 ;; If all commands are to be bunched up on one line, we collect
10477 (unless gnus-view-pseudos-separately
10478 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10481 (setq action (cdr (assq 'action (car ps))))
10482 (setq files (list (cdr (assq 'name (car ps)))))
10483 (while (and ps (cdr ps)
10484 (string= (or action "1")
10485 (or (cdr (assq 'action (cadr ps))) "2")))
10486 (push (cdr (assq 'name (cadr ps))) files)
10487 (setcdr ps (cddr ps)))
10489 (when (not (string-match "%s" action))
10492 (when (assq 'execute (car ps))
10493 (setcdr (assq 'execute (car ps))
10494 (funcall (if (string-match "%s" action)
10501 (gnus-quote-arg-for-sh-or-csh f)))
10503 (setq ps (cdr ps)))))
10504 (if (and gnus-view-pseudos (not not-view))
10506 (when (assq 'execute (car pslist))
10507 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10508 (eq gnus-view-pseudos 'not-confirm)))
10509 (setq pslist (cdr pslist)))
10512 (setq after-article (or (cdr (assq 'article (car pslist)))
10513 (gnus-summary-article-number)))
10514 (gnus-summary-goto-subject after-article)
10517 (insert " " (file-name-nondirectory
10518 (cdr (assq 'name (car pslist))))
10519 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10521 (forward-line -1) ; back to `b'
10522 (gnus-add-text-properties
10523 b (1- e) (list 'gnus-number gnus-reffed-article-number
10524 gnus-mouse-face-prop gnus-mouse-face))
10526 after-article gnus-reffed-article-number
10527 gnus-unread-mark b (car pslist) 0 (- e b))
10528 (setq gnus-newsgroup-unreads
10529 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10530 gnus-reffed-article-number))
10531 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10532 (setq pslist (cdr pslist)))))))
10534 (defun gnus-pseudos< (p1 p2)
10535 (let ((c1 (cdr (assq 'action p1)))
10536 (c2 (cdr (assq 'action p2))))
10537 (and c1 c2 (string< c1 c2))))
10539 (defun gnus-request-pseudo-article (props)
10540 (cond ((assq 'execute props)
10541 (gnus-execute-command (cdr (assq 'execute props)))))
10542 (let ((gnus-current-article (gnus-summary-article-number)))
10543 (gnus-run-hooks 'gnus-mark-article-hook)))
10545 (defun gnus-execute-command (command &optional automatic)
10547 (gnus-article-setup-buffer)
10548 (set-buffer gnus-article-buffer)
10549 (setq buffer-read-only nil)
10550 (let ((command (if automatic command
10551 (read-string "Command: " (cons command 0)))))
10553 (insert "$ " command "\n\n")
10554 (if gnus-view-pseudo-asynchronously
10555 (start-process "gnus-execute" (current-buffer) shell-file-name
10556 shell-command-switch command)
10557 (call-process shell-file-name nil t nil
10558 shell-command-switch command)))))
10560 ;; Summary kill commands.
10562 (defun gnus-summary-edit-global-kill (article)
10563 "Edit the \"global\" kill file."
10564 (interactive (list (gnus-summary-article-number)))
10565 (gnus-group-edit-global-kill article))
10567 (defun gnus-summary-edit-local-kill ()
10568 "Edit a local kill file applied to the current newsgroup."
10570 (setq gnus-current-headers (gnus-summary-article-header))
10571 (gnus-group-edit-local-kill
10572 (gnus-summary-article-number) gnus-newsgroup-name))
10574 ;;; Header reading.
10576 (defun gnus-read-header (id &optional header)
10577 "Read the headers of article ID and enter them into the Gnus system."
10578 (let ((group gnus-newsgroup-name)
10579 (gnus-override-method
10581 gnus-override-method
10582 (and (gnus-news-group-p gnus-newsgroup-name)
10583 (car (gnus-refer-article-methods)))))
10585 ;; First we check to see whether the header in question is already
10588 ;; This is a Message-ID.
10589 (setq header (or header (gnus-id-to-header id)))
10590 ;; This is an article number.
10591 (setq header (or header (gnus-summary-article-header id))))
10593 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10594 ;; We have found the header.
10596 ;; If this is a sparse article, we have to nix out its
10597 ;; previous entry in the thread hashtb.
10599 (gnus-summary-article-sparse-p (mail-header-number header)))
10600 (let* ((parent (gnus-parent-id (mail-header-references header)))
10601 (thread (and parent (gnus-id-to-thread parent))))
10603 (delq (assq header thread) thread))))
10604 ;; We have to really fetch the header to this article.
10606 (set-buffer nntp-server-buffer)
10607 (when (setq where (gnus-request-head id group))
10608 (nnheader-fold-continuation-lines)
10609 (goto-char (point-max))
10611 (goto-char (point-min))
10615 ((cdr where) (cdr where))
10616 (header (mail-header-number header))
10617 (t gnus-reffed-article-number))
10619 (insert " Article retrieved.\n"))
10620 (if (or (not where)
10621 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10622 () ; Malformed head.
10623 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10624 (when (and (stringp id)
10625 (not (string= (gnus-group-real-name group)
10627 ;; If we fetched by Message-ID and the article came
10628 ;; from a different group, we fudge some bogus article
10629 ;; numbers for this article.
10630 (mail-header-set-number header gnus-reffed-article-number))
10632 (set-buffer gnus-summary-buffer)
10633 (decf gnus-reffed-article-number)
10634 (gnus-remove-header (mail-header-number header))
10635 (push header gnus-newsgroup-headers)
10636 (setq gnus-current-headers header)
10637 (push (mail-header-number header) gnus-newsgroup-limit)))
10640 (defun gnus-remove-header (number)
10641 "Remove header NUMBER from `gnus-newsgroup-headers'."
10642 (if (and gnus-newsgroup-headers
10643 (= number (mail-header-number (car gnus-newsgroup-headers))))
10644 (pop gnus-newsgroup-headers)
10645 (let ((headers gnus-newsgroup-headers))
10646 (while (and (cdr headers)
10647 (not (= number (mail-header-number (cadr headers)))))
10649 (when (cdr headers)
10650 (setcdr headers (cddr headers))))))
10653 ;;; summary highlights
10656 (defun gnus-highlight-selected-summary ()
10657 "Highlight selected article in summary buffer."
10658 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10659 (when gnus-summary-selected-face
10661 (let* ((beg (progn (beginning-of-line) (point)))
10662 (end (progn (end-of-line) (point)))
10663 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10664 (from (if (get-text-property beg gnus-mouse-face-prop)
10666 (or (next-single-property-change
10667 beg gnus-mouse-face-prop nil end)
10672 (or (next-single-property-change
10673 from gnus-mouse-face-prop nil end)
10675 ;; If no mouse-face prop on line we will have to = from = end,
10676 ;; so we highlight the entire line instead.
10677 (when (= (+ to 2) from)
10680 (if gnus-newsgroup-selected-overlay
10681 ;; Move old overlay.
10683 gnus-newsgroup-selected-overlay from to (current-buffer))
10684 ;; Create new overlay.
10686 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10687 'face gnus-summary-selected-face))))))
10689 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10690 (defun gnus-summary-highlight-line ()
10691 "Highlight current line according to `gnus-summary-highlight'."
10692 (let* ((list gnus-summary-highlight)
10694 (end (progn (end-of-line) (point)))
10695 ;; now find out where the line starts and leave point there.
10696 (beg (progn (beginning-of-line) (point)))
10697 (article (gnus-summary-article-number))
10698 (score (or (cdr (assq (or article gnus-current-article)
10699 gnus-newsgroup-scored))
10700 gnus-summary-default-score 0))
10701 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10702 (inhibit-read-only t))
10703 ;; Eval the cars of the lists until we find a match.
10704 (let ((default gnus-summary-default-score)
10705 (default-high gnus-summary-default-high-score)
10706 (default-low gnus-summary-default-low-score))
10708 (not (eval (caar list))))
10709 (setq list (cdr list))))
10710 (let ((face (cdar list)))
10711 (unless (eq face (get-text-property beg 'face))
10712 (gnus-put-text-property-excluding-characters-with-faces
10714 (setq face (if (boundp face) (symbol-value face) face)))
10715 (when gnus-summary-highlight-line-function
10716 (funcall gnus-summary-highlight-line-function article face))))
10719 (defun gnus-update-read-articles (group unread &optional compute)
10720 "Update the list of read articles in GROUP.
10721 UNREAD is a sorted list."
10722 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10723 (entry (gnus-gethash group gnus-newsrc-hashtb))
10724 (info (nth 2 entry))
10727 (if (or (not info) (not active))
10728 ;; There is no info on this group if it was, in fact,
10729 ;; killed. Gnus stores no information on killed groups, so
10730 ;; there's nothing to be done.
10731 ;; One could store the information somewhere temporarily,
10732 ;; perhaps... Hmmm...
10734 ;; Remove any negative articles numbers.
10735 (while (and unread (< (car unread) 0))
10736 (setq unread (cdr unread)))
10737 ;; Remove any expired article numbers
10738 (while (and unread (< (car unread) (car active)))
10739 (setq unread (cdr unread)))
10740 ;; Compute the ranges of read articles by looking at the list of
10741 ;; unread articles.
10743 (when (/= (car unread) prev)
10744 (push (if (= prev (1- (car unread))) prev
10745 (cons prev (1- (car unread))))
10747 (setq prev (1+ (car unread)))
10748 (setq unread (cdr unread)))
10749 (when (<= prev (cdr active))
10750 (push (cons prev (cdr active)) read))
10751 (setq read (if (> (length read) 1) (nreverse read) read))
10756 ;; Propagate the read marks to the backend.
10757 (when (gnus-check-backend-function 'request-set-mark group)
10758 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10759 (add (gnus-remove-from-range read (gnus-info-read info))))
10761 (unless (gnus-check-group group)
10762 (error "Can't open server for %s" group))
10763 (gnus-request-set-mark
10764 group (delq nil (list (if add (list add 'add '(read)))
10765 (if del (list del 'del '(read))))))
10767 `(gnus-request-set-mark
10770 (if del (list del 'add '(read)))
10771 (if add (list add 'del '(read))))))))))
10772 (set-buffer gnus-group-buffer)
10773 (gnus-undo-register
10775 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10776 (gnus-info-set-read ',info ',(gnus-info-read info))
10777 (gnus-get-unread-articles-in-group ',info
10778 (gnus-active ,group))
10779 (gnus-group-update-group ,group t)
10781 ;; Enter this list into the group info.
10782 (gnus-info-set-read info read)
10783 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10784 (gnus-get-unread-articles-in-group info (gnus-active group))
10787 (defun gnus-offer-save-summaries ()
10788 "Offer to save all active summary buffers."
10790 ;; Go through all buffers and find all summaries.
10791 (dolist (buffer (buffer-list))
10792 (when (and (setq buffer (buffer-name buffer))
10793 (string-match "Summary" buffer)
10795 (set-buffer buffer)
10796 ;; We check that this is, indeed, a summary buffer.
10797 (and (eq major-mode 'gnus-summary-mode)
10798 ;; Also make sure this isn't bogus.
10799 gnus-newsgroup-prepared
10800 ;; Also make sure that this isn't a
10801 ;; dead summary buffer.
10802 (not gnus-dead-summary-mode))))
10803 (push buffer buffers)))
10804 ;; Go through all these summary buffers and offer to save them.
10808 "Update summary buffer %s? "
10810 (switch-to-buffer buf)
10811 (gnus-summary-exit))
10815 ;;; @ for mime-partial
10818 (defun gnus-request-partial-message ()
10820 (let ((number (gnus-summary-article-number))
10821 (group gnus-newsgroup-name)
10822 (mother gnus-article-buffer))
10823 (set-buffer (get-buffer-create " *Partial Article*"))
10825 (setq mime-preview-buffer mother)
10826 (gnus-request-article-this-buffer number group)
10827 (mime-parse-buffer)
10830 (autoload 'mime-combine-message/partial-pieces-automatically
10832 "Internal method to combine message/partial messages automatically.")
10834 (mime-add-condition
10835 'action '((type . message)(subtype . partial)
10836 (major-mode . gnus-original-article-mode)
10837 (method . mime-combine-message/partial-pieces-automatically)
10838 (summary-buffer-exp . gnus-summary-buffer)
10839 (request-partial-message-method . gnus-request-partial-message)
10843 ;;; @ for message/rfc822
10846 (defun gnus-mime-extract-message/rfc822 (entity situation)
10847 "Burst a forwarded article."
10849 (set-buffer gnus-summary-buffer)
10850 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
10851 gnus-newsgroup-name 'gnus-group-history))
10852 (gnus-group-marked (list group))
10855 (mime-insert-entity-content entity)
10856 (setq article (gnus-request-accept-article group)))
10857 (when (and (consp article)
10858 (numberp (setq article (cdr article))))
10859 (setq info (gnus-get-info group))
10860 (gnus-info-set-read info
10861 (gnus-remove-from-range (gnus-info-read info)
10863 (when (string-equal group gnus-newsgroup-name)
10865 (let (gnus-show-threads)
10866 (gnus-summary-goto-subject article t))
10867 (gnus-summary-clear-mark-forward 1))
10868 (set-buffer gnus-group-buffer)
10869 (gnus-group-get-new-news-this-group nil t)))))
10871 (mime-add-condition
10872 'action '((type . message)(subtype . rfc822)
10873 (major-mode . gnus-original-article-mode)
10874 (method . gnus-mime-extract-message/rfc822)
10878 (mime-add-condition
10879 'action '((type . message)(subtype . news)
10880 (major-mode . gnus-original-article-mode)
10881 (method . gnus-mime-extract-message/rfc822)
10885 (defun gnus-mime-extract-multipart (entity situation)
10886 (let ((children (mime-entity-children entity))
10887 mime-acting-situation-to-override
10890 (mime-play-entity (car children)
10891 (cons (assq 'mode situation)
10892 mime-acting-situation-to-override))
10893 (setq children (cdr children)))
10894 (if (setq f (cdr (assq 'after-method
10895 mime-acting-situation-to-override)))
10899 (mime-add-condition
10900 'action '((type . multipart)
10901 (method . gnus-mime-extract-multipart)
10910 (defun gnus-summary-setup-default-charset ()
10911 "Setup newsgroup default charset."
10912 (if (equal gnus-newsgroup-name "nndraft:drafts")
10913 (setq gnus-newsgroup-charset nil)
10914 (let* ((ignored-charsets
10915 (or gnus-newsgroup-ephemeral-ignored-charsets
10917 (and gnus-newsgroup-name
10918 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10919 gnus-newsgroup-ignored-charsets))))
10920 (setq gnus-newsgroup-charset
10921 (or gnus-newsgroup-ephemeral-charset
10922 (and gnus-newsgroup-name
10923 (gnus-parameter-charset gnus-newsgroup-name))
10924 gnus-default-charset))
10925 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10926 ignored-charsets))))
10932 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10933 "Display the current article buffer fully MIME-buttonized.
10934 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10935 treated as multipart/mixed."
10937 (require 'gnus-art)
10938 (let ((gnus-unbuttonized-mime-types nil)
10939 (gnus-mime-display-multipart-as-mixed show-all-parts))
10940 (gnus-summary-show-article)))
10942 (defun gnus-summary-repair-multipart (article)
10943 "Add a Content-Type header to a multipart article without one."
10944 (interactive (list (gnus-summary-article-number)))
10945 (gnus-with-article article
10946 (message-narrow-to-head)
10947 (message-remove-header "Mime-Version")
10948 (goto-char (point-max))
10949 (insert "Mime-Version: 1.0\n")
10951 (when (search-forward "\n--" nil t)
10952 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10953 (message-narrow-to-head)
10954 (message-remove-header "Content-Type")
10955 (goto-char (point-max))
10956 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10959 (let (gnus-mark-article-hook)
10960 (gnus-summary-select-article t t nil article)))
10962 (defun gnus-summary-toggle-display-buttonized ()
10963 "Toggle the buttonizing of the article buffer."
10965 (require 'gnus-art)
10966 (if (setq gnus-inhibit-mime-unbuttonizing
10967 (not gnus-inhibit-mime-unbuttonizing))
10968 (let ((gnus-unbuttonized-mime-types nil))
10969 (gnus-summary-show-article))
10970 (gnus-summary-show-article)))
10973 ;;; Intelli-mouse commmands
10976 (defun gnus-wheel-summary-scroll (event)
10978 (let ((amount (if (memq 'shift (event-modifiers event))
10979 (car gnus-wheel-scroll-amount)
10980 (cdr gnus-wheel-scroll-amount)))
10981 (direction (- (* (static-if (featurep 'xemacs)
10982 (event-button event)
10983 (cond ((eq 'mouse-4 (event-basic-type event))
10985 ((eq 'mouse-5 (event-basic-type event))
10989 (gnus-summary-scroll-up (* amount direction))
10990 (when (gnus-eval-in-buffer-window gnus-article-buffer
10993 (and (if (< 0 direction)
10994 (gnus-article-next-page 0)
10995 (gnus-article-prev-page 0)
10997 (if (setq edge (get-text-property
10998 (point-min) 'gnus-wheel-edge))
10999 (setq edge (* edge direction))
11002 (let ((buffer-read-only nil)
11003 (inhibit-read-only t))
11004 (put-text-property (point-min) (point-max)
11005 'gnus-wheel-edge direction)
11007 (or (> edge gnus-wheel-edge-resistance)
11008 (let ((buffer-read-only nil)
11009 (inhibit-read-only t))
11010 (put-text-property (point-min) (point-max)
11012 (* (1+ edge) direction))
11014 (eq last-command 'gnus-wheel-summary-scroll))))
11015 (gnus-summary-next-article nil nil (minusp direction)))))
11017 (defun gnus-wheel-install ()
11018 "Enable mouse wheel support on summary window."
11019 (when gnus-use-wheel
11021 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11023 (define-key gnus-summary-mode-map key
11024 'gnus-wheel-summary-scroll)))))
11026 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11029 ;;; Traditional PGP commmands
11032 (defun gnus-summary-decrypt-article (&optional force)
11033 "Decrypt the current article in traditional PGP way.
11034 This will have permanent effect only in mail groups.
11035 If FORCE is non-nil, allow editing of articles even in read-only
11038 (gnus-summary-select-article t)
11039 (gnus-eval-in-buffer-window gnus-article-buffer
11043 (goto-char (point-min))
11044 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11045 (error "Not a traditional PGP message!"))
11046 (let ((armor-start (match-beginning 0)))
11047 (if (and (pgg-decrypt-region armor-start (point-max))
11048 (or force (not (gnus-group-read-only-p))))
11049 (let ((inhibit-read-only t)
11051 (delete-region armor-start
11053 (re-search-forward "^-+END PGP" nil t)
11054 (beginning-of-line 2)
11056 (insert-buffer-substring pgg-output-buffer))))))))
11058 (defun gnus-summary-verify-article ()
11059 "Verify the current article in traditional PGP way."
11062 (set-buffer gnus-original-article-buffer)
11063 (goto-char (point-min))
11064 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11065 (error "Not a traditional PGP message!"))
11066 (re-search-forward "^-+END PGP" nil t)
11067 (beginning-of-line 2)
11068 (call-interactively (function pgg-verify-region))))
11071 ;;; Generic summary marking commands
11074 (defvar gnus-summary-marking-alist
11075 '((read gnus-del-mark "d")
11076 (unread gnus-unread-mark "u")
11077 (ticked gnus-ticked-mark "!")
11078 (dormant gnus-dormant-mark "?")
11079 (expirable gnus-expirable-mark "e"))
11080 "An alist of names/marks/keystrokes.")
11082 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11083 (defvar gnus-summary-mark-map)
11085 (defun gnus-summary-make-all-marking-commands ()
11086 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11087 (dolist (elem gnus-summary-marking-alist)
11088 (apply 'gnus-summary-make-marking-command elem)))
11090 (defun gnus-summary-make-marking-command (name mark keystroke)
11091 (let ((map (make-sparse-keymap)))
11092 (define-key gnus-summary-generic-mark-map keystroke map)
11093 (dolist (lway `((next "next" next nil "n")
11094 (next-unread "next unread" next t "N")
11095 (prev "previous" prev nil "p")
11096 (prev-unread "previous unread" prev t "P")
11097 (nomove "" nil nil ,keystroke)))
11098 (let ((func (gnus-summary-make-marking-command-1
11099 mark (car lway) lway name)))
11100 (setq func (eval func))
11101 (define-key map (nth 4 lway) func)))))
11103 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11105 (format "gnus-summary-put-mark-as-%s%s"
11106 name (if (eq way 'nomove)
11108 (concat "-" (symbol-name way)))))
11111 "Mark the current article as %s%s.
11112 If N, the prefix, then repeat N times.
11113 If N is negative, move in reverse order.
11114 The difference between N and the actual number of articles marked is
11116 name (car (cdr lway)))
11118 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11120 (defun gnus-summary-generic-mark (n mark move unread)
11121 "Mark N articles with MARK."
11122 (unless (eq major-mode 'gnus-summary-mode)
11123 (error "This command can only be used in the summary buffer"))
11124 (gnus-summary-show-thread)
11127 ((eq move 'next) 1)
11128 ((eq move 'prev) -1)
11130 (if (zerop nummove)
11134 nummove (* -1 nummove))))
11135 (while (and (> n 0)
11136 (gnus-summary-mark-article nil mark)
11137 (zerop (gnus-summary-next-subject nummove unread t)))
11140 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11141 (gnus-summary-recenter)
11142 (gnus-summary-position-point)
11143 (gnus-set-mode-line 'summary)
11146 (defun gnus-summary-insert-articles (articles)
11147 (when (setq articles
11148 (gnus-sorted-difference articles
11149 (mapcar (lambda (h)
11150 (mail-header-number h))
11151 gnus-newsgroup-headers)))
11152 (setq gnus-newsgroup-headers
11154 gnus-newsgroup-headers
11155 (gnus-fetch-headers articles)
11156 'gnus-article-sort-by-number))
11157 ;; Suppress duplicates?
11158 (when gnus-suppress-duplicates
11159 (gnus-dup-suppress-articles))
11161 ;; We might want to build some more threads first.
11162 (when (and gnus-fetch-old-headers
11163 (eq gnus-headers-retrieved-by 'nov))
11164 (if (eq gnus-fetch-old-headers 'invisible)
11165 (gnus-build-all-threads)
11166 (gnus-build-old-threads)))
11167 ;; Let the Gnus agent mark articles as read.
11169 (gnus-agent-get-undownloaded-list))
11170 ;; Remove list identifiers from subject
11171 (when gnus-list-identifiers
11172 (gnus-summary-remove-list-identifiers))
11173 ;; First and last article in this newsgroup.
11174 (when gnus-newsgroup-headers
11175 (setq gnus-newsgroup-begin
11176 (mail-header-number (car gnus-newsgroup-headers))
11178 (mail-header-number
11179 (gnus-last-element gnus-newsgroup-headers))))
11180 (when gnus-use-scoring
11181 (gnus-possibly-score-headers))))
11183 (defun gnus-summary-insert-old-articles (&optional all)
11184 "Insert all old articles in this group.
11185 If ALL is non-nil, already read articles become readable.
11186 If ALL is a number, fetch this number of articles."
11189 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11192 (gnus-sorted-difference
11193 (gnus-uncompress-range (list gnus-newsgroup-active))
11195 (setq len (length older))
11200 (setq older (last older all))))
11203 (if (and (numberp gnus-large-newsgroup)
11204 (> len gnus-large-newsgroup))
11208 "How many articles from %s (default %d): "
11210 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11212 (unless (string-match "^[ \t]*$" input)
11213 (setq all (string-to-number input))
11215 (setq older (last older all))))))))
11217 (message "No old news.")
11218 (gnus-summary-insert-articles older)
11219 (gnus-summary-limit (gnus-sorted-nunion old older))))
11220 (gnus-summary-position-point)))
11222 (defun gnus-summary-insert-new-articles ()
11223 "Insert all new articles in this group."
11226 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11227 (old-active gnus-newsgroup-active)
11228 (nnmail-fetched-sources (list t))
11230 (setq gnus-newsgroup-active
11231 (gnus-activate-group gnus-newsgroup-name 'scan))
11232 (setq i (1+ (cdr old-active)))
11233 (while (<= i (cdr gnus-newsgroup-active))
11237 (message "No gnus is bad news.")
11238 (setq new (nreverse new))
11239 (gnus-summary-insert-articles new)
11240 (setq gnus-newsgroup-unreads
11241 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11242 (gnus-summary-limit (gnus-sorted-nunion old new))))
11243 (gnus-summary-position-point)))
11245 (gnus-summary-make-all-marking-commands)
11247 (gnus-ems-redefine)
11249 (provide 'gnus-sum)
11251 (run-hooks 'gnus-sum-load-hook)
11253 ;;; gnus-sum.el ends here