1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
42 ;; (require 'gnus-art)
51 (autoload 'gnus-cache-articles-in-group "gnus-cache")
52 (autoload 'pgg-decrypt-region "pgg" nil t)
53 (autoload 'pgg-verify-region "pgg" nil t))
55 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
56 (autoload 'gnus-cache-write-active "gnus-cache")
57 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
58 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
59 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
60 (autoload 'mm-uu-dissect "mm-uu")
62 (defcustom gnus-kill-summary-on-exit t
63 "*If non-nil, kill the summary buffer when you exit from it.
64 If nil, the summary will become a \"*Dead Summary*\" buffer, and
65 it will be killed sometime later."
66 :group 'gnus-summary-exit
69 (defcustom gnus-fetch-old-headers nil
70 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
71 If an unread article in the group refers to an older, already read (or
72 just marked as read) article, the old article will not normally be
73 displayed in the Summary buffer. If this variable is non-nil, Gnus
74 will attempt to grab the headers to the old articles, and thereby
75 build complete threads. If it has the value `some', only enough
76 headers to connect otherwise loose threads will be displayed. This
77 variable can also be a number. In that case, no more than that number
78 of old headers will be fetched. If it has the value `invisible', all
79 old headers will be fetched, but none will be displayed.
81 The server has to support NOV for any of this to work."
83 :type '(choice (const :tag "off" nil)
86 (sexp :menu-tag "other" t)))
88 (defcustom gnus-refer-thread-limit 200
89 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
90 If t, fetch all the available old headers."
93 (sexp :menu-tag "other" t)))
95 (defcustom gnus-summary-make-false-root 'adopt
96 "*nil means that Gnus won't gather loose threads.
97 If the root of a thread has expired or been read in a previous
98 session, the information necessary to build a complete thread has been
99 lost. Instead of having many small sub-threads from this original thread
100 scattered all over the summary buffer, Gnus can gather them.
102 If non-nil, Gnus will try to gather all loose sub-threads from an
103 original thread into one large thread.
105 If this variable is non-nil, it should be one of `none', `adopt',
108 If this variable is `none', Gnus will not make a false root, but just
109 present the sub-threads after another.
110 If this variable is `dummy', Gnus will create a dummy root that will
111 have all the sub-threads as children.
112 If this variable is `adopt', Gnus will make one of the \"children\"
113 the parent and mark all the step-children as such.
114 If this variable is `empty', the \"children\" are printed with empty
115 subject fields. (Or rather, they will be printed with a string
116 given by the `gnus-summary-same-subject' variable.)"
118 :type '(choice (const :tag "off" nil)
124 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
125 "*A regexp to match subjects to be excluded from loose thread gathering.
126 As loose thread gathering is done on subjects only, that means that
127 there can be many false gatherings performed. By rooting out certain
128 common subjects, gathering might become saner."
132 (defcustom gnus-summary-gather-subject-limit nil
133 "*Maximum length of subject comparisons when gathering loose threads.
134 Use nil to compare full subjects. Setting this variable to a low
135 number will help gather threads that have been corrupted by
136 newsreaders chopping off subject lines, but it might also mean that
137 unrelated articles that have subject that happen to begin with the
138 same few characters will be incorrectly gathered.
140 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
143 :type '(choice (const :tag "off" nil)
145 (sexp :menu-tag "on" t)))
147 (defcustom gnus-simplify-subject-functions nil
148 "List of functions taking a string argument that simplify subjects.
149 The functions are applied recursively.
151 Useful functions to put in this list include: `gnus-simplify-subject-re',
152 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 (they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-zcore-fuzz 0
217 "*Fuzziness factor for the zcore in the summary buffer.
218 Articles with scores closer than this to `gnus-summary-default-score'
220 :group 'gnus-summary-format
223 (defcustom gnus-simplify-subject-fuzzy-regexp nil
224 "*Strings to be removed when doing fuzzy matches.
225 This can either be a regular expression or list of regular expressions
226 that will be removed from subject strings if fuzzy subject
227 simplification is selected."
229 :type '(repeat regexp))
231 (defcustom gnus-show-threads t
232 "*If non-nil, display threads in summary mode."
236 (defcustom gnus-thread-hide-subtree nil
237 "*If non-nil, hide all threads initially.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If nil, don't select the first unread article when entering a group.
282 If this variable is `best', select the highest-scored unread article
283 in the group. If t, select the first unread article.
285 This variable can also be a function to place point on a likely
286 subject line. Useful values include `gnus-summary-first-unread-subject',
287 `gnus-summary-first-unread-article' and
288 `gnus-summary-best-unread-article'.
290 If you want to prevent automatic selection of the first unread article
291 in some newsgroups, set the variable to nil in
292 `gnus-select-group-hook'."
293 :group 'gnus-group-select
294 :type '(choice (const :tag "none" nil)
296 (sexp :menu-tag "first" t)
297 (function-item gnus-summary-first-unread-subject)
298 (function-item gnus-summary-first-unread-article)
299 (function-item gnus-summary-best-unread-article)))
301 (defcustom gnus-dont-select-after-jump-to-other-group nil
302 "If non-nil, don't select the first unread article after entering the
303 other group by the command `gnus-summary-jump-to-other-group'. If nil,
304 it is depend on the value of `gnus-auto-select-first' whether to select
306 :group 'gnus-group-select
309 (defcustom gnus-auto-select-next t
310 "*If non-nil, offer to go to the next group from the end of the previous.
311 If the value is t and the next newsgroup is empty, Gnus will exit
312 summary mode and go back to group mode. If the value is neither nil
313 nor t, Gnus will select the following unread newsgroup. In
314 particular, if the value is the symbol `quietly', the next unread
315 newsgroup will be selected without any confirmation, and if it is
316 `almost-quietly', the next group will be selected without any
317 confirmation if you are located on the last article in the group.
318 Finally, if this variable is `slightly-quietly', the `Z n' command
319 will go to the next group without confirmation."
320 :group 'gnus-summary-maneuvering
321 :type '(choice (const :tag "off" nil)
323 (const almost-quietly)
324 (const slightly-quietly)
325 (sexp :menu-tag "on" t)))
327 (defcustom gnus-auto-select-same nil
328 "*If non-nil, select the next article with the same subject.
329 If there are no more articles with the same subject, go to
330 the first unread article."
331 :group 'gnus-summary-maneuvering
334 (defcustom gnus-summary-check-current nil
335 "*If non-nil, consider the current article when moving.
336 The \"unread\" movement commands will stay on the same line if the
337 current article is unread."
338 :group 'gnus-summary-maneuvering
341 (defcustom gnus-auto-center-summary t
342 "*If non-nil, always center the current summary buffer.
343 In particular, if `vertical' do only vertical recentering. If non-nil
344 and non-`vertical', do both horizontal and vertical recentering."
345 :group 'gnus-summary-maneuvering
346 :type '(choice (const :tag "none" nil)
348 (integer :tag "height")
349 (sexp :menu-tag "both" t)))
351 (defcustom gnus-show-all-headers nil
352 "*If non-nil, don't hide any headers."
353 :group 'gnus-article-hiding
354 :group 'gnus-article-headers
357 (defcustom gnus-summary-ignore-duplicates nil
358 "*If non-nil, ignore articles with identical Message-ID headers."
362 (defcustom gnus-single-article-buffer t
363 "*If non-nil, display all articles in the same buffer.
364 If nil, each group will get its own article buffer."
365 :group 'gnus-article-various
368 (defcustom gnus-break-pages t
369 "*If non-nil, do page breaking on articles.
370 The page delimiter is specified by the `gnus-page-delimiter'
372 :group 'gnus-article-various
375 (defcustom gnus-show-mime t
376 "*If non-nil, do mime processing of articles.
377 The articles will simply be fed to the function given by
378 `gnus-article-display-method-for-mime'."
379 :group 'gnus-article-mime
382 (defcustom gnus-move-split-methods nil
383 "*Variable used to suggest where articles are to be moved to.
384 It uses the same syntax as the `gnus-split-methods' variable.
385 However, whereas `gnus-split-methods' specifies file names as targets,
386 this variable specifies group names."
387 :group 'gnus-summary-mail
388 :type '(repeat (choice (list :value (fun) function)
389 (cons :value ("" "") regexp (repeat string))
392 (defcustom gnus-unread-mark ? ;Whitespace
393 "*Mark used for unread articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-ticked-mark ?!
398 "*Mark used for ticked articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-dormant-mark ??
403 "*Mark used for dormant articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-del-mark ?r
408 "*Mark used for del'd articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-read-mark ?R
413 "*Mark used for read articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-expirable-mark ?E
418 "*Mark used for expirable articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-killed-mark ?K
423 "*Mark used for killed articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-souped-mark ?F
428 "*Mark used for souped articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-kill-file-mark ?X
433 "*Mark used for articles killed by kill files."
434 :group 'gnus-summary-marks
437 (defcustom gnus-low-score-mark ?Y
438 "*Mark used for articles with a low score."
439 :group 'gnus-summary-marks
442 (defcustom gnus-catchup-mark ?C
443 "*Mark used for articles that are caught up."
444 :group 'gnus-summary-marks
447 (defcustom gnus-replied-mark ?A
448 "*Mark used for articles that have been replied to."
449 :group 'gnus-summary-marks
452 (defcustom gnus-forwarded-mark ?O
453 "*Mark used for articles that have been forwarded."
454 :group 'gnus-summary-marks
457 (defcustom gnus-cached-mark ?*
458 "*Mark used for articles that are in the cache."
459 :group 'gnus-summary-marks
462 (defcustom gnus-saved-mark ?S
463 "*Mark used for articles that have been saved to."
464 :group 'gnus-summary-marks
467 (defcustom gnus-no-mark ? ;Whitespace
468 "*Mark used for articles that have no other secondary mark."
469 :group 'gnus-summary-marks
472 (defcustom gnus-ancient-mark ?O
473 "*Mark used for ancient articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-sparse-mark ?Q
478 "*Mark used for sparsely reffed articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-canceled-mark ?G
483 "*Mark used for canceled articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-duplicate-mark ?M
488 "*Mark used for duplicate articles."
489 :group 'gnus-summary-marks
492 (defcustom gnus-undownloaded-mark ?@
493 "*Mark used for articles that weren't downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-downloadable-mark ?%
498 "*Mark used for articles that are to be downloaded."
499 :group 'gnus-summary-marks
502 (defcustom gnus-unsendable-mark ?=
503 "*Mark used for articles that won't be sent."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-over-mark ?+
508 "*Score mark used for articles with high scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-score-below-mark ?-
513 "*Score mark used for articles with low scores."
514 :group 'gnus-summary-marks
517 (defcustom gnus-empty-thread-mark ? ;Whitespace
518 "*There is no thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-not-empty-thread-mark ?=
523 "*There is a thread under the article."
524 :group 'gnus-summary-marks
527 (defcustom gnus-view-pseudo-asynchronously nil
528 "*If non-nil, Gnus will view pseudo-articles asynchronously."
529 :group 'gnus-extract-view
532 (defcustom gnus-auto-expirable-marks
533 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
534 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
535 gnus-souped-mark gnus-duplicate-mark)
536 "*The list of marks converted into expiration if a group is auto-expirable."
539 :type '(repeat character))
541 (defcustom gnus-inhibit-user-auto-expire t
542 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
547 (defcustom gnus-view-pseudos nil
548 "*If `automatic', pseudo-articles will be viewed automatically.
549 If `not-confirm', pseudos will be viewed automatically, and the user
550 will not be asked to confirm the command."
551 :group 'gnus-extract-view
552 :type '(choice (const :tag "off" nil)
554 (const not-confirm)))
556 (defcustom gnus-view-pseudos-separately t
557 "*If non-nil, one pseudo-article will be created for each file to be viewed.
558 If nil, all files that use the same viewing command will be given as a
559 list of parameters to that command."
560 :group 'gnus-extract-view
563 (defcustom gnus-insert-pseudo-articles t
564 "*If non-nil, insert pseudo-articles when decoding articles."
565 :group 'gnus-extract-view
568 (defcustom gnus-summary-dummy-line-format
570 "*The format specification for the dummy roots in the summary buffer.
571 It works along the same lines as a normal formatting string,
572 with some simple extensions.
575 :group 'gnus-threading
578 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
579 "*The format specification for the summary mode line.
580 It works along the same lines as a normal formatting string,
581 with some simple extensions:
584 %p Unprefixed group name
585 %A Current article number
586 %z Current article score
588 %U Number of unread articles in the group
589 %e Number of unselected articles in the group
590 %Z A string with unread/unselected article counts
591 %g Shortish group name
592 %S Subject of the current article
594 %s Current score file name
595 %d Number of dormant articles
596 %r Number of articles that have been marked as read in this session
597 %E Number of articles expunged by the score files"
598 :group 'gnus-summary-format
601 (defcustom gnus-list-identifiers nil
602 "Regexp that matches list identifiers to be removed from subject.
603 This can also be a list of regexps."
605 :group 'gnus-summary-format
606 :group 'gnus-article-hiding
607 :type '(choice (const :tag "none" nil)
609 (repeat :value (".*") regexp)))
611 (defcustom gnus-summary-mark-below 0
612 "*Mark all articles with a score below this variable as read.
613 This variable is local to each summary buffer and usually set by the
615 :group 'gnus-score-default
618 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
619 "*List of functions used for sorting articles in the summary buffer.
621 Each function takes two articles and returns non-nil if the first
622 article should be sorted before the other. If you use more than one
623 function, the primary sort function should be the last. You should
624 probably always include `gnus-article-sort-by-number' in the list of
625 sorting functions -- preferably first. Also note that sorting by date
626 is often much slower than sorting by number, and the sorting order is
627 very similar. (Sorting by date means sorting by the time the message
628 was sent, sorting by number means sorting by arrival time.)
630 Ready-made functions include `gnus-article-sort-by-number',
631 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
632 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
634 When threading is turned on, the variable `gnus-thread-sort-functions'
635 controls how articles are sorted."
636 :group 'gnus-summary-sort
637 :type '(repeat (choice (function-item gnus-article-sort-by-number)
638 (function-item gnus-article-sort-by-author)
639 (function-item gnus-article-sort-by-subject)
640 (function-item gnus-article-sort-by-date)
641 (function-item gnus-article-sort-by-score)
642 (function :tag "other"))))
644 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
645 "*List of functions used for sorting threads in the summary buffer.
646 By default, threads are sorted by article number.
648 Each function takes two threads and returns non-nil if the first
649 thread should be sorted before the other. If you use more than one
650 function, the primary sort function should be the last. You should
651 probably always include `gnus-thread-sort-by-number' in the list of
652 sorting functions -- preferably first. Also note that sorting by date
653 is often much slower than sorting by number, and the sorting order is
654 very similar. (Sorting by date means sorting by the time the message
655 was sent, sorting by number means sorting by arrival time.)
657 Ready-made functions include `gnus-thread-sort-by-number',
658 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
659 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
660 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
662 When threading is turned off, the variable
663 `gnus-article-sort-functions' controls how articles are sorted."
664 :group 'gnus-summary-sort
665 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
666 (function-item gnus-thread-sort-by-author)
667 (function-item gnus-thread-sort-by-subject)
668 (function-item gnus-thread-sort-by-date)
669 (function-item gnus-thread-sort-by-score)
670 (function-item gnus-thread-sort-by-total-score)
671 (function :tag "other"))))
673 (defcustom gnus-thread-score-function '+
674 "*Function used for calculating the total score of a thread.
676 The function is called with the scores of the article and each
677 subthread and should then return the score of the thread.
679 Some functions you can use are `+', `max', or `min'."
680 :group 'gnus-summary-sort
683 (defcustom gnus-summary-expunge-below nil
684 "All articles that have a score less than this variable will be expunged.
685 This variable is local to the summary buffers."
686 :group 'gnus-score-default
687 :type '(choice (const :tag "off" nil)
690 (defcustom gnus-thread-expunge-below nil
691 "All threads that have a total score less than this variable will be expunged.
692 See `gnus-thread-score-function' for en explanation of what a
695 This variable is local to the summary buffers."
696 :group 'gnus-threading
697 :group 'gnus-score-default
698 :type '(choice (const :tag "off" nil)
701 (defcustom gnus-summary-mode-hook nil
702 "*A hook for Gnus summary mode.
703 This hook is run before any variables are set in the summary buffer."
704 :options '(turn-on-gnus-mailing-list-mode)
705 :group 'gnus-summary-various
708 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
709 (when (featurep 'xemacs)
710 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
711 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
712 (add-hook 'gnus-summary-mode-hook
713 'gnus-xmas-switch-horizontal-scrollbar-off))
715 (defcustom gnus-summary-menu-hook nil
716 "*Hook run after the creation of the summary mode menu."
717 :group 'gnus-summary-visual
720 (defcustom gnus-summary-exit-hook nil
721 "*A hook called on exit from the summary buffer.
722 It will be called with point in the group buffer."
723 :group 'gnus-summary-exit
726 (defcustom gnus-summary-prepare-hook nil
727 "*A hook called after the summary buffer has been generated.
728 If you want to modify the summary buffer, you can use this hook."
729 :group 'gnus-summary-various
732 (defcustom gnus-summary-prepared-hook nil
733 "*A hook called as the last thing after the summary buffer has been generated."
734 :group 'gnus-summary-various
737 (defcustom gnus-summary-generate-hook nil
738 "*A hook run just before generating the summary buffer.
739 This hook is commonly used to customize threading variables and the
741 :group 'gnus-summary-various
744 (defcustom gnus-select-group-hook nil
745 "*A hook called when a newsgroup is selected.
747 If you'd like to simplify subjects like the
748 `gnus-summary-next-same-subject' command does, you can use the
751 (setq gnus-select-group-hook
754 (mapcar (lambda (header)
755 (mail-header-set-subject
757 (gnus-simplify-subject
758 (mail-header-subject header) 're-only)))
759 gnus-newsgroup-headers))))"
760 :group 'gnus-group-select
763 (defcustom gnus-select-article-hook nil
764 "*A hook called when an article is selected."
765 :group 'gnus-summary-choose
768 (defcustom gnus-visual-mark-article-hook
769 (list 'gnus-highlight-selected-summary)
770 "*Hook run after selecting an article in the summary buffer.
771 It is meant to be used for highlighting the article in some way. It
772 is not run if `gnus-visual' is nil."
773 :group 'gnus-summary-visual
776 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
777 "*A hook called before parsing the headers."
781 (defcustom gnus-exit-group-hook nil
782 "*A hook called when exiting summary mode.
783 This hook is not called from the non-updating exit commands like `Q'."
787 (defcustom gnus-summary-update-hook
788 (list 'gnus-summary-highlight-line)
789 "*A hook called when a summary line is changed.
790 The hook will not be called if `gnus-visual' is nil.
792 The default function `gnus-summary-highlight-line' will
793 highlight the line according to the `gnus-summary-highlight'
795 :group 'gnus-summary-visual
798 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
799 "*A hook called when an article is selected for the first time.
800 The hook is intended to mark an article as read (or unread)
801 automatically when it is selected."
802 :group 'gnus-summary-choose
805 (defcustom gnus-group-no-more-groups-hook nil
806 "*A hook run when returning to group mode having no more (unread) groups."
807 :group 'gnus-group-select
810 (defcustom gnus-ps-print-hook nil
811 "*A hook run before ps-printing something from Gnus."
815 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
816 "Face used for highlighting the current article in the summary buffer."
817 :group 'gnus-summary-visual
820 (defcustom gnus-summary-highlight
821 '(((= mark gnus-canceled-mark)
822 . gnus-summary-cancelled-face)
823 ((and (> score default)
824 (or (= mark gnus-dormant-mark)
825 (= mark gnus-ticked-mark)))
826 . gnus-summary-high-ticked-face)
827 ((and (< score default)
828 (or (= mark gnus-dormant-mark)
829 (= mark gnus-ticked-mark)))
830 . gnus-summary-low-ticked-face)
831 ((or (= mark gnus-dormant-mark)
832 (= mark gnus-ticked-mark))
833 . gnus-summary-normal-ticked-face)
834 ((and (> score default) (= mark gnus-ancient-mark))
835 . gnus-summary-high-ancient-face)
836 ((and (< score default) (= mark gnus-ancient-mark))
837 . gnus-summary-low-ancient-face)
838 ((= mark gnus-ancient-mark)
839 . gnus-summary-normal-ancient-face)
840 ((and (> score default) (= mark gnus-unread-mark))
841 . gnus-summary-high-unread-face)
842 ((and (< score default) (= mark gnus-unread-mark))
843 . gnus-summary-low-unread-face)
844 ((and (memq article gnus-newsgroup-incorporated)
845 (= mark gnus-unread-mark))
846 . gnus-summary-incorporated-face)
847 ((= mark gnus-unread-mark)
848 . gnus-summary-normal-unread-face)
849 ((and (> score default) (memq mark (list gnus-downloadable-mark
850 gnus-undownloaded-mark)))
851 . gnus-summary-high-unread-face)
852 ((and (< score default) (memq mark (list gnus-downloadable-mark
853 gnus-undownloaded-mark)))
854 . gnus-summary-low-unread-face)
855 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
856 . gnus-summary-normal-unread-face)
858 . gnus-summary-high-read-face)
860 . gnus-summary-low-read-face)
862 . gnus-summary-normal-read-face))
863 "*Controls the highlighting of summary buffer lines.
865 A list of (FORM . FACE) pairs. When deciding how a a particular
866 summary line should be displayed, each form is evaluated. The content
867 of the face field after the first true form is used. You can change
868 how those summary lines are displayed, by editing the face field.
870 You can use the following variables in the FORM field.
872 score: The articles score
873 default: The default article score.
874 below: The score below which articles are automatically marked as read.
875 mark: The articles mark."
876 :group 'gnus-summary-visual
877 :type '(repeat (cons (sexp :tag "Form" nil)
880 (defcustom gnus-alter-header-function nil
881 "Function called to allow alteration of article header structures.
882 The function is called with one parameter, the article header vector,
883 which it may alter in any way.")
885 (defvar gnus-decode-encoded-word-function
886 (mime-find-field-decoder 'From 'nov)
887 "Variable that says which function should be used to decode a string with encoded words.")
889 (defcustom gnus-extra-headers nil
890 "*Extra headers to parse."
893 :type '(repeat symbol))
895 (defcustom gnus-ignored-from-addresses
896 (and user-mail-address (regexp-quote user-mail-address))
897 "*Regexp of From headers that may be suppressed in favor of To headers."
902 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
903 "List of charsets that should be ignored.
904 When these charsets are used in the \"charset\" parameter, the
905 default charset will be used instead."
907 :type '(repeat symbol)
908 :group 'gnus-charset)
910 (gnus-define-group-parameter
914 "Return the ignored charsets of GROUP."
915 :variable gnus-group-ignored-charsets-alist
917 '(("alt\\.chinese\\.text" iso-8859-1))
919 "Alist of regexps (to match group names) and charsets that should be ignored.
920 When these charsets are used in the \"charset\" parameter, the
921 default charset will be used instead."
922 :variable-group gnus-charset
923 :variable-type '(repeat (cons (regexp :tag "Group")
925 :parameter-type '(choice :tag "Ignored charsets"
928 :parameter-document "\
929 List of charsets that should be ignored.
931 When these charsets are used in the \"charset\" parameter, the
932 default charset will be used instead.")
934 (defcustom gnus-group-highlight-words-alist nil
935 "Alist of group regexps and highlight regexps.
936 This variable uses the same syntax as `gnus-emphasis-alist'."
938 :type '(repeat (cons (regexp :tag "Group")
939 (repeat (list (regexp :tag "Highlight regexp")
940 (number :tag "Group for entire word" 0)
941 (number :tag "Group for displayed part" 0)
943 gnus-emphasis-highlight-words)))))
944 :group 'gnus-summary-visual)
946 (defcustom gnus-use-wheel nil
947 "Use Intelli-mouse on summary movement"
949 :group 'gnus-summary-maneuvering)
951 (defcustom gnus-wheel-scroll-amount '(5 . 1)
952 "Amount to scroll messages by spinning the mouse wheel.
953 This is actually a cons cell, where the first item is the amount to scroll
954 on a normal wheel event, and the second is the amount to scroll when the
955 wheel is moved with the shift key depressed."
956 :type '(cons (integer :tag "Shift") integer)
957 :group 'gnus-summary-maneuvering)
959 (defcustom gnus-wheel-edge-resistance 2
960 "How hard it should be to change the current article
961 by moving the mouse over the edge of the article window."
963 :group 'gnus-summary-maneuvering)
965 (defcustom gnus-summary-show-article-charset-alist
967 "Alist of number and charset.
968 The article will be shown with the charset corresponding to the
970 For example: ((1 . cn-gb-2312) (2 . big5))."
972 :type '(repeat (cons (number :tag "Argument" 1)
973 (symbol :tag "Charset")))
974 :group 'gnus-charset)
976 (defcustom gnus-preserve-marks t
977 "Whether marks are preserved when moving, copying and respooling messages."
980 :group 'gnus-summary-marks)
982 (defcustom gnus-alter-articles-to-read-function nil
983 "Function to be called to alter the list of articles to be selected."
984 :type '(choice (const nil) function)
985 :group 'gnus-summary)
987 (defcustom gnus-orphan-score nil
988 "*All orphans get this score added. Set in the score file."
989 :group 'gnus-score-default
990 :type '(choice (const nil)
993 (defcustom gnus-summary-save-parts-default-mime "image/.*"
994 "*A regexp to match MIME parts when saving multiple parts of a message
995 with gnus-summary-save-parts (X m). This regexp will be used by default
996 when prompting the user for which type of files to save."
1001 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1002 "*A regexp to match MIME parts when saving multiple parts of a message
1003 with gnus-summary-save-parts (X m). This regexp will be used by default
1004 when prompting the user for which type of files to save."
1005 :group 'gnus-summary
1009 ;;; Internal variables
1011 (defvar gnus-article-mime-handles nil)
1012 (defvar gnus-article-decoded-p nil)
1013 (defvar gnus-article-charset nil)
1014 (defvar gnus-article-ignored-charsets nil)
1015 (defvar gnus-scores-exclude-files nil)
1016 (defvar gnus-page-broken nil)
1017 (defvar gnus-inhibit-mime-unbuttonizing nil)
1019 (defvar gnus-original-article nil)
1020 (defvar gnus-article-internal-prepare-hook nil)
1021 (defvar gnus-newsgroup-process-stack nil)
1023 (defvar gnus-thread-indent-array nil)
1024 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1025 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1026 "Function called to sort the articles within a thread after it has been gathered together.")
1028 (defvar gnus-summary-save-parts-type-history nil)
1029 (defvar gnus-summary-save-parts-last-directory nil)
1031 (defvar gnus-summary-save-parts-type-history nil)
1032 (defvar gnus-summary-save-parts-last-directory nil)
1034 ;; Avoid highlighting in kill files.
1035 (defvar gnus-summary-inhibit-highlight nil)
1036 (defvar gnus-newsgroup-selected-overlay nil)
1037 (defvar gnus-inhibit-limiting nil)
1038 (defvar gnus-newsgroup-adaptive-score-file nil)
1039 (defvar gnus-current-score-file nil)
1040 (defvar gnus-current-move-group nil)
1041 (defvar gnus-current-copy-group nil)
1042 (defvar gnus-current-crosspost-group nil)
1044 (defvar gnus-newsgroup-dependencies nil)
1045 (defvar gnus-newsgroup-adaptive nil)
1046 (defvar gnus-summary-display-article-function nil)
1047 (defvar gnus-summary-highlight-line-function nil
1048 "Function called after highlighting a summary line.")
1050 (defvar gnus-summary-line-format-alist
1051 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1052 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1053 (?s gnus-tmp-subject-or-nil ?s)
1054 (?n gnus-tmp-name ?s)
1055 (?A (std11-address-string
1056 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1057 (?a (or (std11-full-name-string
1058 (car (mime-entity-read-field gnus-tmp-header 'From)))
1060 (?F gnus-tmp-from ?s)
1061 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1062 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1063 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1064 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1065 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1066 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1067 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1068 (?L gnus-tmp-lines ?s)
1069 (?I gnus-tmp-indentation ?s)
1070 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1071 (?R gnus-tmp-replied ?c)
1072 (?\[ gnus-tmp-opening-bracket ?c)
1073 (?\] gnus-tmp-closing-bracket ?c)
1074 (?\> (make-string gnus-tmp-level ? ) ?s)
1075 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1076 (?i gnus-tmp-score ?d)
1077 (?z gnus-tmp-score-char ?c)
1078 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1079 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1080 (?U gnus-tmp-unread ?c)
1081 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1082 (?t (gnus-summary-number-of-articles-in-thread
1083 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1085 (?e (gnus-summary-number-of-articles-in-thread
1086 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1088 (?u gnus-tmp-user-defined ?s)
1089 (?P (gnus-pick-line-number) ?d))
1090 "An alist of format specifications that can appear in summary lines.
1091 These are paired with what variables they correspond with, along with
1092 the type of the variable (string, integer, character, etc).")
1094 (defvar gnus-summary-dummy-line-format-alist
1095 `((?S gnus-tmp-subject ?s)
1096 (?N gnus-tmp-number ?d)
1097 (?u gnus-tmp-user-defined ?s)))
1099 (defvar gnus-summary-mode-line-format-alist
1100 `((?G gnus-tmp-group-name ?s)
1101 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1102 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1103 (?A gnus-tmp-article-number ?d)
1104 (?Z gnus-tmp-unread-and-unselected ?s)
1105 (?V gnus-version ?s)
1106 (?U gnus-tmp-unread-and-unticked ?d)
1107 (?S gnus-tmp-subject ?s)
1108 (?e gnus-tmp-unselected ?d)
1109 (?u gnus-tmp-user-defined ?s)
1110 (?d (length gnus-newsgroup-dormant) ?d)
1111 (?t (length gnus-newsgroup-marked) ?d)
1112 (?r (length gnus-newsgroup-reads) ?d)
1113 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1114 (?E gnus-newsgroup-expunged-tally ?d)
1115 (?s (gnus-current-score-file-nondirectory) ?s)))
1117 (defvar gnus-last-search-regexp nil
1118 "Default regexp for article search command.")
1120 (defvar gnus-summary-search-article-matched-data nil
1121 "Last matched data of article search command. It is the local variable
1122 in `gnus-article-buffer' which consists of the list of start position,
1123 end position and text.")
1125 (defvar gnus-last-shell-command nil
1126 "Default shell command on article.")
1128 (defvar gnus-newsgroup-begin nil)
1129 (defvar gnus-newsgroup-end nil)
1130 (defvar gnus-newsgroup-last-rmail nil)
1131 (defvar gnus-newsgroup-last-mail nil)
1132 (defvar gnus-newsgroup-last-folder nil)
1133 (defvar gnus-newsgroup-last-file nil)
1134 (defvar gnus-newsgroup-auto-expire nil)
1135 (defvar gnus-newsgroup-active nil)
1137 (defvar gnus-newsgroup-data nil)
1138 (defvar gnus-newsgroup-data-reverse nil)
1139 (defvar gnus-newsgroup-limit nil)
1140 (defvar gnus-newsgroup-limits nil)
1142 (defvar gnus-newsgroup-unreads nil
1143 "List of unread articles in the current newsgroup.")
1145 (defvar gnus-newsgroup-unselected nil
1146 "List of unselected unread articles in the current newsgroup.")
1148 (defvar gnus-newsgroup-reads nil
1149 "Alist of read articles and article marks in the current newsgroup.")
1151 (defvar gnus-newsgroup-expunged-tally nil)
1153 (defvar gnus-newsgroup-marked nil
1154 "List of ticked articles in the current newsgroup (a subset of unread art).")
1156 (defvar gnus-newsgroup-killed nil
1157 "List of ranges of articles that have been through the scoring process.")
1159 (defvar gnus-newsgroup-cached nil
1160 "List of articles that come from the article cache.")
1162 (defvar gnus-newsgroup-saved nil
1163 "List of articles that have been saved.")
1165 (defvar gnus-newsgroup-kill-headers nil)
1167 (defvar gnus-newsgroup-replied nil
1168 "List of articles that have been replied to in the current newsgroup.")
1170 (defvar gnus-newsgroup-forwarded nil
1171 "List of articles that have been forwarded in the current newsgroup.")
1173 (defvar gnus-newsgroup-expirable nil
1174 "List of articles in the current newsgroup that can be expired.")
1176 (defvar gnus-newsgroup-processable nil
1177 "List of articles in the current newsgroup that can be processed.")
1179 (defvar gnus-newsgroup-downloadable nil
1180 "List of articles in the current newsgroup that can be processed.")
1182 (defvar gnus-newsgroup-undownloaded nil
1183 "List of articles in the current newsgroup that haven't been downloaded..")
1185 (defvar gnus-newsgroup-unsendable nil
1186 "List of articles in the current newsgroup that won't be sent.")
1188 (defvar gnus-newsgroup-bookmarks nil
1189 "List of articles in the current newsgroup that have bookmarks.")
1191 (defvar gnus-newsgroup-dormant nil
1192 "List of dormant articles in the current newsgroup.")
1194 (defvar gnus-newsgroup-scored nil
1195 "List of scored articles in the current newsgroup.")
1197 (defvar gnus-newsgroup-incorporated nil
1198 "List of incorporated articles in the current newsgroup.")
1200 (defvar gnus-newsgroup-headers nil
1201 "List of article headers in the current newsgroup.")
1203 (defvar gnus-newsgroup-threads nil)
1205 (defvar gnus-newsgroup-prepared nil
1206 "Whether the current group has been prepared properly.")
1208 (defvar gnus-newsgroup-ancient nil
1209 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1211 (defvar gnus-newsgroup-sparse nil)
1213 (defvar gnus-current-article nil)
1214 (defvar gnus-article-current nil)
1215 (defvar gnus-current-headers nil)
1216 (defvar gnus-have-all-headers nil)
1217 (defvar gnus-last-article nil)
1218 (defvar gnus-newsgroup-history nil)
1219 (defvar gnus-newsgroup-charset nil)
1220 (defvar gnus-newsgroup-ephemeral-charset nil)
1221 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1223 (defvar gnus-article-before-search nil)
1225 (defconst gnus-summary-local-variables
1226 '(gnus-newsgroup-name
1227 gnus-newsgroup-begin gnus-newsgroup-end
1228 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1229 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1230 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1231 gnus-newsgroup-unselected gnus-newsgroup-marked
1232 gnus-newsgroup-reads gnus-newsgroup-saved
1233 gnus-newsgroup-replied gnus-newsgroup-forwarded
1234 gnus-newsgroup-expirable
1235 gnus-newsgroup-processable gnus-newsgroup-killed
1236 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1237 gnus-newsgroup-unsendable
1238 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1239 gnus-newsgroup-headers gnus-newsgroup-threads
1240 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1241 gnus-current-article gnus-current-headers gnus-have-all-headers
1242 gnus-last-article gnus-article-internal-prepare-hook
1243 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1244 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1245 gnus-thread-expunge-below
1246 gnus-score-alist gnus-current-score-file
1247 (gnus-summary-expunge-below . global)
1248 (gnus-summary-mark-below . global)
1249 (gnus-orphan-score . global)
1250 gnus-newsgroup-active gnus-scores-exclude-files
1251 gnus-newsgroup-history gnus-newsgroup-ancient
1252 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1253 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1254 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1255 (gnus-newsgroup-expunged-tally . 0)
1256 gnus-cache-removable-articles gnus-newsgroup-cached
1257 gnus-newsgroup-data gnus-newsgroup-data-reverse
1258 gnus-newsgroup-limit gnus-newsgroup-limits
1259 gnus-newsgroup-charset
1260 gnus-newsgroup-incorporated)
1261 "Variables that are buffer-local to the summary buffers.")
1263 (defvar gnus-newsgroup-variables nil
1264 "Variables that have separate values in the newsgroups.")
1266 ;; Byte-compiler warning.
1267 (eval-when-compile (defvar gnus-article-mode-map))
1269 ;; Subject simplification.
1271 (defun gnus-simplify-whitespace (str)
1272 "Remove excessive whitespace from STR."
1275 (while (string-match "[ \t][ \t]+" mystr)
1276 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1278 (substring mystr (match-end 0)))))
1280 (when (string-match "^[ \t]+" mystr)
1281 (setq mystr (substring mystr (match-end 0))))
1283 (when (string-match "[ \t]+$" mystr)
1284 (setq mystr (substring mystr 0 (match-beginning 0))))
1287 (defsubst gnus-simplify-subject-re (subject)
1288 "Remove \"Re:\" from subject lines."
1289 (if (string-match message-subject-re-regexp subject)
1290 (substring subject (match-end 0))
1293 (defun gnus-simplify-subject (subject &optional re-only)
1294 "Remove `Re:' and words in parentheses.
1295 If RE-ONLY is non-nil, strip leading `Re:'s only."
1296 (let ((case-fold-search t)) ;Ignore case.
1297 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1298 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1299 (setq subject (substring subject (match-end 0))))
1300 ;; Remove uninteresting prefixes.
1301 (when (and (not re-only)
1302 gnus-simplify-ignored-prefixes
1303 (string-match gnus-simplify-ignored-prefixes subject))
1304 (setq subject (substring subject (match-end 0))))
1305 ;; Remove words in parentheses from end.
1307 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1308 (setq subject (substring subject 0 (match-beginning 0)))))
1309 ;; Return subject string.
1312 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1314 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1315 (goto-char (point-min))
1316 (while (re-search-forward regexp nil t)
1317 (replace-match (or newtext ""))))
1319 (defun gnus-simplify-buffer-fuzzy ()
1320 "Simplify string in the buffer fuzzily.
1321 The string in the accessible portion of the current buffer is simplified.
1322 It is assumed to be a single-line subject.
1323 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1324 matter is removed. Additional things can be deleted by setting
1325 `gnus-simplify-subject-fuzzy-regexp'."
1326 (let ((case-fold-search t)
1328 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1330 (while (not (eq modified-tick (buffer-modified-tick)))
1331 (setq modified-tick (buffer-modified-tick))
1333 ((listp gnus-simplify-subject-fuzzy-regexp)
1334 (mapcar 'gnus-simplify-buffer-fuzzy-step
1335 gnus-simplify-subject-fuzzy-regexp))
1336 (gnus-simplify-subject-fuzzy-regexp
1337 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1338 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1339 (gnus-simplify-buffer-fuzzy-step
1340 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1341 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1343 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1344 (gnus-simplify-buffer-fuzzy-step " +" " ")
1345 (gnus-simplify-buffer-fuzzy-step " $")
1346 (gnus-simplify-buffer-fuzzy-step "^ +")))
1348 (defun gnus-simplify-subject-fuzzy (subject)
1349 "Simplify a subject string fuzzily.
1350 See `gnus-simplify-buffer-fuzzy' for details."
1352 (gnus-set-work-buffer)
1353 (let ((case-fold-search t))
1354 ;; Remove uninteresting prefixes.
1355 (when (and gnus-simplify-ignored-prefixes
1356 (string-match gnus-simplify-ignored-prefixes subject))
1357 (setq subject (substring subject (match-end 0))))
1359 (inline (gnus-simplify-buffer-fuzzy))
1362 (defsubst gnus-simplify-subject-fully (subject)
1363 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1365 (gnus-simplify-subject-functions
1366 (gnus-map-function gnus-simplify-subject-functions subject))
1367 ((null gnus-summary-gather-subject-limit)
1368 (gnus-simplify-subject-re subject))
1369 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1370 (gnus-simplify-subject-fuzzy subject))
1371 ((numberp gnus-summary-gather-subject-limit)
1372 (gnus-limit-string (gnus-simplify-subject-re subject)
1373 gnus-summary-gather-subject-limit))
1377 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1378 "Check whether two subjects are equal.
1379 If optional argument simple-first is t, first argument is already
1382 ((null simple-first)
1383 (equal (gnus-simplify-subject-fully s1)
1384 (gnus-simplify-subject-fully s2)))
1387 (gnus-simplify-subject-fully s2)))))
1389 (defun gnus-summary-bubble-group ()
1390 "Increase the score of the current group.
1391 This is a handy function to add to `gnus-summary-exit-hook' to
1392 increase the score of each group you read."
1393 (gnus-group-add-score gnus-newsgroup-name))
1397 ;;; Gnus summary mode
1400 (put 'gnus-summary-mode 'mode-class 'special)
1402 (defvar gnus-article-commands-menu)
1405 ;; Non-orthogonal keys
1407 (gnus-define-keys gnus-summary-mode-map
1408 " " gnus-summary-next-page
1409 "\177" gnus-summary-prev-page
1410 [delete] gnus-summary-prev-page
1411 [backspace] gnus-summary-prev-page
1412 "\r" gnus-summary-scroll-up
1413 "\M-\r" gnus-summary-scroll-down
1414 "n" gnus-summary-next-unread-article
1415 "p" gnus-summary-prev-unread-article
1416 "N" gnus-summary-next-article
1417 "P" gnus-summary-prev-article
1418 "\M-\C-n" gnus-summary-next-same-subject
1419 "\M-\C-p" gnus-summary-prev-same-subject
1420 "\M-n" gnus-summary-next-unread-subject
1421 "\M-p" gnus-summary-prev-unread-subject
1422 "." gnus-summary-first-unread-article
1423 "," gnus-summary-best-unread-article
1424 "\M-s" gnus-summary-search-article-forward
1425 "\M-r" gnus-summary-search-article-backward
1426 "<" gnus-summary-beginning-of-article
1427 ">" gnus-summary-end-of-article
1428 "j" gnus-summary-goto-article
1429 "^" gnus-summary-refer-parent-article
1430 "\M-^" gnus-summary-refer-article
1431 "u" gnus-summary-tick-article-forward
1432 "!" gnus-summary-tick-article-forward
1433 "U" gnus-summary-tick-article-backward
1434 "d" gnus-summary-mark-as-read-forward
1435 "D" gnus-summary-mark-as-read-backward
1436 "E" gnus-summary-mark-as-expirable
1437 "\M-u" gnus-summary-clear-mark-forward
1438 "\M-U" gnus-summary-clear-mark-backward
1439 "k" gnus-summary-kill-same-subject-and-select
1440 "\C-k" gnus-summary-kill-same-subject
1441 "\M-\C-k" gnus-summary-kill-thread
1442 "\M-\C-l" gnus-summary-lower-thread
1443 "e" gnus-summary-edit-article
1444 "#" gnus-summary-mark-as-processable
1445 "\M-#" gnus-summary-unmark-as-processable
1446 "\M-\C-t" gnus-summary-toggle-threads
1447 "\M-\C-s" gnus-summary-show-thread
1448 "\M-\C-h" gnus-summary-hide-thread
1449 "\M-\C-f" gnus-summary-next-thread
1450 "\M-\C-b" gnus-summary-prev-thread
1451 [(meta down)] gnus-summary-next-thread
1452 [(meta up)] gnus-summary-prev-thread
1453 "\M-\C-u" gnus-summary-up-thread
1454 "\M-\C-d" gnus-summary-down-thread
1455 "&" gnus-summary-execute-command
1456 "c" gnus-summary-catchup-and-exit
1457 "\C-w" gnus-summary-mark-region-as-read
1458 "\C-t" gnus-summary-toggle-truncation
1459 "?" gnus-summary-mark-as-dormant
1460 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1461 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1462 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1463 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1464 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1465 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1466 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1467 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1468 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1469 "=" gnus-summary-expand-window
1470 "\C-x\C-s" gnus-summary-reselect-current-group
1471 "\M-g" gnus-summary-rescan-group
1472 "w" gnus-summary-stop-page-breaking
1473 "\C-c\C-r" gnus-summary-caesar-message
1474 "\M-t" gnus-summary-toggle-mime
1475 "f" gnus-summary-followup
1476 "F" gnus-summary-followup-with-original
1477 "C" gnus-summary-cancel-article
1478 "r" gnus-summary-reply
1479 "R" gnus-summary-reply-with-original
1480 "\C-c\C-f" gnus-summary-mail-forward
1481 "o" gnus-summary-save-article
1482 "\C-o" gnus-summary-save-article-mail
1483 "|" gnus-summary-pipe-output
1484 "\M-k" gnus-summary-edit-local-kill
1485 "\M-K" gnus-summary-edit-global-kill
1487 "\C-c\C-d" gnus-summary-describe-group
1488 "q" gnus-summary-exit
1489 "Q" gnus-summary-exit-no-update
1490 "\C-c\C-i" gnus-info-find-node
1491 gnus-mouse-2 gnus-mouse-pick-article
1492 "m" gnus-summary-mail-other-window
1493 "a" gnus-summary-post-news
1494 "x" gnus-summary-limit-to-unread
1495 "s" gnus-summary-isearch-article
1496 "t" gnus-article-toggle-headers
1497 "g" gnus-summary-show-article
1498 "l" gnus-summary-goto-last-article
1499 "v" gnus-summary-preview-mime-message
1500 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1501 "\C-d" gnus-summary-enter-digest-group
1502 "\M-\C-d" gnus-summary-read-document
1503 "\M-\C-e" gnus-summary-edit-parameters
1504 "\M-\C-a" gnus-summary-customize-parameters
1506 "*" gnus-cache-enter-article
1507 "\M-*" gnus-cache-remove-article
1508 "\M-&" gnus-summary-universal-argument
1509 "\C-l" gnus-recenter
1510 "I" gnus-summary-increase-score
1511 "L" gnus-summary-lower-score
1512 "\M-i" gnus-symbolic-argument
1513 "h" gnus-summary-select-article-buffer
1515 "V" gnus-summary-score-map
1516 "X" gnus-uu-extract-map
1517 "S" gnus-summary-send-map)
1519 ;; Sort of orthogonal keymap
1520 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1521 "t" gnus-summary-tick-article-forward
1522 "!" gnus-summary-tick-article-forward
1523 "d" gnus-summary-mark-as-read-forward
1524 "r" gnus-summary-mark-as-read-forward
1525 "c" gnus-summary-clear-mark-forward
1526 " " gnus-summary-clear-mark-forward
1527 "e" gnus-summary-mark-as-expirable
1528 "x" gnus-summary-mark-as-expirable
1529 "?" gnus-summary-mark-as-dormant
1530 "b" gnus-summary-set-bookmark
1531 "B" gnus-summary-remove-bookmark
1532 "#" gnus-summary-mark-as-processable
1533 "\M-#" gnus-summary-unmark-as-processable
1534 "S" gnus-summary-limit-include-expunged
1535 "C" gnus-summary-catchup
1536 "H" gnus-summary-catchup-to-here
1537 "\C-c" gnus-summary-catchup-all
1538 "k" gnus-summary-kill-same-subject-and-select
1539 "K" gnus-summary-kill-same-subject
1540 "P" gnus-uu-mark-map)
1542 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1543 "c" gnus-summary-clear-above
1544 "u" gnus-summary-tick-above
1545 "m" gnus-summary-mark-above
1546 "k" gnus-summary-kill-below)
1548 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1549 "/" gnus-summary-limit-to-subject
1550 "n" gnus-summary-limit-to-articles
1551 "w" gnus-summary-pop-limit
1552 "s" gnus-summary-limit-to-subject
1553 "a" gnus-summary-limit-to-author
1554 "u" gnus-summary-limit-to-unread
1555 "m" gnus-summary-limit-to-marks
1556 "M" gnus-summary-limit-exclude-marks
1557 "v" gnus-summary-limit-to-score
1558 "*" gnus-summary-limit-include-cached
1559 "D" gnus-summary-limit-include-dormant
1560 "T" gnus-summary-limit-include-thread
1561 "d" gnus-summary-limit-exclude-dormant
1562 "t" gnus-summary-limit-to-age
1563 "x" gnus-summary-limit-to-extra
1564 "E" gnus-summary-limit-include-expunged
1565 "c" gnus-summary-limit-exclude-childless-dormant
1566 "C" gnus-summary-limit-mark-excluded-as-read
1567 "o" gnus-summary-insert-old-articles
1568 "N" gnus-summary-insert-new-articles)
1570 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1571 "n" gnus-summary-next-unread-article
1572 "p" gnus-summary-prev-unread-article
1573 "N" gnus-summary-next-article
1574 "P" gnus-summary-prev-article
1575 "\C-n" gnus-summary-next-same-subject
1576 "\C-p" gnus-summary-prev-same-subject
1577 "\M-n" gnus-summary-next-unread-subject
1578 "\M-p" gnus-summary-prev-unread-subject
1579 "f" gnus-summary-first-unread-article
1580 "b" gnus-summary-best-unread-article
1581 "j" gnus-summary-goto-article
1582 "g" gnus-summary-goto-subject
1583 "l" gnus-summary-goto-last-article
1584 "o" gnus-summary-pop-article)
1586 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1587 "k" gnus-summary-kill-thread
1588 "l" gnus-summary-lower-thread
1589 "i" gnus-summary-raise-thread
1590 "T" gnus-summary-toggle-threads
1591 "t" gnus-summary-rethread-current
1592 "^" gnus-summary-reparent-thread
1593 "s" gnus-summary-show-thread
1594 "S" gnus-summary-show-all-threads
1595 "h" gnus-summary-hide-thread
1596 "H" gnus-summary-hide-all-threads
1597 "n" gnus-summary-next-thread
1598 "p" gnus-summary-prev-thread
1599 "u" gnus-summary-up-thread
1600 "o" gnus-summary-top-thread
1601 "d" gnus-summary-down-thread
1602 "#" gnus-uu-mark-thread
1603 "\M-#" gnus-uu-unmark-thread)
1605 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1606 "g" gnus-summary-prepare
1607 "c" gnus-summary-insert-cached-articles)
1609 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1610 "c" gnus-summary-catchup-and-exit
1611 "C" gnus-summary-catchup-all-and-exit
1612 "E" gnus-summary-exit-no-update
1613 "J" gnus-summary-jump-to-other-group
1614 "Q" gnus-summary-exit
1615 "Z" gnus-summary-exit
1616 "n" gnus-summary-catchup-and-goto-next-group
1617 "R" gnus-summary-reselect-current-group
1618 "G" gnus-summary-rescan-group
1619 "N" gnus-summary-next-group
1620 "s" gnus-summary-save-newsrc
1621 "P" gnus-summary-prev-group)
1623 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1624 " " gnus-summary-next-page
1625 "n" gnus-summary-next-page
1626 "\177" gnus-summary-prev-page
1627 [delete] gnus-summary-prev-page
1628 "p" gnus-summary-prev-page
1629 "\r" gnus-summary-scroll-up
1630 "\M-\r" gnus-summary-scroll-down
1631 "<" gnus-summary-beginning-of-article
1632 ">" gnus-summary-end-of-article
1633 "b" gnus-summary-beginning-of-article
1634 "e" gnus-summary-end-of-article
1635 "^" gnus-summary-refer-parent-article
1636 "r" gnus-summary-refer-parent-article
1637 "D" gnus-summary-enter-digest-group
1638 "R" gnus-summary-refer-references
1639 "T" gnus-summary-refer-thread
1640 "g" gnus-summary-show-article
1641 "s" gnus-summary-isearch-article
1642 "P" gnus-summary-print-article
1643 "M" gnus-mailing-list-insinuate
1644 "t" gnus-article-babel)
1646 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1647 "b" gnus-article-add-buttons
1648 "B" gnus-article-add-buttons-to-head
1649 "o" gnus-article-treat-overstrike
1650 "e" gnus-article-emphasize
1651 "w" gnus-article-fill-cited-article
1652 "Q" gnus-article-fill-long-lines
1653 "C" gnus-article-capitalize-sentences
1654 "c" gnus-article-remove-cr
1655 "Z" gnus-article-decode-HZ
1656 "f" gnus-article-display-x-face
1657 "l" gnus-summary-stop-page-breaking
1658 "r" gnus-summary-caesar-message
1659 "t" gnus-article-toggle-headers
1660 "v" gnus-summary-verbose-headers
1661 "m" gnus-summary-toggle-mime
1662 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1663 "p" gnus-article-verify-x-pgp-sig
1664 "d" gnus-article-treat-dumbquotes
1665 "s" gnus-smiley-display)
1667 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1668 "a" gnus-article-hide
1669 "h" gnus-article-toggle-headers
1670 "b" gnus-article-hide-boring-headers
1671 "s" gnus-article-hide-signature
1672 "c" gnus-article-hide-citation
1673 "C" gnus-article-hide-citation-in-followups
1674 "l" gnus-article-hide-list-identifiers
1675 "p" gnus-article-hide-pgp
1676 "B" gnus-article-strip-banner
1677 "P" gnus-article-hide-pem
1678 "\C-c" gnus-article-hide-citation-maybe)
1680 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1681 "a" gnus-article-highlight
1682 "h" gnus-article-highlight-headers
1683 "c" gnus-article-highlight-citation
1684 "s" gnus-article-highlight-signature)
1686 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1687 "z" gnus-article-date-ut
1688 "u" gnus-article-date-ut
1689 "l" gnus-article-date-local
1690 "p" gnus-article-date-english
1691 "e" gnus-article-date-lapsed
1692 "o" gnus-article-date-original
1693 "i" gnus-article-date-iso8601
1694 "s" gnus-article-date-user)
1696 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1697 "t" gnus-article-remove-trailing-blank-lines
1698 "l" gnus-article-strip-leading-blank-lines
1699 "m" gnus-article-strip-multiple-blank-lines
1700 "a" gnus-article-strip-blank-lines
1701 "A" gnus-article-strip-all-blank-lines
1702 "s" gnus-article-strip-leading-space
1703 "e" gnus-article-strip-trailing-space
1704 "w" gnus-article-remove-leading-whitespace)
1706 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1708 "f" gnus-summary-fetch-faq
1709 "d" gnus-summary-describe-group
1710 "h" gnus-summary-describe-briefly
1711 "i" gnus-info-find-node)
1713 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1714 "e" gnus-summary-expire-articles
1715 "\M-\C-e" gnus-summary-expire-articles-now
1716 "\177" gnus-summary-delete-article
1717 [delete] gnus-summary-delete-article
1718 [backspace] gnus-summary-delete-article
1719 "m" gnus-summary-move-article
1720 "r" gnus-summary-respool-article
1721 "w" gnus-summary-edit-article
1722 "c" gnus-summary-copy-article
1723 "B" gnus-summary-crosspost-article
1724 "q" gnus-summary-respool-query
1725 "t" gnus-summary-respool-trace
1726 "i" gnus-summary-import-article
1727 "I" gnus-summary-create-article
1728 "p" gnus-summary-article-posted-p)
1730 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1731 "o" gnus-summary-save-article
1732 "m" gnus-summary-save-article-mail
1733 "F" gnus-summary-write-article-file
1734 "r" gnus-summary-save-article-rmail
1735 "f" gnus-summary-save-article-file
1736 "b" gnus-summary-save-article-body-file
1737 "h" gnus-summary-save-article-folder
1738 "v" gnus-summary-save-article-vm
1739 "p" gnus-summary-pipe-output
1740 "s" gnus-soup-add-article)
1742 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1743 "b" gnus-summary-display-buttonized
1744 "m" gnus-summary-repair-multipart
1745 "v" gnus-article-view-part
1746 "o" gnus-article-save-part
1747 "c" gnus-article-copy-part
1748 "C" gnus-article-view-part-as-charset
1749 "e" gnus-article-externalize-part
1750 "E" gnus-article-encrypt-body
1751 "i" gnus-article-inline-part
1752 "|" gnus-article-pipe-part))
1754 (defvar gnus-article-post-menu nil)
1756 (defun gnus-summary-make-menu-bar ()
1757 (gnus-turn-off-edit-menu 'summary)
1759 (unless (boundp 'gnus-summary-misc-menu)
1762 gnus-summary-kill-menu gnus-summary-mode-map ""
1767 ["Customize" gnus-score-customize t])
1768 (gnus-make-score-map 'increase)
1769 (gnus-make-score-map 'lower)
1771 ["Kill below" gnus-summary-kill-below t]
1772 ["Mark above" gnus-summary-mark-above t]
1773 ["Tick above" gnus-summary-tick-above t]
1774 ["Clear above" gnus-summary-clear-above t])
1775 ["Current score" gnus-summary-current-score t]
1776 ["Set score" gnus-summary-set-score t]
1777 ["Switch current score file..." gnus-score-change-score-file t]
1778 ["Set mark below..." gnus-score-set-mark-below t]
1779 ["Set expunge below..." gnus-score-set-expunge-below t]
1780 ["Edit current score file" gnus-score-edit-current-scores t]
1781 ["Edit score file" gnus-score-edit-file t]
1782 ["Trace score" gnus-score-find-trace t]
1783 ["Find words" gnus-score-find-favourite-words t]
1784 ["Rescore buffer" gnus-summary-rescore t]
1785 ["Increase score..." gnus-summary-increase-score t]
1786 ["Lower score..." gnus-summary-lower-score t]))))
1788 ;; Define both the Article menu in the summary buffer and the equivalent
1789 ;; Commands menu in the article buffer here for consistency.
1792 ["All" gnus-article-hide t]
1793 ["Headers" gnus-article-toggle-headers t]
1794 ["Signature" gnus-article-hide-signature t]
1795 ["Citation" gnus-article-hide-citation t]
1796 ["List identifiers" gnus-article-hide-list-identifiers t]
1797 ["PGP" gnus-article-hide-pgp t]
1798 ["Banner" gnus-article-strip-banner t]
1799 ["Boring headers" gnus-article-hide-boring-headers t])
1801 ["All" gnus-article-highlight t]
1802 ["Headers" gnus-article-highlight-headers t]
1803 ["Signature" gnus-article-highlight-signature t]
1804 ["Citation" gnus-article-highlight-citation t])
1806 ["Local" gnus-article-date-local t]
1807 ["ISO8601" gnus-article-date-iso8601 t]
1808 ["UT" gnus-article-date-ut t]
1809 ["Original" gnus-article-date-original t]
1810 ["Lapsed" gnus-article-date-lapsed t]
1811 ["User-defined" gnus-article-date-user t])
1814 ["Leading" gnus-article-strip-leading-blank-lines t]
1815 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1816 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1817 ["All of the above" gnus-article-strip-blank-lines t]
1818 ["All" gnus-article-strip-all-blank-lines t]
1819 ["Leading space" gnus-article-strip-leading-space t]
1820 ["Trailing space" gnus-article-strip-trailing-space t]
1821 ["Leading space in headers"
1822 gnus-article-remove-leading-whitespace t])
1823 ["Overstrike" gnus-article-treat-overstrike t]
1824 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1825 ["Emphasis" gnus-article-emphasize t]
1826 ["Word wrap" gnus-article-fill-cited-article t]
1827 ["Fill long lines" gnus-article-fill-long-lines t]
1828 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1829 ["CR" gnus-article-remove-cr t]
1830 ["Show X-Face" gnus-article-display-x-face t]
1831 ["Rot 13" gnus-summary-caesar-message
1832 ,@(if (featurep 'xemacs) '(t)
1833 '(:help "\"Caesar rotate\" article by 13"))]
1834 ["Unix pipe" gnus-summary-pipe-message t]
1835 ["Add buttons" gnus-article-add-buttons t]
1836 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1837 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1838 ["Toggle MIME" gnus-summary-toggle-mime t]
1839 ["Verbose header" gnus-summary-verbose-headers t]
1840 ["Toggle header" gnus-summary-toggle-header t]
1841 ["Toggle smileys" gnus-smiley-display t]
1842 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1843 ["HZ" gnus-article-decode-HZ t])
1845 ["Save in default format" gnus-summary-save-article
1846 ,@(if (featurep 'xemacs) '(t)
1847 '(:help "Save article using default method"))]
1848 ["Save in file" gnus-summary-save-article-file
1849 ,@(if (featurep 'xemacs) '(t)
1850 '(:help "Save article in file"))]
1851 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1852 ["Save in MH folder" gnus-summary-save-article-folder t]
1853 ["Save in VM folder" gnus-summary-save-article-vm t]
1854 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1855 ["Save body in file" gnus-summary-save-article-body-file t]
1856 ["Pipe through a filter" gnus-summary-pipe-output t]
1857 ["Add to SOUP packet" gnus-soup-add-article t]
1858 ["Print" gnus-summary-print-article t])
1860 ["Respool article..." gnus-summary-respool-article t]
1861 ["Move article..." gnus-summary-move-article
1862 (gnus-check-backend-function
1863 'request-move-article gnus-newsgroup-name)]
1864 ["Copy article..." gnus-summary-copy-article t]
1865 ["Crosspost article..." gnus-summary-crosspost-article
1866 (gnus-check-backend-function
1867 'request-replace-article gnus-newsgroup-name)]
1868 ["Import file..." gnus-summary-import-article t]
1869 ["Create article..." gnus-summary-create-article t]
1870 ["Check if posted" gnus-summary-article-posted-p t]
1871 ["Edit article" gnus-summary-edit-article
1872 (not (gnus-group-read-only-p))]
1873 ["Delete article" gnus-summary-delete-article
1874 (gnus-check-backend-function
1875 'request-expire-articles gnus-newsgroup-name)]
1876 ["Query respool" gnus-summary-respool-query t]
1877 ["Trace respool" gnus-summary-respool-trace t]
1878 ["Delete expirable articles" gnus-summary-expire-articles-now
1879 (gnus-check-backend-function
1880 'request-expire-articles gnus-newsgroup-name)])
1882 ["Uudecode" gnus-uu-decode-uu
1883 ,@(if (featurep 'xemacs) '(t)
1884 '(:help "Decode uuencoded article(s)"))]
1885 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1886 ["Unshar" gnus-uu-decode-unshar t]
1887 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1888 ["Save" gnus-uu-decode-save t]
1889 ["Binhex" gnus-uu-decode-binhex t]
1890 ["Postscript" gnus-uu-decode-postscript t])
1892 ["Enter article" gnus-cache-enter-article t]
1893 ["Remove article" gnus-cache-remove-article t])
1894 ["Translate" gnus-article-babel t]
1895 ["Select article buffer" gnus-summary-select-article-buffer t]
1896 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1897 ["Isearch article..." gnus-summary-isearch-article t]
1898 ["Beginning of the article" gnus-summary-beginning-of-article t]
1899 ["End of the article" gnus-summary-end-of-article t]
1900 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1901 ["Fetch referenced articles" gnus-summary-refer-references t]
1902 ["Fetch current thread" gnus-summary-refer-thread t]
1903 ["Fetch article with id..." gnus-summary-refer-article t]
1904 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1905 ["Redisplay" gnus-summary-show-article t])))
1907 gnus-summary-article-menu gnus-summary-mode-map ""
1908 (cons "Article" innards))
1910 (if (not (keymapp gnus-summary-article-menu))
1912 gnus-article-commands-menu gnus-article-mode-map ""
1913 (cons "Commands" innards))
1914 ;; in Emacs, don't share menu.
1915 (setq gnus-article-commands-menu
1916 (copy-keymap gnus-summary-article-menu))
1917 (define-key gnus-article-mode-map [menu-bar commands]
1918 (cons "Commands" gnus-article-commands-menu))))
1921 gnus-summary-thread-menu gnus-summary-mode-map ""
1923 ["Toggle threading" gnus-summary-toggle-threads t]
1924 ["Hide threads" gnus-summary-hide-all-threads t]
1925 ["Show threads" gnus-summary-show-all-threads t]
1926 ["Hide thread" gnus-summary-hide-thread t]
1927 ["Show thread" gnus-summary-show-thread t]
1928 ["Go to next thread" gnus-summary-next-thread t]
1929 ["Go to previous thread" gnus-summary-prev-thread t]
1930 ["Go down thread" gnus-summary-down-thread t]
1931 ["Go up thread" gnus-summary-up-thread t]
1932 ["Top of thread" gnus-summary-top-thread t]
1933 ["Mark thread as read" gnus-summary-kill-thread t]
1934 ["Lower thread score" gnus-summary-lower-thread t]
1935 ["Raise thread score" gnus-summary-raise-thread t]
1936 ["Rethread current" gnus-summary-rethread-current t]))
1939 gnus-summary-post-menu gnus-summary-mode-map ""
1941 ["Post an article" gnus-summary-post-news
1942 ,@(if (featurep 'xemacs) '(t)
1943 '(:help "Post an article"))]
1944 ["Followup" gnus-summary-followup
1945 ,@(if (featurep 'xemacs) '(t)
1946 '(:help "Post followup to this article"))]
1947 ["Followup and yank" gnus-summary-followup-with-original
1948 ,@(if (featurep 'xemacs) '(t)
1949 '(:help "Post followup to this article, quoting its contents"))]
1950 ["Supersede article" gnus-summary-supersede-article t]
1951 ["Cancel article" gnus-summary-cancel-article
1952 ,@(if (featurep 'xemacs) '(t)
1953 '(:help "Cancel an article you posted"))]
1954 ["Reply" gnus-summary-reply t]
1955 ["Reply and yank" gnus-summary-reply-with-original t]
1956 ["Wide reply" gnus-summary-wide-reply t]
1957 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1958 ,@(if (featurep 'xemacs) '(t)
1959 '(:help "Mail a reply, quoting this article"))]
1960 ["Mail forward" gnus-summary-mail-forward t]
1961 ["Post forward" gnus-summary-post-forward t]
1962 ["Digest and mail" gnus-summary-digest-mail-forward t]
1963 ["Digest and post" gnus-summary-digest-post-forward t]
1964 ["Resend message" gnus-summary-resend-message t]
1965 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1966 ["Send a mail" gnus-summary-mail-other-window t]
1967 ["Uuencode and post" gnus-uu-post-news
1968 ,@(if (featurep 'xemacs) '(t)
1969 '(:help "Post a uuencoded article"))]
1970 ["Followup via news" gnus-summary-followup-to-mail t]
1971 ["Followup via news and yank"
1972 gnus-summary-followup-to-mail-with-original t]
1974 ;;["Send" gnus-summary-send-draft t]
1975 ;;["Send bounced" gnus-resend-bounced-mail t])
1979 ((not (keymapp gnus-summary-post-menu))
1980 (setq gnus-article-post-menu gnus-summary-post-menu))
1981 ((not gnus-article-post-menu)
1982 ;; Don't share post menu.
1983 (setq gnus-article-post-menu
1984 (copy-keymap gnus-summary-post-menu))))
1985 (define-key gnus-article-mode-map [menu-bar post]
1986 (cons "Post" gnus-article-post-menu))
1989 gnus-summary-misc-menu gnus-summary-mode-map ""
1992 ["Mark as read" gnus-summary-mark-as-read-forward t]
1993 ["Mark same subject and select"
1994 gnus-summary-kill-same-subject-and-select t]
1995 ["Mark same subject" gnus-summary-kill-same-subject t]
1996 ["Catchup" gnus-summary-catchup
1997 ,@(if (featurep 'xemacs) '(t)
1998 '(:help "Mark unread articles in this group as read"))]
1999 ["Catchup all" gnus-summary-catchup-all t]
2000 ["Catchup to here" gnus-summary-catchup-to-here t]
2001 ["Catchup region" gnus-summary-mark-region-as-read t]
2002 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2004 ["Tick" gnus-summary-tick-article-forward t]
2005 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2006 ["Remove marks" gnus-summary-clear-mark-forward t]
2007 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2008 ["Set bookmark" gnus-summary-set-bookmark t]
2009 ["Remove bookmark" gnus-summary-remove-bookmark t])
2011 ["Marks..." gnus-summary-limit-to-marks t]
2012 ["Subject..." gnus-summary-limit-to-subject t]
2013 ["Author..." gnus-summary-limit-to-author t]
2014 ["Age..." gnus-summary-limit-to-age t]
2015 ["Extra..." gnus-summary-limit-to-extra t]
2016 ["Score" gnus-summary-limit-to-score t]
2017 ["Unread" gnus-summary-limit-to-unread t]
2018 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2019 ["Articles" gnus-summary-limit-to-articles t]
2020 ["Pop limit" gnus-summary-pop-limit t]
2021 ["Show dormant" gnus-summary-limit-include-dormant t]
2022 ["Hide childless dormant"
2023 gnus-summary-limit-exclude-childless-dormant t]
2024 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2025 ["Hide marked" gnus-summary-limit-exclude-marks t]
2026 ["Show expunged" gnus-summary-limit-include-expunged t])
2028 ["Set mark" gnus-summary-mark-as-processable t]
2029 ["Remove mark" gnus-summary-unmark-as-processable t]
2030 ["Remove all marks" gnus-summary-unmark-all-processable t]
2031 ["Mark above" gnus-uu-mark-over t]
2032 ["Mark series" gnus-uu-mark-series t]
2033 ["Mark region" gnus-uu-mark-region t]
2034 ["Unmark region" gnus-uu-unmark-region t]
2035 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2036 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2037 ["Mark all" gnus-uu-mark-all t]
2038 ["Mark buffer" gnus-uu-mark-buffer t]
2039 ["Mark sparse" gnus-uu-mark-sparse t]
2040 ["Mark thread" gnus-uu-mark-thread t]
2041 ["Unmark thread" gnus-uu-unmark-thread t]
2042 ("Process Mark Sets"
2043 ["Kill" gnus-summary-kill-process-mark t]
2044 ["Yank" gnus-summary-yank-process-mark
2045 gnus-newsgroup-process-stack]
2046 ["Save" gnus-summary-save-process-mark t]))
2048 ["Page forward" gnus-summary-next-page
2049 ,@(if (featurep 'xemacs) '(t)
2050 '(:help "Show next page of article"))]
2051 ["Page backward" gnus-summary-prev-page
2052 ,@(if (featurep 'xemacs) '(t)
2053 '(:help "Show previous page of article"))]
2054 ["Line forward" gnus-summary-scroll-up t])
2056 ["Next unread article" gnus-summary-next-unread-article t]
2057 ["Previous unread article" gnus-summary-prev-unread-article t]
2058 ["Next article" gnus-summary-next-article t]
2059 ["Previous article" gnus-summary-prev-article t]
2060 ["Next unread subject" gnus-summary-next-unread-subject t]
2061 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2062 ["Next article same subject" gnus-summary-next-same-subject t]
2063 ["Previous article same subject" gnus-summary-prev-same-subject t]
2064 ["First unread article" gnus-summary-first-unread-article t]
2065 ["Best unread article" gnus-summary-best-unread-article t]
2066 ["Go to subject number..." gnus-summary-goto-subject t]
2067 ["Go to article number..." gnus-summary-goto-article t]
2068 ["Go to the last article" gnus-summary-goto-last-article t]
2069 ["Pop article off history" gnus-summary-pop-article t])
2071 ["Sort by number" gnus-summary-sort-by-number t]
2072 ["Sort by author" gnus-summary-sort-by-author t]
2073 ["Sort by subject" gnus-summary-sort-by-subject t]
2074 ["Sort by date" gnus-summary-sort-by-date t]
2075 ["Sort by score" gnus-summary-sort-by-score t]
2076 ["Sort by lines" gnus-summary-sort-by-lines t]
2077 ["Sort by characters" gnus-summary-sort-by-chars t]
2078 ["Original sort" gnus-summary-sort-by-original t])
2080 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2081 ["Describe group" gnus-summary-describe-group t]
2082 ["Read manual" gnus-info-find-node t])
2084 ["Pick and read" gnus-pick-mode t]
2085 ["Binary" gnus-binary-mode t])
2087 ["Regenerate" gnus-summary-prepare t]
2088 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2089 ["Toggle threading" gnus-summary-toggle-threads t])
2090 ["See old articles" gnus-summary-insert-old-articles t]
2091 ["See new articles" gnus-summary-insert-new-articles t]
2092 ["Filter articles..." gnus-summary-execute-command t]
2093 ["Run command on subjects..." gnus-summary-universal-argument t]
2094 ["Search articles forward..." gnus-summary-search-article-forward t]
2095 ["Search articles backward..." gnus-summary-search-article-backward t]
2096 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2097 ["Expand window" gnus-summary-expand-window t]
2098 ["Expire expirable articles" gnus-summary-expire-articles
2099 (gnus-check-backend-function
2100 'request-expire-articles gnus-newsgroup-name)]
2101 ["Edit local kill file" gnus-summary-edit-local-kill t]
2102 ["Edit main kill file" gnus-summary-edit-global-kill t]
2103 ["Edit group parameters" gnus-summary-edit-parameters t]
2104 ["Customize group parameters" gnus-summary-customize-parameters t]
2105 ["Send a bug report" gnus-bug t]
2107 ["Catchup and exit" gnus-summary-catchup-and-exit
2108 ,@(if (featurep 'xemacs) '(t)
2109 '(:help "Mark unread articles in this group as read, then exit"))]
2110 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2111 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2112 ["Exit group" gnus-summary-exit
2113 ,@(if (featurep 'xemacs) '(t)
2114 '(:help "Exit current group, return to group selection mode"))]
2115 ["Exit group without updating" gnus-summary-exit-no-update t]
2116 ["Exit and goto next group" gnus-summary-next-group t]
2117 ["Exit and goto prev group" gnus-summary-prev-group t]
2118 ["Reselect group" gnus-summary-reselect-current-group t]
2119 ["Rescan group" gnus-summary-rescan-group t]
2120 ["Update dribble" gnus-summary-save-newsrc t])))
2122 (gnus-run-hooks 'gnus-summary-menu-hook)))
2124 (defvar gnus-summary-tool-bar-map nil)
2126 ;; Emacs 21 tool bar. Should be no-op otherwise.
2127 (defun gnus-summary-make-tool-bar ()
2128 (if (and (fboundp 'tool-bar-add-item-from-menu)
2129 (default-value 'tool-bar-mode)
2130 (not gnus-summary-tool-bar-map))
2131 (setq gnus-summary-tool-bar-map
2132 (let ((tool-bar-map (make-sparse-keymap))
2133 (load-path (mm-image-load-path)))
2134 (tool-bar-add-item-from-menu
2135 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2136 (tool-bar-add-item-from-menu
2137 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2138 (tool-bar-add-item-from-menu
2139 'gnus-summary-post-news "post" gnus-summary-mode-map)
2140 (tool-bar-add-item-from-menu
2141 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2142 (tool-bar-add-item-from-menu
2143 'gnus-summary-followup "followup" gnus-summary-mode-map)
2144 (tool-bar-add-item-from-menu
2145 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2146 (tool-bar-add-item-from-menu
2147 'gnus-summary-reply "reply" gnus-summary-mode-map)
2148 (tool-bar-add-item-from-menu
2149 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2150 (tool-bar-add-item-from-menu
2151 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2152 (tool-bar-add-item-from-menu
2153 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2154 (tool-bar-add-item-from-menu
2155 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2156 (tool-bar-add-item-from-menu
2157 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2158 (tool-bar-add-item-from-menu
2159 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2160 (tool-bar-add-item-from-menu
2161 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2162 (tool-bar-add-item-from-menu
2163 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2165 (if gnus-summary-tool-bar-map
2166 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2168 (defun gnus-score-set-default (var value)
2169 "A version of set that updates the GNU Emacs menu-bar."
2171 ;; It is the message that forces the active status to be updated.
2174 (defun gnus-make-score-map (type)
2175 "Make a summary score map of type TYPE."
2178 (let ((headers '(("author" "from" string)
2179 ("subject" "subject" string)
2180 ("article body" "body" string)
2181 ("article head" "head" string)
2182 ("xref" "xref" string)
2183 ("extra header" "extra" string)
2184 ("lines" "lines" number)
2185 ("followups to author" "followup" string)))
2186 (types '((number ("less than" <)
2189 (string ("substring" s)
2193 (perms '(("temporary" (current-time-string))
2201 (if (eq type 'lower)
2206 (setq header (car headers))
2212 (let ((ts (cdr (assoc (nth 2 header) types)))
2228 'gnus-summary-score-entry
2230 (if (or (string= (nth 1 header)
2232 (string= (nth 1 header)
2235 (list 'gnus-summary-header
2237 (list 'quote (nth 1 (car ts)))
2238 (list 'gnus-score-delta-default
2245 (list (nreverse outp))))
2248 (list (nreverse outt))))
2250 (setq headers (cdr headers)))
2251 (list (nreverse outh))))))))
2255 (defun gnus-summary-mode (&optional group)
2256 "Major mode for reading articles.
2258 All normal editing commands are switched off.
2259 \\<gnus-summary-mode-map>
2260 Each line in this buffer represents one article. To read an
2261 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2262 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2265 You can also post articles and send mail from this buffer. To
2266 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2267 of an article, type `\\[gnus-summary-reply]'.
2269 There are approx. one gazillion commands you can execute in this
2270 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2272 The following commands are available:
2274 \\{gnus-summary-mode-map}"
2276 (kill-all-local-variables)
2277 (when (gnus-visual-p 'summary-menu 'menu)
2278 (gnus-summary-make-menu-bar)
2279 (gnus-summary-make-tool-bar))
2280 (gnus-summary-make-local-variables)
2281 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2282 (gnus-summary-make-local-variables))
2283 (gnus-make-thread-indent-array)
2284 (gnus-simplify-mode-line)
2285 (setq major-mode 'gnus-summary-mode)
2286 (setq mode-name "Summary")
2287 (make-local-variable 'minor-mode-alist)
2288 (use-local-map gnus-summary-mode-map)
2289 (buffer-disable-undo)
2290 (setq buffer-read-only t) ;Disable modification
2291 (setq truncate-lines t)
2292 (setq selective-display t)
2293 (setq selective-display-ellipses t) ;Display `...'
2294 (gnus-summary-set-display-table)
2295 (gnus-set-default-directory)
2296 (setq gnus-newsgroup-name group)
2297 (unless (gnus-news-group-p group)
2298 (setq gnus-newsgroup-incorporated
2299 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2300 (make-local-variable 'gnus-summary-line-format)
2301 (make-local-variable 'gnus-summary-line-format-spec)
2302 (make-local-variable 'gnus-summary-dummy-line-format)
2303 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2304 (make-local-variable 'gnus-summary-mark-positions)
2305 (make-local-hook 'pre-command-hook)
2306 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2307 (gnus-run-hooks 'gnus-summary-mode-hook)
2308 (turn-on-gnus-mailing-list-mode)
2309 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2310 (gnus-update-summary-mark-positions))
2312 (defun gnus-summary-make-local-variables ()
2313 "Make all the local summary buffer variables."
2315 (dolist (local gnus-summary-local-variables)
2318 (if (eq (cdr local) 'global)
2319 ;; Copy the global value of the variable.
2320 (setq global (symbol-value (car local)))
2321 ;; Use the value from the list.
2322 (setq global (eval (cdr local))))
2323 (set (make-local-variable (car local)) global))
2324 ;; Simple nil-valued local variable.
2325 (set (make-local-variable local) nil)))))
2327 (defun gnus-summary-clear-local-variables ()
2328 (let ((locals gnus-summary-local-variables))
2330 (if (consp (car locals))
2331 (and (vectorp (caar locals))
2332 (set (caar locals) nil))
2333 (and (vectorp (car locals))
2334 (set (car locals) nil)))
2335 (setq locals (cdr locals)))))
2337 ;; Summary data functions.
2339 (defmacro gnus-data-number (data)
2342 (defmacro gnus-data-set-number (data number)
2343 `(setcar ,data ,number))
2345 (defmacro gnus-data-mark (data)
2348 (defmacro gnus-data-set-mark (data mark)
2349 `(setcar (nthcdr 1 ,data) ,mark))
2351 (defmacro gnus-data-pos (data)
2354 (defmacro gnus-data-set-pos (data pos)
2355 `(setcar (nthcdr 2 ,data) ,pos))
2357 (defmacro gnus-data-header (data)
2360 (defmacro gnus-data-set-header (data header)
2361 `(setcar (nthcdr 3 ,data) ,header))
2363 (defmacro gnus-data-level (data)
2366 (defmacro gnus-data-unread-p (data)
2367 `(= (nth 1 ,data) gnus-unread-mark))
2369 (defmacro gnus-data-read-p (data)
2370 `(/= (nth 1 ,data) gnus-unread-mark))
2372 (defmacro gnus-data-pseudo-p (data)
2373 `(consp (nth 3 ,data)))
2375 (defmacro gnus-data-find (number)
2376 `(assq ,number gnus-newsgroup-data))
2378 (defmacro gnus-data-find-list (number &optional data)
2379 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2380 (memq (assq ,number bdata)
2383 (defmacro gnus-data-make (number mark pos header level)
2384 `(list ,number ,mark ,pos ,header ,level))
2386 (defun gnus-data-enter (after-article number mark pos header level offset)
2387 (let ((data (gnus-data-find-list after-article)))
2389 (error "No such article: %d" after-article))
2390 (setcdr data (cons (gnus-data-make number mark pos header level)
2392 (setq gnus-newsgroup-data-reverse nil)
2393 (gnus-data-update-list (cddr data) offset)))
2395 (defun gnus-data-enter-list (after-article list &optional offset)
2397 (let ((data (and after-article (gnus-data-find-list after-article)))
2401 (let ((odata gnus-newsgroup-data))
2402 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2404 (gnus-data-update-list odata offset)))
2405 ;; Find the last element in the list to be spliced into the main
2408 (setq list (cdr list)))
2411 (setcdr list gnus-newsgroup-data)
2412 (setq gnus-newsgroup-data ilist)
2414 (gnus-data-update-list (cdr list) offset)))
2415 (setcdr list (cdr data))
2418 (gnus-data-update-list (cdr list) offset))))
2419 (setq gnus-newsgroup-data-reverse nil))))
2421 (defun gnus-data-remove (article &optional offset)
2422 (let ((data gnus-newsgroup-data))
2423 (if (= (gnus-data-number (car data)) article)
2425 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2426 gnus-newsgroup-data-reverse nil)
2428 (gnus-data-update-list gnus-newsgroup-data offset)))
2430 (when (= (gnus-data-number (cadr data)) article)
2431 (setcdr data (cddr data))
2433 (gnus-data-update-list (cdr data) offset))
2435 gnus-newsgroup-data-reverse nil))
2436 (setq data (cdr data))))))
2438 (defmacro gnus-data-list (backward)
2440 (or gnus-newsgroup-data-reverse
2441 (setq gnus-newsgroup-data-reverse
2442 (reverse gnus-newsgroup-data)))
2443 gnus-newsgroup-data))
2445 (defun gnus-data-update-list (data offset)
2446 "Add OFFSET to the POS of all data entries in DATA."
2447 (setq gnus-newsgroup-data-reverse nil)
2449 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2450 (setq data (cdr data))))
2452 (defun gnus-summary-article-pseudo-p (article)
2453 "Say whether this article is a pseudo article or not."
2454 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2456 (defmacro gnus-summary-article-sparse-p (article)
2457 "Say whether this article is a sparse article or not."
2458 `(memq ,article gnus-newsgroup-sparse))
2460 (defmacro gnus-summary-article-ancient-p (article)
2461 "Say whether this article is a sparse article or not."
2462 `(memq ,article gnus-newsgroup-ancient))
2464 (defun gnus-article-parent-p (number)
2465 "Say whether this article is a parent or not."
2466 (let ((data (gnus-data-find-list number)))
2467 (and (cdr data) ; There has to be an article after...
2468 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2469 (gnus-data-level (nth 1 data))))))
2471 (defun gnus-article-children (number)
2472 "Return a list of all children to NUMBER."
2473 (let* ((data (gnus-data-find-list number))
2474 (level (gnus-data-level (car data)))
2476 (setq data (cdr data))
2478 (= (gnus-data-level (car data)) (1+ level)))
2479 (push (gnus-data-number (car data)) children)
2480 (setq data (cdr data)))
2483 (defmacro gnus-summary-skip-intangible ()
2484 "If the current article is intangible, then jump to a different article."
2485 '(let ((to (get-text-property (point) 'gnus-intangible)))
2486 (and to (gnus-summary-goto-subject to))))
2488 (defmacro gnus-summary-article-intangible-p ()
2489 "Say whether this article is intangible or not."
2490 '(get-text-property (point) 'gnus-intangible))
2492 (defun gnus-article-read-p (article)
2493 "Say whether ARTICLE is read or not."
2494 (not (or (memq article gnus-newsgroup-marked)
2495 (memq article gnus-newsgroup-unreads)
2496 (memq article gnus-newsgroup-unselected)
2497 (memq article gnus-newsgroup-dormant))))
2499 ;; Some summary mode macros.
2501 (defmacro gnus-summary-article-number ()
2502 "The article number of the article on the current line.
2503 If there isn's an article number here, then we return the current
2506 (gnus-summary-skip-intangible)
2507 (or (get-text-property (point) 'gnus-number)
2508 (gnus-summary-last-subject))))
2510 (defmacro gnus-summary-article-header (&optional number)
2511 "Return the header of article NUMBER."
2512 `(gnus-data-header (gnus-data-find
2513 ,(or number '(gnus-summary-article-number)))))
2515 (defmacro gnus-summary-thread-level (&optional number)
2516 "Return the level of thread that starts with article NUMBER."
2517 `(if (and (eq gnus-summary-make-false-root 'dummy)
2518 (get-text-property (point) 'gnus-intangible))
2520 (gnus-data-level (gnus-data-find
2521 ,(or number '(gnus-summary-article-number))))))
2523 (defmacro gnus-summary-article-mark (&optional number)
2524 "Return the mark of article NUMBER."
2525 `(gnus-data-mark (gnus-data-find
2526 ,(or number '(gnus-summary-article-number)))))
2528 (defmacro gnus-summary-article-pos (&optional number)
2529 "Return the position of the line of article NUMBER."
2530 `(gnus-data-pos (gnus-data-find
2531 ,(or number '(gnus-summary-article-number)))))
2533 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2534 (defmacro gnus-summary-article-subject (&optional number)
2535 "Return current subject string or nil if nothing."
2538 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2539 '(gnus-data-header (assq (gnus-summary-article-number)
2540 gnus-newsgroup-data)))))
2543 (mail-header-subject headers))))
2545 (defmacro gnus-summary-article-score (&optional number)
2546 "Return current article score."
2547 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2548 gnus-newsgroup-scored))
2549 gnus-summary-default-score 0))
2551 (defun gnus-summary-article-children (&optional number)
2552 "Return a list of article numbers that are children of article NUMBER."
2553 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2554 (level (gnus-data-level (car data)))
2556 (while (and (setq data (cdr data))
2557 (> (setq l (gnus-data-level (car data))) level))
2558 (and (= (1+ level) l)
2559 (push (gnus-data-number (car data))
2561 (nreverse children)))
2563 (defun gnus-summary-article-parent (&optional number)
2564 "Return the article number of the parent of article NUMBER."
2565 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2566 (gnus-data-list t)))
2567 (level (gnus-data-level (car data))))
2569 () ; This is a root.
2570 ;; We search until we find an article with a level less than
2571 ;; this one. That function has to be the parent.
2572 (while (and (setq data (cdr data))
2573 (not (< (gnus-data-level (car data)) level))))
2574 (and data (gnus-data-number (car data))))))
2576 (defun gnus-unread-mark-p (mark)
2577 "Say whether MARK is the unread mark."
2578 (= mark gnus-unread-mark))
2580 (defun gnus-read-mark-p (mark)
2581 "Say whether MARK is one of the marks that mark as read.
2582 This is all marks except unread, ticked, dormant, and expirable."
2583 (not (or (= mark gnus-unread-mark)
2584 (= mark gnus-ticked-mark)
2585 (= mark gnus-dormant-mark)
2586 (= mark gnus-expirable-mark))))
2588 (defmacro gnus-article-mark (number)
2589 "Return the MARK of article NUMBER.
2590 This macro should only be used when computing the mark the \"first\"
2591 time; i.e., when generating the summary lines. After that,
2592 `gnus-summary-article-mark' should be used to examine the
2595 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2596 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2597 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2598 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2599 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2600 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2601 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2602 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2603 gnus-ancient-mark))))
2605 ;; Saving hidden threads.
2607 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2608 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2610 (defmacro gnus-save-hidden-threads (&rest forms)
2611 "Save hidden threads, eval FORMS, and restore the hidden threads."
2612 (let ((config (make-symbol "config")))
2613 `(let ((,config (gnus-hidden-threads-configuration)))
2617 (gnus-restore-hidden-threads-configuration ,config)))))
2619 (defun gnus-data-compute-positions ()
2620 "Compute the positions of all articles."
2621 (setq gnus-newsgroup-data-reverse nil)
2622 (let ((data gnus-newsgroup-data))
2624 (gnus-save-hidden-threads
2625 (gnus-summary-show-all-threads)
2626 (goto-char (point-min))
2628 (while (get-text-property (point) 'gnus-intangible)
2630 (gnus-data-set-pos (car data) (+ (point) 3))
2631 (setq data (cdr data))
2632 (forward-line 1))))))
2634 (defun gnus-hidden-threads-configuration ()
2635 "Return the current hidden threads configuration."
2638 (goto-char (point-min))
2639 (while (search-forward "\r" nil t)
2640 (push (1- (point)) config))
2643 (defun gnus-restore-hidden-threads-configuration (config)
2644 "Restore hidden threads configuration from CONFIG."
2646 (let (point buffer-read-only)
2647 (while (setq point (pop config))
2648 (when (and (< point (point-max))
2650 (eq (char-after) ?\n))
2651 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2653 ;; Various summary mode internalish functions.
2655 (defun gnus-mouse-pick-article (e)
2658 (gnus-summary-next-page nil t))
2660 (defun gnus-summary-set-display-table ()
2661 "Change the display table.
2662 Odd characters have a tendency to mess
2663 up nicely formatted displays - we make all possible glyphs
2664 display only a single character."
2666 ;; We start from the standard display table, if any.
2667 (let ((table (or (copy-sequence standard-display-table)
2668 (make-display-table)))
2670 ;; Nix out all the control chars...
2671 (while (>= (setq i (1- i)) 0)
2672 (aset table i [??]))
2673 ;; ... but not newline and cr, of course. (cr is necessary for the
2674 ;; selective display).
2675 (aset table ?\n nil)
2676 (aset table ?\r nil)
2677 ;; We keep TAB as well.
2678 (aset table ?\t nil)
2679 ;; We nix out any glyphs over 126 that are not set already.
2681 (while (>= (setq i (1- i)) 127)
2682 ;; Only modify if the entry is nil.
2683 (unless (aref table i)
2684 (aset table i [??]))))
2685 (setq buffer-display-table table)))
2687 (defun gnus-summary-buffer-name (group)
2688 "Return the summary buffer name of GROUP."
2689 (concat "*Summary " group "*"))
2691 (defun gnus-summary-setup-buffer (group)
2692 "Initialize summary buffer."
2693 (let ((buffer (gnus-summary-buffer-name group)))
2694 (if (get-buffer buffer)
2697 (setq gnus-summary-buffer (current-buffer))
2698 (not gnus-newsgroup-prepared))
2699 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2700 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2701 (gnus-summary-mode group)
2703 (gnus-carpal-setup-buffer 'summary))
2704 (unless gnus-single-article-buffer
2705 (make-local-variable 'gnus-article-buffer)
2706 (make-local-variable 'gnus-article-current)
2707 (make-local-variable 'gnus-original-article-buffer))
2708 (setq gnus-newsgroup-name group)
2709 ;; Set any local variables in the group parameters.
2710 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2713 (defun gnus-set-global-variables ()
2714 "Set the global equivalents of the buffer-local variables.
2715 They are set to the latest values they had. These reflect the summary
2716 buffer that was in action when the last article was fetched."
2717 (when (eq major-mode 'gnus-summary-mode)
2718 (setq gnus-summary-buffer (current-buffer))
2719 (let ((name gnus-newsgroup-name)
2720 (marked gnus-newsgroup-marked)
2721 (unread gnus-newsgroup-unreads)
2722 (headers gnus-current-headers)
2723 (data gnus-newsgroup-data)
2724 (summary gnus-summary-buffer)
2725 (article-buffer gnus-article-buffer)
2726 (original gnus-original-article-buffer)
2727 (gac gnus-article-current)
2728 (reffed gnus-reffed-article-number)
2729 (score-file gnus-current-score-file)
2730 (default-charset gnus-newsgroup-charset)
2732 (let ((locals gnus-newsgroup-variables))
2734 (if (consp (car locals))
2735 (push (eval (caar locals)) vlist)
2736 (push (eval (car locals)) vlist))
2737 (setq locals (cdr locals)))
2738 (setq vlist (nreverse vlist)))
2740 (set-buffer gnus-group-buffer)
2741 (setq gnus-newsgroup-name name
2742 gnus-newsgroup-marked marked
2743 gnus-newsgroup-unreads unread
2744 gnus-current-headers headers
2745 gnus-newsgroup-data data
2746 gnus-article-current gac
2747 gnus-summary-buffer summary
2748 gnus-article-buffer article-buffer
2749 gnus-original-article-buffer original
2750 gnus-reffed-article-number reffed
2751 gnus-current-score-file score-file
2752 gnus-newsgroup-charset default-charset)
2753 (let ((locals gnus-newsgroup-variables))
2755 (if (consp (car locals))
2756 (set (caar locals) (pop vlist))
2757 (set (car locals) (pop vlist)))
2758 (setq locals (cdr locals))))
2759 ;; The article buffer also has local variables.
2760 (when (gnus-buffer-live-p gnus-article-buffer)
2761 (set-buffer gnus-article-buffer)
2762 (setq gnus-summary-buffer summary))))))
2764 (defun gnus-summary-article-unread-p (article)
2765 "Say whether ARTICLE is unread or not."
2766 (memq article gnus-newsgroup-unreads))
2768 (defun gnus-summary-first-article-p (&optional article)
2769 "Return whether ARTICLE is the first article in the buffer."
2770 (if (not (setq article (or article (gnus-summary-article-number))))
2772 (eq article (caar gnus-newsgroup-data))))
2774 (defun gnus-summary-last-article-p (&optional article)
2775 "Return whether ARTICLE is the last article in the buffer."
2776 (if (not (setq article (or article (gnus-summary-article-number))))
2777 ;; All non-existent numbers are the last article. :-)
2779 (not (cdr (gnus-data-find-list article)))))
2781 (defun gnus-make-thread-indent-array ()
2783 (unless (and gnus-thread-indent-array
2784 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2785 (setq gnus-thread-indent-array (make-vector 201 "")
2786 gnus-thread-indent-array-level gnus-thread-indent-level)
2788 (aset gnus-thread-indent-array n
2789 (make-string (* n gnus-thread-indent-level) ? ))
2792 (defun gnus-update-summary-mark-positions ()
2793 "Compute where the summary marks are to go."
2795 (when (gnus-buffer-exists-p gnus-summary-buffer)
2796 (set-buffer gnus-summary-buffer))
2797 (let ((gnus-replied-mark 129)
2798 (gnus-score-below-mark 130)
2799 (gnus-score-over-mark 130)
2800 (gnus-download-mark 131)
2801 (spec gnus-summary-line-format-spec)
2804 (gnus-set-work-buffer)
2805 (let ((gnus-summary-line-format-spec spec)
2806 (gnus-newsgroup-downloadable '((0 . t))))
2807 (gnus-summary-insert-line
2808 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2809 0 nil 128 t nil "" nil 1)
2810 (goto-char (point-min))
2811 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2813 (goto-char (point-min))
2814 (push (cons 'replied (and (search-forward "\201" nil t)
2817 (goto-char (point-min))
2818 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2820 (goto-char (point-min))
2821 (push (cons 'download
2822 (and (search-forward "\203" nil t) (- (point) 2)))
2824 (setq gnus-summary-mark-positions pos))))
2826 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2827 "Insert a dummy root in the summary buffer."
2829 (gnus-add-text-properties
2830 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2831 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2833 (defun gnus-summary-from-or-to-or-newsgroups (header)
2834 (let ((to (cdr (assq 'To (mail-header-extra header))))
2835 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2836 (default-mime-charset (with-current-buffer gnus-summary-buffer
2837 default-mime-charset)))
2840 gnus-ignored-from-addresses
2841 (string-match gnus-ignored-from-addresses
2842 (mail-header-from header)))
2844 (or (car (funcall gnus-extract-address-components
2846 gnus-decode-encoded-word-function to)))
2847 (funcall gnus-decode-encoded-word-function to))))
2849 gnus-ignored-from-addresses
2850 (string-match gnus-ignored-from-addresses
2851 (mail-header-from header)))
2852 (concat "=> " newsgroups))
2854 (or (car (funcall gnus-extract-address-components
2855 (mail-header-from header)))
2856 (mail-header-from header))))))
2858 (defun gnus-summary-insert-line (gnus-tmp-header
2859 gnus-tmp-level gnus-tmp-current
2860 gnus-tmp-unread gnus-tmp-replied
2861 gnus-tmp-expirable gnus-tmp-subject-or-nil
2862 &optional gnus-tmp-dummy gnus-tmp-score
2864 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2865 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2866 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2867 (gnus-tmp-score-char
2868 (if (or (null gnus-summary-default-score)
2869 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2870 gnus-summary-zcore-fuzz))
2872 (if (< gnus-tmp-score gnus-summary-default-score)
2873 gnus-score-below-mark gnus-score-over-mark)))
2875 (cond (gnus-tmp-process gnus-process-mark)
2876 ((memq gnus-tmp-current gnus-newsgroup-cached)
2878 (gnus-tmp-replied gnus-replied-mark)
2879 ((memq gnus-tmp-current gnus-newsgroup-saved)
2882 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2885 ((string-match "<[^>]+> *$" gnus-tmp-from)
2886 (let ((beg (match-beginning 0)))
2887 (or (and (string-match "^\".+\"" gnus-tmp-from)
2888 (substring gnus-tmp-from 1 (1- (match-end 0))))
2889 (substring gnus-tmp-from 0 beg))))
2890 ((string-match "(.+)" gnus-tmp-from)
2891 (substring gnus-tmp-from
2892 (1+ (match-beginning 0)) (1- (match-end 0))))
2894 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2895 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2896 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2897 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2898 (buffer-read-only nil))
2899 (when (string= gnus-tmp-name "")
2900 (setq gnus-tmp-name gnus-tmp-from))
2901 (unless (numberp gnus-tmp-lines)
2902 (setq gnus-tmp-lines -1))
2903 (when (= gnus-tmp-lines -1)
2904 (setq gnus-tmp-lines "?"))
2905 (gnus-put-text-property-excluding-characters-with-faces
2907 (progn (eval gnus-summary-line-format-spec) (point))
2908 'gnus-number gnus-tmp-number)
2909 (when (gnus-visual-p 'summary-highlight 'highlight)
2911 (gnus-run-hooks 'gnus-summary-update-hook)
2914 (defun gnus-summary-update-line (&optional dont-update)
2915 "Update summary line after change."
2916 (when (and gnus-summary-default-score
2917 (not gnus-summary-inhibit-highlight))
2918 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2919 (article (gnus-summary-article-number))
2920 (score (gnus-summary-article-score article)))
2922 (if (and gnus-summary-mark-below
2923 (< (gnus-summary-article-score)
2924 gnus-summary-mark-below))
2925 ;; This article has a low score, so we mark it as read.
2926 (when (memq article gnus-newsgroup-unreads)
2927 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2928 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2929 ;; This article was previously marked as read on account
2930 ;; of a low score, but now it has risen, so we mark it as
2932 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2933 (gnus-summary-update-mark
2934 (if (or (null gnus-summary-default-score)
2935 (<= (abs (- score gnus-summary-default-score))
2936 gnus-summary-zcore-fuzz))
2938 (if (< score gnus-summary-default-score)
2939 gnus-score-below-mark gnus-score-over-mark))
2941 ;; Do visual highlighting.
2942 (when (gnus-visual-p 'summary-highlight 'highlight)
2943 (gnus-run-hooks 'gnus-summary-update-hook)))))
2945 (defvar gnus-tmp-new-adopts nil)
2947 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2948 "Return the number of articles in THREAD.
2949 This may be 0 in some cases -- if none of the articles in
2950 the thread are to be displayed."
2952 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2954 ((not (listp thread))
2956 ((and (consp thread) (cdr thread))
2959 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2962 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2965 (when (and level (zerop level) gnus-tmp-new-adopts)
2968 'gnus-summary-number-of-articles-in-thread
2969 gnus-tmp-new-adopts))))
2971 (if (> number 1) gnus-not-empty-thread-mark
2972 gnus-empty-thread-mark)
2975 (defun gnus-summary-set-local-parameters (group)
2976 "Go through the local params of GROUP and set all variable specs in that list."
2977 (let ((params (gnus-group-find-parameter group))
2980 (setq elem (car params)
2981 params (cdr params))
2982 (and (consp elem) ; Has to be a cons.
2983 (consp (cdr elem)) ; The cdr has to be a list.
2984 (symbolp (car elem)) ; Has to be a symbol in there.
2985 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2986 (ignore-errors ; So we set it.
2987 (make-local-variable (car elem))
2988 (set (car elem) (eval (nth 1 elem))))))))
2990 (defun gnus-summary-read-group (group &optional show-all no-article
2991 kill-buffer no-display backward
2993 "Start reading news in newsgroup GROUP.
2994 If SHOW-ALL is non-nil, already read articles are also listed.
2995 If NO-ARTICLE is non-nil, no article is selected initially.
2996 If NO-DISPLAY, don't generate a summary buffer."
3000 (let ((gnus-auto-select-next nil))
3001 (or (gnus-summary-read-group-1
3002 group show-all no-article
3003 kill-buffer no-display
3006 select-articles nil)))))
3007 (eq gnus-auto-select-next 'quietly))
3008 (set-buffer gnus-group-buffer)
3009 ;; The entry function called above goes to the next
3010 ;; group automatically, so we go two groups back
3011 ;; if we are searching for the previous group.
3013 (gnus-group-prev-unread-group 2))
3014 (if (not (equal group (gnus-group-group-name)))
3015 (setq group (gnus-group-group-name))
3019 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3020 "Directly jump to the other GROUP from summary buffer.
3021 If SHOW-ALL is non-nil, already read articles are also listed."
3023 (if (eq gnus-summary-buffer (current-buffer))
3024 (list (completing-read
3025 "Group: " gnus-active-hashtb nil t
3026 (when (and gnus-newsgroup-name
3027 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3028 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3029 'gnus-group-history)
3031 (error "%s must be invoked from a gnus summary buffer." this-command)))
3032 (unless (or (zerop (length group))
3033 (and gnus-newsgroup-name
3034 (string-equal gnus-newsgroup-name group)))
3036 (gnus-summary-read-group group show-all
3037 gnus-dont-select-after-jump-to-other-group)))
3039 (defun gnus-summary-read-group-1 (group show-all no-article
3040 kill-buffer no-display
3041 &optional select-articles)
3042 ;; Killed foreign groups can't be entered.
3043 ;; (when (and (not (gnus-group-native-p group))
3044 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3045 ;; (error "Dead non-native groups can't be entered"))
3046 (gnus-message 5 "Retrieving newsgroup: %s..."
3047 (gnus-group-decoded-name group))
3048 (let* ((new-group (gnus-summary-setup-buffer group))
3049 (quit-config (gnus-group-quit-config group))
3050 (did-select (and new-group (gnus-select-newsgroup
3051 group show-all select-articles))))
3053 ;; This summary buffer exists already, so we just select it.
3055 (gnus-set-global-variables)
3057 (gnus-kill-or-deaden-summary kill-buffer))
3058 (gnus-configure-windows 'summary 'force)
3059 (gnus-set-mode-line 'summary)
3060 (gnus-summary-position-point)
3063 ;; We couldn't select this group.
3065 (when (and (eq major-mode 'gnus-summary-mode)
3066 (not (equal (current-buffer) kill-buffer)))
3067 (kill-buffer (current-buffer))
3068 (if (not quit-config)
3070 ;; Update the info -- marks might need to be removed,
3072 (gnus-summary-update-info)
3073 (set-buffer gnus-group-buffer)
3074 (gnus-group-jump-to-group group)
3075 (gnus-group-next-unread-group 1))
3076 (gnus-handle-ephemeral-exit quit-config)))
3077 (let ((grpinfo (gnus-get-info group)))
3078 (if (null (gnus-info-read grpinfo))
3079 (gnus-message 3 "Group %s contains no messages"
3080 (gnus-group-decoded-name group))
3081 (gnus-message 3 "Can't select group")))
3083 ;; The user did a `C-g' while prompting for number of articles,
3084 ;; so we exit this group.
3085 ((eq did-select 'quit)
3086 (and (eq major-mode 'gnus-summary-mode)
3087 (not (equal (current-buffer) kill-buffer))
3088 (kill-buffer (current-buffer)))
3090 (gnus-kill-or-deaden-summary kill-buffer))
3091 (if (not quit-config)
3093 (set-buffer gnus-group-buffer)
3094 (gnus-group-jump-to-group group)
3095 (gnus-group-next-unread-group 1)
3096 (gnus-configure-windows 'group 'force))
3097 (gnus-handle-ephemeral-exit quit-config))
3098 ;; Finally signal the quit.
3100 ;; The group was successfully selected.
3102 (gnus-set-global-variables)
3103 ;; Save the active value in effect when the group was entered.
3104 (setq gnus-newsgroup-active
3106 (gnus-active gnus-newsgroup-name)))
3107 ;; You can change the summary buffer in some way with this hook.
3108 (gnus-run-hooks 'gnus-select-group-hook)
3109 (gnus-update-format-specifications
3110 nil 'summary 'summary-mode 'summary-dummy)
3111 (gnus-update-summary-mark-positions)
3112 ;; Do score processing.
3113 (when gnus-use-scoring
3114 (gnus-possibly-score-headers))
3115 ;; Check whether to fill in the gaps in the threads.
3116 (when gnus-build-sparse-threads
3117 (gnus-build-sparse-threads))
3118 ;; Find the initial limit.
3119 (if gnus-show-threads
3121 (let ((gnus-newsgroup-dormant nil))
3122 (gnus-summary-initial-limit show-all))
3123 (gnus-summary-initial-limit show-all))
3124 ;; When untreaded, all articles are always shown.
3125 (setq gnus-newsgroup-limit
3127 (lambda (header) (mail-header-number header))
3128 gnus-newsgroup-headers)))
3129 ;; Generate the summary buffer.
3131 (gnus-summary-prepare))
3132 (when gnus-use-trees
3133 (gnus-tree-open group)
3134 (setq gnus-summary-highlight-line-function
3135 'gnus-tree-highlight-article))
3136 ;; If the summary buffer is empty, but there are some low-scored
3137 ;; articles or some excluded dormants, we include these in the
3139 (when (and (zerop (buffer-size))
3141 (cond (gnus-newsgroup-dormant
3142 (gnus-summary-limit-include-dormant))
3143 ((and gnus-newsgroup-scored show-all)
3144 (gnus-summary-limit-include-expunged t))))
3145 ;; Function `gnus-apply-kill-file' must be called in this hook.
3146 (gnus-run-hooks 'gnus-apply-kill-hook)
3147 (if (and (zerop (buffer-size))
3150 ;; This newsgroup is empty.
3151 (gnus-summary-catchup-and-exit nil t)
3152 (gnus-message 6 "No unread news")
3154 (gnus-kill-or-deaden-summary kill-buffer))
3155 ;; Return nil from this function.
3157 ;; Hide conversation thread subtrees. We cannot do this in
3158 ;; gnus-summary-prepare-hook since kill processing may not
3159 ;; work with hidden articles.
3160 (and gnus-show-threads
3161 gnus-thread-hide-subtree
3162 (gnus-summary-hide-all-threads))
3164 (gnus-kill-or-deaden-summary kill-buffer))
3165 ;; Show first unread article if requested.
3166 (if (and (not no-article)
3168 gnus-newsgroup-unreads
3169 gnus-auto-select-first)
3171 (gnus-configure-windows 'summary)
3173 ((eq gnus-auto-select-first 'best)
3174 (gnus-summary-best-unread-article))
3175 ((eq gnus-auto-select-first t)
3176 (gnus-summary-first-unread-article))
3177 ((gnus-functionp gnus-auto-select-first)
3178 (funcall gnus-auto-select-first))))
3179 ;; Don't select any articles, just move point to the first
3180 ;; article in the group.
3181 (goto-char (point-min))
3182 (gnus-summary-position-point)
3183 (gnus-configure-windows 'summary 'force)
3184 (gnus-set-mode-line 'summary))
3185 (when (get-buffer-window gnus-group-buffer t)
3186 ;; Gotta use windows, because recenter does weird stuff if
3187 ;; the current buffer ain't the displayed window.
3188 (let ((owin (selected-window)))
3189 (select-window (get-buffer-window gnus-group-buffer t))
3190 (when (gnus-group-goto-group group)
3192 (select-window owin)))
3193 ;; Mark this buffer as "prepared".
3194 (setq gnus-newsgroup-prepared t)
3195 (gnus-run-hooks 'gnus-summary-prepared-hook)
3198 (defun gnus-summary-prepare ()
3199 "Generate the summary buffer."
3201 (let ((buffer-read-only nil))
3203 (setq gnus-newsgroup-data nil
3204 gnus-newsgroup-data-reverse nil)
3205 (gnus-run-hooks 'gnus-summary-generate-hook)
3206 ;; Generate the buffer, either with threads or without.
3207 (when gnus-newsgroup-headers
3208 (gnus-summary-prepare-threads
3209 (if gnus-show-threads
3210 (gnus-sort-gathered-threads
3211 (funcall gnus-summary-thread-gathering-function
3213 (gnus-cut-threads (gnus-make-threads)))))
3214 ;; Unthreaded display.
3215 (gnus-sort-articles gnus-newsgroup-headers))))
3216 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3217 ;; Call hooks for modifying summary buffer.
3218 (goto-char (point-min))
3219 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3221 (defsubst gnus-general-simplify-subject (subject)
3222 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3225 ;; Truncate the subject.
3226 (gnus-simplify-subject-functions
3227 (gnus-map-function gnus-simplify-subject-functions subject))
3228 ((numberp gnus-summary-gather-subject-limit)
3229 (setq subject (gnus-simplify-subject-re subject))
3230 (if (> (length subject) gnus-summary-gather-subject-limit)
3231 (substring subject 0 gnus-summary-gather-subject-limit)
3233 ;; Fuzzily simplify it.
3234 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3235 (gnus-simplify-subject-fuzzy subject))
3236 ;; Just remove the leading "Re:".
3238 (gnus-simplify-subject-re subject))))
3240 (if (and gnus-summary-gather-exclude-subject
3241 (string-match gnus-summary-gather-exclude-subject subject))
3242 nil ; This article shouldn't be gathered
3245 (defun gnus-summary-simplify-subject-query ()
3246 "Query where the respool algorithm would put this article."
3248 (gnus-summary-select-article)
3250 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3252 (defun gnus-gather-threads-by-subject (threads)
3253 "Gather threads by looking at Subject headers."
3254 (if (not gnus-summary-make-false-root)
3256 (let ((hashtb (gnus-make-hashtable 1024))
3259 subject hthread whole-subject)
3261 (setq subject (gnus-general-simplify-subject
3262 (setq whole-subject (mail-header-subject
3265 (if (setq hthread (gnus-gethash subject hashtb))
3267 ;; We enter a dummy root into the thread, if we
3268 ;; haven't done that already.
3269 (unless (stringp (caar hthread))
3270 (setcar hthread (list whole-subject (car hthread))))
3271 ;; We add this new gathered thread to this gathered
3273 (setcdr (car hthread)
3274 (nconc (cdar hthread) (list (car threads))))
3275 ;; Remove it from the list of threads.
3276 (setcdr prev (cdr threads))
3277 (setq threads prev))
3278 ;; Enter this thread into the hash table.
3279 (gnus-sethash subject threads hashtb)))
3281 (setq threads (cdr threads)))
3284 (defun gnus-gather-threads-by-references (threads)
3285 "Gather threads by looking at References headers."
3286 (let ((idhashtb (gnus-make-hashtable 1024))
3287 (thhashtb (gnus-make-hashtable 1024))
3290 ids references id gthread gid entered ref)
3292 (when (setq references (mail-header-references (caar threads)))
3293 (setq id (mail-header-id (caar threads))
3294 ids (gnus-split-references references)
3296 (while (setq ref (pop ids))
3297 (setq ids (delete ref ids))
3298 (if (not (setq gid (gnus-gethash ref idhashtb)))
3300 (gnus-sethash ref id idhashtb)
3301 (gnus-sethash id threads thhashtb))
3302 (setq gthread (gnus-gethash gid thhashtb))
3304 ;; We enter a dummy root into the thread, if we
3305 ;; haven't done that already.
3306 (unless (stringp (caar gthread))
3307 (setcar gthread (list (mail-header-subject (caar gthread))
3309 ;; We add this new gathered thread to this gathered
3311 (setcdr (car gthread)
3312 (nconc (cdar gthread) (list (car threads)))))
3313 ;; Add it into the thread hash table.
3314 (gnus-sethash id gthread thhashtb)
3316 ;; Remove it from the list of threads.
3317 (setcdr prev (cdr threads))
3318 (setq threads prev))))
3320 (setq threads (cdr threads)))
3323 (defun gnus-sort-gathered-threads (threads)
3324 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3325 (let ((result threads))
3327 (when (stringp (caar threads))
3328 (setcdr (car threads)
3329 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3330 (setq threads (cdr threads)))
3333 (defun gnus-thread-loop-p (root thread)
3334 "Say whether ROOT is in THREAD."
3335 (let ((stack (list thread))
3338 (while (setq thread (pop stack))
3339 (setq th (cdr thread))
3341 (not (eq (caar th) root)))
3344 ;; We have found a loop.
3346 (setcdr thread (delq (car th) (cdr thread)))
3347 (if (boundp (setq ref-dep (intern "none"
3348 gnus-newsgroup-dependencies)))
3349 (setcdr (symbol-value ref-dep)
3350 (nconc (cdr (symbol-value ref-dep))
3352 (set ref-dep (list nil (car th))))
3355 ;; Push all the subthreads onto the stack.
3356 (push (cdr thread) stack)))
3359 (defun gnus-make-threads ()
3360 "Go through the dependency hashtb and find the roots. Return all threads."
3362 (while (catch 'infloop
3365 ;; Deal with self-referencing References loops.
3366 (when (and (car (symbol-value refs))
3373 (car (symbol-value refs)) thread))
3374 (cdr (symbol-value refs)))))))
3377 (unless (car (symbol-value refs))
3378 ;; These threads do not refer back to any other articles,
3379 ;; so they're roots.
3380 (setq threads (append (cdr (symbol-value refs)) threads))))
3381 gnus-newsgroup-dependencies)))
3384 ;; Build the thread tree.
3385 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3386 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3388 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3389 if it was already present.
3391 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3392 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3393 Message-IDs will be renamed be renamed to a unique Message-ID before
3396 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3397 (let* ((id (mail-header-id header))
3398 (id-dep (and id (intern id dependencies)))
3399 ref ref-dep ref-header)
3400 ;; Enter this `header' in the `dependencies' table.
3404 ;; The first two cases do the normal part: enter a new `header'
3405 ;; in the `dependencies' table.
3406 ((not (boundp id-dep))
3407 (set id-dep (list header)))
3408 ((null (car (symbol-value id-dep)))
3409 (setcar (symbol-value id-dep) header))
3411 ;; From here the `header' was already present in the
3412 ;; `dependencies' table.
3414 ;; Overrides an existing entry;
3415 ;; just set the header part of the entry.
3416 (setcar (symbol-value id-dep) header))
3418 ;; Renames the existing `header' to a unique Message-ID.
3419 ((not gnus-summary-ignore-duplicates)
3420 ;; An article with this Message-ID has already been seen.
3421 ;; We rename the Message-ID.
3422 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3424 (mail-header-set-id header id))
3426 ;; The last case ignores an existing entry, except it adds any
3427 ;; additional Xrefs (in case the two articles came from different
3429 ;; Also sets `header' to `nil' meaning that the `dependencies'
3430 ;; table was *not* modified.
3432 (mail-header-set-xref
3433 (car (symbol-value id-dep))
3434 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3436 (or (mail-header-xref header) "")))
3440 ;; First check if that we are not creating a References loop.
3441 (setq ref (gnus-parent-id (mail-header-references header)))
3443 (setq ref-dep (intern-soft ref dependencies))
3445 (setq ref-header (car (symbol-value ref-dep))))
3446 (if (string= id ref)
3447 ;; Yuk! This is a reference loop. Make the article be a
3450 (mail-header-set-references (car (symbol-value id-dep)) "none")
3452 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3453 (setq ref (gnus-parent-id (mail-header-references header)))
3454 (setq ref-dep (intern (or ref "none") dependencies))
3455 (if (boundp ref-dep)
3456 (setcdr (symbol-value ref-dep)
3457 (nconc (cdr (symbol-value ref-dep))
3458 (list (symbol-value id-dep))))
3459 (set ref-dep (list nil (symbol-value id-dep)))))
3462 (defun gnus-build-sparse-threads ()
3463 (let ((headers gnus-newsgroup-headers)
3464 (mail-parse-charset gnus-newsgroup-charset)
3465 (gnus-summary-ignore-duplicates t)
3466 header references generation relations
3467 subject child end new-child date)
3468 ;; First we create an alist of generations/relations, where
3469 ;; generations is how much we trust the relation, and the relation
3471 (gnus-message 7 "Making sparse threads...")
3473 (nnheader-set-temp-buffer " *gnus sparse threads*")
3474 (while (setq header (pop headers))
3475 (when (and (setq references (mail-header-references header))
3476 (not (string= references "")))
3478 (setq child (mail-header-id header)
3479 subject (mail-header-subject header)
3480 date (mail-header-date header)
3482 (while (search-backward ">" nil t)
3483 (setq end (1+ (point)))
3484 (when (search-backward "<" nil t)
3485 (setq new-child (buffer-substring (point) end))
3486 (push (list (incf generation)
3487 child (setq child new-child)
3491 (push (list (1+ generation) child nil subject) relations))
3493 (kill-buffer (current-buffer)))
3494 ;; Sort over trustworthiness.
3497 (when (gnus-dependencies-add-header
3498 (make-full-mail-header-from-decoded-header
3499 gnus-reffed-article-number
3500 (nth 3 relation) "" (or (nth 4 relation) "")
3502 (or (nth 2 relation) "") 0 0 "")
3503 gnus-newsgroup-dependencies nil)
3504 (push gnus-reffed-article-number gnus-newsgroup-limit)
3505 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3506 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3507 gnus-newsgroup-reads)
3508 (decf gnus-reffed-article-number)))
3509 (sort relations 'car-less-than-car))
3510 (gnus-message 7 "Making sparse threads...done")))
3512 (defun gnus-build-old-threads ()
3513 ;; Look at all the articles that refer back to old articles, and
3514 ;; fetch the headers for the articles that aren't there. This will
3515 ;; build complete threads - if the roots haven't been expired by the
3517 (let ((mail-parse-charset gnus-newsgroup-charset)
3521 (when (not (car (symbol-value refs)))
3522 (setq heads (cdr (symbol-value refs)))
3524 (if (memq (mail-header-number (caar heads))
3525 gnus-newsgroup-dormant)
3526 (setq heads (cdr heads))
3527 (setq id (symbol-name refs))
3528 (while (and (setq id (gnus-build-get-header id))
3529 (not (car (gnus-id-to-thread id)))))
3530 (setq heads nil)))))
3531 gnus-newsgroup-dependencies)))
3533 ;; This function has to be called with point after the article number
3534 ;; on the beginning of the line.
3535 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3536 (let ((eol (gnus-point-at-eol))
3537 (buffer (current-buffer))
3540 ;; overview: [num subject from date id refs chars lines misc]
3543 (narrow-to-region (point) eol)
3548 (make-full-mail-header
3550 (nnheader-nov-field) ; subject
3551 (nnheader-nov-field) ; from
3552 (nnheader-nov-field) ; date
3553 (nnheader-nov-read-message-id) ; id
3554 (nnheader-nov-field) ; refs
3555 (nnheader-nov-read-integer) ; chars
3556 (nnheader-nov-read-integer) ; lines
3558 (if (looking-at "Xref: ")
3559 (goto-char (match-end 0)))
3560 (nnheader-nov-field)) ; Xref
3561 (nnheader-nov-parse-extra)))) ; extra
3565 (when gnus-alter-header-function
3566 (funcall gnus-alter-header-function header))
3567 (gnus-dependencies-add-header header dependencies force-new)))
3569 (defun gnus-build-get-header (id)
3570 "Look through the buffer of NOV lines and find the header to ID.
3571 Enter this line into the dependencies hash table, and return
3572 the id of the parent article (if any)."
3573 (let ((deps gnus-newsgroup-dependencies)
3577 (set-buffer nntp-server-buffer)
3578 (let ((case-fold-search nil))
3579 (goto-char (point-min))
3580 (while (and (not found)
3581 (search-forward id nil t))
3583 (setq found (looking-at
3584 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3585 (regexp-quote id))))
3586 (or found (beginning-of-line 2)))
3590 (setq header (gnus-nov-parse-line
3591 (read (current-buffer)) deps))
3592 (gnus-parent-id (mail-header-references header))))))
3594 (let ((number (mail-header-number header)))
3595 (push number gnus-newsgroup-limit)
3596 (push header gnus-newsgroup-headers)
3597 (if (memq number gnus-newsgroup-unselected)
3599 (push number gnus-newsgroup-unreads)
3600 (setq gnus-newsgroup-unselected
3601 (delq number gnus-newsgroup-unselected)))
3602 (push number gnus-newsgroup-ancient)))))))
3604 (defun gnus-build-all-threads ()
3605 "Read all the headers."
3606 (let ((gnus-summary-ignore-duplicates t)
3607 (mail-parse-charset gnus-newsgroup-charset)
3608 (dependencies gnus-newsgroup-dependencies)
3611 (set-buffer nntp-server-buffer)
3612 (let ((case-fold-search nil))
3613 (goto-char (point-min))
3616 (setq article (read (current-buffer))
3617 header (gnus-nov-parse-line article dependencies)))
3620 (set-buffer gnus-summary-buffer)
3621 (push header gnus-newsgroup-headers)
3622 (if (memq (setq article (mail-header-number header))
3623 gnus-newsgroup-unselected)
3625 (push article gnus-newsgroup-unreads)
3626 (setq gnus-newsgroup-unselected
3627 (delq article gnus-newsgroup-unselected)))
3628 (push article gnus-newsgroup-ancient)))
3629 (forward-line 1)))))))
3631 (defun gnus-summary-update-article-line (article header)
3632 "Update the line for ARTICLE using HEADERS."
3633 (let* ((id (mail-header-id header))
3634 (thread (gnus-id-to-thread id)))
3636 (error "Article in no thread"))
3637 ;; Update the thread.
3638 (setcar thread header)
3639 (gnus-summary-goto-subject article)
3640 (let* ((datal (gnus-data-find-list article))
3642 (length (when (cdr datal)
3643 (- (gnus-data-pos data)
3644 (gnus-data-pos (cadr datal)))))
3645 (buffer-read-only nil)
3646 (level (gnus-summary-thread-level)))
3648 (gnus-summary-insert-line
3649 header level nil (gnus-article-mark article)
3650 (memq article gnus-newsgroup-replied)
3651 (memq article gnus-newsgroup-expirable)
3652 ;; Only insert the Subject string when it's different
3653 ;; from the previous Subject string.
3658 (mail-header-subject
3661 (gnus-data-find-list
3663 (gnus-data-list t)))))
3664 ;; Error on the side of excessive subjects.
3666 (mail-header-subject header)))
3668 (mail-header-subject header))
3669 nil (cdr (assq article gnus-newsgroup-scored))
3670 (memq article gnus-newsgroup-processable))
3672 (gnus-data-update-list
3673 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3675 (defun gnus-summary-update-article (article &optional iheader)
3676 "Update ARTICLE in the summary buffer."
3677 (set-buffer gnus-summary-buffer)
3678 (let* ((header (gnus-summary-article-header article))
3679 (id (mail-header-id header))
3680 (data (gnus-data-find article))
3681 (thread (gnus-id-to-thread id))
3682 (references (mail-header-references header))
3686 (when (and references
3687 (not (equal "" references)))
3690 (buffer-read-only nil)
3696 (delq thread parent)))
3697 (if (gnus-summary-insert-subject id header)
3698 ;; Set the (possibly) new article number in the data structure.
3699 (gnus-data-set-number data (gnus-id-to-article id))
3703 (defun gnus-rebuild-thread (id &optional line)
3704 "Rebuild the thread containing ID.
3705 If LINE, insert the rebuilt thread starting on line LINE."
3706 (let ((buffer-read-only nil)
3707 old-pos current thread data)
3708 (if (not gnus-show-threads)
3709 (setq thread (list (car (gnus-id-to-thread id))))
3710 ;; Get the thread this article is part of.
3711 (setq thread (gnus-remove-thread id)))
3712 (setq old-pos (gnus-point-at-bol))
3713 (setq current (save-excursion
3714 (and (zerop (forward-line -1))
3715 (gnus-summary-article-number))))
3716 ;; If this is a gathered thread, we have to go some re-gathering.
3717 (when (stringp (car thread))
3718 (let ((subject (car thread))
3720 (setq thread (cdr thread))
3722 (unless (memq (setq thr (gnus-id-to-thread
3724 (mail-header-id (caar thread)))))
3727 (setq thread (cdr thread)))
3728 ;; We now have all (unique) roots.
3729 (if (= (length roots) 1)
3730 ;; All the loose roots are now one solid root.
3731 (setq thread (car roots))
3732 (setq thread (cons subject (gnus-sort-threads roots))))))
3734 ;; We then insert this thread into the summary buffer.
3736 (goto-char (point-min))
3737 (forward-line (1- line)))
3738 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3739 (if gnus-show-threads
3740 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3741 (gnus-summary-prepare-unthreaded thread))
3742 (setq data (nreverse gnus-newsgroup-data))
3743 (setq threads gnus-newsgroup-threads))
3744 ;; We splice the new data into the data structure.
3745 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3746 ;;!!! then we want to insert at the beginning of the buffer.
3747 ;;!!! That happens to be true with Gnus now, but that may
3748 ;;!!! change in the future. Perhaps.
3749 (gnus-data-enter-list
3750 (if line nil current) data (- (point) old-pos))
3751 (setq gnus-newsgroup-threads
3752 (nconc threads gnus-newsgroup-threads))
3753 (gnus-data-compute-positions))))
3755 (defun gnus-number-to-header (number)
3756 "Return the header for article NUMBER."
3757 (let ((headers gnus-newsgroup-headers))
3759 (not (= number (mail-header-number (car headers)))))
3764 (defun gnus-parent-headers (in-headers &optional generation)
3765 "Return the headers of the GENERATIONeth parent of HEADERS."
3767 (setq generation 1))
3769 (headers in-headers)
3772 (not (zerop generation))
3773 (setq references (mail-header-references headers)))
3774 (setq headers (if (and references
3775 (setq parent (gnus-parent-id references)))
3776 (car (gnus-id-to-thread parent))
3779 (and (not (eq headers in-headers))
3782 (defun gnus-id-to-thread (id)
3783 "Return the (sub-)thread where ID appears."
3784 (gnus-gethash id gnus-newsgroup-dependencies))
3786 (defun gnus-id-to-article (id)
3787 "Return the article number of ID."
3788 (let ((thread (gnus-id-to-thread id)))
3791 (mail-header-number (car thread)))))
3793 (defun gnus-id-to-header (id)
3794 "Return the article headers of ID."
3795 (car (gnus-id-to-thread id)))
3797 (defun gnus-article-displayed-root-p (article)
3798 "Say whether ARTICLE is a root(ish) article."
3799 (let ((level (gnus-summary-thread-level article))
3800 (refs (mail-header-references (gnus-summary-article-header article)))
3806 ((null (gnus-parent-id refs)) t)
3808 (null (setq particle (gnus-id-to-article
3809 (gnus-parent-id refs))))
3810 (null (gnus-summary-thread-level particle)))))))
3812 (defun gnus-root-id (id)
3813 "Return the id of the root of the thread where ID appears."
3815 (while (and id (setq prev (car (gnus-id-to-thread id))))
3817 id (gnus-parent-id (mail-header-references prev))))
3820 (defun gnus-articles-in-thread (thread)
3821 "Return the list of articles in THREAD."
3822 (cons (mail-header-number (car thread))
3823 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3825 (defun gnus-remove-thread (id &optional dont-remove)
3826 "Remove the thread that has ID in it."
3827 (let (headers thread last-id)
3828 ;; First go up in this thread until we find the root.
3829 (setq last-id (gnus-root-id id)
3830 headers (message-flatten-list (gnus-id-to-thread last-id)))
3831 ;; We have now found the real root of this thread. It might have
3832 ;; been gathered into some loose thread, so we have to search
3833 ;; through the threads to find the thread we wanted.
3834 (let ((threads gnus-newsgroup-threads)
3837 (setq sub (car threads))
3838 (if (stringp (car sub))
3839 ;; This is a gathered thread, so we look at the roots
3840 ;; below it to find whether this article is in this
3843 (setq sub (cdr sub))
3845 (when (member (caar sub) headers)
3846 (setq thread (car threads)
3849 (setq sub (cdr sub))))
3850 ;; It's an ordinary thread, so we check it.
3851 (when (eq (car sub) (car headers))
3854 (setq threads (cdr threads)))
3855 ;; If this article is in no thread, then it's a root.
3858 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3859 (setq thread (gnus-id-to-thread last-id)))
3862 thread ; We return this thread.
3864 (if (stringp (car thread))
3866 ;; If we use dummy roots, then we have to remove the
3867 ;; dummy root as well.
3868 (when (eq gnus-summary-make-false-root 'dummy)
3869 ;; We go to the dummy root by going to
3870 ;; the first sub-"thread", and then one line up.
3871 (gnus-summary-goto-article
3872 (mail-header-number (caadr thread)))
3875 (gnus-data-compute-positions))
3876 (setq thread (cdr thread))
3878 (gnus-remove-thread-1 (car thread))
3879 (setq thread (cdr thread))))
3880 (gnus-remove-thread-1 thread))))))))
3882 (defun gnus-remove-thread-1 (thread)
3883 "Remove the thread THREAD recursively."
3884 (let ((number (mail-header-number (pop thread)))
3886 (setq thread (reverse thread))
3888 (gnus-remove-thread-1 (pop thread)))
3889 (when (setq d (gnus-data-find number))
3890 (goto-char (gnus-data-pos d))
3891 (gnus-summary-show-thread)
3894 (- (gnus-point-at-bol)
3896 (1+ (gnus-point-at-eol))
3897 (gnus-delete-line)))))))
3899 (defun gnus-sort-threads-1 (threads func)
3900 (sort (mapcar (lambda (thread)
3903 (gnus-sort-threads-1 (cdr thread) func))))
3906 (defun gnus-sort-threads (threads)
3908 (if (not gnus-thread-sort-functions)
3910 (gnus-message 8 "Sorting threads...")
3912 (gnus-sort-threads-1
3914 (gnus-make-sort-function gnus-thread-sort-functions))
3915 (gnus-message 8 "Sorting threads...done"))))
3917 (defun gnus-sort-articles (articles)
3919 (when gnus-article-sort-functions
3920 (gnus-message 7 "Sorting articles...")
3922 (setq gnus-newsgroup-headers
3923 (sort articles (gnus-make-sort-function
3924 gnus-article-sort-functions)))
3925 (gnus-message 7 "Sorting articles...done"))))
3927 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3928 (defmacro gnus-thread-header (thread)
3929 "Return header of first article in THREAD.
3930 Note that THREAD must never, ever be anything else than a variable -
3931 using some other form will lead to serious barfage."
3932 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3933 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3934 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3937 (defsubst gnus-article-sort-by-number (h1 h2)
3938 "Sort articles by article number."
3939 (< (mail-header-number h1)
3940 (mail-header-number h2)))
3942 (defun gnus-thread-sort-by-number (h1 h2)
3943 "Sort threads by root article number."
3944 (gnus-article-sort-by-number
3945 (gnus-thread-header h1) (gnus-thread-header h2)))
3947 (defsubst gnus-article-sort-by-lines (h1 h2)
3948 "Sort articles by article Lines header."
3949 (< (mail-header-lines h1)
3950 (mail-header-lines h2)))
3952 (defun gnus-thread-sort-by-lines (h1 h2)
3953 "Sort threads by root article Lines header."
3954 (gnus-article-sort-by-lines
3955 (gnus-thread-header h1) (gnus-thread-header h2)))
3957 (defsubst gnus-article-sort-by-chars (h1 h2)
3958 "Sort articles by octet length."
3959 (< (mail-header-chars h1)
3960 (mail-header-chars h2)))
3962 (defun gnus-thread-sort-by-chars (h1 h2)
3963 "Sort threads by root article octet length."
3964 (gnus-article-sort-by-chars
3965 (gnus-thread-header h1) (gnus-thread-header h2)))
3967 (defsubst gnus-article-sort-by-author (h1 h2)
3968 "Sort articles by root author."
3970 (let ((addr (car (mime-entity-read-field h1 'From))))
3971 (or (std11-full-name-string addr)
3972 (std11-address-string addr)
3974 (let ((addr (car (mime-entity-read-field h2 'From))))
3975 (or (std11-full-name-string addr)
3976 (std11-address-string addr)
3980 (defun gnus-thread-sort-by-author (h1 h2)
3981 "Sort threads by root author."
3982 (gnus-article-sort-by-author
3983 (gnus-thread-header h1) (gnus-thread-header h2)))
3985 (defsubst gnus-article-sort-by-subject (h1 h2)
3986 "Sort articles by root subject."
3988 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3989 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3991 (defun gnus-thread-sort-by-subject (h1 h2)
3992 "Sort threads by root subject."
3993 (gnus-article-sort-by-subject
3994 (gnus-thread-header h1) (gnus-thread-header h2)))
3996 (defsubst gnus-article-sort-by-date (h1 h2)
3997 "Sort articles by root article date."
3999 (gnus-date-get-time (mail-header-date h1))
4000 (gnus-date-get-time (mail-header-date h2))))
4002 (defun gnus-thread-sort-by-date (h1 h2)
4003 "Sort threads by root article date."
4004 (gnus-article-sort-by-date
4005 (gnus-thread-header h1) (gnus-thread-header h2)))
4007 (defsubst gnus-article-sort-by-score (h1 h2)
4008 "Sort articles by root article score.
4009 Unscored articles will be counted as having a score of zero."
4010 (> (or (cdr (assq (mail-header-number h1)
4011 gnus-newsgroup-scored))
4012 gnus-summary-default-score 0)
4013 (or (cdr (assq (mail-header-number h2)
4014 gnus-newsgroup-scored))
4015 gnus-summary-default-score 0)))
4017 (defun gnus-thread-sort-by-score (h1 h2)
4018 "Sort threads by root article score."
4019 (gnus-article-sort-by-score
4020 (gnus-thread-header h1) (gnus-thread-header h2)))
4022 (defun gnus-thread-sort-by-total-score (h1 h2)
4023 "Sort threads by the sum of all scores in the thread.
4024 Unscored articles will be counted as having a score of zero."
4025 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4027 (defun gnus-thread-total-score (thread)
4028 ;; This function find the total score of THREAD.
4029 (cond ((null thread)
4032 (if (stringp (car thread))
4033 (apply gnus-thread-score-function 0
4034 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4035 (gnus-thread-total-score-1 thread)))
4037 (gnus-thread-total-score-1 (list thread)))))
4039 (defun gnus-thread-total-score-1 (root)
4040 ;; This function find the total score of the thread below ROOT.
4041 (setq root (car root))
4042 (apply gnus-thread-score-function
4044 (mapcar 'gnus-thread-total-score
4045 (cdr (gnus-id-to-thread (mail-header-id root))))
4046 (when (> (mail-header-number root) 0)
4047 (list (or (cdr (assq (mail-header-number root)
4048 gnus-newsgroup-scored))
4049 gnus-summary-default-score 0))))
4050 (list gnus-summary-default-score)
4053 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4054 (defvar gnus-tmp-prev-subject nil)
4055 (defvar gnus-tmp-false-parent nil)
4056 (defvar gnus-tmp-root-expunged nil)
4057 (defvar gnus-tmp-dummy-line nil)
4059 (eval-when-compile (defvar gnus-tmp-header))
4060 (defun gnus-extra-header (type &optional header)
4061 "Return the extra header of TYPE."
4062 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4065 (defun gnus-summary-prepare-threads (threads)
4066 "Prepare summary buffer from THREADS and indentation LEVEL.
4067 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4068 or a straight list of headers."
4069 (gnus-message 7 "Generating summary...")
4071 (setq gnus-newsgroup-threads threads)
4074 (let ((gnus-tmp-level 0)
4075 (default-score (or gnus-summary-default-score 0))
4076 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4077 thread number subject stack state gnus-tmp-gathered beg-match
4078 new-roots gnus-tmp-new-adopts thread-end
4079 gnus-tmp-header gnus-tmp-unread
4080 gnus-tmp-replied gnus-tmp-subject-or-nil
4081 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4082 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4083 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4085 (setq gnus-tmp-prev-subject nil)
4087 (if (vectorp (car threads))
4088 ;; If this is a straight (sic) list of headers, then a
4089 ;; threaded summary display isn't required, so we just create
4090 ;; an unthreaded one.
4091 (gnus-summary-prepare-unthreaded threads)
4093 ;; Do the threaded display.
4095 (while (or threads stack gnus-tmp-new-adopts new-roots)
4097 (if (and (= gnus-tmp-level 0)
4100 (not gnus-tmp-false-parent)
4101 (or gnus-tmp-new-adopts new-roots))
4102 (if gnus-tmp-new-adopts
4103 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4104 thread (list (car gnus-tmp-new-adopts))
4105 gnus-tmp-header (caar thread)
4106 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4108 (setq thread (list (car new-roots))
4109 gnus-tmp-header (caar thread)
4110 new-roots (cdr new-roots))))
4113 ;; If there are some threads, we do them before the
4114 ;; threads on the stack.
4115 (setq thread threads
4116 gnus-tmp-header (caar thread))
4117 ;; There were no current threads, so we pop something off
4119 (setq state (car stack)
4120 gnus-tmp-level (car state)
4123 gnus-tmp-header (caar thread))))
4125 (setq gnus-tmp-false-parent nil)
4126 (setq gnus-tmp-root-expunged nil)
4127 (setq thread-end nil)
4129 (if (stringp gnus-tmp-header)
4130 ;; The header is a dummy root.
4132 ((eq gnus-summary-make-false-root 'adopt)
4133 ;; We let the first article adopt the rest.
4134 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4136 (setq gnus-tmp-gathered
4138 (lambda (h) (mail-header-number (car h)))
4141 (setq thread (cons (list (caar thread)
4144 (setq gnus-tmp-level -1
4145 gnus-tmp-false-parent t))
4146 ((eq gnus-summary-make-false-root 'empty)
4147 ;; We print adopted articles with empty subject fields.
4148 (setq gnus-tmp-gathered
4150 (lambda (h) (mail-header-number (car h)))
4153 (setq gnus-tmp-level -1))
4154 ((eq gnus-summary-make-false-root 'dummy)
4155 ;; We remember that we probably want to output a dummy
4157 (setq gnus-tmp-dummy-line gnus-tmp-header)
4158 (setq gnus-tmp-prev-subject gnus-tmp-header))
4160 ;; We do not make a root for the gathered
4161 ;; sub-threads at all.
4162 (setq gnus-tmp-level -1)))
4164 (setq number (mail-header-number gnus-tmp-header)
4165 subject (mail-header-subject gnus-tmp-header))
4168 ;; If the thread has changed subject, we might want to make
4169 ;; this subthread into a root.
4170 ((and (null gnus-thread-ignore-subject)
4171 (not (zerop gnus-tmp-level))
4172 gnus-tmp-prev-subject
4174 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4175 (setq new-roots (nconc new-roots (list (car thread)))
4177 gnus-tmp-header nil))
4178 ;; If the article lies outside the current limit,
4179 ;; then we do not display it.
4180 ((not (memq number gnus-newsgroup-limit))
4181 (setq gnus-tmp-gathered
4183 (lambda (h) (mail-header-number (car h)))
4186 (setq gnus-tmp-new-adopts (if (cdar thread)
4187 (append gnus-tmp-new-adopts
4189 gnus-tmp-new-adopts)
4191 gnus-tmp-header nil)
4192 (when (zerop gnus-tmp-level)
4193 (setq gnus-tmp-root-expunged t)))
4194 ;; Perhaps this article is to be marked as read?
4195 ((and gnus-summary-mark-below
4196 (< (or (cdr (assq number gnus-newsgroup-scored))
4198 gnus-summary-mark-below)
4199 ;; Don't touch sparse articles.
4200 (not (gnus-summary-article-sparse-p number))
4201 (not (gnus-summary-article-ancient-p number)))
4202 (setq gnus-newsgroup-unreads
4203 (delq number gnus-newsgroup-unreads))
4204 (if gnus-newsgroup-auto-expire
4205 (push number gnus-newsgroup-expirable)
4206 (push (cons number gnus-low-score-mark)
4207 gnus-newsgroup-reads))))
4209 (when gnus-tmp-header
4210 ;; We may have an old dummy line to output before this
4212 (when (and gnus-tmp-dummy-line
4215 (mail-header-subject gnus-tmp-header)))
4216 (gnus-summary-insert-dummy-line
4217 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4218 (setq gnus-tmp-dummy-line nil))
4220 ;; Compute the mark.
4221 (setq gnus-tmp-unread (gnus-article-mark number))
4223 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4224 gnus-tmp-header gnus-tmp-level)
4225 gnus-newsgroup-data)
4227 ;; Actually insert the line.
4229 gnus-tmp-subject-or-nil
4231 ((and gnus-thread-ignore-subject
4232 gnus-tmp-prev-subject
4233 (not (inline (gnus-subject-equal
4234 gnus-tmp-prev-subject subject))))
4236 ((zerop gnus-tmp-level)
4237 (if (and (eq gnus-summary-make-false-root 'empty)
4238 (memq number gnus-tmp-gathered)
4239 gnus-tmp-prev-subject
4240 (inline (gnus-subject-equal
4241 gnus-tmp-prev-subject subject)))
4242 gnus-summary-same-subject
4244 (t gnus-summary-same-subject)))
4245 (if (and (eq gnus-summary-make-false-root 'adopt)
4246 (= gnus-tmp-level 1)
4247 (memq number gnus-tmp-gathered))
4248 (setq gnus-tmp-opening-bracket ?\<
4249 gnus-tmp-closing-bracket ?\>)
4250 (setq gnus-tmp-opening-bracket ?\[
4251 gnus-tmp-closing-bracket ?\]))
4253 gnus-tmp-indentation
4254 (aref gnus-thread-indent-array gnus-tmp-level)
4255 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4256 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4257 gnus-summary-default-score 0)
4259 (if (or (null gnus-summary-default-score)
4260 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4261 gnus-summary-zcore-fuzz))
4263 (if (< gnus-tmp-score gnus-summary-default-score)
4264 gnus-score-below-mark gnus-score-over-mark))
4266 (cond ((memq number gnus-newsgroup-processable)
4268 ((memq number gnus-newsgroup-cached)
4270 ((memq number gnus-newsgroup-replied)
4272 ((memq number gnus-newsgroup-forwarded)
4273 gnus-forwarded-mark)
4274 ((memq number gnus-newsgroup-saved)
4277 gnus-tmp-from (mail-header-from gnus-tmp-header)
4280 ((string-match "<[^>]+> *$" gnus-tmp-from)
4281 (setq beg-match (match-beginning 0))
4282 (or (and (string-match "^\".+\"" gnus-tmp-from)
4283 (substring gnus-tmp-from 1 (1- (match-end 0))))
4284 (substring gnus-tmp-from 0 beg-match)))
4285 ((string-match "(.+)" gnus-tmp-from)
4286 (substring gnus-tmp-from
4287 (1+ (match-beginning 0)) (1- (match-end 0))))
4289 (when (string= gnus-tmp-name "")
4290 (setq gnus-tmp-name gnus-tmp-from))
4291 (unless (numberp gnus-tmp-lines)
4292 (setq gnus-tmp-lines -1))
4293 (when (= gnus-tmp-lines -1)
4294 (setq gnus-tmp-lines "?"))
4295 (gnus-put-text-property
4297 (progn (eval gnus-summary-line-format-spec) (point))
4298 'gnus-number number)
4301 (gnus-run-hooks 'gnus-summary-update-hook)
4304 (setq gnus-tmp-prev-subject subject)))
4306 (when (nth 1 thread)
4307 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4308 (incf gnus-tmp-level)
4309 (setq threads (if thread-end nil (cdar thread)))
4311 (setq gnus-tmp-level 0)))))
4312 (gnus-message 7 "Generating summary...done"))
4314 (defun gnus-summary-prepare-unthreaded (headers)
4315 "Generate an unthreaded summary buffer based on HEADERS."
4316 (let (header number mark)
4321 ;; We may have to root out some bad articles...
4322 (when (memq (setq number (mail-header-number
4323 (setq header (pop headers))))
4324 gnus-newsgroup-limit)
4325 ;; Mark article as read when it has a low score.
4326 (when (and gnus-summary-mark-below
4327 (< (or (cdr (assq number gnus-newsgroup-scored))
4328 gnus-summary-default-score 0)
4329 gnus-summary-mark-below)
4330 (not (gnus-summary-article-ancient-p number)))
4331 (setq gnus-newsgroup-unreads
4332 (delq number gnus-newsgroup-unreads))
4333 (if gnus-newsgroup-auto-expire
4334 (push number gnus-newsgroup-expirable)
4335 (push (cons number gnus-low-score-mark)
4336 gnus-newsgroup-reads)))
4338 (setq mark (gnus-article-mark number))
4339 (push (gnus-data-make number mark (1+ (point)) header 0)
4340 gnus-newsgroup-data)
4341 (gnus-summary-insert-line
4343 mark (memq number gnus-newsgroup-replied)
4344 (memq number gnus-newsgroup-expirable)
4345 (mail-header-subject header) nil
4346 (cdr (assq number gnus-newsgroup-scored))
4347 (memq number gnus-newsgroup-processable))))))
4349 (defun gnus-summary-remove-list-identifiers ()
4350 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4351 (let ((regexp (if (consp gnus-list-identifiers)
4352 (mapconcat 'identity gnus-list-identifiers " *\\|")
4353 gnus-list-identifiers))
4356 (dolist (header gnus-newsgroup-headers)
4357 (setq subject (mail-header-subject header)
4359 (while (string-match
4360 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4363 (concat (substring subject 0 (match-beginning 2))
4364 (substring subject (match-end 0)))
4368 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4370 (concat (substring subject 0 (match-beginning 1))
4371 (substring subject (match-end 1)))))
4373 (mail-header-set-subject header subject))))))
4375 (defun gnus-fetch-headers (articles)
4376 "Fetch headers of ARTICLES."
4377 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4378 (gnus-message 5 "Fetching headers for %s..." name)
4380 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
4381 (if (eq 'nnimap (car (gnus-find-method-for-group name)))
4383 (setq gnus-headers-retrieved-by
4384 (gnus-retrieve-headers
4385 articles gnus-newsgroup-name
4386 ;; We might want to fetch old headers, but
4387 ;; not if there is only 1 article.
4389 (not (eq gnus-fetch-old-headers 'some))
4390 (not (numberp gnus-fetch-old-headers)))
4391 (> (length articles) 1))
4392 gnus-fetch-old-headers))))
4393 (gnus-get-newsgroup-headers-xover
4394 articles nil nil gnus-newsgroup-name t)
4395 (gnus-get-newsgroup-headers))
4396 (gnus-retrieve-parsed-headers
4397 articles gnus-newsgroup-name
4398 ;; We might want to fetch old headers, but
4399 ;; not if there is only 1 article.
4400 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4401 (not (numberp gnus-fetch-old-headers)))
4402 (> (length articles) 1))
4403 gnus-fetch-old-headers)))
4404 (gnus-message 5 "Fetching headers for %s...done" name))))
4406 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4407 "Select newsgroup GROUP.
4408 If READ-ALL is non-nil, all articles in the group are selected.
4409 If SELECT-ARTICLES, only select those articles from GROUP."
4410 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4411 ;;!!! Dirty hack; should be removed.
4412 (gnus-summary-ignore-duplicates
4413 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4415 gnus-summary-ignore-duplicates))
4416 (info (nth 2 entry))
4417 articles fetched-articles cached)
4419 (unless (gnus-check-server
4420 (setq gnus-current-select-method
4421 (gnus-find-method-for-group group)))
4422 (error "Couldn't open server"))
4424 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4425 (gnus-activate-group group) ; Or we can activate it...
4426 (progn ; Or we bug out.
4427 (when (equal major-mode 'gnus-summary-mode)
4428 (kill-buffer (current-buffer)))
4429 (error "Couldn't activate group %s: %s"
4430 group (gnus-status-message group))))
4432 (unless (gnus-request-group group t)
4433 (when (equal major-mode 'gnus-summary-mode)
4434 (kill-buffer (current-buffer)))
4435 (error "Couldn't request group %s: %s"
4436 group (gnus-status-message group)))
4438 (setq gnus-newsgroup-name group)
4439 (setq gnus-newsgroup-unselected nil)
4440 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4441 (gnus-summary-setup-default-charset)
4443 ;; Adjust and set lists of article marks.
4445 (gnus-adjust-marked-articles info))
4447 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4449 (if (gnus-virtual-group-p group)
4450 gnus-newsgroup-cached
4451 (gnus-cache-articles-in-group group)))
4453 (setq gnus-newsgroup-unreads
4454 (gnus-set-difference
4455 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4456 gnus-newsgroup-dormant))
4458 (setq gnus-newsgroup-processable nil)
4460 (gnus-update-read-articles group gnus-newsgroup-unreads)
4462 (if (setq articles select-articles)
4463 (setq gnus-newsgroup-unselected
4464 (gnus-sorted-intersection
4465 gnus-newsgroup-unreads
4466 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4467 (setq articles (gnus-articles-to-read group read-all)))
4471 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4473 ((eq articles 0) nil)
4475 ;; Init the dependencies hash table.
4476 (setq gnus-newsgroup-dependencies
4477 (gnus-make-hashtable (length articles)))
4478 (gnus-set-global-variables)
4479 ;; Retrieve the headers and read them in.
4480 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4482 ;; Suppress duplicates?
4483 (when gnus-suppress-duplicates
4484 (gnus-dup-suppress-articles))
4486 ;; Set the initial limit.
4487 (setq gnus-newsgroup-limit (copy-sequence articles))
4488 ;; Remove canceled articles from the list of unread articles.
4489 (setq gnus-newsgroup-unreads
4490 (gnus-set-sorted-intersection
4491 gnus-newsgroup-unreads
4492 (setq fetched-articles
4493 (mapcar (lambda (headers) (mail-header-number headers))
4494 gnus-newsgroup-headers))))
4495 ;; Removed marked articles that do not exist.
4496 (gnus-update-missing-marks
4497 (gnus-sorted-complement fetched-articles articles))
4499 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4501 (setq gnus-newsgroup-cached cached))
4503 ;; We might want to build some more threads first.
4504 (when (and gnus-fetch-old-headers
4505 (eq gnus-headers-retrieved-by 'nov))
4506 (if (eq gnus-fetch-old-headers 'invisible)
4507 (gnus-build-all-threads)
4508 (gnus-build-old-threads)))
4509 ;; Let the Gnus agent mark articles as read.
4511 (gnus-agent-get-undownloaded-list))
4512 ;; Remove list identifiers from subject
4513 (when gnus-list-identifiers
4514 (gnus-summary-remove-list-identifiers))
4515 ;; Check whether auto-expire is to be done in this group.
4516 (setq gnus-newsgroup-auto-expire
4517 (gnus-group-auto-expirable-p group))
4518 ;; Set up the article buffer now, if necessary.
4519 (unless gnus-single-article-buffer
4520 (gnus-article-setup-buffer))
4521 ;; First and last article in this newsgroup.
4522 (when gnus-newsgroup-headers
4523 (setq gnus-newsgroup-begin
4524 (mail-header-number (car gnus-newsgroup-headers))
4527 (gnus-last-element gnus-newsgroup-headers))))
4528 ;; GROUP is successfully selected.
4529 (or gnus-newsgroup-headers t)))))
4531 (defun gnus-articles-to-read (group &optional read-all)
4532 "Find out what articles the user wants to read."
4534 ;; Select all articles if `read-all' is non-nil, or if there
4535 ;; are no unread articles.
4537 (and (zerop (length gnus-newsgroup-marked))
4538 (zerop (length gnus-newsgroup-unreads)))
4539 (eq (gnus-group-find-parameter group 'display)
4542 (gnus-uncompress-range (gnus-active group))
4543 (gnus-cache-articles-in-group group))
4544 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4545 (copy-sequence gnus-newsgroup-unreads))
4547 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4548 (scored (length scored-list))
4549 (number (length articles))
4550 (marked (+ (length gnus-newsgroup-marked)
4551 (length gnus-newsgroup-dormant)))
4559 ((and (or (<= scored marked) (= scored number))
4560 (natnump gnus-large-newsgroup)
4561 (> number gnus-large-newsgroup))
4562 (let* ((cursor-in-echo-area nil)
4563 (input (read-from-minibuffer
4565 "How many articles from %s (max %d): "
4566 (gnus-limit-string gnus-newsgroup-name 35)
4568 (cons (number-to-string gnus-large-newsgroup)
4570 (if (string-match "^[ \t]*$" input)
4573 ((and (> scored marked) (< scored number)
4574 (> (- scored number) 20))
4577 (format "%s %s (%d scored, %d total): "
4578 "How many articles from"
4579 group scored number))))
4580 (if (string-match "^[ \t]*$" input)
4584 (message "Quit getting the articles to read")
4586 (setq select (if (stringp select) (string-to-number select) select))
4587 (if (or (null select) (zerop select))
4589 (if (and (not (zerop scored)) (<= (abs select) scored))
4591 (setq articles (sort scored-list '<))
4592 (setq number (length articles)))
4593 (setq articles (copy-sequence articles)))
4595 (when (< (abs select) number)
4597 ;; Select the N oldest articles.
4598 (setcdr (nthcdr (1- (abs select)) articles) nil)
4599 ;; Select the N most recent articles.
4600 (setq articles (nthcdr (- number select) articles))))
4601 (setq gnus-newsgroup-unselected
4602 (gnus-sorted-intersection
4603 gnus-newsgroup-unreads
4604 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4605 (when gnus-alter-articles-to-read-function
4606 (setq gnus-newsgroup-unreads
4608 (funcall gnus-alter-articles-to-read-function
4609 gnus-newsgroup-name gnus-newsgroup-unreads)
4613 (defun gnus-killed-articles (killed articles)
4616 (when (inline (gnus-member-of-range (car articles) killed))
4617 (push (car articles) out))
4618 (setq articles (cdr articles)))
4621 (defun gnus-uncompress-marks (marks)
4622 "Uncompress the mark ranges in MARKS."
4623 (let ((uncompressed '(score bookmark))
4626 (if (memq (caar marks) uncompressed)
4627 (push (car marks) out)
4628 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4629 (setq marks (cdr marks)))
4632 (defun gnus-adjust-marked-articles (info)
4633 "Set all article lists and remove all marks that are no longer valid."
4634 (let* ((marked-lists (gnus-info-marks info))
4635 (active (gnus-active (gnus-info-group info)))
4638 (types gnus-article-mark-lists)
4639 (uncompressed '(score bookmark killed))
4640 marks var articles article mark)
4643 (setq marks (pop marked-lists))
4644 (set (setq var (intern (format "gnus-newsgroup-%s"
4645 (car (rassq (setq mark (car marks))
4647 (if (memq (car marks) uncompressed) (cdr marks)
4648 (gnus-uncompress-range (cdr marks))))
4650 (setq articles (symbol-value var))
4652 ;; All articles have to be subsets of the active articles.
4654 ;; Adjust "simple" lists.
4655 ((memq mark '(tick dormant expire reply save))
4657 (when (or (< (setq article (pop articles)) min) (> article max))
4658 (set var (delq article (symbol-value var))))))
4660 ((memq mark uncompressed)
4661 (when (not (listp (cdr (symbol-value var))))
4662 (set var (list (symbol-value var))))
4663 (when (not (listp (cdr articles)))
4664 (setq articles (list articles)))
4666 (when (or (not (consp (setq article (pop articles))))
4667 (< (car article) min)
4668 (> (car article) max))
4669 (set var (delq article (symbol-value var))))))))))
4671 (defun gnus-update-missing-marks (missing)
4672 "Go through the list of MISSING articles and remove them from the mark lists."
4674 (let ((types gnus-article-mark-lists)
4676 ;; Go through all types.
4678 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4679 (when (symbol-value var)
4680 ;; This list has articles. So we delete all missing articles
4684 (set var (delq (pop m) (symbol-value var)))))))))
4686 (defun gnus-update-marks ()
4687 "Enter the various lists of marked articles into the newsgroup info list."
4688 (let ((types gnus-article-mark-lists)
4689 (info (gnus-get-info gnus-newsgroup-name))
4690 (uncompressed '(score bookmark killed))
4691 type list newmarked symbol delta-marks)
4693 ;; Add all marks lists to the list of marks lists.
4694 (while (setq type (pop types))
4695 (setq list (symbol-value
4697 (intern (format "gnus-newsgroup-%s"
4701 ;; Get rid of the entries of the articles that have the
4703 (when (and (eq (cdr type) 'score)
4707 (prev (cons nil list))
4710 (if (or (not (consp (car arts)))
4711 (= (cdar arts) gnus-summary-default-score))
4712 (setcdr prev (cdr arts))
4714 (setq arts (cdr arts)))
4715 (setq list (cdr all)))))
4717 (unless (memq (cdr type) uncompressed)
4718 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4720 (when (gnus-check-backend-function
4721 'request-set-mark gnus-newsgroup-name)
4722 ;; propagate flags to server, with the following exceptions:
4723 ;; uncompressed:s are not proper flags (they are cons cells)
4724 ;; cache is a internal gnus flag
4725 ;; download are local to one gnus installation (well)
4726 ;; unsend are for nndraft groups only
4727 ;; xxx: generality of this? this suits nnimap anyway
4728 (unless (memq (cdr type) (append '(cache download unsend)
4730 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4731 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4732 (add (gnus-remove-from-range
4733 (gnus-copy-sequence list) old)))
4735 (push (list add 'add (list (cdr type))) delta-marks))
4737 (push (list del 'del (list (cdr type))) delta-marks)))))
4740 (push (cons (cdr type) list) newmarked)))
4743 (unless (gnus-check-group gnus-newsgroup-name)
4744 (error "Can't open server for %s" gnus-newsgroup-name))
4745 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4747 ;; Enter these new marks into the info of the group.
4749 (setcar (nthcdr 3 info) newmarked)
4750 ;; Add the marks lists to the end of the info.
4752 (setcdr (nthcdr 2 info) (list newmarked))))
4754 ;; Cut off the end of the info if there's nothing else there.
4758 (when (nthcdr (decf i) info)
4759 (setcdr (nthcdr i info) nil)))))))
4761 (defun gnus-set-mode-line (where)
4762 "Set the mode line of the article or summary buffers.
4763 If WHERE is `summary', the summary mode line format will be used."
4764 ;; Is this mode line one we keep updated?
4765 (when (and (memq where gnus-updated-mode-lines)
4767 (intern (format "gnus-%s-mode-line-format-spec" where))))
4770 ;; We evaluate this in the summary buffer since these
4771 ;; variables are buffer-local to that buffer.
4772 (set-buffer gnus-summary-buffer)
4773 ;; We bind all these variables that are used in the `eval' form
4775 (let* ((mformat (symbol-value
4777 (format "gnus-%s-mode-line-format-spec" where))))
4778 (gnus-tmp-group-name (gnus-group-decoded-name
4779 gnus-newsgroup-name))
4780 (gnus-tmp-article-number (or gnus-current-article 0))
4781 (gnus-tmp-unread gnus-newsgroup-unreads)
4782 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4783 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4784 (gnus-tmp-unread-and-unselected
4785 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4786 (zerop gnus-tmp-unselected))
4788 ((zerop gnus-tmp-unselected)
4789 (format "{%d more}" gnus-tmp-unread-and-unticked))
4790 (t (format "{%d(+%d) more}"
4791 gnus-tmp-unread-and-unticked
4792 gnus-tmp-unselected))))
4794 (if (and gnus-current-headers
4795 (vectorp gnus-current-headers))
4796 (gnus-mode-string-quote
4797 (mail-header-subject gnus-current-headers))
4799 bufname-length max-len
4800 gnus-tmp-header);; passed as argument to any user-format-funcs
4801 (setq mode-string (eval mformat))
4802 (setq bufname-length (if (string-match "%b" mode-string)
4805 (if (eq where 'summary)
4807 (get-buffer gnus-article-buffer))))
4810 (setq max-len (max 4 (if gnus-mode-non-string-length
4812 gnus-mode-non-string-length
4814 (length mode-string))))
4815 ;; We might have to chop a bit of the string off...
4816 (when (> (length mode-string) max-len)
4818 (concat (gnus-truncate-string mode-string (- max-len 3))
4820 ;; Pad the mode string a bit.
4821 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4822 ;; Update the mode line.
4823 (setq mode-line-buffer-identification
4824 (gnus-mode-line-buffer-identification (list mode-string)))
4825 (set-buffer-modified-p t))))
4827 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4828 "Go through the HEADERS list and add all Xrefs to a hash table.
4829 The resulting hash table is returned, or nil if no Xrefs were found."
4830 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4831 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4832 (xref-hashtb (gnus-make-hashtable))
4833 start group entry number xrefs header)
4835 (setq header (pop headers))
4836 (when (and (setq xrefs (mail-header-xref header))
4837 (not (memq (setq number (mail-header-number header))
4840 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4841 (setq start (match-end 0))
4842 (setq group (if prefix
4843 (concat prefix (substring xrefs (match-beginning 1)
4845 (substring xrefs (match-beginning 1) (match-end 1))))
4847 (string-to-int (substring xrefs (match-beginning 2)
4849 (if (setq entry (gnus-gethash group xref-hashtb))
4850 (setcdr entry (cons number (cdr entry)))
4851 (gnus-sethash group (cons number nil) xref-hashtb)))))
4852 (and start xref-hashtb)))
4854 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4855 "Look through all the headers and mark the Xrefs as read."
4856 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4857 name entry info xref-hashtb idlist method nth4)
4859 (set-buffer gnus-group-buffer)
4860 (when (setq xref-hashtb
4861 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4864 (unless (string= from-newsgroup (setq name (symbol-name group)))
4865 (setq idlist (symbol-value group))
4866 ;; Dead groups are not updated.
4868 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4870 (when (stringp (setq nth4 (gnus-info-method info)))
4871 (setq nth4 (gnus-server-to-method nth4))))
4872 ;; Only do the xrefs if the group has the same
4873 ;; select method as the group we have just read.
4874 (or (gnus-methods-equal-p
4875 nth4 (gnus-find-method-for-group from-newsgroup))
4877 (equal nth4 (setq method (gnus-find-method-for-group
4879 (and (equal (car nth4) (car method))
4880 (equal (nth 1 nth4) (nth 1 method))))
4881 gnus-use-cross-reference
4882 (or (not (eq gnus-use-cross-reference t))
4884 ;; Only do cross-references on subscribed
4885 ;; groups, if that is what is wanted.
4886 (<= (gnus-info-level info) gnus-level-subscribed))
4887 (gnus-group-make-articles-read name idlist))))
4890 (defun gnus-compute-read-articles (group articles)
4891 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4892 (info (nth 2 entry))
4893 (active (gnus-active group))
4896 ;; First peel off all invalid article numbers.
4898 (let ((ids articles)
4900 (while (setq id (pop ids))
4901 (when (and first (> id (cdr active)))
4902 ;; We'll end up in this situation in one particular
4903 ;; obscure situation. If you re-scan a group and get
4904 ;; a new article that is cross-posted to a different
4905 ;; group that has not been re-scanned, you might get
4906 ;; crossposted article that has a higher number than
4907 ;; Gnus believes possible. So we re-activate this
4908 ;; group as well. This might mean doing the
4909 ;; crossposting thingy will *increase* the number
4910 ;; of articles in some groups. Tsk, tsk.
4911 (setq active (or (gnus-activate-group group) active)))
4912 (when (or (> id (cdr active))
4913 (< id (car active)))
4914 (setq articles (delq id articles))))))
4915 ;; If the read list is nil, we init it.
4917 (null (gnus-info-read info))
4919 (setq ninfo (cons 1 (1- (car active))))
4920 (setq ninfo (gnus-info-read info)))
4921 ;; Then we add the read articles to the range.
4923 ninfo (setq articles (sort articles '<))))))
4925 (defun gnus-group-make-articles-read (group articles)
4926 "Update the info of GROUP to say that ARTICLES are read."
4928 (entry (gnus-gethash group gnus-newsrc-hashtb))
4929 (info (nth 2 entry))
4930 (active (gnus-active group))
4933 (setq range (gnus-compute-read-articles group articles))
4935 (set-buffer gnus-group-buffer)
4938 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4939 (gnus-info-set-read ',info ',(gnus-info-read info))
4940 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4941 (gnus-group-update-group ,group t))))
4942 ;; Add the read articles to the range.
4943 (gnus-info-set-read info range)
4944 ;; Then we have to re-compute how many unread
4945 ;; articles there are in this group.
4949 (setq num (- (1+ (cdr active)) (car active))))
4950 ((not (listp (cdr range)))
4951 (setq num (- (cdr active) (- (1+ (cdr range))
4955 (if (numberp (car range))
4957 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4958 (setq range (cdr range)))
4959 (setq num (- (cdr active) num))))
4960 ;; Update the number of unread articles.
4962 ;; Update the group buffer.
4963 (gnus-group-update-group group t)))))
4965 (defvar gnus-newsgroup-none-id 0)
4967 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4968 (let ((cur nntp-server-buffer)
4971 (save-excursion (set-buffer gnus-summary-buffer)
4972 gnus-newsgroup-dependencies)))
4974 (mail-parse-charset gnus-newsgroup-charset)
4975 (mail-parse-ignored-charsets
4976 (save-excursion (condition-case nil
4977 (set-buffer gnus-summary-buffer)
4979 gnus-newsgroup-ignored-charsets)))
4981 (set-buffer nntp-server-buffer)
4982 ;; Translate all TAB characters into SPACE characters.
4983 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4984 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4985 (gnus-run-hooks 'gnus-parse-headers-hook)
4986 (let ((case-fold-search t)
4987 in-reply-to header p lines chars ctype)
4988 (goto-char (point-min))
4989 ;; Search to the beginning of the next header. Error messages
4990 ;; do not begin with 2 or 3.
4991 (while (re-search-forward "^[23][0-9]+ " nil t)
4994 ;; This implementation of this function, with nine
4995 ;; search-forwards instead of the one re-search-forward and
4996 ;; a case (which basically was the old function) is actually
4997 ;; about twice as fast, even though it looks messier. You
4998 ;; can't have everything, I guess. Speed and elegance
4999 ;; doesn't always go hand in hand.
5002 (make-full-mail-header
5008 (narrow-to-region (point)
5009 (or (and (search-forward "\n.\n" nil t)
5015 (if (search-forward "\nsubject: " nil t)
5016 (nnheader-header-value)
5021 (if (or (search-forward "\nfrom: " nil t)
5022 (search-forward "\nfrom:" nil t))
5023 (nnheader-header-value)
5028 (if (search-forward "\ndate: " nil t)
5029 (nnheader-header-value)
5034 (setq id (if (re-search-forward
5035 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5036 ;; We do it this way to make sure the Message-ID
5037 ;; is (somewhat) syntactically valid.
5038 (buffer-substring (match-beginning 1)
5040 ;; If there was no message-id, we just fake one
5041 ;; to make subsequent routines simpler.
5042 (nnheader-generate-fake-message-id))))
5046 (if (search-forward "\nreferences: " nil t)
5050 (nnheader-header-value)
5055 (search-backward ">" end t)
5058 (search-backward "<" end t)
5060 ;; Get the references from the in-reply-to header if there
5061 ;; were no references and the in-reply-to header looks
5063 (if (and (search-forward "\nin-reply-to: " nil t)
5064 (setq in-reply-to (nnheader-header-value))
5065 (string-match "<[^>]+>" in-reply-to))
5067 (setq ref (substring in-reply-to (match-beginning 0)
5069 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5070 (setq ref2 (substring in-reply-to (match-beginning 0)
5072 (when (> (length ref2) (length ref))
5079 (if (search-forward "\nchars: " nil t)
5080 (if (numberp (setq chars (ignore-errors (read cur))))
5086 (if (search-forward "\nlines: " nil t)
5087 (if (numberp (setq lines (ignore-errors (read cur))))
5093 (and (search-forward "\nxref: " nil t)
5094 (nnheader-header-value)))
5096 (when gnus-extra-headers
5097 (let ((extra gnus-extra-headers)
5101 (when (search-forward
5102 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5103 (push (cons (car extra) (nnheader-header-value)) out))
5107 (if (and (search-forward "\ncontent-type: " nil t)
5108 (setq ctype (nnheader-header-value)))
5109 (mime-entity-set-content-type-internal
5110 header (mime-parse-Content-Type ctype)))
5111 (when (equal id ref)
5114 (when gnus-alter-header-function
5115 (funcall gnus-alter-header-function header)
5116 (setq id (mail-header-id header)
5117 ref (gnus-parent-id (mail-header-references header))))
5120 (gnus-dependencies-add-header
5121 header dependencies force-new))
5122 (push header headers))
5123 (goto-char (point-max))
5125 (nreverse headers)))))
5127 ;; Goes through the xover lines and returns a list of vectors
5128 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5129 force-new dependencies
5130 group also-fetch-heads)
5131 "Parse the news overview data in the server buffer.
5132 Return a list of headers that match SEQUENCE (see
5133 `nntp-retrieve-headers')."
5134 ;; Get the Xref when the users reads the articles since most/some
5135 ;; NNTP servers do not include Xrefs when using XOVER.
5136 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5137 (let ((mail-parse-charset gnus-newsgroup-charset)
5138 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5139 (cur nntp-server-buffer)
5140 (dependencies (or dependencies gnus-newsgroup-dependencies))
5141 number headers header)
5143 (set-buffer nntp-server-buffer)
5144 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5145 ;; Allow the user to mangle the headers before parsing them.
5146 (gnus-run-hooks 'gnus-parse-headers-hook)
5147 (goto-char (point-min))
5150 (while (and sequence (not (eobp)))
5151 (setq number (read cur))
5152 (while (and sequence
5153 (< (car sequence) number))
5154 (setq sequence (cdr sequence)))
5156 (eq number (car sequence))
5158 (setq sequence (cdr sequence))
5159 (setq header (inline
5160 (gnus-nov-parse-line
5161 number dependencies force-new))))
5162 (push header headers))
5165 (gnus-error 4 "Strange nov line (%d)"
5166 (count-lines (point-min) (point)))))
5168 ;; A common bug in inn is that if you have posted an article and
5169 ;; then retrieves the active file, it will answer correctly --
5170 ;; the new article is included. However, a NOV entry for the
5171 ;; article may not have been generated yet, so this may fail.
5172 ;; We work around this problem by retrieving the last few
5173 ;; headers using HEAD.
5174 (if (or (not also-fetch-heads)
5176 ;; We (probably) got all the headers.
5178 (let ((gnus-nov-is-evil t))
5181 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
5182 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
5183 (when (gnus-retrieve-headers sequence group)
5184 (gnus-get-newsgroup-headers))
5185 (gnus-retrieve-parsed-headers sequence group))))))))
5187 (defun gnus-article-get-xrefs ()
5188 "Fill in the Xref value in `gnus-current-headers', if necessary.
5189 This is meant to be called in `gnus-article-internal-prepare-hook'."
5190 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5191 gnus-current-headers)))
5192 (or (not gnus-use-cross-reference)
5194 (and (mail-header-xref headers)
5195 (not (string= (mail-header-xref headers) "")))
5196 (let ((case-fold-search t)
5199 (nnheader-narrow-to-headers)
5200 (goto-char (point-min))
5201 (when (or (and (not (eobp))
5202 (eq (downcase (char-after)) ?x)
5203 (looking-at "Xref:"))
5204 (search-forward "\nXref:" nil t))
5205 (goto-char (1+ (match-end 0)))
5206 (setq xref (buffer-substring (point)
5207 (progn (end-of-line) (point))))
5208 (mail-header-set-xref headers xref)))))))
5210 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5211 "Find article ID and insert the summary line for that article.
5212 OLD-HEADER can either be a header or a line number to insert
5213 the subject line on."
5214 (let* ((line (and (numberp old-header) old-header))
5215 (old-header (and (vectorp old-header) old-header))
5216 (header (cond ((and old-header use-old-header)
5219 (gnus-number-to-header id))
5220 (gnus-number-to-header id))
5222 (gnus-read-header id))))
5223 (number (and (numberp id) id))
5226 ;; Rebuild the thread that this article is part of and go to the
5227 ;; article we have fetched.
5228 (when (and (not gnus-show-threads)
5231 (setq d (gnus-data-find (mail-header-number old-header))))
5232 (goto-char (gnus-data-pos d))
5235 (- (gnus-point-at-bol)
5237 (1+ (gnus-point-at-eol))
5238 (gnus-delete-line))))))
5240 (mail-header-set-number header (mail-header-number old-header)))
5241 (setq gnus-newsgroup-sparse
5242 (delq (setq number (mail-header-number header))
5243 gnus-newsgroup-sparse))
5244 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5245 (push number gnus-newsgroup-limit)
5246 (gnus-rebuild-thread (mail-header-id header) line)
5247 (gnus-summary-goto-subject number nil t))
5248 (when (and (numberp number)
5250 ;; We have to update the boundaries even if we can't fetch the
5251 ;; article if ID is a number -- so that the next `P' or `N'
5252 ;; command will fetch the previous (or next) article even
5253 ;; if the one we tried to fetch this time has been canceled.
5254 (when (> number gnus-newsgroup-end)
5255 (setq gnus-newsgroup-end number))
5256 (when (< number gnus-newsgroup-begin)
5257 (setq gnus-newsgroup-begin number))
5258 (setq gnus-newsgroup-unselected
5259 (delq number gnus-newsgroup-unselected)))
5260 ;; Report back a success?
5261 (and header (mail-header-number header))))
5263 ;;; Process/prefix in the summary buffer
5265 (defun gnus-summary-work-articles (n)
5266 "Return a list of articles to be worked upon.
5267 The prefix argument, the list of process marked articles, and the
5268 current article will be taken into consideration."
5270 (set-buffer gnus-summary-buffer)
5273 ;; A numerical prefix has been given.
5274 (setq n (prefix-numeric-value n))
5275 (let ((backward (< n 0))
5276 (n (abs (prefix-numeric-value n)))
5281 (push (setq article (gnus-summary-article-number))
5284 (gnus-summary-find-prev nil article)
5285 (gnus-summary-find-next nil article)))
5287 (nreverse articles)))
5288 ((and (gnus-region-active-p) (mark))
5289 (message "region active")
5290 ;; Work on the region between point and mark.
5291 (let ((max (max (point) (mark)))
5294 (goto-char (min (point) (mark)))
5297 (push (setq article (gnus-summary-article-number)) articles)
5298 (gnus-summary-find-next nil article)
5300 (nreverse articles))))
5301 (gnus-newsgroup-processable
5302 ;; There are process-marked articles present.
5303 ;; Save current state.
5304 (gnus-summary-save-process-mark)
5306 (reverse gnus-newsgroup-processable))
5308 ;; Just return the current article.
5309 (list (gnus-summary-article-number))))))
5311 (defmacro gnus-summary-iterate (arg &rest forms)
5312 "Iterate over the process/prefixed articles and do FORMS.
5313 ARG is the interactive prefix given to the command. FORMS will be
5314 executed with point over the summary line of the articles."
5315 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5316 `(let ((,articles (gnus-summary-work-articles ,arg)))
5318 (gnus-summary-goto-subject (car ,articles))
5322 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5323 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5325 (defun gnus-summary-save-process-mark ()
5326 "Push the current set of process marked articles on the stack."
5328 (push (copy-sequence gnus-newsgroup-processable)
5329 gnus-newsgroup-process-stack))
5331 (defun gnus-summary-kill-process-mark ()
5332 "Push the current set of process marked articles on the stack and unmark."
5334 (gnus-summary-save-process-mark)
5335 (gnus-summary-unmark-all-processable))
5337 (defun gnus-summary-yank-process-mark ()
5338 "Pop the last process mark state off the stack and restore it."
5340 (unless gnus-newsgroup-process-stack
5341 (error "Empty mark stack"))
5342 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5344 (defun gnus-summary-process-mark-set (set)
5345 "Make SET into the current process marked articles."
5346 (gnus-summary-unmark-all-processable)
5348 (gnus-summary-set-process-mark (pop set))))
5350 ;;; Searching and stuff
5352 (defun gnus-summary-search-group (&optional backward use-level)
5353 "Search for next unread newsgroup.
5354 If optional argument BACKWARD is non-nil, search backward instead."
5356 (set-buffer gnus-group-buffer)
5357 (when (gnus-group-search-forward
5358 backward nil (if use-level (gnus-group-group-level) nil))
5359 (gnus-group-group-name))))
5361 (defun gnus-summary-best-group (&optional exclude-group)
5362 "Find the name of the best unread group.
5363 If EXCLUDE-GROUP, do not go to this group."
5365 (set-buffer gnus-group-buffer)
5367 (gnus-group-best-unread-group exclude-group))))
5369 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5370 (if backward (gnus-summary-find-prev)
5371 (let* ((dummy (gnus-summary-article-intangible-p))
5372 (article (or article (gnus-summary-article-number)))
5373 (arts (gnus-data-find-list article))
5375 (when (and (not dummy)
5376 (or (not gnus-summary-check-current)
5378 (not (gnus-data-unread-p (car arts)))))
5379 (setq arts (cdr arts)))
5384 (when (or (and undownloaded
5385 (eq gnus-undownloaded-mark
5386 (gnus-data-mark (car arts))))
5387 (gnus-data-unread-p (car arts)))
5388 (setq result (car arts)
5390 (setq arts (cdr arts)))
5393 (goto-char (gnus-data-pos result))
5394 (gnus-data-number result)))))
5396 (defun gnus-summary-find-prev (&optional unread article)
5397 (let* ((eobp (eobp))
5398 (article (or article (gnus-summary-article-number)))
5399 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5401 (when (and (not eobp)
5402 (or (not gnus-summary-check-current)
5404 (not (gnus-data-unread-p (car arts)))))
5405 (setq arts (cdr arts)))
5410 (when (gnus-data-unread-p (car arts))
5411 (setq result (car arts)
5413 (setq arts (cdr arts)))
5416 (goto-char (gnus-data-pos result))
5417 (gnus-data-number result))))
5419 (defun gnus-summary-find-subject (subject &optional unread backward article)
5420 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5421 (article (or article (gnus-summary-article-number)))
5422 (articles (gnus-data-list backward))
5423 (arts (gnus-data-find-list article articles))
5425 (when (or (not gnus-summary-check-current)
5427 (not (gnus-data-unread-p (car arts))))
5428 (setq arts (cdr arts)))
5430 (and (or (not unread)
5431 (gnus-data-unread-p (car arts)))
5432 (vectorp (gnus-data-header (car arts)))
5434 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5435 (setq result (car arts)
5437 (setq arts (cdr arts)))
5439 (goto-char (gnus-data-pos result))
5440 (gnus-data-number result))))
5442 (defun gnus-summary-search-forward (&optional unread subject backward)
5443 "Search forward for an article.
5444 If UNREAD, look for unread articles. If SUBJECT, look for
5445 articles with that subject. If BACKWARD, search backward instead."
5446 (cond (subject (gnus-summary-find-subject subject unread backward))
5447 (backward (gnus-summary-find-prev unread))
5448 (t (gnus-summary-find-next unread))))
5450 (defun gnus-recenter (&optional n)
5451 "Center point in window and redisplay frame.
5452 Also do horizontal recentering."
5454 (when (and gnus-auto-center-summary
5455 (not (eq gnus-auto-center-summary 'vertical)))
5456 (gnus-horizontal-recenter))
5459 (defun gnus-summary-recenter ()
5460 "Center point in the summary window.
5461 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5462 displayed, no centering will be performed."
5463 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5464 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5466 (let* ((top (cond ((< (window-height) 4) 0)
5467 ((< (window-height) 7) 1)
5468 (t (if (numberp gnus-auto-center-summary)
5469 gnus-auto-center-summary
5471 (height (1- (window-height)))
5472 (bottom (save-excursion (goto-char (point-max))
5473 (forward-line (- height))
5475 (window (get-buffer-window (current-buffer))))
5476 ;; The user has to want it.
5477 (when gnus-auto-center-summary
5478 (when (get-buffer-window gnus-article-buffer)
5479 ;; Only do recentering when the article buffer is displayed,
5480 ;; Set the window start to either `bottom', which is the biggest
5481 ;; possible valid number, or the second line from the top,
5482 ;; whichever is the least.
5483 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5484 (if (> bottom top-pos)
5485 ;; Keep the second line from the top visible
5486 (set-window-start window top-pos t)
5487 ;; Try to keep the bottom line visible; if it's partially
5488 ;; obscured, either scroll one more line to make it fully
5489 ;; visible, or revert to using TOP-POS.
5491 (goto-char (point-max))
5493 (let ((last-line-start (point)))
5495 (set-window-start window (point) t)
5496 (when (not (pos-visible-in-window-p last-line-start window))
5498 (set-window-start window (min (point) top-pos) t)))))))
5499 ;; Do horizontal recentering while we're at it.
5500 (when (and (get-buffer-window (current-buffer) t)
5501 (not (eq gnus-auto-center-summary 'vertical)))
5502 (let ((selected (selected-window)))
5503 (select-window (get-buffer-window (current-buffer) t))
5504 (gnus-summary-position-point)
5505 (gnus-horizontal-recenter)
5506 (select-window selected))))))
5508 (defun gnus-summary-jump-to-group (newsgroup)
5509 "Move point to NEWSGROUP in group mode buffer."
5510 ;; Keep update point of group mode buffer if visible.
5511 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5512 (save-window-excursion
5513 ;; Take care of tree window mode.
5514 (when (get-buffer-window gnus-group-buffer)
5515 (pop-to-buffer gnus-group-buffer))
5516 (gnus-group-jump-to-group newsgroup))
5518 ;; Take care of tree window mode.
5519 (if (get-buffer-window gnus-group-buffer)
5520 (pop-to-buffer gnus-group-buffer)
5521 (set-buffer gnus-group-buffer))
5522 (gnus-group-jump-to-group newsgroup))))
5524 ;; This function returns a list of article numbers based on the
5525 ;; difference between the ranges of read articles in this group and
5526 ;; the range of active articles.
5527 (defun gnus-list-of-unread-articles (group)
5528 (let* ((read (gnus-info-read (gnus-get-info group)))
5529 (active (or (gnus-active group) (gnus-activate-group group)))
5532 ;; If none are read, then all are unread.
5534 (setq first (car active))
5535 ;; If the range of read articles is a single range, then the
5536 ;; first unread article is the article after the last read
5537 ;; article. Sounds logical, doesn't it?
5538 (if (and (not (listp (cdr read)))
5539 (or (< (car read) (car active))
5540 (progn (setq read (list read))
5542 (setq first (max (car active) (1+ (cdr read))))
5543 ;; `read' is a list of ranges.
5544 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5547 (setq first (car active)))
5550 (while (< first nlast)
5552 (setq first (1+ first))))
5553 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5554 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5555 (setq read (cdr read)))))
5556 ;; And add the last unread articles.
5557 (while (<= first last)
5559 (setq first (1+ first)))
5560 ;; Return the list of unread articles.
5561 (delq 0 (nreverse unread))))
5563 (defun gnus-list-of-read-articles (group)
5564 "Return a list of unread, unticked and non-dormant articles."
5565 (let* ((info (gnus-get-info group))
5566 (marked (gnus-info-marks info))
5567 (active (gnus-active group)))
5569 (gnus-set-difference
5570 (gnus-sorted-complement
5571 (gnus-uncompress-range active)
5572 (gnus-list-of-unread-articles group))
5574 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5575 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5577 ;; Various summary commands
5579 (defun gnus-summary-select-article-buffer ()
5580 "Reconfigure windows to show article buffer."
5582 (if (not (gnus-buffer-live-p gnus-article-buffer))
5583 (error "There is no article buffer for this summary buffer")
5584 (gnus-configure-windows 'article)
5585 (select-window (get-buffer-window gnus-article-buffer))))
5587 (defun gnus-summary-universal-argument (arg)
5588 "Perform any operation on all articles that are process/prefixed."
5590 (let ((articles (gnus-summary-work-articles arg))
5597 (substitute-command-keys
5598 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5600 (gnus-error 1 "Undefined key")
5603 (gnus-summary-goto-subject (setq article (pop articles)))
5604 (let (gnus-newsgroup-processable)
5605 (command-execute func))
5606 (gnus-summary-remove-process-mark article)))))
5607 (gnus-summary-position-point))
5609 (defun gnus-summary-toggle-truncation (&optional arg)
5610 "Toggle truncation of summary lines.
5611 With arg, turn line truncation on iff arg is positive."
5613 (setq truncate-lines
5614 (if (null arg) (not truncate-lines)
5615 (> (prefix-numeric-value arg) 0)))
5618 (defun gnus-summary-reselect-current-group (&optional all rescan)
5619 "Exit and then reselect the current newsgroup.
5620 The prefix argument ALL means to select all articles."
5622 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5623 (error "Ephemeral groups can't be reselected"))
5624 (let ((current-subject (gnus-summary-article-number))
5625 (group gnus-newsgroup-name))
5626 (setq gnus-newsgroup-begin nil)
5628 ;; We have to adjust the point of group mode buffer because
5629 ;; point was moved to the next unread newsgroup by exiting.
5630 (gnus-summary-jump-to-group group)
5633 (save-window-excursion
5634 ;; Don't show group contents.
5635 (set-window-start (selected-window) (point-max))
5636 (gnus-group-get-new-news-this-group 1))))
5637 (gnus-group-read-group all t)
5638 (gnus-summary-goto-subject current-subject nil t)))
5640 (defun gnus-summary-rescan-group (&optional all)
5641 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5643 (gnus-summary-reselect-current-group all t))
5645 (defun gnus-summary-update-info (&optional non-destructive)
5647 (let ((group gnus-newsgroup-name))
5649 (when gnus-newsgroup-kill-headers
5650 (setq gnus-newsgroup-killed
5651 (gnus-compress-sequence
5653 (gnus-set-sorted-intersection
5654 (gnus-uncompress-range gnus-newsgroup-killed)
5655 (setq gnus-newsgroup-unselected
5656 (sort gnus-newsgroup-unselected '<)))
5657 (setq gnus-newsgroup-unreads
5658 (sort gnus-newsgroup-unreads '<)))
5660 (unless (listp (cdr gnus-newsgroup-killed))
5661 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5662 (let ((headers gnus-newsgroup-headers))
5663 ;; Set the new ranges of read articles.
5665 (set-buffer gnus-group-buffer)
5666 (gnus-undo-force-boundary))
5667 (gnus-update-read-articles
5668 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5669 ;; Set the current article marks.
5670 (let ((gnus-newsgroup-scored
5671 (if (and (not gnus-save-score)
5672 (not non-destructive))
5674 gnus-newsgroup-scored)))
5676 (gnus-update-marks)))
5677 ;; Do the cross-ref thing.
5678 (when gnus-use-cross-reference
5679 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5680 ;; Do not switch windows but change the buffer to work.
5681 (set-buffer gnus-group-buffer)
5682 (unless (gnus-ephemeral-group-p group)
5683 (gnus-group-update-group group)))))))
5685 (defun gnus-summary-save-newsrc (&optional force)
5686 "Save the current number of read/marked articles in the dribble buffer.
5687 The dribble buffer will then be saved.
5688 If FORCE (the prefix), also save the .newsrc file(s)."
5690 (gnus-summary-update-info t)
5692 (gnus-save-newsrc-file)
5693 (gnus-dribble-save)))
5695 (defun gnus-summary-exit (&optional temporary)
5696 "Exit reading current newsgroup, and then return to group selection mode.
5697 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5699 (gnus-set-global-variables)
5700 (gnus-kill-save-kill-buffer)
5701 (gnus-async-halt-prefetch)
5702 (let* ((group gnus-newsgroup-name)
5703 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5706 (buf (current-buffer)))
5708 ;; Do adaptive scoring, and possibly save score files.
5709 (when gnus-newsgroup-adaptive
5710 (gnus-score-adaptive))
5711 (when gnus-use-scoring
5713 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5714 ;; If we have several article buffers, we kill them at exit.
5715 (unless gnus-single-article-buffer
5716 (gnus-kill-buffer gnus-original-article-buffer)
5717 (setq gnus-article-current nil))
5718 (when gnus-use-cache
5719 (gnus-cache-possibly-remove-articles)
5720 (gnus-cache-save-buffers))
5721 (gnus-async-prefetch-remove-group group)
5722 (when gnus-suppress-duplicates
5723 (gnus-dup-enter-articles))
5724 (when gnus-use-trees
5725 (gnus-tree-close group))
5726 (when gnus-use-cache
5727 (gnus-cache-write-active))
5728 ;; Remove entries for this group.
5729 (nnmail-purge-split-history (gnus-group-real-name group))
5730 ;; Make all changes in this group permanent.
5732 (gnus-run-hooks 'gnus-exit-group-hook)
5733 (gnus-summary-update-info))
5734 (gnus-close-group group)
5735 ;; Make sure where we were, and go to next newsgroup.
5736 (set-buffer gnus-group-buffer)
5738 (gnus-group-jump-to-group group))
5739 (gnus-run-hooks 'gnus-summary-exit-hook)
5740 (unless (or quit-config
5741 ;; If this group has disappeared from the summary
5742 ;; buffer, don't skip forwards.
5743 (not (string= group (gnus-group-group-name))))
5744 (gnus-group-next-unread-group 1))
5745 (setq group-point (point))
5748 ;; If we have several article buffers, we kill them at exit.
5749 (unless gnus-single-article-buffer
5750 (gnus-kill-buffer gnus-article-buffer)
5751 (gnus-kill-buffer gnus-original-article-buffer)
5752 (setq gnus-article-current nil))
5754 (if (not gnus-kill-summary-on-exit)
5756 (gnus-deaden-summary)
5758 ;; We set all buffer-local variables to nil. It is unclear why
5759 ;; this is needed, but if we don't, buffer-local variables are
5760 ;; not garbage-collected, it seems. This would the lead to en
5761 ;; ever-growing Emacs.
5762 (gnus-summary-clear-local-variables)
5763 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5764 (gnus-summary-clear-local-variables))
5765 (when (get-buffer gnus-article-buffer)
5766 (bury-buffer gnus-article-buffer))
5767 ;; We clear the global counterparts of the buffer-local
5768 ;; variables as well, just to be on the safe side.
5769 (set-buffer gnus-group-buffer)
5770 (gnus-summary-clear-local-variables)
5771 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5772 (gnus-summary-clear-local-variables)))
5773 (setq gnus-current-select-method gnus-select-method)
5774 (pop-to-buffer gnus-group-buffer)
5775 (if (not quit-config)
5777 (goto-char group-point)
5778 (gnus-configure-windows 'group 'force)
5779 (unless (pos-visible-in-window-p)
5780 (forward-line (/ (static-if (featurep 'xemacs)
5781 (window-displayed-height)
5782 (1- (window-height)))
5784 (set-window-start (selected-window) (point))
5785 (goto-char group-point)))
5786 (gnus-handle-ephemeral-exit quit-config))
5787 ;; Return to group mode buffer.
5788 (when (eq mode 'gnus-summary-mode)
5789 (gnus-kill-buffer buf))
5790 ;; Clear the current group name.
5792 (setq gnus-newsgroup-name nil)))))
5794 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5795 (defun gnus-summary-exit-no-update (&optional no-questions)
5796 "Quit reading current newsgroup without updating read article info."
5798 (let* ((group gnus-newsgroup-name)
5799 (quit-config (gnus-group-quit-config group)))
5800 (when (or no-questions
5802 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5803 (gnus-async-halt-prefetch)
5805 (delq 'gnus-summary-expire-articles
5806 (copy-sequence gnus-summary-prepare-exit-hook)))
5807 ;; If we have several article buffers, we kill them at exit.
5808 (unless gnus-single-article-buffer
5809 (gnus-kill-buffer gnus-article-buffer)
5810 (gnus-kill-buffer gnus-original-article-buffer)
5811 (setq gnus-article-current nil))
5812 (if (not gnus-kill-summary-on-exit)
5813 (gnus-deaden-summary)
5814 (gnus-close-group group)
5815 (gnus-summary-clear-local-variables)
5816 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5817 (gnus-summary-clear-local-variables))
5818 (set-buffer gnus-group-buffer)
5819 (gnus-summary-clear-local-variables)
5820 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5821 (gnus-summary-clear-local-variables))
5822 (when (get-buffer gnus-summary-buffer)
5823 (kill-buffer gnus-summary-buffer)))
5824 (unless gnus-single-article-buffer
5825 (setq gnus-article-current nil))
5826 (when gnus-use-trees
5827 (gnus-tree-close group))
5828 (gnus-async-prefetch-remove-group group)
5829 (when (get-buffer gnus-article-buffer)
5830 (bury-buffer gnus-article-buffer))
5831 ;; Return to the group buffer.
5832 (gnus-configure-windows 'group 'force)
5833 ;; Clear the current group name.
5834 (setq gnus-newsgroup-name nil)
5835 (when (equal (gnus-group-group-name) group)
5836 (gnus-group-next-unread-group 1))
5838 (gnus-handle-ephemeral-exit quit-config)))))
5840 (defun gnus-handle-ephemeral-exit (quit-config)
5841 "Handle movement when leaving an ephemeral group.
5842 The state which existed when entering the ephemeral is reset."
5843 (if (not (buffer-name (car quit-config)))
5844 (gnus-configure-windows 'group 'force)
5845 (set-buffer (car quit-config))
5846 (cond ((eq major-mode 'gnus-summary-mode)
5847 (gnus-set-global-variables))
5848 ((eq major-mode 'gnus-article-mode)
5850 ;; The `gnus-summary-buffer' variable may point
5851 ;; to the old summary buffer when using a single
5853 (unless (gnus-buffer-live-p gnus-summary-buffer)
5854 (set-buffer gnus-group-buffer))
5855 (set-buffer gnus-summary-buffer)
5856 (gnus-set-global-variables))))
5857 (if (or (eq (cdr quit-config) 'article)
5858 (eq (cdr quit-config) 'pick))
5860 ;; The current article may be from the ephemeral group
5861 ;; thus it is best that we reload this article
5862 (gnus-summary-show-article)
5863 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5864 (gnus-configure-windows 'pick 'force)
5865 (gnus-configure-windows (cdr quit-config) 'force)))
5866 (gnus-configure-windows (cdr quit-config) 'force))
5867 (when (eq major-mode 'gnus-summary-mode)
5868 (gnus-summary-next-subject 1 nil t)
5869 (gnus-summary-recenter)
5870 (gnus-summary-position-point))))
5872 (defun gnus-summary-preview-mime-message ()
5873 "MIME decode and play this message."
5875 (let ((gnus-break-pages nil)
5877 (gnus-summary-select-article gnus-show-all-headers t))
5878 (select-window (get-buffer-window gnus-article-buffer)))
5882 (defvar gnus-dead-summary-mode-map nil)
5884 (unless gnus-dead-summary-mode-map
5885 (setq gnus-dead-summary-mode-map (make-keymap))
5886 (suppress-keymap gnus-dead-summary-mode-map)
5887 (substitute-key-definition
5888 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5889 (let ((keys '("\C-d" "\r" "\177" [delete])))
5891 (define-key gnus-dead-summary-mode-map
5892 (pop keys) 'gnus-summary-wake-up-the-dead))))
5894 (defvar gnus-dead-summary-mode nil
5895 "Minor mode for Gnus summary buffers.")
5897 (defun gnus-dead-summary-mode (&optional arg)
5898 "Minor mode for Gnus summary buffers."
5900 (when (eq major-mode 'gnus-summary-mode)
5901 (make-local-variable 'gnus-dead-summary-mode)
5902 (setq gnus-dead-summary-mode
5903 (if (null arg) (not gnus-dead-summary-mode)
5904 (> (prefix-numeric-value arg) 0)))
5905 (when gnus-dead-summary-mode
5906 (gnus-add-minor-mode
5907 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5909 (defun gnus-deaden-summary ()
5910 "Make the current summary buffer into a dead summary buffer."
5911 ;; Kill any previous dead summary buffer.
5912 (when (and gnus-dead-summary
5913 (buffer-name gnus-dead-summary))
5915 (set-buffer gnus-dead-summary)
5916 (when gnus-dead-summary-mode
5917 (kill-buffer (current-buffer)))))
5918 ;; Make this the current dead summary.
5919 (setq gnus-dead-summary (current-buffer))
5920 (gnus-dead-summary-mode 1)
5921 (let ((name (buffer-name)))
5922 (when (string-match "Summary" name)
5924 (concat (substring name 0 (match-beginning 0)) "Dead "
5925 (substring name (match-beginning 0)))
5929 (defun gnus-kill-or-deaden-summary (buffer)
5930 "Kill or deaden the summary BUFFER."
5932 (when (and (buffer-name buffer)
5933 (not gnus-single-article-buffer))
5936 (gnus-kill-buffer gnus-article-buffer)
5937 (gnus-kill-buffer gnus-original-article-buffer)))
5938 (cond (gnus-kill-summary-on-exit
5939 (when (and gnus-use-trees
5940 (gnus-buffer-exists-p buffer))
5943 (gnus-tree-close gnus-newsgroup-name)))
5944 (gnus-kill-buffer buffer))
5945 ((gnus-buffer-exists-p buffer)
5948 (gnus-deaden-summary))))))
5950 (defun gnus-summary-wake-up-the-dead (&rest args)
5951 "Wake up the dead summary buffer."
5953 (gnus-dead-summary-mode -1)
5954 (let ((name (buffer-name)))
5955 (when (string-match "Dead " name)
5957 (concat (substring name 0 (match-beginning 0))
5958 (substring name (match-end 0)))
5960 (gnus-message 3 "This dead summary is now alive again"))
5962 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5963 (defun gnus-summary-fetch-faq (&optional faq-dir)
5964 "Fetch the FAQ for the current group.
5965 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5969 (when current-prefix-arg
5971 "Faq dir: " (and (listp gnus-group-faq-directory)
5972 (mapcar (lambda (file) (list file))
5973 gnus-group-faq-directory))))))
5974 (let (gnus-faq-buffer)
5975 (when (setq gnus-faq-buffer
5976 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5977 (gnus-configure-windows 'summary-faq))))
5979 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5980 (defun gnus-summary-describe-group (&optional force)
5981 "Describe the current newsgroup."
5983 (gnus-group-describe-group force gnus-newsgroup-name))
5985 (defun gnus-summary-describe-briefly ()
5986 "Describe summary mode commands briefly."
5988 (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")))
5990 ;; Walking around group mode buffer from summary mode.
5992 (defun gnus-summary-next-group (&optional no-article target-group backward)
5993 "Exit current newsgroup and then select next unread newsgroup.
5994 If prefix argument NO-ARTICLE is non-nil, no article is selected
5995 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5996 previous group instead."
5998 ;; Stop pre-fetching.
5999 (gnus-async-halt-prefetch)
6000 (let ((current-group gnus-newsgroup-name)
6001 (current-buffer (current-buffer))
6003 ;; First we semi-exit this group to update Xrefs and all variables.
6004 ;; We can't do a real exit, because the window conf must remain
6005 ;; the same in case the user is prompted for info, and we don't
6006 ;; want the window conf to change before that...
6007 (gnus-summary-exit t)
6008 (while (not entered)
6009 ;; Then we find what group we are supposed to enter.
6010 (set-buffer gnus-group-buffer)
6011 (gnus-group-jump-to-group current-group)
6014 (if (eq gnus-keep-same-level 'best)
6015 (gnus-summary-best-group gnus-newsgroup-name)
6016 (gnus-summary-search-group backward gnus-keep-same-level))))
6017 (if (not target-group)
6018 ;; There are no further groups, so we return to the group
6021 (gnus-message 5 "Returning to the group buffer")
6023 (when (gnus-buffer-live-p current-buffer)
6024 (set-buffer current-buffer)
6025 (gnus-summary-exit))
6026 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6027 ;; We try to enter the target group.
6028 (gnus-group-jump-to-group target-group)
6029 (let ((unreads (gnus-group-group-unread)))
6030 (if (and (or (eq t unreads)
6031 (and unreads (not (zerop unreads))))
6032 (gnus-summary-read-group
6033 target-group nil no-article
6034 (and (buffer-name current-buffer) current-buffer)
6037 (setq current-group target-group
6038 target-group nil)))))))
6040 (defun gnus-summary-prev-group (&optional no-article)
6041 "Exit current newsgroup and then select previous unread newsgroup.
6042 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6044 (gnus-summary-next-group no-article nil t))
6046 ;; Walking around summary lines.
6048 (defun gnus-summary-first-subject (&optional unread undownloaded)
6049 "Go to the first unread subject.
6050 If UNREAD is non-nil, go to the first unread article.
6051 Returns the article selected or nil if there are no unread articles."
6056 ((null gnus-newsgroup-data)
6057 (gnus-message 3 "No articles in the group")
6059 ;; Pick the first article.
6061 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6062 (gnus-data-number (car gnus-newsgroup-data)))
6063 ;; No unread articles.
6064 ((null gnus-newsgroup-unreads)
6065 (gnus-message 3 "No more unread articles")
6067 ;; Find the first unread article.
6069 (let ((data gnus-newsgroup-data))
6071 (and (not (and undownloaded
6072 (eq gnus-undownloaded-mark
6073 (gnus-data-mark (car data)))))
6074 (not (gnus-data-unread-p (car data)))))
6075 (setq data (cdr data)))
6077 (goto-char (gnus-data-pos (car data)))
6078 (gnus-data-number (car data))))))
6079 (gnus-summary-position-point)))
6081 (defun gnus-summary-next-subject (n &optional unread dont-display)
6082 "Go to next N'th summary line.
6083 If N is negative, go to the previous N'th subject line.
6084 If UNREAD is non-nil, only unread articles are selected.
6085 The difference between N and the actual number of steps taken is
6088 (let ((backward (< n 0))
6092 (gnus-summary-find-prev unread)
6093 (gnus-summary-find-next unread)))
6094 (unless (zerop (setq n (1- n)))
6095 (gnus-summary-show-thread)))
6097 (gnus-message 7 "No more%s articles"
6098 (if unread " unread" "")))
6099 (unless dont-display
6100 (gnus-summary-recenter)
6101 (gnus-summary-position-point))
6104 (defun gnus-summary-next-unread-subject (n)
6105 "Go to next N'th unread summary line."
6107 (gnus-summary-next-subject n t))
6109 (defun gnus-summary-prev-subject (n &optional unread)
6110 "Go to previous N'th summary line.
6111 If optional argument UNREAD is non-nil, only unread article is selected."
6113 (gnus-summary-next-subject (- n) unread))
6115 (defun gnus-summary-prev-unread-subject (n)
6116 "Go to previous N'th unread summary line."
6118 (gnus-summary-next-subject (- n) t))
6120 (defun gnus-summary-goto-subject (article &optional force silent)
6121 "Go the subject line of ARTICLE.
6122 If FORCE, also allow jumping to articles not currently shown."
6123 (interactive "nArticle number: ")
6125 (data (gnus-data-find article)))
6126 ;; We read in the article if we have to.
6129 (gnus-summary-insert-subject
6131 (if (or (numberp force) (vectorp force)) force)
6133 (setq data (gnus-data-find article)))
6138 (gnus-message 3 "Can't find article %d" article))
6140 (goto-char (gnus-data-pos data))
6141 (gnus-summary-position-point)
6144 ;; Walking around summary lines with displaying articles.
6146 (defun gnus-summary-expand-window (&optional arg)
6147 "Make the summary buffer take up the entire Emacs frame.
6148 Given a prefix, will force an `article' buffer configuration."
6151 (gnus-configure-windows 'article 'force)
6152 (gnus-configure-windows 'summary 'force)))
6154 (defun gnus-summary-display-article (article &optional all-header)
6155 "Display ARTICLE in article buffer."
6156 (when (gnus-buffer-live-p gnus-article-buffer)
6157 (with-current-buffer gnus-article-buffer
6158 (set-buffer-multibyte t)))
6159 (gnus-set-global-variables)
6160 (when (gnus-buffer-live-p gnus-article-buffer)
6161 (with-current-buffer gnus-article-buffer
6162 (setq gnus-article-charset gnus-newsgroup-charset)
6163 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6167 (if gnus-summary-display-article-function
6168 (funcall gnus-summary-display-article-function article all-header)
6169 (gnus-article-prepare article all-header))
6170 (with-current-buffer gnus-article-buffer
6171 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6173 (gnus-run-hooks 'gnus-select-article-hook)
6174 (when (and gnus-current-article
6175 (not (zerop gnus-current-article)))
6176 (gnus-summary-goto-subject gnus-current-article))
6177 (gnus-summary-recenter)
6178 (when (and gnus-use-trees gnus-show-threads)
6179 (gnus-possibly-generate-tree article)
6180 (gnus-highlight-selected-tree article))
6181 ;; Successfully display article.
6182 (gnus-article-set-window-start
6183 (cdr (assq article gnus-newsgroup-bookmarks))))))
6185 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6186 "Select the current article.
6187 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6188 non-nil, the article will be re-fetched even if it already present in
6189 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6191 ;; Make sure we are in the summary buffer to work around bbdb bug.
6192 (unless (eq major-mode 'gnus-summary-mode)
6193 (set-buffer gnus-summary-buffer))
6194 (let ((article (or article (gnus-summary-article-number)))
6195 (all-headers (not (not all-headers))) ;Must be T or NIL.
6196 gnus-summary-display-article-function)
6198 (gnus-summary-article-pseudo-p article)
6199 (error "This is a pseudo-article"))
6201 (set-buffer gnus-summary-buffer)
6202 (if (or (and gnus-single-article-buffer
6203 (or (null gnus-current-article)
6204 (null gnus-article-current)
6205 (null (get-buffer gnus-article-buffer))
6206 (not (eq article (cdr gnus-article-current)))
6207 (not (equal (car gnus-article-current)
6208 gnus-newsgroup-name))))
6209 (and (not gnus-single-article-buffer)
6210 (or (null gnus-current-article)
6211 (not (eq gnus-current-article article))))
6213 ;; The requested article is different from the current article.
6215 (gnus-summary-display-article article all-headers)
6216 (when (or all-headers gnus-show-all-headers)
6217 (gnus-article-show-all-headers))
6218 (gnus-article-set-window-start
6219 (cdr (assq article gnus-newsgroup-bookmarks)))
6221 (when (or all-headers gnus-show-all-headers)
6222 (gnus-article-show-all-headers))
6225 (defun gnus-summary-force-verify-and-decrypt ()
6227 (let ((mm-verify-option 'known)
6228 (mm-decrypt-option 'known))
6229 (gnus-summary-select-article nil 'force)))
6231 (defun gnus-summary-set-current-mark (&optional current-mark)
6232 "Obsolete function."
6235 (defun gnus-summary-next-article (&optional unread subject backward push)
6236 "Select the next article.
6237 If UNREAD, only unread articles are selected.
6238 If SUBJECT, only articles with SUBJECT are selected.
6239 If BACKWARD, the previous article is selected instead of the next."
6242 ;; Is there such an article?
6243 ((and (gnus-summary-search-forward unread subject backward)
6244 (or (gnus-summary-display-article (gnus-summary-article-number))
6245 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6246 (gnus-summary-position-point))
6247 ;; If not, we try the first unread, if that is wanted.
6249 gnus-auto-select-same
6250 (gnus-summary-first-unread-article))
6251 (gnus-summary-position-point)
6252 (gnus-message 6 "Wrapped"))
6253 ;; Try to get next/previous article not displayed in this group.
6254 ((and gnus-auto-extend-newsgroup
6255 (not unread) (not subject))
6256 (gnus-summary-goto-article
6257 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6258 nil (count-lines (point-min) (point))))
6259 ;; Go to next/previous group.
6261 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6262 (gnus-summary-jump-to-group gnus-newsgroup-name))
6263 (let ((cmd last-command-char)
6266 (set-buffer gnus-group-buffer)
6269 (if (eq gnus-keep-same-level 'best)
6270 (gnus-summary-best-group gnus-newsgroup-name)
6271 (gnus-summary-search-group backward gnus-keep-same-level))))
6272 ;; For some reason, the group window gets selected. We change
6274 (select-window (get-buffer-window (current-buffer)))
6275 ;; Select next unread newsgroup automagically.
6277 ((or (not gnus-auto-select-next)
6279 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6280 ((or (eq gnus-auto-select-next 'quietly)
6281 (and (eq gnus-auto-select-next 'slightly-quietly)
6283 (and (eq gnus-auto-select-next 'almost-quietly)
6284 (gnus-summary-last-article-p)))
6286 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6288 (gnus-message 7 "No more%s articles (%s)..."
6289 (if unread " unread" "")
6290 (if group (concat "selecting " group)
6292 (gnus-summary-next-group nil group backward)))
6294 (when (gnus-key-press-event-p last-input-event)
6295 (gnus-summary-walk-group-buffer
6296 gnus-newsgroup-name cmd unread backward point))))))))
6298 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6299 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6300 (?\C-p (gnus-group-prev-unread-group 1))))
6301 (cursor-in-echo-area t)
6302 keve key group ended)
6304 (set-buffer gnus-group-buffer)
6307 (if (eq gnus-keep-same-level 'best)
6308 (gnus-summary-best-group gnus-newsgroup-name)
6309 (gnus-summary-search-group backward gnus-keep-same-level))))
6312 5 "No more%s articles%s" (if unread " unread" "")
6314 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6315 (format " (Type %s for %s [%s])"
6316 (single-key-description cmd) group
6317 (car (gnus-gethash group gnus-newsrc-hashtb)))
6318 (format " (Type %s to exit %s)"
6319 (single-key-description cmd)
6320 gnus-newsgroup-name)))
6321 ;; Confirm auto selection.
6322 (setq key (car (setq keve (gnus-read-event-char))))
6325 ((assq key keystrokes)
6326 (let ((obuf (current-buffer)))
6327 (switch-to-buffer gnus-group-buffer)
6329 (gnus-group-jump-to-group group))
6330 (eval (cadr (assq key keystrokes)))
6331 (setq group (gnus-group-group-name))
6332 (switch-to-buffer obuf))
6336 (gnus-ephemeral-group-p gnus-newsgroup-name))
6338 (gnus-summary-next-group nil group backward)))
6340 (push (cdr keve) unread-command-events))))))
6342 (defun gnus-summary-next-unread-article ()
6343 "Select unread article after current one."
6345 (gnus-summary-next-article
6346 (or (not (eq gnus-summary-goto-unread 'never))
6347 (gnus-summary-last-article-p (gnus-summary-article-number)))
6348 (and gnus-auto-select-same
6349 (gnus-summary-article-subject))))
6351 (defun gnus-summary-prev-article (&optional unread subject)
6352 "Select the article after the current one.
6353 If UNREAD is non-nil, only unread articles are selected."
6355 (gnus-summary-next-article unread subject t))
6357 (defun gnus-summary-prev-unread-article ()
6358 "Select unread article before current one."
6360 (gnus-summary-prev-article
6361 (or (not (eq gnus-summary-goto-unread 'never))
6362 (gnus-summary-first-article-p (gnus-summary-article-number)))
6363 (and gnus-auto-select-same
6364 (gnus-summary-article-subject))))
6366 (defun gnus-summary-next-page (&optional lines circular)
6367 "Show next page of the selected article.
6368 If at the end of the current article, select the next article.
6369 LINES says how many lines should be scrolled up.
6371 If CIRCULAR is non-nil, go to the start of the article instead of
6372 selecting the next article when reaching the end of the current
6375 (setq gnus-summary-buffer (current-buffer))
6376 (gnus-set-global-variables)
6377 (let ((article (gnus-summary-article-number))
6378 (article-window (get-buffer-window gnus-article-buffer t))
6380 ;; If the buffer is empty, we have no article.
6382 (error "No article to select"))
6383 (gnus-configure-windows 'article)
6384 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6385 (if (and (eq gnus-summary-goto-unread 'never)
6386 (not (gnus-summary-last-article-p article)))
6387 (gnus-summary-next-article)
6388 (gnus-summary-next-unread-article))
6389 (if (or (null gnus-current-article)
6390 (null gnus-article-current)
6391 (/= article (cdr gnus-article-current))
6392 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6393 ;; Selected subject is different from current article's.
6394 (gnus-summary-display-article article)
6395 (when article-window
6396 (gnus-eval-in-buffer-window gnus-article-buffer
6397 (setq endp (gnus-article-next-page lines)))
6400 (gnus-summary-beginning-of-article))
6402 (gnus-message 3 "End of message"))
6404 (if (and (eq gnus-summary-goto-unread 'never)
6405 (not (gnus-summary-last-article-p article)))
6406 (gnus-summary-next-article)
6407 (gnus-summary-next-unread-article))))))))
6408 (gnus-summary-recenter)
6409 (gnus-summary-position-point)))
6411 (defun gnus-summary-prev-page (&optional lines move)
6412 "Show previous page of selected article.
6413 Argument LINES specifies lines to be scrolled down.
6414 If MOVE, move to the previous unread article if point is at
6415 the beginning of the buffer."
6417 (let ((article (gnus-summary-article-number))
6418 (article-window (get-buffer-window gnus-article-buffer t))
6420 (gnus-configure-windows 'article)
6421 (if (or (null gnus-current-article)
6422 (null gnus-article-current)
6423 (/= article (cdr gnus-article-current))
6424 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6425 ;; Selected subject is different from current article's.
6426 (gnus-summary-display-article article)
6427 (gnus-summary-recenter)
6428 (when article-window
6429 (gnus-eval-in-buffer-window gnus-article-buffer
6430 (setq endp (gnus-article-prev-page lines)))
6431 (when (and move endp)
6433 (gnus-message 3 "Beginning of message"))
6435 (if (and (eq gnus-summary-goto-unread 'never)
6436 (not (gnus-summary-first-article-p article)))
6437 (gnus-summary-prev-article)
6438 (gnus-summary-prev-unread-article))))))))
6439 (gnus-summary-position-point))
6441 (defun gnus-summary-prev-page-or-article (&optional lines)
6442 "Show previous page of selected article.
6443 Argument LINES specifies lines to be scrolled down.
6444 If at the beginning of the article, go to the next article."
6446 (gnus-summary-prev-page lines t))
6448 (defun gnus-summary-scroll-up (lines)
6449 "Scroll up (or down) one line current article.
6450 Argument LINES specifies lines to be scrolled up (or down if negative)."
6452 (gnus-configure-windows 'article)
6453 (gnus-summary-show-thread)
6454 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6455 (gnus-eval-in-buffer-window gnus-article-buffer
6457 (when (gnus-article-next-page lines)
6458 (gnus-message 3 "End of message")))
6460 (gnus-article-prev-page (- lines))))))
6461 (gnus-summary-recenter)
6462 (gnus-summary-position-point))
6464 (defun gnus-summary-scroll-down (lines)
6465 "Scroll down (or up) one line current article.
6466 Argument LINES specifies lines to be scrolled down (or up if negative)."
6468 (gnus-summary-scroll-up (- lines)))
6470 (defun gnus-summary-next-same-subject ()
6471 "Select next article which has the same subject as current one."
6473 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6475 (defun gnus-summary-prev-same-subject ()
6476 "Select previous article which has the same subject as current one."
6478 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6480 (defun gnus-summary-next-unread-same-subject ()
6481 "Select next unread article which has the same subject as current one."
6483 (gnus-summary-next-article t (gnus-summary-article-subject)))
6485 (defun gnus-summary-prev-unread-same-subject ()
6486 "Select previous unread article which has the same subject as current one."
6488 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6490 (defun gnus-summary-first-unread-article ()
6491 "Select the first unread article.
6492 Return nil if there are no unread articles."
6495 (when (gnus-summary-first-subject t)
6496 (gnus-summary-show-thread)
6497 (gnus-summary-first-subject t)
6498 (gnus-summary-display-article (gnus-summary-article-number)))
6499 (gnus-summary-position-point)))
6501 (defun gnus-summary-first-unread-subject ()
6502 "Place the point on the subject line of the first unread article.
6503 Return nil if there are no unread articles."
6506 (when (gnus-summary-first-subject t)
6507 (gnus-summary-show-thread)
6508 (gnus-summary-first-subject t))
6509 (gnus-summary-position-point)))
6511 (defun gnus-summary-first-article ()
6512 "Select the first article.
6513 Return nil if there are no articles."
6516 (when (gnus-summary-first-subject)
6517 (gnus-summary-show-thread)
6518 (gnus-summary-first-subject)
6519 (gnus-summary-display-article (gnus-summary-article-number)))
6520 (gnus-summary-position-point)))
6522 (defun gnus-summary-best-unread-article ()
6523 "Select the unread article with the highest score."
6525 (let ((best -1000000)
6526 (data gnus-newsgroup-data)
6529 (and (gnus-data-unread-p (car data))
6531 (gnus-summary-article-score (gnus-data-number (car data))))
6534 article (gnus-data-number (car data))))
6535 (setq data (cdr data)))
6538 (gnus-summary-goto-article article)
6539 (error "No unread articles"))
6540 (gnus-summary-position-point))))
6542 (defun gnus-summary-last-subject ()
6543 "Go to the last displayed subject line in the group."
6544 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6546 (gnus-summary-goto-subject article))))
6548 (defun gnus-summary-goto-article (article &optional all-headers force)
6549 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6550 If ALL-HEADERS is non-nil, no header lines are hidden.
6551 If FORCE, go to the article even if it isn't displayed. If FORCE
6552 is a number, it is the line the article is to be displayed on."
6556 "Article number or Message-ID: "
6557 (mapcar (lambda (number) (list (int-to-string number)))
6558 gnus-newsgroup-limit))
6562 (if (and (stringp article)
6563 (string-match "@" article))
6564 (gnus-summary-refer-article article)
6565 (when (stringp article)
6566 (setq article (string-to-number article)))
6567 (if (gnus-summary-goto-subject article force)
6568 (gnus-summary-display-article article all-headers)
6569 (gnus-message 4 "Couldn't go to article %s" article) nil))
6570 (gnus-summary-position-point)))
6572 (defun gnus-summary-goto-last-article ()
6573 "Go to the previously read article."
6576 (when gnus-last-article
6577 (gnus-summary-goto-article gnus-last-article nil t))
6578 (gnus-summary-position-point)))
6580 (defun gnus-summary-pop-article (number)
6581 "Pop one article off the history and go to the previous.
6582 NUMBER articles will be popped off."
6585 (setq gnus-newsgroup-history
6586 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6588 (gnus-summary-goto-article (car to) nil t)
6589 (error "Article history empty")))
6590 (gnus-summary-position-point))
6592 ;; Summary commands and functions for limiting the summary buffer.
6594 (defun gnus-summary-limit-to-articles (n)
6595 "Limit the summary buffer to the next N articles.
6596 If not given a prefix, use the process marked articles instead."
6599 (let ((articles (gnus-summary-work-articles n)))
6600 (setq gnus-newsgroup-processable nil)
6601 (gnus-summary-limit articles))
6602 (gnus-summary-position-point)))
6604 (defun gnus-summary-pop-limit (&optional total)
6605 "Restore the previous limit.
6606 If given a prefix, remove all limits."
6609 (setq gnus-newsgroup-limits
6610 (list (mapcar (lambda (h) (mail-header-number h))
6611 gnus-newsgroup-headers))))
6612 (unless gnus-newsgroup-limits
6613 (error "No limit to pop"))
6615 (gnus-summary-limit nil 'pop)
6616 (gnus-summary-position-point)))
6618 (defun gnus-summary-limit-to-subject (subject &optional header)
6619 "Limit the summary buffer to articles that have subjects that match a regexp."
6620 (interactive "sLimit to subject (regexp): ")
6622 (setq header "subject"))
6623 (when (not (equal "" subject))
6625 (let ((articles (gnus-summary-find-matching
6626 (or header "subject") subject 'all)))
6628 (error "Found no matches for \"%s\"" subject))
6629 (gnus-summary-limit articles))
6630 (gnus-summary-position-point))))
6632 (defun gnus-summary-limit-to-author (from)
6633 "Limit the summary buffer to articles that have authors that match a regexp."
6634 (interactive "sLimit to author (regexp): ")
6635 (gnus-summary-limit-to-subject from "from"))
6637 (defun gnus-summary-limit-to-age (age &optional younger-p)
6638 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6639 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6640 articles that are younger than AGE days."
6642 (let ((younger current-prefix-arg)
6645 (while (not days-got)
6646 (setq days (if younger
6647 (read-string "Limit to articles within (in days): ")
6648 (read-string "Limit to articles older than (in days): ")))
6649 (when (> (length days) 0)
6650 (setq days (read days)))
6653 (message "Please enter a number.")
6655 (list days younger)))
6657 (let ((data gnus-newsgroup-data)
6658 (cutoff (days-to-time age))
6659 articles d date is-younger)
6660 (while (setq d (pop data))
6661 (when (and (vectorp (gnus-data-header d))
6662 (setq date (mail-header-date (gnus-data-header d))))
6663 (setq is-younger (time-less-p
6664 (time-since (condition-case ()
6671 (push (gnus-data-number d) articles))))
6672 (gnus-summary-limit (nreverse articles)))
6673 (gnus-summary-position-point)))
6675 (defun gnus-summary-limit-to-extra (header regexp)
6676 "Limit the summary buffer to articles that match an 'extra' header."
6680 (gnus-completing-read
6681 (symbol-name (car gnus-extra-headers))
6682 "Limit extra header:"
6684 (cons (symbol-name x) x))
6689 (read-string (format "Limit to header %s (regexp): " header)))))
6690 (when (not (equal "" regexp))
6692 (let ((articles (gnus-summary-find-matching
6693 (cons 'extra header) regexp 'all)))
6695 (error "Found no matches for \"%s\"" regexp))
6696 (gnus-summary-limit articles))
6697 (gnus-summary-position-point))))
6699 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6701 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6703 (defun gnus-summary-limit-to-unread (&optional all)
6704 "Limit the summary buffer to articles that are not marked as read.
6705 If ALL is non-nil, limit strictly to unread articles."
6708 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6709 (gnus-summary-limit-to-marks
6710 ;; Concat all the marks that say that an article is read and have
6712 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6713 gnus-killed-mark gnus-kill-file-mark
6714 gnus-low-score-mark gnus-expirable-mark
6715 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6716 gnus-duplicate-mark gnus-souped-mark)
6719 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6720 (make-obsolete 'gnus-summary-delete-marked-with
6721 'gnus-summary-limit-exlude-marks)
6723 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6724 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6725 If REVERSE, limit the summary buffer to articles that are marked
6726 with MARKS. MARKS can either be a string of marks or a list of marks.
6727 Returns how many articles were removed."
6728 (interactive "sMarks: ")
6729 (gnus-summary-limit-to-marks marks t))
6731 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6732 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6733 If REVERSE (the prefix), limit the summary buffer to articles that are
6734 not marked with MARKS. MARKS can either be a string of marks or a
6736 Returns how many articles were removed."
6737 (interactive "sMarks: \nP")
6739 (let ((data gnus-newsgroup-data)
6740 (marks (if (listp marks) marks
6741 (append marks nil))) ; Transform to list.
6744 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6745 (memq (gnus-data-mark (car data)) marks))
6746 (push (gnus-data-number (car data)) articles))
6747 (setq data (cdr data)))
6748 (gnus-summary-limit articles))
6749 (gnus-summary-position-point)))
6751 (defun gnus-summary-limit-to-score (&optional score)
6752 "Limit to articles with score at or above SCORE."
6754 (setq score (if score
6755 (prefix-numeric-value score)
6756 (or gnus-summary-default-score 0)))
6757 (let ((data gnus-newsgroup-data)
6760 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6762 (push (gnus-data-number (car data)) articles))
6763 (setq data (cdr data)))
6765 (gnus-summary-limit articles)
6766 (gnus-summary-position-point))))
6768 (defun gnus-summary-limit-include-thread (id)
6769 "Display all the hidden articles that in the current thread."
6770 (interactive (list (mail-header-id (gnus-summary-article-header))))
6771 (let ((articles (gnus-articles-in-thread
6772 (gnus-id-to-thread (gnus-root-id id)))))
6774 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6775 (gnus-summary-position-point))))
6777 (defun gnus-summary-limit-include-dormant ()
6778 "Display all the hidden articles that are marked as dormant.
6779 Note that this command only works on a subset of the articles currently
6780 fetched for this group."
6782 (unless gnus-newsgroup-dormant
6783 (error "There are no dormant articles in this group"))
6785 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6786 (gnus-summary-position-point)))
6788 (defun gnus-summary-limit-exclude-dormant ()
6789 "Hide all dormant articles."
6792 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6793 (gnus-summary-position-point)))
6795 (defun gnus-summary-limit-exclude-childless-dormant ()
6796 "Hide all dormant articles that have no children."
6798 (let ((data (gnus-data-list t))
6799 articles d children)
6800 ;; Find all articles that are either not dormant or have
6802 (while (setq d (pop data))
6803 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6805 (gnus-article-children (gnus-data-number d)))
6808 (when (memq (car children) articles)
6813 (push (gnus-data-number d) articles)))
6816 (gnus-summary-limit articles)
6817 (gnus-summary-position-point))))
6819 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6820 "Mark all unread excluded articles as read.
6821 If ALL, mark even excluded ticked and dormants as read."
6823 (let ((articles (gnus-sorted-complement
6825 (mapcar (lambda (h) (mail-header-number h))
6826 gnus-newsgroup-headers)
6828 (sort gnus-newsgroup-limit '<)))
6830 (setq gnus-newsgroup-unreads
6831 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6833 (setq gnus-newsgroup-dormant nil
6834 gnus-newsgroup-marked nil
6835 gnus-newsgroup-reads
6837 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6838 gnus-newsgroup-reads))
6839 (while (setq article (pop articles))
6840 (unless (or (memq article gnus-newsgroup-dormant)
6841 (memq article gnus-newsgroup-marked))
6842 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6844 (defun gnus-summary-limit (articles &optional pop)
6846 ;; We pop the previous limit off the stack and use that.
6847 (setq articles (car gnus-newsgroup-limits)
6848 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6849 ;; We use the new limit, so we push the old limit on the stack.
6850 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6852 (setq gnus-newsgroup-limit articles)
6853 (let ((total (length gnus-newsgroup-data))
6854 (data (gnus-data-find-list (gnus-summary-article-number)))
6855 (gnus-summary-mark-below nil) ; Inhibit this.
6857 ;; This will do all the work of generating the new summary buffer
6858 ;; according to the new limit.
6859 (gnus-summary-prepare)
6860 ;; Hide any threads, possibly.
6861 (and gnus-show-threads
6862 gnus-thread-hide-subtree
6863 (gnus-summary-hide-all-threads))
6864 ;; Try to return to the article you were at, or one in the
6867 ;; We try to find some article after the current one.
6869 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6872 (setq data (cdr data))))
6874 ;; If there is no data, that means that we were after the last
6875 ;; article. The same goes when we can't find any articles
6876 ;; after the current one.
6877 (goto-char (point-max))
6878 (gnus-summary-find-prev))
6879 (gnus-set-mode-line 'summary)
6880 ;; We return how many articles were removed from the summary
6881 ;; buffer as a result of the new limit.
6882 (- total (length gnus-newsgroup-data))))
6884 (defsubst gnus-invisible-cut-children (threads)
6887 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6892 (defsubst gnus-cut-thread (thread)
6893 "Go forwards in the thread until we find an article that we want to display."
6894 (when (or (eq gnus-fetch-old-headers 'some)
6895 (eq gnus-fetch-old-headers 'invisible)
6896 (numberp gnus-fetch-old-headers)
6897 (eq gnus-build-sparse-threads 'some)
6898 (eq gnus-build-sparse-threads 'more))
6899 ;; Deal with old-fetched headers and sparse threads.
6903 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6904 (gnus-summary-article-ancient-p
6905 (mail-header-number (car thread))))
6906 (if (or (<= (length (cdr thread)) 1)
6907 (eq gnus-fetch-old-headers 'invisible))
6908 (setq gnus-newsgroup-limit
6909 (delq (mail-header-number (car thread))
6910 gnus-newsgroup-limit)
6911 thread (cadr thread))
6912 (when (gnus-invisible-cut-children (cdr thread))
6913 (let ((th (cdr thread)))
6915 (if (memq (mail-header-number (caar th))
6916 gnus-newsgroup-limit)
6917 (setq thread (car th)
6919 (setq th (cdr th))))))))))
6922 (defun gnus-cut-threads (threads)
6923 "Cut off all uninteresting articles from the beginning of threads."
6924 (when (or (eq gnus-fetch-old-headers 'some)
6925 (eq gnus-fetch-old-headers 'invisible)
6926 (numberp gnus-fetch-old-headers)
6927 (eq gnus-build-sparse-threads 'some)
6928 (eq gnus-build-sparse-threads 'more))
6931 (setcar th (gnus-cut-thread (car th)))
6932 (setq th (cdr th)))))
6933 ;; Remove nixed out threads.
6936 (defun gnus-summary-initial-limit (&optional show-if-empty)
6937 "Figure out what the initial limit is supposed to be on group entry.
6938 This entails weeding out unwanted dormants, low-scored articles,
6939 fetch-old-headers verbiage, and so on."
6940 ;; Most groups have nothing to remove.
6941 (if (or gnus-inhibit-limiting
6942 (and (null gnus-newsgroup-dormant)
6943 (not (eq gnus-fetch-old-headers 'some))
6944 (not (numberp gnus-fetch-old-headers))
6945 (not (eq gnus-fetch-old-headers 'invisible))
6946 (null gnus-summary-expunge-below)
6947 (not (eq gnus-build-sparse-threads 'some))
6948 (not (eq gnus-build-sparse-threads 'more))
6949 (null gnus-thread-expunge-below)
6950 (not gnus-use-nocem)))
6952 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6953 (setq gnus-newsgroup-limit nil)
6956 (unless (car (symbol-value node))
6957 ;; These threads have no parents -- they are roots.
6958 (let ((nodes (cdr (symbol-value node)))
6961 (if (and gnus-thread-expunge-below
6962 (< (gnus-thread-total-score (car nodes))
6963 gnus-thread-expunge-below))
6964 (gnus-expunge-thread (pop nodes))
6965 (setq thread (pop nodes))
6966 (gnus-summary-limit-children thread))))))
6967 gnus-newsgroup-dependencies)
6968 ;; If this limitation resulted in an empty group, we might
6969 ;; pop the previous limit and use it instead.
6970 (when (and (not gnus-newsgroup-limit)
6972 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6973 gnus-newsgroup-limit))
6975 (defun gnus-summary-limit-children (thread)
6976 "Return 1 if this subthread is visible and 0 if it is not."
6977 ;; First we get the number of visible children to this thread. This
6978 ;; is done by recursing down the thread using this function, so this
6979 ;; will really go down to a leaf article first, before slowly
6980 ;; working its way up towards the root.
6984 (apply '+ (mapcar 'gnus-summary-limit-children
6987 (number (mail-header-number (car thread)))
6990 (not (memq number gnus-newsgroup-marked))
6992 ;; If this article is dormant and has absolutely no visible
6993 ;; children, then this article isn't visible.
6994 (and (memq number gnus-newsgroup-dormant)
6996 ;; If this is "fetch-old-headered" and there is no
6997 ;; visible children, then we don't want this article.
6998 (and (or (eq gnus-fetch-old-headers 'some)
6999 (numberp gnus-fetch-old-headers))
7000 (gnus-summary-article-ancient-p number)
7002 ;; If this is "fetch-old-headered" and `invisible', then
7003 ;; we don't want this article.
7004 (and (eq gnus-fetch-old-headers 'invisible)
7005 (gnus-summary-article-ancient-p number))
7006 ;; If this is a sparsely inserted article with no children,
7007 ;; we don't want it.
7008 (and (eq gnus-build-sparse-threads 'some)
7009 (gnus-summary-article-sparse-p number)
7011 ;; If we use expunging, and this article is really
7012 ;; low-scored, then we don't want this article.
7013 (when (and gnus-summary-expunge-below
7015 (or (cdr (assq number gnus-newsgroup-scored))
7016 gnus-summary-default-score))
7017 gnus-summary-expunge-below))
7018 ;; We increase the expunge-tally here, but that has
7019 ;; nothing to do with the limits, really.
7020 (incf gnus-newsgroup-expunged-tally)
7021 ;; We also mark as read here, if that's wanted.
7022 (when (and gnus-summary-mark-below
7023 (< score gnus-summary-mark-below))
7024 (setq gnus-newsgroup-unreads
7025 (delq number gnus-newsgroup-unreads))
7026 (if gnus-newsgroup-auto-expire
7027 (push number gnus-newsgroup-expirable)
7028 (push (cons number gnus-low-score-mark)
7029 gnus-newsgroup-reads)))
7031 ;; Check NoCeM things.
7032 (if (and gnus-use-nocem
7033 (gnus-nocem-unwanted-article-p
7034 (mail-header-id (car thread))))
7036 (setq gnus-newsgroup-unreads
7037 (delq number gnus-newsgroup-unreads))
7039 ;; Nope, invisible article.
7041 ;; Ok, this article is to be visible, so we add it to the limit
7043 (push number gnus-newsgroup-limit)
7046 (defun gnus-expunge-thread (thread)
7047 "Mark all articles in THREAD as read."
7048 (let* ((number (mail-header-number (car thread))))
7049 (incf gnus-newsgroup-expunged-tally)
7050 ;; We also mark as read here, if that's wanted.
7051 (setq gnus-newsgroup-unreads
7052 (delq number gnus-newsgroup-unreads))
7053 (if gnus-newsgroup-auto-expire
7054 (push number gnus-newsgroup-expirable)
7055 (push (cons number gnus-low-score-mark)
7056 gnus-newsgroup-reads)))
7057 ;; Go recursively through all subthreads.
7058 (mapcar 'gnus-expunge-thread (cdr thread)))
7060 ;; Summary article oriented commands
7062 (defun gnus-summary-refer-parent-article (n)
7063 "Refer parent article N times.
7064 If N is negative, go to ancestor -N instead.
7065 The difference between N and the number of articles fetched is returned."
7069 (when (not (natnump n))
7074 (setq header (gnus-summary-article-header))
7075 (if (and (eq (mail-header-number header)
7076 (cdr gnus-article-current))
7077 (equal gnus-newsgroup-name
7078 (car gnus-article-current)))
7079 ;; If we try to find the parent of the currently
7080 ;; displayed article, then we take a look at the actual
7081 ;; References header, since this is slightly more
7082 ;; reliable than the References field we got from the
7085 (set-buffer gnus-original-article-buffer)
7086 (nnheader-narrow-to-headers)
7087 (unless (setq ref (message-fetch-field "references"))
7088 (setq ref (message-fetch-field "in-reply-to")))
7091 ;; It's not the current article, so we take a bet on
7092 ;; the value we got from the server.
7093 (mail-header-references header)))
7095 (not (equal ref "")))
7096 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7097 (gnus-message 1 "Couldn't find parent"))
7098 (gnus-message 1 "No references in article %d"
7099 (gnus-summary-article-number))
7102 (gnus-summary-position-point)
7105 (defun gnus-summary-refer-references ()
7106 "Fetch all articles mentioned in the References header.
7107 Return the number of articles fetched."
7109 (let ((ref (mail-header-references (gnus-summary-article-header)))
7110 (current (gnus-summary-article-number))
7114 (error "No References in the current article")
7115 ;; For each Message-ID in the References header...
7116 (while (string-match "<[^>]*>" ref)
7118 ;; ... fetch that article.
7119 (gnus-summary-refer-article
7120 (prog1 (match-string 0 ref)
7121 (setq ref (substring ref (match-end 0))))))
7122 (gnus-summary-goto-subject current)
7123 (gnus-summary-position-point)
7126 (defun gnus-summary-refer-thread (&optional limit)
7127 "Fetch all articles in the current thread.
7128 If LIMIT (the numerical prefix), fetch that many old headers instead
7129 of what's specified by the `gnus-refer-thread-limit' variable."
7131 (let ((id (mail-header-id (gnus-summary-article-header)))
7132 (limit (if limit (prefix-numeric-value limit)
7133 gnus-refer-thread-limit)))
7134 ;; We want to fetch LIMIT *old* headers, but we also have to
7135 ;; re-fetch all the headers in the current buffer, because many of
7136 ;; them may be undisplayed. So we adjust LIMIT.
7137 (when (numberp limit)
7138 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7139 (unless (eq gnus-fetch-old-headers 'invisible)
7140 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7141 ;; Retrieve the headers and read them in.
7142 (if (eq (gnus-retrieve-headers
7143 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7145 (gnus-build-all-threads)
7146 (error "Can't fetch thread from backends that don't support NOV"))
7147 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7148 (gnus-summary-limit-include-thread id)))
7150 (defun gnus-summary-refer-article (message-id)
7151 "Fetch an article specified by MESSAGE-ID."
7152 (interactive "sMessage-ID: ")
7153 (when (and (stringp message-id)
7154 (not (zerop (length message-id))))
7155 ;; Construct the correct Message-ID if necessary.
7156 ;; Suggested by tale@pawl.rpi.edu.
7157 (unless (string-match "^<" message-id)
7158 (setq message-id (concat "<" message-id)))
7159 (unless (string-match ">$" message-id)
7160 (setq message-id (concat message-id ">")))
7161 (let* ((header (gnus-id-to-header message-id))
7163 (gnus-summary-article-sparse-p
7164 (mail-header-number header))
7165 (memq (mail-header-number header)
7166 gnus-newsgroup-limit)))
7169 ;; If the article is present in the buffer we just go to it.
7171 (or (not (gnus-summary-article-sparse-p
7172 (mail-header-number header)))
7175 (gnus-summary-goto-article
7176 (mail-header-number header) nil t)
7178 (gnus-summary-update-article (mail-header-number header)))))
7180 ;; We fetch the article.
7182 (dolist (gnus-override-method (gnus-refer-article-methods))
7183 (gnus-check-server gnus-override-method)
7184 ;; Fetch the header, and display the article.
7185 (when (setq number (gnus-summary-insert-subject message-id))
7186 (gnus-summary-select-article nil nil nil number)
7188 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7190 (defun gnus-refer-article-methods ()
7191 "Return a list of referrable methods."
7193 ;; No method, so we default to current and native.
7194 ((null gnus-refer-article-method)
7195 (list gnus-current-select-method gnus-select-method))
7197 ((eq 'current gnus-refer-article-method)
7198 (list gnus-current-select-method))
7199 ;; List of select methods.
7200 ((not (and (symbolp (car gnus-refer-article-method))
7201 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7203 (dolist (method gnus-refer-article-method)
7204 (push (if (eq 'current method)
7205 gnus-current-select-method
7209 ;; One single select method.
7211 (list gnus-refer-article-method))))
7213 (defun gnus-summary-edit-parameters ()
7214 "Edit the group parameters of the current group."
7216 (gnus-group-edit-group gnus-newsgroup-name 'params))
7218 (defun gnus-summary-customize-parameters ()
7219 "Customize the group parameters of the current group."
7221 (gnus-group-customize gnus-newsgroup-name))
7223 (defun gnus-summary-enter-digest-group (&optional force)
7224 "Enter an nndoc group based on the current article.
7225 If FORCE, force a digest interpretation. If not, try
7226 to guess what the document format is."
7228 (let ((conf gnus-current-window-configuration))
7230 (gnus-summary-select-article))
7231 (setq gnus-current-window-configuration conf)
7232 (let* ((name (format "%s-%d"
7233 (gnus-group-prefixed-name
7234 gnus-newsgroup-name (list 'nndoc ""))
7236 (set-buffer gnus-summary-buffer)
7237 gnus-current-article)))
7238 (ogroup gnus-newsgroup-name)
7239 (params (append (gnus-info-params (gnus-get-info ogroup))
7240 (list (cons 'to-group ogroup))
7241 (list (cons 'save-article-group ogroup))))
7242 (case-fold-search t)
7243 (buf (current-buffer))
7246 (set-buffer gnus-original-article-buffer)
7247 ;; Have the digest group inherit the main mail address of
7248 ;; the parent article.
7249 (when (setq to-address (or (message-fetch-field "reply-to")
7250 (message-fetch-field "from")))
7251 (setq params (append
7252 (list (cons 'to-address
7253 (funcall gnus-decode-encoded-word-function
7255 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7256 (insert-buffer-substring gnus-original-article-buffer)
7257 ;; Remove lines that may lead nndoc to misinterpret the
7260 (goto-char (point-min))
7261 (or (search-forward "\n\n" nil t) (point)))
7262 (goto-char (point-min))
7263 (delete-matching-lines "^Path:\\|^From ")
7266 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7267 (gnus-newsgroup-ephemeral-ignored-charsets
7268 gnus-newsgroup-ignored-charsets))
7269 (gnus-group-read-ephemeral-group
7270 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7272 ,(if force 'mbox 'guess))) t))
7273 ;; Make all postings to this group go to the parent group.
7274 (nconc (gnus-info-params (gnus-get-info name))
7276 ;; Couldn't select this doc group.
7277 (switch-to-buffer buf)
7278 (gnus-set-global-variables)
7279 (gnus-configure-windows 'summary)
7280 (gnus-message 3 "Article couldn't be entered?"))
7281 (kill-buffer dig)))))
7283 (defun gnus-summary-read-document (n)
7284 "Open a new group based on the current article(s).
7285 This will allow you to read digests and other similar
7286 documents as newsgroups.
7287 Obeys the standard process/prefix convention."
7289 (let* ((articles (gnus-summary-work-articles n))
7290 (ogroup gnus-newsgroup-name)
7291 (params (append (gnus-info-params (gnus-get-info ogroup))
7292 (list (cons 'to-group ogroup))))
7293 article group egroup groups vgroup)
7294 (while (setq article (pop articles))
7295 (setq group (format "%s-%d" gnus-newsgroup-name article))
7296 (gnus-summary-remove-process-mark article)
7297 (when (gnus-summary-display-article article)
7300 (insert-buffer-substring gnus-original-article-buffer)
7301 ;; Remove some headers that may lead nndoc to make
7303 (message-narrow-to-head)
7304 (goto-char (point-min))
7305 (delete-matching-lines "^\\(Path\\):\\|^From ")
7308 (gnus-group-read-ephemeral-group
7309 group `(nndoc ,group (nndoc-address ,(current-buffer))
7310 (nndoc-article-type guess))
7313 ;; Make all postings to this group go to the parent group.
7314 (nconc (gnus-info-params (gnus-get-info egroup))
7316 (push egroup groups))
7317 ;; Couldn't select this doc group.
7318 (gnus-error 3 "Article couldn't be entered"))))))
7319 ;; Now we have selected all the documents.
7322 (error "None of the articles could be interpreted as documents"))
7323 ((gnus-group-read-ephemeral-group
7324 (setq vgroup (format
7325 "nnvirtual:%s-%s" gnus-newsgroup-name
7326 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7327 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7329 (cons (current-buffer) 'summary)))
7331 (error "Couldn't select virtual nndoc group")))))
7333 (defun gnus-summary-isearch-article (&optional regexp-p)
7334 "Do incremental search forward on the current article.
7335 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7337 (let* ((gnus-inhibit-treatment t)
7338 (old (gnus-summary-select-article)))
7339 (gnus-configure-windows 'article)
7340 (gnus-eval-in-buffer-window gnus-article-buffer
7344 (gnus-article-show-all-headers))
7345 (goto-char (point-min))
7346 (isearch-forward regexp-p)))))
7348 (defun gnus-summary-search-article-forward (regexp &optional backward)
7349 "Search for an article containing REGEXP forward.
7350 If BACKWARD, search backward instead."
7353 (format "Search article %s (regexp%s): "
7354 (if current-prefix-arg "backward" "forward")
7355 (if gnus-last-search-regexp
7356 (concat ", default " gnus-last-search-regexp)
7358 current-prefix-arg))
7359 (if (string-equal regexp "")
7360 (setq regexp (or gnus-last-search-regexp ""))
7361 (setq gnus-last-search-regexp regexp)
7362 (setq gnus-article-before-search gnus-current-article))
7363 ;; Intentionally set gnus-last-article.
7364 (setq gnus-last-article gnus-article-before-search)
7365 (let ((gnus-last-article gnus-last-article))
7366 (if (gnus-summary-search-article regexp backward)
7367 (gnus-summary-show-thread)
7368 (error "Search failed: \"%s\"" regexp))))
7370 (defun gnus-summary-search-article-backward (regexp)
7371 "Search for an article containing REGEXP backward."
7374 (format "Search article backward (regexp%s): "
7375 (if gnus-last-search-regexp
7376 (concat ", default " gnus-last-search-regexp)
7378 (gnus-summary-search-article-forward regexp 'backward))
7381 (defmacro gnus-summary-search-article-position-point (regexp backward)
7382 "Dehighlight the last matched text and goto the beginning position."
7383 (` (if (and gnus-summary-search-article-matched-data
7384 (let ((text (caddr gnus-summary-search-article-matched-data))
7385 (inhibit-read-only t)
7388 (goto-char (car gnus-summary-search-article-matched-data))
7389 (cadr gnus-summary-search-article-matched-data))
7391 (string-match (, regexp) text)))
7392 (if (, backward) (beginning-of-line) (end-of-line))
7393 (goto-char (if (, backward) (point-max) (point-min))))))
7395 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7396 "Place point where X-Face image is displayed."
7397 (if (featurep 'xemacs)
7398 (` (let ((end (if (search-forward "\n\n" nil t)
7399 (goto-char (1- (point)))
7402 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7403 (unless (and (re-search-forward "^From:" end t)
7404 (setq extent (extent-at (point)))
7405 (extent-begin-glyph extent))
7406 (goto-char (, opoint)))))
7407 (` (let ((end (if (search-forward "\n\n" nil t)
7408 (goto-char (1- (point)))
7410 (start (or (search-backward "\n\n" nil t) (point-min))))
7412 (or (text-property-any start end 'x-face-image t);; x-face-e21
7413 (text-property-any start end 'x-face-mule-bitmap-image t)
7416 (defmacro gnus-summary-search-article-highlight-matched-text
7417 (backward treated x-face)
7418 "Highlight matched text in the function `gnus-summary-search-article'."
7419 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7420 (end (set-marker (make-marker) (match-end 0)))
7421 (inhibit-read-only t)
7425 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7427 (lambda (item) (setq items (delq item items)))
7428 '(gnus-treat-buttonize
7429 gnus-treat-fill-article
7430 gnus-treat-fill-long-lines
7431 gnus-treat-emphasize
7432 gnus-treat-highlight-headers
7433 gnus-treat-highlight-citation
7434 gnus-treat-highlight-signature
7435 gnus-treat-overstrike
7436 gnus-treat-display-xface
7437 gnus-treat-buttonize-head
7438 gnus-treat-decode-article-as-default-mime-charset))
7439 (static-if (featurep 'xemacs)
7441 (cons '(x-face-mule-delete-x-face-field
7444 (gnus-treat-display-xface
7445 (when (, x-face) gnus-treat-display-xface)))
7446 (gnus-article-prepare-mime-display)))
7447 (goto-char (if (, backward) start end))
7449 (gnus-summary-search-article-highlight-goto-x-face (point)))
7450 (setq gnus-summary-search-article-matched-data
7451 (list start end (buffer-substring start end)))
7452 (unless (eq start end);; matched text has been deleted. :-<
7453 (put-text-property start end 'face
7454 (or (find-face 'isearch)
7455 'secondary-selection))))))
7458 (defun gnus-summary-search-article (regexp &optional backward)
7459 "Search for an article containing REGEXP.
7460 Optional argument BACKWARD means do search for backward.
7461 `gnus-select-article-hook' is not called during the search."
7462 ;; We have to require this here to make sure that the following
7463 ;; dynamic binding isn't shadowed by autoloading.
7464 (require 'gnus-async)
7466 (let ((gnus-select-article-hook nil) ;Disable hook.
7467 (gnus-article-prepare-hook nil)
7468 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7469 (gnus-use-article-prefetch nil)
7470 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7471 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7472 (sum (current-buffer))
7475 (gnus-save-hidden-threads
7476 (static-if (featurep 'xemacs)
7477 (let ((gnus-inhibit-treatment t))
7478 (setq treated (eq 'old (gnus-summary-select-article)))
7480 (not (and (gnus-buffer-live-p gnus-article-buffer)
7481 (window-live-p (get-buffer-window
7482 gnus-article-buffer t)))))
7483 (gnus-summary-select-article nil t)
7484 (setq treated nil)))
7485 (let ((gnus-inhibit-treatment t)
7486 (x-face-mule-delete-x-face-field 'never))
7487 (setq treated (eq 'old (gnus-summary-select-article)))
7490 (and (gnus-buffer-live-p gnus-article-buffer)
7491 (window-live-p (get-buffer-window
7492 gnus-article-buffer t))
7493 (or (not (string-match "^\\^X-Face:" regexp))
7494 (with-current-buffer gnus-article-buffer
7495 gnus-summary-search-article-matched-data)))))
7496 (gnus-summary-select-article nil t)
7497 (setq treated nil))))
7498 (set-buffer gnus-article-buffer)
7502 (gnus-article-show-all-headers)
7503 (gnus-summary-search-article-position-point regexp backward))
7504 (goto-char (if backward (point-max) (point-min))))
7506 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7508 (re-search-backward regexp nil t)
7509 (re-search-forward regexp nil t))
7510 ;; We found the regexp.
7512 (gnus-summary-search-article-highlight-matched-text
7513 backward treated (string-match "^\\^X-Face:" regexp))
7516 (/ (- 2 (window-height
7517 (get-buffer-window gnus-article-buffer t)))
7520 (get-buffer-window (current-buffer))
7523 (setq point (point)))
7524 ;; We didn't find it, so we go to the next article.
7527 (while (eq found 'not)
7528 (if (not (if backward (gnus-summary-find-prev)
7529 (gnus-summary-find-next)))
7530 ;; No more articles.
7532 ;; Select the next article and adjust point.
7533 (unless (gnus-summary-article-sparse-p
7534 (gnus-summary-article-number))
7536 (let ((gnus-inhibit-treatment t))
7537 (gnus-summary-select-article))
7539 (set-buffer gnus-article-buffer)
7541 (goto-char (if backward (point-max) (point-min))))))))
7542 (gnus-message 7 ""))
7543 ;; Return whether we found the regexp.
7544 (when (eq found 'found)
7546 (gnus-summary-show-thread)
7547 (gnus-summary-goto-subject gnus-current-article)
7548 (gnus-summary-position-point)
7551 (defun gnus-summary-find-matching (header regexp &optional backward unread
7553 "Return a list of all articles that match REGEXP on HEADER.
7554 The search stars on the current article and goes forwards unless
7555 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7556 If UNREAD is non-nil, only unread articles will
7557 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7558 in the comparisons."
7559 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7560 (gnus-data-find-list
7561 (gnus-summary-article-number) (gnus-data-list backward))))
7562 (case-fold-search (not not-case-fold))
7565 (if (eq (car header) 'extra)
7568 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7570 (error "%s is an invalid header" header))
7571 (unless (fboundp (intern (concat "mail-header-" header)))
7572 (error "%s is not a valid header" header))
7573 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7576 (and (or (not unread) ; We want all articles...
7577 (gnus-data-unread-p d)) ; Or just unreads.
7578 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7579 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7580 (push (gnus-data-number d) articles)) ; Success!
7581 (setq data (cdr data)))
7582 (nreverse articles)))
7584 (defun gnus-summary-execute-command (header regexp command &optional backward)
7585 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7586 If HEADER is an empty string (or nil), the match is done on the entire
7587 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7589 (list (let ((completion-ignore-case t))
7592 (mapcar (lambda (header) (list (format "%s" header)))
7594 '("Number" "Subject" "From" "Lines" "Date"
7595 "Message-ID" "Xref" "References" "Body")
7596 gnus-extra-headers))
7597 nil 'require-match))
7598 (read-string "Regexp: ")
7599 (read-key-sequence "Command: ")
7600 current-prefix-arg))
7601 (when (equal header "Body")
7603 ;; Hidden thread subtrees must be searched as well.
7604 (gnus-summary-show-all-threads)
7605 ;; We don't want to change current point nor window configuration.
7607 (save-window-excursion
7608 (gnus-message 6 "Executing %s..." (key-description command))
7609 ;; We'd like to execute COMMAND interactively so as to give arguments.
7610 (gnus-execute header regexp
7611 `(call-interactively ',(key-binding command))
7613 (gnus-message 6 "Executing %s...done" (key-description command)))))
7615 (defun gnus-summary-beginning-of-article ()
7616 "Scroll the article back to the beginning."
7618 (gnus-summary-select-article)
7619 (gnus-configure-windows 'article)
7620 (gnus-eval-in-buffer-window gnus-article-buffer
7622 (goto-char (point-min))
7623 (when gnus-page-broken
7624 (gnus-narrow-to-page))))
7626 (defun gnus-summary-end-of-article ()
7627 "Scroll to the end of the article."
7629 (gnus-summary-select-article)
7630 (gnus-configure-windows 'article)
7631 (gnus-eval-in-buffer-window gnus-article-buffer
7633 (goto-char (point-max))
7635 (when gnus-page-broken
7636 (gnus-narrow-to-page))))
7638 (defun gnus-summary-print-article (&optional filename n)
7639 "Generate and print a PostScript image of the N next (mail) articles.
7641 If N is negative, print the N previous articles. If N is nil and articles
7642 have been marked with the process mark, print these instead.
7644 If the optional first argument FILENAME is nil, send the image to the
7645 printer. If FILENAME is a string, save the PostScript image in a file with
7646 that name. If FILENAME is a number, prompt the user for the name of the file
7648 (interactive (list (ps-print-preprint current-prefix-arg)))
7649 (dolist (article (gnus-summary-work-articles n))
7650 (gnus-summary-select-article nil nil 'pseudo article)
7651 (gnus-eval-in-buffer-window gnus-article-buffer
7652 (let ((buffer (generate-new-buffer " *print*")))
7655 (copy-to-buffer buffer (point-min) (point-max))
7657 (gnus-article-delete-invisible-text)
7658 (when (gnus-visual-p 'article-highlight 'highlight)
7659 ;; Copy-to-buffer doesn't copy overlay. So redo
7661 (let ((gnus-article-buffer buffer))
7662 (gnus-article-highlight-citation t)
7663 (gnus-article-highlight-signature)))
7664 (let ((ps-left-header
7667 (mail-header-subject gnus-current-headers) ")")
7669 (mail-header-from gnus-current-headers) ")")))
7672 "/pagenumberstring load"
7674 (mail-header-date gnus-current-headers) ")"))))
7675 (gnus-run-hooks 'gnus-ps-print-hook)
7678 (ps-spool-buffer-with-faces)
7679 (ps-spool-buffer)))))
7680 (kill-buffer buffer))))
7681 (gnus-summary-remove-process-mark article))
7682 (ps-despool filename))
7684 (defun gnus-summary-show-article (&optional arg)
7685 "Force re-fetching of the current article.
7686 If ARG (the prefix) is a number, show the article with the charset
7687 defined in `gnus-summary-show-article-charset-alist', or the charset
7689 If ARG (the prefix) is non-nil and not a number, show the raw article
7690 without any article massaging functions being run."
7694 (let ((gnus-newsgroup-charset
7695 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7696 (read-coding-system "Charset: ")))
7697 (gnus-newsgroup-ignored-charsets 'gnus-all))
7698 (gnus-summary-select-article nil 'force)
7699 (let ((deps gnus-newsgroup-dependencies)
7702 (set-buffer gnus-original-article-buffer)
7704 (message-narrow-to-head)
7705 (setq head (buffer-string)))
7707 (insert (format "211 %d Article retrieved.\n"
7708 (cdr gnus-article-current)))
7711 (let ((nntp-server-buffer (current-buffer)))
7712 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7713 (gnus-data-set-header
7714 (gnus-data-find (cdr gnus-article-current))
7716 (gnus-summary-update-article-line
7717 (cdr gnus-article-current) header))))
7719 ;; Select the article the normal way.
7720 (gnus-summary-select-article nil 'force))
7722 ;; We have to require this here to make sure that the following
7723 ;; dynamic binding isn't shadowed by autoloading.
7724 (require 'gnus-async)
7726 ;; Bind the article treatment functions to nil.
7727 (let ((gnus-have-all-headers t)
7728 gnus-article-prepare-hook
7729 gnus-article-decode-hook
7732 (gnus-inhibit-treatment t))
7733 (gnus-summary-select-article nil 'force))))
7734 (gnus-summary-goto-subject gnus-current-article)
7735 (gnus-summary-position-point))
7737 (defun gnus-summary-verbose-headers (&optional arg)
7738 "Toggle permanent full header display.
7739 If ARG is a positive number, turn header display on.
7740 If ARG is a negative number, turn header display off."
7742 (setq gnus-show-all-headers
7743 (cond ((or (not (numberp arg))
7745 (not gnus-show-all-headers))
7748 (gnus-summary-show-article))
7750 (defun gnus-summary-toggle-header (&optional arg)
7751 "Show the headers if they are hidden, or hide them if they are shown.
7752 If ARG is a positive number, show the entire header.
7753 If ARG is a negative number, hide the unwanted header lines."
7756 (set-buffer gnus-article-buffer)
7758 (let* ((buffer-read-only nil)
7759 (inhibit-point-motion-hooks t)
7765 (article-narrow-to-head)
7766 (gnus-article-hidden-text-p 'headers))))
7767 (goto-char (point-min))
7768 (when (search-forward "\n\n" nil t)
7769 (delete-region (point-min) (1- (point))))
7770 (goto-char (point-min))
7772 (set-buffer gnus-original-article-buffer)
7773 (goto-char (point-min))
7774 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7775 (insert-buffer-substring gnus-original-article-buffer 1 e)
7777 (narrow-to-region (point-min) (point))
7778 (article-decode-encoded-words)
7780 (let ((gnus-treat-hide-headers nil)
7781 (gnus-treat-hide-boring-headers nil))
7782 (setq gnus-article-wash-types
7783 (delq 'headers gnus-article-wash-types))
7784 (gnus-treat-article 'head))
7785 (gnus-treat-article 'head)))
7786 (gnus-set-mode-line 'article)))))
7788 (defun gnus-summary-show-all-headers ()
7789 "Make all header lines visible."
7791 (gnus-summary-toggle-header 1))
7793 (defun gnus-summary-toggle-mime (&optional arg)
7794 "Toggle MIME processing.
7795 If ARG is a positive number, turn MIME processing on."
7797 (setq gnus-show-mime
7799 (not gnus-show-mime)
7800 (> (prefix-numeric-value arg) 0)))
7801 (gnus-summary-select-article t 'force))
7803 (defun gnus-summary-caesar-message (&optional arg)
7804 "Caesar rotate the current article by 13.
7805 The numerical prefix specifies how many places to rotate each letter
7808 (gnus-summary-select-article)
7809 (let ((mail-header-separator ""))
7810 (gnus-eval-in-buffer-window gnus-article-buffer
7813 (let ((start (window-start))
7815 (message-caesar-buffer-body arg)
7816 (set-window-start (get-buffer-window (current-buffer)) start))))))
7818 (defun gnus-summary-stop-page-breaking ()
7819 "Stop page breaking in the current article."
7821 (gnus-summary-select-article)
7822 (gnus-eval-in-buffer-window gnus-article-buffer
7824 (when (gnus-visual-p 'page-marker)
7825 (let ((buffer-read-only nil))
7826 (gnus-remove-text-with-property 'gnus-prev)
7827 (gnus-remove-text-with-property 'gnus-next))
7828 (setq gnus-page-broken nil))))
7830 (defun gnus-summary-move-article (&optional n to-newsgroup
7831 select-method action)
7832 "Move the current article to a different newsgroup.
7833 If N is a positive number, move the N next articles.
7834 If N is a negative number, move the N previous articles.
7835 If N is nil and any articles have been marked with the process mark,
7836 move those articles instead.
7837 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7838 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7839 re-spool using this method.
7841 For this function to work, both the current newsgroup and the
7842 newsgroup that you want to move to have to support the `request-move'
7843 and `request-accept' functions.
7845 ACTION can be either `move' (the default), `crosspost' or `copy'."
7848 (setq action 'move))
7849 ;; Disable marking as read.
7850 (let (gnus-mark-article-hook)
7851 (save-window-excursion
7852 (gnus-summary-select-article)))
7853 ;; Check whether the source group supports the required functions.
7854 (cond ((and (eq action 'move)
7855 (not (gnus-check-backend-function
7856 'request-move-article gnus-newsgroup-name)))
7857 (error "The current group does not support article moving"))
7858 ((and (eq action 'crosspost)
7859 (not (gnus-check-backend-function
7860 'request-replace-article gnus-newsgroup-name)))
7861 (error "The current group does not support article editing")))
7862 (let ((articles (gnus-summary-work-articles n))
7863 (prefix (if (gnus-check-backend-function
7864 'request-move-article gnus-newsgroup-name)
7865 (gnus-group-real-prefix gnus-newsgroup-name)
7867 (names '((move "Move" "Moving")
7868 (copy "Copy" "Copying")
7869 (crosspost "Crosspost" "Crossposting")))
7870 (copy-buf (save-excursion
7871 (nnheader-set-temp-buffer " *copy article*")))
7872 (default-marks gnus-article-mark-lists)
7873 (no-expire-marks (delete '(expirable . expire)
7874 (copy-sequence gnus-article-mark-lists)))
7875 art-group to-method new-xref article to-groups)
7876 (unless (assq action names)
7877 (error "Unknown action %s" action))
7878 ;; Read the newsgroup name.
7879 (when (and (not to-newsgroup)
7880 (not select-method))
7882 (gnus-read-move-group-name
7883 (cadr (assq action names))
7884 (symbol-value (intern (format "gnus-current-%s-group" action)))
7886 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7887 (setq to-method (or select-method
7888 (gnus-server-to-method
7889 (gnus-group-method to-newsgroup))))
7890 ;; Check the method we are to move this article to...
7891 (unless (gnus-check-backend-function
7892 'request-accept-article (car to-method))
7893 (error "%s does not support article copying" (car to-method)))
7894 (unless (gnus-check-server to-method)
7895 (error "Can't open server %s" (car to-method)))
7896 (gnus-message 6 "%s to %s: %s..."
7897 (caddr (assq action names))
7898 (or (car select-method) to-newsgroup) articles)
7900 (setq article (pop articles))
7904 ;; Move the article.
7906 ;; Remove this article from future suppression.
7907 (gnus-dup-unsuppress-article article)
7908 (gnus-request-move-article
7909 article ; Article to move
7910 gnus-newsgroup-name ; From newsgroup
7911 (nth 1 (gnus-find-method-for-group
7912 gnus-newsgroup-name)) ; Server
7913 (list 'gnus-request-accept-article
7914 to-newsgroup (list 'quote select-method)
7915 (not articles) t) ; Accept form
7916 (not articles))) ; Only save nov last time
7917 ;; Copy the article.
7920 (set-buffer copy-buf)
7921 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7922 (gnus-request-accept-article
7923 to-newsgroup select-method (not articles) t))))
7924 ;; Crosspost the article.
7925 ((eq action 'crosspost)
7926 (let ((xref (message-tokenize-header
7927 (mail-header-xref (gnus-summary-article-header article))
7929 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7932 (setq xref (list (system-name))))
7935 (mapconcat 'identity
7936 (delete "Xref:" (delete new-xref xref))
7940 (set-buffer copy-buf)
7941 ;; First put the article in the destination group.
7942 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7943 (when (consp (setq art-group
7944 (gnus-request-accept-article
7945 to-newsgroup select-method (not articles))))
7946 (setq new-xref (concat new-xref " " (car art-group)
7947 ":" (cdr art-group)))
7948 ;; Now we have the new Xrefs header, so we insert
7949 ;; it and replace the new article.
7950 (nnheader-replace-header "Xref" new-xref)
7951 (gnus-request-replace-article
7952 (cdr art-group) to-newsgroup (current-buffer))
7956 (gnus-message 1 "Couldn't %s article %s: %s"
7957 (cadr (assq action names)) article
7958 (nnheader-get-report (car to-method))))
7959 ((eq art-group 'junk)
7960 (when (eq action 'move)
7961 (gnus-summary-mark-article article gnus-canceled-mark)
7962 (gnus-message 4 "Deleted article %s" article)))
7964 (let* ((pto-group (gnus-group-prefixed-name
7965 (car art-group) to-method))
7967 (gnus-gethash pto-group gnus-newsrc-hashtb))
7968 (info (nth 2 entry))
7969 (to-group (gnus-info-group info))
7971 ;; Update the group that has been moved to.
7973 (memq action '(move copy)))
7974 (unless (member to-group to-groups)
7975 (push to-group to-groups))
7977 (unless (memq article gnus-newsgroup-unreads)
7978 (push 'read to-marks)
7980 info (gnus-add-to-range (gnus-info-read info)
7981 (list (cdr art-group)))))
7983 ;; See whether the article is to be put in the cache.
7984 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7987 (to-article (cdr art-group)))
7989 ;; Enter the article into the cache in the new group,
7990 ;; if that is required.
7991 (when gnus-use-cache
7992 (gnus-cache-possibly-enter-article
7994 (let ((header (copy-sequence
7995 (gnus-summary-article-header article))))
7996 (mail-header-set-number header to-article)
7998 (memq article gnus-newsgroup-marked)
7999 (memq article gnus-newsgroup-dormant)
8000 (memq article gnus-newsgroup-unreads)))
8002 (when gnus-preserve-marks
8003 ;; Copy any marks over to the new group.
8004 (when (and (equal to-group gnus-newsgroup-name)
8005 (not (memq article gnus-newsgroup-unreads)))
8006 ;; Mark this article as read in this group.
8007 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8008 (setcdr (gnus-active to-group) to-article)
8009 (setcdr gnus-newsgroup-active to-article))
8012 (when (memq article (symbol-value
8013 (intern (format "gnus-newsgroup-%s"
8015 (push (cdar marks) to-marks)
8016 ;; If the other group is the same as this group,
8017 ;; then we have to add the mark to the list.
8018 (when (equal to-group gnus-newsgroup-name)
8019 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8022 (intern (format "gnus-newsgroup-%s"
8024 ;; Copy the marks to other group.
8025 (gnus-add-marked-articles
8026 to-group (cdar marks) (list to-article) info))
8027 (setq marks (cdr marks)))
8029 (gnus-request-set-mark to-group (list (list (list to-article)
8034 (concat "(gnus-group-set-info '"
8035 (gnus-prin1-to-string (gnus-get-info to-group))
8038 ;; Update the Xref header in this article to point to
8039 ;; the new crossposted article we have just created.
8040 (when (eq action 'crosspost)
8042 (set-buffer copy-buf)
8043 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8044 (nnheader-replace-header "Xref" new-xref)
8045 (gnus-request-replace-article
8046 article gnus-newsgroup-name (current-buffer)))))
8048 ;;;!!!Why is this necessary?
8049 (set-buffer gnus-summary-buffer)
8051 (gnus-summary-goto-subject article)
8052 (when (eq action 'move)
8053 (gnus-summary-mark-article article gnus-canceled-mark))))
8054 (gnus-summary-remove-process-mark article))
8055 ;; Re-activate all groups that have been moved to.
8058 (set-buffer gnus-group-buffer)
8059 (when (gnus-group-goto-group (car to-groups) t)
8060 (gnus-group-get-new-news-this-group 1 t))
8063 (gnus-kill-buffer copy-buf)
8064 (gnus-summary-position-point)
8065 (gnus-set-mode-line 'summary)))
8067 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8068 "Move the current article to a different newsgroup.
8069 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8070 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8071 re-spool using this method."
8073 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8075 (defun gnus-summary-crosspost-article (&optional n)
8076 "Crosspost the current article to some other group."
8078 (gnus-summary-move-article n nil nil 'crosspost))
8080 (defcustom gnus-summary-respool-default-method nil
8081 "Default method for respooling an article.
8082 If nil, use to the current newsgroup method."
8083 :type '(choice (gnus-select-method :value (nnml ""))
8085 :group 'gnus-summary-mail)
8087 (defun gnus-summary-respool-article (&optional n method)
8088 "Respool the current article.
8089 The article will be squeezed through the mail spooling process again,
8090 which means that it will be put in some mail newsgroup or other
8091 depending on `nnmail-split-methods'.
8092 If N is a positive number, respool the N next articles.
8093 If N is a negative number, respool the N previous articles.
8094 If N is nil and any articles have been marked with the process mark,
8095 respool those articles instead.
8097 Respooling can be done both from mail groups and \"real\" newsgroups.
8098 In the former case, the articles in question will be moved from the
8099 current group into whatever groups they are destined to. In the
8100 latter case, they will be copied into the relevant groups."
8102 (list current-prefix-arg
8103 (let* ((methods (gnus-methods-using 'respool))
8105 (symbol-name (or gnus-summary-respool-default-method
8106 (car (gnus-find-method-for-group
8107 gnus-newsgroup-name)))))
8109 (gnus-completing-read
8110 methname "What backend do you want to use when respooling?"
8111 methods nil t nil 'gnus-mail-method-history))
8114 ((zerop (length (setq ms (gnus-servers-using-backend
8116 (list (intern method) ""))
8120 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8121 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8124 (error "No method given for respooling"))
8125 (if (assoc (symbol-name
8126 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8127 (gnus-methods-using 'respool))
8128 (gnus-summary-move-article n nil method)
8129 (gnus-summary-copy-article n nil method)))
8131 (defun gnus-summary-import-article (file &optional edit)
8132 "Import an arbitrary file into a mail newsgroup."
8133 (interactive "fImport file: \nP")
8134 (let ((group gnus-newsgroup-name)
8135 (now (current-time))
8136 atts lines group-art)
8137 (unless (gnus-check-backend-function 'request-accept-article group)
8138 (error "%s does not support article importing" group))
8139 (or (file-readable-p file)
8140 (not (file-regular-p file))
8141 (error "Can't read %s" file))
8143 (set-buffer (gnus-get-buffer-create " *import file*"))
8145 (nnheader-insert-file-contents file)
8146 (goto-char (point-min))
8147 (unless (nnheader-article-p)
8148 ;; This doesn't look like an article, so we fudge some headers.
8149 (setq atts (file-attributes file)
8150 lines (count-lines (point-min) (point-max)))
8151 (insert "From: " (read-string "From: ") "\n"
8152 "Subject: " (read-string "Subject: ") "\n"
8153 "Date: " (message-make-date (nth 5 atts)) "\n"
8154 "Message-ID: " (message-make-message-id) "\n"
8155 "Lines: " (int-to-string lines) "\n"
8156 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8157 (setq group-art (gnus-request-accept-article group nil t))
8158 (kill-buffer (current-buffer)))
8159 (setq gnus-newsgroup-active (gnus-activate-group group))
8161 (gnus-summary-goto-article (cdr group-art) nil t)
8163 (gnus-summary-edit-article))))
8165 (defun gnus-summary-create-article ()
8166 "Create an article in a mail newsgroup."
8168 (let ((group gnus-newsgroup-name)
8169 (now (current-time))
8171 (unless (gnus-check-backend-function 'request-accept-article group)
8172 (error "%s does not support article importing" group))
8174 (set-buffer (gnus-get-buffer-create " *import file*"))
8176 (goto-char (point-min))
8177 ;; This doesn't look like an article, so we fudge some headers.
8178 (insert "From: " (read-string "From: ") "\n"
8179 "Subject: " (read-string "Subject: ") "\n"
8180 "Date: " (message-make-date now) "\n"
8181 "Message-ID: " (message-make-message-id) "\n")
8182 (setq group-art (gnus-request-accept-article group nil t))
8183 (kill-buffer (current-buffer)))
8184 (setq gnus-newsgroup-active (gnus-activate-group group))
8186 (gnus-summary-goto-article (cdr group-art) nil t)
8187 (gnus-summary-edit-article)))
8189 (defun gnus-summary-article-posted-p ()
8190 "Say whether the current (mail) article is available from news as well.
8191 This will be the case if the article has both been mailed and posted."
8193 (let ((id (mail-header-references (gnus-summary-article-header)))
8194 (gnus-override-method (car (gnus-refer-article-methods))))
8195 (if (gnus-request-head id "")
8196 (gnus-message 2 "The current message was found on %s"
8197 gnus-override-method)
8198 (gnus-message 2 "The current message couldn't be found on %s"
8199 gnus-override-method)
8202 (defun gnus-summary-expire-articles (&optional now)
8203 "Expire all articles that are marked as expirable in the current group."
8205 (when (gnus-check-backend-function
8206 'request-expire-articles gnus-newsgroup-name)
8207 ;; This backend supports expiry.
8208 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8209 (expirable (if total
8211 ;; We need to update the info for
8212 ;; this group for `gnus-list-of-read-articles'
8213 ;; to give us the right answer.
8214 (gnus-run-hooks 'gnus-exit-group-hook)
8215 (gnus-summary-update-info)
8216 (gnus-list-of-read-articles gnus-newsgroup-name))
8217 (setq gnus-newsgroup-expirable
8218 (sort gnus-newsgroup-expirable '<))))
8219 (expiry-wait (if now 'immediate
8220 (gnus-group-find-parameter
8221 gnus-newsgroup-name 'expiry-wait)))
8222 (nnmail-expiry-target
8223 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8224 nnmail-expiry-target))
8227 ;; There are expirable articles in this group, so we run them
8228 ;; through the expiry process.
8229 (gnus-message 6 "Expiring articles...")
8230 (unless (gnus-check-group gnus-newsgroup-name)
8231 (error "Can't open server for %s" gnus-newsgroup-name))
8232 ;; The list of articles that weren't expired is returned.
8235 (let ((nnmail-expiry-wait-function nil)
8236 (nnmail-expiry-wait expiry-wait))
8237 (setq es (gnus-request-expire-articles
8238 expirable gnus-newsgroup-name)))
8239 (setq es (gnus-request-expire-articles
8240 expirable gnus-newsgroup-name)))
8242 (setq gnus-newsgroup-expirable es))
8243 ;; We go through the old list of expirable, and mark all
8244 ;; really expired articles as nonexistent.
8245 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8246 (let ((gnus-use-cache nil))
8248 (unless (memq (car expirable) es)
8249 (when (gnus-data-find (car expirable))
8250 (gnus-summary-mark-article
8251 (car expirable) gnus-canceled-mark)))
8252 (setq expirable (cdr expirable))))))
8253 (gnus-message 6 "Expiring articles...done")))))
8255 (defun gnus-summary-expire-articles-now ()
8256 "Expunge all expirable articles in the current group.
8257 This means that *all* articles that are marked as expirable will be
8258 deleted forever, right now."
8260 (or gnus-expert-user
8262 "Are you really, really, really sure you want to delete all these messages? ")
8264 (gnus-summary-expire-articles t))
8266 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8267 (defun gnus-summary-delete-article (&optional n)
8268 "Delete the N next (mail) articles.
8269 This command actually deletes articles. This is not a marking
8270 command. The article will disappear forever from your life, never to
8272 If N is negative, delete backwards.
8273 If N is nil and articles have been marked with the process mark,
8274 delete these instead."
8276 (unless (gnus-check-backend-function 'request-expire-articles
8277 gnus-newsgroup-name)
8278 (error "The current newsgroup does not support article deletion"))
8279 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8280 (error "Couldn't open server"))
8281 ;; Compute the list of articles to delete.
8282 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8284 (if (and gnus-novice-user
8285 (not (gnus-yes-or-no-p
8286 (format "Do you really want to delete %s forever? "
8287 (if (> (length articles) 1)
8288 (format "these %s articles" (length articles))
8291 ;; Delete the articles.
8292 (setq not-deleted (gnus-request-expire-articles
8293 articles gnus-newsgroup-name 'force))
8295 (gnus-summary-remove-process-mark (car articles))
8296 ;; The backend might not have been able to delete the article
8298 (unless (memq (car articles) not-deleted)
8299 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8300 (setq articles (cdr articles)))
8302 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8303 (gnus-summary-position-point)
8304 (gnus-set-mode-line 'summary)
8307 (defun gnus-summary-edit-article (&optional force)
8308 "Edit the current article.
8309 This will have permanent effect only in mail groups.
8310 If FORCE is non-nil, allow editing of articles even in read-only
8314 (set-buffer gnus-summary-buffer)
8315 (let ((mail-parse-charset gnus-newsgroup-charset)
8316 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8317 (gnus-set-global-variables)
8318 (when (and (not force)
8319 (gnus-group-read-only-p))
8320 (error "The current newsgroup does not support article editing"))
8321 (gnus-summary-show-article t)
8322 (gnus-article-edit-article
8324 `(lambda (no-highlight)
8325 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8326 (message-options message-options)
8327 (message-options-set-recipient)
8328 (mail-parse-ignored-charsets
8329 ',gnus-newsgroup-ignored-charsets))
8330 (gnus-summary-edit-article-done
8331 ,(or (mail-header-references gnus-current-headers) "")
8332 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8334 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8336 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8338 "Make edits to the current article permanent."
8341 ;; The buffer restriction contains the entire article if it exists.
8342 (when (article-goto-body)
8343 (let ((lines (count-lines (point) (point-max)))
8344 (length (- (point-max) (point)))
8345 (case-fold-search t)
8346 (body (copy-marker (point))))
8347 (goto-char (point-min))
8348 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8349 (delete-region (match-beginning 1) (match-end 1))
8350 (insert (number-to-string length)))
8351 (goto-char (point-min))
8352 (when (re-search-forward
8353 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8354 (delete-region (match-beginning 1) (match-end 1))
8355 (insert (number-to-string length)))
8356 (goto-char (point-min))
8357 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8358 (delete-region (match-beginning 1) (match-end 1))
8359 (insert (number-to-string lines))))))
8360 ;; Replace the article.
8361 (let ((buf (current-buffer)))
8363 (insert-buffer-substring buf)
8365 (if (and (not read-only)
8366 (not (gnus-request-replace-article
8367 (cdr gnus-article-current) (car gnus-article-current)
8368 (current-buffer) t)))
8369 (error "Couldn't replace article")
8370 ;; Update the summary buffer.
8372 (equal (message-tokenize-header references " ")
8373 (message-tokenize-header
8374 (or (message-fetch-field "references") "") " ")))
8375 ;; We only have to update this line.
8378 (message-narrow-to-head)
8379 (let ((head (buffer-string))
8382 (insert (format "211 %d Article retrieved.\n"
8383 (cdr gnus-article-current)))
8386 (let ((nntp-server-buffer (current-buffer)))
8387 (setq header (car (gnus-get-newsgroup-headers
8389 (set-buffer gnus-summary-buffer)
8390 gnus-newsgroup-dependencies)
8393 (set-buffer gnus-summary-buffer)
8394 (gnus-data-set-header
8395 (gnus-data-find (cdr gnus-article-current))
8397 (gnus-summary-update-article-line
8398 (cdr gnus-article-current) header))))))
8400 (set-buffer (or buffer gnus-summary-buffer))
8401 (gnus-summary-update-article (cdr gnus-article-current)))
8402 ;; Prettify the article buffer again.
8403 (unless no-highlight
8405 (set-buffer gnus-article-buffer)
8406 ;;;!!! Fix this -- article should be rehighlighted.
8407 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8408 (set-buffer gnus-original-article-buffer)
8409 (gnus-request-article
8410 (cdr gnus-article-current)
8411 (car gnus-article-current) (current-buffer))))
8412 ;; Prettify the summary buffer line.
8413 (when (gnus-visual-p 'summary-highlight 'highlight)
8414 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8416 (defun gnus-summary-edit-wash (key)
8417 "Perform editing command KEY in the article buffer."
8421 (message "%s" (concat (this-command-keys) "- "))
8424 (gnus-summary-edit-article)
8425 (execute-kbd-macro (concat (this-command-keys) key))
8426 (gnus-article-edit-done))
8430 (defun gnus-summary-respool-query (&optional silent trace)
8431 "Query where the respool algorithm would put this article."
8433 (let (gnus-mark-article-hook)
8434 (gnus-summary-select-article)
8436 (set-buffer gnus-original-article-buffer)
8438 (message-narrow-to-head)
8439 (let ((groups (nnmail-article-group 'identity trace)))
8442 (message "This message would go to %s"
8443 (mapconcat 'car groups ", "))
8444 (message "This message would go to no groups"))
8447 (defun gnus-summary-respool-trace ()
8448 "Trace where the respool algorithm would put this article.
8449 Display a buffer showing all fancy splitting patterns which matched."
8451 (gnus-summary-respool-query nil t))
8453 ;; Summary marking commands.
8455 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8456 "Mark articles which has the same subject as read, and then select the next.
8457 If UNMARK is positive, remove any kind of mark.
8458 If UNMARK is negative, tick articles."
8461 (setq unmark (prefix-numeric-value unmark)))
8463 (gnus-summary-mark-same-subject
8464 (gnus-summary-article-subject) unmark)))
8465 ;; Select next unread article. If auto-select-same mode, should
8466 ;; select the first unread article.
8467 (gnus-summary-next-article t (and gnus-auto-select-same
8468 (gnus-summary-article-subject)))
8469 (gnus-message 7 "%d article%s marked as %s"
8470 count (if (= count 1) " is" "s are")
8471 (if unmark "unread" "read"))))
8473 (defun gnus-summary-kill-same-subject (&optional unmark)
8474 "Mark articles which has the same subject as read.
8475 If UNMARK is positive, remove any kind of mark.
8476 If UNMARK is negative, tick articles."
8479 (setq unmark (prefix-numeric-value unmark)))
8481 (gnus-summary-mark-same-subject
8482 (gnus-summary-article-subject) unmark)))
8483 ;; If marked as read, go to next unread subject.
8485 ;; Go to next unread subject.
8486 (gnus-summary-next-subject 1 t))
8487 (gnus-message 7 "%d articles are marked as %s"
8488 count (if unmark "unread" "read"))))
8490 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8491 "Mark articles with same SUBJECT as read, and return marked number.
8492 If optional argument UNMARK is positive, remove any kinds of marks.
8493 If optional argument UNMARK is negative, mark articles as unread instead."
8497 ((null unmark) ; Mark as read.
8500 (gnus-summary-mark-article-as-read gnus-killed-mark)
8501 (gnus-summary-show-thread) t)
8502 (gnus-summary-find-subject subject))
8503 (setq count (1+ count))))
8504 ((> unmark 0) ; Tick.
8507 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8508 (gnus-summary-show-thread) t)
8509 (gnus-summary-find-subject subject))
8510 (setq count (1+ count))))
8511 (t ; Mark as unread.
8514 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8515 (gnus-summary-show-thread) t)
8516 (gnus-summary-find-subject subject))
8517 (setq count (1+ count)))))
8518 (gnus-set-mode-line 'summary)
8519 ;; Return the number of marked articles.
8522 (defun gnus-summary-mark-as-processable (n &optional unmark)
8523 "Set the process mark on the next N articles.
8524 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8525 the process mark instead. The difference between N and the actual
8526 number of articles marked is returned."
8528 (if (and (null n) (gnus-region-active-p))
8529 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8530 (setq n (prefix-numeric-value n))
8531 (let ((backward (< n 0))
8536 (gnus-summary-remove-process-mark
8537 (gnus-summary-article-number))
8538 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8539 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8542 (gnus-message 7 "No more articles"))
8543 (gnus-summary-recenter)
8544 (gnus-summary-position-point)
8547 (defun gnus-summary-unmark-as-processable (n)
8548 "Remove the process mark from the next N articles.
8549 If N is negative, unmark backward instead. The difference between N and
8550 the actual number of articles unmarked is returned."
8552 (gnus-summary-mark-as-processable n t))
8554 (defun gnus-summary-unmark-all-processable ()
8555 "Remove the process mark from all articles."
8558 (while gnus-newsgroup-processable
8559 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8560 (gnus-summary-position-point))
8562 (defun gnus-summary-add-mark (article type)
8563 "Mark ARTICLE with a mark of TYPE."
8564 (let ((vtype (car (assq type gnus-article-mark-lists)))
8567 (error "No such mark type: %s" type)
8568 (setq var (intern (format "gnus-newsgroup-%s" type)))
8569 (set var (cons article (symbol-value var)))
8570 (if (memq type '(processable cached replied forwarded saved))
8571 (gnus-summary-update-secondary-mark article)
8572 ;;; !!! This is bobus. We should find out what primary
8573 ;;; !!! mark we want to set.
8574 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8576 (defun gnus-summary-mark-as-expirable (n)
8577 "Mark N articles forward as expirable.
8578 If N is negative, mark backward instead. The difference between N and
8579 the actual number of articles marked is returned."
8581 (gnus-summary-mark-forward n gnus-expirable-mark))
8583 (defun gnus-summary-mark-article-as-replied (article)
8584 "Mark ARTICLE as replied to and update the summary line.
8585 ARTICLE can also be a list of articles."
8586 (interactive (list (gnus-summary-article-number)))
8587 (let ((articles (if (listp article) article (list article))))
8588 (dolist (article articles)
8589 (push article gnus-newsgroup-replied)
8590 (let ((buffer-read-only nil))
8591 (when (gnus-summary-goto-subject article nil t)
8592 (gnus-summary-update-secondary-mark article))))))
8594 (defun gnus-summary-mark-article-as-forwarded (article)
8595 "Mark ARTICLE as forwarded and update the summary line.
8596 ARTICLE can also be a list of articles."
8597 (let ((articles (if (listp article) article (list article))))
8598 (dolist (article articles)
8599 (push article gnus-newsgroup-forwarded)
8600 (let ((buffer-read-only nil))
8601 (when (gnus-summary-goto-subject article nil t)
8602 (gnus-summary-update-secondary-mark article))))))
8604 (defun gnus-summary-set-bookmark (article)
8605 "Set a bookmark in current article."
8606 (interactive (list (gnus-summary-article-number)))
8607 (when (or (not (get-buffer gnus-article-buffer))
8608 (not gnus-current-article)
8609 (not gnus-article-current)
8610 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8611 (error "No current article selected"))
8612 ;; Remove old bookmark, if one exists.
8613 (let ((old (assq article gnus-newsgroup-bookmarks)))
8615 (setq gnus-newsgroup-bookmarks
8616 (delq old gnus-newsgroup-bookmarks))))
8617 ;; Set the new bookmark, which is on the form
8618 ;; (article-number . line-number-in-body).
8622 (set-buffer gnus-article-buffer)
8626 (goto-char (point-min))
8627 (search-forward "\n\n" nil t)
8630 gnus-newsgroup-bookmarks)
8631 (gnus-message 6 "A bookmark has been added to the current article."))
8633 (defun gnus-summary-remove-bookmark (article)
8634 "Remove the bookmark from the current article."
8635 (interactive (list (gnus-summary-article-number)))
8636 ;; Remove old bookmark, if one exists.
8637 (let ((old (assq article gnus-newsgroup-bookmarks)))
8640 (setq gnus-newsgroup-bookmarks
8641 (delq old gnus-newsgroup-bookmarks))
8642 (gnus-message 6 "Removed bookmark."))
8643 (gnus-message 6 "No bookmark in current article."))))
8645 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8646 (defun gnus-summary-mark-as-dormant (n)
8647 "Mark N articles forward as dormant.
8648 If N is negative, mark backward instead. The difference between N and
8649 the actual number of articles marked is returned."
8651 (gnus-summary-mark-forward n gnus-dormant-mark))
8653 (defun gnus-summary-set-process-mark (article)
8654 "Set the process mark on ARTICLE and update the summary line."
8655 (setq gnus-newsgroup-processable
8657 (delq article gnus-newsgroup-processable)))
8658 (when (gnus-summary-goto-subject article)
8659 (gnus-summary-show-thread)
8660 (gnus-summary-goto-subject article)
8661 (gnus-summary-update-secondary-mark article)))
8663 (defun gnus-summary-remove-process-mark (article)
8664 "Remove the process mark from ARTICLE and update the summary line."
8665 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8666 (when (gnus-summary-goto-subject article)
8667 (gnus-summary-show-thread)
8668 (gnus-summary-goto-subject article)
8669 (gnus-summary-update-secondary-mark article)))
8671 (defun gnus-summary-set-saved-mark (article)
8672 "Set the process mark on ARTICLE and update the summary line."
8673 (push article gnus-newsgroup-saved)
8674 (when (gnus-summary-goto-subject article)
8675 (gnus-summary-update-secondary-mark article)))
8677 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8678 "Mark N articles as read forwards.
8679 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8680 The difference between N and the actual number of articles marked is
8682 Iff NO-EXPIRE, auto-expiry will be inhibited."
8684 (gnus-summary-show-thread)
8685 (let ((backward (< n 0))
8686 (gnus-summary-goto-unread
8687 (and gnus-summary-goto-unread
8688 (not (eq gnus-summary-goto-unread 'never))
8689 (not (memq mark (list gnus-unread-mark
8690 gnus-ticked-mark gnus-dormant-mark)))))
8692 (mark (or mark gnus-del-mark)))
8694 (gnus-summary-mark-article nil mark no-expire)
8695 (zerop (gnus-summary-next-subject
8697 (and gnus-summary-goto-unread
8698 (not (eq gnus-summary-goto-unread 'never)))
8702 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8703 (gnus-summary-recenter)
8704 (gnus-summary-position-point)
8705 (gnus-set-mode-line 'summary)
8708 (defun gnus-summary-mark-article-as-read (mark)
8709 "Mark the current article quickly as read with MARK."
8710 (let ((article (gnus-summary-article-number)))
8711 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8712 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8713 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8714 (push (cons article mark) gnus-newsgroup-reads)
8715 ;; Possibly remove from cache, if that is used.
8716 (when gnus-use-cache
8717 (gnus-cache-enter-remove-article article))
8718 ;; Allow the backend to change the mark.
8719 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8720 ;; Check for auto-expiry.
8721 (when (and gnus-newsgroup-auto-expire
8722 (memq mark gnus-auto-expirable-marks))
8723 (setq mark gnus-expirable-mark)
8724 ;; Let the backend know about the mark change.
8725 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8726 (push article gnus-newsgroup-expirable))
8727 ;; Set the mark in the buffer.
8728 (gnus-summary-update-mark mark 'unread)
8731 (defun gnus-summary-mark-article-as-unread (mark)
8732 "Mark the current article quickly as unread with MARK."
8733 (let* ((article (gnus-summary-article-number))
8734 (old-mark (gnus-summary-article-mark article)))
8735 ;; Allow the backend to change the mark.
8736 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8737 (if (eq mark old-mark)
8741 (gnus-error 1 "Can't mark negative article numbers")
8743 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8744 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8745 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8746 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8747 (cond ((= mark gnus-ticked-mark)
8748 (push article gnus-newsgroup-marked))
8749 ((= mark gnus-dormant-mark)
8750 (push article gnus-newsgroup-dormant))
8752 (push article gnus-newsgroup-unreads)))
8753 (gnus-pull article gnus-newsgroup-reads)
8755 ;; See whether the article is to be put in the cache.
8757 (vectorp (gnus-summary-article-header article))
8759 (gnus-cache-possibly-enter-article
8760 gnus-newsgroup-name article
8761 (gnus-summary-article-header article)
8762 (= mark gnus-ticked-mark)
8763 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8766 (gnus-summary-update-mark mark 'unread)
8769 (defun gnus-summary-mark-article (&optional article mark no-expire)
8770 "Mark ARTICLE with MARK. MARK can be any character.
8771 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8772 `??' (dormant) and `?E' (expirable).
8773 If MARK is nil, then the default character `?r' is used.
8774 If ARTICLE is nil, then the article on the current line will be
8776 Iff NO-EXPIRE, auto-expiry will be inhibited."
8777 ;; The mark might be a string.
8778 (when (stringp mark)
8779 (setq mark (aref mark 0)))
8780 ;; If no mark is given, then we check auto-expiring.
8782 (setq mark gnus-del-mark))
8783 (when (and (not no-expire)
8784 gnus-newsgroup-auto-expire
8785 (memq mark gnus-auto-expirable-marks))
8786 (setq mark gnus-expirable-mark))
8787 (let ((article (or article (gnus-summary-article-number)))
8788 (old-mark (gnus-summary-article-mark article)))
8789 ;; Allow the backend to change the mark.
8790 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8791 (if (eq mark old-mark)
8794 (error "No article on current line"))
8795 (if (not (if (or (= mark gnus-unread-mark)
8796 (= mark gnus-ticked-mark)
8797 (= mark gnus-dormant-mark))
8798 (gnus-mark-article-as-unread article mark)
8799 (gnus-mark-article-as-read article mark)))
8801 ;; See whether the article is to be put in the cache.
8803 (not (= mark gnus-canceled-mark))
8804 (vectorp (gnus-summary-article-header article))
8806 (gnus-cache-possibly-enter-article
8807 gnus-newsgroup-name article
8808 (gnus-summary-article-header article)
8809 (= mark gnus-ticked-mark)
8810 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8812 (when (gnus-summary-goto-subject article nil t)
8813 (let ((buffer-read-only nil))
8814 (gnus-summary-show-thread)
8816 (gnus-summary-update-mark mark 'unread)
8819 (defun gnus-summary-update-secondary-mark (article)
8820 "Update the secondary (read, process, cache) mark."
8821 (gnus-summary-update-mark
8822 (cond ((memq article gnus-newsgroup-processable)
8824 ((memq article gnus-newsgroup-cached)
8826 ((memq article gnus-newsgroup-replied)
8828 ((memq article gnus-newsgroup-forwarded)
8829 gnus-forwarded-mark)
8830 ((memq article gnus-newsgroup-saved)
8834 (when (gnus-visual-p 'summary-highlight 'highlight)
8835 (gnus-run-hooks 'gnus-summary-update-hook))
8838 (defun gnus-summary-update-mark (mark type)
8839 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8840 (buffer-read-only nil))
8841 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8843 (when (looking-at "\r")
8845 (when (<= (+ forward (point)) (point-max))
8846 ;; Go to the right position on the line.
8847 (goto-char (+ forward (point)))
8848 ;; Replace the old mark with the new mark.
8849 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8850 ;; Optionally update the marks by some user rule.
8851 (when (eq type 'unread)
8853 (gnus-data-find (gnus-summary-article-number)) mark)
8854 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8856 (defun gnus-mark-article-as-read (article &optional mark)
8857 "Enter ARTICLE in the pertinent lists and remove it from others."
8858 ;; Make the article expirable.
8859 (let ((mark (or mark gnus-del-mark)))
8860 (if (= mark gnus-expirable-mark)
8861 (push article gnus-newsgroup-expirable)
8862 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8863 ;; Remove from unread and marked lists.
8864 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8865 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8866 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8867 (push (cons article mark) gnus-newsgroup-reads)
8868 ;; Possibly remove from cache, if that is used.
8869 (when gnus-use-cache
8870 (gnus-cache-enter-remove-article article))
8873 (defun gnus-mark-article-as-unread (article &optional mark)
8874 "Enter ARTICLE in the pertinent lists and remove it from others."
8875 (let ((mark (or mark gnus-ticked-mark)))
8878 (gnus-error 1 "Can't mark negative article numbers")
8880 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8881 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8882 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8883 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8885 ;; Unsuppress duplicates?
8886 (when gnus-suppress-duplicates
8887 (gnus-dup-unsuppress-article article))
8889 (cond ((= mark gnus-ticked-mark)
8890 (push article gnus-newsgroup-marked))
8891 ((= mark gnus-dormant-mark)
8892 (push article gnus-newsgroup-dormant))
8894 (push article gnus-newsgroup-unreads)))
8895 (gnus-pull article gnus-newsgroup-reads)
8898 (defalias 'gnus-summary-mark-as-unread-forward
8899 'gnus-summary-tick-article-forward)
8900 (make-obsolete 'gnus-summary-mark-as-unread-forward
8901 'gnus-summary-tick-article-forward)
8902 (defun gnus-summary-tick-article-forward (n)
8903 "Tick N articles forwards.
8904 If N is negative, tick backwards instead.
8905 The difference between N and the number of articles ticked is returned."
8907 (gnus-summary-mark-forward n gnus-ticked-mark))
8909 (defalias 'gnus-summary-mark-as-unread-backward
8910 'gnus-summary-tick-article-backward)
8911 (make-obsolete 'gnus-summary-mark-as-unread-backward
8912 'gnus-summary-tick-article-backward)
8913 (defun gnus-summary-tick-article-backward (n)
8914 "Tick N articles backwards.
8915 The difference between N and the number of articles ticked is returned."
8917 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8919 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8920 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8921 (defun gnus-summary-tick-article (&optional article clear-mark)
8922 "Mark current article as unread.
8923 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8924 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8926 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8929 (defun gnus-summary-mark-as-read-forward (n)
8930 "Mark N articles as read forwards.
8931 If N is negative, mark backwards instead.
8932 The difference between N and the actual number of articles marked is
8935 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8937 (defun gnus-summary-mark-as-read-backward (n)
8938 "Mark the N articles as read backwards.
8939 The difference between N and the actual number of articles marked is
8942 (gnus-summary-mark-forward
8943 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8945 (defun gnus-summary-mark-as-read (&optional article mark)
8946 "Mark current article as read.
8947 ARTICLE specifies the article to be marked as read.
8948 MARK specifies a string to be inserted at the beginning of the line."
8949 (gnus-summary-mark-article article mark))
8951 (defun gnus-summary-clear-mark-forward (n)
8952 "Clear marks from N articles forward.
8953 If N is negative, clear backward instead.
8954 The difference between N and the number of marks cleared is returned."
8956 (gnus-summary-mark-forward n gnus-unread-mark))
8958 (defun gnus-summary-clear-mark-backward (n)
8959 "Clear marks from N articles backward.
8960 The difference between N and the number of marks cleared is returned."
8962 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8964 (defun gnus-summary-mark-unread-as-read ()
8965 "Intended to be used by `gnus-summary-mark-article-hook'."
8966 (when (memq gnus-current-article gnus-newsgroup-unreads)
8967 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8969 (defun gnus-summary-mark-read-and-unread-as-read ()
8970 "Intended to be used by `gnus-summary-mark-article-hook'."
8971 (let ((mark (gnus-summary-article-mark)))
8972 (when (or (gnus-unread-mark-p mark)
8973 (gnus-read-mark-p mark))
8974 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8976 (defun gnus-summary-mark-unread-as-ticked ()
8977 "Intended to be used by `gnus-summary-mark-article-hook'."
8978 (when (memq gnus-current-article gnus-newsgroup-unreads)
8979 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8981 (defun gnus-summary-mark-region-as-read (point mark all)
8982 "Mark all unread articles between point and mark as read.
8983 If given a prefix, mark all articles between point and mark as read,
8984 even ticked and dormant ones."
8985 (interactive "r\nP")
8994 (memq (setq article (gnus-summary-article-number))
8995 gnus-newsgroup-unreads))
8996 (gnus-summary-mark-article article gnus-del-mark))
8998 (gnus-summary-find-next))))))
9000 (defun gnus-summary-mark-below (score mark)
9001 "Mark articles with score less than SCORE with MARK."
9002 (interactive "P\ncMark: ")
9003 (setq score (if score
9004 (prefix-numeric-value score)
9005 (or gnus-summary-default-score 0)))
9007 (set-buffer gnus-summary-buffer)
9008 (goto-char (point-min))
9011 (and (< (gnus-summary-article-score) score)
9012 (gnus-summary-mark-article nil mark))
9013 (gnus-summary-find-next)))))
9015 (defun gnus-summary-kill-below (&optional score)
9016 "Mark articles with score below SCORE as read."
9018 (gnus-summary-mark-below score gnus-killed-mark))
9020 (defun gnus-summary-clear-above (&optional score)
9021 "Clear all marks from articles with score above SCORE."
9023 (gnus-summary-mark-above score gnus-unread-mark))
9025 (defun gnus-summary-tick-above (&optional score)
9026 "Tick all articles with score above SCORE."
9028 (gnus-summary-mark-above score gnus-ticked-mark))
9030 (defun gnus-summary-mark-above (score mark)
9031 "Mark articles with score over SCORE with MARK."
9032 (interactive "P\ncMark: ")
9033 (setq score (if score
9034 (prefix-numeric-value score)
9035 (or gnus-summary-default-score 0)))
9037 (set-buffer gnus-summary-buffer)
9038 (goto-char (point-min))
9040 (when (> (gnus-summary-article-score) score)
9041 (gnus-summary-mark-article nil mark))
9043 (gnus-summary-find-next)))))
9045 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9046 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9047 (defun gnus-summary-limit-include-expunged (&optional no-error)
9048 "Display all the hidden articles that were expunged for low scores."
9050 (let ((buffer-read-only nil))
9051 (let ((scored gnus-newsgroup-scored)
9054 (unless (gnus-summary-article-header (caar scored))
9055 (and (setq h (gnus-number-to-header (caar scored)))
9056 (< (cdar scored) gnus-summary-expunge-below)
9058 (setq scored (cdr scored)))
9060 (when (not no-error)
9061 (error "No expunged articles hidden"))
9062 (goto-char (point-min))
9063 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9064 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9065 (mapcar (lambda (x) (push (mail-header-number x)
9066 gnus-newsgroup-limit))
9068 (gnus-summary-prepare-unthreaded (nreverse headers))
9069 (goto-char (point-min))
9070 (gnus-summary-position-point)
9073 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9074 "Mark all unread articles in this newsgroup as read.
9075 If prefix argument ALL is non-nil, ticked and dormant articles will
9076 also be marked as read.
9077 If QUIETLY is non-nil, no questions will be asked.
9078 If TO-HERE is non-nil, it should be a point in the buffer. All
9079 articles before this point will be marked as read.
9080 Note that this function will only catch up the unread article
9081 in the current summary buffer limitation.
9082 The number of articles marked as read is returned."
9087 (not gnus-interactive-catchup) ;Without confirmation?
9091 "Mark absolutely all articles as read? "
9092 "Mark all unread articles as read? ")))
9094 (not gnus-newsgroup-adaptive)
9095 (not gnus-newsgroup-auto-expire)
9096 (not gnus-suppress-duplicates)
9097 (or (not gnus-use-cache)
9098 (eq gnus-use-cache 'passive)))
9101 (setq gnus-newsgroup-marked nil
9102 gnus-newsgroup-dormant nil))
9103 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9104 ;; We actually mark all articles as canceled, which we
9105 ;; have to do when using auto-expiry or adaptive scoring.
9106 (gnus-summary-show-all-threads)
9107 (when (gnus-summary-first-subject (not all) t)
9109 (if to-here (< (point) to-here) t)
9110 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9111 (gnus-summary-find-next (not all) nil nil t))))
9112 (gnus-set-mode-line 'summary))
9114 (gnus-summary-position-point)))
9116 (defun gnus-summary-catchup-to-here (&optional all)
9117 "Mark all unticked articles before the current one as read.
9118 If ALL is non-nil, also mark ticked and dormant articles as read."
9121 (gnus-save-hidden-threads
9122 (let ((beg (point)))
9123 ;; We check that there are unread articles.
9124 (when (or all (gnus-summary-find-prev))
9125 (gnus-summary-catchup all t beg)))))
9126 (gnus-summary-position-point))
9128 (defun gnus-summary-catchup-all (&optional quietly)
9129 "Mark all articles in this newsgroup as read."
9131 (gnus-summary-catchup t quietly))
9133 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9134 "Mark all unread articles in this group as read, then exit.
9135 If prefix argument ALL is non-nil, all articles are marked as read.
9136 If QUIETLY is non-nil, no questions will be asked."
9138 (when (gnus-summary-catchup all quietly nil 'fast)
9139 ;; Select next newsgroup or exit.
9140 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9141 (eq gnus-auto-select-next 'quietly))
9142 (gnus-summary-next-group nil)
9143 (gnus-summary-exit))))
9145 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9146 "Mark all articles in this newsgroup as read, and then exit."
9148 (gnus-summary-catchup-and-exit t quietly))
9150 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9151 "Mark all articles in this group as read and select the next group.
9152 If given a prefix, mark all articles, unread as well as ticked, as
9156 (gnus-summary-catchup all))
9157 (gnus-summary-next-group))
9163 (defmacro gnus-with-article (article &rest forms)
9164 "Select ARTICLE and perform FORMS in the original article buffer.
9165 Then replace the article with the result."
9167 ;; We don't want the article to be marked as read.
9168 (let (gnus-mark-article-hook)
9169 (gnus-summary-select-article t t nil ,article))
9170 (set-buffer gnus-original-article-buffer)
9172 (if (not (gnus-check-backend-function
9173 'request-replace-article (car gnus-article-current)))
9174 (gnus-message 5 "Read-only group; not replacing")
9175 (unless (gnus-request-replace-article
9176 ,article (car gnus-article-current)
9178 (error "Couldn't replace article")))
9179 ;; The cache and backlog have to be flushed somewhat.
9180 (when gnus-keep-backlog
9181 (gnus-backlog-remove-article
9182 (car gnus-article-current) (cdr gnus-article-current)))
9183 (when gnus-use-cache
9184 (gnus-cache-update-article
9185 (car gnus-article-current) (cdr gnus-article-current)))))
9187 (put 'gnus-with-article 'lisp-indent-function 1)
9188 (put 'gnus-with-article 'edebug-form-spec '(form body))
9190 ;; Thread-based commands.
9192 (defun gnus-summary-articles-in-thread (&optional article)
9193 "Return a list of all articles in the current thread.
9194 If ARTICLE is non-nil, return all articles in the thread that starts
9196 (let* ((article (or article (gnus-summary-article-number)))
9197 (data (gnus-data-find-list article))
9198 (top-level (gnus-data-level (car data)))
9200 (cond ((null gnus-thread-operation-ignore-subject)
9201 (gnus-simplify-subject-re
9202 (mail-header-subject (gnus-data-header (car data)))))
9203 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9204 (gnus-simplify-subject-fuzzy
9205 (mail-header-subject (gnus-data-header (car data)))))
9207 (end-point (save-excursion
9208 (if (gnus-summary-go-to-next-thread)
9209 (point) (point-max))))
9212 (< (gnus-data-pos (car data)) end-point))
9213 (when (or (not top-subject)
9214 (string= top-subject
9215 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9216 (gnus-simplify-subject-fuzzy
9217 (mail-header-subject
9218 (gnus-data-header (car data))))
9219 (gnus-simplify-subject-re
9220 (mail-header-subject
9221 (gnus-data-header (car data)))))))
9222 (push (gnus-data-number (car data)) articles))
9223 (unless (and (setq data (cdr data))
9224 (> (gnus-data-level (car data)) top-level))
9226 ;; Return the list of articles.
9227 (nreverse articles)))
9229 (defun gnus-summary-rethread-current ()
9230 "Rethread the thread the current article is part of."
9232 (let* ((gnus-show-threads t)
9233 (article (gnus-summary-article-number))
9234 (id (mail-header-id (gnus-summary-article-header)))
9235 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9237 (error "No article on the current line"))
9238 (gnus-rebuild-thread id)
9239 (gnus-summary-goto-subject article)))
9241 (defun gnus-summary-reparent-thread ()
9242 "Make the current article child of the marked (or previous) article.
9244 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9245 is non-nil or the Subject: of both articles are the same."
9247 (unless (not (gnus-group-read-only-p))
9248 (error "The current newsgroup does not support article editing"))
9249 (unless (<= (length gnus-newsgroup-processable) 1)
9250 (error "No more than one article may be marked"))
9251 (save-window-excursion
9252 (let ((gnus-article-buffer " *reparent*")
9253 (current-article (gnus-summary-article-number))
9254 ;; First grab the marked article, otherwise one line up.
9255 (parent-article (if (not (null gnus-newsgroup-processable))
9256 (car gnus-newsgroup-processable)
9258 (if (eq (forward-line -1) 0)
9259 (gnus-summary-article-number)
9260 (error "Beginning of summary buffer"))))))
9261 (unless (not (eq current-article parent-article))
9262 (error "An article may not be self-referential"))
9263 (let ((message-id (mail-header-id
9264 (gnus-summary-article-header parent-article))))
9265 (unless (and message-id (not (equal message-id "")))
9266 (error "No message-id in desired parent"))
9267 (gnus-with-article current-article
9269 (goto-char (point-min))
9270 (message-narrow-to-head)
9271 (if (re-search-forward "^References: " nil t)
9273 (re-search-forward "^[^ \t]" nil t)
9276 (insert " " message-id))
9277 (insert "References: " message-id "\n"))))
9278 (set-buffer gnus-summary-buffer)
9279 (gnus-summary-unmark-all-processable)
9280 (gnus-summary-update-article current-article)
9281 (gnus-summary-rethread-current)
9282 (gnus-message 3 "Article %d is now the child of article %d"
9283 current-article parent-article)))))
9285 (defun gnus-summary-toggle-threads (&optional arg)
9286 "Toggle showing conversation threads.
9287 If ARG is positive number, turn showing conversation threads on."
9289 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9290 (setq gnus-show-threads
9291 (if (null arg) (not gnus-show-threads)
9292 (> (prefix-numeric-value arg) 0)))
9293 (gnus-summary-prepare)
9294 (gnus-summary-goto-subject current)
9295 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9296 (gnus-summary-position-point)))
9298 (defun gnus-summary-show-all-threads ()
9302 (let ((buffer-read-only nil))
9303 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9304 (gnus-summary-position-point))
9306 (defun gnus-summary-show-thread ()
9307 "Show thread subtrees.
9308 Returns nil if no thread was there to be shown."
9310 (let ((buffer-read-only nil)
9312 ;; first goto end then to beg, to have point at beg after let
9313 (end (progn (end-of-line) (point)))
9314 (beg (progn (beginning-of-line) (point))))
9316 ;; Any hidden lines here?
9317 (search-forward "\r" end t)
9318 (subst-char-in-region beg end ?\^M ?\n t)
9320 (gnus-summary-position-point))))
9322 (defun gnus-summary-hide-all-threads ()
9323 "Hide all thread subtrees."
9326 (goto-char (point-min))
9327 (gnus-summary-hide-thread)
9328 (while (zerop (gnus-summary-next-thread 1 t))
9329 (gnus-summary-hide-thread)))
9330 (gnus-summary-position-point))
9332 (defun gnus-summary-hide-thread ()
9333 "Hide thread subtrees.
9334 Returns nil if no threads were there to be hidden."
9336 (let ((buffer-read-only nil)
9338 (article (gnus-summary-article-number)))
9340 ;; Go forward until either the buffer ends or the subthread
9342 (when (and (not (eobp))
9343 (or (zerop (gnus-summary-next-thread 1 t))
9344 (goto-char (point-max))))
9346 (if (and (> (point) start)
9347 (search-backward "\n" start t))
9349 (subst-char-in-region start (point) ?\n ?\^M)
9350 (gnus-summary-goto-subject article))
9354 (defun gnus-summary-go-to-next-thread (&optional previous)
9355 "Go to the same level (or less) next thread.
9356 If PREVIOUS is non-nil, go to previous thread instead.
9357 Return the article number moved to, or nil if moving was impossible."
9358 (let ((level (gnus-summary-thread-level))
9359 (way (if previous -1 1))
9362 (while (and (not (eobp))
9363 (< level (gnus-summary-thread-level)))
9371 (gnus-summary-article-number)
9374 (defun gnus-summary-next-thread (n &optional silent)
9375 "Go to the same level next N'th thread.
9376 If N is negative, search backward instead.
9377 Returns the difference between N and the number of skips actually
9380 If SILENT, don't output messages."
9382 (let ((backward (< n 0))
9385 (gnus-summary-go-to-next-thread backward))
9388 (gnus-summary-position-point))
9389 (when (and (not silent) (/= 0 n))
9390 (gnus-message 7 "No more threads"))
9393 (defun gnus-summary-prev-thread (n)
9394 "Go to the same level previous N'th thread.
9395 Returns the difference between N and the number of skips actually
9398 (gnus-summary-next-thread (- n)))
9400 (defun gnus-summary-go-down-thread ()
9401 "Go down one level in the current thread."
9402 (let ((children (gnus-summary-article-children)))
9404 (gnus-summary-goto-subject (car children)))))
9406 (defun gnus-summary-go-up-thread ()
9407 "Go up one level in the current thread."
9408 (let ((parent (gnus-summary-article-parent)))
9410 (gnus-summary-goto-subject parent))))
9412 (defun gnus-summary-down-thread (n)
9413 "Go down thread N steps.
9414 If N is negative, go up instead.
9415 Returns the difference between N and how many steps down that were
9421 (if up (gnus-summary-go-up-thread)
9422 (gnus-summary-go-down-thread)))
9424 (gnus-summary-position-point)
9426 (gnus-message 7 "Can't go further"))
9429 (defun gnus-summary-up-thread (n)
9430 "Go up thread N steps.
9431 If N is negative, go down instead.
9432 Returns the difference between N and how many steps down that were
9435 (gnus-summary-down-thread (- n)))
9437 (defun gnus-summary-top-thread ()
9438 "Go to the top of the thread."
9440 (while (gnus-summary-go-up-thread))
9441 (gnus-summary-article-number))
9443 (defun gnus-summary-kill-thread (&optional unmark)
9444 "Mark articles under current thread as read.
9445 If the prefix argument is positive, remove any kinds of marks.
9446 If the prefix argument is negative, tick articles instead."
9449 (setq unmark (prefix-numeric-value unmark)))
9450 (let ((articles (gnus-summary-articles-in-thread)))
9452 ;; Expand the thread.
9453 (gnus-summary-show-thread)
9454 ;; Mark all the articles.
9456 (gnus-summary-goto-subject (car articles))
9457 (cond ((null unmark)
9458 (gnus-summary-mark-article-as-read gnus-killed-mark))
9460 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9462 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9463 (setq articles (cdr articles))))
9464 ;; Hide killed subtrees.
9466 gnus-thread-hide-killed
9467 (gnus-summary-hide-thread))
9468 ;; If marked as read, go to next unread subject.
9470 ;; Go to next unread subject.
9471 (gnus-summary-next-subject 1 t)))
9472 (gnus-set-mode-line 'summary))
9474 ;; Summary sorting commands
9476 (defun gnus-summary-sort-by-number (&optional reverse)
9477 "Sort the summary buffer by article number.
9478 Argument REVERSE means reverse order."
9480 (gnus-summary-sort 'number reverse))
9482 (defun gnus-summary-sort-by-author (&optional reverse)
9483 "Sort the summary buffer by author name alphabetically.
9484 If `case-fold-search' is non-nil, case of letters is ignored.
9485 Argument REVERSE means reverse order."
9487 (gnus-summary-sort 'author reverse))
9489 (defun gnus-summary-sort-by-subject (&optional reverse)
9490 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9491 If `case-fold-search' is non-nil, case of letters is ignored.
9492 Argument REVERSE means reverse order."
9494 (gnus-summary-sort 'subject reverse))
9496 (defun gnus-summary-sort-by-date (&optional reverse)
9497 "Sort the summary buffer by date.
9498 Argument REVERSE means reverse order."
9500 (gnus-summary-sort 'date reverse))
9502 (defun gnus-summary-sort-by-score (&optional reverse)
9503 "Sort the summary buffer by score.
9504 Argument REVERSE means reverse order."
9506 (gnus-summary-sort 'score reverse))
9508 (defun gnus-summary-sort-by-lines (&optional reverse)
9509 "Sort the summary buffer by the number of lines.
9510 Argument REVERSE means reverse order."
9512 (gnus-summary-sort 'lines reverse))
9514 (defun gnus-summary-sort-by-chars (&optional reverse)
9515 "Sort the summary buffer by article length.
9516 Argument REVERSE means reverse order."
9518 (gnus-summary-sort 'chars reverse))
9520 (defun gnus-summary-sort-by-original (&optional reverse)
9521 "Sort the summary buffer using the default sorting method.
9522 Argument REVERSE means reverse order."
9524 (let* ((buffer-read-only)
9525 (gnus-summary-prepare-hook nil))
9526 ;; We do the sorting by regenerating the threads.
9527 (gnus-summary-prepare)
9528 ;; Hide subthreads if needed.
9529 (when (and gnus-show-threads gnus-thread-hide-subtree)
9530 (gnus-summary-hide-all-threads))))
9532 (defun gnus-summary-sort (predicate reverse)
9533 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9534 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9535 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9536 (gnus-thread-sort-functions
9541 (gnus-sort-gathered-threads-function
9542 gnus-thread-sort-functions)
9543 (gnus-article-sort-functions
9549 (gnus-summary-prepare-hook nil))
9550 ;; We do the sorting by regenerating the threads.
9551 (gnus-summary-prepare)
9552 ;; Hide subthreads if needed.
9553 (when (and gnus-show-threads gnus-thread-hide-subtree)
9554 (gnus-summary-hide-all-threads))))
9556 ;; Summary saving commands.
9558 (defun gnus-summary-save-article (&optional n not-saved)
9559 "Save the current article using the default saver function.
9560 If N is a positive number, save the N next articles.
9561 If N is a negative number, save the N previous articles.
9562 If N is nil and any articles have been marked with the process mark,
9563 save those articles instead.
9564 The variable `gnus-default-article-saver' specifies the saver function."
9566 (let* ((articles (gnus-summary-work-articles n))
9567 (save-buffer (save-excursion
9568 (nnheader-set-temp-buffer " *Gnus Save*")))
9569 (num (length articles))
9571 (dolist (article articles)
9572 (setq header (gnus-summary-article-header article))
9573 (if (not (vectorp header))
9574 ;; This is a pseudo-article.
9575 (if (assq 'name header)
9576 (gnus-copy-file (cdr (assq 'name header)))
9577 (gnus-message 1 "Article %d is unsaveable" article))
9578 ;; This is a real article.
9579 (save-window-excursion
9580 (gnus-summary-select-article t nil nil article))
9582 (set-buffer save-buffer)
9584 (insert-buffer-substring gnus-original-article-buffer))
9585 (setq file (gnus-article-save save-buffer file num))
9586 (gnus-summary-remove-process-mark article)
9588 (gnus-summary-set-saved-mark article))))
9589 (gnus-kill-buffer save-buffer)
9590 (gnus-summary-position-point)
9591 (gnus-set-mode-line 'summary)
9594 (defun gnus-summary-pipe-output (&optional arg)
9595 "Pipe the current article to a subprocess.
9596 If N is a positive number, pipe the N next articles.
9597 If N is a negative number, pipe the N previous articles.
9598 If N is nil and any articles have been marked with the process mark,
9599 pipe those articles instead."
9602 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9603 (gnus-summary-save-article arg t))
9604 (gnus-configure-windows 'pipe))
9606 (defun gnus-summary-save-article-mail (&optional arg)
9607 "Append the current article to an mail file.
9608 If N is a positive number, save the N next articles.
9609 If N is a negative number, save the N previous articles.
9610 If N is nil and any articles have been marked with the process mark,
9611 save those articles instead."
9614 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9615 (gnus-summary-save-article arg)))
9617 (defun gnus-summary-save-article-rmail (&optional arg)
9618 "Append the current article to an rmail file.
9619 If N is a positive number, save the N next articles.
9620 If N is a negative number, save the N previous articles.
9621 If N is nil and any articles have been marked with the process mark,
9622 save those articles instead."
9625 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9626 (gnus-summary-save-article arg)))
9628 (defun gnus-summary-save-article-file (&optional arg)
9629 "Append the current article to a file.
9630 If N is a positive number, save the N next articles.
9631 If N is a negative number, save the N previous articles.
9632 If N is nil and any articles have been marked with the process mark,
9633 save those articles instead."
9636 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9637 (gnus-summary-save-article arg)))
9639 (defun gnus-summary-write-article-file (&optional arg)
9640 "Write the current article to a file, deleting the previous file.
9641 If N is a positive number, save the N next articles.
9642 If N is a negative number, save the N previous articles.
9643 If N is nil and any articles have been marked with the process mark,
9644 save those articles instead."
9647 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9648 (gnus-summary-save-article arg)))
9650 (defun gnus-summary-save-article-body-file (&optional arg)
9651 "Append the current article body to a file.
9652 If N is a positive number, save the N next articles.
9653 If N is a negative number, save the N previous articles.
9654 If N is nil and any articles have been marked with the process mark,
9655 save those articles instead."
9658 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9659 (gnus-summary-save-article arg)))
9661 (defun gnus-summary-pipe-message (program)
9662 "Pipe the current article through PROGRAM."
9663 (interactive "sProgram: ")
9664 (gnus-summary-select-article)
9665 (let ((mail-header-separator ""))
9666 (gnus-eval-in-buffer-window gnus-article-buffer
9669 (let ((start (window-start))
9671 (message-pipe-buffer-body program)
9672 (set-window-start (get-buffer-window (current-buffer)) start))))))
9674 (defun gnus-get-split-value (methods)
9675 "Return a value based on the split METHODS."
9676 (let (split-name method result match)
9679 (set-buffer gnus-original-article-buffer)
9681 (nnheader-narrow-to-headers)
9682 (while (and methods (not split-name))
9683 (goto-char (point-min))
9684 (setq method (pop methods))
9685 (setq match (car method))
9688 ;; Regular expression.
9690 (re-search-forward match nil t)))
9691 ((gnus-functionp match)
9695 (setq result (funcall match gnus-newsgroup-name))))
9700 (setq result (eval match)))))
9701 (setq split-name (cdr method))
9702 (cond ((stringp result)
9703 (push (expand-file-name
9704 result gnus-article-save-directory)
9707 (setq split-name (append result split-name)))))))))
9708 (nreverse split-name)))
9710 (defun gnus-valid-move-group-p (group)
9713 (symbol-value group)
9714 (gnus-get-function (gnus-find-method-for-group
9715 (symbol-name group)) 'request-accept-article t)))
9717 (defun gnus-read-move-group-name (prompt default articles prefix)
9718 "Read a group name."
9719 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9720 (minibuffer-confirm-incomplete nil) ; XEmacs
9724 (if (> (length articles) 1)
9725 (format "these %d articles" (length articles))
9730 (gnus-completing-read default prom
9732 'gnus-valid-move-group-p
9734 'gnus-group-history))
9735 ((= 1 (length split-name))
9736 (gnus-completing-read (car split-name) prom
9738 'gnus-valid-move-group-p
9740 'gnus-group-history))
9742 (gnus-completing-read nil prom
9743 (mapcar (lambda (el) (list el))
9744 (nreverse split-name))
9746 'gnus-group-history))))
9747 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9749 (if (or (string= to-newsgroup "")
9750 (string= to-newsgroup prefix))
9751 (setq to-newsgroup default))
9752 (unless to-newsgroup
9753 (error "No group name entered"))
9754 (or (gnus-active to-newsgroup)
9755 (gnus-activate-group to-newsgroup nil nil to-method)
9756 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9758 (or (and (gnus-request-create-group to-newsgroup to-method)
9759 (gnus-activate-group
9760 to-newsgroup nil nil to-method)
9761 (gnus-subscribe-group to-newsgroup))
9762 (error "Couldn't create group %s" to-newsgroup)))
9763 (error "No such group: %s" to-newsgroup)))
9766 (defun gnus-summary-save-parts (type dir n &optional reverse)
9767 "Save parts matching TYPE to DIR.
9768 If REVERSE, save parts that do not match TYPE."
9770 (list (read-string "Save parts of type: "
9771 (or (car gnus-summary-save-parts-type-history)
9772 gnus-summary-save-parts-default-mime)
9773 'gnus-summary-save-parts-type-history)
9774 (setq gnus-summary-save-parts-last-directory
9775 (read-file-name "Save to directory: "
9776 gnus-summary-save-parts-last-directory
9778 current-prefix-arg))
9779 (gnus-summary-iterate n
9780 (let ((gnus-display-mime-function nil)
9781 (gnus-inhibit-treatment t))
9782 (gnus-summary-select-article))
9784 (set-buffer gnus-article-buffer)
9785 (let ((handles (or gnus-article-mime-handles
9786 (mm-dissect-buffer) (mm-uu-dissect))))
9788 (gnus-summary-save-parts-1 type dir handles reverse)
9789 (unless gnus-article-mime-handles ;; Don't destroy this case.
9790 (mm-destroy-parts handles)))))))
9792 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9793 (if (stringp (car handle))
9794 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9797 (not (string-match type (mm-handle-media-type handle)))
9798 (string-match type (mm-handle-media-type handle)))
9799 (let ((file (expand-file-name
9800 (file-name-nondirectory
9802 (mail-content-type-get
9803 (mm-handle-disposition handle) 'filename)
9804 (concat gnus-newsgroup-name
9805 "." (number-to-string
9806 (cdr gnus-article-current)))))
9808 (unless (file-exists-p file)
9809 (mm-save-part-to-file handle file))))))
9811 ;; Summary extract commands
9813 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9814 (let ((buffer-read-only nil)
9815 (article (gnus-summary-article-number))
9817 (unless (gnus-summary-goto-subject article)
9818 (error "No such article: %d" article))
9819 (gnus-summary-position-point)
9820 ;; If all commands are to be bunched up on one line, we collect
9822 (unless gnus-view-pseudos-separately
9823 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9826 (setq action (cdr (assq 'action (car ps))))
9827 (setq files (list (cdr (assq 'name (car ps)))))
9828 (while (and ps (cdr ps)
9829 (string= (or action "1")
9830 (or (cdr (assq 'action (cadr ps))) "2")))
9831 (push (cdr (assq 'name (cadr ps))) files)
9832 (setcdr ps (cddr ps)))
9834 (when (not (string-match "%s" action))
9837 (when (assq 'execute (car ps))
9838 (setcdr (assq 'execute (car ps))
9839 (funcall (if (string-match "%s" action)
9846 (gnus-quote-arg-for-sh-or-csh f)))
9848 (setq ps (cdr ps)))))
9849 (if (and gnus-view-pseudos (not not-view))
9851 (when (assq 'execute (car pslist))
9852 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9853 (eq gnus-view-pseudos 'not-confirm)))
9854 (setq pslist (cdr pslist)))
9857 (setq after-article (or (cdr (assq 'article (car pslist)))
9858 (gnus-summary-article-number)))
9859 (gnus-summary-goto-subject after-article)
9862 (insert " " (file-name-nondirectory
9863 (cdr (assq 'name (car pslist))))
9864 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9866 (forward-line -1) ; back to `b'
9867 (gnus-add-text-properties
9868 b (1- e) (list 'gnus-number gnus-reffed-article-number
9869 gnus-mouse-face-prop gnus-mouse-face))
9871 after-article gnus-reffed-article-number
9872 gnus-unread-mark b (car pslist) 0 (- e b))
9873 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9874 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9875 (setq pslist (cdr pslist)))))))
9877 (defun gnus-pseudos< (p1 p2)
9878 (let ((c1 (cdr (assq 'action p1)))
9879 (c2 (cdr (assq 'action p2))))
9880 (and c1 c2 (string< c1 c2))))
9882 (defun gnus-request-pseudo-article (props)
9883 (cond ((assq 'execute props)
9884 (gnus-execute-command (cdr (assq 'execute props)))))
9885 (let ((gnus-current-article (gnus-summary-article-number)))
9886 (gnus-run-hooks 'gnus-mark-article-hook)))
9888 (defun gnus-execute-command (command &optional automatic)
9890 (gnus-article-setup-buffer)
9891 (set-buffer gnus-article-buffer)
9892 (setq buffer-read-only nil)
9893 (let ((command (if automatic command
9894 (read-string "Command: " (cons command 0)))))
9896 (insert "$ " command "\n\n")
9897 (if gnus-view-pseudo-asynchronously
9898 (start-process "gnus-execute" (current-buffer) shell-file-name
9899 shell-command-switch command)
9900 (call-process shell-file-name nil t nil
9901 shell-command-switch command)))))
9903 ;; Summary kill commands.
9905 (defun gnus-summary-edit-global-kill (article)
9906 "Edit the \"global\" kill file."
9907 (interactive (list (gnus-summary-article-number)))
9908 (gnus-group-edit-global-kill article))
9910 (defun gnus-summary-edit-local-kill ()
9911 "Edit a local kill file applied to the current newsgroup."
9913 (setq gnus-current-headers (gnus-summary-article-header))
9914 (gnus-group-edit-local-kill
9915 (gnus-summary-article-number) gnus-newsgroup-name))
9919 (defun gnus-read-header (id &optional header)
9920 "Read the headers of article ID and enter them into the Gnus system."
9921 (let ((group gnus-newsgroup-name)
9922 (gnus-override-method
9924 gnus-override-method
9925 (and (gnus-news-group-p gnus-newsgroup-name)
9926 (car (gnus-refer-article-methods)))))
9928 ;; First we check to see whether the header in question is already
9931 ;; This is a Message-ID.
9932 (setq header (or header (gnus-id-to-header id)))
9933 ;; This is an article number.
9934 (setq header (or header (gnus-summary-article-header id))))
9936 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9937 ;; We have found the header.
9939 ;; If this is a sparse article, we have to nix out its
9940 ;; previous entry in the thread hashtb.
9942 (gnus-summary-article-sparse-p (mail-header-number header)))
9943 (let* ((parent (gnus-parent-id (mail-header-references header)))
9944 (thread (and parent (gnus-id-to-thread parent))))
9946 (delq (assq header thread) thread))))
9947 ;; We have to really fetch the header to this article.
9949 (set-buffer nntp-server-buffer)
9950 (when (setq where (gnus-request-head id group))
9951 (nnheader-fold-continuation-lines)
9952 (goto-char (point-max))
9954 (goto-char (point-min))
9958 ((cdr where) (cdr where))
9959 (header (mail-header-number header))
9960 (t gnus-reffed-article-number))
9962 (insert " Article retrieved.\n"))
9964 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9965 () ; Malformed head.
9966 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9967 (when (and (stringp id)
9968 (not (string= (gnus-group-real-name group)
9970 ;; If we fetched by Message-ID and the article came
9971 ;; from a different group, we fudge some bogus article
9972 ;; numbers for this article.
9973 (mail-header-set-number header gnus-reffed-article-number))
9975 (set-buffer gnus-summary-buffer)
9976 (decf gnus-reffed-article-number)
9977 (gnus-remove-header (mail-header-number header))
9978 (push header gnus-newsgroup-headers)
9979 (setq gnus-current-headers header)
9980 (push (mail-header-number header) gnus-newsgroup-limit)))
9983 (defun gnus-remove-header (number)
9984 "Remove header NUMBER from `gnus-newsgroup-headers'."
9985 (if (and gnus-newsgroup-headers
9986 (= number (mail-header-number (car gnus-newsgroup-headers))))
9987 (pop gnus-newsgroup-headers)
9988 (let ((headers gnus-newsgroup-headers))
9989 (while (and (cdr headers)
9990 (not (= number (mail-header-number (cadr headers)))))
9993 (setcdr headers (cddr headers))))))
9996 ;;; summary highlights
9999 (defun gnus-highlight-selected-summary ()
10000 "Highlight selected article in summary buffer."
10001 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10002 (when gnus-summary-selected-face
10004 (let* ((beg (progn (beginning-of-line) (point)))
10005 (end (progn (end-of-line) (point)))
10006 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10007 (from (if (get-text-property beg gnus-mouse-face-prop)
10009 (or (next-single-property-change
10010 beg gnus-mouse-face-prop nil end)
10015 (or (next-single-property-change
10016 from gnus-mouse-face-prop nil end)
10018 ;; If no mouse-face prop on line we will have to = from = end,
10019 ;; so we highlight the entire line instead.
10020 (when (= (+ to 2) from)
10023 (if gnus-newsgroup-selected-overlay
10024 ;; Move old overlay.
10026 gnus-newsgroup-selected-overlay from to (current-buffer))
10027 ;; Create new overlay.
10029 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10030 'face gnus-summary-selected-face))))))
10032 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10033 (defun gnus-summary-highlight-line ()
10034 "Highlight current line according to `gnus-summary-highlight'."
10035 (let* ((list gnus-summary-highlight)
10037 (end (progn (end-of-line) (point)))
10038 ;; now find out where the line starts and leave point there.
10039 (beg (progn (beginning-of-line) (point)))
10040 (article (gnus-summary-article-number))
10041 (score (or (cdr (assq (or article gnus-current-article)
10042 gnus-newsgroup-scored))
10043 gnus-summary-default-score 0))
10044 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10045 (inhibit-read-only t))
10046 ;; Eval the cars of the lists until we find a match.
10047 (let ((default gnus-summary-default-score))
10049 (not (eval (caar list))))
10050 (setq list (cdr list))))
10051 (let ((face (cdar list)))
10052 (unless (eq face (get-text-property beg 'face))
10053 (gnus-put-text-property-excluding-characters-with-faces
10055 (setq face (if (boundp face) (symbol-value face) face)))
10056 (when gnus-summary-highlight-line-function
10057 (funcall gnus-summary-highlight-line-function article face))))
10060 (defun gnus-update-read-articles (group unread &optional compute)
10061 "Update the list of read articles in GROUP."
10062 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10063 (entry (gnus-gethash group gnus-newsrc-hashtb))
10064 (info (nth 2 entry))
10066 (unread (sort (copy-sequence unread) '<))
10068 (if (or (not info) (not active))
10069 ;; There is no info on this group if it was, in fact,
10070 ;; killed. Gnus stores no information on killed groups, so
10071 ;; there's nothing to be done.
10072 ;; One could store the information somewhere temporarily,
10073 ;; perhaps... Hmmm...
10075 ;; Remove any negative articles numbers.
10076 (while (and unread (< (car unread) 0))
10077 (setq unread (cdr unread)))
10078 ;; Remove any expired article numbers
10079 (while (and unread (< (car unread) (car active)))
10080 (setq unread (cdr unread)))
10081 ;; Compute the ranges of read articles by looking at the list of
10082 ;; unread articles.
10084 (when (/= (car unread) prev)
10085 (push (if (= prev (1- (car unread))) prev
10086 (cons prev (1- (car unread))))
10088 (setq prev (1+ (car unread)))
10089 (setq unread (cdr unread)))
10090 (when (<= prev (cdr active))
10091 (push (cons prev (cdr active)) read))
10092 (setq read (if (> (length read) 1) (nreverse read) read))
10097 ;; Propagate the read marks to the backend.
10098 (when (gnus-check-backend-function 'request-set-mark group)
10099 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10100 (add (gnus-remove-from-range read (gnus-info-read info))))
10102 (unless (gnus-check-group group)
10103 (error "Can't open server for %s" group))
10104 (gnus-request-set-mark
10105 group (delq nil (list (if add (list add 'add '(read)))
10106 (if del (list del 'del '(read))))))
10108 `(gnus-request-set-mark
10111 (if del (list del 'add '(read)))
10112 (if add (list add 'del '(read))))))))))
10113 (set-buffer gnus-group-buffer)
10114 (gnus-undo-register
10116 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10117 (gnus-info-set-read ',info ',(gnus-info-read info))
10118 (gnus-get-unread-articles-in-group ',info
10119 (gnus-active ,group))
10120 (gnus-group-update-group ,group t)
10122 ;; Enter this list into the group info.
10123 (gnus-info-set-read info read)
10124 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10125 (gnus-get-unread-articles-in-group info (gnus-active group))
10128 (defun gnus-offer-save-summaries ()
10129 "Offer to save all active summary buffers."
10131 (let ((buflist (buffer-list))
10133 ;; Go through all buffers and find all summaries.
10135 (and (setq bufname (buffer-name (car buflist)))
10136 (string-match "Summary" bufname)
10138 (set-buffer bufname)
10139 ;; We check that this is, indeed, a summary buffer.
10140 (and (eq major-mode 'gnus-summary-mode)
10141 ;; Also make sure this isn't bogus.
10142 gnus-newsgroup-prepared
10143 ;; Also make sure that this isn't a dead summary buffer.
10144 (not gnus-dead-summary-mode)))
10145 (push bufname buffers))
10146 (setq buflist (cdr buflist)))
10147 ;; Go through all these summary buffers and offer to save them.
10150 "Update summary buffer %s? "
10152 (switch-to-buffer buf)
10153 (gnus-summary-exit))
10157 ;;; @ for mime-partial
10160 (defun gnus-request-partial-message ()
10162 (let ((number (gnus-summary-article-number))
10163 (group gnus-newsgroup-name)
10164 (mother gnus-article-buffer))
10165 (set-buffer (get-buffer-create " *Partial Article*"))
10167 (setq mime-preview-buffer mother)
10168 (gnus-request-article-this-buffer number group)
10169 (mime-parse-buffer)
10172 (autoload 'mime-combine-message/partial-pieces-automatically
10174 "Internal method to combine message/partial messages automatically.")
10176 (mime-add-condition
10177 'action '((type . message)(subtype . partial)
10178 (major-mode . gnus-original-article-mode)
10179 (method . mime-combine-message/partial-pieces-automatically)
10180 (summary-buffer-exp . gnus-summary-buffer)
10181 (request-partial-message-method . gnus-request-partial-message)
10185 ;;; @ for message/rfc822
10188 (defun gnus-mime-extract-message/rfc822 (entity situation)
10189 (let (group article num cwin swin cur)
10191 (mime-insert-entity-content entity)
10192 (setq group (or (cdr (assq 'group situation))
10193 (completing-read "Group: "
10196 (gnus-read-active-file-p)
10197 gnus-newsgroup-name))
10198 article (gnus-request-accept-article group)))
10199 (when (and (consp article)
10200 (numberp (setq article (cdr article))))
10201 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10202 cwin (get-buffer-window (current-buffer) t))
10203 (save-window-excursion
10204 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10205 (select-window swin)
10206 (set-buffer gnus-summary-buffer))
10207 (setq cur gnus-current-article)
10209 (let (gnus-show-threads)
10210 (gnus-summary-goto-subject article t))
10211 (gnus-summary-clear-mark-forward 1)
10212 (gnus-summary-goto-subject cur))
10213 (when (and cwin (window-frame cwin))
10214 (select-frame (window-frame cwin)))
10215 (when (boundp 'mime-acting-situation-to-override)
10216 (set-alist 'mime-acting-situation-to-override
10219 (set-alist 'mime-acting-situation-to-override
10222 (save-current-buffer
10223 (set-buffer gnus-group-buffer)
10224 (gnus-activate-group ,group))
10225 (gnus-summary-goto-article ,cur
10226 gnus-show-all-headers)))
10227 (set-alist 'mime-acting-situation-to-override
10230 (mime-add-condition
10231 'action '((type . message)(subtype . rfc822)
10232 (major-mode . gnus-original-article-mode)
10233 (method . gnus-mime-extract-message/rfc822)
10237 (mime-add-condition
10238 'action '((type . message)(subtype . news)
10239 (major-mode . gnus-original-article-mode)
10240 (method . gnus-mime-extract-message/rfc822)
10244 (defun gnus-mime-extract-multipart (entity situation)
10245 (let ((children (mime-entity-children entity))
10246 mime-acting-situation-to-override
10249 (mime-play-entity (car children)
10250 (cons (assq 'mode situation)
10251 mime-acting-situation-to-override))
10252 (setq children (cdr children)))
10253 (if (setq f (cdr (assq 'after-method
10254 mime-acting-situation-to-override)))
10258 (mime-add-condition
10259 'action '((type . multipart)
10260 (method . gnus-mime-extract-multipart)
10269 (defun gnus-summary-setup-default-charset ()
10270 "Setup newsgroup default charset."
10271 (if (equal gnus-newsgroup-name "nndraft:drafts")
10272 (setq gnus-newsgroup-charset nil)
10273 (let* ((ignored-charsets
10274 (or gnus-newsgroup-ephemeral-ignored-charsets
10276 (and gnus-newsgroup-name
10277 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10278 gnus-newsgroup-ignored-charsets))))
10279 (setq gnus-newsgroup-charset
10280 (or gnus-newsgroup-ephemeral-charset
10281 (and gnus-newsgroup-name
10282 (gnus-parameter-charset gnus-newsgroup-name))
10283 gnus-default-charset))
10284 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10285 ignored-charsets))))
10291 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10292 "Display the current article buffer fully MIME-buttonized.
10293 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10294 treated as multipart/mixed."
10296 (require 'gnus-art)
10297 (let ((gnus-unbuttonized-mime-types nil)
10298 (gnus-mime-display-multipart-as-mixed show-all-parts))
10299 (gnus-summary-show-article)))
10301 (defun gnus-summary-repair-multipart (article)
10302 "Add a Content-Type header to a multipart article without one."
10303 (interactive (list (gnus-summary-article-number)))
10304 (gnus-with-article article
10305 (message-narrow-to-head)
10306 (message-remove-header "Mime-Version")
10307 (goto-char (point-max))
10308 (insert "Mime-Version: 1.0\n")
10310 (when (search-forward "\n--" nil t)
10311 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10312 (message-narrow-to-head)
10313 (message-remove-header "Content-Type")
10314 (goto-char (point-max))
10315 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10318 (let (gnus-mark-article-hook)
10319 (gnus-summary-select-article t t nil article)))
10321 (defun gnus-summary-toggle-display-buttonized ()
10322 "Toggle the buttonizing of the article buffer."
10324 (require 'gnus-art)
10325 (if (setq gnus-inhibit-mime-unbuttonizing
10326 (not gnus-inhibit-mime-unbuttonizing))
10327 (let ((gnus-unbuttonized-mime-types nil))
10328 (gnus-summary-show-article))
10329 (gnus-summary-show-article)))
10332 ;;; Intelli-mouse commmands
10335 (defun gnus-wheel-summary-scroll (event)
10337 (let ((amount (if (memq 'shift (event-modifiers event))
10338 (car gnus-wheel-scroll-amount)
10339 (cdr gnus-wheel-scroll-amount)))
10340 (direction (- (* (static-if (featurep 'xemacs)
10341 (event-button event)
10342 (cond ((eq 'mouse-4 (event-basic-type event))
10344 ((eq 'mouse-5 (event-basic-type event))
10348 (gnus-summary-scroll-up (* amount direction))
10349 (when (gnus-eval-in-buffer-window gnus-article-buffer
10352 (and (if (< 0 direction)
10353 (gnus-article-next-page 0)
10354 (gnus-article-prev-page 0)
10356 (if (setq edge (get-text-property
10357 (point-min) 'gnus-wheel-edge))
10358 (setq edge (* edge direction))
10361 (let ((buffer-read-only nil)
10362 (inhibit-read-only t))
10363 (put-text-property (point-min) (point-max)
10364 'gnus-wheel-edge direction)
10366 (or (> edge gnus-wheel-edge-resistance)
10367 (let ((buffer-read-only nil)
10368 (inhibit-read-only t))
10369 (put-text-property (point-min) (point-max)
10371 (* (1+ edge) direction))
10373 (eq last-command 'gnus-wheel-summary-scroll))))
10374 (gnus-summary-next-article nil nil (minusp direction)))))
10376 (defun gnus-wheel-install ()
10377 "Enable mouse wheel support on summary window."
10378 (when gnus-use-wheel
10380 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10382 (define-key gnus-summary-mode-map key
10383 'gnus-wheel-summary-scroll)))))
10385 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10388 ;;; Traditional PGP commmands
10391 (defun gnus-summary-decrypt-article (&optional force)
10392 "Decrypt the current article in traditional PGP way.
10393 This will have permanent effect only in mail groups.
10394 If FORCE is non-nil, allow editing of articles even in read-only
10397 (gnus-summary-select-article t)
10398 (gnus-eval-in-buffer-window gnus-article-buffer
10402 (goto-char (point-min))
10403 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10404 (error "Not a traditional PGP message!"))
10405 (let ((armor-start (match-beginning 0)))
10406 (if (and (pgg-decrypt-region armor-start (point-max))
10407 (or force (not (gnus-group-read-only-p))))
10408 (let ((inhibit-read-only t)
10410 (delete-region armor-start
10412 (re-search-forward "^-+END PGP" nil t)
10413 (beginning-of-line 2)
10415 (insert-buffer-substring pgg-output-buffer))))))))
10417 (defun gnus-summary-verify-article ()
10418 "Verify the current article in traditional PGP way."
10421 (set-buffer gnus-original-article-buffer)
10422 (goto-char (point-min))
10423 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10424 (error "Not a traditional PGP message!"))
10425 (re-search-forward "^-+END PGP" nil t)
10426 (beginning-of-line 2)
10427 (call-interactively (function pgg-verify-region))))
10430 ;;; Generic summary marking commands
10433 (defvar gnus-summary-marking-alist
10434 '((read gnus-del-mark "d")
10435 (unread gnus-unread-mark "u")
10436 (ticked gnus-ticked-mark "!")
10437 (dormant gnus-dormant-mark "?")
10438 (expirable gnus-expirable-mark "e"))
10439 "An alist of names/marks/keystrokes.")
10441 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10442 (defvar gnus-summary-mark-map)
10444 (defun gnus-summary-make-all-marking-commands ()
10445 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10446 (dolist (elem gnus-summary-marking-alist)
10447 (apply 'gnus-summary-make-marking-command elem)))
10449 (defun gnus-summary-make-marking-command (name mark keystroke)
10450 (let ((map (make-sparse-keymap)))
10451 (define-key gnus-summary-generic-mark-map keystroke map)
10452 (dolist (lway `((next "next" next nil "n")
10453 (next-unread "next unread" next t "N")
10454 (prev "previous" prev nil "p")
10455 (prev-unread "previous unread" prev t "P")
10456 (nomove "" nil nil ,keystroke)))
10457 (let ((func (gnus-summary-make-marking-command-1
10458 mark (car lway) lway name)))
10459 (setq func (eval func))
10460 (define-key map (nth 4 lway) func)))))
10462 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10464 (format "gnus-summary-put-mark-as-%s%s"
10465 name (if (eq way 'nomove)
10467 (concat "-" (symbol-name way)))))
10470 "Mark the current article as %s%s.
10471 If N, the prefix, then repeat N times.
10472 If N is negative, move in reverse order.
10473 The difference between N and the actual number of articles marked is
10475 name (car (cdr lway)))
10477 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10479 (defun gnus-summary-generic-mark (n mark move unread)
10480 "Mark N articles with MARK."
10481 (unless (eq major-mode 'gnus-summary-mode)
10482 (error "This command can only be used in the summary buffer"))
10483 (gnus-summary-show-thread)
10486 ((eq move 'next) 1)
10487 ((eq move 'prev) -1)
10489 (if (zerop nummove)
10493 nummove (* -1 nummove))))
10494 (while (and (> n 0)
10495 (gnus-summary-mark-article nil mark)
10496 (zerop (gnus-summary-next-subject nummove unread t)))
10499 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10500 (gnus-summary-recenter)
10501 (gnus-summary-position-point)
10502 (gnus-set-mode-line 'summary)
10505 (defun gnus-summary-insert-articles (articles)
10506 (when (setq articles
10507 (gnus-set-difference articles
10508 (mapcar (lambda (h) (mail-header-number h))
10509 gnus-newsgroup-headers)))
10510 (setq gnus-newsgroup-headers
10512 gnus-newsgroup-headers
10513 (gnus-fetch-headers articles)
10514 'gnus-article-sort-by-number))
10515 ;; Suppress duplicates?
10516 (when gnus-suppress-duplicates
10517 (gnus-dup-suppress-articles))
10519 ;; We might want to build some more threads first.
10520 (when (and gnus-fetch-old-headers
10521 (eq gnus-headers-retrieved-by 'nov))
10522 (if (eq gnus-fetch-old-headers 'invisible)
10523 (gnus-build-all-threads)
10524 (gnus-build-old-threads)))
10525 ;; Let the Gnus agent mark articles as read.
10527 (gnus-agent-get-undownloaded-list))
10528 ;; Remove list identifiers from subject
10529 (when gnus-list-identifiers
10530 (gnus-summary-remove-list-identifiers))
10531 ;; First and last article in this newsgroup.
10532 (when gnus-newsgroup-headers
10533 (setq gnus-newsgroup-begin
10534 (mail-header-number (car gnus-newsgroup-headers))
10536 (mail-header-number
10537 (gnus-last-element gnus-newsgroup-headers))))
10538 (when gnus-use-scoring
10539 (gnus-possibly-score-headers))))
10541 (defun gnus-summary-insert-old-articles (&optional all)
10542 "Insert all old articles in this group.
10543 If ALL is non-nil, already read articles become readable.
10544 If ALL is a number, fetch this number of articles."
10547 (let ((old (mapcar 'car gnus-newsgroup-data))
10548 (i (car gnus-newsgroup-active))
10550 (while (<= i (cdr gnus-newsgroup-active))
10551 (or (memq i old) (push i older))
10553 (setq len (length older))
10558 (setq older (subseq older 0 all))))
10561 (if (and (numberp gnus-large-newsgroup)
10562 (> len gnus-large-newsgroup))
10566 "How many articles from %s (default %d): "
10568 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10570 (unless (string-match "^[ \t]*$" input)
10571 (setq all (string-to-number input))
10573 (setq older (subseq older 0 all))))))))
10575 (message "No old news.")
10576 (gnus-summary-insert-articles older)
10577 (gnus-summary-limit (gnus-union older old))))
10578 (gnus-summary-position-point)))
10580 (defun gnus-summary-insert-new-articles ()
10581 "Insert all new articles in this group."
10584 (let ((old (mapcar 'car gnus-newsgroup-data))
10585 (old-active gnus-newsgroup-active)
10586 (nnmail-fetched-sources (list t))
10588 (setq gnus-newsgroup-active
10589 (gnus-activate-group gnus-newsgroup-name 'scan))
10590 (setq i (1+ (cdr old-active)))
10591 (while (<= i (cdr gnus-newsgroup-active))
10595 (message "No gnus is bad news.")
10596 (gnus-summary-insert-articles new)
10597 (setq gnus-newsgroup-unreads
10598 (append gnus-newsgroup-unreads new))
10599 (gnus-summary-limit (gnus-union old new))))
10600 (gnus-summary-position-point)))
10602 (gnus-summary-make-all-marking-commands)
10604 (gnus-ems-redefine)
10606 (provide 'gnus-sum)
10608 (run-hooks 'gnus-sum-load-hook)
10610 ;;; gnus-sum.el ends here