1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
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))
42 ;; (require 'gnus-art)
51 (autoload 'pgg-decrypt-region "pgg" nil t)
52 (autoload 'pgg-verify-region "pgg" nil t))
54 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
55 (autoload 'gnus-cache-write-active "gnus-cache")
56 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
57 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
58 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
59 (autoload 'mm-uu-dissect "mm-uu")
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include: `gnus-simplify-subject-re',
151 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
153 :type '(repeat function))
155 (defcustom gnus-simplify-ignored-prefixes nil
156 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
158 :type '(choice (const :tag "off" nil)
161 (defcustom gnus-build-sparse-threads nil
162 "*If non-nil, fill in the gaps in threads.
163 If `some', only fill in the gaps that are needed to tie loose threads
164 together. If `more', fill in all leaf nodes that Gnus can find. If
165 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
167 :type '(choice (const :tag "off" nil)
170 (sexp :menu-tag "all" t)))
172 (defcustom gnus-summary-thread-gathering-function
173 'gnus-gather-threads-by-subject
174 "*Function used for gathering loose threads.
175 There are two pre-defined functions: `gnus-gather-threads-by-subject',
176 which only takes Subjects into consideration; and
177 `gnus-gather-threads-by-references', which compared the References
178 headers of the articles to find matches."
180 :type '(radio (function-item gnus-gather-threads-by-subject)
181 (function-item gnus-gather-threads-by-references)
182 (function :tag "other")))
184 (defcustom gnus-summary-same-subject ""
185 "*String indicating that the current article has the same subject as the previous.
186 This variable will only be used if the value of
187 `gnus-summary-make-false-root' is `empty'."
188 :group 'gnus-summary-format
191 (defcustom gnus-summary-goto-unread t
192 "*If t, many commands will go to the next unread article.
193 This applies to marking commands as well as other commands that
194 \"naturally\" select the next article, like, for instance, `SPC' at
195 the end of an article.
197 If nil, the marking commands do NOT go to the next unread article
198 (they go to the next article instead). If `never', commands that
199 usually go to the next unread article, will go to the next article,
200 whether it is read or not."
201 :group 'gnus-summary-marks
202 :link '(custom-manual "(gnus)Setting Marks")
203 :type '(choice (const :tag "off" nil)
205 (sexp :menu-tag "on" t)))
207 (defcustom gnus-summary-default-score 0
208 "*Default article score level.
209 All scores generated by the score files will be added to this score.
210 If this variable is nil, scoring will be disabled."
211 :group 'gnus-score-default
212 :type '(choice (const :tag "disable")
215 (defcustom gnus-summary-default-high-score 0
216 "*Default threshold for a high scored article.
217 An article will be highlighted as high scored if its score is greater
219 :group 'gnus-score-default
222 (defcustom gnus-summary-default-low-score 0
223 "*Default threshold for a low scored article.
224 An article will be highlighted as low scored if its score is smaller
226 :group 'gnus-score-default
229 (defcustom gnus-summary-zcore-fuzz 0
230 "*Fuzziness factor for the zcore in the summary buffer.
231 Articles with scores closer than this to `gnus-summary-default-score'
233 :group 'gnus-summary-format
236 (defcustom gnus-simplify-subject-fuzzy-regexp nil
237 "*Strings to be removed when doing fuzzy matches.
238 This can either be a regular expression or list of regular expressions
239 that will be removed from subject strings if fuzzy subject
240 simplification is selected."
242 :type '(repeat regexp))
244 (defcustom gnus-show-threads t
245 "*If non-nil, display threads in summary mode."
249 (defcustom gnus-thread-hide-subtree nil
250 "*If non-nil, hide all threads initially.
251 If threads are hidden, you have to run the command
252 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
253 to expose hidden threads."
257 (defcustom gnus-thread-hide-killed t
258 "*If non-nil, hide killed threads automatically."
262 (defcustom gnus-thread-ignore-subject t
263 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
264 If nil, articles that have different subjects from their parents will
265 start separate threads."
269 (defcustom gnus-thread-operation-ignore-subject t
270 "*If non-nil, subjects will be ignored when doing thread commands.
271 This affects commands like `gnus-summary-kill-thread' and
272 `gnus-summary-lower-thread'.
274 If this variable is nil, articles in the same thread with different
275 subjects will not be included in the operation in question. If this
276 variable is `fuzzy', only articles that have subjects that are fuzzily
277 equal will be included."
279 :type '(choice (const :tag "off" nil)
283 (defcustom gnus-thread-indent-level 4
284 "*Number that says how much each sub-thread should be indented."
288 (defcustom gnus-auto-extend-newsgroup t
289 "*If non-nil, extend newsgroup forward and backward when requested."
290 :group 'gnus-summary-choose
293 (defcustom gnus-auto-select-first t
294 "*If nil, don't select the first unread article when entering a group.
295 If this variable is `best', select the highest-scored unread article
296 in the group. If t, select the first unread article.
298 This variable can also be a function to place point on a likely
299 subject line. Useful values include `gnus-summary-first-unread-subject',
300 `gnus-summary-first-unread-article' and
301 `gnus-summary-best-unread-article'.
303 If you want to prevent automatic selection of the first unread article
304 in some newsgroups, set the variable to nil in
305 `gnus-select-group-hook'."
306 :group 'gnus-group-select
307 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "first" t)
310 (function-item gnus-summary-first-unread-subject)
311 (function-item gnus-summary-first-unread-article)
312 (function-item gnus-summary-best-unread-article)))
314 (defcustom gnus-dont-select-after-jump-to-other-group nil
315 "If non-nil, don't select the first unread article after entering the
316 other group by the command `gnus-summary-jump-to-other-group'. If nil,
317 it is depend on the value of `gnus-auto-select-first' whether to select
319 :group 'gnus-group-select
322 (defcustom gnus-auto-select-next t
323 "*If non-nil, offer to go to the next group from the end of the previous.
324 If the value is t and the next newsgroup is empty, Gnus will exit
325 summary mode and go back to group mode. If the value is neither nil
326 nor t, Gnus will select the following unread newsgroup. In
327 particular, if the value is the symbol `quietly', the next unread
328 newsgroup will be selected without any confirmation, and if it is
329 `almost-quietly', the next group will be selected without any
330 confirmation if you are located on the last article in the group.
331 Finally, if this variable is `slightly-quietly', the `Z n' command
332 will go to the next group without confirmation."
333 :group 'gnus-summary-maneuvering
334 :type '(choice (const :tag "off" nil)
336 (const almost-quietly)
337 (const slightly-quietly)
338 (sexp :menu-tag "on" t)))
340 (defcustom gnus-auto-select-same nil
341 "*If non-nil, select the next article with the same subject.
342 If there are no more articles with the same subject, go to
343 the first unread article."
344 :group 'gnus-summary-maneuvering
347 (defcustom gnus-summary-check-current nil
348 "*If non-nil, consider the current article when moving.
349 The \"unread\" movement commands will stay on the same line if the
350 current article is unread."
351 :group 'gnus-summary-maneuvering
354 (defcustom gnus-auto-center-summary t
355 "*If non-nil, always center the current summary buffer.
356 In particular, if `vertical' do only vertical recentering. If non-nil
357 and non-`vertical', do both horizontal and vertical recentering."
358 :group 'gnus-summary-maneuvering
359 :type '(choice (const :tag "none" nil)
361 (integer :tag "height")
362 (sexp :menu-tag "both" t)))
364 (defcustom gnus-show-all-headers nil
365 "*If non-nil, don't hide any headers."
366 :group 'gnus-article-hiding
367 :group 'gnus-article-headers
370 (defcustom gnus-summary-ignore-duplicates nil
371 "*If non-nil, ignore articles with identical Message-ID headers."
375 (defcustom gnus-single-article-buffer t
376 "*If non-nil, display all articles in the same buffer.
377 If nil, each group will get its own article buffer."
378 :group 'gnus-article-various
381 (defcustom gnus-break-pages t
382 "*If non-nil, do page breaking on articles.
383 The page delimiter is specified by the `gnus-page-delimiter'
385 :group 'gnus-article-various
388 (defcustom gnus-show-mime t
389 "*If non-nil, do mime processing of articles.
390 The articles will simply be fed to the function given by
391 `gnus-article-display-method-for-mime'."
392 :group 'gnus-article-mime
395 (defcustom gnus-move-split-methods nil
396 "*Variable used to suggest where articles are to be moved to.
397 It uses the same syntax as the `gnus-split-methods' variable.
398 However, whereas `gnus-split-methods' specifies file names as targets,
399 this variable specifies group names."
400 :group 'gnus-summary-mail
401 :type '(repeat (choice (list :value (fun) function)
402 (cons :value ("" "") regexp (repeat string))
405 (defcustom gnus-unread-mark ?\ ;;;Whitespace
406 "*Mark used for unread articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-ticked-mark ?!
411 "*Mark used for ticked articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-dormant-mark ??
416 "*Mark used for dormant articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-del-mark ?r
421 "*Mark used for del'd articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-read-mark ?R
426 "*Mark used for read articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-expirable-mark ?E
431 "*Mark used for expirable articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-killed-mark ?K
436 "*Mark used for killed articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-souped-mark ?F
441 "*Mark used for souped articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-kill-file-mark ?X
446 "*Mark used for articles killed by kill files."
447 :group 'gnus-summary-marks
450 (defcustom gnus-low-score-mark ?Y
451 "*Mark used for articles with a low score."
452 :group 'gnus-summary-marks
455 (defcustom gnus-catchup-mark ?C
456 "*Mark used for articles that are caught up."
457 :group 'gnus-summary-marks
460 (defcustom gnus-replied-mark ?A
461 "*Mark used for articles that have been replied to."
462 :group 'gnus-summary-marks
465 (defcustom gnus-forwarded-mark ?F
466 "*Mark used for articles that have been forwarded."
467 :group 'gnus-summary-marks
470 (defcustom gnus-recent-mark ?N
471 "*Mark used for articles that are recent."
472 :group 'gnus-summary-marks
475 (defcustom gnus-cached-mark ?*
476 "*Mark used for articles that are in the cache."
477 :group 'gnus-summary-marks
480 (defcustom gnus-saved-mark ?S
481 "*Mark used for articles that have been saved."
482 :group 'gnus-summary-marks
485 (defcustom gnus-unseen-mark ?.
486 "*Mark used for articles that haven't been seen."
487 :group 'gnus-summary-marks
490 (defcustom gnus-no-mark ?\ ;;;Whitespace
491 "*Mark used for articles that have no other secondary mark."
492 :group 'gnus-summary-marks
495 (defcustom gnus-ancient-mark ?O
496 "*Mark used for ancient articles."
497 :group 'gnus-summary-marks
500 (defcustom gnus-sparse-mark ?Q
501 "*Mark used for sparsely reffed articles."
502 :group 'gnus-summary-marks
505 (defcustom gnus-canceled-mark ?G
506 "*Mark used for canceled articles."
507 :group 'gnus-summary-marks
510 (defcustom gnus-duplicate-mark ?M
511 "*Mark used for duplicate articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-undownloaded-mark ?@
516 "*Mark used for articles that weren't downloaded."
517 :group 'gnus-summary-marks
520 (defcustom gnus-downloadable-mark ?%
521 "*Mark used for articles that are to be downloaded."
522 :group 'gnus-summary-marks
525 (defcustom gnus-unsendable-mark ?=
526 "*Mark used for articles that won't be sent."
527 :group 'gnus-summary-marks
530 (defcustom gnus-score-over-mark ?+
531 "*Score mark used for articles with high scores."
532 :group 'gnus-summary-marks
535 (defcustom gnus-score-below-mark ?-
536 "*Score mark used for articles with low scores."
537 :group 'gnus-summary-marks
540 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
541 "*There is no thread under the article."
542 :group 'gnus-summary-marks
545 (defcustom gnus-not-empty-thread-mark ?=
546 "*There is a thread under the article."
547 :group 'gnus-summary-marks
550 (defcustom gnus-view-pseudo-asynchronously nil
551 "*If non-nil, Gnus will view pseudo-articles asynchronously."
552 :group 'gnus-extract-view
555 (defcustom gnus-auto-expirable-marks
556 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
557 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
558 gnus-souped-mark gnus-duplicate-mark)
559 "*The list of marks converted into expiration if a group is auto-expirable."
562 :type '(repeat character))
564 (defcustom gnus-inhibit-user-auto-expire t
565 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
570 (defcustom gnus-view-pseudos nil
571 "*If `automatic', pseudo-articles will be viewed automatically.
572 If `not-confirm', pseudos will be viewed automatically, and the user
573 will not be asked to confirm the command."
574 :group 'gnus-extract-view
575 :type '(choice (const :tag "off" nil)
577 (const not-confirm)))
579 (defcustom gnus-view-pseudos-separately t
580 "*If non-nil, one pseudo-article will be created for each file to be viewed.
581 If nil, all files that use the same viewing command will be given as a
582 list of parameters to that command."
583 :group 'gnus-extract-view
586 (defcustom gnus-insert-pseudo-articles t
587 "*If non-nil, insert pseudo-articles when decoding articles."
588 :group 'gnus-extract-view
591 (defcustom gnus-summary-dummy-line-format
593 "*The format specification for the dummy roots in the summary buffer.
594 It works along the same lines as a normal formatting string,
595 with some simple extensions.
598 :group 'gnus-threading
601 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
602 "*The format specification for the summary mode line.
603 It works along the same lines as a normal formatting string,
604 with some simple extensions:
607 %p Unprefixed group name
608 %A Current article number
609 %z Current article score
611 %U Number of unread articles in the group
612 %e Number of unselected articles in the group
613 %Z A string with unread/unselected article counts
614 %g Shortish group name
615 %S Subject of the current article
617 %s Current score file name
618 %d Number of dormant articles
619 %r Number of articles that have been marked as read in this session
620 %E Number of articles expunged by the score files"
621 :group 'gnus-summary-format
624 (defcustom gnus-list-identifiers nil
625 "Regexp that matches list identifiers to be removed from subject.
626 This can also be a list of regexps."
628 :group 'gnus-summary-format
629 :group 'gnus-article-hiding
630 :type '(choice (const :tag "none" nil)
632 (repeat :value (".*") regexp)))
634 (defcustom gnus-summary-mark-below 0
635 "*Mark all articles with a score below this variable as read.
636 This variable is local to each summary buffer and usually set by the
638 :group 'gnus-score-default
641 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
642 "*List of functions used for sorting articles in the summary buffer.
644 Each function takes two articles and returns non-nil if the first
645 article should be sorted before the other. If you use more than one
646 function, the primary sort function should be the last. You should
647 probably always include `gnus-article-sort-by-number' in the list of
648 sorting functions -- preferably first. Also note that sorting by date
649 is often much slower than sorting by number, and the sorting order is
650 very similar. (Sorting by date means sorting by the time the message
651 was sent, sorting by number means sorting by arrival time.)
653 Ready-made functions include `gnus-article-sort-by-number',
654 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
655 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
657 When threading is turned on, the variable `gnus-thread-sort-functions'
658 controls how articles are sorted."
659 :group 'gnus-summary-sort
660 :type '(repeat (choice (function-item gnus-article-sort-by-number)
661 (function-item gnus-article-sort-by-author)
662 (function-item gnus-article-sort-by-subject)
663 (function-item gnus-article-sort-by-date)
664 (function-item gnus-article-sort-by-score)
665 (function :tag "other"))))
667 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
668 "*List of functions used for sorting threads in the summary buffer.
669 By default, threads are sorted by article number.
671 Each function takes two threads and returns non-nil if the first
672 thread should be sorted before the other. If you use more than one
673 function, the primary sort function should be the last. You should
674 probably always include `gnus-thread-sort-by-number' in the list of
675 sorting functions -- preferably first. Also note that sorting by date
676 is often much slower than sorting by number, and the sorting order is
677 very similar. (Sorting by date means sorting by the time the message
678 was sent, sorting by number means sorting by arrival time.)
680 Ready-made functions include `gnus-thread-sort-by-number',
681 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
682 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
683 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
685 When threading is turned off, the variable
686 `gnus-article-sort-functions' controls how articles are sorted."
687 :group 'gnus-summary-sort
688 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
689 (function-item gnus-thread-sort-by-author)
690 (function-item gnus-thread-sort-by-subject)
691 (function-item gnus-thread-sort-by-date)
692 (function-item gnus-thread-sort-by-score)
693 (function-item gnus-thread-sort-by-total-score)
694 (function :tag "other"))))
696 (defcustom gnus-thread-score-function '+
697 "*Function used for calculating the total score of a thread.
699 The function is called with the scores of the article and each
700 subthread and should then return the score of the thread.
702 Some functions you can use are `+', `max', or `min'."
703 :group 'gnus-summary-sort
706 (defcustom gnus-summary-expunge-below nil
707 "All articles that have a score less than this variable will be expunged.
708 This variable is local to the summary buffers."
709 :group 'gnus-score-default
710 :type '(choice (const :tag "off" nil)
713 (defcustom gnus-thread-expunge-below nil
714 "All threads that have a total score less than this variable will be expunged.
715 See `gnus-thread-score-function' for en explanation of what a
718 This variable is local to the summary buffers."
719 :group 'gnus-threading
720 :group 'gnus-score-default
721 :type '(choice (const :tag "off" nil)
724 (defcustom gnus-summary-mode-hook nil
725 "*A hook for Gnus summary mode.
726 This hook is run before any variables are set in the summary buffer."
727 :options '(turn-on-gnus-mailing-list-mode)
728 :group 'gnus-summary-various
731 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
732 (when (featurep 'xemacs)
733 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
734 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
735 (add-hook 'gnus-summary-mode-hook
736 'gnus-xmas-switch-horizontal-scrollbar-off))
738 (defcustom gnus-summary-menu-hook nil
739 "*Hook run after the creation of the summary mode menu."
740 :group 'gnus-summary-visual
743 (defcustom gnus-summary-exit-hook nil
744 "*A hook called on exit from the summary buffer.
745 It will be called with point in the group buffer."
746 :group 'gnus-summary-exit
749 (defcustom gnus-summary-prepare-hook nil
750 "*A hook called after the summary buffer has been generated.
751 If you want to modify the summary buffer, you can use this hook."
752 :group 'gnus-summary-various
755 (defcustom gnus-summary-prepared-hook nil
756 "*A hook called as the last thing after the summary buffer has been generated."
757 :group 'gnus-summary-various
760 (defcustom gnus-summary-generate-hook nil
761 "*A hook run just before generating the summary buffer.
762 This hook is commonly used to customize threading variables and the
764 :group 'gnus-summary-various
767 (defcustom gnus-select-group-hook nil
768 "*A hook called when a newsgroup is selected.
770 If you'd like to simplify subjects like the
771 `gnus-summary-next-same-subject' command does, you can use the
774 (setq gnus-select-group-hook
777 (mapcar (lambda (header)
778 (mail-header-set-subject
780 (gnus-simplify-subject
781 (mail-header-subject header) 're-only)))
782 gnus-newsgroup-headers))))"
783 :group 'gnus-group-select
786 (defcustom gnus-select-article-hook nil
787 "*A hook called when an article is selected."
788 :group 'gnus-summary-choose
791 (defcustom gnus-visual-mark-article-hook
792 (list 'gnus-highlight-selected-summary)
793 "*Hook run after selecting an article in the summary buffer.
794 It is meant to be used for highlighting the article in some way. It
795 is not run if `gnus-visual' is nil."
796 :group 'gnus-summary-visual
799 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
800 "*A hook called before parsing the headers."
804 (defcustom gnus-exit-group-hook nil
805 "*A hook called when exiting summary mode.
806 This hook is not called from the non-updating exit commands like `Q'."
810 (defcustom gnus-summary-update-hook
811 (list 'gnus-summary-highlight-line)
812 "*A hook called when a summary line is changed.
813 The hook will not be called if `gnus-visual' is nil.
815 The default function `gnus-summary-highlight-line' will
816 highlight the line according to the `gnus-summary-highlight'
818 :group 'gnus-summary-visual
821 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
822 "*A hook called when an article is selected for the first time.
823 The hook is intended to mark an article as read (or unread)
824 automatically when it is selected."
825 :group 'gnus-summary-choose
828 (defcustom gnus-group-no-more-groups-hook nil
829 "*A hook run when returning to group mode having no more (unread) groups."
830 :group 'gnus-group-select
833 (defcustom gnus-ps-print-hook nil
834 "*A hook run before ps-printing something from Gnus."
838 (defcustom gnus-summary-display-arrow
839 (and (fboundp 'display-graphic-p)
841 "*If non-nil, display an arrow highlighting the current article."
846 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
847 "Face used for highlighting the current article in the summary buffer."
848 :group 'gnus-summary-visual
851 (defcustom gnus-summary-highlight
852 '(((= mark gnus-canceled-mark)
853 . gnus-summary-cancelled-face)
854 ((and (> score default-high)
855 (or (= mark gnus-dormant-mark)
856 (= mark gnus-ticked-mark)))
857 . gnus-summary-high-ticked-face)
858 ((and (< score default-low)
859 (or (= mark gnus-dormant-mark)
860 (= mark gnus-ticked-mark)))
861 . gnus-summary-low-ticked-face)
862 ((or (= mark gnus-dormant-mark)
863 (= mark gnus-ticked-mark))
864 . gnus-summary-normal-ticked-face)
865 ((and (> score default-high) (= mark gnus-ancient-mark))
866 . gnus-summary-high-ancient-face)
867 ((and (< score default-low) (= mark gnus-ancient-mark))
868 . gnus-summary-low-ancient-face)
869 ((= mark gnus-ancient-mark)
870 . gnus-summary-normal-ancient-face)
871 ((and (> score default-high) (= mark gnus-unread-mark))
872 . gnus-summary-high-unread-face)
873 ((and (< score default-low) (= mark gnus-unread-mark))
874 . gnus-summary-low-unread-face)
875 ((= mark gnus-unread-mark)
876 . gnus-summary-normal-unread-face)
877 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
878 gnus-undownloaded-mark)))
879 . gnus-summary-high-unread-face)
880 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
881 gnus-undownloaded-mark)))
882 . gnus-summary-low-unread-face)
883 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
884 (memq article gnus-newsgroup-unreads))
885 . gnus-summary-normal-unread-face)
886 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
887 . gnus-summary-normal-read-face)
888 ((> score default-high)
889 . gnus-summary-high-read-face)
890 ((< score default-low)
891 . gnus-summary-low-read-face)
893 . gnus-summary-normal-read-face))
894 "*Controls the highlighting of summary buffer lines.
896 A list of (FORM . FACE) pairs. When deciding how a a particular
897 summary line should be displayed, each form is evaluated. The content
898 of the face field after the first true form is used. You can change
899 how those summary lines are displayed, by editing the face field.
901 You can use the following variables in the FORM field.
903 score: The article's score
904 default: The default article score.
905 default-high: The default score for high scored articles.
906 default-low: The default score for low scored articles.
907 below: The score below which articles are automatically marked as read.
908 mark: The articles mark."
909 :group 'gnus-summary-visual
910 :type '(repeat (cons (sexp :tag "Form" nil)
913 (defcustom gnus-alter-header-function nil
914 "Function called to allow alteration of article header structures.
915 The function is called with one parameter, the article header vector,
916 which it may alter in any way.")
918 (defvar gnus-decode-encoded-word-function
919 (mime-find-field-decoder 'From 'nov)
920 "Variable that says which function should be used to decode a string with encoded words.")
922 (defcustom gnus-extra-headers nil
923 "*Extra headers to parse."
926 :type '(repeat symbol))
928 (defcustom gnus-ignored-from-addresses
929 (and user-mail-address (regexp-quote user-mail-address))
930 "*Regexp of From headers that may be suppressed in favor of To headers."
935 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
936 "List of charsets that should be ignored.
937 When these charsets are used in the \"charset\" parameter, the
938 default charset will be used instead."
940 :type '(repeat symbol)
941 :group 'gnus-charset)
943 (gnus-define-group-parameter
947 "Return the ignored charsets of GROUP."
948 :variable gnus-group-ignored-charsets-alist
950 '(("alt\\.chinese\\.text" iso-8859-1))
952 "Alist of regexps (to match group names) and charsets that should be ignored.
953 When these charsets are used in the \"charset\" parameter, the
954 default charset will be used instead."
955 :variable-group gnus-charset
956 :variable-type '(repeat (cons (regexp :tag "Group")
958 :parameter-type '(choice :tag "Ignored charsets"
961 :parameter-document "\
962 List of charsets that should be ignored.
964 When these charsets are used in the \"charset\" parameter, the
965 default charset will be used instead.")
967 (defcustom gnus-group-highlight-words-alist nil
968 "Alist of group regexps and highlight regexps.
969 This variable uses the same syntax as `gnus-emphasis-alist'."
971 :type '(repeat (cons (regexp :tag "Group")
972 (repeat (list (regexp :tag "Highlight regexp")
973 (number :tag "Group for entire word" 0)
974 (number :tag "Group for displayed part" 0)
976 gnus-emphasis-highlight-words)))))
977 :group 'gnus-summary-visual)
979 (defcustom gnus-use-wheel nil
980 "Use Intelli-mouse on summary movement"
982 :group 'gnus-summary-maneuvering)
984 (defcustom gnus-wheel-scroll-amount '(5 . 1)
985 "Amount to scroll messages by spinning the mouse wheel.
986 This is actually a cons cell, where the first item is the amount to scroll
987 on a normal wheel event, and the second is the amount to scroll when the
988 wheel is moved with the shift key depressed."
989 :type '(cons (integer :tag "Shift") integer)
990 :group 'gnus-summary-maneuvering)
992 (defcustom gnus-wheel-edge-resistance 2
993 "How hard it should be to change the current article
994 by moving the mouse over the edge of the article window."
996 :group 'gnus-summary-maneuvering)
998 (defcustom gnus-summary-show-article-charset-alist
1000 "Alist of number and charset.
1001 The article will be shown with the charset corresponding to the
1003 For example: ((1 . cn-gb-2312) (2 . big5))."
1005 :type '(repeat (cons (number :tag "Argument" 1)
1006 (symbol :tag "Charset")))
1007 :group 'gnus-charset)
1009 (defcustom gnus-preserve-marks t
1010 "Whether marks are preserved when moving, copying and respooling messages."
1013 :group 'gnus-summary-marks)
1015 (defcustom gnus-alter-articles-to-read-function nil
1016 "Function to be called to alter the list of articles to be selected."
1017 :type '(choice (const nil) function)
1018 :group 'gnus-summary)
1020 (defcustom gnus-orphan-score nil
1021 "*All orphans get this score added. Set in the score file."
1022 :group 'gnus-score-default
1023 :type '(choice (const nil)
1026 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1027 "*A regexp to match MIME parts when saving multiple parts of a message
1028 with gnus-summary-save-parts (X m). This regexp will be used by default
1029 when prompting the user for which type of files to save."
1030 :group 'gnus-summary
1034 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1035 "*A regexp to match MIME parts when saving multiple parts of a message
1036 with gnus-summary-save-parts (X m). This regexp will be used by default
1037 when prompting the user for which type of files to save."
1038 :group 'gnus-summary
1041 (defcustom gnus-read-all-available-headers nil
1042 "Whether Gnus should parse all headers made available to it.
1043 This is mostly relevant for slow backends where the user may
1044 wish to widen the summary buffer to include all headers
1045 that were fetched. Say, for nnultimate groups."
1046 :group 'gnus-summary
1047 :type '(choice boolean regexp))
1049 ;;; Internal variables
1051 (defvar gnus-summary-display-cache nil)
1052 (defvar gnus-article-mime-handles nil)
1053 (defvar gnus-article-decoded-p nil)
1054 (defvar gnus-article-charset nil)
1055 (defvar gnus-article-ignored-charsets nil)
1056 (defvar gnus-scores-exclude-files nil)
1057 (defvar gnus-page-broken nil)
1058 (defvar gnus-inhibit-mime-unbuttonizing nil)
1060 (defvar gnus-original-article nil)
1061 (defvar gnus-article-internal-prepare-hook nil)
1062 (defvar gnus-newsgroup-process-stack nil)
1064 (defvar gnus-thread-indent-array nil)
1065 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1066 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1067 "Function called to sort the articles within a thread after it has been gathered together.")
1069 (defvar gnus-summary-save-parts-type-history nil)
1070 (defvar gnus-summary-save-parts-last-directory nil)
1072 (defvar gnus-summary-save-parts-type-history nil)
1073 (defvar gnus-summary-save-parts-last-directory nil)
1075 ;; Avoid highlighting in kill files.
1076 (defvar gnus-summary-inhibit-highlight nil)
1077 (defvar gnus-newsgroup-selected-overlay nil)
1078 (defvar gnus-inhibit-limiting nil)
1079 (defvar gnus-newsgroup-adaptive-score-file nil)
1080 (defvar gnus-current-score-file nil)
1081 (defvar gnus-current-move-group nil)
1082 (defvar gnus-current-copy-group nil)
1083 (defvar gnus-current-crosspost-group nil)
1084 (defvar gnus-newsgroup-display nil)
1086 (defvar gnus-newsgroup-dependencies nil)
1087 (defvar gnus-newsgroup-adaptive nil)
1088 (defvar gnus-summary-display-article-function nil)
1089 (defvar gnus-summary-highlight-line-function nil
1090 "Function called after highlighting a summary line.")
1092 (defvar gnus-summary-line-format-alist
1093 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1094 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1095 (?s gnus-tmp-subject-or-nil ?s)
1096 (?n gnus-tmp-name ?s)
1097 (?A (std11-address-string
1098 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1099 (?a (or (std11-full-name-string
1100 (car (mime-entity-read-field gnus-tmp-header 'From)))
1102 (?F gnus-tmp-from ?s)
1103 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1104 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1105 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1106 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1107 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1108 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1109 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1110 (?L gnus-tmp-lines ?s)
1111 (?I gnus-tmp-indentation ?s)
1112 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1113 (?R gnus-tmp-replied ?c)
1114 (?\[ gnus-tmp-opening-bracket ?c)
1115 (?\] gnus-tmp-closing-bracket ?c)
1116 (?\> (make-string gnus-tmp-level ? ) ?s)
1117 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1118 (?i gnus-tmp-score ?d)
1119 (?z gnus-tmp-score-char ?c)
1120 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1121 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1122 (?U gnus-tmp-unread ?c)
1123 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1124 (?t (gnus-summary-number-of-articles-in-thread
1125 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1127 (?e (gnus-summary-number-of-articles-in-thread
1128 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1130 (?u gnus-tmp-user-defined ?s)
1131 (?P (gnus-pick-line-number) ?d)
1132 (?B gnus-tmp-thread-tree-header-string ?s))
1133 "An alist of format specifications that can appear in summary lines.
1134 These are paired with what variables they correspond with, along with
1135 the type of the variable (string, integer, character, etc).")
1137 (defvar gnus-summary-dummy-line-format-alist
1138 `((?S gnus-tmp-subject ?s)
1139 (?N gnus-tmp-number ?d)
1140 (?u gnus-tmp-user-defined ?s)))
1142 (defvar gnus-summary-mode-line-format-alist
1143 `((?G gnus-tmp-group-name ?s)
1144 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1145 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1146 (?A gnus-tmp-article-number ?d)
1147 (?Z gnus-tmp-unread-and-unselected ?s)
1148 (?V gnus-version ?s)
1149 (?U gnus-tmp-unread-and-unticked ?d)
1150 (?S gnus-tmp-subject ?s)
1151 (?e gnus-tmp-unselected ?d)
1152 (?u gnus-tmp-user-defined ?s)
1153 (?d (length gnus-newsgroup-dormant) ?d)
1154 (?t (length gnus-newsgroup-marked) ?d)
1155 (?r (length gnus-newsgroup-reads) ?d)
1156 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1157 (?E gnus-newsgroup-expunged-tally ?d)
1158 (?s (gnus-current-score-file-nondirectory) ?s)))
1160 (defvar gnus-last-search-regexp nil
1161 "Default regexp for article search command.")
1163 (defvar gnus-summary-search-article-matched-data nil
1164 "Last matched data of article search command. It is the local variable
1165 in `gnus-article-buffer' which consists of the list of start position,
1166 end position and text.")
1168 (defvar gnus-last-shell-command nil
1169 "Default shell command on article.")
1171 (defvar gnus-newsgroup-begin nil)
1172 (defvar gnus-newsgroup-end nil)
1173 (defvar gnus-newsgroup-last-rmail nil)
1174 (defvar gnus-newsgroup-last-mail nil)
1175 (defvar gnus-newsgroup-last-folder nil)
1176 (defvar gnus-newsgroup-last-file nil)
1177 (defvar gnus-newsgroup-auto-expire nil)
1178 (defvar gnus-newsgroup-active nil)
1180 (defvar gnus-newsgroup-data nil)
1181 (defvar gnus-newsgroup-data-reverse nil)
1182 (defvar gnus-newsgroup-limit nil)
1183 (defvar gnus-newsgroup-limits nil)
1185 (defvar gnus-newsgroup-unreads nil
1186 "List of unread articles in the current newsgroup.")
1188 (defvar gnus-newsgroup-unselected nil
1189 "List of unselected unread articles in the current newsgroup.")
1191 (defvar gnus-newsgroup-reads nil
1192 "Alist of read articles and article marks in the current newsgroup.")
1194 (defvar gnus-newsgroup-expunged-tally nil)
1196 (defvar gnus-newsgroup-marked nil
1197 "List of ticked articles in the current newsgroup (a subset of unread art).")
1199 (defvar gnus-newsgroup-killed nil
1200 "List of ranges of articles that have been through the scoring process.")
1202 (defvar gnus-newsgroup-cached nil
1203 "List of articles that come from the article cache.")
1205 (defvar gnus-newsgroup-saved nil
1206 "List of articles that have been saved.")
1208 (defvar gnus-newsgroup-kill-headers nil)
1210 (defvar gnus-newsgroup-replied nil
1211 "List of articles that have been replied to in the current newsgroup.")
1213 (defvar gnus-newsgroup-forwarded nil
1214 "List of articles that have been forwarded in the current newsgroup.")
1216 (defvar gnus-newsgroup-recent nil
1217 "List of articles that have are recent in the current newsgroup.")
1219 (defvar gnus-newsgroup-expirable nil
1220 "List of articles in the current newsgroup that can be expired.")
1222 (defvar gnus-newsgroup-processable nil
1223 "List of articles in the current newsgroup that can be processed.")
1225 (defvar gnus-newsgroup-downloadable nil
1226 "List of articles in the current newsgroup that can be processed.")
1228 (defvar gnus-newsgroup-undownloaded nil
1229 "List of articles in the current newsgroup that haven't been downloaded..")
1231 (defvar gnus-newsgroup-unsendable nil
1232 "List of articles in the current newsgroup that won't be sent.")
1234 (defvar gnus-newsgroup-bookmarks nil
1235 "List of articles in the current newsgroup that have bookmarks.")
1237 (defvar gnus-newsgroup-dormant nil
1238 "List of dormant articles in the current newsgroup.")
1240 (defvar gnus-newsgroup-unseen nil
1241 "List of unseen articles in the current newsgroup.")
1243 (defvar gnus-newsgroup-seen nil
1244 "Range of seen articles in the current newsgroup.")
1246 (defvar gnus-newsgroup-articles nil
1247 "List of articles in the current newsgroup.")
1249 (defvar gnus-newsgroup-scored nil
1250 "List of scored articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-incorporated nil
1253 "List of incorporated articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-headers nil
1256 "List of article headers in the current newsgroup.")
1258 (defvar gnus-newsgroup-threads nil)
1260 (defvar gnus-newsgroup-prepared nil
1261 "Whether the current group has been prepared properly.")
1263 (defvar gnus-newsgroup-ancient nil
1264 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1266 (defvar gnus-newsgroup-sparse nil)
1268 (defvar gnus-current-article nil)
1269 (defvar gnus-article-current nil)
1270 (defvar gnus-current-headers nil)
1271 (defvar gnus-have-all-headers nil)
1272 (defvar gnus-last-article nil)
1273 (defvar gnus-newsgroup-history nil)
1274 (defvar gnus-newsgroup-charset nil)
1275 (defvar gnus-newsgroup-ephemeral-charset nil)
1276 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1278 (defvar gnus-article-before-search nil)
1280 (defconst gnus-summary-local-variables
1281 '(gnus-newsgroup-name
1282 gnus-newsgroup-begin gnus-newsgroup-end
1283 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1284 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1285 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1286 gnus-newsgroup-unselected gnus-newsgroup-marked
1287 gnus-newsgroup-reads gnus-newsgroup-saved
1288 gnus-newsgroup-replied gnus-newsgroup-forwarded
1289 gnus-newsgroup-recent
1290 gnus-newsgroup-expirable
1291 gnus-newsgroup-processable gnus-newsgroup-killed
1292 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1293 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1294 gnus-newsgroup-seen gnus-newsgroup-articles
1295 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1296 gnus-newsgroup-headers gnus-newsgroup-threads
1297 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1298 gnus-current-article gnus-current-headers gnus-have-all-headers
1299 gnus-last-article gnus-article-internal-prepare-hook
1300 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1301 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1302 gnus-thread-expunge-below
1303 gnus-score-alist gnus-current-score-file
1304 (gnus-summary-expunge-below . global)
1305 (gnus-summary-mark-below . global)
1306 (gnus-orphan-score . global)
1307 gnus-newsgroup-active gnus-scores-exclude-files
1308 gnus-newsgroup-history gnus-newsgroup-ancient
1309 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1310 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1311 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1312 (gnus-newsgroup-expunged-tally . 0)
1313 gnus-cache-removable-articles gnus-newsgroup-cached
1314 gnus-newsgroup-data gnus-newsgroup-data-reverse
1315 gnus-newsgroup-limit gnus-newsgroup-limits
1316 gnus-newsgroup-charset gnus-newsgroup-display
1317 gnus-newsgroup-incorporated)
1318 "Variables that are buffer-local to the summary buffers.")
1320 (defvar gnus-newsgroup-variables nil
1321 "Variables that have separate values in the newsgroups.")
1323 ;; Byte-compiler warning.
1324 (eval-when-compile (defvar gnus-article-mode-map))
1326 ;; Subject simplification.
1328 (defun gnus-simplify-whitespace (str)
1329 "Remove excessive whitespace from STR."
1332 (while (string-match "[ \t][ \t]+" mystr)
1333 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1335 (substring mystr (match-end 0)))))
1337 (when (string-match "^[ \t]+" mystr)
1338 (setq mystr (substring mystr (match-end 0))))
1340 (when (string-match "[ \t]+$" mystr)
1341 (setq mystr (substring mystr 0 (match-beginning 0))))
1344 (defsubst gnus-simplify-subject-re (subject)
1345 "Remove \"Re:\" from subject lines."
1346 (if (string-match message-subject-re-regexp subject)
1347 (substring subject (match-end 0))
1350 (defun gnus-simplify-subject (subject &optional re-only)
1351 "Remove `Re:' and words in parentheses.
1352 If RE-ONLY is non-nil, strip leading `Re:'s only."
1353 (let ((case-fold-search t)) ;Ignore case.
1354 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1355 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1356 (setq subject (substring subject (match-end 0))))
1357 ;; Remove uninteresting prefixes.
1358 (when (and (not re-only)
1359 gnus-simplify-ignored-prefixes
1360 (string-match gnus-simplify-ignored-prefixes subject))
1361 (setq subject (substring subject (match-end 0))))
1362 ;; Remove words in parentheses from end.
1364 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1365 (setq subject (substring subject 0 (match-beginning 0)))))
1366 ;; Return subject string.
1369 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1371 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1372 (goto-char (point-min))
1373 (while (re-search-forward regexp nil t)
1374 (replace-match (or newtext ""))))
1376 (defun gnus-simplify-buffer-fuzzy ()
1377 "Simplify string in the buffer fuzzily.
1378 The string in the accessible portion of the current buffer is simplified.
1379 It is assumed to be a single-line subject.
1380 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1381 matter is removed. Additional things can be deleted by setting
1382 `gnus-simplify-subject-fuzzy-regexp'."
1383 (let ((case-fold-search t)
1385 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1387 (while (not (eq modified-tick (buffer-modified-tick)))
1388 (setq modified-tick (buffer-modified-tick))
1390 ((listp gnus-simplify-subject-fuzzy-regexp)
1391 (mapcar 'gnus-simplify-buffer-fuzzy-step
1392 gnus-simplify-subject-fuzzy-regexp))
1393 (gnus-simplify-subject-fuzzy-regexp
1394 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1395 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1396 (gnus-simplify-buffer-fuzzy-step
1397 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1398 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1400 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1401 (gnus-simplify-buffer-fuzzy-step " +" " ")
1402 (gnus-simplify-buffer-fuzzy-step " $")
1403 (gnus-simplify-buffer-fuzzy-step "^ +")))
1405 (defun gnus-simplify-subject-fuzzy (subject)
1406 "Simplify a subject string fuzzily.
1407 See `gnus-simplify-buffer-fuzzy' for details."
1409 (gnus-set-work-buffer)
1410 (let ((case-fold-search t))
1411 ;; Remove uninteresting prefixes.
1412 (when (and gnus-simplify-ignored-prefixes
1413 (string-match gnus-simplify-ignored-prefixes subject))
1414 (setq subject (substring subject (match-end 0))))
1416 (inline (gnus-simplify-buffer-fuzzy))
1419 (defsubst gnus-simplify-subject-fully (subject)
1420 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1422 (gnus-simplify-subject-functions
1423 (gnus-map-function gnus-simplify-subject-functions subject))
1424 ((null gnus-summary-gather-subject-limit)
1425 (gnus-simplify-subject-re subject))
1426 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1427 (gnus-simplify-subject-fuzzy subject))
1428 ((numberp gnus-summary-gather-subject-limit)
1429 (gnus-limit-string (gnus-simplify-subject-re subject)
1430 gnus-summary-gather-subject-limit))
1434 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1435 "Check whether two subjects are equal.
1436 If optional argument simple-first is t, first argument is already
1439 ((null simple-first)
1440 (equal (gnus-simplify-subject-fully s1)
1441 (gnus-simplify-subject-fully s2)))
1444 (gnus-simplify-subject-fully s2)))))
1446 (defun gnus-summary-bubble-group ()
1447 "Increase the score of the current group.
1448 This is a handy function to add to `gnus-summary-exit-hook' to
1449 increase the score of each group you read."
1450 (gnus-group-add-score gnus-newsgroup-name))
1454 ;;; Gnus summary mode
1457 (put 'gnus-summary-mode 'mode-class 'special)
1459 (defvar gnus-article-commands-menu)
1462 ;; Non-orthogonal keys
1464 (gnus-define-keys gnus-summary-mode-map
1465 " " gnus-summary-next-page
1466 "\177" gnus-summary-prev-page
1467 [delete] gnus-summary-prev-page
1468 [backspace] gnus-summary-prev-page
1469 "\r" gnus-summary-scroll-up
1470 "\M-\r" gnus-summary-scroll-down
1471 "n" gnus-summary-next-unread-article
1472 "p" gnus-summary-prev-unread-article
1473 "N" gnus-summary-next-article
1474 "P" gnus-summary-prev-article
1475 "\M-\C-n" gnus-summary-next-same-subject
1476 "\M-\C-p" gnus-summary-prev-same-subject
1477 "\M-n" gnus-summary-next-unread-subject
1478 "\M-p" gnus-summary-prev-unread-subject
1479 "." gnus-summary-first-unread-article
1480 "," gnus-summary-best-unread-article
1481 "\M-s" gnus-summary-search-article-forward
1482 "\M-r" gnus-summary-search-article-backward
1483 "<" gnus-summary-beginning-of-article
1484 ">" gnus-summary-end-of-article
1485 "j" gnus-summary-goto-article
1486 "^" gnus-summary-refer-parent-article
1487 "\M-^" gnus-summary-refer-article
1488 "u" gnus-summary-tick-article-forward
1489 "!" gnus-summary-tick-article-forward
1490 "U" gnus-summary-tick-article-backward
1491 "d" gnus-summary-mark-as-read-forward
1492 "D" gnus-summary-mark-as-read-backward
1493 "E" gnus-summary-mark-as-expirable
1494 "\M-u" gnus-summary-clear-mark-forward
1495 "\M-U" gnus-summary-clear-mark-backward
1496 "k" gnus-summary-kill-same-subject-and-select
1497 "\C-k" gnus-summary-kill-same-subject
1498 "\M-\C-k" gnus-summary-kill-thread
1499 "\M-\C-l" gnus-summary-lower-thread
1500 "e" gnus-summary-edit-article
1501 "#" gnus-summary-mark-as-processable
1502 "\M-#" gnus-summary-unmark-as-processable
1503 "\M-\C-t" gnus-summary-toggle-threads
1504 "\M-\C-s" gnus-summary-show-thread
1505 "\M-\C-h" gnus-summary-hide-thread
1506 "\M-\C-f" gnus-summary-next-thread
1507 "\M-\C-b" gnus-summary-prev-thread
1508 [(meta down)] gnus-summary-next-thread
1509 [(meta up)] gnus-summary-prev-thread
1510 "\M-\C-u" gnus-summary-up-thread
1511 "\M-\C-d" gnus-summary-down-thread
1512 "&" gnus-summary-execute-command
1513 "c" gnus-summary-catchup-and-exit
1514 "\C-w" gnus-summary-mark-region-as-read
1515 "\C-t" gnus-summary-toggle-truncation
1516 "?" gnus-summary-mark-as-dormant
1517 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1518 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1519 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1520 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1521 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1522 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1523 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1524 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1525 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1526 "=" gnus-summary-expand-window
1527 "\C-x\C-s" gnus-summary-reselect-current-group
1528 "\M-g" gnus-summary-rescan-group
1529 "w" gnus-summary-stop-page-breaking
1530 "\C-c\C-r" gnus-summary-caesar-message
1531 "\M-t" gnus-summary-toggle-mime
1532 "f" gnus-summary-followup
1533 "F" gnus-summary-followup-with-original
1534 "C" gnus-summary-cancel-article
1535 "r" gnus-summary-reply
1536 "R" gnus-summary-reply-with-original
1537 "\C-c\C-f" gnus-summary-mail-forward
1538 "o" gnus-summary-save-article
1539 "\C-o" gnus-summary-save-article-mail
1540 "|" gnus-summary-pipe-output
1541 "\M-k" gnus-summary-edit-local-kill
1542 "\M-K" gnus-summary-edit-global-kill
1544 "\C-c\C-d" gnus-summary-describe-group
1545 "q" gnus-summary-exit
1546 "Q" gnus-summary-exit-no-update
1547 "\C-c\C-i" gnus-info-find-node
1548 gnus-mouse-2 gnus-mouse-pick-article
1549 "m" gnus-summary-mail-other-window
1550 "a" gnus-summary-post-news
1551 "x" gnus-summary-limit-to-unread
1552 "s" gnus-summary-isearch-article
1553 "t" gnus-article-toggle-headers
1554 "g" gnus-summary-show-article
1555 "l" gnus-summary-goto-last-article
1556 "v" gnus-summary-preview-mime-message
1557 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1558 "\C-d" gnus-summary-enter-digest-group
1559 "\M-\C-d" gnus-summary-read-document
1560 "\M-\C-e" gnus-summary-edit-parameters
1561 "\M-\C-a" gnus-summary-customize-parameters
1563 "*" gnus-cache-enter-article
1564 "\M-*" gnus-cache-remove-article
1565 "\M-&" gnus-summary-universal-argument
1566 "\C-l" gnus-recenter
1567 "I" gnus-summary-increase-score
1568 "L" gnus-summary-lower-score
1569 "\M-i" gnus-symbolic-argument
1570 "h" gnus-summary-select-article-buffer
1572 "V" gnus-summary-score-map
1573 "X" gnus-uu-extract-map
1574 "S" gnus-summary-send-map)
1576 ;; Sort of orthogonal keymap
1577 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1578 "t" gnus-summary-tick-article-forward
1579 "!" gnus-summary-tick-article-forward
1580 "d" gnus-summary-mark-as-read-forward
1581 "r" gnus-summary-mark-as-read-forward
1582 "c" gnus-summary-clear-mark-forward
1583 " " gnus-summary-clear-mark-forward
1584 "e" gnus-summary-mark-as-expirable
1585 "x" gnus-summary-mark-as-expirable
1586 "?" gnus-summary-mark-as-dormant
1587 "b" gnus-summary-set-bookmark
1588 "B" gnus-summary-remove-bookmark
1589 "#" gnus-summary-mark-as-processable
1590 "\M-#" gnus-summary-unmark-as-processable
1591 "S" gnus-summary-limit-include-expunged
1592 "C" gnus-summary-catchup
1593 "H" gnus-summary-catchup-to-here
1594 "h" gnus-summary-catchup-from-here
1595 "\C-c" gnus-summary-catchup-all
1596 "k" gnus-summary-kill-same-subject-and-select
1597 "K" gnus-summary-kill-same-subject
1598 "P" gnus-uu-mark-map)
1600 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1601 "c" gnus-summary-clear-above
1602 "u" gnus-summary-tick-above
1603 "m" gnus-summary-mark-above
1604 "k" gnus-summary-kill-below)
1606 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1607 "/" gnus-summary-limit-to-subject
1608 "n" gnus-summary-limit-to-articles
1609 "w" gnus-summary-pop-limit
1610 "s" gnus-summary-limit-to-subject
1611 "a" gnus-summary-limit-to-author
1612 "u" gnus-summary-limit-to-unread
1613 "m" gnus-summary-limit-to-marks
1614 "M" gnus-summary-limit-exclude-marks
1615 "v" gnus-summary-limit-to-score
1616 "*" gnus-summary-limit-include-cached
1617 "D" gnus-summary-limit-include-dormant
1618 "T" gnus-summary-limit-include-thread
1619 "d" gnus-summary-limit-exclude-dormant
1620 "t" gnus-summary-limit-to-age
1621 "x" gnus-summary-limit-to-extra
1622 "E" gnus-summary-limit-include-expunged
1623 "c" gnus-summary-limit-exclude-childless-dormant
1624 "C" gnus-summary-limit-mark-excluded-as-read
1625 "o" gnus-summary-insert-old-articles
1626 "N" gnus-summary-insert-new-articles)
1628 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1629 "n" gnus-summary-next-unread-article
1630 "p" gnus-summary-prev-unread-article
1631 "N" gnus-summary-next-article
1632 "P" gnus-summary-prev-article
1633 "\C-n" gnus-summary-next-same-subject
1634 "\C-p" gnus-summary-prev-same-subject
1635 "\M-n" gnus-summary-next-unread-subject
1636 "\M-p" gnus-summary-prev-unread-subject
1637 "f" gnus-summary-first-unread-article
1638 "b" gnus-summary-best-unread-article
1639 "j" gnus-summary-goto-article
1640 "g" gnus-summary-goto-subject
1641 "l" gnus-summary-goto-last-article
1642 "o" gnus-summary-pop-article)
1644 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1645 "k" gnus-summary-kill-thread
1646 "l" gnus-summary-lower-thread
1647 "i" gnus-summary-raise-thread
1648 "T" gnus-summary-toggle-threads
1649 "t" gnus-summary-rethread-current
1650 "^" gnus-summary-reparent-thread
1651 "s" gnus-summary-show-thread
1652 "S" gnus-summary-show-all-threads
1653 "h" gnus-summary-hide-thread
1654 "H" gnus-summary-hide-all-threads
1655 "n" gnus-summary-next-thread
1656 "p" gnus-summary-prev-thread
1657 "u" gnus-summary-up-thread
1658 "o" gnus-summary-top-thread
1659 "d" gnus-summary-down-thread
1660 "#" gnus-uu-mark-thread
1661 "\M-#" gnus-uu-unmark-thread)
1663 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1664 "g" gnus-summary-prepare
1665 "c" gnus-summary-insert-cached-articles)
1667 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1668 "c" gnus-summary-catchup-and-exit
1669 "C" gnus-summary-catchup-all-and-exit
1670 "E" gnus-summary-exit-no-update
1671 "J" gnus-summary-jump-to-other-group
1672 "Q" gnus-summary-exit
1673 "Z" gnus-summary-exit
1674 "n" gnus-summary-catchup-and-goto-next-group
1675 "R" gnus-summary-reselect-current-group
1676 "G" gnus-summary-rescan-group
1677 "N" gnus-summary-next-group
1678 "s" gnus-summary-save-newsrc
1679 "P" gnus-summary-prev-group)
1681 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1682 " " gnus-summary-next-page
1683 "n" gnus-summary-next-page
1684 "\177" gnus-summary-prev-page
1685 [delete] gnus-summary-prev-page
1686 "p" gnus-summary-prev-page
1687 "\r" gnus-summary-scroll-up
1688 "\M-\r" gnus-summary-scroll-down
1689 "<" gnus-summary-beginning-of-article
1690 ">" gnus-summary-end-of-article
1691 "b" gnus-summary-beginning-of-article
1692 "e" gnus-summary-end-of-article
1693 "^" gnus-summary-refer-parent-article
1694 "r" gnus-summary-refer-parent-article
1695 "D" gnus-summary-enter-digest-group
1696 "R" gnus-summary-refer-references
1697 "T" gnus-summary-refer-thread
1698 "g" gnus-summary-show-article
1699 "s" gnus-summary-isearch-article
1700 "P" gnus-summary-print-article
1701 "M" gnus-mailing-list-insinuate
1702 "t" gnus-article-babel)
1704 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1705 "b" gnus-article-add-buttons
1706 "B" gnus-article-add-buttons-to-head
1707 "o" gnus-article-treat-overstrike
1708 "e" gnus-article-emphasize
1709 "w" gnus-article-fill-cited-article
1710 "Q" gnus-article-fill-long-lines
1711 "C" gnus-article-capitalize-sentences
1712 "c" gnus-article-remove-cr
1713 "Z" gnus-article-decode-HZ
1714 "f" gnus-article-display-x-face
1715 "l" gnus-summary-stop-page-breaking
1716 "r" gnus-summary-caesar-message
1717 "t" gnus-article-toggle-headers
1718 "v" gnus-summary-verbose-headers
1719 "m" gnus-summary-toggle-mime
1720 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1721 "p" gnus-article-verify-x-pgp-sig
1722 "d" gnus-article-treat-dumbquotes
1723 "s" gnus-smiley-display)
1725 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1726 "a" gnus-article-hide
1727 "h" gnus-article-toggle-headers
1728 "b" gnus-article-hide-boring-headers
1729 "s" gnus-article-hide-signature
1730 "c" gnus-article-hide-citation
1731 "C" gnus-article-hide-citation-in-followups
1732 "l" gnus-article-hide-list-identifiers
1733 "p" gnus-article-hide-pgp
1734 "B" gnus-article-strip-banner
1735 "P" gnus-article-hide-pem
1736 "\C-c" gnus-article-hide-citation-maybe)
1738 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1739 "a" gnus-article-highlight
1740 "h" gnus-article-highlight-headers
1741 "c" gnus-article-highlight-citation
1742 "s" gnus-article-highlight-signature)
1744 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1745 "z" gnus-article-date-ut
1746 "u" gnus-article-date-ut
1747 "l" gnus-article-date-local
1748 "p" gnus-article-date-english
1749 "e" gnus-article-date-lapsed
1750 "o" gnus-article-date-original
1751 "i" gnus-article-date-iso8601
1752 "s" gnus-article-date-user)
1754 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1755 "t" gnus-article-remove-trailing-blank-lines
1756 "l" gnus-article-strip-leading-blank-lines
1757 "m" gnus-article-strip-multiple-blank-lines
1758 "a" gnus-article-strip-blank-lines
1759 "A" gnus-article-strip-all-blank-lines
1760 "s" gnus-article-strip-leading-space
1761 "e" gnus-article-strip-trailing-space
1762 "w" gnus-article-remove-leading-whitespace)
1764 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1766 "f" gnus-summary-fetch-faq
1767 "d" gnus-summary-describe-group
1768 "h" gnus-summary-describe-briefly
1769 "i" gnus-info-find-node)
1771 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1772 "e" gnus-summary-expire-articles
1773 "\M-\C-e" gnus-summary-expire-articles-now
1774 "\177" gnus-summary-delete-article
1775 [delete] gnus-summary-delete-article
1776 [backspace] gnus-summary-delete-article
1777 "m" gnus-summary-move-article
1778 "r" gnus-summary-respool-article
1779 "w" gnus-summary-edit-article
1780 "c" gnus-summary-copy-article
1781 "B" gnus-summary-crosspost-article
1782 "q" gnus-summary-respool-query
1783 "t" gnus-summary-respool-trace
1784 "i" gnus-summary-import-article
1785 "I" gnus-summary-create-article
1786 "p" gnus-summary-article-posted-p)
1788 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1789 "o" gnus-summary-save-article
1790 "m" gnus-summary-save-article-mail
1791 "F" gnus-summary-write-article-file
1792 "r" gnus-summary-save-article-rmail
1793 "f" gnus-summary-save-article-file
1794 "b" gnus-summary-save-article-body-file
1795 "h" gnus-summary-save-article-folder
1796 "v" gnus-summary-save-article-vm
1797 "p" gnus-summary-pipe-output
1798 "s" gnus-soup-add-article)
1800 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1801 "b" gnus-summary-display-buttonized
1802 "m" gnus-summary-repair-multipart
1803 "v" gnus-article-view-part
1804 "o" gnus-article-save-part
1805 "c" gnus-article-copy-part
1806 "C" gnus-article-view-part-as-charset
1807 "e" gnus-article-externalize-part
1808 "E" gnus-article-encrypt-body
1809 "i" gnus-article-inline-part
1810 "|" gnus-article-pipe-part))
1812 (defvar gnus-article-post-menu nil)
1814 (defun gnus-summary-make-menu-bar ()
1815 (gnus-turn-off-edit-menu 'summary)
1817 (unless (boundp 'gnus-summary-misc-menu)
1820 gnus-summary-kill-menu gnus-summary-mode-map ""
1825 ["Customize" gnus-score-customize t])
1826 (gnus-make-score-map 'increase)
1827 (gnus-make-score-map 'lower)
1829 ["Kill below" gnus-summary-kill-below t]
1830 ["Mark above" gnus-summary-mark-above t]
1831 ["Tick above" gnus-summary-tick-above t]
1832 ["Clear above" gnus-summary-clear-above t])
1833 ["Current score" gnus-summary-current-score t]
1834 ["Set score" gnus-summary-set-score t]
1835 ["Switch current score file..." gnus-score-change-score-file t]
1836 ["Set mark below..." gnus-score-set-mark-below t]
1837 ["Set expunge below..." gnus-score-set-expunge-below t]
1838 ["Edit current score file" gnus-score-edit-current-scores t]
1839 ["Edit score file" gnus-score-edit-file t]
1840 ["Trace score" gnus-score-find-trace t]
1841 ["Find words" gnus-score-find-favourite-words t]
1842 ["Rescore buffer" gnus-summary-rescore t]
1843 ["Increase score..." gnus-summary-increase-score t]
1844 ["Lower score..." gnus-summary-lower-score t]))))
1846 ;; Define both the Article menu in the summary buffer and the equivalent
1847 ;; Commands menu in the article buffer here for consistency.
1850 ["All" gnus-article-hide t]
1851 ["Headers" gnus-article-toggle-headers t]
1852 ["Signature" gnus-article-hide-signature t]
1853 ["Citation" gnus-article-hide-citation t]
1854 ["List identifiers" gnus-article-hide-list-identifiers t]
1855 ["PGP" gnus-article-hide-pgp t]
1856 ["Banner" gnus-article-strip-banner t]
1857 ["Boring headers" gnus-article-hide-boring-headers t])
1859 ["All" gnus-article-highlight t]
1860 ["Headers" gnus-article-highlight-headers t]
1861 ["Signature" gnus-article-highlight-signature t]
1862 ["Citation" gnus-article-highlight-citation t])
1864 ["Local" gnus-article-date-local t]
1865 ["ISO8601" gnus-article-date-iso8601 t]
1866 ["UT" gnus-article-date-ut t]
1867 ["Original" gnus-article-date-original t]
1868 ["Lapsed" gnus-article-date-lapsed t]
1869 ["User-defined" gnus-article-date-user t])
1872 ["Leading" gnus-article-strip-leading-blank-lines t]
1873 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1874 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1875 ["All of the above" gnus-article-strip-blank-lines t]
1876 ["All" gnus-article-strip-all-blank-lines t]
1877 ["Leading space" gnus-article-strip-leading-space t]
1878 ["Trailing space" gnus-article-strip-trailing-space t]
1879 ["Leading space in headers"
1880 gnus-article-remove-leading-whitespace t])
1881 ["Overstrike" gnus-article-treat-overstrike t]
1882 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1883 ["Emphasis" gnus-article-emphasize t]
1884 ["Word wrap" gnus-article-fill-cited-article t]
1885 ["Fill long lines" gnus-article-fill-long-lines t]
1886 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1887 ["CR" gnus-article-remove-cr t]
1888 ["Show X-Face" gnus-article-display-x-face t]
1889 ["Rot 13" gnus-summary-caesar-message
1890 ,@(if (featurep 'xemacs) '(t)
1891 '(:help "\"Caesar rotate\" article by 13"))]
1892 ["Unix pipe" gnus-summary-pipe-message t]
1893 ["Add buttons" gnus-article-add-buttons t]
1894 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1895 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1896 ["Toggle MIME" gnus-summary-toggle-mime t]
1897 ["Verbose header" gnus-summary-verbose-headers t]
1898 ["Toggle header" gnus-summary-toggle-header t]
1899 ["Toggle smileys" gnus-smiley-display t]
1900 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1901 ["HZ" gnus-article-decode-HZ t])
1903 ["Save in default format" gnus-summary-save-article
1904 ,@(if (featurep 'xemacs) '(t)
1905 '(:help "Save article using default method"))]
1906 ["Save in file" gnus-summary-save-article-file
1907 ,@(if (featurep 'xemacs) '(t)
1908 '(:help "Save article in file"))]
1909 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1910 ["Save in MH folder" gnus-summary-save-article-folder t]
1911 ["Save in VM folder" gnus-summary-save-article-vm t]
1912 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1913 ["Save body in file" gnus-summary-save-article-body-file t]
1914 ["Pipe through a filter" gnus-summary-pipe-output t]
1915 ["Add to SOUP packet" gnus-soup-add-article t]
1916 ["Print" gnus-summary-print-article t])
1918 ["Respool article..." gnus-summary-respool-article t]
1919 ["Move article..." gnus-summary-move-article
1920 (gnus-check-backend-function
1921 'request-move-article gnus-newsgroup-name)]
1922 ["Copy article..." gnus-summary-copy-article t]
1923 ["Crosspost article..." gnus-summary-crosspost-article
1924 (gnus-check-backend-function
1925 'request-replace-article gnus-newsgroup-name)]
1926 ["Import file..." gnus-summary-import-article t]
1927 ["Create article..." gnus-summary-create-article t]
1928 ["Check if posted" gnus-summary-article-posted-p t]
1929 ["Edit article" gnus-summary-edit-article
1930 (not (gnus-group-read-only-p))]
1931 ["Delete article" gnus-summary-delete-article
1932 (gnus-check-backend-function
1933 'request-expire-articles gnus-newsgroup-name)]
1934 ["Query respool" gnus-summary-respool-query t]
1935 ["Trace respool" gnus-summary-respool-trace t]
1936 ["Delete expirable articles" gnus-summary-expire-articles-now
1937 (gnus-check-backend-function
1938 'request-expire-articles gnus-newsgroup-name)])
1940 ["Uudecode" gnus-uu-decode-uu
1941 ,@(if (featurep 'xemacs) '(t)
1942 '(:help "Decode uuencoded article(s)"))]
1943 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1944 ["Unshar" gnus-uu-decode-unshar t]
1945 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1946 ["Save" gnus-uu-decode-save t]
1947 ["Binhex" gnus-uu-decode-binhex t]
1948 ["Postscript" gnus-uu-decode-postscript t])
1950 ["Enter article" gnus-cache-enter-article t]
1951 ["Remove article" gnus-cache-remove-article t])
1952 ["Translate" gnus-article-babel t]
1953 ["Select article buffer" gnus-summary-select-article-buffer t]
1954 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1955 ["Isearch article..." gnus-summary-isearch-article t]
1956 ["Beginning of the article" gnus-summary-beginning-of-article t]
1957 ["End of the article" gnus-summary-end-of-article t]
1958 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1959 ["Fetch referenced articles" gnus-summary-refer-references t]
1960 ["Fetch current thread" gnus-summary-refer-thread t]
1961 ["Fetch article with id..." gnus-summary-refer-article t]
1962 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1963 ["Redisplay" gnus-summary-show-article t]
1964 ["Raw article" gnus-summary-show-raw-article t])))
1966 gnus-summary-article-menu gnus-summary-mode-map ""
1967 (cons "Article" innards))
1969 (if (not (keymapp gnus-summary-article-menu))
1971 gnus-article-commands-menu gnus-article-mode-map ""
1972 (cons "Commands" innards))
1973 ;; in Emacs, don't share menu.
1974 (setq gnus-article-commands-menu
1975 (copy-keymap gnus-summary-article-menu))
1976 (define-key gnus-article-mode-map [menu-bar commands]
1977 (cons "Commands" gnus-article-commands-menu))))
1980 gnus-summary-thread-menu gnus-summary-mode-map ""
1982 ["Toggle threading" gnus-summary-toggle-threads t]
1983 ["Hide threads" gnus-summary-hide-all-threads t]
1984 ["Show threads" gnus-summary-show-all-threads t]
1985 ["Hide thread" gnus-summary-hide-thread t]
1986 ["Show thread" gnus-summary-show-thread t]
1987 ["Go to next thread" gnus-summary-next-thread t]
1988 ["Go to previous thread" gnus-summary-prev-thread t]
1989 ["Go down thread" gnus-summary-down-thread t]
1990 ["Go up thread" gnus-summary-up-thread t]
1991 ["Top of thread" gnus-summary-top-thread t]
1992 ["Mark thread as read" gnus-summary-kill-thread t]
1993 ["Lower thread score" gnus-summary-lower-thread t]
1994 ["Raise thread score" gnus-summary-raise-thread t]
1995 ["Rethread current" gnus-summary-rethread-current t]))
1998 gnus-summary-post-menu gnus-summary-mode-map ""
2000 ["Post an article" gnus-summary-post-news
2001 ,@(if (featurep 'xemacs) '(t)
2002 '(:help "Post an article"))]
2003 ["Followup" gnus-summary-followup
2004 ,@(if (featurep 'xemacs) '(t)
2005 '(:help "Post followup to this article"))]
2006 ["Followup and yank" gnus-summary-followup-with-original
2007 ,@(if (featurep 'xemacs) '(t)
2008 '(:help "Post followup to this article, quoting its contents"))]
2009 ["Supersede article" gnus-summary-supersede-article t]
2010 ["Cancel article" gnus-summary-cancel-article
2011 ,@(if (featurep 'xemacs) '(t)
2012 '(:help "Cancel an article you posted"))]
2013 ["Reply" gnus-summary-reply t]
2014 ["Reply and yank" gnus-summary-reply-with-original t]
2015 ["Wide reply" gnus-summary-wide-reply t]
2016 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2017 ,@(if (featurep 'xemacs) '(t)
2018 '(:help "Mail a reply, quoting this article"))]
2019 ["Mail forward" gnus-summary-mail-forward t]
2020 ["Post forward" gnus-summary-post-forward t]
2021 ["Digest and mail" gnus-summary-digest-mail-forward t]
2022 ["Digest and post" gnus-summary-digest-post-forward t]
2023 ["Resend message" gnus-summary-resend-message t]
2024 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2025 ["Send a mail" gnus-summary-mail-other-window t]
2026 ["Uuencode and post" gnus-uu-post-news
2027 ,@(if (featurep 'xemacs) '(t)
2028 '(:help "Post a uuencoded article"))]
2029 ["Followup via news" gnus-summary-followup-to-mail t]
2030 ["Followup via news and yank"
2031 gnus-summary-followup-to-mail-with-original t]
2033 ;;["Send" gnus-summary-send-draft t]
2034 ;;["Send bounced" gnus-resend-bounced-mail t])
2038 ((not (keymapp gnus-summary-post-menu))
2039 (setq gnus-article-post-menu gnus-summary-post-menu))
2040 ((not gnus-article-post-menu)
2041 ;; Don't share post menu.
2042 (setq gnus-article-post-menu
2043 (copy-keymap gnus-summary-post-menu))))
2044 (define-key gnus-article-mode-map [menu-bar post]
2045 (cons "Post" gnus-article-post-menu))
2048 gnus-summary-misc-menu gnus-summary-mode-map ""
2051 ["Mark as read" gnus-summary-mark-as-read-forward t]
2052 ["Mark same subject and select"
2053 gnus-summary-kill-same-subject-and-select t]
2054 ["Mark same subject" gnus-summary-kill-same-subject t]
2055 ["Catchup" gnus-summary-catchup
2056 ,@(if (featurep 'xemacs) '(t)
2057 '(:help "Mark unread articles in this group as read"))]
2058 ["Catchup all" gnus-summary-catchup-all t]
2059 ["Catchup to here" gnus-summary-catchup-to-here t]
2060 ["Catchup from here" gnus-summary-catchup-from-here t]
2061 ["Catchup region" gnus-summary-mark-region-as-read t]
2062 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2064 ["Tick" gnus-summary-tick-article-forward t]
2065 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2066 ["Remove marks" gnus-summary-clear-mark-forward t]
2067 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2068 ["Set bookmark" gnus-summary-set-bookmark t]
2069 ["Remove bookmark" gnus-summary-remove-bookmark t])
2071 ["Marks..." gnus-summary-limit-to-marks t]
2072 ["Subject..." gnus-summary-limit-to-subject t]
2073 ["Author..." gnus-summary-limit-to-author t]
2074 ["Age..." gnus-summary-limit-to-age t]
2075 ["Extra..." gnus-summary-limit-to-extra t]
2076 ["Score" gnus-summary-limit-to-score t]
2077 ["Unread" gnus-summary-limit-to-unread t]
2078 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2079 ["Articles" gnus-summary-limit-to-articles t]
2080 ["Pop limit" gnus-summary-pop-limit t]
2081 ["Show dormant" gnus-summary-limit-include-dormant t]
2082 ["Hide childless dormant"
2083 gnus-summary-limit-exclude-childless-dormant t]
2084 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2085 ["Hide marked" gnus-summary-limit-exclude-marks t]
2086 ["Show expunged" gnus-summary-limit-include-expunged t])
2088 ["Set mark" gnus-summary-mark-as-processable t]
2089 ["Remove mark" gnus-summary-unmark-as-processable t]
2090 ["Remove all marks" gnus-summary-unmark-all-processable t]
2091 ["Mark above" gnus-uu-mark-over t]
2092 ["Mark series" gnus-uu-mark-series t]
2093 ["Mark region" gnus-uu-mark-region t]
2094 ["Unmark region" gnus-uu-unmark-region t]
2095 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2096 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2097 ["Mark all" gnus-uu-mark-all t]
2098 ["Mark buffer" gnus-uu-mark-buffer t]
2099 ["Mark sparse" gnus-uu-mark-sparse t]
2100 ["Mark thread" gnus-uu-mark-thread t]
2101 ["Unmark thread" gnus-uu-unmark-thread t]
2102 ("Process Mark Sets"
2103 ["Kill" gnus-summary-kill-process-mark t]
2104 ["Yank" gnus-summary-yank-process-mark
2105 gnus-newsgroup-process-stack]
2106 ["Save" gnus-summary-save-process-mark t]))
2108 ["Page forward" gnus-summary-next-page
2109 ,@(if (featurep 'xemacs) '(t)
2110 '(:help "Show next page of article"))]
2111 ["Page backward" gnus-summary-prev-page
2112 ,@(if (featurep 'xemacs) '(t)
2113 '(:help "Show previous page of article"))]
2114 ["Line forward" gnus-summary-scroll-up t])
2116 ["Next unread article" gnus-summary-next-unread-article t]
2117 ["Previous unread article" gnus-summary-prev-unread-article t]
2118 ["Next article" gnus-summary-next-article t]
2119 ["Previous article" gnus-summary-prev-article t]
2120 ["Next unread subject" gnus-summary-next-unread-subject t]
2121 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2122 ["Next article same subject" gnus-summary-next-same-subject t]
2123 ["Previous article same subject" gnus-summary-prev-same-subject t]
2124 ["First unread article" gnus-summary-first-unread-article t]
2125 ["Best unread article" gnus-summary-best-unread-article t]
2126 ["Go to subject number..." gnus-summary-goto-subject t]
2127 ["Go to article number..." gnus-summary-goto-article t]
2128 ["Go to the last article" gnus-summary-goto-last-article t]
2129 ["Pop article off history" gnus-summary-pop-article t])
2131 ["Sort by number" gnus-summary-sort-by-number t]
2132 ["Sort by author" gnus-summary-sort-by-author t]
2133 ["Sort by subject" gnus-summary-sort-by-subject t]
2134 ["Sort by date" gnus-summary-sort-by-date t]
2135 ["Sort by score" gnus-summary-sort-by-score t]
2136 ["Sort by lines" gnus-summary-sort-by-lines t]
2137 ["Sort by characters" gnus-summary-sort-by-chars t]
2138 ["Original sort" gnus-summary-sort-by-original t])
2140 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2141 ["Describe group" gnus-summary-describe-group t]
2142 ["Read manual" gnus-info-find-node t])
2144 ["Pick and read" gnus-pick-mode t]
2145 ["Binary" gnus-binary-mode t])
2147 ["Regenerate" gnus-summary-prepare t]
2148 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2149 ["Toggle threading" gnus-summary-toggle-threads t])
2150 ["See old articles" gnus-summary-insert-old-articles t]
2151 ["See new articles" gnus-summary-insert-new-articles t]
2152 ["Filter articles..." gnus-summary-execute-command t]
2153 ["Run command on subjects..." gnus-summary-universal-argument t]
2154 ["Search articles forward..." gnus-summary-search-article-forward t]
2155 ["Search articles backward..." gnus-summary-search-article-backward t]
2156 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2157 ["Expand window" gnus-summary-expand-window t]
2158 ["Expire expirable articles" gnus-summary-expire-articles
2159 (gnus-check-backend-function
2160 'request-expire-articles gnus-newsgroup-name)]
2161 ["Edit local kill file" gnus-summary-edit-local-kill t]
2162 ["Edit main kill file" gnus-summary-edit-global-kill t]
2163 ["Edit group parameters" gnus-summary-edit-parameters t]
2164 ["Customize group parameters" gnus-summary-customize-parameters t]
2165 ["Send a bug report" gnus-bug t]
2167 ["Catchup and exit" gnus-summary-catchup-and-exit
2168 ,@(if (featurep 'xemacs) '(t)
2169 '(:help "Mark unread articles in this group as read, then exit"))]
2170 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2171 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2172 ["Exit group" gnus-summary-exit
2173 ,@(if (featurep 'xemacs) '(t)
2174 '(:help "Exit current group, return to group selection mode"))]
2175 ["Exit group without updating" gnus-summary-exit-no-update t]
2176 ["Exit and goto next group" gnus-summary-next-group t]
2177 ["Exit and goto prev group" gnus-summary-prev-group t]
2178 ["Reselect group" gnus-summary-reselect-current-group t]
2179 ["Rescan group" gnus-summary-rescan-group t]
2180 ["Update dribble" gnus-summary-save-newsrc t])))
2182 (gnus-run-hooks 'gnus-summary-menu-hook)))
2184 (defvar gnus-summary-tool-bar-map nil)
2186 ;; Emacs 21 tool bar. Should be no-op otherwise.
2187 (defun gnus-summary-make-tool-bar ()
2188 (if (and (fboundp 'tool-bar-add-item-from-menu)
2189 (default-value 'tool-bar-mode)
2190 (not gnus-summary-tool-bar-map))
2191 (setq gnus-summary-tool-bar-map
2192 (let ((tool-bar-map (make-sparse-keymap))
2193 (load-path (mm-image-load-path)))
2194 (tool-bar-add-item-from-menu
2195 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2196 (tool-bar-add-item-from-menu
2197 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2198 (tool-bar-add-item-from-menu
2199 'gnus-summary-post-news "post" gnus-summary-mode-map)
2200 (tool-bar-add-item-from-menu
2201 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2202 (tool-bar-add-item-from-menu
2203 'gnus-summary-followup "followup" gnus-summary-mode-map)
2204 (tool-bar-add-item-from-menu
2205 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2206 (tool-bar-add-item-from-menu
2207 'gnus-summary-reply "reply" gnus-summary-mode-map)
2208 (tool-bar-add-item-from-menu
2209 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2210 (tool-bar-add-item-from-menu
2211 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2212 (tool-bar-add-item-from-menu
2213 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2214 (tool-bar-add-item-from-menu
2215 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2216 (tool-bar-add-item-from-menu
2217 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2218 (tool-bar-add-item-from-menu
2219 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2220 (tool-bar-add-item-from-menu
2221 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2222 (tool-bar-add-item-from-menu
2223 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2225 (if gnus-summary-tool-bar-map
2226 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2228 (defun gnus-score-set-default (var value)
2229 "A version of set that updates the GNU Emacs menu-bar."
2231 ;; It is the message that forces the active status to be updated.
2234 (defun gnus-make-score-map (type)
2235 "Make a summary score map of type TYPE."
2238 (let ((headers '(("author" "from" string)
2239 ("subject" "subject" string)
2240 ("article body" "body" string)
2241 ("article head" "head" string)
2242 ("xref" "xref" string)
2243 ("extra header" "extra" string)
2244 ("lines" "lines" number)
2245 ("followups to author" "followup" string)))
2246 (types '((number ("less than" <)
2249 (string ("substring" s)
2253 (perms '(("temporary" (current-time-string))
2261 (if (eq type 'lower)
2266 (setq header (car headers))
2272 (let ((ts (cdr (assoc (nth 2 header) types)))
2288 'gnus-summary-score-entry
2290 (if (or (string= (nth 1 header)
2292 (string= (nth 1 header)
2295 (list 'gnus-summary-header
2297 (list 'quote (nth 1 (car ts)))
2298 (list 'gnus-score-delta-default
2305 (list (nreverse outp))))
2308 (list (nreverse outt))))
2310 (setq headers (cdr headers)))
2311 (list (nreverse outh))))))))
2315 (defun gnus-summary-mode (&optional group)
2316 "Major mode for reading articles.
2318 All normal editing commands are switched off.
2319 \\<gnus-summary-mode-map>
2320 Each line in this buffer represents one article. To read an
2321 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2322 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2325 You can also post articles and send mail from this buffer. To
2326 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2327 of an article, type `\\[gnus-summary-reply]'.
2329 There are approx. one gazillion commands you can execute in this
2330 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2332 The following commands are available:
2334 \\{gnus-summary-mode-map}"
2336 (kill-all-local-variables)
2337 (when (gnus-visual-p 'summary-menu 'menu)
2338 (gnus-summary-make-menu-bar)
2339 (gnus-summary-make-tool-bar))
2340 (gnus-summary-make-local-variables)
2341 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2342 (gnus-summary-make-local-variables))
2343 (gnus-make-thread-indent-array)
2344 (gnus-simplify-mode-line)
2345 (setq major-mode 'gnus-summary-mode)
2346 (setq mode-name "Summary")
2347 (make-local-variable 'minor-mode-alist)
2348 (use-local-map gnus-summary-mode-map)
2349 (buffer-disable-undo)
2350 (setq buffer-read-only t) ;Disable modification
2351 (setq truncate-lines t)
2352 (setq selective-display t)
2353 (setq selective-display-ellipses t) ;Display `...'
2354 (gnus-summary-set-display-table)
2355 (gnus-set-default-directory)
2356 (setq gnus-newsgroup-name group)
2357 (unless (gnus-news-group-p group)
2358 (setq gnus-newsgroup-incorporated
2359 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2360 (make-local-variable 'gnus-summary-line-format)
2361 (make-local-variable 'gnus-summary-line-format-spec)
2362 (make-local-variable 'gnus-summary-dummy-line-format)
2363 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2364 (make-local-variable 'gnus-summary-mark-positions)
2365 (make-local-hook 'pre-command-hook)
2366 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2367 (gnus-run-hooks 'gnus-summary-mode-hook)
2368 (turn-on-gnus-mailing-list-mode)
2369 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2370 (gnus-update-summary-mark-positions))
2372 (defun gnus-summary-make-local-variables ()
2373 "Make all the local summary buffer variables."
2375 (dolist (local gnus-summary-local-variables)
2378 (if (eq (cdr local) 'global)
2379 ;; Copy the global value of the variable.
2380 (setq global (symbol-value (car local)))
2381 ;; Use the value from the list.
2382 (setq global (eval (cdr local))))
2383 (set (make-local-variable (car local)) global))
2384 ;; Simple nil-valued local variable.
2385 (set (make-local-variable local) nil)))))
2387 (defun gnus-summary-clear-local-variables ()
2388 (let ((locals gnus-summary-local-variables))
2390 (if (consp (car locals))
2391 (and (vectorp (caar locals))
2392 (set (caar locals) nil))
2393 (and (vectorp (car locals))
2394 (set (car locals) nil)))
2395 (setq locals (cdr locals)))))
2397 ;; Summary data functions.
2399 (defmacro gnus-data-number (data)
2402 (defmacro gnus-data-set-number (data number)
2403 `(setcar ,data ,number))
2405 (defmacro gnus-data-mark (data)
2408 (defmacro gnus-data-set-mark (data mark)
2409 `(setcar (nthcdr 1 ,data) ,mark))
2411 (defmacro gnus-data-pos (data)
2414 (defmacro gnus-data-set-pos (data pos)
2415 `(setcar (nthcdr 2 ,data) ,pos))
2417 (defmacro gnus-data-header (data)
2420 (defmacro gnus-data-set-header (data header)
2421 `(setcar (nthcdr 3 ,data) ,header))
2423 (defmacro gnus-data-level (data)
2426 (defmacro gnus-data-unread-p (data)
2427 `(= (nth 1 ,data) gnus-unread-mark))
2429 (defmacro gnus-data-read-p (data)
2430 `(/= (nth 1 ,data) gnus-unread-mark))
2432 (defmacro gnus-data-pseudo-p (data)
2433 `(consp (nth 3 ,data)))
2435 (defmacro gnus-data-find (number)
2436 `(assq ,number gnus-newsgroup-data))
2438 (defmacro gnus-data-find-list (number &optional data)
2439 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2440 (memq (assq ,number bdata)
2443 (defmacro gnus-data-make (number mark pos header level)
2444 `(list ,number ,mark ,pos ,header ,level))
2446 (defun gnus-data-enter (after-article number mark pos header level offset)
2447 (let ((data (gnus-data-find-list after-article)))
2449 (error "No such article: %d" after-article))
2450 (setcdr data (cons (gnus-data-make number mark pos header level)
2452 (setq gnus-newsgroup-data-reverse nil)
2453 (gnus-data-update-list (cddr data) offset)))
2455 (defun gnus-data-enter-list (after-article list &optional offset)
2457 (let ((data (and after-article (gnus-data-find-list after-article)))
2461 (let ((odata gnus-newsgroup-data))
2462 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2464 (gnus-data-update-list odata offset)))
2465 ;; Find the last element in the list to be spliced into the main
2468 (setq list (cdr list)))
2471 (setcdr list gnus-newsgroup-data)
2472 (setq gnus-newsgroup-data ilist)
2474 (gnus-data-update-list (cdr list) offset)))
2475 (setcdr list (cdr data))
2478 (gnus-data-update-list (cdr list) offset))))
2479 (setq gnus-newsgroup-data-reverse nil))))
2481 (defun gnus-data-remove (article &optional offset)
2482 (let ((data gnus-newsgroup-data))
2483 (if (= (gnus-data-number (car data)) article)
2485 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2486 gnus-newsgroup-data-reverse nil)
2488 (gnus-data-update-list gnus-newsgroup-data offset)))
2490 (when (= (gnus-data-number (cadr data)) article)
2491 (setcdr data (cddr data))
2493 (gnus-data-update-list (cdr data) offset))
2495 gnus-newsgroup-data-reverse nil))
2496 (setq data (cdr data))))))
2498 (defmacro gnus-data-list (backward)
2500 (or gnus-newsgroup-data-reverse
2501 (setq gnus-newsgroup-data-reverse
2502 (reverse gnus-newsgroup-data)))
2503 gnus-newsgroup-data))
2505 (defun gnus-data-update-list (data offset)
2506 "Add OFFSET to the POS of all data entries in DATA."
2507 (setq gnus-newsgroup-data-reverse nil)
2509 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2510 (setq data (cdr data))))
2512 (defun gnus-summary-article-pseudo-p (article)
2513 "Say whether this article is a pseudo article or not."
2514 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2516 (defmacro gnus-summary-article-sparse-p (article)
2517 "Say whether this article is a sparse article or not."
2518 `(memq ,article gnus-newsgroup-sparse))
2520 (defmacro gnus-summary-article-ancient-p (article)
2521 "Say whether this article is a sparse article or not."
2522 `(memq ,article gnus-newsgroup-ancient))
2524 (defun gnus-article-parent-p (number)
2525 "Say whether this article is a parent or not."
2526 (let ((data (gnus-data-find-list number)))
2527 (and (cdr data) ; There has to be an article after...
2528 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2529 (gnus-data-level (nth 1 data))))))
2531 (defun gnus-article-children (number)
2532 "Return a list of all children to NUMBER."
2533 (let* ((data (gnus-data-find-list number))
2534 (level (gnus-data-level (car data)))
2536 (setq data (cdr data))
2538 (= (gnus-data-level (car data)) (1+ level)))
2539 (push (gnus-data-number (car data)) children)
2540 (setq data (cdr data)))
2543 (defmacro gnus-summary-skip-intangible ()
2544 "If the current article is intangible, then jump to a different article."
2545 '(let ((to (get-text-property (point) 'gnus-intangible)))
2546 (and to (gnus-summary-goto-subject to))))
2548 (defmacro gnus-summary-article-intangible-p ()
2549 "Say whether this article is intangible or not."
2550 '(get-text-property (point) 'gnus-intangible))
2552 (defun gnus-article-read-p (article)
2553 "Say whether ARTICLE is read or not."
2554 (not (or (memq article gnus-newsgroup-marked)
2555 (memq article gnus-newsgroup-unreads)
2556 (memq article gnus-newsgroup-unselected)
2557 (memq article gnus-newsgroup-dormant))))
2559 ;; Some summary mode macros.
2561 (defmacro gnus-summary-article-number ()
2562 "The article number of the article on the current line.
2563 If there isn's an article number here, then we return the current
2566 (gnus-summary-skip-intangible)
2567 (or (get-text-property (point) 'gnus-number)
2568 (gnus-summary-last-subject))))
2570 (defmacro gnus-summary-article-header (&optional number)
2571 "Return the header of article NUMBER."
2572 `(gnus-data-header (gnus-data-find
2573 ,(or number '(gnus-summary-article-number)))))
2575 (defmacro gnus-summary-thread-level (&optional number)
2576 "Return the level of thread that starts with article NUMBER."
2577 `(if (and (eq gnus-summary-make-false-root 'dummy)
2578 (get-text-property (point) 'gnus-intangible))
2580 (gnus-data-level (gnus-data-find
2581 ,(or number '(gnus-summary-article-number))))))
2583 (defmacro gnus-summary-article-mark (&optional number)
2584 "Return the mark of article NUMBER."
2585 `(gnus-data-mark (gnus-data-find
2586 ,(or number '(gnus-summary-article-number)))))
2588 (defmacro gnus-summary-article-pos (&optional number)
2589 "Return the position of the line of article NUMBER."
2590 `(gnus-data-pos (gnus-data-find
2591 ,(or number '(gnus-summary-article-number)))))
2593 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2594 (defmacro gnus-summary-article-subject (&optional number)
2595 "Return current subject string or nil if nothing."
2598 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2599 '(gnus-data-header (assq (gnus-summary-article-number)
2600 gnus-newsgroup-data)))))
2603 (mail-header-subject headers))))
2605 (defmacro gnus-summary-article-score (&optional number)
2606 "Return current article score."
2607 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2608 gnus-newsgroup-scored))
2609 gnus-summary-default-score 0))
2611 (defun gnus-summary-article-children (&optional number)
2612 "Return a list of article numbers that are children of article NUMBER."
2613 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2614 (level (gnus-data-level (car data)))
2616 (while (and (setq data (cdr data))
2617 (> (setq l (gnus-data-level (car data))) level))
2618 (and (= (1+ level) l)
2619 (push (gnus-data-number (car data))
2621 (nreverse children)))
2623 (defun gnus-summary-article-parent (&optional number)
2624 "Return the article number of the parent of article NUMBER."
2625 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2626 (gnus-data-list t)))
2627 (level (gnus-data-level (car data))))
2629 () ; This is a root.
2630 ;; We search until we find an article with a level less than
2631 ;; this one. That function has to be the parent.
2632 (while (and (setq data (cdr data))
2633 (not (< (gnus-data-level (car data)) level))))
2634 (and data (gnus-data-number (car data))))))
2636 (defun gnus-unread-mark-p (mark)
2637 "Say whether MARK is the unread mark."
2638 (= mark gnus-unread-mark))
2640 (defun gnus-read-mark-p (mark)
2641 "Say whether MARK is one of the marks that mark as read.
2642 This is all marks except unread, ticked, dormant, and expirable."
2643 (not (or (= mark gnus-unread-mark)
2644 (= mark gnus-ticked-mark)
2645 (= mark gnus-dormant-mark)
2646 (= mark gnus-expirable-mark))))
2648 (defmacro gnus-article-mark (number)
2649 "Return the MARK of article NUMBER.
2650 This macro should only be used when computing the mark the \"first\"
2651 time; i.e., when generating the summary lines. After that,
2652 `gnus-summary-article-mark' should be used to examine the
2655 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2656 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2657 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2658 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2659 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2660 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2661 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2662 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2663 gnus-ancient-mark))))
2665 ;; Saving hidden threads.
2667 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2668 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2670 (defmacro gnus-save-hidden-threads (&rest forms)
2671 "Save hidden threads, eval FORMS, and restore the hidden threads."
2672 (let ((config (make-symbol "config")))
2673 `(let ((,config (gnus-hidden-threads-configuration)))
2677 (gnus-restore-hidden-threads-configuration ,config)))))
2679 (defun gnus-data-compute-positions ()
2680 "Compute the positions of all articles."
2681 (setq gnus-newsgroup-data-reverse nil)
2682 (let ((data gnus-newsgroup-data))
2684 (gnus-save-hidden-threads
2685 (gnus-summary-show-all-threads)
2686 (goto-char (point-min))
2688 (while (get-text-property (point) 'gnus-intangible)
2690 (gnus-data-set-pos (car data) (+ (point) 3))
2691 (setq data (cdr data))
2692 (forward-line 1))))))
2694 (defun gnus-hidden-threads-configuration ()
2695 "Return the current hidden threads configuration."
2698 (goto-char (point-min))
2699 (while (search-forward "\r" nil t)
2700 (push (1- (point)) config))
2703 (defun gnus-restore-hidden-threads-configuration (config)
2704 "Restore hidden threads configuration from CONFIG."
2706 (let (point buffer-read-only)
2707 (while (setq point (pop config))
2708 (when (and (< point (point-max))
2710 (eq (char-after) ?\n))
2711 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2713 ;; Various summary mode internalish functions.
2715 (defun gnus-mouse-pick-article (e)
2718 (gnus-summary-next-page nil t))
2720 (defun gnus-summary-set-display-table ()
2721 "Change the display table.
2722 Odd characters have a tendency to mess
2723 up nicely formatted displays - we make all possible glyphs
2724 display only a single character."
2726 ;; We start from the standard display table, if any.
2727 (let ((table (or (copy-sequence standard-display-table)
2728 (make-display-table)))
2730 ;; Nix out all the control chars...
2731 (while (>= (setq i (1- i)) 0)
2732 (aset table i [??]))
2733 ;; ... but not newline and cr, of course. (cr is necessary for the
2734 ;; selective display).
2735 (aset table ?\n nil)
2736 (aset table ?\r nil)
2737 ;; We keep TAB as well.
2738 (aset table ?\t nil)
2739 ;; We nix out any glyphs over 126 that are not set already.
2741 (while (>= (setq i (1- i)) 127)
2742 ;; Only modify if the entry is nil.
2743 (unless (aref table i)
2744 (aset table i [??]))))
2745 (setq buffer-display-table table)))
2747 (defun gnus-summary-set-article-display-arrow (pos)
2748 "Update the overlay arrow to point to line at position POS."
2749 (when (and gnus-summary-display-arrow
2750 (boundp 'overlay-arrow-position)
2751 (boundp 'overlay-arrow-string))
2755 (unless overlay-arrow-position
2756 (setq overlay-arrow-position (make-marker)))
2757 (setq overlay-arrow-string "=>"
2758 overlay-arrow-position (set-marker overlay-arrow-position
2760 (current-buffer))))))
2762 (defun gnus-summary-buffer-name (group)
2763 "Return the summary buffer name of GROUP."
2764 (concat "*Summary " group "*"))
2766 (defun gnus-summary-setup-buffer (group)
2767 "Initialize summary buffer."
2768 (let ((buffer (gnus-summary-buffer-name group)))
2769 (if (get-buffer buffer)
2772 (setq gnus-summary-buffer (current-buffer))
2773 (not gnus-newsgroup-prepared))
2774 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2775 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2776 (gnus-summary-mode group)
2778 (gnus-carpal-setup-buffer 'summary))
2779 (unless gnus-single-article-buffer
2780 (make-local-variable 'gnus-article-buffer)
2781 (make-local-variable 'gnus-article-current)
2782 (make-local-variable 'gnus-original-article-buffer))
2783 (setq gnus-newsgroup-name group)
2784 ;; Set any local variables in the group parameters.
2785 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2788 (defun gnus-set-global-variables ()
2789 "Set the global equivalents of the buffer-local variables.
2790 They are set to the latest values they had. These reflect the summary
2791 buffer that was in action when the last article was fetched."
2792 (when (eq major-mode 'gnus-summary-mode)
2793 (setq gnus-summary-buffer (current-buffer))
2794 (let ((name gnus-newsgroup-name)
2795 (marked gnus-newsgroup-marked)
2796 (unread gnus-newsgroup-unreads)
2797 (headers gnus-current-headers)
2798 (data gnus-newsgroup-data)
2799 (summary gnus-summary-buffer)
2800 (article-buffer gnus-article-buffer)
2801 (original gnus-original-article-buffer)
2802 (gac gnus-article-current)
2803 (reffed gnus-reffed-article-number)
2804 (score-file gnus-current-score-file)
2805 (default-charset gnus-newsgroup-charset)
2807 (let ((locals gnus-newsgroup-variables))
2809 (if (consp (car locals))
2810 (push (eval (caar locals)) vlist)
2811 (push (eval (car locals)) vlist))
2812 (setq locals (cdr locals)))
2813 (setq vlist (nreverse vlist)))
2815 (set-buffer gnus-group-buffer)
2816 (setq gnus-newsgroup-name name
2817 gnus-newsgroup-marked marked
2818 gnus-newsgroup-unreads unread
2819 gnus-current-headers headers
2820 gnus-newsgroup-data data
2821 gnus-article-current gac
2822 gnus-summary-buffer summary
2823 gnus-article-buffer article-buffer
2824 gnus-original-article-buffer original
2825 gnus-reffed-article-number reffed
2826 gnus-current-score-file score-file
2827 gnus-newsgroup-charset default-charset)
2828 (let ((locals gnus-newsgroup-variables))
2830 (if (consp (car locals))
2831 (set (caar locals) (pop vlist))
2832 (set (car locals) (pop vlist)))
2833 (setq locals (cdr locals))))
2834 ;; The article buffer also has local variables.
2835 (when (gnus-buffer-live-p gnus-article-buffer)
2836 (set-buffer gnus-article-buffer)
2837 (setq gnus-summary-buffer summary))))))
2839 (defun gnus-summary-article-unread-p (article)
2840 "Say whether ARTICLE is unread or not."
2841 (memq article gnus-newsgroup-unreads))
2843 (defun gnus-summary-first-article-p (&optional article)
2844 "Return whether ARTICLE is the first article in the buffer."
2845 (if (not (setq article (or article (gnus-summary-article-number))))
2847 (eq article (caar gnus-newsgroup-data))))
2849 (defun gnus-summary-last-article-p (&optional article)
2850 "Return whether ARTICLE is the last article in the buffer."
2851 (if (not (setq article (or article (gnus-summary-article-number))))
2852 ;; All non-existent numbers are the last article. :-)
2854 (not (cdr (gnus-data-find-list article)))))
2856 (defun gnus-make-thread-indent-array ()
2858 (unless (and gnus-thread-indent-array
2859 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2860 (setq gnus-thread-indent-array (make-vector 201 "")
2861 gnus-thread-indent-array-level gnus-thread-indent-level)
2863 (aset gnus-thread-indent-array n
2864 (make-string (* n gnus-thread-indent-level) ? ))
2867 (defun gnus-update-summary-mark-positions ()
2868 "Compute where the summary marks are to go."
2870 (when (gnus-buffer-exists-p gnus-summary-buffer)
2871 (set-buffer gnus-summary-buffer))
2872 (let ((gnus-replied-mark 129)
2873 (gnus-score-below-mark 130)
2874 (gnus-score-over-mark 130)
2875 (gnus-download-mark 131)
2876 (spec gnus-summary-line-format-spec)
2879 (gnus-set-work-buffer)
2880 (let ((gnus-summary-line-format-spec spec)
2881 (gnus-newsgroup-downloadable '((0 . t))))
2882 (gnus-summary-insert-line
2883 (make-full-mail-header 0 "" "nobody"
2884 "05 Apr 2001 23:33:09 +0400"
2886 0 nil 128 t nil "" nil 1)
2887 (goto-char (point-min))
2888 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2890 (goto-char (point-min))
2891 (push (cons 'replied (and (search-forward "\201" nil t)
2894 (goto-char (point-min))
2895 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2897 (goto-char (point-min))
2898 (push (cons 'download
2899 (and (search-forward "\203" nil t) (- (point) 2)))
2901 (setq gnus-summary-mark-positions pos))))
2903 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2904 "Insert a dummy root in the summary buffer."
2906 (gnus-add-text-properties
2907 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2908 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2910 (defun gnus-summary-from-or-to-or-newsgroups (header)
2911 (let ((to (cdr (assq 'To (mail-header-extra header))))
2912 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2913 (default-mime-charset (with-current-buffer gnus-summary-buffer
2914 default-mime-charset)))
2917 gnus-ignored-from-addresses
2918 (string-match gnus-ignored-from-addresses
2919 (mail-header-from header)))
2921 (or (car (funcall gnus-extract-address-components
2923 gnus-decode-encoded-word-function to)))
2924 (funcall gnus-decode-encoded-word-function to))))
2926 gnus-ignored-from-addresses
2927 (string-match gnus-ignored-from-addresses
2928 (mail-header-from header)))
2929 (concat "=> " newsgroups))
2931 (or (car (funcall gnus-extract-address-components
2932 (mail-header-from header)))
2933 (mail-header-from header))))))
2935 (defun gnus-summary-insert-line (gnus-tmp-header
2936 gnus-tmp-level gnus-tmp-current
2937 gnus-tmp-unread gnus-tmp-replied
2938 gnus-tmp-expirable gnus-tmp-subject-or-nil
2939 &optional gnus-tmp-dummy gnus-tmp-score
2941 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2942 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2943 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2944 (gnus-tmp-score-char
2945 (if (or (null gnus-summary-default-score)
2946 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2947 gnus-summary-zcore-fuzz))
2949 (if (< gnus-tmp-score gnus-summary-default-score)
2950 gnus-score-below-mark gnus-score-over-mark)))
2952 (cond (gnus-tmp-process gnus-process-mark)
2953 ((memq gnus-tmp-current gnus-newsgroup-cached)
2955 (gnus-tmp-replied gnus-replied-mark)
2956 ((memq gnus-tmp-current gnus-newsgroup-saved)
2959 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2962 ((string-match "<[^>]+> *$" gnus-tmp-from)
2963 (let ((beg (match-beginning 0)))
2964 (or (and (string-match "^\".+\"" gnus-tmp-from)
2965 (substring gnus-tmp-from 1 (1- (match-end 0))))
2966 (substring gnus-tmp-from 0 beg))))
2967 ((string-match "(.+)" gnus-tmp-from)
2968 (substring gnus-tmp-from
2969 (1+ (match-beginning 0)) (1- (match-end 0))))
2971 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2972 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2973 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2974 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2975 (buffer-read-only nil))
2976 (when (string= gnus-tmp-name "")
2977 (setq gnus-tmp-name gnus-tmp-from))
2978 (unless (numberp gnus-tmp-lines)
2979 (setq gnus-tmp-lines -1))
2980 (when (= gnus-tmp-lines -1)
2981 (setq gnus-tmp-lines "?"))
2982 (gnus-put-text-property-excluding-characters-with-faces
2984 (progn (eval gnus-summary-line-format-spec) (point))
2985 'gnus-number gnus-tmp-number)
2986 (when (gnus-visual-p 'summary-highlight 'highlight)
2988 (gnus-run-hooks 'gnus-summary-update-hook)
2991 (defun gnus-summary-update-line (&optional dont-update)
2992 "Update summary line after change."
2993 (when (and gnus-summary-default-score
2994 (not gnus-summary-inhibit-highlight))
2995 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2996 (article (gnus-summary-article-number))
2997 (score (gnus-summary-article-score article)))
2999 (if (and gnus-summary-mark-below
3000 (< (gnus-summary-article-score)
3001 gnus-summary-mark-below))
3002 ;; This article has a low score, so we mark it as read.
3003 (when (memq article gnus-newsgroup-unreads)
3004 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3005 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3006 ;; This article was previously marked as read on account
3007 ;; of a low score, but now it has risen, so we mark it as
3009 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3010 (gnus-summary-update-mark
3011 (if (or (null gnus-summary-default-score)
3012 (<= (abs (- score gnus-summary-default-score))
3013 gnus-summary-zcore-fuzz))
3015 (if (< score gnus-summary-default-score)
3016 gnus-score-below-mark gnus-score-over-mark))
3018 ;; Do visual highlighting.
3019 (when (gnus-visual-p 'summary-highlight 'highlight)
3020 (gnus-run-hooks 'gnus-summary-update-hook)))))
3022 (defvar gnus-tmp-new-adopts nil)
3024 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3025 "Return the number of articles in THREAD.
3026 This may be 0 in some cases -- if none of the articles in
3027 the thread are to be displayed."
3029 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3031 ((not (listp thread))
3033 ((and (consp thread) (cdr thread))
3036 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3039 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3042 (when (and level (zerop level) gnus-tmp-new-adopts)
3045 'gnus-summary-number-of-articles-in-thread
3046 gnus-tmp-new-adopts))))
3048 (if (> number 1) gnus-not-empty-thread-mark
3049 gnus-empty-thread-mark)
3052 (defun gnus-summary-set-local-parameters (group)
3053 "Go through the local params of GROUP and set all variable specs in that list."
3054 (let ((params (gnus-group-find-parameter group))
3055 (vars '(quit-config)) ; Ignore quit-config.
3058 (setq elem (car params)
3059 params (cdr params))
3060 (and (consp elem) ; Has to be a cons.
3061 (consp (cdr elem)) ; The cdr has to be a list.
3062 (symbolp (car elem)) ; Has to be a symbol in there.
3063 (not (memq (car elem) vars))
3064 (ignore-errors ; So we set it.
3065 (push (car elem) vars)
3066 (make-local-variable (car elem))
3067 (set (car elem) (eval (nth 1 elem))))))))
3069 (defun gnus-summary-read-group (group &optional show-all no-article
3070 kill-buffer no-display backward
3072 "Start reading news in newsgroup GROUP.
3073 If SHOW-ALL is non-nil, already read articles are also listed.
3074 If NO-ARTICLE is non-nil, no article is selected initially.
3075 If NO-DISPLAY, don't generate a summary buffer."
3079 (let ((gnus-auto-select-next nil))
3080 (or (gnus-summary-read-group-1
3081 group show-all no-article
3082 kill-buffer no-display
3085 select-articles nil)))))
3086 (eq gnus-auto-select-next 'quietly))
3087 (set-buffer gnus-group-buffer)
3088 ;; The entry function called above goes to the next
3089 ;; group automatically, so we go two groups back
3090 ;; if we are searching for the previous group.
3092 (gnus-group-prev-unread-group 2))
3093 (if (not (equal group (gnus-group-group-name)))
3094 (setq group (gnus-group-group-name))
3098 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3099 "Directly jump to the other GROUP from summary buffer.
3100 If SHOW-ALL is non-nil, already read articles are also listed."
3102 (if (eq gnus-summary-buffer (current-buffer))
3103 (list (completing-read
3104 "Group: " gnus-active-hashtb nil t
3105 (when (and gnus-newsgroup-name
3106 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3107 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3108 'gnus-group-history)
3110 (error "%s must be invoked from a gnus summary buffer." this-command)))
3111 (unless (or (zerop (length group))
3112 (and gnus-newsgroup-name
3113 (string-equal gnus-newsgroup-name group)))
3115 (gnus-summary-read-group group show-all
3116 gnus-dont-select-after-jump-to-other-group)))
3118 (defun gnus-summary-read-group-1 (group show-all no-article
3119 kill-buffer no-display
3120 &optional select-articles)
3121 ;; Killed foreign groups can't be entered.
3122 ;; (when (and (not (gnus-group-native-p group))
3123 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3124 ;; (error "Dead non-native groups can't be entered"))
3125 (gnus-message 5 "Retrieving newsgroup: %s..."
3126 (gnus-group-decoded-name group))
3127 (let* ((new-group (gnus-summary-setup-buffer group))
3128 (quit-config (gnus-group-quit-config group))
3129 (did-select (and new-group (gnus-select-newsgroup
3130 group show-all select-articles))))
3132 ;; This summary buffer exists already, so we just select it.
3134 (gnus-set-global-variables)
3136 (gnus-kill-or-deaden-summary kill-buffer))
3137 (gnus-configure-windows 'summary 'force)
3138 (gnus-set-mode-line 'summary)
3139 (gnus-summary-position-point)
3142 ;; We couldn't select this group.
3144 (when (and (eq major-mode 'gnus-summary-mode)
3145 (not (equal (current-buffer) kill-buffer)))
3146 (kill-buffer (current-buffer))
3147 (if (not quit-config)
3149 ;; Update the info -- marks might need to be removed,
3151 (gnus-summary-update-info)
3152 (set-buffer gnus-group-buffer)
3153 (gnus-group-jump-to-group group)
3154 (gnus-group-next-unread-group 1))
3155 (gnus-handle-ephemeral-exit quit-config)))
3156 (let ((grpinfo (gnus-get-info group)))
3157 (if (null (gnus-info-read grpinfo))
3158 (gnus-message 3 "Group %s contains no messages"
3159 (gnus-group-decoded-name group))
3160 (gnus-message 3 "Can't select group")))
3162 ;; The user did a `C-g' while prompting for number of articles,
3163 ;; so we exit this group.
3164 ((eq did-select 'quit)
3165 (and (eq major-mode 'gnus-summary-mode)
3166 (not (equal (current-buffer) kill-buffer))
3167 (kill-buffer (current-buffer)))
3169 (gnus-kill-or-deaden-summary kill-buffer))
3170 (if (not quit-config)
3172 (set-buffer gnus-group-buffer)
3173 (gnus-group-jump-to-group group)
3174 (gnus-group-next-unread-group 1)
3175 (gnus-configure-windows 'group 'force))
3176 (gnus-handle-ephemeral-exit quit-config))
3177 ;; Finally signal the quit.
3179 ;; The group was successfully selected.
3181 (gnus-set-global-variables)
3182 ;; Save the active value in effect when the group was entered.
3183 (setq gnus-newsgroup-active
3185 (gnus-active gnus-newsgroup-name)))
3186 ;; You can change the summary buffer in some way with this hook.
3187 (gnus-run-hooks 'gnus-select-group-hook)
3188 (gnus-update-format-specifications
3189 nil 'summary 'summary-mode 'summary-dummy)
3190 (gnus-update-summary-mark-positions)
3191 ;; Do score processing.
3192 (when gnus-use-scoring
3193 (gnus-possibly-score-headers))
3194 ;; Check whether to fill in the gaps in the threads.
3195 (when gnus-build-sparse-threads
3196 (gnus-build-sparse-threads))
3197 ;; Find the initial limit.
3198 (if gnus-show-threads
3200 (let ((gnus-newsgroup-dormant nil))
3201 (gnus-summary-initial-limit show-all))
3202 (gnus-summary-initial-limit show-all))
3203 ;; When untreaded, all articles are always shown.
3204 (setq gnus-newsgroup-limit
3206 (lambda (header) (mail-header-number header))
3207 gnus-newsgroup-headers)))
3208 ;; Generate the summary buffer.
3210 (gnus-summary-prepare))
3211 (when gnus-use-trees
3212 (gnus-tree-open group)
3213 (setq gnus-summary-highlight-line-function
3214 'gnus-tree-highlight-article))
3215 ;; If the summary buffer is empty, but there are some low-scored
3216 ;; articles or some excluded dormants, we include these in the
3218 (when (and (zerop (buffer-size))
3220 (cond (gnus-newsgroup-dormant
3221 (gnus-summary-limit-include-dormant))
3222 ((and gnus-newsgroup-scored show-all)
3223 (gnus-summary-limit-include-expunged t))))
3224 ;; Function `gnus-apply-kill-file' must be called in this hook.
3225 (gnus-run-hooks 'gnus-apply-kill-hook)
3226 (if (and (zerop (buffer-size))
3229 ;; This newsgroup is empty.
3230 (gnus-summary-catchup-and-exit nil t)
3231 (gnus-message 6 "No unread news")
3233 (gnus-kill-or-deaden-summary kill-buffer))
3234 ;; Return nil from this function.
3236 ;; Hide conversation thread subtrees. We cannot do this in
3237 ;; gnus-summary-prepare-hook since kill processing may not
3238 ;; work with hidden articles.
3239 (and gnus-show-threads
3240 gnus-thread-hide-subtree
3241 (gnus-summary-hide-all-threads))
3243 (gnus-kill-or-deaden-summary kill-buffer))
3244 ;; Show first unread article if requested.
3245 (if (and (not no-article)
3247 gnus-newsgroup-unreads
3248 gnus-auto-select-first)
3250 (gnus-configure-windows 'summary)
3252 ((eq gnus-auto-select-first 'best)
3253 (gnus-summary-best-unread-article))
3254 ((eq gnus-auto-select-first t)
3255 (gnus-summary-first-unread-article))
3256 ((gnus-functionp gnus-auto-select-first)
3257 (funcall gnus-auto-select-first))))
3258 ;; Don't select any articles, just move point to the first
3259 ;; article in the group.
3260 (goto-char (point-min))
3261 (gnus-summary-position-point)
3262 (gnus-configure-windows 'summary 'force)
3263 (gnus-set-mode-line 'summary))
3264 (when (get-buffer-window gnus-group-buffer t)
3265 ;; Gotta use windows, because recenter does weird stuff if
3266 ;; the current buffer ain't the displayed window.
3267 (let ((owin (selected-window)))
3268 (select-window (get-buffer-window gnus-group-buffer t))
3269 (when (gnus-group-goto-group group)
3271 (select-window owin)))
3272 ;; Mark this buffer as "prepared".
3273 (setq gnus-newsgroup-prepared t)
3274 (gnus-run-hooks 'gnus-summary-prepared-hook)
3277 (defun gnus-summary-prepare ()
3278 "Generate the summary buffer."
3280 (let ((buffer-read-only nil))
3282 (setq gnus-newsgroup-data nil
3283 gnus-newsgroup-data-reverse nil)
3284 (gnus-run-hooks 'gnus-summary-generate-hook)
3285 ;; Generate the buffer, either with threads or without.
3286 (when gnus-newsgroup-headers
3287 (gnus-summary-prepare-threads
3288 (if gnus-show-threads
3289 (gnus-sort-gathered-threads
3290 (funcall gnus-summary-thread-gathering-function
3292 (gnus-cut-threads (gnus-make-threads)))))
3293 ;; Unthreaded display.
3294 (gnus-sort-articles gnus-newsgroup-headers))))
3295 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3296 ;; Call hooks for modifying summary buffer.
3297 (goto-char (point-min))
3298 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3300 (defsubst gnus-general-simplify-subject (subject)
3301 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3304 ;; Truncate the subject.
3305 (gnus-simplify-subject-functions
3306 (gnus-map-function gnus-simplify-subject-functions subject))
3307 ((numberp gnus-summary-gather-subject-limit)
3308 (setq subject (gnus-simplify-subject-re subject))
3309 (if (> (length subject) gnus-summary-gather-subject-limit)
3310 (substring subject 0 gnus-summary-gather-subject-limit)
3312 ;; Fuzzily simplify it.
3313 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3314 (gnus-simplify-subject-fuzzy subject))
3315 ;; Just remove the leading "Re:".
3317 (gnus-simplify-subject-re subject))))
3319 (if (and gnus-summary-gather-exclude-subject
3320 (string-match gnus-summary-gather-exclude-subject subject))
3321 nil ; This article shouldn't be gathered
3324 (defun gnus-summary-simplify-subject-query ()
3325 "Query where the respool algorithm would put this article."
3327 (gnus-summary-select-article)
3329 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3331 (defun gnus-gather-threads-by-subject (threads)
3332 "Gather threads by looking at Subject headers."
3333 (if (not gnus-summary-make-false-root)
3335 (let ((hashtb (gnus-make-hashtable 1024))
3338 subject hthread whole-subject)
3340 (setq subject (gnus-general-simplify-subject
3341 (setq whole-subject (mail-header-subject
3344 (if (setq hthread (gnus-gethash subject hashtb))
3346 ;; We enter a dummy root into the thread, if we
3347 ;; haven't done that already.
3348 (unless (stringp (caar hthread))
3349 (setcar hthread (list whole-subject (car hthread))))
3350 ;; We add this new gathered thread to this gathered
3352 (setcdr (car hthread)
3353 (nconc (cdar hthread) (list (car threads))))
3354 ;; Remove it from the list of threads.
3355 (setcdr prev (cdr threads))
3356 (setq threads prev))
3357 ;; Enter this thread into the hash table.
3358 (gnus-sethash subject threads hashtb)))
3360 (setq threads (cdr threads)))
3363 (defun gnus-gather-threads-by-references (threads)
3364 "Gather threads by looking at References headers."
3365 (let ((idhashtb (gnus-make-hashtable 1024))
3366 (thhashtb (gnus-make-hashtable 1024))
3369 ids references id gthread gid entered ref)
3371 (when (setq references (mail-header-references (caar threads)))
3372 (setq id (mail-header-id (caar threads))
3373 ids (gnus-split-references references)
3375 (while (setq ref (pop ids))
3376 (setq ids (delete ref ids))
3377 (if (not (setq gid (gnus-gethash ref idhashtb)))
3379 (gnus-sethash ref id idhashtb)
3380 (gnus-sethash id threads thhashtb))
3381 (setq gthread (gnus-gethash gid thhashtb))
3383 ;; We enter a dummy root into the thread, if we
3384 ;; haven't done that already.
3385 (unless (stringp (caar gthread))
3386 (setcar gthread (list (mail-header-subject (caar gthread))
3388 ;; We add this new gathered thread to this gathered
3390 (setcdr (car gthread)
3391 (nconc (cdar gthread) (list (car threads)))))
3392 ;; Add it into the thread hash table.
3393 (gnus-sethash id gthread thhashtb)
3395 ;; Remove it from the list of threads.
3396 (setcdr prev (cdr threads))
3397 (setq threads prev))))
3399 (setq threads (cdr threads)))
3402 (defun gnus-sort-gathered-threads (threads)
3403 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3404 (let ((result threads))
3406 (when (stringp (caar threads))
3407 (setcdr (car threads)
3408 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3409 (setq threads (cdr threads)))
3412 (defun gnus-thread-loop-p (root thread)
3413 "Say whether ROOT is in THREAD."
3414 (let ((stack (list thread))
3417 (while (setq thread (pop stack))
3418 (setq th (cdr thread))
3420 (not (eq (caar th) root)))
3423 ;; We have found a loop.
3425 (setcdr thread (delq (car th) (cdr thread)))
3426 (if (boundp (setq ref-dep (intern "none"
3427 gnus-newsgroup-dependencies)))
3428 (setcdr (symbol-value ref-dep)
3429 (nconc (cdr (symbol-value ref-dep))
3431 (set ref-dep (list nil (car th))))
3434 ;; Push all the subthreads onto the stack.
3435 (push (cdr thread) stack)))
3438 (defun gnus-make-threads ()
3439 "Go through the dependency hashtb and find the roots. Return all threads."
3441 (while (catch 'infloop
3444 ;; Deal with self-referencing References loops.
3445 (when (and (car (symbol-value refs))
3452 (car (symbol-value refs)) thread))
3453 (cdr (symbol-value refs)))))))
3456 (unless (car (symbol-value refs))
3457 ;; These threads do not refer back to any other articles,
3458 ;; so they're roots.
3459 (setq threads (append (cdr (symbol-value refs)) threads))))
3460 gnus-newsgroup-dependencies)))
3463 ;; Build the thread tree.
3464 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3465 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3467 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3468 if it was already present.
3470 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3471 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3472 Message-IDs will be renamed be renamed to a unique Message-ID before
3475 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3476 (let* ((id (mail-header-id header))
3477 (id-dep (and id (intern id dependencies)))
3478 ref ref-dep ref-header)
3479 ;; Enter this `header' in the `dependencies' table.
3483 ;; The first two cases do the normal part: enter a new `header'
3484 ;; in the `dependencies' table.
3485 ((not (boundp id-dep))
3486 (set id-dep (list header)))
3487 ((null (car (symbol-value id-dep)))
3488 (setcar (symbol-value id-dep) header))
3490 ;; From here the `header' was already present in the
3491 ;; `dependencies' table.
3493 ;; Overrides an existing entry;
3494 ;; just set the header part of the entry.
3495 (setcar (symbol-value id-dep) header))
3497 ;; Renames the existing `header' to a unique Message-ID.
3498 ((not gnus-summary-ignore-duplicates)
3499 ;; An article with this Message-ID has already been seen.
3500 ;; We rename the Message-ID.
3501 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3503 (mail-header-set-id header id))
3505 ;; The last case ignores an existing entry, except it adds any
3506 ;; additional Xrefs (in case the two articles came from different
3508 ;; Also sets `header' to `nil' meaning that the `dependencies'
3509 ;; table was *not* modified.
3511 (mail-header-set-xref
3512 (car (symbol-value id-dep))
3513 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3515 (or (mail-header-xref header) "")))
3519 ;; First check if that we are not creating a References loop.
3520 (setq ref (gnus-parent-id (mail-header-references header)))
3522 (setq ref-dep (intern-soft ref dependencies))
3524 (setq ref-header (car (symbol-value ref-dep))))
3525 (if (string= id ref)
3526 ;; Yuk! This is a reference loop. Make the article be a
3529 (mail-header-set-references (car (symbol-value id-dep)) "none")
3531 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3532 (setq ref (gnus-parent-id (mail-header-references header)))
3533 (setq ref-dep (intern (or ref "none") dependencies))
3534 (if (boundp ref-dep)
3535 (setcdr (symbol-value ref-dep)
3536 (nconc (cdr (symbol-value ref-dep))
3537 (list (symbol-value id-dep))))
3538 (set ref-dep (list nil (symbol-value id-dep)))))
3541 (defun gnus-build-sparse-threads ()
3542 (let ((headers gnus-newsgroup-headers)
3543 (mail-parse-charset gnus-newsgroup-charset)
3544 (gnus-summary-ignore-duplicates t)
3545 header references generation relations
3546 subject child end new-child date)
3547 ;; First we create an alist of generations/relations, where
3548 ;; generations is how much we trust the relation, and the relation
3550 (gnus-message 7 "Making sparse threads...")
3552 (nnheader-set-temp-buffer " *gnus sparse threads*")
3553 (while (setq header (pop headers))
3554 (when (and (setq references (mail-header-references header))
3555 (not (string= references "")))
3557 (setq child (mail-header-id header)
3558 subject (mail-header-subject header)
3559 date (mail-header-date header)
3561 (while (search-backward ">" nil t)
3562 (setq end (1+ (point)))
3563 (when (search-backward "<" nil t)
3564 (setq new-child (buffer-substring (point) end))
3565 (push (list (incf generation)
3566 child (setq child new-child)
3570 (push (list (1+ generation) child nil subject) relations))
3572 (kill-buffer (current-buffer)))
3573 ;; Sort over trustworthiness.
3576 (when (gnus-dependencies-add-header
3577 (make-full-mail-header-from-decoded-header
3578 gnus-reffed-article-number
3579 (nth 3 relation) "" (or (nth 4 relation) "")
3581 (or (nth 2 relation) "") 0 0 "")
3582 gnus-newsgroup-dependencies nil)
3583 (push gnus-reffed-article-number gnus-newsgroup-limit)
3584 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3585 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3586 gnus-newsgroup-reads)
3587 (decf gnus-reffed-article-number)))
3588 (sort relations 'car-less-than-car))
3589 (gnus-message 7 "Making sparse threads...done")))
3591 (defun gnus-build-old-threads ()
3592 ;; Look at all the articles that refer back to old articles, and
3593 ;; fetch the headers for the articles that aren't there. This will
3594 ;; build complete threads - if the roots haven't been expired by the
3596 (let ((mail-parse-charset gnus-newsgroup-charset)
3600 (when (not (car (symbol-value refs)))
3601 (setq heads (cdr (symbol-value refs)))
3603 (if (memq (mail-header-number (caar heads))
3604 gnus-newsgroup-dormant)
3605 (setq heads (cdr heads))
3606 (setq id (symbol-name refs))
3607 (while (and (setq id (gnus-build-get-header id))
3608 (not (car (gnus-id-to-thread id)))))
3609 (setq heads nil)))))
3610 gnus-newsgroup-dependencies)))
3612 ;; This function has to be called with point after the article number
3613 ;; on the beginning of the line.
3614 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3615 (let ((eol (gnus-point-at-eol))
3616 (buffer (current-buffer))
3619 ;; overview: [num subject from date id refs chars lines misc]
3622 (narrow-to-region (point) eol)
3627 (make-full-mail-header
3629 (nnheader-nov-field) ; subject
3630 (nnheader-nov-field) ; from
3631 (nnheader-nov-field) ; date
3632 (nnheader-nov-read-message-id) ; id
3633 (nnheader-nov-field) ; refs
3634 (nnheader-nov-read-integer) ; chars
3635 (nnheader-nov-read-integer) ; lines
3637 (if (looking-at "Xref: ")
3638 (goto-char (match-end 0)))
3639 (nnheader-nov-field)) ; Xref
3640 (nnheader-nov-parse-extra)))) ; extra
3644 (when gnus-alter-header-function
3645 (funcall gnus-alter-header-function header))
3646 (gnus-dependencies-add-header header dependencies force-new)))
3648 (defun gnus-build-get-header (id)
3649 "Look through the buffer of NOV lines and find the header to ID.
3650 Enter this line into the dependencies hash table, and return
3651 the id of the parent article (if any)."
3652 (let ((deps gnus-newsgroup-dependencies)
3656 (set-buffer nntp-server-buffer)
3657 (let ((case-fold-search nil))
3658 (goto-char (point-min))
3659 (while (and (not found)
3660 (search-forward id nil t))
3662 (setq found (looking-at
3663 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3664 (regexp-quote id))))
3665 (or found (beginning-of-line 2)))
3669 (setq header (gnus-nov-parse-line
3670 (read (current-buffer)) deps))
3671 (gnus-parent-id (mail-header-references header))))))
3673 (let ((number (mail-header-number header)))
3674 (push number gnus-newsgroup-limit)
3675 (push header gnus-newsgroup-headers)
3676 (if (memq number gnus-newsgroup-unselected)
3678 (push number gnus-newsgroup-unreads)
3679 (setq gnus-newsgroup-unselected
3680 (delq number gnus-newsgroup-unselected)))
3681 (push number gnus-newsgroup-ancient)))))))
3683 (defun gnus-build-all-threads ()
3684 "Read all the headers."
3685 (let ((gnus-summary-ignore-duplicates t)
3686 (mail-parse-charset gnus-newsgroup-charset)
3687 (dependencies gnus-newsgroup-dependencies)
3690 (set-buffer nntp-server-buffer)
3691 (let ((case-fold-search nil))
3692 (goto-char (point-min))
3695 (setq article (read (current-buffer))
3696 header (gnus-nov-parse-line article dependencies)))
3699 (set-buffer gnus-summary-buffer)
3700 (push header gnus-newsgroup-headers)
3701 (if (memq (setq article (mail-header-number header))
3702 gnus-newsgroup-unselected)
3704 (push article gnus-newsgroup-unreads)
3705 (setq gnus-newsgroup-unselected
3706 (delq article gnus-newsgroup-unselected)))
3707 (push article gnus-newsgroup-ancient)))
3708 (forward-line 1)))))))
3710 (defun gnus-summary-update-article-line (article header)
3711 "Update the line for ARTICLE using HEADERS."
3712 (let* ((id (mail-header-id header))
3713 (thread (gnus-id-to-thread id)))
3715 (error "Article in no thread"))
3716 ;; Update the thread.
3717 (setcar thread header)
3718 (gnus-summary-goto-subject article)
3719 (let* ((datal (gnus-data-find-list article))
3721 (length (when (cdr datal)
3722 (- (gnus-data-pos data)
3723 (gnus-data-pos (cadr datal)))))
3724 (buffer-read-only nil)
3725 (level (gnus-summary-thread-level)))
3727 (gnus-summary-insert-line
3728 header level nil (gnus-article-mark article)
3729 (memq article gnus-newsgroup-replied)
3730 (memq article gnus-newsgroup-expirable)
3731 ;; Only insert the Subject string when it's different
3732 ;; from the previous Subject string.
3737 (mail-header-subject
3740 (gnus-data-find-list
3742 (gnus-data-list t)))))
3743 ;; Error on the side of excessive subjects.
3745 (mail-header-subject header)))
3747 (mail-header-subject header))
3748 nil (cdr (assq article gnus-newsgroup-scored))
3749 (memq article gnus-newsgroup-processable))
3751 (gnus-data-update-list
3752 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3754 (defun gnus-summary-update-article (article &optional iheader)
3755 "Update ARTICLE in the summary buffer."
3756 (set-buffer gnus-summary-buffer)
3757 (let* ((header (gnus-summary-article-header article))
3758 (id (mail-header-id header))
3759 (data (gnus-data-find article))
3760 (thread (gnus-id-to-thread id))
3761 (references (mail-header-references header))
3765 (when (and references
3766 (not (equal "" references)))
3769 (buffer-read-only nil)
3775 (delq thread parent)))
3776 (if (gnus-summary-insert-subject id header)
3777 ;; Set the (possibly) new article number in the data structure.
3778 (gnus-data-set-number data (gnus-id-to-article id))
3782 (defun gnus-rebuild-thread (id &optional line)
3783 "Rebuild the thread containing ID.
3784 If LINE, insert the rebuilt thread starting on line LINE."
3785 (let ((buffer-read-only nil)
3786 old-pos current thread data)
3787 (if (not gnus-show-threads)
3788 (setq thread (list (car (gnus-id-to-thread id))))
3789 ;; Get the thread this article is part of.
3790 (setq thread (gnus-remove-thread id)))
3791 (setq old-pos (gnus-point-at-bol))
3792 (setq current (save-excursion
3793 (and (re-search-backward "[\r\n]" nil t)
3794 (gnus-summary-article-number))))
3795 ;; If this is a gathered thread, we have to go some re-gathering.
3796 (when (stringp (car thread))
3797 (let ((subject (car thread))
3799 (setq thread (cdr thread))
3801 (unless (memq (setq thr (gnus-id-to-thread
3803 (mail-header-id (caar thread)))))
3806 (setq thread (cdr thread)))
3807 ;; We now have all (unique) roots.
3808 (if (= (length roots) 1)
3809 ;; All the loose roots are now one solid root.
3810 (setq thread (car roots))
3811 (setq thread (cons subject (gnus-sort-threads roots))))))
3813 ;; We then insert this thread into the summary buffer.
3815 (goto-char (point-min))
3816 (forward-line (1- line)))
3817 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3818 (if gnus-show-threads
3819 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3820 (gnus-summary-prepare-unthreaded thread))
3821 (setq data (nreverse gnus-newsgroup-data))
3822 (setq threads gnus-newsgroup-threads))
3823 ;; We splice the new data into the data structure.
3824 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3825 ;;!!! then we want to insert at the beginning of the buffer.
3826 ;;!!! That happens to be true with Gnus now, but that may
3827 ;;!!! change in the future. Perhaps.
3828 (gnus-data-enter-list
3829 (if line nil current) data (- (point) old-pos))
3830 (setq gnus-newsgroup-threads
3831 (nconc threads gnus-newsgroup-threads))
3832 (gnus-data-compute-positions))))
3834 (defun gnus-number-to-header (number)
3835 "Return the header for article NUMBER."
3836 (let ((headers gnus-newsgroup-headers))
3838 (not (= number (mail-header-number (car headers)))))
3843 (defun gnus-parent-headers (in-headers &optional generation)
3844 "Return the headers of the GENERATIONeth parent of HEADERS."
3846 (setq generation 1))
3848 (headers in-headers)
3851 (not (zerop generation))
3852 (setq references (mail-header-references headers)))
3853 (setq headers (if (and references
3854 (setq parent (gnus-parent-id references)))
3855 (car (gnus-id-to-thread parent))
3858 (and (not (eq headers in-headers))
3861 (defun gnus-id-to-thread (id)
3862 "Return the (sub-)thread where ID appears."
3863 (gnus-gethash id gnus-newsgroup-dependencies))
3865 (defun gnus-id-to-article (id)
3866 "Return the article number of ID."
3867 (let ((thread (gnus-id-to-thread id)))
3870 (mail-header-number (car thread)))))
3872 (defun gnus-id-to-header (id)
3873 "Return the article headers of ID."
3874 (car (gnus-id-to-thread id)))
3876 (defun gnus-article-displayed-root-p (article)
3877 "Say whether ARTICLE is a root(ish) article."
3878 (let ((level (gnus-summary-thread-level article))
3879 (refs (mail-header-references (gnus-summary-article-header article)))
3885 ((null (gnus-parent-id refs)) t)
3887 (null (setq particle (gnus-id-to-article
3888 (gnus-parent-id refs))))
3889 (null (gnus-summary-thread-level particle)))))))
3891 (defun gnus-root-id (id)
3892 "Return the id of the root of the thread where ID appears."
3894 (while (and id (setq prev (car (gnus-id-to-thread id))))
3896 id (gnus-parent-id (mail-header-references prev))))
3899 (defun gnus-articles-in-thread (thread)
3900 "Return the list of articles in THREAD."
3901 (cons (mail-header-number (car thread))
3902 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3904 (defun gnus-remove-thread (id &optional dont-remove)
3905 "Remove the thread that has ID in it."
3906 (let (headers thread last-id)
3907 ;; First go up in this thread until we find the root.
3908 (setq last-id (gnus-root-id id)
3909 headers (message-flatten-list (gnus-id-to-thread last-id)))
3910 ;; We have now found the real root of this thread. It might have
3911 ;; been gathered into some loose thread, so we have to search
3912 ;; through the threads to find the thread we wanted.
3913 (let ((threads gnus-newsgroup-threads)
3916 (setq sub (car threads))
3917 (if (stringp (car sub))
3918 ;; This is a gathered thread, so we look at the roots
3919 ;; below it to find whether this article is in this
3922 (setq sub (cdr sub))
3924 (when (member (caar sub) headers)
3925 (setq thread (car threads)
3928 (setq sub (cdr sub))))
3929 ;; It's an ordinary thread, so we check it.
3930 (when (eq (car sub) (car headers))
3933 (setq threads (cdr threads)))
3934 ;; If this article is in no thread, then it's a root.
3937 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3938 (setq thread (gnus-id-to-thread last-id)))
3941 thread ; We return this thread.
3943 (if (stringp (car thread))
3945 ;; If we use dummy roots, then we have to remove the
3946 ;; dummy root as well.
3947 (when (eq gnus-summary-make-false-root 'dummy)
3948 ;; We go to the dummy root by going to
3949 ;; the first sub-"thread", and then one line up.
3950 (gnus-summary-goto-article
3951 (mail-header-number (caadr thread)))
3954 (gnus-data-compute-positions))
3955 (setq thread (cdr thread))
3957 (gnus-remove-thread-1 (car thread))
3958 (setq thread (cdr thread))))
3959 (gnus-remove-thread-1 thread))))))))
3961 (defun gnus-remove-thread-1 (thread)
3962 "Remove the thread THREAD recursively."
3963 (let ((number (mail-header-number (pop thread)))
3965 (setq thread (reverse thread))
3967 (gnus-remove-thread-1 (pop thread)))
3968 (when (setq d (gnus-data-find number))
3969 (goto-char (gnus-data-pos d))
3970 (gnus-summary-show-thread)
3973 (- (gnus-point-at-bol)
3975 (1+ (gnus-point-at-eol))
3976 (gnus-delete-line)))))))
3978 (defun gnus-sort-threads-1 (threads func)
3979 (sort (mapcar (lambda (thread)
3982 (gnus-sort-threads-1 (cdr thread) func))))
3985 (defun gnus-sort-threads (threads)
3987 (if (not gnus-thread-sort-functions)
3989 (gnus-message 8 "Sorting threads...")
3991 (gnus-sort-threads-1
3993 (gnus-make-sort-function gnus-thread-sort-functions))
3994 (gnus-message 8 "Sorting threads...done"))))
3996 (defun gnus-sort-articles (articles)
3998 (when gnus-article-sort-functions
3999 (gnus-message 7 "Sorting articles...")
4001 (setq gnus-newsgroup-headers
4002 (sort articles (gnus-make-sort-function
4003 gnus-article-sort-functions)))
4004 (gnus-message 7 "Sorting articles...done"))))
4006 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4007 (defmacro gnus-thread-header (thread)
4008 "Return header of first article in THREAD.
4009 Note that THREAD must never, ever be anything else than a variable -
4010 using some other form will lead to serious barfage."
4011 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4012 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4013 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4016 (defsubst gnus-article-sort-by-number (h1 h2)
4017 "Sort articles by article number."
4018 (< (mail-header-number h1)
4019 (mail-header-number h2)))
4021 (defun gnus-thread-sort-by-number (h1 h2)
4022 "Sort threads by root article number."
4023 (gnus-article-sort-by-number
4024 (gnus-thread-header h1) (gnus-thread-header h2)))
4026 (defsubst gnus-article-sort-by-lines (h1 h2)
4027 "Sort articles by article Lines header."
4028 (< (mail-header-lines h1)
4029 (mail-header-lines h2)))
4031 (defun gnus-thread-sort-by-lines (h1 h2)
4032 "Sort threads by root article Lines header."
4033 (gnus-article-sort-by-lines
4034 (gnus-thread-header h1) (gnus-thread-header h2)))
4036 (defsubst gnus-article-sort-by-chars (h1 h2)
4037 "Sort articles by octet length."
4038 (< (mail-header-chars h1)
4039 (mail-header-chars h2)))
4041 (defun gnus-thread-sort-by-chars (h1 h2)
4042 "Sort threads by root article octet length."
4043 (gnus-article-sort-by-chars
4044 (gnus-thread-header h1) (gnus-thread-header h2)))
4046 (defsubst gnus-article-sort-by-author (h1 h2)
4047 "Sort articles by root author."
4049 (let ((addr (car (mime-entity-read-field h1 'From))))
4050 (or (std11-full-name-string addr)
4051 (std11-address-string addr)
4053 (let ((addr (car (mime-entity-read-field h2 'From))))
4054 (or (std11-full-name-string addr)
4055 (std11-address-string addr)
4059 (defun gnus-thread-sort-by-author (h1 h2)
4060 "Sort threads by root author."
4061 (gnus-article-sort-by-author
4062 (gnus-thread-header h1) (gnus-thread-header h2)))
4064 (defsubst gnus-article-sort-by-subject (h1 h2)
4065 "Sort articles by root subject."
4067 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4068 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4070 (defun gnus-thread-sort-by-subject (h1 h2)
4071 "Sort threads by root subject."
4072 (gnus-article-sort-by-subject
4073 (gnus-thread-header h1) (gnus-thread-header h2)))
4075 (defsubst gnus-article-sort-by-date (h1 h2)
4076 "Sort articles by root article date."
4078 (gnus-date-get-time (mail-header-date h1))
4079 (gnus-date-get-time (mail-header-date h2))))
4081 (defun gnus-thread-sort-by-date (h1 h2)
4082 "Sort threads by root article date."
4083 (gnus-article-sort-by-date
4084 (gnus-thread-header h1) (gnus-thread-header h2)))
4086 (defsubst gnus-article-sort-by-score (h1 h2)
4087 "Sort articles by root article score.
4088 Unscored articles will be counted as having a score of zero."
4089 (> (or (cdr (assq (mail-header-number h1)
4090 gnus-newsgroup-scored))
4091 gnus-summary-default-score 0)
4092 (or (cdr (assq (mail-header-number h2)
4093 gnus-newsgroup-scored))
4094 gnus-summary-default-score 0)))
4096 (defun gnus-thread-sort-by-score (h1 h2)
4097 "Sort threads by root article score."
4098 (gnus-article-sort-by-score
4099 (gnus-thread-header h1) (gnus-thread-header h2)))
4101 (defun gnus-thread-sort-by-total-score (h1 h2)
4102 "Sort threads by the sum of all scores in the thread.
4103 Unscored articles will be counted as having a score of zero."
4104 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4106 (defun gnus-thread-total-score (thread)
4107 ;; This function find the total score of THREAD.
4108 (cond ((null thread)
4111 (if (stringp (car thread))
4112 (apply gnus-thread-score-function 0
4113 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4114 (gnus-thread-total-score-1 thread)))
4116 (gnus-thread-total-score-1 (list thread)))))
4118 (defun gnus-thread-total-score-1 (root)
4119 ;; This function find the total score of the thread below ROOT.
4120 (setq root (car root))
4121 (apply gnus-thread-score-function
4123 (mapcar 'gnus-thread-total-score
4124 (cdr (gnus-id-to-thread (mail-header-id root))))
4125 (when (> (mail-header-number root) 0)
4126 (list (or (cdr (assq (mail-header-number root)
4127 gnus-newsgroup-scored))
4128 gnus-summary-default-score 0))))
4129 (list gnus-summary-default-score)
4132 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4133 (defvar gnus-tmp-prev-subject nil)
4134 (defvar gnus-tmp-false-parent nil)
4135 (defvar gnus-tmp-root-expunged nil)
4136 (defvar gnus-tmp-dummy-line nil)
4138 (eval-when-compile (defvar gnus-tmp-header))
4139 (defun gnus-extra-header (type &optional header)
4140 "Return the extra header of TYPE."
4141 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4144 (defvar gnus-tmp-thread-tree-header-string "")
4146 (defvar gnus-sum-thread-tree-root "> "
4147 "With %B spec, used for the root of a thread.
4148 If nil, use subject instead.")
4149 (defvar gnus-sum-thread-tree-single-indent ""
4150 "With %B spec, used for a thread with just one message.
4151 If nil, use subject instead.")
4152 (defvar gnus-sum-thread-tree-vertical "| "
4153 "With %B spec, used for drawing a vertical line.")
4154 (defvar gnus-sum-thread-tree-indent " "
4155 "With %B spec, used for indenting.")
4156 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4157 "With %B spec, used for a leaf with brothers.")
4158 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4159 "With %B spec, used for a leaf without brothers.")
4161 (defun gnus-summary-prepare-threads (threads)
4162 "Prepare summary buffer from THREADS and indentation LEVEL.
4163 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4164 or a straight list of headers."
4165 (gnus-message 7 "Generating summary...")
4167 (setq gnus-newsgroup-threads threads)
4170 (let ((gnus-tmp-level 0)
4171 (default-score (or gnus-summary-default-score 0))
4172 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4173 thread number subject stack state gnus-tmp-gathered beg-match
4174 new-roots gnus-tmp-new-adopts thread-end
4175 gnus-tmp-header gnus-tmp-unread
4176 gnus-tmp-replied gnus-tmp-subject-or-nil
4177 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4178 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4179 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4182 (setq gnus-tmp-prev-subject nil)
4184 (if (vectorp (car threads))
4185 ;; If this is a straight (sic) list of headers, then a
4186 ;; threaded summary display isn't required, so we just create
4187 ;; an unthreaded one.
4188 (gnus-summary-prepare-unthreaded threads)
4190 ;; Do the threaded display.
4192 (while (or threads stack gnus-tmp-new-adopts new-roots)
4194 (if (and (= gnus-tmp-level 0)
4197 (not gnus-tmp-false-parent)
4198 (or gnus-tmp-new-adopts new-roots))
4199 (if gnus-tmp-new-adopts
4200 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4201 thread (list (car gnus-tmp-new-adopts))
4202 gnus-tmp-header (caar thread)
4203 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4205 (setq thread (list (car new-roots))
4206 gnus-tmp-header (caar thread)
4207 new-roots (cdr new-roots))))
4210 ;; If there are some threads, we do them before the
4211 ;; threads on the stack.
4212 (setq thread threads
4213 gnus-tmp-header (caar thread))
4214 ;; There were no current threads, so we pop something off
4216 (setq state (car stack)
4217 gnus-tmp-level (car state)
4218 tree-stack (cadr state)
4219 thread (caddr state)
4221 gnus-tmp-header (caar thread))))
4223 (setq gnus-tmp-false-parent nil)
4224 (setq gnus-tmp-root-expunged nil)
4225 (setq thread-end nil)
4227 (if (stringp gnus-tmp-header)
4228 ;; The header is a dummy root.
4230 ((eq gnus-summary-make-false-root 'adopt)
4231 ;; We let the first article adopt the rest.
4232 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4234 (setq gnus-tmp-gathered
4236 (lambda (h) (mail-header-number (car h)))
4239 (setq thread (cons (list (caar thread)
4242 (setq gnus-tmp-level -1
4243 gnus-tmp-false-parent t))
4244 ((eq gnus-summary-make-false-root 'empty)
4245 ;; We print adopted articles with empty subject fields.
4246 (setq gnus-tmp-gathered
4248 (lambda (h) (mail-header-number (car h)))
4251 (setq gnus-tmp-level -1))
4252 ((eq gnus-summary-make-false-root 'dummy)
4253 ;; We remember that we probably want to output a dummy
4255 (setq gnus-tmp-dummy-line gnus-tmp-header)
4256 (setq gnus-tmp-prev-subject gnus-tmp-header))
4258 ;; We do not make a root for the gathered
4259 ;; sub-threads at all.
4260 (setq gnus-tmp-level -1)))
4262 (setq number (mail-header-number gnus-tmp-header)
4263 subject (mail-header-subject gnus-tmp-header))
4266 ;; If the thread has changed subject, we might want to make
4267 ;; this subthread into a root.
4268 ((and (null gnus-thread-ignore-subject)
4269 (not (zerop gnus-tmp-level))
4270 gnus-tmp-prev-subject
4272 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4273 (setq new-roots (nconc new-roots (list (car thread)))
4275 gnus-tmp-header nil))
4276 ;; If the article lies outside the current limit,
4277 ;; then we do not display it.
4278 ((not (memq number gnus-newsgroup-limit))
4279 (setq gnus-tmp-gathered
4281 (lambda (h) (mail-header-number (car h)))
4284 (setq gnus-tmp-new-adopts (if (cdar thread)
4285 (append gnus-tmp-new-adopts
4287 gnus-tmp-new-adopts)
4289 gnus-tmp-header nil)
4290 (when (zerop gnus-tmp-level)
4291 (setq gnus-tmp-root-expunged t)))
4292 ;; Perhaps this article is to be marked as read?
4293 ((and gnus-summary-mark-below
4294 (< (or (cdr (assq number gnus-newsgroup-scored))
4296 gnus-summary-mark-below)
4297 ;; Don't touch sparse articles.
4298 (not (gnus-summary-article-sparse-p number))
4299 (not (gnus-summary-article-ancient-p number)))
4300 (setq gnus-newsgroup-unreads
4301 (delq number gnus-newsgroup-unreads))
4302 (if gnus-newsgroup-auto-expire
4303 (push number gnus-newsgroup-expirable)
4304 (push (cons number gnus-low-score-mark)
4305 gnus-newsgroup-reads))))
4307 (when gnus-tmp-header
4308 ;; We may have an old dummy line to output before this
4310 (when (and gnus-tmp-dummy-line
4313 (mail-header-subject gnus-tmp-header)))
4314 (gnus-summary-insert-dummy-line
4315 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4316 (setq gnus-tmp-dummy-line nil))
4318 ;; Compute the mark.
4319 (setq gnus-tmp-unread (gnus-article-mark number))
4321 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4322 gnus-tmp-header gnus-tmp-level)
4323 gnus-newsgroup-data)
4325 ;; Actually insert the line.
4327 gnus-tmp-subject-or-nil
4329 ((and gnus-thread-ignore-subject
4330 gnus-tmp-prev-subject
4331 (not (inline (gnus-subject-equal
4332 gnus-tmp-prev-subject subject))))
4334 ((zerop gnus-tmp-level)
4335 (if (and (eq gnus-summary-make-false-root 'empty)
4336 (memq number gnus-tmp-gathered)
4337 gnus-tmp-prev-subject
4338 (inline (gnus-subject-equal
4339 gnus-tmp-prev-subject subject)))
4340 gnus-summary-same-subject
4342 (t gnus-summary-same-subject)))
4343 (if (and (eq gnus-summary-make-false-root 'adopt)
4344 (= gnus-tmp-level 1)
4345 (memq number gnus-tmp-gathered))
4346 (setq gnus-tmp-opening-bracket ?\<
4347 gnus-tmp-closing-bracket ?\>)
4348 (setq gnus-tmp-opening-bracket ?\[
4349 gnus-tmp-closing-bracket ?\]))
4351 gnus-tmp-indentation
4352 (aref gnus-thread-indent-array gnus-tmp-level)
4353 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4354 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4355 gnus-summary-default-score 0)
4357 (if (or (null gnus-summary-default-score)
4358 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4359 gnus-summary-zcore-fuzz))
4361 (if (< gnus-tmp-score gnus-summary-default-score)
4362 gnus-score-below-mark gnus-score-over-mark))
4364 (cond ((memq number gnus-newsgroup-processable)
4366 ((memq number gnus-newsgroup-cached)
4368 ((memq number gnus-newsgroup-replied)
4370 ((memq number gnus-newsgroup-forwarded)
4371 gnus-forwarded-mark)
4372 ((memq number gnus-newsgroup-saved)
4374 ((memq number gnus-newsgroup-recent)
4376 ((memq number gnus-newsgroup-unseen)
4379 gnus-tmp-from (mail-header-from gnus-tmp-header)
4382 ((string-match "<[^>]+> *$" gnus-tmp-from)
4383 (setq beg-match (match-beginning 0))
4384 (or (and (string-match "^\".+\"" gnus-tmp-from)
4385 (substring gnus-tmp-from 1 (1- (match-end 0))))
4386 (substring gnus-tmp-from 0 beg-match)))
4387 ((string-match "(.+)" gnus-tmp-from)
4388 (substring gnus-tmp-from
4389 (1+ (match-beginning 0)) (1- (match-end 0))))
4391 gnus-tmp-thread-tree-header-string
4393 ((not gnus-show-threads) "")
4394 ((zerop gnus-tmp-level)
4396 (or gnus-sum-thread-tree-root subject)
4397 (or gnus-sum-thread-tree-single-indent subject)))
4399 (concat (apply 'concat
4400 (mapcar (lambda (item)
4402 gnus-sum-thread-tree-vertical
4403 gnus-sum-thread-tree-indent))
4404 (cdr (reverse tree-stack))))
4406 gnus-sum-thread-tree-leaf-with-other
4407 gnus-sum-thread-tree-single-leaf)))))
4408 (when (string= gnus-tmp-name "")
4409 (setq gnus-tmp-name gnus-tmp-from))
4410 (unless (numberp gnus-tmp-lines)
4411 (setq gnus-tmp-lines -1))
4412 (when (= gnus-tmp-lines -1)
4413 (setq gnus-tmp-lines "?"))
4414 (gnus-put-text-property
4416 (progn (eval gnus-summary-line-format-spec) (point))
4417 'gnus-number number)
4420 (gnus-run-hooks 'gnus-summary-update-hook)
4423 (setq gnus-tmp-prev-subject subject)))
4425 (when (nth 1 thread)
4426 (push (list (max 0 gnus-tmp-level)
4427 (copy-list tree-stack)
4430 (push (if (nth 1 thread) 1 0) tree-stack)
4431 (incf gnus-tmp-level)
4432 (setq threads (if thread-end nil (cdar thread)))
4434 (setq gnus-tmp-level 0)))))
4435 (gnus-message 7 "Generating summary...done"))
4437 (defun gnus-summary-prepare-unthreaded (headers)
4438 "Generate an unthreaded summary buffer based on HEADERS."
4439 (let (header number mark)
4444 ;; We may have to root out some bad articles...
4445 (when (memq (setq number (mail-header-number
4446 (setq header (pop headers))))
4447 gnus-newsgroup-limit)
4448 ;; Mark article as read when it has a low score.
4449 (when (and gnus-summary-mark-below
4450 (< (or (cdr (assq number gnus-newsgroup-scored))
4451 gnus-summary-default-score 0)
4452 gnus-summary-mark-below)
4453 (not (gnus-summary-article-ancient-p number)))
4454 (setq gnus-newsgroup-unreads
4455 (delq number gnus-newsgroup-unreads))
4456 (if gnus-newsgroup-auto-expire
4457 (push number gnus-newsgroup-expirable)
4458 (push (cons number gnus-low-score-mark)
4459 gnus-newsgroup-reads)))
4461 (setq mark (gnus-article-mark number))
4462 (push (gnus-data-make number mark (1+ (point)) header 0)
4463 gnus-newsgroup-data)
4464 (gnus-summary-insert-line
4466 mark (memq number gnus-newsgroup-replied)
4467 (memq number gnus-newsgroup-expirable)
4468 (mail-header-subject header) nil
4469 (cdr (assq number gnus-newsgroup-scored))
4470 (memq number gnus-newsgroup-processable))))))
4472 (defun gnus-summary-remove-list-identifiers ()
4473 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4474 (let ((regexp (if (consp gnus-list-identifiers)
4475 (mapconcat 'identity gnus-list-identifiers " *\\|")
4476 gnus-list-identifiers))
4479 (dolist (header gnus-newsgroup-headers)
4480 (setq subject (mail-header-subject header)
4482 (while (string-match
4483 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4486 (concat (substring subject 0 (match-beginning 2))
4487 (substring subject (match-end 0)))
4491 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4493 (concat (substring subject 0 (match-beginning 1))
4494 (substring subject (match-end 1)))))
4496 (mail-header-set-subject header subject))))))
4498 (defun gnus-fetch-headers (articles)
4499 "Fetch headers of ARTICLES."
4500 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4501 (gnus-message 5 "Fetching headers for %s..." name)
4504 (setq gnus-headers-retrieved-by
4505 (gnus-retrieve-headers
4506 articles gnus-newsgroup-name
4507 ;; We might want to fetch old headers, but
4508 ;; not if there is only 1 article.
4510 (not (eq gnus-fetch-old-headers 'some))
4511 (not (numberp gnus-fetch-old-headers)))
4512 (> (length articles) 1))
4513 gnus-fetch-old-headers))))
4514 (gnus-get-newsgroup-headers-xover
4515 articles nil nil gnus-newsgroup-name t)
4516 (gnus-get-newsgroup-headers))
4517 (gnus-message 5 "Fetching headers for %s...done" name))))
4519 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4520 "Select newsgroup GROUP.
4521 If READ-ALL is non-nil, all articles in the group are selected.
4522 If SELECT-ARTICLES, only select those articles from GROUP."
4523 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4524 ;;!!! Dirty hack; should be removed.
4525 (gnus-summary-ignore-duplicates
4526 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4528 gnus-summary-ignore-duplicates))
4529 (info (nth 2 entry))
4530 articles fetched-articles cached)
4532 (unless (gnus-check-server
4533 (setq gnus-current-select-method
4534 (gnus-find-method-for-group group)))
4535 (error "Couldn't open server"))
4537 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4538 (gnus-activate-group group) ; Or we can activate it...
4539 (progn ; Or we bug out.
4540 (when (equal major-mode 'gnus-summary-mode)
4541 (kill-buffer (current-buffer)))
4542 (error "Couldn't activate group %s: %s"
4543 group (gnus-status-message group))))
4545 (unless (gnus-request-group group t)
4546 (when (equal major-mode 'gnus-summary-mode)
4547 (kill-buffer (current-buffer)))
4548 (error "Couldn't request group %s: %s"
4549 group (gnus-status-message group)))
4551 (setq gnus-newsgroup-name group
4552 gnus-newsgroup-unselected nil
4553 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4555 (setq gnus-newsgroup-display (gnus-group-find-parameter group 'display))
4556 (setq gnus-newsgroup-display
4558 ((eq gnus-newsgroup-display 'all)
4559 (setq gnus-newsgroup-display 'identity))
4560 ((arrayp gnus-newsgroup-display)
4561 (gnus-summary-display-make-predicate
4562 (mapcar 'identity gnus-newsgroup-display)))
4566 (gnus-summary-setup-default-charset)
4568 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4569 (when (gnus-virtual-group-p group)
4570 (setq cached gnus-newsgroup-cached))
4572 (setq gnus-newsgroup-unreads
4573 (gnus-set-difference
4574 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4575 gnus-newsgroup-dormant))
4577 (setq gnus-newsgroup-processable nil)
4579 (gnus-update-read-articles group gnus-newsgroup-unreads)
4581 ;; Adjust and set lists of article marks.
4583 (gnus-adjust-marked-articles info))
4585 (if (setq articles select-articles)
4586 (setq gnus-newsgroup-unselected
4587 (gnus-sorted-intersection
4588 gnus-newsgroup-unreads
4589 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4590 (setq articles (gnus-articles-to-read group read-all)))
4594 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4596 ((eq articles 0) nil)
4598 ;; Init the dependencies hash table.
4599 (setq gnus-newsgroup-dependencies
4600 (gnus-make-hashtable (length articles)))
4601 (gnus-set-global-variables)
4602 ;; Retrieve the headers and read them in.
4603 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4605 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4607 (setq gnus-newsgroup-cached cached))
4609 ;; Suppress duplicates?
4610 (when gnus-suppress-duplicates
4611 (gnus-dup-suppress-articles))
4613 ;; Set the initial limit.
4614 (setq gnus-newsgroup-limit (copy-sequence articles))
4615 ;; Remove canceled articles from the list of unread articles.
4616 (setq fetched-articles
4617 (mapcar (lambda (headers) (mail-header-number headers))
4618 gnus-newsgroup-headers))
4619 (setq gnus-newsgroup-articles fetched-articles)
4620 (setq gnus-newsgroup-unreads
4621 (gnus-set-sorted-intersection
4622 gnus-newsgroup-unreads fetched-articles))
4624 (let ((marks (assq 'seen (gnus-info-marks info))))
4625 ;; The `seen' marks are treated specially.
4626 (when (setq gnus-newsgroup-seen (cdr marks))
4627 (dolist (article gnus-newsgroup-articles)
4628 (unless (gnus-member-of-range
4629 article gnus-newsgroup-seen)
4630 (push article gnus-newsgroup-unseen)))))
4632 ;; Removed marked articles that do not exist.
4633 (gnus-update-missing-marks
4634 (gnus-sorted-complement fetched-articles articles))
4635 ;; We might want to build some more threads first.
4636 (when (and gnus-fetch-old-headers
4637 (eq gnus-headers-retrieved-by 'nov))
4638 (if (eq gnus-fetch-old-headers 'invisible)
4639 (gnus-build-all-threads)
4640 (gnus-build-old-threads)))
4641 ;; Let the Gnus agent mark articles as read.
4643 (gnus-agent-get-undownloaded-list))
4644 ;; Remove list identifiers from subject
4645 (when gnus-list-identifiers
4646 (gnus-summary-remove-list-identifiers))
4647 ;; Check whether auto-expire is to be done in this group.
4648 (setq gnus-newsgroup-auto-expire
4649 (gnus-group-auto-expirable-p group))
4650 ;; Set up the article buffer now, if necessary.
4651 (unless gnus-single-article-buffer
4652 (gnus-article-setup-buffer))
4653 ;; First and last article in this newsgroup.
4654 (when gnus-newsgroup-headers
4655 (setq gnus-newsgroup-begin
4656 (mail-header-number (car gnus-newsgroup-headers))
4659 (gnus-last-element gnus-newsgroup-headers))))
4660 ;; GROUP is successfully selected.
4661 (or gnus-newsgroup-headers t)))))
4663 (defun gnus-summary-display-make-predicate (display)
4664 (require 'gnus-agent)
4665 (when (= (length display) 1)
4666 (setq display (car display)))
4667 (unless gnus-summary-display-cache
4668 (dolist (elem gnus-article-mark-lists)
4669 (push (cons (cdr elem)
4671 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4672 gnus-summary-display-cache)))
4673 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4674 (gnus-get-predicate display)))
4676 ;; Uses the dynamically bound `number' variable.
4678 (defun gnus-article-marked-p (type &optional article)
4679 (let ((article (or article number)))
4682 (memq article gnus-newsgroup-marked))
4684 (memq article gnus-newsgroup-unsendable))
4685 ((eq type 'undownload)
4686 (memq article gnus-newsgroup-undownloaded))
4687 ((eq type 'download)
4688 (memq article gnus-newsgroup-downloadable))
4690 (memq article gnus-newsgroup-unreads))
4692 (memq article gnus-newsgroup-reads))
4694 (memq article gnus-newsgroup-dormant) )
4696 (memq article gnus-newsgroup-expirable))
4698 (memq article gnus-newsgroup-replied))
4700 (memq article gnus-newsgroup-killed))
4701 ((eq type 'bookmark)
4702 (assq article gnus-newsgroup-bookmarks))
4704 (assq article gnus-newsgroup-scored))
4706 (memq article gnus-newsgroup-saved))
4708 (memq article gnus-newsgroup-cached))
4710 (memq article gnus-newsgroup-forwarded))
4712 (memq article gnus-newsgroup-recent))
4715 (defun gnus-articles-to-read (group &optional read-all)
4716 "Find out what articles the user wants to read."
4718 ;; Select all articles if `read-all' is non-nil, or if there
4719 ;; are no unread articles.
4721 (and (zerop (length gnus-newsgroup-marked))
4722 (zerop (length gnus-newsgroup-unreads)))
4723 gnus-newsgroup-display)
4724 ;; We want to select the headers for all the articles in
4725 ;; the group, so we select either all the active
4726 ;; articles in the group, or (if that's nil), the
4727 ;; articles in the cache.
4729 (gnus-uncompress-range (gnus-active group))
4730 (gnus-cache-articles-in-group group))
4731 ;; Select only the "normal" subset of articles.
4732 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4733 (copy-sequence gnus-newsgroup-unreads))
4735 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4736 (scored (length scored-list))
4737 (number (length articles))
4738 (marked (+ (length gnus-newsgroup-marked)
4739 (length gnus-newsgroup-dormant)))
4747 ((and (or (<= scored marked) (= scored number))
4748 (natnump gnus-large-newsgroup)
4749 (> number gnus-large-newsgroup))
4750 (let* ((cursor-in-echo-area nil)
4752 (read-from-minibuffer
4754 "How many articles from %s (max %d): "
4756 (gnus-group-decoded-name gnus-newsgroup-name)
4759 (cons (number-to-string gnus-large-newsgroup)
4761 (if (string-match "^[ \t]*$" input)
4764 ((and (> scored marked) (< scored number)
4765 (> (- scored number) 20))
4768 (format "%s %s (%d scored, %d total): "
4769 "How many articles from"
4770 (gnus-group-decoded-name group)
4772 (if (string-match "^[ \t]*$" input)
4776 (message "Quit getting the articles to read")
4778 (setq select (if (stringp select) (string-to-number select) select))
4779 (if (or (null select) (zerop select))
4781 (if (and (not (zerop scored)) (<= (abs select) scored))
4783 (setq articles (sort scored-list '<))
4784 (setq number (length articles)))
4785 (setq articles (copy-sequence articles)))
4787 (when (< (abs select) number)
4789 ;; Select the N oldest articles.
4790 (setcdr (nthcdr (1- (abs select)) articles) nil)
4791 ;; Select the N most recent articles.
4792 (setq articles (nthcdr (- number select) articles))))
4793 (setq gnus-newsgroup-unselected
4794 (gnus-sorted-intersection
4795 gnus-newsgroup-unreads
4796 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4797 (when gnus-alter-articles-to-read-function
4798 (setq gnus-newsgroup-unreads
4800 (funcall gnus-alter-articles-to-read-function
4801 gnus-newsgroup-name gnus-newsgroup-unreads)
4805 (defun gnus-killed-articles (killed articles)
4808 (when (inline (gnus-member-of-range (car articles) killed))
4809 (push (car articles) out))
4810 (setq articles (cdr articles)))
4813 (defun gnus-uncompress-marks (marks)
4814 "Uncompress the mark ranges in MARKS."
4815 (let ((uncompressed '(score bookmark))
4818 (if (memq (caar marks) uncompressed)
4819 (push (car marks) out)
4820 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4821 (setq marks (cdr marks)))
4824 (defun gnus-adjust-marked-articles (info)
4825 "Set all article lists and remove all marks that are no longer valid."
4826 (let* ((marked-lists (gnus-info-marks info))
4827 (active (gnus-active (gnus-info-group info)))
4830 (types gnus-article-mark-lists)
4831 (uncompressed '(score bookmark killed))
4832 marks var articles article mark)
4834 (dolist (marks marked-lists)
4835 (setq mark (car marks))
4836 (unless (eq mark 'seen)
4837 ;; Do the rest of the marks.
4838 (set (setq var (intern (format "gnus-newsgroup-%s"
4839 (car (rassq mark types)))))
4841 ((memq mark uncompressed)
4844 (gnus-uncompress-range (cdr marks)))))
4846 (setq articles (symbol-value var))
4848 ;; All articles have to be subsets of the active articles.
4850 ;; Adjust "simple" lists.
4851 ((memq mark '(tick dormant expire reply save))
4853 (when (or (< (setq article (pop articles)) min) (> article max))
4854 (set var (delq article (symbol-value var))))))
4856 ((memq mark uncompressed)
4857 (when (not (listp (cdr (symbol-value var))))
4858 (set var (list (symbol-value var))))
4859 (when (not (listp (cdr articles)))
4860 (setq articles (list articles)))
4862 (when (or (not (consp (setq article (pop articles))))
4863 (< (car article) min)
4864 (> (car article) max))
4865 (set var (delq article (symbol-value var)))))))))))
4867 (defun gnus-update-missing-marks (missing)
4868 "Go through the list of MISSING articles and remove them from the mark lists."
4870 (let ((types gnus-article-mark-lists)
4872 ;; Go through all types.
4874 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4875 (when (symbol-value var)
4876 ;; This list has articles. So we delete all missing articles
4880 (set var (delq (pop m) (symbol-value var)))))))))
4882 (defun gnus-update-marks ()
4883 "Enter the various lists of marked articles into the newsgroup info list."
4884 (let ((types gnus-article-mark-lists)
4885 (info (gnus-get-info gnus-newsgroup-name))
4886 (uncompressed '(score bookmark killed seen))
4887 type list newmarked symbol delta-marks)
4889 ;; Add all marks lists to the list of marks lists.
4890 (while (setq type (pop types))
4891 (setq list (symbol-value
4893 (intern (format "gnus-newsgroup-%s" (car type))))))
4896 ;; Get rid of the entries of the articles that have the
4898 (when (and (eq (cdr type) 'score)
4902 (prev (cons nil list))
4905 (if (or (not (consp (car arts)))
4906 (= (cdar arts) gnus-summary-default-score))
4907 (setcdr prev (cdr arts))
4909 (setq arts (cdr arts)))
4910 (setq list (cdr all)))))
4912 (when (eq (cdr type) 'seen)
4915 (gnus-add-to-range list gnus-newsgroup-unseen)
4916 (gnus-compress-sequence gnus-newsgroup-articles))))
4918 (unless (memq (cdr type) uncompressed)
4919 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4921 (when (gnus-check-backend-function
4922 'request-set-mark gnus-newsgroup-name)
4923 ;; propagate flags to server, with the following exceptions:
4924 ;; uncompressed:s are not proper flags (they are cons cells)
4925 ;; cache is a internal gnus flag
4926 ;; download are local to one gnus installation (well)
4927 ;; unsend are for nndraft groups only
4928 ;; xxx: generality of this? this suits nnimap anyway
4929 (unless (memq (cdr type) (append '(cache download unsend)
4931 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4932 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4933 (add (gnus-remove-from-range
4934 (gnus-copy-sequence list) old)))
4936 (push (list add 'add (list (cdr type))) delta-marks))
4938 (push (list del 'del (list (cdr type))) delta-marks)))))
4941 (push (cons (cdr type) list) newmarked)))
4944 (unless (gnus-check-group gnus-newsgroup-name)
4945 (error "Can't open server for %s" gnus-newsgroup-name))
4946 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4948 ;; Enter these new marks into the info of the group.
4950 (setcar (nthcdr 3 info) newmarked)
4951 ;; Add the marks lists to the end of the info.
4953 (setcdr (nthcdr 2 info) (list newmarked))))
4955 ;; Cut off the end of the info if there's nothing else there.
4959 (when (nthcdr (decf i) info)
4960 (setcdr (nthcdr i info) nil)))))))
4962 (defun gnus-set-mode-line (where)
4963 "Set the mode line of the article or summary buffers.
4964 If WHERE is `summary', the summary mode line format will be used."
4965 ;; Is this mode line one we keep updated?
4966 (when (and (memq where gnus-updated-mode-lines)
4968 (intern (format "gnus-%s-mode-line-format-spec" where))))
4971 ;; We evaluate this in the summary buffer since these
4972 ;; variables are buffer-local to that buffer.
4973 (set-buffer gnus-summary-buffer)
4974 ;; We bind all these variables that are used in the `eval' form
4976 (let* ((mformat (symbol-value
4978 (format "gnus-%s-mode-line-format-spec" where))))
4979 (gnus-tmp-group-name (gnus-group-decoded-name
4980 gnus-newsgroup-name))
4981 (gnus-tmp-article-number (or gnus-current-article 0))
4982 (gnus-tmp-unread gnus-newsgroup-unreads)
4983 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4984 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4985 (gnus-tmp-unread-and-unselected
4986 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4987 (zerop gnus-tmp-unselected))
4989 ((zerop gnus-tmp-unselected)
4990 (format "{%d more}" gnus-tmp-unread-and-unticked))
4991 (t (format "{%d(+%d) more}"
4992 gnus-tmp-unread-and-unticked
4993 gnus-tmp-unselected))))
4995 (if (and gnus-current-headers
4996 (vectorp gnus-current-headers))
4997 (gnus-mode-string-quote
4998 (mail-header-subject gnus-current-headers))
5000 bufname-length max-len
5001 gnus-tmp-header);; passed as argument to any user-format-funcs
5002 (setq mode-string (eval mformat))
5003 (setq bufname-length (if (string-match "%b" mode-string)
5006 (if (eq where 'summary)
5008 (get-buffer gnus-article-buffer))))
5011 (setq max-len (max 4 (if gnus-mode-non-string-length
5013 gnus-mode-non-string-length
5015 (length mode-string))))
5016 ;; We might have to chop a bit of the string off...
5017 (when (> (length mode-string) max-len)
5019 (concat (gnus-truncate-string mode-string (- max-len 3))
5021 ;; Pad the mode string a bit.
5022 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5023 ;; Update the mode line.
5024 (setq mode-line-buffer-identification
5025 (gnus-mode-line-buffer-identification (list mode-string)))
5026 (set-buffer-modified-p t))))
5028 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5029 "Go through the HEADERS list and add all Xrefs to a hash table.
5030 The resulting hash table is returned, or nil if no Xrefs were found."
5031 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5032 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5033 (xref-hashtb (gnus-make-hashtable))
5034 start group entry number xrefs header)
5036 (setq header (pop headers))
5037 (when (and (setq xrefs (mail-header-xref header))
5038 (not (memq (setq number (mail-header-number header))
5041 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5042 (setq start (match-end 0))
5043 (setq group (if prefix
5044 (concat prefix (substring xrefs (match-beginning 1)
5046 (substring xrefs (match-beginning 1) (match-end 1))))
5048 (string-to-int (substring xrefs (match-beginning 2)
5050 (if (setq entry (gnus-gethash group xref-hashtb))
5051 (setcdr entry (cons number (cdr entry)))
5052 (gnus-sethash group (cons number nil) xref-hashtb)))))
5053 (and start xref-hashtb)))
5055 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5056 "Look through all the headers and mark the Xrefs as read."
5057 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5058 name entry info xref-hashtb idlist method nth4)
5060 (set-buffer gnus-group-buffer)
5061 (when (setq xref-hashtb
5062 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5065 (unless (string= from-newsgroup (setq name (symbol-name group)))
5066 (setq idlist (symbol-value group))
5067 ;; Dead groups are not updated.
5069 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5071 (when (stringp (setq nth4 (gnus-info-method info)))
5072 (setq nth4 (gnus-server-to-method nth4))))
5073 ;; Only do the xrefs if the group has the same
5074 ;; select method as the group we have just read.
5075 (or (gnus-methods-equal-p
5076 nth4 (gnus-find-method-for-group from-newsgroup))
5078 (equal nth4 (setq method (gnus-find-method-for-group
5080 (and (equal (car nth4) (car method))
5081 (equal (nth 1 nth4) (nth 1 method))))
5082 gnus-use-cross-reference
5083 (or (not (eq gnus-use-cross-reference t))
5085 ;; Only do cross-references on subscribed
5086 ;; groups, if that is what is wanted.
5087 (<= (gnus-info-level info) gnus-level-subscribed))
5088 (gnus-group-make-articles-read name idlist))))
5091 (defun gnus-compute-read-articles (group articles)
5092 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5093 (info (nth 2 entry))
5094 (active (gnus-active group))
5097 ;; First peel off all invalid article numbers.
5099 (let ((ids articles)
5101 (while (setq id (pop ids))
5102 (when (and first (> id (cdr active)))
5103 ;; We'll end up in this situation in one particular
5104 ;; obscure situation. If you re-scan a group and get
5105 ;; a new article that is cross-posted to a different
5106 ;; group that has not been re-scanned, you might get
5107 ;; crossposted article that has a higher number than
5108 ;; Gnus believes possible. So we re-activate this
5109 ;; group as well. This might mean doing the
5110 ;; crossposting thingy will *increase* the number
5111 ;; of articles in some groups. Tsk, tsk.
5112 (setq active (or (gnus-activate-group group) active)))
5113 (when (or (> id (cdr active))
5114 (< id (car active)))
5115 (setq articles (delq id articles))))))
5116 ;; If the read list is nil, we init it.
5118 (null (gnus-info-read info))
5120 (setq ninfo (cons 1 (1- (car active))))
5121 (setq ninfo (gnus-info-read info)))
5122 ;; Then we add the read articles to the range.
5124 ninfo (setq articles (sort articles '<))))))
5126 (defun gnus-group-make-articles-read (group articles)
5127 "Update the info of GROUP to say that ARTICLES are read."
5129 (entry (gnus-gethash group gnus-newsrc-hashtb))
5130 (info (nth 2 entry))
5131 (active (gnus-active group))
5134 (setq range (gnus-compute-read-articles group articles))
5136 (set-buffer gnus-group-buffer)
5139 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5140 (gnus-info-set-read ',info ',(gnus-info-read info))
5141 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5142 (gnus-group-update-group ,group t))))
5143 ;; Add the read articles to the range.
5144 (gnus-info-set-read info range)
5145 (gnus-request-set-mark group (list (list range 'add '(read))))
5146 ;; Then we have to re-compute how many unread
5147 ;; articles there are in this group.
5151 (setq num (- (1+ (cdr active)) (car active))))
5152 ((not (listp (cdr range)))
5153 (setq num (- (cdr active) (- (1+ (cdr range))
5157 (if (numberp (car range))
5159 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5160 (setq range (cdr range)))
5161 (setq num (- (cdr active) num))))
5162 ;; Update the number of unread articles.
5164 ;; Update the group buffer.
5165 (gnus-group-update-group group t)))))
5167 (defvar gnus-newsgroup-none-id 0)
5169 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5170 (let ((cur nntp-server-buffer)
5173 (save-excursion (set-buffer gnus-summary-buffer)
5174 gnus-newsgroup-dependencies)))
5176 (mail-parse-charset gnus-newsgroup-charset)
5177 (mail-parse-ignored-charsets
5178 (save-excursion (condition-case nil
5179 (set-buffer gnus-summary-buffer)
5181 gnus-newsgroup-ignored-charsets)))
5183 (set-buffer nntp-server-buffer)
5184 ;; Translate all TAB characters into SPACE characters.
5185 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5186 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5187 (gnus-run-hooks 'gnus-parse-headers-hook)
5188 (let ((case-fold-search t)
5189 in-reply-to header p lines chars ctype)
5190 (goto-char (point-min))
5191 ;; Search to the beginning of the next header. Error messages
5192 ;; do not begin with 2 or 3.
5193 (while (re-search-forward "^[23][0-9]+ " nil t)
5196 ;; This implementation of this function, with nine
5197 ;; search-forwards instead of the one re-search-forward and
5198 ;; a case (which basically was the old function) is actually
5199 ;; about twice as fast, even though it looks messier. You
5200 ;; can't have everything, I guess. Speed and elegance
5201 ;; doesn't always go hand in hand.
5204 (make-full-mail-header
5210 (narrow-to-region (point)
5211 (or (and (search-forward "\n.\n" nil t)
5217 (if (search-forward "\nsubject:" nil t)
5218 (nnheader-header-value)
5223 (if (search-forward "\nfrom:" nil t)
5224 (nnheader-header-value)
5229 (if (search-forward "\ndate:" nil t)
5230 (nnheader-header-value) ""))
5234 (setq id (if (re-search-forward
5235 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5236 ;; We do it this way to make sure the Message-ID
5237 ;; is (somewhat) syntactically valid.
5238 (buffer-substring (match-beginning 1)
5240 ;; If there was no message-id, we just fake one
5241 ;; to make subsequent routines simpler.
5242 (nnheader-generate-fake-message-id))))
5246 (if (search-forward "\nreferences:" nil t)
5250 (nnheader-header-value)
5255 (search-backward ">" end t)
5258 (search-backward "<" end t)
5260 ;; Get the references from the in-reply-to header if there
5261 ;; were no references and the in-reply-to header looks
5263 (if (and (search-forward "\nin-reply-to:" nil t)
5264 (setq in-reply-to (nnheader-header-value))
5265 (string-match "<[^>]+>" in-reply-to))
5267 (setq ref (substring in-reply-to (match-beginning 0)
5269 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5270 (setq ref2 (substring in-reply-to (match-beginning 0)
5272 (when (> (length ref2) (length ref))
5279 (if (search-forward "\nchars: " nil t)
5280 (if (numberp (setq chars (ignore-errors (read cur))))
5286 (if (search-forward "\nlines: " nil t)
5287 (if (numberp (setq lines (ignore-errors (read cur))))
5293 (and (search-forward "\nxref:" nil t)
5294 (nnheader-header-value)))
5296 (when gnus-extra-headers
5297 (let ((extra gnus-extra-headers)
5301 (when (search-forward
5302 (concat "\n" (symbol-name (car extra)) ":") nil t)
5303 (push (cons (car extra) (nnheader-header-value)) out))
5307 (if (and (search-forward "\ncontent-type: " nil t)
5308 (setq ctype (nnheader-header-value)))
5309 (mime-entity-set-content-type-internal
5310 header (mime-parse-Content-Type ctype)))
5311 (when (equal id ref)
5314 (when gnus-alter-header-function
5315 (funcall gnus-alter-header-function header)
5316 (setq id (mail-header-id header)
5317 ref (gnus-parent-id (mail-header-references header))))
5320 (gnus-dependencies-add-header
5321 header dependencies force-new))
5322 (push header headers))
5323 (goto-char (point-max))
5325 (nreverse headers)))))
5327 ;; Goes through the xover lines and returns a list of vectors
5328 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5329 force-new dependencies
5330 group also-fetch-heads)
5331 "Parse the news overview data in the server buffer.
5332 Return a list of headers that match SEQUENCE (see
5333 `nntp-retrieve-headers')."
5334 ;; Get the Xref when the users reads the articles since most/some
5335 ;; NNTP servers do not include Xrefs when using XOVER.
5336 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5337 (let ((mail-parse-charset gnus-newsgroup-charset)
5338 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5339 (cur nntp-server-buffer)
5340 (dependencies (or dependencies gnus-newsgroup-dependencies))
5342 ((eq gnus-read-all-available-headers t)
5344 ((stringp gnus-read-all-available-headers)
5345 (string-match gnus-read-all-available-headers group))
5348 number headers header)
5350 (set-buffer nntp-server-buffer)
5351 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5352 ;; Allow the user to mangle the headers before parsing them.
5353 (gnus-run-hooks 'gnus-parse-headers-hook)
5354 (goto-char (point-min))
5357 (while (and (or sequence allp)
5359 (setq number (read cur))
5361 (while (and sequence
5362 (< (car sequence) number))
5363 (setq sequence (cdr sequence))))
5366 (eq number (car sequence))))
5368 (setq sequence (cdr sequence))
5369 (setq header (inline
5370 (gnus-nov-parse-line
5371 number dependencies force-new)))))
5372 (push header headers))
5375 (gnus-error 4 "Strange nov line (%d)"
5376 (count-lines (point-min) (point)))))
5378 ;; A common bug in inn is that if you have posted an article and
5379 ;; then retrieves the active file, it will answer correctly --
5380 ;; the new article is included. However, a NOV entry for the
5381 ;; article may not have been generated yet, so this may fail.
5382 ;; We work around this problem by retrieving the last few
5383 ;; headers using HEAD.
5384 (if (or (not also-fetch-heads)
5386 ;; We (probably) got all the headers.
5388 (let ((gnus-nov-is-evil t))
5391 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5392 (gnus-get-newsgroup-headers))))))))
5394 (defun gnus-article-get-xrefs ()
5395 "Fill in the Xref value in `gnus-current-headers', if necessary.
5396 This is meant to be called in `gnus-article-internal-prepare-hook'."
5397 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5398 gnus-current-headers)))
5399 (or (not gnus-use-cross-reference)
5401 (and (mail-header-xref headers)
5402 (not (string= (mail-header-xref headers) "")))
5403 (let ((case-fold-search t)
5406 (nnheader-narrow-to-headers)
5407 (goto-char (point-min))
5408 (when (or (and (not (eobp))
5409 (eq (downcase (char-after)) ?x)
5410 (looking-at "Xref:"))
5411 (search-forward "\nXref:" nil t))
5412 (goto-char (1+ (match-end 0)))
5413 (setq xref (buffer-substring (point)
5414 (progn (end-of-line) (point))))
5415 (mail-header-set-xref headers xref)))))))
5417 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5418 "Find article ID and insert the summary line for that article.
5419 OLD-HEADER can either be a header or a line number to insert
5420 the subject line on."
5421 (let* ((line (and (numberp old-header) old-header))
5422 (old-header (and (vectorp old-header) old-header))
5423 (header (cond ((and old-header use-old-header)
5426 (gnus-number-to-header id))
5427 (gnus-number-to-header id))
5429 (gnus-read-header id))))
5430 (number (and (numberp id) id))
5433 ;; Rebuild the thread that this article is part of and go to the
5434 ;; article we have fetched.
5435 (when (and (not gnus-show-threads)
5438 (setq d (gnus-data-find (mail-header-number old-header))))
5439 (goto-char (gnus-data-pos d))
5442 (- (gnus-point-at-bol)
5444 (1+ (gnus-point-at-eol))
5445 (gnus-delete-line))))))
5447 (mail-header-set-number header (mail-header-number old-header)))
5448 (setq gnus-newsgroup-sparse
5449 (delq (setq number (mail-header-number header))
5450 gnus-newsgroup-sparse))
5451 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5452 (push number gnus-newsgroup-limit)
5453 (gnus-rebuild-thread (mail-header-id header) line)
5454 (gnus-summary-goto-subject number nil t))
5455 (when (and (numberp number)
5457 ;; We have to update the boundaries even if we can't fetch the
5458 ;; article if ID is a number -- so that the next `P' or `N'
5459 ;; command will fetch the previous (or next) article even
5460 ;; if the one we tried to fetch this time has been canceled.
5461 (when (> number gnus-newsgroup-end)
5462 (setq gnus-newsgroup-end number))
5463 (when (< number gnus-newsgroup-begin)
5464 (setq gnus-newsgroup-begin number))
5465 (setq gnus-newsgroup-unselected
5466 (delq number gnus-newsgroup-unselected)))
5467 ;; Report back a success?
5468 (and header (mail-header-number header))))
5470 ;;; Process/prefix in the summary buffer
5472 (defun gnus-summary-work-articles (n)
5473 "Return a list of articles to be worked upon.
5474 The prefix argument, the list of process marked articles, and the
5475 current article will be taken into consideration."
5477 (set-buffer gnus-summary-buffer)
5480 ;; A numerical prefix has been given.
5481 (setq n (prefix-numeric-value n))
5482 (let ((backward (< n 0))
5483 (n (abs (prefix-numeric-value n)))
5488 (push (setq article (gnus-summary-article-number))
5491 (gnus-summary-find-prev nil article)
5492 (gnus-summary-find-next nil article)))
5494 (nreverse articles)))
5495 ((and (gnus-region-active-p) (mark))
5496 (message "region active")
5497 ;; Work on the region between point and mark.
5498 (let ((max (max (point) (mark)))
5501 (goto-char (min (point) (mark)))
5504 (push (setq article (gnus-summary-article-number)) articles)
5505 (gnus-summary-find-next nil article)
5507 (nreverse articles))))
5508 (gnus-newsgroup-processable
5509 ;; There are process-marked articles present.
5510 ;; Save current state.
5511 (gnus-summary-save-process-mark)
5513 (reverse gnus-newsgroup-processable))
5515 ;; Just return the current article.
5516 (list (gnus-summary-article-number))))))
5518 (defmacro gnus-summary-iterate (arg &rest forms)
5519 "Iterate over the process/prefixed articles and do FORMS.
5520 ARG is the interactive prefix given to the command. FORMS will be
5521 executed with point over the summary line of the articles."
5522 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5523 `(let ((,articles (gnus-summary-work-articles ,arg)))
5525 (gnus-summary-goto-subject (car ,articles))
5529 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5530 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5532 (defun gnus-summary-save-process-mark ()
5533 "Push the current set of process marked articles on the stack."
5535 (push (copy-sequence gnus-newsgroup-processable)
5536 gnus-newsgroup-process-stack))
5538 (defun gnus-summary-kill-process-mark ()
5539 "Push the current set of process marked articles on the stack and unmark."
5541 (gnus-summary-save-process-mark)
5542 (gnus-summary-unmark-all-processable))
5544 (defun gnus-summary-yank-process-mark ()
5545 "Pop the last process mark state off the stack and restore it."
5547 (unless gnus-newsgroup-process-stack
5548 (error "Empty mark stack"))
5549 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5551 (defun gnus-summary-process-mark-set (set)
5552 "Make SET into the current process marked articles."
5553 (gnus-summary-unmark-all-processable)
5555 (gnus-summary-set-process-mark (pop set))))
5557 ;;; Searching and stuff
5559 (defun gnus-summary-search-group (&optional backward use-level)
5560 "Search for next unread newsgroup.
5561 If optional argument BACKWARD is non-nil, search backward instead."
5563 (set-buffer gnus-group-buffer)
5564 (when (gnus-group-search-forward
5565 backward nil (if use-level (gnus-group-group-level) nil))
5566 (gnus-group-group-name))))
5568 (defun gnus-summary-best-group (&optional exclude-group)
5569 "Find the name of the best unread group.
5570 If EXCLUDE-GROUP, do not go to this group."
5572 (set-buffer gnus-group-buffer)
5574 (gnus-group-best-unread-group exclude-group))))
5576 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5577 (if backward (gnus-summary-find-prev)
5578 (let* ((dummy (gnus-summary-article-intangible-p))
5579 (article (or article (gnus-summary-article-number)))
5580 (arts (gnus-data-find-list article))
5582 (when (and (not dummy)
5583 (or (not gnus-summary-check-current)
5585 (not (gnus-data-unread-p (car arts)))))
5586 (setq arts (cdr arts)))
5591 (when (or (and undownloaded
5592 (eq gnus-undownloaded-mark
5593 (gnus-data-mark (car arts))))
5594 (gnus-data-unread-p (car arts)))
5595 (setq result (car arts)
5597 (setq arts (cdr arts)))
5600 (goto-char (gnus-data-pos result))
5601 (gnus-data-number result)))))
5603 (defun gnus-summary-find-prev (&optional unread article)
5604 (let* ((eobp (eobp))
5605 (article (or article (gnus-summary-article-number)))
5606 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5608 (when (and (not eobp)
5609 (or (not gnus-summary-check-current)
5611 (not (gnus-data-unread-p (car arts)))))
5612 (setq arts (cdr arts)))
5617 (when (gnus-data-unread-p (car arts))
5618 (setq result (car arts)
5620 (setq arts (cdr arts)))
5623 (goto-char (gnus-data-pos result))
5624 (gnus-data-number result))))
5626 (defun gnus-summary-find-subject (subject &optional unread backward article)
5627 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5628 (article (or article (gnus-summary-article-number)))
5629 (articles (gnus-data-list backward))
5630 (arts (gnus-data-find-list article articles))
5632 (when (or (not gnus-summary-check-current)
5634 (not (gnus-data-unread-p (car arts))))
5635 (setq arts (cdr arts)))
5637 (and (or (not unread)
5638 (gnus-data-unread-p (car arts)))
5639 (vectorp (gnus-data-header (car arts)))
5641 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5642 (setq result (car arts)
5644 (setq arts (cdr arts)))
5646 (goto-char (gnus-data-pos result))
5647 (gnus-data-number result))))
5649 (defun gnus-summary-search-forward (&optional unread subject backward)
5650 "Search forward for an article.
5651 If UNREAD, look for unread articles. If SUBJECT, look for
5652 articles with that subject. If BACKWARD, search backward instead."
5653 (cond (subject (gnus-summary-find-subject subject unread backward))
5654 (backward (gnus-summary-find-prev unread))
5655 (t (gnus-summary-find-next unread))))
5657 (defun gnus-recenter (&optional n)
5658 "Center point in window and redisplay frame.
5659 Also do horizontal recentering."
5661 (when (and gnus-auto-center-summary
5662 (not (eq gnus-auto-center-summary 'vertical)))
5663 (gnus-horizontal-recenter))
5666 (defun gnus-summary-recenter ()
5667 "Center point in the summary window.
5668 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5669 displayed, no centering will be performed."
5670 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5671 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5673 (let* ((top (cond ((< (window-height) 4) 0)
5674 ((< (window-height) 7) 1)
5675 (t (if (numberp gnus-auto-center-summary)
5676 gnus-auto-center-summary
5678 (height (1- (window-height)))
5679 (bottom (save-excursion (goto-char (point-max))
5680 (forward-line (- height))
5682 (window (get-buffer-window (current-buffer))))
5683 ;; The user has to want it.
5684 (when gnus-auto-center-summary
5685 (when (get-buffer-window gnus-article-buffer)
5686 ;; Only do recentering when the article buffer is displayed,
5687 ;; Set the window start to either `bottom', which is the biggest
5688 ;; possible valid number, or the second line from the top,
5689 ;; whichever is the least.
5690 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5691 (if (> bottom top-pos)
5692 ;; Keep the second line from the top visible
5693 (set-window-start window top-pos t)
5694 ;; Try to keep the bottom line visible; if it's partially
5695 ;; obscured, either scroll one more line to make it fully
5696 ;; visible, or revert to using TOP-POS.
5698 (goto-char (point-max))
5700 (let ((last-line-start (point)))
5702 (set-window-start window (point) t)
5703 (when (not (pos-visible-in-window-p last-line-start window))
5705 (set-window-start window (min (point) top-pos) t)))))))
5706 ;; Do horizontal recentering while we're at it.
5707 (when (and (get-buffer-window (current-buffer) t)
5708 (not (eq gnus-auto-center-summary 'vertical)))
5709 (let ((selected (selected-window)))
5710 (select-window (get-buffer-window (current-buffer) t))
5711 (gnus-summary-position-point)
5712 (gnus-horizontal-recenter)
5713 (select-window selected))))))
5715 (defun gnus-summary-jump-to-group (newsgroup)
5716 "Move point to NEWSGROUP in group mode buffer."
5717 ;; Keep update point of group mode buffer if visible.
5718 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5719 (save-window-excursion
5720 ;; Take care of tree window mode.
5721 (when (get-buffer-window gnus-group-buffer)
5722 (pop-to-buffer gnus-group-buffer))
5723 (gnus-group-jump-to-group newsgroup))
5725 ;; Take care of tree window mode.
5726 (if (get-buffer-window gnus-group-buffer)
5727 (pop-to-buffer gnus-group-buffer)
5728 (set-buffer gnus-group-buffer))
5729 (gnus-group-jump-to-group newsgroup))))
5731 ;; This function returns a list of article numbers based on the
5732 ;; difference between the ranges of read articles in this group and
5733 ;; the range of active articles.
5734 (defun gnus-list-of-unread-articles (group)
5735 (let* ((read (gnus-info-read (gnus-get-info group)))
5736 (active (or (gnus-active group) (gnus-activate-group group)))
5739 ;; If none are read, then all are unread.
5741 (setq first (car active))
5742 ;; If the range of read articles is a single range, then the
5743 ;; first unread article is the article after the last read
5744 ;; article. Sounds logical, doesn't it?
5745 (if (and (not (listp (cdr read)))
5746 (or (< (car read) (car active))
5747 (progn (setq read (list read))
5749 (setq first (max (car active) (1+ (cdr read))))
5750 ;; `read' is a list of ranges.
5751 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5754 (setq first (car active)))
5757 (while (< first nlast)
5759 (setq first (1+ first))))
5760 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5761 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5762 (setq read (cdr read)))))
5763 ;; And add the last unread articles.
5764 (while (<= first last)
5766 (setq first (1+ first)))
5767 ;; Return the list of unread articles.
5768 (delq 0 (nreverse unread))))
5770 (defun gnus-list-of-read-articles (group)
5771 "Return a list of unread, unticked and non-dormant articles."
5772 (let* ((info (gnus-get-info group))
5773 (marked (gnus-info-marks info))
5774 (active (gnus-active group)))
5776 (gnus-set-difference
5777 (gnus-sorted-complement
5778 (gnus-uncompress-range active)
5779 (gnus-list-of-unread-articles group))
5781 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5782 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5784 ;; Various summary commands
5786 (defun gnus-summary-select-article-buffer ()
5787 "Reconfigure windows to show article buffer."
5789 (if (not (gnus-buffer-live-p gnus-article-buffer))
5790 (error "There is no article buffer for this summary buffer")
5791 (gnus-configure-windows 'article)
5792 (select-window (get-buffer-window gnus-article-buffer))))
5794 (defun gnus-summary-universal-argument (arg)
5795 "Perform any operation on all articles that are process/prefixed."
5797 (let ((articles (gnus-summary-work-articles arg))
5804 (substitute-command-keys
5805 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5807 (gnus-error 1 "Undefined key")
5810 (gnus-summary-goto-subject (setq article (pop articles)))
5811 (let (gnus-newsgroup-processable)
5812 (command-execute func))
5813 (gnus-summary-remove-process-mark article)))))
5814 (gnus-summary-position-point))
5816 (defun gnus-summary-toggle-truncation (&optional arg)
5817 "Toggle truncation of summary lines.
5818 With arg, turn line truncation on iff arg is positive."
5820 (setq truncate-lines
5821 (if (null arg) (not truncate-lines)
5822 (> (prefix-numeric-value arg) 0)))
5825 (defun gnus-summary-reselect-current-group (&optional all rescan)
5826 "Exit and then reselect the current newsgroup.
5827 The prefix argument ALL means to select all articles."
5829 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5830 (error "Ephemeral groups can't be reselected"))
5831 (let ((current-subject (gnus-summary-article-number))
5832 (group gnus-newsgroup-name))
5833 (setq gnus-newsgroup-begin nil)
5835 ;; We have to adjust the point of group mode buffer because
5836 ;; point was moved to the next unread newsgroup by exiting.
5837 (gnus-summary-jump-to-group group)
5840 (save-window-excursion
5841 ;; Don't show group contents.
5842 (set-window-start (selected-window) (point-max))
5843 (gnus-group-get-new-news-this-group 1))))
5844 (gnus-group-read-group all t)
5845 (gnus-summary-goto-subject current-subject nil t)))
5847 (defun gnus-summary-rescan-group (&optional all)
5848 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5850 (gnus-summary-reselect-current-group all t))
5852 (defun gnus-summary-update-info (&optional non-destructive)
5854 (let ((group gnus-newsgroup-name))
5856 (when gnus-newsgroup-kill-headers
5857 (setq gnus-newsgroup-killed
5858 (gnus-compress-sequence
5860 (gnus-set-sorted-intersection
5861 (gnus-uncompress-range gnus-newsgroup-killed)
5862 (setq gnus-newsgroup-unselected
5863 (sort gnus-newsgroup-unselected '<)))
5864 (setq gnus-newsgroup-unreads
5865 (sort gnus-newsgroup-unreads '<)))
5867 (unless (listp (cdr gnus-newsgroup-killed))
5868 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5869 (let ((headers gnus-newsgroup-headers))
5870 ;; Set the new ranges of read articles.
5872 (set-buffer gnus-group-buffer)
5873 (gnus-undo-force-boundary))
5874 (gnus-update-read-articles
5875 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5876 ;; Set the current article marks.
5877 (let ((gnus-newsgroup-scored
5878 (if (and (not gnus-save-score)
5879 (not non-destructive))
5881 gnus-newsgroup-scored)))
5883 (gnus-update-marks)))
5884 ;; Do the cross-ref thing.
5885 (when gnus-use-cross-reference
5886 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5887 ;; Do not switch windows but change the buffer to work.
5888 (set-buffer gnus-group-buffer)
5889 (unless (gnus-ephemeral-group-p group)
5890 (gnus-group-update-group group)))))))
5892 (defun gnus-summary-save-newsrc (&optional force)
5893 "Save the current number of read/marked articles in the dribble buffer.
5894 The dribble buffer will then be saved.
5895 If FORCE (the prefix), also save the .newsrc file(s)."
5897 (gnus-summary-update-info t)
5899 (gnus-save-newsrc-file)
5900 (gnus-dribble-save)))
5902 (defun gnus-summary-exit (&optional temporary)
5903 "Exit reading current newsgroup, and then return to group selection mode.
5904 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5906 (gnus-set-global-variables)
5907 (gnus-kill-save-kill-buffer)
5908 (gnus-async-halt-prefetch)
5909 (let* ((group gnus-newsgroup-name)
5910 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5913 (buf (current-buffer)))
5915 ;; Do adaptive scoring, and possibly save score files.
5916 (when gnus-newsgroup-adaptive
5917 (gnus-score-adaptive))
5918 (when gnus-use-scoring
5920 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5921 ;; If we have several article buffers, we kill them at exit.
5922 (unless gnus-single-article-buffer
5923 (gnus-kill-buffer gnus-original-article-buffer)
5924 (setq gnus-article-current nil))
5925 (when gnus-use-cache
5926 (gnus-cache-possibly-remove-articles)
5927 (gnus-cache-save-buffers))
5928 (gnus-async-prefetch-remove-group group)
5929 (when gnus-suppress-duplicates
5930 (gnus-dup-enter-articles))
5931 (when gnus-use-trees
5932 (gnus-tree-close group))
5933 (when gnus-use-cache
5934 (gnus-cache-write-active))
5935 ;; Remove entries for this group.
5936 (nnmail-purge-split-history (gnus-group-real-name group))
5937 ;; Make all changes in this group permanent.
5939 (gnus-run-hooks 'gnus-exit-group-hook)
5940 (gnus-summary-update-info))
5941 (gnus-close-group group)
5942 ;; Make sure where we were, and go to next newsgroup.
5943 (set-buffer gnus-group-buffer)
5945 (gnus-group-jump-to-group group))
5946 (gnus-run-hooks 'gnus-summary-exit-hook)
5947 (unless (or quit-config
5948 ;; If this group has disappeared from the summary
5949 ;; buffer, don't skip forwards.
5950 (not (string= group (gnus-group-group-name))))
5951 (gnus-group-next-unread-group 1))
5952 (setq group-point (point))
5955 ;; If we have several article buffers, we kill them at exit.
5956 (unless gnus-single-article-buffer
5957 (gnus-kill-buffer gnus-article-buffer)
5958 (gnus-kill-buffer gnus-original-article-buffer)
5959 (setq gnus-article-current nil))
5961 (if (not gnus-kill-summary-on-exit)
5963 (gnus-deaden-summary)
5965 ;; We set all buffer-local variables to nil. It is unclear why
5966 ;; this is needed, but if we don't, buffer-local variables are
5967 ;; not garbage-collected, it seems. This would the lead to en
5968 ;; ever-growing Emacs.
5969 (gnus-summary-clear-local-variables)
5970 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5971 (gnus-summary-clear-local-variables))
5972 (when (get-buffer gnus-article-buffer)
5973 (bury-buffer gnus-article-buffer))
5974 ;; We clear the global counterparts of the buffer-local
5975 ;; variables as well, just to be on the safe side.
5976 (set-buffer gnus-group-buffer)
5977 (gnus-summary-clear-local-variables)
5978 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5979 (gnus-summary-clear-local-variables)))
5980 (setq gnus-current-select-method gnus-select-method)
5981 (pop-to-buffer gnus-group-buffer)
5982 (if (not quit-config)
5984 (goto-char group-point)
5985 (gnus-configure-windows 'group 'force)
5986 (unless (pos-visible-in-window-p)
5987 (forward-line (/ (static-if (featurep 'xemacs)
5988 (window-displayed-height)
5989 (1- (window-height)))
5991 (set-window-start (selected-window) (point))
5992 (goto-char group-point)))
5993 (gnus-handle-ephemeral-exit quit-config))
5994 ;; Return to group mode buffer.
5995 (when (eq mode 'gnus-summary-mode)
5996 (gnus-kill-buffer buf))
5997 ;; Clear the current group name.
5999 (setq gnus-newsgroup-name nil)))))
6001 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6002 (defun gnus-summary-exit-no-update (&optional no-questions)
6003 "Quit reading current newsgroup without updating read article info."
6005 (let* ((group gnus-newsgroup-name)
6006 (quit-config (gnus-group-quit-config group)))
6007 (when (or no-questions
6009 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6010 (gnus-async-halt-prefetch)
6012 (delq 'gnus-summary-expire-articles
6013 (copy-sequence gnus-summary-prepare-exit-hook)))
6014 ;; If we have several article buffers, we kill them at exit.
6015 (unless gnus-single-article-buffer
6016 (gnus-kill-buffer gnus-article-buffer)
6017 (gnus-kill-buffer gnus-original-article-buffer)
6018 (setq gnus-article-current nil))
6019 (if (not gnus-kill-summary-on-exit)
6020 (gnus-deaden-summary)
6021 (gnus-close-group group)
6022 (gnus-summary-clear-local-variables)
6023 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6024 (gnus-summary-clear-local-variables))
6025 (set-buffer gnus-group-buffer)
6026 (gnus-summary-clear-local-variables)
6027 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6028 (gnus-summary-clear-local-variables))
6029 (when (get-buffer gnus-summary-buffer)
6030 (kill-buffer gnus-summary-buffer)))
6031 (unless gnus-single-article-buffer
6032 (setq gnus-article-current nil))
6033 (when gnus-use-trees
6034 (gnus-tree-close group))
6035 (gnus-async-prefetch-remove-group group)
6036 (when (get-buffer gnus-article-buffer)
6037 (bury-buffer gnus-article-buffer))
6038 ;; Return to the group buffer.
6039 (gnus-configure-windows 'group 'force)
6040 ;; Clear the current group name.
6041 (setq gnus-newsgroup-name nil)
6042 (when (equal (gnus-group-group-name) group)
6043 (gnus-group-next-unread-group 1))
6045 (gnus-handle-ephemeral-exit quit-config)))))
6047 (defun gnus-handle-ephemeral-exit (quit-config)
6048 "Handle movement when leaving an ephemeral group.
6049 The state which existed when entering the ephemeral is reset."
6050 (if (not (buffer-name (car quit-config)))
6051 (gnus-configure-windows 'group 'force)
6052 (set-buffer (car quit-config))
6053 (cond ((eq major-mode 'gnus-summary-mode)
6054 (gnus-set-global-variables))
6055 ((eq major-mode 'gnus-article-mode)
6057 ;; The `gnus-summary-buffer' variable may point
6058 ;; to the old summary buffer when using a single
6060 (unless (gnus-buffer-live-p gnus-summary-buffer)
6061 (set-buffer gnus-group-buffer))
6062 (set-buffer gnus-summary-buffer)
6063 (gnus-set-global-variables))))
6064 (if (or (eq (cdr quit-config) 'article)
6065 (eq (cdr quit-config) 'pick))
6067 ;; The current article may be from the ephemeral group
6068 ;; thus it is best that we reload this article
6069 (gnus-summary-show-article)
6070 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6071 (gnus-configure-windows 'pick 'force)
6072 (gnus-configure-windows (cdr quit-config) 'force)))
6073 (gnus-configure-windows (cdr quit-config) 'force))
6074 (when (eq major-mode 'gnus-summary-mode)
6075 (gnus-summary-next-subject 1 nil t)
6076 (gnus-summary-recenter)
6077 (gnus-summary-position-point))))
6079 (defun gnus-summary-preview-mime-message ()
6080 "MIME decode and play this message."
6082 (let ((gnus-break-pages nil)
6084 (gnus-summary-select-article gnus-show-all-headers t))
6085 (select-window (get-buffer-window gnus-article-buffer)))
6089 (defvar gnus-dead-summary-mode-map nil)
6091 (unless gnus-dead-summary-mode-map
6092 (setq gnus-dead-summary-mode-map (make-keymap))
6093 (suppress-keymap gnus-dead-summary-mode-map)
6094 (substitute-key-definition
6095 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6096 (let ((keys '("\C-d" "\r" "\177" [delete])))
6098 (define-key gnus-dead-summary-mode-map
6099 (pop keys) 'gnus-summary-wake-up-the-dead))))
6101 (defvar gnus-dead-summary-mode nil
6102 "Minor mode for Gnus summary buffers.")
6104 (defun gnus-dead-summary-mode (&optional arg)
6105 "Minor mode for Gnus summary buffers."
6107 (when (eq major-mode 'gnus-summary-mode)
6108 (make-local-variable 'gnus-dead-summary-mode)
6109 (setq gnus-dead-summary-mode
6110 (if (null arg) (not gnus-dead-summary-mode)
6111 (> (prefix-numeric-value arg) 0)))
6112 (when gnus-dead-summary-mode
6113 (gnus-add-minor-mode
6114 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6116 (defun gnus-deaden-summary ()
6117 "Make the current summary buffer into a dead summary buffer."
6118 ;; Kill any previous dead summary buffer.
6119 (when (and gnus-dead-summary
6120 (buffer-name gnus-dead-summary))
6122 (set-buffer gnus-dead-summary)
6123 (when gnus-dead-summary-mode
6124 (kill-buffer (current-buffer)))))
6125 ;; Make this the current dead summary.
6126 (setq gnus-dead-summary (current-buffer))
6127 (gnus-dead-summary-mode 1)
6128 (let ((name (buffer-name)))
6129 (when (string-match "Summary" name)
6131 (concat (substring name 0 (match-beginning 0)) "Dead "
6132 (substring name (match-beginning 0)))
6136 (defun gnus-kill-or-deaden-summary (buffer)
6137 "Kill or deaden the summary BUFFER."
6139 (when (and (buffer-name buffer)
6140 (not gnus-single-article-buffer))
6143 (gnus-kill-buffer gnus-article-buffer)
6144 (gnus-kill-buffer gnus-original-article-buffer)))
6145 (cond (gnus-kill-summary-on-exit
6146 (when (and gnus-use-trees
6147 (gnus-buffer-exists-p buffer))
6150 (gnus-tree-close gnus-newsgroup-name)))
6151 (gnus-kill-buffer buffer))
6152 ((gnus-buffer-exists-p buffer)
6155 (gnus-deaden-summary))))))
6157 (defun gnus-summary-wake-up-the-dead (&rest args)
6158 "Wake up the dead summary buffer."
6160 (gnus-dead-summary-mode -1)
6161 (let ((name (buffer-name)))
6162 (when (string-match "Dead " name)
6164 (concat (substring name 0 (match-beginning 0))
6165 (substring name (match-end 0)))
6167 (gnus-message 3 "This dead summary is now alive again"))
6169 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6170 (defun gnus-summary-fetch-faq (&optional faq-dir)
6171 "Fetch the FAQ for the current group.
6172 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6176 (when current-prefix-arg
6178 "Faq dir: " (and (listp gnus-group-faq-directory)
6179 (mapcar (lambda (file) (list file))
6180 gnus-group-faq-directory))))))
6181 (let (gnus-faq-buffer)
6182 (when (setq gnus-faq-buffer
6183 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6184 (gnus-configure-windows 'summary-faq))))
6186 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6187 (defun gnus-summary-describe-group (&optional force)
6188 "Describe the current newsgroup."
6190 (gnus-group-describe-group force gnus-newsgroup-name))
6192 (defun gnus-summary-describe-briefly ()
6193 "Describe summary mode commands briefly."
6195 (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")))
6197 ;; Walking around group mode buffer from summary mode.
6199 (defun gnus-summary-next-group (&optional no-article target-group backward)
6200 "Exit current newsgroup and then select next unread newsgroup.
6201 If prefix argument NO-ARTICLE is non-nil, no article is selected
6202 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6203 previous group instead."
6205 ;; Stop pre-fetching.
6206 (gnus-async-halt-prefetch)
6207 (let ((current-group gnus-newsgroup-name)
6208 (current-buffer (current-buffer))
6210 ;; First we semi-exit this group to update Xrefs and all variables.
6211 ;; We can't do a real exit, because the window conf must remain
6212 ;; the same in case the user is prompted for info, and we don't
6213 ;; want the window conf to change before that...
6214 (gnus-summary-exit t)
6215 (while (not entered)
6216 ;; Then we find what group we are supposed to enter.
6217 (set-buffer gnus-group-buffer)
6218 (gnus-group-jump-to-group current-group)
6221 (if (eq gnus-keep-same-level 'best)
6222 (gnus-summary-best-group gnus-newsgroup-name)
6223 (gnus-summary-search-group backward gnus-keep-same-level))))
6224 (if (not target-group)
6225 ;; There are no further groups, so we return to the group
6228 (gnus-message 5 "Returning to the group buffer")
6230 (when (gnus-buffer-live-p current-buffer)
6231 (set-buffer current-buffer)
6232 (gnus-summary-exit))
6233 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6234 ;; We try to enter the target group.
6235 (gnus-group-jump-to-group target-group)
6236 (let ((unreads (gnus-group-group-unread)))
6237 (if (and (or (eq t unreads)
6238 (and unreads (not (zerop unreads))))
6239 (gnus-summary-read-group
6240 target-group nil no-article
6241 (and (buffer-name current-buffer) current-buffer)
6244 (setq current-group target-group
6245 target-group nil)))))))
6247 (defun gnus-summary-prev-group (&optional no-article)
6248 "Exit current newsgroup and then select previous unread newsgroup.
6249 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6251 (gnus-summary-next-group no-article nil t))
6253 ;; Walking around summary lines.
6255 (defun gnus-summary-first-subject (&optional unread undownloaded)
6256 "Go to the first unread subject.
6257 If UNREAD is non-nil, go to the first unread article.
6258 Returns the article selected or nil if there are no unread articles."
6263 ((null gnus-newsgroup-data)
6264 (gnus-message 3 "No articles in the group")
6266 ;; Pick the first article.
6268 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6269 (gnus-data-number (car gnus-newsgroup-data)))
6270 ;; No unread articles.
6271 ((null gnus-newsgroup-unreads)
6272 (gnus-message 3 "No more unread articles")
6274 ;; Find the first unread article.
6276 (let ((data gnus-newsgroup-data))
6278 (and (not (and undownloaded
6279 (eq gnus-undownloaded-mark
6280 (gnus-data-mark (car data)))))
6281 (not (gnus-data-unread-p (car data)))))
6282 (setq data (cdr data)))
6284 (goto-char (gnus-data-pos (car data)))
6285 (gnus-data-number (car data))))))
6286 (gnus-summary-position-point)))
6288 (defun gnus-summary-next-subject (n &optional unread dont-display)
6289 "Go to next N'th summary line.
6290 If N is negative, go to the previous N'th subject line.
6291 If UNREAD is non-nil, only unread articles are selected.
6292 The difference between N and the actual number of steps taken is
6295 (let ((backward (< n 0))
6299 (gnus-summary-find-prev unread)
6300 (gnus-summary-find-next unread)))
6301 (unless (zerop (setq n (1- n)))
6302 (gnus-summary-show-thread)))
6304 (gnus-message 7 "No more%s articles"
6305 (if unread " unread" "")))
6306 (unless dont-display
6307 (gnus-summary-recenter)
6308 (gnus-summary-position-point))
6311 (defun gnus-summary-next-unread-subject (n)
6312 "Go to next N'th unread summary line."
6314 (gnus-summary-next-subject n t))
6316 (defun gnus-summary-prev-subject (n &optional unread)
6317 "Go to previous N'th summary line.
6318 If optional argument UNREAD is non-nil, only unread article is selected."
6320 (gnus-summary-next-subject (- n) unread))
6322 (defun gnus-summary-prev-unread-subject (n)
6323 "Go to previous N'th unread summary line."
6325 (gnus-summary-next-subject (- n) t))
6327 (defun gnus-summary-goto-subject (article &optional force silent)
6328 "Go the subject line of ARTICLE.
6329 If FORCE, also allow jumping to articles not currently shown."
6330 (interactive "nArticle number: ")
6332 (data (gnus-data-find article)))
6333 ;; We read in the article if we have to.
6336 (gnus-summary-insert-subject
6338 (if (or (numberp force) (vectorp force)) force)
6340 (setq data (gnus-data-find article)))
6345 (gnus-message 3 "Can't find article %d" article))
6347 (let ((pt (gnus-data-pos data)))
6349 (gnus-summary-set-article-display-arrow pt))
6350 (gnus-summary-position-point)
6353 ;; Walking around summary lines with displaying articles.
6355 (defun gnus-summary-expand-window (&optional arg)
6356 "Make the summary buffer take up the entire Emacs frame.
6357 Given a prefix, will force an `article' buffer configuration."
6360 (gnus-configure-windows 'article 'force)
6361 (gnus-configure-windows 'summary 'force)))
6363 (defun gnus-summary-display-article (article &optional all-header)
6364 "Display ARTICLE in article buffer."
6365 (when (gnus-buffer-live-p gnus-article-buffer)
6366 (with-current-buffer gnus-article-buffer
6367 (set-buffer-multibyte t)))
6368 (gnus-set-global-variables)
6369 (when (gnus-buffer-live-p gnus-article-buffer)
6370 (with-current-buffer gnus-article-buffer
6371 (setq gnus-article-charset gnus-newsgroup-charset)
6372 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6376 (if gnus-summary-display-article-function
6377 (funcall gnus-summary-display-article-function article all-header)
6378 (gnus-article-prepare article all-header))
6379 (with-current-buffer gnus-article-buffer
6380 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6382 (gnus-run-hooks 'gnus-select-article-hook)
6383 (when (and gnus-current-article
6384 (not (zerop gnus-current-article)))
6385 (gnus-summary-goto-subject gnus-current-article))
6386 (gnus-summary-recenter)
6387 (when (and gnus-use-trees gnus-show-threads)
6388 (gnus-possibly-generate-tree article)
6389 (gnus-highlight-selected-tree article))
6390 ;; Successfully display article.
6391 (gnus-article-set-window-start
6392 (cdr (assq article gnus-newsgroup-bookmarks))))))
6394 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6395 "Select the current article.
6396 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6397 non-nil, the article will be re-fetched even if it already present in
6398 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6400 ;; Make sure we are in the summary buffer to work around bbdb bug.
6401 (unless (eq major-mode 'gnus-summary-mode)
6402 (set-buffer gnus-summary-buffer))
6403 (let ((article (or article (gnus-summary-article-number)))
6404 (all-headers (not (not all-headers))) ;Must be T or NIL.
6405 gnus-summary-display-article-function)
6407 (gnus-summary-article-pseudo-p article)
6408 (error "This is a pseudo-article"))
6410 (set-buffer gnus-summary-buffer)
6411 (if (or (and gnus-single-article-buffer
6412 (or (null gnus-current-article)
6413 (null gnus-article-current)
6414 (null (get-buffer gnus-article-buffer))
6415 (not (eq article (cdr gnus-article-current)))
6416 (not (equal (car gnus-article-current)
6417 gnus-newsgroup-name))))
6418 (and (not gnus-single-article-buffer)
6419 (or (null gnus-current-article)
6420 (not (eq gnus-current-article article))))
6422 ;; The requested article is different from the current article.
6424 (gnus-summary-display-article article all-headers)
6425 (when (or all-headers gnus-show-all-headers)
6426 (gnus-article-show-all-headers))
6427 (gnus-article-set-window-start
6428 (cdr (assq article gnus-newsgroup-bookmarks)))
6430 (when (or all-headers gnus-show-all-headers)
6431 (gnus-article-show-all-headers))
6434 (defun gnus-summary-force-verify-and-decrypt ()
6436 (let ((mm-verify-option 'known)
6437 (mm-decrypt-option 'known))
6438 (gnus-summary-select-article nil 'force)))
6440 (defun gnus-summary-set-current-mark (&optional current-mark)
6441 "Obsolete function."
6444 (defun gnus-summary-next-article (&optional unread subject backward push)
6445 "Select the next article.
6446 If UNREAD, only unread articles are selected.
6447 If SUBJECT, only articles with SUBJECT are selected.
6448 If BACKWARD, the previous article is selected instead of the next."
6451 ;; Is there such an article?
6452 ((and (gnus-summary-search-forward unread subject backward)
6453 (or (gnus-summary-display-article (gnus-summary-article-number))
6454 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6455 (gnus-summary-position-point))
6456 ;; If not, we try the first unread, if that is wanted.
6458 gnus-auto-select-same
6459 (gnus-summary-first-unread-article))
6460 (gnus-summary-position-point)
6461 (gnus-message 6 "Wrapped"))
6462 ;; Try to get next/previous article not displayed in this group.
6463 ((and gnus-auto-extend-newsgroup
6464 (not unread) (not subject))
6465 (gnus-summary-goto-article
6466 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6467 nil (count-lines (point-min) (point))))
6468 ;; Go to next/previous group.
6470 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6471 (gnus-summary-jump-to-group gnus-newsgroup-name))
6472 (let ((cmd last-command-char)
6475 (set-buffer gnus-group-buffer)
6478 (if (eq gnus-keep-same-level 'best)
6479 (gnus-summary-best-group gnus-newsgroup-name)
6480 (gnus-summary-search-group backward gnus-keep-same-level))))
6481 ;; For some reason, the group window gets selected. We change
6483 (select-window (get-buffer-window (current-buffer)))
6484 ;; Select next unread newsgroup automagically.
6486 ((or (not gnus-auto-select-next)
6488 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6489 ((or (eq gnus-auto-select-next 'quietly)
6490 (and (eq gnus-auto-select-next 'slightly-quietly)
6492 (and (eq gnus-auto-select-next 'almost-quietly)
6493 (gnus-summary-last-article-p)))
6495 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6497 (gnus-message 7 "No more%s articles (%s)..."
6498 (if unread " unread" "")
6499 (if group (concat "selecting " group)
6501 (gnus-summary-next-group nil group backward)))
6503 (when (gnus-key-press-event-p last-input-event)
6504 (gnus-summary-walk-group-buffer
6505 gnus-newsgroup-name cmd unread backward point))))))))
6507 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6508 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6509 (?\C-p (gnus-group-prev-unread-group 1))))
6510 (cursor-in-echo-area t)
6511 keve key group ended)
6513 (set-buffer gnus-group-buffer)
6516 (if (eq gnus-keep-same-level 'best)
6517 (gnus-summary-best-group gnus-newsgroup-name)
6518 (gnus-summary-search-group backward gnus-keep-same-level))))
6521 5 "No more%s articles%s" (if unread " unread" "")
6523 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6524 (format " (Type %s for %s [%s])"
6525 (single-key-description cmd) group
6526 (car (gnus-gethash group gnus-newsrc-hashtb)))
6527 (format " (Type %s to exit %s)"
6528 (single-key-description cmd)
6529 gnus-newsgroup-name)))
6530 ;; Confirm auto selection.
6531 (setq key (car (setq keve (gnus-read-event-char))))
6534 ((assq key keystrokes)
6535 (let ((obuf (current-buffer)))
6536 (switch-to-buffer gnus-group-buffer)
6538 (gnus-group-jump-to-group group))
6539 (eval (cadr (assq key keystrokes)))
6540 (setq group (gnus-group-group-name))
6541 (switch-to-buffer obuf))
6545 (gnus-ephemeral-group-p gnus-newsgroup-name))
6547 (gnus-summary-next-group nil group backward)))
6549 (push (cdr keve) unread-command-events))))))
6551 (defun gnus-summary-next-unread-article ()
6552 "Select unread article after current one."
6554 (gnus-summary-next-article
6555 (or (not (eq gnus-summary-goto-unread 'never))
6556 (gnus-summary-last-article-p (gnus-summary-article-number)))
6557 (and gnus-auto-select-same
6558 (gnus-summary-article-subject))))
6560 (defun gnus-summary-prev-article (&optional unread subject)
6561 "Select the article after the current one.
6562 If UNREAD is non-nil, only unread articles are selected."
6564 (gnus-summary-next-article unread subject t))
6566 (defun gnus-summary-prev-unread-article ()
6567 "Select unread article before current one."
6569 (gnus-summary-prev-article
6570 (or (not (eq gnus-summary-goto-unread 'never))
6571 (gnus-summary-first-article-p (gnus-summary-article-number)))
6572 (and gnus-auto-select-same
6573 (gnus-summary-article-subject))))
6575 (defun gnus-summary-next-page (&optional lines circular)
6576 "Show next page of the selected article.
6577 If at the end of the current article, select the next article.
6578 LINES says how many lines should be scrolled up.
6580 If CIRCULAR is non-nil, go to the start of the article instead of
6581 selecting the next article when reaching the end of the current
6584 (setq gnus-summary-buffer (current-buffer))
6585 (gnus-set-global-variables)
6586 (let ((article (gnus-summary-article-number))
6587 (article-window (get-buffer-window gnus-article-buffer t))
6589 ;; If the buffer is empty, we have no article.
6591 (error "No article to select"))
6592 (gnus-configure-windows 'article)
6593 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6594 (if (and (eq gnus-summary-goto-unread 'never)
6595 (not (gnus-summary-last-article-p article)))
6596 (gnus-summary-next-article)
6597 (gnus-summary-next-unread-article))
6598 (if (or (null gnus-current-article)
6599 (null gnus-article-current)
6600 (/= article (cdr gnus-article-current))
6601 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6602 ;; Selected subject is different from current article's.
6603 (gnus-summary-display-article article)
6604 (when article-window
6605 (gnus-eval-in-buffer-window gnus-article-buffer
6606 (setq endp (gnus-article-next-page lines)))
6609 (gnus-summary-beginning-of-article))
6611 (gnus-message 3 "End of message"))
6613 (if (and (eq gnus-summary-goto-unread 'never)
6614 (not (gnus-summary-last-article-p article)))
6615 (gnus-summary-next-article)
6616 (gnus-summary-next-unread-article))))))))
6617 (gnus-summary-recenter)
6618 (gnus-summary-position-point)))
6620 (defun gnus-summary-prev-page (&optional lines move)
6621 "Show previous page of selected article.
6622 Argument LINES specifies lines to be scrolled down.
6623 If MOVE, move to the previous unread article if point is at
6624 the beginning of the buffer."
6626 (let ((article (gnus-summary-article-number))
6627 (article-window (get-buffer-window gnus-article-buffer t))
6629 (gnus-configure-windows 'article)
6630 (if (or (null gnus-current-article)
6631 (null gnus-article-current)
6632 (/= article (cdr gnus-article-current))
6633 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6634 ;; Selected subject is different from current article's.
6635 (gnus-summary-display-article article)
6636 (gnus-summary-recenter)
6637 (when article-window
6638 (gnus-eval-in-buffer-window gnus-article-buffer
6639 (setq endp (gnus-article-prev-page lines)))
6640 (when (and move endp)
6642 (gnus-message 3 "Beginning of message"))
6644 (if (and (eq gnus-summary-goto-unread 'never)
6645 (not (gnus-summary-first-article-p article)))
6646 (gnus-summary-prev-article)
6647 (gnus-summary-prev-unread-article))))))))
6648 (gnus-summary-position-point))
6650 (defun gnus-summary-prev-page-or-article (&optional lines)
6651 "Show previous page of selected article.
6652 Argument LINES specifies lines to be scrolled down.
6653 If at the beginning of the article, go to the next article."
6655 (gnus-summary-prev-page lines t))
6657 (defun gnus-summary-scroll-up (lines)
6658 "Scroll up (or down) one line current article.
6659 Argument LINES specifies lines to be scrolled up (or down if negative)."
6661 (gnus-configure-windows 'article)
6662 (gnus-summary-show-thread)
6663 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6664 (gnus-eval-in-buffer-window gnus-article-buffer
6666 (when (gnus-article-next-page lines)
6667 (gnus-message 3 "End of message")))
6669 (gnus-article-prev-page (- lines))))))
6670 (gnus-summary-recenter)
6671 (gnus-summary-position-point))
6673 (defun gnus-summary-scroll-down (lines)
6674 "Scroll down (or up) one line current article.
6675 Argument LINES specifies lines to be scrolled down (or up if negative)."
6677 (gnus-summary-scroll-up (- lines)))
6679 (defun gnus-summary-next-same-subject ()
6680 "Select next article which has the same subject as current one."
6682 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6684 (defun gnus-summary-prev-same-subject ()
6685 "Select previous article which has the same subject as current one."
6687 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6689 (defun gnus-summary-next-unread-same-subject ()
6690 "Select next unread article which has the same subject as current one."
6692 (gnus-summary-next-article t (gnus-summary-article-subject)))
6694 (defun gnus-summary-prev-unread-same-subject ()
6695 "Select previous unread article which has the same subject as current one."
6697 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6699 (defun gnus-summary-first-unread-article ()
6700 "Select the first unread article.
6701 Return nil if there are no unread articles."
6704 (when (gnus-summary-first-subject t)
6705 (gnus-summary-show-thread)
6706 (gnus-summary-first-subject t)
6707 (gnus-summary-display-article (gnus-summary-article-number)))
6708 (gnus-summary-position-point)))
6710 (defun gnus-summary-first-unread-subject ()
6711 "Place the point on the subject line of the first unread article.
6712 Return nil if there are no unread articles."
6715 (when (gnus-summary-first-subject t)
6716 (gnus-summary-show-thread)
6717 (gnus-summary-first-subject t))
6718 (gnus-summary-position-point)))
6720 (defun gnus-summary-first-article ()
6721 "Select the first article.
6722 Return nil if there are no articles."
6725 (when (gnus-summary-first-subject)
6726 (gnus-summary-show-thread)
6727 (gnus-summary-first-subject)
6728 (gnus-summary-display-article (gnus-summary-article-number)))
6729 (gnus-summary-position-point)))
6731 (defun gnus-summary-best-unread-article ()
6732 "Select the unread article with the highest score."
6734 (let ((best -1000000)
6735 (data gnus-newsgroup-data)
6738 (and (gnus-data-unread-p (car data))
6740 (gnus-summary-article-score (gnus-data-number (car data))))
6743 article (gnus-data-number (car data))))
6744 (setq data (cdr data)))
6747 (gnus-summary-goto-article article)
6748 (error "No unread articles"))
6749 (gnus-summary-position-point))))
6751 (defun gnus-summary-last-subject ()
6752 "Go to the last displayed subject line in the group."
6753 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6755 (gnus-summary-goto-subject article))))
6757 (defun gnus-summary-goto-article (article &optional all-headers force)
6758 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6759 If ALL-HEADERS is non-nil, no header lines are hidden.
6760 If FORCE, go to the article even if it isn't displayed. If FORCE
6761 is a number, it is the line the article is to be displayed on."
6765 "Article number or Message-ID: "
6766 (mapcar (lambda (number) (list (int-to-string number)))
6767 gnus-newsgroup-limit))
6771 (if (and (stringp article)
6772 (string-match "@" article))
6773 (gnus-summary-refer-article article)
6774 (when (stringp article)
6775 (setq article (string-to-number article)))
6776 (if (gnus-summary-goto-subject article force)
6777 (gnus-summary-display-article article all-headers)
6778 (gnus-message 4 "Couldn't go to article %s" article) nil))
6779 (gnus-summary-position-point)))
6781 (defun gnus-summary-goto-last-article ()
6782 "Go to the previously read article."
6785 (when gnus-last-article
6786 (gnus-summary-goto-article gnus-last-article nil t))
6787 (gnus-summary-position-point)))
6789 (defun gnus-summary-pop-article (number)
6790 "Pop one article off the history and go to the previous.
6791 NUMBER articles will be popped off."
6794 (setq gnus-newsgroup-history
6795 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6797 (gnus-summary-goto-article (car to) nil t)
6798 (error "Article history empty")))
6799 (gnus-summary-position-point))
6801 ;; Summary commands and functions for limiting the summary buffer.
6803 (defun gnus-summary-limit-to-articles (n)
6804 "Limit the summary buffer to the next N articles.
6805 If not given a prefix, use the process marked articles instead."
6808 (let ((articles (gnus-summary-work-articles n)))
6809 (setq gnus-newsgroup-processable nil)
6810 (gnus-summary-limit articles))
6811 (gnus-summary-position-point)))
6813 (defun gnus-summary-pop-limit (&optional total)
6814 "Restore the previous limit.
6815 If given a prefix, remove all limits."
6818 (setq gnus-newsgroup-limits
6819 (list (mapcar (lambda (h) (mail-header-number h))
6820 gnus-newsgroup-headers))))
6821 (unless gnus-newsgroup-limits
6822 (error "No limit to pop"))
6824 (gnus-summary-limit nil 'pop)
6825 (gnus-summary-position-point)))
6827 (defun gnus-summary-limit-to-subject (subject &optional header)
6828 "Limit the summary buffer to articles that have subjects that match a regexp."
6829 (interactive "sLimit to subject (regexp): ")
6831 (setq header "subject"))
6832 (when (not (equal "" subject))
6834 (let ((articles (gnus-summary-find-matching
6835 (or header "subject") subject 'all)))
6837 (error "Found no matches for \"%s\"" subject))
6838 (gnus-summary-limit articles))
6839 (gnus-summary-position-point))))
6841 (defun gnus-summary-limit-to-author (from)
6842 "Limit the summary buffer to articles that have authors that match a regexp."
6843 (interactive "sLimit to author (regexp): ")
6844 (gnus-summary-limit-to-subject from "from"))
6846 (defun gnus-summary-limit-to-age (age &optional younger-p)
6847 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6848 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6849 articles that are younger than AGE days."
6851 (let ((younger current-prefix-arg)
6854 (while (not days-got)
6855 (setq days (if younger
6856 (read-string "Limit to articles within (in days): ")
6857 (read-string "Limit to articles older than (in days): ")))
6858 (when (> (length days) 0)
6859 (setq days (read days)))
6862 (message "Please enter a number.")
6864 (list days younger)))
6866 (let ((data gnus-newsgroup-data)
6867 (cutoff (days-to-time age))
6868 articles d date is-younger)
6869 (while (setq d (pop data))
6870 (when (and (vectorp (gnus-data-header d))
6871 (setq date (mail-header-date (gnus-data-header d))))
6872 (setq is-younger (time-less-p
6873 (time-since (condition-case ()
6880 (push (gnus-data-number d) articles))))
6881 (gnus-summary-limit (nreverse articles)))
6882 (gnus-summary-position-point)))
6884 (defun gnus-summary-limit-to-extra (header regexp)
6885 "Limit the summary buffer to articles that match an 'extra' header."
6889 (gnus-completing-read
6890 (symbol-name (car gnus-extra-headers))
6891 "Limit extra header:"
6893 (cons (symbol-name x) x))
6898 (read-string (format "Limit to header %s (regexp): " header)))))
6899 (when (not (equal "" regexp))
6901 (let ((articles (gnus-summary-find-matching
6902 (cons 'extra header) regexp 'all)))
6904 (error "Found no matches for \"%s\"" regexp))
6905 (gnus-summary-limit articles))
6906 (gnus-summary-position-point))))
6908 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6910 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6912 (defun gnus-summary-limit-to-unread (&optional all)
6913 "Limit the summary buffer to articles that are not marked as read.
6914 If ALL is non-nil, limit strictly to unread articles."
6917 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6918 (gnus-summary-limit-to-marks
6919 ;; Concat all the marks that say that an article is read and have
6921 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6922 gnus-killed-mark gnus-kill-file-mark
6923 gnus-low-score-mark gnus-expirable-mark
6924 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6925 gnus-duplicate-mark gnus-souped-mark)
6928 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6929 (make-obsolete 'gnus-summary-delete-marked-with
6930 'gnus-summary-limit-exlude-marks)
6932 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6933 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6934 If REVERSE, limit the summary buffer to articles that are marked
6935 with MARKS. MARKS can either be a string of marks or a list of marks.
6936 Returns how many articles were removed."
6937 (interactive "sMarks: ")
6938 (gnus-summary-limit-to-marks marks t))
6940 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6941 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6942 If REVERSE (the prefix), limit the summary buffer to articles that are
6943 not marked with MARKS. MARKS can either be a string of marks or a
6945 Returns how many articles were removed."
6946 (interactive "sMarks: \nP")
6948 (let ((data gnus-newsgroup-data)
6949 (marks (if (listp marks) marks
6950 (append marks nil))) ; Transform to list.
6953 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6954 (memq (gnus-data-mark (car data)) marks))
6955 (push (gnus-data-number (car data)) articles))
6956 (setq data (cdr data)))
6957 (gnus-summary-limit articles))
6958 (gnus-summary-position-point)))
6960 (defun gnus-summary-limit-to-score (&optional score)
6961 "Limit to articles with score at or above SCORE."
6963 (setq score (if score
6964 (prefix-numeric-value score)
6965 (or gnus-summary-default-score 0)))
6966 (let ((data gnus-newsgroup-data)
6969 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6971 (push (gnus-data-number (car data)) articles))
6972 (setq data (cdr data)))
6974 (gnus-summary-limit articles)
6975 (gnus-summary-position-point))))
6977 (defun gnus-summary-limit-include-thread (id)
6978 "Display all the hidden articles that is in the thread with ID in it.
6979 When called interactively, ID is the Message-ID of the current
6981 (interactive (list (mail-header-id (gnus-summary-article-header))))
6982 (let ((articles (gnus-articles-in-thread
6983 (gnus-id-to-thread (gnus-root-id id)))))
6985 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6986 (gnus-summary-limit-include-matching-articles
6988 (regexp-quote (gnus-simplify-subject-re
6989 (mail-header-subject (gnus-id-to-header id)))))
6990 (gnus-summary-position-point))))
6992 (defun gnus-summary-limit-include-matching-articles (header regexp)
6993 "Display all the hidden articles that have HEADERs that match REGEXP."
6994 (interactive (list (read-string "Match on header: ")
6995 (read-string "Regexp: ")))
6996 (let ((articles (gnus-find-matching-articles header regexp)))
6998 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6999 (gnus-summary-position-point))))
7001 (defun gnus-summary-limit-include-dormant ()
7002 "Display all the hidden articles that are marked as dormant.
7003 Note that this command only works on a subset of the articles currently
7004 fetched for this group."
7006 (unless gnus-newsgroup-dormant
7007 (error "There are no dormant articles in this group"))
7009 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7010 (gnus-summary-position-point)))
7012 (defun gnus-summary-limit-exclude-dormant ()
7013 "Hide all dormant articles."
7016 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7017 (gnus-summary-position-point)))
7019 (defun gnus-summary-limit-exclude-childless-dormant ()
7020 "Hide all dormant articles that have no children."
7022 (let ((data (gnus-data-list t))
7023 articles d children)
7024 ;; Find all articles that are either not dormant or have
7026 (while (setq d (pop data))
7027 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7029 (gnus-article-children (gnus-data-number d)))
7032 (when (memq (car children) articles)
7037 (push (gnus-data-number d) articles)))
7040 (gnus-summary-limit articles)
7041 (gnus-summary-position-point))))
7043 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7044 "Mark all unread excluded articles as read.
7045 If ALL, mark even excluded ticked and dormants as read."
7047 (let ((articles (gnus-sorted-complement
7049 (mapcar (lambda (h) (mail-header-number h))
7050 gnus-newsgroup-headers)
7052 (sort gnus-newsgroup-limit '<)))
7054 (setq gnus-newsgroup-unreads
7055 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7057 (setq gnus-newsgroup-dormant nil
7058 gnus-newsgroup-marked nil
7059 gnus-newsgroup-reads
7061 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7062 gnus-newsgroup-reads))
7063 (while (setq article (pop articles))
7064 (unless (or (memq article gnus-newsgroup-dormant)
7065 (memq article gnus-newsgroup-marked))
7066 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7068 (defun gnus-summary-limit (articles &optional pop)
7070 ;; We pop the previous limit off the stack and use that.
7071 (setq articles (car gnus-newsgroup-limits)
7072 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7073 ;; We use the new limit, so we push the old limit on the stack.
7074 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7076 (setq gnus-newsgroup-limit articles)
7077 (let ((total (length gnus-newsgroup-data))
7078 (data (gnus-data-find-list (gnus-summary-article-number)))
7079 (gnus-summary-mark-below nil) ; Inhibit this.
7081 ;; This will do all the work of generating the new summary buffer
7082 ;; according to the new limit.
7083 (gnus-summary-prepare)
7084 ;; Hide any threads, possibly.
7085 (and gnus-show-threads
7086 gnus-thread-hide-subtree
7087 (gnus-summary-hide-all-threads))
7088 ;; Try to return to the article you were at, or one in the
7091 ;; We try to find some article after the current one.
7093 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7096 (setq data (cdr data))))
7098 ;; If there is no data, that means that we were after the last
7099 ;; article. The same goes when we can't find any articles
7100 ;; after the current one.
7101 (goto-char (point-max))
7102 (gnus-summary-find-prev))
7103 (gnus-set-mode-line 'summary)
7104 ;; We return how many articles were removed from the summary
7105 ;; buffer as a result of the new limit.
7106 (- total (length gnus-newsgroup-data))))
7108 (defsubst gnus-invisible-cut-children (threads)
7111 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7116 (defsubst gnus-cut-thread (thread)
7117 "Go forwards in the thread until we find an article that we want to display."
7118 (when (or (eq gnus-fetch-old-headers 'some)
7119 (eq gnus-fetch-old-headers 'invisible)
7120 (numberp gnus-fetch-old-headers)
7121 (eq gnus-build-sparse-threads 'some)
7122 (eq gnus-build-sparse-threads 'more))
7123 ;; Deal with old-fetched headers and sparse threads.
7127 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7128 (gnus-summary-article-ancient-p
7129 (mail-header-number (car thread))))
7130 (if (or (<= (length (cdr thread)) 1)
7131 (eq gnus-fetch-old-headers 'invisible))
7132 (setq gnus-newsgroup-limit
7133 (delq (mail-header-number (car thread))
7134 gnus-newsgroup-limit)
7135 thread (cadr thread))
7136 (when (gnus-invisible-cut-children (cdr thread))
7137 (let ((th (cdr thread)))
7139 (if (memq (mail-header-number (caar th))
7140 gnus-newsgroup-limit)
7141 (setq thread (car th)
7143 (setq th (cdr th))))))))))
7146 (defun gnus-cut-threads (threads)
7147 "Cut off all uninteresting articles from the beginning of threads."
7148 (when (or (eq gnus-fetch-old-headers 'some)
7149 (eq gnus-fetch-old-headers 'invisible)
7150 (numberp gnus-fetch-old-headers)
7151 (eq gnus-build-sparse-threads 'some)
7152 (eq gnus-build-sparse-threads 'more))
7155 (setcar th (gnus-cut-thread (car th)))
7156 (setq th (cdr th)))))
7157 ;; Remove nixed out threads.
7160 (defun gnus-summary-initial-limit (&optional show-if-empty)
7161 "Figure out what the initial limit is supposed to be on group entry.
7162 This entails weeding out unwanted dormants, low-scored articles,
7163 fetch-old-headers verbiage, and so on."
7164 ;; Most groups have nothing to remove.
7165 (if (or gnus-inhibit-limiting
7166 (and (null gnus-newsgroup-dormant)
7167 (eq gnus-newsgroup-display 'identity)
7168 (not (eq gnus-fetch-old-headers 'some))
7169 (not (numberp gnus-fetch-old-headers))
7170 (not (eq gnus-fetch-old-headers 'invisible))
7171 (null gnus-summary-expunge-below)
7172 (not (eq gnus-build-sparse-threads 'some))
7173 (not (eq gnus-build-sparse-threads 'more))
7174 (null gnus-thread-expunge-below)
7175 (not gnus-use-nocem)))
7177 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7178 (setq gnus-newsgroup-limit nil)
7181 (unless (car (symbol-value node))
7182 ;; These threads have no parents -- they are roots.
7183 (let ((nodes (cdr (symbol-value node)))
7186 (if (and gnus-thread-expunge-below
7187 (< (gnus-thread-total-score (car nodes))
7188 gnus-thread-expunge-below))
7189 (gnus-expunge-thread (pop nodes))
7190 (setq thread (pop nodes))
7191 (gnus-summary-limit-children thread))))))
7192 gnus-newsgroup-dependencies)
7193 ;; If this limitation resulted in an empty group, we might
7194 ;; pop the previous limit and use it instead.
7195 (when (and (not gnus-newsgroup-limit)
7197 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7198 gnus-newsgroup-limit))
7200 (defun gnus-summary-limit-children (thread)
7201 "Return 1 if this subthread is visible and 0 if it is not."
7202 ;; First we get the number of visible children to this thread. This
7203 ;; is done by recursing down the thread using this function, so this
7204 ;; will really go down to a leaf article first, before slowly
7205 ;; working its way up towards the root.
7209 (apply '+ (mapcar 'gnus-summary-limit-children
7212 (number (mail-header-number (car thread)))
7215 (not (memq number gnus-newsgroup-marked))
7217 ;; If this article is dormant and has absolutely no visible
7218 ;; children, then this article isn't visible.
7219 (and (memq number gnus-newsgroup-dormant)
7221 ;; If this is "fetch-old-headered" and there is no
7222 ;; visible children, then we don't want this article.
7223 (and (or (eq gnus-fetch-old-headers 'some)
7224 (numberp gnus-fetch-old-headers))
7225 (gnus-summary-article-ancient-p number)
7227 ;; If this is "fetch-old-headered" and `invisible', then
7228 ;; we don't want this article.
7229 (and (eq gnus-fetch-old-headers 'invisible)
7230 (gnus-summary-article-ancient-p number))
7231 ;; If this is a sparsely inserted article with no children,
7232 ;; we don't want it.
7233 (and (eq gnus-build-sparse-threads 'some)
7234 (gnus-summary-article-sparse-p number)
7236 ;; If we use expunging, and this article is really
7237 ;; low-scored, then we don't want this article.
7238 (when (and gnus-summary-expunge-below
7240 (or (cdr (assq number gnus-newsgroup-scored))
7241 gnus-summary-default-score))
7242 gnus-summary-expunge-below))
7243 ;; We increase the expunge-tally here, but that has
7244 ;; nothing to do with the limits, really.
7245 (incf gnus-newsgroup-expunged-tally)
7246 ;; We also mark as read here, if that's wanted.
7247 (when (and gnus-summary-mark-below
7248 (< score gnus-summary-mark-below))
7249 (setq gnus-newsgroup-unreads
7250 (delq number gnus-newsgroup-unreads))
7251 (if gnus-newsgroup-auto-expire
7252 (push number gnus-newsgroup-expirable)
7253 (push (cons number gnus-low-score-mark)
7254 gnus-newsgroup-reads)))
7256 ;; Do the `display' group parameter.
7257 (and gnus-newsgroup-display
7258 (not (funcall gnus-newsgroup-display)))
7259 ;; Check NoCeM things.
7260 (if (and gnus-use-nocem
7261 (gnus-nocem-unwanted-article-p
7262 (mail-header-id (car thread))))
7264 (setq gnus-newsgroup-unreads
7265 (delq number gnus-newsgroup-unreads))
7267 ;; Nope, invisible article.
7269 ;; Ok, this article is to be visible, so we add it to the limit
7271 (push number gnus-newsgroup-limit)
7274 (defun gnus-expunge-thread (thread)
7275 "Mark all articles in THREAD as read."
7276 (let* ((number (mail-header-number (car thread))))
7277 (incf gnus-newsgroup-expunged-tally)
7278 ;; We also mark as read here, if that's wanted.
7279 (setq gnus-newsgroup-unreads
7280 (delq number gnus-newsgroup-unreads))
7281 (if gnus-newsgroup-auto-expire
7282 (push number gnus-newsgroup-expirable)
7283 (push (cons number gnus-low-score-mark)
7284 gnus-newsgroup-reads)))
7285 ;; Go recursively through all subthreads.
7286 (mapcar 'gnus-expunge-thread (cdr thread)))
7288 ;; Summary article oriented commands
7290 (defun gnus-summary-refer-parent-article (n)
7291 "Refer parent article N times.
7292 If N is negative, go to ancestor -N instead.
7293 The difference between N and the number of articles fetched is returned."
7297 (when (not (natnump n))
7302 (setq header (gnus-summary-article-header))
7303 (if (and (eq (mail-header-number header)
7304 (cdr gnus-article-current))
7305 (equal gnus-newsgroup-name
7306 (car gnus-article-current)))
7307 ;; If we try to find the parent of the currently
7308 ;; displayed article, then we take a look at the actual
7309 ;; References header, since this is slightly more
7310 ;; reliable than the References field we got from the
7313 (set-buffer gnus-original-article-buffer)
7314 (nnheader-narrow-to-headers)
7315 (unless (setq ref (message-fetch-field "references"))
7316 (setq ref (message-fetch-field "in-reply-to")))
7319 ;; It's not the current article, so we take a bet on
7320 ;; the value we got from the server.
7321 (mail-header-references header)))
7323 (not (equal ref "")))
7324 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7325 (gnus-message 1 "Couldn't find parent"))
7326 (gnus-message 1 "No references in article %d"
7327 (gnus-summary-article-number))
7330 (gnus-summary-position-point)
7333 (defun gnus-summary-refer-references ()
7334 "Fetch all articles mentioned in the References header.
7335 Return the number of articles fetched."
7337 (let ((ref (mail-header-references (gnus-summary-article-header)))
7338 (current (gnus-summary-article-number))
7342 (error "No References in the current article")
7343 ;; For each Message-ID in the References header...
7344 (while (string-match "<[^>]*>" ref)
7346 ;; ... fetch that article.
7347 (gnus-summary-refer-article
7348 (prog1 (match-string 0 ref)
7349 (setq ref (substring ref (match-end 0))))))
7350 (gnus-summary-goto-subject current)
7351 (gnus-summary-position-point)
7354 (defun gnus-summary-refer-thread (&optional limit)
7355 "Fetch all articles in the current thread.
7356 If LIMIT (the numerical prefix), fetch that many old headers instead
7357 of what's specified by the `gnus-refer-thread-limit' variable."
7359 (let ((id (mail-header-id (gnus-summary-article-header)))
7360 (limit (if limit (prefix-numeric-value limit)
7361 gnus-refer-thread-limit)))
7362 ;; We want to fetch LIMIT *old* headers, but we also have to
7363 ;; re-fetch all the headers in the current buffer, because many of
7364 ;; them may be undisplayed. So we adjust LIMIT.
7365 (when (numberp limit)
7366 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7367 (unless (eq gnus-fetch-old-headers 'invisible)
7368 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7369 ;; Retrieve the headers and read them in.
7370 (if (eq (gnus-retrieve-headers
7371 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7373 (gnus-build-all-threads)
7374 (error "Can't fetch thread from backends that don't support NOV"))
7375 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7376 (gnus-summary-limit-include-thread id)))
7378 (defun gnus-summary-refer-article (message-id)
7379 "Fetch an article specified by MESSAGE-ID."
7380 (interactive "sMessage-ID: ")
7381 (when (and (stringp message-id)
7382 (not (zerop (length message-id))))
7383 ;; Construct the correct Message-ID if necessary.
7384 ;; Suggested by tale@pawl.rpi.edu.
7385 (unless (string-match "^<" message-id)
7386 (setq message-id (concat "<" message-id)))
7387 (unless (string-match ">$" message-id)
7388 (setq message-id (concat message-id ">")))
7389 (let* ((header (gnus-id-to-header message-id))
7391 (gnus-summary-article-sparse-p
7392 (mail-header-number header))
7393 (memq (mail-header-number header)
7394 gnus-newsgroup-limit)))
7397 ;; If the article is present in the buffer we just go to it.
7399 (or (not (gnus-summary-article-sparse-p
7400 (mail-header-number header)))
7403 (gnus-summary-goto-article
7404 (mail-header-number header) nil t)
7406 (gnus-summary-update-article (mail-header-number header)))))
7408 ;; We fetch the article.
7410 (dolist (gnus-override-method (gnus-refer-article-methods))
7411 (gnus-check-server gnus-override-method)
7412 ;; Fetch the header, and display the article.
7413 (when (setq number (gnus-summary-insert-subject message-id))
7414 (gnus-summary-select-article nil nil nil number)
7416 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7418 (defun gnus-refer-article-methods ()
7419 "Return a list of referrable methods."
7421 ;; No method, so we default to current and native.
7422 ((null gnus-refer-article-method)
7423 (list gnus-current-select-method gnus-select-method))
7425 ((eq 'current gnus-refer-article-method)
7426 (list gnus-current-select-method))
7427 ;; List of select methods.
7428 ((not (and (symbolp (car gnus-refer-article-method))
7429 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7431 (dolist (method gnus-refer-article-method)
7432 (push (if (eq 'current method)
7433 gnus-current-select-method
7437 ;; One single select method.
7439 (list gnus-refer-article-method))))
7441 (defun gnus-summary-edit-parameters ()
7442 "Edit the group parameters of the current group."
7444 (gnus-group-edit-group gnus-newsgroup-name 'params))
7446 (defun gnus-summary-customize-parameters ()
7447 "Customize the group parameters of the current group."
7449 (gnus-group-customize gnus-newsgroup-name))
7451 (defun gnus-summary-enter-digest-group (&optional force)
7452 "Enter an nndoc group based on the current article.
7453 If FORCE, force a digest interpretation. If not, try
7454 to guess what the document format is."
7456 (let ((conf gnus-current-window-configuration))
7458 (gnus-summary-select-article))
7459 (setq gnus-current-window-configuration conf)
7460 (let* ((name (format "%s-%d"
7461 (gnus-group-prefixed-name
7462 gnus-newsgroup-name (list 'nndoc ""))
7464 (set-buffer gnus-summary-buffer)
7465 gnus-current-article)))
7466 (ogroup gnus-newsgroup-name)
7467 (params (append (gnus-info-params (gnus-get-info ogroup))
7468 (list (cons 'to-group ogroup))
7469 (list (cons 'save-article-group ogroup))))
7470 (case-fold-search t)
7471 (buf (current-buffer))
7474 (set-buffer gnus-original-article-buffer)
7475 ;; Have the digest group inherit the main mail address of
7476 ;; the parent article.
7477 (when (setq to-address (or (message-fetch-field "reply-to")
7478 (message-fetch-field "from")))
7479 (setq params (append
7480 (list (cons 'to-address
7481 (funcall gnus-decode-encoded-word-function
7483 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7484 (insert-buffer-substring gnus-original-article-buffer)
7485 ;; Remove lines that may lead nndoc to misinterpret the
7488 (goto-char (point-min))
7489 (or (search-forward "\n\n" nil t) (point)))
7490 (goto-char (point-min))
7491 (delete-matching-lines "^Path:\\|^From ")
7494 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7495 (gnus-newsgroup-ephemeral-ignored-charsets
7496 gnus-newsgroup-ignored-charsets))
7497 (gnus-group-read-ephemeral-group
7498 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7500 ,(if force 'mbox 'guess))) t))
7501 ;; Make all postings to this group go to the parent group.
7502 (nconc (gnus-info-params (gnus-get-info name))
7504 ;; Couldn't select this doc group.
7505 (switch-to-buffer buf)
7506 (gnus-set-global-variables)
7507 (gnus-configure-windows 'summary)
7508 (gnus-message 3 "Article couldn't be entered?"))
7509 (kill-buffer dig)))))
7511 (defun gnus-summary-read-document (n)
7512 "Open a new group based on the current article(s).
7513 This will allow you to read digests and other similar
7514 documents as newsgroups.
7515 Obeys the standard process/prefix convention."
7517 (let* ((articles (gnus-summary-work-articles n))
7518 (ogroup gnus-newsgroup-name)
7519 (params (append (gnus-info-params (gnus-get-info ogroup))
7520 (list (cons 'to-group ogroup))))
7521 article group egroup groups vgroup)
7522 (while (setq article (pop articles))
7523 (setq group (format "%s-%d" gnus-newsgroup-name article))
7524 (gnus-summary-remove-process-mark article)
7525 (when (gnus-summary-display-article article)
7528 (insert-buffer-substring gnus-original-article-buffer)
7529 ;; Remove some headers that may lead nndoc to make
7531 (message-narrow-to-head)
7532 (goto-char (point-min))
7533 (delete-matching-lines "^\\(Path\\):\\|^From ")
7536 (gnus-group-read-ephemeral-group
7537 group `(nndoc ,group (nndoc-address ,(current-buffer))
7538 (nndoc-article-type guess))
7541 ;; Make all postings to this group go to the parent group.
7542 (nconc (gnus-info-params (gnus-get-info egroup))
7544 (push egroup groups))
7545 ;; Couldn't select this doc group.
7546 (gnus-error 3 "Article couldn't be entered"))))))
7547 ;; Now we have selected all the documents.
7550 (error "None of the articles could be interpreted as documents"))
7551 ((gnus-group-read-ephemeral-group
7552 (setq vgroup (format
7553 "nnvirtual:%s-%s" gnus-newsgroup-name
7554 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7555 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7557 (cons (current-buffer) 'summary)))
7559 (error "Couldn't select virtual nndoc group")))))
7561 (defun gnus-summary-isearch-article (&optional regexp-p)
7562 "Do incremental search forward on the current article.
7563 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7565 (let* ((gnus-inhibit-treatment t)
7566 (old (gnus-summary-select-article)))
7567 (gnus-configure-windows 'article)
7568 (gnus-eval-in-buffer-window gnus-article-buffer
7572 (gnus-article-show-all-headers))
7573 (goto-char (point-min))
7574 (isearch-forward regexp-p)))))
7576 (defun gnus-summary-search-article-forward (regexp &optional backward)
7577 "Search for an article containing REGEXP forward.
7578 If BACKWARD, search backward instead."
7581 (format "Search article %s (regexp%s): "
7582 (if current-prefix-arg "backward" "forward")
7583 (if gnus-last-search-regexp
7584 (concat ", default " gnus-last-search-regexp)
7586 current-prefix-arg))
7587 (if (string-equal regexp "")
7588 (setq regexp (or gnus-last-search-regexp ""))
7589 (setq gnus-last-search-regexp regexp)
7590 (setq gnus-article-before-search gnus-current-article))
7591 ;; Intentionally set gnus-last-article.
7592 (setq gnus-last-article gnus-article-before-search)
7593 (let ((gnus-last-article gnus-last-article))
7594 (if (gnus-summary-search-article regexp backward)
7595 (gnus-summary-show-thread)
7596 (error "Search failed: \"%s\"" regexp))))
7598 (defun gnus-summary-search-article-backward (regexp)
7599 "Search for an article containing REGEXP backward."
7602 (format "Search article backward (regexp%s): "
7603 (if gnus-last-search-regexp
7604 (concat ", default " gnus-last-search-regexp)
7606 (gnus-summary-search-article-forward regexp 'backward))
7609 (defmacro gnus-summary-search-article-position-point (regexp backward)
7610 "Dehighlight the last matched text and goto the beginning position."
7611 (` (if (and gnus-summary-search-article-matched-data
7612 (let ((text (caddr gnus-summary-search-article-matched-data))
7613 (inhibit-read-only t)
7616 (goto-char (car gnus-summary-search-article-matched-data))
7617 (cadr gnus-summary-search-article-matched-data))
7619 (string-match (, regexp) text)))
7620 (if (, backward) (beginning-of-line) (end-of-line))
7621 (goto-char (if (, backward) (point-max) (point-min))))))
7623 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7624 "Place point where X-Face image is displayed."
7625 (if (featurep 'xemacs)
7626 (` (let ((end (if (search-forward "\n\n" nil t)
7627 (goto-char (1- (point)))
7630 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7631 (unless (and (re-search-forward "^From:" end t)
7632 (setq extent (extent-at (point)))
7633 (extent-begin-glyph extent))
7634 (goto-char (, opoint)))))
7635 (` (let ((end (if (search-forward "\n\n" nil t)
7636 (goto-char (1- (point)))
7638 (start (or (search-backward "\n\n" nil t) (point-min))))
7640 (or (text-property-any start end 'x-face-image t);; x-face-e21
7641 (text-property-any start end 'x-face-mule-bitmap-image t)
7644 (defmacro gnus-summary-search-article-highlight-matched-text
7645 (backward treated x-face)
7646 "Highlight matched text in the function `gnus-summary-search-article'."
7647 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7648 (end (set-marker (make-marker) (match-end 0)))
7649 (inhibit-read-only t)
7653 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7655 (lambda (item) (setq items (delq item items)))
7656 '(gnus-treat-buttonize
7657 gnus-treat-fill-article
7658 gnus-treat-fill-long-lines
7659 gnus-treat-emphasize
7660 gnus-treat-highlight-headers
7661 gnus-treat-highlight-citation
7662 gnus-treat-highlight-signature
7663 gnus-treat-overstrike
7664 gnus-treat-display-xface
7665 gnus-treat-buttonize-head
7666 gnus-treat-decode-article-as-default-mime-charset))
7667 (static-if (featurep 'xemacs)
7669 (cons '(x-face-mule-delete-x-face-field
7672 (gnus-treat-display-xface
7673 (when (, x-face) gnus-treat-display-xface)))
7674 (gnus-article-prepare-mime-display)))
7675 (goto-char (if (, backward) start end))
7677 (gnus-summary-search-article-highlight-goto-x-face (point)))
7678 (setq gnus-summary-search-article-matched-data
7679 (list start end (buffer-substring start end)))
7680 (unless (eq start end);; matched text has been deleted. :-<
7681 (put-text-property start end 'face
7682 (or (find-face 'isearch)
7683 'secondary-selection))))))
7686 (defun gnus-summary-search-article (regexp &optional backward)
7687 "Search for an article containing REGEXP.
7688 Optional argument BACKWARD means do search for backward.
7689 `gnus-select-article-hook' is not called during the search."
7690 ;; We have to require this here to make sure that the following
7691 ;; dynamic binding isn't shadowed by autoloading.
7692 (require 'gnus-async)
7694 (let ((gnus-select-article-hook nil) ;Disable hook.
7695 (gnus-article-prepare-hook nil)
7696 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7697 (gnus-use-article-prefetch nil)
7698 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7699 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7700 (sum (current-buffer))
7703 (gnus-save-hidden-threads
7704 (static-if (featurep 'xemacs)
7705 (let ((gnus-inhibit-treatment t))
7706 (setq treated (eq 'old (gnus-summary-select-article)))
7708 (not (and (gnus-buffer-live-p gnus-article-buffer)
7709 (window-live-p (get-buffer-window
7710 gnus-article-buffer t)))))
7711 (gnus-summary-select-article nil t)
7712 (setq treated nil)))
7713 (let ((gnus-inhibit-treatment t)
7714 (x-face-mule-delete-x-face-field 'never))
7715 (setq treated (eq 'old (gnus-summary-select-article)))
7718 (and (gnus-buffer-live-p gnus-article-buffer)
7719 (window-live-p (get-buffer-window
7720 gnus-article-buffer t))
7721 (or (not (string-match "^\\^X-Face:" regexp))
7722 (with-current-buffer gnus-article-buffer
7723 gnus-summary-search-article-matched-data)))))
7724 (gnus-summary-select-article nil t)
7725 (setq treated nil))))
7726 (set-buffer gnus-article-buffer)
7730 (gnus-article-show-all-headers)
7731 (gnus-summary-search-article-position-point regexp backward))
7732 (goto-char (if backward (point-max) (point-min))))
7734 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7736 (re-search-backward regexp nil t)
7737 (re-search-forward regexp nil t))
7738 ;; We found the regexp.
7740 (gnus-summary-search-article-highlight-matched-text
7741 backward treated (string-match "^\\^X-Face:" regexp))
7744 (/ (- 2 (window-height
7745 (get-buffer-window gnus-article-buffer t)))
7748 (get-buffer-window (current-buffer))
7751 (setq point (point)))
7752 ;; We didn't find it, so we go to the next article.
7755 (while (eq found 'not)
7756 (if (not (if backward (gnus-summary-find-prev)
7757 (gnus-summary-find-next)))
7758 ;; No more articles.
7760 ;; Select the next article and adjust point.
7761 (unless (gnus-summary-article-sparse-p
7762 (gnus-summary-article-number))
7764 (let ((gnus-inhibit-treatment t))
7765 (gnus-summary-select-article))
7767 (set-buffer gnus-article-buffer)
7769 (goto-char (if backward (point-max) (point-min))))))))
7770 (gnus-message 7 ""))
7771 ;; Return whether we found the regexp.
7772 (when (eq found 'found)
7774 (gnus-summary-show-thread)
7775 (gnus-summary-goto-subject gnus-current-article)
7776 (gnus-summary-position-point)
7779 (defun gnus-find-matching-articles (header regexp)
7780 "Return a list of all articles that match REGEXP on HEADER.
7781 This search includes all articles in the current group that Gnus has
7782 fetched headers for, whether they are displayed or not."
7783 (let ((articles nil)
7784 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7785 (case-fold-search t))
7786 (dolist (header gnus-newsgroup-headers)
7787 (when (string-match regexp (funcall func header))
7788 (push (mail-header-number header) articles)))
7789 (nreverse articles)))
7791 (defun gnus-summary-find-matching (header regexp &optional backward unread
7793 "Return a list of all articles that match REGEXP on HEADER.
7794 The search stars on the current article and goes forwards unless
7795 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7796 If UNREAD is non-nil, only unread articles will
7797 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7798 in the comparisons."
7799 (let ((case-fold-search (not not-case-fold))
7802 (if (eq (car header) 'extra)
7805 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7807 (error "%s is an invalid header" header))
7808 (unless (fboundp (intern (concat "mail-header-" header)))
7809 (error "%s is not a valid header" header))
7810 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7811 (dolist (d (if (eq backward 'all)
7813 (gnus-data-find-list
7814 (gnus-summary-article-number)
7815 (gnus-data-list backward))))
7816 (when (and (or (not unread) ; We want all articles...
7817 (gnus-data-unread-p d)) ; Or just unreads.
7818 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7819 (string-match regexp
7820 (funcall func (gnus-data-header d)))) ; Match.
7821 (push (gnus-data-number d) articles))) ; Success!
7822 (nreverse articles)))
7824 (defun gnus-summary-execute-command (header regexp command &optional backward)
7825 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7826 If HEADER is an empty string (or nil), the match is done on the entire
7827 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7829 (list (let ((completion-ignore-case t))
7832 (mapcar (lambda (header) (list (format "%s" header)))
7834 '("Number" "Subject" "From" "Lines" "Date"
7835 "Message-ID" "Xref" "References" "Body")
7836 gnus-extra-headers))
7837 nil 'require-match))
7838 (read-string "Regexp: ")
7839 (read-key-sequence "Command: ")
7840 current-prefix-arg))
7841 (when (equal header "Body")
7843 ;; Hidden thread subtrees must be searched as well.
7844 (gnus-summary-show-all-threads)
7845 ;; We don't want to change current point nor window configuration.
7847 (save-window-excursion
7848 (gnus-message 6 "Executing %s..." (key-description command))
7849 ;; We'd like to execute COMMAND interactively so as to give arguments.
7850 (gnus-execute header regexp
7851 `(call-interactively ',(key-binding command))
7853 (gnus-message 6 "Executing %s...done" (key-description command)))))
7855 (defun gnus-summary-beginning-of-article ()
7856 "Scroll the article back to the beginning."
7858 (gnus-summary-select-article)
7859 (gnus-configure-windows 'article)
7860 (gnus-eval-in-buffer-window gnus-article-buffer
7862 (goto-char (point-min))
7863 (when gnus-page-broken
7864 (gnus-narrow-to-page))))
7866 (defun gnus-summary-end-of-article ()
7867 "Scroll to the end of the article."
7869 (gnus-summary-select-article)
7870 (gnus-configure-windows 'article)
7871 (gnus-eval-in-buffer-window gnus-article-buffer
7873 (goto-char (point-max))
7875 (when gnus-page-broken
7876 (gnus-narrow-to-page))))
7878 (defun gnus-summary-print-article (&optional filename n)
7879 "Generate and print a PostScript image of the N next (mail) articles.
7881 If N is negative, print the N previous articles. If N is nil and articles
7882 have been marked with the process mark, print these instead.
7884 If the optional first argument FILENAME is nil, send the image to the
7885 printer. If FILENAME is a string, save the PostScript image in a file with
7886 that name. If FILENAME is a number, prompt the user for the name of the file
7888 (interactive (list (ps-print-preprint current-prefix-arg)))
7889 (dolist (article (gnus-summary-work-articles n))
7890 (gnus-summary-select-article nil nil 'pseudo article)
7891 (gnus-eval-in-buffer-window gnus-article-buffer
7892 (let ((buffer (generate-new-buffer " *print*")))
7895 (copy-to-buffer buffer (point-min) (point-max))
7897 (gnus-article-delete-invisible-text)
7898 (when (gnus-visual-p 'article-highlight 'highlight)
7899 ;; Copy-to-buffer doesn't copy overlay. So redo
7901 (let ((gnus-article-buffer buffer))
7902 (gnus-article-highlight-citation t)
7903 (gnus-article-highlight-signature)))
7904 (let ((ps-left-header
7907 (mail-header-subject gnus-current-headers) ")")
7909 (mail-header-from gnus-current-headers) ")")))
7912 "/pagenumberstring load"
7914 (mail-header-date gnus-current-headers) ")"))))
7915 (gnus-run-hooks 'gnus-ps-print-hook)
7918 (ps-spool-buffer-with-faces)
7919 (ps-spool-buffer)))))
7920 (kill-buffer buffer))))
7921 (gnus-summary-remove-process-mark article))
7922 (ps-despool filename))
7924 (defun gnus-summary-show-article (&optional arg)
7925 "Force re-fetching of the current article.
7926 If ARG (the prefix) is a number, show the article with the charset
7927 defined in `gnus-summary-show-article-charset-alist', or the charset
7929 If ARG (the prefix) is non-nil and not a number, show the raw article
7930 without any article massaging functions being run."
7934 (gnus-summary-show-article t)
7935 (let ((gnus-newsgroup-charset
7936 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7937 (mm-read-coding-system
7940 (set-buffer gnus-article-buffer)
7941 (detect-coding-region (point) (point-max) t)))))
7942 (gnus-newsgroup-ignored-charsets 'gnus-all))
7943 (gnus-summary-select-article nil 'force)
7944 (let ((deps gnus-newsgroup-dependencies)
7947 (set-buffer gnus-original-article-buffer)
7949 (message-narrow-to-head)
7950 (setq head (buffer-string)))
7952 (insert (format "211 %d Article retrieved.\n"
7953 (cdr gnus-article-current)))
7956 (let ((nntp-server-buffer (current-buffer)))
7957 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7958 (gnus-data-set-header
7959 (gnus-data-find (cdr gnus-article-current))
7961 (gnus-summary-update-article-line
7962 (cdr gnus-article-current) header)
7963 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
7964 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
7966 ;; Select the article the normal way.
7967 (gnus-summary-select-article nil 'force))
7969 ;; We have to require this here to make sure that the following
7970 ;; dynamic binding isn't shadowed by autoloading.
7971 (require 'gnus-async)
7973 ;; Bind the article treatment functions to nil.
7974 (let ((gnus-have-all-headers t)
7975 gnus-article-prepare-hook
7976 gnus-article-decode-hook
7979 (gnus-inhibit-treatment t))
7980 (gnus-summary-select-article nil 'force))))
7981 (gnus-summary-goto-subject gnus-current-article)
7982 (gnus-summary-position-point))
7984 (defun gnus-summary-show-raw-article ()
7985 "Show the raw article without any article massaging functions being run."
7987 (gnus-summary-show-article t))
7989 (defun gnus-summary-verbose-headers (&optional arg)
7990 "Toggle permanent full header display.
7991 If ARG is a positive number, turn header display on.
7992 If ARG is a negative number, turn header display off."
7994 (setq gnus-show-all-headers
7995 (cond ((or (not (numberp arg))
7997 (not gnus-show-all-headers))
8000 (gnus-summary-show-article))
8002 (defun gnus-summary-toggle-header (&optional arg)
8003 "Show the headers if they are hidden, or hide them if they are shown.
8004 If ARG is a positive number, show the entire header.
8005 If ARG is a negative number, hide the unwanted header lines."
8008 (set-buffer gnus-article-buffer)
8010 (let* ((buffer-read-only nil)
8011 (inhibit-point-motion-hooks t)
8017 (article-narrow-to-head)
8018 (gnus-article-hidden-text-p 'headers))))
8019 (goto-char (point-min))
8020 (when (search-forward "\n\n" nil t)
8021 (delete-region (point-min) (1- (point))))
8022 (goto-char (point-min))
8024 (set-buffer gnus-original-article-buffer)
8025 (goto-char (point-min))
8026 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8027 (insert-buffer-substring gnus-original-article-buffer 1 e)
8029 (narrow-to-region (point-min) (point))
8030 (article-decode-encoded-words)
8032 (let ((gnus-treat-hide-headers nil)
8033 (gnus-treat-hide-boring-headers nil))
8034 (setq gnus-article-wash-types
8035 (delq 'headers gnus-article-wash-types))
8036 (gnus-treat-article 'head))
8037 (gnus-treat-article 'head)))
8038 (gnus-set-mode-line 'article)))))
8040 (defun gnus-summary-show-all-headers ()
8041 "Make all header lines visible."
8043 (gnus-summary-toggle-header 1))
8045 (defun gnus-summary-toggle-mime (&optional arg)
8046 "Toggle MIME processing.
8047 If ARG is a positive number, turn MIME processing on."
8049 (setq gnus-show-mime
8051 (not gnus-show-mime)
8052 (> (prefix-numeric-value arg) 0)))
8053 (gnus-summary-select-article t 'force))
8055 (defun gnus-summary-caesar-message (&optional arg)
8056 "Caesar rotate the current article by 13.
8057 The numerical prefix specifies how many places to rotate each letter
8060 (gnus-summary-select-article)
8061 (let ((mail-header-separator ""))
8062 (gnus-eval-in-buffer-window gnus-article-buffer
8065 (let ((start (window-start))
8067 (message-caesar-buffer-body arg)
8068 (set-window-start (get-buffer-window (current-buffer)) start))))))
8070 (defun gnus-summary-stop-page-breaking ()
8071 "Stop page breaking in the current article."
8073 (gnus-summary-select-article)
8074 (gnus-eval-in-buffer-window gnus-article-buffer
8076 (when (gnus-visual-p 'page-marker)
8077 (let ((buffer-read-only nil))
8078 (gnus-remove-text-with-property 'gnus-prev)
8079 (gnus-remove-text-with-property 'gnus-next))
8080 (setq gnus-page-broken nil))))
8082 (defun gnus-summary-move-article (&optional n to-newsgroup
8083 select-method action)
8084 "Move the current article to a different newsgroup.
8085 If N is a positive number, move the N next articles.
8086 If N is a negative number, move the N previous articles.
8087 If N is nil and any articles have been marked with the process mark,
8088 move those articles instead.
8089 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8090 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8091 re-spool using this method.
8093 For this function to work, both the current newsgroup and the
8094 newsgroup that you want to move to have to support the `request-move'
8095 and `request-accept' functions.
8097 ACTION can be either `move' (the default), `crosspost' or `copy'."
8100 (setq action 'move))
8101 ;; Check whether the source group supports the required functions.
8102 (cond ((and (eq action 'move)
8103 (not (gnus-check-backend-function
8104 'request-move-article gnus-newsgroup-name)))
8105 (error "The current group does not support article moving"))
8106 ((and (eq action 'crosspost)
8107 (not (gnus-check-backend-function
8108 'request-replace-article gnus-newsgroup-name)))
8109 (error "The current group does not support article editing")))
8110 (let ((articles (gnus-summary-work-articles n))
8111 (prefix (if (gnus-check-backend-function
8112 'request-move-article gnus-newsgroup-name)
8113 (gnus-group-real-prefix gnus-newsgroup-name)
8115 (names '((move "Move" "Moving")
8116 (copy "Copy" "Copying")
8117 (crosspost "Crosspost" "Crossposting")))
8118 (copy-buf (save-excursion
8119 (nnheader-set-temp-buffer " *copy article*")))
8120 (default-marks gnus-article-mark-lists)
8121 (no-expire-marks (delete '(expirable . expire)
8122 (copy-sequence gnus-article-mark-lists)))
8123 art-group to-method new-xref article to-groups)
8124 (unless (assq action names)
8125 (error "Unknown action %s" action))
8126 ;; Read the newsgroup name.
8127 (when (and (not to-newsgroup)
8128 (not select-method))
8130 (gnus-read-move-group-name
8131 (cadr (assq action names))
8132 (symbol-value (intern (format "gnus-current-%s-group" action)))
8134 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8135 (setq to-method (or select-method
8136 (gnus-server-to-method
8137 (gnus-group-method to-newsgroup))))
8138 ;; Check the method we are to move this article to...
8139 (unless (gnus-check-backend-function
8140 'request-accept-article (car to-method))
8141 (error "%s does not support article copying" (car to-method)))
8142 (unless (gnus-check-server to-method)
8143 (error "Can't open server %s" (car to-method)))
8144 (gnus-message 6 "%s to %s: %s..."
8145 (caddr (assq action names))
8146 (or (car select-method) to-newsgroup) articles)
8148 (setq article (pop articles))
8152 ;; Move the article.
8154 ;; Remove this article from future suppression.
8155 (gnus-dup-unsuppress-article article)
8156 (gnus-request-move-article
8157 article ; Article to move
8158 gnus-newsgroup-name ; From newsgroup
8159 (nth 1 (gnus-find-method-for-group
8160 gnus-newsgroup-name)) ; Server
8161 (list 'gnus-request-accept-article
8162 to-newsgroup (list 'quote select-method)
8163 (not articles) t) ; Accept form
8164 (not articles))) ; Only save nov last time
8165 ;; Copy the article.
8168 (set-buffer copy-buf)
8169 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8170 (gnus-request-accept-article
8171 to-newsgroup select-method (not articles) t))))
8172 ;; Crosspost the article.
8173 ((eq action 'crosspost)
8174 (let ((xref (message-tokenize-header
8175 (mail-header-xref (gnus-summary-article-header article))
8177 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8180 (setq xref (list (system-name))))
8183 (mapconcat 'identity
8184 (delete "Xref:" (delete new-xref xref))
8188 (set-buffer copy-buf)
8189 ;; First put the article in the destination group.
8190 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8191 (when (consp (setq art-group
8192 (gnus-request-accept-article
8193 to-newsgroup select-method (not articles))))
8194 (setq new-xref (concat new-xref " " (car art-group)
8195 ":" (cdr art-group)))
8196 ;; Now we have the new Xrefs header, so we insert
8197 ;; it and replace the new article.
8198 (nnheader-replace-header "Xref" new-xref)
8199 (gnus-request-replace-article
8200 (cdr art-group) to-newsgroup (current-buffer))
8204 (gnus-message 1 "Couldn't %s article %s: %s"
8205 (cadr (assq action names)) article
8206 (nnheader-get-report (car to-method))))
8207 ((eq art-group 'junk)
8208 (when (eq action 'move)
8209 (gnus-summary-mark-article article gnus-canceled-mark)
8210 (gnus-message 4 "Deleted article %s" article)))
8212 (let* ((pto-group (gnus-group-prefixed-name
8213 (car art-group) to-method))
8215 (gnus-gethash pto-group gnus-newsrc-hashtb))
8216 (info (nth 2 entry))
8217 (to-group (gnus-info-group info))
8219 ;; Update the group that has been moved to.
8221 (memq action '(move copy)))
8222 (unless (member to-group to-groups)
8223 (push to-group to-groups))
8225 (unless (memq article gnus-newsgroup-unreads)
8226 (push 'read to-marks)
8228 info (gnus-add-to-range (gnus-info-read info)
8229 (list (cdr art-group)))))
8231 ;; See whether the article is to be put in the cache.
8232 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8235 (to-article (cdr art-group)))
8237 ;; Enter the article into the cache in the new group,
8238 ;; if that is required.
8239 (when gnus-use-cache
8240 (gnus-cache-possibly-enter-article
8242 (let ((header (copy-sequence
8243 (gnus-summary-article-header article))))
8244 (mail-header-set-number header to-article)
8246 (memq article gnus-newsgroup-marked)
8247 (memq article gnus-newsgroup-dormant)
8248 (memq article gnus-newsgroup-unreads)))
8250 (when gnus-preserve-marks
8251 ;; Copy any marks over to the new group.
8252 (when (and (equal to-group gnus-newsgroup-name)
8253 (not (memq article gnus-newsgroup-unreads)))
8254 ;; Mark this article as read in this group.
8255 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8256 (setcdr (gnus-active to-group) to-article)
8257 (setcdr gnus-newsgroup-active to-article))
8260 (when (memq article (symbol-value
8261 (intern (format "gnus-newsgroup-%s"
8263 (push (cdar marks) to-marks)
8264 ;; If the other group is the same as this group,
8265 ;; then we have to add the mark to the list.
8266 (when (equal to-group gnus-newsgroup-name)
8267 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8270 (intern (format "gnus-newsgroup-%s"
8272 ;; Copy the marks to other group.
8273 (gnus-add-marked-articles
8274 to-group (cdar marks) (list to-article) info))
8275 (setq marks (cdr marks)))
8277 (gnus-request-set-mark to-group (list (list (list to-article)
8282 (concat "(gnus-group-set-info '"
8283 (gnus-prin1-to-string (gnus-get-info to-group))
8286 ;; Update the Xref header in this article to point to
8287 ;; the new crossposted article we have just created.
8288 (when (eq action 'crosspost)
8290 (set-buffer copy-buf)
8291 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8292 (nnheader-replace-header "Xref" new-xref)
8293 (gnus-request-replace-article
8294 article gnus-newsgroup-name (current-buffer)))))
8296 ;;;!!!Why is this necessary?
8297 (set-buffer gnus-summary-buffer)
8299 (gnus-summary-goto-subject article)
8300 (when (eq action 'move)
8301 (gnus-summary-mark-article article gnus-canceled-mark))))
8302 (gnus-summary-remove-process-mark article))
8303 ;; Re-activate all groups that have been moved to.
8306 (set-buffer gnus-group-buffer)
8307 (when (gnus-group-goto-group (car to-groups) t)
8308 (gnus-group-get-new-news-this-group 1 t))
8311 (gnus-kill-buffer copy-buf)
8312 (gnus-summary-position-point)
8313 (gnus-set-mode-line 'summary)))
8315 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8316 "Move the current article to a different newsgroup.
8317 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8318 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8319 re-spool using this method."
8321 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8323 (defun gnus-summary-crosspost-article (&optional n)
8324 "Crosspost the current article to some other group."
8326 (gnus-summary-move-article n nil nil 'crosspost))
8328 (defcustom gnus-summary-respool-default-method nil
8329 "Default method for respooling an article.
8330 If nil, use to the current newsgroup method."
8331 :type '(choice (gnus-select-method :value (nnml ""))
8333 :group 'gnus-summary-mail)
8335 (defun gnus-summary-respool-article (&optional n method)
8336 "Respool the current article.
8337 The article will be squeezed through the mail spooling process again,
8338 which means that it will be put in some mail newsgroup or other
8339 depending on `nnmail-split-methods'.
8340 If N is a positive number, respool the N next articles.
8341 If N is a negative number, respool the N previous articles.
8342 If N is nil and any articles have been marked with the process mark,
8343 respool those articles instead.
8345 Respooling can be done both from mail groups and \"real\" newsgroups.
8346 In the former case, the articles in question will be moved from the
8347 current group into whatever groups they are destined to. In the
8348 latter case, they will be copied into the relevant groups."
8350 (list current-prefix-arg
8351 (let* ((methods (gnus-methods-using 'respool))
8353 (symbol-name (or gnus-summary-respool-default-method
8354 (car (gnus-find-method-for-group
8355 gnus-newsgroup-name)))))
8357 (gnus-completing-read
8358 methname "What backend do you want to use when respooling?"
8359 methods nil t nil 'gnus-mail-method-history))
8362 ((zerop (length (setq ms (gnus-servers-using-backend
8364 (list (intern method) ""))
8368 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8369 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8372 (error "No method given for respooling"))
8373 (if (assoc (symbol-name
8374 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8375 (gnus-methods-using 'respool))
8376 (gnus-summary-move-article n nil method)
8377 (gnus-summary-copy-article n nil method)))
8379 (defun gnus-summary-import-article (file &optional edit)
8380 "Import an arbitrary file into a mail newsgroup."
8381 (interactive "fImport file: \nP")
8382 (let ((group gnus-newsgroup-name)
8383 (now (current-time))
8384 atts lines group-art)
8385 (unless (gnus-check-backend-function 'request-accept-article group)
8386 (error "%s does not support article importing" group))
8387 (or (file-readable-p file)
8388 (not (file-regular-p file))
8389 (error "Can't read %s" file))
8391 (set-buffer (gnus-get-buffer-create " *import file*"))
8393 (nnheader-insert-file-contents file)
8394 (goto-char (point-min))
8395 (if (nnheader-article-p)
8397 (goto-char (point-min))
8398 (search-forward "\n\n" nil t)
8399 (narrow-to-region (point-min) (1- (point)))
8400 (goto-char (point-min))
8401 (unless (re-search-forward "^date:" nil t)
8402 (goto-char (point-max))
8403 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8404 ;; This doesn't look like an article, so we fudge some headers.
8405 (setq atts (file-attributes file)
8406 lines (count-lines (point-min) (point-max)))
8407 (insert "From: " (read-string "From: ") "\n"
8408 "Subject: " (read-string "Subject: ") "\n"
8409 "Date: " (message-make-date (nth 5 atts)) "\n"
8410 "Message-ID: " (message-make-message-id) "\n"
8411 "Lines: " (int-to-string lines) "\n"
8412 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8413 (setq group-art (gnus-request-accept-article group nil t))
8414 (kill-buffer (current-buffer)))
8415 (setq gnus-newsgroup-active (gnus-activate-group group))
8417 (gnus-summary-goto-article (cdr group-art) nil t)
8419 (gnus-summary-edit-article))))
8421 (defun gnus-summary-create-article ()
8422 "Create an article in a mail newsgroup."
8424 (let ((group gnus-newsgroup-name)
8425 (now (current-time))
8427 (unless (gnus-check-backend-function 'request-accept-article group)
8428 (error "%s does not support article importing" group))
8430 (set-buffer (gnus-get-buffer-create " *import file*"))
8432 (goto-char (point-min))
8433 ;; This doesn't look like an article, so we fudge some headers.
8434 (insert "From: " (read-string "From: ") "\n"
8435 "Subject: " (read-string "Subject: ") "\n"
8436 "Date: " (message-make-date now) "\n"
8437 "Message-ID: " (message-make-message-id) "\n")
8438 (setq group-art (gnus-request-accept-article group nil t))
8439 (kill-buffer (current-buffer)))
8440 (setq gnus-newsgroup-active (gnus-activate-group group))
8442 (gnus-summary-goto-article (cdr group-art) nil t)
8443 (gnus-summary-edit-article)))
8445 (defun gnus-summary-article-posted-p ()
8446 "Say whether the current (mail) article is available from news as well.
8447 This will be the case if the article has both been mailed and posted."
8449 (let ((id (mail-header-references (gnus-summary-article-header)))
8450 (gnus-override-method (car (gnus-refer-article-methods))))
8451 (if (gnus-request-head id "")
8452 (gnus-message 2 "The current message was found on %s"
8453 gnus-override-method)
8454 (gnus-message 2 "The current message couldn't be found on %s"
8455 gnus-override-method)
8458 (defun gnus-summary-expire-articles (&optional now)
8459 "Expire all articles that are marked as expirable in the current group."
8461 (when (gnus-check-backend-function
8462 'request-expire-articles gnus-newsgroup-name)
8463 ;; This backend supports expiry.
8464 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8465 (expirable (if total
8467 ;; We need to update the info for
8468 ;; this group for `gnus-list-of-read-articles'
8469 ;; to give us the right answer.
8470 (gnus-run-hooks 'gnus-exit-group-hook)
8471 (gnus-summary-update-info)
8472 (gnus-list-of-read-articles gnus-newsgroup-name))
8473 (setq gnus-newsgroup-expirable
8474 (sort gnus-newsgroup-expirable '<))))
8475 (expiry-wait (if now 'immediate
8476 (gnus-group-find-parameter
8477 gnus-newsgroup-name 'expiry-wait)))
8478 (nnmail-expiry-target
8479 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8480 nnmail-expiry-target))
8483 ;; There are expirable articles in this group, so we run them
8484 ;; through the expiry process.
8485 (gnus-message 6 "Expiring articles...")
8486 (unless (gnus-check-group gnus-newsgroup-name)
8487 (error "Can't open server for %s" gnus-newsgroup-name))
8488 ;; The list of articles that weren't expired is returned.
8491 (let ((nnmail-expiry-wait-function nil)
8492 (nnmail-expiry-wait expiry-wait))
8493 (setq es (gnus-request-expire-articles
8494 expirable gnus-newsgroup-name)))
8495 (setq es (gnus-request-expire-articles
8496 expirable gnus-newsgroup-name)))
8498 (setq gnus-newsgroup-expirable es))
8499 ;; We go through the old list of expirable, and mark all
8500 ;; really expired articles as nonexistent.
8501 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8502 (let ((gnus-use-cache nil))
8504 (unless (memq (car expirable) es)
8505 (when (gnus-data-find (car expirable))
8506 (gnus-summary-mark-article
8507 (car expirable) gnus-canceled-mark)))
8508 (setq expirable (cdr expirable))))))
8509 (gnus-message 6 "Expiring articles...done")))))
8511 (defun gnus-summary-expire-articles-now ()
8512 "Expunge all expirable articles in the current group.
8513 This means that *all* articles that are marked as expirable will be
8514 deleted forever, right now."
8516 (or gnus-expert-user
8518 "Are you really, really, really sure you want to delete all these messages? ")
8520 (gnus-summary-expire-articles t))
8522 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8523 (defun gnus-summary-delete-article (&optional n)
8524 "Delete the N next (mail) articles.
8525 This command actually deletes articles. This is not a marking
8526 command. The article will disappear forever from your life, never to
8528 If N is negative, delete backwards.
8529 If N is nil and articles have been marked with the process mark,
8530 delete these instead."
8532 (unless (gnus-check-backend-function 'request-expire-articles
8533 gnus-newsgroup-name)
8534 (error "The current newsgroup does not support article deletion"))
8535 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8536 (error "Couldn't open server"))
8537 ;; Compute the list of articles to delete.
8538 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8540 (if (and gnus-novice-user
8541 (not (gnus-yes-or-no-p
8542 (format "Do you really want to delete %s forever? "
8543 (if (> (length articles) 1)
8544 (format "these %s articles" (length articles))
8547 ;; Delete the articles.
8548 (setq not-deleted (gnus-request-expire-articles
8549 articles gnus-newsgroup-name 'force))
8551 (gnus-summary-remove-process-mark (car articles))
8552 ;; The backend might not have been able to delete the article
8554 (unless (memq (car articles) not-deleted)
8555 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8556 (setq articles (cdr articles)))
8558 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8559 (gnus-summary-position-point)
8560 (gnus-set-mode-line 'summary)
8563 (defun gnus-summary-edit-article (&optional force)
8564 "Edit the current article.
8565 This will have permanent effect only in mail groups.
8566 If FORCE is non-nil, allow editing of articles even in read-only
8570 (set-buffer gnus-summary-buffer)
8571 (let ((mail-parse-charset gnus-newsgroup-charset)
8572 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8573 (gnus-set-global-variables)
8574 (when (and (not force)
8575 (gnus-group-read-only-p))
8576 (error "The current newsgroup does not support article editing"))
8577 (gnus-summary-show-article t)
8578 (gnus-article-edit-article
8580 `(lambda (no-highlight)
8581 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8582 (message-options message-options)
8583 (message-options-set-recipient)
8584 (mail-parse-ignored-charsets
8585 ',gnus-newsgroup-ignored-charsets))
8586 (gnus-summary-edit-article-done
8587 ,(or (mail-header-references gnus-current-headers) "")
8588 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8590 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8592 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8594 "Make edits to the current article permanent."
8597 ;; The buffer restriction contains the entire article if it exists.
8598 (when (article-goto-body)
8599 (let ((lines (count-lines (point) (point-max)))
8600 (length (- (point-max) (point)))
8601 (case-fold-search t)
8602 (body (copy-marker (point))))
8603 (goto-char (point-min))
8604 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8605 (delete-region (match-beginning 1) (match-end 1))
8606 (insert (number-to-string length)))
8607 (goto-char (point-min))
8608 (when (re-search-forward
8609 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8610 (delete-region (match-beginning 1) (match-end 1))
8611 (insert (number-to-string length)))
8612 (goto-char (point-min))
8613 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8614 (delete-region (match-beginning 1) (match-end 1))
8615 (insert (number-to-string lines))))))
8616 ;; Replace the article.
8617 (let ((buf (current-buffer)))
8619 (insert-buffer-substring buf)
8621 (if (and (not read-only)
8622 (not (gnus-request-replace-article
8623 (cdr gnus-article-current) (car gnus-article-current)
8624 (current-buffer) t)))
8625 (error "Couldn't replace article")
8626 ;; Update the summary buffer.
8628 (equal (message-tokenize-header references " ")
8629 (message-tokenize-header
8630 (or (message-fetch-field "references") "") " ")))
8631 ;; We only have to update this line.
8634 (message-narrow-to-head)
8635 (let ((head (buffer-string))
8638 (insert (format "211 %d Article retrieved.\n"
8639 (cdr gnus-article-current)))
8642 (let ((nntp-server-buffer (current-buffer)))
8643 (setq header (car (gnus-get-newsgroup-headers
8645 (set-buffer gnus-summary-buffer)
8646 gnus-newsgroup-dependencies)
8649 (set-buffer gnus-summary-buffer)
8650 (gnus-data-set-header
8651 (gnus-data-find (cdr gnus-article-current))
8653 (gnus-summary-update-article-line
8654 (cdr gnus-article-current) header)
8655 (if (gnus-summary-goto-subject
8656 (cdr gnus-article-current) nil t)
8657 (gnus-summary-update-secondary-mark
8658 (cdr gnus-article-current))))))))
8660 (set-buffer (or buffer gnus-summary-buffer))
8661 (gnus-summary-update-article (cdr gnus-article-current))
8662 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8663 (gnus-summary-update-secondary-mark
8664 (cdr gnus-article-current))))
8665 ;; Prettify the article buffer again.
8666 (unless no-highlight
8668 (set-buffer gnus-article-buffer)
8669 ;;;!!! Fix this -- article should be rehighlighted.
8670 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8671 (set-buffer gnus-original-article-buffer)
8672 (gnus-request-article
8673 (cdr gnus-article-current)
8674 (car gnus-article-current) (current-buffer))))
8675 ;; Prettify the summary buffer line.
8676 (when (gnus-visual-p 'summary-highlight 'highlight)
8677 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8679 (defun gnus-summary-edit-wash (key)
8680 "Perform editing command KEY in the article buffer."
8684 (message "%s" (concat (this-command-keys) "- "))
8687 (gnus-summary-edit-article)
8688 (execute-kbd-macro (concat (this-command-keys) key))
8689 (gnus-article-edit-done))
8693 (defun gnus-summary-respool-query (&optional silent trace)
8694 "Query where the respool algorithm would put this article."
8696 (let (gnus-mark-article-hook)
8697 (gnus-summary-select-article)
8699 (set-buffer gnus-original-article-buffer)
8701 (message-narrow-to-head)
8702 (let ((groups (nnmail-article-group 'identity trace)))
8705 (message "This message would go to %s"
8706 (mapconcat 'car groups ", "))
8707 (message "This message would go to no groups"))
8710 (defun gnus-summary-respool-trace ()
8711 "Trace where the respool algorithm would put this article.
8712 Display a buffer showing all fancy splitting patterns which matched."
8714 (gnus-summary-respool-query nil t))
8716 ;; Summary marking commands.
8718 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8719 "Mark articles which has the same subject as read, and then select the next.
8720 If UNMARK is positive, remove any kind of mark.
8721 If UNMARK is negative, tick articles."
8724 (setq unmark (prefix-numeric-value unmark)))
8726 (gnus-summary-mark-same-subject
8727 (gnus-summary-article-subject) unmark)))
8728 ;; Select next unread article. If auto-select-same mode, should
8729 ;; select the first unread article.
8730 (gnus-summary-next-article t (and gnus-auto-select-same
8731 (gnus-summary-article-subject)))
8732 (gnus-message 7 "%d article%s marked as %s"
8733 count (if (= count 1) " is" "s are")
8734 (if unmark "unread" "read"))))
8736 (defun gnus-summary-kill-same-subject (&optional unmark)
8737 "Mark articles which has the same subject as read.
8738 If UNMARK is positive, remove any kind of mark.
8739 If UNMARK is negative, tick articles."
8742 (setq unmark (prefix-numeric-value unmark)))
8744 (gnus-summary-mark-same-subject
8745 (gnus-summary-article-subject) unmark)))
8746 ;; If marked as read, go to next unread subject.
8748 ;; Go to next unread subject.
8749 (gnus-summary-next-subject 1 t))
8750 (gnus-message 7 "%d articles are marked as %s"
8751 count (if unmark "unread" "read"))))
8753 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8754 "Mark articles with same SUBJECT as read, and return marked number.
8755 If optional argument UNMARK is positive, remove any kinds of marks.
8756 If optional argument UNMARK is negative, mark articles as unread instead."
8760 ((null unmark) ; Mark as read.
8763 (gnus-summary-mark-article-as-read gnus-killed-mark)
8764 (gnus-summary-show-thread) t)
8765 (gnus-summary-find-subject subject))
8766 (setq count (1+ count))))
8767 ((> unmark 0) ; Tick.
8770 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8771 (gnus-summary-show-thread) t)
8772 (gnus-summary-find-subject subject))
8773 (setq count (1+ count))))
8774 (t ; Mark as unread.
8777 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8778 (gnus-summary-show-thread) t)
8779 (gnus-summary-find-subject subject))
8780 (setq count (1+ count)))))
8781 (gnus-set-mode-line 'summary)
8782 ;; Return the number of marked articles.
8785 (defun gnus-summary-mark-as-processable (n &optional unmark)
8786 "Set the process mark on the next N articles.
8787 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8788 the process mark instead. The difference between N and the actual
8789 number of articles marked is returned."
8791 (if (and (null n) (gnus-region-active-p))
8792 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8793 (setq n (prefix-numeric-value n))
8794 (let ((backward (< n 0))
8799 (gnus-summary-remove-process-mark
8800 (gnus-summary-article-number))
8801 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8802 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8805 (gnus-message 7 "No more articles"))
8806 (gnus-summary-recenter)
8807 (gnus-summary-position-point)
8810 (defun gnus-summary-unmark-as-processable (n)
8811 "Remove the process mark from the next N articles.
8812 If N is negative, unmark backward instead. The difference between N and
8813 the actual number of articles unmarked is returned."
8815 (gnus-summary-mark-as-processable n t))
8817 (defun gnus-summary-unmark-all-processable ()
8818 "Remove the process mark from all articles."
8821 (while gnus-newsgroup-processable
8822 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8823 (gnus-summary-position-point))
8825 (defun gnus-summary-add-mark (article type)
8826 "Mark ARTICLE with a mark of TYPE."
8827 (let ((vtype (car (assq type gnus-article-mark-lists)))
8830 (error "No such mark type: %s" type)
8831 (setq var (intern (format "gnus-newsgroup-%s" type)))
8832 (set var (cons article (symbol-value var)))
8833 (if (memq type '(processable cached replied forwarded recent saved))
8834 (gnus-summary-update-secondary-mark article)
8835 ;;; !!! This is bogus. We should find out what primary
8836 ;;; !!! mark we want to set.
8837 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8839 (defun gnus-summary-mark-as-expirable (n)
8840 "Mark N articles forward as expirable.
8841 If N is negative, mark backward instead. The difference between N and
8842 the actual number of articles marked is returned."
8844 (gnus-summary-mark-forward n gnus-expirable-mark))
8846 (defun gnus-summary-mark-article-as-replied (article)
8847 "Mark ARTICLE as replied to and update the summary line.
8848 ARTICLE can also be a list of articles."
8849 (interactive (list (gnus-summary-article-number)))
8850 (let ((articles (if (listp article) article (list article))))
8851 (dolist (article articles)
8852 (push article gnus-newsgroup-replied)
8853 (let ((buffer-read-only nil))
8854 (when (gnus-summary-goto-subject article nil t)
8855 (gnus-summary-update-secondary-mark article))))))
8857 (defun gnus-summary-mark-article-as-forwarded (article)
8858 "Mark ARTICLE as forwarded and update the summary line.
8859 ARTICLE can also be a list of articles."
8860 (let ((articles (if (listp article) article (list article))))
8861 (dolist (article articles)
8862 (push article gnus-newsgroup-forwarded)
8863 (let ((buffer-read-only nil))
8864 (when (gnus-summary-goto-subject article nil t)
8865 (gnus-summary-update-secondary-mark article))))))
8867 (defun gnus-summary-set-bookmark (article)
8868 "Set a bookmark in current article."
8869 (interactive (list (gnus-summary-article-number)))
8870 (when (or (not (get-buffer gnus-article-buffer))
8871 (not gnus-current-article)
8872 (not gnus-article-current)
8873 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8874 (error "No current article selected"))
8875 ;; Remove old bookmark, if one exists.
8876 (let ((old (assq article gnus-newsgroup-bookmarks)))
8878 (setq gnus-newsgroup-bookmarks
8879 (delq old gnus-newsgroup-bookmarks))))
8880 ;; Set the new bookmark, which is on the form
8881 ;; (article-number . line-number-in-body).
8885 (set-buffer gnus-article-buffer)
8889 (goto-char (point-min))
8890 (search-forward "\n\n" nil t)
8893 gnus-newsgroup-bookmarks)
8894 (gnus-message 6 "A bookmark has been added to the current article."))
8896 (defun gnus-summary-remove-bookmark (article)
8897 "Remove the bookmark from the current article."
8898 (interactive (list (gnus-summary-article-number)))
8899 ;; Remove old bookmark, if one exists.
8900 (let ((old (assq article gnus-newsgroup-bookmarks)))
8903 (setq gnus-newsgroup-bookmarks
8904 (delq old gnus-newsgroup-bookmarks))
8905 (gnus-message 6 "Removed bookmark."))
8906 (gnus-message 6 "No bookmark in current article."))))
8908 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8909 (defun gnus-summary-mark-as-dormant (n)
8910 "Mark N articles forward as dormant.
8911 If N is negative, mark backward instead. The difference between N and
8912 the actual number of articles marked is returned."
8914 (gnus-summary-mark-forward n gnus-dormant-mark))
8916 (defun gnus-summary-set-process-mark (article)
8917 "Set the process mark on ARTICLE and update the summary line."
8918 (setq gnus-newsgroup-processable
8920 (delq article gnus-newsgroup-processable)))
8921 (when (gnus-summary-goto-subject article)
8922 (gnus-summary-show-thread)
8923 (gnus-summary-goto-subject article)
8924 (gnus-summary-update-secondary-mark article)))
8926 (defun gnus-summary-remove-process-mark (article)
8927 "Remove the process mark from ARTICLE and update the summary line."
8928 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8929 (when (gnus-summary-goto-subject article)
8930 (gnus-summary-show-thread)
8931 (gnus-summary-goto-subject article)
8932 (gnus-summary-update-secondary-mark article)))
8934 (defun gnus-summary-set-saved-mark (article)
8935 "Set the process mark on ARTICLE and update the summary line."
8936 (push article gnus-newsgroup-saved)
8937 (when (gnus-summary-goto-subject article)
8938 (gnus-summary-update-secondary-mark article)))
8940 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8941 "Mark N articles as read forwards.
8942 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8943 The difference between N and the actual number of articles marked is
8945 Iff NO-EXPIRE, auto-expiry will be inhibited."
8947 (gnus-summary-show-thread)
8948 (let ((backward (< n 0))
8949 (gnus-summary-goto-unread
8950 (and gnus-summary-goto-unread
8951 (not (eq gnus-summary-goto-unread 'never))
8952 (not (memq mark (list gnus-unread-mark
8953 gnus-ticked-mark gnus-dormant-mark)))))
8955 (mark (or mark gnus-del-mark)))
8957 (gnus-summary-mark-article nil mark no-expire)
8958 (zerop (gnus-summary-next-subject
8960 (and gnus-summary-goto-unread
8961 (not (eq gnus-summary-goto-unread 'never)))
8965 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8966 (gnus-summary-recenter)
8967 (gnus-summary-position-point)
8968 (gnus-set-mode-line 'summary)
8971 (defun gnus-summary-mark-article-as-read (mark)
8972 "Mark the current article quickly as read with MARK."
8973 (let ((article (gnus-summary-article-number)))
8974 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8975 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8976 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8977 (push (cons article mark) gnus-newsgroup-reads)
8978 ;; Possibly remove from cache, if that is used.
8979 (when gnus-use-cache
8980 (gnus-cache-enter-remove-article article))
8981 ;; Allow the backend to change the mark.
8982 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8983 ;; Check for auto-expiry.
8984 (when (and gnus-newsgroup-auto-expire
8985 (memq mark gnus-auto-expirable-marks))
8986 (setq mark gnus-expirable-mark)
8987 ;; Let the backend know about the mark change.
8988 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8989 (push article gnus-newsgroup-expirable))
8990 ;; Set the mark in the buffer.
8991 (gnus-summary-update-mark mark 'unread)
8994 (defun gnus-summary-mark-article-as-unread (mark)
8995 "Mark the current article quickly as unread with MARK."
8996 (let* ((article (gnus-summary-article-number))
8997 (old-mark (gnus-summary-article-mark article)))
8998 ;; Allow the backend to change the mark.
8999 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9000 (if (eq mark old-mark)
9004 (gnus-error 1 "Can't mark negative article numbers")
9006 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9007 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9008 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9009 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9010 (cond ((= mark gnus-ticked-mark)
9011 (push article gnus-newsgroup-marked))
9012 ((= mark gnus-dormant-mark)
9013 (push article gnus-newsgroup-dormant))
9015 (push article gnus-newsgroup-unreads)))
9016 (gnus-pull article gnus-newsgroup-reads)
9018 ;; See whether the article is to be put in the cache.
9020 (vectorp (gnus-summary-article-header article))
9022 (gnus-cache-possibly-enter-article
9023 gnus-newsgroup-name article
9024 (gnus-summary-article-header article)
9025 (= mark gnus-ticked-mark)
9026 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9029 (gnus-summary-update-mark mark 'unread)
9032 (defun gnus-summary-mark-article (&optional article mark no-expire)
9033 "Mark ARTICLE with MARK. MARK can be any character.
9034 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9035 `??' (dormant) and `?E' (expirable).
9036 If MARK is nil, then the default character `?r' is used.
9037 If ARTICLE is nil, then the article on the current line will be
9039 Iff NO-EXPIRE, auto-expiry will be inhibited."
9040 ;; The mark might be a string.
9041 (when (stringp mark)
9042 (setq mark (aref mark 0)))
9043 ;; If no mark is given, then we check auto-expiring.
9045 (setq mark gnus-del-mark))
9046 (when (and (not no-expire)
9047 gnus-newsgroup-auto-expire
9048 (memq mark gnus-auto-expirable-marks))
9049 (setq mark gnus-expirable-mark))
9050 (let ((article (or article (gnus-summary-article-number)))
9051 (old-mark (gnus-summary-article-mark article)))
9052 ;; Allow the backend to change the mark.
9053 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9054 (if (eq mark old-mark)
9057 (error "No article on current line"))
9058 (if (not (if (or (= mark gnus-unread-mark)
9059 (= mark gnus-ticked-mark)
9060 (= mark gnus-dormant-mark))
9061 (gnus-mark-article-as-unread article mark)
9062 (gnus-mark-article-as-read article mark)))
9064 ;; See whether the article is to be put in the cache.
9066 (not (= mark gnus-canceled-mark))
9067 (vectorp (gnus-summary-article-header article))
9069 (gnus-cache-possibly-enter-article
9070 gnus-newsgroup-name article
9071 (gnus-summary-article-header article)
9072 (= mark gnus-ticked-mark)
9073 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9075 (when (gnus-summary-goto-subject article nil t)
9076 (let ((buffer-read-only nil))
9077 (gnus-summary-show-thread)
9079 (gnus-summary-update-mark mark 'unread)
9082 (defun gnus-summary-update-secondary-mark (article)
9083 "Update the secondary (read, process, cache) mark."
9084 (gnus-summary-update-mark
9085 (cond ((memq article gnus-newsgroup-processable)
9087 ((memq article gnus-newsgroup-cached)
9089 ((memq article gnus-newsgroup-replied)
9091 ((memq article gnus-newsgroup-forwarded)
9092 gnus-forwarded-mark)
9093 ((memq article gnus-newsgroup-saved)
9095 ((memq article gnus-newsgroup-recent)
9097 ((memq article gnus-newsgroup-unseen)
9101 (when (gnus-visual-p 'summary-highlight 'highlight)
9102 (gnus-run-hooks 'gnus-summary-update-hook))
9105 (defun gnus-summary-update-mark (mark type)
9106 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9107 (buffer-read-only nil))
9108 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9110 (when (looking-at "\r")
9112 (when (<= (+ forward (point)) (point-max))
9113 ;; Go to the right position on the line.
9114 (goto-char (+ forward (point)))
9115 ;; Replace the old mark with the new mark.
9116 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9117 ;; Optionally update the marks by some user rule.
9118 (when (eq type 'unread)
9120 (gnus-data-find (gnus-summary-article-number)) mark)
9121 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9123 (defun gnus-mark-article-as-read (article &optional mark)
9124 "Enter ARTICLE in the pertinent lists and remove it from others."
9125 ;; Make the article expirable.
9126 (let ((mark (or mark gnus-del-mark)))
9127 (if (= mark gnus-expirable-mark)
9128 (push article gnus-newsgroup-expirable)
9129 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9130 ;; Remove from unread and marked lists.
9131 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9132 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9133 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9134 (push (cons article mark) gnus-newsgroup-reads)
9135 ;; Possibly remove from cache, if that is used.
9136 (when gnus-use-cache
9137 (gnus-cache-enter-remove-article article))
9140 (defun gnus-mark-article-as-unread (article &optional mark)
9141 "Enter ARTICLE in the pertinent lists and remove it from others."
9142 (let ((mark (or mark gnus-ticked-mark)))
9145 (gnus-error 1 "Can't mark negative article numbers")
9147 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9148 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9149 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9150 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9152 ;; Unsuppress duplicates?
9153 (when gnus-suppress-duplicates
9154 (gnus-dup-unsuppress-article article))
9156 (cond ((= mark gnus-ticked-mark)
9157 (push article gnus-newsgroup-marked))
9158 ((= mark gnus-dormant-mark)
9159 (push article gnus-newsgroup-dormant))
9161 (push article gnus-newsgroup-unreads)))
9162 (gnus-pull article gnus-newsgroup-reads)
9165 (defalias 'gnus-summary-mark-as-unread-forward
9166 'gnus-summary-tick-article-forward)
9167 (make-obsolete 'gnus-summary-mark-as-unread-forward
9168 'gnus-summary-tick-article-forward)
9169 (defun gnus-summary-tick-article-forward (n)
9170 "Tick N articles forwards.
9171 If N is negative, tick backwards instead.
9172 The difference between N and the number of articles ticked is returned."
9174 (gnus-summary-mark-forward n gnus-ticked-mark))
9176 (defalias 'gnus-summary-mark-as-unread-backward
9177 'gnus-summary-tick-article-backward)
9178 (make-obsolete 'gnus-summary-mark-as-unread-backward
9179 'gnus-summary-tick-article-backward)
9180 (defun gnus-summary-tick-article-backward (n)
9181 "Tick N articles backwards.
9182 The difference between N and the number of articles ticked is returned."
9184 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9186 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9187 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9188 (defun gnus-summary-tick-article (&optional article clear-mark)
9189 "Mark current article as unread.
9190 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9191 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9193 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9196 (defun gnus-summary-mark-as-read-forward (n)
9197 "Mark N articles as read forwards.
9198 If N is negative, mark backwards instead.
9199 The difference between N and the actual number of articles marked is
9202 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9204 (defun gnus-summary-mark-as-read-backward (n)
9205 "Mark the N articles as read backwards.
9206 The difference between N and the actual number of articles marked is
9209 (gnus-summary-mark-forward
9210 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9212 (defun gnus-summary-mark-as-read (&optional article mark)
9213 "Mark current article as read.
9214 ARTICLE specifies the article to be marked as read.
9215 MARK specifies a string to be inserted at the beginning of the line."
9216 (gnus-summary-mark-article article mark))
9218 (defun gnus-summary-clear-mark-forward (n)
9219 "Clear marks from N articles forward.
9220 If N is negative, clear backward instead.
9221 The difference between N and the number of marks cleared is returned."
9223 (gnus-summary-mark-forward n gnus-unread-mark))
9225 (defun gnus-summary-clear-mark-backward (n)
9226 "Clear marks from N articles backward.
9227 The difference between N and the number of marks cleared is returned."
9229 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9231 (defun gnus-summary-mark-unread-as-read ()
9232 "Intended to be used by `gnus-summary-mark-article-hook'."
9233 (when (memq gnus-current-article gnus-newsgroup-unreads)
9234 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9236 (defun gnus-summary-mark-read-and-unread-as-read ()
9237 "Intended to be used by `gnus-summary-mark-article-hook'."
9238 (let ((mark (gnus-summary-article-mark)))
9239 (when (or (gnus-unread-mark-p mark)
9240 (gnus-read-mark-p mark))
9241 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9243 (defun gnus-summary-mark-unread-as-ticked ()
9244 "Intended to be used by `gnus-summary-mark-article-hook'."
9245 (when (memq gnus-current-article gnus-newsgroup-unreads)
9246 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9248 (defun gnus-summary-mark-region-as-read (point mark all)
9249 "Mark all unread articles between point and mark as read.
9250 If given a prefix, mark all articles between point and mark as read,
9251 even ticked and dormant ones."
9252 (interactive "r\nP")
9261 (memq (setq article (gnus-summary-article-number))
9262 gnus-newsgroup-unreads))
9263 (gnus-summary-mark-article article gnus-del-mark))
9265 (gnus-summary-find-next))))))
9267 (defun gnus-summary-mark-below (score mark)
9268 "Mark articles with score less than SCORE with MARK."
9269 (interactive "P\ncMark: ")
9270 (setq score (if score
9271 (prefix-numeric-value score)
9272 (or gnus-summary-default-score 0)))
9274 (set-buffer gnus-summary-buffer)
9275 (goto-char (point-min))
9278 (and (< (gnus-summary-article-score) score)
9279 (gnus-summary-mark-article nil mark))
9280 (gnus-summary-find-next)))))
9282 (defun gnus-summary-kill-below (&optional score)
9283 "Mark articles with score below SCORE as read."
9285 (gnus-summary-mark-below score gnus-killed-mark))
9287 (defun gnus-summary-clear-above (&optional score)
9288 "Clear all marks from articles with score above SCORE."
9290 (gnus-summary-mark-above score gnus-unread-mark))
9292 (defun gnus-summary-tick-above (&optional score)
9293 "Tick all articles with score above SCORE."
9295 (gnus-summary-mark-above score gnus-ticked-mark))
9297 (defun gnus-summary-mark-above (score mark)
9298 "Mark articles with score over SCORE with MARK."
9299 (interactive "P\ncMark: ")
9300 (setq score (if score
9301 (prefix-numeric-value score)
9302 (or gnus-summary-default-score 0)))
9304 (set-buffer gnus-summary-buffer)
9305 (goto-char (point-min))
9307 (when (> (gnus-summary-article-score) score)
9308 (gnus-summary-mark-article nil mark))
9310 (gnus-summary-find-next)))))
9312 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9313 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9314 (defun gnus-summary-limit-include-expunged (&optional no-error)
9315 "Display all the hidden articles that were expunged for low scores."
9317 (let ((buffer-read-only nil))
9318 (let ((scored gnus-newsgroup-scored)
9321 (unless (gnus-summary-article-header (caar scored))
9322 (and (setq h (gnus-number-to-header (caar scored)))
9323 (< (cdar scored) gnus-summary-expunge-below)
9325 (setq scored (cdr scored)))
9327 (when (not no-error)
9328 (error "No expunged articles hidden"))
9329 (goto-char (point-min))
9330 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9331 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9332 (mapcar (lambda (x) (push (mail-header-number x)
9333 gnus-newsgroup-limit))
9335 (gnus-summary-prepare-unthreaded (nreverse headers))
9336 (goto-char (point-min))
9337 (gnus-summary-position-point)
9340 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9341 "Mark all unread articles in this newsgroup as read.
9342 If prefix argument ALL is non-nil, ticked and dormant articles will
9343 also be marked as read.
9344 If QUIETLY is non-nil, no questions will be asked.
9345 If TO-HERE is non-nil, it should be a point in the buffer. All
9346 articles before (after, if REVERSE is set) this point will be marked as read.
9347 Note that this function will only catch up the unread article
9348 in the current summary buffer limitation.
9349 The number of articles marked as read is returned."
9354 (not gnus-interactive-catchup) ;Without confirmation?
9358 "Mark absolutely all articles as read? "
9359 "Mark all unread articles as read? ")))
9361 (not gnus-newsgroup-adaptive)
9362 (not gnus-newsgroup-auto-expire)
9363 (not gnus-suppress-duplicates)
9364 (or (not gnus-use-cache)
9365 (eq gnus-use-cache 'passive)))
9368 (setq gnus-newsgroup-marked nil
9369 gnus-newsgroup-dormant nil))
9370 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9371 ;; We actually mark all articles as canceled, which we
9372 ;; have to do when using auto-expiry or adaptive scoring.
9373 (gnus-summary-show-all-threads)
9374 (if (and to-here reverse)
9378 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9379 (gnus-summary-find-next (not all) nil nil t))))
9380 (when (gnus-summary-first-subject (not all) t)
9382 (if to-here (< (point) to-here) t)
9383 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9384 (gnus-summary-find-next (not all) nil nil t)))))
9385 (gnus-set-mode-line 'summary))
9387 (gnus-summary-position-point)))
9389 (defun gnus-summary-catchup-to-here (&optional all)
9390 "Mark all unticked articles before the current one as read.
9391 If ALL is non-nil, also mark ticked and dormant articles as read."
9394 (gnus-save-hidden-threads
9395 (let ((beg (point)))
9396 ;; We check that there are unread articles.
9397 (when (or all (gnus-summary-find-prev))
9398 (gnus-summary-catchup all t beg)))))
9399 (gnus-summary-position-point))
9401 (defun gnus-summary-catchup-from-here (&optional all)
9402 "Mark all unticked articles after the current one as read.
9403 If ALL is non-nil, also mark ticked and dormant articles as read."
9406 (gnus-save-hidden-threads
9407 (let ((beg (point)))
9408 ;; We check that there are unread articles.
9409 (when (or all (gnus-summary-find-next))
9410 (gnus-summary-catchup all t beg nil t)))))
9411 (gnus-summary-position-point))
9413 (defun gnus-summary-catchup-all (&optional quietly)
9414 "Mark all articles in this newsgroup as read."
9416 (gnus-summary-catchup t quietly))
9418 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9419 "Mark all unread articles in this group as read, then exit.
9420 If prefix argument ALL is non-nil, all articles are marked as read.
9421 If QUIETLY is non-nil, no questions will be asked."
9423 (when (gnus-summary-catchup all quietly nil 'fast)
9424 ;; Select next newsgroup or exit.
9425 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9426 (eq gnus-auto-select-next 'quietly))
9427 (gnus-summary-next-group nil)
9428 (gnus-summary-exit))))
9430 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9431 "Mark all articles in this newsgroup as read, and then exit."
9433 (gnus-summary-catchup-and-exit t quietly))
9435 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9436 "Mark all articles in this group as read and select the next group.
9437 If given a prefix, mark all articles, unread as well as ticked, as
9441 (gnus-summary-catchup all))
9442 (gnus-summary-next-group))
9448 (defmacro gnus-with-article (article &rest forms)
9449 "Select ARTICLE and perform FORMS in the original article buffer.
9450 Then replace the article with the result."
9452 ;; We don't want the article to be marked as read.
9453 (let (gnus-mark-article-hook)
9454 (gnus-summary-select-article t t nil ,article))
9455 (set-buffer gnus-original-article-buffer)
9457 (if (not (gnus-check-backend-function
9458 'request-replace-article (car gnus-article-current)))
9459 (gnus-message 5 "Read-only group; not replacing")
9460 (unless (gnus-request-replace-article
9461 ,article (car gnus-article-current)
9463 (error "Couldn't replace article")))
9464 ;; The cache and backlog have to be flushed somewhat.
9465 (when gnus-keep-backlog
9466 (gnus-backlog-remove-article
9467 (car gnus-article-current) (cdr gnus-article-current)))
9468 (when gnus-use-cache
9469 (gnus-cache-update-article
9470 (car gnus-article-current) (cdr gnus-article-current)))))
9472 (put 'gnus-with-article 'lisp-indent-function 1)
9473 (put 'gnus-with-article 'edebug-form-spec '(form body))
9475 ;; Thread-based commands.
9477 (defun gnus-summary-articles-in-thread (&optional article)
9478 "Return a list of all articles in the current thread.
9479 If ARTICLE is non-nil, return all articles in the thread that starts
9481 (let* ((article (or article (gnus-summary-article-number)))
9482 (data (gnus-data-find-list article))
9483 (top-level (gnus-data-level (car data)))
9485 (cond ((null gnus-thread-operation-ignore-subject)
9486 (gnus-simplify-subject-re
9487 (mail-header-subject (gnus-data-header (car data)))))
9488 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9489 (gnus-simplify-subject-fuzzy
9490 (mail-header-subject (gnus-data-header (car data)))))
9492 (end-point (save-excursion
9493 (if (gnus-summary-go-to-next-thread)
9494 (point) (point-max))))
9497 (< (gnus-data-pos (car data)) end-point))
9498 (when (or (not top-subject)
9499 (string= top-subject
9500 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9501 (gnus-simplify-subject-fuzzy
9502 (mail-header-subject
9503 (gnus-data-header (car data))))
9504 (gnus-simplify-subject-re
9505 (mail-header-subject
9506 (gnus-data-header (car data)))))))
9507 (push (gnus-data-number (car data)) articles))
9508 (unless (and (setq data (cdr data))
9509 (> (gnus-data-level (car data)) top-level))
9511 ;; Return the list of articles.
9512 (nreverse articles)))
9514 (defun gnus-summary-rethread-current ()
9515 "Rethread the thread the current article is part of."
9517 (let* ((gnus-show-threads t)
9518 (article (gnus-summary-article-number))
9519 (id (mail-header-id (gnus-summary-article-header)))
9520 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9522 (error "No article on the current line"))
9523 (gnus-rebuild-thread id)
9524 (gnus-summary-goto-subject article)))
9526 (defun gnus-summary-reparent-thread ()
9527 "Make the current article child of the marked (or previous) article.
9529 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9530 is non-nil or the Subject: of both articles are the same."
9532 (unless (not (gnus-group-read-only-p))
9533 (error "The current newsgroup does not support article editing"))
9534 (unless (<= (length gnus-newsgroup-processable) 1)
9535 (error "No more than one article may be marked"))
9536 (save-window-excursion
9537 (let ((gnus-article-buffer " *reparent*")
9538 (current-article (gnus-summary-article-number))
9539 ;; First grab the marked article, otherwise one line up.
9540 (parent-article (if (not (null gnus-newsgroup-processable))
9541 (car gnus-newsgroup-processable)
9543 (if (eq (forward-line -1) 0)
9544 (gnus-summary-article-number)
9545 (error "Beginning of summary buffer"))))))
9546 (unless (not (eq current-article parent-article))
9547 (error "An article may not be self-referential"))
9548 (let ((message-id (mail-header-id
9549 (gnus-summary-article-header parent-article))))
9550 (unless (and message-id (not (equal message-id "")))
9551 (error "No message-id in desired parent"))
9552 (gnus-with-article current-article
9554 (goto-char (point-min))
9555 (message-narrow-to-head)
9556 (if (re-search-forward "^References: " nil t)
9558 (re-search-forward "^[^ \t]" nil t)
9561 (insert " " message-id))
9562 (insert "References: " message-id "\n"))))
9563 (set-buffer gnus-summary-buffer)
9564 (gnus-summary-unmark-all-processable)
9565 (gnus-summary-update-article current-article)
9566 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9567 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9568 (gnus-summary-rethread-current)
9569 (gnus-message 3 "Article %d is now the child of article %d"
9570 current-article parent-article)))))
9572 (defun gnus-summary-toggle-threads (&optional arg)
9573 "Toggle showing conversation threads.
9574 If ARG is positive number, turn showing conversation threads on."
9576 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9577 (setq gnus-show-threads
9578 (if (null arg) (not gnus-show-threads)
9579 (> (prefix-numeric-value arg) 0)))
9580 (gnus-summary-prepare)
9581 (gnus-summary-goto-subject current)
9582 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9583 (gnus-summary-position-point)))
9585 (defun gnus-summary-show-all-threads ()
9589 (let ((buffer-read-only nil))
9590 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9591 (gnus-summary-position-point))
9593 (defun gnus-summary-show-thread ()
9594 "Show thread subtrees.
9595 Returns nil if no thread was there to be shown."
9597 (let ((buffer-read-only nil)
9599 ;; first goto end then to beg, to have point at beg after let
9600 (end (progn (end-of-line) (point)))
9601 (beg (progn (beginning-of-line) (point))))
9603 ;; Any hidden lines here?
9604 (search-forward "\r" end t)
9605 (subst-char-in-region beg end ?\^M ?\n t)
9607 (gnus-summary-position-point))))
9609 (defun gnus-summary-hide-all-threads ()
9610 "Hide all thread subtrees."
9613 (goto-char (point-min))
9614 (gnus-summary-hide-thread)
9615 (while (zerop (gnus-summary-next-thread 1 t))
9616 (gnus-summary-hide-thread)))
9617 (gnus-summary-position-point))
9619 (defun gnus-summary-hide-thread ()
9620 "Hide thread subtrees.
9621 Returns nil if no threads were there to be hidden."
9623 (let ((buffer-read-only nil)
9625 (article (gnus-summary-article-number)))
9627 ;; Go forward until either the buffer ends or the subthread
9629 (when (and (not (eobp))
9630 (or (zerop (gnus-summary-next-thread 1 t))
9631 (goto-char (point-max))))
9633 (if (and (> (point) start)
9634 (search-backward "\n" start t))
9636 (subst-char-in-region start (point) ?\n ?\^M)
9637 (gnus-summary-goto-subject article))
9641 (defun gnus-summary-go-to-next-thread (&optional previous)
9642 "Go to the same level (or less) next thread.
9643 If PREVIOUS is non-nil, go to previous thread instead.
9644 Return the article number moved to, or nil if moving was impossible."
9645 (let ((level (gnus-summary-thread-level))
9646 (way (if previous -1 1))
9649 (while (and (not (eobp))
9650 (< level (gnus-summary-thread-level)))
9658 (gnus-summary-article-number)
9661 (defun gnus-summary-next-thread (n &optional silent)
9662 "Go to the same level next N'th thread.
9663 If N is negative, search backward instead.
9664 Returns the difference between N and the number of skips actually
9667 If SILENT, don't output messages."
9669 (let ((backward (< n 0))
9672 (gnus-summary-go-to-next-thread backward))
9675 (gnus-summary-position-point))
9676 (when (and (not silent) (/= 0 n))
9677 (gnus-message 7 "No more threads"))
9680 (defun gnus-summary-prev-thread (n)
9681 "Go to the same level previous N'th thread.
9682 Returns the difference between N and the number of skips actually
9685 (gnus-summary-next-thread (- n)))
9687 (defun gnus-summary-go-down-thread ()
9688 "Go down one level in the current thread."
9689 (let ((children (gnus-summary-article-children)))
9691 (gnus-summary-goto-subject (car children)))))
9693 (defun gnus-summary-go-up-thread ()
9694 "Go up one level in the current thread."
9695 (let ((parent (gnus-summary-article-parent)))
9697 (gnus-summary-goto-subject parent))))
9699 (defun gnus-summary-down-thread (n)
9700 "Go down thread N steps.
9701 If N is negative, go up instead.
9702 Returns the difference between N and how many steps down that were
9708 (if up (gnus-summary-go-up-thread)
9709 (gnus-summary-go-down-thread)))
9711 (gnus-summary-position-point)
9713 (gnus-message 7 "Can't go further"))
9716 (defun gnus-summary-up-thread (n)
9717 "Go up thread N steps.
9718 If N is negative, go down instead.
9719 Returns the difference between N and how many steps down that were
9722 (gnus-summary-down-thread (- n)))
9724 (defun gnus-summary-top-thread ()
9725 "Go to the top of the thread."
9727 (while (gnus-summary-go-up-thread))
9728 (gnus-summary-article-number))
9730 (defun gnus-summary-kill-thread (&optional unmark)
9731 "Mark articles under current thread as read.
9732 If the prefix argument is positive, remove any kinds of marks.
9733 If the prefix argument is negative, tick articles instead."
9736 (setq unmark (prefix-numeric-value unmark)))
9737 (let ((articles (gnus-summary-articles-in-thread)))
9739 ;; Expand the thread.
9740 (gnus-summary-show-thread)
9741 ;; Mark all the articles.
9743 (gnus-summary-goto-subject (car articles))
9744 (cond ((null unmark)
9745 (gnus-summary-mark-article-as-read gnus-killed-mark))
9747 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9749 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9750 (setq articles (cdr articles))))
9751 ;; Hide killed subtrees.
9753 gnus-thread-hide-killed
9754 (gnus-summary-hide-thread))
9755 ;; If marked as read, go to next unread subject.
9757 ;; Go to next unread subject.
9758 (gnus-summary-next-subject 1 t)))
9759 (gnus-set-mode-line 'summary))
9761 ;; Summary sorting commands
9763 (defun gnus-summary-sort-by-number (&optional reverse)
9764 "Sort the summary buffer by article number.
9765 Argument REVERSE means reverse order."
9767 (gnus-summary-sort 'number reverse))
9769 (defun gnus-summary-sort-by-author (&optional reverse)
9770 "Sort the summary buffer by author name alphabetically.
9771 If `case-fold-search' is non-nil, case of letters is ignored.
9772 Argument REVERSE means reverse order."
9774 (gnus-summary-sort 'author reverse))
9776 (defun gnus-summary-sort-by-subject (&optional reverse)
9777 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9778 If `case-fold-search' is non-nil, case of letters is ignored.
9779 Argument REVERSE means reverse order."
9781 (gnus-summary-sort 'subject reverse))
9783 (defun gnus-summary-sort-by-date (&optional reverse)
9784 "Sort the summary buffer by date.
9785 Argument REVERSE means reverse order."
9787 (gnus-summary-sort 'date reverse))
9789 (defun gnus-summary-sort-by-score (&optional reverse)
9790 "Sort the summary buffer by score.
9791 Argument REVERSE means reverse order."
9793 (gnus-summary-sort 'score reverse))
9795 (defun gnus-summary-sort-by-lines (&optional reverse)
9796 "Sort the summary buffer by the number of lines.
9797 Argument REVERSE means reverse order."
9799 (gnus-summary-sort 'lines reverse))
9801 (defun gnus-summary-sort-by-chars (&optional reverse)
9802 "Sort the summary buffer by article length.
9803 Argument REVERSE means reverse order."
9805 (gnus-summary-sort 'chars reverse))
9807 (defun gnus-summary-sort-by-original (&optional reverse)
9808 "Sort the summary buffer using the default sorting method.
9809 Argument REVERSE means reverse order."
9811 (let* ((buffer-read-only)
9812 (gnus-summary-prepare-hook nil))
9813 ;; We do the sorting by regenerating the threads.
9814 (gnus-summary-prepare)
9815 ;; Hide subthreads if needed.
9816 (when (and gnus-show-threads gnus-thread-hide-subtree)
9817 (gnus-summary-hide-all-threads))))
9819 (defun gnus-summary-sort (predicate reverse)
9820 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9821 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9822 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9823 (gnus-thread-sort-functions
9828 (gnus-sort-gathered-threads-function
9829 gnus-thread-sort-functions)
9830 (gnus-article-sort-functions
9836 (gnus-summary-prepare-hook nil))
9837 ;; We do the sorting by regenerating the threads.
9838 (gnus-summary-prepare)
9839 ;; Hide subthreads if needed.
9840 (when (and gnus-show-threads gnus-thread-hide-subtree)
9841 (gnus-summary-hide-all-threads))))
9843 ;; Summary saving commands.
9845 (defun gnus-summary-save-article (&optional n not-saved)
9846 "Save the current article using the default saver function.
9847 If N is a positive number, save the N next articles.
9848 If N is a negative number, save the N previous articles.
9849 If N is nil and any articles have been marked with the process mark,
9850 save those articles instead.
9851 The variable `gnus-default-article-saver' specifies the saver function."
9853 (let* ((articles (gnus-summary-work-articles n))
9854 (save-buffer (save-excursion
9855 (nnheader-set-temp-buffer " *Gnus Save*")))
9856 (num (length articles))
9858 (dolist (article articles)
9859 (setq header (gnus-summary-article-header article))
9860 (if (not (vectorp header))
9861 ;; This is a pseudo-article.
9862 (if (assq 'name header)
9863 (gnus-copy-file (cdr (assq 'name header)))
9864 (gnus-message 1 "Article %d is unsaveable" article))
9865 ;; This is a real article.
9866 (save-window-excursion
9867 (gnus-summary-select-article t nil nil article))
9869 (set-buffer save-buffer)
9871 (insert-buffer-substring gnus-original-article-buffer))
9872 (setq file (gnus-article-save save-buffer file num))
9873 (gnus-summary-remove-process-mark article)
9875 (gnus-summary-set-saved-mark article))))
9876 (gnus-kill-buffer save-buffer)
9877 (gnus-summary-position-point)
9878 (gnus-set-mode-line 'summary)
9881 (defun gnus-summary-pipe-output (&optional arg)
9882 "Pipe the current article to a subprocess.
9883 If N is a positive number, pipe the N next articles.
9884 If N is a negative number, pipe the N previous articles.
9885 If N is nil and any articles have been marked with the process mark,
9886 pipe those articles instead."
9889 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9890 (gnus-summary-save-article arg t))
9891 (let ((buffer (get-buffer "*Shell Command Output*")))
9893 (with-current-buffer buffer (> (point-max) (point-min))))
9894 (gnus-configure-windows 'pipe))))
9896 (defun gnus-summary-save-article-mail (&optional arg)
9897 "Append the current article to an mail file.
9898 If N is a positive number, save the N next articles.
9899 If N is a negative number, save the N previous articles.
9900 If N is nil and any articles have been marked with the process mark,
9901 save those articles instead."
9904 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9905 (gnus-summary-save-article arg)))
9907 (defun gnus-summary-save-article-rmail (&optional arg)
9908 "Append the current article to an rmail file.
9909 If N is a positive number, save the N next articles.
9910 If N is a negative number, save the N previous articles.
9911 If N is nil and any articles have been marked with the process mark,
9912 save those articles instead."
9915 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9916 (gnus-summary-save-article arg)))
9918 (defun gnus-summary-save-article-file (&optional arg)
9919 "Append the current article to a file.
9920 If N is a positive number, save the N next articles.
9921 If N is a negative number, save the N previous articles.
9922 If N is nil and any articles have been marked with the process mark,
9923 save those articles instead."
9926 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9927 (gnus-summary-save-article arg)))
9929 (defun gnus-summary-write-article-file (&optional arg)
9930 "Write the current article to a file, deleting the previous file.
9931 If N is a positive number, save the N next articles.
9932 If N is a negative number, save the N previous articles.
9933 If N is nil and any articles have been marked with the process mark,
9934 save those articles instead."
9937 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9938 (gnus-summary-save-article arg)))
9940 (defun gnus-summary-save-article-body-file (&optional arg)
9941 "Append the current article body to a file.
9942 If N is a positive number, save the N next articles.
9943 If N is a negative number, save the N previous articles.
9944 If N is nil and any articles have been marked with the process mark,
9945 save those articles instead."
9948 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9949 (gnus-summary-save-article arg)))
9951 (defun gnus-summary-pipe-message (program)
9952 "Pipe the current article through PROGRAM."
9953 (interactive "sProgram: ")
9954 (gnus-summary-select-article)
9955 (let ((mail-header-separator ""))
9956 (gnus-eval-in-buffer-window gnus-article-buffer
9959 (let ((start (window-start))
9961 (message-pipe-buffer-body program)
9962 (set-window-start (get-buffer-window (current-buffer)) start))))))
9964 (defun gnus-get-split-value (methods)
9965 "Return a value based on the split METHODS."
9966 (let (split-name method result match)
9969 (set-buffer gnus-original-article-buffer)
9971 (nnheader-narrow-to-headers)
9972 (while (and methods (not split-name))
9973 (goto-char (point-min))
9974 (setq method (pop methods))
9975 (setq match (car method))
9978 ;; Regular expression.
9980 (re-search-forward match nil t)))
9981 ((gnus-functionp match)
9985 (setq result (funcall match gnus-newsgroup-name))))
9990 (setq result (eval match)))))
9991 (setq split-name (cdr method))
9992 (cond ((stringp result)
9993 (push (expand-file-name
9994 result gnus-article-save-directory)
9997 (setq split-name (append result split-name)))))))))
9998 (nreverse split-name)))
10000 (defun gnus-valid-move-group-p (group)
10001 (and (boundp group)
10002 (symbol-name group)
10003 (symbol-value group)
10004 (gnus-get-function (gnus-find-method-for-group
10005 (symbol-name group)) 'request-accept-article t)))
10007 (defun gnus-read-move-group-name (prompt default articles prefix)
10008 "Read a group name."
10009 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10010 (minibuffer-confirm-incomplete nil) ; XEmacs
10012 (format "%s %s to:"
10014 (if (> (length articles) 1)
10015 (format "these %d articles" (length articles))
10020 (gnus-completing-read default prom
10022 'gnus-valid-move-group-p
10024 'gnus-group-history))
10025 ((= 1 (length split-name))
10026 (gnus-completing-read (car split-name) prom
10028 'gnus-valid-move-group-p
10030 'gnus-group-history))
10032 (gnus-completing-read nil prom
10033 (mapcar (lambda (el) (list el))
10034 (nreverse split-name))
10036 'gnus-group-history))))
10037 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10039 (if (or (string= to-newsgroup "")
10040 (string= to-newsgroup prefix))
10041 (setq to-newsgroup default))
10042 (unless to-newsgroup
10043 (error "No group name entered"))
10044 (or (gnus-active to-newsgroup)
10045 (gnus-activate-group to-newsgroup nil nil to-method)
10046 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10048 (or (and (gnus-request-create-group to-newsgroup to-method)
10049 (gnus-activate-group
10050 to-newsgroup nil nil to-method)
10051 (gnus-subscribe-group to-newsgroup))
10052 (error "Couldn't create group %s" to-newsgroup)))
10053 (error "No such group: %s" to-newsgroup)))
10056 (defun gnus-summary-save-parts (type dir n &optional reverse)
10057 "Save parts matching TYPE to DIR.
10058 If REVERSE, save parts that do not match TYPE."
10060 (list (read-string "Save parts of type: "
10061 (or (car gnus-summary-save-parts-type-history)
10062 gnus-summary-save-parts-default-mime)
10063 'gnus-summary-save-parts-type-history)
10064 (setq gnus-summary-save-parts-last-directory
10065 (read-file-name "Save to directory: "
10066 gnus-summary-save-parts-last-directory
10068 current-prefix-arg))
10069 (gnus-summary-iterate n
10070 (let ((gnus-display-mime-function nil)
10071 (gnus-inhibit-treatment t))
10072 (gnus-summary-select-article))
10074 (set-buffer gnus-article-buffer)
10075 (let ((handles (or gnus-article-mime-handles
10076 (mm-dissect-buffer) (mm-uu-dissect))))
10078 (gnus-summary-save-parts-1 type dir handles reverse)
10079 (unless gnus-article-mime-handles ;; Don't destroy this case.
10080 (mm-destroy-parts handles)))))))
10082 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10083 (if (stringp (car handle))
10084 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10087 (not (string-match type (mm-handle-media-type handle)))
10088 (string-match type (mm-handle-media-type handle)))
10089 (let ((file (expand-file-name
10090 (file-name-nondirectory
10092 (mail-content-type-get
10093 (mm-handle-disposition handle) 'filename)
10094 (concat gnus-newsgroup-name
10095 "." (number-to-string
10096 (cdr gnus-article-current)))))
10098 (unless (file-exists-p file)
10099 (mm-save-part-to-file handle file))))))
10101 ;; Summary extract commands
10103 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10104 (let ((buffer-read-only nil)
10105 (article (gnus-summary-article-number))
10107 (unless (gnus-summary-goto-subject article)
10108 (error "No such article: %d" article))
10109 (gnus-summary-position-point)
10110 ;; If all commands are to be bunched up on one line, we collect
10112 (unless gnus-view-pseudos-separately
10113 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10116 (setq action (cdr (assq 'action (car ps))))
10117 (setq files (list (cdr (assq 'name (car ps)))))
10118 (while (and ps (cdr ps)
10119 (string= (or action "1")
10120 (or (cdr (assq 'action (cadr ps))) "2")))
10121 (push (cdr (assq 'name (cadr ps))) files)
10122 (setcdr ps (cddr ps)))
10124 (when (not (string-match "%s" action))
10127 (when (assq 'execute (car ps))
10128 (setcdr (assq 'execute (car ps))
10129 (funcall (if (string-match "%s" action)
10136 (gnus-quote-arg-for-sh-or-csh f)))
10138 (setq ps (cdr ps)))))
10139 (if (and gnus-view-pseudos (not not-view))
10141 (when (assq 'execute (car pslist))
10142 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10143 (eq gnus-view-pseudos 'not-confirm)))
10144 (setq pslist (cdr pslist)))
10147 (setq after-article (or (cdr (assq 'article (car pslist)))
10148 (gnus-summary-article-number)))
10149 (gnus-summary-goto-subject after-article)
10152 (insert " " (file-name-nondirectory
10153 (cdr (assq 'name (car pslist))))
10154 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10156 (forward-line -1) ; back to `b'
10157 (gnus-add-text-properties
10158 b (1- e) (list 'gnus-number gnus-reffed-article-number
10159 gnus-mouse-face-prop gnus-mouse-face))
10161 after-article gnus-reffed-article-number
10162 gnus-unread-mark b (car pslist) 0 (- e b))
10163 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10164 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10165 (setq pslist (cdr pslist)))))))
10167 (defun gnus-pseudos< (p1 p2)
10168 (let ((c1 (cdr (assq 'action p1)))
10169 (c2 (cdr (assq 'action p2))))
10170 (and c1 c2 (string< c1 c2))))
10172 (defun gnus-request-pseudo-article (props)
10173 (cond ((assq 'execute props)
10174 (gnus-execute-command (cdr (assq 'execute props)))))
10175 (let ((gnus-current-article (gnus-summary-article-number)))
10176 (gnus-run-hooks 'gnus-mark-article-hook)))
10178 (defun gnus-execute-command (command &optional automatic)
10180 (gnus-article-setup-buffer)
10181 (set-buffer gnus-article-buffer)
10182 (setq buffer-read-only nil)
10183 (let ((command (if automatic command
10184 (read-string "Command: " (cons command 0)))))
10186 (insert "$ " command "\n\n")
10187 (if gnus-view-pseudo-asynchronously
10188 (start-process "gnus-execute" (current-buffer) shell-file-name
10189 shell-command-switch command)
10190 (call-process shell-file-name nil t nil
10191 shell-command-switch command)))))
10193 ;; Summary kill commands.
10195 (defun gnus-summary-edit-global-kill (article)
10196 "Edit the \"global\" kill file."
10197 (interactive (list (gnus-summary-article-number)))
10198 (gnus-group-edit-global-kill article))
10200 (defun gnus-summary-edit-local-kill ()
10201 "Edit a local kill file applied to the current newsgroup."
10203 (setq gnus-current-headers (gnus-summary-article-header))
10204 (gnus-group-edit-local-kill
10205 (gnus-summary-article-number) gnus-newsgroup-name))
10207 ;;; Header reading.
10209 (defun gnus-read-header (id &optional header)
10210 "Read the headers of article ID and enter them into the Gnus system."
10211 (let ((group gnus-newsgroup-name)
10212 (gnus-override-method
10214 gnus-override-method
10215 (and (gnus-news-group-p gnus-newsgroup-name)
10216 (car (gnus-refer-article-methods)))))
10218 ;; First we check to see whether the header in question is already
10221 ;; This is a Message-ID.
10222 (setq header (or header (gnus-id-to-header id)))
10223 ;; This is an article number.
10224 (setq header (or header (gnus-summary-article-header id))))
10226 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10227 ;; We have found the header.
10229 ;; If this is a sparse article, we have to nix out its
10230 ;; previous entry in the thread hashtb.
10232 (gnus-summary-article-sparse-p (mail-header-number header)))
10233 (let* ((parent (gnus-parent-id (mail-header-references header)))
10234 (thread (and parent (gnus-id-to-thread parent))))
10236 (delq (assq header thread) thread))))
10237 ;; We have to really fetch the header to this article.
10239 (set-buffer nntp-server-buffer)
10240 (when (setq where (gnus-request-head id group))
10241 (nnheader-fold-continuation-lines)
10242 (goto-char (point-max))
10244 (goto-char (point-min))
10248 ((cdr where) (cdr where))
10249 (header (mail-header-number header))
10250 (t gnus-reffed-article-number))
10252 (insert " Article retrieved.\n"))
10253 (if (or (not where)
10254 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10255 () ; Malformed head.
10256 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10257 (when (and (stringp id)
10258 (not (string= (gnus-group-real-name group)
10260 ;; If we fetched by Message-ID and the article came
10261 ;; from a different group, we fudge some bogus article
10262 ;; numbers for this article.
10263 (mail-header-set-number header gnus-reffed-article-number))
10265 (set-buffer gnus-summary-buffer)
10266 (decf gnus-reffed-article-number)
10267 (gnus-remove-header (mail-header-number header))
10268 (push header gnus-newsgroup-headers)
10269 (setq gnus-current-headers header)
10270 (push (mail-header-number header) gnus-newsgroup-limit)))
10273 (defun gnus-remove-header (number)
10274 "Remove header NUMBER from `gnus-newsgroup-headers'."
10275 (if (and gnus-newsgroup-headers
10276 (= number (mail-header-number (car gnus-newsgroup-headers))))
10277 (pop gnus-newsgroup-headers)
10278 (let ((headers gnus-newsgroup-headers))
10279 (while (and (cdr headers)
10280 (not (= number (mail-header-number (cadr headers)))))
10282 (when (cdr headers)
10283 (setcdr headers (cddr headers))))))
10286 ;;; summary highlights
10289 (defun gnus-highlight-selected-summary ()
10290 "Highlight selected article in summary buffer."
10291 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10292 (when gnus-summary-selected-face
10294 (let* ((beg (progn (beginning-of-line) (point)))
10295 (end (progn (end-of-line) (point)))
10296 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10297 (from (if (get-text-property beg gnus-mouse-face-prop)
10299 (or (next-single-property-change
10300 beg gnus-mouse-face-prop nil end)
10305 (or (next-single-property-change
10306 from gnus-mouse-face-prop nil end)
10308 ;; If no mouse-face prop on line we will have to = from = end,
10309 ;; so we highlight the entire line instead.
10310 (when (= (+ to 2) from)
10313 (if gnus-newsgroup-selected-overlay
10314 ;; Move old overlay.
10316 gnus-newsgroup-selected-overlay from to (current-buffer))
10317 ;; Create new overlay.
10319 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10320 'face gnus-summary-selected-face))))))
10322 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10323 (defun gnus-summary-highlight-line ()
10324 "Highlight current line according to `gnus-summary-highlight'."
10325 (let* ((list gnus-summary-highlight)
10327 (end (progn (end-of-line) (point)))
10328 ;; now find out where the line starts and leave point there.
10329 (beg (progn (beginning-of-line) (point)))
10330 (article (gnus-summary-article-number))
10331 (score (or (cdr (assq (or article gnus-current-article)
10332 gnus-newsgroup-scored))
10333 gnus-summary-default-score 0))
10334 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10335 (inhibit-read-only t))
10336 ;; Eval the cars of the lists until we find a match.
10337 (let ((default gnus-summary-default-score)
10338 (default-high gnus-summary-default-high-score)
10339 (default-low gnus-summary-default-low-score))
10341 (not (eval (caar list))))
10342 (setq list (cdr list))))
10343 (let ((face (cdar list)))
10344 (unless (eq face (get-text-property beg 'face))
10345 (gnus-put-text-property-excluding-characters-with-faces
10347 (setq face (if (boundp face) (symbol-value face) face)))
10348 (when gnus-summary-highlight-line-function
10349 (funcall gnus-summary-highlight-line-function article face))))
10352 (defun gnus-update-read-articles (group unread &optional compute)
10353 "Update the list of read articles in GROUP."
10354 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10355 (entry (gnus-gethash group gnus-newsrc-hashtb))
10356 (info (nth 2 entry))
10358 (unread (sort (copy-sequence unread) '<))
10360 (if (or (not info) (not active))
10361 ;; There is no info on this group if it was, in fact,
10362 ;; killed. Gnus stores no information on killed groups, so
10363 ;; there's nothing to be done.
10364 ;; One could store the information somewhere temporarily,
10365 ;; perhaps... Hmmm...
10367 ;; Remove any negative articles numbers.
10368 (while (and unread (< (car unread) 0))
10369 (setq unread (cdr unread)))
10370 ;; Remove any expired article numbers
10371 (while (and unread (< (car unread) (car active)))
10372 (setq unread (cdr unread)))
10373 ;; Compute the ranges of read articles by looking at the list of
10374 ;; unread articles.
10376 (when (/= (car unread) prev)
10377 (push (if (= prev (1- (car unread))) prev
10378 (cons prev (1- (car unread))))
10380 (setq prev (1+ (car unread)))
10381 (setq unread (cdr unread)))
10382 (when (<= prev (cdr active))
10383 (push (cons prev (cdr active)) read))
10384 (setq read (if (> (length read) 1) (nreverse read) read))
10389 ;; Propagate the read marks to the backend.
10390 (when (gnus-check-backend-function 'request-set-mark group)
10391 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10392 (add (gnus-remove-from-range read (gnus-info-read info))))
10394 (unless (gnus-check-group group)
10395 (error "Can't open server for %s" group))
10396 (gnus-request-set-mark
10397 group (delq nil (list (if add (list add 'add '(read)))
10398 (if del (list del 'del '(read))))))
10400 `(gnus-request-set-mark
10403 (if del (list del 'add '(read)))
10404 (if add (list add 'del '(read))))))))))
10405 (set-buffer gnus-group-buffer)
10406 (gnus-undo-register
10408 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10409 (gnus-info-set-read ',info ',(gnus-info-read info))
10410 (gnus-get-unread-articles-in-group ',info
10411 (gnus-active ,group))
10412 (gnus-group-update-group ,group t)
10414 ;; Enter this list into the group info.
10415 (gnus-info-set-read info read)
10416 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10417 (gnus-get-unread-articles-in-group info (gnus-active group))
10420 (defun gnus-offer-save-summaries ()
10421 "Offer to save all active summary buffers."
10423 ;; Go through all buffers and find all summaries.
10424 (dolist (buffer (buffer-list))
10425 (when (and (setq buffer (buffer-name buffer))
10426 (string-match "Summary" buffer)
10428 (set-buffer buffer)
10429 ;; We check that this is, indeed, a summary buffer.
10430 (and (eq major-mode 'gnus-summary-mode)
10431 ;; Also make sure this isn't bogus.
10432 gnus-newsgroup-prepared
10433 ;; Also make sure that this isn't a
10434 ;; dead summary buffer.
10435 (not gnus-dead-summary-mode))))
10436 (push buffer buffers)))
10437 ;; Go through all these summary buffers and offer to save them.
10441 "Update summary buffer %s? "
10443 (switch-to-buffer buf)
10444 (gnus-summary-exit))
10448 ;;; @ for mime-partial
10451 (defun gnus-request-partial-message ()
10453 (let ((number (gnus-summary-article-number))
10454 (group gnus-newsgroup-name)
10455 (mother gnus-article-buffer))
10456 (set-buffer (get-buffer-create " *Partial Article*"))
10458 (setq mime-preview-buffer mother)
10459 (gnus-request-article-this-buffer number group)
10460 (mime-parse-buffer)
10463 (autoload 'mime-combine-message/partial-pieces-automatically
10465 "Internal method to combine message/partial messages automatically.")
10467 (mime-add-condition
10468 'action '((type . message)(subtype . partial)
10469 (major-mode . gnus-original-article-mode)
10470 (method . mime-combine-message/partial-pieces-automatically)
10471 (summary-buffer-exp . gnus-summary-buffer)
10472 (request-partial-message-method . gnus-request-partial-message)
10476 ;;; @ for message/rfc822
10479 (defun gnus-mime-extract-message/rfc822 (entity situation)
10480 (let (group article num cwin swin cur)
10482 (mime-insert-entity-content entity)
10483 (setq group (or (cdr (assq 'group situation))
10484 (completing-read "Group: "
10487 (gnus-read-active-file-p)
10488 gnus-newsgroup-name))
10489 article (gnus-request-accept-article group)))
10490 (when (and (consp article)
10491 (numberp (setq article (cdr article))))
10492 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10493 cwin (get-buffer-window (current-buffer) t))
10494 (save-window-excursion
10495 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10496 (select-window swin)
10497 (set-buffer gnus-summary-buffer))
10498 (setq cur gnus-current-article)
10500 (let (gnus-show-threads)
10501 (gnus-summary-goto-subject article t))
10502 (gnus-summary-clear-mark-forward 1)
10503 (gnus-summary-goto-subject cur))
10504 (when (and cwin (window-frame cwin))
10505 (select-frame (window-frame cwin)))
10506 (when (boundp 'mime-acting-situation-to-override)
10507 (set-alist 'mime-acting-situation-to-override
10510 (set-alist 'mime-acting-situation-to-override
10513 (save-current-buffer
10514 (set-buffer gnus-group-buffer)
10515 (gnus-activate-group ,group))
10516 (gnus-summary-goto-article ,cur
10517 gnus-show-all-headers)))
10518 (set-alist 'mime-acting-situation-to-override
10521 (mime-add-condition
10522 'action '((type . message)(subtype . rfc822)
10523 (major-mode . gnus-original-article-mode)
10524 (method . gnus-mime-extract-message/rfc822)
10528 (mime-add-condition
10529 'action '((type . message)(subtype . news)
10530 (major-mode . gnus-original-article-mode)
10531 (method . gnus-mime-extract-message/rfc822)
10535 (defun gnus-mime-extract-multipart (entity situation)
10536 (let ((children (mime-entity-children entity))
10537 mime-acting-situation-to-override
10540 (mime-play-entity (car children)
10541 (cons (assq 'mode situation)
10542 mime-acting-situation-to-override))
10543 (setq children (cdr children)))
10544 (if (setq f (cdr (assq 'after-method
10545 mime-acting-situation-to-override)))
10549 (mime-add-condition
10550 'action '((type . multipart)
10551 (method . gnus-mime-extract-multipart)
10560 (defun gnus-summary-setup-default-charset ()
10561 "Setup newsgroup default charset."
10562 (if (equal gnus-newsgroup-name "nndraft:drafts")
10563 (setq gnus-newsgroup-charset nil)
10564 (let* ((ignored-charsets
10565 (or gnus-newsgroup-ephemeral-ignored-charsets
10567 (and gnus-newsgroup-name
10568 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10569 gnus-newsgroup-ignored-charsets))))
10570 (setq gnus-newsgroup-charset
10571 (or gnus-newsgroup-ephemeral-charset
10572 (and gnus-newsgroup-name
10573 (gnus-parameter-charset gnus-newsgroup-name))
10574 gnus-default-charset))
10575 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10576 ignored-charsets))))
10582 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10583 "Display the current article buffer fully MIME-buttonized.
10584 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10585 treated as multipart/mixed."
10587 (require 'gnus-art)
10588 (let ((gnus-unbuttonized-mime-types nil)
10589 (gnus-mime-display-multipart-as-mixed show-all-parts))
10590 (gnus-summary-show-article)))
10592 (defun gnus-summary-repair-multipart (article)
10593 "Add a Content-Type header to a multipart article without one."
10594 (interactive (list (gnus-summary-article-number)))
10595 (gnus-with-article article
10596 (message-narrow-to-head)
10597 (message-remove-header "Mime-Version")
10598 (goto-char (point-max))
10599 (insert "Mime-Version: 1.0\n")
10601 (when (search-forward "\n--" nil t)
10602 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10603 (message-narrow-to-head)
10604 (message-remove-header "Content-Type")
10605 (goto-char (point-max))
10606 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10609 (let (gnus-mark-article-hook)
10610 (gnus-summary-select-article t t nil article)))
10612 (defun gnus-summary-toggle-display-buttonized ()
10613 "Toggle the buttonizing of the article buffer."
10615 (require 'gnus-art)
10616 (if (setq gnus-inhibit-mime-unbuttonizing
10617 (not gnus-inhibit-mime-unbuttonizing))
10618 (let ((gnus-unbuttonized-mime-types nil))
10619 (gnus-summary-show-article))
10620 (gnus-summary-show-article)))
10623 ;;; Intelli-mouse commmands
10626 (defun gnus-wheel-summary-scroll (event)
10628 (let ((amount (if (memq 'shift (event-modifiers event))
10629 (car gnus-wheel-scroll-amount)
10630 (cdr gnus-wheel-scroll-amount)))
10631 (direction (- (* (static-if (featurep 'xemacs)
10632 (event-button event)
10633 (cond ((eq 'mouse-4 (event-basic-type event))
10635 ((eq 'mouse-5 (event-basic-type event))
10639 (gnus-summary-scroll-up (* amount direction))
10640 (when (gnus-eval-in-buffer-window gnus-article-buffer
10643 (and (if (< 0 direction)
10644 (gnus-article-next-page 0)
10645 (gnus-article-prev-page 0)
10647 (if (setq edge (get-text-property
10648 (point-min) 'gnus-wheel-edge))
10649 (setq edge (* edge direction))
10652 (let ((buffer-read-only nil)
10653 (inhibit-read-only t))
10654 (put-text-property (point-min) (point-max)
10655 'gnus-wheel-edge direction)
10657 (or (> edge gnus-wheel-edge-resistance)
10658 (let ((buffer-read-only nil)
10659 (inhibit-read-only t))
10660 (put-text-property (point-min) (point-max)
10662 (* (1+ edge) direction))
10664 (eq last-command 'gnus-wheel-summary-scroll))))
10665 (gnus-summary-next-article nil nil (minusp direction)))))
10667 (defun gnus-wheel-install ()
10668 "Enable mouse wheel support on summary window."
10669 (when gnus-use-wheel
10671 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10673 (define-key gnus-summary-mode-map key
10674 'gnus-wheel-summary-scroll)))))
10676 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10679 ;;; Traditional PGP commmands
10682 (defun gnus-summary-decrypt-article (&optional force)
10683 "Decrypt the current article in traditional PGP way.
10684 This will have permanent effect only in mail groups.
10685 If FORCE is non-nil, allow editing of articles even in read-only
10688 (gnus-summary-select-article t)
10689 (gnus-eval-in-buffer-window gnus-article-buffer
10693 (goto-char (point-min))
10694 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10695 (error "Not a traditional PGP message!"))
10696 (let ((armor-start (match-beginning 0)))
10697 (if (and (pgg-decrypt-region armor-start (point-max))
10698 (or force (not (gnus-group-read-only-p))))
10699 (let ((inhibit-read-only t)
10701 (delete-region armor-start
10703 (re-search-forward "^-+END PGP" nil t)
10704 (beginning-of-line 2)
10706 (insert-buffer-substring pgg-output-buffer))))))))
10708 (defun gnus-summary-verify-article ()
10709 "Verify the current article in traditional PGP way."
10712 (set-buffer gnus-original-article-buffer)
10713 (goto-char (point-min))
10714 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10715 (error "Not a traditional PGP message!"))
10716 (re-search-forward "^-+END PGP" nil t)
10717 (beginning-of-line 2)
10718 (call-interactively (function pgg-verify-region))))
10721 ;;; Generic summary marking commands
10724 (defvar gnus-summary-marking-alist
10725 '((read gnus-del-mark "d")
10726 (unread gnus-unread-mark "u")
10727 (ticked gnus-ticked-mark "!")
10728 (dormant gnus-dormant-mark "?")
10729 (expirable gnus-expirable-mark "e"))
10730 "An alist of names/marks/keystrokes.")
10732 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10733 (defvar gnus-summary-mark-map)
10735 (defun gnus-summary-make-all-marking-commands ()
10736 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10737 (dolist (elem gnus-summary-marking-alist)
10738 (apply 'gnus-summary-make-marking-command elem)))
10740 (defun gnus-summary-make-marking-command (name mark keystroke)
10741 (let ((map (make-sparse-keymap)))
10742 (define-key gnus-summary-generic-mark-map keystroke map)
10743 (dolist (lway `((next "next" next nil "n")
10744 (next-unread "next unread" next t "N")
10745 (prev "previous" prev nil "p")
10746 (prev-unread "previous unread" prev t "P")
10747 (nomove "" nil nil ,keystroke)))
10748 (let ((func (gnus-summary-make-marking-command-1
10749 mark (car lway) lway name)))
10750 (setq func (eval func))
10751 (define-key map (nth 4 lway) func)))))
10753 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10755 (format "gnus-summary-put-mark-as-%s%s"
10756 name (if (eq way 'nomove)
10758 (concat "-" (symbol-name way)))))
10761 "Mark the current article as %s%s.
10762 If N, the prefix, then repeat N times.
10763 If N is negative, move in reverse order.
10764 The difference between N and the actual number of articles marked is
10766 name (car (cdr lway)))
10768 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10770 (defun gnus-summary-generic-mark (n mark move unread)
10771 "Mark N articles with MARK."
10772 (unless (eq major-mode 'gnus-summary-mode)
10773 (error "This command can only be used in the summary buffer"))
10774 (gnus-summary-show-thread)
10777 ((eq move 'next) 1)
10778 ((eq move 'prev) -1)
10780 (if (zerop nummove)
10784 nummove (* -1 nummove))))
10785 (while (and (> n 0)
10786 (gnus-summary-mark-article nil mark)
10787 (zerop (gnus-summary-next-subject nummove unread t)))
10790 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10791 (gnus-summary-recenter)
10792 (gnus-summary-position-point)
10793 (gnus-set-mode-line 'summary)
10796 (defun gnus-summary-insert-articles (articles)
10797 (when (setq articles
10798 (gnus-set-difference articles
10799 (mapcar (lambda (h) (mail-header-number h))
10800 gnus-newsgroup-headers)))
10801 (setq gnus-newsgroup-headers
10803 gnus-newsgroup-headers
10804 (gnus-fetch-headers articles)
10805 'gnus-article-sort-by-number))
10806 ;; Suppress duplicates?
10807 (when gnus-suppress-duplicates
10808 (gnus-dup-suppress-articles))
10810 ;; We might want to build some more threads first.
10811 (when (and gnus-fetch-old-headers
10812 (eq gnus-headers-retrieved-by 'nov))
10813 (if (eq gnus-fetch-old-headers 'invisible)
10814 (gnus-build-all-threads)
10815 (gnus-build-old-threads)))
10816 ;; Let the Gnus agent mark articles as read.
10818 (gnus-agent-get-undownloaded-list))
10819 ;; Remove list identifiers from subject
10820 (when gnus-list-identifiers
10821 (gnus-summary-remove-list-identifiers))
10822 ;; First and last article in this newsgroup.
10823 (when gnus-newsgroup-headers
10824 (setq gnus-newsgroup-begin
10825 (mail-header-number (car gnus-newsgroup-headers))
10827 (mail-header-number
10828 (gnus-last-element gnus-newsgroup-headers))))
10829 (when gnus-use-scoring
10830 (gnus-possibly-score-headers))))
10832 (defun gnus-summary-insert-old-articles (&optional all)
10833 "Insert all old articles in this group.
10834 If ALL is non-nil, already read articles become readable.
10835 If ALL is a number, fetch this number of articles."
10838 (let ((old (mapcar 'car gnus-newsgroup-data))
10839 (i (car gnus-newsgroup-active))
10841 (while (<= i (cdr gnus-newsgroup-active))
10842 (or (memq i old) (push i older))
10844 (setq len (length older))
10849 (setq older (subseq older 0 all))))
10852 (if (and (numberp gnus-large-newsgroup)
10853 (> len gnus-large-newsgroup))
10857 "How many articles from %s (default %d): "
10859 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10861 (unless (string-match "^[ \t]*$" input)
10862 (setq all (string-to-number input))
10864 (setq older (subseq older 0 all))))))))
10866 (message "No old news.")
10867 (gnus-summary-insert-articles older)
10868 (gnus-summary-limit (gnus-union older old))))
10869 (gnus-summary-position-point)))
10871 (defun gnus-summary-insert-new-articles ()
10872 "Insert all new articles in this group."
10875 (let ((old (mapcar 'car gnus-newsgroup-data))
10876 (old-active gnus-newsgroup-active)
10877 (nnmail-fetched-sources (list t))
10879 (setq gnus-newsgroup-active
10880 (gnus-activate-group gnus-newsgroup-name 'scan))
10881 (setq i (1+ (cdr old-active)))
10882 (while (<= i (cdr gnus-newsgroup-active))
10886 (message "No gnus is bad news.")
10887 (setq new (nreverse new))
10888 (gnus-summary-insert-articles new)
10889 (setq gnus-newsgroup-unreads
10890 (append gnus-newsgroup-unreads new))
10891 (gnus-summary-limit (gnus-union old new))))
10892 (gnus-summary-position-point)))
10894 (gnus-summary-make-all-marking-commands)
10896 (gnus-ems-redefine)
10898 (provide 'gnus-sum)
10900 (run-hooks 'gnus-sum-load-hook)
10902 ;;; gnus-sum.el ends here