1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
42 (autoload 'gnus-cache-write-active "gnus-cache")
43 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
44 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
46 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
47 "Deuglify broken Outlook (Express) articles and redisplay."
49 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
50 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
51 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
53 (defcustom gnus-kill-summary-on-exit t
54 "*If non-nil, kill the summary buffer when you exit from it.
55 If nil, the summary will become a \"*Dead Summary*\" buffer, and
56 it will be killed sometime later."
57 :group 'gnus-summary-exit
60 (defcustom gnus-fetch-old-headers nil
61 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
62 If an unread article in the group refers to an older, already read (or
63 just marked as read) article, the old article will not normally be
64 displayed in the Summary buffer. If this variable is non-nil, Gnus
65 will attempt to grab the headers to the old articles, and thereby
66 build complete threads. If it has the value `some', only enough
67 headers to connect otherwise loose threads will be displayed. This
68 variable can also be a number. In that case, no more than that number
69 of old headers will be fetched. If it has the value `invisible', all
70 old headers will be fetched, but none will be displayed.
72 The server has to support NOV for any of this to work."
74 :type '(choice (const :tag "off" nil)
77 (sexp :menu-tag "other" t)))
79 (defcustom gnus-refer-thread-limit 200
80 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
81 If t, fetch all the available old headers."
84 (sexp :menu-tag "other" t)))
86 (defcustom gnus-summary-make-false-root 'adopt
87 "*nil means that Gnus won't gather loose threads.
88 If the root of a thread has expired or been read in a previous
89 session, the information necessary to build a complete thread has been
90 lost. Instead of having many small sub-threads from this original thread
91 scattered all over the summary buffer, Gnus can gather them.
93 If non-nil, Gnus will try to gather all loose sub-threads from an
94 original thread into one large thread.
96 If this variable is non-nil, it should be one of `none', `adopt',
99 If this variable is `none', Gnus will not make a false root, but just
100 present the sub-threads after another.
101 If this variable is `dummy', Gnus will create a dummy root that will
102 have all the sub-threads as children.
103 If this variable is `adopt', Gnus will make one of the \"children\"
104 the parent and mark all the step-children as such.
105 If this variable is `empty', the \"children\" are printed with empty
106 subject fields. (Or rather, they will be printed with a string
107 given by the `gnus-summary-same-subject' variable.)"
109 :type '(choice (const :tag "off" nil)
115 (defcustom gnus-summary-make-false-root-always nil
116 "Always make a false dummy root."
120 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
121 "*A regexp to match subjects to be excluded from loose thread gathering.
122 As loose thread gathering is done on subjects only, that means that
123 there can be many false gatherings performed. By rooting out certain
124 common subjects, gathering might become saner."
128 (defcustom gnus-summary-gather-subject-limit nil
129 "*Maximum length of subject comparisons when gathering loose threads.
130 Use nil to compare full subjects. Setting this variable to a low
131 number will help gather threads that have been corrupted by
132 newsreaders chopping off subject lines, but it might also mean that
133 unrelated articles that have subject that happen to begin with the
134 same few characters will be incorrectly gathered.
136 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
139 :type '(choice (const :tag "off" nil)
141 (sexp :menu-tag "on" t)))
143 (defcustom gnus-simplify-subject-functions nil
144 "List of functions taking a string argument that simplify subjects.
145 The functions are applied recursively.
147 Useful functions to put in this list include:
148 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
149 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
151 :type '(repeat function))
153 (defcustom gnus-simplify-ignored-prefixes nil
154 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
156 :type '(choice (const :tag "off" nil)
159 (defcustom gnus-build-sparse-threads nil
160 "*If non-nil, fill in the gaps in threads.
161 If `some', only fill in the gaps that are needed to tie loose threads
162 together. If `more', fill in all leaf nodes that Gnus can find. If
163 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
165 :type '(choice (const :tag "off" nil)
168 (sexp :menu-tag "all" t)))
170 (defcustom gnus-summary-thread-gathering-function
171 'gnus-gather-threads-by-subject
172 "*Function used for gathering loose threads.
173 There are two pre-defined functions: `gnus-gather-threads-by-subject',
174 which only takes Subjects into consideration; and
175 `gnus-gather-threads-by-references', which compared the References
176 headers of the articles to find matches."
178 :type '(radio (function-item gnus-gather-threads-by-subject)
179 (function-item gnus-gather-threads-by-references)
180 (function :tag "other")))
182 (defcustom gnus-summary-same-subject ""
183 "*String indicating that the current article has the same subject as the previous.
184 This variable will only be used if the value of
185 `gnus-summary-make-false-root' is `empty'."
186 :group 'gnus-summary-format
189 (defcustom gnus-summary-goto-unread t
190 "*If t, many commands will go to the next unread article.
191 This applies to marking commands as well as other commands that
192 \"naturally\" select the next article, like, for instance, `SPC' at
193 the end of an article.
195 If nil, the marking commands do NOT go to the next unread article
196 \(they go to the next article instead). If `never', commands that
197 usually go to the next unread article, will go to the next article,
198 whether it is read or not."
199 :group 'gnus-summary-marks
200 :link '(custom-manual "(gnus)Setting Marks")
201 :type '(choice (const :tag "off" nil)
203 (sexp :menu-tag "on" t)))
205 (defcustom gnus-summary-default-score 0
206 "*Default article score level.
207 All scores generated by the score files will be added to this score.
208 If this variable is nil, scoring will be disabled."
209 :group 'gnus-score-default
210 :type '(choice (const :tag "disable")
213 (defcustom gnus-summary-default-high-score 0
214 "*Default threshold for a high scored article.
215 An article will be highlighted as high scored if its score is greater
217 :group 'gnus-score-default
220 (defcustom gnus-summary-default-low-score 0
221 "*Default threshold for a low scored article.
222 An article will be highlighted as low scored if its score is smaller
224 :group 'gnus-score-default
227 (defcustom gnus-summary-zcore-fuzz 0
228 "*Fuzziness factor for the zcore in the summary buffer.
229 Articles with scores closer than this to `gnus-summary-default-score'
231 :group 'gnus-summary-format
234 (defcustom gnus-simplify-subject-fuzzy-regexp nil
235 "*Strings to be removed when doing fuzzy matches.
236 This can either be a regular expression or list of regular expressions
237 that will be removed from subject strings if fuzzy subject
238 simplification is selected."
240 :type '(repeat regexp))
242 (defcustom gnus-show-threads t
243 "*If non-nil, display threads in summary mode."
247 (defcustom gnus-thread-hide-subtree nil
248 "*If non-nil, hide all threads initially.
249 This can be a predicate specifier which says which threads to hide.
250 If threads are hidden, you have to run the command
251 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
252 to expose hidden threads."
256 (defcustom gnus-thread-hide-killed t
257 "*If non-nil, hide killed threads automatically."
261 (defcustom gnus-thread-ignore-subject t
262 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
263 If nil, articles that have different subjects from their parents will
264 start separate threads."
268 (defcustom gnus-thread-operation-ignore-subject t
269 "*If non-nil, subjects will be ignored when doing thread commands.
270 This affects commands like `gnus-summary-kill-thread' and
271 `gnus-summary-lower-thread'.
273 If this variable is nil, articles in the same thread with different
274 subjects will not be included in the operation in question. If this
275 variable is `fuzzy', only articles that have subjects that are fuzzily
276 equal will be included."
278 :type '(choice (const :tag "off" nil)
282 (defcustom gnus-thread-indent-level 4
283 "*Number that says how much each sub-thread should be indented."
287 (defcustom gnus-auto-extend-newsgroup t
288 "*If non-nil, extend newsgroup forward and backward when requested."
289 :group 'gnus-summary-choose
292 (defcustom gnus-auto-select-first t
293 "*If non-nil, select the article under point.
294 Which article this is is controlled by the `gnus-auto-select-subject'
297 If you want to prevent automatic selection of articles in some
298 newsgroups, set the variable to nil in `gnus-select-group-hook'."
299 :group 'gnus-group-select
300 :type '(choice (const :tag "none" nil)
301 (sexp :menu-tag "first" t)))
303 (defcustom gnus-auto-select-subject 'unread
304 "*Says what subject to place under point when entering a group.
306 This variable can either be the symbols `first' (place point on the
307 first subject), `unread' (place point on the subject line of the first
308 unread article), `best' (place point on the subject line of the
309 higest-scored article), `unseen' (place point on the subject line of
310 the first unseen article), 'unseen-or-unread' (place point on the subject
311 line of the first unseen article or, if all article have been seen, on the
312 subject line of the first unread article), or a function to be called to
313 place point on some subject line."
314 :group 'gnus-group-select
315 :type '(choice (const best)
319 (const unseen-or-unread)))
321 (defcustom gnus-auto-select-next t
322 "*If non-nil, offer to go to the next group from the end of the previous.
323 If the value is t and the next newsgroup is empty, Gnus will exit
324 summary mode and go back to group mode. If the value is neither nil
325 nor t, Gnus will select the following unread newsgroup. In
326 particular, if the value is the symbol `quietly', the next unread
327 newsgroup will be selected without any confirmation, and if it is
328 `almost-quietly', the next group will be selected without any
329 confirmation if you are located on the last article in the group.
330 Finally, if this variable is `slightly-quietly', the `Z n' command
331 will go to the next group without confirmation."
332 :group 'gnus-summary-maneuvering
333 :type '(choice (const :tag "off" nil)
335 (const almost-quietly)
336 (const slightly-quietly)
337 (sexp :menu-tag "on" t)))
339 (defcustom gnus-auto-select-same nil
340 "*If non-nil, select the next article with the same subject.
341 If there are no more articles with the same subject, go to
342 the first unread article."
343 :group 'gnus-summary-maneuvering
346 (defcustom gnus-summary-check-current nil
347 "*If non-nil, consider the current article when moving.
348 The \"unread\" movement commands will stay on the same line if the
349 current article is unread."
350 :group 'gnus-summary-maneuvering
353 (defcustom gnus-auto-center-summary t
354 "*If non-nil, always center the current summary buffer.
355 In particular, if `vertical' do only vertical recentering. If non-nil
356 and non-`vertical', do both horizontal and vertical recentering."
357 :group 'gnus-summary-maneuvering
358 :type '(choice (const :tag "none" nil)
360 (integer :tag "height")
361 (sexp :menu-tag "both" t)))
363 (defvar gnus-auto-center-group t
364 "*If non-nil, always center the group buffer.")
366 (defcustom gnus-show-all-headers nil
367 "*If non-nil, don't hide any headers."
368 :group 'gnus-article-hiding
369 :group 'gnus-article-headers
372 (defcustom gnus-summary-ignore-duplicates nil
373 "*If non-nil, ignore articles with identical Message-ID headers."
377 (defcustom gnus-single-article-buffer t
378 "*If non-nil, display all articles in the same buffer.
379 If nil, each group will get its own article buffer."
380 :group 'gnus-article-various
383 (defcustom gnus-break-pages t
384 "*If non-nil, do page breaking on articles.
385 The page delimiter is specified by the `gnus-page-delimiter'
387 :group 'gnus-article-various
390 (defcustom gnus-move-split-methods nil
391 "*Variable used to suggest where articles are to be moved to.
392 It uses the same syntax as the `gnus-split-methods' variable.
393 However, whereas `gnus-split-methods' specifies file names as targets,
394 this variable specifies group names."
395 :group 'gnus-summary-mail
396 :type '(repeat (choice (list :value (fun) function)
397 (cons :value ("" "") regexp (repeat string))
400 (defcustom gnus-unread-mark ? ;Whitespace
401 "*Mark used for unread articles."
402 :group 'gnus-summary-marks
405 (defcustom gnus-ticked-mark ?!
406 "*Mark used for ticked articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-dormant-mark ??
411 "*Mark used for dormant articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-del-mark ?r
416 "*Mark used for del'd articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-read-mark ?R
421 "*Mark used for read articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-expirable-mark ?E
426 "*Mark used for expirable articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-killed-mark ?K
431 "*Mark used for killed articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-spam-mark ?$
436 "*Mark used for spam articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-souped-mark ?F
441 "*Mark used for souped articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-kill-file-mark ?X
446 "*Mark used for articles killed by kill files."
447 :group 'gnus-summary-marks
450 (defcustom gnus-low-score-mark ?Y
451 "*Mark used for articles with a low score."
452 :group 'gnus-summary-marks
455 (defcustom gnus-catchup-mark ?C
456 "*Mark used for articles that are caught up."
457 :group 'gnus-summary-marks
460 (defcustom gnus-replied-mark ?A
461 "*Mark used for articles that have been replied to."
462 :group 'gnus-summary-marks
465 (defcustom gnus-forwarded-mark ?F
466 "*Mark used for articles that have been forwarded."
467 :group 'gnus-summary-marks
470 (defcustom gnus-recent-mark ?N
471 "*Mark used for articles that are recent."
472 :group 'gnus-summary-marks
475 (defcustom gnus-cached-mark ?*
476 "*Mark used for articles that are in the cache."
477 :group 'gnus-summary-marks
480 (defcustom gnus-saved-mark ?S
481 "*Mark used for articles that have been saved."
482 :group 'gnus-summary-marks
485 (defcustom gnus-unseen-mark ?.
486 "*Mark used for articles that haven't been seen."
487 :group 'gnus-summary-marks
490 (defcustom gnus-no-mark ? ;Whitespace
491 "*Mark used for articles that have no other secondary mark."
492 :group 'gnus-summary-marks
495 (defcustom gnus-ancient-mark ?O
496 "*Mark used for ancient articles."
497 :group 'gnus-summary-marks
500 (defcustom gnus-sparse-mark ?Q
501 "*Mark used for sparsely reffed articles."
502 :group 'gnus-summary-marks
505 (defcustom gnus-canceled-mark ?G
506 "*Mark used for canceled articles."
507 :group 'gnus-summary-marks
510 (defcustom gnus-duplicate-mark ?M
511 "*Mark used for duplicate articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-undownloaded-mark ?-
516 "*Mark used for articles that weren't downloaded."
517 :group 'gnus-summary-marks
520 (defcustom gnus-downloaded-mark ?+
521 "*Mark used for articles that were downloaded."
522 :group 'gnus-summary-marks
525 (defcustom gnus-downloadable-mark ?%
526 "*Mark used for articles that are to be downloaded."
527 :group 'gnus-summary-marks
530 (defcustom gnus-unsendable-mark ?=
531 "*Mark used for articles that won't be sent."
532 :group 'gnus-summary-marks
535 (defcustom gnus-score-over-mark ?+
536 "*Score mark used for articles with high scores."
537 :group 'gnus-summary-marks
540 (defcustom gnus-score-below-mark ?-
541 "*Score mark used for articles with low scores."
542 :group 'gnus-summary-marks
545 (defcustom gnus-empty-thread-mark ? ;Whitespace
546 "*There is no thread under the article."
547 :group 'gnus-summary-marks
550 (defcustom gnus-not-empty-thread-mark ?=
551 "*There is a thread under the article."
552 :group 'gnus-summary-marks
555 (defcustom gnus-view-pseudo-asynchronously nil
556 "*If non-nil, Gnus will view pseudo-articles asynchronously."
557 :group 'gnus-extract-view
560 (defcustom gnus-auto-expirable-marks
561 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
562 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
563 gnus-souped-mark gnus-duplicate-mark)
564 "*The list of marks converted into expiration if a group is auto-expirable."
567 :type '(repeat character))
569 (defcustom gnus-inhibit-user-auto-expire t
570 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
575 (defcustom gnus-view-pseudos nil
576 "*If `automatic', pseudo-articles will be viewed automatically.
577 If `not-confirm', pseudos will be viewed automatically, and the user
578 will not be asked to confirm the command."
579 :group 'gnus-extract-view
580 :type '(choice (const :tag "off" nil)
582 (const not-confirm)))
584 (defcustom gnus-view-pseudos-separately t
585 "*If non-nil, one pseudo-article will be created for each file to be viewed.
586 If nil, all files that use the same viewing command will be given as a
587 list of parameters to that command."
588 :group 'gnus-extract-view
591 (defcustom gnus-insert-pseudo-articles t
592 "*If non-nil, insert pseudo-articles when decoding articles."
593 :group 'gnus-extract-view
596 (defcustom gnus-summary-dummy-line-format
598 "*The format specification for the dummy roots in the summary buffer.
599 It works along the same lines as a normal formatting string,
600 with some simple extensions.
604 General format specifiers can also be used.
605 See `(gnus)Formatting Variables'."
606 :link '(custom-manual "(gnus)Formatting Variables")
607 :group 'gnus-threading
610 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
611 "*The format specification for the summary mode line.
612 It works along the same lines as a normal formatting string,
613 with some simple extensions:
616 %p Unprefixed group name
617 %A Current article number
618 %z Current article score
620 %U Number of unread articles in the group
621 %e Number of unselected articles in the group
622 %Z A string with unread/unselected article counts
623 %g Shortish group name
624 %S Subject of the current article
626 %s Current score file name
627 %d Number of dormant articles
628 %r Number of articles that have been marked as read in this session
629 %E Number of articles expunged by the score files"
630 :group 'gnus-summary-format
633 (defcustom gnus-list-identifiers nil
634 "Regexp that matches list identifiers to be removed from subject.
635 This can also be a list of regexps."
637 :group 'gnus-summary-format
638 :group 'gnus-article-hiding
639 :type '(choice (const :tag "none" nil)
641 (repeat :value (".*") regexp)))
643 (defcustom gnus-summary-mark-below 0
644 "*Mark all articles with a score below this variable as read.
645 This variable is local to each summary buffer and usually set by the
647 :group 'gnus-score-default
650 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
651 "*List of functions used for sorting articles in the summary buffer.
653 Each function takes two articles and returns non-nil if the first
654 article should be sorted before the other. If you use more than one
655 function, the primary sort function should be the last. You should
656 probably always include `gnus-article-sort-by-number' in the list of
657 sorting functions -- preferably first. Also note that sorting by date
658 is often much slower than sorting by number, and the sorting order is
659 very similar. (Sorting by date means sorting by the time the message
660 was sent, sorting by number means sorting by arrival time.)
662 Ready-made functions include `gnus-article-sort-by-number',
663 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
664 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
665 and `gnus-article-sort-by-score'.
667 When threading is turned on, the variable `gnus-thread-sort-functions'
668 controls how articles are sorted."
669 :group 'gnus-summary-sort
670 :type '(repeat (choice (function-item gnus-article-sort-by-number)
671 (function-item gnus-article-sort-by-author)
672 (function-item gnus-article-sort-by-subject)
673 (function-item gnus-article-sort-by-date)
674 (function-item gnus-article-sort-by-score)
675 (function-item gnus-article-sort-by-random)
676 (function :tag "other"))))
678 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
679 "*List of functions used for sorting threads in the summary buffer.
680 By default, threads are sorted by article number.
682 Each function takes two threads and returns non-nil if the first
683 thread should be sorted before the other. If you use more than one
684 function, the primary sort function should be the last. You should
685 probably always include `gnus-thread-sort-by-number' in the list of
686 sorting functions -- preferably first. Also note that sorting by date
687 is often much slower than sorting by number, and the sorting order is
688 very similar. (Sorting by date means sorting by the time the message
689 was sent, sorting by number means sorting by arrival time.)
691 Ready-made functions include `gnus-thread-sort-by-number',
692 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
693 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
694 `gnus-thread-sort-by-most-recent-number',
695 `gnus-thread-sort-by-most-recent-date',
696 `gnus-thread-sort-by-random', and
697 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
699 When threading is turned off, the variable
700 `gnus-article-sort-functions' controls how articles are sorted."
701 :group 'gnus-summary-sort
702 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
703 (function-item gnus-thread-sort-by-author)
704 (function-item gnus-thread-sort-by-subject)
705 (function-item gnus-thread-sort-by-date)
706 (function-item gnus-thread-sort-by-score)
707 (function-item gnus-thread-sort-by-total-score)
708 (function-item gnus-thread-sort-by-random)
709 (function :tag "other"))))
711 (defcustom gnus-thread-score-function '+
712 "*Function used for calculating the total score of a thread.
714 The function is called with the scores of the article and each
715 subthread and should then return the score of the thread.
717 Some functions you can use are `+', `max', or `min'."
718 :group 'gnus-summary-sort
721 (defcustom gnus-summary-expunge-below nil
722 "All articles that have a score less than this variable will be expunged.
723 This variable is local to the summary buffers."
724 :group 'gnus-score-default
725 :type '(choice (const :tag "off" nil)
728 (defcustom gnus-thread-expunge-below nil
729 "All threads that have a total score less than this variable will be expunged.
730 See `gnus-thread-score-function' for en explanation of what a
733 This variable is local to the summary buffers."
734 :group 'gnus-threading
735 :group 'gnus-score-default
736 :type '(choice (const :tag "off" nil)
739 (defcustom gnus-summary-mode-hook nil
740 "*A hook for Gnus summary mode.
741 This hook is run before any variables are set in the summary buffer."
742 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
743 :group 'gnus-summary-various
746 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
747 (when (featurep 'xemacs)
748 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
749 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
750 (add-hook 'gnus-summary-mode-hook
751 'gnus-xmas-switch-horizontal-scrollbar-off))
753 (defcustom gnus-summary-menu-hook nil
754 "*Hook run after the creation of the summary mode menu."
755 :group 'gnus-summary-visual
758 (defcustom gnus-summary-exit-hook nil
759 "*A hook called on exit from the summary buffer.
760 It will be called with point in the group buffer."
761 :group 'gnus-summary-exit
764 (defcustom gnus-summary-prepare-hook nil
765 "*A hook called after the summary buffer has been generated.
766 If you want to modify the summary buffer, you can use this hook."
767 :group 'gnus-summary-various
770 (defcustom gnus-summary-prepared-hook nil
771 "*A hook called as the last thing after the summary buffer has been generated."
772 :group 'gnus-summary-various
775 (defcustom gnus-summary-generate-hook nil
776 "*A hook run just before generating the summary buffer.
777 This hook is commonly used to customize threading variables and the
779 :group 'gnus-summary-various
782 (defcustom gnus-select-group-hook nil
783 "*A hook called when a newsgroup is selected.
785 If you'd like to simplify subjects like the
786 `gnus-summary-next-same-subject' command does, you can use the
789 (add-hook gnus-select-group-hook
791 (mapcar (lambda (header)
792 (mail-header-set-subject
794 (gnus-simplify-subject
795 (mail-header-subject header) 're-only)))
796 gnus-newsgroup-headers)))"
797 :group 'gnus-group-select
800 (defcustom gnus-select-article-hook nil
801 "*A hook called when an article is selected."
802 :group 'gnus-summary-choose
803 :options '(gnus-agent-fetch-selected-article)
806 (defcustom gnus-visual-mark-article-hook
807 (list 'gnus-highlight-selected-summary)
808 "*Hook run after selecting an article in the summary buffer.
809 It is meant to be used for highlighting the article in some way. It
810 is not run if `gnus-visual' is nil."
811 :group 'gnus-summary-visual
814 (defcustom gnus-parse-headers-hook nil
815 "*A hook called before parsing the headers."
819 (defcustom gnus-exit-group-hook nil
820 "*A hook called when exiting summary mode.
821 This hook is not called from the non-updating exit commands like `Q'."
825 (defcustom gnus-summary-update-hook
826 (list 'gnus-summary-highlight-line)
827 "*A hook called when a summary line is changed.
828 The hook will not be called if `gnus-visual' is nil.
830 The default function `gnus-summary-highlight-line' will
831 highlight the line according to the `gnus-summary-highlight'
833 :group 'gnus-summary-visual
836 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
837 "*A hook called when an article is selected for the first time.
838 The hook is intended to mark an article as read (or unread)
839 automatically when it is selected."
840 :group 'gnus-summary-choose
843 (defcustom gnus-group-no-more-groups-hook nil
844 "*A hook run when returning to group mode having no more (unread) groups."
845 :group 'gnus-group-select
848 (defcustom gnus-ps-print-hook nil
849 "*A hook run before ps-printing something from Gnus."
853 (defcustom gnus-summary-article-move-hook nil
854 "*A hook called after an article is moved, copied, respooled, or crossposted."
858 (defcustom gnus-summary-article-delete-hook nil
859 "*A hook called after an article is deleted."
863 (defcustom gnus-summary-article-expire-hook nil
864 "*A hook called after an article is expired."
868 (defcustom gnus-summary-display-arrow
869 (and (fboundp 'display-graphic-p)
871 "*If non-nil, display an arrow highlighting the current article."
876 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
877 "Face used for highlighting the current article in the summary buffer."
878 :group 'gnus-summary-visual
881 (defvar gnus-tmp-downloaded nil)
883 (defcustom gnus-summary-highlight
884 '(((eq mark gnus-canceled-mark)
885 . gnus-summary-cancelled-face)
886 ((and uncached (> score default-high))
887 . gnus-summary-high-undownloaded-face)
888 ((and uncached (< score default-low))
889 . gnus-summary-low-undownloaded-face)
891 . gnus-summary-normal-undownloaded-face)
892 ((and (> score default-high)
893 (or (eq mark gnus-dormant-mark)
894 (eq mark gnus-ticked-mark)))
895 . gnus-summary-high-ticked-face)
896 ((and (< score default-low)
897 (or (eq mark gnus-dormant-mark)
898 (eq mark gnus-ticked-mark)))
899 . gnus-summary-low-ticked-face)
900 ((or (eq mark gnus-dormant-mark)
901 (eq mark gnus-ticked-mark))
902 . gnus-summary-normal-ticked-face)
903 ((and (> score default-high) (eq mark gnus-ancient-mark))
904 . gnus-summary-high-ancient-face)
905 ((and (< score default-low) (eq mark gnus-ancient-mark))
906 . gnus-summary-low-ancient-face)
907 ((eq mark gnus-ancient-mark)
908 . gnus-summary-normal-ancient-face)
909 ((and (> score default-high) (eq mark gnus-unread-mark))
910 . gnus-summary-high-unread-face)
911 ((and (< score default-low) (eq mark gnus-unread-mark))
912 . gnus-summary-low-unread-face)
913 ((eq mark gnus-unread-mark)
914 . gnus-summary-normal-unread-face)
915 ((> score default-high)
916 . gnus-summary-high-read-face)
917 ((< score default-low)
918 . gnus-summary-low-read-face)
920 . gnus-summary-normal-read-face))
921 "*Controls the highlighting of summary buffer lines.
923 A list of (FORM . FACE) pairs. When deciding how a a particular
924 summary line should be displayed, each form is evaluated. The content
925 of the face field after the first true form is used. You can change
926 how those summary lines are displayed, by editing the face field.
928 You can use the following variables in the FORM field.
930 score: The article's score
931 default: The default article score.
932 default-high: The default score for high scored articles.
933 default-low: The default score for low scored articles.
934 below: The score below which articles are automatically marked as read.
935 mark: The articles mark."
936 :group 'gnus-summary-visual
937 :type '(repeat (cons (sexp :tag "Form" nil)
940 (defcustom gnus-alter-header-function nil
941 "Function called to allow alteration of article header structures.
942 The function is called with one parameter, the article header vector,
943 which it may alter in any way."
944 :type '(choice (const :tag "None" nil)
946 :group 'gnus-summary)
948 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
949 "Variable that says which function should be used to decode a string with encoded words.")
951 (defcustom gnus-extra-headers '(To Newsgroups)
952 "*Extra headers to parse."
955 :type '(repeat symbol))
957 (defcustom gnus-ignored-from-addresses
958 (and user-mail-address (regexp-quote user-mail-address))
959 "*Regexp of From headers that may be suppressed in favor of To headers."
964 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
965 "List of charsets that should be ignored.
966 When these charsets are used in the \"charset\" parameter, the
967 default charset will be used instead."
969 :type '(repeat symbol)
970 :group 'gnus-charset)
972 (gnus-define-group-parameter
976 "Return the ignored charsets of GROUP."
977 :variable gnus-group-ignored-charsets-alist
979 '(("alt\\.chinese\\.text" iso-8859-1))
981 "Alist of regexps (to match group names) and charsets that should be ignored.
982 When these charsets are used in the \"charset\" parameter, the
983 default charset will be used instead."
984 :variable-group gnus-charset
985 :variable-type '(repeat (cons (regexp :tag "Group")
987 :parameter-type '(choice :tag "Ignored charsets"
990 :parameter-document "\
991 List of charsets that should be ignored.
993 When these charsets are used in the \"charset\" parameter, the
994 default charset will be used instead.")
996 (defcustom gnus-group-highlight-words-alist nil
997 "Alist of group regexps and highlight regexps.
998 This variable uses the same syntax as `gnus-emphasis-alist'."
1000 :type '(repeat (cons (regexp :tag "Group")
1001 (repeat (list (regexp :tag "Highlight regexp")
1002 (number :tag "Group for entire word" 0)
1003 (number :tag "Group for displayed part" 0)
1005 gnus-emphasis-highlight-words)))))
1006 :group 'gnus-summary-visual)
1008 (defcustom gnus-summary-show-article-charset-alist
1010 "Alist of number and charset.
1011 The article will be shown with the charset corresponding to the
1013 For example: ((1 . cn-gb-2312) (2 . big5))."
1015 :type '(repeat (cons (number :tag "Argument" 1)
1016 (symbol :tag "Charset")))
1017 :group 'gnus-charset)
1019 (defcustom gnus-preserve-marks t
1020 "Whether marks are preserved when moving, copying and respooling messages."
1023 :group 'gnus-summary-marks)
1025 (defcustom gnus-alter-articles-to-read-function nil
1026 "Function to be called to alter the list of articles to be selected."
1027 :type '(choice (const nil) function)
1028 :group 'gnus-summary)
1030 (defcustom gnus-orphan-score nil
1031 "*All orphans get this score added. Set in the score file."
1032 :group 'gnus-score-default
1033 :type '(choice (const nil)
1036 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1037 "*A regexp to match MIME parts when saving multiple parts of a message
1038 with gnus-summary-save-parts (X m). This regexp will be used by default
1039 when prompting the user for which type of files to save."
1040 :group 'gnus-summary
1043 (defcustom gnus-read-all-available-headers nil
1044 "Whether Gnus should parse all headers made available to it.
1045 This is mostly relevant for slow backends where the user may
1046 wish to widen the summary buffer to include all headers
1047 that were fetched. Say, for nnultimate groups."
1048 :group 'gnus-summary
1049 :type '(choice boolean regexp))
1051 (defcustom gnus-summary-muttprint-program "muttprint"
1052 "Command (and optional arguments) used to run Muttprint."
1054 :group 'gnus-summary
1057 (defcustom gnus-article-loose-mime nil
1058 "If non-nil, don't require MIME-Version header.
1059 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1060 supply the MIME-Version header or deliberately strip it From the mail.
1061 Set it to non-nil, Gnus will treat some articles as MIME even if
1062 the MIME-Version header is missed."
1065 :group 'gnus-article)
1067 (defcustom gnus-article-emulate-mime t
1068 "If non-nil, use MIME emulation for uuencode and the like.
1069 This means that Gnus will search message bodies for text that look
1070 like uuencoded bits, yEncoded bits, and so on, and present that using
1071 the normal Gnus MIME machinery."
1073 :group 'gnus-article)
1075 ;;; Internal variables
1077 (defvar gnus-summary-display-cache nil)
1078 (defvar gnus-article-mime-handles nil)
1079 (defvar gnus-article-decoded-p nil)
1080 (defvar gnus-article-charset nil)
1081 (defvar gnus-article-ignored-charsets nil)
1082 (defvar gnus-scores-exclude-files nil)
1083 (defvar gnus-page-broken nil)
1085 (defvar gnus-original-article nil)
1086 (defvar gnus-article-internal-prepare-hook nil)
1087 (defvar gnus-newsgroup-process-stack nil)
1089 (defvar gnus-thread-indent-array nil)
1090 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1091 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1092 "Function called to sort the articles within a thread after it has been gathered together.")
1094 (defvar gnus-summary-save-parts-type-history nil)
1095 (defvar gnus-summary-save-parts-last-directory nil)
1097 ;; Avoid highlighting in kill files.
1098 (defvar gnus-summary-inhibit-highlight nil)
1099 (defvar gnus-newsgroup-selected-overlay nil)
1100 (defvar gnus-inhibit-limiting nil)
1101 (defvar gnus-newsgroup-adaptive-score-file nil)
1102 (defvar gnus-current-score-file nil)
1103 (defvar gnus-current-move-group nil)
1104 (defvar gnus-current-copy-group nil)
1105 (defvar gnus-current-crosspost-group nil)
1106 (defvar gnus-newsgroup-display nil)
1108 (defvar gnus-newsgroup-dependencies nil)
1109 (defvar gnus-newsgroup-adaptive nil)
1110 (defvar gnus-summary-display-article-function nil)
1111 (defvar gnus-summary-highlight-line-function nil
1112 "Function called after highlighting a summary line.")
1114 (defvar gnus-summary-line-format-alist
1115 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1116 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1117 (?s gnus-tmp-subject-or-nil ?s)
1118 (?n gnus-tmp-name ?s)
1119 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1121 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1123 (?F gnus-tmp-from ?s)
1124 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1125 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1126 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1127 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1128 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1129 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1130 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1131 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1132 (?L gnus-tmp-lines ?s)
1133 (?O gnus-tmp-downloaded ?c)
1134 (?I gnus-tmp-indentation ?s)
1135 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1136 (?R gnus-tmp-replied ?c)
1137 (?\[ gnus-tmp-opening-bracket ?c)
1138 (?\] gnus-tmp-closing-bracket ?c)
1139 (?\> (make-string gnus-tmp-level ? ) ?s)
1140 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1141 (?i gnus-tmp-score ?d)
1142 (?z gnus-tmp-score-char ?c)
1143 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1144 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1145 (?U gnus-tmp-unread ?c)
1146 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1148 (?t (gnus-summary-number-of-articles-in-thread
1149 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1151 (?e (gnus-summary-number-of-articles-in-thread
1152 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1154 (?u gnus-tmp-user-defined ?s)
1155 (?P (gnus-pick-line-number) ?d)
1156 (?B gnus-tmp-thread-tree-header-string ?s)
1157 (user-date (gnus-user-date
1158 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1159 "An alist of format specifications that can appear in summary lines.
1160 These are paired with what variables they correspond with, along with
1161 the type of the variable (string, integer, character, etc).")
1163 (defvar gnus-summary-dummy-line-format-alist
1164 `((?S gnus-tmp-subject ?s)
1165 (?N gnus-tmp-number ?d)
1166 (?u gnus-tmp-user-defined ?s)))
1168 (defvar gnus-summary-mode-line-format-alist
1169 `((?G gnus-tmp-group-name ?s)
1170 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1171 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1172 (?A gnus-tmp-article-number ?d)
1173 (?Z gnus-tmp-unread-and-unselected ?s)
1174 (?V gnus-version ?s)
1175 (?U gnus-tmp-unread-and-unticked ?d)
1176 (?S gnus-tmp-subject ?s)
1177 (?e gnus-tmp-unselected ?d)
1178 (?u gnus-tmp-user-defined ?s)
1179 (?d (length gnus-newsgroup-dormant) ?d)
1180 (?t (length gnus-newsgroup-marked) ?d)
1181 (?h (length gnus-newsgroup-spam-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-last-shell-command nil
1191 "Default shell command on article.")
1193 (defvar gnus-newsgroup-agentized nil
1194 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1195 (defvar gnus-newsgroup-begin nil)
1196 (defvar gnus-newsgroup-end nil)
1197 (defvar gnus-newsgroup-last-rmail nil)
1198 (defvar gnus-newsgroup-last-mail nil)
1199 (defvar gnus-newsgroup-last-folder nil)
1200 (defvar gnus-newsgroup-last-file nil)
1201 (defvar gnus-newsgroup-auto-expire nil)
1202 (defvar gnus-newsgroup-active nil)
1204 (defvar gnus-newsgroup-data nil)
1205 (defvar gnus-newsgroup-data-reverse nil)
1206 (defvar gnus-newsgroup-limit nil)
1207 (defvar gnus-newsgroup-limits nil)
1209 (defvar gnus-newsgroup-unreads nil
1210 "Sorted list of unread articles in the current newsgroup.")
1212 (defvar gnus-newsgroup-unselected nil
1213 "Sorted list of unselected unread articles in the current newsgroup.")
1215 (defvar gnus-newsgroup-reads nil
1216 "Alist of read articles and article marks in the current newsgroup.")
1218 (defvar gnus-newsgroup-expunged-tally nil)
1220 (defvar gnus-newsgroup-marked nil
1221 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1223 (defvar gnus-newsgroup-spam-marked nil
1224 "List of ranges of articles that have been marked as spam.")
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-unfetched nil
1256 "Sorted list of articles in the current newsgroup whose headers have not been fetched into the agent.")
1258 (defvar gnus-newsgroup-undownloaded nil
1259 "List of articles in the current newsgroup that haven't been downloaded..")
1261 (defvar gnus-newsgroup-unsendable nil
1262 "List of articles in the current newsgroup that won't be sent.")
1264 (defvar gnus-newsgroup-bookmarks nil
1265 "List of articles in the current newsgroup that have bookmarks.")
1267 (defvar gnus-newsgroup-dormant nil
1268 "Sorted list of dormant articles in the current newsgroup.")
1270 (defvar gnus-newsgroup-unseen nil
1271 "List of unseen articles in the current newsgroup.")
1273 (defvar gnus-newsgroup-seen nil
1274 "Range of seen articles in the current newsgroup.")
1276 (defvar gnus-newsgroup-articles nil
1277 "List of articles in the current newsgroup.")
1279 (defvar gnus-newsgroup-scored nil
1280 "List of scored 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-spam-marked
1315 gnus-newsgroup-reads gnus-newsgroup-saved
1316 gnus-newsgroup-replied gnus-newsgroup-forwarded
1317 gnus-newsgroup-recent
1318 gnus-newsgroup-expirable
1319 gnus-newsgroup-processable gnus-newsgroup-killed
1320 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1321 gnus-newsgroup-unfetched
1322 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1323 gnus-newsgroup-seen gnus-newsgroup-articles
1324 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1325 gnus-newsgroup-headers gnus-newsgroup-threads
1326 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1327 gnus-current-article gnus-current-headers gnus-have-all-headers
1328 gnus-last-article gnus-article-internal-prepare-hook
1329 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1330 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1331 gnus-thread-expunge-below
1332 gnus-score-alist gnus-current-score-file
1333 (gnus-summary-expunge-below . global)
1334 (gnus-summary-mark-below . global)
1335 (gnus-orphan-score . global)
1336 gnus-newsgroup-active gnus-scores-exclude-files
1337 gnus-newsgroup-history gnus-newsgroup-ancient
1338 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1339 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1340 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1341 (gnus-newsgroup-expunged-tally . 0)
1342 gnus-cache-removable-articles gnus-newsgroup-cached
1343 gnus-newsgroup-data gnus-newsgroup-data-reverse
1344 gnus-newsgroup-limit gnus-newsgroup-limits
1345 gnus-newsgroup-charset gnus-newsgroup-display)
1346 "Variables that are buffer-local to the summary buffers.")
1348 (defvar gnus-newsgroup-variables nil
1349 "A list of variables that have separate values in different newsgroups.
1350 A list of newsgroup (summary buffer) local variables, or cons of
1351 variables and their default values (when the default values are not
1352 nil), that should be made global while the summary buffer is active.
1353 These variables can be used to set variables in the group parameters
1354 while still allowing them to affect operations done in other
1355 buffers. For example:
1357 \(setq gnus-newsgroup-variables
1358 '(message-use-followup-to
1359 (gnus-visible-headers .
1360 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1363 ;; Byte-compiler warning.
1364 ;(eval-when-compile (defvar gnus-article-mode-map))
1366 (let ((features (cons 'gnus-sum features)))
1368 (require 'gnus-agent)
1369 (require 'gnus-art)))
1373 (defvar gnus-decode-encoded-word-methods
1374 '(mail-decode-encoded-word-string)
1375 "List of methods used to decode encoded words.
1377 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1378 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1379 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1380 whose names match REGEXP.
1383 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1384 mail-decode-encoded-word-string
1385 (\"chinese\" . rfc1843-decode-string))")
1387 (defvar gnus-decode-encoded-word-methods-cache nil)
1389 (defun gnus-multi-decode-encoded-word-string (string)
1390 "Apply the functions from `gnus-encoded-word-methods' that match."
1391 (unless (and gnus-decode-encoded-word-methods-cache
1392 (eq gnus-newsgroup-name
1393 (car gnus-decode-encoded-word-methods-cache)))
1394 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1397 (nconc gnus-decode-encoded-word-methods-cache (list x))
1398 (if (and gnus-newsgroup-name
1399 (string-match (car x) gnus-newsgroup-name))
1400 (nconc gnus-decode-encoded-word-methods-cache
1402 gnus-decode-encoded-word-methods))
1403 (let ((xlist gnus-decode-encoded-word-methods-cache))
1406 (setq string (funcall (pop xlist) string))))
1409 ;; Subject simplification.
1411 (defun gnus-simplify-whitespace (str)
1412 "Remove excessive whitespace from STR."
1414 (while (string-match "[ \t][ \t]+" str)
1415 (setq str (concat (substring str 0 (match-beginning 0))
1417 (substring str (match-end 0)))))
1419 (when (string-match "^[ \t]+" str)
1420 (setq str (substring str (match-end 0))))
1422 (when (string-match "[ \t]+$" str)
1423 (setq str (substring str 0 (match-beginning 0))))
1426 (defun gnus-simplify-all-whitespace (str)
1427 "Remove all whitespace from STR."
1428 (while (string-match "[ \t\n]+" str)
1429 (setq str (replace-match "" nil nil str)))
1432 (defsubst gnus-simplify-subject-re (subject)
1433 "Remove \"Re:\" from subject lines."
1434 (if (string-match message-subject-re-regexp subject)
1435 (substring subject (match-end 0))
1438 (defun gnus-simplify-subject (subject &optional re-only)
1439 "Remove `Re:' and words in parentheses.
1440 If RE-ONLY is non-nil, strip leading `Re:'s only."
1441 (let ((case-fold-search t)) ;Ignore case.
1442 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1443 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1444 (setq subject (substring subject (match-end 0))))
1445 ;; Remove uninteresting prefixes.
1446 (when (and (not re-only)
1447 gnus-simplify-ignored-prefixes
1448 (string-match gnus-simplify-ignored-prefixes subject))
1449 (setq subject (substring subject (match-end 0))))
1450 ;; Remove words in parentheses from end.
1452 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1453 (setq subject (substring subject 0 (match-beginning 0)))))
1454 ;; Return subject string.
1457 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1459 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1460 (goto-char (point-min))
1461 (while (re-search-forward regexp nil t)
1462 (replace-match (or newtext ""))))
1464 (defun gnus-simplify-buffer-fuzzy ()
1465 "Simplify string in the buffer fuzzily.
1466 The string in the accessible portion of the current buffer is simplified.
1467 It is assumed to be a single-line subject.
1468 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1469 matter is removed. Additional things can be deleted by setting
1470 `gnus-simplify-subject-fuzzy-regexp'."
1471 (let ((case-fold-search t)
1473 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1475 (while (not (eq modified-tick (buffer-modified-tick)))
1476 (setq modified-tick (buffer-modified-tick))
1478 ((listp gnus-simplify-subject-fuzzy-regexp)
1479 (mapcar 'gnus-simplify-buffer-fuzzy-step
1480 gnus-simplify-subject-fuzzy-regexp))
1481 (gnus-simplify-subject-fuzzy-regexp
1482 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1483 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1484 (gnus-simplify-buffer-fuzzy-step
1485 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1486 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1488 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1489 (gnus-simplify-buffer-fuzzy-step " +" " ")
1490 (gnus-simplify-buffer-fuzzy-step " $")
1491 (gnus-simplify-buffer-fuzzy-step "^ +")))
1493 (defun gnus-simplify-subject-fuzzy (subject)
1494 "Simplify a subject string fuzzily.
1495 See `gnus-simplify-buffer-fuzzy' for details."
1497 (gnus-set-work-buffer)
1498 (let ((case-fold-search t))
1499 ;; Remove uninteresting prefixes.
1500 (when (and gnus-simplify-ignored-prefixes
1501 (string-match gnus-simplify-ignored-prefixes subject))
1502 (setq subject (substring subject (match-end 0))))
1504 (inline (gnus-simplify-buffer-fuzzy))
1507 (defsubst gnus-simplify-subject-fully (subject)
1508 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1510 (gnus-simplify-subject-functions
1511 (gnus-map-function gnus-simplify-subject-functions subject))
1512 ((null gnus-summary-gather-subject-limit)
1513 (gnus-simplify-subject-re subject))
1514 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1515 (gnus-simplify-subject-fuzzy subject))
1516 ((numberp gnus-summary-gather-subject-limit)
1517 (gnus-limit-string (gnus-simplify-subject-re subject)
1518 gnus-summary-gather-subject-limit))
1522 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1523 "Check whether two subjects are equal.
1524 If optional argument simple-first is t, first argument is already
1527 ((null simple-first)
1528 (equal (gnus-simplify-subject-fully s1)
1529 (gnus-simplify-subject-fully s2)))
1532 (gnus-simplify-subject-fully s2)))))
1534 (defun gnus-summary-bubble-group ()
1535 "Increase the score of the current group.
1536 This is a handy function to add to `gnus-summary-exit-hook' to
1537 increase the score of each group you read."
1538 (gnus-group-add-score gnus-newsgroup-name))
1542 ;;; Gnus summary mode
1545 (put 'gnus-summary-mode 'mode-class 'special)
1547 (defvar gnus-article-commands-menu)
1549 ;; Non-orthogonal keys
1551 (gnus-define-keys gnus-summary-mode-map
1552 " " gnus-summary-next-page
1553 "\177" gnus-summary-prev-page
1554 [delete] gnus-summary-prev-page
1555 [backspace] gnus-summary-prev-page
1556 "\r" gnus-summary-scroll-up
1557 "\M-\r" gnus-summary-scroll-down
1558 "n" gnus-summary-next-unread-article
1559 "p" gnus-summary-prev-unread-article
1560 "N" gnus-summary-next-article
1561 "P" gnus-summary-prev-article
1562 "\M-\C-n" gnus-summary-next-same-subject
1563 "\M-\C-p" gnus-summary-prev-same-subject
1564 "\M-n" gnus-summary-next-unread-subject
1565 "\M-p" gnus-summary-prev-unread-subject
1566 "." gnus-summary-first-unread-article
1567 "," gnus-summary-best-unread-article
1568 "\M-s" gnus-summary-search-article-forward
1569 "\M-r" gnus-summary-search-article-backward
1570 "<" gnus-summary-beginning-of-article
1571 ">" gnus-summary-end-of-article
1572 "j" gnus-summary-goto-article
1573 "^" gnus-summary-refer-parent-article
1574 "\M-^" gnus-summary-refer-article
1575 "u" gnus-summary-tick-article-forward
1576 "!" gnus-summary-tick-article-forward
1577 "U" gnus-summary-tick-article-backward
1578 "d" gnus-summary-mark-as-read-forward
1579 "D" gnus-summary-mark-as-read-backward
1580 "E" gnus-summary-mark-as-expirable
1581 "\M-u" gnus-summary-clear-mark-forward
1582 "\M-U" gnus-summary-clear-mark-backward
1583 "k" gnus-summary-kill-same-subject-and-select
1584 "\C-k" gnus-summary-kill-same-subject
1585 "\M-\C-k" gnus-summary-kill-thread
1586 "\M-\C-l" gnus-summary-lower-thread
1587 "e" gnus-summary-edit-article
1588 "#" gnus-summary-mark-as-processable
1589 "\M-#" gnus-summary-unmark-as-processable
1590 "\M-\C-t" gnus-summary-toggle-threads
1591 "\M-\C-s" gnus-summary-show-thread
1592 "\M-\C-h" gnus-summary-hide-thread
1593 "\M-\C-f" gnus-summary-next-thread
1594 "\M-\C-b" gnus-summary-prev-thread
1595 [(meta down)] gnus-summary-next-thread
1596 [(meta up)] gnus-summary-prev-thread
1597 "\M-\C-u" gnus-summary-up-thread
1598 "\M-\C-d" gnus-summary-down-thread
1599 "&" gnus-summary-execute-command
1600 "c" gnus-summary-catchup-and-exit
1601 "\C-w" gnus-summary-mark-region-as-read
1602 "\C-t" gnus-summary-toggle-truncation
1603 "?" gnus-summary-mark-as-dormant
1604 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1605 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1606 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1607 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1608 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1609 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1610 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1611 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1612 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1613 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1614 "=" gnus-summary-expand-window
1615 "\C-x\C-s" gnus-summary-reselect-current-group
1616 "\M-g" gnus-summary-rescan-group
1617 "w" gnus-summary-stop-page-breaking
1618 "\C-c\C-r" gnus-summary-caesar-message
1619 "f" gnus-summary-followup
1620 "F" gnus-summary-followup-with-original
1621 "C" gnus-summary-cancel-article
1622 "r" gnus-summary-reply
1623 "R" gnus-summary-reply-with-original
1624 "\C-c\C-f" gnus-summary-mail-forward
1625 "o" gnus-summary-save-article
1626 "\C-o" gnus-summary-save-article-mail
1627 "|" gnus-summary-pipe-output
1628 "\M-k" gnus-summary-edit-local-kill
1629 "\M-K" gnus-summary-edit-global-kill
1631 "\C-c\C-d" gnus-summary-describe-group
1632 "q" gnus-summary-exit
1633 "Q" gnus-summary-exit-no-update
1634 "\C-c\C-i" gnus-info-find-node
1635 gnus-mouse-2 gnus-mouse-pick-article
1636 "m" gnus-summary-mail-other-window
1637 "a" gnus-summary-post-news
1638 "i" gnus-summary-news-other-window
1639 "x" gnus-summary-limit-to-unread
1640 "s" gnus-summary-isearch-article
1641 "t" gnus-summary-toggle-header
1642 "g" gnus-summary-show-article
1643 "l" gnus-summary-goto-last-article
1644 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1645 "\C-d" gnus-summary-enter-digest-group
1646 "\M-\C-d" gnus-summary-read-document
1647 "\M-\C-e" gnus-summary-edit-parameters
1648 "\M-\C-a" gnus-summary-customize-parameters
1650 "*" gnus-cache-enter-article
1651 "\M-*" gnus-cache-remove-article
1652 "\M-&" gnus-summary-universal-argument
1653 "\C-l" gnus-recenter
1654 "I" gnus-summary-increase-score
1655 "L" gnus-summary-lower-score
1656 "\M-i" gnus-symbolic-argument
1657 "h" gnus-summary-select-article-buffer
1659 "b" gnus-article-view-part
1660 "\M-t" gnus-summary-toggle-display-buttonized
1662 "V" gnus-summary-score-map
1663 "X" gnus-uu-extract-map
1664 "S" gnus-summary-send-map)
1666 ;; Sort of orthogonal keymap
1667 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1668 "t" gnus-summary-tick-article-forward
1669 "!" gnus-summary-tick-article-forward
1670 "d" gnus-summary-mark-as-read-forward
1671 "r" gnus-summary-mark-as-read-forward
1672 "c" gnus-summary-clear-mark-forward
1673 " " gnus-summary-clear-mark-forward
1674 "e" gnus-summary-mark-as-expirable
1675 "x" gnus-summary-mark-as-expirable
1676 "?" gnus-summary-mark-as-dormant
1677 "b" gnus-summary-set-bookmark
1678 "B" gnus-summary-remove-bookmark
1679 "#" gnus-summary-mark-as-processable
1680 "\M-#" gnus-summary-unmark-as-processable
1681 "S" gnus-summary-limit-include-expunged
1682 "C" gnus-summary-catchup
1683 "H" gnus-summary-catchup-to-here
1684 "h" gnus-summary-catchup-from-here
1685 "\C-c" gnus-summary-catchup-all
1686 "k" gnus-summary-kill-same-subject-and-select
1687 "K" gnus-summary-kill-same-subject
1688 "P" gnus-uu-mark-map)
1690 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1691 "c" gnus-summary-clear-above
1692 "u" gnus-summary-tick-above
1693 "m" gnus-summary-mark-above
1694 "k" gnus-summary-kill-below)
1696 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1697 "/" gnus-summary-limit-to-subject
1698 "n" gnus-summary-limit-to-articles
1699 "w" gnus-summary-pop-limit
1700 "s" gnus-summary-limit-to-subject
1701 "a" gnus-summary-limit-to-author
1702 "u" gnus-summary-limit-to-unread
1703 "m" gnus-summary-limit-to-marks
1704 "M" gnus-summary-limit-exclude-marks
1705 "v" gnus-summary-limit-to-score
1706 "*" gnus-summary-limit-include-cached
1707 "D" gnus-summary-limit-include-dormant
1708 "T" gnus-summary-limit-include-thread
1709 "d" gnus-summary-limit-exclude-dormant
1710 "t" gnus-summary-limit-to-age
1711 "." gnus-summary-limit-to-unseen
1712 "x" gnus-summary-limit-to-extra
1713 "p" gnus-summary-limit-to-display-predicate
1714 "E" gnus-summary-limit-include-expunged
1715 "c" gnus-summary-limit-exclude-childless-dormant
1716 "C" gnus-summary-limit-mark-excluded-as-read
1717 "o" gnus-summary-insert-old-articles
1718 "N" gnus-summary-insert-new-articles)
1720 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1721 "n" gnus-summary-next-unread-article
1722 "p" gnus-summary-prev-unread-article
1723 "N" gnus-summary-next-article
1724 "P" gnus-summary-prev-article
1725 "\C-n" gnus-summary-next-same-subject
1726 "\C-p" gnus-summary-prev-same-subject
1727 "\M-n" gnus-summary-next-unread-subject
1728 "\M-p" gnus-summary-prev-unread-subject
1729 "f" gnus-summary-first-unread-article
1730 "b" gnus-summary-best-unread-article
1731 "j" gnus-summary-goto-article
1732 "g" gnus-summary-goto-subject
1733 "l" gnus-summary-goto-last-article
1734 "o" gnus-summary-pop-article)
1736 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1737 "k" gnus-summary-kill-thread
1738 "l" gnus-summary-lower-thread
1739 "i" gnus-summary-raise-thread
1740 "T" gnus-summary-toggle-threads
1741 "t" gnus-summary-rethread-current
1742 "^" gnus-summary-reparent-thread
1743 "s" gnus-summary-show-thread
1744 "S" gnus-summary-show-all-threads
1745 "h" gnus-summary-hide-thread
1746 "H" gnus-summary-hide-all-threads
1747 "n" gnus-summary-next-thread
1748 "p" gnus-summary-prev-thread
1749 "u" gnus-summary-up-thread
1750 "o" gnus-summary-top-thread
1751 "d" gnus-summary-down-thread
1752 "#" gnus-uu-mark-thread
1753 "\M-#" gnus-uu-unmark-thread)
1755 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1756 "g" gnus-summary-prepare
1757 "c" gnus-summary-insert-cached-articles
1758 "d" gnus-summary-insert-dormant-articles)
1760 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1761 "c" gnus-summary-catchup-and-exit
1762 "C" gnus-summary-catchup-all-and-exit
1763 "E" gnus-summary-exit-no-update
1764 "Q" gnus-summary-exit
1765 "Z" gnus-summary-exit
1766 "n" gnus-summary-catchup-and-goto-next-group
1767 "R" gnus-summary-reselect-current-group
1768 "G" gnus-summary-rescan-group
1769 "N" gnus-summary-next-group
1770 "s" gnus-summary-save-newsrc
1771 "P" gnus-summary-prev-group)
1773 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1774 " " gnus-summary-next-page
1775 "n" gnus-summary-next-page
1776 "\177" gnus-summary-prev-page
1777 [delete] gnus-summary-prev-page
1778 "p" gnus-summary-prev-page
1779 "\r" gnus-summary-scroll-up
1780 "\M-\r" gnus-summary-scroll-down
1781 "<" gnus-summary-beginning-of-article
1782 ">" gnus-summary-end-of-article
1783 "b" gnus-summary-beginning-of-article
1784 "e" gnus-summary-end-of-article
1785 "^" gnus-summary-refer-parent-article
1786 "r" gnus-summary-refer-parent-article
1787 "D" gnus-summary-enter-digest-group
1788 "R" gnus-summary-refer-references
1789 "T" gnus-summary-refer-thread
1790 "g" gnus-summary-show-article
1791 "s" gnus-summary-isearch-article
1792 "P" gnus-summary-print-article
1793 "M" gnus-mailing-list-insinuate
1794 "t" gnus-article-babel)
1796 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1797 "b" gnus-article-add-buttons
1798 "B" gnus-article-add-buttons-to-head
1799 "o" gnus-article-treat-overstrike
1800 "e" gnus-article-emphasize
1801 "w" gnus-article-fill-cited-article
1802 "Q" gnus-article-fill-long-lines
1803 "C" gnus-article-capitalize-sentences
1804 "c" gnus-article-remove-cr
1805 "q" gnus-article-de-quoted-unreadable
1806 "6" gnus-article-de-base64-unreadable
1807 "Z" gnus-article-decode-HZ
1808 "h" gnus-article-wash-html
1809 "u" gnus-article-unsplit-urls
1810 "s" gnus-summary-force-verify-and-decrypt
1811 "f" gnus-article-display-x-face
1812 "l" gnus-summary-stop-page-breaking
1813 "r" gnus-summary-caesar-message
1814 "m" gnus-summary-morse-message
1815 "t" gnus-summary-toggle-header
1816 "g" gnus-treat-smiley
1817 "v" gnus-summary-verbose-headers
1818 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1819 "p" gnus-article-verify-x-pgp-sig
1820 "d" gnus-article-treat-dumbquotes)
1822 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1823 ;; mnemonic: deuglif*Y*
1824 "u" gnus-article-outlook-unwrap-lines
1825 "a" gnus-article-outlook-repair-attribution
1826 "c" gnus-article-outlook-rearrange-citation
1827 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1829 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1830 "a" gnus-article-hide
1831 "h" gnus-article-hide-headers
1832 "b" gnus-article-hide-boring-headers
1833 "s" gnus-article-hide-signature
1834 "c" gnus-article-hide-citation
1835 "C" gnus-article-hide-citation-in-followups
1836 "l" gnus-article-hide-list-identifiers
1837 "B" gnus-article-strip-banner
1838 "P" gnus-article-hide-pem
1839 "\C-c" gnus-article-hide-citation-maybe)
1841 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1842 "a" gnus-article-highlight
1843 "h" gnus-article-highlight-headers
1844 "c" gnus-article-highlight-citation
1845 "s" gnus-article-highlight-signature)
1847 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1848 "f" gnus-article-treat-fold-headers
1849 "u" gnus-article-treat-unfold-headers
1850 "n" gnus-article-treat-fold-newsgroups)
1852 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1853 "x" gnus-article-display-x-face
1854 "d" gnus-article-display-face
1855 "s" gnus-treat-smiley
1856 "D" gnus-article-remove-images
1857 "f" gnus-treat-from-picon
1858 "m" gnus-treat-mail-picon
1859 "n" gnus-treat-newsgroups-picon)
1861 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1862 "w" gnus-article-decode-mime-words
1863 "c" gnus-article-decode-charset
1864 "v" gnus-mime-view-all-parts
1865 "b" gnus-article-view-part)
1867 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1868 "z" gnus-article-date-ut
1869 "u" gnus-article-date-ut
1870 "l" gnus-article-date-local
1871 "p" gnus-article-date-english
1872 "e" gnus-article-date-lapsed
1873 "o" gnus-article-date-original
1874 "i" gnus-article-date-iso8601
1875 "s" gnus-article-date-user)
1877 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1878 "t" gnus-article-remove-trailing-blank-lines
1879 "l" gnus-article-strip-leading-blank-lines
1880 "m" gnus-article-strip-multiple-blank-lines
1881 "a" gnus-article-strip-blank-lines
1882 "A" gnus-article-strip-all-blank-lines
1883 "s" gnus-article-strip-leading-space
1884 "e" gnus-article-strip-trailing-space
1885 "w" gnus-article-remove-leading-whitespace)
1887 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1889 "f" gnus-summary-fetch-faq
1890 "d" gnus-summary-describe-group
1891 "h" gnus-summary-describe-briefly
1892 "i" gnus-info-find-node
1893 "c" gnus-group-fetch-charter
1894 "C" gnus-group-fetch-control)
1896 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1897 "e" gnus-summary-expire-articles
1898 "\M-\C-e" gnus-summary-expire-articles-now
1899 "\177" gnus-summary-delete-article
1900 [delete] gnus-summary-delete-article
1901 [backspace] gnus-summary-delete-article
1902 "m" gnus-summary-move-article
1903 "r" gnus-summary-respool-article
1904 "w" gnus-summary-edit-article
1905 "c" gnus-summary-copy-article
1906 "B" gnus-summary-crosspost-article
1907 "q" gnus-summary-respool-query
1908 "t" gnus-summary-respool-trace
1909 "i" gnus-summary-import-article
1910 "I" gnus-summary-create-article
1911 "p" gnus-summary-article-posted-p)
1913 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1914 "o" gnus-summary-save-article
1915 "m" gnus-summary-save-article-mail
1916 "F" gnus-summary-write-article-file
1917 "r" gnus-summary-save-article-rmail
1918 "f" gnus-summary-save-article-file
1919 "b" gnus-summary-save-article-body-file
1920 "h" gnus-summary-save-article-folder
1921 "v" gnus-summary-save-article-vm
1922 "p" gnus-summary-pipe-output
1923 "P" gnus-summary-muttprint
1924 "s" gnus-soup-add-article)
1926 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1927 "b" gnus-summary-display-buttonized
1928 "m" gnus-summary-repair-multipart
1929 "v" gnus-article-view-part
1930 "o" gnus-article-save-part
1931 "c" gnus-article-copy-part
1932 "C" gnus-article-view-part-as-charset
1933 "e" gnus-article-view-part-externally
1934 "E" gnus-article-encrypt-body
1935 "i" gnus-article-inline-part
1936 "|" gnus-article-pipe-part)
1938 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1939 "p" gnus-summary-mark-as-processable
1940 "u" gnus-summary-unmark-as-processable
1941 "U" gnus-summary-unmark-all-processable
1942 "v" gnus-uu-mark-over
1943 "s" gnus-uu-mark-series
1944 "r" gnus-uu-mark-region
1945 "g" gnus-uu-unmark-region
1946 "R" gnus-uu-mark-by-regexp
1947 "G" gnus-uu-unmark-by-regexp
1948 "t" gnus-uu-mark-thread
1949 "T" gnus-uu-unmark-thread
1950 "a" gnus-uu-mark-all
1951 "b" gnus-uu-mark-buffer
1952 "S" gnus-uu-mark-sparse
1953 "k" gnus-summary-kill-process-mark
1954 "y" gnus-summary-yank-process-mark
1955 "w" gnus-summary-save-process-mark
1956 "i" gnus-uu-invert-processable)
1958 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1959 ;;"x" gnus-uu-extract-any
1960 "m" gnus-summary-save-parts
1961 "u" gnus-uu-decode-uu
1962 "U" gnus-uu-decode-uu-and-save
1963 "s" gnus-uu-decode-unshar
1964 "S" gnus-uu-decode-unshar-and-save
1965 "o" gnus-uu-decode-save
1966 "O" gnus-uu-decode-save
1967 "b" gnus-uu-decode-binhex
1968 "B" gnus-uu-decode-binhex
1969 "p" gnus-uu-decode-postscript
1970 "P" gnus-uu-decode-postscript-and-save)
1973 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1974 "u" gnus-uu-decode-uu-view
1975 "U" gnus-uu-decode-uu-and-save-view
1976 "s" gnus-uu-decode-unshar-view
1977 "S" gnus-uu-decode-unshar-and-save-view
1978 "o" gnus-uu-decode-save-view
1979 "O" gnus-uu-decode-save-view
1980 "b" gnus-uu-decode-binhex-view
1981 "B" gnus-uu-decode-binhex-view
1982 "p" gnus-uu-decode-postscript-view
1983 "P" gnus-uu-decode-postscript-and-save-view)
1985 (defvar gnus-article-post-menu nil)
1987 (defconst gnus-summary-menu-maxlen 20)
1989 (defun gnus-summary-menu-split (menu)
1990 ;; If we have lots of elements, divide them into groups of 20
1991 ;; and make a pane (or submenu) for each one.
1992 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1993 (let ((menu menu) sublists next
1996 ;; Pull off the next gnus-summary-menu-maxlen elements
1997 ;; and make them the next element of sublist.
1998 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2000 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2002 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2003 (aref (car (last menu)) 0)) menu)
2007 (nreverse sublists))
2008 ;; Few elements--put them all in one pane.
2011 (defun gnus-summary-make-menu-bar ()
2012 (gnus-turn-off-edit-menu 'summary)
2014 (unless (boundp 'gnus-summary-misc-menu)
2017 gnus-summary-kill-menu gnus-summary-mode-map ""
2022 ["Customize" gnus-score-customize t])
2023 (gnus-make-score-map 'increase)
2024 (gnus-make-score-map 'lower)
2026 ["Kill below" gnus-summary-kill-below t]
2027 ["Mark above" gnus-summary-mark-above t]
2028 ["Tick above" gnus-summary-tick-above t]
2029 ["Clear above" gnus-summary-clear-above t])
2030 ["Current score" gnus-summary-current-score t]
2031 ["Set score" gnus-summary-set-score t]
2032 ["Switch current score file..." gnus-score-change-score-file t]
2033 ["Set mark below..." gnus-score-set-mark-below t]
2034 ["Set expunge below..." gnus-score-set-expunge-below t]
2035 ["Edit current score file" gnus-score-edit-current-scores t]
2036 ["Edit score file" gnus-score-edit-file t]
2037 ["Trace score" gnus-score-find-trace t]
2038 ["Find words" gnus-score-find-favourite-words t]
2039 ["Rescore buffer" gnus-summary-rescore t]
2040 ["Increase score..." gnus-summary-increase-score t]
2041 ["Lower score..." gnus-summary-lower-score t]))))
2043 ;; Define both the Article menu in the summary buffer and the
2044 ;; equivalent Commands menu in the article buffer here for
2048 ["All" gnus-article-hide t]
2049 ["Headers" gnus-article-hide-headers t]
2050 ["Signature" gnus-article-hide-signature t]
2051 ["Citation" gnus-article-hide-citation t]
2052 ["List identifiers" gnus-article-hide-list-identifiers t]
2053 ["Banner" gnus-article-strip-banner t]
2054 ["Boring headers" gnus-article-hide-boring-headers t])
2056 ["All" gnus-article-highlight t]
2057 ["Headers" gnus-article-highlight-headers t]
2058 ["Signature" gnus-article-highlight-signature t]
2059 ["Citation" gnus-article-highlight-citation t])
2061 ["Words" gnus-article-decode-mime-words t]
2062 ["Charset" gnus-article-decode-charset t]
2063 ["QP" gnus-article-de-quoted-unreadable t]
2064 ["Base64" gnus-article-de-base64-unreadable t]
2065 ["View MIME buttons" gnus-summary-display-buttonized t]
2066 ["View all" gnus-mime-view-all-parts t]
2067 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2068 ["Encrypt body" gnus-article-encrypt-body t]
2069 ["Extract all parts" gnus-summary-save-parts t]
2071 ["Repair multipart" gnus-summary-repair-multipart t]
2072 ["Add buttons" gnus-summary-display-buttonized t]
2073 ["Pipe part" gnus-article-pipe-part t]
2074 ["Inline part" gnus-article-inline-part t]
2075 ["Encrypt body" gnus-article-encrypt-body t]
2076 ["View part externally" gnus-article-view-part-externally t]
2077 ["View part with charset" gnus-article-view-part-as-charset t]
2078 ["Copy part" gnus-article-copy-part t]
2079 ["Save part" gnus-article-save-part t]
2080 ["View part" gnus-article-view-part t]))
2082 ["Local" gnus-article-date-local t]
2083 ["ISO8601" gnus-article-date-iso8601 t]
2084 ["UT" gnus-article-date-ut t]
2085 ["Original" gnus-article-date-original t]
2086 ["Lapsed" gnus-article-date-lapsed t]
2087 ["User-defined" gnus-article-date-user t])
2089 ["Remove images" gnus-article-remove-images t]
2090 ["Toggle smiley" gnus-treat-smiley t]
2091 ["Show X-Face" gnus-article-display-x-face t]
2092 ["Show picons in From" gnus-treat-from-picon t]
2093 ["Show picons in mail headers" gnus-treat-mail-picon t]
2094 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2095 ("View as different encoding"
2096 ,@(gnus-summary-menu-split
2099 ;; Since easymenu under FSF Emacs doesn't allow lambda
2100 ;; forms for menu commands, we should provide intern'ed
2101 ;; function symbols.
2102 (let ((command (intern (format "\
2103 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2107 (let ((gnus-summary-show-article-charset-alist
2109 (gnus-summary-show-article 1))))
2110 `[,(symbol-name cs) ,command t]))
2111 (sort (if (fboundp 'coding-system-list)
2112 (coding-system-list)
2113 (mapcar 'car mm-mime-mule-charset-alist))
2117 ["Leading" gnus-article-strip-leading-blank-lines t]
2118 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2119 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2120 ["All of the above" gnus-article-strip-blank-lines t]
2121 ["All" gnus-article-strip-all-blank-lines t]
2122 ["Leading space" gnus-article-strip-leading-space t]
2123 ["Trailing space" gnus-article-strip-trailing-space t]
2124 ["Leading space in headers"
2125 gnus-article-remove-leading-whitespace t])
2126 ["Overstrike" gnus-article-treat-overstrike t]
2127 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2128 ["Emphasis" gnus-article-emphasize t]
2129 ["Word wrap" gnus-article-fill-cited-article t]
2130 ["Fill long lines" gnus-article-fill-long-lines t]
2131 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2132 ["CR" gnus-article-remove-cr t]
2133 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2134 ["Base64" gnus-article-de-base64-unreadable t]
2135 ["Rot 13" gnus-summary-caesar-message
2136 ,@(if (featurep 'xemacs) '(t)
2137 '(:help "\"Caesar rotate\" article by 13"))]
2138 ["Morse decode" gnus-summary-morse-message t]
2139 ["Unix pipe..." gnus-summary-pipe-message t]
2140 ["Add buttons" gnus-article-add-buttons t]
2141 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2142 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2143 ["Verbose header" gnus-summary-verbose-headers t]
2144 ["Toggle header" gnus-summary-toggle-header t]
2145 ["Unfold headers" gnus-article-treat-unfold-headers t]
2146 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2147 ["Html" gnus-article-wash-html t]
2148 ["URLs" gnus-article-unsplit-urls t]
2149 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2150 ["HZ" gnus-article-decode-HZ t]
2151 ("(Outlook) Deuglify"
2152 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2153 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2154 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2155 ["Full (Outlook) deuglify"
2156 gnus-article-outlook-deuglify-article t])
2159 ["Save in default format" gnus-summary-save-article
2160 ,@(if (featurep 'xemacs) '(t)
2161 '(:help "Save article using default method"))]
2162 ["Save in file" gnus-summary-save-article-file
2163 ,@(if (featurep 'xemacs) '(t)
2164 '(:help "Save article in file"))]
2165 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2166 ["Save in MH folder" gnus-summary-save-article-folder t]
2167 ["Save in VM folder" gnus-summary-save-article-vm t]
2168 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2169 ["Save body in file" gnus-summary-save-article-body-file t]
2170 ["Pipe through a filter" gnus-summary-pipe-output t]
2171 ["Add to SOUP packet" gnus-soup-add-article t]
2172 ["Print with Muttprint" gnus-summary-muttprint t]
2173 ["Print" gnus-summary-print-article t])
2175 ["Respool article..." gnus-summary-respool-article t]
2176 ["Move article..." gnus-summary-move-article
2177 (gnus-check-backend-function
2178 'request-move-article gnus-newsgroup-name)]
2179 ["Copy article..." gnus-summary-copy-article t]
2180 ["Crosspost article..." gnus-summary-crosspost-article
2181 (gnus-check-backend-function
2182 'request-replace-article gnus-newsgroup-name)]
2183 ["Import file..." gnus-summary-import-article t]
2184 ["Create article..." gnus-summary-create-article t]
2185 ["Check if posted" gnus-summary-article-posted-p t]
2186 ["Edit article" gnus-summary-edit-article
2187 (not (gnus-group-read-only-p))]
2188 ["Delete article" gnus-summary-delete-article
2189 (gnus-check-backend-function
2190 'request-expire-articles gnus-newsgroup-name)]
2191 ["Query respool" gnus-summary-respool-query t]
2192 ["Trace respool" gnus-summary-respool-trace t]
2193 ["Delete expirable articles" gnus-summary-expire-articles-now
2194 (gnus-check-backend-function
2195 'request-expire-articles gnus-newsgroup-name)])
2197 ["Uudecode" gnus-uu-decode-uu
2198 ,@(if (featurep 'xemacs) '(t)
2199 '(:help "Decode uuencoded article(s)"))]
2200 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2201 ["Unshar" gnus-uu-decode-unshar t]
2202 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2203 ["Save" gnus-uu-decode-save t]
2204 ["Binhex" gnus-uu-decode-binhex t]
2205 ["Postscript" gnus-uu-decode-postscript t]
2206 ["All MIME parts" gnus-summary-save-parts t])
2208 ["Enter article" gnus-cache-enter-article t]
2209 ["Remove article" gnus-cache-remove-article t])
2210 ["Translate" gnus-article-babel t]
2211 ["Select article buffer" gnus-summary-select-article-buffer t]
2212 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2213 ["Isearch article..." gnus-summary-isearch-article t]
2214 ["Beginning of the article" gnus-summary-beginning-of-article t]
2215 ["End of the article" gnus-summary-end-of-article t]
2216 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2217 ["Fetch referenced articles" gnus-summary-refer-references t]
2218 ["Fetch current thread" gnus-summary-refer-thread t]
2219 ["Fetch article with id..." gnus-summary-refer-article t]
2220 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2221 ["Redisplay" gnus-summary-show-article t]
2222 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2224 gnus-summary-article-menu gnus-summary-mode-map ""
2225 (cons "Article" innards))
2227 (if (not (keymapp gnus-summary-article-menu))
2229 gnus-article-commands-menu gnus-article-mode-map ""
2230 (cons "Commands" innards))
2231 ;; in Emacs, don't share menu.
2232 (setq gnus-article-commands-menu
2233 (copy-keymap gnus-summary-article-menu))
2234 (define-key gnus-article-mode-map [menu-bar commands]
2235 (cons "Commands" gnus-article-commands-menu))))
2238 gnus-summary-thread-menu gnus-summary-mode-map ""
2240 ["Find all messages in thread" gnus-summary-refer-thread t]
2241 ["Toggle threading" gnus-summary-toggle-threads t]
2242 ["Hide threads" gnus-summary-hide-all-threads t]
2243 ["Show threads" gnus-summary-show-all-threads t]
2244 ["Hide thread" gnus-summary-hide-thread t]
2245 ["Show thread" gnus-summary-show-thread t]
2246 ["Go to next thread" gnus-summary-next-thread t]
2247 ["Go to previous thread" gnus-summary-prev-thread t]
2248 ["Go down thread" gnus-summary-down-thread t]
2249 ["Go up thread" gnus-summary-up-thread t]
2250 ["Top of thread" gnus-summary-top-thread t]
2251 ["Mark thread as read" gnus-summary-kill-thread t]
2252 ["Lower thread score" gnus-summary-lower-thread t]
2253 ["Raise thread score" gnus-summary-raise-thread t]
2254 ["Rethread current" gnus-summary-rethread-current t]))
2257 gnus-summary-post-menu gnus-summary-mode-map ""
2259 ["Send a message (mail or news)" gnus-summary-post-news
2260 ,@(if (featurep 'xemacs) '(t)
2261 '(:help "Post an article"))]
2262 ["Followup" gnus-summary-followup
2263 ,@(if (featurep 'xemacs) '(t)
2264 '(:help "Post followup to this article"))]
2265 ["Followup and yank" gnus-summary-followup-with-original
2266 ,@(if (featurep 'xemacs) '(t)
2267 '(:help "Post followup to this article, quoting its contents"))]
2268 ["Supersede article" gnus-summary-supersede-article t]
2269 ["Cancel article" gnus-summary-cancel-article
2270 ,@(if (featurep 'xemacs) '(t)
2271 '(:help "Cancel an article you posted"))]
2272 ["Reply" gnus-summary-reply t]
2273 ["Reply and yank" gnus-summary-reply-with-original t]
2274 ["Wide reply" gnus-summary-wide-reply t]
2275 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2276 ,@(if (featurep 'xemacs) '(t)
2277 '(:help "Mail a reply, quoting this article"))]
2278 ["Very wide reply" gnus-summary-very-wide-reply t]
2279 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2280 ,@(if (featurep 'xemacs) '(t)
2281 '(:help "Mail a very wide reply, quoting this article"))]
2282 ["Mail forward" gnus-summary-mail-forward t]
2283 ["Post forward" gnus-summary-post-forward t]
2284 ["Digest and mail" gnus-uu-digest-mail-forward t]
2285 ["Digest and post" gnus-uu-digest-post-forward t]
2286 ["Resend message" gnus-summary-resend-message t]
2287 ["Resend message edit" gnus-summary-resend-message-edit t]
2288 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2289 ["Send a mail" gnus-summary-mail-other-window t]
2290 ["Create a local message" gnus-summary-news-other-window t]
2291 ["Uuencode and post" gnus-uu-post-news
2292 ,@(if (featurep 'xemacs) '(t)
2293 '(:help "Post a uuencoded article"))]
2294 ["Followup via news" gnus-summary-followup-to-mail t]
2295 ["Followup via news and yank"
2296 gnus-summary-followup-to-mail-with-original t]
2298 ;;["Send" gnus-summary-send-draft t]
2299 ;;["Send bounced" gnus-resend-bounced-mail t])
2303 ((not (keymapp gnus-summary-post-menu))
2304 (setq gnus-article-post-menu gnus-summary-post-menu))
2305 ((not gnus-article-post-menu)
2306 ;; Don't share post menu.
2307 (setq gnus-article-post-menu
2308 (copy-keymap gnus-summary-post-menu))))
2309 (define-key gnus-article-mode-map [menu-bar post]
2310 (cons "Post" gnus-article-post-menu))
2313 gnus-summary-misc-menu gnus-summary-mode-map ""
2316 ["Mark as read" gnus-summary-mark-as-read-forward t]
2317 ["Mark same subject and select"
2318 gnus-summary-kill-same-subject-and-select t]
2319 ["Mark same subject" gnus-summary-kill-same-subject t]
2320 ["Catchup" gnus-summary-catchup
2321 ,@(if (featurep 'xemacs) '(t)
2322 '(:help "Mark unread articles in this group as read"))]
2323 ["Catchup all" gnus-summary-catchup-all t]
2324 ["Catchup to here" gnus-summary-catchup-to-here t]
2325 ["Catchup from here" gnus-summary-catchup-from-here t]
2326 ["Catchup region" gnus-summary-mark-region-as-read
2327 (gnus-mark-active-p)]
2328 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2330 ["Tick" gnus-summary-tick-article-forward t]
2331 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2332 ["Remove marks" gnus-summary-clear-mark-forward t]
2333 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2334 ["Set bookmark" gnus-summary-set-bookmark t]
2335 ["Remove bookmark" gnus-summary-remove-bookmark t])
2337 ["Marks..." gnus-summary-limit-to-marks t]
2338 ["Subject..." gnus-summary-limit-to-subject t]
2339 ["Author..." gnus-summary-limit-to-author t]
2340 ["Age..." gnus-summary-limit-to-age t]
2341 ["Extra..." gnus-summary-limit-to-extra t]
2342 ["Score..." gnus-summary-limit-to-score t]
2343 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2344 ["Unread" gnus-summary-limit-to-unread t]
2345 ["Unseen" gnus-summary-limit-to-unseen t]
2346 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2347 ["Next articles" gnus-summary-limit-to-articles t]
2348 ["Pop limit" gnus-summary-pop-limit t]
2349 ["Show dormant" gnus-summary-limit-include-dormant t]
2350 ["Hide childless dormant"
2351 gnus-summary-limit-exclude-childless-dormant t]
2352 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2353 ["Hide marked" gnus-summary-limit-exclude-marks t]
2354 ["Show expunged" gnus-summary-limit-include-expunged t])
2356 ["Set mark" gnus-summary-mark-as-processable t]
2357 ["Remove mark" gnus-summary-unmark-as-processable t]
2358 ["Remove all marks" gnus-summary-unmark-all-processable t]
2359 ["Mark above" gnus-uu-mark-over t]
2360 ["Mark series" gnus-uu-mark-series t]
2361 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2362 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2363 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2364 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2365 ["Mark all" gnus-uu-mark-all t]
2366 ["Mark buffer" gnus-uu-mark-buffer t]
2367 ["Mark sparse" gnus-uu-mark-sparse t]
2368 ["Mark thread" gnus-uu-mark-thread t]
2369 ["Unmark thread" gnus-uu-unmark-thread t]
2370 ("Process Mark Sets"
2371 ["Kill" gnus-summary-kill-process-mark t]
2372 ["Yank" gnus-summary-yank-process-mark
2373 gnus-newsgroup-process-stack]
2374 ["Save" gnus-summary-save-process-mark t]
2375 ["Run command on marked..." gnus-summary-universal-argument t]))
2377 ["Page forward" gnus-summary-next-page
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Show next page of article"))]
2380 ["Page backward" gnus-summary-prev-page
2381 ,@(if (featurep 'xemacs) '(t)
2382 '(:help "Show previous page of article"))]
2383 ["Line forward" gnus-summary-scroll-up t])
2385 ["Next unread article" gnus-summary-next-unread-article t]
2386 ["Previous unread article" gnus-summary-prev-unread-article t]
2387 ["Next article" gnus-summary-next-article t]
2388 ["Previous article" gnus-summary-prev-article t]
2389 ["Next unread subject" gnus-summary-next-unread-subject t]
2390 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2391 ["Next article same subject" gnus-summary-next-same-subject t]
2392 ["Previous article same subject" gnus-summary-prev-same-subject t]
2393 ["First unread article" gnus-summary-first-unread-article t]
2394 ["Best unread article" gnus-summary-best-unread-article t]
2395 ["Go to subject number..." gnus-summary-goto-subject t]
2396 ["Go to article number..." gnus-summary-goto-article t]
2397 ["Go to the last article" gnus-summary-goto-last-article t]
2398 ["Pop article off history" gnus-summary-pop-article t])
2400 ["Sort by number" gnus-summary-sort-by-number t]
2401 ["Sort by author" gnus-summary-sort-by-author t]
2402 ["Sort by subject" gnus-summary-sort-by-subject t]
2403 ["Sort by date" gnus-summary-sort-by-date t]
2404 ["Sort by score" gnus-summary-sort-by-score t]
2405 ["Sort by lines" gnus-summary-sort-by-lines t]
2406 ["Sort by characters" gnus-summary-sort-by-chars t]
2407 ["Randomize" gnus-summary-sort-by-random t]
2408 ["Original sort" gnus-summary-sort-by-original t])
2410 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2411 ["Describe group" gnus-summary-describe-group t]
2412 ["Fetch charter" gnus-group-fetch-charter
2413 ,@(if (featurep 'xemacs) nil
2414 '(:help "Display the charter of the current group"))]
2415 ["Fetch control message" gnus-group-fetch-control
2416 ,@(if (featurep 'xemacs) nil
2417 '(:help "Display the archived control message for the current group"))]
2418 ["Read manual" gnus-info-find-node t])
2420 ["Pick and read" gnus-pick-mode t]
2421 ["Binary" gnus-binary-mode t])
2423 ["Regenerate" gnus-summary-prepare t]
2424 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2425 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2426 ["Toggle threading" gnus-summary-toggle-threads t])
2427 ["See old articles" gnus-summary-insert-old-articles t]
2428 ["See new articles" gnus-summary-insert-new-articles t]
2429 ["Filter articles..." gnus-summary-execute-command t]
2430 ["Run command on articles..." gnus-summary-universal-argument t]
2431 ["Search articles forward..." gnus-summary-search-article-forward t]
2432 ["Search articles backward..." gnus-summary-search-article-backward t]
2433 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2434 ["Expand window" gnus-summary-expand-window t]
2435 ["Expire expirable articles" gnus-summary-expire-articles
2436 (gnus-check-backend-function
2437 'request-expire-articles gnus-newsgroup-name)]
2438 ["Edit local kill file" gnus-summary-edit-local-kill t]
2439 ["Edit main kill file" gnus-summary-edit-global-kill t]
2440 ["Edit group parameters" gnus-summary-edit-parameters t]
2441 ["Customize group parameters" gnus-summary-customize-parameters t]
2442 ["Send a bug report" gnus-bug t]
2444 ["Catchup and exit" gnus-summary-catchup-and-exit
2445 ,@(if (featurep 'xemacs) '(t)
2446 '(:help "Mark unread articles in this group as read, then exit"))]
2447 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2448 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2449 ["Exit group" gnus-summary-exit
2450 ,@(if (featurep 'xemacs) '(t)
2451 '(:help "Exit current group, return to group selection mode"))]
2452 ["Exit group without updating" gnus-summary-exit-no-update t]
2453 ["Exit and goto next group" gnus-summary-next-group t]
2454 ["Exit and goto prev group" gnus-summary-prev-group t]
2455 ["Reselect group" gnus-summary-reselect-current-group t]
2456 ["Rescan group" gnus-summary-rescan-group t]
2457 ["Update dribble" gnus-summary-save-newsrc t])))
2459 (gnus-run-hooks 'gnus-summary-menu-hook)))
2461 (defvar gnus-summary-tool-bar-map nil)
2463 ;; Emacs 21 tool bar. Should be no-op otherwise.
2464 (defun gnus-summary-make-tool-bar ()
2465 (if (and (fboundp 'tool-bar-add-item-from-menu)
2466 (default-value 'tool-bar-mode)
2467 (not gnus-summary-tool-bar-map))
2468 (setq gnus-summary-tool-bar-map
2469 (let ((tool-bar-map (make-sparse-keymap))
2470 (load-path (mm-image-load-path)))
2471 (tool-bar-add-item-from-menu
2472 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2473 (tool-bar-add-item-from-menu
2474 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2475 (tool-bar-add-item-from-menu
2476 'gnus-summary-post-news "post" gnus-summary-mode-map)
2477 (tool-bar-add-item-from-menu
2478 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2479 (tool-bar-add-item-from-menu
2480 'gnus-summary-followup "followup" gnus-summary-mode-map)
2481 (tool-bar-add-item-from-menu
2482 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2483 (tool-bar-add-item-from-menu
2484 'gnus-summary-reply "reply" gnus-summary-mode-map)
2485 (tool-bar-add-item-from-menu
2486 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2487 (tool-bar-add-item-from-menu
2488 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2489 (tool-bar-add-item-from-menu
2490 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2491 (tool-bar-add-item-from-menu
2492 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2493 (tool-bar-add-item-from-menu
2494 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2495 (tool-bar-add-item-from-menu
2496 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2497 (tool-bar-add-item-from-menu
2498 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2499 (tool-bar-add-item-from-menu
2500 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2502 (if gnus-summary-tool-bar-map
2503 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2505 (defun gnus-score-set-default (var value)
2506 "A version of set that updates the GNU Emacs menu-bar."
2508 ;; It is the message that forces the active status to be updated.
2511 (defun gnus-make-score-map (type)
2512 "Make a summary score map of type TYPE."
2515 (let ((headers '(("author" "from" string)
2516 ("subject" "subject" string)
2517 ("article body" "body" string)
2518 ("article head" "head" string)
2519 ("xref" "xref" string)
2520 ("extra header" "extra" string)
2521 ("lines" "lines" number)
2522 ("followups to author" "followup" string)))
2523 (types '((number ("less than" <)
2526 (string ("substring" s)
2530 (perms '(("temporary" (current-time-string))
2538 (if (eq type 'lower)
2543 (setq header (car headers))
2549 (let ((ts (cdr (assoc (nth 2 header) types)))
2565 'gnus-summary-score-entry
2567 (if (or (string= (nth 1 header)
2569 (string= (nth 1 header)
2572 (list 'gnus-summary-header
2574 (list 'quote (nth 1 (car ts)))
2575 (list 'gnus-score-delta-default
2582 (list (nreverse outp))))
2585 (list (nreverse outt))))
2587 (setq headers (cdr headers)))
2588 (list (nreverse outh))))))))
2592 (defun gnus-summary-mode (&optional group)
2593 "Major mode for reading articles.
2595 All normal editing commands are switched off.
2596 \\<gnus-summary-mode-map>
2597 Each line in this buffer represents one article. To read an
2598 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2599 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2602 You can also post articles and send mail from this buffer. To
2603 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2604 of an article, type `\\[gnus-summary-reply]'.
2606 There are approx. one gazillion commands you can execute in this
2607 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2609 The following commands are available:
2611 \\{gnus-summary-mode-map}"
2613 (kill-all-local-variables)
2614 (when (gnus-visual-p 'summary-menu 'menu)
2615 (gnus-summary-make-menu-bar)
2616 (gnus-summary-make-tool-bar))
2617 (gnus-summary-make-local-variables)
2618 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2619 (gnus-summary-make-local-variables))
2620 (gnus-make-thread-indent-array)
2621 (gnus-simplify-mode-line)
2622 (setq major-mode 'gnus-summary-mode)
2623 (setq mode-name "Summary")
2624 (make-local-variable 'minor-mode-alist)
2625 (use-local-map gnus-summary-mode-map)
2626 (buffer-disable-undo)
2627 (setq buffer-read-only t) ;Disable modification
2628 (setq truncate-lines t)
2629 (setq selective-display t)
2630 (setq selective-display-ellipses t) ;Display `...'
2631 (gnus-summary-set-display-table)
2632 (gnus-set-default-directory)
2633 (setq gnus-newsgroup-name group)
2634 (make-local-variable 'gnus-summary-line-format)
2635 (make-local-variable 'gnus-summary-line-format-spec)
2636 (make-local-variable 'gnus-summary-dummy-line-format)
2637 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2638 (make-local-variable 'gnus-summary-mark-positions)
2639 (make-local-hook 'pre-command-hook)
2640 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2641 (gnus-run-hooks 'gnus-summary-mode-hook)
2642 (turn-on-gnus-mailing-list-mode)
2643 (mm-enable-multibyte)
2644 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2645 (gnus-update-summary-mark-positions))
2647 (defun gnus-summary-make-local-variables ()
2648 "Make all the local summary buffer variables."
2650 (dolist (local gnus-summary-local-variables)
2653 (if (eq (cdr local) 'global)
2654 ;; Copy the global value of the variable.
2655 (setq global (symbol-value (car local)))
2656 ;; Use the value from the list.
2657 (setq global (eval (cdr local))))
2658 (set (make-local-variable (car local)) global))
2659 ;; Simple nil-valued local variable.
2660 (set (make-local-variable local) nil)))))
2662 (defun gnus-summary-clear-local-variables ()
2663 (let ((locals gnus-summary-local-variables))
2665 (if (consp (car locals))
2666 (and (vectorp (caar locals))
2667 (set (caar locals) nil))
2668 (and (vectorp (car locals))
2669 (set (car locals) nil)))
2670 (setq locals (cdr locals)))))
2672 ;; Summary data functions.
2674 (defmacro gnus-data-number (data)
2677 (defmacro gnus-data-set-number (data number)
2678 `(setcar ,data ,number))
2680 (defmacro gnus-data-mark (data)
2683 (defmacro gnus-data-set-mark (data mark)
2684 `(setcar (nthcdr 1 ,data) ,mark))
2686 (defmacro gnus-data-pos (data)
2689 (defmacro gnus-data-set-pos (data pos)
2690 `(setcar (nthcdr 2 ,data) ,pos))
2692 (defmacro gnus-data-header (data)
2695 (defmacro gnus-data-set-header (data header)
2696 `(setf (nth 3 ,data) ,header))
2698 (defmacro gnus-data-level (data)
2701 (defmacro gnus-data-unread-p (data)
2702 `(= (nth 1 ,data) gnus-unread-mark))
2704 (defmacro gnus-data-read-p (data)
2705 `(/= (nth 1 ,data) gnus-unread-mark))
2707 (defmacro gnus-data-pseudo-p (data)
2708 `(consp (nth 3 ,data)))
2710 (defmacro gnus-data-find (number)
2711 `(assq ,number gnus-newsgroup-data))
2713 (defmacro gnus-data-find-list (number &optional data)
2714 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2715 (memq (assq ,number bdata)
2718 (defmacro gnus-data-make (number mark pos header level)
2719 `(list ,number ,mark ,pos ,header ,level))
2721 (defun gnus-data-enter (after-article number mark pos header level offset)
2722 (let ((data (gnus-data-find-list after-article)))
2724 (error "No such article: %d" after-article))
2725 (setcdr data (cons (gnus-data-make number mark pos header level)
2727 (setq gnus-newsgroup-data-reverse nil)
2728 (gnus-data-update-list (cddr data) offset)))
2730 (defun gnus-data-enter-list (after-article list &optional offset)
2732 (let ((data (and after-article (gnus-data-find-list after-article)))
2736 (let ((odata gnus-newsgroup-data))
2737 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2739 (gnus-data-update-list odata offset)))
2740 ;; Find the last element in the list to be spliced into the main
2743 (setq list (cdr list)))
2746 (setcdr list gnus-newsgroup-data)
2747 (setq gnus-newsgroup-data ilist)
2749 (gnus-data-update-list (cdr list) offset)))
2750 (setcdr list (cdr data))
2753 (gnus-data-update-list (cdr list) offset))))
2754 (setq gnus-newsgroup-data-reverse nil))))
2756 (defun gnus-data-remove (article &optional offset)
2757 (let ((data gnus-newsgroup-data))
2758 (if (= (gnus-data-number (car data)) article)
2760 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2761 gnus-newsgroup-data-reverse nil)
2763 (gnus-data-update-list gnus-newsgroup-data offset)))
2765 (when (= (gnus-data-number (cadr data)) article)
2766 (setcdr data (cddr data))
2768 (gnus-data-update-list (cdr data) offset))
2770 gnus-newsgroup-data-reverse nil))
2771 (setq data (cdr data))))))
2773 (defmacro gnus-data-list (backward)
2775 (or gnus-newsgroup-data-reverse
2776 (setq gnus-newsgroup-data-reverse
2777 (reverse gnus-newsgroup-data)))
2778 gnus-newsgroup-data))
2780 (defun gnus-data-update-list (data offset)
2781 "Add OFFSET to the POS of all data entries in DATA."
2782 (setq gnus-newsgroup-data-reverse nil)
2784 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2785 (setq data (cdr data))))
2787 (defun gnus-summary-article-pseudo-p (article)
2788 "Say whether this article is a pseudo article or not."
2789 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2791 (defmacro gnus-summary-article-sparse-p (article)
2792 "Say whether this article is a sparse article or not."
2793 `(memq ,article gnus-newsgroup-sparse))
2795 (defmacro gnus-summary-article-ancient-p (article)
2796 "Say whether this article is a sparse article or not."
2797 `(memq ,article gnus-newsgroup-ancient))
2799 (defun gnus-article-parent-p (number)
2800 "Say whether this article is a parent or not."
2801 (let ((data (gnus-data-find-list number)))
2802 (and (cdr data) ; There has to be an article after...
2803 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2804 (gnus-data-level (nth 1 data))))))
2806 (defun gnus-article-children (number)
2807 "Return a list of all children to NUMBER."
2808 (let* ((data (gnus-data-find-list number))
2809 (level (gnus-data-level (car data)))
2811 (setq data (cdr data))
2813 (= (gnus-data-level (car data)) (1+ level)))
2814 (push (gnus-data-number (car data)) children)
2815 (setq data (cdr data)))
2818 (defmacro gnus-summary-skip-intangible ()
2819 "If the current article is intangible, then jump to a different article."
2820 '(let ((to (get-text-property (point) 'gnus-intangible)))
2821 (and to (gnus-summary-goto-subject to))))
2823 (defmacro gnus-summary-article-intangible-p ()
2824 "Say whether this article is intangible or not."
2825 '(get-text-property (point) 'gnus-intangible))
2827 (defun gnus-article-read-p (article)
2828 "Say whether ARTICLE is read or not."
2829 (not (or (memq article gnus-newsgroup-marked)
2830 (memq article gnus-newsgroup-spam-marked)
2831 (memq article gnus-newsgroup-unreads)
2832 (memq article gnus-newsgroup-unselected)
2833 (memq article gnus-newsgroup-dormant))))
2835 ;; Some summary mode macros.
2837 (defmacro gnus-summary-article-number ()
2838 "The article number of the article on the current line.
2839 If there isn't an article number here, then we return the current
2842 (gnus-summary-skip-intangible)
2843 (or (get-text-property (point) 'gnus-number)
2844 (gnus-summary-last-subject))))
2846 (defmacro gnus-summary-article-header (&optional number)
2847 "Return the header of article NUMBER."
2848 `(gnus-data-header (gnus-data-find
2849 ,(or number '(gnus-summary-article-number)))))
2851 (defmacro gnus-summary-thread-level (&optional number)
2852 "Return the level of thread that starts with article NUMBER."
2853 `(if (and (eq gnus-summary-make-false-root 'dummy)
2854 (get-text-property (point) 'gnus-intangible))
2856 (gnus-data-level (gnus-data-find
2857 ,(or number '(gnus-summary-article-number))))))
2859 (defmacro gnus-summary-article-mark (&optional number)
2860 "Return the mark of article NUMBER."
2861 `(gnus-data-mark (gnus-data-find
2862 ,(or number '(gnus-summary-article-number)))))
2864 (defmacro gnus-summary-article-pos (&optional number)
2865 "Return the position of the line of article NUMBER."
2866 `(gnus-data-pos (gnus-data-find
2867 ,(or number '(gnus-summary-article-number)))))
2869 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2870 (defmacro gnus-summary-article-subject (&optional number)
2871 "Return current subject string or nil if nothing."
2874 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2875 '(gnus-data-header (assq (gnus-summary-article-number)
2876 gnus-newsgroup-data)))))
2879 (mail-header-subject headers))))
2881 (defmacro gnus-summary-article-score (&optional number)
2882 "Return current article score."
2883 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2884 gnus-newsgroup-scored))
2885 gnus-summary-default-score 0))
2887 (defun gnus-summary-article-children (&optional number)
2888 "Return a list of article numbers that are children of article NUMBER."
2889 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2890 (level (gnus-data-level (car data)))
2892 (while (and (setq data (cdr data))
2893 (> (setq l (gnus-data-level (car data))) level))
2894 (and (= (1+ level) l)
2895 (push (gnus-data-number (car data))
2897 (nreverse children)))
2899 (defun gnus-summary-article-parent (&optional number)
2900 "Return the article number of the parent of article NUMBER."
2901 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2902 (gnus-data-list t)))
2903 (level (gnus-data-level (car data))))
2905 () ; This is a root.
2906 ;; We search until we find an article with a level less than
2907 ;; this one. That function has to be the parent.
2908 (while (and (setq data (cdr data))
2909 (not (< (gnus-data-level (car data)) level))))
2910 (and data (gnus-data-number (car data))))))
2912 (defun gnus-unread-mark-p (mark)
2913 "Say whether MARK is the unread mark."
2914 (= mark gnus-unread-mark))
2916 (defun gnus-read-mark-p (mark)
2917 "Say whether MARK is one of the marks that mark as read.
2918 This is all marks except unread, ticked, dormant, and expirable."
2919 (not (or (= mark gnus-unread-mark)
2920 (= mark gnus-ticked-mark)
2921 (= mark gnus-spam-mark)
2922 (= mark gnus-dormant-mark)
2923 (= mark gnus-expirable-mark))))
2925 (defmacro gnus-article-mark (number)
2926 "Return the MARK of article NUMBER.
2927 This macro should only be used when computing the mark the \"first\"
2928 time; i.e., when generating the summary lines. After that,
2929 `gnus-summary-article-mark' should be used to examine the
2932 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2933 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2934 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2935 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2936 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2937 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2938 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2939 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2940 gnus-ancient-mark))))
2942 ;; Saving hidden threads.
2944 (defmacro gnus-save-hidden-threads (&rest forms)
2945 "Save hidden threads, eval FORMS, and restore the hidden threads."
2946 (let ((config (make-symbol "config")))
2947 `(let ((,config (gnus-hidden-threads-configuration)))
2951 (gnus-restore-hidden-threads-configuration ,config)))))
2952 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2953 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2955 (defun gnus-data-compute-positions ()
2956 "Compute the positions of all articles."
2957 (setq gnus-newsgroup-data-reverse nil)
2958 (let ((data gnus-newsgroup-data))
2960 (gnus-save-hidden-threads
2961 (gnus-summary-show-all-threads)
2962 (goto-char (point-min))
2964 (while (get-text-property (point) 'gnus-intangible)
2966 (gnus-data-set-pos (car data) (+ (point) 3))
2967 (setq data (cdr data))
2968 (forward-line 1))))))
2970 (defun gnus-hidden-threads-configuration ()
2971 "Return the current hidden threads configuration."
2974 (goto-char (point-min))
2975 (while (search-forward "\r" nil t)
2976 (push (1- (point)) config))
2979 (defun gnus-restore-hidden-threads-configuration (config)
2980 "Restore hidden threads configuration from CONFIG."
2982 (let (point buffer-read-only)
2983 (while (setq point (pop config))
2984 (when (and (< point (point-max))
2986 (eq (char-after) ?\n))
2987 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2989 ;; Various summary mode internalish functions.
2991 (defun gnus-mouse-pick-article (e)
2994 (gnus-summary-next-page nil t))
2996 (defun gnus-summary-set-display-table ()
2997 "Change the display table.
2998 Odd characters have a tendency to mess
2999 up nicely formatted displays - we make all possible glyphs
3000 display only a single character."
3002 ;; We start from the standard display table, if any.
3003 (let ((table (or (copy-sequence standard-display-table)
3004 (make-display-table)))
3006 ;; Nix out all the control chars...
3007 (while (>= (setq i (1- i)) 0)
3008 (aset table i [??]))
3009 ;; ... but not newline and cr, of course. (cr is necessary for the
3010 ;; selective display).
3011 (aset table ?\n nil)
3012 (aset table ?\r nil)
3013 ;; We keep TAB as well.
3014 (aset table ?\t nil)
3015 ;; We nix out any glyphs over 126 that are not set already.
3017 (while (>= (setq i (1- i)) 127)
3018 ;; Only modify if the entry is nil.
3019 (unless (aref table i)
3020 (aset table i [??]))))
3021 (setq buffer-display-table table)))
3023 (defun gnus-summary-set-article-display-arrow (pos)
3024 "Update the overlay arrow to point to line at position POS."
3025 (when (and gnus-summary-display-arrow
3026 (boundp 'overlay-arrow-position)
3027 (boundp 'overlay-arrow-string))
3031 (unless overlay-arrow-position
3032 (setq overlay-arrow-position (make-marker)))
3033 (setq overlay-arrow-string "=>"
3034 overlay-arrow-position (set-marker overlay-arrow-position
3036 (current-buffer))))))
3038 (defun gnus-summary-buffer-name (group)
3039 "Return the summary buffer name of GROUP."
3040 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3042 (defun gnus-summary-setup-buffer (group)
3043 "Initialize summary buffer."
3044 (let ((buffer (gnus-summary-buffer-name group))
3045 (dead-name (concat "*Dead Summary "
3046 (gnus-group-decoded-name group) "*")))
3047 ;; If a dead summary buffer exists, we kill it.
3048 (when (gnus-buffer-live-p dead-name)
3049 (gnus-kill-buffer dead-name))
3050 (if (get-buffer buffer)
3053 (setq gnus-summary-buffer (current-buffer))
3054 (not gnus-newsgroup-prepared))
3055 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3056 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3057 (gnus-summary-mode group)
3059 (gnus-carpal-setup-buffer 'summary))
3060 (unless gnus-single-article-buffer
3061 (make-local-variable 'gnus-article-buffer)
3062 (make-local-variable 'gnus-article-current)
3063 (make-local-variable 'gnus-original-article-buffer))
3064 (setq gnus-newsgroup-name group)
3065 ;; Set any local variables in the group parameters.
3066 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3069 (defun gnus-set-global-variables ()
3070 "Set the global equivalents of the buffer-local variables.
3071 They are set to the latest values they had. These reflect the summary
3072 buffer that was in action when the last article was fetched."
3073 (when (eq major-mode 'gnus-summary-mode)
3074 (setq gnus-summary-buffer (current-buffer))
3075 (let ((name gnus-newsgroup-name)
3076 (marked gnus-newsgroup-marked)
3077 (spam gnus-newsgroup-spam-marked)
3078 (unread gnus-newsgroup-unreads)
3079 (headers gnus-current-headers)
3080 (data gnus-newsgroup-data)
3081 (summary gnus-summary-buffer)
3082 (article-buffer gnus-article-buffer)
3083 (original gnus-original-article-buffer)
3084 (gac gnus-article-current)
3085 (reffed gnus-reffed-article-number)
3086 (score-file gnus-current-score-file)
3087 (default-charset gnus-newsgroup-charset)
3089 (let ((locals gnus-newsgroup-variables))
3091 (if (consp (car locals))
3092 (push (eval (caar locals)) vlist)
3093 (push (eval (car locals)) vlist))
3094 (setq locals (cdr locals)))
3095 (setq vlist (nreverse vlist)))
3097 (set-buffer gnus-group-buffer)
3098 (setq gnus-newsgroup-name name
3099 gnus-newsgroup-marked marked
3100 gnus-newsgroup-spam-marked spam
3101 gnus-newsgroup-unreads unread
3102 gnus-current-headers headers
3103 gnus-newsgroup-data data
3104 gnus-article-current gac
3105 gnus-summary-buffer summary
3106 gnus-article-buffer article-buffer
3107 gnus-original-article-buffer original
3108 gnus-reffed-article-number reffed
3109 gnus-current-score-file score-file
3110 gnus-newsgroup-charset default-charset)
3111 (let ((locals gnus-newsgroup-variables))
3113 (if (consp (car locals))
3114 (set (caar locals) (pop vlist))
3115 (set (car locals) (pop vlist)))
3116 (setq locals (cdr locals))))
3117 ;; The article buffer also has local variables.
3118 (when (gnus-buffer-live-p gnus-article-buffer)
3119 (set-buffer gnus-article-buffer)
3120 (setq gnus-summary-buffer summary))))))
3122 (defun gnus-summary-article-unread-p (article)
3123 "Say whether ARTICLE is unread or not."
3124 (memq article gnus-newsgroup-unreads))
3126 (defun gnus-summary-first-article-p (&optional article)
3127 "Return whether ARTICLE is the first article in the buffer."
3128 (if (not (setq article (or article (gnus-summary-article-number))))
3130 (eq article (caar gnus-newsgroup-data))))
3132 (defun gnus-summary-last-article-p (&optional article)
3133 "Return whether ARTICLE is the last article in the buffer."
3134 (if (not (setq article (or article (gnus-summary-article-number))))
3135 ;; All non-existent numbers are the last article. :-)
3137 (not (cdr (gnus-data-find-list article)))))
3139 (defun gnus-make-thread-indent-array ()
3141 (unless (and gnus-thread-indent-array
3142 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3143 (setq gnus-thread-indent-array (make-vector 201 "")
3144 gnus-thread-indent-array-level gnus-thread-indent-level)
3146 (aset gnus-thread-indent-array n
3147 (make-string (* n gnus-thread-indent-level) ? ))
3150 (defun gnus-update-summary-mark-positions ()
3151 "Compute where the summary marks are to go."
3153 (when (gnus-buffer-exists-p gnus-summary-buffer)
3154 (set-buffer gnus-summary-buffer))
3155 (let ((gnus-replied-mark 129)
3156 (gnus-score-below-mark 130)
3157 (gnus-score-over-mark 130)
3158 (gnus-undownloaded-mark 131)
3159 (spec gnus-summary-line-format-spec)
3162 (gnus-set-work-buffer)
3163 (let ((gnus-summary-line-format-spec spec)
3164 (gnus-newsgroup-downloadable '(0)))
3165 (gnus-summary-insert-line
3166 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3167 0 nil t 128 t nil "" nil 1)
3168 (goto-char (point-min))
3169 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3170 (- (point) (point-min) 1)))))
3171 (goto-char (point-min))
3172 (push (cons 'replied (and (search-forward "\201" nil t)
3173 (- (point) (point-min) 1)))
3175 (goto-char (point-min))
3176 (push (cons 'score (and (search-forward "\202" nil t)
3177 (- (point) (point-min) 1)))
3179 (goto-char (point-min))
3180 (push (cons 'download
3181 (and (search-forward "\203" nil t)
3182 (- (point) (point-min) 1)))
3184 (setq gnus-summary-mark-positions pos))))
3186 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3187 "Insert a dummy root in the summary buffer."
3189 (gnus-add-text-properties
3190 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3191 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3193 (defun gnus-summary-extract-address-component (from)
3194 (or (car (funcall gnus-extract-address-components from))
3197 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3198 (let ((mail-parse-charset gnus-newsgroup-charset)
3199 ; Is it really necessary to do this next part for each summary line?
3200 ; Luckily, doesn't seem to slow things down much.
3201 (mail-parse-ignored-charsets
3202 (save-excursion (set-buffer gnus-summary-buffer)
3203 gnus-newsgroup-ignored-charsets)))
3205 (and gnus-ignored-from-addresses
3206 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3207 (let ((extra-headers (mail-header-extra header))
3211 ((setq to (cdr (assq 'To extra-headers)))
3214 (gnus-summary-extract-address-component
3215 (funcall gnus-decode-encoded-word-function to)))))
3216 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3217 (concat "=> " newsgroups)))))
3218 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3220 (defun gnus-summary-insert-line (gnus-tmp-header
3221 gnus-tmp-level gnus-tmp-current
3222 undownloaded gnus-tmp-unread gnus-tmp-replied
3223 gnus-tmp-expirable gnus-tmp-subject-or-nil
3224 &optional gnus-tmp-dummy gnus-tmp-score
3226 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3227 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3228 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3229 (gnus-tmp-score-char
3230 (if (or (null gnus-summary-default-score)
3231 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3232 gnus-summary-zcore-fuzz))
3234 (if (< gnus-tmp-score gnus-summary-default-score)
3235 gnus-score-below-mark gnus-score-over-mark)))
3236 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3238 (cond (gnus-tmp-process gnus-process-mark)
3239 ((memq gnus-tmp-current gnus-newsgroup-cached)
3241 (gnus-tmp-replied gnus-replied-mark)
3242 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3243 gnus-forwarded-mark)
3244 ((memq gnus-tmp-current gnus-newsgroup-saved)
3246 ((memq gnus-tmp-number gnus-newsgroup-recent)
3248 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3251 (gnus-tmp-downloaded
3253 gnus-undownloaded-mark)
3254 (gnus-newsgroup-agentized
3255 gnus-downloaded-mark)
3258 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3261 ((string-match "<[^>]+> *$" gnus-tmp-from)
3262 (let ((beg (match-beginning 0)))
3263 (or (and (string-match "^\".+\"" gnus-tmp-from)
3264 (substring gnus-tmp-from 1 (1- (match-end 0))))
3265 (substring gnus-tmp-from 0 beg))))
3266 ((string-match "(.+)" gnus-tmp-from)
3267 (substring gnus-tmp-from
3268 (1+ (match-beginning 0)) (1- (match-end 0))))
3270 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3271 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3272 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3273 (buffer-read-only nil))
3274 (when (string= gnus-tmp-name "")
3275 (setq gnus-tmp-name gnus-tmp-from))
3276 (unless (numberp gnus-tmp-lines)
3277 (setq gnus-tmp-lines -1))
3278 (if (= gnus-tmp-lines -1)
3279 (setq gnus-tmp-lines "?")
3280 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3281 (gnus-put-text-property
3283 (progn (eval gnus-summary-line-format-spec) (point))
3284 'gnus-number gnus-tmp-number)
3285 (when (gnus-visual-p 'summary-highlight 'highlight)
3287 (gnus-run-hooks 'gnus-summary-update-hook)
3290 (defun gnus-summary-update-line (&optional dont-update)
3291 "Update summary line after change."
3292 (when (and gnus-summary-default-score
3293 (not gnus-summary-inhibit-highlight))
3294 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3295 (article (gnus-summary-article-number))
3296 (score (gnus-summary-article-score article)))
3298 (if (and gnus-summary-mark-below
3299 (< (gnus-summary-article-score)
3300 gnus-summary-mark-below))
3301 ;; This article has a low score, so we mark it as read.
3302 (when (memq article gnus-newsgroup-unreads)
3303 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3304 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3305 ;; This article was previously marked as read on account
3306 ;; of a low score, but now it has risen, so we mark it as
3308 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3309 (gnus-summary-update-mark
3310 (if (or (null gnus-summary-default-score)
3311 (<= (abs (- score gnus-summary-default-score))
3312 gnus-summary-zcore-fuzz))
3314 (if (< score gnus-summary-default-score)
3315 gnus-score-below-mark gnus-score-over-mark))
3317 ;; Do visual highlighting.
3318 (when (gnus-visual-p 'summary-highlight 'highlight)
3319 (gnus-run-hooks 'gnus-summary-update-hook)))))
3321 (defvar gnus-tmp-new-adopts nil)
3323 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3324 "Return the number of articles in THREAD.
3325 This may be 0 in some cases -- if none of the articles in
3326 the thread are to be displayed."
3328 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3330 ((not (listp thread))
3332 ((and (consp thread) (cdr thread))
3335 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3338 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3341 (when (and level (zerop level) gnus-tmp-new-adopts)
3344 'gnus-summary-number-of-articles-in-thread
3345 gnus-tmp-new-adopts))))
3347 (if (> number 1) gnus-not-empty-thread-mark
3348 gnus-empty-thread-mark)
3351 (defsubst gnus-summary-line-message-size (head)
3352 "Return pretty-printed version of message size.
3353 This function is intended to be used in
3354 `gnus-summary-line-format-alist', which see."
3355 (let ((c (or (mail-header-chars head) -1)))
3356 (cond ((< c 0) "n/a") ; chars not available
3357 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3358 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3359 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3360 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3363 (defun gnus-summary-set-local-parameters (group)
3364 "Go through the local params of GROUP and set all variable specs in that list."
3365 (let ((params (gnus-group-find-parameter group))
3366 (vars '(quit-config)) ; Ignore quit-config.
3369 (setq elem (car params)
3370 params (cdr params))
3371 (and (consp elem) ; Has to be a cons.
3372 (consp (cdr elem)) ; The cdr has to be a list.
3373 (symbolp (car elem)) ; Has to be a symbol in there.
3374 (not (memq (car elem) vars))
3375 (ignore-errors ; So we set it.
3376 (push (car elem) vars)
3377 (make-local-variable (car elem))
3378 (set (car elem) (eval (nth 1 elem))))))))
3380 (defun gnus-summary-read-group (group &optional show-all no-article
3381 kill-buffer no-display backward
3383 "Start reading news in newsgroup GROUP.
3384 If SHOW-ALL is non-nil, already read articles are also listed.
3385 If NO-ARTICLE is non-nil, no article is selected initially.
3386 If NO-DISPLAY, don't generate a summary buffer."
3390 (let ((gnus-auto-select-next nil))
3391 (or (gnus-summary-read-group-1
3392 group show-all no-article
3393 kill-buffer no-display
3396 select-articles nil)))))
3397 (eq gnus-auto-select-next 'quietly))
3398 (set-buffer gnus-group-buffer)
3399 ;; The entry function called above goes to the next
3400 ;; group automatically, so we go two groups back
3401 ;; if we are searching for the previous group.
3403 (gnus-group-prev-unread-group 2))
3404 (if (not (equal group (gnus-group-group-name)))
3405 (setq group (gnus-group-group-name))
3409 (defun gnus-summary-read-group-1 (group show-all no-article
3410 kill-buffer no-display
3411 &optional select-articles)
3412 ;; Killed foreign groups can't be entered.
3413 ;; (when (and (not (gnus-group-native-p group))
3414 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3415 ;; (error "Dead non-native groups can't be entered"))
3416 (gnus-message 5 "Retrieving newsgroup: %s..."
3417 (gnus-group-decoded-name group))
3418 (let* ((new-group (gnus-summary-setup-buffer group))
3419 (quit-config (gnus-group-quit-config group))
3420 (did-select (and new-group (gnus-select-newsgroup
3421 group show-all select-articles))))
3423 ;; This summary buffer exists already, so we just select it.
3425 (gnus-set-global-variables)
3427 (gnus-kill-or-deaden-summary kill-buffer))
3428 (gnus-configure-windows 'summary 'force)
3429 (gnus-set-mode-line 'summary)
3430 (gnus-summary-position-point)
3433 ;; We couldn't select this group.
3435 (when (and (eq major-mode 'gnus-summary-mode)
3436 (not (equal (current-buffer) kill-buffer)))
3437 (kill-buffer (current-buffer))
3438 (if (not quit-config)
3440 ;; Update the info -- marks might need to be removed,
3442 (gnus-summary-update-info)
3443 (set-buffer gnus-group-buffer)
3444 (gnus-group-jump-to-group group)
3445 (gnus-group-next-unread-group 1))
3446 (gnus-handle-ephemeral-exit quit-config)))
3447 (let ((grpinfo (gnus-get-info group)))
3448 (if (null (gnus-info-read grpinfo))
3449 (gnus-message 3 "Group %s contains no messages"
3450 (gnus-group-decoded-name group))
3451 (gnus-message 3 "Can't select group")))
3453 ;; The user did a `C-g' while prompting for number of articles,
3454 ;; so we exit this group.
3455 ((eq did-select 'quit)
3456 (and (eq major-mode 'gnus-summary-mode)
3457 (not (equal (current-buffer) kill-buffer))
3458 (kill-buffer (current-buffer)))
3460 (gnus-kill-or-deaden-summary kill-buffer))
3461 (if (not quit-config)
3463 (set-buffer gnus-group-buffer)
3464 (gnus-group-jump-to-group group)
3465 (gnus-group-next-unread-group 1)
3466 (gnus-configure-windows 'group 'force))
3467 (gnus-handle-ephemeral-exit quit-config))
3468 ;; Finally signal the quit.
3470 ;; The group was successfully selected.
3472 (gnus-set-global-variables)
3473 ;; Save the active value in effect when the group was entered.
3474 (setq gnus-newsgroup-active
3476 (gnus-active gnus-newsgroup-name)))
3477 ;; You can change the summary buffer in some way with this hook.
3478 (gnus-run-hooks 'gnus-select-group-hook)
3479 (gnus-update-format-specifications
3480 nil 'summary 'summary-mode 'summary-dummy)
3481 (gnus-update-summary-mark-positions)
3482 ;; Do score processing.
3483 (when gnus-use-scoring
3484 (gnus-possibly-score-headers))
3485 ;; Check whether to fill in the gaps in the threads.
3486 (when gnus-build-sparse-threads
3487 (gnus-build-sparse-threads))
3488 ;; Find the initial limit.
3489 (if gnus-show-threads
3491 (let ((gnus-newsgroup-dormant nil))
3492 (gnus-summary-initial-limit show-all))
3493 (gnus-summary-initial-limit show-all))
3494 ;; When unthreaded, all articles are always shown.
3495 (setq gnus-newsgroup-limit
3497 (lambda (header) (mail-header-number header))
3498 gnus-newsgroup-headers)))
3499 ;; Generate the summary buffer.
3501 (gnus-summary-prepare))
3502 (when gnus-use-trees
3503 (gnus-tree-open group)
3504 (setq gnus-summary-highlight-line-function
3505 'gnus-tree-highlight-article))
3506 ;; If the summary buffer is empty, but there are some low-scored
3507 ;; articles or some excluded dormants, we include these in the
3509 (when (and (zerop (buffer-size))
3511 (cond (gnus-newsgroup-dormant
3512 (gnus-summary-limit-include-dormant))
3513 ((and gnus-newsgroup-scored show-all)
3514 (gnus-summary-limit-include-expunged t))))
3515 ;; Function `gnus-apply-kill-file' must be called in this hook.
3516 (gnus-run-hooks 'gnus-apply-kill-hook)
3517 (if (and (zerop (buffer-size))
3520 ;; This newsgroup is empty.
3521 (gnus-summary-catchup-and-exit nil t)
3522 (gnus-message 6 "No unread news")
3524 (gnus-kill-or-deaden-summary kill-buffer))
3525 ;; Return nil from this function.
3527 ;; Hide conversation thread subtrees. We cannot do this in
3528 ;; gnus-summary-prepare-hook since kill processing may not
3529 ;; work with hidden articles.
3530 (gnus-summary-maybe-hide-threads)
3532 (gnus-kill-or-deaden-summary kill-buffer))
3533 (gnus-summary-auto-select-subject)
3534 ;; Show first unread article if requested.
3535 (if (and (not no-article)
3537 gnus-newsgroup-unreads
3538 gnus-auto-select-first)
3540 (gnus-configure-windows 'summary)
3541 (let ((art (gnus-summary-article-number)))
3542 (unless (and (not gnus-plugged)
3543 (or (memq art gnus-newsgroup-undownloaded)
3544 (memq art gnus-newsgroup-downloadable)))
3545 (gnus-summary-goto-article art))))
3546 ;; Don't select any articles.
3547 (gnus-summary-position-point)
3548 (gnus-configure-windows 'summary 'force)
3549 (gnus-set-mode-line 'summary))
3550 (when (and gnus-auto-center-group
3551 (get-buffer-window gnus-group-buffer t))
3552 ;; Gotta use windows, because recenter does weird stuff if
3553 ;; the current buffer ain't the displayed window.
3554 (let ((owin (selected-window)))
3555 (select-window (get-buffer-window gnus-group-buffer t))
3556 (when (gnus-group-goto-group group)
3558 (select-window owin)))
3559 ;; Mark this buffer as "prepared".
3560 (setq gnus-newsgroup-prepared t)
3561 (gnus-run-hooks 'gnus-summary-prepared-hook)
3562 (unless (gnus-ephemeral-group-p group)
3563 (gnus-group-update-group group))
3566 (defun gnus-summary-auto-select-subject ()
3567 "Select the subject line on initial group entry."
3568 (goto-char (point-min))
3570 ((eq gnus-auto-select-subject 'best)
3571 (gnus-summary-best-unread-subject))
3572 ((eq gnus-auto-select-subject 'unread)
3573 (gnus-summary-first-unread-subject))
3574 ((eq gnus-auto-select-subject 'unseen)
3575 (gnus-summary-first-unseen-subject))
3576 ((eq gnus-auto-select-subject 'unseen-or-unread)
3577 (gnus-summary-first-unseen-or-unread-subject))
3578 ((eq gnus-auto-select-subject 'first)
3581 ((gnus-functionp gnus-auto-select-subject)
3582 (funcall gnus-auto-select-subject))))
3584 (defun gnus-summary-prepare ()
3585 "Generate the summary buffer."
3587 (let ((buffer-read-only nil))
3589 (setq gnus-newsgroup-data nil
3590 gnus-newsgroup-data-reverse nil)
3591 (gnus-run-hooks 'gnus-summary-generate-hook)
3592 ;; Generate the buffer, either with threads or without.
3593 (when gnus-newsgroup-headers
3594 (gnus-summary-prepare-threads
3595 (if gnus-show-threads
3596 (gnus-sort-gathered-threads
3597 (funcall gnus-summary-thread-gathering-function
3599 (gnus-cut-threads (gnus-make-threads)))))
3600 ;; Unthreaded display.
3601 (gnus-sort-articles gnus-newsgroup-headers))))
3602 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3603 ;; Call hooks for modifying summary buffer.
3604 (goto-char (point-min))
3605 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3607 (defsubst gnus-general-simplify-subject (subject)
3608 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3611 ;; Truncate the subject.
3612 (gnus-simplify-subject-functions
3613 (gnus-map-function gnus-simplify-subject-functions subject))
3614 ((numberp gnus-summary-gather-subject-limit)
3615 (setq subject (gnus-simplify-subject-re subject))
3616 (if (> (length subject) gnus-summary-gather-subject-limit)
3617 (substring subject 0 gnus-summary-gather-subject-limit)
3619 ;; Fuzzily simplify it.
3620 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3621 (gnus-simplify-subject-fuzzy subject))
3622 ;; Just remove the leading "Re:".
3624 (gnus-simplify-subject-re subject))))
3626 (if (and gnus-summary-gather-exclude-subject
3627 (string-match gnus-summary-gather-exclude-subject subject))
3628 nil ; This article shouldn't be gathered
3631 (defun gnus-summary-simplify-subject-query ()
3632 "Query where the respool algorithm would put this article."
3634 (gnus-summary-select-article)
3635 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3637 (defun gnus-gather-threads-by-subject (threads)
3638 "Gather threads by looking at Subject headers."
3639 (if (not gnus-summary-make-false-root)
3641 (let ((hashtb (gnus-make-hashtable 1024))
3644 subject hthread whole-subject)
3646 (setq subject (gnus-general-simplify-subject
3647 (setq whole-subject (mail-header-subject
3650 (if (setq hthread (gnus-gethash subject hashtb))
3652 ;; We enter a dummy root into the thread, if we
3653 ;; haven't done that already.
3654 (unless (stringp (caar hthread))
3655 (setcar hthread (list whole-subject (car hthread))))
3656 ;; We add this new gathered thread to this gathered
3658 (setcdr (car hthread)
3659 (nconc (cdar hthread) (list (car threads))))
3660 ;; Remove it from the list of threads.
3661 (setcdr prev (cdr threads))
3662 (setq threads prev))
3663 ;; Enter this thread into the hash table.
3664 (gnus-sethash subject
3665 (if gnus-summary-make-false-root-always
3667 ;; If you want a dummy root above all
3669 (setcar threads (list whole-subject
3675 (setq threads (cdr threads)))
3678 (defun gnus-gather-threads-by-references (threads)
3679 "Gather threads by looking at References headers."
3680 (let ((idhashtb (gnus-make-hashtable 1024))
3681 (thhashtb (gnus-make-hashtable 1024))
3684 ids references id gthread gid entered ref)
3686 (when (setq references (mail-header-references (caar threads)))
3687 (setq id (mail-header-id (caar threads))
3688 ids (inline (gnus-split-references references))
3690 (while (setq ref (pop ids))
3691 (setq ids (delete ref ids))
3692 (if (not (setq gid (gnus-gethash ref idhashtb)))
3694 (gnus-sethash ref id idhashtb)
3695 (gnus-sethash id threads thhashtb))
3696 (setq gthread (gnus-gethash gid thhashtb))
3698 ;; We enter a dummy root into the thread, if we
3699 ;; haven't done that already.
3700 (unless (stringp (caar gthread))
3701 (setcar gthread (list (mail-header-subject (caar gthread))
3703 ;; We add this new gathered thread to this gathered
3705 (setcdr (car gthread)
3706 (nconc (cdar gthread) (list (car threads)))))
3707 ;; Add it into the thread hash table.
3708 (gnus-sethash id gthread thhashtb)
3710 ;; Remove it from the list of threads.
3711 (setcdr prev (cdr threads))
3712 (setq threads prev))))
3714 (setq threads (cdr threads)))
3717 (defun gnus-sort-gathered-threads (threads)
3718 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3719 (let ((result threads))
3721 (when (stringp (caar threads))
3722 (setcdr (car threads)
3723 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3724 (setq threads (cdr threads)))
3727 (defun gnus-thread-loop-p (root thread)
3728 "Say whether ROOT is in THREAD."
3729 (let ((stack (list thread))
3732 (while (setq thread (pop stack))
3733 (setq th (cdr thread))
3735 (not (eq (caar th) root)))
3738 ;; We have found a loop.
3740 (setcdr thread (delq (car th) (cdr thread)))
3741 (if (boundp (setq ref-dep (intern "none"
3742 gnus-newsgroup-dependencies)))
3743 (setcdr (symbol-value ref-dep)
3744 (nconc (cdr (symbol-value ref-dep))
3746 (set ref-dep (list nil (car th))))
3749 ;; Push all the subthreads onto the stack.
3750 (push (cdr thread) stack)))
3753 (defun gnus-make-threads ()
3754 "Go through the dependency hashtb and find the roots. Return all threads."
3756 (while (catch 'infloop
3759 ;; Deal with self-referencing References loops.
3760 (when (and (car (symbol-value refs))
3767 (car (symbol-value refs)) thread))
3768 (cdr (symbol-value refs)))))))
3771 (unless (car (symbol-value refs))
3772 ;; These threads do not refer back to any other
3773 ;; articles, so they're roots.
3774 (setq threads (append (cdr (symbol-value refs)) threads))))
3775 gnus-newsgroup-dependencies)))
3778 ;; Build the thread tree.
3779 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3780 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3782 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3783 if it was already present.
3785 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3786 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3787 Message-IDs will be renamed to a unique Message-ID before being
3790 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3791 (let* ((id (mail-header-id header))
3792 (id-dep (and id (intern id dependencies)))
3793 parent-id ref ref-dep ref-header replaced)
3794 ;; Enter this `header' in the `dependencies' table.
3798 ;; The first two cases do the normal part: enter a new `header'
3799 ;; in the `dependencies' table.
3800 ((not (boundp id-dep))
3801 (set id-dep (list header)))
3802 ((null (car (symbol-value id-dep)))
3803 (setcar (symbol-value id-dep) header))
3805 ;; From here the `header' was already present in the
3806 ;; `dependencies' table.
3808 ;; Overrides an existing entry;
3809 ;; just set the header part of the entry.
3810 (setcar (symbol-value id-dep) header)
3813 ;; Renames the existing `header' to a unique Message-ID.
3814 ((not gnus-summary-ignore-duplicates)
3815 ;; An article with this Message-ID has already been seen.
3816 ;; We rename the Message-ID.
3817 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3819 (mail-header-set-id header id))
3821 ;; The last case ignores an existing entry, except it adds any
3822 ;; additional Xrefs (in case the two articles came from different
3824 ;; Also sets `header' to `nil' meaning that the `dependencies'
3825 ;; table was *not* modified.
3827 (mail-header-set-xref
3828 (car (symbol-value id-dep))
3829 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3831 (or (mail-header-xref header) "")))
3834 (when (and header (not replaced))
3835 ;; First check that we are not creating a References loop.
3836 (setq parent-id (gnus-parent-id (mail-header-references header)))
3837 (setq ref parent-id)
3839 (setq ref-dep (intern-soft ref dependencies))
3841 (setq ref-header (car (symbol-value ref-dep))))
3842 (if (string= id ref)
3843 ;; Yuk! This is a reference loop. Make the article be a
3846 (mail-header-set-references (car (symbol-value id-dep)) "none")
3848 (setq parent-id nil))
3849 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3850 (setq ref-dep (intern (or parent-id "none") dependencies))
3851 (if (boundp ref-dep)
3852 (setcdr (symbol-value ref-dep)
3853 (nconc (cdr (symbol-value ref-dep))
3854 (list (symbol-value id-dep))))
3855 (set ref-dep (list nil (symbol-value id-dep)))))
3858 (defun gnus-extract-message-id-from-in-reply-to (string)
3859 (if (string-match "<[^>]+>" string)
3860 (substring string (match-beginning 0) (match-end 0))
3863 (defun gnus-build-sparse-threads ()
3864 (let ((headers gnus-newsgroup-headers)
3865 (mail-parse-charset gnus-newsgroup-charset)
3866 (gnus-summary-ignore-duplicates t)
3867 header references generation relations
3868 subject child end new-child date)
3869 ;; First we create an alist of generations/relations, where
3870 ;; generations is how much we trust the relation, and the relation
3872 (gnus-message 7 "Making sparse threads...")
3874 (nnheader-set-temp-buffer " *gnus sparse threads*")
3875 (while (setq header (pop headers))
3876 (when (and (setq references (mail-header-references header))
3877 (not (string= references "")))
3879 (setq child (mail-header-id header)
3880 subject (mail-header-subject header)
3881 date (mail-header-date header)
3883 (while (search-backward ">" nil t)
3884 (setq end (1+ (point)))
3885 (when (search-backward "<" nil t)
3886 (setq new-child (buffer-substring (point) end))
3887 (push (list (incf generation)
3888 child (setq child new-child)
3892 (push (list (1+ generation) child nil subject) relations))
3894 (kill-buffer (current-buffer)))
3895 ;; Sort over trustworthiness.
3898 (when (gnus-dependencies-add-header
3899 (make-full-mail-header
3900 gnus-reffed-article-number
3901 (nth 3 relation) "" (or (nth 4 relation) "")
3903 (or (nth 2 relation) "") 0 0 "")
3904 gnus-newsgroup-dependencies nil)
3905 (push gnus-reffed-article-number gnus-newsgroup-limit)
3906 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3907 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3908 gnus-newsgroup-reads)
3909 (decf gnus-reffed-article-number)))
3910 (sort relations 'car-less-than-car))
3911 (gnus-message 7 "Making sparse threads...done")))
3913 (defun gnus-build-old-threads ()
3914 ;; Look at all the articles that refer back to old articles, and
3915 ;; fetch the headers for the articles that aren't there. This will
3916 ;; build complete threads - if the roots haven't been expired by the
3918 (let ((mail-parse-charset gnus-newsgroup-charset)
3922 (when (not (car (symbol-value refs)))
3923 (setq heads (cdr (symbol-value refs)))
3925 (if (memq (mail-header-number (caar heads))
3926 gnus-newsgroup-dormant)
3927 (setq heads (cdr heads))
3928 (setq id (symbol-name refs))
3929 (while (and (setq id (gnus-build-get-header id))
3930 (not (car (gnus-id-to-thread id)))))
3931 (setq heads nil)))))
3932 gnus-newsgroup-dependencies)))
3934 ;; This function has to be called with point after the article number
3935 ;; on the beginning of the line.
3936 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3937 (let ((eol (gnus-point-at-eol))
3938 (buffer (current-buffer))
3939 header references in-reply-to)
3941 ;; overview: [num subject from date id refs chars lines misc]
3944 (narrow-to-region (point) eol)
3949 (make-full-mail-header
3951 (condition-case () ; subject
3952 (funcall gnus-decode-encoded-word-function
3953 (setq x (nnheader-nov-field)))
3955 (condition-case () ; from
3956 (funcall gnus-decode-encoded-word-function
3957 (setq x (nnheader-nov-field)))
3959 (nnheader-nov-field) ; date
3960 (nnheader-nov-read-message-id) ; id
3961 (setq references (nnheader-nov-field)) ; refs
3962 (nnheader-nov-read-integer) ; chars
3963 (nnheader-nov-read-integer) ; lines
3965 (if (looking-at "Xref: ")
3966 (goto-char (match-end 0)))
3967 (nnheader-nov-field)) ; Xref
3968 (nnheader-nov-parse-extra)))) ; extra
3972 (when (and (string= references "")
3973 (setq in-reply-to (mail-header-extra header))
3974 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3975 (mail-header-set-references
3976 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3978 (when gnus-alter-header-function
3979 (funcall gnus-alter-header-function header))
3980 (gnus-dependencies-add-header header dependencies force-new)))
3982 (defun gnus-build-get-header (id)
3983 "Look through the buffer of NOV lines and find the header to ID.
3984 Enter this line into the dependencies hash table, and return
3985 the id of the parent article (if any)."
3986 (let ((deps gnus-newsgroup-dependencies)
3990 (set-buffer nntp-server-buffer)
3991 (let ((case-fold-search nil))
3992 (goto-char (point-min))
3993 (while (and (not found)
3994 (search-forward id nil t))
3996 (setq found (looking-at
3997 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3998 (regexp-quote id))))
3999 (or found (beginning-of-line 2)))
4003 (setq header (gnus-nov-parse-line
4004 (read (current-buffer)) deps))
4005 (gnus-parent-id (mail-header-references header))))))
4007 (let ((number (mail-header-number header)))
4008 (push number gnus-newsgroup-limit)
4009 (push header gnus-newsgroup-headers)
4010 (if (memq number gnus-newsgroup-unselected)
4012 (setq gnus-newsgroup-unreads
4013 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4015 (setq gnus-newsgroup-unselected
4016 (delq number gnus-newsgroup-unselected)))
4017 (push number gnus-newsgroup-ancient)))))))
4019 (defun gnus-build-all-threads ()
4020 "Read all the headers."
4021 (let ((gnus-summary-ignore-duplicates t)
4022 (mail-parse-charset gnus-newsgroup-charset)
4023 (dependencies gnus-newsgroup-dependencies)
4026 (set-buffer nntp-server-buffer)
4027 (let ((case-fold-search nil))
4028 (goto-char (point-min))
4031 (setq article (read (current-buffer))
4032 header (gnus-nov-parse-line article dependencies)))
4035 (set-buffer gnus-summary-buffer)
4036 (push header gnus-newsgroup-headers)
4037 (if (memq (setq article (mail-header-number header))
4038 gnus-newsgroup-unselected)
4040 (setq gnus-newsgroup-unreads
4041 (gnus-add-to-sorted-list
4042 gnus-newsgroup-unreads article))
4043 (setq gnus-newsgroup-unselected
4044 (delq article gnus-newsgroup-unselected)))
4045 (push article gnus-newsgroup-ancient)))
4046 (forward-line 1)))))))
4048 (defun gnus-summary-update-article-line (article header)
4049 "Update the line for ARTICLE using HEADERS."
4050 (let* ((id (mail-header-id header))
4051 (thread (gnus-id-to-thread id)))
4053 (error "Article in no thread"))
4054 ;; Update the thread.
4055 (setcar thread header)
4056 (gnus-summary-goto-subject article)
4057 (let* ((datal (gnus-data-find-list article))
4059 (buffer-read-only nil)
4060 (level (gnus-summary-thread-level)))
4062 (let ((inserted (- (point)
4064 (gnus-summary-insert-line
4066 (memq article gnus-newsgroup-undownloaded)
4067 (gnus-article-mark article)
4068 (memq article gnus-newsgroup-replied)
4069 (memq article gnus-newsgroup-expirable)
4070 ;; Only insert the Subject string when it's different
4071 ;; from the previous Subject string.
4076 (mail-header-subject
4079 (gnus-data-find-list
4081 (gnus-data-list t)))))
4082 ;; Error on the side of excessive subjects.
4084 (mail-header-subject header)))
4086 (mail-header-subject header))
4087 nil (cdr (assq article gnus-newsgroup-scored))
4088 (memq article gnus-newsgroup-processable))
4091 (gnus-data-update-list
4093 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4095 (defun gnus-summary-update-article (article &optional iheader)
4096 "Update ARTICLE in the summary buffer."
4097 (set-buffer gnus-summary-buffer)
4098 (let* ((header (gnus-summary-article-header article))
4099 (id (mail-header-id header))
4100 (data (gnus-data-find article))
4101 (thread (gnus-id-to-thread id))
4102 (references (mail-header-references header))
4106 (when (and references
4107 (not (equal "" references)))
4110 (buffer-read-only nil)
4116 (delq thread parent)))
4117 (if (gnus-summary-insert-subject id header)
4118 ;; Set the (possibly) new article number in the data structure.
4119 (gnus-data-set-number data (gnus-id-to-article id))
4123 (defun gnus-rebuild-thread (id &optional line)
4124 "Rebuild the thread containing ID.
4125 If LINE, insert the rebuilt thread starting on line LINE."
4126 (let ((buffer-read-only nil)
4127 old-pos current thread data)
4128 (if (not gnus-show-threads)
4129 (setq thread (list (car (gnus-id-to-thread id))))
4130 ;; Get the thread this article is part of.
4131 (setq thread (gnus-remove-thread id)))
4132 (setq old-pos (gnus-point-at-bol))
4133 (setq current (save-excursion
4134 (and (re-search-backward "[\r\n]" nil t)
4135 (gnus-summary-article-number))))
4136 ;; If this is a gathered thread, we have to go some re-gathering.
4137 (when (stringp (car thread))
4138 (let ((subject (car thread))
4140 (setq thread (cdr thread))
4142 (unless (memq (setq thr (gnus-id-to-thread
4144 (mail-header-id (caar thread)))))
4147 (setq thread (cdr thread)))
4148 ;; We now have all (unique) roots.
4149 (if (= (length roots) 1)
4150 ;; All the loose roots are now one solid root.
4151 (setq thread (car roots))
4152 (setq thread (cons subject (gnus-sort-threads roots))))))
4154 ;; We then insert this thread into the summary buffer.
4156 (goto-char (point-min))
4157 (forward-line (1- line)))
4158 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4159 (if gnus-show-threads
4160 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4161 (gnus-summary-prepare-unthreaded thread))
4162 (setq data (nreverse gnus-newsgroup-data))
4163 (setq threads gnus-newsgroup-threads))
4164 ;; We splice the new data into the data structure.
4165 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4166 ;;!!! then we want to insert at the beginning of the buffer.
4167 ;;!!! That happens to be true with Gnus now, but that may
4168 ;;!!! change in the future. Perhaps.
4169 (gnus-data-enter-list
4170 (if line nil current) data (- (point) old-pos))
4171 (setq gnus-newsgroup-threads
4172 (nconc threads gnus-newsgroup-threads))
4173 (gnus-data-compute-positions))))
4175 (defun gnus-number-to-header (number)
4176 "Return the header for article NUMBER."
4177 (let ((headers gnus-newsgroup-headers))
4179 (not (= number (mail-header-number (car headers)))))
4184 (defun gnus-parent-headers (in-headers &optional generation)
4185 "Return the headers of the GENERATIONeth parent of HEADERS."
4187 (setq generation 1))
4189 (headers in-headers)
4192 (not (zerop generation))
4193 (setq references (mail-header-references headers)))
4194 (setq headers (if (and references
4195 (setq parent (gnus-parent-id references)))
4196 (car (gnus-id-to-thread parent))
4199 (and (not (eq headers in-headers))
4202 (defun gnus-id-to-thread (id)
4203 "Return the (sub-)thread where ID appears."
4204 (gnus-gethash id gnus-newsgroup-dependencies))
4206 (defun gnus-id-to-article (id)
4207 "Return the article number of ID."
4208 (let ((thread (gnus-id-to-thread id)))
4211 (mail-header-number (car thread)))))
4213 (defun gnus-id-to-header (id)
4214 "Return the article headers of ID."
4215 (car (gnus-id-to-thread id)))
4217 (defun gnus-article-displayed-root-p (article)
4218 "Say whether ARTICLE is a root(ish) article."
4219 (let ((level (gnus-summary-thread-level article))
4220 (refs (mail-header-references (gnus-summary-article-header article)))
4226 ((null (gnus-parent-id refs)) t)
4228 (null (setq particle (gnus-id-to-article
4229 (gnus-parent-id refs))))
4230 (null (gnus-summary-thread-level particle)))))))
4232 (defun gnus-root-id (id)
4233 "Return the id of the root of the thread where ID appears."
4235 (while (and id (setq prev (car (gnus-id-to-thread id))))
4237 id (gnus-parent-id (mail-header-references prev))))
4240 (defun gnus-articles-in-thread (thread)
4241 "Return the list of articles in THREAD."
4242 (cons (mail-header-number (car thread))
4243 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4245 (defun gnus-remove-thread (id &optional dont-remove)
4246 "Remove the thread that has ID in it."
4247 (let (headers thread last-id)
4248 ;; First go up in this thread until we find the root.
4249 (setq last-id (gnus-root-id id)
4250 headers (message-flatten-list (gnus-id-to-thread last-id)))
4251 ;; We have now found the real root of this thread. It might have
4252 ;; been gathered into some loose thread, so we have to search
4253 ;; through the threads to find the thread we wanted.
4254 (let ((threads gnus-newsgroup-threads)
4257 (setq sub (car threads))
4258 (if (stringp (car sub))
4259 ;; This is a gathered thread, so we look at the roots
4260 ;; below it to find whether this article is in this
4263 (setq sub (cdr sub))
4265 (when (member (caar sub) headers)
4266 (setq thread (car threads)
4269 (setq sub (cdr sub))))
4270 ;; It's an ordinary thread, so we check it.
4271 (when (eq (car sub) (car headers))
4274 (setq threads (cdr threads)))
4275 ;; If this article is in no thread, then it's a root.
4278 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4279 (setq thread (gnus-id-to-thread last-id)))
4282 thread ; We return this thread.
4284 (if (stringp (car thread))
4286 ;; If we use dummy roots, then we have to remove the
4287 ;; dummy root as well.
4288 (when (eq gnus-summary-make-false-root 'dummy)
4289 ;; We go to the dummy root by going to
4290 ;; the first sub-"thread", and then one line up.
4291 (gnus-summary-goto-article
4292 (mail-header-number (caadr thread)))
4295 (gnus-data-compute-positions))
4296 (setq thread (cdr thread))
4298 (gnus-remove-thread-1 (car thread))
4299 (setq thread (cdr thread))))
4300 (gnus-remove-thread-1 thread))))))))
4302 (defun gnus-remove-thread-1 (thread)
4303 "Remove the thread THREAD recursively."
4304 (let ((number (mail-header-number (pop thread)))
4306 (setq thread (reverse thread))
4308 (gnus-remove-thread-1 (pop thread)))
4309 (when (setq d (gnus-data-find number))
4310 (goto-char (gnus-data-pos d))
4311 (gnus-summary-show-thread)
4314 (- (gnus-point-at-bol)
4316 (1+ (gnus-point-at-eol))
4317 (gnus-delete-line)))))))
4319 (defun gnus-sort-threads-1 (threads func)
4320 (sort (mapcar (lambda (thread)
4323 (gnus-sort-threads-1 (cdr thread) func))))
4326 (defun gnus-sort-threads (threads)
4328 (if (not gnus-thread-sort-functions)
4330 (gnus-message 8 "Sorting threads...")
4331 (let ((max-lisp-eval-depth 5000))
4332 (prog1 (gnus-sort-threads-1
4334 (gnus-make-sort-function gnus-thread-sort-functions))
4335 (gnus-message 8 "Sorting threads...done")))))
4337 (defun gnus-sort-articles (articles)
4339 (when gnus-article-sort-functions
4340 (gnus-message 7 "Sorting articles...")
4342 (setq gnus-newsgroup-headers
4343 (sort articles (gnus-make-sort-function
4344 gnus-article-sort-functions)))
4345 (gnus-message 7 "Sorting articles...done"))))
4347 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4348 (defmacro gnus-thread-header (thread)
4349 "Return header of first article in THREAD.
4350 Note that THREAD must never, ever be anything else than a variable -
4351 using some other form will lead to serious barfage."
4352 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4353 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4354 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4357 (defsubst gnus-article-sort-by-number (h1 h2)
4358 "Sort articles by article number."
4359 (< (mail-header-number h1)
4360 (mail-header-number h2)))
4362 (defun gnus-thread-sort-by-number (h1 h2)
4363 "Sort threads by root article number."
4364 (gnus-article-sort-by-number
4365 (gnus-thread-header h1) (gnus-thread-header h2)))
4367 (defsubst gnus-article-sort-by-random (h1 h2)
4368 "Sort articles by article number."
4371 (defun gnus-thread-sort-by-random (h1 h2)
4372 "Sort threads by root article number."
4373 (gnus-article-sort-by-random
4374 (gnus-thread-header h1) (gnus-thread-header h2)))
4376 (defsubst gnus-article-sort-by-lines (h1 h2)
4377 "Sort articles by article Lines header."
4378 (< (mail-header-lines h1)
4379 (mail-header-lines h2)))
4381 (defun gnus-thread-sort-by-lines (h1 h2)
4382 "Sort threads by root article Lines header."
4383 (gnus-article-sort-by-lines
4384 (gnus-thread-header h1) (gnus-thread-header h2)))
4386 (defsubst gnus-article-sort-by-chars (h1 h2)
4387 "Sort articles by octet length."
4388 (< (mail-header-chars h1)
4389 (mail-header-chars h2)))
4391 (defun gnus-thread-sort-by-chars (h1 h2)
4392 "Sort threads by root article octet length."
4393 (gnus-article-sort-by-chars
4394 (gnus-thread-header h1) (gnus-thread-header h2)))
4396 (defsubst gnus-article-sort-by-author (h1 h2)
4397 "Sort articles by root author."
4399 (let ((extract (funcall
4400 gnus-extract-address-components
4401 (mail-header-from h1))))
4402 (or (car extract) (cadr extract) ""))
4403 (let ((extract (funcall
4404 gnus-extract-address-components
4405 (mail-header-from h2))))
4406 (or (car extract) (cadr extract) ""))))
4408 (defun gnus-thread-sort-by-author (h1 h2)
4409 "Sort threads by root author."
4410 (gnus-article-sort-by-author
4411 (gnus-thread-header h1) (gnus-thread-header h2)))
4413 (defsubst gnus-article-sort-by-subject (h1 h2)
4414 "Sort articles by root subject."
4416 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4417 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4419 (defun gnus-thread-sort-by-subject (h1 h2)
4420 "Sort threads by root subject."
4421 (gnus-article-sort-by-subject
4422 (gnus-thread-header h1) (gnus-thread-header h2)))
4424 (defsubst gnus-article-sort-by-date (h1 h2)
4425 "Sort articles by root article date."
4427 (gnus-date-get-time (mail-header-date h1))
4428 (gnus-date-get-time (mail-header-date h2))))
4430 (defun gnus-thread-sort-by-date (h1 h2)
4431 "Sort threads by root article date."
4432 (gnus-article-sort-by-date
4433 (gnus-thread-header h1) (gnus-thread-header h2)))
4435 (defsubst gnus-article-sort-by-score (h1 h2)
4436 "Sort articles by root article score.
4437 Unscored articles will be counted as having a score of zero."
4438 (> (or (cdr (assq (mail-header-number h1)
4439 gnus-newsgroup-scored))
4440 gnus-summary-default-score 0)
4441 (or (cdr (assq (mail-header-number h2)
4442 gnus-newsgroup-scored))
4443 gnus-summary-default-score 0)))
4445 (defun gnus-thread-sort-by-score (h1 h2)
4446 "Sort threads by root article score."
4447 (gnus-article-sort-by-score
4448 (gnus-thread-header h1) (gnus-thread-header h2)))
4450 (defun gnus-thread-sort-by-total-score (h1 h2)
4451 "Sort threads by the sum of all scores in the thread.
4452 Unscored articles will be counted as having a score of zero."
4453 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4455 (defun gnus-thread-total-score (thread)
4456 ;; This function find the total score of THREAD.
4461 (if (stringp (car thread))
4462 (apply gnus-thread-score-function 0
4463 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4464 (gnus-thread-total-score-1 thread)))
4466 (gnus-thread-total-score-1 (list thread)))))
4468 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4469 "Sort threads such that the thread with the most recently arrived article comes first."
4470 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4472 (defun gnus-thread-highest-number (thread)
4473 "Return the highest article number in THREAD."
4474 (apply 'max (mapcar (lambda (header)
4475 (mail-header-number header))
4476 (message-flatten-list thread))))
4478 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4479 "Sort threads such that the thread with the most recently dated article comes first."
4480 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4482 (defun gnus-thread-latest-date (thread)
4483 "Return the highest article date in THREAD."
4484 (let ((previous-time 0))
4491 (mail-header-parse-date (mail-header-date header))
4492 (error previous-time)))))
4494 (message-flatten-list thread)
4496 (< (mail-header-number h1)
4497 (mail-header-number h2))))))))
4499 (defun gnus-thread-total-score-1 (root)
4500 ;; This function find the total score of the thread below ROOT.
4501 (setq root (car root))
4502 (apply gnus-thread-score-function
4504 (mapcar 'gnus-thread-total-score
4505 (cdr (gnus-id-to-thread (mail-header-id root))))
4506 (when (> (mail-header-number root) 0)
4507 (list (or (cdr (assq (mail-header-number root)
4508 gnus-newsgroup-scored))
4509 gnus-summary-default-score 0))))
4510 (list gnus-summary-default-score)
4513 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4514 (defvar gnus-tmp-prev-subject nil)
4515 (defvar gnus-tmp-false-parent nil)
4516 (defvar gnus-tmp-root-expunged nil)
4517 (defvar gnus-tmp-dummy-line nil)
4519 (eval-when-compile (defvar gnus-tmp-header))
4520 (defun gnus-extra-header (type &optional header)
4521 "Return the extra header of TYPE."
4522 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4525 (defvar gnus-tmp-thread-tree-header-string "")
4527 (defcustom gnus-sum-thread-tree-root "> "
4528 "With %B spec, used for the root of a thread.
4529 If nil, use subject instead."
4531 :group 'gnus-thread)
4532 (defcustom gnus-sum-thread-tree-single-indent ""
4533 "With %B spec, used for a thread with just one message.
4534 If nil, use subject instead."
4536 :group 'gnus-thread)
4537 (defcustom gnus-sum-thread-tree-vertical "| "
4538 "With %B spec, used for drawing a vertical line."
4540 :group 'gnus-thread)
4541 (defcustom gnus-sum-thread-tree-indent " "
4542 "With %B spec, used for indenting."
4544 :group 'gnus-thread)
4545 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4546 "With %B spec, used for a leaf with brothers."
4548 :group 'gnus-thread)
4549 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4550 "With %B spec, used for a leaf without brothers."
4552 :group 'gnus-thread)
4554 (defun gnus-summary-prepare-threads (threads)
4555 "Prepare summary buffer from THREADS and indentation LEVEL.
4556 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4557 or a straight list of headers."
4558 (gnus-message 7 "Generating summary...")
4560 (setq gnus-newsgroup-threads threads)
4563 (let ((gnus-tmp-level 0)
4564 (default-score (or gnus-summary-default-score 0))
4565 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4566 (building-line-count gnus-summary-display-while-building)
4567 (building-count (integerp gnus-summary-display-while-building))
4568 thread number subject stack state gnus-tmp-gathered beg-match
4569 new-roots gnus-tmp-new-adopts thread-end simp-subject
4570 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4571 gnus-tmp-replied gnus-tmp-subject-or-nil
4572 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4573 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4574 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4577 (setq gnus-tmp-prev-subject nil
4578 gnus-tmp-thread-tree-header-string "")
4580 (if (vectorp (car threads))
4581 ;; If this is a straight (sic) list of headers, then a
4582 ;; threaded summary display isn't required, so we just create
4583 ;; an unthreaded one.
4584 (gnus-summary-prepare-unthreaded threads)
4586 ;; Do the threaded display.
4588 (if gnus-summary-display-while-building
4589 (switch-to-buffer (buffer-name)))
4590 (while (or threads stack gnus-tmp-new-adopts new-roots)
4592 (if (and (= gnus-tmp-level 0)
4595 (not gnus-tmp-false-parent)
4596 (or gnus-tmp-new-adopts new-roots))
4597 (if gnus-tmp-new-adopts
4598 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4599 thread (list (car gnus-tmp-new-adopts))
4600 gnus-tmp-header (caar thread)
4601 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4603 (setq thread (list (car new-roots))
4604 gnus-tmp-header (caar thread)
4605 new-roots (cdr new-roots))))
4608 ;; If there are some threads, we do them before the
4609 ;; threads on the stack.
4610 (setq thread threads
4611 gnus-tmp-header (caar thread))
4612 ;; There were no current threads, so we pop something off
4614 (setq state (car stack)
4615 gnus-tmp-level (car state)
4616 tree-stack (cadr state)
4617 thread (caddr state)
4619 gnus-tmp-header (caar thread))))
4621 (setq gnus-tmp-false-parent nil)
4622 (setq gnus-tmp-root-expunged nil)
4623 (setq thread-end nil)
4625 (if (stringp gnus-tmp-header)
4626 ;; The header is a dummy root.
4628 ((eq gnus-summary-make-false-root 'adopt)
4629 ;; We let the first article adopt the rest.
4630 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4632 (setq gnus-tmp-gathered
4634 (lambda (h) (mail-header-number (car h)))
4637 (setq thread (cons (list (caar thread)
4640 (setq gnus-tmp-level -1
4641 gnus-tmp-false-parent t))
4642 ((eq gnus-summary-make-false-root 'empty)
4643 ;; We print adopted articles with empty subject fields.
4644 (setq gnus-tmp-gathered
4646 (lambda (h) (mail-header-number (car h)))
4649 (setq gnus-tmp-level -1))
4650 ((eq gnus-summary-make-false-root 'dummy)
4651 ;; We remember that we probably want to output a dummy
4653 (setq gnus-tmp-dummy-line gnus-tmp-header)
4654 (setq gnus-tmp-prev-subject gnus-tmp-header))
4656 ;; We do not make a root for the gathered
4657 ;; sub-threads at all.
4658 (setq gnus-tmp-level -1)))
4660 (setq number (mail-header-number gnus-tmp-header)
4661 subject (mail-header-subject gnus-tmp-header)
4662 simp-subject (gnus-simplify-subject-fully subject))
4665 ;; If the thread has changed subject, we might want to make
4666 ;; this subthread into a root.
4667 ((and (null gnus-thread-ignore-subject)
4668 (not (zerop gnus-tmp-level))
4669 gnus-tmp-prev-subject
4670 (not (string= gnus-tmp-prev-subject simp-subject)))
4671 (setq new-roots (nconc new-roots (list (car thread)))
4673 gnus-tmp-header nil))
4674 ;; If the article lies outside the current limit,
4675 ;; then we do not display it.
4676 ((not (memq number gnus-newsgroup-limit))
4677 (setq gnus-tmp-gathered
4679 (lambda (h) (mail-header-number (car h)))
4682 (setq gnus-tmp-new-adopts (if (cdar thread)
4683 (append gnus-tmp-new-adopts
4685 gnus-tmp-new-adopts)
4687 gnus-tmp-header nil)
4688 (when (zerop gnus-tmp-level)
4689 (setq gnus-tmp-root-expunged t)))
4690 ;; Perhaps this article is to be marked as read?
4691 ((and gnus-summary-mark-below
4692 (< (or (cdr (assq number gnus-newsgroup-scored))
4694 gnus-summary-mark-below)
4695 ;; Don't touch sparse articles.
4696 (not (gnus-summary-article-sparse-p number))
4697 (not (gnus-summary-article-ancient-p number)))
4698 (setq gnus-newsgroup-unreads
4699 (delq number gnus-newsgroup-unreads))
4700 (if gnus-newsgroup-auto-expire
4701 (setq gnus-newsgroup-expirable
4702 (gnus-add-to-sorted-list
4703 gnus-newsgroup-expirable number))
4704 (push (cons number gnus-low-score-mark)
4705 gnus-newsgroup-reads))))
4707 (when gnus-tmp-header
4708 ;; We may have an old dummy line to output before this
4710 (when (and gnus-tmp-dummy-line
4713 (mail-header-subject gnus-tmp-header)))
4714 (gnus-summary-insert-dummy-line
4715 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4716 (setq gnus-tmp-dummy-line nil))
4718 ;; Compute the mark.
4719 (setq gnus-tmp-unread (gnus-article-mark number))
4721 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4722 gnus-tmp-header gnus-tmp-level)
4723 gnus-newsgroup-data)
4725 ;; Actually insert the line.
4727 gnus-tmp-subject-or-nil
4729 ((and gnus-thread-ignore-subject
4730 gnus-tmp-prev-subject
4731 (not (string= gnus-tmp-prev-subject simp-subject)))
4733 ((zerop gnus-tmp-level)
4734 (if (and (eq gnus-summary-make-false-root 'empty)
4735 (memq number gnus-tmp-gathered)
4736 gnus-tmp-prev-subject
4737 (string= gnus-tmp-prev-subject simp-subject))
4738 gnus-summary-same-subject
4740 (t gnus-summary-same-subject)))
4741 (if (and (eq gnus-summary-make-false-root 'adopt)
4742 (= gnus-tmp-level 1)
4743 (memq number gnus-tmp-gathered))
4744 (setq gnus-tmp-opening-bracket ?\<
4745 gnus-tmp-closing-bracket ?\>)
4746 (setq gnus-tmp-opening-bracket ?\[
4747 gnus-tmp-closing-bracket ?\]))
4749 gnus-tmp-indentation
4750 (aref gnus-thread-indent-array gnus-tmp-level)
4751 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4752 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4753 gnus-summary-default-score 0)
4755 (if (or (null gnus-summary-default-score)
4756 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4757 gnus-summary-zcore-fuzz))
4759 (if (< gnus-tmp-score gnus-summary-default-score)
4760 gnus-score-below-mark gnus-score-over-mark))
4762 (cond ((memq number gnus-newsgroup-processable)
4764 ((memq number gnus-newsgroup-cached)
4766 ((memq number gnus-newsgroup-replied)
4768 ((memq number gnus-newsgroup-forwarded)
4769 gnus-forwarded-mark)
4770 ((memq number gnus-newsgroup-saved)
4772 ((memq number gnus-newsgroup-recent)
4774 ((memq number gnus-newsgroup-unseen)
4778 (cond ((memq number gnus-newsgroup-undownloaded)
4779 gnus-undownloaded-mark)
4780 (gnus-newsgroup-agentized
4781 gnus-downloaded-mark)
4784 gnus-tmp-from (mail-header-from gnus-tmp-header)
4787 ((string-match "<[^>]+> *$" gnus-tmp-from)
4788 (setq beg-match (match-beginning 0))
4789 (or (and (string-match "^\".+\"" gnus-tmp-from)
4790 (substring gnus-tmp-from 1 (1- (match-end 0))))
4791 (substring gnus-tmp-from 0 beg-match)))
4792 ((string-match "(.+)" gnus-tmp-from)
4793 (substring gnus-tmp-from
4794 (1+ (match-beginning 0)) (1- (match-end 0))))
4796 gnus-tmp-thread-tree-header-string
4798 ((not gnus-show-threads) "")
4799 ((zerop gnus-tmp-level)
4801 (or gnus-sum-thread-tree-root subject)
4802 (or gnus-sum-thread-tree-single-indent subject)))
4804 (concat (apply 'concat
4805 (mapcar (lambda (item)
4807 gnus-sum-thread-tree-vertical
4808 gnus-sum-thread-tree-indent))
4809 (cdr (reverse tree-stack))))
4811 gnus-sum-thread-tree-leaf-with-other
4812 gnus-sum-thread-tree-single-leaf)))))
4813 (when (string= gnus-tmp-name "")
4814 (setq gnus-tmp-name gnus-tmp-from))
4815 (unless (numberp gnus-tmp-lines)
4816 (setq gnus-tmp-lines -1))
4817 (if (= gnus-tmp-lines -1)
4818 (setq gnus-tmp-lines "?")
4819 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4820 (gnus-put-text-property
4822 (progn (eval gnus-summary-line-format-spec) (point))
4823 'gnus-number number)
4826 (gnus-run-hooks 'gnus-summary-update-hook)
4829 (setq gnus-tmp-prev-subject simp-subject)))
4831 (when (nth 1 thread)
4832 (push (list (max 0 gnus-tmp-level)
4833 (copy-list tree-stack)
4836 (push (if (nth 1 thread) 1 0) tree-stack)
4837 (incf gnus-tmp-level)
4838 (setq threads (if thread-end nil (cdar thread)))
4839 (if gnus-summary-display-while-building
4842 ;; use a set frequency
4843 (setq building-line-count (1- building-line-count))
4844 (when (= building-line-count 0)
4846 (setq building-line-count
4847 gnus-summary-display-while-building)))
4851 (setq gnus-tmp-level 0)))))
4852 (gnus-message 7 "Generating summary...done"))
4854 (defun gnus-summary-prepare-unthreaded (headers)
4855 "Generate an unthreaded summary buffer based on HEADERS."
4856 (let (header number mark)
4861 ;; We may have to root out some bad articles...
4862 (when (memq (setq number (mail-header-number
4863 (setq header (pop headers))))
4864 gnus-newsgroup-limit)
4865 ;; Mark article as read when it has a low score.
4866 (when (and gnus-summary-mark-below
4867 (< (or (cdr (assq number gnus-newsgroup-scored))
4868 gnus-summary-default-score 0)
4869 gnus-summary-mark-below)
4870 (not (gnus-summary-article-ancient-p number)))
4871 (setq gnus-newsgroup-unreads
4872 (delq number gnus-newsgroup-unreads))
4873 (if gnus-newsgroup-auto-expire
4874 (push number gnus-newsgroup-expirable)
4875 (push (cons number gnus-low-score-mark)
4876 gnus-newsgroup-reads)))
4878 (setq mark (gnus-article-mark number))
4879 (push (gnus-data-make number mark (1+ (point)) header 0)
4880 gnus-newsgroup-data)
4881 (gnus-summary-insert-line
4883 (memq number gnus-newsgroup-undownloaded)
4884 mark (memq number gnus-newsgroup-replied)
4885 (memq number gnus-newsgroup-expirable)
4886 (mail-header-subject header) nil
4887 (cdr (assq number gnus-newsgroup-scored))
4888 (memq number gnus-newsgroup-processable))))))
4890 (defun gnus-summary-remove-list-identifiers ()
4891 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4892 (let ((regexp (if (consp gnus-list-identifiers)
4893 (mapconcat 'identity gnus-list-identifiers " *\\|")
4894 gnus-list-identifiers))
4897 (dolist (header gnus-newsgroup-headers)
4898 (setq subject (mail-header-subject header)
4900 (while (string-match
4901 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4904 (concat (substring subject 0 (match-beginning 2))
4905 (substring subject (match-end 0)))
4909 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4911 (concat (substring subject 0 (match-beginning 1))
4912 (substring subject (match-end 1)))))
4914 (mail-header-set-subject header subject))))))
4916 (defun gnus-fetch-headers (articles)
4917 "Fetch headers of ARTICLES."
4918 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4919 (gnus-message 5 "Fetching headers for %s..." name)
4922 (setq gnus-headers-retrieved-by
4923 (gnus-retrieve-headers
4924 articles gnus-newsgroup-name
4925 ;; We might want to fetch old headers, but
4926 ;; not if there is only 1 article.
4928 (not (eq gnus-fetch-old-headers 'some))
4929 (not (numberp gnus-fetch-old-headers)))
4930 (> (length articles) 1))
4931 gnus-fetch-old-headers))))
4932 (gnus-get-newsgroup-headers-xover
4933 articles nil nil gnus-newsgroup-name t)
4934 (gnus-get-newsgroup-headers))
4935 (gnus-message 5 "Fetching headers for %s...done" name))))
4937 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4938 "Select newsgroup GROUP.
4939 If READ-ALL is non-nil, all articles in the group are selected.
4940 If SELECT-ARTICLES, only select those articles from GROUP."
4941 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4942 ;;!!! Dirty hack; should be removed.
4943 (gnus-summary-ignore-duplicates
4944 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4946 gnus-summary-ignore-duplicates))
4947 (info (nth 2 entry))
4948 articles fetched-articles cached)
4950 (unless (gnus-check-server
4951 (set (make-local-variable 'gnus-current-select-method)
4952 (gnus-find-method-for-group group)))
4953 (error "Couldn't open server"))
4955 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4956 (gnus-activate-group group) ; Or we can activate it...
4957 (progn ; Or we bug out.
4958 (when (equal major-mode 'gnus-summary-mode)
4959 (gnus-kill-buffer (current-buffer)))
4960 (error "Couldn't activate group %s: %s"
4961 group (gnus-status-message group))))
4963 (unless (gnus-request-group group t)
4964 (when (equal major-mode 'gnus-summary-mode)
4965 (gnus-kill-buffer (current-buffer)))
4966 (error "Couldn't request group %s: %s"
4967 group (gnus-status-message group)))
4969 (setq gnus-newsgroup-name group
4970 gnus-newsgroup-unselected nil
4971 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4973 (let ((display (gnus-group-find-parameter group 'display)))
4974 (setq gnus-newsgroup-display
4976 ((not (zerop (or (car-safe read-all) 0)))
4977 ;; The user entered the group with C-u SPC/RET, let's show
4983 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4985 ;; The following is probably the "correct" solution, but
4986 ;; it makes Gnus fetch all headers and then limit the
4987 ;; articles (which is slow), so instead we hack the
4988 ;; select-articles parameter instead. -- Simon Josefsson
4991 ;; (gnus-byte-compile
4992 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4994 (setq select-articles
4995 (gnus-uncompress-range
4996 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5000 (cdr (gnus-active group)))))
5005 (gnus-summary-setup-default-charset)
5007 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5008 (when (gnus-virtual-group-p group)
5009 (setq cached gnus-newsgroup-cached))
5011 (setq gnus-newsgroup-unreads
5012 (gnus-sorted-ndifference
5013 (gnus-sorted-ndifference gnus-newsgroup-unreads
5014 gnus-newsgroup-marked)
5015 gnus-newsgroup-dormant))
5017 (setq gnus-newsgroup-processable nil)
5019 (gnus-update-read-articles group gnus-newsgroup-unreads)
5021 ;; Adjust and set lists of article marks.
5023 (gnus-adjust-marked-articles info))
5024 (if (setq articles select-articles)
5025 (setq gnus-newsgroup-unselected
5026 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5027 (setq articles (gnus-articles-to-read group read-all)))
5031 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5033 ((eq articles 0) nil)
5035 ;; Init the dependencies hash table.
5036 (setq gnus-newsgroup-dependencies
5037 (gnus-make-hashtable (length articles)))
5038 (gnus-set-global-variables)
5039 ;; Retrieve the headers and read them in.
5041 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5043 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5045 (setq gnus-newsgroup-cached cached))
5047 ;; Suppress duplicates?
5048 (when gnus-suppress-duplicates
5049 (gnus-dup-suppress-articles))
5051 ;; Set the initial limit.
5052 (setq gnus-newsgroup-limit (copy-sequence articles))
5053 ;; Remove canceled articles from the list of unread articles.
5054 (setq fetched-articles
5055 (mapcar (lambda (headers) (mail-header-number headers))
5056 gnus-newsgroup-headers))
5057 (setq gnus-newsgroup-articles fetched-articles)
5058 (setq gnus-newsgroup-unreads
5059 (gnus-sorted-nintersection
5060 gnus-newsgroup-unreads fetched-articles))
5061 (gnus-compute-unseen-list)
5063 ;; Removed marked articles that do not exist.
5064 (gnus-update-missing-marks
5065 (gnus-sorted-difference articles fetched-articles))
5066 ;; We might want to build some more threads first.
5067 (when (and gnus-fetch-old-headers
5068 (eq gnus-headers-retrieved-by 'nov))
5069 (if (eq gnus-fetch-old-headers 'invisible)
5070 (gnus-build-all-threads)
5071 (gnus-build-old-threads)))
5072 ;; Let the Gnus agent mark articles as read.
5074 (gnus-agent-get-undownloaded-list))
5075 ;; Remove list identifiers from subject
5076 (when gnus-list-identifiers
5077 (gnus-summary-remove-list-identifiers))
5078 ;; Check whether auto-expire is to be done in this group.
5079 (setq gnus-newsgroup-auto-expire
5080 (gnus-group-auto-expirable-p group))
5081 ;; Set up the article buffer now, if necessary.
5082 (unless gnus-single-article-buffer
5083 (gnus-article-setup-buffer))
5084 ;; First and last article in this newsgroup.
5085 (when gnus-newsgroup-headers
5086 (setq gnus-newsgroup-begin
5087 (mail-header-number (car gnus-newsgroup-headers))
5090 (gnus-last-element gnus-newsgroup-headers))))
5091 ;; GROUP is successfully selected.
5092 (or gnus-newsgroup-headers t)))))
5094 (defun gnus-compute-unseen-list ()
5095 ;; The `seen' marks are treated specially.
5096 (if (not gnus-newsgroup-seen)
5097 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5098 (setq gnus-newsgroup-unseen
5099 (gnus-inverse-list-range-intersection
5100 gnus-newsgroup-articles gnus-newsgroup-seen))))
5102 (defun gnus-summary-display-make-predicate (display)
5103 (require 'gnus-agent)
5104 (when (= (length display) 1)
5105 (setq display (car display)))
5106 (unless gnus-summary-display-cache
5107 (dolist (elem (append '((unread . unread)
5110 gnus-article-mark-lists))
5111 (push (cons (cdr elem)
5113 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5114 gnus-summary-display-cache)))
5115 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5116 (gnus-category-predicate-cache gnus-summary-display-cache))
5117 (gnus-get-predicate display)))
5119 ;; Uses the dynamically bound `number' variable.
5122 (defun gnus-article-marked-p (type &optional article)
5123 (let ((article (or article number)))
5126 (memq article gnus-newsgroup-marked))
5128 (memq article gnus-newsgroup-spam-marked))
5130 (memq article gnus-newsgroup-unsendable))
5131 ((eq type 'undownload)
5132 (memq article gnus-newsgroup-undownloaded))
5133 ((eq type 'download)
5134 (memq article gnus-newsgroup-downloadable))
5136 (memq article gnus-newsgroup-unreads))
5138 (memq article gnus-newsgroup-reads))
5140 (memq article gnus-newsgroup-dormant) )
5142 (memq article gnus-newsgroup-expirable))
5144 (memq article gnus-newsgroup-replied))
5146 (memq article gnus-newsgroup-killed))
5147 ((eq type 'bookmark)
5148 (assq article gnus-newsgroup-bookmarks))
5150 (assq article gnus-newsgroup-scored))
5152 (memq article gnus-newsgroup-saved))
5154 (memq article gnus-newsgroup-cached))
5156 (memq article gnus-newsgroup-forwarded))
5158 (not (memq article gnus-newsgroup-unseen)))
5160 (memq article gnus-newsgroup-recent))
5163 (defun gnus-articles-to-read (group &optional read-all)
5164 "Find out what articles the user wants to read."
5165 (let* ((display (gnus-group-find-parameter group 'display))
5167 ;; Select all articles if `read-all' is non-nil, or if there
5168 ;; are no unread articles.
5170 (and (zerop (length gnus-newsgroup-marked))
5171 (zerop (length gnus-newsgroup-unreads)))
5172 ;; Fetch all if the predicate is non-nil.
5173 gnus-newsgroup-display)
5174 ;; We want to select the headers for all the articles in
5175 ;; the group, so we select either all the active
5176 ;; articles in the group, or (if that's nil), the
5177 ;; articles in the cache.
5179 (gnus-uncompress-range (gnus-active group))
5180 (gnus-cache-articles-in-group group))
5181 ;; Select only the "normal" subset of articles.
5183 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5184 gnus-newsgroup-unreads)))
5185 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5186 (scored (length scored-list))
5187 (number (length articles))
5188 (marked (+ (length gnus-newsgroup-marked)
5189 (length gnus-newsgroup-dormant)))
5194 ((numberp gnus-newsgroup-display)
5195 gnus-newsgroup-display)
5199 ((and (or (<= scored marked) (= scored number))
5200 (numberp gnus-large-newsgroup)
5201 (> number gnus-large-newsgroup))
5202 (let* ((cursor-in-echo-area nil)
5203 (initial (gnus-parameter-large-newsgroup-initial
5204 gnus-newsgroup-name))
5208 "How many articles from %s (%s %d): "
5210 (gnus-group-decoded-name gnus-newsgroup-name)
5212 (if initial "max" "default")
5215 (cons (number-to-string initial)
5217 (if (string-match "^[ \t]*$" input) number input)))
5218 ((and (> scored marked) (< scored number)
5219 (> (- scored number) 20))
5222 (format "%s %s (%d scored, %d total): "
5223 "How many articles from"
5224 (gnus-group-decoded-name group)
5226 (if (string-match "^[ \t]*$" input)
5230 (message "Quit getting the articles to read")
5232 (setq select (if (stringp select) (string-to-number select) select))
5233 (if (or (null select) (zerop select))
5235 (if (and (not (zerop scored)) (<= (abs select) scored))
5237 (setq articles (sort scored-list '<))
5238 (setq number (length articles)))
5239 (setq articles (copy-sequence articles)))
5241 (when (< (abs select) number)
5243 ;; Select the N oldest articles.
5244 (setcdr (nthcdr (1- (abs select)) articles) nil)
5245 ;; Select the N most recent articles.
5246 (setq articles (nthcdr (- number select) articles))))
5247 (setq gnus-newsgroup-unselected
5248 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5249 (when gnus-alter-articles-to-read-function
5252 (funcall gnus-alter-articles-to-read-function
5253 gnus-newsgroup-name articles)
5257 (defun gnus-killed-articles (killed articles)
5260 (when (inline (gnus-member-of-range (car articles) killed))
5261 (push (car articles) out))
5262 (setq articles (cdr articles)))
5265 (defun gnus-uncompress-marks (marks)
5266 "Uncompress the mark ranges in MARKS."
5267 (let ((uncompressed '(score bookmark))
5270 (if (memq (caar marks) uncompressed)
5271 (push (car marks) out)
5272 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5273 (setq marks (cdr marks)))
5276 (defun gnus-article-mark-to-type (mark)
5277 "Return the type of MARK."
5278 (or (cadr (assq mark gnus-article-special-mark-lists))
5281 (defun gnus-article-unpropagatable-p (mark)
5282 "Return whether MARK should be propagated to backend."
5283 (memq mark gnus-article-unpropagated-mark-lists))
5285 (defun gnus-adjust-marked-articles (info)
5286 "Set all article lists and remove all marks that are no longer valid."
5287 (let* ((marked-lists (gnus-info-marks info))
5288 (active (gnus-active (gnus-info-group info)))
5291 (types gnus-article-mark-lists)
5292 marks var articles article mark mark-type)
5294 (dolist (marks marked-lists)
5295 (setq mark (car marks)
5296 mark-type (gnus-article-mark-to-type mark)
5297 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5299 ;; We set the variable according to the type of the marks list,
5300 ;; and then adjust the marks to a subset of the active articles.
5302 ;; Adjust "simple" lists.
5303 ((eq mark-type 'list)
5304 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5305 (when (memq mark '(tick dormant expire reply save))
5307 (when (or (< (setq article (pop articles)) min) (> article max))
5308 (set var (delq article (symbol-value var)))))))
5310 ((eq mark-type 'tuple)
5311 (set var (setq articles (cdr marks)))
5312 (when (not (listp (cdr (symbol-value var))))
5313 (set var (list (symbol-value var))))
5314 (when (not (listp (cdr articles)))
5315 (setq articles (list articles)))
5317 (when (or (not (consp (setq article (pop articles))))
5318 (< (car article) min)
5319 (> (car article) max))
5320 (set var (delq article (symbol-value var))))))
5321 ;; Adjust ranges (sloppily).
5322 ((eq mark-type 'range)
5325 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5326 ;; It should be (seen (NUM1 . NUM2)).
5327 (when (numberp (cddr marks))
5328 (setcdr marks (list (cdr marks))))
5329 (setq articles (cdr marks))
5330 (while (and articles
5331 (or (and (consp (car articles))
5332 (> min (cdar articles)))
5333 (and (numberp (car articles))
5334 (> min (car articles)))))
5336 (set var articles))))))))
5338 (defun gnus-update-missing-marks (missing)
5339 "Go through the list of MISSING articles and remove them from the mark lists."
5342 ;; Go through all types.
5343 (dolist (elem gnus-article-mark-lists)
5344 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5345 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5346 (when (symbol-value var)
5347 ;; This list has articles. So we delete all missing
5348 ;; articles from it.
5351 (set var (delq (pop m) (symbol-value var))))))))))
5353 (defun gnus-update-marks ()
5354 "Enter the various lists of marked articles into the newsgroup info list."
5355 (let ((types gnus-article-mark-lists)
5356 (info (gnus-get-info gnus-newsgroup-name))
5357 type list newmarked symbol delta-marks)
5359 ;; Add all marks lists to the list of marks lists.
5360 (while (setq type (pop types))
5361 (setq list (symbol-value
5363 (intern (format "gnus-newsgroup-%s" (car type))))))
5366 ;; Get rid of the entries of the articles that have the
5368 (when (and (eq (cdr type) 'score)
5372 (prev (cons nil list))
5375 (if (or (not (consp (car arts)))
5376 (= (cdar arts) gnus-summary-default-score))
5377 (setcdr prev (cdr arts))
5379 (setq arts (cdr arts)))
5380 (setq list (cdr all)))))
5382 (when (eq (cdr type) 'seen)
5383 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5385 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5386 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5388 (when (and (gnus-check-backend-function
5389 'request-set-mark gnus-newsgroup-name)
5390 (not (gnus-article-unpropagatable-p (cdr type))))
5391 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5392 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5393 (add (gnus-remove-from-range
5394 (gnus-copy-sequence list) old)))
5396 (push (list add 'add (list (cdr type))) delta-marks))
5398 (push (list del 'del (list (cdr type))) delta-marks))))
5401 (push (cons (cdr type) list) newmarked)))
5404 (unless (gnus-check-group gnus-newsgroup-name)
5405 (error "Can't open server for %s" gnus-newsgroup-name))
5406 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5408 ;; Enter these new marks into the info of the group.
5410 (setcar (nthcdr 3 info) newmarked)
5411 ;; Add the marks lists to the end of the info.
5413 (setcdr (nthcdr 2 info) (list newmarked))))
5415 ;; Cut off the end of the info if there's nothing else there.
5419 (when (nthcdr (decf i) info)
5420 (setcdr (nthcdr i info) nil)))))))
5422 (defun gnus-set-mode-line (where)
5423 "Set the mode line of the article or summary buffers.
5424 If WHERE is `summary', the summary mode line format will be used."
5425 ;; Is this mode line one we keep updated?
5426 (when (and (memq where gnus-updated-mode-lines)
5428 (intern (format "gnus-%s-mode-line-format-spec" where))))
5431 ;; We evaluate this in the summary buffer since these
5432 ;; variables are buffer-local to that buffer.
5433 (set-buffer gnus-summary-buffer)
5434 ;; We bind all these variables that are used in the `eval' form
5436 (let* ((mformat (symbol-value
5438 (format "gnus-%s-mode-line-format-spec" where))))
5439 (gnus-tmp-group-name (gnus-group-decoded-name
5440 gnus-newsgroup-name))
5441 (gnus-tmp-article-number (or gnus-current-article 0))
5442 (gnus-tmp-unread gnus-newsgroup-unreads)
5443 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5444 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5445 (gnus-tmp-unread-and-unselected
5446 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5447 (zerop gnus-tmp-unselected))
5449 ((zerop gnus-tmp-unselected)
5450 (format "{%d more}" gnus-tmp-unread-and-unticked))
5451 (t (format "{%d(+%d) more}"
5452 gnus-tmp-unread-and-unticked
5453 gnus-tmp-unselected))))
5455 (if (and gnus-current-headers
5456 (vectorp gnus-current-headers))
5457 (gnus-mode-string-quote
5458 (mail-header-subject gnus-current-headers))
5460 bufname-length max-len
5461 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5462 (setq mode-string (eval mformat))
5463 (setq bufname-length (if (string-match "%b" mode-string)
5466 (if (eq where 'summary)
5468 (get-buffer gnus-article-buffer))))
5471 (setq max-len (max 4 (if gnus-mode-non-string-length
5473 gnus-mode-non-string-length
5475 (length mode-string))))
5476 ;; We might have to chop a bit of the string off...
5477 (when (> (length mode-string) max-len)
5479 (concat (truncate-string-to-width mode-string (- max-len 3))
5481 ;; Pad the mode string a bit.
5482 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5483 ;; Update the mode line.
5484 (setq mode-line-buffer-identification
5485 (gnus-mode-line-buffer-identification (list mode-string)))
5486 (set-buffer-modified-p t))))
5488 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5489 "Go through the HEADERS list and add all Xrefs to a hash table.
5490 The resulting hash table is returned, or nil if no Xrefs were found."
5491 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5492 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5493 (xref-hashtb (gnus-make-hashtable))
5494 start group entry number xrefs header)
5496 (setq header (pop headers))
5497 (when (and (setq xrefs (mail-header-xref header))
5498 (not (memq (setq number (mail-header-number header))
5501 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5502 (setq start (match-end 0))
5503 (setq group (if prefix
5504 (concat prefix (substring xrefs (match-beginning 1)
5506 (substring xrefs (match-beginning 1) (match-end 1))))
5508 (string-to-int (substring xrefs (match-beginning 2)
5510 (if (setq entry (gnus-gethash group xref-hashtb))
5511 (setcdr entry (cons number (cdr entry)))
5512 (gnus-sethash group (cons number nil) xref-hashtb)))))
5513 (and start xref-hashtb)))
5515 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5516 "Look through all the headers and mark the Xrefs as read."
5517 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5518 name entry info xref-hashtb idlist method nth4)
5520 (set-buffer gnus-group-buffer)
5521 (when (setq xref-hashtb
5522 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5525 (unless (string= from-newsgroup (setq name (symbol-name group)))
5526 (setq idlist (symbol-value group))
5527 ;; Dead groups are not updated.
5529 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5531 (when (stringp (setq nth4 (gnus-info-method info)))
5532 (setq nth4 (gnus-server-to-method nth4))))
5533 ;; Only do the xrefs if the group has the same
5534 ;; select method as the group we have just read.
5535 (or (gnus-methods-equal-p
5536 nth4 (gnus-find-method-for-group from-newsgroup))
5538 (equal nth4 (setq method (gnus-find-method-for-group
5540 (and (equal (car nth4) (car method))
5541 (equal (nth 1 nth4) (nth 1 method))))
5542 gnus-use-cross-reference
5543 (or (not (eq gnus-use-cross-reference t))
5545 ;; Only do cross-references on subscribed
5546 ;; groups, if that is what is wanted.
5547 (<= (gnus-info-level info) gnus-level-subscribed))
5548 (gnus-group-make-articles-read name idlist))))
5551 (defun gnus-compute-read-articles (group articles)
5552 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5553 (info (nth 2 entry))
5554 (active (gnus-active group))
5557 ;; First peel off all invalid article numbers.
5559 (let ((ids articles)
5561 (while (setq id (pop ids))
5562 (when (and first (> id (cdr active)))
5563 ;; We'll end up in this situation in one particular
5564 ;; obscure situation. If you re-scan a group and get
5565 ;; a new article that is cross-posted to a different
5566 ;; group that has not been re-scanned, you might get
5567 ;; crossposted article that has a higher number than
5568 ;; Gnus believes possible. So we re-activate this
5569 ;; group as well. This might mean doing the
5570 ;; crossposting thingy will *increase* the number
5571 ;; of articles in some groups. Tsk, tsk.
5572 (setq active (or (gnus-activate-group group) active)))
5573 (when (or (> id (cdr active))
5574 (< id (car active)))
5575 (setq articles (delq id articles))))))
5576 ;; If the read list is nil, we init it.
5578 (null (gnus-info-read info))
5580 (setq ninfo (cons 1 (1- (car active))))
5581 (setq ninfo (gnus-info-read info)))
5582 ;; Then we add the read articles to the range.
5584 ninfo (setq articles (sort articles '<))))))
5586 (defun gnus-group-make-articles-read (group articles)
5587 "Update the info of GROUP to say that ARTICLES are read."
5589 (entry (gnus-gethash group gnus-newsrc-hashtb))
5590 (info (nth 2 entry))
5591 (active (gnus-active group))
5594 (setq range (gnus-compute-read-articles group articles))
5596 (set-buffer gnus-group-buffer)
5599 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5600 (gnus-info-set-read ',info ',(gnus-info-read info))
5601 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5602 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5603 (gnus-group-update-group ,group t))))
5604 ;; Add the read articles to the range.
5605 (gnus-info-set-read info range)
5606 (gnus-request-set-mark group (list (list range 'add '(read))))
5607 ;; Then we have to re-compute how many unread
5608 ;; articles there are in this group.
5612 (setq num (- (1+ (cdr active)) (car active))))
5613 ((not (listp (cdr range)))
5614 (setq num (- (cdr active) (- (1+ (cdr range))
5618 (if (numberp (car range))
5620 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5621 (setq range (cdr range)))
5622 (setq num (- (cdr active) num))))
5623 ;; Update the number of unread articles.
5625 ;; Update the group buffer.
5626 (unless (gnus-ephemeral-group-p group)
5627 (gnus-group-update-group group t))))))
5629 (defvar gnus-newsgroup-none-id 0)
5631 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5632 (let ((cur nntp-server-buffer)
5635 (save-excursion (set-buffer gnus-summary-buffer)
5636 gnus-newsgroup-dependencies)))
5638 (mail-parse-charset gnus-newsgroup-charset)
5639 (mail-parse-ignored-charsets
5640 (save-excursion (condition-case nil
5641 (set-buffer gnus-summary-buffer)
5643 gnus-newsgroup-ignored-charsets)))
5645 (set-buffer nntp-server-buffer)
5646 ;; Translate all TAB characters into SPACE characters.
5647 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5648 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5649 (gnus-run-hooks 'gnus-parse-headers-hook)
5650 (let ((case-fold-search t)
5651 in-reply-to header p lines chars)
5652 (goto-char (point-min))
5653 ;; Search to the beginning of the next header. Error messages
5654 ;; do not begin with 2 or 3.
5655 (while (re-search-forward "^[23][0-9]+ " nil t)
5658 ;; This implementation of this function, with nine
5659 ;; search-forwards instead of the one re-search-forward and
5660 ;; a case (which basically was the old function) is actually
5661 ;; about twice as fast, even though it looks messier. You
5662 ;; can't have everything, I guess. Speed and elegance
5663 ;; doesn't always go hand in hand.
5672 (narrow-to-region (point)
5673 (or (and (search-forward "\n.\n" nil t)
5679 (if (search-forward "\nsubject:" nil t)
5680 (funcall gnus-decode-encoded-word-function
5681 (nnheader-header-value))
5686 (if (search-forward "\nfrom:" nil t)
5687 (funcall gnus-decode-encoded-word-function
5688 (nnheader-header-value))
5693 (if (search-forward "\ndate:" nil t)
5694 (nnheader-header-value) ""))
5698 (setq id (if (re-search-forward
5699 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5700 ;; We do it this way to make sure the Message-ID
5701 ;; is (somewhat) syntactically valid.
5702 (buffer-substring (match-beginning 1)
5704 ;; If there was no message-id, we just fake one
5705 ;; to make subsequent routines simpler.
5706 (nnheader-generate-fake-message-id))))
5710 (if (search-forward "\nreferences:" nil t)
5714 (nnheader-header-value)
5719 (search-backward ">" end t)
5722 (search-backward "<" end t)
5724 ;; Get the references from the in-reply-to header if there
5725 ;; were no references and the in-reply-to header looks
5727 (if (and (search-forward "\nin-reply-to:" nil t)
5728 (setq in-reply-to (nnheader-header-value))
5729 (string-match "<[^>]+>" in-reply-to))
5731 (setq ref (substring in-reply-to (match-beginning 0)
5733 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5734 (setq ref2 (substring in-reply-to (match-beginning 0)
5736 (when (> (length ref2) (length ref))
5743 (if (search-forward "\nchars: " nil t)
5744 (if (numberp (setq chars (ignore-errors (read cur))))
5750 (if (search-forward "\nlines: " nil t)
5751 (if (numberp (setq lines (ignore-errors (read cur))))
5757 (and (search-forward "\nxref:" nil t)
5758 (nnheader-header-value)))
5760 (when gnus-extra-headers
5761 (let ((extra gnus-extra-headers)
5765 (when (search-forward
5766 (concat "\n" (symbol-name (car extra)) ":") nil t)
5767 (push (cons (car extra) (nnheader-header-value))
5771 (when (equal id ref)
5774 (when gnus-alter-header-function
5775 (funcall gnus-alter-header-function header)
5776 (setq id (mail-header-id header)
5777 ref (gnus-parent-id (mail-header-references header))))
5780 (gnus-dependencies-add-header
5781 header dependencies force-new))
5782 (push header headers))
5783 (goto-char (point-max))
5785 (nreverse headers)))))
5787 ;; Goes through the xover lines and returns a list of vectors
5788 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5789 force-new dependencies
5790 group also-fetch-heads)
5791 "Parse the news overview data in the server buffer.
5792 Return a list of headers that match SEQUENCE (see
5793 `nntp-retrieve-headers')."
5794 ;; Get the Xref when the users reads the articles since most/some
5795 ;; NNTP servers do not include Xrefs when using XOVER.
5796 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5797 (let ((mail-parse-charset gnus-newsgroup-charset)
5798 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5799 (cur nntp-server-buffer)
5800 (dependencies (or dependencies gnus-newsgroup-dependencies))
5802 ((eq gnus-read-all-available-headers t)
5804 ((stringp gnus-read-all-available-headers)
5805 (string-match gnus-read-all-available-headers group))
5808 number headers header)
5810 (set-buffer nntp-server-buffer)
5811 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5812 ;; Allow the user to mangle the headers before parsing them.
5813 (gnus-run-hooks 'gnus-parse-headers-hook)
5814 (goto-char (point-min))
5815 (gnus-parse-without-error
5816 (while (and (or sequence allp)
5818 (setq number (read cur))
5820 (while (and sequence
5821 (< (car sequence) number))
5822 (setq sequence (cdr sequence))))
5825 (eq number (car sequence))))
5827 (setq sequence (cdr sequence))
5828 (setq header (inline
5829 (gnus-nov-parse-line
5830 number dependencies force-new)))))
5831 (push header headers))
5833 ;; A common bug in inn is that if you have posted an article and
5834 ;; then retrieves the active file, it will answer correctly --
5835 ;; the new article is included. However, a NOV entry for the
5836 ;; article may not have been generated yet, so this may fail.
5837 ;; We work around this problem by retrieving the last few
5838 ;; headers using HEAD.
5839 (if (or (not also-fetch-heads)
5841 ;; We (probably) got all the headers.
5843 (let ((gnus-nov-is-evil t))
5846 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5847 (gnus-get-newsgroup-headers))))))))
5849 (defun gnus-article-get-xrefs ()
5850 "Fill in the Xref value in `gnus-current-headers', if necessary.
5851 This is meant to be called in `gnus-article-internal-prepare-hook'."
5852 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5853 gnus-current-headers)))
5854 (or (not gnus-use-cross-reference)
5856 (and (mail-header-xref headers)
5857 (not (string= (mail-header-xref headers) "")))
5858 (let ((case-fold-search t)
5861 (nnheader-narrow-to-headers)
5862 (goto-char (point-min))
5863 (when (or (and (not (eobp))
5864 (eq (downcase (char-after)) ?x)
5865 (looking-at "Xref:"))
5866 (search-forward "\nXref:" nil t))
5867 (goto-char (1+ (match-end 0)))
5868 (setq xref (buffer-substring (point)
5869 (progn (end-of-line) (point))))
5870 (mail-header-set-xref headers xref)))))))
5872 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5873 "Find article ID and insert the summary line for that article.
5874 OLD-HEADER can either be a header or a line number to insert
5875 the subject line on."
5876 (let* ((line (and (numberp old-header) old-header))
5877 (old-header (and (vectorp old-header) old-header))
5878 (header (cond ((and old-header use-old-header)
5881 (gnus-number-to-header id))
5882 (gnus-number-to-header id))
5884 (gnus-read-header id))))
5885 (number (and (numberp id) id))
5888 ;; Rebuild the thread that this article is part of and go to the
5889 ;; article we have fetched.
5890 (when (and (not gnus-show-threads)
5893 (setq d (gnus-data-find (mail-header-number old-header))))
5894 (goto-char (gnus-data-pos d))
5897 (- (gnus-point-at-bol)
5899 (1+ (gnus-point-at-eol))
5900 (gnus-delete-line))))))
5902 (mail-header-set-number header (mail-header-number old-header)))
5903 (setq gnus-newsgroup-sparse
5904 (delq (setq number (mail-header-number header))
5905 gnus-newsgroup-sparse))
5906 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5907 (push number gnus-newsgroup-limit)
5908 (gnus-rebuild-thread (mail-header-id header) line)
5909 (gnus-summary-goto-subject number nil t))
5910 (when (and (numberp number)
5912 ;; We have to update the boundaries even if we can't fetch the
5913 ;; article if ID is a number -- so that the next `P' or `N'
5914 ;; command will fetch the previous (or next) article even
5915 ;; if the one we tried to fetch this time has been canceled.
5916 (when (> number gnus-newsgroup-end)
5917 (setq gnus-newsgroup-end number))
5918 (when (< number gnus-newsgroup-begin)
5919 (setq gnus-newsgroup-begin number))
5920 (setq gnus-newsgroup-unselected
5921 (delq number gnus-newsgroup-unselected)))
5922 ;; Report back a success?
5923 (and header (mail-header-number header))))
5925 ;;; Process/prefix in the summary buffer
5927 (defun gnus-summary-work-articles (n)
5928 "Return a list of articles to be worked upon.
5929 The prefix argument, the list of process marked articles, and the
5930 current article will be taken into consideration."
5932 (set-buffer gnus-summary-buffer)
5935 ;; A numerical prefix has been given.
5936 (setq n (prefix-numeric-value n))
5937 (let ((backward (< n 0))
5938 (n (abs (prefix-numeric-value n)))
5943 (push (setq article (gnus-summary-article-number))
5946 (gnus-summary-find-prev nil article)
5947 (gnus-summary-find-next nil article)))
5949 (nreverse articles)))
5950 ((and (gnus-region-active-p) (mark))
5951 (message "region active")
5952 ;; Work on the region between point and mark.
5953 (let ((max (max (point) (mark)))
5956 (goto-char (min (min (point) (mark))))
5959 (push (setq article (gnus-summary-article-number)) articles)
5960 (gnus-summary-find-next nil article)
5962 (nreverse articles))))
5963 (gnus-newsgroup-processable
5964 ;; There are process-marked articles present.
5965 ;; Save current state.
5966 (gnus-summary-save-process-mark)
5968 (reverse gnus-newsgroup-processable))
5970 ;; Just return the current article.
5971 (list (gnus-summary-article-number))))))
5973 (defmacro gnus-summary-iterate (arg &rest forms)
5974 "Iterate over the process/prefixed articles and do FORMS.
5975 ARG is the interactive prefix given to the command. FORMS will be
5976 executed with point over the summary line of the articles."
5977 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5978 `(let ((,articles (gnus-summary-work-articles ,arg)))
5980 (gnus-summary-goto-subject (car ,articles))
5984 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5985 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5987 (defun gnus-summary-save-process-mark ()
5988 "Push the current set of process marked articles on the stack."
5990 (push (copy-sequence gnus-newsgroup-processable)
5991 gnus-newsgroup-process-stack))
5993 (defun gnus-summary-kill-process-mark ()
5994 "Push the current set of process marked articles on the stack and unmark."
5996 (gnus-summary-save-process-mark)
5997 (gnus-summary-unmark-all-processable))
5999 (defun gnus-summary-yank-process-mark ()
6000 "Pop the last process mark state off the stack and restore it."
6002 (unless gnus-newsgroup-process-stack
6003 (error "Empty mark stack"))
6004 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6006 (defun gnus-summary-process-mark-set (set)
6007 "Make SET into the current process marked articles."
6008 (gnus-summary-unmark-all-processable)
6010 (gnus-summary-set-process-mark (pop set))))
6012 ;;; Searching and stuff
6014 (defun gnus-summary-search-group (&optional backward use-level)
6015 "Search for next unread newsgroup.
6016 If optional argument BACKWARD is non-nil, search backward instead."
6018 (set-buffer gnus-group-buffer)
6019 (when (gnus-group-search-forward
6020 backward nil (if use-level (gnus-group-group-level) nil))
6021 (gnus-group-group-name))))
6023 (defun gnus-summary-best-group (&optional exclude-group)
6024 "Find the name of the best unread group.
6025 If EXCLUDE-GROUP, do not go to this group."
6027 (set-buffer gnus-group-buffer)
6029 (gnus-group-best-unread-group exclude-group))))
6031 (defun gnus-summary-find-next (&optional unread article backward)
6032 (if backward (gnus-summary-find-prev)
6033 (let* ((dummy (gnus-summary-article-intangible-p))
6034 (article (or article (gnus-summary-article-number)))
6035 (data (gnus-data-find-list article))
6037 (when (and (not dummy)
6038 (or (not gnus-summary-check-current)
6040 (not (gnus-data-unread-p (car data)))))
6041 (setq data (cdr data)))
6046 (unless (memq (gnus-data-number (car data))
6047 gnus-newsgroup-unfetched)
6048 (when (gnus-data-unread-p (car data))
6049 (setq result (car data)
6051 (setq data (cdr data)))
6054 (goto-char (gnus-data-pos result))
6055 (gnus-data-number result)))))
6057 (defun gnus-summary-find-prev (&optional unread article)
6058 (let* ((eobp (eobp))
6059 (article (or article (gnus-summary-article-number)))
6060 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6062 (when (and (not eobp)
6063 (or (not gnus-summary-check-current)
6065 (not (gnus-data-unread-p (car data)))))
6066 (setq data (cdr data)))
6071 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6072 (when (gnus-data-unread-p (car data))
6073 (setq result (car data)
6075 (setq data (cdr data)))
6078 (goto-char (gnus-data-pos result))
6079 (gnus-data-number result))))
6081 (defun gnus-summary-find-subject (subject &optional unread backward article)
6082 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6083 (article (or article (gnus-summary-article-number)))
6084 (articles (gnus-data-list backward))
6085 (arts (gnus-data-find-list article articles))
6087 (when (or (not gnus-summary-check-current)
6089 (not (gnus-data-unread-p (car arts))))
6090 (setq arts (cdr arts)))
6092 (and (or (not unread)
6093 (gnus-data-unread-p (car arts)))
6094 (vectorp (gnus-data-header (car arts)))
6096 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6097 (setq result (car arts)
6099 (setq arts (cdr arts)))
6101 (goto-char (gnus-data-pos result))
6102 (gnus-data-number result))))
6104 (defun gnus-summary-search-forward (&optional unread subject backward)
6105 "Search forward for an article.
6106 If UNREAD, look for unread articles. If SUBJECT, look for
6107 articles with that subject. If BACKWARD, search backward instead."
6108 (cond (subject (gnus-summary-find-subject subject unread backward))
6109 (backward (gnus-summary-find-prev unread))
6110 (t (gnus-summary-find-next unread))))
6112 (defun gnus-recenter (&optional n)
6113 "Center point in window and redisplay frame.
6114 Also do horizontal recentering."
6116 (when (and gnus-auto-center-summary
6117 (not (eq gnus-auto-center-summary 'vertical)))
6118 (gnus-horizontal-recenter))
6121 (defun gnus-summary-recenter ()
6122 "Center point in the summary window.
6123 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6124 displayed, no centering will be performed."
6125 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6126 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6128 ;; The user has to want it.
6129 (when gnus-auto-center-summary
6130 (let* ((top (cond ((< (window-height) 4) 0)
6131 ((< (window-height) 7) 1)
6132 (t (if (numberp gnus-auto-center-summary)
6133 gnus-auto-center-summary
6135 (height (1- (window-height)))
6136 (bottom (save-excursion (goto-char (point-max))
6137 (forward-line (- height))
6139 (window (get-buffer-window (current-buffer))))
6140 (when (get-buffer-window gnus-article-buffer)
6141 ;; Only do recentering when the article buffer is displayed,
6142 ;; Set the window start to either `bottom', which is the biggest
6143 ;; possible valid number, or the second line from the top,
6144 ;; whichever is the least.
6145 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6146 (if (> bottom top-pos)
6147 ;; Keep the second line from the top visible
6148 (set-window-start window top-pos t)
6149 ;; Try to keep the bottom line visible; if it's partially
6150 ;; obscured, either scroll one more line to make it fully
6151 ;; visible, or revert to using TOP-POS.
6153 (goto-char (point-max))
6155 (let ((last-line-start (point)))
6157 (set-window-start window (point) t)
6158 (when (not (pos-visible-in-window-p last-line-start window))
6160 (set-window-start window (min (point) top-pos) t)))))))
6161 ;; Do horizontal recentering while we're at it.
6162 (when (and (get-buffer-window (current-buffer) t)
6163 (not (eq gnus-auto-center-summary 'vertical)))
6164 (let ((selected (selected-window)))
6165 (select-window (get-buffer-window (current-buffer) t))
6166 (gnus-summary-position-point)
6167 (gnus-horizontal-recenter)
6168 (select-window selected))))))
6170 (defun gnus-summary-jump-to-group (newsgroup)
6171 "Move point to NEWSGROUP in group mode buffer."
6172 ;; Keep update point of group mode buffer if visible.
6173 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6174 (save-window-excursion
6175 ;; Take care of tree window mode.
6176 (when (get-buffer-window gnus-group-buffer)
6177 (pop-to-buffer gnus-group-buffer))
6178 (gnus-group-jump-to-group newsgroup))
6180 ;; Take care of tree window mode.
6181 (if (get-buffer-window gnus-group-buffer)
6182 (pop-to-buffer gnus-group-buffer)
6183 (set-buffer gnus-group-buffer))
6184 (gnus-group-jump-to-group newsgroup))))
6186 ;; This function returns a list of article numbers based on the
6187 ;; difference between the ranges of read articles in this group and
6188 ;; the range of active articles.
6189 (defun gnus-list-of-unread-articles (group)
6190 (let* ((read (gnus-info-read (gnus-get-info group)))
6191 (active (or (gnus-active group) (gnus-activate-group group)))
6194 ;; If none are read, then all are unread.
6196 (setq first (car active))
6197 ;; If the range of read articles is a single range, then the
6198 ;; first unread article is the article after the last read
6199 ;; article. Sounds logical, doesn't it?
6200 (if (and (not (listp (cdr read)))
6201 (or (< (car read) (car active))
6202 (progn (setq read (list read))
6204 (setq first (max (car active) (1+ (cdr read))))
6205 ;; `read' is a list of ranges.
6206 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6209 (setq first (car active)))
6212 (while (< first nlast)
6214 (setq first (1+ first))))
6215 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6216 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6217 (setq read (cdr read)))))
6218 ;; And add the last unread articles.
6219 (while (<= first last)
6221 (setq first (1+ first)))
6222 ;; Return the list of unread articles.
6223 (delq 0 (nreverse unread))))
6225 (defun gnus-list-of-read-articles (group)
6226 "Return a list of unread, unticked and non-dormant articles."
6227 (let* ((info (gnus-get-info group))
6228 (marked (gnus-info-marks info))
6229 (active (gnus-active group)))
6231 (gnus-list-range-difference
6232 (gnus-list-range-difference
6233 (gnus-sorted-complement
6234 (gnus-uncompress-range active)
6235 (gnus-list-of-unread-articles group))
6236 (cdr (assq 'dormant marked)))
6237 (cdr (assq 'tick marked))))))
6239 ;; Various summary commands
6241 (defun gnus-summary-select-article-buffer ()
6242 "Reconfigure windows to show article buffer."
6244 (if (not (gnus-buffer-live-p gnus-article-buffer))
6245 (error "There is no article buffer for this summary buffer")
6246 (gnus-configure-windows 'article)
6247 (select-window (get-buffer-window gnus-article-buffer))))
6249 (defun gnus-summary-universal-argument (arg)
6250 "Perform any operation on all articles that are process/prefixed."
6252 (let ((articles (gnus-summary-work-articles arg))
6259 (substitute-command-keys
6260 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6262 (gnus-error 1 "Undefined key")
6265 (gnus-summary-goto-subject (setq article (pop articles)))
6266 (let (gnus-newsgroup-processable)
6267 (command-execute func))
6268 (gnus-summary-remove-process-mark article)))))
6269 (gnus-summary-position-point))
6271 (defun gnus-summary-toggle-truncation (&optional arg)
6272 "Toggle truncation of summary lines.
6273 With arg, turn line truncation on if arg is positive."
6275 (setq truncate-lines
6276 (if (null arg) (not truncate-lines)
6277 (> (prefix-numeric-value arg) 0)))
6280 (defun gnus-summary-find-uncancelled ()
6281 "Return the number of an uncancelled article.
6282 The current article is considered, then following articles, then previous
6283 articles. If all articles are cancelled then return a dummy 0."
6285 (dolist (rev '(nil t))
6286 (unless found ; don't demand the reverse list if we don't need it
6287 (let ((data (gnus-data-find-list
6288 (gnus-summary-article-number) (gnus-data-list rev))))
6289 (while (and data (not found))
6290 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6291 (setq found (gnus-data-number (car data))))
6292 (setq data (cdr data))))))
6295 (defun gnus-summary-reselect-current-group (&optional all rescan)
6296 "Exit and then reselect the current newsgroup.
6297 The prefix argument ALL means to select all articles."
6299 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6300 (error "Ephemeral groups can't be reselected"))
6301 (let ((current-subject (gnus-summary-find-uncancelled))
6302 (group gnus-newsgroup-name))
6303 (setq gnus-newsgroup-begin nil)
6305 ;; We have to adjust the point of group mode buffer because
6306 ;; point was moved to the next unread newsgroup by exiting.
6307 (gnus-summary-jump-to-group group)
6310 (gnus-group-get-new-news-this-group 1)))
6311 (gnus-group-read-group all t)
6312 (gnus-summary-goto-subject current-subject nil t)))
6314 (defun gnus-summary-rescan-group (&optional all)
6315 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6317 (gnus-summary-reselect-current-group all t))
6319 (defun gnus-summary-update-info (&optional non-destructive)
6321 (let ((group gnus-newsgroup-name))
6323 (when gnus-newsgroup-kill-headers
6324 (setq gnus-newsgroup-killed
6325 (gnus-compress-sequence
6327 (gnus-list-range-intersection
6328 gnus-newsgroup-unselected gnus-newsgroup-killed)
6329 gnus-newsgroup-unreads)
6331 (unless (listp (cdr gnus-newsgroup-killed))
6332 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6333 (let ((headers gnus-newsgroup-headers))
6334 ;; Set the new ranges of read articles.
6336 (set-buffer gnus-group-buffer)
6337 (gnus-undo-force-boundary))
6338 (gnus-update-read-articles
6339 group (gnus-sorted-union
6340 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6341 ;; Set the current article marks.
6342 (let ((gnus-newsgroup-scored
6343 (if (and (not gnus-save-score)
6344 (not non-destructive))
6346 gnus-newsgroup-scored)))
6348 (gnus-update-marks)))
6349 ;; Do the cross-ref thing.
6350 (when gnus-use-cross-reference
6351 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6352 ;; Do not switch windows but change the buffer to work.
6353 (set-buffer gnus-group-buffer)
6354 (unless (gnus-ephemeral-group-p group)
6355 (gnus-group-update-group group)))))))
6357 (defun gnus-summary-save-newsrc (&optional force)
6358 "Save the current number of read/marked articles in the dribble buffer.
6359 The dribble buffer will then be saved.
6360 If FORCE (the prefix), also save the .newsrc file(s)."
6362 (gnus-summary-update-info t)
6364 (gnus-save-newsrc-file)
6365 (gnus-dribble-save)))
6367 (defun gnus-summary-exit (&optional temporary)
6368 "Exit reading current newsgroup, and then return to group selection mode.
6369 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6371 (gnus-set-global-variables)
6372 (when (gnus-buffer-live-p gnus-article-buffer)
6374 (set-buffer gnus-article-buffer)
6375 (mm-destroy-parts gnus-article-mime-handles)
6376 ;; Set it to nil for safety reason.
6377 (setq gnus-article-mime-handle-alist nil)
6378 (setq gnus-article-mime-handles nil)))
6379 (gnus-kill-save-kill-buffer)
6380 (gnus-async-halt-prefetch)
6381 (let* ((group gnus-newsgroup-name)
6382 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6383 (gnus-group-is-exiting-p t)
6386 (buf (current-buffer)))
6388 ;; Do adaptive scoring, and possibly save score files.
6389 (when gnus-newsgroup-adaptive
6390 (gnus-score-adaptive))
6391 (when gnus-use-scoring
6393 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6394 ;; If we have several article buffers, we kill them at exit.
6395 (unless gnus-single-article-buffer
6396 (gnus-kill-buffer gnus-original-article-buffer)
6397 (setq gnus-article-current nil))
6398 (when gnus-use-cache
6399 (gnus-cache-possibly-remove-articles)
6400 (gnus-cache-save-buffers))
6401 (gnus-async-prefetch-remove-group group)
6402 (when gnus-suppress-duplicates
6403 (gnus-dup-enter-articles))
6404 (when gnus-use-trees
6405 (gnus-tree-close group))
6406 (when gnus-use-cache
6407 (gnus-cache-write-active))
6408 ;; Remove entries for this group.
6409 (nnmail-purge-split-history (gnus-group-real-name group))
6410 ;; Make all changes in this group permanent.
6412 (gnus-run-hooks 'gnus-exit-group-hook)
6413 (gnus-summary-update-info))
6414 (gnus-close-group group)
6415 ;; Make sure where we were, and go to next newsgroup.
6416 (set-buffer gnus-group-buffer)
6418 (gnus-group-jump-to-group group))
6419 (gnus-run-hooks 'gnus-summary-exit-hook)
6420 (unless (or quit-config
6421 ;; If this group has disappeared from the summary
6422 ;; buffer, don't skip forwards.
6423 (not (string= group (gnus-group-group-name))))
6424 (gnus-group-next-unread-group 1))
6425 (setq group-point (point))
6428 ;; If we have several article buffers, we kill them at exit.
6429 (unless gnus-single-article-buffer
6430 (gnus-kill-buffer gnus-article-buffer)
6431 (gnus-kill-buffer gnus-original-article-buffer)
6432 (setq gnus-article-current nil))
6434 (if (not gnus-kill-summary-on-exit)
6436 (gnus-deaden-summary)
6438 ;; We set all buffer-local variables to nil. It is unclear why
6439 ;; this is needed, but if we don't, buffer-local variables are
6440 ;; not garbage-collected, it seems. This would the lead to en
6441 ;; ever-growing Emacs.
6442 (gnus-summary-clear-local-variables)
6443 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6444 (gnus-summary-clear-local-variables))
6445 (when (get-buffer gnus-article-buffer)
6446 (bury-buffer gnus-article-buffer))
6447 ;; We clear the global counterparts of the buffer-local
6448 ;; variables as well, just to be on the safe side.
6449 (set-buffer gnus-group-buffer)
6450 (gnus-summary-clear-local-variables)
6451 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6452 (gnus-summary-clear-local-variables))
6453 ;; Return to group mode buffer.
6454 (when (eq mode 'gnus-summary-mode)
6455 (gnus-kill-buffer buf)))
6456 (setq gnus-current-select-method gnus-select-method)
6457 (pop-to-buffer gnus-group-buffer)
6458 (if (not quit-config)
6460 (goto-char group-point)
6461 (gnus-configure-windows 'group 'force))
6462 (gnus-handle-ephemeral-exit quit-config))
6463 ;; Clear the current group name.
6465 (setq gnus-newsgroup-name nil)))))
6467 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6468 (defun gnus-summary-exit-no-update (&optional no-questions)
6469 "Quit reading current newsgroup without updating read article info."
6471 (let* ((group gnus-newsgroup-name)
6472 (gnus-group-is-exiting-p t)
6473 (quit-config (gnus-group-quit-config group)))
6474 (when (or no-questions
6476 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6477 (gnus-async-halt-prefetch)
6479 (delq 'gnus-summary-expire-articles
6480 (copy-sequence gnus-summary-prepare-exit-hook)))
6481 (when (gnus-buffer-live-p gnus-article-buffer)
6483 (set-buffer gnus-article-buffer)
6484 (mm-destroy-parts gnus-article-mime-handles)
6485 ;; Set it to nil for safety reason.
6486 (setq gnus-article-mime-handle-alist nil)
6487 (setq gnus-article-mime-handles nil)))
6488 ;; If we have several article buffers, we kill them at exit.
6489 (unless gnus-single-article-buffer
6490 (gnus-kill-buffer gnus-article-buffer)
6491 (gnus-kill-buffer gnus-original-article-buffer)
6492 (setq gnus-article-current nil))
6493 (if (not gnus-kill-summary-on-exit)
6494 (gnus-deaden-summary)
6495 (gnus-close-group group)
6496 (gnus-summary-clear-local-variables)
6497 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6498 (gnus-summary-clear-local-variables))
6499 (set-buffer gnus-group-buffer)
6500 (gnus-summary-clear-local-variables)
6501 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6502 (gnus-summary-clear-local-variables))
6503 (when (get-buffer gnus-summary-buffer)
6504 (kill-buffer gnus-summary-buffer)))
6505 (unless gnus-single-article-buffer
6506 (setq gnus-article-current nil))
6507 (when gnus-use-trees
6508 (gnus-tree-close group))
6509 (gnus-async-prefetch-remove-group group)
6510 (when (get-buffer gnus-article-buffer)
6511 (bury-buffer gnus-article-buffer))
6512 ;; Return to the group buffer.
6513 (gnus-configure-windows 'group 'force)
6514 ;; Clear the current group name.
6515 (setq gnus-newsgroup-name nil)
6516 (unless (gnus-ephemeral-group-p group)
6517 (gnus-group-update-group group))
6518 (when (equal (gnus-group-group-name) group)
6519 (gnus-group-next-unread-group 1))
6521 (gnus-handle-ephemeral-exit quit-config)))))
6523 (defun gnus-handle-ephemeral-exit (quit-config)
6524 "Handle movement when leaving an ephemeral group.
6525 The state which existed when entering the ephemeral is reset."
6526 (if (not (buffer-name (car quit-config)))
6527 (gnus-configure-windows 'group 'force)
6528 (set-buffer (car quit-config))
6529 (cond ((eq major-mode 'gnus-summary-mode)
6530 (gnus-set-global-variables))
6531 ((eq major-mode 'gnus-article-mode)
6533 ;; The `gnus-summary-buffer' variable may point
6534 ;; to the old summary buffer when using a single
6536 (unless (gnus-buffer-live-p gnus-summary-buffer)
6537 (set-buffer gnus-group-buffer))
6538 (set-buffer gnus-summary-buffer)
6539 (gnus-set-global-variables))))
6540 (if (or (eq (cdr quit-config) 'article)
6541 (eq (cdr quit-config) 'pick))
6543 ;; The current article may be from the ephemeral group
6544 ;; thus it is best that we reload this article
6545 (gnus-summary-show-article)
6546 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6547 (gnus-configure-windows 'pick 'force)
6548 (gnus-configure-windows (cdr quit-config) 'force)))
6549 (gnus-configure-windows (cdr quit-config) 'force))
6550 (when (eq major-mode 'gnus-summary-mode)
6551 (gnus-summary-next-subject 1 nil t)
6552 (gnus-summary-recenter)
6553 (gnus-summary-position-point))))
6557 (defvar gnus-dead-summary-mode-map nil)
6559 (unless gnus-dead-summary-mode-map
6560 (setq gnus-dead-summary-mode-map (make-keymap))
6561 (suppress-keymap gnus-dead-summary-mode-map)
6562 (substitute-key-definition
6563 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6564 (dolist (key '("\C-d" "\r" "\177" [delete]))
6565 (define-key gnus-dead-summary-mode-map
6566 key 'gnus-summary-wake-up-the-dead))
6567 (dolist (key '("q" "Q"))
6568 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6570 (defvar gnus-dead-summary-mode nil
6571 "Minor mode for Gnus summary buffers.")
6573 (defun gnus-dead-summary-mode (&optional arg)
6574 "Minor mode for Gnus summary buffers."
6576 (when (eq major-mode 'gnus-summary-mode)
6577 (make-local-variable 'gnus-dead-summary-mode)
6578 (setq gnus-dead-summary-mode
6579 (if (null arg) (not gnus-dead-summary-mode)
6580 (> (prefix-numeric-value arg) 0)))
6581 (when gnus-dead-summary-mode
6582 (gnus-add-minor-mode
6583 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6585 (defun gnus-deaden-summary ()
6586 "Make the current summary buffer into a dead summary buffer."
6587 ;; Kill any previous dead summary buffer.
6588 (when (and gnus-dead-summary
6589 (buffer-name gnus-dead-summary))
6591 (set-buffer gnus-dead-summary)
6592 (when gnus-dead-summary-mode
6593 (kill-buffer (current-buffer)))))
6594 ;; Make this the current dead summary.
6595 (setq gnus-dead-summary (current-buffer))
6596 (gnus-dead-summary-mode 1)
6597 (let ((name (buffer-name)))
6598 (when (string-match "Summary" name)
6600 (concat (substring name 0 (match-beginning 0)) "Dead "
6601 (substring name (match-beginning 0)))
6605 (defun gnus-kill-or-deaden-summary (buffer)
6606 "Kill or deaden the summary BUFFER."
6608 (when (and (buffer-name buffer)
6609 (not gnus-single-article-buffer))
6612 (gnus-kill-buffer gnus-article-buffer)
6613 (gnus-kill-buffer gnus-original-article-buffer)))
6616 (gnus-kill-summary-on-exit
6617 (when (and gnus-use-trees
6618 (gnus-buffer-exists-p buffer))
6621 (gnus-tree-close gnus-newsgroup-name)))
6622 (gnus-kill-buffer buffer))
6623 ;; Deaden the buffer.
6624 ((gnus-buffer-exists-p buffer)
6627 (gnus-deaden-summary))))))
6629 (defun gnus-summary-wake-up-the-dead (&rest args)
6630 "Wake up the dead summary buffer."
6632 (gnus-dead-summary-mode -1)
6633 (let ((name (buffer-name)))
6634 (when (string-match "Dead " name)
6636 (concat (substring name 0 (match-beginning 0))
6637 (substring name (match-end 0)))
6639 (gnus-message 3 "This dead summary is now alive again"))
6641 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6642 (defun gnus-summary-fetch-faq (&optional faq-dir)
6643 "Fetch the FAQ for the current group.
6644 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6648 (when current-prefix-arg
6650 "FAQ dir: " (and (listp gnus-group-faq-directory)
6651 (mapcar (lambda (file) (list file))
6652 gnus-group-faq-directory))))))
6653 (let (gnus-faq-buffer)
6654 (when (setq gnus-faq-buffer
6655 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6656 (gnus-configure-windows 'summary-faq))))
6658 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6659 (defun gnus-summary-describe-group (&optional force)
6660 "Describe the current newsgroup."
6662 (gnus-group-describe-group force gnus-newsgroup-name))
6664 (defun gnus-summary-describe-briefly ()
6665 "Describe summary mode commands briefly."
6667 (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")))
6669 ;; Walking around group mode buffer from summary mode.
6671 (defun gnus-summary-next-group (&optional no-article target-group backward)
6672 "Exit current newsgroup and then select next unread newsgroup.
6673 If prefix argument NO-ARTICLE is non-nil, no article is selected
6674 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6675 previous group instead."
6677 ;; Stop pre-fetching.
6678 (gnus-async-halt-prefetch)
6679 (let ((current-group gnus-newsgroup-name)
6680 (current-buffer (current-buffer))
6682 (while (not entered)
6683 ;; Then we find what group we are supposed to enter.
6684 (set-buffer gnus-group-buffer)
6685 (gnus-group-jump-to-group current-group)
6688 (if (eq gnus-keep-same-level 'best)
6689 (gnus-summary-best-group gnus-newsgroup-name)
6690 (gnus-summary-search-group backward gnus-keep-same-level))))
6691 (if (not target-group)
6692 ;; There are no further groups, so we return to the group
6695 (gnus-message 5 "Returning to the group buffer")
6697 (when (gnus-buffer-live-p current-buffer)
6698 (set-buffer current-buffer)
6699 (gnus-summary-exit))
6700 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6701 ;; We try to enter the target group.
6702 (gnus-group-jump-to-group target-group)
6703 (let ((unreads (gnus-group-group-unread)))
6704 (if (and (or (eq t unreads)
6705 (and unreads (not (zerop unreads))))
6707 ;; Now we semi-exit this group to update Xrefs
6708 ;; and all variables. We can't do a real exit,
6709 ;; because the window conf must remain the same
6710 ;; in case the user is prompted for info, and we
6711 ;; don't want the window conf to change before
6713 (when (gnus-buffer-live-p current-buffer)
6714 (set-buffer current-buffer)
6715 (gnus-summary-exit t))
6716 (gnus-summary-read-group
6717 target-group nil no-article
6718 (and (buffer-name current-buffer) current-buffer)
6721 (setq current-group target-group
6722 target-group nil)))))))
6724 (defun gnus-summary-prev-group (&optional no-article)
6725 "Exit current newsgroup and then select previous unread newsgroup.
6726 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6728 (gnus-summary-next-group no-article nil t))
6730 ;; Walking around summary lines.
6732 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6733 "Go to the first subject satisfying any non-nil constraint.
6734 If UNREAD is non-nil, the article should be unread.
6735 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6736 If UNSEED is non-nil, the article should be unseen.
6737 Returns the article selected or nil if there are no matching articles."
6741 ((null gnus-newsgroup-data)
6742 (gnus-message 3 "No articles in the group")
6744 ;; Pick the first article.
6745 ((not (or unread undownloaded unseen))
6746 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6747 (gnus-data-number (car gnus-newsgroup-data)))
6748 ;; Find the first unread article.
6750 (let ((data gnus-newsgroup-data))
6752 (let ((num (gnus-data-number (car data))))
6753 (or (memq num gnus-newsgroup-unfetched)
6754 (not (or (and unread
6755 (memq num gnus-newsgroup-unreads))
6757 (memq num gnus-newsgroup-undownloaded))
6759 (memq num gnus-newsgroup-unseen)))))))
6760 (setq data (cdr data)))
6764 (goto-char (gnus-data-pos (car data)))
6765 (gnus-data-number (car data)))
6766 (gnus-message 3 "No more%s articles"
6767 (let* ((r (when unread " unread"))
6768 (d (when undownloaded " undownloaded"))
6769 (s (when unseen " unseen"))
6770 (l (delq nil (list r d s))))
6771 (cond ((= 3 (length l))
6772 (concat r "," d ", or" s))
6774 (concat (car l) ", or" (cadr l)))
6781 (gnus-summary-position-point))))))
6783 (defun gnus-summary-next-subject (n &optional unread dont-display)
6784 "Go to next N'th summary line.
6785 If N is negative, go to the previous N'th subject line.
6786 If UNREAD is non-nil, only unread articles are selected.
6787 The difference between N and the actual number of steps taken is
6790 (let ((backward (< n 0))
6794 (gnus-summary-find-prev unread)
6795 (gnus-summary-find-next unread)))
6796 (unless (zerop (setq n (1- n)))
6797 (gnus-summary-show-thread)))
6799 (gnus-message 7 "No more%s articles"
6800 (if unread " unread" "")))
6801 (unless dont-display
6802 (gnus-summary-recenter)
6803 (gnus-summary-position-point))
6806 (defun gnus-summary-next-unread-subject (n)
6807 "Go to next N'th unread summary line."
6809 (gnus-summary-next-subject n t))
6811 (defun gnus-summary-prev-subject (n &optional unread)
6812 "Go to previous N'th summary line.
6813 If optional argument UNREAD is non-nil, only unread article is selected."
6815 (gnus-summary-next-subject (- n) unread))
6817 (defun gnus-summary-prev-unread-subject (n)
6818 "Go to previous N'th unread summary line."
6820 (gnus-summary-next-subject (- n) t))
6822 (defun gnus-summary-goto-subjects (articles)
6823 "Insert the subject header for ARTICLES in the current buffer."
6825 (dolist (article articles)
6826 (gnus-summary-goto-subject article t)))
6827 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6828 (gnus-summary-position-point))
6830 (defun gnus-summary-goto-subject (article &optional force silent)
6831 "Go the subject line of ARTICLE.
6832 If FORCE, also allow jumping to articles not currently shown."
6833 (interactive "nArticle number: ")
6834 (unless (numberp article)
6835 (error "Article %s is not a number" article))
6837 (data (gnus-data-find article)))
6838 ;; We read in the article if we have to.
6841 (gnus-summary-insert-subject
6843 (if (or (numberp force) (vectorp force)) force)
6845 (setq data (gnus-data-find article)))
6850 (gnus-message 3 "Can't find article %d" article))
6852 (let ((pt (gnus-data-pos data)))
6854 (gnus-summary-set-article-display-arrow pt))
6855 (gnus-summary-position-point)
6858 ;; Walking around summary lines with displaying articles.
6860 (defun gnus-summary-expand-window (&optional arg)
6861 "Make the summary buffer take up the entire Emacs frame.
6862 Given a prefix, will force an `article' buffer configuration."
6865 (gnus-configure-windows 'article 'force)
6866 (gnus-configure-windows 'summary 'force)))
6868 (defun gnus-summary-display-article (article &optional all-header)
6869 "Display ARTICLE in article buffer."
6870 (when (gnus-buffer-live-p gnus-article-buffer)
6871 (with-current-buffer gnus-article-buffer
6872 (mm-enable-multibyte)))
6873 (gnus-set-global-variables)
6874 (when (gnus-buffer-live-p gnus-article-buffer)
6875 (with-current-buffer gnus-article-buffer
6876 (setq gnus-article-charset gnus-newsgroup-charset)
6877 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6878 (mm-enable-multibyte)))
6882 (if gnus-summary-display-article-function
6883 (funcall gnus-summary-display-article-function article all-header)
6884 (gnus-article-prepare article all-header))
6885 (gnus-run-hooks 'gnus-select-article-hook)
6886 (when (and gnus-current-article
6887 (not (zerop gnus-current-article)))
6888 (gnus-summary-goto-subject gnus-current-article))
6889 (gnus-summary-recenter)
6890 (when (and gnus-use-trees gnus-show-threads)
6891 (gnus-possibly-generate-tree article)
6892 (gnus-highlight-selected-tree article))
6893 ;; Successfully display article.
6894 (gnus-article-set-window-start
6895 (cdr (assq article gnus-newsgroup-bookmarks))))))
6897 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6898 "Select the current article.
6899 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6900 non-nil, the article will be re-fetched even if it already present in
6901 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6903 ;; Make sure we are in the summary buffer to work around bbdb bug.
6904 (unless (eq major-mode 'gnus-summary-mode)
6905 (set-buffer gnus-summary-buffer))
6906 (let ((article (or article (gnus-summary-article-number)))
6907 (all-headers (not (not all-headers))) ;Must be t or nil.
6908 gnus-summary-display-article-function)
6910 (gnus-summary-article-pseudo-p article)
6911 (error "This is a pseudo-article"))
6913 (set-buffer gnus-summary-buffer)
6914 (if (or (and gnus-single-article-buffer
6915 (or (null gnus-current-article)
6916 (null gnus-article-current)
6917 (null (get-buffer gnus-article-buffer))
6918 (not (eq article (cdr gnus-article-current)))
6919 (not (equal (car gnus-article-current)
6920 gnus-newsgroup-name))))
6921 (and (not gnus-single-article-buffer)
6922 (or (null gnus-current-article)
6923 (not (eq gnus-current-article article))))
6925 ;; The requested article is different from the current article.
6927 (gnus-summary-display-article article all-headers)
6928 (when (gnus-buffer-live-p gnus-article-buffer)
6929 (with-current-buffer gnus-article-buffer
6930 (if (not gnus-article-decoded-p) ;; a local variable
6931 (mm-disable-multibyte))))
6932 (gnus-article-set-window-start
6933 (cdr (assq article gnus-newsgroup-bookmarks)))
6937 (defun gnus-summary-force-verify-and-decrypt ()
6938 "Display buttons for signed/encrypted parts and verify/decrypt them."
6940 (let ((mm-verify-option 'known)
6941 (mm-decrypt-option 'known)
6942 (gnus-buttonized-mime-types (append (list "multipart/signed"
6943 "multipart/encrypted")
6944 gnus-buttonized-mime-types)))
6945 (gnus-summary-select-article nil 'force)))
6947 (defun gnus-summary-set-current-mark (&optional current-mark)
6948 "Obsolete function."
6951 (defun gnus-summary-next-article (&optional unread subject backward push)
6952 "Select the next article.
6953 If UNREAD, only unread articles are selected.
6954 If SUBJECT, only articles with SUBJECT are selected.
6955 If BACKWARD, the previous article is selected instead of the next."
6958 ;; Is there such an article?
6959 ((and (gnus-summary-search-forward unread subject backward)
6960 (or (gnus-summary-display-article (gnus-summary-article-number))
6961 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6962 (gnus-summary-position-point))
6963 ;; If not, we try the first unread, if that is wanted.
6965 gnus-auto-select-same
6966 (gnus-summary-first-unread-article))
6967 (gnus-summary-position-point)
6968 (gnus-message 6 "Wrapped"))
6969 ;; Try to get next/previous article not displayed in this group.
6970 ((and gnus-auto-extend-newsgroup
6971 (not unread) (not subject))
6972 (gnus-summary-goto-article
6973 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6974 nil (count-lines (point-min) (point))))
6975 ;; Go to next/previous group.
6977 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6978 (gnus-summary-jump-to-group gnus-newsgroup-name))
6979 (let ((cmd last-command-char)
6982 (set-buffer gnus-group-buffer)
6985 (if (eq gnus-keep-same-level 'best)
6986 (gnus-summary-best-group gnus-newsgroup-name)
6987 (gnus-summary-search-group backward gnus-keep-same-level))))
6988 ;; For some reason, the group window gets selected. We change
6990 (select-window (get-buffer-window (current-buffer)))
6991 ;; Select next unread newsgroup automagically.
6993 ((or (not gnus-auto-select-next)
6995 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6996 ((or (eq gnus-auto-select-next 'quietly)
6997 (and (eq gnus-auto-select-next 'slightly-quietly)
6999 (and (eq gnus-auto-select-next 'almost-quietly)
7000 (gnus-summary-last-article-p)))
7002 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7004 (gnus-message 7 "No more%s articles (%s)..."
7005 (if unread " unread" "")
7006 (if group (concat "selecting " group)
7008 (gnus-summary-next-group nil group backward)))
7010 (when (gnus-key-press-event-p last-input-event)
7011 (gnus-summary-walk-group-buffer
7012 gnus-newsgroup-name cmd unread backward point))))))))
7014 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7015 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7016 (?\C-p (gnus-group-prev-unread-group 1))))
7017 (cursor-in-echo-area t)
7018 keve key group ended prompt)
7020 (set-buffer gnus-group-buffer)
7023 (if (eq gnus-keep-same-level 'best)
7024 (gnus-summary-best-group gnus-newsgroup-name)
7025 (gnus-summary-search-group backward gnus-keep-same-level))))
7029 "No more%s articles%s " (if unread " unread" "")
7031 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7032 (format " (Type %s for %s [%s])"
7033 (single-key-description cmd) group
7034 (car (gnus-gethash group gnus-newsrc-hashtb)))
7035 (format " (Type %s to exit %s)"
7036 (single-key-description cmd)
7037 gnus-newsgroup-name))))
7038 ;; Confirm auto selection.
7039 (setq key (car (setq keve (gnus-read-event-char prompt)))
7042 ((assq key keystrokes)
7043 (let ((obuf (current-buffer)))
7044 (switch-to-buffer gnus-group-buffer)
7046 (gnus-group-jump-to-group group))
7047 (eval (cadr (assq key keystrokes)))
7048 (setq group (gnus-group-group-name))
7049 (switch-to-buffer obuf))
7053 (gnus-ephemeral-group-p gnus-newsgroup-name))
7055 (gnus-summary-next-group nil group backward)))
7057 (push (cdr keve) unread-command-events))))))
7059 (defun gnus-summary-next-unread-article ()
7060 "Select unread article after current one."
7062 (gnus-summary-next-article
7063 (or (not (eq gnus-summary-goto-unread 'never))
7064 (gnus-summary-last-article-p (gnus-summary-article-number)))
7065 (and gnus-auto-select-same
7066 (gnus-summary-article-subject))))
7068 (defun gnus-summary-prev-article (&optional unread subject)
7069 "Select the article after the current one.
7070 If UNREAD is non-nil, only unread articles are selected."
7072 (gnus-summary-next-article unread subject t))
7074 (defun gnus-summary-prev-unread-article ()
7075 "Select unread article before current one."
7077 (gnus-summary-prev-article
7078 (or (not (eq gnus-summary-goto-unread 'never))
7079 (gnus-summary-first-article-p (gnus-summary-article-number)))
7080 (and gnus-auto-select-same
7081 (gnus-summary-article-subject))))
7083 (defun gnus-summary-next-page (&optional lines circular stop)
7084 "Show next page of the selected article.
7085 If at the end of the current article, select the next article.
7086 LINES says how many lines should be scrolled up.
7088 If CIRCULAR is non-nil, go to the start of the article instead of
7089 selecting the next article when reaching the end of the current
7092 If STOP is non-nil, just stop when reaching the end of the message."
7094 (setq gnus-summary-buffer (current-buffer))
7095 (gnus-set-global-variables)
7096 (let ((article (gnus-summary-article-number))
7097 (article-window (get-buffer-window gnus-article-buffer t))
7099 ;; If the buffer is empty, we have no article.
7101 (error "No article to select"))
7102 (gnus-configure-windows 'article)
7103 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7104 (if (and (eq gnus-summary-goto-unread 'never)
7105 (not (gnus-summary-last-article-p article)))
7106 (gnus-summary-next-article)
7107 (gnus-summary-next-unread-article))
7108 (if (or (null gnus-current-article)
7109 (null gnus-article-current)
7110 (/= article (cdr gnus-article-current))
7111 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7112 ;; Selected subject is different from current article's.
7113 (gnus-summary-display-article article)
7114 (when article-window
7115 (gnus-eval-in-buffer-window gnus-article-buffer
7116 (setq endp (or (gnus-article-next-page lines)
7117 (gnus-article-only-boring-p))))
7120 (gnus-message 3 "End of message"))
7122 (gnus-summary-beginning-of-article))
7124 (gnus-message 3 "End of message"))
7126 (if (and (eq gnus-summary-goto-unread 'never)
7127 (not (gnus-summary-last-article-p article)))
7128 (gnus-summary-next-article)
7129 (gnus-summary-next-unread-article))))))))
7130 (gnus-summary-recenter)
7131 (gnus-summary-position-point)))
7133 (defun gnus-summary-prev-page (&optional lines move)
7134 "Show previous page of selected article.
7135 Argument LINES specifies lines to be scrolled down.
7136 If MOVE, move to the previous unread article if point is at
7137 the beginning of the buffer."
7139 (let ((article (gnus-summary-article-number))
7140 (article-window (get-buffer-window gnus-article-buffer t))
7142 (gnus-configure-windows 'article)
7143 (if (or (null gnus-current-article)
7144 (null gnus-article-current)
7145 (/= article (cdr gnus-article-current))
7146 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7147 ;; Selected subject is different from current article's.
7148 (gnus-summary-display-article article)
7149 (gnus-summary-recenter)
7150 (when article-window
7151 (gnus-eval-in-buffer-window gnus-article-buffer
7152 (setq endp (gnus-article-prev-page lines)))
7153 (when (and move endp)
7155 (gnus-message 3 "Beginning of message"))
7157 (if (and (eq gnus-summary-goto-unread 'never)
7158 (not (gnus-summary-first-article-p article)))
7159 (gnus-summary-prev-article)
7160 (gnus-summary-prev-unread-article))))))))
7161 (gnus-summary-position-point))
7163 (defun gnus-summary-prev-page-or-article (&optional lines)
7164 "Show previous page of selected article.
7165 Argument LINES specifies lines to be scrolled down.
7166 If at the beginning of the article, go to the next article."
7168 (gnus-summary-prev-page lines t))
7170 (defun gnus-summary-scroll-up (lines)
7171 "Scroll up (or down) one line current article.
7172 Argument LINES specifies lines to be scrolled up (or down if negative)."
7174 (gnus-configure-windows 'article)
7175 (gnus-summary-show-thread)
7176 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7177 (gnus-eval-in-buffer-window gnus-article-buffer
7179 (when (gnus-article-next-page lines)
7180 (gnus-message 3 "End of message")))
7182 (gnus-article-prev-page (- lines))))))
7183 (gnus-summary-recenter)
7184 (gnus-summary-position-point))
7186 (defun gnus-summary-scroll-down (lines)
7187 "Scroll down (or up) one line current article.
7188 Argument LINES specifies lines to be scrolled down (or up if negative)."
7190 (gnus-summary-scroll-up (- lines)))
7192 (defun gnus-summary-next-same-subject ()
7193 "Select next article which has the same subject as current one."
7195 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7197 (defun gnus-summary-prev-same-subject ()
7198 "Select previous article which has the same subject as current one."
7200 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7202 (defun gnus-summary-next-unread-same-subject ()
7203 "Select next unread article which has the same subject as current one."
7205 (gnus-summary-next-article t (gnus-summary-article-subject)))
7207 (defun gnus-summary-prev-unread-same-subject ()
7208 "Select previous unread article which has the same subject as current one."
7210 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7212 (defun gnus-summary-first-unread-article ()
7213 "Select the first unread article.
7214 Return nil if there are no unread articles."
7217 (when (gnus-summary-first-subject t)
7218 (gnus-summary-show-thread)
7219 (gnus-summary-first-subject t)
7220 (gnus-summary-display-article (gnus-summary-article-number)))
7221 (gnus-summary-position-point)))
7223 (defun gnus-summary-first-unread-subject ()
7224 "Place the point on the subject line of the first unread article.
7225 Return nil if there are no unread articles."
7228 (when (gnus-summary-first-subject t)
7229 (gnus-summary-show-thread)
7230 (gnus-summary-first-subject t))
7231 (gnus-summary-position-point)))
7233 (defun gnus-summary-first-unseen-subject ()
7234 "Place the point on the subject line of the first unseen article.
7235 Return nil if there are no unseen articles."
7238 (when (gnus-summary-first-subject nil nil t)
7239 (gnus-summary-show-thread)
7240 (gnus-summary-first-subject nil nil t))
7241 (gnus-summary-position-point)))
7243 (defun gnus-summary-first-unseen-or-unread-subject ()
7244 "Place the point on the subject line of the first unseen article or,
7245 if all article have been seen, on the subject line of the first unread
7249 (unless (when (gnus-summary-first-subject nil nil t)
7250 (gnus-summary-show-thread)
7251 (gnus-summary-first-subject nil nil t))
7252 (when (gnus-summary-first-subject t)
7253 (gnus-summary-show-thread)
7254 (gnus-summary-first-subject t)))
7255 (gnus-summary-position-point)))
7257 (defun gnus-summary-first-article ()
7258 "Select the first article.
7259 Return nil if there are no articles."
7262 (when (gnus-summary-first-subject)
7263 (gnus-summary-show-thread)
7264 (gnus-summary-first-subject)
7265 (gnus-summary-display-article (gnus-summary-article-number)))
7266 (gnus-summary-position-point)))
7268 (defun gnus-summary-best-unread-article (&optional arg)
7269 "Select the unread article with the highest score.
7270 If given a prefix argument, select the next unread article that has a
7271 score higher than the default score."
7273 (let ((article (if arg
7274 (gnus-summary-better-unread-subject)
7275 (gnus-summary-best-unread-subject))))
7277 (gnus-summary-goto-article article)
7278 (error "No unread articles"))))
7280 (defun gnus-summary-best-unread-subject ()
7281 "Select the unread subject with the highest score."
7283 (let ((best -1000000)
7284 (data gnus-newsgroup-data)
7287 (and (gnus-data-unread-p (car data))
7289 (gnus-summary-article-score (gnus-data-number (car data))))
7292 article (gnus-data-number (car data))))
7293 (setq data (cdr data)))
7295 (gnus-summary-goto-subject article))
7296 (gnus-summary-position-point)
7299 (defun gnus-summary-better-unread-subject ()
7300 "Select the first unread subject that has a score over the default score."
7302 (let ((data gnus-newsgroup-data)
7304 (while (and (setq article (gnus-data-number (car data)))
7305 (or (gnus-data-read-p (car data))
7306 (not (> (gnus-summary-article-score article)
7307 gnus-summary-default-score))))
7308 (setq data (cdr data)))
7310 (gnus-summary-goto-subject article))
7311 (gnus-summary-position-point)
7314 (defun gnus-summary-last-subject ()
7315 "Go to the last displayed subject line in the group."
7316 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7318 (gnus-summary-goto-subject article))))
7320 (defun gnus-summary-goto-article (article &optional all-headers force)
7321 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7322 If ALL-HEADERS is non-nil, no header lines are hidden.
7323 If FORCE, go to the article even if it isn't displayed. If FORCE
7324 is a number, it is the line the article is to be displayed on."
7328 "Article number or Message-ID: "
7329 (mapcar (lambda (number) (list (int-to-string number)))
7330 gnus-newsgroup-limit))
7334 (if (and (stringp article)
7335 (string-match "@" article))
7336 (gnus-summary-refer-article article)
7337 (when (stringp article)
7338 (setq article (string-to-number article)))
7339 (if (gnus-summary-goto-subject article force)
7340 (gnus-summary-display-article article all-headers)
7341 (gnus-message 4 "Couldn't go to article %s" article) nil))
7342 (gnus-summary-position-point)))
7344 (defun gnus-summary-goto-last-article ()
7345 "Go to the previously read article."
7348 (when gnus-last-article
7349 (gnus-summary-goto-article gnus-last-article nil t))
7350 (gnus-summary-position-point)))
7352 (defun gnus-summary-pop-article (number)
7353 "Pop one article off the history and go to the previous.
7354 NUMBER articles will be popped off."
7357 (setq gnus-newsgroup-history
7358 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7360 (gnus-summary-goto-article (car to) nil t)
7361 (error "Article history empty")))
7362 (gnus-summary-position-point))
7364 ;; Summary commands and functions for limiting the summary buffer.
7366 (defun gnus-summary-limit-to-articles (n)
7367 "Limit the summary buffer to the next N articles.
7368 If not given a prefix, use the process marked articles instead."
7371 (let ((articles (gnus-summary-work-articles n)))
7372 (setq gnus-newsgroup-processable nil)
7373 (gnus-summary-limit articles))
7374 (gnus-summary-position-point)))
7376 (defun gnus-summary-pop-limit (&optional total)
7377 "Restore the previous limit.
7378 If given a prefix, remove all limits."
7381 (setq gnus-newsgroup-limits
7382 (list (mapcar (lambda (h) (mail-header-number h))
7383 gnus-newsgroup-headers))))
7384 (unless gnus-newsgroup-limits
7385 (error "No limit to pop"))
7387 (gnus-summary-limit nil 'pop)
7388 (gnus-summary-position-point)))
7390 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7391 "Limit the summary buffer to articles that have subjects that match a regexp.
7392 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7394 (list (read-string (if current-prefix-arg
7395 "Exclude subject (regexp): "
7396 "Limit to subject (regexp): "))
7397 nil current-prefix-arg))
7399 (setq header "subject"))
7400 (when (not (equal "" subject))
7402 (let ((articles (gnus-summary-find-matching
7403 (or header "subject") subject 'all nil nil
7406 (error "Found no matches for \"%s\"" subject))
7407 (gnus-summary-limit articles))
7408 (gnus-summary-position-point))))
7410 (defun gnus-summary-limit-to-author (from &optional not-matching)
7411 "Limit the summary buffer to articles that have authors that match a regexp.
7412 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7414 (list (read-string (if current-prefix-arg
7415 "Exclude author (regexp): "
7416 "Limit to author (regexp): "))
7417 current-prefix-arg))
7418 (gnus-summary-limit-to-subject from "from" not-matching))
7420 (defun gnus-summary-limit-to-age (age &optional younger-p)
7421 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7422 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7423 articles that are younger than AGE days."
7425 (let ((younger current-prefix-arg)
7428 (while (not days-got)
7429 (setq days (if younger
7430 (read-string "Limit to articles younger than (in days, older when negative): ")
7432 "Limit to articles older than (in days, younger when negative): ")))
7433 (when (> (length days) 0)
7434 (setq days (read days)))
7440 (setq younger (not younger))
7441 (setq days (* days -1)))))
7442 (message "Please enter a number.")
7444 (list days younger)))
7446 (let ((data gnus-newsgroup-data)
7447 (cutoff (days-to-time age))
7448 articles d date is-younger)
7449 (while (setq d (pop data))
7450 (when (and (vectorp (gnus-data-header d))
7451 (setq date (mail-header-date (gnus-data-header d))))
7452 (setq is-younger (time-less-p
7453 (time-since (condition-case ()
7460 (push (gnus-data-number d) articles))))
7461 (gnus-summary-limit (nreverse articles)))
7462 (gnus-summary-position-point)))
7464 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7465 "Limit the summary buffer to articles that match an 'extra' header."
7469 (gnus-completing-read-with-default
7470 (symbol-name (car gnus-extra-headers))
7471 (if current-prefix-arg
7472 "Exclude extra header:"
7473 "Limit extra header:")
7475 (cons (symbol-name x) x))
7480 (read-string (format "%s header %s (regexp): "
7481 (if current-prefix-arg "Exclude" "Limit to")
7483 current-prefix-arg)))
7484 (when (not (equal "" regexp))
7486 (let ((articles (gnus-summary-find-matching
7487 (cons 'extra header) regexp 'all nil nil
7490 (error "Found no matches for \"%s\"" regexp))
7491 (gnus-summary-limit articles))
7492 (gnus-summary-position-point))))
7494 (defun gnus-summary-limit-to-display-predicate ()
7495 "Limit the summary buffer to the predicated in the `display' group parameter."
7497 (unless gnus-newsgroup-display
7498 (error "There is no `display' group parameter"))
7500 (dolist (number gnus-newsgroup-articles)
7501 (when (funcall gnus-newsgroup-display)
7502 (push number articles)))
7503 (gnus-summary-limit articles))
7504 (gnus-summary-position-point))
7506 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7508 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7510 (defun gnus-summary-limit-to-unread (&optional all)
7511 "Limit the summary buffer to articles that are not marked as read.
7512 If ALL is non-nil, limit strictly to unread articles."
7515 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7516 (gnus-summary-limit-to-marks
7517 ;; Concat all the marks that say that an article is read and have
7519 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7520 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7521 gnus-low-score-mark gnus-expirable-mark
7522 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7523 gnus-duplicate-mark gnus-souped-mark)
7526 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7527 (make-obsolete 'gnus-summary-delete-marked-with
7528 'gnus-summary-limit-exclude-marks)
7530 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7531 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7532 If REVERSE, limit the summary buffer to articles that are marked
7533 with MARKS. MARKS can either be a string of marks or a list of marks.
7534 Returns how many articles were removed."
7535 (interactive "sMarks: ")
7536 (gnus-summary-limit-to-marks marks t))
7538 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7539 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7540 If REVERSE (the prefix), limit the summary buffer to articles that are
7541 not marked with MARKS. MARKS can either be a string of marks or a
7543 Returns how many articles were removed."
7544 (interactive "sMarks: \nP")
7546 (let ((data gnus-newsgroup-data)
7547 (marks (if (listp marks) marks
7548 (append marks nil))) ; Transform to list.
7551 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7552 (memq (gnus-data-mark (car data)) marks))
7553 (push (gnus-data-number (car data)) articles))
7554 (setq data (cdr data)))
7555 (gnus-summary-limit articles))
7556 (gnus-summary-position-point)))
7558 (defun gnus-summary-limit-to-score (score)
7559 "Limit to articles with score at or above SCORE."
7560 (interactive "NLimit to articles with score of at least: ")
7561 (let ((data gnus-newsgroup-data)
7564 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7566 (push (gnus-data-number (car data)) articles))
7567 (setq data (cdr data)))
7569 (gnus-summary-limit articles)
7570 (gnus-summary-position-point))))
7572 (defun gnus-summary-limit-to-unseen ()
7573 "Limit to unseen articles."
7576 (gnus-summary-limit gnus-newsgroup-unseen)
7577 (gnus-summary-position-point)))
7579 (defun gnus-summary-limit-include-thread (id)
7580 "Display all the hidden articles that is in the thread with ID in it.
7581 When called interactively, ID is the Message-ID of the current
7583 (interactive (list (mail-header-id (gnus-summary-article-header))))
7584 (let ((articles (gnus-articles-in-thread
7585 (gnus-id-to-thread (gnus-root-id id)))))
7587 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7588 (gnus-summary-limit-include-matching-articles
7590 (regexp-quote (gnus-simplify-subject-re
7591 (mail-header-subject (gnus-id-to-header id)))))
7592 (gnus-summary-position-point))))
7594 (defun gnus-summary-limit-include-matching-articles (header regexp)
7595 "Display all the hidden articles that have HEADERs that match REGEXP."
7596 (interactive (list (read-string "Match on header: ")
7597 (read-string "Regexp: ")))
7598 (let ((articles (gnus-find-matching-articles header regexp)))
7600 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7601 (gnus-summary-position-point))))
7603 (defun gnus-summary-insert-dormant-articles ()
7604 "Insert all the dormat articles for this group into the current buffer."
7606 (let ((gnus-verbose (max 6 gnus-verbose)))
7607 (if (not gnus-newsgroup-dormant)
7608 (gnus-message 3 "No cached articles for this group")
7609 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7611 (defun gnus-summary-limit-include-dormant ()
7612 "Display all the hidden articles that are marked as dormant.
7613 Note that this command only works on a subset of the articles currently
7614 fetched for this group."
7616 (unless gnus-newsgroup-dormant
7617 (error "There are no dormant articles in this group"))
7619 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7620 (gnus-summary-position-point)))
7622 (defun gnus-summary-limit-exclude-dormant ()
7623 "Hide all dormant articles."
7626 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7627 (gnus-summary-position-point)))
7629 (defun gnus-summary-limit-exclude-childless-dormant ()
7630 "Hide all dormant articles that have no children."
7632 (let ((data (gnus-data-list t))
7633 articles d children)
7634 ;; Find all articles that are either not dormant or have
7636 (while (setq d (pop data))
7637 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7639 (gnus-article-children (gnus-data-number d)))
7642 (when (memq (car children) articles)
7647 (push (gnus-data-number d) articles)))
7650 (gnus-summary-limit articles)
7651 (gnus-summary-position-point))))
7653 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7654 "Mark all unread excluded articles as read.
7655 If ALL, mark even excluded ticked and dormants as read."
7657 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7658 (let ((articles (gnus-sorted-ndifference
7660 (mapcar (lambda (h) (mail-header-number h))
7661 gnus-newsgroup-headers)
7663 gnus-newsgroup-limit))
7665 (setq gnus-newsgroup-unreads
7666 (gnus-sorted-intersection gnus-newsgroup-unreads
7667 gnus-newsgroup-limit))
7669 (setq gnus-newsgroup-dormant nil
7670 gnus-newsgroup-marked nil
7671 gnus-newsgroup-reads
7673 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7674 gnus-newsgroup-reads))
7675 (while (setq article (pop articles))
7676 (unless (or (memq article gnus-newsgroup-dormant)
7677 (memq article gnus-newsgroup-marked))
7678 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7680 (defun gnus-summary-limit (articles &optional pop)
7682 ;; We pop the previous limit off the stack and use that.
7683 (setq articles (car gnus-newsgroup-limits)
7684 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7685 ;; We use the new limit, so we push the old limit on the stack.
7686 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7688 (setq gnus-newsgroup-limit articles)
7689 (let ((total (length gnus-newsgroup-data))
7690 (data (gnus-data-find-list (gnus-summary-article-number)))
7691 (gnus-summary-mark-below nil) ; Inhibit this.
7693 ;; This will do all the work of generating the new summary buffer
7694 ;; according to the new limit.
7695 (gnus-summary-prepare)
7696 ;; Hide any threads, possibly.
7697 (gnus-summary-maybe-hide-threads)
7698 ;; Try to return to the article you were at, or one in the
7701 ;; We try to find some article after the current one.
7703 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7706 (setq data (cdr data))))
7708 ;; If there is no data, that means that we were after the last
7709 ;; article. The same goes when we can't find any articles
7710 ;; after the current one.
7711 (goto-char (point-max))
7712 (gnus-summary-find-prev))
7713 (gnus-set-mode-line 'summary)
7714 ;; We return how many articles were removed from the summary
7715 ;; buffer as a result of the new limit.
7716 (- total (length gnus-newsgroup-data))))
7718 (defsubst gnus-invisible-cut-children (threads)
7721 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7726 (defsubst gnus-cut-thread (thread)
7727 "Go forwards in the thread until we find an article that we want to display."
7728 (when (or (eq gnus-fetch-old-headers 'some)
7729 (eq gnus-fetch-old-headers 'invisible)
7730 (numberp gnus-fetch-old-headers)
7731 (eq gnus-build-sparse-threads 'some)
7732 (eq gnus-build-sparse-threads 'more))
7733 ;; Deal with old-fetched headers and sparse threads.
7737 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7738 (gnus-summary-article-ancient-p
7739 (mail-header-number (car thread))))
7740 (if (or (<= (length (cdr thread)) 1)
7741 (eq gnus-fetch-old-headers 'invisible))
7742 (setq gnus-newsgroup-limit
7743 (delq (mail-header-number (car thread))
7744 gnus-newsgroup-limit)
7745 thread (cadr thread))
7746 (when (gnus-invisible-cut-children (cdr thread))
7747 (let ((th (cdr thread)))
7749 (if (memq (mail-header-number (caar th))
7750 gnus-newsgroup-limit)
7751 (setq thread (car th)
7753 (setq th (cdr th))))))))))
7756 (defun gnus-cut-threads (threads)
7757 "Cut off all uninteresting articles from the beginning of threads."
7758 (when (or (eq gnus-fetch-old-headers 'some)
7759 (eq gnus-fetch-old-headers 'invisible)
7760 (numberp gnus-fetch-old-headers)
7761 (eq gnus-build-sparse-threads 'some)
7762 (eq gnus-build-sparse-threads 'more))
7765 (setcar th (gnus-cut-thread (car th)))
7766 (setq th (cdr th)))))
7767 ;; Remove nixed out threads.
7770 (defun gnus-summary-initial-limit (&optional show-if-empty)
7771 "Figure out what the initial limit is supposed to be on group entry.
7772 This entails weeding out unwanted dormants, low-scored articles,
7773 fetch-old-headers verbiage, and so on."
7774 ;; Most groups have nothing to remove.
7775 (if (or gnus-inhibit-limiting
7776 (and (null gnus-newsgroup-dormant)
7777 (eq gnus-newsgroup-display 'gnus-not-ignore)
7778 (not (eq gnus-fetch-old-headers 'some))
7779 (not (numberp gnus-fetch-old-headers))
7780 (not (eq gnus-fetch-old-headers 'invisible))
7781 (null gnus-summary-expunge-below)
7782 (not (eq gnus-build-sparse-threads 'some))
7783 (not (eq gnus-build-sparse-threads 'more))
7784 (null gnus-thread-expunge-below)
7785 (not gnus-use-nocem)))
7787 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7788 (setq gnus-newsgroup-limit nil)
7791 (unless (car (symbol-value node))
7792 ;; These threads have no parents -- they are roots.
7793 (let ((nodes (cdr (symbol-value node)))
7796 (if (and gnus-thread-expunge-below
7797 (< (gnus-thread-total-score (car nodes))
7798 gnus-thread-expunge-below))
7799 (gnus-expunge-thread (pop nodes))
7800 (setq thread (pop nodes))
7801 (gnus-summary-limit-children thread))))))
7802 gnus-newsgroup-dependencies)
7803 ;; If this limitation resulted in an empty group, we might
7804 ;; pop the previous limit and use it instead.
7805 (when (and (not gnus-newsgroup-limit)
7807 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7808 gnus-newsgroup-limit))
7810 (defun gnus-summary-limit-children (thread)
7811 "Return 1 if this subthread is visible and 0 if it is not."
7812 ;; First we get the number of visible children to this thread. This
7813 ;; is done by recursing down the thread using this function, so this
7814 ;; will really go down to a leaf article first, before slowly
7815 ;; working its way up towards the root.
7817 (let* ((max-lisp-eval-depth 5000)
7820 (apply '+ (mapcar 'gnus-summary-limit-children
7823 (number (mail-header-number (car thread)))
7826 (not (memq number gnus-newsgroup-marked))
7828 ;; If this article is dormant and has absolutely no visible
7829 ;; children, then this article isn't visible.
7830 (and (memq number gnus-newsgroup-dormant)
7832 ;; If this is "fetch-old-headered" and there is no
7833 ;; visible children, then we don't want this article.
7834 (and (or (eq gnus-fetch-old-headers 'some)
7835 (numberp gnus-fetch-old-headers))
7836 (gnus-summary-article-ancient-p number)
7838 ;; If this is "fetch-old-headered" and `invisible', then
7839 ;; we don't want this article.
7840 (and (eq gnus-fetch-old-headers 'invisible)
7841 (gnus-summary-article-ancient-p number))
7842 ;; If this is a sparsely inserted article with no children,
7843 ;; we don't want it.
7844 (and (eq gnus-build-sparse-threads 'some)
7845 (gnus-summary-article-sparse-p number)
7847 ;; If we use expunging, and this article is really
7848 ;; low-scored, then we don't want this article.
7849 (when (and gnus-summary-expunge-below
7851 (or (cdr (assq number gnus-newsgroup-scored))
7852 gnus-summary-default-score))
7853 gnus-summary-expunge-below))
7854 ;; We increase the expunge-tally here, but that has
7855 ;; nothing to do with the limits, really.
7856 (incf gnus-newsgroup-expunged-tally)
7857 ;; We also mark as read here, if that's wanted.
7858 (when (and gnus-summary-mark-below
7859 (< score gnus-summary-mark-below))
7860 (setq gnus-newsgroup-unreads
7861 (delq number gnus-newsgroup-unreads))
7862 (if gnus-newsgroup-auto-expire
7863 (push number gnus-newsgroup-expirable)
7864 (push (cons number gnus-low-score-mark)
7865 gnus-newsgroup-reads)))
7867 ;; Do the `display' group parameter.
7868 (and gnus-newsgroup-display
7869 (not (funcall gnus-newsgroup-display)))
7870 ;; Check NoCeM things.
7871 (if (and gnus-use-nocem
7872 (gnus-nocem-unwanted-article-p
7873 (mail-header-id (car thread))))
7875 (setq gnus-newsgroup-unreads
7876 (delq number gnus-newsgroup-unreads))
7878 ;; Nope, invisible article.
7880 ;; Ok, this article is to be visible, so we add it to the limit
7882 (push number gnus-newsgroup-limit)
7885 (defun gnus-expunge-thread (thread)
7886 "Mark all articles in THREAD as read."
7887 (let* ((number (mail-header-number (car thread))))
7888 (incf gnus-newsgroup-expunged-tally)
7889 ;; We also mark as read here, if that's wanted.
7890 (setq gnus-newsgroup-unreads
7891 (delq number gnus-newsgroup-unreads))
7892 (if gnus-newsgroup-auto-expire
7893 (push number gnus-newsgroup-expirable)
7894 (push (cons number gnus-low-score-mark)
7895 gnus-newsgroup-reads)))
7896 ;; Go recursively through all subthreads.
7897 (mapcar 'gnus-expunge-thread (cdr thread)))
7899 ;; Summary article oriented commands
7901 (defun gnus-summary-refer-parent-article (n)
7902 "Refer parent article N times.
7903 If N is negative, go to ancestor -N instead.
7904 The difference between N and the number of articles fetched is returned."
7908 (when (not (natnump n))
7913 (setq header (gnus-summary-article-header))
7914 (if (and (eq (mail-header-number header)
7915 (cdr gnus-article-current))
7916 (equal gnus-newsgroup-name
7917 (car gnus-article-current)))
7918 ;; If we try to find the parent of the currently
7919 ;; displayed article, then we take a look at the actual
7920 ;; References header, since this is slightly more
7921 ;; reliable than the References field we got from the
7924 (set-buffer gnus-original-article-buffer)
7925 (nnheader-narrow-to-headers)
7926 (unless (setq ref (message-fetch-field "references"))
7927 (setq ref (message-fetch-field "in-reply-to")))
7930 ;; It's not the current article, so we take a bet on
7931 ;; the value we got from the server.
7932 (mail-header-references header)))
7934 (not (equal ref "")))
7935 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7936 (gnus-message 1 "Couldn't find parent"))
7937 (gnus-message 1 "No references in article %d"
7938 (gnus-summary-article-number))
7941 (gnus-summary-position-point)
7944 (defun gnus-summary-refer-references ()
7945 "Fetch all articles mentioned in the References header.
7946 Return the number of articles fetched."
7948 (let ((ref (mail-header-references (gnus-summary-article-header)))
7949 (current (gnus-summary-article-number))
7953 (error "No References in the current article")
7954 ;; For each Message-ID in the References header...
7955 (while (string-match "<[^>]*>" ref)
7957 ;; ... fetch that article.
7958 (gnus-summary-refer-article
7959 (prog1 (match-string 0 ref)
7960 (setq ref (substring ref (match-end 0))))))
7961 (gnus-summary-goto-subject current)
7962 (gnus-summary-position-point)
7965 (defun gnus-summary-refer-thread (&optional limit)
7966 "Fetch all articles in the current thread.
7967 If LIMIT (the numerical prefix), fetch that many old headers instead
7968 of what's specified by the `gnus-refer-thread-limit' variable."
7970 (let ((id (mail-header-id (gnus-summary-article-header)))
7971 (limit (if limit (prefix-numeric-value limit)
7972 gnus-refer-thread-limit)))
7973 (unless (eq gnus-fetch-old-headers 'invisible)
7974 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7975 ;; Retrieve the headers and read them in.
7976 (if (eq (if (numberp limit)
7977 (gnus-retrieve-headers
7979 (+ (mail-header-number
7980 (gnus-summary-article-header))
7982 gnus-newsgroup-end))
7983 gnus-newsgroup-name (* limit 2))
7984 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
7986 (gnus-retrieve-headers (list gnus-newsgroup-end)
7987 gnus-newsgroup-name limit))
7989 (gnus-build-all-threads)
7990 (error "Can't fetch thread from backends that don't support NOV"))
7991 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7992 (gnus-summary-limit-include-thread id)))
7994 (defun gnus-summary-refer-article (message-id)
7995 "Fetch an article specified by MESSAGE-ID."
7996 (interactive "sMessage-ID: ")
7997 (when (and (stringp message-id)
7998 (not (zerop (length message-id))))
7999 ;; Construct the correct Message-ID if necessary.
8000 ;; Suggested by tale@pawl.rpi.edu.
8001 (unless (string-match "^<" message-id)
8002 (setq message-id (concat "<" message-id)))
8003 (unless (string-match ">$" message-id)
8004 (setq message-id (concat message-id ">")))
8005 (let* ((header (gnus-id-to-header message-id))
8007 (gnus-summary-article-sparse-p
8008 (mail-header-number header))
8009 (memq (mail-header-number header)
8010 gnus-newsgroup-limit)))
8013 ;; If the article is present in the buffer we just go to it.
8015 (or (not (gnus-summary-article-sparse-p
8016 (mail-header-number header)))
8019 (gnus-summary-goto-article
8020 (mail-header-number header) nil t)
8022 (gnus-summary-update-article (mail-header-number header)))))
8024 ;; We fetch the article.
8026 (dolist (gnus-override-method (gnus-refer-article-methods))
8027 (gnus-check-server gnus-override-method)
8028 ;; Fetch the header, and display the article.
8029 (when (setq number (gnus-summary-insert-subject message-id))
8030 (gnus-summary-select-article nil nil nil number)
8032 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8034 (defun gnus-refer-article-methods ()
8035 "Return a list of referable methods."
8037 ;; No method, so we default to current and native.
8038 ((null gnus-refer-article-method)
8039 (list gnus-current-select-method gnus-select-method))
8041 ((eq 'current gnus-refer-article-method)
8042 (list gnus-current-select-method))
8043 ;; List of select methods.
8044 ((not (and (symbolp (car gnus-refer-article-method))
8045 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8047 (dolist (method gnus-refer-article-method)
8048 (push (if (eq 'current method)
8049 gnus-current-select-method
8053 ;; One single select method.
8055 (list gnus-refer-article-method))))
8057 (defun gnus-summary-edit-parameters ()
8058 "Edit the group parameters of the current group."
8060 (gnus-group-edit-group gnus-newsgroup-name 'params))
8062 (defun gnus-summary-customize-parameters ()
8063 "Customize the group parameters of the current group."
8065 (gnus-group-customize gnus-newsgroup-name))
8067 (defun gnus-summary-enter-digest-group (&optional force)
8068 "Enter an nndoc group based on the current article.
8069 If FORCE, force a digest interpretation. If not, try
8070 to guess what the document format is."
8072 (let ((conf gnus-current-window-configuration))
8074 (gnus-summary-select-article))
8075 (setq gnus-current-window-configuration conf)
8076 (let* ((name (format "%s-%d"
8077 (gnus-group-prefixed-name
8078 gnus-newsgroup-name (list 'nndoc ""))
8080 (set-buffer gnus-summary-buffer)
8081 gnus-current-article)))
8082 (ogroup gnus-newsgroup-name)
8083 (params (append (gnus-info-params (gnus-get-info ogroup))
8084 (list (cons 'to-group ogroup))
8085 (list (cons 'save-article-group ogroup))))
8086 (case-fold-search t)
8087 (buf (current-buffer))
8090 (set-buffer gnus-original-article-buffer)
8091 ;; Have the digest group inherit the main mail address of
8092 ;; the parent article.
8093 (when (setq to-address (or (gnus-fetch-field "reply-to")
8094 (gnus-fetch-field "from")))
8095 (setq params (append
8096 (list (cons 'to-address
8097 (funcall gnus-decode-encoded-word-function
8099 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8100 (insert-buffer-substring gnus-original-article-buffer)
8101 ;; Remove lines that may lead nndoc to misinterpret the
8104 (goto-char (point-min))
8105 (or (search-forward "\n\n" nil t) (point)))
8106 (goto-char (point-min))
8107 (delete-matching-lines "^Path:\\|^From ")
8110 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8111 (gnus-newsgroup-ephemeral-ignored-charsets
8112 gnus-newsgroup-ignored-charsets))
8113 (gnus-group-read-ephemeral-group
8114 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8116 ,(if force 'mbox 'guess)))
8118 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8120 ;; Make all postings to this group go to the parent group.
8121 (nconc (gnus-info-params (gnus-get-info name))
8123 ;; Couldn't select this doc group.
8124 (switch-to-buffer buf)
8125 (gnus-set-global-variables)
8126 (gnus-configure-windows 'summary)
8127 (gnus-message 3 "Article couldn't be entered?"))
8128 (kill-buffer dig)))))
8130 (defun gnus-summary-read-document (n)
8131 "Open a new group based on the current article(s).
8132 This will allow you to read digests and other similar
8133 documents as newsgroups.
8134 Obeys the standard process/prefix convention."
8136 (let* ((articles (gnus-summary-work-articles n))
8137 (ogroup gnus-newsgroup-name)
8138 (params (append (gnus-info-params (gnus-get-info ogroup))
8139 (list (cons 'to-group ogroup))))
8140 article group egroup groups vgroup)
8141 (while (setq article (pop articles))
8142 (setq group (format "%s-%d" gnus-newsgroup-name article))
8143 (gnus-summary-remove-process-mark article)
8144 (when (gnus-summary-display-article article)
8147 (insert-buffer-substring gnus-original-article-buffer)
8148 ;; Remove some headers that may lead nndoc to make
8150 (message-narrow-to-head)
8151 (goto-char (point-min))
8152 (delete-matching-lines "^\\(Path\\):\\|^From ")
8155 (gnus-group-read-ephemeral-group
8156 group `(nndoc ,group (nndoc-address ,(current-buffer))
8157 (nndoc-article-type guess))
8160 ;; Make all postings to this group go to the parent group.
8161 (nconc (gnus-info-params (gnus-get-info egroup))
8163 (push egroup groups))
8164 ;; Couldn't select this doc group.
8165 (gnus-error 3 "Article couldn't be entered"))))))
8166 ;; Now we have selected all the documents.
8169 (error "None of the articles could be interpreted as documents"))
8170 ((gnus-group-read-ephemeral-group
8171 (setq vgroup (format
8172 "nnvirtual:%s-%s" gnus-newsgroup-name
8173 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8174 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8176 (cons (current-buffer) 'summary)))
8178 (error "Couldn't select virtual nndoc group")))))
8180 (defun gnus-summary-isearch-article (&optional regexp-p)
8181 "Do incremental search forward on the current article.
8182 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8184 (gnus-summary-select-article)
8185 (gnus-configure-windows 'article)
8186 (gnus-eval-in-buffer-window gnus-article-buffer
8189 (isearch-forward regexp-p))))
8191 (defun gnus-summary-search-article-forward (regexp &optional backward)
8192 "Search for an article containing REGEXP forward.
8193 If BACKWARD, search backward instead."
8196 (format "Search article %s (regexp%s): "
8197 (if current-prefix-arg "backward" "forward")
8198 (if gnus-last-search-regexp
8199 (concat ", default " gnus-last-search-regexp)
8201 current-prefix-arg))
8202 (if (string-equal regexp "")
8203 (setq regexp (or gnus-last-search-regexp ""))
8204 (setq gnus-last-search-regexp regexp)
8205 (setq gnus-article-before-search gnus-current-article))
8206 ;; Intentionally set gnus-last-article.
8207 (setq gnus-last-article gnus-article-before-search)
8208 (let ((gnus-last-article gnus-last-article))
8209 (if (gnus-summary-search-article regexp backward)
8210 (gnus-summary-show-thread)
8211 (error "Search failed: \"%s\"" regexp))))
8213 (defun gnus-summary-search-article-backward (regexp)
8214 "Search for an article containing REGEXP backward."
8217 (format "Search article backward (regexp%s): "
8218 (if gnus-last-search-regexp
8219 (concat ", default " gnus-last-search-regexp)
8221 (gnus-summary-search-article-forward regexp 'backward))
8223 (defun gnus-summary-search-article (regexp &optional backward)
8224 "Search for an article containing REGEXP.
8225 Optional argument BACKWARD means do search for backward.
8226 `gnus-select-article-hook' is not called during the search."
8227 ;; We have to require this here to make sure that the following
8228 ;; dynamic binding isn't shadowed by autoloading.
8229 (require 'gnus-async)
8231 (let ((gnus-select-article-hook nil) ;Disable hook.
8232 (gnus-article-prepare-hook nil)
8233 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8234 (gnus-use-article-prefetch nil)
8235 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8236 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8238 (gnus-keep-backlog nil)
8239 (gnus-break-pages nil)
8240 (gnus-summary-display-arrow nil)
8241 (gnus-updated-mode-lines nil)
8242 (gnus-auto-center-summary nil)
8243 (sum (current-buffer))
8244 (gnus-display-mime-function nil)
8247 (gnus-save-hidden-threads
8248 (gnus-summary-select-article)
8249 (set-buffer gnus-article-buffer)
8250 (goto-char (window-point (get-buffer-window (current-buffer))))
8254 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8256 (re-search-backward regexp nil t)
8257 (re-search-forward regexp nil t))
8258 ;; We found the regexp.
8263 (get-buffer-window (current-buffer))
8267 (get-buffer-window (current-buffer))
8270 (setq point (point)))
8271 ;; We didn't find it, so we go to the next article.
8274 (while (eq found 'not)
8275 (if (not (if backward (gnus-summary-find-prev)
8276 (gnus-summary-find-next)))
8277 ;; No more articles.
8279 ;; Select the next article and adjust point.
8280 (unless (gnus-summary-article-sparse-p
8281 (gnus-summary-article-number))
8283 (gnus-summary-select-article)
8284 (set-buffer gnus-article-buffer)
8286 (goto-char (if backward (point-max) (point-min))))))))
8287 (gnus-message 7 ""))
8288 ;; Return whether we found the regexp.
8289 (when (eq found 'found)
8291 (gnus-summary-show-thread)
8292 (gnus-summary-goto-subject gnus-current-article)
8293 (gnus-summary-position-point)
8296 (defun gnus-find-matching-articles (header regexp)
8297 "Return a list of all articles that match REGEXP on HEADER.
8298 This search includes all articles in the current group that Gnus has
8299 fetched headers for, whether they are displayed or not."
8300 (let ((articles nil)
8301 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8302 (case-fold-search t))
8303 (dolist (header gnus-newsgroup-headers)
8304 (when (string-match regexp (funcall func header))
8305 (push (mail-header-number header) articles)))
8306 (nreverse articles)))
8308 (defun gnus-summary-find-matching (header regexp &optional backward unread
8309 not-case-fold not-matching)
8310 "Return a list of all articles that match REGEXP on HEADER.
8311 The search stars on the current article and goes forwards unless
8312 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8313 If UNREAD is non-nil, only unread articles will
8314 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8315 in the comparisons. If NOT-MATCHING, return a list of all articles that
8316 not match REGEXP on HEADER."
8317 (let ((case-fold-search (not not-case-fold))
8320 (if (eq (car header) 'extra)
8323 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8325 (error "%s is an invalid header" header))
8326 (unless (fboundp (intern (concat "mail-header-" header)))
8327 (error "%s is not a valid header" header))
8328 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8329 (dolist (d (if (eq backward 'all)
8331 (gnus-data-find-list
8332 (gnus-summary-article-number)
8333 (gnus-data-list backward))))
8334 (when (and (or (not unread) ; We want all articles...
8335 (gnus-data-unread-p d)) ; Or just unreads.
8336 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8340 (funcall func (gnus-data-header d))))
8341 (string-match regexp
8342 (funcall func (gnus-data-header d)))))
8343 (push (gnus-data-number d) articles))) ; Success!
8344 (nreverse articles)))
8346 (defun gnus-summary-execute-command (header regexp command &optional backward)
8347 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8348 If HEADER is an empty string (or nil), the match is done on the entire
8349 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8351 (list (let ((completion-ignore-case t))
8354 (mapcar (lambda (header) (list (format "%s" header)))
8356 '("Number" "Subject" "From" "Lines" "Date"
8357 "Message-ID" "Xref" "References" "Body")
8358 gnus-extra-headers))
8359 nil 'require-match))
8360 (read-string "Regexp: ")
8361 (read-key-sequence "Command: ")
8362 current-prefix-arg))
8363 (when (equal header "Body")
8365 ;; Hidden thread subtrees must be searched as well.
8366 (gnus-summary-show-all-threads)
8367 ;; We don't want to change current point nor window configuration.
8369 (save-window-excursion
8371 gnus-treat-strip-trailing-blank-lines
8372 gnus-treat-strip-leading-blank-lines
8373 gnus-treat-strip-multiple-blank-lines
8374 gnus-treat-hide-boring-headers
8375 gnus-treat-fold-newsgroups
8376 gnus-article-prepare-hook)
8377 (gnus-message 6 "Executing %s..." (key-description command))
8378 ;; We'd like to execute COMMAND interactively so as to give arguments.
8379 (gnus-execute header regexp
8380 `(call-interactively ',(key-binding command))
8382 (gnus-message 6 "Executing %s...done" (key-description command))))))
8384 (defun gnus-summary-beginning-of-article ()
8385 "Scroll the article back to the beginning."
8387 (gnus-summary-select-article)
8388 (gnus-configure-windows 'article)
8389 (gnus-eval-in-buffer-window gnus-article-buffer
8391 (goto-char (point-min))
8392 (when gnus-page-broken
8393 (gnus-narrow-to-page))))
8395 (defun gnus-summary-end-of-article ()
8396 "Scroll to the end of the article."
8398 (gnus-summary-select-article)
8399 (gnus-configure-windows 'article)
8400 (gnus-eval-in-buffer-window gnus-article-buffer
8402 (goto-char (point-max))
8404 (when gnus-page-broken
8405 (gnus-narrow-to-page))))
8407 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8408 "Truncate to LEN and quote all \"(\"'s in STRING."
8409 (gnus-replace-in-string (if (and len (> (length string) len))
8410 (substring string 0 len)
8414 (defun gnus-summary-print-article (&optional filename n)
8415 "Generate and print a PostScript image of the N next (mail) articles.
8417 If N is negative, print the N previous articles. If N is nil and articles
8418 have been marked with the process mark, print these instead.
8420 If the optional first argument FILENAME is nil, send the image to the
8421 printer. If FILENAME is a string, save the PostScript image in a file with
8422 that name. If FILENAME is a number, prompt the user for the name of the file
8424 (interactive (list (ps-print-preprint current-prefix-arg)))
8425 (dolist (article (gnus-summary-work-articles n))
8426 (gnus-summary-select-article nil nil 'pseudo article)
8427 (gnus-eval-in-buffer-window gnus-article-buffer
8428 (gnus-print-buffer))
8429 (gnus-summary-remove-process-mark article))
8430 (ps-despool filename))
8432 (defun gnus-print-buffer ()
8433 (let ((buffer (generate-new-buffer " *print*")))
8436 (copy-to-buffer buffer (point-min) (point-max))
8438 (gnus-article-delete-invisible-text)
8439 (gnus-remove-text-with-property 'gnus-decoration)
8440 (when (gnus-visual-p 'article-highlight 'highlight)
8441 ;; Copy-to-buffer doesn't copy overlay. So redo
8443 (let ((gnus-article-buffer buffer))
8444 (gnus-article-highlight-citation t)
8445 (gnus-article-highlight-signature)))
8446 (let ((ps-left-header
8449 (gnus-summary-print-truncate-and-quote
8450 (mail-header-subject gnus-current-headers)
8453 (gnus-summary-print-truncate-and-quote
8454 (mail-header-from gnus-current-headers)
8458 "/pagenumberstring load"
8460 (mail-header-date gnus-current-headers) ")"))))
8461 (gnus-run-hooks 'gnus-ps-print-hook)
8464 (ps-spool-buffer-with-faces)
8465 (ps-spool-buffer)))))
8466 (kill-buffer buffer))))
8468 (defun gnus-summary-show-article (&optional arg)
8469 "Force redisplaying of the current article.
8470 If ARG (the prefix) is a number, show the article with the charset
8471 defined in `gnus-summary-show-article-charset-alist', or the charset
8473 If ARG (the prefix) is non-nil and not a number, show the raw article
8474 without any article massaging functions being run. Normally, the key strokes
8479 (gnus-summary-show-article t)
8480 (let ((gnus-newsgroup-charset
8481 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8482 (mm-read-coding-system
8483 "View as charset: " ;; actually it is coding system.
8485 (set-buffer gnus-article-buffer)
8486 (mm-detect-coding-region (point) (point-max))))))
8487 (gnus-newsgroup-ignored-charsets 'gnus-all))
8488 (gnus-summary-select-article nil 'force)
8489 (let ((deps gnus-newsgroup-dependencies)
8492 (set-buffer gnus-original-article-buffer)
8494 (message-narrow-to-head)
8495 (setq head (buffer-string))
8496 (goto-char (point-min))
8497 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8498 (goto-char (point-max))
8500 (setq lines (1- (count-lines (point) (point-max))))))
8502 (insert (format "211 %d Article retrieved.\n"
8503 (cdr gnus-article-current)))
8505 (if lines (insert (format "Lines: %d\n" lines)))
8507 (let ((nntp-server-buffer (current-buffer)))
8508 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8509 (gnus-data-set-header
8510 (gnus-data-find (cdr gnus-article-current))
8512 (gnus-summary-update-article-line
8513 (cdr gnus-article-current) header)
8514 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8515 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8517 ;; Select the article the normal way.
8518 (gnus-summary-select-article nil 'force))
8520 ;; We have to require this here to make sure that the following
8521 ;; dynamic binding isn't shadowed by autoloading.
8522 (require 'gnus-async)
8524 ;; Bind the article treatment functions to nil.
8525 (let ((gnus-have-all-headers t)
8526 gnus-article-prepare-hook
8527 gnus-article-decode-hook
8528 gnus-display-mime-function
8530 ;; Destroy any MIME parts.
8531 (when (gnus-buffer-live-p gnus-article-buffer)
8533 (set-buffer gnus-article-buffer)
8534 (mm-destroy-parts gnus-article-mime-handles)
8535 ;; Set it to nil for safety reason.
8536 (setq gnus-article-mime-handle-alist nil)
8537 (setq gnus-article-mime-handles nil)))
8538 (gnus-summary-select-article nil 'force))))
8539 (gnus-summary-goto-subject gnus-current-article)
8540 (gnus-summary-position-point))
8542 (defun gnus-summary-show-raw-article ()
8543 "Show the raw article without any article massaging functions being run."
8545 (gnus-summary-show-article t))
8547 (defun gnus-summary-verbose-headers (&optional arg)
8548 "Toggle permanent full header display.
8549 If ARG is a positive number, turn header display on.
8550 If ARG is a negative number, turn header display off."
8552 (setq gnus-show-all-headers
8553 (cond ((or (not (numberp arg))
8555 (not gnus-show-all-headers))
8558 (gnus-summary-show-article))
8560 (defun gnus-summary-toggle-header (&optional arg)
8561 "Show the headers if they are hidden, or hide them if they are shown.
8562 If ARG is a positive number, show the entire header.
8563 If ARG is a negative number, hide the unwanted header lines."
8565 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8566 (get-buffer-window gnus-article-buffer t))))
8567 (with-current-buffer gnus-article-buffer
8569 (article-narrow-to-head)
8570 (let* ((buffer-read-only nil)
8571 (inhibit-point-motion-hooks t)
8572 (hidden (if (numberp arg)
8574 (gnus-article-hidden-text-p 'headers)))
8576 (delete-region (point-min) (point-max))
8577 (with-current-buffer gnus-original-article-buffer
8578 (goto-char (setq s (point-min)))
8579 (setq e (if (search-forward "\n\n" nil t)
8582 (insert-buffer-substring gnus-original-article-buffer s e)
8583 (article-decode-encoded-words)
8585 (let ((gnus-treat-hide-headers nil)
8586 (gnus-treat-hide-boring-headers nil))
8587 (gnus-delete-wash-type 'headers)
8588 (gnus-treat-article 'head))
8589 (gnus-treat-article 'head))
8592 (set-window-start window (goto-char (point-min))))
8593 (setq gnus-page-broken
8594 (when gnus-break-pages
8595 (gnus-narrow-to-page)
8597 (gnus-set-mode-line 'article)))))
8599 (defun gnus-summary-show-all-headers ()
8600 "Make all header lines visible."
8602 (gnus-summary-toggle-header 1))
8604 (defun gnus-summary-caesar-message (&optional arg)
8605 "Caesar rotate the current article by 13.
8606 The numerical prefix specifies how many places to rotate each letter
8609 (gnus-summary-select-article)
8610 (let ((mail-header-separator ""))
8611 (gnus-eval-in-buffer-window gnus-article-buffer
8614 (let ((start (window-start))
8616 (message-caesar-buffer-body arg)
8617 (set-window-start (get-buffer-window (current-buffer)) start))))))
8619 (autoload 'unmorse-region "morse"
8620 "Convert morse coded text in region to ordinary ASCII text."
8623 (defun gnus-summary-morse-message (&optional arg)
8624 "Morse decode the current article."
8626 (gnus-summary-select-article)
8627 (let ((mail-header-separator ""))
8628 (gnus-eval-in-buffer-window gnus-article-buffer
8632 (let ((pos (window-start))
8634 (goto-char (point-min))
8635 (when (message-goto-body)
8636 (gnus-narrow-to-body))
8637 (goto-char (point-min))
8638 (while (re-search-forward "·" (point-max) t)
8639 (replace-match "."))
8640 (unmorse-region (point-min) (point-max))
8642 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8644 (defun gnus-summary-stop-page-breaking ()
8645 "Stop page breaking in the current article."
8647 (gnus-summary-select-article)
8648 (gnus-eval-in-buffer-window gnus-article-buffer
8650 (when (gnus-visual-p 'page-marker)
8651 (let ((buffer-read-only nil))
8652 (gnus-remove-text-with-property 'gnus-prev)
8653 (gnus-remove-text-with-property 'gnus-next))
8654 (setq gnus-page-broken nil))))
8656 (defun gnus-summary-move-article (&optional n to-newsgroup
8657 select-method action)
8658 "Move the current article to a different newsgroup.
8659 If N is a positive number, move the N next articles.
8660 If N is a negative number, move the N previous articles.
8661 If N is nil and any articles have been marked with the process mark,
8662 move those articles instead.
8663 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8664 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8665 re-spool using this method.
8667 When called interactively with TO-NEWSGROUP being nil, the value of
8668 the variable `gnus-move-split-methods' is used for finding a default
8669 for the target newsgroup.
8671 For this function to work, both the current newsgroup and the
8672 newsgroup that you want to move to have to support the `request-move'
8673 and `request-accept' functions.
8675 ACTION can be either `move' (the default), `crosspost' or `copy'."
8678 (setq action 'move))
8679 ;; Check whether the source group supports the required functions.
8680 (cond ((and (eq action 'move)
8681 (not (gnus-check-backend-function
8682 'request-move-article gnus-newsgroup-name)))
8683 (error "The current group does not support article moving"))
8684 ((and (eq action 'crosspost)
8685 (not (gnus-check-backend-function
8686 'request-replace-article gnus-newsgroup-name)))
8687 (error "The current group does not support article editing")))
8688 (let ((articles (gnus-summary-work-articles n))
8689 (prefix (if (gnus-check-backend-function
8690 'request-move-article gnus-newsgroup-name)
8691 (gnus-group-real-prefix gnus-newsgroup-name)
8693 (names '((move "Move" "Moving")
8694 (copy "Copy" "Copying")
8695 (crosspost "Crosspost" "Crossposting")))
8696 (copy-buf (save-excursion
8697 (nnheader-set-temp-buffer " *copy article*")))
8698 art-group to-method new-xref article to-groups)
8699 (unless (assq action names)
8700 (error "Unknown action %s" action))
8701 ;; Read the newsgroup name.
8702 (when (and (not to-newsgroup)
8703 (not select-method))
8704 (if (and gnus-move-split-methods
8706 (and (memq gnus-current-article articles)
8707 (gnus-buffer-live-p gnus-original-article-buffer))))
8708 ;; When `gnus-move-split-methods' is non-nil, we have to
8709 ;; select an article to give `gnus-read-move-group-name' an
8710 ;; opportunity to suggest an appropriate default. However,
8711 ;; we needn't render or mark the article.
8712 (let ((gnus-display-mime-function nil)
8713 (gnus-article-prepare-hook nil)
8714 (gnus-mark-article-hook nil))
8715 (gnus-summary-select-article nil nil nil (car articles))))
8717 (gnus-read-move-group-name
8718 (cadr (assq action names))
8719 (symbol-value (intern (format "gnus-current-%s-group" action)))
8721 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8722 (setq to-method (or select-method
8723 (gnus-server-to-method
8724 (gnus-group-method to-newsgroup))))
8725 ;; Check the method we are to move this article to...
8726 (unless (gnus-check-backend-function
8727 'request-accept-article (car to-method))
8728 (error "%s does not support article copying" (car to-method)))
8729 (unless (gnus-check-server to-method)
8730 (error "Can't open server %s" (car to-method)))
8731 (gnus-message 6 "%s to %s: %s..."
8732 (caddr (assq action names))
8733 (or (car select-method) to-newsgroup) articles)
8735 (setq article (pop articles))
8739 ;; Move the article.
8741 ;; Remove this article from future suppression.
8742 (gnus-dup-unsuppress-article article)
8743 (gnus-request-move-article
8744 article ; Article to move
8745 gnus-newsgroup-name ; From newsgroup
8746 (nth 1 (gnus-find-method-for-group
8747 gnus-newsgroup-name)) ; Server
8748 (list 'gnus-request-accept-article
8749 to-newsgroup (list 'quote select-method)
8750 (not articles) t) ; Accept form
8751 (not articles))) ; Only save nov last time
8752 ;; Copy the article.
8755 (set-buffer copy-buf)
8756 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8757 (gnus-request-accept-article
8758 to-newsgroup select-method (not articles) t))))
8759 ;; Crosspost the article.
8760 ((eq action 'crosspost)
8761 (let ((xref (message-tokenize-header
8762 (mail-header-xref (gnus-summary-article-header article))
8764 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8765 ":" (number-to-string article)))
8767 (setq xref (list (system-name))))
8770 (mapconcat 'identity
8771 (delete "Xref:" (delete new-xref xref))
8775 (set-buffer copy-buf)
8776 ;; First put the article in the destination group.
8777 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8778 (when (consp (setq art-group
8779 (gnus-request-accept-article
8780 to-newsgroup select-method (not articles))))
8781 (setq new-xref (concat new-xref " " (car art-group)
8783 (number-to-string (cdr art-group))))
8784 ;; Now we have the new Xrefs header, so we insert
8785 ;; it and replace the new article.
8786 (nnheader-replace-header "Xref" new-xref)
8787 (gnus-request-replace-article
8788 (cdr art-group) to-newsgroup (current-buffer))
8792 (gnus-message 1 "Couldn't %s article %s: %s"
8793 (cadr (assq action names)) article
8794 (nnheader-get-report (car to-method))))
8795 ((eq art-group 'junk)
8796 (when (eq action 'move)
8797 (let ((id (mail-header-id (gnus-data-header
8798 (assoc article (gnus-data-list nil))))))
8799 (gnus-summary-mark-article article gnus-canceled-mark)
8800 (gnus-message 4 "Deleted article %s" article)
8801 ;; run the move/copy/crosspost/respool hook
8802 (run-hook-with-args 'gnus-summary-article-delete-hook
8803 action id gnus-newsgroup-name nil
8806 (let* ((pto-group (gnus-group-prefixed-name
8807 (car art-group) to-method))
8809 (gnus-gethash pto-group gnus-newsrc-hashtb))
8810 (info (nth 2 entry))
8811 (to-group (gnus-info-group info))
8813 ;; Update the group that has been moved to.
8815 (memq action '(move copy)))
8816 (unless (member to-group to-groups)
8817 (push to-group to-groups))
8819 (unless (memq article gnus-newsgroup-unreads)
8820 (push 'read to-marks)
8822 info (gnus-add-to-range (gnus-info-read info)
8823 (list (cdr art-group)))))
8825 ;; See whether the article is to be put in the cache.
8826 (let ((marks gnus-article-mark-lists)
8827 (to-article (cdr art-group)))
8829 ;; Enter the article into the cache in the new group,
8830 ;; if that is required.
8831 (when gnus-use-cache
8832 (gnus-cache-possibly-enter-article
8834 (memq article gnus-newsgroup-marked)
8835 (memq article gnus-newsgroup-dormant)
8836 (memq article gnus-newsgroup-unreads)))
8838 (when gnus-preserve-marks
8839 ;; Copy any marks over to the new group.
8840 (when (and (equal to-group gnus-newsgroup-name)
8841 (not (memq article gnus-newsgroup-unreads)))
8842 ;; Mark this article as read in this group.
8843 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8844 (setcdr (gnus-active to-group) to-article)
8845 (setcdr gnus-newsgroup-active to-article))
8848 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8849 (when (memq article (symbol-value
8850 (intern (format "gnus-newsgroup-%s"
8852 (push (cdar marks) to-marks)
8853 ;; If the other group is the same as this group,
8854 ;; then we have to add the mark to the list.
8855 (when (equal to-group gnus-newsgroup-name)
8856 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8859 (intern (format "gnus-newsgroup-%s"
8861 ;; Copy the marks to other group.
8862 (gnus-add-marked-articles
8863 to-group (cdar marks) (list to-article) info)))
8864 (setq marks (cdr marks)))
8866 (gnus-request-set-mark
8867 to-group (list (list (list to-article) 'add to-marks))))
8870 (concat "(gnus-group-set-info '"
8871 (gnus-prin1-to-string (gnus-get-info to-group))
8874 ;; Update the Xref header in this article to point to
8875 ;; the new crossposted article we have just created.
8876 (when (eq action 'crosspost)
8878 (set-buffer copy-buf)
8879 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8880 (nnheader-replace-header "Xref" new-xref)
8881 (gnus-request-replace-article
8882 article gnus-newsgroup-name (current-buffer))))
8884 ;; run the move/copy/crosspost/respool hook
8885 (let ((id (mail-header-id (gnus-data-header
8886 (assoc article (gnus-data-list nil))))))
8887 (run-hook-with-args 'gnus-summary-article-move-hook
8888 action id gnus-newsgroup-name to-newsgroup
8891 ;;;!!!Why is this necessary?
8892 (set-buffer gnus-summary-buffer)
8894 (gnus-summary-goto-subject article)
8895 (when (eq action 'move)
8896 (gnus-summary-mark-article article gnus-canceled-mark))))
8897 (gnus-summary-remove-process-mark article))
8898 ;; Re-activate all groups that have been moved to.
8900 (set-buffer gnus-group-buffer)
8901 (let ((gnus-group-marked to-groups))
8902 (gnus-group-get-new-news-this-group nil t)))
8904 (gnus-kill-buffer copy-buf)
8905 (gnus-summary-position-point)
8906 (gnus-set-mode-line 'summary)))
8908 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8909 "Move the current article to a different newsgroup.
8910 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8911 When called interactively, if TO-NEWSGROUP is nil, use the value of
8912 the variable `gnus-move-split-methods' for finding a default target
8914 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8915 re-spool using this method."
8917 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8919 (defun gnus-summary-crosspost-article (&optional n)
8920 "Crosspost the current article to some other group."
8922 (gnus-summary-move-article n nil nil 'crosspost))
8924 (defcustom gnus-summary-respool-default-method nil
8925 "Default method type for respooling an article.
8926 If nil, use to the current newsgroup method."
8928 :group 'gnus-summary-mail)
8930 (defcustom gnus-summary-display-while-building nil
8931 "If not-nil, show and update the summary buffer as it's being built.
8932 If the value is t, update the buffer after every line is inserted. If
8933 the value is an integer (N), update the display every N lines."
8935 :type '(choice (const :tag "off" nil)
8937 (const :tag "frequently" t)))
8939 (defun gnus-summary-respool-article (&optional n method)
8940 "Respool the current article.
8941 The article will be squeezed through the mail spooling process again,
8942 which means that it will be put in some mail newsgroup or other
8943 depending on `nnmail-split-methods'.
8944 If N is a positive number, respool the N next articles.
8945 If N is a negative number, respool the N previous articles.
8946 If N is nil and any articles have been marked with the process mark,
8947 respool those articles instead.
8949 Respooling can be done both from mail groups and \"real\" newsgroups.
8950 In the former case, the articles in question will be moved from the
8951 current group into whatever groups they are destined to. In the
8952 latter case, they will be copied into the relevant groups."
8954 (list current-prefix-arg
8955 (let* ((methods (gnus-methods-using 'respool))
8957 (symbol-name (or gnus-summary-respool-default-method
8958 (car (gnus-find-method-for-group
8959 gnus-newsgroup-name)))))
8961 (gnus-completing-read-with-default
8962 methname "What backend do you want to use when respooling?"
8963 methods nil t nil 'gnus-mail-method-history))
8966 ((zerop (length (setq ms (gnus-servers-using-backend
8968 (list (intern method) ""))
8972 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8973 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8976 (error "No method given for respooling"))
8977 (if (assoc (symbol-name
8978 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8979 (gnus-methods-using 'respool))
8980 (gnus-summary-move-article n nil method)
8981 (gnus-summary-copy-article n nil method)))
8983 (defun gnus-summary-import-article (file &optional edit)
8984 "Import an arbitrary file into a mail newsgroup."
8985 (interactive "fImport file: \nP")
8986 (let ((group gnus-newsgroup-name)
8987 (now (current-time))
8988 atts lines group-art)
8989 (unless (gnus-check-backend-function 'request-accept-article group)
8990 (error "%s does not support article importing" group))
8991 (or (file-readable-p file)
8992 (not (file-regular-p file))
8993 (error "Can't read %s" file))
8995 (set-buffer (gnus-get-buffer-create " *import file*"))
8997 (nnheader-insert-file-contents file)
8998 (goto-char (point-min))
8999 (if (nnheader-article-p)
9001 (goto-char (point-min))
9002 (search-forward "\n\n" nil t)
9003 (narrow-to-region (point-min) (1- (point)))
9004 (goto-char (point-min))
9005 (unless (re-search-forward "^date:" nil t)
9006 (goto-char (point-max))
9007 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9008 ;; This doesn't look like an article, so we fudge some headers.
9009 (setq atts (file-attributes file)
9010 lines (count-lines (point-min) (point-max)))
9011 (insert "From: " (read-string "From: ") "\n"
9012 "Subject: " (read-string "Subject: ") "\n"
9013 "Date: " (message-make-date (nth 5 atts)) "\n"
9014 "Message-ID: " (message-make-message-id) "\n"
9015 "Lines: " (int-to-string lines) "\n"
9016 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9017 (setq group-art (gnus-request-accept-article group nil t))
9018 (kill-buffer (current-buffer)))
9019 (setq gnus-newsgroup-active (gnus-activate-group group))
9021 (gnus-summary-goto-article (cdr group-art) nil t)
9023 (gnus-summary-edit-article))))
9025 (defun gnus-summary-create-article ()
9026 "Create an article in a mail newsgroup."
9028 (let ((group gnus-newsgroup-name)
9029 (now (current-time))
9031 (unless (gnus-check-backend-function 'request-accept-article group)
9032 (error "%s does not support article importing" group))
9034 (set-buffer (gnus-get-buffer-create " *import file*"))
9036 (goto-char (point-min))
9037 ;; This doesn't look like an article, so we fudge some headers.
9038 (insert "From: " (read-string "From: ") "\n"
9039 "Subject: " (read-string "Subject: ") "\n"
9040 "Date: " (message-make-date now) "\n"
9041 "Message-ID: " (message-make-message-id) "\n")
9042 (setq group-art (gnus-request-accept-article group nil t))
9043 (kill-buffer (current-buffer)))
9044 (setq gnus-newsgroup-active (gnus-activate-group group))
9046 (gnus-summary-goto-article (cdr group-art) nil t)
9047 (gnus-summary-edit-article)))
9049 (defun gnus-summary-article-posted-p ()
9050 "Say whether the current (mail) article is available from news as well.
9051 This will be the case if the article has both been mailed and posted."
9053 (let ((id (mail-header-references (gnus-summary-article-header)))
9054 (gnus-override-method (car (gnus-refer-article-methods))))
9055 (if (gnus-request-head id "")
9056 (gnus-message 2 "The current message was found on %s"
9057 gnus-override-method)
9058 (gnus-message 2 "The current message couldn't be found on %s"
9059 gnus-override-method)
9062 (defun gnus-summary-expire-articles (&optional now)
9063 "Expire all articles that are marked as expirable in the current group."
9065 (when (gnus-check-backend-function
9066 'request-expire-articles gnus-newsgroup-name)
9067 ;; This backend supports expiry.
9068 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9069 (expirable (if total
9071 ;; We need to update the info for
9072 ;; this group for `gnus-list-of-read-articles'
9073 ;; to give us the right answer.
9074 (gnus-run-hooks 'gnus-exit-group-hook)
9075 (gnus-summary-update-info)
9076 (gnus-list-of-read-articles gnus-newsgroup-name))
9077 (setq gnus-newsgroup-expirable
9078 (sort gnus-newsgroup-expirable '<))))
9079 (expiry-wait (if now 'immediate
9080 (gnus-group-find-parameter
9081 gnus-newsgroup-name 'expiry-wait)))
9082 (nnmail-expiry-target
9083 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9084 nnmail-expiry-target))
9087 ;; There are expirable articles in this group, so we run them
9088 ;; through the expiry process.
9089 (gnus-message 6 "Expiring articles...")
9090 (unless (gnus-check-group gnus-newsgroup-name)
9091 (error "Can't open server for %s" gnus-newsgroup-name))
9092 ;; The list of articles that weren't expired is returned.
9095 (let ((nnmail-expiry-wait-function nil)
9096 (nnmail-expiry-wait expiry-wait))
9097 (setq es (gnus-request-expire-articles
9098 expirable gnus-newsgroup-name)))
9099 (setq es (gnus-request-expire-articles
9100 expirable gnus-newsgroup-name)))
9102 (setq gnus-newsgroup-expirable es))
9103 ;; We go through the old list of expirable, and mark all
9104 ;; really expired articles as nonexistent.
9105 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9106 (let ((gnus-use-cache nil))
9107 (dolist (article expirable)
9108 (when (and (not (memq article es))
9109 (gnus-data-find article))
9110 (gnus-summary-mark-article article gnus-canceled-mark)
9111 (let ((id (mail-header-id (gnus-data-header
9113 (gnus-data-list nil))))))
9114 (run-hook-with-args 'gnus-summary-article-expire-hook
9115 'delete id gnus-newsgroup-name nil
9117 (gnus-message 6 "Expiring articles...done")))))
9119 (defun gnus-summary-expire-articles-now ()
9120 "Expunge all expirable articles in the current group.
9121 This means that *all* articles that are marked as expirable will be
9122 deleted forever, right now."
9124 (or gnus-expert-user
9126 "Are you really, really, really sure you want to delete all these messages? ")
9128 (gnus-summary-expire-articles t))
9130 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9131 (defun gnus-summary-delete-article (&optional n)
9132 "Delete the N next (mail) articles.
9133 This command actually deletes articles. This is not a marking
9134 command. The article will disappear forever from your life, never to
9136 If N is negative, delete backwards.
9137 If N is nil and articles have been marked with the process mark,
9138 delete these instead."
9140 (unless (gnus-check-backend-function 'request-expire-articles
9141 gnus-newsgroup-name)
9142 (error "The current newsgroup does not support article deletion"))
9143 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9144 (error "Couldn't open server"))
9145 ;; Compute the list of articles to delete.
9146 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9147 (nnmail-expiry-target 'delete)
9149 (if (and gnus-novice-user
9150 (not (gnus-yes-or-no-p
9151 (format "Do you really want to delete %s forever? "
9152 (if (> (length articles) 1)
9153 (format "these %s articles" (length articles))
9156 ;; Delete the articles.
9157 (setq not-deleted (gnus-request-expire-articles
9158 articles gnus-newsgroup-name 'force))
9160 (gnus-summary-remove-process-mark (car articles))
9161 ;; The backend might not have been able to delete the article
9163 (unless (memq (car articles) not-deleted)
9164 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9165 (let* ((article (car articles))
9166 (id (mail-header-id (gnus-data-header
9167 (assoc article (gnus-data-list nil))))))
9168 (run-hook-with-args 'gnus-summary-article-delete-hook
9169 'delete id gnus-newsgroup-name nil
9171 (setq articles (cdr articles)))
9173 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9174 (gnus-summary-position-point)
9175 (gnus-set-mode-line 'summary)
9178 (defun gnus-summary-edit-article (&optional arg)
9179 "Edit the current article.
9180 This will have permanent effect only in mail groups.
9181 If ARG is nil, edit the decoded articles.
9182 If ARG is 1, edit the raw articles.
9183 If ARG is 2, edit the raw articles even in read-only groups.
9184 If ARG is 3, edit the articles with the current handles.
9185 Otherwise, allow editing of articles even in read-only
9188 (let (force raw current-handles)
9197 (setq current-handles
9198 (and (gnus-buffer-live-p gnus-article-buffer)
9199 (with-current-buffer gnus-article-buffer
9201 gnus-article-mime-handles
9202 (setq gnus-article-mime-handles nil))))))
9205 (when (and raw (not force)
9206 (member gnus-newsgroup-name '("nndraft:delayed"
9209 (error "Can't edit the raw article in group %s"
9210 gnus-newsgroup-name))
9212 (set-buffer gnus-summary-buffer)
9213 (let ((mail-parse-charset gnus-newsgroup-charset)
9214 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9215 (gnus-set-global-variables)
9216 (when (and (not force)
9217 (gnus-group-read-only-p))
9218 (error "The current newsgroup does not support article editing"))
9219 (gnus-summary-show-article t)
9220 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9221 (with-current-buffer gnus-article-buffer
9222 (mm-enable-multibyte)))
9223 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9225 (gnus-article-edit-article
9228 (let ((mbl mml-buffer-list))
9229 (setq mml-buffer-list nil)
9230 (mime-to-mml ,'current-handles)
9231 (let ((mbl1 mml-buffer-list))
9232 (setq mml-buffer-list mbl)
9233 (set (make-local-variable 'mml-buffer-list) mbl1))
9234 (make-local-hook 'kill-buffer-hook)
9235 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9236 `(lambda (no-highlight)
9237 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9238 (message-options message-options)
9239 (message-options-set-recipient)
9240 (mail-parse-ignored-charsets
9241 ',gnus-newsgroup-ignored-charsets))
9242 ,(if (not raw) '(progn
9244 (mml-destroy-buffers)
9245 (remove-hook 'kill-buffer-hook
9246 'mml-destroy-buffers t)
9247 (kill-local-variable 'mml-buffer-list)))
9248 (gnus-summary-edit-article-done
9249 ,(or (mail-header-references gnus-current-headers) "")
9250 ,(gnus-group-read-only-p)
9251 ,gnus-summary-buffer no-highlight))))))))
9253 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9255 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9257 "Make edits to the current article permanent."
9260 ;; The buffer restriction contains the entire article if it exists.
9261 (when (article-goto-body)
9262 (let ((lines (count-lines (point) (point-max)))
9263 (length (- (point-max) (point)))
9264 (case-fold-search t)
9265 (body (copy-marker (point))))
9266 (goto-char (point-min))
9267 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9268 (delete-region (match-beginning 1) (match-end 1))
9269 (insert (number-to-string length)))
9270 (goto-char (point-min))
9271 (when (re-search-forward
9272 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9273 (delete-region (match-beginning 1) (match-end 1))
9274 (insert (number-to-string length)))
9275 (goto-char (point-min))
9276 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9277 (delete-region (match-beginning 1) (match-end 1))
9278 (insert (number-to-string lines))))))
9279 ;; Replace the article.
9280 (let ((buf (current-buffer)))
9282 (insert-buffer-substring buf)
9284 (if (and (not read-only)
9285 (not (gnus-request-replace-article
9286 (cdr gnus-article-current) (car gnus-article-current)
9287 (current-buffer) t)))
9288 (error "Couldn't replace article")
9289 ;; Update the summary buffer.
9291 (equal (message-tokenize-header references " ")
9292 (message-tokenize-header
9293 (or (message-fetch-field "references") "") " ")))
9294 ;; We only have to update this line.
9297 (message-narrow-to-head)
9298 (let ((head (buffer-string))
9301 (insert (format "211 %d Article retrieved.\n"
9302 (cdr gnus-article-current)))
9305 (let ((nntp-server-buffer (current-buffer)))
9306 (setq header (car (gnus-get-newsgroup-headers
9309 (set-buffer gnus-summary-buffer)
9310 (gnus-data-set-header
9311 (gnus-data-find (cdr gnus-article-current))
9313 (gnus-summary-update-article-line
9314 (cdr gnus-article-current) header)
9315 (if (gnus-summary-goto-subject
9316 (cdr gnus-article-current) nil t)
9317 (gnus-summary-update-secondary-mark
9318 (cdr gnus-article-current))))))))
9320 (set-buffer (or buffer gnus-summary-buffer))
9321 (gnus-summary-update-article (cdr gnus-article-current))
9322 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9323 (gnus-summary-update-secondary-mark
9324 (cdr gnus-article-current))))
9325 ;; Prettify the article buffer again.
9326 (unless no-highlight
9328 (set-buffer gnus-article-buffer)
9329 ;;;!!! Fix this -- article should be rehighlighted.
9330 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9331 (set-buffer gnus-original-article-buffer)
9332 (gnus-request-article
9333 (cdr gnus-article-current)
9334 (car gnus-article-current) (current-buffer))))
9335 ;; Prettify the summary buffer line.
9336 (when (gnus-visual-p 'summary-highlight 'highlight)
9337 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9339 (defun gnus-summary-edit-wash (key)
9340 "Perform editing command KEY in the article buffer."
9344 (message "%s" (concat (this-command-keys) "- "))
9347 (gnus-summary-edit-article)
9348 (execute-kbd-macro (concat (this-command-keys) key))
9349 (gnus-article-edit-done))
9353 (defun gnus-summary-respool-query (&optional silent trace)
9354 "Query where the respool algorithm would put this article."
9356 (let (gnus-mark-article-hook)
9357 (gnus-summary-select-article)
9359 (set-buffer gnus-original-article-buffer)
9361 (message-narrow-to-head)
9362 (let ((groups (nnmail-article-group 'identity trace)))
9365 (message "This message would go to %s"
9366 (mapconcat 'car groups ", "))
9367 (message "This message would go to no groups"))
9370 (defun gnus-summary-respool-trace ()
9371 "Trace where the respool algorithm would put this article.
9372 Display a buffer showing all fancy splitting patterns which matched."
9374 (gnus-summary-respool-query nil t))
9376 ;; Summary marking commands.
9378 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9379 "Mark articles which has the same subject as read, and then select the next.
9380 If UNMARK is positive, remove any kind of mark.
9381 If UNMARK is negative, tick articles."
9384 (setq unmark (prefix-numeric-value unmark)))
9386 (gnus-summary-mark-same-subject
9387 (gnus-summary-article-subject) unmark)))
9388 ;; Select next unread article. If auto-select-same mode, should
9389 ;; select the first unread article.
9390 (gnus-summary-next-article t (and gnus-auto-select-same
9391 (gnus-summary-article-subject)))
9392 (gnus-message 7 "%d article%s marked as %s"
9393 count (if (= count 1) " is" "s are")
9394 (if unmark "unread" "read"))))
9396 (defun gnus-summary-kill-same-subject (&optional unmark)
9397 "Mark articles which has the same subject as read.
9398 If UNMARK is positive, remove any kind of mark.
9399 If UNMARK is negative, tick articles."
9402 (setq unmark (prefix-numeric-value unmark)))
9404 (gnus-summary-mark-same-subject
9405 (gnus-summary-article-subject) unmark)))
9406 ;; If marked as read, go to next unread subject.
9408 ;; Go to next unread subject.
9409 (gnus-summary-next-subject 1 t))
9410 (gnus-message 7 "%d articles are marked as %s"
9411 count (if unmark "unread" "read"))))
9413 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9414 "Mark articles with same SUBJECT as read, and return marked number.
9415 If optional argument UNMARK is positive, remove any kinds of marks.
9416 If optional argument UNMARK is negative, mark articles as unread instead."
9420 ((null unmark) ; Mark as read.
9423 (gnus-summary-mark-article-as-read gnus-killed-mark)
9424 (gnus-summary-show-thread) t)
9425 (gnus-summary-find-subject subject))
9426 (setq count (1+ count))))
9427 ((> unmark 0) ; Tick.
9430 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9431 (gnus-summary-show-thread) t)
9432 (gnus-summary-find-subject subject))
9433 (setq count (1+ count))))
9434 (t ; Mark as unread.
9437 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9438 (gnus-summary-show-thread) t)
9439 (gnus-summary-find-subject subject))
9440 (setq count (1+ count)))))
9441 (gnus-set-mode-line 'summary)
9442 ;; Return the number of marked articles.
9445 (defun gnus-summary-mark-as-processable (n &optional unmark)
9446 "Set the process mark on the next N articles.
9447 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9448 the process mark instead. The difference between N and the actual
9449 number of articles marked is returned."
9451 (if (and (null n) (gnus-region-active-p))
9452 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9453 (setq n (prefix-numeric-value n))
9454 (let ((backward (< n 0))
9459 (gnus-summary-remove-process-mark
9460 (gnus-summary-article-number))
9461 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9462 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9465 (gnus-message 7 "No more articles"))
9466 (gnus-summary-recenter)
9467 (gnus-summary-position-point)
9470 (defun gnus-summary-unmark-as-processable (n)
9471 "Remove the process mark from the next N articles.
9472 If N is negative, unmark backward instead. The difference between N and
9473 the actual number of articles unmarked is returned."
9475 (gnus-summary-mark-as-processable n t))
9477 (defun gnus-summary-unmark-all-processable ()
9478 "Remove the process mark from all articles."
9481 (while gnus-newsgroup-processable
9482 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9483 (gnus-summary-position-point))
9485 (defun gnus-summary-add-mark (article type)
9486 "Mark ARTICLE with a mark of TYPE."
9487 (let ((vtype (car (assq type gnus-article-mark-lists)))
9490 (error "No such mark type: %s" type)
9491 (setq var (intern (format "gnus-newsgroup-%s" type)))
9492 (set var (cons article (symbol-value var)))
9493 (if (memq type '(processable cached replied forwarded recent saved))
9494 (gnus-summary-update-secondary-mark article)
9495 ;;; !!! This is bogus. We should find out what primary
9496 ;;; !!! mark we want to set.
9497 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9499 (defun gnus-summary-mark-as-expirable (n)
9500 "Mark N articles forward as expirable.
9501 If N is negative, mark backward instead. The difference between N and
9502 the actual number of articles marked is returned."
9504 (gnus-summary-mark-forward n gnus-expirable-mark))
9506 (defun gnus-summary-mark-as-spam (n)
9507 "Mark N articles forward as spam.
9508 If N is negative, mark backward instead. The difference between N and
9509 the actual number of articles marked is returned."
9511 (gnus-summary-mark-forward n gnus-spam-mark))
9513 (defun gnus-summary-mark-article-as-replied (article)
9514 "Mark ARTICLE as replied to and update the summary line.
9515 ARTICLE can also be a list of articles."
9516 (interactive (list (gnus-summary-article-number)))
9517 (let ((articles (if (listp article) article (list article))))
9518 (dolist (article articles)
9519 (unless (numberp article)
9520 (error "%s is not a number" article))
9521 (push article gnus-newsgroup-replied)
9522 (let ((buffer-read-only nil))
9523 (when (gnus-summary-goto-subject article nil t)
9524 (gnus-summary-update-secondary-mark article))))))
9526 (defun gnus-summary-mark-article-as-forwarded (article)
9527 "Mark ARTICLE as forwarded and update the summary line.
9528 ARTICLE can also be a list of articles."
9529 (let ((articles (if (listp article) article (list article))))
9530 (dolist (article articles)
9531 (push article gnus-newsgroup-forwarded)
9532 (let ((buffer-read-only nil))
9533 (when (gnus-summary-goto-subject article nil t)
9534 (gnus-summary-update-secondary-mark article))))))
9536 (defun gnus-summary-set-bookmark (article)
9537 "Set a bookmark in current article."
9538 (interactive (list (gnus-summary-article-number)))
9539 (when (or (not (get-buffer gnus-article-buffer))
9540 (not gnus-current-article)
9541 (not gnus-article-current)
9542 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9543 (error "No current article selected"))
9544 ;; Remove old bookmark, if one exists.
9545 (gnus-pull article gnus-newsgroup-bookmarks)
9546 ;; Set the new bookmark, which is on the form
9547 ;; (article-number . line-number-in-body).
9551 (set-buffer gnus-article-buffer)
9558 gnus-newsgroup-bookmarks)
9559 (gnus-message 6 "A bookmark has been added to the current article."))
9561 (defun gnus-summary-remove-bookmark (article)
9562 "Remove the bookmark from the current article."
9563 (interactive (list (gnus-summary-article-number)))
9564 ;; Remove old bookmark, if one exists.
9565 (if (not (assq article gnus-newsgroup-bookmarks))
9566 (gnus-message 6 "No bookmark in current article.")
9567 (gnus-pull article gnus-newsgroup-bookmarks)
9568 (gnus-message 6 "Removed bookmark.")))
9570 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9571 (defun gnus-summary-mark-as-dormant (n)
9572 "Mark N articles forward as dormant.
9573 If N is negative, mark backward instead. The difference between N and
9574 the actual number of articles marked is returned."
9576 (gnus-summary-mark-forward n gnus-dormant-mark))
9578 (defun gnus-summary-set-process-mark (article)
9579 "Set the process mark on ARTICLE and update the summary line."
9580 (setq gnus-newsgroup-processable
9582 (delq article gnus-newsgroup-processable)))
9583 (when (gnus-summary-goto-subject article)
9584 (gnus-summary-show-thread)
9585 (gnus-summary-goto-subject article)
9586 (gnus-summary-update-secondary-mark article)))
9588 (defun gnus-summary-remove-process-mark (article)
9589 "Remove the process mark from ARTICLE and update the summary line."
9590 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9591 (when (gnus-summary-goto-subject article)
9592 (gnus-summary-show-thread)
9593 (gnus-summary-goto-subject article)
9594 (gnus-summary-update-secondary-mark article)))
9596 (defun gnus-summary-set-saved-mark (article)
9597 "Set the process mark on ARTICLE and update the summary line."
9598 (push article gnus-newsgroup-saved)
9599 (when (gnus-summary-goto-subject article)
9600 (gnus-summary-update-secondary-mark article)))
9602 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9603 "Mark N articles as read forwards.
9604 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9605 The difference between N and the actual number of articles marked is
9607 If NO-EXPIRE, auto-expiry will be inhibited."
9609 (gnus-summary-show-thread)
9610 (let ((backward (< n 0))
9611 (gnus-summary-goto-unread
9612 (and gnus-summary-goto-unread
9613 (not (eq gnus-summary-goto-unread 'never))
9614 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9615 gnus-ticked-mark gnus-dormant-mark)))))
9617 (mark (or mark gnus-del-mark)))
9619 (gnus-summary-mark-article nil mark no-expire)
9620 (zerop (gnus-summary-next-subject
9622 (and gnus-summary-goto-unread
9623 (not (eq gnus-summary-goto-unread 'never)))
9627 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9628 (gnus-summary-recenter)
9629 (gnus-summary-position-point)
9630 (gnus-set-mode-line 'summary)
9633 (defun gnus-summary-mark-article-as-read (mark)
9634 "Mark the current article quickly as read with MARK."
9635 (let ((article (gnus-summary-article-number)))
9636 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9637 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9638 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9639 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9640 (push (cons article mark) gnus-newsgroup-reads)
9641 ;; Possibly remove from cache, if that is used.
9642 (when gnus-use-cache
9643 (gnus-cache-enter-remove-article article))
9644 ;; Allow the backend to change the mark.
9645 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9646 ;; Check for auto-expiry.
9647 (when (and gnus-newsgroup-auto-expire
9648 (memq mark gnus-auto-expirable-marks))
9649 (setq mark gnus-expirable-mark)
9650 ;; Let the backend know about the mark change.
9651 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9652 (push article gnus-newsgroup-expirable))
9653 ;; Set the mark in the buffer.
9654 (gnus-summary-update-mark mark 'unread)
9657 (defun gnus-summary-mark-article-as-unread (mark)
9658 "Mark the current article quickly as unread with MARK."
9659 (let* ((article (gnus-summary-article-number))
9660 (old-mark (gnus-summary-article-mark article)))
9661 ;; Allow the backend to change the mark.
9662 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9663 (if (eq mark old-mark)
9667 (gnus-error 1 "Can't mark negative article numbers")
9669 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9670 (setq gnus-newsgroup-spam-marked
9671 (delq article gnus-newsgroup-spam-marked))
9672 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9673 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9674 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9675 (cond ((= mark gnus-ticked-mark)
9676 (setq gnus-newsgroup-marked
9677 (gnus-add-to-sorted-list gnus-newsgroup-marked
9679 ((= mark gnus-spam-mark)
9680 (setq gnus-newsgroup-spam-marked
9681 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9683 ((= mark gnus-dormant-mark)
9684 (setq gnus-newsgroup-dormant
9685 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9688 (setq gnus-newsgroup-unreads
9689 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9691 (gnus-pull article gnus-newsgroup-reads)
9693 ;; See whether the article is to be put in the cache.
9695 (vectorp (gnus-summary-article-header article))
9697 (gnus-cache-possibly-enter-article
9698 gnus-newsgroup-name article
9699 (= mark gnus-ticked-mark)
9700 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9703 (gnus-summary-update-mark mark 'unread)
9706 (defun gnus-summary-mark-article (&optional article mark no-expire)
9707 "Mark ARTICLE with MARK. MARK can be any character.
9708 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9709 `??' (dormant) and `?E' (expirable).
9710 If MARK is nil, then the default character `?r' is used.
9711 If ARTICLE is nil, then the article on the current line will be
9713 If NO-EXPIRE, auto-expiry will be inhibited."
9714 ;; The mark might be a string.
9715 (when (stringp mark)
9716 (setq mark (aref mark 0)))
9717 ;; If no mark is given, then we check auto-expiring.
9719 (setq mark gnus-del-mark))
9720 (when (and (not no-expire)
9721 gnus-newsgroup-auto-expire
9722 (memq mark gnus-auto-expirable-marks))
9723 (setq mark gnus-expirable-mark))
9724 (let ((article (or article (gnus-summary-article-number)))
9725 (old-mark (gnus-summary-article-mark article)))
9726 ;; Allow the backend to change the mark.
9727 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9728 (if (eq mark old-mark)
9731 (error "No article on current line"))
9732 (if (not (if (or (= mark gnus-unread-mark)
9733 (= mark gnus-ticked-mark)
9734 (= mark gnus-spam-mark)
9735 (= mark gnus-dormant-mark))
9736 (gnus-mark-article-as-unread article mark)
9737 (gnus-mark-article-as-read article mark)))
9739 ;; See whether the article is to be put in the cache.
9741 (not (= mark gnus-canceled-mark))
9742 (vectorp (gnus-summary-article-header article))
9744 (gnus-cache-possibly-enter-article
9745 gnus-newsgroup-name article
9746 (= mark gnus-ticked-mark)
9747 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9749 (when (gnus-summary-goto-subject article nil t)
9750 (let ((buffer-read-only nil))
9751 (gnus-summary-show-thread)
9753 (gnus-summary-update-mark mark 'unread)
9756 (defun gnus-summary-update-secondary-mark (article)
9757 "Update the secondary (read, process, cache) mark."
9758 (gnus-summary-update-mark
9759 (cond ((memq article gnus-newsgroup-processable)
9761 ((memq article gnus-newsgroup-cached)
9763 ((memq article gnus-newsgroup-replied)
9765 ((memq article gnus-newsgroup-forwarded)
9766 gnus-forwarded-mark)
9767 ((memq article gnus-newsgroup-saved)
9769 ((memq article gnus-newsgroup-recent)
9771 ((memq article gnus-newsgroup-unseen)
9775 (when (gnus-visual-p 'summary-highlight 'highlight)
9776 (gnus-run-hooks 'gnus-summary-update-hook))
9779 (defun gnus-summary-update-download-mark (article)
9780 "Update the secondary (read, process, cache) mark."
9781 (gnus-summary-update-mark
9782 (cond ((memq article gnus-newsgroup-undownloaded)
9783 gnus-undownloaded-mark)
9784 (gnus-newsgroup-agentized
9785 gnus-downloaded-mark)
9789 (gnus-summary-update-line t)
9792 (defun gnus-summary-update-mark (mark type)
9793 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9794 (buffer-read-only nil))
9795 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9797 (when (looking-at "\r")
9799 (when (<= (+ forward (point)) (point-max))
9800 ;; Go to the right position on the line.
9801 (goto-char (+ forward (point)))
9802 ;; Replace the old mark with the new mark.
9803 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9804 ;; Optionally update the marks by some user rule.
9805 (when (eq type 'unread)
9807 (gnus-data-find (gnus-summary-article-number)) mark)
9808 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9810 (defun gnus-mark-article-as-read (article &optional mark)
9811 "Enter ARTICLE in the pertinent lists and remove it from others."
9812 ;; Make the article expirable.
9813 (let ((mark (or mark gnus-del-mark)))
9814 (setq gnus-newsgroup-expirable
9815 (if (= mark gnus-expirable-mark)
9816 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9817 (delq article gnus-newsgroup-expirable)))
9818 ;; Remove from unread and marked lists.
9819 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9820 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9821 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9822 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9823 (push (cons article mark) gnus-newsgroup-reads)
9824 ;; Possibly remove from cache, if that is used.
9825 (when gnus-use-cache
9826 (gnus-cache-enter-remove-article article))
9829 (defun gnus-mark-article-as-unread (article &optional mark)
9830 "Enter ARTICLE in the pertinent lists and remove it from others."
9831 (let ((mark (or mark gnus-ticked-mark)))
9834 (gnus-error 1 "Can't mark negative article numbers")
9836 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9837 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9838 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9839 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9840 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9842 ;; Unsuppress duplicates?
9843 (when gnus-suppress-duplicates
9844 (gnus-dup-unsuppress-article article))
9846 (cond ((= mark gnus-ticked-mark)
9847 (setq gnus-newsgroup-marked
9848 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9849 ((= mark gnus-spam-mark)
9850 (setq gnus-newsgroup-spam-marked
9851 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9853 ((= mark gnus-dormant-mark)
9854 (setq gnus-newsgroup-dormant
9855 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9857 (setq gnus-newsgroup-unreads
9858 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9859 (gnus-pull article gnus-newsgroup-reads)
9862 (defalias 'gnus-summary-mark-as-unread-forward
9863 'gnus-summary-tick-article-forward)
9864 (make-obsolete 'gnus-summary-mark-as-unread-forward
9865 'gnus-summary-tick-article-forward)
9866 (defun gnus-summary-tick-article-forward (n)
9867 "Tick N articles forwards.
9868 If N is negative, tick backwards instead.
9869 The difference between N and the number of articles ticked is returned."
9871 (gnus-summary-mark-forward n gnus-ticked-mark))
9873 (defalias 'gnus-summary-mark-as-unread-backward
9874 'gnus-summary-tick-article-backward)
9875 (make-obsolete 'gnus-summary-mark-as-unread-backward
9876 'gnus-summary-tick-article-backward)
9877 (defun gnus-summary-tick-article-backward (n)
9878 "Tick N articles backwards.
9879 The difference between N and the number of articles ticked is returned."
9881 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9883 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9884 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9885 (defun gnus-summary-tick-article (&optional article clear-mark)
9886 "Mark current article as unread.
9887 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9888 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9890 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9893 (defun gnus-summary-mark-as-read-forward (n)
9894 "Mark N articles as read forwards.
9895 If N is negative, mark backwards instead.
9896 The difference between N and the actual number of articles marked is
9899 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9901 (defun gnus-summary-mark-as-read-backward (n)
9902 "Mark the N articles as read backwards.
9903 The difference between N and the actual number of articles marked is
9906 (gnus-summary-mark-forward
9907 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9909 (defun gnus-summary-mark-as-read (&optional article mark)
9910 "Mark current article as read.
9911 ARTICLE specifies the article to be marked as read.
9912 MARK specifies a string to be inserted at the beginning of the line."
9913 (gnus-summary-mark-article article mark))
9915 (defun gnus-summary-clear-mark-forward (n)
9916 "Clear marks from N articles forward.
9917 If N is negative, clear backward instead.
9918 The difference between N and the number of marks cleared is returned."
9920 (gnus-summary-mark-forward n gnus-unread-mark))
9922 (defun gnus-summary-clear-mark-backward (n)
9923 "Clear marks from N articles backward.
9924 The difference between N and the number of marks cleared is returned."
9926 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9928 (defun gnus-summary-mark-unread-as-read ()
9929 "Intended to be used by `gnus-summary-mark-article-hook'."
9930 (when (memq gnus-current-article gnus-newsgroup-unreads)
9931 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9933 (defun gnus-summary-mark-read-and-unread-as-read ()
9934 "Intended to be used by `gnus-summary-mark-article-hook'."
9935 (let ((mark (gnus-summary-article-mark)))
9936 (when (or (gnus-unread-mark-p mark)
9937 (gnus-read-mark-p mark))
9938 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9940 (defun gnus-summary-mark-unread-as-ticked ()
9941 "Intended to be used by `gnus-summary-mark-article-hook'."
9942 (when (memq gnus-current-article gnus-newsgroup-unreads)
9943 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9945 (defun gnus-summary-mark-region-as-read (point mark all)
9946 "Mark all unread articles between point and mark as read.
9947 If given a prefix, mark all articles between point and mark as read,
9948 even ticked and dormant ones."
9949 (interactive "r\nP")
9958 (memq (setq article (gnus-summary-article-number))
9959 gnus-newsgroup-unreads))
9960 (gnus-summary-mark-article article gnus-del-mark))
9962 (gnus-summary-find-next))))))
9964 (defun gnus-summary-mark-below (score mark)
9965 "Mark articles with score less than SCORE with MARK."
9966 (interactive "P\ncMark: ")
9967 (setq score (if score
9968 (prefix-numeric-value score)
9969 (or gnus-summary-default-score 0)))
9971 (set-buffer gnus-summary-buffer)
9972 (goto-char (point-min))
9975 (and (< (gnus-summary-article-score) score)
9976 (gnus-summary-mark-article nil mark))
9977 (gnus-summary-find-next)))))
9979 (defun gnus-summary-kill-below (&optional score)
9980 "Mark articles with score below SCORE as read."
9982 (gnus-summary-mark-below score gnus-killed-mark))
9984 (defun gnus-summary-clear-above (&optional score)
9985 "Clear all marks from articles with score above SCORE."
9987 (gnus-summary-mark-above score gnus-unread-mark))
9989 (defun gnus-summary-tick-above (&optional score)
9990 "Tick all articles with score above SCORE."
9992 (gnus-summary-mark-above score gnus-ticked-mark))
9994 (defun gnus-summary-mark-above (score mark)
9995 "Mark articles with score over SCORE with MARK."
9996 (interactive "P\ncMark: ")
9997 (setq score (if score
9998 (prefix-numeric-value score)
9999 (or gnus-summary-default-score 0)))
10001 (set-buffer gnus-summary-buffer)
10002 (goto-char (point-min))
10004 (when (> (gnus-summary-article-score) score)
10005 (gnus-summary-mark-article nil mark))
10007 (gnus-summary-find-next)))))
10009 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10010 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10011 (defun gnus-summary-limit-include-expunged (&optional no-error)
10012 "Display all the hidden articles that were expunged for low scores."
10014 (let ((buffer-read-only nil))
10015 (let ((scored gnus-newsgroup-scored)
10018 (unless (gnus-summary-article-header (caar scored))
10019 (and (setq h (gnus-number-to-header (caar scored)))
10020 (< (cdar scored) gnus-summary-expunge-below)
10022 (setq scored (cdr scored)))
10024 (when (not no-error)
10025 (error "No expunged articles hidden"))
10026 (goto-char (point-min))
10027 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10028 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10029 (mapcar (lambda (x) (push (mail-header-number x)
10030 gnus-newsgroup-limit))
10032 (gnus-summary-prepare-unthreaded (nreverse headers))
10033 (goto-char (point-min))
10034 (gnus-summary-position-point)
10037 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10038 "Mark all unread articles in this newsgroup as read.
10039 If prefix argument ALL is non-nil, ticked and dormant articles will
10040 also be marked as read.
10041 If QUIETLY is non-nil, no questions will be asked.
10042 If TO-HERE is non-nil, it should be a point in the buffer. All
10043 articles before (after, if REVERSE is set) this point will be marked as read.
10044 Note that this function will only catch up the unread article
10045 in the current summary buffer limitation.
10046 The number of articles marked as read is returned."
10051 (not gnus-interactive-catchup) ;Without confirmation?
10055 "Mark absolutely all articles as read? "
10056 "Mark all unread articles as read? ")))
10058 (not gnus-newsgroup-adaptive)
10059 (not gnus-newsgroup-auto-expire)
10060 (not gnus-suppress-duplicates)
10061 (or (not gnus-use-cache)
10062 (eq gnus-use-cache 'passive)))
10065 (setq gnus-newsgroup-marked nil
10066 gnus-newsgroup-spam-marked nil
10067 gnus-newsgroup-dormant nil))
10068 (setq gnus-newsgroup-unreads
10069 (gnus-sorted-nunion
10070 (gnus-intersection gnus-newsgroup-unreads
10071 gnus-newsgroup-downloadable)
10072 gnus-newsgroup-unfetched)))
10073 ;; We actually mark all articles as canceled, which we
10074 ;; have to do when using auto-expiry or adaptive scoring.
10075 (gnus-summary-show-all-threads)
10076 (if (and to-here reverse)
10078 (goto-char to-here)
10080 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10081 (gnus-summary-find-next (not all)))))
10082 (when (gnus-summary-first-subject (not all))
10084 (if to-here (< (point) to-here) t)
10085 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10086 (gnus-summary-find-next (not all))))))
10087 (gnus-set-mode-line 'summary))
10089 (gnus-summary-position-point)))
10091 (defun gnus-summary-catchup-to-here (&optional all)
10092 "Mark all unticked articles before the current one as read.
10093 If ALL is non-nil, also mark ticked and dormant articles as read."
10096 (gnus-save-hidden-threads
10097 (let ((beg (point)))
10098 ;; We check that there are unread articles.
10099 (when (or all (gnus-summary-find-prev))
10100 (gnus-summary-catchup all t beg)))))
10101 (gnus-summary-position-point))
10103 (defun gnus-summary-catchup-from-here (&optional all)
10104 "Mark all unticked articles after the current one as read.
10105 If ALL is non-nil, also mark ticked and dormant articles as read."
10108 (gnus-save-hidden-threads
10109 (let ((beg (point)))
10110 ;; We check that there are unread articles.
10111 (when (or all (gnus-summary-find-next))
10112 (gnus-summary-catchup all t beg nil t)))))
10114 (gnus-summary-position-point))
10115 (defun gnus-summary-catchup-all (&optional quietly)
10116 "Mark all articles in this newsgroup as read.
10117 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10118 instead, which marks only unread articles as read."
10120 (gnus-summary-catchup t quietly))
10122 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10123 "Mark all unread articles in this group as read, then exit.
10124 If prefix argument ALL is non-nil, all articles are marked as read.
10125 If QUIETLY is non-nil, no questions will be asked."
10127 (when (gnus-summary-catchup all quietly nil 'fast)
10128 ;; Select next newsgroup or exit.
10129 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10130 (eq gnus-auto-select-next 'quietly))
10131 (gnus-summary-next-group nil)
10132 (gnus-summary-exit))))
10134 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10135 "Mark all articles in this newsgroup as read, and then exit.
10136 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10137 instead, which marks only unread articles as read."
10139 (gnus-summary-catchup-and-exit t quietly))
10141 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10142 "Mark all articles in this group as read and select the next group.
10143 If given a prefix, mark all articles, unread as well as ticked, as
10147 (gnus-summary-catchup all))
10148 (gnus-summary-next-group))
10154 (defmacro gnus-with-article (article &rest forms)
10155 "Select ARTICLE and perform FORMS in the original article buffer.
10156 Then replace the article with the result."
10158 ;; We don't want the article to be marked as read.
10159 (let (gnus-mark-article-hook)
10160 (gnus-summary-select-article t t nil ,article))
10161 (set-buffer gnus-original-article-buffer)
10163 (if (not (gnus-check-backend-function
10164 'request-replace-article (car gnus-article-current)))
10165 (gnus-message 5 "Read-only group; not replacing")
10166 (unless (gnus-request-replace-article
10167 ,article (car gnus-article-current)
10168 (current-buffer) t)
10169 (error "Couldn't replace article")))
10170 ;; The cache and backlog have to be flushed somewhat.
10171 (when gnus-keep-backlog
10172 (gnus-backlog-remove-article
10173 (car gnus-article-current) (cdr gnus-article-current)))
10174 (when gnus-use-cache
10175 (gnus-cache-update-article
10176 (car gnus-article-current) (cdr gnus-article-current)))))
10178 (put 'gnus-with-article 'lisp-indent-function 1)
10179 (put 'gnus-with-article 'edebug-form-spec '(form body))
10181 ;; Thread-based commands.
10183 (defun gnus-summary-articles-in-thread (&optional article)
10184 "Return a list of all articles in the current thread.
10185 If ARTICLE is non-nil, return all articles in the thread that starts
10186 with that article."
10187 (let* ((article (or article (gnus-summary-article-number)))
10188 (data (gnus-data-find-list article))
10189 (top-level (gnus-data-level (car data)))
10191 (cond ((null gnus-thread-operation-ignore-subject)
10192 (gnus-simplify-subject-re
10193 (mail-header-subject (gnus-data-header (car data)))))
10194 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10195 (gnus-simplify-subject-fuzzy
10196 (mail-header-subject (gnus-data-header (car data)))))
10198 (end-point (save-excursion
10199 (if (gnus-summary-go-to-next-thread)
10200 (point) (point-max))))
10203 (< (gnus-data-pos (car data)) end-point))
10204 (when (or (not top-subject)
10205 (string= top-subject
10206 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10207 (gnus-simplify-subject-fuzzy
10208 (mail-header-subject
10209 (gnus-data-header (car data))))
10210 (gnus-simplify-subject-re
10211 (mail-header-subject
10212 (gnus-data-header (car data)))))))
10213 (push (gnus-data-number (car data)) articles))
10214 (unless (and (setq data (cdr data))
10215 (> (gnus-data-level (car data)) top-level))
10217 ;; Return the list of articles.
10218 (nreverse articles)))
10220 (defun gnus-summary-rethread-current ()
10221 "Rethread the thread the current article is part of."
10223 (let* ((gnus-show-threads t)
10224 (article (gnus-summary-article-number))
10225 (id (mail-header-id (gnus-summary-article-header)))
10226 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10228 (error "No article on the current line"))
10229 (gnus-rebuild-thread id)
10230 (gnus-summary-goto-subject article)))
10232 (defun gnus-summary-reparent-thread ()
10233 "Make the current article child of the marked (or previous) article.
10235 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10236 is non-nil or the Subject: of both articles are the same."
10238 (unless (not (gnus-group-read-only-p))
10239 (error "The current newsgroup does not support article editing"))
10240 (unless (<= (length gnus-newsgroup-processable) 1)
10241 (error "No more than one article may be marked"))
10242 (save-window-excursion
10243 (let ((gnus-article-buffer " *reparent*")
10244 (current-article (gnus-summary-article-number))
10245 ;; First grab the marked article, otherwise one line up.
10246 (parent-article (if (not (null gnus-newsgroup-processable))
10247 (car gnus-newsgroup-processable)
10249 (if (eq (forward-line -1) 0)
10250 (gnus-summary-article-number)
10251 (error "Beginning of summary buffer"))))))
10252 (unless (not (eq current-article parent-article))
10253 (error "An article may not be self-referential"))
10254 (let ((message-id (mail-header-id
10255 (gnus-summary-article-header parent-article))))
10256 (unless (and message-id (not (equal message-id "")))
10257 (error "No message-id in desired parent"))
10258 (gnus-with-article current-article
10260 (goto-char (point-min))
10261 (message-narrow-to-head)
10262 (if (re-search-forward "^References: " nil t)
10264 (re-search-forward "^[^ \t]" nil t)
10267 (insert " " message-id))
10268 (insert "References: " message-id "\n"))))
10269 (set-buffer gnus-summary-buffer)
10270 (gnus-summary-unmark-all-processable)
10271 (gnus-summary-update-article current-article)
10272 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10273 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10274 (gnus-summary-rethread-current)
10275 (gnus-message 3 "Article %d is now the child of article %d"
10276 current-article parent-article)))))
10278 (defun gnus-summary-toggle-threads (&optional arg)
10279 "Toggle showing conversation threads.
10280 If ARG is positive number, turn showing conversation threads on."
10282 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10283 (setq gnus-show-threads
10284 (if (null arg) (not gnus-show-threads)
10285 (> (prefix-numeric-value arg) 0)))
10286 (gnus-summary-prepare)
10287 (gnus-summary-goto-subject current)
10288 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10289 (gnus-summary-position-point)))
10291 (defun gnus-summary-show-all-threads ()
10292 "Show all threads."
10295 (let ((buffer-read-only nil))
10296 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10297 (gnus-summary-position-point))
10299 (defun gnus-summary-show-thread ()
10300 "Show thread subtrees.
10301 Returns nil if no thread was there to be shown."
10303 (let ((buffer-read-only nil)
10305 ;; first goto end then to beg, to have point at beg after let
10306 (end (progn (end-of-line) (point)))
10307 (beg (progn (beginning-of-line) (point))))
10309 ;; Any hidden lines here?
10310 (search-forward "\r" end t)
10311 (subst-char-in-region beg end ?\^M ?\n t)
10313 (gnus-summary-position-point))))
10315 (defun gnus-summary-maybe-hide-threads ()
10316 "If requested, hide the threads that should be hidden."
10317 (when (and gnus-show-threads
10318 gnus-thread-hide-subtree)
10319 (gnus-summary-hide-all-threads
10320 (if (or (consp gnus-thread-hide-subtree)
10321 (gnus-functionp gnus-thread-hide-subtree))
10322 (gnus-make-predicate gnus-thread-hide-subtree)
10325 ;;; Hiding predicates.
10327 (defun gnus-article-unread-p (header)
10328 (memq (mail-header-number header) gnus-newsgroup-unreads))
10330 (defun gnus-article-unseen-p (header)
10331 (memq (mail-header-number header) gnus-newsgroup-unseen))
10333 (defun gnus-map-articles (predicate articles)
10334 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10335 (apply 'gnus-or (mapcar predicate
10336 (mapcar 'gnus-summary-article-header articles))))
10338 (defun gnus-summary-hide-all-threads (&optional predicate)
10339 "Hide all thread subtrees.
10340 If PREDICATE is supplied, threads that satisfy this predicate
10341 will not be hidden."
10344 (goto-char (point-min))
10347 (when (or (not predicate)
10349 predicate (gnus-summary-article-children)))
10350 (gnus-summary-hide-thread))
10351 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10352 (gnus-summary-position-point))
10354 (defun gnus-summary-hide-thread ()
10355 "Hide thread subtrees.
10356 If PREDICATE is supplied, threads that satisfy this predicate
10357 will not be hidden.
10358 Returns nil if no threads were there to be hidden."
10360 (let ((buffer-read-only nil)
10362 (article (gnus-summary-article-number)))
10364 ;; Go forward until either the buffer ends or the subthread
10366 (when (and (not (eobp))
10367 (or (zerop (gnus-summary-next-thread 1 t))
10368 (goto-char (point-max))))
10370 (if (and (> (point) start)
10371 (search-backward "\n" start t))
10373 (subst-char-in-region start (point) ?\n ?\^M)
10374 (gnus-summary-goto-subject article))
10378 (defun gnus-summary-go-to-next-thread (&optional previous)
10379 "Go to the same level (or less) next thread.
10380 If PREVIOUS is non-nil, go to previous thread instead.
10381 Return the article number moved to, or nil if moving was impossible."
10382 (let ((level (gnus-summary-thread-level))
10383 (way (if previous -1 1))
10386 (while (and (not (eobp))
10387 (< level (gnus-summary-thread-level)))
10388 (forward-line way))
10395 (gnus-summary-article-number)
10396 (goto-char beg)))))
10398 (defun gnus-summary-next-thread (n &optional silent)
10399 "Go to the same level next N'th thread.
10400 If N is negative, search backward instead.
10401 Returns the difference between N and the number of skips actually
10404 If SILENT, don't output messages."
10406 (let ((backward (< n 0))
10408 (while (and (> n 0)
10409 (gnus-summary-go-to-next-thread backward))
10412 (gnus-summary-position-point))
10413 (when (and (not silent) (/= 0 n))
10414 (gnus-message 7 "No more threads"))
10417 (defun gnus-summary-prev-thread (n)
10418 "Go to the same level previous N'th thread.
10419 Returns the difference between N and the number of skips actually
10422 (gnus-summary-next-thread (- n)))
10424 (defun gnus-summary-go-down-thread ()
10425 "Go down one level in the current thread."
10426 (let ((children (gnus-summary-article-children)))
10428 (gnus-summary-goto-subject (car children)))))
10430 (defun gnus-summary-go-up-thread ()
10431 "Go up one level in the current thread."
10432 (let ((parent (gnus-summary-article-parent)))
10434 (gnus-summary-goto-subject parent))))
10436 (defun gnus-summary-down-thread (n)
10437 "Go down thread N steps.
10438 If N is negative, go up instead.
10439 Returns the difference between N and how many steps down that were
10444 (while (and (> n 0)
10445 (if up (gnus-summary-go-up-thread)
10446 (gnus-summary-go-down-thread)))
10448 (gnus-summary-position-point)
10450 (gnus-message 7 "Can't go further"))
10453 (defun gnus-summary-up-thread (n)
10454 "Go up thread N steps.
10455 If N is negative, go down instead.
10456 Returns the difference between N and how many steps down that were
10459 (gnus-summary-down-thread (- n)))
10461 (defun gnus-summary-top-thread ()
10462 "Go to the top of the thread."
10464 (while (gnus-summary-go-up-thread))
10465 (gnus-summary-article-number))
10467 (defun gnus-summary-kill-thread (&optional unmark)
10468 "Mark articles under current thread as read.
10469 If the prefix argument is positive, remove any kinds of marks.
10470 If the prefix argument is negative, tick articles instead."
10473 (setq unmark (prefix-numeric-value unmark)))
10474 (let ((articles (gnus-summary-articles-in-thread)))
10476 ;; Expand the thread.
10477 (gnus-summary-show-thread)
10478 ;; Mark all the articles.
10480 (gnus-summary-goto-subject (car articles))
10481 (cond ((null unmark)
10482 (gnus-summary-mark-article-as-read gnus-killed-mark))
10484 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10486 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10487 (setq articles (cdr articles))))
10488 ;; Hide killed subtrees.
10490 gnus-thread-hide-killed
10491 (gnus-summary-hide-thread))
10492 ;; If marked as read, go to next unread subject.
10493 (when (null unmark)
10494 ;; Go to next unread subject.
10495 (gnus-summary-next-subject 1 t)))
10496 (gnus-set-mode-line 'summary))
10498 ;; Summary sorting commands
10500 (defun gnus-summary-sort-by-number (&optional reverse)
10501 "Sort the summary buffer by article number.
10502 Argument REVERSE means reverse order."
10504 (gnus-summary-sort 'number reverse))
10506 (defun gnus-summary-sort-by-random (&optional reverse)
10507 "Randomize the order in the summary buffer.
10508 Argument REVERSE means to randomize in reverse order."
10510 (gnus-summary-sort 'random reverse))
10512 (defun gnus-summary-sort-by-author (&optional reverse)
10513 "Sort the summary buffer by author name alphabetically.
10514 If `case-fold-search' is non-nil, case of letters is ignored.
10515 Argument REVERSE means reverse order."
10517 (gnus-summary-sort 'author reverse))
10519 (defun gnus-summary-sort-by-subject (&optional reverse)
10520 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10521 If `case-fold-search' is non-nil, case of letters is ignored.
10522 Argument REVERSE means reverse order."
10524 (gnus-summary-sort 'subject reverse))
10526 (defun gnus-summary-sort-by-date (&optional reverse)
10527 "Sort the summary buffer by date.
10528 Argument REVERSE means reverse order."
10530 (gnus-summary-sort 'date reverse))
10532 (defun gnus-summary-sort-by-score (&optional reverse)
10533 "Sort the summary buffer by score.
10534 Argument REVERSE means reverse order."
10536 (gnus-summary-sort 'score reverse))
10538 (defun gnus-summary-sort-by-lines (&optional reverse)
10539 "Sort the summary buffer by the number of lines.
10540 Argument REVERSE means reverse order."
10542 (gnus-summary-sort 'lines reverse))
10544 (defun gnus-summary-sort-by-chars (&optional reverse)
10545 "Sort the summary buffer by article length.
10546 Argument REVERSE means reverse order."
10548 (gnus-summary-sort 'chars reverse))
10550 (defun gnus-summary-sort-by-original (&optional reverse)
10551 "Sort the summary buffer using the default sorting method.
10552 Argument REVERSE means reverse order."
10554 (let* ((buffer-read-only)
10555 (gnus-summary-prepare-hook nil))
10556 ;; We do the sorting by regenerating the threads.
10557 (gnus-summary-prepare)
10558 ;; Hide subthreads if needed.
10559 (gnus-summary-maybe-hide-threads)))
10561 (defun gnus-summary-sort (predicate reverse)
10562 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10563 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10564 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10565 (gnus-thread-sort-functions
10570 (gnus-sort-gathered-threads-function
10571 gnus-thread-sort-functions)
10572 (gnus-article-sort-functions
10576 (,article t2 t1))))
10578 (gnus-summary-prepare-hook nil))
10579 ;; We do the sorting by regenerating the threads.
10580 (gnus-summary-prepare)
10581 ;; Hide subthreads if needed.
10582 (gnus-summary-maybe-hide-threads)))
10584 ;; Summary saving commands.
10586 (defun gnus-summary-save-article (&optional n not-saved)
10587 "Save the current article using the default saver function.
10588 If N is a positive number, save the N next articles.
10589 If N is a negative number, save the N previous articles.
10590 If N is nil and any articles have been marked with the process mark,
10591 save those articles instead.
10592 The variable `gnus-default-article-saver' specifies the saver function."
10594 (let* ((articles (gnus-summary-work-articles n))
10595 (save-buffer (save-excursion
10596 (nnheader-set-temp-buffer " *Gnus Save*")))
10597 (num (length articles))
10599 (dolist (article articles)
10600 (setq header (gnus-summary-article-header article))
10601 (if (not (vectorp header))
10602 ;; This is a pseudo-article.
10603 (if (assq 'name header)
10604 (gnus-copy-file (cdr (assq 'name header)))
10605 (gnus-message 1 "Article %d is unsaveable" article))
10606 ;; This is a real article.
10607 (save-window-excursion
10608 (let ((gnus-display-mime-function nil)
10609 (gnus-article-prepare-hook nil))
10610 (gnus-summary-select-article t nil nil article)))
10612 (set-buffer save-buffer)
10614 (insert-buffer-substring gnus-original-article-buffer))
10615 (setq file (gnus-article-save save-buffer file num))
10616 (gnus-summary-remove-process-mark article)
10618 (gnus-summary-set-saved-mark article))))
10619 (gnus-kill-buffer save-buffer)
10620 (gnus-summary-position-point)
10621 (gnus-set-mode-line 'summary)
10624 (defun gnus-summary-pipe-output (&optional arg headers)
10625 "Pipe the current article to a subprocess.
10626 If N is a positive number, pipe the N next articles.
10627 If N is a negative number, pipe the N previous articles.
10628 If N is nil and any articles have been marked with the process mark,
10629 pipe those articles instead.
10630 If HEADERS (the symbolic prefix), include the headers, too."
10631 (interactive (gnus-interactive "P\ny"))
10632 (require 'gnus-art)
10633 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10634 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10635 (gnus-summary-save-article arg t))
10636 (let ((buffer (get-buffer "*Shell Command Output*")))
10638 (not (zerop (buffer-size buffer))))
10639 (gnus-configure-windows 'pipe))))
10641 (defun gnus-summary-save-article-mail (&optional arg)
10642 "Append the current article to an mail file.
10643 If N is a positive number, save the N next articles.
10644 If N is a negative number, save the N previous articles.
10645 If N is nil and any articles have been marked with the process mark,
10646 save those articles instead."
10648 (require 'gnus-art)
10649 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10650 (gnus-summary-save-article arg)))
10652 (defun gnus-summary-save-article-rmail (&optional arg)
10653 "Append the current article to an rmail file.
10654 If N is a positive number, save the N next articles.
10655 If N is a negative number, save the N previous articles.
10656 If N is nil and any articles have been marked with the process mark,
10657 save those articles instead."
10659 (require 'gnus-art)
10660 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10661 (gnus-summary-save-article arg)))
10663 (defun gnus-summary-save-article-file (&optional arg)
10664 "Append the current article to a file.
10665 If N is a positive number, save the N next articles.
10666 If N is a negative number, save the N previous articles.
10667 If N is nil and any articles have been marked with the process mark,
10668 save those articles instead."
10670 (require 'gnus-art)
10671 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10672 (gnus-summary-save-article arg)))
10674 (defun gnus-summary-write-article-file (&optional arg)
10675 "Write the current article to a file, deleting the previous file.
10676 If N is a positive number, save the N next articles.
10677 If N is a negative number, save the N previous articles.
10678 If N is nil and any articles have been marked with the process mark,
10679 save those articles instead."
10681 (require 'gnus-art)
10682 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10683 (gnus-summary-save-article arg)))
10685 (defun gnus-summary-save-article-body-file (&optional arg)
10686 "Append the current article body to a file.
10687 If N is a positive number, save the N next articles.
10688 If N is a negative number, save the N previous articles.
10689 If N is nil and any articles have been marked with the process mark,
10690 save those articles instead."
10692 (require 'gnus-art)
10693 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10694 (gnus-summary-save-article arg)))
10696 (defun gnus-summary-muttprint (&optional arg)
10697 "Print the current article using Muttprint.
10698 If N is a positive number, save the N next articles.
10699 If N is a negative number, save the N previous articles.
10700 If N is nil and any articles have been marked with the process mark,
10701 save those articles instead."
10703 (require 'gnus-art)
10704 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10705 (gnus-summary-save-article arg t)))
10707 (defun gnus-summary-pipe-message (program)
10708 "Pipe the current article through PROGRAM."
10709 (interactive "sProgram: ")
10710 (gnus-summary-select-article)
10711 (let ((mail-header-separator ""))
10712 (gnus-eval-in-buffer-window gnus-article-buffer
10715 (let ((start (window-start))
10717 (message-pipe-buffer-body program)
10718 (set-window-start (get-buffer-window (current-buffer)) start))))))
10720 (defun gnus-get-split-value (methods)
10721 "Return a value based on the split METHODS."
10722 (let (split-name method result match)
10725 (set-buffer gnus-original-article-buffer)
10727 (nnheader-narrow-to-headers)
10728 (while (and methods (not split-name))
10729 (goto-char (point-min))
10730 (setq method (pop methods))
10731 (setq match (car method))
10734 ;; Regular expression.
10736 (re-search-forward match nil t)))
10737 ((gnus-functionp match)
10741 (setq result (funcall match gnus-newsgroup-name))))
10746 (setq result (eval match)))))
10747 (setq split-name (cdr method))
10748 (cond ((stringp result)
10749 (push (expand-file-name
10750 result gnus-article-save-directory)
10753 (setq split-name (append result split-name)))))))))
10754 (nreverse split-name)))
10756 (defun gnus-valid-move-group-p (group)
10757 (and (boundp group)
10758 (symbol-name group)
10759 (symbol-value group)
10760 (gnus-get-function (gnus-find-method-for-group
10761 (symbol-name group)) 'request-accept-article t)))
10763 (defun gnus-read-move-group-name (prompt default articles prefix)
10764 "Read a group name."
10765 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10766 (minibuffer-confirm-incomplete nil) ; XEmacs
10768 (format "%s %s to:"
10770 (if (> (length articles) 1)
10771 (format "these %d articles" (length articles))
10776 (gnus-completing-read-with-default
10779 'gnus-valid-move-group-p
10781 'gnus-group-history))
10782 ((= 1 (length split-name))
10783 (gnus-completing-read-with-default
10784 (car split-name) prom
10786 'gnus-valid-move-group-p
10788 'gnus-group-history))
10790 (gnus-completing-read-with-default
10792 (mapcar (lambda (el) (list el))
10793 (nreverse split-name))
10795 'gnus-group-history))))
10796 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10798 (if (or (string= to-newsgroup "")
10799 (string= to-newsgroup prefix))
10800 (setq to-newsgroup default))
10801 (unless to-newsgroup
10802 (error "No group name entered"))
10803 (or (gnus-active to-newsgroup)
10804 (gnus-activate-group to-newsgroup nil nil to-method)
10805 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10807 (or (and (gnus-request-create-group to-newsgroup to-method)
10808 (gnus-activate-group
10809 to-newsgroup nil nil to-method)
10810 (gnus-subscribe-group to-newsgroup))
10811 (error "Couldn't create group %s" to-newsgroup)))
10812 (error "No such group: %s" to-newsgroup)))
10815 (defun gnus-summary-save-parts (type dir n &optional reverse)
10816 "Save parts matching TYPE to DIR.
10817 If REVERSE, save parts that do not match TYPE."
10819 (list (read-string "Save parts of type: "
10820 (or (car gnus-summary-save-parts-type-history)
10821 gnus-summary-save-parts-default-mime)
10822 'gnus-summary-save-parts-type-history)
10823 (setq gnus-summary-save-parts-last-directory
10824 (read-file-name "Save to directory: "
10825 gnus-summary-save-parts-last-directory
10827 current-prefix-arg))
10828 (gnus-summary-iterate n
10829 (let ((gnus-display-mime-function nil)
10830 (gnus-inhibit-treatment t))
10831 (gnus-summary-select-article))
10833 (set-buffer gnus-article-buffer)
10834 (let ((handles (or gnus-article-mime-handles
10835 (mm-dissect-buffer nil gnus-article-loose-mime)
10836 (and gnus-article-emulate-mime
10837 (mm-uu-dissect)))))
10839 (gnus-summary-save-parts-1 type dir handles reverse)
10840 (unless gnus-article-mime-handles ;; Don't destroy this case.
10841 (mm-destroy-parts handles)))))))
10843 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10844 (if (stringp (car handle))
10845 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10848 (not (string-match type (mm-handle-media-type handle)))
10849 (string-match type (mm-handle-media-type handle)))
10850 (let ((file (expand-file-name
10851 (file-name-nondirectory
10853 (mail-content-type-get
10854 (mm-handle-disposition handle) 'filename)
10855 (concat gnus-newsgroup-name
10856 "." (number-to-string
10857 (cdr gnus-article-current)))))
10859 (unless (file-exists-p file)
10860 (mm-save-part-to-file handle file))))))
10862 ;; Summary extract commands
10864 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10865 (let ((buffer-read-only nil)
10866 (article (gnus-summary-article-number))
10868 (unless (gnus-summary-goto-subject article)
10869 (error "No such article: %d" article))
10870 (gnus-summary-position-point)
10871 ;; If all commands are to be bunched up on one line, we collect
10873 (unless gnus-view-pseudos-separately
10874 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10877 (setq action (cdr (assq 'action (car ps))))
10878 (setq files (list (cdr (assq 'name (car ps)))))
10879 (while (and ps (cdr ps)
10880 (string= (or action "1")
10881 (or (cdr (assq 'action (cadr ps))) "2")))
10882 (push (cdr (assq 'name (cadr ps))) files)
10883 (setcdr ps (cddr ps)))
10885 (when (not (string-match "%s" action))
10888 (when (assq 'execute (car ps))
10889 (setcdr (assq 'execute (car ps))
10890 (funcall (if (string-match "%s" action)
10899 (setq ps (cdr ps)))))
10900 (if (and gnus-view-pseudos (not not-view))
10902 (when (assq 'execute (car pslist))
10903 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10904 (eq gnus-view-pseudos 'not-confirm)))
10905 (setq pslist (cdr pslist)))
10908 (setq after-article (or (cdr (assq 'article (car pslist)))
10909 (gnus-summary-article-number)))
10910 (gnus-summary-goto-subject after-article)
10913 (insert " " (file-name-nondirectory
10914 (cdr (assq 'name (car pslist))))
10915 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10917 (forward-line -1) ; back to `b'
10918 (gnus-add-text-properties
10919 b (1- e) (list 'gnus-number gnus-reffed-article-number
10920 gnus-mouse-face-prop gnus-mouse-face))
10922 after-article gnus-reffed-article-number
10923 gnus-unread-mark b (car pslist) 0 (- e b))
10924 (setq gnus-newsgroup-unreads
10925 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10926 gnus-reffed-article-number))
10927 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10928 (setq pslist (cdr pslist)))))))
10930 (defun gnus-pseudos< (p1 p2)
10931 (let ((c1 (cdr (assq 'action p1)))
10932 (c2 (cdr (assq 'action p2))))
10933 (and c1 c2 (string< c1 c2))))
10935 (defun gnus-request-pseudo-article (props)
10936 (cond ((assq 'execute props)
10937 (gnus-execute-command (cdr (assq 'execute props)))))
10938 (let ((gnus-current-article (gnus-summary-article-number)))
10939 (gnus-run-hooks 'gnus-mark-article-hook)))
10941 (defun gnus-execute-command (command &optional automatic)
10943 (gnus-article-setup-buffer)
10944 (set-buffer gnus-article-buffer)
10945 (setq buffer-read-only nil)
10946 (let ((command (if automatic command
10947 (read-string "Command: " (cons command 0)))))
10949 (insert "$ " command "\n\n")
10950 (if gnus-view-pseudo-asynchronously
10951 (start-process "gnus-execute" (current-buffer) shell-file-name
10952 shell-command-switch command)
10953 (call-process shell-file-name nil t nil
10954 shell-command-switch command)))))
10956 ;; Summary kill commands.
10958 (defun gnus-summary-edit-global-kill (article)
10959 "Edit the \"global\" kill file."
10960 (interactive (list (gnus-summary-article-number)))
10961 (gnus-group-edit-global-kill article))
10963 (defun gnus-summary-edit-local-kill ()
10964 "Edit a local kill file applied to the current newsgroup."
10966 (setq gnus-current-headers (gnus-summary-article-header))
10967 (gnus-group-edit-local-kill
10968 (gnus-summary-article-number) gnus-newsgroup-name))
10970 ;;; Header reading.
10972 (defun gnus-read-header (id &optional header)
10973 "Read the headers of article ID and enter them into the Gnus system."
10974 (let ((group gnus-newsgroup-name)
10975 (gnus-override-method
10977 gnus-override-method
10978 (and (gnus-news-group-p gnus-newsgroup-name)
10979 (car (gnus-refer-article-methods)))))
10981 ;; First we check to see whether the header in question is already
10984 ;; This is a Message-ID.
10985 (setq header (or header (gnus-id-to-header id)))
10986 ;; This is an article number.
10987 (setq header (or header (gnus-summary-article-header id))))
10989 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10990 ;; We have found the header.
10992 ;; If this is a sparse article, we have to nix out its
10993 ;; previous entry in the thread hashtb.
10995 (gnus-summary-article-sparse-p (mail-header-number header)))
10996 (let* ((parent (gnus-parent-id (mail-header-references header)))
10997 (thread (and parent (gnus-id-to-thread parent))))
10999 (delq (assq header thread) thread))))
11000 ;; We have to really fetch the header to this article.
11002 (set-buffer nntp-server-buffer)
11003 (when (setq where (gnus-request-head id group))
11004 (nnheader-fold-continuation-lines)
11005 (goto-char (point-max))
11007 (goto-char (point-min))
11011 ((cdr where) (cdr where))
11012 (header (mail-header-number header))
11013 (t gnus-reffed-article-number))
11015 (insert " Article retrieved.\n"))
11016 (if (or (not where)
11017 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11018 () ; Malformed head.
11019 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11020 (when (and (stringp id)
11021 (not (string= (gnus-group-real-name group)
11023 ;; If we fetched by Message-ID and the article came
11024 ;; from a different group, we fudge some bogus article
11025 ;; numbers for this article.
11026 (mail-header-set-number header gnus-reffed-article-number))
11028 (set-buffer gnus-summary-buffer)
11029 (decf gnus-reffed-article-number)
11030 (gnus-remove-header (mail-header-number header))
11031 (push header gnus-newsgroup-headers)
11032 (setq gnus-current-headers header)
11033 (push (mail-header-number header) gnus-newsgroup-limit)))
11036 (defun gnus-remove-header (number)
11037 "Remove header NUMBER from `gnus-newsgroup-headers'."
11038 (if (and gnus-newsgroup-headers
11039 (= number (mail-header-number (car gnus-newsgroup-headers))))
11040 (pop gnus-newsgroup-headers)
11041 (let ((headers gnus-newsgroup-headers))
11042 (while (and (cdr headers)
11043 (not (= number (mail-header-number (cadr headers)))))
11045 (when (cdr headers)
11046 (setcdr headers (cddr headers))))))
11049 ;;; summary highlights
11052 (defun gnus-highlight-selected-summary ()
11053 "Highlight selected article in summary buffer."
11054 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11055 (when gnus-summary-selected-face
11057 (let* ((beg (progn (beginning-of-line) (point)))
11058 (end (progn (end-of-line) (point)))
11059 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11060 (from (if (get-text-property beg gnus-mouse-face-prop)
11062 (or (next-single-property-change
11063 beg gnus-mouse-face-prop nil end)
11068 (or (next-single-property-change
11069 from gnus-mouse-face-prop nil end)
11071 ;; If no mouse-face prop on line we will have to = from = end,
11072 ;; so we highlight the entire line instead.
11073 (when (= (+ to 2) from)
11076 (if gnus-newsgroup-selected-overlay
11077 ;; Move old overlay.
11079 gnus-newsgroup-selected-overlay from to (current-buffer))
11080 ;; Create new overlay.
11082 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11083 'face gnus-summary-selected-face))))))
11085 (defvar gnus-summary-highlight-line-cached nil)
11086 (defvar gnus-summary-highlight-line-trigger nil)
11088 (defun gnus-summary-highlight-line-0 ()
11089 (if (and (eq gnus-summary-highlight-line-trigger
11090 gnus-summary-highlight)
11091 gnus-summary-highlight-line-cached)
11092 gnus-summary-highlight-line-cached
11093 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11094 gnus-summary-highlight-line-cached
11095 (let* ((cond (list 'cond))
11097 (list gnus-summary-highlight))
11099 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11102 (gnus-byte-compile (list 'lambda nil cond))))))
11104 (defun gnus-summary-highlight-line ()
11105 "Highlight current line according to `gnus-summary-highlight'."
11106 (let* ((beg (gnus-point-at-bol))
11107 (article (or (gnus-summary-article-number) gnus-current-article))
11108 (score (or (cdr (assq article
11109 gnus-newsgroup-scored))
11110 gnus-summary-default-score 0))
11111 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11112 (inhibit-read-only t)
11113 (default gnus-summary-default-score)
11114 (default-high gnus-summary-default-high-score)
11115 (default-low gnus-summary-default-low-score)
11116 (uncached (memq article gnus-newsgroup-undownloaded))
11117 (downloaded (not uncached)))
11118 (let ((face (funcall (gnus-summary-highlight-line-0))))
11119 (unless (eq face (get-text-property beg 'face))
11120 (gnus-put-text-property-excluding-characters-with-faces
11121 beg (gnus-point-at-eol) 'face
11122 (setq face (if (boundp face) (symbol-value face) face)))
11123 (when gnus-summary-highlight-line-function
11124 (funcall gnus-summary-highlight-line-function article face))))))
11126 (defun gnus-update-read-articles (group unread &optional compute)
11127 "Update the list of read articles in GROUP.
11128 UNREAD is a sorted list."
11129 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11130 (entry (gnus-gethash group gnus-newsrc-hashtb))
11131 (info (nth 2 entry))
11134 (if (or (not info) (not active))
11135 ;; There is no info on this group if it was, in fact,
11136 ;; killed. Gnus stores no information on killed groups, so
11137 ;; there's nothing to be done.
11138 ;; One could store the information somewhere temporarily,
11139 ;; perhaps... Hmmm...
11141 ;; Remove any negative articles numbers.
11142 (while (and unread (< (car unread) 0))
11143 (setq unread (cdr unread)))
11144 ;; Remove any expired article numbers
11145 (while (and unread (< (car unread) (car active)))
11146 (setq unread (cdr unread)))
11147 ;; Compute the ranges of read articles by looking at the list of
11148 ;; unread articles.
11150 (when (/= (car unread) prev)
11151 (push (if (= prev (1- (car unread))) prev
11152 (cons prev (1- (car unread))))
11154 (setq prev (1+ (car unread)))
11155 (setq unread (cdr unread)))
11156 (when (<= prev (cdr active))
11157 (push (cons prev (cdr active)) read))
11158 (setq read (if (> (length read) 1) (nreverse read) read))
11163 ;; Propagate the read marks to the backend.
11164 (when (gnus-check-backend-function 'request-set-mark group)
11165 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11166 (add (gnus-remove-from-range read (gnus-info-read info))))
11168 (unless (gnus-check-group group)
11169 (error "Can't open server for %s" group))
11170 (gnus-request-set-mark
11171 group (delq nil (list (if add (list add 'add '(read)))
11172 (if del (list del 'del '(read))))))
11174 `(gnus-request-set-mark
11177 (if del (list del 'add '(read)))
11178 (if add (list add 'del '(read))))))))))
11179 (set-buffer gnus-group-buffer)
11180 (gnus-undo-register
11182 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11183 (gnus-info-set-read ',info ',(gnus-info-read info))
11184 (gnus-get-unread-articles-in-group ',info
11185 (gnus-active ,group))
11186 (gnus-group-update-group ,group t)
11188 ;; Enter this list into the group info.
11189 (gnus-info-set-read info read)
11190 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11191 (gnus-get-unread-articles-in-group info (gnus-active group))
11194 (defun gnus-offer-save-summaries ()
11195 "Offer to save all active summary buffers."
11197 ;; Go through all buffers and find all summaries.
11198 (dolist (buffer (buffer-list))
11199 (when (and (setq buffer (buffer-name buffer))
11200 (string-match "Summary" buffer)
11202 (set-buffer buffer)
11203 ;; We check that this is, indeed, a summary buffer.
11204 (and (eq major-mode 'gnus-summary-mode)
11205 ;; Also make sure this isn't bogus.
11206 gnus-newsgroup-prepared
11207 ;; Also make sure that this isn't a
11208 ;; dead summary buffer.
11209 (not gnus-dead-summary-mode))))
11210 (push buffer buffers)))
11211 ;; Go through all these summary buffers and offer to save them.
11215 "Update summary buffer %s? "
11217 (switch-to-buffer buf)
11218 (gnus-summary-exit))
11221 (defun gnus-summary-setup-default-charset ()
11222 "Setup newsgroup default charset."
11223 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11224 (setq gnus-newsgroup-charset nil)
11225 (let* ((ignored-charsets
11226 (or gnus-newsgroup-ephemeral-ignored-charsets
11228 (and gnus-newsgroup-name
11229 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11230 gnus-newsgroup-ignored-charsets))))
11231 (setq gnus-newsgroup-charset
11232 (or gnus-newsgroup-ephemeral-charset
11233 (and gnus-newsgroup-name
11234 (gnus-parameter-charset gnus-newsgroup-name))
11235 gnus-default-charset))
11236 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11237 ignored-charsets))))
11243 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11244 "Display the current article buffer fully MIME-buttonized.
11245 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11246 treated as multipart/mixed."
11248 (require 'gnus-art)
11249 (let ((gnus-unbuttonized-mime-types nil)
11250 (gnus-mime-display-multipart-as-mixed show-all-parts))
11251 (gnus-summary-show-article)))
11253 (defun gnus-summary-repair-multipart (article)
11254 "Add a Content-Type header to a multipart article without one."
11255 (interactive (list (gnus-summary-article-number)))
11256 (gnus-with-article article
11257 (message-narrow-to-head)
11258 (message-remove-header "Mime-Version")
11259 (goto-char (point-max))
11260 (insert "Mime-Version: 1.0\n")
11262 (when (search-forward "\n--" nil t)
11263 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11264 (message-narrow-to-head)
11265 (message-remove-header "Content-Type")
11266 (goto-char (point-max))
11267 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11270 (let (gnus-mark-article-hook)
11271 (gnus-summary-select-article t t nil article)))
11273 (defun gnus-summary-toggle-display-buttonized ()
11274 "Toggle the buttonizing of the article buffer."
11276 (require 'gnus-art)
11277 (if (setq gnus-inhibit-mime-unbuttonizing
11278 (not gnus-inhibit-mime-unbuttonizing))
11279 (let ((gnus-unbuttonized-mime-types nil))
11280 (gnus-summary-show-article))
11281 (gnus-summary-show-article)))
11284 ;;; Generic summary marking commands
11287 (defvar gnus-summary-marking-alist
11288 '((read gnus-del-mark "d")
11289 (unread gnus-unread-mark "u")
11290 (ticked gnus-ticked-mark "!")
11291 (dormant gnus-dormant-mark "?")
11292 (expirable gnus-expirable-mark "e"))
11293 "An alist of names/marks/keystrokes.")
11295 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11296 (defvar gnus-summary-mark-map)
11298 (defun gnus-summary-make-all-marking-commands ()
11299 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11300 (dolist (elem gnus-summary-marking-alist)
11301 (apply 'gnus-summary-make-marking-command elem)))
11303 (defun gnus-summary-make-marking-command (name mark keystroke)
11304 (let ((map (make-sparse-keymap)))
11305 (define-key gnus-summary-generic-mark-map keystroke map)
11306 (dolist (lway `((next "next" next nil "n")
11307 (next-unread "next unread" next t "N")
11308 (prev "previous" prev nil "p")
11309 (prev-unread "previous unread" prev t "P")
11310 (nomove "" nil nil ,keystroke)))
11311 (let ((func (gnus-summary-make-marking-command-1
11312 mark (car lway) lway name)))
11313 (setq func (eval func))
11314 (define-key map (nth 4 lway) func)))))
11316 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11318 (format "gnus-summary-put-mark-as-%s%s"
11319 name (if (eq way 'nomove)
11321 (concat "-" (symbol-name way)))))
11324 "Mark the current article as %s%s.
11325 If N, the prefix, then repeat N times.
11326 If N is negative, move in reverse order.
11327 The difference between N and the actual number of articles marked is
11331 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11333 (defun gnus-summary-generic-mark (n mark move unread)
11334 "Mark N articles with MARK."
11335 (unless (eq major-mode 'gnus-summary-mode)
11336 (error "This command can only be used in the summary buffer"))
11337 (gnus-summary-show-thread)
11340 ((eq move 'next) 1)
11341 ((eq move 'prev) -1)
11343 (if (zerop nummove)
11347 nummove (* -1 nummove))))
11348 (while (and (> n 0)
11349 (gnus-summary-mark-article nil mark)
11350 (zerop (gnus-summary-next-subject nummove unread t)))
11353 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11354 (gnus-summary-recenter)
11355 (gnus-summary-position-point)
11356 (gnus-set-mode-line 'summary)
11359 (defun gnus-summary-insert-articles (articles)
11360 (when (setq articles
11361 (gnus-sorted-difference articles
11362 (mapcar (lambda (h)
11363 (mail-header-number h))
11364 gnus-newsgroup-headers)))
11365 (setq gnus-newsgroup-headers
11367 gnus-newsgroup-headers
11368 (gnus-fetch-headers articles)
11369 'gnus-article-sort-by-number))
11370 ;; Suppress duplicates?
11371 (when gnus-suppress-duplicates
11372 (gnus-dup-suppress-articles))
11374 ;; We might want to build some more threads first.
11375 (when (and gnus-fetch-old-headers
11376 (eq gnus-headers-retrieved-by 'nov))
11377 (if (eq gnus-fetch-old-headers 'invisible)
11378 (gnus-build-all-threads)
11379 (gnus-build-old-threads)))
11380 ;; Let the Gnus agent mark articles as read.
11382 (gnus-agent-get-undownloaded-list))
11383 ;; Remove list identifiers from subject
11384 (when gnus-list-identifiers
11385 (gnus-summary-remove-list-identifiers))
11386 ;; First and last article in this newsgroup.
11387 (when gnus-newsgroup-headers
11388 (setq gnus-newsgroup-begin
11389 (mail-header-number (car gnus-newsgroup-headers))
11391 (mail-header-number
11392 (gnus-last-element gnus-newsgroup-headers))))
11393 (when gnus-use-scoring
11394 (gnus-possibly-score-headers))))
11396 (defun gnus-summary-insert-old-articles (&optional all)
11397 "Insert all old articles in this group.
11398 If ALL is non-nil, already read articles become readable.
11399 If ALL is a number, fetch this number of articles."
11402 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11405 ;; Some nntp servers lie about their active range. When
11406 ;; this happens, the active range can be in the millions.
11407 ;; Use a compressed range to avoid creating a huge list.
11408 (gnus-range-difference (list gnus-newsgroup-active) old))
11409 (setq len (gnus-range-length older))
11414 (let ((older-range (nreverse older)))
11418 (let* ((r (pop older-range))
11419 (min (if (numberp r) r (car r)))
11420 (max (if (numberp r) r (cdr r))))
11421 (while (and (<= min max)
11426 (setq older (gnus-uncompress-range older))))
11428 (setq older (gnus-uncompress-range older)))
11430 (when (and (numberp gnus-large-newsgroup)
11431 (> len gnus-large-newsgroup))
11432 (let* ((cursor-in-echo-area nil)
11433 (initial (gnus-parameter-large-newsgroup-initial
11434 gnus-newsgroup-name))
11438 "How many articles from %s (%s %d): "
11440 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11441 (if initial "max" "default")
11444 (cons (number-to-string initial)
11446 (unless (string-match "^[ \t]*$" input)
11447 (setq all (string-to-number input))
11449 (let ((older-range (nreverse older)))
11453 (let* ((r (pop older-range))
11454 (min (if (numberp r) r (car r)))
11455 (max (if (numberp r) r (cdr r))))
11456 (while (and (<= min max)
11460 max (1- max))))))))))
11461 (setq older (gnus-uncompress-range older))))
11463 (message "No old news.")
11464 (gnus-summary-insert-articles older)
11465 (gnus-summary-limit (gnus-sorted-nunion old older))))
11466 (gnus-summary-position-point)))
11468 (defun gnus-summary-insert-new-articles ()
11469 "Insert all new articles in this group."
11472 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11473 (old-active gnus-newsgroup-active)
11474 (nnmail-fetched-sources (list t))
11476 (setq gnus-newsgroup-active
11477 (gnus-activate-group gnus-newsgroup-name 'scan))
11478 (setq i (cdr gnus-newsgroup-active))
11479 (while (> i (cdr old-active))
11483 (message "No gnus is bad news.")
11484 (gnus-summary-insert-articles new)
11485 (setq gnus-newsgroup-unreads
11486 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11487 (gnus-summary-limit (gnus-sorted-nunion old new))))
11488 (gnus-summary-position-point)))
11490 (gnus-summary-make-all-marking-commands)
11492 (gnus-ems-redefine)
11494 (provide 'gnus-sum)
11496 (run-hooks 'gnus-sum-load-hook)
11498 ;;; gnus-sum.el ends here