1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
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."
50 (defcustom gnus-kill-summary-on-exit t
51 "*If non-nil, kill the summary buffer when you exit from it.
52 If nil, the summary will become a \"*Dead Summary*\" buffer, and
53 it will be killed sometime later."
54 :group 'gnus-summary-exit
57 (defcustom gnus-fetch-old-headers nil
58 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
59 If an unread article in the group refers to an older, already read (or
60 just marked as read) article, the old article will not normally be
61 displayed in the Summary buffer. If this variable is non-nil, Gnus
62 will attempt to grab the headers to the old articles, and thereby
63 build complete threads. If it has the value `some', only enough
64 headers to connect otherwise loose threads will be displayed. This
65 variable can also be a number. In that case, no more than that number
66 of old headers will be fetched. If it has the value `invisible', all
67 old headers will be fetched, but none will be displayed.
69 The server has to support NOV for any of this to work."
71 :type '(choice (const :tag "off" nil)
74 (sexp :menu-tag "other" t)))
76 (defcustom gnus-refer-thread-limit 200
77 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
78 If t, fetch all the available old headers."
81 (sexp :menu-tag "other" t)))
83 (defcustom gnus-summary-make-false-root 'adopt
84 "*nil means that Gnus won't gather loose threads.
85 If the root of a thread has expired or been read in a previous
86 session, the information necessary to build a complete thread has been
87 lost. Instead of having many small sub-threads from this original thread
88 scattered all over the summary buffer, Gnus can gather them.
90 If non-nil, Gnus will try to gather all loose sub-threads from an
91 original thread into one large thread.
93 If this variable is non-nil, it should be one of `none', `adopt',
96 If this variable is `none', Gnus will not make a false root, but just
97 present the sub-threads after another.
98 If this variable is `dummy', Gnus will create a dummy root that will
99 have all the sub-threads as children.
100 If this variable is `adopt', Gnus will make one of the \"children\"
101 the parent and mark all the step-children as such.
102 If this variable is `empty', the \"children\" are printed with empty
103 subject fields. (Or rather, they will be printed with a string
104 given by the `gnus-summary-same-subject' variable.)"
106 :type '(choice (const :tag "off" nil)
112 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
113 "*A regexp to match subjects to be excluded from loose thread gathering.
114 As loose thread gathering is done on subjects only, that means that
115 there can be many false gatherings performed. By rooting out certain
116 common subjects, gathering might become saner."
120 (defcustom gnus-summary-gather-subject-limit nil
121 "*Maximum length of subject comparisons when gathering loose threads.
122 Use nil to compare full subjects. Setting this variable to a low
123 number will help gather threads that have been corrupted by
124 newsreaders chopping off subject lines, but it might also mean that
125 unrelated articles that have subject that happen to begin with the
126 same few characters will be incorrectly gathered.
128 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
131 :type '(choice (const :tag "off" nil)
133 (sexp :menu-tag "on" t)))
135 (defcustom gnus-simplify-subject-functions nil
136 "List of functions taking a string argument that simplify subjects.
137 The functions are applied recursively.
139 Useful functions to put in this list include:
140 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
141 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
143 :type '(repeat function))
145 (defcustom gnus-simplify-ignored-prefixes nil
146 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
148 :type '(choice (const :tag "off" nil)
151 (defcustom gnus-build-sparse-threads nil
152 "*If non-nil, fill in the gaps in threads.
153 If `some', only fill in the gaps that are needed to tie loose threads
154 together. If `more', fill in all leaf nodes that Gnus can find. If
155 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
157 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "all" t)))
162 (defcustom gnus-summary-thread-gathering-function
163 'gnus-gather-threads-by-subject
164 "*Function used for gathering loose threads.
165 There are two pre-defined functions: `gnus-gather-threads-by-subject',
166 which only takes Subjects into consideration; and
167 `gnus-gather-threads-by-references', which compared the References
168 headers of the articles to find matches."
170 :type '(radio (function-item gnus-gather-threads-by-subject)
171 (function-item gnus-gather-threads-by-references)
172 (function :tag "other")))
174 (defcustom gnus-summary-same-subject ""
175 "*String indicating that the current article has the same subject as the previous.
176 This variable will only be used if the value of
177 `gnus-summary-make-false-root' is `empty'."
178 :group 'gnus-summary-format
181 (defcustom gnus-summary-goto-unread t
182 "*If t, many commands will go to the next unread article.
183 This applies to marking commands as well as other commands that
184 \"naturally\" select the next article, like, for instance, `SPC' at
185 the end of an article.
187 If nil, the marking commands do NOT go to the next unread article
188 (they go to the next article instead). If `never', commands that
189 usually go to the next unread article, will go to the next article,
190 whether it is read or not."
191 :group 'gnus-summary-marks
192 :link '(custom-manual "(gnus)Setting Marks")
193 :type '(choice (const :tag "off" nil)
195 (sexp :menu-tag "on" t)))
197 (defcustom gnus-summary-default-score 0
198 "*Default article score level.
199 All scores generated by the score files will be added to this score.
200 If this variable is nil, scoring will be disabled."
201 :group 'gnus-score-default
202 :type '(choice (const :tag "disable")
205 (defcustom gnus-summary-default-high-score 0
206 "*Default threshold for a high scored article.
207 An article will be highlighted as high scored if its score is greater
209 :group 'gnus-score-default
212 (defcustom gnus-summary-default-low-score 0
213 "*Default threshold for a low scored article.
214 An article will be highlighted as low scored if its score is smaller
216 :group 'gnus-score-default
219 (defcustom gnus-summary-zcore-fuzz 0
220 "*Fuzziness factor for the zcore in the summary buffer.
221 Articles with scores closer than this to `gnus-summary-default-score'
223 :group 'gnus-summary-format
226 (defcustom gnus-simplify-subject-fuzzy-regexp nil
227 "*Strings to be removed when doing fuzzy matches.
228 This can either be a regular expression or list of regular expressions
229 that will be removed from subject strings if fuzzy subject
230 simplification is selected."
232 :type '(repeat regexp))
234 (defcustom gnus-show-threads t
235 "*If non-nil, display threads in summary mode."
239 (defcustom gnus-thread-hide-subtree nil
240 "*If non-nil, hide all threads initially.
241 This can be a predicate specifier which says which threads to hide.
242 If threads are hidden, you have to run the command
243 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
244 to expose hidden threads."
248 (defcustom gnus-thread-hide-killed t
249 "*If non-nil, hide killed threads automatically."
253 (defcustom gnus-thread-ignore-subject t
254 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
255 If nil, articles that have different subjects from their parents will
256 start separate threads."
260 (defcustom gnus-thread-operation-ignore-subject t
261 "*If non-nil, subjects will be ignored when doing thread commands.
262 This affects commands like `gnus-summary-kill-thread' and
263 `gnus-summary-lower-thread'.
265 If this variable is nil, articles in the same thread with different
266 subjects will not be included in the operation in question. If this
267 variable is `fuzzy', only articles that have subjects that are fuzzily
268 equal will be included."
270 :type '(choice (const :tag "off" nil)
274 (defcustom gnus-thread-indent-level 4
275 "*Number that says how much each sub-thread should be indented."
279 (defcustom gnus-auto-extend-newsgroup t
280 "*If non-nil, extend newsgroup forward and backward when requested."
281 :group 'gnus-summary-choose
284 (defcustom gnus-auto-select-first t
285 "*If non-nil, select the article under point.
286 Which article this is is controlled by the `gnus-auto-select-subject'
289 If you want to prevent automatic selection of articles in some
290 newsgroups, set the variable to nil in `gnus-select-group-hook'."
291 :group 'gnus-group-select
292 :type '(choice (const :tag "none" nil)
293 (sexp :menu-tag "first" t)))
295 (defcustom gnus-auto-select-subject 'unread
296 "*Says what subject to place under point when entering a group.
298 This variable can either be the symbols `first' (place point on the
299 first subject), `unread' (place point on the subject line of the first
300 unread article), `best' (place point on the subject line of the
301 higest-scored article), `unseen' (place point on the subject line of
302 the first unseen article), 'unseen-or-unread' (place point on the subject
303 line of the first unseen article or, if all article have been seen, on the
304 subject line of the first unread article), or a function to be called to
305 place point on some subject line."
306 :group 'gnus-group-select
307 :type '(choice (const best)
311 (const unseen-or-unread)))
313 (defcustom gnus-auto-select-next t
314 "*If non-nil, offer to go to the next group from the end of the previous.
315 If the value is t and the next newsgroup is empty, Gnus will exit
316 summary mode and go back to group mode. If the value is neither nil
317 nor t, Gnus will select the following unread newsgroup. In
318 particular, if the value is the symbol `quietly', the next unread
319 newsgroup will be selected without any confirmation, and if it is
320 `almost-quietly', the next group will be selected without any
321 confirmation if you are located on the last article in the group.
322 Finally, if this variable is `slightly-quietly', the `Z n' command
323 will go to the next group without confirmation."
324 :group 'gnus-summary-maneuvering
325 :type '(choice (const :tag "off" nil)
327 (const almost-quietly)
328 (const slightly-quietly)
329 (sexp :menu-tag "on" t)))
331 (defcustom gnus-auto-select-same nil
332 "*If non-nil, select the next article with the same subject.
333 If there are no more articles with the same subject, go to
334 the first unread article."
335 :group 'gnus-summary-maneuvering
338 (defcustom gnus-summary-check-current nil
339 "*If non-nil, consider the current article when moving.
340 The \"unread\" movement commands will stay on the same line if the
341 current article is unread."
342 :group 'gnus-summary-maneuvering
345 (defcustom gnus-auto-center-summary t
346 "*If non-nil, always center the current summary buffer.
347 In particular, if `vertical' do only vertical recentering. If non-nil
348 and non-`vertical', do both horizontal and vertical recentering."
349 :group 'gnus-summary-maneuvering
350 :type '(choice (const :tag "none" nil)
352 (integer :tag "height")
353 (sexp :menu-tag "both" t)))
355 (defcustom gnus-show-all-headers nil
356 "*If non-nil, don't hide any headers."
357 :group 'gnus-article-hiding
358 :group 'gnus-article-headers
361 (defcustom gnus-summary-ignore-duplicates nil
362 "*If non-nil, ignore articles with identical Message-ID headers."
366 (defcustom gnus-single-article-buffer t
367 "*If non-nil, display all articles in the same buffer.
368 If nil, each group will get its own article buffer."
369 :group 'gnus-article-various
372 (defcustom gnus-break-pages t
373 "*If non-nil, do page breaking on articles.
374 The page delimiter is specified by the `gnus-page-delimiter'
376 :group 'gnus-article-various
379 (defcustom gnus-move-split-methods nil
380 "*Variable used to suggest where articles are to be moved to.
381 It uses the same syntax as the `gnus-split-methods' variable.
382 However, whereas `gnus-split-methods' specifies file names as targets,
383 this variable specifies group names."
384 :group 'gnus-summary-mail
385 :type '(repeat (choice (list :value (fun) function)
386 (cons :value ("" "") regexp (repeat string))
389 (defcustom gnus-unread-mark ? ;Whitespace
390 "*Mark used for unread articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-ticked-mark ?!
395 "*Mark used for ticked articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-dormant-mark ??
400 "*Mark used for dormant articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-del-mark ?r
405 "*Mark used for del'd articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-read-mark ?R
410 "*Mark used for read articles."
411 :group 'gnus-summary-marks
414 (defcustom gnus-expirable-mark ?E
415 "*Mark used for expirable articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-killed-mark ?K
420 "*Mark used for killed articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-spam-mark ?H
425 "*Mark used for spam articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-souped-mark ?F
430 "*Mark used for souped articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-kill-file-mark ?X
435 "*Mark used for articles killed by kill files."
436 :group 'gnus-summary-marks
439 (defcustom gnus-low-score-mark ?Y
440 "*Mark used for articles with a low score."
441 :group 'gnus-summary-marks
444 (defcustom gnus-catchup-mark ?C
445 "*Mark used for articles that are caught up."
446 :group 'gnus-summary-marks
449 (defcustom gnus-replied-mark ?A
450 "*Mark used for articles that have been replied to."
451 :group 'gnus-summary-marks
454 (defcustom gnus-forwarded-mark ?F
455 "*Mark used for articles that have been forwarded."
456 :group 'gnus-summary-marks
459 (defcustom gnus-recent-mark ?N
460 "*Mark used for articles that are recent."
461 :group 'gnus-summary-marks
464 (defcustom gnus-cached-mark ?*
465 "*Mark used for articles that are in the cache."
466 :group 'gnus-summary-marks
469 (defcustom gnus-saved-mark ?S
470 "*Mark used for articles that have been saved."
471 :group 'gnus-summary-marks
474 (defcustom gnus-unseen-mark ?.
475 "*Mark used for articles that haven't been seen."
476 :group 'gnus-summary-marks
479 (defcustom gnus-no-mark ? ;Whitespace
480 "*Mark used for articles that have no other secondary mark."
481 :group 'gnus-summary-marks
484 (defcustom gnus-ancient-mark ?O
485 "*Mark used for ancient articles."
486 :group 'gnus-summary-marks
489 (defcustom gnus-sparse-mark ?Q
490 "*Mark used for sparsely reffed articles."
491 :group 'gnus-summary-marks
494 (defcustom gnus-canceled-mark ?G
495 "*Mark used for canceled articles."
496 :group 'gnus-summary-marks
499 (defcustom gnus-duplicate-mark ?M
500 "*Mark used for duplicate articles."
501 :group 'gnus-summary-marks
504 (defcustom gnus-undownloaded-mark ?@
505 "*Mark used for articles that weren't downloaded."
506 :group 'gnus-summary-marks
509 (defcustom gnus-downloadable-mark ?%
510 "*Mark used for articles that are to be downloaded."
511 :group 'gnus-summary-marks
514 (defcustom gnus-unsendable-mark ?=
515 "*Mark used for articles that won't be sent."
516 :group 'gnus-summary-marks
519 (defcustom gnus-score-over-mark ?+
520 "*Score mark used for articles with high scores."
521 :group 'gnus-summary-marks
524 (defcustom gnus-score-below-mark ?-
525 "*Score mark used for articles with low scores."
526 :group 'gnus-summary-marks
529 (defcustom gnus-empty-thread-mark ? ;Whitespace
530 "*There is no thread under the article."
531 :group 'gnus-summary-marks
534 (defcustom gnus-not-empty-thread-mark ?=
535 "*There is a thread under the article."
536 :group 'gnus-summary-marks
539 (defcustom gnus-view-pseudo-asynchronously nil
540 "*If non-nil, Gnus will view pseudo-articles asynchronously."
541 :group 'gnus-extract-view
544 (defcustom gnus-auto-expirable-marks
545 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
546 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
547 gnus-souped-mark gnus-duplicate-mark)
548 "*The list of marks converted into expiration if a group is auto-expirable."
551 :type '(repeat character))
553 (defcustom gnus-inhibit-user-auto-expire t
554 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
559 (defcustom gnus-view-pseudos nil
560 "*If `automatic', pseudo-articles will be viewed automatically.
561 If `not-confirm', pseudos will be viewed automatically, and the user
562 will not be asked to confirm the command."
563 :group 'gnus-extract-view
564 :type '(choice (const :tag "off" nil)
566 (const not-confirm)))
568 (defcustom gnus-view-pseudos-separately t
569 "*If non-nil, one pseudo-article will be created for each file to be viewed.
570 If nil, all files that use the same viewing command will be given as a
571 list of parameters to that command."
572 :group 'gnus-extract-view
575 (defcustom gnus-insert-pseudo-articles t
576 "*If non-nil, insert pseudo-articles when decoding articles."
577 :group 'gnus-extract-view
580 (defcustom gnus-summary-dummy-line-format
582 "*The format specification for the dummy roots in the summary buffer.
583 It works along the same lines as a normal formatting string,
584 with some simple extensions.
588 General format specifiers can also be used.
589 See `(gnus)Formatting Variables'."
590 :link '(custom-manual "(gnus)Formatting Variables")
591 :group 'gnus-threading
594 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
595 "*The format specification for the summary mode line.
596 It works along the same lines as a normal formatting string,
597 with some simple extensions:
600 %p Unprefixed group name
601 %A Current article number
602 %z Current article score
604 %U Number of unread articles in the group
605 %e Number of unselected articles in the group
606 %Z A string with unread/unselected article counts
607 %g Shortish group name
608 %S Subject of the current article
610 %s Current score file name
611 %d Number of dormant articles
612 %r Number of articles that have been marked as read in this session
613 %E Number of articles expunged by the score files"
614 :group 'gnus-summary-format
617 (defcustom gnus-list-identifiers nil
618 "Regexp that matches list identifiers to be removed from subject.
619 This can also be a list of regexps."
621 :group 'gnus-summary-format
622 :group 'gnus-article-hiding
623 :type '(choice (const :tag "none" nil)
625 (repeat :value (".*") regexp)))
627 (defcustom gnus-summary-mark-below 0
628 "*Mark all articles with a score below this variable as read.
629 This variable is local to each summary buffer and usually set by the
631 :group 'gnus-score-default
634 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
635 "*List of functions used for sorting articles in the summary buffer.
637 Each function takes two articles and returns non-nil if the first
638 article should be sorted before the other. If you use more than one
639 function, the primary sort function should be the last. You should
640 probably always include `gnus-article-sort-by-number' in the list of
641 sorting functions -- preferably first. Also note that sorting by date
642 is often much slower than sorting by number, and the sorting order is
643 very similar. (Sorting by date means sorting by the time the message
644 was sent, sorting by number means sorting by arrival time.)
646 Ready-made functions include `gnus-article-sort-by-number',
647 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
648 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
649 and `gnus-article-sort-by-score'.
651 When threading is turned on, the variable `gnus-thread-sort-functions'
652 controls how articles are sorted."
653 :group 'gnus-summary-sort
654 :type '(repeat (choice (function-item gnus-article-sort-by-number)
655 (function-item gnus-article-sort-by-author)
656 (function-item gnus-article-sort-by-subject)
657 (function-item gnus-article-sort-by-date)
658 (function-item gnus-article-sort-by-score)
659 (function-item gnus-article-sort-by-random)
660 (function :tag "other"))))
662 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
663 "*List of functions used for sorting threads in the summary buffer.
664 By default, threads are sorted by article number.
666 Each function takes two threads and returns non-nil if the first
667 thread should be sorted before the other. If you use more than one
668 function, the primary sort function should be the last. You should
669 probably always include `gnus-thread-sort-by-number' in the list of
670 sorting functions -- preferably first. Also note that sorting by date
671 is often much slower than sorting by number, and the sorting order is
672 very similar. (Sorting by date means sorting by the time the message
673 was sent, sorting by number means sorting by arrival time.)
675 Ready-made functions include `gnus-thread-sort-by-number',
676 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
677 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
678 `gnus-thread-sort-by-most-recent-number',
679 `gnus-thread-sort-by-most-recent-date',
680 `gnus-thread-sort-by-random', and
681 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
683 When threading is turned off, the variable
684 `gnus-article-sort-functions' controls how articles are sorted."
685 :group 'gnus-summary-sort
686 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
687 (function-item gnus-thread-sort-by-author)
688 (function-item gnus-thread-sort-by-subject)
689 (function-item gnus-thread-sort-by-date)
690 (function-item gnus-thread-sort-by-score)
691 (function-item gnus-thread-sort-by-total-score)
692 (function-item gnus-thread-sort-by-random)
693 (function :tag "other"))))
695 (defcustom gnus-thread-score-function '+
696 "*Function used for calculating the total score of a thread.
698 The function is called with the scores of the article and each
699 subthread and should then return the score of the thread.
701 Some functions you can use are `+', `max', or `min'."
702 :group 'gnus-summary-sort
705 (defcustom gnus-summary-expunge-below nil
706 "All articles that have a score less than this variable will be expunged.
707 This variable is local to the summary buffers."
708 :group 'gnus-score-default
709 :type '(choice (const :tag "off" nil)
712 (defcustom gnus-thread-expunge-below nil
713 "All threads that have a total score less than this variable will be expunged.
714 See `gnus-thread-score-function' for en explanation of what a
717 This variable is local to the summary buffers."
718 :group 'gnus-threading
719 :group 'gnus-score-default
720 :type '(choice (const :tag "off" nil)
723 (defcustom gnus-summary-mode-hook nil
724 "*A hook for Gnus summary mode.
725 This hook is run before any variables are set in the summary buffer."
726 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
727 :group 'gnus-summary-various
730 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
731 (when (featurep 'xemacs)
732 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
733 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
734 (add-hook 'gnus-summary-mode-hook
735 'gnus-xmas-switch-horizontal-scrollbar-off))
737 (defcustom gnus-summary-menu-hook nil
738 "*Hook run after the creation of the summary mode menu."
739 :group 'gnus-summary-visual
742 (defcustom gnus-summary-exit-hook nil
743 "*A hook called on exit from the summary buffer.
744 It will be called with point in the group buffer."
745 :group 'gnus-summary-exit
748 (defcustom gnus-summary-prepare-hook nil
749 "*A hook called after the summary buffer has been generated.
750 If you want to modify the summary buffer, you can use this hook."
751 :group 'gnus-summary-various
754 (defcustom gnus-summary-prepared-hook nil
755 "*A hook called as the last thing after the summary buffer has been generated."
756 :group 'gnus-summary-various
759 (defcustom gnus-summary-generate-hook nil
760 "*A hook run just before generating the summary buffer.
761 This hook is commonly used to customize threading variables and the
763 :group 'gnus-summary-various
766 (defcustom gnus-select-group-hook nil
767 "*A hook called when a newsgroup is selected.
769 If you'd like to simplify subjects like the
770 `gnus-summary-next-same-subject' command does, you can use the
773 (add-hook gnus-select-group-hook
775 (mapcar (lambda (header)
776 (mail-header-set-subject
778 (gnus-simplify-subject
779 (mail-header-subject header) 're-only)))
780 gnus-newsgroup-headers)))"
781 :group 'gnus-group-select
784 (defcustom gnus-select-article-hook nil
785 "*A hook called when an article is selected."
786 :group 'gnus-summary-choose
789 (defcustom gnus-visual-mark-article-hook
790 (list 'gnus-highlight-selected-summary)
791 "*Hook run after selecting an article in the summary buffer.
792 It is meant to be used for highlighting the article in some way. It
793 is not run if `gnus-visual' is nil."
794 :group 'gnus-summary-visual
797 (defcustom gnus-parse-headers-hook nil
798 "*A hook called before parsing the headers."
802 (defcustom gnus-exit-group-hook nil
803 "*A hook called when exiting summary mode.
804 This hook is not called from the non-updating exit commands like `Q'."
808 (defcustom gnus-summary-update-hook
809 (list 'gnus-summary-highlight-line)
810 "*A hook called when a summary line is changed.
811 The hook will not be called if `gnus-visual' is nil.
813 The default function `gnus-summary-highlight-line' will
814 highlight the line according to the `gnus-summary-highlight'
816 :group 'gnus-summary-visual
819 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
820 "*A hook called when an article is selected for the first time.
821 The hook is intended to mark an article as read (or unread)
822 automatically when it is selected."
823 :group 'gnus-summary-choose
826 (defcustom gnus-group-no-more-groups-hook nil
827 "*A hook run when returning to group mode having no more (unread) groups."
828 :group 'gnus-group-select
831 (defcustom gnus-ps-print-hook nil
832 "*A hook run before ps-printing something from Gnus."
836 (defcustom gnus-summary-display-arrow
837 (and (fboundp 'display-graphic-p)
839 "*If non-nil, display an arrow highlighting the current article."
844 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
845 "Face used for highlighting the current article in the summary buffer."
846 :group 'gnus-summary-visual
849 (defcustom gnus-summary-highlight
850 '(((eq mark gnus-canceled-mark)
851 . gnus-summary-cancelled-face)
852 ((and (> score default-high)
853 (or (eq mark gnus-dormant-mark)
854 (eq mark gnus-ticked-mark)))
855 . gnus-summary-high-ticked-face)
856 ((and (< score default-low)
857 (or (eq mark gnus-dormant-mark)
858 (eq mark gnus-ticked-mark)))
859 . gnus-summary-low-ticked-face)
860 ((or (eq mark gnus-dormant-mark)
861 (eq mark gnus-ticked-mark))
862 . gnus-summary-normal-ticked-face)
863 ((and (> score default-high) (eq mark gnus-ancient-mark))
864 . gnus-summary-high-ancient-face)
865 ((and (< score default-low) (eq mark gnus-ancient-mark))
866 . gnus-summary-low-ancient-face)
867 ((eq mark gnus-ancient-mark)
868 . gnus-summary-normal-ancient-face)
869 ((and (> score default-high) (eq mark gnus-unread-mark))
870 . gnus-summary-high-unread-face)
871 ((and (< score default-low) (eq mark gnus-unread-mark))
872 . gnus-summary-low-unread-face)
873 ((eq mark gnus-unread-mark)
874 . gnus-summary-normal-unread-face)
875 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
876 gnus-undownloaded-mark)))
877 . gnus-summary-high-unread-face)
878 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
879 gnus-undownloaded-mark)))
880 . gnus-summary-low-unread-face)
881 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
882 (memq article gnus-newsgroup-unreads))
883 . gnus-summary-normal-unread-face)
884 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
885 . gnus-summary-normal-read-face)
886 ((> score default-high)
887 . gnus-summary-high-read-face)
888 ((< score default-low)
889 . gnus-summary-low-read-face)
891 . gnus-summary-normal-read-face))
892 "*Controls the highlighting of summary buffer lines.
894 A list of (FORM . FACE) pairs. When deciding how a a particular
895 summary line should be displayed, each form is evaluated. The content
896 of the face field after the first true form is used. You can change
897 how those summary lines are displayed, by editing the face field.
899 You can use the following variables in the FORM field.
901 score: The article's score
902 default: The default article score.
903 default-high: The default score for high scored articles.
904 default-low: The default score for low scored articles.
905 below: The score below which articles are automatically marked as read.
906 mark: The articles mark."
907 :group 'gnus-summary-visual
908 :type '(repeat (cons (sexp :tag "Form" nil)
911 (defcustom gnus-alter-header-function nil
912 "Function called to allow alteration of article header structures.
913 The function is called with one parameter, the article header vector,
914 which it may alter in any way.")
916 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
917 "Variable that says which function should be used to decode a string with encoded words.")
919 (defcustom gnus-extra-headers '(To Newsgroups)
920 "*Extra headers to parse."
923 :type '(repeat symbol))
925 (defcustom gnus-ignored-from-addresses
926 (and user-mail-address (regexp-quote user-mail-address))
927 "*Regexp of From headers that may be suppressed in favor of To headers."
932 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
933 "List of charsets that should be ignored.
934 When these charsets are used in the \"charset\" parameter, the
935 default charset will be used instead."
937 :type '(repeat symbol)
938 :group 'gnus-charset)
940 (gnus-define-group-parameter
944 "Return the ignored charsets of GROUP."
945 :variable gnus-group-ignored-charsets-alist
947 '(("alt\\.chinese\\.text" iso-8859-1))
949 "Alist of regexps (to match group names) and charsets that should be ignored.
950 When these charsets are used in the \"charset\" parameter, the
951 default charset will be used instead."
952 :variable-group gnus-charset
953 :variable-type '(repeat (cons (regexp :tag "Group")
955 :parameter-type '(choice :tag "Ignored charsets"
958 :parameter-document "\
959 List of charsets that should be ignored.
961 When these charsets are used in the \"charset\" parameter, the
962 default charset will be used instead.")
964 (defcustom gnus-group-highlight-words-alist nil
965 "Alist of group regexps and highlight regexps.
966 This variable uses the same syntax as `gnus-emphasis-alist'."
968 :type '(repeat (cons (regexp :tag "Group")
969 (repeat (list (regexp :tag "Highlight regexp")
970 (number :tag "Group for entire word" 0)
971 (number :tag "Group for displayed part" 0)
973 gnus-emphasis-highlight-words)))))
974 :group 'gnus-summary-visual)
976 (defcustom gnus-summary-show-article-charset-alist
978 "Alist of number and charset.
979 The article will be shown with the charset corresponding to the
981 For example: ((1 . cn-gb-2312) (2 . big5))."
983 :type '(repeat (cons (number :tag "Argument" 1)
984 (symbol :tag "Charset")))
985 :group 'gnus-charset)
987 (defcustom gnus-preserve-marks t
988 "Whether marks are preserved when moving, copying and respooling messages."
991 :group 'gnus-summary-marks)
993 (defcustom gnus-alter-articles-to-read-function nil
994 "Function to be called to alter the list of articles to be selected."
995 :type '(choice (const nil) function)
996 :group 'gnus-summary)
998 (defcustom gnus-orphan-score nil
999 "*All orphans get this score added. Set in the score file."
1000 :group 'gnus-score-default
1001 :type '(choice (const nil)
1004 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1005 "*A regexp to match MIME parts when saving multiple parts of a message
1006 with gnus-summary-save-parts (X m). This regexp will be used by default
1007 when prompting the user for which type of files to save."
1008 :group 'gnus-summary
1011 (defcustom gnus-read-all-available-headers nil
1012 "Whether Gnus should parse all headers made available to it.
1013 This is mostly relevant for slow backends where the user may
1014 wish to widen the summary buffer to include all headers
1015 that were fetched. Say, for nnultimate groups."
1016 :group 'gnus-summary
1017 :type '(choice boolean regexp))
1019 (defcustom gnus-summary-muttprint-program "muttprint"
1020 "Command (and optional arguments) used to run Muttprint."
1022 :group 'gnus-summary
1025 (defcustom gnus-article-loose-mime nil
1026 "If non-nil, don't require MIME-Version header.
1027 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1028 supply the MIME-Version header or deliberately strip it From the mail.
1029 Set it to non-nil, Gnus will treat some articles as MIME even if
1030 the MIME-Version header is missed."
1033 :group 'gnus-article)
1035 ;;; Internal variables
1037 (defvar gnus-summary-display-cache nil)
1038 (defvar gnus-article-mime-handles nil)
1039 (defvar gnus-article-decoded-p nil)
1040 (defvar gnus-article-charset nil)
1041 (defvar gnus-article-ignored-charsets nil)
1042 (defvar gnus-scores-exclude-files nil)
1043 (defvar gnus-page-broken nil)
1044 (defvar gnus-inhibit-mime-unbuttonizing nil)
1046 (defvar gnus-original-article nil)
1047 (defvar gnus-article-internal-prepare-hook nil)
1048 (defvar gnus-newsgroup-process-stack nil)
1050 (defvar gnus-thread-indent-array nil)
1051 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1052 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1053 "Function called to sort the articles within a thread after it has been gathered together.")
1055 (defvar gnus-summary-save-parts-type-history nil)
1056 (defvar gnus-summary-save-parts-last-directory nil)
1058 ;; Avoid highlighting in kill files.
1059 (defvar gnus-summary-inhibit-highlight nil)
1060 (defvar gnus-newsgroup-selected-overlay nil)
1061 (defvar gnus-inhibit-limiting nil)
1062 (defvar gnus-newsgroup-adaptive-score-file nil)
1063 (defvar gnus-current-score-file nil)
1064 (defvar gnus-current-move-group nil)
1065 (defvar gnus-current-copy-group nil)
1066 (defvar gnus-current-crosspost-group nil)
1067 (defvar gnus-newsgroup-display nil)
1069 (defvar gnus-newsgroup-dependencies nil)
1070 (defvar gnus-newsgroup-adaptive nil)
1071 (defvar gnus-summary-display-article-function nil)
1072 (defvar gnus-summary-highlight-line-function nil
1073 "Function called after highlighting a summary line.")
1075 (defvar gnus-summary-line-format-alist
1076 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1077 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1078 (?s gnus-tmp-subject-or-nil ?s)
1079 (?n gnus-tmp-name ?s)
1080 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1082 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1084 (?F gnus-tmp-from ?s)
1085 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1086 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1087 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1088 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1089 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1090 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1091 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1092 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1093 (?L gnus-tmp-lines ?s)
1094 (?I gnus-tmp-indentation ?s)
1095 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1096 (?R gnus-tmp-replied ?c)
1097 (?\[ gnus-tmp-opening-bracket ?c)
1098 (?\] gnus-tmp-closing-bracket ?c)
1099 (?\> (make-string gnus-tmp-level ? ) ?s)
1100 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1101 (?i gnus-tmp-score ?d)
1102 (?z gnus-tmp-score-char ?c)
1103 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1104 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1105 (?U gnus-tmp-unread ?c)
1106 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1108 (?t (gnus-summary-number-of-articles-in-thread
1109 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1111 (?e (gnus-summary-number-of-articles-in-thread
1112 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1114 (?u gnus-tmp-user-defined ?s)
1115 (?P (gnus-pick-line-number) ?d)
1116 (?B gnus-tmp-thread-tree-header-string ?s)
1117 (user-date (gnus-user-date
1118 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1119 "An alist of format specifications that can appear in summary lines.
1120 These are paired with what variables they correspond with, along with
1121 the type of the variable (string, integer, character, etc).")
1123 (defvar gnus-summary-dummy-line-format-alist
1124 `((?S gnus-tmp-subject ?s)
1125 (?N gnus-tmp-number ?d)
1126 (?u gnus-tmp-user-defined ?s)))
1128 (defvar gnus-summary-mode-line-format-alist
1129 `((?G gnus-tmp-group-name ?s)
1130 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1131 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1132 (?A gnus-tmp-article-number ?d)
1133 (?Z gnus-tmp-unread-and-unselected ?s)
1134 (?V gnus-version ?s)
1135 (?U gnus-tmp-unread-and-unticked ?d)
1136 (?S gnus-tmp-subject ?s)
1137 (?e gnus-tmp-unselected ?d)
1138 (?u gnus-tmp-user-defined ?s)
1139 (?d (length gnus-newsgroup-dormant) ?d)
1140 (?t (length gnus-newsgroup-marked) ?d)
1141 (?h (length gnus-newsgroup-spam-marked) ?d)
1142 (?r (length gnus-newsgroup-reads) ?d)
1143 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1144 (?E gnus-newsgroup-expunged-tally ?d)
1145 (?s (gnus-current-score-file-nondirectory) ?s)))
1147 (defvar gnus-last-search-regexp nil
1148 "Default regexp for article search command.")
1150 (defvar gnus-last-shell-command nil
1151 "Default shell command on article.")
1153 (defvar gnus-newsgroup-begin nil)
1154 (defvar gnus-newsgroup-end nil)
1155 (defvar gnus-newsgroup-last-rmail nil)
1156 (defvar gnus-newsgroup-last-mail nil)
1157 (defvar gnus-newsgroup-last-folder nil)
1158 (defvar gnus-newsgroup-last-file nil)
1159 (defvar gnus-newsgroup-auto-expire nil)
1160 (defvar gnus-newsgroup-active nil)
1162 (defvar gnus-newsgroup-data nil)
1163 (defvar gnus-newsgroup-data-reverse nil)
1164 (defvar gnus-newsgroup-limit nil)
1165 (defvar gnus-newsgroup-limits nil)
1167 (defvar gnus-newsgroup-unreads nil
1168 "Sorted list of unread articles in the current newsgroup.")
1170 (defvar gnus-newsgroup-unselected nil
1171 "Sorted list of unselected unread articles in the current newsgroup.")
1173 (defvar gnus-newsgroup-reads nil
1174 "Alist of read articles and article marks in the current newsgroup.")
1176 (defvar gnus-newsgroup-expunged-tally nil)
1178 (defvar gnus-newsgroup-marked nil
1179 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1181 (defvar gnus-newsgroup-spam-marked nil
1182 "List of ranges of articles that have been marked as spam.")
1184 (defvar gnus-newsgroup-killed nil
1185 "List of ranges of articles that have been through the scoring process.")
1187 (defvar gnus-newsgroup-cached nil
1188 "Sorted list of articles that come from the article cache.")
1190 (defvar gnus-newsgroup-saved nil
1191 "List of articles that have been saved.")
1193 (defvar gnus-newsgroup-kill-headers nil)
1195 (defvar gnus-newsgroup-replied nil
1196 "List of articles that have been replied to in the current newsgroup.")
1198 (defvar gnus-newsgroup-forwarded nil
1199 "List of articles that have been forwarded in the current newsgroup.")
1201 (defvar gnus-newsgroup-recent nil
1202 "List of articles that have are recent in the current newsgroup.")
1204 (defvar gnus-newsgroup-expirable nil
1205 "Sorted list of articles in the current newsgroup that can be expired.")
1207 (defvar gnus-newsgroup-processable nil
1208 "List of articles in the current newsgroup that can be processed.")
1210 (defvar gnus-newsgroup-downloadable nil
1211 "Sorted list of articles in the current newsgroup that can be processed.")
1213 (defvar gnus-newsgroup-undownloaded nil
1214 "List of articles in the current newsgroup that haven't been downloaded..")
1216 (defvar gnus-newsgroup-unsendable nil
1217 "List of articles in the current newsgroup that won't be sent.")
1219 (defvar gnus-newsgroup-bookmarks nil
1220 "List of articles in the current newsgroup that have bookmarks.")
1222 (defvar gnus-newsgroup-dormant nil
1223 "Sorted list of dormant articles in the current newsgroup.")
1225 (defvar gnus-newsgroup-unseen nil
1226 "List of unseen articles in the current newsgroup.")
1228 (defvar gnus-newsgroup-seen nil
1229 "Range of seen articles in the current newsgroup.")
1231 (defvar gnus-newsgroup-articles nil
1232 "List of articles in the current newsgroup.")
1234 (defvar gnus-newsgroup-scored nil
1235 "List of scored articles in the current newsgroup.")
1237 (defvar gnus-newsgroup-headers nil
1238 "List of article headers in the current newsgroup.")
1240 (defvar gnus-newsgroup-threads nil)
1242 (defvar gnus-newsgroup-prepared nil
1243 "Whether the current group has been prepared properly.")
1245 (defvar gnus-newsgroup-ancient nil
1246 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1248 (defvar gnus-newsgroup-sparse nil)
1250 (defvar gnus-current-article nil)
1251 (defvar gnus-article-current nil)
1252 (defvar gnus-current-headers nil)
1253 (defvar gnus-have-all-headers nil)
1254 (defvar gnus-last-article nil)
1255 (defvar gnus-newsgroup-history nil)
1256 (defvar gnus-newsgroup-charset nil)
1257 (defvar gnus-newsgroup-ephemeral-charset nil)
1258 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1260 (defvar gnus-article-before-search nil)
1262 (defconst gnus-summary-local-variables
1263 '(gnus-newsgroup-name
1264 gnus-newsgroup-begin gnus-newsgroup-end
1265 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1266 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1267 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1268 gnus-newsgroup-unselected gnus-newsgroup-marked
1269 gnus-newsgroup-spam-marked
1270 gnus-newsgroup-reads gnus-newsgroup-saved
1271 gnus-newsgroup-replied gnus-newsgroup-forwarded
1272 gnus-newsgroup-recent
1273 gnus-newsgroup-expirable
1274 gnus-newsgroup-processable gnus-newsgroup-killed
1275 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1276 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1277 gnus-newsgroup-seen gnus-newsgroup-articles
1278 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1279 gnus-newsgroup-headers gnus-newsgroup-threads
1280 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1281 gnus-current-article gnus-current-headers gnus-have-all-headers
1282 gnus-last-article gnus-article-internal-prepare-hook
1283 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1284 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1285 gnus-thread-expunge-below
1286 gnus-score-alist gnus-current-score-file
1287 (gnus-summary-expunge-below . global)
1288 (gnus-summary-mark-below . global)
1289 (gnus-orphan-score . global)
1290 gnus-newsgroup-active gnus-scores-exclude-files
1291 gnus-newsgroup-history gnus-newsgroup-ancient
1292 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1293 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1294 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1295 (gnus-newsgroup-expunged-tally . 0)
1296 gnus-cache-removable-articles gnus-newsgroup-cached
1297 gnus-newsgroup-data gnus-newsgroup-data-reverse
1298 gnus-newsgroup-limit gnus-newsgroup-limits
1299 gnus-newsgroup-charset gnus-newsgroup-display)
1300 "Variables that are buffer-local to the summary buffers.")
1302 (defvar gnus-newsgroup-variables nil
1303 "A list of variables that have separate values in different newsgroups.
1304 A list of newsgroup (summary buffer) local variables, or cons of
1305 variables and their default values (when the default values are not
1306 nil), that should be made global while the summary buffer is active.
1307 These variables can be used to set variables in the group parameters
1308 while still allowing them to affect operations done in other
1309 buffers. For example:
1311 \(setq gnus-newsgroup-variables
1312 '(message-use-followup-to
1313 (gnus-visible-headers .
1314 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1317 ;; Byte-compiler warning.
1318 (eval-when-compile (defvar gnus-article-mode-map))
1322 (defvar gnus-decode-encoded-word-methods
1323 '(mail-decode-encoded-word-string)
1324 "List of methods used to decode encoded words.
1326 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1327 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1328 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1329 whose names match REGEXP.
1332 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1333 mail-decode-encoded-word-string
1334 (\"chinese\" . rfc1843-decode-string))")
1336 (defvar gnus-decode-encoded-word-methods-cache nil)
1338 (defun gnus-multi-decode-encoded-word-string (string)
1339 "Apply the functions from `gnus-encoded-word-methods' that match."
1340 (unless (and gnus-decode-encoded-word-methods-cache
1341 (eq gnus-newsgroup-name
1342 (car gnus-decode-encoded-word-methods-cache)))
1343 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1346 (nconc gnus-decode-encoded-word-methods-cache (list x))
1347 (if (and gnus-newsgroup-name
1348 (string-match (car x) gnus-newsgroup-name))
1349 (nconc gnus-decode-encoded-word-methods-cache
1351 gnus-decode-encoded-word-methods))
1352 (let ((xlist gnus-decode-encoded-word-methods-cache))
1355 (setq string (funcall (pop xlist) string))))
1358 ;; Subject simplification.
1360 (defun gnus-simplify-whitespace (str)
1361 "Remove excessive whitespace from STR."
1364 (while (string-match "[ \t][ \t]+" mystr)
1365 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1367 (substring mystr (match-end 0)))))
1369 (when (string-match "^[ \t]+" mystr)
1370 (setq mystr (substring mystr (match-end 0))))
1372 (when (string-match "[ \t]+$" mystr)
1373 (setq mystr (substring mystr 0 (match-beginning 0))))
1376 (defun gnus-simplify-all-whitespace (str)
1377 "Remove all whitespace from STR."
1379 (while (string-match "[ \t\n]+" mystr)
1380 (setq mystr (replace-match "" nil nil mystr)))
1383 (defsubst gnus-simplify-subject-re (subject)
1384 "Remove \"Re:\" from subject lines."
1385 (if (string-match message-subject-re-regexp subject)
1386 (substring subject (match-end 0))
1389 (defun gnus-simplify-subject (subject &optional re-only)
1390 "Remove `Re:' and words in parentheses.
1391 If RE-ONLY is non-nil, strip leading `Re:'s only."
1392 (let ((case-fold-search t)) ;Ignore case.
1393 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1394 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1395 (setq subject (substring subject (match-end 0))))
1396 ;; Remove uninteresting prefixes.
1397 (when (and (not re-only)
1398 gnus-simplify-ignored-prefixes
1399 (string-match gnus-simplify-ignored-prefixes subject))
1400 (setq subject (substring subject (match-end 0))))
1401 ;; Remove words in parentheses from end.
1403 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1404 (setq subject (substring subject 0 (match-beginning 0)))))
1405 ;; Return subject string.
1408 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1410 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1411 (goto-char (point-min))
1412 (while (re-search-forward regexp nil t)
1413 (replace-match (or newtext ""))))
1415 (defun gnus-simplify-buffer-fuzzy ()
1416 "Simplify string in the buffer fuzzily.
1417 The string in the accessible portion of the current buffer is simplified.
1418 It is assumed to be a single-line subject.
1419 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1420 matter is removed. Additional things can be deleted by setting
1421 `gnus-simplify-subject-fuzzy-regexp'."
1422 (let ((case-fold-search t)
1424 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1426 (while (not (eq modified-tick (buffer-modified-tick)))
1427 (setq modified-tick (buffer-modified-tick))
1429 ((listp gnus-simplify-subject-fuzzy-regexp)
1430 (mapcar 'gnus-simplify-buffer-fuzzy-step
1431 gnus-simplify-subject-fuzzy-regexp))
1432 (gnus-simplify-subject-fuzzy-regexp
1433 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1434 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1435 (gnus-simplify-buffer-fuzzy-step
1436 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1437 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1439 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1440 (gnus-simplify-buffer-fuzzy-step " +" " ")
1441 (gnus-simplify-buffer-fuzzy-step " $")
1442 (gnus-simplify-buffer-fuzzy-step "^ +")))
1444 (defun gnus-simplify-subject-fuzzy (subject)
1445 "Simplify a subject string fuzzily.
1446 See `gnus-simplify-buffer-fuzzy' for details."
1448 (gnus-set-work-buffer)
1449 (let ((case-fold-search t))
1450 ;; Remove uninteresting prefixes.
1451 (when (and gnus-simplify-ignored-prefixes
1452 (string-match gnus-simplify-ignored-prefixes subject))
1453 (setq subject (substring subject (match-end 0))))
1455 (inline (gnus-simplify-buffer-fuzzy))
1458 (defsubst gnus-simplify-subject-fully (subject)
1459 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1461 (gnus-simplify-subject-functions
1462 (gnus-map-function gnus-simplify-subject-functions subject))
1463 ((null gnus-summary-gather-subject-limit)
1464 (gnus-simplify-subject-re subject))
1465 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1466 (gnus-simplify-subject-fuzzy subject))
1467 ((numberp gnus-summary-gather-subject-limit)
1468 (gnus-limit-string (gnus-simplify-subject-re subject)
1469 gnus-summary-gather-subject-limit))
1473 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1474 "Check whether two subjects are equal.
1475 If optional argument simple-first is t, first argument is already
1478 ((null simple-first)
1479 (equal (gnus-simplify-subject-fully s1)
1480 (gnus-simplify-subject-fully s2)))
1483 (gnus-simplify-subject-fully s2)))))
1485 (defun gnus-summary-bubble-group ()
1486 "Increase the score of the current group.
1487 This is a handy function to add to `gnus-summary-exit-hook' to
1488 increase the score of each group you read."
1489 (gnus-group-add-score gnus-newsgroup-name))
1493 ;;; Gnus summary mode
1496 (put 'gnus-summary-mode 'mode-class 'special)
1498 (defvar gnus-article-commands-menu)
1501 ;; Non-orthogonal keys
1503 (gnus-define-keys gnus-summary-mode-map
1504 " " gnus-summary-next-page
1505 "\177" gnus-summary-prev-page
1506 [delete] gnus-summary-prev-page
1507 [backspace] gnus-summary-prev-page
1508 "\r" gnus-summary-scroll-up
1509 "\M-\r" gnus-summary-scroll-down
1510 "n" gnus-summary-next-unread-article
1511 "p" gnus-summary-prev-unread-article
1512 "N" gnus-summary-next-article
1513 "P" gnus-summary-prev-article
1514 "\M-\C-n" gnus-summary-next-same-subject
1515 "\M-\C-p" gnus-summary-prev-same-subject
1516 "\M-n" gnus-summary-next-unread-subject
1517 "\M-p" gnus-summary-prev-unread-subject
1518 "." gnus-summary-first-unread-article
1519 "," gnus-summary-best-unread-article
1520 "\M-s" gnus-summary-search-article-forward
1521 "\M-r" gnus-summary-search-article-backward
1522 "<" gnus-summary-beginning-of-article
1523 ">" gnus-summary-end-of-article
1524 "j" gnus-summary-goto-article
1525 "^" gnus-summary-refer-parent-article
1526 "\M-^" gnus-summary-refer-article
1527 "u" gnus-summary-tick-article-forward
1528 "!" gnus-summary-tick-article-forward
1529 "U" gnus-summary-tick-article-backward
1530 "d" gnus-summary-mark-as-read-forward
1531 "D" gnus-summary-mark-as-read-backward
1532 "E" gnus-summary-mark-as-expirable
1533 "\M-u" gnus-summary-clear-mark-forward
1534 "\M-U" gnus-summary-clear-mark-backward
1535 "k" gnus-summary-kill-same-subject-and-select
1536 "\C-k" gnus-summary-kill-same-subject
1537 "\M-\C-k" gnus-summary-kill-thread
1538 "\M-\C-l" gnus-summary-lower-thread
1539 "e" gnus-summary-edit-article
1540 "#" gnus-summary-mark-as-processable
1541 "\M-#" gnus-summary-unmark-as-processable
1542 "\M-\C-t" gnus-summary-toggle-threads
1543 "\M-\C-s" gnus-summary-show-thread
1544 "\M-\C-h" gnus-summary-hide-thread
1545 "\M-\C-f" gnus-summary-next-thread
1546 "\M-\C-b" gnus-summary-prev-thread
1547 [(meta down)] gnus-summary-next-thread
1548 [(meta up)] gnus-summary-prev-thread
1549 "\M-\C-u" gnus-summary-up-thread
1550 "\M-\C-d" gnus-summary-down-thread
1551 "&" gnus-summary-execute-command
1552 "c" gnus-summary-catchup-and-exit
1553 "\C-w" gnus-summary-mark-region-as-read
1554 "\C-t" gnus-summary-toggle-truncation
1555 "?" gnus-summary-mark-as-dormant
1556 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1557 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1558 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1559 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1560 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1561 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1562 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1563 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1564 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1565 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1566 "=" gnus-summary-expand-window
1567 "\C-x\C-s" gnus-summary-reselect-current-group
1568 "\M-g" gnus-summary-rescan-group
1569 "w" gnus-summary-stop-page-breaking
1570 "\C-c\C-r" gnus-summary-caesar-message
1571 "f" gnus-summary-followup
1572 "F" gnus-summary-followup-with-original
1573 "C" gnus-summary-cancel-article
1574 "r" gnus-summary-reply
1575 "R" gnus-summary-reply-with-original
1576 "\C-c\C-f" gnus-summary-mail-forward
1577 "o" gnus-summary-save-article
1578 "\C-o" gnus-summary-save-article-mail
1579 "|" gnus-summary-pipe-output
1580 "\M-k" gnus-summary-edit-local-kill
1581 "\M-K" gnus-summary-edit-global-kill
1583 "\C-c\C-d" gnus-summary-describe-group
1584 "q" gnus-summary-exit
1585 "Q" gnus-summary-exit-no-update
1586 "\C-c\C-i" gnus-info-find-node
1587 gnus-mouse-2 gnus-mouse-pick-article
1588 "m" gnus-summary-mail-other-window
1589 "a" gnus-summary-post-news
1590 "i" gnus-summary-news-other-window
1591 "x" gnus-summary-limit-to-unread
1592 "s" gnus-summary-isearch-article
1593 "t" gnus-summary-toggle-header
1594 "g" gnus-summary-show-article
1595 "l" gnus-summary-goto-last-article
1596 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1597 "\C-d" gnus-summary-enter-digest-group
1598 "\M-\C-d" gnus-summary-read-document
1599 "\M-\C-e" gnus-summary-edit-parameters
1600 "\M-\C-a" gnus-summary-customize-parameters
1602 "*" gnus-cache-enter-article
1603 "\M-*" gnus-cache-remove-article
1604 "\M-&" gnus-summary-universal-argument
1605 "\C-l" gnus-recenter
1606 "I" gnus-summary-increase-score
1607 "L" gnus-summary-lower-score
1608 "\M-i" gnus-symbolic-argument
1609 "h" gnus-summary-select-article-buffer
1611 "b" gnus-article-view-part
1612 "\M-t" gnus-summary-toggle-display-buttonized
1614 "V" gnus-summary-score-map
1615 "X" gnus-uu-extract-map
1616 "S" gnus-summary-send-map)
1618 ;; Sort of orthogonal keymap
1619 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1620 "t" gnus-summary-tick-article-forward
1621 "!" gnus-summary-tick-article-forward
1622 "d" gnus-summary-mark-as-read-forward
1623 "r" gnus-summary-mark-as-read-forward
1624 "c" gnus-summary-clear-mark-forward
1625 " " gnus-summary-clear-mark-forward
1626 "e" gnus-summary-mark-as-expirable
1627 "x" gnus-summary-mark-as-expirable
1628 "?" gnus-summary-mark-as-dormant
1629 "b" gnus-summary-set-bookmark
1630 "B" gnus-summary-remove-bookmark
1631 "#" gnus-summary-mark-as-processable
1632 "\M-#" gnus-summary-unmark-as-processable
1633 "S" gnus-summary-limit-include-expunged
1634 "C" gnus-summary-catchup
1635 "H" gnus-summary-catchup-to-here
1636 "h" gnus-summary-catchup-from-here
1637 "\C-c" gnus-summary-catchup-all
1638 "k" gnus-summary-kill-same-subject-and-select
1639 "K" gnus-summary-kill-same-subject
1640 "P" gnus-uu-mark-map)
1642 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1643 "c" gnus-summary-clear-above
1644 "u" gnus-summary-tick-above
1645 "m" gnus-summary-mark-above
1646 "k" gnus-summary-kill-below)
1648 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1649 "/" gnus-summary-limit-to-subject
1650 "n" gnus-summary-limit-to-articles
1651 "w" gnus-summary-pop-limit
1652 "s" gnus-summary-limit-to-subject
1653 "a" gnus-summary-limit-to-author
1654 "u" gnus-summary-limit-to-unread
1655 "m" gnus-summary-limit-to-marks
1656 "M" gnus-summary-limit-exclude-marks
1657 "v" gnus-summary-limit-to-score
1658 "*" gnus-summary-limit-include-cached
1659 "D" gnus-summary-limit-include-dormant
1660 "T" gnus-summary-limit-include-thread
1661 "d" gnus-summary-limit-exclude-dormant
1662 "t" gnus-summary-limit-to-age
1663 "x" gnus-summary-limit-to-extra
1664 "p" gnus-summary-limit-to-display-predicate
1665 "E" gnus-summary-limit-include-expunged
1666 "c" gnus-summary-limit-exclude-childless-dormant
1667 "C" gnus-summary-limit-mark-excluded-as-read
1668 "o" gnus-summary-insert-old-articles
1669 "N" gnus-summary-insert-new-articles)
1671 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1672 "n" gnus-summary-next-unread-article
1673 "p" gnus-summary-prev-unread-article
1674 "N" gnus-summary-next-article
1675 "P" gnus-summary-prev-article
1676 "\C-n" gnus-summary-next-same-subject
1677 "\C-p" gnus-summary-prev-same-subject
1678 "\M-n" gnus-summary-next-unread-subject
1679 "\M-p" gnus-summary-prev-unread-subject
1680 "f" gnus-summary-first-unread-article
1681 "b" gnus-summary-best-unread-article
1682 "j" gnus-summary-goto-article
1683 "g" gnus-summary-goto-subject
1684 "l" gnus-summary-goto-last-article
1685 "o" gnus-summary-pop-article)
1687 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1688 "k" gnus-summary-kill-thread
1689 "l" gnus-summary-lower-thread
1690 "i" gnus-summary-raise-thread
1691 "T" gnus-summary-toggle-threads
1692 "t" gnus-summary-rethread-current
1693 "^" gnus-summary-reparent-thread
1694 "s" gnus-summary-show-thread
1695 "S" gnus-summary-show-all-threads
1696 "h" gnus-summary-hide-thread
1697 "H" gnus-summary-hide-all-threads
1698 "n" gnus-summary-next-thread
1699 "p" gnus-summary-prev-thread
1700 "u" gnus-summary-up-thread
1701 "o" gnus-summary-top-thread
1702 "d" gnus-summary-down-thread
1703 "#" gnus-uu-mark-thread
1704 "\M-#" gnus-uu-unmark-thread)
1706 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1707 "g" gnus-summary-prepare
1708 "c" gnus-summary-insert-cached-articles)
1710 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1711 "c" gnus-summary-catchup-and-exit
1712 "C" gnus-summary-catchup-all-and-exit
1713 "E" gnus-summary-exit-no-update
1714 "Q" gnus-summary-exit
1715 "Z" gnus-summary-exit
1716 "n" gnus-summary-catchup-and-goto-next-group
1717 "R" gnus-summary-reselect-current-group
1718 "G" gnus-summary-rescan-group
1719 "N" gnus-summary-next-group
1720 "s" gnus-summary-save-newsrc
1721 "P" gnus-summary-prev-group)
1723 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1724 " " gnus-summary-next-page
1725 "n" gnus-summary-next-page
1726 "\177" gnus-summary-prev-page
1727 [delete] gnus-summary-prev-page
1728 "p" gnus-summary-prev-page
1729 "\r" gnus-summary-scroll-up
1730 "\M-\r" gnus-summary-scroll-down
1731 "<" gnus-summary-beginning-of-article
1732 ">" gnus-summary-end-of-article
1733 "b" gnus-summary-beginning-of-article
1734 "e" gnus-summary-end-of-article
1735 "^" gnus-summary-refer-parent-article
1736 "r" gnus-summary-refer-parent-article
1737 "D" gnus-summary-enter-digest-group
1738 "R" gnus-summary-refer-references
1739 "T" gnus-summary-refer-thread
1740 "g" gnus-summary-show-article
1741 "s" gnus-summary-isearch-article
1742 "P" gnus-summary-print-article
1743 "M" gnus-mailing-list-insinuate
1744 "t" gnus-article-babel)
1746 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1747 "b" gnus-article-add-buttons
1748 "B" gnus-article-add-buttons-to-head
1749 "o" gnus-article-treat-overstrike
1750 "e" gnus-article-emphasize
1751 "w" gnus-article-fill-cited-article
1752 "Q" gnus-article-fill-long-lines
1753 "C" gnus-article-capitalize-sentences
1754 "c" gnus-article-remove-cr
1755 "q" gnus-article-de-quoted-unreadable
1756 "6" gnus-article-de-base64-unreadable
1757 "Z" gnus-article-decode-HZ
1758 "h" gnus-article-wash-html
1759 "u" gnus-article-unsplit-urls
1760 "s" gnus-summary-force-verify-and-decrypt
1761 "f" gnus-article-display-x-face
1762 "l" gnus-summary-stop-page-breaking
1763 "r" gnus-summary-caesar-message
1764 "t" gnus-summary-toggle-header
1765 "g" gnus-treat-smiley
1766 "v" gnus-summary-verbose-headers
1767 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1768 "p" gnus-article-verify-x-pgp-sig
1769 "d" gnus-article-treat-dumbquotes
1770 "k" gnus-article-outlook-deuglify-article)
1772 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1773 "a" gnus-article-hide
1774 "h" gnus-article-hide-headers
1775 "b" gnus-article-hide-boring-headers
1776 "s" gnus-article-hide-signature
1777 "c" gnus-article-hide-citation
1778 "C" gnus-article-hide-citation-in-followups
1779 "l" gnus-article-hide-list-identifiers
1780 "p" gnus-article-hide-pgp
1781 "B" gnus-article-strip-banner
1782 "P" gnus-article-hide-pem
1783 "\C-c" gnus-article-hide-citation-maybe)
1785 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1786 "a" gnus-article-highlight
1787 "h" gnus-article-highlight-headers
1788 "c" gnus-article-highlight-citation
1789 "s" gnus-article-highlight-signature)
1791 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1792 "f" gnus-article-treat-fold-headers
1793 "u" gnus-article-treat-unfold-headers
1794 "n" gnus-article-treat-fold-newsgroups)
1796 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1797 "x" gnus-article-display-x-face
1798 "s" gnus-treat-smiley
1799 "D" gnus-article-remove-images
1800 "f" gnus-treat-from-picon
1801 "m" gnus-treat-mail-picon
1802 "n" gnus-treat-newsgroups-picon)
1804 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1805 "w" gnus-article-decode-mime-words
1806 "c" gnus-article-decode-charset
1807 "v" gnus-mime-view-all-parts
1808 "b" gnus-article-view-part)
1810 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1811 "z" gnus-article-date-ut
1812 "u" gnus-article-date-ut
1813 "l" gnus-article-date-local
1814 "p" gnus-article-date-english
1815 "e" gnus-article-date-lapsed
1816 "o" gnus-article-date-original
1817 "i" gnus-article-date-iso8601
1818 "s" gnus-article-date-user)
1820 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1821 "t" gnus-article-remove-trailing-blank-lines
1822 "l" gnus-article-strip-leading-blank-lines
1823 "m" gnus-article-strip-multiple-blank-lines
1824 "a" gnus-article-strip-blank-lines
1825 "A" gnus-article-strip-all-blank-lines
1826 "s" gnus-article-strip-leading-space
1827 "e" gnus-article-strip-trailing-space
1828 "w" gnus-article-remove-leading-whitespace)
1830 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1832 "f" gnus-summary-fetch-faq
1833 "d" gnus-summary-describe-group
1834 "h" gnus-summary-describe-briefly
1835 "i" gnus-info-find-node)
1837 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1838 "e" gnus-summary-expire-articles
1839 "\M-\C-e" gnus-summary-expire-articles-now
1840 "\177" gnus-summary-delete-article
1841 [delete] gnus-summary-delete-article
1842 [backspace] gnus-summary-delete-article
1843 "m" gnus-summary-move-article
1844 "r" gnus-summary-respool-article
1845 "w" gnus-summary-edit-article
1846 "c" gnus-summary-copy-article
1847 "B" gnus-summary-crosspost-article
1848 "q" gnus-summary-respool-query
1849 "t" gnus-summary-respool-trace
1850 "i" gnus-summary-import-article
1851 "I" gnus-summary-create-article
1852 "p" gnus-summary-article-posted-p)
1854 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1855 "o" gnus-summary-save-article
1856 "m" gnus-summary-save-article-mail
1857 "F" gnus-summary-write-article-file
1858 "r" gnus-summary-save-article-rmail
1859 "f" gnus-summary-save-article-file
1860 "b" gnus-summary-save-article-body-file
1861 "h" gnus-summary-save-article-folder
1862 "v" gnus-summary-save-article-vm
1863 "p" gnus-summary-pipe-output
1864 "P" gnus-summary-muttprint
1865 "s" gnus-soup-add-article)
1867 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1868 "b" gnus-summary-display-buttonized
1869 "m" gnus-summary-repair-multipart
1870 "v" gnus-article-view-part
1871 "o" gnus-article-save-part
1872 "c" gnus-article-copy-part
1873 "C" gnus-article-view-part-as-charset
1874 "e" gnus-article-view-part-externally
1875 "E" gnus-article-encrypt-body
1876 "i" gnus-article-inline-part
1877 "|" gnus-article-pipe-part)
1879 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1880 "p" gnus-summary-mark-as-processable
1881 "u" gnus-summary-unmark-as-processable
1882 "U" gnus-summary-unmark-all-processable
1883 "v" gnus-uu-mark-over
1884 "s" gnus-uu-mark-series
1885 "r" gnus-uu-mark-region
1886 "g" gnus-uu-unmark-region
1887 "R" gnus-uu-mark-by-regexp
1888 "G" gnus-uu-unmark-by-regexp
1889 "t" gnus-uu-mark-thread
1890 "T" gnus-uu-unmark-thread
1891 "a" gnus-uu-mark-all
1892 "b" gnus-uu-mark-buffer
1893 "S" gnus-uu-mark-sparse
1894 "k" gnus-summary-kill-process-mark
1895 "y" gnus-summary-yank-process-mark
1896 "w" gnus-summary-save-process-mark
1897 "i" gnus-uu-invert-processable)
1899 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1900 ;;"x" gnus-uu-extract-any
1901 "m" gnus-summary-save-parts
1902 "u" gnus-uu-decode-uu
1903 "U" gnus-uu-decode-uu-and-save
1904 "s" gnus-uu-decode-unshar
1905 "S" gnus-uu-decode-unshar-and-save
1906 "o" gnus-uu-decode-save
1907 "O" gnus-uu-decode-save
1908 "b" gnus-uu-decode-binhex
1909 "B" gnus-uu-decode-binhex
1910 "p" gnus-uu-decode-postscript
1911 "P" gnus-uu-decode-postscript-and-save)
1914 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1915 "u" gnus-uu-decode-uu-view
1916 "U" gnus-uu-decode-uu-and-save-view
1917 "s" gnus-uu-decode-unshar-view
1918 "S" gnus-uu-decode-unshar-and-save-view
1919 "o" gnus-uu-decode-save-view
1920 "O" gnus-uu-decode-save-view
1921 "b" gnus-uu-decode-binhex-view
1922 "B" gnus-uu-decode-binhex-view
1923 "p" gnus-uu-decode-postscript-view
1924 "P" gnus-uu-decode-postscript-and-save-view))
1926 (defvar gnus-article-post-menu nil)
1928 (defconst gnus-summary-menu-maxlen 20)
1930 (defun gnus-summary-menu-split (menu)
1931 ;; If we have lots of elements, divide them into groups of 20
1932 ;; and make a pane (or submenu) for each one.
1933 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1934 (let ((menu menu) sublists next
1937 ;; Pull off the next gnus-summary-menu-maxlen elements
1938 ;; and make them the next element of sublist.
1939 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1941 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1943 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1944 (aref (car (last menu)) 0)) menu)
1948 (nreverse sublists))
1949 ;; Few elements--put them all in one pane.
1952 (defun gnus-summary-make-menu-bar ()
1953 (gnus-turn-off-edit-menu 'summary)
1955 (unless (boundp 'gnus-summary-misc-menu)
1958 gnus-summary-kill-menu gnus-summary-mode-map ""
1963 ["Customize" gnus-score-customize t])
1964 (gnus-make-score-map 'increase)
1965 (gnus-make-score-map 'lower)
1967 ["Kill below" gnus-summary-kill-below t]
1968 ["Mark above" gnus-summary-mark-above t]
1969 ["Tick above" gnus-summary-tick-above t]
1970 ["Clear above" gnus-summary-clear-above t])
1971 ["Current score" gnus-summary-current-score t]
1972 ["Set score" gnus-summary-set-score t]
1973 ["Switch current score file..." gnus-score-change-score-file t]
1974 ["Set mark below..." gnus-score-set-mark-below t]
1975 ["Set expunge below..." gnus-score-set-expunge-below t]
1976 ["Edit current score file" gnus-score-edit-current-scores t]
1977 ["Edit score file" gnus-score-edit-file t]
1978 ["Trace score" gnus-score-find-trace t]
1979 ["Find words" gnus-score-find-favourite-words t]
1980 ["Rescore buffer" gnus-summary-rescore t]
1981 ["Increase score..." gnus-summary-increase-score t]
1982 ["Lower score..." gnus-summary-lower-score t]))))
1984 ;; Define both the Article menu in the summary buffer and the
1985 ;; equivalent Commands menu in the article buffer here for
1989 ["All" gnus-article-hide t]
1990 ["Headers" gnus-article-hide-headers t]
1991 ["Signature" gnus-article-hide-signature t]
1992 ["Citation" gnus-article-hide-citation t]
1993 ["List identifiers" gnus-article-hide-list-identifiers t]
1994 ["PGP" gnus-article-hide-pgp t]
1995 ["Banner" gnus-article-strip-banner t]
1996 ["Boring headers" gnus-article-hide-boring-headers t])
1998 ["All" gnus-article-highlight t]
1999 ["Headers" gnus-article-highlight-headers t]
2000 ["Signature" gnus-article-highlight-signature t]
2001 ["Citation" gnus-article-highlight-citation t])
2003 ["Words" gnus-article-decode-mime-words t]
2004 ["Charset" gnus-article-decode-charset t]
2005 ["QP" gnus-article-de-quoted-unreadable t]
2006 ["Base64" gnus-article-de-base64-unreadable t]
2007 ["View MIME buttons" gnus-summary-display-buttonized t]
2008 ["View all" gnus-mime-view-all-parts t]
2009 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2010 ["Encrypt body" gnus-article-encrypt-body t]
2011 ["Extract all parts" gnus-summary-save-parts t])
2013 ["Local" gnus-article-date-local t]
2014 ["ISO8601" gnus-article-date-iso8601 t]
2015 ["UT" gnus-article-date-ut t]
2016 ["Original" gnus-article-date-original t]
2017 ["Lapsed" gnus-article-date-lapsed t]
2018 ["User-defined" gnus-article-date-user t])
2020 ["Remove images" gnus-article-remove-images t]
2021 ["Toggle smiley" gnus-treat-smiley t]
2022 ["Show X-Face" gnus-article-display-x-face t]
2023 ["Show picons in From" gnus-treat-from-picon t]
2024 ["Show picons in mail headers" gnus-treat-mail-picon t]
2025 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2026 ("View as different encoding"
2027 ,@(gnus-summary-menu-split
2030 ;; Since easymenu under FSF Emacs doesn't allow lambda
2031 ;; forms for menu commands, we should provide intern'ed
2032 ;; function symbols.
2033 (let ((command (intern (format "\
2034 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2038 (let ((gnus-summary-show-article-charset-alist
2040 (gnus-summary-show-article 1))))
2041 `[,(symbol-name cs) ,command t]))
2042 (sort (if (fboundp 'coding-system-list)
2043 (coding-system-list)
2044 (mapcar 'car mm-mime-mule-charset-alist))
2046 (string< (symbol-name a)
2047 (symbol-name b))))))))
2050 ["Leading" gnus-article-strip-leading-blank-lines t]
2051 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2052 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2053 ["All of the above" gnus-article-strip-blank-lines t]
2054 ["All" gnus-article-strip-all-blank-lines t]
2055 ["Leading space" gnus-article-strip-leading-space t]
2056 ["Trailing space" gnus-article-strip-trailing-space t]
2057 ["Leading space in headers"
2058 gnus-article-remove-leading-whitespace t])
2059 ["Overstrike" gnus-article-treat-overstrike t]
2060 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2061 ["Emphasis" gnus-article-emphasize t]
2062 ["Word wrap" gnus-article-fill-cited-article t]
2063 ["Fill long lines" gnus-article-fill-long-lines t]
2064 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2065 ["CR" gnus-article-remove-cr t]
2066 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2067 ["Base64" gnus-article-de-base64-unreadable t]
2068 ["Rot 13" gnus-summary-caesar-message
2069 ,@(if (featurep 'xemacs) '(t)
2070 '(:help "\"Caesar rotate\" article by 13"))]
2071 ["Unix pipe" gnus-summary-pipe-message t]
2072 ["Add buttons" gnus-article-add-buttons t]
2073 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2074 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2075 ["Verbose header" gnus-summary-verbose-headers t]
2076 ["Toggle header" gnus-summary-toggle-header t]
2077 ["Unfold headers" gnus-article-treat-unfold-headers t]
2078 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2079 ["Html" gnus-article-wash-html t]
2080 ["URLs" gnus-article-unsplit-urls t]
2081 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2082 ["HZ" gnus-article-decode-HZ t]
2083 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2086 ["Save in default format" gnus-summary-save-article
2087 ,@(if (featurep 'xemacs) '(t)
2088 '(:help "Save article using default method"))]
2089 ["Save in file" gnus-summary-save-article-file
2090 ,@(if (featurep 'xemacs) '(t)
2091 '(:help "Save article in file"))]
2092 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2093 ["Save in MH folder" gnus-summary-save-article-folder t]
2094 ["Save in VM folder" gnus-summary-save-article-vm t]
2095 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2096 ["Save body in file" gnus-summary-save-article-body-file t]
2097 ["Pipe through a filter" gnus-summary-pipe-output t]
2098 ["Add to SOUP packet" gnus-soup-add-article t]
2099 ["Print with Muttprint" gnus-summary-muttprint t]
2100 ["Print" gnus-summary-print-article t])
2102 ["Respool article..." gnus-summary-respool-article t]
2103 ["Move article..." gnus-summary-move-article
2104 (gnus-check-backend-function
2105 'request-move-article gnus-newsgroup-name)]
2106 ["Copy article..." gnus-summary-copy-article t]
2107 ["Crosspost article..." gnus-summary-crosspost-article
2108 (gnus-check-backend-function
2109 'request-replace-article gnus-newsgroup-name)]
2110 ["Import file..." gnus-summary-import-article t]
2111 ["Create article..." gnus-summary-create-article t]
2112 ["Check if posted" gnus-summary-article-posted-p t]
2113 ["Edit article" gnus-summary-edit-article
2114 (not (gnus-group-read-only-p))]
2115 ["Delete article" gnus-summary-delete-article
2116 (gnus-check-backend-function
2117 'request-expire-articles gnus-newsgroup-name)]
2118 ["Query respool" gnus-summary-respool-query t]
2119 ["Trace respool" gnus-summary-respool-trace t]
2120 ["Delete expirable articles" gnus-summary-expire-articles-now
2121 (gnus-check-backend-function
2122 'request-expire-articles gnus-newsgroup-name)])
2124 ["Uudecode" gnus-uu-decode-uu
2125 ,@(if (featurep 'xemacs) '(t)
2126 '(:help "Decode uuencoded article(s)"))]
2127 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2128 ["Unshar" gnus-uu-decode-unshar t]
2129 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2130 ["Save" gnus-uu-decode-save t]
2131 ["Binhex" gnus-uu-decode-binhex t]
2132 ["Postscript" gnus-uu-decode-postscript t]
2133 ["All MIME parts" gnus-summary-save-parts t])
2135 ["Enter article" gnus-cache-enter-article t]
2136 ["Remove article" gnus-cache-remove-article t])
2137 ["Translate" gnus-article-babel t]
2138 ["Select article buffer" gnus-summary-select-article-buffer t]
2139 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2140 ["Isearch article..." gnus-summary-isearch-article t]
2141 ["Beginning of the article" gnus-summary-beginning-of-article t]
2142 ["End of the article" gnus-summary-end-of-article t]
2143 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2144 ["Fetch referenced articles" gnus-summary-refer-references t]
2145 ["Fetch current thread" gnus-summary-refer-thread t]
2146 ["Fetch article with id..." gnus-summary-refer-article t]
2147 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2148 ["Redisplay" gnus-summary-show-article t]
2149 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2151 gnus-summary-article-menu gnus-summary-mode-map ""
2152 (cons "Article" innards))
2154 (if (not (keymapp gnus-summary-article-menu))
2156 gnus-article-commands-menu gnus-article-mode-map ""
2157 (cons "Commands" innards))
2158 ;; in Emacs, don't share menu.
2159 (setq gnus-article-commands-menu
2160 (copy-keymap gnus-summary-article-menu))
2161 (define-key gnus-article-mode-map [menu-bar commands]
2162 (cons "Commands" gnus-article-commands-menu))))
2165 gnus-summary-thread-menu gnus-summary-mode-map ""
2167 ["Toggle threading" gnus-summary-toggle-threads t]
2168 ["Hide threads" gnus-summary-hide-all-threads t]
2169 ["Show threads" gnus-summary-show-all-threads t]
2170 ["Hide thread" gnus-summary-hide-thread t]
2171 ["Show thread" gnus-summary-show-thread t]
2172 ["Go to next thread" gnus-summary-next-thread t]
2173 ["Go to previous thread" gnus-summary-prev-thread t]
2174 ["Go down thread" gnus-summary-down-thread t]
2175 ["Go up thread" gnus-summary-up-thread t]
2176 ["Top of thread" gnus-summary-top-thread t]
2177 ["Mark thread as read" gnus-summary-kill-thread t]
2178 ["Lower thread score" gnus-summary-lower-thread t]
2179 ["Raise thread score" gnus-summary-raise-thread t]
2180 ["Rethread current" gnus-summary-rethread-current t]))
2183 gnus-summary-post-menu gnus-summary-mode-map ""
2185 ["Send a message (mail or news)" gnus-summary-post-news
2186 ,@(if (featurep 'xemacs) '(t)
2187 '(:help "Post an article"))]
2188 ["Followup" gnus-summary-followup
2189 ,@(if (featurep 'xemacs) '(t)
2190 '(:help "Post followup to this article"))]
2191 ["Followup and yank" gnus-summary-followup-with-original
2192 ,@(if (featurep 'xemacs) '(t)
2193 '(:help "Post followup to this article, quoting its contents"))]
2194 ["Supersede article" gnus-summary-supersede-article t]
2195 ["Cancel article" gnus-summary-cancel-article
2196 ,@(if (featurep 'xemacs) '(t)
2197 '(:help "Cancel an article you posted"))]
2198 ["Reply" gnus-summary-reply t]
2199 ["Reply and yank" gnus-summary-reply-with-original t]
2200 ["Wide reply" gnus-summary-wide-reply t]
2201 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2202 ,@(if (featurep 'xemacs) '(t)
2203 '(:help "Mail a reply, quoting this article"))]
2204 ["Very wide reply" gnus-summary-very-wide-reply t]
2205 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2206 ,@(if (featurep 'xemacs) '(t)
2207 '(:help "Mail a very wide reply, quoting this article"))]
2208 ["Mail forward" gnus-summary-mail-forward t]
2209 ["Post forward" gnus-summary-post-forward t]
2210 ["Digest and mail" gnus-uu-digest-mail-forward t]
2211 ["Digest and post" gnus-uu-digest-post-forward t]
2212 ["Resend message" gnus-summary-resend-message t]
2213 ["Resend message edit" gnus-summary-resend-message-edit t]
2214 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2215 ["Send a mail" gnus-summary-mail-other-window t]
2216 ["Create a local message" gnus-summary-news-other-window t]
2217 ["Uuencode and post" gnus-uu-post-news
2218 ,@(if (featurep 'xemacs) '(t)
2219 '(:help "Post a uuencoded article"))]
2220 ["Followup via news" gnus-summary-followup-to-mail t]
2221 ["Followup via news and yank"
2222 gnus-summary-followup-to-mail-with-original t]
2224 ;;["Send" gnus-summary-send-draft t]
2225 ;;["Send bounced" gnus-resend-bounced-mail t])
2229 ((not (keymapp gnus-summary-post-menu))
2230 (setq gnus-article-post-menu gnus-summary-post-menu))
2231 ((not gnus-article-post-menu)
2232 ;; Don't share post menu.
2233 (setq gnus-article-post-menu
2234 (copy-keymap gnus-summary-post-menu))))
2235 (define-key gnus-article-mode-map [menu-bar post]
2236 (cons "Post" gnus-article-post-menu))
2239 gnus-summary-misc-menu gnus-summary-mode-map ""
2242 ["Mark as read" gnus-summary-mark-as-read-forward t]
2243 ["Mark same subject and select"
2244 gnus-summary-kill-same-subject-and-select t]
2245 ["Mark same subject" gnus-summary-kill-same-subject t]
2246 ["Catchup" gnus-summary-catchup
2247 ,@(if (featurep 'xemacs) '(t)
2248 '(:help "Mark unread articles in this group as read"))]
2249 ["Catchup all" gnus-summary-catchup-all t]
2250 ["Catchup to here" gnus-summary-catchup-to-here t]
2251 ["Catchup from here" gnus-summary-catchup-from-here t]
2252 ["Catchup region" gnus-summary-mark-region-as-read t]
2253 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2255 ["Tick" gnus-summary-tick-article-forward t]
2256 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2257 ["Remove marks" gnus-summary-clear-mark-forward t]
2258 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2259 ["Set bookmark" gnus-summary-set-bookmark t]
2260 ["Remove bookmark" gnus-summary-remove-bookmark t])
2262 ["Marks..." gnus-summary-limit-to-marks t]
2263 ["Subject..." gnus-summary-limit-to-subject t]
2264 ["Author..." gnus-summary-limit-to-author t]
2265 ["Age..." gnus-summary-limit-to-age t]
2266 ["Extra..." gnus-summary-limit-to-extra t]
2267 ["Score" gnus-summary-limit-to-score t]
2268 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2269 ["Unread" gnus-summary-limit-to-unread t]
2270 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2271 ["Articles" gnus-summary-limit-to-articles t]
2272 ["Pop limit" gnus-summary-pop-limit t]
2273 ["Show dormant" gnus-summary-limit-include-dormant t]
2274 ["Hide childless dormant"
2275 gnus-summary-limit-exclude-childless-dormant t]
2276 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2277 ["Hide marked" gnus-summary-limit-exclude-marks t]
2278 ["Show expunged" gnus-summary-limit-include-expunged t])
2280 ["Set mark" gnus-summary-mark-as-processable t]
2281 ["Remove mark" gnus-summary-unmark-as-processable t]
2282 ["Remove all marks" gnus-summary-unmark-all-processable t]
2283 ["Mark above" gnus-uu-mark-over t]
2284 ["Mark series" gnus-uu-mark-series t]
2285 ["Mark region" gnus-uu-mark-region t]
2286 ["Unmark region" gnus-uu-unmark-region t]
2287 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2288 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2289 ["Mark all" gnus-uu-mark-all t]
2290 ["Mark buffer" gnus-uu-mark-buffer t]
2291 ["Mark sparse" gnus-uu-mark-sparse t]
2292 ["Mark thread" gnus-uu-mark-thread t]
2293 ["Unmark thread" gnus-uu-unmark-thread t]
2294 ("Process Mark Sets"
2295 ["Kill" gnus-summary-kill-process-mark t]
2296 ["Yank" gnus-summary-yank-process-mark
2297 gnus-newsgroup-process-stack]
2298 ["Save" gnus-summary-save-process-mark t]))
2300 ["Page forward" gnus-summary-next-page
2301 ,@(if (featurep 'xemacs) '(t)
2302 '(:help "Show next page of article"))]
2303 ["Page backward" gnus-summary-prev-page
2304 ,@(if (featurep 'xemacs) '(t)
2305 '(:help "Show previous page of article"))]
2306 ["Line forward" gnus-summary-scroll-up t])
2308 ["Next unread article" gnus-summary-next-unread-article t]
2309 ["Previous unread article" gnus-summary-prev-unread-article t]
2310 ["Next article" gnus-summary-next-article t]
2311 ["Previous article" gnus-summary-prev-article t]
2312 ["Next unread subject" gnus-summary-next-unread-subject t]
2313 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2314 ["Next article same subject" gnus-summary-next-same-subject t]
2315 ["Previous article same subject" gnus-summary-prev-same-subject t]
2316 ["First unread article" gnus-summary-first-unread-article t]
2317 ["Best unread article" gnus-summary-best-unread-article t]
2318 ["Go to subject number..." gnus-summary-goto-subject t]
2319 ["Go to article number..." gnus-summary-goto-article t]
2320 ["Go to the last article" gnus-summary-goto-last-article t]
2321 ["Pop article off history" gnus-summary-pop-article t])
2323 ["Sort by number" gnus-summary-sort-by-number t]
2324 ["Sort by author" gnus-summary-sort-by-author t]
2325 ["Sort by subject" gnus-summary-sort-by-subject t]
2326 ["Sort by date" gnus-summary-sort-by-date t]
2327 ["Sort by score" gnus-summary-sort-by-score t]
2328 ["Sort by lines" gnus-summary-sort-by-lines t]
2329 ["Sort by characters" gnus-summary-sort-by-chars t]
2330 ["Randomize" gnus-summary-sort-by-random t]
2331 ["Original sort" gnus-summary-sort-by-original t])
2333 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2334 ["Describe group" gnus-summary-describe-group t]
2335 ["Read manual" gnus-info-find-node t])
2337 ["Pick and read" gnus-pick-mode t]
2338 ["Binary" gnus-binary-mode t])
2340 ["Regenerate" gnus-summary-prepare t]
2341 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2342 ["Toggle threading" gnus-summary-toggle-threads t])
2343 ["See old articles" gnus-summary-insert-old-articles t]
2344 ["See new articles" gnus-summary-insert-new-articles t]
2345 ["Filter articles..." gnus-summary-execute-command t]
2346 ["Run command on subjects..." gnus-summary-universal-argument t]
2347 ["Search articles forward..." gnus-summary-search-article-forward t]
2348 ["Search articles backward..." gnus-summary-search-article-backward t]
2349 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2350 ["Expand window" gnus-summary-expand-window t]
2351 ["Expire expirable articles" gnus-summary-expire-articles
2352 (gnus-check-backend-function
2353 'request-expire-articles gnus-newsgroup-name)]
2354 ["Edit local kill file" gnus-summary-edit-local-kill t]
2355 ["Edit main kill file" gnus-summary-edit-global-kill t]
2356 ["Edit group parameters" gnus-summary-edit-parameters t]
2357 ["Customize group parameters" gnus-summary-customize-parameters t]
2358 ["Send a bug report" gnus-bug t]
2360 ["Catchup and exit" gnus-summary-catchup-and-exit
2361 ,@(if (featurep 'xemacs) '(t)
2362 '(:help "Mark unread articles in this group as read, then exit"))]
2363 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2364 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2365 ["Exit group" gnus-summary-exit
2366 ,@(if (featurep 'xemacs) '(t)
2367 '(:help "Exit current group, return to group selection mode"))]
2368 ["Exit group without updating" gnus-summary-exit-no-update t]
2369 ["Exit and goto next group" gnus-summary-next-group t]
2370 ["Exit and goto prev group" gnus-summary-prev-group t]
2371 ["Reselect group" gnus-summary-reselect-current-group t]
2372 ["Rescan group" gnus-summary-rescan-group t]
2373 ["Update dribble" gnus-summary-save-newsrc t])))
2375 (gnus-run-hooks 'gnus-summary-menu-hook)))
2377 (defvar gnus-summary-tool-bar-map nil)
2379 ;; Emacs 21 tool bar. Should be no-op otherwise.
2380 (defun gnus-summary-make-tool-bar ()
2381 (if (and (fboundp 'tool-bar-add-item-from-menu)
2382 (default-value 'tool-bar-mode)
2383 (not gnus-summary-tool-bar-map))
2384 (setq gnus-summary-tool-bar-map
2385 (let ((tool-bar-map (make-sparse-keymap))
2386 (load-path (mm-image-load-path)))
2387 (tool-bar-add-item-from-menu
2388 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2389 (tool-bar-add-item-from-menu
2390 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2391 (tool-bar-add-item-from-menu
2392 'gnus-summary-post-news "post" gnus-summary-mode-map)
2393 (tool-bar-add-item-from-menu
2394 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2395 (tool-bar-add-item-from-menu
2396 'gnus-summary-followup "followup" gnus-summary-mode-map)
2397 (tool-bar-add-item-from-menu
2398 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2399 (tool-bar-add-item-from-menu
2400 'gnus-summary-reply "reply" gnus-summary-mode-map)
2401 (tool-bar-add-item-from-menu
2402 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2403 (tool-bar-add-item-from-menu
2404 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2405 (tool-bar-add-item-from-menu
2406 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2407 (tool-bar-add-item-from-menu
2408 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2409 (tool-bar-add-item-from-menu
2410 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2411 (tool-bar-add-item-from-menu
2412 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2413 (tool-bar-add-item-from-menu
2414 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2415 (tool-bar-add-item-from-menu
2416 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2418 (if gnus-summary-tool-bar-map
2419 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2421 (defun gnus-score-set-default (var value)
2422 "A version of set that updates the GNU Emacs menu-bar."
2424 ;; It is the message that forces the active status to be updated.
2427 (defun gnus-make-score-map (type)
2428 "Make a summary score map of type TYPE."
2431 (let ((headers '(("author" "from" string)
2432 ("subject" "subject" string)
2433 ("article body" "body" string)
2434 ("article head" "head" string)
2435 ("xref" "xref" string)
2436 ("extra header" "extra" string)
2437 ("lines" "lines" number)
2438 ("followups to author" "followup" string)))
2439 (types '((number ("less than" <)
2442 (string ("substring" s)
2446 (perms '(("temporary" (current-time-string))
2454 (if (eq type 'lower)
2459 (setq header (car headers))
2465 (let ((ts (cdr (assoc (nth 2 header) types)))
2481 'gnus-summary-score-entry
2483 (if (or (string= (nth 1 header)
2485 (string= (nth 1 header)
2488 (list 'gnus-summary-header
2490 (list 'quote (nth 1 (car ts)))
2491 (list 'gnus-score-delta-default
2498 (list (nreverse outp))))
2501 (list (nreverse outt))))
2503 (setq headers (cdr headers)))
2504 (list (nreverse outh))))))))
2508 (defun gnus-summary-mode (&optional group)
2509 "Major mode for reading articles.
2511 All normal editing commands are switched off.
2512 \\<gnus-summary-mode-map>
2513 Each line in this buffer represents one article. To read an
2514 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2515 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2518 You can also post articles and send mail from this buffer. To
2519 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2520 of an article, type `\\[gnus-summary-reply]'.
2522 There are approx. one gazillion commands you can execute in this
2523 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2525 The following commands are available:
2527 \\{gnus-summary-mode-map}"
2529 (kill-all-local-variables)
2530 (when (gnus-visual-p 'summary-menu 'menu)
2531 (gnus-summary-make-menu-bar)
2532 (gnus-summary-make-tool-bar))
2533 (gnus-summary-make-local-variables)
2534 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2535 (gnus-summary-make-local-variables))
2536 (gnus-make-thread-indent-array)
2537 (gnus-simplify-mode-line)
2538 (setq major-mode 'gnus-summary-mode)
2539 (setq mode-name "Summary")
2540 (make-local-variable 'minor-mode-alist)
2541 (use-local-map gnus-summary-mode-map)
2542 (buffer-disable-undo)
2543 (setq buffer-read-only t) ;Disable modification
2544 (setq truncate-lines t)
2545 (setq selective-display t)
2546 (setq selective-display-ellipses t) ;Display `...'
2547 (gnus-summary-set-display-table)
2548 (gnus-set-default-directory)
2549 (setq gnus-newsgroup-name group)
2550 (make-local-variable 'gnus-summary-line-format)
2551 (make-local-variable 'gnus-summary-line-format-spec)
2552 (make-local-variable 'gnus-summary-dummy-line-format)
2553 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2554 (make-local-variable 'gnus-summary-mark-positions)
2555 (make-local-hook 'pre-command-hook)
2556 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2557 (gnus-run-hooks 'gnus-summary-mode-hook)
2558 (turn-on-gnus-mailing-list-mode)
2559 (mm-enable-multibyte)
2560 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2561 (gnus-update-summary-mark-positions))
2563 (defun gnus-summary-make-local-variables ()
2564 "Make all the local summary buffer variables."
2566 (dolist (local gnus-summary-local-variables)
2569 (if (eq (cdr local) 'global)
2570 ;; Copy the global value of the variable.
2571 (setq global (symbol-value (car local)))
2572 ;; Use the value from the list.
2573 (setq global (eval (cdr local))))
2574 (set (make-local-variable (car local)) global))
2575 ;; Simple nil-valued local variable.
2576 (set (make-local-variable local) nil)))))
2578 (defun gnus-summary-clear-local-variables ()
2579 (let ((locals gnus-summary-local-variables))
2581 (if (consp (car locals))
2582 (and (vectorp (caar locals))
2583 (set (caar locals) nil))
2584 (and (vectorp (car locals))
2585 (set (car locals) nil)))
2586 (setq locals (cdr locals)))))
2588 ;; Summary data functions.
2590 (defmacro gnus-data-number (data)
2593 (defmacro gnus-data-set-number (data number)
2594 `(setcar ,data ,number))
2596 (defmacro gnus-data-mark (data)
2599 (defmacro gnus-data-set-mark (data mark)
2600 `(setcar (nthcdr 1 ,data) ,mark))
2602 (defmacro gnus-data-pos (data)
2605 (defmacro gnus-data-set-pos (data pos)
2606 `(setcar (nthcdr 2 ,data) ,pos))
2608 (defmacro gnus-data-header (data)
2611 (defmacro gnus-data-set-header (data header)
2612 `(setf (nth 3 ,data) ,header))
2614 (defmacro gnus-data-level (data)
2617 (defmacro gnus-data-unread-p (data)
2618 `(= (nth 1 ,data) gnus-unread-mark))
2620 (defmacro gnus-data-read-p (data)
2621 `(/= (nth 1 ,data) gnus-unread-mark))
2623 (defmacro gnus-data-pseudo-p (data)
2624 `(consp (nth 3 ,data)))
2626 (defmacro gnus-data-find (number)
2627 `(assq ,number gnus-newsgroup-data))
2629 (defmacro gnus-data-find-list (number &optional data)
2630 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2631 (memq (assq ,number bdata)
2634 (defmacro gnus-data-make (number mark pos header level)
2635 `(list ,number ,mark ,pos ,header ,level))
2637 (defun gnus-data-enter (after-article number mark pos header level offset)
2638 (let ((data (gnus-data-find-list after-article)))
2640 (error "No such article: %d" after-article))
2641 (setcdr data (cons (gnus-data-make number mark pos header level)
2643 (setq gnus-newsgroup-data-reverse nil)
2644 (gnus-data-update-list (cddr data) offset)))
2646 (defun gnus-data-enter-list (after-article list &optional offset)
2648 (let ((data (and after-article (gnus-data-find-list after-article)))
2652 (let ((odata gnus-newsgroup-data))
2653 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2655 (gnus-data-update-list odata offset)))
2656 ;; Find the last element in the list to be spliced into the main
2659 (setq list (cdr list)))
2662 (setcdr list gnus-newsgroup-data)
2663 (setq gnus-newsgroup-data ilist)
2665 (gnus-data-update-list (cdr list) offset)))
2666 (setcdr list (cdr data))
2669 (gnus-data-update-list (cdr list) offset))))
2670 (setq gnus-newsgroup-data-reverse nil))))
2672 (defun gnus-data-remove (article &optional offset)
2673 (let ((data gnus-newsgroup-data))
2674 (if (= (gnus-data-number (car data)) article)
2676 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2677 gnus-newsgroup-data-reverse nil)
2679 (gnus-data-update-list gnus-newsgroup-data offset)))
2681 (when (= (gnus-data-number (cadr data)) article)
2682 (setcdr data (cddr data))
2684 (gnus-data-update-list (cdr data) offset))
2686 gnus-newsgroup-data-reverse nil))
2687 (setq data (cdr data))))))
2689 (defmacro gnus-data-list (backward)
2691 (or gnus-newsgroup-data-reverse
2692 (setq gnus-newsgroup-data-reverse
2693 (reverse gnus-newsgroup-data)))
2694 gnus-newsgroup-data))
2696 (defun gnus-data-update-list (data offset)
2697 "Add OFFSET to the POS of all data entries in DATA."
2698 (setq gnus-newsgroup-data-reverse nil)
2700 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2701 (setq data (cdr data))))
2703 (defun gnus-summary-article-pseudo-p (article)
2704 "Say whether this article is a pseudo article or not."
2705 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2707 (defmacro gnus-summary-article-sparse-p (article)
2708 "Say whether this article is a sparse article or not."
2709 `(memq ,article gnus-newsgroup-sparse))
2711 (defmacro gnus-summary-article-ancient-p (article)
2712 "Say whether this article is a sparse article or not."
2713 `(memq ,article gnus-newsgroup-ancient))
2715 (defun gnus-article-parent-p (number)
2716 "Say whether this article is a parent or not."
2717 (let ((data (gnus-data-find-list number)))
2718 (and (cdr data) ; There has to be an article after...
2719 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2720 (gnus-data-level (nth 1 data))))))
2722 (defun gnus-article-children (number)
2723 "Return a list of all children to NUMBER."
2724 (let* ((data (gnus-data-find-list number))
2725 (level (gnus-data-level (car data)))
2727 (setq data (cdr data))
2729 (= (gnus-data-level (car data)) (1+ level)))
2730 (push (gnus-data-number (car data)) children)
2731 (setq data (cdr data)))
2734 (defmacro gnus-summary-skip-intangible ()
2735 "If the current article is intangible, then jump to a different article."
2736 '(let ((to (get-text-property (point) 'gnus-intangible)))
2737 (and to (gnus-summary-goto-subject to))))
2739 (defmacro gnus-summary-article-intangible-p ()
2740 "Say whether this article is intangible or not."
2741 '(get-text-property (point) 'gnus-intangible))
2743 (defun gnus-article-read-p (article)
2744 "Say whether ARTICLE is read or not."
2745 (not (or (memq article gnus-newsgroup-marked)
2746 (memq article gnus-newsgroup-spam-marked)
2747 (memq article gnus-newsgroup-unreads)
2748 (memq article gnus-newsgroup-unselected)
2749 (memq article gnus-newsgroup-dormant))))
2751 ;; Some summary mode macros.
2753 (defmacro gnus-summary-article-number ()
2754 "The article number of the article on the current line.
2755 If there isn's an article number here, then we return the current
2758 (gnus-summary-skip-intangible)
2759 (or (get-text-property (point) 'gnus-number)
2760 (gnus-summary-last-subject))))
2762 (defmacro gnus-summary-article-header (&optional number)
2763 "Return the header of article NUMBER."
2764 `(gnus-data-header (gnus-data-find
2765 ,(or number '(gnus-summary-article-number)))))
2767 (defmacro gnus-summary-thread-level (&optional number)
2768 "Return the level of thread that starts with article NUMBER."
2769 `(if (and (eq gnus-summary-make-false-root 'dummy)
2770 (get-text-property (point) 'gnus-intangible))
2772 (gnus-data-level (gnus-data-find
2773 ,(or number '(gnus-summary-article-number))))))
2775 (defmacro gnus-summary-article-mark (&optional number)
2776 "Return the mark of article NUMBER."
2777 `(gnus-data-mark (gnus-data-find
2778 ,(or number '(gnus-summary-article-number)))))
2780 (defmacro gnus-summary-article-pos (&optional number)
2781 "Return the position of the line of article NUMBER."
2782 `(gnus-data-pos (gnus-data-find
2783 ,(or number '(gnus-summary-article-number)))))
2785 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2786 (defmacro gnus-summary-article-subject (&optional number)
2787 "Return current subject string or nil if nothing."
2790 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2791 '(gnus-data-header (assq (gnus-summary-article-number)
2792 gnus-newsgroup-data)))))
2795 (mail-header-subject headers))))
2797 (defmacro gnus-summary-article-score (&optional number)
2798 "Return current article score."
2799 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2800 gnus-newsgroup-scored))
2801 gnus-summary-default-score 0))
2803 (defun gnus-summary-article-children (&optional number)
2804 "Return a list of article numbers that are children of article NUMBER."
2805 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2806 (level (gnus-data-level (car data)))
2808 (while (and (setq data (cdr data))
2809 (> (setq l (gnus-data-level (car data))) level))
2810 (and (= (1+ level) l)
2811 (push (gnus-data-number (car data))
2813 (nreverse children)))
2815 (defun gnus-summary-article-parent (&optional number)
2816 "Return the article number of the parent of article NUMBER."
2817 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2818 (gnus-data-list t)))
2819 (level (gnus-data-level (car data))))
2821 () ; This is a root.
2822 ;; We search until we find an article with a level less than
2823 ;; this one. That function has to be the parent.
2824 (while (and (setq data (cdr data))
2825 (not (< (gnus-data-level (car data)) level))))
2826 (and data (gnus-data-number (car data))))))
2828 (defun gnus-unread-mark-p (mark)
2829 "Say whether MARK is the unread mark."
2830 (= mark gnus-unread-mark))
2832 (defun gnus-read-mark-p (mark)
2833 "Say whether MARK is one of the marks that mark as read.
2834 This is all marks except unread, ticked, dormant, and expirable."
2835 (not (or (= mark gnus-unread-mark)
2836 (= mark gnus-ticked-mark)
2837 (= mark gnus-dormant-mark)
2838 (= mark gnus-expirable-mark))))
2840 (defmacro gnus-article-mark (number)
2841 "Return the MARK of article NUMBER.
2842 This macro should only be used when computing the mark the \"first\"
2843 time; i.e., when generating the summary lines. After that,
2844 `gnus-summary-article-mark' should be used to examine the
2847 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2848 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2849 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2850 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2851 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2852 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2853 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2854 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2855 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2856 gnus-ancient-mark))))
2858 ;; Saving hidden threads.
2860 (defmacro gnus-save-hidden-threads (&rest forms)
2861 "Save hidden threads, eval FORMS, and restore the hidden threads."
2862 (let ((config (make-symbol "config")))
2863 `(let ((,config (gnus-hidden-threads-configuration)))
2867 (gnus-restore-hidden-threads-configuration ,config)))))
2868 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2869 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2871 (defun gnus-data-compute-positions ()
2872 "Compute the positions of all articles."
2873 (setq gnus-newsgroup-data-reverse nil)
2874 (let ((data gnus-newsgroup-data))
2876 (gnus-save-hidden-threads
2877 (gnus-summary-show-all-threads)
2878 (goto-char (point-min))
2880 (while (get-text-property (point) 'gnus-intangible)
2882 (gnus-data-set-pos (car data) (+ (point) 3))
2883 (setq data (cdr data))
2884 (forward-line 1))))))
2886 (defun gnus-hidden-threads-configuration ()
2887 "Return the current hidden threads configuration."
2890 (goto-char (point-min))
2891 (while (search-forward "\r" nil t)
2892 (push (1- (point)) config))
2895 (defun gnus-restore-hidden-threads-configuration (config)
2896 "Restore hidden threads configuration from CONFIG."
2898 (let (point buffer-read-only)
2899 (while (setq point (pop config))
2900 (when (and (< point (point-max))
2902 (eq (char-after) ?\n))
2903 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2905 ;; Various summary mode internalish functions.
2907 (defun gnus-mouse-pick-article (e)
2910 (gnus-summary-next-page nil t))
2912 (defun gnus-summary-set-display-table ()
2913 "Change the display table.
2914 Odd characters have a tendency to mess
2915 up nicely formatted displays - we make all possible glyphs
2916 display only a single character."
2918 ;; We start from the standard display table, if any.
2919 (let ((table (or (copy-sequence standard-display-table)
2920 (make-display-table)))
2922 ;; Nix out all the control chars...
2923 (while (>= (setq i (1- i)) 0)
2924 (aset table i [??]))
2925 ;; ... but not newline and cr, of course. (cr is necessary for the
2926 ;; selective display).
2927 (aset table ?\n nil)
2928 (aset table ?\r nil)
2929 ;; We keep TAB as well.
2930 (aset table ?\t nil)
2931 ;; We nix out any glyphs over 126 that are not set already.
2933 (while (>= (setq i (1- i)) 127)
2934 ;; Only modify if the entry is nil.
2935 (unless (aref table i)
2936 (aset table i [??]))))
2937 (setq buffer-display-table table)))
2939 (defun gnus-summary-set-article-display-arrow (pos)
2940 "Update the overlay arrow to point to line at position POS."
2941 (when (and gnus-summary-display-arrow
2942 (boundp 'overlay-arrow-position)
2943 (boundp 'overlay-arrow-string))
2947 (unless overlay-arrow-position
2948 (setq overlay-arrow-position (make-marker)))
2949 (setq overlay-arrow-string "=>"
2950 overlay-arrow-position (set-marker overlay-arrow-position
2952 (current-buffer))))))
2954 (defun gnus-summary-buffer-name (group)
2955 "Return the summary buffer name of GROUP."
2956 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2958 (defun gnus-summary-setup-buffer (group)
2959 "Initialize summary buffer."
2960 (let ((buffer (gnus-summary-buffer-name group))
2961 (dead-name (concat "*Dead Summary "
2962 (gnus-group-decoded-name group) "*")))
2963 ;; If a dead summary buffer exists, we kill it.
2964 (when (gnus-buffer-live-p dead-name)
2965 (gnus-kill-buffer dead-name))
2966 (if (get-buffer buffer)
2969 (setq gnus-summary-buffer (current-buffer))
2970 (not gnus-newsgroup-prepared))
2971 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2972 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2973 (gnus-summary-mode group)
2975 (gnus-carpal-setup-buffer 'summary))
2976 (unless gnus-single-article-buffer
2977 (make-local-variable 'gnus-article-buffer)
2978 (make-local-variable 'gnus-article-current)
2979 (make-local-variable 'gnus-original-article-buffer))
2980 (setq gnus-newsgroup-name group)
2981 ;; Set any local variables in the group parameters.
2982 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2985 (defun gnus-set-global-variables ()
2986 "Set the global equivalents of the buffer-local variables.
2987 They are set to the latest values they had. These reflect the summary
2988 buffer that was in action when the last article was fetched."
2989 (when (eq major-mode 'gnus-summary-mode)
2990 (setq gnus-summary-buffer (current-buffer))
2991 (let ((name gnus-newsgroup-name)
2992 (marked gnus-newsgroup-marked)
2993 (spam gnus-newsgroup-spam-marked)
2994 (unread gnus-newsgroup-unreads)
2995 (headers gnus-current-headers)
2996 (data gnus-newsgroup-data)
2997 (summary gnus-summary-buffer)
2998 (article-buffer gnus-article-buffer)
2999 (original gnus-original-article-buffer)
3000 (gac gnus-article-current)
3001 (reffed gnus-reffed-article-number)
3002 (score-file gnus-current-score-file)
3003 (default-charset gnus-newsgroup-charset)
3005 (let ((locals gnus-newsgroup-variables))
3007 (if (consp (car locals))
3008 (push (eval (caar locals)) vlist)
3009 (push (eval (car locals)) vlist))
3010 (setq locals (cdr locals)))
3011 (setq vlist (nreverse vlist)))
3013 (set-buffer gnus-group-buffer)
3014 (setq gnus-newsgroup-name name
3015 gnus-newsgroup-marked marked
3016 gnus-newsgroup-spam-marked spam
3017 gnus-newsgroup-unreads unread
3018 gnus-current-headers headers
3019 gnus-newsgroup-data data
3020 gnus-article-current gac
3021 gnus-summary-buffer summary
3022 gnus-article-buffer article-buffer
3023 gnus-original-article-buffer original
3024 gnus-reffed-article-number reffed
3025 gnus-current-score-file score-file
3026 gnus-newsgroup-charset default-charset)
3027 (let ((locals gnus-newsgroup-variables))
3029 (if (consp (car locals))
3030 (set (caar locals) (pop vlist))
3031 (set (car locals) (pop vlist)))
3032 (setq locals (cdr locals))))
3033 ;; The article buffer also has local variables.
3034 (when (gnus-buffer-live-p gnus-article-buffer)
3035 (set-buffer gnus-article-buffer)
3036 (setq gnus-summary-buffer summary))))))
3038 (defun gnus-summary-article-unread-p (article)
3039 "Say whether ARTICLE is unread or not."
3040 (memq article gnus-newsgroup-unreads))
3042 (defun gnus-summary-first-article-p (&optional article)
3043 "Return whether ARTICLE is the first article in the buffer."
3044 (if (not (setq article (or article (gnus-summary-article-number))))
3046 (eq article (caar gnus-newsgroup-data))))
3048 (defun gnus-summary-last-article-p (&optional article)
3049 "Return whether ARTICLE is the last article in the buffer."
3050 (if (not (setq article (or article (gnus-summary-article-number))))
3051 ;; All non-existent numbers are the last article. :-)
3053 (not (cdr (gnus-data-find-list article)))))
3055 (defun gnus-make-thread-indent-array ()
3057 (unless (and gnus-thread-indent-array
3058 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3059 (setq gnus-thread-indent-array (make-vector 201 "")
3060 gnus-thread-indent-array-level gnus-thread-indent-level)
3062 (aset gnus-thread-indent-array n
3063 (make-string (* n gnus-thread-indent-level) ? ))
3066 (defun gnus-update-summary-mark-positions ()
3067 "Compute where the summary marks are to go."
3069 (when (gnus-buffer-exists-p gnus-summary-buffer)
3070 (set-buffer gnus-summary-buffer))
3071 (let ((gnus-replied-mark 129)
3072 (gnus-score-below-mark 130)
3073 (gnus-score-over-mark 130)
3074 (gnus-download-mark 131)
3075 (spec gnus-summary-line-format-spec)
3078 (gnus-set-work-buffer)
3079 (let ((gnus-summary-line-format-spec spec)
3080 (gnus-newsgroup-downloadable '((0 . t))))
3081 (gnus-summary-insert-line
3082 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3083 0 nil 128 t nil "" nil 1)
3084 (goto-char (point-min))
3085 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3086 (- (point) (point-min) 1)))))
3087 (goto-char (point-min))
3088 (push (cons 'replied (and (search-forward "\201" nil t)
3089 (- (point) (point-min) 1)))
3091 (goto-char (point-min))
3092 (push (cons 'score (and (search-forward "\202" nil t)
3093 (- (point) (point-min) 1)))
3095 (goto-char (point-min))
3096 (push (cons 'download
3097 (and (search-forward "\203" nil t)
3098 (- (point) (point-min) 1)))
3100 (setq gnus-summary-mark-positions pos))))
3102 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3103 "Insert a dummy root in the summary buffer."
3105 (gnus-add-text-properties
3106 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3107 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3109 (defun gnus-summary-extract-address-component (from)
3110 (or (car (funcall gnus-extract-address-components from))
3113 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3114 (let ((mail-parse-charset gnus-newsgroup-charset)
3115 ; Is it really necessary to do this next part for each summary line?
3116 ; Luckily, doesn't seem to slow things down much.
3117 (mail-parse-ignored-charsets
3118 (save-excursion (set-buffer gnus-summary-buffer)
3119 gnus-newsgroup-ignored-charsets)))
3121 (and gnus-ignored-from-addresses
3122 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3123 (let ((extra-headers (mail-header-extra header))
3127 ((setq to (cdr (assq 'To extra-headers)))
3130 (gnus-summary-extract-address-component
3131 (funcall gnus-decode-encoded-word-function to)))))
3132 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3133 (concat "=> " newsgroups)))))
3134 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3136 (defun gnus-summary-insert-line (gnus-tmp-header
3137 gnus-tmp-level gnus-tmp-current
3138 gnus-tmp-unread gnus-tmp-replied
3139 gnus-tmp-expirable gnus-tmp-subject-or-nil
3140 &optional gnus-tmp-dummy gnus-tmp-score
3142 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3143 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3144 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3145 (gnus-tmp-score-char
3146 (if (or (null gnus-summary-default-score)
3147 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3148 gnus-summary-zcore-fuzz))
3150 (if (< gnus-tmp-score gnus-summary-default-score)
3151 gnus-score-below-mark gnus-score-over-mark)))
3152 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3154 (cond (gnus-tmp-process gnus-process-mark)
3155 ((memq gnus-tmp-current gnus-newsgroup-cached)
3157 (gnus-tmp-replied gnus-replied-mark)
3158 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3159 gnus-forwarded-mark)
3160 ((memq gnus-tmp-current gnus-newsgroup-saved)
3162 ((memq gnus-tmp-number gnus-newsgroup-recent)
3164 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3167 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3170 ((string-match "<[^>]+> *$" gnus-tmp-from)
3171 (let ((beg (match-beginning 0)))
3172 (or (and (string-match "^\".+\"" gnus-tmp-from)
3173 (substring gnus-tmp-from 1 (1- (match-end 0))))
3174 (substring gnus-tmp-from 0 beg))))
3175 ((string-match "(.+)" gnus-tmp-from)
3176 (substring gnus-tmp-from
3177 (1+ (match-beginning 0)) (1- (match-end 0))))
3179 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3180 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3181 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3182 (buffer-read-only nil))
3183 (when (string= gnus-tmp-name "")
3184 (setq gnus-tmp-name gnus-tmp-from))
3185 (unless (numberp gnus-tmp-lines)
3186 (setq gnus-tmp-lines -1))
3187 (if (= gnus-tmp-lines -1)
3188 (setq gnus-tmp-lines "?")
3189 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3190 (gnus-put-text-property
3192 (progn (eval gnus-summary-line-format-spec) (point))
3193 'gnus-number gnus-tmp-number)
3194 (when (gnus-visual-p 'summary-highlight 'highlight)
3196 (gnus-run-hooks 'gnus-summary-update-hook)
3199 (defun gnus-summary-update-line (&optional dont-update)
3200 "Update summary line after change."
3201 (when (and gnus-summary-default-score
3202 (not gnus-summary-inhibit-highlight))
3203 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3204 (article (gnus-summary-article-number))
3205 (score (gnus-summary-article-score article)))
3207 (if (and gnus-summary-mark-below
3208 (< (gnus-summary-article-score)
3209 gnus-summary-mark-below))
3210 ;; This article has a low score, so we mark it as read.
3211 (when (memq article gnus-newsgroup-unreads)
3212 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3213 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3214 ;; This article was previously marked as read on account
3215 ;; of a low score, but now it has risen, so we mark it as
3217 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3218 (gnus-summary-update-mark
3219 (if (or (null gnus-summary-default-score)
3220 (<= (abs (- score gnus-summary-default-score))
3221 gnus-summary-zcore-fuzz))
3223 (if (< score gnus-summary-default-score)
3224 gnus-score-below-mark gnus-score-over-mark))
3226 ;; Do visual highlighting.
3227 (when (gnus-visual-p 'summary-highlight 'highlight)
3228 (gnus-run-hooks 'gnus-summary-update-hook)))))
3230 (defvar gnus-tmp-new-adopts nil)
3232 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3233 "Return the number of articles in THREAD.
3234 This may be 0 in some cases -- if none of the articles in
3235 the thread are to be displayed."
3237 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3239 ((not (listp thread))
3241 ((and (consp thread) (cdr thread))
3244 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3247 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3250 (when (and level (zerop level) gnus-tmp-new-adopts)
3253 'gnus-summary-number-of-articles-in-thread
3254 gnus-tmp-new-adopts))))
3256 (if (> number 1) gnus-not-empty-thread-mark
3257 gnus-empty-thread-mark)
3260 (defsubst gnus-summary-line-message-size (head)
3261 "Return pretty-printed version of message size.
3262 This function is intended to be used in
3263 `gnus-summary-line-format-alist', which see."
3264 (let ((c (or (mail-header-chars head) -1)))
3265 (cond ((< c 0) "n/a") ; chars not available
3266 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3267 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3268 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3269 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3272 (defun gnus-summary-set-local-parameters (group)
3273 "Go through the local params of GROUP and set all variable specs in that list."
3274 (let ((params (gnus-group-find-parameter group))
3275 (vars '(quit-config)) ; Ignore quit-config.
3278 (setq elem (car params)
3279 params (cdr params))
3280 (and (consp elem) ; Has to be a cons.
3281 (consp (cdr elem)) ; The cdr has to be a list.
3282 (symbolp (car elem)) ; Has to be a symbol in there.
3283 (not (memq (car elem) vars))
3284 (ignore-errors ; So we set it.
3285 (push (car elem) vars)
3286 (make-local-variable (car elem))
3287 (set (car elem) (eval (nth 1 elem))))))))
3289 (defun gnus-summary-read-group (group &optional show-all no-article
3290 kill-buffer no-display backward
3292 "Start reading news in newsgroup GROUP.
3293 If SHOW-ALL is non-nil, already read articles are also listed.
3294 If NO-ARTICLE is non-nil, no article is selected initially.
3295 If NO-DISPLAY, don't generate a summary buffer."
3299 (let ((gnus-auto-select-next nil))
3300 (or (gnus-summary-read-group-1
3301 group show-all no-article
3302 kill-buffer no-display
3305 select-articles nil)))))
3306 (eq gnus-auto-select-next 'quietly))
3307 (set-buffer gnus-group-buffer)
3308 ;; The entry function called above goes to the next
3309 ;; group automatically, so we go two groups back
3310 ;; if we are searching for the previous group.
3312 (gnus-group-prev-unread-group 2))
3313 (if (not (equal group (gnus-group-group-name)))
3314 (setq group (gnus-group-group-name))
3318 (defun gnus-summary-read-group-1 (group show-all no-article
3319 kill-buffer no-display
3320 &optional select-articles)
3321 ;; Killed foreign groups can't be entered.
3322 ;; (when (and (not (gnus-group-native-p group))
3323 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3324 ;; (error "Dead non-native groups can't be entered"))
3325 (gnus-message 5 "Retrieving newsgroup: %s..."
3326 (gnus-group-decoded-name group))
3327 (let* ((new-group (gnus-summary-setup-buffer group))
3328 (quit-config (gnus-group-quit-config group))
3329 (did-select (and new-group (gnus-select-newsgroup
3330 group show-all select-articles))))
3332 ;; This summary buffer exists already, so we just select it.
3334 (gnus-set-global-variables)
3336 (gnus-kill-or-deaden-summary kill-buffer))
3337 (gnus-configure-windows 'summary 'force)
3338 (gnus-set-mode-line 'summary)
3339 (gnus-summary-position-point)
3342 ;; We couldn't select this group.
3344 (when (and (eq major-mode 'gnus-summary-mode)
3345 (not (equal (current-buffer) kill-buffer)))
3346 (kill-buffer (current-buffer))
3347 (if (not quit-config)
3349 ;; Update the info -- marks might need to be removed,
3351 (gnus-summary-update-info)
3352 (set-buffer gnus-group-buffer)
3353 (gnus-group-jump-to-group group)
3354 (gnus-group-next-unread-group 1))
3355 (gnus-handle-ephemeral-exit quit-config)))
3356 (let ((grpinfo (gnus-get-info group)))
3357 (if (null (gnus-info-read grpinfo))
3358 (gnus-message 3 "Group %s contains no messages"
3359 (gnus-group-decoded-name group))
3360 (gnus-message 3 "Can't select group")))
3362 ;; The user did a `C-g' while prompting for number of articles,
3363 ;; so we exit this group.
3364 ((eq did-select 'quit)
3365 (and (eq major-mode 'gnus-summary-mode)
3366 (not (equal (current-buffer) kill-buffer))
3367 (kill-buffer (current-buffer)))
3369 (gnus-kill-or-deaden-summary kill-buffer))
3370 (if (not quit-config)
3372 (set-buffer gnus-group-buffer)
3373 (gnus-group-jump-to-group group)
3374 (gnus-group-next-unread-group 1)
3375 (gnus-configure-windows 'group 'force))
3376 (gnus-handle-ephemeral-exit quit-config))
3377 ;; Finally signal the quit.
3379 ;; The group was successfully selected.
3381 (gnus-set-global-variables)
3382 ;; Save the active value in effect when the group was entered.
3383 (setq gnus-newsgroup-active
3385 (gnus-active gnus-newsgroup-name)))
3386 ;; You can change the summary buffer in some way with this hook.
3387 (gnus-run-hooks 'gnus-select-group-hook)
3388 (gnus-update-format-specifications
3389 nil 'summary 'summary-mode 'summary-dummy)
3390 (gnus-update-summary-mark-positions)
3391 ;; Do score processing.
3392 (when gnus-use-scoring
3393 (gnus-possibly-score-headers))
3394 ;; Check whether to fill in the gaps in the threads.
3395 (when gnus-build-sparse-threads
3396 (gnus-build-sparse-threads))
3397 ;; Find the initial limit.
3398 (if gnus-show-threads
3400 (let ((gnus-newsgroup-dormant nil))
3401 (gnus-summary-initial-limit show-all))
3402 (gnus-summary-initial-limit show-all))
3403 ;; When untreaded, all articles are always shown.
3404 (setq gnus-newsgroup-limit
3406 (lambda (header) (mail-header-number header))
3407 gnus-newsgroup-headers)))
3408 ;; Generate the summary buffer.
3410 (gnus-summary-prepare))
3411 (when gnus-use-trees
3412 (gnus-tree-open group)
3413 (setq gnus-summary-highlight-line-function
3414 'gnus-tree-highlight-article))
3415 ;; If the summary buffer is empty, but there are some low-scored
3416 ;; articles or some excluded dormants, we include these in the
3418 (when (and (zerop (buffer-size))
3420 (cond (gnus-newsgroup-dormant
3421 (gnus-summary-limit-include-dormant))
3422 ((and gnus-newsgroup-scored show-all)
3423 (gnus-summary-limit-include-expunged t))))
3424 ;; Function `gnus-apply-kill-file' must be called in this hook.
3425 (gnus-run-hooks 'gnus-apply-kill-hook)
3426 (if (and (zerop (buffer-size))
3429 ;; This newsgroup is empty.
3430 (gnus-summary-catchup-and-exit nil t)
3431 (gnus-message 6 "No unread news")
3433 (gnus-kill-or-deaden-summary kill-buffer))
3434 ;; Return nil from this function.
3436 ;; Hide conversation thread subtrees. We cannot do this in
3437 ;; gnus-summary-prepare-hook since kill processing may not
3438 ;; work with hidden articles.
3439 (gnus-summary-maybe-hide-threads)
3441 (gnus-kill-or-deaden-summary kill-buffer))
3442 (gnus-summary-auto-select-subject)
3443 ;; Show first unread article if requested.
3444 (if (and (not no-article)
3446 gnus-newsgroup-unreads
3447 gnus-auto-select-first)
3449 (gnus-configure-windows 'summary)
3450 (let ((art (gnus-summary-article-number)))
3451 (unless (or (memq art gnus-newsgroup-undownloaded)
3452 (memq art gnus-newsgroup-downloadable))
3453 (gnus-summary-goto-article art))))
3454 ;; Don't select any articles.
3455 (gnus-summary-position-point)
3456 (gnus-configure-windows 'summary 'force)
3457 (gnus-set-mode-line 'summary))
3458 (when (get-buffer-window gnus-group-buffer t)
3459 ;; Gotta use windows, because recenter does weird stuff if
3460 ;; the current buffer ain't the displayed window.
3461 (let ((owin (selected-window)))
3462 (select-window (get-buffer-window gnus-group-buffer t))
3463 (when (gnus-group-goto-group group)
3465 (select-window owin)))
3466 ;; Mark this buffer as "prepared".
3467 (setq gnus-newsgroup-prepared t)
3468 (gnus-run-hooks 'gnus-summary-prepared-hook)
3471 (defun gnus-summary-auto-select-subject ()
3472 "Select the subject line on initial group entry."
3473 (goto-char (point-min))
3475 ((eq gnus-auto-select-subject 'best)
3476 (gnus-summary-best-unread-subject))
3477 ((eq gnus-auto-select-subject 'unread)
3478 (gnus-summary-first-unread-subject))
3479 ((eq gnus-auto-select-subject 'unseen)
3480 (gnus-summary-first-unseen-subject))
3481 ((eq gnus-auto-select-subject 'unseen-or-unread)
3482 (gnus-summary-first-unseen-or-unread-subject))
3483 ((eq gnus-auto-select-subject 'first)
3486 ((gnus-functionp gnus-auto-select-subject)
3487 (funcall gnus-auto-select-subject))))
3489 (defun gnus-summary-prepare ()
3490 "Generate the summary buffer."
3492 (let ((buffer-read-only nil))
3494 (setq gnus-newsgroup-data nil
3495 gnus-newsgroup-data-reverse nil)
3496 (gnus-run-hooks 'gnus-summary-generate-hook)
3497 ;; Generate the buffer, either with threads or without.
3498 (when gnus-newsgroup-headers
3499 (gnus-summary-prepare-threads
3500 (if gnus-show-threads
3501 (gnus-sort-gathered-threads
3502 (funcall gnus-summary-thread-gathering-function
3504 (gnus-cut-threads (gnus-make-threads)))))
3505 ;; Unthreaded display.
3506 (gnus-sort-articles gnus-newsgroup-headers))))
3507 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3508 ;; Call hooks for modifying summary buffer.
3509 (goto-char (point-min))
3510 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3512 (defsubst gnus-general-simplify-subject (subject)
3513 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3516 ;; Truncate the subject.
3517 (gnus-simplify-subject-functions
3518 (gnus-map-function gnus-simplify-subject-functions subject))
3519 ((numberp gnus-summary-gather-subject-limit)
3520 (setq subject (gnus-simplify-subject-re subject))
3521 (if (> (length subject) gnus-summary-gather-subject-limit)
3522 (substring subject 0 gnus-summary-gather-subject-limit)
3524 ;; Fuzzily simplify it.
3525 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3526 (gnus-simplify-subject-fuzzy subject))
3527 ;; Just remove the leading "Re:".
3529 (gnus-simplify-subject-re subject))))
3531 (if (and gnus-summary-gather-exclude-subject
3532 (string-match gnus-summary-gather-exclude-subject subject))
3533 nil ; This article shouldn't be gathered
3536 (defun gnus-summary-simplify-subject-query ()
3537 "Query where the respool algorithm would put this article."
3539 (gnus-summary-select-article)
3540 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3542 (defun gnus-gather-threads-by-subject (threads)
3543 "Gather threads by looking at Subject headers."
3544 (if (not gnus-summary-make-false-root)
3546 (let ((hashtb (gnus-make-hashtable 1024))
3549 subject hthread whole-subject)
3551 (setq subject (gnus-general-simplify-subject
3552 (setq whole-subject (mail-header-subject
3555 (if (setq hthread (gnus-gethash subject hashtb))
3557 ;; We enter a dummy root into the thread, if we
3558 ;; haven't done that already.
3559 (unless (stringp (caar hthread))
3560 (setcar hthread (list whole-subject (car hthread))))
3561 ;; We add this new gathered thread to this gathered
3563 (setcdr (car hthread)
3564 (nconc (cdar hthread) (list (car threads))))
3565 ;; Remove it from the list of threads.
3566 (setcdr prev (cdr threads))
3567 (setq threads prev))
3568 ;; Enter this thread into the hash table.
3569 (gnus-sethash subject threads hashtb)))
3571 (setq threads (cdr threads)))
3574 (defun gnus-gather-threads-by-references (threads)
3575 "Gather threads by looking at References headers."
3576 (let ((idhashtb (gnus-make-hashtable 1024))
3577 (thhashtb (gnus-make-hashtable 1024))
3580 ids references id gthread gid entered ref)
3582 (when (setq references (mail-header-references (caar threads)))
3583 (setq id (mail-header-id (caar threads))
3584 ids (inline (gnus-split-references references))
3586 (while (setq ref (pop ids))
3587 (setq ids (delete ref ids))
3588 (if (not (setq gid (gnus-gethash ref idhashtb)))
3590 (gnus-sethash ref id idhashtb)
3591 (gnus-sethash id threads thhashtb))
3592 (setq gthread (gnus-gethash gid thhashtb))
3594 ;; We enter a dummy root into the thread, if we
3595 ;; haven't done that already.
3596 (unless (stringp (caar gthread))
3597 (setcar gthread (list (mail-header-subject (caar gthread))
3599 ;; We add this new gathered thread to this gathered
3601 (setcdr (car gthread)
3602 (nconc (cdar gthread) (list (car threads)))))
3603 ;; Add it into the thread hash table.
3604 (gnus-sethash id gthread thhashtb)
3606 ;; Remove it from the list of threads.
3607 (setcdr prev (cdr threads))
3608 (setq threads prev))))
3610 (setq threads (cdr threads)))
3613 (defun gnus-sort-gathered-threads (threads)
3614 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3615 (let ((result threads))
3617 (when (stringp (caar threads))
3618 (setcdr (car threads)
3619 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3620 (setq threads (cdr threads)))
3623 (defun gnus-thread-loop-p (root thread)
3624 "Say whether ROOT is in THREAD."
3625 (let ((stack (list thread))
3628 (while (setq thread (pop stack))
3629 (setq th (cdr thread))
3631 (not (eq (caar th) root)))
3634 ;; We have found a loop.
3636 (setcdr thread (delq (car th) (cdr thread)))
3637 (if (boundp (setq ref-dep (intern "none"
3638 gnus-newsgroup-dependencies)))
3639 (setcdr (symbol-value ref-dep)
3640 (nconc (cdr (symbol-value ref-dep))
3642 (set ref-dep (list nil (car th))))
3645 ;; Push all the subthreads onto the stack.
3646 (push (cdr thread) stack)))
3649 (defun gnus-make-threads ()
3650 "Go through the dependency hashtb and find the roots. Return all threads."
3652 (while (catch 'infloop
3655 ;; Deal with self-referencing References loops.
3656 (when (and (car (symbol-value refs))
3663 (car (symbol-value refs)) thread))
3664 (cdr (symbol-value refs)))))))
3667 (unless (car (symbol-value refs))
3668 ;; These threads do not refer back to any other
3669 ;; articles, so they're roots.
3670 (setq threads (append (cdr (symbol-value refs)) threads))))
3671 gnus-newsgroup-dependencies)))
3674 ;; Build the thread tree.
3675 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3676 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3678 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3679 if it was already present.
3681 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3682 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3683 Message-IDs will be renamed to a unique Message-ID before being
3686 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3687 (let* ((id (mail-header-id header))
3688 (id-dep (and id (intern id dependencies)))
3689 parent-id ref ref-dep ref-header replaced)
3690 ;; Enter this `header' in the `dependencies' table.
3694 ;; The first two cases do the normal part: enter a new `header'
3695 ;; in the `dependencies' table.
3696 ((not (boundp id-dep))
3697 (set id-dep (list header)))
3698 ((null (car (symbol-value id-dep)))
3699 (setcar (symbol-value id-dep) header))
3701 ;; From here the `header' was already present in the
3702 ;; `dependencies' table.
3704 ;; Overrides an existing entry;
3705 ;; just set the header part of the entry.
3706 (setcar (symbol-value id-dep) header)
3709 ;; Renames the existing `header' to a unique Message-ID.
3710 ((not gnus-summary-ignore-duplicates)
3711 ;; An article with this Message-ID has already been seen.
3712 ;; We rename the Message-ID.
3713 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3715 (mail-header-set-id header id))
3717 ;; The last case ignores an existing entry, except it adds any
3718 ;; additional Xrefs (in case the two articles came from different
3720 ;; Also sets `header' to `nil' meaning that the `dependencies'
3721 ;; table was *not* modified.
3723 (mail-header-set-xref
3724 (car (symbol-value id-dep))
3725 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3727 (or (mail-header-xref header) "")))
3730 (when (and header (not replaced))
3731 ;; First check that we are not creating a References loop.
3732 (setq parent-id (gnus-parent-id (mail-header-references header)))
3733 (setq ref parent-id)
3735 (setq ref-dep (intern-soft ref dependencies))
3737 (setq ref-header (car (symbol-value ref-dep))))
3738 (if (string= id ref)
3739 ;; Yuk! This is a reference loop. Make the article be a
3742 (mail-header-set-references (car (symbol-value id-dep)) "none")
3744 (setq parent-id nil))
3745 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3746 (setq ref-dep (intern (or parent-id "none") dependencies))
3747 (if (boundp ref-dep)
3748 (setcdr (symbol-value ref-dep)
3749 (nconc (cdr (symbol-value ref-dep))
3750 (list (symbol-value id-dep))))
3751 (set ref-dep (list nil (symbol-value id-dep)))))
3754 (defun gnus-extract-message-id-from-in-reply-to (string)
3755 (if (string-match "<[^>]+>" string)
3756 (substring string (match-beginning 0) (match-end 0))
3759 (defun gnus-build-sparse-threads ()
3760 (let ((headers gnus-newsgroup-headers)
3761 (mail-parse-charset gnus-newsgroup-charset)
3762 (gnus-summary-ignore-duplicates t)
3763 header references generation relations
3764 subject child end new-child date)
3765 ;; First we create an alist of generations/relations, where
3766 ;; generations is how much we trust the relation, and the relation
3768 (gnus-message 7 "Making sparse threads...")
3770 (nnheader-set-temp-buffer " *gnus sparse threads*")
3771 (while (setq header (pop headers))
3772 (when (and (setq references (mail-header-references header))
3773 (not (string= references "")))
3775 (setq child (mail-header-id header)
3776 subject (mail-header-subject header)
3777 date (mail-header-date header)
3779 (while (search-backward ">" nil t)
3780 (setq end (1+ (point)))
3781 (when (search-backward "<" nil t)
3782 (setq new-child (buffer-substring (point) end))
3783 (push (list (incf generation)
3784 child (setq child new-child)
3788 (push (list (1+ generation) child nil subject) relations))
3790 (kill-buffer (current-buffer)))
3791 ;; Sort over trustworthiness.
3794 (when (gnus-dependencies-add-header
3795 (make-full-mail-header
3796 gnus-reffed-article-number
3797 (nth 3 relation) "" (or (nth 4 relation) "")
3799 (or (nth 2 relation) "") 0 0 "")
3800 gnus-newsgroup-dependencies nil)
3801 (push gnus-reffed-article-number gnus-newsgroup-limit)
3802 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3803 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3804 gnus-newsgroup-reads)
3805 (decf gnus-reffed-article-number)))
3806 (sort relations 'car-less-than-car))
3807 (gnus-message 7 "Making sparse threads...done")))
3809 (defun gnus-build-old-threads ()
3810 ;; Look at all the articles that refer back to old articles, and
3811 ;; fetch the headers for the articles that aren't there. This will
3812 ;; build complete threads - if the roots haven't been expired by the
3814 (let ((mail-parse-charset gnus-newsgroup-charset)
3818 (when (not (car (symbol-value refs)))
3819 (setq heads (cdr (symbol-value refs)))
3821 (if (memq (mail-header-number (caar heads))
3822 gnus-newsgroup-dormant)
3823 (setq heads (cdr heads))
3824 (setq id (symbol-name refs))
3825 (while (and (setq id (gnus-build-get-header id))
3826 (not (car (gnus-id-to-thread id)))))
3827 (setq heads nil)))))
3828 gnus-newsgroup-dependencies)))
3830 ;; This function has to be called with point after the article number
3831 ;; on the beginning of the line.
3832 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3833 (let ((eol (gnus-point-at-eol))
3834 (buffer (current-buffer))
3835 header references in-reply-to)
3837 ;; overview: [num subject from date id refs chars lines misc]
3840 (narrow-to-region (point) eol)
3845 (make-full-mail-header
3847 (funcall gnus-decode-encoded-word-function
3848 (nnheader-nov-field)) ; subject
3849 (funcall gnus-decode-encoded-word-function
3850 (nnheader-nov-field)) ; from
3851 (nnheader-nov-field) ; date
3852 (nnheader-nov-read-message-id) ; id
3853 (setq references (nnheader-nov-field)) ; refs
3854 (nnheader-nov-read-integer) ; chars
3855 (nnheader-nov-read-integer) ; lines
3857 (if (looking-at "Xref: ")
3858 (goto-char (match-end 0)))
3859 (nnheader-nov-field)) ; Xref
3860 (nnheader-nov-parse-extra)))) ; extra
3864 (when (and (string= references "")
3865 (setq in-reply-to (mail-header-extra header))
3866 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3867 (mail-header-set-references
3868 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3870 (when gnus-alter-header-function
3871 (funcall gnus-alter-header-function header))
3872 (gnus-dependencies-add-header header dependencies force-new)))
3874 (defun gnus-build-get-header (id)
3875 "Look through the buffer of NOV lines and find the header to ID.
3876 Enter this line into the dependencies hash table, and return
3877 the id of the parent article (if any)."
3878 (let ((deps gnus-newsgroup-dependencies)
3882 (set-buffer nntp-server-buffer)
3883 (let ((case-fold-search nil))
3884 (goto-char (point-min))
3885 (while (and (not found)
3886 (search-forward id nil t))
3888 (setq found (looking-at
3889 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3890 (regexp-quote id))))
3891 (or found (beginning-of-line 2)))
3895 (setq header (gnus-nov-parse-line
3896 (read (current-buffer)) deps))
3897 (gnus-parent-id (mail-header-references header))))))
3899 (let ((number (mail-header-number header)))
3900 (push number gnus-newsgroup-limit)
3901 (push header gnus-newsgroup-headers)
3902 (if (memq number gnus-newsgroup-unselected)
3904 (setq gnus-newsgroup-unreads
3905 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3907 (setq gnus-newsgroup-unselected
3908 (delq number gnus-newsgroup-unselected)))
3909 (push number gnus-newsgroup-ancient)))))))
3911 (defun gnus-build-all-threads ()
3912 "Read all the headers."
3913 (let ((gnus-summary-ignore-duplicates t)
3914 (mail-parse-charset gnus-newsgroup-charset)
3915 (dependencies gnus-newsgroup-dependencies)
3918 (set-buffer nntp-server-buffer)
3919 (let ((case-fold-search nil))
3920 (goto-char (point-min))
3923 (setq article (read (current-buffer))
3924 header (gnus-nov-parse-line article dependencies)))
3927 (set-buffer gnus-summary-buffer)
3928 (push header gnus-newsgroup-headers)
3929 (if (memq (setq article (mail-header-number header))
3930 gnus-newsgroup-unselected)
3932 (setq gnus-newsgroup-unreads
3933 (gnus-add-to-sorted-list
3934 gnus-newsgroup-unreads article))
3935 (setq gnus-newsgroup-unselected
3936 (delq article gnus-newsgroup-unselected)))
3937 (push article gnus-newsgroup-ancient)))
3938 (forward-line 1)))))))
3940 (defun gnus-summary-update-article-line (article header)
3941 "Update the line for ARTICLE using HEADERS."
3942 (let* ((id (mail-header-id header))
3943 (thread (gnus-id-to-thread id)))
3945 (error "Article in no thread"))
3946 ;; Update the thread.
3947 (setcar thread header)
3948 (gnus-summary-goto-subject article)
3949 (let* ((datal (gnus-data-find-list article))
3951 (length (when (cdr datal)
3952 (- (gnus-data-pos data)
3953 (gnus-data-pos (cadr datal)))))
3954 (buffer-read-only nil)
3955 (level (gnus-summary-thread-level)))
3957 (gnus-summary-insert-line
3958 header level nil (gnus-article-mark article)
3959 (memq article gnus-newsgroup-replied)
3960 (memq article gnus-newsgroup-expirable)
3961 ;; Only insert the Subject string when it's different
3962 ;; from the previous Subject string.
3967 (mail-header-subject
3970 (gnus-data-find-list
3972 (gnus-data-list t)))))
3973 ;; Error on the side of excessive subjects.
3975 (mail-header-subject header)))
3977 (mail-header-subject header))
3978 nil (cdr (assq article gnus-newsgroup-scored))
3979 (memq article gnus-newsgroup-processable))
3981 (gnus-data-update-list
3982 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3984 (defun gnus-summary-update-article (article &optional iheader)
3985 "Update ARTICLE in the summary buffer."
3986 (set-buffer gnus-summary-buffer)
3987 (let* ((header (gnus-summary-article-header article))
3988 (id (mail-header-id header))
3989 (data (gnus-data-find article))
3990 (thread (gnus-id-to-thread id))
3991 (references (mail-header-references header))
3995 (when (and references
3996 (not (equal "" references)))
3999 (buffer-read-only nil)
4005 (delq thread parent)))
4006 (if (gnus-summary-insert-subject id header)
4007 ;; Set the (possibly) new article number in the data structure.
4008 (gnus-data-set-number data (gnus-id-to-article id))
4012 (defun gnus-rebuild-thread (id &optional line)
4013 "Rebuild the thread containing ID.
4014 If LINE, insert the rebuilt thread starting on line LINE."
4015 (let ((buffer-read-only nil)
4016 old-pos current thread data)
4017 (if (not gnus-show-threads)
4018 (setq thread (list (car (gnus-id-to-thread id))))
4019 ;; Get the thread this article is part of.
4020 (setq thread (gnus-remove-thread id)))
4021 (setq old-pos (gnus-point-at-bol))
4022 (setq current (save-excursion
4023 (and (re-search-backward "[\r\n]" nil t)
4024 (gnus-summary-article-number))))
4025 ;; If this is a gathered thread, we have to go some re-gathering.
4026 (when (stringp (car thread))
4027 (let ((subject (car thread))
4029 (setq thread (cdr thread))
4031 (unless (memq (setq thr (gnus-id-to-thread
4033 (mail-header-id (caar thread)))))
4036 (setq thread (cdr thread)))
4037 ;; We now have all (unique) roots.
4038 (if (= (length roots) 1)
4039 ;; All the loose roots are now one solid root.
4040 (setq thread (car roots))
4041 (setq thread (cons subject (gnus-sort-threads roots))))))
4043 ;; We then insert this thread into the summary buffer.
4045 (goto-char (point-min))
4046 (forward-line (1- line)))
4047 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4048 (if gnus-show-threads
4049 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4050 (gnus-summary-prepare-unthreaded thread))
4051 (setq data (nreverse gnus-newsgroup-data))
4052 (setq threads gnus-newsgroup-threads))
4053 ;; We splice the new data into the data structure.
4054 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4055 ;;!!! then we want to insert at the beginning of the buffer.
4056 ;;!!! That happens to be true with Gnus now, but that may
4057 ;;!!! change in the future. Perhaps.
4058 (gnus-data-enter-list
4059 (if line nil current) data (- (point) old-pos))
4060 (setq gnus-newsgroup-threads
4061 (nconc threads gnus-newsgroup-threads))
4062 (gnus-data-compute-positions))))
4064 (defun gnus-number-to-header (number)
4065 "Return the header for article NUMBER."
4066 (let ((headers gnus-newsgroup-headers))
4068 (not (= number (mail-header-number (car headers)))))
4073 (defun gnus-parent-headers (in-headers &optional generation)
4074 "Return the headers of the GENERATIONeth parent of HEADERS."
4076 (setq generation 1))
4078 (headers in-headers)
4081 (not (zerop generation))
4082 (setq references (mail-header-references headers)))
4083 (setq headers (if (and references
4084 (setq parent (gnus-parent-id references)))
4085 (car (gnus-id-to-thread parent))
4088 (and (not (eq headers in-headers))
4091 (defun gnus-id-to-thread (id)
4092 "Return the (sub-)thread where ID appears."
4093 (gnus-gethash id gnus-newsgroup-dependencies))
4095 (defun gnus-id-to-article (id)
4096 "Return the article number of ID."
4097 (let ((thread (gnus-id-to-thread id)))
4100 (mail-header-number (car thread)))))
4102 (defun gnus-id-to-header (id)
4103 "Return the article headers of ID."
4104 (car (gnus-id-to-thread id)))
4106 (defun gnus-article-displayed-root-p (article)
4107 "Say whether ARTICLE is a root(ish) article."
4108 (let ((level (gnus-summary-thread-level article))
4109 (refs (mail-header-references (gnus-summary-article-header article)))
4115 ((null (gnus-parent-id refs)) t)
4117 (null (setq particle (gnus-id-to-article
4118 (gnus-parent-id refs))))
4119 (null (gnus-summary-thread-level particle)))))))
4121 (defun gnus-root-id (id)
4122 "Return the id of the root of the thread where ID appears."
4124 (while (and id (setq prev (car (gnus-id-to-thread id))))
4126 id (gnus-parent-id (mail-header-references prev))))
4129 (defun gnus-articles-in-thread (thread)
4130 "Return the list of articles in THREAD."
4131 (cons (mail-header-number (car thread))
4132 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4134 (defun gnus-remove-thread (id &optional dont-remove)
4135 "Remove the thread that has ID in it."
4136 (let (headers thread last-id)
4137 ;; First go up in this thread until we find the root.
4138 (setq last-id (gnus-root-id id)
4139 headers (message-flatten-list (gnus-id-to-thread last-id)))
4140 ;; We have now found the real root of this thread. It might have
4141 ;; been gathered into some loose thread, so we have to search
4142 ;; through the threads to find the thread we wanted.
4143 (let ((threads gnus-newsgroup-threads)
4146 (setq sub (car threads))
4147 (if (stringp (car sub))
4148 ;; This is a gathered thread, so we look at the roots
4149 ;; below it to find whether this article is in this
4152 (setq sub (cdr sub))
4154 (when (member (caar sub) headers)
4155 (setq thread (car threads)
4158 (setq sub (cdr sub))))
4159 ;; It's an ordinary thread, so we check it.
4160 (when (eq (car sub) (car headers))
4163 (setq threads (cdr threads)))
4164 ;; If this article is in no thread, then it's a root.
4167 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4168 (setq thread (gnus-id-to-thread last-id)))
4171 thread ; We return this thread.
4173 (if (stringp (car thread))
4175 ;; If we use dummy roots, then we have to remove the
4176 ;; dummy root as well.
4177 (when (eq gnus-summary-make-false-root 'dummy)
4178 ;; We go to the dummy root by going to
4179 ;; the first sub-"thread", and then one line up.
4180 (gnus-summary-goto-article
4181 (mail-header-number (caadr thread)))
4184 (gnus-data-compute-positions))
4185 (setq thread (cdr thread))
4187 (gnus-remove-thread-1 (car thread))
4188 (setq thread (cdr thread))))
4189 (gnus-remove-thread-1 thread))))))))
4191 (defun gnus-remove-thread-1 (thread)
4192 "Remove the thread THREAD recursively."
4193 (let ((number (mail-header-number (pop thread)))
4195 (setq thread (reverse thread))
4197 (gnus-remove-thread-1 (pop thread)))
4198 (when (setq d (gnus-data-find number))
4199 (goto-char (gnus-data-pos d))
4200 (gnus-summary-show-thread)
4203 (- (gnus-point-at-bol)
4205 (1+ (gnus-point-at-eol))
4206 (gnus-delete-line)))))))
4208 (defun gnus-sort-threads-1 (threads func)
4209 (sort (mapcar (lambda (thread)
4212 (gnus-sort-threads-1 (cdr thread) func))))
4215 (defun gnus-sort-threads (threads)
4217 (if (not gnus-thread-sort-functions)
4219 (gnus-message 8 "Sorting threads...")
4221 (gnus-sort-threads-1
4223 (gnus-make-sort-function gnus-thread-sort-functions))
4224 (gnus-message 8 "Sorting threads...done"))))
4226 (defun gnus-sort-articles (articles)
4228 (when gnus-article-sort-functions
4229 (gnus-message 7 "Sorting articles...")
4231 (setq gnus-newsgroup-headers
4232 (sort articles (gnus-make-sort-function
4233 gnus-article-sort-functions)))
4234 (gnus-message 7 "Sorting articles...done"))))
4236 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4237 (defmacro gnus-thread-header (thread)
4238 "Return header of first article in THREAD.
4239 Note that THREAD must never, ever be anything else than a variable -
4240 using some other form will lead to serious barfage."
4241 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4242 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4243 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4246 (defsubst gnus-article-sort-by-number (h1 h2)
4247 "Sort articles by article number."
4248 (< (mail-header-number h1)
4249 (mail-header-number h2)))
4251 (defun gnus-thread-sort-by-number (h1 h2)
4252 "Sort threads by root article number."
4253 (gnus-article-sort-by-number
4254 (gnus-thread-header h1) (gnus-thread-header h2)))
4256 (defsubst gnus-article-sort-by-random (h1 h2)
4257 "Sort articles by article number."
4260 (defun gnus-thread-sort-by-random (h1 h2)
4261 "Sort threads by root article number."
4262 (gnus-article-sort-by-random
4263 (gnus-thread-header h1) (gnus-thread-header h2)))
4265 (defsubst gnus-article-sort-by-lines (h1 h2)
4266 "Sort articles by article Lines header."
4267 (< (mail-header-lines h1)
4268 (mail-header-lines h2)))
4270 (defun gnus-thread-sort-by-lines (h1 h2)
4271 "Sort threads by root article Lines header."
4272 (gnus-article-sort-by-lines
4273 (gnus-thread-header h1) (gnus-thread-header h2)))
4275 (defsubst gnus-article-sort-by-chars (h1 h2)
4276 "Sort articles by octet length."
4277 (< (mail-header-chars h1)
4278 (mail-header-chars h2)))
4280 (defun gnus-thread-sort-by-chars (h1 h2)
4281 "Sort threads by root article octet length."
4282 (gnus-article-sort-by-chars
4283 (gnus-thread-header h1) (gnus-thread-header h2)))
4285 (defsubst gnus-article-sort-by-author (h1 h2)
4286 "Sort articles by root author."
4288 (let ((extract (funcall
4289 gnus-extract-address-components
4290 (mail-header-from h1))))
4291 (or (car extract) (cadr extract) ""))
4292 (let ((extract (funcall
4293 gnus-extract-address-components
4294 (mail-header-from h2))))
4295 (or (car extract) (cadr extract) ""))))
4297 (defun gnus-thread-sort-by-author (h1 h2)
4298 "Sort threads by root author."
4299 (gnus-article-sort-by-author
4300 (gnus-thread-header h1) (gnus-thread-header h2)))
4302 (defsubst gnus-article-sort-by-subject (h1 h2)
4303 "Sort articles by root subject."
4305 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4306 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4308 (defun gnus-thread-sort-by-subject (h1 h2)
4309 "Sort threads by root subject."
4310 (gnus-article-sort-by-subject
4311 (gnus-thread-header h1) (gnus-thread-header h2)))
4313 (defsubst gnus-article-sort-by-date (h1 h2)
4314 "Sort articles by root article date."
4316 (gnus-date-get-time (mail-header-date h1))
4317 (gnus-date-get-time (mail-header-date h2))))
4319 (defun gnus-thread-sort-by-date (h1 h2)
4320 "Sort threads by root article date."
4321 (gnus-article-sort-by-date
4322 (gnus-thread-header h1) (gnus-thread-header h2)))
4324 (defsubst gnus-article-sort-by-score (h1 h2)
4325 "Sort articles by root article score.
4326 Unscored articles will be counted as having a score of zero."
4327 (> (or (cdr (assq (mail-header-number h1)
4328 gnus-newsgroup-scored))
4329 gnus-summary-default-score 0)
4330 (or (cdr (assq (mail-header-number h2)
4331 gnus-newsgroup-scored))
4332 gnus-summary-default-score 0)))
4334 (defun gnus-thread-sort-by-score (h1 h2)
4335 "Sort threads by root article score."
4336 (gnus-article-sort-by-score
4337 (gnus-thread-header h1) (gnus-thread-header h2)))
4339 (defun gnus-thread-sort-by-total-score (h1 h2)
4340 "Sort threads by the sum of all scores in the thread.
4341 Unscored articles will be counted as having a score of zero."
4342 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4344 (defun gnus-thread-total-score (thread)
4345 ;; This function find the total score of THREAD.
4350 (if (stringp (car thread))
4351 (apply gnus-thread-score-function 0
4352 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4353 (gnus-thread-total-score-1 thread)))
4355 (gnus-thread-total-score-1 (list thread)))))
4357 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4358 "Sort threads such that the thread with the most recently arrived article comes first."
4359 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4361 (defun gnus-thread-highest-number (thread)
4362 "Return the highest article number in THREAD."
4363 (apply 'max (mapcar (lambda (header)
4364 (mail-header-number header))
4365 (message-flatten-list thread))))
4367 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4368 "Sort threads such that the thread with the most recently dated article comes first."
4369 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4371 (defun gnus-thread-latest-date (thread)
4372 "Return the highest article date in THREAD."
4373 (let ((previous-time 0))
4378 (mail-header-parse-date
4380 (mail-header-date header)
4381 (error previous-time))))))
4383 (message-flatten-list thread)
4385 (< (mail-header-number h1)
4386 (mail-header-number h2))))))))
4388 (defun gnus-thread-total-score-1 (root)
4389 ;; This function find the total score of the thread below ROOT.
4390 (setq root (car root))
4391 (apply gnus-thread-score-function
4393 (mapcar 'gnus-thread-total-score
4394 (cdr (gnus-id-to-thread (mail-header-id root))))
4395 (when (> (mail-header-number root) 0)
4396 (list (or (cdr (assq (mail-header-number root)
4397 gnus-newsgroup-scored))
4398 gnus-summary-default-score 0))))
4399 (list gnus-summary-default-score)
4402 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4403 (defvar gnus-tmp-prev-subject nil)
4404 (defvar gnus-tmp-false-parent nil)
4405 (defvar gnus-tmp-root-expunged nil)
4406 (defvar gnus-tmp-dummy-line nil)
4408 (eval-when-compile (defvar gnus-tmp-header))
4409 (defun gnus-extra-header (type &optional header)
4410 "Return the extra header of TYPE."
4411 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4414 (defvar gnus-tmp-thread-tree-header-string "")
4416 (defcustom gnus-sum-thread-tree-root "> "
4417 "With %B spec, used for the root of a thread.
4418 If nil, use subject instead."
4420 :group 'gnus-thread)
4421 (defcustom gnus-sum-thread-tree-single-indent ""
4422 "With %B spec, used for a thread with just one message.
4423 If nil, use subject instead."
4425 :group 'gnus-thread)
4426 (defcustom gnus-sum-thread-tree-vertical "| "
4427 "With %B spec, used for drawing a vertical line."
4429 :group 'gnus-thread)
4430 (defcustom gnus-sum-thread-tree-indent " "
4431 "With %B spec, used for indenting."
4433 :group 'gnus-thread)
4434 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4435 "With %B spec, used for a leaf with brothers."
4437 :group 'gnus-thread)
4438 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4439 "With %B spec, used for a leaf without brothers."
4441 :group 'gnus-thread)
4443 (defun gnus-summary-prepare-threads (threads)
4444 "Prepare summary buffer from THREADS and indentation LEVEL.
4445 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4446 or a straight list of headers."
4447 (gnus-message 7 "Generating summary...")
4449 (setq gnus-newsgroup-threads threads)
4452 (let ((gnus-tmp-level 0)
4453 (default-score (or gnus-summary-default-score 0))
4454 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4455 thread number subject stack state gnus-tmp-gathered beg-match
4456 new-roots gnus-tmp-new-adopts thread-end simp-subject
4457 gnus-tmp-header gnus-tmp-unread
4458 gnus-tmp-replied gnus-tmp-subject-or-nil
4459 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4460 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4461 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4464 (setq gnus-tmp-prev-subject nil)
4466 (if (vectorp (car threads))
4467 ;; If this is a straight (sic) list of headers, then a
4468 ;; threaded summary display isn't required, so we just create
4469 ;; an unthreaded one.
4470 (gnus-summary-prepare-unthreaded threads)
4472 ;; Do the threaded display.
4474 (while (or threads stack gnus-tmp-new-adopts new-roots)
4476 (if (and (= gnus-tmp-level 0)
4479 (not gnus-tmp-false-parent)
4480 (or gnus-tmp-new-adopts new-roots))
4481 (if gnus-tmp-new-adopts
4482 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4483 thread (list (car gnus-tmp-new-adopts))
4484 gnus-tmp-header (caar thread)
4485 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4487 (setq thread (list (car new-roots))
4488 gnus-tmp-header (caar thread)
4489 new-roots (cdr new-roots))))
4492 ;; If there are some threads, we do them before the
4493 ;; threads on the stack.
4494 (setq thread threads
4495 gnus-tmp-header (caar thread))
4496 ;; There were no current threads, so we pop something off
4498 (setq state (car stack)
4499 gnus-tmp-level (car state)
4500 tree-stack (cadr state)
4501 thread (caddr state)
4503 gnus-tmp-header (caar thread))))
4505 (setq gnus-tmp-false-parent nil)
4506 (setq gnus-tmp-root-expunged nil)
4507 (setq thread-end nil)
4509 (if (stringp gnus-tmp-header)
4510 ;; The header is a dummy root.
4512 ((eq gnus-summary-make-false-root 'adopt)
4513 ;; We let the first article adopt the rest.
4514 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4516 (setq gnus-tmp-gathered
4518 (lambda (h) (mail-header-number (car h)))
4521 (setq thread (cons (list (caar thread)
4524 (setq gnus-tmp-level -1
4525 gnus-tmp-false-parent t))
4526 ((eq gnus-summary-make-false-root 'empty)
4527 ;; We print adopted articles with empty subject fields.
4528 (setq gnus-tmp-gathered
4530 (lambda (h) (mail-header-number (car h)))
4533 (setq gnus-tmp-level -1))
4534 ((eq gnus-summary-make-false-root 'dummy)
4535 ;; We remember that we probably want to output a dummy
4537 (setq gnus-tmp-dummy-line gnus-tmp-header)
4538 (setq gnus-tmp-prev-subject gnus-tmp-header))
4540 ;; We do not make a root for the gathered
4541 ;; sub-threads at all.
4542 (setq gnus-tmp-level -1)))
4544 (setq number (mail-header-number gnus-tmp-header)
4545 subject (mail-header-subject gnus-tmp-header)
4546 simp-subject (gnus-simplify-subject-fully subject))
4549 ;; If the thread has changed subject, we might want to make
4550 ;; this subthread into a root.
4551 ((and (null gnus-thread-ignore-subject)
4552 (not (zerop gnus-tmp-level))
4553 gnus-tmp-prev-subject
4554 (not (string= gnus-tmp-prev-subject simp-subject)))
4555 (setq new-roots (nconc new-roots (list (car thread)))
4557 gnus-tmp-header nil))
4558 ;; If the article lies outside the current limit,
4559 ;; then we do not display it.
4560 ((not (memq number gnus-newsgroup-limit))
4561 (setq gnus-tmp-gathered
4563 (lambda (h) (mail-header-number (car h)))
4566 (setq gnus-tmp-new-adopts (if (cdar thread)
4567 (append gnus-tmp-new-adopts
4569 gnus-tmp-new-adopts)
4571 gnus-tmp-header nil)
4572 (when (zerop gnus-tmp-level)
4573 (setq gnus-tmp-root-expunged t)))
4574 ;; Perhaps this article is to be marked as read?
4575 ((and gnus-summary-mark-below
4576 (< (or (cdr (assq number gnus-newsgroup-scored))
4578 gnus-summary-mark-below)
4579 ;; Don't touch sparse articles.
4580 (not (gnus-summary-article-sparse-p number))
4581 (not (gnus-summary-article-ancient-p number)))
4582 (setq gnus-newsgroup-unreads
4583 (delq number gnus-newsgroup-unreads))
4584 (if gnus-newsgroup-auto-expire
4585 (setq gnus-newsgroup-expirable
4586 (gnus-add-to-sorted-list
4587 gnus-newsgroup-expirable number))
4588 (push (cons number gnus-low-score-mark)
4589 gnus-newsgroup-reads))))
4591 (when gnus-tmp-header
4592 ;; We may have an old dummy line to output before this
4594 (when (and gnus-tmp-dummy-line
4597 (mail-header-subject gnus-tmp-header)))
4598 (gnus-summary-insert-dummy-line
4599 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4600 (setq gnus-tmp-dummy-line nil))
4602 ;; Compute the mark.
4603 (setq gnus-tmp-unread (gnus-article-mark number))
4605 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4606 gnus-tmp-header gnus-tmp-level)
4607 gnus-newsgroup-data)
4609 ;; Actually insert the line.
4611 gnus-tmp-subject-or-nil
4613 ((and gnus-thread-ignore-subject
4614 gnus-tmp-prev-subject
4615 (not (string= gnus-tmp-prev-subject simp-subject)))
4617 ((zerop gnus-tmp-level)
4618 (if (and (eq gnus-summary-make-false-root 'empty)
4619 (memq number gnus-tmp-gathered)
4620 gnus-tmp-prev-subject
4621 (string= gnus-tmp-prev-subject simp-subject))
4622 gnus-summary-same-subject
4624 (t gnus-summary-same-subject)))
4625 (if (and (eq gnus-summary-make-false-root 'adopt)
4626 (= gnus-tmp-level 1)
4627 (memq number gnus-tmp-gathered))
4628 (setq gnus-tmp-opening-bracket ?\<
4629 gnus-tmp-closing-bracket ?\>)
4630 (setq gnus-tmp-opening-bracket ?\[
4631 gnus-tmp-closing-bracket ?\]))
4633 gnus-tmp-indentation
4634 (aref gnus-thread-indent-array gnus-tmp-level)
4635 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4636 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4637 gnus-summary-default-score 0)
4639 (if (or (null gnus-summary-default-score)
4640 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4641 gnus-summary-zcore-fuzz))
4643 (if (< gnus-tmp-score gnus-summary-default-score)
4644 gnus-score-below-mark gnus-score-over-mark))
4646 (cond ((memq number gnus-newsgroup-processable)
4648 ((memq number gnus-newsgroup-cached)
4650 ((memq number gnus-newsgroup-replied)
4652 ((memq number gnus-newsgroup-forwarded)
4653 gnus-forwarded-mark)
4654 ((memq number gnus-newsgroup-saved)
4656 ((memq number gnus-newsgroup-recent)
4658 ((memq number gnus-newsgroup-unseen)
4661 gnus-tmp-from (mail-header-from gnus-tmp-header)
4664 ((string-match "<[^>]+> *$" gnus-tmp-from)
4665 (setq beg-match (match-beginning 0))
4666 (or (and (string-match "^\".+\"" gnus-tmp-from)
4667 (substring gnus-tmp-from 1 (1- (match-end 0))))
4668 (substring gnus-tmp-from 0 beg-match)))
4669 ((string-match "(.+)" gnus-tmp-from)
4670 (substring gnus-tmp-from
4671 (1+ (match-beginning 0)) (1- (match-end 0))))
4673 gnus-tmp-thread-tree-header-string
4675 ((not gnus-show-threads) "")
4676 ((zerop gnus-tmp-level)
4678 (or gnus-sum-thread-tree-root subject)
4679 (or gnus-sum-thread-tree-single-indent subject)))
4681 (concat (apply 'concat
4682 (mapcar (lambda (item)
4684 gnus-sum-thread-tree-vertical
4685 gnus-sum-thread-tree-indent))
4686 (cdr (reverse tree-stack))))
4688 gnus-sum-thread-tree-leaf-with-other
4689 gnus-sum-thread-tree-single-leaf)))))
4690 (when (string= gnus-tmp-name "")
4691 (setq gnus-tmp-name gnus-tmp-from))
4692 (unless (numberp gnus-tmp-lines)
4693 (setq gnus-tmp-lines -1))
4694 (if (= gnus-tmp-lines -1)
4695 (setq gnus-tmp-lines "?")
4696 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4697 (gnus-put-text-property
4699 (progn (eval gnus-summary-line-format-spec) (point))
4700 'gnus-number number)
4703 (gnus-run-hooks 'gnus-summary-update-hook)
4706 (setq gnus-tmp-prev-subject simp-subject)))
4708 (when (nth 1 thread)
4709 (push (list (max 0 gnus-tmp-level)
4710 (copy-list tree-stack)
4713 (push (if (nth 1 thread) 1 0) tree-stack)
4714 (incf gnus-tmp-level)
4715 (setq threads (if thread-end nil (cdar thread)))
4717 (setq gnus-tmp-level 0)))))
4718 (gnus-message 7 "Generating summary...done"))
4720 (defun gnus-summary-prepare-unthreaded (headers)
4721 "Generate an unthreaded summary buffer based on HEADERS."
4722 (let (header number mark)
4727 ;; We may have to root out some bad articles...
4728 (when (memq (setq number (mail-header-number
4729 (setq header (pop headers))))
4730 gnus-newsgroup-limit)
4731 ;; Mark article as read when it has a low score.
4732 (when (and gnus-summary-mark-below
4733 (< (or (cdr (assq number gnus-newsgroup-scored))
4734 gnus-summary-default-score 0)
4735 gnus-summary-mark-below)
4736 (not (gnus-summary-article-ancient-p number)))
4737 (setq gnus-newsgroup-unreads
4738 (delq number gnus-newsgroup-unreads))
4739 (if gnus-newsgroup-auto-expire
4740 (push number gnus-newsgroup-expirable)
4741 (push (cons number gnus-low-score-mark)
4742 gnus-newsgroup-reads)))
4744 (setq mark (gnus-article-mark number))
4745 (push (gnus-data-make number mark (1+ (point)) header 0)
4746 gnus-newsgroup-data)
4747 (gnus-summary-insert-line
4749 mark (memq number gnus-newsgroup-replied)
4750 (memq number gnus-newsgroup-expirable)
4751 (mail-header-subject header) nil
4752 (cdr (assq number gnus-newsgroup-scored))
4753 (memq number gnus-newsgroup-processable))))))
4755 (defun gnus-summary-remove-list-identifiers ()
4756 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4757 (let ((regexp (if (consp gnus-list-identifiers)
4758 (mapconcat 'identity gnus-list-identifiers " *\\|")
4759 gnus-list-identifiers))
4762 (dolist (header gnus-newsgroup-headers)
4763 (setq subject (mail-header-subject header)
4765 (while (string-match
4766 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4769 (concat (substring subject 0 (match-beginning 2))
4770 (substring subject (match-end 0)))
4774 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4776 (concat (substring subject 0 (match-beginning 1))
4777 (substring subject (match-end 1)))))
4779 (mail-header-set-subject header subject))))))
4781 (defun gnus-fetch-headers (articles)
4782 "Fetch headers of ARTICLES."
4783 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4784 (gnus-message 5 "Fetching headers for %s..." name)
4787 (setq gnus-headers-retrieved-by
4788 (gnus-retrieve-headers
4789 articles gnus-newsgroup-name
4790 ;; We might want to fetch old headers, but
4791 ;; not if there is only 1 article.
4793 (not (eq gnus-fetch-old-headers 'some))
4794 (not (numberp gnus-fetch-old-headers)))
4795 (> (length articles) 1))
4796 gnus-fetch-old-headers))))
4797 (gnus-get-newsgroup-headers-xover
4798 articles nil nil gnus-newsgroup-name t)
4799 (gnus-get-newsgroup-headers))
4800 (gnus-message 5 "Fetching headers for %s...done" name))))
4802 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4803 "Select newsgroup GROUP.
4804 If READ-ALL is non-nil, all articles in the group are selected.
4805 If SELECT-ARTICLES, only select those articles from GROUP."
4806 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4807 ;;!!! Dirty hack; should be removed.
4808 (gnus-summary-ignore-duplicates
4809 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4811 gnus-summary-ignore-duplicates))
4812 (info (nth 2 entry))
4813 articles fetched-articles cached)
4815 (unless (gnus-check-server
4816 (set (make-local-variable 'gnus-current-select-method)
4817 (gnus-find-method-for-group group)))
4818 (error "Couldn't open server"))
4820 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4821 (gnus-activate-group group) ; Or we can activate it...
4822 (progn ; Or we bug out.
4823 (when (equal major-mode 'gnus-summary-mode)
4824 (kill-buffer (current-buffer)))
4825 (error "Couldn't activate group %s: %s"
4826 group (gnus-status-message group))))
4828 (unless (gnus-request-group group t)
4829 (when (equal major-mode 'gnus-summary-mode)
4830 (kill-buffer (current-buffer)))
4831 (error "Couldn't request group %s: %s"
4832 group (gnus-status-message group)))
4834 (setq gnus-newsgroup-name group
4835 gnus-newsgroup-unselected nil
4836 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4838 (let ((display (gnus-group-find-parameter group 'display)))
4839 (setq gnus-newsgroup-display
4841 ((not (zerop (or (car-safe read-all) 0)))
4842 ;; The user entered the group with C-u SPC/RET, let's show
4848 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4850 ;; The following is probably the "correct" solution, but
4851 ;; it makes Gnus fetch all headers and then limit the
4852 ;; articles (which is slow), so instead we hack the
4853 ;; select-articles parameter instead. -- Simon Josefsson
4856 ;; (gnus-byte-compile
4857 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4859 (setq select-articles
4860 (gnus-uncompress-range
4861 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4865 (cdr (gnus-active group)))))
4870 (gnus-summary-setup-default-charset)
4872 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4873 (when (gnus-virtual-group-p group)
4874 (setq cached gnus-newsgroup-cached))
4876 (setq gnus-newsgroup-unreads
4877 (gnus-sorted-ndifference
4878 (gnus-sorted-ndifference gnus-newsgroup-unreads
4879 gnus-newsgroup-marked)
4880 gnus-newsgroup-dormant))
4882 (setq gnus-newsgroup-processable nil)
4884 (gnus-update-read-articles group gnus-newsgroup-unreads)
4886 ;; Adjust and set lists of article marks.
4888 (gnus-adjust-marked-articles info))
4890 (if (setq articles select-articles)
4891 (setq gnus-newsgroup-unselected
4892 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4893 (setq articles (gnus-articles-to-read group read-all)))
4897 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4899 ((eq articles 0) nil)
4901 ;; Init the dependencies hash table.
4902 (setq gnus-newsgroup-dependencies
4903 (gnus-make-hashtable (length articles)))
4904 (gnus-set-global-variables)
4905 ;; Retrieve the headers and read them in.
4906 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4908 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4910 (setq gnus-newsgroup-cached cached))
4912 ;; Suppress duplicates?
4913 (when gnus-suppress-duplicates
4914 (gnus-dup-suppress-articles))
4916 ;; Set the initial limit.
4917 (setq gnus-newsgroup-limit (copy-sequence articles))
4918 ;; Remove canceled articles from the list of unread articles.
4919 (setq fetched-articles
4920 (mapcar (lambda (headers) (mail-header-number headers))
4921 gnus-newsgroup-headers))
4922 (setq gnus-newsgroup-articles fetched-articles)
4923 (setq gnus-newsgroup-unreads
4924 (gnus-sorted-nintersection
4925 gnus-newsgroup-unreads fetched-articles))
4926 (gnus-compute-unseen-list)
4928 ;; Removed marked articles that do not exist.
4929 (gnus-update-missing-marks
4930 (gnus-sorted-difference articles fetched-articles))
4931 ;; We might want to build some more threads first.
4932 (when (and gnus-fetch-old-headers
4933 (eq gnus-headers-retrieved-by 'nov))
4934 (if (eq gnus-fetch-old-headers 'invisible)
4935 (gnus-build-all-threads)
4936 (gnus-build-old-threads)))
4937 ;; Let the Gnus agent mark articles as read.
4939 (gnus-agent-get-undownloaded-list))
4940 ;; Remove list identifiers from subject
4941 (when gnus-list-identifiers
4942 (gnus-summary-remove-list-identifiers))
4943 ;; Check whether auto-expire is to be done in this group.
4944 (setq gnus-newsgroup-auto-expire
4945 (gnus-group-auto-expirable-p group))
4946 ;; Set up the article buffer now, if necessary.
4947 (unless gnus-single-article-buffer
4948 (gnus-article-setup-buffer))
4949 ;; First and last article in this newsgroup.
4950 (when gnus-newsgroup-headers
4951 (setq gnus-newsgroup-begin
4952 (mail-header-number (car gnus-newsgroup-headers))
4955 (gnus-last-element gnus-newsgroup-headers))))
4956 ;; GROUP is successfully selected.
4957 (or gnus-newsgroup-headers t)))))
4959 (defun gnus-compute-unseen-list ()
4960 ;; The `seen' marks are treated specially.
4961 (if (not gnus-newsgroup-seen)
4962 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4963 (setq gnus-newsgroup-unseen
4964 (gnus-inverse-list-range-intersection
4965 gnus-newsgroup-articles gnus-newsgroup-seen))))
4967 (defun gnus-summary-display-make-predicate (display)
4968 (require 'gnus-agent)
4969 (when (= (length display) 1)
4970 (setq display (car display)))
4971 (unless gnus-summary-display-cache
4972 (dolist (elem (append '((unread . unread)
4975 gnus-article-mark-lists))
4976 (push (cons (cdr elem)
4978 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4979 gnus-summary-display-cache)))
4980 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
4981 (gnus-category-predicate-cache gnus-summary-display-cache))
4982 (gnus-get-predicate display)))
4984 ;; Uses the dynamically bound `number' variable.
4986 (defun gnus-article-marked-p (type &optional article)
4987 (let ((article (or article number)))
4990 (memq article gnus-newsgroup-marked))
4992 (memq article gnus-newsgroup-spam-marked))
4994 (memq article gnus-newsgroup-unsendable))
4995 ((eq type 'undownload)
4996 (memq article gnus-newsgroup-undownloaded))
4997 ((eq type 'download)
4998 (memq article gnus-newsgroup-downloadable))
5000 (memq article gnus-newsgroup-unreads))
5002 (memq article gnus-newsgroup-reads))
5004 (memq article gnus-newsgroup-dormant) )
5006 (memq article gnus-newsgroup-expirable))
5008 (memq article gnus-newsgroup-replied))
5010 (memq article gnus-newsgroup-killed))
5011 ((eq type 'bookmark)
5012 (assq article gnus-newsgroup-bookmarks))
5014 (assq article gnus-newsgroup-scored))
5016 (memq article gnus-newsgroup-saved))
5018 (memq article gnus-newsgroup-cached))
5020 (memq article gnus-newsgroup-forwarded))
5022 (not (memq article gnus-newsgroup-unseen)))
5024 (memq article gnus-newsgroup-recent))
5027 (defun gnus-articles-to-read (group &optional read-all)
5028 "Find out what articles the user wants to read."
5030 ;; Select all articles if `read-all' is non-nil, or if there
5031 ;; are no unread articles.
5033 (and (zerop (length gnus-newsgroup-marked))
5034 (zerop (length gnus-newsgroup-unreads)))
5035 ;; Fetch all if the predicate is non-nil.
5036 gnus-newsgroup-display)
5037 ;; We want to select the headers for all the articles in
5038 ;; the group, so we select either all the active
5039 ;; articles in the group, or (if that's nil), the
5040 ;; articles in the cache.
5042 (gnus-uncompress-range (gnus-active group))
5043 (gnus-cache-articles-in-group group))
5044 ;; Select only the "normal" subset of articles.
5046 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5047 gnus-newsgroup-unreads)))
5048 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5049 (scored (length scored-list))
5050 (number (length articles))
5051 (marked (+ (length gnus-newsgroup-marked)
5052 (length gnus-newsgroup-dormant)))
5057 ((numberp gnus-newsgroup-display)
5058 gnus-newsgroup-display)
5062 ((and (or (<= scored marked) (= scored number))
5063 (numberp gnus-large-newsgroup)
5064 (> number gnus-large-newsgroup))
5065 (let* ((cursor-in-echo-area nil)
5066 (initial (gnus-parameter-large-newsgroup-initial
5067 gnus-newsgroup-name))
5071 "How many articles from %s (%s %d): "
5073 (gnus-group-decoded-name gnus-newsgroup-name)
5075 (if initial "max" "default")
5078 (cons (number-to-string initial)
5080 (if (string-match "^[ \t]*$" input) number input)))
5081 ((and (> scored marked) (< scored number)
5082 (> (- scored number) 20))
5085 (format "%s %s (%d scored, %d total): "
5086 "How many articles from"
5087 (gnus-group-decoded-name group)
5089 (if (string-match "^[ \t]*$" input)
5093 (message "Quit getting the articles to read")
5095 (setq select (if (stringp select) (string-to-number select) select))
5096 (if (or (null select) (zerop select))
5098 (if (and (not (zerop scored)) (<= (abs select) scored))
5100 (setq articles (sort scored-list '<))
5101 (setq number (length articles)))
5102 (setq articles (copy-sequence articles)))
5104 (when (< (abs select) number)
5106 ;; Select the N oldest articles.
5107 (setcdr (nthcdr (1- (abs select)) articles) nil)
5108 ;; Select the N most recent articles.
5109 (setq articles (nthcdr (- number select) articles))))
5110 (setq gnus-newsgroup-unselected
5111 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5112 (when gnus-alter-articles-to-read-function
5113 (setq gnus-newsgroup-unreads
5115 (funcall gnus-alter-articles-to-read-function
5116 gnus-newsgroup-name gnus-newsgroup-unreads)
5120 (defun gnus-killed-articles (killed articles)
5123 (when (inline (gnus-member-of-range (car articles) killed))
5124 (push (car articles) out))
5125 (setq articles (cdr articles)))
5128 (defun gnus-uncompress-marks (marks)
5129 "Uncompress the mark ranges in MARKS."
5130 (let ((uncompressed '(score bookmark))
5133 (if (memq (caar marks) uncompressed)
5134 (push (car marks) out)
5135 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5136 (setq marks (cdr marks)))
5139 (defun gnus-article-mark-to-type (mark)
5140 "Return the type of MARK."
5141 (or (cadr (assq mark gnus-article-special-mark-lists))
5144 (defun gnus-article-unpropagatable-p (mark)
5145 "Return whether MARK should be propagated to backend."
5146 (memq mark gnus-article-unpropagated-mark-lists))
5148 (defun gnus-adjust-marked-articles (info)
5149 "Set all article lists and remove all marks that are no longer valid."
5150 (let* ((marked-lists (gnus-info-marks info))
5151 (active (gnus-active (gnus-info-group info)))
5154 (types gnus-article-mark-lists)
5155 marks var articles article mark mark-type)
5157 (dolist (marks marked-lists)
5158 (setq mark (car marks)
5159 mark-type (gnus-article-mark-to-type mark)
5160 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5162 ;; We set the variable according to the type of the marks list,
5163 ;; and then adjust the marks to a subset of the active articles.
5165 ;; Adjust "simple" lists.
5166 ((eq mark-type 'list)
5167 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5168 (when (memq mark '(tick dormant expire reply save))
5170 (when (or (< (setq article (pop articles)) min) (> article max))
5171 (set var (delq article (symbol-value var)))))))
5173 ((eq mark-type 'tuple)
5174 (set var (setq articles (cdr marks)))
5175 (when (not (listp (cdr (symbol-value var))))
5176 (set var (list (symbol-value var))))
5177 (when (not (listp (cdr articles)))
5178 (setq articles (list articles)))
5180 (when (or (not (consp (setq article (pop articles))))
5181 (< (car article) min)
5182 (> (car article) max))
5183 (set var (delq article (symbol-value var))))))
5184 ;; Adjust ranges (sloppily).
5185 ((eq mark-type 'range)
5188 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5189 ;; It should be (seen (NUM1 . NUM2)).
5190 (when (numberp (cddr marks))
5191 (setcdr marks (list (cdr marks))))
5192 (setq articles (cdr marks))
5193 (while (and articles
5194 (or (and (consp (car articles))
5195 (> min (cdar articles)))
5196 (and (numberp (car articles))
5197 (> min (car articles)))))
5199 (set var articles))))))))
5201 (defun gnus-update-missing-marks (missing)
5202 "Go through the list of MISSING articles and remove them from the mark lists."
5205 ;; Go through all types.
5206 (dolist (elem gnus-article-mark-lists)
5207 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5208 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5209 (when (symbol-value var)
5210 ;; This list has articles. So we delete all missing
5211 ;; articles from it.
5214 (set var (delq (pop m) (symbol-value var))))))))))
5216 (defun gnus-update-marks ()
5217 "Enter the various lists of marked articles into the newsgroup info list."
5218 (let ((types gnus-article-mark-lists)
5219 (info (gnus-get-info gnus-newsgroup-name))
5220 type list newmarked symbol delta-marks)
5222 ;; Add all marks lists to the list of marks lists.
5223 (while (setq type (pop types))
5224 (setq list (symbol-value
5226 (intern (format "gnus-newsgroup-%s" (car type))))))
5229 ;; Get rid of the entries of the articles that have the
5231 (when (and (eq (cdr type) 'score)
5235 (prev (cons nil list))
5238 (if (or (not (consp (car arts)))
5239 (= (cdar arts) gnus-summary-default-score))
5240 (setcdr prev (cdr arts))
5242 (setq arts (cdr arts)))
5243 (setq list (cdr all)))))
5245 (when (eq (cdr type) 'seen)
5246 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5248 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5249 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5251 (when (and (gnus-check-backend-function
5252 'request-set-mark gnus-newsgroup-name)
5253 (not (gnus-article-unpropagatable-p (cdr type))))
5254 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5255 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5256 (add (gnus-remove-from-range
5257 (gnus-copy-sequence list) old)))
5259 (push (list add 'add (list (cdr type))) delta-marks))
5261 (push (list del 'del (list (cdr type))) delta-marks))))
5264 (push (cons (cdr type) list) newmarked)))
5267 (unless (gnus-check-group gnus-newsgroup-name)
5268 (error "Can't open server for %s" gnus-newsgroup-name))
5269 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5271 ;; Enter these new marks into the info of the group.
5273 (setcar (nthcdr 3 info) newmarked)
5274 ;; Add the marks lists to the end of the info.
5276 (setcdr (nthcdr 2 info) (list newmarked))))
5278 ;; Cut off the end of the info if there's nothing else there.
5282 (when (nthcdr (decf i) info)
5283 (setcdr (nthcdr i info) nil)))))))
5285 (defun gnus-set-mode-line (where)
5286 "Set the mode line of the article or summary buffers.
5287 If WHERE is `summary', the summary mode line format will be used."
5288 ;; Is this mode line one we keep updated?
5289 (when (and (memq where gnus-updated-mode-lines)
5291 (intern (format "gnus-%s-mode-line-format-spec" where))))
5294 ;; We evaluate this in the summary buffer since these
5295 ;; variables are buffer-local to that buffer.
5296 (set-buffer gnus-summary-buffer)
5297 ;; We bind all these variables that are used in the `eval' form
5299 (let* ((mformat (symbol-value
5301 (format "gnus-%s-mode-line-format-spec" where))))
5302 (gnus-tmp-group-name (gnus-group-decoded-name
5303 gnus-newsgroup-name))
5304 (gnus-tmp-article-number (or gnus-current-article 0))
5305 (gnus-tmp-unread gnus-newsgroup-unreads)
5306 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5307 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5308 (gnus-tmp-unread-and-unselected
5309 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5310 (zerop gnus-tmp-unselected))
5312 ((zerop gnus-tmp-unselected)
5313 (format "{%d more}" gnus-tmp-unread-and-unticked))
5314 (t (format "{%d(+%d) more}"
5315 gnus-tmp-unread-and-unticked
5316 gnus-tmp-unselected))))
5318 (if (and gnus-current-headers
5319 (vectorp gnus-current-headers))
5320 (gnus-mode-string-quote
5321 (mail-header-subject gnus-current-headers))
5323 bufname-length max-len
5324 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5325 (setq mode-string (eval mformat))
5326 (setq bufname-length (if (string-match "%b" mode-string)
5329 (if (eq where 'summary)
5331 (get-buffer gnus-article-buffer))))
5334 (setq max-len (max 4 (if gnus-mode-non-string-length
5336 gnus-mode-non-string-length
5338 (length mode-string))))
5339 ;; We might have to chop a bit of the string off...
5340 (when (> (length mode-string) max-len)
5342 (concat (truncate-string-to-width mode-string (- max-len 3))
5344 ;; Pad the mode string a bit.
5345 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5346 ;; Update the mode line.
5347 (setq mode-line-buffer-identification
5348 (gnus-mode-line-buffer-identification (list mode-string)))
5349 (set-buffer-modified-p t))))
5351 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5352 "Go through the HEADERS list and add all Xrefs to a hash table.
5353 The resulting hash table is returned, or nil if no Xrefs were found."
5354 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5355 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5356 (xref-hashtb (gnus-make-hashtable))
5357 start group entry number xrefs header)
5359 (setq header (pop headers))
5360 (when (and (setq xrefs (mail-header-xref header))
5361 (not (memq (setq number (mail-header-number header))
5364 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5365 (setq start (match-end 0))
5366 (setq group (if prefix
5367 (concat prefix (substring xrefs (match-beginning 1)
5369 (substring xrefs (match-beginning 1) (match-end 1))))
5371 (string-to-int (substring xrefs (match-beginning 2)
5373 (if (setq entry (gnus-gethash group xref-hashtb))
5374 (setcdr entry (cons number (cdr entry)))
5375 (gnus-sethash group (cons number nil) xref-hashtb)))))
5376 (and start xref-hashtb)))
5378 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5379 "Look through all the headers and mark the Xrefs as read."
5380 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5381 name entry info xref-hashtb idlist method nth4)
5383 (set-buffer gnus-group-buffer)
5384 (when (setq xref-hashtb
5385 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5388 (unless (string= from-newsgroup (setq name (symbol-name group)))
5389 (setq idlist (symbol-value group))
5390 ;; Dead groups are not updated.
5392 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5394 (when (stringp (setq nth4 (gnus-info-method info)))
5395 (setq nth4 (gnus-server-to-method nth4))))
5396 ;; Only do the xrefs if the group has the same
5397 ;; select method as the group we have just read.
5398 (or (gnus-methods-equal-p
5399 nth4 (gnus-find-method-for-group from-newsgroup))
5401 (equal nth4 (setq method (gnus-find-method-for-group
5403 (and (equal (car nth4) (car method))
5404 (equal (nth 1 nth4) (nth 1 method))))
5405 gnus-use-cross-reference
5406 (or (not (eq gnus-use-cross-reference t))
5408 ;; Only do cross-references on subscribed
5409 ;; groups, if that is what is wanted.
5410 (<= (gnus-info-level info) gnus-level-subscribed))
5411 (gnus-group-make-articles-read name idlist))))
5414 (defun gnus-compute-read-articles (group articles)
5415 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5416 (info (nth 2 entry))
5417 (active (gnus-active group))
5420 ;; First peel off all invalid article numbers.
5422 (let ((ids articles)
5424 (while (setq id (pop ids))
5425 (when (and first (> id (cdr active)))
5426 ;; We'll end up in this situation in one particular
5427 ;; obscure situation. If you re-scan a group and get
5428 ;; a new article that is cross-posted to a different
5429 ;; group that has not been re-scanned, you might get
5430 ;; crossposted article that has a higher number than
5431 ;; Gnus believes possible. So we re-activate this
5432 ;; group as well. This might mean doing the
5433 ;; crossposting thingy will *increase* the number
5434 ;; of articles in some groups. Tsk, tsk.
5435 (setq active (or (gnus-activate-group group) active)))
5436 (when (or (> id (cdr active))
5437 (< id (car active)))
5438 (setq articles (delq id articles))))))
5439 ;; If the read list is nil, we init it.
5441 (null (gnus-info-read info))
5443 (setq ninfo (cons 1 (1- (car active))))
5444 (setq ninfo (gnus-info-read info)))
5445 ;; Then we add the read articles to the range.
5447 ninfo (setq articles (sort articles '<))))))
5449 (defun gnus-group-make-articles-read (group articles)
5450 "Update the info of GROUP to say that ARTICLES are read."
5452 (entry (gnus-gethash group gnus-newsrc-hashtb))
5453 (info (nth 2 entry))
5454 (active (gnus-active group))
5457 (setq range (gnus-compute-read-articles group articles))
5459 (set-buffer gnus-group-buffer)
5462 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5463 (gnus-info-set-read ',info ',(gnus-info-read info))
5464 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5465 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5466 (gnus-group-update-group ,group t))))
5467 ;; Add the read articles to the range.
5468 (gnus-info-set-read info range)
5469 (gnus-request-set-mark group (list (list range 'add '(read))))
5470 ;; Then we have to re-compute how many unread
5471 ;; articles there are in this group.
5475 (setq num (- (1+ (cdr active)) (car active))))
5476 ((not (listp (cdr range)))
5477 (setq num (- (cdr active) (- (1+ (cdr range))
5481 (if (numberp (car range))
5483 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5484 (setq range (cdr range)))
5485 (setq num (- (cdr active) num))))
5486 ;; Update the number of unread articles.
5488 ;; Update the group buffer.
5489 (gnus-group-update-group group t)))))
5491 (defvar gnus-newsgroup-none-id 0)
5493 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5494 (let ((cur nntp-server-buffer)
5497 (save-excursion (set-buffer gnus-summary-buffer)
5498 gnus-newsgroup-dependencies)))
5500 (mail-parse-charset gnus-newsgroup-charset)
5501 (mail-parse-ignored-charsets
5502 (save-excursion (condition-case nil
5503 (set-buffer gnus-summary-buffer)
5505 gnus-newsgroup-ignored-charsets)))
5507 (set-buffer nntp-server-buffer)
5508 ;; Translate all TAB characters into SPACE characters.
5509 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5510 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5511 (gnus-run-hooks 'gnus-parse-headers-hook)
5512 (let ((case-fold-search t)
5513 in-reply-to header p lines chars)
5514 (goto-char (point-min))
5515 ;; Search to the beginning of the next header. Error messages
5516 ;; do not begin with 2 or 3.
5517 (while (re-search-forward "^[23][0-9]+ " nil t)
5520 ;; This implementation of this function, with nine
5521 ;; search-forwards instead of the one re-search-forward and
5522 ;; a case (which basically was the old function) is actually
5523 ;; about twice as fast, even though it looks messier. You
5524 ;; can't have everything, I guess. Speed and elegance
5525 ;; doesn't always go hand in hand.
5534 (narrow-to-region (point)
5535 (or (and (search-forward "\n.\n" nil t)
5541 (if (search-forward "\nsubject:" nil t)
5542 (funcall gnus-decode-encoded-word-function
5543 (nnheader-header-value))
5548 (if (search-forward "\nfrom:" nil t)
5549 (funcall gnus-decode-encoded-word-function
5550 (nnheader-header-value))
5555 (if (search-forward "\ndate:" nil t)
5556 (nnheader-header-value) ""))
5560 (setq id (if (re-search-forward
5561 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5562 ;; We do it this way to make sure the Message-ID
5563 ;; is (somewhat) syntactically valid.
5564 (buffer-substring (match-beginning 1)
5566 ;; If there was no message-id, we just fake one
5567 ;; to make subsequent routines simpler.
5568 (nnheader-generate-fake-message-id))))
5572 (if (search-forward "\nreferences:" nil t)
5576 (nnheader-header-value)
5581 (search-backward ">" end t)
5584 (search-backward "<" end t)
5586 ;; Get the references from the in-reply-to header if there
5587 ;; were no references and the in-reply-to header looks
5589 (if (and (search-forward "\nin-reply-to:" nil t)
5590 (setq in-reply-to (nnheader-header-value))
5591 (string-match "<[^>]+>" in-reply-to))
5593 (setq ref (substring in-reply-to (match-beginning 0)
5595 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5596 (setq ref2 (substring in-reply-to (match-beginning 0)
5598 (when (> (length ref2) (length ref))
5605 (if (search-forward "\nchars: " nil t)
5606 (if (numberp (setq chars (ignore-errors (read cur))))
5612 (if (search-forward "\nlines: " nil t)
5613 (if (numberp (setq lines (ignore-errors (read cur))))
5619 (and (search-forward "\nxref:" nil t)
5620 (nnheader-header-value)))
5622 (when gnus-extra-headers
5623 (let ((extra gnus-extra-headers)
5627 (when (search-forward
5628 (concat "\n" (symbol-name (car extra)) ":") nil t)
5629 (push (cons (car extra) (nnheader-header-value))
5633 (when (equal id ref)
5636 (when gnus-alter-header-function
5637 (funcall gnus-alter-header-function header)
5638 (setq id (mail-header-id header)
5639 ref (gnus-parent-id (mail-header-references header))))
5642 (gnus-dependencies-add-header
5643 header dependencies force-new))
5644 (push header headers))
5645 (goto-char (point-max))
5647 (nreverse headers)))))
5649 ;; Goes through the xover lines and returns a list of vectors
5650 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5651 force-new dependencies
5652 group also-fetch-heads)
5653 "Parse the news overview data in the server buffer.
5654 Return a list of headers that match SEQUENCE (see
5655 `nntp-retrieve-headers')."
5656 ;; Get the Xref when the users reads the articles since most/some
5657 ;; NNTP servers do not include Xrefs when using XOVER.
5658 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5659 (let ((mail-parse-charset gnus-newsgroup-charset)
5660 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5661 (cur nntp-server-buffer)
5662 (dependencies (or dependencies gnus-newsgroup-dependencies))
5664 ((eq gnus-read-all-available-headers t)
5666 ((stringp gnus-read-all-available-headers)
5667 (string-match gnus-read-all-available-headers group))
5670 number headers header)
5672 (set-buffer nntp-server-buffer)
5673 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5674 ;; Allow the user to mangle the headers before parsing them.
5675 (gnus-run-hooks 'gnus-parse-headers-hook)
5676 (goto-char (point-min))
5677 (gnus-parse-without-error
5678 (while (and (or sequence allp)
5680 (setq number (read cur))
5682 (while (and sequence
5683 (< (car sequence) number))
5684 (setq sequence (cdr sequence))))
5687 (eq number (car sequence))))
5689 (setq sequence (cdr sequence))
5690 (setq header (inline
5691 (gnus-nov-parse-line
5692 number dependencies force-new)))))
5693 (push header headers))
5695 ;; A common bug in inn is that if you have posted an article and
5696 ;; then retrieves the active file, it will answer correctly --
5697 ;; the new article is included. However, a NOV entry for the
5698 ;; article may not have been generated yet, so this may fail.
5699 ;; We work around this problem by retrieving the last few
5700 ;; headers using HEAD.
5701 (if (or (not also-fetch-heads)
5703 ;; We (probably) got all the headers.
5705 (let ((gnus-nov-is-evil t))
5708 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5709 (gnus-get-newsgroup-headers))))))))
5711 (defun gnus-article-get-xrefs ()
5712 "Fill in the Xref value in `gnus-current-headers', if necessary.
5713 This is meant to be called in `gnus-article-internal-prepare-hook'."
5714 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5715 gnus-current-headers)))
5716 (or (not gnus-use-cross-reference)
5718 (and (mail-header-xref headers)
5719 (not (string= (mail-header-xref headers) "")))
5720 (let ((case-fold-search t)
5723 (nnheader-narrow-to-headers)
5724 (goto-char (point-min))
5725 (when (or (and (not (eobp))
5726 (eq (downcase (char-after)) ?x)
5727 (looking-at "Xref:"))
5728 (search-forward "\nXref:" nil t))
5729 (goto-char (1+ (match-end 0)))
5730 (setq xref (buffer-substring (point)
5731 (progn (end-of-line) (point))))
5732 (mail-header-set-xref headers xref)))))))
5734 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5735 "Find article ID and insert the summary line for that article.
5736 OLD-HEADER can either be a header or a line number to insert
5737 the subject line on."
5738 (let* ((line (and (numberp old-header) old-header))
5739 (old-header (and (vectorp old-header) old-header))
5740 (header (cond ((and old-header use-old-header)
5743 (gnus-number-to-header id))
5744 (gnus-number-to-header id))
5746 (gnus-read-header id))))
5747 (number (and (numberp id) id))
5750 ;; Rebuild the thread that this article is part of and go to the
5751 ;; article we have fetched.
5752 (when (and (not gnus-show-threads)
5755 (setq d (gnus-data-find (mail-header-number old-header))))
5756 (goto-char (gnus-data-pos d))
5759 (- (gnus-point-at-bol)
5761 (1+ (gnus-point-at-eol))
5762 (gnus-delete-line))))))
5764 (mail-header-set-number header (mail-header-number old-header)))
5765 (setq gnus-newsgroup-sparse
5766 (delq (setq number (mail-header-number header))
5767 gnus-newsgroup-sparse))
5768 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5769 (push number gnus-newsgroup-limit)
5770 (gnus-rebuild-thread (mail-header-id header) line)
5771 (gnus-summary-goto-subject number nil t))
5772 (when (and (numberp number)
5774 ;; We have to update the boundaries even if we can't fetch the
5775 ;; article if ID is a number -- so that the next `P' or `N'
5776 ;; command will fetch the previous (or next) article even
5777 ;; if the one we tried to fetch this time has been canceled.
5778 (when (> number gnus-newsgroup-end)
5779 (setq gnus-newsgroup-end number))
5780 (when (< number gnus-newsgroup-begin)
5781 (setq gnus-newsgroup-begin number))
5782 (setq gnus-newsgroup-unselected
5783 (delq number gnus-newsgroup-unselected)))
5784 ;; Report back a success?
5785 (and header (mail-header-number header))))
5787 ;;; Process/prefix in the summary buffer
5789 (defun gnus-summary-work-articles (n)
5790 "Return a list of articles to be worked upon.
5791 The prefix argument, the list of process marked articles, and the
5792 current article will be taken into consideration."
5794 (set-buffer gnus-summary-buffer)
5797 ;; A numerical prefix has been given.
5798 (setq n (prefix-numeric-value n))
5799 (let ((backward (< n 0))
5800 (n (abs (prefix-numeric-value n)))
5805 (push (setq article (gnus-summary-article-number))
5808 (gnus-summary-find-prev nil article)
5809 (gnus-summary-find-next nil article)))
5811 (nreverse articles)))
5812 ((and (gnus-region-active-p) (mark))
5813 (message "region active")
5814 ;; Work on the region between point and mark.
5815 (let ((max (max (point) (mark)))
5818 (goto-char (min (min (point) (mark))))
5821 (push (setq article (gnus-summary-article-number)) articles)
5822 (gnus-summary-find-next nil article)
5824 (nreverse articles))))
5825 (gnus-newsgroup-processable
5826 ;; There are process-marked articles present.
5827 ;; Save current state.
5828 (gnus-summary-save-process-mark)
5830 (reverse gnus-newsgroup-processable))
5832 ;; Just return the current article.
5833 (list (gnus-summary-article-number))))))
5835 (defmacro gnus-summary-iterate (arg &rest forms)
5836 "Iterate over the process/prefixed articles and do FORMS.
5837 ARG is the interactive prefix given to the command. FORMS will be
5838 executed with point over the summary line of the articles."
5839 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5840 `(let ((,articles (gnus-summary-work-articles ,arg)))
5842 (gnus-summary-goto-subject (car ,articles))
5846 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5847 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5849 (defun gnus-summary-save-process-mark ()
5850 "Push the current set of process marked articles on the stack."
5852 (push (copy-sequence gnus-newsgroup-processable)
5853 gnus-newsgroup-process-stack))
5855 (defun gnus-summary-kill-process-mark ()
5856 "Push the current set of process marked articles on the stack and unmark."
5858 (gnus-summary-save-process-mark)
5859 (gnus-summary-unmark-all-processable))
5861 (defun gnus-summary-yank-process-mark ()
5862 "Pop the last process mark state off the stack and restore it."
5864 (unless gnus-newsgroup-process-stack
5865 (error "Empty mark stack"))
5866 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5868 (defun gnus-summary-process-mark-set (set)
5869 "Make SET into the current process marked articles."
5870 (gnus-summary-unmark-all-processable)
5872 (gnus-summary-set-process-mark (pop set))))
5874 ;;; Searching and stuff
5876 (defun gnus-summary-search-group (&optional backward use-level)
5877 "Search for next unread newsgroup.
5878 If optional argument BACKWARD is non-nil, search backward instead."
5880 (set-buffer gnus-group-buffer)
5881 (when (gnus-group-search-forward
5882 backward nil (if use-level (gnus-group-group-level) nil))
5883 (gnus-group-group-name))))
5885 (defun gnus-summary-best-group (&optional exclude-group)
5886 "Find the name of the best unread group.
5887 If EXCLUDE-GROUP, do not go to this group."
5889 (set-buffer gnus-group-buffer)
5891 (gnus-group-best-unread-group exclude-group))))
5893 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5894 (if backward (gnus-summary-find-prev)
5895 (let* ((dummy (gnus-summary-article-intangible-p))
5896 (article (or article (gnus-summary-article-number)))
5897 (arts (gnus-data-find-list article))
5899 (when (and (not dummy)
5900 (or (not gnus-summary-check-current)
5902 (not (gnus-data-unread-p (car arts)))))
5903 (setq arts (cdr arts)))
5908 (when (or (and undownloaded
5909 (eq gnus-undownloaded-mark
5910 (gnus-data-mark (car arts))))
5911 (gnus-data-unread-p (car arts)))
5912 (setq result (car arts)
5914 (setq arts (cdr arts)))
5917 (goto-char (gnus-data-pos result))
5918 (gnus-data-number result)))))
5920 (defun gnus-summary-find-prev (&optional unread article)
5921 (let* ((eobp (eobp))
5922 (article (or article (gnus-summary-article-number)))
5923 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5925 (when (and (not eobp)
5926 (or (not gnus-summary-check-current)
5928 (not (gnus-data-unread-p (car arts)))))
5929 (setq arts (cdr arts)))
5934 (when (gnus-data-unread-p (car arts))
5935 (setq result (car arts)
5937 (setq arts (cdr arts)))
5940 (goto-char (gnus-data-pos result))
5941 (gnus-data-number result))))
5943 (defun gnus-summary-find-subject (subject &optional unread backward article)
5944 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5945 (article (or article (gnus-summary-article-number)))
5946 (articles (gnus-data-list backward))
5947 (arts (gnus-data-find-list article articles))
5949 (when (or (not gnus-summary-check-current)
5951 (not (gnus-data-unread-p (car arts))))
5952 (setq arts (cdr arts)))
5954 (and (or (not unread)
5955 (gnus-data-unread-p (car arts)))
5956 (vectorp (gnus-data-header (car arts)))
5958 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5959 (setq result (car arts)
5961 (setq arts (cdr arts)))
5963 (goto-char (gnus-data-pos result))
5964 (gnus-data-number result))))
5966 (defun gnus-summary-search-forward (&optional unread subject backward)
5967 "Search forward for an article.
5968 If UNREAD, look for unread articles. If SUBJECT, look for
5969 articles with that subject. If BACKWARD, search backward instead."
5970 (cond (subject (gnus-summary-find-subject subject unread backward))
5971 (backward (gnus-summary-find-prev unread))
5972 (t (gnus-summary-find-next unread))))
5974 (defun gnus-recenter (&optional n)
5975 "Center point in window and redisplay frame.
5976 Also do horizontal recentering."
5978 (when (and gnus-auto-center-summary
5979 (not (eq gnus-auto-center-summary 'vertical)))
5980 (gnus-horizontal-recenter))
5983 (defun gnus-summary-recenter ()
5984 "Center point in the summary window.
5985 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5986 displayed, no centering will be performed."
5987 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5988 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5990 (let* ((top (cond ((< (window-height) 4) 0)
5991 ((< (window-height) 7) 1)
5992 (t (if (numberp gnus-auto-center-summary)
5993 gnus-auto-center-summary
5995 (height (1- (window-height)))
5996 (bottom (save-excursion (goto-char (point-max))
5997 (forward-line (- height))
5999 (window (get-buffer-window (current-buffer))))
6000 ;; The user has to want it.
6001 (when gnus-auto-center-summary
6002 (when (get-buffer-window gnus-article-buffer)
6003 ;; Only do recentering when the article buffer is displayed,
6004 ;; Set the window start to either `bottom', which is the biggest
6005 ;; possible valid number, or the second line from the top,
6006 ;; whichever is the least.
6007 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6008 (if (> bottom top-pos)
6009 ;; Keep the second line from the top visible
6010 (set-window-start window top-pos t)
6011 ;; Try to keep the bottom line visible; if it's partially
6012 ;; obscured, either scroll one more line to make it fully
6013 ;; visible, or revert to using TOP-POS.
6015 (goto-char (point-max))
6017 (let ((last-line-start (point)))
6019 (set-window-start window (point) t)
6020 (when (not (pos-visible-in-window-p last-line-start window))
6022 (set-window-start window (min (point) top-pos) t)))))))
6023 ;; Do horizontal recentering while we're at it.
6024 (when (and (get-buffer-window (current-buffer) t)
6025 (not (eq gnus-auto-center-summary 'vertical)))
6026 (let ((selected (selected-window)))
6027 (select-window (get-buffer-window (current-buffer) t))
6028 (gnus-summary-position-point)
6029 (gnus-horizontal-recenter)
6030 (select-window selected))))))
6032 (defun gnus-summary-jump-to-group (newsgroup)
6033 "Move point to NEWSGROUP in group mode buffer."
6034 ;; Keep update point of group mode buffer if visible.
6035 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6036 (save-window-excursion
6037 ;; Take care of tree window mode.
6038 (when (get-buffer-window gnus-group-buffer)
6039 (pop-to-buffer gnus-group-buffer))
6040 (gnus-group-jump-to-group newsgroup))
6042 ;; Take care of tree window mode.
6043 (if (get-buffer-window gnus-group-buffer)
6044 (pop-to-buffer gnus-group-buffer)
6045 (set-buffer gnus-group-buffer))
6046 (gnus-group-jump-to-group newsgroup))))
6048 ;; This function returns a list of article numbers based on the
6049 ;; difference between the ranges of read articles in this group and
6050 ;; the range of active articles.
6051 (defun gnus-list-of-unread-articles (group)
6052 (let* ((read (gnus-info-read (gnus-get-info group)))
6053 (active (or (gnus-active group) (gnus-activate-group group)))
6056 ;; If none are read, then all are unread.
6058 (setq first (car active))
6059 ;; If the range of read articles is a single range, then the
6060 ;; first unread article is the article after the last read
6061 ;; article. Sounds logical, doesn't it?
6062 (if (and (not (listp (cdr read)))
6063 (or (< (car read) (car active))
6064 (progn (setq read (list read))
6066 (setq first (max (car active) (1+ (cdr read))))
6067 ;; `read' is a list of ranges.
6068 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6071 (setq first (car active)))
6074 (while (< first nlast)
6076 (setq first (1+ first))))
6077 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6078 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6079 (setq read (cdr read)))))
6080 ;; And add the last unread articles.
6081 (while (<= first last)
6083 (setq first (1+ first)))
6084 ;; Return the list of unread articles.
6085 (delq 0 (nreverse unread))))
6087 (defun gnus-list-of-read-articles (group)
6088 "Return a list of unread, unticked and non-dormant articles."
6089 (let* ((info (gnus-get-info group))
6090 (marked (gnus-info-marks info))
6091 (active (gnus-active group)))
6093 (gnus-list-range-difference
6094 (gnus-list-range-difference
6095 (gnus-sorted-complement
6096 (gnus-uncompress-range active)
6097 (gnus-list-of-unread-articles group))
6098 (cdr (assq 'dormant marked)))
6099 (cdr (assq 'tick marked))))))
6101 ;; Various summary commands
6103 (defun gnus-summary-select-article-buffer ()
6104 "Reconfigure windows to show article buffer."
6106 (if (not (gnus-buffer-live-p gnus-article-buffer))
6107 (error "There is no article buffer for this summary buffer")
6108 (gnus-configure-windows 'article)
6109 (select-window (get-buffer-window gnus-article-buffer))))
6111 (defun gnus-summary-universal-argument (arg)
6112 "Perform any operation on all articles that are process/prefixed."
6114 (let ((articles (gnus-summary-work-articles arg))
6121 (substitute-command-keys
6122 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6124 (gnus-error 1 "Undefined key")
6127 (gnus-summary-goto-subject (setq article (pop articles)))
6128 (let (gnus-newsgroup-processable)
6129 (command-execute func))
6130 (gnus-summary-remove-process-mark article)))))
6131 (gnus-summary-position-point))
6133 (defun gnus-summary-toggle-truncation (&optional arg)
6134 "Toggle truncation of summary lines.
6135 With arg, turn line truncation on iff arg is positive."
6137 (setq truncate-lines
6138 (if (null arg) (not truncate-lines)
6139 (> (prefix-numeric-value arg) 0)))
6142 (defun gnus-summary-reselect-current-group (&optional all rescan)
6143 "Exit and then reselect the current newsgroup.
6144 The prefix argument ALL means to select all articles."
6146 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6147 (error "Ephemeral groups can't be reselected"))
6148 (let ((current-subject (gnus-summary-article-number))
6149 (group gnus-newsgroup-name))
6150 (setq gnus-newsgroup-begin nil)
6152 ;; We have to adjust the point of group mode buffer because
6153 ;; point was moved to the next unread newsgroup by exiting.
6154 (gnus-summary-jump-to-group group)
6157 (gnus-group-get-new-news-this-group 1)))
6158 (gnus-group-read-group all t)
6159 (gnus-summary-goto-subject current-subject nil t)))
6161 (defun gnus-summary-rescan-group (&optional all)
6162 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6164 (gnus-summary-reselect-current-group all t))
6166 (defun gnus-summary-update-info (&optional non-destructive)
6168 (let ((group gnus-newsgroup-name))
6170 (when gnus-newsgroup-kill-headers
6171 (setq gnus-newsgroup-killed
6172 (gnus-compress-sequence
6174 (gnus-list-range-intersection
6175 gnus-newsgroup-unselected gnus-newsgroup-killed)
6176 gnus-newsgroup-unreads)
6178 (unless (listp (cdr gnus-newsgroup-killed))
6179 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6180 (let ((headers gnus-newsgroup-headers))
6181 ;; Set the new ranges of read articles.
6183 (set-buffer gnus-group-buffer)
6184 (gnus-undo-force-boundary))
6185 (gnus-update-read-articles
6186 group (gnus-sorted-union
6187 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6188 ;; Set the current article marks.
6189 (let ((gnus-newsgroup-scored
6190 (if (and (not gnus-save-score)
6191 (not non-destructive))
6193 gnus-newsgroup-scored)))
6195 (gnus-update-marks)))
6196 ;; Do the cross-ref thing.
6197 (when gnus-use-cross-reference
6198 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6199 ;; Do not switch windows but change the buffer to work.
6200 (set-buffer gnus-group-buffer)
6201 (unless (gnus-ephemeral-group-p group)
6202 (gnus-group-update-group group)))))))
6204 (defun gnus-summary-save-newsrc (&optional force)
6205 "Save the current number of read/marked articles in the dribble buffer.
6206 The dribble buffer will then be saved.
6207 If FORCE (the prefix), also save the .newsrc file(s)."
6209 (gnus-summary-update-info t)
6211 (gnus-save-newsrc-file)
6212 (gnus-dribble-save)))
6214 (defun gnus-summary-exit (&optional temporary)
6215 "Exit reading current newsgroup, and then return to group selection mode.
6216 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6218 (gnus-set-global-variables)
6219 (when (gnus-buffer-live-p gnus-article-buffer)
6221 (set-buffer gnus-article-buffer)
6222 (mm-destroy-parts gnus-article-mime-handles)
6223 ;; Set it to nil for safety reason.
6224 (setq gnus-article-mime-handle-alist nil)
6225 (setq gnus-article-mime-handles nil)))
6226 (gnus-kill-save-kill-buffer)
6227 (gnus-async-halt-prefetch)
6228 (let* ((group gnus-newsgroup-name)
6229 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6232 (buf (current-buffer)))
6234 ;; Do adaptive scoring, and possibly save score files.
6235 (when gnus-newsgroup-adaptive
6236 (gnus-score-adaptive))
6237 (when gnus-use-scoring
6239 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6240 ;; If we have several article buffers, we kill them at exit.
6241 (unless gnus-single-article-buffer
6242 (gnus-kill-buffer gnus-original-article-buffer)
6243 (setq gnus-article-current nil))
6244 (when gnus-use-cache
6245 (gnus-cache-possibly-remove-articles)
6246 (gnus-cache-save-buffers))
6247 (gnus-async-prefetch-remove-group group)
6248 (when gnus-suppress-duplicates
6249 (gnus-dup-enter-articles))
6250 (when gnus-use-trees
6251 (gnus-tree-close group))
6252 (when gnus-use-cache
6253 (gnus-cache-write-active))
6254 ;; Remove entries for this group.
6255 (nnmail-purge-split-history (gnus-group-real-name group))
6256 ;; Make all changes in this group permanent.
6258 (gnus-run-hooks 'gnus-exit-group-hook)
6259 (gnus-summary-update-info))
6260 (gnus-close-group group)
6261 ;; Make sure where we were, and go to next newsgroup.
6262 (set-buffer gnus-group-buffer)
6264 (gnus-group-jump-to-group group))
6265 (gnus-run-hooks 'gnus-summary-exit-hook)
6266 (unless (or quit-config
6267 ;; If this group has disappeared from the summary
6268 ;; buffer, don't skip forwards.
6269 (not (string= group (gnus-group-group-name))))
6270 (gnus-group-next-unread-group 1))
6271 (setq group-point (point))
6274 ;; If we have several article buffers, we kill them at exit.
6275 (unless gnus-single-article-buffer
6276 (gnus-kill-buffer gnus-article-buffer)
6277 (gnus-kill-buffer gnus-original-article-buffer)
6278 (setq gnus-article-current nil))
6280 (if (not gnus-kill-summary-on-exit)
6282 (gnus-deaden-summary)
6284 ;; We set all buffer-local variables to nil. It is unclear why
6285 ;; this is needed, but if we don't, buffer-local variables are
6286 ;; not garbage-collected, it seems. This would the lead to en
6287 ;; ever-growing Emacs.
6288 (gnus-summary-clear-local-variables)
6289 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6290 (gnus-summary-clear-local-variables))
6291 (when (get-buffer gnus-article-buffer)
6292 (bury-buffer gnus-article-buffer))
6293 ;; We clear the global counterparts of the buffer-local
6294 ;; variables as well, just to be on the safe side.
6295 (set-buffer gnus-group-buffer)
6296 (gnus-summary-clear-local-variables)
6297 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6298 (gnus-summary-clear-local-variables)))
6299 (setq gnus-current-select-method gnus-select-method)
6300 (pop-to-buffer gnus-group-buffer)
6301 (if (not quit-config)
6303 (goto-char group-point)
6304 (gnus-configure-windows 'group 'force))
6305 (gnus-handle-ephemeral-exit quit-config))
6306 ;; Return to group mode buffer.
6307 (when (eq mode 'gnus-summary-mode)
6308 (gnus-kill-buffer buf))
6309 ;; Clear the current group name.
6311 (setq gnus-newsgroup-name nil)))))
6313 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6314 (defun gnus-summary-exit-no-update (&optional no-questions)
6315 "Quit reading current newsgroup without updating read article info."
6317 (let* ((group gnus-newsgroup-name)
6318 (quit-config (gnus-group-quit-config group)))
6319 (when (or no-questions
6321 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6322 (gnus-async-halt-prefetch)
6324 (delq 'gnus-summary-expire-articles
6325 (copy-sequence gnus-summary-prepare-exit-hook)))
6326 (when (gnus-buffer-live-p gnus-article-buffer)
6328 (set-buffer gnus-article-buffer)
6329 (mm-destroy-parts gnus-article-mime-handles)
6330 ;; Set it to nil for safety reason.
6331 (setq gnus-article-mime-handle-alist nil)
6332 (setq gnus-article-mime-handles nil)))
6333 ;; If we have several article buffers, we kill them at exit.
6334 (unless gnus-single-article-buffer
6335 (gnus-kill-buffer gnus-article-buffer)
6336 (gnus-kill-buffer gnus-original-article-buffer)
6337 (setq gnus-article-current nil))
6338 (if (not gnus-kill-summary-on-exit)
6339 (gnus-deaden-summary)
6340 (gnus-close-group group)
6341 (gnus-summary-clear-local-variables)
6342 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6343 (gnus-summary-clear-local-variables))
6344 (set-buffer gnus-group-buffer)
6345 (gnus-summary-clear-local-variables)
6346 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6347 (gnus-summary-clear-local-variables))
6348 (when (get-buffer gnus-summary-buffer)
6349 (kill-buffer gnus-summary-buffer)))
6350 (unless gnus-single-article-buffer
6351 (setq gnus-article-current nil))
6352 (when gnus-use-trees
6353 (gnus-tree-close group))
6354 (gnus-async-prefetch-remove-group group)
6355 (when (get-buffer gnus-article-buffer)
6356 (bury-buffer gnus-article-buffer))
6357 ;; Return to the group buffer.
6358 (gnus-configure-windows 'group 'force)
6359 ;; Clear the current group name.
6360 (setq gnus-newsgroup-name nil)
6361 (when (equal (gnus-group-group-name) group)
6362 (gnus-group-next-unread-group 1))
6364 (gnus-handle-ephemeral-exit quit-config)))))
6366 (defun gnus-handle-ephemeral-exit (quit-config)
6367 "Handle movement when leaving an ephemeral group.
6368 The state which existed when entering the ephemeral is reset."
6369 (if (not (buffer-name (car quit-config)))
6370 (gnus-configure-windows 'group 'force)
6371 (set-buffer (car quit-config))
6372 (cond ((eq major-mode 'gnus-summary-mode)
6373 (gnus-set-global-variables))
6374 ((eq major-mode 'gnus-article-mode)
6376 ;; The `gnus-summary-buffer' variable may point
6377 ;; to the old summary buffer when using a single
6379 (unless (gnus-buffer-live-p gnus-summary-buffer)
6380 (set-buffer gnus-group-buffer))
6381 (set-buffer gnus-summary-buffer)
6382 (gnus-set-global-variables))))
6383 (if (or (eq (cdr quit-config) 'article)
6384 (eq (cdr quit-config) 'pick))
6386 ;; The current article may be from the ephemeral group
6387 ;; thus it is best that we reload this article
6388 (gnus-summary-show-article)
6389 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6390 (gnus-configure-windows 'pick 'force)
6391 (gnus-configure-windows (cdr quit-config) 'force)))
6392 (gnus-configure-windows (cdr quit-config) 'force))
6393 (when (eq major-mode 'gnus-summary-mode)
6394 (gnus-summary-next-subject 1 nil t)
6395 (gnus-summary-recenter)
6396 (gnus-summary-position-point))))
6400 (defvar gnus-dead-summary-mode-map nil)
6402 (unless gnus-dead-summary-mode-map
6403 (setq gnus-dead-summary-mode-map (make-keymap))
6404 (suppress-keymap gnus-dead-summary-mode-map)
6405 (substitute-key-definition
6406 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6407 (dolist (key '("\C-d" "\r" "\177" [delete]))
6408 (define-key gnus-dead-summary-mode-map
6409 key 'gnus-summary-wake-up-the-dead))
6410 (dolist (key '("q" "Q"))
6411 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6413 (defvar gnus-dead-summary-mode nil
6414 "Minor mode for Gnus summary buffers.")
6416 (defun gnus-dead-summary-mode (&optional arg)
6417 "Minor mode for Gnus summary buffers."
6419 (when (eq major-mode 'gnus-summary-mode)
6420 (make-local-variable 'gnus-dead-summary-mode)
6421 (setq gnus-dead-summary-mode
6422 (if (null arg) (not gnus-dead-summary-mode)
6423 (> (prefix-numeric-value arg) 0)))
6424 (when gnus-dead-summary-mode
6425 (gnus-add-minor-mode
6426 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6428 (defun gnus-deaden-summary ()
6429 "Make the current summary buffer into a dead summary buffer."
6430 ;; Kill any previous dead summary buffer.
6431 (when (and gnus-dead-summary
6432 (buffer-name gnus-dead-summary))
6434 (set-buffer gnus-dead-summary)
6435 (when gnus-dead-summary-mode
6436 (kill-buffer (current-buffer)))))
6437 ;; Make this the current dead summary.
6438 (setq gnus-dead-summary (current-buffer))
6439 (gnus-dead-summary-mode 1)
6440 (let ((name (buffer-name)))
6441 (when (string-match "Summary" name)
6443 (concat (substring name 0 (match-beginning 0)) "Dead "
6444 (substring name (match-beginning 0)))
6448 (defun gnus-kill-or-deaden-summary (buffer)
6449 "Kill or deaden the summary BUFFER."
6451 (when (and (buffer-name buffer)
6452 (not gnus-single-article-buffer))
6455 (gnus-kill-buffer gnus-article-buffer)
6456 (gnus-kill-buffer gnus-original-article-buffer)))
6459 (gnus-kill-summary-on-exit
6460 (when (and gnus-use-trees
6461 (gnus-buffer-exists-p buffer))
6464 (gnus-tree-close gnus-newsgroup-name)))
6465 (gnus-kill-buffer buffer))
6466 ;; Deaden the buffer.
6467 ((gnus-buffer-exists-p buffer)
6470 (gnus-deaden-summary))))))
6472 (defun gnus-summary-wake-up-the-dead (&rest args)
6473 "Wake up the dead summary buffer."
6475 (gnus-dead-summary-mode -1)
6476 (let ((name (buffer-name)))
6477 (when (string-match "Dead " name)
6479 (concat (substring name 0 (match-beginning 0))
6480 (substring name (match-end 0)))
6482 (gnus-message 3 "This dead summary is now alive again"))
6484 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6485 (defun gnus-summary-fetch-faq (&optional faq-dir)
6486 "Fetch the FAQ for the current group.
6487 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6491 (when current-prefix-arg
6493 "Faq dir: " (and (listp gnus-group-faq-directory)
6494 (mapcar (lambda (file) (list file))
6495 gnus-group-faq-directory))))))
6496 (let (gnus-faq-buffer)
6497 (when (setq gnus-faq-buffer
6498 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6499 (gnus-configure-windows 'summary-faq))))
6501 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6502 (defun gnus-summary-describe-group (&optional force)
6503 "Describe the current newsgroup."
6505 (gnus-group-describe-group force gnus-newsgroup-name))
6507 (defun gnus-summary-describe-briefly ()
6508 "Describe summary mode commands briefly."
6510 (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")))
6512 ;; Walking around group mode buffer from summary mode.
6514 (defun gnus-summary-next-group (&optional no-article target-group backward)
6515 "Exit current newsgroup and then select next unread newsgroup.
6516 If prefix argument NO-ARTICLE is non-nil, no article is selected
6517 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6518 previous group instead."
6520 ;; Stop pre-fetching.
6521 (gnus-async-halt-prefetch)
6522 (let ((current-group gnus-newsgroup-name)
6523 (current-buffer (current-buffer))
6525 ;; First we semi-exit this group to update Xrefs and all variables.
6526 ;; We can't do a real exit, because the window conf must remain
6527 ;; the same in case the user is prompted for info, and we don't
6528 ;; want the window conf to change before that...
6529 (gnus-summary-exit t)
6530 (while (not entered)
6531 ;; Then we find what group we are supposed to enter.
6532 (set-buffer gnus-group-buffer)
6533 (gnus-group-jump-to-group current-group)
6536 (if (eq gnus-keep-same-level 'best)
6537 (gnus-summary-best-group gnus-newsgroup-name)
6538 (gnus-summary-search-group backward gnus-keep-same-level))))
6539 (if (not target-group)
6540 ;; There are no further groups, so we return to the group
6543 (gnus-message 5 "Returning to the group buffer")
6545 (when (gnus-buffer-live-p current-buffer)
6546 (set-buffer current-buffer)
6547 (gnus-summary-exit))
6548 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6549 ;; We try to enter the target group.
6550 (gnus-group-jump-to-group target-group)
6551 (let ((unreads (gnus-group-group-unread)))
6552 (if (and (or (eq t unreads)
6553 (and unreads (not (zerop unreads))))
6554 (gnus-summary-read-group
6555 target-group nil no-article
6556 (and (buffer-name current-buffer) current-buffer)
6559 (setq current-group target-group
6560 target-group nil)))))))
6562 (defun gnus-summary-prev-group (&optional no-article)
6563 "Exit current newsgroup and then select previous unread newsgroup.
6564 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6566 (gnus-summary-next-group no-article nil t))
6568 ;; Walking around summary lines.
6570 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6571 "Go to the first unread subject.
6572 If UNREAD is non-nil, go to the first unread article.
6573 Returns the article selected or nil if there are no unread articles."
6578 ((null gnus-newsgroup-data)
6579 (gnus-message 3 "No articles in the group")
6581 ;; Pick the first article.
6583 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6584 (gnus-data-number (car gnus-newsgroup-data)))
6585 ;; No unread articles.
6586 ((null gnus-newsgroup-unreads)
6587 (gnus-message 3 "No more unread articles")
6589 ;; Find the first unread article.
6591 (let ((data gnus-newsgroup-data))
6593 (and (not (and undownloaded
6594 (eq gnus-undownloaded-mark
6595 (gnus-data-mark (car data)))))
6598 (gnus-data-number (car data))
6599 gnus-newsgroup-unseen))
6600 (not (gnus-data-unread-p (car data))))
6601 (not (gnus-data-unread-p (car data))))))
6602 (setq data (cdr data)))
6604 (goto-char (gnus-data-pos (car data)))
6605 (gnus-data-number (car data))))))
6606 (gnus-summary-position-point)))
6608 (defun gnus-summary-next-subject (n &optional unread dont-display)
6609 "Go to next N'th summary line.
6610 If N is negative, go to the previous N'th subject line.
6611 If UNREAD is non-nil, only unread articles are selected.
6612 The difference between N and the actual number of steps taken is
6615 (let ((backward (< n 0))
6619 (gnus-summary-find-prev unread)
6620 (gnus-summary-find-next unread)))
6621 (unless (zerop (setq n (1- n)))
6622 (gnus-summary-show-thread)))
6624 (gnus-message 7 "No more%s articles"
6625 (if unread " unread" "")))
6626 (unless dont-display
6627 (gnus-summary-recenter)
6628 (gnus-summary-position-point))
6631 (defun gnus-summary-next-unread-subject (n)
6632 "Go to next N'th unread summary line."
6634 (gnus-summary-next-subject n t))
6636 (defun gnus-summary-prev-subject (n &optional unread)
6637 "Go to previous N'th summary line.
6638 If optional argument UNREAD is non-nil, only unread article is selected."
6640 (gnus-summary-next-subject (- n) unread))
6642 (defun gnus-summary-prev-unread-subject (n)
6643 "Go to previous N'th unread summary line."
6645 (gnus-summary-next-subject (- n) t))
6647 (defun gnus-summary-goto-subject (article &optional force silent)
6648 "Go the subject line of ARTICLE.
6649 If FORCE, also allow jumping to articles not currently shown."
6650 (interactive "nArticle number: ")
6651 (unless (numberp article)
6652 (error "Article %s is not a number" article))
6654 (data (gnus-data-find article)))
6655 ;; We read in the article if we have to.
6658 (gnus-summary-insert-subject
6660 (if (or (numberp force) (vectorp force)) force)
6662 (setq data (gnus-data-find article)))
6667 (gnus-message 3 "Can't find article %d" article))
6669 (let ((pt (gnus-data-pos data)))
6671 (gnus-summary-set-article-display-arrow pt))
6672 (gnus-summary-position-point)
6675 ;; Walking around summary lines with displaying articles.
6677 (defun gnus-summary-expand-window (&optional arg)
6678 "Make the summary buffer take up the entire Emacs frame.
6679 Given a prefix, will force an `article' buffer configuration."
6682 (gnus-configure-windows 'article 'force)
6683 (gnus-configure-windows 'summary 'force)))
6685 (defun gnus-summary-display-article (article &optional all-header)
6686 "Display ARTICLE in article buffer."
6687 (when (gnus-buffer-live-p gnus-article-buffer)
6688 (with-current-buffer gnus-article-buffer
6689 (mm-enable-multibyte)))
6690 (gnus-set-global-variables)
6691 (when (gnus-buffer-live-p gnus-article-buffer)
6692 (with-current-buffer gnus-article-buffer
6693 (setq gnus-article-charset gnus-newsgroup-charset)
6694 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6695 (mm-enable-multibyte)))
6699 (if gnus-summary-display-article-function
6700 (funcall gnus-summary-display-article-function article all-header)
6701 (gnus-article-prepare article all-header))
6702 (gnus-run-hooks 'gnus-select-article-hook)
6703 (when (and gnus-current-article
6704 (not (zerop gnus-current-article)))
6705 (gnus-summary-goto-subject gnus-current-article))
6706 (gnus-summary-recenter)
6707 (when (and gnus-use-trees gnus-show-threads)
6708 (gnus-possibly-generate-tree article)
6709 (gnus-highlight-selected-tree article))
6710 ;; Successfully display article.
6711 (gnus-article-set-window-start
6712 (cdr (assq article gnus-newsgroup-bookmarks))))))
6714 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6715 "Select the current article.
6716 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6717 non-nil, the article will be re-fetched even if it already present in
6718 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6720 ;; Make sure we are in the summary buffer to work around bbdb bug.
6721 (unless (eq major-mode 'gnus-summary-mode)
6722 (set-buffer gnus-summary-buffer))
6723 (let ((article (or article (gnus-summary-article-number)))
6724 (all-headers (not (not all-headers))) ;Must be t or nil.
6725 gnus-summary-display-article-function)
6727 (gnus-summary-article-pseudo-p article)
6728 (error "This is a pseudo-article"))
6730 (set-buffer gnus-summary-buffer)
6731 (if (or (and gnus-single-article-buffer
6732 (or (null gnus-current-article)
6733 (null gnus-article-current)
6734 (null (get-buffer gnus-article-buffer))
6735 (not (eq article (cdr gnus-article-current)))
6736 (not (equal (car gnus-article-current)
6737 gnus-newsgroup-name))))
6738 (and (not gnus-single-article-buffer)
6739 (or (null gnus-current-article)
6740 (not (eq gnus-current-article article))))
6742 ;; The requested article is different from the current article.
6744 (gnus-summary-display-article article all-headers)
6745 (when (gnus-buffer-live-p gnus-article-buffer)
6746 (with-current-buffer gnus-article-buffer
6747 (if (not gnus-article-decoded-p) ;; a local variable
6748 (mm-disable-multibyte))))
6749 (gnus-article-set-window-start
6750 (cdr (assq article gnus-newsgroup-bookmarks)))
6754 (defun gnus-summary-force-verify-and-decrypt ()
6756 (let ((mm-verify-option 'known)
6757 (mm-decrypt-option 'known)
6758 (gnus-buttonized-mime-types (append (list "multipart/signed"
6759 "multipart/encrypted")
6760 gnus-buttonized-mime-types)))
6761 (gnus-summary-select-article nil 'force)))
6763 (defun gnus-summary-set-current-mark (&optional current-mark)
6764 "Obsolete function."
6767 (defun gnus-summary-next-article (&optional unread subject backward push)
6768 "Select the next article.
6769 If UNREAD, only unread articles are selected.
6770 If SUBJECT, only articles with SUBJECT are selected.
6771 If BACKWARD, the previous article is selected instead of the next."
6774 ;; Is there such an article?
6775 ((and (gnus-summary-search-forward unread subject backward)
6776 (or (gnus-summary-display-article (gnus-summary-article-number))
6777 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6778 (gnus-summary-position-point))
6779 ;; If not, we try the first unread, if that is wanted.
6781 gnus-auto-select-same
6782 (gnus-summary-first-unread-article))
6783 (gnus-summary-position-point)
6784 (gnus-message 6 "Wrapped"))
6785 ;; Try to get next/previous article not displayed in this group.
6786 ((and gnus-auto-extend-newsgroup
6787 (not unread) (not subject))
6788 (gnus-summary-goto-article
6789 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6790 nil (count-lines (point-min) (point))))
6791 ;; Go to next/previous group.
6793 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6794 (gnus-summary-jump-to-group gnus-newsgroup-name))
6795 (let ((cmd last-command-char)
6798 (set-buffer gnus-group-buffer)
6801 (if (eq gnus-keep-same-level 'best)
6802 (gnus-summary-best-group gnus-newsgroup-name)
6803 (gnus-summary-search-group backward gnus-keep-same-level))))
6804 ;; For some reason, the group window gets selected. We change
6806 (select-window (get-buffer-window (current-buffer)))
6807 ;; Select next unread newsgroup automagically.
6809 ((or (not gnus-auto-select-next)
6811 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6812 ((or (eq gnus-auto-select-next 'quietly)
6813 (and (eq gnus-auto-select-next 'slightly-quietly)
6815 (and (eq gnus-auto-select-next 'almost-quietly)
6816 (gnus-summary-last-article-p)))
6818 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6820 (gnus-message 7 "No more%s articles (%s)..."
6821 (if unread " unread" "")
6822 (if group (concat "selecting " group)
6824 (gnus-summary-next-group nil group backward)))
6826 (when (gnus-key-press-event-p last-input-event)
6827 (gnus-summary-walk-group-buffer
6828 gnus-newsgroup-name cmd unread backward point))))))))
6830 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6831 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6832 (?\C-p (gnus-group-prev-unread-group 1))))
6833 (cursor-in-echo-area t)
6834 keve key group ended)
6836 (set-buffer gnus-group-buffer)
6839 (if (eq gnus-keep-same-level 'best)
6840 (gnus-summary-best-group gnus-newsgroup-name)
6841 (gnus-summary-search-group backward gnus-keep-same-level))))
6844 5 "No more%s articles%s" (if unread " unread" "")
6846 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6847 (format " (Type %s for %s [%s])"
6848 (single-key-description cmd) group
6849 (car (gnus-gethash group gnus-newsrc-hashtb)))
6850 (format " (Type %s to exit %s)"
6851 (single-key-description cmd)
6852 gnus-newsgroup-name)))
6853 ;; Confirm auto selection.
6854 (setq key (car (setq keve (gnus-read-event-char))))
6857 ((assq key keystrokes)
6858 (let ((obuf (current-buffer)))
6859 (switch-to-buffer gnus-group-buffer)
6861 (gnus-group-jump-to-group group))
6862 (eval (cadr (assq key keystrokes)))
6863 (setq group (gnus-group-group-name))
6864 (switch-to-buffer obuf))
6868 (gnus-ephemeral-group-p gnus-newsgroup-name))
6870 (gnus-summary-next-group nil group backward)))
6872 (push (cdr keve) unread-command-events))))))
6874 (defun gnus-summary-next-unread-article ()
6875 "Select unread article after current one."
6877 (gnus-summary-next-article
6878 (or (not (eq gnus-summary-goto-unread 'never))
6879 (gnus-summary-last-article-p (gnus-summary-article-number)))
6880 (and gnus-auto-select-same
6881 (gnus-summary-article-subject))))
6883 (defun gnus-summary-prev-article (&optional unread subject)
6884 "Select the article after the current one.
6885 If UNREAD is non-nil, only unread articles are selected."
6887 (gnus-summary-next-article unread subject t))
6889 (defun gnus-summary-prev-unread-article ()
6890 "Select unread article before current one."
6892 (gnus-summary-prev-article
6893 (or (not (eq gnus-summary-goto-unread 'never))
6894 (gnus-summary-first-article-p (gnus-summary-article-number)))
6895 (and gnus-auto-select-same
6896 (gnus-summary-article-subject))))
6898 (defun gnus-summary-next-page (&optional lines circular)
6899 "Show next page of the selected article.
6900 If at the end of the current article, select the next article.
6901 LINES says how many lines should be scrolled up.
6903 If CIRCULAR is non-nil, go to the start of the article instead of
6904 selecting the next article when reaching the end of the current
6907 (setq gnus-summary-buffer (current-buffer))
6908 (gnus-set-global-variables)
6909 (let ((article (gnus-summary-article-number))
6910 (article-window (get-buffer-window gnus-article-buffer t))
6912 ;; If the buffer is empty, we have no article.
6914 (error "No article to select"))
6915 (gnus-configure-windows 'article)
6916 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6917 (if (and (eq gnus-summary-goto-unread 'never)
6918 (not (gnus-summary-last-article-p article)))
6919 (gnus-summary-next-article)
6920 (gnus-summary-next-unread-article))
6921 (if (or (null gnus-current-article)
6922 (null gnus-article-current)
6923 (/= article (cdr gnus-article-current))
6924 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6925 ;; Selected subject is different from current article's.
6926 (gnus-summary-display-article article)
6927 (when article-window
6928 (gnus-eval-in-buffer-window gnus-article-buffer
6929 (setq endp (gnus-article-next-page lines)))
6932 (gnus-summary-beginning-of-article))
6934 (gnus-message 3 "End of message"))
6936 (if (and (eq gnus-summary-goto-unread 'never)
6937 (not (gnus-summary-last-article-p article)))
6938 (gnus-summary-next-article)
6939 (gnus-summary-next-unread-article))))))))
6940 (gnus-summary-recenter)
6941 (gnus-summary-position-point)))
6943 (defun gnus-summary-prev-page (&optional lines move)
6944 "Show previous page of selected article.
6945 Argument LINES specifies lines to be scrolled down.
6946 If MOVE, move to the previous unread article if point is at
6947 the beginning of the buffer."
6949 (let ((article (gnus-summary-article-number))
6950 (article-window (get-buffer-window gnus-article-buffer t))
6952 (gnus-configure-windows 'article)
6953 (if (or (null gnus-current-article)
6954 (null gnus-article-current)
6955 (/= article (cdr gnus-article-current))
6956 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6957 ;; Selected subject is different from current article's.
6958 (gnus-summary-display-article article)
6959 (gnus-summary-recenter)
6960 (when article-window
6961 (gnus-eval-in-buffer-window gnus-article-buffer
6962 (setq endp (gnus-article-prev-page lines)))
6963 (when (and move endp)
6965 (gnus-message 3 "Beginning of message"))
6967 (if (and (eq gnus-summary-goto-unread 'never)
6968 (not (gnus-summary-first-article-p article)))
6969 (gnus-summary-prev-article)
6970 (gnus-summary-prev-unread-article))))))))
6971 (gnus-summary-position-point))
6973 (defun gnus-summary-prev-page-or-article (&optional lines)
6974 "Show previous page of selected article.
6975 Argument LINES specifies lines to be scrolled down.
6976 If at the beginning of the article, go to the next article."
6978 (gnus-summary-prev-page lines t))
6980 (defun gnus-summary-scroll-up (lines)
6981 "Scroll up (or down) one line current article.
6982 Argument LINES specifies lines to be scrolled up (or down if negative)."
6984 (gnus-configure-windows 'article)
6985 (gnus-summary-show-thread)
6986 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6987 (gnus-eval-in-buffer-window gnus-article-buffer
6989 (when (gnus-article-next-page lines)
6990 (gnus-message 3 "End of message")))
6992 (gnus-article-prev-page (- lines))))))
6993 (gnus-summary-recenter)
6994 (gnus-summary-position-point))
6996 (defun gnus-summary-scroll-down (lines)
6997 "Scroll down (or up) one line current article.
6998 Argument LINES specifies lines to be scrolled down (or up if negative)."
7000 (gnus-summary-scroll-up (- lines)))
7002 (defun gnus-summary-next-same-subject ()
7003 "Select next article which has the same subject as current one."
7005 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7007 (defun gnus-summary-prev-same-subject ()
7008 "Select previous article which has the same subject as current one."
7010 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7012 (defun gnus-summary-next-unread-same-subject ()
7013 "Select next unread article which has the same subject as current one."
7015 (gnus-summary-next-article t (gnus-summary-article-subject)))
7017 (defun gnus-summary-prev-unread-same-subject ()
7018 "Select previous unread article which has the same subject as current one."
7020 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7022 (defun gnus-summary-first-unread-article ()
7023 "Select the first unread article.
7024 Return nil if there are no unread articles."
7027 (when (gnus-summary-first-subject t)
7028 (gnus-summary-show-thread)
7029 (gnus-summary-first-subject t)
7030 (gnus-summary-display-article (gnus-summary-article-number)))
7031 (gnus-summary-position-point)))
7033 (defun gnus-summary-first-unread-subject ()
7034 "Place the point on the subject line of the first unread article.
7035 Return nil if there are no unread articles."
7038 (when (gnus-summary-first-subject t)
7039 (gnus-summary-show-thread)
7040 (gnus-summary-first-subject t))
7041 (gnus-summary-position-point)))
7043 (defun gnus-summary-first-unseen-subject ()
7044 "Place the point on the subject line of the first unseen article.
7045 Return nil if there are no unseen articles."
7048 (when (gnus-summary-first-subject t t t)
7049 (gnus-summary-show-thread)
7050 (gnus-summary-first-subject t t t))
7051 (gnus-summary-position-point)))
7053 (defun gnus-summary-first-unseen-or-unread-subject ()
7054 "Place the point on the subject line of the first unseen article.
7055 Return nil if there are no unseen articles."
7058 (unless (when (gnus-summary-first-subject t t t)
7059 (gnus-summary-show-thread)
7060 (gnus-summary-first-subject t t t))
7061 (when (gnus-summary-first-subject t)
7062 (gnus-summary-show-thread)
7063 (gnus-summary-first-subject t)))
7064 (gnus-summary-position-point)))
7066 (defun gnus-summary-first-article ()
7067 "Select the first article.
7068 Return nil if there are no articles."
7071 (when (gnus-summary-first-subject)
7072 (gnus-summary-show-thread)
7073 (gnus-summary-first-subject)
7074 (gnus-summary-display-article (gnus-summary-article-number)))
7075 (gnus-summary-position-point)))
7077 (defun gnus-summary-best-unread-article (&optional arg)
7078 "Select the unread article with the highest score.
7079 If given a prefix argument, select the next unread article that has a
7080 score higher than the default score."
7082 (let ((article (if arg
7083 (gnus-summary-better-unread-subject)
7084 (gnus-summary-best-unread-subject))))
7086 (gnus-summary-goto-article article)
7087 (error "No unread articles"))))
7089 (defun gnus-summary-best-unread-subject ()
7090 "Select the unread subject with the highest score."
7092 (let ((best -1000000)
7093 (data gnus-newsgroup-data)
7096 (and (gnus-data-unread-p (car data))
7098 (gnus-summary-article-score (gnus-data-number (car data))))
7101 article (gnus-data-number (car data))))
7102 (setq data (cdr data)))
7104 (gnus-summary-goto-subject article))
7105 (gnus-summary-position-point)
7108 (defun gnus-summary-better-unread-subject ()
7109 "Select the first unread subject that has a score over the default score."
7111 (let ((data gnus-newsgroup-data)
7113 (while (and (setq article (gnus-data-number (car data)))
7114 (or (gnus-data-read-p (car data))
7115 (not (> (gnus-summary-article-score article)
7116 gnus-summary-default-score))))
7117 (setq data (cdr data)))
7119 (gnus-summary-goto-subject article))
7120 (gnus-summary-position-point)
7123 (defun gnus-summary-last-subject ()
7124 "Go to the last displayed subject line in the group."
7125 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7127 (gnus-summary-goto-subject article))))
7129 (defun gnus-summary-goto-article (article &optional all-headers force)
7130 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7131 If ALL-HEADERS is non-nil, no header lines are hidden.
7132 If FORCE, go to the article even if it isn't displayed. If FORCE
7133 is a number, it is the line the article is to be displayed on."
7137 "Article number or Message-ID: "
7138 (mapcar (lambda (number) (list (int-to-string number)))
7139 gnus-newsgroup-limit))
7143 (if (and (stringp article)
7144 (string-match "@" article))
7145 (gnus-summary-refer-article article)
7146 (when (stringp article)
7147 (setq article (string-to-number article)))
7148 (if (gnus-summary-goto-subject article force)
7149 (gnus-summary-display-article article all-headers)
7150 (gnus-message 4 "Couldn't go to article %s" article) nil))
7151 (gnus-summary-position-point)))
7153 (defun gnus-summary-goto-last-article ()
7154 "Go to the previously read article."
7157 (when gnus-last-article
7158 (gnus-summary-goto-article gnus-last-article nil t))
7159 (gnus-summary-position-point)))
7161 (defun gnus-summary-pop-article (number)
7162 "Pop one article off the history and go to the previous.
7163 NUMBER articles will be popped off."
7166 (setq gnus-newsgroup-history
7167 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7169 (gnus-summary-goto-article (car to) nil t)
7170 (error "Article history empty")))
7171 (gnus-summary-position-point))
7173 ;; Summary commands and functions for limiting the summary buffer.
7175 (defun gnus-summary-limit-to-articles (n)
7176 "Limit the summary buffer to the next N articles.
7177 If not given a prefix, use the process marked articles instead."
7180 (let ((articles (gnus-summary-work-articles n)))
7181 (setq gnus-newsgroup-processable nil)
7182 (gnus-summary-limit articles))
7183 (gnus-summary-position-point)))
7185 (defun gnus-summary-pop-limit (&optional total)
7186 "Restore the previous limit.
7187 If given a prefix, remove all limits."
7190 (setq gnus-newsgroup-limits
7191 (list (mapcar (lambda (h) (mail-header-number h))
7192 gnus-newsgroup-headers))))
7193 (unless gnus-newsgroup-limits
7194 (error "No limit to pop"))
7196 (gnus-summary-limit nil 'pop)
7197 (gnus-summary-position-point)))
7199 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7200 "Limit the summary buffer to articles that have subjects that match a regexp.
7201 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7203 (list (read-string (if current-prefix-arg
7204 "Exclude subject (regexp): "
7205 "Limit to subject (regexp): "))
7206 nil current-prefix-arg))
7208 (setq header "subject"))
7209 (when (not (equal "" subject))
7211 (let ((articles (gnus-summary-find-matching
7212 (or header "subject") subject 'all nil nil
7215 (error "Found no matches for \"%s\"" subject))
7216 (gnus-summary-limit articles))
7217 (gnus-summary-position-point))))
7219 (defun gnus-summary-limit-to-author (from &optional not-matching)
7220 "Limit the summary buffer to articles that have authors that match a regexp.
7221 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7223 (list (read-string (if current-prefix-arg
7224 "Exclude author (regexp): "
7225 "Limit to author (regexp): "))
7226 current-prefix-arg))
7227 (gnus-summary-limit-to-subject from "from" not-matching))
7229 (defun gnus-summary-limit-to-age (age &optional younger-p)
7230 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7231 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7232 articles that are younger than AGE days."
7234 (let ((younger current-prefix-arg)
7237 (while (not days-got)
7238 (setq days (if younger
7239 (read-string "Limit to articles within (in days): ")
7240 (read-string "Limit to articles older than (in days): ")))
7241 (when (> (length days) 0)
7242 (setq days (read days)))
7248 (setq younger (not younger))
7249 (setq days (* days -1)))))
7250 (message "Please enter a number.")
7252 (list days younger)))
7254 (let ((data gnus-newsgroup-data)
7255 (cutoff (days-to-time age))
7256 articles d date is-younger)
7257 (while (setq d (pop data))
7258 (when (and (vectorp (gnus-data-header d))
7259 (setq date (mail-header-date (gnus-data-header d))))
7260 (setq is-younger (time-less-p
7261 (time-since (condition-case ()
7268 (push (gnus-data-number d) articles))))
7269 (gnus-summary-limit (nreverse articles)))
7270 (gnus-summary-position-point)))
7272 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7273 "Limit the summary buffer to articles that match an 'extra' header."
7277 (gnus-completing-read-with-default
7278 (symbol-name (car gnus-extra-headers))
7279 (if current-prefix-arg
7280 "Exclude extra header:"
7281 "Limit extra header:")
7283 (cons (symbol-name x) x))
7288 (read-string (format "%s header %s (regexp): "
7289 (if current-prefix-arg "Exclude" "Limit to")
7291 current-prefix-arg)))
7292 (when (not (equal "" regexp))
7294 (let ((articles (gnus-summary-find-matching
7295 (cons 'extra header) regexp 'all nil nil
7298 (error "Found no matches for \"%s\"" regexp))
7299 (gnus-summary-limit articles))
7300 (gnus-summary-position-point))))
7302 (defun gnus-summary-limit-to-display-predicate ()
7303 "Limit the summary buffer to the predicated in the `display' group parameter."
7305 (unless gnus-newsgroup-display
7306 (error "There is no `display' group parameter"))
7308 (dolist (number gnus-newsgroup-articles)
7309 (when (funcall gnus-newsgroup-display)
7310 (push number articles)))
7311 (gnus-summary-limit articles))
7312 (gnus-summary-position-point))
7314 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7316 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7318 (defun gnus-summary-limit-to-unread (&optional all)
7319 "Limit the summary buffer to articles that are not marked as read.
7320 If ALL is non-nil, limit strictly to unread articles."
7323 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7324 (gnus-summary-limit-to-marks
7325 ;; Concat all the marks that say that an article is read and have
7327 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7328 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7329 gnus-low-score-mark gnus-expirable-mark
7330 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7331 gnus-duplicate-mark gnus-souped-mark)
7334 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7335 (make-obsolete 'gnus-summary-delete-marked-with
7336 'gnus-summary-limit-exclude-marks)
7338 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7339 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7340 If REVERSE, limit the summary buffer to articles that are marked
7341 with MARKS. MARKS can either be a string of marks or a list of marks.
7342 Returns how many articles were removed."
7343 (interactive "sMarks: ")
7344 (gnus-summary-limit-to-marks marks t))
7346 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7347 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7348 If REVERSE (the prefix), limit the summary buffer to articles that are
7349 not marked with MARKS. MARKS can either be a string of marks or a
7351 Returns how many articles were removed."
7352 (interactive "sMarks: \nP")
7354 (let ((data gnus-newsgroup-data)
7355 (marks (if (listp marks) marks
7356 (append marks nil))) ; Transform to list.
7359 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7360 (memq (gnus-data-mark (car data)) marks))
7361 (push (gnus-data-number (car data)) articles))
7362 (setq data (cdr data)))
7363 (gnus-summary-limit articles))
7364 (gnus-summary-position-point)))
7366 (defun gnus-summary-limit-to-score (score)
7367 "Limit to articles with score at or above SCORE."
7368 (interactive "NLimit to articles with score of at least: ")
7369 (let ((data gnus-newsgroup-data)
7372 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7374 (push (gnus-data-number (car data)) articles))
7375 (setq data (cdr data)))
7377 (gnus-summary-limit articles)
7378 (gnus-summary-position-point))))
7380 (defun gnus-summary-limit-include-thread (id)
7381 "Display all the hidden articles that is in the thread with ID in it.
7382 When called interactively, ID is the Message-ID of the current
7384 (interactive (list (mail-header-id (gnus-summary-article-header))))
7385 (let ((articles (gnus-articles-in-thread
7386 (gnus-id-to-thread (gnus-root-id id)))))
7388 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7389 (gnus-summary-limit-include-matching-articles
7391 (regexp-quote (gnus-simplify-subject-re
7392 (mail-header-subject (gnus-id-to-header id)))))
7393 (gnus-summary-position-point))))
7395 (defun gnus-summary-limit-include-matching-articles (header regexp)
7396 "Display all the hidden articles that have HEADERs that match REGEXP."
7397 (interactive (list (read-string "Match on header: ")
7398 (read-string "Regexp: ")))
7399 (let ((articles (gnus-find-matching-articles header regexp)))
7401 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7402 (gnus-summary-position-point))))
7404 (defun gnus-summary-limit-include-dormant ()
7405 "Display all the hidden articles that are marked as dormant.
7406 Note that this command only works on a subset of the articles currently
7407 fetched for this group."
7409 (unless gnus-newsgroup-dormant
7410 (error "There are no dormant articles in this group"))
7412 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7413 (gnus-summary-position-point)))
7415 (defun gnus-summary-limit-exclude-dormant ()
7416 "Hide all dormant articles."
7419 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7420 (gnus-summary-position-point)))
7422 (defun gnus-summary-limit-exclude-childless-dormant ()
7423 "Hide all dormant articles that have no children."
7425 (let ((data (gnus-data-list t))
7426 articles d children)
7427 ;; Find all articles that are either not dormant or have
7429 (while (setq d (pop data))
7430 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7432 (gnus-article-children (gnus-data-number d)))
7435 (when (memq (car children) articles)
7440 (push (gnus-data-number d) articles)))
7443 (gnus-summary-limit articles)
7444 (gnus-summary-position-point))))
7446 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7447 "Mark all unread excluded articles as read.
7448 If ALL, mark even excluded ticked and dormants as read."
7450 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7451 (let ((articles (gnus-sorted-ndifference
7453 (mapcar (lambda (h) (mail-header-number h))
7454 gnus-newsgroup-headers)
7456 gnus-newsgroup-limit))
7458 (setq gnus-newsgroup-unreads
7459 (gnus-sorted-intersection gnus-newsgroup-unreads
7460 gnus-newsgroup-limit))
7462 (setq gnus-newsgroup-dormant nil
7463 gnus-newsgroup-marked nil
7464 gnus-newsgroup-reads
7466 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7467 gnus-newsgroup-reads))
7468 (while (setq article (pop articles))
7469 (unless (or (memq article gnus-newsgroup-dormant)
7470 (memq article gnus-newsgroup-marked))
7471 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7473 (defun gnus-summary-limit (articles &optional pop)
7475 ;; We pop the previous limit off the stack and use that.
7476 (setq articles (car gnus-newsgroup-limits)
7477 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7478 ;; We use the new limit, so we push the old limit on the stack.
7479 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7481 (setq gnus-newsgroup-limit articles)
7482 (let ((total (length gnus-newsgroup-data))
7483 (data (gnus-data-find-list (gnus-summary-article-number)))
7484 (gnus-summary-mark-below nil) ; Inhibit this.
7486 ;; This will do all the work of generating the new summary buffer
7487 ;; according to the new limit.
7488 (gnus-summary-prepare)
7489 ;; Hide any threads, possibly.
7490 (gnus-summary-maybe-hide-threads)
7491 ;; Try to return to the article you were at, or one in the
7494 ;; We try to find some article after the current one.
7496 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7499 (setq data (cdr data))))
7501 ;; If there is no data, that means that we were after the last
7502 ;; article. The same goes when we can't find any articles
7503 ;; after the current one.
7504 (goto-char (point-max))
7505 (gnus-summary-find-prev))
7506 (gnus-set-mode-line 'summary)
7507 ;; We return how many articles were removed from the summary
7508 ;; buffer as a result of the new limit.
7509 (- total (length gnus-newsgroup-data))))
7511 (defsubst gnus-invisible-cut-children (threads)
7514 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7519 (defsubst gnus-cut-thread (thread)
7520 "Go forwards in the thread until we find an article that we want to display."
7521 (when (or (eq gnus-fetch-old-headers 'some)
7522 (eq gnus-fetch-old-headers 'invisible)
7523 (numberp gnus-fetch-old-headers)
7524 (eq gnus-build-sparse-threads 'some)
7525 (eq gnus-build-sparse-threads 'more))
7526 ;; Deal with old-fetched headers and sparse threads.
7530 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7531 (gnus-summary-article-ancient-p
7532 (mail-header-number (car thread))))
7533 (if (or (<= (length (cdr thread)) 1)
7534 (eq gnus-fetch-old-headers 'invisible))
7535 (setq gnus-newsgroup-limit
7536 (delq (mail-header-number (car thread))
7537 gnus-newsgroup-limit)
7538 thread (cadr thread))
7539 (when (gnus-invisible-cut-children (cdr thread))
7540 (let ((th (cdr thread)))
7542 (if (memq (mail-header-number (caar th))
7543 gnus-newsgroup-limit)
7544 (setq thread (car th)
7546 (setq th (cdr th))))))))))
7549 (defun gnus-cut-threads (threads)
7550 "Cut off all uninteresting articles from the beginning of threads."
7551 (when (or (eq gnus-fetch-old-headers 'some)
7552 (eq gnus-fetch-old-headers 'invisible)
7553 (numberp gnus-fetch-old-headers)
7554 (eq gnus-build-sparse-threads 'some)
7555 (eq gnus-build-sparse-threads 'more))
7558 (setcar th (gnus-cut-thread (car th)))
7559 (setq th (cdr th)))))
7560 ;; Remove nixed out threads.
7563 (defun gnus-summary-initial-limit (&optional show-if-empty)
7564 "Figure out what the initial limit is supposed to be on group entry.
7565 This entails weeding out unwanted dormants, low-scored articles,
7566 fetch-old-headers verbiage, and so on."
7567 ;; Most groups have nothing to remove.
7568 (if (or gnus-inhibit-limiting
7569 (and (null gnus-newsgroup-dormant)
7570 (eq gnus-newsgroup-display 'gnus-not-ignore)
7571 (not (eq gnus-fetch-old-headers 'some))
7572 (not (numberp gnus-fetch-old-headers))
7573 (not (eq gnus-fetch-old-headers 'invisible))
7574 (null gnus-summary-expunge-below)
7575 (not (eq gnus-build-sparse-threads 'some))
7576 (not (eq gnus-build-sparse-threads 'more))
7577 (null gnus-thread-expunge-below)
7578 (not gnus-use-nocem)))
7580 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7581 (setq gnus-newsgroup-limit nil)
7584 (unless (car (symbol-value node))
7585 ;; These threads have no parents -- they are roots.
7586 (let ((nodes (cdr (symbol-value node)))
7589 (if (and gnus-thread-expunge-below
7590 (< (gnus-thread-total-score (car nodes))
7591 gnus-thread-expunge-below))
7592 (gnus-expunge-thread (pop nodes))
7593 (setq thread (pop nodes))
7594 (gnus-summary-limit-children thread))))))
7595 gnus-newsgroup-dependencies)
7596 ;; If this limitation resulted in an empty group, we might
7597 ;; pop the previous limit and use it instead.
7598 (when (and (not gnus-newsgroup-limit)
7600 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7601 gnus-newsgroup-limit))
7603 (defun gnus-summary-limit-children (thread)
7604 "Return 1 if this subthread is visible and 0 if it is not."
7605 ;; First we get the number of visible children to this thread. This
7606 ;; is done by recursing down the thread using this function, so this
7607 ;; will really go down to a leaf article first, before slowly
7608 ;; working its way up towards the root.
7612 (apply '+ (mapcar 'gnus-summary-limit-children
7615 (number (mail-header-number (car thread)))
7618 (not (memq number gnus-newsgroup-marked))
7620 ;; If this article is dormant and has absolutely no visible
7621 ;; children, then this article isn't visible.
7622 (and (memq number gnus-newsgroup-dormant)
7624 ;; If this is "fetch-old-headered" and there is no
7625 ;; visible children, then we don't want this article.
7626 (and (or (eq gnus-fetch-old-headers 'some)
7627 (numberp gnus-fetch-old-headers))
7628 (gnus-summary-article-ancient-p number)
7630 ;; If this is "fetch-old-headered" and `invisible', then
7631 ;; we don't want this article.
7632 (and (eq gnus-fetch-old-headers 'invisible)
7633 (gnus-summary-article-ancient-p number))
7634 ;; If this is a sparsely inserted article with no children,
7635 ;; we don't want it.
7636 (and (eq gnus-build-sparse-threads 'some)
7637 (gnus-summary-article-sparse-p number)
7639 ;; If we use expunging, and this article is really
7640 ;; low-scored, then we don't want this article.
7641 (when (and gnus-summary-expunge-below
7643 (or (cdr (assq number gnus-newsgroup-scored))
7644 gnus-summary-default-score))
7645 gnus-summary-expunge-below))
7646 ;; We increase the expunge-tally here, but that has
7647 ;; nothing to do with the limits, really.
7648 (incf gnus-newsgroup-expunged-tally)
7649 ;; We also mark as read here, if that's wanted.
7650 (when (and gnus-summary-mark-below
7651 (< score gnus-summary-mark-below))
7652 (setq gnus-newsgroup-unreads
7653 (delq number gnus-newsgroup-unreads))
7654 (if gnus-newsgroup-auto-expire
7655 (push number gnus-newsgroup-expirable)
7656 (push (cons number gnus-low-score-mark)
7657 gnus-newsgroup-reads)))
7659 ;; Do the `display' group parameter.
7660 (and gnus-newsgroup-display
7661 (not (funcall gnus-newsgroup-display)))
7662 ;; Check NoCeM things.
7663 (if (and gnus-use-nocem
7664 (gnus-nocem-unwanted-article-p
7665 (mail-header-id (car thread))))
7667 (setq gnus-newsgroup-unreads
7668 (delq number gnus-newsgroup-unreads))
7670 ;; Nope, invisible article.
7672 ;; Ok, this article is to be visible, so we add it to the limit
7674 (push number gnus-newsgroup-limit)
7677 (defun gnus-expunge-thread (thread)
7678 "Mark all articles in THREAD as read."
7679 (let* ((number (mail-header-number (car thread))))
7680 (incf gnus-newsgroup-expunged-tally)
7681 ;; We also mark as read here, if that's wanted.
7682 (setq gnus-newsgroup-unreads
7683 (delq number gnus-newsgroup-unreads))
7684 (if gnus-newsgroup-auto-expire
7685 (push number gnus-newsgroup-expirable)
7686 (push (cons number gnus-low-score-mark)
7687 gnus-newsgroup-reads)))
7688 ;; Go recursively through all subthreads.
7689 (mapcar 'gnus-expunge-thread (cdr thread)))
7691 ;; Summary article oriented commands
7693 (defun gnus-summary-refer-parent-article (n)
7694 "Refer parent article N times.
7695 If N is negative, go to ancestor -N instead.
7696 The difference between N and the number of articles fetched is returned."
7700 (when (not (natnump n))
7705 (setq header (gnus-summary-article-header))
7706 (if (and (eq (mail-header-number header)
7707 (cdr gnus-article-current))
7708 (equal gnus-newsgroup-name
7709 (car gnus-article-current)))
7710 ;; If we try to find the parent of the currently
7711 ;; displayed article, then we take a look at the actual
7712 ;; References header, since this is slightly more
7713 ;; reliable than the References field we got from the
7716 (set-buffer gnus-original-article-buffer)
7717 (nnheader-narrow-to-headers)
7718 (unless (setq ref (message-fetch-field "references"))
7719 (setq ref (message-fetch-field "in-reply-to")))
7722 ;; It's not the current article, so we take a bet on
7723 ;; the value we got from the server.
7724 (mail-header-references header)))
7726 (not (equal ref "")))
7727 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7728 (gnus-message 1 "Couldn't find parent"))
7729 (gnus-message 1 "No references in article %d"
7730 (gnus-summary-article-number))
7733 (gnus-summary-position-point)
7736 (defun gnus-summary-refer-references ()
7737 "Fetch all articles mentioned in the References header.
7738 Return the number of articles fetched."
7740 (let ((ref (mail-header-references (gnus-summary-article-header)))
7741 (current (gnus-summary-article-number))
7745 (error "No References in the current article")
7746 ;; For each Message-ID in the References header...
7747 (while (string-match "<[^>]*>" ref)
7749 ;; ... fetch that article.
7750 (gnus-summary-refer-article
7751 (prog1 (match-string 0 ref)
7752 (setq ref (substring ref (match-end 0))))))
7753 (gnus-summary-goto-subject current)
7754 (gnus-summary-position-point)
7757 (defun gnus-summary-refer-thread (&optional limit)
7758 "Fetch all articles in the current thread.
7759 If LIMIT (the numerical prefix), fetch that many old headers instead
7760 of what's specified by the `gnus-refer-thread-limit' variable."
7762 (let ((id (mail-header-id (gnus-summary-article-header)))
7763 (limit (if limit (prefix-numeric-value limit)
7764 gnus-refer-thread-limit)))
7765 ;; We want to fetch LIMIT *old* headers, but we also have to
7766 ;; re-fetch all the headers in the current buffer, because many of
7767 ;; them may be undisplayed. So we adjust LIMIT.
7768 (when (numberp limit)
7769 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7770 (unless (eq gnus-fetch-old-headers 'invisible)
7771 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7772 ;; Retrieve the headers and read them in.
7773 (if (eq (gnus-retrieve-headers
7774 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7776 (gnus-build-all-threads)
7777 (error "Can't fetch thread from backends that don't support NOV"))
7778 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7779 (gnus-summary-limit-include-thread id)))
7781 (defun gnus-summary-refer-article (message-id)
7782 "Fetch an article specified by MESSAGE-ID."
7783 (interactive "sMessage-ID: ")
7784 (when (and (stringp message-id)
7785 (not (zerop (length message-id))))
7786 ;; Construct the correct Message-ID if necessary.
7787 ;; Suggested by tale@pawl.rpi.edu.
7788 (unless (string-match "^<" message-id)
7789 (setq message-id (concat "<" message-id)))
7790 (unless (string-match ">$" message-id)
7791 (setq message-id (concat message-id ">")))
7792 (let* ((header (gnus-id-to-header message-id))
7794 (gnus-summary-article-sparse-p
7795 (mail-header-number header))
7796 (memq (mail-header-number header)
7797 gnus-newsgroup-limit)))
7800 ;; If the article is present in the buffer we just go to it.
7802 (or (not (gnus-summary-article-sparse-p
7803 (mail-header-number header)))
7806 (gnus-summary-goto-article
7807 (mail-header-number header) nil t)
7809 (gnus-summary-update-article (mail-header-number header)))))
7811 ;; We fetch the article.
7813 (dolist (gnus-override-method (gnus-refer-article-methods))
7814 (gnus-check-server gnus-override-method)
7815 ;; Fetch the header, and display the article.
7816 (when (setq number (gnus-summary-insert-subject message-id))
7817 (gnus-summary-select-article nil nil nil number)
7819 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7821 (defun gnus-refer-article-methods ()
7822 "Return a list of referrable methods."
7824 ;; No method, so we default to current and native.
7825 ((null gnus-refer-article-method)
7826 (list gnus-current-select-method gnus-select-method))
7828 ((eq 'current gnus-refer-article-method)
7829 (list gnus-current-select-method))
7830 ;; List of select methods.
7831 ((not (and (symbolp (car gnus-refer-article-method))
7832 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7834 (dolist (method gnus-refer-article-method)
7835 (push (if (eq 'current method)
7836 gnus-current-select-method
7840 ;; One single select method.
7842 (list gnus-refer-article-method))))
7844 (defun gnus-summary-edit-parameters ()
7845 "Edit the group parameters of the current group."
7847 (gnus-group-edit-group gnus-newsgroup-name 'params))
7849 (defun gnus-summary-customize-parameters ()
7850 "Customize the group parameters of the current group."
7852 (gnus-group-customize gnus-newsgroup-name))
7854 (defun gnus-summary-enter-digest-group (&optional force)
7855 "Enter an nndoc group based on the current article.
7856 If FORCE, force a digest interpretation. If not, try
7857 to guess what the document format is."
7859 (let ((conf gnus-current-window-configuration))
7861 (gnus-summary-select-article))
7862 (setq gnus-current-window-configuration conf)
7863 (let* ((name (format "%s-%d"
7864 (gnus-group-prefixed-name
7865 gnus-newsgroup-name (list 'nndoc ""))
7867 (set-buffer gnus-summary-buffer)
7868 gnus-current-article)))
7869 (ogroup gnus-newsgroup-name)
7870 (params (append (gnus-info-params (gnus-get-info ogroup))
7871 (list (cons 'to-group ogroup))
7872 (list (cons 'save-article-group ogroup))))
7873 (case-fold-search t)
7874 (buf (current-buffer))
7877 (set-buffer gnus-original-article-buffer)
7878 ;; Have the digest group inherit the main mail address of
7879 ;; the parent article.
7880 (when (setq to-address (or (gnus-fetch-field "reply-to")
7881 (gnus-fetch-field "from")))
7882 (setq params (append
7883 (list (cons 'to-address
7884 (funcall gnus-decode-encoded-word-function
7886 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7887 (insert-buffer-substring gnus-original-article-buffer)
7888 ;; Remove lines that may lead nndoc to misinterpret the
7891 (goto-char (point-min))
7892 (or (search-forward "\n\n" nil t) (point)))
7893 (goto-char (point-min))
7894 (delete-matching-lines "^Path:\\|^From ")
7897 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7898 (gnus-newsgroup-ephemeral-ignored-charsets
7899 gnus-newsgroup-ignored-charsets))
7900 (gnus-group-read-ephemeral-group
7901 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7903 ,(if force 'mbox 'guess)))
7905 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7907 ;; Make all postings to this group go to the parent group.
7908 (nconc (gnus-info-params (gnus-get-info name))
7910 ;; Couldn't select this doc group.
7911 (switch-to-buffer buf)
7912 (gnus-set-global-variables)
7913 (gnus-configure-windows 'summary)
7914 (gnus-message 3 "Article couldn't be entered?"))
7915 (kill-buffer dig)))))
7917 (defun gnus-summary-read-document (n)
7918 "Open a new group based on the current article(s).
7919 This will allow you to read digests and other similar
7920 documents as newsgroups.
7921 Obeys the standard process/prefix convention."
7923 (let* ((articles (gnus-summary-work-articles n))
7924 (ogroup gnus-newsgroup-name)
7925 (params (append (gnus-info-params (gnus-get-info ogroup))
7926 (list (cons 'to-group ogroup))))
7927 article group egroup groups vgroup)
7928 (while (setq article (pop articles))
7929 (setq group (format "%s-%d" gnus-newsgroup-name article))
7930 (gnus-summary-remove-process-mark article)
7931 (when (gnus-summary-display-article article)
7934 (insert-buffer-substring gnus-original-article-buffer)
7935 ;; Remove some headers that may lead nndoc to make
7937 (message-narrow-to-head)
7938 (goto-char (point-min))
7939 (delete-matching-lines "^\\(Path\\):\\|^From ")
7942 (gnus-group-read-ephemeral-group
7943 group `(nndoc ,group (nndoc-address ,(current-buffer))
7944 (nndoc-article-type guess))
7947 ;; Make all postings to this group go to the parent group.
7948 (nconc (gnus-info-params (gnus-get-info egroup))
7950 (push egroup groups))
7951 ;; Couldn't select this doc group.
7952 (gnus-error 3 "Article couldn't be entered"))))))
7953 ;; Now we have selected all the documents.
7956 (error "None of the articles could be interpreted as documents"))
7957 ((gnus-group-read-ephemeral-group
7958 (setq vgroup (format
7959 "nnvirtual:%s-%s" gnus-newsgroup-name
7960 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7961 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7963 (cons (current-buffer) 'summary)))
7965 (error "Couldn't select virtual nndoc group")))))
7967 (defun gnus-summary-isearch-article (&optional regexp-p)
7968 "Do incremental search forward on the current article.
7969 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7971 (gnus-summary-select-article)
7972 (gnus-configure-windows 'article)
7973 (gnus-eval-in-buffer-window gnus-article-buffer
7976 (isearch-forward regexp-p))))
7978 (defun gnus-summary-search-article-forward (regexp &optional backward)
7979 "Search for an article containing REGEXP forward.
7980 If BACKWARD, search backward instead."
7983 (format "Search article %s (regexp%s): "
7984 (if current-prefix-arg "backward" "forward")
7985 (if gnus-last-search-regexp
7986 (concat ", default " gnus-last-search-regexp)
7988 current-prefix-arg))
7989 (if (string-equal regexp "")
7990 (setq regexp (or gnus-last-search-regexp ""))
7991 (setq gnus-last-search-regexp regexp)
7992 (setq gnus-article-before-search gnus-current-article))
7993 ;; Intentionally set gnus-last-article.
7994 (setq gnus-last-article gnus-article-before-search)
7995 (let ((gnus-last-article gnus-last-article))
7996 (if (gnus-summary-search-article regexp backward)
7997 (gnus-summary-show-thread)
7998 (error "Search failed: \"%s\"" regexp))))
8000 (defun gnus-summary-search-article-backward (regexp)
8001 "Search for an article containing REGEXP backward."
8004 (format "Search article backward (regexp%s): "
8005 (if gnus-last-search-regexp
8006 (concat ", default " gnus-last-search-regexp)
8008 (gnus-summary-search-article-forward regexp 'backward))
8010 (defun gnus-summary-search-article (regexp &optional backward)
8011 "Search for an article containing REGEXP.
8012 Optional argument BACKWARD means do search for backward.
8013 `gnus-select-article-hook' is not called during the search."
8014 ;; We have to require this here to make sure that the following
8015 ;; dynamic binding isn't shadowed by autoloading.
8016 (require 'gnus-async)
8018 (let ((gnus-select-article-hook nil) ;Disable hook.
8019 (gnus-article-prepare-hook nil)
8020 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8021 (gnus-use-article-prefetch nil)
8022 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8023 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8024 (sum (current-buffer))
8025 (gnus-display-mime-function nil)
8028 (gnus-save-hidden-threads
8029 (gnus-summary-select-article)
8030 (set-buffer gnus-article-buffer)
8031 (goto-char (window-point (get-buffer-window (current-buffer))))
8035 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8037 (re-search-backward regexp nil t)
8038 (re-search-forward regexp nil t))
8039 ;; We found the regexp.
8044 (get-buffer-window (current-buffer))
8048 (get-buffer-window (current-buffer))
8051 (setq point (point)))
8052 ;; We didn't find it, so we go to the next article.
8055 (while (eq found 'not)
8056 (if (not (if backward (gnus-summary-find-prev)
8057 (gnus-summary-find-next)))
8058 ;; No more articles.
8060 ;; Select the next article and adjust point.
8061 (unless (gnus-summary-article-sparse-p
8062 (gnus-summary-article-number))
8064 (gnus-summary-select-article)
8065 (set-buffer gnus-article-buffer)
8067 (goto-char (if backward (point-max) (point-min))))))))
8068 (gnus-message 7 ""))
8069 ;; Return whether we found the regexp.
8070 (when (eq found 'found)
8072 (gnus-summary-show-thread)
8073 (gnus-summary-goto-subject gnus-current-article)
8074 (gnus-summary-position-point)
8077 (defun gnus-find-matching-articles (header regexp)
8078 "Return a list of all articles that match REGEXP on HEADER.
8079 This search includes all articles in the current group that Gnus has
8080 fetched headers for, whether they are displayed or not."
8081 (let ((articles nil)
8082 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8083 (case-fold-search t))
8084 (dolist (header gnus-newsgroup-headers)
8085 (when (string-match regexp (funcall func header))
8086 (push (mail-header-number header) articles)))
8087 (nreverse articles)))
8089 (defun gnus-summary-find-matching (header regexp &optional backward unread
8090 not-case-fold not-matching)
8091 "Return a list of all articles that match REGEXP on HEADER.
8092 The search stars on the current article and goes forwards unless
8093 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8094 If UNREAD is non-nil, only unread articles will
8095 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8096 in the comparisons. If NOT-MATCHING, return a list of all articles that
8097 not match REGEXP on HEADER."
8098 (let ((case-fold-search (not not-case-fold))
8101 (if (eq (car header) 'extra)
8104 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8106 (error "%s is an invalid header" header))
8107 (unless (fboundp (intern (concat "mail-header-" header)))
8108 (error "%s is not a valid header" header))
8109 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8110 (dolist (d (if (eq backward 'all)
8112 (gnus-data-find-list
8113 (gnus-summary-article-number)
8114 (gnus-data-list backward))))
8115 (when (and (or (not unread) ; We want all articles...
8116 (gnus-data-unread-p d)) ; Or just unreads.
8117 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8121 (funcall func (gnus-data-header d))))
8122 (string-match regexp
8123 (funcall func (gnus-data-header d)))))
8124 (push (gnus-data-number d) articles))) ; Success!
8125 (nreverse articles)))
8127 (defun gnus-summary-execute-command (header regexp command &optional backward)
8128 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8129 If HEADER is an empty string (or nil), the match is done on the entire
8130 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8132 (list (let ((completion-ignore-case t))
8135 (mapcar (lambda (header) (list (format "%s" header)))
8137 '("Number" "Subject" "From" "Lines" "Date"
8138 "Message-ID" "Xref" "References" "Body")
8139 gnus-extra-headers))
8140 nil 'require-match))
8141 (read-string "Regexp: ")
8142 (read-key-sequence "Command: ")
8143 current-prefix-arg))
8144 (when (equal header "Body")
8146 ;; Hidden thread subtrees must be searched as well.
8147 (gnus-summary-show-all-threads)
8148 ;; We don't want to change current point nor window configuration.
8150 (save-window-excursion
8151 (gnus-message 6 "Executing %s..." (key-description command))
8152 ;; We'd like to execute COMMAND interactively so as to give arguments.
8153 (gnus-execute header regexp
8154 `(call-interactively ',(key-binding command))
8156 (gnus-message 6 "Executing %s...done" (key-description command)))))
8158 (defun gnus-summary-beginning-of-article ()
8159 "Scroll the article back to the beginning."
8161 (gnus-summary-select-article)
8162 (gnus-configure-windows 'article)
8163 (gnus-eval-in-buffer-window gnus-article-buffer
8165 (goto-char (point-min))
8166 (when gnus-page-broken
8167 (gnus-narrow-to-page))))
8169 (defun gnus-summary-end-of-article ()
8170 "Scroll to the end of the article."
8172 (gnus-summary-select-article)
8173 (gnus-configure-windows 'article)
8174 (gnus-eval-in-buffer-window gnus-article-buffer
8176 (goto-char (point-max))
8178 (when gnus-page-broken
8179 (gnus-narrow-to-page))))
8181 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8182 "Truncate to LEN and quote all \"(\"'s in STRING."
8183 (gnus-replace-in-string (if (and len (> (length string) len))
8184 (substring string 0 len)
8188 (defun gnus-summary-print-article (&optional filename n)
8189 "Generate and print a PostScript image of the N next (mail) articles.
8191 If N is negative, print the N previous articles. If N is nil and articles
8192 have been marked with the process mark, print these instead.
8194 If the optional first argument FILENAME is nil, send the image to the
8195 printer. If FILENAME is a string, save the PostScript image in a file with
8196 that name. If FILENAME is a number, prompt the user for the name of the file
8198 (interactive (list (ps-print-preprint current-prefix-arg)))
8199 (dolist (article (gnus-summary-work-articles n))
8200 (gnus-summary-select-article nil nil 'pseudo article)
8201 (gnus-eval-in-buffer-window gnus-article-buffer
8202 (gnus-print-buffer))
8203 (gnus-summary-remove-process-mark article))
8204 (ps-despool filename))
8206 (defun gnus-print-buffer ()
8207 (let ((buffer (generate-new-buffer " *print*")))
8210 (copy-to-buffer buffer (point-min) (point-max))
8212 (gnus-article-delete-invisible-text)
8213 (gnus-remove-text-with-property 'gnus-decoration)
8214 (when (gnus-visual-p 'article-highlight 'highlight)
8215 ;; Copy-to-buffer doesn't copy overlay. So redo
8217 (let ((gnus-article-buffer buffer))
8218 (gnus-article-highlight-citation t)
8219 (gnus-article-highlight-signature)))
8220 (let ((ps-left-header
8223 (gnus-summary-print-truncate-and-quote
8224 (mail-header-subject gnus-current-headers)
8227 (gnus-summary-print-truncate-and-quote
8228 (mail-header-from gnus-current-headers)
8232 "/pagenumberstring load"
8234 (mail-header-date gnus-current-headers) ")"))))
8235 (gnus-run-hooks 'gnus-ps-print-hook)
8238 (ps-spool-buffer-with-faces)
8239 (ps-spool-buffer)))))
8240 (kill-buffer buffer))))
8242 (defun gnus-summary-show-article (&optional arg)
8243 "Force redisplaying of the current article.
8244 If ARG (the prefix) is a number, show the article with the charset
8245 defined in `gnus-summary-show-article-charset-alist', or the charset
8247 If ARG (the prefix) is non-nil and not a number, show the raw article
8248 without any article massaging functions being run. Normally, the key strokes
8253 (gnus-summary-show-article t)
8254 (let ((gnus-newsgroup-charset
8255 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8256 (mm-read-coding-system
8257 "View as charset: " ;; actually it is coding system.
8259 (set-buffer gnus-article-buffer)
8260 (mm-detect-coding-region (point) (point-max))))))
8261 (gnus-newsgroup-ignored-charsets 'gnus-all))
8262 (gnus-summary-select-article nil 'force)
8263 (let ((deps gnus-newsgroup-dependencies)
8266 (set-buffer gnus-original-article-buffer)
8268 (message-narrow-to-head)
8269 (setq head (buffer-string))
8270 (goto-char (point-min))
8271 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8272 (goto-char (point-max))
8274 (setq lines (1- (count-lines (point) (point-max))))))
8276 (insert (format "211 %d Article retrieved.\n"
8277 (cdr gnus-article-current)))
8279 (if lines (insert (format "Lines: %d\n" lines)))
8281 (let ((nntp-server-buffer (current-buffer)))
8282 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8283 (gnus-data-set-header
8284 (gnus-data-find (cdr gnus-article-current))
8286 (gnus-summary-update-article-line
8287 (cdr gnus-article-current) header)
8288 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8289 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8291 ;; Select the article the normal way.
8292 (gnus-summary-select-article nil 'force))
8294 ;; We have to require this here to make sure that the following
8295 ;; dynamic binding isn't shadowed by autoloading.
8296 (require 'gnus-async)
8298 ;; Bind the article treatment functions to nil.
8299 (let ((gnus-have-all-headers t)
8300 gnus-article-prepare-hook
8301 gnus-article-decode-hook
8302 gnus-display-mime-function
8304 ;; Destroy any MIME parts.
8305 (when (gnus-buffer-live-p gnus-article-buffer)
8307 (set-buffer gnus-article-buffer)
8308 (mm-destroy-parts gnus-article-mime-handles)
8309 ;; Set it to nil for safety reason.
8310 (setq gnus-article-mime-handle-alist nil)
8311 (setq gnus-article-mime-handles nil)))
8312 (gnus-summary-select-article nil 'force))))
8313 (gnus-summary-goto-subject gnus-current-article)
8314 (gnus-summary-position-point))
8316 (defun gnus-summary-show-raw-article ()
8317 "Show the raw article without any article massaging functions being run."
8319 (gnus-summary-show-article t))
8321 (defun gnus-summary-verbose-headers (&optional arg)
8322 "Toggle permanent full header display.
8323 If ARG is a positive number, turn header display on.
8324 If ARG is a negative number, turn header display off."
8326 (setq gnus-show-all-headers
8327 (cond ((or (not (numberp arg))
8329 (not gnus-show-all-headers))
8332 (gnus-summary-show-article))
8334 (defun gnus-summary-toggle-header (&optional arg)
8335 "Show the headers if they are hidden, or hide them if they are shown.
8336 If ARG is a positive number, show the entire header.
8337 If ARG is a negative number, hide the unwanted header lines."
8339 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8340 (get-buffer-window gnus-article-buffer t))))
8342 (with-current-buffer gnus-article-buffer
8344 (article-narrow-to-head)
8345 (let* ((buffer-read-only nil)
8346 (inhibit-point-motion-hooks t)
8347 (hidden (if (numberp arg)
8349 (gnus-article-hidden-text-p 'headers)))
8351 (delete-region (point-min) (point-max))
8352 (with-current-buffer gnus-original-article-buffer
8353 (goto-char (setq s (point-min)))
8354 (setq e (if (search-forward "\n\n" nil t)
8357 (insert-buffer-substring gnus-original-article-buffer s e)
8358 (article-decode-encoded-words)
8360 (let ((gnus-treat-hide-headers nil)
8361 (gnus-treat-hide-boring-headers nil))
8362 (gnus-delete-wash-type 'headers)
8363 (gnus-treat-article 'head))
8364 (gnus-treat-article 'head))
8366 (set-window-start window (goto-char (point-min)))
8367 (setq gnus-page-broken
8368 (when gnus-break-pages
8369 (gnus-narrow-to-page)
8371 (gnus-set-mode-line 'article))))))
8373 (defun gnus-summary-show-all-headers ()
8374 "Make all header lines visible."
8376 (gnus-summary-toggle-header 1))
8378 (defun gnus-summary-caesar-message (&optional arg)
8379 "Caesar rotate the current article by 13.
8380 The numerical prefix specifies how many places to rotate each letter
8383 (gnus-summary-select-article)
8384 (let ((mail-header-separator ""))
8385 (gnus-eval-in-buffer-window gnus-article-buffer
8388 (let ((start (window-start))
8390 (message-caesar-buffer-body arg)
8391 (set-window-start (get-buffer-window (current-buffer)) start))))))
8393 (defun gnus-summary-stop-page-breaking ()
8394 "Stop page breaking in the current article."
8396 (gnus-summary-select-article)
8397 (gnus-eval-in-buffer-window gnus-article-buffer
8399 (when (gnus-visual-p 'page-marker)
8400 (let ((buffer-read-only nil))
8401 (gnus-remove-text-with-property 'gnus-prev)
8402 (gnus-remove-text-with-property 'gnus-next))
8403 (setq gnus-page-broken nil))))
8405 (defun gnus-summary-move-article (&optional n to-newsgroup
8406 select-method action)
8407 "Move the current article to a different newsgroup.
8408 If N is a positive number, move the N next articles.
8409 If N is a negative number, move the N previous articles.
8410 If N is nil and any articles have been marked with the process mark,
8411 move those articles instead.
8412 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8413 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8414 re-spool using this method.
8416 When called interactively with TO-NEWSGROUP being nil, the value of
8417 the variable `gnus-move-split-methods' is used for finding a default
8418 for the target newsgroup.
8420 For this function to work, both the current newsgroup and the
8421 newsgroup that you want to move to have to support the `request-move'
8422 and `request-accept' functions.
8424 ACTION can be either `move' (the default), `crosspost' or `copy'."
8427 (setq action 'move))
8428 ;; Check whether the source group supports the required functions.
8429 (cond ((and (eq action 'move)
8430 (not (gnus-check-backend-function
8431 'request-move-article gnus-newsgroup-name)))
8432 (error "The current group does not support article moving"))
8433 ((and (eq action 'crosspost)
8434 (not (gnus-check-backend-function
8435 'request-replace-article gnus-newsgroup-name)))
8436 (error "The current group does not support article editing")))
8437 (let ((articles (gnus-summary-work-articles n))
8438 (prefix (if (gnus-check-backend-function
8439 'request-move-article gnus-newsgroup-name)
8440 (gnus-group-real-prefix gnus-newsgroup-name)
8442 (names '((move "Move" "Moving")
8443 (copy "Copy" "Copying")
8444 (crosspost "Crosspost" "Crossposting")))
8445 (copy-buf (save-excursion
8446 (nnheader-set-temp-buffer " *copy article*")))
8447 art-group to-method new-xref article to-groups)
8448 (unless (assq action names)
8449 (error "Unknown action %s" action))
8450 ;; Read the newsgroup name.
8451 (when (and (not to-newsgroup)
8452 (not select-method))
8453 (if (and gnus-move-split-methods
8455 (and (memq gnus-current-article articles)
8456 (gnus-buffer-live-p gnus-original-article-buffer))))
8457 ;; When `gnus-move-split-methods' is non-nil, we have to
8458 ;; select an article to give `gnus-read-move-group-name' an
8459 ;; opportunity to suggest an appropriate default. However,
8460 ;; we needn't render or mark the article.
8461 (let ((gnus-display-mime-function nil)
8462 (gnus-article-prepare-hook nil)
8463 (gnus-mark-article-hook nil))
8464 (gnus-summary-select-article nil nil nil (car articles))))
8466 (gnus-read-move-group-name
8467 (cadr (assq action names))
8468 (symbol-value (intern (format "gnus-current-%s-group" action)))
8470 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8471 (setq to-method (or select-method
8472 (gnus-server-to-method
8473 (gnus-group-method to-newsgroup))))
8474 ;; Check the method we are to move this article to...
8475 (unless (gnus-check-backend-function
8476 'request-accept-article (car to-method))
8477 (error "%s does not support article copying" (car to-method)))
8478 (unless (gnus-check-server to-method)
8479 (error "Can't open server %s" (car to-method)))
8480 (gnus-message 6 "%s to %s: %s..."
8481 (caddr (assq action names))
8482 (or (car select-method) to-newsgroup) articles)
8484 (setq article (pop articles))
8488 ;; Move the article.
8490 ;; Remove this article from future suppression.
8491 (gnus-dup-unsuppress-article article)
8492 (gnus-request-move-article
8493 article ; Article to move
8494 gnus-newsgroup-name ; From newsgroup
8495 (nth 1 (gnus-find-method-for-group
8496 gnus-newsgroup-name)) ; Server
8497 (list 'gnus-request-accept-article
8498 to-newsgroup (list 'quote select-method)
8499 (not articles) t) ; Accept form
8500 (not articles))) ; Only save nov last time
8501 ;; Copy the article.
8504 (set-buffer copy-buf)
8505 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8506 (gnus-request-accept-article
8507 to-newsgroup select-method (not articles) t))))
8508 ;; Crosspost the article.
8509 ((eq action 'crosspost)
8510 (let ((xref (message-tokenize-header
8511 (mail-header-xref (gnus-summary-article-header article))
8513 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8514 ":" (number-to-string article)))
8516 (setq xref (list (system-name))))
8519 (mapconcat 'identity
8520 (delete "Xref:" (delete new-xref xref))
8524 (set-buffer copy-buf)
8525 ;; First put the article in the destination group.
8526 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8527 (when (consp (setq art-group
8528 (gnus-request-accept-article
8529 to-newsgroup select-method (not articles))))
8530 (setq new-xref (concat new-xref " " (car art-group)
8532 (number-to-string (cdr art-group))))
8533 ;; Now we have the new Xrefs header, so we insert
8534 ;; it and replace the new article.
8535 (nnheader-replace-header "Xref" new-xref)
8536 (gnus-request-replace-article
8537 (cdr art-group) to-newsgroup (current-buffer))
8541 (gnus-message 1 "Couldn't %s article %s: %s"
8542 (cadr (assq action names)) article
8543 (nnheader-get-report (car to-method))))
8544 ((eq art-group 'junk)
8545 (when (eq action 'move)
8546 (gnus-summary-mark-article article gnus-canceled-mark)
8547 (gnus-message 4 "Deleted article %s" article)))
8549 (let* ((pto-group (gnus-group-prefixed-name
8550 (car art-group) to-method))
8552 (gnus-gethash pto-group gnus-newsrc-hashtb))
8553 (info (nth 2 entry))
8554 (to-group (gnus-info-group info))
8556 ;; Update the group that has been moved to.
8558 (memq action '(move copy)))
8559 (unless (member to-group to-groups)
8560 (push to-group to-groups))
8562 (unless (memq article gnus-newsgroup-unreads)
8563 (push 'read to-marks)
8565 info (gnus-add-to-range (gnus-info-read info)
8566 (list (cdr art-group)))))
8568 ;; See whether the article is to be put in the cache.
8569 (let ((marks gnus-article-mark-lists)
8570 (to-article (cdr art-group)))
8572 ;; Enter the article into the cache in the new group,
8573 ;; if that is required.
8574 (when gnus-use-cache
8575 (gnus-cache-possibly-enter-article
8577 (memq article gnus-newsgroup-marked)
8578 (memq article gnus-newsgroup-dormant)
8579 (memq article gnus-newsgroup-unreads)))
8581 (when gnus-preserve-marks
8582 ;; Copy any marks over to the new group.
8583 (when (and (equal to-group gnus-newsgroup-name)
8584 (not (memq article gnus-newsgroup-unreads)))
8585 ;; Mark this article as read in this group.
8586 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8587 (setcdr (gnus-active to-group) to-article)
8588 (setcdr gnus-newsgroup-active to-article))
8591 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8592 (when (memq article (symbol-value
8593 (intern (format "gnus-newsgroup-%s"
8595 (push (cdar marks) to-marks)
8596 ;; If the other group is the same as this group,
8597 ;; then we have to add the mark to the list.
8598 (when (equal to-group gnus-newsgroup-name)
8599 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8602 (intern (format "gnus-newsgroup-%s"
8604 ;; Copy the marks to other group.
8605 (gnus-add-marked-articles
8606 to-group (cdar marks) (list to-article) info)))
8607 (setq marks (cdr marks)))
8609 (gnus-request-set-mark to-group (list (list (list to-article)
8614 (concat "(gnus-group-set-info '"
8615 (gnus-prin1-to-string (gnus-get-info to-group))
8618 ;; Update the Xref header in this article to point to
8619 ;; the new crossposted article we have just created.
8620 (when (eq action 'crosspost)
8622 (set-buffer copy-buf)
8623 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8624 (nnheader-replace-header "Xref" new-xref)
8625 (gnus-request-replace-article
8626 article gnus-newsgroup-name (current-buffer)))))
8628 ;;;!!!Why is this necessary?
8629 (set-buffer gnus-summary-buffer)
8631 (gnus-summary-goto-subject article)
8632 (when (eq action 'move)
8633 (gnus-summary-mark-article article gnus-canceled-mark))))
8634 (gnus-summary-remove-process-mark article))
8635 ;; Re-activate all groups that have been moved to.
8637 (set-buffer gnus-group-buffer)
8638 (let ((gnus-group-marked to-groups))
8639 (gnus-group-get-new-news-this-group nil t)))
8641 (gnus-kill-buffer copy-buf)
8642 (gnus-summary-position-point)
8643 (gnus-set-mode-line 'summary)))
8645 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8646 "Move the current article to a different newsgroup.
8647 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8648 When called interactively, if TO-NEWSGROUP is nil, use the value of
8649 the variable `gnus-move-split-methods' for finding a default target
8651 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8652 re-spool using this method."
8654 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8656 (defun gnus-summary-crosspost-article (&optional n)
8657 "Crosspost the current article to some other group."
8659 (gnus-summary-move-article n nil nil 'crosspost))
8661 (defcustom gnus-summary-respool-default-method nil
8662 "Default method type for respooling an article.
8663 If nil, use to the current newsgroup method."
8665 :group 'gnus-summary-mail)
8667 (defun gnus-summary-respool-article (&optional n method)
8668 "Respool the current article.
8669 The article will be squeezed through the mail spooling process again,
8670 which means that it will be put in some mail newsgroup or other
8671 depending on `nnmail-split-methods'.
8672 If N is a positive number, respool the N next articles.
8673 If N is a negative number, respool the N previous articles.
8674 If N is nil and any articles have been marked with the process mark,
8675 respool those articles instead.
8677 Respooling can be done both from mail groups and \"real\" newsgroups.
8678 In the former case, the articles in question will be moved from the
8679 current group into whatever groups they are destined to. In the
8680 latter case, they will be copied into the relevant groups."
8682 (list current-prefix-arg
8683 (let* ((methods (gnus-methods-using 'respool))
8685 (symbol-name (or gnus-summary-respool-default-method
8686 (car (gnus-find-method-for-group
8687 gnus-newsgroup-name)))))
8689 (gnus-completing-read-with-default
8690 methname "What backend do you want to use when respooling?"
8691 methods nil t nil 'gnus-mail-method-history))
8694 ((zerop (length (setq ms (gnus-servers-using-backend
8696 (list (intern method) ""))
8700 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8701 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8704 (error "No method given for respooling"))
8705 (if (assoc (symbol-name
8706 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8707 (gnus-methods-using 'respool))
8708 (gnus-summary-move-article n nil method)
8709 (gnus-summary-copy-article n nil method)))
8711 (defun gnus-summary-import-article (file &optional edit)
8712 "Import an arbitrary file into a mail newsgroup."
8713 (interactive "fImport file: \nP")
8714 (let ((group gnus-newsgroup-name)
8715 (now (current-time))
8716 atts lines group-art)
8717 (unless (gnus-check-backend-function 'request-accept-article group)
8718 (error "%s does not support article importing" group))
8719 (or (file-readable-p file)
8720 (not (file-regular-p file))
8721 (error "Can't read %s" file))
8723 (set-buffer (gnus-get-buffer-create " *import file*"))
8725 (nnheader-insert-file-contents file)
8726 (goto-char (point-min))
8727 (if (nnheader-article-p)
8729 (goto-char (point-min))
8730 (search-forward "\n\n" nil t)
8731 (narrow-to-region (point-min) (1- (point)))
8732 (goto-char (point-min))
8733 (unless (re-search-forward "^date:" nil t)
8734 (goto-char (point-max))
8735 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8736 ;; This doesn't look like an article, so we fudge some headers.
8737 (setq atts (file-attributes file)
8738 lines (count-lines (point-min) (point-max)))
8739 (insert "From: " (read-string "From: ") "\n"
8740 "Subject: " (read-string "Subject: ") "\n"
8741 "Date: " (message-make-date (nth 5 atts)) "\n"
8742 "Message-ID: " (message-make-message-id) "\n"
8743 "Lines: " (int-to-string lines) "\n"
8744 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8745 (setq group-art (gnus-request-accept-article group nil t))
8746 (kill-buffer (current-buffer)))
8747 (setq gnus-newsgroup-active (gnus-activate-group group))
8749 (gnus-summary-goto-article (cdr group-art) nil t)
8751 (gnus-summary-edit-article))))
8753 (defun gnus-summary-create-article ()
8754 "Create an article in a mail newsgroup."
8756 (let ((group gnus-newsgroup-name)
8757 (now (current-time))
8759 (unless (gnus-check-backend-function 'request-accept-article group)
8760 (error "%s does not support article importing" group))
8762 (set-buffer (gnus-get-buffer-create " *import file*"))
8764 (goto-char (point-min))
8765 ;; This doesn't look like an article, so we fudge some headers.
8766 (insert "From: " (read-string "From: ") "\n"
8767 "Subject: " (read-string "Subject: ") "\n"
8768 "Date: " (message-make-date now) "\n"
8769 "Message-ID: " (message-make-message-id) "\n")
8770 (setq group-art (gnus-request-accept-article group nil t))
8771 (kill-buffer (current-buffer)))
8772 (setq gnus-newsgroup-active (gnus-activate-group group))
8774 (gnus-summary-goto-article (cdr group-art) nil t)
8775 (gnus-summary-edit-article)))
8777 (defun gnus-summary-article-posted-p ()
8778 "Say whether the current (mail) article is available from news as well.
8779 This will be the case if the article has both been mailed and posted."
8781 (let ((id (mail-header-references (gnus-summary-article-header)))
8782 (gnus-override-method (car (gnus-refer-article-methods))))
8783 (if (gnus-request-head id "")
8784 (gnus-message 2 "The current message was found on %s"
8785 gnus-override-method)
8786 (gnus-message 2 "The current message couldn't be found on %s"
8787 gnus-override-method)
8790 (defun gnus-summary-expire-articles (&optional now)
8791 "Expire all articles that are marked as expirable in the current group."
8793 (when (gnus-check-backend-function
8794 'request-expire-articles gnus-newsgroup-name)
8795 ;; This backend supports expiry.
8796 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8797 (expirable (if total
8799 ;; We need to update the info for
8800 ;; this group for `gnus-list-of-read-articles'
8801 ;; to give us the right answer.
8802 (gnus-run-hooks 'gnus-exit-group-hook)
8803 (gnus-summary-update-info)
8804 (gnus-list-of-read-articles gnus-newsgroup-name))
8805 (setq gnus-newsgroup-expirable
8806 (sort gnus-newsgroup-expirable '<))))
8807 (expiry-wait (if now 'immediate
8808 (gnus-group-find-parameter
8809 gnus-newsgroup-name 'expiry-wait)))
8810 (nnmail-expiry-target
8811 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8812 nnmail-expiry-target))
8815 ;; There are expirable articles in this group, so we run them
8816 ;; through the expiry process.
8817 (gnus-message 6 "Expiring articles...")
8818 (unless (gnus-check-group gnus-newsgroup-name)
8819 (error "Can't open server for %s" gnus-newsgroup-name))
8820 ;; The list of articles that weren't expired is returned.
8823 (let ((nnmail-expiry-wait-function nil)
8824 (nnmail-expiry-wait expiry-wait))
8825 (setq es (gnus-request-expire-articles
8826 expirable gnus-newsgroup-name)))
8827 (setq es (gnus-request-expire-articles
8828 expirable gnus-newsgroup-name)))
8830 (setq gnus-newsgroup-expirable es))
8831 ;; We go through the old list of expirable, and mark all
8832 ;; really expired articles as nonexistent.
8833 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8834 (let ((gnus-use-cache nil))
8835 (dolist (article expirable)
8836 (when (and (not (memq article es))
8837 (gnus-data-find article))
8838 (gnus-summary-mark-article article gnus-canceled-mark))))))
8839 (gnus-message 6 "Expiring articles...done")))))
8841 (defun gnus-summary-expire-articles-now ()
8842 "Expunge all expirable articles in the current group.
8843 This means that *all* articles that are marked as expirable will be
8844 deleted forever, right now."
8846 (or gnus-expert-user
8848 "Are you really, really, really sure you want to delete all these messages? ")
8850 (gnus-summary-expire-articles t))
8852 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8853 (defun gnus-summary-delete-article (&optional n)
8854 "Delete the N next (mail) articles.
8855 This command actually deletes articles. This is not a marking
8856 command. The article will disappear forever from your life, never to
8858 If N is negative, delete backwards.
8859 If N is nil and articles have been marked with the process mark,
8860 delete these instead."
8862 (unless (gnus-check-backend-function 'request-expire-articles
8863 gnus-newsgroup-name)
8864 (error "The current newsgroup does not support article deletion"))
8865 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8866 (error "Couldn't open server"))
8867 ;; Compute the list of articles to delete.
8868 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8869 (nnmail-expiry-target 'delete)
8871 (if (and gnus-novice-user
8872 (not (gnus-yes-or-no-p
8873 (format "Do you really want to delete %s forever? "
8874 (if (> (length articles) 1)
8875 (format "these %s articles" (length articles))
8878 ;; Delete the articles.
8879 (setq not-deleted (gnus-request-expire-articles
8880 articles gnus-newsgroup-name 'force))
8882 (gnus-summary-remove-process-mark (car articles))
8883 ;; The backend might not have been able to delete the article
8885 (unless (memq (car articles) not-deleted)
8886 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8887 (setq articles (cdr articles)))
8889 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8890 (gnus-summary-position-point)
8891 (gnus-set-mode-line 'summary)
8894 (defun gnus-summary-edit-article (&optional arg)
8895 "Edit the current article.
8896 This will have permanent effect only in mail groups.
8897 If ARG is nil, edit the decoded articles.
8898 If ARG is 1, edit the raw articles.
8899 If ARG is 2, edit the raw articles even in read-only groups.
8900 If ARG is 3, edit the articles with the current handles.
8901 Otherwise, allow editing of articles even in read-only
8904 (let (force raw current-handles)
8913 (setq current-handles
8914 (and (gnus-buffer-live-p gnus-article-buffer)
8915 (with-current-buffer gnus-article-buffer
8917 gnus-article-mime-handles
8918 (setq gnus-article-mime-handles nil))))))
8921 (when (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8922 (error "Can't edit the raw article in group nndraft:drafts"))
8924 (set-buffer gnus-summary-buffer)
8925 (let ((mail-parse-charset gnus-newsgroup-charset)
8926 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8927 (gnus-set-global-variables)
8928 (when (and (not force)
8929 (gnus-group-read-only-p))
8930 (error "The current newsgroup does not support article editing"))
8931 (gnus-summary-show-article t)
8932 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8933 (with-current-buffer gnus-article-buffer
8934 (mm-enable-multibyte)))
8935 (if (equal gnus-newsgroup-name "nndraft:drafts")
8937 (gnus-article-edit-article
8940 (let ((mbl mml-buffer-list))
8941 (setq mml-buffer-list nil)
8942 (mime-to-mml ,'current-handles)
8943 (let ((mbl1 mml-buffer-list))
8944 (setq mml-buffer-list mbl)
8945 (set (make-local-variable 'mml-buffer-list) mbl1))
8946 (make-local-hook 'kill-buffer-hook)
8947 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8948 `(lambda (no-highlight)
8949 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8950 (message-options message-options)
8951 (message-options-set-recipient)
8952 (mail-parse-ignored-charsets
8953 ',gnus-newsgroup-ignored-charsets))
8954 ,(if (not raw) '(progn
8956 (mml-destroy-buffers)
8957 (remove-hook 'kill-buffer-hook
8958 'mml-destroy-buffers t)
8959 (kill-local-variable 'mml-buffer-list)))
8960 (gnus-summary-edit-article-done
8961 ,(or (mail-header-references gnus-current-headers) "")
8962 ,(gnus-group-read-only-p)
8963 ,gnus-summary-buffer no-highlight))))))))
8965 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8967 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8969 "Make edits to the current article permanent."
8972 ;; The buffer restriction contains the entire article if it exists.
8973 (when (article-goto-body)
8974 (let ((lines (count-lines (point) (point-max)))
8975 (length (- (point-max) (point)))
8976 (case-fold-search t)
8977 (body (copy-marker (point))))
8978 (goto-char (point-min))
8979 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8980 (delete-region (match-beginning 1) (match-end 1))
8981 (insert (number-to-string length)))
8982 (goto-char (point-min))
8983 (when (re-search-forward
8984 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8985 (delete-region (match-beginning 1) (match-end 1))
8986 (insert (number-to-string length)))
8987 (goto-char (point-min))
8988 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8989 (delete-region (match-beginning 1) (match-end 1))
8990 (insert (number-to-string lines))))))
8991 ;; Replace the article.
8992 (let ((buf (current-buffer)))
8994 (insert-buffer-substring buf)
8996 (if (and (not read-only)
8997 (not (gnus-request-replace-article
8998 (cdr gnus-article-current) (car gnus-article-current)
8999 (current-buffer) t)))
9000 (error "Couldn't replace article")
9001 ;; Update the summary buffer.
9003 (equal (message-tokenize-header references " ")
9004 (message-tokenize-header
9005 (or (message-fetch-field "references") "") " ")))
9006 ;; We only have to update this line.
9009 (message-narrow-to-head)
9010 (let ((head (buffer-string))
9013 (insert (format "211 %d Article retrieved.\n"
9014 (cdr gnus-article-current)))
9017 (let ((nntp-server-buffer (current-buffer)))
9018 (setq header (car (gnus-get-newsgroup-headers
9021 (set-buffer gnus-summary-buffer)
9022 (gnus-data-set-header
9023 (gnus-data-find (cdr gnus-article-current))
9025 (gnus-summary-update-article-line
9026 (cdr gnus-article-current) header)
9027 (if (gnus-summary-goto-subject
9028 (cdr gnus-article-current) nil t)
9029 (gnus-summary-update-secondary-mark
9030 (cdr gnus-article-current))))))))
9032 (set-buffer (or buffer gnus-summary-buffer))
9033 (gnus-summary-update-article (cdr gnus-article-current))
9034 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9035 (gnus-summary-update-secondary-mark
9036 (cdr gnus-article-current))))
9037 ;; Prettify the article buffer again.
9038 (unless no-highlight
9040 (set-buffer gnus-article-buffer)
9041 ;;;!!! Fix this -- article should be rehighlighted.
9042 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9043 (set-buffer gnus-original-article-buffer)
9044 (gnus-request-article
9045 (cdr gnus-article-current)
9046 (car gnus-article-current) (current-buffer))))
9047 ;; Prettify the summary buffer line.
9048 (when (gnus-visual-p 'summary-highlight 'highlight)
9049 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9051 (defun gnus-summary-edit-wash (key)
9052 "Perform editing command KEY in the article buffer."
9056 (message "%s" (concat (this-command-keys) "- "))
9059 (gnus-summary-edit-article)
9060 (execute-kbd-macro (concat (this-command-keys) key))
9061 (gnus-article-edit-done))
9065 (defun gnus-summary-respool-query (&optional silent trace)
9066 "Query where the respool algorithm would put this article."
9068 (let (gnus-mark-article-hook)
9069 (gnus-summary-select-article)
9071 (set-buffer gnus-original-article-buffer)
9073 (message-narrow-to-head)
9074 (let ((groups (nnmail-article-group 'identity trace)))
9077 (message "This message would go to %s"
9078 (mapconcat 'car groups ", "))
9079 (message "This message would go to no groups"))
9082 (defun gnus-summary-respool-trace ()
9083 "Trace where the respool algorithm would put this article.
9084 Display a buffer showing all fancy splitting patterns which matched."
9086 (gnus-summary-respool-query nil t))
9088 ;; Summary marking commands.
9090 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9091 "Mark articles which has the same subject as read, and then select the next.
9092 If UNMARK is positive, remove any kind of mark.
9093 If UNMARK is negative, tick articles."
9096 (setq unmark (prefix-numeric-value unmark)))
9098 (gnus-summary-mark-same-subject
9099 (gnus-summary-article-subject) unmark)))
9100 ;; Select next unread article. If auto-select-same mode, should
9101 ;; select the first unread article.
9102 (gnus-summary-next-article t (and gnus-auto-select-same
9103 (gnus-summary-article-subject)))
9104 (gnus-message 7 "%d article%s marked as %s"
9105 count (if (= count 1) " is" "s are")
9106 (if unmark "unread" "read"))))
9108 (defun gnus-summary-kill-same-subject (&optional unmark)
9109 "Mark articles which has the same subject as read.
9110 If UNMARK is positive, remove any kind of mark.
9111 If UNMARK is negative, tick articles."
9114 (setq unmark (prefix-numeric-value unmark)))
9116 (gnus-summary-mark-same-subject
9117 (gnus-summary-article-subject) unmark)))
9118 ;; If marked as read, go to next unread subject.
9120 ;; Go to next unread subject.
9121 (gnus-summary-next-subject 1 t))
9122 (gnus-message 7 "%d articles are marked as %s"
9123 count (if unmark "unread" "read"))))
9125 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9126 "Mark articles with same SUBJECT as read, and return marked number.
9127 If optional argument UNMARK is positive, remove any kinds of marks.
9128 If optional argument UNMARK is negative, mark articles as unread instead."
9132 ((null unmark) ; Mark as read.
9135 (gnus-summary-mark-article-as-read gnus-killed-mark)
9136 (gnus-summary-show-thread) t)
9137 (gnus-summary-find-subject subject))
9138 (setq count (1+ count))))
9139 ((> unmark 0) ; Tick.
9142 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9143 (gnus-summary-show-thread) t)
9144 (gnus-summary-find-subject subject))
9145 (setq count (1+ count))))
9146 (t ; Mark as unread.
9149 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9150 (gnus-summary-show-thread) t)
9151 (gnus-summary-find-subject subject))
9152 (setq count (1+ count)))))
9153 (gnus-set-mode-line 'summary)
9154 ;; Return the number of marked articles.
9157 (defun gnus-summary-mark-as-processable (n &optional unmark)
9158 "Set the process mark on the next N articles.
9159 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9160 the process mark instead. The difference between N and the actual
9161 number of articles marked is returned."
9163 (if (and (null n) (gnus-region-active-p))
9164 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9165 (setq n (prefix-numeric-value n))
9166 (let ((backward (< n 0))
9171 (gnus-summary-remove-process-mark
9172 (gnus-summary-article-number))
9173 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9174 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9177 (gnus-message 7 "No more articles"))
9178 (gnus-summary-recenter)
9179 (gnus-summary-position-point)
9182 (defun gnus-summary-unmark-as-processable (n)
9183 "Remove the process mark from the next N articles.
9184 If N is negative, unmark backward instead. The difference between N and
9185 the actual number of articles unmarked is returned."
9187 (gnus-summary-mark-as-processable n t))
9189 (defun gnus-summary-unmark-all-processable ()
9190 "Remove the process mark from all articles."
9193 (while gnus-newsgroup-processable
9194 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9195 (gnus-summary-position-point))
9197 (defun gnus-summary-add-mark (article type)
9198 "Mark ARTICLE with a mark of TYPE."
9199 (let ((vtype (car (assq type gnus-article-mark-lists)))
9202 (error "No such mark type: %s" type)
9203 (setq var (intern (format "gnus-newsgroup-%s" type)))
9204 (set var (cons article (symbol-value var)))
9205 (if (memq type '(processable cached replied forwarded recent saved))
9206 (gnus-summary-update-secondary-mark article)
9207 ;;; !!! This is bogus. We should find out what primary
9208 ;;; !!! mark we want to set.
9209 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9211 (defun gnus-summary-mark-as-expirable (n)
9212 "Mark N articles forward as expirable.
9213 If N is negative, mark backward instead. The difference between N and
9214 the actual number of articles marked is returned."
9216 (gnus-summary-mark-forward n gnus-expirable-mark))
9218 (defun gnus-summary-mark-as-spam (n)
9219 "Mark N articles forward as spam.
9220 If N is negative, mark backward instead. The difference between N and
9221 the actual number of articles marked is returned."
9223 (gnus-summary-mark-forward n gnus-spam-mark))
9225 (defun gnus-summary-mark-article-as-replied (article)
9226 "Mark ARTICLE as replied to and update the summary line.
9227 ARTICLE can also be a list of articles."
9228 (interactive (list (gnus-summary-article-number)))
9229 (let ((articles (if (listp article) article (list article))))
9230 (dolist (article articles)
9231 (push article gnus-newsgroup-replied)
9232 (let ((buffer-read-only nil))
9233 (when (gnus-summary-goto-subject article nil t)
9234 (gnus-summary-update-secondary-mark article))))))
9236 (defun gnus-summary-mark-article-as-forwarded (article)
9237 "Mark ARTICLE as forwarded and update the summary line.
9238 ARTICLE can also be a list of articles."
9239 (let ((articles (if (listp article) article (list article))))
9240 (dolist (article articles)
9241 (push article gnus-newsgroup-forwarded)
9242 (let ((buffer-read-only nil))
9243 (when (gnus-summary-goto-subject article nil t)
9244 (gnus-summary-update-secondary-mark article))))))
9246 (defun gnus-summary-set-bookmark (article)
9247 "Set a bookmark in current article."
9248 (interactive (list (gnus-summary-article-number)))
9249 (when (or (not (get-buffer gnus-article-buffer))
9250 (not gnus-current-article)
9251 (not gnus-article-current)
9252 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9253 (error "No current article selected"))
9254 ;; Remove old bookmark, if one exists.
9255 (let ((old (assq article gnus-newsgroup-bookmarks)))
9257 (setq gnus-newsgroup-bookmarks
9258 (delq old gnus-newsgroup-bookmarks))))
9259 ;; Set the new bookmark, which is on the form
9260 ;; (article-number . line-number-in-body).
9264 (set-buffer gnus-article-buffer)
9268 (goto-char (point-min))
9269 (search-forward "\n\n" nil t)
9272 gnus-newsgroup-bookmarks)
9273 (gnus-message 6 "A bookmark has been added to the current article."))
9275 (defun gnus-summary-remove-bookmark (article)
9276 "Remove the bookmark from the current article."
9277 (interactive (list (gnus-summary-article-number)))
9278 ;; Remove old bookmark, if one exists.
9279 (let ((old (assq article gnus-newsgroup-bookmarks)))
9282 (setq gnus-newsgroup-bookmarks
9283 (delq old gnus-newsgroup-bookmarks))
9284 (gnus-message 6 "Removed bookmark."))
9285 (gnus-message 6 "No bookmark in current article."))))
9287 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9288 (defun gnus-summary-mark-as-dormant (n)
9289 "Mark N articles forward as dormant.
9290 If N is negative, mark backward instead. The difference between N and
9291 the actual number of articles marked is returned."
9293 (gnus-summary-mark-forward n gnus-dormant-mark))
9295 (defun gnus-summary-set-process-mark (article)
9296 "Set the process mark on ARTICLE and update the summary line."
9297 (setq gnus-newsgroup-processable
9299 (delq article gnus-newsgroup-processable)))
9300 (when (gnus-summary-goto-subject article)
9301 (gnus-summary-show-thread)
9302 (gnus-summary-goto-subject article)
9303 (gnus-summary-update-secondary-mark article)))
9305 (defun gnus-summary-remove-process-mark (article)
9306 "Remove the process mark from ARTICLE and update the summary line."
9307 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9308 (when (gnus-summary-goto-subject article)
9309 (gnus-summary-show-thread)
9310 (gnus-summary-goto-subject article)
9311 (gnus-summary-update-secondary-mark article)))
9313 (defun gnus-summary-set-saved-mark (article)
9314 "Set the process mark on ARTICLE and update the summary line."
9315 (push article gnus-newsgroup-saved)
9316 (when (gnus-summary-goto-subject article)
9317 (gnus-summary-update-secondary-mark article)))
9319 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9320 "Mark N articles as read forwards.
9321 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9322 The difference between N and the actual number of articles marked is
9324 Iff NO-EXPIRE, auto-expiry will be inhibited."
9326 (gnus-summary-show-thread)
9327 (let ((backward (< n 0))
9328 (gnus-summary-goto-unread
9329 (and gnus-summary-goto-unread
9330 (not (eq gnus-summary-goto-unread 'never))
9331 (not (memq mark (list gnus-unread-mark
9332 gnus-ticked-mark gnus-dormant-mark)))))
9334 (mark (or mark gnus-del-mark)))
9336 (gnus-summary-mark-article nil mark no-expire)
9337 (zerop (gnus-summary-next-subject
9339 (and gnus-summary-goto-unread
9340 (not (eq gnus-summary-goto-unread 'never)))
9344 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9345 (gnus-summary-recenter)
9346 (gnus-summary-position-point)
9347 (gnus-set-mode-line 'summary)
9350 (defun gnus-summary-mark-article-as-read (mark)
9351 "Mark the current article quickly as read with MARK."
9352 (let ((article (gnus-summary-article-number)))
9353 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9354 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9355 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9356 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9357 (push (cons article mark) gnus-newsgroup-reads)
9358 ;; Possibly remove from cache, if that is used.
9359 (when gnus-use-cache
9360 (gnus-cache-enter-remove-article article))
9361 ;; Allow the backend to change the mark.
9362 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9363 ;; Check for auto-expiry.
9364 (when (and gnus-newsgroup-auto-expire
9365 (memq mark gnus-auto-expirable-marks))
9366 (setq mark gnus-expirable-mark)
9367 ;; Let the backend know about the mark change.
9368 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9369 (push article gnus-newsgroup-expirable))
9370 ;; Set the mark in the buffer.
9371 (gnus-summary-update-mark mark 'unread)
9374 (defun gnus-summary-mark-article-as-unread (mark)
9375 "Mark the current article quickly as unread with MARK."
9376 (let* ((article (gnus-summary-article-number))
9377 (old-mark (gnus-summary-article-mark article)))
9378 ;; Allow the backend to change the mark.
9379 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9380 (if (eq mark old-mark)
9384 (gnus-error 1 "Can't mark negative article numbers")
9386 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9387 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9388 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9389 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9390 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9391 (cond ((= mark gnus-ticked-mark)
9392 (setq gnus-newsgroup-marked
9393 (gnus-add-to-sorted-list gnus-newsgroup-marked
9395 ((= mark gnus-spam-mark)
9396 (setq gnus-newsgroup-spam-marked
9397 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9399 ((= mark gnus-dormant-mark)
9400 (setq gnus-newsgroup-dormant
9401 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9404 (setq gnus-newsgroup-unreads
9405 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9407 (gnus-pull article gnus-newsgroup-reads)
9409 ;; See whether the article is to be put in the cache.
9411 (vectorp (gnus-summary-article-header article))
9413 (gnus-cache-possibly-enter-article
9414 gnus-newsgroup-name article
9415 (= mark gnus-ticked-mark)
9416 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9419 (gnus-summary-update-mark mark 'unread)
9422 (defun gnus-summary-mark-article (&optional article mark no-expire)
9423 "Mark ARTICLE with MARK. MARK can be any character.
9424 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9425 `??' (dormant) and `?E' (expirable).
9426 If MARK is nil, then the default character `?r' is used.
9427 If ARTICLE is nil, then the article on the current line will be
9429 Iff NO-EXPIRE, auto-expiry will be inhibited."
9430 ;; The mark might be a string.
9431 (when (stringp mark)
9432 (setq mark (aref mark 0)))
9433 ;; If no mark is given, then we check auto-expiring.
9435 (setq mark gnus-del-mark))
9436 (when (and (not no-expire)
9437 gnus-newsgroup-auto-expire
9438 (memq mark gnus-auto-expirable-marks))
9439 (setq mark gnus-expirable-mark))
9440 (let ((article (or article (gnus-summary-article-number)))
9441 (old-mark (gnus-summary-article-mark article)))
9442 ;; Allow the backend to change the mark.
9443 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9444 (if (eq mark old-mark)
9447 (error "No article on current line"))
9448 (if (not (if (or (= mark gnus-unread-mark)
9449 (= mark gnus-ticked-mark)
9450 (= mark gnus-spam-mark)
9451 (= mark gnus-dormant-mark))
9452 (gnus-mark-article-as-unread article mark)
9453 (gnus-mark-article-as-read article mark)))
9455 ;; See whether the article is to be put in the cache.
9457 (not (= mark gnus-canceled-mark))
9458 (vectorp (gnus-summary-article-header article))
9460 (gnus-cache-possibly-enter-article
9461 gnus-newsgroup-name article
9462 (= mark gnus-ticked-mark)
9463 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9465 (when (gnus-summary-goto-subject article nil t)
9466 (let ((buffer-read-only nil))
9467 (gnus-summary-show-thread)
9469 (gnus-summary-update-mark mark 'unread)
9472 (defun gnus-summary-update-secondary-mark (article)
9473 "Update the secondary (read, process, cache) mark."
9474 (gnus-summary-update-mark
9475 (cond ((memq article gnus-newsgroup-processable)
9477 ((memq article gnus-newsgroup-cached)
9479 ((memq article gnus-newsgroup-replied)
9481 ((memq article gnus-newsgroup-forwarded)
9482 gnus-forwarded-mark)
9483 ((memq article gnus-newsgroup-saved)
9485 ((memq article gnus-newsgroup-recent)
9487 ((memq article gnus-newsgroup-unseen)
9491 (when (gnus-visual-p 'summary-highlight 'highlight)
9492 (gnus-run-hooks 'gnus-summary-update-hook))
9495 (defun gnus-summary-update-mark (mark type)
9496 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9497 (buffer-read-only nil))
9498 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9500 (when (looking-at "\r")
9502 (when (<= (+ forward (point)) (point-max))
9503 ;; Go to the right position on the line.
9504 (goto-char (+ forward (point)))
9505 ;; Replace the old mark with the new mark.
9506 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9507 ;; Optionally update the marks by some user rule.
9508 (when (eq type 'unread)
9510 (gnus-data-find (gnus-summary-article-number)) mark)
9511 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9513 (defun gnus-mark-article-as-read (article &optional mark)
9514 "Enter ARTICLE in the pertinent lists and remove it from others."
9515 ;; Make the article expirable.
9516 (let ((mark (or mark gnus-del-mark)))
9517 (setq gnus-newsgroup-expirable
9518 (if (= mark gnus-expirable-mark)
9519 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9520 (delq article gnus-newsgroup-expirable)))
9521 ;; Remove from unread and marked lists.
9522 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9523 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9524 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9525 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9526 (push (cons article mark) gnus-newsgroup-reads)
9527 ;; Possibly remove from cache, if that is used.
9528 (when gnus-use-cache
9529 (gnus-cache-enter-remove-article article))
9532 (defun gnus-mark-article-as-unread (article &optional mark)
9533 "Enter ARTICLE in the pertinent lists and remove it from others."
9534 (let ((mark (or mark gnus-ticked-mark)))
9537 (gnus-error 1 "Can't mark negative article numbers")
9539 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9540 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9541 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9542 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9543 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9545 ;; Unsuppress duplicates?
9546 (when gnus-suppress-duplicates
9547 (gnus-dup-unsuppress-article article))
9549 (cond ((= mark gnus-ticked-mark)
9550 (setq gnus-newsgroup-marked
9551 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9552 ((= mark gnus-spam-mark)
9553 (setq gnus-newsgroup-spam-marked
9554 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked article)))
9555 ((= mark gnus-dormant-mark)
9556 (setq gnus-newsgroup-dormant
9557 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9559 (setq gnus-newsgroup-unreads
9560 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9561 (gnus-pull article gnus-newsgroup-reads)
9564 (defalias 'gnus-summary-mark-as-unread-forward
9565 'gnus-summary-tick-article-forward)
9566 (make-obsolete 'gnus-summary-mark-as-unread-forward
9567 'gnus-summary-tick-article-forward)
9568 (defun gnus-summary-tick-article-forward (n)
9569 "Tick N articles forwards.
9570 If N is negative, tick backwards instead.
9571 The difference between N and the number of articles ticked is returned."
9573 (gnus-summary-mark-forward n gnus-ticked-mark))
9575 (defalias 'gnus-summary-mark-as-unread-backward
9576 'gnus-summary-tick-article-backward)
9577 (make-obsolete 'gnus-summary-mark-as-unread-backward
9578 'gnus-summary-tick-article-backward)
9579 (defun gnus-summary-tick-article-backward (n)
9580 "Tick N articles backwards.
9581 The difference between N and the number of articles ticked is returned."
9583 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9585 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9586 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9587 (defun gnus-summary-tick-article (&optional article clear-mark)
9588 "Mark current article as unread.
9589 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9590 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9592 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9595 (defun gnus-summary-mark-as-read-forward (n)
9596 "Mark N articles as read forwards.
9597 If N is negative, mark backwards instead.
9598 The difference between N and the actual number of articles marked is
9601 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9603 (defun gnus-summary-mark-as-read-backward (n)
9604 "Mark the N articles as read backwards.
9605 The difference between N and the actual number of articles marked is
9608 (gnus-summary-mark-forward
9609 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9611 (defun gnus-summary-mark-as-read (&optional article mark)
9612 "Mark current article as read.
9613 ARTICLE specifies the article to be marked as read.
9614 MARK specifies a string to be inserted at the beginning of the line."
9615 (gnus-summary-mark-article article mark))
9617 (defun gnus-summary-clear-mark-forward (n)
9618 "Clear marks from N articles forward.
9619 If N is negative, clear backward instead.
9620 The difference between N and the number of marks cleared is returned."
9622 (gnus-summary-mark-forward n gnus-unread-mark))
9624 (defun gnus-summary-clear-mark-backward (n)
9625 "Clear marks from N articles backward.
9626 The difference between N and the number of marks cleared is returned."
9628 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9630 (defun gnus-summary-mark-unread-as-read ()
9631 "Intended to be used by `gnus-summary-mark-article-hook'."
9632 (when (memq gnus-current-article gnus-newsgroup-unreads)
9633 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9635 (defun gnus-summary-mark-read-and-unread-as-read ()
9636 "Intended to be used by `gnus-summary-mark-article-hook'."
9637 (let ((mark (gnus-summary-article-mark)))
9638 (when (or (gnus-unread-mark-p mark)
9639 (gnus-read-mark-p mark))
9640 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9642 (defun gnus-summary-mark-unread-as-ticked ()
9643 "Intended to be used by `gnus-summary-mark-article-hook'."
9644 (when (memq gnus-current-article gnus-newsgroup-unreads)
9645 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9647 (defun gnus-summary-mark-region-as-read (point mark all)
9648 "Mark all unread articles between point and mark as read.
9649 If given a prefix, mark all articles between point and mark as read,
9650 even ticked and dormant ones."
9651 (interactive "r\nP")
9660 (memq (setq article (gnus-summary-article-number))
9661 gnus-newsgroup-unreads))
9662 (gnus-summary-mark-article article gnus-del-mark))
9664 (gnus-summary-find-next))))))
9666 (defun gnus-summary-mark-below (score mark)
9667 "Mark articles with score less than SCORE with MARK."
9668 (interactive "P\ncMark: ")
9669 (setq score (if score
9670 (prefix-numeric-value score)
9671 (or gnus-summary-default-score 0)))
9673 (set-buffer gnus-summary-buffer)
9674 (goto-char (point-min))
9677 (and (< (gnus-summary-article-score) score)
9678 (gnus-summary-mark-article nil mark))
9679 (gnus-summary-find-next)))))
9681 (defun gnus-summary-kill-below (&optional score)
9682 "Mark articles with score below SCORE as read."
9684 (gnus-summary-mark-below score gnus-killed-mark))
9686 (defun gnus-summary-clear-above (&optional score)
9687 "Clear all marks from articles with score above SCORE."
9689 (gnus-summary-mark-above score gnus-unread-mark))
9691 (defun gnus-summary-tick-above (&optional score)
9692 "Tick all articles with score above SCORE."
9694 (gnus-summary-mark-above score gnus-ticked-mark))
9696 (defun gnus-summary-mark-above (score mark)
9697 "Mark articles with score over SCORE with MARK."
9698 (interactive "P\ncMark: ")
9699 (setq score (if score
9700 (prefix-numeric-value score)
9701 (or gnus-summary-default-score 0)))
9703 (set-buffer gnus-summary-buffer)
9704 (goto-char (point-min))
9706 (when (> (gnus-summary-article-score) score)
9707 (gnus-summary-mark-article nil mark))
9709 (gnus-summary-find-next)))))
9711 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9712 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9713 (defun gnus-summary-limit-include-expunged (&optional no-error)
9714 "Display all the hidden articles that were expunged for low scores."
9716 (let ((buffer-read-only nil))
9717 (let ((scored gnus-newsgroup-scored)
9720 (unless (gnus-summary-article-header (caar scored))
9721 (and (setq h (gnus-number-to-header (caar scored)))
9722 (< (cdar scored) gnus-summary-expunge-below)
9724 (setq scored (cdr scored)))
9726 (when (not no-error)
9727 (error "No expunged articles hidden"))
9728 (goto-char (point-min))
9729 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9730 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9731 (mapcar (lambda (x) (push (mail-header-number x)
9732 gnus-newsgroup-limit))
9734 (gnus-summary-prepare-unthreaded (nreverse headers))
9735 (goto-char (point-min))
9736 (gnus-summary-position-point)
9739 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9740 "Mark all unread articles in this newsgroup as read.
9741 If prefix argument ALL is non-nil, ticked and dormant articles will
9742 also be marked as read.
9743 If QUIETLY is non-nil, no questions will be asked.
9744 If TO-HERE is non-nil, it should be a point in the buffer. All
9745 articles before (after, if REVERSE is set) this point will be marked as read.
9746 Note that this function will only catch up the unread article
9747 in the current summary buffer limitation.
9748 The number of articles marked as read is returned."
9753 (not gnus-interactive-catchup) ;Without confirmation?
9757 "Mark absolutely all articles as read? "
9758 "Mark all unread articles as read? ")))
9760 (not gnus-newsgroup-adaptive)
9761 (not gnus-newsgroup-auto-expire)
9762 (not gnus-suppress-duplicates)
9763 (or (not gnus-use-cache)
9764 (eq gnus-use-cache 'passive)))
9767 (setq gnus-newsgroup-marked nil
9768 gnus-newsgroup-spam-marked nil
9769 gnus-newsgroup-dormant nil))
9770 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9771 ;; We actually mark all articles as canceled, which we
9772 ;; have to do when using auto-expiry or adaptive scoring.
9773 (gnus-summary-show-all-threads)
9774 (if (and to-here reverse)
9778 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9779 (gnus-summary-find-next (not all) nil nil t))))
9780 (when (gnus-summary-first-subject (not all) t)
9782 (if to-here (< (point) to-here) t)
9783 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9784 (gnus-summary-find-next (not all) nil nil t)))))
9785 (gnus-set-mode-line 'summary))
9787 (gnus-summary-position-point)))
9789 (defun gnus-summary-catchup-to-here (&optional all)
9790 "Mark all unticked articles before the current one as read.
9791 If ALL is non-nil, also mark ticked and dormant articles as read."
9794 (gnus-save-hidden-threads
9795 (let ((beg (point)))
9796 ;; We check that there are unread articles.
9797 (when (or all (gnus-summary-find-prev))
9798 (gnus-summary-catchup all t beg)))))
9799 (gnus-summary-position-point))
9801 (defun gnus-summary-catchup-from-here (&optional all)
9802 "Mark all unticked articles after the current one as read.
9803 If ALL is non-nil, also mark ticked and dormant articles as read."
9806 (gnus-save-hidden-threads
9807 (let ((beg (point)))
9808 ;; We check that there are unread articles.
9809 (when (or all (gnus-summary-find-next))
9810 (gnus-summary-catchup all t beg nil t)))))
9812 (gnus-summary-position-point))
9813 (defun gnus-summary-catchup-all (&optional quietly)
9814 "Mark all articles in this newsgroup as read."
9816 (gnus-summary-catchup t quietly))
9818 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9819 "Mark all unread articles in this group as read, then exit.
9820 If prefix argument ALL is non-nil, all articles are marked as read.
9821 If QUIETLY is non-nil, no questions will be asked."
9823 (when (gnus-summary-catchup all quietly nil 'fast)
9824 ;; Select next newsgroup or exit.
9825 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9826 (eq gnus-auto-select-next 'quietly))
9827 (gnus-summary-next-group nil)
9828 (gnus-summary-exit))))
9830 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9831 "Mark all articles in this newsgroup as read, and then exit."
9833 (gnus-summary-catchup-and-exit t quietly))
9835 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9836 "Mark all articles in this group as read and select the next group.
9837 If given a prefix, mark all articles, unread as well as ticked, as
9841 (gnus-summary-catchup all))
9842 (gnus-summary-next-group))
9848 (defmacro gnus-with-article (article &rest forms)
9849 "Select ARTICLE and perform FORMS in the original article buffer.
9850 Then replace the article with the result."
9852 ;; We don't want the article to be marked as read.
9853 (let (gnus-mark-article-hook)
9854 (gnus-summary-select-article t t nil ,article))
9855 (set-buffer gnus-original-article-buffer)
9857 (if (not (gnus-check-backend-function
9858 'request-replace-article (car gnus-article-current)))
9859 (gnus-message 5 "Read-only group; not replacing")
9860 (unless (gnus-request-replace-article
9861 ,article (car gnus-article-current)
9863 (error "Couldn't replace article")))
9864 ;; The cache and backlog have to be flushed somewhat.
9865 (when gnus-keep-backlog
9866 (gnus-backlog-remove-article
9867 (car gnus-article-current) (cdr gnus-article-current)))
9868 (when gnus-use-cache
9869 (gnus-cache-update-article
9870 (car gnus-article-current) (cdr gnus-article-current)))))
9872 (put 'gnus-with-article 'lisp-indent-function 1)
9873 (put 'gnus-with-article 'edebug-form-spec '(form body))
9875 ;; Thread-based commands.
9877 (defun gnus-summary-articles-in-thread (&optional article)
9878 "Return a list of all articles in the current thread.
9879 If ARTICLE is non-nil, return all articles in the thread that starts
9881 (let* ((article (or article (gnus-summary-article-number)))
9882 (data (gnus-data-find-list article))
9883 (top-level (gnus-data-level (car data)))
9885 (cond ((null gnus-thread-operation-ignore-subject)
9886 (gnus-simplify-subject-re
9887 (mail-header-subject (gnus-data-header (car data)))))
9888 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9889 (gnus-simplify-subject-fuzzy
9890 (mail-header-subject (gnus-data-header (car data)))))
9892 (end-point (save-excursion
9893 (if (gnus-summary-go-to-next-thread)
9894 (point) (point-max))))
9897 (< (gnus-data-pos (car data)) end-point))
9898 (when (or (not top-subject)
9899 (string= top-subject
9900 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9901 (gnus-simplify-subject-fuzzy
9902 (mail-header-subject
9903 (gnus-data-header (car data))))
9904 (gnus-simplify-subject-re
9905 (mail-header-subject
9906 (gnus-data-header (car data)))))))
9907 (push (gnus-data-number (car data)) articles))
9908 (unless (and (setq data (cdr data))
9909 (> (gnus-data-level (car data)) top-level))
9911 ;; Return the list of articles.
9912 (nreverse articles)))
9914 (defun gnus-summary-rethread-current ()
9915 "Rethread the thread the current article is part of."
9917 (let* ((gnus-show-threads t)
9918 (article (gnus-summary-article-number))
9919 (id (mail-header-id (gnus-summary-article-header)))
9920 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9922 (error "No article on the current line"))
9923 (gnus-rebuild-thread id)
9924 (gnus-summary-goto-subject article)))
9926 (defun gnus-summary-reparent-thread ()
9927 "Make the current article child of the marked (or previous) article.
9929 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9930 is non-nil or the Subject: of both articles are the same."
9932 (unless (not (gnus-group-read-only-p))
9933 (error "The current newsgroup does not support article editing"))
9934 (unless (<= (length gnus-newsgroup-processable) 1)
9935 (error "No more than one article may be marked"))
9936 (save-window-excursion
9937 (let ((gnus-article-buffer " *reparent*")
9938 (current-article (gnus-summary-article-number))
9939 ;; First grab the marked article, otherwise one line up.
9940 (parent-article (if (not (null gnus-newsgroup-processable))
9941 (car gnus-newsgroup-processable)
9943 (if (eq (forward-line -1) 0)
9944 (gnus-summary-article-number)
9945 (error "Beginning of summary buffer"))))))
9946 (unless (not (eq current-article parent-article))
9947 (error "An article may not be self-referential"))
9948 (let ((message-id (mail-header-id
9949 (gnus-summary-article-header parent-article))))
9950 (unless (and message-id (not (equal message-id "")))
9951 (error "No message-id in desired parent"))
9952 (gnus-with-article current-article
9954 (goto-char (point-min))
9955 (message-narrow-to-head)
9956 (if (re-search-forward "^References: " nil t)
9958 (re-search-forward "^[^ \t]" nil t)
9961 (insert " " message-id))
9962 (insert "References: " message-id "\n"))))
9963 (set-buffer gnus-summary-buffer)
9964 (gnus-summary-unmark-all-processable)
9965 (gnus-summary-update-article current-article)
9966 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9967 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9968 (gnus-summary-rethread-current)
9969 (gnus-message 3 "Article %d is now the child of article %d"
9970 current-article parent-article)))))
9972 (defun gnus-summary-toggle-threads (&optional arg)
9973 "Toggle showing conversation threads.
9974 If ARG is positive number, turn showing conversation threads on."
9976 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9977 (setq gnus-show-threads
9978 (if (null arg) (not gnus-show-threads)
9979 (> (prefix-numeric-value arg) 0)))
9980 (gnus-summary-prepare)
9981 (gnus-summary-goto-subject current)
9982 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9983 (gnus-summary-position-point)))
9985 (defun gnus-summary-show-all-threads ()
9989 (let ((buffer-read-only nil))
9990 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9991 (gnus-summary-position-point))
9993 (defun gnus-summary-show-thread ()
9994 "Show thread subtrees.
9995 Returns nil if no thread was there to be shown."
9997 (let ((buffer-read-only nil)
9999 ;; first goto end then to beg, to have point at beg after let
10000 (end (progn (end-of-line) (point)))
10001 (beg (progn (beginning-of-line) (point))))
10003 ;; Any hidden lines here?
10004 (search-forward "\r" end t)
10005 (subst-char-in-region beg end ?\^M ?\n t)
10007 (gnus-summary-position-point))))
10009 (defun gnus-summary-maybe-hide-threads ()
10010 "If requested, hide the threads that should be hidden."
10011 (when (and gnus-show-threads
10012 gnus-thread-hide-subtree)
10013 (gnus-summary-hide-all-threads
10014 (if (or (consp gnus-thread-hide-subtree)
10015 (gnus-functionp gnus-thread-hide-subtree))
10016 (gnus-make-predicate gnus-thread-hide-subtree)
10019 ;;; Hiding predicates.
10021 (defun gnus-article-unread-p (header)
10022 (memq (mail-header-number header) gnus-newsgroup-unreads))
10024 (defun gnus-article-unseen-p (header)
10025 (memq (mail-header-number header) gnus-newsgroup-unseen))
10027 (defun gnus-map-articles (predicate articles)
10028 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10029 (apply 'gnus-or (mapcar predicate
10030 (mapcar 'gnus-summary-article-header articles))))
10032 (defun gnus-summary-hide-all-threads (&optional predicate)
10033 "Hide all thread subtrees.
10034 If PREDICATE is supplied, threads that satisfy this predicate
10035 will not be hidden."
10038 (goto-char (point-min))
10041 (when (or (not predicate)
10043 predicate (gnus-summary-article-children)))
10044 (gnus-summary-hide-thread))
10045 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10046 (gnus-summary-position-point))
10048 (defun gnus-summary-hide-thread ()
10049 "Hide thread subtrees.
10050 If PREDICATE is supplied, threads that satisfy this predicate
10051 will not be hidden.
10052 Returns nil if no threads were there to be hidden."
10054 (let ((buffer-read-only nil)
10056 (article (gnus-summary-article-number)))
10058 ;; Go forward until either the buffer ends or the subthread
10060 (when (and (not (eobp))
10061 (or (zerop (gnus-summary-next-thread 1 t))
10062 (goto-char (point-max))))
10064 (if (and (> (point) start)
10065 (search-backward "\n" start t))
10067 (subst-char-in-region start (point) ?\n ?\^M)
10068 (gnus-summary-goto-subject article))
10072 (defun gnus-summary-go-to-next-thread (&optional previous)
10073 "Go to the same level (or less) next thread.
10074 If PREVIOUS is non-nil, go to previous thread instead.
10075 Return the article number moved to, or nil if moving was impossible."
10076 (let ((level (gnus-summary-thread-level))
10077 (way (if previous -1 1))
10080 (while (and (not (eobp))
10081 (< level (gnus-summary-thread-level)))
10082 (forward-line way))
10089 (gnus-summary-article-number)
10090 (goto-char beg)))))
10092 (defun gnus-summary-next-thread (n &optional silent)
10093 "Go to the same level next N'th thread.
10094 If N is negative, search backward instead.
10095 Returns the difference between N and the number of skips actually
10098 If SILENT, don't output messages."
10100 (let ((backward (< n 0))
10102 (while (and (> n 0)
10103 (gnus-summary-go-to-next-thread backward))
10106 (gnus-summary-position-point))
10107 (when (and (not silent) (/= 0 n))
10108 (gnus-message 7 "No more threads"))
10111 (defun gnus-summary-prev-thread (n)
10112 "Go to the same level previous N'th thread.
10113 Returns the difference between N and the number of skips actually
10116 (gnus-summary-next-thread (- n)))
10118 (defun gnus-summary-go-down-thread ()
10119 "Go down one level in the current thread."
10120 (let ((children (gnus-summary-article-children)))
10122 (gnus-summary-goto-subject (car children)))))
10124 (defun gnus-summary-go-up-thread ()
10125 "Go up one level in the current thread."
10126 (let ((parent (gnus-summary-article-parent)))
10128 (gnus-summary-goto-subject parent))))
10130 (defun gnus-summary-down-thread (n)
10131 "Go down thread N steps.
10132 If N is negative, go up instead.
10133 Returns the difference between N and how many steps down that were
10138 (while (and (> n 0)
10139 (if up (gnus-summary-go-up-thread)
10140 (gnus-summary-go-down-thread)))
10142 (gnus-summary-position-point)
10144 (gnus-message 7 "Can't go further"))
10147 (defun gnus-summary-up-thread (n)
10148 "Go up thread N steps.
10149 If N is negative, go down instead.
10150 Returns the difference between N and how many steps down that were
10153 (gnus-summary-down-thread (- n)))
10155 (defun gnus-summary-top-thread ()
10156 "Go to the top of the thread."
10158 (while (gnus-summary-go-up-thread))
10159 (gnus-summary-article-number))
10161 (defun gnus-summary-kill-thread (&optional unmark)
10162 "Mark articles under current thread as read.
10163 If the prefix argument is positive, remove any kinds of marks.
10164 If the prefix argument is negative, tick articles instead."
10167 (setq unmark (prefix-numeric-value unmark)))
10168 (let ((articles (gnus-summary-articles-in-thread)))
10170 ;; Expand the thread.
10171 (gnus-summary-show-thread)
10172 ;; Mark all the articles.
10174 (gnus-summary-goto-subject (car articles))
10175 (cond ((null unmark)
10176 (gnus-summary-mark-article-as-read gnus-killed-mark))
10178 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10180 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10181 (setq articles (cdr articles))))
10182 ;; Hide killed subtrees.
10184 gnus-thread-hide-killed
10185 (gnus-summary-hide-thread))
10186 ;; If marked as read, go to next unread subject.
10187 (when (null unmark)
10188 ;; Go to next unread subject.
10189 (gnus-summary-next-subject 1 t)))
10190 (gnus-set-mode-line 'summary))
10192 ;; Summary sorting commands
10194 (defun gnus-summary-sort-by-number (&optional reverse)
10195 "Sort the summary buffer by article number.
10196 Argument REVERSE means reverse order."
10198 (gnus-summary-sort 'number reverse))
10200 (defun gnus-summary-sort-by-random (&optional reverse)
10201 "Randomize the order in the summary buffer.
10202 Argument REVERSE means to randomize in reverse order."
10204 (gnus-summary-sort 'random reverse))
10206 (defun gnus-summary-sort-by-author (&optional reverse)
10207 "Sort the summary buffer by author name alphabetically.
10208 If `case-fold-search' is non-nil, case of letters is ignored.
10209 Argument REVERSE means reverse order."
10211 (gnus-summary-sort 'author reverse))
10213 (defun gnus-summary-sort-by-subject (&optional reverse)
10214 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10215 If `case-fold-search' is non-nil, case of letters is ignored.
10216 Argument REVERSE means reverse order."
10218 (gnus-summary-sort 'subject reverse))
10220 (defun gnus-summary-sort-by-date (&optional reverse)
10221 "Sort the summary buffer by date.
10222 Argument REVERSE means reverse order."
10224 (gnus-summary-sort 'date reverse))
10226 (defun gnus-summary-sort-by-score (&optional reverse)
10227 "Sort the summary buffer by score.
10228 Argument REVERSE means reverse order."
10230 (gnus-summary-sort 'score reverse))
10232 (defun gnus-summary-sort-by-lines (&optional reverse)
10233 "Sort the summary buffer by the number of lines.
10234 Argument REVERSE means reverse order."
10236 (gnus-summary-sort 'lines reverse))
10238 (defun gnus-summary-sort-by-chars (&optional reverse)
10239 "Sort the summary buffer by article length.
10240 Argument REVERSE means reverse order."
10242 (gnus-summary-sort 'chars reverse))
10244 (defun gnus-summary-sort-by-original (&optional reverse)
10245 "Sort the summary buffer using the default sorting method.
10246 Argument REVERSE means reverse order."
10248 (let* ((buffer-read-only)
10249 (gnus-summary-prepare-hook nil))
10250 ;; We do the sorting by regenerating the threads.
10251 (gnus-summary-prepare)
10252 ;; Hide subthreads if needed.
10253 (gnus-summary-maybe-hide-threads)))
10255 (defun gnus-summary-sort (predicate reverse)
10256 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10257 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10258 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10259 (gnus-thread-sort-functions
10264 (gnus-sort-gathered-threads-function
10265 gnus-thread-sort-functions)
10266 (gnus-article-sort-functions
10270 (,article t2 t1))))
10272 (gnus-summary-prepare-hook nil))
10273 ;; We do the sorting by regenerating the threads.
10274 (gnus-summary-prepare)
10275 ;; Hide subthreads if needed.
10276 (gnus-summary-maybe-hide-threads)))
10278 ;; Summary saving commands.
10280 (defun gnus-summary-save-article (&optional n not-saved)
10281 "Save the current article using the default saver function.
10282 If N is a positive number, save the N next articles.
10283 If N is a negative number, save the N previous articles.
10284 If N is nil and any articles have been marked with the process mark,
10285 save those articles instead.
10286 The variable `gnus-default-article-saver' specifies the saver function."
10288 (let* ((articles (gnus-summary-work-articles n))
10289 (save-buffer (save-excursion
10290 (nnheader-set-temp-buffer " *Gnus Save*")))
10291 (num (length articles))
10293 (dolist (article articles)
10294 (setq header (gnus-summary-article-header article))
10295 (if (not (vectorp header))
10296 ;; This is a pseudo-article.
10297 (if (assq 'name header)
10298 (gnus-copy-file (cdr (assq 'name header)))
10299 (gnus-message 1 "Article %d is unsaveable" article))
10300 ;; This is a real article.
10301 (save-window-excursion
10302 (let ((gnus-display-mime-function nil)
10303 (gnus-article-prepare-hook nil))
10304 (gnus-summary-select-article t nil nil article)))
10306 (set-buffer save-buffer)
10308 (insert-buffer-substring gnus-original-article-buffer))
10309 (setq file (gnus-article-save save-buffer file num))
10310 (gnus-summary-remove-process-mark article)
10312 (gnus-summary-set-saved-mark article))))
10313 (gnus-kill-buffer save-buffer)
10314 (gnus-summary-position-point)
10315 (gnus-set-mode-line 'summary)
10318 (defun gnus-summary-pipe-output (&optional arg)
10319 "Pipe the current article to a subprocess.
10320 If N is a positive number, pipe the N next articles.
10321 If N is a negative number, pipe the N previous articles.
10322 If N is nil and any articles have been marked with the process mark,
10323 pipe those articles instead."
10325 (require 'gnus-art)
10326 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10327 (gnus-summary-save-article arg t))
10328 (let ((buffer (get-buffer "*Shell Command Output*")))
10330 (with-current-buffer buffer (> (point-max) (point-min))))
10331 (gnus-configure-windows 'pipe))))
10333 (defun gnus-summary-save-article-mail (&optional arg)
10334 "Append the current article to an mail file.
10335 If N is a positive number, save the N next articles.
10336 If N is a negative number, save the N previous articles.
10337 If N is nil and any articles have been marked with the process mark,
10338 save those articles instead."
10340 (require 'gnus-art)
10341 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10342 (gnus-summary-save-article arg)))
10344 (defun gnus-summary-save-article-rmail (&optional arg)
10345 "Append the current article to an rmail file.
10346 If N is a positive number, save the N next articles.
10347 If N is a negative number, save the N previous articles.
10348 If N is nil and any articles have been marked with the process mark,
10349 save those articles instead."
10351 (require 'gnus-art)
10352 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10353 (gnus-summary-save-article arg)))
10355 (defun gnus-summary-save-article-file (&optional arg)
10356 "Append the current article to a file.
10357 If N is a positive number, save the N next articles.
10358 If N is a negative number, save the N previous articles.
10359 If N is nil and any articles have been marked with the process mark,
10360 save those articles instead."
10362 (require 'gnus-art)
10363 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10364 (gnus-summary-save-article arg)))
10366 (defun gnus-summary-write-article-file (&optional arg)
10367 "Write the current article to a file, deleting the previous file.
10368 If N is a positive number, save the N next articles.
10369 If N is a negative number, save the N previous articles.
10370 If N is nil and any articles have been marked with the process mark,
10371 save those articles instead."
10373 (require 'gnus-art)
10374 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10375 (gnus-summary-save-article arg)))
10377 (defun gnus-summary-save-article-body-file (&optional arg)
10378 "Append the current article body to a file.
10379 If N is a positive number, save the N next articles.
10380 If N is a negative number, save the N previous articles.
10381 If N is nil and any articles have been marked with the process mark,
10382 save those articles instead."
10384 (require 'gnus-art)
10385 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10386 (gnus-summary-save-article arg)))
10388 (defun gnus-summary-muttprint (&optional arg)
10389 "Print the current article using Muttprint.
10390 If N is a positive number, save the N next articles.
10391 If N is a negative number, save the N previous articles.
10392 If N is nil and any articles have been marked with the process mark,
10393 save those articles instead."
10395 (require 'gnus-art)
10396 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10397 (gnus-summary-save-article arg t)))
10399 (defun gnus-summary-pipe-message (program)
10400 "Pipe the current article through PROGRAM."
10401 (interactive "sProgram: ")
10402 (gnus-summary-select-article)
10403 (let ((mail-header-separator ""))
10404 (gnus-eval-in-buffer-window gnus-article-buffer
10407 (let ((start (window-start))
10409 (message-pipe-buffer-body program)
10410 (set-window-start (get-buffer-window (current-buffer)) start))))))
10412 (defun gnus-get-split-value (methods)
10413 "Return a value based on the split METHODS."
10414 (let (split-name method result match)
10417 (set-buffer gnus-original-article-buffer)
10419 (nnheader-narrow-to-headers)
10420 (while (and methods (not split-name))
10421 (goto-char (point-min))
10422 (setq method (pop methods))
10423 (setq match (car method))
10426 ;; Regular expression.
10428 (re-search-forward match nil t)))
10429 ((gnus-functionp match)
10433 (setq result (funcall match gnus-newsgroup-name))))
10438 (setq result (eval match)))))
10439 (setq split-name (cdr method))
10440 (cond ((stringp result)
10441 (push (expand-file-name
10442 result gnus-article-save-directory)
10445 (setq split-name (append result split-name)))))))))
10446 (nreverse split-name)))
10448 (defun gnus-valid-move-group-p (group)
10449 (and (boundp group)
10450 (symbol-name group)
10451 (symbol-value group)
10452 (gnus-get-function (gnus-find-method-for-group
10453 (symbol-name group)) 'request-accept-article t)))
10455 (defun gnus-read-move-group-name (prompt default articles prefix)
10456 "Read a group name."
10457 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10458 (minibuffer-confirm-incomplete nil) ; XEmacs
10460 (format "%s %s to:"
10462 (if (> (length articles) 1)
10463 (format "these %d articles" (length articles))
10468 (gnus-completing-read-with-default
10471 'gnus-valid-move-group-p
10473 'gnus-group-history))
10474 ((= 1 (length split-name))
10475 (gnus-completing-read-with-default
10476 (car split-name) prom
10478 'gnus-valid-move-group-p
10480 'gnus-group-history))
10482 (gnus-completing-read-with-default
10484 (mapcar (lambda (el) (list el))
10485 (nreverse split-name))
10487 'gnus-group-history))))
10488 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10490 (if (or (string= to-newsgroup "")
10491 (string= to-newsgroup prefix))
10492 (setq to-newsgroup default))
10493 (unless to-newsgroup
10494 (error "No group name entered"))
10495 (or (gnus-active to-newsgroup)
10496 (gnus-activate-group to-newsgroup nil nil to-method)
10497 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10499 (or (and (gnus-request-create-group to-newsgroup to-method)
10500 (gnus-activate-group
10501 to-newsgroup nil nil to-method)
10502 (gnus-subscribe-group to-newsgroup))
10503 (error "Couldn't create group %s" to-newsgroup)))
10504 (error "No such group: %s" to-newsgroup)))
10507 (defun gnus-summary-save-parts (type dir n &optional reverse)
10508 "Save parts matching TYPE to DIR.
10509 If REVERSE, save parts that do not match TYPE."
10511 (list (read-string "Save parts of type: "
10512 (or (car gnus-summary-save-parts-type-history)
10513 gnus-summary-save-parts-default-mime)
10514 'gnus-summary-save-parts-type-history)
10515 (setq gnus-summary-save-parts-last-directory
10516 (read-file-name "Save to directory: "
10517 gnus-summary-save-parts-last-directory
10519 current-prefix-arg))
10520 (gnus-summary-iterate n
10521 (let ((gnus-display-mime-function nil)
10522 (gnus-inhibit-treatment t))
10523 (gnus-summary-select-article))
10525 (set-buffer gnus-article-buffer)
10526 (let ((handles (or gnus-article-mime-handles
10527 (mm-dissect-buffer nil gnus-article-loose-mime)
10530 (gnus-summary-save-parts-1 type dir handles reverse)
10531 (unless gnus-article-mime-handles ;; Don't destroy this case.
10532 (mm-destroy-parts handles)))))))
10534 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10535 (if (stringp (car handle))
10536 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10539 (not (string-match type (mm-handle-media-type handle)))
10540 (string-match type (mm-handle-media-type handle)))
10541 (let ((file (expand-file-name
10542 (file-name-nondirectory
10544 (mail-content-type-get
10545 (mm-handle-disposition handle) 'filename)
10546 (concat gnus-newsgroup-name
10547 "." (number-to-string
10548 (cdr gnus-article-current)))))
10550 (unless (file-exists-p file)
10551 (mm-save-part-to-file handle file))))))
10553 ;; Summary extract commands
10555 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10556 (let ((buffer-read-only nil)
10557 (article (gnus-summary-article-number))
10559 (unless (gnus-summary-goto-subject article)
10560 (error "No such article: %d" article))
10561 (gnus-summary-position-point)
10562 ;; If all commands are to be bunched up on one line, we collect
10564 (unless gnus-view-pseudos-separately
10565 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10568 (setq action (cdr (assq 'action (car ps))))
10569 (setq files (list (cdr (assq 'name (car ps)))))
10570 (while (and ps (cdr ps)
10571 (string= (or action "1")
10572 (or (cdr (assq 'action (cadr ps))) "2")))
10573 (push (cdr (assq 'name (cadr ps))) files)
10574 (setcdr ps (cddr ps)))
10576 (when (not (string-match "%s" action))
10579 (when (assq 'execute (car ps))
10580 (setcdr (assq 'execute (car ps))
10581 (funcall (if (string-match "%s" action)
10590 (setq ps (cdr ps)))))
10591 (if (and gnus-view-pseudos (not not-view))
10593 (when (assq 'execute (car pslist))
10594 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10595 (eq gnus-view-pseudos 'not-confirm)))
10596 (setq pslist (cdr pslist)))
10599 (setq after-article (or (cdr (assq 'article (car pslist)))
10600 (gnus-summary-article-number)))
10601 (gnus-summary-goto-subject after-article)
10604 (insert " " (file-name-nondirectory
10605 (cdr (assq 'name (car pslist))))
10606 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10608 (forward-line -1) ; back to `b'
10609 (gnus-add-text-properties
10610 b (1- e) (list 'gnus-number gnus-reffed-article-number
10611 gnus-mouse-face-prop gnus-mouse-face))
10613 after-article gnus-reffed-article-number
10614 gnus-unread-mark b (car pslist) 0 (- e b))
10615 (setq gnus-newsgroup-unreads
10616 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10617 gnus-reffed-article-number))
10618 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10619 (setq pslist (cdr pslist)))))))
10621 (defun gnus-pseudos< (p1 p2)
10622 (let ((c1 (cdr (assq 'action p1)))
10623 (c2 (cdr (assq 'action p2))))
10624 (and c1 c2 (string< c1 c2))))
10626 (defun gnus-request-pseudo-article (props)
10627 (cond ((assq 'execute props)
10628 (gnus-execute-command (cdr (assq 'execute props)))))
10629 (let ((gnus-current-article (gnus-summary-article-number)))
10630 (gnus-run-hooks 'gnus-mark-article-hook)))
10632 (defun gnus-execute-command (command &optional automatic)
10634 (gnus-article-setup-buffer)
10635 (set-buffer gnus-article-buffer)
10636 (setq buffer-read-only nil)
10637 (let ((command (if automatic command
10638 (read-string "Command: " (cons command 0)))))
10640 (insert "$ " command "\n\n")
10641 (if gnus-view-pseudo-asynchronously
10642 (start-process "gnus-execute" (current-buffer) shell-file-name
10643 shell-command-switch command)
10644 (call-process shell-file-name nil t nil
10645 shell-command-switch command)))))
10647 ;; Summary kill commands.
10649 (defun gnus-summary-edit-global-kill (article)
10650 "Edit the \"global\" kill file."
10651 (interactive (list (gnus-summary-article-number)))
10652 (gnus-group-edit-global-kill article))
10654 (defun gnus-summary-edit-local-kill ()
10655 "Edit a local kill file applied to the current newsgroup."
10657 (setq gnus-current-headers (gnus-summary-article-header))
10658 (gnus-group-edit-local-kill
10659 (gnus-summary-article-number) gnus-newsgroup-name))
10661 ;;; Header reading.
10663 (defun gnus-read-header (id &optional header)
10664 "Read the headers of article ID and enter them into the Gnus system."
10665 (let ((group gnus-newsgroup-name)
10666 (gnus-override-method
10668 gnus-override-method
10669 (and (gnus-news-group-p gnus-newsgroup-name)
10670 (car (gnus-refer-article-methods)))))
10672 ;; First we check to see whether the header in question is already
10675 ;; This is a Message-ID.
10676 (setq header (or header (gnus-id-to-header id)))
10677 ;; This is an article number.
10678 (setq header (or header (gnus-summary-article-header id))))
10680 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10681 ;; We have found the header.
10683 ;; If this is a sparse article, we have to nix out its
10684 ;; previous entry in the thread hashtb.
10686 (gnus-summary-article-sparse-p (mail-header-number header)))
10687 (let* ((parent (gnus-parent-id (mail-header-references header)))
10688 (thread (and parent (gnus-id-to-thread parent))))
10690 (delq (assq header thread) thread))))
10691 ;; We have to really fetch the header to this article.
10693 (set-buffer nntp-server-buffer)
10694 (when (setq where (gnus-request-head id group))
10695 (nnheader-fold-continuation-lines)
10696 (goto-char (point-max))
10698 (goto-char (point-min))
10702 ((cdr where) (cdr where))
10703 (header (mail-header-number header))
10704 (t gnus-reffed-article-number))
10706 (insert " Article retrieved.\n"))
10707 (if (or (not where)
10708 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10709 () ; Malformed head.
10710 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10711 (when (and (stringp id)
10712 (not (string= (gnus-group-real-name group)
10714 ;; If we fetched by Message-ID and the article came
10715 ;; from a different group, we fudge some bogus article
10716 ;; numbers for this article.
10717 (mail-header-set-number header gnus-reffed-article-number))
10719 (set-buffer gnus-summary-buffer)
10720 (decf gnus-reffed-article-number)
10721 (gnus-remove-header (mail-header-number header))
10722 (push header gnus-newsgroup-headers)
10723 (setq gnus-current-headers header)
10724 (push (mail-header-number header) gnus-newsgroup-limit)))
10727 (defun gnus-remove-header (number)
10728 "Remove header NUMBER from `gnus-newsgroup-headers'."
10729 (if (and gnus-newsgroup-headers
10730 (= number (mail-header-number (car gnus-newsgroup-headers))))
10731 (pop gnus-newsgroup-headers)
10732 (let ((headers gnus-newsgroup-headers))
10733 (while (and (cdr headers)
10734 (not (= number (mail-header-number (cadr headers)))))
10736 (when (cdr headers)
10737 (setcdr headers (cddr headers))))))
10740 ;;; summary highlights
10743 (defun gnus-highlight-selected-summary ()
10744 "Highlight selected article in summary buffer."
10745 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10746 (when gnus-summary-selected-face
10748 (let* ((beg (progn (beginning-of-line) (point)))
10749 (end (progn (end-of-line) (point)))
10750 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10751 (from (if (get-text-property beg gnus-mouse-face-prop)
10753 (or (next-single-property-change
10754 beg gnus-mouse-face-prop nil end)
10759 (or (next-single-property-change
10760 from gnus-mouse-face-prop nil end)
10762 ;; If no mouse-face prop on line we will have to = from = end,
10763 ;; so we highlight the entire line instead.
10764 (when (= (+ to 2) from)
10767 (if gnus-newsgroup-selected-overlay
10768 ;; Move old overlay.
10770 gnus-newsgroup-selected-overlay from to (current-buffer))
10771 ;; Create new overlay.
10773 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10774 'face gnus-summary-selected-face))))))
10776 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10777 (defun gnus-summary-highlight-line ()
10778 "Highlight current line according to `gnus-summary-highlight'."
10779 (let* ((list gnus-summary-highlight)
10780 (beg (gnus-point-at-bol))
10781 (article (gnus-summary-article-number))
10782 (score (or (cdr (assq (or article gnus-current-article)
10783 gnus-newsgroup-scored))
10784 gnus-summary-default-score 0))
10785 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10786 (inhibit-read-only t)
10787 (default gnus-summary-default-score)
10788 (default-high gnus-summary-default-high-score)
10789 (default-low gnus-summary-default-low-score))
10790 ;; Eval the cars of the lists until we find a match.
10792 (not (eval (caar list))))
10793 (setq list (cdr list)))
10794 (let ((face (cdar list)))
10795 (unless (eq face (get-text-property beg 'face))
10796 (gnus-put-text-property-excluding-characters-with-faces
10797 beg (gnus-point-at-eol) 'face
10798 (setq face (if (boundp face) (symbol-value face) face)))
10799 (when gnus-summary-highlight-line-function
10800 (funcall gnus-summary-highlight-line-function article face))))))
10802 (defun gnus-update-read-articles (group unread &optional compute)
10803 "Update the list of read articles in GROUP.
10804 UNREAD is a sorted list."
10805 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10806 (entry (gnus-gethash group gnus-newsrc-hashtb))
10807 (info (nth 2 entry))
10810 (if (or (not info) (not active))
10811 ;; There is no info on this group if it was, in fact,
10812 ;; killed. Gnus stores no information on killed groups, so
10813 ;; there's nothing to be done.
10814 ;; One could store the information somewhere temporarily,
10815 ;; perhaps... Hmmm...
10817 ;; Remove any negative articles numbers.
10818 (while (and unread (< (car unread) 0))
10819 (setq unread (cdr unread)))
10820 ;; Remove any expired article numbers
10821 (while (and unread (< (car unread) (car active)))
10822 (setq unread (cdr unread)))
10823 ;; Compute the ranges of read articles by looking at the list of
10824 ;; unread articles.
10826 (when (/= (car unread) prev)
10827 (push (if (= prev (1- (car unread))) prev
10828 (cons prev (1- (car unread))))
10830 (setq prev (1+ (car unread)))
10831 (setq unread (cdr unread)))
10832 (when (<= prev (cdr active))
10833 (push (cons prev (cdr active)) read))
10834 (setq read (if (> (length read) 1) (nreverse read) read))
10839 ;; Propagate the read marks to the backend.
10840 (when (gnus-check-backend-function 'request-set-mark group)
10841 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10842 (add (gnus-remove-from-range read (gnus-info-read info))))
10844 (unless (gnus-check-group group)
10845 (error "Can't open server for %s" group))
10846 (gnus-request-set-mark
10847 group (delq nil (list (if add (list add 'add '(read)))
10848 (if del (list del 'del '(read))))))
10850 `(gnus-request-set-mark
10853 (if del (list del 'add '(read)))
10854 (if add (list add 'del '(read))))))))))
10855 (set-buffer gnus-group-buffer)
10856 (gnus-undo-register
10858 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10859 (gnus-info-set-read ',info ',(gnus-info-read info))
10860 (gnus-get-unread-articles-in-group ',info
10861 (gnus-active ,group))
10862 (gnus-group-update-group ,group t)
10864 ;; Enter this list into the group info.
10865 (gnus-info-set-read info read)
10866 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10867 (gnus-get-unread-articles-in-group info (gnus-active group))
10870 (defun gnus-offer-save-summaries ()
10871 "Offer to save all active summary buffers."
10873 ;; Go through all buffers and find all summaries.
10874 (dolist (buffer (buffer-list))
10875 (when (and (setq buffer (buffer-name buffer))
10876 (string-match "Summary" buffer)
10878 (set-buffer buffer)
10879 ;; We check that this is, indeed, a summary buffer.
10880 (and (eq major-mode 'gnus-summary-mode)
10881 ;; Also make sure this isn't bogus.
10882 gnus-newsgroup-prepared
10883 ;; Also make sure that this isn't a
10884 ;; dead summary buffer.
10885 (not gnus-dead-summary-mode))))
10886 (push buffer buffers)))
10887 ;; Go through all these summary buffers and offer to save them.
10891 "Update summary buffer %s? "
10893 (switch-to-buffer buf)
10894 (gnus-summary-exit))
10897 (defun gnus-summary-setup-default-charset ()
10898 "Setup newsgroup default charset."
10899 (if (equal gnus-newsgroup-name "nndraft:drafts")
10900 (setq gnus-newsgroup-charset nil)
10901 (let* ((ignored-charsets
10902 (or gnus-newsgroup-ephemeral-ignored-charsets
10904 (and gnus-newsgroup-name
10905 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10906 gnus-newsgroup-ignored-charsets))))
10907 (setq gnus-newsgroup-charset
10908 (or gnus-newsgroup-ephemeral-charset
10909 (and gnus-newsgroup-name
10910 (gnus-parameter-charset gnus-newsgroup-name))
10911 gnus-default-charset))
10912 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10913 ignored-charsets))))
10919 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10920 "Display the current article buffer fully MIME-buttonized.
10921 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10922 treated as multipart/mixed."
10924 (require 'gnus-art)
10925 (let ((gnus-unbuttonized-mime-types nil)
10926 (gnus-mime-display-multipart-as-mixed show-all-parts))
10927 (gnus-summary-show-article)))
10929 (defun gnus-summary-repair-multipart (article)
10930 "Add a Content-Type header to a multipart article without one."
10931 (interactive (list (gnus-summary-article-number)))
10932 (gnus-with-article article
10933 (message-narrow-to-head)
10934 (message-remove-header "Mime-Version")
10935 (goto-char (point-max))
10936 (insert "Mime-Version: 1.0\n")
10938 (when (search-forward "\n--" nil t)
10939 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10940 (message-narrow-to-head)
10941 (message-remove-header "Content-Type")
10942 (goto-char (point-max))
10943 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10946 (let (gnus-mark-article-hook)
10947 (gnus-summary-select-article t t nil article)))
10949 (defun gnus-summary-toggle-display-buttonized ()
10950 "Toggle the buttonizing of the article buffer."
10952 (require 'gnus-art)
10953 (if (setq gnus-inhibit-mime-unbuttonizing
10954 (not gnus-inhibit-mime-unbuttonizing))
10955 (let ((gnus-unbuttonized-mime-types nil))
10956 (gnus-summary-show-article))
10957 (gnus-summary-show-article)))
10960 ;;; Generic summary marking commands
10963 (defvar gnus-summary-marking-alist
10964 '((read gnus-del-mark "d")
10965 (unread gnus-unread-mark "u")
10966 (ticked gnus-ticked-mark "!")
10967 (dormant gnus-dormant-mark "?")
10968 (expirable gnus-expirable-mark "e"))
10969 "An alist of names/marks/keystrokes.")
10971 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10972 (defvar gnus-summary-mark-map)
10974 (defun gnus-summary-make-all-marking-commands ()
10975 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10976 (dolist (elem gnus-summary-marking-alist)
10977 (apply 'gnus-summary-make-marking-command elem)))
10979 (defun gnus-summary-make-marking-command (name mark keystroke)
10980 (let ((map (make-sparse-keymap)))
10981 (define-key gnus-summary-generic-mark-map keystroke map)
10982 (dolist (lway `((next "next" next nil "n")
10983 (next-unread "next unread" next t "N")
10984 (prev "previous" prev nil "p")
10985 (prev-unread "previous unread" prev t "P")
10986 (nomove "" nil nil ,keystroke)))
10987 (let ((func (gnus-summary-make-marking-command-1
10988 mark (car lway) lway name)))
10989 (setq func (eval func))
10990 (define-key map (nth 4 lway) func)))))
10992 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10994 (format "gnus-summary-put-mark-as-%s%s"
10995 name (if (eq way 'nomove)
10997 (concat "-" (symbol-name way)))))
11000 "Mark the current article as %s%s.
11001 If N, the prefix, then repeat N times.
11002 If N is negative, move in reverse order.
11003 The difference between N and the actual number of articles marked is
11007 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11009 (defun gnus-summary-generic-mark (n mark move unread)
11010 "Mark N articles with MARK."
11011 (unless (eq major-mode 'gnus-summary-mode)
11012 (error "This command can only be used in the summary buffer"))
11013 (gnus-summary-show-thread)
11016 ((eq move 'next) 1)
11017 ((eq move 'prev) -1)
11019 (if (zerop nummove)
11023 nummove (* -1 nummove))))
11024 (while (and (> n 0)
11025 (gnus-summary-mark-article nil mark)
11026 (zerop (gnus-summary-next-subject nummove unread t)))
11029 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11030 (gnus-summary-recenter)
11031 (gnus-summary-position-point)
11032 (gnus-set-mode-line 'summary)
11035 (defun gnus-summary-insert-articles (articles)
11036 (when (setq articles
11037 (gnus-sorted-difference articles
11038 (mapcar (lambda (h)
11039 (mail-header-number h))
11040 gnus-newsgroup-headers)))
11041 (setq gnus-newsgroup-headers
11043 gnus-newsgroup-headers
11044 (gnus-fetch-headers articles)
11045 'gnus-article-sort-by-number))
11046 ;; Suppress duplicates?
11047 (when gnus-suppress-duplicates
11048 (gnus-dup-suppress-articles))
11050 ;; We might want to build some more threads first.
11051 (when (and gnus-fetch-old-headers
11052 (eq gnus-headers-retrieved-by 'nov))
11053 (if (eq gnus-fetch-old-headers 'invisible)
11054 (gnus-build-all-threads)
11055 (gnus-build-old-threads)))
11056 ;; Let the Gnus agent mark articles as read.
11058 (gnus-agent-get-undownloaded-list))
11059 ;; Remove list identifiers from subject
11060 (when gnus-list-identifiers
11061 (gnus-summary-remove-list-identifiers))
11062 ;; First and last article in this newsgroup.
11063 (when gnus-newsgroup-headers
11064 (setq gnus-newsgroup-begin
11065 (mail-header-number (car gnus-newsgroup-headers))
11067 (mail-header-number
11068 (gnus-last-element gnus-newsgroup-headers))))
11069 (when gnus-use-scoring
11070 (gnus-possibly-score-headers))))
11072 (defun gnus-summary-insert-old-articles (&optional all)
11073 "Insert all old articles in this group.
11074 If ALL is non-nil, already read articles become readable.
11075 If ALL is a number, fetch this number of articles."
11078 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11081 (gnus-sorted-difference
11082 (gnus-uncompress-range (list gnus-newsgroup-active))
11084 (setq len (length older))
11089 (setq older (last older all))))
11092 (if (and (numberp gnus-large-newsgroup)
11093 (> len gnus-large-newsgroup))
11094 (let* ((cursor-in-echo-area nil)
11095 (initial (gnus-parameter-large-newsgroup-initial
11096 gnus-newsgroup-name))
11100 "How many articles from %s (%s %d): "
11102 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11103 (if initial "max" "default")
11106 (cons (number-to-string initial)
11108 (unless (string-match "^[ \t]*$" input)
11109 (setq all (string-to-number input))
11111 (setq older (last older all))))))))
11113 (message "No old news.")
11114 (gnus-summary-insert-articles older)
11115 (gnus-summary-limit (gnus-sorted-nunion old older))))
11116 (gnus-summary-position-point)))
11118 (defun gnus-summary-insert-new-articles ()
11119 "Insert all new articles in this group."
11122 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11123 (old-active gnus-newsgroup-active)
11124 (nnmail-fetched-sources (list t))
11126 (setq gnus-newsgroup-active
11127 (gnus-activate-group gnus-newsgroup-name 'scan))
11128 (setq i (cdr gnus-newsgroup-active))
11129 (while (> i (cdr old-active))
11133 (message "No gnus is bad news.")
11134 (gnus-summary-insert-articles new)
11135 (setq gnus-newsgroup-unreads
11136 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11137 (gnus-summary-limit (gnus-sorted-nunion old new))))
11138 (gnus-summary-position-point)))
11140 (gnus-summary-make-all-marking-commands)
11142 (gnus-ems-redefine)
11144 (provide 'gnus-sum)
11146 (run-hooks 'gnus-sum-load-hook)
11148 ;;; gnus-sum.el ends here