1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
41 ;; (require 'gnus-art)
50 (autoload 'gnus-cache-articles-in-group "gnus-cache")
51 (autoload 'pgg-decrypt-region "pgg" nil t)
52 (autoload 'pgg-verify-region "pgg" nil t))
54 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
55 (autoload 'gnus-cache-write-active "gnus-cache")
56 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
57 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
58 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
59 (autoload 'mm-uu-dissect "mm-uu")
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include: `gnus-simplify-subject-re',
151 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
153 :type '(repeat function))
155 (defcustom gnus-simplify-ignored-prefixes nil
156 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
158 :type '(choice (const :tag "off" nil)
161 (defcustom gnus-build-sparse-threads nil
162 "*If non-nil, fill in the gaps in threads.
163 If `some', only fill in the gaps that are needed to tie loose threads
164 together. If `more', fill in all leaf nodes that Gnus can find. If
165 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
167 :type '(choice (const :tag "off" nil)
170 (sexp :menu-tag "all" t)))
172 (defcustom gnus-summary-thread-gathering-function
173 'gnus-gather-threads-by-subject
174 "*Function used for gathering loose threads.
175 There are two pre-defined functions: `gnus-gather-threads-by-subject',
176 which only takes Subjects into consideration; and
177 `gnus-gather-threads-by-references', which compared the References
178 headers of the articles to find matches."
180 :type '(radio (function-item gnus-gather-threads-by-subject)
181 (function-item gnus-gather-threads-by-references)
182 (function :tag "other")))
184 (defcustom gnus-summary-same-subject ""
185 "*String indicating that the current article has the same subject as the previous.
186 This variable will only be used if the value of
187 `gnus-summary-make-false-root' is `empty'."
188 :group 'gnus-summary-format
191 (defcustom gnus-summary-goto-unread t
192 "*If t, many commands will go to the next unread article.
193 This applies to marking commands as well as other commands that
194 \"naturally\" select the next article, like, for instance, `SPC' at
195 the end of an article.
197 If nil, the marking commands do NOT go to the next unread article
198 (they go to the next article instead). If `never', commands that
199 usually go to the next unread article, will go to the next article,
200 whether it is read or not."
201 :group 'gnus-summary-marks
202 :link '(custom-manual "(gnus)Setting Marks")
203 :type '(choice (const :tag "off" nil)
205 (sexp :menu-tag "on" t)))
207 (defcustom gnus-summary-default-score 0
208 "*Default article score level.
209 All scores generated by the score files will be added to this score.
210 If this variable is nil, scoring will be disabled."
211 :group 'gnus-score-default
212 :type '(choice (const :tag "disable")
215 (defcustom gnus-summary-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 If threads are hidden, you have to run the command
238 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
239 to expose hidden threads."
243 (defcustom gnus-thread-hide-killed t
244 "*If non-nil, hide killed threads automatically."
248 (defcustom gnus-thread-ignore-subject t
249 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
250 If nil, articles that have different subjects from their parents will
251 start separate threads."
255 (defcustom gnus-thread-operation-ignore-subject t
256 "*If non-nil, subjects will be ignored when doing thread commands.
257 This affects commands like `gnus-summary-kill-thread' and
258 `gnus-summary-lower-thread'.
260 If this variable is nil, articles in the same thread with different
261 subjects will not be included in the operation in question. If this
262 variable is `fuzzy', only articles that have subjects that are fuzzily
263 equal will be included."
265 :type '(choice (const :tag "off" nil)
269 (defcustom gnus-thread-indent-level 4
270 "*Number that says how much each sub-thread should be indented."
274 (defcustom gnus-auto-extend-newsgroup t
275 "*If non-nil, extend newsgroup forward and backward when requested."
276 :group 'gnus-summary-choose
279 (defcustom gnus-auto-select-first t
280 "*If nil, don't select the first unread article when entering a group.
281 If this variable is `best', select the highest-scored unread article
282 in the group. If t, select the first unread article.
284 This variable can also be a function to place point on a likely
285 subject line. Useful values include `gnus-summary-first-unread-subject',
286 `gnus-summary-first-unread-article' and
287 `gnus-summary-best-unread-article'.
289 If you want to prevent automatic selection of the first unread article
290 in some newsgroups, set the variable to nil in
291 `gnus-select-group-hook'."
292 :group 'gnus-group-select
293 :type '(choice (const :tag "none" nil)
295 (sexp :menu-tag "first" t)
296 (function-item gnus-summary-first-unread-subject)
297 (function-item gnus-summary-first-unread-article)
298 (function-item gnus-summary-best-unread-article)))
300 (defcustom gnus-dont-select-after-jump-to-other-group nil
301 "If non-nil, don't select the first unread article after entering the
302 other group by the command `gnus-summary-jump-to-other-group'. If nil,
303 it is depend on the value of `gnus-auto-select-first' whether to select
305 :group 'gnus-group-select
308 (defcustom gnus-auto-select-next t
309 "*If non-nil, offer to go to the next group from the end of the previous.
310 If the value is t and the next newsgroup is empty, Gnus will exit
311 summary mode and go back to group mode. If the value is neither nil
312 nor t, Gnus will select the following unread newsgroup. In
313 particular, if the value is the symbol `quietly', the next unread
314 newsgroup will be selected without any confirmation, and if it is
315 `almost-quietly', the next group will be selected without any
316 confirmation if you are located on the last article in the group.
317 Finally, if this variable is `slightly-quietly', the `Z n' command
318 will go to the next group without confirmation."
319 :group 'gnus-summary-maneuvering
320 :type '(choice (const :tag "off" nil)
322 (const almost-quietly)
323 (const slightly-quietly)
324 (sexp :menu-tag "on" t)))
326 (defcustom gnus-auto-select-same nil
327 "*If non-nil, select the next article with the same subject.
328 If there are no more articles with the same subject, go to
329 the first unread article."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-summary-check-current nil
334 "*If non-nil, consider the current article when moving.
335 The \"unread\" movement commands will stay on the same line if the
336 current article is unread."
337 :group 'gnus-summary-maneuvering
340 (defcustom gnus-auto-center-summary t
341 "*If non-nil, always center the current summary buffer.
342 In particular, if `vertical' do only vertical recentering. If non-nil
343 and non-`vertical', do both horizontal and vertical recentering."
344 :group 'gnus-summary-maneuvering
345 :type '(choice (const :tag "none" nil)
347 (integer :tag "height")
348 (sexp :menu-tag "both" t)))
350 (defcustom gnus-show-all-headers nil
351 "*If non-nil, don't hide any headers."
352 :group 'gnus-article-hiding
353 :group 'gnus-article-headers
356 (defcustom gnus-summary-ignore-duplicates nil
357 "*If non-nil, ignore articles with identical Message-ID headers."
361 (defcustom gnus-single-article-buffer t
362 "*If non-nil, display all articles in the same buffer.
363 If nil, each group will get its own article buffer."
364 :group 'gnus-article-various
367 (defcustom gnus-break-pages t
368 "*If non-nil, do page breaking on articles.
369 The page delimiter is specified by the `gnus-page-delimiter'
371 :group 'gnus-article-various
374 (defcustom gnus-show-mime t
375 "*If non-nil, do mime processing of articles.
376 The articles will simply be fed to the function given by
377 `gnus-article-display-method-for-mime'."
378 :group 'gnus-article-mime
381 (defcustom gnus-move-split-methods nil
382 "*Variable used to suggest where articles are to be moved to.
383 It uses the same syntax as the `gnus-split-methods' variable.
384 However, whereas `gnus-split-methods' specifies file names as targets,
385 this variable specifies group names."
386 :group 'gnus-summary-mail
387 :type '(repeat (choice (list :value (fun) function)
388 (cons :value ("" "") regexp (repeat string))
391 (defcustom gnus-unread-mark ? ;Whitespace
392 "*Mark used for unread articles."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ticked-mark ?!
397 "*Mark used for ticked articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-dormant-mark ??
402 "*Mark used for dormant articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-del-mark ?r
407 "*Mark used for del'd articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-read-mark ?R
412 "*Mark used for read articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-expirable-mark ?E
417 "*Mark used for expirable articles."
418 :group 'gnus-summary-marks
421 (defcustom gnus-killed-mark ?K
422 "*Mark used for killed articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-souped-mark ?F
427 "*Mark used for killed articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-kill-file-mark ?X
432 "*Mark used for articles killed by kill files."
433 :group 'gnus-summary-marks
436 (defcustom gnus-low-score-mark ?Y
437 "*Mark used for articles with a low score."
438 :group 'gnus-summary-marks
441 (defcustom gnus-catchup-mark ?C
442 "*Mark used for articles that are caught up."
443 :group 'gnus-summary-marks
446 (defcustom gnus-replied-mark ?A
447 "*Mark used for articles that have been replied to."
448 :group 'gnus-summary-marks
451 (defcustom gnus-cached-mark ?*
452 "*Mark used for articles that are in the cache."
453 :group 'gnus-summary-marks
456 (defcustom gnus-saved-mark ?S
457 "*Mark used for articles that have been saved to."
458 :group 'gnus-summary-marks
461 (defcustom gnus-ancient-mark ?O
462 "*Mark used for ancient articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-sparse-mark ?Q
467 "*Mark used for sparsely reffed articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-canceled-mark ?G
472 "*Mark used for canceled articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-duplicate-mark ?M
477 "*Mark used for duplicate articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-undownloaded-mark ?@
482 "*Mark used for articles that weren't downloaded."
483 :group 'gnus-summary-marks
486 (defcustom gnus-downloadable-mark ?%
487 "*Mark used for articles that are to be downloaded."
488 :group 'gnus-summary-marks
491 (defcustom gnus-unsendable-mark ?=
492 "*Mark used for articles that won't be sent."
493 :group 'gnus-summary-marks
496 (defcustom gnus-score-over-mark ?+
497 "*Score mark used for articles with high scores."
498 :group 'gnus-summary-marks
501 (defcustom gnus-score-below-mark ?-
502 "*Score mark used for articles with low scores."
503 :group 'gnus-summary-marks
506 (defcustom gnus-empty-thread-mark ? ;Whitespace
507 "*There is no thread under the article."
508 :group 'gnus-summary-marks
511 (defcustom gnus-not-empty-thread-mark ?=
512 "*There is a thread under the article."
513 :group 'gnus-summary-marks
516 (defcustom gnus-view-pseudo-asynchronously nil
517 "*If non-nil, Gnus will view pseudo-articles asynchronously."
518 :group 'gnus-extract-view
521 (defcustom gnus-auto-expirable-marks
522 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
523 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
524 gnus-souped-mark gnus-duplicate-mark)
525 "*The list of marks converted into expiration if a group is auto-expirable."
528 :type '(repeat character))
530 (defcustom gnus-inhibit-user-auto-expire t
531 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
536 (defcustom gnus-view-pseudos nil
537 "*If `automatic', pseudo-articles will be viewed automatically.
538 If `not-confirm', pseudos will be viewed automatically, and the user
539 will not be asked to confirm the command."
540 :group 'gnus-extract-view
541 :type '(choice (const :tag "off" nil)
543 (const not-confirm)))
545 (defcustom gnus-view-pseudos-separately t
546 "*If non-nil, one pseudo-article will be created for each file to be viewed.
547 If nil, all files that use the same viewing command will be given as a
548 list of parameters to that command."
549 :group 'gnus-extract-view
552 (defcustom gnus-insert-pseudo-articles t
553 "*If non-nil, insert pseudo-articles when decoding articles."
554 :group 'gnus-extract-view
557 (defcustom gnus-summary-dummy-line-format
559 "*The format specification for the dummy roots in the summary buffer.
560 It works along the same lines as a normal formatting string,
561 with some simple extensions.
564 :group 'gnus-threading
567 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
568 "*The format specification for the summary mode line.
569 It works along the same lines as a normal formatting string,
570 with some simple extensions:
573 %p Unprefixed group name
574 %A Current article number
575 %z Current article score
577 %U Number of unread articles in the group
578 %e Number of unselected articles in the group
579 %Z A string with unread/unselected article counts
580 %g Shortish group name
581 %S Subject of the current article
583 %s Current score file name
584 %d Number of dormant articles
585 %r Number of articles that have been marked as read in this session
586 %E Number of articles expunged by the score files"
587 :group 'gnus-summary-format
590 (defcustom gnus-list-identifiers nil
591 "Regexp that matches list identifiers to be removed from subject.
592 This can also be a list of regexps."
594 :group 'gnus-summary-format
595 :group 'gnus-article-hiding
596 :type '(choice (const :tag "none" nil)
598 (repeat :value (".*") regexp)))
600 (defcustom gnus-summary-mark-below 0
601 "*Mark all articles with a score below this variable as read.
602 This variable is local to each summary buffer and usually set by the
604 :group 'gnus-score-default
607 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
608 "*List of functions used for sorting articles in the summary buffer.
609 This variable is only used when not using a threaded display."
610 :group 'gnus-summary-sort
611 :type '(repeat (choice (function-item gnus-article-sort-by-number)
612 (function-item gnus-article-sort-by-author)
613 (function-item gnus-article-sort-by-subject)
614 (function-item gnus-article-sort-by-date)
615 (function-item gnus-article-sort-by-score)
616 (function :tag "other"))))
618 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
619 "*List of functions used for sorting threads in the summary buffer.
620 By default, threads are sorted by article number.
622 Each function takes two threads and return non-nil if the first thread
623 should be sorted before the other. If you use more than one function,
624 the primary sort function should be the last. You should probably
625 always include `gnus-thread-sort-by-number' in the list of sorting
626 functions -- preferably first.
628 Ready-made functions include `gnus-thread-sort-by-number',
629 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
630 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
631 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
632 :group 'gnus-summary-sort
633 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
634 (function-item gnus-thread-sort-by-author)
635 (function-item gnus-thread-sort-by-subject)
636 (function-item gnus-thread-sort-by-date)
637 (function-item gnus-thread-sort-by-score)
638 (function-item gnus-thread-sort-by-total-score)
639 (function :tag "other"))))
641 (defcustom gnus-thread-score-function '+
642 "*Function used for calculating the total score of a thread.
644 The function is called with the scores of the article and each
645 subthread and should then return the score of the thread.
647 Some functions you can use are `+', `max', or `min'."
648 :group 'gnus-summary-sort
651 (defcustom gnus-summary-expunge-below nil
652 "All articles that have a score less than this variable will be expunged.
653 This variable is local to the summary buffers."
654 :group 'gnus-score-default
655 :type '(choice (const :tag "off" nil)
658 (defcustom gnus-thread-expunge-below nil
659 "All threads that have a total score less than this variable will be expunged.
660 See `gnus-thread-score-function' for en explanation of what a
663 This variable is local to the summary buffers."
664 :group 'gnus-threading
665 :group 'gnus-score-default
666 :type '(choice (const :tag "off" nil)
669 (defcustom gnus-summary-mode-hook nil
670 "*A hook for Gnus summary mode.
671 This hook is run before any variables are set in the summary buffer."
672 :options '(turn-on-gnus-mailing-list-mode)
673 :group 'gnus-summary-various
676 (defcustom gnus-summary-menu-hook nil
677 "*Hook run after the creation of the summary mode menu."
678 :group 'gnus-summary-visual
681 (defcustom gnus-summary-exit-hook nil
682 "*A hook called on exit from the summary buffer.
683 It will be called with point in the group buffer."
684 :group 'gnus-summary-exit
687 (defcustom gnus-summary-prepare-hook nil
688 "*A hook called after the summary buffer has been generated.
689 If you want to modify the summary buffer, you can use this hook."
690 :group 'gnus-summary-various
693 (defcustom gnus-summary-prepared-hook nil
694 "*A hook called as the last thing after the summary buffer has been generated."
695 :group 'gnus-summary-various
698 (defcustom gnus-summary-generate-hook nil
699 "*A hook run just before generating the summary buffer.
700 This hook is commonly used to customize threading variables and the
702 :group 'gnus-summary-various
705 (defcustom gnus-select-group-hook nil
706 "*A hook called when a newsgroup is selected.
708 If you'd like to simplify subjects like the
709 `gnus-summary-next-same-subject' command does, you can use the
712 (setq gnus-select-group-hook
715 (mapcar (lambda (header)
716 (mail-header-set-subject
718 (gnus-simplify-subject
719 (mail-header-subject header) 're-only)))
720 gnus-newsgroup-headers))))"
721 :group 'gnus-group-select
724 (defcustom gnus-select-article-hook nil
725 "*A hook called when an article is selected."
726 :group 'gnus-summary-choose
729 (defcustom gnus-visual-mark-article-hook
730 (list 'gnus-highlight-selected-summary)
731 "*Hook run after selecting an article in the summary buffer.
732 It is meant to be used for highlighting the article in some way. It
733 is not run if `gnus-visual' is nil."
734 :group 'gnus-summary-visual
737 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
738 "*A hook called before parsing the headers."
742 (defcustom gnus-exit-group-hook nil
743 "*A hook called when exiting summary mode.
744 This hook is not called from the non-updating exit commands like `Q'."
748 (defcustom gnus-summary-update-hook
749 (list 'gnus-summary-highlight-line)
750 "*A hook called when a summary line is changed.
751 The hook will not be called if `gnus-visual' is nil.
753 The default function `gnus-summary-highlight-line' will
754 highlight the line according to the `gnus-summary-highlight'
756 :group 'gnus-summary-visual
759 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
760 "*A hook called when an article is selected for the first time.
761 The hook is intended to mark an article as read (or unread)
762 automatically when it is selected."
763 :group 'gnus-summary-choose
766 (defcustom gnus-group-no-more-groups-hook nil
767 "*A hook run when returning to group mode having no more (unread) groups."
768 :group 'gnus-group-select
771 (defcustom gnus-ps-print-hook nil
772 "*A hook run before ps-printing something from Gnus."
776 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
777 "Face used for highlighting the current article in the summary buffer."
778 :group 'gnus-summary-visual
781 (defcustom gnus-summary-highlight
782 '(((= mark gnus-canceled-mark)
783 . gnus-summary-cancelled-face)
784 ((and (> score default)
785 (or (= mark gnus-dormant-mark)
786 (= mark gnus-ticked-mark)))
787 . gnus-summary-high-ticked-face)
788 ((and (< score default)
789 (or (= mark gnus-dormant-mark)
790 (= mark gnus-ticked-mark)))
791 . gnus-summary-low-ticked-face)
792 ((or (= mark gnus-dormant-mark)
793 (= mark gnus-ticked-mark))
794 . gnus-summary-normal-ticked-face)
795 ((and (> score default) (= mark gnus-ancient-mark))
796 . gnus-summary-high-ancient-face)
797 ((and (< score default) (= mark gnus-ancient-mark))
798 . gnus-summary-low-ancient-face)
799 ((= mark gnus-ancient-mark)
800 . gnus-summary-normal-ancient-face)
801 ((and (> score default) (= mark gnus-unread-mark))
802 . gnus-summary-high-unread-face)
803 ((and (< score default) (= mark gnus-unread-mark))
804 . gnus-summary-low-unread-face)
805 ((and (memq article gnus-newsgroup-incorporated)
806 (= mark gnus-unread-mark))
807 . gnus-summary-incorporated-face)
808 ((= mark gnus-unread-mark)
809 . gnus-summary-normal-unread-face)
810 ((and (> score default) (memq mark (list gnus-downloadable-mark
811 gnus-undownloaded-mark)))
812 . gnus-summary-high-unread-face)
813 ((and (< score default) (memq mark (list gnus-downloadable-mark
814 gnus-undownloaded-mark)))
815 . gnus-summary-low-unread-face)
816 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
817 . gnus-summary-normal-unread-face)
819 . gnus-summary-high-read-face)
821 . gnus-summary-low-read-face)
823 . gnus-summary-normal-read-face))
824 "*Controls the highlighting of summary buffer lines.
826 A list of (FORM . FACE) pairs. When deciding how a a particular
827 summary line should be displayed, each form is evaluated. The content
828 of the face field after the first true form is used. You can change
829 how those summary lines are displayed, by editing the face field.
831 You can use the following variables in the FORM field.
833 score: The articles score
834 default: The default article score.
835 below: The score below which articles are automatically marked as read.
836 mark: The articles mark."
837 :group 'gnus-summary-visual
838 :type '(repeat (cons (sexp :tag "Form" nil)
841 (defcustom gnus-alter-header-function nil
842 "Function called to allow alteration of article header structures.
843 The function is called with one parameter, the article header vector,
844 which it may alter in any way.")
846 (defvar gnus-decode-encoded-word-function
847 (mime-find-field-decoder 'From 'nov)
848 "Variable that says which function should be used to decode a string with encoded words.")
850 (defcustom gnus-extra-headers nil
851 "*Extra headers to parse."
854 :type '(repeat symbol))
856 (defcustom gnus-ignored-from-addresses
857 (and user-mail-address (regexp-quote user-mail-address))
858 "*Regexp of From headers that may be suppressed in favor of To headers."
863 (defcustom gnus-group-charset-alist
864 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
865 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
866 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
867 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
868 ("^relcom\\>" koi8-r)
870 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
871 ("^israel\\>" iso-8859-1)
873 ("^alt.chinese.text.big5\\>" chinese-big5)
874 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
875 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
877 "Alist of regexps (to match group names) and default charsets to be used when reading."
878 :type '(repeat (list (regexp :tag "Group")
879 (symbol :tag "Charset")))
880 :group 'gnus-charset)
882 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
883 "List of charsets that should be ignored.
884 When these charsets are used in the \"charset\" parameter, the
885 default charset will be used instead."
887 :type '(repeat symbol)
888 :group 'gnus-charset)
890 (defcustom gnus-group-ignored-charsets-alist
891 '(("alt\\.chinese\\.text" iso-8859-1))
892 "Alist of regexps (to match group names) and charsets that should be ignored.
893 When these charsets are used in the \"charset\" parameter, the
894 default charset will be used instead."
895 :type '(repeat (cons (regexp :tag "Group")
897 :group 'gnus-charset)
899 (defcustom gnus-group-highlight-words-alist nil
900 "Alist of group regexps and highlight regexps.
901 This variable uses the same syntax as `gnus-emphasis-alist'."
903 :type '(repeat (cons (regexp :tag "Group")
904 (repeat (list (regexp :tag "Highlight regexp")
905 (number :tag "Group for entire word" 0)
906 (number :tag "Group for displayed part" 0)
908 gnus-emphasis-highlight-words)))))
909 :group 'gnus-summary-visual)
911 (defcustom gnus-use-wheel nil
912 "Use Intelli-mouse on summary movement"
914 :group 'gnus-summary-maneuvering)
916 (defcustom gnus-wheel-scroll-amount '(5 . 1)
917 "Amount to scroll messages by spinning the mouse wheel.
918 This is actually a cons cell, where the first item is the amount to scroll
919 on a normal wheel event, and the second is the amount to scroll when the
920 wheel is moved with the shift key depressed."
921 :type '(cons (integer :tag "Shift") integer)
922 :group 'gnus-summary-maneuvering)
924 (defcustom gnus-wheel-edge-resistance 2
925 "How hard it should be to change the current article
926 by moving the mouse over the edge of the article window."
928 :group 'gnus-summary-maneuvering)
930 (defcustom gnus-summary-show-article-charset-alist
932 "Alist of number and charset.
933 The article will be shown with the charset corresponding to the
935 For example: ((1 . cn-gb-2312) (2 . big5))."
937 :type '(repeat (cons (number :tag "Argument" 1)
938 (symbol :tag "Charset")))
939 :group 'gnus-charset)
941 (defcustom gnus-preserve-marks t
942 "Whether marks are preserved when moving, copying and respooling messages."
945 :group 'gnus-summary-marks)
947 (defcustom gnus-alter-articles-to-read-function nil
948 "Function to be called to alter the list of articles to be selected."
950 :group 'gnus-summary)
952 (defcustom gnus-orphan-score nil
953 "*All orphans get this score added. Set in the score file."
954 :group 'gnus-score-default
955 :type '(choice (const nil)
958 (defcustom gnus-summary-save-parts-default-mime "image/.*"
959 "*A regexp to match MIME parts when saving multiple parts of a message
960 with gnus-summary-save-parts (X m). This regexp will be used by default
961 when prompting the user for which type of files to save."
966 (defcustom gnus-summary-save-parts-default-mime "image/.*"
967 "*A regexp to match MIME parts when saving multiple parts of a message
968 with gnus-summary-save-parts (X m). This regexp will be used by default
969 when prompting the user for which type of files to save."
974 ;;; Internal variables
976 (defvar gnus-article-mime-handles nil)
977 (defvar gnus-article-decoded-p nil)
978 (defvar gnus-article-charset nil)
979 (defvar gnus-article-ignored-charsets nil)
980 (defvar gnus-scores-exclude-files nil)
981 (defvar gnus-page-broken nil)
982 (defvar gnus-inhibit-mime-unbuttonizing nil)
984 (defvar gnus-original-article nil)
985 (defvar gnus-article-internal-prepare-hook nil)
986 (defvar gnus-newsgroup-process-stack nil)
988 (defvar gnus-thread-indent-array nil)
989 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
990 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
991 "Function called to sort the articles within a thread after it has been gathered together.")
993 (defvar gnus-summary-save-parts-type-history nil)
994 (defvar gnus-summary-save-parts-last-directory nil)
996 (defvar gnus-summary-save-parts-type-history nil)
997 (defvar gnus-summary-save-parts-last-directory nil)
999 ;; Avoid highlighting in kill files.
1000 (defvar gnus-summary-inhibit-highlight nil)
1001 (defvar gnus-newsgroup-selected-overlay nil)
1002 (defvar gnus-inhibit-limiting nil)
1003 (defvar gnus-newsgroup-adaptive-score-file nil)
1004 (defvar gnus-current-score-file nil)
1005 (defvar gnus-current-move-group nil)
1006 (defvar gnus-current-copy-group nil)
1007 (defvar gnus-current-crosspost-group nil)
1009 (defvar gnus-newsgroup-dependencies nil)
1010 (defvar gnus-newsgroup-adaptive nil)
1011 (defvar gnus-summary-display-article-function nil)
1012 (defvar gnus-summary-highlight-line-function nil
1013 "Function called after highlighting a summary line.")
1015 (defvar gnus-summary-line-format-alist
1016 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1017 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1018 (?s gnus-tmp-subject-or-nil ?s)
1019 (?n gnus-tmp-name ?s)
1020 (?A (std11-address-string
1021 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1022 (?a (or (std11-full-name-string
1023 (car (mime-entity-read-field gnus-tmp-header 'From)))
1025 (?F gnus-tmp-from ?s)
1026 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1027 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1028 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1029 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1030 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1031 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1032 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1033 (?L gnus-tmp-lines ?d)
1034 (?I gnus-tmp-indentation ?s)
1035 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1036 (?R gnus-tmp-replied ?c)
1037 (?\[ gnus-tmp-opening-bracket ?c)
1038 (?\] gnus-tmp-closing-bracket ?c)
1039 (?\> (make-string gnus-tmp-level ? ) ?s)
1040 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1041 (?i gnus-tmp-score ?d)
1042 (?z gnus-tmp-score-char ?c)
1043 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1044 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1045 (?U gnus-tmp-unread ?c)
1046 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1047 (?t (gnus-summary-number-of-articles-in-thread
1048 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1050 (?e (gnus-summary-number-of-articles-in-thread
1051 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1053 (?u gnus-tmp-user-defined ?s)
1054 (?P (gnus-pick-line-number) ?d))
1055 "An alist of format specifications that can appear in summary lines.
1056 These are paired with what variables they correspond with, along with
1057 the type of the variable (string, integer, character, etc).")
1059 (defvar gnus-summary-dummy-line-format-alist
1060 `((?S gnus-tmp-subject ?s)
1061 (?N gnus-tmp-number ?d)
1062 (?u gnus-tmp-user-defined ?s)))
1064 (defvar gnus-summary-mode-line-format-alist
1065 `((?G gnus-tmp-group-name ?s)
1066 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1067 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1068 (?A gnus-tmp-article-number ?d)
1069 (?Z gnus-tmp-unread-and-unselected ?s)
1070 (?V gnus-version ?s)
1071 (?U gnus-tmp-unread-and-unticked ?d)
1072 (?S gnus-tmp-subject ?s)
1073 (?e gnus-tmp-unselected ?d)
1074 (?u gnus-tmp-user-defined ?s)
1075 (?d (length gnus-newsgroup-dormant) ?d)
1076 (?t (length gnus-newsgroup-marked) ?d)
1077 (?r (length gnus-newsgroup-reads) ?d)
1078 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1079 (?E gnus-newsgroup-expunged-tally ?d)
1080 (?s (gnus-current-score-file-nondirectory) ?s)))
1082 (defvar gnus-last-search-regexp nil
1083 "Default regexp for article search command.")
1085 (defvar gnus-summary-search-article-matched-data nil
1086 "Last matched data of article search command. It is the local variable
1087 in `gnus-article-buffer' which consists of the list of start position,
1088 end position and text.")
1090 (defvar gnus-last-shell-command nil
1091 "Default shell command on article.")
1093 (defvar gnus-newsgroup-begin nil)
1094 (defvar gnus-newsgroup-end nil)
1095 (defvar gnus-newsgroup-last-rmail nil)
1096 (defvar gnus-newsgroup-last-mail nil)
1097 (defvar gnus-newsgroup-last-folder nil)
1098 (defvar gnus-newsgroup-last-file nil)
1099 (defvar gnus-newsgroup-auto-expire nil)
1100 (defvar gnus-newsgroup-active nil)
1102 (defvar gnus-newsgroup-data nil)
1103 (defvar gnus-newsgroup-data-reverse nil)
1104 (defvar gnus-newsgroup-limit nil)
1105 (defvar gnus-newsgroup-limits nil)
1107 (defvar gnus-newsgroup-unreads nil
1108 "List of unread articles in the current newsgroup.")
1110 (defvar gnus-newsgroup-unselected nil
1111 "List of unselected unread articles in the current newsgroup.")
1113 (defvar gnus-newsgroup-reads nil
1114 "Alist of read articles and article marks in the current newsgroup.")
1116 (defvar gnus-newsgroup-expunged-tally nil)
1118 (defvar gnus-newsgroup-marked nil
1119 "List of ticked articles in the current newsgroup (a subset of unread art).")
1121 (defvar gnus-newsgroup-killed nil
1122 "List of ranges of articles that have been through the scoring process.")
1124 (defvar gnus-newsgroup-cached nil
1125 "List of articles that come from the article cache.")
1127 (defvar gnus-newsgroup-saved nil
1128 "List of articles that have been saved.")
1130 (defvar gnus-newsgroup-kill-headers nil)
1132 (defvar gnus-newsgroup-replied nil
1133 "List of articles that have been replied to in the current newsgroup.")
1135 (defvar gnus-newsgroup-expirable nil
1136 "List of articles in the current newsgroup that can be expired.")
1138 (defvar gnus-newsgroup-processable nil
1139 "List of articles in the current newsgroup that can be processed.")
1141 (defvar gnus-newsgroup-downloadable nil
1142 "List of articles in the current newsgroup that can be processed.")
1144 (defvar gnus-newsgroup-undownloaded nil
1145 "List of articles in the current newsgroup that haven't been downloaded..")
1147 (defvar gnus-newsgroup-unsendable nil
1148 "List of articles in the current newsgroup that won't be sent.")
1150 (defvar gnus-newsgroup-bookmarks nil
1151 "List of articles in the current newsgroup that have bookmarks.")
1153 (defvar gnus-newsgroup-dormant nil
1154 "List of dormant articles in the current newsgroup.")
1156 (defvar gnus-newsgroup-scored nil
1157 "List of scored articles in the current newsgroup.")
1159 (defvar gnus-newsgroup-incorporated nil
1160 "List of incorporated articles in the current newsgroup.")
1162 (defvar gnus-newsgroup-headers nil
1163 "List of article headers in the current newsgroup.")
1165 (defvar gnus-newsgroup-threads nil)
1167 (defvar gnus-newsgroup-prepared nil
1168 "Whether the current group has been prepared properly.")
1170 (defvar gnus-newsgroup-ancient nil
1171 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1173 (defvar gnus-newsgroup-sparse nil)
1175 (defvar gnus-current-article nil)
1176 (defvar gnus-article-current nil)
1177 (defvar gnus-current-headers nil)
1178 (defvar gnus-have-all-headers nil)
1179 (defvar gnus-last-article nil)
1180 (defvar gnus-newsgroup-history nil)
1181 (defvar gnus-newsgroup-charset nil)
1182 (defvar gnus-newsgroup-ephemeral-charset nil)
1183 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1185 (defvar gnus-article-before-search nil)
1187 (defconst gnus-summary-local-variables
1188 '(gnus-newsgroup-name
1189 gnus-newsgroup-begin gnus-newsgroup-end
1190 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1191 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1192 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1193 gnus-newsgroup-unselected gnus-newsgroup-marked
1194 gnus-newsgroup-reads gnus-newsgroup-saved
1195 gnus-newsgroup-replied gnus-newsgroup-expirable
1196 gnus-newsgroup-processable gnus-newsgroup-killed
1197 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1198 gnus-newsgroup-unsendable
1199 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1200 gnus-newsgroup-headers gnus-newsgroup-threads
1201 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1202 gnus-current-article gnus-current-headers gnus-have-all-headers
1203 gnus-last-article gnus-article-internal-prepare-hook
1204 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1205 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1206 gnus-thread-expunge-below
1207 gnus-score-alist gnus-current-score-file
1208 (gnus-summary-expunge-below . global)
1209 (gnus-summary-mark-below . global)
1210 (gnus-orphan-score . global)
1211 gnus-newsgroup-active gnus-scores-exclude-files
1212 gnus-newsgroup-history gnus-newsgroup-ancient
1213 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1214 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1215 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1216 (gnus-newsgroup-expunged-tally . 0)
1217 gnus-cache-removable-articles gnus-newsgroup-cached
1218 gnus-newsgroup-data gnus-newsgroup-data-reverse
1219 gnus-newsgroup-limit gnus-newsgroup-limits
1220 gnus-newsgroup-charset
1221 gnus-newsgroup-incorporated)
1222 "Variables that are buffer-local to the summary buffers.")
1224 (defvar gnus-newsgroup-variables nil
1225 "Variables that have separate values in the newsgroups.")
1227 ;; Byte-compiler warning.
1228 (eval-when-compile (defvar gnus-article-mode-map))
1230 ;; Subject simplification.
1232 (defun gnus-simplify-whitespace (str)
1233 "Remove excessive whitespace from STR."
1236 (while (string-match "[ \t][ \t]+" mystr)
1237 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1239 (substring mystr (match-end 0)))))
1241 (when (string-match "^[ \t]+" mystr)
1242 (setq mystr (substring mystr (match-end 0))))
1244 (when (string-match "[ \t]+$" mystr)
1245 (setq mystr (substring mystr 0 (match-beginning 0))))
1248 (defsubst gnus-simplify-subject-re (subject)
1249 "Remove \"Re:\" from subject lines."
1250 (if (string-match "^[Rr][Ee]: *" subject)
1251 (substring subject (match-end 0))
1254 (defun gnus-simplify-subject (subject &optional re-only)
1255 "Remove `Re:' and words in parentheses.
1256 If RE-ONLY is non-nil, strip leading `Re:'s only."
1257 (let ((case-fold-search t)) ;Ignore case.
1258 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1259 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1260 (setq subject (substring subject (match-end 0))))
1261 ;; Remove uninteresting prefixes.
1262 (when (and (not re-only)
1263 gnus-simplify-ignored-prefixes
1264 (string-match gnus-simplify-ignored-prefixes subject))
1265 (setq subject (substring subject (match-end 0))))
1266 ;; Remove words in parentheses from end.
1268 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1269 (setq subject (substring subject 0 (match-beginning 0)))))
1270 ;; Return subject string.
1273 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1275 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1276 (goto-char (point-min))
1277 (while (re-search-forward regexp nil t)
1278 (replace-match (or newtext ""))))
1280 (defun gnus-simplify-buffer-fuzzy ()
1281 "Simplify string in the buffer fuzzily.
1282 The string in the accessible portion of the current buffer is simplified.
1283 It is assumed to be a single-line subject.
1284 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1285 matter is removed. Additional things can be deleted by setting
1286 `gnus-simplify-subject-fuzzy-regexp'."
1287 (let ((case-fold-search t)
1289 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1291 (while (not (eq modified-tick (buffer-modified-tick)))
1292 (setq modified-tick (buffer-modified-tick))
1294 ((listp gnus-simplify-subject-fuzzy-regexp)
1295 (mapcar 'gnus-simplify-buffer-fuzzy-step
1296 gnus-simplify-subject-fuzzy-regexp))
1297 (gnus-simplify-subject-fuzzy-regexp
1298 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1299 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1300 (gnus-simplify-buffer-fuzzy-step
1301 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1302 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1304 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1305 (gnus-simplify-buffer-fuzzy-step " +" " ")
1306 (gnus-simplify-buffer-fuzzy-step " $")
1307 (gnus-simplify-buffer-fuzzy-step "^ +")))
1309 (defun gnus-simplify-subject-fuzzy (subject)
1310 "Simplify a subject string fuzzily.
1311 See `gnus-simplify-buffer-fuzzy' for details."
1313 (gnus-set-work-buffer)
1314 (let ((case-fold-search t))
1315 ;; Remove uninteresting prefixes.
1316 (when (and gnus-simplify-ignored-prefixes
1317 (string-match gnus-simplify-ignored-prefixes subject))
1318 (setq subject (substring subject (match-end 0))))
1320 (inline (gnus-simplify-buffer-fuzzy))
1323 (defsubst gnus-simplify-subject-fully (subject)
1324 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1326 (gnus-simplify-subject-functions
1327 (gnus-map-function gnus-simplify-subject-functions subject))
1328 ((null gnus-summary-gather-subject-limit)
1329 (gnus-simplify-subject-re subject))
1330 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1331 (gnus-simplify-subject-fuzzy subject))
1332 ((numberp gnus-summary-gather-subject-limit)
1333 (gnus-limit-string (gnus-simplify-subject-re subject)
1334 gnus-summary-gather-subject-limit))
1338 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1339 "Check whether two subjects are equal.
1340 If optional argument simple-first is t, first argument is already
1343 ((null simple-first)
1344 (equal (gnus-simplify-subject-fully s1)
1345 (gnus-simplify-subject-fully s2)))
1348 (gnus-simplify-subject-fully s2)))))
1350 (defun gnus-summary-bubble-group ()
1351 "Increase the score of the current group.
1352 This is a handy function to add to `gnus-summary-exit-hook' to
1353 increase the score of each group you read."
1354 (gnus-group-add-score gnus-newsgroup-name))
1358 ;;; Gnus summary mode
1361 (put 'gnus-summary-mode 'mode-class 'special)
1364 ;; Non-orthogonal keys
1366 (gnus-define-keys gnus-summary-mode-map
1367 " " gnus-summary-next-page
1368 "\177" gnus-summary-prev-page
1369 [delete] gnus-summary-prev-page
1370 [backspace] gnus-summary-prev-page
1371 "\r" gnus-summary-scroll-up
1372 "\M-\r" gnus-summary-scroll-down
1373 "n" gnus-summary-next-unread-article
1374 "p" gnus-summary-prev-unread-article
1375 "N" gnus-summary-next-article
1376 "P" gnus-summary-prev-article
1377 "\M-\C-n" gnus-summary-next-same-subject
1378 "\M-\C-p" gnus-summary-prev-same-subject
1379 "\M-n" gnus-summary-next-unread-subject
1380 "\M-p" gnus-summary-prev-unread-subject
1381 "." gnus-summary-first-unread-article
1382 "," gnus-summary-best-unread-article
1383 "\M-s" gnus-summary-search-article-forward
1384 "\M-r" gnus-summary-search-article-backward
1385 "<" gnus-summary-beginning-of-article
1386 ">" gnus-summary-end-of-article
1387 "j" gnus-summary-goto-article
1388 "^" gnus-summary-refer-parent-article
1389 "\M-^" gnus-summary-refer-article
1390 "u" gnus-summary-tick-article-forward
1391 "!" gnus-summary-tick-article-forward
1392 "U" gnus-summary-tick-article-backward
1393 "d" gnus-summary-mark-as-read-forward
1394 "D" gnus-summary-mark-as-read-backward
1395 "E" gnus-summary-mark-as-expirable
1396 "\M-u" gnus-summary-clear-mark-forward
1397 "\M-U" gnus-summary-clear-mark-backward
1398 "k" gnus-summary-kill-same-subject-and-select
1399 "\C-k" gnus-summary-kill-same-subject
1400 "\M-\C-k" gnus-summary-kill-thread
1401 "\M-\C-l" gnus-summary-lower-thread
1402 "e" gnus-summary-edit-article
1403 "#" gnus-summary-mark-as-processable
1404 "\M-#" gnus-summary-unmark-as-processable
1405 "\M-\C-t" gnus-summary-toggle-threads
1406 "\M-\C-s" gnus-summary-show-thread
1407 "\M-\C-h" gnus-summary-hide-thread
1408 "\M-\C-f" gnus-summary-next-thread
1409 "\M-\C-b" gnus-summary-prev-thread
1410 [(meta down)] gnus-summary-next-thread
1411 [(meta up)] gnus-summary-prev-thread
1412 "\M-\C-u" gnus-summary-up-thread
1413 "\M-\C-d" gnus-summary-down-thread
1414 "&" gnus-summary-execute-command
1415 "c" gnus-summary-catchup-and-exit
1416 "\C-w" gnus-summary-mark-region-as-read
1417 "\C-t" gnus-summary-toggle-truncation
1418 "?" gnus-summary-mark-as-dormant
1419 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1420 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1421 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1422 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1423 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1424 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1425 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1426 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1427 "=" gnus-summary-expand-window
1428 "\C-x\C-s" gnus-summary-reselect-current-group
1429 "\M-g" gnus-summary-rescan-group
1430 "w" gnus-summary-stop-page-breaking
1431 "\C-c\C-r" gnus-summary-caesar-message
1432 "\M-t" gnus-summary-toggle-mime
1433 "f" gnus-summary-followup
1434 "F" gnus-summary-followup-with-original
1435 "C" gnus-summary-cancel-article
1436 "r" gnus-summary-reply
1437 "R" gnus-summary-reply-with-original
1438 "\C-c\C-f" gnus-summary-mail-forward
1439 "o" gnus-summary-save-article
1440 "\C-o" gnus-summary-save-article-mail
1441 "|" gnus-summary-pipe-output
1442 "\M-k" gnus-summary-edit-local-kill
1443 "\M-K" gnus-summary-edit-global-kill
1445 "\C-c\C-d" gnus-summary-describe-group
1446 "q" gnus-summary-exit
1447 "Q" gnus-summary-exit-no-update
1448 "\C-c\C-i" gnus-info-find-node
1449 gnus-mouse-2 gnus-mouse-pick-article
1450 "m" gnus-summary-mail-other-window
1451 "a" gnus-summary-post-news
1452 "x" gnus-summary-limit-to-unread
1453 "s" gnus-summary-isearch-article
1454 "t" gnus-article-toggle-headers
1455 "g" gnus-summary-show-article
1456 "l" gnus-summary-goto-last-article
1457 "v" gnus-summary-preview-mime-message
1458 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1459 "\C-d" gnus-summary-enter-digest-group
1460 "\M-\C-d" gnus-summary-read-document
1461 "\M-\C-e" gnus-summary-edit-parameters
1462 "\M-\C-a" gnus-summary-customize-parameters
1464 "*" gnus-cache-enter-article
1465 "\M-*" gnus-cache-remove-article
1466 "\M-&" gnus-summary-universal-argument
1467 "\C-l" gnus-recenter
1468 "I" gnus-summary-increase-score
1469 "L" gnus-summary-lower-score
1470 "\M-i" gnus-symbolic-argument
1471 "h" gnus-summary-select-article-buffer
1473 "V" gnus-summary-score-map
1474 "X" gnus-uu-extract-map
1475 "S" gnus-summary-send-map)
1477 ;; Sort of orthogonal keymap
1478 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1479 "t" gnus-summary-tick-article-forward
1480 "!" gnus-summary-tick-article-forward
1481 "d" gnus-summary-mark-as-read-forward
1482 "r" gnus-summary-mark-as-read-forward
1483 "c" gnus-summary-clear-mark-forward
1484 " " gnus-summary-clear-mark-forward
1485 "e" gnus-summary-mark-as-expirable
1486 "x" gnus-summary-mark-as-expirable
1487 "?" gnus-summary-mark-as-dormant
1488 "b" gnus-summary-set-bookmark
1489 "B" gnus-summary-remove-bookmark
1490 "#" gnus-summary-mark-as-processable
1491 "\M-#" gnus-summary-unmark-as-processable
1492 "S" gnus-summary-limit-include-expunged
1493 "C" gnus-summary-catchup
1494 "H" gnus-summary-catchup-to-here
1495 "\C-c" gnus-summary-catchup-all
1496 "k" gnus-summary-kill-same-subject-and-select
1497 "K" gnus-summary-kill-same-subject
1498 "P" gnus-uu-mark-map)
1500 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1501 "c" gnus-summary-clear-above
1502 "u" gnus-summary-tick-above
1503 "m" gnus-summary-mark-above
1504 "k" gnus-summary-kill-below)
1506 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1507 "/" gnus-summary-limit-to-subject
1508 "n" gnus-summary-limit-to-articles
1509 "w" gnus-summary-pop-limit
1510 "s" gnus-summary-limit-to-subject
1511 "a" gnus-summary-limit-to-author
1512 "u" gnus-summary-limit-to-unread
1513 "m" gnus-summary-limit-to-marks
1514 "M" gnus-summary-limit-exclude-marks
1515 "v" gnus-summary-limit-to-score
1516 "*" gnus-summary-limit-include-cached
1517 "D" gnus-summary-limit-include-dormant
1518 "T" gnus-summary-limit-include-thread
1519 "d" gnus-summary-limit-exclude-dormant
1520 "t" gnus-summary-limit-to-age
1521 "x" gnus-summary-limit-to-extra
1522 "E" gnus-summary-limit-include-expunged
1523 "c" gnus-summary-limit-exclude-childless-dormant
1524 "C" gnus-summary-limit-mark-excluded-as-read)
1526 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1527 "n" gnus-summary-next-unread-article
1528 "p" gnus-summary-prev-unread-article
1529 "N" gnus-summary-next-article
1530 "P" gnus-summary-prev-article
1531 "\C-n" gnus-summary-next-same-subject
1532 "\C-p" gnus-summary-prev-same-subject
1533 "\M-n" gnus-summary-next-unread-subject
1534 "\M-p" gnus-summary-prev-unread-subject
1535 "f" gnus-summary-first-unread-article
1536 "b" gnus-summary-best-unread-article
1537 "j" gnus-summary-goto-article
1538 "g" gnus-summary-goto-subject
1539 "l" gnus-summary-goto-last-article
1540 "o" gnus-summary-pop-article)
1542 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1543 "k" gnus-summary-kill-thread
1544 "l" gnus-summary-lower-thread
1545 "i" gnus-summary-raise-thread
1546 "T" gnus-summary-toggle-threads
1547 "t" gnus-summary-rethread-current
1548 "^" gnus-summary-reparent-thread
1549 "s" gnus-summary-show-thread
1550 "S" gnus-summary-show-all-threads
1551 "h" gnus-summary-hide-thread
1552 "H" gnus-summary-hide-all-threads
1553 "n" gnus-summary-next-thread
1554 "p" gnus-summary-prev-thread
1555 "u" gnus-summary-up-thread
1556 "o" gnus-summary-top-thread
1557 "d" gnus-summary-down-thread
1558 "#" gnus-uu-mark-thread
1559 "\M-#" gnus-uu-unmark-thread)
1561 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1562 "g" gnus-summary-prepare
1563 "c" gnus-summary-insert-cached-articles)
1565 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1566 "c" gnus-summary-catchup-and-exit
1567 "C" gnus-summary-catchup-all-and-exit
1568 "E" gnus-summary-exit-no-update
1569 "J" gnus-summary-jump-to-other-group
1570 "Q" gnus-summary-exit
1571 "Z" gnus-summary-exit
1572 "n" gnus-summary-catchup-and-goto-next-group
1573 "R" gnus-summary-reselect-current-group
1574 "G" gnus-summary-rescan-group
1575 "N" gnus-summary-next-group
1576 "s" gnus-summary-save-newsrc
1577 "P" gnus-summary-prev-group)
1579 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1580 " " gnus-summary-next-page
1581 "n" gnus-summary-next-page
1582 "\177" gnus-summary-prev-page
1583 [delete] gnus-summary-prev-page
1584 "p" gnus-summary-prev-page
1585 "\r" gnus-summary-scroll-up
1586 "\M-\r" gnus-summary-scroll-down
1587 "<" gnus-summary-beginning-of-article
1588 ">" gnus-summary-end-of-article
1589 "b" gnus-summary-beginning-of-article
1590 "e" gnus-summary-end-of-article
1591 "^" gnus-summary-refer-parent-article
1592 "r" gnus-summary-refer-parent-article
1593 "D" gnus-summary-enter-digest-group
1594 "R" gnus-summary-refer-references
1595 "T" gnus-summary-refer-thread
1596 "g" gnus-summary-show-article
1597 "s" gnus-summary-isearch-article
1598 "P" gnus-summary-print-article
1599 "M" gnus-mailing-list-insinuate
1600 "t" gnus-article-babel)
1602 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1603 "b" gnus-article-add-buttons
1604 "B" gnus-article-add-buttons-to-head
1605 "o" gnus-article-treat-overstrike
1606 "e" gnus-article-emphasize
1607 "w" gnus-article-fill-cited-article
1608 "Q" gnus-article-fill-long-lines
1609 "C" gnus-article-capitalize-sentences
1610 "c" gnus-article-remove-cr
1611 "Z" gnus-article-decode-HZ
1612 "f" gnus-article-display-x-face
1613 "l" gnus-summary-stop-page-breaking
1614 "r" gnus-summary-caesar-message
1615 "t" gnus-article-toggle-headers
1616 "v" gnus-summary-verbose-headers
1617 "m" gnus-summary-toggle-mime
1618 "H" gnus-article-strip-headers-in-body
1619 "p" gnus-article-verify-x-pgp-sig
1620 "d" gnus-article-treat-dumbquotes
1621 "s" gnus-smiley-display)
1623 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1624 "a" gnus-article-hide
1625 "h" gnus-article-toggle-headers
1626 "b" gnus-article-hide-boring-headers
1627 "s" gnus-article-hide-signature
1628 "c" gnus-article-hide-citation
1629 "C" gnus-article-hide-citation-in-followups
1630 "l" gnus-article-hide-list-identifiers
1631 "p" gnus-article-hide-pgp
1632 "B" gnus-article-strip-banner
1633 "P" gnus-article-hide-pem
1634 "\C-c" gnus-article-hide-citation-maybe)
1636 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1637 "a" gnus-article-highlight
1638 "h" gnus-article-highlight-headers
1639 "c" gnus-article-highlight-citation
1640 "s" gnus-article-highlight-signature)
1642 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1643 "z" gnus-article-date-ut
1644 "u" gnus-article-date-ut
1645 "l" gnus-article-date-local
1646 "e" gnus-article-date-lapsed
1647 "o" gnus-article-date-original
1648 "i" gnus-article-date-iso8601
1649 "s" gnus-article-date-user)
1651 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1652 "t" gnus-article-remove-trailing-blank-lines
1653 "l" gnus-article-strip-leading-blank-lines
1654 "m" gnus-article-strip-multiple-blank-lines
1655 "a" gnus-article-strip-blank-lines
1656 "A" gnus-article-strip-all-blank-lines
1657 "s" gnus-article-strip-leading-space
1658 "e" gnus-article-strip-trailing-space)
1660 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1662 "f" gnus-summary-fetch-faq
1663 "d" gnus-summary-describe-group
1664 "h" gnus-summary-describe-briefly
1665 "i" gnus-info-find-node)
1667 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1668 "e" gnus-summary-expire-articles
1669 "\M-\C-e" gnus-summary-expire-articles-now
1670 "\177" gnus-summary-delete-article
1671 [delete] gnus-summary-delete-article
1672 [backspace] gnus-summary-delete-article
1673 "m" gnus-summary-move-article
1674 "r" gnus-summary-respool-article
1675 "w" gnus-summary-edit-article
1676 "c" gnus-summary-copy-article
1677 "B" gnus-summary-crosspost-article
1678 "q" gnus-summary-respool-query
1679 "t" gnus-summary-respool-trace
1680 "i" gnus-summary-import-article
1681 "p" gnus-summary-article-posted-p)
1683 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1684 "o" gnus-summary-save-article
1685 "m" gnus-summary-save-article-mail
1686 "F" gnus-summary-write-article-file
1687 "r" gnus-summary-save-article-rmail
1688 "f" gnus-summary-save-article-file
1689 "b" gnus-summary-save-article-body-file
1690 "h" gnus-summary-save-article-folder
1691 "v" gnus-summary-save-article-vm
1692 "p" gnus-summary-pipe-output
1693 "s" gnus-soup-add-article)
1695 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1696 "b" gnus-summary-display-buttonized
1697 "m" gnus-summary-repair-multipart
1698 "v" gnus-article-view-part
1699 "o" gnus-article-save-part
1700 "c" gnus-article-copy-part
1701 "C" gnus-article-view-part-as-charset
1702 "e" gnus-article-externalize-part
1703 "E" gnus-article-encrypt-body
1704 "i" gnus-article-inline-part
1705 "|" gnus-article-pipe-part))
1707 (defun gnus-summary-make-menu-bar ()
1708 (gnus-turn-off-edit-menu 'summary)
1710 (unless (boundp 'gnus-summary-misc-menu)
1713 gnus-summary-kill-menu gnus-summary-mode-map ""
1718 ["Enter score..." gnus-summary-score-entry t]
1719 ["Customize" gnus-score-customize t])
1720 (gnus-make-score-map 'increase)
1721 (gnus-make-score-map 'lower)
1723 ["Kill below" gnus-summary-kill-below t]
1724 ["Mark above" gnus-summary-mark-above t]
1725 ["Tick above" gnus-summary-tick-above t]
1726 ["Clear above" gnus-summary-clear-above t])
1727 ["Current score" gnus-summary-current-score t]
1728 ["Set score" gnus-summary-set-score t]
1729 ["Switch current score file..." gnus-score-change-score-file t]
1730 ["Set mark below..." gnus-score-set-mark-below t]
1731 ["Set expunge below..." gnus-score-set-expunge-below t]
1732 ["Edit current score file" gnus-score-edit-current-scores t]
1733 ["Edit score file" gnus-score-edit-file t]
1734 ["Trace score" gnus-score-find-trace t]
1735 ["Find words" gnus-score-find-favourite-words t]
1736 ["Rescore buffer" gnus-summary-rescore t]
1737 ["Increase score..." gnus-summary-increase-score t]
1738 ["Lower score..." gnus-summary-lower-score t]))))
1740 ;; Define both the Article menu in the summary buffer and the equivalent
1741 ;; Commands menu in the article buffer here for consistency.
1744 ["All" gnus-article-hide t]
1745 ["Headers" gnus-article-toggle-headers t]
1746 ["Signature" gnus-article-hide-signature t]
1747 ["Citation" gnus-article-hide-citation t]
1748 ["List identifiers" gnus-article-hide-list-identifiers t]
1749 ["PGP" gnus-article-hide-pgp t]
1750 ["Banner" gnus-article-strip-banner t]
1751 ["Boring headers" gnus-article-hide-boring-headers t])
1753 ["All" gnus-article-highlight t]
1754 ["Headers" gnus-article-highlight-headers t]
1755 ["Signature" gnus-article-highlight-signature t]
1756 ["Citation" gnus-article-highlight-citation t])
1758 ["Local" gnus-article-date-local t]
1759 ["ISO8601" gnus-article-date-iso8601 t]
1760 ["UT" gnus-article-date-ut t]
1761 ["Original" gnus-article-date-original t]
1762 ["Lapsed" gnus-article-date-lapsed t]
1763 ["User-defined" gnus-article-date-user t])
1766 ["Leading" gnus-article-strip-leading-blank-lines t]
1767 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1768 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1769 ["All of the above" gnus-article-strip-blank-lines t]
1770 ["All" gnus-article-strip-all-blank-lines t]
1771 ["Leading space" gnus-article-strip-leading-space t]
1772 ["Trailing space" gnus-article-strip-trailing-space t])
1773 ["Overstrike" gnus-article-treat-overstrike t]
1774 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1775 ["Emphasis" gnus-article-emphasize t]
1776 ["Word wrap" gnus-article-fill-cited-article t]
1777 ["Fill long lines" gnus-article-fill-long-lines t]
1778 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1779 ["CR" gnus-article-remove-cr t]
1780 ["Show X-Face" gnus-article-display-x-face t]
1781 ["Rot 13" gnus-summary-caesar-message
1782 ,@(if (featurep 'xemacs) nil
1783 '(:help "\"Caesar rotate\" article by 13"))]
1784 ["Unix pipe" gnus-summary-pipe-message t]
1785 ["Add buttons" gnus-article-add-buttons t]
1786 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1787 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1788 ["Toggle MIME" gnus-summary-toggle-mime t]
1789 ["Verbose header" gnus-summary-verbose-headers t]
1790 ["Toggle header" gnus-summary-toggle-header t]
1791 ["Toggle smileys" gnus-smiley-display t]
1792 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1793 ["HZ" gnus-article-decode-HZ t])
1795 ["Save in default format" gnus-summary-save-article
1796 ,@(if (featurep 'xemacs) nil
1797 '(:help "Save article using default method"))]
1798 ["Save in file" gnus-summary-save-article-file
1799 ,@(if (featurep 'xemacs) nil
1800 '(:help "Save article in file"))]
1801 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1802 ["Save in MH folder" gnus-summary-save-article-folder t]
1803 ["Save in VM folder" gnus-summary-save-article-vm t]
1804 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1805 ["Save body in file" gnus-summary-save-article-body-file t]
1806 ["Pipe through a filter" gnus-summary-pipe-output t]
1807 ["Add to SOUP packet" gnus-soup-add-article t]
1808 ["Print" gnus-summary-print-article t])
1810 ["Respool article..." gnus-summary-respool-article t]
1811 ["Move article..." gnus-summary-move-article
1812 (gnus-check-backend-function
1813 'request-move-article gnus-newsgroup-name)]
1814 ["Copy article..." gnus-summary-copy-article t]
1815 ["Crosspost article..." gnus-summary-crosspost-article
1816 (gnus-check-backend-function
1817 'request-replace-article gnus-newsgroup-name)]
1818 ["Import file..." gnus-summary-import-article t]
1819 ["Check if posted" gnus-summary-article-posted-p t]
1820 ["Edit article" gnus-summary-edit-article
1821 (not (gnus-group-read-only-p))]
1822 ["Delete article" gnus-summary-delete-article
1823 (gnus-check-backend-function
1824 'request-expire-articles gnus-newsgroup-name)]
1825 ["Query respool" gnus-summary-respool-query t]
1826 ["Trace respool" gnus-summary-respool-trace t]
1827 ["Delete expirable articles" gnus-summary-expire-articles-now
1828 (gnus-check-backend-function
1829 'request-expire-articles gnus-newsgroup-name)])
1831 ["Uudecode" gnus-uu-decode-uu
1832 ,@(if (featurep 'xemacs) nil
1833 '(:help "Decode uuencoded article(s)"))]
1834 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1835 ["Unshar" gnus-uu-decode-unshar t]
1836 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1837 ["Save" gnus-uu-decode-save t]
1838 ["Binhex" gnus-uu-decode-binhex t]
1839 ["Postscript" gnus-uu-decode-postscript t])
1841 ["Enter article" gnus-cache-enter-article t]
1842 ["Remove article" gnus-cache-remove-article t])
1843 ["Translate" gnus-article-babel t]
1844 ["Select article buffer" gnus-summary-select-article-buffer t]
1845 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1846 ["Isearch article..." gnus-summary-isearch-article t]
1847 ["Beginning of the article" gnus-summary-beginning-of-article t]
1848 ["End of the article" gnus-summary-end-of-article t]
1849 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1850 ["Fetch referenced articles" gnus-summary-refer-references t]
1851 ["Fetch current thread" gnus-summary-refer-thread t]
1852 ["Fetch article with id..." gnus-summary-refer-article t]
1853 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1854 ["Redisplay" gnus-summary-show-article t])))
1856 gnus-summary-article-menu gnus-summary-mode-map ""
1857 (cons "Article" innards))
1860 gnus-article-commands-menu gnus-article-mode-map ""
1861 (cons "Commands" innards)))
1864 gnus-summary-thread-menu gnus-summary-mode-map ""
1866 ["Toggle threading" gnus-summary-toggle-threads t]
1867 ["Hide threads" gnus-summary-hide-all-threads t]
1868 ["Show threads" gnus-summary-show-all-threads t]
1869 ["Hide thread" gnus-summary-hide-thread t]
1870 ["Show thread" gnus-summary-show-thread t]
1871 ["Go to next thread" gnus-summary-next-thread t]
1872 ["Go to previous thread" gnus-summary-prev-thread t]
1873 ["Go down thread" gnus-summary-down-thread t]
1874 ["Go up thread" gnus-summary-up-thread t]
1875 ["Top of thread" gnus-summary-top-thread t]
1876 ["Mark thread as read" gnus-summary-kill-thread t]
1877 ["Lower thread score" gnus-summary-lower-thread t]
1878 ["Raise thread score" gnus-summary-raise-thread t]
1879 ["Rethread current" gnus-summary-rethread-current t]))
1882 gnus-summary-post-menu gnus-summary-mode-map ""
1884 ["Post an article" gnus-summary-post-news
1885 ,@(if (featurep 'xemacs) nil
1886 '(:help "Post an article"))]
1887 ["Followup" gnus-summary-followup
1888 ,@(if (featurep 'xemacs) nil
1889 '(:help "Post followup to this article"))]
1890 ["Followup and yank" gnus-summary-followup-with-original
1891 ,@(if (featurep 'xemacs) nil
1892 '(:help "Post followup to this article, quoting its contents"))]
1893 ["Supersede article" gnus-summary-supersede-article t]
1894 ["Cancel article" gnus-summary-cancel-article
1895 ,@(if (featurep 'xemacs) nil
1896 '(:help "Cancel an article you posted"))]
1897 ["Reply" gnus-summary-reply t]
1898 ["Reply and yank" gnus-summary-reply-with-original t]
1899 ["Wide reply" gnus-summary-wide-reply t]
1900 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1901 ,@(if (featurep 'xemacs) nil
1902 '(:help "Mail a reply, quoting this article"))]
1903 ["Mail forward" gnus-summary-mail-forward t]
1904 ["Post forward" gnus-summary-post-forward t]
1905 ["Digest and mail" gnus-uu-digest-mail-forward t]
1906 ["Digest and post" gnus-uu-digest-post-forward t]
1907 ["Resend message" gnus-summary-resend-message t]
1908 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1909 ["Send a mail" gnus-summary-mail-other-window t]
1910 ["Uuencode and post" gnus-uu-post-news
1911 ,@(if (featurep 'xemacs) nil
1912 '(:help "Post a uuencoded article"))]
1913 ["Followup via news" gnus-summary-followup-to-mail t]
1914 ["Followup via news and yank"
1915 gnus-summary-followup-to-mail-with-original t]
1917 ;;["Send" gnus-summary-send-draft t]
1918 ;;["Send bounced" gnus-resend-bounced-mail t])
1922 gnus-summary-misc-menu gnus-summary-mode-map ""
1925 ["Mark as read" gnus-summary-mark-as-read-forward t]
1926 ["Mark same subject and select"
1927 gnus-summary-kill-same-subject-and-select t]
1928 ["Mark same subject" gnus-summary-kill-same-subject t]
1929 ["Catchup" gnus-summary-catchup
1930 ,@(if (featurep 'xemacs) nil
1931 '(:help "Mark unread articles in this group as read"))]
1932 ["Catchup all" gnus-summary-catchup-all t]
1933 ["Catchup to here" gnus-summary-catchup-to-here t]
1934 ["Catchup region" gnus-summary-mark-region-as-read t]
1935 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1937 ["Tick" gnus-summary-tick-article-forward t]
1938 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1939 ["Remove marks" gnus-summary-clear-mark-forward t]
1940 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1941 ["Set bookmark" gnus-summary-set-bookmark t]
1942 ["Remove bookmark" gnus-summary-remove-bookmark t])
1944 ["Marks..." gnus-summary-limit-to-marks t]
1945 ["Subject..." gnus-summary-limit-to-subject t]
1946 ["Author..." gnus-summary-limit-to-author t]
1947 ["Age..." gnus-summary-limit-to-age t]
1948 ["Extra..." gnus-summary-limit-to-extra t]
1949 ["Score" gnus-summary-limit-to-score t]
1950 ["Unread" gnus-summary-limit-to-unread t]
1951 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1952 ["Articles" gnus-summary-limit-to-articles t]
1953 ["Pop limit" gnus-summary-pop-limit t]
1954 ["Show dormant" gnus-summary-limit-include-dormant t]
1955 ["Hide childless dormant"
1956 gnus-summary-limit-exclude-childless-dormant t]
1957 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1958 ["Hide marked" gnus-summary-limit-exclude-marks t]
1959 ["Show expunged" gnus-summary-show-all-expunged t])
1961 ["Set mark" gnus-summary-mark-as-processable t]
1962 ["Remove mark" gnus-summary-unmark-as-processable t]
1963 ["Remove all marks" gnus-summary-unmark-all-processable t]
1964 ["Mark above" gnus-uu-mark-over t]
1965 ["Mark series" gnus-uu-mark-series t]
1966 ["Mark region" gnus-uu-mark-region t]
1967 ["Unmark region" gnus-uu-unmark-region t]
1968 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1969 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1970 ["Mark all" gnus-uu-mark-all t]
1971 ["Mark buffer" gnus-uu-mark-buffer t]
1972 ["Mark sparse" gnus-uu-mark-sparse t]
1973 ["Mark thread" gnus-uu-mark-thread t]
1974 ["Unmark thread" gnus-uu-unmark-thread t]
1975 ("Process Mark Sets"
1976 ["Kill" gnus-summary-kill-process-mark t]
1977 ["Yank" gnus-summary-yank-process-mark
1978 gnus-newsgroup-process-stack]
1979 ["Save" gnus-summary-save-process-mark t]))
1981 ["Page forward" gnus-summary-next-page
1982 ,@(if (featurep 'xemacs) nil
1983 '(:help "Show next page of article"))]
1984 ["Page backward" gnus-summary-prev-page
1985 ,@(if (featurep 'xemacs) nil
1986 '(:help "Show previous page of article"))]
1987 ["Line forward" gnus-summary-scroll-up t])
1989 ["Next unread article" gnus-summary-next-unread-article t]
1990 ["Previous unread article" gnus-summary-prev-unread-article t]
1991 ["Next article" gnus-summary-next-article t]
1992 ["Previous article" gnus-summary-prev-article t]
1993 ["Next unread subject" gnus-summary-next-unread-subject t]
1994 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1995 ["Next article same subject" gnus-summary-next-same-subject t]
1996 ["Previous article same subject" gnus-summary-prev-same-subject t]
1997 ["First unread article" gnus-summary-first-unread-article t]
1998 ["Best unread article" gnus-summary-best-unread-article t]
1999 ["Go to subject number..." gnus-summary-goto-subject t]
2000 ["Go to article number..." gnus-summary-goto-article t]
2001 ["Go to the last article" gnus-summary-goto-last-article t]
2002 ["Pop article off history" gnus-summary-pop-article t])
2004 ["Sort by number" gnus-summary-sort-by-number t]
2005 ["Sort by author" gnus-summary-sort-by-author t]
2006 ["Sort by subject" gnus-summary-sort-by-subject t]
2007 ["Sort by date" gnus-summary-sort-by-date t]
2008 ["Sort by score" gnus-summary-sort-by-score t]
2009 ["Sort by lines" gnus-summary-sort-by-lines t]
2010 ["Sort by characters" gnus-summary-sort-by-chars t])
2012 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2013 ["Describe group" gnus-summary-describe-group t]
2014 ["Read manual" gnus-info-find-node t])
2016 ["Pick and read" gnus-pick-mode t]
2017 ["Binary" gnus-binary-mode t])
2019 ["Regenerate" gnus-summary-prepare t]
2020 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2021 ["Toggle threading" gnus-summary-toggle-threads t])
2022 ["Filter articles..." gnus-summary-execute-command t]
2023 ["Run command on subjects..." gnus-summary-universal-argument t]
2024 ["Search articles forward..." gnus-summary-search-article-forward t]
2025 ["Search articles backward..." gnus-summary-search-article-backward t]
2026 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2027 ["Expand window" gnus-summary-expand-window t]
2028 ["Expire expirable articles" gnus-summary-expire-articles
2029 (gnus-check-backend-function
2030 'request-expire-articles gnus-newsgroup-name)]
2031 ["Edit local kill file" gnus-summary-edit-local-kill t]
2032 ["Edit main kill file" gnus-summary-edit-global-kill t]
2033 ["Edit group parameters" gnus-summary-edit-parameters t]
2034 ["Customize group parameters" gnus-summary-customize-parameters t]
2035 ["Send a bug report" gnus-bug t]
2037 ["Catchup and exit" gnus-summary-catchup-and-exit
2038 ,@(if (featurep 'xemacs) nil
2039 '(:help "Mark unread articles in this group as read, then exit"))]
2040 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2041 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2042 ["Exit group" gnus-summary-exit
2043 ,@(if (featurep 'xemacs) nil
2044 '(:help "Exit current group, return to group selection mode"))]
2045 ["Exit group without updating" gnus-summary-exit-no-update t]
2046 ["Exit and goto next group" gnus-summary-next-group t]
2047 ["Exit and goto prev group" gnus-summary-prev-group t]
2048 ["Reselect group" gnus-summary-reselect-current-group t]
2049 ["Rescan group" gnus-summary-rescan-group t]
2050 ["Update dribble" gnus-summary-save-newsrc t])))
2052 (gnus-run-hooks 'gnus-summary-menu-hook)))
2054 (defvar gnus-summary-tool-bar-map nil)
2056 ;; Emacs 21 tool bar. Should be no-op otherwise.
2057 (defun gnus-summary-make-tool-bar ()
2058 (if (and (fboundp 'tool-bar-add-item-from-menu)
2059 (default-value 'tool-bar-mode)
2060 (not gnus-summary-tool-bar-map))
2061 (setq gnus-summary-tool-bar-map
2062 (let ((tool-bar-map (make-sparse-keymap))
2063 (load-path (mm-image-load-path)))
2064 (tool-bar-add-item-from-menu
2065 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2066 (tool-bar-add-item-from-menu
2067 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2068 (tool-bar-add-item-from-menu
2069 'gnus-summary-post-news "post" gnus-summary-mode-map)
2070 (tool-bar-add-item-from-menu
2071 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2072 (tool-bar-add-item-from-menu
2073 'gnus-summary-followup "followup" gnus-summary-mode-map)
2074 (tool-bar-add-item-from-menu
2075 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2076 (tool-bar-add-item-from-menu
2077 'gnus-summary-reply "reply" gnus-summary-mode-map)
2078 (tool-bar-add-item-from-menu
2079 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2080 (tool-bar-add-item-from-menu
2081 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2082 (tool-bar-add-item-from-menu
2083 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2084 (tool-bar-add-item-from-menu
2085 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2086 (tool-bar-add-item-from-menu
2087 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2088 (tool-bar-add-item-from-menu
2089 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2090 (tool-bar-add-item-from-menu
2091 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2092 (tool-bar-add-item-from-menu
2093 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2095 (if gnus-summary-tool-bar-map
2096 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2098 (defun gnus-score-set-default (var value)
2099 "A version of set that updates the GNU Emacs menu-bar."
2101 ;; It is the message that forces the active status to be updated.
2104 (defun gnus-make-score-map (type)
2105 "Make a summary score map of type TYPE."
2108 (let ((headers '(("author" "from" string)
2109 ("subject" "subject" string)
2110 ("article body" "body" string)
2111 ("article head" "head" string)
2112 ("xref" "xref" string)
2113 ("extra header" "extra" string)
2114 ("lines" "lines" number)
2115 ("followups to author" "followup" string)))
2116 (types '((number ("less than" <)
2119 (string ("substring" s)
2123 (perms '(("temporary" (current-time-string))
2131 (if (eq type 'lower)
2136 (setq header (car headers))
2142 (let ((ts (cdr (assoc (nth 2 header) types)))
2158 'gnus-summary-score-entry
2160 (if (or (string= (nth 1 header)
2162 (string= (nth 1 header)
2165 (list 'gnus-summary-header
2167 (list 'quote (nth 1 (car ts)))
2168 (list 'gnus-score-delta-default
2175 (list (nreverse outp))))
2178 (list (nreverse outt))))
2180 (setq headers (cdr headers)))
2181 (list (nreverse outh))))))))
2185 (defun gnus-summary-mode (&optional group)
2186 "Major mode for reading articles.
2188 All normal editing commands are switched off.
2189 \\<gnus-summary-mode-map>
2190 Each line in this buffer represents one article. To read an
2191 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2192 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2195 You can also post articles and send mail from this buffer. To
2196 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2197 of an article, type `\\[gnus-summary-reply]'.
2199 There are approx. one gazillion commands you can execute in this
2200 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2202 The following commands are available:
2204 \\{gnus-summary-mode-map}"
2206 (kill-all-local-variables)
2207 (when (gnus-visual-p 'summary-menu 'menu)
2208 (gnus-summary-make-menu-bar)
2209 (gnus-summary-make-tool-bar))
2210 (gnus-summary-make-local-variables)
2211 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2212 (gnus-summary-make-local-variables))
2213 (gnus-make-thread-indent-array)
2214 (gnus-simplify-mode-line)
2215 (setq major-mode 'gnus-summary-mode)
2216 (setq mode-name "Summary")
2217 (make-local-variable 'minor-mode-alist)
2218 (use-local-map gnus-summary-mode-map)
2219 (buffer-disable-undo)
2220 (setq buffer-read-only t) ;Disable modification
2221 (setq truncate-lines t)
2222 (setq selective-display t)
2223 (setq selective-display-ellipses t) ;Display `...'
2224 (gnus-summary-set-display-table)
2225 (gnus-set-default-directory)
2226 (setq gnus-newsgroup-name group)
2227 (unless (gnus-news-group-p group)
2228 (setq gnus-newsgroup-incorporated
2229 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2230 (make-local-variable 'gnus-summary-line-format)
2231 (make-local-variable 'gnus-summary-line-format-spec)
2232 (make-local-variable 'gnus-summary-dummy-line-format)
2233 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2234 (make-local-variable 'gnus-summary-mark-positions)
2235 (make-local-hook 'pre-command-hook)
2236 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2237 (gnus-run-hooks 'gnus-summary-mode-hook)
2238 (turn-on-gnus-mailing-list-mode)
2239 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2240 (gnus-update-summary-mark-positions))
2242 (defun gnus-summary-make-local-variables ()
2243 "Make all the local summary buffer variables."
2245 (dolist (local gnus-summary-local-variables)
2248 (if (eq (cdr local) 'global)
2249 ;; Copy the global value of the variable.
2250 (setq global (symbol-value (car local)))
2251 ;; Use the value from the list.
2252 (setq global (eval (cdr local))))
2253 (set (make-local-variable (car local)) global))
2254 ;; Simple nil-valued local variable.
2255 (set (make-local-variable local) nil)))))
2257 (defun gnus-summary-clear-local-variables ()
2258 (let ((locals gnus-summary-local-variables))
2260 (if (consp (car locals))
2261 (and (vectorp (caar locals))
2262 (set (caar locals) nil))
2263 (and (vectorp (car locals))
2264 (set (car locals) nil)))
2265 (setq locals (cdr locals)))))
2267 ;; Summary data functions.
2269 (defmacro gnus-data-number (data)
2272 (defmacro gnus-data-set-number (data number)
2273 `(setcar ,data ,number))
2275 (defmacro gnus-data-mark (data)
2278 (defmacro gnus-data-set-mark (data mark)
2279 `(setcar (nthcdr 1 ,data) ,mark))
2281 (defmacro gnus-data-pos (data)
2284 (defmacro gnus-data-set-pos (data pos)
2285 `(setcar (nthcdr 2 ,data) ,pos))
2287 (defmacro gnus-data-header (data)
2290 (defmacro gnus-data-set-header (data header)
2291 `(setcar (nthcdr 3 ,data) ,header))
2293 (defmacro gnus-data-level (data)
2296 (defmacro gnus-data-unread-p (data)
2297 `(= (nth 1 ,data) gnus-unread-mark))
2299 (defmacro gnus-data-read-p (data)
2300 `(/= (nth 1 ,data) gnus-unread-mark))
2302 (defmacro gnus-data-pseudo-p (data)
2303 `(consp (nth 3 ,data)))
2305 (defmacro gnus-data-find (number)
2306 `(assq ,number gnus-newsgroup-data))
2308 (defmacro gnus-data-find-list (number &optional data)
2309 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2310 (memq (assq ,number bdata)
2313 (defmacro gnus-data-make (number mark pos header level)
2314 `(list ,number ,mark ,pos ,header ,level))
2316 (defun gnus-data-enter (after-article number mark pos header level offset)
2317 (let ((data (gnus-data-find-list after-article)))
2319 (error "No such article: %d" after-article))
2320 (setcdr data (cons (gnus-data-make number mark pos header level)
2322 (setq gnus-newsgroup-data-reverse nil)
2323 (gnus-data-update-list (cddr data) offset)))
2325 (defun gnus-data-enter-list (after-article list &optional offset)
2327 (let ((data (and after-article (gnus-data-find-list after-article)))
2331 (let ((odata gnus-newsgroup-data))
2332 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2334 (gnus-data-update-list odata offset)))
2335 ;; Find the last element in the list to be spliced into the main
2338 (setq list (cdr list)))
2341 (setcdr list gnus-newsgroup-data)
2342 (setq gnus-newsgroup-data ilist)
2344 (gnus-data-update-list (cdr list) offset)))
2345 (setcdr list (cdr data))
2348 (gnus-data-update-list (cdr list) offset))))
2349 (setq gnus-newsgroup-data-reverse nil))))
2351 (defun gnus-data-remove (article &optional offset)
2352 (let ((data gnus-newsgroup-data))
2353 (if (= (gnus-data-number (car data)) article)
2355 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2356 gnus-newsgroup-data-reverse nil)
2358 (gnus-data-update-list gnus-newsgroup-data offset)))
2360 (when (= (gnus-data-number (cadr data)) article)
2361 (setcdr data (cddr data))
2363 (gnus-data-update-list (cdr data) offset))
2365 gnus-newsgroup-data-reverse nil))
2366 (setq data (cdr data))))))
2368 (defmacro gnus-data-list (backward)
2370 (or gnus-newsgroup-data-reverse
2371 (setq gnus-newsgroup-data-reverse
2372 (reverse gnus-newsgroup-data)))
2373 gnus-newsgroup-data))
2375 (defun gnus-data-update-list (data offset)
2376 "Add OFFSET to the POS of all data entries in DATA."
2377 (setq gnus-newsgroup-data-reverse nil)
2379 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2380 (setq data (cdr data))))
2382 (defun gnus-summary-article-pseudo-p (article)
2383 "Say whether this article is a pseudo article or not."
2384 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2386 (defmacro gnus-summary-article-sparse-p (article)
2387 "Say whether this article is a sparse article or not."
2388 `(memq ,article gnus-newsgroup-sparse))
2390 (defmacro gnus-summary-article-ancient-p (article)
2391 "Say whether this article is a sparse article or not."
2392 `(memq ,article gnus-newsgroup-ancient))
2394 (defun gnus-article-parent-p (number)
2395 "Say whether this article is a parent or not."
2396 (let ((data (gnus-data-find-list number)))
2397 (and (cdr data) ; There has to be an article after...
2398 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2399 (gnus-data-level (nth 1 data))))))
2401 (defun gnus-article-children (number)
2402 "Return a list of all children to NUMBER."
2403 (let* ((data (gnus-data-find-list number))
2404 (level (gnus-data-level (car data)))
2406 (setq data (cdr data))
2408 (= (gnus-data-level (car data)) (1+ level)))
2409 (push (gnus-data-number (car data)) children)
2410 (setq data (cdr data)))
2413 (defmacro gnus-summary-skip-intangible ()
2414 "If the current article is intangible, then jump to a different article."
2415 '(let ((to (get-text-property (point) 'gnus-intangible)))
2416 (and to (gnus-summary-goto-subject to))))
2418 (defmacro gnus-summary-article-intangible-p ()
2419 "Say whether this article is intangible or not."
2420 '(get-text-property (point) 'gnus-intangible))
2422 (defun gnus-article-read-p (article)
2423 "Say whether ARTICLE is read or not."
2424 (not (or (memq article gnus-newsgroup-marked)
2425 (memq article gnus-newsgroup-unreads)
2426 (memq article gnus-newsgroup-unselected)
2427 (memq article gnus-newsgroup-dormant))))
2429 ;; Some summary mode macros.
2431 (defmacro gnus-summary-article-number ()
2432 "The article number of the article on the current line.
2433 If there isn's an article number here, then we return the current
2436 (gnus-summary-skip-intangible)
2437 (or (get-text-property (point) 'gnus-number)
2438 (gnus-summary-last-subject))))
2440 (defmacro gnus-summary-article-header (&optional number)
2441 "Return the header of article NUMBER."
2442 `(gnus-data-header (gnus-data-find
2443 ,(or number '(gnus-summary-article-number)))))
2445 (defmacro gnus-summary-thread-level (&optional number)
2446 "Return the level of thread that starts with article NUMBER."
2447 `(if (and (eq gnus-summary-make-false-root 'dummy)
2448 (get-text-property (point) 'gnus-intangible))
2450 (gnus-data-level (gnus-data-find
2451 ,(or number '(gnus-summary-article-number))))))
2453 (defmacro gnus-summary-article-mark (&optional number)
2454 "Return the mark of article NUMBER."
2455 `(gnus-data-mark (gnus-data-find
2456 ,(or number '(gnus-summary-article-number)))))
2458 (defmacro gnus-summary-article-pos (&optional number)
2459 "Return the position of the line of article NUMBER."
2460 `(gnus-data-pos (gnus-data-find
2461 ,(or number '(gnus-summary-article-number)))))
2463 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2464 (defmacro gnus-summary-article-subject (&optional number)
2465 "Return current subject string or nil if nothing."
2468 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2469 '(gnus-data-header (assq (gnus-summary-article-number)
2470 gnus-newsgroup-data)))))
2473 (mail-header-subject headers))))
2475 (defmacro gnus-summary-article-score (&optional number)
2476 "Return current article score."
2477 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2478 gnus-newsgroup-scored))
2479 gnus-summary-default-score 0))
2481 (defun gnus-summary-article-children (&optional number)
2482 "Return a list of article numbers that are children of article NUMBER."
2483 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2484 (level (gnus-data-level (car data)))
2486 (while (and (setq data (cdr data))
2487 (> (setq l (gnus-data-level (car data))) level))
2488 (and (= (1+ level) l)
2489 (push (gnus-data-number (car data))
2491 (nreverse children)))
2493 (defun gnus-summary-article-parent (&optional number)
2494 "Return the article number of the parent of article NUMBER."
2495 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2496 (gnus-data-list t)))
2497 (level (gnus-data-level (car data))))
2499 () ; This is a root.
2500 ;; We search until we find an article with a level less than
2501 ;; this one. That function has to be the parent.
2502 (while (and (setq data (cdr data))
2503 (not (< (gnus-data-level (car data)) level))))
2504 (and data (gnus-data-number (car data))))))
2506 (defun gnus-unread-mark-p (mark)
2507 "Say whether MARK is the unread mark."
2508 (= mark gnus-unread-mark))
2510 (defun gnus-read-mark-p (mark)
2511 "Say whether MARK is one of the marks that mark as read.
2512 This is all marks except unread, ticked, dormant, and expirable."
2513 (not (or (= mark gnus-unread-mark)
2514 (= mark gnus-ticked-mark)
2515 (= mark gnus-dormant-mark)
2516 (= mark gnus-expirable-mark))))
2518 (defmacro gnus-article-mark (number)
2519 "Return the MARK of article NUMBER.
2520 This macro should only be used when computing the mark the \"first\"
2521 time; i.e., when generating the summary lines. After that,
2522 `gnus-summary-article-mark' should be used to examine the
2525 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2526 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2527 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2528 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2529 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2530 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2531 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2532 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2533 gnus-ancient-mark))))
2535 ;; Saving hidden threads.
2537 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2538 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2540 (defmacro gnus-save-hidden-threads (&rest forms)
2541 "Save hidden threads, eval FORMS, and restore the hidden threads."
2542 (let ((config (make-symbol "config")))
2543 `(let ((,config (gnus-hidden-threads-configuration)))
2547 (gnus-restore-hidden-threads-configuration ,config)))))
2549 (defun gnus-data-compute-positions ()
2550 "Compute the positions of all articles."
2551 (setq gnus-newsgroup-data-reverse nil)
2552 (let ((data gnus-newsgroup-data))
2554 (gnus-save-hidden-threads
2555 (gnus-summary-show-all-threads)
2556 (goto-char (point-min))
2558 (while (get-text-property (point) 'gnus-intangible)
2560 (gnus-data-set-pos (car data) (+ (point) 3))
2561 (setq data (cdr data))
2562 (forward-line 1))))))
2564 (defun gnus-hidden-threads-configuration ()
2565 "Return the current hidden threads configuration."
2568 (goto-char (point-min))
2569 (while (search-forward "\r" nil t)
2570 (push (1- (point)) config))
2573 (defun gnus-restore-hidden-threads-configuration (config)
2574 "Restore hidden threads configuration from CONFIG."
2576 (let (point buffer-read-only)
2577 (while (setq point (pop config))
2578 (when (and (< point (point-max))
2580 (eq (char-after) ?\n))
2581 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2583 ;; Various summary mode internalish functions.
2585 (defun gnus-mouse-pick-article (e)
2588 (gnus-summary-next-page nil t))
2590 (defun gnus-summary-set-display-table ()
2591 "Change the display table.
2592 Odd characters have a tendency to mess
2593 up nicely formatted displays - we make all possible glyphs
2594 display only a single character."
2596 ;; We start from the standard display table, if any.
2597 (let ((table (or (copy-sequence standard-display-table)
2598 (make-display-table)))
2600 ;; Nix out all the control chars...
2601 (while (>= (setq i (1- i)) 0)
2602 (aset table i [??]))
2603 ;; ... but not newline and cr, of course. (cr is necessary for the
2604 ;; selective display).
2605 (aset table ?\n nil)
2606 (aset table ?\r nil)
2607 ;; We keep TAB as well.
2608 (aset table ?\t nil)
2609 ;; We nix out any glyphs over 126 that are not set already.
2611 (while (>= (setq i (1- i)) 127)
2612 ;; Only modify if the entry is nil.
2613 (unless (aref table i)
2614 (aset table i [??]))))
2615 (setq buffer-display-table table)))
2617 (defun gnus-summary-setup-buffer (group)
2618 "Initialize summary buffer."
2619 (let ((buffer (concat "*Summary " group "*")))
2620 (if (get-buffer buffer)
2623 (setq gnus-summary-buffer (current-buffer))
2624 (not gnus-newsgroup-prepared))
2625 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2626 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2627 (gnus-summary-mode group)
2629 (gnus-carpal-setup-buffer 'summary))
2630 (unless gnus-single-article-buffer
2631 (make-local-variable 'gnus-article-buffer)
2632 (make-local-variable 'gnus-article-current)
2633 (make-local-variable 'gnus-original-article-buffer))
2634 (setq gnus-newsgroup-name group)
2637 (defun gnus-set-global-variables ()
2638 "Set the global equivalents of the buffer-local variables.
2639 They are set to the latest values they had. These reflect the summary
2640 buffer that was in action when the last article was fetched."
2641 (when (eq major-mode 'gnus-summary-mode)
2642 (setq gnus-summary-buffer (current-buffer))
2643 (let ((name gnus-newsgroup-name)
2644 (marked gnus-newsgroup-marked)
2645 (unread gnus-newsgroup-unreads)
2646 (headers gnus-current-headers)
2647 (data gnus-newsgroup-data)
2648 (summary gnus-summary-buffer)
2649 (article-buffer gnus-article-buffer)
2650 (original gnus-original-article-buffer)
2651 (gac gnus-article-current)
2652 (reffed gnus-reffed-article-number)
2653 (score-file gnus-current-score-file)
2654 (default-charset gnus-newsgroup-charset)
2656 (let ((locals gnus-newsgroup-variables))
2658 (if (consp (car locals))
2659 (push (eval (caar locals)) vlist)
2660 (push (eval (car locals)) vlist))
2661 (setq locals (cdr locals)))
2662 (setq vlist (nreverse vlist)))
2664 (set-buffer gnus-group-buffer)
2665 (setq gnus-newsgroup-name name
2666 gnus-newsgroup-marked marked
2667 gnus-newsgroup-unreads unread
2668 gnus-current-headers headers
2669 gnus-newsgroup-data data
2670 gnus-article-current gac
2671 gnus-summary-buffer summary
2672 gnus-article-buffer article-buffer
2673 gnus-original-article-buffer original
2674 gnus-reffed-article-number reffed
2675 gnus-current-score-file score-file
2676 gnus-newsgroup-charset default-charset)
2677 (let ((locals gnus-newsgroup-variables))
2679 (if (consp (car locals))
2680 (set (caar locals) (pop vlist))
2681 (set (car locals) (pop vlist)))
2682 (setq locals (cdr locals))))
2683 ;; The article buffer also has local variables.
2684 (when (gnus-buffer-live-p gnus-article-buffer)
2685 (set-buffer gnus-article-buffer)
2686 (setq gnus-summary-buffer summary))))))
2688 (defun gnus-summary-article-unread-p (article)
2689 "Say whether ARTICLE is unread or not."
2690 (memq article gnus-newsgroup-unreads))
2692 (defun gnus-summary-first-article-p (&optional article)
2693 "Return whether ARTICLE is the first article in the buffer."
2694 (if (not (setq article (or article (gnus-summary-article-number))))
2696 (eq article (caar gnus-newsgroup-data))))
2698 (defun gnus-summary-last-article-p (&optional article)
2699 "Return whether ARTICLE is the last article in the buffer."
2700 (if (not (setq article (or article (gnus-summary-article-number))))
2701 ;; All non-existent numbers are the last article. :-)
2703 (not (cdr (gnus-data-find-list article)))))
2705 (defun gnus-make-thread-indent-array ()
2707 (unless (and gnus-thread-indent-array
2708 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2709 (setq gnus-thread-indent-array (make-vector 201 "")
2710 gnus-thread-indent-array-level gnus-thread-indent-level)
2712 (aset gnus-thread-indent-array n
2713 (make-string (* n gnus-thread-indent-level) ? ))
2716 (defun gnus-update-summary-mark-positions ()
2717 "Compute where the summary marks are to go."
2719 (when (gnus-buffer-exists-p gnus-summary-buffer)
2720 (set-buffer gnus-summary-buffer))
2721 (let ((gnus-replied-mark 129)
2722 (gnus-score-below-mark 130)
2723 (gnus-score-over-mark 130)
2724 (gnus-download-mark 131)
2725 (spec gnus-summary-line-format-spec)
2728 (gnus-set-work-buffer)
2729 (let ((gnus-summary-line-format-spec spec)
2730 (gnus-newsgroup-downloadable '((0 . t))))
2731 (gnus-summary-insert-line
2732 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2733 0 nil 128 t nil "" nil 1)
2734 (goto-char (point-min))
2735 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2737 (goto-char (point-min))
2738 (push (cons 'replied (and (search-forward "\201" nil t)
2741 (goto-char (point-min))
2742 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2744 (goto-char (point-min))
2745 (push (cons 'download
2746 (and (search-forward "\203" nil t) (- (point) 2)))
2748 (setq gnus-summary-mark-positions pos))))
2750 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2751 "Insert a dummy root in the summary buffer."
2753 (gnus-add-text-properties
2754 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2755 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2757 (defun gnus-summary-from-or-to-or-newsgroups (header)
2758 (let ((to (cdr (assq 'To (mail-header-extra header))))
2759 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2760 (default-mime-charset (with-current-buffer gnus-summary-buffer
2761 default-mime-charset)))
2764 gnus-ignored-from-addresses
2765 (string-match gnus-ignored-from-addresses
2766 (mail-header-from header)))
2768 (or (car (funcall gnus-extract-address-components
2770 gnus-decode-encoded-word-function to)))
2771 (funcall gnus-decode-encoded-word-function to))))
2773 gnus-ignored-from-addresses
2774 (string-match gnus-ignored-from-addresses
2775 (mail-header-from header)))
2776 (concat "=> " newsgroups))
2778 (or (car (funcall gnus-extract-address-components
2779 (mail-header-from header)))
2780 (mail-header-from header))))))
2782 (defun gnus-summary-insert-line (gnus-tmp-header
2783 gnus-tmp-level gnus-tmp-current
2784 gnus-tmp-unread gnus-tmp-replied
2785 gnus-tmp-expirable gnus-tmp-subject-or-nil
2786 &optional gnus-tmp-dummy gnus-tmp-score
2788 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2789 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2790 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2791 (gnus-tmp-score-char
2792 (if (or (null gnus-summary-default-score)
2793 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2794 gnus-summary-zcore-fuzz))
2796 (if (< gnus-tmp-score gnus-summary-default-score)
2797 gnus-score-below-mark gnus-score-over-mark)))
2799 (cond (gnus-tmp-process gnus-process-mark)
2800 ((memq gnus-tmp-current gnus-newsgroup-cached)
2802 (gnus-tmp-replied gnus-replied-mark)
2803 ((memq gnus-tmp-current gnus-newsgroup-saved)
2805 (t gnus-unread-mark)))
2806 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2809 ((string-match "<[^>]+> *$" gnus-tmp-from)
2810 (let ((beg (match-beginning 0)))
2811 (or (and (string-match "^\".+\"" gnus-tmp-from)
2812 (substring gnus-tmp-from 1 (1- (match-end 0))))
2813 (substring gnus-tmp-from 0 beg))))
2814 ((string-match "(.+)" gnus-tmp-from)
2815 (substring gnus-tmp-from
2816 (1+ (match-beginning 0)) (1- (match-end 0))))
2818 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2819 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2820 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2821 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2822 (buffer-read-only nil))
2823 (when (string= gnus-tmp-name "")
2824 (setq gnus-tmp-name gnus-tmp-from))
2825 (unless (numberp gnus-tmp-lines)
2826 (setq gnus-tmp-lines 0))
2827 (gnus-put-text-property-excluding-characters-with-faces
2829 (progn (eval gnus-summary-line-format-spec) (point))
2830 'gnus-number gnus-tmp-number)
2831 (when (gnus-visual-p 'summary-highlight 'highlight)
2833 (gnus-run-hooks 'gnus-summary-update-hook)
2836 (defun gnus-summary-update-line (&optional dont-update)
2837 "Update summary line after change."
2838 (when (and gnus-summary-default-score
2839 (not gnus-summary-inhibit-highlight))
2840 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2841 (article (gnus-summary-article-number))
2842 (score (gnus-summary-article-score article)))
2844 (if (and gnus-summary-mark-below
2845 (< (gnus-summary-article-score)
2846 gnus-summary-mark-below))
2847 ;; This article has a low score, so we mark it as read.
2848 (when (memq article gnus-newsgroup-unreads)
2849 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2850 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2851 ;; This article was previously marked as read on account
2852 ;; of a low score, but now it has risen, so we mark it as
2854 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2855 (gnus-summary-update-mark
2856 (if (or (null gnus-summary-default-score)
2857 (<= (abs (- score gnus-summary-default-score))
2858 gnus-summary-zcore-fuzz))
2860 (if (< score gnus-summary-default-score)
2861 gnus-score-below-mark gnus-score-over-mark))
2863 ;; Do visual highlighting.
2864 (when (gnus-visual-p 'summary-highlight 'highlight)
2865 (gnus-run-hooks 'gnus-summary-update-hook)))))
2867 (defvar gnus-tmp-new-adopts nil)
2869 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2870 "Return the number of articles in THREAD.
2871 This may be 0 in some cases -- if none of the articles in
2872 the thread are to be displayed."
2874 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2876 ((not (listp thread))
2878 ((and (consp thread) (cdr thread))
2881 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2884 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2887 (when (and level (zerop level) gnus-tmp-new-adopts)
2890 'gnus-summary-number-of-articles-in-thread
2891 gnus-tmp-new-adopts))))
2893 (if (> number 1) gnus-not-empty-thread-mark
2894 gnus-empty-thread-mark)
2897 (defun gnus-summary-set-local-parameters (group)
2898 "Go through the local params of GROUP and set all variable specs in that list."
2899 (let ((params (gnus-group-find-parameter group))
2902 (setq elem (car params)
2903 params (cdr params))
2904 (and (consp elem) ; Has to be a cons.
2905 (consp (cdr elem)) ; The cdr has to be a list.
2906 (symbolp (car elem)) ; Has to be a symbol in there.
2907 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2908 (ignore-errors ; So we set it.
2909 (make-local-variable (car elem))
2910 (set (car elem) (eval (nth 1 elem))))))))
2912 (defun gnus-summary-read-group (group &optional show-all no-article
2913 kill-buffer no-display backward
2915 "Start reading news in newsgroup GROUP.
2916 If SHOW-ALL is non-nil, already read articles are also listed.
2917 If NO-ARTICLE is non-nil, no article is selected initially.
2918 If NO-DISPLAY, don't generate a summary buffer."
2922 (let ((gnus-auto-select-next nil))
2923 (or (gnus-summary-read-group-1
2924 group show-all no-article
2925 kill-buffer no-display
2928 select-articles nil)))))
2929 (eq gnus-auto-select-next 'quietly))
2930 (set-buffer gnus-group-buffer)
2931 ;; The entry function called above goes to the next
2932 ;; group automatically, so we go two groups back
2933 ;; if we are searching for the previous group.
2935 (gnus-group-prev-unread-group 2))
2936 (if (not (equal group (gnus-group-group-name)))
2937 (setq group (gnus-group-group-name))
2941 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2942 "Directly jump to the other GROUP from summary buffer.
2943 If SHOW-ALL is non-nil, already read articles are also listed."
2945 (if (eq gnus-summary-buffer (current-buffer))
2946 (list (completing-read
2947 "Group: " gnus-active-hashtb nil t
2948 (when (and gnus-newsgroup-name
2949 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2950 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2951 'gnus-group-history)
2953 (error "%s must be invoked from a gnus summary buffer." this-command)))
2954 (unless (or (zerop (length group))
2955 (and gnus-newsgroup-name
2956 (string-equal gnus-newsgroup-name group)))
2958 (gnus-summary-read-group group show-all
2959 gnus-dont-select-after-jump-to-other-group)))
2961 (defun gnus-summary-read-group-1 (group show-all no-article
2962 kill-buffer no-display
2963 &optional select-articles)
2964 ;; Killed foreign groups can't be entered.
2965 (when (and (not (gnus-group-native-p group))
2966 (not (gnus-gethash group gnus-newsrc-hashtb)))
2967 (error "Dead non-native groups can't be entered"))
2968 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2969 (let* ((new-group (gnus-summary-setup-buffer group))
2970 (quit-config (gnus-group-quit-config group))
2971 (did-select (and new-group (gnus-select-newsgroup
2972 group show-all select-articles))))
2974 ;; This summary buffer exists already, so we just select it.
2976 (gnus-set-global-variables)
2978 (gnus-kill-or-deaden-summary kill-buffer))
2979 (gnus-configure-windows 'summary 'force)
2980 (gnus-set-mode-line 'summary)
2981 (gnus-summary-position-point)
2984 ;; We couldn't select this group.
2986 (when (and (eq major-mode 'gnus-summary-mode)
2987 (not (equal (current-buffer) kill-buffer)))
2988 (kill-buffer (current-buffer))
2989 (if (not quit-config)
2991 ;; Update the info -- marks might need to be removed,
2993 (gnus-summary-update-info)
2994 (set-buffer gnus-group-buffer)
2995 (gnus-group-jump-to-group group)
2996 (gnus-group-next-unread-group 1))
2997 (gnus-handle-ephemeral-exit quit-config)))
2998 (gnus-message 3 "Can't select group")
3000 ;; The user did a `C-g' while prompting for number of articles,
3001 ;; so we exit this group.
3002 ((eq did-select 'quit)
3003 (and (eq major-mode 'gnus-summary-mode)
3004 (not (equal (current-buffer) kill-buffer))
3005 (kill-buffer (current-buffer)))
3007 (gnus-kill-or-deaden-summary kill-buffer))
3008 (if (not quit-config)
3010 (set-buffer gnus-group-buffer)
3011 (gnus-group-jump-to-group group)
3012 (gnus-group-next-unread-group 1)
3013 (gnus-configure-windows 'group 'force))
3014 (gnus-handle-ephemeral-exit quit-config))
3015 ;; Finally signal the quit.
3017 ;; The group was successfully selected.
3019 (gnus-set-global-variables)
3020 ;; Save the active value in effect when the group was entered.
3021 (setq gnus-newsgroup-active
3023 (gnus-active gnus-newsgroup-name)))
3024 ;; You can change the summary buffer in some way with this hook.
3025 (gnus-run-hooks 'gnus-select-group-hook)
3026 ;; Set any local variables in the group parameters.
3027 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3028 (gnus-update-format-specifications
3029 nil 'summary 'summary-mode 'summary-dummy)
3030 (gnus-update-summary-mark-positions)
3031 ;; Do score processing.
3032 (when gnus-use-scoring
3033 (gnus-possibly-score-headers))
3034 ;; Check whether to fill in the gaps in the threads.
3035 (when gnus-build-sparse-threads
3036 (gnus-build-sparse-threads))
3037 ;; Find the initial limit.
3038 (if gnus-show-threads
3040 (let ((gnus-newsgroup-dormant nil))
3041 (gnus-summary-initial-limit show-all))
3042 (gnus-summary-initial-limit show-all))
3043 ;; When untreaded, all articles are always shown.
3044 (setq gnus-newsgroup-limit
3046 (lambda (header) (mail-header-number header))
3047 gnus-newsgroup-headers)))
3048 ;; Generate the summary buffer.
3050 (gnus-summary-prepare))
3051 (when gnus-use-trees
3052 (gnus-tree-open group)
3053 (setq gnus-summary-highlight-line-function
3054 'gnus-tree-highlight-article))
3055 ;; If the summary buffer is empty, but there are some low-scored
3056 ;; articles or some excluded dormants, we include these in the
3058 (when (and (zerop (buffer-size))
3060 (cond (gnus-newsgroup-dormant
3061 (gnus-summary-limit-include-dormant))
3062 ((and gnus-newsgroup-scored show-all)
3063 (gnus-summary-limit-include-expunged t))))
3064 ;; Function `gnus-apply-kill-file' must be called in this hook.
3065 (gnus-run-hooks 'gnus-apply-kill-hook)
3066 (if (and (zerop (buffer-size))
3069 ;; This newsgroup is empty.
3070 (gnus-summary-catchup-and-exit nil t)
3071 (gnus-message 6 "No unread news")
3073 (gnus-kill-or-deaden-summary kill-buffer))
3074 ;; Return nil from this function.
3076 ;; Hide conversation thread subtrees. We cannot do this in
3077 ;; gnus-summary-prepare-hook since kill processing may not
3078 ;; work with hidden articles.
3079 (and gnus-show-threads
3080 gnus-thread-hide-subtree
3081 (gnus-summary-hide-all-threads))
3083 (gnus-kill-or-deaden-summary kill-buffer))
3084 ;; Show first unread article if requested.
3085 (if (and (not no-article)
3087 gnus-newsgroup-unreads
3088 gnus-auto-select-first)
3090 (gnus-configure-windows 'summary)
3092 ((eq gnus-auto-select-first 'best)
3093 (gnus-summary-best-unread-article))
3094 ((eq gnus-auto-select-first t)
3095 (gnus-summary-first-unread-article))
3096 ((gnus-functionp gnus-auto-select-first)
3097 (funcall gnus-auto-select-first))))
3098 ;; Don't select any articles, just move point to the first
3099 ;; article in the group.
3100 (goto-char (point-min))
3101 (gnus-summary-position-point)
3102 (gnus-configure-windows 'summary 'force)
3103 (gnus-set-mode-line 'summary))
3104 (when (get-buffer-window gnus-group-buffer t)
3105 ;; Gotta use windows, because recenter does weird stuff if
3106 ;; the current buffer ain't the displayed window.
3107 (let ((owin (selected-window)))
3108 (select-window (get-buffer-window gnus-group-buffer t))
3109 (when (gnus-group-goto-group group)
3111 (select-window owin)))
3112 ;; Mark this buffer as "prepared".
3113 (setq gnus-newsgroup-prepared t)
3114 (gnus-run-hooks 'gnus-summary-prepared-hook)
3117 (defun gnus-summary-prepare ()
3118 "Generate the summary buffer."
3120 (let ((buffer-read-only nil))
3122 (setq gnus-newsgroup-data nil
3123 gnus-newsgroup-data-reverse nil)
3124 (gnus-run-hooks 'gnus-summary-generate-hook)
3125 ;; Generate the buffer, either with threads or without.
3126 (when gnus-newsgroup-headers
3127 (gnus-summary-prepare-threads
3128 (if gnus-show-threads
3129 (gnus-sort-gathered-threads
3130 (funcall gnus-summary-thread-gathering-function
3132 (gnus-cut-threads (gnus-make-threads)))))
3133 ;; Unthreaded display.
3134 (gnus-sort-articles gnus-newsgroup-headers))))
3135 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3136 ;; Call hooks for modifying summary buffer.
3137 (goto-char (point-min))
3138 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3140 (defsubst gnus-general-simplify-subject (subject)
3141 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3144 ;; Truncate the subject.
3145 (gnus-simplify-subject-functions
3146 (gnus-map-function gnus-simplify-subject-functions subject))
3147 ((numberp gnus-summary-gather-subject-limit)
3148 (setq subject (gnus-simplify-subject-re subject))
3149 (if (> (length subject) gnus-summary-gather-subject-limit)
3150 (substring subject 0 gnus-summary-gather-subject-limit)
3152 ;; Fuzzily simplify it.
3153 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3154 (gnus-simplify-subject-fuzzy subject))
3155 ;; Just remove the leading "Re:".
3157 (gnus-simplify-subject-re subject))))
3159 (if (and gnus-summary-gather-exclude-subject
3160 (string-match gnus-summary-gather-exclude-subject subject))
3161 nil ; This article shouldn't be gathered
3164 (defun gnus-summary-simplify-subject-query ()
3165 "Query where the respool algorithm would put this article."
3167 (gnus-summary-select-article)
3169 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3171 (defun gnus-gather-threads-by-subject (threads)
3172 "Gather threads by looking at Subject headers."
3173 (if (not gnus-summary-make-false-root)
3175 (let ((hashtb (gnus-make-hashtable 1024))
3178 subject hthread whole-subject)
3180 (setq subject (gnus-general-simplify-subject
3181 (setq whole-subject (mail-header-subject
3184 (if (setq hthread (gnus-gethash subject hashtb))
3186 ;; We enter a dummy root into the thread, if we
3187 ;; haven't done that already.
3188 (unless (stringp (caar hthread))
3189 (setcar hthread (list whole-subject (car hthread))))
3190 ;; We add this new gathered thread to this gathered
3192 (setcdr (car hthread)
3193 (nconc (cdar hthread) (list (car threads))))
3194 ;; Remove it from the list of threads.
3195 (setcdr prev (cdr threads))
3196 (setq threads prev))
3197 ;; Enter this thread into the hash table.
3198 (gnus-sethash subject threads hashtb)))
3200 (setq threads (cdr threads)))
3203 (defun gnus-gather-threads-by-references (threads)
3204 "Gather threads by looking at References headers."
3205 (let ((idhashtb (gnus-make-hashtable 1024))
3206 (thhashtb (gnus-make-hashtable 1024))
3209 ids references id gthread gid entered ref)
3211 (when (setq references (mail-header-references (caar threads)))
3212 (setq id (mail-header-id (caar threads))
3213 ids (gnus-split-references references)
3215 (while (setq ref (pop ids))
3216 (setq ids (delete ref ids))
3217 (if (not (setq gid (gnus-gethash ref idhashtb)))
3219 (gnus-sethash ref id idhashtb)
3220 (gnus-sethash id threads thhashtb))
3221 (setq gthread (gnus-gethash gid thhashtb))
3223 ;; We enter a dummy root into the thread, if we
3224 ;; haven't done that already.
3225 (unless (stringp (caar gthread))
3226 (setcar gthread (list (mail-header-subject (caar gthread))
3228 ;; We add this new gathered thread to this gathered
3230 (setcdr (car gthread)
3231 (nconc (cdar gthread) (list (car threads)))))
3232 ;; Add it into the thread hash table.
3233 (gnus-sethash id gthread thhashtb)
3235 ;; Remove it from the list of threads.
3236 (setcdr prev (cdr threads))
3237 (setq threads prev))))
3239 (setq threads (cdr threads)))
3242 (defun gnus-sort-gathered-threads (threads)
3243 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3244 (let ((result threads))
3246 (when (stringp (caar threads))
3247 (setcdr (car threads)
3248 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3249 (setq threads (cdr threads)))
3252 (defun gnus-thread-loop-p (root thread)
3253 "Say whether ROOT is in THREAD."
3254 (let ((stack (list thread))
3257 (while (setq thread (pop stack))
3258 (setq th (cdr thread))
3260 (not (eq (caar th) root)))
3263 ;; We have found a loop.
3265 (setcdr thread (delq (car th) (cdr thread)))
3266 (if (boundp (setq ref-dep (intern "none"
3267 gnus-newsgroup-dependencies)))
3268 (setcdr (symbol-value ref-dep)
3269 (nconc (cdr (symbol-value ref-dep))
3271 (set ref-dep (list nil (car th))))
3274 ;; Push all the subthreads onto the stack.
3275 (push (cdr thread) stack)))
3278 (defun gnus-make-threads ()
3279 "Go through the dependency hashtb and find the roots. Return all threads."
3281 (while (catch 'infloop
3284 ;; Deal with self-referencing References loops.
3285 (when (and (car (symbol-value refs))
3292 (car (symbol-value refs)) thread))
3293 (cdr (symbol-value refs)))))))
3296 (unless (car (symbol-value refs))
3297 ;; These threads do not refer back to any other articles,
3298 ;; so they're roots.
3299 (setq threads (append (cdr (symbol-value refs)) threads))))
3300 gnus-newsgroup-dependencies)))
3303 ;; Build the thread tree.
3304 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3305 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3307 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3308 if it was already present.
3310 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3311 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3312 Message-IDs will be renamed be renamed to a unique Message-ID before
3315 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3316 (let* ((id (mail-header-id header))
3317 (id-dep (and id (intern id dependencies)))
3318 ref ref-dep ref-header)
3319 ;; Enter this `header' in the `dependencies' table.
3323 ;; The first two cases do the normal part: enter a new `header'
3324 ;; in the `dependencies' table.
3325 ((not (boundp id-dep))
3326 (set id-dep (list header)))
3327 ((null (car (symbol-value id-dep)))
3328 (setcar (symbol-value id-dep) header))
3330 ;; From here the `header' was already present in the
3331 ;; `dependencies' table.
3333 ;; Overrides an existing entry;
3334 ;; just set the header part of the entry.
3335 (setcar (symbol-value id-dep) header))
3337 ;; Renames the existing `header' to a unique Message-ID.
3338 ((not gnus-summary-ignore-duplicates)
3339 ;; An article with this Message-ID has already been seen.
3340 ;; We rename the Message-ID.
3341 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3343 (mail-header-set-id header id))
3345 ;; The last case ignores an existing entry, except it adds any
3346 ;; additional Xrefs (in case the two articles came from different
3348 ;; Also sets `header' to `nil' meaning that the `dependencies'
3349 ;; table was *not* modified.
3351 (mail-header-set-xref
3352 (car (symbol-value id-dep))
3353 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3355 (or (mail-header-xref header) "")))
3359 ;; First check if that we are not creating a References loop.
3360 (setq ref (gnus-parent-id (mail-header-references header)))
3362 (setq ref-dep (intern-soft ref dependencies))
3364 (setq ref-header (car (symbol-value ref-dep))))
3365 (if (string= id ref)
3366 ;; Yuk! This is a reference loop. Make the article be a
3369 (mail-header-set-references (car (symbol-value id-dep)) "none")
3371 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3372 (setq ref (gnus-parent-id (mail-header-references header)))
3373 (setq ref-dep (intern (or ref "none") dependencies))
3374 (if (boundp ref-dep)
3375 (setcdr (symbol-value ref-dep)
3376 (nconc (cdr (symbol-value ref-dep))
3377 (list (symbol-value id-dep))))
3378 (set ref-dep (list nil (symbol-value id-dep)))))
3381 (defun gnus-build-sparse-threads ()
3382 (let ((headers gnus-newsgroup-headers)
3383 (mail-parse-charset gnus-newsgroup-charset)
3384 (gnus-summary-ignore-duplicates t)
3385 header references generation relations
3386 subject child end new-child date)
3387 ;; First we create an alist of generations/relations, where
3388 ;; generations is how much we trust the relation, and the relation
3390 (gnus-message 7 "Making sparse threads...")
3392 (nnheader-set-temp-buffer " *gnus sparse threads*")
3393 (while (setq header (pop headers))
3394 (when (and (setq references (mail-header-references header))
3395 (not (string= references "")))
3397 (setq child (mail-header-id header)
3398 subject (mail-header-subject header)
3399 date (mail-header-date header)
3401 (while (search-backward ">" nil t)
3402 (setq end (1+ (point)))
3403 (when (search-backward "<" nil t)
3404 (setq new-child (buffer-substring (point) end))
3405 (push (list (incf generation)
3406 child (setq child new-child)
3410 (push (list (1+ generation) child nil subject) relations))
3412 (kill-buffer (current-buffer)))
3413 ;; Sort over trustworthiness.
3416 (when (gnus-dependencies-add-header
3417 (make-full-mail-header-from-decoded-header
3418 gnus-reffed-article-number
3419 (nth 3 relation) "" (or (nth 4 relation) "")
3421 (or (nth 2 relation) "") 0 0 "")
3422 gnus-newsgroup-dependencies nil)
3423 (push gnus-reffed-article-number gnus-newsgroup-limit)
3424 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3425 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3426 gnus-newsgroup-reads)
3427 (decf gnus-reffed-article-number)))
3428 (sort relations 'car-less-than-car))
3429 (gnus-message 7 "Making sparse threads...done")))
3431 (defun gnus-build-old-threads ()
3432 ;; Look at all the articles that refer back to old articles, and
3433 ;; fetch the headers for the articles that aren't there. This will
3434 ;; build complete threads - if the roots haven't been expired by the
3436 (let ((mail-parse-charset gnus-newsgroup-charset)
3440 (when (not (car (symbol-value refs)))
3441 (setq heads (cdr (symbol-value refs)))
3443 (if (memq (mail-header-number (caar heads))
3444 gnus-newsgroup-dormant)
3445 (setq heads (cdr heads))
3446 (setq id (symbol-name refs))
3447 (while (and (setq id (gnus-build-get-header id))
3448 (not (car (gnus-id-to-thread id)))))
3449 (setq heads nil)))))
3450 gnus-newsgroup-dependencies)))
3452 ;; This function has to be called with point after the article number
3453 ;; on the beginning of the line.
3454 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3455 (let ((eol (gnus-point-at-eol))
3456 (buffer (current-buffer))
3459 ;; overview: [num subject from date id refs chars lines misc]
3462 (narrow-to-region (point) eol)
3467 (make-full-mail-header
3469 (nnheader-nov-field) ; subject
3470 (nnheader-nov-field) ; from
3471 (nnheader-nov-field) ; date
3472 (nnheader-nov-read-message-id) ; id
3473 (nnheader-nov-field) ; refs
3474 (nnheader-nov-read-integer) ; chars
3475 (nnheader-nov-read-integer) ; lines
3477 (if (looking-at "Xref: ")
3478 (goto-char (match-end 0)))
3479 (nnheader-nov-field)) ; Xref
3480 (nnheader-nov-parse-extra)))) ; extra
3484 (when gnus-alter-header-function
3485 (funcall gnus-alter-header-function header))
3486 (gnus-dependencies-add-header header dependencies force-new)))
3488 (defun gnus-build-get-header (id)
3489 "Look through the buffer of NOV lines and find the header to ID.
3490 Enter this line into the dependencies hash table, and return
3491 the id of the parent article (if any)."
3492 (let ((deps gnus-newsgroup-dependencies)
3496 (set-buffer nntp-server-buffer)
3497 (let ((case-fold-search nil))
3498 (goto-char (point-min))
3499 (while (and (not found)
3500 (search-forward id nil t))
3502 (setq found (looking-at
3503 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3504 (regexp-quote id))))
3505 (or found (beginning-of-line 2)))
3509 (setq header (gnus-nov-parse-line
3510 (read (current-buffer)) deps))
3511 (gnus-parent-id (mail-header-references header))))))
3513 (let ((number (mail-header-number header)))
3514 (push number gnus-newsgroup-limit)
3515 (push header gnus-newsgroup-headers)
3516 (if (memq number gnus-newsgroup-unselected)
3518 (push number gnus-newsgroup-unreads)
3519 (setq gnus-newsgroup-unselected
3520 (delq number gnus-newsgroup-unselected)))
3521 (push number gnus-newsgroup-ancient)))))))
3523 (defun gnus-build-all-threads ()
3524 "Read all the headers."
3525 (let ((gnus-summary-ignore-duplicates t)
3526 (mail-parse-charset gnus-newsgroup-charset)
3527 (dependencies gnus-newsgroup-dependencies)
3530 (set-buffer nntp-server-buffer)
3531 (let ((case-fold-search nil))
3532 (goto-char (point-min))
3535 (setq article (read (current-buffer))
3536 header (gnus-nov-parse-line article dependencies)))
3539 (set-buffer gnus-summary-buffer)
3540 (push header gnus-newsgroup-headers)
3541 (if (memq (setq article (mail-header-number header))
3542 gnus-newsgroup-unselected)
3544 (push article gnus-newsgroup-unreads)
3545 (setq gnus-newsgroup-unselected
3546 (delq article gnus-newsgroup-unselected)))
3547 (push article gnus-newsgroup-ancient)))
3548 (forward-line 1)))))))
3550 (defun gnus-summary-update-article-line (article header)
3551 "Update the line for ARTICLE using HEADERS."
3552 (let* ((id (mail-header-id header))
3553 (thread (gnus-id-to-thread id)))
3555 (error "Article in no thread"))
3556 ;; Update the thread.
3557 (setcar thread header)
3558 (gnus-summary-goto-subject article)
3559 (let* ((datal (gnus-data-find-list article))
3561 (length (when (cdr datal)
3562 (- (gnus-data-pos data)
3563 (gnus-data-pos (cadr datal)))))
3564 (buffer-read-only nil)
3565 (level (gnus-summary-thread-level)))
3567 (gnus-summary-insert-line
3568 header level nil (gnus-article-mark article)
3569 (memq article gnus-newsgroup-replied)
3570 (memq article gnus-newsgroup-expirable)
3571 ;; Only insert the Subject string when it's different
3572 ;; from the previous Subject string.
3577 (mail-header-subject
3580 (gnus-data-find-list
3582 (gnus-data-list t)))))
3583 ;; Error on the side of excessive subjects.
3585 (mail-header-subject header)))
3587 (mail-header-subject header))
3588 nil (cdr (assq article gnus-newsgroup-scored))
3589 (memq article gnus-newsgroup-processable))
3591 (gnus-data-update-list
3592 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3594 (defun gnus-summary-update-article (article &optional iheader)
3595 "Update ARTICLE in the summary buffer."
3596 (set-buffer gnus-summary-buffer)
3597 (let* ((header (gnus-summary-article-header article))
3598 (id (mail-header-id header))
3599 (data (gnus-data-find article))
3600 (thread (gnus-id-to-thread id))
3601 (references (mail-header-references header))
3605 (when (and references
3606 (not (equal "" references)))
3609 (buffer-read-only nil)
3615 (delq thread parent)))
3616 (if (gnus-summary-insert-subject id header)
3617 ;; Set the (possibly) new article number in the data structure.
3618 (gnus-data-set-number data (gnus-id-to-article id))
3622 (defun gnus-rebuild-thread (id &optional line)
3623 "Rebuild the thread containing ID.
3624 If LINE, insert the rebuilt thread starting on line LINE."
3625 (let ((buffer-read-only nil)
3626 old-pos current thread data)
3627 (if (not gnus-show-threads)
3628 (setq thread (list (car (gnus-id-to-thread id))))
3629 ;; Get the thread this article is part of.
3630 (setq thread (gnus-remove-thread id)))
3631 (setq old-pos (gnus-point-at-bol))
3632 (setq current (save-excursion
3633 (and (zerop (forward-line -1))
3634 (gnus-summary-article-number))))
3635 ;; If this is a gathered thread, we have to go some re-gathering.
3636 (when (stringp (car thread))
3637 (let ((subject (car thread))
3639 (setq thread (cdr thread))
3641 (unless (memq (setq thr (gnus-id-to-thread
3643 (mail-header-id (caar thread)))))
3646 (setq thread (cdr thread)))
3647 ;; We now have all (unique) roots.
3648 (if (= (length roots) 1)
3649 ;; All the loose roots are now one solid root.
3650 (setq thread (car roots))
3651 (setq thread (cons subject (gnus-sort-threads roots))))))
3653 ;; We then insert this thread into the summary buffer.
3655 (goto-char (point-min))
3656 (forward-line (1- line)))
3657 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3658 (if gnus-show-threads
3659 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3660 (gnus-summary-prepare-unthreaded thread))
3661 (setq data (nreverse gnus-newsgroup-data))
3662 (setq threads gnus-newsgroup-threads))
3663 ;; We splice the new data into the data structure.
3664 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3665 ;;!!! then we want to insert at the beginning of the buffer.
3666 ;;!!! That happens to be true with Gnus now, but that may
3667 ;;!!! change in the future. Perhaps.
3668 (gnus-data-enter-list
3669 (if line nil current) data (- (point) old-pos))
3670 (setq gnus-newsgroup-threads
3671 (nconc threads gnus-newsgroup-threads))
3672 (gnus-data-compute-positions))))
3674 (defun gnus-number-to-header (number)
3675 "Return the header for article NUMBER."
3676 (let ((headers gnus-newsgroup-headers))
3678 (not (= number (mail-header-number (car headers)))))
3683 (defun gnus-parent-headers (in-headers &optional generation)
3684 "Return the headers of the GENERATIONeth parent of HEADERS."
3686 (setq generation 1))
3688 (headers in-headers)
3691 (not (zerop generation))
3692 (setq references (mail-header-references headers)))
3693 (setq headers (if (and references
3694 (setq parent (gnus-parent-id references)))
3695 (car (gnus-id-to-thread parent))
3698 (and (not (eq headers in-headers))
3701 (defun gnus-id-to-thread (id)
3702 "Return the (sub-)thread where ID appears."
3703 (gnus-gethash id gnus-newsgroup-dependencies))
3705 (defun gnus-id-to-article (id)
3706 "Return the article number of ID."
3707 (let ((thread (gnus-id-to-thread id)))
3710 (mail-header-number (car thread)))))
3712 (defun gnus-id-to-header (id)
3713 "Return the article headers of ID."
3714 (car (gnus-id-to-thread id)))
3716 (defun gnus-article-displayed-root-p (article)
3717 "Say whether ARTICLE is a root(ish) article."
3718 (let ((level (gnus-summary-thread-level article))
3719 (refs (mail-header-references (gnus-summary-article-header article)))
3725 ((null (gnus-parent-id refs)) t)
3727 (null (setq particle (gnus-id-to-article
3728 (gnus-parent-id refs))))
3729 (null (gnus-summary-thread-level particle)))))))
3731 (defun gnus-root-id (id)
3732 "Return the id of the root of the thread where ID appears."
3734 (while (and id (setq prev (car (gnus-id-to-thread id))))
3736 id (gnus-parent-id (mail-header-references prev))))
3739 (defun gnus-articles-in-thread (thread)
3740 "Return the list of articles in THREAD."
3741 (cons (mail-header-number (car thread))
3742 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3744 (defun gnus-remove-thread (id &optional dont-remove)
3745 "Remove the thread that has ID in it."
3746 (let (headers thread last-id)
3747 ;; First go up in this thread until we find the root.
3748 (setq last-id (gnus-root-id id)
3749 headers (message-flatten-list (gnus-id-to-thread last-id)))
3750 ;; We have now found the real root of this thread. It might have
3751 ;; been gathered into some loose thread, so we have to search
3752 ;; through the threads to find the thread we wanted.
3753 (let ((threads gnus-newsgroup-threads)
3756 (setq sub (car threads))
3757 (if (stringp (car sub))
3758 ;; This is a gathered thread, so we look at the roots
3759 ;; below it to find whether this article is in this
3762 (setq sub (cdr sub))
3764 (when (member (caar sub) headers)
3765 (setq thread (car threads)
3768 (setq sub (cdr sub))))
3769 ;; It's an ordinary thread, so we check it.
3770 (when (eq (car sub) (car headers))
3773 (setq threads (cdr threads)))
3774 ;; If this article is in no thread, then it's a root.
3777 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3778 (setq thread (gnus-id-to-thread last-id)))
3781 thread ; We return this thread.
3783 (if (stringp (car thread))
3785 ;; If we use dummy roots, then we have to remove the
3786 ;; dummy root as well.
3787 (when (eq gnus-summary-make-false-root 'dummy)
3788 ;; We go to the dummy root by going to
3789 ;; the first sub-"thread", and then one line up.
3790 (gnus-summary-goto-article
3791 (mail-header-number (caadr thread)))
3794 (gnus-data-compute-positions))
3795 (setq thread (cdr thread))
3797 (gnus-remove-thread-1 (car thread))
3798 (setq thread (cdr thread))))
3799 (gnus-remove-thread-1 thread))))))))
3801 (defun gnus-remove-thread-1 (thread)
3802 "Remove the thread THREAD recursively."
3803 (let ((number (mail-header-number (pop thread)))
3805 (setq thread (reverse thread))
3807 (gnus-remove-thread-1 (pop thread)))
3808 (when (setq d (gnus-data-find number))
3809 (goto-char (gnus-data-pos d))
3810 (gnus-summary-show-thread)
3813 (- (gnus-point-at-bol)
3815 (1+ (gnus-point-at-eol))
3816 (gnus-delete-line)))))))
3818 (defun gnus-sort-threads-1 (threads func)
3819 (sort (mapcar (lambda (thread)
3822 (gnus-sort-threads-1 (cdr thread) func))))
3825 (defun gnus-sort-threads (threads)
3827 (if (not gnus-thread-sort-functions)
3829 (gnus-message 8 "Sorting threads...")
3831 (gnus-sort-threads-1
3833 (gnus-make-sort-function gnus-thread-sort-functions))
3834 (gnus-message 8 "Sorting threads...done"))))
3836 (defun gnus-sort-articles (articles)
3838 (when gnus-article-sort-functions
3839 (gnus-message 7 "Sorting articles...")
3841 (setq gnus-newsgroup-headers
3842 (sort articles (gnus-make-sort-function
3843 gnus-article-sort-functions)))
3844 (gnus-message 7 "Sorting articles...done"))))
3846 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3847 (defmacro gnus-thread-header (thread)
3848 "Return header of first article in THREAD.
3849 Note that THREAD must never, ever be anything else than a variable -
3850 using some other form will lead to serious barfage."
3851 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3852 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3853 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3856 (defsubst gnus-article-sort-by-number (h1 h2)
3857 "Sort articles by article number."
3858 (< (mail-header-number h1)
3859 (mail-header-number h2)))
3861 (defun gnus-thread-sort-by-number (h1 h2)
3862 "Sort threads by root article number."
3863 (gnus-article-sort-by-number
3864 (gnus-thread-header h1) (gnus-thread-header h2)))
3866 (defsubst gnus-article-sort-by-lines (h1 h2)
3867 "Sort articles by article Lines header."
3868 (< (mail-header-lines h1)
3869 (mail-header-lines h2)))
3871 (defun gnus-thread-sort-by-lines (h1 h2)
3872 "Sort threads by root article Lines header."
3873 (gnus-article-sort-by-lines
3874 (gnus-thread-header h1) (gnus-thread-header h2)))
3876 (defsubst gnus-article-sort-by-chars (h1 h2)
3877 "Sort articles by octet length."
3878 (< (mail-header-chars h1)
3879 (mail-header-chars h2)))
3881 (defun gnus-thread-sort-by-chars (h1 h2)
3882 "Sort threads by root article octet length."
3883 (gnus-article-sort-by-chars
3884 (gnus-thread-header h1) (gnus-thread-header h2)))
3886 (defsubst gnus-article-sort-by-author (h1 h2)
3887 "Sort articles by root author."
3889 (let ((addr (car (mime-entity-read-field h1 'From))))
3890 (or (std11-full-name-string addr)
3891 (std11-address-string addr)
3893 (let ((addr (car (mime-entity-read-field h2 'From))))
3894 (or (std11-full-name-string addr)
3895 (std11-address-string addr)
3899 (defun gnus-thread-sort-by-author (h1 h2)
3900 "Sort threads by root author."
3901 (gnus-article-sort-by-author
3902 (gnus-thread-header h1) (gnus-thread-header h2)))
3904 (defsubst gnus-article-sort-by-subject (h1 h2)
3905 "Sort articles by root subject."
3907 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3908 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3910 (defun gnus-thread-sort-by-subject (h1 h2)
3911 "Sort threads by root subject."
3912 (gnus-article-sort-by-subject
3913 (gnus-thread-header h1) (gnus-thread-header h2)))
3915 (defsubst gnus-article-sort-by-date (h1 h2)
3916 "Sort articles by root article date."
3918 (gnus-date-get-time (mail-header-date h1))
3919 (gnus-date-get-time (mail-header-date h2))))
3921 (defun gnus-thread-sort-by-date (h1 h2)
3922 "Sort threads by root article date."
3923 (gnus-article-sort-by-date
3924 (gnus-thread-header h1) (gnus-thread-header h2)))
3926 (defsubst gnus-article-sort-by-score (h1 h2)
3927 "Sort articles by root article score.
3928 Unscored articles will be counted as having a score of zero."
3929 (> (or (cdr (assq (mail-header-number h1)
3930 gnus-newsgroup-scored))
3931 gnus-summary-default-score 0)
3932 (or (cdr (assq (mail-header-number h2)
3933 gnus-newsgroup-scored))
3934 gnus-summary-default-score 0)))
3936 (defun gnus-thread-sort-by-score (h1 h2)
3937 "Sort threads by root article score."
3938 (gnus-article-sort-by-score
3939 (gnus-thread-header h1) (gnus-thread-header h2)))
3941 (defun gnus-thread-sort-by-total-score (h1 h2)
3942 "Sort threads by the sum of all scores in the thread.
3943 Unscored articles will be counted as having a score of zero."
3944 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3946 (defun gnus-thread-total-score (thread)
3947 ;; This function find the total score of THREAD.
3948 (cond ((null thread)
3951 (if (stringp (car thread))
3952 (apply gnus-thread-score-function 0
3953 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3954 (gnus-thread-total-score-1 thread)))
3956 (gnus-thread-total-score-1 (list thread)))))
3958 (defun gnus-thread-total-score-1 (root)
3959 ;; This function find the total score of the thread below ROOT.
3960 (setq root (car root))
3961 (apply gnus-thread-score-function
3963 (mapcar 'gnus-thread-total-score
3964 (cdr (gnus-id-to-thread (mail-header-id root))))
3965 (when (> (mail-header-number root) 0)
3966 (list (or (cdr (assq (mail-header-number root)
3967 gnus-newsgroup-scored))
3968 gnus-summary-default-score 0))))
3969 (list gnus-summary-default-score)
3972 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3973 (defvar gnus-tmp-prev-subject nil)
3974 (defvar gnus-tmp-false-parent nil)
3975 (defvar gnus-tmp-root-expunged nil)
3976 (defvar gnus-tmp-dummy-line nil)
3978 (eval-when-compile (defvar gnus-tmp-header))
3979 (defun gnus-extra-header (type &optional header)
3980 "Return the extra header of TYPE."
3981 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3984 (defun gnus-summary-prepare-threads (threads)
3985 "Prepare summary buffer from THREADS and indentation LEVEL.
3986 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3987 or a straight list of headers."
3988 (gnus-message 7 "Generating summary...")
3990 (setq gnus-newsgroup-threads threads)
3993 (let ((gnus-tmp-level 0)
3994 (default-score (or gnus-summary-default-score 0))
3995 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3996 thread number subject stack state gnus-tmp-gathered beg-match
3997 new-roots gnus-tmp-new-adopts thread-end
3998 gnus-tmp-header gnus-tmp-unread
3999 gnus-tmp-replied gnus-tmp-subject-or-nil
4000 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4001 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4002 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4004 (setq gnus-tmp-prev-subject nil)
4006 (if (vectorp (car threads))
4007 ;; If this is a straight (sic) list of headers, then a
4008 ;; threaded summary display isn't required, so we just create
4009 ;; an unthreaded one.
4010 (gnus-summary-prepare-unthreaded threads)
4012 ;; Do the threaded display.
4014 (while (or threads stack gnus-tmp-new-adopts new-roots)
4016 (if (and (= gnus-tmp-level 0)
4019 (not gnus-tmp-false-parent)
4020 (or gnus-tmp-new-adopts new-roots))
4021 (if gnus-tmp-new-adopts
4022 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4023 thread (list (car gnus-tmp-new-adopts))
4024 gnus-tmp-header (caar thread)
4025 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4027 (setq thread (list (car new-roots))
4028 gnus-tmp-header (caar thread)
4029 new-roots (cdr new-roots))))
4032 ;; If there are some threads, we do them before the
4033 ;; threads on the stack.
4034 (setq thread threads
4035 gnus-tmp-header (caar thread))
4036 ;; There were no current threads, so we pop something off
4038 (setq state (car stack)
4039 gnus-tmp-level (car state)
4042 gnus-tmp-header (caar thread))))
4044 (setq gnus-tmp-false-parent nil)
4045 (setq gnus-tmp-root-expunged nil)
4046 (setq thread-end nil)
4048 (if (stringp gnus-tmp-header)
4049 ;; The header is a dummy root.
4051 ((eq gnus-summary-make-false-root 'adopt)
4052 ;; We let the first article adopt the rest.
4053 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4055 (setq gnus-tmp-gathered
4057 (lambda (h) (mail-header-number (car h)))
4060 (setq thread (cons (list (caar thread)
4063 (setq gnus-tmp-level -1
4064 gnus-tmp-false-parent t))
4065 ((eq gnus-summary-make-false-root 'empty)
4066 ;; We print adopted articles with empty subject fields.
4067 (setq gnus-tmp-gathered
4069 (lambda (h) (mail-header-number (car h)))
4072 (setq gnus-tmp-level -1))
4073 ((eq gnus-summary-make-false-root 'dummy)
4074 ;; We remember that we probably want to output a dummy
4076 (setq gnus-tmp-dummy-line gnus-tmp-header)
4077 (setq gnus-tmp-prev-subject gnus-tmp-header))
4079 ;; We do not make a root for the gathered
4080 ;; sub-threads at all.
4081 (setq gnus-tmp-level -1)))
4083 (setq number (mail-header-number gnus-tmp-header)
4084 subject (mail-header-subject gnus-tmp-header))
4087 ;; If the thread has changed subject, we might want to make
4088 ;; this subthread into a root.
4089 ((and (null gnus-thread-ignore-subject)
4090 (not (zerop gnus-tmp-level))
4091 gnus-tmp-prev-subject
4093 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4094 (setq new-roots (nconc new-roots (list (car thread)))
4096 gnus-tmp-header nil))
4097 ;; If the article lies outside the current limit,
4098 ;; then we do not display it.
4099 ((not (memq number gnus-newsgroup-limit))
4100 (setq gnus-tmp-gathered
4102 (lambda (h) (mail-header-number (car h)))
4105 (setq gnus-tmp-new-adopts (if (cdar thread)
4106 (append gnus-tmp-new-adopts
4108 gnus-tmp-new-adopts)
4110 gnus-tmp-header nil)
4111 (when (zerop gnus-tmp-level)
4112 (setq gnus-tmp-root-expunged t)))
4113 ;; Perhaps this article is to be marked as read?
4114 ((and gnus-summary-mark-below
4115 (< (or (cdr (assq number gnus-newsgroup-scored))
4117 gnus-summary-mark-below)
4118 ;; Don't touch sparse articles.
4119 (not (gnus-summary-article-sparse-p number))
4120 (not (gnus-summary-article-ancient-p number)))
4121 (setq gnus-newsgroup-unreads
4122 (delq number gnus-newsgroup-unreads))
4123 (if gnus-newsgroup-auto-expire
4124 (push number gnus-newsgroup-expirable)
4125 (push (cons number gnus-low-score-mark)
4126 gnus-newsgroup-reads))))
4128 (when gnus-tmp-header
4129 ;; We may have an old dummy line to output before this
4131 (when (and gnus-tmp-dummy-line
4134 (mail-header-subject gnus-tmp-header)))
4135 (gnus-summary-insert-dummy-line
4136 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4137 (setq gnus-tmp-dummy-line nil))
4139 ;; Compute the mark.
4140 (setq gnus-tmp-unread (gnus-article-mark number))
4142 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4143 gnus-tmp-header gnus-tmp-level)
4144 gnus-newsgroup-data)
4146 ;; Actually insert the line.
4148 gnus-tmp-subject-or-nil
4150 ((and gnus-thread-ignore-subject
4151 gnus-tmp-prev-subject
4152 (not (inline (gnus-subject-equal
4153 gnus-tmp-prev-subject subject))))
4155 ((zerop gnus-tmp-level)
4156 (if (and (eq gnus-summary-make-false-root 'empty)
4157 (memq number gnus-tmp-gathered)
4158 gnus-tmp-prev-subject
4159 (inline (gnus-subject-equal
4160 gnus-tmp-prev-subject subject)))
4161 gnus-summary-same-subject
4163 (t gnus-summary-same-subject)))
4164 (if (and (eq gnus-summary-make-false-root 'adopt)
4165 (= gnus-tmp-level 1)
4166 (memq number gnus-tmp-gathered))
4167 (setq gnus-tmp-opening-bracket ?\<
4168 gnus-tmp-closing-bracket ?\>)
4169 (setq gnus-tmp-opening-bracket ?\[
4170 gnus-tmp-closing-bracket ?\]))
4172 gnus-tmp-indentation
4173 (aref gnus-thread-indent-array gnus-tmp-level)
4174 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4175 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4176 gnus-summary-default-score 0)
4178 (if (or (null gnus-summary-default-score)
4179 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4180 gnus-summary-zcore-fuzz))
4182 (if (< gnus-tmp-score gnus-summary-default-score)
4183 gnus-score-below-mark gnus-score-over-mark))
4185 (cond ((memq number gnus-newsgroup-processable)
4187 ((memq number gnus-newsgroup-cached)
4189 ((memq number gnus-newsgroup-replied)
4191 ((memq number gnus-newsgroup-saved)
4193 (t gnus-unread-mark))
4194 gnus-tmp-from (mail-header-from gnus-tmp-header)
4197 ((string-match "<[^>]+> *$" gnus-tmp-from)
4198 (setq beg-match (match-beginning 0))
4199 (or (and (string-match "^\".+\"" gnus-tmp-from)
4200 (substring gnus-tmp-from 1 (1- (match-end 0))))
4201 (substring gnus-tmp-from 0 beg-match)))
4202 ((string-match "(.+)" gnus-tmp-from)
4203 (substring gnus-tmp-from
4204 (1+ (match-beginning 0)) (1- (match-end 0))))
4206 (when (string= gnus-tmp-name "")
4207 (setq gnus-tmp-name gnus-tmp-from))
4208 (unless (numberp gnus-tmp-lines)
4209 (setq gnus-tmp-lines 0))
4210 (gnus-put-text-property
4212 (progn (eval gnus-summary-line-format-spec) (point))
4213 'gnus-number number)
4216 (gnus-run-hooks 'gnus-summary-update-hook)
4219 (setq gnus-tmp-prev-subject subject)))
4221 (when (nth 1 thread)
4222 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4223 (incf gnus-tmp-level)
4224 (setq threads (if thread-end nil (cdar thread)))
4226 (setq gnus-tmp-level 0)))))
4227 (gnus-message 7 "Generating summary...done"))
4229 (defun gnus-summary-prepare-unthreaded (headers)
4230 "Generate an unthreaded summary buffer based on HEADERS."
4231 (let (header number mark)
4236 ;; We may have to root out some bad articles...
4237 (when (memq (setq number (mail-header-number
4238 (setq header (pop headers))))
4239 gnus-newsgroup-limit)
4240 ;; Mark article as read when it has a low score.
4241 (when (and gnus-summary-mark-below
4242 (< (or (cdr (assq number gnus-newsgroup-scored))
4243 gnus-summary-default-score 0)
4244 gnus-summary-mark-below)
4245 (not (gnus-summary-article-ancient-p number)))
4246 (setq gnus-newsgroup-unreads
4247 (delq number gnus-newsgroup-unreads))
4248 (if gnus-newsgroup-auto-expire
4249 (push number gnus-newsgroup-expirable)
4250 (push (cons number gnus-low-score-mark)
4251 gnus-newsgroup-reads)))
4253 (setq mark (gnus-article-mark number))
4254 (push (gnus-data-make number mark (1+ (point)) header 0)
4255 gnus-newsgroup-data)
4256 (gnus-summary-insert-line
4258 mark (memq number gnus-newsgroup-replied)
4259 (memq number gnus-newsgroup-expirable)
4260 (mail-header-subject header) nil
4261 (cdr (assq number gnus-newsgroup-scored))
4262 (memq number gnus-newsgroup-processable))))))
4264 (defun gnus-summary-remove-list-identifiers ()
4265 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4266 (let ((regexp (if (stringp gnus-list-identifiers)
4267 gnus-list-identifiers
4268 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4269 (dolist (header gnus-newsgroup-headers)
4270 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4271 " *\\)\\)+\\(Re: +\\)?\\)")
4272 (mail-header-subject header))
4273 (mail-header-set-subject
4274 header (concat (substring (mail-header-subject header)
4275 0 (match-beginning 1))
4277 (match-string 3 (mail-header-subject header))
4278 (match-string 5 (mail-header-subject header)))
4279 (substring (mail-header-subject header)
4280 (match-end 1))))))))
4282 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4283 "Select newsgroup GROUP.
4284 If READ-ALL is non-nil, all articles in the group are selected.
4285 If SELECT-ARTICLES, only select those articles from GROUP."
4286 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4287 ;;!!! Dirty hack; should be removed.
4288 (gnus-summary-ignore-duplicates
4289 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4291 gnus-summary-ignore-duplicates))
4292 (info (nth 2 entry))
4293 articles fetched-articles cached)
4295 (unless (gnus-check-server
4296 (setq gnus-current-select-method
4297 (gnus-find-method-for-group group)))
4298 (error "Couldn't open server"))
4300 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4301 (gnus-activate-group group) ; Or we can activate it...
4302 (progn ; Or we bug out.
4303 (when (equal major-mode 'gnus-summary-mode)
4304 (kill-buffer (current-buffer)))
4305 (error "Couldn't activate group %s: %s"
4306 group (gnus-status-message group))))
4308 (unless (gnus-request-group group t)
4309 (when (equal major-mode 'gnus-summary-mode)
4310 (kill-buffer (current-buffer)))
4311 (error "Couldn't request group %s: %s"
4312 group (gnus-status-message group)))
4314 (setq gnus-newsgroup-name group)
4315 (setq gnus-newsgroup-unselected nil)
4316 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4317 (gnus-summary-setup-default-charset)
4319 ;; Adjust and set lists of article marks.
4321 (gnus-adjust-marked-articles info))
4323 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4325 (if (gnus-virtual-group-p group)
4326 gnus-newsgroup-cached
4327 (gnus-cache-articles-in-group group)))
4329 (setq gnus-newsgroup-unreads
4330 (gnus-set-difference
4331 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4332 gnus-newsgroup-dormant))
4334 (setq gnus-newsgroup-processable nil)
4336 (gnus-update-read-articles group gnus-newsgroup-unreads)
4338 (if (setq articles select-articles)
4339 (setq gnus-newsgroup-unselected
4340 (gnus-sorted-intersection
4341 gnus-newsgroup-unreads
4342 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4343 (setq articles (gnus-articles-to-read group read-all)))
4347 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4349 ((eq articles 0) nil)
4351 ;; Init the dependencies hash table.
4352 (setq gnus-newsgroup-dependencies
4353 (gnus-make-hashtable (length articles)))
4354 (gnus-set-global-variables)
4355 ;; Retrieve the headers and read them in.
4356 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4357 (setq gnus-newsgroup-headers
4358 (gnus-retrieve-parsed-headers
4359 articles gnus-newsgroup-name
4360 ;; We might want to fetch old headers, but
4361 ;; not if there is only 1 article.
4362 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4363 (not (numberp gnus-fetch-old-headers)))
4364 (> (length articles) 1))
4365 gnus-fetch-old-headers)))
4366 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4368 ;; Suppress duplicates?
4369 (when gnus-suppress-duplicates
4370 (gnus-dup-suppress-articles))
4372 ;; Set the initial limit.
4373 (setq gnus-newsgroup-limit (copy-sequence articles))
4374 ;; Remove canceled articles from the list of unread articles.
4375 (setq gnus-newsgroup-unreads
4376 (gnus-set-sorted-intersection
4377 gnus-newsgroup-unreads
4378 (setq fetched-articles
4379 (mapcar (lambda (headers) (mail-header-number headers))
4380 gnus-newsgroup-headers))))
4381 ;; Removed marked articles that do not exist.
4382 (gnus-update-missing-marks
4383 (gnus-sorted-complement fetched-articles articles))
4385 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4387 (setq gnus-newsgroup-cached cached))
4389 ;; We might want to build some more threads first.
4390 (when (and gnus-fetch-old-headers
4391 (eq gnus-headers-retrieved-by 'nov))
4392 (if (eq gnus-fetch-old-headers 'invisible)
4393 (gnus-build-all-threads)
4394 (gnus-build-old-threads)))
4395 ;; Let the Gnus agent mark articles as read.
4397 (gnus-agent-get-undownloaded-list))
4398 ;; Remove list identifiers from subject
4399 (when gnus-list-identifiers
4400 (gnus-summary-remove-list-identifiers))
4401 ;; Check whether auto-expire is to be done in this group.
4402 (setq gnus-newsgroup-auto-expire
4403 (gnus-group-auto-expirable-p group))
4404 ;; Set up the article buffer now, if necessary.
4405 (unless gnus-single-article-buffer
4406 (gnus-article-setup-buffer))
4407 ;; First and last article in this newsgroup.
4408 (when gnus-newsgroup-headers
4409 (setq gnus-newsgroup-begin
4410 (mail-header-number (car gnus-newsgroup-headers))
4413 (gnus-last-element gnus-newsgroup-headers))))
4414 ;; GROUP is successfully selected.
4415 (or gnus-newsgroup-headers t)))))
4417 (defun gnus-articles-to-read (group &optional read-all)
4418 "Find out what articles the user wants to read."
4420 ;; Select all articles if `read-all' is non-nil, or if there
4421 ;; are no unread articles.
4423 (and (zerop (length gnus-newsgroup-marked))
4424 (zerop (length gnus-newsgroup-unreads)))
4425 (eq (gnus-group-find-parameter group 'display)
4428 (gnus-uncompress-range (gnus-active group))
4429 (gnus-cache-articles-in-group group))
4430 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4431 (copy-sequence gnus-newsgroup-unreads))
4433 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4434 (scored (length scored-list))
4435 (number (length articles))
4436 (marked (+ (length gnus-newsgroup-marked)
4437 (length gnus-newsgroup-dormant)))
4445 ((and (or (<= scored marked) (= scored number))
4446 (natnump gnus-large-newsgroup)
4447 (> number gnus-large-newsgroup))
4448 (let* ((cursor-in-echo-area nil)
4449 (input (read-from-minibuffer
4451 "How many articles from %s (max %d): "
4452 (gnus-limit-string gnus-newsgroup-name 35)
4454 (cons (number-to-string gnus-large-newsgroup)
4456 (if (string-match "^[ \t]*$" input)
4459 ((and (> scored marked) (< scored number)
4460 (> (- scored number) 20))
4463 (format "%s %s (%d scored, %d total): "
4464 "How many articles from"
4465 group scored number))))
4466 (if (string-match "^[ \t]*$" input)
4470 (message "Quit getting the articles to read")
4472 (setq select (if (stringp select) (string-to-number select) select))
4473 (if (or (null select) (zerop select))
4475 (if (and (not (zerop scored)) (<= (abs select) scored))
4477 (setq articles (sort scored-list '<))
4478 (setq number (length articles)))
4479 (setq articles (copy-sequence articles)))
4481 (when (< (abs select) number)
4483 ;; Select the N oldest articles.
4484 (setcdr (nthcdr (1- (abs select)) articles) nil)
4485 ;; Select the N most recent articles.
4486 (setq articles (nthcdr (- number select) articles))))
4487 (setq gnus-newsgroup-unselected
4488 (gnus-sorted-intersection
4489 gnus-newsgroup-unreads
4490 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4491 (when gnus-alter-articles-to-read-function
4492 (setq gnus-newsgroup-unreads
4494 (funcall gnus-alter-articles-to-read-function
4495 gnus-newsgroup-name gnus-newsgroup-unreads)
4499 (defun gnus-killed-articles (killed articles)
4502 (when (inline (gnus-member-of-range (car articles) killed))
4503 (push (car articles) out))
4504 (setq articles (cdr articles)))
4507 (defun gnus-uncompress-marks (marks)
4508 "Uncompress the mark ranges in MARKS."
4509 (let ((uncompressed '(score bookmark))
4512 (if (memq (caar marks) uncompressed)
4513 (push (car marks) out)
4514 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4515 (setq marks (cdr marks)))
4518 (defun gnus-adjust-marked-articles (info)
4519 "Set all article lists and remove all marks that are no longer valid."
4520 (let* ((marked-lists (gnus-info-marks info))
4521 (active (gnus-active (gnus-info-group info)))
4524 (types gnus-article-mark-lists)
4525 (uncompressed '(score bookmark killed))
4526 marks var articles article mark)
4529 (setq marks (pop marked-lists))
4530 (set (setq var (intern (format "gnus-newsgroup-%s"
4531 (car (rassq (setq mark (car marks))
4533 (if (memq (car marks) uncompressed) (cdr marks)
4534 (gnus-uncompress-range (cdr marks))))
4536 (setq articles (symbol-value var))
4538 ;; All articles have to be subsets of the active articles.
4540 ;; Adjust "simple" lists.
4541 ((memq mark '(tick dormant expire reply save))
4543 (when (or (< (setq article (pop articles)) min) (> article max))
4544 (set var (delq article (symbol-value var))))))
4546 ((memq mark uncompressed)
4547 (when (not (listp (cdr (symbol-value var))))
4548 (set var (list (symbol-value var))))
4549 (when (not (listp (cdr articles)))
4550 (setq articles (list articles)))
4552 (when (or (not (consp (setq article (pop articles))))
4553 (< (car article) min)
4554 (> (car article) max))
4555 (set var (delq article (symbol-value var))))))))))
4557 (defun gnus-update-missing-marks (missing)
4558 "Go through the list of MISSING articles and remove them from the mark lists."
4560 (let ((types gnus-article-mark-lists)
4562 ;; Go through all types.
4564 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4565 (when (symbol-value var)
4566 ;; This list has articles. So we delete all missing articles
4570 (set var (delq (pop m) (symbol-value var)))))))))
4572 (defun gnus-update-marks ()
4573 "Enter the various lists of marked articles into the newsgroup info list."
4574 (let ((types gnus-article-mark-lists)
4575 (info (gnus-get-info gnus-newsgroup-name))
4576 (uncompressed '(score bookmark killed))
4577 type list newmarked symbol delta-marks)
4579 ;; Add all marks lists to the list of marks lists.
4580 (while (setq type (pop types))
4581 (setq list (symbol-value
4583 (intern (format "gnus-newsgroup-%s"
4587 ;; Get rid of the entries of the articles that have the
4589 (when (and (eq (cdr type) 'score)
4593 (prev (cons nil list))
4596 (if (or (not (consp (car arts)))
4597 (= (cdar arts) gnus-summary-default-score))
4598 (setcdr prev (cdr arts))
4600 (setq arts (cdr arts)))
4601 (setq list (cdr all)))))
4603 (unless (memq (cdr type) uncompressed)
4604 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4606 (when (gnus-check-backend-function
4607 'request-set-mark gnus-newsgroup-name)
4608 ;; propagate flags to server, with the following exceptions:
4609 ;; uncompressed:s are not proper flags (they are cons cells)
4610 ;; cache is a internal gnus flag
4611 ;; download are local to one gnus installation (well)
4612 ;; unsend are for nndraft groups only
4613 ;; xxx: generality of this? this suits nnimap anyway
4614 (unless (memq (cdr type) (append '(cache download unsend)
4616 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4617 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4618 (add (gnus-remove-from-range
4619 (gnus-copy-sequence list) old)))
4621 (push (list add 'add (list (cdr type))) delta-marks))
4623 (push (list del 'del (list (cdr type))) delta-marks)))))
4626 (push (cons (cdr type) list) newmarked)))
4629 (unless (gnus-check-group gnus-newsgroup-name)
4630 (error "Can't open server for %s" gnus-newsgroup-name))
4631 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4633 ;; Enter these new marks into the info of the group.
4635 (setcar (nthcdr 3 info) newmarked)
4636 ;; Add the marks lists to the end of the info.
4638 (setcdr (nthcdr 2 info) (list newmarked))))
4640 ;; Cut off the end of the info if there's nothing else there.
4644 (when (nthcdr (decf i) info)
4645 (setcdr (nthcdr i info) nil)))))))
4647 (defun gnus-set-mode-line (where)
4648 "Set the mode line of the article or summary buffers.
4649 If WHERE is `summary', the summary mode line format will be used."
4650 ;; Is this mode line one we keep updated?
4651 (when (and (memq where gnus-updated-mode-lines)
4653 (intern (format "gnus-%s-mode-line-format-spec" where))))
4656 ;; We evaluate this in the summary buffer since these
4657 ;; variables are buffer-local to that buffer.
4658 (set-buffer gnus-summary-buffer)
4659 ;; We bind all these variables that are used in the `eval' form
4661 (let* ((mformat (symbol-value
4663 (format "gnus-%s-mode-line-format-spec" where))))
4664 (gnus-tmp-group-name (gnus-group-name-decode
4666 (gnus-group-name-charset
4668 gnus-newsgroup-name)))
4669 (gnus-tmp-article-number (or gnus-current-article 0))
4670 (gnus-tmp-unread gnus-newsgroup-unreads)
4671 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4672 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4673 (gnus-tmp-unread-and-unselected
4674 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4675 (zerop gnus-tmp-unselected))
4677 ((zerop gnus-tmp-unselected)
4678 (format "{%d more}" gnus-tmp-unread-and-unticked))
4679 (t (format "{%d(+%d) more}"
4680 gnus-tmp-unread-and-unticked
4681 gnus-tmp-unselected))))
4683 (if (and gnus-current-headers
4684 (vectorp gnus-current-headers))
4685 (gnus-mode-string-quote
4686 (mail-header-subject gnus-current-headers))
4688 bufname-length max-len
4689 gnus-tmp-header);; passed as argument to any user-format-funcs
4690 (setq mode-string (eval mformat))
4691 (setq bufname-length (if (string-match "%b" mode-string)
4694 (if (eq where 'summary)
4696 (get-buffer gnus-article-buffer))))
4699 (setq max-len (max 4 (if gnus-mode-non-string-length
4701 gnus-mode-non-string-length
4703 (length mode-string))))
4704 ;; We might have to chop a bit of the string off...
4705 (when (> (length mode-string) max-len)
4707 (concat (gnus-truncate-string mode-string (- max-len 3))
4709 ;; Pad the mode string a bit.
4710 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4711 ;; Update the mode line.
4712 (setq mode-line-buffer-identification
4713 (gnus-mode-line-buffer-identification (list mode-string)))
4714 (set-buffer-modified-p t))))
4716 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4717 "Go through the HEADERS list and add all Xrefs to a hash table.
4718 The resulting hash table is returned, or nil if no Xrefs were found."
4719 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4720 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4721 (xref-hashtb (gnus-make-hashtable))
4722 start group entry number xrefs header)
4724 (setq header (pop headers))
4725 (when (and (setq xrefs (mail-header-xref header))
4726 (not (memq (setq number (mail-header-number header))
4729 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4730 (setq start (match-end 0))
4731 (setq group (if prefix
4732 (concat prefix (substring xrefs (match-beginning 1)
4734 (substring xrefs (match-beginning 1) (match-end 1))))
4736 (string-to-int (substring xrefs (match-beginning 2)
4738 (if (setq entry (gnus-gethash group xref-hashtb))
4739 (setcdr entry (cons number (cdr entry)))
4740 (gnus-sethash group (cons number nil) xref-hashtb)))))
4741 (and start xref-hashtb)))
4743 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4744 "Look through all the headers and mark the Xrefs as read."
4745 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4746 name entry info xref-hashtb idlist method nth4)
4748 (set-buffer gnus-group-buffer)
4749 (when (setq xref-hashtb
4750 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4753 (unless (string= from-newsgroup (setq name (symbol-name group)))
4754 (setq idlist (symbol-value group))
4755 ;; Dead groups are not updated.
4757 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4759 (when (stringp (setq nth4 (gnus-info-method info)))
4760 (setq nth4 (gnus-server-to-method nth4))))
4761 ;; Only do the xrefs if the group has the same
4762 ;; select method as the group we have just read.
4763 (or (gnus-methods-equal-p
4764 nth4 (gnus-find-method-for-group from-newsgroup))
4766 (equal nth4 (setq method (gnus-find-method-for-group
4768 (and (equal (car nth4) (car method))
4769 (equal (nth 1 nth4) (nth 1 method))))
4770 gnus-use-cross-reference
4771 (or (not (eq gnus-use-cross-reference t))
4773 ;; Only do cross-references on subscribed
4774 ;; groups, if that is what is wanted.
4775 (<= (gnus-info-level info) gnus-level-subscribed))
4776 (gnus-group-make-articles-read name idlist))))
4779 (defun gnus-compute-read-articles (group articles)
4780 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4781 (info (nth 2 entry))
4782 (active (gnus-active group))
4785 ;; First peel off all invalid article numbers.
4787 (let ((ids articles)
4789 (while (setq id (pop ids))
4790 (when (and first (> id (cdr active)))
4791 ;; We'll end up in this situation in one particular
4792 ;; obscure situation. If you re-scan a group and get
4793 ;; a new article that is cross-posted to a different
4794 ;; group that has not been re-scanned, you might get
4795 ;; crossposted article that has a higher number than
4796 ;; Gnus believes possible. So we re-activate this
4797 ;; group as well. This might mean doing the
4798 ;; crossposting thingy will *increase* the number
4799 ;; of articles in some groups. Tsk, tsk.
4800 (setq active (or (gnus-activate-group group) active)))
4801 (when (or (> id (cdr active))
4802 (< id (car active)))
4803 (setq articles (delq id articles))))))
4804 ;; If the read list is nil, we init it.
4806 (null (gnus-info-read info))
4808 (setq ninfo (cons 1 (1- (car active))))
4809 (setq ninfo (gnus-info-read info)))
4810 ;; Then we add the read articles to the range.
4812 ninfo (setq articles (sort articles '<))))))
4814 (defun gnus-group-make-articles-read (group articles)
4815 "Update the info of GROUP to say that ARTICLES are read."
4817 (entry (gnus-gethash group gnus-newsrc-hashtb))
4818 (info (nth 2 entry))
4819 (active (gnus-active group))
4822 (setq range (gnus-compute-read-articles group articles))
4824 (set-buffer gnus-group-buffer)
4827 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4828 (gnus-info-set-read ',info ',(gnus-info-read info))
4829 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4830 (gnus-group-update-group ,group t))))
4831 ;; Add the read articles to the range.
4832 (gnus-info-set-read info range)
4833 ;; Then we have to re-compute how many unread
4834 ;; articles there are in this group.
4838 (setq num (- (1+ (cdr active)) (car active))))
4839 ((not (listp (cdr range)))
4840 (setq num (- (cdr active) (- (1+ (cdr range))
4844 (if (numberp (car range))
4846 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4847 (setq range (cdr range)))
4848 (setq num (- (cdr active) num))))
4849 ;; Update the number of unread articles.
4851 ;; Update the group buffer.
4852 (gnus-group-update-group group t)))))
4854 (defvar gnus-newsgroup-none-id 0)
4856 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4857 (let ((cur nntp-server-buffer)
4860 (save-excursion (set-buffer gnus-summary-buffer)
4861 gnus-newsgroup-dependencies)))
4863 (mail-parse-charset gnus-newsgroup-charset)
4864 (mail-parse-ignored-charsets
4865 (save-excursion (condition-case nil
4866 (set-buffer gnus-summary-buffer)
4868 gnus-newsgroup-ignored-charsets)))
4870 (set-buffer nntp-server-buffer)
4871 ;; Translate all TAB characters into SPACE characters.
4872 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4873 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4874 (gnus-run-hooks 'gnus-parse-headers-hook)
4875 (let ((case-fold-search t)
4876 in-reply-to header p lines chars ctype)
4877 (goto-char (point-min))
4878 ;; Search to the beginning of the next header. Error messages
4879 ;; do not begin with 2 or 3.
4880 (while (re-search-forward "^[23][0-9]+ " nil t)
4883 ;; This implementation of this function, with nine
4884 ;; search-forwards instead of the one re-search-forward and
4885 ;; a case (which basically was the old function) is actually
4886 ;; about twice as fast, even though it looks messier. You
4887 ;; can't have everything, I guess. Speed and elegance
4888 ;; doesn't always go hand in hand.
4891 (make-full-mail-header
4897 (narrow-to-region (point)
4898 (or (and (search-forward "\n.\n" nil t)
4904 (if (search-forward "\nsubject: " nil t)
4905 (nnheader-header-value)
4910 (if (or (search-forward "\nfrom: " nil t)
4911 (search-forward "\nfrom:" nil t))
4912 (nnheader-header-value)
4917 (if (search-forward "\ndate: " nil t)
4918 (nnheader-header-value)
4923 (setq id (if (re-search-forward
4924 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4925 ;; We do it this way to make sure the Message-ID
4926 ;; is (somewhat) syntactically valid.
4927 (buffer-substring (match-beginning 1)
4929 ;; If there was no message-id, we just fake one
4930 ;; to make subsequent routines simpler.
4931 (nnheader-generate-fake-message-id))))
4935 (if (search-forward "\nreferences: " nil t)
4939 (nnheader-header-value)
4944 (search-backward ">" end t)
4947 (search-backward "<" end t)
4949 ;; Get the references from the in-reply-to header if there
4950 ;; were no references and the in-reply-to header looks
4952 (if (and (search-forward "\nin-reply-to: " nil t)
4953 (setq in-reply-to (nnheader-header-value))
4954 (string-match "<[^>]+>" in-reply-to))
4956 (setq ref (substring in-reply-to (match-beginning 0)
4958 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4959 (setq ref2 (substring in-reply-to (match-beginning 0)
4961 (when (> (length ref2) (length ref))
4968 (if (search-forward "\nchars: " nil t)
4969 (if (numberp (setq chars (ignore-errors (read cur))))
4975 (if (search-forward "\nlines: " nil t)
4976 (if (numberp (setq lines (ignore-errors (read cur))))
4982 (and (search-forward "\nxref: " nil t)
4983 (nnheader-header-value)))
4985 (when gnus-extra-headers
4986 (let ((extra gnus-extra-headers)
4990 (when (search-forward
4991 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4992 (push (cons (car extra) (nnheader-header-value)) out))
4996 (if (and (search-forward "\ncontent-type: " nil t)
4997 (setq ctype (nnheader-header-value)))
4998 (mime-entity-set-content-type-internal
4999 header (mime-parse-Content-Type ctype)))
5000 (when (equal id ref)
5003 (when gnus-alter-header-function
5004 (funcall gnus-alter-header-function header)
5005 (setq id (mail-header-id header)
5006 ref (gnus-parent-id (mail-header-references header))))
5009 (gnus-dependencies-add-header
5010 header dependencies force-new))
5011 (push header headers))
5012 (goto-char (point-max))
5014 (nreverse headers)))))
5016 ;; Goes through the xover lines and returns a list of vectors
5017 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5018 force-new dependencies
5019 group also-fetch-heads)
5020 "Parse the news overview data in the server buffer.
5021 Return a list of headers that match SEQUENCE (see
5022 `nntp-retrieve-headers')."
5023 ;; Get the Xref when the users reads the articles since most/some
5024 ;; NNTP servers do not include Xrefs when using XOVER.
5025 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5026 (let ((mail-parse-charset gnus-newsgroup-charset)
5027 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5028 (cur nntp-server-buffer)
5029 (dependencies (or dependencies gnus-newsgroup-dependencies))
5030 number headers header)
5032 (set-buffer nntp-server-buffer)
5033 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5034 ;; Allow the user to mangle the headers before parsing them.
5035 (gnus-run-hooks 'gnus-parse-headers-hook)
5036 (goto-char (point-min))
5039 (while (and sequence (not (eobp)))
5040 (setq number (read cur))
5041 (while (and sequence
5042 (< (car sequence) number))
5043 (setq sequence (cdr sequence)))
5045 (eq number (car sequence))
5047 (setq sequence (cdr sequence))
5048 (setq header (inline
5049 (gnus-nov-parse-line
5050 number dependencies force-new))))
5051 (push header headers))
5054 (gnus-error 4 "Strange nov line (%d)"
5055 (count-lines (point-min) (point)))))
5057 ;; A common bug in inn is that if you have posted an article and
5058 ;; then retrieves the active file, it will answer correctly --
5059 ;; the new article is included. However, a NOV entry for the
5060 ;; article may not have been generated yet, so this may fail.
5061 ;; We work around this problem by retrieving the last few
5062 ;; headers using HEAD.
5063 (if (or (not also-fetch-heads)
5065 ;; We (probably) got all the headers.
5067 (let ((gnus-nov-is-evil t))
5070 (gnus-retrieve-parsed-headers sequence group)
5073 (defun gnus-article-get-xrefs ()
5074 "Fill in the Xref value in `gnus-current-headers', if necessary.
5075 This is meant to be called in `gnus-article-internal-prepare-hook'."
5076 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5077 gnus-current-headers)))
5078 (or (not gnus-use-cross-reference)
5080 (and (mail-header-xref headers)
5081 (not (string= (mail-header-xref headers) "")))
5082 (let ((case-fold-search t)
5085 (nnheader-narrow-to-headers)
5086 (goto-char (point-min))
5087 (when (or (and (not (eobp))
5088 (eq (downcase (char-after)) ?x)
5089 (looking-at "Xref:"))
5090 (search-forward "\nXref:" nil t))
5091 (goto-char (1+ (match-end 0)))
5092 (setq xref (buffer-substring (point)
5093 (progn (end-of-line) (point))))
5094 (mail-header-set-xref headers xref)))))))
5096 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5097 "Find article ID and insert the summary line for that article.
5098 OLD-HEADER can either be a header or a line number to insert
5099 the subject line on."
5100 (let* ((line (and (numberp old-header) old-header))
5101 (old-header (and (vectorp old-header) old-header))
5102 (header (cond ((and old-header use-old-header)
5105 (gnus-number-to-header id))
5106 (gnus-number-to-header id))
5108 (gnus-read-header id))))
5109 (number (and (numberp id) id))
5112 ;; Rebuild the thread that this article is part of and go to the
5113 ;; article we have fetched.
5114 (when (and (not gnus-show-threads)
5117 (setq d (gnus-data-find (mail-header-number old-header))))
5118 (goto-char (gnus-data-pos d))
5121 (- (gnus-point-at-bol)
5123 (1+ (gnus-point-at-eol))
5124 (gnus-delete-line))))))
5126 (mail-header-set-number header (mail-header-number old-header)))
5127 (setq gnus-newsgroup-sparse
5128 (delq (setq number (mail-header-number header))
5129 gnus-newsgroup-sparse))
5130 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5131 (push number gnus-newsgroup-limit)
5132 (gnus-rebuild-thread (mail-header-id header) line)
5133 (gnus-summary-goto-subject number nil t))
5134 (when (and (numberp number)
5136 ;; We have to update the boundaries even if we can't fetch the
5137 ;; article if ID is a number -- so that the next `P' or `N'
5138 ;; command will fetch the previous (or next) article even
5139 ;; if the one we tried to fetch this time has been canceled.
5140 (when (> number gnus-newsgroup-end)
5141 (setq gnus-newsgroup-end number))
5142 (when (< number gnus-newsgroup-begin)
5143 (setq gnus-newsgroup-begin number))
5144 (setq gnus-newsgroup-unselected
5145 (delq number gnus-newsgroup-unselected)))
5146 ;; Report back a success?
5147 (and header (mail-header-number header))))
5149 ;;; Process/prefix in the summary buffer
5151 (defun gnus-summary-work-articles (n)
5152 "Return a list of articles to be worked upon.
5153 The prefix argument, the list of process marked articles, and the
5154 current article will be taken into consideration."
5156 (set-buffer gnus-summary-buffer)
5159 ;; A numerical prefix has been given.
5160 (setq n (prefix-numeric-value n))
5161 (let ((backward (< n 0))
5162 (n (abs (prefix-numeric-value n)))
5167 (push (setq article (gnus-summary-article-number))
5170 (gnus-summary-find-prev nil article)
5171 (gnus-summary-find-next nil article)))
5173 (nreverse articles)))
5174 ((and (gnus-region-active-p) (mark))
5175 (message "region active")
5176 ;; Work on the region between point and mark.
5177 (let ((max (max (point) (mark)))
5180 (goto-char (min (point) (mark)))
5183 (push (setq article (gnus-summary-article-number)) articles)
5184 (gnus-summary-find-next nil article)
5186 (nreverse articles))))
5187 (gnus-newsgroup-processable
5188 ;; There are process-marked articles present.
5189 ;; Save current state.
5190 (gnus-summary-save-process-mark)
5192 (reverse gnus-newsgroup-processable))
5194 ;; Just return the current article.
5195 (list (gnus-summary-article-number))))))
5197 (defmacro gnus-summary-iterate (arg &rest forms)
5198 "Iterate over the process/prefixed articles and do FORMS.
5199 ARG is the interactive prefix given to the command. FORMS will be
5200 executed with point over the summary line of the articles."
5201 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5202 `(let ((,articles (gnus-summary-work-articles ,arg)))
5204 (gnus-summary-goto-subject (car ,articles))
5208 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5209 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5211 (defun gnus-summary-save-process-mark ()
5212 "Push the current set of process marked articles on the stack."
5214 (push (copy-sequence gnus-newsgroup-processable)
5215 gnus-newsgroup-process-stack))
5217 (defun gnus-summary-kill-process-mark ()
5218 "Push the current set of process marked articles on the stack and unmark."
5220 (gnus-summary-save-process-mark)
5221 (gnus-summary-unmark-all-processable))
5223 (defun gnus-summary-yank-process-mark ()
5224 "Pop the last process mark state off the stack and restore it."
5226 (unless gnus-newsgroup-process-stack
5227 (error "Empty mark stack"))
5228 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5230 (defun gnus-summary-process-mark-set (set)
5231 "Make SET into the current process marked articles."
5232 (gnus-summary-unmark-all-processable)
5234 (gnus-summary-set-process-mark (pop set))))
5236 ;;; Searching and stuff
5238 (defun gnus-summary-search-group (&optional backward use-level)
5239 "Search for next unread newsgroup.
5240 If optional argument BACKWARD is non-nil, search backward instead."
5242 (set-buffer gnus-group-buffer)
5243 (when (gnus-group-search-forward
5244 backward nil (if use-level (gnus-group-group-level) nil))
5245 (gnus-group-group-name))))
5247 (defun gnus-summary-best-group (&optional exclude-group)
5248 "Find the name of the best unread group.
5249 If EXCLUDE-GROUP, do not go to this group."
5251 (set-buffer gnus-group-buffer)
5253 (gnus-group-best-unread-group exclude-group))))
5255 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5256 (if backward (gnus-summary-find-prev)
5257 (let* ((dummy (gnus-summary-article-intangible-p))
5258 (article (or article (gnus-summary-article-number)))
5259 (arts (gnus-data-find-list article))
5261 (when (and (not dummy)
5262 (or (not gnus-summary-check-current)
5264 (not (gnus-data-unread-p (car arts)))))
5265 (setq arts (cdr arts)))
5270 (when (or (and undownloaded
5271 (eq gnus-undownloaded-mark
5272 (gnus-data-mark (car arts))))
5273 (gnus-data-unread-p (car arts)))
5274 (setq result (car arts)
5276 (setq arts (cdr arts)))
5279 (goto-char (gnus-data-pos result))
5280 (gnus-data-number result)))))
5282 (defun gnus-summary-find-prev (&optional unread article)
5283 (let* ((eobp (eobp))
5284 (article (or article (gnus-summary-article-number)))
5285 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5287 (when (and (not eobp)
5288 (or (not gnus-summary-check-current)
5290 (not (gnus-data-unread-p (car arts)))))
5291 (setq arts (cdr arts)))
5296 (when (gnus-data-unread-p (car arts))
5297 (setq result (car arts)
5299 (setq arts (cdr arts)))
5302 (goto-char (gnus-data-pos result))
5303 (gnus-data-number result))))
5305 (defun gnus-summary-find-subject (subject &optional unread backward article)
5306 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5307 (article (or article (gnus-summary-article-number)))
5308 (articles (gnus-data-list backward))
5309 (arts (gnus-data-find-list article articles))
5311 (when (or (not gnus-summary-check-current)
5313 (not (gnus-data-unread-p (car arts))))
5314 (setq arts (cdr arts)))
5316 (and (or (not unread)
5317 (gnus-data-unread-p (car arts)))
5318 (vectorp (gnus-data-header (car arts)))
5320 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5321 (setq result (car arts)
5323 (setq arts (cdr arts)))
5325 (goto-char (gnus-data-pos result))
5326 (gnus-data-number result))))
5328 (defun gnus-summary-search-forward (&optional unread subject backward)
5329 "Search forward for an article.
5330 If UNREAD, look for unread articles. If SUBJECT, look for
5331 articles with that subject. If BACKWARD, search backward instead."
5332 (cond (subject (gnus-summary-find-subject subject unread backward))
5333 (backward (gnus-summary-find-prev unread))
5334 (t (gnus-summary-find-next unread))))
5336 (defun gnus-recenter (&optional n)
5337 "Center point in window and redisplay frame.
5338 Also do horizontal recentering."
5340 (when (and gnus-auto-center-summary
5341 (not (eq gnus-auto-center-summary 'vertical)))
5342 (gnus-horizontal-recenter))
5345 (defun gnus-summary-recenter ()
5346 "Center point in the summary window.
5347 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5348 displayed, no centering will be performed."
5349 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5350 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5352 (let* ((top (cond ((< (window-height) 4) 0)
5353 ((< (window-height) 7) 1)
5354 (t (if (numberp gnus-auto-center-summary)
5355 gnus-auto-center-summary
5357 (height (1- (window-height)))
5358 (bottom (save-excursion (goto-char (point-max))
5359 (forward-line (- height))
5361 (window (get-buffer-window (current-buffer))))
5362 ;; The user has to want it.
5363 (when gnus-auto-center-summary
5364 (when (get-buffer-window gnus-article-buffer)
5365 ;; Only do recentering when the article buffer is displayed,
5366 ;; Set the window start to either `bottom', which is the biggest
5367 ;; possible valid number, or the second line from the top,
5368 ;; whichever is the least.
5369 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5370 (if (> bottom top-pos)
5371 ;; Keep the second line from the top visible
5372 (set-window-start window top-pos t)
5373 ;; Try to keep the bottom line visible; if it's partially
5374 ;; obscured, either scroll one more line to make it fully
5375 ;; visible, or revert to using TOP-POS.
5377 (goto-char (point-max))
5379 (let ((last-line-start (point)))
5381 (set-window-start window (point) t)
5382 (when (not (pos-visible-in-window-p last-line-start window))
5384 (set-window-start window (min (point) top-pos) t)))))))
5385 ;; Do horizontal recentering while we're at it.
5386 (when (and (get-buffer-window (current-buffer) t)
5387 (not (eq gnus-auto-center-summary 'vertical)))
5388 (let ((selected (selected-window)))
5389 (select-window (get-buffer-window (current-buffer) t))
5390 (gnus-summary-position-point)
5391 (gnus-horizontal-recenter)
5392 (select-window selected))))))
5394 (defun gnus-summary-jump-to-group (newsgroup)
5395 "Move point to NEWSGROUP in group mode buffer."
5396 ;; Keep update point of group mode buffer if visible.
5397 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5398 (save-window-excursion
5399 ;; Take care of tree window mode.
5400 (when (get-buffer-window gnus-group-buffer)
5401 (pop-to-buffer gnus-group-buffer))
5402 (gnus-group-jump-to-group newsgroup))
5404 ;; Take care of tree window mode.
5405 (if (get-buffer-window gnus-group-buffer)
5406 (pop-to-buffer gnus-group-buffer)
5407 (set-buffer gnus-group-buffer))
5408 (gnus-group-jump-to-group newsgroup))))
5410 ;; This function returns a list of article numbers based on the
5411 ;; difference between the ranges of read articles in this group and
5412 ;; the range of active articles.
5413 (defun gnus-list-of-unread-articles (group)
5414 (let* ((read (gnus-info-read (gnus-get-info group)))
5415 (active (or (gnus-active group) (gnus-activate-group group)))
5418 ;; If none are read, then all are unread.
5420 (setq first (car active))
5421 ;; If the range of read articles is a single range, then the
5422 ;; first unread article is the article after the last read
5423 ;; article. Sounds logical, doesn't it?
5424 (if (and (not (listp (cdr read)))
5425 (or (< (car read) (car active))
5426 (progn (setq read (list read))
5428 (setq first (max (car active) (1+ (cdr read))))
5429 ;; `read' is a list of ranges.
5430 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5433 (setq first (car active)))
5436 (while (< first nlast)
5438 (setq first (1+ first))))
5439 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5440 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5441 (setq read (cdr read)))))
5442 ;; And add the last unread articles.
5443 (while (<= first last)
5445 (setq first (1+ first)))
5446 ;; Return the list of unread articles.
5447 (delq 0 (nreverse unread))))
5449 (defun gnus-list-of-read-articles (group)
5450 "Return a list of unread, unticked and non-dormant articles."
5451 (let* ((info (gnus-get-info group))
5452 (marked (gnus-info-marks info))
5453 (active (gnus-active group)))
5455 (gnus-set-difference
5456 (gnus-sorted-complement
5457 (gnus-uncompress-range active)
5458 (gnus-list-of-unread-articles group))
5460 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5461 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5463 ;; Various summary commands
5465 (defun gnus-summary-select-article-buffer ()
5466 "Reconfigure windows to show article buffer."
5468 (if (not (gnus-buffer-live-p gnus-article-buffer))
5469 (error "There is no article buffer for this summary buffer")
5470 (gnus-configure-windows 'article)
5471 (select-window (get-buffer-window gnus-article-buffer))))
5473 (defun gnus-summary-universal-argument (arg)
5474 "Perform any operation on all articles that are process/prefixed."
5476 (let ((articles (gnus-summary-work-articles arg))
5483 (substitute-command-keys
5484 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5486 (gnus-error 1 "Undefined key")
5489 (gnus-summary-goto-subject (setq article (pop articles)))
5490 (let (gnus-newsgroup-processable)
5491 (command-execute func))
5492 (gnus-summary-remove-process-mark article)))))
5493 (gnus-summary-position-point))
5495 (defun gnus-summary-toggle-truncation (&optional arg)
5496 "Toggle truncation of summary lines.
5497 With arg, turn line truncation on iff arg is positive."
5499 (setq truncate-lines
5500 (if (null arg) (not truncate-lines)
5501 (> (prefix-numeric-value arg) 0)))
5504 (defun gnus-summary-reselect-current-group (&optional all rescan)
5505 "Exit and then reselect the current newsgroup.
5506 The prefix argument ALL means to select all articles."
5508 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5509 (error "Ephemeral groups can't be reselected"))
5510 (let ((current-subject (gnus-summary-article-number))
5511 (group gnus-newsgroup-name))
5512 (setq gnus-newsgroup-begin nil)
5514 ;; We have to adjust the point of group mode buffer because
5515 ;; point was moved to the next unread newsgroup by exiting.
5516 (gnus-summary-jump-to-group group)
5519 (save-window-excursion
5520 ;; Don't show group contents.
5521 (set-window-start (selected-window) (point-max))
5522 (gnus-group-get-new-news-this-group 1))))
5523 (gnus-group-read-group all t)
5524 (gnus-summary-goto-subject current-subject nil t)))
5526 (defun gnus-summary-rescan-group (&optional all)
5527 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5529 (gnus-summary-reselect-current-group all t))
5531 (defun gnus-summary-update-info (&optional non-destructive)
5533 (let ((group gnus-newsgroup-name))
5535 (when gnus-newsgroup-kill-headers
5536 (setq gnus-newsgroup-killed
5537 (gnus-compress-sequence
5539 (gnus-set-sorted-intersection
5540 (gnus-uncompress-range gnus-newsgroup-killed)
5541 (setq gnus-newsgroup-unselected
5542 (sort gnus-newsgroup-unselected '<)))
5543 (setq gnus-newsgroup-unreads
5544 (sort gnus-newsgroup-unreads '<)))
5546 (unless (listp (cdr gnus-newsgroup-killed))
5547 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5548 (let ((headers gnus-newsgroup-headers))
5549 ;; Set the new ranges of read articles.
5551 (set-buffer gnus-group-buffer)
5552 (gnus-undo-force-boundary))
5553 (gnus-update-read-articles
5554 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5555 ;; Set the current article marks.
5556 (let ((gnus-newsgroup-scored
5557 (if (and (not gnus-save-score)
5558 (not non-destructive))
5560 gnus-newsgroup-scored)))
5562 (gnus-update-marks)))
5563 ;; Do the cross-ref thing.
5564 (when gnus-use-cross-reference
5565 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5566 ;; Do not switch windows but change the buffer to work.
5567 (set-buffer gnus-group-buffer)
5568 (unless (gnus-ephemeral-group-p group)
5569 (gnus-group-update-group group)))))))
5571 (defun gnus-summary-save-newsrc (&optional force)
5572 "Save the current number of read/marked articles in the dribble buffer.
5573 The dribble buffer will then be saved.
5574 If FORCE (the prefix), also save the .newsrc file(s)."
5576 (gnus-summary-update-info t)
5578 (gnus-save-newsrc-file)
5579 (gnus-dribble-save)))
5581 (defun gnus-summary-exit (&optional temporary)
5582 "Exit reading current newsgroup, and then return to group selection mode.
5583 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5585 (gnus-set-global-variables)
5586 (gnus-kill-save-kill-buffer)
5587 (gnus-async-halt-prefetch)
5588 (let* ((group gnus-newsgroup-name)
5589 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5592 (buf (current-buffer)))
5594 ;; Do adaptive scoring, and possibly save score files.
5595 (when gnus-newsgroup-adaptive
5596 (gnus-score-adaptive))
5597 (when gnus-use-scoring
5599 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5600 ;; If we have several article buffers, we kill them at exit.
5601 (unless gnus-single-article-buffer
5602 (gnus-kill-buffer gnus-original-article-buffer)
5603 (setq gnus-article-current nil))
5604 (when gnus-use-cache
5605 (gnus-cache-possibly-remove-articles)
5606 (gnus-cache-save-buffers))
5607 (gnus-async-prefetch-remove-group group)
5608 (when gnus-suppress-duplicates
5609 (gnus-dup-enter-articles))
5610 (when gnus-use-trees
5611 (gnus-tree-close group))
5612 (when gnus-use-cache
5613 (gnus-cache-write-active))
5614 ;; Remove entries for this group.
5615 (nnmail-purge-split-history (gnus-group-real-name group))
5616 ;; Make all changes in this group permanent.
5618 (gnus-run-hooks 'gnus-exit-group-hook)
5619 (gnus-summary-update-info))
5620 (gnus-close-group group)
5621 ;; Make sure where we were, and go to next newsgroup.
5622 (set-buffer gnus-group-buffer)
5624 (gnus-group-jump-to-group group))
5625 (gnus-run-hooks 'gnus-summary-exit-hook)
5626 (unless (or quit-config
5627 ;; If this group has disappeared from the summary
5628 ;; buffer, don't skip forwards.
5629 (not (string= group (gnus-group-group-name))))
5630 (gnus-group-next-unread-group 1))
5631 (setq group-point (point))
5634 ;; If we have several article buffers, we kill them at exit.
5635 (unless gnus-single-article-buffer
5636 (gnus-kill-buffer gnus-article-buffer)
5637 (gnus-kill-buffer gnus-original-article-buffer)
5638 (setq gnus-article-current nil))
5640 (if (not gnus-kill-summary-on-exit)
5641 (gnus-deaden-summary)
5642 ;; We set all buffer-local variables to nil. It is unclear why
5643 ;; this is needed, but if we don't, buffer-local variables are
5644 ;; not garbage-collected, it seems. This would the lead to en
5645 ;; ever-growing Emacs.
5646 (gnus-summary-clear-local-variables)
5647 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5648 (gnus-summary-clear-local-variables))
5649 (when (get-buffer gnus-article-buffer)
5650 (bury-buffer gnus-article-buffer))
5651 ;; We clear the global counterparts of the buffer-local
5652 ;; variables as well, just to be on the safe side.
5653 (set-buffer gnus-group-buffer)
5654 (gnus-summary-clear-local-variables)
5655 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5656 (gnus-summary-clear-local-variables))
5657 ;; Return to group mode buffer.
5658 (when (eq mode 'gnus-summary-mode)
5659 (gnus-kill-buffer buf)))
5660 (setq gnus-current-select-method gnus-select-method)
5661 (pop-to-buffer gnus-group-buffer)
5662 (if (not quit-config)
5664 (goto-char group-point)
5665 (gnus-configure-windows 'group 'force)
5666 (unless (pos-visible-in-window-p)
5667 (forward-line (/ (static-if (featurep 'xemacs)
5668 (window-displayed-height)
5669 (1- (window-height)))
5671 (set-window-start (selected-window) (point))
5672 (goto-char group-point)))
5673 (gnus-handle-ephemeral-exit quit-config))
5674 ;; Clear the current group name.
5676 (setq gnus-newsgroup-name nil)))))
5678 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5679 (defun gnus-summary-exit-no-update (&optional no-questions)
5680 "Quit reading current newsgroup without updating read article info."
5682 (let* ((group gnus-newsgroup-name)
5683 (quit-config (gnus-group-quit-config group)))
5684 (when (or no-questions
5686 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5687 (gnus-async-halt-prefetch)
5689 (delq 'gnus-summary-expire-articles
5690 (copy-sequence gnus-summary-prepare-exit-hook)))
5691 ;; If we have several article buffers, we kill them at exit.
5692 (unless gnus-single-article-buffer
5693 (gnus-kill-buffer gnus-article-buffer)
5694 (gnus-kill-buffer gnus-original-article-buffer)
5695 (setq gnus-article-current nil))
5696 (if (not gnus-kill-summary-on-exit)
5697 (gnus-deaden-summary)
5698 (gnus-close-group group)
5699 (gnus-summary-clear-local-variables)
5700 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5701 (gnus-summary-clear-local-variables))
5702 (set-buffer gnus-group-buffer)
5703 (gnus-summary-clear-local-variables)
5704 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5705 (gnus-summary-clear-local-variables))
5706 (when (get-buffer gnus-summary-buffer)
5707 (kill-buffer gnus-summary-buffer)))
5708 (unless gnus-single-article-buffer
5709 (setq gnus-article-current nil))
5710 (when gnus-use-trees
5711 (gnus-tree-close group))
5712 (gnus-async-prefetch-remove-group group)
5713 (when (get-buffer gnus-article-buffer)
5714 (bury-buffer gnus-article-buffer))
5715 ;; Return to the group buffer.
5716 (gnus-configure-windows 'group 'force)
5717 ;; Clear the current group name.
5718 (setq gnus-newsgroup-name nil)
5719 (when (equal (gnus-group-group-name) group)
5720 (gnus-group-next-unread-group 1))
5722 (gnus-handle-ephemeral-exit quit-config)))))
5724 (defun gnus-handle-ephemeral-exit (quit-config)
5725 "Handle movement when leaving an ephemeral group.
5726 The state which existed when entering the ephemeral is reset."
5727 (if (not (buffer-name (car quit-config)))
5728 (gnus-configure-windows 'group 'force)
5729 (set-buffer (car quit-config))
5730 (cond ((eq major-mode 'gnus-summary-mode)
5731 (gnus-set-global-variables))
5732 ((eq major-mode 'gnus-article-mode)
5734 ;; The `gnus-summary-buffer' variable may point
5735 ;; to the old summary buffer when using a single
5737 (unless (gnus-buffer-live-p gnus-summary-buffer)
5738 (set-buffer gnus-group-buffer))
5739 (set-buffer gnus-summary-buffer)
5740 (gnus-set-global-variables))))
5741 (if (or (eq (cdr quit-config) 'article)
5742 (eq (cdr quit-config) 'pick))
5744 ;; The current article may be from the ephemeral group
5745 ;; thus it is best that we reload this article
5746 (gnus-summary-show-article)
5747 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5748 (gnus-configure-windows 'pick 'force)
5749 (gnus-configure-windows (cdr quit-config) 'force)))
5750 (gnus-configure-windows (cdr quit-config) 'force))
5751 (when (eq major-mode 'gnus-summary-mode)
5752 (gnus-summary-next-subject 1 nil t)
5753 (gnus-summary-recenter)
5754 (gnus-summary-position-point))))
5756 (defun gnus-summary-preview-mime-message ()
5757 "MIME decode and play this message."
5759 (let ((gnus-break-pages nil)
5761 (gnus-summary-select-article gnus-show-all-headers t))
5762 (select-window (get-buffer-window gnus-article-buffer)))
5766 (defvar gnus-dead-summary-mode-map nil)
5768 (unless gnus-dead-summary-mode-map
5769 (setq gnus-dead-summary-mode-map (make-keymap))
5770 (suppress-keymap gnus-dead-summary-mode-map)
5771 (substitute-key-definition
5772 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5773 (let ((keys '("\C-d" "\r" "\177" [delete])))
5775 (define-key gnus-dead-summary-mode-map
5776 (pop keys) 'gnus-summary-wake-up-the-dead))))
5778 (defvar gnus-dead-summary-mode nil
5779 "Minor mode for Gnus summary buffers.")
5781 (defun gnus-dead-summary-mode (&optional arg)
5782 "Minor mode for Gnus summary buffers."
5784 (when (eq major-mode 'gnus-summary-mode)
5785 (make-local-variable 'gnus-dead-summary-mode)
5786 (setq gnus-dead-summary-mode
5787 (if (null arg) (not gnus-dead-summary-mode)
5788 (> (prefix-numeric-value arg) 0)))
5789 (when gnus-dead-summary-mode
5790 (gnus-add-minor-mode
5791 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5793 (defun gnus-deaden-summary ()
5794 "Make the current summary buffer into a dead summary buffer."
5795 ;; Kill any previous dead summary buffer.
5796 (when (and gnus-dead-summary
5797 (buffer-name gnus-dead-summary))
5799 (set-buffer gnus-dead-summary)
5800 (when gnus-dead-summary-mode
5801 (kill-buffer (current-buffer)))))
5802 ;; Make this the current dead summary.
5803 (setq gnus-dead-summary (current-buffer))
5804 (gnus-dead-summary-mode 1)
5805 (let ((name (buffer-name)))
5806 (when (string-match "Summary" name)
5808 (concat (substring name 0 (match-beginning 0)) "Dead "
5809 (substring name (match-beginning 0)))
5813 (defun gnus-kill-or-deaden-summary (buffer)
5814 "Kill or deaden the summary BUFFER."
5816 (when (and (buffer-name buffer)
5817 (not gnus-single-article-buffer))
5820 (gnus-kill-buffer gnus-article-buffer)
5821 (gnus-kill-buffer gnus-original-article-buffer)))
5822 (cond (gnus-kill-summary-on-exit
5823 (when (and gnus-use-trees
5824 (gnus-buffer-exists-p buffer))
5827 (gnus-tree-close gnus-newsgroup-name)))
5828 (gnus-kill-buffer buffer))
5829 ((gnus-buffer-exists-p buffer)
5832 (gnus-deaden-summary))))))
5834 (defun gnus-summary-wake-up-the-dead (&rest args)
5835 "Wake up the dead summary buffer."
5837 (gnus-dead-summary-mode -1)
5838 (let ((name (buffer-name)))
5839 (when (string-match "Dead " name)
5841 (concat (substring name 0 (match-beginning 0))
5842 (substring name (match-end 0)))
5844 (gnus-message 3 "This dead summary is now alive again"))
5846 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5847 (defun gnus-summary-fetch-faq (&optional faq-dir)
5848 "Fetch the FAQ for the current group.
5849 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5853 (when current-prefix-arg
5855 "Faq dir: " (and (listp gnus-group-faq-directory)
5856 (mapcar (lambda (file) (list file))
5857 gnus-group-faq-directory))))))
5858 (let (gnus-faq-buffer)
5859 (when (setq gnus-faq-buffer
5860 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5861 (gnus-configure-windows 'summary-faq))))
5863 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5864 (defun gnus-summary-describe-group (&optional force)
5865 "Describe the current newsgroup."
5867 (gnus-group-describe-group force gnus-newsgroup-name))
5869 (defun gnus-summary-describe-briefly ()
5870 "Describe summary mode commands briefly."
5872 (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")))
5874 ;; Walking around group mode buffer from summary mode.
5876 (defun gnus-summary-next-group (&optional no-article target-group backward)
5877 "Exit current newsgroup and then select next unread newsgroup.
5878 If prefix argument NO-ARTICLE is non-nil, no article is selected
5879 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5880 previous group instead."
5882 ;; Stop pre-fetching.
5883 (gnus-async-halt-prefetch)
5884 (let ((current-group gnus-newsgroup-name)
5885 (current-buffer (current-buffer))
5887 ;; First we semi-exit this group to update Xrefs and all variables.
5888 ;; We can't do a real exit, because the window conf must remain
5889 ;; the same in case the user is prompted for info, and we don't
5890 ;; want the window conf to change before that...
5891 (gnus-summary-exit t)
5892 (while (not entered)
5893 ;; Then we find what group we are supposed to enter.
5894 (set-buffer gnus-group-buffer)
5895 (gnus-group-jump-to-group current-group)
5898 (if (eq gnus-keep-same-level 'best)
5899 (gnus-summary-best-group gnus-newsgroup-name)
5900 (gnus-summary-search-group backward gnus-keep-same-level))))
5901 (if (not target-group)
5902 ;; There are no further groups, so we return to the group
5905 (gnus-message 5 "Returning to the group buffer")
5907 (when (gnus-buffer-live-p current-buffer)
5908 (set-buffer current-buffer)
5909 (gnus-summary-exit))
5910 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5911 ;; We try to enter the target group.
5912 (gnus-group-jump-to-group target-group)
5913 (let ((unreads (gnus-group-group-unread)))
5914 (if (and (or (eq t unreads)
5915 (and unreads (not (zerop unreads))))
5916 (gnus-summary-read-group
5917 target-group nil no-article
5918 (and (buffer-name current-buffer) current-buffer)
5921 (setq current-group target-group
5922 target-group nil)))))))
5924 (defun gnus-summary-prev-group (&optional no-article)
5925 "Exit current newsgroup and then select previous unread newsgroup.
5926 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5928 (gnus-summary-next-group no-article nil t))
5930 ;; Walking around summary lines.
5932 (defun gnus-summary-first-subject (&optional unread undownloaded)
5933 "Go to the first unread subject.
5934 If UNREAD is non-nil, go to the first unread article.
5935 Returns the article selected or nil if there are no unread articles."
5940 ((null gnus-newsgroup-data)
5941 (gnus-message 3 "No articles in the group")
5943 ;; Pick the first article.
5945 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5946 (gnus-data-number (car gnus-newsgroup-data)))
5947 ;; No unread articles.
5948 ((null gnus-newsgroup-unreads)
5949 (gnus-message 3 "No more unread articles")
5951 ;; Find the first unread article.
5953 (let ((data gnus-newsgroup-data))
5955 (and (not (and undownloaded
5956 (eq gnus-undownloaded-mark
5957 (gnus-data-mark (car data)))))
5958 (not (gnus-data-unread-p (car data)))))
5959 (setq data (cdr data)))
5961 (goto-char (gnus-data-pos (car data)))
5962 (gnus-data-number (car data))))))
5963 (gnus-summary-position-point)))
5965 (defun gnus-summary-next-subject (n &optional unread dont-display)
5966 "Go to next N'th summary line.
5967 If N is negative, go to the previous N'th subject line.
5968 If UNREAD is non-nil, only unread articles are selected.
5969 The difference between N and the actual number of steps taken is
5972 (let ((backward (< n 0))
5976 (gnus-summary-find-prev unread)
5977 (gnus-summary-find-next unread)))
5978 (unless (zerop (setq n (1- n)))
5979 (gnus-summary-show-thread)))
5981 (gnus-message 7 "No more%s articles"
5982 (if unread " unread" "")))
5983 (unless dont-display
5984 (gnus-summary-recenter)
5985 (gnus-summary-position-point))
5988 (defun gnus-summary-next-unread-subject (n)
5989 "Go to next N'th unread summary line."
5991 (gnus-summary-next-subject n t))
5993 (defun gnus-summary-prev-subject (n &optional unread)
5994 "Go to previous N'th summary line.
5995 If optional argument UNREAD is non-nil, only unread article is selected."
5997 (gnus-summary-next-subject (- n) unread))
5999 (defun gnus-summary-prev-unread-subject (n)
6000 "Go to previous N'th unread summary line."
6002 (gnus-summary-next-subject (- n) t))
6004 (defun gnus-summary-goto-subject (article &optional force silent)
6005 "Go the subject line of ARTICLE.
6006 If FORCE, also allow jumping to articles not currently shown."
6007 (interactive "nArticle number: ")
6009 (data (gnus-data-find article)))
6010 ;; We read in the article if we have to.
6013 (gnus-summary-insert-subject
6015 (if (or (numberp force) (vectorp force)) force)
6017 (setq data (gnus-data-find article)))
6022 (gnus-message 3 "Can't find article %d" article))
6024 (goto-char (gnus-data-pos data))
6025 (gnus-summary-position-point)
6028 ;; Walking around summary lines with displaying articles.
6030 (defun gnus-summary-expand-window (&optional arg)
6031 "Make the summary buffer take up the entire Emacs frame.
6032 Given a prefix, will force an `article' buffer configuration."
6035 (gnus-configure-windows 'article 'force)
6036 (gnus-configure-windows 'summary 'force)))
6038 (defun gnus-summary-display-article (article &optional all-header)
6039 "Display ARTICLE in article buffer."
6040 (when (gnus-buffer-live-p gnus-article-buffer)
6041 (with-current-buffer gnus-article-buffer
6042 (mm-enable-multibyte-mule4)))
6043 (gnus-set-global-variables)
6044 (when (gnus-buffer-live-p gnus-article-buffer)
6045 (with-current-buffer gnus-article-buffer
6046 (setq gnus-article-charset gnus-newsgroup-charset)
6047 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6051 (if gnus-summary-display-article-function
6052 (funcall gnus-summary-display-article-function article all-header)
6053 (gnus-article-prepare article all-header))
6054 (with-current-buffer gnus-article-buffer
6055 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6057 (gnus-run-hooks 'gnus-select-article-hook)
6058 (when (and gnus-current-article
6059 (not (zerop gnus-current-article)))
6060 (gnus-summary-goto-subject gnus-current-article))
6061 (gnus-summary-recenter)
6062 (when (and gnus-use-trees gnus-show-threads)
6063 (gnus-possibly-generate-tree article)
6064 (gnus-highlight-selected-tree article))
6065 ;; Successfully display article.
6066 (gnus-article-set-window-start
6067 (cdr (assq article gnus-newsgroup-bookmarks))))))
6069 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6070 "Select the current article.
6071 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6072 non-nil, the article will be re-fetched even if it already present in
6073 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6075 ;; Make sure we are in the summary buffer to work around bbdb bug.
6076 (unless (eq major-mode 'gnus-summary-mode)
6077 (set-buffer gnus-summary-buffer))
6078 (let ((article (or article (gnus-summary-article-number)))
6079 (all-headers (not (not all-headers))) ;Must be T or NIL.
6080 gnus-summary-display-article-function)
6082 (gnus-summary-article-pseudo-p article)
6083 (error "This is a pseudo-article"))
6085 (set-buffer gnus-summary-buffer)
6086 (if (or (and gnus-single-article-buffer
6087 (or (null gnus-current-article)
6088 (null gnus-article-current)
6089 (null (get-buffer gnus-article-buffer))
6090 (not (eq article (cdr gnus-article-current)))
6091 (not (equal (car gnus-article-current)
6092 gnus-newsgroup-name))))
6093 (and (not gnus-single-article-buffer)
6094 (or (null gnus-current-article)
6095 (not (eq gnus-current-article article))))
6097 ;; The requested article is different from the current article.
6099 (gnus-summary-display-article article all-headers)
6100 (when (or all-headers gnus-show-all-headers)
6101 (gnus-article-show-all-headers))
6102 (gnus-article-set-window-start
6103 (cdr (assq article gnus-newsgroup-bookmarks)))
6105 (when (or all-headers gnus-show-all-headers)
6106 (gnus-article-show-all-headers))
6109 (defun gnus-summary-force-verify-and-decrypt ()
6111 (let ((mm-verify-option 'known)
6112 (mm-decrypt-option 'known))
6113 (gnus-summary-select-article nil 'force)))
6115 (defun gnus-summary-set-current-mark (&optional current-mark)
6116 "Obsolete function."
6119 (defun gnus-summary-next-article (&optional unread subject backward push)
6120 "Select the next article.
6121 If UNREAD, only unread articles are selected.
6122 If SUBJECT, only articles with SUBJECT are selected.
6123 If BACKWARD, the previous article is selected instead of the next."
6126 ;; Is there such an article?
6127 ((and (gnus-summary-search-forward unread subject backward)
6128 (or (gnus-summary-display-article (gnus-summary-article-number))
6129 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6130 (gnus-summary-position-point))
6131 ;; If not, we try the first unread, if that is wanted.
6133 gnus-auto-select-same
6134 (gnus-summary-first-unread-article))
6135 (gnus-summary-position-point)
6136 (gnus-message 6 "Wrapped"))
6137 ;; Try to get next/previous article not displayed in this group.
6138 ((and gnus-auto-extend-newsgroup
6139 (not unread) (not subject))
6140 (gnus-summary-goto-article
6141 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6142 nil (count-lines (point-min) (point))))
6143 ;; Go to next/previous group.
6145 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6146 (gnus-summary-jump-to-group gnus-newsgroup-name))
6147 (let ((cmd last-command-char)
6150 (set-buffer gnus-group-buffer)
6153 (if (eq gnus-keep-same-level 'best)
6154 (gnus-summary-best-group gnus-newsgroup-name)
6155 (gnus-summary-search-group backward gnus-keep-same-level))))
6156 ;; For some reason, the group window gets selected. We change
6158 (select-window (get-buffer-window (current-buffer)))
6159 ;; Select next unread newsgroup automagically.
6161 ((or (not gnus-auto-select-next)
6163 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6164 ((or (eq gnus-auto-select-next 'quietly)
6165 (and (eq gnus-auto-select-next 'slightly-quietly)
6167 (and (eq gnus-auto-select-next 'almost-quietly)
6168 (gnus-summary-last-article-p)))
6170 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6172 (gnus-message 7 "No more%s articles (%s)..."
6173 (if unread " unread" "")
6174 (if group (concat "selecting " group)
6176 (gnus-summary-next-group nil group backward)))
6178 (when (gnus-key-press-event-p last-input-event)
6179 (gnus-summary-walk-group-buffer
6180 gnus-newsgroup-name cmd unread backward point))))))))
6182 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6183 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6184 (?\C-p (gnus-group-prev-unread-group 1))))
6185 (cursor-in-echo-area t)
6186 keve key group ended)
6188 (set-buffer gnus-group-buffer)
6191 (if (eq gnus-keep-same-level 'best)
6192 (gnus-summary-best-group gnus-newsgroup-name)
6193 (gnus-summary-search-group backward gnus-keep-same-level))))
6196 5 "No more%s articles%s" (if unread " unread" "")
6198 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6199 (format " (Type %s for %s [%s])"
6200 (single-key-description cmd) group
6201 (car (gnus-gethash group gnus-newsrc-hashtb)))
6202 (format " (Type %s to exit %s)"
6203 (single-key-description cmd)
6204 gnus-newsgroup-name)))
6205 ;; Confirm auto selection.
6206 (setq key (car (setq keve (gnus-read-event-char))))
6209 ((assq key keystrokes)
6210 (let ((obuf (current-buffer)))
6211 (switch-to-buffer gnus-group-buffer)
6213 (gnus-group-jump-to-group group))
6214 (eval (cadr (assq key keystrokes)))
6215 (setq group (gnus-group-group-name))
6216 (switch-to-buffer obuf))
6220 (gnus-ephemeral-group-p gnus-newsgroup-name))
6222 (gnus-summary-next-group nil group backward)))
6224 (push (cdr keve) unread-command-events))))))
6226 (defun gnus-summary-next-unread-article ()
6227 "Select unread article after current one."
6229 (gnus-summary-next-article
6230 (or (not (eq gnus-summary-goto-unread 'never))
6231 (gnus-summary-last-article-p (gnus-summary-article-number)))
6232 (and gnus-auto-select-same
6233 (gnus-summary-article-subject))))
6235 (defun gnus-summary-prev-article (&optional unread subject)
6236 "Select the article after the current one.
6237 If UNREAD is non-nil, only unread articles are selected."
6239 (gnus-summary-next-article unread subject t))
6241 (defun gnus-summary-prev-unread-article ()
6242 "Select unread article before current one."
6244 (gnus-summary-prev-article
6245 (or (not (eq gnus-summary-goto-unread 'never))
6246 (gnus-summary-first-article-p (gnus-summary-article-number)))
6247 (and gnus-auto-select-same
6248 (gnus-summary-article-subject))))
6250 (defun gnus-summary-next-page (&optional lines circular)
6251 "Show next page of the selected article.
6252 If at the end of the current article, select the next article.
6253 LINES says how many lines should be scrolled up.
6255 If CIRCULAR is non-nil, go to the start of the article instead of
6256 selecting the next article when reaching the end of the current
6259 (setq gnus-summary-buffer (current-buffer))
6260 (gnus-set-global-variables)
6261 (let ((article (gnus-summary-article-number))
6262 (article-window (get-buffer-window gnus-article-buffer t))
6264 ;; If the buffer is empty, we have no article.
6266 (error "No article to select"))
6267 (gnus-configure-windows 'article)
6268 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6269 (if (and (eq gnus-summary-goto-unread 'never)
6270 (not (gnus-summary-last-article-p article)))
6271 (gnus-summary-next-article)
6272 (gnus-summary-next-unread-article))
6273 (if (or (null gnus-current-article)
6274 (null gnus-article-current)
6275 (/= article (cdr gnus-article-current))
6276 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6277 ;; Selected subject is different from current article's.
6278 (gnus-summary-display-article article)
6279 (when article-window
6280 (gnus-eval-in-buffer-window gnus-article-buffer
6281 (setq endp (gnus-article-next-page lines)))
6284 (gnus-summary-beginning-of-article))
6286 (gnus-message 3 "End of message"))
6288 (if (and (eq gnus-summary-goto-unread 'never)
6289 (not (gnus-summary-last-article-p article)))
6290 (gnus-summary-next-article)
6291 (gnus-summary-next-unread-article))))))))
6292 (gnus-summary-recenter)
6293 (gnus-summary-position-point)))
6295 (defun gnus-summary-prev-page (&optional lines move)
6296 "Show previous page of selected article.
6297 Argument LINES specifies lines to be scrolled down.
6298 If MOVE, move to the previous unread article if point is at
6299 the beginning of the buffer."
6301 (let ((article (gnus-summary-article-number))
6302 (article-window (get-buffer-window gnus-article-buffer t))
6304 (gnus-configure-windows 'article)
6305 (if (or (null gnus-current-article)
6306 (null gnus-article-current)
6307 (/= article (cdr gnus-article-current))
6308 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6309 ;; Selected subject is different from current article's.
6310 (gnus-summary-display-article article)
6311 (gnus-summary-recenter)
6312 (when article-window
6313 (gnus-eval-in-buffer-window gnus-article-buffer
6314 (setq endp (gnus-article-prev-page lines)))
6315 (when (and move endp)
6317 (gnus-message 3 "Beginning of message"))
6319 (if (and (eq gnus-summary-goto-unread 'never)
6320 (not (gnus-summary-first-article-p article)))
6321 (gnus-summary-prev-article)
6322 (gnus-summary-prev-unread-article))))))))
6323 (gnus-summary-position-point))
6325 (defun gnus-summary-prev-page-or-article (&optional lines)
6326 "Show previous page of selected article.
6327 Argument LINES specifies lines to be scrolled down.
6328 If at the beginning of the article, go to the next article."
6330 (gnus-summary-prev-page lines t))
6332 (defun gnus-summary-scroll-up (lines)
6333 "Scroll up (or down) one line current article.
6334 Argument LINES specifies lines to be scrolled up (or down if negative)."
6336 (gnus-configure-windows 'article)
6337 (gnus-summary-show-thread)
6338 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6339 (gnus-eval-in-buffer-window gnus-article-buffer
6341 (when (gnus-article-next-page lines)
6342 (gnus-message 3 "End of message")))
6344 (gnus-article-prev-page (- lines))))))
6345 (gnus-summary-recenter)
6346 (gnus-summary-position-point))
6348 (defun gnus-summary-scroll-down (lines)
6349 "Scroll down (or up) one line current article.
6350 Argument LINES specifies lines to be scrolled down (or up if negative)."
6352 (gnus-summary-scroll-up (- lines)))
6354 (defun gnus-summary-next-same-subject ()
6355 "Select next article which has the same subject as current one."
6357 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6359 (defun gnus-summary-prev-same-subject ()
6360 "Select previous article which has the same subject as current one."
6362 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6364 (defun gnus-summary-next-unread-same-subject ()
6365 "Select next unread article which has the same subject as current one."
6367 (gnus-summary-next-article t (gnus-summary-article-subject)))
6369 (defun gnus-summary-prev-unread-same-subject ()
6370 "Select previous unread article which has the same subject as current one."
6372 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6374 (defun gnus-summary-first-unread-article ()
6375 "Select the first unread article.
6376 Return nil if there are no unread articles."
6379 (when (gnus-summary-first-subject t)
6380 (gnus-summary-show-thread)
6381 (gnus-summary-first-subject t)
6382 (gnus-summary-display-article (gnus-summary-article-number)))
6383 (gnus-summary-position-point)))
6385 (defun gnus-summary-first-unread-subject ()
6386 "Place the point on the subject line of the first unread article.
6387 Return nil if there are no unread articles."
6390 (when (gnus-summary-first-subject t)
6391 (gnus-summary-show-thread)
6392 (gnus-summary-first-subject t))
6393 (gnus-summary-position-point)))
6395 (defun gnus-summary-first-article ()
6396 "Select the first article.
6397 Return nil if there are no articles."
6400 (when (gnus-summary-first-subject)
6401 (gnus-summary-show-thread)
6402 (gnus-summary-first-subject)
6403 (gnus-summary-display-article (gnus-summary-article-number)))
6404 (gnus-summary-position-point)))
6406 (defun gnus-summary-best-unread-article ()
6407 "Select the unread article with the highest score."
6409 (let ((best -1000000)
6410 (data gnus-newsgroup-data)
6413 (and (gnus-data-unread-p (car data))
6415 (gnus-summary-article-score (gnus-data-number (car data))))
6418 article (gnus-data-number (car data))))
6419 (setq data (cdr data)))
6422 (gnus-summary-goto-article article)
6423 (error "No unread articles"))
6424 (gnus-summary-position-point))))
6426 (defun gnus-summary-last-subject ()
6427 "Go to the last displayed subject line in the group."
6428 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6430 (gnus-summary-goto-subject article))))
6432 (defun gnus-summary-goto-article (article &optional all-headers force)
6433 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6434 If ALL-HEADERS is non-nil, no header lines are hidden.
6435 If FORCE, go to the article even if it isn't displayed. If FORCE
6436 is a number, it is the line the article is to be displayed on."
6440 "Article number or Message-ID: "
6441 (mapcar (lambda (number) (list (int-to-string number)))
6442 gnus-newsgroup-limit))
6446 (if (and (stringp article)
6447 (string-match "@" article))
6448 (gnus-summary-refer-article article)
6449 (when (stringp article)
6450 (setq article (string-to-number article)))
6451 (if (gnus-summary-goto-subject article force)
6452 (gnus-summary-display-article article all-headers)
6453 (gnus-message 4 "Couldn't go to article %s" article) nil))
6454 (gnus-summary-position-point)))
6456 (defun gnus-summary-goto-last-article ()
6457 "Go to the previously read article."
6460 (when gnus-last-article
6461 (gnus-summary-goto-article gnus-last-article nil t))
6462 (gnus-summary-position-point)))
6464 (defun gnus-summary-pop-article (number)
6465 "Pop one article off the history and go to the previous.
6466 NUMBER articles will be popped off."
6469 (setq gnus-newsgroup-history
6470 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6472 (gnus-summary-goto-article (car to) nil t)
6473 (error "Article history empty")))
6474 (gnus-summary-position-point))
6476 ;; Summary commands and functions for limiting the summary buffer.
6478 (defun gnus-summary-limit-to-articles (n)
6479 "Limit the summary buffer to the next N articles.
6480 If not given a prefix, use the process marked articles instead."
6483 (let ((articles (gnus-summary-work-articles n)))
6484 (setq gnus-newsgroup-processable nil)
6485 (gnus-summary-limit articles))
6486 (gnus-summary-position-point)))
6488 (defun gnus-summary-pop-limit (&optional total)
6489 "Restore the previous limit.
6490 If given a prefix, remove all limits."
6493 (setq gnus-newsgroup-limits
6494 (list (mapcar (lambda (h) (mail-header-number h))
6495 gnus-newsgroup-headers))))
6496 (unless gnus-newsgroup-limits
6497 (error "No limit to pop"))
6499 (gnus-summary-limit nil 'pop)
6500 (gnus-summary-position-point)))
6502 (defun gnus-summary-limit-to-subject (subject &optional header)
6503 "Limit the summary buffer to articles that have subjects that match a regexp."
6504 (interactive "sLimit to subject (regexp): ")
6506 (setq header "subject"))
6507 (when (not (equal "" subject))
6509 (let ((articles (gnus-summary-find-matching
6510 (or header "subject") subject 'all)))
6512 (error "Found no matches for \"%s\"" subject))
6513 (gnus-summary-limit articles))
6514 (gnus-summary-position-point))))
6516 (defun gnus-summary-limit-to-author (from)
6517 "Limit the summary buffer to articles that have authors that match a regexp."
6518 (interactive "sLimit to author (regexp): ")
6519 (gnus-summary-limit-to-subject from "from"))
6521 (defun gnus-summary-limit-to-age (age &optional younger-p)
6522 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6523 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6524 articles that are younger than AGE days."
6526 (let ((younger current-prefix-arg)
6529 (while (not days-got)
6530 (setq days (if younger
6531 (read-string "Limit to articles within (in days): ")
6532 (read-string "Limit to articles older than (in days): ")))
6533 (when (> (length days) 0)
6534 (setq days (read days)))
6537 (message "Please enter a number.")
6539 (list days younger)))
6541 (let ((data gnus-newsgroup-data)
6542 (cutoff (days-to-time age))
6543 articles d date is-younger)
6544 (while (setq d (pop data))
6545 (when (and (vectorp (gnus-data-header d))
6546 (setq date (mail-header-date (gnus-data-header d))))
6547 (setq is-younger (time-less-p
6548 (time-since (condition-case ()
6555 (push (gnus-data-number d) articles))))
6556 (gnus-summary-limit (nreverse articles)))
6557 (gnus-summary-position-point)))
6559 (defun gnus-summary-limit-to-extra (header regexp)
6560 "Limit the summary buffer to articles that match an 'extra' header."
6564 (gnus-completing-read
6565 (symbol-name (car gnus-extra-headers))
6566 "Limit extra header:"
6568 (cons (symbol-name x) x))
6573 (read-string (format "Limit to header %s (regexp): " header)))))
6574 (when (not (equal "" regexp))
6576 (let ((articles (gnus-summary-find-matching
6577 (cons 'extra header) regexp 'all)))
6579 (error "Found no matches for \"%s\"" regexp))
6580 (gnus-summary-limit articles))
6581 (gnus-summary-position-point))))
6583 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6585 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6587 (defun gnus-summary-limit-to-unread (&optional all)
6588 "Limit the summary buffer to articles that are not marked as read.
6589 If ALL is non-nil, limit strictly to unread articles."
6592 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6593 (gnus-summary-limit-to-marks
6594 ;; Concat all the marks that say that an article is read and have
6596 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6597 gnus-killed-mark gnus-kill-file-mark
6598 gnus-low-score-mark gnus-expirable-mark
6599 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6600 gnus-duplicate-mark gnus-souped-mark)
6603 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6604 (make-obsolete 'gnus-summary-delete-marked-with
6605 'gnus-summary-limit-exlude-marks)
6607 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6608 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6609 If REVERSE, limit the summary buffer to articles that are marked
6610 with MARKS. MARKS can either be a string of marks or a list of marks.
6611 Returns how many articles were removed."
6612 (interactive "sMarks: ")
6613 (gnus-summary-limit-to-marks marks t))
6615 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6616 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6617 If REVERSE (the prefix), limit the summary buffer to articles that are
6618 not marked with MARKS. MARKS can either be a string of marks or a
6620 Returns how many articles were removed."
6621 (interactive "sMarks: \nP")
6623 (let ((data gnus-newsgroup-data)
6624 (marks (if (listp marks) marks
6625 (append marks nil))) ; Transform to list.
6628 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6629 (memq (gnus-data-mark (car data)) marks))
6630 (push (gnus-data-number (car data)) articles))
6631 (setq data (cdr data)))
6632 (gnus-summary-limit articles))
6633 (gnus-summary-position-point)))
6635 (defun gnus-summary-limit-to-score (&optional score)
6636 "Limit to articles with score at or above SCORE."
6638 (setq score (if score
6639 (prefix-numeric-value score)
6640 (or gnus-summary-default-score 0)))
6641 (let ((data gnus-newsgroup-data)
6644 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6646 (push (gnus-data-number (car data)) articles))
6647 (setq data (cdr data)))
6649 (gnus-summary-limit articles)
6650 (gnus-summary-position-point))))
6652 (defun gnus-summary-limit-include-thread (id)
6653 "Display all the hidden articles that in the current thread."
6654 (interactive (list (mail-header-id (gnus-summary-article-header))))
6655 (let ((articles (gnus-articles-in-thread
6656 (gnus-id-to-thread (gnus-root-id id)))))
6658 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6659 (gnus-summary-position-point))))
6661 (defun gnus-summary-limit-include-dormant ()
6662 "Display all the hidden articles that are marked as dormant.
6663 Note that this command only works on a subset of the articles currently
6664 fetched for this group."
6666 (unless gnus-newsgroup-dormant
6667 (error "There are no dormant articles in this group"))
6669 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6670 (gnus-summary-position-point)))
6672 (defun gnus-summary-limit-exclude-dormant ()
6673 "Hide all dormant articles."
6676 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6677 (gnus-summary-position-point)))
6679 (defun gnus-summary-limit-exclude-childless-dormant ()
6680 "Hide all dormant articles that have no children."
6682 (let ((data (gnus-data-list t))
6683 articles d children)
6684 ;; Find all articles that are either not dormant or have
6686 (while (setq d (pop data))
6687 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6689 (gnus-article-children (gnus-data-number d)))
6692 (when (memq (car children) articles)
6697 (push (gnus-data-number d) articles)))
6700 (gnus-summary-limit articles)
6701 (gnus-summary-position-point))))
6703 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6704 "Mark all unread excluded articles as read.
6705 If ALL, mark even excluded ticked and dormants as read."
6707 (let ((articles (gnus-sorted-complement
6709 (mapcar (lambda (h) (mail-header-number h))
6710 gnus-newsgroup-headers)
6712 (sort gnus-newsgroup-limit '<)))
6714 (setq gnus-newsgroup-unreads
6715 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6717 (setq gnus-newsgroup-dormant nil
6718 gnus-newsgroup-marked nil
6719 gnus-newsgroup-reads
6721 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6722 gnus-newsgroup-reads))
6723 (while (setq article (pop articles))
6724 (unless (or (memq article gnus-newsgroup-dormant)
6725 (memq article gnus-newsgroup-marked))
6726 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6728 (defun gnus-summary-limit (articles &optional pop)
6730 ;; We pop the previous limit off the stack and use that.
6731 (setq articles (car gnus-newsgroup-limits)
6732 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6733 ;; We use the new limit, so we push the old limit on the stack.
6734 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6736 (setq gnus-newsgroup-limit articles)
6737 (let ((total (length gnus-newsgroup-data))
6738 (data (gnus-data-find-list (gnus-summary-article-number)))
6739 (gnus-summary-mark-below nil) ; Inhibit this.
6741 ;; This will do all the work of generating the new summary buffer
6742 ;; according to the new limit.
6743 (gnus-summary-prepare)
6744 ;; Hide any threads, possibly.
6745 (and gnus-show-threads
6746 gnus-thread-hide-subtree
6747 (gnus-summary-hide-all-threads))
6748 ;; Try to return to the article you were at, or one in the
6751 ;; We try to find some article after the current one.
6753 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6756 (setq data (cdr data))))
6758 ;; If there is no data, that means that we were after the last
6759 ;; article. The same goes when we can't find any articles
6760 ;; after the current one.
6761 (goto-char (point-max))
6762 (gnus-summary-find-prev))
6763 (gnus-set-mode-line 'summary)
6764 ;; We return how many articles were removed from the summary
6765 ;; buffer as a result of the new limit.
6766 (- total (length gnus-newsgroup-data))))
6768 (defsubst gnus-invisible-cut-children (threads)
6771 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6776 (defsubst gnus-cut-thread (thread)
6777 "Go forwards in the thread until we find an article that we want to display."
6778 (when (or (eq gnus-fetch-old-headers 'some)
6779 (eq gnus-fetch-old-headers 'invisible)
6780 (numberp gnus-fetch-old-headers)
6781 (eq gnus-build-sparse-threads 'some)
6782 (eq gnus-build-sparse-threads 'more))
6783 ;; Deal with old-fetched headers and sparse threads.
6787 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6788 (gnus-summary-article-ancient-p
6789 (mail-header-number (car thread))))
6790 (if (or (<= (length (cdr thread)) 1)
6791 (eq gnus-fetch-old-headers 'invisible))
6792 (setq gnus-newsgroup-limit
6793 (delq (mail-header-number (car thread))
6794 gnus-newsgroup-limit)
6795 thread (cadr thread))
6796 (when (gnus-invisible-cut-children (cdr thread))
6797 (let ((th (cdr thread)))
6799 (if (memq (mail-header-number (caar th))
6800 gnus-newsgroup-limit)
6801 (setq thread (car th)
6803 (setq th (cdr th))))))))))
6806 (defun gnus-cut-threads (threads)
6807 "Cut off all uninteresting articles from the beginning of threads."
6808 (when (or (eq gnus-fetch-old-headers 'some)
6809 (eq gnus-fetch-old-headers 'invisible)
6810 (numberp gnus-fetch-old-headers)
6811 (eq gnus-build-sparse-threads 'some)
6812 (eq gnus-build-sparse-threads 'more))
6815 (setcar th (gnus-cut-thread (car th)))
6816 (setq th (cdr th)))))
6817 ;; Remove nixed out threads.
6820 (defun gnus-summary-initial-limit (&optional show-if-empty)
6821 "Figure out what the initial limit is supposed to be on group entry.
6822 This entails weeding out unwanted dormants, low-scored articles,
6823 fetch-old-headers verbiage, and so on."
6824 ;; Most groups have nothing to remove.
6825 (if (or gnus-inhibit-limiting
6826 (and (null gnus-newsgroup-dormant)
6827 (not (eq gnus-fetch-old-headers 'some))
6828 (not (numberp gnus-fetch-old-headers))
6829 (not (eq gnus-fetch-old-headers 'invisible))
6830 (null gnus-summary-expunge-below)
6831 (not (eq gnus-build-sparse-threads 'some))
6832 (not (eq gnus-build-sparse-threads 'more))
6833 (null gnus-thread-expunge-below)
6834 (not gnus-use-nocem)))
6836 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6837 (setq gnus-newsgroup-limit nil)
6840 (unless (car (symbol-value node))
6841 ;; These threads have no parents -- they are roots.
6842 (let ((nodes (cdr (symbol-value node)))
6845 (if (and gnus-thread-expunge-below
6846 (< (gnus-thread-total-score (car nodes))
6847 gnus-thread-expunge-below))
6848 (gnus-expunge-thread (pop nodes))
6849 (setq thread (pop nodes))
6850 (gnus-summary-limit-children thread))))))
6851 gnus-newsgroup-dependencies)
6852 ;; If this limitation resulted in an empty group, we might
6853 ;; pop the previous limit and use it instead.
6854 (when (and (not gnus-newsgroup-limit)
6856 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6857 gnus-newsgroup-limit))
6859 (defun gnus-summary-limit-children (thread)
6860 "Return 1 if this subthread is visible and 0 if it is not."
6861 ;; First we get the number of visible children to this thread. This
6862 ;; is done by recursing down the thread using this function, so this
6863 ;; will really go down to a leaf article first, before slowly
6864 ;; working its way up towards the root.
6868 (apply '+ (mapcar 'gnus-summary-limit-children
6871 (number (mail-header-number (car thread)))
6874 (not (memq number gnus-newsgroup-marked))
6876 ;; If this article is dormant and has absolutely no visible
6877 ;; children, then this article isn't visible.
6878 (and (memq number gnus-newsgroup-dormant)
6880 ;; If this is "fetch-old-headered" and there is no
6881 ;; visible children, then we don't want this article.
6882 (and (or (eq gnus-fetch-old-headers 'some)
6883 (numberp gnus-fetch-old-headers))
6884 (gnus-summary-article-ancient-p number)
6886 ;; If this is "fetch-old-headered" and `invisible', then
6887 ;; we don't want this article.
6888 (and (eq gnus-fetch-old-headers 'invisible)
6889 (gnus-summary-article-ancient-p number))
6890 ;; If this is a sparsely inserted article with no children,
6891 ;; we don't want it.
6892 (and (eq gnus-build-sparse-threads 'some)
6893 (gnus-summary-article-sparse-p number)
6895 ;; If we use expunging, and this article is really
6896 ;; low-scored, then we don't want this article.
6897 (when (and gnus-summary-expunge-below
6899 (or (cdr (assq number gnus-newsgroup-scored))
6900 gnus-summary-default-score))
6901 gnus-summary-expunge-below))
6902 ;; We increase the expunge-tally here, but that has
6903 ;; nothing to do with the limits, really.
6904 (incf gnus-newsgroup-expunged-tally)
6905 ;; We also mark as read here, if that's wanted.
6906 (when (and gnus-summary-mark-below
6907 (< score gnus-summary-mark-below))
6908 (setq gnus-newsgroup-unreads
6909 (delq number gnus-newsgroup-unreads))
6910 (if gnus-newsgroup-auto-expire
6911 (push number gnus-newsgroup-expirable)
6912 (push (cons number gnus-low-score-mark)
6913 gnus-newsgroup-reads)))
6915 ;; Check NoCeM things.
6916 (if (and gnus-use-nocem
6917 (gnus-nocem-unwanted-article-p
6918 (mail-header-id (car thread))))
6920 (setq gnus-newsgroup-unreads
6921 (delq number gnus-newsgroup-unreads))
6923 ;; Nope, invisible article.
6925 ;; Ok, this article is to be visible, so we add it to the limit
6927 (push number gnus-newsgroup-limit)
6930 (defun gnus-expunge-thread (thread)
6931 "Mark all articles in THREAD as read."
6932 (let* ((number (mail-header-number (car thread))))
6933 (incf gnus-newsgroup-expunged-tally)
6934 ;; We also mark as read here, if that's wanted.
6935 (setq gnus-newsgroup-unreads
6936 (delq number gnus-newsgroup-unreads))
6937 (if gnus-newsgroup-auto-expire
6938 (push number gnus-newsgroup-expirable)
6939 (push (cons number gnus-low-score-mark)
6940 gnus-newsgroup-reads)))
6941 ;; Go recursively through all subthreads.
6942 (mapcar 'gnus-expunge-thread (cdr thread)))
6944 ;; Summary article oriented commands
6946 (defun gnus-summary-refer-parent-article (n)
6947 "Refer parent article N times.
6948 If N is negative, go to ancestor -N instead.
6949 The difference between N and the number of articles fetched is returned."
6953 (when (not (natnump n))
6958 (setq header (gnus-summary-article-header))
6959 (if (and (eq (mail-header-number header)
6960 (cdr gnus-article-current))
6961 (equal gnus-newsgroup-name
6962 (car gnus-article-current)))
6963 ;; If we try to find the parent of the currently
6964 ;; displayed article, then we take a look at the actual
6965 ;; References header, since this is slightly more
6966 ;; reliable than the References field we got from the
6969 (set-buffer gnus-original-article-buffer)
6970 (nnheader-narrow-to-headers)
6971 (unless (setq ref (message-fetch-field "references"))
6972 (setq ref (message-fetch-field "in-reply-to")))
6975 ;; It's not the current article, so we take a bet on
6976 ;; the value we got from the server.
6977 (mail-header-references header)))
6979 (not (equal ref "")))
6980 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6981 (gnus-message 1 "Couldn't find parent"))
6982 (gnus-message 1 "No references in article %d"
6983 (gnus-summary-article-number))
6986 (gnus-summary-position-point)
6989 (defun gnus-summary-refer-references ()
6990 "Fetch all articles mentioned in the References header.
6991 Return the number of articles fetched."
6993 (let ((ref (mail-header-references (gnus-summary-article-header)))
6994 (current (gnus-summary-article-number))
6998 (error "No References in the current article")
6999 ;; For each Message-ID in the References header...
7000 (while (string-match "<[^>]*>" ref)
7002 ;; ... fetch that article.
7003 (gnus-summary-refer-article
7004 (prog1 (match-string 0 ref)
7005 (setq ref (substring ref (match-end 0))))))
7006 (gnus-summary-goto-subject current)
7007 (gnus-summary-position-point)
7010 (defun gnus-summary-refer-thread (&optional limit)
7011 "Fetch all articles in the current thread.
7012 If LIMIT (the numerical prefix), fetch that many old headers instead
7013 of what's specified by the `gnus-refer-thread-limit' variable."
7015 (let ((id (mail-header-id (gnus-summary-article-header)))
7016 (limit (if limit (prefix-numeric-value limit)
7017 gnus-refer-thread-limit)))
7018 ;; We want to fetch LIMIT *old* headers, but we also have to
7019 ;; re-fetch all the headers in the current buffer, because many of
7020 ;; them may be undisplayed. So we adjust LIMIT.
7021 (when (numberp limit)
7022 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7023 (unless (eq gnus-fetch-old-headers 'invisible)
7024 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7025 ;; Retrieve the headers and read them in.
7026 (if (eq (gnus-retrieve-headers
7027 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7029 (gnus-build-all-threads)
7030 (error "Can't fetch thread from backends that don't support NOV"))
7031 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7032 (gnus-summary-limit-include-thread id)))
7034 (defun gnus-summary-refer-article (message-id)
7035 "Fetch an article specified by MESSAGE-ID."
7036 (interactive "sMessage-ID: ")
7037 (when (and (stringp message-id)
7038 (not (zerop (length message-id))))
7039 ;; Construct the correct Message-ID if necessary.
7040 ;; Suggested by tale@pawl.rpi.edu.
7041 (unless (string-match "^<" message-id)
7042 (setq message-id (concat "<" message-id)))
7043 (unless (string-match ">$" message-id)
7044 (setq message-id (concat message-id ">")))
7045 (let* ((header (gnus-id-to-header message-id))
7047 (gnus-summary-article-sparse-p
7048 (mail-header-number header))
7049 (memq (mail-header-number header)
7050 gnus-newsgroup-limit)))
7053 ;; If the article is present in the buffer we just go to it.
7055 (or (not (gnus-summary-article-sparse-p
7056 (mail-header-number header)))
7059 (gnus-summary-goto-article
7060 (mail-header-number header) nil t)
7062 (gnus-summary-update-article (mail-header-number header)))))
7064 ;; We fetch the article.
7066 (dolist (gnus-override-method (gnus-refer-article-methods))
7067 (gnus-check-server gnus-override-method)
7068 ;; Fetch the header, and display the article.
7069 (when (setq number (gnus-summary-insert-subject message-id))
7070 (gnus-summary-select-article nil nil nil number)
7072 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7074 (defun gnus-refer-article-methods ()
7075 "Return a list of referrable methods."
7077 ;; No method, so we default to current and native.
7078 ((null gnus-refer-article-method)
7079 (list gnus-current-select-method gnus-select-method))
7081 ((eq 'current gnus-refer-article-method)
7082 (list gnus-current-select-method))
7083 ;; List of select methods.
7084 ((not (and (symbolp (car gnus-refer-article-method))
7085 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7087 (dolist (method gnus-refer-article-method)
7088 (push (if (eq 'current method)
7089 gnus-current-select-method
7093 ;; One single select method.
7095 (list gnus-refer-article-method))))
7097 (defun gnus-summary-edit-parameters ()
7098 "Edit the group parameters of the current group."
7100 (gnus-group-edit-group gnus-newsgroup-name 'params))
7102 (defun gnus-summary-customize-parameters ()
7103 "Customize the group parameters of the current group."
7105 (gnus-group-customize gnus-newsgroup-name))
7107 (defun gnus-summary-enter-digest-group (&optional force)
7108 "Enter an nndoc group based on the current article.
7109 If FORCE, force a digest interpretation. If not, try
7110 to guess what the document format is."
7112 (let ((conf gnus-current-window-configuration))
7114 (gnus-summary-select-article))
7115 (setq gnus-current-window-configuration conf)
7116 (let* ((name (format "%s-%d"
7117 (gnus-group-prefixed-name
7118 gnus-newsgroup-name (list 'nndoc ""))
7120 (set-buffer gnus-summary-buffer)
7121 gnus-current-article)))
7122 (ogroup gnus-newsgroup-name)
7123 (params (append (gnus-info-params (gnus-get-info ogroup))
7124 (list (cons 'to-group ogroup))
7125 (list (cons 'save-article-group ogroup))))
7126 (case-fold-search t)
7127 (buf (current-buffer))
7130 (set-buffer gnus-original-article-buffer)
7131 ;; Have the digest group inherit the main mail address of
7132 ;; the parent article.
7133 (when (setq to-address (or (message-fetch-field "reply-to")
7134 (message-fetch-field "from")))
7135 (setq params (append
7136 (list (cons 'to-address
7137 (funcall gnus-decode-encoded-word-function
7139 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7140 (insert-buffer-substring gnus-original-article-buffer)
7141 ;; Remove lines that may lead nndoc to misinterpret the
7144 (goto-char (point-min))
7145 (or (search-forward "\n\n" nil t) (point)))
7146 (goto-char (point-min))
7147 (delete-matching-lines "^Path:\\|^From ")
7150 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7151 (gnus-newsgroup-ephemeral-ignored-charsets
7152 gnus-newsgroup-ignored-charsets))
7153 (gnus-group-read-ephemeral-group
7154 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7156 ,(if force 'mbox 'guess))) t))
7157 ;; Make all postings to this group go to the parent group.
7158 (nconc (gnus-info-params (gnus-get-info name))
7160 ;; Couldn't select this doc group.
7161 (switch-to-buffer buf)
7162 (gnus-set-global-variables)
7163 (gnus-configure-windows 'summary)
7164 (gnus-message 3 "Article couldn't be entered?"))
7165 (kill-buffer dig)))))
7167 (defun gnus-summary-read-document (n)
7168 "Open a new group based on the current article(s).
7169 This will allow you to read digests and other similar
7170 documents as newsgroups.
7171 Obeys the standard process/prefix convention."
7173 (let* ((articles (gnus-summary-work-articles n))
7174 (ogroup gnus-newsgroup-name)
7175 (params (append (gnus-info-params (gnus-get-info ogroup))
7176 (list (cons 'to-group ogroup))))
7177 article group egroup groups vgroup)
7178 (while (setq article (pop articles))
7179 (setq group (format "%s-%d" gnus-newsgroup-name article))
7180 (gnus-summary-remove-process-mark article)
7181 (when (gnus-summary-display-article article)
7184 (insert-buffer-substring gnus-original-article-buffer)
7185 ;; Remove some headers that may lead nndoc to make
7187 (message-narrow-to-head)
7188 (goto-char (point-min))
7189 (delete-matching-lines "^\\(Path\\):\\|^From ")
7192 (gnus-group-read-ephemeral-group
7193 group `(nndoc ,group (nndoc-address ,(current-buffer))
7194 (nndoc-article-type guess))
7197 ;; Make all postings to this group go to the parent group.
7198 (nconc (gnus-info-params (gnus-get-info egroup))
7200 (push egroup groups))
7201 ;; Couldn't select this doc group.
7202 (gnus-error 3 "Article couldn't be entered"))))))
7203 ;; Now we have selected all the documents.
7206 (error "None of the articles could be interpreted as documents"))
7207 ((gnus-group-read-ephemeral-group
7208 (setq vgroup (format
7209 "nnvirtual:%s-%s" gnus-newsgroup-name
7210 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7211 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7213 (cons (current-buffer) 'summary)))
7215 (error "Couldn't select virtual nndoc group")))))
7217 (defun gnus-summary-isearch-article (&optional regexp-p)
7218 "Do incremental search forward on the current article.
7219 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7221 (let* ((gnus-inhibit-treatment t)
7222 (old (gnus-summary-select-article)))
7223 (gnus-configure-windows 'article)
7224 (gnus-eval-in-buffer-window gnus-article-buffer
7228 (gnus-article-show-all-headers))
7229 (goto-char (point-min))
7230 (isearch-forward regexp-p)))))
7232 (defun gnus-summary-search-article-forward (regexp &optional backward)
7233 "Search for an article containing REGEXP forward.
7234 If BACKWARD, search backward instead."
7237 (format "Search article %s (regexp%s): "
7238 (if current-prefix-arg "backward" "forward")
7239 (if gnus-last-search-regexp
7240 (concat ", default " gnus-last-search-regexp)
7242 current-prefix-arg))
7243 (if (string-equal regexp "")
7244 (setq regexp (or gnus-last-search-regexp ""))
7245 (setq gnus-last-search-regexp regexp)
7246 (setq gnus-article-before-search gnus-current-article))
7247 ;; Intentionally set gnus-last-article.
7248 (setq gnus-last-article gnus-article-before-search)
7249 (let ((gnus-last-article gnus-last-article))
7250 (if (gnus-summary-search-article regexp backward)
7251 (gnus-summary-show-thread)
7252 (error "Search failed: \"%s\"" regexp))))
7254 (defun gnus-summary-search-article-backward (regexp)
7255 "Search for an article containing REGEXP backward."
7258 (format "Search article backward (regexp%s): "
7259 (if gnus-last-search-regexp
7260 (concat ", default " gnus-last-search-regexp)
7262 (gnus-summary-search-article-forward regexp 'backward))
7265 (defmacro gnus-summary-search-article-position-point (regexp backward)
7266 "Dehighlight the last matched text and goto the beginning position."
7267 (` (if (and gnus-summary-search-article-matched-data
7268 (let ((text (caddr gnus-summary-search-article-matched-data))
7269 (inhibit-read-only t)
7272 (goto-char (car gnus-summary-search-article-matched-data))
7273 (cadr gnus-summary-search-article-matched-data))
7275 (string-match (, regexp) text)))
7276 (if (, backward) (beginning-of-line) (end-of-line))
7277 (goto-char (if (, backward) (point-max) (point-min))))))
7279 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7280 "Place point where X-Face image is displayed."
7281 (if (featurep 'xemacs)
7282 (` (let ((end (if (search-forward "\n\n" nil t)
7283 (goto-char (1- (point)))
7286 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7287 (unless (and (re-search-forward "^From:" end t)
7288 (setq extent (extent-at (point)))
7289 (extent-begin-glyph extent))
7290 (goto-char (, opoint)))))
7291 (` (let ((end (if (search-forward "\n\n" nil t)
7292 (goto-char (1- (point)))
7294 (start (or (search-backward "\n\n" nil t) (point-min))))
7296 (or (text-property-any start end 'x-face-image t);; x-face-e21
7297 (text-property-any start end 'x-face-mule-bitmap-image t)
7300 (defmacro gnus-summary-search-article-highlight-matched-text
7301 (backward treated x-face)
7302 "Highlight matched text in the function `gnus-summary-search-article'."
7303 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7304 (end (set-marker (make-marker) (match-end 0)))
7305 (inhibit-read-only t)
7309 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7311 (lambda (item) (setq items (delq item items)))
7312 '(gnus-treat-buttonize
7313 gnus-treat-fill-article
7314 gnus-treat-fill-long-lines
7315 gnus-treat-emphasize
7316 gnus-treat-highlight-headers
7317 gnus-treat-highlight-citation
7318 gnus-treat-highlight-signature
7319 gnus-treat-overstrike
7320 gnus-treat-display-xface
7321 gnus-treat-buttonize-head
7322 gnus-treat-decode-article-as-default-mime-charset))
7323 (static-if (featurep 'xemacs)
7325 (cons '(x-face-mule-delete-x-face-field
7328 (gnus-treat-display-xface
7329 (when (, x-face) gnus-treat-display-xface)))
7330 (gnus-article-prepare-mime-display)))
7331 (goto-char (if (, backward) start end))
7333 (gnus-summary-search-article-highlight-goto-x-face (point)))
7334 (setq gnus-summary-search-article-matched-data
7335 (list start end (buffer-substring start end)))
7336 (unless (eq start end);; matched text has been deleted. :-<
7337 (put-text-property start end 'face
7338 (or (find-face 'isearch)
7339 'secondary-selection))))))
7342 (defun gnus-summary-search-article (regexp &optional backward)
7343 "Search for an article containing REGEXP.
7344 Optional argument BACKWARD means do search for backward.
7345 `gnus-select-article-hook' is not called during the search."
7346 ;; We have to require this here to make sure that the following
7347 ;; dynamic binding isn't shadowed by autoloading.
7348 (require 'gnus-async)
7350 (let ((gnus-select-article-hook nil) ;Disable hook.
7351 (gnus-article-display-hook nil)
7352 (gnus-article-prepare-hook nil)
7353 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7354 (gnus-use-article-prefetch nil)
7355 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7356 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7357 (sum (current-buffer))
7360 (gnus-save-hidden-threads
7361 (static-if (featurep 'xemacs)
7362 (let ((gnus-inhibit-treatment t))
7363 (setq treated (eq 'old (gnus-summary-select-article)))
7365 (not (and (gnus-buffer-live-p gnus-article-buffer)
7366 (window-live-p (get-buffer-window
7367 gnus-article-buffer t)))))
7368 (gnus-summary-select-article nil t)
7369 (setq treated nil)))
7370 (let ((gnus-inhibit-treatment t)
7371 (x-face-mule-delete-x-face-field 'never))
7372 (setq treated (eq 'old (gnus-summary-select-article)))
7375 (and (gnus-buffer-live-p gnus-article-buffer)
7376 (window-live-p (get-buffer-window
7377 gnus-article-buffer t))
7378 (or (not (string-match "^\\^X-Face:" regexp))
7379 (with-current-buffer gnus-article-buffer
7380 gnus-summary-search-article-matched-data)))))
7381 (gnus-summary-select-article nil t)
7382 (setq treated nil))))
7383 (set-buffer gnus-article-buffer)
7387 (gnus-article-show-all-headers)
7388 (gnus-summary-search-article-position-point regexp backward))
7389 (goto-char (if backward (point-max) (point-min))))
7391 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7393 (re-search-backward regexp nil t)
7394 (re-search-forward regexp nil t))
7395 ;; We found the regexp.
7397 (gnus-summary-search-article-highlight-matched-text
7398 backward treated (string-match "^\\^X-Face:" regexp))
7401 (/ (- 2 (window-height
7402 (get-buffer-window gnus-article-buffer t)))
7405 (get-buffer-window (current-buffer))
7408 (setq point (point)))
7409 ;; We didn't find it, so we go to the next article.
7412 (while (eq found 'not)
7413 (if (not (if backward (gnus-summary-find-prev)
7414 (gnus-summary-find-next)))
7415 ;; No more articles.
7417 ;; Select the next article and adjust point.
7418 (unless (gnus-summary-article-sparse-p
7419 (gnus-summary-article-number))
7421 (let ((gnus-inhibit-treatment t))
7422 (gnus-summary-select-article))
7424 (set-buffer gnus-article-buffer)
7426 (goto-char (if backward (point-max) (point-min))))))))
7427 (gnus-message 7 ""))
7428 ;; Return whether we found the regexp.
7429 (when (eq found 'found)
7431 (gnus-summary-show-thread)
7432 (gnus-summary-goto-subject gnus-current-article)
7433 (gnus-summary-position-point)
7436 (defun gnus-summary-find-matching (header regexp &optional backward unread
7438 "Return a list of all articles that match REGEXP on HEADER.
7439 The search stars on the current article and goes forwards unless
7440 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7441 If UNREAD is non-nil, only unread articles will
7442 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7443 in the comparisons."
7444 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7445 (gnus-data-find-list
7446 (gnus-summary-article-number) (gnus-data-list backward))))
7447 (case-fold-search (not not-case-fold))
7450 (if (eq (car header) 'extra)
7453 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7455 (error "%s is an invalid header" header))
7456 (unless (fboundp (intern (concat "mail-header-" header)))
7457 (error "%s is not a valid header" header))
7458 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7461 (and (or (not unread) ; We want all articles...
7462 (gnus-data-unread-p d)) ; Or just unreads.
7463 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7464 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7465 (push (gnus-data-number d) articles)) ; Success!
7466 (setq data (cdr data)))
7467 (nreverse articles)))
7469 (defun gnus-summary-execute-command (header regexp command &optional backward)
7470 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7471 If HEADER is an empty string (or nil), the match is done on the entire
7472 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7474 (list (let ((completion-ignore-case t))
7477 (mapcar (lambda (string) (list string))
7478 '("Number" "Subject" "From" "Lines" "Date"
7479 "Message-ID" "Xref" "References" "Body"))
7480 nil 'require-match))
7481 (read-string "Regexp: ")
7482 (read-key-sequence "Command: ")
7483 current-prefix-arg))
7484 (when (equal header "Body")
7486 ;; Hidden thread subtrees must be searched as well.
7487 (gnus-summary-show-all-threads)
7488 ;; We don't want to change current point nor window configuration.
7490 (save-window-excursion
7491 (gnus-message 6 "Executing %s..." (key-description command))
7492 ;; We'd like to execute COMMAND interactively so as to give arguments.
7493 (gnus-execute header regexp
7494 `(call-interactively ',(key-binding command))
7496 (gnus-message 6 "Executing %s...done" (key-description command)))))
7498 (defun gnus-summary-beginning-of-article ()
7499 "Scroll the article back to the beginning."
7501 (gnus-summary-select-article)
7502 (gnus-configure-windows 'article)
7503 (gnus-eval-in-buffer-window gnus-article-buffer
7505 (goto-char (point-min))
7506 (when gnus-page-broken
7507 (gnus-narrow-to-page))))
7509 (defun gnus-summary-end-of-article ()
7510 "Scroll to the end of the article."
7512 (gnus-summary-select-article)
7513 (gnus-configure-windows 'article)
7514 (gnus-eval-in-buffer-window gnus-article-buffer
7516 (goto-char (point-max))
7518 (when gnus-page-broken
7519 (gnus-narrow-to-page))))
7521 (defun gnus-summary-print-article (&optional filename n)
7522 "Generate and print a PostScript image of the N next (mail) articles.
7524 If N is negative, print the N previous articles. If N is nil and articles
7525 have been marked with the process mark, print these instead.
7527 If the optional first argument FILENAME is nil, send the image to the
7528 printer. If FILENAME is a string, save the PostScript image in a file with
7529 that name. If FILENAME is a number, prompt the user for the name of the file
7531 (interactive (list (ps-print-preprint current-prefix-arg)
7532 current-prefix-arg))
7533 (dolist (article (gnus-summary-work-articles n))
7534 (gnus-summary-select-article nil nil 'pseudo article)
7535 (gnus-eval-in-buffer-window gnus-article-buffer
7536 (let ((buffer (generate-new-buffer " *print*")))
7539 (copy-to-buffer buffer (point-min) (point-max))
7541 (gnus-article-delete-invisible-text)
7542 (let ((ps-left-header
7545 (mail-header-subject gnus-current-headers) ")")
7547 (mail-header-from gnus-current-headers) ")")))
7550 "/pagenumberstring load"
7552 (mail-header-date gnus-current-headers) ")"))))
7553 (gnus-run-hooks 'gnus-ps-print-hook)
7555 (ps-print-buffer-with-faces filename))))
7556 (kill-buffer buffer))))))
7558 (defun gnus-summary-show-article (&optional arg)
7559 "Force re-fetching of the current article.
7560 If ARG (the prefix) is a number, show the article with the charset
7561 defined in `gnus-summary-show-article-charset-alist', or the charset
7563 If ARG (the prefix) is non-nil and not a number, show the raw article
7564 without any article massaging functions being run."
7568 (let ((gnus-newsgroup-charset
7569 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7570 (read-coding-system "Charset: ")))
7571 (gnus-newsgroup-ignored-charsets 'gnus-all))
7572 (gnus-summary-select-article nil 'force)
7573 (let ((deps gnus-newsgroup-dependencies)
7576 (set-buffer gnus-original-article-buffer)
7578 (message-narrow-to-head)
7579 (setq head (buffer-string)))
7581 (insert (format "211 %d Article retrieved.\n"
7582 (cdr gnus-article-current)))
7585 (let ((nntp-server-buffer (current-buffer)))
7586 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7587 (gnus-data-set-header
7588 (gnus-data-find (cdr gnus-article-current))
7590 (gnus-summary-update-article-line
7591 (cdr gnus-article-current) header))))
7593 ;; Select the article the normal way.
7594 (gnus-summary-select-article nil 'force))
7596 ;; We have to require this here to make sure that the following
7597 ;; dynamic binding isn't shadowed by autoloading.
7598 (require 'gnus-async)
7600 ;; Bind the article treatment functions to nil.
7601 (let ((gnus-have-all-headers t)
7602 gnus-article-display-hook
7603 gnus-article-prepare-hook
7604 gnus-article-decode-hook
7607 (gnus-summary-select-article nil 'force))))
7608 (gnus-summary-goto-subject gnus-current-article)
7609 (gnus-summary-position-point))
7611 (defun gnus-summary-verbose-headers (&optional arg)
7612 "Toggle permanent full header display.
7613 If ARG is a positive number, turn header display on.
7614 If ARG is a negative number, turn header display off."
7616 (setq gnus-show-all-headers
7617 (cond ((or (not (numberp arg))
7619 (not gnus-show-all-headers))
7622 (gnus-summary-show-article))
7624 (defun gnus-summary-toggle-header (&optional arg)
7625 "Show the headers if they are hidden, or hide them if they are shown.
7626 If ARG is a positive number, show the entire header.
7627 If ARG is a negative number, hide the unwanted header lines."
7630 (set-buffer gnus-article-buffer)
7632 (let* ((buffer-read-only nil)
7633 (inhibit-point-motion-hooks t)
7639 (article-narrow-to-head)
7640 (gnus-article-hidden-text-p 'headers))))
7641 (goto-char (point-min))
7642 (when (search-forward "\n\n" nil t)
7643 (delete-region (point-min) (1- (point))))
7644 (goto-char (point-min))
7646 (set-buffer gnus-original-article-buffer)
7647 (goto-char (point-min))
7648 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7649 (insert-buffer-substring gnus-original-article-buffer 1 e)
7651 (narrow-to-region (point-min) (point))
7652 (article-decode-encoded-words)
7654 (let ((gnus-treat-hide-headers nil)
7655 (gnus-treat-hide-boring-headers nil))
7656 (setq gnus-article-wash-types
7657 (delq 'headers gnus-article-wash-types))
7658 (gnus-treat-article 'head))
7659 (gnus-treat-article 'head)))
7660 (gnus-set-mode-line 'article)))))
7662 (defun gnus-summary-show-all-headers ()
7663 "Make all header lines visible."
7665 (gnus-article-show-all-headers))
7667 (defun gnus-summary-toggle-mime (&optional arg)
7668 "Toggle MIME processing.
7669 If ARG is a positive number, turn MIME processing on."
7671 (setq gnus-show-mime
7673 (not gnus-show-mime)
7674 (> (prefix-numeric-value arg) 0)))
7675 (gnus-summary-select-article t 'force))
7677 (defun gnus-summary-caesar-message (&optional arg)
7678 "Caesar rotate the current article by 13.
7679 The numerical prefix specifies how many places to rotate each letter
7682 (gnus-summary-select-article)
7683 (let ((mail-header-separator ""))
7684 (gnus-eval-in-buffer-window gnus-article-buffer
7687 (let ((start (window-start))
7689 (message-caesar-buffer-body arg)
7690 (set-window-start (get-buffer-window (current-buffer)) start))))))
7692 (defun gnus-summary-stop-page-breaking ()
7693 "Stop page breaking in the current article."
7695 (gnus-summary-select-article)
7696 (gnus-eval-in-buffer-window gnus-article-buffer
7698 (when (gnus-visual-p 'page-marker)
7699 (let ((buffer-read-only nil))
7700 (gnus-remove-text-with-property 'gnus-prev)
7701 (gnus-remove-text-with-property 'gnus-next))
7702 (setq gnus-page-broken nil))))
7704 (defun gnus-summary-move-article (&optional n to-newsgroup
7705 select-method action)
7706 "Move the current article to a different newsgroup.
7707 If N is a positive number, move the N next articles.
7708 If N is a negative number, move the N previous articles.
7709 If N is nil and any articles have been marked with the process mark,
7710 move those articles instead.
7711 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7712 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7713 re-spool using this method.
7715 For this function to work, both the current newsgroup and the
7716 newsgroup that you want to move to have to support the `request-move'
7717 and `request-accept' functions.
7719 ACTION can be either `move' (the default), `crosspost' or `copy'."
7722 (setq action 'move))
7723 ;; Disable marking as read.
7724 (let (gnus-mark-article-hook)
7725 (save-window-excursion
7726 (gnus-summary-select-article)))
7727 ;; Check whether the source group supports the required functions.
7728 (cond ((and (eq action 'move)
7729 (not (gnus-check-backend-function
7730 'request-move-article gnus-newsgroup-name)))
7731 (error "The current group does not support article moving"))
7732 ((and (eq action 'crosspost)
7733 (not (gnus-check-backend-function
7734 'request-replace-article gnus-newsgroup-name)))
7735 (error "The current group does not support article editing")))
7736 (let ((articles (gnus-summary-work-articles n))
7737 (prefix (if (gnus-check-backend-function
7738 'request-move-article gnus-newsgroup-name)
7739 (gnus-group-real-prefix gnus-newsgroup-name)
7741 (names '((move "Move" "Moving")
7742 (copy "Copy" "Copying")
7743 (crosspost "Crosspost" "Crossposting")))
7744 (copy-buf (save-excursion
7745 (nnheader-set-temp-buffer " *copy article*")))
7746 (default-marks gnus-article-mark-lists)
7747 (no-expire-marks (delete '(expirable . expire)
7748 (copy-sequence gnus-article-mark-lists)))
7749 art-group to-method new-xref article to-groups)
7750 (unless (assq action names)
7751 (error "Unknown action %s" action))
7752 ;; Read the newsgroup name.
7753 (when (and (not to-newsgroup)
7754 (not select-method))
7756 (gnus-read-move-group-name
7757 (cadr (assq action names))
7758 (symbol-value (intern (format "gnus-current-%s-group" action)))
7760 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7761 (setq to-method (or select-method
7762 (gnus-server-to-method
7763 (gnus-group-method to-newsgroup))))
7764 ;; Check the method we are to move this article to...
7765 (unless (gnus-check-backend-function
7766 'request-accept-article (car to-method))
7767 (error "%s does not support article copying" (car to-method)))
7768 (unless (gnus-check-server to-method)
7769 (error "Can't open server %s" (car to-method)))
7770 (gnus-message 6 "%s to %s: %s..."
7771 (caddr (assq action names))
7772 (or (car select-method) to-newsgroup) articles)
7774 (setq article (pop articles))
7778 ;; Move the article.
7780 ;; Remove this article from future suppression.
7781 (gnus-dup-unsuppress-article article)
7782 (gnus-request-move-article
7783 article ; Article to move
7784 gnus-newsgroup-name ; From newsgroup
7785 (nth 1 (gnus-find-method-for-group
7786 gnus-newsgroup-name)) ; Server
7787 (list 'gnus-request-accept-article
7788 to-newsgroup (list 'quote select-method)
7789 (not articles) t) ; Accept form
7790 (not articles))) ; Only save nov last time
7791 ;; Copy the article.
7794 (set-buffer copy-buf)
7795 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7796 (gnus-request-accept-article
7797 to-newsgroup select-method (not articles) t))))
7798 ;; Crosspost the article.
7799 ((eq action 'crosspost)
7800 (let ((xref (message-tokenize-header
7801 (mail-header-xref (gnus-summary-article-header article))
7803 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7806 (setq xref (list (system-name))))
7809 (mapconcat 'identity
7810 (delete "Xref:" (delete new-xref xref))
7814 (set-buffer copy-buf)
7815 ;; First put the article in the destination group.
7816 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7817 (when (consp (setq art-group
7818 (gnus-request-accept-article
7819 to-newsgroup select-method (not articles))))
7820 (setq new-xref (concat new-xref " " (car art-group)
7821 ":" (cdr art-group)))
7822 ;; Now we have the new Xrefs header, so we insert
7823 ;; it and replace the new article.
7824 (nnheader-replace-header "Xref" new-xref)
7825 (gnus-request-replace-article
7826 (cdr art-group) to-newsgroup (current-buffer))
7830 (gnus-message 1 "Couldn't %s article %s: %s"
7831 (cadr (assq action names)) article
7832 (nnheader-get-report (car to-method))))
7833 ((eq art-group 'junk)
7834 (when (eq action 'move)
7835 (gnus-summary-mark-article article gnus-canceled-mark)
7836 (gnus-message 4 "Deleted article %s" article)))
7838 (let* ((pto-group (gnus-group-prefixed-name
7839 (car art-group) to-method))
7841 (gnus-gethash pto-group gnus-newsrc-hashtb))
7842 (info (nth 2 entry))
7843 (to-group (gnus-info-group info))
7845 ;; Update the group that has been moved to.
7847 (memq action '(move copy)))
7848 (unless (member to-group to-groups)
7849 (push to-group to-groups))
7851 (unless (memq article gnus-newsgroup-unreads)
7852 (push 'read to-marks)
7854 info (gnus-add-to-range (gnus-info-read info)
7855 (list (cdr art-group)))))
7857 ;; See whether the article is to be put in the cache.
7858 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7861 (to-article (cdr art-group)))
7863 ;; Enter the article into the cache in the new group,
7864 ;; if that is required.
7865 (when gnus-use-cache
7866 (gnus-cache-possibly-enter-article
7868 (let ((header (copy-sequence
7869 (gnus-summary-article-header article))))
7870 (mail-header-set-number header to-article)
7872 (memq article gnus-newsgroup-marked)
7873 (memq article gnus-newsgroup-dormant)
7874 (memq article gnus-newsgroup-unreads)))
7876 (when gnus-preserve-marks
7877 ;; Copy any marks over to the new group.
7878 (when (and (equal to-group gnus-newsgroup-name)
7879 (not (memq article gnus-newsgroup-unreads)))
7880 ;; Mark this article as read in this group.
7881 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7882 (setcdr (gnus-active to-group) to-article)
7883 (setcdr gnus-newsgroup-active to-article))
7886 (when (memq article (symbol-value
7887 (intern (format "gnus-newsgroup-%s"
7889 (push (cdar marks) to-marks)
7890 ;; If the other group is the same as this group,
7891 ;; then we have to add the mark to the list.
7892 (when (equal to-group gnus-newsgroup-name)
7893 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7896 (intern (format "gnus-newsgroup-%s"
7898 ;; Copy the marks to other group.
7899 (gnus-add-marked-articles
7900 to-group (cdar marks) (list to-article) info))
7901 (setq marks (cdr marks)))
7903 (gnus-request-set-mark to-group (list (list (list to-article)
7908 (concat "(gnus-group-set-info '"
7909 (gnus-prin1-to-string (gnus-get-info to-group))
7912 ;; Update the Xref header in this article to point to
7913 ;; the new crossposted article we have just created.
7914 (when (eq action 'crosspost)
7916 (set-buffer copy-buf)
7917 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7918 (nnheader-replace-header "Xref" new-xref)
7919 (gnus-request-replace-article
7920 article gnus-newsgroup-name (current-buffer)))))
7922 ;;;!!!Why is this necessary?
7923 (set-buffer gnus-summary-buffer)
7925 (gnus-summary-goto-subject article)
7926 (when (eq action 'move)
7927 (gnus-summary-mark-article article gnus-canceled-mark))))
7928 (gnus-summary-remove-process-mark article))
7929 ;; Re-activate all groups that have been moved to.
7932 (set-buffer gnus-group-buffer)
7933 (when (gnus-group-goto-group (car to-groups) t)
7934 (gnus-group-get-new-news-this-group 1 t))
7937 (gnus-kill-buffer copy-buf)
7938 (gnus-summary-position-point)
7939 (gnus-set-mode-line 'summary)))
7941 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7942 "Move the current article to a different newsgroup.
7943 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7944 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7945 re-spool using this method."
7947 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7949 (defun gnus-summary-crosspost-article (&optional n)
7950 "Crosspost the current article to some other group."
7952 (gnus-summary-move-article n nil nil 'crosspost))
7954 (defcustom gnus-summary-respool-default-method nil
7955 "Default method for respooling an article.
7956 If nil, use to the current newsgroup method."
7957 :type '(choice (gnus-select-method :value (nnml ""))
7959 :group 'gnus-summary-mail)
7961 (defun gnus-summary-respool-article (&optional n method)
7962 "Respool the current article.
7963 The article will be squeezed through the mail spooling process again,
7964 which means that it will be put in some mail newsgroup or other
7965 depending on `nnmail-split-methods'.
7966 If N is a positive number, respool the N next articles.
7967 If N is a negative number, respool the N previous articles.
7968 If N is nil and any articles have been marked with the process mark,
7969 respool those articles instead.
7971 Respooling can be done both from mail groups and \"real\" newsgroups.
7972 In the former case, the articles in question will be moved from the
7973 current group into whatever groups they are destined to. In the
7974 latter case, they will be copied into the relevant groups."
7976 (list current-prefix-arg
7977 (let* ((methods (gnus-methods-using 'respool))
7979 (symbol-name (or gnus-summary-respool-default-method
7980 (car (gnus-find-method-for-group
7981 gnus-newsgroup-name)))))
7983 (gnus-completing-read
7984 methname "What backend do you want to use when respooling?"
7985 methods nil t nil 'gnus-mail-method-history))
7988 ((zerop (length (setq ms (gnus-servers-using-backend
7990 (list (intern method) ""))
7994 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7995 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7998 (error "No method given for respooling"))
7999 (if (assoc (symbol-name
8000 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8001 (gnus-methods-using 'respool))
8002 (gnus-summary-move-article n nil method)
8003 (gnus-summary-copy-article n nil method)))
8005 (defun gnus-summary-import-article (file)
8006 "Import an arbitrary file into a mail newsgroup."
8007 (interactive "fImport file: ")
8008 (let ((group gnus-newsgroup-name)
8009 (now (current-time))
8011 (unless (gnus-check-backend-function 'request-accept-article group)
8012 (error "%s does not support article importing" group))
8013 (or (file-readable-p file)
8014 (not (file-regular-p file))
8015 (error "Can't read %s" file))
8017 (set-buffer (gnus-get-buffer-create " *import file*"))
8019 (nnheader-insert-file-contents file)
8020 (goto-char (point-min))
8021 (unless (nnheader-article-p)
8022 ;; This doesn't look like an article, so we fudge some headers.
8023 (setq atts (file-attributes file)
8024 lines (count-lines (point-min) (point-max)))
8025 (insert "From: " (read-string "From: ") "\n"
8026 "Subject: " (read-string "Subject: ") "\n"
8027 "Date: " (message-make-date (nth 5 atts))
8029 "Message-ID: " (message-make-message-id) "\n"
8030 "Lines: " (int-to-string lines) "\n"
8031 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8032 (gnus-request-accept-article group nil t)
8033 (kill-buffer (current-buffer)))))
8035 (defun gnus-summary-article-posted-p ()
8036 "Say whether the current (mail) article is available from news as well.
8037 This will be the case if the article has both been mailed and posted."
8039 (let ((id (mail-header-references (gnus-summary-article-header)))
8040 (gnus-override-method (car (gnus-refer-article-methods))))
8041 (if (gnus-request-head id "")
8042 (gnus-message 2 "The current message was found on %s"
8043 gnus-override-method)
8044 (gnus-message 2 "The current message couldn't be found on %s"
8045 gnus-override-method)
8048 (defun gnus-summary-expire-articles (&optional now)
8049 "Expire all articles that are marked as expirable in the current group."
8051 (when (gnus-check-backend-function
8052 'request-expire-articles gnus-newsgroup-name)
8053 ;; This backend supports expiry.
8054 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8055 (expirable (if total
8057 ;; We need to update the info for
8058 ;; this group for `gnus-list-of-read-articles'
8059 ;; to give us the right answer.
8060 (gnus-run-hooks 'gnus-exit-group-hook)
8061 (gnus-summary-update-info)
8062 (gnus-list-of-read-articles gnus-newsgroup-name))
8063 (setq gnus-newsgroup-expirable
8064 (sort gnus-newsgroup-expirable '<))))
8065 (expiry-wait (if now 'immediate
8066 (gnus-group-find-parameter
8067 gnus-newsgroup-name 'expiry-wait)))
8068 (nnmail-expiry-target
8069 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8070 nnmail-expiry-target))
8073 ;; There are expirable articles in this group, so we run them
8074 ;; through the expiry process.
8075 (gnus-message 6 "Expiring articles...")
8076 (unless (gnus-check-group gnus-newsgroup-name)
8077 (error "Can't open server for %s" gnus-newsgroup-name))
8078 ;; The list of articles that weren't expired is returned.
8081 (let ((nnmail-expiry-wait-function nil)
8082 (nnmail-expiry-wait expiry-wait))
8083 (setq es (gnus-request-expire-articles
8084 expirable gnus-newsgroup-name)))
8085 (setq es (gnus-request-expire-articles
8086 expirable gnus-newsgroup-name)))
8088 (setq gnus-newsgroup-expirable es))
8089 ;; We go through the old list of expirable, and mark all
8090 ;; really expired articles as nonexistent.
8091 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8092 (let ((gnus-use-cache nil))
8094 (unless (memq (car expirable) es)
8095 (when (gnus-data-find (car expirable))
8096 (gnus-summary-mark-article
8097 (car expirable) gnus-canceled-mark)))
8098 (setq expirable (cdr expirable))))))
8099 (gnus-message 6 "Expiring articles...done")))))
8101 (defun gnus-summary-expire-articles-now ()
8102 "Expunge all expirable articles in the current group.
8103 This means that *all* articles that are marked as expirable will be
8104 deleted forever, right now."
8106 (or gnus-expert-user
8108 "Are you really, really, really sure you want to delete all these messages? ")
8110 (gnus-summary-expire-articles t))
8112 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8113 (defun gnus-summary-delete-article (&optional n)
8114 "Delete the N next (mail) articles.
8115 This command actually deletes articles. This is not a marking
8116 command. The article will disappear forever from your life, never to
8118 If N is negative, delete backwards.
8119 If N is nil and articles have been marked with the process mark,
8120 delete these instead."
8122 (unless (gnus-check-backend-function 'request-expire-articles
8123 gnus-newsgroup-name)
8124 (error "The current newsgroup does not support article deletion"))
8125 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8126 (error "Couldn't open server"))
8127 ;; Compute the list of articles to delete.
8128 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8130 (if (and gnus-novice-user
8131 (not (gnus-yes-or-no-p
8132 (format "Do you really want to delete %s forever? "
8133 (if (> (length articles) 1)
8134 (format "these %s articles" (length articles))
8137 ;; Delete the articles.
8138 (setq not-deleted (gnus-request-expire-articles
8139 articles gnus-newsgroup-name 'force))
8141 (gnus-summary-remove-process-mark (car articles))
8142 ;; The backend might not have been able to delete the article
8144 (unless (memq (car articles) not-deleted)
8145 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8146 (setq articles (cdr articles)))
8148 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8149 (gnus-summary-position-point)
8150 (gnus-set-mode-line 'summary)
8153 (defun gnus-summary-edit-article (&optional force)
8154 "Edit the current article.
8155 This will have permanent effect only in mail groups.
8156 If FORCE is non-nil, allow editing of articles even in read-only
8160 (set-buffer gnus-summary-buffer)
8161 (let ((mail-parse-charset gnus-newsgroup-charset)
8162 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8163 (gnus-set-global-variables)
8164 (when (and (not force)
8165 (gnus-group-read-only-p))
8166 (error "The current newsgroup does not support article editing"))
8167 (gnus-summary-show-article t)
8168 (gnus-article-edit-article
8170 `(lambda (no-highlight)
8171 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8172 (message-options message-options)
8173 (message-options-set-recipient)
8174 (mail-parse-ignored-charsets
8175 ',gnus-newsgroup-ignored-charsets))
8176 (gnus-summary-edit-article-done
8177 ,(or (mail-header-references gnus-current-headers) "")
8178 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8180 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8182 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8184 "Make edits to the current article permanent."
8187 ;; The buffer restriction contains the entire article if it exists.
8188 (when (article-goto-body)
8189 (let ((lines (count-lines (point) (point-max)))
8190 (length (- (point-max) (point)))
8191 (case-fold-search t)
8192 (body (copy-marker (point))))
8193 (goto-char (point-min))
8194 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8195 (delete-region (match-beginning 1) (match-end 1))
8196 (insert (number-to-string length)))
8197 (goto-char (point-min))
8198 (when (re-search-forward
8199 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8200 (delete-region (match-beginning 1) (match-end 1))
8201 (insert (number-to-string length)))
8202 (goto-char (point-min))
8203 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8204 (delete-region (match-beginning 1) (match-end 1))
8205 (insert (number-to-string lines))))))
8206 ;; Replace the article.
8207 (let ((buf (current-buffer)))
8209 (insert-buffer-substring buf)
8211 (if (and (not read-only)
8212 (not (gnus-request-replace-article
8213 (cdr gnus-article-current) (car gnus-article-current)
8214 (current-buffer) t)))
8215 (error "Couldn't replace article")
8216 ;; Update the summary buffer.
8218 (equal (message-tokenize-header references " ")
8219 (message-tokenize-header
8220 (or (message-fetch-field "references") "") " ")))
8221 ;; We only have to update this line.
8224 (message-narrow-to-head)
8225 (let ((head (buffer-string))
8228 (insert (format "211 %d Article retrieved.\n"
8229 (cdr gnus-article-current)))
8232 (let ((nntp-server-buffer (current-buffer)))
8233 (setq header (car (gnus-get-newsgroup-headers
8235 (set-buffer gnus-summary-buffer)
8236 gnus-newsgroup-dependencies)
8239 (set-buffer gnus-summary-buffer)
8240 (gnus-data-set-header
8241 (gnus-data-find (cdr gnus-article-current))
8243 (gnus-summary-update-article-line
8244 (cdr gnus-article-current) header))))))
8246 (set-buffer (or buffer gnus-summary-buffer))
8247 (gnus-summary-update-article (cdr gnus-article-current)))
8248 ;; Prettify the article buffer again.
8249 (unless no-highlight
8251 (set-buffer gnus-article-buffer)
8252 ;;;!!! Fix this -- article should be rehighlighted.
8253 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8254 (set-buffer gnus-original-article-buffer)
8255 (gnus-request-article
8256 (cdr gnus-article-current)
8257 (car gnus-article-current) (current-buffer))))
8258 ;; Prettify the summary buffer line.
8259 (when (gnus-visual-p 'summary-highlight 'highlight)
8260 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8262 (defun gnus-summary-edit-wash (key)
8263 "Perform editing command KEY in the article buffer."
8267 (message "%s" (concat (this-command-keys) "- "))
8270 (gnus-summary-edit-article)
8271 (execute-kbd-macro (concat (this-command-keys) key))
8272 (gnus-article-edit-done))
8276 (defun gnus-summary-respool-query (&optional silent trace)
8277 "Query where the respool algorithm would put this article."
8279 (let (gnus-mark-article-hook)
8280 (gnus-summary-select-article)
8282 (set-buffer gnus-original-article-buffer)
8284 (message-narrow-to-head)
8285 (let ((groups (nnmail-article-group 'identity trace)))
8288 (message "This message would go to %s"
8289 (mapconcat 'car groups ", "))
8290 (message "This message would go to no groups"))
8293 (defun gnus-summary-respool-trace ()
8294 "Trace where the respool algorithm would put this article.
8295 Display a buffer showing all fancy splitting patterns which matched."
8297 (gnus-summary-respool-query nil t))
8299 ;; Summary marking commands.
8301 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8302 "Mark articles which has the same subject as read, and then select the next.
8303 If UNMARK is positive, remove any kind of mark.
8304 If UNMARK is negative, tick articles."
8307 (setq unmark (prefix-numeric-value unmark)))
8309 (gnus-summary-mark-same-subject
8310 (gnus-summary-article-subject) unmark)))
8311 ;; Select next unread article. If auto-select-same mode, should
8312 ;; select the first unread article.
8313 (gnus-summary-next-article t (and gnus-auto-select-same
8314 (gnus-summary-article-subject)))
8315 (gnus-message 7 "%d article%s marked as %s"
8316 count (if (= count 1) " is" "s are")
8317 (if unmark "unread" "read"))))
8319 (defun gnus-summary-kill-same-subject (&optional unmark)
8320 "Mark articles which has the same subject as read.
8321 If UNMARK is positive, remove any kind of mark.
8322 If UNMARK is negative, tick articles."
8325 (setq unmark (prefix-numeric-value unmark)))
8327 (gnus-summary-mark-same-subject
8328 (gnus-summary-article-subject) unmark)))
8329 ;; If marked as read, go to next unread subject.
8331 ;; Go to next unread subject.
8332 (gnus-summary-next-subject 1 t))
8333 (gnus-message 7 "%d articles are marked as %s"
8334 count (if unmark "unread" "read"))))
8336 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8337 "Mark articles with same SUBJECT as read, and return marked number.
8338 If optional argument UNMARK is positive, remove any kinds of marks.
8339 If optional argument UNMARK is negative, mark articles as unread instead."
8343 ((null unmark) ; Mark as read.
8346 (gnus-summary-mark-article-as-read gnus-killed-mark)
8347 (gnus-summary-show-thread) t)
8348 (gnus-summary-find-subject subject))
8349 (setq count (1+ count))))
8350 ((> unmark 0) ; Tick.
8353 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8354 (gnus-summary-show-thread) t)
8355 (gnus-summary-find-subject subject))
8356 (setq count (1+ count))))
8357 (t ; Mark as unread.
8360 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8361 (gnus-summary-show-thread) t)
8362 (gnus-summary-find-subject subject))
8363 (setq count (1+ count)))))
8364 (gnus-set-mode-line 'summary)
8365 ;; Return the number of marked articles.
8368 (defun gnus-summary-mark-as-processable (n &optional unmark)
8369 "Set the process mark on the next N articles.
8370 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8371 the process mark instead. The difference between N and the actual
8372 number of articles marked is returned."
8374 (let ((backward (< n 0))
8379 (gnus-summary-remove-process-mark
8380 (gnus-summary-article-number))
8381 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8382 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8385 (gnus-message 7 "No more articles"))
8386 (gnus-summary-recenter)
8387 (gnus-summary-position-point)
8390 (defun gnus-summary-unmark-as-processable (n)
8391 "Remove the process mark from the next N articles.
8392 If N is negative, unmark backward instead. The difference between N and
8393 the actual number of articles unmarked is returned."
8395 (gnus-summary-mark-as-processable n t))
8397 (defun gnus-summary-unmark-all-processable ()
8398 "Remove the process mark from all articles."
8401 (while gnus-newsgroup-processable
8402 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8403 (gnus-summary-position-point))
8405 (defun gnus-summary-mark-as-expirable (n)
8406 "Mark N articles forward as expirable.
8407 If N is negative, mark backward instead. The difference between N and
8408 the actual number of articles marked is returned."
8410 (gnus-summary-mark-forward n gnus-expirable-mark))
8412 (defun gnus-summary-mark-article-as-replied (article)
8413 "Mark ARTICLE replied and update the summary line."
8414 (push article gnus-newsgroup-replied)
8415 (let ((buffer-read-only nil))
8416 (when (gnus-summary-goto-subject article nil t)
8417 (gnus-summary-update-secondary-mark article))))
8419 (defun gnus-summary-set-bookmark (article)
8420 "Set a bookmark in current article."
8421 (interactive (list (gnus-summary-article-number)))
8422 (when (or (not (get-buffer gnus-article-buffer))
8423 (not gnus-current-article)
8424 (not gnus-article-current)
8425 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8426 (error "No current article selected"))
8427 ;; Remove old bookmark, if one exists.
8428 (let ((old (assq article gnus-newsgroup-bookmarks)))
8430 (setq gnus-newsgroup-bookmarks
8431 (delq old gnus-newsgroup-bookmarks))))
8432 ;; Set the new bookmark, which is on the form
8433 ;; (article-number . line-number-in-body).
8437 (set-buffer gnus-article-buffer)
8441 (goto-char (point-min))
8442 (search-forward "\n\n" nil t)
8445 gnus-newsgroup-bookmarks)
8446 (gnus-message 6 "A bookmark has been added to the current article."))
8448 (defun gnus-summary-remove-bookmark (article)
8449 "Remove the bookmark from the current article."
8450 (interactive (list (gnus-summary-article-number)))
8451 ;; Remove old bookmark, if one exists.
8452 (let ((old (assq article gnus-newsgroup-bookmarks)))
8455 (setq gnus-newsgroup-bookmarks
8456 (delq old gnus-newsgroup-bookmarks))
8457 (gnus-message 6 "Removed bookmark."))
8458 (gnus-message 6 "No bookmark in current article."))))
8460 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8461 (defun gnus-summary-mark-as-dormant (n)
8462 "Mark N articles forward as dormant.
8463 If N is negative, mark backward instead. The difference between N and
8464 the actual number of articles marked is returned."
8466 (gnus-summary-mark-forward n gnus-dormant-mark))
8468 (defun gnus-summary-set-process-mark (article)
8469 "Set the process mark on ARTICLE and update the summary line."
8470 (setq gnus-newsgroup-processable
8472 (delq article gnus-newsgroup-processable)))
8473 (when (gnus-summary-goto-subject article)
8474 (gnus-summary-show-thread)
8475 (gnus-summary-goto-subject article)
8476 (gnus-summary-update-secondary-mark article)))
8478 (defun gnus-summary-remove-process-mark (article)
8479 "Remove the process mark from ARTICLE and update the summary line."
8480 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8481 (when (gnus-summary-goto-subject article)
8482 (gnus-summary-show-thread)
8483 (gnus-summary-goto-subject article)
8484 (gnus-summary-update-secondary-mark article)))
8486 (defun gnus-summary-set-saved-mark (article)
8487 "Set the process mark on ARTICLE and update the summary line."
8488 (push article gnus-newsgroup-saved)
8489 (when (gnus-summary-goto-subject article)
8490 (gnus-summary-update-secondary-mark article)))
8492 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8493 "Mark N articles as read forwards.
8494 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8495 The difference between N and the actual number of articles marked is
8497 Iff NO-EXPIRE, auto-expiry will be inhibited."
8499 (gnus-summary-show-thread)
8500 (let ((backward (< n 0))
8501 (gnus-summary-goto-unread
8502 (and gnus-summary-goto-unread
8503 (not (eq gnus-summary-goto-unread 'never))
8504 (not (memq mark (list gnus-unread-mark
8505 gnus-ticked-mark gnus-dormant-mark)))))
8507 (mark (or mark gnus-del-mark)))
8509 (gnus-summary-mark-article nil mark no-expire)
8510 (zerop (gnus-summary-next-subject
8512 (and gnus-summary-goto-unread
8513 (not (eq gnus-summary-goto-unread 'never)))
8517 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8518 (gnus-summary-recenter)
8519 (gnus-summary-position-point)
8520 (gnus-set-mode-line 'summary)
8523 (defun gnus-summary-mark-article-as-read (mark)
8524 "Mark the current article quickly as read with MARK."
8525 (let ((article (gnus-summary-article-number)))
8526 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8527 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8528 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8529 (push (cons article mark) gnus-newsgroup-reads)
8530 ;; Possibly remove from cache, if that is used.
8531 (when gnus-use-cache
8532 (gnus-cache-enter-remove-article article))
8533 ;; Allow the backend to change the mark.
8534 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8535 ;; Check for auto-expiry.
8536 (when (and gnus-newsgroup-auto-expire
8537 (memq mark gnus-auto-expirable-marks))
8538 (setq mark gnus-expirable-mark)
8539 ;; Let the backend know about the mark change.
8540 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8541 (push article gnus-newsgroup-expirable))
8542 ;; Set the mark in the buffer.
8543 (gnus-summary-update-mark mark 'unread)
8546 (defun gnus-summary-mark-article-as-unread (mark)
8547 "Mark the current article quickly as unread with MARK."
8548 (let* ((article (gnus-summary-article-number))
8549 (old-mark (gnus-summary-article-mark article)))
8550 ;; Allow the backend to change the mark.
8551 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8552 (if (eq mark old-mark)
8556 (gnus-error 1 "Can't mark negative article numbers")
8558 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8559 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8560 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8561 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8562 (cond ((= mark gnus-ticked-mark)
8563 (push article gnus-newsgroup-marked))
8564 ((= mark gnus-dormant-mark)
8565 (push article gnus-newsgroup-dormant))
8567 (push article gnus-newsgroup-unreads)))
8568 (gnus-pull article gnus-newsgroup-reads)
8570 ;; See whether the article is to be put in the cache.
8572 (vectorp (gnus-summary-article-header article))
8574 (gnus-cache-possibly-enter-article
8575 gnus-newsgroup-name article
8576 (gnus-summary-article-header article)
8577 (= mark gnus-ticked-mark)
8578 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8581 (gnus-summary-update-mark mark 'unread)
8584 (defun gnus-summary-mark-article (&optional article mark no-expire)
8585 "Mark ARTICLE with MARK. MARK can be any character.
8586 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8587 `??' (dormant) and `?E' (expirable).
8588 If MARK is nil, then the default character `?r' is used.
8589 If ARTICLE is nil, then the article on the current line will be
8591 Iff NO-EXPIRE, auto-expiry will be inhibited."
8592 ;; The mark might be a string.
8593 (when (stringp mark)
8594 (setq mark (aref mark 0)))
8595 ;; If no mark is given, then we check auto-expiring.
8597 (setq mark gnus-del-mark))
8598 (when (and (not no-expire)
8599 gnus-newsgroup-auto-expire
8600 (memq mark gnus-auto-expirable-marks))
8601 (setq mark gnus-expirable-mark))
8602 (let ((article (or article (gnus-summary-article-number)))
8603 (old-mark (gnus-summary-article-mark article)))
8604 ;; Allow the backend to change the mark.
8605 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8606 (if (eq mark old-mark)
8609 (error "No article on current line"))
8610 (if (not (if (or (= mark gnus-unread-mark)
8611 (= mark gnus-ticked-mark)
8612 (= mark gnus-dormant-mark))
8613 (gnus-mark-article-as-unread article mark)
8614 (gnus-mark-article-as-read article mark)))
8616 ;; See whether the article is to be put in the cache.
8618 (not (= mark gnus-canceled-mark))
8619 (vectorp (gnus-summary-article-header article))
8621 (gnus-cache-possibly-enter-article
8622 gnus-newsgroup-name article
8623 (gnus-summary-article-header article)
8624 (= mark gnus-ticked-mark)
8625 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8627 (when (gnus-summary-goto-subject article nil t)
8628 (let ((buffer-read-only nil))
8629 (gnus-summary-show-thread)
8631 (gnus-summary-update-mark mark 'unread)
8634 (defun gnus-summary-update-secondary-mark (article)
8635 "Update the secondary (read, process, cache) mark."
8636 (gnus-summary-update-mark
8637 (cond ((memq article gnus-newsgroup-processable)
8639 ((memq article gnus-newsgroup-cached)
8641 ((memq article gnus-newsgroup-replied)
8643 ((memq article gnus-newsgroup-saved)
8645 (t gnus-unread-mark))
8647 (when (gnus-visual-p 'summary-highlight 'highlight)
8648 (gnus-run-hooks 'gnus-summary-update-hook))
8651 (defun gnus-summary-update-mark (mark type)
8652 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8653 (buffer-read-only nil))
8654 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8656 (when (looking-at "\r")
8658 (when (<= (+ forward (point)) (point-max))
8659 ;; Go to the right position on the line.
8660 (goto-char (+ forward (point)))
8661 ;; Replace the old mark with the new mark.
8662 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8663 ;; Optionally update the marks by some user rule.
8664 (when (eq type 'unread)
8666 (gnus-data-find (gnus-summary-article-number)) mark)
8667 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8669 (defun gnus-mark-article-as-read (article &optional mark)
8670 "Enter ARTICLE in the pertinent lists and remove it from others."
8671 ;; Make the article expirable.
8672 (let ((mark (or mark gnus-del-mark)))
8673 (if (= mark gnus-expirable-mark)
8674 (push article gnus-newsgroup-expirable)
8675 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8676 ;; Remove from unread and marked lists.
8677 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8678 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8679 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8680 (push (cons article mark) gnus-newsgroup-reads)
8681 ;; Possibly remove from cache, if that is used.
8682 (when gnus-use-cache
8683 (gnus-cache-enter-remove-article article))
8686 (defun gnus-mark-article-as-unread (article &optional mark)
8687 "Enter ARTICLE in the pertinent lists and remove it from others."
8688 (let ((mark (or mark gnus-ticked-mark)))
8691 (gnus-error 1 "Can't mark negative article numbers")
8693 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8694 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8695 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8696 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8698 ;; Unsuppress duplicates?
8699 (when gnus-suppress-duplicates
8700 (gnus-dup-unsuppress-article article))
8702 (cond ((= mark gnus-ticked-mark)
8703 (push article gnus-newsgroup-marked))
8704 ((= mark gnus-dormant-mark)
8705 (push article gnus-newsgroup-dormant))
8707 (push article gnus-newsgroup-unreads)))
8708 (gnus-pull article gnus-newsgroup-reads)
8711 (defalias 'gnus-summary-mark-as-unread-forward
8712 'gnus-summary-tick-article-forward)
8713 (make-obsolete 'gnus-summary-mark-as-unread-forward
8714 'gnus-summary-tick-article-forward)
8715 (defun gnus-summary-tick-article-forward (n)
8716 "Tick N articles forwards.
8717 If N is negative, tick backwards instead.
8718 The difference between N and the number of articles ticked is returned."
8720 (gnus-summary-mark-forward n gnus-ticked-mark))
8722 (defalias 'gnus-summary-mark-as-unread-backward
8723 'gnus-summary-tick-article-backward)
8724 (make-obsolete 'gnus-summary-mark-as-unread-backward
8725 'gnus-summary-tick-article-backward)
8726 (defun gnus-summary-tick-article-backward (n)
8727 "Tick N articles backwards.
8728 The difference between N and the number of articles ticked is returned."
8730 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8732 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8733 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8734 (defun gnus-summary-tick-article (&optional article clear-mark)
8735 "Mark current article as unread.
8736 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8737 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8739 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8742 (defun gnus-summary-mark-as-read-forward (n)
8743 "Mark N articles as read forwards.
8744 If N is negative, mark backwards instead.
8745 The difference between N and the actual number of articles marked is
8748 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8750 (defun gnus-summary-mark-as-read-backward (n)
8751 "Mark the N articles as read backwards.
8752 The difference between N and the actual number of articles marked is
8755 (gnus-summary-mark-forward
8756 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8758 (defun gnus-summary-mark-as-read (&optional article mark)
8759 "Mark current article as read.
8760 ARTICLE specifies the article to be marked as read.
8761 MARK specifies a string to be inserted at the beginning of the line."
8762 (gnus-summary-mark-article article mark))
8764 (defun gnus-summary-clear-mark-forward (n)
8765 "Clear marks from N articles forward.
8766 If N is negative, clear backward instead.
8767 The difference between N and the number of marks cleared is returned."
8769 (gnus-summary-mark-forward n gnus-unread-mark))
8771 (defun gnus-summary-clear-mark-backward (n)
8772 "Clear marks from N articles backward.
8773 The difference between N and the number of marks cleared is returned."
8775 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8777 (defun gnus-summary-mark-unread-as-read ()
8778 "Intended to be used by `gnus-summary-mark-article-hook'."
8779 (when (memq gnus-current-article gnus-newsgroup-unreads)
8780 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8782 (defun gnus-summary-mark-read-and-unread-as-read ()
8783 "Intended to be used by `gnus-summary-mark-article-hook'."
8784 (let ((mark (gnus-summary-article-mark)))
8785 (when (or (gnus-unread-mark-p mark)
8786 (gnus-read-mark-p mark))
8787 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8789 (defun gnus-summary-mark-region-as-read (point mark all)
8790 "Mark all unread articles between point and mark as read.
8791 If given a prefix, mark all articles between point and mark as read,
8792 even ticked and dormant ones."
8793 (interactive "r\nP")
8802 (memq (setq article (gnus-summary-article-number))
8803 gnus-newsgroup-unreads))
8804 (gnus-summary-mark-article article gnus-del-mark))
8806 (gnus-summary-find-next))))))
8808 (defun gnus-summary-mark-below (score mark)
8809 "Mark articles with score less than SCORE with MARK."
8810 (interactive "P\ncMark: ")
8811 (setq score (if score
8812 (prefix-numeric-value score)
8813 (or gnus-summary-default-score 0)))
8815 (set-buffer gnus-summary-buffer)
8816 (goto-char (point-min))
8819 (and (< (gnus-summary-article-score) score)
8820 (gnus-summary-mark-article nil mark))
8821 (gnus-summary-find-next)))))
8823 (defun gnus-summary-kill-below (&optional score)
8824 "Mark articles with score below SCORE as read."
8826 (gnus-summary-mark-below score gnus-killed-mark))
8828 (defun gnus-summary-clear-above (&optional score)
8829 "Clear all marks from articles with score above SCORE."
8831 (gnus-summary-mark-above score gnus-unread-mark))
8833 (defun gnus-summary-tick-above (&optional score)
8834 "Tick all articles with score above SCORE."
8836 (gnus-summary-mark-above score gnus-ticked-mark))
8838 (defun gnus-summary-mark-above (score mark)
8839 "Mark articles with score over SCORE with MARK."
8840 (interactive "P\ncMark: ")
8841 (setq score (if score
8842 (prefix-numeric-value score)
8843 (or gnus-summary-default-score 0)))
8845 (set-buffer gnus-summary-buffer)
8846 (goto-char (point-min))
8848 (when (> (gnus-summary-article-score) score)
8849 (gnus-summary-mark-article nil mark))
8851 (gnus-summary-find-next)))))
8853 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8854 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8855 (defun gnus-summary-limit-include-expunged (&optional no-error)
8856 "Display all the hidden articles that were expunged for low scores."
8858 (let ((buffer-read-only nil))
8859 (let ((scored gnus-newsgroup-scored)
8862 (unless (gnus-summary-goto-subject (caar scored))
8863 (and (setq h (gnus-summary-article-header (caar scored)))
8864 (< (cdar scored) gnus-summary-expunge-below)
8866 (setq scored (cdr scored)))
8868 (when (not no-error)
8869 (error "No expunged articles hidden"))
8870 (goto-char (point-min))
8871 (gnus-summary-prepare-unthreaded (nreverse headers))
8872 (goto-char (point-min))
8873 (gnus-summary-position-point)
8876 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8877 "Mark all unread articles in this newsgroup as read.
8878 If prefix argument ALL is non-nil, ticked and dormant articles will
8879 also be marked as read.
8880 If QUIETLY is non-nil, no questions will be asked.
8881 If TO-HERE is non-nil, it should be a point in the buffer. All
8882 articles before this point will be marked as read.
8883 Note that this function will only catch up the unread article
8884 in the current summary buffer limitation.
8885 The number of articles marked as read is returned."
8890 (not gnus-interactive-catchup) ;Without confirmation?
8894 "Mark absolutely all articles as read? "
8895 "Mark all unread articles as read? ")))
8897 (not gnus-newsgroup-adaptive)
8898 (not gnus-newsgroup-auto-expire)
8899 (not gnus-suppress-duplicates)
8900 (or (not gnus-use-cache)
8901 (eq gnus-use-cache 'passive)))
8904 (setq gnus-newsgroup-marked nil
8905 gnus-newsgroup-dormant nil))
8906 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8907 ;; We actually mark all articles as canceled, which we
8908 ;; have to do when using auto-expiry or adaptive scoring.
8909 (gnus-summary-show-all-threads)
8910 (when (gnus-summary-first-subject (not all) t)
8912 (if to-here (< (point) to-here) t)
8913 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8914 (gnus-summary-find-next (not all) nil nil t))))
8915 (gnus-set-mode-line 'summary))
8917 (gnus-summary-position-point)))
8919 (defun gnus-summary-catchup-to-here (&optional all)
8920 "Mark all unticked articles before the current one as read.
8921 If ALL is non-nil, also mark ticked and dormant articles as read."
8924 (gnus-save-hidden-threads
8925 (let ((beg (point)))
8926 ;; We check that there are unread articles.
8927 (when (or all (gnus-summary-find-prev))
8928 (gnus-summary-catchup all t beg)))))
8929 (gnus-summary-position-point))
8931 (defun gnus-summary-catchup-all (&optional quietly)
8932 "Mark all articles in this newsgroup as read."
8934 (gnus-summary-catchup t quietly))
8936 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8937 "Mark all unread articles in this group as read, then exit.
8938 If prefix argument ALL is non-nil, all articles are marked as read."
8940 (when (gnus-summary-catchup all quietly nil 'fast)
8941 ;; Select next newsgroup or exit.
8942 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8943 (eq gnus-auto-select-next 'quietly))
8944 (gnus-summary-next-group nil)
8945 (gnus-summary-exit))))
8947 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8948 "Mark all articles in this newsgroup as read, and then exit."
8950 (gnus-summary-catchup-and-exit t quietly))
8952 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8953 "Mark all articles in this group as read and select the next group.
8954 If given a prefix, mark all articles, unread as well as ticked, as
8958 (gnus-summary-catchup all))
8959 (gnus-summary-next-group))
8965 (defmacro gnus-with-article (article &rest forms)
8966 "Select ARTICLE and perform FORMS in the original article buffer.
8967 Then replace the article with the result."
8969 ;; We don't want the article to be marked as read.
8970 (let (gnus-mark-article-hook)
8971 (gnus-summary-select-article t t nil ,article))
8972 (set-buffer gnus-original-article-buffer)
8974 (if (not (gnus-check-backend-function
8975 'request-replace-article (car gnus-article-current)))
8976 (gnus-message 5 "Read-only group; not replacing")
8977 (unless (gnus-request-replace-article
8978 ,article (car gnus-article-current)
8980 (error "Couldn't replace article")))
8981 ;; The cache and backlog have to be flushed somewhat.
8982 (when gnus-keep-backlog
8983 (gnus-backlog-remove-article
8984 (car gnus-article-current) (cdr gnus-article-current)))
8985 (when gnus-use-cache
8986 (gnus-cache-update-article
8987 (car gnus-article-current) (cdr gnus-article-current)))))
8989 (put 'gnus-with-article 'lisp-indent-function 1)
8990 (put 'gnus-with-article 'edebug-form-spec '(form body))
8992 ;; Thread-based commands.
8994 (defun gnus-summary-articles-in-thread (&optional article)
8995 "Return a list of all articles in the current thread.
8996 If ARTICLE is non-nil, return all articles in the thread that starts
8998 (let* ((article (or article (gnus-summary-article-number)))
8999 (data (gnus-data-find-list article))
9000 (top-level (gnus-data-level (car data)))
9002 (cond ((null gnus-thread-operation-ignore-subject)
9003 (gnus-simplify-subject-re
9004 (mail-header-subject (gnus-data-header (car data)))))
9005 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9006 (gnus-simplify-subject-fuzzy
9007 (mail-header-subject (gnus-data-header (car data)))))
9009 (end-point (save-excursion
9010 (if (gnus-summary-go-to-next-thread)
9011 (point) (point-max))))
9014 (< (gnus-data-pos (car data)) end-point))
9015 (when (or (not top-subject)
9016 (string= top-subject
9017 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9018 (gnus-simplify-subject-fuzzy
9019 (mail-header-subject
9020 (gnus-data-header (car data))))
9021 (gnus-simplify-subject-re
9022 (mail-header-subject
9023 (gnus-data-header (car data)))))))
9024 (push (gnus-data-number (car data)) articles))
9025 (unless (and (setq data (cdr data))
9026 (> (gnus-data-level (car data)) top-level))
9028 ;; Return the list of articles.
9029 (nreverse articles)))
9031 (defun gnus-summary-rethread-current ()
9032 "Rethread the thread the current article is part of."
9034 (let* ((gnus-show-threads t)
9035 (article (gnus-summary-article-number))
9036 (id (mail-header-id (gnus-summary-article-header)))
9037 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9039 (error "No article on the current line"))
9040 (gnus-rebuild-thread id)
9041 (gnus-summary-goto-subject article)))
9043 (defun gnus-summary-reparent-thread ()
9044 "Make the current article child of the marked (or previous) article.
9046 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9047 is non-nil or the Subject: of both articles are the same."
9049 (unless (not (gnus-group-read-only-p))
9050 (error "The current newsgroup does not support article editing"))
9051 (unless (<= (length gnus-newsgroup-processable) 1)
9052 (error "No more than one article may be marked"))
9053 (save-window-excursion
9054 (let ((gnus-article-buffer " *reparent*")
9055 (current-article (gnus-summary-article-number))
9056 ;; First grab the marked article, otherwise one line up.
9057 (parent-article (if (not (null gnus-newsgroup-processable))
9058 (car gnus-newsgroup-processable)
9060 (if (eq (forward-line -1) 0)
9061 (gnus-summary-article-number)
9062 (error "Beginning of summary buffer"))))))
9063 (unless (not (eq current-article parent-article))
9064 (error "An article may not be self-referential"))
9065 (let ((message-id (mail-header-id
9066 (gnus-summary-article-header parent-article))))
9067 (unless (and message-id (not (equal message-id "")))
9068 (error "No message-id in desired parent"))
9069 (gnus-with-article current-article
9071 (goto-char (point-min))
9072 (message-narrow-to-head)
9073 (if (re-search-forward "^References: " nil t)
9075 (re-search-forward "^[^ \t]" nil t)
9078 (insert " " message-id))
9079 (insert "References: " message-id "\n"))))
9080 (set-buffer gnus-summary-buffer)
9081 (gnus-summary-unmark-all-processable)
9082 (gnus-summary-update-article current-article)
9083 (gnus-summary-rethread-current)
9084 (gnus-message 3 "Article %d is now the child of article %d"
9085 current-article parent-article)))))
9087 (defun gnus-summary-toggle-threads (&optional arg)
9088 "Toggle showing conversation threads.
9089 If ARG is positive number, turn showing conversation threads on."
9091 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9092 (setq gnus-show-threads
9093 (if (null arg) (not gnus-show-threads)
9094 (> (prefix-numeric-value arg) 0)))
9095 (gnus-summary-prepare)
9096 (gnus-summary-goto-subject current)
9097 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9098 (gnus-summary-position-point)))
9100 (defun gnus-summary-show-all-threads ()
9104 (let ((buffer-read-only nil))
9105 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9106 (gnus-summary-position-point))
9108 (defun gnus-summary-show-thread ()
9109 "Show thread subtrees.
9110 Returns nil if no thread was there to be shown."
9112 (let ((buffer-read-only nil)
9114 ;; first goto end then to beg, to have point at beg after let
9115 (end (progn (end-of-line) (point)))
9116 (beg (progn (beginning-of-line) (point))))
9118 ;; Any hidden lines here?
9119 (search-forward "\r" end t)
9120 (subst-char-in-region beg end ?\^M ?\n t)
9122 (gnus-summary-position-point))))
9124 (defun gnus-summary-hide-all-threads ()
9125 "Hide all thread subtrees."
9128 (goto-char (point-min))
9129 (gnus-summary-hide-thread)
9130 (while (zerop (gnus-summary-next-thread 1 t))
9131 (gnus-summary-hide-thread)))
9132 (gnus-summary-position-point))
9134 (defun gnus-summary-hide-thread ()
9135 "Hide thread subtrees.
9136 Returns nil if no threads were there to be hidden."
9138 (let ((buffer-read-only nil)
9140 (article (gnus-summary-article-number)))
9142 ;; Go forward until either the buffer ends or the subthread
9144 (when (and (not (eobp))
9145 (or (zerop (gnus-summary-next-thread 1 t))
9146 (goto-char (point-max))))
9148 (if (and (> (point) start)
9149 (search-backward "\n" start t))
9151 (subst-char-in-region start (point) ?\n ?\^M)
9152 (gnus-summary-goto-subject article))
9156 (defun gnus-summary-go-to-next-thread (&optional previous)
9157 "Go to the same level (or less) next thread.
9158 If PREVIOUS is non-nil, go to previous thread instead.
9159 Return the article number moved to, or nil if moving was impossible."
9160 (let ((level (gnus-summary-thread-level))
9161 (way (if previous -1 1))
9164 (while (and (not (eobp))
9165 (< level (gnus-summary-thread-level)))
9173 (gnus-summary-article-number)
9176 (defun gnus-summary-next-thread (n &optional silent)
9177 "Go to the same level next N'th thread.
9178 If N is negative, search backward instead.
9179 Returns the difference between N and the number of skips actually
9182 If SILENT, don't output messages."
9184 (let ((backward (< n 0))
9187 (gnus-summary-go-to-next-thread backward))
9190 (gnus-summary-position-point))
9191 (when (and (not silent) (/= 0 n))
9192 (gnus-message 7 "No more threads"))
9195 (defun gnus-summary-prev-thread (n)
9196 "Go to the same level previous N'th thread.
9197 Returns the difference between N and the number of skips actually
9200 (gnus-summary-next-thread (- n)))
9202 (defun gnus-summary-go-down-thread ()
9203 "Go down one level in the current thread."
9204 (let ((children (gnus-summary-article-children)))
9206 (gnus-summary-goto-subject (car children)))))
9208 (defun gnus-summary-go-up-thread ()
9209 "Go up one level in the current thread."
9210 (let ((parent (gnus-summary-article-parent)))
9212 (gnus-summary-goto-subject parent))))
9214 (defun gnus-summary-down-thread (n)
9215 "Go down thread N steps.
9216 If N is negative, go up instead.
9217 Returns the difference between N and how many steps down that were
9223 (if up (gnus-summary-go-up-thread)
9224 (gnus-summary-go-down-thread)))
9226 (gnus-summary-position-point)
9228 (gnus-message 7 "Can't go further"))
9231 (defun gnus-summary-up-thread (n)
9232 "Go up thread N steps.
9233 If N is negative, go up instead.
9234 Returns the difference between N and how many steps down that were
9237 (gnus-summary-down-thread (- n)))
9239 (defun gnus-summary-top-thread ()
9240 "Go to the top of the thread."
9242 (while (gnus-summary-go-up-thread))
9243 (gnus-summary-article-number))
9245 (defun gnus-summary-kill-thread (&optional unmark)
9246 "Mark articles under current thread as read.
9247 If the prefix argument is positive, remove any kinds of marks.
9248 If the prefix argument is negative, tick articles instead."
9251 (setq unmark (prefix-numeric-value unmark)))
9252 (let ((articles (gnus-summary-articles-in-thread)))
9254 ;; Expand the thread.
9255 (gnus-summary-show-thread)
9256 ;; Mark all the articles.
9258 (gnus-summary-goto-subject (car articles))
9259 (cond ((null unmark)
9260 (gnus-summary-mark-article-as-read gnus-killed-mark))
9262 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9264 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9265 (setq articles (cdr articles))))
9266 ;; Hide killed subtrees.
9268 gnus-thread-hide-killed
9269 (gnus-summary-hide-thread))
9270 ;; If marked as read, go to next unread subject.
9272 ;; Go to next unread subject.
9273 (gnus-summary-next-subject 1 t)))
9274 (gnus-set-mode-line 'summary))
9276 ;; Summary sorting commands
9278 (defun gnus-summary-sort-by-number (&optional reverse)
9279 "Sort the summary buffer by article number.
9280 Argument REVERSE means reverse order."
9282 (gnus-summary-sort 'number reverse))
9284 (defun gnus-summary-sort-by-author (&optional reverse)
9285 "Sort the summary buffer by author name alphabetically.
9286 If `case-fold-search' is non-nil, case of letters is ignored.
9287 Argument REVERSE means reverse order."
9289 (gnus-summary-sort 'author reverse))
9291 (defun gnus-summary-sort-by-subject (&optional reverse)
9292 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9293 If `case-fold-search' is non-nil, case of letters is ignored.
9294 Argument REVERSE means reverse order."
9296 (gnus-summary-sort 'subject reverse))
9298 (defun gnus-summary-sort-by-date (&optional reverse)
9299 "Sort the summary buffer by date.
9300 Argument REVERSE means reverse order."
9302 (gnus-summary-sort 'date reverse))
9304 (defun gnus-summary-sort-by-score (&optional reverse)
9305 "Sort the summary buffer by score.
9306 Argument REVERSE means reverse order."
9308 (gnus-summary-sort 'score reverse))
9310 (defun gnus-summary-sort-by-lines (&optional reverse)
9311 "Sort the summary buffer by the number of lines.
9312 Argument REVERSE means reverse order."
9314 (gnus-summary-sort 'lines reverse))
9316 (defun gnus-summary-sort-by-chars (&optional reverse)
9317 "Sort the summary buffer by article length.
9318 Argument REVERSE means reverse order."
9320 (gnus-summary-sort 'chars reverse))
9322 (defun gnus-summary-sort (predicate reverse)
9323 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9324 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9325 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9326 (gnus-thread-sort-functions
9331 (gnus-sort-gathered-threads-function
9332 gnus-thread-sort-functions)
9333 (gnus-article-sort-functions
9339 (gnus-summary-prepare-hook nil))
9340 ;; We do the sorting by regenerating the threads.
9341 (gnus-summary-prepare)
9342 ;; Hide subthreads if needed.
9343 (when (and gnus-show-threads gnus-thread-hide-subtree)
9344 (gnus-summary-hide-all-threads))))
9346 ;; Summary saving commands.
9348 (defun gnus-summary-save-article (&optional n not-saved)
9349 "Save the current article using the default saver function.
9350 If N is a positive number, save the N next articles.
9351 If N is a negative number, save the N previous articles.
9352 If N is nil and any articles have been marked with the process mark,
9353 save those articles instead.
9354 The variable `gnus-default-article-saver' specifies the saver function."
9356 (let* ((articles (gnus-summary-work-articles n))
9357 (save-buffer (save-excursion
9358 (nnheader-set-temp-buffer " *Gnus Save*")))
9359 (num (length articles))
9361 (dolist (article articles)
9362 (setq header (gnus-summary-article-header article))
9363 (if (not (vectorp header))
9364 ;; This is a pseudo-article.
9365 (if (assq 'name header)
9366 (gnus-copy-file (cdr (assq 'name header)))
9367 (gnus-message 1 "Article %d is unsaveable" article))
9368 ;; This is a real article.
9369 (save-window-excursion
9370 (gnus-summary-select-article t nil nil article))
9372 (set-buffer save-buffer)
9374 (insert-buffer-substring gnus-original-article-buffer))
9375 (setq file (gnus-article-save save-buffer file num))
9376 (gnus-summary-remove-process-mark article)
9378 (gnus-summary-set-saved-mark article))))
9379 (gnus-kill-buffer save-buffer)
9380 (gnus-summary-position-point)
9381 (gnus-set-mode-line 'summary)
9384 (defun gnus-summary-pipe-output (&optional arg)
9385 "Pipe the current article to a subprocess.
9386 If N is a positive number, pipe the N next articles.
9387 If N is a negative number, pipe the N previous articles.
9388 If N is nil and any articles have been marked with the process mark,
9389 pipe those articles instead."
9392 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9393 (gnus-summary-save-article arg t))
9394 (gnus-configure-windows 'pipe))
9396 (defun gnus-summary-save-article-mail (&optional arg)
9397 "Append the current article to an mail file.
9398 If N is a positive number, save the N next articles.
9399 If N is a negative number, save the N previous articles.
9400 If N is nil and any articles have been marked with the process mark,
9401 save those articles instead."
9404 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9405 (gnus-summary-save-article arg)))
9407 (defun gnus-summary-save-article-rmail (&optional arg)
9408 "Append the current article to an rmail file.
9409 If N is a positive number, save the N next articles.
9410 If N is a negative number, save the N previous articles.
9411 If N is nil and any articles have been marked with the process mark,
9412 save those articles instead."
9415 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9416 (gnus-summary-save-article arg)))
9418 (defun gnus-summary-save-article-file (&optional arg)
9419 "Append the current article to a file.
9420 If N is a positive number, save the N next articles.
9421 If N is a negative number, save the N previous articles.
9422 If N is nil and any articles have been marked with the process mark,
9423 save those articles instead."
9426 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9427 (gnus-summary-save-article arg)))
9429 (defun gnus-summary-write-article-file (&optional arg)
9430 "Write the current article to a file, deleting the previous file.
9431 If N is a positive number, save the N next articles.
9432 If N is a negative number, save the N previous articles.
9433 If N is nil and any articles have been marked with the process mark,
9434 save those articles instead."
9437 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9438 (gnus-summary-save-article arg)))
9440 (defun gnus-summary-save-article-body-file (&optional arg)
9441 "Append the current article body to a file.
9442 If N is a positive number, save the N next articles.
9443 If N is a negative number, save the N previous articles.
9444 If N is nil and any articles have been marked with the process mark,
9445 save those articles instead."
9448 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9449 (gnus-summary-save-article arg)))
9451 (defun gnus-summary-pipe-message (program)
9452 "Pipe the current article through PROGRAM."
9453 (interactive "sProgram: ")
9454 (gnus-summary-select-article)
9455 (let ((mail-header-separator ""))
9456 (gnus-eval-in-buffer-window gnus-article-buffer
9459 (let ((start (window-start))
9461 (message-pipe-buffer-body program)
9462 (set-window-start (get-buffer-window (current-buffer)) start))))))
9464 (defun gnus-get-split-value (methods)
9465 "Return a value based on the split METHODS."
9466 (let (split-name method result match)
9469 (set-buffer gnus-original-article-buffer)
9471 (nnheader-narrow-to-headers)
9472 (while (and methods (not split-name))
9473 (goto-char (point-min))
9474 (setq method (pop methods))
9475 (setq match (car method))
9478 ;; Regular expression.
9480 (re-search-forward match nil t)))
9481 ((gnus-functionp match)
9485 (setq result (funcall match gnus-newsgroup-name))))
9490 (setq result (eval match)))))
9491 (setq split-name (cdr method))
9492 (cond ((stringp result)
9493 (push (expand-file-name
9494 result gnus-article-save-directory)
9497 (setq split-name (append result split-name)))))))))
9498 (nreverse split-name)))
9500 (defun gnus-valid-move-group-p (group)
9503 (symbol-value group)
9504 (gnus-get-function (gnus-find-method-for-group
9505 (symbol-name group)) 'request-accept-article t)))
9507 (defun gnus-read-move-group-name (prompt default articles prefix)
9508 "Read a group name."
9509 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9510 (minibuffer-confirm-incomplete nil) ; XEmacs
9514 (if (> (length articles) 1)
9515 (format "these %d articles" (length articles))
9520 (gnus-completing-read default prom
9522 'gnus-valid-move-group-p
9524 'gnus-group-history))
9525 ((= 1 (length split-name))
9526 (gnus-completing-read (car split-name) prom
9528 'gnus-valid-move-group-p
9530 'gnus-group-history))
9532 (gnus-completing-read nil prom
9533 (mapcar (lambda (el) (list el))
9534 (nreverse split-name))
9536 'gnus-group-history))))
9537 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9539 (if (or (string= to-newsgroup "")
9540 (string= to-newsgroup prefix))
9541 (setq to-newsgroup default))
9542 (unless to-newsgroup
9543 (error "No group name entered"))
9544 (or (gnus-active to-newsgroup)
9545 (gnus-activate-group to-newsgroup nil nil to-method)
9546 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9548 (or (and (gnus-request-create-group to-newsgroup to-method)
9549 (gnus-activate-group
9550 to-newsgroup nil nil to-method)
9551 (gnus-subscribe-group to-newsgroup))
9552 (error "Couldn't create group %s" to-newsgroup)))
9553 (error "No such group: %s" to-newsgroup)))
9556 (defun gnus-summary-save-parts (type dir n &optional reverse)
9557 "Save parts matching TYPE to DIR.
9558 If REVERSE, save parts that do not match TYPE."
9560 (list (read-string "Save parts of type: "
9561 (or (car gnus-summary-save-parts-type-history)
9562 gnus-summary-save-parts-default-mime)
9563 'gnus-summary-save-parts-type-history)
9564 (setq gnus-summary-save-parts-last-directory
9565 (read-file-name "Save to directory: "
9566 gnus-summary-save-parts-last-directory
9568 current-prefix-arg))
9569 (gnus-summary-iterate n
9570 (let ((gnus-display-mime-function nil)
9571 (gnus-inhibit-treatment t))
9572 (gnus-summary-select-article))
9574 (set-buffer gnus-article-buffer)
9575 (let ((handles (or gnus-article-mime-handles
9576 (mm-dissect-buffer) (mm-uu-dissect))))
9578 (gnus-summary-save-parts-1 type dir handles reverse)
9579 (unless gnus-article-mime-handles ;; Don't destroy this case.
9580 (mm-destroy-parts handles)))))))
9582 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9583 (if (stringp (car handle))
9584 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9587 (not (string-match type (mm-handle-media-type handle)))
9588 (string-match type (mm-handle-media-type handle)))
9589 (let ((file (expand-file-name
9590 (file-name-nondirectory
9592 (mail-content-type-get
9593 (mm-handle-disposition handle) 'filename)
9594 (concat gnus-newsgroup-name
9595 "." (number-to-string
9596 (cdr gnus-article-current)))))
9598 (unless (file-exists-p file)
9599 (mm-save-part-to-file handle file))))))
9601 ;; Summary extract commands
9603 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9604 (let ((buffer-read-only nil)
9605 (article (gnus-summary-article-number))
9607 (unless (gnus-summary-goto-subject article)
9608 (error "No such article: %d" article))
9609 (gnus-summary-position-point)
9610 ;; If all commands are to be bunched up on one line, we collect
9612 (unless gnus-view-pseudos-separately
9613 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9616 (setq action (cdr (assq 'action (car ps))))
9617 (setq files (list (cdr (assq 'name (car ps)))))
9618 (while (and ps (cdr ps)
9619 (string= (or action "1")
9620 (or (cdr (assq 'action (cadr ps))) "2")))
9621 (push (cdr (assq 'name (cadr ps))) files)
9622 (setcdr ps (cddr ps)))
9624 (when (not (string-match "%s" action))
9627 (when (assq 'execute (car ps))
9628 (setcdr (assq 'execute (car ps))
9629 (funcall (if (string-match "%s" action)
9636 (gnus-quote-arg-for-sh-or-csh f)))
9638 (setq ps (cdr ps)))))
9639 (if (and gnus-view-pseudos (not not-view))
9641 (when (assq 'execute (car pslist))
9642 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9643 (eq gnus-view-pseudos 'not-confirm)))
9644 (setq pslist (cdr pslist)))
9647 (setq after-article (or (cdr (assq 'article (car pslist)))
9648 (gnus-summary-article-number)))
9649 (gnus-summary-goto-subject after-article)
9652 (insert " " (file-name-nondirectory
9653 (cdr (assq 'name (car pslist))))
9654 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9656 (forward-line -1) ; back to `b'
9657 (gnus-add-text-properties
9658 b (1- e) (list 'gnus-number gnus-reffed-article-number
9659 gnus-mouse-face-prop gnus-mouse-face))
9661 after-article gnus-reffed-article-number
9662 gnus-unread-mark b (car pslist) 0 (- e b))
9663 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9664 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9665 (setq pslist (cdr pslist)))))))
9667 (defun gnus-pseudos< (p1 p2)
9668 (let ((c1 (cdr (assq 'action p1)))
9669 (c2 (cdr (assq 'action p2))))
9670 (and c1 c2 (string< c1 c2))))
9672 (defun gnus-request-pseudo-article (props)
9673 (cond ((assq 'execute props)
9674 (gnus-execute-command (cdr (assq 'execute props)))))
9675 (let ((gnus-current-article (gnus-summary-article-number)))
9676 (gnus-run-hooks 'gnus-mark-article-hook)))
9678 (defun gnus-execute-command (command &optional automatic)
9680 (gnus-article-setup-buffer)
9681 (set-buffer gnus-article-buffer)
9682 (setq buffer-read-only nil)
9683 (let ((command (if automatic command
9684 (read-string "Command: " (cons command 0)))))
9686 (insert "$ " command "\n\n")
9687 (if gnus-view-pseudo-asynchronously
9688 (start-process "gnus-execute" (current-buffer) shell-file-name
9689 shell-command-switch command)
9690 (call-process shell-file-name nil t nil
9691 shell-command-switch command)))))
9693 ;; Summary kill commands.
9695 (defun gnus-summary-edit-global-kill (article)
9696 "Edit the \"global\" kill file."
9697 (interactive (list (gnus-summary-article-number)))
9698 (gnus-group-edit-global-kill article))
9700 (defun gnus-summary-edit-local-kill ()
9701 "Edit a local kill file applied to the current newsgroup."
9703 (setq gnus-current-headers (gnus-summary-article-header))
9704 (gnus-group-edit-local-kill
9705 (gnus-summary-article-number) gnus-newsgroup-name))
9709 (defun gnus-read-header (id &optional header)
9710 "Read the headers of article ID and enter them into the Gnus system."
9711 (let ((group gnus-newsgroup-name)
9712 (gnus-override-method
9714 gnus-override-method
9715 (and (gnus-news-group-p gnus-newsgroup-name)
9716 (car (gnus-refer-article-methods)))))
9718 ;; First we check to see whether the header in question is already
9721 ;; This is a Message-ID.
9722 (setq header (or header (gnus-id-to-header id)))
9723 ;; This is an article number.
9724 (setq header (or header (gnus-summary-article-header id))))
9726 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9727 ;; We have found the header.
9729 ;; If this is a sparse article, we have to nix out its
9730 ;; previous entry in the thread hashtb.
9732 (gnus-summary-article-sparse-p (mail-header-number header)))
9733 (let* ((parent (gnus-parent-id (mail-header-references header)))
9734 (thread (and parent (gnus-id-to-thread parent))))
9736 (delq (assq header thread) thread))))
9737 ;; We have to really fetch the header to this article.
9739 (set-buffer nntp-server-buffer)
9740 (when (setq where (gnus-request-head id group))
9741 (nnheader-fold-continuation-lines)
9742 (goto-char (point-max))
9744 (goto-char (point-min))
9748 ((cdr where) (cdr where))
9749 (header (mail-header-number header))
9750 (t gnus-reffed-article-number))
9752 (insert " Article retrieved.\n"))
9754 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9755 () ; Malformed head.
9756 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9757 (when (and (stringp id)
9758 (not (string= (gnus-group-real-name group)
9760 ;; If we fetched by Message-ID and the article came
9761 ;; from a different group, we fudge some bogus article
9762 ;; numbers for this article.
9763 (mail-header-set-number header gnus-reffed-article-number))
9765 (set-buffer gnus-summary-buffer)
9766 (decf gnus-reffed-article-number)
9767 (gnus-remove-header (mail-header-number header))
9768 (push header gnus-newsgroup-headers)
9769 (setq gnus-current-headers header)
9770 (push (mail-header-number header) gnus-newsgroup-limit)))
9773 (defun gnus-remove-header (number)
9774 "Remove header NUMBER from `gnus-newsgroup-headers'."
9775 (if (and gnus-newsgroup-headers
9776 (= number (mail-header-number (car gnus-newsgroup-headers))))
9777 (pop gnus-newsgroup-headers)
9778 (let ((headers gnus-newsgroup-headers))
9779 (while (and (cdr headers)
9780 (not (= number (mail-header-number (cadr headers)))))
9783 (setcdr headers (cddr headers))))))
9786 ;;; summary highlights
9789 (defun gnus-highlight-selected-summary ()
9790 "Highlight selected article in summary buffer."
9791 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9792 (when gnus-summary-selected-face
9794 (let* ((beg (progn (beginning-of-line) (point)))
9795 (end (progn (end-of-line) (point)))
9796 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9797 (from (if (get-text-property beg gnus-mouse-face-prop)
9799 (or (next-single-property-change
9800 beg gnus-mouse-face-prop nil end)
9805 (or (next-single-property-change
9806 from gnus-mouse-face-prop nil end)
9808 ;; If no mouse-face prop on line we will have to = from = end,
9809 ;; so we highlight the entire line instead.
9810 (when (= (+ to 2) from)
9813 (if gnus-newsgroup-selected-overlay
9814 ;; Move old overlay.
9816 gnus-newsgroup-selected-overlay from to (current-buffer))
9817 ;; Create new overlay.
9819 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9820 'face gnus-summary-selected-face))))))
9822 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9823 (defun gnus-summary-highlight-line ()
9824 "Highlight current line according to `gnus-summary-highlight'."
9825 (let* ((list gnus-summary-highlight)
9827 (end (progn (end-of-line) (point)))
9828 ;; now find out where the line starts and leave point there.
9829 (beg (progn (beginning-of-line) (point)))
9830 (article (gnus-summary-article-number))
9831 (score (or (cdr (assq (or article gnus-current-article)
9832 gnus-newsgroup-scored))
9833 gnus-summary-default-score 0))
9834 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9835 (inhibit-read-only t))
9836 ;; Eval the cars of the lists until we find a match.
9837 (let ((default gnus-summary-default-score))
9839 (not (eval (caar list))))
9840 (setq list (cdr list))))
9841 (let ((face (cdar list)))
9842 (unless (eq face (get-text-property beg 'face))
9843 (gnus-put-text-property-excluding-characters-with-faces
9845 (setq face (if (boundp face) (symbol-value face) face)))
9846 (when gnus-summary-highlight-line-function
9847 (funcall gnus-summary-highlight-line-function article face))))
9850 (defun gnus-update-read-articles (group unread &optional compute)
9851 "Update the list of read articles in GROUP."
9852 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9853 (entry (gnus-gethash group gnus-newsrc-hashtb))
9854 (info (nth 2 entry))
9856 (unread (sort (copy-sequence unread) '<))
9858 (if (or (not info) (not active))
9859 ;; There is no info on this group if it was, in fact,
9860 ;; killed. Gnus stores no information on killed groups, so
9861 ;; there's nothing to be done.
9862 ;; One could store the information somewhere temporarily,
9863 ;; perhaps... Hmmm...
9865 ;; Remove any negative articles numbers.
9866 (while (and unread (< (car unread) 0))
9867 (setq unread (cdr unread)))
9868 ;; Remove any expired article numbers
9869 (while (and unread (< (car unread) (car active)))
9870 (setq unread (cdr unread)))
9871 ;; Compute the ranges of read articles by looking at the list of
9874 (when (/= (car unread) prev)
9875 (push (if (= prev (1- (car unread))) prev
9876 (cons prev (1- (car unread))))
9878 (setq prev (1+ (car unread)))
9879 (setq unread (cdr unread)))
9880 (when (<= prev (cdr active))
9881 (push (cons prev (cdr active)) read))
9882 (setq read (if (> (length read) 1) (nreverse read) read))
9887 ;; Propagate the read marks to the backend.
9888 (when (gnus-check-backend-function 'request-set-mark group)
9889 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9890 (add (gnus-remove-from-range read (gnus-info-read info))))
9892 (unless (gnus-check-group group)
9893 (error "Can't open server for %s" group))
9894 (gnus-request-set-mark
9895 group (delq nil (list (if add (list add 'add '(read)))
9896 (if del (list del 'del '(read))))))
9898 `(gnus-request-set-mark
9901 (if del (list del 'add '(read)))
9902 (if add (list add 'del '(read))))))))))
9903 (set-buffer gnus-group-buffer)
9906 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9907 (gnus-info-set-read ',info ',(gnus-info-read info))
9908 (gnus-get-unread-articles-in-group ',info
9909 (gnus-active ,group))
9910 (gnus-group-update-group ,group t)
9912 ;; Enter this list into the group info.
9913 (gnus-info-set-read info read)
9914 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9915 (gnus-get-unread-articles-in-group info (gnus-active group))
9918 (defun gnus-offer-save-summaries ()
9919 "Offer to save all active summary buffers."
9921 (let ((buflist (buffer-list))
9923 ;; Go through all buffers and find all summaries.
9925 (and (setq bufname (buffer-name (car buflist)))
9926 (string-match "Summary" bufname)
9928 (set-buffer bufname)
9929 ;; We check that this is, indeed, a summary buffer.
9930 (and (eq major-mode 'gnus-summary-mode)
9931 ;; Also make sure this isn't bogus.
9932 gnus-newsgroup-prepared
9933 ;; Also make sure that this isn't a dead summary buffer.
9934 (not gnus-dead-summary-mode)))
9935 (push bufname buffers))
9936 (setq buflist (cdr buflist)))
9937 ;; Go through all these summary buffers and offer to save them.
9940 "Update summary buffer %s? "
9942 (switch-to-buffer buf)
9943 (gnus-summary-exit))
9947 ;;; @ for mime-partial
9950 (defun gnus-request-partial-message ()
9952 (let ((number (gnus-summary-article-number))
9953 (group gnus-newsgroup-name)
9954 (mother gnus-article-buffer))
9955 (set-buffer (get-buffer-create " *Partial Article*"))
9957 (setq mime-preview-buffer mother)
9958 (gnus-request-article-this-buffer number group)
9962 (autoload 'mime-combine-message/partial-pieces-automatically
9964 "Internal method to combine message/partial messages automatically.")
9967 'action '((type . message)(subtype . partial)
9968 (major-mode . gnus-original-article-mode)
9969 (method . mime-combine-message/partial-pieces-automatically)
9970 (summary-buffer-exp . gnus-summary-buffer)
9971 (request-partial-message-method . gnus-request-partial-message)
9975 ;;; @ for message/rfc822
9978 (defun gnus-mime-extract-message/rfc822 (entity situation)
9979 (let (group article num cwin swin cur)
9981 (mime-insert-entity-content entity)
9982 (setq group (or (cdr (assq 'group situation))
9983 (completing-read "Group: "
9986 (gnus-read-active-file-p)
9987 gnus-newsgroup-name))
9988 article (gnus-request-accept-article group)))
9989 (when (and (consp article)
9990 (numberp (setq article (cdr article))))
9991 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9992 cwin (get-buffer-window (current-buffer) t))
9993 (save-window-excursion
9994 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9995 (select-window swin)
9996 (set-buffer gnus-summary-buffer))
9997 (setq cur gnus-current-article)
9999 (let (gnus-show-threads)
10000 (gnus-summary-goto-subject article t))
10001 (gnus-summary-clear-mark-forward 1)
10002 (gnus-summary-goto-subject cur))
10003 (when (and cwin (window-frame cwin))
10004 (select-frame (window-frame cwin)))
10005 (when (boundp 'mime-acting-situation-to-override)
10006 (set-alist 'mime-acting-situation-to-override
10009 (set-alist 'mime-acting-situation-to-override
10012 (save-current-buffer
10013 (set-buffer gnus-group-buffer)
10014 (gnus-activate-group ,group))
10015 (gnus-summary-goto-article ,cur
10016 gnus-show-all-headers)))
10017 (set-alist 'mime-acting-situation-to-override
10020 (mime-add-condition
10021 'action '((type . message)(subtype . rfc822)
10022 (major-mode . gnus-original-article-mode)
10023 (method . gnus-mime-extract-message/rfc822)
10027 (mime-add-condition
10028 'action '((type . message)(subtype . news)
10029 (major-mode . gnus-original-article-mode)
10030 (method . gnus-mime-extract-message/rfc822)
10034 (defun gnus-mime-extract-multipart (entity situation)
10035 (let ((children (mime-entity-children entity))
10036 mime-acting-situation-to-override
10039 (mime-play-entity (car children)
10040 (cons (assq 'mode situation)
10041 mime-acting-situation-to-override))
10042 (setq children (cdr children)))
10043 (if (setq f (cdr (assq 'after-method
10044 mime-acting-situation-to-override)))
10048 (mime-add-condition
10049 'action '((type . multipart)
10050 (method . gnus-mime-extract-multipart)
10059 (defun gnus-summary-setup-default-charset ()
10060 "Setup newsgroup default charset."
10061 (if (equal gnus-newsgroup-name "nndraft:drafts")
10062 (setq gnus-newsgroup-charset nil)
10063 (let* ((name (and gnus-newsgroup-name
10064 (gnus-group-real-name gnus-newsgroup-name)))
10066 (or gnus-newsgroup-ephemeral-ignored-charsets
10068 (and gnus-newsgroup-name
10069 (or (gnus-group-find-parameter gnus-newsgroup-name
10070 'ignored-charsets t)
10071 (let ((alist gnus-group-ignored-charsets-alist)
10072 elem (charsets nil))
10073 (while (setq elem (pop alist))
10075 (string-match (car elem) name))
10077 charsets (cdr elem))))
10079 gnus-newsgroup-ignored-charsets))))
10080 (setq gnus-newsgroup-charset
10081 (or gnus-newsgroup-ephemeral-charset
10082 (and gnus-newsgroup-name
10083 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
10084 (let ((alist gnus-group-charset-alist)
10086 (while (setq elem (pop alist))
10088 (string-match (car elem) name))
10090 charset (cadr elem))))
10092 gnus-default-charset))
10093 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10094 ignored-charsets))))
10100 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10101 "Display the current article buffer fully MIME-buttonized.
10102 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10103 treated as multipart/mixed."
10105 (require 'gnus-art)
10106 (let ((gnus-unbuttonized-mime-types nil)
10107 (gnus-mime-display-multipart-as-mixed show-all-parts))
10108 (gnus-summary-show-article)))
10110 (defun gnus-summary-repair-multipart (article)
10111 "Add a Content-Type header to a multipart article without one."
10112 (interactive (list (gnus-summary-article-number)))
10113 (gnus-with-article article
10114 (message-narrow-to-head)
10115 (message-remove-header "Mime-Version")
10116 (goto-char (point-max))
10117 (insert "Mime-Version: 1.0\n")
10119 (when (search-forward "\n--" nil t)
10120 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10121 (message-narrow-to-head)
10122 (message-remove-header "Content-Type")
10123 (goto-char (point-max))
10124 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10127 (let (gnus-mark-article-hook)
10128 (gnus-summary-select-article t t nil article)))
10130 (defun gnus-summary-toggle-display-buttonized ()
10131 "Toggle the buttonizing of the article buffer."
10133 (require 'gnus-art)
10134 (if (setq gnus-inhibit-mime-unbuttonizing
10135 (not gnus-inhibit-mime-unbuttonizing))
10136 (let ((gnus-unbuttonized-mime-types nil))
10137 (gnus-summary-show-article))
10138 (gnus-summary-show-article)))
10141 ;;; Intelli-mouse commmands
10144 (defun gnus-wheel-summary-scroll (event)
10146 (let ((amount (if (memq 'shift (event-modifiers event))
10147 (car gnus-wheel-scroll-amount)
10148 (cdr gnus-wheel-scroll-amount)))
10149 (direction (- (* (static-if (featurep 'xemacs)
10150 (event-button event)
10151 (cond ((eq 'mouse-4 (event-basic-type event))
10153 ((eq 'mouse-5 (event-basic-type event))
10157 (gnus-summary-scroll-up (* amount direction))
10158 (when (gnus-eval-in-buffer-window gnus-article-buffer
10161 (and (if (< 0 direction)
10162 (gnus-article-next-page 0)
10163 (gnus-article-prev-page 0)
10165 (if (setq edge (get-text-property
10166 (point-min) 'gnus-wheel-edge))
10167 (setq edge (* edge direction))
10170 (let ((buffer-read-only nil)
10171 (inhibit-read-only t))
10172 (put-text-property (point-min) (point-max)
10173 'gnus-wheel-edge direction)
10175 (or (> edge gnus-wheel-edge-resistance)
10176 (let ((buffer-read-only nil)
10177 (inhibit-read-only t))
10178 (put-text-property (point-min) (point-max)
10180 (* (1+ edge) direction))
10182 (eq last-command 'gnus-wheel-summary-scroll))))
10183 (gnus-summary-next-article nil nil (minusp direction)))))
10185 (defun gnus-wheel-install ()
10186 "Enable mouse wheel support on summary window."
10187 (when gnus-use-wheel
10189 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10191 (define-key gnus-summary-mode-map key
10192 'gnus-wheel-summary-scroll)))))
10194 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10197 ;;; Traditional PGP commmands
10200 (defun gnus-summary-decrypt-article (&optional force)
10201 "Decrypt the current article in traditional PGP way.
10202 This will have permanent effect only in mail groups.
10203 If FORCE is non-nil, allow editing of articles even in read-only
10206 (gnus-summary-select-article t)
10207 (gnus-eval-in-buffer-window gnus-article-buffer
10211 (goto-char (point-min))
10212 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10213 (error "Not a traditional PGP message!"))
10214 (let ((armor-start (match-beginning 0)))
10215 (if (and (pgg-decrypt-region armor-start (point-max))
10216 (or force (not (gnus-group-read-only-p))))
10217 (let ((inhibit-read-only t)
10219 (delete-region armor-start
10221 (re-search-forward "^-+END PGP" nil t)
10222 (beginning-of-line 2)
10224 (insert-buffer-substring pgg-output-buffer))))))))
10226 (defun gnus-summary-verify-article ()
10227 "Verify the current article in traditional PGP way."
10230 (set-buffer gnus-original-article-buffer)
10231 (goto-char (point-min))
10232 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10233 (error "Not a traditional PGP message!"))
10234 (re-search-forward "^-+END PGP" nil t)
10235 (beginning-of-line 2)
10236 (call-interactively (function pgg-verify-region))))
10239 ;;; Generic summary marking commands
10242 (defvar gnus-summary-marking-alist
10243 '((read gnus-del-mark "d")
10244 (unread gnus-unread-mark "u")
10245 (ticked gnus-ticked-mark "!")
10246 (dormant gnus-dormant-mark "?")
10247 (expirable gnus-expirable-mark "e"))
10248 "An alist of names/marks/keystrokes.")
10250 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10251 (defvar gnus-summary-mark-map)
10253 (defun gnus-summary-make-all-marking-commands ()
10254 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10255 (dolist (elem gnus-summary-marking-alist)
10256 (apply 'gnus-summary-make-marking-command elem)))
10258 (defun gnus-summary-make-marking-command (name mark keystroke)
10259 (let ((map (make-sparse-keymap)))
10260 (define-key gnus-summary-generic-mark-map keystroke map)
10261 (dolist (lway `((next "next" next nil "n")
10262 (next-unread "next unread" next t "N")
10263 (prev "previous" prev nil "p")
10264 (prev-unread "previous unread" prev t "P")
10265 (nomove "" nil nil ,keystroke)))
10266 (let ((func (gnus-summary-make-marking-command-1
10267 mark (car lway) lway name)))
10268 (setq func (eval func))
10269 (define-key map (nth 4 lway) func)))))
10271 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10273 (format "gnus-summary-put-mark-as-%s%s"
10274 name (if (eq way 'nomove)
10276 (concat "-" (symbol-name way)))))
10279 "Mark the current article as %s%s.
10280 If N, the prefix, then repeat N times.
10281 If N is negative, move in reverse order.
10282 The difference between N and the actual number of articles marked is
10284 name (car (cdr lway)))
10286 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10288 (defun gnus-summary-generic-mark (n mark move unread)
10289 "Mark N articles with MARK."
10290 (unless (eq major-mode 'gnus-summary-mode)
10291 (error "This command can only be used in the summary buffer"))
10292 (gnus-summary-show-thread)
10295 ((eq move 'next) 1)
10296 ((eq move 'prev) -1)
10298 (if (zerop nummove)
10302 nummove (* -1 nummove))))
10303 (while (and (> n 0)
10304 (gnus-summary-mark-article nil mark)
10305 (zerop (gnus-summary-next-subject nummove unread t)))
10308 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10309 (gnus-summary-recenter)
10310 (gnus-summary-position-point)
10311 (gnus-set-mode-line 'summary)
10314 (gnus-summary-make-all-marking-commands)
10316 (gnus-ems-redefine)
10318 (provide 'gnus-sum)
10320 (run-hooks 'gnus-sum-load-hook)
10322 ;;; gnus-sum.el ends here