1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include: `gnus-simplify-subject-re',
151 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
153 :type '(repeat function))
155 (defcustom gnus-simplify-ignored-prefixes nil
156 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
158 :type '(choice (const :tag "off" nil)
161 (defcustom gnus-build-sparse-threads nil
162 "*If non-nil, fill in the gaps in threads.
163 If `some', only fill in the gaps that are needed to tie loose threads
164 together. If `more', fill in all leaf nodes that Gnus can find. If
165 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
167 :type '(choice (const :tag "off" nil)
170 (sexp :menu-tag "all" t)))
172 (defcustom gnus-summary-thread-gathering-function
173 'gnus-gather-threads-by-subject
174 "*Function used for gathering loose threads.
175 There are two pre-defined functions: `gnus-gather-threads-by-subject',
176 which only takes Subjects into consideration; and
177 `gnus-gather-threads-by-references', which compared the References
178 headers of the articles to find matches."
180 :type '(radio (function-item gnus-gather-threads-by-subject)
181 (function-item gnus-gather-threads-by-references)
182 (function :tag "other")))
184 (defcustom gnus-summary-same-subject ""
185 "*String indicating that the current article has the same subject as the previous.
186 This variable will only be used if the value of
187 `gnus-summary-make-false-root' is `empty'."
188 :group 'gnus-summary-format
191 (defcustom gnus-summary-goto-unread t
192 "*If t, many commands will go to the next unread article.
193 This applies to marking commands as well as other commands that
194 \"naturally\" select the next article, like, for instance, `SPC' at
195 the end of an article.
197 If nil, the marking commands do NOT go to the next unread article
198 (they go to the next article instead). If `never', commands that
199 usually go to the next unread article, will go to the next article,
200 whether it is read or not."
201 :group 'gnus-summary-marks
202 :link '(custom-manual "(gnus)Setting Marks")
203 :type '(choice (const :tag "off" nil)
205 (sexp :menu-tag "on" t)))
207 (defcustom gnus-summary-default-score 0
208 "*Default article score level.
209 All scores generated by the score files will be added to this score.
210 If this variable is nil, scoring will be disabled."
211 :group 'gnus-score-default
212 :type '(choice (const :tag "disable")
215 (defcustom gnus-summary-default-high-score 0
216 "*Default threshold for a high scored article.
217 An article will be highlighted as high scored if its score is greater
219 :group 'gnus-score-default
222 (defcustom gnus-summary-default-low-score 0
223 "*Default threshold for a low scored article.
224 An article will be highlighted as low scored if its score is smaller
226 :group 'gnus-score-default
229 (defcustom gnus-summary-zcore-fuzz 0
230 "*Fuzziness factor for the zcore in the summary buffer.
231 Articles with scores closer than this to `gnus-summary-default-score'
233 :group 'gnus-summary-format
236 (defcustom gnus-simplify-subject-fuzzy-regexp nil
237 "*Strings to be removed when doing fuzzy matches.
238 This can either be a regular expression or list of regular expressions
239 that will be removed from subject strings if fuzzy subject
240 simplification is selected."
242 :type '(repeat regexp))
244 (defcustom gnus-show-threads t
245 "*If non-nil, display threads in summary mode."
249 (defcustom gnus-thread-hide-subtree nil
250 "*If non-nil, hide all threads initially.
251 This can be a predicate specifier which says which threads to hide.
252 If threads are hidden, you have to run the command
253 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
254 to expose hidden threads."
258 (defcustom gnus-thread-hide-killed t
259 "*If non-nil, hide killed threads automatically."
263 (defcustom gnus-thread-ignore-subject t
264 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
265 If nil, articles that have different subjects from their parents will
266 start separate threads."
270 (defcustom gnus-thread-operation-ignore-subject t
271 "*If non-nil, subjects will be ignored when doing thread commands.
272 This affects commands like `gnus-summary-kill-thread' and
273 `gnus-summary-lower-thread'.
275 If this variable is nil, articles in the same thread with different
276 subjects will not be included in the operation in question. If this
277 variable is `fuzzy', only articles that have subjects that are fuzzily
278 equal will be included."
280 :type '(choice (const :tag "off" nil)
284 (defcustom gnus-thread-indent-level 4
285 "*Number that says how much each sub-thread should be indented."
289 (defcustom gnus-auto-extend-newsgroup t
290 "*If non-nil, extend newsgroup forward and backward when requested."
291 :group 'gnus-summary-choose
294 (defcustom gnus-auto-select-first t
295 "*If non-nil, select the article under point.
296 Which article this is is controlled by the `gnus-auto-select-subject'
299 If you want to prevent automatic selection of articles in some
300 newsgroups, set the variable to nil in `gnus-select-group-hook'."
301 :group 'gnus-group-select
302 :type '(choice (const :tag "none" nil)
303 (sexp :menu-tag "first" t)))
305 (defcustom gnus-auto-select-subject 'unread
306 "*Says what subject to place under point when entering a group.
308 This variable can either be the symbols `first' (place point on the
309 first subject), `unread' (place point on the subject line of the first
310 unread article), `best' (place point on the subject line of the
311 higest-scored article), `unseen' (place point on the subject line of
312 the first unseen article), 'unseen-or-unread' (place point on the subject
313 line of the first unseen article or, if all article have been seen, on the
314 subject line of the first unread article), or a function to be called to
315 place point on some subject line."
316 :group 'gnus-group-select
317 :type '(choice (const best)
321 (const unseen-or-unread)))
323 (defcustom gnus-dont-select-after-jump-to-other-group nil
324 "If non-nil, don't select the first unread article after entering the
325 other group by the command `gnus-summary-jump-to-other-group'. If nil,
326 it is depend on the value of `gnus-auto-select-first' whether to select
328 :group 'gnus-group-select
331 (defcustom gnus-auto-select-next t
332 "*If non-nil, offer to go to the next group from the end of the previous.
333 If the value is t and the next newsgroup is empty, Gnus will exit
334 summary mode and go back to group mode. If the value is neither nil
335 nor t, Gnus will select the following unread newsgroup. In
336 particular, if the value is the symbol `quietly', the next unread
337 newsgroup will be selected without any confirmation, and if it is
338 `almost-quietly', the next group will be selected without any
339 confirmation if you are located on the last article in the group.
340 Finally, if this variable is `slightly-quietly', the `Z n' command
341 will go to the next group without confirmation."
342 :group 'gnus-summary-maneuvering
343 :type '(choice (const :tag "off" nil)
345 (const almost-quietly)
346 (const slightly-quietly)
347 (sexp :menu-tag "on" t)))
349 (defcustom gnus-auto-select-same nil
350 "*If non-nil, select the next article with the same subject.
351 If there are no more articles with the same subject, go to
352 the first unread article."
353 :group 'gnus-summary-maneuvering
356 (defcustom gnus-summary-check-current nil
357 "*If non-nil, consider the current article when moving.
358 The \"unread\" movement commands will stay on the same line if the
359 current article is unread."
360 :group 'gnus-summary-maneuvering
363 (defcustom gnus-auto-center-summary t
364 "*If non-nil, always center the current summary buffer.
365 In particular, if `vertical' do only vertical recentering. If non-nil
366 and non-`vertical', do both horizontal and vertical recentering."
367 :group 'gnus-summary-maneuvering
368 :type '(choice (const :tag "none" nil)
370 (integer :tag "height")
371 (sexp :menu-tag "both" t)))
373 (defcustom gnus-show-all-headers nil
374 "*If non-nil, don't hide any headers."
375 :group 'gnus-article-hiding
376 :group 'gnus-article-headers
379 (defcustom gnus-summary-ignore-duplicates nil
380 "*If non-nil, ignore articles with identical Message-ID headers."
384 (defcustom gnus-single-article-buffer t
385 "*If non-nil, display all articles in the same buffer.
386 If nil, each group will get its own article buffer."
387 :group 'gnus-article-various
390 (defcustom gnus-break-pages t
391 "*If non-nil, do page breaking on articles.
392 The page delimiter is specified by the `gnus-page-delimiter'
394 :group 'gnus-article-various
397 (defcustom gnus-show-mime t
398 "*If non-nil, do mime processing of articles.
399 The articles will simply be fed to the function given by
400 `gnus-article-display-method-for-mime'."
401 :group 'gnus-article-mime
404 (defcustom gnus-move-split-methods nil
405 "*Variable used to suggest where articles are to be moved to.
406 It uses the same syntax as the `gnus-split-methods' variable.
407 However, whereas `gnus-split-methods' specifies file names as targets,
408 this variable specifies group names."
409 :group 'gnus-summary-mail
410 :type '(repeat (choice (list :value (fun) function)
411 (cons :value ("" "") regexp (repeat string))
414 (defcustom gnus-unread-mark ?\ ;;;Whitespace
415 "*Mark used for unread articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-ticked-mark ?!
420 "*Mark used for ticked articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-dormant-mark ??
425 "*Mark used for dormant articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-del-mark ?r
430 "*Mark used for del'd articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-read-mark ?R
435 "*Mark used for read articles."
436 :group 'gnus-summary-marks
439 (defcustom gnus-expirable-mark ?E
440 "*Mark used for expirable articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-killed-mark ?K
445 "*Mark used for killed articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-spam-mark ?H
450 "*Mark used for spam articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-souped-mark ?F
455 "*Mark used for souped articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-kill-file-mark ?X
460 "*Mark used for articles killed by kill files."
461 :group 'gnus-summary-marks
464 (defcustom gnus-low-score-mark ?Y
465 "*Mark used for articles with a low score."
466 :group 'gnus-summary-marks
469 (defcustom gnus-catchup-mark ?C
470 "*Mark used for articles that are caught up."
471 :group 'gnus-summary-marks
474 (defcustom gnus-replied-mark ?A
475 "*Mark used for articles that have been replied to."
476 :group 'gnus-summary-marks
479 (defcustom gnus-forwarded-mark ?F
480 "*Mark used for articles that have been forwarded."
481 :group 'gnus-summary-marks
484 (defcustom gnus-recent-mark ?N
485 "*Mark used for articles that are recent."
486 :group 'gnus-summary-marks
489 (defcustom gnus-cached-mark ?*
490 "*Mark used for articles that are in the cache."
491 :group 'gnus-summary-marks
494 (defcustom gnus-saved-mark ?S
495 "*Mark used for articles that have been saved."
496 :group 'gnus-summary-marks
499 (defcustom gnus-unseen-mark ?.
500 "*Mark used for articles that haven't been seen."
501 :group 'gnus-summary-marks
504 (defcustom gnus-no-mark ?\ ;;;Whitespace
505 "*Mark used for articles that have no other secondary mark."
506 :group 'gnus-summary-marks
509 (defcustom gnus-ancient-mark ?O
510 "*Mark used for ancient articles."
511 :group 'gnus-summary-marks
514 (defcustom gnus-sparse-mark ?Q
515 "*Mark used for sparsely reffed articles."
516 :group 'gnus-summary-marks
519 (defcustom gnus-canceled-mark ?G
520 "*Mark used for canceled articles."
521 :group 'gnus-summary-marks
524 (defcustom gnus-duplicate-mark ?M
525 "*Mark used for duplicate articles."
526 :group 'gnus-summary-marks
529 (defcustom gnus-undownloaded-mark ?@
530 "*Mark used for articles that weren't downloaded."
531 :group 'gnus-summary-marks
534 (defcustom gnus-downloadable-mark ?%
535 "*Mark used for articles that are to be downloaded."
536 :group 'gnus-summary-marks
539 (defcustom gnus-unsendable-mark ?=
540 "*Mark used for articles that won't be sent."
541 :group 'gnus-summary-marks
544 (defcustom gnus-score-over-mark ?+
545 "*Score mark used for articles with high scores."
546 :group 'gnus-summary-marks
549 (defcustom gnus-score-below-mark ?-
550 "*Score mark used for articles with low scores."
551 :group 'gnus-summary-marks
554 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
555 "*There is no thread under the article."
556 :group 'gnus-summary-marks
559 (defcustom gnus-not-empty-thread-mark ?=
560 "*There is a thread under the article."
561 :group 'gnus-summary-marks
564 (defcustom gnus-view-pseudo-asynchronously nil
565 "*If non-nil, Gnus will view pseudo-articles asynchronously."
566 :group 'gnus-extract-view
569 (defcustom gnus-auto-expirable-marks
570 (list gnus-spam-mark gnus-killed-mark gnus-del-mark gnus-catchup-mark
571 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
572 gnus-souped-mark gnus-duplicate-mark)
573 "*The list of marks converted into expiration if a group is auto-expirable."
576 :type '(repeat character))
578 (defcustom gnus-inhibit-user-auto-expire t
579 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
584 (defcustom gnus-view-pseudos nil
585 "*If `automatic', pseudo-articles will be viewed automatically.
586 If `not-confirm', pseudos will be viewed automatically, and the user
587 will not be asked to confirm the command."
588 :group 'gnus-extract-view
589 :type '(choice (const :tag "off" nil)
591 (const not-confirm)))
593 (defcustom gnus-view-pseudos-separately t
594 "*If non-nil, one pseudo-article will be created for each file to be viewed.
595 If nil, all files that use the same viewing command will be given as a
596 list of parameters to that command."
597 :group 'gnus-extract-view
600 (defcustom gnus-insert-pseudo-articles t
601 "*If non-nil, insert pseudo-articles when decoding articles."
602 :group 'gnus-extract-view
605 (defcustom gnus-summary-dummy-line-format
607 "*The format specification for the dummy roots in the summary buffer.
608 It works along the same lines as a normal formatting string,
609 with some simple extensions.
613 General format specifiers can also be used.
614 See `(gnus)Formatting Variables'."
615 :link '(custom-manual "(gnus)Formatting Variables")
616 :group 'gnus-threading
619 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
620 "*The format specification for the summary mode line.
621 It works along the same lines as a normal formatting string,
622 with some simple extensions:
625 %p Unprefixed group name
626 %A Current article number
627 %z Current article score
629 %U Number of unread articles in the group
630 %e Number of unselected articles in the group
631 %Z A string with unread/unselected article counts
632 %g Shortish group name
633 %S Subject of the current article
635 %s Current score file name
636 %d Number of dormant articles
637 %r Number of articles that have been marked as read in this session
638 %E Number of articles expunged by the score files"
639 :group 'gnus-summary-format
642 (defcustom gnus-list-identifiers nil
643 "Regexp that matches list identifiers to be removed from subject.
644 This can also be a list of regexps."
646 :group 'gnus-summary-format
647 :group 'gnus-article-hiding
648 :type '(choice (const :tag "none" nil)
650 (repeat :value (".*") regexp)))
652 (defcustom gnus-summary-mark-below 0
653 "*Mark all articles with a score below this variable as read.
654 This variable is local to each summary buffer and usually set by the
656 :group 'gnus-score-default
659 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
660 "*List of functions used for sorting articles in the summary buffer.
662 Each function takes two articles and returns non-nil if the first
663 article should be sorted before the other. If you use more than one
664 function, the primary sort function should be the last. You should
665 probably always include `gnus-article-sort-by-number' in the list of
666 sorting functions -- preferably first. Also note that sorting by date
667 is often much slower than sorting by number, and the sorting order is
668 very similar. (Sorting by date means sorting by the time the message
669 was sent, sorting by number means sorting by arrival time.)
671 Ready-made functions include `gnus-article-sort-by-number',
672 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
673 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
675 When threading is turned on, the variable `gnus-thread-sort-functions'
676 controls how articles are sorted."
677 :group 'gnus-summary-sort
678 :type '(repeat (choice (function-item gnus-article-sort-by-number)
679 (function-item gnus-article-sort-by-author)
680 (function-item gnus-article-sort-by-subject)
681 (function-item gnus-article-sort-by-date)
682 (function-item gnus-article-sort-by-score)
683 (function :tag "other"))))
685 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
686 "*List of functions used for sorting threads in the summary buffer.
687 By default, threads are sorted by article number.
689 Each function takes two threads and returns non-nil if the first
690 thread should be sorted before the other. If you use more than one
691 function, the primary sort function should be the last. You should
692 probably always include `gnus-thread-sort-by-number' in the list of
693 sorting functions -- preferably first. Also note that sorting by date
694 is often much slower than sorting by number, and the sorting order is
695 very similar. (Sorting by date means sorting by the time the message
696 was sent, sorting by number means sorting by arrival time.)
698 Ready-made functions include `gnus-thread-sort-by-number',
699 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
700 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
701 `gnus-thread-sort-by-most-recent-number',
702 `gnus-thread-sort-by-most-recent-date', and
703 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
705 When threading is turned off, the variable
706 `gnus-article-sort-functions' controls how articles are sorted."
707 :group 'gnus-summary-sort
708 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
709 (function-item gnus-thread-sort-by-author)
710 (function-item gnus-thread-sort-by-subject)
711 (function-item gnus-thread-sort-by-date)
712 (function-item gnus-thread-sort-by-score)
713 (function-item gnus-thread-sort-by-total-score)
714 (function :tag "other"))))
716 (defcustom gnus-thread-score-function '+
717 "*Function used for calculating the total score of a thread.
719 The function is called with the scores of the article and each
720 subthread and should then return the score of the thread.
722 Some functions you can use are `+', `max', or `min'."
723 :group 'gnus-summary-sort
726 (defcustom gnus-summary-expunge-below nil
727 "All articles that have a score less than this variable will be expunged.
728 This variable is local to the summary buffers."
729 :group 'gnus-score-default
730 :type '(choice (const :tag "off" nil)
733 (defcustom gnus-thread-expunge-below nil
734 "All threads that have a total score less than this variable will be expunged.
735 See `gnus-thread-score-function' for en explanation of what a
738 This variable is local to the summary buffers."
739 :group 'gnus-threading
740 :group 'gnus-score-default
741 :type '(choice (const :tag "off" nil)
744 (defcustom gnus-summary-mode-hook nil
745 "*A hook for Gnus summary mode.
746 This hook is run before any variables are set in the summary buffer."
747 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
748 :group 'gnus-summary-various
751 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
752 (when (featurep 'xemacs)
753 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
754 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
755 (add-hook 'gnus-summary-mode-hook
756 'gnus-xmas-switch-horizontal-scrollbar-off))
758 (defcustom gnus-summary-menu-hook nil
759 "*Hook run after the creation of the summary mode menu."
760 :group 'gnus-summary-visual
763 (defcustom gnus-summary-exit-hook nil
764 "*A hook called on exit from the summary buffer.
765 It will be called with point in the group buffer."
766 :group 'gnus-summary-exit
769 (defcustom gnus-summary-prepare-hook nil
770 "*A hook called after the summary buffer has been generated.
771 If you want to modify the summary buffer, you can use this hook."
772 :group 'gnus-summary-various
775 (defcustom gnus-summary-prepared-hook nil
776 "*A hook called as the last thing after the summary buffer has been generated."
777 :group 'gnus-summary-various
780 (defcustom gnus-summary-generate-hook nil
781 "*A hook run just before generating the summary buffer.
782 This hook is commonly used to customize threading variables and the
784 :group 'gnus-summary-various
787 (defcustom gnus-select-group-hook nil
788 "*A hook called when a newsgroup is selected.
790 If you'd like to simplify subjects like the
791 `gnus-summary-next-same-subject' command does, you can use the
794 (add-hook gnus-select-group-hook
796 (mapcar (lambda (header)
797 (mail-header-set-subject
799 (gnus-simplify-subject
800 (mail-header-subject header) 're-only)))
801 gnus-newsgroup-headers)))"
802 :group 'gnus-group-select
805 (defcustom gnus-select-article-hook nil
806 "*A hook called when an article is selected."
807 :group 'gnus-summary-choose
810 (defcustom gnus-visual-mark-article-hook
811 (list 'gnus-highlight-selected-summary)
812 "*Hook run after selecting an article in the summary buffer.
813 It is meant to be used for highlighting the article in some way. It
814 is not run if `gnus-visual' is nil."
815 :group 'gnus-summary-visual
818 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
819 "*A hook called before parsing the headers."
823 (defcustom gnus-exit-group-hook nil
824 "*A hook called when exiting summary mode.
825 This hook is not called from the non-updating exit commands like `Q'."
829 (defcustom gnus-summary-update-hook
830 (list 'gnus-summary-highlight-line)
831 "*A hook called when a summary line is changed.
832 The hook will not be called if `gnus-visual' is nil.
834 The default function `gnus-summary-highlight-line' will
835 highlight the line according to the `gnus-summary-highlight'
837 :group 'gnus-summary-visual
840 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
841 "*A hook called when an article is selected for the first time.
842 The hook is intended to mark an article as read (or unread)
843 automatically when it is selected."
844 :group 'gnus-summary-choose
847 (defcustom gnus-group-no-more-groups-hook nil
848 "*A hook run when returning to group mode having no more (unread) groups."
849 :group 'gnus-group-select
852 (defcustom gnus-ps-print-hook nil
853 "*A hook run before ps-printing something from Gnus."
857 (defcustom gnus-summary-display-arrow
858 (and (fboundp 'display-graphic-p)
860 "*If non-nil, display an arrow highlighting the current article."
865 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
866 "Face used for highlighting the current article in the summary buffer."
867 :group 'gnus-summary-visual
870 (defcustom gnus-summary-highlight
871 '(((eq mark gnus-canceled-mark)
872 . gnus-summary-cancelled-face)
873 ((and (> score default-high)
874 (or (eq mark gnus-dormant-mark)
875 (eq mark gnus-ticked-mark)))
876 . gnus-summary-high-ticked-face)
877 ((and (< score default-low)
878 (or (eq mark gnus-dormant-mark)
879 (eq mark gnus-ticked-mark)))
880 . gnus-summary-low-ticked-face)
881 ((or (eq mark gnus-dormant-mark)
882 (eq mark gnus-ticked-mark))
883 . gnus-summary-normal-ticked-face)
884 ((and (> score default-high) (eq mark gnus-ancient-mark))
885 . gnus-summary-high-ancient-face)
886 ((and (< score default-low) (eq mark gnus-ancient-mark))
887 . gnus-summary-low-ancient-face)
888 ((eq mark gnus-ancient-mark)
889 . gnus-summary-normal-ancient-face)
890 ((and (> score default-high) (eq mark gnus-unread-mark))
891 . gnus-summary-high-unread-face)
892 ((and (< score default-low) (eq mark gnus-unread-mark))
893 . gnus-summary-low-unread-face)
894 ((eq mark gnus-unread-mark)
895 . gnus-summary-normal-unread-face)
896 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
897 gnus-undownloaded-mark)))
898 . gnus-summary-high-unread-face)
899 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
900 gnus-undownloaded-mark)))
901 . gnus-summary-low-unread-face)
902 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
903 (memq article gnus-newsgroup-unreads))
904 . gnus-summary-normal-unread-face)
905 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
906 . gnus-summary-normal-read-face)
907 ((> score default-high)
908 . gnus-summary-high-read-face)
909 ((< score default-low)
910 . gnus-summary-low-read-face)
912 . gnus-summary-normal-read-face))
913 "*Controls the highlighting of summary buffer lines.
915 A list of (FORM . FACE) pairs. When deciding how a a particular
916 summary line should be displayed, each form is evaluated. The content
917 of the face field after the first true form is used. You can change
918 how those summary lines are displayed, by editing the face field.
920 You can use the following variables in the FORM field.
922 score: The article's score
923 default: The default article score.
924 default-high: The default score for high scored articles.
925 default-low: The default score for low scored articles.
926 below: The score below which articles are automatically marked as read.
927 mark: The articles mark."
928 :group 'gnus-summary-visual
929 :type '(repeat (cons (sexp :tag "Form" nil)
932 (defcustom gnus-alter-header-function nil
933 "Function called to allow alteration of article header structures.
934 The function is called with one parameter, the article header vector,
935 which it may alter in any way.")
937 (defvar gnus-decode-encoded-word-function
938 (mime-find-field-decoder 'From 'nov)
939 "Variable that says which function should be used to decode a string with encoded words.")
941 (defcustom gnus-extra-headers '(To Newsgroups)
942 "*Extra headers to parse."
945 :type '(repeat symbol))
947 (defcustom gnus-ignored-from-addresses
948 (and user-mail-address (regexp-quote user-mail-address))
949 "*Regexp of From headers that may be suppressed in favor of To headers."
954 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
955 "List of charsets that should be ignored.
956 When these charsets are used in the \"charset\" parameter, the
957 default charset will be used instead."
959 :type '(repeat symbol)
960 :group 'gnus-charset)
962 (gnus-define-group-parameter
966 "Return the ignored charsets of GROUP."
967 :variable gnus-group-ignored-charsets-alist
969 '(("alt\\.chinese\\.text" iso-8859-1))
971 "Alist of regexps (to match group names) and charsets that should be ignored.
972 When these charsets are used in the \"charset\" parameter, the
973 default charset will be used instead."
974 :variable-group gnus-charset
975 :variable-type '(repeat (cons (regexp :tag "Group")
977 :parameter-type '(choice :tag "Ignored charsets"
980 :parameter-document "\
981 List of charsets that should be ignored.
983 When these charsets are used in the \"charset\" parameter, the
984 default charset will be used instead.")
986 (defcustom gnus-group-highlight-words-alist nil
987 "Alist of group regexps and highlight regexps.
988 This variable uses the same syntax as `gnus-emphasis-alist'."
990 :type '(repeat (cons (regexp :tag "Group")
991 (repeat (list (regexp :tag "Highlight regexp")
992 (number :tag "Group for entire word" 0)
993 (number :tag "Group for displayed part" 0)
995 gnus-emphasis-highlight-words)))))
996 :group 'gnus-summary-visual)
998 (defcustom gnus-use-wheel nil
999 "Use Intelli-mouse on summary movement"
1001 :group 'gnus-summary-maneuvering)
1003 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1004 "Amount to scroll messages by spinning the mouse wheel.
1005 This is actually a cons cell, where the first item is the amount to scroll
1006 on a normal wheel event, and the second is the amount to scroll when the
1007 wheel is moved with the shift key depressed."
1008 :type '(cons (integer :tag "Shift") integer)
1009 :group 'gnus-summary-maneuvering)
1011 (defcustom gnus-wheel-edge-resistance 2
1012 "How hard it should be to change the current article
1013 by moving the mouse over the edge of the article window."
1015 :group 'gnus-summary-maneuvering)
1017 (defcustom gnus-summary-show-article-charset-alist
1019 "Alist of number and charset.
1020 The article will be shown with the charset corresponding to the
1022 For example: ((1 . cn-gb-2312) (2 . big5))."
1024 :type '(repeat (cons (number :tag "Argument" 1)
1025 (symbol :tag "Charset")))
1026 :group 'gnus-charset)
1028 (defcustom gnus-preserve-marks t
1029 "Whether marks are preserved when moving, copying and respooling messages."
1032 :group 'gnus-summary-marks)
1034 (defcustom gnus-alter-articles-to-read-function nil
1035 "Function to be called to alter the list of articles to be selected."
1036 :type '(choice (const nil) function)
1037 :group 'gnus-summary)
1039 (defcustom gnus-orphan-score nil
1040 "*All orphans get this score added. Set in the score file."
1041 :group 'gnus-score-default
1042 :type '(choice (const nil)
1045 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1046 "*A regexp to match MIME parts when saving multiple parts of a message
1047 with gnus-summary-save-parts (X m). This regexp will be used by default
1048 when prompting the user for which type of files to save."
1049 :group 'gnus-summary
1052 (defcustom gnus-read-all-available-headers nil
1053 "Whether Gnus should parse all headers made available to it.
1054 This is mostly relevant for slow backends where the user may
1055 wish to widen the summary buffer to include all headers
1056 that were fetched. Say, for nnultimate groups."
1057 :group 'gnus-summary
1058 :type '(choice boolean regexp))
1060 (defcustom gnus-summary-muttprint-program "muttprint"
1061 "Command (and optional arguments) used to run Muttprint."
1063 :group 'gnus-summary
1066 (defcustom gnus-article-loose-mime nil
1067 "If non-nil, don't require MIME-Version header.
1068 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1069 supply the MIME-Version header or deliberately strip it From the mail.
1070 Set it to non-nil, Gnus will treat some articles as MIME even if
1071 the MIME-Version header is missed."
1074 :group 'gnus-article)
1076 ;;; Internal variables
1078 (defvar gnus-summary-display-cache nil)
1079 (defvar gnus-article-mime-handles nil)
1080 (defvar gnus-article-decoded-p nil)
1081 (defvar gnus-article-charset nil)
1082 (defvar gnus-article-ignored-charsets nil)
1083 (defvar gnus-scores-exclude-files nil)
1084 (defvar gnus-page-broken nil)
1085 (defvar gnus-inhibit-mime-unbuttonizing nil)
1087 (defvar gnus-original-article nil)
1088 (defvar gnus-article-internal-prepare-hook nil)
1089 (defvar gnus-newsgroup-process-stack nil)
1091 (defvar gnus-thread-indent-array nil)
1092 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1093 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1094 "Function called to sort the articles within a thread after it has been gathered together.")
1096 (defvar gnus-summary-save-parts-type-history nil)
1097 (defvar gnus-summary-save-parts-last-directory nil)
1099 ;; Avoid highlighting in kill files.
1100 (defvar gnus-summary-inhibit-highlight nil)
1101 (defvar gnus-newsgroup-selected-overlay nil)
1102 (defvar gnus-inhibit-limiting nil)
1103 (defvar gnus-newsgroup-adaptive-score-file nil)
1104 (defvar gnus-current-score-file nil)
1105 (defvar gnus-current-move-group nil)
1106 (defvar gnus-current-copy-group nil)
1107 (defvar gnus-current-crosspost-group nil)
1108 (defvar gnus-newsgroup-display nil)
1110 (defvar gnus-newsgroup-dependencies nil)
1111 (defvar gnus-newsgroup-adaptive nil)
1112 (defvar gnus-summary-display-article-function nil)
1113 (defvar gnus-summary-highlight-line-function nil
1114 "Function called after highlighting a summary line.")
1116 (defvar gnus-summary-line-format-alist
1117 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1118 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1119 (?s gnus-tmp-subject-or-nil ?s)
1120 (?n gnus-tmp-name ?s)
1121 (?A (std11-address-string
1122 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1123 (?a (or (std11-full-name-string
1124 (car (mime-entity-read-field gnus-tmp-header 'From)))
1126 (?F gnus-tmp-from ?s)
1127 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1128 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1129 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1130 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1131 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1132 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1133 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1134 (?L gnus-tmp-lines ?s)
1135 (?I gnus-tmp-indentation ?s)
1136 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1137 (?R gnus-tmp-replied ?c)
1138 (?\[ gnus-tmp-opening-bracket ?c)
1139 (?\] gnus-tmp-closing-bracket ?c)
1140 (?\> (make-string gnus-tmp-level ? ) ?s)
1141 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1142 (?i gnus-tmp-score ?d)
1143 (?z gnus-tmp-score-char ?c)
1144 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1145 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1146 (?U gnus-tmp-unread ?c)
1147 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1149 (?t (gnus-summary-number-of-articles-in-thread
1150 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1152 (?e (gnus-summary-number-of-articles-in-thread
1153 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1155 (?u gnus-tmp-user-defined ?s)
1156 (?P (gnus-pick-line-number) ?d)
1157 (?B gnus-tmp-thread-tree-header-string ?s)
1158 (user-date (gnus-user-date
1159 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1160 "An alist of format specifications that can appear in summary lines.
1161 These are paired with what variables they correspond with, along with
1162 the type of the variable (string, integer, character, etc).")
1164 (defvar gnus-summary-dummy-line-format-alist
1165 `((?S gnus-tmp-subject ?s)
1166 (?N gnus-tmp-number ?d)
1167 (?u gnus-tmp-user-defined ?s)))
1169 (defvar gnus-summary-mode-line-format-alist
1170 `((?G gnus-tmp-group-name ?s)
1171 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1172 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1173 (?A gnus-tmp-article-number ?d)
1174 (?Z gnus-tmp-unread-and-unselected ?s)
1175 (?V gnus-version ?s)
1176 (?U gnus-tmp-unread-and-unticked ?d)
1177 (?S gnus-tmp-subject ?s)
1178 (?e gnus-tmp-unselected ?d)
1179 (?u gnus-tmp-user-defined ?s)
1180 (?d (length gnus-newsgroup-dormant) ?d)
1181 (?t (length gnus-newsgroup-marked) ?d)
1182 (?r (length gnus-newsgroup-reads) ?d)
1183 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1184 (?E gnus-newsgroup-expunged-tally ?d)
1185 (?s (gnus-current-score-file-nondirectory) ?s)))
1187 (defvar gnus-last-search-regexp nil
1188 "Default regexp for article search command.")
1190 (defvar gnus-summary-search-article-matched-data nil
1191 "Last matched data of article search command. It is the local variable
1192 in `gnus-article-buffer' which consists of the list of start position,
1193 end position and text.")
1195 (defvar gnus-last-shell-command nil
1196 "Default shell command on article.")
1198 (defvar gnus-newsgroup-begin nil)
1199 (defvar gnus-newsgroup-end nil)
1200 (defvar gnus-newsgroup-last-rmail nil)
1201 (defvar gnus-newsgroup-last-mail nil)
1202 (defvar gnus-newsgroup-last-folder nil)
1203 (defvar gnus-newsgroup-last-file nil)
1204 (defvar gnus-newsgroup-auto-expire nil)
1205 (defvar gnus-newsgroup-active nil)
1207 (defvar gnus-newsgroup-data nil)
1208 (defvar gnus-newsgroup-data-reverse nil)
1209 (defvar gnus-newsgroup-limit nil)
1210 (defvar gnus-newsgroup-limits nil)
1212 (defvar gnus-newsgroup-unreads nil
1213 "Sorted list of unread articles in the current newsgroup.")
1215 (defvar gnus-newsgroup-unselected nil
1216 "Sorted list of unselected unread articles in the current newsgroup.")
1218 (defvar gnus-newsgroup-reads nil
1219 "Alist of read articles and article marks in the current newsgroup.")
1221 (defvar gnus-newsgroup-expunged-tally nil)
1223 (defvar gnus-newsgroup-marked nil
1224 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1226 (defvar gnus-newsgroup-killed nil
1227 "List of ranges of articles that have been through the scoring process.")
1229 (defvar gnus-newsgroup-cached nil
1230 "Sorted list of articles that come from the article cache.")
1232 (defvar gnus-newsgroup-saved nil
1233 "List of articles that have been saved.")
1235 (defvar gnus-newsgroup-kill-headers nil)
1237 (defvar gnus-newsgroup-replied nil
1238 "List of articles that have been replied to in the current newsgroup.")
1240 (defvar gnus-newsgroup-forwarded nil
1241 "List of articles that have been forwarded in the current newsgroup.")
1243 (defvar gnus-newsgroup-recent nil
1244 "List of articles that have are recent in the current newsgroup.")
1246 (defvar gnus-newsgroup-expirable nil
1247 "Sorted list of articles in the current newsgroup that can be expired.")
1249 (defvar gnus-newsgroup-processable nil
1250 "List of articles in the current newsgroup that can be processed.")
1252 (defvar gnus-newsgroup-downloadable nil
1253 "Sorted list of articles in the current newsgroup that can be processed.")
1255 (defvar gnus-newsgroup-undownloaded nil
1256 "List of articles in the current newsgroup that haven't been downloaded..")
1258 (defvar gnus-newsgroup-unsendable nil
1259 "List of articles in the current newsgroup that won't be sent.")
1261 (defvar gnus-newsgroup-bookmarks nil
1262 "List of articles in the current newsgroup that have bookmarks.")
1264 (defvar gnus-newsgroup-dormant nil
1265 "Sorted list of dormant articles in the current newsgroup.")
1267 (defvar gnus-newsgroup-unseen nil
1268 "List of unseen articles in the current newsgroup.")
1270 (defvar gnus-newsgroup-seen nil
1271 "Range of seen articles in the current newsgroup.")
1273 (defvar gnus-newsgroup-articles nil
1274 "List of articles in the current newsgroup.")
1276 (defvar gnus-newsgroup-scored nil
1277 "List of scored articles in the current newsgroup.")
1279 (defvar gnus-newsgroup-incorporated nil
1280 "List of incorporated articles in the current newsgroup.")
1282 (defvar gnus-newsgroup-headers nil
1283 "List of article headers in the current newsgroup.")
1285 (defvar gnus-newsgroup-threads nil)
1287 (defvar gnus-newsgroup-prepared nil
1288 "Whether the current group has been prepared properly.")
1290 (defvar gnus-newsgroup-ancient nil
1291 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1293 (defvar gnus-newsgroup-sparse nil)
1295 (defvar gnus-current-article nil)
1296 (defvar gnus-article-current nil)
1297 (defvar gnus-current-headers nil)
1298 (defvar gnus-have-all-headers nil)
1299 (defvar gnus-last-article nil)
1300 (defvar gnus-newsgroup-history nil)
1301 (defvar gnus-newsgroup-charset nil)
1302 (defvar gnus-newsgroup-ephemeral-charset nil)
1303 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1305 (defvar gnus-article-before-search nil)
1307 (defconst gnus-summary-local-variables
1308 '(gnus-newsgroup-name
1309 gnus-newsgroup-begin gnus-newsgroup-end
1310 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1311 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1312 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1313 gnus-newsgroup-unselected gnus-newsgroup-marked
1314 gnus-newsgroup-reads gnus-newsgroup-saved
1315 gnus-newsgroup-replied gnus-newsgroup-forwarded
1316 gnus-newsgroup-recent
1317 gnus-newsgroup-expirable
1318 gnus-newsgroup-processable gnus-newsgroup-killed
1319 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1320 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1321 gnus-newsgroup-seen gnus-newsgroup-articles
1322 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1323 gnus-newsgroup-headers gnus-newsgroup-threads
1324 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1325 gnus-current-article gnus-current-headers gnus-have-all-headers
1326 gnus-last-article gnus-article-internal-prepare-hook
1327 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1328 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1329 gnus-thread-expunge-below
1330 gnus-score-alist gnus-current-score-file
1331 (gnus-summary-expunge-below . global)
1332 (gnus-summary-mark-below . global)
1333 (gnus-orphan-score . global)
1334 gnus-newsgroup-active gnus-scores-exclude-files
1335 gnus-newsgroup-history gnus-newsgroup-ancient
1336 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1337 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1338 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1339 (gnus-newsgroup-expunged-tally . 0)
1340 gnus-cache-removable-articles gnus-newsgroup-cached
1341 gnus-newsgroup-data gnus-newsgroup-data-reverse
1342 gnus-newsgroup-limit gnus-newsgroup-limits
1343 gnus-newsgroup-charset gnus-newsgroup-display
1344 gnus-newsgroup-incorporated)
1345 "Variables that are buffer-local to the summary buffers.")
1347 (defvar gnus-newsgroup-variables nil
1348 "A list of variables that have separate values in different newsgroups.
1349 A list of newsgroup (summary buffer) local variables, or cons of
1350 variables and their default values (when the default values are not
1351 nil), that should be made global while the summary buffer is active.
1352 These variables can be used to set variables in the group parameters
1353 while still allowing them to affect operations done in other
1354 buffers. For example:
1356 \(setq gnus-newsgroup-variables
1357 '(message-use-followup-to
1358 (gnus-visible-headers .
1359 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1362 ;; Byte-compiler warning.
1363 (eval-when-compile (defvar gnus-article-mode-map))
1365 ;; Subject simplification.
1367 (defun gnus-simplify-whitespace (str)
1368 "Remove excessive whitespace from STR."
1371 (while (string-match "[ \t][ \t]+" mystr)
1372 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1374 (substring mystr (match-end 0)))))
1376 (when (string-match "^[ \t]+" mystr)
1377 (setq mystr (substring mystr (match-end 0))))
1379 (when (string-match "[ \t]+$" mystr)
1380 (setq mystr (substring mystr 0 (match-beginning 0))))
1383 (defsubst gnus-simplify-subject-re (subject)
1384 "Remove \"Re:\" from subject lines."
1385 (if (string-match message-subject-re-regexp subject)
1386 (substring subject (match-end 0))
1389 (defun gnus-simplify-subject (subject &optional re-only)
1390 "Remove `Re:' and words in parentheses.
1391 If RE-ONLY is non-nil, strip leading `Re:'s only."
1392 (let ((case-fold-search t)) ;Ignore case.
1393 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1394 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1395 (setq subject (substring subject (match-end 0))))
1396 ;; Remove uninteresting prefixes.
1397 (when (and (not re-only)
1398 gnus-simplify-ignored-prefixes
1399 (string-match gnus-simplify-ignored-prefixes subject))
1400 (setq subject (substring subject (match-end 0))))
1401 ;; Remove words in parentheses from end.
1403 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1404 (setq subject (substring subject 0 (match-beginning 0)))))
1405 ;; Return subject string.
1408 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1410 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1411 (goto-char (point-min))
1412 (while (re-search-forward regexp nil t)
1413 (replace-match (or newtext ""))))
1415 (defun gnus-simplify-buffer-fuzzy ()
1416 "Simplify string in the buffer fuzzily.
1417 The string in the accessible portion of the current buffer is simplified.
1418 It is assumed to be a single-line subject.
1419 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1420 matter is removed. Additional things can be deleted by setting
1421 `gnus-simplify-subject-fuzzy-regexp'."
1422 (let ((case-fold-search t)
1424 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1426 (while (not (eq modified-tick (buffer-modified-tick)))
1427 (setq modified-tick (buffer-modified-tick))
1429 ((listp gnus-simplify-subject-fuzzy-regexp)
1430 (mapcar 'gnus-simplify-buffer-fuzzy-step
1431 gnus-simplify-subject-fuzzy-regexp))
1432 (gnus-simplify-subject-fuzzy-regexp
1433 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1434 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1435 (gnus-simplify-buffer-fuzzy-step
1436 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1437 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1439 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1440 (gnus-simplify-buffer-fuzzy-step " +" " ")
1441 (gnus-simplify-buffer-fuzzy-step " $")
1442 (gnus-simplify-buffer-fuzzy-step "^ +")))
1444 (defun gnus-simplify-subject-fuzzy (subject)
1445 "Simplify a subject string fuzzily.
1446 See `gnus-simplify-buffer-fuzzy' for details."
1448 (gnus-set-work-buffer)
1449 (let ((case-fold-search t))
1450 ;; Remove uninteresting prefixes.
1451 (when (and gnus-simplify-ignored-prefixes
1452 (string-match gnus-simplify-ignored-prefixes subject))
1453 (setq subject (substring subject (match-end 0))))
1455 (inline (gnus-simplify-buffer-fuzzy))
1458 (defsubst gnus-simplify-subject-fully (subject)
1459 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1461 (gnus-simplify-subject-functions
1462 (gnus-map-function gnus-simplify-subject-functions subject))
1463 ((null gnus-summary-gather-subject-limit)
1464 (gnus-simplify-subject-re subject))
1465 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1466 (gnus-simplify-subject-fuzzy subject))
1467 ((numberp gnus-summary-gather-subject-limit)
1468 (gnus-limit-string (gnus-simplify-subject-re subject)
1469 gnus-summary-gather-subject-limit))
1473 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1474 "Check whether two subjects are equal.
1475 If optional argument simple-first is t, first argument is already
1478 ((null simple-first)
1479 (equal (gnus-simplify-subject-fully s1)
1480 (gnus-simplify-subject-fully s2)))
1483 (gnus-simplify-subject-fully s2)))))
1485 (defun gnus-summary-bubble-group ()
1486 "Increase the score of the current group.
1487 This is a handy function to add to `gnus-summary-exit-hook' to
1488 increase the score of each group you read."
1489 (gnus-group-add-score gnus-newsgroup-name))
1493 ;;; Gnus summary mode
1496 (put 'gnus-summary-mode 'mode-class 'special)
1498 (defvar gnus-article-commands-menu)
1501 ;; Non-orthogonal keys
1503 (gnus-define-keys gnus-summary-mode-map
1504 " " gnus-summary-next-page
1505 "\177" gnus-summary-prev-page
1506 [delete] gnus-summary-prev-page
1507 [backspace] gnus-summary-prev-page
1508 "\r" gnus-summary-scroll-up
1509 "\M-\r" gnus-summary-scroll-down
1510 "n" gnus-summary-next-unread-article
1511 "p" gnus-summary-prev-unread-article
1512 "N" gnus-summary-next-article
1513 "P" gnus-summary-prev-article
1514 "\M-\C-n" gnus-summary-next-same-subject
1515 "\M-\C-p" gnus-summary-prev-same-subject
1516 "\M-n" gnus-summary-next-unread-subject
1517 "\M-p" gnus-summary-prev-unread-subject
1518 "." gnus-summary-first-unread-article
1519 "," gnus-summary-best-unread-article
1520 "\M-s" gnus-summary-search-article-forward
1521 "\M-r" gnus-summary-search-article-backward
1522 "<" gnus-summary-beginning-of-article
1523 ">" gnus-summary-end-of-article
1524 "j" gnus-summary-goto-article
1525 "^" gnus-summary-refer-parent-article
1526 "\M-^" gnus-summary-refer-article
1527 "u" gnus-summary-tick-article-forward
1528 "!" gnus-summary-tick-article-forward
1529 "U" gnus-summary-tick-article-backward
1530 "d" gnus-summary-mark-as-read-forward
1531 "D" gnus-summary-mark-as-read-backward
1532 "E" gnus-summary-mark-as-expirable
1533 "\M-u" gnus-summary-clear-mark-forward
1534 "\M-U" gnus-summary-clear-mark-backward
1535 "k" gnus-summary-kill-same-subject-and-select
1536 "\C-k" gnus-summary-kill-same-subject
1537 "\M-\C-k" gnus-summary-kill-thread
1538 "\M-\C-l" gnus-summary-lower-thread
1539 "e" gnus-summary-edit-article
1540 "#" gnus-summary-mark-as-processable
1541 "\M-#" gnus-summary-unmark-as-processable
1542 "\M-\C-t" gnus-summary-toggle-threads
1543 "\M-\C-s" gnus-summary-show-thread
1544 "\M-\C-h" gnus-summary-hide-thread
1545 "\M-\C-f" gnus-summary-next-thread
1546 "\M-\C-b" gnus-summary-prev-thread
1547 [(meta down)] gnus-summary-next-thread
1548 [(meta up)] gnus-summary-prev-thread
1549 "\M-\C-u" gnus-summary-up-thread
1550 "\M-\C-d" gnus-summary-down-thread
1551 "&" gnus-summary-execute-command
1552 "c" gnus-summary-catchup-and-exit
1553 "\C-w" gnus-summary-mark-region-as-read
1554 "\C-t" gnus-summary-toggle-truncation
1555 "?" gnus-summary-mark-as-dormant
1556 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1557 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1558 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1559 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1560 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1561 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1562 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1563 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1564 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1565 "=" gnus-summary-expand-window
1566 "\C-x\C-s" gnus-summary-reselect-current-group
1567 "\M-g" gnus-summary-rescan-group
1568 "w" gnus-summary-stop-page-breaking
1569 "\C-c\C-r" gnus-summary-caesar-message
1570 "\M-t" gnus-summary-toggle-mime
1571 "f" gnus-summary-followup
1572 "F" gnus-summary-followup-with-original
1573 "C" gnus-summary-cancel-article
1574 "r" gnus-summary-reply
1575 "R" gnus-summary-reply-with-original
1576 "\C-c\C-f" gnus-summary-mail-forward
1577 "o" gnus-summary-save-article
1578 "\C-o" gnus-summary-save-article-mail
1579 "|" gnus-summary-pipe-output
1580 "\M-k" gnus-summary-edit-local-kill
1581 "\M-K" gnus-summary-edit-global-kill
1583 "\C-c\C-d" gnus-summary-describe-group
1584 "q" gnus-summary-exit
1585 "Q" gnus-summary-exit-no-update
1586 "\C-c\C-i" gnus-info-find-node
1587 gnus-mouse-2 gnus-mouse-pick-article
1588 "m" gnus-summary-mail-other-window
1589 "a" gnus-summary-post-news
1590 "i" gnus-summary-news-other-window
1591 "x" gnus-summary-limit-to-unread
1592 "s" gnus-summary-isearch-article
1593 "t" gnus-article-toggle-headers
1594 "g" gnus-summary-show-article
1595 "l" gnus-summary-goto-last-article
1596 "v" gnus-summary-preview-mime-message
1597 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1598 "\C-d" gnus-summary-enter-digest-group
1599 "\M-\C-d" gnus-summary-read-document
1600 "\M-\C-e" gnus-summary-edit-parameters
1601 "\M-\C-a" gnus-summary-customize-parameters
1603 "\C-c\C-n" gnus-namazu-search
1604 "*" gnus-cache-enter-article
1605 "\M-*" gnus-cache-remove-article
1606 "\M-&" gnus-summary-universal-argument
1607 "\C-l" gnus-recenter
1608 "I" gnus-summary-increase-score
1609 "L" gnus-summary-lower-score
1610 "\M-i" gnus-symbolic-argument
1611 "h" gnus-summary-select-article-buffer
1613 "V" gnus-summary-score-map
1614 "X" gnus-uu-extract-map
1615 "S" gnus-summary-send-map)
1617 ;; Sort of orthogonal keymap
1618 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1619 "t" gnus-summary-tick-article-forward
1620 "!" gnus-summary-tick-article-forward
1621 "d" gnus-summary-mark-as-read-forward
1622 "r" gnus-summary-mark-as-read-forward
1623 "c" gnus-summary-clear-mark-forward
1624 " " gnus-summary-clear-mark-forward
1625 "e" gnus-summary-mark-as-expirable
1626 "x" gnus-summary-mark-as-expirable
1627 "?" gnus-summary-mark-as-dormant
1628 "b" gnus-summary-set-bookmark
1629 "B" gnus-summary-remove-bookmark
1630 "#" gnus-summary-mark-as-processable
1631 "\M-#" gnus-summary-unmark-as-processable
1632 "S" gnus-summary-limit-include-expunged
1633 "C" gnus-summary-catchup
1634 "H" gnus-summary-catchup-to-here
1635 "h" gnus-summary-catchup-from-here
1636 "\C-c" gnus-summary-catchup-all
1637 "k" gnus-summary-kill-same-subject-and-select
1638 "K" gnus-summary-kill-same-subject
1639 "P" gnus-uu-mark-map)
1641 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1642 "c" gnus-summary-clear-above
1643 "u" gnus-summary-tick-above
1644 "m" gnus-summary-mark-above
1645 "k" gnus-summary-kill-below)
1647 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1648 "/" gnus-summary-limit-to-subject
1649 "n" gnus-summary-limit-to-articles
1650 "w" gnus-summary-pop-limit
1651 "s" gnus-summary-limit-to-subject
1652 "a" gnus-summary-limit-to-author
1653 "u" gnus-summary-limit-to-unread
1654 "m" gnus-summary-limit-to-marks
1655 "M" gnus-summary-limit-exclude-marks
1656 "v" gnus-summary-limit-to-score
1657 "*" gnus-summary-limit-include-cached
1658 "D" gnus-summary-limit-include-dormant
1659 "T" gnus-summary-limit-include-thread
1660 "d" gnus-summary-limit-exclude-dormant
1661 "t" gnus-summary-limit-to-age
1662 "x" gnus-summary-limit-to-extra
1663 "p" gnus-summary-limit-to-display-predicate
1664 "E" gnus-summary-limit-include-expunged
1665 "c" gnus-summary-limit-exclude-childless-dormant
1666 "C" gnus-summary-limit-mark-excluded-as-read
1667 "o" gnus-summary-insert-old-articles
1668 "N" gnus-summary-insert-new-articles)
1670 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1671 "n" gnus-summary-next-unread-article
1672 "p" gnus-summary-prev-unread-article
1673 "N" gnus-summary-next-article
1674 "P" gnus-summary-prev-article
1675 "\C-n" gnus-summary-next-same-subject
1676 "\C-p" gnus-summary-prev-same-subject
1677 "\M-n" gnus-summary-next-unread-subject
1678 "\M-p" gnus-summary-prev-unread-subject
1679 "f" gnus-summary-first-unread-article
1680 "b" gnus-summary-best-unread-article
1681 "j" gnus-summary-goto-article
1682 "g" gnus-summary-goto-subject
1683 "l" gnus-summary-goto-last-article
1684 "o" gnus-summary-pop-article)
1686 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1687 "k" gnus-summary-kill-thread
1688 "l" gnus-summary-lower-thread
1689 "i" gnus-summary-raise-thread
1690 "T" gnus-summary-toggle-threads
1691 "t" gnus-summary-rethread-current
1692 "^" gnus-summary-reparent-thread
1693 "s" gnus-summary-show-thread
1694 "S" gnus-summary-show-all-threads
1695 "h" gnus-summary-hide-thread
1696 "H" gnus-summary-hide-all-threads
1697 "n" gnus-summary-next-thread
1698 "p" gnus-summary-prev-thread
1699 "u" gnus-summary-up-thread
1700 "o" gnus-summary-top-thread
1701 "d" gnus-summary-down-thread
1702 "#" gnus-uu-mark-thread
1703 "\M-#" gnus-uu-unmark-thread)
1705 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1706 "g" gnus-summary-prepare
1707 "c" gnus-summary-insert-cached-articles)
1709 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1710 "c" gnus-summary-catchup-and-exit
1711 "C" gnus-summary-catchup-all-and-exit
1712 "E" gnus-summary-exit-no-update
1713 "J" gnus-summary-jump-to-other-group
1714 "Q" gnus-summary-exit
1715 "Z" gnus-summary-exit
1716 "n" gnus-summary-catchup-and-goto-next-group
1717 "R" gnus-summary-reselect-current-group
1718 "G" gnus-summary-rescan-group
1719 "N" gnus-summary-next-group
1720 "s" gnus-summary-save-newsrc
1721 "P" gnus-summary-prev-group)
1723 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1724 " " gnus-summary-next-page
1725 "n" gnus-summary-next-page
1726 "\177" gnus-summary-prev-page
1727 [delete] gnus-summary-prev-page
1728 "p" gnus-summary-prev-page
1729 "\r" gnus-summary-scroll-up
1730 "\M-\r" gnus-summary-scroll-down
1731 "<" gnus-summary-beginning-of-article
1732 ">" gnus-summary-end-of-article
1733 "b" gnus-summary-beginning-of-article
1734 "e" gnus-summary-end-of-article
1735 "^" gnus-summary-refer-parent-article
1736 "r" gnus-summary-refer-parent-article
1737 "D" gnus-summary-enter-digest-group
1738 "R" gnus-summary-refer-references
1739 "T" gnus-summary-refer-thread
1740 "g" gnus-summary-show-article
1741 "s" gnus-summary-isearch-article
1742 "P" gnus-summary-print-article
1743 "M" gnus-mailing-list-insinuate
1744 "t" gnus-article-babel)
1746 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1747 "b" gnus-article-add-buttons
1748 "B" gnus-article-add-buttons-to-head
1749 "o" gnus-article-treat-overstrike
1750 "e" gnus-article-emphasize
1751 "w" gnus-article-fill-cited-article
1752 "Q" gnus-article-fill-long-lines
1753 "C" gnus-article-capitalize-sentences
1754 "c" gnus-article-remove-cr
1755 "Z" gnus-article-decode-HZ
1756 "h" gnus-article-wash-html
1757 "u" gnus-article-unsplit-urls
1758 "f" gnus-article-display-x-face
1759 "l" gnus-summary-stop-page-breaking
1760 "r" gnus-summary-caesar-message
1761 "t" gnus-article-toggle-headers
1762 "g" gnus-treat-smiley
1763 "v" gnus-summary-verbose-headers
1764 "m" gnus-summary-toggle-mime
1765 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1766 "p" gnus-article-verify-x-pgp-sig
1767 "d" gnus-article-treat-dumbquotes
1768 "k" gnus-article-outlook-deuglify-article)
1770 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1771 "a" gnus-article-hide
1772 "h" gnus-article-toggle-headers
1773 "b" gnus-article-hide-boring-headers
1774 "s" gnus-article-hide-signature
1775 "c" gnus-article-hide-citation
1776 "C" gnus-article-hide-citation-in-followups
1777 "l" gnus-article-hide-list-identifiers
1778 "p" gnus-article-hide-pgp
1779 "B" gnus-article-strip-banner
1780 "P" gnus-article-hide-pem
1781 "\C-c" gnus-article-hide-citation-maybe)
1783 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1784 "a" gnus-article-highlight
1785 "h" gnus-article-highlight-headers
1786 "c" gnus-article-highlight-citation
1787 "s" gnus-article-highlight-signature)
1789 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1790 "f" gnus-article-treat-fold-headers
1791 "u" gnus-article-treat-unfold-headers
1792 "n" gnus-article-treat-fold-newsgroups)
1794 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1795 "x" gnus-article-display-x-face
1796 "s" gnus-treat-smiley
1797 "D" gnus-article-remove-images
1798 "f" gnus-treat-from-picon
1799 "m" gnus-treat-mail-picon
1800 "n" gnus-treat-newsgroups-picon)
1802 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1803 "z" gnus-article-date-ut
1804 "u" gnus-article-date-ut
1805 "l" gnus-article-date-local
1806 "p" gnus-article-date-english
1807 "e" gnus-article-date-lapsed
1808 "o" gnus-article-date-original
1809 "i" gnus-article-date-iso8601
1810 "s" gnus-article-date-user)
1812 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1813 "t" gnus-article-remove-trailing-blank-lines
1814 "l" gnus-article-strip-leading-blank-lines
1815 "m" gnus-article-strip-multiple-blank-lines
1816 "a" gnus-article-strip-blank-lines
1817 "A" gnus-article-strip-all-blank-lines
1818 "s" gnus-article-strip-leading-space
1819 "e" gnus-article-strip-trailing-space
1820 "w" gnus-article-remove-leading-whitespace)
1822 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1824 "f" gnus-summary-fetch-faq
1825 "d" gnus-summary-describe-group
1826 "h" gnus-summary-describe-briefly
1827 "i" gnus-info-find-node)
1829 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1830 "e" gnus-summary-expire-articles
1831 "\M-\C-e" gnus-summary-expire-articles-now
1832 "\177" gnus-summary-delete-article
1833 [delete] gnus-summary-delete-article
1834 [backspace] gnus-summary-delete-article
1835 "m" gnus-summary-move-article
1836 "r" gnus-summary-respool-article
1837 "w" gnus-summary-edit-article
1838 "c" gnus-summary-copy-article
1839 "B" gnus-summary-crosspost-article
1840 "q" gnus-summary-respool-query
1841 "t" gnus-summary-respool-trace
1842 "i" gnus-summary-import-article
1843 "I" gnus-summary-create-article
1844 "p" gnus-summary-article-posted-p)
1846 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1847 "o" gnus-summary-save-article
1848 "m" gnus-summary-save-article-mail
1849 "F" gnus-summary-write-article-file
1850 "r" gnus-summary-save-article-rmail
1851 "f" gnus-summary-save-article-file
1852 "b" gnus-summary-save-article-body-file
1853 "h" gnus-summary-save-article-folder
1854 "v" gnus-summary-save-article-vm
1855 "p" gnus-summary-pipe-output
1856 "P" gnus-summary-muttprint
1857 "s" gnus-soup-add-article)
1859 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1860 "b" gnus-summary-display-buttonized
1861 "m" gnus-summary-repair-multipart
1862 "v" gnus-article-view-part
1863 "o" gnus-article-save-part
1864 "c" gnus-article-copy-part
1865 "C" gnus-article-view-part-as-charset
1866 "e" gnus-article-view-part-externally
1867 "E" gnus-article-encrypt-body
1868 "i" gnus-article-inline-part
1869 "|" gnus-article-pipe-part)
1871 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1872 "p" gnus-summary-mark-as-processable
1873 "u" gnus-summary-unmark-as-processable
1874 "U" gnus-summary-unmark-all-processable
1875 "v" gnus-uu-mark-over
1876 "s" gnus-uu-mark-series
1877 "r" gnus-uu-mark-region
1878 "g" gnus-uu-unmark-region
1879 "R" gnus-uu-mark-by-regexp
1880 "G" gnus-uu-unmark-by-regexp
1881 "t" gnus-uu-mark-thread
1882 "T" gnus-uu-unmark-thread
1883 "a" gnus-uu-mark-all
1884 "b" gnus-uu-mark-buffer
1885 "S" gnus-uu-mark-sparse
1886 "k" gnus-summary-kill-process-mark
1887 "y" gnus-summary-yank-process-mark
1888 "w" gnus-summary-save-process-mark
1889 "i" gnus-uu-invert-processable)
1891 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1892 ;;"x" gnus-uu-extract-any
1893 "m" gnus-summary-save-parts
1894 "u" gnus-uu-decode-uu
1895 "U" gnus-uu-decode-uu-and-save
1896 "s" gnus-uu-decode-unshar
1897 "S" gnus-uu-decode-unshar-and-save
1898 "o" gnus-uu-decode-save
1899 "O" gnus-uu-decode-save
1900 "b" gnus-uu-decode-binhex
1901 "B" gnus-uu-decode-binhex
1902 "p" gnus-uu-decode-postscript
1903 "P" gnus-uu-decode-postscript-and-save)
1906 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1907 "u" gnus-uu-decode-uu-view
1908 "U" gnus-uu-decode-uu-and-save-view
1909 "s" gnus-uu-decode-unshar-view
1910 "S" gnus-uu-decode-unshar-and-save-view
1911 "o" gnus-uu-decode-save-view
1912 "O" gnus-uu-decode-save-view
1913 "b" gnus-uu-decode-binhex-view
1914 "B" gnus-uu-decode-binhex-view
1915 "p" gnus-uu-decode-postscript-view
1916 "P" gnus-uu-decode-postscript-and-save-view))
1918 (defvar gnus-article-post-menu nil)
1920 (defun gnus-summary-make-menu-bar ()
1921 (gnus-turn-off-edit-menu 'summary)
1923 (unless (boundp 'gnus-summary-misc-menu)
1926 gnus-summary-kill-menu gnus-summary-mode-map ""
1931 ["Customize" gnus-score-customize t])
1932 (gnus-make-score-map 'increase)
1933 (gnus-make-score-map 'lower)
1935 ["Kill below" gnus-summary-kill-below t]
1936 ["Mark above" gnus-summary-mark-above t]
1937 ["Tick above" gnus-summary-tick-above t]
1938 ["Clear above" gnus-summary-clear-above t])
1939 ["Current score" gnus-summary-current-score t]
1940 ["Set score" gnus-summary-set-score t]
1941 ["Switch current score file..." gnus-score-change-score-file t]
1942 ["Set mark below..." gnus-score-set-mark-below t]
1943 ["Set expunge below..." gnus-score-set-expunge-below t]
1944 ["Edit current score file" gnus-score-edit-current-scores t]
1945 ["Edit score file" gnus-score-edit-file t]
1946 ["Trace score" gnus-score-find-trace t]
1947 ["Find words" gnus-score-find-favourite-words t]
1948 ["Rescore buffer" gnus-summary-rescore t]
1949 ["Increase score..." gnus-summary-increase-score t]
1950 ["Lower score..." gnus-summary-lower-score t]))))
1952 ;; Define both the Article menu in the summary buffer and the
1953 ;; equivalent Commands menu in the article buffer here for
1957 ["All" gnus-article-hide t]
1958 ["Headers" gnus-article-toggle-headers t]
1959 ["Signature" gnus-article-hide-signature t]
1960 ["Citation" gnus-article-hide-citation t]
1961 ["List identifiers" gnus-article-hide-list-identifiers t]
1962 ["PGP" gnus-article-hide-pgp t]
1963 ["Banner" gnus-article-strip-banner t]
1964 ["Boring headers" gnus-article-hide-boring-headers t])
1966 ["All" gnus-article-highlight t]
1967 ["Headers" gnus-article-highlight-headers t]
1968 ["Signature" gnus-article-highlight-signature t]
1969 ["Citation" gnus-article-highlight-citation t])
1971 ["Local" gnus-article-date-local t]
1972 ["ISO8601" gnus-article-date-iso8601 t]
1973 ["UT" gnus-article-date-ut t]
1974 ["Original" gnus-article-date-original t]
1975 ["Lapsed" gnus-article-date-lapsed t]
1976 ["User-defined" gnus-article-date-user t])
1978 ["Remove images" gnus-article-remove-images t]
1979 ["Toggle smiley" gnus-treat-smiley t]
1980 ["Show X-Face" gnus-article-display-x-face t]
1981 ["Show picons in From" gnus-treat-from-picon t]
1982 ["Show picons in mail headers" gnus-treat-mail-picon t]
1983 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
1984 ("View as different encoding"
1987 ;; Since easymenu under FSF Emacs doesn't allow lambda
1988 ;; forms for menu commands, we should provide intern'ed
1989 ;; function symbols.
1990 (let ((command (intern (format "\
1991 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
1995 (let ((gnus-summary-show-article-charset-alist
1997 (gnus-summary-show-article 1))))
1998 `[,(symbol-name cs) ,command t]))
1999 (sort (if (fboundp 'coding-system-list)
2000 (coding-system-list)
2001 ;;(mapcar 'car mm-mime-mule-charset-alist)
2004 (string< (symbol-name a)
2005 (symbol-name b)))))))
2008 ["Leading" gnus-article-strip-leading-blank-lines t]
2009 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2010 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2011 ["All of the above" gnus-article-strip-blank-lines t]
2012 ["All" gnus-article-strip-all-blank-lines t]
2013 ["Leading space" gnus-article-strip-leading-space t]
2014 ["Trailing space" gnus-article-strip-trailing-space t]
2015 ["Leading space in headers"
2016 gnus-article-remove-leading-whitespace t])
2017 ["Overstrike" gnus-article-treat-overstrike t]
2018 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2019 ["Emphasis" gnus-article-emphasize t]
2020 ["Word wrap" gnus-article-fill-cited-article t]
2021 ["Fill long lines" gnus-article-fill-long-lines t]
2022 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2023 ["CR" gnus-article-remove-cr t]
2024 ["Rot 13" gnus-summary-caesar-message
2025 ,@(if (featurep 'xemacs) '(t)
2026 '(:help "\"Caesar rotate\" article by 13"))]
2027 ["Unix pipe" gnus-summary-pipe-message t]
2028 ["Add buttons" gnus-article-add-buttons t]
2029 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2030 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2031 ["Toggle MIME" gnus-summary-toggle-mime t]
2032 ["Verbose header" gnus-summary-verbose-headers t]
2033 ["Toggle header" gnus-summary-toggle-header t]
2034 ["Unfold headers" gnus-article-treat-unfold-headers t]
2035 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2036 ["Html" gnus-article-wash-html t]
2037 ["URLs" gnus-article-unsplit-urls t]
2038 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2039 ["HZ" gnus-article-decode-HZ t]
2040 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2043 ["Save in default format" gnus-summary-save-article
2044 ,@(if (featurep 'xemacs) '(t)
2045 '(:help "Save article using default method"))]
2046 ["Save in file" gnus-summary-save-article-file
2047 ,@(if (featurep 'xemacs) '(t)
2048 '(:help "Save article in file"))]
2049 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2050 ["Save in MH folder" gnus-summary-save-article-folder t]
2051 ["Save in VM folder" gnus-summary-save-article-vm t]
2052 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2053 ["Save body in file" gnus-summary-save-article-body-file t]
2054 ["Pipe through a filter" gnus-summary-pipe-output t]
2055 ["Add to SOUP packet" gnus-soup-add-article t]
2056 ["Print with Muttprint" gnus-summary-muttprint t]
2057 ["Print" gnus-summary-print-article t])
2059 ["Respool article..." gnus-summary-respool-article t]
2060 ["Move article..." gnus-summary-move-article
2061 (gnus-check-backend-function
2062 'request-move-article gnus-newsgroup-name)]
2063 ["Copy article..." gnus-summary-copy-article t]
2064 ["Crosspost article..." gnus-summary-crosspost-article
2065 (gnus-check-backend-function
2066 'request-replace-article gnus-newsgroup-name)]
2067 ["Import file..." gnus-summary-import-article t]
2068 ["Create article..." gnus-summary-create-article t]
2069 ["Check if posted" gnus-summary-article-posted-p t]
2070 ["Edit article" gnus-summary-edit-article
2071 (not (gnus-group-read-only-p))]
2072 ["Delete article" gnus-summary-delete-article
2073 (gnus-check-backend-function
2074 'request-expire-articles gnus-newsgroup-name)]
2075 ["Query respool" gnus-summary-respool-query t]
2076 ["Trace respool" gnus-summary-respool-trace t]
2077 ["Delete expirable articles" gnus-summary-expire-articles-now
2078 (gnus-check-backend-function
2079 'request-expire-articles gnus-newsgroup-name)])
2081 ["Uudecode" gnus-uu-decode-uu
2082 ,@(if (featurep 'xemacs) '(t)
2083 '(:help "Decode uuencoded article(s)"))]
2084 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2085 ["Unshar" gnus-uu-decode-unshar t]
2086 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2087 ["Save" gnus-uu-decode-save t]
2088 ["Binhex" gnus-uu-decode-binhex t]
2089 ["Postscript" gnus-uu-decode-postscript t])
2091 ["Enter article" gnus-cache-enter-article t]
2092 ["Remove article" gnus-cache-remove-article t])
2093 ["Translate" gnus-article-babel t]
2094 ["Select article buffer" gnus-summary-select-article-buffer t]
2095 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2096 ["Isearch article..." gnus-summary-isearch-article t]
2097 ["Beginning of the article" gnus-summary-beginning-of-article t]
2098 ["End of the article" gnus-summary-end-of-article t]
2099 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2100 ["Fetch referenced articles" gnus-summary-refer-references t]
2101 ["Fetch current thread" gnus-summary-refer-thread t]
2102 ["Fetch article with id..." gnus-summary-refer-article t]
2103 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2104 ["Redisplay" gnus-summary-show-article t]
2105 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2107 gnus-summary-article-menu gnus-summary-mode-map ""
2108 (cons "Article" innards))
2110 (if (not (keymapp gnus-summary-article-menu))
2112 gnus-article-commands-menu gnus-article-mode-map ""
2113 (cons "Commands" innards))
2114 ;; in Emacs, don't share menu.
2115 (setq gnus-article-commands-menu
2116 (copy-keymap gnus-summary-article-menu))
2117 (define-key gnus-article-mode-map [menu-bar commands]
2118 (cons "Commands" gnus-article-commands-menu))))
2121 gnus-summary-thread-menu gnus-summary-mode-map ""
2123 ["Toggle threading" gnus-summary-toggle-threads t]
2124 ["Hide threads" gnus-summary-hide-all-threads t]
2125 ["Show threads" gnus-summary-show-all-threads t]
2126 ["Hide thread" gnus-summary-hide-thread t]
2127 ["Show thread" gnus-summary-show-thread t]
2128 ["Go to next thread" gnus-summary-next-thread t]
2129 ["Go to previous thread" gnus-summary-prev-thread t]
2130 ["Go down thread" gnus-summary-down-thread t]
2131 ["Go up thread" gnus-summary-up-thread t]
2132 ["Top of thread" gnus-summary-top-thread t]
2133 ["Mark thread as read" gnus-summary-kill-thread t]
2134 ["Lower thread score" gnus-summary-lower-thread t]
2135 ["Raise thread score" gnus-summary-raise-thread t]
2136 ["Rethread current" gnus-summary-rethread-current t]))
2139 gnus-summary-post-menu gnus-summary-mode-map ""
2141 ["Send a message (mail or news)" gnus-summary-post-news
2142 ,@(if (featurep 'xemacs) '(t)
2143 '(:help "Post an article"))]
2144 ["Followup" gnus-summary-followup
2145 ,@(if (featurep 'xemacs) '(t)
2146 '(:help "Post followup to this article"))]
2147 ["Followup and yank" gnus-summary-followup-with-original
2148 ,@(if (featurep 'xemacs) '(t)
2149 '(:help "Post followup to this article, quoting its contents"))]
2150 ["Supersede article" gnus-summary-supersede-article t]
2151 ["Cancel article" gnus-summary-cancel-article
2152 ,@(if (featurep 'xemacs) '(t)
2153 '(:help "Cancel an article you posted"))]
2154 ["Reply" gnus-summary-reply t]
2155 ["Reply and yank" gnus-summary-reply-with-original t]
2156 ["Wide reply" gnus-summary-wide-reply t]
2157 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2158 ,@(if (featurep 'xemacs) '(t)
2159 '(:help "Mail a reply, quoting this article"))]
2160 ["Very wide reply" gnus-summary-very-wide-reply t]
2161 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2162 ,@(if (featurep 'xemacs) '(t)
2163 '(:help "Mail a very wide reply, quoting this article"))]
2164 ["Mail forward" gnus-summary-mail-forward t]
2165 ["Post forward" gnus-summary-post-forward t]
2166 ["Digest and mail" gnus-summary-digest-mail-forward t]
2167 ["Digest and post" gnus-summary-digest-post-forward t]
2168 ["Resend message" gnus-summary-resend-message t]
2169 ["Resend message edit" gnus-summary-resend-message-edit t]
2170 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2171 ["Send a mail" gnus-summary-mail-other-window t]
2172 ["Create a local message" gnus-summary-news-other-window t]
2173 ["Uuencode and post" gnus-uu-post-news
2174 ,@(if (featurep 'xemacs) '(t)
2175 '(:help "Post a uuencoded article"))]
2176 ["Followup via news" gnus-summary-followup-to-mail t]
2177 ["Followup via news and yank"
2178 gnus-summary-followup-to-mail-with-original t]
2180 ;;["Send" gnus-summary-send-draft t]
2181 ;;["Send bounced" gnus-resend-bounced-mail t])
2185 ((not (keymapp gnus-summary-post-menu))
2186 (setq gnus-article-post-menu gnus-summary-post-menu))
2187 ((not gnus-article-post-menu)
2188 ;; Don't share post menu.
2189 (setq gnus-article-post-menu
2190 (copy-keymap gnus-summary-post-menu))))
2191 (define-key gnus-article-mode-map [menu-bar post]
2192 (cons "Post" gnus-article-post-menu))
2195 gnus-summary-misc-menu gnus-summary-mode-map ""
2198 ["Mark as read" gnus-summary-mark-as-read-forward t]
2199 ["Mark same subject and select"
2200 gnus-summary-kill-same-subject-and-select t]
2201 ["Mark same subject" gnus-summary-kill-same-subject t]
2202 ["Catchup" gnus-summary-catchup
2203 ,@(if (featurep 'xemacs) '(t)
2204 '(:help "Mark unread articles in this group as read"))]
2205 ["Catchup all" gnus-summary-catchup-all t]
2206 ["Catchup to here" gnus-summary-catchup-to-here t]
2207 ["Catchup from here" gnus-summary-catchup-from-here t]
2208 ["Catchup region" gnus-summary-mark-region-as-read t]
2209 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2211 ["Tick" gnus-summary-tick-article-forward t]
2212 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2213 ["Remove marks" gnus-summary-clear-mark-forward t]
2214 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2215 ["Set bookmark" gnus-summary-set-bookmark t]
2216 ["Remove bookmark" gnus-summary-remove-bookmark t])
2218 ["Marks..." gnus-summary-limit-to-marks t]
2219 ["Subject..." gnus-summary-limit-to-subject t]
2220 ["Author..." gnus-summary-limit-to-author t]
2221 ["Age..." gnus-summary-limit-to-age t]
2222 ["Extra..." gnus-summary-limit-to-extra t]
2223 ["Score" gnus-summary-limit-to-score t]
2224 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2225 ["Unread" gnus-summary-limit-to-unread t]
2226 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2227 ["Articles" gnus-summary-limit-to-articles t]
2228 ["Pop limit" gnus-summary-pop-limit t]
2229 ["Show dormant" gnus-summary-limit-include-dormant t]
2230 ["Hide childless dormant"
2231 gnus-summary-limit-exclude-childless-dormant t]
2232 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2233 ["Hide marked" gnus-summary-limit-exclude-marks t]
2234 ["Show expunged" gnus-summary-limit-include-expunged t])
2236 ["Set mark" gnus-summary-mark-as-processable t]
2237 ["Remove mark" gnus-summary-unmark-as-processable t]
2238 ["Remove all marks" gnus-summary-unmark-all-processable t]
2239 ["Mark above" gnus-uu-mark-over t]
2240 ["Mark series" gnus-uu-mark-series t]
2241 ["Mark region" gnus-uu-mark-region t]
2242 ["Unmark region" gnus-uu-unmark-region t]
2243 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2244 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2245 ["Mark all" gnus-uu-mark-all t]
2246 ["Mark buffer" gnus-uu-mark-buffer t]
2247 ["Mark sparse" gnus-uu-mark-sparse t]
2248 ["Mark thread" gnus-uu-mark-thread t]
2249 ["Unmark thread" gnus-uu-unmark-thread t]
2250 ("Process Mark Sets"
2251 ["Kill" gnus-summary-kill-process-mark t]
2252 ["Yank" gnus-summary-yank-process-mark
2253 gnus-newsgroup-process-stack]
2254 ["Save" gnus-summary-save-process-mark t]))
2256 ["Page forward" gnus-summary-next-page
2257 ,@(if (featurep 'xemacs) '(t)
2258 '(:help "Show next page of article"))]
2259 ["Page backward" gnus-summary-prev-page
2260 ,@(if (featurep 'xemacs) '(t)
2261 '(:help "Show previous page of article"))]
2262 ["Line forward" gnus-summary-scroll-up t])
2264 ["Next unread article" gnus-summary-next-unread-article t]
2265 ["Previous unread article" gnus-summary-prev-unread-article t]
2266 ["Next article" gnus-summary-next-article t]
2267 ["Previous article" gnus-summary-prev-article t]
2268 ["Next unread subject" gnus-summary-next-unread-subject t]
2269 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2270 ["Next article same subject" gnus-summary-next-same-subject t]
2271 ["Previous article same subject" gnus-summary-prev-same-subject t]
2272 ["First unread article" gnus-summary-first-unread-article t]
2273 ["Best unread article" gnus-summary-best-unread-article t]
2274 ["Go to subject number..." gnus-summary-goto-subject t]
2275 ["Go to article number..." gnus-summary-goto-article t]
2276 ["Go to the last article" gnus-summary-goto-last-article t]
2277 ["Pop article off history" gnus-summary-pop-article t])
2279 ["Sort by number" gnus-summary-sort-by-number t]
2280 ["Sort by author" gnus-summary-sort-by-author t]
2281 ["Sort by subject" gnus-summary-sort-by-subject t]
2282 ["Sort by date" gnus-summary-sort-by-date t]
2283 ["Sort by score" gnus-summary-sort-by-score t]
2284 ["Sort by lines" gnus-summary-sort-by-lines t]
2285 ["Sort by characters" gnus-summary-sort-by-chars t]
2286 ["Original sort" gnus-summary-sort-by-original t])
2288 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2289 ["Describe group" gnus-summary-describe-group t]
2290 ["Read manual" gnus-info-find-node t])
2292 ["Pick and read" gnus-pick-mode t]
2293 ["Binary" gnus-binary-mode t])
2295 ["Regenerate" gnus-summary-prepare t]
2296 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2297 ["Toggle threading" gnus-summary-toggle-threads t])
2298 ["See old articles" gnus-summary-insert-old-articles t]
2299 ["See new articles" gnus-summary-insert-new-articles t]
2300 ["Filter articles..." gnus-summary-execute-command t]
2301 ["Run command on subjects..." gnus-summary-universal-argument t]
2302 ["Search articles forward..." gnus-summary-search-article-forward t]
2303 ["Search articles backward..." gnus-summary-search-article-backward t]
2304 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2305 ["Expand window" gnus-summary-expand-window t]
2306 ["Expire expirable articles" gnus-summary-expire-articles
2307 (gnus-check-backend-function
2308 'request-expire-articles gnus-newsgroup-name)]
2309 ["Edit local kill file" gnus-summary-edit-local-kill t]
2310 ["Edit main kill file" gnus-summary-edit-global-kill t]
2311 ["Edit group parameters" gnus-summary-edit-parameters t]
2312 ["Customize group parameters" gnus-summary-customize-parameters t]
2313 ["Send a bug report" gnus-bug t]
2315 ["Catchup and exit" gnus-summary-catchup-and-exit
2316 ,@(if (featurep 'xemacs) '(t)
2317 '(:help "Mark unread articles in this group as read, then exit"))]
2318 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2319 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2320 ["Exit group" gnus-summary-exit
2321 ,@(if (featurep 'xemacs) '(t)
2322 '(:help "Exit current group, return to group selection mode"))]
2323 ["Exit group without updating" gnus-summary-exit-no-update t]
2324 ["Exit and goto next group" gnus-summary-next-group t]
2325 ["Exit and goto prev group" gnus-summary-prev-group t]
2326 ["Reselect group" gnus-summary-reselect-current-group t]
2327 ["Rescan group" gnus-summary-rescan-group t]
2328 ["Update dribble" gnus-summary-save-newsrc t])))
2330 (gnus-run-hooks 'gnus-summary-menu-hook)))
2332 (defvar gnus-summary-tool-bar-map nil)
2334 ;; Emacs 21 tool bar. Should be no-op otherwise.
2335 (defun gnus-summary-make-tool-bar ()
2336 (if (and (fboundp 'tool-bar-add-item-from-menu)
2337 (default-value 'tool-bar-mode)
2338 (not gnus-summary-tool-bar-map))
2339 (setq gnus-summary-tool-bar-map
2340 (let ((tool-bar-map (make-sparse-keymap))
2341 (load-path (mm-image-load-path)))
2342 (tool-bar-add-item-from-menu
2343 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2344 (tool-bar-add-item-from-menu
2345 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2346 (tool-bar-add-item-from-menu
2347 'gnus-summary-post-news "post" gnus-summary-mode-map)
2348 (tool-bar-add-item-from-menu
2349 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2350 (tool-bar-add-item-from-menu
2351 'gnus-summary-followup "followup" gnus-summary-mode-map)
2352 (tool-bar-add-item-from-menu
2353 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2354 (tool-bar-add-item-from-menu
2355 'gnus-summary-reply "reply" gnus-summary-mode-map)
2356 (tool-bar-add-item-from-menu
2357 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2358 (tool-bar-add-item-from-menu
2359 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2360 (tool-bar-add-item-from-menu
2361 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2362 (tool-bar-add-item-from-menu
2363 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2364 (tool-bar-add-item-from-menu
2365 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2366 (tool-bar-add-item-from-menu
2367 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2368 (tool-bar-add-item-from-menu
2369 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2370 (tool-bar-add-item-from-menu
2371 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2373 (if gnus-summary-tool-bar-map
2374 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2376 (defun gnus-score-set-default (var value)
2377 "A version of set that updates the GNU Emacs menu-bar."
2379 ;; It is the message that forces the active status to be updated.
2382 (defun gnus-make-score-map (type)
2383 "Make a summary score map of type TYPE."
2386 (let ((headers '(("author" "from" string)
2387 ("subject" "subject" string)
2388 ("article body" "body" string)
2389 ("article head" "head" string)
2390 ("xref" "xref" string)
2391 ("extra header" "extra" string)
2392 ("lines" "lines" number)
2393 ("followups to author" "followup" string)))
2394 (types '((number ("less than" <)
2397 (string ("substring" s)
2401 (perms '(("temporary" (current-time-string))
2409 (if (eq type 'lower)
2414 (setq header (car headers))
2420 (let ((ts (cdr (assoc (nth 2 header) types)))
2436 'gnus-summary-score-entry
2438 (if (or (string= (nth 1 header)
2440 (string= (nth 1 header)
2443 (list 'gnus-summary-header
2445 (list 'quote (nth 1 (car ts)))
2446 (list 'gnus-score-delta-default
2453 (list (nreverse outp))))
2456 (list (nreverse outt))))
2458 (setq headers (cdr headers)))
2459 (list (nreverse outh))))))))
2463 (defun gnus-summary-mode (&optional group)
2464 "Major mode for reading articles.
2466 All normal editing commands are switched off.
2467 \\<gnus-summary-mode-map>
2468 Each line in this buffer represents one article. To read an
2469 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2470 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2473 You can also post articles and send mail from this buffer. To
2474 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2475 of an article, type `\\[gnus-summary-reply]'.
2477 There are approx. one gazillion commands you can execute in this
2478 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2480 The following commands are available:
2482 \\{gnus-summary-mode-map}"
2484 (kill-all-local-variables)
2485 (when (gnus-visual-p 'summary-menu 'menu)
2486 (gnus-summary-make-menu-bar)
2487 (gnus-summary-make-tool-bar))
2488 (gnus-summary-make-local-variables)
2489 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2490 (gnus-summary-make-local-variables))
2491 (gnus-make-thread-indent-array)
2492 (gnus-simplify-mode-line)
2493 (setq major-mode 'gnus-summary-mode)
2494 (setq mode-name "Summary")
2495 (make-local-variable 'minor-mode-alist)
2496 (use-local-map gnus-summary-mode-map)
2497 (buffer-disable-undo)
2498 (setq buffer-read-only t) ;Disable modification
2499 (setq truncate-lines t)
2500 (setq selective-display t)
2501 (setq selective-display-ellipses t) ;Display `...'
2502 (gnus-summary-set-display-table)
2503 (gnus-set-default-directory)
2504 (setq gnus-newsgroup-name group)
2505 (unless (gnus-news-group-p group)
2506 (setq gnus-newsgroup-incorporated
2507 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2508 (make-local-variable 'gnus-summary-line-format)
2509 (make-local-variable 'gnus-summary-line-format-spec)
2510 (make-local-variable 'gnus-summary-dummy-line-format)
2511 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2512 (make-local-variable 'gnus-summary-mark-positions)
2513 (make-local-hook 'pre-command-hook)
2514 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2515 (gnus-run-hooks 'gnus-summary-mode-hook)
2516 (turn-on-gnus-mailing-list-mode)
2517 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2518 (gnus-update-summary-mark-positions))
2520 (defun gnus-summary-make-local-variables ()
2521 "Make all the local summary buffer variables."
2523 (dolist (local gnus-summary-local-variables)
2526 (if (eq (cdr local) 'global)
2527 ;; Copy the global value of the variable.
2528 (setq global (symbol-value (car local)))
2529 ;; Use the value from the list.
2530 (setq global (eval (cdr local))))
2531 (set (make-local-variable (car local)) global))
2532 ;; Simple nil-valued local variable.
2533 (set (make-local-variable local) nil)))))
2535 (defun gnus-summary-clear-local-variables ()
2536 (let ((locals gnus-summary-local-variables))
2538 (if (consp (car locals))
2539 (and (vectorp (caar locals))
2540 (set (caar locals) nil))
2541 (and (vectorp (car locals))
2542 (set (car locals) nil)))
2543 (setq locals (cdr locals)))))
2545 ;; Summary data functions.
2547 (defmacro gnus-data-number (data)
2550 (defmacro gnus-data-set-number (data number)
2551 `(setcar ,data ,number))
2553 (defmacro gnus-data-mark (data)
2556 (defmacro gnus-data-set-mark (data mark)
2557 `(setcar (nthcdr 1 ,data) ,mark))
2559 (defmacro gnus-data-pos (data)
2562 (defmacro gnus-data-set-pos (data pos)
2563 `(setcar (nthcdr 2 ,data) ,pos))
2565 (defmacro gnus-data-header (data)
2568 (defmacro gnus-data-set-header (data header)
2569 `(setcar (nthcdr 3 ,data) ,header))
2571 (defmacro gnus-data-level (data)
2574 (defmacro gnus-data-unread-p (data)
2575 `(= (nth 1 ,data) gnus-unread-mark))
2577 (defmacro gnus-data-read-p (data)
2578 `(/= (nth 1 ,data) gnus-unread-mark))
2580 (defmacro gnus-data-pseudo-p (data)
2581 `(consp (nth 3 ,data)))
2583 (defmacro gnus-data-find (number)
2584 `(assq ,number gnus-newsgroup-data))
2586 (defmacro gnus-data-find-list (number &optional data)
2587 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2588 (memq (assq ,number bdata)
2591 (defmacro gnus-data-make (number mark pos header level)
2592 `(list ,number ,mark ,pos ,header ,level))
2594 (defun gnus-data-enter (after-article number mark pos header level offset)
2595 (let ((data (gnus-data-find-list after-article)))
2597 (error "No such article: %d" after-article))
2598 (setcdr data (cons (gnus-data-make number mark pos header level)
2600 (setq gnus-newsgroup-data-reverse nil)
2601 (gnus-data-update-list (cddr data) offset)))
2603 (defun gnus-data-enter-list (after-article list &optional offset)
2605 (let ((data (and after-article (gnus-data-find-list after-article)))
2609 (let ((odata gnus-newsgroup-data))
2610 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2612 (gnus-data-update-list odata offset)))
2613 ;; Find the last element in the list to be spliced into the main
2616 (setq list (cdr list)))
2619 (setcdr list gnus-newsgroup-data)
2620 (setq gnus-newsgroup-data ilist)
2622 (gnus-data-update-list (cdr list) offset)))
2623 (setcdr list (cdr data))
2626 (gnus-data-update-list (cdr list) offset))))
2627 (setq gnus-newsgroup-data-reverse nil))))
2629 (defun gnus-data-remove (article &optional offset)
2630 (let ((data gnus-newsgroup-data))
2631 (if (= (gnus-data-number (car data)) article)
2633 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2634 gnus-newsgroup-data-reverse nil)
2636 (gnus-data-update-list gnus-newsgroup-data offset)))
2638 (when (= (gnus-data-number (cadr data)) article)
2639 (setcdr data (cddr data))
2641 (gnus-data-update-list (cdr data) offset))
2643 gnus-newsgroup-data-reverse nil))
2644 (setq data (cdr data))))))
2646 (defmacro gnus-data-list (backward)
2648 (or gnus-newsgroup-data-reverse
2649 (setq gnus-newsgroup-data-reverse
2650 (reverse gnus-newsgroup-data)))
2651 gnus-newsgroup-data))
2653 (defun gnus-data-update-list (data offset)
2654 "Add OFFSET to the POS of all data entries in DATA."
2655 (setq gnus-newsgroup-data-reverse nil)
2657 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2658 (setq data (cdr data))))
2660 (defun gnus-summary-article-pseudo-p (article)
2661 "Say whether this article is a pseudo article or not."
2662 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2664 (defmacro gnus-summary-article-sparse-p (article)
2665 "Say whether this article is a sparse article or not."
2666 `(memq ,article gnus-newsgroup-sparse))
2668 (defmacro gnus-summary-article-ancient-p (article)
2669 "Say whether this article is a sparse article or not."
2670 `(memq ,article gnus-newsgroup-ancient))
2672 (defun gnus-article-parent-p (number)
2673 "Say whether this article is a parent or not."
2674 (let ((data (gnus-data-find-list number)))
2675 (and (cdr data) ; There has to be an article after...
2676 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2677 (gnus-data-level (nth 1 data))))))
2679 (defun gnus-article-children (number)
2680 "Return a list of all children to NUMBER."
2681 (let* ((data (gnus-data-find-list number))
2682 (level (gnus-data-level (car data)))
2684 (setq data (cdr data))
2686 (= (gnus-data-level (car data)) (1+ level)))
2687 (push (gnus-data-number (car data)) children)
2688 (setq data (cdr data)))
2691 (defmacro gnus-summary-skip-intangible ()
2692 "If the current article is intangible, then jump to a different article."
2693 '(let ((to (get-text-property (point) 'gnus-intangible)))
2694 (and to (gnus-summary-goto-subject to))))
2696 (defmacro gnus-summary-article-intangible-p ()
2697 "Say whether this article is intangible or not."
2698 '(get-text-property (point) 'gnus-intangible))
2700 (defun gnus-article-read-p (article)
2701 "Say whether ARTICLE is read or not."
2702 (not (or (memq article gnus-newsgroup-marked)
2703 (memq article gnus-newsgroup-unreads)
2704 (memq article gnus-newsgroup-unselected)
2705 (memq article gnus-newsgroup-dormant))))
2707 ;; Some summary mode macros.
2709 (defmacro gnus-summary-article-number ()
2710 "The article number of the article on the current line.
2711 If there isn's an article number here, then we return the current
2714 (gnus-summary-skip-intangible)
2715 (or (get-text-property (point) 'gnus-number)
2716 (gnus-summary-last-subject))))
2718 (defmacro gnus-summary-article-header (&optional number)
2719 "Return the header of article NUMBER."
2720 `(gnus-data-header (gnus-data-find
2721 ,(or number '(gnus-summary-article-number)))))
2723 (defmacro gnus-summary-thread-level (&optional number)
2724 "Return the level of thread that starts with article NUMBER."
2725 `(if (and (eq gnus-summary-make-false-root 'dummy)
2726 (get-text-property (point) 'gnus-intangible))
2728 (gnus-data-level (gnus-data-find
2729 ,(or number '(gnus-summary-article-number))))))
2731 (defmacro gnus-summary-article-mark (&optional number)
2732 "Return the mark of article NUMBER."
2733 `(gnus-data-mark (gnus-data-find
2734 ,(or number '(gnus-summary-article-number)))))
2736 (defmacro gnus-summary-article-pos (&optional number)
2737 "Return the position of the line of article NUMBER."
2738 `(gnus-data-pos (gnus-data-find
2739 ,(or number '(gnus-summary-article-number)))))
2741 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2742 (defmacro gnus-summary-article-subject (&optional number)
2743 "Return current subject string or nil if nothing."
2746 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2747 '(gnus-data-header (assq (gnus-summary-article-number)
2748 gnus-newsgroup-data)))))
2751 (mail-header-subject headers))))
2753 (defmacro gnus-summary-article-score (&optional number)
2754 "Return current article score."
2755 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2756 gnus-newsgroup-scored))
2757 gnus-summary-default-score 0))
2759 (defun gnus-summary-article-children (&optional number)
2760 "Return a list of article numbers that are children of article NUMBER."
2761 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2762 (level (gnus-data-level (car data)))
2764 (while (and (setq data (cdr data))
2765 (> (setq l (gnus-data-level (car data))) level))
2766 (and (= (1+ level) l)
2767 (push (gnus-data-number (car data))
2769 (nreverse children)))
2771 (defun gnus-summary-article-parent (&optional number)
2772 "Return the article number of the parent of article NUMBER."
2773 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2774 (gnus-data-list t)))
2775 (level (gnus-data-level (car data))))
2777 () ; This is a root.
2778 ;; We search until we find an article with a level less than
2779 ;; this one. That function has to be the parent.
2780 (while (and (setq data (cdr data))
2781 (not (< (gnus-data-level (car data)) level))))
2782 (and data (gnus-data-number (car data))))))
2784 (defun gnus-unread-mark-p (mark)
2785 "Say whether MARK is the unread mark."
2786 (= mark gnus-unread-mark))
2788 (defun gnus-read-mark-p (mark)
2789 "Say whether MARK is one of the marks that mark as read.
2790 This is all marks except unread, ticked, dormant, and expirable."
2791 (not (or (= mark gnus-unread-mark)
2792 (= mark gnus-ticked-mark)
2793 (= mark gnus-dormant-mark)
2794 (= mark gnus-expirable-mark))))
2796 (defmacro gnus-article-mark (number)
2797 "Return the MARK of article NUMBER.
2798 This macro should only be used when computing the mark the \"first\"
2799 time; i.e., when generating the summary lines. After that,
2800 `gnus-summary-article-mark' should be used to examine the
2803 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2804 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2805 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2806 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2807 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2808 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2809 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2810 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2811 gnus-ancient-mark))))
2813 ;; Saving hidden threads.
2815 (defmacro gnus-save-hidden-threads (&rest forms)
2816 "Save hidden threads, eval FORMS, and restore the hidden threads."
2817 (let ((config (make-symbol "config")))
2818 `(let ((,config (gnus-hidden-threads-configuration)))
2822 (gnus-restore-hidden-threads-configuration ,config)))))
2823 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2824 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2826 (defun gnus-data-compute-positions ()
2827 "Compute the positions of all articles."
2828 (setq gnus-newsgroup-data-reverse nil)
2829 (let ((data gnus-newsgroup-data))
2831 (gnus-save-hidden-threads
2832 (gnus-summary-show-all-threads)
2833 (goto-char (point-min))
2835 (while (get-text-property (point) 'gnus-intangible)
2837 (gnus-data-set-pos (car data) (+ (point) 3))
2838 (setq data (cdr data))
2839 (forward-line 1))))))
2841 (defun gnus-hidden-threads-configuration ()
2842 "Return the current hidden threads configuration."
2845 (goto-char (point-min))
2846 (while (search-forward "\r" nil t)
2847 (push (1- (point)) config))
2850 (defun gnus-restore-hidden-threads-configuration (config)
2851 "Restore hidden threads configuration from CONFIG."
2853 (let (point buffer-read-only)
2854 (while (setq point (pop config))
2855 (when (and (< point (point-max))
2857 (eq (char-after) ?\n))
2858 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2860 ;; Various summary mode internalish functions.
2862 (defun gnus-mouse-pick-article (e)
2865 (gnus-summary-next-page nil t))
2867 (defun gnus-summary-set-display-table ()
2868 "Change the display table.
2869 Odd characters have a tendency to mess
2870 up nicely formatted displays - we make all possible glyphs
2871 display only a single character."
2873 ;; We start from the standard display table, if any.
2874 (let ((table (or (copy-sequence standard-display-table)
2875 (make-display-table)))
2877 ;; Nix out all the control chars...
2878 (while (>= (setq i (1- i)) 0)
2879 (aset table i [??]))
2880 ;; ... but not newline and cr, of course. (cr is necessary for the
2881 ;; selective display).
2882 (aset table ?\n nil)
2883 (aset table ?\r nil)
2884 ;; We keep TAB as well.
2885 (aset table ?\t nil)
2886 ;; We nix out any glyphs over 126 that are not set already.
2888 (while (>= (setq i (1- i)) 127)
2889 ;; Only modify if the entry is nil.
2890 (unless (aref table i)
2891 (aset table i [??]))))
2892 (setq buffer-display-table table)))
2894 (defun gnus-summary-set-article-display-arrow (pos)
2895 "Update the overlay arrow to point to line at position POS."
2896 (when (and gnus-summary-display-arrow
2897 (boundp 'overlay-arrow-position)
2898 (boundp 'overlay-arrow-string))
2902 (unless overlay-arrow-position
2903 (setq overlay-arrow-position (make-marker)))
2904 (setq overlay-arrow-string "=>"
2905 overlay-arrow-position (set-marker overlay-arrow-position
2907 (current-buffer))))))
2909 (defun gnus-summary-buffer-name (group)
2910 "Return the summary buffer name of GROUP."
2911 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2913 (defun gnus-summary-setup-buffer (group)
2914 "Initialize summary buffer."
2915 (let ((buffer (gnus-summary-buffer-name group))
2916 (dead-name (concat "*Dead Summary "
2917 (gnus-group-decoded-name group) "*")))
2918 ;; If a dead summary buffer exists, we kill it.
2919 (when (gnus-buffer-live-p dead-name)
2920 (gnus-kill-buffer dead-name))
2921 (if (get-buffer buffer)
2924 (setq gnus-summary-buffer (current-buffer))
2925 (not gnus-newsgroup-prepared))
2926 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2927 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2928 (gnus-summary-mode group)
2930 (gnus-carpal-setup-buffer 'summary))
2931 (unless gnus-single-article-buffer
2932 (make-local-variable 'gnus-article-buffer)
2933 (make-local-variable 'gnus-article-current)
2934 (make-local-variable 'gnus-original-article-buffer))
2935 (setq gnus-newsgroup-name group)
2936 ;; Set any local variables in the group parameters.
2937 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2940 (defun gnus-set-global-variables ()
2941 "Set the global equivalents of the buffer-local variables.
2942 They are set to the latest values they had. These reflect the summary
2943 buffer that was in action when the last article was fetched."
2944 (when (eq major-mode 'gnus-summary-mode)
2945 (setq gnus-summary-buffer (current-buffer))
2946 (let ((name gnus-newsgroup-name)
2947 (marked gnus-newsgroup-marked)
2948 (unread gnus-newsgroup-unreads)
2949 (headers gnus-current-headers)
2950 (data gnus-newsgroup-data)
2951 (summary gnus-summary-buffer)
2952 (article-buffer gnus-article-buffer)
2953 (original gnus-original-article-buffer)
2954 (gac gnus-article-current)
2955 (reffed gnus-reffed-article-number)
2956 (score-file gnus-current-score-file)
2957 (default-charset gnus-newsgroup-charset)
2959 (let ((locals gnus-newsgroup-variables))
2961 (if (consp (car locals))
2962 (push (eval (caar locals)) vlist)
2963 (push (eval (car locals)) vlist))
2964 (setq locals (cdr locals)))
2965 (setq vlist (nreverse vlist)))
2967 (set-buffer gnus-group-buffer)
2968 (setq gnus-newsgroup-name name
2969 gnus-newsgroup-marked marked
2970 gnus-newsgroup-unreads unread
2971 gnus-current-headers headers
2972 gnus-newsgroup-data data
2973 gnus-article-current gac
2974 gnus-summary-buffer summary
2975 gnus-article-buffer article-buffer
2976 gnus-original-article-buffer original
2977 gnus-reffed-article-number reffed
2978 gnus-current-score-file score-file
2979 gnus-newsgroup-charset default-charset)
2980 (let ((locals gnus-newsgroup-variables))
2982 (if (consp (car locals))
2983 (set (caar locals) (pop vlist))
2984 (set (car locals) (pop vlist)))
2985 (setq locals (cdr locals))))
2986 ;; The article buffer also has local variables.
2987 (when (gnus-buffer-live-p gnus-article-buffer)
2988 (set-buffer gnus-article-buffer)
2989 (setq gnus-summary-buffer summary))))))
2991 (defun gnus-summary-article-unread-p (article)
2992 "Say whether ARTICLE is unread or not."
2993 (memq article gnus-newsgroup-unreads))
2995 (defun gnus-summary-first-article-p (&optional article)
2996 "Return whether ARTICLE is the first article in the buffer."
2997 (if (not (setq article (or article (gnus-summary-article-number))))
2999 (eq article (caar gnus-newsgroup-data))))
3001 (defun gnus-summary-last-article-p (&optional article)
3002 "Return whether ARTICLE is the last article in the buffer."
3003 (if (not (setq article (or article (gnus-summary-article-number))))
3004 ;; All non-existent numbers are the last article. :-)
3006 (not (cdr (gnus-data-find-list article)))))
3008 (defun gnus-make-thread-indent-array ()
3010 (unless (and gnus-thread-indent-array
3011 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3012 (setq gnus-thread-indent-array (make-vector 201 "")
3013 gnus-thread-indent-array-level gnus-thread-indent-level)
3015 (aset gnus-thread-indent-array n
3016 (make-string (* n gnus-thread-indent-level) ? ))
3019 (defun gnus-update-summary-mark-positions ()
3020 "Compute where the summary marks are to go."
3022 (when (gnus-buffer-exists-p gnus-summary-buffer)
3023 (set-buffer gnus-summary-buffer))
3024 (let ((gnus-replied-mark 129)
3025 (gnus-score-below-mark 130)
3026 (gnus-score-over-mark 130)
3027 (gnus-download-mark 131)
3028 (spec gnus-summary-line-format-spec)
3031 (gnus-set-work-buffer)
3032 (let ((gnus-summary-line-format-spec spec)
3033 (gnus-newsgroup-downloadable '((0 . t))))
3034 (gnus-summary-insert-line
3035 (make-full-mail-header 0 "" "nobody"
3036 "05 Apr 2001 23:33:09 +0400"
3038 0 nil 128 t nil "" nil 1)
3039 (goto-char (point-min))
3040 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3041 (- (point) (point-min) 1)))))
3042 (goto-char (point-min))
3043 (push (cons 'replied (and (search-forward "\201" nil t)
3044 (- (point) (point-min) 1)))
3046 (goto-char (point-min))
3047 (push (cons 'score (and (search-forward "\202" nil t)
3048 (- (point) (point-min) 1)))
3050 (goto-char (point-min))
3051 (push (cons 'download
3052 (and (search-forward "\203" nil t)
3053 (- (point) (point-min) 1)))
3055 (setq gnus-summary-mark-positions pos))))
3057 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3058 "Insert a dummy root in the summary buffer."
3060 (gnus-add-text-properties
3061 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3062 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3064 (defun gnus-summary-extract-address-component (from)
3065 (or (car (funcall gnus-extract-address-components from))
3068 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3069 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3070 default-mime-charset)))
3071 ;; Is it really necessary to do this next part for each summary line?
3072 ;; Luckily, doesn't seem to slow things down much.
3074 (and gnus-ignored-from-addresses
3075 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3076 (let ((extra-headers (mail-header-extra header))
3080 ((setq to (cdr (assq 'To extra-headers)))
3083 (gnus-summary-extract-address-component
3084 (funcall gnus-decode-encoded-word-function to)))))
3085 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3086 (concat "=> " newsgroups)))))
3087 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3089 (defun gnus-summary-insert-line (gnus-tmp-header
3090 gnus-tmp-level gnus-tmp-current
3091 gnus-tmp-unread gnus-tmp-replied
3092 gnus-tmp-expirable gnus-tmp-subject-or-nil
3093 &optional gnus-tmp-dummy gnus-tmp-score
3095 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3096 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3097 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3098 (gnus-tmp-score-char
3099 (if (or (null gnus-summary-default-score)
3100 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3101 gnus-summary-zcore-fuzz))
3103 (if (< gnus-tmp-score gnus-summary-default-score)
3104 gnus-score-below-mark gnus-score-over-mark)))
3105 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3107 (cond (gnus-tmp-process gnus-process-mark)
3108 ((memq gnus-tmp-current gnus-newsgroup-cached)
3110 (gnus-tmp-replied gnus-replied-mark)
3111 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3112 gnus-forwarded-mark)
3113 ((memq gnus-tmp-current gnus-newsgroup-saved)
3115 ((memq gnus-tmp-number gnus-newsgroup-recent)
3117 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3120 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3123 ((string-match "<[^>]+> *$" gnus-tmp-from)
3124 (let ((beg (match-beginning 0)))
3125 (or (and (string-match "^\".+\"" gnus-tmp-from)
3126 (substring gnus-tmp-from 1 (1- (match-end 0))))
3127 (substring gnus-tmp-from 0 beg))))
3128 ((string-match "(.+)" gnus-tmp-from)
3129 (substring gnus-tmp-from
3130 (1+ (match-beginning 0)) (1- (match-end 0))))
3132 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3133 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3134 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3135 (buffer-read-only nil))
3136 (when (string= gnus-tmp-name "")
3137 (setq gnus-tmp-name gnus-tmp-from))
3138 (unless (numberp gnus-tmp-lines)
3139 (setq gnus-tmp-lines -1))
3140 (if (= gnus-tmp-lines -1)
3141 (setq gnus-tmp-lines "?")
3142 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3143 (gnus-put-text-property-excluding-characters-with-faces
3145 (progn (eval gnus-summary-line-format-spec) (point))
3146 'gnus-number gnus-tmp-number)
3147 (when (gnus-visual-p 'summary-highlight 'highlight)
3149 (gnus-run-hooks 'gnus-summary-update-hook)
3152 (defun gnus-summary-update-line (&optional dont-update)
3153 "Update summary line after change."
3154 (when (and gnus-summary-default-score
3155 (not gnus-summary-inhibit-highlight))
3156 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3157 (article (gnus-summary-article-number))
3158 (score (gnus-summary-article-score article)))
3160 (if (and gnus-summary-mark-below
3161 (< (gnus-summary-article-score)
3162 gnus-summary-mark-below))
3163 ;; This article has a low score, so we mark it as read.
3164 (when (memq article gnus-newsgroup-unreads)
3165 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3166 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3167 ;; This article was previously marked as read on account
3168 ;; of a low score, but now it has risen, so we mark it as
3170 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3171 (gnus-summary-update-mark
3172 (if (or (null gnus-summary-default-score)
3173 (<= (abs (- score gnus-summary-default-score))
3174 gnus-summary-zcore-fuzz))
3176 (if (< score gnus-summary-default-score)
3177 gnus-score-below-mark gnus-score-over-mark))
3179 ;; Do visual highlighting.
3180 (when (gnus-visual-p 'summary-highlight 'highlight)
3181 (gnus-run-hooks 'gnus-summary-update-hook)))))
3183 (defvar gnus-tmp-new-adopts nil)
3185 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3186 "Return the number of articles in THREAD.
3187 This may be 0 in some cases -- if none of the articles in
3188 the thread are to be displayed."
3190 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3192 ((not (listp thread))
3194 ((and (consp thread) (cdr thread))
3197 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3200 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3203 (when (and level (zerop level) gnus-tmp-new-adopts)
3206 'gnus-summary-number-of-articles-in-thread
3207 gnus-tmp-new-adopts))))
3209 (if (> number 1) gnus-not-empty-thread-mark
3210 gnus-empty-thread-mark)
3213 (defun gnus-summary-set-local-parameters (group)
3214 "Go through the local params of GROUP and set all variable specs in that list."
3215 (let ((params (gnus-group-find-parameter group))
3216 (vars '(quit-config)) ; Ignore quit-config.
3219 (setq elem (car params)
3220 params (cdr params))
3221 (and (consp elem) ; Has to be a cons.
3222 (consp (cdr elem)) ; The cdr has to be a list.
3223 (symbolp (car elem)) ; Has to be a symbol in there.
3224 (not (memq (car elem) vars))
3225 (ignore-errors ; So we set it.
3226 (push (car elem) vars)
3227 (make-local-variable (car elem))
3228 (set (car elem) (eval (nth 1 elem))))))))
3230 (defun gnus-summary-read-group (group &optional show-all no-article
3231 kill-buffer no-display backward
3233 "Start reading news in newsgroup GROUP.
3234 If SHOW-ALL is non-nil, already read articles are also listed.
3235 If NO-ARTICLE is non-nil, no article is selected initially.
3236 If NO-DISPLAY, don't generate a summary buffer."
3240 (let ((gnus-auto-select-next nil))
3241 (or (gnus-summary-read-group-1
3242 group show-all no-article
3243 kill-buffer no-display
3246 select-articles nil)))))
3247 (eq gnus-auto-select-next 'quietly))
3248 (set-buffer gnus-group-buffer)
3249 ;; The entry function called above goes to the next
3250 ;; group automatically, so we go two groups back
3251 ;; if we are searching for the previous group.
3253 (gnus-group-prev-unread-group 2))
3254 (if (not (equal group (gnus-group-group-name)))
3255 (setq group (gnus-group-group-name))
3259 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3260 "Directly jump to the other GROUP from summary buffer.
3261 If SHOW-ALL is non-nil, already read articles are also listed."
3263 (if (eq gnus-summary-buffer (current-buffer))
3264 (list (completing-read
3265 "Group: " gnus-active-hashtb nil t
3266 (when (and gnus-newsgroup-name
3267 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3268 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3269 'gnus-group-history)
3271 (error "%s must be invoked from a gnus summary buffer." this-command)))
3272 (unless (or (zerop (length group))
3273 (and gnus-newsgroup-name
3274 (string-equal gnus-newsgroup-name group)))
3276 (gnus-summary-read-group group show-all
3277 gnus-dont-select-after-jump-to-other-group)))
3279 (defun gnus-summary-read-group-1 (group show-all no-article
3280 kill-buffer no-display
3281 &optional select-articles)
3282 ;; Killed foreign groups can't be entered.
3283 ;; (when (and (not (gnus-group-native-p group))
3284 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3285 ;; (error "Dead non-native groups can't be entered"))
3286 (gnus-message 5 "Retrieving newsgroup: %s..."
3287 (gnus-group-decoded-name group))
3288 (let* ((new-group (gnus-summary-setup-buffer group))
3289 (quit-config (gnus-group-quit-config group))
3290 (did-select (and new-group (gnus-select-newsgroup
3291 group show-all select-articles))))
3293 ;; This summary buffer exists already, so we just select it.
3295 (gnus-set-global-variables)
3297 (gnus-kill-or-deaden-summary kill-buffer))
3298 (gnus-configure-windows 'summary 'force)
3299 (gnus-set-mode-line 'summary)
3300 (gnus-summary-position-point)
3303 ;; We couldn't select this group.
3305 (when (and (eq major-mode 'gnus-summary-mode)
3306 (not (equal (current-buffer) kill-buffer)))
3307 (kill-buffer (current-buffer))
3308 (if (not quit-config)
3310 ;; Update the info -- marks might need to be removed,
3312 (gnus-summary-update-info)
3313 (set-buffer gnus-group-buffer)
3314 (gnus-group-jump-to-group group)
3315 (gnus-group-next-unread-group 1))
3316 (gnus-handle-ephemeral-exit quit-config)))
3317 (let ((grpinfo (gnus-get-info group)))
3318 (if (null (gnus-info-read grpinfo))
3319 (gnus-message 3 "Group %s contains no messages"
3320 (gnus-group-decoded-name group))
3321 (gnus-message 3 "Can't select group")))
3323 ;; The user did a `C-g' while prompting for number of articles,
3324 ;; so we exit this group.
3325 ((eq did-select 'quit)
3326 (and (eq major-mode 'gnus-summary-mode)
3327 (not (equal (current-buffer) kill-buffer))
3328 (kill-buffer (current-buffer)))
3330 (gnus-kill-or-deaden-summary kill-buffer))
3331 (if (not quit-config)
3333 (set-buffer gnus-group-buffer)
3334 (gnus-group-jump-to-group group)
3335 (gnus-group-next-unread-group 1)
3336 (gnus-configure-windows 'group 'force))
3337 (gnus-handle-ephemeral-exit quit-config))
3338 ;; Finally signal the quit.
3340 ;; The group was successfully selected.
3342 (gnus-set-global-variables)
3343 ;; Save the active value in effect when the group was entered.
3344 (setq gnus-newsgroup-active
3346 (gnus-active gnus-newsgroup-name)))
3347 ;; You can change the summary buffer in some way with this hook.
3348 (gnus-run-hooks 'gnus-select-group-hook)
3349 (gnus-update-format-specifications
3350 nil 'summary 'summary-mode 'summary-dummy)
3351 (gnus-update-summary-mark-positions)
3352 ;; Do score processing.
3353 (when gnus-use-scoring
3354 (gnus-possibly-score-headers))
3355 ;; Check whether to fill in the gaps in the threads.
3356 (when gnus-build-sparse-threads
3357 (gnus-build-sparse-threads))
3358 ;; Find the initial limit.
3359 (if gnus-show-threads
3361 (let ((gnus-newsgroup-dormant nil))
3362 (gnus-summary-initial-limit show-all))
3363 (gnus-summary-initial-limit show-all))
3364 ;; When untreaded, all articles are always shown.
3365 (setq gnus-newsgroup-limit
3367 (lambda (header) (mail-header-number header))
3368 gnus-newsgroup-headers)))
3369 ;; Generate the summary buffer.
3371 (gnus-summary-prepare))
3372 (when gnus-use-trees
3373 (gnus-tree-open group)
3374 (setq gnus-summary-highlight-line-function
3375 'gnus-tree-highlight-article))
3376 ;; If the summary buffer is empty, but there are some low-scored
3377 ;; articles or some excluded dormants, we include these in the
3379 (when (and (zerop (buffer-size))
3381 (cond (gnus-newsgroup-dormant
3382 (gnus-summary-limit-include-dormant))
3383 ((and gnus-newsgroup-scored show-all)
3384 (gnus-summary-limit-include-expunged t))))
3385 ;; Function `gnus-apply-kill-file' must be called in this hook.
3386 (gnus-run-hooks 'gnus-apply-kill-hook)
3387 (if (and (zerop (buffer-size))
3390 ;; This newsgroup is empty.
3391 (gnus-summary-catchup-and-exit nil t)
3392 (gnus-message 6 "No unread news")
3394 (gnus-kill-or-deaden-summary kill-buffer))
3395 ;; Return nil from this function.
3397 ;; Hide conversation thread subtrees. We cannot do this in
3398 ;; gnus-summary-prepare-hook since kill processing may not
3399 ;; work with hidden articles.
3400 (gnus-summary-maybe-hide-threads)
3402 (gnus-kill-or-deaden-summary kill-buffer))
3403 (gnus-summary-auto-select-subject)
3404 ;; Show first unread article if requested.
3405 (if (and (not no-article)
3407 gnus-newsgroup-unreads
3408 gnus-auto-select-first)
3410 (gnus-configure-windows 'summary)
3411 (let ((art (gnus-summary-article-number)))
3412 (unless (or (memq art gnus-newsgroup-undownloaded)
3413 (memq art gnus-newsgroup-downloadable))
3414 (gnus-summary-goto-article art))))
3415 ;; Don't select any articles.
3416 (gnus-summary-position-point)
3417 (gnus-configure-windows 'summary 'force)
3418 (gnus-set-mode-line 'summary))
3419 (when (get-buffer-window gnus-group-buffer t)
3420 ;; Gotta use windows, because recenter does weird stuff if
3421 ;; the current buffer ain't the displayed window.
3422 (let ((owin (selected-window)))
3423 (select-window (get-buffer-window gnus-group-buffer t))
3424 (when (gnus-group-goto-group group)
3426 (select-window owin)))
3427 ;; Mark this buffer as "prepared".
3428 (setq gnus-newsgroup-prepared t)
3429 (gnus-run-hooks 'gnus-summary-prepared-hook)
3432 (defun gnus-summary-auto-select-subject ()
3433 "Select the subject line on initial group entry."
3434 (goto-char (point-min))
3436 ((eq gnus-auto-select-subject 'best)
3437 (gnus-summary-best-unread-subject))
3438 ((eq gnus-auto-select-subject 'unread)
3439 (gnus-summary-first-unread-subject))
3440 ((eq gnus-auto-select-subject 'unseen)
3441 (gnus-summary-first-unseen-subject))
3442 ((eq gnus-auto-select-subject 'unseen-or-unread)
3443 (gnus-summary-first-unseen-or-unread-subject))
3444 ((eq gnus-auto-select-subject 'first)
3447 ((gnus-functionp gnus-auto-select-subject)
3448 (funcall gnus-auto-select-subject))))
3450 (defun gnus-summary-prepare ()
3451 "Generate the summary buffer."
3453 (let ((buffer-read-only nil))
3455 (setq gnus-newsgroup-data nil
3456 gnus-newsgroup-data-reverse nil)
3457 (gnus-run-hooks 'gnus-summary-generate-hook)
3458 ;; Generate the buffer, either with threads or without.
3459 (when gnus-newsgroup-headers
3460 (gnus-summary-prepare-threads
3461 (if gnus-show-threads
3462 (gnus-sort-gathered-threads
3463 (funcall gnus-summary-thread-gathering-function
3465 (gnus-cut-threads (gnus-make-threads)))))
3466 ;; Unthreaded display.
3467 (gnus-sort-articles gnus-newsgroup-headers))))
3468 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3469 ;; Call hooks for modifying summary buffer.
3470 (goto-char (point-min))
3471 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3473 (defsubst gnus-general-simplify-subject (subject)
3474 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3477 ;; Truncate the subject.
3478 (gnus-simplify-subject-functions
3479 (gnus-map-function gnus-simplify-subject-functions subject))
3480 ((numberp gnus-summary-gather-subject-limit)
3481 (setq subject (gnus-simplify-subject-re subject))
3482 (if (> (length subject) gnus-summary-gather-subject-limit)
3483 (substring subject 0 gnus-summary-gather-subject-limit)
3485 ;; Fuzzily simplify it.
3486 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3487 (gnus-simplify-subject-fuzzy subject))
3488 ;; Just remove the leading "Re:".
3490 (gnus-simplify-subject-re subject))))
3492 (if (and gnus-summary-gather-exclude-subject
3493 (string-match gnus-summary-gather-exclude-subject subject))
3494 nil ; This article shouldn't be gathered
3497 (defun gnus-summary-simplify-subject-query ()
3498 "Query where the respool algorithm would put this article."
3500 (gnus-summary-select-article)
3502 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3504 (defun gnus-gather-threads-by-subject (threads)
3505 "Gather threads by looking at Subject headers."
3506 (if (not gnus-summary-make-false-root)
3508 (let ((hashtb (gnus-make-hashtable 1024))
3511 subject hthread whole-subject)
3513 (setq subject (gnus-general-simplify-subject
3514 (setq whole-subject (mail-header-subject
3517 (if (setq hthread (gnus-gethash subject hashtb))
3519 ;; We enter a dummy root into the thread, if we
3520 ;; haven't done that already.
3521 (unless (stringp (caar hthread))
3522 (setcar hthread (list whole-subject (car hthread))))
3523 ;; We add this new gathered thread to this gathered
3525 (setcdr (car hthread)
3526 (nconc (cdar hthread) (list (car threads))))
3527 ;; Remove it from the list of threads.
3528 (setcdr prev (cdr threads))
3529 (setq threads prev))
3530 ;; Enter this thread into the hash table.
3531 (gnus-sethash subject threads hashtb)))
3533 (setq threads (cdr threads)))
3536 (defun gnus-gather-threads-by-references (threads)
3537 "Gather threads by looking at References headers."
3538 (let ((idhashtb (gnus-make-hashtable 1024))
3539 (thhashtb (gnus-make-hashtable 1024))
3542 ids references id gthread gid entered ref)
3544 (when (setq references (mail-header-references (caar threads)))
3545 (setq id (mail-header-id (caar threads))
3546 ids (inline (gnus-split-references references))
3548 (while (setq ref (pop ids))
3549 (setq ids (delete ref ids))
3550 (if (not (setq gid (gnus-gethash ref idhashtb)))
3552 (gnus-sethash ref id idhashtb)
3553 (gnus-sethash id threads thhashtb))
3554 (setq gthread (gnus-gethash gid thhashtb))
3556 ;; We enter a dummy root into the thread, if we
3557 ;; haven't done that already.
3558 (unless (stringp (caar gthread))
3559 (setcar gthread (list (mail-header-subject (caar gthread))
3561 ;; We add this new gathered thread to this gathered
3563 (setcdr (car gthread)
3564 (nconc (cdar gthread) (list (car threads)))))
3565 ;; Add it into the thread hash table.
3566 (gnus-sethash id gthread thhashtb)
3568 ;; Remove it from the list of threads.
3569 (setcdr prev (cdr threads))
3570 (setq threads prev))))
3572 (setq threads (cdr threads)))
3575 (defun gnus-sort-gathered-threads (threads)
3576 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3577 (let ((result threads))
3579 (when (stringp (caar threads))
3580 (setcdr (car threads)
3581 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3582 (setq threads (cdr threads)))
3585 (defun gnus-thread-loop-p (root thread)
3586 "Say whether ROOT is in THREAD."
3587 (let ((stack (list thread))
3590 (while (setq thread (pop stack))
3591 (setq th (cdr thread))
3593 (not (eq (caar th) root)))
3596 ;; We have found a loop.
3598 (setcdr thread (delq (car th) (cdr thread)))
3599 (if (boundp (setq ref-dep (intern "none"
3600 gnus-newsgroup-dependencies)))
3601 (setcdr (symbol-value ref-dep)
3602 (nconc (cdr (symbol-value ref-dep))
3604 (set ref-dep (list nil (car th))))
3607 ;; Push all the subthreads onto the stack.
3608 (push (cdr thread) stack)))
3611 (defun gnus-make-threads ()
3612 "Go through the dependency hashtb and find the roots. Return all threads."
3614 (while (catch 'infloop
3617 ;; Deal with self-referencing References loops.
3618 (when (and (car (symbol-value refs))
3625 (car (symbol-value refs)) thread))
3626 (cdr (symbol-value refs)))))))
3629 (unless (car (symbol-value refs))
3630 ;; These threads do not refer back to any other articles,
3631 ;; so they're roots.
3632 (setq threads (append (cdr (symbol-value refs)) threads))))
3633 gnus-newsgroup-dependencies)))
3636 ;; Build the thread tree.
3637 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3638 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3640 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3641 if it was already present.
3643 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3644 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3645 Message-IDs will be renamed to a unique Message-ID before being
3648 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3649 (let* ((id (mail-header-id header))
3650 (id-dep (and id (intern id dependencies)))
3651 ref ref-dep ref-header replaced)
3652 ;; Enter this `header' in the `dependencies' table.
3656 ;; The first two cases do the normal part: enter a new `header'
3657 ;; in the `dependencies' table.
3658 ((not (boundp id-dep))
3659 (set id-dep (list header)))
3660 ((null (car (symbol-value id-dep)))
3661 (setcar (symbol-value id-dep) header))
3663 ;; From here the `header' was already present in the
3664 ;; `dependencies' table.
3666 ;; Overrides an existing entry;
3667 ;; just set the header part of the entry.
3668 (setcar (symbol-value id-dep) header)
3671 ;; Renames the existing `header' to a unique Message-ID.
3672 ((not gnus-summary-ignore-duplicates)
3673 ;; An article with this Message-ID has already been seen.
3674 ;; We rename the Message-ID.
3675 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3677 (mail-header-set-id header id))
3679 ;; The last case ignores an existing entry, except it adds any
3680 ;; additional Xrefs (in case the two articles came from different
3682 ;; Also sets `header' to `nil' meaning that the `dependencies'
3683 ;; table was *not* modified.
3685 (mail-header-set-xref
3686 (car (symbol-value id-dep))
3687 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3689 (or (mail-header-xref header) "")))
3692 (when (and header (not replaced))
3693 ;; First check that we are not creating a References loop.
3694 (setq ref (gnus-parent-id (mail-header-references header)))
3696 (setq ref-dep (intern-soft ref dependencies))
3698 (setq ref-header (car (symbol-value ref-dep))))
3699 (if (string= id ref)
3700 ;; Yuk! This is a reference loop. Make the article be a
3703 (mail-header-set-references (car (symbol-value id-dep)) "none")
3705 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3706 (setq ref (gnus-parent-id (mail-header-references header)))
3707 (setq ref-dep (intern (or ref "none") dependencies))
3708 (if (boundp ref-dep)
3709 (setcdr (symbol-value ref-dep)
3710 (nconc (cdr (symbol-value ref-dep))
3711 (list (symbol-value id-dep))))
3712 (set ref-dep (list nil (symbol-value id-dep)))))
3715 (defun gnus-extract-message-id-from-in-reply-to (string)
3716 (if (string-match "<[^>]+>" string)
3717 (substring string (match-beginning 0) (match-end 0))
3720 (defun gnus-build-sparse-threads ()
3721 (let ((headers gnus-newsgroup-headers)
3722 (mail-parse-charset gnus-newsgroup-charset)
3723 (gnus-summary-ignore-duplicates t)
3724 header references generation relations
3725 subject child end new-child date)
3726 ;; First we create an alist of generations/relations, where
3727 ;; generations is how much we trust the relation, and the relation
3729 (gnus-message 7 "Making sparse threads...")
3731 (nnheader-set-temp-buffer " *gnus sparse threads*")
3732 (while (setq header (pop headers))
3733 (when (and (setq references (mail-header-references header))
3734 (not (string= references "")))
3736 (setq child (mail-header-id header)
3737 subject (mail-header-subject header)
3738 date (mail-header-date header)
3740 (while (search-backward ">" nil t)
3741 (setq end (1+ (point)))
3742 (when (search-backward "<" nil t)
3743 (setq new-child (buffer-substring (point) end))
3744 (push (list (incf generation)
3745 child (setq child new-child)
3749 (push (list (1+ generation) child nil subject) relations))
3751 (kill-buffer (current-buffer)))
3752 ;; Sort over trustworthiness.
3755 (when (gnus-dependencies-add-header
3756 (make-full-mail-header-from-decoded-header
3757 gnus-reffed-article-number
3758 (nth 3 relation) "" (or (nth 4 relation) "")
3760 (or (nth 2 relation) "") 0 0 "")
3761 gnus-newsgroup-dependencies nil)
3762 (push gnus-reffed-article-number gnus-newsgroup-limit)
3763 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3764 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3765 gnus-newsgroup-reads)
3766 (decf gnus-reffed-article-number)))
3767 (sort relations 'car-less-than-car))
3768 (gnus-message 7 "Making sparse threads...done")))
3770 (defun gnus-build-old-threads ()
3771 ;; Look at all the articles that refer back to old articles, and
3772 ;; fetch the headers for the articles that aren't there. This will
3773 ;; build complete threads - if the roots haven't been expired by the
3775 (let ((mail-parse-charset gnus-newsgroup-charset)
3779 (when (not (car (symbol-value refs)))
3780 (setq heads (cdr (symbol-value refs)))
3782 (if (memq (mail-header-number (caar heads))
3783 gnus-newsgroup-dormant)
3784 (setq heads (cdr heads))
3785 (setq id (symbol-name refs))
3786 (while (and (setq id (gnus-build-get-header id))
3787 (not (car (gnus-id-to-thread id)))))
3788 (setq heads nil)))))
3789 gnus-newsgroup-dependencies)))
3791 ;; This function has to be called with point after the article number
3792 ;; on the beginning of the line.
3793 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3794 (let ((eol (gnus-point-at-eol))
3795 (buffer (current-buffer))
3796 header references in-reply-to)
3798 ;; overview: [num subject from date id refs chars lines misc]
3801 (narrow-to-region (point) eol)
3806 (make-full-mail-header
3808 (nnheader-nov-field) ; subject
3809 (nnheader-nov-field) ; from
3810 (nnheader-nov-field) ; date
3811 (nnheader-nov-read-message-id) ; id
3812 (nnheader-nov-field) ; refs
3813 (nnheader-nov-read-integer) ; chars
3814 (nnheader-nov-read-integer) ; lines
3816 (if (looking-at "Xref: ")
3817 (goto-char (match-end 0)))
3818 (nnheader-nov-field)) ; Xref
3819 (nnheader-nov-parse-extra)))) ; extra
3823 (when (and (string= references "")
3824 (setq in-reply-to (mail-header-extra header))
3825 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3826 (mail-header-set-references
3827 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3829 (when gnus-alter-header-function
3830 (funcall gnus-alter-header-function header))
3831 (gnus-dependencies-add-header header dependencies force-new)))
3833 (defun gnus-build-get-header (id)
3834 "Look through the buffer of NOV lines and find the header to ID.
3835 Enter this line into the dependencies hash table, and return
3836 the id of the parent article (if any)."
3837 (let ((deps gnus-newsgroup-dependencies)
3841 (set-buffer nntp-server-buffer)
3842 (let ((case-fold-search nil))
3843 (goto-char (point-min))
3844 (while (and (not found)
3845 (search-forward id nil t))
3847 (setq found (looking-at
3848 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3849 (regexp-quote id))))
3850 (or found (beginning-of-line 2)))
3854 (setq header (gnus-nov-parse-line
3855 (read (current-buffer)) deps))
3856 (gnus-parent-id (mail-header-references header))))))
3858 (let ((number (mail-header-number header)))
3859 (push number gnus-newsgroup-limit)
3860 (push header gnus-newsgroup-headers)
3861 (if (memq number gnus-newsgroup-unselected)
3863 (setq gnus-newsgroup-unreads
3864 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3866 (setq gnus-newsgroup-unselected
3867 (delq number gnus-newsgroup-unselected)))
3868 (push number gnus-newsgroup-ancient)))))))
3870 (defun gnus-build-all-threads ()
3871 "Read all the headers."
3872 (let ((gnus-summary-ignore-duplicates t)
3873 (mail-parse-charset gnus-newsgroup-charset)
3874 (dependencies gnus-newsgroup-dependencies)
3877 (set-buffer nntp-server-buffer)
3878 (let ((case-fold-search nil))
3879 (goto-char (point-min))
3882 (setq article (read (current-buffer))
3883 header (gnus-nov-parse-line article dependencies)))
3886 (set-buffer gnus-summary-buffer)
3887 (push header gnus-newsgroup-headers)
3888 (if (memq (setq article (mail-header-number header))
3889 gnus-newsgroup-unselected)
3891 (setq gnus-newsgroup-unreads
3892 (gnus-add-to-sorted-list
3893 gnus-newsgroup-unreads article))
3894 (setq gnus-newsgroup-unselected
3895 (delq article gnus-newsgroup-unselected)))
3896 (push article gnus-newsgroup-ancient)))
3897 (forward-line 1)))))))
3899 (defun gnus-summary-update-article-line (article header)
3900 "Update the line for ARTICLE using HEADERS."
3901 (let* ((id (mail-header-id header))
3902 (thread (gnus-id-to-thread id)))
3904 (error "Article in no thread"))
3905 ;; Update the thread.
3906 (setcar thread header)
3907 (gnus-summary-goto-subject article)
3908 (let* ((datal (gnus-data-find-list article))
3910 (length (when (cdr datal)
3911 (- (gnus-data-pos data)
3912 (gnus-data-pos (cadr datal)))))
3913 (buffer-read-only nil)
3914 (level (gnus-summary-thread-level)))
3916 (gnus-summary-insert-line
3917 header level nil (gnus-article-mark article)
3918 (memq article gnus-newsgroup-replied)
3919 (memq article gnus-newsgroup-expirable)
3920 ;; Only insert the Subject string when it's different
3921 ;; from the previous Subject string.
3926 (mail-header-subject
3929 (gnus-data-find-list
3931 (gnus-data-list t)))))
3932 ;; Error on the side of excessive subjects.
3934 (mail-header-subject header)))
3936 (mail-header-subject header))
3937 nil (cdr (assq article gnus-newsgroup-scored))
3938 (memq article gnus-newsgroup-processable))
3940 (gnus-data-update-list
3941 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3943 (defun gnus-summary-update-article (article &optional iheader)
3944 "Update ARTICLE in the summary buffer."
3945 (set-buffer gnus-summary-buffer)
3946 (let* ((header (gnus-summary-article-header article))
3947 (id (mail-header-id header))
3948 (data (gnus-data-find article))
3949 (thread (gnus-id-to-thread id))
3950 (references (mail-header-references header))
3954 (when (and references
3955 (not (equal "" references)))
3958 (buffer-read-only nil)
3964 (delq thread parent)))
3965 (if (gnus-summary-insert-subject id header)
3966 ;; Set the (possibly) new article number in the data structure.
3967 (gnus-data-set-number data (gnus-id-to-article id))
3971 (defun gnus-rebuild-thread (id &optional line)
3972 "Rebuild the thread containing ID.
3973 If LINE, insert the rebuilt thread starting on line LINE."
3974 (let ((buffer-read-only nil)
3975 old-pos current thread data)
3976 (if (not gnus-show-threads)
3977 (setq thread (list (car (gnus-id-to-thread id))))
3978 ;; Get the thread this article is part of.
3979 (setq thread (gnus-remove-thread id)))
3980 (setq old-pos (gnus-point-at-bol))
3981 (setq current (save-excursion
3982 (and (re-search-backward "[\r\n]" nil t)
3983 (gnus-summary-article-number))))
3984 ;; If this is a gathered thread, we have to go some re-gathering.
3985 (when (stringp (car thread))
3986 (let ((subject (car thread))
3988 (setq thread (cdr thread))
3990 (unless (memq (setq thr (gnus-id-to-thread
3992 (mail-header-id (caar thread)))))
3995 (setq thread (cdr thread)))
3996 ;; We now have all (unique) roots.
3997 (if (= (length roots) 1)
3998 ;; All the loose roots are now one solid root.
3999 (setq thread (car roots))
4000 (setq thread (cons subject (gnus-sort-threads roots))))))
4002 ;; We then insert this thread into the summary buffer.
4004 (goto-char (point-min))
4005 (forward-line (1- line)))
4006 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4007 (if gnus-show-threads
4008 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4009 (gnus-summary-prepare-unthreaded thread))
4010 (setq data (nreverse gnus-newsgroup-data))
4011 (setq threads gnus-newsgroup-threads))
4012 ;; We splice the new data into the data structure.
4013 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4014 ;;!!! then we want to insert at the beginning of the buffer.
4015 ;;!!! That happens to be true with Gnus now, but that may
4016 ;;!!! change in the future. Perhaps.
4017 (gnus-data-enter-list
4018 (if line nil current) data (- (point) old-pos))
4019 (setq gnus-newsgroup-threads
4020 (nconc threads gnus-newsgroup-threads))
4021 (gnus-data-compute-positions))))
4023 (defun gnus-number-to-header (number)
4024 "Return the header for article NUMBER."
4025 (let ((headers gnus-newsgroup-headers))
4027 (not (= number (mail-header-number (car headers)))))
4032 (defun gnus-parent-headers (in-headers &optional generation)
4033 "Return the headers of the GENERATIONeth parent of HEADERS."
4035 (setq generation 1))
4037 (headers in-headers)
4040 (not (zerop generation))
4041 (setq references (mail-header-references headers)))
4042 (setq headers (if (and references
4043 (setq parent (gnus-parent-id references)))
4044 (car (gnus-id-to-thread parent))
4047 (and (not (eq headers in-headers))
4050 (defun gnus-id-to-thread (id)
4051 "Return the (sub-)thread where ID appears."
4052 (gnus-gethash id gnus-newsgroup-dependencies))
4054 (defun gnus-id-to-article (id)
4055 "Return the article number of ID."
4056 (let ((thread (gnus-id-to-thread id)))
4059 (mail-header-number (car thread)))))
4061 (defun gnus-id-to-header (id)
4062 "Return the article headers of ID."
4063 (car (gnus-id-to-thread id)))
4065 (defun gnus-article-displayed-root-p (article)
4066 "Say whether ARTICLE is a root(ish) article."
4067 (let ((level (gnus-summary-thread-level article))
4068 (refs (mail-header-references (gnus-summary-article-header article)))
4074 ((null (gnus-parent-id refs)) t)
4076 (null (setq particle (gnus-id-to-article
4077 (gnus-parent-id refs))))
4078 (null (gnus-summary-thread-level particle)))))))
4080 (defun gnus-root-id (id)
4081 "Return the id of the root of the thread where ID appears."
4083 (while (and id (setq prev (car (gnus-id-to-thread id))))
4085 id (gnus-parent-id (mail-header-references prev))))
4088 (defun gnus-articles-in-thread (thread)
4089 "Return the list of articles in THREAD."
4090 (cons (mail-header-number (car thread))
4091 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4093 (defun gnus-remove-thread (id &optional dont-remove)
4094 "Remove the thread that has ID in it."
4095 (let (headers thread last-id)
4096 ;; First go up in this thread until we find the root.
4097 (setq last-id (gnus-root-id id)
4098 headers (message-flatten-list (gnus-id-to-thread last-id)))
4099 ;; We have now found the real root of this thread. It might have
4100 ;; been gathered into some loose thread, so we have to search
4101 ;; through the threads to find the thread we wanted.
4102 (let ((threads gnus-newsgroup-threads)
4105 (setq sub (car threads))
4106 (if (stringp (car sub))
4107 ;; This is a gathered thread, so we look at the roots
4108 ;; below it to find whether this article is in this
4111 (setq sub (cdr sub))
4113 (when (member (caar sub) headers)
4114 (setq thread (car threads)
4117 (setq sub (cdr sub))))
4118 ;; It's an ordinary thread, so we check it.
4119 (when (eq (car sub) (car headers))
4122 (setq threads (cdr threads)))
4123 ;; If this article is in no thread, then it's a root.
4126 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4127 (setq thread (gnus-id-to-thread last-id)))
4130 thread ; We return this thread.
4132 (if (stringp (car thread))
4134 ;; If we use dummy roots, then we have to remove the
4135 ;; dummy root as well.
4136 (when (eq gnus-summary-make-false-root 'dummy)
4137 ;; We go to the dummy root by going to
4138 ;; the first sub-"thread", and then one line up.
4139 (gnus-summary-goto-article
4140 (mail-header-number (caadr thread)))
4143 (gnus-data-compute-positions))
4144 (setq thread (cdr thread))
4146 (gnus-remove-thread-1 (car thread))
4147 (setq thread (cdr thread))))
4148 (gnus-remove-thread-1 thread))))))))
4150 (defun gnus-remove-thread-1 (thread)
4151 "Remove the thread THREAD recursively."
4152 (let ((number (mail-header-number (pop thread)))
4154 (setq thread (reverse thread))
4156 (gnus-remove-thread-1 (pop thread)))
4157 (when (setq d (gnus-data-find number))
4158 (goto-char (gnus-data-pos d))
4159 (gnus-summary-show-thread)
4162 (- (gnus-point-at-bol)
4164 (1+ (gnus-point-at-eol))
4165 (gnus-delete-line)))))))
4167 (defun gnus-sort-threads-1 (threads func)
4168 (sort (mapcar (lambda (thread)
4171 (gnus-sort-threads-1 (cdr thread) func))))
4174 (defun gnus-sort-threads (threads)
4176 (if (not gnus-thread-sort-functions)
4178 (gnus-message 8 "Sorting threads...")
4180 (gnus-sort-threads-1
4182 (gnus-make-sort-function gnus-thread-sort-functions))
4183 (gnus-message 8 "Sorting threads...done"))))
4185 (defun gnus-sort-articles (articles)
4187 (when gnus-article-sort-functions
4188 (gnus-message 7 "Sorting articles...")
4190 (setq gnus-newsgroup-headers
4191 (sort articles (gnus-make-sort-function
4192 gnus-article-sort-functions)))
4193 (gnus-message 7 "Sorting articles...done"))))
4195 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4196 (defmacro gnus-thread-header (thread)
4197 "Return header of first article in THREAD.
4198 Note that THREAD must never, ever be anything else than a variable -
4199 using some other form will lead to serious barfage."
4200 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4201 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4202 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4205 (defsubst gnus-article-sort-by-number (h1 h2)
4206 "Sort articles by article number."
4207 (< (mail-header-number h1)
4208 (mail-header-number h2)))
4210 (defun gnus-thread-sort-by-number (h1 h2)
4211 "Sort threads by root article number."
4212 (gnus-article-sort-by-number
4213 (gnus-thread-header h1) (gnus-thread-header h2)))
4215 (defsubst gnus-article-sort-by-lines (h1 h2)
4216 "Sort articles by article Lines header."
4217 (< (mail-header-lines h1)
4218 (mail-header-lines h2)))
4220 (defun gnus-thread-sort-by-lines (h1 h2)
4221 "Sort threads by root article Lines header."
4222 (gnus-article-sort-by-lines
4223 (gnus-thread-header h1) (gnus-thread-header h2)))
4225 (defsubst gnus-article-sort-by-chars (h1 h2)
4226 "Sort articles by octet length."
4227 (< (mail-header-chars h1)
4228 (mail-header-chars h2)))
4230 (defun gnus-thread-sort-by-chars (h1 h2)
4231 "Sort threads by root article octet length."
4232 (gnus-article-sort-by-chars
4233 (gnus-thread-header h1) (gnus-thread-header h2)))
4235 (defsubst gnus-article-sort-by-author (h1 h2)
4236 "Sort articles by root author."
4238 (let ((addr (car (mime-entity-read-field h1 'From))))
4239 (or (std11-full-name-string addr)
4240 (std11-address-string addr)
4242 (let ((addr (car (mime-entity-read-field h2 'From))))
4243 (or (std11-full-name-string addr)
4244 (std11-address-string addr)
4248 (defun gnus-thread-sort-by-author (h1 h2)
4249 "Sort threads by root author."
4250 (gnus-article-sort-by-author
4251 (gnus-thread-header h1) (gnus-thread-header h2)))
4253 (defsubst gnus-article-sort-by-subject (h1 h2)
4254 "Sort articles by root subject."
4256 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4257 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4259 (defun gnus-thread-sort-by-subject (h1 h2)
4260 "Sort threads by root subject."
4261 (gnus-article-sort-by-subject
4262 (gnus-thread-header h1) (gnus-thread-header h2)))
4264 (defsubst gnus-article-sort-by-date (h1 h2)
4265 "Sort articles by root article date."
4267 (gnus-date-get-time (mail-header-date h1))
4268 (gnus-date-get-time (mail-header-date h2))))
4270 (defun gnus-thread-sort-by-date (h1 h2)
4271 "Sort threads by root article date."
4272 (gnus-article-sort-by-date
4273 (gnus-thread-header h1) (gnus-thread-header h2)))
4275 (defsubst gnus-article-sort-by-score (h1 h2)
4276 "Sort articles by root article score.
4277 Unscored articles will be counted as having a score of zero."
4278 (> (or (cdr (assq (mail-header-number h1)
4279 gnus-newsgroup-scored))
4280 gnus-summary-default-score 0)
4281 (or (cdr (assq (mail-header-number h2)
4282 gnus-newsgroup-scored))
4283 gnus-summary-default-score 0)))
4285 (defun gnus-thread-sort-by-score (h1 h2)
4286 "Sort threads by root article score."
4287 (gnus-article-sort-by-score
4288 (gnus-thread-header h1) (gnus-thread-header h2)))
4290 (defun gnus-thread-sort-by-total-score (h1 h2)
4291 "Sort threads by the sum of all scores in the thread.
4292 Unscored articles will be counted as having a score of zero."
4293 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4295 (defun gnus-thread-total-score (thread)
4296 ;; This function find the total score of THREAD.
4301 (if (stringp (car thread))
4302 (apply gnus-thread-score-function 0
4303 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4304 (gnus-thread-total-score-1 thread)))
4306 (gnus-thread-total-score-1 (list thread)))))
4308 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4309 "Sort threads such that the thread with the most recently arrived article comes first."
4310 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4312 (defun gnus-thread-highest-number (thread)
4313 "Return the highest article number in THREAD."
4314 (apply 'max (mapcar (lambda (header)
4315 (mail-header-number header))
4316 (message-flatten-list thread))))
4318 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4319 "Sort threads such that the thread with the most recently dated article comes first."
4320 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4322 (defun gnus-thread-latest-date (thread)
4323 "Return the highest article date in THREAD."
4324 (let ((previous-time 0))
4329 (mail-header-parse-date
4331 (mail-header-date header)
4332 (error previous-time))))))
4334 (message-flatten-list thread)
4336 (< (mail-header-number h1)
4337 (mail-header-number h2))))))))
4339 (defun gnus-thread-total-score-1 (root)
4340 ;; This function find the total score of the thread below ROOT.
4341 (setq root (car root))
4342 (apply gnus-thread-score-function
4344 (mapcar 'gnus-thread-total-score
4345 (cdr (gnus-id-to-thread (mail-header-id root))))
4346 (when (> (mail-header-number root) 0)
4347 (list (or (cdr (assq (mail-header-number root)
4348 gnus-newsgroup-scored))
4349 gnus-summary-default-score 0))))
4350 (list gnus-summary-default-score)
4353 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4354 (defvar gnus-tmp-prev-subject nil)
4355 (defvar gnus-tmp-false-parent nil)
4356 (defvar gnus-tmp-root-expunged nil)
4357 (defvar gnus-tmp-dummy-line nil)
4359 (eval-when-compile (defvar gnus-tmp-header))
4360 (defun gnus-extra-header (type &optional header)
4361 "Return the extra header of TYPE."
4362 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4365 (defvar gnus-tmp-thread-tree-header-string "")
4367 (defcustom gnus-sum-thread-tree-root "> "
4368 "With %B spec, used for the root of a thread.
4369 If nil, use subject instead."
4371 :group 'gnus-thread)
4372 (defcustom gnus-sum-thread-tree-single-indent ""
4373 "With %B spec, used for a thread with just one message.
4374 If nil, use subject instead."
4376 :group 'gnus-thread)
4377 (defcustom gnus-sum-thread-tree-vertical "| "
4378 "With %B spec, used for drawing a vertical line."
4380 :group 'gnus-thread)
4381 (defcustom gnus-sum-thread-tree-indent " "
4382 "With %B spec, used for indenting."
4384 :group 'gnus-thread)
4385 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4386 "With %B spec, used for a leaf with brothers."
4388 :group 'gnus-thread)
4389 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4390 "With %B spec, used for a leaf without brothers."
4392 :group 'gnus-thread)
4394 (defun gnus-summary-prepare-threads (threads)
4395 "Prepare summary buffer from THREADS and indentation LEVEL.
4396 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4397 or a straight list of headers."
4398 (gnus-message 7 "Generating summary...")
4400 (setq gnus-newsgroup-threads threads)
4403 (let ((gnus-tmp-level 0)
4404 (default-score (or gnus-summary-default-score 0))
4405 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4406 thread number subject stack state gnus-tmp-gathered beg-match
4407 new-roots gnus-tmp-new-adopts thread-end
4408 gnus-tmp-header gnus-tmp-unread
4409 gnus-tmp-replied gnus-tmp-subject-or-nil
4410 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4411 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4412 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4415 (setq gnus-tmp-prev-subject nil)
4417 (if (vectorp (car threads))
4418 ;; If this is a straight (sic) list of headers, then a
4419 ;; threaded summary display isn't required, so we just create
4420 ;; an unthreaded one.
4421 (gnus-summary-prepare-unthreaded threads)
4423 ;; Do the threaded display.
4425 (while (or threads stack gnus-tmp-new-adopts new-roots)
4427 (if (and (= gnus-tmp-level 0)
4430 (not gnus-tmp-false-parent)
4431 (or gnus-tmp-new-adopts new-roots))
4432 (if gnus-tmp-new-adopts
4433 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4434 thread (list (car gnus-tmp-new-adopts))
4435 gnus-tmp-header (caar thread)
4436 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4438 (setq thread (list (car new-roots))
4439 gnus-tmp-header (caar thread)
4440 new-roots (cdr new-roots))))
4443 ;; If there are some threads, we do them before the
4444 ;; threads on the stack.
4445 (setq thread threads
4446 gnus-tmp-header (caar thread))
4447 ;; There were no current threads, so we pop something off
4449 (setq state (car stack)
4450 gnus-tmp-level (car state)
4451 tree-stack (cadr state)
4452 thread (caddr state)
4454 gnus-tmp-header (caar thread))))
4456 (setq gnus-tmp-false-parent nil)
4457 (setq gnus-tmp-root-expunged nil)
4458 (setq thread-end nil)
4460 (if (stringp gnus-tmp-header)
4461 ;; The header is a dummy root.
4463 ((eq gnus-summary-make-false-root 'adopt)
4464 ;; We let the first article adopt the rest.
4465 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4467 (setq gnus-tmp-gathered
4469 (lambda (h) (mail-header-number (car h)))
4472 (setq thread (cons (list (caar thread)
4475 (setq gnus-tmp-level -1
4476 gnus-tmp-false-parent t))
4477 ((eq gnus-summary-make-false-root 'empty)
4478 ;; We print adopted articles with empty subject fields.
4479 (setq gnus-tmp-gathered
4481 (lambda (h) (mail-header-number (car h)))
4484 (setq gnus-tmp-level -1))
4485 ((eq gnus-summary-make-false-root 'dummy)
4486 ;; We remember that we probably want to output a dummy
4488 (setq gnus-tmp-dummy-line gnus-tmp-header)
4489 (setq gnus-tmp-prev-subject gnus-tmp-header))
4491 ;; We do not make a root for the gathered
4492 ;; sub-threads at all.
4493 (setq gnus-tmp-level -1)))
4495 (setq number (mail-header-number gnus-tmp-header)
4496 subject (mail-header-subject gnus-tmp-header))
4499 ;; If the thread has changed subject, we might want to make
4500 ;; this subthread into a root.
4501 ((and (null gnus-thread-ignore-subject)
4502 (not (zerop gnus-tmp-level))
4503 gnus-tmp-prev-subject
4505 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4506 (setq new-roots (nconc new-roots (list (car thread)))
4508 gnus-tmp-header nil))
4509 ;; If the article lies outside the current limit,
4510 ;; then we do not display it.
4511 ((not (memq number gnus-newsgroup-limit))
4512 (setq gnus-tmp-gathered
4514 (lambda (h) (mail-header-number (car h)))
4517 (setq gnus-tmp-new-adopts (if (cdar thread)
4518 (append gnus-tmp-new-adopts
4520 gnus-tmp-new-adopts)
4522 gnus-tmp-header nil)
4523 (when (zerop gnus-tmp-level)
4524 (setq gnus-tmp-root-expunged t)))
4525 ;; Perhaps this article is to be marked as read?
4526 ((and gnus-summary-mark-below
4527 (< (or (cdr (assq number gnus-newsgroup-scored))
4529 gnus-summary-mark-below)
4530 ;; Don't touch sparse articles.
4531 (not (gnus-summary-article-sparse-p number))
4532 (not (gnus-summary-article-ancient-p number)))
4533 (setq gnus-newsgroup-unreads
4534 (delq number gnus-newsgroup-unreads))
4535 (if gnus-newsgroup-auto-expire
4536 (setq gnus-newsgroup-expirable
4537 (gnus-add-to-sorted-list
4538 gnus-newsgroup-expirable number))
4539 (push (cons number gnus-low-score-mark)
4540 gnus-newsgroup-reads))))
4542 (when gnus-tmp-header
4543 ;; We may have an old dummy line to output before this
4545 (when (and gnus-tmp-dummy-line
4548 (mail-header-subject gnus-tmp-header)))
4549 (gnus-summary-insert-dummy-line
4550 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4551 (setq gnus-tmp-dummy-line nil))
4553 ;; Compute the mark.
4554 (setq gnus-tmp-unread (gnus-article-mark number))
4556 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4557 gnus-tmp-header gnus-tmp-level)
4558 gnus-newsgroup-data)
4560 ;; Actually insert the line.
4562 gnus-tmp-subject-or-nil
4564 ((and gnus-thread-ignore-subject
4565 gnus-tmp-prev-subject
4566 (not (inline (gnus-subject-equal
4567 gnus-tmp-prev-subject subject))))
4569 ((zerop gnus-tmp-level)
4570 (if (and (eq gnus-summary-make-false-root 'empty)
4571 (memq number gnus-tmp-gathered)
4572 gnus-tmp-prev-subject
4573 (inline (gnus-subject-equal
4574 gnus-tmp-prev-subject subject)))
4575 gnus-summary-same-subject
4577 (t gnus-summary-same-subject)))
4578 (if (and (eq gnus-summary-make-false-root 'adopt)
4579 (= gnus-tmp-level 1)
4580 (memq number gnus-tmp-gathered))
4581 (setq gnus-tmp-opening-bracket ?\<
4582 gnus-tmp-closing-bracket ?\>)
4583 (setq gnus-tmp-opening-bracket ?\[
4584 gnus-tmp-closing-bracket ?\]))
4586 gnus-tmp-indentation
4587 (aref gnus-thread-indent-array gnus-tmp-level)
4588 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4589 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4590 gnus-summary-default-score 0)
4592 (if (or (null gnus-summary-default-score)
4593 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4594 gnus-summary-zcore-fuzz))
4596 (if (< gnus-tmp-score gnus-summary-default-score)
4597 gnus-score-below-mark gnus-score-over-mark))
4599 (cond ((memq number gnus-newsgroup-processable)
4601 ((memq number gnus-newsgroup-cached)
4603 ((memq number gnus-newsgroup-replied)
4605 ((memq number gnus-newsgroup-forwarded)
4606 gnus-forwarded-mark)
4607 ((memq number gnus-newsgroup-saved)
4609 ((memq number gnus-newsgroup-recent)
4611 ((memq number gnus-newsgroup-unseen)
4614 gnus-tmp-from (mail-header-from gnus-tmp-header)
4617 ((string-match "<[^>]+> *$" gnus-tmp-from)
4618 (setq beg-match (match-beginning 0))
4619 (or (and (string-match "^\".+\"" gnus-tmp-from)
4620 (substring gnus-tmp-from 1 (1- (match-end 0))))
4621 (substring gnus-tmp-from 0 beg-match)))
4622 ((string-match "(.+)" gnus-tmp-from)
4623 (substring gnus-tmp-from
4624 (1+ (match-beginning 0)) (1- (match-end 0))))
4626 gnus-tmp-thread-tree-header-string
4628 ((not gnus-show-threads) "")
4629 ((zerop gnus-tmp-level)
4631 (or gnus-sum-thread-tree-root subject)
4632 (or gnus-sum-thread-tree-single-indent subject)))
4634 (concat (apply 'concat
4635 (mapcar (lambda (item)
4637 gnus-sum-thread-tree-vertical
4638 gnus-sum-thread-tree-indent))
4639 (cdr (reverse tree-stack))))
4641 gnus-sum-thread-tree-leaf-with-other
4642 gnus-sum-thread-tree-single-leaf)))))
4643 (when (string= gnus-tmp-name "")
4644 (setq gnus-tmp-name gnus-tmp-from))
4645 (unless (numberp gnus-tmp-lines)
4646 (setq gnus-tmp-lines -1))
4647 (if (= gnus-tmp-lines -1)
4648 (setq gnus-tmp-lines "?")
4649 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4650 (gnus-put-text-property
4652 (progn (eval gnus-summary-line-format-spec) (point))
4653 'gnus-number number)
4656 (gnus-run-hooks 'gnus-summary-update-hook)
4659 (setq gnus-tmp-prev-subject subject)))
4661 (when (nth 1 thread)
4662 (push (list (max 0 gnus-tmp-level)
4663 (copy-list tree-stack)
4666 (push (if (nth 1 thread) 1 0) tree-stack)
4667 (incf gnus-tmp-level)
4668 (setq threads (if thread-end nil (cdar thread)))
4670 (setq gnus-tmp-level 0)))))
4671 (gnus-message 7 "Generating summary...done"))
4673 (defun gnus-summary-prepare-unthreaded (headers)
4674 "Generate an unthreaded summary buffer based on HEADERS."
4675 (let (header number mark)
4680 ;; We may have to root out some bad articles...
4681 (when (memq (setq number (mail-header-number
4682 (setq header (pop headers))))
4683 gnus-newsgroup-limit)
4684 ;; Mark article as read when it has a low score.
4685 (when (and gnus-summary-mark-below
4686 (< (or (cdr (assq number gnus-newsgroup-scored))
4687 gnus-summary-default-score 0)
4688 gnus-summary-mark-below)
4689 (not (gnus-summary-article-ancient-p number)))
4690 (setq gnus-newsgroup-unreads
4691 (delq number gnus-newsgroup-unreads))
4692 (if gnus-newsgroup-auto-expire
4693 (push number gnus-newsgroup-expirable)
4694 (push (cons number gnus-low-score-mark)
4695 gnus-newsgroup-reads)))
4697 (setq mark (gnus-article-mark number))
4698 (push (gnus-data-make number mark (1+ (point)) header 0)
4699 gnus-newsgroup-data)
4700 (gnus-summary-insert-line
4702 mark (memq number gnus-newsgroup-replied)
4703 (memq number gnus-newsgroup-expirable)
4704 (mail-header-subject header) nil
4705 (cdr (assq number gnus-newsgroup-scored))
4706 (memq number gnus-newsgroup-processable))))))
4708 (defun gnus-summary-remove-list-identifiers ()
4709 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4710 (let ((regexp (if (consp gnus-list-identifiers)
4711 (mapconcat 'identity gnus-list-identifiers " *\\|")
4712 gnus-list-identifiers))
4715 (dolist (header gnus-newsgroup-headers)
4716 (setq subject (mail-header-subject header)
4718 (while (string-match
4719 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4722 (concat (substring subject 0 (match-beginning 2))
4723 (substring subject (match-end 0)))
4727 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4729 (concat (substring subject 0 (match-beginning 1))
4730 (substring subject (match-end 1)))))
4732 (mail-header-set-subject header subject))))))
4734 (defun gnus-fetch-headers (articles)
4735 "Fetch headers of ARTICLES."
4736 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4737 (gnus-message 5 "Fetching headers for %s..." name)
4740 (setq gnus-headers-retrieved-by
4741 (gnus-retrieve-headers
4742 articles gnus-newsgroup-name
4743 ;; We might want to fetch old headers, but
4744 ;; not if there is only 1 article.
4746 (not (eq gnus-fetch-old-headers 'some))
4747 (not (numberp gnus-fetch-old-headers)))
4748 (> (length articles) 1))
4749 gnus-fetch-old-headers))))
4750 (gnus-get-newsgroup-headers-xover
4751 articles nil nil gnus-newsgroup-name t)
4752 (gnus-get-newsgroup-headers))
4753 (gnus-message 5 "Fetching headers for %s...done" name))))
4755 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4756 "Select newsgroup GROUP.
4757 If READ-ALL is non-nil, all articles in the group are selected.
4758 If SELECT-ARTICLES, only select those articles from GROUP."
4759 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4760 ;;!!! Dirty hack; should be removed.
4761 (gnus-summary-ignore-duplicates
4762 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4764 gnus-summary-ignore-duplicates))
4765 (info (nth 2 entry))
4766 articles fetched-articles cached)
4768 (unless (gnus-check-server
4769 (set (make-local-variable 'gnus-current-select-method)
4770 (gnus-find-method-for-group group)))
4771 (error "Couldn't open server"))
4773 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4774 (gnus-activate-group group) ; Or we can activate it...
4775 (progn ; Or we bug out.
4776 (when (equal major-mode 'gnus-summary-mode)
4777 (kill-buffer (current-buffer)))
4778 (error "Couldn't activate group %s: %s"
4779 group (gnus-status-message group))))
4781 (unless (gnus-request-group group t)
4782 (when (equal major-mode 'gnus-summary-mode)
4783 (kill-buffer (current-buffer)))
4784 (error "Couldn't request group %s: %s"
4785 group (gnus-status-message group)))
4787 (setq gnus-newsgroup-name group
4788 gnus-newsgroup-unselected nil
4789 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4791 (let ((display (gnus-group-find-parameter group 'display)))
4792 (setq gnus-newsgroup-display
4794 ((not (zerop (or (car-safe read-all) 0)))
4795 ;; The user entered the group with C-u SPC/RET, let's show
4801 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4803 ;; The following is probably the "correct" solution, but
4804 ;; it makes Gnus fetch all headers and then limit the
4805 ;; articles (which is slow), so instead we hack the
4806 ;; select-articles parameter instead. -- Simon Josefsson
4809 ;; (gnus-byte-compile
4810 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4812 (setq select-articles
4813 (gnus-uncompress-range
4814 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4818 (cdr (gnus-active group)))))
4823 (gnus-summary-setup-default-charset)
4825 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4826 (when (gnus-virtual-group-p group)
4827 (setq cached gnus-newsgroup-cached))
4829 (setq gnus-newsgroup-unreads
4830 (gnus-sorted-ndifference
4831 (gnus-sorted-ndifference gnus-newsgroup-unreads
4832 gnus-newsgroup-marked)
4833 gnus-newsgroup-dormant))
4835 (setq gnus-newsgroup-processable nil)
4837 (gnus-update-read-articles group gnus-newsgroup-unreads)
4839 ;; Adjust and set lists of article marks.
4841 (gnus-adjust-marked-articles info))
4843 (if (setq articles select-articles)
4844 (setq gnus-newsgroup-unselected
4845 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4846 (setq articles (gnus-articles-to-read group read-all)))
4850 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4852 ((eq articles 0) nil)
4854 ;; Init the dependencies hash table.
4855 (setq gnus-newsgroup-dependencies
4856 (gnus-make-hashtable (length articles)))
4857 (gnus-set-global-variables)
4858 ;; Retrieve the headers and read them in.
4859 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4861 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4863 (setq gnus-newsgroup-cached cached))
4865 ;; Suppress duplicates?
4866 (when gnus-suppress-duplicates
4867 (gnus-dup-suppress-articles))
4869 ;; Set the initial limit.
4870 (setq gnus-newsgroup-limit (copy-sequence articles))
4871 ;; Remove canceled articles from the list of unread articles.
4872 (setq fetched-articles
4873 (mapcar (lambda (headers) (mail-header-number headers))
4874 gnus-newsgroup-headers))
4875 (setq gnus-newsgroup-articles fetched-articles)
4876 (setq gnus-newsgroup-unreads
4877 (gnus-sorted-nintersection
4878 gnus-newsgroup-unreads fetched-articles))
4879 (gnus-compute-unseen-list)
4881 ;; Removed marked articles that do not exist.
4882 (gnus-update-missing-marks
4883 (gnus-sorted-difference articles fetched-articles))
4884 ;; We might want to build some more threads first.
4885 (when (and gnus-fetch-old-headers
4886 (eq gnus-headers-retrieved-by 'nov))
4887 (if (eq gnus-fetch-old-headers 'invisible)
4888 (gnus-build-all-threads)
4889 (gnus-build-old-threads)))
4890 ;; Let the Gnus agent mark articles as read.
4892 (gnus-agent-get-undownloaded-list))
4893 ;; Remove list identifiers from subject
4894 (when gnus-list-identifiers
4895 (gnus-summary-remove-list-identifiers))
4896 ;; Check whether auto-expire is to be done in this group.
4897 (setq gnus-newsgroup-auto-expire
4898 (gnus-group-auto-expirable-p group))
4899 ;; Set up the article buffer now, if necessary.
4900 (unless gnus-single-article-buffer
4901 (gnus-article-setup-buffer))
4902 ;; First and last article in this newsgroup.
4903 (when gnus-newsgroup-headers
4904 (setq gnus-newsgroup-begin
4905 (mail-header-number (car gnus-newsgroup-headers))
4908 (gnus-last-element gnus-newsgroup-headers))))
4909 ;; GROUP is successfully selected.
4910 (or gnus-newsgroup-headers t)))))
4912 (defun gnus-compute-unseen-list ()
4913 ;; The `seen' marks are treated specially.
4914 (if (not gnus-newsgroup-seen)
4915 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4916 (setq gnus-newsgroup-unseen
4917 (gnus-inverse-list-range-intersection
4918 gnus-newsgroup-articles gnus-newsgroup-seen))))
4920 (defun gnus-summary-display-make-predicate (display)
4921 (require 'gnus-agent)
4922 (when (= (length display) 1)
4923 (setq display (car display)))
4924 (unless gnus-summary-display-cache
4925 (dolist (elem (append '((unread . unread)
4928 gnus-article-mark-lists))
4929 (push (cons (cdr elem)
4931 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4932 gnus-summary-display-cache)))
4933 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
4934 (gnus-category-predicate-cache gnus-summary-display-cache))
4935 (gnus-get-predicate display)))
4937 ;; Uses the dynamically bound `number' variable.
4939 (defun gnus-article-marked-p (type &optional article)
4940 (let ((article (or article number)))
4943 (memq article gnus-newsgroup-marked))
4945 (memq article gnus-newsgroup-unsendable))
4946 ((eq type 'undownload)
4947 (memq article gnus-newsgroup-undownloaded))
4948 ((eq type 'download)
4949 (memq article gnus-newsgroup-downloadable))
4951 (memq article gnus-newsgroup-unreads))
4953 (memq article gnus-newsgroup-reads))
4955 (memq article gnus-newsgroup-dormant) )
4957 (memq article gnus-newsgroup-expirable))
4959 (memq article gnus-newsgroup-replied))
4961 (memq article gnus-newsgroup-killed))
4962 ((eq type 'bookmark)
4963 (assq article gnus-newsgroup-bookmarks))
4965 (assq article gnus-newsgroup-scored))
4967 (memq article gnus-newsgroup-saved))
4969 (memq article gnus-newsgroup-cached))
4971 (memq article gnus-newsgroup-forwarded))
4973 (not (memq article gnus-newsgroup-unseen)))
4975 (memq article gnus-newsgroup-recent))
4978 (defun gnus-articles-to-read (group &optional read-all)
4979 "Find out what articles the user wants to read."
4981 ;; Select all articles if `read-all' is non-nil, or if there
4982 ;; are no unread articles.
4984 (and (zerop (length gnus-newsgroup-marked))
4985 (zerop (length gnus-newsgroup-unreads)))
4986 ;; Fetch all if the predicate is non-nil.
4987 gnus-newsgroup-display)
4988 ;; We want to select the headers for all the articles in
4989 ;; the group, so we select either all the active
4990 ;; articles in the group, or (if that's nil), the
4991 ;; articles in the cache.
4993 (gnus-uncompress-range (gnus-active group))
4994 (gnus-cache-articles-in-group group))
4995 ;; Select only the "normal" subset of articles.
4997 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
4998 gnus-newsgroup-unreads)))
4999 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5000 (scored (length scored-list))
5001 (number (length articles))
5002 (marked (+ (length gnus-newsgroup-marked)
5003 (length gnus-newsgroup-dormant)))
5008 ((numberp gnus-newsgroup-display)
5009 gnus-newsgroup-display)
5013 ((and (or (<= scored marked) (= scored number))
5014 (numberp gnus-large-newsgroup)
5015 (> number gnus-large-newsgroup))
5016 (let* ((cursor-in-echo-area nil)
5017 (initial (gnus-parameter-large-newsgroup-initial
5018 gnus-newsgroup-name))
5022 "How many articles from %s (%s %d): "
5024 (gnus-group-decoded-name gnus-newsgroup-name)
5026 (if initial "max" "default")
5029 (cons (number-to-string initial)
5031 (if (string-match "^[ \t]*$" input) number input)))
5032 ((and (> scored marked) (< scored number)
5033 (> (- scored number) 20))
5036 (format "%s %s (%d scored, %d total): "
5037 "How many articles from"
5038 (gnus-group-decoded-name group)
5040 (if (string-match "^[ \t]*$" input)
5044 (message "Quit getting the articles to read")
5046 (setq select (if (stringp select) (string-to-number select) select))
5047 (if (or (null select) (zerop select))
5049 (if (and (not (zerop scored)) (<= (abs select) scored))
5051 (setq articles (sort scored-list '<))
5052 (setq number (length articles)))
5053 (setq articles (copy-sequence articles)))
5055 (when (< (abs select) number)
5057 ;; Select the N oldest articles.
5058 (setcdr (nthcdr (1- (abs select)) articles) nil)
5059 ;; Select the N most recent articles.
5060 (setq articles (nthcdr (- number select) articles))))
5061 (setq gnus-newsgroup-unselected
5062 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5063 (when gnus-alter-articles-to-read-function
5064 (setq gnus-newsgroup-unreads
5066 (funcall gnus-alter-articles-to-read-function
5067 gnus-newsgroup-name gnus-newsgroup-unreads)
5071 (defun gnus-killed-articles (killed articles)
5074 (when (inline (gnus-member-of-range (car articles) killed))
5075 (push (car articles) out))
5076 (setq articles (cdr articles)))
5079 (defun gnus-uncompress-marks (marks)
5080 "Uncompress the mark ranges in MARKS."
5081 (let ((uncompressed '(score bookmark))
5084 (if (memq (caar marks) uncompressed)
5085 (push (car marks) out)
5086 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5087 (setq marks (cdr marks)))
5090 (defun gnus-article-mark-to-type (mark)
5091 "Return the type of MARK."
5092 (or (cadr (assq mark gnus-article-special-mark-lists))
5095 (defun gnus-article-unpropagatable-p (mark)
5096 "Return whether MARK should be propagated to backend."
5097 (memq mark gnus-article-unpropagated-mark-lists))
5099 (defun gnus-adjust-marked-articles (info)
5100 "Set all article lists and remove all marks that are no longer valid."
5101 (let* ((marked-lists (gnus-info-marks info))
5102 (active (gnus-active (gnus-info-group info)))
5105 (types gnus-article-mark-lists)
5106 marks var articles article mark mark-type)
5108 (dolist (marks marked-lists)
5109 (setq mark (car marks)
5110 mark-type (gnus-article-mark-to-type mark)
5111 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5113 ;; We set the variable according to the type of the marks list,
5114 ;; and then adjust the marks to a subset of the active articles.
5116 ;; Adjust "simple" lists.
5117 ((eq mark-type 'list)
5118 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5119 (when (memq mark '(tick dormant expire reply save))
5121 (when (or (< (setq article (pop articles)) min) (> article max))
5122 (set var (delq article (symbol-value var)))))))
5124 ((eq mark-type 'tuple)
5125 (set var (setq articles (cdr marks)))
5126 (when (not (listp (cdr (symbol-value var))))
5127 (set var (list (symbol-value var))))
5128 (when (not (listp (cdr articles)))
5129 (setq articles (list articles)))
5131 (when (or (not (consp (setq article (pop articles))))
5132 (< (car article) min)
5133 (> (car article) max))
5134 (set var (delq article (symbol-value var))))))
5135 ;; Adjust ranges (sloppily).
5136 ((eq mark-type 'range)
5139 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5140 ;; It should be (seen (NUM1 . NUM2)).
5141 (when (numberp (cddr marks))
5142 (setcdr marks (list (cdr marks))))
5143 (setq articles (cdr marks))
5144 (while (and articles
5145 (or (and (consp (car articles))
5146 (> min (cdar articles)))
5147 (and (numberp (car articles))
5148 (> min (car articles)))))
5150 (set var articles))))))))
5152 (defun gnus-update-missing-marks (missing)
5153 "Go through the list of MISSING articles and remove them from the mark lists."
5156 ;; Go through all types.
5157 (dolist (elem gnus-article-mark-lists)
5158 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5159 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5160 (when (symbol-value var)
5161 ;; This list has articles. So we delete all missing
5162 ;; articles from it.
5165 (set var (delq (pop m) (symbol-value var))))))))))
5167 (defun gnus-update-marks ()
5168 "Enter the various lists of marked articles into the newsgroup info list."
5169 (let ((types gnus-article-mark-lists)
5170 (info (gnus-get-info gnus-newsgroup-name))
5171 type list newmarked symbol delta-marks)
5173 ;; Add all marks lists to the list of marks lists.
5174 (while (setq type (pop types))
5175 (setq list (symbol-value
5177 (intern (format "gnus-newsgroup-%s" (car type))))))
5180 ;; Get rid of the entries of the articles that have the
5182 (when (and (eq (cdr type) 'score)
5186 (prev (cons nil list))
5189 (if (or (not (consp (car arts)))
5190 (= (cdar arts) gnus-summary-default-score))
5191 (setcdr prev (cdr arts))
5193 (setq arts (cdr arts)))
5194 (setq list (cdr all)))))
5196 (when (eq (cdr type) 'seen)
5197 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5199 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5200 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5202 (when (and (gnus-check-backend-function
5203 'request-set-mark gnus-newsgroup-name)
5204 (not (gnus-article-unpropagatable-p (cdr type))))
5205 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5206 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5207 (add (gnus-remove-from-range
5208 (gnus-copy-sequence list) old)))
5210 (push (list add 'add (list (cdr type))) delta-marks))
5212 (push (list del 'del (list (cdr type))) delta-marks))))
5215 (push (cons (cdr type) list) newmarked)))
5218 (unless (gnus-check-group gnus-newsgroup-name)
5219 (error "Can't open server for %s" gnus-newsgroup-name))
5220 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5222 ;; Enter these new marks into the info of the group.
5224 (setcar (nthcdr 3 info) newmarked)
5225 ;; Add the marks lists to the end of the info.
5227 (setcdr (nthcdr 2 info) (list newmarked))))
5229 ;; Cut off the end of the info if there's nothing else there.
5233 (when (nthcdr (decf i) info)
5234 (setcdr (nthcdr i info) nil)))))))
5236 (defun gnus-set-mode-line (where)
5237 "Set the mode line of the article or summary buffers.
5238 If WHERE is `summary', the summary mode line format will be used."
5239 ;; Is this mode line one we keep updated?
5240 (when (and (memq where gnus-updated-mode-lines)
5242 (intern (format "gnus-%s-mode-line-format-spec" where))))
5245 ;; We evaluate this in the summary buffer since these
5246 ;; variables are buffer-local to that buffer.
5247 (set-buffer gnus-summary-buffer)
5248 ;; We bind all these variables that are used in the `eval' form
5250 (let* ((mformat (symbol-value
5252 (format "gnus-%s-mode-line-format-spec" where))))
5253 (gnus-tmp-group-name (gnus-group-decoded-name
5254 gnus-newsgroup-name))
5255 (gnus-tmp-article-number (or gnus-current-article 0))
5256 (gnus-tmp-unread gnus-newsgroup-unreads)
5257 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5258 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5259 (gnus-tmp-unread-and-unselected
5260 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5261 (zerop gnus-tmp-unselected))
5263 ((zerop gnus-tmp-unselected)
5264 (format "{%d more}" gnus-tmp-unread-and-unticked))
5265 (t (format "{%d(+%d) more}"
5266 gnus-tmp-unread-and-unticked
5267 gnus-tmp-unselected))))
5269 (if (and gnus-current-headers
5270 (vectorp gnus-current-headers))
5271 (gnus-mode-string-quote
5272 (mail-header-subject gnus-current-headers))
5274 bufname-length max-len
5275 gnus-tmp-header);; passed as argument to any user-format-funcs
5276 (setq mode-string (eval mformat))
5277 (setq bufname-length (if (string-match "%b" mode-string)
5280 (if (eq where 'summary)
5282 (get-buffer gnus-article-buffer))))
5285 (setq max-len (max 4 (if gnus-mode-non-string-length
5287 gnus-mode-non-string-length
5289 (length mode-string))))
5290 ;; We might have to chop a bit of the string off...
5291 (when (> (length mode-string) max-len)
5293 (concat (gnus-truncate-string mode-string (- max-len 3))
5295 ;; Pad the mode string a bit.
5296 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5297 ;; Update the mode line.
5298 (setq mode-line-buffer-identification
5299 (gnus-mode-line-buffer-identification (list mode-string)))
5300 (set-buffer-modified-p t))))
5302 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5303 "Go through the HEADERS list and add all Xrefs to a hash table.
5304 The resulting hash table is returned, or nil if no Xrefs were found."
5305 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5306 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5307 (xref-hashtb (gnus-make-hashtable))
5308 start group entry number xrefs header)
5310 (setq header (pop headers))
5311 (when (and (setq xrefs (mail-header-xref header))
5312 (not (memq (setq number (mail-header-number header))
5315 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5316 (setq start (match-end 0))
5317 (setq group (if prefix
5318 (concat prefix (substring xrefs (match-beginning 1)
5320 (substring xrefs (match-beginning 1) (match-end 1))))
5322 (string-to-int (substring xrefs (match-beginning 2)
5324 (if (setq entry (gnus-gethash group xref-hashtb))
5325 (setcdr entry (cons number (cdr entry)))
5326 (gnus-sethash group (cons number nil) xref-hashtb)))))
5327 (and start xref-hashtb)))
5329 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5330 "Look through all the headers and mark the Xrefs as read."
5331 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5332 name entry info xref-hashtb idlist method nth4)
5334 (set-buffer gnus-group-buffer)
5335 (when (setq xref-hashtb
5336 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5339 (unless (string= from-newsgroup (setq name (symbol-name group)))
5340 (setq idlist (symbol-value group))
5341 ;; Dead groups are not updated.
5343 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5345 (when (stringp (setq nth4 (gnus-info-method info)))
5346 (setq nth4 (gnus-server-to-method nth4))))
5347 ;; Only do the xrefs if the group has the same
5348 ;; select method as the group we have just read.
5349 (or (gnus-methods-equal-p
5350 nth4 (gnus-find-method-for-group from-newsgroup))
5352 (equal nth4 (setq method (gnus-find-method-for-group
5354 (and (equal (car nth4) (car method))
5355 (equal (nth 1 nth4) (nth 1 method))))
5356 gnus-use-cross-reference
5357 (or (not (eq gnus-use-cross-reference t))
5359 ;; Only do cross-references on subscribed
5360 ;; groups, if that is what is wanted.
5361 (<= (gnus-info-level info) gnus-level-subscribed))
5362 (gnus-group-make-articles-read name idlist))))
5365 (defun gnus-compute-read-articles (group articles)
5366 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5367 (info (nth 2 entry))
5368 (active (gnus-active group))
5371 ;; First peel off all invalid article numbers.
5373 (let ((ids articles)
5375 (while (setq id (pop ids))
5376 (when (and first (> id (cdr active)))
5377 ;; We'll end up in this situation in one particular
5378 ;; obscure situation. If you re-scan a group and get
5379 ;; a new article that is cross-posted to a different
5380 ;; group that has not been re-scanned, you might get
5381 ;; crossposted article that has a higher number than
5382 ;; Gnus believes possible. So we re-activate this
5383 ;; group as well. This might mean doing the
5384 ;; crossposting thingy will *increase* the number
5385 ;; of articles in some groups. Tsk, tsk.
5386 (setq active (or (gnus-activate-group group) active)))
5387 (when (or (> id (cdr active))
5388 (< id (car active)))
5389 (setq articles (delq id articles))))))
5390 ;; If the read list is nil, we init it.
5392 (null (gnus-info-read info))
5394 (setq ninfo (cons 1 (1- (car active))))
5395 (setq ninfo (gnus-info-read info)))
5396 ;; Then we add the read articles to the range.
5398 ninfo (setq articles (sort articles '<))))))
5400 (defun gnus-group-make-articles-read (group articles)
5401 "Update the info of GROUP to say that ARTICLES are read."
5403 (entry (gnus-gethash group gnus-newsrc-hashtb))
5404 (info (nth 2 entry))
5405 (active (gnus-active group))
5408 (setq range (gnus-compute-read-articles group articles))
5410 (set-buffer gnus-group-buffer)
5413 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5414 (gnus-info-set-read ',info ',(gnus-info-read info))
5415 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5416 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5417 (gnus-group-update-group ,group t))))
5418 ;; Add the read articles to the range.
5419 (gnus-info-set-read info range)
5420 (gnus-request-set-mark group (list (list range 'add '(read))))
5421 ;; Then we have to re-compute how many unread
5422 ;; articles there are in this group.
5426 (setq num (- (1+ (cdr active)) (car active))))
5427 ((not (listp (cdr range)))
5428 (setq num (- (cdr active) (- (1+ (cdr range))
5432 (if (numberp (car range))
5434 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5435 (setq range (cdr range)))
5436 (setq num (- (cdr active) num))))
5437 ;; Update the number of unread articles.
5439 ;; Update the group buffer.
5440 (gnus-group-update-group group t)))))
5442 (defvar gnus-newsgroup-none-id 0)
5444 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5445 (let ((cur nntp-server-buffer)
5448 (save-excursion (set-buffer gnus-summary-buffer)
5449 gnus-newsgroup-dependencies)))
5451 (mail-parse-charset gnus-newsgroup-charset)
5452 (mail-parse-ignored-charsets
5453 (save-excursion (condition-case nil
5454 (set-buffer gnus-summary-buffer)
5456 gnus-newsgroup-ignored-charsets)))
5458 (set-buffer nntp-server-buffer)
5459 ;; Translate all TAB characters into SPACE characters.
5460 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5461 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5462 (gnus-run-hooks 'gnus-parse-headers-hook)
5463 (let ((case-fold-search t)
5464 in-reply-to header p lines chars ctype)
5465 (goto-char (point-min))
5466 ;; Search to the beginning of the next header. Error messages
5467 ;; do not begin with 2 or 3.
5468 (while (re-search-forward "^[23][0-9]+ " nil t)
5471 ;; This implementation of this function, with nine
5472 ;; search-forwards instead of the one re-search-forward and
5473 ;; a case (which basically was the old function) is actually
5474 ;; about twice as fast, even though it looks messier. You
5475 ;; can't have everything, I guess. Speed and elegance
5476 ;; doesn't always go hand in hand.
5479 (make-full-mail-header
5485 (narrow-to-region (point)
5486 (or (and (search-forward "\n.\n" nil t)
5492 (if (search-forward "\nsubject:" nil t)
5493 (nnheader-header-value)
5498 (if (search-forward "\nfrom:" nil t)
5499 (nnheader-header-value)
5504 (if (search-forward "\ndate:" nil t)
5505 (nnheader-header-value) ""))
5509 (setq id (if (re-search-forward
5510 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5511 ;; We do it this way to make sure the Message-ID
5512 ;; is (somewhat) syntactically valid.
5513 (buffer-substring (match-beginning 1)
5515 ;; If there was no message-id, we just fake one
5516 ;; to make subsequent routines simpler.
5517 (nnheader-generate-fake-message-id))))
5521 (if (search-forward "\nreferences:" nil t)
5525 (nnheader-header-value)
5530 (search-backward ">" end t)
5533 (search-backward "<" end t)
5535 ;; Get the references from the in-reply-to header if there
5536 ;; were no references and the in-reply-to header looks
5538 (if (and (search-forward "\nin-reply-to:" nil t)
5539 (setq in-reply-to (nnheader-header-value))
5540 (string-match "<[^>]+>" in-reply-to))
5542 (setq ref (substring in-reply-to (match-beginning 0)
5544 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5545 (setq ref2 (substring in-reply-to (match-beginning 0)
5547 (when (> (length ref2) (length ref))
5554 (if (search-forward "\nchars: " nil t)
5555 (if (numberp (setq chars (ignore-errors (read cur))))
5561 (if (search-forward "\nlines: " nil t)
5562 (if (numberp (setq lines (ignore-errors (read cur))))
5568 (and (search-forward "\nxref:" nil t)
5569 (nnheader-header-value)))
5571 (when gnus-extra-headers
5572 (let ((extra gnus-extra-headers)
5576 (when (search-forward
5577 (concat "\n" (symbol-name (car extra)) ":") nil t)
5578 (push (cons (car extra) (nnheader-header-value)) out))
5582 (if (and (search-forward "\ncontent-type: " nil t)
5583 (setq ctype (nnheader-header-value)))
5584 (mime-entity-set-content-type-internal
5585 header (mime-parse-Content-Type ctype)))
5586 (when (equal id ref)
5589 (when gnus-alter-header-function
5590 (funcall gnus-alter-header-function header)
5591 (setq id (mail-header-id header)
5592 ref (gnus-parent-id (mail-header-references header))))
5595 (gnus-dependencies-add-header
5596 header dependencies force-new))
5597 (push header headers))
5598 (goto-char (point-max))
5600 (nreverse headers)))))
5602 ;; Goes through the xover lines and returns a list of vectors
5603 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5604 force-new dependencies
5605 group also-fetch-heads)
5606 "Parse the news overview data in the server buffer.
5607 Return a list of headers that match SEQUENCE (see
5608 `nntp-retrieve-headers')."
5609 ;; Get the Xref when the users reads the articles since most/some
5610 ;; NNTP servers do not include Xrefs when using XOVER.
5611 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5612 (let ((mail-parse-charset gnus-newsgroup-charset)
5613 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5614 (cur nntp-server-buffer)
5615 (dependencies (or dependencies gnus-newsgroup-dependencies))
5617 ((eq gnus-read-all-available-headers t)
5619 ((stringp gnus-read-all-available-headers)
5620 (string-match gnus-read-all-available-headers group))
5623 number headers header)
5625 (set-buffer nntp-server-buffer)
5626 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5627 ;; Allow the user to mangle the headers before parsing them.
5628 (gnus-run-hooks 'gnus-parse-headers-hook)
5629 (goto-char (point-min))
5630 (gnus-parse-without-error
5631 (while (and (or sequence allp)
5633 (setq number (read cur))
5635 (while (and sequence
5636 (< (car sequence) number))
5637 (setq sequence (cdr sequence))))
5640 (eq number (car sequence))))
5642 (setq sequence (cdr sequence))
5643 (setq header (inline
5644 (gnus-nov-parse-line
5645 number dependencies force-new)))))
5646 (push header headers))
5648 ;; A common bug in inn is that if you have posted an article and
5649 ;; then retrieves the active file, it will answer correctly --
5650 ;; the new article is included. However, a NOV entry for the
5651 ;; article may not have been generated yet, so this may fail.
5652 ;; We work around this problem by retrieving the last few
5653 ;; headers using HEAD.
5654 (if (or (not also-fetch-heads)
5656 ;; We (probably) got all the headers.
5658 (let ((gnus-nov-is-evil t))
5661 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5662 (gnus-get-newsgroup-headers))))))))
5664 (defun gnus-article-get-xrefs ()
5665 "Fill in the Xref value in `gnus-current-headers', if necessary.
5666 This is meant to be called in `gnus-article-internal-prepare-hook'."
5667 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5668 gnus-current-headers)))
5669 (or (not gnus-use-cross-reference)
5671 (and (mail-header-xref headers)
5672 (not (string= (mail-header-xref headers) "")))
5673 (let ((case-fold-search t)
5676 (nnheader-narrow-to-headers)
5677 (goto-char (point-min))
5678 (when (or (and (not (eobp))
5679 (eq (downcase (char-after)) ?x)
5680 (looking-at "Xref:"))
5681 (search-forward "\nXref:" nil t))
5682 (goto-char (1+ (match-end 0)))
5683 (setq xref (buffer-substring (point)
5684 (progn (end-of-line) (point))))
5685 (mail-header-set-xref headers xref)))))))
5687 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5688 "Find article ID and insert the summary line for that article.
5689 OLD-HEADER can either be a header or a line number to insert
5690 the subject line on."
5691 (let* ((line (and (numberp old-header) old-header))
5692 (old-header (and (vectorp old-header) old-header))
5693 (header (cond ((and old-header use-old-header)
5696 (gnus-number-to-header id))
5697 (gnus-number-to-header id))
5699 (gnus-read-header id))))
5700 (number (and (numberp id) id))
5703 ;; Rebuild the thread that this article is part of and go to the
5704 ;; article we have fetched.
5705 (when (and (not gnus-show-threads)
5708 (setq d (gnus-data-find (mail-header-number old-header))))
5709 (goto-char (gnus-data-pos d))
5712 (- (gnus-point-at-bol)
5714 (1+ (gnus-point-at-eol))
5715 (gnus-delete-line))))))
5717 (mail-header-set-number header (mail-header-number old-header)))
5718 (setq gnus-newsgroup-sparse
5719 (delq (setq number (mail-header-number header))
5720 gnus-newsgroup-sparse))
5721 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5722 (push number gnus-newsgroup-limit)
5723 (gnus-rebuild-thread (mail-header-id header) line)
5724 (gnus-summary-goto-subject number nil t))
5725 (when (and (numberp number)
5727 ;; We have to update the boundaries even if we can't fetch the
5728 ;; article if ID is a number -- so that the next `P' or `N'
5729 ;; command will fetch the previous (or next) article even
5730 ;; if the one we tried to fetch this time has been canceled.
5731 (when (> number gnus-newsgroup-end)
5732 (setq gnus-newsgroup-end number))
5733 (when (< number gnus-newsgroup-begin)
5734 (setq gnus-newsgroup-begin number))
5735 (setq gnus-newsgroup-unselected
5736 (delq number gnus-newsgroup-unselected)))
5737 ;; Report back a success?
5738 (and header (mail-header-number header))))
5740 ;;; Process/prefix in the summary buffer
5742 (defun gnus-summary-work-articles (n)
5743 "Return a list of articles to be worked upon.
5744 The prefix argument, the list of process marked articles, and the
5745 current article will be taken into consideration."
5747 (set-buffer gnus-summary-buffer)
5750 ;; A numerical prefix has been given.
5751 (setq n (prefix-numeric-value n))
5752 (let ((backward (< n 0))
5753 (n (abs (prefix-numeric-value n)))
5758 (push (setq article (gnus-summary-article-number))
5761 (gnus-summary-find-prev nil article)
5762 (gnus-summary-find-next nil article)))
5764 (nreverse articles)))
5765 ((and (gnus-region-active-p) (mark))
5766 (message "region active")
5767 ;; Work on the region between point and mark.
5768 (let ((max (max (point) (mark)))
5771 (goto-char (min (point) (mark)))
5774 (push (setq article (gnus-summary-article-number)) articles)
5775 (gnus-summary-find-next nil article)
5777 (nreverse articles))))
5778 (gnus-newsgroup-processable
5779 ;; There are process-marked articles present.
5780 ;; Save current state.
5781 (gnus-summary-save-process-mark)
5783 (reverse gnus-newsgroup-processable))
5785 ;; Just return the current article.
5786 (list (gnus-summary-article-number))))))
5788 (defmacro gnus-summary-iterate (arg &rest forms)
5789 "Iterate over the process/prefixed articles and do FORMS.
5790 ARG is the interactive prefix given to the command. FORMS will be
5791 executed with point over the summary line of the articles."
5792 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5793 `(let ((,articles (gnus-summary-work-articles ,arg)))
5795 (gnus-summary-goto-subject (car ,articles))
5799 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5800 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5802 (defun gnus-summary-save-process-mark ()
5803 "Push the current set of process marked articles on the stack."
5805 (push (copy-sequence gnus-newsgroup-processable)
5806 gnus-newsgroup-process-stack))
5808 (defun gnus-summary-kill-process-mark ()
5809 "Push the current set of process marked articles on the stack and unmark."
5811 (gnus-summary-save-process-mark)
5812 (gnus-summary-unmark-all-processable))
5814 (defun gnus-summary-yank-process-mark ()
5815 "Pop the last process mark state off the stack and restore it."
5817 (unless gnus-newsgroup-process-stack
5818 (error "Empty mark stack"))
5819 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5821 (defun gnus-summary-process-mark-set (set)
5822 "Make SET into the current process marked articles."
5823 (gnus-summary-unmark-all-processable)
5825 (gnus-summary-set-process-mark (pop set))))
5827 ;;; Searching and stuff
5829 (defun gnus-summary-search-group (&optional backward use-level)
5830 "Search for next unread newsgroup.
5831 If optional argument BACKWARD is non-nil, search backward instead."
5833 (set-buffer gnus-group-buffer)
5834 (when (gnus-group-search-forward
5835 backward nil (if use-level (gnus-group-group-level) nil))
5836 (gnus-group-group-name))))
5838 (defun gnus-summary-best-group (&optional exclude-group)
5839 "Find the name of the best unread group.
5840 If EXCLUDE-GROUP, do not go to this group."
5842 (set-buffer gnus-group-buffer)
5844 (gnus-group-best-unread-group exclude-group))))
5846 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5847 (if backward (gnus-summary-find-prev)
5848 (let* ((dummy (gnus-summary-article-intangible-p))
5849 (article (or article (gnus-summary-article-number)))
5850 (arts (gnus-data-find-list article))
5852 (when (and (not dummy)
5853 (or (not gnus-summary-check-current)
5855 (not (gnus-data-unread-p (car arts)))))
5856 (setq arts (cdr arts)))
5861 (when (or (and undownloaded
5862 (eq gnus-undownloaded-mark
5863 (gnus-data-mark (car arts))))
5864 (gnus-data-unread-p (car arts)))
5865 (setq result (car arts)
5867 (setq arts (cdr arts)))
5870 (goto-char (gnus-data-pos result))
5871 (gnus-data-number result)))))
5873 (defun gnus-summary-find-prev (&optional unread article)
5874 (let* ((eobp (eobp))
5875 (article (or article (gnus-summary-article-number)))
5876 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5878 (when (and (not eobp)
5879 (or (not gnus-summary-check-current)
5881 (not (gnus-data-unread-p (car arts)))))
5882 (setq arts (cdr arts)))
5887 (when (gnus-data-unread-p (car arts))
5888 (setq result (car arts)
5890 (setq arts (cdr arts)))
5893 (goto-char (gnus-data-pos result))
5894 (gnus-data-number result))))
5896 (defun gnus-summary-find-subject (subject &optional unread backward article)
5897 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5898 (article (or article (gnus-summary-article-number)))
5899 (articles (gnus-data-list backward))
5900 (arts (gnus-data-find-list article articles))
5902 (when (or (not gnus-summary-check-current)
5904 (not (gnus-data-unread-p (car arts))))
5905 (setq arts (cdr arts)))
5907 (and (or (not unread)
5908 (gnus-data-unread-p (car arts)))
5909 (vectorp (gnus-data-header (car arts)))
5911 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5912 (setq result (car arts)
5914 (setq arts (cdr arts)))
5916 (goto-char (gnus-data-pos result))
5917 (gnus-data-number result))))
5919 (defun gnus-summary-search-forward (&optional unread subject backward)
5920 "Search forward for an article.
5921 If UNREAD, look for unread articles. If SUBJECT, look for
5922 articles with that subject. If BACKWARD, search backward instead."
5923 (cond (subject (gnus-summary-find-subject subject unread backward))
5924 (backward (gnus-summary-find-prev unread))
5925 (t (gnus-summary-find-next unread))))
5927 (defun gnus-recenter (&optional n)
5928 "Center point in window and redisplay frame.
5929 Also do horizontal recentering."
5931 (when (and gnus-auto-center-summary
5932 (not (eq gnus-auto-center-summary 'vertical)))
5933 (gnus-horizontal-recenter))
5936 (defun gnus-summary-recenter ()
5937 "Center point in the summary window.
5938 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5939 displayed, no centering will be performed."
5940 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5941 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5943 (let* ((top (cond ((< (window-height) 4) 0)
5944 ((< (window-height) 7) 1)
5945 (t (if (numberp gnus-auto-center-summary)
5946 gnus-auto-center-summary
5948 (height (1- (window-height)))
5949 (bottom (save-excursion (goto-char (point-max))
5950 (forward-line (- height))
5952 (window (get-buffer-window (current-buffer))))
5953 ;; The user has to want it.
5954 (when gnus-auto-center-summary
5955 (when (get-buffer-window gnus-article-buffer)
5956 ;; Only do recentering when the article buffer is displayed,
5957 ;; Set the window start to either `bottom', which is the biggest
5958 ;; possible valid number, or the second line from the top,
5959 ;; whichever is the least.
5960 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5961 (if (> bottom top-pos)
5962 ;; Keep the second line from the top visible
5963 (set-window-start window top-pos t)
5964 ;; Try to keep the bottom line visible; if it's partially
5965 ;; obscured, either scroll one more line to make it fully
5966 ;; visible, or revert to using TOP-POS.
5968 (goto-char (point-max))
5970 (let ((last-line-start (point)))
5972 (set-window-start window (point) t)
5973 (when (not (pos-visible-in-window-p last-line-start window))
5975 (set-window-start window (min (point) top-pos) t)))))))
5976 ;; Do horizontal recentering while we're at it.
5977 (when (and (get-buffer-window (current-buffer) t)
5978 (not (eq gnus-auto-center-summary 'vertical)))
5979 (let ((selected (selected-window)))
5980 (select-window (get-buffer-window (current-buffer) t))
5981 (gnus-summary-position-point)
5982 (gnus-horizontal-recenter)
5983 (select-window selected))))))
5985 (defun gnus-summary-jump-to-group (newsgroup)
5986 "Move point to NEWSGROUP in group mode buffer."
5987 ;; Keep update point of group mode buffer if visible.
5988 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5989 (save-window-excursion
5990 ;; Take care of tree window mode.
5991 (when (get-buffer-window gnus-group-buffer)
5992 (pop-to-buffer gnus-group-buffer))
5993 (gnus-group-jump-to-group newsgroup))
5995 ;; Take care of tree window mode.
5996 (if (get-buffer-window gnus-group-buffer)
5997 (pop-to-buffer gnus-group-buffer)
5998 (set-buffer gnus-group-buffer))
5999 (gnus-group-jump-to-group newsgroup))))
6001 ;; This function returns a list of article numbers based on the
6002 ;; difference between the ranges of read articles in this group and
6003 ;; the range of active articles.
6004 (defun gnus-list-of-unread-articles (group)
6005 (let* ((read (gnus-info-read (gnus-get-info group)))
6006 (active (or (gnus-active group) (gnus-activate-group group)))
6009 ;; If none are read, then all are unread.
6011 (setq first (car active))
6012 ;; If the range of read articles is a single range, then the
6013 ;; first unread article is the article after the last read
6014 ;; article. Sounds logical, doesn't it?
6015 (if (and (not (listp (cdr read)))
6016 (or (< (car read) (car active))
6017 (progn (setq read (list read))
6019 (setq first (max (car active) (1+ (cdr read))))
6020 ;; `read' is a list of ranges.
6021 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6024 (setq first (car active)))
6027 (while (< first nlast)
6029 (setq first (1+ first))))
6030 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6031 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6032 (setq read (cdr read)))))
6033 ;; And add the last unread articles.
6034 (while (<= first last)
6036 (setq first (1+ first)))
6037 ;; Return the list of unread articles.
6038 (delq 0 (nreverse unread))))
6040 (defun gnus-list-of-read-articles (group)
6041 "Return a list of unread, unticked and non-dormant articles."
6042 (let* ((info (gnus-get-info group))
6043 (marked (gnus-info-marks info))
6044 (active (gnus-active group)))
6046 (gnus-list-range-difference
6047 (gnus-list-range-difference
6048 (gnus-sorted-complement
6049 (gnus-uncompress-range active)
6050 (gnus-list-of-unread-articles group))
6051 (cdr (assq 'dormant marked)))
6052 (cdr (assq 'tick marked))))))
6054 ;; Various summary commands
6056 (defun gnus-summary-select-article-buffer ()
6057 "Reconfigure windows to show article buffer."
6059 (if (not (gnus-buffer-live-p gnus-article-buffer))
6060 (error "There is no article buffer for this summary buffer")
6061 (gnus-configure-windows 'article)
6062 (select-window (get-buffer-window gnus-article-buffer))))
6064 (defun gnus-summary-universal-argument (arg)
6065 "Perform any operation on all articles that are process/prefixed."
6067 (let ((articles (gnus-summary-work-articles arg))
6074 (substitute-command-keys
6075 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6077 (gnus-error 1 "Undefined key")
6080 (gnus-summary-goto-subject (setq article (pop articles)))
6081 (let (gnus-newsgroup-processable)
6082 (command-execute func))
6083 (gnus-summary-remove-process-mark article)))))
6084 (gnus-summary-position-point))
6086 (defun gnus-summary-toggle-truncation (&optional arg)
6087 "Toggle truncation of summary lines.
6088 With arg, turn line truncation on iff arg is positive."
6090 (setq truncate-lines
6091 (if (null arg) (not truncate-lines)
6092 (> (prefix-numeric-value arg) 0)))
6095 (defun gnus-summary-reselect-current-group (&optional all rescan)
6096 "Exit and then reselect the current newsgroup.
6097 The prefix argument ALL means to select all articles."
6099 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6100 (error "Ephemeral groups can't be reselected"))
6101 (let ((current-subject (gnus-summary-article-number))
6102 (group gnus-newsgroup-name))
6103 (setq gnus-newsgroup-begin nil)
6105 ;; We have to adjust the point of group mode buffer because
6106 ;; point was moved to the next unread newsgroup by exiting.
6107 (gnus-summary-jump-to-group group)
6110 (save-window-excursion
6111 ;; Don't show group contents.
6112 (set-window-start (selected-window) (point-max))
6113 (gnus-group-get-new-news-this-group 1))))
6114 (gnus-group-read-group all t)
6115 (gnus-summary-goto-subject current-subject nil t)))
6117 (defun gnus-summary-rescan-group (&optional all)
6118 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6120 (gnus-summary-reselect-current-group all t))
6122 (defun gnus-summary-update-info (&optional non-destructive)
6124 (let ((group gnus-newsgroup-name))
6126 (when gnus-newsgroup-kill-headers
6127 (setq gnus-newsgroup-killed
6128 (gnus-compress-sequence
6130 (gnus-list-range-intersection
6131 gnus-newsgroup-unselected gnus-newsgroup-killed)
6132 gnus-newsgroup-unreads)
6134 (unless (listp (cdr gnus-newsgroup-killed))
6135 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6136 (let ((headers gnus-newsgroup-headers))
6137 ;; Set the new ranges of read articles.
6139 (set-buffer gnus-group-buffer)
6140 (gnus-undo-force-boundary))
6141 (gnus-update-read-articles
6142 group (gnus-sorted-union
6143 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6144 ;; Set the current article marks.
6145 (let ((gnus-newsgroup-scored
6146 (if (and (not gnus-save-score)
6147 (not non-destructive))
6149 gnus-newsgroup-scored)))
6151 (gnus-update-marks)))
6152 ;; Do the cross-ref thing.
6153 (when gnus-use-cross-reference
6154 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6155 ;; Do not switch windows but change the buffer to work.
6156 (set-buffer gnus-group-buffer)
6157 (unless (gnus-ephemeral-group-p group)
6158 (gnus-group-update-group group)))))))
6160 (defun gnus-summary-save-newsrc (&optional force)
6161 "Save the current number of read/marked articles in the dribble buffer.
6162 The dribble buffer will then be saved.
6163 If FORCE (the prefix), also save the .newsrc file(s)."
6165 (gnus-summary-update-info t)
6167 (gnus-save-newsrc-file)
6168 (gnus-dribble-save)))
6170 (defun gnus-summary-exit (&optional temporary)
6171 "Exit reading current newsgroup, and then return to group selection mode.
6172 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6174 (gnus-set-global-variables)
6175 (gnus-kill-save-kill-buffer)
6176 (gnus-async-halt-prefetch)
6177 (let* ((group gnus-newsgroup-name)
6178 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6181 (buf (current-buffer)))
6183 ;; Do adaptive scoring, and possibly save score files.
6184 (when gnus-newsgroup-adaptive
6185 (gnus-score-adaptive))
6186 (when gnus-use-scoring
6188 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6189 ;; If we have several article buffers, we kill them at exit.
6190 (unless gnus-single-article-buffer
6191 (gnus-kill-buffer gnus-original-article-buffer)
6192 (setq gnus-article-current nil))
6193 (when gnus-use-cache
6194 (gnus-cache-possibly-remove-articles)
6195 (gnus-cache-save-buffers))
6196 (gnus-async-prefetch-remove-group group)
6197 (when gnus-suppress-duplicates
6198 (gnus-dup-enter-articles))
6199 (when gnus-use-trees
6200 (gnus-tree-close group))
6201 (when gnus-use-cache
6202 (gnus-cache-write-active))
6203 ;; Remove entries for this group.
6204 (nnmail-purge-split-history (gnus-group-real-name group))
6205 ;; Make all changes in this group permanent.
6207 (gnus-run-hooks 'gnus-exit-group-hook)
6208 (gnus-summary-update-info))
6209 (gnus-close-group group)
6210 ;; Make sure where we were, and go to next newsgroup.
6211 (set-buffer gnus-group-buffer)
6213 (gnus-group-jump-to-group group))
6214 (gnus-run-hooks 'gnus-summary-exit-hook)
6215 (unless (or quit-config
6216 ;; If this group has disappeared from the summary
6217 ;; buffer, don't skip forwards.
6218 (not (string= group (gnus-group-group-name))))
6219 (gnus-group-next-unread-group 1))
6220 (setq group-point (point))
6223 ;; If we have several article buffers, we kill them at exit.
6224 (unless gnus-single-article-buffer
6225 (gnus-kill-buffer gnus-article-buffer)
6226 (gnus-kill-buffer gnus-original-article-buffer)
6227 (setq gnus-article-current nil))
6229 (if (not gnus-kill-summary-on-exit)
6231 (gnus-deaden-summary)
6233 ;; We set all buffer-local variables to nil. It is unclear why
6234 ;; this is needed, but if we don't, buffer-local variables are
6235 ;; not garbage-collected, it seems. This would the lead to en
6236 ;; ever-growing Emacs.
6237 (gnus-summary-clear-local-variables)
6238 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6239 (gnus-summary-clear-local-variables))
6240 (when (get-buffer gnus-article-buffer)
6241 (bury-buffer gnus-article-buffer))
6242 ;; We clear the global counterparts of the buffer-local
6243 ;; variables as well, just to be on the safe side.
6244 (set-buffer gnus-group-buffer)
6245 (gnus-summary-clear-local-variables)
6246 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6247 (gnus-summary-clear-local-variables)))
6248 (setq gnus-current-select-method gnus-select-method)
6249 (pop-to-buffer gnus-group-buffer)
6250 (if (not quit-config)
6252 (goto-char group-point)
6253 (gnus-configure-windows 'group 'force)
6254 (unless (pos-visible-in-window-p)
6255 (forward-line (/ (static-if (featurep 'xemacs)
6256 (window-displayed-height)
6257 (1- (window-height)))
6259 (set-window-start (selected-window) (point))
6260 (goto-char group-point)))
6261 (gnus-handle-ephemeral-exit quit-config))
6262 ;; Return to group mode buffer.
6263 (when (eq mode 'gnus-summary-mode)
6264 (gnus-kill-buffer buf))
6265 ;; Clear the current group name.
6267 (setq gnus-newsgroup-name nil)))))
6269 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6270 (defun gnus-summary-exit-no-update (&optional no-questions)
6271 "Quit reading current newsgroup without updating read article info."
6273 (let* ((group gnus-newsgroup-name)
6274 (quit-config (gnus-group-quit-config group)))
6275 (when (or no-questions
6277 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6278 (gnus-async-halt-prefetch)
6280 (delq 'gnus-summary-expire-articles
6281 (copy-sequence gnus-summary-prepare-exit-hook)))
6282 ;; If we have several article buffers, we kill them at exit.
6283 (unless gnus-single-article-buffer
6284 (gnus-kill-buffer gnus-article-buffer)
6285 (gnus-kill-buffer gnus-original-article-buffer)
6286 (setq gnus-article-current nil))
6287 (if (not gnus-kill-summary-on-exit)
6288 (gnus-deaden-summary)
6289 (gnus-close-group group)
6290 (gnus-summary-clear-local-variables)
6291 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6292 (gnus-summary-clear-local-variables))
6293 (set-buffer gnus-group-buffer)
6294 (gnus-summary-clear-local-variables)
6295 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6296 (gnus-summary-clear-local-variables))
6297 (when (get-buffer gnus-summary-buffer)
6298 (kill-buffer gnus-summary-buffer)))
6299 (unless gnus-single-article-buffer
6300 (setq gnus-article-current nil))
6301 (when gnus-use-trees
6302 (gnus-tree-close group))
6303 (gnus-async-prefetch-remove-group group)
6304 (when (get-buffer gnus-article-buffer)
6305 (bury-buffer gnus-article-buffer))
6306 ;; Return to the group buffer.
6307 (gnus-configure-windows 'group 'force)
6308 ;; Clear the current group name.
6309 (setq gnus-newsgroup-name nil)
6310 (when (equal (gnus-group-group-name) group)
6311 (gnus-group-next-unread-group 1))
6313 (gnus-handle-ephemeral-exit quit-config)))))
6315 (defun gnus-handle-ephemeral-exit (quit-config)
6316 "Handle movement when leaving an ephemeral group.
6317 The state which existed when entering the ephemeral is reset."
6318 (if (not (buffer-name (car quit-config)))
6319 (gnus-configure-windows 'group 'force)
6320 (set-buffer (car quit-config))
6321 (cond ((eq major-mode 'gnus-summary-mode)
6322 (gnus-set-global-variables))
6323 ((eq major-mode 'gnus-article-mode)
6325 ;; The `gnus-summary-buffer' variable may point
6326 ;; to the old summary buffer when using a single
6328 (unless (gnus-buffer-live-p gnus-summary-buffer)
6329 (set-buffer gnus-group-buffer))
6330 (set-buffer gnus-summary-buffer)
6331 (gnus-set-global-variables))))
6332 (if (or (eq (cdr quit-config) 'article)
6333 (eq (cdr quit-config) 'pick))
6335 ;; The current article may be from the ephemeral group
6336 ;; thus it is best that we reload this article
6337 (gnus-summary-show-article)
6338 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6339 (gnus-configure-windows 'pick 'force)
6340 (gnus-configure-windows (cdr quit-config) 'force)))
6341 (gnus-configure-windows (cdr quit-config) 'force))
6342 (when (eq major-mode 'gnus-summary-mode)
6343 (gnus-summary-next-subject 1 nil t)
6344 (gnus-summary-recenter)
6345 (gnus-summary-position-point))))
6347 (defun gnus-summary-preview-mime-message ()
6348 "MIME decode and play this message."
6350 (let ((gnus-break-pages nil)
6352 (gnus-summary-select-article gnus-show-all-headers t))
6353 (let ((w (get-buffer-window gnus-article-buffer)))
6355 (select-window (get-buffer-window gnus-article-buffer)))))
6359 (defvar gnus-dead-summary-mode-map nil)
6361 (unless gnus-dead-summary-mode-map
6362 (setq gnus-dead-summary-mode-map (make-keymap))
6363 (suppress-keymap gnus-dead-summary-mode-map)
6364 (substitute-key-definition
6365 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6366 (dolist (key '("\C-d" "\r" "\177" [delete]))
6367 (define-key gnus-dead-summary-mode-map
6368 key 'gnus-summary-wake-up-the-dead))
6369 (dolist (key '("q" "Q"))
6370 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6372 (defvar gnus-dead-summary-mode nil
6373 "Minor mode for Gnus summary buffers.")
6375 (defun gnus-dead-summary-mode (&optional arg)
6376 "Minor mode for Gnus summary buffers."
6378 (when (eq major-mode 'gnus-summary-mode)
6379 (make-local-variable 'gnus-dead-summary-mode)
6380 (setq gnus-dead-summary-mode
6381 (if (null arg) (not gnus-dead-summary-mode)
6382 (> (prefix-numeric-value arg) 0)))
6383 (when gnus-dead-summary-mode
6384 (gnus-add-minor-mode
6385 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6387 (defun gnus-deaden-summary ()
6388 "Make the current summary buffer into a dead summary buffer."
6389 ;; Kill any previous dead summary buffer.
6390 (when (and gnus-dead-summary
6391 (buffer-name gnus-dead-summary))
6393 (set-buffer gnus-dead-summary)
6394 (when gnus-dead-summary-mode
6395 (kill-buffer (current-buffer)))))
6396 ;; Make this the current dead summary.
6397 (setq gnus-dead-summary (current-buffer))
6398 (gnus-dead-summary-mode 1)
6399 (let ((name (buffer-name)))
6400 (when (string-match "Summary" name)
6402 (concat (substring name 0 (match-beginning 0)) "Dead "
6403 (substring name (match-beginning 0)))
6407 (defun gnus-kill-or-deaden-summary (buffer)
6408 "Kill or deaden the summary BUFFER."
6410 (when (and (buffer-name buffer)
6411 (not gnus-single-article-buffer))
6414 (gnus-kill-buffer gnus-article-buffer)
6415 (gnus-kill-buffer gnus-original-article-buffer)))
6418 (gnus-kill-summary-on-exit
6419 (when (and gnus-use-trees
6420 (gnus-buffer-exists-p buffer))
6423 (gnus-tree-close gnus-newsgroup-name)))
6424 (gnus-kill-buffer buffer))
6425 ;; Deaden the buffer.
6426 ((gnus-buffer-exists-p buffer)
6429 (gnus-deaden-summary))))))
6431 (defun gnus-summary-wake-up-the-dead (&rest args)
6432 "Wake up the dead summary buffer."
6434 (gnus-dead-summary-mode -1)
6435 (let ((name (buffer-name)))
6436 (when (string-match "Dead " name)
6438 (concat (substring name 0 (match-beginning 0))
6439 (substring name (match-end 0)))
6441 (gnus-message 3 "This dead summary is now alive again"))
6443 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6444 (defun gnus-summary-fetch-faq (&optional faq-dir)
6445 "Fetch the FAQ for the current group.
6446 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6450 (when current-prefix-arg
6452 "Faq dir: " (and (listp gnus-group-faq-directory)
6453 (mapcar (lambda (file) (list file))
6454 gnus-group-faq-directory))))))
6455 (let (gnus-faq-buffer)
6456 (when (setq gnus-faq-buffer
6457 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6458 (gnus-configure-windows 'summary-faq))))
6460 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6461 (defun gnus-summary-describe-group (&optional force)
6462 "Describe the current newsgroup."
6464 (gnus-group-describe-group force gnus-newsgroup-name))
6466 (defun gnus-summary-describe-briefly ()
6467 "Describe summary mode commands briefly."
6469 (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")))
6471 ;; Walking around group mode buffer from summary mode.
6473 (defun gnus-summary-next-group (&optional no-article target-group backward)
6474 "Exit current newsgroup and then select next unread newsgroup.
6475 If prefix argument NO-ARTICLE is non-nil, no article is selected
6476 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6477 previous group instead."
6479 ;; Stop pre-fetching.
6480 (gnus-async-halt-prefetch)
6481 (let ((current-group gnus-newsgroup-name)
6482 (current-buffer (current-buffer))
6484 ;; First we semi-exit this group to update Xrefs and all variables.
6485 ;; We can't do a real exit, because the window conf must remain
6486 ;; the same in case the user is prompted for info, and we don't
6487 ;; want the window conf to change before that...
6488 (gnus-summary-exit t)
6489 (while (not entered)
6490 ;; Then we find what group we are supposed to enter.
6491 (set-buffer gnus-group-buffer)
6492 (gnus-group-jump-to-group current-group)
6495 (if (eq gnus-keep-same-level 'best)
6496 (gnus-summary-best-group gnus-newsgroup-name)
6497 (gnus-summary-search-group backward gnus-keep-same-level))))
6498 (if (not target-group)
6499 ;; There are no further groups, so we return to the group
6502 (gnus-message 5 "Returning to the group buffer")
6504 (when (gnus-buffer-live-p current-buffer)
6505 (set-buffer current-buffer)
6506 (gnus-summary-exit))
6507 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6508 ;; We try to enter the target group.
6509 (gnus-group-jump-to-group target-group)
6510 (let ((unreads (gnus-group-group-unread)))
6511 (if (and (or (eq t unreads)
6512 (and unreads (not (zerop unreads))))
6513 (gnus-summary-read-group
6514 target-group nil no-article
6515 (and (buffer-name current-buffer) current-buffer)
6518 (setq current-group target-group
6519 target-group nil)))))))
6521 (defun gnus-summary-prev-group (&optional no-article)
6522 "Exit current newsgroup and then select previous unread newsgroup.
6523 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6525 (gnus-summary-next-group no-article nil t))
6527 ;; Walking around summary lines.
6529 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6530 "Go to the first unread subject.
6531 If UNREAD is non-nil, go to the first unread article.
6532 Returns the article selected or nil if there are no unread articles."
6537 ((null gnus-newsgroup-data)
6538 (gnus-message 3 "No articles in the group")
6540 ;; Pick the first article.
6542 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6543 (gnus-data-number (car gnus-newsgroup-data)))
6544 ;; No unread articles.
6545 ((null gnus-newsgroup-unreads)
6546 (gnus-message 3 "No more unread articles")
6548 ;; Find the first unread article.
6550 (let ((data gnus-newsgroup-data))
6552 (and (not (and undownloaded
6553 (eq gnus-undownloaded-mark
6554 (gnus-data-mark (car data)))))
6557 (gnus-data-number (car data))
6558 gnus-newsgroup-unseen))
6559 (not (gnus-data-unread-p (car data))))
6560 (not (gnus-data-unread-p (car data))))))
6561 (setq data (cdr data)))
6563 (goto-char (gnus-data-pos (car data)))
6564 (gnus-data-number (car data))))))
6565 (gnus-summary-position-point)))
6567 (defun gnus-summary-next-subject (n &optional unread dont-display)
6568 "Go to next N'th summary line.
6569 If N is negative, go to the previous N'th subject line.
6570 If UNREAD is non-nil, only unread articles are selected.
6571 The difference between N and the actual number of steps taken is
6574 (let ((backward (< n 0))
6578 (gnus-summary-find-prev unread)
6579 (gnus-summary-find-next unread)))
6580 (unless (zerop (setq n (1- n)))
6581 (gnus-summary-show-thread)))
6583 (gnus-message 7 "No more%s articles"
6584 (if unread " unread" "")))
6585 (unless dont-display
6586 (gnus-summary-recenter)
6587 (gnus-summary-position-point))
6590 (defun gnus-summary-next-unread-subject (n)
6591 "Go to next N'th unread summary line."
6593 (gnus-summary-next-subject n t))
6595 (defun gnus-summary-prev-subject (n &optional unread)
6596 "Go to previous N'th summary line.
6597 If optional argument UNREAD is non-nil, only unread article is selected."
6599 (gnus-summary-next-subject (- n) unread))
6601 (defun gnus-summary-prev-unread-subject (n)
6602 "Go to previous N'th unread summary line."
6604 (gnus-summary-next-subject (- n) t))
6606 (defun gnus-summary-goto-subject (article &optional force silent)
6607 "Go the subject line of ARTICLE.
6608 If FORCE, also allow jumping to articles not currently shown."
6609 (interactive "nArticle number: ")
6610 (unless (numberp article)
6611 (error "Article %s is not a number" article))
6613 (data (gnus-data-find article)))
6614 ;; We read in the article if we have to.
6617 (gnus-summary-insert-subject
6619 (if (or (numberp force) (vectorp force)) force)
6621 (setq data (gnus-data-find article)))
6626 (gnus-message 3 "Can't find article %d" article))
6628 (let ((pt (gnus-data-pos data)))
6630 (gnus-summary-set-article-display-arrow pt))
6631 (gnus-summary-position-point)
6634 ;; Walking around summary lines with displaying articles.
6636 (defun gnus-summary-expand-window (&optional arg)
6637 "Make the summary buffer take up the entire Emacs frame.
6638 Given a prefix, will force an `article' buffer configuration."
6641 (gnus-configure-windows 'article 'force)
6642 (gnus-configure-windows 'summary 'force)))
6644 (defun gnus-summary-display-article (article &optional all-header)
6645 "Display ARTICLE in article buffer."
6646 (when (gnus-buffer-live-p gnus-article-buffer)
6647 (with-current-buffer gnus-article-buffer
6648 (set-buffer-multibyte t)))
6649 (gnus-set-global-variables)
6650 (when (gnus-buffer-live-p gnus-article-buffer)
6651 (with-current-buffer gnus-article-buffer
6652 (setq gnus-article-charset gnus-newsgroup-charset)
6653 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6654 (set-buffer-multibyte t)))
6658 (if gnus-summary-display-article-function
6659 (funcall gnus-summary-display-article-function article all-header)
6660 (gnus-article-prepare article all-header))
6661 (with-current-buffer gnus-article-buffer
6662 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6664 (gnus-run-hooks 'gnus-select-article-hook)
6665 (when (and gnus-current-article
6666 (not (zerop gnus-current-article)))
6667 (gnus-summary-goto-subject gnus-current-article))
6668 (gnus-summary-recenter)
6669 (when (and gnus-use-trees gnus-show-threads)
6670 (gnus-possibly-generate-tree article)
6671 (gnus-highlight-selected-tree article))
6672 ;; Successfully display article.
6673 (gnus-article-set-window-start
6674 (cdr (assq article gnus-newsgroup-bookmarks))))))
6676 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6677 "Select the current article.
6678 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6679 non-nil, the article will be re-fetched even if it already present in
6680 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6682 ;; Make sure we are in the summary buffer to work around bbdb bug.
6683 (unless (eq major-mode 'gnus-summary-mode)
6684 (set-buffer gnus-summary-buffer))
6685 (let ((article (or article (gnus-summary-article-number)))
6686 (all-headers (not (not all-headers))) ;Must be T or NIL.
6687 gnus-summary-display-article-function)
6689 (gnus-summary-article-pseudo-p article)
6690 (error "This is a pseudo-article"))
6692 (set-buffer gnus-summary-buffer)
6693 (if (or (and gnus-single-article-buffer
6694 (or (null gnus-current-article)
6695 (null gnus-article-current)
6696 (null (get-buffer gnus-article-buffer))
6697 (not (eq article (cdr gnus-article-current)))
6698 (not (equal (car gnus-article-current)
6699 gnus-newsgroup-name))))
6700 (and (not gnus-single-article-buffer)
6701 (or (null gnus-current-article)
6702 (not (eq gnus-current-article article))))
6704 ;; The requested article is different from the current article.
6706 (gnus-summary-display-article article all-headers)
6707 (gnus-article-set-window-start
6708 (cdr (assq article gnus-newsgroup-bookmarks)))
6712 (defun gnus-summary-force-verify-and-decrypt ()
6714 (let ((mm-verify-option 'known)
6715 (mm-decrypt-option 'known)
6716 (gnus-buttonized-mime-types (append (list "multipart/signed"
6717 "multipart/encrypted")
6718 gnus-buttonized-mime-types)))
6719 (gnus-summary-select-article nil 'force)))
6721 (defun gnus-summary-set-current-mark (&optional current-mark)
6722 "Obsolete function."
6725 (defun gnus-summary-next-article (&optional unread subject backward push)
6726 "Select the next article.
6727 If UNREAD, only unread articles are selected.
6728 If SUBJECT, only articles with SUBJECT are selected.
6729 If BACKWARD, the previous article is selected instead of the next."
6732 ;; Is there such an article?
6733 ((and (gnus-summary-search-forward unread subject backward)
6734 (or (gnus-summary-display-article (gnus-summary-article-number))
6735 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6736 (gnus-summary-position-point))
6737 ;; If not, we try the first unread, if that is wanted.
6739 gnus-auto-select-same
6740 (gnus-summary-first-unread-article))
6741 (gnus-summary-position-point)
6742 (gnus-message 6 "Wrapped"))
6743 ;; Try to get next/previous article not displayed in this group.
6744 ((and gnus-auto-extend-newsgroup
6745 (not unread) (not subject))
6746 (gnus-summary-goto-article
6747 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748 nil (count-lines (point-min) (point))))
6749 ;; Go to next/previous group.
6751 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6752 (gnus-summary-jump-to-group gnus-newsgroup-name))
6753 (let ((cmd last-command-char)
6756 (set-buffer gnus-group-buffer)
6759 (if (eq gnus-keep-same-level 'best)
6760 (gnus-summary-best-group gnus-newsgroup-name)
6761 (gnus-summary-search-group backward gnus-keep-same-level))))
6762 ;; For some reason, the group window gets selected. We change
6764 (select-window (get-buffer-window (current-buffer)))
6765 ;; Select next unread newsgroup automagically.
6767 ((or (not gnus-auto-select-next)
6769 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6770 ((or (eq gnus-auto-select-next 'quietly)
6771 (and (eq gnus-auto-select-next 'slightly-quietly)
6773 (and (eq gnus-auto-select-next 'almost-quietly)
6774 (gnus-summary-last-article-p)))
6776 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6778 (gnus-message 7 "No more%s articles (%s)..."
6779 (if unread " unread" "")
6780 (if group (concat "selecting " group)
6782 (gnus-summary-next-group nil group backward)))
6784 (when (gnus-key-press-event-p last-input-event)
6785 (gnus-summary-walk-group-buffer
6786 gnus-newsgroup-name cmd unread backward point))))))))
6788 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6789 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6790 (?\C-p (gnus-group-prev-unread-group 1))))
6791 (cursor-in-echo-area t)
6792 keve key group ended)
6794 (set-buffer gnus-group-buffer)
6797 (if (eq gnus-keep-same-level 'best)
6798 (gnus-summary-best-group gnus-newsgroup-name)
6799 (gnus-summary-search-group backward gnus-keep-same-level))))
6802 5 "No more%s articles%s" (if unread " unread" "")
6804 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6805 (format " (Type %s for %s [%s])"
6806 (single-key-description cmd) group
6807 (car (gnus-gethash group gnus-newsrc-hashtb)))
6808 (format " (Type %s to exit %s)"
6809 (single-key-description cmd)
6810 gnus-newsgroup-name)))
6811 ;; Confirm auto selection.
6812 (setq key (car (setq keve (gnus-read-event-char))))
6815 ((assq key keystrokes)
6816 (let ((obuf (current-buffer)))
6817 (switch-to-buffer gnus-group-buffer)
6819 (gnus-group-jump-to-group group))
6820 (eval (cadr (assq key keystrokes)))
6821 (setq group (gnus-group-group-name))
6822 (switch-to-buffer obuf))
6826 (gnus-ephemeral-group-p gnus-newsgroup-name))
6828 (gnus-summary-next-group nil group backward)))
6830 (push (cdr keve) unread-command-events))))))
6832 (defun gnus-summary-next-unread-article ()
6833 "Select unread article after current one."
6835 (gnus-summary-next-article
6836 (or (not (eq gnus-summary-goto-unread 'never))
6837 (gnus-summary-last-article-p (gnus-summary-article-number)))
6838 (and gnus-auto-select-same
6839 (gnus-summary-article-subject))))
6841 (defun gnus-summary-prev-article (&optional unread subject)
6842 "Select the article after the current one.
6843 If UNREAD is non-nil, only unread articles are selected."
6845 (gnus-summary-next-article unread subject t))
6847 (defun gnus-summary-prev-unread-article ()
6848 "Select unread article before current one."
6850 (gnus-summary-prev-article
6851 (or (not (eq gnus-summary-goto-unread 'never))
6852 (gnus-summary-first-article-p (gnus-summary-article-number)))
6853 (and gnus-auto-select-same
6854 (gnus-summary-article-subject))))
6856 (defun gnus-summary-next-page (&optional lines circular)
6857 "Show next page of the selected article.
6858 If at the end of the current article, select the next article.
6859 LINES says how many lines should be scrolled up.
6861 If CIRCULAR is non-nil, go to the start of the article instead of
6862 selecting the next article when reaching the end of the current
6865 (setq gnus-summary-buffer (current-buffer))
6866 (gnus-set-global-variables)
6867 (let ((article (gnus-summary-article-number))
6868 (article-window (get-buffer-window gnus-article-buffer t))
6870 ;; If the buffer is empty, we have no article.
6872 (error "No article to select"))
6873 (gnus-configure-windows 'article)
6874 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6875 (if (and (eq gnus-summary-goto-unread 'never)
6876 (not (gnus-summary-last-article-p article)))
6877 (gnus-summary-next-article)
6878 (gnus-summary-next-unread-article))
6879 (if (or (null gnus-current-article)
6880 (null gnus-article-current)
6881 (/= article (cdr gnus-article-current))
6882 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6883 ;; Selected subject is different from current article's.
6884 (gnus-summary-display-article article)
6885 (when article-window
6886 (gnus-eval-in-buffer-window gnus-article-buffer
6887 (setq endp (gnus-article-next-page lines)))
6890 (gnus-summary-beginning-of-article))
6892 (gnus-message 3 "End of message"))
6894 (if (and (eq gnus-summary-goto-unread 'never)
6895 (not (gnus-summary-last-article-p article)))
6896 (gnus-summary-next-article)
6897 (gnus-summary-next-unread-article))))))))
6898 (gnus-summary-recenter)
6899 (gnus-summary-position-point)))
6901 (defun gnus-summary-prev-page (&optional lines move)
6902 "Show previous page of selected article.
6903 Argument LINES specifies lines to be scrolled down.
6904 If MOVE, move to the previous unread article if point is at
6905 the beginning of the buffer."
6907 (let ((article (gnus-summary-article-number))
6908 (article-window (get-buffer-window gnus-article-buffer t))
6910 (gnus-configure-windows 'article)
6911 (if (or (null gnus-current-article)
6912 (null gnus-article-current)
6913 (/= article (cdr gnus-article-current))
6914 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6915 ;; Selected subject is different from current article's.
6916 (gnus-summary-display-article article)
6917 (gnus-summary-recenter)
6918 (when article-window
6919 (gnus-eval-in-buffer-window gnus-article-buffer
6920 (setq endp (gnus-article-prev-page lines)))
6921 (when (and move endp)
6923 (gnus-message 3 "Beginning of message"))
6925 (if (and (eq gnus-summary-goto-unread 'never)
6926 (not (gnus-summary-first-article-p article)))
6927 (gnus-summary-prev-article)
6928 (gnus-summary-prev-unread-article))))))))
6929 (gnus-summary-position-point))
6931 (defun gnus-summary-prev-page-or-article (&optional lines)
6932 "Show previous page of selected article.
6933 Argument LINES specifies lines to be scrolled down.
6934 If at the beginning of the article, go to the next article."
6936 (gnus-summary-prev-page lines t))
6938 (defun gnus-summary-scroll-up (lines)
6939 "Scroll up (or down) one line current article.
6940 Argument LINES specifies lines to be scrolled up (or down if negative)."
6942 (gnus-configure-windows 'article)
6943 (gnus-summary-show-thread)
6944 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6945 (gnus-eval-in-buffer-window gnus-article-buffer
6947 (when (gnus-article-next-page lines)
6948 (gnus-message 3 "End of message")))
6950 (gnus-article-prev-page (- lines))))))
6951 (gnus-summary-recenter)
6952 (gnus-summary-position-point))
6954 (defun gnus-summary-scroll-down (lines)
6955 "Scroll down (or up) one line current article.
6956 Argument LINES specifies lines to be scrolled down (or up if negative)."
6958 (gnus-summary-scroll-up (- lines)))
6960 (defun gnus-summary-next-same-subject ()
6961 "Select next article which has the same subject as current one."
6963 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6965 (defun gnus-summary-prev-same-subject ()
6966 "Select previous article which has the same subject as current one."
6968 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6970 (defun gnus-summary-next-unread-same-subject ()
6971 "Select next unread article which has the same subject as current one."
6973 (gnus-summary-next-article t (gnus-summary-article-subject)))
6975 (defun gnus-summary-prev-unread-same-subject ()
6976 "Select previous unread article which has the same subject as current one."
6978 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6980 (defun gnus-summary-first-unread-article ()
6981 "Select the first unread article.
6982 Return nil if there are no unread articles."
6985 (when (gnus-summary-first-subject t)
6986 (gnus-summary-show-thread)
6987 (gnus-summary-first-subject t)
6988 (gnus-summary-display-article (gnus-summary-article-number)))
6989 (gnus-summary-position-point)))
6991 (defun gnus-summary-first-unread-subject ()
6992 "Place the point on the subject line of the first unread article.
6993 Return nil if there are no unread articles."
6996 (when (gnus-summary-first-subject t)
6997 (gnus-summary-show-thread)
6998 (gnus-summary-first-subject t))
6999 (gnus-summary-position-point)))
7001 (defun gnus-summary-first-unseen-subject ()
7002 "Place the point on the subject line of the first unseen article.
7003 Return nil if there are no unseen articles."
7006 (when (gnus-summary-first-subject t t t)
7007 (gnus-summary-show-thread)
7008 (gnus-summary-first-subject t t t))
7009 (gnus-summary-position-point)))
7011 (defun gnus-summary-first-unseen-or-unread-subject ()
7012 "Place the point on the subject line of the first unseen article.
7013 Return nil if there are no unseen articles."
7016 (unless (when (gnus-summary-first-subject t t t)
7017 (gnus-summary-show-thread)
7018 (gnus-summary-first-subject t t t))
7019 (when (gnus-summary-first-subject t)
7020 (gnus-summary-show-thread)
7021 (gnus-summary-first-subject t)))
7022 (gnus-summary-position-point)))
7024 (defun gnus-summary-first-article ()
7025 "Select the first article.
7026 Return nil if there are no articles."
7029 (when (gnus-summary-first-subject)
7030 (gnus-summary-show-thread)
7031 (gnus-summary-first-subject)
7032 (gnus-summary-display-article (gnus-summary-article-number)))
7033 (gnus-summary-position-point)))
7035 (defun gnus-summary-best-unread-article (&optional arg)
7036 "Select the unread article with the highest score.
7037 If given a prefix argument, select the next unread article that has a
7038 score higher than the default score."
7040 (let ((article (if arg
7041 (gnus-summary-better-unread-subject)
7042 (gnus-summary-best-unread-subject))))
7044 (gnus-summary-goto-article article)
7045 (error "No unread articles"))))
7047 (defun gnus-summary-best-unread-subject ()
7048 "Select the unread subject with the highest score."
7050 (let ((best -1000000)
7051 (data gnus-newsgroup-data)
7054 (and (gnus-data-unread-p (car data))
7056 (gnus-summary-article-score (gnus-data-number (car data))))
7059 article (gnus-data-number (car data))))
7060 (setq data (cdr data)))
7062 (gnus-summary-goto-subject article))
7063 (gnus-summary-position-point)
7066 (defun gnus-summary-better-unread-subject ()
7067 "Select the first unread subject that has a score over the default score."
7069 (let ((data gnus-newsgroup-data)
7071 (while (and (setq article (gnus-data-number (car data)))
7072 (or (gnus-data-read-p (car data))
7073 (not (> (gnus-summary-article-score article)
7074 gnus-summary-default-score))))
7075 (setq data (cdr data)))
7077 (gnus-summary-goto-subject article))
7078 (gnus-summary-position-point)
7081 (defun gnus-summary-last-subject ()
7082 "Go to the last displayed subject line in the group."
7083 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7085 (gnus-summary-goto-subject article))))
7087 (defun gnus-summary-goto-article (article &optional all-headers force)
7088 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7089 If ALL-HEADERS is non-nil, no header lines are hidden.
7090 If FORCE, go to the article even if it isn't displayed. If FORCE
7091 is a number, it is the line the article is to be displayed on."
7095 "Article number or Message-ID: "
7096 (mapcar (lambda (number) (list (int-to-string number)))
7097 gnus-newsgroup-limit))
7101 (if (and (stringp article)
7102 (string-match "@" article))
7103 (gnus-summary-refer-article article)
7104 (when (stringp article)
7105 (setq article (string-to-number article)))
7106 (if (gnus-summary-goto-subject article force)
7107 (gnus-summary-display-article article all-headers)
7108 (gnus-message 4 "Couldn't go to article %s" article) nil))
7109 (gnus-summary-position-point)))
7111 (defun gnus-summary-goto-last-article ()
7112 "Go to the previously read article."
7115 (when gnus-last-article
7116 (gnus-summary-goto-article gnus-last-article nil t))
7117 (gnus-summary-position-point)))
7119 (defun gnus-summary-pop-article (number)
7120 "Pop one article off the history and go to the previous.
7121 NUMBER articles will be popped off."
7124 (setq gnus-newsgroup-history
7125 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7127 (gnus-summary-goto-article (car to) nil t)
7128 (error "Article history empty")))
7129 (gnus-summary-position-point))
7131 ;; Summary commands and functions for limiting the summary buffer.
7133 (defun gnus-summary-limit-to-articles (n)
7134 "Limit the summary buffer to the next N articles.
7135 If not given a prefix, use the process marked articles instead."
7138 (let ((articles (gnus-summary-work-articles n)))
7139 (setq gnus-newsgroup-processable nil)
7140 (gnus-summary-limit articles))
7141 (gnus-summary-position-point)))
7143 (defun gnus-summary-pop-limit (&optional total)
7144 "Restore the previous limit.
7145 If given a prefix, remove all limits."
7148 (setq gnus-newsgroup-limits
7149 (list (mapcar (lambda (h) (mail-header-number h))
7150 gnus-newsgroup-headers))))
7151 (unless gnus-newsgroup-limits
7152 (error "No limit to pop"))
7154 (gnus-summary-limit nil 'pop)
7155 (gnus-summary-position-point)))
7157 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7158 "Limit the summary buffer to articles that have subjects that match a regexp.
7159 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7161 (list (read-string (if current-prefix-arg
7162 "Exclude subject (regexp): "
7163 "Limit to subject (regexp): "))
7164 nil current-prefix-arg))
7166 (setq header "subject"))
7167 (when (not (equal "" subject))
7169 (let ((articles (gnus-summary-find-matching
7170 (or header "subject") subject 'all nil nil
7173 (error "Found no matches for \"%s\"" subject))
7174 (gnus-summary-limit articles))
7175 (gnus-summary-position-point))))
7177 (defun gnus-summary-limit-to-author (from &optional not-matching)
7178 "Limit the summary buffer to articles that have authors that match a regexp.
7179 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7181 (list (read-string (if current-prefix-arg
7182 "Exclude author (regexp): "
7183 "Limit to author (regexp): "))
7184 current-prefix-arg))
7185 (gnus-summary-limit-to-subject from "from" not-matching))
7187 (defun gnus-summary-limit-to-age (age &optional younger-p)
7188 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7189 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7190 articles that are younger than AGE days."
7192 (let ((younger current-prefix-arg)
7195 (while (not days-got)
7196 (setq days (if younger
7197 (read-string "Limit to articles within (in days): ")
7198 (read-string "Limit to articles older than (in days): ")))
7199 (when (> (length days) 0)
7200 (setq days (read days)))
7206 (setq younger (not younger))
7207 (setq days (* days -1)))))
7208 (message "Please enter a number.")
7210 (list days younger)))
7212 (let ((data gnus-newsgroup-data)
7213 (cutoff (days-to-time age))
7214 articles d date is-younger)
7215 (while (setq d (pop data))
7216 (when (and (vectorp (gnus-data-header d))
7217 (setq date (mail-header-date (gnus-data-header d))))
7218 (setq is-younger (time-less-p
7219 (time-since (condition-case ()
7226 (push (gnus-data-number d) articles))))
7227 (gnus-summary-limit (nreverse articles)))
7228 (gnus-summary-position-point)))
7230 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7231 "Limit the summary buffer to articles that match an 'extra' header."
7235 (gnus-completing-read-with-default
7236 (symbol-name (car gnus-extra-headers))
7237 (if current-prefix-arg
7238 "Exclude extra header:"
7239 "Limit extra header:")
7241 (cons (symbol-name x) x))
7246 (read-string (format "%s header %s (regexp): "
7247 (if current-prefix-arg "Exclude" "Limit to")
7249 current-prefix-arg)))
7250 (when (not (equal "" regexp))
7252 (let ((articles (gnus-summary-find-matching
7253 (cons 'extra header) regexp 'all nil nil
7256 (error "Found no matches for \"%s\"" regexp))
7257 (gnus-summary-limit articles))
7258 (gnus-summary-position-point))))
7260 (defun gnus-summary-limit-to-display-predicate ()
7261 "Limit the summary buffer to the predicated in the `display' group parameter."
7263 (unless gnus-newsgroup-display
7264 (error "There is no `display' group parameter"))
7266 (dolist (number gnus-newsgroup-articles)
7267 (when (funcall gnus-newsgroup-display)
7268 (push number articles)))
7269 (gnus-summary-limit articles))
7270 (gnus-summary-position-point))
7272 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7274 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7276 (defun gnus-summary-limit-to-unread (&optional all)
7277 "Limit the summary buffer to articles that are not marked as read.
7278 If ALL is non-nil, limit strictly to unread articles."
7281 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7282 (gnus-summary-limit-to-marks
7283 ;; Concat all the marks that say that an article is read and have
7285 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7286 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7287 gnus-low-score-mark gnus-expirable-mark
7288 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7289 gnus-duplicate-mark gnus-souped-mark)
7292 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7293 (make-obsolete 'gnus-summary-delete-marked-with
7294 'gnus-summary-limit-exclude-marks)
7296 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7297 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7298 If REVERSE, limit the summary buffer to articles that are marked
7299 with MARKS. MARKS can either be a string of marks or a list of marks.
7300 Returns how many articles were removed."
7301 (interactive "sMarks: ")
7302 (gnus-summary-limit-to-marks marks t))
7304 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7305 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7306 If REVERSE (the prefix), limit the summary buffer to articles that are
7307 not marked with MARKS. MARKS can either be a string of marks or a
7309 Returns how many articles were removed."
7310 (interactive "sMarks: \nP")
7312 (let ((data gnus-newsgroup-data)
7313 (marks (if (listp marks) marks
7314 (append marks nil))) ; Transform to list.
7317 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7318 (memq (gnus-data-mark (car data)) marks))
7319 (push (gnus-data-number (car data)) articles))
7320 (setq data (cdr data)))
7321 (gnus-summary-limit articles))
7322 (gnus-summary-position-point)))
7324 (defun gnus-summary-limit-to-score (score)
7325 "Limit to articles with score at or above SCORE."
7326 (interactive "NLimit to articles with score of at least: ")
7327 (let ((data gnus-newsgroup-data)
7330 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7332 (push (gnus-data-number (car data)) articles))
7333 (setq data (cdr data)))
7335 (gnus-summary-limit articles)
7336 (gnus-summary-position-point))))
7338 (defun gnus-summary-limit-include-thread (id)
7339 "Display all the hidden articles that is in the thread with ID in it.
7340 When called interactively, ID is the Message-ID of the current
7342 (interactive (list (mail-header-id (gnus-summary-article-header))))
7343 (let ((articles (gnus-articles-in-thread
7344 (gnus-id-to-thread (gnus-root-id id)))))
7346 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7347 (gnus-summary-limit-include-matching-articles
7349 (regexp-quote (gnus-simplify-subject-re
7350 (mail-header-subject (gnus-id-to-header id)))))
7351 (gnus-summary-position-point))))
7353 (defun gnus-summary-limit-include-matching-articles (header regexp)
7354 "Display all the hidden articles that have HEADERs that match REGEXP."
7355 (interactive (list (read-string "Match on header: ")
7356 (read-string "Regexp: ")))
7357 (let ((articles (gnus-find-matching-articles header regexp)))
7359 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7360 (gnus-summary-position-point))))
7362 (defun gnus-summary-limit-include-dormant ()
7363 "Display all the hidden articles that are marked as dormant.
7364 Note that this command only works on a subset of the articles currently
7365 fetched for this group."
7367 (unless gnus-newsgroup-dormant
7368 (error "There are no dormant articles in this group"))
7370 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7371 (gnus-summary-position-point)))
7373 (defun gnus-summary-limit-exclude-dormant ()
7374 "Hide all dormant articles."
7377 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7378 (gnus-summary-position-point)))
7380 (defun gnus-summary-limit-exclude-childless-dormant ()
7381 "Hide all dormant articles that have no children."
7383 (let ((data (gnus-data-list t))
7384 articles d children)
7385 ;; Find all articles that are either not dormant or have
7387 (while (setq d (pop data))
7388 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7390 (gnus-article-children (gnus-data-number d)))
7393 (when (memq (car children) articles)
7398 (push (gnus-data-number d) articles)))
7401 (gnus-summary-limit articles)
7402 (gnus-summary-position-point))))
7404 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7405 "Mark all unread excluded articles as read.
7406 If ALL, mark even excluded ticked and dormants as read."
7408 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7409 (let ((articles (gnus-sorted-ndifference
7411 (mapcar (lambda (h) (mail-header-number h))
7412 gnus-newsgroup-headers)
7414 gnus-newsgroup-limit))
7416 (setq gnus-newsgroup-unreads
7417 (gnus-sorted-intersection gnus-newsgroup-unreads
7418 gnus-newsgroup-limit))
7420 (setq gnus-newsgroup-dormant nil
7421 gnus-newsgroup-marked nil
7422 gnus-newsgroup-reads
7424 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7425 gnus-newsgroup-reads))
7426 (while (setq article (pop articles))
7427 (unless (or (memq article gnus-newsgroup-dormant)
7428 (memq article gnus-newsgroup-marked))
7429 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7431 (defun gnus-summary-limit (articles &optional pop)
7433 ;; We pop the previous limit off the stack and use that.
7434 (setq articles (car gnus-newsgroup-limits)
7435 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7436 ;; We use the new limit, so we push the old limit on the stack.
7437 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7439 (setq gnus-newsgroup-limit articles)
7440 (let ((total (length gnus-newsgroup-data))
7441 (data (gnus-data-find-list (gnus-summary-article-number)))
7442 (gnus-summary-mark-below nil) ; Inhibit this.
7444 ;; This will do all the work of generating the new summary buffer
7445 ;; according to the new limit.
7446 (gnus-summary-prepare)
7447 ;; Hide any threads, possibly.
7448 (gnus-summary-maybe-hide-threads)
7449 ;; Try to return to the article you were at, or one in the
7452 ;; We try to find some article after the current one.
7454 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7457 (setq data (cdr data))))
7459 ;; If there is no data, that means that we were after the last
7460 ;; article. The same goes when we can't find any articles
7461 ;; after the current one.
7462 (goto-char (point-max))
7463 (gnus-summary-find-prev))
7464 (gnus-set-mode-line 'summary)
7465 ;; We return how many articles were removed from the summary
7466 ;; buffer as a result of the new limit.
7467 (- total (length gnus-newsgroup-data))))
7469 (defsubst gnus-invisible-cut-children (threads)
7472 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7477 (defsubst gnus-cut-thread (thread)
7478 "Go forwards in the thread until we find an article that we want to display."
7479 (when (or (eq gnus-fetch-old-headers 'some)
7480 (eq gnus-fetch-old-headers 'invisible)
7481 (numberp gnus-fetch-old-headers)
7482 (eq gnus-build-sparse-threads 'some)
7483 (eq gnus-build-sparse-threads 'more))
7484 ;; Deal with old-fetched headers and sparse threads.
7488 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7489 (gnus-summary-article-ancient-p
7490 (mail-header-number (car thread))))
7491 (if (or (<= (length (cdr thread)) 1)
7492 (eq gnus-fetch-old-headers 'invisible))
7493 (setq gnus-newsgroup-limit
7494 (delq (mail-header-number (car thread))
7495 gnus-newsgroup-limit)
7496 thread (cadr thread))
7497 (when (gnus-invisible-cut-children (cdr thread))
7498 (let ((th (cdr thread)))
7500 (if (memq (mail-header-number (caar th))
7501 gnus-newsgroup-limit)
7502 (setq thread (car th)
7504 (setq th (cdr th))))))))))
7507 (defun gnus-cut-threads (threads)
7508 "Cut off all uninteresting articles from the beginning of threads."
7509 (when (or (eq gnus-fetch-old-headers 'some)
7510 (eq gnus-fetch-old-headers 'invisible)
7511 (numberp gnus-fetch-old-headers)
7512 (eq gnus-build-sparse-threads 'some)
7513 (eq gnus-build-sparse-threads 'more))
7516 (setcar th (gnus-cut-thread (car th)))
7517 (setq th (cdr th)))))
7518 ;; Remove nixed out threads.
7521 (defun gnus-summary-initial-limit (&optional show-if-empty)
7522 "Figure out what the initial limit is supposed to be on group entry.
7523 This entails weeding out unwanted dormants, low-scored articles,
7524 fetch-old-headers verbiage, and so on."
7525 ;; Most groups have nothing to remove.
7526 (if (or gnus-inhibit-limiting
7527 (and (null gnus-newsgroup-dormant)
7528 (eq gnus-newsgroup-display 'gnus-not-ignore)
7529 (not (eq gnus-fetch-old-headers 'some))
7530 (not (numberp gnus-fetch-old-headers))
7531 (not (eq gnus-fetch-old-headers 'invisible))
7532 (null gnus-summary-expunge-below)
7533 (not (eq gnus-build-sparse-threads 'some))
7534 (not (eq gnus-build-sparse-threads 'more))
7535 (null gnus-thread-expunge-below)
7536 (not gnus-use-nocem)))
7538 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7539 (setq gnus-newsgroup-limit nil)
7542 (unless (car (symbol-value node))
7543 ;; These threads have no parents -- they are roots.
7544 (let ((nodes (cdr (symbol-value node)))
7547 (if (and gnus-thread-expunge-below
7548 (< (gnus-thread-total-score (car nodes))
7549 gnus-thread-expunge-below))
7550 (gnus-expunge-thread (pop nodes))
7551 (setq thread (pop nodes))
7552 (gnus-summary-limit-children thread))))))
7553 gnus-newsgroup-dependencies)
7554 ;; If this limitation resulted in an empty group, we might
7555 ;; pop the previous limit and use it instead.
7556 (when (and (not gnus-newsgroup-limit)
7558 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7559 gnus-newsgroup-limit))
7561 (defun gnus-summary-limit-children (thread)
7562 "Return 1 if this subthread is visible and 0 if it is not."
7563 ;; First we get the number of visible children to this thread. This
7564 ;; is done by recursing down the thread using this function, so this
7565 ;; will really go down to a leaf article first, before slowly
7566 ;; working its way up towards the root.
7570 (apply '+ (mapcar 'gnus-summary-limit-children
7573 (number (mail-header-number (car thread)))
7576 (not (memq number gnus-newsgroup-marked))
7578 ;; If this article is dormant and has absolutely no visible
7579 ;; children, then this article isn't visible.
7580 (and (memq number gnus-newsgroup-dormant)
7582 ;; If this is "fetch-old-headered" and there is no
7583 ;; visible children, then we don't want this article.
7584 (and (or (eq gnus-fetch-old-headers 'some)
7585 (numberp gnus-fetch-old-headers))
7586 (gnus-summary-article-ancient-p number)
7588 ;; If this is "fetch-old-headered" and `invisible', then
7589 ;; we don't want this article.
7590 (and (eq gnus-fetch-old-headers 'invisible)
7591 (gnus-summary-article-ancient-p number))
7592 ;; If this is a sparsely inserted article with no children,
7593 ;; we don't want it.
7594 (and (eq gnus-build-sparse-threads 'some)
7595 (gnus-summary-article-sparse-p number)
7597 ;; If we use expunging, and this article is really
7598 ;; low-scored, then we don't want this article.
7599 (when (and gnus-summary-expunge-below
7601 (or (cdr (assq number gnus-newsgroup-scored))
7602 gnus-summary-default-score))
7603 gnus-summary-expunge-below))
7604 ;; We increase the expunge-tally here, but that has
7605 ;; nothing to do with the limits, really.
7606 (incf gnus-newsgroup-expunged-tally)
7607 ;; We also mark as read here, if that's wanted.
7608 (when (and gnus-summary-mark-below
7609 (< score gnus-summary-mark-below))
7610 (setq gnus-newsgroup-unreads
7611 (delq number gnus-newsgroup-unreads))
7612 (if gnus-newsgroup-auto-expire
7613 (push number gnus-newsgroup-expirable)
7614 (push (cons number gnus-low-score-mark)
7615 gnus-newsgroup-reads)))
7617 ;; Do the `display' group parameter.
7618 (and gnus-newsgroup-display
7619 (not (funcall gnus-newsgroup-display)))
7620 ;; Check NoCeM things.
7621 (if (and gnus-use-nocem
7622 (gnus-nocem-unwanted-article-p
7623 (mail-header-id (car thread))))
7625 (setq gnus-newsgroup-unreads
7626 (delq number gnus-newsgroup-unreads))
7628 ;; Nope, invisible article.
7630 ;; Ok, this article is to be visible, so we add it to the limit
7632 (push number gnus-newsgroup-limit)
7635 (defun gnus-expunge-thread (thread)
7636 "Mark all articles in THREAD as read."
7637 (let* ((number (mail-header-number (car thread))))
7638 (incf gnus-newsgroup-expunged-tally)
7639 ;; We also mark as read here, if that's wanted.
7640 (setq gnus-newsgroup-unreads
7641 (delq number gnus-newsgroup-unreads))
7642 (if gnus-newsgroup-auto-expire
7643 (push number gnus-newsgroup-expirable)
7644 (push (cons number gnus-low-score-mark)
7645 gnus-newsgroup-reads)))
7646 ;; Go recursively through all subthreads.
7647 (mapcar 'gnus-expunge-thread (cdr thread)))
7649 ;; Summary article oriented commands
7651 (defun gnus-summary-refer-parent-article (n)
7652 "Refer parent article N times.
7653 If N is negative, go to ancestor -N instead.
7654 The difference between N and the number of articles fetched is returned."
7658 (when (not (natnump n))
7663 (setq header (gnus-summary-article-header))
7664 (if (and (eq (mail-header-number header)
7665 (cdr gnus-article-current))
7666 (equal gnus-newsgroup-name
7667 (car gnus-article-current)))
7668 ;; If we try to find the parent of the currently
7669 ;; displayed article, then we take a look at the actual
7670 ;; References header, since this is slightly more
7671 ;; reliable than the References field we got from the
7674 (set-buffer gnus-original-article-buffer)
7675 (nnheader-narrow-to-headers)
7676 (unless (setq ref (message-fetch-field "references"))
7677 (setq ref (message-fetch-field "in-reply-to")))
7680 ;; It's not the current article, so we take a bet on
7681 ;; the value we got from the server.
7682 (mail-header-references header)))
7684 (not (equal ref "")))
7685 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7686 (gnus-message 1 "Couldn't find parent"))
7687 (gnus-message 1 "No references in article %d"
7688 (gnus-summary-article-number))
7691 (gnus-summary-position-point)
7694 (defun gnus-summary-refer-references ()
7695 "Fetch all articles mentioned in the References header.
7696 Return the number of articles fetched."
7698 (let ((ref (mail-header-references (gnus-summary-article-header)))
7699 (current (gnus-summary-article-number))
7703 (error "No References in the current article")
7704 ;; For each Message-ID in the References header...
7705 (while (string-match "<[^>]*>" ref)
7707 ;; ... fetch that article.
7708 (gnus-summary-refer-article
7709 (prog1 (match-string 0 ref)
7710 (setq ref (substring ref (match-end 0))))))
7711 (gnus-summary-goto-subject current)
7712 (gnus-summary-position-point)
7715 (defun gnus-summary-refer-thread (&optional limit)
7716 "Fetch all articles in the current thread.
7717 If LIMIT (the numerical prefix), fetch that many old headers instead
7718 of what's specified by the `gnus-refer-thread-limit' variable."
7720 (let ((id (mail-header-id (gnus-summary-article-header)))
7721 (limit (if limit (prefix-numeric-value limit)
7722 gnus-refer-thread-limit)))
7723 ;; We want to fetch LIMIT *old* headers, but we also have to
7724 ;; re-fetch all the headers in the current buffer, because many of
7725 ;; them may be undisplayed. So we adjust LIMIT.
7726 (when (numberp limit)
7727 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7728 (unless (eq gnus-fetch-old-headers 'invisible)
7729 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7730 ;; Retrieve the headers and read them in.
7731 (if (eq (gnus-retrieve-headers
7732 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7734 (gnus-build-all-threads)
7735 (error "Can't fetch thread from backends that don't support NOV"))
7736 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7737 (gnus-summary-limit-include-thread id)))
7739 (defun gnus-summary-refer-article (message-id)
7740 "Fetch an article specified by MESSAGE-ID."
7741 (interactive "sMessage-ID: ")
7742 (when (and (stringp message-id)
7743 (not (zerop (length message-id))))
7744 ;; Construct the correct Message-ID if necessary.
7745 ;; Suggested by tale@pawl.rpi.edu.
7746 (unless (string-match "^<" message-id)
7747 (setq message-id (concat "<" message-id)))
7748 (unless (string-match ">$" message-id)
7749 (setq message-id (concat message-id ">")))
7750 (let* ((header (gnus-id-to-header message-id))
7752 (gnus-summary-article-sparse-p
7753 (mail-header-number header))
7754 (memq (mail-header-number header)
7755 gnus-newsgroup-limit)))
7758 ;; If the article is present in the buffer we just go to it.
7760 (or (not (gnus-summary-article-sparse-p
7761 (mail-header-number header)))
7764 (gnus-summary-goto-article
7765 (mail-header-number header) nil t)
7767 (gnus-summary-update-article (mail-header-number header)))))
7769 ;; We fetch the article.
7771 (dolist (gnus-override-method (gnus-refer-article-methods))
7772 (gnus-check-server gnus-override-method)
7773 ;; Fetch the header, and display the article.
7774 (when (setq number (gnus-summary-insert-subject message-id))
7775 (gnus-summary-select-article nil nil nil number)
7777 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7779 (defun gnus-refer-article-methods ()
7780 "Return a list of referrable methods."
7782 ;; No method, so we default to current and native.
7783 ((null gnus-refer-article-method)
7784 (list gnus-current-select-method gnus-select-method))
7786 ((eq 'current gnus-refer-article-method)
7787 (list gnus-current-select-method))
7788 ;; List of select methods.
7789 ((not (and (symbolp (car gnus-refer-article-method))
7790 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7792 (dolist (method gnus-refer-article-method)
7793 (push (if (eq 'current method)
7794 gnus-current-select-method
7798 ;; One single select method.
7800 (list gnus-refer-article-method))))
7802 (defun gnus-summary-edit-parameters ()
7803 "Edit the group parameters of the current group."
7805 (gnus-group-edit-group gnus-newsgroup-name 'params))
7807 (defun gnus-summary-customize-parameters ()
7808 "Customize the group parameters of the current group."
7810 (gnus-group-customize gnus-newsgroup-name))
7812 (defun gnus-summary-enter-digest-group (&optional force)
7813 "Enter an nndoc group based on the current article.
7814 If FORCE, force a digest interpretation. If not, try
7815 to guess what the document format is."
7817 (let ((conf gnus-current-window-configuration))
7819 (gnus-summary-select-article))
7820 (setq gnus-current-window-configuration conf)
7821 (let* ((name (format "%s-%d"
7822 (gnus-group-prefixed-name
7823 gnus-newsgroup-name (list 'nndoc ""))
7825 (set-buffer gnus-summary-buffer)
7826 gnus-current-article)))
7827 (ogroup gnus-newsgroup-name)
7828 (params (append (gnus-info-params (gnus-get-info ogroup))
7829 (list (cons 'to-group ogroup))
7830 (list (cons 'save-article-group ogroup))))
7831 (case-fold-search t)
7832 (buf (current-buffer))
7835 (set-buffer gnus-original-article-buffer)
7836 ;; Have the digest group inherit the main mail address of
7837 ;; the parent article.
7838 (when (setq to-address (or (message-fetch-field "reply-to")
7839 (message-fetch-field "from")))
7840 (setq params (append
7841 (list (cons 'to-address
7842 (funcall gnus-decode-encoded-word-function
7844 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7845 (insert-buffer-substring gnus-original-article-buffer)
7846 ;; Remove lines that may lead nndoc to misinterpret the
7849 (goto-char (point-min))
7850 (or (search-forward "\n\n" nil t) (point)))
7851 (goto-char (point-min))
7852 (delete-matching-lines "^Path:\\|^From ")
7855 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7856 (gnus-newsgroup-ephemeral-ignored-charsets
7857 gnus-newsgroup-ignored-charsets))
7858 (gnus-group-read-ephemeral-group
7859 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7861 ,(if force 'mbox 'guess)))
7863 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7865 ;; Make all postings to this group go to the parent group.
7866 (nconc (gnus-info-params (gnus-get-info name))
7868 ;; Couldn't select this doc group.
7869 (switch-to-buffer buf)
7870 (gnus-set-global-variables)
7871 (gnus-configure-windows 'summary)
7872 (gnus-message 3 "Article couldn't be entered?"))
7873 (kill-buffer dig)))))
7875 (defun gnus-summary-read-document (n)
7876 "Open a new group based on the current article(s).
7877 This will allow you to read digests and other similar
7878 documents as newsgroups.
7879 Obeys the standard process/prefix convention."
7881 (let* ((articles (gnus-summary-work-articles n))
7882 (ogroup gnus-newsgroup-name)
7883 (params (append (gnus-info-params (gnus-get-info ogroup))
7884 (list (cons 'to-group ogroup))))
7885 article group egroup groups vgroup)
7886 (while (setq article (pop articles))
7887 (setq group (format "%s-%d" gnus-newsgroup-name article))
7888 (gnus-summary-remove-process-mark article)
7889 (when (gnus-summary-display-article article)
7892 (insert-buffer-substring gnus-original-article-buffer)
7893 ;; Remove some headers that may lead nndoc to make
7895 (message-narrow-to-head)
7896 (goto-char (point-min))
7897 (delete-matching-lines "^\\(Path\\):\\|^From ")
7900 (gnus-group-read-ephemeral-group
7901 group `(nndoc ,group (nndoc-address ,(current-buffer))
7902 (nndoc-article-type guess))
7905 ;; Make all postings to this group go to the parent group.
7906 (nconc (gnus-info-params (gnus-get-info egroup))
7908 (push egroup groups))
7909 ;; Couldn't select this doc group.
7910 (gnus-error 3 "Article couldn't be entered"))))))
7911 ;; Now we have selected all the documents.
7914 (error "None of the articles could be interpreted as documents"))
7915 ((gnus-group-read-ephemeral-group
7916 (setq vgroup (format
7917 "nnvirtual:%s-%s" gnus-newsgroup-name
7918 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7919 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7921 (cons (current-buffer) 'summary)))
7923 (error "Couldn't select virtual nndoc group")))))
7925 (defun gnus-summary-isearch-article (&optional regexp-p)
7926 "Do incremental search forward on the current article.
7927 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7929 (let* ((gnus-inhibit-treatment t)
7930 (old (gnus-summary-select-article)))
7931 (gnus-configure-windows 'article)
7932 (gnus-eval-in-buffer-window gnus-article-buffer
7936 (gnus-article-show-all-headers))
7937 (goto-char (point-min))
7938 (isearch-forward regexp-p)))))
7940 (defun gnus-summary-search-article-forward (regexp &optional backward)
7941 "Search for an article containing REGEXP forward.
7942 If BACKWARD, search backward instead."
7945 (format "Search article %s (regexp%s): "
7946 (if current-prefix-arg "backward" "forward")
7947 (if gnus-last-search-regexp
7948 (concat ", default " gnus-last-search-regexp)
7950 current-prefix-arg))
7951 (if (string-equal regexp "")
7952 (setq regexp (or gnus-last-search-regexp ""))
7953 (setq gnus-last-search-regexp regexp)
7954 (setq gnus-article-before-search gnus-current-article))
7955 ;; Intentionally set gnus-last-article.
7956 (setq gnus-last-article gnus-article-before-search)
7957 (let ((gnus-last-article gnus-last-article))
7958 (if (gnus-summary-search-article regexp backward)
7959 (gnus-summary-show-thread)
7960 (error "Search failed: \"%s\"" regexp))))
7962 (defun gnus-summary-search-article-backward (regexp)
7963 "Search for an article containing REGEXP backward."
7966 (format "Search article backward (regexp%s): "
7967 (if gnus-last-search-regexp
7968 (concat ", default " gnus-last-search-regexp)
7970 (gnus-summary-search-article-forward regexp 'backward))
7973 (defmacro gnus-summary-search-article-position-point (regexp backward)
7974 "Dehighlight the last matched text and goto the beginning position."
7975 (` (if (and gnus-summary-search-article-matched-data
7976 (let ((text (caddr gnus-summary-search-article-matched-data))
7977 (inhibit-read-only t)
7980 (goto-char (car gnus-summary-search-article-matched-data))
7981 (cadr gnus-summary-search-article-matched-data))
7983 (string-match (, regexp) text)))
7984 (if (, backward) (beginning-of-line) (end-of-line))
7985 (goto-char (if (, backward) (point-max) (point-min))))))
7987 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7988 "Place point where X-Face image is displayed."
7989 (if (featurep 'xemacs)
7990 (` (let ((end (if (search-forward "\n\n" nil t)
7991 (goto-char (1- (point)))
7994 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7995 (unless (and (re-search-forward "^From:" end t)
7996 (setq extent (extent-at (point)))
7997 (extent-begin-glyph extent))
7998 (goto-char (, opoint)))))
7999 (` (let ((end (if (search-forward "\n\n" nil t)
8000 (goto-char (1- (point)))
8002 (start (or (search-backward "\n\n" nil t) (point-min))))
8004 (or (text-property-any start end 'x-face-image t);; x-face-e21
8005 (text-property-any start end 'x-face-mule-bitmap-image t)
8008 (defmacro gnus-summary-search-article-highlight-matched-text
8009 (backward treated x-face)
8010 "Highlight matched text in the function `gnus-summary-search-article'."
8011 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8012 (end (set-marker (make-marker) (match-end 0)))
8013 (inhibit-read-only t)
8017 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8019 (lambda (item) (setq items (delq item items)))
8020 '(gnus-treat-buttonize
8021 gnus-treat-fill-article
8022 gnus-treat-fill-long-lines
8023 gnus-treat-emphasize
8024 gnus-treat-highlight-headers
8025 gnus-treat-highlight-citation
8026 gnus-treat-highlight-signature
8027 gnus-treat-overstrike
8028 gnus-treat-display-xface
8029 gnus-treat-buttonize-head
8030 gnus-treat-decode-article-as-default-mime-charset))
8031 (static-if (featurep 'xemacs)
8033 (cons '(x-face-mule-delete-x-face-field
8036 (gnus-treat-display-xface
8037 (when (, x-face) gnus-treat-display-xface)))
8038 (gnus-article-prepare-mime-display)))
8039 (goto-char (if (, backward) start end))
8041 (gnus-summary-search-article-highlight-goto-x-face (point)))
8042 (setq gnus-summary-search-article-matched-data
8043 (list start end (buffer-substring start end)))
8044 (unless (eq start end);; matched text has been deleted. :-<
8045 (put-text-property start end 'face
8046 (or (find-face 'isearch)
8047 'secondary-selection))))))
8050 (defun gnus-summary-search-article (regexp &optional backward)
8051 "Search for an article containing REGEXP.
8052 Optional argument BACKWARD means do search for backward.
8053 `gnus-select-article-hook' is not called during the search."
8054 ;; We have to require this here to make sure that the following
8055 ;; dynamic binding isn't shadowed by autoloading.
8056 (require 'gnus-async)
8058 (let ((gnus-select-article-hook nil) ;Disable hook.
8059 (gnus-article-prepare-hook nil)
8060 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8061 (gnus-use-article-prefetch nil)
8062 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8063 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8064 (sum (current-buffer))
8067 (gnus-save-hidden-threads
8068 (static-if (featurep 'xemacs)
8069 (let ((gnus-inhibit-treatment t))
8070 (setq treated (eq 'old (gnus-summary-select-article)))
8072 (not (and (gnus-buffer-live-p gnus-article-buffer)
8073 (window-live-p (get-buffer-window
8074 gnus-article-buffer t)))))
8075 (gnus-summary-select-article nil t)
8076 (setq treated nil)))
8077 (let ((gnus-inhibit-treatment t)
8078 (x-face-mule-delete-x-face-field 'never))
8079 (setq treated (eq 'old (gnus-summary-select-article)))
8082 (and (gnus-buffer-live-p gnus-article-buffer)
8083 (window-live-p (get-buffer-window
8084 gnus-article-buffer t))
8085 (or (not (string-match "^\\^X-Face:" regexp))
8086 (with-current-buffer gnus-article-buffer
8087 gnus-summary-search-article-matched-data)))))
8088 (gnus-summary-select-article nil t)
8089 (setq treated nil))))
8090 (set-buffer gnus-article-buffer)
8094 (gnus-article-show-all-headers)
8095 (gnus-summary-search-article-position-point regexp backward))
8096 (goto-char (if backward (point-max) (point-min))))
8098 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8100 (re-search-backward regexp nil t)
8101 (re-search-forward regexp nil t))
8102 ;; We found the regexp.
8104 (gnus-summary-search-article-highlight-matched-text
8105 backward treated (string-match "^\\^X-Face:" regexp))
8108 (/ (- 2 (window-height
8109 (get-buffer-window gnus-article-buffer t)))
8112 (get-buffer-window (current-buffer))
8115 (setq point (point)))
8116 ;; We didn't find it, so we go to the next article.
8119 (while (eq found 'not)
8120 (if (not (if backward (gnus-summary-find-prev)
8121 (gnus-summary-find-next)))
8122 ;; No more articles.
8124 ;; Select the next article and adjust point.
8125 (unless (gnus-summary-article-sparse-p
8126 (gnus-summary-article-number))
8128 (let ((gnus-inhibit-treatment t))
8129 (gnus-summary-select-article))
8131 (set-buffer gnus-article-buffer)
8133 (goto-char (if backward (point-max) (point-min))))))))
8134 (gnus-message 7 ""))
8135 ;; Return whether we found the regexp.
8136 (when (eq found 'found)
8138 (gnus-summary-show-thread)
8139 (gnus-summary-goto-subject gnus-current-article)
8140 (gnus-summary-position-point)
8143 (defun gnus-find-matching-articles (header regexp)
8144 "Return a list of all articles that match REGEXP on HEADER.
8145 This search includes all articles in the current group that Gnus has
8146 fetched headers for, whether they are displayed or not."
8147 (let ((articles nil)
8148 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8149 (case-fold-search t))
8150 (dolist (header gnus-newsgroup-headers)
8151 (when (string-match regexp (funcall func header))
8152 (push (mail-header-number header) articles)))
8153 (nreverse articles)))
8155 (defun gnus-summary-find-matching (header regexp &optional backward unread
8156 not-case-fold not-matching)
8157 "Return a list of all articles that match REGEXP on HEADER.
8158 The search stars on the current article and goes forwards unless
8159 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8160 If UNREAD is non-nil, only unread articles will
8161 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8162 in the comparisons. If NOT-MATCHING, return a list of all articles that
8163 not match REGEXP on HEADER."
8164 (let ((case-fold-search (not not-case-fold))
8167 (if (eq (car header) 'extra)
8170 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8172 (error "%s is an invalid header" header))
8173 (unless (fboundp (intern (concat "mail-header-" header)))
8174 (error "%s is not a valid header" header))
8175 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8176 (dolist (d (if (eq backward 'all)
8178 (gnus-data-find-list
8179 (gnus-summary-article-number)
8180 (gnus-data-list backward))))
8181 (when (and (or (not unread) ; We want all articles...
8182 (gnus-data-unread-p d)) ; Or just unreads.
8183 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8187 (funcall func (gnus-data-header d))))
8188 (string-match regexp
8189 (funcall func (gnus-data-header d)))))
8190 (push (gnus-data-number d) articles))) ; Success!
8191 (nreverse articles)))
8193 (defun gnus-summary-execute-command (header regexp command &optional backward)
8194 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8195 If HEADER is an empty string (or nil), the match is done on the entire
8196 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8198 (list (let ((completion-ignore-case t))
8201 (mapcar (lambda (header) (list (format "%s" header)))
8203 '("Number" "Subject" "From" "Lines" "Date"
8204 "Message-ID" "Xref" "References" "Body")
8205 gnus-extra-headers))
8206 nil 'require-match))
8207 (read-string "Regexp: ")
8208 (read-key-sequence "Command: ")
8209 current-prefix-arg))
8210 (when (equal header "Body")
8212 ;; Hidden thread subtrees must be searched as well.
8213 (gnus-summary-show-all-threads)
8214 ;; We don't want to change current point nor window configuration.
8216 (save-window-excursion
8217 (gnus-message 6 "Executing %s..." (key-description command))
8218 ;; We'd like to execute COMMAND interactively so as to give arguments.
8219 (gnus-execute header regexp
8220 `(call-interactively ',(key-binding command))
8222 (gnus-message 6 "Executing %s...done" (key-description command)))))
8224 (defun gnus-summary-beginning-of-article ()
8225 "Scroll the article back to the beginning."
8227 (gnus-summary-select-article)
8228 (gnus-configure-windows 'article)
8229 (gnus-eval-in-buffer-window gnus-article-buffer
8231 (goto-char (point-min))
8232 (when gnus-page-broken
8233 (gnus-narrow-to-page))))
8235 (defun gnus-summary-end-of-article ()
8236 "Scroll to the end of the article."
8238 (gnus-summary-select-article)
8239 (gnus-configure-windows 'article)
8240 (gnus-eval-in-buffer-window gnus-article-buffer
8242 (goto-char (point-max))
8244 (when gnus-page-broken
8245 (gnus-narrow-to-page))))
8247 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8248 "Truncate to LEN and quote all \"(\"'s in STRING."
8249 (gnus-replace-in-string (if (and len (> (length string) len))
8250 (substring string 0 len)
8254 (defun gnus-summary-print-article (&optional filename n)
8255 "Generate and print a PostScript image of the N next (mail) articles.
8257 If N is negative, print the N previous articles. If N is nil and articles
8258 have been marked with the process mark, print these instead.
8260 If the optional first argument FILENAME is nil, send the image to the
8261 printer. If FILENAME is a string, save the PostScript image in a file with
8262 that name. If FILENAME is a number, prompt the user for the name of the file
8264 (interactive (list (ps-print-preprint current-prefix-arg)))
8265 (dolist (article (gnus-summary-work-articles n))
8266 (gnus-summary-select-article nil nil 'pseudo article)
8267 (gnus-eval-in-buffer-window gnus-article-buffer
8268 (gnus-print-buffer))
8269 (gnus-summary-remove-process-mark article))
8270 (ps-despool filename))
8272 (defun gnus-print-buffer ()
8273 (let ((buffer (generate-new-buffer " *print*")))
8276 (copy-to-buffer buffer (point-min) (point-max))
8278 (gnus-article-delete-invisible-text)
8279 (gnus-remove-text-with-property 'gnus-decoration)
8280 (when (gnus-visual-p 'article-highlight 'highlight)
8281 ;; Copy-to-buffer doesn't copy overlay. So redo
8283 (let ((gnus-article-buffer buffer))
8284 (gnus-article-highlight-citation t)
8285 (gnus-article-highlight-signature)))
8286 (let ((ps-left-header
8289 (gnus-summary-print-truncate-and-quote
8290 (mail-header-subject gnus-current-headers)
8293 (gnus-summary-print-truncate-and-quote
8294 (mail-header-from gnus-current-headers)
8298 "/pagenumberstring load"
8300 (mail-header-date gnus-current-headers) ")"))))
8301 (gnus-run-hooks 'gnus-ps-print-hook)
8304 (ps-spool-buffer-with-faces)
8305 (ps-spool-buffer)))))
8306 (kill-buffer buffer))))
8308 (defun gnus-summary-show-article (&optional arg)
8309 "Force redisplaying of the current article.
8310 If ARG (the prefix) is a number, show the article with the charset
8311 defined in `gnus-summary-show-article-charset-alist', or the charset
8313 If ARG (the prefix) is non-nil and not a number, show the raw article
8314 without any article massaging functions being run. Normally, the key strokes
8319 (gnus-summary-show-article t)
8320 (let* ((gnus-newsgroup-charset
8321 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8322 (mm-read-coding-system
8323 "View as charset: " ;; actually it is coding system.
8325 (set-buffer gnus-article-buffer)
8326 (mm-detect-coding-region (point) (point-max))))))
8327 (default-mime-charset gnus-newsgroup-charset)
8328 (gnus-newsgroup-ignored-charsets 'gnus-all))
8329 (gnus-summary-select-article nil 'force)
8330 (let ((deps gnus-newsgroup-dependencies)
8333 (set-buffer gnus-original-article-buffer)
8335 (message-narrow-to-head)
8336 (setq head (buffer-string))
8337 (goto-char (point-min))
8338 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8339 (goto-char (point-max))
8341 (setq lines (1- (count-lines (point) (point-max))))))
8343 (insert (format "211 %d Article retrieved.\n"
8344 (cdr gnus-article-current)))
8346 (if lines (insert (format "Lines: %d\n" lines)))
8348 (let ((nntp-server-buffer (current-buffer)))
8349 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8350 (gnus-data-set-header
8351 (gnus-data-find (cdr gnus-article-current))
8353 (gnus-summary-update-article-line
8354 (cdr gnus-article-current) header)
8355 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8356 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8358 ;; Select the article the normal way.
8359 (gnus-summary-select-article nil 'force))
8361 ;; We have to require this here to make sure that the following
8362 ;; dynamic binding isn't shadowed by autoloading.
8363 (require 'gnus-async)
8365 ;; Bind the article treatment functions to nil.
8366 (let ((gnus-have-all-headers t)
8367 gnus-article-prepare-hook
8368 gnus-article-decode-hook
8371 (gnus-inhibit-treatment t))
8372 (gnus-summary-select-article nil 'force))))
8373 (gnus-summary-goto-subject gnus-current-article)
8374 (gnus-summary-position-point))
8376 (defun gnus-summary-show-raw-article ()
8377 "Show the raw article without any article massaging functions being run."
8379 (gnus-summary-show-article t))
8381 (defun gnus-summary-verbose-headers (&optional arg)
8382 "Toggle permanent full header display.
8383 If ARG is a positive number, turn header display on.
8384 If ARG is a negative number, turn header display off."
8386 (setq gnus-show-all-headers
8387 (cond ((or (not (numberp arg))
8389 (not gnus-show-all-headers))
8392 (gnus-summary-show-article))
8394 (defun gnus-summary-toggle-header (&optional arg)
8395 "Show the headers if they are hidden, or hide them if they are shown.
8396 If ARG is a positive number, show the entire header.
8397 If ARG is a negative number, hide the unwanted header lines."
8400 (set-buffer gnus-article-buffer)
8402 (let* ((buffer-read-only nil)
8403 (inhibit-point-motion-hooks t)
8406 (article-narrow-to-head)
8408 hidden (if (numberp arg)
8410 (gnus-article-hidden-text-p 'headers))))
8411 (delete-region (point-min) e)
8412 (goto-char (point-min))
8413 (with-current-buffer gnus-original-article-buffer
8414 (goto-char (setq s (point-min)))
8415 (setq e (search-forward "\n\n" nil t)
8416 e (if e (1- e) (point-max))))
8417 (insert-buffer-substring gnus-original-article-buffer s e)
8419 (narrow-to-region (point-min) (point))
8420 (article-decode-encoded-words)
8422 (let ((gnus-treat-hide-headers nil)
8423 (gnus-treat-hide-boring-headers nil))
8424 (gnus-delete-wash-type 'headers)
8425 (gnus-treat-article 'head))
8426 (gnus-treat-article 'head)))
8427 (gnus-set-mode-line 'article)))))
8429 (defun gnus-summary-show-all-headers ()
8430 "Make all header lines visible."
8432 (gnus-summary-toggle-header 1))
8434 (defun gnus-summary-toggle-mime (&optional arg)
8435 "Toggle MIME processing.
8436 If ARG is a positive number, turn MIME processing on."
8438 (setq gnus-show-mime
8440 (not gnus-show-mime)
8441 (> (prefix-numeric-value arg) 0)))
8442 (gnus-summary-select-article t 'force))
8444 (defun gnus-summary-caesar-message (&optional arg)
8445 "Caesar rotate the current article by 13.
8446 The numerical prefix specifies how many places to rotate each letter
8449 (gnus-summary-select-article)
8450 (let ((mail-header-separator ""))
8451 (gnus-eval-in-buffer-window gnus-article-buffer
8454 (let ((start (window-start))
8456 (message-caesar-buffer-body arg)
8457 (set-window-start (get-buffer-window (current-buffer)) start))))))
8459 (defun gnus-summary-stop-page-breaking ()
8460 "Stop page breaking in the current article."
8462 (gnus-summary-select-article)
8463 (gnus-eval-in-buffer-window gnus-article-buffer
8465 (when (gnus-visual-p 'page-marker)
8466 (let ((buffer-read-only nil))
8467 (gnus-remove-text-with-property 'gnus-prev)
8468 (gnus-remove-text-with-property 'gnus-next))
8469 (setq gnus-page-broken nil))))
8471 (defun gnus-summary-move-article (&optional n to-newsgroup
8472 select-method action)
8473 "Move the current article to a different newsgroup.
8474 If N is a positive number, move the N next articles.
8475 If N is a negative number, move the N previous articles.
8476 If N is nil and any articles have been marked with the process mark,
8477 move those articles instead.
8478 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8479 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8480 re-spool using this method.
8482 When called interactively with TO-NEWSGROUP being nil, the value of
8483 the variable `gnus-move-split-methods' is used for finding a default
8484 for the target newsgroup.
8486 For this function to work, both the current newsgroup and the
8487 newsgroup that you want to move to have to support the `request-move'
8488 and `request-accept' functions.
8490 ACTION can be either `move' (the default), `crosspost' or `copy'."
8493 (setq action 'move))
8494 ;; Check whether the source group supports the required functions.
8495 (cond ((and (eq action 'move)
8496 (not (gnus-check-backend-function
8497 'request-move-article gnus-newsgroup-name)))
8498 (error "The current group does not support article moving"))
8499 ((and (eq action 'crosspost)
8500 (not (gnus-check-backend-function
8501 'request-replace-article gnus-newsgroup-name)))
8502 (error "The current group does not support article editing")))
8503 (let ((articles (gnus-summary-work-articles n))
8504 (prefix (if (gnus-check-backend-function
8505 'request-move-article gnus-newsgroup-name)
8506 (gnus-group-real-prefix gnus-newsgroup-name)
8508 (names '((move "Move" "Moving")
8509 (copy "Copy" "Copying")
8510 (crosspost "Crosspost" "Crossposting")))
8511 (copy-buf (save-excursion
8512 (nnheader-set-temp-buffer " *copy article*")))
8513 (default-marks gnus-article-mark-lists)
8514 (no-expire-marks (delete '(expirable . expire)
8515 (copy-sequence gnus-article-mark-lists)))
8516 art-group to-method new-xref article to-groups)
8517 (unless (assq action names)
8518 (error "Unknown action %s" action))
8519 ;; Read the newsgroup name.
8520 (when (and (not to-newsgroup)
8521 (not select-method))
8522 (if (and gnus-move-split-methods
8524 (and (memq gnus-current-article articles)
8525 (gnus-buffer-live-p gnus-original-article-buffer))))
8526 ;; When `gnus-move-split-methods' is non-nil, we have to
8527 ;; select an article to give `gnus-read-move-group-name' an
8528 ;; opportunity to suggest an appropriate default. However,
8529 ;; we needn't render or mark the article.
8530 (let ((gnus-display-mime-function nil)
8531 (gnus-article-prepare-hook nil)
8532 (gnus-mark-article-hook nil))
8533 (gnus-summary-select-article nil nil nil (car articles))))
8535 (gnus-read-move-group-name
8536 (cadr (assq action names))
8537 (symbol-value (intern (format "gnus-current-%s-group" action)))
8539 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8540 (setq to-method (or select-method
8541 (gnus-server-to-method
8542 (gnus-group-method to-newsgroup))))
8543 ;; Check the method we are to move this article to...
8544 (unless (gnus-check-backend-function
8545 'request-accept-article (car to-method))
8546 (error "%s does not support article copying" (car to-method)))
8547 (unless (gnus-check-server to-method)
8548 (error "Can't open server %s" (car to-method)))
8549 (gnus-message 6 "%s to %s: %s..."
8550 (caddr (assq action names))
8551 (or (car select-method) to-newsgroup) articles)
8553 (setq article (pop articles))
8557 ;; Move the article.
8559 ;; Remove this article from future suppression.
8560 (gnus-dup-unsuppress-article article)
8561 (gnus-request-move-article
8562 article ; Article to move
8563 gnus-newsgroup-name ; From newsgroup
8564 (nth 1 (gnus-find-method-for-group
8565 gnus-newsgroup-name)) ; Server
8566 (list 'gnus-request-accept-article
8567 to-newsgroup (list 'quote select-method)
8568 (not articles) t) ; Accept form
8569 (not articles))) ; Only save nov last time
8570 ;; Copy the article.
8573 (set-buffer copy-buf)
8574 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8575 (gnus-request-accept-article
8576 to-newsgroup select-method (not articles) t))))
8577 ;; Crosspost the article.
8578 ((eq action 'crosspost)
8579 (let ((xref (message-tokenize-header
8580 (mail-header-xref (gnus-summary-article-header article))
8582 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8583 ":" (number-to-string article)))
8585 (setq xref (list (system-name))))
8588 (mapconcat 'identity
8589 (delete "Xref:" (delete new-xref xref))
8593 (set-buffer copy-buf)
8594 ;; First put the article in the destination group.
8595 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8596 (when (consp (setq art-group
8597 (gnus-request-accept-article
8598 to-newsgroup select-method (not articles))))
8599 (setq new-xref (concat new-xref " " (car art-group)
8601 (number-to-string (cdr art-group))))
8602 ;; Now we have the new Xrefs header, so we insert
8603 ;; it and replace the new article.
8604 (nnheader-replace-header "Xref" new-xref)
8605 (gnus-request-replace-article
8606 (cdr art-group) to-newsgroup (current-buffer))
8610 (gnus-message 1 "Couldn't %s article %s: %s"
8611 (cadr (assq action names)) article
8612 (nnheader-get-report (car to-method))))
8613 ((eq art-group 'junk)
8614 (when (eq action 'move)
8615 (gnus-summary-mark-article article gnus-canceled-mark)
8616 (gnus-message 4 "Deleted article %s" article)))
8618 (let* ((pto-group (gnus-group-prefixed-name
8619 (car art-group) to-method))
8621 (gnus-gethash pto-group gnus-newsrc-hashtb))
8622 (info (nth 2 entry))
8623 (to-group (gnus-info-group info))
8625 ;; Update the group that has been moved to.
8627 (memq action '(move copy)))
8628 (unless (member to-group to-groups)
8629 (push to-group to-groups))
8631 (unless (memq article gnus-newsgroup-unreads)
8632 (push 'read to-marks)
8634 info (gnus-add-to-range (gnus-info-read info)
8635 (list (cdr art-group)))))
8637 ;; See whether the article is to be put in the cache.
8638 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8641 (to-article (cdr art-group)))
8643 ;; Enter the article into the cache in the new group,
8644 ;; if that is required.
8645 (when gnus-use-cache
8646 (gnus-cache-possibly-enter-article
8648 (let ((header (copy-sequence
8649 (gnus-summary-article-header article))))
8650 (mail-header-set-number header to-article)
8652 (memq article gnus-newsgroup-marked)
8653 (memq article gnus-newsgroup-dormant)
8654 (memq article gnus-newsgroup-unreads)))
8656 (when gnus-preserve-marks
8657 ;; Copy any marks over to the new group.
8658 (when (and (equal to-group gnus-newsgroup-name)
8659 (not (memq article gnus-newsgroup-unreads)))
8660 ;; Mark this article as read in this group.
8661 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8662 (setcdr (gnus-active to-group) to-article)
8663 (setcdr gnus-newsgroup-active to-article))
8666 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8667 (when (memq article (symbol-value
8668 (intern (format "gnus-newsgroup-%s"
8670 (push (cdar marks) to-marks)
8671 ;; If the other group is the same as this group,
8672 ;; then we have to add the mark to the list.
8673 (when (equal to-group gnus-newsgroup-name)
8674 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8677 (intern (format "gnus-newsgroup-%s"
8679 ;; Copy the marks to other group.
8680 (gnus-add-marked-articles
8681 to-group (cdar marks) (list to-article) info)))
8682 (setq marks (cdr marks)))
8684 (gnus-request-set-mark to-group (list (list (list to-article)
8689 (concat "(gnus-group-set-info '"
8690 (gnus-prin1-to-string (gnus-get-info to-group))
8693 ;; Update the Xref header in this article to point to
8694 ;; the new crossposted article we have just created.
8695 (when (eq action 'crosspost)
8697 (set-buffer copy-buf)
8698 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8699 (nnheader-replace-header "Xref" new-xref)
8700 (gnus-request-replace-article
8701 article gnus-newsgroup-name (current-buffer)))))
8703 ;;;!!!Why is this necessary?
8704 (set-buffer gnus-summary-buffer)
8706 (gnus-summary-goto-subject article)
8707 (when (eq action 'move)
8708 (gnus-summary-mark-article article gnus-canceled-mark))))
8709 (gnus-summary-remove-process-mark article))
8710 ;; Re-activate all groups that have been moved to.
8712 (set-buffer gnus-group-buffer)
8713 (let ((gnus-group-marked to-groups))
8714 (gnus-group-get-new-news-this-group nil t)))
8716 (gnus-kill-buffer copy-buf)
8717 (gnus-summary-position-point)
8718 (gnus-set-mode-line 'summary)))
8720 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8721 "Move the current article to a different newsgroup.
8722 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8723 When called interactively, if TO-NEWSGROUP is nil, use the value of
8724 the variable `gnus-move-split-methods' for finding a default target
8726 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8727 re-spool using this method."
8729 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8731 (defun gnus-summary-crosspost-article (&optional n)
8732 "Crosspost the current article to some other group."
8734 (gnus-summary-move-article n nil nil 'crosspost))
8736 (defcustom gnus-summary-respool-default-method nil
8737 "Default method type for respooling an article.
8738 If nil, use to the current newsgroup method."
8740 :group 'gnus-summary-mail)
8742 (defun gnus-summary-respool-article (&optional n method)
8743 "Respool the current article.
8744 The article will be squeezed through the mail spooling process again,
8745 which means that it will be put in some mail newsgroup or other
8746 depending on `nnmail-split-methods'.
8747 If N is a positive number, respool the N next articles.
8748 If N is a negative number, respool the N previous articles.
8749 If N is nil and any articles have been marked with the process mark,
8750 respool those articles instead.
8752 Respooling can be done both from mail groups and \"real\" newsgroups.
8753 In the former case, the articles in question will be moved from the
8754 current group into whatever groups they are destined to. In the
8755 latter case, they will be copied into the relevant groups."
8757 (list current-prefix-arg
8758 (let* ((methods (gnus-methods-using 'respool))
8760 (symbol-name (or gnus-summary-respool-default-method
8761 (car (gnus-find-method-for-group
8762 gnus-newsgroup-name)))))
8764 (gnus-completing-read-with-default
8765 methname "What backend do you want to use when respooling?"
8766 methods nil t nil 'gnus-mail-method-history))
8769 ((zerop (length (setq ms (gnus-servers-using-backend
8771 (list (intern method) ""))
8775 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8776 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8779 (error "No method given for respooling"))
8780 (if (assoc (symbol-name
8781 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8782 (gnus-methods-using 'respool))
8783 (gnus-summary-move-article n nil method)
8784 (gnus-summary-copy-article n nil method)))
8786 (defun gnus-summary-import-article (file &optional edit)
8787 "Import an arbitrary file into a mail newsgroup."
8788 (interactive "fImport file: \nP")
8789 (let ((group gnus-newsgroup-name)
8790 (now (current-time))
8791 atts lines group-art)
8792 (unless (gnus-check-backend-function 'request-accept-article group)
8793 (error "%s does not support article importing" group))
8794 (or (file-readable-p file)
8795 (not (file-regular-p file))
8796 (error "Can't read %s" file))
8798 (set-buffer (gnus-get-buffer-create " *import file*"))
8800 (nnheader-insert-file-contents file)
8801 (goto-char (point-min))
8802 (if (nnheader-article-p)
8804 (goto-char (point-min))
8805 (search-forward "\n\n" nil t)
8806 (narrow-to-region (point-min) (1- (point)))
8807 (goto-char (point-min))
8808 (unless (re-search-forward "^date:" nil t)
8809 (goto-char (point-max))
8810 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8811 ;; This doesn't look like an article, so we fudge some headers.
8812 (setq atts (file-attributes file)
8813 lines (count-lines (point-min) (point-max)))
8814 (insert "From: " (read-string "From: ") "\n"
8815 "Subject: " (read-string "Subject: ") "\n"
8816 "Date: " (message-make-date (nth 5 atts)) "\n"
8817 "Message-ID: " (message-make-message-id) "\n"
8818 "Lines: " (int-to-string lines) "\n"
8819 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8820 (setq group-art (gnus-request-accept-article group nil t))
8821 (kill-buffer (current-buffer)))
8822 (setq gnus-newsgroup-active (gnus-activate-group group))
8824 (gnus-summary-goto-article (cdr group-art) nil t)
8826 (gnus-summary-edit-article))))
8828 (defun gnus-summary-create-article ()
8829 "Create an article in a mail newsgroup."
8831 (let ((group gnus-newsgroup-name)
8832 (now (current-time))
8834 (unless (gnus-check-backend-function 'request-accept-article group)
8835 (error "%s does not support article importing" group))
8837 (set-buffer (gnus-get-buffer-create " *import file*"))
8839 (goto-char (point-min))
8840 ;; This doesn't look like an article, so we fudge some headers.
8841 (insert "From: " (read-string "From: ") "\n"
8842 "Subject: " (read-string "Subject: ") "\n"
8843 "Date: " (message-make-date now) "\n"
8844 "Message-ID: " (message-make-message-id) "\n")
8845 (setq group-art (gnus-request-accept-article group nil t))
8846 (kill-buffer (current-buffer)))
8847 (setq gnus-newsgroup-active (gnus-activate-group group))
8849 (gnus-summary-goto-article (cdr group-art) nil t)
8850 (gnus-summary-edit-article)))
8852 (defun gnus-summary-article-posted-p ()
8853 "Say whether the current (mail) article is available from news as well.
8854 This will be the case if the article has both been mailed and posted."
8856 (let ((id (mail-header-references (gnus-summary-article-header)))
8857 (gnus-override-method (car (gnus-refer-article-methods))))
8858 (if (gnus-request-head id "")
8859 (gnus-message 2 "The current message was found on %s"
8860 gnus-override-method)
8861 (gnus-message 2 "The current message couldn't be found on %s"
8862 gnus-override-method)
8865 (defun gnus-summary-expire-articles (&optional now)
8866 "Expire all articles that are marked as expirable in the current group."
8868 (when (gnus-check-backend-function
8869 'request-expire-articles gnus-newsgroup-name)
8870 ;; This backend supports expiry.
8871 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8872 (expirable (if total
8874 ;; We need to update the info for
8875 ;; this group for `gnus-list-of-read-articles'
8876 ;; to give us the right answer.
8877 (gnus-run-hooks 'gnus-exit-group-hook)
8878 (gnus-summary-update-info)
8879 (gnus-list-of-read-articles gnus-newsgroup-name))
8880 (setq gnus-newsgroup-expirable
8881 (sort gnus-newsgroup-expirable '<))))
8882 (expiry-wait (if now 'immediate
8883 (gnus-group-find-parameter
8884 gnus-newsgroup-name 'expiry-wait)))
8885 (nnmail-expiry-target
8886 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8887 nnmail-expiry-target))
8890 ;; There are expirable articles in this group, so we run them
8891 ;; through the expiry process.
8892 (gnus-message 6 "Expiring articles...")
8893 (unless (gnus-check-group gnus-newsgroup-name)
8894 (error "Can't open server for %s" gnus-newsgroup-name))
8895 ;; The list of articles that weren't expired is returned.
8898 (let ((nnmail-expiry-wait-function nil)
8899 (nnmail-expiry-wait expiry-wait))
8900 (setq es (gnus-request-expire-articles
8901 expirable gnus-newsgroup-name)))
8902 (setq es (gnus-request-expire-articles
8903 expirable gnus-newsgroup-name)))
8905 (setq gnus-newsgroup-expirable es))
8906 ;; We go through the old list of expirable, and mark all
8907 ;; really expired articles as nonexistent.
8908 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8909 (let ((gnus-use-cache nil))
8910 (dolist (article expirable)
8911 (when (and (not (memq article es))
8912 (gnus-data-find article))
8913 (gnus-summary-mark-article article gnus-canceled-mark))))))
8914 (gnus-message 6 "Expiring articles...done")))))
8916 (defun gnus-summary-expire-articles-now ()
8917 "Expunge all expirable articles in the current group.
8918 This means that *all* articles that are marked as expirable will be
8919 deleted forever, right now."
8921 (or gnus-expert-user
8923 "Are you really, really, really sure you want to delete all these messages? ")
8925 (gnus-summary-expire-articles t))
8927 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8928 (defun gnus-summary-delete-article (&optional n)
8929 "Delete the N next (mail) articles.
8930 This command actually deletes articles. This is not a marking
8931 command. The article will disappear forever from your life, never to
8933 If N is negative, delete backwards.
8934 If N is nil and articles have been marked with the process mark,
8935 delete these instead."
8937 (unless (gnus-check-backend-function 'request-expire-articles
8938 gnus-newsgroup-name)
8939 (error "The current newsgroup does not support article deletion"))
8940 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8941 (error "Couldn't open server"))
8942 ;; Compute the list of articles to delete.
8943 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8945 (if (and gnus-novice-user
8946 (not (gnus-yes-or-no-p
8947 (format "Do you really want to delete %s forever? "
8948 (if (> (length articles) 1)
8949 (format "these %s articles" (length articles))
8952 ;; Delete the articles.
8953 (setq not-deleted (gnus-request-expire-articles
8954 articles gnus-newsgroup-name 'force))
8956 (gnus-summary-remove-process-mark (car articles))
8957 ;; The backend might not have been able to delete the article
8959 (unless (memq (car articles) not-deleted)
8960 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8961 (setq articles (cdr articles)))
8963 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8964 (gnus-summary-position-point)
8965 (gnus-set-mode-line 'summary)
8968 (defun gnus-summary-edit-article (&optional force)
8969 "Edit the current article.
8970 This will have permanent effect only in mail groups.
8971 If FORCE is non-nil, allow editing of articles even in read-only
8975 (set-buffer gnus-summary-buffer)
8976 (let ((mail-parse-charset gnus-newsgroup-charset)
8977 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8978 (gnus-set-global-variables)
8979 (when (and (not force)
8980 (gnus-group-read-only-p))
8981 (error "The current newsgroup does not support article editing"))
8982 (gnus-summary-show-article t)
8983 (gnus-article-edit-article
8985 `(lambda (no-highlight)
8986 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8987 (message-options message-options)
8988 (message-options-set-recipient)
8989 (mail-parse-ignored-charsets
8990 ',gnus-newsgroup-ignored-charsets))
8991 (gnus-summary-edit-article-done
8992 ,(or (mail-header-references gnus-current-headers) "")
8993 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8995 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8997 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8999 "Make edits to the current article permanent."
9002 ;; The buffer restriction contains the entire article if it exists.
9003 (when (article-goto-body)
9004 (let ((lines (count-lines (point) (point-max)))
9005 (length (- (point-max) (point)))
9006 (case-fold-search t)
9007 (body (copy-marker (point))))
9008 (goto-char (point-min))
9009 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9010 (delete-region (match-beginning 1) (match-end 1))
9011 (insert (number-to-string length)))
9012 (goto-char (point-min))
9013 (when (re-search-forward
9014 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9015 (delete-region (match-beginning 1) (match-end 1))
9016 (insert (number-to-string length)))
9017 (goto-char (point-min))
9018 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9019 (delete-region (match-beginning 1) (match-end 1))
9020 (insert (number-to-string lines))))))
9021 ;; Replace the article.
9022 (let ((buf (current-buffer)))
9024 (insert-buffer-substring buf)
9026 (if (and (not read-only)
9027 (not (gnus-request-replace-article
9028 (cdr gnus-article-current) (car gnus-article-current)
9029 (current-buffer) t)))
9030 (error "Couldn't replace article")
9031 ;; Update the summary buffer.
9033 (equal (message-tokenize-header references " ")
9034 (message-tokenize-header
9035 (or (message-fetch-field "references") "") " ")))
9036 ;; We only have to update this line.
9039 (message-narrow-to-head)
9040 (let ((head (buffer-string))
9043 (insert (format "211 %d Article retrieved.\n"
9044 (cdr gnus-article-current)))
9047 (let ((nntp-server-buffer (current-buffer)))
9048 (setq header (car (gnus-get-newsgroup-headers
9051 (set-buffer gnus-summary-buffer)
9052 (gnus-data-set-header
9053 (gnus-data-find (cdr gnus-article-current))
9055 (gnus-summary-update-article-line
9056 (cdr gnus-article-current) header)
9057 (if (gnus-summary-goto-subject
9058 (cdr gnus-article-current) nil t)
9059 (gnus-summary-update-secondary-mark
9060 (cdr gnus-article-current))))))))
9062 (set-buffer (or buffer gnus-summary-buffer))
9063 (gnus-summary-update-article (cdr gnus-article-current))
9064 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9065 (gnus-summary-update-secondary-mark
9066 (cdr gnus-article-current))))
9067 ;; Prettify the article buffer again.
9068 (unless no-highlight
9070 (set-buffer gnus-article-buffer)
9071 ;;;!!! Fix this -- article should be rehighlighted.
9072 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9073 (set-buffer gnus-original-article-buffer)
9074 (gnus-request-article
9075 (cdr gnus-article-current)
9076 (car gnus-article-current) (current-buffer))))
9077 ;; Prettify the summary buffer line.
9078 (when (gnus-visual-p 'summary-highlight 'highlight)
9079 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9081 (defun gnus-summary-edit-wash (key)
9082 "Perform editing command KEY in the article buffer."
9086 (message "%s" (concat (this-command-keys) "- "))
9089 (gnus-summary-edit-article)
9090 (execute-kbd-macro (concat (this-command-keys) key))
9091 (gnus-article-edit-done))
9095 (defun gnus-summary-respool-query (&optional silent trace)
9096 "Query where the respool algorithm would put this article."
9098 (let (gnus-mark-article-hook)
9099 (gnus-summary-select-article)
9101 (set-buffer gnus-original-article-buffer)
9103 (message-narrow-to-head)
9104 (let ((groups (nnmail-article-group 'identity trace)))
9107 (message "This message would go to %s"
9108 (mapconcat 'car groups ", "))
9109 (message "This message would go to no groups"))
9112 (defun gnus-summary-respool-trace ()
9113 "Trace where the respool algorithm would put this article.
9114 Display a buffer showing all fancy splitting patterns which matched."
9116 (gnus-summary-respool-query nil t))
9118 ;; Summary marking commands.
9120 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9121 "Mark articles which has the same subject as read, and then select the next.
9122 If UNMARK is positive, remove any kind of mark.
9123 If UNMARK is negative, tick articles."
9126 (setq unmark (prefix-numeric-value unmark)))
9128 (gnus-summary-mark-same-subject
9129 (gnus-summary-article-subject) unmark)))
9130 ;; Select next unread article. If auto-select-same mode, should
9131 ;; select the first unread article.
9132 (gnus-summary-next-article t (and gnus-auto-select-same
9133 (gnus-summary-article-subject)))
9134 (gnus-message 7 "%d article%s marked as %s"
9135 count (if (= count 1) " is" "s are")
9136 (if unmark "unread" "read"))))
9138 (defun gnus-summary-kill-same-subject (&optional unmark)
9139 "Mark articles which has the same subject as read.
9140 If UNMARK is positive, remove any kind of mark.
9141 If UNMARK is negative, tick articles."
9144 (setq unmark (prefix-numeric-value unmark)))
9146 (gnus-summary-mark-same-subject
9147 (gnus-summary-article-subject) unmark)))
9148 ;; If marked as read, go to next unread subject.
9150 ;; Go to next unread subject.
9151 (gnus-summary-next-subject 1 t))
9152 (gnus-message 7 "%d articles are marked as %s"
9153 count (if unmark "unread" "read"))))
9155 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9156 "Mark articles with same SUBJECT as read, and return marked number.
9157 If optional argument UNMARK is positive, remove any kinds of marks.
9158 If optional argument UNMARK is negative, mark articles as unread instead."
9162 ((null unmark) ; Mark as read.
9165 (gnus-summary-mark-article-as-read gnus-killed-mark)
9166 (gnus-summary-show-thread) t)
9167 (gnus-summary-find-subject subject))
9168 (setq count (1+ count))))
9169 ((> unmark 0) ; Tick.
9172 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9173 (gnus-summary-show-thread) t)
9174 (gnus-summary-find-subject subject))
9175 (setq count (1+ count))))
9176 (t ; Mark as unread.
9179 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9180 (gnus-summary-show-thread) t)
9181 (gnus-summary-find-subject subject))
9182 (setq count (1+ count)))))
9183 (gnus-set-mode-line 'summary)
9184 ;; Return the number of marked articles.
9187 (defun gnus-summary-mark-as-processable (n &optional unmark)
9188 "Set the process mark on the next N articles.
9189 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9190 the process mark instead. The difference between N and the actual
9191 number of articles marked is returned."
9193 (if (and (null n) (gnus-region-active-p))
9194 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9195 (setq n (prefix-numeric-value n))
9196 (let ((backward (< n 0))
9201 (gnus-summary-remove-process-mark
9202 (gnus-summary-article-number))
9203 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9204 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9207 (gnus-message 7 "No more articles"))
9208 (gnus-summary-recenter)
9209 (gnus-summary-position-point)
9212 (defun gnus-summary-unmark-as-processable (n)
9213 "Remove the process mark from the next N articles.
9214 If N is negative, unmark backward instead. The difference between N and
9215 the actual number of articles unmarked is returned."
9217 (gnus-summary-mark-as-processable n t))
9219 (defun gnus-summary-unmark-all-processable ()
9220 "Remove the process mark from all articles."
9223 (while gnus-newsgroup-processable
9224 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9225 (gnus-summary-position-point))
9227 (defun gnus-summary-add-mark (article type)
9228 "Mark ARTICLE with a mark of TYPE."
9229 (let ((vtype (car (assq type gnus-article-mark-lists)))
9232 (error "No such mark type: %s" type)
9233 (setq var (intern (format "gnus-newsgroup-%s" type)))
9234 (set var (cons article (symbol-value var)))
9235 (if (memq type '(processable cached replied forwarded recent saved))
9236 (gnus-summary-update-secondary-mark article)
9237 ;;; !!! This is bogus. We should find out what primary
9238 ;;; !!! mark we want to set.
9239 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9241 (defun gnus-summary-mark-as-expirable (n)
9242 "Mark N articles forward as expirable.
9243 If N is negative, mark backward instead. The difference between N and
9244 the actual number of articles marked is returned."
9246 (gnus-summary-mark-forward n gnus-expirable-mark))
9248 (defun gnus-summary-mark-as-spam (n)
9249 "Mark N articles forward as spam.
9250 If N is negative, mark backward instead. The difference between N and
9251 the actual number of articles marked is returned."
9253 (gnus-summary-mark-forward n gnus-spam-mark))
9255 (defun gnus-summary-mark-article-as-replied (article)
9256 "Mark ARTICLE as replied to and update the summary line.
9257 ARTICLE can also be a list of articles."
9258 (interactive (list (gnus-summary-article-number)))
9259 (let ((articles (if (listp article) article (list article))))
9260 (dolist (article articles)
9261 (push article gnus-newsgroup-replied)
9262 (let ((buffer-read-only nil))
9263 (when (gnus-summary-goto-subject article nil t)
9264 (gnus-summary-update-secondary-mark article))))))
9266 (defun gnus-summary-mark-article-as-forwarded (article)
9267 "Mark ARTICLE as forwarded and update the summary line.
9268 ARTICLE can also be a list of articles."
9269 (let ((articles (if (listp article) article (list article))))
9270 (dolist (article articles)
9271 (push article gnus-newsgroup-forwarded)
9272 (let ((buffer-read-only nil))
9273 (when (gnus-summary-goto-subject article nil t)
9274 (gnus-summary-update-secondary-mark article))))))
9276 (defun gnus-summary-set-bookmark (article)
9277 "Set a bookmark in current article."
9278 (interactive (list (gnus-summary-article-number)))
9279 (when (or (not (get-buffer gnus-article-buffer))
9280 (not gnus-current-article)
9281 (not gnus-article-current)
9282 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9283 (error "No current article selected"))
9284 ;; Remove old bookmark, if one exists.
9285 (let ((old (assq article gnus-newsgroup-bookmarks)))
9287 (setq gnus-newsgroup-bookmarks
9288 (delq old gnus-newsgroup-bookmarks))))
9289 ;; Set the new bookmark, which is on the form
9290 ;; (article-number . line-number-in-body).
9294 (set-buffer gnus-article-buffer)
9298 (goto-char (point-min))
9299 (search-forward "\n\n" nil t)
9302 gnus-newsgroup-bookmarks)
9303 (gnus-message 6 "A bookmark has been added to the current article."))
9305 (defun gnus-summary-remove-bookmark (article)
9306 "Remove the bookmark from the current article."
9307 (interactive (list (gnus-summary-article-number)))
9308 ;; Remove old bookmark, if one exists.
9309 (let ((old (assq article gnus-newsgroup-bookmarks)))
9312 (setq gnus-newsgroup-bookmarks
9313 (delq old gnus-newsgroup-bookmarks))
9314 (gnus-message 6 "Removed bookmark."))
9315 (gnus-message 6 "No bookmark in current article."))))
9317 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9318 (defun gnus-summary-mark-as-dormant (n)
9319 "Mark N articles forward as dormant.
9320 If N is negative, mark backward instead. The difference between N and
9321 the actual number of articles marked is returned."
9323 (gnus-summary-mark-forward n gnus-dormant-mark))
9325 (defun gnus-summary-set-process-mark (article)
9326 "Set the process mark on ARTICLE and update the summary line."
9327 (setq gnus-newsgroup-processable
9329 (delq article gnus-newsgroup-processable)))
9330 (when (gnus-summary-goto-subject article)
9331 (gnus-summary-show-thread)
9332 (gnus-summary-goto-subject article)
9333 (gnus-summary-update-secondary-mark article)))
9335 (defun gnus-summary-remove-process-mark (article)
9336 "Remove the process mark from ARTICLE and update the summary line."
9337 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9338 (when (gnus-summary-goto-subject article)
9339 (gnus-summary-show-thread)
9340 (gnus-summary-goto-subject article)
9341 (gnus-summary-update-secondary-mark article)))
9343 (defun gnus-summary-set-saved-mark (article)
9344 "Set the process mark on ARTICLE and update the summary line."
9345 (push article gnus-newsgroup-saved)
9346 (when (gnus-summary-goto-subject article)
9347 (gnus-summary-update-secondary-mark article)))
9349 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9350 "Mark N articles as read forwards.
9351 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9352 The difference between N and the actual number of articles marked is
9354 Iff NO-EXPIRE, auto-expiry will be inhibited."
9356 (gnus-summary-show-thread)
9357 (let ((backward (< n 0))
9358 (gnus-summary-goto-unread
9359 (and gnus-summary-goto-unread
9360 (not (eq gnus-summary-goto-unread 'never))
9361 (not (memq mark (list gnus-unread-mark
9362 gnus-ticked-mark gnus-dormant-mark)))))
9364 (mark (or mark gnus-del-mark)))
9366 (gnus-summary-mark-article nil mark no-expire)
9367 (zerop (gnus-summary-next-subject
9369 (and gnus-summary-goto-unread
9370 (not (eq gnus-summary-goto-unread 'never)))
9374 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9375 (gnus-summary-recenter)
9376 (gnus-summary-position-point)
9377 (gnus-set-mode-line 'summary)
9380 (defun gnus-summary-mark-article-as-read (mark)
9381 "Mark the current article quickly as read with MARK."
9382 (let ((article (gnus-summary-article-number)))
9383 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9384 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9385 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9386 (push (cons article mark) gnus-newsgroup-reads)
9387 ;; Possibly remove from cache, if that is used.
9388 (when gnus-use-cache
9389 (gnus-cache-enter-remove-article article))
9390 ;; Allow the backend to change the mark.
9391 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9392 ;; Check for auto-expiry.
9393 (when (and gnus-newsgroup-auto-expire
9394 (memq mark gnus-auto-expirable-marks))
9395 (setq mark gnus-expirable-mark)
9396 ;; Let the backend know about the mark change.
9397 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9398 (push article gnus-newsgroup-expirable))
9399 ;; Set the mark in the buffer.
9400 (gnus-summary-update-mark mark 'unread)
9403 (defun gnus-summary-mark-article-as-unread (mark)
9404 "Mark the current article quickly as unread with MARK."
9405 (let* ((article (gnus-summary-article-number))
9406 (old-mark (gnus-summary-article-mark article)))
9407 ;; Allow the backend to change the mark.
9408 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9409 (if (eq mark old-mark)
9413 (gnus-error 1 "Can't mark negative article numbers")
9415 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9416 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9417 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9418 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9419 (cond ((= mark gnus-ticked-mark)
9420 (setq gnus-newsgroup-marked
9421 (gnus-add-to-sorted-list gnus-newsgroup-marked
9423 ((= mark gnus-dormant-mark)
9424 (setq gnus-newsgroup-dormant
9425 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9428 (setq gnus-newsgroup-unreads
9429 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9431 (gnus-pull article gnus-newsgroup-reads)
9433 ;; See whether the article is to be put in the cache.
9435 (vectorp (gnus-summary-article-header article))
9437 (gnus-cache-possibly-enter-article
9438 gnus-newsgroup-name article
9439 (gnus-summary-article-header article)
9440 (= mark gnus-ticked-mark)
9441 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9444 (gnus-summary-update-mark mark 'unread)
9447 (defun gnus-summary-mark-article (&optional article mark no-expire)
9448 "Mark ARTICLE with MARK. MARK can be any character.
9449 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9450 `??' (dormant) and `?E' (expirable).
9451 If MARK is nil, then the default character `?r' is used.
9452 If ARTICLE is nil, then the article on the current line will be
9454 Iff NO-EXPIRE, auto-expiry will be inhibited."
9455 ;; The mark might be a string.
9456 (when (stringp mark)
9457 (setq mark (aref mark 0)))
9458 ;; If no mark is given, then we check auto-expiring.
9460 (setq mark gnus-del-mark))
9461 (when (and (not no-expire)
9462 gnus-newsgroup-auto-expire
9463 (memq mark gnus-auto-expirable-marks))
9464 (setq mark gnus-expirable-mark))
9465 (let ((article (or article (gnus-summary-article-number)))
9466 (old-mark (gnus-summary-article-mark article)))
9467 ;; Allow the backend to change the mark.
9468 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9469 (if (eq mark old-mark)
9472 (error "No article on current line"))
9473 (if (not (if (or (= mark gnus-unread-mark)
9474 (= mark gnus-ticked-mark)
9475 (= mark gnus-dormant-mark))
9476 (gnus-mark-article-as-unread article mark)
9477 (gnus-mark-article-as-read article mark)))
9479 ;; See whether the article is to be put in the cache.
9481 (not (= mark gnus-canceled-mark))
9482 (vectorp (gnus-summary-article-header article))
9484 (gnus-cache-possibly-enter-article
9485 gnus-newsgroup-name article
9486 (gnus-summary-article-header article)
9487 (= mark gnus-ticked-mark)
9488 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9490 (when (gnus-summary-goto-subject article nil t)
9491 (let ((buffer-read-only nil))
9492 (gnus-summary-show-thread)
9494 (gnus-summary-update-mark mark 'unread)
9497 (defun gnus-summary-update-secondary-mark (article)
9498 "Update the secondary (read, process, cache) mark."
9499 (gnus-summary-update-mark
9500 (cond ((memq article gnus-newsgroup-processable)
9502 ((memq article gnus-newsgroup-cached)
9504 ((memq article gnus-newsgroup-replied)
9506 ((memq article gnus-newsgroup-forwarded)
9507 gnus-forwarded-mark)
9508 ((memq article gnus-newsgroup-saved)
9510 ((memq article gnus-newsgroup-recent)
9512 ((memq article gnus-newsgroup-unseen)
9516 (when (gnus-visual-p 'summary-highlight 'highlight)
9517 (gnus-run-hooks 'gnus-summary-update-hook))
9520 (defun gnus-summary-update-mark (mark type)
9521 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9522 (buffer-read-only nil))
9523 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9525 (when (looking-at "\r")
9527 (when (<= (+ forward (point)) (point-max))
9528 ;; Go to the right position on the line.
9529 (goto-char (+ forward (point)))
9530 ;; Replace the old mark with the new mark.
9531 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9532 ;; Optionally update the marks by some user rule.
9533 (when (eq type 'unread)
9535 (gnus-data-find (gnus-summary-article-number)) mark)
9536 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9538 (defun gnus-mark-article-as-read (article &optional mark)
9539 "Enter ARTICLE in the pertinent lists and remove it from others."
9540 ;; Make the article expirable.
9541 (let ((mark (or mark gnus-del-mark)))
9542 (setq gnus-newsgroup-expirable
9543 (if (= mark gnus-expirable-mark)
9544 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9545 (delq article gnus-newsgroup-expirable)))
9546 ;; Remove from unread and marked lists.
9547 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9548 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9549 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9550 (push (cons article mark) gnus-newsgroup-reads)
9551 ;; Possibly remove from cache, if that is used.
9552 (when gnus-use-cache
9553 (gnus-cache-enter-remove-article article))
9556 (defun gnus-mark-article-as-unread (article &optional mark)
9557 "Enter ARTICLE in the pertinent lists and remove it from others."
9558 (let ((mark (or mark gnus-ticked-mark)))
9561 (gnus-error 1 "Can't mark negative article numbers")
9563 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9564 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9565 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9566 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9568 ;; Unsuppress duplicates?
9569 (when gnus-suppress-duplicates
9570 (gnus-dup-unsuppress-article article))
9572 (cond ((= mark gnus-ticked-mark)
9573 (setq gnus-newsgroup-marked
9574 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9575 ((= mark gnus-dormant-mark)
9576 (setq gnus-newsgroup-dormant
9577 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9579 (setq gnus-newsgroup-unreads
9580 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9581 (gnus-pull article gnus-newsgroup-reads)
9584 (defalias 'gnus-summary-mark-as-unread-forward
9585 'gnus-summary-tick-article-forward)
9586 (make-obsolete 'gnus-summary-mark-as-unread-forward
9587 'gnus-summary-tick-article-forward)
9588 (defun gnus-summary-tick-article-forward (n)
9589 "Tick N articles forwards.
9590 If N is negative, tick backwards instead.
9591 The difference between N and the number of articles ticked is returned."
9593 (gnus-summary-mark-forward n gnus-ticked-mark))
9595 (defalias 'gnus-summary-mark-as-unread-backward
9596 'gnus-summary-tick-article-backward)
9597 (make-obsolete 'gnus-summary-mark-as-unread-backward
9598 'gnus-summary-tick-article-backward)
9599 (defun gnus-summary-tick-article-backward (n)
9600 "Tick N articles backwards.
9601 The difference between N and the number of articles ticked is returned."
9603 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9605 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9606 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9607 (defun gnus-summary-tick-article (&optional article clear-mark)
9608 "Mark current article as unread.
9609 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9610 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9612 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9615 (defun gnus-summary-mark-as-read-forward (n)
9616 "Mark N articles as read forwards.
9617 If N is negative, mark backwards instead.
9618 The difference between N and the actual number of articles marked is
9621 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9623 (defun gnus-summary-mark-as-read-backward (n)
9624 "Mark the N articles as read backwards.
9625 The difference between N and the actual number of articles marked is
9628 (gnus-summary-mark-forward
9629 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9631 (defun gnus-summary-mark-as-read (&optional article mark)
9632 "Mark current article as read.
9633 ARTICLE specifies the article to be marked as read.
9634 MARK specifies a string to be inserted at the beginning of the line."
9635 (gnus-summary-mark-article article mark))
9637 (defun gnus-summary-clear-mark-forward (n)
9638 "Clear marks from N articles forward.
9639 If N is negative, clear backward instead.
9640 The difference between N and the number of marks cleared is returned."
9642 (gnus-summary-mark-forward n gnus-unread-mark))
9644 (defun gnus-summary-clear-mark-backward (n)
9645 "Clear marks from N articles backward.
9646 The difference between N and the number of marks cleared is returned."
9648 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9650 (defun gnus-summary-mark-unread-as-read ()
9651 "Intended to be used by `gnus-summary-mark-article-hook'."
9652 (when (memq gnus-current-article gnus-newsgroup-unreads)
9653 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9655 (defun gnus-summary-mark-read-and-unread-as-read ()
9656 "Intended to be used by `gnus-summary-mark-article-hook'."
9657 (let ((mark (gnus-summary-article-mark)))
9658 (when (or (gnus-unread-mark-p mark)
9659 (gnus-read-mark-p mark))
9660 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9662 (defun gnus-summary-mark-unread-as-ticked ()
9663 "Intended to be used by `gnus-summary-mark-article-hook'."
9664 (when (memq gnus-current-article gnus-newsgroup-unreads)
9665 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9667 (defun gnus-summary-mark-region-as-read (point mark all)
9668 "Mark all unread articles between point and mark as read.
9669 If given a prefix, mark all articles between point and mark as read,
9670 even ticked and dormant ones."
9671 (interactive "r\nP")
9680 (memq (setq article (gnus-summary-article-number))
9681 gnus-newsgroup-unreads))
9682 (gnus-summary-mark-article article gnus-del-mark))
9684 (gnus-summary-find-next))))))
9686 (defun gnus-summary-mark-below (score mark)
9687 "Mark articles with score less than SCORE with MARK."
9688 (interactive "P\ncMark: ")
9689 (setq score (if score
9690 (prefix-numeric-value score)
9691 (or gnus-summary-default-score 0)))
9693 (set-buffer gnus-summary-buffer)
9694 (goto-char (point-min))
9697 (and (< (gnus-summary-article-score) score)
9698 (gnus-summary-mark-article nil mark))
9699 (gnus-summary-find-next)))))
9701 (defun gnus-summary-kill-below (&optional score)
9702 "Mark articles with score below SCORE as read."
9704 (gnus-summary-mark-below score gnus-killed-mark))
9706 (defun gnus-summary-clear-above (&optional score)
9707 "Clear all marks from articles with score above SCORE."
9709 (gnus-summary-mark-above score gnus-unread-mark))
9711 (defun gnus-summary-tick-above (&optional score)
9712 "Tick all articles with score above SCORE."
9714 (gnus-summary-mark-above score gnus-ticked-mark))
9716 (defun gnus-summary-mark-above (score mark)
9717 "Mark articles with score over SCORE with MARK."
9718 (interactive "P\ncMark: ")
9719 (setq score (if score
9720 (prefix-numeric-value score)
9721 (or gnus-summary-default-score 0)))
9723 (set-buffer gnus-summary-buffer)
9724 (goto-char (point-min))
9726 (when (> (gnus-summary-article-score) score)
9727 (gnus-summary-mark-article nil mark))
9729 (gnus-summary-find-next)))))
9731 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9732 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9733 (defun gnus-summary-limit-include-expunged (&optional no-error)
9734 "Display all the hidden articles that were expunged for low scores."
9736 (let ((buffer-read-only nil))
9737 (let ((scored gnus-newsgroup-scored)
9740 (unless (gnus-summary-article-header (caar scored))
9741 (and (setq h (gnus-number-to-header (caar scored)))
9742 (< (cdar scored) gnus-summary-expunge-below)
9744 (setq scored (cdr scored)))
9746 (when (not no-error)
9747 (error "No expunged articles hidden"))
9748 (goto-char (point-min))
9749 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9750 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9751 (mapcar (lambda (x) (push (mail-header-number x)
9752 gnus-newsgroup-limit))
9754 (gnus-summary-prepare-unthreaded (nreverse headers))
9755 (goto-char (point-min))
9756 (gnus-summary-position-point)
9759 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9760 "Mark all unread articles in this newsgroup as read.
9761 If prefix argument ALL is non-nil, ticked and dormant articles will
9762 also be marked as read.
9763 If QUIETLY is non-nil, no questions will be asked.
9764 If TO-HERE is non-nil, it should be a point in the buffer. All
9765 articles before (after, if REVERSE is set) this point will be marked as read.
9766 Note that this function will only catch up the unread article
9767 in the current summary buffer limitation.
9768 The number of articles marked as read is returned."
9773 (not gnus-interactive-catchup) ;Without confirmation?
9777 "Mark absolutely all articles as read? "
9778 "Mark all unread articles as read? ")))
9780 (not gnus-newsgroup-adaptive)
9781 (not gnus-newsgroup-auto-expire)
9782 (not gnus-suppress-duplicates)
9783 (or (not gnus-use-cache)
9784 (eq gnus-use-cache 'passive)))
9787 (setq gnus-newsgroup-marked nil
9788 gnus-newsgroup-dormant nil))
9789 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9790 ;; We actually mark all articles as canceled, which we
9791 ;; have to do when using auto-expiry or adaptive scoring.
9792 (gnus-summary-show-all-threads)
9793 (if (and to-here reverse)
9797 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9798 (gnus-summary-find-next (not all) nil nil t))))
9799 (when (gnus-summary-first-subject (not all) t)
9801 (if to-here (< (point) to-here) t)
9802 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9803 (gnus-summary-find-next (not all) nil nil t)))))
9804 (gnus-set-mode-line 'summary))
9806 (gnus-summary-position-point)))
9808 (defun gnus-summary-catchup-to-here (&optional all)
9809 "Mark all unticked articles before the current one as read.
9810 If ALL is non-nil, also mark ticked and dormant articles as read."
9813 (gnus-save-hidden-threads
9814 (let ((beg (point)))
9815 ;; We check that there are unread articles.
9816 (when (or all (gnus-summary-find-prev))
9817 (gnus-summary-catchup all t beg)))))
9818 (gnus-summary-position-point))
9820 (defun gnus-summary-catchup-from-here (&optional all)
9821 "Mark all unticked articles after the current one as read.
9822 If ALL is non-nil, also mark ticked and dormant articles as read."
9825 (gnus-save-hidden-threads
9826 (let ((beg (point)))
9827 ;; We check that there are unread articles.
9828 (when (or all (gnus-summary-find-next))
9829 (gnus-summary-catchup all t beg nil t)))))
9830 (gnus-summary-position-point))
9832 (defun gnus-summary-catchup-all (&optional quietly)
9833 "Mark all articles in this newsgroup as read."
9835 (gnus-summary-catchup t quietly))
9837 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9838 "Mark all unread articles in this group as read, then exit.
9839 If prefix argument ALL is non-nil, all articles are marked as read.
9840 If QUIETLY is non-nil, no questions will be asked."
9842 (when (gnus-summary-catchup all quietly nil 'fast)
9843 ;; Select next newsgroup or exit.
9844 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9845 (eq gnus-auto-select-next 'quietly))
9846 (gnus-summary-next-group nil)
9847 (gnus-summary-exit))))
9849 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9850 "Mark all articles in this newsgroup as read, and then exit."
9852 (gnus-summary-catchup-and-exit t quietly))
9854 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9855 "Mark all articles in this group as read and select the next group.
9856 If given a prefix, mark all articles, unread as well as ticked, as
9860 (gnus-summary-catchup all))
9861 (gnus-summary-next-group))
9867 (defmacro gnus-with-article (article &rest forms)
9868 "Select ARTICLE and perform FORMS in the original article buffer.
9869 Then replace the article with the result."
9871 ;; We don't want the article to be marked as read.
9872 (let (gnus-mark-article-hook)
9873 (gnus-summary-select-article t t nil ,article))
9874 (set-buffer gnus-original-article-buffer)
9876 (if (not (gnus-check-backend-function
9877 'request-replace-article (car gnus-article-current)))
9878 (gnus-message 5 "Read-only group; not replacing")
9879 (unless (gnus-request-replace-article
9880 ,article (car gnus-article-current)
9882 (error "Couldn't replace article")))
9883 ;; The cache and backlog have to be flushed somewhat.
9884 (when gnus-keep-backlog
9885 (gnus-backlog-remove-article
9886 (car gnus-article-current) (cdr gnus-article-current)))
9887 (when gnus-use-cache
9888 (gnus-cache-update-article
9889 (car gnus-article-current) (cdr gnus-article-current)))))
9891 (put 'gnus-with-article 'lisp-indent-function 1)
9892 (put 'gnus-with-article 'edebug-form-spec '(form body))
9894 ;; Thread-based commands.
9896 (defun gnus-summary-articles-in-thread (&optional article)
9897 "Return a list of all articles in the current thread.
9898 If ARTICLE is non-nil, return all articles in the thread that starts
9900 (let* ((article (or article (gnus-summary-article-number)))
9901 (data (gnus-data-find-list article))
9902 (top-level (gnus-data-level (car data)))
9904 (cond ((null gnus-thread-operation-ignore-subject)
9905 (gnus-simplify-subject-re
9906 (mail-header-subject (gnus-data-header (car data)))))
9907 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9908 (gnus-simplify-subject-fuzzy
9909 (mail-header-subject (gnus-data-header (car data)))))
9911 (end-point (save-excursion
9912 (if (gnus-summary-go-to-next-thread)
9913 (point) (point-max))))
9916 (< (gnus-data-pos (car data)) end-point))
9917 (when (or (not top-subject)
9918 (string= top-subject
9919 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9920 (gnus-simplify-subject-fuzzy
9921 (mail-header-subject
9922 (gnus-data-header (car data))))
9923 (gnus-simplify-subject-re
9924 (mail-header-subject
9925 (gnus-data-header (car data)))))))
9926 (push (gnus-data-number (car data)) articles))
9927 (unless (and (setq data (cdr data))
9928 (> (gnus-data-level (car data)) top-level))
9930 ;; Return the list of articles.
9931 (nreverse articles)))
9933 (defun gnus-summary-rethread-current ()
9934 "Rethread the thread the current article is part of."
9936 (let* ((gnus-show-threads t)
9937 (article (gnus-summary-article-number))
9938 (id (mail-header-id (gnus-summary-article-header)))
9939 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9941 (error "No article on the current line"))
9942 (gnus-rebuild-thread id)
9943 (gnus-summary-goto-subject article)))
9945 (defun gnus-summary-reparent-thread ()
9946 "Make the current article child of the marked (or previous) article.
9948 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9949 is non-nil or the Subject: of both articles are the same."
9951 (unless (not (gnus-group-read-only-p))
9952 (error "The current newsgroup does not support article editing"))
9953 (unless (<= (length gnus-newsgroup-processable) 1)
9954 (error "No more than one article may be marked"))
9955 (save-window-excursion
9956 (let ((gnus-article-buffer " *reparent*")
9957 (current-article (gnus-summary-article-number))
9958 ;; First grab the marked article, otherwise one line up.
9959 (parent-article (if (not (null gnus-newsgroup-processable))
9960 (car gnus-newsgroup-processable)
9962 (if (eq (forward-line -1) 0)
9963 (gnus-summary-article-number)
9964 (error "Beginning of summary buffer"))))))
9965 (unless (not (eq current-article parent-article))
9966 (error "An article may not be self-referential"))
9967 (let ((message-id (mail-header-id
9968 (gnus-summary-article-header parent-article))))
9969 (unless (and message-id (not (equal message-id "")))
9970 (error "No message-id in desired parent"))
9971 (gnus-with-article current-article
9973 (goto-char (point-min))
9974 (message-narrow-to-head)
9975 (if (re-search-forward "^References: " nil t)
9977 (re-search-forward "^[^ \t]" nil t)
9980 (insert " " message-id))
9981 (insert "References: " message-id "\n"))))
9982 (set-buffer gnus-summary-buffer)
9983 (gnus-summary-unmark-all-processable)
9984 (gnus-summary-update-article current-article)
9985 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9986 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9987 (gnus-summary-rethread-current)
9988 (gnus-message 3 "Article %d is now the child of article %d"
9989 current-article parent-article)))))
9991 (defun gnus-summary-toggle-threads (&optional arg)
9992 "Toggle showing conversation threads.
9993 If ARG is positive number, turn showing conversation threads on."
9995 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9996 (setq gnus-show-threads
9997 (if (null arg) (not gnus-show-threads)
9998 (> (prefix-numeric-value arg) 0)))
9999 (gnus-summary-prepare)
10000 (gnus-summary-goto-subject current)
10001 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10002 (gnus-summary-position-point)))
10004 (defun gnus-summary-show-all-threads ()
10005 "Show all threads."
10008 (let ((buffer-read-only nil))
10009 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10010 (gnus-summary-position-point))
10012 (defun gnus-summary-show-thread ()
10013 "Show thread subtrees.
10014 Returns nil if no thread was there to be shown."
10016 (let ((buffer-read-only nil)
10018 ;; first goto end then to beg, to have point at beg after let
10019 (end (progn (end-of-line) (point)))
10020 (beg (progn (beginning-of-line) (point))))
10022 ;; Any hidden lines here?
10023 (search-forward "\r" end t)
10024 (subst-char-in-region beg end ?\^M ?\n t)
10026 (gnus-summary-position-point))))
10028 (defun gnus-summary-maybe-hide-threads ()
10029 "If requested, hide the threads that should be hidden."
10030 (when (and gnus-show-threads
10031 gnus-thread-hide-subtree)
10032 (gnus-summary-hide-all-threads
10033 (if (or (consp gnus-thread-hide-subtree)
10034 (gnus-functionp gnus-thread-hide-subtree))
10035 (gnus-make-predicate gnus-thread-hide-subtree)
10038 ;;; Hiding predicates.
10040 (defun gnus-article-unread-p (header)
10041 (memq (mail-header-number header) gnus-newsgroup-unreads))
10043 (defun gnus-article-unseen-p (header)
10044 (memq (mail-header-number header) gnus-newsgroup-unseen))
10046 (defun gnus-map-articles (predicate articles)
10047 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10048 (apply 'gnus-or (mapcar predicate
10049 (mapcar 'gnus-summary-article-header articles))))
10051 (defun gnus-summary-hide-all-threads (&optional predicate)
10052 "Hide all thread subtrees.
10053 If PREDICATE is supplied, threads that satisfy this predicate
10054 will not be hidden."
10057 (goto-char (point-min))
10060 (when (or (not predicate)
10062 predicate (gnus-summary-article-children)))
10063 (gnus-summary-hide-thread))
10064 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10065 (gnus-summary-position-point))
10067 (defun gnus-summary-hide-thread ()
10068 "Hide thread subtrees.
10069 If PREDICATE is supplied, threads that satisfy this predicate
10070 will not be hidden.
10071 Returns nil if no threads were there to be hidden."
10073 (let ((buffer-read-only nil)
10075 (article (gnus-summary-article-number)))
10077 ;; Go forward until either the buffer ends or the subthread
10079 (when (and (not (eobp))
10080 (or (zerop (gnus-summary-next-thread 1 t))
10081 (goto-char (point-max))))
10083 (if (and (> (point) start)
10084 (search-backward "\n" start t))
10086 (subst-char-in-region start (point) ?\n ?\^M)
10087 (gnus-summary-goto-subject article))
10091 (defun gnus-summary-go-to-next-thread (&optional previous)
10092 "Go to the same level (or less) next thread.
10093 If PREVIOUS is non-nil, go to previous thread instead.
10094 Return the article number moved to, or nil if moving was impossible."
10095 (let ((level (gnus-summary-thread-level))
10096 (way (if previous -1 1))
10099 (while (and (not (eobp))
10100 (< level (gnus-summary-thread-level)))
10101 (forward-line way))
10108 (gnus-summary-article-number)
10109 (goto-char beg)))))
10111 (defun gnus-summary-next-thread (n &optional silent)
10112 "Go to the same level next N'th thread.
10113 If N is negative, search backward instead.
10114 Returns the difference between N and the number of skips actually
10117 If SILENT, don't output messages."
10119 (let ((backward (< n 0))
10121 (while (and (> n 0)
10122 (gnus-summary-go-to-next-thread backward))
10125 (gnus-summary-position-point))
10126 (when (and (not silent) (/= 0 n))
10127 (gnus-message 7 "No more threads"))
10130 (defun gnus-summary-prev-thread (n)
10131 "Go to the same level previous N'th thread.
10132 Returns the difference between N and the number of skips actually
10135 (gnus-summary-next-thread (- n)))
10137 (defun gnus-summary-go-down-thread ()
10138 "Go down one level in the current thread."
10139 (let ((children (gnus-summary-article-children)))
10141 (gnus-summary-goto-subject (car children)))))
10143 (defun gnus-summary-go-up-thread ()
10144 "Go up one level in the current thread."
10145 (let ((parent (gnus-summary-article-parent)))
10147 (gnus-summary-goto-subject parent))))
10149 (defun gnus-summary-down-thread (n)
10150 "Go down thread N steps.
10151 If N is negative, go up instead.
10152 Returns the difference between N and how many steps down that were
10157 (while (and (> n 0)
10158 (if up (gnus-summary-go-up-thread)
10159 (gnus-summary-go-down-thread)))
10161 (gnus-summary-position-point)
10163 (gnus-message 7 "Can't go further"))
10166 (defun gnus-summary-up-thread (n)
10167 "Go up thread N steps.
10168 If N is negative, go down instead.
10169 Returns the difference between N and how many steps down that were
10172 (gnus-summary-down-thread (- n)))
10174 (defun gnus-summary-top-thread ()
10175 "Go to the top of the thread."
10177 (while (gnus-summary-go-up-thread))
10178 (gnus-summary-article-number))
10180 (defun gnus-summary-kill-thread (&optional unmark)
10181 "Mark articles under current thread as read.
10182 If the prefix argument is positive, remove any kinds of marks.
10183 If the prefix argument is negative, tick articles instead."
10186 (setq unmark (prefix-numeric-value unmark)))
10187 (let ((articles (gnus-summary-articles-in-thread)))
10189 ;; Expand the thread.
10190 (gnus-summary-show-thread)
10191 ;; Mark all the articles.
10193 (gnus-summary-goto-subject (car articles))
10194 (cond ((null unmark)
10195 (gnus-summary-mark-article-as-read gnus-killed-mark))
10197 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10199 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10200 (setq articles (cdr articles))))
10201 ;; Hide killed subtrees.
10203 gnus-thread-hide-killed
10204 (gnus-summary-hide-thread))
10205 ;; If marked as read, go to next unread subject.
10206 (when (null unmark)
10207 ;; Go to next unread subject.
10208 (gnus-summary-next-subject 1 t)))
10209 (gnus-set-mode-line 'summary))
10211 ;; Summary sorting commands
10213 (defun gnus-summary-sort-by-number (&optional reverse)
10214 "Sort the summary buffer by article number.
10215 Argument REVERSE means reverse order."
10217 (gnus-summary-sort 'number reverse))
10219 (defun gnus-summary-sort-by-author (&optional reverse)
10220 "Sort the summary buffer by author name alphabetically.
10221 If `case-fold-search' is non-nil, case of letters is ignored.
10222 Argument REVERSE means reverse order."
10224 (gnus-summary-sort 'author reverse))
10226 (defun gnus-summary-sort-by-subject (&optional reverse)
10227 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10228 If `case-fold-search' is non-nil, case of letters is ignored.
10229 Argument REVERSE means reverse order."
10231 (gnus-summary-sort 'subject reverse))
10233 (defun gnus-summary-sort-by-date (&optional reverse)
10234 "Sort the summary buffer by date.
10235 Argument REVERSE means reverse order."
10237 (gnus-summary-sort 'date reverse))
10239 (defun gnus-summary-sort-by-score (&optional reverse)
10240 "Sort the summary buffer by score.
10241 Argument REVERSE means reverse order."
10243 (gnus-summary-sort 'score reverse))
10245 (defun gnus-summary-sort-by-lines (&optional reverse)
10246 "Sort the summary buffer by the number of lines.
10247 Argument REVERSE means reverse order."
10249 (gnus-summary-sort 'lines reverse))
10251 (defun gnus-summary-sort-by-chars (&optional reverse)
10252 "Sort the summary buffer by article length.
10253 Argument REVERSE means reverse order."
10255 (gnus-summary-sort 'chars reverse))
10257 (defun gnus-summary-sort-by-original (&optional reverse)
10258 "Sort the summary buffer using the default sorting method.
10259 Argument REVERSE means reverse order."
10261 (let* ((buffer-read-only)
10262 (gnus-summary-prepare-hook nil))
10263 ;; We do the sorting by regenerating the threads.
10264 (gnus-summary-prepare)
10265 ;; Hide subthreads if needed.
10266 (gnus-summary-maybe-hide-threads)))
10268 (defun gnus-summary-sort (predicate reverse)
10269 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10270 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10271 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10272 (gnus-thread-sort-functions
10277 (gnus-sort-gathered-threads-function
10278 gnus-thread-sort-functions)
10279 (gnus-article-sort-functions
10283 (,article t2 t1))))
10285 (gnus-summary-prepare-hook nil))
10286 ;; We do the sorting by regenerating the threads.
10287 (gnus-summary-prepare)
10288 ;; Hide subthreads if needed.
10289 (gnus-summary-maybe-hide-threads)))
10291 ;; Summary saving commands.
10293 (defun gnus-summary-save-article (&optional n not-saved)
10294 "Save the current article using the default saver function.
10295 If N is a positive number, save the N next articles.
10296 If N is a negative number, save the N previous articles.
10297 If N is nil and any articles have been marked with the process mark,
10298 save those articles instead.
10299 The variable `gnus-default-article-saver' specifies the saver function."
10301 (let* ((articles (gnus-summary-work-articles n))
10302 (save-buffer (save-excursion
10303 (nnheader-set-temp-buffer " *Gnus Save*")))
10304 (num (length articles))
10306 (dolist (article articles)
10307 (setq header (gnus-summary-article-header article))
10308 (if (not (vectorp header))
10309 ;; This is a pseudo-article.
10310 (if (assq 'name header)
10311 (gnus-copy-file (cdr (assq 'name header)))
10312 (gnus-message 1 "Article %d is unsaveable" article))
10313 ;; This is a real article.
10314 (save-window-excursion
10315 (let ((gnus-display-mime-function nil)
10316 (gnus-article-prepare-hook nil))
10317 (gnus-summary-select-article t nil nil article)))
10319 (set-buffer save-buffer)
10321 (insert-buffer-substring gnus-original-article-buffer))
10322 (setq file (gnus-article-save save-buffer file num))
10323 (gnus-summary-remove-process-mark article)
10325 (gnus-summary-set-saved-mark article))))
10326 (gnus-kill-buffer save-buffer)
10327 (gnus-summary-position-point)
10328 (gnus-set-mode-line 'summary)
10331 (defun gnus-summary-pipe-output (&optional arg)
10332 "Pipe the current article to a subprocess.
10333 If N is a positive number, pipe the N next articles.
10334 If N is a negative number, pipe the N previous articles.
10335 If N is nil and any articles have been marked with the process mark,
10336 pipe those articles instead."
10338 (require 'gnus-art)
10339 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10340 (gnus-summary-save-article arg t))
10341 (let ((buffer (get-buffer "*Shell Command Output*")))
10343 (with-current-buffer buffer (> (point-max) (point-min))))
10344 (gnus-configure-windows 'pipe))))
10346 (defun gnus-summary-save-article-mail (&optional arg)
10347 "Append the current article to an mail file.
10348 If N is a positive number, save the N next articles.
10349 If N is a negative number, save the N previous articles.
10350 If N is nil and any articles have been marked with the process mark,
10351 save those articles instead."
10353 (require 'gnus-art)
10354 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10355 (gnus-summary-save-article arg)))
10357 (defun gnus-summary-save-article-rmail (&optional arg)
10358 "Append the current article to an rmail file.
10359 If N is a positive number, save the N next articles.
10360 If N is a negative number, save the N previous articles.
10361 If N is nil and any articles have been marked with the process mark,
10362 save those articles instead."
10364 (require 'gnus-art)
10365 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10366 (gnus-summary-save-article arg)))
10368 (defun gnus-summary-save-article-file (&optional arg)
10369 "Append the current article to a file.
10370 If N is a positive number, save the N next articles.
10371 If N is a negative number, save the N previous articles.
10372 If N is nil and any articles have been marked with the process mark,
10373 save those articles instead."
10375 (require 'gnus-art)
10376 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10377 (gnus-summary-save-article arg)))
10379 (defun gnus-summary-write-article-file (&optional arg)
10380 "Write the current article to a file, deleting the previous file.
10381 If N is a positive number, save the N next articles.
10382 If N is a negative number, save the N previous articles.
10383 If N is nil and any articles have been marked with the process mark,
10384 save those articles instead."
10386 (require 'gnus-art)
10387 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10388 (gnus-summary-save-article arg)))
10390 (defun gnus-summary-save-article-body-file (&optional arg)
10391 "Append the current article body to a file.
10392 If N is a positive number, save the N next articles.
10393 If N is a negative number, save the N previous articles.
10394 If N is nil and any articles have been marked with the process mark,
10395 save those articles instead."
10397 (require 'gnus-art)
10398 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10399 (gnus-summary-save-article arg)))
10401 (defun gnus-summary-muttprint (&optional arg)
10402 "Print the current article using Muttprint.
10403 If N is a positive number, save the N next articles.
10404 If N is a negative number, save the N previous articles.
10405 If N is nil and any articles have been marked with the process mark,
10406 save those articles instead."
10408 (require 'gnus-art)
10409 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10410 (gnus-summary-save-article arg t)))
10412 (defun gnus-summary-pipe-message (program)
10413 "Pipe the current article through PROGRAM."
10414 (interactive "sProgram: ")
10415 (gnus-summary-select-article)
10416 (let ((mail-header-separator ""))
10417 (gnus-eval-in-buffer-window gnus-article-buffer
10420 (let ((start (window-start))
10422 (message-pipe-buffer-body program)
10423 (set-window-start (get-buffer-window (current-buffer)) start))))))
10425 (defun gnus-get-split-value (methods)
10426 "Return a value based on the split METHODS."
10427 (let (split-name method result match)
10430 (set-buffer gnus-original-article-buffer)
10432 (nnheader-narrow-to-headers)
10433 (while (and methods (not split-name))
10434 (goto-char (point-min))
10435 (setq method (pop methods))
10436 (setq match (car method))
10439 ;; Regular expression.
10441 (re-search-forward match nil t)))
10442 ((gnus-functionp match)
10446 (setq result (funcall match gnus-newsgroup-name))))
10451 (setq result (eval match)))))
10452 (setq split-name (cdr method))
10453 (cond ((stringp result)
10454 (push (expand-file-name
10455 result gnus-article-save-directory)
10458 (setq split-name (append result split-name)))))))))
10459 (nreverse split-name)))
10461 (defun gnus-valid-move-group-p (group)
10462 (and (boundp group)
10463 (symbol-name group)
10464 (symbol-value group)
10465 (gnus-get-function (gnus-find-method-for-group
10466 (symbol-name group)) 'request-accept-article t)))
10468 (defun gnus-read-move-group-name (prompt default articles prefix)
10469 "Read a group name."
10470 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10471 (minibuffer-confirm-incomplete nil) ; XEmacs
10473 (format "%s %s to:"
10475 (if (> (length articles) 1)
10476 (format "these %d articles" (length articles))
10481 (gnus-completing-read-with-default
10484 'gnus-valid-move-group-p
10486 'gnus-group-history))
10487 ((= 1 (length split-name))
10488 (gnus-completing-read-with-default
10489 (car split-name) prom
10491 'gnus-valid-move-group-p
10493 'gnus-group-history))
10495 (gnus-completing-read-with-default
10497 (mapcar (lambda (el) (list el))
10498 (nreverse split-name))
10500 'gnus-group-history))))
10501 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10503 (if (or (string= to-newsgroup "")
10504 (string= to-newsgroup prefix))
10505 (setq to-newsgroup default))
10506 (unless to-newsgroup
10507 (error "No group name entered"))
10508 (or (gnus-active to-newsgroup)
10509 (gnus-activate-group to-newsgroup nil nil to-method)
10510 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10512 (or (and (gnus-request-create-group to-newsgroup to-method)
10513 (gnus-activate-group
10514 to-newsgroup nil nil to-method)
10515 (gnus-subscribe-group to-newsgroup))
10516 (error "Couldn't create group %s" to-newsgroup)))
10517 (error "No such group: %s" to-newsgroup)))
10520 (defun gnus-summary-save-parts (type dir n &optional reverse)
10521 "Save parts matching TYPE to DIR.
10522 If REVERSE, save parts that do not match TYPE."
10524 (list (read-string "Save parts of type: "
10525 (or (car gnus-summary-save-parts-type-history)
10526 gnus-summary-save-parts-default-mime)
10527 'gnus-summary-save-parts-type-history)
10528 (setq gnus-summary-save-parts-last-directory
10529 (read-file-name "Save to directory: "
10530 gnus-summary-save-parts-last-directory
10532 current-prefix-arg))
10533 (gnus-summary-iterate n
10534 (let ((gnus-display-mime-function nil)
10535 (gnus-inhibit-treatment t))
10536 (gnus-summary-select-article))
10538 (set-buffer gnus-article-buffer)
10539 (let ((handles (or gnus-article-mime-handles
10540 (mm-dissect-buffer nil gnus-article-loose-mime)
10543 (gnus-summary-save-parts-1 type dir handles reverse)
10544 (unless gnus-article-mime-handles ;; Don't destroy this case.
10545 (mm-destroy-parts handles)))))))
10547 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10548 (if (stringp (car handle))
10549 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10552 (not (string-match type (mm-handle-media-type handle)))
10553 (string-match type (mm-handle-media-type handle)))
10554 (let ((file (expand-file-name
10555 (file-name-nondirectory
10557 (mail-content-type-get
10558 (mm-handle-disposition handle) 'filename)
10559 (concat gnus-newsgroup-name
10560 "." (number-to-string
10561 (cdr gnus-article-current)))))
10563 (unless (file-exists-p file)
10564 (mm-save-part-to-file handle file))))))
10566 ;; Summary extract commands
10568 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10569 (let ((buffer-read-only nil)
10570 (article (gnus-summary-article-number))
10572 (unless (gnus-summary-goto-subject article)
10573 (error "No such article: %d" article))
10574 (gnus-summary-position-point)
10575 ;; If all commands are to be bunched up on one line, we collect
10577 (unless gnus-view-pseudos-separately
10578 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10581 (setq action (cdr (assq 'action (car ps))))
10582 (setq files (list (cdr (assq 'name (car ps)))))
10583 (while (and ps (cdr ps)
10584 (string= (or action "1")
10585 (or (cdr (assq 'action (cadr ps))) "2")))
10586 (push (cdr (assq 'name (cadr ps))) files)
10587 (setcdr ps (cddr ps)))
10589 (when (not (string-match "%s" action))
10592 (when (assq 'execute (car ps))
10593 (setcdr (assq 'execute (car ps))
10594 (funcall (if (string-match "%s" action)
10601 (gnus-quote-arg-for-sh-or-csh f)))
10603 (setq ps (cdr ps)))))
10604 (if (and gnus-view-pseudos (not not-view))
10606 (when (assq 'execute (car pslist))
10607 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10608 (eq gnus-view-pseudos 'not-confirm)))
10609 (setq pslist (cdr pslist)))
10612 (setq after-article (or (cdr (assq 'article (car pslist)))
10613 (gnus-summary-article-number)))
10614 (gnus-summary-goto-subject after-article)
10617 (insert " " (file-name-nondirectory
10618 (cdr (assq 'name (car pslist))))
10619 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10621 (forward-line -1) ; back to `b'
10622 (gnus-add-text-properties
10623 b (1- e) (list 'gnus-number gnus-reffed-article-number
10624 gnus-mouse-face-prop gnus-mouse-face))
10626 after-article gnus-reffed-article-number
10627 gnus-unread-mark b (car pslist) 0 (- e b))
10628 (setq gnus-newsgroup-unreads
10629 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10630 gnus-reffed-article-number))
10631 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10632 (setq pslist (cdr pslist)))))))
10634 (defun gnus-pseudos< (p1 p2)
10635 (let ((c1 (cdr (assq 'action p1)))
10636 (c2 (cdr (assq 'action p2))))
10637 (and c1 c2 (string< c1 c2))))
10639 (defun gnus-request-pseudo-article (props)
10640 (cond ((assq 'execute props)
10641 (gnus-execute-command (cdr (assq 'execute props)))))
10642 (let ((gnus-current-article (gnus-summary-article-number)))
10643 (gnus-run-hooks 'gnus-mark-article-hook)))
10645 (defun gnus-execute-command (command &optional automatic)
10647 (gnus-article-setup-buffer)
10648 (set-buffer gnus-article-buffer)
10649 (setq buffer-read-only nil)
10650 (let ((command (if automatic command
10651 (read-string "Command: " (cons command 0)))))
10653 (insert "$ " command "\n\n")
10654 (if gnus-view-pseudo-asynchronously
10655 (start-process "gnus-execute" (current-buffer) shell-file-name
10656 shell-command-switch command)
10657 (call-process shell-file-name nil t nil
10658 shell-command-switch command)))))
10660 ;; Summary kill commands.
10662 (defun gnus-summary-edit-global-kill (article)
10663 "Edit the \"global\" kill file."
10664 (interactive (list (gnus-summary-article-number)))
10665 (gnus-group-edit-global-kill article))
10667 (defun gnus-summary-edit-local-kill ()
10668 "Edit a local kill file applied to the current newsgroup."
10670 (setq gnus-current-headers (gnus-summary-article-header))
10671 (gnus-group-edit-local-kill
10672 (gnus-summary-article-number) gnus-newsgroup-name))
10674 ;;; Header reading.
10676 (defun gnus-read-header (id &optional header)
10677 "Read the headers of article ID and enter them into the Gnus system."
10678 (let ((group gnus-newsgroup-name)
10679 (gnus-override-method
10681 gnus-override-method
10682 (and (gnus-news-group-p gnus-newsgroup-name)
10683 (car (gnus-refer-article-methods)))))
10685 ;; First we check to see whether the header in question is already
10688 ;; This is a Message-ID.
10689 (setq header (or header (gnus-id-to-header id)))
10690 ;; This is an article number.
10691 (setq header (or header (gnus-summary-article-header id))))
10693 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10694 ;; We have found the header.
10696 ;; If this is a sparse article, we have to nix out its
10697 ;; previous entry in the thread hashtb.
10699 (gnus-summary-article-sparse-p (mail-header-number header)))
10700 (let* ((parent (gnus-parent-id (mail-header-references header)))
10701 (thread (and parent (gnus-id-to-thread parent))))
10703 (delq (assq header thread) thread))))
10704 ;; We have to really fetch the header to this article.
10706 (set-buffer nntp-server-buffer)
10707 (when (setq where (gnus-request-head id group))
10708 (nnheader-fold-continuation-lines)
10709 (goto-char (point-max))
10711 (goto-char (point-min))
10715 ((cdr where) (cdr where))
10716 (header (mail-header-number header))
10717 (t gnus-reffed-article-number))
10719 (insert " Article retrieved.\n"))
10720 (if (or (not where)
10721 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10722 () ; Malformed head.
10723 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10724 (when (and (stringp id)
10725 (not (string= (gnus-group-real-name group)
10727 ;; If we fetched by Message-ID and the article came
10728 ;; from a different group, we fudge some bogus article
10729 ;; numbers for this article.
10730 (mail-header-set-number header gnus-reffed-article-number))
10732 (set-buffer gnus-summary-buffer)
10733 (decf gnus-reffed-article-number)
10734 (gnus-remove-header (mail-header-number header))
10735 (push header gnus-newsgroup-headers)
10736 (setq gnus-current-headers header)
10737 (push (mail-header-number header) gnus-newsgroup-limit)))
10740 (defun gnus-remove-header (number)
10741 "Remove header NUMBER from `gnus-newsgroup-headers'."
10742 (if (and gnus-newsgroup-headers
10743 (= number (mail-header-number (car gnus-newsgroup-headers))))
10744 (pop gnus-newsgroup-headers)
10745 (let ((headers gnus-newsgroup-headers))
10746 (while (and (cdr headers)
10747 (not (= number (mail-header-number (cadr headers)))))
10749 (when (cdr headers)
10750 (setcdr headers (cddr headers))))))
10753 ;;; summary highlights
10756 (defun gnus-highlight-selected-summary ()
10757 "Highlight selected article in summary buffer."
10758 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10759 (when gnus-summary-selected-face
10761 (let* ((beg (progn (beginning-of-line) (point)))
10762 (end (progn (end-of-line) (point)))
10763 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10764 (from (if (get-text-property beg gnus-mouse-face-prop)
10766 (or (next-single-property-change
10767 beg gnus-mouse-face-prop nil end)
10772 (or (next-single-property-change
10773 from gnus-mouse-face-prop nil end)
10775 ;; If no mouse-face prop on line we will have to = from = end,
10776 ;; so we highlight the entire line instead.
10777 (when (= (+ to 2) from)
10780 (if gnus-newsgroup-selected-overlay
10781 ;; Move old overlay.
10783 gnus-newsgroup-selected-overlay from to (current-buffer))
10784 ;; Create new overlay.
10786 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10787 'face gnus-summary-selected-face))))))
10789 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10790 (defun gnus-summary-highlight-line ()
10791 "Highlight current line according to `gnus-summary-highlight'."
10792 (let* ((list gnus-summary-highlight)
10793 (beg (gnus-point-at-bol))
10794 (article (gnus-summary-article-number))
10795 (score (or (cdr (assq (or article gnus-current-article)
10796 gnus-newsgroup-scored))
10797 gnus-summary-default-score 0))
10798 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10799 (inhibit-read-only t)
10800 (default gnus-summary-default-score)
10801 (default-high gnus-summary-default-high-score)
10802 (default-low gnus-summary-default-low-score))
10803 ;; Eval the cars of the lists until we find a match.
10805 (not (eval (caar list))))
10806 (setq list (cdr list)))
10807 (let ((face (cdar list)))
10808 (unless (eq face (get-text-property beg 'face))
10809 (gnus-put-text-property-excluding-characters-with-faces
10810 beg (gnus-point-at-eol) 'face
10811 (setq face (if (boundp face) (symbol-value face) face)))
10812 (when gnus-summary-highlight-line-function
10813 (funcall gnus-summary-highlight-line-function article face))))))
10815 (defun gnus-update-read-articles (group unread &optional compute)
10816 "Update the list of read articles in GROUP.
10817 UNREAD is a sorted list."
10818 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10819 (entry (gnus-gethash group gnus-newsrc-hashtb))
10820 (info (nth 2 entry))
10823 (if (or (not info) (not active))
10824 ;; There is no info on this group if it was, in fact,
10825 ;; killed. Gnus stores no information on killed groups, so
10826 ;; there's nothing to be done.
10827 ;; One could store the information somewhere temporarily,
10828 ;; perhaps... Hmmm...
10830 ;; Remove any negative articles numbers.
10831 (while (and unread (< (car unread) 0))
10832 (setq unread (cdr unread)))
10833 ;; Remove any expired article numbers
10834 (while (and unread (< (car unread) (car active)))
10835 (setq unread (cdr unread)))
10836 ;; Compute the ranges of read articles by looking at the list of
10837 ;; unread articles.
10839 (when (/= (car unread) prev)
10840 (push (if (= prev (1- (car unread))) prev
10841 (cons prev (1- (car unread))))
10843 (setq prev (1+ (car unread)))
10844 (setq unread (cdr unread)))
10845 (when (<= prev (cdr active))
10846 (push (cons prev (cdr active)) read))
10847 (setq read (if (> (length read) 1) (nreverse read) read))
10852 ;; Propagate the read marks to the backend.
10853 (when (gnus-check-backend-function 'request-set-mark group)
10854 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10855 (add (gnus-remove-from-range read (gnus-info-read info))))
10857 (unless (gnus-check-group group)
10858 (error "Can't open server for %s" group))
10859 (gnus-request-set-mark
10860 group (delq nil (list (if add (list add 'add '(read)))
10861 (if del (list del 'del '(read))))))
10863 `(gnus-request-set-mark
10866 (if del (list del 'add '(read)))
10867 (if add (list add 'del '(read))))))))))
10868 (set-buffer gnus-group-buffer)
10869 (gnus-undo-register
10871 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10872 (gnus-info-set-read ',info ',(gnus-info-read info))
10873 (gnus-get-unread-articles-in-group ',info
10874 (gnus-active ,group))
10875 (gnus-group-update-group ,group t)
10877 ;; Enter this list into the group info.
10878 (gnus-info-set-read info read)
10879 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10880 (gnus-get-unread-articles-in-group info (gnus-active group))
10883 (defun gnus-offer-save-summaries ()
10884 "Offer to save all active summary buffers."
10886 ;; Go through all buffers and find all summaries.
10887 (dolist (buffer (buffer-list))
10888 (when (and (setq buffer (buffer-name buffer))
10889 (string-match "Summary" buffer)
10891 (set-buffer buffer)
10892 ;; We check that this is, indeed, a summary buffer.
10893 (and (eq major-mode 'gnus-summary-mode)
10894 ;; Also make sure this isn't bogus.
10895 gnus-newsgroup-prepared
10896 ;; Also make sure that this isn't a
10897 ;; dead summary buffer.
10898 (not gnus-dead-summary-mode))))
10899 (push buffer buffers)))
10900 ;; Go through all these summary buffers and offer to save them.
10904 "Update summary buffer %s? "
10906 (switch-to-buffer buf)
10907 (gnus-summary-exit))
10911 ;;; @ for mime-partial
10914 (defun gnus-request-partial-message ()
10916 (let ((number (gnus-summary-article-number))
10917 (group gnus-newsgroup-name)
10918 (mother gnus-article-buffer))
10919 (set-buffer (get-buffer-create " *Partial Article*"))
10921 (setq mime-preview-buffer mother)
10922 (gnus-request-article-this-buffer number group)
10923 (mime-parse-buffer)
10926 (autoload 'mime-combine-message/partial-pieces-automatically
10928 "Internal method to combine message/partial messages automatically.")
10930 (mime-add-condition
10931 'action '((type . message)(subtype . partial)
10932 (major-mode . gnus-original-article-mode)
10933 (method . mime-combine-message/partial-pieces-automatically)
10934 (summary-buffer-exp . gnus-summary-buffer)
10935 (request-partial-message-method . gnus-request-partial-message)
10939 ;;; @ for message/rfc822
10942 (defun gnus-mime-extract-message/rfc822 (entity situation)
10943 "Burst a forwarded article."
10945 (set-buffer gnus-summary-buffer)
10946 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
10947 gnus-newsgroup-name 'gnus-group-history))
10948 (gnus-group-marked (list group))
10951 (mime-insert-entity-content entity)
10952 (setq article (gnus-request-accept-article group)))
10953 (when (and (consp article)
10954 (numberp (setq article (cdr article))))
10955 (setq info (gnus-get-info group))
10956 (gnus-info-set-read info
10957 (gnus-remove-from-range (gnus-info-read info)
10959 (when (string-equal group gnus-newsgroup-name)
10961 (let (gnus-show-threads)
10962 (gnus-summary-goto-subject article t))
10963 (gnus-summary-clear-mark-forward 1))
10964 (set-buffer gnus-group-buffer)
10965 (gnus-group-get-new-news-this-group nil t)))))
10967 (mime-add-condition
10968 'action '((type . message)(subtype . rfc822)
10969 (major-mode . gnus-original-article-mode)
10970 (method . gnus-mime-extract-message/rfc822)
10974 (mime-add-condition
10975 'action '((type . message)(subtype . news)
10976 (major-mode . gnus-original-article-mode)
10977 (method . gnus-mime-extract-message/rfc822)
10981 (defun gnus-mime-extract-multipart (entity situation)
10982 (let ((children (mime-entity-children entity))
10983 mime-acting-situation-to-override
10986 (mime-play-entity (car children)
10987 (cons (assq 'mode situation)
10988 mime-acting-situation-to-override))
10989 (setq children (cdr children)))
10990 (if (setq f (cdr (assq 'after-method
10991 mime-acting-situation-to-override)))
10995 (mime-add-condition
10996 'action '((type . multipart)
10997 (method . gnus-mime-extract-multipart)
11006 (defun gnus-summary-inherit-default-charset ()
11007 "Import `default-mime-charset' from summary buffer."
11008 (if (buffer-live-p gnus-summary-buffer)
11009 (if (local-variable-p 'default-mime-charset gnus-summary-buffer)
11011 (make-local-variable 'default-mime-charset)
11012 (setq default-mime-charset
11013 (with-current-buffer gnus-summary-buffer
11014 default-mime-charset)))
11015 (kill-local-variable 'default-mime-charset))))
11017 (defun gnus-summary-setup-default-charset ()
11018 "Setup newsgroup default charset."
11019 (if (equal gnus-newsgroup-name "nndraft:drafts")
11021 (setq gnus-newsgroup-charset nil)
11022 (make-local-variable 'default-mime-charset)
11023 (setq default-mime-charset nil))
11024 (let ((ignored-charsets
11025 (or gnus-newsgroup-ephemeral-ignored-charsets
11027 (and gnus-newsgroup-name
11028 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11029 gnus-newsgroup-ignored-charsets)))
11031 (setq gnus-newsgroup-charset
11032 (or gnus-newsgroup-ephemeral-charset
11033 (when (and gnus-newsgroup-name
11034 (setq charset (gnus-parameter-charset
11035 gnus-newsgroup-name)))
11036 (make-local-variable 'default-mime-charset)
11037 (setq default-mime-charset charset))
11038 gnus-default-charset))
11039 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11040 ignored-charsets))))
11046 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11047 "Display the current article buffer fully MIME-buttonized.
11048 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11049 treated as multipart/mixed."
11051 (require 'gnus-art)
11052 (let ((gnus-unbuttonized-mime-types nil)
11053 (gnus-mime-display-multipart-as-mixed show-all-parts))
11054 (gnus-summary-show-article)))
11056 (defun gnus-summary-repair-multipart (article)
11057 "Add a Content-Type header to a multipart article without one."
11058 (interactive (list (gnus-summary-article-number)))
11059 (gnus-with-article article
11060 (message-narrow-to-head)
11061 (message-remove-header "Mime-Version")
11062 (goto-char (point-max))
11063 (insert "Mime-Version: 1.0\n")
11065 (when (search-forward "\n--" nil t)
11066 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11067 (message-narrow-to-head)
11068 (message-remove-header "Content-Type")
11069 (goto-char (point-max))
11070 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11073 (let (gnus-mark-article-hook)
11074 (gnus-summary-select-article t t nil article)))
11076 (defun gnus-summary-toggle-display-buttonized ()
11077 "Toggle the buttonizing of the article buffer."
11079 (require 'gnus-art)
11080 (if (setq gnus-inhibit-mime-unbuttonizing
11081 (not gnus-inhibit-mime-unbuttonizing))
11082 (let ((gnus-unbuttonized-mime-types nil))
11083 (gnus-summary-show-article))
11084 (gnus-summary-show-article)))
11087 ;;; Intelli-mouse commmands
11090 (defun gnus-wheel-summary-scroll (event)
11092 (let ((amount (if (memq 'shift (event-modifiers event))
11093 (car gnus-wheel-scroll-amount)
11094 (cdr gnus-wheel-scroll-amount)))
11095 (direction (- (* (static-if (featurep 'xemacs)
11096 (event-button event)
11097 (cond ((eq 'mouse-4 (event-basic-type event))
11099 ((eq 'mouse-5 (event-basic-type event))
11103 (gnus-summary-scroll-up (* amount direction))
11104 (when (gnus-eval-in-buffer-window gnus-article-buffer
11107 (and (if (< 0 direction)
11108 (gnus-article-next-page 0)
11109 (gnus-article-prev-page 0)
11111 (if (setq edge (get-text-property
11112 (point-min) 'gnus-wheel-edge))
11113 (setq edge (* edge direction))
11116 (let ((buffer-read-only nil)
11117 (inhibit-read-only t))
11118 (put-text-property (point-min) (point-max)
11119 'gnus-wheel-edge direction)
11121 (or (> edge gnus-wheel-edge-resistance)
11122 (let ((buffer-read-only nil)
11123 (inhibit-read-only t))
11124 (put-text-property (point-min) (point-max)
11126 (* (1+ edge) direction))
11128 (eq last-command 'gnus-wheel-summary-scroll))))
11129 (gnus-summary-next-article nil nil (minusp direction)))))
11131 (defun gnus-wheel-install ()
11132 "Enable mouse wheel support on summary window."
11133 (when gnus-use-wheel
11135 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11137 (define-key gnus-summary-mode-map key
11138 'gnus-wheel-summary-scroll)))))
11140 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11143 ;;; Traditional PGP commmands
11146 (defun gnus-summary-decrypt-article (&optional force)
11147 "Decrypt the current article in traditional PGP way.
11148 This will have permanent effect only in mail groups.
11149 If FORCE is non-nil, allow editing of articles even in read-only
11152 (gnus-summary-select-article t)
11153 (gnus-eval-in-buffer-window gnus-article-buffer
11157 (goto-char (point-min))
11158 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11159 (error "Not a traditional PGP message!"))
11160 (let ((armor-start (match-beginning 0)))
11161 (if (and (pgg-decrypt-region armor-start (point-max))
11162 (or force (not (gnus-group-read-only-p))))
11163 (let ((inhibit-read-only t)
11165 (delete-region armor-start
11167 (re-search-forward "^-+END PGP" nil t)
11168 (beginning-of-line 2)
11170 (insert-buffer-substring pgg-output-buffer))))))))
11172 (defun gnus-summary-verify-article ()
11173 "Verify the current article in traditional PGP way."
11176 (set-buffer gnus-original-article-buffer)
11177 (goto-char (point-min))
11178 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11179 (error "Not a traditional PGP message!"))
11180 (re-search-forward "^-+END PGP" nil t)
11181 (beginning-of-line 2)
11182 (call-interactively (function pgg-verify-region))))
11185 ;;; Generic summary marking commands
11188 (defvar gnus-summary-marking-alist
11189 '((read gnus-del-mark "d")
11190 (unread gnus-unread-mark "u")
11191 (ticked gnus-ticked-mark "!")
11192 (dormant gnus-dormant-mark "?")
11193 (expirable gnus-expirable-mark "e"))
11194 "An alist of names/marks/keystrokes.")
11196 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11197 (defvar gnus-summary-mark-map)
11199 (defun gnus-summary-make-all-marking-commands ()
11200 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11201 (dolist (elem gnus-summary-marking-alist)
11202 (apply 'gnus-summary-make-marking-command elem)))
11204 (defun gnus-summary-make-marking-command (name mark keystroke)
11205 (let ((map (make-sparse-keymap)))
11206 (define-key gnus-summary-generic-mark-map keystroke map)
11207 (dolist (lway `((next "next" next nil "n")
11208 (next-unread "next unread" next t "N")
11209 (prev "previous" prev nil "p")
11210 (prev-unread "previous unread" prev t "P")
11211 (nomove "" nil nil ,keystroke)))
11212 (let ((func (gnus-summary-make-marking-command-1
11213 mark (car lway) lway name)))
11214 (setq func (eval func))
11215 (define-key map (nth 4 lway) func)))))
11217 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11219 (format "gnus-summary-put-mark-as-%s%s"
11220 name (if (eq way 'nomove)
11222 (concat "-" (symbol-name way)))))
11225 "Mark the current article as %s%s.
11226 If N, the prefix, then repeat N times.
11227 If N is negative, move in reverse order.
11228 The difference between N and the actual number of articles marked is
11230 name (car (cdr lway)))
11232 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11234 (defun gnus-summary-generic-mark (n mark move unread)
11235 "Mark N articles with MARK."
11236 (unless (eq major-mode 'gnus-summary-mode)
11237 (error "This command can only be used in the summary buffer"))
11238 (gnus-summary-show-thread)
11241 ((eq move 'next) 1)
11242 ((eq move 'prev) -1)
11244 (if (zerop nummove)
11248 nummove (* -1 nummove))))
11249 (while (and (> n 0)
11250 (gnus-summary-mark-article nil mark)
11251 (zerop (gnus-summary-next-subject nummove unread t)))
11254 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11255 (gnus-summary-recenter)
11256 (gnus-summary-position-point)
11257 (gnus-set-mode-line 'summary)
11260 (defun gnus-summary-insert-articles (articles)
11261 (when (setq articles
11262 (gnus-sorted-difference articles
11263 (mapcar (lambda (h)
11264 (mail-header-number h))
11265 gnus-newsgroup-headers)))
11266 (setq gnus-newsgroup-headers
11268 gnus-newsgroup-headers
11269 (gnus-fetch-headers articles)
11270 'gnus-article-sort-by-number))
11271 ;; Suppress duplicates?
11272 (when gnus-suppress-duplicates
11273 (gnus-dup-suppress-articles))
11275 ;; We might want to build some more threads first.
11276 (when (and gnus-fetch-old-headers
11277 (eq gnus-headers-retrieved-by 'nov))
11278 (if (eq gnus-fetch-old-headers 'invisible)
11279 (gnus-build-all-threads)
11280 (gnus-build-old-threads)))
11281 ;; Let the Gnus agent mark articles as read.
11283 (gnus-agent-get-undownloaded-list))
11284 ;; Remove list identifiers from subject
11285 (when gnus-list-identifiers
11286 (gnus-summary-remove-list-identifiers))
11287 ;; First and last article in this newsgroup.
11288 (when gnus-newsgroup-headers
11289 (setq gnus-newsgroup-begin
11290 (mail-header-number (car gnus-newsgroup-headers))
11292 (mail-header-number
11293 (gnus-last-element gnus-newsgroup-headers))))
11294 (when gnus-use-scoring
11295 (gnus-possibly-score-headers))))
11297 (defun gnus-summary-insert-old-articles (&optional all)
11298 "Insert all old articles in this group.
11299 If ALL is non-nil, already read articles become readable.
11300 If ALL is a number, fetch this number of articles."
11303 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11306 (gnus-sorted-difference
11307 (gnus-uncompress-range (list gnus-newsgroup-active))
11309 (setq len (length older))
11314 (setq older (last older all))))
11317 (if (and (numberp gnus-large-newsgroup)
11318 (> len gnus-large-newsgroup))
11319 (let* ((cursor-in-echo-area nil)
11320 (initial (gnus-parameter-large-newsgroup-initial
11321 gnus-newsgroup-name))
11325 "How many articles from %s (%s %d): "
11327 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11328 (if initial "max" "default")
11331 (cons (number-to-string initial)
11333 (unless (string-match "^[ \t]*$" input)
11334 (setq all (string-to-number input))
11336 (setq older (last older all))))))))
11338 (message "No old news.")
11339 (gnus-summary-insert-articles older)
11340 (gnus-summary-limit (gnus-sorted-nunion old older))))
11341 (gnus-summary-position-point)))
11343 (defun gnus-summary-insert-new-articles ()
11344 "Insert all new articles in this group."
11347 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11348 (old-active gnus-newsgroup-active)
11349 (nnmail-fetched-sources (list t))
11351 (setq gnus-newsgroup-active
11352 (gnus-activate-group gnus-newsgroup-name 'scan))
11353 (setq i (1+ (cdr old-active)))
11354 (while (<= i (cdr gnus-newsgroup-active))
11358 (message "No gnus is bad news.")
11359 (setq new (nreverse new))
11360 (gnus-summary-insert-articles new)
11361 (setq gnus-newsgroup-unreads
11362 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11363 (gnus-summary-limit (gnus-sorted-nunion old new))))
11364 (gnus-summary-position-point)))
11366 (gnus-summary-make-all-marking-commands)
11368 (gnus-ems-redefine)
11370 (provide 'gnus-sum)
11372 (run-hooks 'gnus-sum-load-hook)
11374 ;;; gnus-sum.el ends here