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))
41 ;; (require 'gnus-art)
50 (autoload 'gnus-cache-articles-in-group "gnus-cache")
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-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 If threads are hidden, you have to run the command
238 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
239 to expose hidden threads."
243 (defcustom gnus-thread-hide-killed t
244 "*If non-nil, hide killed threads automatically."
248 (defcustom gnus-thread-ignore-subject t
249 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
250 If nil, articles that have different subjects from their parents will
251 start separate threads."
255 (defcustom gnus-thread-operation-ignore-subject t
256 "*If non-nil, subjects will be ignored when doing thread commands.
257 This affects commands like `gnus-summary-kill-thread' and
258 `gnus-summary-lower-thread'.
260 If this variable is nil, articles in the same thread with different
261 subjects will not be included in the operation in question. If this
262 variable is `fuzzy', only articles that have subjects that are fuzzily
263 equal will be included."
265 :type '(choice (const :tag "off" nil)
269 (defcustom gnus-thread-indent-level 4
270 "*Number that says how much each sub-thread should be indented."
274 (defcustom gnus-auto-extend-newsgroup t
275 "*If non-nil, extend newsgroup forward and backward when requested."
276 :group 'gnus-summary-choose
279 (defcustom gnus-auto-select-first t
280 "*If nil, don't select the first unread article when entering a group.
281 If this variable is `best', select the highest-scored unread article
282 in the group. If t, select the first unread article.
284 This variable can also be a function to place point on a likely
285 subject line. Useful values include `gnus-summary-first-unread-subject',
286 `gnus-summary-first-unread-article' and
287 `gnus-summary-best-unread-article'.
289 If you want to prevent automatic selection of the first unread article
290 in some newsgroups, set the variable to nil in
291 `gnus-select-group-hook'."
292 :group 'gnus-group-select
293 :type '(choice (const :tag "none" nil)
295 (sexp :menu-tag "first" t)
296 (function-item gnus-summary-first-unread-subject)
297 (function-item gnus-summary-first-unread-article)
298 (function-item gnus-summary-best-unread-article)))
300 (defcustom gnus-dont-select-after-jump-to-other-group nil
301 "If non-nil, don't select the first unread article after entering the
302 other group by the command `gnus-summary-jump-to-other-group'. If nil,
303 it is depend on the value of `gnus-auto-select-first' whether to select
305 :group 'gnus-group-select
308 (defcustom gnus-auto-select-next t
309 "*If non-nil, offer to go to the next group from the end of the previous.
310 If the value is t and the next newsgroup is empty, Gnus will exit
311 summary mode and go back to group mode. If the value is neither nil
312 nor t, Gnus will select the following unread newsgroup. In
313 particular, if the value is the symbol `quietly', the next unread
314 newsgroup will be selected without any confirmation, and if it is
315 `almost-quietly', the next group will be selected without any
316 confirmation if you are located on the last article in the group.
317 Finally, if this variable is `slightly-quietly', the `Z n' command
318 will go to the next group without confirmation."
319 :group 'gnus-summary-maneuvering
320 :type '(choice (const :tag "off" nil)
322 (const almost-quietly)
323 (const slightly-quietly)
324 (sexp :menu-tag "on" t)))
326 (defcustom gnus-auto-select-same nil
327 "*If non-nil, select the next article with the same subject.
328 If there are no more articles with the same subject, go to
329 the first unread article."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-summary-check-current nil
334 "*If non-nil, consider the current article when moving.
335 The \"unread\" movement commands will stay on the same line if the
336 current article is unread."
337 :group 'gnus-summary-maneuvering
340 (defcustom gnus-auto-center-summary t
341 "*If non-nil, always center the current summary buffer.
342 In particular, if `vertical' do only vertical recentering. If non-nil
343 and non-`vertical', do both horizontal and vertical recentering."
344 :group 'gnus-summary-maneuvering
345 :type '(choice (const :tag "none" nil)
347 (integer :tag "height")
348 (sexp :menu-tag "both" t)))
350 (defcustom gnus-show-all-headers nil
351 "*If non-nil, don't hide any headers."
352 :group 'gnus-article-hiding
353 :group 'gnus-article-headers
356 (defcustom gnus-summary-ignore-duplicates nil
357 "*If non-nil, ignore articles with identical Message-ID headers."
361 (defcustom gnus-single-article-buffer t
362 "*If non-nil, display all articles in the same buffer.
363 If nil, each group will get its own article buffer."
364 :group 'gnus-article-various
367 (defcustom gnus-break-pages t
368 "*If non-nil, do page breaking on articles.
369 The page delimiter is specified by the `gnus-page-delimiter'
371 :group 'gnus-article-various
374 (defcustom gnus-show-mime t
375 "*If non-nil, do mime processing of articles.
376 The articles will simply be fed to the function given by
377 `gnus-article-display-method-for-mime'."
378 :group 'gnus-article-mime
381 (defcustom gnus-move-split-methods nil
382 "*Variable used to suggest where articles are to be moved to.
383 It uses the same syntax as the `gnus-split-methods' variable.
384 However, whereas `gnus-split-methods' specifies file names as targets,
385 this variable specifies group names."
386 :group 'gnus-summary-mail
387 :type '(repeat (choice (list :value (fun) function)
388 (cons :value ("" "") regexp (repeat string))
391 (defcustom gnus-unread-mark ? ;Whitespace
392 "*Mark used for unread articles."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ticked-mark ?!
397 "*Mark used for ticked articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-dormant-mark ??
402 "*Mark used for dormant articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-del-mark ?r
407 "*Mark used for del'd articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-read-mark ?R
412 "*Mark used for read articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-expirable-mark ?E
417 "*Mark used for expirable articles."
418 :group 'gnus-summary-marks
421 (defcustom gnus-killed-mark ?K
422 "*Mark used for killed articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-souped-mark ?F
427 "*Mark used for killed articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-kill-file-mark ?X
432 "*Mark used for articles killed by kill files."
433 :group 'gnus-summary-marks
436 (defcustom gnus-low-score-mark ?Y
437 "*Mark used for articles with a low score."
438 :group 'gnus-summary-marks
441 (defcustom gnus-catchup-mark ?C
442 "*Mark used for articles that are caught up."
443 :group 'gnus-summary-marks
446 (defcustom gnus-replied-mark ?A
447 "*Mark used for articles that have been replied to."
448 :group 'gnus-summary-marks
451 (defcustom gnus-cached-mark ?*
452 "*Mark used for articles that are in the cache."
453 :group 'gnus-summary-marks
456 (defcustom gnus-saved-mark ?S
457 "*Mark used for articles that have been saved to."
458 :group 'gnus-summary-marks
461 (defcustom gnus-no-mark ? ;Whitespace
462 "*Mark used for articles that have no other secondary mark."
463 :group 'gnus-summary-marks
466 (defcustom gnus-ancient-mark ?O
467 "*Mark used for ancient articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-sparse-mark ?Q
472 "*Mark used for sparsely reffed articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-canceled-mark ?G
477 "*Mark used for canceled articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-duplicate-mark ?M
482 "*Mark used for duplicate articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-undownloaded-mark ?@
487 "*Mark used for articles that weren't downloaded."
488 :group 'gnus-summary-marks
491 (defcustom gnus-downloadable-mark ?%
492 "*Mark used for articles that are to be downloaded."
493 :group 'gnus-summary-marks
496 (defcustom gnus-unsendable-mark ?=
497 "*Mark used for articles that won't be sent."
498 :group 'gnus-summary-marks
501 (defcustom gnus-score-over-mark ?+
502 "*Score mark used for articles with high scores."
503 :group 'gnus-summary-marks
506 (defcustom gnus-score-below-mark ?-
507 "*Score mark used for articles with low scores."
508 :group 'gnus-summary-marks
511 (defcustom gnus-empty-thread-mark ? ;Whitespace
512 "*There is no thread under the article."
513 :group 'gnus-summary-marks
516 (defcustom gnus-not-empty-thread-mark ?=
517 "*There is a thread under the article."
518 :group 'gnus-summary-marks
521 (defcustom gnus-view-pseudo-asynchronously nil
522 "*If non-nil, Gnus will view pseudo-articles asynchronously."
523 :group 'gnus-extract-view
526 (defcustom gnus-auto-expirable-marks
527 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
528 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
529 gnus-souped-mark gnus-duplicate-mark)
530 "*The list of marks converted into expiration if a group is auto-expirable."
533 :type '(repeat character))
535 (defcustom gnus-inhibit-user-auto-expire t
536 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
541 (defcustom gnus-view-pseudos nil
542 "*If `automatic', pseudo-articles will be viewed automatically.
543 If `not-confirm', pseudos will be viewed automatically, and the user
544 will not be asked to confirm the command."
545 :group 'gnus-extract-view
546 :type '(choice (const :tag "off" nil)
548 (const not-confirm)))
550 (defcustom gnus-view-pseudos-separately t
551 "*If non-nil, one pseudo-article will be created for each file to be viewed.
552 If nil, all files that use the same viewing command will be given as a
553 list of parameters to that command."
554 :group 'gnus-extract-view
557 (defcustom gnus-insert-pseudo-articles t
558 "*If non-nil, insert pseudo-articles when decoding articles."
559 :group 'gnus-extract-view
562 (defcustom gnus-summary-dummy-line-format
564 "*The format specification for the dummy roots in the summary buffer.
565 It works along the same lines as a normal formatting string,
566 with some simple extensions.
569 :group 'gnus-threading
572 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
573 "*The format specification for the summary mode line.
574 It works along the same lines as a normal formatting string,
575 with some simple extensions:
578 %p Unprefixed group name
579 %A Current article number
580 %z Current article score
582 %U Number of unread articles in the group
583 %e Number of unselected articles in the group
584 %Z A string with unread/unselected article counts
585 %g Shortish group name
586 %S Subject of the current article
588 %s Current score file name
589 %d Number of dormant articles
590 %r Number of articles that have been marked as read in this session
591 %E Number of articles expunged by the score files"
592 :group 'gnus-summary-format
595 (defcustom gnus-list-identifiers nil
596 "Regexp that matches list identifiers to be removed from subject.
597 This can also be a list of regexps."
599 :group 'gnus-summary-format
600 :group 'gnus-article-hiding
601 :type '(choice (const :tag "none" nil)
603 (repeat :value (".*") regexp)))
605 (defcustom gnus-summary-mark-below 0
606 "*Mark all articles with a score below this variable as read.
607 This variable is local to each summary buffer and usually set by the
609 :group 'gnus-score-default
612 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
613 "*List of functions used for sorting articles in the summary buffer.
614 This variable is only used when not using a threaded display."
615 :group 'gnus-summary-sort
616 :type '(repeat (choice (function-item gnus-article-sort-by-number)
617 (function-item gnus-article-sort-by-author)
618 (function-item gnus-article-sort-by-subject)
619 (function-item gnus-article-sort-by-date)
620 (function-item gnus-article-sort-by-score)
621 (function :tag "other"))))
623 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
624 "*List of functions used for sorting threads in the summary buffer.
625 By default, threads are sorted by article number.
627 Each function takes two threads and return non-nil if the first thread
628 should be sorted before the other. If you use more than one function,
629 the primary sort function should be the last. You should probably
630 always include `gnus-thread-sort-by-number' in the list of sorting
631 functions -- preferably first.
633 Ready-made functions include `gnus-thread-sort-by-number',
634 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
635 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
636 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
637 :group 'gnus-summary-sort
638 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
639 (function-item gnus-thread-sort-by-author)
640 (function-item gnus-thread-sort-by-subject)
641 (function-item gnus-thread-sort-by-date)
642 (function-item gnus-thread-sort-by-score)
643 (function-item gnus-thread-sort-by-total-score)
644 (function :tag "other"))))
646 (defcustom gnus-thread-score-function '+
647 "*Function used for calculating the total score of a thread.
649 The function is called with the scores of the article and each
650 subthread and should then return the score of the thread.
652 Some functions you can use are `+', `max', or `min'."
653 :group 'gnus-summary-sort
656 (defcustom gnus-summary-expunge-below nil
657 "All articles that have a score less than this variable will be expunged.
658 This variable is local to the summary buffers."
659 :group 'gnus-score-default
660 :type '(choice (const :tag "off" nil)
663 (defcustom gnus-thread-expunge-below nil
664 "All threads that have a total score less than this variable will be expunged.
665 See `gnus-thread-score-function' for en explanation of what a
668 This variable is local to the summary buffers."
669 :group 'gnus-threading
670 :group 'gnus-score-default
671 :type '(choice (const :tag "off" nil)
674 (defcustom gnus-summary-mode-hook nil
675 "*A hook for Gnus summary mode.
676 This hook is run before any variables are set in the summary buffer."
677 :options '(turn-on-gnus-mailing-list-mode)
678 :group 'gnus-summary-various
681 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
682 (when (featurep 'xemacs)
683 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
684 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
685 (add-hook 'gnus-summary-mode-hook
686 'gnus-xmas-switch-horizontal-scrollbar-off))
688 (defcustom gnus-summary-menu-hook nil
689 "*Hook run after the creation of the summary mode menu."
690 :group 'gnus-summary-visual
693 (defcustom gnus-summary-exit-hook nil
694 "*A hook called on exit from the summary buffer.
695 It will be called with point in the group buffer."
696 :group 'gnus-summary-exit
699 (defcustom gnus-summary-prepare-hook nil
700 "*A hook called after the summary buffer has been generated.
701 If you want to modify the summary buffer, you can use this hook."
702 :group 'gnus-summary-various
705 (defcustom gnus-summary-prepared-hook nil
706 "*A hook called as the last thing after the summary buffer has been generated."
707 :group 'gnus-summary-various
710 (defcustom gnus-summary-generate-hook nil
711 "*A hook run just before generating the summary buffer.
712 This hook is commonly used to customize threading variables and the
714 :group 'gnus-summary-various
717 (defcustom gnus-select-group-hook nil
718 "*A hook called when a newsgroup is selected.
720 If you'd like to simplify subjects like the
721 `gnus-summary-next-same-subject' command does, you can use the
724 (setq gnus-select-group-hook
727 (mapcar (lambda (header)
728 (mail-header-set-subject
730 (gnus-simplify-subject
731 (mail-header-subject header) 're-only)))
732 gnus-newsgroup-headers))))"
733 :group 'gnus-group-select
736 (defcustom gnus-select-article-hook nil
737 "*A hook called when an article is selected."
738 :group 'gnus-summary-choose
741 (defcustom gnus-visual-mark-article-hook
742 (list 'gnus-highlight-selected-summary)
743 "*Hook run after selecting an article in the summary buffer.
744 It is meant to be used for highlighting the article in some way. It
745 is not run if `gnus-visual' is nil."
746 :group 'gnus-summary-visual
749 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
750 "*A hook called before parsing the headers."
754 (defcustom gnus-exit-group-hook nil
755 "*A hook called when exiting summary mode.
756 This hook is not called from the non-updating exit commands like `Q'."
760 (defcustom gnus-summary-update-hook
761 (list 'gnus-summary-highlight-line)
762 "*A hook called when a summary line is changed.
763 The hook will not be called if `gnus-visual' is nil.
765 The default function `gnus-summary-highlight-line' will
766 highlight the line according to the `gnus-summary-highlight'
768 :group 'gnus-summary-visual
771 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
772 "*A hook called when an article is selected for the first time.
773 The hook is intended to mark an article as read (or unread)
774 automatically when it is selected."
775 :group 'gnus-summary-choose
778 (defcustom gnus-group-no-more-groups-hook nil
779 "*A hook run when returning to group mode having no more (unread) groups."
780 :group 'gnus-group-select
783 (defcustom gnus-ps-print-hook nil
784 "*A hook run before ps-printing something from Gnus."
788 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
789 "Face used for highlighting the current article in the summary buffer."
790 :group 'gnus-summary-visual
793 (defcustom gnus-summary-highlight
794 '(((= mark gnus-canceled-mark)
795 . gnus-summary-cancelled-face)
796 ((and (> score default)
797 (or (= mark gnus-dormant-mark)
798 (= mark gnus-ticked-mark)))
799 . gnus-summary-high-ticked-face)
800 ((and (< score default)
801 (or (= mark gnus-dormant-mark)
802 (= mark gnus-ticked-mark)))
803 . gnus-summary-low-ticked-face)
804 ((or (= mark gnus-dormant-mark)
805 (= mark gnus-ticked-mark))
806 . gnus-summary-normal-ticked-face)
807 ((and (> score default) (= mark gnus-ancient-mark))
808 . gnus-summary-high-ancient-face)
809 ((and (< score default) (= mark gnus-ancient-mark))
810 . gnus-summary-low-ancient-face)
811 ((= mark gnus-ancient-mark)
812 . gnus-summary-normal-ancient-face)
813 ((and (> score default) (= mark gnus-unread-mark))
814 . gnus-summary-high-unread-face)
815 ((and (< score default) (= mark gnus-unread-mark))
816 . gnus-summary-low-unread-face)
817 ((and (memq article gnus-newsgroup-incorporated)
818 (= mark gnus-unread-mark))
819 . gnus-summary-incorporated-face)
820 ((= mark gnus-unread-mark)
821 . gnus-summary-normal-unread-face)
822 ((and (> score default) (memq mark (list gnus-downloadable-mark
823 gnus-undownloaded-mark)))
824 . gnus-summary-high-unread-face)
825 ((and (< score default) (memq mark (list gnus-downloadable-mark
826 gnus-undownloaded-mark)))
827 . gnus-summary-low-unread-face)
828 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
829 . gnus-summary-normal-unread-face)
831 . gnus-summary-high-read-face)
833 . gnus-summary-low-read-face)
835 . gnus-summary-normal-read-face))
836 "*Controls the highlighting of summary buffer lines.
838 A list of (FORM . FACE) pairs. When deciding how a a particular
839 summary line should be displayed, each form is evaluated. The content
840 of the face field after the first true form is used. You can change
841 how those summary lines are displayed, by editing the face field.
843 You can use the following variables in the FORM field.
845 score: The articles score
846 default: The default article score.
847 below: The score below which articles are automatically marked as read.
848 mark: The articles mark."
849 :group 'gnus-summary-visual
850 :type '(repeat (cons (sexp :tag "Form" nil)
853 (defcustom gnus-alter-header-function nil
854 "Function called to allow alteration of article header structures.
855 The function is called with one parameter, the article header vector,
856 which it may alter in any way.")
858 (defvar gnus-decode-encoded-word-function
859 (mime-find-field-decoder 'From 'nov)
860 "Variable that says which function should be used to decode a string with encoded words.")
862 (defcustom gnus-extra-headers nil
863 "*Extra headers to parse."
866 :type '(repeat symbol))
868 (defcustom gnus-ignored-from-addresses
869 (and user-mail-address (regexp-quote user-mail-address))
870 "*Regexp of From headers that may be suppressed in favor of To headers."
875 (gnus-define-group-parameter
878 "Return the default charset of GROUP."
879 :variable gnus-group-charset-alist
881 '(("\\(^\\|:\\)hk\\>\\|\\(^\\|:\\)tw\\>\\|\\<big5\\>" cn-big5)
882 ("\\(^\\|:\\)cn\\>\\|\\<chinese\\>" cn-gb-2312)
883 ("\\(^\\|:\\)fj\\>\\|\\(^\\|:\\)japan\\>" iso-2022-jp-2)
884 ("\\(^\\|:\\)tnn\\>\\|\\(^\\|:\\)pin\\>\\|\\(^\\|:\\)sci.lang.japan" iso-2022-7bit)
885 ("\\(^\\|:\\)relcom\\>" koi8-r)
886 ("\\(^\\|:\\)fido7\\>" koi8-r)
887 ("\\(^\\|:\\)\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
888 ("\\(^\\|:\\)israel\\>" iso-8859-1)
889 ("\\(^\\|:\\)han\\>" euc-kr)
890 ("\\(^\\|:\\)alt.chinese.text.big5\\>" chinese-big5)
891 ("\\(^\\|:\\)soc.culture.vietnamese\\>" vietnamese-viqr)
892 ("\\(^\\|:\\)\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
895 "Alist of regexps (to match group names) and default charsets to be used when reading."
896 :variable-group gnus-charset
897 :variable-type '(repeat (list (regexp :tag "Group")
898 (symbol :tag "Charset")))
899 :parameter-type '(symbol :tag "Charset")
900 :parameter-document "\
901 The default charset to use in the group.")
903 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
904 "List of charsets that should be ignored.
905 When these charsets are used in the \"charset\" parameter, the
906 default charset will be used instead."
908 :type '(repeat symbol)
909 :group 'gnus-charset)
911 (gnus-define-group-parameter
915 "Return the ignored charsets of GROUP."
916 :variable gnus-group-ignored-charsets-alist
918 '(("alt\\.chinese\\.text" iso-8859-1))
920 "Alist of regexps (to match group names) and charsets that should be ignored.
921 When these charsets are used in the \"charset\" parameter, the
922 default charset will be used instead."
923 :variable-group gnus-charset
924 :variable-type '(repeat (cons (regexp :tag "Group")
926 :parameter-type '(choice :tag "Ignored charsets"
929 :parameter-document "\
930 List of charsets that should be ignored.
932 When these charsets are used in the \"charset\" parameter, the
933 default charset will be used instead.")
935 (defcustom gnus-group-highlight-words-alist nil
936 "Alist of group regexps and highlight regexps.
937 This variable uses the same syntax as `gnus-emphasis-alist'."
939 :type '(repeat (cons (regexp :tag "Group")
940 (repeat (list (regexp :tag "Highlight regexp")
941 (number :tag "Group for entire word" 0)
942 (number :tag "Group for displayed part" 0)
944 gnus-emphasis-highlight-words)))))
945 :group 'gnus-summary-visual)
947 (defcustom gnus-use-wheel nil
948 "Use Intelli-mouse on summary movement"
950 :group 'gnus-summary-maneuvering)
952 (defcustom gnus-wheel-scroll-amount '(5 . 1)
953 "Amount to scroll messages by spinning the mouse wheel.
954 This is actually a cons cell, where the first item is the amount to scroll
955 on a normal wheel event, and the second is the amount to scroll when the
956 wheel is moved with the shift key depressed."
957 :type '(cons (integer :tag "Shift") integer)
958 :group 'gnus-summary-maneuvering)
960 (defcustom gnus-wheel-edge-resistance 2
961 "How hard it should be to change the current article
962 by moving the mouse over the edge of the article window."
964 :group 'gnus-summary-maneuvering)
966 (defcustom gnus-summary-show-article-charset-alist
968 "Alist of number and charset.
969 The article will be shown with the charset corresponding to the
971 For example: ((1 . cn-gb-2312) (2 . big5))."
973 :type '(repeat (cons (number :tag "Argument" 1)
974 (symbol :tag "Charset")))
975 :group 'gnus-charset)
977 (defcustom gnus-preserve-marks t
978 "Whether marks are preserved when moving, copying and respooling messages."
981 :group 'gnus-summary-marks)
983 (defcustom gnus-alter-articles-to-read-function nil
984 "Function to be called to alter the list of articles to be selected."
986 :group 'gnus-summary)
988 (defcustom gnus-orphan-score nil
989 "*All orphans get this score added. Set in the score file."
990 :group 'gnus-score-default
991 :type '(choice (const nil)
994 (defcustom gnus-summary-save-parts-default-mime "image/.*"
995 "*A regexp to match MIME parts when saving multiple parts of a message
996 with gnus-summary-save-parts (X m). This regexp will be used by default
997 when prompting the user for which type of files to save."
1002 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1003 "*A regexp to match MIME parts when saving multiple parts of a message
1004 with gnus-summary-save-parts (X m). This regexp will be used by default
1005 when prompting the user for which type of files to save."
1006 :group 'gnus-summary
1010 ;;; Internal variables
1012 (defvar gnus-article-mime-handles nil)
1013 (defvar gnus-article-decoded-p nil)
1014 (defvar gnus-article-charset nil)
1015 (defvar gnus-article-ignored-charsets nil)
1016 (defvar gnus-scores-exclude-files nil)
1017 (defvar gnus-page-broken nil)
1018 (defvar gnus-inhibit-mime-unbuttonizing nil)
1020 (defvar gnus-original-article nil)
1021 (defvar gnus-article-internal-prepare-hook nil)
1022 (defvar gnus-newsgroup-process-stack nil)
1024 (defvar gnus-thread-indent-array nil)
1025 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1026 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1027 "Function called to sort the articles within a thread after it has been gathered together.")
1029 (defvar gnus-summary-save-parts-type-history nil)
1030 (defvar gnus-summary-save-parts-last-directory nil)
1032 (defvar gnus-summary-save-parts-type-history nil)
1033 (defvar gnus-summary-save-parts-last-directory nil)
1035 ;; Avoid highlighting in kill files.
1036 (defvar gnus-summary-inhibit-highlight nil)
1037 (defvar gnus-newsgroup-selected-overlay nil)
1038 (defvar gnus-inhibit-limiting nil)
1039 (defvar gnus-newsgroup-adaptive-score-file nil)
1040 (defvar gnus-current-score-file nil)
1041 (defvar gnus-current-move-group nil)
1042 (defvar gnus-current-copy-group nil)
1043 (defvar gnus-current-crosspost-group nil)
1045 (defvar gnus-newsgroup-dependencies nil)
1046 (defvar gnus-newsgroup-adaptive nil)
1047 (defvar gnus-summary-display-article-function nil)
1048 (defvar gnus-summary-highlight-line-function nil
1049 "Function called after highlighting a summary line.")
1051 (defvar gnus-summary-line-format-alist
1052 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1053 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1054 (?s gnus-tmp-subject-or-nil ?s)
1055 (?n gnus-tmp-name ?s)
1056 (?A (std11-address-string
1057 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1058 (?a (or (std11-full-name-string
1059 (car (mime-entity-read-field gnus-tmp-header 'From)))
1061 (?F gnus-tmp-from ?s)
1062 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1063 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1064 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1065 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1066 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1067 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1068 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1069 (?L gnus-tmp-lines ?d)
1070 (?I gnus-tmp-indentation ?s)
1071 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1072 (?R gnus-tmp-replied ?c)
1073 (?\[ gnus-tmp-opening-bracket ?c)
1074 (?\] gnus-tmp-closing-bracket ?c)
1075 (?\> (make-string gnus-tmp-level ? ) ?s)
1076 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1077 (?i gnus-tmp-score ?d)
1078 (?z gnus-tmp-score-char ?c)
1079 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1080 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1081 (?U gnus-tmp-unread ?c)
1082 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1083 (?t (gnus-summary-number-of-articles-in-thread
1084 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1086 (?e (gnus-summary-number-of-articles-in-thread
1087 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1089 (?u gnus-tmp-user-defined ?s)
1090 (?P (gnus-pick-line-number) ?d))
1091 "An alist of format specifications that can appear in summary lines.
1092 These are paired with what variables they correspond with, along with
1093 the type of the variable (string, integer, character, etc).")
1095 (defvar gnus-summary-dummy-line-format-alist
1096 `((?S gnus-tmp-subject ?s)
1097 (?N gnus-tmp-number ?d)
1098 (?u gnus-tmp-user-defined ?s)))
1100 (defvar gnus-summary-mode-line-format-alist
1101 `((?G gnus-tmp-group-name ?s)
1102 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1103 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1104 (?A gnus-tmp-article-number ?d)
1105 (?Z gnus-tmp-unread-and-unselected ?s)
1106 (?V gnus-version ?s)
1107 (?U gnus-tmp-unread-and-unticked ?d)
1108 (?S gnus-tmp-subject ?s)
1109 (?e gnus-tmp-unselected ?d)
1110 (?u gnus-tmp-user-defined ?s)
1111 (?d (length gnus-newsgroup-dormant) ?d)
1112 (?t (length gnus-newsgroup-marked) ?d)
1113 (?r (length gnus-newsgroup-reads) ?d)
1114 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1115 (?E gnus-newsgroup-expunged-tally ?d)
1116 (?s (gnus-current-score-file-nondirectory) ?s)))
1118 (defvar gnus-last-search-regexp nil
1119 "Default regexp for article search command.")
1121 (defvar gnus-summary-search-article-matched-data nil
1122 "Last matched data of article search command. It is the local variable
1123 in `gnus-article-buffer' which consists of the list of start position,
1124 end position and text.")
1126 (defvar gnus-last-shell-command nil
1127 "Default shell command on article.")
1129 (defvar gnus-newsgroup-begin nil)
1130 (defvar gnus-newsgroup-end nil)
1131 (defvar gnus-newsgroup-last-rmail nil)
1132 (defvar gnus-newsgroup-last-mail nil)
1133 (defvar gnus-newsgroup-last-folder nil)
1134 (defvar gnus-newsgroup-last-file nil)
1135 (defvar gnus-newsgroup-auto-expire nil)
1136 (defvar gnus-newsgroup-active nil)
1138 (defvar gnus-newsgroup-data nil)
1139 (defvar gnus-newsgroup-data-reverse nil)
1140 (defvar gnus-newsgroup-limit nil)
1141 (defvar gnus-newsgroup-limits nil)
1143 (defvar gnus-newsgroup-unreads nil
1144 "List of unread articles in the current newsgroup.")
1146 (defvar gnus-newsgroup-unselected nil
1147 "List of unselected unread articles in the current newsgroup.")
1149 (defvar gnus-newsgroup-reads nil
1150 "Alist of read articles and article marks in the current newsgroup.")
1152 (defvar gnus-newsgroup-expunged-tally nil)
1154 (defvar gnus-newsgroup-marked nil
1155 "List of ticked articles in the current newsgroup (a subset of unread art).")
1157 (defvar gnus-newsgroup-killed nil
1158 "List of ranges of articles that have been through the scoring process.")
1160 (defvar gnus-newsgroup-cached nil
1161 "List of articles that come from the article cache.")
1163 (defvar gnus-newsgroup-saved nil
1164 "List of articles that have been saved.")
1166 (defvar gnus-newsgroup-kill-headers nil)
1168 (defvar gnus-newsgroup-replied nil
1169 "List of articles that have been replied to in the current newsgroup.")
1171 (defvar gnus-newsgroup-expirable nil
1172 "List of articles in the current newsgroup that can be expired.")
1174 (defvar gnus-newsgroup-processable nil
1175 "List of articles in the current newsgroup that can be processed.")
1177 (defvar gnus-newsgroup-downloadable nil
1178 "List of articles in the current newsgroup that can be processed.")
1180 (defvar gnus-newsgroup-undownloaded nil
1181 "List of articles in the current newsgroup that haven't been downloaded..")
1183 (defvar gnus-newsgroup-unsendable nil
1184 "List of articles in the current newsgroup that won't be sent.")
1186 (defvar gnus-newsgroup-bookmarks nil
1187 "List of articles in the current newsgroup that have bookmarks.")
1189 (defvar gnus-newsgroup-dormant nil
1190 "List of dormant articles in the current newsgroup.")
1192 (defvar gnus-newsgroup-scored nil
1193 "List of scored articles in the current newsgroup.")
1195 (defvar gnus-newsgroup-incorporated nil
1196 "List of incorporated articles in the current newsgroup.")
1198 (defvar gnus-newsgroup-headers nil
1199 "List of article headers in the current newsgroup.")
1201 (defvar gnus-newsgroup-threads nil)
1203 (defvar gnus-newsgroup-prepared nil
1204 "Whether the current group has been prepared properly.")
1206 (defvar gnus-newsgroup-ancient nil
1207 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1209 (defvar gnus-newsgroup-sparse nil)
1211 (defvar gnus-current-article nil)
1212 (defvar gnus-article-current nil)
1213 (defvar gnus-current-headers nil)
1214 (defvar gnus-have-all-headers nil)
1215 (defvar gnus-last-article nil)
1216 (defvar gnus-newsgroup-history nil)
1217 (defvar gnus-newsgroup-charset nil)
1218 (defvar gnus-newsgroup-ephemeral-charset nil)
1219 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1221 (defvar gnus-article-before-search nil)
1223 (defconst gnus-summary-local-variables
1224 '(gnus-newsgroup-name
1225 gnus-newsgroup-begin gnus-newsgroup-end
1226 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1227 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1228 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1229 gnus-newsgroup-unselected gnus-newsgroup-marked
1230 gnus-newsgroup-reads gnus-newsgroup-saved
1231 gnus-newsgroup-replied gnus-newsgroup-expirable
1232 gnus-newsgroup-processable gnus-newsgroup-killed
1233 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1234 gnus-newsgroup-unsendable
1235 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1236 gnus-newsgroup-headers gnus-newsgroup-threads
1237 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1238 gnus-current-article gnus-current-headers gnus-have-all-headers
1239 gnus-last-article gnus-article-internal-prepare-hook
1240 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1241 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1242 gnus-thread-expunge-below
1243 gnus-score-alist gnus-current-score-file
1244 (gnus-summary-expunge-below . global)
1245 (gnus-summary-mark-below . global)
1246 (gnus-orphan-score . global)
1247 gnus-newsgroup-active gnus-scores-exclude-files
1248 gnus-newsgroup-history gnus-newsgroup-ancient
1249 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1250 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1251 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1252 (gnus-newsgroup-expunged-tally . 0)
1253 gnus-cache-removable-articles gnus-newsgroup-cached
1254 gnus-newsgroup-data gnus-newsgroup-data-reverse
1255 gnus-newsgroup-limit gnus-newsgroup-limits
1256 gnus-newsgroup-charset
1257 gnus-newsgroup-incorporated)
1258 "Variables that are buffer-local to the summary buffers.")
1260 (defvar gnus-newsgroup-variables nil
1261 "Variables that have separate values in the newsgroups.")
1263 ;; Byte-compiler warning.
1264 (eval-when-compile (defvar gnus-article-mode-map))
1266 ;; Subject simplification.
1268 (defun gnus-simplify-whitespace (str)
1269 "Remove excessive whitespace from STR."
1272 (while (string-match "[ \t][ \t]+" mystr)
1273 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1275 (substring mystr (match-end 0)))))
1277 (when (string-match "^[ \t]+" mystr)
1278 (setq mystr (substring mystr (match-end 0))))
1280 (when (string-match "[ \t]+$" mystr)
1281 (setq mystr (substring mystr 0 (match-beginning 0))))
1284 (defsubst gnus-simplify-subject-re (subject)
1285 "Remove \"Re:\" from subject lines."
1286 (if (string-match message-subject-re-regexp subject)
1287 (substring subject (match-end 0))
1290 (defun gnus-simplify-subject (subject &optional re-only)
1291 "Remove `Re:' and words in parentheses.
1292 If RE-ONLY is non-nil, strip leading `Re:'s only."
1293 (let ((case-fold-search t)) ;Ignore case.
1294 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1295 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1296 (setq subject (substring subject (match-end 0))))
1297 ;; Remove uninteresting prefixes.
1298 (when (and (not re-only)
1299 gnus-simplify-ignored-prefixes
1300 (string-match gnus-simplify-ignored-prefixes subject))
1301 (setq subject (substring subject (match-end 0))))
1302 ;; Remove words in parentheses from end.
1304 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1305 (setq subject (substring subject 0 (match-beginning 0)))))
1306 ;; Return subject string.
1309 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1311 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1312 (goto-char (point-min))
1313 (while (re-search-forward regexp nil t)
1314 (replace-match (or newtext ""))))
1316 (defun gnus-simplify-buffer-fuzzy ()
1317 "Simplify string in the buffer fuzzily.
1318 The string in the accessible portion of the current buffer is simplified.
1319 It is assumed to be a single-line subject.
1320 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1321 matter is removed. Additional things can be deleted by setting
1322 `gnus-simplify-subject-fuzzy-regexp'."
1323 (let ((case-fold-search t)
1325 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1327 (while (not (eq modified-tick (buffer-modified-tick)))
1328 (setq modified-tick (buffer-modified-tick))
1330 ((listp gnus-simplify-subject-fuzzy-regexp)
1331 (mapcar 'gnus-simplify-buffer-fuzzy-step
1332 gnus-simplify-subject-fuzzy-regexp))
1333 (gnus-simplify-subject-fuzzy-regexp
1334 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1335 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1336 (gnus-simplify-buffer-fuzzy-step
1337 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1338 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1340 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1341 (gnus-simplify-buffer-fuzzy-step " +" " ")
1342 (gnus-simplify-buffer-fuzzy-step " $")
1343 (gnus-simplify-buffer-fuzzy-step "^ +")))
1345 (defun gnus-simplify-subject-fuzzy (subject)
1346 "Simplify a subject string fuzzily.
1347 See `gnus-simplify-buffer-fuzzy' for details."
1349 (gnus-set-work-buffer)
1350 (let ((case-fold-search t))
1351 ;; Remove uninteresting prefixes.
1352 (when (and gnus-simplify-ignored-prefixes
1353 (string-match gnus-simplify-ignored-prefixes subject))
1354 (setq subject (substring subject (match-end 0))))
1356 (inline (gnus-simplify-buffer-fuzzy))
1359 (defsubst gnus-simplify-subject-fully (subject)
1360 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1362 (gnus-simplify-subject-functions
1363 (gnus-map-function gnus-simplify-subject-functions subject))
1364 ((null gnus-summary-gather-subject-limit)
1365 (gnus-simplify-subject-re subject))
1366 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1367 (gnus-simplify-subject-fuzzy subject))
1368 ((numberp gnus-summary-gather-subject-limit)
1369 (gnus-limit-string (gnus-simplify-subject-re subject)
1370 gnus-summary-gather-subject-limit))
1374 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1375 "Check whether two subjects are equal.
1376 If optional argument simple-first is t, first argument is already
1379 ((null simple-first)
1380 (equal (gnus-simplify-subject-fully s1)
1381 (gnus-simplify-subject-fully s2)))
1384 (gnus-simplify-subject-fully s2)))))
1386 (defun gnus-summary-bubble-group ()
1387 "Increase the score of the current group.
1388 This is a handy function to add to `gnus-summary-exit-hook' to
1389 increase the score of each group you read."
1390 (gnus-group-add-score gnus-newsgroup-name))
1394 ;;; Gnus summary mode
1397 (put 'gnus-summary-mode 'mode-class 'special)
1399 (defvar gnus-article-commands-menu)
1402 ;; Non-orthogonal keys
1404 (gnus-define-keys gnus-summary-mode-map
1405 " " gnus-summary-next-page
1406 "\177" gnus-summary-prev-page
1407 [delete] gnus-summary-prev-page
1408 [backspace] gnus-summary-prev-page
1409 "\r" gnus-summary-scroll-up
1410 "\M-\r" gnus-summary-scroll-down
1411 "n" gnus-summary-next-unread-article
1412 "p" gnus-summary-prev-unread-article
1413 "N" gnus-summary-next-article
1414 "P" gnus-summary-prev-article
1415 "\M-\C-n" gnus-summary-next-same-subject
1416 "\M-\C-p" gnus-summary-prev-same-subject
1417 "\M-n" gnus-summary-next-unread-subject
1418 "\M-p" gnus-summary-prev-unread-subject
1419 "." gnus-summary-first-unread-article
1420 "," gnus-summary-best-unread-article
1421 "\M-s" gnus-summary-search-article-forward
1422 "\M-r" gnus-summary-search-article-backward
1423 "<" gnus-summary-beginning-of-article
1424 ">" gnus-summary-end-of-article
1425 "j" gnus-summary-goto-article
1426 "^" gnus-summary-refer-parent-article
1427 "\M-^" gnus-summary-refer-article
1428 "u" gnus-summary-tick-article-forward
1429 "!" gnus-summary-tick-article-forward
1430 "U" gnus-summary-tick-article-backward
1431 "d" gnus-summary-mark-as-read-forward
1432 "D" gnus-summary-mark-as-read-backward
1433 "E" gnus-summary-mark-as-expirable
1434 "\M-u" gnus-summary-clear-mark-forward
1435 "\M-U" gnus-summary-clear-mark-backward
1436 "k" gnus-summary-kill-same-subject-and-select
1437 "\C-k" gnus-summary-kill-same-subject
1438 "\M-\C-k" gnus-summary-kill-thread
1439 "\M-\C-l" gnus-summary-lower-thread
1440 "e" gnus-summary-edit-article
1441 "#" gnus-summary-mark-as-processable
1442 "\M-#" gnus-summary-unmark-as-processable
1443 "\M-\C-t" gnus-summary-toggle-threads
1444 "\M-\C-s" gnus-summary-show-thread
1445 "\M-\C-h" gnus-summary-hide-thread
1446 "\M-\C-f" gnus-summary-next-thread
1447 "\M-\C-b" gnus-summary-prev-thread
1448 [(meta down)] gnus-summary-next-thread
1449 [(meta up)] gnus-summary-prev-thread
1450 "\M-\C-u" gnus-summary-up-thread
1451 "\M-\C-d" gnus-summary-down-thread
1452 "&" gnus-summary-execute-command
1453 "c" gnus-summary-catchup-and-exit
1454 "\C-w" gnus-summary-mark-region-as-read
1455 "\C-t" gnus-summary-toggle-truncation
1456 "?" gnus-summary-mark-as-dormant
1457 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1458 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1459 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1460 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1461 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1462 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1463 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1464 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1465 "=" gnus-summary-expand-window
1466 "\C-x\C-s" gnus-summary-reselect-current-group
1467 "\M-g" gnus-summary-rescan-group
1468 "w" gnus-summary-stop-page-breaking
1469 "\C-c\C-r" gnus-summary-caesar-message
1470 "\M-t" gnus-summary-toggle-mime
1471 "f" gnus-summary-followup
1472 "F" gnus-summary-followup-with-original
1473 "C" gnus-summary-cancel-article
1474 "r" gnus-summary-reply
1475 "R" gnus-summary-reply-with-original
1476 "\C-c\C-f" gnus-summary-mail-forward
1477 "o" gnus-summary-save-article
1478 "\C-o" gnus-summary-save-article-mail
1479 "|" gnus-summary-pipe-output
1480 "\M-k" gnus-summary-edit-local-kill
1481 "\M-K" gnus-summary-edit-global-kill
1483 "\C-c\C-d" gnus-summary-describe-group
1484 "q" gnus-summary-exit
1485 "Q" gnus-summary-exit-no-update
1486 "\C-c\C-i" gnus-info-find-node
1487 gnus-mouse-2 gnus-mouse-pick-article
1488 "m" gnus-summary-mail-other-window
1489 "a" gnus-summary-post-news
1490 "x" gnus-summary-limit-to-unread
1491 "s" gnus-summary-isearch-article
1492 "t" gnus-article-toggle-headers
1493 "g" gnus-summary-show-article
1494 "l" gnus-summary-goto-last-article
1495 "v" gnus-summary-preview-mime-message
1496 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1497 "\C-d" gnus-summary-enter-digest-group
1498 "\M-\C-d" gnus-summary-read-document
1499 "\M-\C-e" gnus-summary-edit-parameters
1500 "\M-\C-a" gnus-summary-customize-parameters
1502 "*" gnus-cache-enter-article
1503 "\M-*" gnus-cache-remove-article
1504 "\M-&" gnus-summary-universal-argument
1505 "\C-l" gnus-recenter
1506 "I" gnus-summary-increase-score
1507 "L" gnus-summary-lower-score
1508 "\M-i" gnus-symbolic-argument
1509 "h" gnus-summary-select-article-buffer
1511 "V" gnus-summary-score-map
1512 "X" gnus-uu-extract-map
1513 "S" gnus-summary-send-map)
1515 ;; Sort of orthogonal keymap
1516 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1517 "t" gnus-summary-tick-article-forward
1518 "!" gnus-summary-tick-article-forward
1519 "d" gnus-summary-mark-as-read-forward
1520 "r" gnus-summary-mark-as-read-forward
1521 "c" gnus-summary-clear-mark-forward
1522 " " gnus-summary-clear-mark-forward
1523 "e" gnus-summary-mark-as-expirable
1524 "x" gnus-summary-mark-as-expirable
1525 "?" gnus-summary-mark-as-dormant
1526 "b" gnus-summary-set-bookmark
1527 "B" gnus-summary-remove-bookmark
1528 "#" gnus-summary-mark-as-processable
1529 "\M-#" gnus-summary-unmark-as-processable
1530 "S" gnus-summary-limit-include-expunged
1531 "C" gnus-summary-catchup
1532 "H" gnus-summary-catchup-to-here
1533 "\C-c" gnus-summary-catchup-all
1534 "k" gnus-summary-kill-same-subject-and-select
1535 "K" gnus-summary-kill-same-subject
1536 "P" gnus-uu-mark-map)
1538 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1539 "c" gnus-summary-clear-above
1540 "u" gnus-summary-tick-above
1541 "m" gnus-summary-mark-above
1542 "k" gnus-summary-kill-below)
1544 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1545 "/" gnus-summary-limit-to-subject
1546 "n" gnus-summary-limit-to-articles
1547 "w" gnus-summary-pop-limit
1548 "s" gnus-summary-limit-to-subject
1549 "a" gnus-summary-limit-to-author
1550 "u" gnus-summary-limit-to-unread
1551 "m" gnus-summary-limit-to-marks
1552 "M" gnus-summary-limit-exclude-marks
1553 "v" gnus-summary-limit-to-score
1554 "*" gnus-summary-limit-include-cached
1555 "D" gnus-summary-limit-include-dormant
1556 "T" gnus-summary-limit-include-thread
1557 "d" gnus-summary-limit-exclude-dormant
1558 "t" gnus-summary-limit-to-age
1559 "x" gnus-summary-limit-to-extra
1560 "E" gnus-summary-limit-include-expunged
1561 "c" gnus-summary-limit-exclude-childless-dormant
1562 "C" gnus-summary-limit-mark-excluded-as-read)
1564 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1565 "n" gnus-summary-next-unread-article
1566 "p" gnus-summary-prev-unread-article
1567 "N" gnus-summary-next-article
1568 "P" gnus-summary-prev-article
1569 "\C-n" gnus-summary-next-same-subject
1570 "\C-p" gnus-summary-prev-same-subject
1571 "\M-n" gnus-summary-next-unread-subject
1572 "\M-p" gnus-summary-prev-unread-subject
1573 "f" gnus-summary-first-unread-article
1574 "b" gnus-summary-best-unread-article
1575 "j" gnus-summary-goto-article
1576 "g" gnus-summary-goto-subject
1577 "l" gnus-summary-goto-last-article
1578 "o" gnus-summary-pop-article)
1580 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1581 "k" gnus-summary-kill-thread
1582 "l" gnus-summary-lower-thread
1583 "i" gnus-summary-raise-thread
1584 "T" gnus-summary-toggle-threads
1585 "t" gnus-summary-rethread-current
1586 "^" gnus-summary-reparent-thread
1587 "s" gnus-summary-show-thread
1588 "S" gnus-summary-show-all-threads
1589 "h" gnus-summary-hide-thread
1590 "H" gnus-summary-hide-all-threads
1591 "n" gnus-summary-next-thread
1592 "p" gnus-summary-prev-thread
1593 "u" gnus-summary-up-thread
1594 "o" gnus-summary-top-thread
1595 "d" gnus-summary-down-thread
1596 "#" gnus-uu-mark-thread
1597 "\M-#" gnus-uu-unmark-thread)
1599 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1600 "g" gnus-summary-prepare
1601 "c" gnus-summary-insert-cached-articles)
1603 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1604 "c" gnus-summary-catchup-and-exit
1605 "C" gnus-summary-catchup-all-and-exit
1606 "E" gnus-summary-exit-no-update
1607 "J" gnus-summary-jump-to-other-group
1608 "Q" gnus-summary-exit
1609 "Z" gnus-summary-exit
1610 "n" gnus-summary-catchup-and-goto-next-group
1611 "R" gnus-summary-reselect-current-group
1612 "G" gnus-summary-rescan-group
1613 "N" gnus-summary-next-group
1614 "s" gnus-summary-save-newsrc
1615 "P" gnus-summary-prev-group)
1617 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1618 " " gnus-summary-next-page
1619 "n" gnus-summary-next-page
1620 "\177" gnus-summary-prev-page
1621 [delete] gnus-summary-prev-page
1622 "p" gnus-summary-prev-page
1623 "\r" gnus-summary-scroll-up
1624 "\M-\r" gnus-summary-scroll-down
1625 "<" gnus-summary-beginning-of-article
1626 ">" gnus-summary-end-of-article
1627 "b" gnus-summary-beginning-of-article
1628 "e" gnus-summary-end-of-article
1629 "^" gnus-summary-refer-parent-article
1630 "r" gnus-summary-refer-parent-article
1631 "D" gnus-summary-enter-digest-group
1632 "R" gnus-summary-refer-references
1633 "T" gnus-summary-refer-thread
1634 "g" gnus-summary-show-article
1635 "s" gnus-summary-isearch-article
1636 "P" gnus-summary-print-article
1637 "M" gnus-mailing-list-insinuate
1638 "t" gnus-article-babel)
1640 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1641 "b" gnus-article-add-buttons
1642 "B" gnus-article-add-buttons-to-head
1643 "o" gnus-article-treat-overstrike
1644 "e" gnus-article-emphasize
1645 "w" gnus-article-fill-cited-article
1646 "Q" gnus-article-fill-long-lines
1647 "C" gnus-article-capitalize-sentences
1648 "c" gnus-article-remove-cr
1649 "Z" gnus-article-decode-HZ
1650 "f" gnus-article-display-x-face
1651 "l" gnus-summary-stop-page-breaking
1652 "r" gnus-summary-caesar-message
1653 "t" gnus-article-toggle-headers
1654 "v" gnus-summary-verbose-headers
1655 "m" gnus-summary-toggle-mime
1656 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1657 "p" gnus-article-verify-x-pgp-sig
1658 "d" gnus-article-treat-dumbquotes
1659 "s" gnus-smiley-display)
1661 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1662 "a" gnus-article-hide
1663 "h" gnus-article-toggle-headers
1664 "b" gnus-article-hide-boring-headers
1665 "s" gnus-article-hide-signature
1666 "c" gnus-article-hide-citation
1667 "C" gnus-article-hide-citation-in-followups
1668 "l" gnus-article-hide-list-identifiers
1669 "p" gnus-article-hide-pgp
1670 "B" gnus-article-strip-banner
1671 "P" gnus-article-hide-pem
1672 "\C-c" gnus-article-hide-citation-maybe)
1674 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1675 "a" gnus-article-highlight
1676 "h" gnus-article-highlight-headers
1677 "c" gnus-article-highlight-citation
1678 "s" gnus-article-highlight-signature)
1680 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1681 "z" gnus-article-date-ut
1682 "u" gnus-article-date-ut
1683 "l" gnus-article-date-local
1684 "p" gnus-article-date-english
1685 "e" gnus-article-date-lapsed
1686 "o" gnus-article-date-original
1687 "i" gnus-article-date-iso8601
1688 "s" gnus-article-date-user)
1690 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1691 "t" gnus-article-remove-trailing-blank-lines
1692 "l" gnus-article-strip-leading-blank-lines
1693 "m" gnus-article-strip-multiple-blank-lines
1694 "a" gnus-article-strip-blank-lines
1695 "A" gnus-article-strip-all-blank-lines
1696 "s" gnus-article-strip-leading-space
1697 "e" gnus-article-strip-trailing-space
1698 "w" gnus-article-remove-leading-whitespace)
1700 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1702 "f" gnus-summary-fetch-faq
1703 "d" gnus-summary-describe-group
1704 "h" gnus-summary-describe-briefly
1705 "i" gnus-info-find-node)
1707 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1708 "e" gnus-summary-expire-articles
1709 "\M-\C-e" gnus-summary-expire-articles-now
1710 "\177" gnus-summary-delete-article
1711 [delete] gnus-summary-delete-article
1712 [backspace] gnus-summary-delete-article
1713 "m" gnus-summary-move-article
1714 "r" gnus-summary-respool-article
1715 "w" gnus-summary-edit-article
1716 "c" gnus-summary-copy-article
1717 "B" gnus-summary-crosspost-article
1718 "q" gnus-summary-respool-query
1719 "t" gnus-summary-respool-trace
1720 "i" gnus-summary-import-article
1721 "p" gnus-summary-article-posted-p)
1723 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1724 "o" gnus-summary-save-article
1725 "m" gnus-summary-save-article-mail
1726 "F" gnus-summary-write-article-file
1727 "r" gnus-summary-save-article-rmail
1728 "f" gnus-summary-save-article-file
1729 "b" gnus-summary-save-article-body-file
1730 "h" gnus-summary-save-article-folder
1731 "v" gnus-summary-save-article-vm
1732 "p" gnus-summary-pipe-output
1733 "s" gnus-soup-add-article)
1735 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1736 "b" gnus-summary-display-buttonized
1737 "m" gnus-summary-repair-multipart
1738 "v" gnus-article-view-part
1739 "o" gnus-article-save-part
1740 "c" gnus-article-copy-part
1741 "C" gnus-article-view-part-as-charset
1742 "e" gnus-article-externalize-part
1743 "E" gnus-article-encrypt-body
1744 "i" gnus-article-inline-part
1745 "|" gnus-article-pipe-part))
1747 (defun gnus-summary-make-menu-bar ()
1748 (gnus-turn-off-edit-menu 'summary)
1750 (unless (boundp 'gnus-summary-misc-menu)
1753 gnus-summary-kill-menu gnus-summary-mode-map ""
1758 ["Customize" gnus-score-customize t])
1759 (gnus-make-score-map 'increase)
1760 (gnus-make-score-map 'lower)
1762 ["Kill below" gnus-summary-kill-below t]
1763 ["Mark above" gnus-summary-mark-above t]
1764 ["Tick above" gnus-summary-tick-above t]
1765 ["Clear above" gnus-summary-clear-above t])
1766 ["Current score" gnus-summary-current-score t]
1767 ["Set score" gnus-summary-set-score t]
1768 ["Switch current score file..." gnus-score-change-score-file t]
1769 ["Set mark below..." gnus-score-set-mark-below t]
1770 ["Set expunge below..." gnus-score-set-expunge-below t]
1771 ["Edit current score file" gnus-score-edit-current-scores t]
1772 ["Edit score file" gnus-score-edit-file t]
1773 ["Trace score" gnus-score-find-trace t]
1774 ["Find words" gnus-score-find-favourite-words t]
1775 ["Rescore buffer" gnus-summary-rescore t]
1776 ["Increase score..." gnus-summary-increase-score t]
1777 ["Lower score..." gnus-summary-lower-score t]))))
1779 ;; Define both the Article menu in the summary buffer and the equivalent
1780 ;; Commands menu in the article buffer here for consistency.
1783 ["All" gnus-article-hide t]
1784 ["Headers" gnus-article-toggle-headers t]
1785 ["Signature" gnus-article-hide-signature t]
1786 ["Citation" gnus-article-hide-citation t]
1787 ["List identifiers" gnus-article-hide-list-identifiers t]
1788 ["PGP" gnus-article-hide-pgp t]
1789 ["Banner" gnus-article-strip-banner t]
1790 ["Boring headers" gnus-article-hide-boring-headers t])
1792 ["All" gnus-article-highlight t]
1793 ["Headers" gnus-article-highlight-headers t]
1794 ["Signature" gnus-article-highlight-signature t]
1795 ["Citation" gnus-article-highlight-citation t])
1797 ["Local" gnus-article-date-local t]
1798 ["ISO8601" gnus-article-date-iso8601 t]
1799 ["UT" gnus-article-date-ut t]
1800 ["Original" gnus-article-date-original t]
1801 ["Lapsed" gnus-article-date-lapsed t]
1802 ["User-defined" gnus-article-date-user t])
1805 ["Leading" gnus-article-strip-leading-blank-lines t]
1806 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1807 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1808 ["All of the above" gnus-article-strip-blank-lines t]
1809 ["All" gnus-article-strip-all-blank-lines t]
1810 ["Leading space" gnus-article-strip-leading-space t]
1811 ["Trailing space" gnus-article-strip-trailing-space t]
1812 ["Leading space in headers"
1813 gnus-article-remove-leading-whitespace t])
1814 ["Overstrike" gnus-article-treat-overstrike t]
1815 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1816 ["Emphasis" gnus-article-emphasize t]
1817 ["Word wrap" gnus-article-fill-cited-article t]
1818 ["Fill long lines" gnus-article-fill-long-lines t]
1819 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1820 ["CR" gnus-article-remove-cr t]
1821 ["Show X-Face" gnus-article-display-x-face t]
1822 ["Rot 13" gnus-summary-caesar-message
1823 ,@(if (featurep 'xemacs) '(t)
1824 '(:help "\"Caesar rotate\" article by 13"))]
1825 ["Unix pipe" gnus-summary-pipe-message t]
1826 ["Add buttons" gnus-article-add-buttons t]
1827 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1828 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1829 ["Toggle MIME" gnus-summary-toggle-mime t]
1830 ["Verbose header" gnus-summary-verbose-headers t]
1831 ["Toggle header" gnus-summary-toggle-header t]
1832 ["Toggle smileys" gnus-smiley-display t]
1833 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1834 ["HZ" gnus-article-decode-HZ t])
1836 ["Save in default format" gnus-summary-save-article
1837 ,@(if (featurep 'xemacs) '(t)
1838 '(:help "Save article using default method"))]
1839 ["Save in file" gnus-summary-save-article-file
1840 ,@(if (featurep 'xemacs) '(t)
1841 '(:help "Save article in file"))]
1842 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1843 ["Save in MH folder" gnus-summary-save-article-folder t]
1844 ["Save in VM folder" gnus-summary-save-article-vm t]
1845 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1846 ["Save body in file" gnus-summary-save-article-body-file t]
1847 ["Pipe through a filter" gnus-summary-pipe-output t]
1848 ["Add to SOUP packet" gnus-soup-add-article t]
1849 ["Print" gnus-summary-print-article t])
1851 ["Respool article..." gnus-summary-respool-article t]
1852 ["Move article..." gnus-summary-move-article
1853 (gnus-check-backend-function
1854 'request-move-article gnus-newsgroup-name)]
1855 ["Copy article..." gnus-summary-copy-article t]
1856 ["Crosspost article..." gnus-summary-crosspost-article
1857 (gnus-check-backend-function
1858 'request-replace-article gnus-newsgroup-name)]
1859 ["Import file..." gnus-summary-import-article t]
1860 ["Check if posted" gnus-summary-article-posted-p t]
1861 ["Edit article" gnus-summary-edit-article
1862 (not (gnus-group-read-only-p))]
1863 ["Delete article" gnus-summary-delete-article
1864 (gnus-check-backend-function
1865 'request-expire-articles gnus-newsgroup-name)]
1866 ["Query respool" gnus-summary-respool-query t]
1867 ["Trace respool" gnus-summary-respool-trace t]
1868 ["Delete expirable articles" gnus-summary-expire-articles-now
1869 (gnus-check-backend-function
1870 'request-expire-articles gnus-newsgroup-name)])
1872 ["Uudecode" gnus-uu-decode-uu
1873 ,@(if (featurep 'xemacs) '(t)
1874 '(:help "Decode uuencoded article(s)"))]
1875 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1876 ["Unshar" gnus-uu-decode-unshar t]
1877 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1878 ["Save" gnus-uu-decode-save t]
1879 ["Binhex" gnus-uu-decode-binhex t]
1880 ["Postscript" gnus-uu-decode-postscript t])
1882 ["Enter article" gnus-cache-enter-article t]
1883 ["Remove article" gnus-cache-remove-article t])
1884 ["Translate" gnus-article-babel t]
1885 ["Select article buffer" gnus-summary-select-article-buffer t]
1886 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1887 ["Isearch article..." gnus-summary-isearch-article t]
1888 ["Beginning of the article" gnus-summary-beginning-of-article t]
1889 ["End of the article" gnus-summary-end-of-article t]
1890 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1891 ["Fetch referenced articles" gnus-summary-refer-references t]
1892 ["Fetch current thread" gnus-summary-refer-thread t]
1893 ["Fetch article with id..." gnus-summary-refer-article t]
1894 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1895 ["Redisplay" gnus-summary-show-article t])))
1897 gnus-summary-article-menu gnus-summary-mode-map ""
1898 (cons "Article" innards))
1900 (if (not (keymapp gnus-summary-article-menu))
1902 gnus-article-commands-menu gnus-article-mode-map ""
1903 (cons "Commands" innards))
1904 ;; in Emacs, don't share menu.
1905 (setq gnus-article-commands-menu
1906 (copy-keymap gnus-summary-article-menu))
1907 (define-key gnus-article-mode-map [menu-bar commands]
1908 (cons "Commands" gnus-article-commands-menu))))
1911 gnus-summary-thread-menu gnus-summary-mode-map ""
1913 ["Toggle threading" gnus-summary-toggle-threads t]
1914 ["Hide threads" gnus-summary-hide-all-threads t]
1915 ["Show threads" gnus-summary-show-all-threads t]
1916 ["Hide thread" gnus-summary-hide-thread t]
1917 ["Show thread" gnus-summary-show-thread t]
1918 ["Go to next thread" gnus-summary-next-thread t]
1919 ["Go to previous thread" gnus-summary-prev-thread t]
1920 ["Go down thread" gnus-summary-down-thread t]
1921 ["Go up thread" gnus-summary-up-thread t]
1922 ["Top of thread" gnus-summary-top-thread t]
1923 ["Mark thread as read" gnus-summary-kill-thread t]
1924 ["Lower thread score" gnus-summary-lower-thread t]
1925 ["Raise thread score" gnus-summary-raise-thread t]
1926 ["Rethread current" gnus-summary-rethread-current t]))
1929 gnus-summary-post-menu gnus-summary-mode-map ""
1931 ["Post an article" gnus-summary-post-news
1932 ,@(if (featurep 'xemacs) '(t)
1933 '(:help "Post an article"))]
1934 ["Followup" gnus-summary-followup
1935 ,@(if (featurep 'xemacs) '(t)
1936 '(:help "Post followup to this article"))]
1937 ["Followup and yank" gnus-summary-followup-with-original
1938 ,@(if (featurep 'xemacs) '(t)
1939 '(:help "Post followup to this article, quoting its contents"))]
1940 ["Supersede article" gnus-summary-supersede-article t]
1941 ["Cancel article" gnus-summary-cancel-article
1942 ,@(if (featurep 'xemacs) '(t)
1943 '(:help "Cancel an article you posted"))]
1944 ["Reply" gnus-summary-reply t]
1945 ["Reply and yank" gnus-summary-reply-with-original t]
1946 ["Wide reply" gnus-summary-wide-reply t]
1947 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1948 ,@(if (featurep 'xemacs) '(t)
1949 '(:help "Mail a reply, quoting this article"))]
1950 ["Mail forward" gnus-summary-mail-forward t]
1951 ["Post forward" gnus-summary-post-forward t]
1952 ["Digest and mail" gnus-uu-digest-mail-forward t]
1953 ["Digest and post" gnus-uu-digest-post-forward t]
1954 ["Resend message" gnus-summary-resend-message t]
1955 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1956 ["Send a mail" gnus-summary-mail-other-window t]
1957 ["Uuencode and post" gnus-uu-post-news
1958 ,@(if (featurep 'xemacs) '(t)
1959 '(:help "Post a uuencoded article"))]
1960 ["Followup via news" gnus-summary-followup-to-mail t]
1961 ["Followup via news and yank"
1962 gnus-summary-followup-to-mail-with-original t]
1964 ;;["Send" gnus-summary-send-draft t]
1965 ;;["Send bounced" gnus-resend-bounced-mail t])
1969 gnus-summary-misc-menu gnus-summary-mode-map ""
1972 ["Mark as read" gnus-summary-mark-as-read-forward t]
1973 ["Mark same subject and select"
1974 gnus-summary-kill-same-subject-and-select t]
1975 ["Mark same subject" gnus-summary-kill-same-subject t]
1976 ["Catchup" gnus-summary-catchup
1977 ,@(if (featurep 'xemacs) '(t)
1978 '(:help "Mark unread articles in this group as read"))]
1979 ["Catchup all" gnus-summary-catchup-all t]
1980 ["Catchup to here" gnus-summary-catchup-to-here t]
1981 ["Catchup region" gnus-summary-mark-region-as-read t]
1982 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1984 ["Tick" gnus-summary-tick-article-forward t]
1985 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1986 ["Remove marks" gnus-summary-clear-mark-forward t]
1987 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1988 ["Set bookmark" gnus-summary-set-bookmark t]
1989 ["Remove bookmark" gnus-summary-remove-bookmark t])
1991 ["Marks..." gnus-summary-limit-to-marks t]
1992 ["Subject..." gnus-summary-limit-to-subject t]
1993 ["Author..." gnus-summary-limit-to-author t]
1994 ["Age..." gnus-summary-limit-to-age t]
1995 ["Extra..." gnus-summary-limit-to-extra t]
1996 ["Score" gnus-summary-limit-to-score t]
1997 ["Unread" gnus-summary-limit-to-unread t]
1998 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1999 ["Articles" gnus-summary-limit-to-articles t]
2000 ["Pop limit" gnus-summary-pop-limit t]
2001 ["Show dormant" gnus-summary-limit-include-dormant t]
2002 ["Hide childless dormant"
2003 gnus-summary-limit-exclude-childless-dormant t]
2004 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2005 ["Hide marked" gnus-summary-limit-exclude-marks t]
2006 ["Show expunged" gnus-summary-show-all-expunged t])
2008 ["Set mark" gnus-summary-mark-as-processable t]
2009 ["Remove mark" gnus-summary-unmark-as-processable t]
2010 ["Remove all marks" gnus-summary-unmark-all-processable t]
2011 ["Mark above" gnus-uu-mark-over t]
2012 ["Mark series" gnus-uu-mark-series t]
2013 ["Mark region" gnus-uu-mark-region t]
2014 ["Unmark region" gnus-uu-unmark-region t]
2015 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2016 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2017 ["Mark all" gnus-uu-mark-all t]
2018 ["Mark buffer" gnus-uu-mark-buffer t]
2019 ["Mark sparse" gnus-uu-mark-sparse t]
2020 ["Mark thread" gnus-uu-mark-thread t]
2021 ["Unmark thread" gnus-uu-unmark-thread t]
2022 ("Process Mark Sets"
2023 ["Kill" gnus-summary-kill-process-mark t]
2024 ["Yank" gnus-summary-yank-process-mark
2025 gnus-newsgroup-process-stack]
2026 ["Save" gnus-summary-save-process-mark t]))
2028 ["Page forward" gnus-summary-next-page
2029 ,@(if (featurep 'xemacs) '(t)
2030 '(:help "Show next page of article"))]
2031 ["Page backward" gnus-summary-prev-page
2032 ,@(if (featurep 'xemacs) '(t)
2033 '(:help "Show previous page of article"))]
2034 ["Line forward" gnus-summary-scroll-up t])
2036 ["Next unread article" gnus-summary-next-unread-article t]
2037 ["Previous unread article" gnus-summary-prev-unread-article t]
2038 ["Next article" gnus-summary-next-article t]
2039 ["Previous article" gnus-summary-prev-article t]
2040 ["Next unread subject" gnus-summary-next-unread-subject t]
2041 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2042 ["Next article same subject" gnus-summary-next-same-subject t]
2043 ["Previous article same subject" gnus-summary-prev-same-subject t]
2044 ["First unread article" gnus-summary-first-unread-article t]
2045 ["Best unread article" gnus-summary-best-unread-article t]
2046 ["Go to subject number..." gnus-summary-goto-subject t]
2047 ["Go to article number..." gnus-summary-goto-article t]
2048 ["Go to the last article" gnus-summary-goto-last-article t]
2049 ["Pop article off history" gnus-summary-pop-article t])
2051 ["Sort by number" gnus-summary-sort-by-number t]
2052 ["Sort by author" gnus-summary-sort-by-author t]
2053 ["Sort by subject" gnus-summary-sort-by-subject t]
2054 ["Sort by date" gnus-summary-sort-by-date t]
2055 ["Sort by score" gnus-summary-sort-by-score t]
2056 ["Sort by lines" gnus-summary-sort-by-lines t]
2057 ["Sort by characters" gnus-summary-sort-by-chars t])
2059 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2060 ["Describe group" gnus-summary-describe-group t]
2061 ["Read manual" gnus-info-find-node t])
2063 ["Pick and read" gnus-pick-mode t]
2064 ["Binary" gnus-binary-mode t])
2066 ["Regenerate" gnus-summary-prepare t]
2067 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2068 ["Toggle threading" gnus-summary-toggle-threads t])
2069 ["Filter articles..." gnus-summary-execute-command t]
2070 ["Run command on subjects..." gnus-summary-universal-argument t]
2071 ["Search articles forward..." gnus-summary-search-article-forward t]
2072 ["Search articles backward..." gnus-summary-search-article-backward t]
2073 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2074 ["Expand window" gnus-summary-expand-window t]
2075 ["Expire expirable articles" gnus-summary-expire-articles
2076 (gnus-check-backend-function
2077 'request-expire-articles gnus-newsgroup-name)]
2078 ["Edit local kill file" gnus-summary-edit-local-kill t]
2079 ["Edit main kill file" gnus-summary-edit-global-kill t]
2080 ["Edit group parameters" gnus-summary-edit-parameters t]
2081 ["Customize group parameters" gnus-summary-customize-parameters t]
2082 ["Send a bug report" gnus-bug t]
2084 ["Catchup and exit" gnus-summary-catchup-and-exit
2085 ,@(if (featurep 'xemacs) '(t)
2086 '(:help "Mark unread articles in this group as read, then exit"))]
2087 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2088 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2089 ["Exit group" gnus-summary-exit
2090 ,@(if (featurep 'xemacs) '(t)
2091 '(:help "Exit current group, return to group selection mode"))]
2092 ["Exit group without updating" gnus-summary-exit-no-update t]
2093 ["Exit and goto next group" gnus-summary-next-group t]
2094 ["Exit and goto prev group" gnus-summary-prev-group t]
2095 ["Reselect group" gnus-summary-reselect-current-group t]
2096 ["Rescan group" gnus-summary-rescan-group t]
2097 ["Update dribble" gnus-summary-save-newsrc t])))
2099 (gnus-run-hooks 'gnus-summary-menu-hook)))
2101 (defvar gnus-summary-tool-bar-map nil)
2103 ;; Emacs 21 tool bar. Should be no-op otherwise.
2104 (defun gnus-summary-make-tool-bar ()
2105 (if (and (fboundp 'tool-bar-add-item-from-menu)
2106 (default-value 'tool-bar-mode)
2107 (not gnus-summary-tool-bar-map))
2108 (setq gnus-summary-tool-bar-map
2109 (let ((tool-bar-map (make-sparse-keymap))
2110 (load-path (mm-image-load-path)))
2111 (tool-bar-add-item-from-menu
2112 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2113 (tool-bar-add-item-from-menu
2114 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2115 (tool-bar-add-item-from-menu
2116 'gnus-summary-post-news "post" gnus-summary-mode-map)
2117 (tool-bar-add-item-from-menu
2118 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2119 (tool-bar-add-item-from-menu
2120 'gnus-summary-followup "followup" gnus-summary-mode-map)
2121 (tool-bar-add-item-from-menu
2122 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2123 (tool-bar-add-item-from-menu
2124 'gnus-summary-reply "reply" gnus-summary-mode-map)
2125 (tool-bar-add-item-from-menu
2126 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2127 (tool-bar-add-item-from-menu
2128 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2129 (tool-bar-add-item-from-menu
2130 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2131 (tool-bar-add-item-from-menu
2132 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2133 (tool-bar-add-item-from-menu
2134 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2135 (tool-bar-add-item-from-menu
2136 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2137 (tool-bar-add-item-from-menu
2138 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2139 (tool-bar-add-item-from-menu
2140 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2142 (if gnus-summary-tool-bar-map
2143 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2145 (defun gnus-score-set-default (var value)
2146 "A version of set that updates the GNU Emacs menu-bar."
2148 ;; It is the message that forces the active status to be updated.
2151 (defun gnus-make-score-map (type)
2152 "Make a summary score map of type TYPE."
2155 (let ((headers '(("author" "from" string)
2156 ("subject" "subject" string)
2157 ("article body" "body" string)
2158 ("article head" "head" string)
2159 ("xref" "xref" string)
2160 ("extra header" "extra" string)
2161 ("lines" "lines" number)
2162 ("followups to author" "followup" string)))
2163 (types '((number ("less than" <)
2166 (string ("substring" s)
2170 (perms '(("temporary" (current-time-string))
2178 (if (eq type 'lower)
2183 (setq header (car headers))
2189 (let ((ts (cdr (assoc (nth 2 header) types)))
2205 'gnus-summary-score-entry
2207 (if (or (string= (nth 1 header)
2209 (string= (nth 1 header)
2212 (list 'gnus-summary-header
2214 (list 'quote (nth 1 (car ts)))
2215 (list 'gnus-score-delta-default
2222 (list (nreverse outp))))
2225 (list (nreverse outt))))
2227 (setq headers (cdr headers)))
2228 (list (nreverse outh))))))))
2232 (defun gnus-summary-mode (&optional group)
2233 "Major mode for reading articles.
2235 All normal editing commands are switched off.
2236 \\<gnus-summary-mode-map>
2237 Each line in this buffer represents one article. To read an
2238 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2239 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2242 You can also post articles and send mail from this buffer. To
2243 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2244 of an article, type `\\[gnus-summary-reply]'.
2246 There are approx. one gazillion commands you can execute in this
2247 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2249 The following commands are available:
2251 \\{gnus-summary-mode-map}"
2253 (kill-all-local-variables)
2254 (when (gnus-visual-p 'summary-menu 'menu)
2255 (gnus-summary-make-menu-bar)
2256 (gnus-summary-make-tool-bar))
2257 (gnus-summary-make-local-variables)
2258 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2259 (gnus-summary-make-local-variables))
2260 (gnus-make-thread-indent-array)
2261 (gnus-simplify-mode-line)
2262 (setq major-mode 'gnus-summary-mode)
2263 (setq mode-name "Summary")
2264 (make-local-variable 'minor-mode-alist)
2265 (use-local-map gnus-summary-mode-map)
2266 (buffer-disable-undo)
2267 (setq buffer-read-only t) ;Disable modification
2268 (setq truncate-lines t)
2269 (setq selective-display t)
2270 (setq selective-display-ellipses t) ;Display `...'
2271 (gnus-summary-set-display-table)
2272 (gnus-set-default-directory)
2273 (setq gnus-newsgroup-name group)
2274 (unless (gnus-news-group-p group)
2275 (setq gnus-newsgroup-incorporated
2276 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2277 (make-local-variable 'gnus-summary-line-format)
2278 (make-local-variable 'gnus-summary-line-format-spec)
2279 (make-local-variable 'gnus-summary-dummy-line-format)
2280 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2281 (make-local-variable 'gnus-summary-mark-positions)
2282 (make-local-hook 'pre-command-hook)
2283 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2284 (gnus-run-hooks 'gnus-summary-mode-hook)
2285 (turn-on-gnus-mailing-list-mode)
2286 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2287 (gnus-update-summary-mark-positions))
2289 (defun gnus-summary-make-local-variables ()
2290 "Make all the local summary buffer variables."
2292 (dolist (local gnus-summary-local-variables)
2295 (if (eq (cdr local) 'global)
2296 ;; Copy the global value of the variable.
2297 (setq global (symbol-value (car local)))
2298 ;; Use the value from the list.
2299 (setq global (eval (cdr local))))
2300 (set (make-local-variable (car local)) global))
2301 ;; Simple nil-valued local variable.
2302 (set (make-local-variable local) nil)))))
2304 (defun gnus-summary-clear-local-variables ()
2305 (let ((locals gnus-summary-local-variables))
2307 (if (consp (car locals))
2308 (and (vectorp (caar locals))
2309 (set (caar locals) nil))
2310 (and (vectorp (car locals))
2311 (set (car locals) nil)))
2312 (setq locals (cdr locals)))))
2314 ;; Summary data functions.
2316 (defmacro gnus-data-number (data)
2319 (defmacro gnus-data-set-number (data number)
2320 `(setcar ,data ,number))
2322 (defmacro gnus-data-mark (data)
2325 (defmacro gnus-data-set-mark (data mark)
2326 `(setcar (nthcdr 1 ,data) ,mark))
2328 (defmacro gnus-data-pos (data)
2331 (defmacro gnus-data-set-pos (data pos)
2332 `(setcar (nthcdr 2 ,data) ,pos))
2334 (defmacro gnus-data-header (data)
2337 (defmacro gnus-data-set-header (data header)
2338 `(setcar (nthcdr 3 ,data) ,header))
2340 (defmacro gnus-data-level (data)
2343 (defmacro gnus-data-unread-p (data)
2344 `(= (nth 1 ,data) gnus-unread-mark))
2346 (defmacro gnus-data-read-p (data)
2347 `(/= (nth 1 ,data) gnus-unread-mark))
2349 (defmacro gnus-data-pseudo-p (data)
2350 `(consp (nth 3 ,data)))
2352 (defmacro gnus-data-find (number)
2353 `(assq ,number gnus-newsgroup-data))
2355 (defmacro gnus-data-find-list (number &optional data)
2356 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2357 (memq (assq ,number bdata)
2360 (defmacro gnus-data-make (number mark pos header level)
2361 `(list ,number ,mark ,pos ,header ,level))
2363 (defun gnus-data-enter (after-article number mark pos header level offset)
2364 (let ((data (gnus-data-find-list after-article)))
2366 (error "No such article: %d" after-article))
2367 (setcdr data (cons (gnus-data-make number mark pos header level)
2369 (setq gnus-newsgroup-data-reverse nil)
2370 (gnus-data-update-list (cddr data) offset)))
2372 (defun gnus-data-enter-list (after-article list &optional offset)
2374 (let ((data (and after-article (gnus-data-find-list after-article)))
2378 (let ((odata gnus-newsgroup-data))
2379 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2381 (gnus-data-update-list odata offset)))
2382 ;; Find the last element in the list to be spliced into the main
2385 (setq list (cdr list)))
2388 (setcdr list gnus-newsgroup-data)
2389 (setq gnus-newsgroup-data ilist)
2391 (gnus-data-update-list (cdr list) offset)))
2392 (setcdr list (cdr data))
2395 (gnus-data-update-list (cdr list) offset))))
2396 (setq gnus-newsgroup-data-reverse nil))))
2398 (defun gnus-data-remove (article &optional offset)
2399 (let ((data gnus-newsgroup-data))
2400 (if (= (gnus-data-number (car data)) article)
2402 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2403 gnus-newsgroup-data-reverse nil)
2405 (gnus-data-update-list gnus-newsgroup-data offset)))
2407 (when (= (gnus-data-number (cadr data)) article)
2408 (setcdr data (cddr data))
2410 (gnus-data-update-list (cdr data) offset))
2412 gnus-newsgroup-data-reverse nil))
2413 (setq data (cdr data))))))
2415 (defmacro gnus-data-list (backward)
2417 (or gnus-newsgroup-data-reverse
2418 (setq gnus-newsgroup-data-reverse
2419 (reverse gnus-newsgroup-data)))
2420 gnus-newsgroup-data))
2422 (defun gnus-data-update-list (data offset)
2423 "Add OFFSET to the POS of all data entries in DATA."
2424 (setq gnus-newsgroup-data-reverse nil)
2426 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2427 (setq data (cdr data))))
2429 (defun gnus-summary-article-pseudo-p (article)
2430 "Say whether this article is a pseudo article or not."
2431 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2433 (defmacro gnus-summary-article-sparse-p (article)
2434 "Say whether this article is a sparse article or not."
2435 `(memq ,article gnus-newsgroup-sparse))
2437 (defmacro gnus-summary-article-ancient-p (article)
2438 "Say whether this article is a sparse article or not."
2439 `(memq ,article gnus-newsgroup-ancient))
2441 (defun gnus-article-parent-p (number)
2442 "Say whether this article is a parent or not."
2443 (let ((data (gnus-data-find-list number)))
2444 (and (cdr data) ; There has to be an article after...
2445 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2446 (gnus-data-level (nth 1 data))))))
2448 (defun gnus-article-children (number)
2449 "Return a list of all children to NUMBER."
2450 (let* ((data (gnus-data-find-list number))
2451 (level (gnus-data-level (car data)))
2453 (setq data (cdr data))
2455 (= (gnus-data-level (car data)) (1+ level)))
2456 (push (gnus-data-number (car data)) children)
2457 (setq data (cdr data)))
2460 (defmacro gnus-summary-skip-intangible ()
2461 "If the current article is intangible, then jump to a different article."
2462 '(let ((to (get-text-property (point) 'gnus-intangible)))
2463 (and to (gnus-summary-goto-subject to))))
2465 (defmacro gnus-summary-article-intangible-p ()
2466 "Say whether this article is intangible or not."
2467 '(get-text-property (point) 'gnus-intangible))
2469 (defun gnus-article-read-p (article)
2470 "Say whether ARTICLE is read or not."
2471 (not (or (memq article gnus-newsgroup-marked)
2472 (memq article gnus-newsgroup-unreads)
2473 (memq article gnus-newsgroup-unselected)
2474 (memq article gnus-newsgroup-dormant))))
2476 ;; Some summary mode macros.
2478 (defmacro gnus-summary-article-number ()
2479 "The article number of the article on the current line.
2480 If there isn's an article number here, then we return the current
2483 (gnus-summary-skip-intangible)
2484 (or (get-text-property (point) 'gnus-number)
2485 (gnus-summary-last-subject))))
2487 (defmacro gnus-summary-article-header (&optional number)
2488 "Return the header of article NUMBER."
2489 `(gnus-data-header (gnus-data-find
2490 ,(or number '(gnus-summary-article-number)))))
2492 (defmacro gnus-summary-thread-level (&optional number)
2493 "Return the level of thread that starts with article NUMBER."
2494 `(if (and (eq gnus-summary-make-false-root 'dummy)
2495 (get-text-property (point) 'gnus-intangible))
2497 (gnus-data-level (gnus-data-find
2498 ,(or number '(gnus-summary-article-number))))))
2500 (defmacro gnus-summary-article-mark (&optional number)
2501 "Return the mark of article NUMBER."
2502 `(gnus-data-mark (gnus-data-find
2503 ,(or number '(gnus-summary-article-number)))))
2505 (defmacro gnus-summary-article-pos (&optional number)
2506 "Return the position of the line of article NUMBER."
2507 `(gnus-data-pos (gnus-data-find
2508 ,(or number '(gnus-summary-article-number)))))
2510 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2511 (defmacro gnus-summary-article-subject (&optional number)
2512 "Return current subject string or nil if nothing."
2515 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2516 '(gnus-data-header (assq (gnus-summary-article-number)
2517 gnus-newsgroup-data)))))
2520 (mail-header-subject headers))))
2522 (defmacro gnus-summary-article-score (&optional number)
2523 "Return current article score."
2524 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2525 gnus-newsgroup-scored))
2526 gnus-summary-default-score 0))
2528 (defun gnus-summary-article-children (&optional number)
2529 "Return a list of article numbers that are children of article NUMBER."
2530 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2531 (level (gnus-data-level (car data)))
2533 (while (and (setq data (cdr data))
2534 (> (setq l (gnus-data-level (car data))) level))
2535 (and (= (1+ level) l)
2536 (push (gnus-data-number (car data))
2538 (nreverse children)))
2540 (defun gnus-summary-article-parent (&optional number)
2541 "Return the article number of the parent of article NUMBER."
2542 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2543 (gnus-data-list t)))
2544 (level (gnus-data-level (car data))))
2546 () ; This is a root.
2547 ;; We search until we find an article with a level less than
2548 ;; this one. That function has to be the parent.
2549 (while (and (setq data (cdr data))
2550 (not (< (gnus-data-level (car data)) level))))
2551 (and data (gnus-data-number (car data))))))
2553 (defun gnus-unread-mark-p (mark)
2554 "Say whether MARK is the unread mark."
2555 (= mark gnus-unread-mark))
2557 (defun gnus-read-mark-p (mark)
2558 "Say whether MARK is one of the marks that mark as read.
2559 This is all marks except unread, ticked, dormant, and expirable."
2560 (not (or (= mark gnus-unread-mark)
2561 (= mark gnus-ticked-mark)
2562 (= mark gnus-dormant-mark)
2563 (= mark gnus-expirable-mark))))
2565 (defmacro gnus-article-mark (number)
2566 "Return the MARK of article NUMBER.
2567 This macro should only be used when computing the mark the \"first\"
2568 time; i.e., when generating the summary lines. After that,
2569 `gnus-summary-article-mark' should be used to examine the
2572 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2573 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2574 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2575 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2576 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2577 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2578 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2579 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2580 gnus-ancient-mark))))
2582 ;; Saving hidden threads.
2584 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2585 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2587 (defmacro gnus-save-hidden-threads (&rest forms)
2588 "Save hidden threads, eval FORMS, and restore the hidden threads."
2589 (let ((config (make-symbol "config")))
2590 `(let ((,config (gnus-hidden-threads-configuration)))
2594 (gnus-restore-hidden-threads-configuration ,config)))))
2596 (defun gnus-data-compute-positions ()
2597 "Compute the positions of all articles."
2598 (setq gnus-newsgroup-data-reverse nil)
2599 (let ((data gnus-newsgroup-data))
2601 (gnus-save-hidden-threads
2602 (gnus-summary-show-all-threads)
2603 (goto-char (point-min))
2605 (while (get-text-property (point) 'gnus-intangible)
2607 (gnus-data-set-pos (car data) (+ (point) 3))
2608 (setq data (cdr data))
2609 (forward-line 1))))))
2611 (defun gnus-hidden-threads-configuration ()
2612 "Return the current hidden threads configuration."
2615 (goto-char (point-min))
2616 (while (search-forward "\r" nil t)
2617 (push (1- (point)) config))
2620 (defun gnus-restore-hidden-threads-configuration (config)
2621 "Restore hidden threads configuration from CONFIG."
2623 (let (point buffer-read-only)
2624 (while (setq point (pop config))
2625 (when (and (< point (point-max))
2627 (eq (char-after) ?\n))
2628 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2630 ;; Various summary mode internalish functions.
2632 (defun gnus-mouse-pick-article (e)
2635 (gnus-summary-next-page nil t))
2637 (defun gnus-summary-set-display-table ()
2638 "Change the display table.
2639 Odd characters have a tendency to mess
2640 up nicely formatted displays - we make all possible glyphs
2641 display only a single character."
2643 ;; We start from the standard display table, if any.
2644 (let ((table (or (copy-sequence standard-display-table)
2645 (make-display-table)))
2647 ;; Nix out all the control chars...
2648 (while (>= (setq i (1- i)) 0)
2649 (aset table i [??]))
2650 ;; ... but not newline and cr, of course. (cr is necessary for the
2651 ;; selective display).
2652 (aset table ?\n nil)
2653 (aset table ?\r nil)
2654 ;; We keep TAB as well.
2655 (aset table ?\t nil)
2656 ;; We nix out any glyphs over 126 that are not set already.
2658 (while (>= (setq i (1- i)) 127)
2659 ;; Only modify if the entry is nil.
2660 (unless (aref table i)
2661 (aset table i [??]))))
2662 (setq buffer-display-table table)))
2664 (defun gnus-summary-buffer-name (group)
2665 "Return the summary buffer name of GROUP."
2666 (concat "*Summary " group "*"))
2668 (defun gnus-summary-setup-buffer (group)
2669 "Initialize summary buffer."
2670 (let ((buffer (gnus-summary-buffer-name group)))
2671 (if (get-buffer buffer)
2674 (setq gnus-summary-buffer (current-buffer))
2675 (not gnus-newsgroup-prepared))
2676 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2677 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2678 (gnus-summary-mode group)
2680 (gnus-carpal-setup-buffer 'summary))
2681 (unless gnus-single-article-buffer
2682 (make-local-variable 'gnus-article-buffer)
2683 (make-local-variable 'gnus-article-current)
2684 (make-local-variable 'gnus-original-article-buffer))
2685 (setq gnus-newsgroup-name group)
2686 ;; Set any local variables in the group parameters.
2687 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2690 (defun gnus-set-global-variables ()
2691 "Set the global equivalents of the buffer-local variables.
2692 They are set to the latest values they had. These reflect the summary
2693 buffer that was in action when the last article was fetched."
2694 (when (eq major-mode 'gnus-summary-mode)
2695 (setq gnus-summary-buffer (current-buffer))
2696 (let ((name gnus-newsgroup-name)
2697 (marked gnus-newsgroup-marked)
2698 (unread gnus-newsgroup-unreads)
2699 (headers gnus-current-headers)
2700 (data gnus-newsgroup-data)
2701 (summary gnus-summary-buffer)
2702 (article-buffer gnus-article-buffer)
2703 (original gnus-original-article-buffer)
2704 (gac gnus-article-current)
2705 (reffed gnus-reffed-article-number)
2706 (score-file gnus-current-score-file)
2707 (default-charset gnus-newsgroup-charset)
2709 (let ((locals gnus-newsgroup-variables))
2711 (if (consp (car locals))
2712 (push (eval (caar locals)) vlist)
2713 (push (eval (car locals)) vlist))
2714 (setq locals (cdr locals)))
2715 (setq vlist (nreverse vlist)))
2717 (set-buffer gnus-group-buffer)
2718 (setq gnus-newsgroup-name name
2719 gnus-newsgroup-marked marked
2720 gnus-newsgroup-unreads unread
2721 gnus-current-headers headers
2722 gnus-newsgroup-data data
2723 gnus-article-current gac
2724 gnus-summary-buffer summary
2725 gnus-article-buffer article-buffer
2726 gnus-original-article-buffer original
2727 gnus-reffed-article-number reffed
2728 gnus-current-score-file score-file
2729 gnus-newsgroup-charset default-charset)
2730 (let ((locals gnus-newsgroup-variables))
2732 (if (consp (car locals))
2733 (set (caar locals) (pop vlist))
2734 (set (car locals) (pop vlist)))
2735 (setq locals (cdr locals))))
2736 ;; The article buffer also has local variables.
2737 (when (gnus-buffer-live-p gnus-article-buffer)
2738 (set-buffer gnus-article-buffer)
2739 (setq gnus-summary-buffer summary))))))
2741 (defun gnus-summary-article-unread-p (article)
2742 "Say whether ARTICLE is unread or not."
2743 (memq article gnus-newsgroup-unreads))
2745 (defun gnus-summary-first-article-p (&optional article)
2746 "Return whether ARTICLE is the first article in the buffer."
2747 (if (not (setq article (or article (gnus-summary-article-number))))
2749 (eq article (caar gnus-newsgroup-data))))
2751 (defun gnus-summary-last-article-p (&optional article)
2752 "Return whether ARTICLE is the last article in the buffer."
2753 (if (not (setq article (or article (gnus-summary-article-number))))
2754 ;; All non-existent numbers are the last article. :-)
2756 (not (cdr (gnus-data-find-list article)))))
2758 (defun gnus-make-thread-indent-array ()
2760 (unless (and gnus-thread-indent-array
2761 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2762 (setq gnus-thread-indent-array (make-vector 201 "")
2763 gnus-thread-indent-array-level gnus-thread-indent-level)
2765 (aset gnus-thread-indent-array n
2766 (make-string (* n gnus-thread-indent-level) ? ))
2769 (defun gnus-update-summary-mark-positions ()
2770 "Compute where the summary marks are to go."
2772 (when (gnus-buffer-exists-p gnus-summary-buffer)
2773 (set-buffer gnus-summary-buffer))
2774 (let ((gnus-replied-mark 129)
2775 (gnus-score-below-mark 130)
2776 (gnus-score-over-mark 130)
2777 (gnus-download-mark 131)
2778 (spec gnus-summary-line-format-spec)
2781 (gnus-set-work-buffer)
2782 (let ((gnus-summary-line-format-spec spec)
2783 (gnus-newsgroup-downloadable '((0 . t))))
2784 (gnus-summary-insert-line
2785 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2786 0 nil 128 t nil "" nil 1)
2787 (goto-char (point-min))
2788 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2790 (goto-char (point-min))
2791 (push (cons 'replied (and (search-forward "\201" nil t)
2794 (goto-char (point-min))
2795 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2797 (goto-char (point-min))
2798 (push (cons 'download
2799 (and (search-forward "\203" nil t) (- (point) 2)))
2801 (setq gnus-summary-mark-positions pos))))
2803 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2804 "Insert a dummy root in the summary buffer."
2806 (gnus-add-text-properties
2807 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2808 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2810 (defun gnus-summary-from-or-to-or-newsgroups (header)
2811 (let ((to (cdr (assq 'To (mail-header-extra header))))
2812 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2813 (default-mime-charset (with-current-buffer gnus-summary-buffer
2814 default-mime-charset)))
2817 gnus-ignored-from-addresses
2818 (string-match gnus-ignored-from-addresses
2819 (mail-header-from header)))
2821 (or (car (funcall gnus-extract-address-components
2823 gnus-decode-encoded-word-function to)))
2824 (funcall gnus-decode-encoded-word-function to))))
2826 gnus-ignored-from-addresses
2827 (string-match gnus-ignored-from-addresses
2828 (mail-header-from header)))
2829 (concat "=> " newsgroups))
2831 (or (car (funcall gnus-extract-address-components
2832 (mail-header-from header)))
2833 (mail-header-from header))))))
2835 (defun gnus-summary-insert-line (gnus-tmp-header
2836 gnus-tmp-level gnus-tmp-current
2837 gnus-tmp-unread gnus-tmp-replied
2838 gnus-tmp-expirable gnus-tmp-subject-or-nil
2839 &optional gnus-tmp-dummy gnus-tmp-score
2841 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2842 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2843 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2844 (gnus-tmp-score-char
2845 (if (or (null gnus-summary-default-score)
2846 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2847 gnus-summary-zcore-fuzz))
2849 (if (< gnus-tmp-score gnus-summary-default-score)
2850 gnus-score-below-mark gnus-score-over-mark)))
2852 (cond (gnus-tmp-process gnus-process-mark)
2853 ((memq gnus-tmp-current gnus-newsgroup-cached)
2855 (gnus-tmp-replied gnus-replied-mark)
2856 ((memq gnus-tmp-current gnus-newsgroup-saved)
2859 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2862 ((string-match "<[^>]+> *$" gnus-tmp-from)
2863 (let ((beg (match-beginning 0)))
2864 (or (and (string-match "^\".+\"" gnus-tmp-from)
2865 (substring gnus-tmp-from 1 (1- (match-end 0))))
2866 (substring gnus-tmp-from 0 beg))))
2867 ((string-match "(.+)" gnus-tmp-from)
2868 (substring gnus-tmp-from
2869 (1+ (match-beginning 0)) (1- (match-end 0))))
2871 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2872 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2873 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2874 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2875 (buffer-read-only nil))
2876 (when (string= gnus-tmp-name "")
2877 (setq gnus-tmp-name gnus-tmp-from))
2878 (unless (numberp gnus-tmp-lines)
2879 (setq gnus-tmp-lines 0))
2880 (gnus-put-text-property-excluding-characters-with-faces
2882 (progn (eval gnus-summary-line-format-spec) (point))
2883 'gnus-number gnus-tmp-number)
2884 (when (gnus-visual-p 'summary-highlight 'highlight)
2886 (gnus-run-hooks 'gnus-summary-update-hook)
2889 (defun gnus-summary-update-line (&optional dont-update)
2890 "Update summary line after change."
2891 (when (and gnus-summary-default-score
2892 (not gnus-summary-inhibit-highlight))
2893 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2894 (article (gnus-summary-article-number))
2895 (score (gnus-summary-article-score article)))
2897 (if (and gnus-summary-mark-below
2898 (< (gnus-summary-article-score)
2899 gnus-summary-mark-below))
2900 ;; This article has a low score, so we mark it as read.
2901 (when (memq article gnus-newsgroup-unreads)
2902 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2903 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2904 ;; This article was previously marked as read on account
2905 ;; of a low score, but now it has risen, so we mark it as
2907 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2908 (gnus-summary-update-mark
2909 (if (or (null gnus-summary-default-score)
2910 (<= (abs (- score gnus-summary-default-score))
2911 gnus-summary-zcore-fuzz))
2913 (if (< score gnus-summary-default-score)
2914 gnus-score-below-mark gnus-score-over-mark))
2916 ;; Do visual highlighting.
2917 (when (gnus-visual-p 'summary-highlight 'highlight)
2918 (gnus-run-hooks 'gnus-summary-update-hook)))))
2920 (defvar gnus-tmp-new-adopts nil)
2922 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2923 "Return the number of articles in THREAD.
2924 This may be 0 in some cases -- if none of the articles in
2925 the thread are to be displayed."
2927 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2929 ((not (listp thread))
2931 ((and (consp thread) (cdr thread))
2934 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2937 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2940 (when (and level (zerop level) gnus-tmp-new-adopts)
2943 'gnus-summary-number-of-articles-in-thread
2944 gnus-tmp-new-adopts))))
2946 (if (> number 1) gnus-not-empty-thread-mark
2947 gnus-empty-thread-mark)
2950 (defun gnus-summary-set-local-parameters (group)
2951 "Go through the local params of GROUP and set all variable specs in that list."
2952 (let ((params (gnus-group-find-parameter group))
2955 (setq elem (car params)
2956 params (cdr params))
2957 (and (consp elem) ; Has to be a cons.
2958 (consp (cdr elem)) ; The cdr has to be a list.
2959 (symbolp (car elem)) ; Has to be a symbol in there.
2960 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2961 (ignore-errors ; So we set it.
2962 (make-local-variable (car elem))
2963 (set (car elem) (eval (nth 1 elem))))))))
2965 (defun gnus-summary-read-group (group &optional show-all no-article
2966 kill-buffer no-display backward
2968 "Start reading news in newsgroup GROUP.
2969 If SHOW-ALL is non-nil, already read articles are also listed.
2970 If NO-ARTICLE is non-nil, no article is selected initially.
2971 If NO-DISPLAY, don't generate a summary buffer."
2975 (let ((gnus-auto-select-next nil))
2976 (or (gnus-summary-read-group-1
2977 group show-all no-article
2978 kill-buffer no-display
2981 select-articles nil)))))
2982 (eq gnus-auto-select-next 'quietly))
2983 (set-buffer gnus-group-buffer)
2984 ;; The entry function called above goes to the next
2985 ;; group automatically, so we go two groups back
2986 ;; if we are searching for the previous group.
2988 (gnus-group-prev-unread-group 2))
2989 (if (not (equal group (gnus-group-group-name)))
2990 (setq group (gnus-group-group-name))
2994 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2995 "Directly jump to the other GROUP from summary buffer.
2996 If SHOW-ALL is non-nil, already read articles are also listed."
2998 (if (eq gnus-summary-buffer (current-buffer))
2999 (list (completing-read
3000 "Group: " gnus-active-hashtb nil t
3001 (when (and gnus-newsgroup-name
3002 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3003 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3004 'gnus-group-history)
3006 (error "%s must be invoked from a gnus summary buffer." this-command)))
3007 (unless (or (zerop (length group))
3008 (and gnus-newsgroup-name
3009 (string-equal gnus-newsgroup-name group)))
3011 (gnus-summary-read-group group show-all
3012 gnus-dont-select-after-jump-to-other-group)))
3014 (defun gnus-summary-read-group-1 (group show-all no-article
3015 kill-buffer no-display
3016 &optional select-articles)
3017 ;; Killed foreign groups can't be entered.
3018 ;; (when (and (not (gnus-group-native-p group))
3019 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3020 ;; (error "Dead non-native groups can't be entered"))
3021 (gnus-message 5 "Retrieving newsgroup: %s..." group)
3022 (let* ((new-group (gnus-summary-setup-buffer group))
3023 (quit-config (gnus-group-quit-config group))
3024 (did-select (and new-group (gnus-select-newsgroup
3025 group show-all select-articles))))
3027 ;; This summary buffer exists already, so we just select it.
3029 (gnus-set-global-variables)
3031 (gnus-kill-or-deaden-summary kill-buffer))
3032 (gnus-configure-windows 'summary 'force)
3033 (gnus-set-mode-line 'summary)
3034 (gnus-summary-position-point)
3037 ;; We couldn't select this group.
3039 (when (and (eq major-mode 'gnus-summary-mode)
3040 (not (equal (current-buffer) kill-buffer)))
3041 (kill-buffer (current-buffer))
3042 (if (not quit-config)
3044 ;; Update the info -- marks might need to be removed,
3046 (gnus-summary-update-info)
3047 (set-buffer gnus-group-buffer)
3048 (gnus-group-jump-to-group group)
3049 (gnus-group-next-unread-group 1))
3050 (gnus-handle-ephemeral-exit quit-config)))
3051 (let ((grpinfo (gnus-get-info group)))
3052 (if (null (gnus-info-read grpinfo))
3053 (gnus-message 3 "Group %s contains no messages" group)
3054 (gnus-message 3 "Can't select group")))
3056 ;; The user did a `C-g' while prompting for number of articles,
3057 ;; so we exit this group.
3058 ((eq did-select 'quit)
3059 (and (eq major-mode 'gnus-summary-mode)
3060 (not (equal (current-buffer) kill-buffer))
3061 (kill-buffer (current-buffer)))
3063 (gnus-kill-or-deaden-summary kill-buffer))
3064 (if (not quit-config)
3066 (set-buffer gnus-group-buffer)
3067 (gnus-group-jump-to-group group)
3068 (gnus-group-next-unread-group 1)
3069 (gnus-configure-windows 'group 'force))
3070 (gnus-handle-ephemeral-exit quit-config))
3071 ;; Finally signal the quit.
3073 ;; The group was successfully selected.
3075 (gnus-set-global-variables)
3076 ;; Save the active value in effect when the group was entered.
3077 (setq gnus-newsgroup-active
3079 (gnus-active gnus-newsgroup-name)))
3080 ;; You can change the summary buffer in some way with this hook.
3081 (gnus-run-hooks 'gnus-select-group-hook)
3082 (gnus-update-format-specifications
3083 nil 'summary 'summary-mode 'summary-dummy)
3084 (gnus-update-summary-mark-positions)
3085 ;; Do score processing.
3086 (when gnus-use-scoring
3087 (gnus-possibly-score-headers))
3088 ;; Check whether to fill in the gaps in the threads.
3089 (when gnus-build-sparse-threads
3090 (gnus-build-sparse-threads))
3091 ;; Find the initial limit.
3092 (if gnus-show-threads
3094 (let ((gnus-newsgroup-dormant nil))
3095 (gnus-summary-initial-limit show-all))
3096 (gnus-summary-initial-limit show-all))
3097 ;; When untreaded, all articles are always shown.
3098 (setq gnus-newsgroup-limit
3100 (lambda (header) (mail-header-number header))
3101 gnus-newsgroup-headers)))
3102 ;; Generate the summary buffer.
3104 (gnus-summary-prepare))
3105 (when gnus-use-trees
3106 (gnus-tree-open group)
3107 (setq gnus-summary-highlight-line-function
3108 'gnus-tree-highlight-article))
3109 ;; If the summary buffer is empty, but there are some low-scored
3110 ;; articles or some excluded dormants, we include these in the
3112 (when (and (zerop (buffer-size))
3114 (cond (gnus-newsgroup-dormant
3115 (gnus-summary-limit-include-dormant))
3116 ((and gnus-newsgroup-scored show-all)
3117 (gnus-summary-limit-include-expunged t))))
3118 ;; Function `gnus-apply-kill-file' must be called in this hook.
3119 (gnus-run-hooks 'gnus-apply-kill-hook)
3120 (if (and (zerop (buffer-size))
3123 ;; This newsgroup is empty.
3124 (gnus-summary-catchup-and-exit nil t)
3125 (gnus-message 6 "No unread news")
3127 (gnus-kill-or-deaden-summary kill-buffer))
3128 ;; Return nil from this function.
3130 ;; Hide conversation thread subtrees. We cannot do this in
3131 ;; gnus-summary-prepare-hook since kill processing may not
3132 ;; work with hidden articles.
3133 (and gnus-show-threads
3134 gnus-thread-hide-subtree
3135 (gnus-summary-hide-all-threads))
3137 (gnus-kill-or-deaden-summary kill-buffer))
3138 ;; Show first unread article if requested.
3139 (if (and (not no-article)
3141 gnus-newsgroup-unreads
3142 gnus-auto-select-first)
3144 (gnus-configure-windows 'summary)
3146 ((eq gnus-auto-select-first 'best)
3147 (gnus-summary-best-unread-article))
3148 ((eq gnus-auto-select-first t)
3149 (gnus-summary-first-unread-article))
3150 ((gnus-functionp gnus-auto-select-first)
3151 (funcall gnus-auto-select-first))))
3152 ;; Don't select any articles, just move point to the first
3153 ;; article in the group.
3154 (goto-char (point-min))
3155 (gnus-summary-position-point)
3156 (gnus-configure-windows 'summary 'force)
3157 (gnus-set-mode-line 'summary))
3158 (when (get-buffer-window gnus-group-buffer t)
3159 ;; Gotta use windows, because recenter does weird stuff if
3160 ;; the current buffer ain't the displayed window.
3161 (let ((owin (selected-window)))
3162 (select-window (get-buffer-window gnus-group-buffer t))
3163 (when (gnus-group-goto-group group)
3165 (select-window owin)))
3166 ;; Mark this buffer as "prepared".
3167 (setq gnus-newsgroup-prepared t)
3168 (gnus-run-hooks 'gnus-summary-prepared-hook)
3171 (defun gnus-summary-prepare ()
3172 "Generate the summary buffer."
3174 (let ((buffer-read-only nil))
3176 (setq gnus-newsgroup-data nil
3177 gnus-newsgroup-data-reverse nil)
3178 (gnus-run-hooks 'gnus-summary-generate-hook)
3179 ;; Generate the buffer, either with threads or without.
3180 (when gnus-newsgroup-headers
3181 (gnus-summary-prepare-threads
3182 (if gnus-show-threads
3183 (gnus-sort-gathered-threads
3184 (funcall gnus-summary-thread-gathering-function
3186 (gnus-cut-threads (gnus-make-threads)))))
3187 ;; Unthreaded display.
3188 (gnus-sort-articles gnus-newsgroup-headers))))
3189 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3190 ;; Call hooks for modifying summary buffer.
3191 (goto-char (point-min))
3192 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3194 (defsubst gnus-general-simplify-subject (subject)
3195 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3198 ;; Truncate the subject.
3199 (gnus-simplify-subject-functions
3200 (gnus-map-function gnus-simplify-subject-functions subject))
3201 ((numberp gnus-summary-gather-subject-limit)
3202 (setq subject (gnus-simplify-subject-re subject))
3203 (if (> (length subject) gnus-summary-gather-subject-limit)
3204 (substring subject 0 gnus-summary-gather-subject-limit)
3206 ;; Fuzzily simplify it.
3207 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3208 (gnus-simplify-subject-fuzzy subject))
3209 ;; Just remove the leading "Re:".
3211 (gnus-simplify-subject-re subject))))
3213 (if (and gnus-summary-gather-exclude-subject
3214 (string-match gnus-summary-gather-exclude-subject subject))
3215 nil ; This article shouldn't be gathered
3218 (defun gnus-summary-simplify-subject-query ()
3219 "Query where the respool algorithm would put this article."
3221 (gnus-summary-select-article)
3223 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3225 (defun gnus-gather-threads-by-subject (threads)
3226 "Gather threads by looking at Subject headers."
3227 (if (not gnus-summary-make-false-root)
3229 (let ((hashtb (gnus-make-hashtable 1024))
3232 subject hthread whole-subject)
3234 (setq subject (gnus-general-simplify-subject
3235 (setq whole-subject (mail-header-subject
3238 (if (setq hthread (gnus-gethash subject hashtb))
3240 ;; We enter a dummy root into the thread, if we
3241 ;; haven't done that already.
3242 (unless (stringp (caar hthread))
3243 (setcar hthread (list whole-subject (car hthread))))
3244 ;; We add this new gathered thread to this gathered
3246 (setcdr (car hthread)
3247 (nconc (cdar hthread) (list (car threads))))
3248 ;; Remove it from the list of threads.
3249 (setcdr prev (cdr threads))
3250 (setq threads prev))
3251 ;; Enter this thread into the hash table.
3252 (gnus-sethash subject threads hashtb)))
3254 (setq threads (cdr threads)))
3257 (defun gnus-gather-threads-by-references (threads)
3258 "Gather threads by looking at References headers."
3259 (let ((idhashtb (gnus-make-hashtable 1024))
3260 (thhashtb (gnus-make-hashtable 1024))
3263 ids references id gthread gid entered ref)
3265 (when (setq references (mail-header-references (caar threads)))
3266 (setq id (mail-header-id (caar threads))
3267 ids (gnus-split-references references)
3269 (while (setq ref (pop ids))
3270 (setq ids (delete ref ids))
3271 (if (not (setq gid (gnus-gethash ref idhashtb)))
3273 (gnus-sethash ref id idhashtb)
3274 (gnus-sethash id threads thhashtb))
3275 (setq gthread (gnus-gethash gid thhashtb))
3277 ;; We enter a dummy root into the thread, if we
3278 ;; haven't done that already.
3279 (unless (stringp (caar gthread))
3280 (setcar gthread (list (mail-header-subject (caar gthread))
3282 ;; We add this new gathered thread to this gathered
3284 (setcdr (car gthread)
3285 (nconc (cdar gthread) (list (car threads)))))
3286 ;; Add it into the thread hash table.
3287 (gnus-sethash id gthread thhashtb)
3289 ;; Remove it from the list of threads.
3290 (setcdr prev (cdr threads))
3291 (setq threads prev))))
3293 (setq threads (cdr threads)))
3296 (defun gnus-sort-gathered-threads (threads)
3297 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3298 (let ((result threads))
3300 (when (stringp (caar threads))
3301 (setcdr (car threads)
3302 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3303 (setq threads (cdr threads)))
3306 (defun gnus-thread-loop-p (root thread)
3307 "Say whether ROOT is in THREAD."
3308 (let ((stack (list thread))
3311 (while (setq thread (pop stack))
3312 (setq th (cdr thread))
3314 (not (eq (caar th) root)))
3317 ;; We have found a loop.
3319 (setcdr thread (delq (car th) (cdr thread)))
3320 (if (boundp (setq ref-dep (intern "none"
3321 gnus-newsgroup-dependencies)))
3322 (setcdr (symbol-value ref-dep)
3323 (nconc (cdr (symbol-value ref-dep))
3325 (set ref-dep (list nil (car th))))
3328 ;; Push all the subthreads onto the stack.
3329 (push (cdr thread) stack)))
3332 (defun gnus-make-threads ()
3333 "Go through the dependency hashtb and find the roots. Return all threads."
3335 (while (catch 'infloop
3338 ;; Deal with self-referencing References loops.
3339 (when (and (car (symbol-value refs))
3346 (car (symbol-value refs)) thread))
3347 (cdr (symbol-value refs)))))))
3350 (unless (car (symbol-value refs))
3351 ;; These threads do not refer back to any other articles,
3352 ;; so they're roots.
3353 (setq threads (append (cdr (symbol-value refs)) threads))))
3354 gnus-newsgroup-dependencies)))
3357 ;; Build the thread tree.
3358 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3359 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3361 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3362 if it was already present.
3364 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3365 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3366 Message-IDs will be renamed be renamed to a unique Message-ID before
3369 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3370 (let* ((id (mail-header-id header))
3371 (id-dep (and id (intern id dependencies)))
3372 ref ref-dep ref-header)
3373 ;; Enter this `header' in the `dependencies' table.
3377 ;; The first two cases do the normal part: enter a new `header'
3378 ;; in the `dependencies' table.
3379 ((not (boundp id-dep))
3380 (set id-dep (list header)))
3381 ((null (car (symbol-value id-dep)))
3382 (setcar (symbol-value id-dep) header))
3384 ;; From here the `header' was already present in the
3385 ;; `dependencies' table.
3387 ;; Overrides an existing entry;
3388 ;; just set the header part of the entry.
3389 (setcar (symbol-value id-dep) header))
3391 ;; Renames the existing `header' to a unique Message-ID.
3392 ((not gnus-summary-ignore-duplicates)
3393 ;; An article with this Message-ID has already been seen.
3394 ;; We rename the Message-ID.
3395 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3397 (mail-header-set-id header id))
3399 ;; The last case ignores an existing entry, except it adds any
3400 ;; additional Xrefs (in case the two articles came from different
3402 ;; Also sets `header' to `nil' meaning that the `dependencies'
3403 ;; table was *not* modified.
3405 (mail-header-set-xref
3406 (car (symbol-value id-dep))
3407 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3409 (or (mail-header-xref header) "")))
3413 ;; First check if that we are not creating a References loop.
3414 (setq ref (gnus-parent-id (mail-header-references header)))
3416 (setq ref-dep (intern-soft ref dependencies))
3418 (setq ref-header (car (symbol-value ref-dep))))
3419 (if (string= id ref)
3420 ;; Yuk! This is a reference loop. Make the article be a
3423 (mail-header-set-references (car (symbol-value id-dep)) "none")
3425 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3426 (setq ref (gnus-parent-id (mail-header-references header)))
3427 (setq ref-dep (intern (or ref "none") dependencies))
3428 (if (boundp ref-dep)
3429 (setcdr (symbol-value ref-dep)
3430 (nconc (cdr (symbol-value ref-dep))
3431 (list (symbol-value id-dep))))
3432 (set ref-dep (list nil (symbol-value id-dep)))))
3435 (defun gnus-build-sparse-threads ()
3436 (let ((headers gnus-newsgroup-headers)
3437 (mail-parse-charset gnus-newsgroup-charset)
3438 (gnus-summary-ignore-duplicates t)
3439 header references generation relations
3440 subject child end new-child date)
3441 ;; First we create an alist of generations/relations, where
3442 ;; generations is how much we trust the relation, and the relation
3444 (gnus-message 7 "Making sparse threads...")
3446 (nnheader-set-temp-buffer " *gnus sparse threads*")
3447 (while (setq header (pop headers))
3448 (when (and (setq references (mail-header-references header))
3449 (not (string= references "")))
3451 (setq child (mail-header-id header)
3452 subject (mail-header-subject header)
3453 date (mail-header-date header)
3455 (while (search-backward ">" nil t)
3456 (setq end (1+ (point)))
3457 (when (search-backward "<" nil t)
3458 (setq new-child (buffer-substring (point) end))
3459 (push (list (incf generation)
3460 child (setq child new-child)
3464 (push (list (1+ generation) child nil subject) relations))
3466 (kill-buffer (current-buffer)))
3467 ;; Sort over trustworthiness.
3470 (when (gnus-dependencies-add-header
3471 (make-full-mail-header-from-decoded-header
3472 gnus-reffed-article-number
3473 (nth 3 relation) "" (or (nth 4 relation) "")
3475 (or (nth 2 relation) "") 0 0 "")
3476 gnus-newsgroup-dependencies nil)
3477 (push gnus-reffed-article-number gnus-newsgroup-limit)
3478 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3479 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3480 gnus-newsgroup-reads)
3481 (decf gnus-reffed-article-number)))
3482 (sort relations 'car-less-than-car))
3483 (gnus-message 7 "Making sparse threads...done")))
3485 (defun gnus-build-old-threads ()
3486 ;; Look at all the articles that refer back to old articles, and
3487 ;; fetch the headers for the articles that aren't there. This will
3488 ;; build complete threads - if the roots haven't been expired by the
3490 (let ((mail-parse-charset gnus-newsgroup-charset)
3494 (when (not (car (symbol-value refs)))
3495 (setq heads (cdr (symbol-value refs)))
3497 (if (memq (mail-header-number (caar heads))
3498 gnus-newsgroup-dormant)
3499 (setq heads (cdr heads))
3500 (setq id (symbol-name refs))
3501 (while (and (setq id (gnus-build-get-header id))
3502 (not (car (gnus-id-to-thread id)))))
3503 (setq heads nil)))))
3504 gnus-newsgroup-dependencies)))
3506 ;; This function has to be called with point after the article number
3507 ;; on the beginning of the line.
3508 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3509 (let ((eol (gnus-point-at-eol))
3510 (buffer (current-buffer))
3513 ;; overview: [num subject from date id refs chars lines misc]
3516 (narrow-to-region (point) eol)
3521 (make-full-mail-header
3523 (nnheader-nov-field) ; subject
3524 (nnheader-nov-field) ; from
3525 (nnheader-nov-field) ; date
3526 (nnheader-nov-read-message-id) ; id
3527 (nnheader-nov-field) ; refs
3528 (nnheader-nov-read-integer) ; chars
3529 (nnheader-nov-read-integer) ; lines
3531 (if (looking-at "Xref: ")
3532 (goto-char (match-end 0)))
3533 (nnheader-nov-field)) ; Xref
3534 (nnheader-nov-parse-extra)))) ; extra
3538 (when gnus-alter-header-function
3539 (funcall gnus-alter-header-function header))
3540 (gnus-dependencies-add-header header dependencies force-new)))
3542 (defun gnus-build-get-header (id)
3543 "Look through the buffer of NOV lines and find the header to ID.
3544 Enter this line into the dependencies hash table, and return
3545 the id of the parent article (if any)."
3546 (let ((deps gnus-newsgroup-dependencies)
3550 (set-buffer nntp-server-buffer)
3551 (let ((case-fold-search nil))
3552 (goto-char (point-min))
3553 (while (and (not found)
3554 (search-forward id nil t))
3556 (setq found (looking-at
3557 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3558 (regexp-quote id))))
3559 (or found (beginning-of-line 2)))
3563 (setq header (gnus-nov-parse-line
3564 (read (current-buffer)) deps))
3565 (gnus-parent-id (mail-header-references header))))))
3567 (let ((number (mail-header-number header)))
3568 (push number gnus-newsgroup-limit)
3569 (push header gnus-newsgroup-headers)
3570 (if (memq number gnus-newsgroup-unselected)
3572 (push number gnus-newsgroup-unreads)
3573 (setq gnus-newsgroup-unselected
3574 (delq number gnus-newsgroup-unselected)))
3575 (push number gnus-newsgroup-ancient)))))))
3577 (defun gnus-build-all-threads ()
3578 "Read all the headers."
3579 (let ((gnus-summary-ignore-duplicates t)
3580 (mail-parse-charset gnus-newsgroup-charset)
3581 (dependencies gnus-newsgroup-dependencies)
3584 (set-buffer nntp-server-buffer)
3585 (let ((case-fold-search nil))
3586 (goto-char (point-min))
3589 (setq article (read (current-buffer))
3590 header (gnus-nov-parse-line article dependencies)))
3593 (set-buffer gnus-summary-buffer)
3594 (push header gnus-newsgroup-headers)
3595 (if (memq (setq article (mail-header-number header))
3596 gnus-newsgroup-unselected)
3598 (push article gnus-newsgroup-unreads)
3599 (setq gnus-newsgroup-unselected
3600 (delq article gnus-newsgroup-unselected)))
3601 (push article gnus-newsgroup-ancient)))
3602 (forward-line 1)))))))
3604 (defun gnus-summary-update-article-line (article header)
3605 "Update the line for ARTICLE using HEADERS."
3606 (let* ((id (mail-header-id header))
3607 (thread (gnus-id-to-thread id)))
3609 (error "Article in no thread"))
3610 ;; Update the thread.
3611 (setcar thread header)
3612 (gnus-summary-goto-subject article)
3613 (let* ((datal (gnus-data-find-list article))
3615 (length (when (cdr datal)
3616 (- (gnus-data-pos data)
3617 (gnus-data-pos (cadr datal)))))
3618 (buffer-read-only nil)
3619 (level (gnus-summary-thread-level)))
3621 (gnus-summary-insert-line
3622 header level nil (gnus-article-mark article)
3623 (memq article gnus-newsgroup-replied)
3624 (memq article gnus-newsgroup-expirable)
3625 ;; Only insert the Subject string when it's different
3626 ;; from the previous Subject string.
3631 (mail-header-subject
3634 (gnus-data-find-list
3636 (gnus-data-list t)))))
3637 ;; Error on the side of excessive subjects.
3639 (mail-header-subject header)))
3641 (mail-header-subject header))
3642 nil (cdr (assq article gnus-newsgroup-scored))
3643 (memq article gnus-newsgroup-processable))
3645 (gnus-data-update-list
3646 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3648 (defun gnus-summary-update-article (article &optional iheader)
3649 "Update ARTICLE in the summary buffer."
3650 (set-buffer gnus-summary-buffer)
3651 (let* ((header (gnus-summary-article-header article))
3652 (id (mail-header-id header))
3653 (data (gnus-data-find article))
3654 (thread (gnus-id-to-thread id))
3655 (references (mail-header-references header))
3659 (when (and references
3660 (not (equal "" references)))
3663 (buffer-read-only nil)
3669 (delq thread parent)))
3670 (if (gnus-summary-insert-subject id header)
3671 ;; Set the (possibly) new article number in the data structure.
3672 (gnus-data-set-number data (gnus-id-to-article id))
3676 (defun gnus-rebuild-thread (id &optional line)
3677 "Rebuild the thread containing ID.
3678 If LINE, insert the rebuilt thread starting on line LINE."
3679 (let ((buffer-read-only nil)
3680 old-pos current thread data)
3681 (if (not gnus-show-threads)
3682 (setq thread (list (car (gnus-id-to-thread id))))
3683 ;; Get the thread this article is part of.
3684 (setq thread (gnus-remove-thread id)))
3685 (setq old-pos (gnus-point-at-bol))
3686 (setq current (save-excursion
3687 (and (zerop (forward-line -1))
3688 (gnus-summary-article-number))))
3689 ;; If this is a gathered thread, we have to go some re-gathering.
3690 (when (stringp (car thread))
3691 (let ((subject (car thread))
3693 (setq thread (cdr thread))
3695 (unless (memq (setq thr (gnus-id-to-thread
3697 (mail-header-id (caar thread)))))
3700 (setq thread (cdr thread)))
3701 ;; We now have all (unique) roots.
3702 (if (= (length roots) 1)
3703 ;; All the loose roots are now one solid root.
3704 (setq thread (car roots))
3705 (setq thread (cons subject (gnus-sort-threads roots))))))
3707 ;; We then insert this thread into the summary buffer.
3709 (goto-char (point-min))
3710 (forward-line (1- line)))
3711 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3712 (if gnus-show-threads
3713 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3714 (gnus-summary-prepare-unthreaded thread))
3715 (setq data (nreverse gnus-newsgroup-data))
3716 (setq threads gnus-newsgroup-threads))
3717 ;; We splice the new data into the data structure.
3718 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3719 ;;!!! then we want to insert at the beginning of the buffer.
3720 ;;!!! That happens to be true with Gnus now, but that may
3721 ;;!!! change in the future. Perhaps.
3722 (gnus-data-enter-list
3723 (if line nil current) data (- (point) old-pos))
3724 (setq gnus-newsgroup-threads
3725 (nconc threads gnus-newsgroup-threads))
3726 (gnus-data-compute-positions))))
3728 (defun gnus-number-to-header (number)
3729 "Return the header for article NUMBER."
3730 (let ((headers gnus-newsgroup-headers))
3732 (not (= number (mail-header-number (car headers)))))
3737 (defun gnus-parent-headers (in-headers &optional generation)
3738 "Return the headers of the GENERATIONeth parent of HEADERS."
3740 (setq generation 1))
3742 (headers in-headers)
3745 (not (zerop generation))
3746 (setq references (mail-header-references headers)))
3747 (setq headers (if (and references
3748 (setq parent (gnus-parent-id references)))
3749 (car (gnus-id-to-thread parent))
3752 (and (not (eq headers in-headers))
3755 (defun gnus-id-to-thread (id)
3756 "Return the (sub-)thread where ID appears."
3757 (gnus-gethash id gnus-newsgroup-dependencies))
3759 (defun gnus-id-to-article (id)
3760 "Return the article number of ID."
3761 (let ((thread (gnus-id-to-thread id)))
3764 (mail-header-number (car thread)))))
3766 (defun gnus-id-to-header (id)
3767 "Return the article headers of ID."
3768 (car (gnus-id-to-thread id)))
3770 (defun gnus-article-displayed-root-p (article)
3771 "Say whether ARTICLE is a root(ish) article."
3772 (let ((level (gnus-summary-thread-level article))
3773 (refs (mail-header-references (gnus-summary-article-header article)))
3779 ((null (gnus-parent-id refs)) t)
3781 (null (setq particle (gnus-id-to-article
3782 (gnus-parent-id refs))))
3783 (null (gnus-summary-thread-level particle)))))))
3785 (defun gnus-root-id (id)
3786 "Return the id of the root of the thread where ID appears."
3788 (while (and id (setq prev (car (gnus-id-to-thread id))))
3790 id (gnus-parent-id (mail-header-references prev))))
3793 (defun gnus-articles-in-thread (thread)
3794 "Return the list of articles in THREAD."
3795 (cons (mail-header-number (car thread))
3796 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3798 (defun gnus-remove-thread (id &optional dont-remove)
3799 "Remove the thread that has ID in it."
3800 (let (headers thread last-id)
3801 ;; First go up in this thread until we find the root.
3802 (setq last-id (gnus-root-id id)
3803 headers (message-flatten-list (gnus-id-to-thread last-id)))
3804 ;; We have now found the real root of this thread. It might have
3805 ;; been gathered into some loose thread, so we have to search
3806 ;; through the threads to find the thread we wanted.
3807 (let ((threads gnus-newsgroup-threads)
3810 (setq sub (car threads))
3811 (if (stringp (car sub))
3812 ;; This is a gathered thread, so we look at the roots
3813 ;; below it to find whether this article is in this
3816 (setq sub (cdr sub))
3818 (when (member (caar sub) headers)
3819 (setq thread (car threads)
3822 (setq sub (cdr sub))))
3823 ;; It's an ordinary thread, so we check it.
3824 (when (eq (car sub) (car headers))
3827 (setq threads (cdr threads)))
3828 ;; If this article is in no thread, then it's a root.
3831 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3832 (setq thread (gnus-id-to-thread last-id)))
3835 thread ; We return this thread.
3837 (if (stringp (car thread))
3839 ;; If we use dummy roots, then we have to remove the
3840 ;; dummy root as well.
3841 (when (eq gnus-summary-make-false-root 'dummy)
3842 ;; We go to the dummy root by going to
3843 ;; the first sub-"thread", and then one line up.
3844 (gnus-summary-goto-article
3845 (mail-header-number (caadr thread)))
3848 (gnus-data-compute-positions))
3849 (setq thread (cdr thread))
3851 (gnus-remove-thread-1 (car thread))
3852 (setq thread (cdr thread))))
3853 (gnus-remove-thread-1 thread))))))))
3855 (defun gnus-remove-thread-1 (thread)
3856 "Remove the thread THREAD recursively."
3857 (let ((number (mail-header-number (pop thread)))
3859 (setq thread (reverse thread))
3861 (gnus-remove-thread-1 (pop thread)))
3862 (when (setq d (gnus-data-find number))
3863 (goto-char (gnus-data-pos d))
3864 (gnus-summary-show-thread)
3867 (- (gnus-point-at-bol)
3869 (1+ (gnus-point-at-eol))
3870 (gnus-delete-line)))))))
3872 (defun gnus-sort-threads-1 (threads func)
3873 (sort (mapcar (lambda (thread)
3876 (gnus-sort-threads-1 (cdr thread) func))))
3879 (defun gnus-sort-threads (threads)
3881 (if (not gnus-thread-sort-functions)
3883 (gnus-message 8 "Sorting threads...")
3885 (gnus-sort-threads-1
3887 (gnus-make-sort-function gnus-thread-sort-functions))
3888 (gnus-message 8 "Sorting threads...done"))))
3890 (defun gnus-sort-articles (articles)
3892 (when gnus-article-sort-functions
3893 (gnus-message 7 "Sorting articles...")
3895 (setq gnus-newsgroup-headers
3896 (sort articles (gnus-make-sort-function
3897 gnus-article-sort-functions)))
3898 (gnus-message 7 "Sorting articles...done"))))
3900 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3901 (defmacro gnus-thread-header (thread)
3902 "Return header of first article in THREAD.
3903 Note that THREAD must never, ever be anything else than a variable -
3904 using some other form will lead to serious barfage."
3905 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3906 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3907 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3910 (defsubst gnus-article-sort-by-number (h1 h2)
3911 "Sort articles by article number."
3912 (< (mail-header-number h1)
3913 (mail-header-number h2)))
3915 (defun gnus-thread-sort-by-number (h1 h2)
3916 "Sort threads by root article number."
3917 (gnus-article-sort-by-number
3918 (gnus-thread-header h1) (gnus-thread-header h2)))
3920 (defsubst gnus-article-sort-by-lines (h1 h2)
3921 "Sort articles by article Lines header."
3922 (< (mail-header-lines h1)
3923 (mail-header-lines h2)))
3925 (defun gnus-thread-sort-by-lines (h1 h2)
3926 "Sort threads by root article Lines header."
3927 (gnus-article-sort-by-lines
3928 (gnus-thread-header h1) (gnus-thread-header h2)))
3930 (defsubst gnus-article-sort-by-chars (h1 h2)
3931 "Sort articles by octet length."
3932 (< (mail-header-chars h1)
3933 (mail-header-chars h2)))
3935 (defun gnus-thread-sort-by-chars (h1 h2)
3936 "Sort threads by root article octet length."
3937 (gnus-article-sort-by-chars
3938 (gnus-thread-header h1) (gnus-thread-header h2)))
3940 (defsubst gnus-article-sort-by-author (h1 h2)
3941 "Sort articles by root author."
3943 (let ((addr (car (mime-entity-read-field h1 'From))))
3944 (or (std11-full-name-string addr)
3945 (std11-address-string addr)
3947 (let ((addr (car (mime-entity-read-field h2 'From))))
3948 (or (std11-full-name-string addr)
3949 (std11-address-string addr)
3953 (defun gnus-thread-sort-by-author (h1 h2)
3954 "Sort threads by root author."
3955 (gnus-article-sort-by-author
3956 (gnus-thread-header h1) (gnus-thread-header h2)))
3958 (defsubst gnus-article-sort-by-subject (h1 h2)
3959 "Sort articles by root subject."
3961 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3962 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3964 (defun gnus-thread-sort-by-subject (h1 h2)
3965 "Sort threads by root subject."
3966 (gnus-article-sort-by-subject
3967 (gnus-thread-header h1) (gnus-thread-header h2)))
3969 (defsubst gnus-article-sort-by-date (h1 h2)
3970 "Sort articles by root article date."
3972 (gnus-date-get-time (mail-header-date h1))
3973 (gnus-date-get-time (mail-header-date h2))))
3975 (defun gnus-thread-sort-by-date (h1 h2)
3976 "Sort threads by root article date."
3977 (gnus-article-sort-by-date
3978 (gnus-thread-header h1) (gnus-thread-header h2)))
3980 (defsubst gnus-article-sort-by-score (h1 h2)
3981 "Sort articles by root article score.
3982 Unscored articles will be counted as having a score of zero."
3983 (> (or (cdr (assq (mail-header-number h1)
3984 gnus-newsgroup-scored))
3985 gnus-summary-default-score 0)
3986 (or (cdr (assq (mail-header-number h2)
3987 gnus-newsgroup-scored))
3988 gnus-summary-default-score 0)))
3990 (defun gnus-thread-sort-by-score (h1 h2)
3991 "Sort threads by root article score."
3992 (gnus-article-sort-by-score
3993 (gnus-thread-header h1) (gnus-thread-header h2)))
3995 (defun gnus-thread-sort-by-total-score (h1 h2)
3996 "Sort threads by the sum of all scores in the thread.
3997 Unscored articles will be counted as having a score of zero."
3998 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4000 (defun gnus-thread-total-score (thread)
4001 ;; This function find the total score of THREAD.
4002 (cond ((null thread)
4005 (if (stringp (car thread))
4006 (apply gnus-thread-score-function 0
4007 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4008 (gnus-thread-total-score-1 thread)))
4010 (gnus-thread-total-score-1 (list thread)))))
4012 (defun gnus-thread-total-score-1 (root)
4013 ;; This function find the total score of the thread below ROOT.
4014 (setq root (car root))
4015 (apply gnus-thread-score-function
4017 (mapcar 'gnus-thread-total-score
4018 (cdr (gnus-id-to-thread (mail-header-id root))))
4019 (when (> (mail-header-number root) 0)
4020 (list (or (cdr (assq (mail-header-number root)
4021 gnus-newsgroup-scored))
4022 gnus-summary-default-score 0))))
4023 (list gnus-summary-default-score)
4026 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4027 (defvar gnus-tmp-prev-subject nil)
4028 (defvar gnus-tmp-false-parent nil)
4029 (defvar gnus-tmp-root-expunged nil)
4030 (defvar gnus-tmp-dummy-line nil)
4032 (eval-when-compile (defvar gnus-tmp-header))
4033 (defun gnus-extra-header (type &optional header)
4034 "Return the extra header of TYPE."
4035 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4038 (defun gnus-summary-prepare-threads (threads)
4039 "Prepare summary buffer from THREADS and indentation LEVEL.
4040 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4041 or a straight list of headers."
4042 (gnus-message 7 "Generating summary...")
4044 (setq gnus-newsgroup-threads threads)
4047 (let ((gnus-tmp-level 0)
4048 (default-score (or gnus-summary-default-score 0))
4049 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4050 thread number subject stack state gnus-tmp-gathered beg-match
4051 new-roots gnus-tmp-new-adopts thread-end
4052 gnus-tmp-header gnus-tmp-unread
4053 gnus-tmp-replied gnus-tmp-subject-or-nil
4054 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4055 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4056 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4058 (setq gnus-tmp-prev-subject nil)
4060 (if (vectorp (car threads))
4061 ;; If this is a straight (sic) list of headers, then a
4062 ;; threaded summary display isn't required, so we just create
4063 ;; an unthreaded one.
4064 (gnus-summary-prepare-unthreaded threads)
4066 ;; Do the threaded display.
4068 (while (or threads stack gnus-tmp-new-adopts new-roots)
4070 (if (and (= gnus-tmp-level 0)
4073 (not gnus-tmp-false-parent)
4074 (or gnus-tmp-new-adopts new-roots))
4075 (if gnus-tmp-new-adopts
4076 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4077 thread (list (car gnus-tmp-new-adopts))
4078 gnus-tmp-header (caar thread)
4079 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4081 (setq thread (list (car new-roots))
4082 gnus-tmp-header (caar thread)
4083 new-roots (cdr new-roots))))
4086 ;; If there are some threads, we do them before the
4087 ;; threads on the stack.
4088 (setq thread threads
4089 gnus-tmp-header (caar thread))
4090 ;; There were no current threads, so we pop something off
4092 (setq state (car stack)
4093 gnus-tmp-level (car state)
4096 gnus-tmp-header (caar thread))))
4098 (setq gnus-tmp-false-parent nil)
4099 (setq gnus-tmp-root-expunged nil)
4100 (setq thread-end nil)
4102 (if (stringp gnus-tmp-header)
4103 ;; The header is a dummy root.
4105 ((eq gnus-summary-make-false-root 'adopt)
4106 ;; We let the first article adopt the rest.
4107 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4109 (setq gnus-tmp-gathered
4111 (lambda (h) (mail-header-number (car h)))
4114 (setq thread (cons (list (caar thread)
4117 (setq gnus-tmp-level -1
4118 gnus-tmp-false-parent t))
4119 ((eq gnus-summary-make-false-root 'empty)
4120 ;; We print adopted articles with empty subject fields.
4121 (setq gnus-tmp-gathered
4123 (lambda (h) (mail-header-number (car h)))
4126 (setq gnus-tmp-level -1))
4127 ((eq gnus-summary-make-false-root 'dummy)
4128 ;; We remember that we probably want to output a dummy
4130 (setq gnus-tmp-dummy-line gnus-tmp-header)
4131 (setq gnus-tmp-prev-subject gnus-tmp-header))
4133 ;; We do not make a root for the gathered
4134 ;; sub-threads at all.
4135 (setq gnus-tmp-level -1)))
4137 (setq number (mail-header-number gnus-tmp-header)
4138 subject (mail-header-subject gnus-tmp-header))
4141 ;; If the thread has changed subject, we might want to make
4142 ;; this subthread into a root.
4143 ((and (null gnus-thread-ignore-subject)
4144 (not (zerop gnus-tmp-level))
4145 gnus-tmp-prev-subject
4147 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4148 (setq new-roots (nconc new-roots (list (car thread)))
4150 gnus-tmp-header nil))
4151 ;; If the article lies outside the current limit,
4152 ;; then we do not display it.
4153 ((not (memq number gnus-newsgroup-limit))
4154 (setq gnus-tmp-gathered
4156 (lambda (h) (mail-header-number (car h)))
4159 (setq gnus-tmp-new-adopts (if (cdar thread)
4160 (append gnus-tmp-new-adopts
4162 gnus-tmp-new-adopts)
4164 gnus-tmp-header nil)
4165 (when (zerop gnus-tmp-level)
4166 (setq gnus-tmp-root-expunged t)))
4167 ;; Perhaps this article is to be marked as read?
4168 ((and gnus-summary-mark-below
4169 (< (or (cdr (assq number gnus-newsgroup-scored))
4171 gnus-summary-mark-below)
4172 ;; Don't touch sparse articles.
4173 (not (gnus-summary-article-sparse-p number))
4174 (not (gnus-summary-article-ancient-p number)))
4175 (setq gnus-newsgroup-unreads
4176 (delq number gnus-newsgroup-unreads))
4177 (if gnus-newsgroup-auto-expire
4178 (push number gnus-newsgroup-expirable)
4179 (push (cons number gnus-low-score-mark)
4180 gnus-newsgroup-reads))))
4182 (when gnus-tmp-header
4183 ;; We may have an old dummy line to output before this
4185 (when (and gnus-tmp-dummy-line
4188 (mail-header-subject gnus-tmp-header)))
4189 (gnus-summary-insert-dummy-line
4190 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4191 (setq gnus-tmp-dummy-line nil))
4193 ;; Compute the mark.
4194 (setq gnus-tmp-unread (gnus-article-mark number))
4196 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4197 gnus-tmp-header gnus-tmp-level)
4198 gnus-newsgroup-data)
4200 ;; Actually insert the line.
4202 gnus-tmp-subject-or-nil
4204 ((and gnus-thread-ignore-subject
4205 gnus-tmp-prev-subject
4206 (not (inline (gnus-subject-equal
4207 gnus-tmp-prev-subject subject))))
4209 ((zerop gnus-tmp-level)
4210 (if (and (eq gnus-summary-make-false-root 'empty)
4211 (memq number gnus-tmp-gathered)
4212 gnus-tmp-prev-subject
4213 (inline (gnus-subject-equal
4214 gnus-tmp-prev-subject subject)))
4215 gnus-summary-same-subject
4217 (t gnus-summary-same-subject)))
4218 (if (and (eq gnus-summary-make-false-root 'adopt)
4219 (= gnus-tmp-level 1)
4220 (memq number gnus-tmp-gathered))
4221 (setq gnus-tmp-opening-bracket ?\<
4222 gnus-tmp-closing-bracket ?\>)
4223 (setq gnus-tmp-opening-bracket ?\[
4224 gnus-tmp-closing-bracket ?\]))
4226 gnus-tmp-indentation
4227 (aref gnus-thread-indent-array gnus-tmp-level)
4228 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4229 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4230 gnus-summary-default-score 0)
4232 (if (or (null gnus-summary-default-score)
4233 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4234 gnus-summary-zcore-fuzz))
4236 (if (< gnus-tmp-score gnus-summary-default-score)
4237 gnus-score-below-mark gnus-score-over-mark))
4239 (cond ((memq number gnus-newsgroup-processable)
4241 ((memq number gnus-newsgroup-cached)
4243 ((memq number gnus-newsgroup-replied)
4245 ((memq number gnus-newsgroup-saved)
4248 gnus-tmp-from (mail-header-from gnus-tmp-header)
4251 ((string-match "<[^>]+> *$" gnus-tmp-from)
4252 (setq beg-match (match-beginning 0))
4253 (or (and (string-match "^\".+\"" gnus-tmp-from)
4254 (substring gnus-tmp-from 1 (1- (match-end 0))))
4255 (substring gnus-tmp-from 0 beg-match)))
4256 ((string-match "(.+)" gnus-tmp-from)
4257 (substring gnus-tmp-from
4258 (1+ (match-beginning 0)) (1- (match-end 0))))
4260 (when (string= gnus-tmp-name "")
4261 (setq gnus-tmp-name gnus-tmp-from))
4262 (unless (numberp gnus-tmp-lines)
4263 (setq gnus-tmp-lines 0))
4264 (gnus-put-text-property
4266 (progn (eval gnus-summary-line-format-spec) (point))
4267 'gnus-number number)
4270 (gnus-run-hooks 'gnus-summary-update-hook)
4273 (setq gnus-tmp-prev-subject subject)))
4275 (when (nth 1 thread)
4276 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4277 (incf gnus-tmp-level)
4278 (setq threads (if thread-end nil (cdar thread)))
4280 (setq gnus-tmp-level 0)))))
4281 (gnus-message 7 "Generating summary...done"))
4283 (defun gnus-summary-prepare-unthreaded (headers)
4284 "Generate an unthreaded summary buffer based on HEADERS."
4285 (let (header number mark)
4290 ;; We may have to root out some bad articles...
4291 (when (memq (setq number (mail-header-number
4292 (setq header (pop headers))))
4293 gnus-newsgroup-limit)
4294 ;; Mark article as read when it has a low score.
4295 (when (and gnus-summary-mark-below
4296 (< (or (cdr (assq number gnus-newsgroup-scored))
4297 gnus-summary-default-score 0)
4298 gnus-summary-mark-below)
4299 (not (gnus-summary-article-ancient-p number)))
4300 (setq gnus-newsgroup-unreads
4301 (delq number gnus-newsgroup-unreads))
4302 (if gnus-newsgroup-auto-expire
4303 (push number gnus-newsgroup-expirable)
4304 (push (cons number gnus-low-score-mark)
4305 gnus-newsgroup-reads)))
4307 (setq mark (gnus-article-mark number))
4308 (push (gnus-data-make number mark (1+ (point)) header 0)
4309 gnus-newsgroup-data)
4310 (gnus-summary-insert-line
4312 mark (memq number gnus-newsgroup-replied)
4313 (memq number gnus-newsgroup-expirable)
4314 (mail-header-subject header) nil
4315 (cdr (assq number gnus-newsgroup-scored))
4316 (memq number gnus-newsgroup-processable))))))
4318 (defun gnus-summary-remove-list-identifiers ()
4319 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4320 (let ((regexp (if (consp gnus-list-identifiers)
4321 (mapconcat 'identity gnus-list-identifiers " *\\|")
4322 gnus-list-identifiers))
4325 (dolist (header gnus-newsgroup-headers)
4326 (setq subject (mail-header-subject header)
4328 (while (string-match
4329 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4332 (concat (substring subject 0 (match-beginning 2))
4333 (substring subject (match-end 0)))
4337 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4339 (concat (substring subject 0 (match-beginning 1))
4340 (substring subject (match-end 1)))))
4342 (mail-header-set-subject header subject))))))
4344 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4345 "Select newsgroup GROUP.
4346 If READ-ALL is non-nil, all articles in the group are selected.
4347 If SELECT-ARTICLES, only select those articles from GROUP."
4348 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4349 ;;!!! Dirty hack; should be removed.
4350 (gnus-summary-ignore-duplicates
4351 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4353 gnus-summary-ignore-duplicates))
4354 (info (nth 2 entry))
4355 articles fetched-articles cached)
4357 (unless (gnus-check-server
4358 (setq gnus-current-select-method
4359 (gnus-find-method-for-group group)))
4360 (error "Couldn't open server"))
4362 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4363 (gnus-activate-group group) ; Or we can activate it...
4364 (progn ; Or we bug out.
4365 (when (equal major-mode 'gnus-summary-mode)
4366 (kill-buffer (current-buffer)))
4367 (error "Couldn't activate group %s: %s"
4368 group (gnus-status-message group))))
4370 (unless (gnus-request-group group t)
4371 (when (equal major-mode 'gnus-summary-mode)
4372 (kill-buffer (current-buffer)))
4373 (error "Couldn't request group %s: %s"
4374 group (gnus-status-message group)))
4376 (setq gnus-newsgroup-name group)
4377 (setq gnus-newsgroup-unselected nil)
4378 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4379 (gnus-summary-setup-default-charset)
4381 ;; Adjust and set lists of article marks.
4383 (gnus-adjust-marked-articles info))
4385 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4387 (if (gnus-virtual-group-p group)
4388 gnus-newsgroup-cached
4389 (gnus-cache-articles-in-group group)))
4391 (setq gnus-newsgroup-unreads
4392 (gnus-set-difference
4393 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4394 gnus-newsgroup-dormant))
4396 (setq gnus-newsgroup-processable nil)
4398 (gnus-update-read-articles group gnus-newsgroup-unreads)
4400 (if (setq articles select-articles)
4401 (setq gnus-newsgroup-unselected
4402 (gnus-sorted-intersection
4403 gnus-newsgroup-unreads
4404 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4405 (setq articles (gnus-articles-to-read group read-all)))
4409 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4411 ((eq articles 0) nil)
4413 ;; Init the dependencies hash table.
4414 (setq gnus-newsgroup-dependencies
4415 (gnus-make-hashtable (length articles)))
4416 (gnus-set-global-variables)
4417 ;; Retrieve the headers and read them in.
4418 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4419 (setq gnus-newsgroup-headers
4420 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
4421 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
4424 gnus-headers-retrieved-by
4425 (gnus-retrieve-headers
4426 articles gnus-newsgroup-name
4427 ;; We might want to fetch old headers, but
4428 ;; not if there is only 1 article.
4430 (not (eq gnus-fetch-old-headers 'some))
4431 (not (numberp gnus-fetch-old-headers)))
4432 (> (length articles) 1))
4433 gnus-fetch-old-headers))))
4434 (gnus-get-newsgroup-headers-xover
4435 articles nil nil gnus-newsgroup-name t)
4436 (gnus-get-newsgroup-headers))
4437 (gnus-retrieve-parsed-headers
4438 articles gnus-newsgroup-name
4439 ;; We might want to fetch old headers, but
4440 ;; not if there is only 1 article.
4441 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4442 (not (numberp gnus-fetch-old-headers)))
4443 (> (length articles) 1))
4444 gnus-fetch-old-headers))))
4445 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4447 ;; Suppress duplicates?
4448 (when gnus-suppress-duplicates
4449 (gnus-dup-suppress-articles))
4451 ;; Set the initial limit.
4452 (setq gnus-newsgroup-limit (copy-sequence articles))
4453 ;; Remove canceled articles from the list of unread articles.
4454 (setq gnus-newsgroup-unreads
4455 (gnus-set-sorted-intersection
4456 gnus-newsgroup-unreads
4457 (setq fetched-articles
4458 (mapcar (lambda (headers) (mail-header-number headers))
4459 gnus-newsgroup-headers))))
4460 ;; Removed marked articles that do not exist.
4461 (gnus-update-missing-marks
4462 (gnus-sorted-complement fetched-articles articles))
4464 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4466 (setq gnus-newsgroup-cached cached))
4468 ;; We might want to build some more threads first.
4469 (when (and gnus-fetch-old-headers
4470 (eq gnus-headers-retrieved-by 'nov))
4471 (if (eq gnus-fetch-old-headers 'invisible)
4472 (gnus-build-all-threads)
4473 (gnus-build-old-threads)))
4474 ;; Let the Gnus agent mark articles as read.
4476 (gnus-agent-get-undownloaded-list))
4477 ;; Remove list identifiers from subject
4478 (when gnus-list-identifiers
4479 (gnus-summary-remove-list-identifiers))
4480 ;; Check whether auto-expire is to be done in this group.
4481 (setq gnus-newsgroup-auto-expire
4482 (gnus-group-auto-expirable-p group))
4483 ;; Set up the article buffer now, if necessary.
4484 (unless gnus-single-article-buffer
4485 (gnus-article-setup-buffer))
4486 ;; First and last article in this newsgroup.
4487 (when gnus-newsgroup-headers
4488 (setq gnus-newsgroup-begin
4489 (mail-header-number (car gnus-newsgroup-headers))
4492 (gnus-last-element gnus-newsgroup-headers))))
4493 ;; GROUP is successfully selected.
4494 (or gnus-newsgroup-headers t)))))
4496 (defun gnus-articles-to-read (group &optional read-all)
4497 "Find out what articles the user wants to read."
4499 ;; Select all articles if `read-all' is non-nil, or if there
4500 ;; are no unread articles.
4502 (and (zerop (length gnus-newsgroup-marked))
4503 (zerop (length gnus-newsgroup-unreads)))
4504 (eq (gnus-group-find-parameter group 'display)
4507 (gnus-uncompress-range (gnus-active group))
4508 (gnus-cache-articles-in-group group))
4509 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4510 (copy-sequence gnus-newsgroup-unreads))
4512 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4513 (scored (length scored-list))
4514 (number (length articles))
4515 (marked (+ (length gnus-newsgroup-marked)
4516 (length gnus-newsgroup-dormant)))
4524 ((and (or (<= scored marked) (= scored number))
4525 (natnump gnus-large-newsgroup)
4526 (> number gnus-large-newsgroup))
4527 (let* ((cursor-in-echo-area nil)
4528 (input (read-from-minibuffer
4530 "How many articles from %s (max %d): "
4531 (gnus-limit-string gnus-newsgroup-name 35)
4533 (cons (number-to-string gnus-large-newsgroup)
4535 (if (string-match "^[ \t]*$" input)
4538 ((and (> scored marked) (< scored number)
4539 (> (- scored number) 20))
4542 (format "%s %s (%d scored, %d total): "
4543 "How many articles from"
4544 group scored number))))
4545 (if (string-match "^[ \t]*$" input)
4549 (message "Quit getting the articles to read")
4551 (setq select (if (stringp select) (string-to-number select) select))
4552 (if (or (null select) (zerop select))
4554 (if (and (not (zerop scored)) (<= (abs select) scored))
4556 (setq articles (sort scored-list '<))
4557 (setq number (length articles)))
4558 (setq articles (copy-sequence articles)))
4560 (when (< (abs select) number)
4562 ;; Select the N oldest articles.
4563 (setcdr (nthcdr (1- (abs select)) articles) nil)
4564 ;; Select the N most recent articles.
4565 (setq articles (nthcdr (- number select) articles))))
4566 (setq gnus-newsgroup-unselected
4567 (gnus-sorted-intersection
4568 gnus-newsgroup-unreads
4569 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4570 (when gnus-alter-articles-to-read-function
4571 (setq gnus-newsgroup-unreads
4573 (funcall gnus-alter-articles-to-read-function
4574 gnus-newsgroup-name gnus-newsgroup-unreads)
4578 (defun gnus-killed-articles (killed articles)
4581 (when (inline (gnus-member-of-range (car articles) killed))
4582 (push (car articles) out))
4583 (setq articles (cdr articles)))
4586 (defun gnus-uncompress-marks (marks)
4587 "Uncompress the mark ranges in MARKS."
4588 (let ((uncompressed '(score bookmark))
4591 (if (memq (caar marks) uncompressed)
4592 (push (car marks) out)
4593 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4594 (setq marks (cdr marks)))
4597 (defun gnus-adjust-marked-articles (info)
4598 "Set all article lists and remove all marks that are no longer valid."
4599 (let* ((marked-lists (gnus-info-marks info))
4600 (active (gnus-active (gnus-info-group info)))
4603 (types gnus-article-mark-lists)
4604 (uncompressed '(score bookmark killed))
4605 marks var articles article mark)
4608 (setq marks (pop marked-lists))
4609 (set (setq var (intern (format "gnus-newsgroup-%s"
4610 (car (rassq (setq mark (car marks))
4612 (if (memq (car marks) uncompressed) (cdr marks)
4613 (gnus-uncompress-range (cdr marks))))
4615 (setq articles (symbol-value var))
4617 ;; All articles have to be subsets of the active articles.
4619 ;; Adjust "simple" lists.
4620 ((memq mark '(tick dormant expire reply save))
4622 (when (or (< (setq article (pop articles)) min) (> article max))
4623 (set var (delq article (symbol-value var))))))
4625 ((memq mark uncompressed)
4626 (when (not (listp (cdr (symbol-value var))))
4627 (set var (list (symbol-value var))))
4628 (when (not (listp (cdr articles)))
4629 (setq articles (list articles)))
4631 (when (or (not (consp (setq article (pop articles))))
4632 (< (car article) min)
4633 (> (car article) max))
4634 (set var (delq article (symbol-value var))))))))))
4636 (defun gnus-update-missing-marks (missing)
4637 "Go through the list of MISSING articles and remove them from the mark lists."
4639 (let ((types gnus-article-mark-lists)
4641 ;; Go through all types.
4643 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4644 (when (symbol-value var)
4645 ;; This list has articles. So we delete all missing articles
4649 (set var (delq (pop m) (symbol-value var)))))))))
4651 (defun gnus-update-marks ()
4652 "Enter the various lists of marked articles into the newsgroup info list."
4653 (let ((types gnus-article-mark-lists)
4654 (info (gnus-get-info gnus-newsgroup-name))
4655 (uncompressed '(score bookmark killed))
4656 type list newmarked symbol delta-marks)
4658 ;; Add all marks lists to the list of marks lists.
4659 (while (setq type (pop types))
4660 (setq list (symbol-value
4662 (intern (format "gnus-newsgroup-%s"
4666 ;; Get rid of the entries of the articles that have the
4668 (when (and (eq (cdr type) 'score)
4672 (prev (cons nil list))
4675 (if (or (not (consp (car arts)))
4676 (= (cdar arts) gnus-summary-default-score))
4677 (setcdr prev (cdr arts))
4679 (setq arts (cdr arts)))
4680 (setq list (cdr all)))))
4682 (unless (memq (cdr type) uncompressed)
4683 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4685 (when (gnus-check-backend-function
4686 'request-set-mark gnus-newsgroup-name)
4687 ;; propagate flags to server, with the following exceptions:
4688 ;; uncompressed:s are not proper flags (they are cons cells)
4689 ;; cache is a internal gnus flag
4690 ;; download are local to one gnus installation (well)
4691 ;; unsend are for nndraft groups only
4692 ;; xxx: generality of this? this suits nnimap anyway
4693 (unless (memq (cdr type) (append '(cache download unsend)
4695 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4696 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4697 (add (gnus-remove-from-range
4698 (gnus-copy-sequence list) old)))
4700 (push (list add 'add (list (cdr type))) delta-marks))
4702 (push (list del 'del (list (cdr type))) delta-marks)))))
4705 (push (cons (cdr type) list) newmarked)))
4708 (unless (gnus-check-group gnus-newsgroup-name)
4709 (error "Can't open server for %s" gnus-newsgroup-name))
4710 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4712 ;; Enter these new marks into the info of the group.
4714 (setcar (nthcdr 3 info) newmarked)
4715 ;; Add the marks lists to the end of the info.
4717 (setcdr (nthcdr 2 info) (list newmarked))))
4719 ;; Cut off the end of the info if there's nothing else there.
4723 (when (nthcdr (decf i) info)
4724 (setcdr (nthcdr i info) nil)))))))
4726 (defun gnus-set-mode-line (where)
4727 "Set the mode line of the article or summary buffers.
4728 If WHERE is `summary', the summary mode line format will be used."
4729 ;; Is this mode line one we keep updated?
4730 (when (and (memq where gnus-updated-mode-lines)
4732 (intern (format "gnus-%s-mode-line-format-spec" where))))
4735 ;; We evaluate this in the summary buffer since these
4736 ;; variables are buffer-local to that buffer.
4737 (set-buffer gnus-summary-buffer)
4738 ;; We bind all these variables that are used in the `eval' form
4740 (let* ((mformat (symbol-value
4742 (format "gnus-%s-mode-line-format-spec" where))))
4743 (gnus-tmp-group-name (gnus-group-name-decode
4745 (gnus-group-name-charset
4747 gnus-newsgroup-name)))
4748 (gnus-tmp-article-number (or gnus-current-article 0))
4749 (gnus-tmp-unread gnus-newsgroup-unreads)
4750 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4751 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4752 (gnus-tmp-unread-and-unselected
4753 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4754 (zerop gnus-tmp-unselected))
4756 ((zerop gnus-tmp-unselected)
4757 (format "{%d more}" gnus-tmp-unread-and-unticked))
4758 (t (format "{%d(+%d) more}"
4759 gnus-tmp-unread-and-unticked
4760 gnus-tmp-unselected))))
4762 (if (and gnus-current-headers
4763 (vectorp gnus-current-headers))
4764 (gnus-mode-string-quote
4765 (mail-header-subject gnus-current-headers))
4767 bufname-length max-len
4768 gnus-tmp-header);; passed as argument to any user-format-funcs
4769 (setq mode-string (eval mformat))
4770 (setq bufname-length (if (string-match "%b" mode-string)
4773 (if (eq where 'summary)
4775 (get-buffer gnus-article-buffer))))
4778 (setq max-len (max 4 (if gnus-mode-non-string-length
4780 gnus-mode-non-string-length
4782 (length mode-string))))
4783 ;; We might have to chop a bit of the string off...
4784 (when (> (length mode-string) max-len)
4786 (concat (gnus-truncate-string mode-string (- max-len 3))
4788 ;; Pad the mode string a bit.
4789 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4790 ;; Update the mode line.
4791 (setq mode-line-buffer-identification
4792 (gnus-mode-line-buffer-identification (list mode-string)))
4793 (set-buffer-modified-p t))))
4795 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4796 "Go through the HEADERS list and add all Xrefs to a hash table.
4797 The resulting hash table is returned, or nil if no Xrefs were found."
4798 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4799 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4800 (xref-hashtb (gnus-make-hashtable))
4801 start group entry number xrefs header)
4803 (setq header (pop headers))
4804 (when (and (setq xrefs (mail-header-xref header))
4805 (not (memq (setq number (mail-header-number header))
4808 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4809 (setq start (match-end 0))
4810 (setq group (if prefix
4811 (concat prefix (substring xrefs (match-beginning 1)
4813 (substring xrefs (match-beginning 1) (match-end 1))))
4815 (string-to-int (substring xrefs (match-beginning 2)
4817 (if (setq entry (gnus-gethash group xref-hashtb))
4818 (setcdr entry (cons number (cdr entry)))
4819 (gnus-sethash group (cons number nil) xref-hashtb)))))
4820 (and start xref-hashtb)))
4822 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4823 "Look through all the headers and mark the Xrefs as read."
4824 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4825 name entry info xref-hashtb idlist method nth4)
4827 (set-buffer gnus-group-buffer)
4828 (when (setq xref-hashtb
4829 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4832 (unless (string= from-newsgroup (setq name (symbol-name group)))
4833 (setq idlist (symbol-value group))
4834 ;; Dead groups are not updated.
4836 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4838 (when (stringp (setq nth4 (gnus-info-method info)))
4839 (setq nth4 (gnus-server-to-method nth4))))
4840 ;; Only do the xrefs if the group has the same
4841 ;; select method as the group we have just read.
4842 (or (gnus-methods-equal-p
4843 nth4 (gnus-find-method-for-group from-newsgroup))
4845 (equal nth4 (setq method (gnus-find-method-for-group
4847 (and (equal (car nth4) (car method))
4848 (equal (nth 1 nth4) (nth 1 method))))
4849 gnus-use-cross-reference
4850 (or (not (eq gnus-use-cross-reference t))
4852 ;; Only do cross-references on subscribed
4853 ;; groups, if that is what is wanted.
4854 (<= (gnus-info-level info) gnus-level-subscribed))
4855 (gnus-group-make-articles-read name idlist))))
4858 (defun gnus-compute-read-articles (group articles)
4859 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4860 (info (nth 2 entry))
4861 (active (gnus-active group))
4864 ;; First peel off all invalid article numbers.
4866 (let ((ids articles)
4868 (while (setq id (pop ids))
4869 (when (and first (> id (cdr active)))
4870 ;; We'll end up in this situation in one particular
4871 ;; obscure situation. If you re-scan a group and get
4872 ;; a new article that is cross-posted to a different
4873 ;; group that has not been re-scanned, you might get
4874 ;; crossposted article that has a higher number than
4875 ;; Gnus believes possible. So we re-activate this
4876 ;; group as well. This might mean doing the
4877 ;; crossposting thingy will *increase* the number
4878 ;; of articles in some groups. Tsk, tsk.
4879 (setq active (or (gnus-activate-group group) active)))
4880 (when (or (> id (cdr active))
4881 (< id (car active)))
4882 (setq articles (delq id articles))))))
4883 ;; If the read list is nil, we init it.
4885 (null (gnus-info-read info))
4887 (setq ninfo (cons 1 (1- (car active))))
4888 (setq ninfo (gnus-info-read info)))
4889 ;; Then we add the read articles to the range.
4891 ninfo (setq articles (sort articles '<))))))
4893 (defun gnus-group-make-articles-read (group articles)
4894 "Update the info of GROUP to say that ARTICLES are read."
4896 (entry (gnus-gethash group gnus-newsrc-hashtb))
4897 (info (nth 2 entry))
4898 (active (gnus-active group))
4901 (setq range (gnus-compute-read-articles group articles))
4903 (set-buffer gnus-group-buffer)
4906 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4907 (gnus-info-set-read ',info ',(gnus-info-read info))
4908 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4909 (gnus-group-update-group ,group t))))
4910 ;; Add the read articles to the range.
4911 (gnus-info-set-read info range)
4912 ;; Then we have to re-compute how many unread
4913 ;; articles there are in this group.
4917 (setq num (- (1+ (cdr active)) (car active))))
4918 ((not (listp (cdr range)))
4919 (setq num (- (cdr active) (- (1+ (cdr range))
4923 (if (numberp (car range))
4925 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4926 (setq range (cdr range)))
4927 (setq num (- (cdr active) num))))
4928 ;; Update the number of unread articles.
4930 ;; Update the group buffer.
4931 (gnus-group-update-group group t)))))
4933 (defvar gnus-newsgroup-none-id 0)
4935 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4936 (let ((cur nntp-server-buffer)
4939 (save-excursion (set-buffer gnus-summary-buffer)
4940 gnus-newsgroup-dependencies)))
4942 (mail-parse-charset gnus-newsgroup-charset)
4943 (mail-parse-ignored-charsets
4944 (save-excursion (condition-case nil
4945 (set-buffer gnus-summary-buffer)
4947 gnus-newsgroup-ignored-charsets)))
4949 (set-buffer nntp-server-buffer)
4950 ;; Translate all TAB characters into SPACE characters.
4951 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4952 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4953 (gnus-run-hooks 'gnus-parse-headers-hook)
4954 (let ((case-fold-search t)
4955 in-reply-to header p lines chars ctype)
4956 (goto-char (point-min))
4957 ;; Search to the beginning of the next header. Error messages
4958 ;; do not begin with 2 or 3.
4959 (while (re-search-forward "^[23][0-9]+ " nil t)
4962 ;; This implementation of this function, with nine
4963 ;; search-forwards instead of the one re-search-forward and
4964 ;; a case (which basically was the old function) is actually
4965 ;; about twice as fast, even though it looks messier. You
4966 ;; can't have everything, I guess. Speed and elegance
4967 ;; doesn't always go hand in hand.
4970 (make-full-mail-header
4976 (narrow-to-region (point)
4977 (or (and (search-forward "\n.\n" nil t)
4983 (if (search-forward "\nsubject: " nil t)
4984 (nnheader-header-value)
4989 (if (or (search-forward "\nfrom: " nil t)
4990 (search-forward "\nfrom:" nil t))
4991 (nnheader-header-value)
4996 (if (search-forward "\ndate: " nil t)
4997 (nnheader-header-value)
5002 (setq id (if (re-search-forward
5003 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5004 ;; We do it this way to make sure the Message-ID
5005 ;; is (somewhat) syntactically valid.
5006 (buffer-substring (match-beginning 1)
5008 ;; If there was no message-id, we just fake one
5009 ;; to make subsequent routines simpler.
5010 (nnheader-generate-fake-message-id))))
5014 (if (search-forward "\nreferences: " nil t)
5018 (nnheader-header-value)
5023 (search-backward ">" end t)
5026 (search-backward "<" end t)
5028 ;; Get the references from the in-reply-to header if there
5029 ;; were no references and the in-reply-to header looks
5031 (if (and (search-forward "\nin-reply-to: " nil t)
5032 (setq in-reply-to (nnheader-header-value))
5033 (string-match "<[^>]+>" in-reply-to))
5035 (setq ref (substring in-reply-to (match-beginning 0)
5037 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5038 (setq ref2 (substring in-reply-to (match-beginning 0)
5040 (when (> (length ref2) (length ref))
5047 (if (search-forward "\nchars: " nil t)
5048 (if (numberp (setq chars (ignore-errors (read cur))))
5054 (if (search-forward "\nlines: " nil t)
5055 (if (numberp (setq lines (ignore-errors (read cur))))
5061 (and (search-forward "\nxref: " nil t)
5062 (nnheader-header-value)))
5064 (when gnus-extra-headers
5065 (let ((extra gnus-extra-headers)
5069 (when (search-forward
5070 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5071 (push (cons (car extra) (nnheader-header-value)) out))
5075 (if (and (search-forward "\ncontent-type: " nil t)
5076 (setq ctype (nnheader-header-value)))
5077 (mime-entity-set-content-type-internal
5078 header (mime-parse-Content-Type ctype)))
5079 (when (equal id ref)
5082 (when gnus-alter-header-function
5083 (funcall gnus-alter-header-function header)
5084 (setq id (mail-header-id header)
5085 ref (gnus-parent-id (mail-header-references header))))
5088 (gnus-dependencies-add-header
5089 header dependencies force-new))
5090 (push header headers))
5091 (goto-char (point-max))
5093 (nreverse headers)))))
5095 ;; Goes through the xover lines and returns a list of vectors
5096 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5097 force-new dependencies
5098 group also-fetch-heads)
5099 "Parse the news overview data in the server buffer.
5100 Return a list of headers that match SEQUENCE (see
5101 `nntp-retrieve-headers')."
5102 ;; Get the Xref when the users reads the articles since most/some
5103 ;; NNTP servers do not include Xrefs when using XOVER.
5104 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5105 (let ((mail-parse-charset gnus-newsgroup-charset)
5106 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5107 (cur nntp-server-buffer)
5108 (dependencies (or dependencies gnus-newsgroup-dependencies))
5109 number headers header)
5111 (set-buffer nntp-server-buffer)
5112 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5113 ;; Allow the user to mangle the headers before parsing them.
5114 (gnus-run-hooks 'gnus-parse-headers-hook)
5115 (goto-char (point-min))
5118 (while (and sequence (not (eobp)))
5119 (setq number (read cur))
5120 (while (and sequence
5121 (< (car sequence) number))
5122 (setq sequence (cdr sequence)))
5124 (eq number (car sequence))
5126 (setq sequence (cdr sequence))
5127 (setq header (inline
5128 (gnus-nov-parse-line
5129 number dependencies force-new))))
5130 (push header headers))
5133 (gnus-error 4 "Strange nov line (%d)"
5134 (count-lines (point-min) (point)))))
5136 ;; A common bug in inn is that if you have posted an article and
5137 ;; then retrieves the active file, it will answer correctly --
5138 ;; the new article is included. However, a NOV entry for the
5139 ;; article may not have been generated yet, so this may fail.
5140 ;; We work around this problem by retrieving the last few
5141 ;; headers using HEAD.
5142 (if (or (not also-fetch-heads)
5144 ;; We (probably) got all the headers.
5146 (let ((gnus-nov-is-evil t))
5149 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
5150 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
5151 (when (gnus-retrieve-headers sequence group)
5152 (gnus-get-newsgroup-headers))
5153 (gnus-retrieve-parsed-headers sequence group))))))))
5155 (defun gnus-article-get-xrefs ()
5156 "Fill in the Xref value in `gnus-current-headers', if necessary.
5157 This is meant to be called in `gnus-article-internal-prepare-hook'."
5158 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5159 gnus-current-headers)))
5160 (or (not gnus-use-cross-reference)
5162 (and (mail-header-xref headers)
5163 (not (string= (mail-header-xref headers) "")))
5164 (let ((case-fold-search t)
5167 (nnheader-narrow-to-headers)
5168 (goto-char (point-min))
5169 (when (or (and (not (eobp))
5170 (eq (downcase (char-after)) ?x)
5171 (looking-at "Xref:"))
5172 (search-forward "\nXref:" nil t))
5173 (goto-char (1+ (match-end 0)))
5174 (setq xref (buffer-substring (point)
5175 (progn (end-of-line) (point))))
5176 (mail-header-set-xref headers xref)))))))
5178 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5179 "Find article ID and insert the summary line for that article.
5180 OLD-HEADER can either be a header or a line number to insert
5181 the subject line on."
5182 (let* ((line (and (numberp old-header) old-header))
5183 (old-header (and (vectorp old-header) old-header))
5184 (header (cond ((and old-header use-old-header)
5187 (gnus-number-to-header id))
5188 (gnus-number-to-header id))
5190 (gnus-read-header id))))
5191 (number (and (numberp id) id))
5194 ;; Rebuild the thread that this article is part of and go to the
5195 ;; article we have fetched.
5196 (when (and (not gnus-show-threads)
5199 (setq d (gnus-data-find (mail-header-number old-header))))
5200 (goto-char (gnus-data-pos d))
5203 (- (gnus-point-at-bol)
5205 (1+ (gnus-point-at-eol))
5206 (gnus-delete-line))))))
5208 (mail-header-set-number header (mail-header-number old-header)))
5209 (setq gnus-newsgroup-sparse
5210 (delq (setq number (mail-header-number header))
5211 gnus-newsgroup-sparse))
5212 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5213 (push number gnus-newsgroup-limit)
5214 (gnus-rebuild-thread (mail-header-id header) line)
5215 (gnus-summary-goto-subject number nil t))
5216 (when (and (numberp number)
5218 ;; We have to update the boundaries even if we can't fetch the
5219 ;; article if ID is a number -- so that the next `P' or `N'
5220 ;; command will fetch the previous (or next) article even
5221 ;; if the one we tried to fetch this time has been canceled.
5222 (when (> number gnus-newsgroup-end)
5223 (setq gnus-newsgroup-end number))
5224 (when (< number gnus-newsgroup-begin)
5225 (setq gnus-newsgroup-begin number))
5226 (setq gnus-newsgroup-unselected
5227 (delq number gnus-newsgroup-unselected)))
5228 ;; Report back a success?
5229 (and header (mail-header-number header))))
5231 ;;; Process/prefix in the summary buffer
5233 (defun gnus-summary-work-articles (n)
5234 "Return a list of articles to be worked upon.
5235 The prefix argument, the list of process marked articles, and the
5236 current article will be taken into consideration."
5238 (set-buffer gnus-summary-buffer)
5241 ;; A numerical prefix has been given.
5242 (setq n (prefix-numeric-value n))
5243 (let ((backward (< n 0))
5244 (n (abs (prefix-numeric-value n)))
5249 (push (setq article (gnus-summary-article-number))
5252 (gnus-summary-find-prev nil article)
5253 (gnus-summary-find-next nil article)))
5255 (nreverse articles)))
5256 ((and (gnus-region-active-p) (mark))
5257 (message "region active")
5258 ;; Work on the region between point and mark.
5259 (let ((max (max (point) (mark)))
5262 (goto-char (min (point) (mark)))
5265 (push (setq article (gnus-summary-article-number)) articles)
5266 (gnus-summary-find-next nil article)
5268 (nreverse articles))))
5269 (gnus-newsgroup-processable
5270 ;; There are process-marked articles present.
5271 ;; Save current state.
5272 (gnus-summary-save-process-mark)
5274 (reverse gnus-newsgroup-processable))
5276 ;; Just return the current article.
5277 (list (gnus-summary-article-number))))))
5279 (defmacro gnus-summary-iterate (arg &rest forms)
5280 "Iterate over the process/prefixed articles and do FORMS.
5281 ARG is the interactive prefix given to the command. FORMS will be
5282 executed with point over the summary line of the articles."
5283 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5284 `(let ((,articles (gnus-summary-work-articles ,arg)))
5286 (gnus-summary-goto-subject (car ,articles))
5290 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5291 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5293 (defun gnus-summary-save-process-mark ()
5294 "Push the current set of process marked articles on the stack."
5296 (push (copy-sequence gnus-newsgroup-processable)
5297 gnus-newsgroup-process-stack))
5299 (defun gnus-summary-kill-process-mark ()
5300 "Push the current set of process marked articles on the stack and unmark."
5302 (gnus-summary-save-process-mark)
5303 (gnus-summary-unmark-all-processable))
5305 (defun gnus-summary-yank-process-mark ()
5306 "Pop the last process mark state off the stack and restore it."
5308 (unless gnus-newsgroup-process-stack
5309 (error "Empty mark stack"))
5310 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5312 (defun gnus-summary-process-mark-set (set)
5313 "Make SET into the current process marked articles."
5314 (gnus-summary-unmark-all-processable)
5316 (gnus-summary-set-process-mark (pop set))))
5318 ;;; Searching and stuff
5320 (defun gnus-summary-search-group (&optional backward use-level)
5321 "Search for next unread newsgroup.
5322 If optional argument BACKWARD is non-nil, search backward instead."
5324 (set-buffer gnus-group-buffer)
5325 (when (gnus-group-search-forward
5326 backward nil (if use-level (gnus-group-group-level) nil))
5327 (gnus-group-group-name))))
5329 (defun gnus-summary-best-group (&optional exclude-group)
5330 "Find the name of the best unread group.
5331 If EXCLUDE-GROUP, do not go to this group."
5333 (set-buffer gnus-group-buffer)
5335 (gnus-group-best-unread-group exclude-group))))
5337 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5338 (if backward (gnus-summary-find-prev)
5339 (let* ((dummy (gnus-summary-article-intangible-p))
5340 (article (or article (gnus-summary-article-number)))
5341 (arts (gnus-data-find-list article))
5343 (when (and (not dummy)
5344 (or (not gnus-summary-check-current)
5346 (not (gnus-data-unread-p (car arts)))))
5347 (setq arts (cdr arts)))
5352 (when (or (and undownloaded
5353 (eq gnus-undownloaded-mark
5354 (gnus-data-mark (car arts))))
5355 (gnus-data-unread-p (car arts)))
5356 (setq result (car arts)
5358 (setq arts (cdr arts)))
5361 (goto-char (gnus-data-pos result))
5362 (gnus-data-number result)))))
5364 (defun gnus-summary-find-prev (&optional unread article)
5365 (let* ((eobp (eobp))
5366 (article (or article (gnus-summary-article-number)))
5367 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5369 (when (and (not eobp)
5370 (or (not gnus-summary-check-current)
5372 (not (gnus-data-unread-p (car arts)))))
5373 (setq arts (cdr arts)))
5378 (when (gnus-data-unread-p (car arts))
5379 (setq result (car arts)
5381 (setq arts (cdr arts)))
5384 (goto-char (gnus-data-pos result))
5385 (gnus-data-number result))))
5387 (defun gnus-summary-find-subject (subject &optional unread backward article)
5388 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5389 (article (or article (gnus-summary-article-number)))
5390 (articles (gnus-data-list backward))
5391 (arts (gnus-data-find-list article articles))
5393 (when (or (not gnus-summary-check-current)
5395 (not (gnus-data-unread-p (car arts))))
5396 (setq arts (cdr arts)))
5398 (and (or (not unread)
5399 (gnus-data-unread-p (car arts)))
5400 (vectorp (gnus-data-header (car arts)))
5402 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5403 (setq result (car arts)
5405 (setq arts (cdr arts)))
5407 (goto-char (gnus-data-pos result))
5408 (gnus-data-number result))))
5410 (defun gnus-summary-search-forward (&optional unread subject backward)
5411 "Search forward for an article.
5412 If UNREAD, look for unread articles. If SUBJECT, look for
5413 articles with that subject. If BACKWARD, search backward instead."
5414 (cond (subject (gnus-summary-find-subject subject unread backward))
5415 (backward (gnus-summary-find-prev unread))
5416 (t (gnus-summary-find-next unread))))
5418 (defun gnus-recenter (&optional n)
5419 "Center point in window and redisplay frame.
5420 Also do horizontal recentering."
5422 (when (and gnus-auto-center-summary
5423 (not (eq gnus-auto-center-summary 'vertical)))
5424 (gnus-horizontal-recenter))
5427 (defun gnus-summary-recenter ()
5428 "Center point in the summary window.
5429 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5430 displayed, no centering will be performed."
5431 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5432 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5434 (let* ((top (cond ((< (window-height) 4) 0)
5435 ((< (window-height) 7) 1)
5436 (t (if (numberp gnus-auto-center-summary)
5437 gnus-auto-center-summary
5439 (height (1- (window-height)))
5440 (bottom (save-excursion (goto-char (point-max))
5441 (forward-line (- height))
5443 (window (get-buffer-window (current-buffer))))
5444 ;; The user has to want it.
5445 (when gnus-auto-center-summary
5446 (when (get-buffer-window gnus-article-buffer)
5447 ;; Only do recentering when the article buffer is displayed,
5448 ;; Set the window start to either `bottom', which is the biggest
5449 ;; possible valid number, or the second line from the top,
5450 ;; whichever is the least.
5451 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5452 (if (> bottom top-pos)
5453 ;; Keep the second line from the top visible
5454 (set-window-start window top-pos t)
5455 ;; Try to keep the bottom line visible; if it's partially
5456 ;; obscured, either scroll one more line to make it fully
5457 ;; visible, or revert to using TOP-POS.
5459 (goto-char (point-max))
5461 (let ((last-line-start (point)))
5463 (set-window-start window (point) t)
5464 (when (not (pos-visible-in-window-p last-line-start window))
5466 (set-window-start window (min (point) top-pos) t)))))))
5467 ;; Do horizontal recentering while we're at it.
5468 (when (and (get-buffer-window (current-buffer) t)
5469 (not (eq gnus-auto-center-summary 'vertical)))
5470 (let ((selected (selected-window)))
5471 (select-window (get-buffer-window (current-buffer) t))
5472 (gnus-summary-position-point)
5473 (gnus-horizontal-recenter)
5474 (select-window selected))))))
5476 (defun gnus-summary-jump-to-group (newsgroup)
5477 "Move point to NEWSGROUP in group mode buffer."
5478 ;; Keep update point of group mode buffer if visible.
5479 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5480 (save-window-excursion
5481 ;; Take care of tree window mode.
5482 (when (get-buffer-window gnus-group-buffer)
5483 (pop-to-buffer gnus-group-buffer))
5484 (gnus-group-jump-to-group newsgroup))
5486 ;; Take care of tree window mode.
5487 (if (get-buffer-window gnus-group-buffer)
5488 (pop-to-buffer gnus-group-buffer)
5489 (set-buffer gnus-group-buffer))
5490 (gnus-group-jump-to-group newsgroup))))
5492 ;; This function returns a list of article numbers based on the
5493 ;; difference between the ranges of read articles in this group and
5494 ;; the range of active articles.
5495 (defun gnus-list-of-unread-articles (group)
5496 (let* ((read (gnus-info-read (gnus-get-info group)))
5497 (active (or (gnus-active group) (gnus-activate-group group)))
5500 ;; If none are read, then all are unread.
5502 (setq first (car active))
5503 ;; If the range of read articles is a single range, then the
5504 ;; first unread article is the article after the last read
5505 ;; article. Sounds logical, doesn't it?
5506 (if (and (not (listp (cdr read)))
5507 (or (< (car read) (car active))
5508 (progn (setq read (list read))
5510 (setq first (max (car active) (1+ (cdr read))))
5511 ;; `read' is a list of ranges.
5512 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5515 (setq first (car active)))
5518 (while (< first nlast)
5520 (setq first (1+ first))))
5521 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5522 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5523 (setq read (cdr read)))))
5524 ;; And add the last unread articles.
5525 (while (<= first last)
5527 (setq first (1+ first)))
5528 ;; Return the list of unread articles.
5529 (delq 0 (nreverse unread))))
5531 (defun gnus-list-of-read-articles (group)
5532 "Return a list of unread, unticked and non-dormant articles."
5533 (let* ((info (gnus-get-info group))
5534 (marked (gnus-info-marks info))
5535 (active (gnus-active group)))
5537 (gnus-set-difference
5538 (gnus-sorted-complement
5539 (gnus-uncompress-range active)
5540 (gnus-list-of-unread-articles group))
5542 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5543 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5545 ;; Various summary commands
5547 (defun gnus-summary-select-article-buffer ()
5548 "Reconfigure windows to show article buffer."
5550 (if (not (gnus-buffer-live-p gnus-article-buffer))
5551 (error "There is no article buffer for this summary buffer")
5552 (gnus-configure-windows 'article)
5553 (select-window (get-buffer-window gnus-article-buffer))))
5555 (defun gnus-summary-universal-argument (arg)
5556 "Perform any operation on all articles that are process/prefixed."
5558 (let ((articles (gnus-summary-work-articles arg))
5565 (substitute-command-keys
5566 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5568 (gnus-error 1 "Undefined key")
5571 (gnus-summary-goto-subject (setq article (pop articles)))
5572 (let (gnus-newsgroup-processable)
5573 (command-execute func))
5574 (gnus-summary-remove-process-mark article)))))
5575 (gnus-summary-position-point))
5577 (defun gnus-summary-toggle-truncation (&optional arg)
5578 "Toggle truncation of summary lines.
5579 With arg, turn line truncation on iff arg is positive."
5581 (setq truncate-lines
5582 (if (null arg) (not truncate-lines)
5583 (> (prefix-numeric-value arg) 0)))
5586 (defun gnus-summary-reselect-current-group (&optional all rescan)
5587 "Exit and then reselect the current newsgroup.
5588 The prefix argument ALL means to select all articles."
5590 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5591 (error "Ephemeral groups can't be reselected"))
5592 (let ((current-subject (gnus-summary-article-number))
5593 (group gnus-newsgroup-name))
5594 (setq gnus-newsgroup-begin nil)
5596 ;; We have to adjust the point of group mode buffer because
5597 ;; point was moved to the next unread newsgroup by exiting.
5598 (gnus-summary-jump-to-group group)
5601 (save-window-excursion
5602 ;; Don't show group contents.
5603 (set-window-start (selected-window) (point-max))
5604 (gnus-group-get-new-news-this-group 1))))
5605 (gnus-group-read-group all t)
5606 (gnus-summary-goto-subject current-subject nil t)))
5608 (defun gnus-summary-rescan-group (&optional all)
5609 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5611 (gnus-summary-reselect-current-group all t))
5613 (defun gnus-summary-update-info (&optional non-destructive)
5615 (let ((group gnus-newsgroup-name))
5617 (when gnus-newsgroup-kill-headers
5618 (setq gnus-newsgroup-killed
5619 (gnus-compress-sequence
5621 (gnus-set-sorted-intersection
5622 (gnus-uncompress-range gnus-newsgroup-killed)
5623 (setq gnus-newsgroup-unselected
5624 (sort gnus-newsgroup-unselected '<)))
5625 (setq gnus-newsgroup-unreads
5626 (sort gnus-newsgroup-unreads '<)))
5628 (unless (listp (cdr gnus-newsgroup-killed))
5629 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5630 (let ((headers gnus-newsgroup-headers))
5631 ;; Set the new ranges of read articles.
5633 (set-buffer gnus-group-buffer)
5634 (gnus-undo-force-boundary))
5635 (gnus-update-read-articles
5636 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5637 ;; Set the current article marks.
5638 (let ((gnus-newsgroup-scored
5639 (if (and (not gnus-save-score)
5640 (not non-destructive))
5642 gnus-newsgroup-scored)))
5644 (gnus-update-marks)))
5645 ;; Do the cross-ref thing.
5646 (when gnus-use-cross-reference
5647 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5648 ;; Do not switch windows but change the buffer to work.
5649 (set-buffer gnus-group-buffer)
5650 (unless (gnus-ephemeral-group-p group)
5651 (gnus-group-update-group group)))))))
5653 (defun gnus-summary-save-newsrc (&optional force)
5654 "Save the current number of read/marked articles in the dribble buffer.
5655 The dribble buffer will then be saved.
5656 If FORCE (the prefix), also save the .newsrc file(s)."
5658 (gnus-summary-update-info t)
5660 (gnus-save-newsrc-file)
5661 (gnus-dribble-save)))
5663 (defun gnus-summary-exit (&optional temporary)
5664 "Exit reading current newsgroup, and then return to group selection mode.
5665 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5667 (gnus-set-global-variables)
5668 (gnus-kill-save-kill-buffer)
5669 (gnus-async-halt-prefetch)
5670 (let* ((group gnus-newsgroup-name)
5671 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5674 (buf (current-buffer)))
5676 ;; Do adaptive scoring, and possibly save score files.
5677 (when gnus-newsgroup-adaptive
5678 (gnus-score-adaptive))
5679 (when gnus-use-scoring
5681 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5682 ;; If we have several article buffers, we kill them at exit.
5683 (unless gnus-single-article-buffer
5684 (gnus-kill-buffer gnus-original-article-buffer)
5685 (setq gnus-article-current nil))
5686 (when gnus-use-cache
5687 (gnus-cache-possibly-remove-articles)
5688 (gnus-cache-save-buffers))
5689 (gnus-async-prefetch-remove-group group)
5690 (when gnus-suppress-duplicates
5691 (gnus-dup-enter-articles))
5692 (when gnus-use-trees
5693 (gnus-tree-close group))
5694 (when gnus-use-cache
5695 (gnus-cache-write-active))
5696 ;; Remove entries for this group.
5697 (nnmail-purge-split-history (gnus-group-real-name group))
5698 ;; Make all changes in this group permanent.
5700 (gnus-run-hooks 'gnus-exit-group-hook)
5701 (gnus-summary-update-info))
5702 (gnus-close-group group)
5703 ;; Make sure where we were, and go to next newsgroup.
5704 (set-buffer gnus-group-buffer)
5706 (gnus-group-jump-to-group group))
5707 (gnus-run-hooks 'gnus-summary-exit-hook)
5708 (unless (or quit-config
5709 ;; If this group has disappeared from the summary
5710 ;; buffer, don't skip forwards.
5711 (not (string= group (gnus-group-group-name))))
5712 (gnus-group-next-unread-group 1))
5713 (setq group-point (point))
5716 ;; If we have several article buffers, we kill them at exit.
5717 (unless gnus-single-article-buffer
5718 (gnus-kill-buffer gnus-article-buffer)
5719 (gnus-kill-buffer gnus-original-article-buffer)
5720 (setq gnus-article-current nil))
5722 (if (not gnus-kill-summary-on-exit)
5723 (gnus-deaden-summary)
5724 ;; We set all buffer-local variables to nil. It is unclear why
5725 ;; this is needed, but if we don't, buffer-local variables are
5726 ;; not garbage-collected, it seems. This would the lead to en
5727 ;; ever-growing Emacs.
5728 (gnus-summary-clear-local-variables)
5729 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5730 (gnus-summary-clear-local-variables))
5731 (when (get-buffer gnus-article-buffer)
5732 (bury-buffer gnus-article-buffer))
5733 ;; We clear the global counterparts of the buffer-local
5734 ;; variables as well, just to be on the safe side.
5735 (set-buffer gnus-group-buffer)
5736 (gnus-summary-clear-local-variables)
5737 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5738 (gnus-summary-clear-local-variables))
5739 ;; Return to group mode buffer.
5740 (when (eq mode 'gnus-summary-mode)
5741 (gnus-kill-buffer buf)))
5742 (setq gnus-current-select-method gnus-select-method)
5743 (pop-to-buffer gnus-group-buffer)
5744 (if (not quit-config)
5746 (goto-char group-point)
5747 (gnus-configure-windows 'group 'force)
5748 (unless (pos-visible-in-window-p)
5749 (forward-line (/ (static-if (featurep 'xemacs)
5750 (window-displayed-height)
5751 (1- (window-height)))
5753 (set-window-start (selected-window) (point))
5754 (goto-char group-point)))
5755 (gnus-handle-ephemeral-exit quit-config))
5756 ;; Clear the current group name.
5758 (setq gnus-newsgroup-name nil)))))
5760 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5761 (defun gnus-summary-exit-no-update (&optional no-questions)
5762 "Quit reading current newsgroup without updating read article info."
5764 (let* ((group gnus-newsgroup-name)
5765 (quit-config (gnus-group-quit-config group)))
5766 (when (or no-questions
5768 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5769 (gnus-async-halt-prefetch)
5771 (delq 'gnus-summary-expire-articles
5772 (copy-sequence gnus-summary-prepare-exit-hook)))
5773 ;; If we have several article buffers, we kill them at exit.
5774 (unless gnus-single-article-buffer
5775 (gnus-kill-buffer gnus-article-buffer)
5776 (gnus-kill-buffer gnus-original-article-buffer)
5777 (setq gnus-article-current nil))
5778 (if (not gnus-kill-summary-on-exit)
5779 (gnus-deaden-summary)
5780 (gnus-close-group group)
5781 (gnus-summary-clear-local-variables)
5782 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5783 (gnus-summary-clear-local-variables))
5784 (set-buffer gnus-group-buffer)
5785 (gnus-summary-clear-local-variables)
5786 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5787 (gnus-summary-clear-local-variables))
5788 (when (get-buffer gnus-summary-buffer)
5789 (kill-buffer gnus-summary-buffer)))
5790 (unless gnus-single-article-buffer
5791 (setq gnus-article-current nil))
5792 (when gnus-use-trees
5793 (gnus-tree-close group))
5794 (gnus-async-prefetch-remove-group group)
5795 (when (get-buffer gnus-article-buffer)
5796 (bury-buffer gnus-article-buffer))
5797 ;; Return to the group buffer.
5798 (gnus-configure-windows 'group 'force)
5799 ;; Clear the current group name.
5800 (setq gnus-newsgroup-name nil)
5801 (when (equal (gnus-group-group-name) group)
5802 (gnus-group-next-unread-group 1))
5804 (gnus-handle-ephemeral-exit quit-config)))))
5806 (defun gnus-handle-ephemeral-exit (quit-config)
5807 "Handle movement when leaving an ephemeral group.
5808 The state which existed when entering the ephemeral is reset."
5809 (if (not (buffer-name (car quit-config)))
5810 (gnus-configure-windows 'group 'force)
5811 (set-buffer (car quit-config))
5812 (cond ((eq major-mode 'gnus-summary-mode)
5813 (gnus-set-global-variables))
5814 ((eq major-mode 'gnus-article-mode)
5816 ;; The `gnus-summary-buffer' variable may point
5817 ;; to the old summary buffer when using a single
5819 (unless (gnus-buffer-live-p gnus-summary-buffer)
5820 (set-buffer gnus-group-buffer))
5821 (set-buffer gnus-summary-buffer)
5822 (gnus-set-global-variables))))
5823 (if (or (eq (cdr quit-config) 'article)
5824 (eq (cdr quit-config) 'pick))
5826 ;; The current article may be from the ephemeral group
5827 ;; thus it is best that we reload this article
5828 (gnus-summary-show-article)
5829 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5830 (gnus-configure-windows 'pick 'force)
5831 (gnus-configure-windows (cdr quit-config) 'force)))
5832 (gnus-configure-windows (cdr quit-config) 'force))
5833 (when (eq major-mode 'gnus-summary-mode)
5834 (gnus-summary-next-subject 1 nil t)
5835 (gnus-summary-recenter)
5836 (gnus-summary-position-point))))
5838 (defun gnus-summary-preview-mime-message ()
5839 "MIME decode and play this message."
5841 (let ((gnus-break-pages nil)
5843 (gnus-summary-select-article gnus-show-all-headers t))
5844 (select-window (get-buffer-window gnus-article-buffer)))
5848 (defvar gnus-dead-summary-mode-map nil)
5850 (unless gnus-dead-summary-mode-map
5851 (setq gnus-dead-summary-mode-map (make-keymap))
5852 (suppress-keymap gnus-dead-summary-mode-map)
5853 (substitute-key-definition
5854 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5855 (let ((keys '("\C-d" "\r" "\177" [delete])))
5857 (define-key gnus-dead-summary-mode-map
5858 (pop keys) 'gnus-summary-wake-up-the-dead))))
5860 (defvar gnus-dead-summary-mode nil
5861 "Minor mode for Gnus summary buffers.")
5863 (defun gnus-dead-summary-mode (&optional arg)
5864 "Minor mode for Gnus summary buffers."
5866 (when (eq major-mode 'gnus-summary-mode)
5867 (make-local-variable 'gnus-dead-summary-mode)
5868 (setq gnus-dead-summary-mode
5869 (if (null arg) (not gnus-dead-summary-mode)
5870 (> (prefix-numeric-value arg) 0)))
5871 (when gnus-dead-summary-mode
5872 (gnus-add-minor-mode
5873 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5875 (defun gnus-deaden-summary ()
5876 "Make the current summary buffer into a dead summary buffer."
5877 ;; Kill any previous dead summary buffer.
5878 (when (and gnus-dead-summary
5879 (buffer-name gnus-dead-summary))
5881 (set-buffer gnus-dead-summary)
5882 (when gnus-dead-summary-mode
5883 (kill-buffer (current-buffer)))))
5884 ;; Make this the current dead summary.
5885 (setq gnus-dead-summary (current-buffer))
5886 (gnus-dead-summary-mode 1)
5887 (let ((name (buffer-name)))
5888 (when (string-match "Summary" name)
5890 (concat (substring name 0 (match-beginning 0)) "Dead "
5891 (substring name (match-beginning 0)))
5895 (defun gnus-kill-or-deaden-summary (buffer)
5896 "Kill or deaden the summary BUFFER."
5898 (when (and (buffer-name buffer)
5899 (not gnus-single-article-buffer))
5902 (gnus-kill-buffer gnus-article-buffer)
5903 (gnus-kill-buffer gnus-original-article-buffer)))
5904 (cond (gnus-kill-summary-on-exit
5905 (when (and gnus-use-trees
5906 (gnus-buffer-exists-p buffer))
5909 (gnus-tree-close gnus-newsgroup-name)))
5910 (gnus-kill-buffer buffer))
5911 ((gnus-buffer-exists-p buffer)
5914 (gnus-deaden-summary))))))
5916 (defun gnus-summary-wake-up-the-dead (&rest args)
5917 "Wake up the dead summary buffer."
5919 (gnus-dead-summary-mode -1)
5920 (let ((name (buffer-name)))
5921 (when (string-match "Dead " name)
5923 (concat (substring name 0 (match-beginning 0))
5924 (substring name (match-end 0)))
5926 (gnus-message 3 "This dead summary is now alive again"))
5928 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5929 (defun gnus-summary-fetch-faq (&optional faq-dir)
5930 "Fetch the FAQ for the current group.
5931 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5935 (when current-prefix-arg
5937 "Faq dir: " (and (listp gnus-group-faq-directory)
5938 (mapcar (lambda (file) (list file))
5939 gnus-group-faq-directory))))))
5940 (let (gnus-faq-buffer)
5941 (when (setq gnus-faq-buffer
5942 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5943 (gnus-configure-windows 'summary-faq))))
5945 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5946 (defun gnus-summary-describe-group (&optional force)
5947 "Describe the current newsgroup."
5949 (gnus-group-describe-group force gnus-newsgroup-name))
5951 (defun gnus-summary-describe-briefly ()
5952 "Describe summary mode commands briefly."
5954 (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")))
5956 ;; Walking around group mode buffer from summary mode.
5958 (defun gnus-summary-next-group (&optional no-article target-group backward)
5959 "Exit current newsgroup and then select next unread newsgroup.
5960 If prefix argument NO-ARTICLE is non-nil, no article is selected
5961 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5962 previous group instead."
5964 ;; Stop pre-fetching.
5965 (gnus-async-halt-prefetch)
5966 (let ((current-group gnus-newsgroup-name)
5967 (current-buffer (current-buffer))
5969 ;; First we semi-exit this group to update Xrefs and all variables.
5970 ;; We can't do a real exit, because the window conf must remain
5971 ;; the same in case the user is prompted for info, and we don't
5972 ;; want the window conf to change before that...
5973 (gnus-summary-exit t)
5974 (while (not entered)
5975 ;; Then we find what group we are supposed to enter.
5976 (set-buffer gnus-group-buffer)
5977 (gnus-group-jump-to-group current-group)
5980 (if (eq gnus-keep-same-level 'best)
5981 (gnus-summary-best-group gnus-newsgroup-name)
5982 (gnus-summary-search-group backward gnus-keep-same-level))))
5983 (if (not target-group)
5984 ;; There are no further groups, so we return to the group
5987 (gnus-message 5 "Returning to the group buffer")
5989 (when (gnus-buffer-live-p current-buffer)
5990 (set-buffer current-buffer)
5991 (gnus-summary-exit))
5992 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5993 ;; We try to enter the target group.
5994 (gnus-group-jump-to-group target-group)
5995 (let ((unreads (gnus-group-group-unread)))
5996 (if (and (or (eq t unreads)
5997 (and unreads (not (zerop unreads))))
5998 (gnus-summary-read-group
5999 target-group nil no-article
6000 (and (buffer-name current-buffer) current-buffer)
6003 (setq current-group target-group
6004 target-group nil)))))))
6006 (defun gnus-summary-prev-group (&optional no-article)
6007 "Exit current newsgroup and then select previous unread newsgroup.
6008 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6010 (gnus-summary-next-group no-article nil t))
6012 ;; Walking around summary lines.
6014 (defun gnus-summary-first-subject (&optional unread undownloaded)
6015 "Go to the first unread subject.
6016 If UNREAD is non-nil, go to the first unread article.
6017 Returns the article selected or nil if there are no unread articles."
6022 ((null gnus-newsgroup-data)
6023 (gnus-message 3 "No articles in the group")
6025 ;; Pick the first article.
6027 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6028 (gnus-data-number (car gnus-newsgroup-data)))
6029 ;; No unread articles.
6030 ((null gnus-newsgroup-unreads)
6031 (gnus-message 3 "No more unread articles")
6033 ;; Find the first unread article.
6035 (let ((data gnus-newsgroup-data))
6037 (and (not (and undownloaded
6038 (eq gnus-undownloaded-mark
6039 (gnus-data-mark (car data)))))
6040 (not (gnus-data-unread-p (car data)))))
6041 (setq data (cdr data)))
6043 (goto-char (gnus-data-pos (car data)))
6044 (gnus-data-number (car data))))))
6045 (gnus-summary-position-point)))
6047 (defun gnus-summary-next-subject (n &optional unread dont-display)
6048 "Go to next N'th summary line.
6049 If N is negative, go to the previous N'th subject line.
6050 If UNREAD is non-nil, only unread articles are selected.
6051 The difference between N and the actual number of steps taken is
6054 (let ((backward (< n 0))
6058 (gnus-summary-find-prev unread)
6059 (gnus-summary-find-next unread)))
6060 (unless (zerop (setq n (1- n)))
6061 (gnus-summary-show-thread)))
6063 (gnus-message 7 "No more%s articles"
6064 (if unread " unread" "")))
6065 (unless dont-display
6066 (gnus-summary-recenter)
6067 (gnus-summary-position-point))
6070 (defun gnus-summary-next-unread-subject (n)
6071 "Go to next N'th unread summary line."
6073 (gnus-summary-next-subject n t))
6075 (defun gnus-summary-prev-subject (n &optional unread)
6076 "Go to previous N'th summary line.
6077 If optional argument UNREAD is non-nil, only unread article is selected."
6079 (gnus-summary-next-subject (- n) unread))
6081 (defun gnus-summary-prev-unread-subject (n)
6082 "Go to previous N'th unread summary line."
6084 (gnus-summary-next-subject (- n) t))
6086 (defun gnus-summary-goto-subject (article &optional force silent)
6087 "Go the subject line of ARTICLE.
6088 If FORCE, also allow jumping to articles not currently shown."
6089 (interactive "nArticle number: ")
6091 (data (gnus-data-find article)))
6092 ;; We read in the article if we have to.
6095 (gnus-summary-insert-subject
6097 (if (or (numberp force) (vectorp force)) force)
6099 (setq data (gnus-data-find article)))
6104 (gnus-message 3 "Can't find article %d" article))
6106 (goto-char (gnus-data-pos data))
6107 (gnus-summary-position-point)
6110 ;; Walking around summary lines with displaying articles.
6112 (defun gnus-summary-expand-window (&optional arg)
6113 "Make the summary buffer take up the entire Emacs frame.
6114 Given a prefix, will force an `article' buffer configuration."
6117 (gnus-configure-windows 'article 'force)
6118 (gnus-configure-windows 'summary 'force)))
6120 (defun gnus-summary-display-article (article &optional all-header)
6121 "Display ARTICLE in article buffer."
6122 (when (gnus-buffer-live-p gnus-article-buffer)
6123 (with-current-buffer gnus-article-buffer
6124 (set-buffer-multibyte t)))
6125 (gnus-set-global-variables)
6126 (when (gnus-buffer-live-p gnus-article-buffer)
6127 (with-current-buffer gnus-article-buffer
6128 (setq gnus-article-charset gnus-newsgroup-charset)
6129 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6133 (if gnus-summary-display-article-function
6134 (funcall gnus-summary-display-article-function article all-header)
6135 (gnus-article-prepare article all-header))
6136 (with-current-buffer gnus-article-buffer
6137 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6139 (gnus-run-hooks 'gnus-select-article-hook)
6140 (when (and gnus-current-article
6141 (not (zerop gnus-current-article)))
6142 (gnus-summary-goto-subject gnus-current-article))
6143 (gnus-summary-recenter)
6144 (when (and gnus-use-trees gnus-show-threads)
6145 (gnus-possibly-generate-tree article)
6146 (gnus-highlight-selected-tree article))
6147 ;; Successfully display article.
6148 (gnus-article-set-window-start
6149 (cdr (assq article gnus-newsgroup-bookmarks))))))
6151 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6152 "Select the current article.
6153 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6154 non-nil, the article will be re-fetched even if it already present in
6155 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6157 ;; Make sure we are in the summary buffer to work around bbdb bug.
6158 (unless (eq major-mode 'gnus-summary-mode)
6159 (set-buffer gnus-summary-buffer))
6160 (let ((article (or article (gnus-summary-article-number)))
6161 (all-headers (not (not all-headers))) ;Must be T or NIL.
6162 gnus-summary-display-article-function)
6164 (gnus-summary-article-pseudo-p article)
6165 (error "This is a pseudo-article"))
6167 (set-buffer gnus-summary-buffer)
6168 (if (or (and gnus-single-article-buffer
6169 (or (null gnus-current-article)
6170 (null gnus-article-current)
6171 (null (get-buffer gnus-article-buffer))
6172 (not (eq article (cdr gnus-article-current)))
6173 (not (equal (car gnus-article-current)
6174 gnus-newsgroup-name))))
6175 (and (not gnus-single-article-buffer)
6176 (or (null gnus-current-article)
6177 (not (eq gnus-current-article article))))
6179 ;; The requested article is different from the current article.
6181 (gnus-summary-display-article article all-headers)
6182 (when (or all-headers gnus-show-all-headers)
6183 (gnus-article-show-all-headers))
6184 (gnus-article-set-window-start
6185 (cdr (assq article gnus-newsgroup-bookmarks)))
6187 (when (or all-headers gnus-show-all-headers)
6188 (gnus-article-show-all-headers))
6191 (defun gnus-summary-force-verify-and-decrypt ()
6193 (let ((mm-verify-option 'known)
6194 (mm-decrypt-option 'known))
6195 (gnus-summary-select-article nil 'force)))
6197 (defun gnus-summary-set-current-mark (&optional current-mark)
6198 "Obsolete function."
6201 (defun gnus-summary-next-article (&optional unread subject backward push)
6202 "Select the next article.
6203 If UNREAD, only unread articles are selected.
6204 If SUBJECT, only articles with SUBJECT are selected.
6205 If BACKWARD, the previous article is selected instead of the next."
6208 ;; Is there such an article?
6209 ((and (gnus-summary-search-forward unread subject backward)
6210 (or (gnus-summary-display-article (gnus-summary-article-number))
6211 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6212 (gnus-summary-position-point))
6213 ;; If not, we try the first unread, if that is wanted.
6215 gnus-auto-select-same
6216 (gnus-summary-first-unread-article))
6217 (gnus-summary-position-point)
6218 (gnus-message 6 "Wrapped"))
6219 ;; Try to get next/previous article not displayed in this group.
6220 ((and gnus-auto-extend-newsgroup
6221 (not unread) (not subject))
6222 (gnus-summary-goto-article
6223 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6224 nil (count-lines (point-min) (point))))
6225 ;; Go to next/previous group.
6227 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6228 (gnus-summary-jump-to-group gnus-newsgroup-name))
6229 (let ((cmd last-command-char)
6232 (set-buffer gnus-group-buffer)
6235 (if (eq gnus-keep-same-level 'best)
6236 (gnus-summary-best-group gnus-newsgroup-name)
6237 (gnus-summary-search-group backward gnus-keep-same-level))))
6238 ;; For some reason, the group window gets selected. We change
6240 (select-window (get-buffer-window (current-buffer)))
6241 ;; Select next unread newsgroup automagically.
6243 ((or (not gnus-auto-select-next)
6245 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6246 ((or (eq gnus-auto-select-next 'quietly)
6247 (and (eq gnus-auto-select-next 'slightly-quietly)
6249 (and (eq gnus-auto-select-next 'almost-quietly)
6250 (gnus-summary-last-article-p)))
6252 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6254 (gnus-message 7 "No more%s articles (%s)..."
6255 (if unread " unread" "")
6256 (if group (concat "selecting " group)
6258 (gnus-summary-next-group nil group backward)))
6260 (when (gnus-key-press-event-p last-input-event)
6261 (gnus-summary-walk-group-buffer
6262 gnus-newsgroup-name cmd unread backward point))))))))
6264 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6265 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6266 (?\C-p (gnus-group-prev-unread-group 1))))
6267 (cursor-in-echo-area t)
6268 keve key group ended)
6270 (set-buffer gnus-group-buffer)
6273 (if (eq gnus-keep-same-level 'best)
6274 (gnus-summary-best-group gnus-newsgroup-name)
6275 (gnus-summary-search-group backward gnus-keep-same-level))))
6278 5 "No more%s articles%s" (if unread " unread" "")
6280 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6281 (format " (Type %s for %s [%s])"
6282 (single-key-description cmd) group
6283 (car (gnus-gethash group gnus-newsrc-hashtb)))
6284 (format " (Type %s to exit %s)"
6285 (single-key-description cmd)
6286 gnus-newsgroup-name)))
6287 ;; Confirm auto selection.
6288 (setq key (car (setq keve (gnus-read-event-char))))
6291 ((assq key keystrokes)
6292 (let ((obuf (current-buffer)))
6293 (switch-to-buffer gnus-group-buffer)
6295 (gnus-group-jump-to-group group))
6296 (eval (cadr (assq key keystrokes)))
6297 (setq group (gnus-group-group-name))
6298 (switch-to-buffer obuf))
6302 (gnus-ephemeral-group-p gnus-newsgroup-name))
6304 (gnus-summary-next-group nil group backward)))
6306 (push (cdr keve) unread-command-events))))))
6308 (defun gnus-summary-next-unread-article ()
6309 "Select unread article after current one."
6311 (gnus-summary-next-article
6312 (or (not (eq gnus-summary-goto-unread 'never))
6313 (gnus-summary-last-article-p (gnus-summary-article-number)))
6314 (and gnus-auto-select-same
6315 (gnus-summary-article-subject))))
6317 (defun gnus-summary-prev-article (&optional unread subject)
6318 "Select the article after the current one.
6319 If UNREAD is non-nil, only unread articles are selected."
6321 (gnus-summary-next-article unread subject t))
6323 (defun gnus-summary-prev-unread-article ()
6324 "Select unread article before current one."
6326 (gnus-summary-prev-article
6327 (or (not (eq gnus-summary-goto-unread 'never))
6328 (gnus-summary-first-article-p (gnus-summary-article-number)))
6329 (and gnus-auto-select-same
6330 (gnus-summary-article-subject))))
6332 (defun gnus-summary-next-page (&optional lines circular)
6333 "Show next page of the selected article.
6334 If at the end of the current article, select the next article.
6335 LINES says how many lines should be scrolled up.
6337 If CIRCULAR is non-nil, go to the start of the article instead of
6338 selecting the next article when reaching the end of the current
6341 (setq gnus-summary-buffer (current-buffer))
6342 (gnus-set-global-variables)
6343 (let ((article (gnus-summary-article-number))
6344 (article-window (get-buffer-window gnus-article-buffer t))
6346 ;; If the buffer is empty, we have no article.
6348 (error "No article to select"))
6349 (gnus-configure-windows 'article)
6350 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6351 (if (and (eq gnus-summary-goto-unread 'never)
6352 (not (gnus-summary-last-article-p article)))
6353 (gnus-summary-next-article)
6354 (gnus-summary-next-unread-article))
6355 (if (or (null gnus-current-article)
6356 (null gnus-article-current)
6357 (/= article (cdr gnus-article-current))
6358 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6359 ;; Selected subject is different from current article's.
6360 (gnus-summary-display-article article)
6361 (when article-window
6362 (gnus-eval-in-buffer-window gnus-article-buffer
6363 (setq endp (gnus-article-next-page lines)))
6366 (gnus-summary-beginning-of-article))
6368 (gnus-message 3 "End of message"))
6370 (if (and (eq gnus-summary-goto-unread 'never)
6371 (not (gnus-summary-last-article-p article)))
6372 (gnus-summary-next-article)
6373 (gnus-summary-next-unread-article))))))))
6374 (gnus-summary-recenter)
6375 (gnus-summary-position-point)))
6377 (defun gnus-summary-prev-page (&optional lines move)
6378 "Show previous page of selected article.
6379 Argument LINES specifies lines to be scrolled down.
6380 If MOVE, move to the previous unread article if point is at
6381 the beginning of the buffer."
6383 (let ((article (gnus-summary-article-number))
6384 (article-window (get-buffer-window gnus-article-buffer t))
6386 (gnus-configure-windows 'article)
6387 (if (or (null gnus-current-article)
6388 (null gnus-article-current)
6389 (/= article (cdr gnus-article-current))
6390 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6391 ;; Selected subject is different from current article's.
6392 (gnus-summary-display-article article)
6393 (gnus-summary-recenter)
6394 (when article-window
6395 (gnus-eval-in-buffer-window gnus-article-buffer
6396 (setq endp (gnus-article-prev-page lines)))
6397 (when (and move endp)
6399 (gnus-message 3 "Beginning of message"))
6401 (if (and (eq gnus-summary-goto-unread 'never)
6402 (not (gnus-summary-first-article-p article)))
6403 (gnus-summary-prev-article)
6404 (gnus-summary-prev-unread-article))))))))
6405 (gnus-summary-position-point))
6407 (defun gnus-summary-prev-page-or-article (&optional lines)
6408 "Show previous page of selected article.
6409 Argument LINES specifies lines to be scrolled down.
6410 If at the beginning of the article, go to the next article."
6412 (gnus-summary-prev-page lines t))
6414 (defun gnus-summary-scroll-up (lines)
6415 "Scroll up (or down) one line current article.
6416 Argument LINES specifies lines to be scrolled up (or down if negative)."
6418 (gnus-configure-windows 'article)
6419 (gnus-summary-show-thread)
6420 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6421 (gnus-eval-in-buffer-window gnus-article-buffer
6423 (when (gnus-article-next-page lines)
6424 (gnus-message 3 "End of message")))
6426 (gnus-article-prev-page (- lines))))))
6427 (gnus-summary-recenter)
6428 (gnus-summary-position-point))
6430 (defun gnus-summary-scroll-down (lines)
6431 "Scroll down (or up) one line current article.
6432 Argument LINES specifies lines to be scrolled down (or up if negative)."
6434 (gnus-summary-scroll-up (- lines)))
6436 (defun gnus-summary-next-same-subject ()
6437 "Select next article which has the same subject as current one."
6439 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6441 (defun gnus-summary-prev-same-subject ()
6442 "Select previous article which has the same subject as current one."
6444 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6446 (defun gnus-summary-next-unread-same-subject ()
6447 "Select next unread article which has the same subject as current one."
6449 (gnus-summary-next-article t (gnus-summary-article-subject)))
6451 (defun gnus-summary-prev-unread-same-subject ()
6452 "Select previous unread article which has the same subject as current one."
6454 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6456 (defun gnus-summary-first-unread-article ()
6457 "Select the first unread article.
6458 Return nil if there are no unread articles."
6461 (when (gnus-summary-first-subject t)
6462 (gnus-summary-show-thread)
6463 (gnus-summary-first-subject t)
6464 (gnus-summary-display-article (gnus-summary-article-number)))
6465 (gnus-summary-position-point)))
6467 (defun gnus-summary-first-unread-subject ()
6468 "Place the point on the subject line of the first unread article.
6469 Return nil if there are no unread articles."
6472 (when (gnus-summary-first-subject t)
6473 (gnus-summary-show-thread)
6474 (gnus-summary-first-subject t))
6475 (gnus-summary-position-point)))
6477 (defun gnus-summary-first-article ()
6478 "Select the first article.
6479 Return nil if there are no articles."
6482 (when (gnus-summary-first-subject)
6483 (gnus-summary-show-thread)
6484 (gnus-summary-first-subject)
6485 (gnus-summary-display-article (gnus-summary-article-number)))
6486 (gnus-summary-position-point)))
6488 (defun gnus-summary-best-unread-article ()
6489 "Select the unread article with the highest score."
6491 (let ((best -1000000)
6492 (data gnus-newsgroup-data)
6495 (and (gnus-data-unread-p (car data))
6497 (gnus-summary-article-score (gnus-data-number (car data))))
6500 article (gnus-data-number (car data))))
6501 (setq data (cdr data)))
6504 (gnus-summary-goto-article article)
6505 (error "No unread articles"))
6506 (gnus-summary-position-point))))
6508 (defun gnus-summary-last-subject ()
6509 "Go to the last displayed subject line in the group."
6510 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6512 (gnus-summary-goto-subject article))))
6514 (defun gnus-summary-goto-article (article &optional all-headers force)
6515 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6516 If ALL-HEADERS is non-nil, no header lines are hidden.
6517 If FORCE, go to the article even if it isn't displayed. If FORCE
6518 is a number, it is the line the article is to be displayed on."
6522 "Article number or Message-ID: "
6523 (mapcar (lambda (number) (list (int-to-string number)))
6524 gnus-newsgroup-limit))
6528 (if (and (stringp article)
6529 (string-match "@" article))
6530 (gnus-summary-refer-article article)
6531 (when (stringp article)
6532 (setq article (string-to-number article)))
6533 (if (gnus-summary-goto-subject article force)
6534 (gnus-summary-display-article article all-headers)
6535 (gnus-message 4 "Couldn't go to article %s" article) nil))
6536 (gnus-summary-position-point)))
6538 (defun gnus-summary-goto-last-article ()
6539 "Go to the previously read article."
6542 (when gnus-last-article
6543 (gnus-summary-goto-article gnus-last-article nil t))
6544 (gnus-summary-position-point)))
6546 (defun gnus-summary-pop-article (number)
6547 "Pop one article off the history and go to the previous.
6548 NUMBER articles will be popped off."
6551 (setq gnus-newsgroup-history
6552 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6554 (gnus-summary-goto-article (car to) nil t)
6555 (error "Article history empty")))
6556 (gnus-summary-position-point))
6558 ;; Summary commands and functions for limiting the summary buffer.
6560 (defun gnus-summary-limit-to-articles (n)
6561 "Limit the summary buffer to the next N articles.
6562 If not given a prefix, use the process marked articles instead."
6565 (let ((articles (gnus-summary-work-articles n)))
6566 (setq gnus-newsgroup-processable nil)
6567 (gnus-summary-limit articles))
6568 (gnus-summary-position-point)))
6570 (defun gnus-summary-pop-limit (&optional total)
6571 "Restore the previous limit.
6572 If given a prefix, remove all limits."
6575 (setq gnus-newsgroup-limits
6576 (list (mapcar (lambda (h) (mail-header-number h))
6577 gnus-newsgroup-headers))))
6578 (unless gnus-newsgroup-limits
6579 (error "No limit to pop"))
6581 (gnus-summary-limit nil 'pop)
6582 (gnus-summary-position-point)))
6584 (defun gnus-summary-limit-to-subject (subject &optional header)
6585 "Limit the summary buffer to articles that have subjects that match a regexp."
6586 (interactive "sLimit to subject (regexp): ")
6588 (setq header "subject"))
6589 (when (not (equal "" subject))
6591 (let ((articles (gnus-summary-find-matching
6592 (or header "subject") subject 'all)))
6594 (error "Found no matches for \"%s\"" subject))
6595 (gnus-summary-limit articles))
6596 (gnus-summary-position-point))))
6598 (defun gnus-summary-limit-to-author (from)
6599 "Limit the summary buffer to articles that have authors that match a regexp."
6600 (interactive "sLimit to author (regexp): ")
6601 (gnus-summary-limit-to-subject from "from"))
6603 (defun gnus-summary-limit-to-age (age &optional younger-p)
6604 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6605 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6606 articles that are younger than AGE days."
6608 (let ((younger current-prefix-arg)
6611 (while (not days-got)
6612 (setq days (if younger
6613 (read-string "Limit to articles within (in days): ")
6614 (read-string "Limit to articles older than (in days): ")))
6615 (when (> (length days) 0)
6616 (setq days (read days)))
6619 (message "Please enter a number.")
6621 (list days younger)))
6623 (let ((data gnus-newsgroup-data)
6624 (cutoff (days-to-time age))
6625 articles d date is-younger)
6626 (while (setq d (pop data))
6627 (when (and (vectorp (gnus-data-header d))
6628 (setq date (mail-header-date (gnus-data-header d))))
6629 (setq is-younger (time-less-p
6630 (time-since (condition-case ()
6637 (push (gnus-data-number d) articles))))
6638 (gnus-summary-limit (nreverse articles)))
6639 (gnus-summary-position-point)))
6641 (defun gnus-summary-limit-to-extra (header regexp)
6642 "Limit the summary buffer to articles that match an 'extra' header."
6646 (gnus-completing-read
6647 (symbol-name (car gnus-extra-headers))
6648 "Limit extra header:"
6650 (cons (symbol-name x) x))
6655 (read-string (format "Limit to header %s (regexp): " header)))))
6656 (when (not (equal "" regexp))
6658 (let ((articles (gnus-summary-find-matching
6659 (cons 'extra header) regexp 'all)))
6661 (error "Found no matches for \"%s\"" regexp))
6662 (gnus-summary-limit articles))
6663 (gnus-summary-position-point))))
6665 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6667 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6669 (defun gnus-summary-limit-to-unread (&optional all)
6670 "Limit the summary buffer to articles that are not marked as read.
6671 If ALL is non-nil, limit strictly to unread articles."
6674 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6675 (gnus-summary-limit-to-marks
6676 ;; Concat all the marks that say that an article is read and have
6678 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6679 gnus-killed-mark gnus-kill-file-mark
6680 gnus-low-score-mark gnus-expirable-mark
6681 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6682 gnus-duplicate-mark gnus-souped-mark)
6685 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6686 (make-obsolete 'gnus-summary-delete-marked-with
6687 'gnus-summary-limit-exlude-marks)
6689 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6690 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6691 If REVERSE, limit the summary buffer to articles that are marked
6692 with MARKS. MARKS can either be a string of marks or a list of marks.
6693 Returns how many articles were removed."
6694 (interactive "sMarks: ")
6695 (gnus-summary-limit-to-marks marks t))
6697 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6698 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6699 If REVERSE (the prefix), limit the summary buffer to articles that are
6700 not marked with MARKS. MARKS can either be a string of marks or a
6702 Returns how many articles were removed."
6703 (interactive "sMarks: \nP")
6705 (let ((data gnus-newsgroup-data)
6706 (marks (if (listp marks) marks
6707 (append marks nil))) ; Transform to list.
6710 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6711 (memq (gnus-data-mark (car data)) marks))
6712 (push (gnus-data-number (car data)) articles))
6713 (setq data (cdr data)))
6714 (gnus-summary-limit articles))
6715 (gnus-summary-position-point)))
6717 (defun gnus-summary-limit-to-score (&optional score)
6718 "Limit to articles with score at or above SCORE."
6720 (setq score (if score
6721 (prefix-numeric-value score)
6722 (or gnus-summary-default-score 0)))
6723 (let ((data gnus-newsgroup-data)
6726 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6728 (push (gnus-data-number (car data)) articles))
6729 (setq data (cdr data)))
6731 (gnus-summary-limit articles)
6732 (gnus-summary-position-point))))
6734 (defun gnus-summary-limit-include-thread (id)
6735 "Display all the hidden articles that in the current thread."
6736 (interactive (list (mail-header-id (gnus-summary-article-header))))
6737 (let ((articles (gnus-articles-in-thread
6738 (gnus-id-to-thread (gnus-root-id id)))))
6740 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6741 (gnus-summary-position-point))))
6743 (defun gnus-summary-limit-include-dormant ()
6744 "Display all the hidden articles that are marked as dormant.
6745 Note that this command only works on a subset of the articles currently
6746 fetched for this group."
6748 (unless gnus-newsgroup-dormant
6749 (error "There are no dormant articles in this group"))
6751 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6752 (gnus-summary-position-point)))
6754 (defun gnus-summary-limit-exclude-dormant ()
6755 "Hide all dormant articles."
6758 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6759 (gnus-summary-position-point)))
6761 (defun gnus-summary-limit-exclude-childless-dormant ()
6762 "Hide all dormant articles that have no children."
6764 (let ((data (gnus-data-list t))
6765 articles d children)
6766 ;; Find all articles that are either not dormant or have
6768 (while (setq d (pop data))
6769 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6771 (gnus-article-children (gnus-data-number d)))
6774 (when (memq (car children) articles)
6779 (push (gnus-data-number d) articles)))
6782 (gnus-summary-limit articles)
6783 (gnus-summary-position-point))))
6785 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6786 "Mark all unread excluded articles as read.
6787 If ALL, mark even excluded ticked and dormants as read."
6789 (let ((articles (gnus-sorted-complement
6791 (mapcar (lambda (h) (mail-header-number h))
6792 gnus-newsgroup-headers)
6794 (sort gnus-newsgroup-limit '<)))
6796 (setq gnus-newsgroup-unreads
6797 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6799 (setq gnus-newsgroup-dormant nil
6800 gnus-newsgroup-marked nil
6801 gnus-newsgroup-reads
6803 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6804 gnus-newsgroup-reads))
6805 (while (setq article (pop articles))
6806 (unless (or (memq article gnus-newsgroup-dormant)
6807 (memq article gnus-newsgroup-marked))
6808 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6810 (defun gnus-summary-limit (articles &optional pop)
6812 ;; We pop the previous limit off the stack and use that.
6813 (setq articles (car gnus-newsgroup-limits)
6814 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6815 ;; We use the new limit, so we push the old limit on the stack.
6816 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6818 (setq gnus-newsgroup-limit articles)
6819 (let ((total (length gnus-newsgroup-data))
6820 (data (gnus-data-find-list (gnus-summary-article-number)))
6821 (gnus-summary-mark-below nil) ; Inhibit this.
6823 ;; This will do all the work of generating the new summary buffer
6824 ;; according to the new limit.
6825 (gnus-summary-prepare)
6826 ;; Hide any threads, possibly.
6827 (and gnus-show-threads
6828 gnus-thread-hide-subtree
6829 (gnus-summary-hide-all-threads))
6830 ;; Try to return to the article you were at, or one in the
6833 ;; We try to find some article after the current one.
6835 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6838 (setq data (cdr data))))
6840 ;; If there is no data, that means that we were after the last
6841 ;; article. The same goes when we can't find any articles
6842 ;; after the current one.
6843 (goto-char (point-max))
6844 (gnus-summary-find-prev))
6845 (gnus-set-mode-line 'summary)
6846 ;; We return how many articles were removed from the summary
6847 ;; buffer as a result of the new limit.
6848 (- total (length gnus-newsgroup-data))))
6850 (defsubst gnus-invisible-cut-children (threads)
6853 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6858 (defsubst gnus-cut-thread (thread)
6859 "Go forwards in the thread until we find an article that we want to display."
6860 (when (or (eq gnus-fetch-old-headers 'some)
6861 (eq gnus-fetch-old-headers 'invisible)
6862 (numberp gnus-fetch-old-headers)
6863 (eq gnus-build-sparse-threads 'some)
6864 (eq gnus-build-sparse-threads 'more))
6865 ;; Deal with old-fetched headers and sparse threads.
6869 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6870 (gnus-summary-article-ancient-p
6871 (mail-header-number (car thread))))
6872 (if (or (<= (length (cdr thread)) 1)
6873 (eq gnus-fetch-old-headers 'invisible))
6874 (setq gnus-newsgroup-limit
6875 (delq (mail-header-number (car thread))
6876 gnus-newsgroup-limit)
6877 thread (cadr thread))
6878 (when (gnus-invisible-cut-children (cdr thread))
6879 (let ((th (cdr thread)))
6881 (if (memq (mail-header-number (caar th))
6882 gnus-newsgroup-limit)
6883 (setq thread (car th)
6885 (setq th (cdr th))))))))))
6888 (defun gnus-cut-threads (threads)
6889 "Cut off all uninteresting articles from the beginning of threads."
6890 (when (or (eq gnus-fetch-old-headers 'some)
6891 (eq gnus-fetch-old-headers 'invisible)
6892 (numberp gnus-fetch-old-headers)
6893 (eq gnus-build-sparse-threads 'some)
6894 (eq gnus-build-sparse-threads 'more))
6897 (setcar th (gnus-cut-thread (car th)))
6898 (setq th (cdr th)))))
6899 ;; Remove nixed out threads.
6902 (defun gnus-summary-initial-limit (&optional show-if-empty)
6903 "Figure out what the initial limit is supposed to be on group entry.
6904 This entails weeding out unwanted dormants, low-scored articles,
6905 fetch-old-headers verbiage, and so on."
6906 ;; Most groups have nothing to remove.
6907 (if (or gnus-inhibit-limiting
6908 (and (null gnus-newsgroup-dormant)
6909 (not (eq gnus-fetch-old-headers 'some))
6910 (not (numberp gnus-fetch-old-headers))
6911 (not (eq gnus-fetch-old-headers 'invisible))
6912 (null gnus-summary-expunge-below)
6913 (not (eq gnus-build-sparse-threads 'some))
6914 (not (eq gnus-build-sparse-threads 'more))
6915 (null gnus-thread-expunge-below)
6916 (not gnus-use-nocem)))
6918 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6919 (setq gnus-newsgroup-limit nil)
6922 (unless (car (symbol-value node))
6923 ;; These threads have no parents -- they are roots.
6924 (let ((nodes (cdr (symbol-value node)))
6927 (if (and gnus-thread-expunge-below
6928 (< (gnus-thread-total-score (car nodes))
6929 gnus-thread-expunge-below))
6930 (gnus-expunge-thread (pop nodes))
6931 (setq thread (pop nodes))
6932 (gnus-summary-limit-children thread))))))
6933 gnus-newsgroup-dependencies)
6934 ;; If this limitation resulted in an empty group, we might
6935 ;; pop the previous limit and use it instead.
6936 (when (and (not gnus-newsgroup-limit)
6938 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6939 gnus-newsgroup-limit))
6941 (defun gnus-summary-limit-children (thread)
6942 "Return 1 if this subthread is visible and 0 if it is not."
6943 ;; First we get the number of visible children to this thread. This
6944 ;; is done by recursing down the thread using this function, so this
6945 ;; will really go down to a leaf article first, before slowly
6946 ;; working its way up towards the root.
6950 (apply '+ (mapcar 'gnus-summary-limit-children
6953 (number (mail-header-number (car thread)))
6956 (not (memq number gnus-newsgroup-marked))
6958 ;; If this article is dormant and has absolutely no visible
6959 ;; children, then this article isn't visible.
6960 (and (memq number gnus-newsgroup-dormant)
6962 ;; If this is "fetch-old-headered" and there is no
6963 ;; visible children, then we don't want this article.
6964 (and (or (eq gnus-fetch-old-headers 'some)
6965 (numberp gnus-fetch-old-headers))
6966 (gnus-summary-article-ancient-p number)
6968 ;; If this is "fetch-old-headered" and `invisible', then
6969 ;; we don't want this article.
6970 (and (eq gnus-fetch-old-headers 'invisible)
6971 (gnus-summary-article-ancient-p number))
6972 ;; If this is a sparsely inserted article with no children,
6973 ;; we don't want it.
6974 (and (eq gnus-build-sparse-threads 'some)
6975 (gnus-summary-article-sparse-p number)
6977 ;; If we use expunging, and this article is really
6978 ;; low-scored, then we don't want this article.
6979 (when (and gnus-summary-expunge-below
6981 (or (cdr (assq number gnus-newsgroup-scored))
6982 gnus-summary-default-score))
6983 gnus-summary-expunge-below))
6984 ;; We increase the expunge-tally here, but that has
6985 ;; nothing to do with the limits, really.
6986 (incf gnus-newsgroup-expunged-tally)
6987 ;; We also mark as read here, if that's wanted.
6988 (when (and gnus-summary-mark-below
6989 (< score gnus-summary-mark-below))
6990 (setq gnus-newsgroup-unreads
6991 (delq number gnus-newsgroup-unreads))
6992 (if gnus-newsgroup-auto-expire
6993 (push number gnus-newsgroup-expirable)
6994 (push (cons number gnus-low-score-mark)
6995 gnus-newsgroup-reads)))
6997 ;; Check NoCeM things.
6998 (if (and gnus-use-nocem
6999 (gnus-nocem-unwanted-article-p
7000 (mail-header-id (car thread))))
7002 (setq gnus-newsgroup-unreads
7003 (delq number gnus-newsgroup-unreads))
7005 ;; Nope, invisible article.
7007 ;; Ok, this article is to be visible, so we add it to the limit
7009 (push number gnus-newsgroup-limit)
7012 (defun gnus-expunge-thread (thread)
7013 "Mark all articles in THREAD as read."
7014 (let* ((number (mail-header-number (car thread))))
7015 (incf gnus-newsgroup-expunged-tally)
7016 ;; We also mark as read here, if that's wanted.
7017 (setq gnus-newsgroup-unreads
7018 (delq number gnus-newsgroup-unreads))
7019 (if gnus-newsgroup-auto-expire
7020 (push number gnus-newsgroup-expirable)
7021 (push (cons number gnus-low-score-mark)
7022 gnus-newsgroup-reads)))
7023 ;; Go recursively through all subthreads.
7024 (mapcar 'gnus-expunge-thread (cdr thread)))
7026 ;; Summary article oriented commands
7028 (defun gnus-summary-refer-parent-article (n)
7029 "Refer parent article N times.
7030 If N is negative, go to ancestor -N instead.
7031 The difference between N and the number of articles fetched is returned."
7035 (when (not (natnump n))
7040 (setq header (gnus-summary-article-header))
7041 (if (and (eq (mail-header-number header)
7042 (cdr gnus-article-current))
7043 (equal gnus-newsgroup-name
7044 (car gnus-article-current)))
7045 ;; If we try to find the parent of the currently
7046 ;; displayed article, then we take a look at the actual
7047 ;; References header, since this is slightly more
7048 ;; reliable than the References field we got from the
7051 (set-buffer gnus-original-article-buffer)
7052 (nnheader-narrow-to-headers)
7053 (unless (setq ref (message-fetch-field "references"))
7054 (setq ref (message-fetch-field "in-reply-to")))
7057 ;; It's not the current article, so we take a bet on
7058 ;; the value we got from the server.
7059 (mail-header-references header)))
7061 (not (equal ref "")))
7062 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7063 (gnus-message 1 "Couldn't find parent"))
7064 (gnus-message 1 "No references in article %d"
7065 (gnus-summary-article-number))
7068 (gnus-summary-position-point)
7071 (defun gnus-summary-refer-references ()
7072 "Fetch all articles mentioned in the References header.
7073 Return the number of articles fetched."
7075 (let ((ref (mail-header-references (gnus-summary-article-header)))
7076 (current (gnus-summary-article-number))
7080 (error "No References in the current article")
7081 ;; For each Message-ID in the References header...
7082 (while (string-match "<[^>]*>" ref)
7084 ;; ... fetch that article.
7085 (gnus-summary-refer-article
7086 (prog1 (match-string 0 ref)
7087 (setq ref (substring ref (match-end 0))))))
7088 (gnus-summary-goto-subject current)
7089 (gnus-summary-position-point)
7092 (defun gnus-summary-refer-thread (&optional limit)
7093 "Fetch all articles in the current thread.
7094 If LIMIT (the numerical prefix), fetch that many old headers instead
7095 of what's specified by the `gnus-refer-thread-limit' variable."
7097 (let ((id (mail-header-id (gnus-summary-article-header)))
7098 (limit (if limit (prefix-numeric-value limit)
7099 gnus-refer-thread-limit)))
7100 ;; We want to fetch LIMIT *old* headers, but we also have to
7101 ;; re-fetch all the headers in the current buffer, because many of
7102 ;; them may be undisplayed. So we adjust LIMIT.
7103 (when (numberp limit)
7104 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7105 (unless (eq gnus-fetch-old-headers 'invisible)
7106 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7107 ;; Retrieve the headers and read them in.
7108 (if (eq (gnus-retrieve-headers
7109 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7111 (gnus-build-all-threads)
7112 (error "Can't fetch thread from backends that don't support NOV"))
7113 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7114 (gnus-summary-limit-include-thread id)))
7116 (defun gnus-summary-refer-article (message-id)
7117 "Fetch an article specified by MESSAGE-ID."
7118 (interactive "sMessage-ID: ")
7119 (when (and (stringp message-id)
7120 (not (zerop (length message-id))))
7121 ;; Construct the correct Message-ID if necessary.
7122 ;; Suggested by tale@pawl.rpi.edu.
7123 (unless (string-match "^<" message-id)
7124 (setq message-id (concat "<" message-id)))
7125 (unless (string-match ">$" message-id)
7126 (setq message-id (concat message-id ">")))
7127 (let* ((header (gnus-id-to-header message-id))
7129 (gnus-summary-article-sparse-p
7130 (mail-header-number header))
7131 (memq (mail-header-number header)
7132 gnus-newsgroup-limit)))
7135 ;; If the article is present in the buffer we just go to it.
7137 (or (not (gnus-summary-article-sparse-p
7138 (mail-header-number header)))
7141 (gnus-summary-goto-article
7142 (mail-header-number header) nil t)
7144 (gnus-summary-update-article (mail-header-number header)))))
7146 ;; We fetch the article.
7148 (dolist (gnus-override-method (gnus-refer-article-methods))
7149 (gnus-check-server gnus-override-method)
7150 ;; Fetch the header, and display the article.
7151 (when (setq number (gnus-summary-insert-subject message-id))
7152 (gnus-summary-select-article nil nil nil number)
7154 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7156 (defun gnus-refer-article-methods ()
7157 "Return a list of referrable methods."
7159 ;; No method, so we default to current and native.
7160 ((null gnus-refer-article-method)
7161 (list gnus-current-select-method gnus-select-method))
7163 ((eq 'current gnus-refer-article-method)
7164 (list gnus-current-select-method))
7165 ;; List of select methods.
7166 ((not (and (symbolp (car gnus-refer-article-method))
7167 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7169 (dolist (method gnus-refer-article-method)
7170 (push (if (eq 'current method)
7171 gnus-current-select-method
7175 ;; One single select method.
7177 (list gnus-refer-article-method))))
7179 (defun gnus-summary-edit-parameters ()
7180 "Edit the group parameters of the current group."
7182 (gnus-group-edit-group gnus-newsgroup-name 'params))
7184 (defun gnus-summary-customize-parameters ()
7185 "Customize the group parameters of the current group."
7187 (gnus-group-customize gnus-newsgroup-name))
7189 (defun gnus-summary-enter-digest-group (&optional force)
7190 "Enter an nndoc group based on the current article.
7191 If FORCE, force a digest interpretation. If not, try
7192 to guess what the document format is."
7194 (let ((conf gnus-current-window-configuration))
7196 (gnus-summary-select-article))
7197 (setq gnus-current-window-configuration conf)
7198 (let* ((name (format "%s-%d"
7199 (gnus-group-prefixed-name
7200 gnus-newsgroup-name (list 'nndoc ""))
7202 (set-buffer gnus-summary-buffer)
7203 gnus-current-article)))
7204 (ogroup gnus-newsgroup-name)
7205 (params (append (gnus-info-params (gnus-get-info ogroup))
7206 (list (cons 'to-group ogroup))
7207 (list (cons 'save-article-group ogroup))))
7208 (case-fold-search t)
7209 (buf (current-buffer))
7212 (set-buffer gnus-original-article-buffer)
7213 ;; Have the digest group inherit the main mail address of
7214 ;; the parent article.
7215 (when (setq to-address (or (message-fetch-field "reply-to")
7216 (message-fetch-field "from")))
7217 (setq params (append
7218 (list (cons 'to-address
7219 (funcall gnus-decode-encoded-word-function
7221 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7222 (insert-buffer-substring gnus-original-article-buffer)
7223 ;; Remove lines that may lead nndoc to misinterpret the
7226 (goto-char (point-min))
7227 (or (search-forward "\n\n" nil t) (point)))
7228 (goto-char (point-min))
7229 (delete-matching-lines "^Path:\\|^From ")
7232 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7233 (gnus-newsgroup-ephemeral-ignored-charsets
7234 gnus-newsgroup-ignored-charsets))
7235 (gnus-group-read-ephemeral-group
7236 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7238 ,(if force 'mbox 'guess))) t))
7239 ;; Make all postings to this group go to the parent group.
7240 (nconc (gnus-info-params (gnus-get-info name))
7242 ;; Couldn't select this doc group.
7243 (switch-to-buffer buf)
7244 (gnus-set-global-variables)
7245 (gnus-configure-windows 'summary)
7246 (gnus-message 3 "Article couldn't be entered?"))
7247 (kill-buffer dig)))))
7249 (defun gnus-summary-read-document (n)
7250 "Open a new group based on the current article(s).
7251 This will allow you to read digests and other similar
7252 documents as newsgroups.
7253 Obeys the standard process/prefix convention."
7255 (let* ((articles (gnus-summary-work-articles n))
7256 (ogroup gnus-newsgroup-name)
7257 (params (append (gnus-info-params (gnus-get-info ogroup))
7258 (list (cons 'to-group ogroup))))
7259 article group egroup groups vgroup)
7260 (while (setq article (pop articles))
7261 (setq group (format "%s-%d" gnus-newsgroup-name article))
7262 (gnus-summary-remove-process-mark article)
7263 (when (gnus-summary-display-article article)
7266 (insert-buffer-substring gnus-original-article-buffer)
7267 ;; Remove some headers that may lead nndoc to make
7269 (message-narrow-to-head)
7270 (goto-char (point-min))
7271 (delete-matching-lines "^\\(Path\\):\\|^From ")
7274 (gnus-group-read-ephemeral-group
7275 group `(nndoc ,group (nndoc-address ,(current-buffer))
7276 (nndoc-article-type guess))
7279 ;; Make all postings to this group go to the parent group.
7280 (nconc (gnus-info-params (gnus-get-info egroup))
7282 (push egroup groups))
7283 ;; Couldn't select this doc group.
7284 (gnus-error 3 "Article couldn't be entered"))))))
7285 ;; Now we have selected all the documents.
7288 (error "None of the articles could be interpreted as documents"))
7289 ((gnus-group-read-ephemeral-group
7290 (setq vgroup (format
7291 "nnvirtual:%s-%s" gnus-newsgroup-name
7292 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7293 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7295 (cons (current-buffer) 'summary)))
7297 (error "Couldn't select virtual nndoc group")))))
7299 (defun gnus-summary-isearch-article (&optional regexp-p)
7300 "Do incremental search forward on the current article.
7301 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7303 (let* ((gnus-inhibit-treatment t)
7304 (old (gnus-summary-select-article)))
7305 (gnus-configure-windows 'article)
7306 (gnus-eval-in-buffer-window gnus-article-buffer
7310 (gnus-article-show-all-headers))
7311 (goto-char (point-min))
7312 (isearch-forward regexp-p)))))
7314 (defun gnus-summary-search-article-forward (regexp &optional backward)
7315 "Search for an article containing REGEXP forward.
7316 If BACKWARD, search backward instead."
7319 (format "Search article %s (regexp%s): "
7320 (if current-prefix-arg "backward" "forward")
7321 (if gnus-last-search-regexp
7322 (concat ", default " gnus-last-search-regexp)
7324 current-prefix-arg))
7325 (if (string-equal regexp "")
7326 (setq regexp (or gnus-last-search-regexp ""))
7327 (setq gnus-last-search-regexp regexp)
7328 (setq gnus-article-before-search gnus-current-article))
7329 ;; Intentionally set gnus-last-article.
7330 (setq gnus-last-article gnus-article-before-search)
7331 (let ((gnus-last-article gnus-last-article))
7332 (if (gnus-summary-search-article regexp backward)
7333 (gnus-summary-show-thread)
7334 (error "Search failed: \"%s\"" regexp))))
7336 (defun gnus-summary-search-article-backward (regexp)
7337 "Search for an article containing REGEXP backward."
7340 (format "Search article backward (regexp%s): "
7341 (if gnus-last-search-regexp
7342 (concat ", default " gnus-last-search-regexp)
7344 (gnus-summary-search-article-forward regexp 'backward))
7347 (defmacro gnus-summary-search-article-position-point (regexp backward)
7348 "Dehighlight the last matched text and goto the beginning position."
7349 (` (if (and gnus-summary-search-article-matched-data
7350 (let ((text (caddr gnus-summary-search-article-matched-data))
7351 (inhibit-read-only t)
7354 (goto-char (car gnus-summary-search-article-matched-data))
7355 (cadr gnus-summary-search-article-matched-data))
7357 (string-match (, regexp) text)))
7358 (if (, backward) (beginning-of-line) (end-of-line))
7359 (goto-char (if (, backward) (point-max) (point-min))))))
7361 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7362 "Place point where X-Face image is displayed."
7363 (if (featurep 'xemacs)
7364 (` (let ((end (if (search-forward "\n\n" nil t)
7365 (goto-char (1- (point)))
7368 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7369 (unless (and (re-search-forward "^From:" end t)
7370 (setq extent (extent-at (point)))
7371 (extent-begin-glyph extent))
7372 (goto-char (, opoint)))))
7373 (` (let ((end (if (search-forward "\n\n" nil t)
7374 (goto-char (1- (point)))
7376 (start (or (search-backward "\n\n" nil t) (point-min))))
7378 (or (text-property-any start end 'x-face-image t);; x-face-e21
7379 (text-property-any start end 'x-face-mule-bitmap-image t)
7382 (defmacro gnus-summary-search-article-highlight-matched-text
7383 (backward treated x-face)
7384 "Highlight matched text in the function `gnus-summary-search-article'."
7385 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7386 (end (set-marker (make-marker) (match-end 0)))
7387 (inhibit-read-only t)
7391 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7393 (lambda (item) (setq items (delq item items)))
7394 '(gnus-treat-buttonize
7395 gnus-treat-fill-article
7396 gnus-treat-fill-long-lines
7397 gnus-treat-emphasize
7398 gnus-treat-highlight-headers
7399 gnus-treat-highlight-citation
7400 gnus-treat-highlight-signature
7401 gnus-treat-overstrike
7402 gnus-treat-display-xface
7403 gnus-treat-buttonize-head
7404 gnus-treat-decode-article-as-default-mime-charset))
7405 (static-if (featurep 'xemacs)
7407 (cons '(x-face-mule-delete-x-face-field
7410 (gnus-treat-display-xface
7411 (when (, x-face) gnus-treat-display-xface)))
7412 (gnus-article-prepare-mime-display)))
7413 (goto-char (if (, backward) start end))
7415 (gnus-summary-search-article-highlight-goto-x-face (point)))
7416 (setq gnus-summary-search-article-matched-data
7417 (list start end (buffer-substring start end)))
7418 (unless (eq start end);; matched text has been deleted. :-<
7419 (put-text-property start end 'face
7420 (or (find-face 'isearch)
7421 'secondary-selection))))))
7424 (defun gnus-summary-search-article (regexp &optional backward)
7425 "Search for an article containing REGEXP.
7426 Optional argument BACKWARD means do search for backward.
7427 `gnus-select-article-hook' is not called during the search."
7428 ;; We have to require this here to make sure that the following
7429 ;; dynamic binding isn't shadowed by autoloading.
7430 (require 'gnus-async)
7432 (let ((gnus-select-article-hook nil) ;Disable hook.
7433 (gnus-article-prepare-hook nil)
7434 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7435 (gnus-use-article-prefetch nil)
7436 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7437 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7438 (sum (current-buffer))
7441 (gnus-save-hidden-threads
7442 (static-if (featurep 'xemacs)
7443 (let ((gnus-inhibit-treatment t))
7444 (setq treated (eq 'old (gnus-summary-select-article)))
7446 (not (and (gnus-buffer-live-p gnus-article-buffer)
7447 (window-live-p (get-buffer-window
7448 gnus-article-buffer t)))))
7449 (gnus-summary-select-article nil t)
7450 (setq treated nil)))
7451 (let ((gnus-inhibit-treatment t)
7452 (x-face-mule-delete-x-face-field 'never))
7453 (setq treated (eq 'old (gnus-summary-select-article)))
7456 (and (gnus-buffer-live-p gnus-article-buffer)
7457 (window-live-p (get-buffer-window
7458 gnus-article-buffer t))
7459 (or (not (string-match "^\\^X-Face:" regexp))
7460 (with-current-buffer gnus-article-buffer
7461 gnus-summary-search-article-matched-data)))))
7462 (gnus-summary-select-article nil t)
7463 (setq treated nil))))
7464 (set-buffer gnus-article-buffer)
7468 (gnus-article-show-all-headers)
7469 (gnus-summary-search-article-position-point regexp backward))
7470 (goto-char (if backward (point-max) (point-min))))
7472 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7474 (re-search-backward regexp nil t)
7475 (re-search-forward regexp nil t))
7476 ;; We found the regexp.
7478 (gnus-summary-search-article-highlight-matched-text
7479 backward treated (string-match "^\\^X-Face:" regexp))
7482 (/ (- 2 (window-height
7483 (get-buffer-window gnus-article-buffer t)))
7486 (get-buffer-window (current-buffer))
7489 (setq point (point)))
7490 ;; We didn't find it, so we go to the next article.
7493 (while (eq found 'not)
7494 (if (not (if backward (gnus-summary-find-prev)
7495 (gnus-summary-find-next)))
7496 ;; No more articles.
7498 ;; Select the next article and adjust point.
7499 (unless (gnus-summary-article-sparse-p
7500 (gnus-summary-article-number))
7502 (let ((gnus-inhibit-treatment t))
7503 (gnus-summary-select-article))
7505 (set-buffer gnus-article-buffer)
7507 (goto-char (if backward (point-max) (point-min))))))))
7508 (gnus-message 7 ""))
7509 ;; Return whether we found the regexp.
7510 (when (eq found 'found)
7512 (gnus-summary-show-thread)
7513 (gnus-summary-goto-subject gnus-current-article)
7514 (gnus-summary-position-point)
7517 (defun gnus-summary-find-matching (header regexp &optional backward unread
7519 "Return a list of all articles that match REGEXP on HEADER.
7520 The search stars on the current article and goes forwards unless
7521 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7522 If UNREAD is non-nil, only unread articles will
7523 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7524 in the comparisons."
7525 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7526 (gnus-data-find-list
7527 (gnus-summary-article-number) (gnus-data-list backward))))
7528 (case-fold-search (not not-case-fold))
7531 (if (eq (car header) 'extra)
7534 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7536 (error "%s is an invalid header" header))
7537 (unless (fboundp (intern (concat "mail-header-" header)))
7538 (error "%s is not a valid header" header))
7539 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7542 (and (or (not unread) ; We want all articles...
7543 (gnus-data-unread-p d)) ; Or just unreads.
7544 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7545 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7546 (push (gnus-data-number d) articles)) ; Success!
7547 (setq data (cdr data)))
7548 (nreverse articles)))
7550 (defun gnus-summary-execute-command (header regexp command &optional backward)
7551 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7552 If HEADER is an empty string (or nil), the match is done on the entire
7553 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7555 (list (let ((completion-ignore-case t))
7558 (mapcar (lambda (string) (list string))
7559 '("Number" "Subject" "From" "Lines" "Date"
7560 "Message-ID" "Xref" "References" "Body"))
7561 nil 'require-match))
7562 (read-string "Regexp: ")
7563 (read-key-sequence "Command: ")
7564 current-prefix-arg))
7565 (when (equal header "Body")
7567 ;; Hidden thread subtrees must be searched as well.
7568 (gnus-summary-show-all-threads)
7569 ;; We don't want to change current point nor window configuration.
7571 (save-window-excursion
7572 (gnus-message 6 "Executing %s..." (key-description command))
7573 ;; We'd like to execute COMMAND interactively so as to give arguments.
7574 (gnus-execute header regexp
7575 `(call-interactively ',(key-binding command))
7577 (gnus-message 6 "Executing %s...done" (key-description command)))))
7579 (defun gnus-summary-beginning-of-article ()
7580 "Scroll the article back to the beginning."
7582 (gnus-summary-select-article)
7583 (gnus-configure-windows 'article)
7584 (gnus-eval-in-buffer-window gnus-article-buffer
7586 (goto-char (point-min))
7587 (when gnus-page-broken
7588 (gnus-narrow-to-page))))
7590 (defun gnus-summary-end-of-article ()
7591 "Scroll to the end of the article."
7593 (gnus-summary-select-article)
7594 (gnus-configure-windows 'article)
7595 (gnus-eval-in-buffer-window gnus-article-buffer
7597 (goto-char (point-max))
7599 (when gnus-page-broken
7600 (gnus-narrow-to-page))))
7602 (defun gnus-summary-print-article (&optional filename n)
7603 "Generate and print a PostScript image of the N next (mail) articles.
7605 If N is negative, print the N previous articles. If N is nil and articles
7606 have been marked with the process mark, print these instead.
7608 If the optional first argument FILENAME is nil, send the image to the
7609 printer. If FILENAME is a string, save the PostScript image in a file with
7610 that name. If FILENAME is a number, prompt the user for the name of the file
7612 (interactive (list (ps-print-preprint current-prefix-arg)))
7613 (dolist (article (gnus-summary-work-articles n))
7614 (gnus-summary-select-article nil nil 'pseudo article)
7615 (gnus-eval-in-buffer-window gnus-article-buffer
7616 (let ((buffer (generate-new-buffer " *print*")))
7619 (copy-to-buffer buffer (point-min) (point-max))
7621 (gnus-article-delete-invisible-text)
7622 (when (gnus-visual-p 'article-highlight 'highlight)
7623 ;; Copy-to-buffer doesn't copy overlay. So redo
7625 (let ((gnus-article-buffer buffer))
7626 (gnus-article-highlight-citation t)
7627 (gnus-article-highlight-signature)))
7628 (let ((ps-left-header
7631 (mail-header-subject gnus-current-headers) ")")
7633 (mail-header-from gnus-current-headers) ")")))
7636 "/pagenumberstring load"
7638 (mail-header-date gnus-current-headers) ")"))))
7639 (gnus-run-hooks 'gnus-ps-print-hook)
7641 (ps-spool-buffer-with-faces))))
7642 (kill-buffer buffer))))
7643 (gnus-summary-remove-process-mark article))
7644 (ps-despool filename))
7646 (defun gnus-summary-show-article (&optional arg)
7647 "Force re-fetching of the current article.
7648 If ARG (the prefix) is a number, show the article with the charset
7649 defined in `gnus-summary-show-article-charset-alist', or the charset
7651 If ARG (the prefix) is non-nil and not a number, show the raw article
7652 without any article massaging functions being run."
7656 (let ((gnus-newsgroup-charset
7657 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7658 (read-coding-system "Charset: ")))
7659 (gnus-newsgroup-ignored-charsets 'gnus-all))
7660 (gnus-summary-select-article nil 'force)
7661 (let ((deps gnus-newsgroup-dependencies)
7664 (set-buffer gnus-original-article-buffer)
7666 (message-narrow-to-head)
7667 (setq head (buffer-string)))
7669 (insert (format "211 %d Article retrieved.\n"
7670 (cdr gnus-article-current)))
7673 (let ((nntp-server-buffer (current-buffer)))
7674 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7675 (gnus-data-set-header
7676 (gnus-data-find (cdr gnus-article-current))
7678 (gnus-summary-update-article-line
7679 (cdr gnus-article-current) header))))
7681 ;; Select the article the normal way.
7682 (gnus-summary-select-article nil 'force))
7684 ;; We have to require this here to make sure that the following
7685 ;; dynamic binding isn't shadowed by autoloading.
7686 (require 'gnus-async)
7688 ;; Bind the article treatment functions to nil.
7689 (let ((gnus-have-all-headers t)
7690 gnus-article-prepare-hook
7691 gnus-article-decode-hook
7694 (gnus-summary-select-article nil 'force))))
7695 (gnus-summary-goto-subject gnus-current-article)
7696 (gnus-summary-position-point))
7698 (defun gnus-summary-verbose-headers (&optional arg)
7699 "Toggle permanent full header display.
7700 If ARG is a positive number, turn header display on.
7701 If ARG is a negative number, turn header display off."
7703 (setq gnus-show-all-headers
7704 (cond ((or (not (numberp arg))
7706 (not gnus-show-all-headers))
7709 (gnus-summary-show-article))
7711 (defun gnus-summary-toggle-header (&optional arg)
7712 "Show the headers if they are hidden, or hide them if they are shown.
7713 If ARG is a positive number, show the entire header.
7714 If ARG is a negative number, hide the unwanted header lines."
7717 (set-buffer gnus-article-buffer)
7719 (let* ((buffer-read-only nil)
7720 (inhibit-point-motion-hooks t)
7726 (article-narrow-to-head)
7727 (gnus-article-hidden-text-p 'headers))))
7728 (goto-char (point-min))
7729 (when (search-forward "\n\n" nil t)
7730 (delete-region (point-min) (1- (point))))
7731 (goto-char (point-min))
7733 (set-buffer gnus-original-article-buffer)
7734 (goto-char (point-min))
7735 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7736 (insert-buffer-substring gnus-original-article-buffer 1 e)
7738 (narrow-to-region (point-min) (point))
7739 (article-decode-encoded-words)
7741 (let ((gnus-treat-hide-headers nil)
7742 (gnus-treat-hide-boring-headers nil))
7743 (setq gnus-article-wash-types
7744 (delq 'headers gnus-article-wash-types))
7745 (gnus-treat-article 'head))
7746 (gnus-treat-article 'head)))
7747 (gnus-set-mode-line 'article)))))
7749 (defun gnus-summary-show-all-headers ()
7750 "Make all header lines visible."
7752 (gnus-article-show-all-headers))
7754 (defun gnus-summary-toggle-mime (&optional arg)
7755 "Toggle MIME processing.
7756 If ARG is a positive number, turn MIME processing on."
7758 (setq gnus-show-mime
7760 (not gnus-show-mime)
7761 (> (prefix-numeric-value arg) 0)))
7762 (gnus-summary-select-article t 'force))
7764 (defun gnus-summary-caesar-message (&optional arg)
7765 "Caesar rotate the current article by 13.
7766 The numerical prefix specifies how many places to rotate each letter
7769 (gnus-summary-select-article)
7770 (let ((mail-header-separator ""))
7771 (gnus-eval-in-buffer-window gnus-article-buffer
7774 (let ((start (window-start))
7776 (message-caesar-buffer-body arg)
7777 (set-window-start (get-buffer-window (current-buffer)) start))))))
7779 (defun gnus-summary-stop-page-breaking ()
7780 "Stop page breaking in the current article."
7782 (gnus-summary-select-article)
7783 (gnus-eval-in-buffer-window gnus-article-buffer
7785 (when (gnus-visual-p 'page-marker)
7786 (let ((buffer-read-only nil))
7787 (gnus-remove-text-with-property 'gnus-prev)
7788 (gnus-remove-text-with-property 'gnus-next))
7789 (setq gnus-page-broken nil))))
7791 (defun gnus-summary-move-article (&optional n to-newsgroup
7792 select-method action)
7793 "Move the current article to a different newsgroup.
7794 If N is a positive number, move the N next articles.
7795 If N is a negative number, move the N previous articles.
7796 If N is nil and any articles have been marked with the process mark,
7797 move those articles instead.
7798 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7799 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7800 re-spool using this method.
7802 For this function to work, both the current newsgroup and the
7803 newsgroup that you want to move to have to support the `request-move'
7804 and `request-accept' functions.
7806 ACTION can be either `move' (the default), `crosspost' or `copy'."
7809 (setq action 'move))
7810 ;; Disable marking as read.
7811 (let (gnus-mark-article-hook)
7812 (save-window-excursion
7813 (gnus-summary-select-article)))
7814 ;; Check whether the source group supports the required functions.
7815 (cond ((and (eq action 'move)
7816 (not (gnus-check-backend-function
7817 'request-move-article gnus-newsgroup-name)))
7818 (error "The current group does not support article moving"))
7819 ((and (eq action 'crosspost)
7820 (not (gnus-check-backend-function
7821 'request-replace-article gnus-newsgroup-name)))
7822 (error "The current group does not support article editing")))
7823 (let ((articles (gnus-summary-work-articles n))
7824 (prefix (if (gnus-check-backend-function
7825 'request-move-article gnus-newsgroup-name)
7826 (gnus-group-real-prefix gnus-newsgroup-name)
7828 (names '((move "Move" "Moving")
7829 (copy "Copy" "Copying")
7830 (crosspost "Crosspost" "Crossposting")))
7831 (copy-buf (save-excursion
7832 (nnheader-set-temp-buffer " *copy article*")))
7833 (default-marks gnus-article-mark-lists)
7834 (no-expire-marks (delete '(expirable . expire)
7835 (copy-sequence gnus-article-mark-lists)))
7836 art-group to-method new-xref article to-groups)
7837 (unless (assq action names)
7838 (error "Unknown action %s" action))
7839 ;; Read the newsgroup name.
7840 (when (and (not to-newsgroup)
7841 (not select-method))
7843 (gnus-read-move-group-name
7844 (cadr (assq action names))
7845 (symbol-value (intern (format "gnus-current-%s-group" action)))
7847 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7848 (setq to-method (or select-method
7849 (gnus-server-to-method
7850 (gnus-group-method to-newsgroup))))
7851 ;; Check the method we are to move this article to...
7852 (unless (gnus-check-backend-function
7853 'request-accept-article (car to-method))
7854 (error "%s does not support article copying" (car to-method)))
7855 (unless (gnus-check-server to-method)
7856 (error "Can't open server %s" (car to-method)))
7857 (gnus-message 6 "%s to %s: %s..."
7858 (caddr (assq action names))
7859 (or (car select-method) to-newsgroup) articles)
7861 (setq article (pop articles))
7865 ;; Move the article.
7867 ;; Remove this article from future suppression.
7868 (gnus-dup-unsuppress-article article)
7869 (gnus-request-move-article
7870 article ; Article to move
7871 gnus-newsgroup-name ; From newsgroup
7872 (nth 1 (gnus-find-method-for-group
7873 gnus-newsgroup-name)) ; Server
7874 (list 'gnus-request-accept-article
7875 to-newsgroup (list 'quote select-method)
7876 (not articles) t) ; Accept form
7877 (not articles))) ; Only save nov last time
7878 ;; Copy the article.
7881 (set-buffer copy-buf)
7882 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7883 (gnus-request-accept-article
7884 to-newsgroup select-method (not articles) t))))
7885 ;; Crosspost the article.
7886 ((eq action 'crosspost)
7887 (let ((xref (message-tokenize-header
7888 (mail-header-xref (gnus-summary-article-header article))
7890 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7893 (setq xref (list (system-name))))
7896 (mapconcat 'identity
7897 (delete "Xref:" (delete new-xref xref))
7901 (set-buffer copy-buf)
7902 ;; First put the article in the destination group.
7903 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7904 (when (consp (setq art-group
7905 (gnus-request-accept-article
7906 to-newsgroup select-method (not articles))))
7907 (setq new-xref (concat new-xref " " (car art-group)
7908 ":" (cdr art-group)))
7909 ;; Now we have the new Xrefs header, so we insert
7910 ;; it and replace the new article.
7911 (nnheader-replace-header "Xref" new-xref)
7912 (gnus-request-replace-article
7913 (cdr art-group) to-newsgroup (current-buffer))
7917 (gnus-message 1 "Couldn't %s article %s: %s"
7918 (cadr (assq action names)) article
7919 (nnheader-get-report (car to-method))))
7920 ((eq art-group 'junk)
7921 (when (eq action 'move)
7922 (gnus-summary-mark-article article gnus-canceled-mark)
7923 (gnus-message 4 "Deleted article %s" article)))
7925 (let* ((pto-group (gnus-group-prefixed-name
7926 (car art-group) to-method))
7928 (gnus-gethash pto-group gnus-newsrc-hashtb))
7929 (info (nth 2 entry))
7930 (to-group (gnus-info-group info))
7932 ;; Update the group that has been moved to.
7934 (memq action '(move copy)))
7935 (unless (member to-group to-groups)
7936 (push to-group to-groups))
7938 (unless (memq article gnus-newsgroup-unreads)
7939 (push 'read to-marks)
7941 info (gnus-add-to-range (gnus-info-read info)
7942 (list (cdr art-group)))))
7944 ;; See whether the article is to be put in the cache.
7945 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7948 (to-article (cdr art-group)))
7950 ;; Enter the article into the cache in the new group,
7951 ;; if that is required.
7952 (when gnus-use-cache
7953 (gnus-cache-possibly-enter-article
7955 (let ((header (copy-sequence
7956 (gnus-summary-article-header article))))
7957 (mail-header-set-number header to-article)
7959 (memq article gnus-newsgroup-marked)
7960 (memq article gnus-newsgroup-dormant)
7961 (memq article gnus-newsgroup-unreads)))
7963 (when gnus-preserve-marks
7964 ;; Copy any marks over to the new group.
7965 (when (and (equal to-group gnus-newsgroup-name)
7966 (not (memq article gnus-newsgroup-unreads)))
7967 ;; Mark this article as read in this group.
7968 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7969 (setcdr (gnus-active to-group) to-article)
7970 (setcdr gnus-newsgroup-active to-article))
7973 (when (memq article (symbol-value
7974 (intern (format "gnus-newsgroup-%s"
7976 (push (cdar marks) to-marks)
7977 ;; If the other group is the same as this group,
7978 ;; then we have to add the mark to the list.
7979 (when (equal to-group gnus-newsgroup-name)
7980 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7983 (intern (format "gnus-newsgroup-%s"
7985 ;; Copy the marks to other group.
7986 (gnus-add-marked-articles
7987 to-group (cdar marks) (list to-article) info))
7988 (setq marks (cdr marks)))
7990 (gnus-request-set-mark to-group (list (list (list to-article)
7995 (concat "(gnus-group-set-info '"
7996 (gnus-prin1-to-string (gnus-get-info to-group))
7999 ;; Update the Xref header in this article to point to
8000 ;; the new crossposted article we have just created.
8001 (when (eq action 'crosspost)
8003 (set-buffer copy-buf)
8004 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8005 (nnheader-replace-header "Xref" new-xref)
8006 (gnus-request-replace-article
8007 article gnus-newsgroup-name (current-buffer)))))
8009 ;;;!!!Why is this necessary?
8010 (set-buffer gnus-summary-buffer)
8012 (gnus-summary-goto-subject article)
8013 (when (eq action 'move)
8014 (gnus-summary-mark-article article gnus-canceled-mark))))
8015 (gnus-summary-remove-process-mark article))
8016 ;; Re-activate all groups that have been moved to.
8019 (set-buffer gnus-group-buffer)
8020 (when (gnus-group-goto-group (car to-groups) t)
8021 (gnus-group-get-new-news-this-group 1 t))
8024 (gnus-kill-buffer copy-buf)
8025 (gnus-summary-position-point)
8026 (gnus-set-mode-line 'summary)))
8028 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8029 "Move the current article to a different newsgroup.
8030 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8031 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8032 re-spool using this method."
8034 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8036 (defun gnus-summary-crosspost-article (&optional n)
8037 "Crosspost the current article to some other group."
8039 (gnus-summary-move-article n nil nil 'crosspost))
8041 (defcustom gnus-summary-respool-default-method nil
8042 "Default method for respooling an article.
8043 If nil, use to the current newsgroup method."
8044 :type '(choice (gnus-select-method :value (nnml ""))
8046 :group 'gnus-summary-mail)
8048 (defun gnus-summary-respool-article (&optional n method)
8049 "Respool the current article.
8050 The article will be squeezed through the mail spooling process again,
8051 which means that it will be put in some mail newsgroup or other
8052 depending on `nnmail-split-methods'.
8053 If N is a positive number, respool the N next articles.
8054 If N is a negative number, respool the N previous articles.
8055 If N is nil and any articles have been marked with the process mark,
8056 respool those articles instead.
8058 Respooling can be done both from mail groups and \"real\" newsgroups.
8059 In the former case, the articles in question will be moved from the
8060 current group into whatever groups they are destined to. In the
8061 latter case, they will be copied into the relevant groups."
8063 (list current-prefix-arg
8064 (let* ((methods (gnus-methods-using 'respool))
8066 (symbol-name (or gnus-summary-respool-default-method
8067 (car (gnus-find-method-for-group
8068 gnus-newsgroup-name)))))
8070 (gnus-completing-read
8071 methname "What backend do you want to use when respooling?"
8072 methods nil t nil 'gnus-mail-method-history))
8075 ((zerop (length (setq ms (gnus-servers-using-backend
8077 (list (intern method) ""))
8081 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8082 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8085 (error "No method given for respooling"))
8086 (if (assoc (symbol-name
8087 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8088 (gnus-methods-using 'respool))
8089 (gnus-summary-move-article n nil method)
8090 (gnus-summary-copy-article n nil method)))
8092 (defun gnus-summary-import-article (file)
8093 "Import an arbitrary file into a mail newsgroup."
8094 (interactive "fImport file: ")
8095 (let ((group gnus-newsgroup-name)
8096 (now (current-time))
8098 (unless (gnus-check-backend-function 'request-accept-article group)
8099 (error "%s does not support article importing" group))
8100 (or (file-readable-p file)
8101 (not (file-regular-p file))
8102 (error "Can't read %s" file))
8104 (set-buffer (gnus-get-buffer-create " *import file*"))
8106 (nnheader-insert-file-contents file)
8107 (goto-char (point-min))
8108 (unless (nnheader-article-p)
8109 ;; This doesn't look like an article, so we fudge some headers.
8110 (setq atts (file-attributes file)
8111 lines (count-lines (point-min) (point-max)))
8112 (insert "From: " (read-string "From: ") "\n"
8113 "Subject: " (read-string "Subject: ") "\n"
8114 "Date: " (message-make-date (nth 5 atts))
8116 "Message-ID: " (message-make-message-id) "\n"
8117 "Lines: " (int-to-string lines) "\n"
8118 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8119 (gnus-request-accept-article group nil t)
8120 (kill-buffer (current-buffer)))))
8122 (defun gnus-summary-article-posted-p ()
8123 "Say whether the current (mail) article is available from news as well.
8124 This will be the case if the article has both been mailed and posted."
8126 (let ((id (mail-header-references (gnus-summary-article-header)))
8127 (gnus-override-method (car (gnus-refer-article-methods))))
8128 (if (gnus-request-head id "")
8129 (gnus-message 2 "The current message was found on %s"
8130 gnus-override-method)
8131 (gnus-message 2 "The current message couldn't be found on %s"
8132 gnus-override-method)
8135 (defun gnus-summary-expire-articles (&optional now)
8136 "Expire all articles that are marked as expirable in the current group."
8138 (when (gnus-check-backend-function
8139 'request-expire-articles gnus-newsgroup-name)
8140 ;; This backend supports expiry.
8141 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8142 (expirable (if total
8144 ;; We need to update the info for
8145 ;; this group for `gnus-list-of-read-articles'
8146 ;; to give us the right answer.
8147 (gnus-run-hooks 'gnus-exit-group-hook)
8148 (gnus-summary-update-info)
8149 (gnus-list-of-read-articles gnus-newsgroup-name))
8150 (setq gnus-newsgroup-expirable
8151 (sort gnus-newsgroup-expirable '<))))
8152 (expiry-wait (if now 'immediate
8153 (gnus-group-find-parameter
8154 gnus-newsgroup-name 'expiry-wait)))
8155 (nnmail-expiry-target
8156 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8157 nnmail-expiry-target))
8160 ;; There are expirable articles in this group, so we run them
8161 ;; through the expiry process.
8162 (gnus-message 6 "Expiring articles...")
8163 (unless (gnus-check-group gnus-newsgroup-name)
8164 (error "Can't open server for %s" gnus-newsgroup-name))
8165 ;; The list of articles that weren't expired is returned.
8168 (let ((nnmail-expiry-wait-function nil)
8169 (nnmail-expiry-wait expiry-wait))
8170 (setq es (gnus-request-expire-articles
8171 expirable gnus-newsgroup-name)))
8172 (setq es (gnus-request-expire-articles
8173 expirable gnus-newsgroup-name)))
8175 (setq gnus-newsgroup-expirable es))
8176 ;; We go through the old list of expirable, and mark all
8177 ;; really expired articles as nonexistent.
8178 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8179 (let ((gnus-use-cache nil))
8181 (unless (memq (car expirable) es)
8182 (when (gnus-data-find (car expirable))
8183 (gnus-summary-mark-article
8184 (car expirable) gnus-canceled-mark)))
8185 (setq expirable (cdr expirable))))))
8186 (gnus-message 6 "Expiring articles...done")))))
8188 (defun gnus-summary-expire-articles-now ()
8189 "Expunge all expirable articles in the current group.
8190 This means that *all* articles that are marked as expirable will be
8191 deleted forever, right now."
8193 (or gnus-expert-user
8195 "Are you really, really, really sure you want to delete all these messages? ")
8197 (gnus-summary-expire-articles t))
8199 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8200 (defun gnus-summary-delete-article (&optional n)
8201 "Delete the N next (mail) articles.
8202 This command actually deletes articles. This is not a marking
8203 command. The article will disappear forever from your life, never to
8205 If N is negative, delete backwards.
8206 If N is nil and articles have been marked with the process mark,
8207 delete these instead."
8209 (unless (gnus-check-backend-function 'request-expire-articles
8210 gnus-newsgroup-name)
8211 (error "The current newsgroup does not support article deletion"))
8212 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8213 (error "Couldn't open server"))
8214 ;; Compute the list of articles to delete.
8215 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8217 (if (and gnus-novice-user
8218 (not (gnus-yes-or-no-p
8219 (format "Do you really want to delete %s forever? "
8220 (if (> (length articles) 1)
8221 (format "these %s articles" (length articles))
8224 ;; Delete the articles.
8225 (setq not-deleted (gnus-request-expire-articles
8226 articles gnus-newsgroup-name 'force))
8228 (gnus-summary-remove-process-mark (car articles))
8229 ;; The backend might not have been able to delete the article
8231 (unless (memq (car articles) not-deleted)
8232 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8233 (setq articles (cdr articles)))
8235 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8236 (gnus-summary-position-point)
8237 (gnus-set-mode-line 'summary)
8240 (defun gnus-summary-edit-article (&optional force)
8241 "Edit the current article.
8242 This will have permanent effect only in mail groups.
8243 If FORCE is non-nil, allow editing of articles even in read-only
8247 (set-buffer gnus-summary-buffer)
8248 (let ((mail-parse-charset gnus-newsgroup-charset)
8249 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8250 (gnus-set-global-variables)
8251 (when (and (not force)
8252 (gnus-group-read-only-p))
8253 (error "The current newsgroup does not support article editing"))
8254 (gnus-summary-show-article t)
8255 (gnus-article-edit-article
8257 `(lambda (no-highlight)
8258 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8259 (message-options message-options)
8260 (message-options-set-recipient)
8261 (mail-parse-ignored-charsets
8262 ',gnus-newsgroup-ignored-charsets))
8263 (gnus-summary-edit-article-done
8264 ,(or (mail-header-references gnus-current-headers) "")
8265 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8267 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8269 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8271 "Make edits to the current article permanent."
8274 ;; The buffer restriction contains the entire article if it exists.
8275 (when (article-goto-body)
8276 (let ((lines (count-lines (point) (point-max)))
8277 (length (- (point-max) (point)))
8278 (case-fold-search t)
8279 (body (copy-marker (point))))
8280 (goto-char (point-min))
8281 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8282 (delete-region (match-beginning 1) (match-end 1))
8283 (insert (number-to-string length)))
8284 (goto-char (point-min))
8285 (when (re-search-forward
8286 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8287 (delete-region (match-beginning 1) (match-end 1))
8288 (insert (number-to-string length)))
8289 (goto-char (point-min))
8290 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8291 (delete-region (match-beginning 1) (match-end 1))
8292 (insert (number-to-string lines))))))
8293 ;; Replace the article.
8294 (let ((buf (current-buffer)))
8296 (insert-buffer-substring buf)
8298 (if (and (not read-only)
8299 (not (gnus-request-replace-article
8300 (cdr gnus-article-current) (car gnus-article-current)
8301 (current-buffer) t)))
8302 (error "Couldn't replace article")
8303 ;; Update the summary buffer.
8305 (equal (message-tokenize-header references " ")
8306 (message-tokenize-header
8307 (or (message-fetch-field "references") "") " ")))
8308 ;; We only have to update this line.
8311 (message-narrow-to-head)
8312 (let ((head (buffer-string))
8315 (insert (format "211 %d Article retrieved.\n"
8316 (cdr gnus-article-current)))
8319 (let ((nntp-server-buffer (current-buffer)))
8320 (setq header (car (gnus-get-newsgroup-headers
8322 (set-buffer gnus-summary-buffer)
8323 gnus-newsgroup-dependencies)
8326 (set-buffer gnus-summary-buffer)
8327 (gnus-data-set-header
8328 (gnus-data-find (cdr gnus-article-current))
8330 (gnus-summary-update-article-line
8331 (cdr gnus-article-current) header))))))
8333 (set-buffer (or buffer gnus-summary-buffer))
8334 (gnus-summary-update-article (cdr gnus-article-current)))
8335 ;; Prettify the article buffer again.
8336 (unless no-highlight
8338 (set-buffer gnus-article-buffer)
8339 ;;;!!! Fix this -- article should be rehighlighted.
8340 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8341 (set-buffer gnus-original-article-buffer)
8342 (gnus-request-article
8343 (cdr gnus-article-current)
8344 (car gnus-article-current) (current-buffer))))
8345 ;; Prettify the summary buffer line.
8346 (when (gnus-visual-p 'summary-highlight 'highlight)
8347 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8349 (defun gnus-summary-edit-wash (key)
8350 "Perform editing command KEY in the article buffer."
8354 (message "%s" (concat (this-command-keys) "- "))
8357 (gnus-summary-edit-article)
8358 (execute-kbd-macro (concat (this-command-keys) key))
8359 (gnus-article-edit-done))
8363 (defun gnus-summary-respool-query (&optional silent trace)
8364 "Query where the respool algorithm would put this article."
8366 (let (gnus-mark-article-hook)
8367 (gnus-summary-select-article)
8369 (set-buffer gnus-original-article-buffer)
8371 (message-narrow-to-head)
8372 (let ((groups (nnmail-article-group 'identity trace)))
8375 (message "This message would go to %s"
8376 (mapconcat 'car groups ", "))
8377 (message "This message would go to no groups"))
8380 (defun gnus-summary-respool-trace ()
8381 "Trace where the respool algorithm would put this article.
8382 Display a buffer showing all fancy splitting patterns which matched."
8384 (gnus-summary-respool-query nil t))
8386 ;; Summary marking commands.
8388 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8389 "Mark articles which has the same subject as read, and then select the next.
8390 If UNMARK is positive, remove any kind of mark.
8391 If UNMARK is negative, tick articles."
8394 (setq unmark (prefix-numeric-value unmark)))
8396 (gnus-summary-mark-same-subject
8397 (gnus-summary-article-subject) unmark)))
8398 ;; Select next unread article. If auto-select-same mode, should
8399 ;; select the first unread article.
8400 (gnus-summary-next-article t (and gnus-auto-select-same
8401 (gnus-summary-article-subject)))
8402 (gnus-message 7 "%d article%s marked as %s"
8403 count (if (= count 1) " is" "s are")
8404 (if unmark "unread" "read"))))
8406 (defun gnus-summary-kill-same-subject (&optional unmark)
8407 "Mark articles which has the same subject as read.
8408 If UNMARK is positive, remove any kind of mark.
8409 If UNMARK is negative, tick articles."
8412 (setq unmark (prefix-numeric-value unmark)))
8414 (gnus-summary-mark-same-subject
8415 (gnus-summary-article-subject) unmark)))
8416 ;; If marked as read, go to next unread subject.
8418 ;; Go to next unread subject.
8419 (gnus-summary-next-subject 1 t))
8420 (gnus-message 7 "%d articles are marked as %s"
8421 count (if unmark "unread" "read"))))
8423 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8424 "Mark articles with same SUBJECT as read, and return marked number.
8425 If optional argument UNMARK is positive, remove any kinds of marks.
8426 If optional argument UNMARK is negative, mark articles as unread instead."
8430 ((null unmark) ; Mark as read.
8433 (gnus-summary-mark-article-as-read gnus-killed-mark)
8434 (gnus-summary-show-thread) t)
8435 (gnus-summary-find-subject subject))
8436 (setq count (1+ count))))
8437 ((> unmark 0) ; Tick.
8440 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8441 (gnus-summary-show-thread) t)
8442 (gnus-summary-find-subject subject))
8443 (setq count (1+ count))))
8444 (t ; Mark as unread.
8447 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8448 (gnus-summary-show-thread) t)
8449 (gnus-summary-find-subject subject))
8450 (setq count (1+ count)))))
8451 (gnus-set-mode-line 'summary)
8452 ;; Return the number of marked articles.
8455 (defun gnus-summary-mark-as-processable (n &optional unmark)
8456 "Set the process mark on the next N articles.
8457 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8458 the process mark instead. The difference between N and the actual
8459 number of articles marked is returned."
8461 (if (and (null n) (gnus-region-active-p))
8462 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8463 (setq n (prefix-numeric-value n))
8464 (let ((backward (< n 0))
8469 (gnus-summary-remove-process-mark
8470 (gnus-summary-article-number))
8471 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8472 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8475 (gnus-message 7 "No more articles"))
8476 (gnus-summary-recenter)
8477 (gnus-summary-position-point)
8480 (defun gnus-summary-unmark-as-processable (n)
8481 "Remove the process mark from the next N articles.
8482 If N is negative, unmark backward instead. The difference between N and
8483 the actual number of articles unmarked is returned."
8485 (gnus-summary-mark-as-processable n t))
8487 (defun gnus-summary-unmark-all-processable ()
8488 "Remove the process mark from all articles."
8491 (while gnus-newsgroup-processable
8492 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8493 (gnus-summary-position-point))
8495 (defun gnus-summary-add-mark (article type)
8496 "Mark ARTICLE with a mark of TYPE."
8497 (let ((vtype (car (assq type gnus-article-mark-lists)))
8500 (error "No such mark type: %s" type)
8501 (setq var (intern (format "gnus-newsgroup-%s" type)))
8502 (set var (cons article (symbol-value var)))
8503 (if (memq type '(processable cached replied saved))
8504 (gnus-summary-update-secondary-mark article)
8505 ;;; !!! This is bobus. We should find out what primary
8506 ;;; !!! mark we want to set.
8507 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8509 (defun gnus-summary-mark-as-expirable (n)
8510 "Mark N articles forward as expirable.
8511 If N is negative, mark backward instead. The difference between N and
8512 the actual number of articles marked is returned."
8514 (gnus-summary-mark-forward n gnus-expirable-mark))
8516 (defun gnus-summary-mark-article-as-replied (article)
8517 "Mark ARTICLE replied and update the summary line."
8518 (push article gnus-newsgroup-replied)
8519 (let ((buffer-read-only nil))
8520 (when (gnus-summary-goto-subject article nil t)
8521 (gnus-summary-update-secondary-mark article))))
8523 (defun gnus-summary-set-bookmark (article)
8524 "Set a bookmark in current article."
8525 (interactive (list (gnus-summary-article-number)))
8526 (when (or (not (get-buffer gnus-article-buffer))
8527 (not gnus-current-article)
8528 (not gnus-article-current)
8529 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8530 (error "No current article selected"))
8531 ;; Remove old bookmark, if one exists.
8532 (let ((old (assq article gnus-newsgroup-bookmarks)))
8534 (setq gnus-newsgroup-bookmarks
8535 (delq old gnus-newsgroup-bookmarks))))
8536 ;; Set the new bookmark, which is on the form
8537 ;; (article-number . line-number-in-body).
8541 (set-buffer gnus-article-buffer)
8545 (goto-char (point-min))
8546 (search-forward "\n\n" nil t)
8549 gnus-newsgroup-bookmarks)
8550 (gnus-message 6 "A bookmark has been added to the current article."))
8552 (defun gnus-summary-remove-bookmark (article)
8553 "Remove the bookmark from the current article."
8554 (interactive (list (gnus-summary-article-number)))
8555 ;; Remove old bookmark, if one exists.
8556 (let ((old (assq article gnus-newsgroup-bookmarks)))
8559 (setq gnus-newsgroup-bookmarks
8560 (delq old gnus-newsgroup-bookmarks))
8561 (gnus-message 6 "Removed bookmark."))
8562 (gnus-message 6 "No bookmark in current article."))))
8564 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8565 (defun gnus-summary-mark-as-dormant (n)
8566 "Mark N articles forward as dormant.
8567 If N is negative, mark backward instead. The difference between N and
8568 the actual number of articles marked is returned."
8570 (gnus-summary-mark-forward n gnus-dormant-mark))
8572 (defun gnus-summary-set-process-mark (article)
8573 "Set the process mark on ARTICLE and update the summary line."
8574 (setq gnus-newsgroup-processable
8576 (delq article gnus-newsgroup-processable)))
8577 (when (gnus-summary-goto-subject article)
8578 (gnus-summary-show-thread)
8579 (gnus-summary-goto-subject article)
8580 (gnus-summary-update-secondary-mark article)))
8582 (defun gnus-summary-remove-process-mark (article)
8583 "Remove the process mark from ARTICLE and update the summary line."
8584 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8585 (when (gnus-summary-goto-subject article)
8586 (gnus-summary-show-thread)
8587 (gnus-summary-goto-subject article)
8588 (gnus-summary-update-secondary-mark article)))
8590 (defun gnus-summary-set-saved-mark (article)
8591 "Set the process mark on ARTICLE and update the summary line."
8592 (push article gnus-newsgroup-saved)
8593 (when (gnus-summary-goto-subject article)
8594 (gnus-summary-update-secondary-mark article)))
8596 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8597 "Mark N articles as read forwards.
8598 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8599 The difference between N and the actual number of articles marked is
8601 Iff NO-EXPIRE, auto-expiry will be inhibited."
8603 (gnus-summary-show-thread)
8604 (let ((backward (< n 0))
8605 (gnus-summary-goto-unread
8606 (and gnus-summary-goto-unread
8607 (not (eq gnus-summary-goto-unread 'never))
8608 (not (memq mark (list gnus-unread-mark
8609 gnus-ticked-mark gnus-dormant-mark)))))
8611 (mark (or mark gnus-del-mark)))
8613 (gnus-summary-mark-article nil mark no-expire)
8614 (zerop (gnus-summary-next-subject
8616 (and gnus-summary-goto-unread
8617 (not (eq gnus-summary-goto-unread 'never)))
8621 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8622 (gnus-summary-recenter)
8623 (gnus-summary-position-point)
8624 (gnus-set-mode-line 'summary)
8627 (defun gnus-summary-mark-article-as-read (mark)
8628 "Mark the current article quickly as read with MARK."
8629 (let ((article (gnus-summary-article-number)))
8630 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8631 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8632 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8633 (push (cons article mark) gnus-newsgroup-reads)
8634 ;; Possibly remove from cache, if that is used.
8635 (when gnus-use-cache
8636 (gnus-cache-enter-remove-article article))
8637 ;; Allow the backend to change the mark.
8638 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8639 ;; Check for auto-expiry.
8640 (when (and gnus-newsgroup-auto-expire
8641 (memq mark gnus-auto-expirable-marks))
8642 (setq mark gnus-expirable-mark)
8643 ;; Let the backend know about the mark change.
8644 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8645 (push article gnus-newsgroup-expirable))
8646 ;; Set the mark in the buffer.
8647 (gnus-summary-update-mark mark 'unread)
8650 (defun gnus-summary-mark-article-as-unread (mark)
8651 "Mark the current article quickly as unread with MARK."
8652 (let* ((article (gnus-summary-article-number))
8653 (old-mark (gnus-summary-article-mark article)))
8654 ;; Allow the backend to change the mark.
8655 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8656 (if (eq mark old-mark)
8660 (gnus-error 1 "Can't mark negative article numbers")
8662 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8663 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8664 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8665 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8666 (cond ((= mark gnus-ticked-mark)
8667 (push article gnus-newsgroup-marked))
8668 ((= mark gnus-dormant-mark)
8669 (push article gnus-newsgroup-dormant))
8671 (push article gnus-newsgroup-unreads)))
8672 (gnus-pull article gnus-newsgroup-reads)
8674 ;; See whether the article is to be put in the cache.
8676 (vectorp (gnus-summary-article-header article))
8678 (gnus-cache-possibly-enter-article
8679 gnus-newsgroup-name article
8680 (gnus-summary-article-header article)
8681 (= mark gnus-ticked-mark)
8682 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8685 (gnus-summary-update-mark mark 'unread)
8688 (defun gnus-summary-mark-article (&optional article mark no-expire)
8689 "Mark ARTICLE with MARK. MARK can be any character.
8690 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8691 `??' (dormant) and `?E' (expirable).
8692 If MARK is nil, then the default character `?r' is used.
8693 If ARTICLE is nil, then the article on the current line will be
8695 Iff NO-EXPIRE, auto-expiry will be inhibited."
8696 ;; The mark might be a string.
8697 (when (stringp mark)
8698 (setq mark (aref mark 0)))
8699 ;; If no mark is given, then we check auto-expiring.
8701 (setq mark gnus-del-mark))
8702 (when (and (not no-expire)
8703 gnus-newsgroup-auto-expire
8704 (memq mark gnus-auto-expirable-marks))
8705 (setq mark gnus-expirable-mark))
8706 (let ((article (or article (gnus-summary-article-number)))
8707 (old-mark (gnus-summary-article-mark article)))
8708 ;; Allow the backend to change the mark.
8709 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8710 (if (eq mark old-mark)
8713 (error "No article on current line"))
8714 (if (not (if (or (= mark gnus-unread-mark)
8715 (= mark gnus-ticked-mark)
8716 (= mark gnus-dormant-mark))
8717 (gnus-mark-article-as-unread article mark)
8718 (gnus-mark-article-as-read article mark)))
8720 ;; See whether the article is to be put in the cache.
8722 (not (= mark gnus-canceled-mark))
8723 (vectorp (gnus-summary-article-header article))
8725 (gnus-cache-possibly-enter-article
8726 gnus-newsgroup-name article
8727 (gnus-summary-article-header article)
8728 (= mark gnus-ticked-mark)
8729 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8731 (when (gnus-summary-goto-subject article nil t)
8732 (let ((buffer-read-only nil))
8733 (gnus-summary-show-thread)
8735 (gnus-summary-update-mark mark 'unread)
8738 (defun gnus-summary-update-secondary-mark (article)
8739 "Update the secondary (read, process, cache) mark."
8740 (gnus-summary-update-mark
8741 (cond ((memq article gnus-newsgroup-processable)
8743 ((memq article gnus-newsgroup-cached)
8745 ((memq article gnus-newsgroup-replied)
8747 ((memq article gnus-newsgroup-saved)
8751 (when (gnus-visual-p 'summary-highlight 'highlight)
8752 (gnus-run-hooks 'gnus-summary-update-hook))
8755 (defun gnus-summary-update-mark (mark type)
8756 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8757 (buffer-read-only nil))
8758 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8760 (when (looking-at "\r")
8762 (when (<= (+ forward (point)) (point-max))
8763 ;; Go to the right position on the line.
8764 (goto-char (+ forward (point)))
8765 ;; Replace the old mark with the new mark.
8766 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8767 ;; Optionally update the marks by some user rule.
8768 (when (eq type 'unread)
8770 (gnus-data-find (gnus-summary-article-number)) mark)
8771 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8773 (defun gnus-mark-article-as-read (article &optional mark)
8774 "Enter ARTICLE in the pertinent lists and remove it from others."
8775 ;; Make the article expirable.
8776 (let ((mark (or mark gnus-del-mark)))
8777 (if (= mark gnus-expirable-mark)
8778 (push article gnus-newsgroup-expirable)
8779 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8780 ;; Remove from unread and marked lists.
8781 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8782 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8783 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8784 (push (cons article mark) gnus-newsgroup-reads)
8785 ;; Possibly remove from cache, if that is used.
8786 (when gnus-use-cache
8787 (gnus-cache-enter-remove-article article))
8790 (defun gnus-mark-article-as-unread (article &optional mark)
8791 "Enter ARTICLE in the pertinent lists and remove it from others."
8792 (let ((mark (or mark gnus-ticked-mark)))
8795 (gnus-error 1 "Can't mark negative article numbers")
8797 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8798 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8799 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8800 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8802 ;; Unsuppress duplicates?
8803 (when gnus-suppress-duplicates
8804 (gnus-dup-unsuppress-article article))
8806 (cond ((= mark gnus-ticked-mark)
8807 (push article gnus-newsgroup-marked))
8808 ((= mark gnus-dormant-mark)
8809 (push article gnus-newsgroup-dormant))
8811 (push article gnus-newsgroup-unreads)))
8812 (gnus-pull article gnus-newsgroup-reads)
8815 (defalias 'gnus-summary-mark-as-unread-forward
8816 'gnus-summary-tick-article-forward)
8817 (make-obsolete 'gnus-summary-mark-as-unread-forward
8818 'gnus-summary-tick-article-forward)
8819 (defun gnus-summary-tick-article-forward (n)
8820 "Tick N articles forwards.
8821 If N is negative, tick backwards instead.
8822 The difference between N and the number of articles ticked is returned."
8824 (gnus-summary-mark-forward n gnus-ticked-mark))
8826 (defalias 'gnus-summary-mark-as-unread-backward
8827 'gnus-summary-tick-article-backward)
8828 (make-obsolete 'gnus-summary-mark-as-unread-backward
8829 'gnus-summary-tick-article-backward)
8830 (defun gnus-summary-tick-article-backward (n)
8831 "Tick N articles backwards.
8832 The difference between N and the number of articles ticked is returned."
8834 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8836 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8837 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8838 (defun gnus-summary-tick-article (&optional article clear-mark)
8839 "Mark current article as unread.
8840 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8841 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8843 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8846 (defun gnus-summary-mark-as-read-forward (n)
8847 "Mark N articles as read forwards.
8848 If N is negative, mark backwards instead.
8849 The difference between N and the actual number of articles marked is
8852 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8854 (defun gnus-summary-mark-as-read-backward (n)
8855 "Mark the N articles as read backwards.
8856 The difference between N and the actual number of articles marked is
8859 (gnus-summary-mark-forward
8860 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8862 (defun gnus-summary-mark-as-read (&optional article mark)
8863 "Mark current article as read.
8864 ARTICLE specifies the article to be marked as read.
8865 MARK specifies a string to be inserted at the beginning of the line."
8866 (gnus-summary-mark-article article mark))
8868 (defun gnus-summary-clear-mark-forward (n)
8869 "Clear marks from N articles forward.
8870 If N is negative, clear backward instead.
8871 The difference between N and the number of marks cleared is returned."
8873 (gnus-summary-mark-forward n gnus-unread-mark))
8875 (defun gnus-summary-clear-mark-backward (n)
8876 "Clear marks from N articles backward.
8877 The difference between N and the number of marks cleared is returned."
8879 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8881 (defun gnus-summary-mark-unread-as-read ()
8882 "Intended to be used by `gnus-summary-mark-article-hook'."
8883 (when (memq gnus-current-article gnus-newsgroup-unreads)
8884 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8886 (defun gnus-summary-mark-read-and-unread-as-read ()
8887 "Intended to be used by `gnus-summary-mark-article-hook'."
8888 (let ((mark (gnus-summary-article-mark)))
8889 (when (or (gnus-unread-mark-p mark)
8890 (gnus-read-mark-p mark))
8891 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8893 (defun gnus-summary-mark-unread-as-ticked ()
8894 "Intended to be used by `gnus-summary-mark-article-hook'."
8895 (when (memq gnus-current-article gnus-newsgroup-unreads)
8896 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8898 (defun gnus-summary-mark-region-as-read (point mark all)
8899 "Mark all unread articles between point and mark as read.
8900 If given a prefix, mark all articles between point and mark as read,
8901 even ticked and dormant ones."
8902 (interactive "r\nP")
8911 (memq (setq article (gnus-summary-article-number))
8912 gnus-newsgroup-unreads))
8913 (gnus-summary-mark-article article gnus-del-mark))
8915 (gnus-summary-find-next))))))
8917 (defun gnus-summary-mark-below (score mark)
8918 "Mark articles with score less than SCORE with MARK."
8919 (interactive "P\ncMark: ")
8920 (setq score (if score
8921 (prefix-numeric-value score)
8922 (or gnus-summary-default-score 0)))
8924 (set-buffer gnus-summary-buffer)
8925 (goto-char (point-min))
8928 (and (< (gnus-summary-article-score) score)
8929 (gnus-summary-mark-article nil mark))
8930 (gnus-summary-find-next)))))
8932 (defun gnus-summary-kill-below (&optional score)
8933 "Mark articles with score below SCORE as read."
8935 (gnus-summary-mark-below score gnus-killed-mark))
8937 (defun gnus-summary-clear-above (&optional score)
8938 "Clear all marks from articles with score above SCORE."
8940 (gnus-summary-mark-above score gnus-unread-mark))
8942 (defun gnus-summary-tick-above (&optional score)
8943 "Tick all articles with score above SCORE."
8945 (gnus-summary-mark-above score gnus-ticked-mark))
8947 (defun gnus-summary-mark-above (score mark)
8948 "Mark articles with score over SCORE with MARK."
8949 (interactive "P\ncMark: ")
8950 (setq score (if score
8951 (prefix-numeric-value score)
8952 (or gnus-summary-default-score 0)))
8954 (set-buffer gnus-summary-buffer)
8955 (goto-char (point-min))
8957 (when (> (gnus-summary-article-score) score)
8958 (gnus-summary-mark-article nil mark))
8960 (gnus-summary-find-next)))))
8962 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8963 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8964 (defun gnus-summary-limit-include-expunged (&optional no-error)
8965 "Display all the hidden articles that were expunged for low scores."
8967 (let ((buffer-read-only nil))
8968 (let ((scored gnus-newsgroup-scored)
8971 (unless (gnus-number-to-header (caar scored))
8972 (and (setq h (gnus-summary-article-header (caar scored)))
8973 (< (cdar scored) gnus-summary-expunge-below)
8975 (setq scored (cdr scored)))
8977 (when (not no-error)
8978 (error "No expunged articles hidden"))
8979 (goto-char (point-min))
8980 (gnus-summary-prepare-unthreaded (nreverse headers))
8981 (goto-char (point-min))
8982 (gnus-summary-position-point)
8985 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8986 "Mark all unread articles in this newsgroup as read.
8987 If prefix argument ALL is non-nil, ticked and dormant articles will
8988 also be marked as read.
8989 If QUIETLY is non-nil, no questions will be asked.
8990 If TO-HERE is non-nil, it should be a point in the buffer. All
8991 articles before this point will be marked as read.
8992 Note that this function will only catch up the unread article
8993 in the current summary buffer limitation.
8994 The number of articles marked as read is returned."
8999 (not gnus-interactive-catchup) ;Without confirmation?
9003 "Mark absolutely all articles as read? "
9004 "Mark all unread articles as read? ")))
9006 (not gnus-newsgroup-adaptive)
9007 (not gnus-newsgroup-auto-expire)
9008 (not gnus-suppress-duplicates)
9009 (or (not gnus-use-cache)
9010 (eq gnus-use-cache 'passive)))
9013 (setq gnus-newsgroup-marked nil
9014 gnus-newsgroup-dormant nil))
9015 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9016 ;; We actually mark all articles as canceled, which we
9017 ;; have to do when using auto-expiry or adaptive scoring.
9018 (gnus-summary-show-all-threads)
9019 (when (gnus-summary-first-subject (not all) t)
9021 (if to-here (< (point) to-here) t)
9022 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9023 (gnus-summary-find-next (not all) nil nil t))))
9024 (gnus-set-mode-line 'summary))
9026 (gnus-summary-position-point)))
9028 (defun gnus-summary-catchup-to-here (&optional all)
9029 "Mark all unticked articles before the current one as read.
9030 If ALL is non-nil, also mark ticked and dormant articles as read."
9033 (gnus-save-hidden-threads
9034 (let ((beg (point)))
9035 ;; We check that there are unread articles.
9036 (when (or all (gnus-summary-find-prev))
9037 (gnus-summary-catchup all t beg)))))
9038 (gnus-summary-position-point))
9040 (defun gnus-summary-catchup-all (&optional quietly)
9041 "Mark all articles in this newsgroup as read."
9043 (gnus-summary-catchup t quietly))
9045 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9046 "Mark all unread articles in this group as read, then exit.
9047 If prefix argument ALL is non-nil, all articles are marked as read."
9049 (when (gnus-summary-catchup all quietly nil 'fast)
9050 ;; Select next newsgroup or exit.
9051 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9052 (eq gnus-auto-select-next 'quietly))
9053 (gnus-summary-next-group nil)
9054 (gnus-summary-exit))))
9056 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9057 "Mark all articles in this newsgroup as read, and then exit."
9059 (gnus-summary-catchup-and-exit t quietly))
9061 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9062 "Mark all articles in this group as read and select the next group.
9063 If given a prefix, mark all articles, unread as well as ticked, as
9067 (gnus-summary-catchup all))
9068 (gnus-summary-next-group))
9074 (defmacro gnus-with-article (article &rest forms)
9075 "Select ARTICLE and perform FORMS in the original article buffer.
9076 Then replace the article with the result."
9078 ;; We don't want the article to be marked as read.
9079 (let (gnus-mark-article-hook)
9080 (gnus-summary-select-article t t nil ,article))
9081 (set-buffer gnus-original-article-buffer)
9083 (if (not (gnus-check-backend-function
9084 'request-replace-article (car gnus-article-current)))
9085 (gnus-message 5 "Read-only group; not replacing")
9086 (unless (gnus-request-replace-article
9087 ,article (car gnus-article-current)
9089 (error "Couldn't replace article")))
9090 ;; The cache and backlog have to be flushed somewhat.
9091 (when gnus-keep-backlog
9092 (gnus-backlog-remove-article
9093 (car gnus-article-current) (cdr gnus-article-current)))
9094 (when gnus-use-cache
9095 (gnus-cache-update-article
9096 (car gnus-article-current) (cdr gnus-article-current)))))
9098 (put 'gnus-with-article 'lisp-indent-function 1)
9099 (put 'gnus-with-article 'edebug-form-spec '(form body))
9101 ;; Thread-based commands.
9103 (defun gnus-summary-articles-in-thread (&optional article)
9104 "Return a list of all articles in the current thread.
9105 If ARTICLE is non-nil, return all articles in the thread that starts
9107 (let* ((article (or article (gnus-summary-article-number)))
9108 (data (gnus-data-find-list article))
9109 (top-level (gnus-data-level (car data)))
9111 (cond ((null gnus-thread-operation-ignore-subject)
9112 (gnus-simplify-subject-re
9113 (mail-header-subject (gnus-data-header (car data)))))
9114 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9115 (gnus-simplify-subject-fuzzy
9116 (mail-header-subject (gnus-data-header (car data)))))
9118 (end-point (save-excursion
9119 (if (gnus-summary-go-to-next-thread)
9120 (point) (point-max))))
9123 (< (gnus-data-pos (car data)) end-point))
9124 (when (or (not top-subject)
9125 (string= top-subject
9126 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9127 (gnus-simplify-subject-fuzzy
9128 (mail-header-subject
9129 (gnus-data-header (car data))))
9130 (gnus-simplify-subject-re
9131 (mail-header-subject
9132 (gnus-data-header (car data)))))))
9133 (push (gnus-data-number (car data)) articles))
9134 (unless (and (setq data (cdr data))
9135 (> (gnus-data-level (car data)) top-level))
9137 ;; Return the list of articles.
9138 (nreverse articles)))
9140 (defun gnus-summary-rethread-current ()
9141 "Rethread the thread the current article is part of."
9143 (let* ((gnus-show-threads t)
9144 (article (gnus-summary-article-number))
9145 (id (mail-header-id (gnus-summary-article-header)))
9146 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9148 (error "No article on the current line"))
9149 (gnus-rebuild-thread id)
9150 (gnus-summary-goto-subject article)))
9152 (defun gnus-summary-reparent-thread ()
9153 "Make the current article child of the marked (or previous) article.
9155 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9156 is non-nil or the Subject: of both articles are the same."
9158 (unless (not (gnus-group-read-only-p))
9159 (error "The current newsgroup does not support article editing"))
9160 (unless (<= (length gnus-newsgroup-processable) 1)
9161 (error "No more than one article may be marked"))
9162 (save-window-excursion
9163 (let ((gnus-article-buffer " *reparent*")
9164 (current-article (gnus-summary-article-number))
9165 ;; First grab the marked article, otherwise one line up.
9166 (parent-article (if (not (null gnus-newsgroup-processable))
9167 (car gnus-newsgroup-processable)
9169 (if (eq (forward-line -1) 0)
9170 (gnus-summary-article-number)
9171 (error "Beginning of summary buffer"))))))
9172 (unless (not (eq current-article parent-article))
9173 (error "An article may not be self-referential"))
9174 (let ((message-id (mail-header-id
9175 (gnus-summary-article-header parent-article))))
9176 (unless (and message-id (not (equal message-id "")))
9177 (error "No message-id in desired parent"))
9178 (gnus-with-article current-article
9180 (goto-char (point-min))
9181 (message-narrow-to-head)
9182 (if (re-search-forward "^References: " nil t)
9184 (re-search-forward "^[^ \t]" nil t)
9187 (insert " " message-id))
9188 (insert "References: " message-id "\n"))))
9189 (set-buffer gnus-summary-buffer)
9190 (gnus-summary-unmark-all-processable)
9191 (gnus-summary-update-article current-article)
9192 (gnus-summary-rethread-current)
9193 (gnus-message 3 "Article %d is now the child of article %d"
9194 current-article parent-article)))))
9196 (defun gnus-summary-toggle-threads (&optional arg)
9197 "Toggle showing conversation threads.
9198 If ARG is positive number, turn showing conversation threads on."
9200 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9201 (setq gnus-show-threads
9202 (if (null arg) (not gnus-show-threads)
9203 (> (prefix-numeric-value arg) 0)))
9204 (gnus-summary-prepare)
9205 (gnus-summary-goto-subject current)
9206 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9207 (gnus-summary-position-point)))
9209 (defun gnus-summary-show-all-threads ()
9213 (let ((buffer-read-only nil))
9214 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9215 (gnus-summary-position-point))
9217 (defun gnus-summary-show-thread ()
9218 "Show thread subtrees.
9219 Returns nil if no thread was there to be shown."
9221 (let ((buffer-read-only nil)
9223 ;; first goto end then to beg, to have point at beg after let
9224 (end (progn (end-of-line) (point)))
9225 (beg (progn (beginning-of-line) (point))))
9227 ;; Any hidden lines here?
9228 (search-forward "\r" end t)
9229 (subst-char-in-region beg end ?\^M ?\n t)
9231 (gnus-summary-position-point))))
9233 (defun gnus-summary-hide-all-threads ()
9234 "Hide all thread subtrees."
9237 (goto-char (point-min))
9238 (gnus-summary-hide-thread)
9239 (while (zerop (gnus-summary-next-thread 1 t))
9240 (gnus-summary-hide-thread)))
9241 (gnus-summary-position-point))
9243 (defun gnus-summary-hide-thread ()
9244 "Hide thread subtrees.
9245 Returns nil if no threads were there to be hidden."
9247 (let ((buffer-read-only nil)
9249 (article (gnus-summary-article-number)))
9251 ;; Go forward until either the buffer ends or the subthread
9253 (when (and (not (eobp))
9254 (or (zerop (gnus-summary-next-thread 1 t))
9255 (goto-char (point-max))))
9257 (if (and (> (point) start)
9258 (search-backward "\n" start t))
9260 (subst-char-in-region start (point) ?\n ?\^M)
9261 (gnus-summary-goto-subject article))
9265 (defun gnus-summary-go-to-next-thread (&optional previous)
9266 "Go to the same level (or less) next thread.
9267 If PREVIOUS is non-nil, go to previous thread instead.
9268 Return the article number moved to, or nil if moving was impossible."
9269 (let ((level (gnus-summary-thread-level))
9270 (way (if previous -1 1))
9273 (while (and (not (eobp))
9274 (< level (gnus-summary-thread-level)))
9282 (gnus-summary-article-number)
9285 (defun gnus-summary-next-thread (n &optional silent)
9286 "Go to the same level next N'th thread.
9287 If N is negative, search backward instead.
9288 Returns the difference between N and the number of skips actually
9291 If SILENT, don't output messages."
9293 (let ((backward (< n 0))
9296 (gnus-summary-go-to-next-thread backward))
9299 (gnus-summary-position-point))
9300 (when (and (not silent) (/= 0 n))
9301 (gnus-message 7 "No more threads"))
9304 (defun gnus-summary-prev-thread (n)
9305 "Go to the same level previous N'th thread.
9306 Returns the difference between N and the number of skips actually
9309 (gnus-summary-next-thread (- n)))
9311 (defun gnus-summary-go-down-thread ()
9312 "Go down one level in the current thread."
9313 (let ((children (gnus-summary-article-children)))
9315 (gnus-summary-goto-subject (car children)))))
9317 (defun gnus-summary-go-up-thread ()
9318 "Go up one level in the current thread."
9319 (let ((parent (gnus-summary-article-parent)))
9321 (gnus-summary-goto-subject parent))))
9323 (defun gnus-summary-down-thread (n)
9324 "Go down thread N steps.
9325 If N is negative, go up instead.
9326 Returns the difference between N and how many steps down that were
9332 (if up (gnus-summary-go-up-thread)
9333 (gnus-summary-go-down-thread)))
9335 (gnus-summary-position-point)
9337 (gnus-message 7 "Can't go further"))
9340 (defun gnus-summary-up-thread (n)
9341 "Go up thread N steps.
9342 If N is negative, go up instead.
9343 Returns the difference between N and how many steps down that were
9346 (gnus-summary-down-thread (- n)))
9348 (defun gnus-summary-top-thread ()
9349 "Go to the top of the thread."
9351 (while (gnus-summary-go-up-thread))
9352 (gnus-summary-article-number))
9354 (defun gnus-summary-kill-thread (&optional unmark)
9355 "Mark articles under current thread as read.
9356 If the prefix argument is positive, remove any kinds of marks.
9357 If the prefix argument is negative, tick articles instead."
9360 (setq unmark (prefix-numeric-value unmark)))
9361 (let ((articles (gnus-summary-articles-in-thread)))
9363 ;; Expand the thread.
9364 (gnus-summary-show-thread)
9365 ;; Mark all the articles.
9367 (gnus-summary-goto-subject (car articles))
9368 (cond ((null unmark)
9369 (gnus-summary-mark-article-as-read gnus-killed-mark))
9371 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9373 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9374 (setq articles (cdr articles))))
9375 ;; Hide killed subtrees.
9377 gnus-thread-hide-killed
9378 (gnus-summary-hide-thread))
9379 ;; If marked as read, go to next unread subject.
9381 ;; Go to next unread subject.
9382 (gnus-summary-next-subject 1 t)))
9383 (gnus-set-mode-line 'summary))
9385 ;; Summary sorting commands
9387 (defun gnus-summary-sort-by-number (&optional reverse)
9388 "Sort the summary buffer by article number.
9389 Argument REVERSE means reverse order."
9391 (gnus-summary-sort 'number reverse))
9393 (defun gnus-summary-sort-by-author (&optional reverse)
9394 "Sort the summary buffer by author name alphabetically.
9395 If `case-fold-search' is non-nil, case of letters is ignored.
9396 Argument REVERSE means reverse order."
9398 (gnus-summary-sort 'author reverse))
9400 (defun gnus-summary-sort-by-subject (&optional reverse)
9401 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9402 If `case-fold-search' is non-nil, case of letters is ignored.
9403 Argument REVERSE means reverse order."
9405 (gnus-summary-sort 'subject reverse))
9407 (defun gnus-summary-sort-by-date (&optional reverse)
9408 "Sort the summary buffer by date.
9409 Argument REVERSE means reverse order."
9411 (gnus-summary-sort 'date reverse))
9413 (defun gnus-summary-sort-by-score (&optional reverse)
9414 "Sort the summary buffer by score.
9415 Argument REVERSE means reverse order."
9417 (gnus-summary-sort 'score reverse))
9419 (defun gnus-summary-sort-by-lines (&optional reverse)
9420 "Sort the summary buffer by the number of lines.
9421 Argument REVERSE means reverse order."
9423 (gnus-summary-sort 'lines reverse))
9425 (defun gnus-summary-sort-by-chars (&optional reverse)
9426 "Sort the summary buffer by article length.
9427 Argument REVERSE means reverse order."
9429 (gnus-summary-sort 'chars reverse))
9431 (defun gnus-summary-sort (predicate reverse)
9432 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9433 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9434 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9435 (gnus-thread-sort-functions
9440 (gnus-sort-gathered-threads-function
9441 gnus-thread-sort-functions)
9442 (gnus-article-sort-functions
9448 (gnus-summary-prepare-hook nil))
9449 ;; We do the sorting by regenerating the threads.
9450 (gnus-summary-prepare)
9451 ;; Hide subthreads if needed.
9452 (when (and gnus-show-threads gnus-thread-hide-subtree)
9453 (gnus-summary-hide-all-threads))))
9455 ;; Summary saving commands.
9457 (defun gnus-summary-save-article (&optional n not-saved)
9458 "Save the current article using the default saver function.
9459 If N is a positive number, save the N next articles.
9460 If N is a negative number, save the N previous articles.
9461 If N is nil and any articles have been marked with the process mark,
9462 save those articles instead.
9463 The variable `gnus-default-article-saver' specifies the saver function."
9465 (let* ((articles (gnus-summary-work-articles n))
9466 (save-buffer (save-excursion
9467 (nnheader-set-temp-buffer " *Gnus Save*")))
9468 (num (length articles))
9470 (dolist (article articles)
9471 (setq header (gnus-summary-article-header article))
9472 (if (not (vectorp header))
9473 ;; This is a pseudo-article.
9474 (if (assq 'name header)
9475 (gnus-copy-file (cdr (assq 'name header)))
9476 (gnus-message 1 "Article %d is unsaveable" article))
9477 ;; This is a real article.
9478 (save-window-excursion
9479 (gnus-summary-select-article t nil nil article))
9481 (set-buffer save-buffer)
9483 (insert-buffer-substring gnus-original-article-buffer))
9484 (setq file (gnus-article-save save-buffer file num))
9485 (gnus-summary-remove-process-mark article)
9487 (gnus-summary-set-saved-mark article))))
9488 (gnus-kill-buffer save-buffer)
9489 (gnus-summary-position-point)
9490 (gnus-set-mode-line 'summary)
9493 (defun gnus-summary-pipe-output (&optional arg)
9494 "Pipe the current article to a subprocess.
9495 If N is a positive number, pipe the N next articles.
9496 If N is a negative number, pipe the N previous articles.
9497 If N is nil and any articles have been marked with the process mark,
9498 pipe those articles instead."
9501 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9502 (gnus-summary-save-article arg t))
9503 (gnus-configure-windows 'pipe))
9505 (defun gnus-summary-save-article-mail (&optional arg)
9506 "Append the current article to an mail file.
9507 If N is a positive number, save the N next articles.
9508 If N is a negative number, save the N previous articles.
9509 If N is nil and any articles have been marked with the process mark,
9510 save those articles instead."
9513 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9514 (gnus-summary-save-article arg)))
9516 (defun gnus-summary-save-article-rmail (&optional arg)
9517 "Append the current article to an rmail file.
9518 If N is a positive number, save the N next articles.
9519 If N is a negative number, save the N previous articles.
9520 If N is nil and any articles have been marked with the process mark,
9521 save those articles instead."
9524 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9525 (gnus-summary-save-article arg)))
9527 (defun gnus-summary-save-article-file (&optional arg)
9528 "Append the current article to a file.
9529 If N is a positive number, save the N next articles.
9530 If N is a negative number, save the N previous articles.
9531 If N is nil and any articles have been marked with the process mark,
9532 save those articles instead."
9535 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9536 (gnus-summary-save-article arg)))
9538 (defun gnus-summary-write-article-file (&optional arg)
9539 "Write the current article to a file, deleting the previous file.
9540 If N is a positive number, save the N next articles.
9541 If N is a negative number, save the N previous articles.
9542 If N is nil and any articles have been marked with the process mark,
9543 save those articles instead."
9546 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9547 (gnus-summary-save-article arg)))
9549 (defun gnus-summary-save-article-body-file (&optional arg)
9550 "Append the current article body to a file.
9551 If N is a positive number, save the N next articles.
9552 If N is a negative number, save the N previous articles.
9553 If N is nil and any articles have been marked with the process mark,
9554 save those articles instead."
9557 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9558 (gnus-summary-save-article arg)))
9560 (defun gnus-summary-pipe-message (program)
9561 "Pipe the current article through PROGRAM."
9562 (interactive "sProgram: ")
9563 (gnus-summary-select-article)
9564 (let ((mail-header-separator ""))
9565 (gnus-eval-in-buffer-window gnus-article-buffer
9568 (let ((start (window-start))
9570 (message-pipe-buffer-body program)
9571 (set-window-start (get-buffer-window (current-buffer)) start))))))
9573 (defun gnus-get-split-value (methods)
9574 "Return a value based on the split METHODS."
9575 (let (split-name method result match)
9578 (set-buffer gnus-original-article-buffer)
9580 (nnheader-narrow-to-headers)
9581 (while (and methods (not split-name))
9582 (goto-char (point-min))
9583 (setq method (pop methods))
9584 (setq match (car method))
9587 ;; Regular expression.
9589 (re-search-forward match nil t)))
9590 ((gnus-functionp match)
9594 (setq result (funcall match gnus-newsgroup-name))))
9599 (setq result (eval match)))))
9600 (setq split-name (cdr method))
9601 (cond ((stringp result)
9602 (push (expand-file-name
9603 result gnus-article-save-directory)
9606 (setq split-name (append result split-name)))))))))
9607 (nreverse split-name)))
9609 (defun gnus-valid-move-group-p (group)
9612 (symbol-value group)
9613 (gnus-get-function (gnus-find-method-for-group
9614 (symbol-name group)) 'request-accept-article t)))
9616 (defun gnus-read-move-group-name (prompt default articles prefix)
9617 "Read a group name."
9618 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9619 (minibuffer-confirm-incomplete nil) ; XEmacs
9623 (if (> (length articles) 1)
9624 (format "these %d articles" (length articles))
9629 (gnus-completing-read default prom
9631 'gnus-valid-move-group-p
9633 'gnus-group-history))
9634 ((= 1 (length split-name))
9635 (gnus-completing-read (car split-name) prom
9637 'gnus-valid-move-group-p
9639 'gnus-group-history))
9641 (gnus-completing-read nil prom
9642 (mapcar (lambda (el) (list el))
9643 (nreverse split-name))
9645 'gnus-group-history))))
9646 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9648 (if (or (string= to-newsgroup "")
9649 (string= to-newsgroup prefix))
9650 (setq to-newsgroup default))
9651 (unless to-newsgroup
9652 (error "No group name entered"))
9653 (or (gnus-active to-newsgroup)
9654 (gnus-activate-group to-newsgroup nil nil to-method)
9655 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9657 (or (and (gnus-request-create-group to-newsgroup to-method)
9658 (gnus-activate-group
9659 to-newsgroup nil nil to-method)
9660 (gnus-subscribe-group to-newsgroup))
9661 (error "Couldn't create group %s" to-newsgroup)))
9662 (error "No such group: %s" to-newsgroup)))
9665 (defun gnus-summary-save-parts (type dir n &optional reverse)
9666 "Save parts matching TYPE to DIR.
9667 If REVERSE, save parts that do not match TYPE."
9669 (list (read-string "Save parts of type: "
9670 (or (car gnus-summary-save-parts-type-history)
9671 gnus-summary-save-parts-default-mime)
9672 'gnus-summary-save-parts-type-history)
9673 (setq gnus-summary-save-parts-last-directory
9674 (read-file-name "Save to directory: "
9675 gnus-summary-save-parts-last-directory
9677 current-prefix-arg))
9678 (gnus-summary-iterate n
9679 (let ((gnus-display-mime-function nil)
9680 (gnus-inhibit-treatment t))
9681 (gnus-summary-select-article))
9683 (set-buffer gnus-article-buffer)
9684 (let ((handles (or gnus-article-mime-handles
9685 (mm-dissect-buffer) (mm-uu-dissect))))
9687 (gnus-summary-save-parts-1 type dir handles reverse)
9688 (unless gnus-article-mime-handles ;; Don't destroy this case.
9689 (mm-destroy-parts handles)))))))
9691 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9692 (if (stringp (car handle))
9693 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9696 (not (string-match type (mm-handle-media-type handle)))
9697 (string-match type (mm-handle-media-type handle)))
9698 (let ((file (expand-file-name
9699 (file-name-nondirectory
9701 (mail-content-type-get
9702 (mm-handle-disposition handle) 'filename)
9703 (concat gnus-newsgroup-name
9704 "." (number-to-string
9705 (cdr gnus-article-current)))))
9707 (unless (file-exists-p file)
9708 (mm-save-part-to-file handle file))))))
9710 ;; Summary extract commands
9712 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9713 (let ((buffer-read-only nil)
9714 (article (gnus-summary-article-number))
9716 (unless (gnus-summary-goto-subject article)
9717 (error "No such article: %d" article))
9718 (gnus-summary-position-point)
9719 ;; If all commands are to be bunched up on one line, we collect
9721 (unless gnus-view-pseudos-separately
9722 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9725 (setq action (cdr (assq 'action (car ps))))
9726 (setq files (list (cdr (assq 'name (car ps)))))
9727 (while (and ps (cdr ps)
9728 (string= (or action "1")
9729 (or (cdr (assq 'action (cadr ps))) "2")))
9730 (push (cdr (assq 'name (cadr ps))) files)
9731 (setcdr ps (cddr ps)))
9733 (when (not (string-match "%s" action))
9736 (when (assq 'execute (car ps))
9737 (setcdr (assq 'execute (car ps))
9738 (funcall (if (string-match "%s" action)
9745 (gnus-quote-arg-for-sh-or-csh f)))
9747 (setq ps (cdr ps)))))
9748 (if (and gnus-view-pseudos (not not-view))
9750 (when (assq 'execute (car pslist))
9751 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9752 (eq gnus-view-pseudos 'not-confirm)))
9753 (setq pslist (cdr pslist)))
9756 (setq after-article (or (cdr (assq 'article (car pslist)))
9757 (gnus-summary-article-number)))
9758 (gnus-summary-goto-subject after-article)
9761 (insert " " (file-name-nondirectory
9762 (cdr (assq 'name (car pslist))))
9763 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9765 (forward-line -1) ; back to `b'
9766 (gnus-add-text-properties
9767 b (1- e) (list 'gnus-number gnus-reffed-article-number
9768 gnus-mouse-face-prop gnus-mouse-face))
9770 after-article gnus-reffed-article-number
9771 gnus-unread-mark b (car pslist) 0 (- e b))
9772 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9773 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9774 (setq pslist (cdr pslist)))))))
9776 (defun gnus-pseudos< (p1 p2)
9777 (let ((c1 (cdr (assq 'action p1)))
9778 (c2 (cdr (assq 'action p2))))
9779 (and c1 c2 (string< c1 c2))))
9781 (defun gnus-request-pseudo-article (props)
9782 (cond ((assq 'execute props)
9783 (gnus-execute-command (cdr (assq 'execute props)))))
9784 (let ((gnus-current-article (gnus-summary-article-number)))
9785 (gnus-run-hooks 'gnus-mark-article-hook)))
9787 (defun gnus-execute-command (command &optional automatic)
9789 (gnus-article-setup-buffer)
9790 (set-buffer gnus-article-buffer)
9791 (setq buffer-read-only nil)
9792 (let ((command (if automatic command
9793 (read-string "Command: " (cons command 0)))))
9795 (insert "$ " command "\n\n")
9796 (if gnus-view-pseudo-asynchronously
9797 (start-process "gnus-execute" (current-buffer) shell-file-name
9798 shell-command-switch command)
9799 (call-process shell-file-name nil t nil
9800 shell-command-switch command)))))
9802 ;; Summary kill commands.
9804 (defun gnus-summary-edit-global-kill (article)
9805 "Edit the \"global\" kill file."
9806 (interactive (list (gnus-summary-article-number)))
9807 (gnus-group-edit-global-kill article))
9809 (defun gnus-summary-edit-local-kill ()
9810 "Edit a local kill file applied to the current newsgroup."
9812 (setq gnus-current-headers (gnus-summary-article-header))
9813 (gnus-group-edit-local-kill
9814 (gnus-summary-article-number) gnus-newsgroup-name))
9818 (defun gnus-read-header (id &optional header)
9819 "Read the headers of article ID and enter them into the Gnus system."
9820 (let ((group gnus-newsgroup-name)
9821 (gnus-override-method
9823 gnus-override-method
9824 (and (gnus-news-group-p gnus-newsgroup-name)
9825 (car (gnus-refer-article-methods)))))
9827 ;; First we check to see whether the header in question is already
9830 ;; This is a Message-ID.
9831 (setq header (or header (gnus-id-to-header id)))
9832 ;; This is an article number.
9833 (setq header (or header (gnus-summary-article-header id))))
9835 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9836 ;; We have found the header.
9838 ;; If this is a sparse article, we have to nix out its
9839 ;; previous entry in the thread hashtb.
9841 (gnus-summary-article-sparse-p (mail-header-number header)))
9842 (let* ((parent (gnus-parent-id (mail-header-references header)))
9843 (thread (and parent (gnus-id-to-thread parent))))
9845 (delq (assq header thread) thread))))
9846 ;; We have to really fetch the header to this article.
9848 (set-buffer nntp-server-buffer)
9849 (when (setq where (gnus-request-head id group))
9850 (nnheader-fold-continuation-lines)
9851 (goto-char (point-max))
9853 (goto-char (point-min))
9857 ((cdr where) (cdr where))
9858 (header (mail-header-number header))
9859 (t gnus-reffed-article-number))
9861 (insert " Article retrieved.\n"))
9863 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9864 () ; Malformed head.
9865 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9866 (when (and (stringp id)
9867 (not (string= (gnus-group-real-name group)
9869 ;; If we fetched by Message-ID and the article came
9870 ;; from a different group, we fudge some bogus article
9871 ;; numbers for this article.
9872 (mail-header-set-number header gnus-reffed-article-number))
9874 (set-buffer gnus-summary-buffer)
9875 (decf gnus-reffed-article-number)
9876 (gnus-remove-header (mail-header-number header))
9877 (push header gnus-newsgroup-headers)
9878 (setq gnus-current-headers header)
9879 (push (mail-header-number header) gnus-newsgroup-limit)))
9882 (defun gnus-remove-header (number)
9883 "Remove header NUMBER from `gnus-newsgroup-headers'."
9884 (if (and gnus-newsgroup-headers
9885 (= number (mail-header-number (car gnus-newsgroup-headers))))
9886 (pop gnus-newsgroup-headers)
9887 (let ((headers gnus-newsgroup-headers))
9888 (while (and (cdr headers)
9889 (not (= number (mail-header-number (cadr headers)))))
9892 (setcdr headers (cddr headers))))))
9895 ;;; summary highlights
9898 (defun gnus-highlight-selected-summary ()
9899 "Highlight selected article in summary buffer."
9900 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9901 (when gnus-summary-selected-face
9903 (let* ((beg (progn (beginning-of-line) (point)))
9904 (end (progn (end-of-line) (point)))
9905 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9906 (from (if (get-text-property beg gnus-mouse-face-prop)
9908 (or (next-single-property-change
9909 beg gnus-mouse-face-prop nil end)
9914 (or (next-single-property-change
9915 from gnus-mouse-face-prop nil end)
9917 ;; If no mouse-face prop on line we will have to = from = end,
9918 ;; so we highlight the entire line instead.
9919 (when (= (+ to 2) from)
9922 (if gnus-newsgroup-selected-overlay
9923 ;; Move old overlay.
9925 gnus-newsgroup-selected-overlay from to (current-buffer))
9926 ;; Create new overlay.
9928 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9929 'face gnus-summary-selected-face))))))
9931 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9932 (defun gnus-summary-highlight-line ()
9933 "Highlight current line according to `gnus-summary-highlight'."
9934 (let* ((list gnus-summary-highlight)
9936 (end (progn (end-of-line) (point)))
9937 ;; now find out where the line starts and leave point there.
9938 (beg (progn (beginning-of-line) (point)))
9939 (article (gnus-summary-article-number))
9940 (score (or (cdr (assq (or article gnus-current-article)
9941 gnus-newsgroup-scored))
9942 gnus-summary-default-score 0))
9943 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9944 (inhibit-read-only t))
9945 ;; Eval the cars of the lists until we find a match.
9946 (let ((default gnus-summary-default-score))
9948 (not (eval (caar list))))
9949 (setq list (cdr list))))
9950 (let ((face (cdar list)))
9951 (unless (eq face (get-text-property beg 'face))
9952 (gnus-put-text-property-excluding-characters-with-faces
9954 (setq face (if (boundp face) (symbol-value face) face)))
9955 (when gnus-summary-highlight-line-function
9956 (funcall gnus-summary-highlight-line-function article face))))
9959 (defun gnus-update-read-articles (group unread &optional compute)
9960 "Update the list of read articles in GROUP."
9961 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9962 (entry (gnus-gethash group gnus-newsrc-hashtb))
9963 (info (nth 2 entry))
9965 (unread (sort (copy-sequence unread) '<))
9967 (if (or (not info) (not active))
9968 ;; There is no info on this group if it was, in fact,
9969 ;; killed. Gnus stores no information on killed groups, so
9970 ;; there's nothing to be done.
9971 ;; One could store the information somewhere temporarily,
9972 ;; perhaps... Hmmm...
9974 ;; Remove any negative articles numbers.
9975 (while (and unread (< (car unread) 0))
9976 (setq unread (cdr unread)))
9977 ;; Remove any expired article numbers
9978 (while (and unread (< (car unread) (car active)))
9979 (setq unread (cdr unread)))
9980 ;; Compute the ranges of read articles by looking at the list of
9983 (when (/= (car unread) prev)
9984 (push (if (= prev (1- (car unread))) prev
9985 (cons prev (1- (car unread))))
9987 (setq prev (1+ (car unread)))
9988 (setq unread (cdr unread)))
9989 (when (<= prev (cdr active))
9990 (push (cons prev (cdr active)) read))
9991 (setq read (if (> (length read) 1) (nreverse read) read))
9996 ;; Propagate the read marks to the backend.
9997 (when (gnus-check-backend-function 'request-set-mark group)
9998 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9999 (add (gnus-remove-from-range read (gnus-info-read info))))
10001 (unless (gnus-check-group group)
10002 (error "Can't open server for %s" group))
10003 (gnus-request-set-mark
10004 group (delq nil (list (if add (list add 'add '(read)))
10005 (if del (list del 'del '(read))))))
10007 `(gnus-request-set-mark
10010 (if del (list del 'add '(read)))
10011 (if add (list add 'del '(read))))))))))
10012 (set-buffer gnus-group-buffer)
10013 (gnus-undo-register
10015 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10016 (gnus-info-set-read ',info ',(gnus-info-read info))
10017 (gnus-get-unread-articles-in-group ',info
10018 (gnus-active ,group))
10019 (gnus-group-update-group ,group t)
10021 ;; Enter this list into the group info.
10022 (gnus-info-set-read info read)
10023 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10024 (gnus-get-unread-articles-in-group info (gnus-active group))
10027 (defun gnus-offer-save-summaries ()
10028 "Offer to save all active summary buffers."
10030 (let ((buflist (buffer-list))
10032 ;; Go through all buffers and find all summaries.
10034 (and (setq bufname (buffer-name (car buflist)))
10035 (string-match "Summary" bufname)
10037 (set-buffer bufname)
10038 ;; We check that this is, indeed, a summary buffer.
10039 (and (eq major-mode 'gnus-summary-mode)
10040 ;; Also make sure this isn't bogus.
10041 gnus-newsgroup-prepared
10042 ;; Also make sure that this isn't a dead summary buffer.
10043 (not gnus-dead-summary-mode)))
10044 (push bufname buffers))
10045 (setq buflist (cdr buflist)))
10046 ;; Go through all these summary buffers and offer to save them.
10049 "Update summary buffer %s? "
10051 (switch-to-buffer buf)
10052 (gnus-summary-exit))
10056 ;;; @ for mime-partial
10059 (defun gnus-request-partial-message ()
10061 (let ((number (gnus-summary-article-number))
10062 (group gnus-newsgroup-name)
10063 (mother gnus-article-buffer))
10064 (set-buffer (get-buffer-create " *Partial Article*"))
10066 (setq mime-preview-buffer mother)
10067 (gnus-request-article-this-buffer number group)
10068 (mime-parse-buffer)
10071 (autoload 'mime-combine-message/partial-pieces-automatically
10073 "Internal method to combine message/partial messages automatically.")
10075 (mime-add-condition
10076 'action '((type . message)(subtype . partial)
10077 (major-mode . gnus-original-article-mode)
10078 (method . mime-combine-message/partial-pieces-automatically)
10079 (summary-buffer-exp . gnus-summary-buffer)
10080 (request-partial-message-method . gnus-request-partial-message)
10084 ;;; @ for message/rfc822
10087 (defun gnus-mime-extract-message/rfc822 (entity situation)
10088 (let (group article num cwin swin cur)
10090 (mime-insert-entity-content entity)
10091 (setq group (or (cdr (assq 'group situation))
10092 (completing-read "Group: "
10095 (gnus-read-active-file-p)
10096 gnus-newsgroup-name))
10097 article (gnus-request-accept-article group)))
10098 (when (and (consp article)
10099 (numberp (setq article (cdr article))))
10100 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10101 cwin (get-buffer-window (current-buffer) t))
10102 (save-window-excursion
10103 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10104 (select-window swin)
10105 (set-buffer gnus-summary-buffer))
10106 (setq cur gnus-current-article)
10108 (let (gnus-show-threads)
10109 (gnus-summary-goto-subject article t))
10110 (gnus-summary-clear-mark-forward 1)
10111 (gnus-summary-goto-subject cur))
10112 (when (and cwin (window-frame cwin))
10113 (select-frame (window-frame cwin)))
10114 (when (boundp 'mime-acting-situation-to-override)
10115 (set-alist 'mime-acting-situation-to-override
10118 (set-alist 'mime-acting-situation-to-override
10121 (save-current-buffer
10122 (set-buffer gnus-group-buffer)
10123 (gnus-activate-group ,group))
10124 (gnus-summary-goto-article ,cur
10125 gnus-show-all-headers)))
10126 (set-alist 'mime-acting-situation-to-override
10129 (mime-add-condition
10130 'action '((type . message)(subtype . rfc822)
10131 (major-mode . gnus-original-article-mode)
10132 (method . gnus-mime-extract-message/rfc822)
10136 (mime-add-condition
10137 'action '((type . message)(subtype . news)
10138 (major-mode . gnus-original-article-mode)
10139 (method . gnus-mime-extract-message/rfc822)
10143 (defun gnus-mime-extract-multipart (entity situation)
10144 (let ((children (mime-entity-children entity))
10145 mime-acting-situation-to-override
10148 (mime-play-entity (car children)
10149 (cons (assq 'mode situation)
10150 mime-acting-situation-to-override))
10151 (setq children (cdr children)))
10152 (if (setq f (cdr (assq 'after-method
10153 mime-acting-situation-to-override)))
10157 (mime-add-condition
10158 'action '((type . multipart)
10159 (method . gnus-mime-extract-multipart)
10168 (defun gnus-summary-setup-default-charset ()
10169 "Setup newsgroup default charset."
10170 (if (equal gnus-newsgroup-name "nndraft:drafts")
10171 (setq gnus-newsgroup-charset nil)
10172 (let* ((ignored-charsets
10173 (or gnus-newsgroup-ephemeral-ignored-charsets
10175 (and gnus-newsgroup-name
10176 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10177 gnus-newsgroup-ignored-charsets))))
10178 (setq gnus-newsgroup-charset
10179 (or gnus-newsgroup-ephemeral-charset
10180 (and gnus-newsgroup-name
10181 (gnus-parameter-charset gnus-newsgroup-name))
10182 gnus-default-charset))
10183 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10184 ignored-charsets))))
10190 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10191 "Display the current article buffer fully MIME-buttonized.
10192 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10193 treated as multipart/mixed."
10195 (require 'gnus-art)
10196 (let ((gnus-unbuttonized-mime-types nil)
10197 (gnus-mime-display-multipart-as-mixed show-all-parts))
10198 (gnus-summary-show-article)))
10200 (defun gnus-summary-repair-multipart (article)
10201 "Add a Content-Type header to a multipart article without one."
10202 (interactive (list (gnus-summary-article-number)))
10203 (gnus-with-article article
10204 (message-narrow-to-head)
10205 (message-remove-header "Mime-Version")
10206 (goto-char (point-max))
10207 (insert "Mime-Version: 1.0\n")
10209 (when (search-forward "\n--" nil t)
10210 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10211 (message-narrow-to-head)
10212 (message-remove-header "Content-Type")
10213 (goto-char (point-max))
10214 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10217 (let (gnus-mark-article-hook)
10218 (gnus-summary-select-article t t nil article)))
10220 (defun gnus-summary-toggle-display-buttonized ()
10221 "Toggle the buttonizing of the article buffer."
10223 (require 'gnus-art)
10224 (if (setq gnus-inhibit-mime-unbuttonizing
10225 (not gnus-inhibit-mime-unbuttonizing))
10226 (let ((gnus-unbuttonized-mime-types nil))
10227 (gnus-summary-show-article))
10228 (gnus-summary-show-article)))
10231 ;;; Intelli-mouse commmands
10234 (defun gnus-wheel-summary-scroll (event)
10236 (let ((amount (if (memq 'shift (event-modifiers event))
10237 (car gnus-wheel-scroll-amount)
10238 (cdr gnus-wheel-scroll-amount)))
10239 (direction (- (* (static-if (featurep 'xemacs)
10240 (event-button event)
10241 (cond ((eq 'mouse-4 (event-basic-type event))
10243 ((eq 'mouse-5 (event-basic-type event))
10247 (gnus-summary-scroll-up (* amount direction))
10248 (when (gnus-eval-in-buffer-window gnus-article-buffer
10251 (and (if (< 0 direction)
10252 (gnus-article-next-page 0)
10253 (gnus-article-prev-page 0)
10255 (if (setq edge (get-text-property
10256 (point-min) 'gnus-wheel-edge))
10257 (setq edge (* edge direction))
10260 (let ((buffer-read-only nil)
10261 (inhibit-read-only t))
10262 (put-text-property (point-min) (point-max)
10263 'gnus-wheel-edge direction)
10265 (or (> edge gnus-wheel-edge-resistance)
10266 (let ((buffer-read-only nil)
10267 (inhibit-read-only t))
10268 (put-text-property (point-min) (point-max)
10270 (* (1+ edge) direction))
10272 (eq last-command 'gnus-wheel-summary-scroll))))
10273 (gnus-summary-next-article nil nil (minusp direction)))))
10275 (defun gnus-wheel-install ()
10276 "Enable mouse wheel support on summary window."
10277 (when gnus-use-wheel
10279 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10281 (define-key gnus-summary-mode-map key
10282 'gnus-wheel-summary-scroll)))))
10284 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10287 ;;; Traditional PGP commmands
10290 (defun gnus-summary-decrypt-article (&optional force)
10291 "Decrypt the current article in traditional PGP way.
10292 This will have permanent effect only in mail groups.
10293 If FORCE is non-nil, allow editing of articles even in read-only
10296 (gnus-summary-select-article t)
10297 (gnus-eval-in-buffer-window gnus-article-buffer
10301 (goto-char (point-min))
10302 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10303 (error "Not a traditional PGP message!"))
10304 (let ((armor-start (match-beginning 0)))
10305 (if (and (pgg-decrypt-region armor-start (point-max))
10306 (or force (not (gnus-group-read-only-p))))
10307 (let ((inhibit-read-only t)
10309 (delete-region armor-start
10311 (re-search-forward "^-+END PGP" nil t)
10312 (beginning-of-line 2)
10314 (insert-buffer-substring pgg-output-buffer))))))))
10316 (defun gnus-summary-verify-article ()
10317 "Verify the current article in traditional PGP way."
10320 (set-buffer gnus-original-article-buffer)
10321 (goto-char (point-min))
10322 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10323 (error "Not a traditional PGP message!"))
10324 (re-search-forward "^-+END PGP" nil t)
10325 (beginning-of-line 2)
10326 (call-interactively (function pgg-verify-region))))
10329 ;;; Generic summary marking commands
10332 (defvar gnus-summary-marking-alist
10333 '((read gnus-del-mark "d")
10334 (unread gnus-unread-mark "u")
10335 (ticked gnus-ticked-mark "!")
10336 (dormant gnus-dormant-mark "?")
10337 (expirable gnus-expirable-mark "e"))
10338 "An alist of names/marks/keystrokes.")
10340 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10341 (defvar gnus-summary-mark-map)
10343 (defun gnus-summary-make-all-marking-commands ()
10344 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10345 (dolist (elem gnus-summary-marking-alist)
10346 (apply 'gnus-summary-make-marking-command elem)))
10348 (defun gnus-summary-make-marking-command (name mark keystroke)
10349 (let ((map (make-sparse-keymap)))
10350 (define-key gnus-summary-generic-mark-map keystroke map)
10351 (dolist (lway `((next "next" next nil "n")
10352 (next-unread "next unread" next t "N")
10353 (prev "previous" prev nil "p")
10354 (prev-unread "previous unread" prev t "P")
10355 (nomove "" nil nil ,keystroke)))
10356 (let ((func (gnus-summary-make-marking-command-1
10357 mark (car lway) lway name)))
10358 (setq func (eval func))
10359 (define-key map (nth 4 lway) func)))))
10361 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10363 (format "gnus-summary-put-mark-as-%s%s"
10364 name (if (eq way 'nomove)
10366 (concat "-" (symbol-name way)))))
10369 "Mark the current article as %s%s.
10370 If N, the prefix, then repeat N times.
10371 If N is negative, move in reverse order.
10372 The difference between N and the actual number of articles marked is
10374 name (car (cdr lway)))
10376 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10378 (defun gnus-summary-generic-mark (n mark move unread)
10379 "Mark N articles with MARK."
10380 (unless (eq major-mode 'gnus-summary-mode)
10381 (error "This command can only be used in the summary buffer"))
10382 (gnus-summary-show-thread)
10385 ((eq move 'next) 1)
10386 ((eq move 'prev) -1)
10388 (if (zerop nummove)
10392 nummove (* -1 nummove))))
10393 (while (and (> n 0)
10394 (gnus-summary-mark-article nil mark)
10395 (zerop (gnus-summary-next-subject nummove unread t)))
10398 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10399 (gnus-summary-recenter)
10400 (gnus-summary-position-point)
10401 (gnus-set-mode-line 'summary)
10404 (gnus-summary-make-all-marking-commands)
10406 (gnus-ems-redefine)
10408 (provide 'gnus-sum)
10410 (run-hooks 'gnus-sum-load-hook)
10412 ;;; gnus-sum.el ends here