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 gnus-pick-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 gnus-tmp-from)
1125 (?t (gnus-summary-number-of-articles-in-thread
1126 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1128 (?e (gnus-summary-number-of-articles-in-thread
1129 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1131 (?u gnus-tmp-user-defined ?s)
1132 (?P (gnus-pick-line-number) ?d)
1133 (?B gnus-tmp-thread-tree-header-string ?s)
1134 (user-date (gnus-user-date
1135 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1136 "An alist of format specifications that can appear in summary lines.
1137 These are paired with what variables they correspond with, along with
1138 the type of the variable (string, integer, character, etc).")
1140 (defvar gnus-summary-dummy-line-format-alist
1141 `((?S gnus-tmp-subject ?s)
1142 (?N gnus-tmp-number ?d)
1143 (?u gnus-tmp-user-defined ?s)))
1145 (defvar gnus-summary-mode-line-format-alist
1146 `((?G gnus-tmp-group-name ?s)
1147 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1148 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1149 (?A gnus-tmp-article-number ?d)
1150 (?Z gnus-tmp-unread-and-unselected ?s)
1151 (?V gnus-version ?s)
1152 (?U gnus-tmp-unread-and-unticked ?d)
1153 (?S gnus-tmp-subject ?s)
1154 (?e gnus-tmp-unselected ?d)
1155 (?u gnus-tmp-user-defined ?s)
1156 (?d (length gnus-newsgroup-dormant) ?d)
1157 (?t (length gnus-newsgroup-marked) ?d)
1158 (?r (length gnus-newsgroup-reads) ?d)
1159 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1160 (?E gnus-newsgroup-expunged-tally ?d)
1161 (?s (gnus-current-score-file-nondirectory) ?s)))
1163 (defvar gnus-last-search-regexp nil
1164 "Default regexp for article search command.")
1166 (defvar gnus-summary-search-article-matched-data nil
1167 "Last matched data of article search command. It is the local variable
1168 in `gnus-article-buffer' which consists of the list of start position,
1169 end position and text.")
1171 (defvar gnus-last-shell-command nil
1172 "Default shell command on article.")
1174 (defvar gnus-newsgroup-begin nil)
1175 (defvar gnus-newsgroup-end nil)
1176 (defvar gnus-newsgroup-last-rmail nil)
1177 (defvar gnus-newsgroup-last-mail nil)
1178 (defvar gnus-newsgroup-last-folder nil)
1179 (defvar gnus-newsgroup-last-file nil)
1180 (defvar gnus-newsgroup-auto-expire nil)
1181 (defvar gnus-newsgroup-active nil)
1183 (defvar gnus-newsgroup-data nil)
1184 (defvar gnus-newsgroup-data-reverse nil)
1185 (defvar gnus-newsgroup-limit nil)
1186 (defvar gnus-newsgroup-limits nil)
1188 (defvar gnus-newsgroup-unreads nil
1189 "List of unread articles in the current newsgroup.")
1191 (defvar gnus-newsgroup-unselected nil
1192 "List of unselected unread articles in the current newsgroup.")
1194 (defvar gnus-newsgroup-reads nil
1195 "Alist of read articles and article marks in the current newsgroup.")
1197 (defvar gnus-newsgroup-expunged-tally nil)
1199 (defvar gnus-newsgroup-marked nil
1200 "List of ticked articles in the current newsgroup (a subset of unread art).")
1202 (defvar gnus-newsgroup-killed nil
1203 "List of ranges of articles that have been through the scoring process.")
1205 (defvar gnus-newsgroup-cached nil
1206 "List of articles that come from the article cache.")
1208 (defvar gnus-newsgroup-saved nil
1209 "List of articles that have been saved.")
1211 (defvar gnus-newsgroup-kill-headers nil)
1213 (defvar gnus-newsgroup-replied nil
1214 "List of articles that have been replied to in the current newsgroup.")
1216 (defvar gnus-newsgroup-forwarded nil
1217 "List of articles that have been forwarded in the current newsgroup.")
1219 (defvar gnus-newsgroup-recent nil
1220 "List of articles that have are recent in the current newsgroup.")
1222 (defvar gnus-newsgroup-expirable nil
1223 "List of articles in the current newsgroup that can be expired.")
1225 (defvar gnus-newsgroup-processable nil
1226 "List of articles in the current newsgroup that can be processed.")
1228 (defvar gnus-newsgroup-downloadable nil
1229 "List of articles in the current newsgroup that can be processed.")
1231 (defvar gnus-newsgroup-undownloaded nil
1232 "List of articles in the current newsgroup that haven't been downloaded..")
1234 (defvar gnus-newsgroup-unsendable nil
1235 "List of articles in the current newsgroup that won't be sent.")
1237 (defvar gnus-newsgroup-bookmarks nil
1238 "List of articles in the current newsgroup that have bookmarks.")
1240 (defvar gnus-newsgroup-dormant nil
1241 "List of dormant articles in the current newsgroup.")
1243 (defvar gnus-newsgroup-unseen nil
1244 "List of unseen articles in the current newsgroup.")
1246 (defvar gnus-newsgroup-seen nil
1247 "Range of seen articles in the current newsgroup.")
1249 (defvar gnus-newsgroup-articles nil
1250 "List of articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-scored nil
1253 "List of scored articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-incorporated nil
1256 "List of incorporated articles in the current newsgroup.")
1258 (defvar gnus-newsgroup-headers nil
1259 "List of article headers in the current newsgroup.")
1261 (defvar gnus-newsgroup-threads nil)
1263 (defvar gnus-newsgroup-prepared nil
1264 "Whether the current group has been prepared properly.")
1266 (defvar gnus-newsgroup-ancient nil
1267 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1269 (defvar gnus-newsgroup-sparse nil)
1271 (defvar gnus-current-article nil)
1272 (defvar gnus-article-current nil)
1273 (defvar gnus-current-headers nil)
1274 (defvar gnus-have-all-headers nil)
1275 (defvar gnus-last-article nil)
1276 (defvar gnus-newsgroup-history nil)
1277 (defvar gnus-newsgroup-charset nil)
1278 (defvar gnus-newsgroup-ephemeral-charset nil)
1279 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1281 (defvar gnus-article-before-search nil)
1283 (defconst gnus-summary-local-variables
1284 '(gnus-newsgroup-name
1285 gnus-newsgroup-begin gnus-newsgroup-end
1286 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1287 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1288 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1289 gnus-newsgroup-unselected gnus-newsgroup-marked
1290 gnus-newsgroup-reads gnus-newsgroup-saved
1291 gnus-newsgroup-replied gnus-newsgroup-forwarded
1292 gnus-newsgroup-recent
1293 gnus-newsgroup-expirable
1294 gnus-newsgroup-processable gnus-newsgroup-killed
1295 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1296 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1297 gnus-newsgroup-seen gnus-newsgroup-articles
1298 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1299 gnus-newsgroup-headers gnus-newsgroup-threads
1300 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1301 gnus-current-article gnus-current-headers gnus-have-all-headers
1302 gnus-last-article gnus-article-internal-prepare-hook
1303 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1304 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1305 gnus-thread-expunge-below
1306 gnus-score-alist gnus-current-score-file
1307 (gnus-summary-expunge-below . global)
1308 (gnus-summary-mark-below . global)
1309 (gnus-orphan-score . global)
1310 gnus-newsgroup-active gnus-scores-exclude-files
1311 gnus-newsgroup-history gnus-newsgroup-ancient
1312 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1313 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1314 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1315 (gnus-newsgroup-expunged-tally . 0)
1316 gnus-cache-removable-articles gnus-newsgroup-cached
1317 gnus-newsgroup-data gnus-newsgroup-data-reverse
1318 gnus-newsgroup-limit gnus-newsgroup-limits
1319 gnus-newsgroup-charset gnus-newsgroup-display
1320 gnus-newsgroup-incorporated)
1321 "Variables that are buffer-local to the summary buffers.")
1323 (defvar gnus-newsgroup-variables nil
1324 "A list of variables that have separate values in different newsgroups.
1325 A list of newsgroup (summary buffer) local variables, or cons of
1326 variables and their default values (when the default values are not
1327 nil), that should be made global while the summary buffer is active.
1328 These variables can be used to set variables in the group parameters
1329 while still allowing them to affect operations done in other
1330 buffers. For example:
1332 \(setq gnus-newsgroup-variables
1333 '(message-use-followup-to
1334 (gnus-visible-headers .
1335 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1338 ;; Byte-compiler warning.
1339 (eval-when-compile (defvar gnus-article-mode-map))
1341 ;; Subject simplification.
1343 (defun gnus-simplify-whitespace (str)
1344 "Remove excessive whitespace from STR."
1347 (while (string-match "[ \t][ \t]+" mystr)
1348 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1350 (substring mystr (match-end 0)))))
1352 (when (string-match "^[ \t]+" mystr)
1353 (setq mystr (substring mystr (match-end 0))))
1355 (when (string-match "[ \t]+$" mystr)
1356 (setq mystr (substring mystr 0 (match-beginning 0))))
1359 (defsubst gnus-simplify-subject-re (subject)
1360 "Remove \"Re:\" from subject lines."
1361 (if (string-match message-subject-re-regexp subject)
1362 (substring subject (match-end 0))
1365 (defun gnus-simplify-subject (subject &optional re-only)
1366 "Remove `Re:' and words in parentheses.
1367 If RE-ONLY is non-nil, strip leading `Re:'s only."
1368 (let ((case-fold-search t)) ;Ignore case.
1369 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1370 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1371 (setq subject (substring subject (match-end 0))))
1372 ;; Remove uninteresting prefixes.
1373 (when (and (not re-only)
1374 gnus-simplify-ignored-prefixes
1375 (string-match gnus-simplify-ignored-prefixes subject))
1376 (setq subject (substring subject (match-end 0))))
1377 ;; Remove words in parentheses from end.
1379 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1380 (setq subject (substring subject 0 (match-beginning 0)))))
1381 ;; Return subject string.
1384 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1386 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1387 (goto-char (point-min))
1388 (while (re-search-forward regexp nil t)
1389 (replace-match (or newtext ""))))
1391 (defun gnus-simplify-buffer-fuzzy ()
1392 "Simplify string in the buffer fuzzily.
1393 The string in the accessible portion of the current buffer is simplified.
1394 It is assumed to be a single-line subject.
1395 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1396 matter is removed. Additional things can be deleted by setting
1397 `gnus-simplify-subject-fuzzy-regexp'."
1398 (let ((case-fold-search t)
1400 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1402 (while (not (eq modified-tick (buffer-modified-tick)))
1403 (setq modified-tick (buffer-modified-tick))
1405 ((listp gnus-simplify-subject-fuzzy-regexp)
1406 (mapcar 'gnus-simplify-buffer-fuzzy-step
1407 gnus-simplify-subject-fuzzy-regexp))
1408 (gnus-simplify-subject-fuzzy-regexp
1409 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1410 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1411 (gnus-simplify-buffer-fuzzy-step
1412 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1413 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1415 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1416 (gnus-simplify-buffer-fuzzy-step " +" " ")
1417 (gnus-simplify-buffer-fuzzy-step " $")
1418 (gnus-simplify-buffer-fuzzy-step "^ +")))
1420 (defun gnus-simplify-subject-fuzzy (subject)
1421 "Simplify a subject string fuzzily.
1422 See `gnus-simplify-buffer-fuzzy' for details."
1424 (gnus-set-work-buffer)
1425 (let ((case-fold-search t))
1426 ;; Remove uninteresting prefixes.
1427 (when (and gnus-simplify-ignored-prefixes
1428 (string-match gnus-simplify-ignored-prefixes subject))
1429 (setq subject (substring subject (match-end 0))))
1431 (inline (gnus-simplify-buffer-fuzzy))
1434 (defsubst gnus-simplify-subject-fully (subject)
1435 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1437 (gnus-simplify-subject-functions
1438 (gnus-map-function gnus-simplify-subject-functions subject))
1439 ((null gnus-summary-gather-subject-limit)
1440 (gnus-simplify-subject-re subject))
1441 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1442 (gnus-simplify-subject-fuzzy subject))
1443 ((numberp gnus-summary-gather-subject-limit)
1444 (gnus-limit-string (gnus-simplify-subject-re subject)
1445 gnus-summary-gather-subject-limit))
1449 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1450 "Check whether two subjects are equal.
1451 If optional argument simple-first is t, first argument is already
1454 ((null simple-first)
1455 (equal (gnus-simplify-subject-fully s1)
1456 (gnus-simplify-subject-fully s2)))
1459 (gnus-simplify-subject-fully s2)))))
1461 (defun gnus-summary-bubble-group ()
1462 "Increase the score of the current group.
1463 This is a handy function to add to `gnus-summary-exit-hook' to
1464 increase the score of each group you read."
1465 (gnus-group-add-score gnus-newsgroup-name))
1469 ;;; Gnus summary mode
1472 (put 'gnus-summary-mode 'mode-class 'special)
1474 (defvar gnus-article-commands-menu)
1477 ;; Non-orthogonal keys
1479 (gnus-define-keys gnus-summary-mode-map
1480 " " gnus-summary-next-page
1481 "\177" gnus-summary-prev-page
1482 [delete] gnus-summary-prev-page
1483 [backspace] gnus-summary-prev-page
1484 "\r" gnus-summary-scroll-up
1485 "\M-\r" gnus-summary-scroll-down
1486 "n" gnus-summary-next-unread-article
1487 "p" gnus-summary-prev-unread-article
1488 "N" gnus-summary-next-article
1489 "P" gnus-summary-prev-article
1490 "\M-\C-n" gnus-summary-next-same-subject
1491 "\M-\C-p" gnus-summary-prev-same-subject
1492 "\M-n" gnus-summary-next-unread-subject
1493 "\M-p" gnus-summary-prev-unread-subject
1494 "." gnus-summary-first-unread-article
1495 "," gnus-summary-best-unread-article
1496 "\M-s" gnus-summary-search-article-forward
1497 "\M-r" gnus-summary-search-article-backward
1498 "<" gnus-summary-beginning-of-article
1499 ">" gnus-summary-end-of-article
1500 "j" gnus-summary-goto-article
1501 "^" gnus-summary-refer-parent-article
1502 "\M-^" gnus-summary-refer-article
1503 "u" gnus-summary-tick-article-forward
1504 "!" gnus-summary-tick-article-forward
1505 "U" gnus-summary-tick-article-backward
1506 "d" gnus-summary-mark-as-read-forward
1507 "D" gnus-summary-mark-as-read-backward
1508 "E" gnus-summary-mark-as-expirable
1509 "\M-u" gnus-summary-clear-mark-forward
1510 "\M-U" gnus-summary-clear-mark-backward
1511 "k" gnus-summary-kill-same-subject-and-select
1512 "\C-k" gnus-summary-kill-same-subject
1513 "\M-\C-k" gnus-summary-kill-thread
1514 "\M-\C-l" gnus-summary-lower-thread
1515 "e" gnus-summary-edit-article
1516 "#" gnus-summary-mark-as-processable
1517 "\M-#" gnus-summary-unmark-as-processable
1518 "\M-\C-t" gnus-summary-toggle-threads
1519 "\M-\C-s" gnus-summary-show-thread
1520 "\M-\C-h" gnus-summary-hide-thread
1521 "\M-\C-f" gnus-summary-next-thread
1522 "\M-\C-b" gnus-summary-prev-thread
1523 [(meta down)] gnus-summary-next-thread
1524 [(meta up)] gnus-summary-prev-thread
1525 "\M-\C-u" gnus-summary-up-thread
1526 "\M-\C-d" gnus-summary-down-thread
1527 "&" gnus-summary-execute-command
1528 "c" gnus-summary-catchup-and-exit
1529 "\C-w" gnus-summary-mark-region-as-read
1530 "\C-t" gnus-summary-toggle-truncation
1531 "?" gnus-summary-mark-as-dormant
1532 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1533 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1534 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1535 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1536 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1537 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1538 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1539 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1540 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1541 "=" gnus-summary-expand-window
1542 "\C-x\C-s" gnus-summary-reselect-current-group
1543 "\M-g" gnus-summary-rescan-group
1544 "w" gnus-summary-stop-page-breaking
1545 "\C-c\C-r" gnus-summary-caesar-message
1546 "\M-t" gnus-summary-toggle-mime
1547 "f" gnus-summary-followup
1548 "F" gnus-summary-followup-with-original
1549 "C" gnus-summary-cancel-article
1550 "r" gnus-summary-reply
1551 "R" gnus-summary-reply-with-original
1552 "\C-c\C-f" gnus-summary-mail-forward
1553 "o" gnus-summary-save-article
1554 "\C-o" gnus-summary-save-article-mail
1555 "|" gnus-summary-pipe-output
1556 "\M-k" gnus-summary-edit-local-kill
1557 "\M-K" gnus-summary-edit-global-kill
1559 "\C-c\C-d" gnus-summary-describe-group
1560 "q" gnus-summary-exit
1561 "Q" gnus-summary-exit-no-update
1562 "\C-c\C-i" gnus-info-find-node
1563 gnus-mouse-2 gnus-mouse-pick-article
1564 "m" gnus-summary-mail-other-window
1565 "a" gnus-summary-post-news
1566 "i" gnus-summary-news-other-window
1567 "x" gnus-summary-limit-to-unread
1568 "s" gnus-summary-isearch-article
1569 "t" gnus-article-toggle-headers
1570 "g" gnus-summary-show-article
1571 "l" gnus-summary-goto-last-article
1572 "v" gnus-summary-preview-mime-message
1573 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1574 "\C-d" gnus-summary-enter-digest-group
1575 "\M-\C-d" gnus-summary-read-document
1576 "\M-\C-e" gnus-summary-edit-parameters
1577 "\M-\C-a" gnus-summary-customize-parameters
1579 "\C-c\C-n" gnus-namazu-search
1580 "*" gnus-cache-enter-article
1581 "\M-*" gnus-cache-remove-article
1582 "\M-&" gnus-summary-universal-argument
1583 "\C-l" gnus-recenter
1584 "I" gnus-summary-increase-score
1585 "L" gnus-summary-lower-score
1586 "\M-i" gnus-symbolic-argument
1587 "h" gnus-summary-select-article-buffer
1589 "V" gnus-summary-score-map
1590 "X" gnus-uu-extract-map
1591 "S" gnus-summary-send-map)
1593 ;; Sort of orthogonal keymap
1594 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1595 "t" gnus-summary-tick-article-forward
1596 "!" gnus-summary-tick-article-forward
1597 "d" gnus-summary-mark-as-read-forward
1598 "r" gnus-summary-mark-as-read-forward
1599 "c" gnus-summary-clear-mark-forward
1600 " " gnus-summary-clear-mark-forward
1601 "e" gnus-summary-mark-as-expirable
1602 "x" gnus-summary-mark-as-expirable
1603 "?" gnus-summary-mark-as-dormant
1604 "b" gnus-summary-set-bookmark
1605 "B" gnus-summary-remove-bookmark
1606 "#" gnus-summary-mark-as-processable
1607 "\M-#" gnus-summary-unmark-as-processable
1608 "S" gnus-summary-limit-include-expunged
1609 "C" gnus-summary-catchup
1610 "H" gnus-summary-catchup-to-here
1611 "h" gnus-summary-catchup-from-here
1612 "\C-c" gnus-summary-catchup-all
1613 "k" gnus-summary-kill-same-subject-and-select
1614 "K" gnus-summary-kill-same-subject
1615 "P" gnus-uu-mark-map)
1617 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1618 "c" gnus-summary-clear-above
1619 "u" gnus-summary-tick-above
1620 "m" gnus-summary-mark-above
1621 "k" gnus-summary-kill-below)
1623 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1624 "/" gnus-summary-limit-to-subject
1625 "n" gnus-summary-limit-to-articles
1626 "w" gnus-summary-pop-limit
1627 "s" gnus-summary-limit-to-subject
1628 "a" gnus-summary-limit-to-author
1629 "u" gnus-summary-limit-to-unread
1630 "m" gnus-summary-limit-to-marks
1631 "M" gnus-summary-limit-exclude-marks
1632 "v" gnus-summary-limit-to-score
1633 "*" gnus-summary-limit-include-cached
1634 "D" gnus-summary-limit-include-dormant
1635 "T" gnus-summary-limit-include-thread
1636 "d" gnus-summary-limit-exclude-dormant
1637 "t" gnus-summary-limit-to-age
1638 "x" gnus-summary-limit-to-extra
1639 "p" gnus-summary-limit-to-display-predicate
1640 "E" gnus-summary-limit-include-expunged
1641 "c" gnus-summary-limit-exclude-childless-dormant
1642 "C" gnus-summary-limit-mark-excluded-as-read
1643 "o" gnus-summary-insert-old-articles
1644 "N" gnus-summary-insert-new-articles)
1646 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1647 "n" gnus-summary-next-unread-article
1648 "p" gnus-summary-prev-unread-article
1649 "N" gnus-summary-next-article
1650 "P" gnus-summary-prev-article
1651 "\C-n" gnus-summary-next-same-subject
1652 "\C-p" gnus-summary-prev-same-subject
1653 "\M-n" gnus-summary-next-unread-subject
1654 "\M-p" gnus-summary-prev-unread-subject
1655 "f" gnus-summary-first-unread-article
1656 "b" gnus-summary-best-unread-article
1657 "j" gnus-summary-goto-article
1658 "g" gnus-summary-goto-subject
1659 "l" gnus-summary-goto-last-article
1660 "o" gnus-summary-pop-article)
1662 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1663 "k" gnus-summary-kill-thread
1664 "l" gnus-summary-lower-thread
1665 "i" gnus-summary-raise-thread
1666 "T" gnus-summary-toggle-threads
1667 "t" gnus-summary-rethread-current
1668 "^" gnus-summary-reparent-thread
1669 "s" gnus-summary-show-thread
1670 "S" gnus-summary-show-all-threads
1671 "h" gnus-summary-hide-thread
1672 "H" gnus-summary-hide-all-threads
1673 "n" gnus-summary-next-thread
1674 "p" gnus-summary-prev-thread
1675 "u" gnus-summary-up-thread
1676 "o" gnus-summary-top-thread
1677 "d" gnus-summary-down-thread
1678 "#" gnus-uu-mark-thread
1679 "\M-#" gnus-uu-unmark-thread)
1681 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1682 "g" gnus-summary-prepare
1683 "c" gnus-summary-insert-cached-articles)
1685 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1686 "c" gnus-summary-catchup-and-exit
1687 "C" gnus-summary-catchup-all-and-exit
1688 "E" gnus-summary-exit-no-update
1689 "J" gnus-summary-jump-to-other-group
1690 "Q" gnus-summary-exit
1691 "Z" gnus-summary-exit
1692 "n" gnus-summary-catchup-and-goto-next-group
1693 "R" gnus-summary-reselect-current-group
1694 "G" gnus-summary-rescan-group
1695 "N" gnus-summary-next-group
1696 "s" gnus-summary-save-newsrc
1697 "P" gnus-summary-prev-group)
1699 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1700 " " gnus-summary-next-page
1701 "n" gnus-summary-next-page
1702 "\177" gnus-summary-prev-page
1703 [delete] gnus-summary-prev-page
1704 "p" gnus-summary-prev-page
1705 "\r" gnus-summary-scroll-up
1706 "\M-\r" gnus-summary-scroll-down
1707 "<" gnus-summary-beginning-of-article
1708 ">" gnus-summary-end-of-article
1709 "b" gnus-summary-beginning-of-article
1710 "e" gnus-summary-end-of-article
1711 "^" gnus-summary-refer-parent-article
1712 "r" gnus-summary-refer-parent-article
1713 "D" gnus-summary-enter-digest-group
1714 "R" gnus-summary-refer-references
1715 "T" gnus-summary-refer-thread
1716 "g" gnus-summary-show-article
1717 "s" gnus-summary-isearch-article
1718 "P" gnus-summary-print-article
1719 "M" gnus-mailing-list-insinuate
1720 "t" gnus-article-babel)
1722 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1723 "b" gnus-article-add-buttons
1724 "B" gnus-article-add-buttons-to-head
1725 "o" gnus-article-treat-overstrike
1726 "e" gnus-article-emphasize
1727 "w" gnus-article-fill-cited-article
1728 "Q" gnus-article-fill-long-lines
1729 "C" gnus-article-capitalize-sentences
1730 "c" gnus-article-remove-cr
1731 "Z" gnus-article-decode-HZ
1732 "f" gnus-article-display-x-face
1733 "l" gnus-summary-stop-page-breaking
1734 "r" gnus-summary-caesar-message
1735 "t" gnus-article-toggle-headers
1736 "g" gnus-summary-toggle-smiley
1737 "v" gnus-summary-verbose-headers
1738 "m" gnus-summary-toggle-mime
1739 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1740 "p" gnus-article-verify-x-pgp-sig
1741 "d" gnus-article-treat-dumbquotes)
1743 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1744 "a" gnus-article-hide
1745 "h" gnus-article-toggle-headers
1746 "b" gnus-article-hide-boring-headers
1747 "s" gnus-article-hide-signature
1748 "c" gnus-article-hide-citation
1749 "C" gnus-article-hide-citation-in-followups
1750 "l" gnus-article-hide-list-identifiers
1751 "p" gnus-article-hide-pgp
1752 "B" gnus-article-strip-banner
1753 "P" gnus-article-hide-pem
1754 "\C-c" gnus-article-hide-citation-maybe)
1756 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1757 "a" gnus-article-highlight
1758 "h" gnus-article-highlight-headers
1759 "c" gnus-article-highlight-citation
1760 "s" gnus-article-highlight-signature)
1762 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1763 "z" gnus-article-date-ut
1764 "u" gnus-article-date-ut
1765 "l" gnus-article-date-local
1766 "p" gnus-article-date-english
1767 "e" gnus-article-date-lapsed
1768 "o" gnus-article-date-original
1769 "i" gnus-article-date-iso8601
1770 "s" gnus-article-date-user)
1772 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1773 "t" gnus-article-remove-trailing-blank-lines
1774 "l" gnus-article-strip-leading-blank-lines
1775 "m" gnus-article-strip-multiple-blank-lines
1776 "a" gnus-article-strip-blank-lines
1777 "A" gnus-article-strip-all-blank-lines
1778 "s" gnus-article-strip-leading-space
1779 "e" gnus-article-strip-trailing-space
1780 "w" gnus-article-remove-leading-whitespace)
1782 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1784 "f" gnus-summary-fetch-faq
1785 "d" gnus-summary-describe-group
1786 "h" gnus-summary-describe-briefly
1787 "i" gnus-info-find-node)
1789 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1790 "e" gnus-summary-expire-articles
1791 "\M-\C-e" gnus-summary-expire-articles-now
1792 "\177" gnus-summary-delete-article
1793 [delete] gnus-summary-delete-article
1794 [backspace] gnus-summary-delete-article
1795 "m" gnus-summary-move-article
1796 "r" gnus-summary-respool-article
1797 "w" gnus-summary-edit-article
1798 "c" gnus-summary-copy-article
1799 "B" gnus-summary-crosspost-article
1800 "q" gnus-summary-respool-query
1801 "t" gnus-summary-respool-trace
1802 "i" gnus-summary-import-article
1803 "I" gnus-summary-create-article
1804 "p" gnus-summary-article-posted-p)
1806 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1807 "o" gnus-summary-save-article
1808 "m" gnus-summary-save-article-mail
1809 "F" gnus-summary-write-article-file
1810 "r" gnus-summary-save-article-rmail
1811 "f" gnus-summary-save-article-file
1812 "b" gnus-summary-save-article-body-file
1813 "h" gnus-summary-save-article-folder
1814 "v" gnus-summary-save-article-vm
1815 "p" gnus-summary-pipe-output
1816 "s" gnus-soup-add-article)
1818 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1819 "b" gnus-summary-display-buttonized
1820 "m" gnus-summary-repair-multipart
1821 "v" gnus-article-view-part
1822 "o" gnus-article-save-part
1823 "c" gnus-article-copy-part
1824 "C" gnus-article-view-part-as-charset
1825 "e" gnus-article-externalize-part
1826 "E" gnus-article-encrypt-body
1827 "i" gnus-article-inline-part
1828 "|" gnus-article-pipe-part))
1830 (defvar gnus-article-post-menu nil)
1832 (defun gnus-summary-make-menu-bar ()
1833 (gnus-turn-off-edit-menu 'summary)
1835 (unless (boundp 'gnus-summary-misc-menu)
1838 gnus-summary-kill-menu gnus-summary-mode-map ""
1843 ["Customize" gnus-score-customize t])
1844 (gnus-make-score-map 'increase)
1845 (gnus-make-score-map 'lower)
1847 ["Kill below" gnus-summary-kill-below t]
1848 ["Mark above" gnus-summary-mark-above t]
1849 ["Tick above" gnus-summary-tick-above t]
1850 ["Clear above" gnus-summary-clear-above t])
1851 ["Current score" gnus-summary-current-score t]
1852 ["Set score" gnus-summary-set-score t]
1853 ["Switch current score file..." gnus-score-change-score-file t]
1854 ["Set mark below..." gnus-score-set-mark-below t]
1855 ["Set expunge below..." gnus-score-set-expunge-below t]
1856 ["Edit current score file" gnus-score-edit-current-scores t]
1857 ["Edit score file" gnus-score-edit-file t]
1858 ["Trace score" gnus-score-find-trace t]
1859 ["Find words" gnus-score-find-favourite-words t]
1860 ["Rescore buffer" gnus-summary-rescore t]
1861 ["Increase score..." gnus-summary-increase-score t]
1862 ["Lower score..." gnus-summary-lower-score t]))))
1864 ;; Define both the Article menu in the summary buffer and the equivalent
1865 ;; Commands menu in the article buffer here for consistency.
1868 ["All" gnus-article-hide t]
1869 ["Headers" gnus-article-toggle-headers t]
1870 ["Signature" gnus-article-hide-signature t]
1871 ["Citation" gnus-article-hide-citation t]
1872 ["List identifiers" gnus-article-hide-list-identifiers t]
1873 ["PGP" gnus-article-hide-pgp t]
1874 ["Banner" gnus-article-strip-banner t]
1875 ["Boring headers" gnus-article-hide-boring-headers t])
1877 ["All" gnus-article-highlight t]
1878 ["Headers" gnus-article-highlight-headers t]
1879 ["Signature" gnus-article-highlight-signature t]
1880 ["Citation" gnus-article-highlight-citation t])
1882 ["Local" gnus-article-date-local t]
1883 ["ISO8601" gnus-article-date-iso8601 t]
1884 ["UT" gnus-article-date-ut t]
1885 ["Original" gnus-article-date-original t]
1886 ["Lapsed" gnus-article-date-lapsed t]
1887 ["User-defined" gnus-article-date-user t])
1890 ["Leading" gnus-article-strip-leading-blank-lines t]
1891 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1892 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1893 ["All of the above" gnus-article-strip-blank-lines t]
1894 ["All" gnus-article-strip-all-blank-lines t]
1895 ["Leading space" gnus-article-strip-leading-space t]
1896 ["Trailing space" gnus-article-strip-trailing-space t]
1897 ["Leading space in headers"
1898 gnus-article-remove-leading-whitespace t])
1899 ["Overstrike" gnus-article-treat-overstrike t]
1900 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1901 ["Emphasis" gnus-article-emphasize t]
1902 ["Word wrap" gnus-article-fill-cited-article t]
1903 ["Fill long lines" gnus-article-fill-long-lines t]
1904 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1905 ["CR" gnus-article-remove-cr t]
1906 ["Show X-Face" gnus-article-display-x-face t]
1907 ["Rot 13" gnus-summary-caesar-message
1908 ,@(if (featurep 'xemacs) '(t)
1909 '(:help "\"Caesar rotate\" article by 13"))]
1910 ["Unix pipe" gnus-summary-pipe-message t]
1911 ["Add buttons" gnus-article-add-buttons t]
1912 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1913 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1914 ["Toggle MIME" gnus-summary-toggle-mime t]
1915 ["Verbose header" gnus-summary-verbose-headers t]
1916 ["Toggle header" gnus-summary-toggle-header t]
1917 ["Toggle smiley" gnus-summary-toggle-smiley t]
1918 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1919 ["HZ" gnus-article-decode-HZ t])
1921 ["Save in default format" gnus-summary-save-article
1922 ,@(if (featurep 'xemacs) '(t)
1923 '(:help "Save article using default method"))]
1924 ["Save in file" gnus-summary-save-article-file
1925 ,@(if (featurep 'xemacs) '(t)
1926 '(:help "Save article in file"))]
1927 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1928 ["Save in MH folder" gnus-summary-save-article-folder t]
1929 ["Save in VM folder" gnus-summary-save-article-vm t]
1930 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1931 ["Save body in file" gnus-summary-save-article-body-file t]
1932 ["Pipe through a filter" gnus-summary-pipe-output t]
1933 ["Add to SOUP packet" gnus-soup-add-article t]
1934 ["Print" gnus-summary-print-article t])
1936 ["Respool article..." gnus-summary-respool-article t]
1937 ["Move article..." gnus-summary-move-article
1938 (gnus-check-backend-function
1939 'request-move-article gnus-newsgroup-name)]
1940 ["Copy article..." gnus-summary-copy-article t]
1941 ["Crosspost article..." gnus-summary-crosspost-article
1942 (gnus-check-backend-function
1943 'request-replace-article gnus-newsgroup-name)]
1944 ["Import file..." gnus-summary-import-article t]
1945 ["Create article..." gnus-summary-create-article t]
1946 ["Check if posted" gnus-summary-article-posted-p t]
1947 ["Edit article" gnus-summary-edit-article
1948 (not (gnus-group-read-only-p))]
1949 ["Delete article" gnus-summary-delete-article
1950 (gnus-check-backend-function
1951 'request-expire-articles gnus-newsgroup-name)]
1952 ["Query respool" gnus-summary-respool-query t]
1953 ["Trace respool" gnus-summary-respool-trace t]
1954 ["Delete expirable articles" gnus-summary-expire-articles-now
1955 (gnus-check-backend-function
1956 'request-expire-articles gnus-newsgroup-name)])
1958 ["Uudecode" gnus-uu-decode-uu
1959 ,@(if (featurep 'xemacs) '(t)
1960 '(:help "Decode uuencoded article(s)"))]
1961 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1962 ["Unshar" gnus-uu-decode-unshar t]
1963 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1964 ["Save" gnus-uu-decode-save t]
1965 ["Binhex" gnus-uu-decode-binhex t]
1966 ["Postscript" gnus-uu-decode-postscript t])
1968 ["Enter article" gnus-cache-enter-article t]
1969 ["Remove article" gnus-cache-remove-article t])
1970 ["Translate" gnus-article-babel t]
1971 ["Select article buffer" gnus-summary-select-article-buffer t]
1972 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1973 ["Isearch article..." gnus-summary-isearch-article t]
1974 ["Beginning of the article" gnus-summary-beginning-of-article t]
1975 ["End of the article" gnus-summary-end-of-article t]
1976 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1977 ["Fetch referenced articles" gnus-summary-refer-references t]
1978 ["Fetch current thread" gnus-summary-refer-thread t]
1979 ["Fetch article with id..." gnus-summary-refer-article t]
1980 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1981 ["Redisplay" gnus-summary-show-article t]
1982 ["Raw article" gnus-summary-show-raw-article t])))
1984 gnus-summary-article-menu gnus-summary-mode-map ""
1985 (cons "Article" innards))
1987 (if (not (keymapp gnus-summary-article-menu))
1989 gnus-article-commands-menu gnus-article-mode-map ""
1990 (cons "Commands" innards))
1991 ;; in Emacs, don't share menu.
1992 (setq gnus-article-commands-menu
1993 (copy-keymap gnus-summary-article-menu))
1994 (define-key gnus-article-mode-map [menu-bar commands]
1995 (cons "Commands" gnus-article-commands-menu))))
1998 gnus-summary-thread-menu gnus-summary-mode-map ""
2000 ["Toggle threading" gnus-summary-toggle-threads t]
2001 ["Hide threads" gnus-summary-hide-all-threads t]
2002 ["Show threads" gnus-summary-show-all-threads t]
2003 ["Hide thread" gnus-summary-hide-thread t]
2004 ["Show thread" gnus-summary-show-thread t]
2005 ["Go to next thread" gnus-summary-next-thread t]
2006 ["Go to previous thread" gnus-summary-prev-thread t]
2007 ["Go down thread" gnus-summary-down-thread t]
2008 ["Go up thread" gnus-summary-up-thread t]
2009 ["Top of thread" gnus-summary-top-thread t]
2010 ["Mark thread as read" gnus-summary-kill-thread t]
2011 ["Lower thread score" gnus-summary-lower-thread t]
2012 ["Raise thread score" gnus-summary-raise-thread t]
2013 ["Rethread current" gnus-summary-rethread-current t]))
2016 gnus-summary-post-menu gnus-summary-mode-map ""
2018 ["Send a message (mail or news)" gnus-summary-post-news
2019 ,@(if (featurep 'xemacs) '(t)
2020 '(:help "Post an article"))]
2021 ["Followup" gnus-summary-followup
2022 ,@(if (featurep 'xemacs) '(t)
2023 '(:help "Post followup to this article"))]
2024 ["Followup and yank" gnus-summary-followup-with-original
2025 ,@(if (featurep 'xemacs) '(t)
2026 '(:help "Post followup to this article, quoting its contents"))]
2027 ["Supersede article" gnus-summary-supersede-article t]
2028 ["Cancel article" gnus-summary-cancel-article
2029 ,@(if (featurep 'xemacs) '(t)
2030 '(:help "Cancel an article you posted"))]
2031 ["Reply" gnus-summary-reply t]
2032 ["Reply and yank" gnus-summary-reply-with-original t]
2033 ["Wide reply" gnus-summary-wide-reply t]
2034 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2035 ,@(if (featurep 'xemacs) '(t)
2036 '(:help "Mail a reply, quoting this article"))]
2037 ["Mail forward" gnus-summary-mail-forward t]
2038 ["Post forward" gnus-summary-post-forward t]
2039 ["Digest and mail" gnus-summary-digest-mail-forward t]
2040 ["Digest and post" gnus-summary-digest-post-forward t]
2041 ["Resend message" gnus-summary-resend-message t]
2042 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2043 ["Send a mail" gnus-summary-mail-other-window t]
2044 ["Create a local message" gnus-summary-news-other-window t]
2045 ["Uuencode and post" gnus-uu-post-news
2046 ,@(if (featurep 'xemacs) '(t)
2047 '(:help "Post a uuencoded article"))]
2048 ["Followup via news" gnus-summary-followup-to-mail t]
2049 ["Followup via news and yank"
2050 gnus-summary-followup-to-mail-with-original t]
2052 ;;["Send" gnus-summary-send-draft t]
2053 ;;["Send bounced" gnus-resend-bounced-mail t])
2057 ((not (keymapp gnus-summary-post-menu))
2058 (setq gnus-article-post-menu gnus-summary-post-menu))
2059 ((not gnus-article-post-menu)
2060 ;; Don't share post menu.
2061 (setq gnus-article-post-menu
2062 (copy-keymap gnus-summary-post-menu))))
2063 (define-key gnus-article-mode-map [menu-bar post]
2064 (cons "Post" gnus-article-post-menu))
2067 gnus-summary-misc-menu gnus-summary-mode-map ""
2070 ["Mark as read" gnus-summary-mark-as-read-forward t]
2071 ["Mark same subject and select"
2072 gnus-summary-kill-same-subject-and-select t]
2073 ["Mark same subject" gnus-summary-kill-same-subject t]
2074 ["Catchup" gnus-summary-catchup
2075 ,@(if (featurep 'xemacs) '(t)
2076 '(:help "Mark unread articles in this group as read"))]
2077 ["Catchup all" gnus-summary-catchup-all t]
2078 ["Catchup to here" gnus-summary-catchup-to-here t]
2079 ["Catchup from here" gnus-summary-catchup-from-here t]
2080 ["Catchup region" gnus-summary-mark-region-as-read t]
2081 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2083 ["Tick" gnus-summary-tick-article-forward t]
2084 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2085 ["Remove marks" gnus-summary-clear-mark-forward t]
2086 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2087 ["Set bookmark" gnus-summary-set-bookmark t]
2088 ["Remove bookmark" gnus-summary-remove-bookmark t])
2090 ["Marks..." gnus-summary-limit-to-marks t]
2091 ["Subject..." gnus-summary-limit-to-subject t]
2092 ["Author..." gnus-summary-limit-to-author t]
2093 ["Age..." gnus-summary-limit-to-age t]
2094 ["Extra..." gnus-summary-limit-to-extra t]
2095 ["Score" gnus-summary-limit-to-score t]
2096 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2097 ["Unread" gnus-summary-limit-to-unread t]
2098 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2099 ["Articles" gnus-summary-limit-to-articles t]
2100 ["Pop limit" gnus-summary-pop-limit t]
2101 ["Show dormant" gnus-summary-limit-include-dormant t]
2102 ["Hide childless dormant"
2103 gnus-summary-limit-exclude-childless-dormant t]
2104 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2105 ["Hide marked" gnus-summary-limit-exclude-marks t]
2106 ["Show expunged" gnus-summary-limit-include-expunged t])
2108 ["Set mark" gnus-summary-mark-as-processable t]
2109 ["Remove mark" gnus-summary-unmark-as-processable t]
2110 ["Remove all marks" gnus-summary-unmark-all-processable t]
2111 ["Mark above" gnus-uu-mark-over t]
2112 ["Mark series" gnus-uu-mark-series t]
2113 ["Mark region" gnus-uu-mark-region t]
2114 ["Unmark region" gnus-uu-unmark-region t]
2115 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2116 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2117 ["Mark all" gnus-uu-mark-all t]
2118 ["Mark buffer" gnus-uu-mark-buffer t]
2119 ["Mark sparse" gnus-uu-mark-sparse t]
2120 ["Mark thread" gnus-uu-mark-thread t]
2121 ["Unmark thread" gnus-uu-unmark-thread t]
2122 ("Process Mark Sets"
2123 ["Kill" gnus-summary-kill-process-mark t]
2124 ["Yank" gnus-summary-yank-process-mark
2125 gnus-newsgroup-process-stack]
2126 ["Save" gnus-summary-save-process-mark t]))
2128 ["Page forward" gnus-summary-next-page
2129 ,@(if (featurep 'xemacs) '(t)
2130 '(:help "Show next page of article"))]
2131 ["Page backward" gnus-summary-prev-page
2132 ,@(if (featurep 'xemacs) '(t)
2133 '(:help "Show previous page of article"))]
2134 ["Line forward" gnus-summary-scroll-up t])
2136 ["Next unread article" gnus-summary-next-unread-article t]
2137 ["Previous unread article" gnus-summary-prev-unread-article t]
2138 ["Next article" gnus-summary-next-article t]
2139 ["Previous article" gnus-summary-prev-article t]
2140 ["Next unread subject" gnus-summary-next-unread-subject t]
2141 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2142 ["Next article same subject" gnus-summary-next-same-subject t]
2143 ["Previous article same subject" gnus-summary-prev-same-subject t]
2144 ["First unread article" gnus-summary-first-unread-article t]
2145 ["Best unread article" gnus-summary-best-unread-article t]
2146 ["Go to subject number..." gnus-summary-goto-subject t]
2147 ["Go to article number..." gnus-summary-goto-article t]
2148 ["Go to the last article" gnus-summary-goto-last-article t]
2149 ["Pop article off history" gnus-summary-pop-article t])
2151 ["Sort by number" gnus-summary-sort-by-number t]
2152 ["Sort by author" gnus-summary-sort-by-author t]
2153 ["Sort by subject" gnus-summary-sort-by-subject t]
2154 ["Sort by date" gnus-summary-sort-by-date t]
2155 ["Sort by score" gnus-summary-sort-by-score t]
2156 ["Sort by lines" gnus-summary-sort-by-lines t]
2157 ["Sort by characters" gnus-summary-sort-by-chars t]
2158 ["Original sort" gnus-summary-sort-by-original t])
2160 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2161 ["Describe group" gnus-summary-describe-group t]
2162 ["Read manual" gnus-info-find-node t])
2164 ["Pick and read" gnus-pick-mode t]
2165 ["Binary" gnus-binary-mode t])
2167 ["Regenerate" gnus-summary-prepare t]
2168 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2169 ["Toggle threading" gnus-summary-toggle-threads t])
2170 ["See old articles" gnus-summary-insert-old-articles t]
2171 ["See new articles" gnus-summary-insert-new-articles t]
2172 ["Filter articles..." gnus-summary-execute-command t]
2173 ["Run command on subjects..." gnus-summary-universal-argument t]
2174 ["Search articles forward..." gnus-summary-search-article-forward t]
2175 ["Search articles backward..." gnus-summary-search-article-backward t]
2176 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2177 ["Expand window" gnus-summary-expand-window t]
2178 ["Expire expirable articles" gnus-summary-expire-articles
2179 (gnus-check-backend-function
2180 'request-expire-articles gnus-newsgroup-name)]
2181 ["Edit local kill file" gnus-summary-edit-local-kill t]
2182 ["Edit main kill file" gnus-summary-edit-global-kill t]
2183 ["Edit group parameters" gnus-summary-edit-parameters t]
2184 ["Customize group parameters" gnus-summary-customize-parameters t]
2185 ["Send a bug report" gnus-bug t]
2187 ["Catchup and exit" gnus-summary-catchup-and-exit
2188 ,@(if (featurep 'xemacs) '(t)
2189 '(:help "Mark unread articles in this group as read, then exit"))]
2190 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2191 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2192 ["Exit group" gnus-summary-exit
2193 ,@(if (featurep 'xemacs) '(t)
2194 '(:help "Exit current group, return to group selection mode"))]
2195 ["Exit group without updating" gnus-summary-exit-no-update t]
2196 ["Exit and goto next group" gnus-summary-next-group t]
2197 ["Exit and goto prev group" gnus-summary-prev-group t]
2198 ["Reselect group" gnus-summary-reselect-current-group t]
2199 ["Rescan group" gnus-summary-rescan-group t]
2200 ["Update dribble" gnus-summary-save-newsrc t])))
2202 (gnus-run-hooks 'gnus-summary-menu-hook)))
2204 (defvar gnus-summary-tool-bar-map nil)
2206 ;; Emacs 21 tool bar. Should be no-op otherwise.
2207 (defun gnus-summary-make-tool-bar ()
2208 (if (and (fboundp 'tool-bar-add-item-from-menu)
2209 (default-value 'tool-bar-mode)
2210 (not gnus-summary-tool-bar-map))
2211 (setq gnus-summary-tool-bar-map
2212 (let ((tool-bar-map (make-sparse-keymap))
2213 (load-path (mm-image-load-path)))
2214 (tool-bar-add-item-from-menu
2215 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2216 (tool-bar-add-item-from-menu
2217 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2218 (tool-bar-add-item-from-menu
2219 'gnus-summary-post-news "post" gnus-summary-mode-map)
2220 (tool-bar-add-item-from-menu
2221 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2222 (tool-bar-add-item-from-menu
2223 'gnus-summary-followup "followup" gnus-summary-mode-map)
2224 (tool-bar-add-item-from-menu
2225 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2226 (tool-bar-add-item-from-menu
2227 'gnus-summary-reply "reply" gnus-summary-mode-map)
2228 (tool-bar-add-item-from-menu
2229 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2230 (tool-bar-add-item-from-menu
2231 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2232 (tool-bar-add-item-from-menu
2233 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2234 (tool-bar-add-item-from-menu
2235 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2236 (tool-bar-add-item-from-menu
2237 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2238 (tool-bar-add-item-from-menu
2239 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2240 (tool-bar-add-item-from-menu
2241 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2242 (tool-bar-add-item-from-menu
2243 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2245 (if gnus-summary-tool-bar-map
2246 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2248 (defun gnus-score-set-default (var value)
2249 "A version of set that updates the GNU Emacs menu-bar."
2251 ;; It is the message that forces the active status to be updated.
2254 (defun gnus-make-score-map (type)
2255 "Make a summary score map of type TYPE."
2258 (let ((headers '(("author" "from" string)
2259 ("subject" "subject" string)
2260 ("article body" "body" string)
2261 ("article head" "head" string)
2262 ("xref" "xref" string)
2263 ("extra header" "extra" string)
2264 ("lines" "lines" number)
2265 ("followups to author" "followup" string)))
2266 (types '((number ("less than" <)
2269 (string ("substring" s)
2273 (perms '(("temporary" (current-time-string))
2281 (if (eq type 'lower)
2286 (setq header (car headers))
2292 (let ((ts (cdr (assoc (nth 2 header) types)))
2308 'gnus-summary-score-entry
2310 (if (or (string= (nth 1 header)
2312 (string= (nth 1 header)
2315 (list 'gnus-summary-header
2317 (list 'quote (nth 1 (car ts)))
2318 (list 'gnus-score-delta-default
2325 (list (nreverse outp))))
2328 (list (nreverse outt))))
2330 (setq headers (cdr headers)))
2331 (list (nreverse outh))))))))
2335 (defun gnus-summary-mode (&optional group)
2336 "Major mode for reading articles.
2338 All normal editing commands are switched off.
2339 \\<gnus-summary-mode-map>
2340 Each line in this buffer represents one article. To read an
2341 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2342 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2345 You can also post articles and send mail from this buffer. To
2346 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2347 of an article, type `\\[gnus-summary-reply]'.
2349 There are approx. one gazillion commands you can execute in this
2350 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2352 The following commands are available:
2354 \\{gnus-summary-mode-map}"
2356 (kill-all-local-variables)
2357 (when (gnus-visual-p 'summary-menu 'menu)
2358 (gnus-summary-make-menu-bar)
2359 (gnus-summary-make-tool-bar))
2360 (gnus-summary-make-local-variables)
2361 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2362 (gnus-summary-make-local-variables))
2363 (gnus-make-thread-indent-array)
2364 (gnus-simplify-mode-line)
2365 (setq major-mode 'gnus-summary-mode)
2366 (setq mode-name "Summary")
2367 (make-local-variable 'minor-mode-alist)
2368 (use-local-map gnus-summary-mode-map)
2369 (buffer-disable-undo)
2370 (setq buffer-read-only t) ;Disable modification
2371 (setq truncate-lines t)
2372 (setq selective-display t)
2373 (setq selective-display-ellipses t) ;Display `...'
2374 (gnus-summary-set-display-table)
2375 (gnus-set-default-directory)
2376 (setq gnus-newsgroup-name group)
2377 (unless (gnus-news-group-p group)
2378 (setq gnus-newsgroup-incorporated
2379 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2380 (make-local-variable 'gnus-summary-line-format)
2381 (make-local-variable 'gnus-summary-line-format-spec)
2382 (make-local-variable 'gnus-summary-dummy-line-format)
2383 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2384 (make-local-variable 'gnus-summary-mark-positions)
2385 (make-local-hook 'pre-command-hook)
2386 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2387 (gnus-run-hooks 'gnus-summary-mode-hook)
2388 (turn-on-gnus-mailing-list-mode)
2389 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2390 (gnus-update-summary-mark-positions))
2392 (defun gnus-summary-make-local-variables ()
2393 "Make all the local summary buffer variables."
2395 (dolist (local gnus-summary-local-variables)
2398 (if (eq (cdr local) 'global)
2399 ;; Copy the global value of the variable.
2400 (setq global (symbol-value (car local)))
2401 ;; Use the value from the list.
2402 (setq global (eval (cdr local))))
2403 (set (make-local-variable (car local)) global))
2404 ;; Simple nil-valued local variable.
2405 (set (make-local-variable local) nil)))))
2407 (defun gnus-summary-clear-local-variables ()
2408 (let ((locals gnus-summary-local-variables))
2410 (if (consp (car locals))
2411 (and (vectorp (caar locals))
2412 (set (caar locals) nil))
2413 (and (vectorp (car locals))
2414 (set (car locals) nil)))
2415 (setq locals (cdr locals)))))
2417 ;; Summary data functions.
2419 (defmacro gnus-data-number (data)
2422 (defmacro gnus-data-set-number (data number)
2423 `(setcar ,data ,number))
2425 (defmacro gnus-data-mark (data)
2428 (defmacro gnus-data-set-mark (data mark)
2429 `(setcar (nthcdr 1 ,data) ,mark))
2431 (defmacro gnus-data-pos (data)
2434 (defmacro gnus-data-set-pos (data pos)
2435 `(setcar (nthcdr 2 ,data) ,pos))
2437 (defmacro gnus-data-header (data)
2440 (defmacro gnus-data-set-header (data header)
2441 `(setcar (nthcdr 3 ,data) ,header))
2443 (defmacro gnus-data-level (data)
2446 (defmacro gnus-data-unread-p (data)
2447 `(= (nth 1 ,data) gnus-unread-mark))
2449 (defmacro gnus-data-read-p (data)
2450 `(/= (nth 1 ,data) gnus-unread-mark))
2452 (defmacro gnus-data-pseudo-p (data)
2453 `(consp (nth 3 ,data)))
2455 (defmacro gnus-data-find (number)
2456 `(assq ,number gnus-newsgroup-data))
2458 (defmacro gnus-data-find-list (number &optional data)
2459 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2460 (memq (assq ,number bdata)
2463 (defmacro gnus-data-make (number mark pos header level)
2464 `(list ,number ,mark ,pos ,header ,level))
2466 (defun gnus-data-enter (after-article number mark pos header level offset)
2467 (let ((data (gnus-data-find-list after-article)))
2469 (error "No such article: %d" after-article))
2470 (setcdr data (cons (gnus-data-make number mark pos header level)
2472 (setq gnus-newsgroup-data-reverse nil)
2473 (gnus-data-update-list (cddr data) offset)))
2475 (defun gnus-data-enter-list (after-article list &optional offset)
2477 (let ((data (and after-article (gnus-data-find-list after-article)))
2481 (let ((odata gnus-newsgroup-data))
2482 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2484 (gnus-data-update-list odata offset)))
2485 ;; Find the last element in the list to be spliced into the main
2488 (setq list (cdr list)))
2491 (setcdr list gnus-newsgroup-data)
2492 (setq gnus-newsgroup-data ilist)
2494 (gnus-data-update-list (cdr list) offset)))
2495 (setcdr list (cdr data))
2498 (gnus-data-update-list (cdr list) offset))))
2499 (setq gnus-newsgroup-data-reverse nil))))
2501 (defun gnus-data-remove (article &optional offset)
2502 (let ((data gnus-newsgroup-data))
2503 (if (= (gnus-data-number (car data)) article)
2505 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2506 gnus-newsgroup-data-reverse nil)
2508 (gnus-data-update-list gnus-newsgroup-data offset)))
2510 (when (= (gnus-data-number (cadr data)) article)
2511 (setcdr data (cddr data))
2513 (gnus-data-update-list (cdr data) offset))
2515 gnus-newsgroup-data-reverse nil))
2516 (setq data (cdr data))))))
2518 (defmacro gnus-data-list (backward)
2520 (or gnus-newsgroup-data-reverse
2521 (setq gnus-newsgroup-data-reverse
2522 (reverse gnus-newsgroup-data)))
2523 gnus-newsgroup-data))
2525 (defun gnus-data-update-list (data offset)
2526 "Add OFFSET to the POS of all data entries in DATA."
2527 (setq gnus-newsgroup-data-reverse nil)
2529 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2530 (setq data (cdr data))))
2532 (defun gnus-summary-article-pseudo-p (article)
2533 "Say whether this article is a pseudo article or not."
2534 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2536 (defmacro gnus-summary-article-sparse-p (article)
2537 "Say whether this article is a sparse article or not."
2538 `(memq ,article gnus-newsgroup-sparse))
2540 (defmacro gnus-summary-article-ancient-p (article)
2541 "Say whether this article is a sparse article or not."
2542 `(memq ,article gnus-newsgroup-ancient))
2544 (defun gnus-article-parent-p (number)
2545 "Say whether this article is a parent or not."
2546 (let ((data (gnus-data-find-list number)))
2547 (and (cdr data) ; There has to be an article after...
2548 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2549 (gnus-data-level (nth 1 data))))))
2551 (defun gnus-article-children (number)
2552 "Return a list of all children to NUMBER."
2553 (let* ((data (gnus-data-find-list number))
2554 (level (gnus-data-level (car data)))
2556 (setq data (cdr data))
2558 (= (gnus-data-level (car data)) (1+ level)))
2559 (push (gnus-data-number (car data)) children)
2560 (setq data (cdr data)))
2563 (defmacro gnus-summary-skip-intangible ()
2564 "If the current article is intangible, then jump to a different article."
2565 '(let ((to (get-text-property (point) 'gnus-intangible)))
2566 (and to (gnus-summary-goto-subject to))))
2568 (defmacro gnus-summary-article-intangible-p ()
2569 "Say whether this article is intangible or not."
2570 '(get-text-property (point) 'gnus-intangible))
2572 (defun gnus-article-read-p (article)
2573 "Say whether ARTICLE is read or not."
2574 (not (or (memq article gnus-newsgroup-marked)
2575 (memq article gnus-newsgroup-unreads)
2576 (memq article gnus-newsgroup-unselected)
2577 (memq article gnus-newsgroup-dormant))))
2579 ;; Some summary mode macros.
2581 (defmacro gnus-summary-article-number ()
2582 "The article number of the article on the current line.
2583 If there isn's an article number here, then we return the current
2586 (gnus-summary-skip-intangible)
2587 (or (get-text-property (point) 'gnus-number)
2588 (gnus-summary-last-subject))))
2590 (defmacro gnus-summary-article-header (&optional number)
2591 "Return the header of article NUMBER."
2592 `(gnus-data-header (gnus-data-find
2593 ,(or number '(gnus-summary-article-number)))))
2595 (defmacro gnus-summary-thread-level (&optional number)
2596 "Return the level of thread that starts with article NUMBER."
2597 `(if (and (eq gnus-summary-make-false-root 'dummy)
2598 (get-text-property (point) 'gnus-intangible))
2600 (gnus-data-level (gnus-data-find
2601 ,(or number '(gnus-summary-article-number))))))
2603 (defmacro gnus-summary-article-mark (&optional number)
2604 "Return the mark of article NUMBER."
2605 `(gnus-data-mark (gnus-data-find
2606 ,(or number '(gnus-summary-article-number)))))
2608 (defmacro gnus-summary-article-pos (&optional number)
2609 "Return the position of the line of article NUMBER."
2610 `(gnus-data-pos (gnus-data-find
2611 ,(or number '(gnus-summary-article-number)))))
2613 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2614 (defmacro gnus-summary-article-subject (&optional number)
2615 "Return current subject string or nil if nothing."
2618 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2619 '(gnus-data-header (assq (gnus-summary-article-number)
2620 gnus-newsgroup-data)))))
2623 (mail-header-subject headers))))
2625 (defmacro gnus-summary-article-score (&optional number)
2626 "Return current article score."
2627 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2628 gnus-newsgroup-scored))
2629 gnus-summary-default-score 0))
2631 (defun gnus-summary-article-children (&optional number)
2632 "Return a list of article numbers that are children of article NUMBER."
2633 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2634 (level (gnus-data-level (car data)))
2636 (while (and (setq data (cdr data))
2637 (> (setq l (gnus-data-level (car data))) level))
2638 (and (= (1+ level) l)
2639 (push (gnus-data-number (car data))
2641 (nreverse children)))
2643 (defun gnus-summary-article-parent (&optional number)
2644 "Return the article number of the parent of article NUMBER."
2645 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2646 (gnus-data-list t)))
2647 (level (gnus-data-level (car data))))
2649 () ; This is a root.
2650 ;; We search until we find an article with a level less than
2651 ;; this one. That function has to be the parent.
2652 (while (and (setq data (cdr data))
2653 (not (< (gnus-data-level (car data)) level))))
2654 (and data (gnus-data-number (car data))))))
2656 (defun gnus-unread-mark-p (mark)
2657 "Say whether MARK is the unread mark."
2658 (= mark gnus-unread-mark))
2660 (defun gnus-read-mark-p (mark)
2661 "Say whether MARK is one of the marks that mark as read.
2662 This is all marks except unread, ticked, dormant, and expirable."
2663 (not (or (= mark gnus-unread-mark)
2664 (= mark gnus-ticked-mark)
2665 (= mark gnus-dormant-mark)
2666 (= mark gnus-expirable-mark))))
2668 (defmacro gnus-article-mark (number)
2669 "Return the MARK of article NUMBER.
2670 This macro should only be used when computing the mark the \"first\"
2671 time; i.e., when generating the summary lines. After that,
2672 `gnus-summary-article-mark' should be used to examine the
2675 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2676 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2677 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2678 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2679 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2680 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2681 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2682 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2683 gnus-ancient-mark))))
2685 ;; Saving hidden threads.
2687 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2688 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2690 (defmacro gnus-save-hidden-threads (&rest forms)
2691 "Save hidden threads, eval FORMS, and restore the hidden threads."
2692 (let ((config (make-symbol "config")))
2693 `(let ((,config (gnus-hidden-threads-configuration)))
2697 (gnus-restore-hidden-threads-configuration ,config)))))
2699 (defun gnus-data-compute-positions ()
2700 "Compute the positions of all articles."
2701 (setq gnus-newsgroup-data-reverse nil)
2702 (let ((data gnus-newsgroup-data))
2704 (gnus-save-hidden-threads
2705 (gnus-summary-show-all-threads)
2706 (goto-char (point-min))
2708 (while (get-text-property (point) 'gnus-intangible)
2710 (gnus-data-set-pos (car data) (+ (point) 3))
2711 (setq data (cdr data))
2712 (forward-line 1))))))
2714 (defun gnus-hidden-threads-configuration ()
2715 "Return the current hidden threads configuration."
2718 (goto-char (point-min))
2719 (while (search-forward "\r" nil t)
2720 (push (1- (point)) config))
2723 (defun gnus-restore-hidden-threads-configuration (config)
2724 "Restore hidden threads configuration from CONFIG."
2726 (let (point buffer-read-only)
2727 (while (setq point (pop config))
2728 (when (and (< point (point-max))
2730 (eq (char-after) ?\n))
2731 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2733 ;; Various summary mode internalish functions.
2735 (defun gnus-mouse-pick-article (e)
2738 (gnus-summary-next-page nil t))
2740 (defun gnus-summary-set-display-table ()
2741 "Change the display table.
2742 Odd characters have a tendency to mess
2743 up nicely formatted displays - we make all possible glyphs
2744 display only a single character."
2746 ;; We start from the standard display table, if any.
2747 (let ((table (or (copy-sequence standard-display-table)
2748 (make-display-table)))
2750 ;; Nix out all the control chars...
2751 (while (>= (setq i (1- i)) 0)
2752 (aset table i [??]))
2753 ;; ... but not newline and cr, of course. (cr is necessary for the
2754 ;; selective display).
2755 (aset table ?\n nil)
2756 (aset table ?\r nil)
2757 ;; We keep TAB as well.
2758 (aset table ?\t nil)
2759 ;; We nix out any glyphs over 126 that are not set already.
2761 (while (>= (setq i (1- i)) 127)
2762 ;; Only modify if the entry is nil.
2763 (unless (aref table i)
2764 (aset table i [??]))))
2765 (setq buffer-display-table table)))
2767 (defun gnus-summary-set-article-display-arrow (pos)
2768 "Update the overlay arrow to point to line at position POS."
2769 (when (and gnus-summary-display-arrow
2770 (boundp 'overlay-arrow-position)
2771 (boundp 'overlay-arrow-string))
2775 (unless overlay-arrow-position
2776 (setq overlay-arrow-position (make-marker)))
2777 (setq overlay-arrow-string "=>"
2778 overlay-arrow-position (set-marker overlay-arrow-position
2780 (current-buffer))))))
2782 (defun gnus-summary-buffer-name (group)
2783 "Return the summary buffer name of GROUP."
2784 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2786 (defun gnus-summary-setup-buffer (group)
2787 "Initialize summary buffer."
2788 (let ((buffer (gnus-summary-buffer-name group)))
2789 (if (get-buffer buffer)
2792 (setq gnus-summary-buffer (current-buffer))
2793 (not gnus-newsgroup-prepared))
2794 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2795 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2796 (gnus-summary-mode group)
2798 (gnus-carpal-setup-buffer 'summary))
2799 (unless gnus-single-article-buffer
2800 (make-local-variable 'gnus-article-buffer)
2801 (make-local-variable 'gnus-article-current)
2802 (make-local-variable 'gnus-original-article-buffer))
2803 (setq gnus-newsgroup-name group)
2804 ;; Set any local variables in the group parameters.
2805 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2808 (defun gnus-set-global-variables ()
2809 "Set the global equivalents of the buffer-local variables.
2810 They are set to the latest values they had. These reflect the summary
2811 buffer that was in action when the last article was fetched."
2812 (when (eq major-mode 'gnus-summary-mode)
2813 (setq gnus-summary-buffer (current-buffer))
2814 (let ((name gnus-newsgroup-name)
2815 (marked gnus-newsgroup-marked)
2816 (unread gnus-newsgroup-unreads)
2817 (headers gnus-current-headers)
2818 (data gnus-newsgroup-data)
2819 (summary gnus-summary-buffer)
2820 (article-buffer gnus-article-buffer)
2821 (original gnus-original-article-buffer)
2822 (gac gnus-article-current)
2823 (reffed gnus-reffed-article-number)
2824 (score-file gnus-current-score-file)
2825 (default-charset gnus-newsgroup-charset)
2827 (let ((locals gnus-newsgroup-variables))
2829 (if (consp (car locals))
2830 (push (eval (caar locals)) vlist)
2831 (push (eval (car locals)) vlist))
2832 (setq locals (cdr locals)))
2833 (setq vlist (nreverse vlist)))
2835 (set-buffer gnus-group-buffer)
2836 (setq gnus-newsgroup-name name
2837 gnus-newsgroup-marked marked
2838 gnus-newsgroup-unreads unread
2839 gnus-current-headers headers
2840 gnus-newsgroup-data data
2841 gnus-article-current gac
2842 gnus-summary-buffer summary
2843 gnus-article-buffer article-buffer
2844 gnus-original-article-buffer original
2845 gnus-reffed-article-number reffed
2846 gnus-current-score-file score-file
2847 gnus-newsgroup-charset default-charset)
2848 (let ((locals gnus-newsgroup-variables))
2850 (if (consp (car locals))
2851 (set (caar locals) (pop vlist))
2852 (set (car locals) (pop vlist)))
2853 (setq locals (cdr locals))))
2854 ;; The article buffer also has local variables.
2855 (when (gnus-buffer-live-p gnus-article-buffer)
2856 (set-buffer gnus-article-buffer)
2857 (setq gnus-summary-buffer summary))))))
2859 (defun gnus-summary-article-unread-p (article)
2860 "Say whether ARTICLE is unread or not."
2861 (memq article gnus-newsgroup-unreads))
2863 (defun gnus-summary-first-article-p (&optional article)
2864 "Return whether ARTICLE is the first article in the buffer."
2865 (if (not (setq article (or article (gnus-summary-article-number))))
2867 (eq article (caar gnus-newsgroup-data))))
2869 (defun gnus-summary-last-article-p (&optional article)
2870 "Return whether ARTICLE is the last article in the buffer."
2871 (if (not (setq article (or article (gnus-summary-article-number))))
2872 ;; All non-existent numbers are the last article. :-)
2874 (not (cdr (gnus-data-find-list article)))))
2876 (defun gnus-make-thread-indent-array ()
2878 (unless (and gnus-thread-indent-array
2879 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2880 (setq gnus-thread-indent-array (make-vector 201 "")
2881 gnus-thread-indent-array-level gnus-thread-indent-level)
2883 (aset gnus-thread-indent-array n
2884 (make-string (* n gnus-thread-indent-level) ? ))
2887 (defun gnus-update-summary-mark-positions ()
2888 "Compute where the summary marks are to go."
2890 (when (gnus-buffer-exists-p gnus-summary-buffer)
2891 (set-buffer gnus-summary-buffer))
2892 (let ((gnus-replied-mark 129)
2893 (gnus-score-below-mark 130)
2894 (gnus-score-over-mark 130)
2895 (gnus-download-mark 131)
2896 (spec gnus-summary-line-format-spec)
2899 (gnus-set-work-buffer)
2900 (let ((gnus-summary-line-format-spec spec)
2901 (gnus-newsgroup-downloadable '((0 . t))))
2902 (gnus-summary-insert-line
2903 (make-full-mail-header 0 "" "nobody"
2904 "05 Apr 2001 23:33:09 +0400"
2906 0 nil 128 t nil "" nil 1)
2907 (goto-char (point-min))
2908 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2910 (goto-char (point-min))
2911 (push (cons 'replied (and (search-forward "\201" nil t)
2914 (goto-char (point-min))
2915 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2917 (goto-char (point-min))
2918 (push (cons 'download
2919 (and (search-forward "\203" nil t) (- (point) 2)))
2921 (setq gnus-summary-mark-positions pos))))
2923 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2924 "Insert a dummy root in the summary buffer."
2926 (gnus-add-text-properties
2927 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2928 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2930 (defun gnus-summary-extract-address-component (from)
2931 (or (car (funcall gnus-extract-address-components from))
2934 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2935 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
2936 default-mime-charset)))
2937 ;; Is it really necessary to do this next part for each summary line?
2938 ;; Luckily, doesn't seem to slow things down much.
2940 (and gnus-ignored-from-addresses
2941 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2942 (let ((extra-headers (mail-header-extra header))
2946 ((setq to (cdr (assq 'To extra-headers)))
2948 (gnus-summary-extract-address-component
2949 (funcall gnus-decode-encoded-word-function to))))
2950 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2951 (concat "=> " newsgroups)))))
2952 (gnus-summary-extract-address-component gnus-tmp-from))))
2954 (defun gnus-summary-insert-line (gnus-tmp-header
2955 gnus-tmp-level gnus-tmp-current
2956 gnus-tmp-unread gnus-tmp-replied
2957 gnus-tmp-expirable gnus-tmp-subject-or-nil
2958 &optional gnus-tmp-dummy gnus-tmp-score
2960 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2961 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2962 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2963 (gnus-tmp-score-char
2964 (if (or (null gnus-summary-default-score)
2965 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2966 gnus-summary-zcore-fuzz))
2968 (if (< gnus-tmp-score gnus-summary-default-score)
2969 gnus-score-below-mark gnus-score-over-mark)))
2970 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2972 (cond (gnus-tmp-process gnus-process-mark)
2973 ((memq gnus-tmp-current gnus-newsgroup-cached)
2975 (gnus-tmp-replied gnus-replied-mark)
2976 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
2977 gnus-forwarded-mark)
2978 ((memq gnus-tmp-current gnus-newsgroup-saved)
2980 ((memq gnus-tmp-number gnus-newsgroup-recent)
2982 ((memq gnus-tmp-number gnus-newsgroup-unseen)
2985 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2988 ((string-match "<[^>]+> *$" gnus-tmp-from)
2989 (let ((beg (match-beginning 0)))
2990 (or (and (string-match "^\".+\"" gnus-tmp-from)
2991 (substring gnus-tmp-from 1 (1- (match-end 0))))
2992 (substring gnus-tmp-from 0 beg))))
2993 ((string-match "(.+)" gnus-tmp-from)
2994 (substring gnus-tmp-from
2995 (1+ (match-beginning 0)) (1- (match-end 0))))
2997 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2998 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2999 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3000 (buffer-read-only nil))
3001 (when (string= gnus-tmp-name "")
3002 (setq gnus-tmp-name gnus-tmp-from))
3003 (unless (numberp gnus-tmp-lines)
3004 (setq gnus-tmp-lines -1))
3005 (if (= gnus-tmp-lines -1)
3006 (setq gnus-tmp-lines "?")
3007 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3008 (gnus-put-text-property-excluding-characters-with-faces
3010 (progn (eval gnus-summary-line-format-spec) (point))
3011 'gnus-number gnus-tmp-number)
3012 (when (gnus-visual-p 'summary-highlight 'highlight)
3014 (gnus-run-hooks 'gnus-summary-update-hook)
3017 (defun gnus-summary-update-line (&optional dont-update)
3018 "Update summary line after change."
3019 (when (and gnus-summary-default-score
3020 (not gnus-summary-inhibit-highlight))
3021 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3022 (article (gnus-summary-article-number))
3023 (score (gnus-summary-article-score article)))
3025 (if (and gnus-summary-mark-below
3026 (< (gnus-summary-article-score)
3027 gnus-summary-mark-below))
3028 ;; This article has a low score, so we mark it as read.
3029 (when (memq article gnus-newsgroup-unreads)
3030 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3031 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3032 ;; This article was previously marked as read on account
3033 ;; of a low score, but now it has risen, so we mark it as
3035 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3036 (gnus-summary-update-mark
3037 (if (or (null gnus-summary-default-score)
3038 (<= (abs (- score gnus-summary-default-score))
3039 gnus-summary-zcore-fuzz))
3041 (if (< score gnus-summary-default-score)
3042 gnus-score-below-mark gnus-score-over-mark))
3044 ;; Do visual highlighting.
3045 (when (gnus-visual-p 'summary-highlight 'highlight)
3046 (gnus-run-hooks 'gnus-summary-update-hook)))))
3048 (defvar gnus-tmp-new-adopts nil)
3050 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3051 "Return the number of articles in THREAD.
3052 This may be 0 in some cases -- if none of the articles in
3053 the thread are to be displayed."
3055 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3057 ((not (listp thread))
3059 ((and (consp thread) (cdr thread))
3062 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3065 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3068 (when (and level (zerop level) gnus-tmp-new-adopts)
3071 'gnus-summary-number-of-articles-in-thread
3072 gnus-tmp-new-adopts))))
3074 (if (> number 1) gnus-not-empty-thread-mark
3075 gnus-empty-thread-mark)
3078 (defun gnus-summary-set-local-parameters (group)
3079 "Go through the local params of GROUP and set all variable specs in that list."
3080 (let ((params (gnus-group-find-parameter group))
3081 (vars '(quit-config)) ; Ignore quit-config.
3084 (setq elem (car params)
3085 params (cdr params))
3086 (and (consp elem) ; Has to be a cons.
3087 (consp (cdr elem)) ; The cdr has to be a list.
3088 (symbolp (car elem)) ; Has to be a symbol in there.
3089 (not (memq (car elem) vars))
3090 (ignore-errors ; So we set it.
3091 (push (car elem) vars)
3092 (make-local-variable (car elem))
3093 (set (car elem) (eval (nth 1 elem))))))))
3095 (defun gnus-summary-read-group (group &optional show-all no-article
3096 kill-buffer no-display backward
3098 "Start reading news in newsgroup GROUP.
3099 If SHOW-ALL is non-nil, already read articles are also listed.
3100 If NO-ARTICLE is non-nil, no article is selected initially.
3101 If NO-DISPLAY, don't generate a summary buffer."
3105 (let ((gnus-auto-select-next nil))
3106 (or (gnus-summary-read-group-1
3107 group show-all no-article
3108 kill-buffer no-display
3111 select-articles nil)))))
3112 (eq gnus-auto-select-next 'quietly))
3113 (set-buffer gnus-group-buffer)
3114 ;; The entry function called above goes to the next
3115 ;; group automatically, so we go two groups back
3116 ;; if we are searching for the previous group.
3118 (gnus-group-prev-unread-group 2))
3119 (if (not (equal group (gnus-group-group-name)))
3120 (setq group (gnus-group-group-name))
3124 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3125 "Directly jump to the other GROUP from summary buffer.
3126 If SHOW-ALL is non-nil, already read articles are also listed."
3128 (if (eq gnus-summary-buffer (current-buffer))
3129 (list (completing-read
3130 "Group: " gnus-active-hashtb nil t
3131 (when (and gnus-newsgroup-name
3132 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3133 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3134 'gnus-group-history)
3136 (error "%s must be invoked from a gnus summary buffer." this-command)))
3137 (unless (or (zerop (length group))
3138 (and gnus-newsgroup-name
3139 (string-equal gnus-newsgroup-name group)))
3141 (gnus-summary-read-group group show-all
3142 gnus-dont-select-after-jump-to-other-group)))
3144 (defun gnus-summary-read-group-1 (group show-all no-article
3145 kill-buffer no-display
3146 &optional select-articles)
3147 ;; Killed foreign groups can't be entered.
3148 ;; (when (and (not (gnus-group-native-p group))
3149 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3150 ;; (error "Dead non-native groups can't be entered"))
3151 (gnus-message 5 "Retrieving newsgroup: %s..."
3152 (gnus-group-decoded-name group))
3153 (let* ((new-group (gnus-summary-setup-buffer group))
3154 (quit-config (gnus-group-quit-config group))
3155 (did-select (and new-group (gnus-select-newsgroup
3156 group show-all select-articles))))
3158 ;; This summary buffer exists already, so we just select it.
3160 (gnus-set-global-variables)
3162 (gnus-kill-or-deaden-summary kill-buffer))
3163 (gnus-configure-windows 'summary 'force)
3164 (gnus-set-mode-line 'summary)
3165 (gnus-summary-position-point)
3168 ;; We couldn't select this group.
3170 (when (and (eq major-mode 'gnus-summary-mode)
3171 (not (equal (current-buffer) kill-buffer)))
3172 (kill-buffer (current-buffer))
3173 (if (not quit-config)
3175 ;; Update the info -- marks might need to be removed,
3177 (gnus-summary-update-info)
3178 (set-buffer gnus-group-buffer)
3179 (gnus-group-jump-to-group group)
3180 (gnus-group-next-unread-group 1))
3181 (gnus-handle-ephemeral-exit quit-config)))
3182 (let ((grpinfo (gnus-get-info group)))
3183 (if (null (gnus-info-read grpinfo))
3184 (gnus-message 3 "Group %s contains no messages"
3185 (gnus-group-decoded-name group))
3186 (gnus-message 3 "Can't select group")))
3188 ;; The user did a `C-g' while prompting for number of articles,
3189 ;; so we exit this group.
3190 ((eq did-select 'quit)
3191 (and (eq major-mode 'gnus-summary-mode)
3192 (not (equal (current-buffer) kill-buffer))
3193 (kill-buffer (current-buffer)))
3195 (gnus-kill-or-deaden-summary kill-buffer))
3196 (if (not quit-config)
3198 (set-buffer gnus-group-buffer)
3199 (gnus-group-jump-to-group group)
3200 (gnus-group-next-unread-group 1)
3201 (gnus-configure-windows 'group 'force))
3202 (gnus-handle-ephemeral-exit quit-config))
3203 ;; Finally signal the quit.
3205 ;; The group was successfully selected.
3207 (gnus-set-global-variables)
3208 ;; Save the active value in effect when the group was entered.
3209 (setq gnus-newsgroup-active
3211 (gnus-active gnus-newsgroup-name)))
3212 ;; You can change the summary buffer in some way with this hook.
3213 (gnus-run-hooks 'gnus-select-group-hook)
3214 (gnus-update-format-specifications
3215 nil 'summary 'summary-mode 'summary-dummy)
3216 (gnus-update-summary-mark-positions)
3217 ;; Do score processing.
3218 (when gnus-use-scoring
3219 (gnus-possibly-score-headers))
3220 ;; Check whether to fill in the gaps in the threads.
3221 (when gnus-build-sparse-threads
3222 (gnus-build-sparse-threads))
3223 ;; Find the initial limit.
3224 (if gnus-show-threads
3226 (let ((gnus-newsgroup-dormant nil))
3227 (gnus-summary-initial-limit show-all))
3228 (gnus-summary-initial-limit show-all))
3229 ;; When untreaded, all articles are always shown.
3230 (setq gnus-newsgroup-limit
3232 (lambda (header) (mail-header-number header))
3233 gnus-newsgroup-headers)))
3234 ;; Generate the summary buffer.
3236 (gnus-summary-prepare))
3237 (when gnus-use-trees
3238 (gnus-tree-open group)
3239 (setq gnus-summary-highlight-line-function
3240 'gnus-tree-highlight-article))
3241 ;; If the summary buffer is empty, but there are some low-scored
3242 ;; articles or some excluded dormants, we include these in the
3244 (when (and (zerop (buffer-size))
3246 (cond (gnus-newsgroup-dormant
3247 (gnus-summary-limit-include-dormant))
3248 ((and gnus-newsgroup-scored show-all)
3249 (gnus-summary-limit-include-expunged t))))
3250 ;; Function `gnus-apply-kill-file' must be called in this hook.
3251 (gnus-run-hooks 'gnus-apply-kill-hook)
3252 (if (and (zerop (buffer-size))
3255 ;; This newsgroup is empty.
3256 (gnus-summary-catchup-and-exit nil t)
3257 (gnus-message 6 "No unread news")
3259 (gnus-kill-or-deaden-summary kill-buffer))
3260 ;; Return nil from this function.
3262 ;; Hide conversation thread subtrees. We cannot do this in
3263 ;; gnus-summary-prepare-hook since kill processing may not
3264 ;; work with hidden articles.
3265 (and gnus-show-threads
3266 gnus-thread-hide-subtree
3267 (gnus-summary-hide-all-threads))
3269 (gnus-kill-or-deaden-summary kill-buffer))
3270 ;; Show first unread article if requested.
3271 (if (and (not no-article)
3273 gnus-newsgroup-unreads
3274 gnus-auto-select-first)
3276 (gnus-configure-windows 'summary)
3278 ((eq gnus-auto-select-first 'best)
3279 (gnus-summary-best-unread-article))
3280 ((eq gnus-auto-select-first t)
3281 (gnus-summary-first-unread-article))
3282 ((gnus-functionp gnus-auto-select-first)
3283 (funcall gnus-auto-select-first))))
3284 ;; Don't select any articles, just move point to the first
3285 ;; article in the group.
3286 (goto-char (point-min))
3287 (gnus-summary-position-point)
3288 (gnus-configure-windows 'summary 'force)
3289 (gnus-set-mode-line 'summary))
3290 (when (get-buffer-window gnus-group-buffer t)
3291 ;; Gotta use windows, because recenter does weird stuff if
3292 ;; the current buffer ain't the displayed window.
3293 (let ((owin (selected-window)))
3294 (select-window (get-buffer-window gnus-group-buffer t))
3295 (when (gnus-group-goto-group group)
3297 (select-window owin)))
3298 ;; Mark this buffer as "prepared".
3299 (setq gnus-newsgroup-prepared t)
3300 (gnus-run-hooks 'gnus-summary-prepared-hook)
3303 (defun gnus-summary-prepare ()
3304 "Generate the summary buffer."
3306 (let ((buffer-read-only nil))
3308 (setq gnus-newsgroup-data nil
3309 gnus-newsgroup-data-reverse nil)
3310 (gnus-run-hooks 'gnus-summary-generate-hook)
3311 ;; Generate the buffer, either with threads or without.
3312 (when gnus-newsgroup-headers
3313 (gnus-summary-prepare-threads
3314 (if gnus-show-threads
3315 (gnus-sort-gathered-threads
3316 (funcall gnus-summary-thread-gathering-function
3318 (gnus-cut-threads (gnus-make-threads)))))
3319 ;; Unthreaded display.
3320 (gnus-sort-articles gnus-newsgroup-headers))))
3321 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3322 ;; Call hooks for modifying summary buffer.
3323 (goto-char (point-min))
3324 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3326 (defsubst gnus-general-simplify-subject (subject)
3327 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3330 ;; Truncate the subject.
3331 (gnus-simplify-subject-functions
3332 (gnus-map-function gnus-simplify-subject-functions subject))
3333 ((numberp gnus-summary-gather-subject-limit)
3334 (setq subject (gnus-simplify-subject-re subject))
3335 (if (> (length subject) gnus-summary-gather-subject-limit)
3336 (substring subject 0 gnus-summary-gather-subject-limit)
3338 ;; Fuzzily simplify it.
3339 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3340 (gnus-simplify-subject-fuzzy subject))
3341 ;; Just remove the leading "Re:".
3343 (gnus-simplify-subject-re subject))))
3345 (if (and gnus-summary-gather-exclude-subject
3346 (string-match gnus-summary-gather-exclude-subject subject))
3347 nil ; This article shouldn't be gathered
3350 (defun gnus-summary-simplify-subject-query ()
3351 "Query where the respool algorithm would put this article."
3353 (gnus-summary-select-article)
3355 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3357 (defun gnus-gather-threads-by-subject (threads)
3358 "Gather threads by looking at Subject headers."
3359 (if (not gnus-summary-make-false-root)
3361 (let ((hashtb (gnus-make-hashtable 1024))
3364 subject hthread whole-subject)
3366 (setq subject (gnus-general-simplify-subject
3367 (setq whole-subject (mail-header-subject
3370 (if (setq hthread (gnus-gethash subject hashtb))
3372 ;; We enter a dummy root into the thread, if we
3373 ;; haven't done that already.
3374 (unless (stringp (caar hthread))
3375 (setcar hthread (list whole-subject (car hthread))))
3376 ;; We add this new gathered thread to this gathered
3378 (setcdr (car hthread)
3379 (nconc (cdar hthread) (list (car threads))))
3380 ;; Remove it from the list of threads.
3381 (setcdr prev (cdr threads))
3382 (setq threads prev))
3383 ;; Enter this thread into the hash table.
3384 (gnus-sethash subject threads hashtb)))
3386 (setq threads (cdr threads)))
3389 (defun gnus-gather-threads-by-references (threads)
3390 "Gather threads by looking at References headers."
3391 (let ((idhashtb (gnus-make-hashtable 1024))
3392 (thhashtb (gnus-make-hashtable 1024))
3395 ids references id gthread gid entered ref)
3397 (when (setq references (mail-header-references (caar threads)))
3398 (setq id (mail-header-id (caar threads))
3399 ids (gnus-split-references references)
3401 (while (setq ref (pop ids))
3402 (setq ids (delete ref ids))
3403 (if (not (setq gid (gnus-gethash ref idhashtb)))
3405 (gnus-sethash ref id idhashtb)
3406 (gnus-sethash id threads thhashtb))
3407 (setq gthread (gnus-gethash gid thhashtb))
3409 ;; We enter a dummy root into the thread, if we
3410 ;; haven't done that already.
3411 (unless (stringp (caar gthread))
3412 (setcar gthread (list (mail-header-subject (caar gthread))
3414 ;; We add this new gathered thread to this gathered
3416 (setcdr (car gthread)
3417 (nconc (cdar gthread) (list (car threads)))))
3418 ;; Add it into the thread hash table.
3419 (gnus-sethash id gthread thhashtb)
3421 ;; Remove it from the list of threads.
3422 (setcdr prev (cdr threads))
3423 (setq threads prev))))
3425 (setq threads (cdr threads)))
3428 (defun gnus-sort-gathered-threads (threads)
3429 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3430 (let ((result threads))
3432 (when (stringp (caar threads))
3433 (setcdr (car threads)
3434 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3435 (setq threads (cdr threads)))
3438 (defun gnus-thread-loop-p (root thread)
3439 "Say whether ROOT is in THREAD."
3440 (let ((stack (list thread))
3443 (while (setq thread (pop stack))
3444 (setq th (cdr thread))
3446 (not (eq (caar th) root)))
3449 ;; We have found a loop.
3451 (setcdr thread (delq (car th) (cdr thread)))
3452 (if (boundp (setq ref-dep (intern "none"
3453 gnus-newsgroup-dependencies)))
3454 (setcdr (symbol-value ref-dep)
3455 (nconc (cdr (symbol-value ref-dep))
3457 (set ref-dep (list nil (car th))))
3460 ;; Push all the subthreads onto the stack.
3461 (push (cdr thread) stack)))
3464 (defun gnus-make-threads ()
3465 "Go through the dependency hashtb and find the roots. Return all threads."
3467 (while (catch 'infloop
3470 ;; Deal with self-referencing References loops.
3471 (when (and (car (symbol-value refs))
3478 (car (symbol-value refs)) thread))
3479 (cdr (symbol-value refs)))))))
3482 (unless (car (symbol-value refs))
3483 ;; These threads do not refer back to any other articles,
3484 ;; so they're roots.
3485 (setq threads (append (cdr (symbol-value refs)) threads))))
3486 gnus-newsgroup-dependencies)))
3489 ;; Build the thread tree.
3490 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3491 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3493 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3494 if it was already present.
3496 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3497 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3498 Message-IDs will be renamed be renamed to a unique Message-ID before
3501 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3502 (let* ((id (mail-header-id header))
3503 (id-dep (and id (intern id dependencies)))
3504 ref ref-dep ref-header)
3505 ;; Enter this `header' in the `dependencies' table.
3509 ;; The first two cases do the normal part: enter a new `header'
3510 ;; in the `dependencies' table.
3511 ((not (boundp id-dep))
3512 (set id-dep (list header)))
3513 ((null (car (symbol-value id-dep)))
3514 (setcar (symbol-value id-dep) header))
3516 ;; From here the `header' was already present in the
3517 ;; `dependencies' table.
3519 ;; Overrides an existing entry;
3520 ;; just set the header part of the entry.
3521 (setcar (symbol-value id-dep) header))
3523 ;; Renames the existing `header' to a unique Message-ID.
3524 ((not gnus-summary-ignore-duplicates)
3525 ;; An article with this Message-ID has already been seen.
3526 ;; We rename the Message-ID.
3527 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3529 (mail-header-set-id header id))
3531 ;; The last case ignores an existing entry, except it adds any
3532 ;; additional Xrefs (in case the two articles came from different
3534 ;; Also sets `header' to `nil' meaning that the `dependencies'
3535 ;; table was *not* modified.
3537 (mail-header-set-xref
3538 (car (symbol-value id-dep))
3539 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3541 (or (mail-header-xref header) "")))
3545 ;; First check if that we are not creating a References loop.
3546 (setq ref (gnus-parent-id (mail-header-references header)))
3548 (setq ref-dep (intern-soft ref dependencies))
3550 (setq ref-header (car (symbol-value ref-dep))))
3551 (if (string= id ref)
3552 ;; Yuk! This is a reference loop. Make the article be a
3555 (mail-header-set-references (car (symbol-value id-dep)) "none")
3557 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3558 (setq ref (gnus-parent-id (mail-header-references header)))
3559 (setq ref-dep (intern (or ref "none") dependencies))
3560 (if (boundp ref-dep)
3561 (setcdr (symbol-value ref-dep)
3562 (nconc (cdr (symbol-value ref-dep))
3563 (list (symbol-value id-dep))))
3564 (set ref-dep (list nil (symbol-value id-dep)))))
3567 (defun gnus-build-sparse-threads ()
3568 (let ((headers gnus-newsgroup-headers)
3569 (mail-parse-charset gnus-newsgroup-charset)
3570 (gnus-summary-ignore-duplicates t)
3571 header references generation relations
3572 subject child end new-child date)
3573 ;; First we create an alist of generations/relations, where
3574 ;; generations is how much we trust the relation, and the relation
3576 (gnus-message 7 "Making sparse threads...")
3578 (nnheader-set-temp-buffer " *gnus sparse threads*")
3579 (while (setq header (pop headers))
3580 (when (and (setq references (mail-header-references header))
3581 (not (string= references "")))
3583 (setq child (mail-header-id header)
3584 subject (mail-header-subject header)
3585 date (mail-header-date header)
3587 (while (search-backward ">" nil t)
3588 (setq end (1+ (point)))
3589 (when (search-backward "<" nil t)
3590 (setq new-child (buffer-substring (point) end))
3591 (push (list (incf generation)
3592 child (setq child new-child)
3596 (push (list (1+ generation) child nil subject) relations))
3598 (kill-buffer (current-buffer)))
3599 ;; Sort over trustworthiness.
3602 (when (gnus-dependencies-add-header
3603 (make-full-mail-header-from-decoded-header
3604 gnus-reffed-article-number
3605 (nth 3 relation) "" (or (nth 4 relation) "")
3607 (or (nth 2 relation) "") 0 0 "")
3608 gnus-newsgroup-dependencies nil)
3609 (push gnus-reffed-article-number gnus-newsgroup-limit)
3610 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3611 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3612 gnus-newsgroup-reads)
3613 (decf gnus-reffed-article-number)))
3614 (sort relations 'car-less-than-car))
3615 (gnus-message 7 "Making sparse threads...done")))
3617 (defun gnus-build-old-threads ()
3618 ;; Look at all the articles that refer back to old articles, and
3619 ;; fetch the headers for the articles that aren't there. This will
3620 ;; build complete threads - if the roots haven't been expired by the
3622 (let ((mail-parse-charset gnus-newsgroup-charset)
3626 (when (not (car (symbol-value refs)))
3627 (setq heads (cdr (symbol-value refs)))
3629 (if (memq (mail-header-number (caar heads))
3630 gnus-newsgroup-dormant)
3631 (setq heads (cdr heads))
3632 (setq id (symbol-name refs))
3633 (while (and (setq id (gnus-build-get-header id))
3634 (not (car (gnus-id-to-thread id)))))
3635 (setq heads nil)))))
3636 gnus-newsgroup-dependencies)))
3638 ;; This function has to be called with point after the article number
3639 ;; on the beginning of the line.
3640 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3641 (let ((eol (gnus-point-at-eol))
3642 (buffer (current-buffer))
3645 ;; overview: [num subject from date id refs chars lines misc]
3648 (narrow-to-region (point) eol)
3653 (make-full-mail-header
3655 (nnheader-nov-field) ; subject
3656 (nnheader-nov-field) ; from
3657 (nnheader-nov-field) ; date
3658 (nnheader-nov-read-message-id) ; id
3659 (nnheader-nov-field) ; refs
3660 (nnheader-nov-read-integer) ; chars
3661 (nnheader-nov-read-integer) ; lines
3663 (if (looking-at "Xref: ")
3664 (goto-char (match-end 0)))
3665 (nnheader-nov-field)) ; Xref
3666 (nnheader-nov-parse-extra)))) ; extra
3670 (when gnus-alter-header-function
3671 (funcall gnus-alter-header-function header))
3672 (gnus-dependencies-add-header header dependencies force-new)))
3674 (defun gnus-build-get-header (id)
3675 "Look through the buffer of NOV lines and find the header to ID.
3676 Enter this line into the dependencies hash table, and return
3677 the id of the parent article (if any)."
3678 (let ((deps gnus-newsgroup-dependencies)
3682 (set-buffer nntp-server-buffer)
3683 (let ((case-fold-search nil))
3684 (goto-char (point-min))
3685 (while (and (not found)
3686 (search-forward id nil t))
3688 (setq found (looking-at
3689 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3690 (regexp-quote id))))
3691 (or found (beginning-of-line 2)))
3695 (setq header (gnus-nov-parse-line
3696 (read (current-buffer)) deps))
3697 (gnus-parent-id (mail-header-references header))))))
3699 (let ((number (mail-header-number header)))
3700 (push number gnus-newsgroup-limit)
3701 (push header gnus-newsgroup-headers)
3702 (if (memq number gnus-newsgroup-unselected)
3704 (push number gnus-newsgroup-unreads)
3705 (setq gnus-newsgroup-unselected
3706 (delq number gnus-newsgroup-unselected)))
3707 (push number gnus-newsgroup-ancient)))))))
3709 (defun gnus-build-all-threads ()
3710 "Read all the headers."
3711 (let ((gnus-summary-ignore-duplicates t)
3712 (mail-parse-charset gnus-newsgroup-charset)
3713 (dependencies gnus-newsgroup-dependencies)
3716 (set-buffer nntp-server-buffer)
3717 (let ((case-fold-search nil))
3718 (goto-char (point-min))
3721 (setq article (read (current-buffer))
3722 header (gnus-nov-parse-line article dependencies)))
3725 (set-buffer gnus-summary-buffer)
3726 (push header gnus-newsgroup-headers)
3727 (if (memq (setq article (mail-header-number header))
3728 gnus-newsgroup-unselected)
3730 (push article gnus-newsgroup-unreads)
3731 (setq gnus-newsgroup-unselected
3732 (delq article gnus-newsgroup-unselected)))
3733 (push article gnus-newsgroup-ancient)))
3734 (forward-line 1)))))))
3736 (defun gnus-summary-update-article-line (article header)
3737 "Update the line for ARTICLE using HEADERS."
3738 (let* ((id (mail-header-id header))
3739 (thread (gnus-id-to-thread id)))
3741 (error "Article in no thread"))
3742 ;; Update the thread.
3743 (setcar thread header)
3744 (gnus-summary-goto-subject article)
3745 (let* ((datal (gnus-data-find-list article))
3747 (length (when (cdr datal)
3748 (- (gnus-data-pos data)
3749 (gnus-data-pos (cadr datal)))))
3750 (buffer-read-only nil)
3751 (level (gnus-summary-thread-level)))
3753 (gnus-summary-insert-line
3754 header level nil (gnus-article-mark article)
3755 (memq article gnus-newsgroup-replied)
3756 (memq article gnus-newsgroup-expirable)
3757 ;; Only insert the Subject string when it's different
3758 ;; from the previous Subject string.
3763 (mail-header-subject
3766 (gnus-data-find-list
3768 (gnus-data-list t)))))
3769 ;; Error on the side of excessive subjects.
3771 (mail-header-subject header)))
3773 (mail-header-subject header))
3774 nil (cdr (assq article gnus-newsgroup-scored))
3775 (memq article gnus-newsgroup-processable))
3777 (gnus-data-update-list
3778 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3780 (defun gnus-summary-update-article (article &optional iheader)
3781 "Update ARTICLE in the summary buffer."
3782 (set-buffer gnus-summary-buffer)
3783 (let* ((header (gnus-summary-article-header article))
3784 (id (mail-header-id header))
3785 (data (gnus-data-find article))
3786 (thread (gnus-id-to-thread id))
3787 (references (mail-header-references header))
3791 (when (and references
3792 (not (equal "" references)))
3795 (buffer-read-only nil)
3801 (delq thread parent)))
3802 (if (gnus-summary-insert-subject id header)
3803 ;; Set the (possibly) new article number in the data structure.
3804 (gnus-data-set-number data (gnus-id-to-article id))
3808 (defun gnus-rebuild-thread (id &optional line)
3809 "Rebuild the thread containing ID.
3810 If LINE, insert the rebuilt thread starting on line LINE."
3811 (let ((buffer-read-only nil)
3812 old-pos current thread data)
3813 (if (not gnus-show-threads)
3814 (setq thread (list (car (gnus-id-to-thread id))))
3815 ;; Get the thread this article is part of.
3816 (setq thread (gnus-remove-thread id)))
3817 (setq old-pos (gnus-point-at-bol))
3818 (setq current (save-excursion
3819 (and (re-search-backward "[\r\n]" nil t)
3820 (gnus-summary-article-number))))
3821 ;; If this is a gathered thread, we have to go some re-gathering.
3822 (when (stringp (car thread))
3823 (let ((subject (car thread))
3825 (setq thread (cdr thread))
3827 (unless (memq (setq thr (gnus-id-to-thread
3829 (mail-header-id (caar thread)))))
3832 (setq thread (cdr thread)))
3833 ;; We now have all (unique) roots.
3834 (if (= (length roots) 1)
3835 ;; All the loose roots are now one solid root.
3836 (setq thread (car roots))
3837 (setq thread (cons subject (gnus-sort-threads roots))))))
3839 ;; We then insert this thread into the summary buffer.
3841 (goto-char (point-min))
3842 (forward-line (1- line)))
3843 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3844 (if gnus-show-threads
3845 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3846 (gnus-summary-prepare-unthreaded thread))
3847 (setq data (nreverse gnus-newsgroup-data))
3848 (setq threads gnus-newsgroup-threads))
3849 ;; We splice the new data into the data structure.
3850 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3851 ;;!!! then we want to insert at the beginning of the buffer.
3852 ;;!!! That happens to be true with Gnus now, but that may
3853 ;;!!! change in the future. Perhaps.
3854 (gnus-data-enter-list
3855 (if line nil current) data (- (point) old-pos))
3856 (setq gnus-newsgroup-threads
3857 (nconc threads gnus-newsgroup-threads))
3858 (gnus-data-compute-positions))))
3860 (defun gnus-number-to-header (number)
3861 "Return the header for article NUMBER."
3862 (let ((headers gnus-newsgroup-headers))
3864 (not (= number (mail-header-number (car headers)))))
3869 (defun gnus-parent-headers (in-headers &optional generation)
3870 "Return the headers of the GENERATIONeth parent of HEADERS."
3872 (setq generation 1))
3874 (headers in-headers)
3877 (not (zerop generation))
3878 (setq references (mail-header-references headers)))
3879 (setq headers (if (and references
3880 (setq parent (gnus-parent-id references)))
3881 (car (gnus-id-to-thread parent))
3884 (and (not (eq headers in-headers))
3887 (defun gnus-id-to-thread (id)
3888 "Return the (sub-)thread where ID appears."
3889 (gnus-gethash id gnus-newsgroup-dependencies))
3891 (defun gnus-id-to-article (id)
3892 "Return the article number of ID."
3893 (let ((thread (gnus-id-to-thread id)))
3896 (mail-header-number (car thread)))))
3898 (defun gnus-id-to-header (id)
3899 "Return the article headers of ID."
3900 (car (gnus-id-to-thread id)))
3902 (defun gnus-article-displayed-root-p (article)
3903 "Say whether ARTICLE is a root(ish) article."
3904 (let ((level (gnus-summary-thread-level article))
3905 (refs (mail-header-references (gnus-summary-article-header article)))
3911 ((null (gnus-parent-id refs)) t)
3913 (null (setq particle (gnus-id-to-article
3914 (gnus-parent-id refs))))
3915 (null (gnus-summary-thread-level particle)))))))
3917 (defun gnus-root-id (id)
3918 "Return the id of the root of the thread where ID appears."
3920 (while (and id (setq prev (car (gnus-id-to-thread id))))
3922 id (gnus-parent-id (mail-header-references prev))))
3925 (defun gnus-articles-in-thread (thread)
3926 "Return the list of articles in THREAD."
3927 (cons (mail-header-number (car thread))
3928 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3930 (defun gnus-remove-thread (id &optional dont-remove)
3931 "Remove the thread that has ID in it."
3932 (let (headers thread last-id)
3933 ;; First go up in this thread until we find the root.
3934 (setq last-id (gnus-root-id id)
3935 headers (message-flatten-list (gnus-id-to-thread last-id)))
3936 ;; We have now found the real root of this thread. It might have
3937 ;; been gathered into some loose thread, so we have to search
3938 ;; through the threads to find the thread we wanted.
3939 (let ((threads gnus-newsgroup-threads)
3942 (setq sub (car threads))
3943 (if (stringp (car sub))
3944 ;; This is a gathered thread, so we look at the roots
3945 ;; below it to find whether this article is in this
3948 (setq sub (cdr sub))
3950 (when (member (caar sub) headers)
3951 (setq thread (car threads)
3954 (setq sub (cdr sub))))
3955 ;; It's an ordinary thread, so we check it.
3956 (when (eq (car sub) (car headers))
3959 (setq threads (cdr threads)))
3960 ;; If this article is in no thread, then it's a root.
3963 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3964 (setq thread (gnus-id-to-thread last-id)))
3967 thread ; We return this thread.
3969 (if (stringp (car thread))
3971 ;; If we use dummy roots, then we have to remove the
3972 ;; dummy root as well.
3973 (when (eq gnus-summary-make-false-root 'dummy)
3974 ;; We go to the dummy root by going to
3975 ;; the first sub-"thread", and then one line up.
3976 (gnus-summary-goto-article
3977 (mail-header-number (caadr thread)))
3980 (gnus-data-compute-positions))
3981 (setq thread (cdr thread))
3983 (gnus-remove-thread-1 (car thread))
3984 (setq thread (cdr thread))))
3985 (gnus-remove-thread-1 thread))))))))
3987 (defun gnus-remove-thread-1 (thread)
3988 "Remove the thread THREAD recursively."
3989 (let ((number (mail-header-number (pop thread)))
3991 (setq thread (reverse thread))
3993 (gnus-remove-thread-1 (pop thread)))
3994 (when (setq d (gnus-data-find number))
3995 (goto-char (gnus-data-pos d))
3996 (gnus-summary-show-thread)
3999 (- (gnus-point-at-bol)
4001 (1+ (gnus-point-at-eol))
4002 (gnus-delete-line)))))))
4004 (defun gnus-sort-threads-1 (threads func)
4005 (sort (mapcar (lambda (thread)
4008 (gnus-sort-threads-1 (cdr thread) func))))
4011 (defun gnus-sort-threads (threads)
4013 (if (not gnus-thread-sort-functions)
4015 (gnus-message 8 "Sorting threads...")
4017 (gnus-sort-threads-1
4019 (gnus-make-sort-function gnus-thread-sort-functions))
4020 (gnus-message 8 "Sorting threads...done"))))
4022 (defun gnus-sort-articles (articles)
4024 (when gnus-article-sort-functions
4025 (gnus-message 7 "Sorting articles...")
4027 (setq gnus-newsgroup-headers
4028 (sort articles (gnus-make-sort-function
4029 gnus-article-sort-functions)))
4030 (gnus-message 7 "Sorting articles...done"))))
4032 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4033 (defmacro gnus-thread-header (thread)
4034 "Return header of first article in THREAD.
4035 Note that THREAD must never, ever be anything else than a variable -
4036 using some other form will lead to serious barfage."
4037 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4038 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4039 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4042 (defsubst gnus-article-sort-by-number (h1 h2)
4043 "Sort articles by article number."
4044 (< (mail-header-number h1)
4045 (mail-header-number h2)))
4047 (defun gnus-thread-sort-by-number (h1 h2)
4048 "Sort threads by root article number."
4049 (gnus-article-sort-by-number
4050 (gnus-thread-header h1) (gnus-thread-header h2)))
4052 (defsubst gnus-article-sort-by-lines (h1 h2)
4053 "Sort articles by article Lines header."
4054 (< (mail-header-lines h1)
4055 (mail-header-lines h2)))
4057 (defun gnus-thread-sort-by-lines (h1 h2)
4058 "Sort threads by root article Lines header."
4059 (gnus-article-sort-by-lines
4060 (gnus-thread-header h1) (gnus-thread-header h2)))
4062 (defsubst gnus-article-sort-by-chars (h1 h2)
4063 "Sort articles by octet length."
4064 (< (mail-header-chars h1)
4065 (mail-header-chars h2)))
4067 (defun gnus-thread-sort-by-chars (h1 h2)
4068 "Sort threads by root article octet length."
4069 (gnus-article-sort-by-chars
4070 (gnus-thread-header h1) (gnus-thread-header h2)))
4072 (defsubst gnus-article-sort-by-author (h1 h2)
4073 "Sort articles by root author."
4075 (let ((addr (car (mime-entity-read-field h1 'From))))
4076 (or (std11-full-name-string addr)
4077 (std11-address-string addr)
4079 (let ((addr (car (mime-entity-read-field h2 'From))))
4080 (or (std11-full-name-string addr)
4081 (std11-address-string addr)
4085 (defun gnus-thread-sort-by-author (h1 h2)
4086 "Sort threads by root author."
4087 (gnus-article-sort-by-author
4088 (gnus-thread-header h1) (gnus-thread-header h2)))
4090 (defsubst gnus-article-sort-by-subject (h1 h2)
4091 "Sort articles by root subject."
4093 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4094 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4096 (defun gnus-thread-sort-by-subject (h1 h2)
4097 "Sort threads by root subject."
4098 (gnus-article-sort-by-subject
4099 (gnus-thread-header h1) (gnus-thread-header h2)))
4101 (defsubst gnus-article-sort-by-date (h1 h2)
4102 "Sort articles by root article date."
4104 (gnus-date-get-time (mail-header-date h1))
4105 (gnus-date-get-time (mail-header-date h2))))
4107 (defun gnus-thread-sort-by-date (h1 h2)
4108 "Sort threads by root article date."
4109 (gnus-article-sort-by-date
4110 (gnus-thread-header h1) (gnus-thread-header h2)))
4112 (defsubst gnus-article-sort-by-score (h1 h2)
4113 "Sort articles by root article score.
4114 Unscored articles will be counted as having a score of zero."
4115 (> (or (cdr (assq (mail-header-number h1)
4116 gnus-newsgroup-scored))
4117 gnus-summary-default-score 0)
4118 (or (cdr (assq (mail-header-number h2)
4119 gnus-newsgroup-scored))
4120 gnus-summary-default-score 0)))
4122 (defun gnus-thread-sort-by-score (h1 h2)
4123 "Sort threads by root article score."
4124 (gnus-article-sort-by-score
4125 (gnus-thread-header h1) (gnus-thread-header h2)))
4127 (defun gnus-thread-sort-by-total-score (h1 h2)
4128 "Sort threads by the sum of all scores in the thread.
4129 Unscored articles will be counted as having a score of zero."
4130 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4132 (defun gnus-thread-total-score (thread)
4133 ;; This function find the total score of THREAD.
4134 (cond ((null thread)
4137 (if (stringp (car thread))
4138 (apply gnus-thread-score-function 0
4139 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4140 (gnus-thread-total-score-1 thread)))
4142 (gnus-thread-total-score-1 (list thread)))))
4144 (defun gnus-thread-total-score-1 (root)
4145 ;; This function find the total score of the thread below ROOT.
4146 (setq root (car root))
4147 (apply gnus-thread-score-function
4149 (mapcar 'gnus-thread-total-score
4150 (cdr (gnus-id-to-thread (mail-header-id root))))
4151 (when (> (mail-header-number root) 0)
4152 (list (or (cdr (assq (mail-header-number root)
4153 gnus-newsgroup-scored))
4154 gnus-summary-default-score 0))))
4155 (list gnus-summary-default-score)
4158 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4159 (defvar gnus-tmp-prev-subject nil)
4160 (defvar gnus-tmp-false-parent nil)
4161 (defvar gnus-tmp-root-expunged nil)
4162 (defvar gnus-tmp-dummy-line nil)
4164 (eval-when-compile (defvar gnus-tmp-header))
4165 (defun gnus-extra-header (type &optional header)
4166 "Return the extra header of TYPE."
4167 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4170 (defvar gnus-tmp-thread-tree-header-string "")
4172 (defvar gnus-sum-thread-tree-root "> "
4173 "With %B spec, used for the root of a thread.
4174 If nil, use subject instead.")
4175 (defvar gnus-sum-thread-tree-single-indent ""
4176 "With %B spec, used for a thread with just one message.
4177 If nil, use subject instead.")
4178 (defvar gnus-sum-thread-tree-vertical "| "
4179 "With %B spec, used for drawing a vertical line.")
4180 (defvar gnus-sum-thread-tree-indent " "
4181 "With %B spec, used for indenting.")
4182 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4183 "With %B spec, used for a leaf with brothers.")
4184 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4185 "With %B spec, used for a leaf without brothers.")
4187 (defun gnus-summary-prepare-threads (threads)
4188 "Prepare summary buffer from THREADS and indentation LEVEL.
4189 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4190 or a straight list of headers."
4191 (gnus-message 7 "Generating summary...")
4193 (setq gnus-newsgroup-threads threads)
4196 (let ((gnus-tmp-level 0)
4197 (default-score (or gnus-summary-default-score 0))
4198 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4199 thread number subject stack state gnus-tmp-gathered beg-match
4200 new-roots gnus-tmp-new-adopts thread-end
4201 gnus-tmp-header gnus-tmp-unread
4202 gnus-tmp-replied gnus-tmp-subject-or-nil
4203 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4204 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4205 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4208 (setq gnus-tmp-prev-subject nil)
4210 (if (vectorp (car threads))
4211 ;; If this is a straight (sic) list of headers, then a
4212 ;; threaded summary display isn't required, so we just create
4213 ;; an unthreaded one.
4214 (gnus-summary-prepare-unthreaded threads)
4216 ;; Do the threaded display.
4218 (while (or threads stack gnus-tmp-new-adopts new-roots)
4220 (if (and (= gnus-tmp-level 0)
4223 (not gnus-tmp-false-parent)
4224 (or gnus-tmp-new-adopts new-roots))
4225 (if gnus-tmp-new-adopts
4226 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4227 thread (list (car gnus-tmp-new-adopts))
4228 gnus-tmp-header (caar thread)
4229 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4231 (setq thread (list (car new-roots))
4232 gnus-tmp-header (caar thread)
4233 new-roots (cdr new-roots))))
4236 ;; If there are some threads, we do them before the
4237 ;; threads on the stack.
4238 (setq thread threads
4239 gnus-tmp-header (caar thread))
4240 ;; There were no current threads, so we pop something off
4242 (setq state (car stack)
4243 gnus-tmp-level (car state)
4244 tree-stack (cadr state)
4245 thread (caddr state)
4247 gnus-tmp-header (caar thread))))
4249 (setq gnus-tmp-false-parent nil)
4250 (setq gnus-tmp-root-expunged nil)
4251 (setq thread-end nil)
4253 (if (stringp gnus-tmp-header)
4254 ;; The header is a dummy root.
4256 ((eq gnus-summary-make-false-root 'adopt)
4257 ;; We let the first article adopt the rest.
4258 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4260 (setq gnus-tmp-gathered
4262 (lambda (h) (mail-header-number (car h)))
4265 (setq thread (cons (list (caar thread)
4268 (setq gnus-tmp-level -1
4269 gnus-tmp-false-parent t))
4270 ((eq gnus-summary-make-false-root 'empty)
4271 ;; We print adopted articles with empty subject fields.
4272 (setq gnus-tmp-gathered
4274 (lambda (h) (mail-header-number (car h)))
4277 (setq gnus-tmp-level -1))
4278 ((eq gnus-summary-make-false-root 'dummy)
4279 ;; We remember that we probably want to output a dummy
4281 (setq gnus-tmp-dummy-line gnus-tmp-header)
4282 (setq gnus-tmp-prev-subject gnus-tmp-header))
4284 ;; We do not make a root for the gathered
4285 ;; sub-threads at all.
4286 (setq gnus-tmp-level -1)))
4288 (setq number (mail-header-number gnus-tmp-header)
4289 subject (mail-header-subject gnus-tmp-header))
4292 ;; If the thread has changed subject, we might want to make
4293 ;; this subthread into a root.
4294 ((and (null gnus-thread-ignore-subject)
4295 (not (zerop gnus-tmp-level))
4296 gnus-tmp-prev-subject
4298 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4299 (setq new-roots (nconc new-roots (list (car thread)))
4301 gnus-tmp-header nil))
4302 ;; If the article lies outside the current limit,
4303 ;; then we do not display it.
4304 ((not (memq number gnus-newsgroup-limit))
4305 (setq gnus-tmp-gathered
4307 (lambda (h) (mail-header-number (car h)))
4310 (setq gnus-tmp-new-adopts (if (cdar thread)
4311 (append gnus-tmp-new-adopts
4313 gnus-tmp-new-adopts)
4315 gnus-tmp-header nil)
4316 (when (zerop gnus-tmp-level)
4317 (setq gnus-tmp-root-expunged t)))
4318 ;; Perhaps this article is to be marked as read?
4319 ((and gnus-summary-mark-below
4320 (< (or (cdr (assq number gnus-newsgroup-scored))
4322 gnus-summary-mark-below)
4323 ;; Don't touch sparse articles.
4324 (not (gnus-summary-article-sparse-p number))
4325 (not (gnus-summary-article-ancient-p number)))
4326 (setq gnus-newsgroup-unreads
4327 (delq number gnus-newsgroup-unreads))
4328 (if gnus-newsgroup-auto-expire
4329 (push number gnus-newsgroup-expirable)
4330 (push (cons number gnus-low-score-mark)
4331 gnus-newsgroup-reads))))
4333 (when gnus-tmp-header
4334 ;; We may have an old dummy line to output before this
4336 (when (and gnus-tmp-dummy-line
4339 (mail-header-subject gnus-tmp-header)))
4340 (gnus-summary-insert-dummy-line
4341 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4342 (setq gnus-tmp-dummy-line nil))
4344 ;; Compute the mark.
4345 (setq gnus-tmp-unread (gnus-article-mark number))
4347 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4348 gnus-tmp-header gnus-tmp-level)
4349 gnus-newsgroup-data)
4351 ;; Actually insert the line.
4353 gnus-tmp-subject-or-nil
4355 ((and gnus-thread-ignore-subject
4356 gnus-tmp-prev-subject
4357 (not (inline (gnus-subject-equal
4358 gnus-tmp-prev-subject subject))))
4360 ((zerop gnus-tmp-level)
4361 (if (and (eq gnus-summary-make-false-root 'empty)
4362 (memq number gnus-tmp-gathered)
4363 gnus-tmp-prev-subject
4364 (inline (gnus-subject-equal
4365 gnus-tmp-prev-subject subject)))
4366 gnus-summary-same-subject
4368 (t gnus-summary-same-subject)))
4369 (if (and (eq gnus-summary-make-false-root 'adopt)
4370 (= gnus-tmp-level 1)
4371 (memq number gnus-tmp-gathered))
4372 (setq gnus-tmp-opening-bracket ?\<
4373 gnus-tmp-closing-bracket ?\>)
4374 (setq gnus-tmp-opening-bracket ?\[
4375 gnus-tmp-closing-bracket ?\]))
4377 gnus-tmp-indentation
4378 (aref gnus-thread-indent-array gnus-tmp-level)
4379 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4380 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4381 gnus-summary-default-score 0)
4383 (if (or (null gnus-summary-default-score)
4384 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4385 gnus-summary-zcore-fuzz))
4387 (if (< gnus-tmp-score gnus-summary-default-score)
4388 gnus-score-below-mark gnus-score-over-mark))
4390 (cond ((memq number gnus-newsgroup-processable)
4392 ((memq number gnus-newsgroup-cached)
4394 ((memq number gnus-newsgroup-replied)
4396 ((memq number gnus-newsgroup-forwarded)
4397 gnus-forwarded-mark)
4398 ((memq number gnus-newsgroup-saved)
4400 ((memq number gnus-newsgroup-recent)
4402 ((memq number gnus-newsgroup-unseen)
4405 gnus-tmp-from (mail-header-from gnus-tmp-header)
4408 ((string-match "<[^>]+> *$" gnus-tmp-from)
4409 (setq beg-match (match-beginning 0))
4410 (or (and (string-match "^\".+\"" gnus-tmp-from)
4411 (substring gnus-tmp-from 1 (1- (match-end 0))))
4412 (substring gnus-tmp-from 0 beg-match)))
4413 ((string-match "(.+)" gnus-tmp-from)
4414 (substring gnus-tmp-from
4415 (1+ (match-beginning 0)) (1- (match-end 0))))
4417 gnus-tmp-thread-tree-header-string
4419 ((not gnus-show-threads) "")
4420 ((zerop gnus-tmp-level)
4422 (or gnus-sum-thread-tree-root subject)
4423 (or gnus-sum-thread-tree-single-indent subject)))
4425 (concat (apply 'concat
4426 (mapcar (lambda (item)
4428 gnus-sum-thread-tree-vertical
4429 gnus-sum-thread-tree-indent))
4430 (cdr (reverse tree-stack))))
4432 gnus-sum-thread-tree-leaf-with-other
4433 gnus-sum-thread-tree-single-leaf)))))
4434 (when (string= gnus-tmp-name "")
4435 (setq gnus-tmp-name gnus-tmp-from))
4436 (unless (numberp gnus-tmp-lines)
4437 (setq gnus-tmp-lines -1))
4438 (if (= gnus-tmp-lines -1)
4439 (setq gnus-tmp-lines "?")
4440 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4441 (gnus-put-text-property
4443 (progn (eval gnus-summary-line-format-spec) (point))
4444 'gnus-number number)
4447 (gnus-run-hooks 'gnus-summary-update-hook)
4450 (setq gnus-tmp-prev-subject subject)))
4452 (when (nth 1 thread)
4453 (push (list (max 0 gnus-tmp-level)
4454 (copy-list tree-stack)
4457 (push (if (nth 1 thread) 1 0) tree-stack)
4458 (incf gnus-tmp-level)
4459 (setq threads (if thread-end nil (cdar thread)))
4461 (setq gnus-tmp-level 0)))))
4462 (gnus-message 7 "Generating summary...done"))
4464 (defun gnus-summary-prepare-unthreaded (headers)
4465 "Generate an unthreaded summary buffer based on HEADERS."
4466 (let (header number mark)
4471 ;; We may have to root out some bad articles...
4472 (when (memq (setq number (mail-header-number
4473 (setq header (pop headers))))
4474 gnus-newsgroup-limit)
4475 ;; Mark article as read when it has a low score.
4476 (when (and gnus-summary-mark-below
4477 (< (or (cdr (assq number gnus-newsgroup-scored))
4478 gnus-summary-default-score 0)
4479 gnus-summary-mark-below)
4480 (not (gnus-summary-article-ancient-p number)))
4481 (setq gnus-newsgroup-unreads
4482 (delq number gnus-newsgroup-unreads))
4483 (if gnus-newsgroup-auto-expire
4484 (push number gnus-newsgroup-expirable)
4485 (push (cons number gnus-low-score-mark)
4486 gnus-newsgroup-reads)))
4488 (setq mark (gnus-article-mark number))
4489 (push (gnus-data-make number mark (1+ (point)) header 0)
4490 gnus-newsgroup-data)
4491 (gnus-summary-insert-line
4493 mark (memq number gnus-newsgroup-replied)
4494 (memq number gnus-newsgroup-expirable)
4495 (mail-header-subject header) nil
4496 (cdr (assq number gnus-newsgroup-scored))
4497 (memq number gnus-newsgroup-processable))))))
4499 (defun gnus-summary-remove-list-identifiers ()
4500 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4501 (let ((regexp (if (consp gnus-list-identifiers)
4502 (mapconcat 'identity gnus-list-identifiers " *\\|")
4503 gnus-list-identifiers))
4506 (dolist (header gnus-newsgroup-headers)
4507 (setq subject (mail-header-subject header)
4509 (while (string-match
4510 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4513 (concat (substring subject 0 (match-beginning 2))
4514 (substring subject (match-end 0)))
4518 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4520 (concat (substring subject 0 (match-beginning 1))
4521 (substring subject (match-end 1)))))
4523 (mail-header-set-subject header subject))))))
4525 (defun gnus-fetch-headers (articles)
4526 "Fetch headers of ARTICLES."
4527 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4528 (gnus-message 5 "Fetching headers for %s..." name)
4531 (setq gnus-headers-retrieved-by
4532 (gnus-retrieve-headers
4533 articles gnus-newsgroup-name
4534 ;; We might want to fetch old headers, but
4535 ;; not if there is only 1 article.
4537 (not (eq gnus-fetch-old-headers 'some))
4538 (not (numberp gnus-fetch-old-headers)))
4539 (> (length articles) 1))
4540 gnus-fetch-old-headers))))
4541 (gnus-get-newsgroup-headers-xover
4542 articles nil nil gnus-newsgroup-name t)
4543 (gnus-get-newsgroup-headers))
4544 (gnus-message 5 "Fetching headers for %s...done" name))))
4546 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4547 "Select newsgroup GROUP.
4548 If READ-ALL is non-nil, all articles in the group are selected.
4549 If SELECT-ARTICLES, only select those articles from GROUP."
4550 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4551 ;;!!! Dirty hack; should be removed.
4552 (gnus-summary-ignore-duplicates
4553 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4555 gnus-summary-ignore-duplicates))
4556 (info (nth 2 entry))
4557 articles fetched-articles cached)
4559 (unless (gnus-check-server
4560 (set (make-local-variable 'gnus-current-select-method)
4561 (gnus-find-method-for-group group)))
4562 (error "Couldn't open server"))
4564 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4565 (gnus-activate-group group) ; Or we can activate it...
4566 (progn ; Or we bug out.
4567 (when (equal major-mode 'gnus-summary-mode)
4568 (kill-buffer (current-buffer)))
4569 (error "Couldn't activate group %s: %s"
4570 group (gnus-status-message group))))
4572 (unless (gnus-request-group group t)
4573 (when (equal major-mode 'gnus-summary-mode)
4574 (kill-buffer (current-buffer)))
4575 (error "Couldn't request group %s: %s"
4576 group (gnus-status-message group)))
4578 (setq gnus-newsgroup-name group
4579 gnus-newsgroup-unselected nil
4580 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4582 (let ((display (gnus-group-find-parameter group 'display)))
4583 (setq gnus-newsgroup-display
4585 ((not (zerop (or (car-safe read-all) 0)))
4586 ;; The user entered the group with C-u SPC/RET, let's show
4592 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4594 ;; The following is probably the "correct" solution, but
4595 ;; it makes Gnus fetch all headers and then limit the
4596 ;; articles (which is slow), so instead we hack the
4597 ;; select-articles parameter instead. -- Simon Josefsson
4600 ;; (gnus-byte-compile
4601 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4603 (setq select-articles
4604 (gnus-uncompress-range
4605 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4609 (cdr (gnus-active group)))))
4614 (gnus-summary-setup-default-charset)
4616 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4617 (when (gnus-virtual-group-p group)
4618 (setq cached gnus-newsgroup-cached))
4620 (setq gnus-newsgroup-unreads
4621 (gnus-set-difference
4622 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4623 gnus-newsgroup-dormant))
4625 (setq gnus-newsgroup-processable nil)
4627 (gnus-update-read-articles group gnus-newsgroup-unreads)
4629 ;; Adjust and set lists of article marks.
4631 (gnus-adjust-marked-articles info))
4633 (if (setq articles select-articles)
4634 (setq gnus-newsgroup-unselected
4635 (gnus-sorted-intersection
4636 gnus-newsgroup-unreads
4637 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4638 (setq articles (gnus-articles-to-read group read-all)))
4642 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4644 ((eq articles 0) nil)
4646 ;; Init the dependencies hash table.
4647 (setq gnus-newsgroup-dependencies
4648 (gnus-make-hashtable (length articles)))
4649 (gnus-set-global-variables)
4650 ;; Retrieve the headers and read them in.
4651 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4653 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4655 (setq gnus-newsgroup-cached cached))
4657 ;; Suppress duplicates?
4658 (when gnus-suppress-duplicates
4659 (gnus-dup-suppress-articles))
4661 ;; Set the initial limit.
4662 (setq gnus-newsgroup-limit (copy-sequence articles))
4663 ;; Remove canceled articles from the list of unread articles.
4664 (setq fetched-articles
4665 (mapcar (lambda (headers) (mail-header-number headers))
4666 gnus-newsgroup-headers))
4667 (setq gnus-newsgroup-articles fetched-articles)
4668 (setq gnus-newsgroup-unreads
4669 (gnus-set-sorted-intersection
4670 gnus-newsgroup-unreads fetched-articles))
4672 (let ((marks (assq 'seen (gnus-info-marks info))))
4673 ;; The `seen' marks are treated specially.
4674 (when (setq gnus-newsgroup-seen (cdr marks))
4675 (dolist (article gnus-newsgroup-articles)
4676 (unless (gnus-member-of-range
4677 article gnus-newsgroup-seen)
4678 (push article gnus-newsgroup-unseen)))))
4680 ;; Removed marked articles that do not exist.
4681 (gnus-update-missing-marks
4682 (gnus-sorted-complement fetched-articles articles))
4683 ;; We might want to build some more threads first.
4684 (when (and gnus-fetch-old-headers
4685 (eq gnus-headers-retrieved-by 'nov))
4686 (if (eq gnus-fetch-old-headers 'invisible)
4687 (gnus-build-all-threads)
4688 (gnus-build-old-threads)))
4689 ;; Let the Gnus agent mark articles as read.
4691 (gnus-agent-get-undownloaded-list))
4692 ;; Remove list identifiers from subject
4693 (when gnus-list-identifiers
4694 (gnus-summary-remove-list-identifiers))
4695 ;; Check whether auto-expire is to be done in this group.
4696 (setq gnus-newsgroup-auto-expire
4697 (gnus-group-auto-expirable-p group))
4698 ;; Set up the article buffer now, if necessary.
4699 (unless gnus-single-article-buffer
4700 (gnus-article-setup-buffer))
4701 ;; First and last article in this newsgroup.
4702 (when gnus-newsgroup-headers
4703 (setq gnus-newsgroup-begin
4704 (mail-header-number (car gnus-newsgroup-headers))
4707 (gnus-last-element gnus-newsgroup-headers))))
4708 ;; GROUP is successfully selected.
4709 (or gnus-newsgroup-headers t)))))
4711 (defun gnus-summary-display-make-predicate (display)
4712 (require 'gnus-agent)
4713 (when (= (length display) 1)
4714 (setq display (car display)))
4715 (unless gnus-summary-display-cache
4716 (dolist (elem (append (list (cons 'read 'read)
4717 (cons 'unseen 'unseen))
4718 gnus-article-mark-lists))
4719 (push (cons (cdr elem)
4721 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4722 gnus-summary-display-cache)))
4723 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4724 (gnus-get-predicate display)))
4726 ;; Uses the dynamically bound `number' variable.
4728 (defun gnus-article-marked-p (type &optional article)
4729 (let ((article (or article number)))
4732 (memq article gnus-newsgroup-marked))
4734 (memq article gnus-newsgroup-unsendable))
4735 ((eq type 'undownload)
4736 (memq article gnus-newsgroup-undownloaded))
4737 ((eq type 'download)
4738 (memq article gnus-newsgroup-downloadable))
4740 (memq article gnus-newsgroup-unreads))
4742 (memq article gnus-newsgroup-reads))
4744 (memq article gnus-newsgroup-dormant) )
4746 (memq article gnus-newsgroup-expirable))
4748 (memq article gnus-newsgroup-replied))
4750 (memq article gnus-newsgroup-killed))
4751 ((eq type 'bookmark)
4752 (assq article gnus-newsgroup-bookmarks))
4754 (assq article gnus-newsgroup-scored))
4756 (memq article gnus-newsgroup-saved))
4758 (memq article gnus-newsgroup-cached))
4760 (memq article gnus-newsgroup-forwarded))
4762 (not (memq article gnus-newsgroup-unseen)))
4764 (memq article gnus-newsgroup-recent))
4767 (defun gnus-articles-to-read (group &optional read-all)
4768 "Find out what articles the user wants to read."
4770 ;; Select all articles if `read-all' is non-nil, or if there
4771 ;; are no unread articles.
4773 (and (zerop (length gnus-newsgroup-marked))
4774 (zerop (length gnus-newsgroup-unreads)))
4775 (eq gnus-newsgroup-display 'gnus-not-ignore))
4776 ;; We want to select the headers for all the articles in
4777 ;; the group, so we select either all the active
4778 ;; articles in the group, or (if that's nil), the
4779 ;; articles in the cache.
4781 (gnus-uncompress-range (gnus-active group))
4782 (gnus-cache-articles-in-group group))
4783 ;; Select only the "normal" subset of articles.
4784 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4785 (copy-sequence gnus-newsgroup-unreads))
4787 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4788 (scored (length scored-list))
4789 (number (length articles))
4790 (marked (+ (length gnus-newsgroup-marked)
4791 (length gnus-newsgroup-dormant)))
4799 ((and (or (<= scored marked) (= scored number))
4800 (natnump gnus-large-newsgroup)
4801 (> number gnus-large-newsgroup))
4802 (let* ((cursor-in-echo-area nil)
4804 (read-from-minibuffer
4806 "How many articles from %s (max %d): "
4808 (gnus-group-decoded-name gnus-newsgroup-name)
4811 (cons (number-to-string gnus-large-newsgroup)
4813 (if (string-match "^[ \t]*$" input)
4816 ((and (> scored marked) (< scored number)
4817 (> (- scored number) 20))
4820 (format "%s %s (%d scored, %d total): "
4821 "How many articles from"
4822 (gnus-group-decoded-name group)
4824 (if (string-match "^[ \t]*$" input)
4828 (message "Quit getting the articles to read")
4830 (setq select (if (stringp select) (string-to-number select) select))
4831 (if (or (null select) (zerop select))
4833 (if (and (not (zerop scored)) (<= (abs select) scored))
4835 (setq articles (sort scored-list '<))
4836 (setq number (length articles)))
4837 (setq articles (copy-sequence articles)))
4839 (when (< (abs select) number)
4841 ;; Select the N oldest articles.
4842 (setcdr (nthcdr (1- (abs select)) articles) nil)
4843 ;; Select the N most recent articles.
4844 (setq articles (nthcdr (- number select) articles))))
4845 (setq gnus-newsgroup-unselected
4846 (gnus-sorted-intersection
4847 gnus-newsgroup-unreads
4848 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4849 (when gnus-alter-articles-to-read-function
4850 (setq gnus-newsgroup-unreads
4852 (funcall gnus-alter-articles-to-read-function
4853 gnus-newsgroup-name gnus-newsgroup-unreads)
4857 (defun gnus-killed-articles (killed articles)
4860 (when (inline (gnus-member-of-range (car articles) killed))
4861 (push (car articles) out))
4862 (setq articles (cdr articles)))
4865 (defun gnus-uncompress-marks (marks)
4866 "Uncompress the mark ranges in MARKS."
4867 (let ((uncompressed '(score bookmark))
4870 (if (memq (caar marks) uncompressed)
4871 (push (car marks) out)
4872 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4873 (setq marks (cdr marks)))
4876 (defun gnus-article-mark-to-type (mark)
4877 "Return the type of MARK."
4878 (or (cadr (assq mark gnus-article-special-mark-lists))
4881 (defun gnus-article-unpropagatable-p (mark)
4882 "Return whether MARK should be propagated to backend."
4883 (memq mark gnus-article-unpropagated-mark-lists))
4885 (defun gnus-adjust-marked-articles (info)
4886 "Set all article lists and remove all marks that are no longer valid."
4887 (let* ((marked-lists (gnus-info-marks info))
4888 (active (gnus-active (gnus-info-group info)))
4891 (types gnus-article-mark-lists)
4892 marks var articles article mark mark-type)
4894 (dolist (marks marked-lists)
4895 (setq mark (car marks)
4896 mark-type (gnus-article-mark-to-type mark)
4897 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4899 ;; We set the variable according to the type of the marks list,
4900 ;; and then adjust the marks to a subset of the active articles.
4902 ;; Adjust "simple" lists.
4903 ((eq mark-type 'list)
4904 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4905 (when (memq mark '(tick dormant expire reply save))
4907 (when (or (< (setq article (pop articles)) min) (> article max))
4908 (set var (delq article (symbol-value var)))))))
4910 ((eq mark-type 'tuple)
4911 (set var (setq articles (cdr marks)))
4912 (when (not (listp (cdr (symbol-value var))))
4913 (set var (list (symbol-value var))))
4914 (when (not (listp (cdr articles)))
4915 (setq articles (list articles)))
4917 (when (or (not (consp (setq article (pop articles))))
4918 (< (car article) min)
4919 (> (car article) max))
4920 (set var (delq article (symbol-value var))))))
4921 ((eq mark-type 'range)
4923 ((eq mark 'seen))))))))
4925 (defun gnus-update-missing-marks (missing)
4926 "Go through the list of MISSING articles and remove them from the mark lists."
4929 ;; Go through all types.
4930 (dolist (elem gnus-article-mark-lists)
4931 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4932 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4933 (when (symbol-value var)
4934 ;; This list has articles. So we delete all missing
4935 ;; articles from it.
4938 (set var (delq (pop m) (symbol-value var))))))))))
4940 (defun gnus-update-marks ()
4941 "Enter the various lists of marked articles into the newsgroup info list."
4942 (let ((types gnus-article-mark-lists)
4943 (info (gnus-get-info gnus-newsgroup-name))
4944 type list newmarked symbol delta-marks)
4946 ;; Add all marks lists to the list of marks lists.
4947 (while (setq type (pop types))
4948 (setq list (symbol-value
4950 (intern (format "gnus-newsgroup-%s" (car type))))))
4953 ;; Get rid of the entries of the articles that have the
4955 (when (and (eq (cdr type) 'score)
4959 (prev (cons nil list))
4962 (if (or (not (consp (car arts)))
4963 (= (cdar arts) gnus-summary-default-score))
4964 (setcdr prev (cdr arts))
4966 (setq arts (cdr arts)))
4967 (setq list (cdr all)))))
4969 (when (eq (cdr type) 'seen)
4972 (gnus-add-to-range list gnus-newsgroup-unseen)
4973 (gnus-compress-sequence gnus-newsgroup-articles))))
4975 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4976 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4978 (when (and (gnus-check-backend-function
4979 'request-set-mark gnus-newsgroup-name)
4980 (not (gnus-article-unpropagatable-p (cdr type))))
4981 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4982 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4983 (add (gnus-remove-from-range
4984 (gnus-copy-sequence list) old)))
4986 (push (list add 'add (list (cdr type))) delta-marks))
4988 (push (list del 'del (list (cdr type))) delta-marks))))
4991 (push (cons (cdr type) list) newmarked)))
4994 (unless (gnus-check-group gnus-newsgroup-name)
4995 (error "Can't open server for %s" gnus-newsgroup-name))
4996 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4998 ;; Enter these new marks into the info of the group.
5000 (setcar (nthcdr 3 info) newmarked)
5001 ;; Add the marks lists to the end of the info.
5003 (setcdr (nthcdr 2 info) (list newmarked))))
5005 ;; Cut off the end of the info if there's nothing else there.
5009 (when (nthcdr (decf i) info)
5010 (setcdr (nthcdr i info) nil)))))))
5012 (defun gnus-set-mode-line (where)
5013 "Set the mode line of the article or summary buffers.
5014 If WHERE is `summary', the summary mode line format will be used."
5015 ;; Is this mode line one we keep updated?
5016 (when (and (memq where gnus-updated-mode-lines)
5018 (intern (format "gnus-%s-mode-line-format-spec" where))))
5021 ;; We evaluate this in the summary buffer since these
5022 ;; variables are buffer-local to that buffer.
5023 (set-buffer gnus-summary-buffer)
5024 ;; We bind all these variables that are used in the `eval' form
5026 (let* ((mformat (symbol-value
5028 (format "gnus-%s-mode-line-format-spec" where))))
5029 (gnus-tmp-group-name (gnus-group-decoded-name
5030 gnus-newsgroup-name))
5031 (gnus-tmp-article-number (or gnus-current-article 0))
5032 (gnus-tmp-unread gnus-newsgroup-unreads)
5033 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5034 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5035 (gnus-tmp-unread-and-unselected
5036 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5037 (zerop gnus-tmp-unselected))
5039 ((zerop gnus-tmp-unselected)
5040 (format "{%d more}" gnus-tmp-unread-and-unticked))
5041 (t (format "{%d(+%d) more}"
5042 gnus-tmp-unread-and-unticked
5043 gnus-tmp-unselected))))
5045 (if (and gnus-current-headers
5046 (vectorp gnus-current-headers))
5047 (gnus-mode-string-quote
5048 (mail-header-subject gnus-current-headers))
5050 bufname-length max-len
5051 gnus-tmp-header);; passed as argument to any user-format-funcs
5052 (setq mode-string (eval mformat))
5053 (setq bufname-length (if (string-match "%b" mode-string)
5056 (if (eq where 'summary)
5058 (get-buffer gnus-article-buffer))))
5061 (setq max-len (max 4 (if gnus-mode-non-string-length
5063 gnus-mode-non-string-length
5065 (length mode-string))))
5066 ;; We might have to chop a bit of the string off...
5067 (when (> (length mode-string) max-len)
5069 (concat (gnus-truncate-string mode-string (- max-len 3))
5071 ;; Pad the mode string a bit.
5072 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5073 ;; Update the mode line.
5074 (setq mode-line-buffer-identification
5075 (gnus-mode-line-buffer-identification (list mode-string)))
5076 (set-buffer-modified-p t))))
5078 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5079 "Go through the HEADERS list and add all Xrefs to a hash table.
5080 The resulting hash table is returned, or nil if no Xrefs were found."
5081 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5082 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5083 (xref-hashtb (gnus-make-hashtable))
5084 start group entry number xrefs header)
5086 (setq header (pop headers))
5087 (when (and (setq xrefs (mail-header-xref header))
5088 (not (memq (setq number (mail-header-number header))
5091 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5092 (setq start (match-end 0))
5093 (setq group (if prefix
5094 (concat prefix (substring xrefs (match-beginning 1)
5096 (substring xrefs (match-beginning 1) (match-end 1))))
5098 (string-to-int (substring xrefs (match-beginning 2)
5100 (if (setq entry (gnus-gethash group xref-hashtb))
5101 (setcdr entry (cons number (cdr entry)))
5102 (gnus-sethash group (cons number nil) xref-hashtb)))))
5103 (and start xref-hashtb)))
5105 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5106 "Look through all the headers and mark the Xrefs as read."
5107 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5108 name entry info xref-hashtb idlist method nth4)
5110 (set-buffer gnus-group-buffer)
5111 (when (setq xref-hashtb
5112 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5115 (unless (string= from-newsgroup (setq name (symbol-name group)))
5116 (setq idlist (symbol-value group))
5117 ;; Dead groups are not updated.
5119 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5121 (when (stringp (setq nth4 (gnus-info-method info)))
5122 (setq nth4 (gnus-server-to-method nth4))))
5123 ;; Only do the xrefs if the group has the same
5124 ;; select method as the group we have just read.
5125 (or (gnus-methods-equal-p
5126 nth4 (gnus-find-method-for-group from-newsgroup))
5128 (equal nth4 (setq method (gnus-find-method-for-group
5130 (and (equal (car nth4) (car method))
5131 (equal (nth 1 nth4) (nth 1 method))))
5132 gnus-use-cross-reference
5133 (or (not (eq gnus-use-cross-reference t))
5135 ;; Only do cross-references on subscribed
5136 ;; groups, if that is what is wanted.
5137 (<= (gnus-info-level info) gnus-level-subscribed))
5138 (gnus-group-make-articles-read name idlist))))
5141 (defun gnus-compute-read-articles (group articles)
5142 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5143 (info (nth 2 entry))
5144 (active (gnus-active group))
5147 ;; First peel off all invalid article numbers.
5149 (let ((ids articles)
5151 (while (setq id (pop ids))
5152 (when (and first (> id (cdr active)))
5153 ;; We'll end up in this situation in one particular
5154 ;; obscure situation. If you re-scan a group and get
5155 ;; a new article that is cross-posted to a different
5156 ;; group that has not been re-scanned, you might get
5157 ;; crossposted article that has a higher number than
5158 ;; Gnus believes possible. So we re-activate this
5159 ;; group as well. This might mean doing the
5160 ;; crossposting thingy will *increase* the number
5161 ;; of articles in some groups. Tsk, tsk.
5162 (setq active (or (gnus-activate-group group) active)))
5163 (when (or (> id (cdr active))
5164 (< id (car active)))
5165 (setq articles (delq id articles))))))
5166 ;; If the read list is nil, we init it.
5168 (null (gnus-info-read info))
5170 (setq ninfo (cons 1 (1- (car active))))
5171 (setq ninfo (gnus-info-read info)))
5172 ;; Then we add the read articles to the range.
5174 ninfo (setq articles (sort articles '<))))))
5176 (defun gnus-group-make-articles-read (group articles)
5177 "Update the info of GROUP to say that ARTICLES are read."
5179 (entry (gnus-gethash group gnus-newsrc-hashtb))
5180 (info (nth 2 entry))
5181 (active (gnus-active group))
5184 (setq range (gnus-compute-read-articles group articles))
5186 (set-buffer gnus-group-buffer)
5189 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5190 (gnus-info-set-read ',info ',(gnus-info-read info))
5191 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5192 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5193 (gnus-group-update-group ,group t))))
5194 ;; Add the read articles to the range.
5195 (gnus-info-set-read info range)
5196 (gnus-request-set-mark group (list (list range 'add '(read))))
5197 ;; Then we have to re-compute how many unread
5198 ;; articles there are in this group.
5202 (setq num (- (1+ (cdr active)) (car active))))
5203 ((not (listp (cdr range)))
5204 (setq num (- (cdr active) (- (1+ (cdr range))
5208 (if (numberp (car range))
5210 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5211 (setq range (cdr range)))
5212 (setq num (- (cdr active) num))))
5213 ;; Update the number of unread articles.
5215 ;; Update the group buffer.
5216 (gnus-group-update-group group t)))))
5218 (defvar gnus-newsgroup-none-id 0)
5220 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5221 (let ((cur nntp-server-buffer)
5224 (save-excursion (set-buffer gnus-summary-buffer)
5225 gnus-newsgroup-dependencies)))
5227 (mail-parse-charset gnus-newsgroup-charset)
5228 (mail-parse-ignored-charsets
5229 (save-excursion (condition-case nil
5230 (set-buffer gnus-summary-buffer)
5232 gnus-newsgroup-ignored-charsets)))
5234 (set-buffer nntp-server-buffer)
5235 ;; Translate all TAB characters into SPACE characters.
5236 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5237 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5238 (gnus-run-hooks 'gnus-parse-headers-hook)
5239 (let ((case-fold-search t)
5240 in-reply-to header p lines chars ctype)
5241 (goto-char (point-min))
5242 ;; Search to the beginning of the next header. Error messages
5243 ;; do not begin with 2 or 3.
5244 (while (re-search-forward "^[23][0-9]+ " nil t)
5247 ;; This implementation of this function, with nine
5248 ;; search-forwards instead of the one re-search-forward and
5249 ;; a case (which basically was the old function) is actually
5250 ;; about twice as fast, even though it looks messier. You
5251 ;; can't have everything, I guess. Speed and elegance
5252 ;; doesn't always go hand in hand.
5255 (make-full-mail-header
5261 (narrow-to-region (point)
5262 (or (and (search-forward "\n.\n" nil t)
5268 (if (search-forward "\nsubject:" nil t)
5269 (nnheader-header-value)
5274 (if (search-forward "\nfrom:" nil t)
5275 (nnheader-header-value)
5280 (if (search-forward "\ndate:" nil t)
5281 (nnheader-header-value) ""))
5285 (setq id (if (re-search-forward
5286 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5287 ;; We do it this way to make sure the Message-ID
5288 ;; is (somewhat) syntactically valid.
5289 (buffer-substring (match-beginning 1)
5291 ;; If there was no message-id, we just fake one
5292 ;; to make subsequent routines simpler.
5293 (nnheader-generate-fake-message-id))))
5297 (if (search-forward "\nreferences:" nil t)
5301 (nnheader-header-value)
5306 (search-backward ">" end t)
5309 (search-backward "<" end t)
5311 ;; Get the references from the in-reply-to header if there
5312 ;; were no references and the in-reply-to header looks
5314 (if (and (search-forward "\nin-reply-to:" nil t)
5315 (setq in-reply-to (nnheader-header-value))
5316 (string-match "<[^>]+>" in-reply-to))
5318 (setq ref (substring in-reply-to (match-beginning 0)
5320 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5321 (setq ref2 (substring in-reply-to (match-beginning 0)
5323 (when (> (length ref2) (length ref))
5330 (if (search-forward "\nchars: " nil t)
5331 (if (numberp (setq chars (ignore-errors (read cur))))
5337 (if (search-forward "\nlines: " nil t)
5338 (if (numberp (setq lines (ignore-errors (read cur))))
5344 (and (search-forward "\nxref:" nil t)
5345 (nnheader-header-value)))
5347 (when gnus-extra-headers
5348 (let ((extra gnus-extra-headers)
5352 (when (search-forward
5353 (concat "\n" (symbol-name (car extra)) ":") nil t)
5354 (push (cons (car extra) (nnheader-header-value)) out))
5358 (if (and (search-forward "\ncontent-type: " nil t)
5359 (setq ctype (nnheader-header-value)))
5360 (mime-entity-set-content-type-internal
5361 header (mime-parse-Content-Type ctype)))
5362 (when (equal id ref)
5365 (when gnus-alter-header-function
5366 (funcall gnus-alter-header-function header)
5367 (setq id (mail-header-id header)
5368 ref (gnus-parent-id (mail-header-references header))))
5371 (gnus-dependencies-add-header
5372 header dependencies force-new))
5373 (push header headers))
5374 (goto-char (point-max))
5376 (nreverse headers)))))
5378 ;; Goes through the xover lines and returns a list of vectors
5379 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5380 force-new dependencies
5381 group also-fetch-heads)
5382 "Parse the news overview data in the server buffer.
5383 Return a list of headers that match SEQUENCE (see
5384 `nntp-retrieve-headers')."
5385 ;; Get the Xref when the users reads the articles since most/some
5386 ;; NNTP servers do not include Xrefs when using XOVER.
5387 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5388 (let ((mail-parse-charset gnus-newsgroup-charset)
5389 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5390 (cur nntp-server-buffer)
5391 (dependencies (or dependencies gnus-newsgroup-dependencies))
5393 ((eq gnus-read-all-available-headers t)
5395 ((stringp gnus-read-all-available-headers)
5396 (string-match gnus-read-all-available-headers group))
5399 number headers header)
5401 (set-buffer nntp-server-buffer)
5402 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5403 ;; Allow the user to mangle the headers before parsing them.
5404 (gnus-run-hooks 'gnus-parse-headers-hook)
5405 (goto-char (point-min))
5408 (while (and (or sequence allp)
5410 (setq number (read cur))
5412 (while (and sequence
5413 (< (car sequence) number))
5414 (setq sequence (cdr sequence))))
5417 (eq number (car sequence))))
5419 (setq sequence (cdr sequence))
5420 (setq header (inline
5421 (gnus-nov-parse-line
5422 number dependencies force-new)))))
5423 (push header headers))
5426 (gnus-error 4 "Strange nov line (%d)"
5427 (count-lines (point-min) (point)))))
5429 ;; A common bug in inn is that if you have posted an article and
5430 ;; then retrieves the active file, it will answer correctly --
5431 ;; the new article is included. However, a NOV entry for the
5432 ;; article may not have been generated yet, so this may fail.
5433 ;; We work around this problem by retrieving the last few
5434 ;; headers using HEAD.
5435 (if (or (not also-fetch-heads)
5437 ;; We (probably) got all the headers.
5439 (let ((gnus-nov-is-evil t))
5442 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5443 (gnus-get-newsgroup-headers))))))))
5445 (defun gnus-article-get-xrefs ()
5446 "Fill in the Xref value in `gnus-current-headers', if necessary.
5447 This is meant to be called in `gnus-article-internal-prepare-hook'."
5448 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5449 gnus-current-headers)))
5450 (or (not gnus-use-cross-reference)
5452 (and (mail-header-xref headers)
5453 (not (string= (mail-header-xref headers) "")))
5454 (let ((case-fold-search t)
5457 (nnheader-narrow-to-headers)
5458 (goto-char (point-min))
5459 (when (or (and (not (eobp))
5460 (eq (downcase (char-after)) ?x)
5461 (looking-at "Xref:"))
5462 (search-forward "\nXref:" nil t))
5463 (goto-char (1+ (match-end 0)))
5464 (setq xref (buffer-substring (point)
5465 (progn (end-of-line) (point))))
5466 (mail-header-set-xref headers xref)))))))
5468 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5469 "Find article ID and insert the summary line for that article.
5470 OLD-HEADER can either be a header or a line number to insert
5471 the subject line on."
5472 (let* ((line (and (numberp old-header) old-header))
5473 (old-header (and (vectorp old-header) old-header))
5474 (header (cond ((and old-header use-old-header)
5477 (gnus-number-to-header id))
5478 (gnus-number-to-header id))
5480 (gnus-read-header id))))
5481 (number (and (numberp id) id))
5484 ;; Rebuild the thread that this article is part of and go to the
5485 ;; article we have fetched.
5486 (when (and (not gnus-show-threads)
5489 (setq d (gnus-data-find (mail-header-number old-header))))
5490 (goto-char (gnus-data-pos d))
5493 (- (gnus-point-at-bol)
5495 (1+ (gnus-point-at-eol))
5496 (gnus-delete-line))))))
5498 (mail-header-set-number header (mail-header-number old-header)))
5499 (setq gnus-newsgroup-sparse
5500 (delq (setq number (mail-header-number header))
5501 gnus-newsgroup-sparse))
5502 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5503 (push number gnus-newsgroup-limit)
5504 (gnus-rebuild-thread (mail-header-id header) line)
5505 (gnus-summary-goto-subject number nil t))
5506 (when (and (numberp number)
5508 ;; We have to update the boundaries even if we can't fetch the
5509 ;; article if ID is a number -- so that the next `P' or `N'
5510 ;; command will fetch the previous (or next) article even
5511 ;; if the one we tried to fetch this time has been canceled.
5512 (when (> number gnus-newsgroup-end)
5513 (setq gnus-newsgroup-end number))
5514 (when (< number gnus-newsgroup-begin)
5515 (setq gnus-newsgroup-begin number))
5516 (setq gnus-newsgroup-unselected
5517 (delq number gnus-newsgroup-unselected)))
5518 ;; Report back a success?
5519 (and header (mail-header-number header))))
5521 ;;; Process/prefix in the summary buffer
5523 (defun gnus-summary-work-articles (n)
5524 "Return a list of articles to be worked upon.
5525 The prefix argument, the list of process marked articles, and the
5526 current article will be taken into consideration."
5528 (set-buffer gnus-summary-buffer)
5531 ;; A numerical prefix has been given.
5532 (setq n (prefix-numeric-value n))
5533 (let ((backward (< n 0))
5534 (n (abs (prefix-numeric-value n)))
5539 (push (setq article (gnus-summary-article-number))
5542 (gnus-summary-find-prev nil article)
5543 (gnus-summary-find-next nil article)))
5545 (nreverse articles)))
5546 ((and (gnus-region-active-p) (mark))
5547 (message "region active")
5548 ;; Work on the region between point and mark.
5549 (let ((max (max (point) (mark)))
5552 (goto-char (min (point) (mark)))
5555 (push (setq article (gnus-summary-article-number)) articles)
5556 (gnus-summary-find-next nil article)
5558 (nreverse articles))))
5559 (gnus-newsgroup-processable
5560 ;; There are process-marked articles present.
5561 ;; Save current state.
5562 (gnus-summary-save-process-mark)
5564 (reverse gnus-newsgroup-processable))
5566 ;; Just return the current article.
5567 (list (gnus-summary-article-number))))))
5569 (defmacro gnus-summary-iterate (arg &rest forms)
5570 "Iterate over the process/prefixed articles and do FORMS.
5571 ARG is the interactive prefix given to the command. FORMS will be
5572 executed with point over the summary line of the articles."
5573 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5574 `(let ((,articles (gnus-summary-work-articles ,arg)))
5576 (gnus-summary-goto-subject (car ,articles))
5580 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5581 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5583 (defun gnus-summary-save-process-mark ()
5584 "Push the current set of process marked articles on the stack."
5586 (push (copy-sequence gnus-newsgroup-processable)
5587 gnus-newsgroup-process-stack))
5589 (defun gnus-summary-kill-process-mark ()
5590 "Push the current set of process marked articles on the stack and unmark."
5592 (gnus-summary-save-process-mark)
5593 (gnus-summary-unmark-all-processable))
5595 (defun gnus-summary-yank-process-mark ()
5596 "Pop the last process mark state off the stack and restore it."
5598 (unless gnus-newsgroup-process-stack
5599 (error "Empty mark stack"))
5600 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5602 (defun gnus-summary-process-mark-set (set)
5603 "Make SET into the current process marked articles."
5604 (gnus-summary-unmark-all-processable)
5606 (gnus-summary-set-process-mark (pop set))))
5608 ;;; Searching and stuff
5610 (defun gnus-summary-search-group (&optional backward use-level)
5611 "Search for next unread newsgroup.
5612 If optional argument BACKWARD is non-nil, search backward instead."
5614 (set-buffer gnus-group-buffer)
5615 (when (gnus-group-search-forward
5616 backward nil (if use-level (gnus-group-group-level) nil))
5617 (gnus-group-group-name))))
5619 (defun gnus-summary-best-group (&optional exclude-group)
5620 "Find the name of the best unread group.
5621 If EXCLUDE-GROUP, do not go to this group."
5623 (set-buffer gnus-group-buffer)
5625 (gnus-group-best-unread-group exclude-group))))
5627 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5628 (if backward (gnus-summary-find-prev)
5629 (let* ((dummy (gnus-summary-article-intangible-p))
5630 (article (or article (gnus-summary-article-number)))
5631 (arts (gnus-data-find-list article))
5633 (when (and (not dummy)
5634 (or (not gnus-summary-check-current)
5636 (not (gnus-data-unread-p (car arts)))))
5637 (setq arts (cdr arts)))
5642 (when (or (and undownloaded
5643 (eq gnus-undownloaded-mark
5644 (gnus-data-mark (car arts))))
5645 (gnus-data-unread-p (car arts)))
5646 (setq result (car arts)
5648 (setq arts (cdr arts)))
5651 (goto-char (gnus-data-pos result))
5652 (gnus-data-number result)))))
5654 (defun gnus-summary-find-prev (&optional unread article)
5655 (let* ((eobp (eobp))
5656 (article (or article (gnus-summary-article-number)))
5657 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5659 (when (and (not eobp)
5660 (or (not gnus-summary-check-current)
5662 (not (gnus-data-unread-p (car arts)))))
5663 (setq arts (cdr arts)))
5668 (when (gnus-data-unread-p (car arts))
5669 (setq result (car arts)
5671 (setq arts (cdr arts)))
5674 (goto-char (gnus-data-pos result))
5675 (gnus-data-number result))))
5677 (defun gnus-summary-find-subject (subject &optional unread backward article)
5678 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5679 (article (or article (gnus-summary-article-number)))
5680 (articles (gnus-data-list backward))
5681 (arts (gnus-data-find-list article articles))
5683 (when (or (not gnus-summary-check-current)
5685 (not (gnus-data-unread-p (car arts))))
5686 (setq arts (cdr arts)))
5688 (and (or (not unread)
5689 (gnus-data-unread-p (car arts)))
5690 (vectorp (gnus-data-header (car arts)))
5692 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5693 (setq result (car arts)
5695 (setq arts (cdr arts)))
5697 (goto-char (gnus-data-pos result))
5698 (gnus-data-number result))))
5700 (defun gnus-summary-search-forward (&optional unread subject backward)
5701 "Search forward for an article.
5702 If UNREAD, look for unread articles. If SUBJECT, look for
5703 articles with that subject. If BACKWARD, search backward instead."
5704 (cond (subject (gnus-summary-find-subject subject unread backward))
5705 (backward (gnus-summary-find-prev unread))
5706 (t (gnus-summary-find-next unread))))
5708 (defun gnus-recenter (&optional n)
5709 "Center point in window and redisplay frame.
5710 Also do horizontal recentering."
5712 (when (and gnus-auto-center-summary
5713 (not (eq gnus-auto-center-summary 'vertical)))
5714 (gnus-horizontal-recenter))
5717 (defun gnus-summary-recenter ()
5718 "Center point in the summary window.
5719 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5720 displayed, no centering will be performed."
5721 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5722 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5724 (let* ((top (cond ((< (window-height) 4) 0)
5725 ((< (window-height) 7) 1)
5726 (t (if (numberp gnus-auto-center-summary)
5727 gnus-auto-center-summary
5729 (height (1- (window-height)))
5730 (bottom (save-excursion (goto-char (point-max))
5731 (forward-line (- height))
5733 (window (get-buffer-window (current-buffer))))
5734 ;; The user has to want it.
5735 (when gnus-auto-center-summary
5736 (when (get-buffer-window gnus-article-buffer)
5737 ;; Only do recentering when the article buffer is displayed,
5738 ;; Set the window start to either `bottom', which is the biggest
5739 ;; possible valid number, or the second line from the top,
5740 ;; whichever is the least.
5741 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5742 (if (> bottom top-pos)
5743 ;; Keep the second line from the top visible
5744 (set-window-start window top-pos t)
5745 ;; Try to keep the bottom line visible; if it's partially
5746 ;; obscured, either scroll one more line to make it fully
5747 ;; visible, or revert to using TOP-POS.
5749 (goto-char (point-max))
5751 (let ((last-line-start (point)))
5753 (set-window-start window (point) t)
5754 (when (not (pos-visible-in-window-p last-line-start window))
5756 (set-window-start window (min (point) top-pos) t)))))))
5757 ;; Do horizontal recentering while we're at it.
5758 (when (and (get-buffer-window (current-buffer) t)
5759 (not (eq gnus-auto-center-summary 'vertical)))
5760 (let ((selected (selected-window)))
5761 (select-window (get-buffer-window (current-buffer) t))
5762 (gnus-summary-position-point)
5763 (gnus-horizontal-recenter)
5764 (select-window selected))))))
5766 (defun gnus-summary-jump-to-group (newsgroup)
5767 "Move point to NEWSGROUP in group mode buffer."
5768 ;; Keep update point of group mode buffer if visible.
5769 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5770 (save-window-excursion
5771 ;; Take care of tree window mode.
5772 (when (get-buffer-window gnus-group-buffer)
5773 (pop-to-buffer gnus-group-buffer))
5774 (gnus-group-jump-to-group newsgroup))
5776 ;; Take care of tree window mode.
5777 (if (get-buffer-window gnus-group-buffer)
5778 (pop-to-buffer gnus-group-buffer)
5779 (set-buffer gnus-group-buffer))
5780 (gnus-group-jump-to-group newsgroup))))
5782 ;; This function returns a list of article numbers based on the
5783 ;; difference between the ranges of read articles in this group and
5784 ;; the range of active articles.
5785 (defun gnus-list-of-unread-articles (group)
5786 (let* ((read (gnus-info-read (gnus-get-info group)))
5787 (active (or (gnus-active group) (gnus-activate-group group)))
5790 ;; If none are read, then all are unread.
5792 (setq first (car active))
5793 ;; If the range of read articles is a single range, then the
5794 ;; first unread article is the article after the last read
5795 ;; article. Sounds logical, doesn't it?
5796 (if (and (not (listp (cdr read)))
5797 (or (< (car read) (car active))
5798 (progn (setq read (list read))
5800 (setq first (max (car active) (1+ (cdr read))))
5801 ;; `read' is a list of ranges.
5802 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5805 (setq first (car active)))
5808 (while (< first nlast)
5810 (setq first (1+ first))))
5811 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5812 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5813 (setq read (cdr read)))))
5814 ;; And add the last unread articles.
5815 (while (<= first last)
5817 (setq first (1+ first)))
5818 ;; Return the list of unread articles.
5819 (delq 0 (nreverse unread))))
5821 (defun gnus-list-of-read-articles (group)
5822 "Return a list of unread, unticked and non-dormant articles."
5823 (let* ((info (gnus-get-info group))
5824 (marked (gnus-info-marks info))
5825 (active (gnus-active group)))
5827 (gnus-set-difference
5828 (gnus-sorted-complement
5829 (gnus-uncompress-range active)
5830 (gnus-list-of-unread-articles group))
5832 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5833 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5835 ;; Various summary commands
5837 (defun gnus-summary-select-article-buffer ()
5838 "Reconfigure windows to show article buffer."
5840 (if (not (gnus-buffer-live-p gnus-article-buffer))
5841 (error "There is no article buffer for this summary buffer")
5842 (gnus-configure-windows 'article)
5843 (select-window (get-buffer-window gnus-article-buffer))))
5845 (defun gnus-summary-universal-argument (arg)
5846 "Perform any operation on all articles that are process/prefixed."
5848 (let ((articles (gnus-summary-work-articles arg))
5855 (substitute-command-keys
5856 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5858 (gnus-error 1 "Undefined key")
5861 (gnus-summary-goto-subject (setq article (pop articles)))
5862 (let (gnus-newsgroup-processable)
5863 (command-execute func))
5864 (gnus-summary-remove-process-mark article)))))
5865 (gnus-summary-position-point))
5867 (defun gnus-summary-toggle-truncation (&optional arg)
5868 "Toggle truncation of summary lines.
5869 With arg, turn line truncation on iff arg is positive."
5871 (setq truncate-lines
5872 (if (null arg) (not truncate-lines)
5873 (> (prefix-numeric-value arg) 0)))
5876 (defun gnus-summary-reselect-current-group (&optional all rescan)
5877 "Exit and then reselect the current newsgroup.
5878 The prefix argument ALL means to select all articles."
5880 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5881 (error "Ephemeral groups can't be reselected"))
5882 (let ((current-subject (gnus-summary-article-number))
5883 (group gnus-newsgroup-name))
5884 (setq gnus-newsgroup-begin nil)
5886 ;; We have to adjust the point of group mode buffer because
5887 ;; point was moved to the next unread newsgroup by exiting.
5888 (gnus-summary-jump-to-group group)
5891 (save-window-excursion
5892 ;; Don't show group contents.
5893 (set-window-start (selected-window) (point-max))
5894 (gnus-group-get-new-news-this-group 1))))
5895 (gnus-group-read-group all t)
5896 (gnus-summary-goto-subject current-subject nil t)))
5898 (defun gnus-summary-rescan-group (&optional all)
5899 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5901 (gnus-summary-reselect-current-group all t))
5903 (defun gnus-summary-update-info (&optional non-destructive)
5905 (let ((group gnus-newsgroup-name))
5907 (when gnus-newsgroup-kill-headers
5908 (setq gnus-newsgroup-killed
5909 (gnus-compress-sequence
5911 (gnus-set-sorted-intersection
5912 (gnus-uncompress-range gnus-newsgroup-killed)
5913 (setq gnus-newsgroup-unselected
5914 (sort gnus-newsgroup-unselected '<)))
5915 (setq gnus-newsgroup-unreads
5916 (sort gnus-newsgroup-unreads '<)))
5918 (unless (listp (cdr gnus-newsgroup-killed))
5919 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5920 (let ((headers gnus-newsgroup-headers))
5921 ;; Set the new ranges of read articles.
5923 (set-buffer gnus-group-buffer)
5924 (gnus-undo-force-boundary))
5925 (gnus-update-read-articles
5926 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5927 ;; Set the current article marks.
5928 (let ((gnus-newsgroup-scored
5929 (if (and (not gnus-save-score)
5930 (not non-destructive))
5932 gnus-newsgroup-scored)))
5934 (gnus-update-marks)))
5935 ;; Do the cross-ref thing.
5936 (when gnus-use-cross-reference
5937 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5938 ;; Do not switch windows but change the buffer to work.
5939 (set-buffer gnus-group-buffer)
5940 (unless (gnus-ephemeral-group-p group)
5941 (gnus-group-update-group group)))))))
5943 (defun gnus-summary-save-newsrc (&optional force)
5944 "Save the current number of read/marked articles in the dribble buffer.
5945 The dribble buffer will then be saved.
5946 If FORCE (the prefix), also save the .newsrc file(s)."
5948 (gnus-summary-update-info t)
5950 (gnus-save-newsrc-file)
5951 (gnus-dribble-save)))
5953 (defun gnus-summary-exit (&optional temporary)
5954 "Exit reading current newsgroup, and then return to group selection mode.
5955 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5957 (gnus-set-global-variables)
5958 (gnus-kill-save-kill-buffer)
5959 (gnus-async-halt-prefetch)
5960 (let* ((group gnus-newsgroup-name)
5961 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5964 (buf (current-buffer)))
5966 ;; Do adaptive scoring, and possibly save score files.
5967 (when gnus-newsgroup-adaptive
5968 (gnus-score-adaptive))
5969 (when gnus-use-scoring
5971 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5972 ;; If we have several article buffers, we kill them at exit.
5973 (unless gnus-single-article-buffer
5974 (gnus-kill-buffer gnus-original-article-buffer)
5975 (setq gnus-article-current nil))
5976 (when gnus-use-cache
5977 (gnus-cache-possibly-remove-articles)
5978 (gnus-cache-save-buffers))
5979 (gnus-async-prefetch-remove-group group)
5980 (when gnus-suppress-duplicates
5981 (gnus-dup-enter-articles))
5982 (when gnus-use-trees
5983 (gnus-tree-close group))
5984 (when gnus-use-cache
5985 (gnus-cache-write-active))
5986 ;; Remove entries for this group.
5987 (nnmail-purge-split-history (gnus-group-real-name group))
5988 ;; Make all changes in this group permanent.
5990 (gnus-run-hooks 'gnus-exit-group-hook)
5991 (gnus-summary-update-info))
5992 (gnus-close-group group)
5993 ;; Make sure where we were, and go to next newsgroup.
5994 (set-buffer gnus-group-buffer)
5996 (gnus-group-jump-to-group group))
5997 (gnus-run-hooks 'gnus-summary-exit-hook)
5998 (unless (or quit-config
5999 ;; If this group has disappeared from the summary
6000 ;; buffer, don't skip forwards.
6001 (not (string= group (gnus-group-group-name))))
6002 (gnus-group-next-unread-group 1))
6003 (setq group-point (point))
6006 ;; If we have several article buffers, we kill them at exit.
6007 (unless gnus-single-article-buffer
6008 (gnus-kill-buffer gnus-article-buffer)
6009 (gnus-kill-buffer gnus-original-article-buffer)
6010 (setq gnus-article-current nil))
6012 (if (not gnus-kill-summary-on-exit)
6014 (gnus-deaden-summary)
6016 ;; We set all buffer-local variables to nil. It is unclear why
6017 ;; this is needed, but if we don't, buffer-local variables are
6018 ;; not garbage-collected, it seems. This would the lead to en
6019 ;; ever-growing Emacs.
6020 (gnus-summary-clear-local-variables)
6021 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6022 (gnus-summary-clear-local-variables))
6023 (when (get-buffer gnus-article-buffer)
6024 (bury-buffer gnus-article-buffer))
6025 ;; We clear the global counterparts of the buffer-local
6026 ;; variables as well, just to be on the safe side.
6027 (set-buffer gnus-group-buffer)
6028 (gnus-summary-clear-local-variables)
6029 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6030 (gnus-summary-clear-local-variables)))
6031 (setq gnus-current-select-method gnus-select-method)
6032 (pop-to-buffer gnus-group-buffer)
6033 (if (not quit-config)
6035 (goto-char group-point)
6036 (gnus-configure-windows 'group 'force)
6037 (unless (pos-visible-in-window-p)
6038 (forward-line (/ (static-if (featurep 'xemacs)
6039 (window-displayed-height)
6040 (1- (window-height)))
6042 (set-window-start (selected-window) (point))
6043 (goto-char group-point)))
6044 (gnus-handle-ephemeral-exit quit-config))
6045 ;; Return to group mode buffer.
6046 (when (eq mode 'gnus-summary-mode)
6047 (gnus-kill-buffer buf))
6048 ;; Clear the current group name.
6050 (setq gnus-newsgroup-name nil)))))
6052 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6053 (defun gnus-summary-exit-no-update (&optional no-questions)
6054 "Quit reading current newsgroup without updating read article info."
6056 (let* ((group gnus-newsgroup-name)
6057 (quit-config (gnus-group-quit-config group)))
6058 (when (or no-questions
6060 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6061 (gnus-async-halt-prefetch)
6063 (delq 'gnus-summary-expire-articles
6064 (copy-sequence gnus-summary-prepare-exit-hook)))
6065 ;; If we have several article buffers, we kill them at exit.
6066 (unless gnus-single-article-buffer
6067 (gnus-kill-buffer gnus-article-buffer)
6068 (gnus-kill-buffer gnus-original-article-buffer)
6069 (setq gnus-article-current nil))
6070 (if (not gnus-kill-summary-on-exit)
6071 (gnus-deaden-summary)
6072 (gnus-close-group group)
6073 (gnus-summary-clear-local-variables)
6074 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6075 (gnus-summary-clear-local-variables))
6076 (set-buffer gnus-group-buffer)
6077 (gnus-summary-clear-local-variables)
6078 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6079 (gnus-summary-clear-local-variables))
6080 (when (get-buffer gnus-summary-buffer)
6081 (kill-buffer gnus-summary-buffer)))
6082 (unless gnus-single-article-buffer
6083 (setq gnus-article-current nil))
6084 (when gnus-use-trees
6085 (gnus-tree-close group))
6086 (gnus-async-prefetch-remove-group group)
6087 (when (get-buffer gnus-article-buffer)
6088 (bury-buffer gnus-article-buffer))
6089 ;; Return to the group buffer.
6090 (gnus-configure-windows 'group 'force)
6091 ;; Clear the current group name.
6092 (setq gnus-newsgroup-name nil)
6093 (when (equal (gnus-group-group-name) group)
6094 (gnus-group-next-unread-group 1))
6096 (gnus-handle-ephemeral-exit quit-config)))))
6098 (defun gnus-handle-ephemeral-exit (quit-config)
6099 "Handle movement when leaving an ephemeral group.
6100 The state which existed when entering the ephemeral is reset."
6101 (if (not (buffer-name (car quit-config)))
6102 (gnus-configure-windows 'group 'force)
6103 (set-buffer (car quit-config))
6104 (cond ((eq major-mode 'gnus-summary-mode)
6105 (gnus-set-global-variables))
6106 ((eq major-mode 'gnus-article-mode)
6108 ;; The `gnus-summary-buffer' variable may point
6109 ;; to the old summary buffer when using a single
6111 (unless (gnus-buffer-live-p gnus-summary-buffer)
6112 (set-buffer gnus-group-buffer))
6113 (set-buffer gnus-summary-buffer)
6114 (gnus-set-global-variables))))
6115 (if (or (eq (cdr quit-config) 'article)
6116 (eq (cdr quit-config) 'pick))
6118 ;; The current article may be from the ephemeral group
6119 ;; thus it is best that we reload this article
6120 (gnus-summary-show-article)
6121 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6122 (gnus-configure-windows 'pick 'force)
6123 (gnus-configure-windows (cdr quit-config) 'force)))
6124 (gnus-configure-windows (cdr quit-config) 'force))
6125 (when (eq major-mode 'gnus-summary-mode)
6126 (gnus-summary-next-subject 1 nil t)
6127 (gnus-summary-recenter)
6128 (gnus-summary-position-point))))
6130 (defun gnus-summary-preview-mime-message ()
6131 "MIME decode and play this message."
6133 (let ((gnus-break-pages nil)
6135 (gnus-summary-select-article gnus-show-all-headers t))
6136 (select-window (get-buffer-window gnus-article-buffer)))
6140 (defvar gnus-dead-summary-mode-map nil)
6142 (unless gnus-dead-summary-mode-map
6143 (setq gnus-dead-summary-mode-map (make-keymap))
6144 (suppress-keymap gnus-dead-summary-mode-map)
6145 (substitute-key-definition
6146 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6147 (let ((keys '("\C-d" "\r" "\177" [delete])))
6149 (define-key gnus-dead-summary-mode-map
6150 (pop keys) 'gnus-summary-wake-up-the-dead))))
6152 (defvar gnus-dead-summary-mode nil
6153 "Minor mode for Gnus summary buffers.")
6155 (defun gnus-dead-summary-mode (&optional arg)
6156 "Minor mode for Gnus summary buffers."
6158 (when (eq major-mode 'gnus-summary-mode)
6159 (make-local-variable 'gnus-dead-summary-mode)
6160 (setq gnus-dead-summary-mode
6161 (if (null arg) (not gnus-dead-summary-mode)
6162 (> (prefix-numeric-value arg) 0)))
6163 (when gnus-dead-summary-mode
6164 (gnus-add-minor-mode
6165 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6167 (defun gnus-deaden-summary ()
6168 "Make the current summary buffer into a dead summary buffer."
6169 ;; Kill any previous dead summary buffer.
6170 (when (and gnus-dead-summary
6171 (buffer-name gnus-dead-summary))
6173 (set-buffer gnus-dead-summary)
6174 (when gnus-dead-summary-mode
6175 (kill-buffer (current-buffer)))))
6176 ;; Make this the current dead summary.
6177 (setq gnus-dead-summary (current-buffer))
6178 (gnus-dead-summary-mode 1)
6179 (let ((name (buffer-name)))
6180 (when (string-match "Summary" name)
6182 (concat (substring name 0 (match-beginning 0)) "Dead "
6183 (substring name (match-beginning 0)))
6187 (defun gnus-kill-or-deaden-summary (buffer)
6188 "Kill or deaden the summary BUFFER."
6190 (when (and (buffer-name buffer)
6191 (not gnus-single-article-buffer))
6194 (gnus-kill-buffer gnus-article-buffer)
6195 (gnus-kill-buffer gnus-original-article-buffer)))
6196 (cond (gnus-kill-summary-on-exit
6197 (when (and gnus-use-trees
6198 (gnus-buffer-exists-p buffer))
6201 (gnus-tree-close gnus-newsgroup-name)))
6202 (gnus-kill-buffer buffer))
6203 ((gnus-buffer-exists-p buffer)
6206 (gnus-deaden-summary))))))
6208 (defun gnus-summary-wake-up-the-dead (&rest args)
6209 "Wake up the dead summary buffer."
6211 (gnus-dead-summary-mode -1)
6212 (let ((name (buffer-name)))
6213 (when (string-match "Dead " name)
6215 (concat (substring name 0 (match-beginning 0))
6216 (substring name (match-end 0)))
6218 (gnus-message 3 "This dead summary is now alive again"))
6220 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6221 (defun gnus-summary-fetch-faq (&optional faq-dir)
6222 "Fetch the FAQ for the current group.
6223 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6227 (when current-prefix-arg
6229 "Faq dir: " (and (listp gnus-group-faq-directory)
6230 (mapcar (lambda (file) (list file))
6231 gnus-group-faq-directory))))))
6232 (let (gnus-faq-buffer)
6233 (when (setq gnus-faq-buffer
6234 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6235 (gnus-configure-windows 'summary-faq))))
6237 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6238 (defun gnus-summary-describe-group (&optional force)
6239 "Describe the current newsgroup."
6241 (gnus-group-describe-group force gnus-newsgroup-name))
6243 (defun gnus-summary-describe-briefly ()
6244 "Describe summary mode commands briefly."
6246 (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")))
6248 ;; Walking around group mode buffer from summary mode.
6250 (defun gnus-summary-next-group (&optional no-article target-group backward)
6251 "Exit current newsgroup and then select next unread newsgroup.
6252 If prefix argument NO-ARTICLE is non-nil, no article is selected
6253 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6254 previous group instead."
6256 ;; Stop pre-fetching.
6257 (gnus-async-halt-prefetch)
6258 (let ((current-group gnus-newsgroup-name)
6259 (current-buffer (current-buffer))
6261 ;; First we semi-exit this group to update Xrefs and all variables.
6262 ;; We can't do a real exit, because the window conf must remain
6263 ;; the same in case the user is prompted for info, and we don't
6264 ;; want the window conf to change before that...
6265 (gnus-summary-exit t)
6266 (while (not entered)
6267 ;; Then we find what group we are supposed to enter.
6268 (set-buffer gnus-group-buffer)
6269 (gnus-group-jump-to-group current-group)
6272 (if (eq gnus-keep-same-level 'best)
6273 (gnus-summary-best-group gnus-newsgroup-name)
6274 (gnus-summary-search-group backward gnus-keep-same-level))))
6275 (if (not target-group)
6276 ;; There are no further groups, so we return to the group
6279 (gnus-message 5 "Returning to the group buffer")
6281 (when (gnus-buffer-live-p current-buffer)
6282 (set-buffer current-buffer)
6283 (gnus-summary-exit))
6284 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6285 ;; We try to enter the target group.
6286 (gnus-group-jump-to-group target-group)
6287 (let ((unreads (gnus-group-group-unread)))
6288 (if (and (or (eq t unreads)
6289 (and unreads (not (zerop unreads))))
6290 (gnus-summary-read-group
6291 target-group nil no-article
6292 (and (buffer-name current-buffer) current-buffer)
6295 (setq current-group target-group
6296 target-group nil)))))))
6298 (defun gnus-summary-prev-group (&optional no-article)
6299 "Exit current newsgroup and then select previous unread newsgroup.
6300 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6302 (gnus-summary-next-group no-article nil t))
6304 ;; Walking around summary lines.
6306 (defun gnus-summary-first-subject (&optional unread undownloaded)
6307 "Go to the first unread subject.
6308 If UNREAD is non-nil, go to the first unread article.
6309 Returns the article selected or nil if there are no unread articles."
6314 ((null gnus-newsgroup-data)
6315 (gnus-message 3 "No articles in the group")
6317 ;; Pick the first article.
6319 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6320 (gnus-data-number (car gnus-newsgroup-data)))
6321 ;; No unread articles.
6322 ((null gnus-newsgroup-unreads)
6323 (gnus-message 3 "No more unread articles")
6325 ;; Find the first unread article.
6327 (let ((data gnus-newsgroup-data))
6329 (and (not (and undownloaded
6330 (eq gnus-undownloaded-mark
6331 (gnus-data-mark (car data)))))
6332 (not (gnus-data-unread-p (car data)))))
6333 (setq data (cdr data)))
6335 (goto-char (gnus-data-pos (car data)))
6336 (gnus-data-number (car data))))))
6337 (gnus-summary-position-point)))
6339 (defun gnus-summary-next-subject (n &optional unread dont-display)
6340 "Go to next N'th summary line.
6341 If N is negative, go to the previous N'th subject line.
6342 If UNREAD is non-nil, only unread articles are selected.
6343 The difference between N and the actual number of steps taken is
6346 (let ((backward (< n 0))
6350 (gnus-summary-find-prev unread)
6351 (gnus-summary-find-next unread)))
6352 (unless (zerop (setq n (1- n)))
6353 (gnus-summary-show-thread)))
6355 (gnus-message 7 "No more%s articles"
6356 (if unread " unread" "")))
6357 (unless dont-display
6358 (gnus-summary-recenter)
6359 (gnus-summary-position-point))
6362 (defun gnus-summary-next-unread-subject (n)
6363 "Go to next N'th unread summary line."
6365 (gnus-summary-next-subject n t))
6367 (defun gnus-summary-prev-subject (n &optional unread)
6368 "Go to previous N'th summary line.
6369 If optional argument UNREAD is non-nil, only unread article is selected."
6371 (gnus-summary-next-subject (- n) unread))
6373 (defun gnus-summary-prev-unread-subject (n)
6374 "Go to previous N'th unread summary line."
6376 (gnus-summary-next-subject (- n) t))
6378 (defun gnus-summary-goto-subject (article &optional force silent)
6379 "Go the subject line of ARTICLE.
6380 If FORCE, also allow jumping to articles not currently shown."
6381 (interactive "nArticle number: ")
6383 (data (gnus-data-find article)))
6384 ;; We read in the article if we have to.
6387 (gnus-summary-insert-subject
6389 (if (or (numberp force) (vectorp force)) force)
6391 (setq data (gnus-data-find article)))
6396 (gnus-message 3 "Can't find article %d" article))
6398 (let ((pt (gnus-data-pos data)))
6400 (gnus-summary-set-article-display-arrow pt))
6401 (gnus-summary-position-point)
6404 ;; Walking around summary lines with displaying articles.
6406 (defun gnus-summary-expand-window (&optional arg)
6407 "Make the summary buffer take up the entire Emacs frame.
6408 Given a prefix, will force an `article' buffer configuration."
6411 (gnus-configure-windows 'article 'force)
6412 (gnus-configure-windows 'summary 'force)))
6414 (defun gnus-summary-display-article (article &optional all-header)
6415 "Display ARTICLE in article buffer."
6416 (when (gnus-buffer-live-p gnus-article-buffer)
6417 (with-current-buffer gnus-article-buffer
6418 (set-buffer-multibyte t)))
6419 (gnus-set-global-variables)
6420 (when (gnus-buffer-live-p gnus-article-buffer)
6421 (with-current-buffer gnus-article-buffer
6422 (setq gnus-article-charset gnus-newsgroup-charset)
6423 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6427 (if gnus-summary-display-article-function
6428 (funcall gnus-summary-display-article-function article all-header)
6429 (gnus-article-prepare article all-header))
6430 (with-current-buffer gnus-article-buffer
6431 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6433 (gnus-run-hooks 'gnus-select-article-hook)
6434 (when (and gnus-current-article
6435 (not (zerop gnus-current-article)))
6436 (gnus-summary-goto-subject gnus-current-article))
6437 (gnus-summary-recenter)
6438 (when (and gnus-use-trees gnus-show-threads)
6439 (gnus-possibly-generate-tree article)
6440 (gnus-highlight-selected-tree article))
6441 ;; Successfully display article.
6442 (gnus-article-set-window-start
6443 (cdr (assq article gnus-newsgroup-bookmarks))))))
6445 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6446 "Select the current article.
6447 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6448 non-nil, the article will be re-fetched even if it already present in
6449 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6451 ;; Make sure we are in the summary buffer to work around bbdb bug.
6452 (unless (eq major-mode 'gnus-summary-mode)
6453 (set-buffer gnus-summary-buffer))
6454 (let ((article (or article (gnus-summary-article-number)))
6455 (all-headers (not (not all-headers))) ;Must be T or NIL.
6456 gnus-summary-display-article-function)
6458 (gnus-summary-article-pseudo-p article)
6459 (error "This is a pseudo-article"))
6461 (set-buffer gnus-summary-buffer)
6462 (if (or (and gnus-single-article-buffer
6463 (or (null gnus-current-article)
6464 (null gnus-article-current)
6465 (null (get-buffer gnus-article-buffer))
6466 (not (eq article (cdr gnus-article-current)))
6467 (not (equal (car gnus-article-current)
6468 gnus-newsgroup-name))))
6469 (and (not gnus-single-article-buffer)
6470 (or (null gnus-current-article)
6471 (not (eq gnus-current-article article))))
6473 ;; The requested article is different from the current article.
6475 (gnus-summary-display-article article all-headers)
6476 (when (or all-headers gnus-show-all-headers)
6477 (gnus-article-show-all-headers))
6478 (gnus-article-set-window-start
6479 (cdr (assq article gnus-newsgroup-bookmarks)))
6481 (when (or all-headers gnus-show-all-headers)
6482 (gnus-article-show-all-headers))
6485 (defun gnus-summary-force-verify-and-decrypt ()
6487 (let ((mm-verify-option 'known)
6488 (mm-decrypt-option 'known))
6489 (gnus-summary-select-article nil 'force)))
6491 (defun gnus-summary-set-current-mark (&optional current-mark)
6492 "Obsolete function."
6495 (defun gnus-summary-next-article (&optional unread subject backward push)
6496 "Select the next article.
6497 If UNREAD, only unread articles are selected.
6498 If SUBJECT, only articles with SUBJECT are selected.
6499 If BACKWARD, the previous article is selected instead of the next."
6502 ;; Is there such an article?
6503 ((and (gnus-summary-search-forward unread subject backward)
6504 (or (gnus-summary-display-article (gnus-summary-article-number))
6505 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6506 (gnus-summary-position-point))
6507 ;; If not, we try the first unread, if that is wanted.
6509 gnus-auto-select-same
6510 (gnus-summary-first-unread-article))
6511 (gnus-summary-position-point)
6512 (gnus-message 6 "Wrapped"))
6513 ;; Try to get next/previous article not displayed in this group.
6514 ((and gnus-auto-extend-newsgroup
6515 (not unread) (not subject))
6516 (gnus-summary-goto-article
6517 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6518 nil (count-lines (point-min) (point))))
6519 ;; Go to next/previous group.
6521 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6522 (gnus-summary-jump-to-group gnus-newsgroup-name))
6523 (let ((cmd last-command-char)
6526 (set-buffer gnus-group-buffer)
6529 (if (eq gnus-keep-same-level 'best)
6530 (gnus-summary-best-group gnus-newsgroup-name)
6531 (gnus-summary-search-group backward gnus-keep-same-level))))
6532 ;; For some reason, the group window gets selected. We change
6534 (select-window (get-buffer-window (current-buffer)))
6535 ;; Select next unread newsgroup automagically.
6537 ((or (not gnus-auto-select-next)
6539 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6540 ((or (eq gnus-auto-select-next 'quietly)
6541 (and (eq gnus-auto-select-next 'slightly-quietly)
6543 (and (eq gnus-auto-select-next 'almost-quietly)
6544 (gnus-summary-last-article-p)))
6546 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6548 (gnus-message 7 "No more%s articles (%s)..."
6549 (if unread " unread" "")
6550 (if group (concat "selecting " group)
6552 (gnus-summary-next-group nil group backward)))
6554 (when (gnus-key-press-event-p last-input-event)
6555 (gnus-summary-walk-group-buffer
6556 gnus-newsgroup-name cmd unread backward point))))))))
6558 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6559 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6560 (?\C-p (gnus-group-prev-unread-group 1))))
6561 (cursor-in-echo-area t)
6562 keve key group ended)
6564 (set-buffer gnus-group-buffer)
6567 (if (eq gnus-keep-same-level 'best)
6568 (gnus-summary-best-group gnus-newsgroup-name)
6569 (gnus-summary-search-group backward gnus-keep-same-level))))
6572 5 "No more%s articles%s" (if unread " unread" "")
6574 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6575 (format " (Type %s for %s [%s])"
6576 (single-key-description cmd) group
6577 (car (gnus-gethash group gnus-newsrc-hashtb)))
6578 (format " (Type %s to exit %s)"
6579 (single-key-description cmd)
6580 gnus-newsgroup-name)))
6581 ;; Confirm auto selection.
6582 (setq key (car (setq keve (gnus-read-event-char))))
6585 ((assq key keystrokes)
6586 (let ((obuf (current-buffer)))
6587 (switch-to-buffer gnus-group-buffer)
6589 (gnus-group-jump-to-group group))
6590 (eval (cadr (assq key keystrokes)))
6591 (setq group (gnus-group-group-name))
6592 (switch-to-buffer obuf))
6596 (gnus-ephemeral-group-p gnus-newsgroup-name))
6598 (gnus-summary-next-group nil group backward)))
6600 (push (cdr keve) unread-command-events))))))
6602 (defun gnus-summary-next-unread-article ()
6603 "Select unread article after current one."
6605 (gnus-summary-next-article
6606 (or (not (eq gnus-summary-goto-unread 'never))
6607 (gnus-summary-last-article-p (gnus-summary-article-number)))
6608 (and gnus-auto-select-same
6609 (gnus-summary-article-subject))))
6611 (defun gnus-summary-prev-article (&optional unread subject)
6612 "Select the article after the current one.
6613 If UNREAD is non-nil, only unread articles are selected."
6615 (gnus-summary-next-article unread subject t))
6617 (defun gnus-summary-prev-unread-article ()
6618 "Select unread article before current one."
6620 (gnus-summary-prev-article
6621 (or (not (eq gnus-summary-goto-unread 'never))
6622 (gnus-summary-first-article-p (gnus-summary-article-number)))
6623 (and gnus-auto-select-same
6624 (gnus-summary-article-subject))))
6626 (defun gnus-summary-next-page (&optional lines circular)
6627 "Show next page of the selected article.
6628 If at the end of the current article, select the next article.
6629 LINES says how many lines should be scrolled up.
6631 If CIRCULAR is non-nil, go to the start of the article instead of
6632 selecting the next article when reaching the end of the current
6635 (setq gnus-summary-buffer (current-buffer))
6636 (gnus-set-global-variables)
6637 (let ((article (gnus-summary-article-number))
6638 (article-window (get-buffer-window gnus-article-buffer t))
6640 ;; If the buffer is empty, we have no article.
6642 (error "No article to select"))
6643 (gnus-configure-windows 'article)
6644 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6645 (if (and (eq gnus-summary-goto-unread 'never)
6646 (not (gnus-summary-last-article-p article)))
6647 (gnus-summary-next-article)
6648 (gnus-summary-next-unread-article))
6649 (if (or (null gnus-current-article)
6650 (null gnus-article-current)
6651 (/= article (cdr gnus-article-current))
6652 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6653 ;; Selected subject is different from current article's.
6654 (gnus-summary-display-article article)
6655 (when article-window
6656 (gnus-eval-in-buffer-window gnus-article-buffer
6657 (setq endp (gnus-article-next-page lines)))
6660 (gnus-summary-beginning-of-article))
6662 (gnus-message 3 "End of message"))
6664 (if (and (eq gnus-summary-goto-unread 'never)
6665 (not (gnus-summary-last-article-p article)))
6666 (gnus-summary-next-article)
6667 (gnus-summary-next-unread-article))))))))
6668 (gnus-summary-recenter)
6669 (gnus-summary-position-point)))
6671 (defun gnus-summary-prev-page (&optional lines move)
6672 "Show previous page of selected article.
6673 Argument LINES specifies lines to be scrolled down.
6674 If MOVE, move to the previous unread article if point is at
6675 the beginning of the buffer."
6677 (let ((article (gnus-summary-article-number))
6678 (article-window (get-buffer-window gnus-article-buffer t))
6680 (gnus-configure-windows 'article)
6681 (if (or (null gnus-current-article)
6682 (null gnus-article-current)
6683 (/= article (cdr gnus-article-current))
6684 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6685 ;; Selected subject is different from current article's.
6686 (gnus-summary-display-article article)
6687 (gnus-summary-recenter)
6688 (when article-window
6689 (gnus-eval-in-buffer-window gnus-article-buffer
6690 (setq endp (gnus-article-prev-page lines)))
6691 (when (and move endp)
6693 (gnus-message 3 "Beginning of message"))
6695 (if (and (eq gnus-summary-goto-unread 'never)
6696 (not (gnus-summary-first-article-p article)))
6697 (gnus-summary-prev-article)
6698 (gnus-summary-prev-unread-article))))))))
6699 (gnus-summary-position-point))
6701 (defun gnus-summary-prev-page-or-article (&optional lines)
6702 "Show previous page of selected article.
6703 Argument LINES specifies lines to be scrolled down.
6704 If at the beginning of the article, go to the next article."
6706 (gnus-summary-prev-page lines t))
6708 (defun gnus-summary-scroll-up (lines)
6709 "Scroll up (or down) one line current article.
6710 Argument LINES specifies lines to be scrolled up (or down if negative)."
6712 (gnus-configure-windows 'article)
6713 (gnus-summary-show-thread)
6714 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6715 (gnus-eval-in-buffer-window gnus-article-buffer
6717 (when (gnus-article-next-page lines)
6718 (gnus-message 3 "End of message")))
6720 (gnus-article-prev-page (- lines))))))
6721 (gnus-summary-recenter)
6722 (gnus-summary-position-point))
6724 (defun gnus-summary-scroll-down (lines)
6725 "Scroll down (or up) one line current article.
6726 Argument LINES specifies lines to be scrolled down (or up if negative)."
6728 (gnus-summary-scroll-up (- lines)))
6730 (defun gnus-summary-next-same-subject ()
6731 "Select next article which has the same subject as current one."
6733 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6735 (defun gnus-summary-prev-same-subject ()
6736 "Select previous article which has the same subject as current one."
6738 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6740 (defun gnus-summary-next-unread-same-subject ()
6741 "Select next unread article which has the same subject as current one."
6743 (gnus-summary-next-article t (gnus-summary-article-subject)))
6745 (defun gnus-summary-prev-unread-same-subject ()
6746 "Select previous unread article which has the same subject as current one."
6748 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6750 (defun gnus-summary-first-unread-article ()
6751 "Select the first unread article.
6752 Return nil if there are no unread articles."
6755 (when (gnus-summary-first-subject t)
6756 (gnus-summary-show-thread)
6757 (gnus-summary-first-subject t)
6758 (gnus-summary-display-article (gnus-summary-article-number)))
6759 (gnus-summary-position-point)))
6761 (defun gnus-summary-first-unread-subject ()
6762 "Place the point on the subject line of the first unread article.
6763 Return nil if there are no unread articles."
6766 (when (gnus-summary-first-subject t)
6767 (gnus-summary-show-thread)
6768 (gnus-summary-first-subject t))
6769 (gnus-summary-position-point)))
6771 (defun gnus-summary-first-article ()
6772 "Select the first article.
6773 Return nil if there are no articles."
6776 (when (gnus-summary-first-subject)
6777 (gnus-summary-show-thread)
6778 (gnus-summary-first-subject)
6779 (gnus-summary-display-article (gnus-summary-article-number)))
6780 (gnus-summary-position-point)))
6782 (defun gnus-summary-best-unread-article ()
6783 "Select the unread article with the highest score."
6785 (let ((best -1000000)
6786 (data gnus-newsgroup-data)
6789 (and (gnus-data-unread-p (car data))
6791 (gnus-summary-article-score (gnus-data-number (car data))))
6794 article (gnus-data-number (car data))))
6795 (setq data (cdr data)))
6798 (gnus-summary-goto-article article)
6799 (error "No unread articles"))
6800 (gnus-summary-position-point))))
6802 (defun gnus-summary-last-subject ()
6803 "Go to the last displayed subject line in the group."
6804 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6806 (gnus-summary-goto-subject article))))
6808 (defun gnus-summary-goto-article (article &optional all-headers force)
6809 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6810 If ALL-HEADERS is non-nil, no header lines are hidden.
6811 If FORCE, go to the article even if it isn't displayed. If FORCE
6812 is a number, it is the line the article is to be displayed on."
6816 "Article number or Message-ID: "
6817 (mapcar (lambda (number) (list (int-to-string number)))
6818 gnus-newsgroup-limit))
6822 (if (and (stringp article)
6823 (string-match "@" article))
6824 (gnus-summary-refer-article article)
6825 (when (stringp article)
6826 (setq article (string-to-number article)))
6827 (if (gnus-summary-goto-subject article force)
6828 (gnus-summary-display-article article all-headers)
6829 (gnus-message 4 "Couldn't go to article %s" article) nil))
6830 (gnus-summary-position-point)))
6832 (defun gnus-summary-goto-last-article ()
6833 "Go to the previously read article."
6836 (when gnus-last-article
6837 (gnus-summary-goto-article gnus-last-article nil t))
6838 (gnus-summary-position-point)))
6840 (defun gnus-summary-pop-article (number)
6841 "Pop one article off the history and go to the previous.
6842 NUMBER articles will be popped off."
6845 (setq gnus-newsgroup-history
6846 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6848 (gnus-summary-goto-article (car to) nil t)
6849 (error "Article history empty")))
6850 (gnus-summary-position-point))
6852 ;; Summary commands and functions for limiting the summary buffer.
6854 (defun gnus-summary-limit-to-articles (n)
6855 "Limit the summary buffer to the next N articles.
6856 If not given a prefix, use the process marked articles instead."
6859 (let ((articles (gnus-summary-work-articles n)))
6860 (setq gnus-newsgroup-processable nil)
6861 (gnus-summary-limit articles))
6862 (gnus-summary-position-point)))
6864 (defun gnus-summary-pop-limit (&optional total)
6865 "Restore the previous limit.
6866 If given a prefix, remove all limits."
6869 (setq gnus-newsgroup-limits
6870 (list (mapcar (lambda (h) (mail-header-number h))
6871 gnus-newsgroup-headers))))
6872 (unless gnus-newsgroup-limits
6873 (error "No limit to pop"))
6875 (gnus-summary-limit nil 'pop)
6876 (gnus-summary-position-point)))
6878 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6879 "Limit the summary buffer to articles that have subjects that match a regexp.
6880 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6882 (list (read-string (if current-prefix-arg
6883 "Exclude subject (regexp): "
6884 "Limit to subject (regexp): "))
6885 nil current-prefix-arg))
6887 (setq header "subject"))
6888 (when (not (equal "" subject))
6890 (let ((articles (gnus-summary-find-matching
6891 (or header "subject") subject 'all nil nil
6894 (error "Found no matches for \"%s\"" subject))
6895 (gnus-summary-limit articles))
6896 (gnus-summary-position-point))))
6898 (defun gnus-summary-limit-to-author (from &optional not-matching)
6899 "Limit the summary buffer to articles that have authors that match a regexp.
6900 If NOT-MATCHING, excluding articles that have authors that match a regexp."
6902 (list (read-string (if current-prefix-arg
6903 "Exclude author (regexp): "
6904 "Limit to author (regexp): "))
6905 current-prefix-arg))
6906 (gnus-summary-limit-to-subject from "from" not-matching))
6908 (defun gnus-summary-limit-to-age (age &optional younger-p)
6909 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6910 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6911 articles that are younger than AGE days."
6913 (let ((younger current-prefix-arg)
6916 (while (not days-got)
6917 (setq days (if younger
6918 (read-string "Limit to articles within (in days): ")
6919 (read-string "Limit to articles older than (in days): ")))
6920 (when (> (length days) 0)
6921 (setq days (read days)))
6924 (message "Please enter a number.")
6926 (list days younger)))
6928 (let ((data gnus-newsgroup-data)
6929 (cutoff (days-to-time age))
6930 articles d date is-younger)
6931 (while (setq d (pop data))
6932 (when (and (vectorp (gnus-data-header d))
6933 (setq date (mail-header-date (gnus-data-header d))))
6934 (setq is-younger (time-less-p
6935 (time-since (condition-case ()
6942 (push (gnus-data-number d) articles))))
6943 (gnus-summary-limit (nreverse articles)))
6944 (gnus-summary-position-point)))
6946 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
6947 "Limit the summary buffer to articles that match an 'extra' header."
6951 (gnus-completing-read
6952 (symbol-name (car gnus-extra-headers))
6953 (if current-prefix-arg
6954 "Exclude extra header:"
6955 "Limit extra header:")
6957 (cons (symbol-name x) x))
6962 (read-string (format "%s header %s (regexp): "
6963 (if current-prefix-arg "Exclude" "Limit to")
6965 current-prefix-arg)))
6966 (when (not (equal "" regexp))
6968 (let ((articles (gnus-summary-find-matching
6969 (cons 'extra header) regexp 'all nil nil
6972 (error "Found no matches for \"%s\"" regexp))
6973 (gnus-summary-limit articles))
6974 (gnus-summary-position-point))))
6976 (defun gnus-summary-limit-to-display-predicate ()
6977 "Limit the summary buffer to the predicated in the `display' group parameter."
6979 (unless gnus-newsgroup-display
6980 (error "There is no `display' group parameter"))
6982 (dolist (number gnus-newsgroup-articles)
6983 (when (funcall gnus-newsgroup-display)
6984 (push number articles)))
6985 (gnus-summary-limit articles))
6986 (gnus-summary-position-point))
6988 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6990 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6992 (defun gnus-summary-limit-to-unread (&optional all)
6993 "Limit the summary buffer to articles that are not marked as read.
6994 If ALL is non-nil, limit strictly to unread articles."
6997 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6998 (gnus-summary-limit-to-marks
6999 ;; Concat all the marks that say that an article is read and have
7001 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7002 gnus-killed-mark gnus-kill-file-mark
7003 gnus-low-score-mark gnus-expirable-mark
7004 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7005 gnus-duplicate-mark gnus-souped-mark)
7008 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7009 (make-obsolete 'gnus-summary-delete-marked-with
7010 'gnus-summary-limit-exlude-marks)
7012 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7013 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7014 If REVERSE, limit the summary buffer to articles that are marked
7015 with MARKS. MARKS can either be a string of marks or a list of marks.
7016 Returns how many articles were removed."
7017 (interactive "sMarks: ")
7018 (gnus-summary-limit-to-marks marks t))
7020 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7021 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7022 If REVERSE (the prefix), limit the summary buffer to articles that are
7023 not marked with MARKS. MARKS can either be a string of marks or a
7025 Returns how many articles were removed."
7026 (interactive "sMarks: \nP")
7028 (let ((data gnus-newsgroup-data)
7029 (marks (if (listp marks) marks
7030 (append marks nil))) ; Transform to list.
7033 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7034 (memq (gnus-data-mark (car data)) marks))
7035 (push (gnus-data-number (car data)) articles))
7036 (setq data (cdr data)))
7037 (gnus-summary-limit articles))
7038 (gnus-summary-position-point)))
7040 (defun gnus-summary-limit-to-score (score)
7041 "Limit to articles with score at or above SCORE."
7042 (interactive "NLimit to articles with score of at least: ")
7043 (let ((data gnus-newsgroup-data)
7046 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7048 (push (gnus-data-number (car data)) articles))
7049 (setq data (cdr data)))
7051 (gnus-summary-limit articles)
7052 (gnus-summary-position-point))))
7054 (defun gnus-summary-limit-include-thread (id)
7055 "Display all the hidden articles that is in the thread with ID in it.
7056 When called interactively, ID is the Message-ID of the current
7058 (interactive (list (mail-header-id (gnus-summary-article-header))))
7059 (let ((articles (gnus-articles-in-thread
7060 (gnus-id-to-thread (gnus-root-id id)))))
7062 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7063 (gnus-summary-limit-include-matching-articles
7065 (regexp-quote (gnus-simplify-subject-re
7066 (mail-header-subject (gnus-id-to-header id)))))
7067 (gnus-summary-position-point))))
7069 (defun gnus-summary-limit-include-matching-articles (header regexp)
7070 "Display all the hidden articles that have HEADERs that match REGEXP."
7071 (interactive (list (read-string "Match on header: ")
7072 (read-string "Regexp: ")))
7073 (let ((articles (gnus-find-matching-articles header regexp)))
7075 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7076 (gnus-summary-position-point))))
7078 (defun gnus-summary-limit-include-dormant ()
7079 "Display all the hidden articles that are marked as dormant.
7080 Note that this command only works on a subset of the articles currently
7081 fetched for this group."
7083 (unless gnus-newsgroup-dormant
7084 (error "There are no dormant articles in this group"))
7086 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7087 (gnus-summary-position-point)))
7089 (defun gnus-summary-limit-exclude-dormant ()
7090 "Hide all dormant articles."
7093 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7094 (gnus-summary-position-point)))
7096 (defun gnus-summary-limit-exclude-childless-dormant ()
7097 "Hide all dormant articles that have no children."
7099 (let ((data (gnus-data-list t))
7100 articles d children)
7101 ;; Find all articles that are either not dormant or have
7103 (while (setq d (pop data))
7104 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7106 (gnus-article-children (gnus-data-number d)))
7109 (when (memq (car children) articles)
7114 (push (gnus-data-number d) articles)))
7117 (gnus-summary-limit articles)
7118 (gnus-summary-position-point))))
7120 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7121 "Mark all unread excluded articles as read.
7122 If ALL, mark even excluded ticked and dormants as read."
7124 (let ((articles (gnus-sorted-complement
7126 (mapcar (lambda (h) (mail-header-number h))
7127 gnus-newsgroup-headers)
7129 (sort gnus-newsgroup-limit '<)))
7131 (setq gnus-newsgroup-unreads
7132 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7134 (setq gnus-newsgroup-dormant nil
7135 gnus-newsgroup-marked nil
7136 gnus-newsgroup-reads
7138 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7139 gnus-newsgroup-reads))
7140 (while (setq article (pop articles))
7141 (unless (or (memq article gnus-newsgroup-dormant)
7142 (memq article gnus-newsgroup-marked))
7143 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7145 (defun gnus-summary-limit (articles &optional pop)
7147 ;; We pop the previous limit off the stack and use that.
7148 (setq articles (car gnus-newsgroup-limits)
7149 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7150 ;; We use the new limit, so we push the old limit on the stack.
7151 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7153 (setq gnus-newsgroup-limit articles)
7154 (let ((total (length gnus-newsgroup-data))
7155 (data (gnus-data-find-list (gnus-summary-article-number)))
7156 (gnus-summary-mark-below nil) ; Inhibit this.
7158 ;; This will do all the work of generating the new summary buffer
7159 ;; according to the new limit.
7160 (gnus-summary-prepare)
7161 ;; Hide any threads, possibly.
7162 (and gnus-show-threads
7163 gnus-thread-hide-subtree
7164 (gnus-summary-hide-all-threads))
7165 ;; Try to return to the article you were at, or one in the
7168 ;; We try to find some article after the current one.
7170 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7173 (setq data (cdr data))))
7175 ;; If there is no data, that means that we were after the last
7176 ;; article. The same goes when we can't find any articles
7177 ;; after the current one.
7178 (goto-char (point-max))
7179 (gnus-summary-find-prev))
7180 (gnus-set-mode-line 'summary)
7181 ;; We return how many articles were removed from the summary
7182 ;; buffer as a result of the new limit.
7183 (- total (length gnus-newsgroup-data))))
7185 (defsubst gnus-invisible-cut-children (threads)
7188 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7193 (defsubst gnus-cut-thread (thread)
7194 "Go forwards in the thread until we find an article that we want to display."
7195 (when (or (eq gnus-fetch-old-headers 'some)
7196 (eq gnus-fetch-old-headers 'invisible)
7197 (numberp gnus-fetch-old-headers)
7198 (eq gnus-build-sparse-threads 'some)
7199 (eq gnus-build-sparse-threads 'more))
7200 ;; Deal with old-fetched headers and sparse threads.
7204 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7205 (gnus-summary-article-ancient-p
7206 (mail-header-number (car thread))))
7207 (if (or (<= (length (cdr thread)) 1)
7208 (eq gnus-fetch-old-headers 'invisible))
7209 (setq gnus-newsgroup-limit
7210 (delq (mail-header-number (car thread))
7211 gnus-newsgroup-limit)
7212 thread (cadr thread))
7213 (when (gnus-invisible-cut-children (cdr thread))
7214 (let ((th (cdr thread)))
7216 (if (memq (mail-header-number (caar th))
7217 gnus-newsgroup-limit)
7218 (setq thread (car th)
7220 (setq th (cdr th))))))))))
7223 (defun gnus-cut-threads (threads)
7224 "Cut off all uninteresting articles from the beginning of threads."
7225 (when (or (eq gnus-fetch-old-headers 'some)
7226 (eq gnus-fetch-old-headers 'invisible)
7227 (numberp gnus-fetch-old-headers)
7228 (eq gnus-build-sparse-threads 'some)
7229 (eq gnus-build-sparse-threads 'more))
7232 (setcar th (gnus-cut-thread (car th)))
7233 (setq th (cdr th)))))
7234 ;; Remove nixed out threads.
7237 (defun gnus-summary-initial-limit (&optional show-if-empty)
7238 "Figure out what the initial limit is supposed to be on group entry.
7239 This entails weeding out unwanted dormants, low-scored articles,
7240 fetch-old-headers verbiage, and so on."
7241 ;; Most groups have nothing to remove.
7242 (if (or gnus-inhibit-limiting
7243 (and (null gnus-newsgroup-dormant)
7244 (eq gnus-newsgroup-display 'gnus-not-ignore)
7245 (not (eq gnus-fetch-old-headers 'some))
7246 (not (numberp gnus-fetch-old-headers))
7247 (not (eq gnus-fetch-old-headers 'invisible))
7248 (null gnus-summary-expunge-below)
7249 (not (eq gnus-build-sparse-threads 'some))
7250 (not (eq gnus-build-sparse-threads 'more))
7251 (null gnus-thread-expunge-below)
7252 (not gnus-use-nocem)))
7254 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7255 (setq gnus-newsgroup-limit nil)
7258 (unless (car (symbol-value node))
7259 ;; These threads have no parents -- they are roots.
7260 (let ((nodes (cdr (symbol-value node)))
7263 (if (and gnus-thread-expunge-below
7264 (< (gnus-thread-total-score (car nodes))
7265 gnus-thread-expunge-below))
7266 (gnus-expunge-thread (pop nodes))
7267 (setq thread (pop nodes))
7268 (gnus-summary-limit-children thread))))))
7269 gnus-newsgroup-dependencies)
7270 ;; If this limitation resulted in an empty group, we might
7271 ;; pop the previous limit and use it instead.
7272 (when (and (not gnus-newsgroup-limit)
7274 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7275 gnus-newsgroup-limit))
7277 (defun gnus-summary-limit-children (thread)
7278 "Return 1 if this subthread is visible and 0 if it is not."
7279 ;; First we get the number of visible children to this thread. This
7280 ;; is done by recursing down the thread using this function, so this
7281 ;; will really go down to a leaf article first, before slowly
7282 ;; working its way up towards the root.
7286 (apply '+ (mapcar 'gnus-summary-limit-children
7289 (number (mail-header-number (car thread)))
7292 (not (memq number gnus-newsgroup-marked))
7294 ;; If this article is dormant and has absolutely no visible
7295 ;; children, then this article isn't visible.
7296 (and (memq number gnus-newsgroup-dormant)
7298 ;; If this is "fetch-old-headered" and there is no
7299 ;; visible children, then we don't want this article.
7300 (and (or (eq gnus-fetch-old-headers 'some)
7301 (numberp gnus-fetch-old-headers))
7302 (gnus-summary-article-ancient-p number)
7304 ;; If this is "fetch-old-headered" and `invisible', then
7305 ;; we don't want this article.
7306 (and (eq gnus-fetch-old-headers 'invisible)
7307 (gnus-summary-article-ancient-p number))
7308 ;; If this is a sparsely inserted article with no children,
7309 ;; we don't want it.
7310 (and (eq gnus-build-sparse-threads 'some)
7311 (gnus-summary-article-sparse-p number)
7313 ;; If we use expunging, and this article is really
7314 ;; low-scored, then we don't want this article.
7315 (when (and gnus-summary-expunge-below
7317 (or (cdr (assq number gnus-newsgroup-scored))
7318 gnus-summary-default-score))
7319 gnus-summary-expunge-below))
7320 ;; We increase the expunge-tally here, but that has
7321 ;; nothing to do with the limits, really.
7322 (incf gnus-newsgroup-expunged-tally)
7323 ;; We also mark as read here, if that's wanted.
7324 (when (and gnus-summary-mark-below
7325 (< score gnus-summary-mark-below))
7326 (setq gnus-newsgroup-unreads
7327 (delq number gnus-newsgroup-unreads))
7328 (if gnus-newsgroup-auto-expire
7329 (push number gnus-newsgroup-expirable)
7330 (push (cons number gnus-low-score-mark)
7331 gnus-newsgroup-reads)))
7333 ;; Do the `display' group parameter.
7334 (and gnus-newsgroup-display
7335 (not (funcall gnus-newsgroup-display)))
7336 ;; Check NoCeM things.
7337 (if (and gnus-use-nocem
7338 (gnus-nocem-unwanted-article-p
7339 (mail-header-id (car thread))))
7341 (setq gnus-newsgroup-unreads
7342 (delq number gnus-newsgroup-unreads))
7344 ;; Nope, invisible article.
7346 ;; Ok, this article is to be visible, so we add it to the limit
7348 (push number gnus-newsgroup-limit)
7351 (defun gnus-expunge-thread (thread)
7352 "Mark all articles in THREAD as read."
7353 (let* ((number (mail-header-number (car thread))))
7354 (incf gnus-newsgroup-expunged-tally)
7355 ;; We also mark as read here, if that's wanted.
7356 (setq gnus-newsgroup-unreads
7357 (delq number gnus-newsgroup-unreads))
7358 (if gnus-newsgroup-auto-expire
7359 (push number gnus-newsgroup-expirable)
7360 (push (cons number gnus-low-score-mark)
7361 gnus-newsgroup-reads)))
7362 ;; Go recursively through all subthreads.
7363 (mapcar 'gnus-expunge-thread (cdr thread)))
7365 ;; Summary article oriented commands
7367 (defun gnus-summary-refer-parent-article (n)
7368 "Refer parent article N times.
7369 If N is negative, go to ancestor -N instead.
7370 The difference between N and the number of articles fetched is returned."
7374 (when (not (natnump n))
7379 (setq header (gnus-summary-article-header))
7380 (if (and (eq (mail-header-number header)
7381 (cdr gnus-article-current))
7382 (equal gnus-newsgroup-name
7383 (car gnus-article-current)))
7384 ;; If we try to find the parent of the currently
7385 ;; displayed article, then we take a look at the actual
7386 ;; References header, since this is slightly more
7387 ;; reliable than the References field we got from the
7390 (set-buffer gnus-original-article-buffer)
7391 (nnheader-narrow-to-headers)
7392 (unless (setq ref (message-fetch-field "references"))
7393 (setq ref (message-fetch-field "in-reply-to")))
7396 ;; It's not the current article, so we take a bet on
7397 ;; the value we got from the server.
7398 (mail-header-references header)))
7400 (not (equal ref "")))
7401 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7402 (gnus-message 1 "Couldn't find parent"))
7403 (gnus-message 1 "No references in article %d"
7404 (gnus-summary-article-number))
7407 (gnus-summary-position-point)
7410 (defun gnus-summary-refer-references ()
7411 "Fetch all articles mentioned in the References header.
7412 Return the number of articles fetched."
7414 (let ((ref (mail-header-references (gnus-summary-article-header)))
7415 (current (gnus-summary-article-number))
7419 (error "No References in the current article")
7420 ;; For each Message-ID in the References header...
7421 (while (string-match "<[^>]*>" ref)
7423 ;; ... fetch that article.
7424 (gnus-summary-refer-article
7425 (prog1 (match-string 0 ref)
7426 (setq ref (substring ref (match-end 0))))))
7427 (gnus-summary-goto-subject current)
7428 (gnus-summary-position-point)
7431 (defun gnus-summary-refer-thread (&optional limit)
7432 "Fetch all articles in the current thread.
7433 If LIMIT (the numerical prefix), fetch that many old headers instead
7434 of what's specified by the `gnus-refer-thread-limit' variable."
7436 (let ((id (mail-header-id (gnus-summary-article-header)))
7437 (limit (if limit (prefix-numeric-value limit)
7438 gnus-refer-thread-limit)))
7439 ;; We want to fetch LIMIT *old* headers, but we also have to
7440 ;; re-fetch all the headers in the current buffer, because many of
7441 ;; them may be undisplayed. So we adjust LIMIT.
7442 (when (numberp limit)
7443 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7444 (unless (eq gnus-fetch-old-headers 'invisible)
7445 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7446 ;; Retrieve the headers and read them in.
7447 (if (eq (gnus-retrieve-headers
7448 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7450 (gnus-build-all-threads)
7451 (error "Can't fetch thread from backends that don't support NOV"))
7452 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7453 (gnus-summary-limit-include-thread id)))
7455 (defun gnus-summary-refer-article (message-id)
7456 "Fetch an article specified by MESSAGE-ID."
7457 (interactive "sMessage-ID: ")
7458 (when (and (stringp message-id)
7459 (not (zerop (length message-id))))
7460 ;; Construct the correct Message-ID if necessary.
7461 ;; Suggested by tale@pawl.rpi.edu.
7462 (unless (string-match "^<" message-id)
7463 (setq message-id (concat "<" message-id)))
7464 (unless (string-match ">$" message-id)
7465 (setq message-id (concat message-id ">")))
7466 (let* ((header (gnus-id-to-header message-id))
7468 (gnus-summary-article-sparse-p
7469 (mail-header-number header))
7470 (memq (mail-header-number header)
7471 gnus-newsgroup-limit)))
7474 ;; If the article is present in the buffer we just go to it.
7476 (or (not (gnus-summary-article-sparse-p
7477 (mail-header-number header)))
7480 (gnus-summary-goto-article
7481 (mail-header-number header) nil t)
7483 (gnus-summary-update-article (mail-header-number header)))))
7485 ;; We fetch the article.
7487 (dolist (gnus-override-method (gnus-refer-article-methods))
7488 (gnus-check-server gnus-override-method)
7489 ;; Fetch the header, and display the article.
7490 (when (setq number (gnus-summary-insert-subject message-id))
7491 (gnus-summary-select-article nil nil nil number)
7493 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7495 (defun gnus-refer-article-methods ()
7496 "Return a list of referrable methods."
7498 ;; No method, so we default to current and native.
7499 ((null gnus-refer-article-method)
7500 (list gnus-current-select-method gnus-select-method))
7502 ((eq 'current gnus-refer-article-method)
7503 (list gnus-current-select-method))
7504 ;; List of select methods.
7505 ((not (and (symbolp (car gnus-refer-article-method))
7506 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7508 (dolist (method gnus-refer-article-method)
7509 (push (if (eq 'current method)
7510 gnus-current-select-method
7514 ;; One single select method.
7516 (list gnus-refer-article-method))))
7518 (defun gnus-summary-edit-parameters ()
7519 "Edit the group parameters of the current group."
7521 (gnus-group-edit-group gnus-newsgroup-name 'params))
7523 (defun gnus-summary-customize-parameters ()
7524 "Customize the group parameters of the current group."
7526 (gnus-group-customize gnus-newsgroup-name))
7528 (defun gnus-summary-enter-digest-group (&optional force)
7529 "Enter an nndoc group based on the current article.
7530 If FORCE, force a digest interpretation. If not, try
7531 to guess what the document format is."
7533 (let ((conf gnus-current-window-configuration))
7535 (gnus-summary-select-article))
7536 (setq gnus-current-window-configuration conf)
7537 (let* ((name (format "%s-%d"
7538 (gnus-group-prefixed-name
7539 gnus-newsgroup-name (list 'nndoc ""))
7541 (set-buffer gnus-summary-buffer)
7542 gnus-current-article)))
7543 (ogroup gnus-newsgroup-name)
7544 (params (append (gnus-info-params (gnus-get-info ogroup))
7545 (list (cons 'to-group ogroup))
7546 (list (cons 'save-article-group ogroup))))
7547 (case-fold-search t)
7548 (buf (current-buffer))
7551 (set-buffer gnus-original-article-buffer)
7552 ;; Have the digest group inherit the main mail address of
7553 ;; the parent article.
7554 (when (setq to-address (or (message-fetch-field "reply-to")
7555 (message-fetch-field "from")))
7556 (setq params (append
7557 (list (cons 'to-address
7558 (funcall gnus-decode-encoded-word-function
7560 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7561 (insert-buffer-substring gnus-original-article-buffer)
7562 ;; Remove lines that may lead nndoc to misinterpret the
7565 (goto-char (point-min))
7566 (or (search-forward "\n\n" nil t) (point)))
7567 (goto-char (point-min))
7568 (delete-matching-lines "^Path:\\|^From ")
7571 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7572 (gnus-newsgroup-ephemeral-ignored-charsets
7573 gnus-newsgroup-ignored-charsets))
7574 (gnus-group-read-ephemeral-group
7575 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7577 ,(if force 'mbox 'guess))) t))
7578 ;; Make all postings to this group go to the parent group.
7579 (nconc (gnus-info-params (gnus-get-info name))
7581 ;; Couldn't select this doc group.
7582 (switch-to-buffer buf)
7583 (gnus-set-global-variables)
7584 (gnus-configure-windows 'summary)
7585 (gnus-message 3 "Article couldn't be entered?"))
7586 (kill-buffer dig)))))
7588 (defun gnus-summary-read-document (n)
7589 "Open a new group based on the current article(s).
7590 This will allow you to read digests and other similar
7591 documents as newsgroups.
7592 Obeys the standard process/prefix convention."
7594 (let* ((articles (gnus-summary-work-articles n))
7595 (ogroup gnus-newsgroup-name)
7596 (params (append (gnus-info-params (gnus-get-info ogroup))
7597 (list (cons 'to-group ogroup))))
7598 article group egroup groups vgroup)
7599 (while (setq article (pop articles))
7600 (setq group (format "%s-%d" gnus-newsgroup-name article))
7601 (gnus-summary-remove-process-mark article)
7602 (when (gnus-summary-display-article article)
7605 (insert-buffer-substring gnus-original-article-buffer)
7606 ;; Remove some headers that may lead nndoc to make
7608 (message-narrow-to-head)
7609 (goto-char (point-min))
7610 (delete-matching-lines "^\\(Path\\):\\|^From ")
7613 (gnus-group-read-ephemeral-group
7614 group `(nndoc ,group (nndoc-address ,(current-buffer))
7615 (nndoc-article-type guess))
7618 ;; Make all postings to this group go to the parent group.
7619 (nconc (gnus-info-params (gnus-get-info egroup))
7621 (push egroup groups))
7622 ;; Couldn't select this doc group.
7623 (gnus-error 3 "Article couldn't be entered"))))))
7624 ;; Now we have selected all the documents.
7627 (error "None of the articles could be interpreted as documents"))
7628 ((gnus-group-read-ephemeral-group
7629 (setq vgroup (format
7630 "nnvirtual:%s-%s" gnus-newsgroup-name
7631 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7632 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7634 (cons (current-buffer) 'summary)))
7636 (error "Couldn't select virtual nndoc group")))))
7638 (defun gnus-summary-isearch-article (&optional regexp-p)
7639 "Do incremental search forward on the current article.
7640 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7642 (let* ((gnus-inhibit-treatment t)
7643 (old (gnus-summary-select-article)))
7644 (gnus-configure-windows 'article)
7645 (gnus-eval-in-buffer-window gnus-article-buffer
7649 (gnus-article-show-all-headers))
7650 (goto-char (point-min))
7651 (isearch-forward regexp-p)))))
7653 (defun gnus-summary-search-article-forward (regexp &optional backward)
7654 "Search for an article containing REGEXP forward.
7655 If BACKWARD, search backward instead."
7658 (format "Search article %s (regexp%s): "
7659 (if current-prefix-arg "backward" "forward")
7660 (if gnus-last-search-regexp
7661 (concat ", default " gnus-last-search-regexp)
7663 current-prefix-arg))
7664 (if (string-equal regexp "")
7665 (setq regexp (or gnus-last-search-regexp ""))
7666 (setq gnus-last-search-regexp regexp)
7667 (setq gnus-article-before-search gnus-current-article))
7668 ;; Intentionally set gnus-last-article.
7669 (setq gnus-last-article gnus-article-before-search)
7670 (let ((gnus-last-article gnus-last-article))
7671 (if (gnus-summary-search-article regexp backward)
7672 (gnus-summary-show-thread)
7673 (error "Search failed: \"%s\"" regexp))))
7675 (defun gnus-summary-search-article-backward (regexp)
7676 "Search for an article containing REGEXP backward."
7679 (format "Search article backward (regexp%s): "
7680 (if gnus-last-search-regexp
7681 (concat ", default " gnus-last-search-regexp)
7683 (gnus-summary-search-article-forward regexp 'backward))
7686 (defmacro gnus-summary-search-article-position-point (regexp backward)
7687 "Dehighlight the last matched text and goto the beginning position."
7688 (` (if (and gnus-summary-search-article-matched-data
7689 (let ((text (caddr gnus-summary-search-article-matched-data))
7690 (inhibit-read-only t)
7693 (goto-char (car gnus-summary-search-article-matched-data))
7694 (cadr gnus-summary-search-article-matched-data))
7696 (string-match (, regexp) text)))
7697 (if (, backward) (beginning-of-line) (end-of-line))
7698 (goto-char (if (, backward) (point-max) (point-min))))))
7700 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7701 "Place point where X-Face image is displayed."
7702 (if (featurep 'xemacs)
7703 (` (let ((end (if (search-forward "\n\n" nil t)
7704 (goto-char (1- (point)))
7707 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7708 (unless (and (re-search-forward "^From:" end t)
7709 (setq extent (extent-at (point)))
7710 (extent-begin-glyph extent))
7711 (goto-char (, opoint)))))
7712 (` (let ((end (if (search-forward "\n\n" nil t)
7713 (goto-char (1- (point)))
7715 (start (or (search-backward "\n\n" nil t) (point-min))))
7717 (or (text-property-any start end 'x-face-image t);; x-face-e21
7718 (text-property-any start end 'x-face-mule-bitmap-image t)
7721 (defmacro gnus-summary-search-article-highlight-matched-text
7722 (backward treated x-face)
7723 "Highlight matched text in the function `gnus-summary-search-article'."
7724 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7725 (end (set-marker (make-marker) (match-end 0)))
7726 (inhibit-read-only t)
7730 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7732 (lambda (item) (setq items (delq item items)))
7733 '(gnus-treat-buttonize
7734 gnus-treat-fill-article
7735 gnus-treat-fill-long-lines
7736 gnus-treat-emphasize
7737 gnus-treat-highlight-headers
7738 gnus-treat-highlight-citation
7739 gnus-treat-highlight-signature
7740 gnus-treat-overstrike
7741 gnus-treat-display-xface
7742 gnus-treat-buttonize-head
7743 gnus-treat-decode-article-as-default-mime-charset))
7744 (static-if (featurep 'xemacs)
7746 (cons '(x-face-mule-delete-x-face-field
7749 (gnus-treat-display-xface
7750 (when (, x-face) gnus-treat-display-xface)))
7751 (gnus-article-prepare-mime-display)))
7752 (goto-char (if (, backward) start end))
7754 (gnus-summary-search-article-highlight-goto-x-face (point)))
7755 (setq gnus-summary-search-article-matched-data
7756 (list start end (buffer-substring start end)))
7757 (unless (eq start end);; matched text has been deleted. :-<
7758 (put-text-property start end 'face
7759 (or (find-face 'isearch)
7760 'secondary-selection))))))
7763 (defun gnus-summary-search-article (regexp &optional backward)
7764 "Search for an article containing REGEXP.
7765 Optional argument BACKWARD means do search for backward.
7766 `gnus-select-article-hook' is not called during the search."
7767 ;; We have to require this here to make sure that the following
7768 ;; dynamic binding isn't shadowed by autoloading.
7769 (require 'gnus-async)
7771 (let ((gnus-select-article-hook nil) ;Disable hook.
7772 (gnus-article-prepare-hook nil)
7773 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7774 (gnus-use-article-prefetch nil)
7775 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7776 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7777 (sum (current-buffer))
7780 (gnus-save-hidden-threads
7781 (static-if (featurep 'xemacs)
7782 (let ((gnus-inhibit-treatment t))
7783 (setq treated (eq 'old (gnus-summary-select-article)))
7785 (not (and (gnus-buffer-live-p gnus-article-buffer)
7786 (window-live-p (get-buffer-window
7787 gnus-article-buffer t)))))
7788 (gnus-summary-select-article nil t)
7789 (setq treated nil)))
7790 (let ((gnus-inhibit-treatment t)
7791 (x-face-mule-delete-x-face-field 'never))
7792 (setq treated (eq 'old (gnus-summary-select-article)))
7795 (and (gnus-buffer-live-p gnus-article-buffer)
7796 (window-live-p (get-buffer-window
7797 gnus-article-buffer t))
7798 (or (not (string-match "^\\^X-Face:" regexp))
7799 (with-current-buffer gnus-article-buffer
7800 gnus-summary-search-article-matched-data)))))
7801 (gnus-summary-select-article nil t)
7802 (setq treated nil))))
7803 (set-buffer gnus-article-buffer)
7807 (gnus-article-show-all-headers)
7808 (gnus-summary-search-article-position-point regexp backward))
7809 (goto-char (if backward (point-max) (point-min))))
7811 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7813 (re-search-backward regexp nil t)
7814 (re-search-forward regexp nil t))
7815 ;; We found the regexp.
7817 (gnus-summary-search-article-highlight-matched-text
7818 backward treated (string-match "^\\^X-Face:" regexp))
7821 (/ (- 2 (window-height
7822 (get-buffer-window gnus-article-buffer t)))
7825 (get-buffer-window (current-buffer))
7828 (setq point (point)))
7829 ;; We didn't find it, so we go to the next article.
7832 (while (eq found 'not)
7833 (if (not (if backward (gnus-summary-find-prev)
7834 (gnus-summary-find-next)))
7835 ;; No more articles.
7837 ;; Select the next article and adjust point.
7838 (unless (gnus-summary-article-sparse-p
7839 (gnus-summary-article-number))
7841 (let ((gnus-inhibit-treatment t))
7842 (gnus-summary-select-article))
7844 (set-buffer gnus-article-buffer)
7846 (goto-char (if backward (point-max) (point-min))))))))
7847 (gnus-message 7 ""))
7848 ;; Return whether we found the regexp.
7849 (when (eq found 'found)
7851 (gnus-summary-show-thread)
7852 (gnus-summary-goto-subject gnus-current-article)
7853 (gnus-summary-position-point)
7856 (defun gnus-find-matching-articles (header regexp)
7857 "Return a list of all articles that match REGEXP on HEADER.
7858 This search includes all articles in the current group that Gnus has
7859 fetched headers for, whether they are displayed or not."
7860 (let ((articles nil)
7861 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7862 (case-fold-search t))
7863 (dolist (header gnus-newsgroup-headers)
7864 (when (string-match regexp (funcall func header))
7865 (push (mail-header-number header) articles)))
7866 (nreverse articles)))
7868 (defun gnus-summary-find-matching (header regexp &optional backward unread
7869 not-case-fold not-matching)
7870 "Return a list of all articles that match REGEXP on HEADER.
7871 The search stars on the current article and goes forwards unless
7872 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7873 If UNREAD is non-nil, only unread articles will
7874 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7875 in the comparisons. If NOT-MATCHING, return a list of all articles that
7876 not match REGEXP on HEADER."
7877 (let ((case-fold-search (not not-case-fold))
7880 (if (eq (car header) 'extra)
7883 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7885 (error "%s is an invalid header" header))
7886 (unless (fboundp (intern (concat "mail-header-" header)))
7887 (error "%s is not a valid header" header))
7888 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7889 (dolist (d (if (eq backward 'all)
7891 (gnus-data-find-list
7892 (gnus-summary-article-number)
7893 (gnus-data-list backward))))
7894 (when (and (or (not unread) ; We want all articles...
7895 (gnus-data-unread-p d)) ; Or just unreads.
7896 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7900 (funcall func (gnus-data-header d))))
7901 (string-match regexp
7902 (funcall func (gnus-data-header d)))))
7903 (push (gnus-data-number d) articles))) ; Success!
7904 (nreverse articles)))
7906 (defun gnus-summary-execute-command (header regexp command &optional backward)
7907 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7908 If HEADER is an empty string (or nil), the match is done on the entire
7909 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7911 (list (let ((completion-ignore-case t))
7914 (mapcar (lambda (header) (list (format "%s" header)))
7916 '("Number" "Subject" "From" "Lines" "Date"
7917 "Message-ID" "Xref" "References" "Body")
7918 gnus-extra-headers))
7919 nil 'require-match))
7920 (read-string "Regexp: ")
7921 (read-key-sequence "Command: ")
7922 current-prefix-arg))
7923 (when (equal header "Body")
7925 ;; Hidden thread subtrees must be searched as well.
7926 (gnus-summary-show-all-threads)
7927 ;; We don't want to change current point nor window configuration.
7929 (save-window-excursion
7930 (gnus-message 6 "Executing %s..." (key-description command))
7931 ;; We'd like to execute COMMAND interactively so as to give arguments.
7932 (gnus-execute header regexp
7933 `(call-interactively ',(key-binding command))
7935 (gnus-message 6 "Executing %s...done" (key-description command)))))
7937 (defun gnus-summary-beginning-of-article ()
7938 "Scroll the article back to the beginning."
7940 (gnus-summary-select-article)
7941 (gnus-configure-windows 'article)
7942 (gnus-eval-in-buffer-window gnus-article-buffer
7944 (goto-char (point-min))
7945 (when gnus-page-broken
7946 (gnus-narrow-to-page))))
7948 (defun gnus-summary-end-of-article ()
7949 "Scroll to the end of the article."
7951 (gnus-summary-select-article)
7952 (gnus-configure-windows 'article)
7953 (gnus-eval-in-buffer-window gnus-article-buffer
7955 (goto-char (point-max))
7957 (when gnus-page-broken
7958 (gnus-narrow-to-page))))
7960 (defun gnus-summary-print-truncate-and-quote (string &optional len)
7961 "Truncate to LEN and quote all \"(\"'s in STRING."
7962 (gnus-replace-in-string (if (and len (> (length string) len))
7963 (substring string 0 len)
7967 (defun gnus-summary-print-article (&optional filename n)
7968 "Generate and print a PostScript image of the N next (mail) articles.
7970 If N is negative, print the N previous articles. If N is nil and articles
7971 have been marked with the process mark, print these instead.
7973 If the optional first argument FILENAME is nil, send the image to the
7974 printer. If FILENAME is a string, save the PostScript image in a file with
7975 that name. If FILENAME is a number, prompt the user for the name of the file
7977 (interactive (list (ps-print-preprint current-prefix-arg)))
7978 (dolist (article (gnus-summary-work-articles n))
7979 (gnus-summary-select-article nil nil 'pseudo article)
7980 (gnus-eval-in-buffer-window gnus-article-buffer
7981 (let ((buffer (generate-new-buffer " *print*")))
7984 (copy-to-buffer buffer (point-min) (point-max))
7986 (gnus-article-delete-invisible-text)
7987 (when (gnus-visual-p 'article-highlight 'highlight)
7988 ;; Copy-to-buffer doesn't copy overlay. So redo
7990 (let ((gnus-article-buffer buffer))
7991 (gnus-article-highlight-citation t)
7992 (gnus-article-highlight-signature)))
7993 (let ((ps-left-header
7996 (gnus-summary-print-truncate-and-quote
7997 (mail-header-subject gnus-current-headers)
8000 (gnus-summary-print-truncate-and-quote
8001 (mail-header-from gnus-current-headers)
8005 "/pagenumberstring load"
8007 (mail-header-date gnus-current-headers) ")"))))
8008 (gnus-run-hooks 'gnus-ps-print-hook)
8011 (ps-spool-buffer-with-faces)
8012 (ps-spool-buffer)))))
8013 (kill-buffer buffer))))
8014 (gnus-summary-remove-process-mark article))
8015 (ps-despool filename))
8017 (defun gnus-summary-show-article (&optional arg)
8018 "Force redisplaying of the current article.
8019 If ARG (the prefix) is a number, show the article with the charset
8020 defined in `gnus-summary-show-article-charset-alist', or the charset
8022 If ARG (the prefix) is non-nil and not a number, show the raw article
8023 without any article massaging functions being run. Normally, the key strokes
8028 (gnus-summary-show-article t)
8029 (let ((gnus-newsgroup-charset
8030 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8031 (mm-read-coding-system
8034 (set-buffer gnus-article-buffer)
8035 (let ((coding-systems
8036 (detect-coding-region (point) (point-max))))
8037 (or (car-safe coding-systems)
8038 coding-systems))))))
8039 (gnus-newsgroup-ignored-charsets 'gnus-all))
8040 (gnus-summary-select-article nil 'force)
8041 (let ((deps gnus-newsgroup-dependencies)
8044 (set-buffer gnus-original-article-buffer)
8046 (message-narrow-to-head)
8047 (setq head (buffer-string))
8048 (goto-char (point-min))
8049 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8050 (goto-char (point-max))
8052 (setq lines (1- (count-lines (point) (point-max))))))
8054 (insert (format "211 %d Article retrieved.\n"
8055 (cdr gnus-article-current)))
8057 (if lines (insert (format "Lines: %d\n" lines)))
8059 (let ((nntp-server-buffer (current-buffer)))
8060 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8061 (gnus-data-set-header
8062 (gnus-data-find (cdr gnus-article-current))
8064 (gnus-summary-update-article-line
8065 (cdr gnus-article-current) header)
8066 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8067 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8069 ;; Select the article the normal way.
8070 (gnus-summary-select-article nil 'force))
8072 ;; We have to require this here to make sure that the following
8073 ;; dynamic binding isn't shadowed by autoloading.
8074 (require 'gnus-async)
8076 ;; Bind the article treatment functions to nil.
8077 (let ((gnus-have-all-headers t)
8078 gnus-article-prepare-hook
8079 gnus-article-decode-hook
8082 (gnus-inhibit-treatment t))
8083 (gnus-summary-select-article nil 'force))))
8084 (gnus-summary-goto-subject gnus-current-article)
8085 (gnus-summary-position-point))
8087 (defun gnus-summary-show-raw-article ()
8088 "Show the raw article without any article massaging functions being run."
8090 (gnus-summary-show-article t))
8092 (defun gnus-summary-verbose-headers (&optional arg)
8093 "Toggle permanent full header display.
8094 If ARG is a positive number, turn header display on.
8095 If ARG is a negative number, turn header display off."
8097 (setq gnus-show-all-headers
8098 (cond ((or (not (numberp arg))
8100 (not gnus-show-all-headers))
8103 (gnus-summary-show-article))
8105 (defun gnus-summary-toggle-header (&optional arg)
8106 "Show the headers if they are hidden, or hide them if they are shown.
8107 If ARG is a positive number, show the entire header.
8108 If ARG is a negative number, hide the unwanted header lines."
8111 (set-buffer gnus-article-buffer)
8113 (let* ((buffer-read-only nil)
8114 (inhibit-point-motion-hooks t)
8120 (article-narrow-to-head)
8121 (gnus-article-hidden-text-p 'headers))))
8122 (goto-char (point-min))
8123 (when (search-forward "\n\n" nil t)
8124 (delete-region (point-min) (1- (point))))
8125 (goto-char (point-min))
8127 (set-buffer gnus-original-article-buffer)
8128 (goto-char (point-min))
8129 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8130 (insert-buffer-substring gnus-original-article-buffer 1 e)
8132 (narrow-to-region (point-min) (point))
8133 (article-decode-encoded-words)
8135 (let ((gnus-treat-hide-headers nil)
8136 (gnus-treat-hide-boring-headers nil))
8137 (setq gnus-article-wash-types
8138 (delq 'headers gnus-article-wash-types))
8139 (gnus-treat-article 'head))
8140 (gnus-treat-article 'head)))
8141 (gnus-set-mode-line 'article)))))
8143 (defun gnus-summary-show-all-headers ()
8144 "Make all header lines visible."
8146 (gnus-summary-toggle-header 1))
8148 (defun gnus-summary-toggle-mime (&optional arg)
8149 "Toggle MIME processing.
8150 If ARG is a positive number, turn MIME processing on."
8152 (setq gnus-show-mime
8154 (not gnus-show-mime)
8155 (> (prefix-numeric-value arg) 0)))
8156 (gnus-summary-select-article t 'force))
8158 (defun gnus-summary-caesar-message (&optional arg)
8159 "Caesar rotate the current article by 13.
8160 The numerical prefix specifies how many places to rotate each letter
8163 (gnus-summary-select-article)
8164 (let ((mail-header-separator ""))
8165 (gnus-eval-in-buffer-window gnus-article-buffer
8168 (let ((start (window-start))
8170 (message-caesar-buffer-body arg)
8171 (set-window-start (get-buffer-window (current-buffer)) start))))))
8173 (defun gnus-summary-stop-page-breaking ()
8174 "Stop page breaking in the current article."
8176 (gnus-summary-select-article)
8177 (gnus-eval-in-buffer-window gnus-article-buffer
8179 (when (gnus-visual-p 'page-marker)
8180 (let ((buffer-read-only nil))
8181 (gnus-remove-text-with-property 'gnus-prev)
8182 (gnus-remove-text-with-property 'gnus-next))
8183 (setq gnus-page-broken nil))))
8185 (defun gnus-summary-move-article (&optional n to-newsgroup
8186 select-method action)
8187 "Move the current article to a different newsgroup.
8188 If N is a positive number, move the N next articles.
8189 If N is a negative number, move the N previous articles.
8190 If N is nil and any articles have been marked with the process mark,
8191 move those articles instead.
8192 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8193 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8194 re-spool using this method.
8196 For this function to work, both the current newsgroup and the
8197 newsgroup that you want to move to have to support the `request-move'
8198 and `request-accept' functions.
8200 ACTION can be either `move' (the default), `crosspost' or `copy'."
8203 (setq action 'move))
8204 ;; Check whether the source group supports the required functions.
8205 (cond ((and (eq action 'move)
8206 (not (gnus-check-backend-function
8207 'request-move-article gnus-newsgroup-name)))
8208 (error "The current group does not support article moving"))
8209 ((and (eq action 'crosspost)
8210 (not (gnus-check-backend-function
8211 'request-replace-article gnus-newsgroup-name)))
8212 (error "The current group does not support article editing")))
8213 (let ((articles (gnus-summary-work-articles n))
8214 (prefix (if (gnus-check-backend-function
8215 'request-move-article gnus-newsgroup-name)
8216 (gnus-group-real-prefix gnus-newsgroup-name)
8218 (names '((move "Move" "Moving")
8219 (copy "Copy" "Copying")
8220 (crosspost "Crosspost" "Crossposting")))
8221 (copy-buf (save-excursion
8222 (nnheader-set-temp-buffer " *copy article*")))
8223 (default-marks gnus-article-mark-lists)
8224 (no-expire-marks (delete '(expirable . expire)
8225 (copy-sequence gnus-article-mark-lists)))
8226 art-group to-method new-xref article to-groups)
8227 (unless (assq action names)
8228 (error "Unknown action %s" action))
8229 ;; Read the newsgroup name.
8230 (when (and (not to-newsgroup)
8231 (not select-method))
8233 (gnus-read-move-group-name
8234 (cadr (assq action names))
8235 (symbol-value (intern (format "gnus-current-%s-group" action)))
8237 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8238 (setq to-method (or select-method
8239 (gnus-server-to-method
8240 (gnus-group-method to-newsgroup))))
8241 ;; Check the method we are to move this article to...
8242 (unless (gnus-check-backend-function
8243 'request-accept-article (car to-method))
8244 (error "%s does not support article copying" (car to-method)))
8245 (unless (gnus-check-server to-method)
8246 (error "Can't open server %s" (car to-method)))
8247 (gnus-message 6 "%s to %s: %s..."
8248 (caddr (assq action names))
8249 (or (car select-method) to-newsgroup) articles)
8251 (setq article (pop articles))
8255 ;; Move the article.
8257 ;; Remove this article from future suppression.
8258 (gnus-dup-unsuppress-article article)
8259 (gnus-request-move-article
8260 article ; Article to move
8261 gnus-newsgroup-name ; From newsgroup
8262 (nth 1 (gnus-find-method-for-group
8263 gnus-newsgroup-name)) ; Server
8264 (list 'gnus-request-accept-article
8265 to-newsgroup (list 'quote select-method)
8266 (not articles) t) ; Accept form
8267 (not articles))) ; Only save nov last time
8268 ;; Copy the article.
8271 (set-buffer copy-buf)
8272 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8273 (gnus-request-accept-article
8274 to-newsgroup select-method (not articles) t))))
8275 ;; Crosspost the article.
8276 ((eq action 'crosspost)
8277 (let ((xref (message-tokenize-header
8278 (mail-header-xref (gnus-summary-article-header article))
8280 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8281 ":" (number-to-string article)))
8283 (setq xref (list (system-name))))
8286 (mapconcat 'identity
8287 (delete "Xref:" (delete new-xref xref))
8291 (set-buffer copy-buf)
8292 ;; First put the article in the destination group.
8293 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8294 (when (consp (setq art-group
8295 (gnus-request-accept-article
8296 to-newsgroup select-method (not articles))))
8297 (setq new-xref (concat new-xref " " (car art-group)
8299 (number-to-string (cdr art-group))))
8300 ;; Now we have the new Xrefs header, so we insert
8301 ;; it and replace the new article.
8302 (nnheader-replace-header "Xref" new-xref)
8303 (gnus-request-replace-article
8304 (cdr art-group) to-newsgroup (current-buffer))
8308 (gnus-message 1 "Couldn't %s article %s: %s"
8309 (cadr (assq action names)) article
8310 (nnheader-get-report (car to-method))))
8311 ((eq art-group 'junk)
8312 (when (eq action 'move)
8313 (gnus-summary-mark-article article gnus-canceled-mark)
8314 (gnus-message 4 "Deleted article %s" article)))
8316 (let* ((pto-group (gnus-group-prefixed-name
8317 (car art-group) to-method))
8319 (gnus-gethash pto-group gnus-newsrc-hashtb))
8320 (info (nth 2 entry))
8321 (to-group (gnus-info-group info))
8323 ;; Update the group that has been moved to.
8325 (memq action '(move copy)))
8326 (unless (member to-group to-groups)
8327 (push to-group to-groups))
8329 (unless (memq article gnus-newsgroup-unreads)
8330 (push 'read to-marks)
8332 info (gnus-add-to-range (gnus-info-read info)
8333 (list (cdr art-group)))))
8335 ;; See whether the article is to be put in the cache.
8336 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8339 (to-article (cdr art-group)))
8341 ;; Enter the article into the cache in the new group,
8342 ;; if that is required.
8343 (when gnus-use-cache
8344 (gnus-cache-possibly-enter-article
8346 (let ((header (copy-sequence
8347 (gnus-summary-article-header article))))
8348 (mail-header-set-number header to-article)
8350 (memq article gnus-newsgroup-marked)
8351 (memq article gnus-newsgroup-dormant)
8352 (memq article gnus-newsgroup-unreads)))
8354 (when gnus-preserve-marks
8355 ;; Copy any marks over to the new group.
8356 (when (and (equal to-group gnus-newsgroup-name)
8357 (not (memq article gnus-newsgroup-unreads)))
8358 ;; Mark this article as read in this group.
8359 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8360 (setcdr (gnus-active to-group) to-article)
8361 (setcdr gnus-newsgroup-active to-article))
8364 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8365 (when (memq article (symbol-value
8366 (intern (format "gnus-newsgroup-%s"
8368 (push (cdar marks) to-marks)
8369 ;; If the other group is the same as this group,
8370 ;; then we have to add the mark to the list.
8371 (when (equal to-group gnus-newsgroup-name)
8372 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8375 (intern (format "gnus-newsgroup-%s"
8377 ;; Copy the marks to other group.
8378 (gnus-add-marked-articles
8379 to-group (cdar marks) (list to-article) info)))
8380 (setq marks (cdr marks)))
8382 (gnus-request-set-mark to-group (list (list (list to-article)
8387 (concat "(gnus-group-set-info '"
8388 (gnus-prin1-to-string (gnus-get-info to-group))
8391 ;; Update the Xref header in this article to point to
8392 ;; the new crossposted article we have just created.
8393 (when (eq action 'crosspost)
8395 (set-buffer copy-buf)
8396 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8397 (nnheader-replace-header "Xref" new-xref)
8398 (gnus-request-replace-article
8399 article gnus-newsgroup-name (current-buffer)))))
8401 ;;;!!!Why is this necessary?
8402 (set-buffer gnus-summary-buffer)
8404 (gnus-summary-goto-subject article)
8405 (when (eq action 'move)
8406 (gnus-summary-mark-article article gnus-canceled-mark))))
8407 (gnus-summary-remove-process-mark article))
8408 ;; Re-activate all groups that have been moved to.
8410 (set-buffer gnus-group-buffer)
8411 (let ((gnus-group-marked to-groups))
8412 (gnus-group-get-new-news-this-group nil t)))
8414 (gnus-kill-buffer copy-buf)
8415 (gnus-summary-position-point)
8416 (gnus-set-mode-line 'summary)))
8418 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8419 "Move the current article to a different newsgroup.
8420 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8421 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8422 re-spool using this method."
8424 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8426 (defun gnus-summary-crosspost-article (&optional n)
8427 "Crosspost the current article to some other group."
8429 (gnus-summary-move-article n nil nil 'crosspost))
8431 (defcustom gnus-summary-respool-default-method nil
8432 "Default method type for respooling an article.
8433 If nil, use to the current newsgroup method."
8435 :group 'gnus-summary-mail)
8437 (defun gnus-summary-respool-article (&optional n method)
8438 "Respool the current article.
8439 The article will be squeezed through the mail spooling process again,
8440 which means that it will be put in some mail newsgroup or other
8441 depending on `nnmail-split-methods'.
8442 If N is a positive number, respool the N next articles.
8443 If N is a negative number, respool the N previous articles.
8444 If N is nil and any articles have been marked with the process mark,
8445 respool those articles instead.
8447 Respooling can be done both from mail groups and \"real\" newsgroups.
8448 In the former case, the articles in question will be moved from the
8449 current group into whatever groups they are destined to. In the
8450 latter case, they will be copied into the relevant groups."
8452 (list current-prefix-arg
8453 (let* ((methods (gnus-methods-using 'respool))
8455 (symbol-name (or gnus-summary-respool-default-method
8456 (car (gnus-find-method-for-group
8457 gnus-newsgroup-name)))))
8459 (gnus-completing-read
8460 methname "What backend do you want to use when respooling?"
8461 methods nil t nil 'gnus-mail-method-history))
8464 ((zerop (length (setq ms (gnus-servers-using-backend
8466 (list (intern method) ""))
8470 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8471 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8474 (error "No method given for respooling"))
8475 (if (assoc (symbol-name
8476 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8477 (gnus-methods-using 'respool))
8478 (gnus-summary-move-article n nil method)
8479 (gnus-summary-copy-article n nil method)))
8481 (defun gnus-summary-import-article (file &optional edit)
8482 "Import an arbitrary file into a mail newsgroup."
8483 (interactive "fImport file: \nP")
8484 (let ((group gnus-newsgroup-name)
8485 (now (current-time))
8486 atts lines group-art)
8487 (unless (gnus-check-backend-function 'request-accept-article group)
8488 (error "%s does not support article importing" group))
8489 (or (file-readable-p file)
8490 (not (file-regular-p file))
8491 (error "Can't read %s" file))
8493 (set-buffer (gnus-get-buffer-create " *import file*"))
8495 (nnheader-insert-file-contents file)
8496 (goto-char (point-min))
8497 (if (nnheader-article-p)
8499 (goto-char (point-min))
8500 (search-forward "\n\n" nil t)
8501 (narrow-to-region (point-min) (1- (point)))
8502 (goto-char (point-min))
8503 (unless (re-search-forward "^date:" nil t)
8504 (goto-char (point-max))
8505 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8506 ;; This doesn't look like an article, so we fudge some headers.
8507 (setq atts (file-attributes file)
8508 lines (count-lines (point-min) (point-max)))
8509 (insert "From: " (read-string "From: ") "\n"
8510 "Subject: " (read-string "Subject: ") "\n"
8511 "Date: " (message-make-date (nth 5 atts)) "\n"
8512 "Message-ID: " (message-make-message-id) "\n"
8513 "Lines: " (int-to-string lines) "\n"
8514 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8515 (setq group-art (gnus-request-accept-article group nil t))
8516 (kill-buffer (current-buffer)))
8517 (setq gnus-newsgroup-active (gnus-activate-group group))
8519 (gnus-summary-goto-article (cdr group-art) nil t)
8521 (gnus-summary-edit-article))))
8523 (defun gnus-summary-create-article ()
8524 "Create an article in a mail newsgroup."
8526 (let ((group gnus-newsgroup-name)
8527 (now (current-time))
8529 (unless (gnus-check-backend-function 'request-accept-article group)
8530 (error "%s does not support article importing" group))
8532 (set-buffer (gnus-get-buffer-create " *import file*"))
8534 (goto-char (point-min))
8535 ;; This doesn't look like an article, so we fudge some headers.
8536 (insert "From: " (read-string "From: ") "\n"
8537 "Subject: " (read-string "Subject: ") "\n"
8538 "Date: " (message-make-date now) "\n"
8539 "Message-ID: " (message-make-message-id) "\n")
8540 (setq group-art (gnus-request-accept-article group nil t))
8541 (kill-buffer (current-buffer)))
8542 (setq gnus-newsgroup-active (gnus-activate-group group))
8544 (gnus-summary-goto-article (cdr group-art) nil t)
8545 (gnus-summary-edit-article)))
8547 (defun gnus-summary-article-posted-p ()
8548 "Say whether the current (mail) article is available from news as well.
8549 This will be the case if the article has both been mailed and posted."
8551 (let ((id (mail-header-references (gnus-summary-article-header)))
8552 (gnus-override-method (car (gnus-refer-article-methods))))
8553 (if (gnus-request-head id "")
8554 (gnus-message 2 "The current message was found on %s"
8555 gnus-override-method)
8556 (gnus-message 2 "The current message couldn't be found on %s"
8557 gnus-override-method)
8560 (defun gnus-summary-expire-articles (&optional now)
8561 "Expire all articles that are marked as expirable in the current group."
8563 (when (gnus-check-backend-function
8564 'request-expire-articles gnus-newsgroup-name)
8565 ;; This backend supports expiry.
8566 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8567 (expirable (if total
8569 ;; We need to update the info for
8570 ;; this group for `gnus-list-of-read-articles'
8571 ;; to give us the right answer.
8572 (gnus-run-hooks 'gnus-exit-group-hook)
8573 (gnus-summary-update-info)
8574 (gnus-list-of-read-articles gnus-newsgroup-name))
8575 (setq gnus-newsgroup-expirable
8576 (sort gnus-newsgroup-expirable '<))))
8577 (expiry-wait (if now 'immediate
8578 (gnus-group-find-parameter
8579 gnus-newsgroup-name 'expiry-wait)))
8580 (nnmail-expiry-target
8581 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8582 nnmail-expiry-target))
8585 ;; There are expirable articles in this group, so we run them
8586 ;; through the expiry process.
8587 (gnus-message 6 "Expiring articles...")
8588 (unless (gnus-check-group gnus-newsgroup-name)
8589 (error "Can't open server for %s" gnus-newsgroup-name))
8590 ;; The list of articles that weren't expired is returned.
8593 (let ((nnmail-expiry-wait-function nil)
8594 (nnmail-expiry-wait expiry-wait))
8595 (setq es (gnus-request-expire-articles
8596 expirable gnus-newsgroup-name)))
8597 (setq es (gnus-request-expire-articles
8598 expirable gnus-newsgroup-name)))
8600 (setq gnus-newsgroup-expirable es))
8601 ;; We go through the old list of expirable, and mark all
8602 ;; really expired articles as nonexistent.
8603 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8604 (let ((gnus-use-cache nil))
8606 (unless (memq (car expirable) es)
8607 (when (gnus-data-find (car expirable))
8608 (gnus-summary-mark-article
8609 (car expirable) gnus-canceled-mark)))
8610 (setq expirable (cdr expirable))))))
8611 (gnus-message 6 "Expiring articles...done")))))
8613 (defun gnus-summary-expire-articles-now ()
8614 "Expunge all expirable articles in the current group.
8615 This means that *all* articles that are marked as expirable will be
8616 deleted forever, right now."
8618 (or gnus-expert-user
8620 "Are you really, really, really sure you want to delete all these messages? ")
8622 (gnus-summary-expire-articles t))
8624 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8625 (defun gnus-summary-delete-article (&optional n)
8626 "Delete the N next (mail) articles.
8627 This command actually deletes articles. This is not a marking
8628 command. The article will disappear forever from your life, never to
8630 If N is negative, delete backwards.
8631 If N is nil and articles have been marked with the process mark,
8632 delete these instead."
8634 (unless (gnus-check-backend-function 'request-expire-articles
8635 gnus-newsgroup-name)
8636 (error "The current newsgroup does not support article deletion"))
8637 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8638 (error "Couldn't open server"))
8639 ;; Compute the list of articles to delete.
8640 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8642 (if (and gnus-novice-user
8643 (not (gnus-yes-or-no-p
8644 (format "Do you really want to delete %s forever? "
8645 (if (> (length articles) 1)
8646 (format "these %s articles" (length articles))
8649 ;; Delete the articles.
8650 (setq not-deleted (gnus-request-expire-articles
8651 articles gnus-newsgroup-name 'force))
8653 (gnus-summary-remove-process-mark (car articles))
8654 ;; The backend might not have been able to delete the article
8656 (unless (memq (car articles) not-deleted)
8657 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8658 (setq articles (cdr articles)))
8660 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8661 (gnus-summary-position-point)
8662 (gnus-set-mode-line 'summary)
8665 (defun gnus-summary-edit-article (&optional force)
8666 "Edit the current article.
8667 This will have permanent effect only in mail groups.
8668 If FORCE is non-nil, allow editing of articles even in read-only
8672 (set-buffer gnus-summary-buffer)
8673 (let ((mail-parse-charset gnus-newsgroup-charset)
8674 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8675 (gnus-set-global-variables)
8676 (when (and (not force)
8677 (gnus-group-read-only-p))
8678 (error "The current newsgroup does not support article editing"))
8679 (gnus-summary-show-article t)
8680 (gnus-article-edit-article
8682 `(lambda (no-highlight)
8683 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8684 (message-options message-options)
8685 (message-options-set-recipient)
8686 (mail-parse-ignored-charsets
8687 ',gnus-newsgroup-ignored-charsets))
8688 (gnus-summary-edit-article-done
8689 ,(or (mail-header-references gnus-current-headers) "")
8690 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8692 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8694 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8696 "Make edits to the current article permanent."
8699 ;; The buffer restriction contains the entire article if it exists.
8700 (when (article-goto-body)
8701 (let ((lines (count-lines (point) (point-max)))
8702 (length (- (point-max) (point)))
8703 (case-fold-search t)
8704 (body (copy-marker (point))))
8705 (goto-char (point-min))
8706 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8707 (delete-region (match-beginning 1) (match-end 1))
8708 (insert (number-to-string length)))
8709 (goto-char (point-min))
8710 (when (re-search-forward
8711 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8712 (delete-region (match-beginning 1) (match-end 1))
8713 (insert (number-to-string length)))
8714 (goto-char (point-min))
8715 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8716 (delete-region (match-beginning 1) (match-end 1))
8717 (insert (number-to-string lines))))))
8718 ;; Replace the article.
8719 (let ((buf (current-buffer)))
8721 (insert-buffer-substring buf)
8723 (if (and (not read-only)
8724 (not (gnus-request-replace-article
8725 (cdr gnus-article-current) (car gnus-article-current)
8726 (current-buffer) t)))
8727 (error "Couldn't replace article")
8728 ;; Update the summary buffer.
8730 (equal (message-tokenize-header references " ")
8731 (message-tokenize-header
8732 (or (message-fetch-field "references") "") " ")))
8733 ;; We only have to update this line.
8736 (message-narrow-to-head)
8737 (let ((head (buffer-string))
8740 (insert (format "211 %d Article retrieved.\n"
8741 (cdr gnus-article-current)))
8744 (let ((nntp-server-buffer (current-buffer)))
8745 (setq header (car (gnus-get-newsgroup-headers
8747 (set-buffer gnus-summary-buffer)
8748 gnus-newsgroup-dependencies)
8751 (set-buffer gnus-summary-buffer)
8752 (gnus-data-set-header
8753 (gnus-data-find (cdr gnus-article-current))
8755 (gnus-summary-update-article-line
8756 (cdr gnus-article-current) header)
8757 (if (gnus-summary-goto-subject
8758 (cdr gnus-article-current) nil t)
8759 (gnus-summary-update-secondary-mark
8760 (cdr gnus-article-current))))))))
8762 (set-buffer (or buffer gnus-summary-buffer))
8763 (gnus-summary-update-article (cdr gnus-article-current))
8764 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8765 (gnus-summary-update-secondary-mark
8766 (cdr gnus-article-current))))
8767 ;; Prettify the article buffer again.
8768 (unless no-highlight
8770 (set-buffer gnus-article-buffer)
8771 ;;;!!! Fix this -- article should be rehighlighted.
8772 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8773 (set-buffer gnus-original-article-buffer)
8774 (gnus-request-article
8775 (cdr gnus-article-current)
8776 (car gnus-article-current) (current-buffer))))
8777 ;; Prettify the summary buffer line.
8778 (when (gnus-visual-p 'summary-highlight 'highlight)
8779 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8781 (defun gnus-summary-edit-wash (key)
8782 "Perform editing command KEY in the article buffer."
8786 (message "%s" (concat (this-command-keys) "- "))
8789 (gnus-summary-edit-article)
8790 (execute-kbd-macro (concat (this-command-keys) key))
8791 (gnus-article-edit-done))
8793 (defun gnus-summary-toggle-smiley (&optional arg)
8794 "Toggle the display of smilies as small graphical icons."
8797 (set-buffer gnus-article-buffer)
8798 (gnus-smiley-display arg)))
8802 (defun gnus-summary-respool-query (&optional silent trace)
8803 "Query where the respool algorithm would put this article."
8805 (let (gnus-mark-article-hook)
8806 (gnus-summary-select-article)
8808 (set-buffer gnus-original-article-buffer)
8810 (message-narrow-to-head)
8811 (let ((groups (nnmail-article-group 'identity trace)))
8814 (message "This message would go to %s"
8815 (mapconcat 'car groups ", "))
8816 (message "This message would go to no groups"))
8819 (defun gnus-summary-respool-trace ()
8820 "Trace where the respool algorithm would put this article.
8821 Display a buffer showing all fancy splitting patterns which matched."
8823 (gnus-summary-respool-query nil t))
8825 ;; Summary marking commands.
8827 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8828 "Mark articles which has the same subject as read, and then select the next.
8829 If UNMARK is positive, remove any kind of mark.
8830 If UNMARK is negative, tick articles."
8833 (setq unmark (prefix-numeric-value unmark)))
8835 (gnus-summary-mark-same-subject
8836 (gnus-summary-article-subject) unmark)))
8837 ;; Select next unread article. If auto-select-same mode, should
8838 ;; select the first unread article.
8839 (gnus-summary-next-article t (and gnus-auto-select-same
8840 (gnus-summary-article-subject)))
8841 (gnus-message 7 "%d article%s marked as %s"
8842 count (if (= count 1) " is" "s are")
8843 (if unmark "unread" "read"))))
8845 (defun gnus-summary-kill-same-subject (&optional unmark)
8846 "Mark articles which has the same subject as read.
8847 If UNMARK is positive, remove any kind of mark.
8848 If UNMARK is negative, tick articles."
8851 (setq unmark (prefix-numeric-value unmark)))
8853 (gnus-summary-mark-same-subject
8854 (gnus-summary-article-subject) unmark)))
8855 ;; If marked as read, go to next unread subject.
8857 ;; Go to next unread subject.
8858 (gnus-summary-next-subject 1 t))
8859 (gnus-message 7 "%d articles are marked as %s"
8860 count (if unmark "unread" "read"))))
8862 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8863 "Mark articles with same SUBJECT as read, and return marked number.
8864 If optional argument UNMARK is positive, remove any kinds of marks.
8865 If optional argument UNMARK is negative, mark articles as unread instead."
8869 ((null unmark) ; Mark as read.
8872 (gnus-summary-mark-article-as-read gnus-killed-mark)
8873 (gnus-summary-show-thread) t)
8874 (gnus-summary-find-subject subject))
8875 (setq count (1+ count))))
8876 ((> unmark 0) ; Tick.
8879 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8880 (gnus-summary-show-thread) t)
8881 (gnus-summary-find-subject subject))
8882 (setq count (1+ count))))
8883 (t ; Mark as unread.
8886 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8887 (gnus-summary-show-thread) t)
8888 (gnus-summary-find-subject subject))
8889 (setq count (1+ count)))))
8890 (gnus-set-mode-line 'summary)
8891 ;; Return the number of marked articles.
8894 (defun gnus-summary-mark-as-processable (n &optional unmark)
8895 "Set the process mark on the next N articles.
8896 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8897 the process mark instead. The difference between N and the actual
8898 number of articles marked is returned."
8900 (if (and (null n) (gnus-region-active-p))
8901 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8902 (setq n (prefix-numeric-value n))
8903 (let ((backward (< n 0))
8908 (gnus-summary-remove-process-mark
8909 (gnus-summary-article-number))
8910 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8911 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8914 (gnus-message 7 "No more articles"))
8915 (gnus-summary-recenter)
8916 (gnus-summary-position-point)
8919 (defun gnus-summary-unmark-as-processable (n)
8920 "Remove the process mark from the next N articles.
8921 If N is negative, unmark backward instead. The difference between N and
8922 the actual number of articles unmarked is returned."
8924 (gnus-summary-mark-as-processable n t))
8926 (defun gnus-summary-unmark-all-processable ()
8927 "Remove the process mark from all articles."
8930 (while gnus-newsgroup-processable
8931 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8932 (gnus-summary-position-point))
8934 (defun gnus-summary-add-mark (article type)
8935 "Mark ARTICLE with a mark of TYPE."
8936 (let ((vtype (car (assq type gnus-article-mark-lists)))
8939 (error "No such mark type: %s" type)
8940 (setq var (intern (format "gnus-newsgroup-%s" type)))
8941 (set var (cons article (symbol-value var)))
8942 (if (memq type '(processable cached replied forwarded recent saved))
8943 (gnus-summary-update-secondary-mark article)
8944 ;;; !!! This is bogus. We should find out what primary
8945 ;;; !!! mark we want to set.
8946 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8948 (defun gnus-summary-mark-as-expirable (n)
8949 "Mark N articles forward as expirable.
8950 If N is negative, mark backward instead. The difference between N and
8951 the actual number of articles marked is returned."
8953 (gnus-summary-mark-forward n gnus-expirable-mark))
8955 (defun gnus-summary-mark-article-as-replied (article)
8956 "Mark ARTICLE as replied to and update the summary line.
8957 ARTICLE can also be a list of articles."
8958 (interactive (list (gnus-summary-article-number)))
8959 (let ((articles (if (listp article) article (list article))))
8960 (dolist (article articles)
8961 (push article gnus-newsgroup-replied)
8962 (let ((buffer-read-only nil))
8963 (when (gnus-summary-goto-subject article nil t)
8964 (gnus-summary-update-secondary-mark article))))))
8966 (defun gnus-summary-mark-article-as-forwarded (article)
8967 "Mark ARTICLE as forwarded and update the summary line.
8968 ARTICLE can also be a list of articles."
8969 (let ((articles (if (listp article) article (list article))))
8970 (dolist (article articles)
8971 (push article gnus-newsgroup-forwarded)
8972 (let ((buffer-read-only nil))
8973 (when (gnus-summary-goto-subject article nil t)
8974 (gnus-summary-update-secondary-mark article))))))
8976 (defun gnus-summary-set-bookmark (article)
8977 "Set a bookmark in current article."
8978 (interactive (list (gnus-summary-article-number)))
8979 (when (or (not (get-buffer gnus-article-buffer))
8980 (not gnus-current-article)
8981 (not gnus-article-current)
8982 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8983 (error "No current article selected"))
8984 ;; Remove old bookmark, if one exists.
8985 (let ((old (assq article gnus-newsgroup-bookmarks)))
8987 (setq gnus-newsgroup-bookmarks
8988 (delq old gnus-newsgroup-bookmarks))))
8989 ;; Set the new bookmark, which is on the form
8990 ;; (article-number . line-number-in-body).
8994 (set-buffer gnus-article-buffer)
8998 (goto-char (point-min))
8999 (search-forward "\n\n" nil t)
9002 gnus-newsgroup-bookmarks)
9003 (gnus-message 6 "A bookmark has been added to the current article."))
9005 (defun gnus-summary-remove-bookmark (article)
9006 "Remove the bookmark from the current article."
9007 (interactive (list (gnus-summary-article-number)))
9008 ;; Remove old bookmark, if one exists.
9009 (let ((old (assq article gnus-newsgroup-bookmarks)))
9012 (setq gnus-newsgroup-bookmarks
9013 (delq old gnus-newsgroup-bookmarks))
9014 (gnus-message 6 "Removed bookmark."))
9015 (gnus-message 6 "No bookmark in current article."))))
9017 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9018 (defun gnus-summary-mark-as-dormant (n)
9019 "Mark N articles forward as dormant.
9020 If N is negative, mark backward instead. The difference between N and
9021 the actual number of articles marked is returned."
9023 (gnus-summary-mark-forward n gnus-dormant-mark))
9025 (defun gnus-summary-set-process-mark (article)
9026 "Set the process mark on ARTICLE and update the summary line."
9027 (setq gnus-newsgroup-processable
9029 (delq article gnus-newsgroup-processable)))
9030 (when (gnus-summary-goto-subject article)
9031 (gnus-summary-show-thread)
9032 (gnus-summary-goto-subject article)
9033 (gnus-summary-update-secondary-mark article)))
9035 (defun gnus-summary-remove-process-mark (article)
9036 "Remove the process mark from ARTICLE and update the summary line."
9037 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9038 (when (gnus-summary-goto-subject article)
9039 (gnus-summary-show-thread)
9040 (gnus-summary-goto-subject article)
9041 (gnus-summary-update-secondary-mark article)))
9043 (defun gnus-summary-set-saved-mark (article)
9044 "Set the process mark on ARTICLE and update the summary line."
9045 (push article gnus-newsgroup-saved)
9046 (when (gnus-summary-goto-subject article)
9047 (gnus-summary-update-secondary-mark article)))
9049 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9050 "Mark N articles as read forwards.
9051 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9052 The difference between N and the actual number of articles marked is
9054 Iff NO-EXPIRE, auto-expiry will be inhibited."
9056 (gnus-summary-show-thread)
9057 (let ((backward (< n 0))
9058 (gnus-summary-goto-unread
9059 (and gnus-summary-goto-unread
9060 (not (eq gnus-summary-goto-unread 'never))
9061 (not (memq mark (list gnus-unread-mark
9062 gnus-ticked-mark gnus-dormant-mark)))))
9064 (mark (or mark gnus-del-mark)))
9066 (gnus-summary-mark-article nil mark no-expire)
9067 (zerop (gnus-summary-next-subject
9069 (and gnus-summary-goto-unread
9070 (not (eq gnus-summary-goto-unread 'never)))
9074 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9075 (gnus-summary-recenter)
9076 (gnus-summary-position-point)
9077 (gnus-set-mode-line 'summary)
9080 (defun gnus-summary-mark-article-as-read (mark)
9081 "Mark the current article quickly as read with MARK."
9082 (let ((article (gnus-summary-article-number)))
9083 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9084 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9085 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9086 (push (cons article mark) gnus-newsgroup-reads)
9087 ;; Possibly remove from cache, if that is used.
9088 (when gnus-use-cache
9089 (gnus-cache-enter-remove-article article))
9090 ;; Allow the backend to change the mark.
9091 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9092 ;; Check for auto-expiry.
9093 (when (and gnus-newsgroup-auto-expire
9094 (memq mark gnus-auto-expirable-marks))
9095 (setq mark gnus-expirable-mark)
9096 ;; Let the backend know about the mark change.
9097 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9098 (push article gnus-newsgroup-expirable))
9099 ;; Set the mark in the buffer.
9100 (gnus-summary-update-mark mark 'unread)
9103 (defun gnus-summary-mark-article-as-unread (mark)
9104 "Mark the current article quickly as unread with MARK."
9105 (let* ((article (gnus-summary-article-number))
9106 (old-mark (gnus-summary-article-mark article)))
9107 ;; Allow the backend to change the mark.
9108 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9109 (if (eq mark old-mark)
9113 (gnus-error 1 "Can't mark negative article numbers")
9115 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9116 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9117 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9118 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9119 (cond ((= mark gnus-ticked-mark)
9120 (push article gnus-newsgroup-marked))
9121 ((= mark gnus-dormant-mark)
9122 (push article gnus-newsgroup-dormant))
9124 (push article gnus-newsgroup-unreads)))
9125 (gnus-pull article gnus-newsgroup-reads)
9127 ;; See whether the article is to be put in the cache.
9129 (vectorp (gnus-summary-article-header article))
9131 (gnus-cache-possibly-enter-article
9132 gnus-newsgroup-name article
9133 (gnus-summary-article-header article)
9134 (= mark gnus-ticked-mark)
9135 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9138 (gnus-summary-update-mark mark 'unread)
9141 (defun gnus-summary-mark-article (&optional article mark no-expire)
9142 "Mark ARTICLE with MARK. MARK can be any character.
9143 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9144 `??' (dormant) and `?E' (expirable).
9145 If MARK is nil, then the default character `?r' is used.
9146 If ARTICLE is nil, then the article on the current line will be
9148 Iff NO-EXPIRE, auto-expiry will be inhibited."
9149 ;; The mark might be a string.
9150 (when (stringp mark)
9151 (setq mark (aref mark 0)))
9152 ;; If no mark is given, then we check auto-expiring.
9154 (setq mark gnus-del-mark))
9155 (when (and (not no-expire)
9156 gnus-newsgroup-auto-expire
9157 (memq mark gnus-auto-expirable-marks))
9158 (setq mark gnus-expirable-mark))
9159 (let ((article (or article (gnus-summary-article-number)))
9160 (old-mark (gnus-summary-article-mark article)))
9161 ;; Allow the backend to change the mark.
9162 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9163 (if (eq mark old-mark)
9166 (error "No article on current line"))
9167 (if (not (if (or (= mark gnus-unread-mark)
9168 (= mark gnus-ticked-mark)
9169 (= mark gnus-dormant-mark))
9170 (gnus-mark-article-as-unread article mark)
9171 (gnus-mark-article-as-read article mark)))
9173 ;; See whether the article is to be put in the cache.
9175 (not (= mark gnus-canceled-mark))
9176 (vectorp (gnus-summary-article-header article))
9178 (gnus-cache-possibly-enter-article
9179 gnus-newsgroup-name article
9180 (gnus-summary-article-header article)
9181 (= mark gnus-ticked-mark)
9182 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9184 (when (gnus-summary-goto-subject article nil t)
9185 (let ((buffer-read-only nil))
9186 (gnus-summary-show-thread)
9188 (gnus-summary-update-mark mark 'unread)
9191 (defun gnus-summary-update-secondary-mark (article)
9192 "Update the secondary (read, process, cache) mark."
9193 (gnus-summary-update-mark
9194 (cond ((memq article gnus-newsgroup-processable)
9196 ((memq article gnus-newsgroup-cached)
9198 ((memq article gnus-newsgroup-replied)
9200 ((memq article gnus-newsgroup-forwarded)
9201 gnus-forwarded-mark)
9202 ((memq article gnus-newsgroup-saved)
9204 ((memq article gnus-newsgroup-recent)
9206 ((memq article gnus-newsgroup-unseen)
9210 (when (gnus-visual-p 'summary-highlight 'highlight)
9211 (gnus-run-hooks 'gnus-summary-update-hook))
9214 (defun gnus-summary-update-mark (mark type)
9215 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9216 (buffer-read-only nil))
9217 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9219 (when (looking-at "\r")
9221 (when (<= (+ forward (point)) (point-max))
9222 ;; Go to the right position on the line.
9223 (goto-char (+ forward (point)))
9224 ;; Replace the old mark with the new mark.
9225 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9226 ;; Optionally update the marks by some user rule.
9227 (when (eq type 'unread)
9229 (gnus-data-find (gnus-summary-article-number)) mark)
9230 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9232 (defun gnus-mark-article-as-read (article &optional mark)
9233 "Enter ARTICLE in the pertinent lists and remove it from others."
9234 ;; Make the article expirable.
9235 (let ((mark (or mark gnus-del-mark)))
9236 (if (= mark gnus-expirable-mark)
9237 (push article gnus-newsgroup-expirable)
9238 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9239 ;; Remove from unread and marked lists.
9240 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9241 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9242 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9243 (push (cons article mark) gnus-newsgroup-reads)
9244 ;; Possibly remove from cache, if that is used.
9245 (when gnus-use-cache
9246 (gnus-cache-enter-remove-article article))
9249 (defun gnus-mark-article-as-unread (article &optional mark)
9250 "Enter ARTICLE in the pertinent lists and remove it from others."
9251 (let ((mark (or mark gnus-ticked-mark)))
9254 (gnus-error 1 "Can't mark negative article numbers")
9256 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9257 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9258 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9259 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9261 ;; Unsuppress duplicates?
9262 (when gnus-suppress-duplicates
9263 (gnus-dup-unsuppress-article article))
9265 (cond ((= mark gnus-ticked-mark)
9266 (push article gnus-newsgroup-marked))
9267 ((= mark gnus-dormant-mark)
9268 (push article gnus-newsgroup-dormant))
9270 (push article gnus-newsgroup-unreads)))
9271 (gnus-pull article gnus-newsgroup-reads)
9274 (defalias 'gnus-summary-mark-as-unread-forward
9275 'gnus-summary-tick-article-forward)
9276 (make-obsolete 'gnus-summary-mark-as-unread-forward
9277 'gnus-summary-tick-article-forward)
9278 (defun gnus-summary-tick-article-forward (n)
9279 "Tick N articles forwards.
9280 If N is negative, tick backwards instead.
9281 The difference between N and the number of articles ticked is returned."
9283 (gnus-summary-mark-forward n gnus-ticked-mark))
9285 (defalias 'gnus-summary-mark-as-unread-backward
9286 'gnus-summary-tick-article-backward)
9287 (make-obsolete 'gnus-summary-mark-as-unread-backward
9288 'gnus-summary-tick-article-backward)
9289 (defun gnus-summary-tick-article-backward (n)
9290 "Tick N articles backwards.
9291 The difference between N and the number of articles ticked is returned."
9293 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9295 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9296 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9297 (defun gnus-summary-tick-article (&optional article clear-mark)
9298 "Mark current article as unread.
9299 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9300 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9302 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9305 (defun gnus-summary-mark-as-read-forward (n)
9306 "Mark N articles as read forwards.
9307 If N is negative, mark backwards instead.
9308 The difference between N and the actual number of articles marked is
9311 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9313 (defun gnus-summary-mark-as-read-backward (n)
9314 "Mark the N articles as read backwards.
9315 The difference between N and the actual number of articles marked is
9318 (gnus-summary-mark-forward
9319 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9321 (defun gnus-summary-mark-as-read (&optional article mark)
9322 "Mark current article as read.
9323 ARTICLE specifies the article to be marked as read.
9324 MARK specifies a string to be inserted at the beginning of the line."
9325 (gnus-summary-mark-article article mark))
9327 (defun gnus-summary-clear-mark-forward (n)
9328 "Clear marks from N articles forward.
9329 If N is negative, clear backward instead.
9330 The difference between N and the number of marks cleared is returned."
9332 (gnus-summary-mark-forward n gnus-unread-mark))
9334 (defun gnus-summary-clear-mark-backward (n)
9335 "Clear marks from N articles backward.
9336 The difference between N and the number of marks cleared is returned."
9338 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9340 (defun gnus-summary-mark-unread-as-read ()
9341 "Intended to be used by `gnus-summary-mark-article-hook'."
9342 (when (memq gnus-current-article gnus-newsgroup-unreads)
9343 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9345 (defun gnus-summary-mark-read-and-unread-as-read ()
9346 "Intended to be used by `gnus-summary-mark-article-hook'."
9347 (let ((mark (gnus-summary-article-mark)))
9348 (when (or (gnus-unread-mark-p mark)
9349 (gnus-read-mark-p mark))
9350 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9352 (defun gnus-summary-mark-unread-as-ticked ()
9353 "Intended to be used by `gnus-summary-mark-article-hook'."
9354 (when (memq gnus-current-article gnus-newsgroup-unreads)
9355 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9357 (defun gnus-summary-mark-region-as-read (point mark all)
9358 "Mark all unread articles between point and mark as read.
9359 If given a prefix, mark all articles between point and mark as read,
9360 even ticked and dormant ones."
9361 (interactive "r\nP")
9370 (memq (setq article (gnus-summary-article-number))
9371 gnus-newsgroup-unreads))
9372 (gnus-summary-mark-article article gnus-del-mark))
9374 (gnus-summary-find-next))))))
9376 (defun gnus-summary-mark-below (score mark)
9377 "Mark articles with score less than SCORE with MARK."
9378 (interactive "P\ncMark: ")
9379 (setq score (if score
9380 (prefix-numeric-value score)
9381 (or gnus-summary-default-score 0)))
9383 (set-buffer gnus-summary-buffer)
9384 (goto-char (point-min))
9387 (and (< (gnus-summary-article-score) score)
9388 (gnus-summary-mark-article nil mark))
9389 (gnus-summary-find-next)))))
9391 (defun gnus-summary-kill-below (&optional score)
9392 "Mark articles with score below SCORE as read."
9394 (gnus-summary-mark-below score gnus-killed-mark))
9396 (defun gnus-summary-clear-above (&optional score)
9397 "Clear all marks from articles with score above SCORE."
9399 (gnus-summary-mark-above score gnus-unread-mark))
9401 (defun gnus-summary-tick-above (&optional score)
9402 "Tick all articles with score above SCORE."
9404 (gnus-summary-mark-above score gnus-ticked-mark))
9406 (defun gnus-summary-mark-above (score mark)
9407 "Mark articles with score over SCORE with MARK."
9408 (interactive "P\ncMark: ")
9409 (setq score (if score
9410 (prefix-numeric-value score)
9411 (or gnus-summary-default-score 0)))
9413 (set-buffer gnus-summary-buffer)
9414 (goto-char (point-min))
9416 (when (> (gnus-summary-article-score) score)
9417 (gnus-summary-mark-article nil mark))
9419 (gnus-summary-find-next)))))
9421 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9422 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9423 (defun gnus-summary-limit-include-expunged (&optional no-error)
9424 "Display all the hidden articles that were expunged for low scores."
9426 (let ((buffer-read-only nil))
9427 (let ((scored gnus-newsgroup-scored)
9430 (unless (gnus-summary-article-header (caar scored))
9431 (and (setq h (gnus-number-to-header (caar scored)))
9432 (< (cdar scored) gnus-summary-expunge-below)
9434 (setq scored (cdr scored)))
9436 (when (not no-error)
9437 (error "No expunged articles hidden"))
9438 (goto-char (point-min))
9439 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9440 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9441 (mapcar (lambda (x) (push (mail-header-number x)
9442 gnus-newsgroup-limit))
9444 (gnus-summary-prepare-unthreaded (nreverse headers))
9445 (goto-char (point-min))
9446 (gnus-summary-position-point)
9449 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9450 "Mark all unread articles in this newsgroup as read.
9451 If prefix argument ALL is non-nil, ticked and dormant articles will
9452 also be marked as read.
9453 If QUIETLY is non-nil, no questions will be asked.
9454 If TO-HERE is non-nil, it should be a point in the buffer. All
9455 articles before (after, if REVERSE is set) this point will be marked as read.
9456 Note that this function will only catch up the unread article
9457 in the current summary buffer limitation.
9458 The number of articles marked as read is returned."
9463 (not gnus-interactive-catchup) ;Without confirmation?
9467 "Mark absolutely all articles as read? "
9468 "Mark all unread articles as read? ")))
9470 (not gnus-newsgroup-adaptive)
9471 (not gnus-newsgroup-auto-expire)
9472 (not gnus-suppress-duplicates)
9473 (or (not gnus-use-cache)
9474 (eq gnus-use-cache 'passive)))
9477 (setq gnus-newsgroup-marked nil
9478 gnus-newsgroup-dormant nil))
9479 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9480 ;; We actually mark all articles as canceled, which we
9481 ;; have to do when using auto-expiry or adaptive scoring.
9482 (gnus-summary-show-all-threads)
9483 (if (and to-here reverse)
9487 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9488 (gnus-summary-find-next (not all) nil nil t))))
9489 (when (gnus-summary-first-subject (not all) t)
9491 (if to-here (< (point) to-here) t)
9492 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9493 (gnus-summary-find-next (not all) nil nil t)))))
9494 (gnus-set-mode-line 'summary))
9496 (gnus-summary-position-point)))
9498 (defun gnus-summary-catchup-to-here (&optional all)
9499 "Mark all unticked articles before the current one as read.
9500 If ALL is non-nil, also mark ticked and dormant articles as read."
9503 (gnus-save-hidden-threads
9504 (let ((beg (point)))
9505 ;; We check that there are unread articles.
9506 (when (or all (gnus-summary-find-prev))
9507 (gnus-summary-catchup all t beg)))))
9508 (gnus-summary-position-point))
9510 (defun gnus-summary-catchup-from-here (&optional all)
9511 "Mark all unticked articles after the current one as read.
9512 If ALL is non-nil, also mark ticked and dormant articles as read."
9515 (gnus-save-hidden-threads
9516 (let ((beg (point)))
9517 ;; We check that there are unread articles.
9518 (when (or all (gnus-summary-find-next))
9519 (gnus-summary-catchup all t beg nil t)))))
9520 (gnus-summary-position-point))
9522 (defun gnus-summary-catchup-all (&optional quietly)
9523 "Mark all articles in this newsgroup as read."
9525 (gnus-summary-catchup t quietly))
9527 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9528 "Mark all unread articles in this group as read, then exit.
9529 If prefix argument ALL is non-nil, all articles are marked as read.
9530 If QUIETLY is non-nil, no questions will be asked."
9532 (when (gnus-summary-catchup all quietly nil 'fast)
9533 ;; Select next newsgroup or exit.
9534 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9535 (eq gnus-auto-select-next 'quietly))
9536 (gnus-summary-next-group nil)
9537 (gnus-summary-exit))))
9539 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9540 "Mark all articles in this newsgroup as read, and then exit."
9542 (gnus-summary-catchup-and-exit t quietly))
9544 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9545 "Mark all articles in this group as read and select the next group.
9546 If given a prefix, mark all articles, unread as well as ticked, as
9550 (gnus-summary-catchup all))
9551 (gnus-summary-next-group))
9557 (defmacro gnus-with-article (article &rest forms)
9558 "Select ARTICLE and perform FORMS in the original article buffer.
9559 Then replace the article with the result."
9561 ;; We don't want the article to be marked as read.
9562 (let (gnus-mark-article-hook)
9563 (gnus-summary-select-article t t nil ,article))
9564 (set-buffer gnus-original-article-buffer)
9566 (if (not (gnus-check-backend-function
9567 'request-replace-article (car gnus-article-current)))
9568 (gnus-message 5 "Read-only group; not replacing")
9569 (unless (gnus-request-replace-article
9570 ,article (car gnus-article-current)
9572 (error "Couldn't replace article")))
9573 ;; The cache and backlog have to be flushed somewhat.
9574 (when gnus-keep-backlog
9575 (gnus-backlog-remove-article
9576 (car gnus-article-current) (cdr gnus-article-current)))
9577 (when gnus-use-cache
9578 (gnus-cache-update-article
9579 (car gnus-article-current) (cdr gnus-article-current)))))
9581 (put 'gnus-with-article 'lisp-indent-function 1)
9582 (put 'gnus-with-article 'edebug-form-spec '(form body))
9584 ;; Thread-based commands.
9586 (defun gnus-summary-articles-in-thread (&optional article)
9587 "Return a list of all articles in the current thread.
9588 If ARTICLE is non-nil, return all articles in the thread that starts
9590 (let* ((article (or article (gnus-summary-article-number)))
9591 (data (gnus-data-find-list article))
9592 (top-level (gnus-data-level (car data)))
9594 (cond ((null gnus-thread-operation-ignore-subject)
9595 (gnus-simplify-subject-re
9596 (mail-header-subject (gnus-data-header (car data)))))
9597 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9598 (gnus-simplify-subject-fuzzy
9599 (mail-header-subject (gnus-data-header (car data)))))
9601 (end-point (save-excursion
9602 (if (gnus-summary-go-to-next-thread)
9603 (point) (point-max))))
9606 (< (gnus-data-pos (car data)) end-point))
9607 (when (or (not top-subject)
9608 (string= top-subject
9609 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9610 (gnus-simplify-subject-fuzzy
9611 (mail-header-subject
9612 (gnus-data-header (car data))))
9613 (gnus-simplify-subject-re
9614 (mail-header-subject
9615 (gnus-data-header (car data)))))))
9616 (push (gnus-data-number (car data)) articles))
9617 (unless (and (setq data (cdr data))
9618 (> (gnus-data-level (car data)) top-level))
9620 ;; Return the list of articles.
9621 (nreverse articles)))
9623 (defun gnus-summary-rethread-current ()
9624 "Rethread the thread the current article is part of."
9626 (let* ((gnus-show-threads t)
9627 (article (gnus-summary-article-number))
9628 (id (mail-header-id (gnus-summary-article-header)))
9629 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9631 (error "No article on the current line"))
9632 (gnus-rebuild-thread id)
9633 (gnus-summary-goto-subject article)))
9635 (defun gnus-summary-reparent-thread ()
9636 "Make the current article child of the marked (or previous) article.
9638 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9639 is non-nil or the Subject: of both articles are the same."
9641 (unless (not (gnus-group-read-only-p))
9642 (error "The current newsgroup does not support article editing"))
9643 (unless (<= (length gnus-newsgroup-processable) 1)
9644 (error "No more than one article may be marked"))
9645 (save-window-excursion
9646 (let ((gnus-article-buffer " *reparent*")
9647 (current-article (gnus-summary-article-number))
9648 ;; First grab the marked article, otherwise one line up.
9649 (parent-article (if (not (null gnus-newsgroup-processable))
9650 (car gnus-newsgroup-processable)
9652 (if (eq (forward-line -1) 0)
9653 (gnus-summary-article-number)
9654 (error "Beginning of summary buffer"))))))
9655 (unless (not (eq current-article parent-article))
9656 (error "An article may not be self-referential"))
9657 (let ((message-id (mail-header-id
9658 (gnus-summary-article-header parent-article))))
9659 (unless (and message-id (not (equal message-id "")))
9660 (error "No message-id in desired parent"))
9661 (gnus-with-article current-article
9663 (goto-char (point-min))
9664 (message-narrow-to-head)
9665 (if (re-search-forward "^References: " nil t)
9667 (re-search-forward "^[^ \t]" nil t)
9670 (insert " " message-id))
9671 (insert "References: " message-id "\n"))))
9672 (set-buffer gnus-summary-buffer)
9673 (gnus-summary-unmark-all-processable)
9674 (gnus-summary-update-article current-article)
9675 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9676 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9677 (gnus-summary-rethread-current)
9678 (gnus-message 3 "Article %d is now the child of article %d"
9679 current-article parent-article)))))
9681 (defun gnus-summary-toggle-threads (&optional arg)
9682 "Toggle showing conversation threads.
9683 If ARG is positive number, turn showing conversation threads on."
9685 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9686 (setq gnus-show-threads
9687 (if (null arg) (not gnus-show-threads)
9688 (> (prefix-numeric-value arg) 0)))
9689 (gnus-summary-prepare)
9690 (gnus-summary-goto-subject current)
9691 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9692 (gnus-summary-position-point)))
9694 (defun gnus-summary-show-all-threads ()
9698 (let ((buffer-read-only nil))
9699 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9700 (gnus-summary-position-point))
9702 (defun gnus-summary-show-thread ()
9703 "Show thread subtrees.
9704 Returns nil if no thread was there to be shown."
9706 (let ((buffer-read-only nil)
9708 ;; first goto end then to beg, to have point at beg after let
9709 (end (progn (end-of-line) (point)))
9710 (beg (progn (beginning-of-line) (point))))
9712 ;; Any hidden lines here?
9713 (search-forward "\r" end t)
9714 (subst-char-in-region beg end ?\^M ?\n t)
9716 (gnus-summary-position-point))))
9718 (defun gnus-summary-hide-all-threads ()
9719 "Hide all thread subtrees."
9722 (goto-char (point-min))
9723 (gnus-summary-hide-thread)
9724 (while (zerop (gnus-summary-next-thread 1 t))
9725 (gnus-summary-hide-thread)))
9726 (gnus-summary-position-point))
9728 (defun gnus-summary-hide-thread ()
9729 "Hide thread subtrees.
9730 Returns nil if no threads were there to be hidden."
9732 (let ((buffer-read-only nil)
9734 (article (gnus-summary-article-number)))
9736 ;; Go forward until either the buffer ends or the subthread
9738 (when (and (not (eobp))
9739 (or (zerop (gnus-summary-next-thread 1 t))
9740 (goto-char (point-max))))
9742 (if (and (> (point) start)
9743 (search-backward "\n" start t))
9745 (subst-char-in-region start (point) ?\n ?\^M)
9746 (gnus-summary-goto-subject article))
9750 (defun gnus-summary-go-to-next-thread (&optional previous)
9751 "Go to the same level (or less) next thread.
9752 If PREVIOUS is non-nil, go to previous thread instead.
9753 Return the article number moved to, or nil if moving was impossible."
9754 (let ((level (gnus-summary-thread-level))
9755 (way (if previous -1 1))
9758 (while (and (not (eobp))
9759 (< level (gnus-summary-thread-level)))
9767 (gnus-summary-article-number)
9770 (defun gnus-summary-next-thread (n &optional silent)
9771 "Go to the same level next N'th thread.
9772 If N is negative, search backward instead.
9773 Returns the difference between N and the number of skips actually
9776 If SILENT, don't output messages."
9778 (let ((backward (< n 0))
9781 (gnus-summary-go-to-next-thread backward))
9784 (gnus-summary-position-point))
9785 (when (and (not silent) (/= 0 n))
9786 (gnus-message 7 "No more threads"))
9789 (defun gnus-summary-prev-thread (n)
9790 "Go to the same level previous N'th thread.
9791 Returns the difference between N and the number of skips actually
9794 (gnus-summary-next-thread (- n)))
9796 (defun gnus-summary-go-down-thread ()
9797 "Go down one level in the current thread."
9798 (let ((children (gnus-summary-article-children)))
9800 (gnus-summary-goto-subject (car children)))))
9802 (defun gnus-summary-go-up-thread ()
9803 "Go up one level in the current thread."
9804 (let ((parent (gnus-summary-article-parent)))
9806 (gnus-summary-goto-subject parent))))
9808 (defun gnus-summary-down-thread (n)
9809 "Go down thread N steps.
9810 If N is negative, go up instead.
9811 Returns the difference between N and how many steps down that were
9817 (if up (gnus-summary-go-up-thread)
9818 (gnus-summary-go-down-thread)))
9820 (gnus-summary-position-point)
9822 (gnus-message 7 "Can't go further"))
9825 (defun gnus-summary-up-thread (n)
9826 "Go up thread N steps.
9827 If N is negative, go down instead.
9828 Returns the difference between N and how many steps down that were
9831 (gnus-summary-down-thread (- n)))
9833 (defun gnus-summary-top-thread ()
9834 "Go to the top of the thread."
9836 (while (gnus-summary-go-up-thread))
9837 (gnus-summary-article-number))
9839 (defun gnus-summary-kill-thread (&optional unmark)
9840 "Mark articles under current thread as read.
9841 If the prefix argument is positive, remove any kinds of marks.
9842 If the prefix argument is negative, tick articles instead."
9845 (setq unmark (prefix-numeric-value unmark)))
9846 (let ((articles (gnus-summary-articles-in-thread)))
9848 ;; Expand the thread.
9849 (gnus-summary-show-thread)
9850 ;; Mark all the articles.
9852 (gnus-summary-goto-subject (car articles))
9853 (cond ((null unmark)
9854 (gnus-summary-mark-article-as-read gnus-killed-mark))
9856 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9858 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9859 (setq articles (cdr articles))))
9860 ;; Hide killed subtrees.
9862 gnus-thread-hide-killed
9863 (gnus-summary-hide-thread))
9864 ;; If marked as read, go to next unread subject.
9866 ;; Go to next unread subject.
9867 (gnus-summary-next-subject 1 t)))
9868 (gnus-set-mode-line 'summary))
9870 ;; Summary sorting commands
9872 (defun gnus-summary-sort-by-number (&optional reverse)
9873 "Sort the summary buffer by article number.
9874 Argument REVERSE means reverse order."
9876 (gnus-summary-sort 'number reverse))
9878 (defun gnus-summary-sort-by-author (&optional reverse)
9879 "Sort the summary buffer by author name alphabetically.
9880 If `case-fold-search' is non-nil, case of letters is ignored.
9881 Argument REVERSE means reverse order."
9883 (gnus-summary-sort 'author reverse))
9885 (defun gnus-summary-sort-by-subject (&optional reverse)
9886 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9887 If `case-fold-search' is non-nil, case of letters is ignored.
9888 Argument REVERSE means reverse order."
9890 (gnus-summary-sort 'subject reverse))
9892 (defun gnus-summary-sort-by-date (&optional reverse)
9893 "Sort the summary buffer by date.
9894 Argument REVERSE means reverse order."
9896 (gnus-summary-sort 'date reverse))
9898 (defun gnus-summary-sort-by-score (&optional reverse)
9899 "Sort the summary buffer by score.
9900 Argument REVERSE means reverse order."
9902 (gnus-summary-sort 'score reverse))
9904 (defun gnus-summary-sort-by-lines (&optional reverse)
9905 "Sort the summary buffer by the number of lines.
9906 Argument REVERSE means reverse order."
9908 (gnus-summary-sort 'lines reverse))
9910 (defun gnus-summary-sort-by-chars (&optional reverse)
9911 "Sort the summary buffer by article length.
9912 Argument REVERSE means reverse order."
9914 (gnus-summary-sort 'chars reverse))
9916 (defun gnus-summary-sort-by-original (&optional reverse)
9917 "Sort the summary buffer using the default sorting method.
9918 Argument REVERSE means reverse order."
9920 (let* ((buffer-read-only)
9921 (gnus-summary-prepare-hook nil))
9922 ;; We do the sorting by regenerating the threads.
9923 (gnus-summary-prepare)
9924 ;; Hide subthreads if needed.
9925 (when (and gnus-show-threads gnus-thread-hide-subtree)
9926 (gnus-summary-hide-all-threads))))
9928 (defun gnus-summary-sort (predicate reverse)
9929 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9930 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9931 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9932 (gnus-thread-sort-functions
9937 (gnus-sort-gathered-threads-function
9938 gnus-thread-sort-functions)
9939 (gnus-article-sort-functions
9945 (gnus-summary-prepare-hook nil))
9946 ;; We do the sorting by regenerating the threads.
9947 (gnus-summary-prepare)
9948 ;; Hide subthreads if needed.
9949 (when (and gnus-show-threads gnus-thread-hide-subtree)
9950 (gnus-summary-hide-all-threads))))
9952 ;; Summary saving commands.
9954 (defun gnus-summary-save-article (&optional n not-saved)
9955 "Save the current article using the default saver function.
9956 If N is a positive number, save the N next articles.
9957 If N is a negative number, save the N previous articles.
9958 If N is nil and any articles have been marked with the process mark,
9959 save those articles instead.
9960 The variable `gnus-default-article-saver' specifies the saver function."
9962 (let* ((articles (gnus-summary-work-articles n))
9963 (save-buffer (save-excursion
9964 (nnheader-set-temp-buffer " *Gnus Save*")))
9965 (num (length articles))
9967 (dolist (article articles)
9968 (setq header (gnus-summary-article-header article))
9969 (if (not (vectorp header))
9970 ;; This is a pseudo-article.
9971 (if (assq 'name header)
9972 (gnus-copy-file (cdr (assq 'name header)))
9973 (gnus-message 1 "Article %d is unsaveable" article))
9974 ;; This is a real article.
9975 (save-window-excursion
9976 (let ((gnus-display-mime-function nil)
9977 (gnus-article-prepare-hook nil))
9978 (gnus-summary-select-article t nil nil article)))
9980 (set-buffer save-buffer)
9982 (insert-buffer-substring gnus-original-article-buffer))
9983 (setq file (gnus-article-save save-buffer file num))
9984 (gnus-summary-remove-process-mark article)
9986 (gnus-summary-set-saved-mark article))))
9987 (gnus-kill-buffer save-buffer)
9988 (gnus-summary-position-point)
9989 (gnus-set-mode-line 'summary)
9992 (defun gnus-summary-pipe-output (&optional arg)
9993 "Pipe the current article to a subprocess.
9994 If N is a positive number, pipe the N next articles.
9995 If N is a negative number, pipe the N previous articles.
9996 If N is nil and any articles have been marked with the process mark,
9997 pipe those articles instead."
10000 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10001 (gnus-summary-save-article arg t))
10002 (let ((buffer (get-buffer "*Shell Command Output*")))
10004 (with-current-buffer buffer (> (point-max) (point-min))))
10005 (gnus-configure-windows 'pipe))))
10007 (defun gnus-summary-save-article-mail (&optional arg)
10008 "Append the current article to an mail file.
10009 If N is a positive number, save the N next articles.
10010 If N is a negative number, save the N previous articles.
10011 If N is nil and any articles have been marked with the process mark,
10012 save those articles instead."
10014 (require 'gnus-art)
10015 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10016 (gnus-summary-save-article arg)))
10018 (defun gnus-summary-save-article-rmail (&optional arg)
10019 "Append the current article to an rmail file.
10020 If N is a positive number, save the N next articles.
10021 If N is a negative number, save the N previous articles.
10022 If N is nil and any articles have been marked with the process mark,
10023 save those articles instead."
10025 (require 'gnus-art)
10026 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10027 (gnus-summary-save-article arg)))
10029 (defun gnus-summary-save-article-file (&optional arg)
10030 "Append the current article to a file.
10031 If N is a positive number, save the N next articles.
10032 If N is a negative number, save the N previous articles.
10033 If N is nil and any articles have been marked with the process mark,
10034 save those articles instead."
10036 (require 'gnus-art)
10037 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10038 (gnus-summary-save-article arg)))
10040 (defun gnus-summary-write-article-file (&optional arg)
10041 "Write the current article to a file, deleting the previous file.
10042 If N is a positive number, save the N next articles.
10043 If N is a negative number, save the N previous articles.
10044 If N is nil and any articles have been marked with the process mark,
10045 save those articles instead."
10047 (require 'gnus-art)
10048 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10049 (gnus-summary-save-article arg)))
10051 (defun gnus-summary-save-article-body-file (&optional arg)
10052 "Append the current article body to a file.
10053 If N is a positive number, save the N next articles.
10054 If N is a negative number, save the N previous articles.
10055 If N is nil and any articles have been marked with the process mark,
10056 save those articles instead."
10058 (require 'gnus-art)
10059 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10060 (gnus-summary-save-article arg)))
10062 (defun gnus-summary-pipe-message (program)
10063 "Pipe the current article through PROGRAM."
10064 (interactive "sProgram: ")
10065 (gnus-summary-select-article)
10066 (let ((mail-header-separator ""))
10067 (gnus-eval-in-buffer-window gnus-article-buffer
10070 (let ((start (window-start))
10072 (message-pipe-buffer-body program)
10073 (set-window-start (get-buffer-window (current-buffer)) start))))))
10075 (defun gnus-get-split-value (methods)
10076 "Return a value based on the split METHODS."
10077 (let (split-name method result match)
10080 (set-buffer gnus-original-article-buffer)
10082 (nnheader-narrow-to-headers)
10083 (while (and methods (not split-name))
10084 (goto-char (point-min))
10085 (setq method (pop methods))
10086 (setq match (car method))
10089 ;; Regular expression.
10091 (re-search-forward match nil t)))
10092 ((gnus-functionp match)
10096 (setq result (funcall match gnus-newsgroup-name))))
10101 (setq result (eval match)))))
10102 (setq split-name (cdr method))
10103 (cond ((stringp result)
10104 (push (expand-file-name
10105 result gnus-article-save-directory)
10108 (setq split-name (append result split-name)))))))))
10109 (nreverse split-name)))
10111 (defun gnus-valid-move-group-p (group)
10112 (and (boundp group)
10113 (symbol-name group)
10114 (symbol-value group)
10115 (gnus-get-function (gnus-find-method-for-group
10116 (symbol-name group)) 'request-accept-article t)))
10118 (defun gnus-read-move-group-name (prompt default articles prefix)
10119 "Read a group name."
10120 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10121 (minibuffer-confirm-incomplete nil) ; XEmacs
10123 (format "%s %s to:"
10125 (if (> (length articles) 1)
10126 (format "these %d articles" (length articles))
10131 (gnus-completing-read default prom
10133 'gnus-valid-move-group-p
10135 'gnus-group-history))
10136 ((= 1 (length split-name))
10137 (gnus-completing-read (car split-name) prom
10139 'gnus-valid-move-group-p
10141 'gnus-group-history))
10143 (gnus-completing-read nil prom
10144 (mapcar (lambda (el) (list el))
10145 (nreverse split-name))
10147 'gnus-group-history))))
10148 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10150 (if (or (string= to-newsgroup "")
10151 (string= to-newsgroup prefix))
10152 (setq to-newsgroup default))
10153 (unless to-newsgroup
10154 (error "No group name entered"))
10155 (or (gnus-active to-newsgroup)
10156 (gnus-activate-group to-newsgroup nil nil to-method)
10157 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10159 (or (and (gnus-request-create-group to-newsgroup to-method)
10160 (gnus-activate-group
10161 to-newsgroup nil nil to-method)
10162 (gnus-subscribe-group to-newsgroup))
10163 (error "Couldn't create group %s" to-newsgroup)))
10164 (error "No such group: %s" to-newsgroup)))
10167 (defun gnus-summary-save-parts (type dir n &optional reverse)
10168 "Save parts matching TYPE to DIR.
10169 If REVERSE, save parts that do not match TYPE."
10171 (list (read-string "Save parts of type: "
10172 (or (car gnus-summary-save-parts-type-history)
10173 gnus-summary-save-parts-default-mime)
10174 'gnus-summary-save-parts-type-history)
10175 (setq gnus-summary-save-parts-last-directory
10176 (read-file-name "Save to directory: "
10177 gnus-summary-save-parts-last-directory
10179 current-prefix-arg))
10180 (gnus-summary-iterate n
10181 (let ((gnus-display-mime-function nil)
10182 (gnus-inhibit-treatment t))
10183 (gnus-summary-select-article))
10185 (set-buffer gnus-article-buffer)
10186 (let ((handles (or gnus-article-mime-handles
10187 (mm-dissect-buffer) (mm-uu-dissect))))
10189 (gnus-summary-save-parts-1 type dir handles reverse)
10190 (unless gnus-article-mime-handles ;; Don't destroy this case.
10191 (mm-destroy-parts handles)))))))
10193 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10194 (if (stringp (car handle))
10195 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10198 (not (string-match type (mm-handle-media-type handle)))
10199 (string-match type (mm-handle-media-type handle)))
10200 (let ((file (expand-file-name
10201 (file-name-nondirectory
10203 (mail-content-type-get
10204 (mm-handle-disposition handle) 'filename)
10205 (concat gnus-newsgroup-name
10206 "." (number-to-string
10207 (cdr gnus-article-current)))))
10209 (unless (file-exists-p file)
10210 (mm-save-part-to-file handle file))))))
10212 ;; Summary extract commands
10214 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10215 (let ((buffer-read-only nil)
10216 (article (gnus-summary-article-number))
10218 (unless (gnus-summary-goto-subject article)
10219 (error "No such article: %d" article))
10220 (gnus-summary-position-point)
10221 ;; If all commands are to be bunched up on one line, we collect
10223 (unless gnus-view-pseudos-separately
10224 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10227 (setq action (cdr (assq 'action (car ps))))
10228 (setq files (list (cdr (assq 'name (car ps)))))
10229 (while (and ps (cdr ps)
10230 (string= (or action "1")
10231 (or (cdr (assq 'action (cadr ps))) "2")))
10232 (push (cdr (assq 'name (cadr ps))) files)
10233 (setcdr ps (cddr ps)))
10235 (when (not (string-match "%s" action))
10238 (when (assq 'execute (car ps))
10239 (setcdr (assq 'execute (car ps))
10240 (funcall (if (string-match "%s" action)
10247 (gnus-quote-arg-for-sh-or-csh f)))
10249 (setq ps (cdr ps)))))
10250 (if (and gnus-view-pseudos (not not-view))
10252 (when (assq 'execute (car pslist))
10253 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10254 (eq gnus-view-pseudos 'not-confirm)))
10255 (setq pslist (cdr pslist)))
10258 (setq after-article (or (cdr (assq 'article (car pslist)))
10259 (gnus-summary-article-number)))
10260 (gnus-summary-goto-subject after-article)
10263 (insert " " (file-name-nondirectory
10264 (cdr (assq 'name (car pslist))))
10265 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10267 (forward-line -1) ; back to `b'
10268 (gnus-add-text-properties
10269 b (1- e) (list 'gnus-number gnus-reffed-article-number
10270 gnus-mouse-face-prop gnus-mouse-face))
10272 after-article gnus-reffed-article-number
10273 gnus-unread-mark b (car pslist) 0 (- e b))
10274 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10275 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10276 (setq pslist (cdr pslist)))))))
10278 (defun gnus-pseudos< (p1 p2)
10279 (let ((c1 (cdr (assq 'action p1)))
10280 (c2 (cdr (assq 'action p2))))
10281 (and c1 c2 (string< c1 c2))))
10283 (defun gnus-request-pseudo-article (props)
10284 (cond ((assq 'execute props)
10285 (gnus-execute-command (cdr (assq 'execute props)))))
10286 (let ((gnus-current-article (gnus-summary-article-number)))
10287 (gnus-run-hooks 'gnus-mark-article-hook)))
10289 (defun gnus-execute-command (command &optional automatic)
10291 (gnus-article-setup-buffer)
10292 (set-buffer gnus-article-buffer)
10293 (setq buffer-read-only nil)
10294 (let ((command (if automatic command
10295 (read-string "Command: " (cons command 0)))))
10297 (insert "$ " command "\n\n")
10298 (if gnus-view-pseudo-asynchronously
10299 (start-process "gnus-execute" (current-buffer) shell-file-name
10300 shell-command-switch command)
10301 (call-process shell-file-name nil t nil
10302 shell-command-switch command)))))
10304 ;; Summary kill commands.
10306 (defun gnus-summary-edit-global-kill (article)
10307 "Edit the \"global\" kill file."
10308 (interactive (list (gnus-summary-article-number)))
10309 (gnus-group-edit-global-kill article))
10311 (defun gnus-summary-edit-local-kill ()
10312 "Edit a local kill file applied to the current newsgroup."
10314 (setq gnus-current-headers (gnus-summary-article-header))
10315 (gnus-group-edit-local-kill
10316 (gnus-summary-article-number) gnus-newsgroup-name))
10318 ;;; Header reading.
10320 (defun gnus-read-header (id &optional header)
10321 "Read the headers of article ID and enter them into the Gnus system."
10322 (let ((group gnus-newsgroup-name)
10323 (gnus-override-method
10325 gnus-override-method
10326 (and (gnus-news-group-p gnus-newsgroup-name)
10327 (car (gnus-refer-article-methods)))))
10329 ;; First we check to see whether the header in question is already
10332 ;; This is a Message-ID.
10333 (setq header (or header (gnus-id-to-header id)))
10334 ;; This is an article number.
10335 (setq header (or header (gnus-summary-article-header id))))
10337 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10338 ;; We have found the header.
10340 ;; If this is a sparse article, we have to nix out its
10341 ;; previous entry in the thread hashtb.
10343 (gnus-summary-article-sparse-p (mail-header-number header)))
10344 (let* ((parent (gnus-parent-id (mail-header-references header)))
10345 (thread (and parent (gnus-id-to-thread parent))))
10347 (delq (assq header thread) thread))))
10348 ;; We have to really fetch the header to this article.
10350 (set-buffer nntp-server-buffer)
10351 (when (setq where (gnus-request-head id group))
10352 (nnheader-fold-continuation-lines)
10353 (goto-char (point-max))
10355 (goto-char (point-min))
10359 ((cdr where) (cdr where))
10360 (header (mail-header-number header))
10361 (t gnus-reffed-article-number))
10363 (insert " Article retrieved.\n"))
10364 (if (or (not where)
10365 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10366 () ; Malformed head.
10367 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10368 (when (and (stringp id)
10369 (not (string= (gnus-group-real-name group)
10371 ;; If we fetched by Message-ID and the article came
10372 ;; from a different group, we fudge some bogus article
10373 ;; numbers for this article.
10374 (mail-header-set-number header gnus-reffed-article-number))
10376 (set-buffer gnus-summary-buffer)
10377 (decf gnus-reffed-article-number)
10378 (gnus-remove-header (mail-header-number header))
10379 (push header gnus-newsgroup-headers)
10380 (setq gnus-current-headers header)
10381 (push (mail-header-number header) gnus-newsgroup-limit)))
10384 (defun gnus-remove-header (number)
10385 "Remove header NUMBER from `gnus-newsgroup-headers'."
10386 (if (and gnus-newsgroup-headers
10387 (= number (mail-header-number (car gnus-newsgroup-headers))))
10388 (pop gnus-newsgroup-headers)
10389 (let ((headers gnus-newsgroup-headers))
10390 (while (and (cdr headers)
10391 (not (= number (mail-header-number (cadr headers)))))
10393 (when (cdr headers)
10394 (setcdr headers (cddr headers))))))
10397 ;;; summary highlights
10400 (defun gnus-highlight-selected-summary ()
10401 "Highlight selected article in summary buffer."
10402 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10403 (when gnus-summary-selected-face
10405 (let* ((beg (progn (beginning-of-line) (point)))
10406 (end (progn (end-of-line) (point)))
10407 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10408 (from (if (get-text-property beg gnus-mouse-face-prop)
10410 (or (next-single-property-change
10411 beg gnus-mouse-face-prop nil end)
10416 (or (next-single-property-change
10417 from gnus-mouse-face-prop nil end)
10419 ;; If no mouse-face prop on line we will have to = from = end,
10420 ;; so we highlight the entire line instead.
10421 (when (= (+ to 2) from)
10424 (if gnus-newsgroup-selected-overlay
10425 ;; Move old overlay.
10427 gnus-newsgroup-selected-overlay from to (current-buffer))
10428 ;; Create new overlay.
10430 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10431 'face gnus-summary-selected-face))))))
10433 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10434 (defun gnus-summary-highlight-line ()
10435 "Highlight current line according to `gnus-summary-highlight'."
10436 (let* ((list gnus-summary-highlight)
10438 (end (progn (end-of-line) (point)))
10439 ;; now find out where the line starts and leave point there.
10440 (beg (progn (beginning-of-line) (point)))
10441 (article (gnus-summary-article-number))
10442 (score (or (cdr (assq (or article gnus-current-article)
10443 gnus-newsgroup-scored))
10444 gnus-summary-default-score 0))
10445 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10446 (inhibit-read-only t))
10447 ;; Eval the cars of the lists until we find a match.
10448 (let ((default gnus-summary-default-score)
10449 (default-high gnus-summary-default-high-score)
10450 (default-low gnus-summary-default-low-score))
10452 (not (eval (caar list))))
10453 (setq list (cdr list))))
10454 (let ((face (cdar list)))
10455 (unless (eq face (get-text-property beg 'face))
10456 (gnus-put-text-property-excluding-characters-with-faces
10458 (setq face (if (boundp face) (symbol-value face) face)))
10459 (when gnus-summary-highlight-line-function
10460 (funcall gnus-summary-highlight-line-function article face))))
10463 (defun gnus-update-read-articles (group unread &optional compute)
10464 "Update the list of read articles in GROUP."
10465 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10466 (entry (gnus-gethash group gnus-newsrc-hashtb))
10467 (info (nth 2 entry))
10469 (unread (sort (copy-sequence unread) '<))
10471 (if (or (not info) (not active))
10472 ;; There is no info on this group if it was, in fact,
10473 ;; killed. Gnus stores no information on killed groups, so
10474 ;; there's nothing to be done.
10475 ;; One could store the information somewhere temporarily,
10476 ;; perhaps... Hmmm...
10478 ;; Remove any negative articles numbers.
10479 (while (and unread (< (car unread) 0))
10480 (setq unread (cdr unread)))
10481 ;; Remove any expired article numbers
10482 (while (and unread (< (car unread) (car active)))
10483 (setq unread (cdr unread)))
10484 ;; Compute the ranges of read articles by looking at the list of
10485 ;; unread articles.
10487 (when (/= (car unread) prev)
10488 (push (if (= prev (1- (car unread))) prev
10489 (cons prev (1- (car unread))))
10491 (setq prev (1+ (car unread)))
10492 (setq unread (cdr unread)))
10493 (when (<= prev (cdr active))
10494 (push (cons prev (cdr active)) read))
10495 (setq read (if (> (length read) 1) (nreverse read) read))
10500 ;; Propagate the read marks to the backend.
10501 (when (gnus-check-backend-function 'request-set-mark group)
10502 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10503 (add (gnus-remove-from-range read (gnus-info-read info))))
10505 (unless (gnus-check-group group)
10506 (error "Can't open server for %s" group))
10507 (gnus-request-set-mark
10508 group (delq nil (list (if add (list add 'add '(read)))
10509 (if del (list del 'del '(read))))))
10511 `(gnus-request-set-mark
10514 (if del (list del 'add '(read)))
10515 (if add (list add 'del '(read))))))))))
10516 (set-buffer gnus-group-buffer)
10517 (gnus-undo-register
10519 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10520 (gnus-info-set-read ',info ',(gnus-info-read info))
10521 (gnus-get-unread-articles-in-group ',info
10522 (gnus-active ,group))
10523 (gnus-group-update-group ,group t)
10525 ;; Enter this list into the group info.
10526 (gnus-info-set-read info read)
10527 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10528 (gnus-get-unread-articles-in-group info (gnus-active group))
10531 (defun gnus-offer-save-summaries ()
10532 "Offer to save all active summary buffers."
10534 ;; Go through all buffers and find all summaries.
10535 (dolist (buffer (buffer-list))
10536 (when (and (setq buffer (buffer-name buffer))
10537 (string-match "Summary" buffer)
10539 (set-buffer buffer)
10540 ;; We check that this is, indeed, a summary buffer.
10541 (and (eq major-mode 'gnus-summary-mode)
10542 ;; Also make sure this isn't bogus.
10543 gnus-newsgroup-prepared
10544 ;; Also make sure that this isn't a
10545 ;; dead summary buffer.
10546 (not gnus-dead-summary-mode))))
10547 (push buffer buffers)))
10548 ;; Go through all these summary buffers and offer to save them.
10552 "Update summary buffer %s? "
10554 (switch-to-buffer buf)
10555 (gnus-summary-exit))
10559 ;;; @ for mime-partial
10562 (defun gnus-request-partial-message ()
10564 (let ((number (gnus-summary-article-number))
10565 (group gnus-newsgroup-name)
10566 (mother gnus-article-buffer))
10567 (set-buffer (get-buffer-create " *Partial Article*"))
10569 (setq mime-preview-buffer mother)
10570 (gnus-request-article-this-buffer number group)
10571 (mime-parse-buffer)
10574 (autoload 'mime-combine-message/partial-pieces-automatically
10576 "Internal method to combine message/partial messages automatically.")
10578 (mime-add-condition
10579 'action '((type . message)(subtype . partial)
10580 (major-mode . gnus-original-article-mode)
10581 (method . mime-combine-message/partial-pieces-automatically)
10582 (summary-buffer-exp . gnus-summary-buffer)
10583 (request-partial-message-method . gnus-request-partial-message)
10587 ;;; @ for message/rfc822
10590 (defun gnus-mime-extract-message/rfc822 (entity situation)
10591 (let (group article num cwin swin cur)
10593 (mime-insert-entity-content entity)
10594 (setq group (or (cdr (assq 'group situation))
10595 (completing-read "Group: "
10598 (gnus-read-active-file-p)
10599 gnus-newsgroup-name))
10600 article (gnus-request-accept-article group)))
10601 (when (and (consp article)
10602 (numberp (setq article (cdr article))))
10603 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10604 cwin (get-buffer-window (current-buffer) t))
10605 (save-window-excursion
10606 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10607 (select-window swin)
10608 (set-buffer gnus-summary-buffer))
10609 (setq cur gnus-current-article)
10611 (let (gnus-show-threads)
10612 (gnus-summary-goto-subject article t))
10613 (gnus-summary-clear-mark-forward 1)
10614 (gnus-summary-goto-subject cur))
10615 (when (and cwin (window-frame cwin))
10616 (select-frame (window-frame cwin)))
10617 (when (boundp 'mime-acting-situation-to-override)
10618 (set-alist 'mime-acting-situation-to-override
10621 (set-alist 'mime-acting-situation-to-override
10624 (save-current-buffer
10625 (set-buffer gnus-group-buffer)
10626 (gnus-activate-group ,group))
10627 (gnus-summary-goto-article ,cur
10628 gnus-show-all-headers)))
10629 (set-alist 'mime-acting-situation-to-override
10632 (mime-add-condition
10633 'action '((type . message)(subtype . rfc822)
10634 (major-mode . gnus-original-article-mode)
10635 (method . gnus-mime-extract-message/rfc822)
10639 (mime-add-condition
10640 'action '((type . message)(subtype . news)
10641 (major-mode . gnus-original-article-mode)
10642 (method . gnus-mime-extract-message/rfc822)
10646 (defun gnus-mime-extract-multipart (entity situation)
10647 (let ((children (mime-entity-children entity))
10648 mime-acting-situation-to-override
10651 (mime-play-entity (car children)
10652 (cons (assq 'mode situation)
10653 mime-acting-situation-to-override))
10654 (setq children (cdr children)))
10655 (if (setq f (cdr (assq 'after-method
10656 mime-acting-situation-to-override)))
10660 (mime-add-condition
10661 'action '((type . multipart)
10662 (method . gnus-mime-extract-multipart)
10671 (defun gnus-summary-setup-default-charset ()
10672 "Setup newsgroup default charset."
10673 (if (equal gnus-newsgroup-name "nndraft:drafts")
10674 (setq gnus-newsgroup-charset nil)
10675 (let* ((ignored-charsets
10676 (or gnus-newsgroup-ephemeral-ignored-charsets
10678 (and gnus-newsgroup-name
10679 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10680 gnus-newsgroup-ignored-charsets))))
10681 (setq gnus-newsgroup-charset
10682 (or gnus-newsgroup-ephemeral-charset
10683 (and gnus-newsgroup-name
10684 (gnus-parameter-charset gnus-newsgroup-name))
10685 gnus-default-charset))
10686 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10687 ignored-charsets))))
10693 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10694 "Display the current article buffer fully MIME-buttonized.
10695 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10696 treated as multipart/mixed."
10698 (require 'gnus-art)
10699 (let ((gnus-unbuttonized-mime-types nil)
10700 (gnus-mime-display-multipart-as-mixed show-all-parts))
10701 (gnus-summary-show-article)))
10703 (defun gnus-summary-repair-multipart (article)
10704 "Add a Content-Type header to a multipart article without one."
10705 (interactive (list (gnus-summary-article-number)))
10706 (gnus-with-article article
10707 (message-narrow-to-head)
10708 (message-remove-header "Mime-Version")
10709 (goto-char (point-max))
10710 (insert "Mime-Version: 1.0\n")
10712 (when (search-forward "\n--" nil t)
10713 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10714 (message-narrow-to-head)
10715 (message-remove-header "Content-Type")
10716 (goto-char (point-max))
10717 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10720 (let (gnus-mark-article-hook)
10721 (gnus-summary-select-article t t nil article)))
10723 (defun gnus-summary-toggle-display-buttonized ()
10724 "Toggle the buttonizing of the article buffer."
10726 (require 'gnus-art)
10727 (if (setq gnus-inhibit-mime-unbuttonizing
10728 (not gnus-inhibit-mime-unbuttonizing))
10729 (let ((gnus-unbuttonized-mime-types nil))
10730 (gnus-summary-show-article))
10731 (gnus-summary-show-article)))
10734 ;;; Intelli-mouse commmands
10737 (defun gnus-wheel-summary-scroll (event)
10739 (let ((amount (if (memq 'shift (event-modifiers event))
10740 (car gnus-wheel-scroll-amount)
10741 (cdr gnus-wheel-scroll-amount)))
10742 (direction (- (* (static-if (featurep 'xemacs)
10743 (event-button event)
10744 (cond ((eq 'mouse-4 (event-basic-type event))
10746 ((eq 'mouse-5 (event-basic-type event))
10750 (gnus-summary-scroll-up (* amount direction))
10751 (when (gnus-eval-in-buffer-window gnus-article-buffer
10754 (and (if (< 0 direction)
10755 (gnus-article-next-page 0)
10756 (gnus-article-prev-page 0)
10758 (if (setq edge (get-text-property
10759 (point-min) 'gnus-wheel-edge))
10760 (setq edge (* edge direction))
10763 (let ((buffer-read-only nil)
10764 (inhibit-read-only t))
10765 (put-text-property (point-min) (point-max)
10766 'gnus-wheel-edge direction)
10768 (or (> edge gnus-wheel-edge-resistance)
10769 (let ((buffer-read-only nil)
10770 (inhibit-read-only t))
10771 (put-text-property (point-min) (point-max)
10773 (* (1+ edge) direction))
10775 (eq last-command 'gnus-wheel-summary-scroll))))
10776 (gnus-summary-next-article nil nil (minusp direction)))))
10778 (defun gnus-wheel-install ()
10779 "Enable mouse wheel support on summary window."
10780 (when gnus-use-wheel
10782 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10784 (define-key gnus-summary-mode-map key
10785 'gnus-wheel-summary-scroll)))))
10787 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10790 ;;; Traditional PGP commmands
10793 (defun gnus-summary-decrypt-article (&optional force)
10794 "Decrypt the current article in traditional PGP way.
10795 This will have permanent effect only in mail groups.
10796 If FORCE is non-nil, allow editing of articles even in read-only
10799 (gnus-summary-select-article t)
10800 (gnus-eval-in-buffer-window gnus-article-buffer
10804 (goto-char (point-min))
10805 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10806 (error "Not a traditional PGP message!"))
10807 (let ((armor-start (match-beginning 0)))
10808 (if (and (pgg-decrypt-region armor-start (point-max))
10809 (or force (not (gnus-group-read-only-p))))
10810 (let ((inhibit-read-only t)
10812 (delete-region armor-start
10814 (re-search-forward "^-+END PGP" nil t)
10815 (beginning-of-line 2)
10817 (insert-buffer-substring pgg-output-buffer))))))))
10819 (defun gnus-summary-verify-article ()
10820 "Verify the current article in traditional PGP way."
10823 (set-buffer gnus-original-article-buffer)
10824 (goto-char (point-min))
10825 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10826 (error "Not a traditional PGP message!"))
10827 (re-search-forward "^-+END PGP" nil t)
10828 (beginning-of-line 2)
10829 (call-interactively (function pgg-verify-region))))
10832 ;;; Generic summary marking commands
10835 (defvar gnus-summary-marking-alist
10836 '((read gnus-del-mark "d")
10837 (unread gnus-unread-mark "u")
10838 (ticked gnus-ticked-mark "!")
10839 (dormant gnus-dormant-mark "?")
10840 (expirable gnus-expirable-mark "e"))
10841 "An alist of names/marks/keystrokes.")
10843 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10844 (defvar gnus-summary-mark-map)
10846 (defun gnus-summary-make-all-marking-commands ()
10847 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10848 (dolist (elem gnus-summary-marking-alist)
10849 (apply 'gnus-summary-make-marking-command elem)))
10851 (defun gnus-summary-make-marking-command (name mark keystroke)
10852 (let ((map (make-sparse-keymap)))
10853 (define-key gnus-summary-generic-mark-map keystroke map)
10854 (dolist (lway `((next "next" next nil "n")
10855 (next-unread "next unread" next t "N")
10856 (prev "previous" prev nil "p")
10857 (prev-unread "previous unread" prev t "P")
10858 (nomove "" nil nil ,keystroke)))
10859 (let ((func (gnus-summary-make-marking-command-1
10860 mark (car lway) lway name)))
10861 (setq func (eval func))
10862 (define-key map (nth 4 lway) func)))))
10864 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10866 (format "gnus-summary-put-mark-as-%s%s"
10867 name (if (eq way 'nomove)
10869 (concat "-" (symbol-name way)))))
10872 "Mark the current article as %s%s.
10873 If N, the prefix, then repeat N times.
10874 If N is negative, move in reverse order.
10875 The difference between N and the actual number of articles marked is
10877 name (car (cdr lway)))
10879 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10881 (defun gnus-summary-generic-mark (n mark move unread)
10882 "Mark N articles with MARK."
10883 (unless (eq major-mode 'gnus-summary-mode)
10884 (error "This command can only be used in the summary buffer"))
10885 (gnus-summary-show-thread)
10888 ((eq move 'next) 1)
10889 ((eq move 'prev) -1)
10891 (if (zerop nummove)
10895 nummove (* -1 nummove))))
10896 (while (and (> n 0)
10897 (gnus-summary-mark-article nil mark)
10898 (zerop (gnus-summary-next-subject nummove unread t)))
10901 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10902 (gnus-summary-recenter)
10903 (gnus-summary-position-point)
10904 (gnus-set-mode-line 'summary)
10907 (defun gnus-summary-insert-articles (articles)
10908 (when (setq articles
10909 (gnus-set-difference articles
10910 (mapcar (lambda (h) (mail-header-number h))
10911 gnus-newsgroup-headers)))
10912 (setq gnus-newsgroup-headers
10914 gnus-newsgroup-headers
10915 (gnus-fetch-headers articles)
10916 'gnus-article-sort-by-number))
10917 ;; Suppress duplicates?
10918 (when gnus-suppress-duplicates
10919 (gnus-dup-suppress-articles))
10921 ;; We might want to build some more threads first.
10922 (when (and gnus-fetch-old-headers
10923 (eq gnus-headers-retrieved-by 'nov))
10924 (if (eq gnus-fetch-old-headers 'invisible)
10925 (gnus-build-all-threads)
10926 (gnus-build-old-threads)))
10927 ;; Let the Gnus agent mark articles as read.
10929 (gnus-agent-get-undownloaded-list))
10930 ;; Remove list identifiers from subject
10931 (when gnus-list-identifiers
10932 (gnus-summary-remove-list-identifiers))
10933 ;; First and last article in this newsgroup.
10934 (when gnus-newsgroup-headers
10935 (setq gnus-newsgroup-begin
10936 (mail-header-number (car gnus-newsgroup-headers))
10938 (mail-header-number
10939 (gnus-last-element gnus-newsgroup-headers))))
10940 (when gnus-use-scoring
10941 (gnus-possibly-score-headers))))
10943 (defun gnus-summary-insert-old-articles (&optional all)
10944 "Insert all old articles in this group.
10945 If ALL is non-nil, already read articles become readable.
10946 If ALL is a number, fetch this number of articles."
10949 (let ((old (mapcar 'car gnus-newsgroup-data))
10950 (i (car gnus-newsgroup-active))
10952 (while (<= i (cdr gnus-newsgroup-active))
10953 (or (memq i old) (push i older))
10955 (setq len (length older))
10960 (setq older (subseq older 0 all))))
10963 (if (and (numberp gnus-large-newsgroup)
10964 (> len gnus-large-newsgroup))
10968 "How many articles from %s (default %d): "
10970 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10972 (unless (string-match "^[ \t]*$" input)
10973 (setq all (string-to-number input))
10975 (setq older (subseq older 0 all))))))))
10977 (message "No old news.")
10978 (gnus-summary-insert-articles older)
10979 (gnus-summary-limit (gnus-union older old))))
10980 (gnus-summary-position-point)))
10982 (defun gnus-summary-insert-new-articles ()
10983 "Insert all new articles in this group."
10986 (let ((old (mapcar 'car gnus-newsgroup-data))
10987 (old-active gnus-newsgroup-active)
10988 (nnmail-fetched-sources (list t))
10990 (setq gnus-newsgroup-active
10991 (gnus-activate-group gnus-newsgroup-name 'scan))
10992 (setq i (1+ (cdr old-active)))
10993 (while (<= i (cdr gnus-newsgroup-active))
10997 (message "No gnus is bad news.")
10998 (setq new (nreverse new))
10999 (gnus-summary-insert-articles new)
11000 (setq gnus-newsgroup-unreads
11001 (append gnus-newsgroup-unreads new))
11002 (gnus-summary-limit (gnus-union old new))))
11003 (gnus-summary-position-point)))
11005 (gnus-summary-make-all-marking-commands)
11007 (gnus-ems-redefine)
11009 (provide 'gnus-sum)
11011 (run-hooks 'gnus-sum-load-hook)
11013 ;;; gnus-sum.el ends here